ReactOS 0.4.16-dev-2491-g3dc6630
pdb.c File Reference
#include <ntstatus.h>
#include <windows.h>
#include <dbghelp.h>
#include <cvconst.h>
#include <stdio.h>
#include <delayimp.h>
#include "wine/test.h"
Include dependency graph for pdb.c:

Go to the source code of this file.

Classes

struct  _test_context
 
struct  _test_data
 
struct  _symregcallback_context
 
struct  _symregcallback_test_data
 

Macros

#define WIN32_NO_STATUS
 
#define ok_ulonglong(expression, result)
 
#define init_sym(fInvadeProcess)   init_sym_imp(fInvadeProcess, __FILE__, __LINE__)
 
#define INIT_PSYM(buff)
 

Typedefs

typedef struct _test_context test_context
 
typedef struct _symregcallback_context symregcallback_context
 

Functions

void create_compressed_files ()
 
int extract_msvc_dll (char szFile[MAX_PATH], char szPath[MAX_PATH])
 
void cleanup_msvc_dll ()
 
static HANDLE proc ()
 
static BOOL init_sym_imp (BOOL fInvadeProcess, const char *file, int line)
 
static void deinit_sym ()
 
BOOL get_module_version (_In_ HMODULE mod, _Out_ VS_FIXEDFILEINFO *fileinfo)
 
static void init_dbghelp_version ()
 
static BOOL WINAPI SymRegisterCallbackW64_Stub (HANDLE hProcess, PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction, ULONG64 UserContext)
 
FARPROC WINAPI DliFailHook (unsigned dliNotify, PDelayLoadInfo pdli)
 
static BOOL supports_pdb (HANDLE hProc, DWORD64 BaseAddress)
 
static void test_SymFromName (HANDLE hProc, DWORD64 BaseAddress)
 
static void test_SymFromAddr (HANDLE hProc, DWORD64 BaseAddress)
 
static BOOL CALLBACK EnumSymProc (PSYMBOL_INFO pSymInfo, ULONG SymbolSize, PVOID UserContext)
 
static void test_SymEnumSymbols (HANDLE hProc, DWORD64 BaseAddress)
 
static BOOL CALLBACK SymRegisterCallback64Proc (HANDLE hProcess, ULONG ActionCode, ULONG64 CallbackData, ULONG64 UserContext)
 
static void test_SymRegCallback (HANDLE hProc, const char *szModuleName, BOOL testANSI)
 
 START_TEST (pdb)
 

Variables

static VS_FIXEDFILEINFO dbghelpFileVer
 
static int g_SymRegisterCallbackW64NotFound = 0
 
PfnDliHook __pfnDliFailureHook2 = DliFailHook
 
static struct _test_data test_data []
 
static struct _symregcallback_test_data symregcallback_test_data []
 

Macro Definition Documentation

◆ INIT_PSYM

#define INIT_PSYM (   buff)
Value:
do { \
memset((buff), 0, sizeof((buff))); \
((PSYMBOL_INFO)(buff))->SizeOfStruct = sizeof(SYMBOL_INFO); \
((PSYMBOL_INFO)(buff))->MaxNameLen = MAX_SYM_NAME; \
} while (0)
struct _SYMBOL_INFO * PSYMBOL_INFO
#define MAX_SYM_NAME
Definition: compat.h:975
static unsigned char buff[32768]
Definition: fatten.c:17

Definition at line 55 of file pdb.c.

◆ init_sym

#define init_sym (   fInvadeProcess)    init_sym_imp(fInvadeProcess, __FILE__, __LINE__)

Definition at line 53 of file pdb.c.

◆ ok_ulonglong

#define ok_ulonglong (   expression,
  result 
)
Value:
do { \
ULONG64 _value = (expression); \
ULONG64 _result = (result); \
ok(_value == (result), "Wrong value for '%s', expected: " #result " (%s), got: %s\n", \
#expression, wine_dbgstr_longlong(_result), wine_dbgstr_longlong(_value)); \
} while (0)
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
GLuint64EXT * result
Definition: glext.h:11304
unsigned __int64 ULONG64
Definition: imports.h:198

Definition at line 18 of file pdb.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 9 of file pdb.c.

Typedef Documentation

◆ symregcallback_context

◆ test_context

Function Documentation

◆ cleanup_msvc_dll()

void cleanup_msvc_dll ( )

Definition at line 90 of file data.c.

91{
92 char szFile[MAX_PATH];
93 BOOL ret;
94 const char* dir = tmpdir();
95
96 sprintf(szFile, "%s\\uffs.pdb", dir);
97 ret = DeleteFileA(szFile);
98 ok(ret, "DeleteFileA failed(%d)\n", GetLastError());
99
100 sprintf(szFile, "%s\\uffs.dll", dir);
101 ret = DeleteFileA(szFile);
102 ok(ret, "DeleteFileA failed(%d)\n", GetLastError());
104 ok(ret, "RemoveDirectoryA failed(%d)\n", GetLastError());
105}
unsigned int dir
Definition: maze.c:112
#define ok(value,...)
Definition: atltest.h:57
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
Definition: dir.c:682
return ret
Definition: mutex.c:146
unsigned int BOOL
Definition: ntddk_ex.h:94
#define sprintf
Definition: sprintf.c:45
static const char * tmpdir()
Definition: data.c:18
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by START_TEST().

◆ create_compressed_files()

void create_compressed_files ( )

◆ deinit_sym()

static void deinit_sym ( )
static

Definition at line 48 of file pdb.c.

49{
51}
BOOL WINAPI SymCleanup(HANDLE hProcess)
Definition: dbghelp.c:557
static HANDLE proc()
Definition: pdb.c:32

Referenced by START_TEST(), and test_SymRegCallback().

◆ DliFailHook()

FARPROC WINAPI DliFailHook ( unsigned  dliNotify,
PDelayLoadInfo  pdli 
)

Definition at line 204 of file pdb.c.

205{
206 /* Was the failure a function, and did we get info */
207 if (dliNotify == dliFailGetProc && pdli)
208 {
209 /* Is it our function? */
210 if (pdli->dlp.fImportByName && !strcmp(pdli->dlp.szProcName, "SymRegisterCallbackW64"))
211 {
212 /* Redirect execution to the stub */
214 }
215 }
216 /* This is not the function you are looking for, continue default behavior (throw exception) */
217 return NULL;
218}
@ dliFailGetProc
Definition: delayimp.h:38
#define NULL
Definition: types.h:112
int(* FARPROC)()
Definition: compat.h:36
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3319
static BOOL WINAPI SymRegisterCallbackW64_Stub(HANDLE hProcess, PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction, ULONG64 UserContext)
Definition: pdb.c:197
DelayLoadProc dlp
Definition: delayimp.h:71
BOOL fImportByName
Definition: delayimp.h:57
LPCSTR szProcName
Definition: delayimp.h:60

◆ EnumSymProc()

static BOOL CALLBACK EnumSymProc ( PSYMBOL_INFO  pSymInfo,
ULONG  SymbolSize,
PVOID  UserContext 
)
static

Definition at line 439 of file pdb.c.

440{
441 test_context* ctx = UserContext;
442
443 if (ctx->Index < ARRAYSIZE(test_data))
444 {
445 ok_ulonglong(pSymInfo->ModBase, ctx->BaseAddress);
446 ok_ulonglong(pSymInfo->Address, ctx->BaseAddress + test_data[ctx->Index].AddressOffset);
447 ok_hex(pSymInfo->Tag, test_data[ctx->Index].Tag);
448 ok_str(pSymInfo->Name, test_data[ctx->Index].Name);
449
450 ctx->Index++;
451 }
452 else
453 {
454 ok(0, "Out of bounds (%lu), max is: %i!\n", ctx->Index, ARRAYSIZE(test_data));
455 }
456
457 return TRUE;
458}
#define ok_hex(expression, result)
Definition: atltest.h:94
#define ok_str(x, y)
Definition: atltest.h:127
#define TRUE
Definition: types.h:120
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define ok_ulonglong(expression, result)
Definition: pdb.c:18
ULONG64 ModBase
Definition: compat.h:1043
ULONG Tag
Definition: compat.h:1049
CHAR Name[1]
Definition: compat.h:1052
ULONG64 Address
Definition: compat.h:1046

Referenced by test_SymEnumSymbols().

◆ extract_msvc_dll()

int extract_msvc_dll ( char  szFile[MAX_PATH],
char  szPath[MAX_PATH] 
)

Definition at line 72 of file data.c.

73{
74 const char* dir = tmpdir();
76 ok(ret, "CreateDirectoryA failed(%d)\n", GetLastError());
77
78 sprintf(szFile, "%s\\uffs.pdb", dir);
79 if (!extract_one(szFile, "msvc_uffs.pdb"))
80 return 0;
81
82 sprintf(szFile, "%s\\uffs.dll", dir);
83 if (!extract_one(szFile, "msvc_uffs.dll"))
84 return 0;
85
87 return 1;
88}
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:37
LPCWSTR szPath
Definition: env.c:37
static int extract_one(const char *filename, const char *resid)
Definition: data.c:28
strcpy
Definition: string.h:131

Referenced by START_TEST().

◆ get_module_version()

BOOL get_module_version ( _In_ HMODULE  mod,
_Out_ VS_FIXEDFILEINFO fileinfo 
)

Definition at line 62 of file pdb.c.

65{
66 BOOL res = FALSE;
67 HRSRC hResInfo;
68 char *errmsg;
69 DWORD dwSize, errcode = 0;
70 UINT uLen;
71 HGLOBAL hResData = 0;
72 LPVOID pRes = NULL;
73 HLOCAL pResCopy = 0;
74 VS_FIXEDFILEINFO *lpFfi;
75
76 if (fileinfo == NULL)
77 {
78 errmsg = "fileinfo is NULL.\n";
79 goto cleanup;
80 }
81
83 if (hResInfo == 0)
84 {
85 errmsg = "FindResource failed";
87 goto cleanup;
88 }
89
90 dwSize = SizeofResource(mod, hResInfo);
91 if (dwSize == 0)
92 {
93 errmsg = "SizeofResource failed";
95 goto cleanup;
96 }
97
98 hResData = LoadResource(mod, hResInfo);
99 if (hResData == 0)
100 {
101 errmsg = "LoadResource failed";
103 goto cleanup;
104 }
105
106 pRes = LockResource(hResData);
107 if (pRes == NULL)
108 {
109 errmsg = "LockResource failed";
111 goto cleanup;
112 }
113
114 pResCopy = LocalAlloc(LMEM_FIXED, dwSize);
115 if (pResCopy == NULL)
116 {
117 errmsg = "LocalAlloc failed";
119 goto cleanup;
120 }
121
122 CopyMemory(pResCopy, pRes, dwSize);
123
124 if (VerQueryValueW(pResCopy, L"\\", (LPVOID*)&lpFfi, &uLen))
125 {
126 *fileinfo = *lpFfi;
127 res = TRUE;
128 }
129
130cleanup:
131 /* cleanup */
132 if (hResData != 0)
133 FreeResource(hResData);
134 if (pResCopy != NULL)
135 LocalFree(pResCopy);
136 /* if it was good */
137 if (res == TRUE)
138 return TRUE;
139 /* failure path */
140 if (errcode == 0)
141 trace("get_module_version - %s.\n", errmsg);
142 else
143 trace("get_module_version - %s (lasterror %d).\n", errmsg, errcode);
144 return FALSE;
145}
std::map< E_MODULE, HMODULE > mod
Definition: LocaleTests.cpp:66
#define trace
Definition: atltest.h:70
EXPORT int errmsg(char *msg, va_alist)
Definition: comerr.c:192
#define FALSE
Definition: types.h:117
static void cleanup(void)
Definition: main.c:1335
BOOL WINAPI FreeResource(HGLOBAL handle)
Definition: res.c:559
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:568
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
BOOL WINAPI VerQueryValueW(LPCVOID pBlock, LPCWSTR lpSubBlock, LPVOID *lplpBuffer, PUINT puLen)
Definition: version.c:1171
#define L(x)
Definition: resources.c:13
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint res
Definition: glext.h:9613
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define CopyMemory
Definition: minwinbase.h:29
#define LMEM_FIXED
Definition: minwinbase.h:81
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
unsigned int UINT
Definition: ndis.h:50
#define MAKEINTRESOURCE(i)
Definition: ntverrsrc.c:25
#define VS_VERSION_INFO
Definition: ntverrsrc.c:27
#define RT_VERSION
Definition: ntverrsrc.c:26
int errcode
Definition: crtdefs.h:222
#define FindResource
Definition: winbase.h:3542

Referenced by init_dbghelp_version().

◆ init_dbghelp_version()

static void init_dbghelp_version ( )
static

Definition at line 148 of file pdb.c.

149{
152 HMODULE hDLL;
153 DWORD fileLen;
154 VS_FIXEDFILEINFO fileInfo;
155
157
158 /* get internal file version */
160 if (v == NULL)
161 return;
162
163 /* get module file version */
164 hDLL = GetModuleHandleW(L"dbghelp.dll");
165 if (hDLL == 0)
166 {
167 ok(FALSE, "Dbghelp.dll is not loaded!\n");
168 return;
169 }
170 if (!get_module_version(hDLL, &fileInfo))
171 memset(&fileInfo, 0, sizeof(fileInfo));
172 dbghelpFileVer = fileInfo;
173
174 /* get full file path */
175 fileLen = GetModuleFileNameW(hDLL, filenameW, MAX_PATH + 1);
176 if (fileLen == 0)
177 {
178 ok(FALSE, "GetModuleFileNameW for dbghelp.dll failed!\n");
179 return;
180 }
181
182 trace("Using %S\n", filenameW);
183 trace(" API-Version: %hu.%hu.%hu (%hu)\n",
184 v->MajorVersion, v->MinorVersion, v->Revision, v->Reserved);
185
186 trace(" Fileversion: %hu.%hu.%hu.%hu\n",
187 HIWORD(fileInfo.dwProductVersionMS),
188 LOWORD(fileInfo.dwProductVersionMS),
189 HIWORD(fileInfo.dwProductVersionLS),
190 LOWORD(fileInfo.dwProductVersionLS));
191}
LPAPI_VERSION WINAPI ImagehlpApiVersion(void)
Definition: dbghelp.c:837
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
const GLdouble * v
Definition: gl.h:2040
static const WCHAR filenameW[]
Definition: amstream.c:41
static VS_FIXEDFILEINFO dbghelpFileVer
Definition: pdb.c:147
BOOL get_module_version(_In_ HMODULE mod, _Out_ VS_FIXEDFILEINFO *fileinfo)
Definition: pdb.c:62
#define LOWORD(l)
Definition: pedump.c:82
#define memset(x, y, z)
Definition: compat.h:39
DWORD dwProductVersionLS
Definition: compat.h:905
DWORD dwProductVersionMS
Definition: compat.h:904
#define HIWORD(l)
Definition: typedefs.h:247
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ init_sym_imp()

static BOOL init_sym_imp ( BOOL  fInvadeProcess,
const char file,
int  line 
)
static

Definition at line 37 of file pdb.c.

38{
39 if (!SymInitialize(proc(), NULL, fInvadeProcess))
40 {
42 ok_(file, line)(0, "Failed to init: 0x%x\n", err);
43 return FALSE;
44 }
45 return TRUE;
46}
#define ok_(x1, x2)
Definition: atltest.h:61
BOOL WINAPI SymInitialize(HANDLE hProcess, PCSTR UserSearchPath, BOOL fInvadeProcess)
Definition: dbghelp.c:534
#define err(...)
Definition: fci.c:127
Definition: parser.c:49

◆ proc()

static HANDLE proc ( )
static

Definition at line 32 of file pdb.c.

33{
34 return GetCurrentProcess();
35}
#define GetCurrentProcess()
Definition: compat.h:759

Referenced by __wine_msi_call_dll_function(), _call_procedure(), _CrtGetMessageBox(), _TestVesion(), abort_dochost_tasks(), add_script_runner(), alloc_async_task(), build_format_strings(), call_enum_date_func(), CallWindowProcT(), CheckRunningDpc(), COMCTL32_SubclassProc(), create_named_scope(), DECLARE_INTERFACE_(), DefSubclassProc(), deinit_sym(), device_process_message(), download_to_cache(), dwarfargvalue(), dwarfpctoline(), enum_callback_wrapper(), enum_windows(), EnumCalendarInfoExEx(), EnumCalendarInfoExW(), EnumCalendarInfoW(), EnumDateFormatsA(), EnumDateFormatsExA(), EnumDateFormatsExEx(), EnumDateFormatsExW(), EnumDateFormatsW(), EnumLanguageGroupLocalesW(), EnumSystemCodePagesW(), EnumSystemGeoID(), EnumSystemLanguageGroupsW(), EnumSystemLocalesA(), EnumSystemLocalesEx(), EnumSystemLocalesW(), EnumTimeFormatsA(), EnumTimeFormatsEx(), EnumTimeFormatsW(), EnumUILanguagesW(), for_each_iface(), for_each_serializable(), FTPFtw(), FTPFtwL2(), get_ndr_types_params(), get_proc_address(), get_shiminfo(), get_window_long_ptr(), GetWindowSubclass(), gl_tab_completion(), ATL::CWndProcThunk::Init(), init_async(), init_sym_imp(), Internal_EnumCalendarInfo(), Internal_EnumDateFormats(), Internal_EnumLanguageGroupLocales(), Internal_EnumSystemCodePages(), Internal_EnumSystemLanguageGroups(), Internal_EnumTimeFormats(), Internal_EnumUILanguages(), IntSyscall(), key_call(), launch_test_process(), LoadProc(), MACRO_RegisterRoutine(), ndr64_async_client_call(), ndr64_client_call(), ndr_stubless_client_call(), ProcessPrefsFile(), push_dochost_task(), push_task(), readproc(), CardWindow::RegisterDropZone(), RemoveWindowSubclass(), RosSymGetAddressInformation(), rpc_broadcast(), rpc_broadcast_exp(), run_customdraw_scenario(), RunDLL(), Set(), set_dialog_proc(), CardRegion::SetAddCardProc(), CardButton::SetButtonProc(), CardRegion::SetClickProc(), CardRegion::SetClickReleaseProc(), CardRegion::SetDblClickProc(), CardRegion::SetDragRule(), CardRegion::SetDropRule(), CardRegion::SetRemoveCardProc(), CardWindow::SetResizeProc(), SetThreadIdealProcessor(), SetWindowSubclass(), START_TEST(), StubGetProcAddress(), subtest_export_forwarder_dep_chain(), Syscall(), test___getmainargs_parent(), test__get_narrow_winmain_command_line(), test_ActiveXObject(), test_exit(), test_FreeLibrary(), test_GetProcAddress(), test_GetProcessHandleFromHwnd(), test_interthread_messages(), test_invalid_stdin(), Test_layers(), test_LoadLibraryA(), test_LoadLibraryExA(), test_LoadLibraryExW(), test_LoadLibraryW(), test_LresultFromObject(), test_procedures(), test_quick_exit(), Test_repeatlayer(), test_stdout_handle(), test_thread_library_reference(), test_UiaAddEvent(), test_UiaNodeFromHandle(), test_updown_buddy(), test_wordbreak_proc(), universal(), wined3d_unregister_window(), wined3d_wndproc(), write_iface_fs(), write_param_fs(), and write_proc_func_header().

◆ START_TEST()

START_TEST ( pdb  )

Definition at line 564 of file pdb.c.

565{
566 char szDllName[MAX_PATH];
567 char szDllPath[MAX_PATH], szOldDir[MAX_PATH];
568 HMODULE hMod;
571
574 //Options |= SYMOPT_DEBUG;
576
577 if (!extract_msvc_dll(szDllName, szDllPath))
578 {
579 ok(0, "Failed extracting files\n");
580 return;
581 }
582
584
585 if (init_sym(FALSE))
586 {
588 BaseAddress = SymLoadModule64(proc(), NULL, szDllName, NULL, 0x600000, 0);
590
591 ok_ulonglong(BaseAddress, 0x600000);
593
594 if (BaseAddress == 0x600000)
595 {
596 trace("Module loaded by SymLoadModule64\n");
600 }
601
602 deinit_sym();
603 }
604
605 /* This needs to load the module by itself */
608
609 hMod = LoadLibraryA(szDllName);
610 if (hMod)
611 {
613 /* Make sure we can find the pdb */
614 GetCurrentDirectoryA(_countof(szOldDir), szOldDir);
615 SetCurrentDirectoryA(szDllPath);
616 /* Invade process */
617 if (init_sym(TRUE))
618 {
619 trace("Module loaded by LoadLibraryA\n");
623
624 deinit_sym();
625 }
626 /* Restore working dir */
627 SetCurrentDirectoryA(szOldDir);
628
629 FreeLibrary(hMod);
630 }
631
633}
DWORD dwErr
Definition: service.c:36
#define ERROR_SUCCESS
Definition: deptool.c:10
static const WCHAR szDllName[]
Definition: sip.c:61
#define SetLastError(x)
Definition: compat.h:752
#define FreeLibrary(x)
Definition: compat.h:748
#define SYMOPT_UNDNAME
Definition: compat.h:988
DWORD WINAPI SymSetOptions(DWORD opts)
Definition: dbghelp.c:585
DWORD WINAPI SymGetOptions(void)
Definition: dbghelp.c:600
DWORD64 WINAPI SymLoadModule64(HANDLE hProcess, HANDLE hFile, PCSTR ImageName, PCSTR ModuleName, DWORD64 BaseOfDll, DWORD SizeOfDll)
Definition: module.c:878
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2065
BOOL WINAPI SetCurrentDirectoryA(IN LPCSTR lpPathName)
Definition: path.c:2125
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
int extract_msvc_dll(char szFile[MAX_PATH], char szPath[MAX_PATH])
Definition: data.c:72
static void test_SymEnumSymbols(HANDLE hProc, DWORD64 BaseAddress)
Definition: pdb.c:460
#define init_sym(fInvadeProcess)
Definition: pdb.c:53
static void deinit_sym()
Definition: pdb.c:48
void cleanup_msvc_dll()
Definition: data.c:90
static void test_SymFromAddr(HANDLE hProc, DWORD64 BaseAddress)
Definition: pdb.c:305
static void init_dbghelp_version()
Definition: pdb.c:148
static void test_SymRegCallback(HANDLE hProc, const char *szModuleName, BOOL testANSI)
Definition: pdb.c:520
static void test_SymFromName(HANDLE hProc, DWORD64 BaseAddress)
Definition: pdb.c:237
#define _countof(array)
Definition: sndvol32.h:70
uint32_t DWORD_PTR
Definition: typedefs.h:65
uint64_t DWORD64
Definition: typedefs.h:67
_In_ PWDFDEVICE_INIT _In_ PWDF_REMOVE_LOCK_OPTIONS Options
Definition: wdfdevice.h:3540

◆ supports_pdb()

static BOOL supports_pdb ( HANDLE  hProc,
DWORD64  BaseAddress 
)
static

Definition at line 224 of file pdb.c.

225{
227 BOOL Ret;
228
229 memset(&ModuleInfo, 0, sizeof(ModuleInfo));
230 ModuleInfo.SizeOfStruct = sizeof(ModuleInfo);
232
233 return Ret && ModuleInfo.SymType == SymPdb;
234}
_In_ ULONG _Out_writes_bytes_opt_ InformationLength PAUX_MODULE_EXTENDED_INFO ModuleInfo
Definition: aux_klib.h:65
@ SymPdb
Definition: compat.h:1059
BOOL WINAPI SymGetModuleInfo64(HANDLE hProcess, DWORD64 dwAddr, PIMAGEHLP_MODULE64 ModuleInfo)
Definition: module.c:1219

Referenced by test_SymEnumSymbols(), test_SymFromAddr(), and test_SymFromName().

◆ SymRegisterCallback64Proc()

static BOOL CALLBACK SymRegisterCallback64Proc ( HANDLE  hProcess,
ULONG  ActionCode,
ULONG64  CallbackData,
ULONG64  UserContext 
)
static

Definition at line 496 of file pdb.c.

501{
503 ctx = (symregcallback_context*)(ULONG_PTR)UserContext;
504
505 if (ctx->idx > sizeof(symregcallback_test_data))
506 {
507 ok(FALSE, "SymRegisterCallback64Proc: Too many calls.\n");
508 }
509 else
510 {
511 ok(ActionCode == symregcallback_test_data[ctx->idx].ActionCode,
512 "ActionCode (idx %u) expected %u, got %u\n",
513 ctx->idx, symregcallback_test_data[ctx->idx].ActionCode, ActionCode);
514 }
515 ctx->idx++;
516
517 return FALSE;
518}
static struct _symregcallback_test_data symregcallback_test_data[]
uint32_t ULONG_PTR
Definition: typedefs.h:65

Referenced by test_SymRegCallback().

◆ SymRegisterCallbackW64_Stub()

static BOOL WINAPI SymRegisterCallbackW64_Stub ( HANDLE  hProcess,
PSYMBOL_REGISTERED_CALLBACK64  CallbackFunction,
ULONG64  UserContext 
)
static

Definition at line 197 of file pdb.c.

198{
200 return FALSE;
201}
static int g_SymRegisterCallbackW64NotFound
Definition: pdb.c:194

Referenced by DliFailHook().

◆ test_SymEnumSymbols()

static void test_SymEnumSymbols ( HANDLE  hProc,
DWORD64  BaseAddress 
)
static

Definition at line 460 of file pdb.c.

461{
462 BOOL Ret;
464
465 ctx.Index = 0;
466 ctx.BaseAddress = BaseAddress;
467
468 if (!supports_pdb(hProc, ctx.BaseAddress))
469 {
470 skip("dbghelp.dll too old or cannot enumerate symbols!\n");
471 }
472 else
473 {
474 Ret = SymEnumSymbols(hProc, ctx.BaseAddress, NULL, EnumSymProc, &ctx);
475 ok_int(Ret, TRUE);
476 ok_int(ctx.Index, ARRAYSIZE(test_data));
477 }
478}
#define skip(...)
Definition: atltest.h:64
#define ok_int(expression, result)
Definition: atltest.h:134
static BOOL CALLBACK EnumSymProc(PSYMBOL_INFO pSymInfo, ULONG SymbolSize, PVOID UserContext)
Definition: pdb.c:439
static BOOL supports_pdb(HANDLE hProc, DWORD64 BaseAddress)
Definition: pdb.c:224
BOOL WINAPI SymEnumSymbols(HANDLE hProcess, ULONG64 BaseOfDll, PCSTR Mask, PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, PVOID UserContext)
Definition: symbol.c:1149

Referenced by START_TEST().

◆ test_SymFromAddr()

static void test_SymFromAddr ( HANDLE  hProc,
DWORD64  BaseAddress 
)
static

Definition at line 305 of file pdb.c.

306{
307 BOOL Ret;
308 char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)];
310
311 DWORD64 Displacement;
312 DWORD dwErr;
313
314 if (!supports_pdb(hProc, BaseAddress))
315 {
316 skip("dbghelp.dll too old or cannot enumerate symbols!\n");
317 }
318 else
319 {
320
321 /* No address found before load address of module */
322 Displacement = 0;
324 Ret = SymFromAddr(hProc, BaseAddress -1, &Displacement, pSymbol);
326 ok_int(Ret, FALSE);
328
329 /* Right at the start of the module is recognized as the first symbol found */
330 Displacement = 0;
332 Ret = SymFromAddr(hProc, BaseAddress, &Displacement, pSymbol);
333 ok_int(Ret, TRUE);
334 ok_ulonglong(Displacement, 0xffffffffffffffff);
336 ok_hex(pSymbol->Flags, 0);
337 ok_ulonglong(pSymbol->Address, BaseAddress + 0x1010);
338 ok_hex(pSymbol->Tag, SymTagFunction);
339 ok_str(pSymbol->Name, "DllMain");
340
341 /* The actual first instruction of the function */
342 Displacement = 0;
344 Ret = SymFromAddr(hProc, BaseAddress + 0x1010, &Displacement, pSymbol);
345 ok_int(Ret, TRUE);
346 ok_ulonglong(Displacement, 0);
348 ok_hex(pSymbol->Flags, 0);
349 ok_ulonglong(pSymbol->Address, BaseAddress + 0x1010);
350 ok_hex(pSymbol->Tag, SymTagFunction);
351 ok_str(pSymbol->Name, "DllMain");
352
353 /* The last instruction in the function */
354 Displacement = 0;
356 Ret = SymFromAddr(hProc, BaseAddress + 0x102D, &Displacement, pSymbol);
357 ok_int(Ret, TRUE);
358 ok_ulonglong(Displacement, 0x1d);
360 ok_hex(pSymbol->Flags, 0);
361 ok_ulonglong(pSymbol->Address, BaseAddress + 0x1010);
362 ok_hex(pSymbol->Tag, SymTagFunction);
363 ok_str(pSymbol->Name, "DllMain");
364
365 /* The padding below the function */
366 Displacement = 0;
368 Ret = SymFromAddr(hProc, BaseAddress + 0x102E, &Displacement, pSymbol);
369 ok_int(Ret, TRUE);
370 ok_ulonglong(Displacement, 0x1e);
372 ok_hex(pSymbol->Flags, 0);
373 ok_ulonglong(pSymbol->Address, BaseAddress + 0x1010);
374 ok_hex(pSymbol->Tag, SymTagFunction);
375 ok_str(pSymbol->Name, "DllMain");
376
377 /* One byte before the next function */
378 Displacement = 0;
380 Ret = SymFromAddr(hProc, BaseAddress + 0x103f, &Displacement, pSymbol);
381 ok_int(Ret, TRUE);
382 ok_ulonglong(Displacement, 0x2f);
384 ok_hex(pSymbol->Flags, 0);
385 ok_ulonglong(pSymbol->Address, BaseAddress + 0x1010);
386 ok_hex(pSymbol->Tag, SymTagFunction);
387 ok_str(pSymbol->Name, "DllMain");
388
389 /* First byte of the next function */
390 Displacement = 0;
392 Ret = SymFromAddr(hProc, BaseAddress + 0x1040, &Displacement, pSymbol);
393 ok_int(Ret, TRUE);
394 ok_ulonglong(Displacement, 0);
396 ok_hex(pSymbol->Flags, 0);
397 ok_ulonglong(pSymbol->Address, BaseAddress + 0x1040);
398 ok_hex(pSymbol->Tag, SymTagFunction);
399 ok_str(pSymbol->Name, "FfsChkdsk");
400
401 /* .idata */
402 Displacement = 0;
404 Ret = SymFromAddr(hProc, BaseAddress + 0x2000, &Displacement, pSymbol);
405 ok_int(Ret, TRUE);
406 ok_ulonglong(Displacement, 0);
408 ok_hex(pSymbol->Flags, 0);
409 ok_ulonglong(pSymbol->Address, BaseAddress + 0x2000);
410 ok_hex(pSymbol->Tag, SymTagPublicSymbol);
411 ok_str(pSymbol->Name, "__imp__DbgPrint");
412 }
413}
BOOL WINAPI SymFromAddr(HANDLE hProcess, DWORD64 Address, DWORD64 *Displacement, PSYMBOL_INFO Symbol)
Definition: symbol.c:1265
#define ERROR_MOD_NOT_FOUND
Definition: compat.h:104
struct _SYMBOL_INFO SYMBOL_INFO
@ SymTagFunction
Definition: compat.h:1586
@ SymTagPublicSymbol
Definition: compat.h:1591
GLuint buffer
Definition: glext.h:5915
#define INIT_PSYM(buff)
Definition: pdb.c:55
ULONG Flags
Definition: compat.h:1044
char TCHAR
Definition: xmlstorage.h:189

Referenced by START_TEST().

◆ test_SymFromName()

static void test_SymFromName ( HANDLE  hProc,
DWORD64  BaseAddress 
)
static

Definition at line 237 of file pdb.c.

238{
239 BOOL Ret;
240 char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)];
242
243 if (!supports_pdb(hProc, BaseAddress))
244 {
245 skip("dbghelp.dll too old or cannot enumerate symbols!\n");
246 }
247 else
248 {
250 Ret = SymFromName(hProc, "DllMain", pSymbol);
251 ok_int(Ret, TRUE);
253 ok_hex(pSymbol->Flags, 0);
254 ok_ulonglong(pSymbol->Address, BaseAddress + 0x1010);
255 ok_hex(pSymbol->Tag, SymTagFunction);
256 ok_str(pSymbol->Name, "DllMain");
257
259 Ret = SymFromName(hProc, "_DllMain@12", pSymbol);
260 ok_int(Ret, TRUE);
262 ok_hex(pSymbol->Flags, 0x400000); // ??
263 ok_ulonglong(pSymbol->Address, BaseAddress + 0x1010);
264 ok_hex(pSymbol->Tag, SymTagPublicSymbol);
265 ok_str(pSymbol->Name, "_DllMain@12");
266
268 Ret = SymFromName(hProc, "FfsChkdsk", pSymbol);
269 ok_int(Ret, TRUE);
271 ok_hex(pSymbol->Flags, 0);
272 ok_ulonglong(pSymbol->Address, BaseAddress + 0x1040);
273 ok_hex(pSymbol->Tag, SymTagFunction);
274 ok_str(pSymbol->Name, "FfsChkdsk");
275
277 Ret = SymFromName(hProc, "_FfsChkdsk@24", pSymbol);
278 ok_int(Ret, TRUE);
280 ok_hex(pSymbol->Flags, 0x400000); // ??
281 ok_ulonglong(pSymbol->Address, BaseAddress + 0x1040);
282 ok_hex(pSymbol->Tag, SymTagPublicSymbol);
283 ok_str(pSymbol->Name, "_FfsChkdsk@24");
284
286 Ret = SymFromName(hProc, "FfsFormat", pSymbol);
287 ok_int(Ret, TRUE);
289 ok_hex(pSymbol->Flags, 0);
290 ok_ulonglong(pSymbol->Address, BaseAddress + 0x1070);
291 ok_hex(pSymbol->Tag, SymTagFunction);
292 ok_str(pSymbol->Name, "FfsFormat");
293
295 Ret = SymFromName(hProc, "_FfsFormat@24", pSymbol);
296 ok_int(Ret, TRUE);
298 ok_hex(pSymbol->Flags, 0x400000); // ??
299 ok_ulonglong(pSymbol->Address, BaseAddress + 0x1070);
300 ok_hex(pSymbol->Tag, SymTagPublicSymbol);
301 ok_str(pSymbol->Name, "_FfsFormat@24");
302 }
303}
BOOL WINAPI SymFromName(HANDLE hProcess, PCSTR Name, PSYMBOL_INFO Symbol)
Definition: symbol.c:1394

Referenced by START_TEST().

◆ test_SymRegCallback()

static void test_SymRegCallback ( HANDLE  hProc,
const char szModuleName,
BOOL  testANSI 
)
static

Definition at line 520 of file pdb.c.

521{
522 BOOL Ret;
523 DWORD dwErr;
526
527 ctx.idx = 0;
528 ctx.isANSI = testANSI;
529
530 if (!init_sym(FALSE))
531 return;
532
533 if (testANSI)
534 {
536 }
537 else
538 {
541 {
542 skip("SymRegisterCallbackW64 not found in dbghelp.dll\n");
543 return;
544 }
545 }
546
547 ok_int(Ret, TRUE);
548 if (!Ret)
549 return;
550
552 BaseAddress = SymLoadModule64(hProc, NULL, szModuleName, NULL, 0x600000, 0);
554
555 ok_ulonglong(BaseAddress, 0x600000);
557
558 /* this is what we want to test ... we expect 5 calls */
559 ok_int(ctx.idx, 5);
560
561 deinit_sym();
562}
BOOL WINAPI SymRegisterCallbackW64(HANDLE hProcess, PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction, ULONG64 UserContext)
Definition: dbghelp.c:822
BOOL WINAPI SymRegisterCallback64(HANDLE hProcess, PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction, ULONG64 UserContext)
Definition: dbghelp.c:810
LPCWSTR LPCWSTR szModuleName
Definition: env.c:37
static BOOL CALLBACK SymRegisterCallback64Proc(HANDLE hProcess, ULONG ActionCode, ULONG64 CallbackData, ULONG64 UserContext)
Definition: pdb.c:496

Referenced by START_TEST().

Variable Documentation

◆ __pfnDliFailureHook2

PfnDliHook __pfnDliFailureHook2 = DliFailHook

Definition at line 221 of file pdb.c.

◆ dbghelpFileVer

VS_FIXEDFILEINFO dbghelpFileVer
static

Definition at line 147 of file pdb.c.

Referenced by init_dbghelp_version().

◆ g_SymRegisterCallbackW64NotFound

int g_SymRegisterCallbackW64NotFound = 0
static

Definition at line 194 of file pdb.c.

Referenced by SymRegisterCallbackW64_Stub(), and test_SymRegCallback().

◆ symregcallback_test_data

struct _symregcallback_test_data symregcallback_test_data[]
static
Initial value:
= {
}
#define CBA_DEFERRED_SYMBOL_LOAD_COMPLETE
Definition: compat.h:977
#define CBA_DEFERRED_SYMBOL_LOAD_CANCEL
Definition: compat.h:982
#define CBA_READ_MEMORY
Definition: compat.h:981
#define CBA_DEFERRED_SYMBOL_LOAD_PARTIAL
Definition: compat.h:985
#define CBA_DEFERRED_SYMBOL_LOAD_START
Definition: compat.h:976

Referenced by SymRegisterCallback64Proc().

◆ test_data

Initial value:
= {
{ 0x1070, 36, SymTagFunction, "FfsFormat" },
{ 0x1010, 32, SymTagFunction, "DllMain" },
{ 0x1040, 36, SymTagFunction, "FfsChkdsk" },
{ 0x2100, 0, SymTagPublicSymbol, "__IMPORT_DESCRIPTOR_ntdll" },
{ 0x109a, 0, SymTagPublicSymbol, "_DbgPrint" },
{ 0x2004, 0, SymTagPublicSymbol, "\x7fntdll_NULL_THUNK_DATA" },
{ 0x2000, 0, SymTagPublicSymbol, "__imp__DbgPrint" },
{ 0x2114, 0, SymTagPublicSymbol, "__NULL_IMPORT_DESCRIPTOR" },
}