Skip to content

Commit 5edfa79

Browse files
bottiger1psychonic
andauthored
Fix more sdktools crash on 64 bits (#2152)
* fix sdktools crash on 64 bits * remove other 32bit-isms from sdktools * Swap sizeof(intptr_t) for sizeof(void *) --------- Co-authored-by: Nick Hastings <[email protected]>
1 parent b6d98c7 commit 5edfa79

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

extensions/sdktools/hooks.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ void CHookManager::OnClientConnected(int client)
234234
}
235235
}
236236

237-
int hookid = SH_ADD_VPHOOK(IClientMessageHandler, ProcessVoiceData, (IClientMessageHandler *)((intptr_t)(pClient) + 4), SH_MEMBER(this, &CHookManager::ProcessVoiceData), true);
237+
int hookid = SH_ADD_VPHOOK(IClientMessageHandler, ProcessVoiceData, (IClientMessageHandler *)((intptr_t)(pClient) + sizeof(void *)), SH_MEMBER(this, &CHookManager::ProcessVoiceData), true);
238238
hook.SetHookID(hookid);
239239
netProcessVoiceData.push_back(new CVTableHook(hook));
240240
}
@@ -584,7 +584,7 @@ bool CHookManager::SendFile(const char *filename, unsigned int transferID)
584584
#if !defined CLIENTVOICE_HOOK_SUPPORT
585585
bool CHookManager::ProcessVoiceData(CLC_VoiceData *msg)
586586
{
587-
IClient *pClient = (IClient *)((intptr_t)(META_IFACEPTR(IClient)) - 4);
587+
IClient *pClient = (IClient *)((intptr_t)(META_IFACEPTR(IClient)) - sizeof(void *));
588588
if (pClient == NULL)
589589
{
590590
return true;

extensions/sdktools/vhelpers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -753,8 +753,8 @@ CEntityFactoryDictionary *GetEntityFactoryDictionary()
753753
int32_t funcOffset = *(int32_t *)((intptr_t)addr + offset);
754754

755755
// Get real address of function
756-
// Address of signature + offset of relative offset + sizeof(int32_t) offset + relative offset
757-
addr = (void *)((intptr_t)addr + offset + 4 + funcOffset);
756+
// Address of signature + offset of relative offset + pointer size + relative offset
757+
addr = (void *)((intptr_t)addr + offset + sizeof(void *) + funcOffset);
758758
}
759759

760760
pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retData, NULL, 0);

0 commit comments

Comments
 (0)