Fix release builds.

This commit is contained in:
momo5502 2016-01-24 13:06:52 +01:00
parent 378ec87619
commit a3ee040a20
3 changed files with 44 additions and 24 deletions

View File

@ -5,7 +5,6 @@ namespace Components
Theatre::Container Theatre::DemoContainer; Theatre::Container Theatre::DemoContainer;
char Theatre::BaselineSnapshot[131072] = { 0 }; char Theatre::BaselineSnapshot[131072] = { 0 };
PBYTE Theatre::BaselineSnapshotMsg = 0;
int Theatre::BaselineSnapshotMsgLen; int Theatre::BaselineSnapshotMsgLen;
int Theatre::BaselineSnapshotMsgOff; int Theatre::BaselineSnapshotMsgOff;
@ -21,20 +20,24 @@ namespace Components
Game::FS_Write(&sequence, 4, *Game::demoFile); Game::FS_Write(&sequence, 4, *Game::demoFile);
} }
void __declspec(naked) Theatre::BaselineStoreStub() void Theatre::StoreBaseline(PBYTE snapshotMsg)
{ {
// Store snapshot message
__asm mov Theatre::BaselineSnapshotMsg, edi
// Store offset and length // Store offset and length
Theatre::BaselineSnapshotMsgLen = *reinterpret_cast<int*>(Theatre::BaselineSnapshotMsg + 20); Theatre::BaselineSnapshotMsgLen = *reinterpret_cast<int*>(snapshotMsg + 20);
Theatre::BaselineSnapshotMsgOff = *reinterpret_cast<int*>(Theatre::BaselineSnapshotMsg + 28) - 7; Theatre::BaselineSnapshotMsgOff = *reinterpret_cast<int*>(snapshotMsg + 28) - 7;
// Copy to our snapshot buffer // Copy to our snapshot buffer
memcpy(Theatre::BaselineSnapshot, *reinterpret_cast<DWORD**>(Theatre::BaselineSnapshotMsg + 8), *reinterpret_cast<DWORD*>(Theatre::BaselineSnapshotMsg + 20)); memcpy(Theatre::BaselineSnapshot, *reinterpret_cast<DWORD**>(snapshotMsg + 8), *reinterpret_cast<DWORD*>(snapshotMsg + 20));
}
__asm void __declspec(naked) Theatre::BaselineStoreStub()
{ {
_asm
{
push edi
call Theatre::StoreBaseline
pop edi
mov edx, 5ABEF5h mov edx, 5ABEF5h
jmp edx jmp edx
} }

View File

@ -39,11 +39,11 @@ namespace Components
static Container DemoContainer; static Container DemoContainer;
static char BaselineSnapshot[131072]; static char BaselineSnapshot[131072];
static PBYTE BaselineSnapshotMsg;
static int BaselineSnapshotMsgLen; static int BaselineSnapshotMsgLen;
static int BaselineSnapshotMsgOff; static int BaselineSnapshotMsgOff;
static void WriteBaseline(); static void WriteBaseline();
static void StoreBaseline(PBYTE snapshotMsg);
static void LoadDemos(); static void LoadDemos();
static void DeleteDemo(); static void DeleteDemo();

View File

@ -1,9 +1,22 @@
#include "STDInclude.hpp" #include "STDInclude.hpp"
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) namespace Main
{ {
static Utils::Hook EntryPointHook; static Utils::Hook EntryPointHook;
void Initialize()
{
EntryPointHook.Uninstall();
Components::Loader::Initialize();
}
void Uninitialize()
{
Components::Loader::Uninitialize();
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
if (ul_reason_for_call == DLL_PROCESS_ATTACH) if (ul_reason_for_call == DLL_PROCESS_ATTACH)
{ {
DWORD oldProtect; DWORD oldProtect;
@ -11,16 +24,20 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReser
EntryPointHook.Initialize(0x6BAC0F, [] () EntryPointHook.Initialize(0x6BAC0F, [] ()
{ {
EntryPointHook.Uninstall(); __asm
Components::Loader::Initialize(); {
__asm jmp EntryPointHook.Place call Main::Initialize
mov eax, 6BAC0Fh
jmp eax
}
})->Install(); })->Install();
} }
else if (ul_reason_for_call == DLL_PROCESS_DETACH) else if (ul_reason_for_call == DLL_PROCESS_DETACH)
{ {
Components::Loader::Uninitialize(); Main::Uninitialize();
} }
return TRUE; return TRUE;
}
} }