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;
char Theatre::BaselineSnapshot[131072] = { 0 };
PBYTE Theatre::BaselineSnapshotMsg = 0;
int Theatre::BaselineSnapshotMsgLen;
int Theatre::BaselineSnapshotMsgOff;
@ -21,20 +20,24 @@ namespace Components
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
Theatre::BaselineSnapshotMsgLen = *reinterpret_cast<int*>(Theatre::BaselineSnapshotMsg + 20);
Theatre::BaselineSnapshotMsgOff = *reinterpret_cast<int*>(Theatre::BaselineSnapshotMsg + 28) - 7;
Theatre::BaselineSnapshotMsgLen = *reinterpret_cast<int*>(snapshotMsg + 20);
Theatre::BaselineSnapshotMsgOff = *reinterpret_cast<int*>(snapshotMsg + 28) - 7;
// 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
jmp edx
}

View File

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

View File

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