Skip to content

Commit

Permalink
Add missing Make32to64Call helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
illusion0001 committed Dec 9, 2024
1 parent e5af182 commit 92fd5a9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@ void WritePatchAddressFloat64(uint64_t Patch_Address, const double* Patch_Bytes,
wchar_t* GetRunningPath(wchar_t* output);
wchar_t* GetModuleName(wchar_t* output);
uintptr_t FindAndPrintPatternW(const wchar_t* Patch_Pattern, const wchar_t* Pattern_Name, size_t offset = 0);
void Make32to64Call(void* source_target, void* second_jmp, void* target_jmp, uint32_t source_size, const wchar_t* source_name, const wchar_t* second_jmp_name, const wchar_t* target_jmp_name);
void Make32to64Hook(void* source_target, void* second_jmp, void* target_jmp, uint32_t source_size, const wchar_t* source_name, const wchar_t* second_jmp_name, const wchar_t* target_jmp_name);
void Make32Hook(void* source_target, void* target_jmp, uint32_t source_size, const wchar_t* source_name, const wchar_t* target_jmp_name);
void Make64Hook(void* source_target, void* target_jmp, uint32_t source_size, const wchar_t* source_name, const wchar_t* target_jmp_name);
uintptr_t ReadLEA32(const wchar_t* Patch_Pattern, const wchar_t* Pattern_Name, size_t offset, size_t lea_size, size_t lea_opcode_size);
uintptr_t ReadLEA32(uintptr_t Address, const wchar_t* Pattern_Name, size_t offset, size_t lea_size, size_t lea_opcode_size);

#define MAKE32HOOK(src,mid,dest,size) Make32to64Hook((void*)(src),(void*)(mid),(void*)(dest),size,TEXT(#src) " Size: " #size ,TEXT(#mid),TEXT(#dest))
#define MAKE32CALL(src,mid,dest,size) Make32to64Call((void*)(src),(void*)(mid),(void*)(dest),size,TEXT(#src) " Size: " #size ,TEXT(#mid),TEXT(#dest))

#define SID(str) ToStringId64(str)
typedef uint64_t StringId64;
#define FNVA1_BASE 0xCBF29CE484222325
Expand Down
17 changes: 17 additions & 0 deletions source/Shared/helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,23 @@ uintptr_t FindAndPrintPatternW(const wchar_t* Patch_Pattern, const wchar_t* Patt
return 0;
}

void Make32to64Call(void* source_target, void* second_jmp, void* target_jmp, uint32_t source_size, const wchar_t* source_name, const wchar_t* second_jmp_name, const wchar_t* target_jmp_name)
{
if (!source_target || !second_jmp || !target_jmp || source_size < 5)
{
LOG(L"Canoot create jump '%s' from '%s' to '%s'\n", source_name, second_jmp_name, target_jmp_name);
LOG(L"source_target: 0x%p\n", source_target);
LOG(L"source_size: %u bytes\n", source_size);
LOG(L"second_jmp: 0x%p\n", second_jmp);
LOG(L"target_jmp: 0x%p\n", target_jmp);
return;
}
Memory::CallFunction32((void*)source_target, (void*)second_jmp, source_size);
LOG(L"Created jump %s (0x%016llx) to %s (0x%016llx)\n", source_name, (uintptr_t)source_target, second_jmp_name, (uintptr_t)second_jmp);
Memory::DetourFunction64((void*)second_jmp, (void*)target_jmp, 14);
LOG(L"Created jump %s (0x%016llx) to %s (0x%016llx)\n", second_jmp_name, (uintptr_t)second_jmp, target_jmp_name, (uintptr_t)target_jmp);
}

void Make32to64Hook(void* source_target, void* second_jmp, void* target_jmp, uint32_t source_size, const wchar_t* source_name, const wchar_t* second_jmp_name, const wchar_t* target_jmp_name)
{
if (!source_target || !second_jmp || !target_jmp || source_size < 5)
Expand Down

0 comments on commit 92fd5a9

Please sign in to comment.