ReactOS  0.4.13-dev-482-ge57f103
dbghelp.c File Reference
#include "config.h"
#include "dbghelp_private.h"
#include "winerror.h"
#include "psapi.h"
#include "wine/debug.h"
#include "wdbgexts.h"
#include "winnls.h"
Include dependency graph for dbghelp.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (dbghelp)
 
struct processprocess_find_by_handle (HANDLE hProcess)
 
BOOL validate_addr64 (DWORD64 addr)
 
voidfetch_buffer (struct process *pcs, unsigned size)
 
const charwine_dbgstr_addr (const ADDRESS64 *addr)
 
struct cpucpu_find (DWORD machine)
 
BOOL WINAPI SymSetSearchPathW (HANDLE hProcess, PCWSTR searchPath)
 
BOOL WINAPI SymSetSearchPath (HANDLE hProcess, PCSTR searchPath)
 
BOOL WINAPI SymGetSearchPathW (HANDLE hProcess, PWSTR szSearchPath, DWORD SearchPathLength)
 
BOOL WINAPI SymGetSearchPath (HANDLE hProcess, PSTR szSearchPath, DWORD SearchPathLength)
 
static BOOL WINAPI process_invade_cb (PCWSTR name, ULONG64 base, ULONG size, PVOID user)
 
static BOOL check_live_target (struct process *pcs)
 
BOOL WINAPI SymInitializeW (HANDLE hProcess, PCWSTR UserSearchPath, BOOL fInvadeProcess)
 
BOOL WINAPI SymInitialize (HANDLE hProcess, PCSTR UserSearchPath, BOOL fInvadeProcess)
 
BOOL WINAPI SymCleanup (HANDLE hProcess)
 
DWORD WINAPI SymSetOptions (DWORD opts)
 
DWORD WINAPI SymGetOptions (void)
 
BOOL WINAPI SymSetParentWindow (HWND hwnd)
 
BOOL WINAPI SymSetContext (HANDLE hProcess, PIMAGEHLP_STACK_FRAME StackFrame, PIMAGEHLP_CONTEXT Context)
 
static BOOL CALLBACK reg_cb64to32 (HANDLE hProcess, ULONG action, ULONG64 data, ULONG64 user)
 
BOOL pcs_callback (const struct process *pcs, ULONG action, void *data)
 
static BOOL sym_register_cb (HANDLE hProcess, PSYMBOL_REGISTERED_CALLBACK64 cb, PSYMBOL_REGISTERED_CALLBACK cb32, DWORD64 user, BOOL unicode)
 
BOOL WINAPI SymRegisterCallback (HANDLE hProcess, PSYMBOL_REGISTERED_CALLBACK CallbackFunction, PVOID UserContext)
 
BOOL WINAPI SymRegisterCallback64 (HANDLE hProcess, PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction, ULONG64 UserContext)
 
BOOL WINAPI SymRegisterCallbackW64 (HANDLE hProcess, PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction, ULONG64 UserContext)
 
LPAPI_VERSION WINAPI ImagehlpApiVersion (VOID)
 
LPAPI_VERSION WINAPI ImagehlpApiVersionEx (LPAPI_VERSION AppVersion)
 
LPEXT_API_VERSION WINAPI ExtensionApiVersion (void)
 
void WINAPI WinDbgExtensionDllInit (PWINDBG_EXTENSION_APIS lpExtensionApis, unsigned short major, unsigned short minor)
 

Variables

unsigned dbghelp_options = SYMOPT_UNDNAME
 
static struct processprocess_first
 
struct cpu cpu_i386 cpu_x86_64 cpu_ppc cpu_arm cpu_arm64
 
static struct cpudbghelp_cpus [] = {&cpu_i386, &cpu_x86_64, &cpu_ppc, &cpu_arm, &cpu_arm64, NULL}
 
struct cpudbghelp_current_cpu =
 
static API_VERSION api_version = { 4, 0, 2, 0 }
 

Function Documentation

◆ check_live_target()

static BOOL check_live_target ( struct process pcs)
static

Definition at line 272 of file dbghelp.c.

273 {
274  if (!GetProcessId(pcs->handle)) return FALSE;
275  if (GetEnvironmentVariableA("DBGHELP_NOLIVE", NULL, 0)) return FALSE;
276 #ifndef DBGHELP_STATIC_LIB
279 #endif
280  return TRUE;
281 }
#define TRUE
Definition: types.h:120
smooth NULL
Definition: ftsmooth.c:416
#define GetEnvironmentVariableA(x, y, z)
Definition: compat.h:411
HANDLE handle
BOOL elf_read_wine_loader_dbg_info(struct process *pcs) DECLSPEC_HIDDEN
Definition: elf_module.c:1820
BOOL macho_read_wine_loader_dbg_info(struct process *pcs) DECLSPEC_HIDDEN
DWORD WINAPI GetProcessId(IN HANDLE Process)
Definition: proc.c:1230

Referenced by SymInitializeW().

◆ cpu_find()

struct cpu* cpu_find ( DWORD  machine)

Definition at line 166 of file dbghelp.c.

167 {
168  struct cpu** cpu;
169 
170  for (cpu = dbghelp_cpus ; *cpu; cpu++)
171  {
172  if (cpu[0]->machine == machine) return cpu[0];
173  }
174  return NULL;
175 }
static struct cpu * dbghelp_cpus[]
Definition: dbghelp.c:145
smooth NULL
Definition: ftsmooth.c:416
static const char machine[]
Definition: profile.c:104

Referenced by StackWalk(), and StackWalk64().

◆ ExtensionApiVersion()

LPEXT_API_VERSION WINAPI ExtensionApiVersion ( void  )

Definition at line 680 of file dbghelp.c.

681 {
682  static EXT_API_VERSION eav = {5, 5, 5, 0};
683  return &eav;
684 }

◆ fetch_buffer()

void* fetch_buffer ( struct process pcs,
unsigned  size 
)

Definition at line 109 of file dbghelp.c.

110 {
111  if (size > pcs->buffer_size)
112  {
113  if (pcs->buffer)
114  pcs->buffer = HeapReAlloc(GetProcessHeap(), 0, pcs->buffer, size);
115  else
116  pcs->buffer = HeapAlloc(GetProcessHeap(), 0, size);
117  pcs->buffer_size = (pcs->buffer) ? size : 0;
118  }
119  return pcs->buffer;
120 }
unsigned buffer_size
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
void * buffer
#define HeapReAlloc
Definition: compat.h:393

Referenced by copy_line_W64_from_64().

◆ ImagehlpApiVersion()

LPAPI_VERSION WINAPI ImagehlpApiVersion ( VOID  )

Definition at line 657 of file dbghelp.c.

658 {
659  return &api_version;
660 }
static API_VERSION api_version
Definition: dbghelp.c:652

Referenced by init_dbghelp_version().

◆ ImagehlpApiVersionEx()

LPAPI_VERSION WINAPI ImagehlpApiVersionEx ( LPAPI_VERSION  AppVersion)

Definition at line 665 of file dbghelp.c.

666 {
667  if (!AppVersion) return NULL;
668 
669  AppVersion->MajorVersion = api_version.MajorVersion;
670  AppVersion->MinorVersion = api_version.MinorVersion;
671  AppVersion->Revision = api_version.Revision;
672  AppVersion->Reserved = api_version.Reserved;
673 
674  return AppVersion;
675 }
USHORT MajorVersion
Definition: compat.h:1212
USHORT MinorVersion
Definition: compat.h:1213
USHORT Revision
Definition: compat.h:1214
smooth NULL
Definition: ftsmooth.c:416
static API_VERSION api_version
Definition: dbghelp.c:652
USHORT Reserved
Definition: compat.h:1215

◆ pcs_callback()

BOOL pcs_callback ( const struct process pcs,
ULONG  action,
void data 
)

Definition at line 551 of file dbghelp.c.

552 {
554 
555  TRACE("%p %u %p\n", pcs, action, data);
556 
557  if (!pcs->reg_cb) return FALSE;
558  if (!pcs->reg_is_unicode)
559  {
561 
562  switch (action)
563  {
564  case CBA_DEBUG_INFO:
566  case CBA_SET_OPTIONS:
568  break;
573  idslW = data;
574  idsl.SizeOfStruct = sizeof(idsl);
575  idsl.BaseOfImage = idslW->BaseOfImage;
576  idsl.CheckSum = idslW->CheckSum;
577  idsl.TimeDateStamp = idslW->TimeDateStamp;
578  WideCharToMultiByte(CP_ACP, 0, idslW->FileName, -1,
579  idsl.FileName, sizeof(idsl.FileName), NULL, NULL);
580  idsl.Reparse = idslW->Reparse;
581  data = &idsl;
582  break;
584  case CBA_EVENT:
585  case CBA_READ_MEMORY:
586  default:
587  FIXME("No mapping for action %u\n", action);
588  return FALSE;
589  }
590  }
591  return pcs->reg_cb(pcs->handle, action, (ULONG64)(DWORD_PTR)data, pcs->reg_user);
592 }
#define CBA_DEFERRED_SYMBOL_LOAD_COMPLETE
Definition: compat.h:626
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
#define CBA_EVENT
Definition: compat.h:633
WCHAR FileName[MAX_PATH+1]
Definition: compat.h:808
#define CBA_READ_MEMORY
Definition: compat.h:630
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define CBA_DEFERRED_SYMBOL_LOAD_FAILURE
Definition: compat.h:627
#define CBA_SYMBOLS_UNLOADED
Definition: compat.h:628
DWORD64 reg_user
#define TRACE(s)
Definition: solgame.cpp:4
PSYMBOL_REGISTERED_CALLBACK64 reg_cb
#define CBA_DEBUG_INFO
Definition: compat.h:635
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
unsigned __int64 ULONG64
Definition: imports.h:198
#define CBA_DUPLICATE_SYMBOL
Definition: compat.h:629
uint32_t DWORD_PTR
Definition: typedefs.h:63
#define CBA_DEFERRED_SYMBOL_LOAD_PARTIAL
Definition: compat.h:634
const WCHAR * action
Definition: action.c:7783
#define CBA_DEFERRED_SYMBOL_LOAD_START
Definition: compat.h:625
#define CBA_SET_OPTIONS
Definition: compat.h:632
HANDLE handle
#define CBA_DEFERRED_SYMBOL_LOAD_CANCEL
Definition: compat.h:631
BOOL reg_is_unicode

Referenced by module_get_debug(), and SymSetOptions().

◆ process_find_by_handle()

◆ process_invade_cb()

static BOOL WINAPI process_invade_cb ( PCWSTR  name,
ULONG64  base,
ULONG  size,
PVOID  user 
)
static

Definition at line 255 of file dbghelp.c.

256 {
257  WCHAR tmp[MAX_PATH];
258  HANDLE hProcess = user;
259 
261  tmp, sizeof(tmp) / sizeof(WCHAR)))
262  lstrcpynW(tmp, name, sizeof(tmp) / sizeof(WCHAR));
263 
264  SymLoadModuleExW(hProcess, 0, tmp, name, base, size, NULL, 0);
265  return TRUE;
266 }
#define TRUE
Definition: types.h:120
DWORD64 WINAPI SymLoadModuleExW(HANDLE, HANDLE, PCWSTR, PCWSTR, DWORD64, DWORD, PMODLOAD_DATA, DWORD)
Definition: module.c:578
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
#define lstrcpynW
Definition: compat.h:397
#define GetModuleFileNameExW(w, x, y, z)
Definition: compat.h:571
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
uint32_t DWORD_PTR
Definition: typedefs.h:63
Definition: name.c:36
void user(int argc, const char *argv[])
Definition: cmds.c:1350

Referenced by SymInitializeW().

◆ reg_cb64to32()

static BOOL CALLBACK reg_cb64to32 ( HANDLE  hProcess,
ULONG  action,
ULONG64  data,
ULONG64  user 
)
static

Definition at line 507 of file dbghelp.c.

508 {
509  struct process* pcs = process_find_by_handle(hProcess);
510  void* data32;
513 
514  if (!pcs) return FALSE;
515  switch (action)
516  {
517  case CBA_DEBUG_INFO:
519  case CBA_SET_OPTIONS:
521  data32 = (void*)(DWORD_PTR)data;
522  break;
528  if (!validate_addr64(idsl64->BaseOfImage))
529  return FALSE;
530  idsl.SizeOfStruct = sizeof(idsl);
531  idsl.BaseOfImage = (DWORD)idsl64->BaseOfImage;
532  idsl.CheckSum = idsl64->CheckSum;
533  idsl.TimeDateStamp = idsl64->TimeDateStamp;
534  memcpy(idsl.FileName, idsl64->FileName, sizeof(idsl.FileName));
535  idsl.Reparse = idsl64->Reparse;
536  data32 = &idsl;
537  break;
539  case CBA_EVENT:
540  case CBA_READ_MEMORY:
541  default:
542  FIXME("No mapping for action %u\n", action);
543  return FALSE;
544  }
545  return pcs->reg_cb32(hProcess, action, data32, (PVOID)(DWORD_PTR)user);
546 }
struct process * process_find_by_handle(HANDLE hProcess)
Definition: dbghelp.c:80
#define CBA_DEFERRED_SYMBOL_LOAD_COMPLETE
Definition: compat.h:626
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
#define CBA_EVENT
Definition: compat.h:633
#define DWORD
Definition: nt_native.h:44
#define CBA_READ_MEMORY
Definition: compat.h:630
#define FIXME(fmt,...)
Definition: debug.h:110
PSYMBOL_REGISTERED_CALLBACK reg_cb32
#define CBA_DEFERRED_SYMBOL_LOAD_FAILURE
Definition: compat.h:627
#define CBA_SYMBOLS_UNLOADED
Definition: compat.h:628
#define CBA_DEBUG_INFO
Definition: compat.h:635
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define CBA_DUPLICATE_SYMBOL
Definition: compat.h:629
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
uint32_t DWORD_PTR
Definition: typedefs.h:63
#define CBA_DEFERRED_SYMBOL_LOAD_PARTIAL
Definition: compat.h:634
const WCHAR * action
Definition: action.c:7783
static BYTE data32[]
Definition: misc.c:526
#define CBA_DEFERRED_SYMBOL_LOAD_START
Definition: compat.h:625
#define CBA_SET_OPTIONS
Definition: compat.h:632
#define CBA_DEFERRED_SYMBOL_LOAD_CANCEL
Definition: compat.h:631
BOOL validate_addr64(DWORD64 addr)
Definition: dbghelp.c:93
void user(int argc, const char *argv[])
Definition: cmds.c:1350

Referenced by SymRegisterCallback().

◆ sym_register_cb()

static BOOL sym_register_cb ( HANDLE  hProcess,
PSYMBOL_REGISTERED_CALLBACK64  cb,
PSYMBOL_REGISTERED_CALLBACK  cb32,
DWORD64  user,
BOOL  unicode 
)
static

Definition at line 599 of file dbghelp.c.

603 {
604  struct process* pcs = process_find_by_handle(hProcess);
605 
606  if (!pcs) return FALSE;
607  pcs->reg_cb = cb;
608  pcs->reg_cb32 = cb32;
609  pcs->reg_is_unicode = unicode;
610  pcs->reg_user = user;
611 
612  return TRUE;
613 }
#define TRUE
Definition: types.h:120
struct process * process_find_by_handle(HANDLE hProcess)
Definition: dbghelp.c:80
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
PSYMBOL_REGISTERED_CALLBACK reg_cb32
DWORD64 reg_user
PSYMBOL_REGISTERED_CALLBACK64 reg_cb
static DWORD cb
Definition: integrity.c:41
void user(int argc, const char *argv[])
Definition: cmds.c:1350
BOOL reg_is_unicode

Referenced by SymRegisterCallback(), SymRegisterCallback64(), and SymRegisterCallbackW64().

◆ SymCleanup()

BOOL WINAPI SymCleanup ( HANDLE  hProcess)

Definition at line 416 of file dbghelp.c.

417 {
418  struct process** ppcs;
419  struct process* next;
420 
421  for (ppcs = &process_first; *ppcs; ppcs = &(*ppcs)->next)
422  {
423  if ((*ppcs)->handle == hProcess)
424  {
425  while ((*ppcs)->lmodules) module_remove(*ppcs, (*ppcs)->lmodules);
426 
427  HeapFree(GetProcessHeap(), 0, (*ppcs)->search_path);
428  next = (*ppcs)->next;
429  HeapFree(GetProcessHeap(), 0, *ppcs);
430  *ppcs = next;
431  return TRUE;
432  }
433  }
434 
435  ERR("this process has not had SymInitialize() called for it!\n");
436  return FALSE;
437 }
#define TRUE
Definition: types.h:120
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
static struct process * process_first
Definition: dbghelp.c:74
#define GetProcessHeap()
Definition: compat.h:395
#define ERR(fmt,...)
Definition: debug.h:109
static unsigned __int64 next
Definition: rand_nt.c:6
struct process * next
BOOL module_remove(struct process *pcs, struct module *module) DECLSPEC_HIDDEN
Definition: module.c:684
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by deinit_sym(), EndStackBacktrace(), main(), and SymInitializeW().

◆ SymGetOptions()

DWORD WINAPI SymGetOptions ( void  )

Definition at line 458 of file dbghelp.c.

459 {
460  return dbghelp_options;
461 }
unsigned dbghelp_options
Definition: dbghelp.c:72

Referenced by BeginStackBacktrace(), InitDbgHelp(), and START_TEST().

◆ SymGetSearchPath()

BOOL WINAPI SymGetSearchPath ( HANDLE  hProcess,
PSTR  szSearchPath,
DWORD  SearchPathLength 
)

Definition at line 232 of file dbghelp.c.

234 {
235  WCHAR* buffer = HeapAlloc(GetProcessHeap(), 0, SearchPathLength * sizeof(WCHAR));
236  BOOL ret = FALSE;
237 
238  if (buffer)
239  {
240  ret = SymGetSearchPathW(hProcess, buffer, SearchPathLength);
241  if (ret)
242  WideCharToMultiByte(CP_ACP, 0, buffer, SearchPathLength,
243  szSearchPath, SearchPathLength, NULL, NULL);
245  }
246  return ret;
247 }
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
BOOL WINAPI SymGetSearchPathW(HANDLE hProcess, PWSTR szSearchPath, DWORD SearchPathLength)
Definition: dbghelp.c:219
GLuint buffer
Definition: glext.h:5915
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
int ret
#define HeapFree(x, y, z)
Definition: compat.h:394

◆ SymGetSearchPathW()

BOOL WINAPI SymGetSearchPathW ( HANDLE  hProcess,
PWSTR  szSearchPath,
DWORD  SearchPathLength 
)

Definition at line 219 of file dbghelp.c.

221 {
222  struct process* pcs = process_find_by_handle(hProcess);
223  if (!pcs) return FALSE;
224 
225  lstrcpynW(szSearchPath, pcs->search_path, SearchPathLength);
226  return TRUE;
227 }
WCHAR * search_path
#define TRUE
Definition: types.h:120
struct process * process_find_by_handle(HANDLE hProcess)
Definition: dbghelp.c:80
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
#define lstrcpynW
Definition: compat.h:397

Referenced by SymGetSearchPath().

◆ SymInitialize()

BOOL WINAPI SymInitialize ( HANDLE  hProcess,
PCSTR  UserSearchPath,
BOOL  fInvadeProcess 
)

Definition at line 393 of file dbghelp.c.

394 {
395  WCHAR* sp = NULL;
396  BOOL ret;
397 
398  if (UserSearchPath)
399  {
400  unsigned len;
401 
402  len = MultiByteToWideChar(CP_ACP, 0, UserSearchPath, -1, NULL, 0);
403  sp = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
404  MultiByteToWideChar(CP_ACP, 0, UserSearchPath, -1, sp, len);
405  }
406 
407  ret = SymInitializeW(hProcess, sp, fInvadeProcess);
408  HeapFree(GetProcessHeap(), 0, sp);
409  return ret;
410 }
#define CP_ACP
Definition: compat.h:99
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI SymInitializeW(HANDLE hProcess, PCWSTR UserSearchPath, BOOL fInvadeProcess)
Definition: dbghelp.c:309
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define MultiByteToWideChar
Definition: compat.h:100
static const WCHAR sp[]
Definition: suminfo.c:288
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by BeginStackBacktrace(), init_sym_imp(), InitDbgHelp(), and main().

◆ SymInitializeW()

BOOL WINAPI SymInitializeW ( HANDLE  hProcess,
PCWSTR  UserSearchPath,
BOOL  fInvadeProcess 
)

Definition at line 309 of file dbghelp.c.

310 {
311  struct process* pcs;
312 
313  TRACE("(%p %s %u)\n", hProcess, debugstr_w(UserSearchPath), fInvadeProcess);
314 
316  WARN("the symbols for this process have already been initialized!\n");
317 
318  /* MSDN says to only call this function once unless SymCleanup() has been called since the last call.
319  It also says to call SymRefreshModuleList() instead if you just want the module list refreshed.
320  Native still returns TRUE even if the process has already been initialized. */
321  return TRUE;
322  }
323 
324  pcs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pcs));
325  if (!pcs) return FALSE;
326 
327  pcs->handle = hProcess;
328 
329  if (UserSearchPath)
330  {
332  (lstrlenW(UserSearchPath) + 1) * sizeof(WCHAR)),
333  UserSearchPath);
334  }
335  else
336  {
337  unsigned size;
338  unsigned len;
339  static const WCHAR sym_path[] = {'_','N','T','_','S','Y','M','B','O','L','_','P','A','T','H',0};
340  static const WCHAR alt_sym_path[] = {'_','N','T','_','A','L','T','E','R','N','A','T','E','_','S','Y','M','B','O','L','_','P','A','T','H',0};
341 
342  pcs->search_path = HeapAlloc(GetProcessHeap(), 0, (len = MAX_PATH) * sizeof(WCHAR));
343  while ((size = GetCurrentDirectoryW(len, pcs->search_path)) >= len)
344  pcs->search_path = HeapReAlloc(GetProcessHeap(), 0, pcs->search_path, (len *= 2) * sizeof(WCHAR));
345  pcs->search_path = HeapReAlloc(GetProcessHeap(), 0, pcs->search_path, (size + 1) * sizeof(WCHAR));
346 
347  len = GetEnvironmentVariableW(sym_path, NULL, 0);
348  if (len)
349  {
350  pcs->search_path = HeapReAlloc(GetProcessHeap(), 0, pcs->search_path, (size + 1 + len + 1) * sizeof(WCHAR));
351  pcs->search_path[size] = ';';
352  GetEnvironmentVariableW(sym_path, pcs->search_path + size + 1, len);
353  size += 1 + len;
354  }
355  len = GetEnvironmentVariableW(alt_sym_path, NULL, 0);
356  if (len)
357  {
358  pcs->search_path = HeapReAlloc(GetProcessHeap(), 0, pcs->search_path, (size + 1 + len + 1) * sizeof(WCHAR));
359  pcs->search_path[size] = ';';
360  GetEnvironmentVariableW(alt_sym_path, pcs->search_path + size + 1, len);
361  }
362  }
363 
364  pcs->lmodules = NULL;
365  pcs->dbg_hdr_addr = 0;
366  pcs->next = process_first;
367  process_first = pcs;
368 
369 #ifndef DBGHELP_STATIC_LIB
370  if (check_live_target(pcs))
371  {
372  if (fInvadeProcess)
376  }
377  else if (fInvadeProcess)
378  {
381  return FALSE;
382  }
383 #endif
384 
385  return TRUE;
386 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
WCHAR * search_path
#define TRUE
Definition: types.h:120
struct process * process_find_by_handle(HANDLE hProcess)
Definition: dbghelp.c:80
#define WARN(fmt,...)
Definition: debug.h:111
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:413
BOOL WINAPI SymCleanup(HANDLE hProcess)
Definition: dbghelp.c:416
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
#define lstrlenW
Definition: compat.h:407
struct module * lmodules
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
static struct process * process_first
Definition: dbghelp.c:74
BOOL elf_synchronize_module_list(struct process *pcs) DECLSPEC_HIDDEN
Definition: elf_module.c:1809
BOOL WINAPI EnumerateLoadedModulesW64(HANDLE hProcess, PENUMLOADED_MODULES_CALLBACKW64 EnumLoadedModulesCallback, PVOID UserContext)
Definition: module.c:906
static BOOL WINAPI process_invade_cb(PCWSTR name, ULONG64 base, ULONG size, PVOID user)
Definition: dbghelp.c:255
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
#define SetLastError(x)
Definition: compat.h:409
unsigned long dbg_hdr_addr
GLenum GLsizei len
Definition: glext.h:6722
BOOL macho_synchronize_module_list(struct process *pcs) DECLSPEC_HIDDEN
struct process * next
#define lstrcpyW
Definition: compat.h:406
#define HeapReAlloc
Definition: compat.h:393
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
static BOOL check_live_target(struct process *pcs)
Definition: dbghelp.c:272
HANDLE handle
#define GetEnvironmentVariableW(x, y, z)
Definition: compat.h:412

Referenced by SymInitialize().

◆ SymRegisterCallback()

BOOL WINAPI SymRegisterCallback ( HANDLE  hProcess,
PSYMBOL_REGISTERED_CALLBACK  CallbackFunction,
PVOID  UserContext 
)

Definition at line 618 of file dbghelp.c.

621 {
622  TRACE("(%p, %p, %p)\n",
623  hProcess, CallbackFunction, UserContext);
625 }
static BOOL CALLBACK reg_cb64to32(HANDLE hProcess, ULONG action, ULONG64 data, ULONG64 user)
Definition: dbghelp.c:507
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
_In_ PCALLBACK_FUNCTION CallbackFunction
Definition: exfuncs.h:826
static BOOL sym_register_cb(HANDLE hProcess, PSYMBOL_REGISTERED_CALLBACK64 cb, PSYMBOL_REGISTERED_CALLBACK cb32, DWORD64 user, BOOL unicode)
Definition: dbghelp.c:599
#define TRACE(s)
Definition: solgame.cpp:4
uint32_t DWORD_PTR
Definition: typedefs.h:63

◆ SymRegisterCallback64()

BOOL WINAPI SymRegisterCallback64 ( HANDLE  hProcess,
PSYMBOL_REGISTERED_CALLBACK64  CallbackFunction,
ULONG64  UserContext 
)

Definition at line 630 of file dbghelp.c.

633 {
634  TRACE("(%p, %p, %s)\n",
636  return sym_register_cb(hProcess, CallbackFunction, NULL, UserContext, FALSE);
637 }
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
_In_ PCALLBACK_FUNCTION CallbackFunction
Definition: exfuncs.h:826
smooth NULL
Definition: ftsmooth.c:416
static BOOL sym_register_cb(HANDLE hProcess, PSYMBOL_REGISTERED_CALLBACK64 cb, PSYMBOL_REGISTERED_CALLBACK cb32, DWORD64 user, BOOL unicode)
Definition: dbghelp.c:599
#define TRACE(s)
Definition: solgame.cpp:4
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41

Referenced by test_SymRegCallback().

◆ SymRegisterCallbackW64()

BOOL WINAPI SymRegisterCallbackW64 ( HANDLE  hProcess,
PSYMBOL_REGISTERED_CALLBACK64  CallbackFunction,
ULONG64  UserContext 
)

Definition at line 642 of file dbghelp.c.

645 {
646  TRACE("(%p, %p, %s)\n",
648  return sym_register_cb(hProcess, CallbackFunction, NULL, UserContext, TRUE);
649 }
#define TRUE
Definition: types.h:120
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
_In_ PCALLBACK_FUNCTION CallbackFunction
Definition: exfuncs.h:826
smooth NULL
Definition: ftsmooth.c:416
static BOOL sym_register_cb(HANDLE hProcess, PSYMBOL_REGISTERED_CALLBACK64 cb, PSYMBOL_REGISTERED_CALLBACK cb32, DWORD64 user, BOOL unicode)
Definition: dbghelp.c:599
#define TRACE(s)
Definition: solgame.cpp:4
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41

Referenced by test_SymRegCallback().

◆ SymSetContext()

BOOL WINAPI SymSetContext ( HANDLE  hProcess,
PIMAGEHLP_STACK_FRAME  StackFrame,
PIMAGEHLP_CONTEXT  Context 
)

Definition at line 478 of file dbghelp.c.

480 {
481  struct process* pcs = process_find_by_handle(hProcess);
482  if (!pcs) return FALSE;
483 
484  if (pcs->ctx_frame.ReturnOffset == StackFrame->ReturnOffset &&
485  pcs->ctx_frame.FrameOffset == StackFrame->FrameOffset &&
486  pcs->ctx_frame.StackOffset == StackFrame->StackOffset)
487  {
488  TRACE("Setting same frame {rtn=%s frm=%s stk=%s}\n",
492  pcs->ctx_frame.InstructionOffset = StackFrame->InstructionOffset;
493  SetLastError(ERROR_ACCESS_DENIED); /* latest MSDN says ERROR_SUCCESS */
494  return FALSE;
495  }
496 
497  pcs->ctx_frame = *StackFrame;
498  /* MSDN states that Context is not (no longer?) used */
499  return TRUE;
500 }
#define TRUE
Definition: types.h:120
struct process * process_find_by_handle(HANDLE hProcess)
Definition: dbghelp.c:80
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
IMAGEHLP_STACK_FRAME ctx_frame
#define ERROR_ACCESS_DENIED
Definition: compat.h:87
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:409
ULONG64 InstructionOffset
Definition: compat.h:1017
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41
ULONG64 ReturnOffset
Definition: compat.h:1018

Referenced by DumpParams(), and ParseImageSymbols().

◆ SymSetOptions()

DWORD WINAPI SymSetOptions ( DWORD  opts)

Definition at line 443 of file dbghelp.c.

444 {
445  struct process* pcs;
446 
447  for (pcs = process_first; pcs; pcs = pcs->next)
448  {
449  pcs_callback(pcs, CBA_SET_OPTIONS, &opts);
450  }
451  return dbghelp_options = opts;
452 }
BOOL pcs_callback(const struct process *pcs, ULONG action, void *data)
Definition: dbghelp.c:551
static struct process * process_first
Definition: dbghelp.c:74
unsigned dbghelp_options
Definition: dbghelp.c:72
struct process * next
#define CBA_SET_OPTIONS
Definition: compat.h:632

Referenced by BeginStackBacktrace(), InitDbgHelp(), main(), and START_TEST().

◆ SymSetParentWindow()

BOOL WINAPI SymSetParentWindow ( HWND  hwnd)

Definition at line 467 of file dbghelp.c.

468 {
469  /* Save hwnd so it can be used as parent window */
470  FIXME("(%p): stub\n", hwnd);
471  return TRUE;
472 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
#define FIXME(fmt,...)
Definition: debug.h:110

◆ SymSetSearchPath()

BOOL WINAPI SymSetSearchPath ( HANDLE  hProcess,
PCSTR  searchPath 
)

Definition at line 199 of file dbghelp.c.

200 {
201  BOOL ret = FALSE;
202  unsigned len;
203  WCHAR* sp;
204 
205  len = MultiByteToWideChar(CP_ACP, 0, searchPath, -1, NULL, 0);
206  if ((sp = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR))))
207  {
208  MultiByteToWideChar(CP_ACP, 0, searchPath, -1, sp, len);
209 
211  HeapFree(GetProcessHeap(), 0, sp);
212  }
213  return ret;
214 }
#define CP_ACP
Definition: compat.h:99
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI SymSetSearchPathW(HANDLE hProcess, PCWSTR searchPath)
Definition: dbghelp.c:181
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define MultiByteToWideChar
Definition: compat.h:100
static const WCHAR sp[]
Definition: suminfo.c:288
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by InitDbgHelp().

◆ SymSetSearchPathW()

BOOL WINAPI SymSetSearchPathW ( HANDLE  hProcess,
PCWSTR  searchPath 
)

Definition at line 181 of file dbghelp.c.

182 {
183  struct process* pcs = process_find_by_handle(hProcess);
184 
185  if (!pcs) return FALSE;
186  if (!searchPath) return FALSE;
187 
188  HeapFree(GetProcessHeap(), 0, pcs->search_path);
190  (lstrlenW(searchPath) + 1) * sizeof(WCHAR)),
191  searchPath);
192  return TRUE;
193 }
WCHAR * search_path
#define TRUE
Definition: types.h:120
struct process * process_find_by_handle(HANDLE hProcess)
Definition: dbghelp.c:80
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
#define lstrlenW
Definition: compat.h:407
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define lstrcpyW
Definition: compat.h:406
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by SymSetSearchPath().

◆ validate_addr64()

BOOL validate_addr64 ( DWORD64  addr)

Definition at line 93 of file dbghelp.c.

94 {
95  if (sizeof(void*) == sizeof(int) && (addr >> 32))
96  {
97  FIXME("Unsupported address %s\n", wine_dbgstr_longlong(addr));
99  return FALSE;
100  }
101  return TRUE;
102 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define FIXME(fmt,...)
Definition: debug.h:110
#define SetLastError(x)
Definition: compat.h:409
GLenum const GLvoid * addr
Definition: glext.h:9621
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41

Referenced by fetch_pe_module_info_cb(), reg_cb64to32(), SymGetModuleBase(), SymLoadModuleExW(), and SymUnloadModule64().

◆ WinDbgExtensionDllInit()

void WINAPI WinDbgExtensionDllInit ( PWINDBG_EXTENSION_APIS  lpExtensionApis,
unsigned short  major,
unsigned short  minor 
)

Definition at line 689 of file dbghelp.c.

691 {
692 }

◆ wine_dbgstr_addr()

const char* wine_dbgstr_addr ( const ADDRESS64 addr)

Definition at line 123 of file dbghelp.c.

124 {
125  if (!addr) return "(null)";
126  switch (addr->Mode)
127  {
128  case AddrModeFlat:
129  return wine_dbg_sprintf("flat<%s>", wine_dbgstr_longlong(addr->Offset));
130  case AddrMode1616:
131  return wine_dbg_sprintf("1616<%04x:%04x>", addr->Segment, (DWORD)addr->Offset);
132  case AddrMode1632:
133  return wine_dbg_sprintf("1632<%04x:%08x>", addr->Segment, (DWORD)addr->Offset);
134  case AddrModeReal:
135  return wine_dbg_sprintf("real<%04x:%04x>", addr->Segment, (DWORD)addr->Offset);
136  default:
137  return "unknown";
138  }
139 }
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:271
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum const GLvoid * addr
Definition: glext.h:9621
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41

Referenced by i386_stack_walk().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( dbghelp  )

Variable Documentation

◆ api_version

API_VERSION api_version = { 4, 0, 2, 0 }
static

Definition at line 652 of file dbghelp.c.

Referenced by ImagehlpApiVersion(), and ImagehlpApiVersionEx().

◆ cpu_arm64

Definition at line 277 of file cpu_arm64.c.

◆ dbghelp_cpus

struct cpu* dbghelp_cpus[] = {&cpu_i386, &cpu_x86_64, &cpu_ppc, &cpu_arm, &cpu_arm64, NULL}
static

Definition at line 145 of file dbghelp.c.

Referenced by cpu_find().

◆ dbghelp_current_cpu

◆ dbghelp_options

◆ process_first

struct process* process_first
static

Definition at line 74 of file dbghelp.c.

Referenced by process_find_by_handle(), SymCleanup(), SymInitializeW(), and SymSetOptions().