1
0
mirror of https://github.com/djhackersdev/bemanitools.git synced 2025-02-17 19:19:16 +01:00

sdvxhook2: fix crash when using sdvxhook2 on certain OS versions

This commit is contained in:
Will Xyen 2022-05-19 20:52:45 -07:00 committed by 6fe20d9b80a9661a09ef66dfd58832d49592386b
parent bd2d722031
commit 537b1fa384

View File

@ -1,4 +1,4 @@
#define LOG_MODULE "power-hook" #define LOG_MODULE "nvapi-hook"
// clang-format off // clang-format off
// Don't format because the order is important here // Don't format because the order is important here
@ -33,11 +33,15 @@ static struct hook_symbol nvapihook_kernel_syms[] = {
static void *my_GetProcAddress(HMODULE dll, const char *name) static void *my_GetProcAddress(HMODULE dll, const char *name)
{ {
if (name != NULL && ((intptr_t) name) > UINT16_MAX) {
// only strcmp is non-ordinal
// https://docs.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getprocaddress
if (strcmp("nvapi_QueryInterface", name) == 0) { if (strcmp("nvapi_QueryInterface", name) == 0) {
log_info("Request for stub %s", name); log_info("Request for stub %s", name);
real_nvapi_QueryInterface = real_GetProcAddress(dll, name); real_nvapi_QueryInterface = real_GetProcAddress(dll, name);
return &my_nvapi_QueryInterface; return &my_nvapi_QueryInterface;
} }
}
// log_warning("Request for unknown stub %s", name); // log_warning("Request for unknown stub %s", name);
return real_GetProcAddress(dll, name); return real_GetProcAddress(dll, name);