| 275 | } |
| 276 | |
| 277 | void Init() |
| 278 | { |
| 279 | CIniReader iniReader(".\\videomode.ini"); |
| 280 | Screen.nWidth = iniReader.ReadInteger("Settings", "Width", 0); |
| 281 | Screen.nHeight = iniReader.ReadInteger("Settings", "Height", 0); |
| 282 | Screen.bFix2D = iniReader.ReadInteger("Settings", "WidescreenUIPatch", 1) != 0; |
| 283 | Screen.bDrawPillarboxes = iniReader.ReadInteger("Settings", "DrawPillarboxes", 1) != 0; |
| 284 | Screen.bDisableCutsceneBorders = iniReader.ReadInteger("Settings", "DisableCutsceneBorders", 0) != 0; |
| 285 | static int32_t nToggleHudKey = iniReader.ReadInteger("MAIN", "ToggleHudKey", VK_F2); |
| 286 | |
| 287 | if (!Screen.nWidth || !Screen.nHeight) |
| 288 | std::tie(Screen.nWidth, Screen.nHeight) = GetDesktopRes(); |
| 289 | |
| 290 | GetRes(); |
| 291 | |
| 292 | //Default Windowed Res Hook |
| 293 | auto pattern = hook::pattern("FF 15 ? ? ? ? 8B 47 08 A3"); |
| 294 | injector::MakeNOP(pattern.get_first(0), 6, true); |
| 295 | injector::MakeCALL(pattern.get_first(0), SetWindowPosHook, true); |
| 296 | |
| 297 | //windowed mode crash in gameplay workaround |
| 298 | pattern = hook::pattern("6A FF 68 ? ? ? ? 64 A1 ? ? ? ? 50 64 89 25 ? ? ? ? 51 53 56 57 8B F1"); |
| 299 | static auto sub_4B8EC0 = (uint32_t)pattern.get_first(0); |
| 300 | dword_4B8EC7 = (uint32_t)pattern.get_first(7); |
| 301 | dword_544758 = *pattern.get_first<uint32_t>(3); |
| 302 | pattern = hook::pattern("89 88 ? ? ? ? 8B 15 ? ? ? ? 8B 44 24 08 6B D2 1C 89 82"); |
| 303 | dword_A909F9 = (uint32_t)(*pattern.count(4).get(1).get<void*>(2)) + 1; |
| 304 | dword_65B45C = (uint32_t)(*hook::get_pattern<void*>("B8 ? ? ? ? 57 8B FF", 1)) + 0x564; |
| 305 | pattern = hook::pattern("8B 4C 24 10 5F 5E B0 01 5B 64 89 0D ? ? ? ? 83 C4 10 C2 08 00"); |
| 306 | struct InitiatingWindowModeHook |
| 307 | { |
| 308 | void operator()(injector::reg_pack& regs) |
| 309 | { |
| 310 | regs.ecx = *(uint32_t*)(regs.esp + 0x10); |
| 311 | regs.eax = 1; |
| 312 | //injector::MakeRET(sub_4B8EC0, 8, true); |
| 313 | injector::MakeJMP(sub_4B8EC0, menu_check, true); |
| 314 | } |
| 315 | }; injector::MakeInline<InitiatingWindowModeHook>(pattern.get_first(0), pattern.get_first(8)); |
| 316 | injector::WriteMemory<uint16_t>(pattern.get_first(5), 0x5E5F, true); // pop edi pop esi |
| 317 | |
| 318 | //Default Fullscreen Res Hook |
| 319 | pattern = hook::pattern("A3 ? ? ? ? 8B 4F 0C"); |
| 320 | Screen.dword_A8F0C8 = *pattern.get_first<int32_t*>(1); |
| 321 | struct FullscreenResXHook1 |
| 322 | { |
| 323 | void operator()(injector::reg_pack& regs) |
| 324 | { |
| 325 | *(uint32_t*)(regs.edi + 8) = Screen.nWidth; |
| 326 | *Screen.dword_A8F0C8 = Screen.nWidth; |
| 327 | } |
| 328 | }; injector::MakeInline<FullscreenResXHook1>(pattern.get_first(0)); |
| 329 | |
| 330 | pattern = hook::pattern("89 0D ? ? ? ? C7 05 ? ? ? ? ? ? ? ? 75 27 8B CE 88 1D"); |
| 331 | Screen.dword_A8F0CC = *pattern.get_first<int32_t*>(2); |
| 332 | struct FullscreenResYHook1 |
| 333 | { |
| 334 | void operator()(injector::reg_pack& regs) |
nothing calls this directly
no test coverage detected