From 108b15878ac1f8b591a499992fd6053db20a846e Mon Sep 17 00:00:00 2001 From: maximegmd <672982+maximegmd@users.noreply.github.com> Date: Mon, 25 Sep 2023 17:15:14 +0200 Subject: [PATCH] Fix some patch patterns --- ida/find_patterns.py | 4 ++-- ida/patterns.py | 6 +++--- src/dllmain.cpp | 9 +++------ src/patches/DisableBoundaries.cpp | 4 ++-- src/patches/DisableVignette.cpp | 4 ++-- src/patches/MinimapFlicker.cpp | 5 ++++- src/patches/OptionsPatch.cpp | 4 ++-- src/reverse/Addresses.h | 12 +++++++++--- 8 files changed, 27 insertions(+), 21 deletions(-) diff --git a/ida/find_patterns.py b/ida/find_patterns.py index f3addb2b..990b49a7 100644 --- a/ida/find_patterns.py +++ b/ida/find_patterns.py @@ -96,7 +96,7 @@ def find_ptr(pattern: str, expected: int = 1, index: int = 0, offset: int = 0) - groups.sort(key=lambda g: g.name.lower()) - addr = find_ptr(pattern='4C 8D 05 ? ? ? ? 45 89 BE 20 02 00 00', offset=3) + addr = find_ptr(pattern='4C 8D 05 ? ? ? ? 48 89 ? ? ? 00 00', expected=9, index=2, offset=3) version = idc.get_strlit_contents(addr) print(f'Finding {total} item(s)...') @@ -111,7 +111,7 @@ def find_ptr(pattern: str, expected: int = 1, index: int = 0, offset: int = 0) - file.write(' */\n') file.write('#include \n') file.write('\n') - #file.write(f'// Addresses for Cyberpunk 2077, version {version.decode()}.\n') + file.write(f'// Addresses for Cyberpunk 2077, version {version.decode()}.\n') file.write('namespace CyberEngineTweaks::Addresses\n') file.write('{\n') file.write(f'constexpr uintptr_t ImageBase = 0x{ida_nalt.get_imagebase():X};\n') diff --git a/ida/patterns.py b/ida/patterns.py index e1e23088..c3e82b31 100644 --- a/ida/patterns.py +++ b/ida/patterns.py @@ -67,11 +67,11 @@ def get_groups() -> List[Group]: Item(name='SetRecordID', pattern='48 89 5C 24 10 48 89 4C 24 08 55 48 8B EC 48 83 EC 40 48 8B DA 48 8D 4D E0 48 8D 55 10 E8', expected=1) # ok ]), Group(name='CPatches', functions=[ - #Item(name='BoundaryTeleport', pattern='48 8B C4 55 53 41 54 48 8D A8 ? ? ? ? 48 81 EC ? ? ? ? 48 89 70 10 48 8D 59 48', expected=1), + Item(name='BoundaryTeleport', pattern='48 8B C4 48 89 58 10 55 56 57 41 54 41 55 41 56 41 57 48 8D A8 F8 FE FF FF 48 81 EC D0 01 00 00 0F 29 78 B8 48 8D 51 48', expected=1), Item(name='IntroMovie', pattern='48 89 5C 24 08 57 48 83 EC 20 48 8B 44 24 50 48 8B D9 48 89 41 08', expected=1), # ok Item(name='Vignette', pattern='33 C0 48 39 41 68 74 11', expected=1), - #Item(name='MinimapFlicker', pattern='83 79 2C 00 48 8B F2 4C', expected=1), - #Item(name='OptionsInit', pattern='40 53 48 83 EC 40 48 8B D9 48 8D 4C 24 20 E8 ? ? ? ? E8 ? ? ? ? 4C 8B 43 08', expected=1), + #Item(name='MinimapFlicker', pattern='44 0F 29 98 78 FF FF FF 44 0F 29 A0 68 FF FF FF 45 85 F6 75 56', expected=1), + Item(name='OptionsInit', pattern='48 89 5C 24 08 55 48 8B EC 48 83 EC 70 48 83 65 F8 00 48 8B D9 83 65 F4 00', expected=1), #Item(name='SkipStartScreen', pattern='74 5F E8 ? ? ? ? 48 8D 4C 24 20 8B D8 E8 ? ? ? ? 48 8B C8 8B D3 E8', expected=2, index=1), ]), Group(name='CGame', functions=[ diff --git a/src/dllmain.cpp b/src/dllmain.cpp index ab1a4147..e2cc9210 100644 --- a/src/dllmain.cpp +++ b/src/dllmain.cpp @@ -11,7 +11,6 @@ void OptionsInitHook(); void DisableIntroMoviesPatch(); void DisableVignettePatch(); void DisableBoundaryTeleportPatch(); -void MinimapFlickerPatch(); static HANDLE s_modInstanceMutex = nullptr; @@ -37,8 +36,8 @@ static void Initialize() // initialize patches - /*if (options.Patches.SkipStartMenu) - StartScreenPatch(); + //if (options.Patches.SkipStartMenu) + // StartScreenPatch(); if (options.Patches.DisableIntroMovies) DisableIntroMoviesPatch(); @@ -49,10 +48,8 @@ static void Initialize() if (options.Patches.DisableBoundaryTeleport) DisableBoundaryTeleportPatch(); - if (options.Patches.MinimapFlicker) - MinimapFlickerPatch(); - OptionsInitHook();*/ + OptionsInitHook(); MH_EnableHook(nullptr); } diff --git a/src/patches/DisableBoundaries.cpp b/src/patches/DisableBoundaries.cpp index 5790efea..82340d3e 100644 --- a/src/patches/DisableBoundaries.cpp +++ b/src/patches/DisableBoundaries.cpp @@ -1,6 +1,6 @@ #include -/* + void DisableBoundaryTeleportPatch() { // Disarm the WorldBoundarySystem/Tick function @@ -22,4 +22,4 @@ void DisableBoundaryTeleportPatch() Log::Info("Disable boundary teleport: success"); } -*/ + diff --git a/src/patches/DisableVignette.cpp b/src/patches/DisableVignette.cpp index b91f64ac..1095eab5 100644 --- a/src/patches/DisableVignette.cpp +++ b/src/patches/DisableVignette.cpp @@ -1,6 +1,6 @@ #include -/* + void DisableVignettePatch() { const RED4ext::RelocPtr func(CyberEngineTweaks::Addresses::CPatches_Vignette); @@ -21,4 +21,4 @@ void DisableVignettePatch() Log::Info("Disable vignette patch: success"); } -*/ + diff --git a/src/patches/MinimapFlicker.cpp b/src/patches/MinimapFlicker.cpp index 96e6ab6b..1b6a6e2e 100644 --- a/src/patches/MinimapFlicker.cpp +++ b/src/patches/MinimapFlicker.cpp @@ -1,6 +1,9 @@ #include -/* +/** + +Does not seem to be needed since 2.0, keeping in case we need it again + void MinimapFlickerPatch() { const RED4ext::RelocPtr func(CyberEngineTweaks::Addresses::CPatches_MinimapFlicker); diff --git a/src/patches/OptionsPatch.cpp b/src/patches/OptionsPatch.cpp index 82e2c6ea..50272aa6 100644 --- a/src/patches/OptionsPatch.cpp +++ b/src/patches/OptionsPatch.cpp @@ -37,7 +37,7 @@ void* HookGameOptionInit(GameOption* apThis) return RealGameOptionInit(apThis); } -/* + void OptionsInitHook() { const RED4ext::RelocPtr func(CyberEngineTweaks::Addresses::CPatches_OptionsInit); @@ -53,4 +53,4 @@ void OptionsInitHook() else Log::Warn("Hidden options hook: failed"); } -*/ + diff --git a/src/reverse/Addresses.h b/src/reverse/Addresses.h index e61f80e3..b68c13b2 100644 --- a/src/reverse/Addresses.h +++ b/src/reverse/Addresses.h @@ -8,6 +8,7 @@ */ #include +// Addresses for Cyberpunk 2077, version 2.0. namespace CyberEngineTweaks::Addresses { constexpr uintptr_t ImageBase = 0x140000000; @@ -26,7 +27,11 @@ constexpr uintptr_t CInitializationState_OnTick = 0x14084A7A8 - ImageBase; // 40 #pragma endregion #pragma region CPatches -constexpr uintptr_t CPatches_IntroMovie = 0x14011D85C - ImageBase; // 48 89 5C 24 08 57 48 83 EC 20 48 8B 44 24 50 48 8B D9 48 89 41 08, expected: 1, index: 0 +constexpr uintptr_t CPatches_BoundaryTeleport = + 0x140C42C10 - ImageBase; // 48 8B C4 48 89 58 10 55 56 57 41 54 41 55 41 56 41 57 48 8D A8 F8 FE FF FF 48 81 EC D0 01 00 00 0F 29 78 B8 48 8D 51 48, expected: 1, index: 0 +constexpr uintptr_t CPatches_IntroMovie = 0x14011D85C - ImageBase; // 48 89 5C 24 08 57 48 83 EC 20 48 8B 44 24 50 48 8B D9 48 89 41 08, expected: 1, index: 0 +constexpr uintptr_t CPatches_Vignette = 0x14230A6D4 - ImageBase; // 33 C0 48 39 41 68 74 11, expected: 1, index: 0 +constexpr uintptr_t CPatches_OptionsInit = 0x1402CBCFC - ImageBase; // 48 89 5C 24 08 55 48 8B EC 48 83 EC 70 48 83 65 F8 00 48 8B D9 83 65 F4 00, expected: 1, index: 0 #pragma endregion #pragma region CPhotoMode @@ -36,7 +41,7 @@ constexpr uintptr_t CPhotoMode_SetRecordID = #pragma region CRenderGlobal constexpr uintptr_t CRenderGlobal_InstanceOffset = - 0x1432FE498 - ImageBase; // 48 8B C4 48 89 58 08 48 89 68 10 48 89 70 18 4C 89 48 20 57 41 56 41 57 48 83 EC 30 8B 01 45 8B, expected: 1, index: 0, offset: 62 + 0x1432FE498 - ImageBase; // 48 8B C4 48 89 58 08 48 89 68 10 48 89 70 18 4C 89 48 20 57 41 56 41 57 48 83 EC 30 8B 01 45 8B, expected: 1, index: 0, offset: 36 constexpr uintptr_t CRenderGlobal__DoNotUse_RenderQueueOffset = 0x1B5EF8520 - ImageBase; // 39 72 24 74 5B 48 8B 4A 18 4C 8D 8C 24 88 00 00 00 8B 42 24 44 8B C7 48 8B 95 ? ? ? ?, expected: 1, index: 0, offset: 0 constexpr uintptr_t CRenderGlobal_Resize = @@ -96,6 +101,7 @@ constexpr uintptr_t gameIGameSystem_SpawnCallback = #pragma endregion #pragma region PlayerSystem -constexpr uintptr_t PlayerSystem_OnPlayerSpawned = 0x1409FE5A0 - ImageBase; // 48 89 5C 24 18 48 89 74 24 20 55 57 41 54 41 56 41 57 48 8B EC 48 83 EC 50 48 8B DA 48 8B F9 +constexpr uintptr_t PlayerSystem_OnPlayerSpawned = + 0x1409FE5A0 - ImageBase; // 48 89 5C 24 18 48 89 74 24 20 55 57 41 54 41 56 41 57 48 8B EC 48 83 EC 50 48 8B DA 48 8B F9, expected: 1, index: 0 #pragma endregion } // namespace CyberEngineTweaks::Addresses