Skip to content

Commit

Permalink
Fix some patch patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
maximegmd committed Sep 25, 2023
1 parent 24a962b commit 108b158
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 21 deletions.
4 changes: 2 additions & 2 deletions ida/find_patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)...')
Expand All @@ -111,7 +111,7 @@ def find_ptr(pattern: str, expected: int = 1, index: int = 0, offset: int = 0) -
file.write(' */\n')
file.write('#include <cstdint>\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')
Expand Down
6 changes: 3 additions & 3 deletions ida/patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[
Expand Down
9 changes: 3 additions & 6 deletions src/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ void OptionsInitHook();
void DisableIntroMoviesPatch();
void DisableVignettePatch();
void DisableBoundaryTeleportPatch();
void MinimapFlickerPatch();

static HANDLE s_modInstanceMutex = nullptr;

Expand All @@ -37,8 +36,8 @@ static void Initialize()

// initialize patches

/*if (options.Patches.SkipStartMenu)
StartScreenPatch();
//if (options.Patches.SkipStartMenu)
// StartScreenPatch();

if (options.Patches.DisableIntroMovies)
DisableIntroMoviesPatch();
Expand All @@ -49,10 +48,8 @@ static void Initialize()
if (options.Patches.DisableBoundaryTeleport)
DisableBoundaryTeleportPatch();

if (options.Patches.MinimapFlicker)
MinimapFlickerPatch();

OptionsInitHook();*/
OptionsInitHook();

MH_EnableHook(nullptr);
}
Expand Down
4 changes: 2 additions & 2 deletions src/patches/DisableBoundaries.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <stdafx.h>

/*

void DisableBoundaryTeleportPatch()
{
// Disarm the WorldBoundarySystem/Tick function
Expand All @@ -22,4 +22,4 @@ void DisableBoundaryTeleportPatch()

Log::Info("Disable boundary teleport: success");
}
*/

4 changes: 2 additions & 2 deletions src/patches/DisableVignette.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <stdafx.h>

/*

void DisableVignettePatch()
{
const RED4ext::RelocPtr<uint8_t> func(CyberEngineTweaks::Addresses::CPatches_Vignette);
Expand All @@ -21,4 +21,4 @@ void DisableVignettePatch()

Log::Info("Disable vignette patch: success");
}
*/

5 changes: 4 additions & 1 deletion src/patches/MinimapFlicker.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include <stdafx.h>

/*
/**
Does not seem to be needed since 2.0, keeping in case we need it again
void MinimapFlickerPatch()
{
const RED4ext::RelocPtr<uint8_t> func(CyberEngineTweaks::Addresses::CPatches_MinimapFlicker);
Expand Down
4 changes: 2 additions & 2 deletions src/patches/OptionsPatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void* HookGameOptionInit(GameOption* apThis)
return RealGameOptionInit(apThis);
}

/*

void OptionsInitHook()
{
const RED4ext::RelocPtr<uint8_t> func(CyberEngineTweaks::Addresses::CPatches_OptionsInit);
Expand All @@ -53,4 +53,4 @@ void OptionsInitHook()
else
Log::Warn("Hidden options hook: failed");
}
*/

12 changes: 9 additions & 3 deletions src/reverse/Addresses.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/
#include <cstdint>

// Addresses for Cyberpunk 2077, version 2.0.
namespace CyberEngineTweaks::Addresses
{
constexpr uintptr_t ImageBase = 0x140000000;
Expand All @@ -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
Expand All @@ -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 =
Expand Down Expand Up @@ -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

0 comments on commit 108b158

Please sign in to comment.