we were missing the MHook_BeginAuthSession. for some unknown reason the hook dies, so its constantly reapplied when changing map.
This commit is contained in:
parent
22cbf25c05
commit
2d022bf65b
@ -93,6 +93,7 @@ ConVar *g_pSvTags;
|
||||
|
||||
IGameConfig *g_pGameConf = NULL;
|
||||
IForward *g_pConnectForward = NULL;
|
||||
IForward *g_pOnBeginAuthSessionResult = NULL;
|
||||
IGameEventManager2 *g_pGameEvents = NULL;
|
||||
ITimer *g_pConnectTimer = NULL;
|
||||
ISDKTools *g_pSDKTools = NULL;
|
||||
@ -236,6 +237,8 @@ Steam3ServerFunc g_pSteam3ServerFunc = NULL;
|
||||
RejectConnectionFunc g_pRejectConnectionFunc = NULL;
|
||||
SetSteamIDFunc g_pSetSteamIDFunc = NULL;
|
||||
|
||||
bool g_bSuppressBeginAuthSession = false;
|
||||
|
||||
CSteam3Server *Steam3Server()
|
||||
{
|
||||
if(!g_pSteam3ServerFunc)
|
||||
@ -268,10 +271,47 @@ void SetSteamID(CBaseClient *pClient, const CSteamID &steamID)
|
||||
#endif
|
||||
}
|
||||
|
||||
class VFuncEmptyClass{};
|
||||
|
||||
int g_nBeginAuthSessionOffset = 0;
|
||||
const void* g_lastAuthTicket;
|
||||
int g_lastcbAuthTicket;
|
||||
CSteamID g_lastClientSteamID;
|
||||
|
||||
SH_DECL_MANUALHOOK3(MHook_BeginAuthSession, 0, 0, 0, EBeginAuthSessionResult, const void *, int, CSteamID);
|
||||
|
||||
//took hook from nide
|
||||
EBeginAuthSessionResult Hook_BeginAuthSession(const void *pAuthTicket, int cbAuthTicket, CSteamID steamID)
|
||||
{
|
||||
if (!g_bSuppressBeginAuthSession)
|
||||
{
|
||||
RETURN_META_VALUE(MRES_IGNORED, k_EBeginAuthSessionResultOK);
|
||||
}
|
||||
g_bSuppressBeginAuthSession = false;
|
||||
|
||||
if (strcmp(steamID.Render(), g_lastClientSteamID.Render()) == 0
|
||||
&& g_lastAuthTicket == pAuthTicket
|
||||
&& g_lastcbAuthTicket == cbAuthTicket)
|
||||
{
|
||||
// Let the server know everything is fine
|
||||
// g_pSM->LogMessage(myself, "You alright ;)");
|
||||
RETURN_META_VALUE(MRES_SUPERCEDE, k_EBeginAuthSessionResultOK);
|
||||
}
|
||||
|
||||
RETURN_META_VALUE(MRES_IGNORED, k_EBeginAuthSessionResultDuplicateRequest);
|
||||
}
|
||||
|
||||
EBeginAuthSessionResult BeginAuthSession(const void *pAuthTicket, int cbAuthTicket, CSteamID steamID)
|
||||
{
|
||||
if (g_nBeginAuthSessionOffset == 0)
|
||||
{
|
||||
return k_EBeginAuthSessionResultInvalidTicket;
|
||||
}
|
||||
|
||||
if(!g_pSteam3Server || !g_pSteam3Server->m_pSteamGameServer)
|
||||
{
|
||||
return k_EBeginAuthSessionResultOK;
|
||||
}
|
||||
|
||||
return g_pSteam3Server->m_pSteamGameServer->BeginAuthSession(pAuthTicket, cbAuthTicket, steamID);
|
||||
}
|
||||
@ -349,7 +389,6 @@ public:
|
||||
StringHashMap<ConnectClientStorage> g_ConnectClientStorage;
|
||||
|
||||
bool g_bEndAuthSessionOnRejectConnection = false;
|
||||
CSteamID g_lastClientSteamID;
|
||||
bool g_bSuppressCheckChallengeType = false;
|
||||
|
||||
DETOUR_DECL_MEMBER1(CSteam3Server__OnValidateAuthTicketResponse, int, ValidateAuthTicketResponse_t *, pResponse)
|
||||
@ -381,6 +420,8 @@ DETOUR_DECL_MEMBER1(CSteam3Server__OnValidateAuthTicketResponse, int, ValidateAu
|
||||
return DETOUR_MEMBER_CALL(CSteam3Server__OnValidateAuthTicketResponse)(pResponse);
|
||||
}
|
||||
|
||||
void *g_pLastHookedSteamGameServer = NULL;
|
||||
|
||||
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)
|
||||
{
|
||||
if(nAuthProtocol != k_EAuthProtocolSteam)
|
||||
@ -389,6 +430,24 @@ DETOUR_DECL_MEMBER9(CBaseServer__ConnectClient, IClient *, netadr_t &, address,
|
||||
return DETOUR_MEMBER_CALL(CBaseServer__ConnectClient)(address, nProtocol, iChallenge, iClientChallenge, nAuthProtocol, pchName, pchPassword, pCookie, cbCookie);
|
||||
}
|
||||
|
||||
if (g_pSteam3Server->m_pSteamGameServer != g_pLastHookedSteamGameServer)
|
||||
{
|
||||
//november 2025 edit.
|
||||
//this just feels wrong man. instead the hook is supposed to survive i guess. but this ensures its reset once on every map so it works.
|
||||
//g_pSM->LogMessage(myself, "Steam GameServer pointer changed! Old: %p, New: %p", g_pLastHookedSteamGameServer, g_pSteam3Server->m_pSteamGameServer);
|
||||
// Remove old hook if it exists
|
||||
if (g_pLastHookedSteamGameServer != NULL)
|
||||
{
|
||||
SH_REMOVE_MANUALHOOK(MHook_BeginAuthSession, g_pLastHookedSteamGameServer, SH_STATIC(Hook_BeginAuthSession), true);
|
||||
}
|
||||
|
||||
// Add hook to the new object
|
||||
SH_MANUALHOOK_RECONFIGURE(MHook_BeginAuthSession, g_nBeginAuthSessionOffset, 0, 0);
|
||||
SH_ADD_MANUALHOOK(MHook_BeginAuthSession, g_pSteam3Server->m_pSteamGameServer, SH_STATIC(Hook_BeginAuthSession), true);
|
||||
|
||||
g_pLastHookedSteamGameServer = g_pSteam3Server->m_pSteamGameServer;
|
||||
}
|
||||
|
||||
g_pBaseServer = (CBaseServer *)this;
|
||||
|
||||
if(pCookie == NULL || (size_t)cbCookie < sizeof(uint64))
|
||||
@ -409,6 +468,8 @@ DETOUR_DECL_MEMBER9(CBaseServer__ConnectClient, IClient *, netadr_t &, address,
|
||||
|
||||
g_bEndAuthSessionOnRejectConnection = true;
|
||||
g_lastClientSteamID = CSteamID(ullSteamID);
|
||||
g_lastcbAuthTicket = cbTicket;
|
||||
g_lastAuthTicket = pvTicket;
|
||||
|
||||
char aSteamID[32];
|
||||
strlcpy(aSteamID, g_lastClientSteamID.Render(), sizeof(aSteamID));
|
||||
@ -515,8 +576,9 @@ DETOUR_DECL_MEMBER9(CBaseServer__ConnectClient, IClient *, netadr_t &, address,
|
||||
|
||||
// k_OnClientPreConnectEx_Accept
|
||||
g_bSuppressCheckChallengeType = true;
|
||||
g_bSuppressBeginAuthSession = true;
|
||||
IClient *pClient = DETOUR_MEMBER_CALL(CBaseServer__ConnectClient)(address, nProtocol, iChallenge, iClientChallenge, nAuthProtocol, pchName, pchPassword, pCookie, cbCookie);
|
||||
|
||||
g_bSuppressBeginAuthSession = false;
|
||||
if(pClient)
|
||||
strlcpy(g_ClientSteamIDMap[pClient->GetPlayerSlot() + 1], aSteamID, sizeof(*g_ClientSteamIDMap));
|
||||
|
||||
@ -833,6 +895,19 @@ bool Connect::SDK_OnLoad(char *error, size_t maxlen, bool late)
|
||||
META_CONPRINTF("ISteamGameServerStats: %p\n", g_pSteam3Server->m_pSteamGameServerStats);
|
||||
*/
|
||||
|
||||
if (!g_pGameConf->GetOffset("ISteamGameServer__BeginAuthSession", &g_nBeginAuthSessionOffset) || g_nBeginAuthSessionOffset == 0)
|
||||
{
|
||||
snprintf(error, maxlen, "Failed to find ISteamGameServer__BeginAuthSession offset.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
SH_MANUALHOOK_RECONFIGURE(MHook_BeginAuthSession, g_nBeginAuthSessionOffset, 0, 0);
|
||||
if (SH_ADD_MANUALHOOK(MHook_BeginAuthSession, g_pSteam3Server->m_pSteamGameServer, SH_STATIC(Hook_BeginAuthSession), true) == 0)
|
||||
{
|
||||
snprintf(error, maxlen, "Failed to setup ISteamGameServer__BeginAuthSession hook.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!g_pGameConf->GetMemSig("s_queryRateChecker", &s_queryRateChecker) || !s_queryRateChecker)
|
||||
{
|
||||
snprintf(error, maxlen, "Failed to find s_queryRateChecker address.\n");
|
||||
@ -907,6 +982,8 @@ bool Connect::SDK_OnLoad(char *error, size_t maxlen, bool late)
|
||||
|
||||
g_pConnectForward = g_pForwards->CreateForward("OnClientPreConnectEx", ET_LowEvent, 5, NULL, Param_String, Param_String, Param_String, Param_String, Param_String);
|
||||
|
||||
g_pOnBeginAuthSessionResult = g_pForwards->CreateForward("OnBeginAuthSessionResult", ET_Ignore, 2, NULL, Param_String, Param_Cell);
|
||||
|
||||
g_pGameEvents->AddListener(&g_ConnectEvents, "player_connect", true);
|
||||
g_pGameEvents->AddListener(&g_ConnectEvents, "player_disconnect", true);
|
||||
g_pGameEvents->AddListener(&g_ConnectEvents, "player_changename", true);
|
||||
@ -964,6 +1041,9 @@ void Connect::SDK_OnUnload()
|
||||
g_Detour_CSteam3Server__OnValidateAuthTicketResponse = NULL;
|
||||
}
|
||||
|
||||
if (g_pOnBeginAuthSessionResult)
|
||||
g_pForwards->ReleaseForward(g_pOnBeginAuthSessionResult);
|
||||
|
||||
g_pGameEvents->RemoveListener(&g_ConnectEvents);
|
||||
|
||||
playerhelpers->RemoveClientListener(this);
|
||||
@ -992,7 +1072,9 @@ cell_t ClientPreConnectEx(IPluginContext *pContext, const cell_t *params)
|
||||
|
||||
ConnectClientStorage Storage;
|
||||
if(!g_ConnectClientStorage.retrieve(pSteamID, &Storage))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(retVal == 0)
|
||||
{
|
||||
|
||||
@ -4,8 +4,73 @@
|
||||
{
|
||||
"#supported"
|
||||
{
|
||||
"engine" "orangebox_valve"
|
||||
"engine" "dods"
|
||||
"engine" "css"
|
||||
"engine" "hl2dm"
|
||||
"engine" "tf2"
|
||||
}
|
||||
|
||||
"Offsets"
|
||||
{
|
||||
"ISteamGameServer__BeginAuthSession"
|
||||
{
|
||||
"linux" "29"
|
||||
"linux64" "29"
|
||||
"windows" "29"
|
||||
}
|
||||
|
||||
"ISteamGameServer__EndAuthSession"
|
||||
{
|
||||
"linux" "30"
|
||||
"linux64" "30"
|
||||
"windows" "30"
|
||||
}
|
||||
}
|
||||
|
||||
"Signatures"
|
||||
{
|
||||
"Steam3Server"
|
||||
{
|
||||
"library" "engine"
|
||||
"linux" "@_Z12Steam3Serverv"
|
||||
"linux64" "@_Z12Steam3Serverv"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"#default"
|
||||
{
|
||||
"#supported"
|
||||
{
|
||||
"engine" "dods"
|
||||
"engine" "css"
|
||||
"engine" "hl2dm"
|
||||
"engine" "tf2"
|
||||
}
|
||||
|
||||
"Offsets"
|
||||
{
|
||||
"ISteamGameServer__BeginAuthSession"
|
||||
{
|
||||
"linux" "26"
|
||||
"linux64" "26"
|
||||
"windows" "26"
|
||||
"windows64" "26"
|
||||
}
|
||||
|
||||
"ISteamGameServer__EndAuthSession"
|
||||
{
|
||||
"linux" "27"
|
||||
"linux64" "27"
|
||||
"windows" "27"
|
||||
"windows64" "27"
|
||||
}
|
||||
|
||||
"CheckMasterServerRequestRestart_Steam3ServerFuncOffset"
|
||||
{
|
||||
"windows" "240"
|
||||
"windows64" "299"
|
||||
}
|
||||
}
|
||||
|
||||
"Signatures"
|
||||
@ -14,8 +79,9 @@
|
||||
{
|
||||
"library" "engine"
|
||||
"linux" "@_ZN11CBaseServer13ConnectClientER8netadr_siiiiPKcS3_S3_i"
|
||||
"mac" "@_ZN11CBaseServer13ConnectClientER8netadr_siiiiPKcS3_S3_i"
|
||||
"windows" "\x55\x8B\xEC\x81\xEC\x04\x05\x00\x00\x56\x68\x2A\x2A\x2A\x2A\x8B\xF1"
|
||||
"linux64" "@_ZN11CBaseServer13ConnectClientER8netadr_siiiiPKcS3_S3_i"
|
||||
"windows" "\x55\x8B\xEC\x81\xEC\x24\x05\x00\x00\x53\x56\x57\x68\x2A\x2A\x2A\x2A"
|
||||
"windows64" "\x48\x89\x5C\x24\x2A\x44\x89\x4C\x24\x2A\x55\x56\x57\x41\x54\x41\x55\x41\x56\x41\x57\x48\x81\xEC\x80\x05\x00\x00"
|
||||
}
|
||||
|
||||
"CBaseServer__CheckChallengeType"
|
||||
@ -30,29 +96,37 @@
|
||||
{
|
||||
"library" "engine"
|
||||
"linux" "@_ZN11CBaseServer16RejectConnectionERK8netadr_siPKc"
|
||||
"mac" "@_ZN11CBaseServer16RejectConnectionERK8netadr_siPKc"
|
||||
"windows" "\x55\x8B\xEC\x81\xEC\x04\x05\x00\x00\x56\x6A\xFF"
|
||||
"linux64" "@_ZN11CBaseServer16RejectConnectionERK8netadr_siPKc"
|
||||
"windows" "\x55\x8B\xEC\x81\xEC\x04\x05\x00\x00\x57"
|
||||
"windows64" "\x48\x89\x5C\x24\x2A\x48\x89\x6C\x24\x2A\x48\x89\x74\x24\x2A\x57\x48\x81\xEC\x50\x05\x00\x00"
|
||||
}
|
||||
|
||||
"CBaseClient__SetSteamID"
|
||||
{
|
||||
"library" "engine"
|
||||
"linux" "@_ZN11CBaseClient10SetSteamIDERK8CSteamID"
|
||||
"mac" "@_ZN11CBaseClient10SetSteamIDERK8CSteamID"
|
||||
"windows" "\x55\x8B\xEC\x8B\x55\x08\x8B\x02\x89\x41\x59\x8B\x42\x04"
|
||||
"linux64" "@_ZN11CBaseClient10SetSteamIDERK8CSteamID"
|
||||
"windows" "\x55\x8B\xEC\x56\x8B\xF1\x57\x8B\x7D\x08\x8D\x4E\x04"
|
||||
"windows64" "\x48\x89\x5C\x24\x2A\x57\x48\x83\xEC\x20\x48\x8B\x02\x48\x8B\xD9\x48\x89\x41"
|
||||
}
|
||||
|
||||
"CBaseServer__CheckMasterServerRequestRestart"
|
||||
{
|
||||
"library" "engine"
|
||||
"windows" "\xE8\x2A\x2A\x2A\x2A\x83\x38\x00\x74\x2A\xE8\x2A\x2A\x2A\x2A\x8B\x08\x8B\x01\x8B\x40\x2C\xFF\xD0"
|
||||
"windows" "\x55\x8B\xEC\x83\xEC\x1C\x53\x57\x33\xD2"
|
||||
"windows64" "\x4C\x8B\xDC\x49\x89\x5B\x2A\x49\x89\x6B\x2A\x56\x57\x41\x54\x41\x56\x41\x57\x48\x83\xEC\x60\x48\x8B\x05\x2A\x2A\x2A\x2A\x48\x8D\x1D"
|
||||
}
|
||||
|
||||
"Steam3Server"
|
||||
"NET_SendPacket"
|
||||
{
|
||||
"library" "engine"
|
||||
"linux" "@_Z12Steam3Serverv"
|
||||
"mac" "@_Z12Steam3Serverv"
|
||||
"linux" "@_Z14NET_SendPacketP11INetChanneliRK8netadr_sPKhiP8bf_writeb"
|
||||
}
|
||||
|
||||
"NET_CheckCleanupFakeIPConnection"
|
||||
{
|
||||
"library" "engine"
|
||||
"linux" "@_Z32NET_CheckCleanupFakeIPConnectioniRK8netadr_s"
|
||||
}
|
||||
|
||||
"CSteam3Server__OnValidateAuthTicketResponse"
|
||||
@ -60,19 +134,16 @@
|
||||
"library" "engine"
|
||||
"linux" "@_ZN13CSteam3Server28OnValidateAuthTicketResponseEP28ValidateAuthTicketResponse_t"
|
||||
}
|
||||
|
||||
"s_queryRateChecker"
|
||||
{
|
||||
"library" "engine"
|
||||
"linux" "@_ZL18s_queryRateChecker"
|
||||
}
|
||||
|
||||
"CIPRateLimit__CheckIP"
|
||||
{
|
||||
"library" "engine"
|
||||
"linux" "@_ZN12CIPRateLimit7CheckIPE8netadr_s"
|
||||
}
|
||||
|
||||
"CBaseServer__ValidChallenge"
|
||||
{
|
||||
"library" "engine"
|
||||
@ -103,19 +174,5 @@
|
||||
"linux" "@net_time"
|
||||
}
|
||||
}
|
||||
|
||||
"Offsets"
|
||||
{
|
||||
"IServer__ProcessConnectionlessPacket"
|
||||
{
|
||||
"windows" "1"
|
||||
"linux" "2"
|
||||
}
|
||||
|
||||
"CBaseServer__m_Socket"
|
||||
{
|
||||
"linux" "8"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user