mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Update Microsoft Detours to latest
This commit is contained in:
parent
61684ddf87
commit
e0fa00abf5
15
r5dev/thirdparty/detours/include/detours.h
vendored
15
r5dev/thirdparty/detours/include/detours.h
vendored
@ -56,6 +56,7 @@
|
||||
#define __try
|
||||
#define __except(x) if (0)
|
||||
#include <strsafe.h>
|
||||
#include <intsafe.h>
|
||||
#endif
|
||||
|
||||
// From winerror.h, as this error isn't found in some SDKs:
|
||||
@ -382,6 +383,10 @@ extern const GUID DETOUR_EXE_HELPER_GUID;
|
||||
#define DETOUR_TRAMPOLINE_SIGNATURE 0x21727444 // Dtr!
|
||||
typedef struct _DETOUR_TRAMPOLINE DETOUR_TRAMPOLINE, *PDETOUR_TRAMPOLINE;
|
||||
|
||||
#ifndef DETOUR_MAX_SUPPORTED_IMAGE_SECTION_HEADERS
|
||||
#define DETOUR_MAX_SUPPORTED_IMAGE_SECTION_HEADERS 32
|
||||
#endif // !DETOUR_MAX_SUPPORTED_IMAGE_SECTION_HEADERS
|
||||
|
||||
/////////////////////////////////////////////////////////// Binary Structures.
|
||||
//
|
||||
#pragma pack(push, 8)
|
||||
@ -453,9 +458,9 @@ typedef struct _DETOUR_EXE_RESTORE
|
||||
#endif
|
||||
#ifdef IMAGE_NT_OPTIONAL_HDR64_MAGIC // some environments do not have this
|
||||
BYTE raw[sizeof(IMAGE_NT_HEADERS64) +
|
||||
sizeof(IMAGE_SECTION_HEADER) * 32];
|
||||
sizeof(IMAGE_SECTION_HEADER) * DETOUR_MAX_SUPPORTED_IMAGE_SECTION_HEADERS];
|
||||
#else
|
||||
BYTE raw[0x108 + sizeof(IMAGE_SECTION_HEADER) * 32];
|
||||
BYTE raw[0x108 + sizeof(IMAGE_SECTION_HEADER) * DETOUR_MAX_SUPPORTED_IMAGE_SECTION_HEADERS];
|
||||
#endif
|
||||
};
|
||||
DETOUR_CLR_HEADER clr;
|
||||
@ -590,6 +595,8 @@ BOOL WINAPI DetourSetCodeModule(_In_ HMODULE hModule,
|
||||
_In_ BOOL fLimitReferencesToModule);
|
||||
PVOID WINAPI DetourAllocateRegionWithinJumpBounds(_In_ LPCVOID pbTarget,
|
||||
_Out_ PDWORD pcbAllocatedSize);
|
||||
BOOL WINAPI DetourIsFunctionImported(_In_ PBYTE pbCode,
|
||||
_In_ PBYTE pbAddress);
|
||||
|
||||
///////////////////////////////////////////////////// Loaded Binary Functions.
|
||||
//
|
||||
@ -951,10 +958,10 @@ typedef DWORD (NTAPI *PF_SymSetOptions)(_In_ DWORD SymOptions);
|
||||
typedef DWORD (NTAPI *PF_SymGetOptions)(VOID);
|
||||
typedef DWORD64 (NTAPI *PF_SymLoadModule64)(_In_ HANDLE hProcess,
|
||||
_In_opt_ HANDLE hFile,
|
||||
_In_ LPSTR ImageName,
|
||||
_In_opt_ LPSTR ImageName,
|
||||
_In_opt_ LPSTR ModuleName,
|
||||
_In_ DWORD64 BaseOfDll,
|
||||
_In_opt_ DWORD SizeOfDll);
|
||||
_In_ DWORD SizeOfDll);
|
||||
typedef BOOL (NTAPI *PF_SymGetModuleInfo64)(_In_ HANDLE hProcess,
|
||||
_In_ DWORD64 qwAddr,
|
||||
_Out_ PIMAGEHLP_MODULE64 ModuleInfo);
|
||||
|
9
r5dev/thirdparty/detours/src/detours.cpp
vendored
9
r5dev/thirdparty/detours/src/detours.cpp
vendored
@ -1395,6 +1395,12 @@ PVOID WINAPI DetourAllocateRegionWithinJumpBounds(_In_ LPCVOID pbTarget,
|
||||
return pbNewlyAllocated;
|
||||
}
|
||||
|
||||
BOOL WINAPI DetourIsFunctionImported(_In_ PBYTE pbCode,
|
||||
_In_ PBYTE pbAddress)
|
||||
{
|
||||
return detour_is_imported(pbCode, pbAddress);
|
||||
}
|
||||
|
||||
static PDETOUR_TRAMPOLINE detour_alloc_trampoline(PBYTE pbTarget)
|
||||
{
|
||||
// We have to place trampolines within +/- 2GB of target.
|
||||
@ -1437,7 +1443,8 @@ static PDETOUR_TRAMPOLINE detour_alloc_trampoline(PBYTE pbTarget)
|
||||
// We need to allocate a new region.
|
||||
|
||||
// Round pbTarget down to 64KB block.
|
||||
pbTarget = pbTarget - (PtrToUlong(pbTarget) & 0xffff);
|
||||
// /RTCc RuntimeChecks breaks PtrToUlong.
|
||||
pbTarget = pbTarget - (ULONG)((ULONG_PTR)pbTarget & 0xffff);
|
||||
|
||||
PVOID pbNewlyAllocated =
|
||||
detour_alloc_trampoline_allocate_new(pbTarget, pLo, pHi);
|
||||
|
Loading…
x
Reference in New Issue
Block a user