From f9e092643b90f9e14d8d8b8564a59f0113e8ab2f Mon Sep 17 00:00:00 2001 From: maximegmd <672982+maximegmd@users.noreply.github.com> Date: Sat, 16 Mar 2024 11:12:38 +0100 Subject: [PATCH] remove outdated stuff --- ida/find_patterns.py | 175 ------------------------------------------- ida/patterns.py | 95 ----------------------- xmake.lua | 10 --- yawn/dllmain.cpp | 9 --- 4 files changed, 289 deletions(-) delete mode 100644 ida/find_patterns.py delete mode 100644 ida/patterns.py delete mode 100644 yawn/dllmain.cpp diff --git a/ida/find_patterns.py b/ida/find_patterns.py deleted file mode 100644 index 2725b742..00000000 --- a/ida/find_patterns.py +++ /dev/null @@ -1,175 +0,0 @@ -import traceback -from typing import Dict, List - -import ida_bytes -import ida_idaapi -import ida_kernwin -import ida_nalt -import idc - -ida_idaapi.require('patterns') - -cached_patterns: Dict[str, List[int]] = dict() - -def bin_search(bin_str: str) -> List[int]: - if not isinstance(bin_str, str): - raise ValueError('bin_str must be a string') - - if bin_str in cached_patterns: - return cached_patterns[bin_str] - - bin_list = bin_str.split() - image = bytearray() - mask = bytearray() - - # Create the mask and convert '?' to 'CC'. - for i in range(len(bin_list)): - byte = bin_list[i] - if byte== '?': - image.append(int('CC', 16)) - mask.append(0) - else: - image.append(int(byte, 16)) - mask.append(1) - - image = bytes(image) - mask = bytes(mask) - - start = ida_nalt.get_imagebase() - end = ida_idaapi.BADADDR - - addrs: List[int] = [] - - ea = ida_bytes.bin_search(start, end, image, mask, 0, ida_bytes.BIN_SEARCH_FORWARD) - while ea != ida_idaapi.BADADDR: - addrs.append(ea) - ea = ida_bytes.bin_search(ea + len(image), end, image, mask, 0, ida_bytes.BIN_SEARCH_FORWARD) - - cached_patterns[bin_str] = addrs - return cached_patterns[bin_str] - -def find_pattern(pattern: str, expected: int = 1, index: int = 0) -> int: - if not isinstance(expected, int): - raise ValueError('expected must be an integer') - - if not isinstance(index, int): - raise ValueError('index must be an integer') - - addrs = bin_search(pattern) - if len(addrs) != expected: - print(f'Found {len(addrs)} match(es) but {expected} match(es) were expected for pattern "{pattern}"') - return ida_idaapi.BADADDR - - return addrs[index] - -def find_function(pattern: str, expected: int = 1, index: int = 0, offset: int = 0) -> int: - addr = find_pattern(pattern, expected, index) - if addr == ida_idaapi.BADADDR: - return addr - - if offset != 0: - disp = ida_bytes.get_dword(addr + offset) - - if disp >= 1 << 31: - disp = 0xFFFFFFFF - disp - disp = disp + 1 - disp = -disp - - # Real address is: pattern_addr + offset + displacement + size_of_displacement. - return addr + offset + disp + 4 - - return addr - -def find_ptr(pattern: str, expected: int = 1, index: int = 0, offset: int = 0) -> int: - addr = find_pattern(pattern, expected, index) - if addr == ida_idaapi.BADADDR: - return addr - - disp = ida_bytes.get_dword(addr + offset) - - # Real address is: pattern_addr + offset + displacement + size_of_displacement. - return addr + offset + disp + 4 - -try: - groups = patterns.get_groups() - total = sum(map(lambda g: len(g.pointers) + len(g.functions), groups)) - - groups.sort(key=lambda g: g.name.lower()) - - # addr = find_ptr(pattern='4C 8D 05 ? ? ? ? 48 89 ? ? ? 00 00', expected=8, index=4, offset=3) - # version = idc.get_strlit_contents(addr) - - print(f'Finding {total} item(s)...') - with open('Addresses.h', 'w') as file: - file.write('#pragma once\n') - file.write('\n') - file.write('/*\n') - file.write(' * This file is generated. DO NOT modify it!\n') - file.write(' *\n') - file.write(' * Add new patterns in "patterns.py" file located in "project_root/scripts" and run "find_patterns.py".\n') - file.write(' * The new file should be located in "idb_path/Addresses.h".\n') - file.write(' */\n') - file.write('#include \n') - file.write('\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') - file.write('\n') - - for group in groups: - if group.name: - file.write(f'#pragma region {group.name}\n') - - for ptr in group.pointers: - addr = find_ptr(pattern=ptr.pattern, expected=ptr.expected, index=ptr.index, offset=ptr.offset) - if addr == ida_idaapi.BADADDR: - file.write(f'#error Could not find pattern "{ptr.pattern}", expected: {ptr.expected}, index: {ptr.index}, offset: {ptr.offset}\n') - continue - - if not group.name and not ptr.name: - ptr.name = f'ptr_{addr:X}' - - file.write('constexpr uintptr_t ') - if group.name: - file.write(f'{group.name}') - - if ptr.name: - file.write('_') - - ptr.name = ptr.name.replace('::', '_') - - file.write(f'{ptr.name} = 0x{addr:X} - ImageBase; ') - file.write(f'// {ptr.pattern}, expected: {ptr.expected}, index: {ptr.index}, offset: {ptr.offset}\n') - - for func in group.functions: - addr = find_function(pattern=func.pattern, expected=func.expected, index=func.index, offset=func.offset) - if addr == ida_idaapi.BADADDR: - file.write(f'#error Could not find pattern "{func.pattern}", expected: {func.expected}, index: {func.index}\n') - continue - - file.write('constexpr uintptr_t ') - - if group.name: - file.write(f'{group.name}_') - - if not func.name: - func.name = f'sub_{addr:X}' - - func.name = func.name.replace('::', '_') - - file.write(f'{func.name} = 0x{addr:X} - ImageBase; ') - file.write(f'// {func.pattern}, expected: {func.expected}, index: {func.index}\n') - - if group.name: - file.write(f'#pragma endregion\n') - - if group != groups[-1]: - file.write('\n') - - file.write('} // namespace CyberEngineTweaks::Addresses\n') - - print('Done!') - ida_kernwin.beep() -except: - traceback.print_exc() \ No newline at end of file diff --git a/ida/patterns.py b/ida/patterns.py deleted file mode 100644 index 82c1f379..00000000 --- a/ida/patterns.py +++ /dev/null @@ -1,95 +0,0 @@ -from typing import List - -class Item: - name: str - pattern: str - expected: int - index: int - offset: int - - def __init__(self, pattern: str, name: str = '', expected: int = 1, index: int = 0, offset: int = 0) -> None: - self.name = name - self.pattern = pattern - self.expected = expected - self.index = index - self.offset = offset - -class Group: - name: str - pointers: List[Item] - functions: List[Item] - - def __init__(self, name: str, pointers: List[Item] = [], functions: List[Item] = []) -> None: - self.name = name - self.pointers = pointers - self.functions = functions - -def get_groups() -> List[Group]: - # Add new patterns here, please try to keep the groups ordering alphabetized. - return [ - Group(name='CRenderGlobal', pointers=[ - # instance offset is used by CRenderNode_Present_DoInternal - Item(name='InstanceOffset', pattern='48 89 5C 24 08 48 89 6C 24 10 4C 89 4C 24 20 56 57 41 56 48 83 EC 30 8B 11 45 8B F0 48 8B 2D', expected=1, offset=31), # ok - Item(name='_DoNotUse_RenderQueueOffset', pattern='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) # ok - ], functions=[ - Item(name='Resize', pattern='48 8B C4 44 88 48 20 44 89 40 18 89 50 10 89 48 08 55 53 56 57 41 54 41 55 41 56 41 57 48 8D 68 ? 48 81 EC ? ? 00 00', expected=1), - Item(name='Shutdown', pattern='40 53 48 83 EC 20 48 8B D9 48 8D 05 ? ? ? ? 48 81 C1 98 00 00 00 48 89 01 E8', expected=1) - ]), - Group(name='CRenderNode_Present', functions=[ - Item(name='DoInternal', pattern='48 89 5C 24 08 48 89 6C 24 10 4C 89 4C 24 20 56 57 41 56 48 83 EC 30 8B 11 45 8B F0 48 8B 2D', expected=1) # ok - ]), - Group(name='CScript', functions=[ - Item(name='RunPureScript', pattern='40 55 48 81 EC D0 00 00 00 48 8D 6C 24 40 8B', expected=1), # ok - Item(name='AllocateFunction', pattern='40 53 48 83 EC 30 BA B8 00 00 00 48 8D 4C 24 20 E8', expected=2, index=0), # ok - Item(name='Log', pattern='48 8B C4 53 48 83 EC 70 48 83 60 C0 00 48 8D 48 C8 83 60 BC 00', expected=3, index=0), # ok - Item(name='LogError', pattern='48 8B C4 53 48 83 EC 70 48 83 60 C0 00 48 8D 48 C8 83 60 BC 00', expected=3, index=1), # ok - Item(name='LogWarning', pattern='48 8B C4 53 48 83 EC 70 48 83 60 C0 00 48 8D 48 C8 83 60 BC 00', expected=3, index=2), # ok - Item(name='ToStringDEBUG', pattern='48 89 5C 24 08 57 48 83 EC 20 83 64 24 38 00 4C 8D 15 ? ? ? ? FE 42 62 33 C0', expected=4, index=1), # ok - Item(name='LogChannel', pattern='48 89 5C 24 08 48 89 74 24 18 55 48 8B EC 48 83 EC 70 48 8B 02 48 8D 35 ? ? ? ? 48 83 65 18 00 4C 8D 45 18 48 83 62 30 00 45 33 C9 48 83 62 38 00', expected=2, index=0), # ok - Item(name='LogChannelWarning', pattern='48 89 5C 24 08 48 89 74 24 18 55 48 8B EC 48 83 EC 70 48 8B 02 48 8D 35 ? ? ? ? 48 83 65 18 00 4C 8D 45 18 48 83 62 30 00 45 33 C9 48 83 62 38 00', expected=2, index=1), # ok - Item(name='TDBIDConstructorDerive', pattern='48 89 5C 24 10 48 89 6C 24 18 48 89 74 24 20 57 45 33 C9 48 8B FA', expected=1), # ok - Item(name='TranslateBytecode', pattern='48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 48 83 EC 20 48 8B 1A 48 8B E9 8B 42 0C', expected=2, index=1), # ok - Item(name='TweakDBLoad', pattern='48 89 5C 24 10 48 89 7C 24 18 55 48 8B EC 48 ? EC 80 00 00 00 48 8B F9 48 8B DA 48 8B 0D', expected=1), # ok - Item(name='RegisterMemberFunction', pattern='40 53 48 83 EC 20 49 8B C1 4D 8B D0 44 8B 4C 24 58 4C 8B DA 41 83 C9 03 4C 8B C0 49 8B D2 48 8B D9 E8', expected=1) # ok - ]), - Group(name='CWinapi', functions=[ - Item(name='ClipToCenter', pattern='48 89 5C 24 08 55 48 8B EC 48 83 EC 30 48 8B D9 48 8B 89 ? 01 00 00', expected=1) # ok - ]), - Group(name='gameIGameSystem', functions=[ - Item(name='Initialize', pattern='48 89 5C 24 08 57 48 83 EC 30 48 8B 42 78 4C 8B CA 48 8B D9', expected=1), # ok - Item(name='UnInitialize', pattern=' 48 89 5C 24 10 48 89 74 24 18 57 48 83 EC 20 48 8B F9 48 8D 51 42', expected=2, index=1), # ok - Item(name='Spawn', pattern='48 89 5C 24 10 48 89 74 24 18 55 57 41 56 48 8D 6C 24 B0 48 81 EC 50 01 00 00 48 83 79 50 00 49 8B D9 4D 8B F0', expected=1), # ok - Item(name='Despawn', pattern='48 8B C4 48 89 58 08 48 89 68 10 48 89 70 18 48 89 78 20 41 56 48 83 EC 40 48 8B E9 0F 57 C0 48 83 C1 41 48 8B F2 F3 0F 7F 40 D8 E8', expected=1), # ok - Item(name='SpawnCallback', pattern='48 89 5C 24 10 48 89 6C 24 18 48 89 74 24 20 57 48 83 EC 60 48 8B F1 48 8B FA 48 83 C1 48 E8', expected=1) # ok - ]), - Group(name='CPhotoMode', functions=[ - 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 48 89 58 10 55 56 57 41 54 41 55 41 56 41 57 48 8D 6C 24 B0 48 81 EC ? 01 00 00 0F 29 ? 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='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=[ - Item(name='Main', pattern='48 89 5C 24 10 55 56 57 48 8B EC 48 81 EC 80 00 00 00 48 8B F9 0F 29 74 24 70 0F 29 7C 24 60 48 8D 4D C0', expected=1) # ok - ]), - Group(name='CBaseInitializationState', functions=[ - Item(name='OnTick', pattern='40 53 48 83 EC 20 48 8B 05 ? ? ? ? 33 DB 4C 8B C2 48 85 C0 ? ? ? ?', expected=1) # ok - ]), - Group(name='CInitializationState', functions=[ - Item(name='OnTick', pattern='40 53 48 83 EC 30 48 8B 05 ? ? ? ? 33 DB 4C 8B C2 8B 88 08 01 00 00', expected=1) # ok - ]), - Group(name='CRunningState', functions=[ - Item(name='OnTick', pattern='40 53 48 83 EC 30 83 64 24 28 00 48 8D 05 ? ? ? ? 48 8B 0D ? ? ? ? 48 8B DA', expected=1) # ok - ]), - Group(name='CShutdownState', functions=[ - Item(name='OnTick', pattern='48 89 5C 24 08 57 48 83 EC 20 48 8B 0D ? ? ? ? 48', expected=1) # ok - ]), - Group(name='PlayerSystem', functions=[ - Item(name='OnPlayerSpawned', pattern='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) - ]), - ] - diff --git a/xmake.lua b/xmake.lua index 42c9cd49..77f41140 100644 --- a/xmake.lua +++ b/xmake.lua @@ -106,16 +106,6 @@ target("cyber_engine_tweaks") cprint("Cyber Engine Tweaks installed at: ${underline}%s", "$(installpath)") end) -target("fake_cyber_engine_tweaks") - set_kind("shared") - set_group("yawn") - set_filename("cyber_engine_tweaks.dll") - add_files("yawn/dllmain.cpp") - - on_package(function(target) - os.cp(target:targetfile(), "package/red4ext/plugins/cyber_engine_tweaks/") - end) - option("installpath") set_default("installpath") set_showmenu(true) diff --git a/yawn/dllmain.cpp b/yawn/dllmain.cpp deleted file mode 100644 index be38e61c..00000000 --- a/yawn/dllmain.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include - -BOOL WINAPI DllMain( - HINSTANCE hinstDLL, // handle to DLL module - DWORD fdwReason, // reason for calling function - LPVOID lpvReserved ) // reserved -{ - return TRUE; -} \ No newline at end of file