| 29 | } |
| 30 | |
| 31 | void Init() |
| 32 | { |
| 33 | auto pattern = hook::pattern("A1 ? ? ? ? 68 ? ? ? ? 50 FF 15"); |
| 34 | hWnd.SetAddress(*pattern.get_first<HWND*>(1)); |
| 35 | WindowRect.SetAddress(*pattern.get_first<tagRECT*>(6)); |
| 36 | |
| 37 | pattern = hook::pattern("A1 ? ? ? ? 33 FF 3B C7 74 ? A1"); |
| 38 | dwWindowedMode.SetAddress(*pattern.get_first<uint32_t*>(1)); |
| 39 | |
| 40 | pattern = hook::pattern("A1 ? ? ? ? 56 8B F0 75"); |
| 41 | g_RacingResolution.SetAddress(*pattern.get_first<int*>(1)); |
| 42 | |
| 43 | pattern = hook::pattern("E8 ? ? ? ? A1 ? ? ? ? A3 ? ? ? ? E8"); |
| 44 | static auto MainLoopHook = safetyhook::create_mid(pattern.get_first(), [](SafetyHookContext& regs) |
| 45 | { |
| 46 | MainLoop(); |
| 47 | }); |
| 48 | |
| 49 | pattern = hook::pattern("A1 ? ? ? ? 3B C3 74 ? ? ? 75"); |
| 50 | GameFlowManager::pRaceCoordinator = *pattern.get_first<int**>(1); |
| 51 | |
| 52 | pattern = hook::pattern("A0 ? ? ? ? 84 C0 74 ? C6 05 ? ? ? ? ? E9"); |
| 53 | bExitFEOptionsSystem.SetAddress(*pattern.get_first<uint8_t*>(1)); |
| 54 | |
| 55 | pattern = hook::pattern("8B 0D ? ? ? ? 3B CB 74 ? E8 ? ? ? ? 83 FF"); |
| 56 | cFEng::pInstance = *pattern.get_first<void**>(2); |
| 57 | cFEng::MakeLoadedPackagesDirty = (decltype(cFEng::MakeLoadedPackagesDirty))injector::GetBranchDestination(pattern.get_first(10)).as_int(); |
| 58 | |
| 59 | pattern = hook::pattern("E8 ? ? ? ? 83 C4 ? E8 ? ? ? ? B9 ? ? ? ? 8B F8"); |
| 60 | static auto GetActualDeltaTime = safetyhook::create_mid(pattern.get_first(), [](SafetyHookContext& regs) |
| 61 | { |
| 62 | actualDeltaTime = *(float*)(regs.esp); |
| 63 | }); |
| 64 | |
| 65 | pattern = hook::pattern("E8 ? ? ? ? A1 ? ? ? ? 85 C0 74 ? ? ? 50 FF 51"); |
| 66 | static auto BeforeResetHook = safetyhook::create_mid(pattern.get_first(), [](SafetyHookContext& regs) |
| 67 | { |
| 68 | WFP::onBeforeReset().executeAll(); |
| 69 | }); |
| 70 | |
| 71 | pattern = hook::pattern("A1 ? ? ? ? ? ? 83 C4 ? 50 FF 92"); |
| 72 | Direct3DDevice.SetAddress(*pattern.get_first<IDirect3DDevice9**>(1)); |
| 73 | static auto BeforeEndSceneHook = safetyhook::create_mid(pattern.get_first(), [](SafetyHookContext& regs) |
| 74 | { |
| 75 | WFP::onEndScene().executeAll(); |
| 76 | }); |
| 77 | |
| 78 | WFP::onInitEvent().executeAll(); |
| 79 | |
| 80 | static auto futures = WFP::onInitEventAsync().executeAllAsync(); |
| 81 | |
| 82 | WFP::onGameInitEvent() += []() |
| 83 | { |
| 84 | for (auto& f : futures.get()) |
| 85 | f.wait(); |
| 86 | futures.get().clear(); |
| 87 | }; |
| 88 | } |
nothing calls this directly
no test coverage detected