Merge pull request #115430 from bruvzg/iat_disable_msvc_cf
[Windows] Disable MSVC control flow check on IAT hooks.
This commit is contained in:
commit
a1746ee204
1 changed files with 8 additions and 2 deletions
|
|
@ -2758,6 +2758,12 @@ bool OS_Windows::_test_create_rendering_device_and_gl(const String &p_display_dr
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define IAT_HOOK_CALL __declspec(guard(nocf))
|
||||
#else
|
||||
#define IAT_HOOK_CALL
|
||||
#endif
|
||||
|
||||
using GetProcAddressType = FARPROC(__stdcall *)(HMODULE, LPCSTR);
|
||||
GetProcAddressType Original_GetProcAddress = nullptr;
|
||||
|
||||
|
|
@ -2793,7 +2799,7 @@ bool _hid_is_controller(HANDLE p_hid_handle) {
|
|||
return false;
|
||||
}
|
||||
|
||||
BOOLEAN __stdcall Hook_HidD_GetProductString(HANDLE p_object, void *p_buffer, ULONG p_buffer_length) {
|
||||
IAT_HOOK_CALL BOOLEAN __stdcall Hook_HidD_GetProductString(HANDLE p_object, void *p_buffer, ULONG p_buffer_length) {
|
||||
constexpr const wchar_t unknown_product_string[] = L"Unknown HID Device";
|
||||
constexpr size_t unknown_product_length = sizeof(unknown_product_string);
|
||||
|
||||
|
|
@ -2811,7 +2817,7 @@ BOOLEAN __stdcall Hook_HidD_GetProductString(HANDLE p_object, void *p_buffer, UL
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
FARPROC __stdcall Hook_GetProcAddress(HMODULE p_module, LPCSTR p_name) {
|
||||
IAT_HOOK_CALL FARPROC __stdcall Hook_GetProcAddress(HMODULE p_module, LPCSTR p_name) {
|
||||
if (String(p_name) == "HidD_GetProductString") {
|
||||
return (FARPROC)(LPVOID)Hook_HidD_GetProductString;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue