Dynamically get CHLTVServer::m_DemoRecorder offset

Instead of hardcoding a hugh member variable offset, get it dynamically
from functions using the variable.
This commit is contained in:
Peace-Maker 2016-03-03 11:49:14 +01:00
parent 4d62d77e55
commit 5399c79d97
2 changed files with 61 additions and 15 deletions

View File

@ -291,16 +291,31 @@ void SourceTVManager::SelectSourceTVServer(IHLTVServer *hltv)
IDemoRecorder *SourceTVManager::GetDemoRecorderPtr(IHLTVServer *hltv) IDemoRecorder *SourceTVManager::GetDemoRecorderPtr(IHLTVServer *hltv)
{ {
static int offset = -1; static int offset = -1;
if (offset == -1 && !g_pGameConf->GetOffset("CHLTVServer::m_DemoRecorder", &offset)) if (offset == -1)
{ {
smutils->LogError(myself, "Failed to get CHLTVServer::m_DemoRecorder offset."); void *addr;
return nullptr; if (!g_pGameConf->GetAddress("CHLTVServer::m_DemoRecorder", &addr))
{
smutils->LogError(myself, "Failed to get CHLTVServer::m_DemoRecorder offset.");
return nullptr;
}
*(int **)&offset = (int *)addr;
} }
if (hltv) if (hltv)
{
#if SOURCE_ENGINE == SE_CSGO
return (IDemoRecorder *)((intptr_t)hltv + offset); return (IDemoRecorder *)((intptr_t)hltv + offset);
#else
IServer *baseServer = hltv->GetBaseServer();
return (IDemoRecorder *)((intptr_t)baseServer + offset);
#endif
}
else else
{
return nullptr; return nullptr;
}
} }
#if SOURCE_ENGINE == SE_CSGO #if SOURCE_ENGINE == SE_CSGO

View File

@ -16,6 +16,20 @@
"signature" "host_client" "signature" "host_client"
} }
} }
"CHLTVServer::m_DemoRecorder"
{
"windows"
{
"signature" "CHLTVServer::GetRecordingDemoFilename"
"read" "2"
}
"linux"
{
"signature" "CHLTVServer::GetRecordingDemoFilename"
"read" "10"
}
}
} }
"Offsets" "Offsets"
{ {
@ -49,12 +63,6 @@
"linux" "65" "linux" "65"
} }
"CHLTVServer::m_DemoRecorder"
{
"windows" "19600"
"linux" "20496"
}
"CHLTVDirector::m_iPVSEntity" "CHLTVDirector::m_iPVSEntity"
{ {
"windows" "32" "windows" "32"
@ -90,6 +98,13 @@
// "SourceTV broadcast local event: %s\n" // "SourceTV broadcast local event: %s\n"
"windows" "\x55\x8B\xEC\x83\xEC\x4C\x53\x8B\xD9\xC7\x45\xB4\x2A\x2A\x2A\x2A\x56\x8D" "windows" "\x55\x8B\xEC\x83\xEC\x4C\x53\x8B\xD9\xC7\x45\xB4\x2A\x2A\x2A\x2A\x56\x8D"
} }
"CHLTVServer::GetRecordingDemoFilename"
{
"library" "engine"
"linux" "@_ZN11CHLTVServer24GetRecordingDemoFilenameEv"
"windows" "\x81\xC1\x2A\x2A\x2A\x2A\x8B\x01\xFF\x20"
}
} }
} }
"cstrike" "cstrike"
@ -108,6 +123,20 @@
"signature" "host_client" "signature" "host_client"
} }
} }
"CHLTVServer::m_DemoRecorder"
{
"windows"
{
"signature" "CHLTVServer::Shutdown"
"read" "5"
}
"linux"
{
"signature" "CHLTVServer::Shutdown"
"read" "12"
}
}
} }
"Offsets" "Offsets"
{ {
@ -153,12 +182,6 @@
"linux" "56" "linux" "56"
} }
"CHLTVServer::m_DemoRecorder"
{
"windows" "19192"
"linux" "19424" // -416
}
"CHLTVDirector::m_iPVSEntity" "CHLTVDirector::m_iPVSEntity"
{ {
"windows" "16" "windows" "16"
@ -194,6 +217,14 @@
// "SourceTV broadcast local event: %s\n" // "SourceTV broadcast local event: %s\n"
"windows" "\x55\x8B\xEC\x81\xEC\x44\x04\x00\x00\x53" "windows" "\x55\x8B\xEC\x81\xEC\x44\x04\x00\x00\x53"
} }
"CHLTVServer::Shutdown"
{
"library" "engine"
"linux" "@_ZN11CHLTVServer8ShutdownEv"
// "HLTV server shutting down"
"windows" "\x56\x8B\xF1\x8B\x86\x2A\x2A\x2A\x2A\x8D\x8E\x2A\x2A\x2A\x2A\xFF\x50\x2A\x8B\x86\x2A\x2A\x2A\x2A\x8D\x8E"
}
} }
} }
} }