From f7c966cca634bb8e66664d4d2db882af3dadcd4c Mon Sep 17 00:00:00 2001 From: Garrett Brown Date: Tue, 23 Dec 2014 17:38:40 -0800 Subject: [dllLoader] Fix segfault if high-order word is zero If the high-order word is zero, then lpProcName is the function's ordinal value. See documentation for GetProcAddress(): - https://msdn.microsoft.com/en-us/library/windows/desktop/ms683212(v=vs.85).aspx --- xbmc/cores/DllLoader/Win32DllLoader.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/xbmc/cores/DllLoader/Win32DllLoader.cpp b/xbmc/cores/DllLoader/Win32DllLoader.cpp index 231501f570..e9b25a39f1 100644 --- a/xbmc/cores/DllLoader/Win32DllLoader.cpp +++ b/xbmc/cores/DllLoader/Win32DllLoader.cpp @@ -31,6 +31,8 @@ #include "exports/emu_kernel32.h" #include "exports/emu_msvcrt.h" +#include + extern "C" FILE _iob[]; extern "C" FARPROC WINAPI dllWin32GetProcAddress(HMODULE hModule, LPCSTR function); @@ -424,10 +426,14 @@ bool Win32DllLoader::ResolveOrdinal(const char *dllName, unsigned long ordinal, extern "C" FARPROC __stdcall dllWin32GetProcAddress(HMODULE hModule, LPCSTR function) { - // first check whether this function is one of the ones we need to wrap - void *fixup = NULL; - if (FunctionNeedsWrapping(win32_exports, function, &fixup)) - return (FARPROC)fixup; + // if the high-order word is zero, then lpProcName is the function's ordinal value + if (reinterpret_cast(function) > std::numeric_limits::max()) + { + // first check whether this function is one of the ones we need to wrap + void *fixup = NULL; + if (FunctionNeedsWrapping(win32_exports, function, &fixup)) + return (FARPROC)fixup; + } // Nope return GetProcAddress(hModule, function); -- cgit v1.2.3