ReactOS  0.4.12-dev-918-g6c6e7b8
rsym.c File Reference
#include <ntstatus.h>
#include <windows.h>
#include <dbghelp.h>
#include <cvconst.h>
#include <stdio.h>
#include "wine/test.h"
Include dependency graph for rsym.c:

Go to the source code of this file.

Classes

struct  _test_context
 
struct  _test_data
 

Macros

#define WIN32_NO_STATUS
 
#define ok_ulonglong(expression, result)
 
#define ok_ulonglong_(file, line, expression, result)
 
#define ok_hex_(file, line, expression, result)
 
#define ok_str_(file, line, x, y)   ok_(file, line)(strcmp(x, y) == 0, "Wrong string. Expected '%s', got '%s'\n", y, x)
 
#define init_sym()   init_sym_imp(__FILE__, __LINE__)
 
#define INIT_PSYM(buff)
 

Typedefs

typedef struct _test_context test_context
 

Functions

void dump_rsym (const char *filename)
 
int extract_gcc_exe (char szFile[MAX_PATH])
 
void cleanup_gcc_exe ()
 
static HANDLE proc ()
 
static BOOL init_sym_imp (const char *file, int line)
 
static void deinit_sym ()
 
static BOOL supports_rsym (HANDLE hProc, DWORD64 BaseAddress)
 
static void test_SymFromName (HANDLE hProc, const char *szModuleName)
 
static void test_SymFromAddr (HANDLE hProc, const char *szModuleName)
 
BOOL CALLBACK EnumSymProc (PSYMBOL_INFO pSymInfo, ULONG SymbolSize, PVOID UserContext)
 
static void test_SymEnumSymbols (HANDLE hProc, const char *szModuleName)
 
 START_TEST (rsym)
 

Variables

static struct _test_data 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)
#define MAX_SYM_NAME
Definition: rsym.c:34
struct _SYMBOL_INFO * PSYMBOL_INFO
static unsigned char buff[32768]
Definition: fatten.c:17

Definition at line 88 of file rsym.c.

◆ init_sym

#define init_sym ( )    init_sym_imp(__FILE__, __LINE__)

Definition at line 86 of file rsym.c.

◆ ok_hex_

#define ok_hex_ (   file,
  line,
  expression,
  result 
)
Value:
do { \
int _value = (expression); \
ok_(file, line)(_value == (result), "Wrong value for '%s', expected: " #result " (0x%x), got: 0x%x\n", \
#expression, (int)(result), _value); \
} while (0)
Definition: parser.c:48
GLuint64EXT * result
Definition: glext.h:11304
Definition: fci.c:126

Definition at line 35 of file rsym.c.

◆ ok_str_

#define ok_str_ (   file,
  line,
  x,
  y 
)    ok_(file, line)(strcmp(x, y) == 0, "Wrong string. Expected '%s', got '%s'\n", y, x)

Definition at line 42 of file rsym.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:41
GLuint64EXT * result
Definition: glext.h:11304

Definition at line 19 of file rsym.c.

◆ ok_ulonglong_

#define ok_ulonglong_ (   file,
  line,
  expression,
  result 
)
Value:
do { \
ULONG64 _value = (expression); \
ULONG64 _result = (result); \
ok_(file, line)(_value == (result), "Wrong value for '%s', expected: " #result " (%s), got: %s\n", \
#expression, wine_dbgstr_longlong(_result), wine_dbgstr_longlong(_value)); \
} while (0)
Definition: parser.c:48
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41
GLuint64EXT * result
Definition: glext.h:11304
Definition: fci.c:126

Definition at line 27 of file rsym.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 11 of file rsym.c.

Typedef Documentation

◆ test_context

Function Documentation

◆ cleanup_gcc_exe()

void cleanup_gcc_exe ( )

Definition at line 119 of file data.c.

120 {
121  char szFile[MAX_PATH];
122  BOOL ret;
123  const char* dir = tmpdir();
124 
125  sprintf(szFile, "%s\\uffs.dll", dir);
126  ret = DeleteFileA(szFile);
127  ok(ret, "DeleteFileA failed(%d)\n", GetLastError());
129  ok(ret, "RemoveDirectoryA failed(%d)\n", GetLastError());
130 }
static const char * tmpdir()
Definition: data.c:18
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define sprintf(buf, format,...)
Definition: sprintf.c:55
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
unsigned int dir
Definition: maze.c:112
#define ok(value,...)
Definition: CComObject.cpp:34
#define MAX_PATH
Definition: compat.h:26
int ret
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
Definition: dir.c:714

Referenced by START_TEST().

◆ deinit_sym()

static void deinit_sym ( )
static

Definition at line 67 of file rsym.c.

68 {
69  SymCleanup(proc());
70 }
BOOL WINAPI SymCleanup(HANDLE hProcess)
Definition: dbghelp.c:416
static HANDLE proc()
Definition: rsym.c:51

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

◆ dump_rsym()

void dump_rsym ( const char filename)

◆ EnumSymProc()

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

Definition at line 289 of file rsym.c.

290 {
291  test_context* ctx = UserContext;
292 
293  if (ctx->Index < ARRAYSIZE(test_data))
294  {
295  ok_ulonglong_(__FILE__, test_data[ctx->Index].Line, pSymInfo->ModBase, ctx->BaseAddress);
296  if (test_data[ctx->Index].AddressOffset > 0x100000)
297  ok_ulonglong_(__FILE__, test_data[ctx->Index].Line, pSymInfo->Address, test_data[ctx->Index].AddressOffset);
298  else
299  ok_ulonglong_(__FILE__, test_data[ctx->Index].Line, pSymInfo->Address, ctx->BaseAddress + test_data[ctx->Index].AddressOffset);
300  ok_hex_(__FILE__, test_data[ctx->Index].Line, pSymInfo->Tag, test_data[ctx->Index].Tag);
301  ok_str_(__FILE__, test_data[ctx->Index].Line, pSymInfo->Name, test_data[ctx->Index].Name);
302 
303  ctx->Index++;
304  }
305  else
306  {
307  ok(0, "Out of bounds (%lu), max is: %i!\n", ctx->Index, ARRAYSIZE(test_data));
308  }
309 
310  return TRUE;
311 }
ULONG Tag
Definition: compat.h:691
CHAR Name[1]
Definition: compat.h:694
#define TRUE
Definition: types.h:120
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
ULONG64 Address
Definition: compat.h:688
#define ok_ulonglong_(file, line, expression, result)
Definition: rsym.c:27
ULONG64 ModBase
Definition: compat.h:685
#define ok(value,...)
Definition: CComObject.cpp:34
#define ok_hex_(file, line, expression, result)
Definition: rsym.c:35
DWORD64 BaseAddress
Definition: pdb.c:444
#define ok_str_(file, line, x, y)
Definition: rsym.c:42
SIZE_T Index
Definition: pdb.c:445

Referenced by test_SymEnumSymbols().

◆ extract_gcc_exe()

int extract_gcc_exe ( char  szFile[MAX_PATH])

Definition at line 106 of file data.c.

107 {
108  const char* dir = tmpdir();
110  ok(ret, "CreateDirectoryA failed(%d)\n", GetLastError());
111 
112  sprintf(szFile, "%s\\uffs.dll", dir);
113  if (!extract_one(szFile, "gcc_uffs.dll"))
114  return 0;
115 
116  return 1;
117 }
static int extract_one(const char *filename, const char *resid)
Definition: data.c:28
static const char * tmpdir()
Definition: data.c:18
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define sprintf(buf, format,...)
Definition: sprintf.c:55
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:37
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
#define ok(value,...)
Definition: CComObject.cpp:34
int ret

Referenced by START_TEST().

◆ init_sym_imp()

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

Definition at line 56 of file rsym.c.

57 {
58  if (!SymInitialize(proc(), NULL, FALSE))
59  {
61  ok_(file, line)(0, "Failed to init: 0x%x\n", err);
62  return FALSE;
63  }
64  return TRUE;
65 }
#define TRUE
Definition: types.h:120
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI SymInitialize(HANDLE hProcess, PCSTR UserSearchPath, BOOL fInvadeProcess)
Definition: dbghelp.c:393
Definition: parser.c:48
unsigned long DWORD
Definition: ntddk_ex.h:95
#define err(...)
static HANDLE proc()
Definition: rsym.c:51
#define ok_(x1, x2)
Definition: CString.cpp:56
Definition: fci.c:126

◆ proc()

static HANDLE proc ( )
static

Definition at line 51 of file rsym.c.

52 {
53  return GetCurrentProcess();
54 }
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1168

Referenced by deinit_sym(), init_sym_imp(), and START_TEST().

◆ START_TEST()

START_TEST ( rsym  )

Definition at line 348 of file rsym.c.

349 {
350  char szDllName[MAX_PATH];
351  //dump_rsym("R:\\src\\trunk\\reactos\\modules\\rostests\\apitests\\dbghelp\\testdata\\gcc_uffs.dll");
352 
354  Options &= ~(SYMOPT_UNDNAME);
355  //Options |= SYMOPT_DEBUG;
357 
359  {
360  ok(0, "Failed extracting files\n");
361  return;
362  }
363 
367 
368  cleanup_gcc_exe();
369 }
static const WCHAR szDllName[]
Definition: sip.c:61
DWORD WINAPI SymSetOptions(DWORD opts)
Definition: dbghelp.c:443
enum OPTION_FLAGS Options
Definition: stats.c:44
void cleanup_gcc_exe()
Definition: data.c:119
static void test_SymFromName(HANDLE hProc, const char *szModuleName)
Definition: rsym.c:95
#define ok(value,...)
Definition: CComObject.cpp:34
static void test_SymEnumSymbols(HANDLE hProc, const char *szModuleName)
Definition: rsym.c:313
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SYMOPT_UNDNAME
Definition: compat.h:637
#define MAX_PATH
Definition: rsym.c:33
DWORD WINAPI SymGetOptions(void)
Definition: dbghelp.c:458
static HANDLE proc()
Definition: rsym.c:51
int extract_gcc_exe(char szFile[MAX_PATH])
Definition: data.c:106
static void test_SymFromAddr(HANDLE hProc, const char *szModuleName)
Definition: rsym.c:151

◆ supports_rsym()

static BOOL supports_rsym ( HANDLE  hProc,
DWORD64  BaseAddress 
)
static

Definition at line 72 of file rsym.c.

73 {
74  IMAGEHLP_MODULE64 ModuleInfo;
75  BOOL Ret;
76 
77  memset(&ModuleInfo, 0, sizeof(ModuleInfo));
78  ModuleInfo.SizeOfStruct = sizeof(ModuleInfo);
79  Ret = SymGetModuleInfo64(hProc, BaseAddress, &ModuleInfo);
80 
81  return Ret &&
82  ModuleInfo.SymType == SymDia &&
83  ModuleInfo.CVSig == ('R' | ('S' << 8) | ('Y' << 16) | ('M' << 24));
84 }
SYM_TYPE SymType
Definition: compat.h:878
Definition: compat.h:705
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD SizeOfStruct
Definition: compat.h:872
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
#define memset(x, y, z)
Definition: compat.h:39
BOOL WINAPI SymGetModuleInfo64(HANDLE hProcess, DWORD64 dwAddr, PIMAGEHLP_MODULE64 ModuleInfo)
Definition: module.c:1013

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

◆ test_SymEnumSymbols()

static void test_SymEnumSymbols ( HANDLE  hProc,
const char szModuleName 
)
static

Definition at line 313 of file rsym.c.

314 {
315  BOOL Ret;
316  DWORD dwErr;
317 
318  test_context ctx;
319 
320  if (!init_sym())
321  return;
322 
323  ctx.Index = 0;
325  ctx.BaseAddress = SymLoadModule64(hProc, NULL, szModuleName, NULL, 0x600000, 0);
326  dwErr = GetLastError();
327 
328  if (supports_rsym(hProc, ctx.BaseAddress))
329  {
330  ok_ulonglong(ctx.BaseAddress, 0x600000);
332 
333  Ret = SymEnumSymbols(hProc, ctx.BaseAddress, NULL, EnumSymProc, &ctx);
334  ok_int(Ret, TRUE);
336  }
337  else
338  {
339  skip("dbghelp.dll cannot parse rsym\n");
340  }
341 
342  deinit_sym();
343 }
#define TRUE
Definition: types.h:120
#define ok_ulonglong(expression, result)
Definition: rsym.c:19
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ok_int(x, y)
Definition: sprintf.c:21
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL CALLBACK EnumSymProc(PSYMBOL_INFO pSymInfo, ULONG SymbolSize, PVOID UserContext)
Definition: rsym.c:289
static void deinit_sym()
Definition: rsym.c:67
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL supports_rsym(HANDLE hProc, DWORD64 BaseAddress)
Definition: rsym.c:72
smooth NULL
Definition: ftsmooth.c:416
DWORD dwErr
Definition: service.c:36
DWORD64 WINAPI SymLoadModule64(HANDLE hProcess, HANDLE hFile, PCSTR ImageName, PCSTR ModuleName, DWORD64 BaseOfDll, DWORD SizeOfDll)
Definition: module.c:673
#define ok_hex(expression, result)
Definition: test.h:759
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
#define init_sym()
Definition: rsym.c:86
BOOL WINAPI SymEnumSymbols(HANDLE hProcess, ULONG64 BaseOfDll, PCSTR Mask, PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, PVOID UserContext)
Definition: symbol.c:1126
#define skip(...)
Definition: CString.cpp:57
DWORD64 BaseAddress
Definition: pdb.c:444
LPCWSTR LPCWSTR szModuleName
Definition: env.c:35
SIZE_T Index
Definition: pdb.c:445

Referenced by START_TEST().

◆ test_SymFromAddr()

static void test_SymFromAddr ( HANDLE  hProc,
const char szModuleName 
)
static

Definition at line 151 of file rsym.c.

152 {
153  BOOL Ret;
154  char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)];
155  PSYMBOL_INFO pSymbol = (PSYMBOL_INFO)buffer;
156 
157  DWORD64 BaseAddress, Displacement;
158  DWORD dwErr;
159 
160  if (!init_sym())
161  return;
162 
164  BaseAddress = SymLoadModule64(hProc, NULL, szModuleName, NULL, 0x600000, 0);
165  dwErr = GetLastError();
166 
167  if (supports_rsym(hProc, BaseAddress))
168  {
169  ok_ulonglong(BaseAddress, 0x600000);
171 
172  /* No address found before load address of module */
173  Displacement = 0;
174  INIT_PSYM(buffer);
175  Ret = SymFromAddr(hProc, BaseAddress -1, &Displacement, pSymbol);
176  dwErr = GetLastError();
177  ok_int(Ret, FALSE);
179 
180  /* Right at the start of the module is recognized as the first symbol found */
181  Displacement = 0;
182  INIT_PSYM(buffer);
183  Ret = SymFromAddr(hProc, BaseAddress, &Displacement, pSymbol);
184  /* Our dbghelp.dll does not recognize this yet */
185  todo_if(!Ret)
186  {
187  ok_int(Ret, TRUE);
188  ok_ulonglong(Displacement, 0xffffffffffffffff);
189  ok_ulonglong(pSymbol->ModBase, BaseAddress);
190  ok_hex(pSymbol->Flags, SYMFLAG_FUNCTION);
191  ok_ulonglong(pSymbol->Address, BaseAddress + 0x1000);
192  ok_hex(pSymbol->Tag, SymTagFunction);
193  ok_str(pSymbol->Name, "DllMain");
194  }
195 
196  /* The actual first instruction of the function */
197  Displacement = 0;
198  INIT_PSYM(buffer);
199  Ret = SymFromAddr(hProc, BaseAddress + 0x1000, &Displacement, pSymbol);
200  ok_int(Ret, TRUE);
201  ok_ulonglong(Displacement, 0);
202  ok_ulonglong(pSymbol->ModBase, BaseAddress);
203  ok_hex(pSymbol->Flags, SYMFLAG_FUNCTION);
204  ok_ulonglong(pSymbol->Address, BaseAddress + 0x1000);
205  ok_hex(pSymbol->Tag, SymTagFunction);
206  ok_str(pSymbol->Name, "DllMain");
207 
208  /* The last instruction in the function */
209  Displacement = 0;
210  INIT_PSYM(buffer);
211  Ret = SymFromAddr(hProc, BaseAddress + 0x1009, &Displacement, pSymbol);
212  ok_int(Ret, TRUE);
213  ok_ulonglong(Displacement, 0x9);
214  ok_ulonglong(pSymbol->ModBase, BaseAddress);
215  ok_hex(pSymbol->Flags, SYMFLAG_FUNCTION);
216  ok_ulonglong(pSymbol->Address, BaseAddress + 0x1000);
217  ok_hex(pSymbol->Tag, SymTagFunction);
218  ok_str(pSymbol->Name, "DllMain");
219 
220  /* First byte of the next function */
221  Displacement = 0;
222  INIT_PSYM(buffer);
223  Ret = SymFromAddr(hProc, BaseAddress + 0x103F, &Displacement, pSymbol);
224  ok_int(Ret, TRUE);
225  ok_ulonglong(Displacement, 0);
226  ok_ulonglong(pSymbol->ModBase, BaseAddress);
227  ok_hex(pSymbol->Flags, SYMFLAG_FUNCTION);
228  ok_ulonglong(pSymbol->Address, BaseAddress + 0x103F);
229  ok_hex(pSymbol->Tag, SymTagFunction);
230  ok_str(pSymbol->Name, "FfsChkdsk");
231 
232  /* .idata */
233  Displacement = 0;
234  INIT_PSYM(buffer);
235  Ret = SymFromAddr(hProc, BaseAddress + 0x4000, &Displacement, pSymbol);
236  ok_int(Ret, TRUE);
237  ok_ulonglong(Displacement, 0);
238  ok_ulonglong(pSymbol->ModBase, BaseAddress);
239  ok_hex(pSymbol->Flags, SYMFLAG_EXPORT);
240  ok_ulonglong(pSymbol->Address, BaseAddress + 0x4000);
241  ok_hex(pSymbol->Tag, SymTagPublicSymbol);
242  ok_str(pSymbol->Name, "_head_dll_ntdll_libntdll_a");
243  }
244  else
245  {
246  skip("dbghelp.dll cannot parse rsym\n");
247  }
248 
249  deinit_sym();
250 }
#define ok_str(x, y)
Definition: sprintf.c:18
ULONG Tag
Definition: compat.h:691
CHAR Name[1]
Definition: compat.h:694
#define TRUE
Definition: types.h:120
#define ok_ulonglong(expression, result)
Definition: rsym.c:19
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ok_int(x, y)
Definition: sprintf.c:21
#define MAX_SYM_NAME
Definition: rsym.c:34
ULONG Flags
Definition: compat.h:686
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLuint buffer
Definition: glext.h:5915
ULONG64 Address
Definition: compat.h:688
#define INIT_PSYM(buff)
Definition: rsym.c:88
static void deinit_sym()
Definition: rsym.c:67
struct _SYMBOL_INFO * PSYMBOL_INFO
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL supports_rsym(HANDLE hProc, DWORD64 BaseAddress)
Definition: rsym.c:72
ULONG64 ModBase
Definition: compat.h:685
smooth NULL
Definition: ftsmooth.c:416
DWORD dwErr
Definition: service.c:36
DWORD64 WINAPI SymLoadModule64(HANDLE hProcess, HANDLE hFile, PCSTR ImageName, PCSTR ModuleName, DWORD64 BaseOfDll, DWORD SizeOfDll)
Definition: module.c:673
char TCHAR
Definition: xmlstorage.h:189
#define ok_hex(expression, result)
Definition: test.h:759
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
#define todo_if(is_todo)
Definition: test.h:144
struct _SYMBOL_INFO SYMBOL_INFO
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
#define init_sym()
Definition: rsym.c:86
BOOL WINAPI SymFromAddr(HANDLE hProcess, DWORD64 Address, DWORD64 *Displacement, PSYMBOL_INFO Symbol)
Definition: symbol.c:1242
#define SYMFLAG_FUNCTION
Definition: compat.h:653
uint64_t DWORD64
Definition: typedefs.h:65
#define skip(...)
Definition: CString.cpp:57
#define SYMFLAG_EXPORT
Definition: compat.h:651
#define ERROR_MOD_NOT_FOUND
Definition: compat.h:94
LPCWSTR LPCWSTR szModuleName
Definition: env.c:35

Referenced by START_TEST().

◆ test_SymFromName()

static void test_SymFromName ( HANDLE  hProc,
const char szModuleName 
)
static

Definition at line 95 of file rsym.c.

96 {
97  BOOL Ret;
98  char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)];
99  PSYMBOL_INFO pSymbol = (PSYMBOL_INFO)buffer;
100 
102  DWORD dwErr;
103 
104  if (!init_sym())
105  return;
106 
108  BaseAddress = SymLoadModule64(hProc, NULL, szModuleName, NULL, 0x600000, 0);
109  dwErr = GetLastError();
110 
111  if (supports_rsym(hProc, BaseAddress))
112  {
113  ok_ulonglong(BaseAddress, 0x600000);
115 
116  INIT_PSYM(buffer);
117  Ret = SymFromName(hProc, "DllMain", pSymbol);
118  ok_int(Ret, TRUE);
119  ok_ulonglong(pSymbol->ModBase, BaseAddress);
120  ok_hex(pSymbol->Flags, SYMFLAG_FUNCTION);
121  ok_ulonglong(pSymbol->Address, BaseAddress + 0x1000);
122  ok_hex(pSymbol->Tag, SymTagFunction);
123  ok_str(pSymbol->Name, "DllMain");
124 
125  INIT_PSYM(buffer);
126  Ret = SymFromName(hProc, "FfsChkdsk", pSymbol);
127  ok_int(Ret, TRUE);
128  ok_ulonglong(pSymbol->ModBase, BaseAddress);
129  ok_hex(pSymbol->Flags, SYMFLAG_FUNCTION);
130  ok_ulonglong(pSymbol->Address, BaseAddress + 0x103F);
131  ok_hex(pSymbol->Tag, SymTagFunction);
132  ok_str(pSymbol->Name, "FfsChkdsk");
133 
134  INIT_PSYM(buffer);
135  Ret = SymFromName(hProc, "FfsFormat", pSymbol);
136  ok_int(Ret, TRUE);
137  ok_ulonglong(pSymbol->ModBase, BaseAddress);
138  ok_hex(pSymbol->Flags, SYMFLAG_FUNCTION);
139  ok_ulonglong(pSymbol->Address, BaseAddress + 0x100C);
140  ok_hex(pSymbol->Tag, SymTagFunction);
141  ok_str(pSymbol->Name, "FfsFormat");
142  }
143  else
144  {
145  skip("dbghelp.dll cannot parse rsym\n");
146  }
147 
148  deinit_sym();
149 }
#define ok_str(x, y)
Definition: sprintf.c:18
ULONG Tag
Definition: compat.h:691
CHAR Name[1]
Definition: compat.h:694
#define TRUE
Definition: types.h:120
#define ok_ulonglong(expression, result)
Definition: rsym.c:19
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ok_int(x, y)
Definition: sprintf.c:21
#define MAX_SYM_NAME
Definition: rsym.c:34
ULONG Flags
Definition: compat.h:686
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLuint buffer
Definition: glext.h:5915
ULONG64 Address
Definition: compat.h:688
#define INIT_PSYM(buff)
Definition: rsym.c:88
static void deinit_sym()
Definition: rsym.c:67
struct _SYMBOL_INFO * PSYMBOL_INFO
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL supports_rsym(HANDLE hProc, DWORD64 BaseAddress)
Definition: rsym.c:72
ULONG64 ModBase
Definition: compat.h:685
smooth NULL
Definition: ftsmooth.c:416
DWORD dwErr
Definition: service.c:36
DWORD64 WINAPI SymLoadModule64(HANDLE hProcess, HANDLE hFile, PCSTR ImageName, PCSTR ModuleName, DWORD64 BaseOfDll, DWORD SizeOfDll)
Definition: module.c:673
char TCHAR
Definition: xmlstorage.h:189
#define ok_hex(expression, result)
Definition: test.h:759
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
struct _SYMBOL_INFO SYMBOL_INFO
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
#define init_sym()
Definition: rsym.c:86
#define SYMFLAG_FUNCTION
Definition: compat.h:653
uint64_t DWORD64
Definition: typedefs.h:65
#define skip(...)
Definition: CString.cpp:57
BOOL WINAPI SymFromName(HANDLE hProcess, PCSTR Name, PSYMBOL_INFO Symbol)
Definition: symbol.c:1371
LPCWSTR LPCWSTR szModuleName
Definition: env.c:35

Referenced by START_TEST().

Variable Documentation

◆ test_data

Initial value:
= {
{ 0x107c, 0, SymTagPublicSymbol, "__CTOR_LIST__", __LINE__ },
{ 0x2074, 0, SymTagPublicSymbol, "__RUNTIME_PSEUDO_RELOC_LIST_END__", __LINE__ },
{ 0x1000, 12, SymTagPublicSymbol, "EntryPoint", __LINE__ },
{ 0x100c, 51, SymTagFunction, "FfsFormat", __LINE__ },
{ 0x4030, 0, SymTagPublicSymbol, "_imp__DbgPrint", __LINE__ },
{ 0x1084, 0, SymTagPublicSymbol, "__DTOR_LIST__", __LINE__ },
{ 0x103f, 53, SymTagFunction, "FfsChkdsk", __LINE__ },
{ 0x2074, 0, SymTagPublicSymbol, "_rt_psrelocs_end", __LINE__ },
{ 0x103f, 53, SymTagPublicSymbol, "ChkdskEx", __LINE__ },
{ 0x4048, 0, SymTagPublicSymbol, "_dll_ntdll_libntdll_a_iname", __LINE__ },
{ 0x2074, 0, SymTagPublicSymbol, "_rt_psrelocs_start", __LINE__ },
{ 0x1000, 12, SymTagFunction, "DllMain", __LINE__ },
{ 0x100c, 0, SymTagPublicSymbol, "FormatEx", __LINE__ },
{ 0x1074, 0, SymTagPublicSymbol, "DbgPrint", __LINE__ },
{ 0x68900000, 0, SymTagPublicSymbol, "__ImageBase", __LINE__ },
{ 0x68902074, 0, SymTagPublicSymbol, "__RUNTIME_PSEUDO_RELOC_LIST__", __LINE__ },
{ 0x4000, 0, SymTagPublicSymbol, "_head_dll_ntdll_libntdll_a", __LINE__ },
}