From 4525781cf58618212e14bfcaa29b5a6bd2c82b5d Mon Sep 17 00:00:00 2001 From: stephanie sappho lenzo Date: Sat, 20 Apr 2024 16:58:29 -0400 Subject: [PATCH 01/10] attempt to add connect_debug macro --- extension/extension.cpp | 67 ++++++++++++++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 15 deletions(-) diff --git a/extension/extension.cpp b/extension/extension.cpp index 22e54f9..dcee23e 100644 --- a/extension/extension.cpp +++ b/extension/extension.cpp @@ -26,7 +26,16 @@ Connect g_connect; SMEXT_LINK(&g_connect); -ConVar connectVersion("connect_version", SMEXT_CONF_VERSION, FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY, SMEXT_CONF_DESCRIPTION " Version"); +ConVar connect_version("connect_version", SMEXT_CONF_VERSION, FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY, SMEXT_CONF_DESCRIPTION " Version"); +ConVar connect_debug("connect_debug", 0, FCVAR_NONE, "connect_debug"); + +#define CONNECT_DEBUG(pMsg, ...) \ + if (connect_debug.GetBool()) \ + { \ + g_SMAPI->ConPrintf(pMsg, __VA_ARGS__); \ + } \ + else {} + IGameConfig *g_pGameConf = NULL; @@ -157,8 +166,10 @@ int g_nEndAuthSessionOffset = 0; EBeginAuthSessionResult BeginAuthSession(const void *pAuthTicket, int cbAuthTicket, CSteamID steamID) { - if (!g_pSteam3Server || !g_pSteam3Server->m_pSteamGameServer || g_nBeginAuthSessionOffset == 0) - return k_EBeginAuthSessionResultOK; + if (!g_pSteam3Server || !g_pSteam3Server->m_pSteamGameServer || g_nBeginAuthSessionOffset == 0) + { + return k_EBeginAuthSessionResultOK; + } void **this_ptr = *(void ***)&g_pSteam3Server->m_pSteamGameServer; void **vtable = *(void ***)g_pSteam3Server->m_pSteamGameServer; @@ -178,7 +189,7 @@ EBeginAuthSessionResult BeginAuthSession(const void *pAuthTicket, int cbAuthTick u.s.adjustor = 0; #else void *addr; - } u; + } u = {}; u.addr = func; #endif @@ -209,7 +220,7 @@ void EndAuthSession(CSteamID steamID) u.s.adjustor = 0; #else void *addr; - } u; + } u = {}; u.addr = func; #endif @@ -240,6 +251,28 @@ ret name##Class::name(p1type p1name, p2type p2name, p3type p3name, p4type p4name DETOUR_DECL_MEMBER9(CBaseServer__ConnectClient, IClient*, netadr_t&, address, int, nProtocol, int, iChallenge, int, iClientChallenge, int, nAuthProtocol, const char *, pchName, const char *, pchPassword, const char *, pCookie, int, cbCookie) { + CONNECT_DEBUG( + "this == %p\n" + "netadr_t& == %p\n", // i don't think this should be %p + "nProtocol == %i\n" + "iChallenge == %i\n" + "iCliChlnge == %i\n" + "nAuthProto == %i\n" + "pchName == %s\n" // probably should sani this b4 printing to console... + "pchPasswd == %s\n" // ^ + "pCookie == %p\n" + "cbCookie == %i\n", + (CBaseServer*)this, + address, + nProtocol, + iChallenge, + iClientChallenge, + nAuthProtocol, + pchName, + pchPassword, + pCookie, + cbCookie + ); if (nAuthProtocol != k_EAuthProtocolSteam) { // This is likely a SourceTV client, we don't want to interfere here. @@ -248,8 +281,10 @@ DETOUR_DECL_MEMBER9(CBaseServer__ConnectClient, IClient*, netadr_t&, address, in g_pBaseServer = (CBaseServer *)this; - if (pCookie == NULL || (size_t)cbCookie < sizeof(uint64)) + if (pCookie == NULL || (size_t)cbCookie < sizeof(uint64)) { + CONNECT_DEBUG("pCookie = %p || (size_t)cbCookie = %x < %x == sizeof(uint64)", + pCookie, (size_t)cbCookie, sizeof(uint64)); RejectConnection(address, iClientChallenge, "#GameUI_ServerRejectInvalidSteamCertLen"); return NULL; } @@ -268,6 +303,8 @@ DETOUR_DECL_MEMBER9(CBaseServer__ConnectClient, IClient*, netadr_t&, address, in EBeginAuthSessionResult result = BeginAuthSession(pvTicket, cbTicket, g_lastClientSteamID); if (result != k_EBeginAuthSessionResultOK) { + CONNECT_DEBUG("EBeginAuthSessionResult result == %i", static_cast(result)); + RejectConnection(address, iClientChallenge, "#GameUI_ServerRejectSteam"); return NULL; } @@ -359,12 +396,12 @@ bool Connect::SDK_OnLoad(char *error, size_t maxlen, bool late) return false; } - //META_CONPRINTF("CheckMasterServerRequestRestart: %p\n", address); + CONNECT_DEBUG("CheckMasterServerRequestRestart: %p\n", address); address = (void *)((intptr_t)address + 1); // Skip CALL opcode intptr_t offset = (intptr_t)(*(void **)address); // Get offset g_pSteam3ServerFunc = (Steam3ServerFunc)((intptr_t)address + offset + sizeof(intptr_t)); - //META_CONPRINTF("Steam3Server: %p\n", g_pSteam3ServerFunc); + CONNECT_DEBUG("Steam3Server: %p\n", g_pSteam3ServerFunc); #endif g_pSteam3Server = Steam3Server(); @@ -374,13 +411,13 @@ bool Connect::SDK_OnLoad(char *error, size_t maxlen, bool late) return false; } - /* - META_CONPRINTF("ISteamGameServer: %p\n", g_pSteam3Server->m_pSteamGameServer); - META_CONPRINTF("ISteamUtils: %p\n", g_pSteam3Server->m_pSteamGameServerUtils); - META_CONPRINTF("ISteamMasterServerUpdater: %p\n", g_pSteam3Server->m_pSteamMasterServerUpdater); - META_CONPRINTF("ISteamNetworking: %p\n", g_pSteam3Server->m_pSteamGameServerNetworking); - META_CONPRINTF("ISteamGameServerStats: %p\n", g_pSteam3Server->m_pSteamGameServerStats); - */ + + CONNECT_DEBUG("ISteamGameServer: %p\n", g_pSteam3Server->m_pSteamGameServer); + CONNECT_DEBUG("ISteamUtils: %p\n", g_pSteam3Server->m_pSteamGameServerUtils); + // CONNECT_DEBUG("ISteamMasterServerUpdater: %p\n", g_pSteam3Server->m_pSteamMasterServerUpdater); + CONNECT_DEBUG("ISteamNetworking: %p\n", g_pSteam3Server->m_pSteamGameServerNetworking); + CONNECT_DEBUG("ISteamGameServerStats: %p\n", g_pSteam3Server->m_pSteamGameServerStats); + if (!g_pGameConf->GetOffset("ISteamGameServer__BeginAuthSession", &g_nBeginAuthSessionOffset) || g_nBeginAuthSessionOffset == 0) { From b90ef97c585fd413895cc74508d5d67570e8a8f3 Mon Sep 17 00:00:00 2001 From: sappho Date: Sat, 20 Apr 2024 17:09:35 -0400 Subject: [PATCH 02/10] Try making ci upload artifacts... --- .github/workflows/ci.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d58068a..9deee7d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -162,4 +162,16 @@ jobs: if test ${HTTP_CODE} -ne 200; then exit ${HTTP_CODE} fi - echo "Upload successful!" \ No newline at end of file + echo "Upload successful!" + + - name: Upload a Build Artifact + uses: actions/upload-artifact@v4.3.2 + with: + # Artifact name + # name: # optional, default is artifact + # A file, directory or wildcard pattern that describes what to upload + path: ${{ env.ZIP_FILENAME }} + # The desired behavior if no files are found using the provided path. + if-no-files-found: error + # Duration after which artifact will expire in days. 0 means using default retention. + retention-days: 14 From 3f586f0ff9b7c1ee621dac9f446812d151306bd2 Mon Sep 17 00:00:00 2001 From: sappho Date: Sat, 20 Apr 2024 17:11:17 -0400 Subject: [PATCH 03/10] working-directory --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9deee7d..940ca16 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -169,6 +169,7 @@ jobs: with: # Artifact name # name: # optional, default is artifact + working-directory: extension/build/package # A file, directory or wildcard pattern that describes what to upload path: ${{ env.ZIP_FILENAME }} # The desired behavior if no files are found using the provided path. From 7c3f42a2ec6de7686453d265547e93fbb43f001e Mon Sep 17 00:00:00 2001 From: sappho Date: Sat, 20 Apr 2024 17:12:56 -0400 Subject: [PATCH 04/10] working-directory doesn't work with upload artifact action... --- .github/workflows/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 940ca16..ecbe05d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -169,9 +169,8 @@ jobs: with: # Artifact name # name: # optional, default is artifact - working-directory: extension/build/package # A file, directory or wildcard pattern that describes what to upload - path: ${{ env.ZIP_FILENAME }} + path: extension/build/package/${{ env.ZIP_FILENAME }} # The desired behavior if no files are found using the provided path. if-no-files-found: error # Duration after which artifact will expire in days. 0 means using default retention. From 56e2ca17487dae65bd9ffd2c01b9a374f29acd36 Mon Sep 17 00:00:00 2001 From: sappho Date: Sat, 20 Apr 2024 17:18:01 -0400 Subject: [PATCH 05/10] last ditch effort to update `path` before i get out the `pwd` and `tree` --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ecbe05d..d499d46 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -163,14 +163,14 @@ jobs: exit ${HTTP_CODE} fi echo "Upload successful!" - + - name: Upload a Build Artifact uses: actions/upload-artifact@v4.3.2 with: # Artifact name # name: # optional, default is artifact # A file, directory or wildcard pattern that describes what to upload - path: extension/build/package/${{ env.ZIP_FILENAME }} + path: ${{ github.workspace }}/extension/build/package/${{ env.ZIP_FILENAME }} # The desired behavior if no files are found using the provided path. if-no-files-found: error # Duration after which artifact will expire in days. 0 means using default retention. From a41c4f90cccd0aafbb505d83edddccf74db02602 Mon Sep 17 00:00:00 2001 From: sappho Date: Sat, 20 Apr 2024 17:20:13 -0400 Subject: [PATCH 06/10] always pkg release... --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d499d46..626c2c2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -145,7 +145,7 @@ jobs: run: Compress-Archive -Path * -Destination ${{ env.ZIP_FILENAME }} - name: Package release - if: github.event_name == 'push' && github.ref == 'refs/heads/action' && startsWith(matrix.os, 'ubuntu-latest') + # if: github.event_name == 'push' && github.ref == 'refs/heads/action' && startsWith(matrix.os, 'ubuntu-latest') working-directory: extension/build/package run: zip -r "${{ env.ZIP_FILENAME }}" . From a4cfc99114adcf2a1e4589b03fff02890f9750e6 Mon Sep 17 00:00:00 2001 From: sappho Date: Sat, 20 Apr 2024 17:23:52 -0400 Subject: [PATCH 07/10] this is so ugly --- .github/workflows/ci.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 626c2c2..c892389 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -147,7 +147,10 @@ jobs: - name: Package release # if: github.event_name == 'push' && github.ref == 'refs/heads/action' && startsWith(matrix.os, 'ubuntu-latest') working-directory: extension/build/package - run: zip -r "${{ env.ZIP_FILENAME }}" . + run: | + zip -r "${{ env.ZIP_FILENAME }}" . + cp "${{ env.ZIP_FILENAME }}" "${{ matrix.os }}_${{ matrix.cc }}_${{ env.ZIP_FILENAME }}" + - name: Upload release if: github.event_name == 'push' && github.ref == 'refs/heads/action' && (startsWith(matrix.os, 'ubuntu-latest') || startsWith(matrix.os, 'windows-latest')) @@ -168,9 +171,10 @@ jobs: uses: actions/upload-artifact@v4.3.2 with: # Artifact name - # name: # optional, default is artifact + name: ${{ matrix.os }} - ${{ matrix.cc }} + # optional, default is artifact # A file, directory or wildcard pattern that describes what to upload - path: ${{ github.workspace }}/extension/build/package/${{ env.ZIP_FILENAME }} + path: ${{ github.workspace }}/extension/build/package/${{ matrix.os }}_${{ matrix.cc }}_${{ env.ZIP_FILENAME }} # The desired behavior if no files are found using the provided path. if-no-files-found: error # Duration after which artifact will expire in days. 0 means using default retention. From d3f4a8f156d22cc46ec4eb80560ae7e0f3790887 Mon Sep 17 00:00:00 2001 From: sappho Date: Sat, 20 Apr 2024 17:25:47 -0400 Subject: [PATCH 08/10] cleaner artifact names! --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c892389..0e88d71 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -171,7 +171,7 @@ jobs: uses: actions/upload-artifact@v4.3.2 with: # Artifact name - name: ${{ matrix.os }} - ${{ matrix.cc }} + name: ${{ matrix.os }}_${{ matrix.cc }}_${{ env.ZIP_FILENAME }} # optional, default is artifact # A file, directory or wildcard pattern that describes what to upload path: ${{ github.workspace }}/extension/build/package/${{ matrix.os }}_${{ matrix.cc }}_${{ env.ZIP_FILENAME }} From 4b40d377c1637339451e3f3b84d9d41813866ac2 Mon Sep 17 00:00:00 2001 From: sappho Date: Sat, 20 Apr 2024 18:07:12 -0400 Subject: [PATCH 09/10] Update windows artifacts --- .github/workflows/ci.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e88d71..2c2c104 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -139,18 +139,20 @@ jobs: echo "ZIP_FILENAME=${ZIP_FILENAME}" >> $GITHUB_ENV + # if: github.event_name == 'push' && github.ref == 'refs/heads/action' && - name: Package release - Windows - if: github.event_name == 'push' && github.ref == 'refs/heads/action' && startsWith(matrix.os, 'windows-latest') + if: startsWith(matrix.os, 'windows-') working-directory: extension/build/package - run: Compress-Archive -Path * -Destination ${{ env.ZIP_FILENAME }} + run: | + Compress-Archive -Path * -Destination ${{ env.ZIP_FILENAME }} + Copy-Item -Path ${{ env.ZIP_FILENAME }} -Destination ${{ matrix.os }}_${{ matrix.cc }}_${{ env.ZIP_FILENAME }} - - name: Package release - # if: github.event_name == 'push' && github.ref == 'refs/heads/action' && startsWith(matrix.os, 'ubuntu-latest') + - name: Package release - Linux + if: startsWith(matrix.os, 'ubuntu-') working-directory: extension/build/package run: | zip -r "${{ env.ZIP_FILENAME }}" . cp "${{ env.ZIP_FILENAME }}" "${{ matrix.os }}_${{ matrix.cc }}_${{ env.ZIP_FILENAME }}" - - name: Upload release if: github.event_name == 'push' && github.ref == 'refs/heads/action' && (startsWith(matrix.os, 'ubuntu-latest') || startsWith(matrix.os, 'windows-latest')) From 27173dc97c5013c4f9b78723b66bd6626ba742ee Mon Sep 17 00:00:00 2001 From: stephanie sappho lenzo Date: Sat, 20 Apr 2024 18:53:07 -0400 Subject: [PATCH 10/10] revert 4525781 --- extension/extension.cpp | 67 +++++++++-------------------------------- 1 file changed, 15 insertions(+), 52 deletions(-) diff --git a/extension/extension.cpp b/extension/extension.cpp index dcee23e..22e54f9 100644 --- a/extension/extension.cpp +++ b/extension/extension.cpp @@ -26,16 +26,7 @@ Connect g_connect; SMEXT_LINK(&g_connect); -ConVar connect_version("connect_version", SMEXT_CONF_VERSION, FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY, SMEXT_CONF_DESCRIPTION " Version"); -ConVar connect_debug("connect_debug", 0, FCVAR_NONE, "connect_debug"); - -#define CONNECT_DEBUG(pMsg, ...) \ - if (connect_debug.GetBool()) \ - { \ - g_SMAPI->ConPrintf(pMsg, __VA_ARGS__); \ - } \ - else {} - +ConVar connectVersion("connect_version", SMEXT_CONF_VERSION, FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY, SMEXT_CONF_DESCRIPTION " Version"); IGameConfig *g_pGameConf = NULL; @@ -166,10 +157,8 @@ int g_nEndAuthSessionOffset = 0; EBeginAuthSessionResult BeginAuthSession(const void *pAuthTicket, int cbAuthTicket, CSteamID steamID) { - if (!g_pSteam3Server || !g_pSteam3Server->m_pSteamGameServer || g_nBeginAuthSessionOffset == 0) - { - return k_EBeginAuthSessionResultOK; - } + if (!g_pSteam3Server || !g_pSteam3Server->m_pSteamGameServer || g_nBeginAuthSessionOffset == 0) + return k_EBeginAuthSessionResultOK; void **this_ptr = *(void ***)&g_pSteam3Server->m_pSteamGameServer; void **vtable = *(void ***)g_pSteam3Server->m_pSteamGameServer; @@ -189,7 +178,7 @@ EBeginAuthSessionResult BeginAuthSession(const void *pAuthTicket, int cbAuthTick u.s.adjustor = 0; #else void *addr; - } u = {}; + } u; u.addr = func; #endif @@ -220,7 +209,7 @@ void EndAuthSession(CSteamID steamID) u.s.adjustor = 0; #else void *addr; - } u = {}; + } u; u.addr = func; #endif @@ -251,28 +240,6 @@ ret name##Class::name(p1type p1name, p2type p2name, p3type p3name, p4type p4name DETOUR_DECL_MEMBER9(CBaseServer__ConnectClient, IClient*, netadr_t&, address, int, nProtocol, int, iChallenge, int, iClientChallenge, int, nAuthProtocol, const char *, pchName, const char *, pchPassword, const char *, pCookie, int, cbCookie) { - CONNECT_DEBUG( - "this == %p\n" - "netadr_t& == %p\n", // i don't think this should be %p - "nProtocol == %i\n" - "iChallenge == %i\n" - "iCliChlnge == %i\n" - "nAuthProto == %i\n" - "pchName == %s\n" // probably should sani this b4 printing to console... - "pchPasswd == %s\n" // ^ - "pCookie == %p\n" - "cbCookie == %i\n", - (CBaseServer*)this, - address, - nProtocol, - iChallenge, - iClientChallenge, - nAuthProtocol, - pchName, - pchPassword, - pCookie, - cbCookie - ); if (nAuthProtocol != k_EAuthProtocolSteam) { // This is likely a SourceTV client, we don't want to interfere here. @@ -281,10 +248,8 @@ DETOUR_DECL_MEMBER9(CBaseServer__ConnectClient, IClient*, netadr_t&, address, in g_pBaseServer = (CBaseServer *)this; - if (pCookie == NULL || (size_t)cbCookie < sizeof(uint64)) + if (pCookie == NULL || (size_t)cbCookie < sizeof(uint64)) { - CONNECT_DEBUG("pCookie = %p || (size_t)cbCookie = %x < %x == sizeof(uint64)", - pCookie, (size_t)cbCookie, sizeof(uint64)); RejectConnection(address, iClientChallenge, "#GameUI_ServerRejectInvalidSteamCertLen"); return NULL; } @@ -303,8 +268,6 @@ DETOUR_DECL_MEMBER9(CBaseServer__ConnectClient, IClient*, netadr_t&, address, in EBeginAuthSessionResult result = BeginAuthSession(pvTicket, cbTicket, g_lastClientSteamID); if (result != k_EBeginAuthSessionResultOK) { - CONNECT_DEBUG("EBeginAuthSessionResult result == %i", static_cast(result)); - RejectConnection(address, iClientChallenge, "#GameUI_ServerRejectSteam"); return NULL; } @@ -396,12 +359,12 @@ bool Connect::SDK_OnLoad(char *error, size_t maxlen, bool late) return false; } - CONNECT_DEBUG("CheckMasterServerRequestRestart: %p\n", address); + //META_CONPRINTF("CheckMasterServerRequestRestart: %p\n", address); address = (void *)((intptr_t)address + 1); // Skip CALL opcode intptr_t offset = (intptr_t)(*(void **)address); // Get offset g_pSteam3ServerFunc = (Steam3ServerFunc)((intptr_t)address + offset + sizeof(intptr_t)); - CONNECT_DEBUG("Steam3Server: %p\n", g_pSteam3ServerFunc); + //META_CONPRINTF("Steam3Server: %p\n", g_pSteam3ServerFunc); #endif g_pSteam3Server = Steam3Server(); @@ -411,13 +374,13 @@ bool Connect::SDK_OnLoad(char *error, size_t maxlen, bool late) return false; } - - CONNECT_DEBUG("ISteamGameServer: %p\n", g_pSteam3Server->m_pSteamGameServer); - CONNECT_DEBUG("ISteamUtils: %p\n", g_pSteam3Server->m_pSteamGameServerUtils); - // CONNECT_DEBUG("ISteamMasterServerUpdater: %p\n", g_pSteam3Server->m_pSteamMasterServerUpdater); - CONNECT_DEBUG("ISteamNetworking: %p\n", g_pSteam3Server->m_pSteamGameServerNetworking); - CONNECT_DEBUG("ISteamGameServerStats: %p\n", g_pSteam3Server->m_pSteamGameServerStats); - + /* + META_CONPRINTF("ISteamGameServer: %p\n", g_pSteam3Server->m_pSteamGameServer); + META_CONPRINTF("ISteamUtils: %p\n", g_pSteam3Server->m_pSteamGameServerUtils); + META_CONPRINTF("ISteamMasterServerUpdater: %p\n", g_pSteam3Server->m_pSteamMasterServerUpdater); + META_CONPRINTF("ISteamNetworking: %p\n", g_pSteam3Server->m_pSteamGameServerNetworking); + META_CONPRINTF("ISteamGameServerStats: %p\n", g_pSteam3Server->m_pSteamGameServerStats); + */ if (!g_pGameConf->GetOffset("ISteamGameServer__BeginAuthSession", &g_nBeginAuthSessionOffset) || g_nBeginAuthSessionOffset == 0) {