mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Update Detours
This commit is contained in:
parent
9b5d80ee95
commit
747fad353e
detours
@ -45,8 +45,18 @@
|
||||
#pragma warning(disable:6102 6103) // /analyze warnings
|
||||
#endif
|
||||
#include <strsafe.h>
|
||||
#include <intsafe.h>
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
#include <crtdbg.h>
|
||||
|
||||
// Allow Detours to cleanly compile with the MingW toolchain.
|
||||
//
|
||||
#ifdef __GNUC__
|
||||
#define __try
|
||||
#define __except(x) if (0)
|
||||
#include <strsafe.h>
|
||||
#endif
|
||||
|
||||
// From winerror.h, as this error isn't found in some SDKs:
|
||||
//
|
||||
@ -118,7 +128,7 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
#if (_MSC_VER < 1299)
|
||||
#if (_MSC_VER < 1299) && !defined(__MINGW32__)
|
||||
typedef LONG LONG_PTR;
|
||||
typedef ULONG ULONG_PTR;
|
||||
#endif
|
||||
@ -605,16 +615,17 @@ _Readable_bytes_(*pcbData)
|
||||
_Success_(return != NULL)
|
||||
PVOID WINAPI DetourFindPayload(_In_opt_ HMODULE hModule,
|
||||
_In_ REFGUID rguid,
|
||||
_Out_ DWORD *pcbData);
|
||||
_Out_opt_ DWORD *pcbData);
|
||||
|
||||
_Writable_bytes_(*pcbData)
|
||||
_Readable_bytes_(*pcbData)
|
||||
_Success_(return != NULL)
|
||||
PVOID WINAPI DetourFindPayloadEx(_In_ REFGUID rguid,
|
||||
_Out_ DWORD * pcbData);
|
||||
_Out_opt_ DWORD *pcbData);
|
||||
|
||||
DWORD WINAPI DetourGetSizeOfPayloads(_In_opt_ HMODULE hModule);
|
||||
|
||||
BOOL WINAPI DetourFreePayload(_In_ PVOID pvData);
|
||||
///////////////////////////////////////////////// Persistent Binary Functions.
|
||||
//
|
||||
|
||||
@ -653,6 +664,11 @@ BOOL WINAPI DetourBinaryClose(_In_ PDETOUR_BINARY pBinary);
|
||||
|
||||
/////////////////////////////////////////////////// Create Process & Load Dll.
|
||||
//
|
||||
_Success_(return != NULL)
|
||||
PVOID WINAPI DetourFindRemotePayload(_In_ HANDLE hProcess,
|
||||
_In_ REFGUID rguid,
|
||||
_Out_opt_ DWORD *pcbData);
|
||||
|
||||
typedef BOOL (WINAPI *PDETOUR_CREATE_PROCESS_ROUTINEA)(
|
||||
_In_opt_ LPCSTR lpApplicationName,
|
||||
_Inout_opt_ LPSTR lpCommandLine,
|
||||
@ -819,8 +835,14 @@ BOOL WINAPI DetourUpdateProcessWithDllEx(_In_ HANDLE hProcess,
|
||||
|
||||
BOOL WINAPI DetourCopyPayloadToProcess(_In_ HANDLE hProcess,
|
||||
_In_ REFGUID rguid,
|
||||
_In_reads_bytes_(cbData) PVOID pvData,
|
||||
_In_reads_bytes_(cbData) LPCVOID pvData,
|
||||
_In_ DWORD cbData);
|
||||
_Success_(return != NULL)
|
||||
PVOID WINAPI DetourCopyPayloadToProcessEx(_In_ HANDLE hProcess,
|
||||
_In_ REFGUID rguid,
|
||||
_In_reads_bytes_(cbData) LPCVOID pvData,
|
||||
_In_ DWORD cbData);
|
||||
|
||||
BOOL WINAPI DetourRestoreAfterWith(VOID);
|
||||
BOOL WINAPI DetourRestoreAfterWithEx(_In_reads_bytes_(cbData) PVOID pvData,
|
||||
_In_ DWORD cbData);
|
||||
@ -836,6 +858,60 @@ VOID CALLBACK DetourFinishHelperProcess(_In_ HWND,
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
/////////////////////////////////////////////////// Type-safe overloads for C++
|
||||
//
|
||||
#if __cplusplus >= 201103L || _MSVC_LANG >= 201103L
|
||||
#include <type_traits>
|
||||
|
||||
template<typename T>
|
||||
struct DetoursIsFunctionPointer : std::false_type {};
|
||||
|
||||
template<typename T>
|
||||
struct DetoursIsFunctionPointer<T*> : std::is_function<typename std::remove_pointer<T>::type> {};
|
||||
|
||||
template<
|
||||
typename T,
|
||||
typename std::enable_if<DetoursIsFunctionPointer<T>::value, int>::type = 0>
|
||||
LONG DetourAttach(_Inout_ T *ppPointer,
|
||||
_In_ T pDetour) noexcept
|
||||
{
|
||||
return DetourAttach(
|
||||
reinterpret_cast<void**>(ppPointer),
|
||||
reinterpret_cast<void*>(pDetour));
|
||||
}
|
||||
|
||||
template<
|
||||
typename T,
|
||||
typename std::enable_if<DetoursIsFunctionPointer<T>::value, int>::type = 0>
|
||||
LONG DetourAttachEx(_Inout_ T *ppPointer,
|
||||
_In_ T pDetour,
|
||||
_Out_opt_ PDETOUR_TRAMPOLINE *ppRealTrampoline,
|
||||
_Out_opt_ T *ppRealTarget,
|
||||
_Out_opt_ T *ppRealDetour) noexcept
|
||||
{
|
||||
return DetourAttachEx(
|
||||
reinterpret_cast<void**>(ppPointer),
|
||||
reinterpret_cast<void*>(pDetour),
|
||||
ppRealTrampoline,
|
||||
reinterpret_cast<void**>(ppRealTarget),
|
||||
reinterpret_cast<void**>(ppRealDetour));
|
||||
}
|
||||
|
||||
template<
|
||||
typename T,
|
||||
typename std::enable_if<DetoursIsFunctionPointer<T>::value, int>::type = 0>
|
||||
LONG DetourDetach(_Inout_ T *ppPointer,
|
||||
_In_ T pDetour) noexcept
|
||||
{
|
||||
return DetourDetach(
|
||||
reinterpret_cast<void**>(ppPointer),
|
||||
reinterpret_cast<void*>(pDetour));
|
||||
}
|
||||
|
||||
#endif // __cplusplus >= 201103L || _MSVC_LANG >= 201103L
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////// Detours Internal Definitions.
|
||||
//
|
||||
#ifdef __cplusplus
|
||||
@ -846,7 +922,7 @@ VOID CALLBACK DetourFinishHelperProcess(_In_ HWND,
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
#if (_MSC_VER < 1299)
|
||||
#if (_MSC_VER < 1299) && !defined(__GNUC__)
|
||||
#include <imagehlp.h>
|
||||
typedef IMAGEHLP_MODULE IMAGEHLP_MODULE64;
|
||||
typedef PIMAGEHLP_MODULE PIMAGEHLP_MODULE64;
|
||||
@ -908,6 +984,21 @@ PDETOUR_SYM_INFO DetourLoadImageHlp(VOID);
|
||||
#endif
|
||||
#define _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS 1
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
int Detour_AssertExprWithFunctionName(int reportType, const char* filename, int linenumber, const char* FunctionName, const char* msg);
|
||||
|
||||
#define DETOUR_ASSERT_EXPR_WITH_FUNCTION(expr, msg) \
|
||||
(void) ((expr) || \
|
||||
(1 != Detour_AssertExprWithFunctionName(_CRT_ASSERT, __FILE__, __LINE__,__FUNCTION__, msg)) || \
|
||||
(_CrtDbgBreak(), 0))
|
||||
|
||||
#define DETOUR_ASSERT(expr) DETOUR_ASSERT_EXPR_WITH_FUNCTION((expr), #expr)
|
||||
|
||||
#else// _DEBUG
|
||||
#define DETOUR_ASSERT(expr)
|
||||
#endif// _DEBUG
|
||||
|
||||
#ifndef DETOUR_TRACE
|
||||
#if DETOUR_DEBUG
|
||||
#define DETOUR_TRACE(x) printf x
|
||||
@ -1114,6 +1205,9 @@ BOOL WINAPI DetourVirtualProtectSameExecute(_In_ PVOID pAddress,
|
||||
_In_ SIZE_T nSize,
|
||||
_In_ DWORD dwNewProtect,
|
||||
_Out_ PDWORD pdwOldProtect);
|
||||
|
||||
// Detours must depend only on kernel32.lib, so we cannot use IsEqualGUID
|
||||
BOOL WINAPI DetourAreSameGuid(_In_ REFGUID left, _In_ REFGUID right);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user