commit
8f8b7637d3
@ -11,8 +11,8 @@ namespace Components
|
|||||||
if (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled() || Monitor::IsEnabled() || Loader::IsPerformingUnitTests()) return;
|
if (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled() || Monitor::IsEnabled() || Loader::IsPerformingUnitTests()) return;
|
||||||
|
|
||||||
DWORD oldProtect;
|
DWORD oldProtect;
|
||||||
std::uint8_t* module = reinterpret_cast<std::uint8_t*>(GetModuleHandle(nullptr));
|
std::uint8_t* _module = reinterpret_cast<std::uint8_t*>(GetModuleHandle(nullptr));
|
||||||
VirtualProtect(module + 0x1000, 0x2D6000, PAGE_EXECUTE_READWRITE, &oldProtect);
|
VirtualProtect(_module + 0x1000, 0x2D6000, PAGE_EXECUTE_READWRITE, &oldProtect);
|
||||||
|
|
||||||
#ifdef COMPILE_IW4MVM
|
#ifdef COMPILE_IW4MVM
|
||||||
client_main::Init();
|
client_main::Init();
|
||||||
@ -26,7 +26,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
VirtualProtect(module + 0x1000, 0x2D6000, PAGE_EXECUTE_READ, &oldProtect);
|
VirtualProtect(_module + 0x1000, 0x2D6000, PAGE_EXECUTE_READ, &oldProtect);
|
||||||
}
|
}
|
||||||
|
|
||||||
IW4MVM::~IW4MVM()
|
IW4MVM::~IW4MVM()
|
||||||
|
@ -9,6 +9,7 @@ namespace Components
|
|||||||
unsigned short Script::FunctionName;
|
unsigned short Script::FunctionName;
|
||||||
std::unordered_map<std::string, std::string> Script::ScriptStorage;
|
std::unordered_map<std::string, std::string> Script::ScriptStorage;
|
||||||
std::unordered_map<int, std::string> Script::ScriptBaseProgramNum;
|
std::unordered_map<int, std::string> Script::ScriptBaseProgramNum;
|
||||||
|
int Script::LastFrameTime = -1;
|
||||||
|
|
||||||
Utils::Signal<Scheduler::Callback> Script::VMShutdownSignal;
|
Utils::Signal<Scheduler::Callback> Script::VMShutdownSignal;
|
||||||
|
|
||||||
@ -566,6 +567,24 @@ namespace Components
|
|||||||
Utils::Hook(0x47548B, Script::ScrShutdownSystemStub, HOOK_CALL).install()->quick();
|
Utils::Hook(0x47548B, Script::ScrShutdownSystemStub, HOOK_CALL).install()->quick();
|
||||||
Utils::Hook(0x4D06BA, Script::ScrShutdownSystemStub, HOOK_CALL).install()->quick();
|
Utils::Hook(0x4D06BA, Script::ScrShutdownSystemStub, HOOK_CALL).install()->quick();
|
||||||
|
|
||||||
|
Scheduler::OnFrame([]()
|
||||||
|
{
|
||||||
|
if (!Game::SV_Loaded())
|
||||||
|
return;
|
||||||
|
|
||||||
|
int nowMs = Game::Sys_Milliseconds();
|
||||||
|
|
||||||
|
if (Script::LastFrameTime != -1)
|
||||||
|
{
|
||||||
|
int timeTaken = static_cast<int>((nowMs - Script::LastFrameTime) * Dvar::Var("timescale").get<float>());
|
||||||
|
|
||||||
|
if (timeTaken >= 500)
|
||||||
|
Logger::Print(23, "Hitch warning: %i msec frame time\n", timeTaken);
|
||||||
|
}
|
||||||
|
|
||||||
|
Script::LastFrameTime = nowMs;
|
||||||
|
});
|
||||||
|
|
||||||
Script::AddFunction("debugBox", [](Game::scr_entref_t)
|
Script::AddFunction("debugBox", [](Game::scr_entref_t)
|
||||||
{
|
{
|
||||||
MessageBoxA(nullptr, Game::Scr_GetString(0), "DEBUG", 0);
|
MessageBoxA(nullptr, Game::Scr_GetString(0), "DEBUG", 0);
|
||||||
|
@ -40,6 +40,7 @@ namespace Components
|
|||||||
static unsigned short FunctionName;
|
static unsigned short FunctionName;
|
||||||
static std::unordered_map<std::string, std::string> ScriptStorage;
|
static std::unordered_map<std::string, std::string> ScriptStorage;
|
||||||
static std::unordered_map<int, std::string> ScriptBaseProgramNum;
|
static std::unordered_map<int, std::string> ScriptBaseProgramNum;
|
||||||
|
static int LastFrameTime;
|
||||||
|
|
||||||
static Utils::Signal<Scheduler::Callback> VMShutdownSignal;
|
static Utils::Signal<Scheduler::Callback> VMShutdownSignal;
|
||||||
|
|
||||||
|
@ -55,9 +55,9 @@ BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*l
|
|||||||
Steam::Proxy::RunMod();
|
Steam::Proxy::RunMod();
|
||||||
|
|
||||||
// Ensure we're working with our desired binary
|
// Ensure we're working with our desired binary
|
||||||
char* module = reinterpret_cast<char*>(0x400000);
|
char* _module = reinterpret_cast<char*>(0x400000);
|
||||||
auto hash1 = Utils::Cryptography::JenkinsOneAtATime::Compute(module + 0x1000, 0x2D531F); // .text
|
auto hash1 = Utils::Cryptography::JenkinsOneAtATime::Compute(_module + 0x1000, 0x2D531F); // .text
|
||||||
auto hash2 = Utils::Cryptography::JenkinsOneAtATime::Compute(module + 0x2D75FC, 0xBDA04); // .rdata
|
auto hash2 = Utils::Cryptography::JenkinsOneAtATime::Compute(_module + 0x2D75FC, 0xBDA04); // .rdata
|
||||||
if ((hash1 != 0x54684DBE
|
if ((hash1 != 0x54684DBE
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
&& hash1 != 0x8AADE716
|
&& hash1 != 0x8AADE716
|
||||||
@ -79,7 +79,7 @@ BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*l
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
DWORD oldProtect;
|
DWORD oldProtect;
|
||||||
VirtualProtect(module + 0x1000, 0x2D6000, PAGE_EXECUTE_READ, &oldProtect); // Protect the .text segment
|
VirtualProtect(_module + 0x1000, 0x2D6000, PAGE_EXECUTE_READ, &oldProtect); // Protect the .text segment
|
||||||
|
|
||||||
// Install entry point hook
|
// Install entry point hook
|
||||||
Utils::Hook(0x6BAC0F, Main::EntryPoint, HOOK_JUMP).install()->quick();
|
Utils::Hook(0x6BAC0F, Main::EntryPoint, HOOK_JUMP).install()->quick();
|
||||||
|
Loading…
Reference in New Issue
Block a user