From c296ee510f6ecfa15f3939ce20faa101d12fa5a0 Mon Sep 17 00:00:00 2001 From: Mark Jansen Date: Sun, 13 Jan 2019 19:41:51 +0100 Subject: [PATCH] [DBGHELP_APITEST] Skip the test when the function is not found --- modules/rostests/apitests/dbghelp/pdb.c | 44 ++++++++++++++++++++----- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/modules/rostests/apitests/dbghelp/pdb.c b/modules/rostests/apitests/dbghelp/pdb.c index 2db3935fe4d..8f4988ac0c7 100644 --- a/modules/rostests/apitests/dbghelp/pdb.c +++ b/modules/rostests/apitests/dbghelp/pdb.c @@ -11,6 +11,7 @@ #include #include // SymTagXXX #include +#include #include "wine/test.h" @@ -189,6 +190,37 @@ static void init_dbghelp_version() LOWORD(fileInfo.dwProductVersionLS)); } +static +int g_SymRegisterCallbackW64NotFound = 0; + +static +BOOL WINAPI SymRegisterCallbackW64_Stub(HANDLE hProcess, PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction, ULONG64 UserContext) +{ + g_SymRegisterCallbackW64NotFound++; + return FALSE; +} + +/* A delay-load failure hook will be called when resolving a delay-load dependency (dll or function) fails */ +FARPROC WINAPI DliFailHook(unsigned dliNotify, PDelayLoadInfo pdli) +{ + /* Was the failure a function, and did we get info */ + if (dliNotify == dliFailGetProc && pdli) + { + /* Is it our function? */ + if (pdli->dlp.fImportByName && !strcmp(pdli->dlp.szProcName, "SymRegisterCallbackW64")) + { + /* Redirect execution to the stub */ + return (FARPROC)SymRegisterCallbackW64_Stub; + } + } + /* This is not the function you are looking for, continue default behavior (throw exception) */ + return NULL; +} + +/* Register the failure hook using the magic name '__pfnDliFailureHook2'. */ +PfnDliHook __pfnDliFailureHook2 = DliFailHook; + + /* Maybe our dbghelp.dll is too old? */ static BOOL can_enumerate(HANDLE hProc, DWORD64 BaseAddress) { @@ -544,18 +576,12 @@ static void test_SymRegCallback(HANDLE hProc, const char* szModuleName, BOOL tes } else { - // dbghelp fileversion 5.2.3790.3959 - // SymRegisterCallbackW64 crash only happens on real Windows 2003 - // Fileversion 5.2.3790.3959 is used in Windows 2003. - // In ROS there is no crash. - // I could not figure out whats wrong. - if ((dbghelpFileVer.dwProductVersionMS == MAKELONG(2, 5)) && - (dbghelpFileVer.dwProductVersionLS == MAKELONG(3959, 3790))) + Ret = SymRegisterCallbackW64(hProc, SymRegisterCallback64Proc, (ULONG_PTR)&ctx); + if (g_SymRegisterCallbackW64NotFound) { - skip("dbghelp.dll ver 5.2.3790.3959 (w2k3), SymRegisterCallbackW64 would crash!\n"); + skip("SymRegisterCallbackW64 not found in dbghelp.dll\n"); return; } - Ret = SymRegisterCallbackW64(hProc, SymRegisterCallback64Proc, (ULONG_PTR)&ctx); } ok_int(Ret, TRUE); -- 2.17.1