ReactOS  0.4.13-dev-563-g0561610
module.c File Reference
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "dbghelp_private.h"
#include "psapi.h"
#include "winternl.h"
#include "wine/debug.h"
Include dependency graph for module.c:

Go to the source code of this file.

Classes

struct  enum_modW64_32
 
struct  enum_modW64_64
 
struct  enum_load_modW64_64
 
struct  enum_load_modW64_32
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (dbghelp)
 
static int match_ext (const WCHAR *ptr, size_t len)
 
static const WCHARget_filename (const WCHAR *name, const WCHAR *endptr)
 
static void module_fill_module (const WCHAR *in, WCHAR *out, size_t size)
 
void module_set_module (struct module *module, const WCHAR *name)
 
const WCHARget_wine_loader_name (void)
 
static const charget_module_type (enum module_type type, BOOL virtual)
 
struct modulemodule_new (struct process *pcs, const WCHAR *name, enum module_type type, BOOL virtual, DWORD64 mod_addr, DWORD64 size, unsigned long stamp, unsigned long checksum)
 
struct modulemodule_find_by_nameW (const struct process *pcs, const WCHAR *name)
 
struct modulemodule_find_by_nameA (const struct process *pcs, const char *name)
 
struct modulemodule_is_already_loaded (const struct process *pcs, const WCHAR *name)
 
static struct modulemodule_get_container (const struct process *pcs, const struct module *inner)
 
struct modulemodule_get_containee (const struct process *pcs, const struct module *outter)
 
BOOL module_get_debug (struct module_pair *pair)
 
struct modulemodule_find_by_addr (const struct process *pcs, DWORD64 addr, enum module_type type)
 
static BOOL module_is_container_loaded (const struct process *pcs, const WCHAR *ImageName, DWORD64 base)
 
enum module_type module_get_type_by_name (const WCHAR *name)
 
static BOOL refresh_module_list (struct process *pcs)
 
DWORD WINAPI SymLoadModule (HANDLE hProcess, HANDLE hFile, PCSTR ImageName, PCSTR ModuleName, DWORD BaseOfDll, DWORD SizeOfDll)
 
DWORD64 WINAPI SymLoadModuleEx (HANDLE hProcess, HANDLE hFile, PCSTR ImageName, PCSTR ModuleName, DWORD64 BaseOfDll, DWORD DllSize, PMODLOAD_DATA Data, DWORD Flags)
 
DWORD64 WINAPI SymLoadModuleExW (HANDLE hProcess, HANDLE hFile, PCWSTR wImageName, PCWSTR wModuleName, DWORD64 BaseOfDll, DWORD SizeOfDll, PMODLOAD_DATA Data, DWORD Flags)
 
DWORD64 WINAPI SymLoadModule64 (HANDLE hProcess, HANDLE hFile, PCSTR ImageName, PCSTR ModuleName, DWORD64 BaseOfDll, DWORD SizeOfDll)
 
BOOL module_remove (struct process *pcs, struct module *module)
 
BOOL WINAPI SymUnloadModule (HANDLE hProcess, DWORD BaseOfDll)
 
BOOL WINAPI SymUnloadModule64 (HANDLE hProcess, DWORD64 BaseOfDll)
 
static BOOL CALLBACK enum_modW64_32 (PCWSTR name, DWORD64 base, PVOID user)
 
BOOL WINAPI SymEnumerateModules (HANDLE hProcess, PSYM_ENUMMODULES_CALLBACK EnumModulesCallback, PVOID UserContext)
 
static BOOL CALLBACK enum_modW64_64 (PCWSTR name, DWORD64 base, PVOID user)
 
BOOL WINAPI SymEnumerateModules64 (HANDLE hProcess, PSYM_ENUMMODULES_CALLBACK64 EnumModulesCallback, PVOID UserContext)
 
BOOL WINAPI SymEnumerateModulesW64 (HANDLE hProcess, PSYM_ENUMMODULES_CALLBACKW64 EnumModulesCallback, PVOID UserContext)
 
static BOOL CALLBACK enum_load_modW64_64 (PCWSTR name, DWORD64 base, ULONG size, PVOID user)
 
BOOL WINAPI EnumerateLoadedModules64 (HANDLE hProcess, PENUMLOADED_MODULES_CALLBACK64 EnumLoadedModulesCallback, PVOID UserContext)
 
static BOOL CALLBACK enum_load_modW64_32 (PCWSTR name, DWORD64 base, ULONG size, PVOID user)
 
BOOL WINAPI EnumerateLoadedModules (HANDLE hProcess, PENUMLOADED_MODULES_CALLBACK EnumLoadedModulesCallback, PVOID UserContext)
 
BOOL WINAPI EnumerateLoadedModulesW64 (HANDLE hProcess, PENUMLOADED_MODULES_CALLBACKW64 EnumLoadedModulesCallback, PVOID UserContext)
 
static void dbghelp_str_WtoA (const WCHAR *src, char *dst, int dst_len)
 
BOOL WINAPI SymGetModuleInfo (HANDLE hProcess, DWORD dwAddr, PIMAGEHLP_MODULE ModuleInfo)
 
BOOL WINAPI SymGetModuleInfoW (HANDLE hProcess, DWORD dwAddr, PIMAGEHLP_MODULEW ModuleInfo)
 
BOOL WINAPI SymGetModuleInfo64 (HANDLE hProcess, DWORD64 dwAddr, PIMAGEHLP_MODULE64 ModuleInfo)
 
BOOL WINAPI SymGetModuleInfoW64 (HANDLE hProcess, DWORD64 dwAddr, PIMAGEHLP_MODULEW64 ModuleInfo)
 
DWORD WINAPI SymGetModuleBase (HANDLE hProcess, DWORD dwAddr)
 
DWORD64 WINAPI SymGetModuleBase64 (HANDLE hProcess, DWORD64 dwAddr)
 
void module_reset_debug_info (struct module *module)
 
BOOL WINAPI SymRefreshModuleList (HANDLE hProcess)
 
PVOID WINAPI SymFunctionTableAccess (HANDLE hProcess, DWORD AddrBase)
 
PVOID WINAPI SymFunctionTableAccess64 (HANDLE hProcess, DWORD64 AddrBase)
 

Variables

const WCHAR S_ElfW [] = {'<','e','l','f','>','\0'}
 
const WCHAR S_WineLoaderW [] = {'<','w','i','n','e','-','l','o','a','d','e','r','>','\0'}
 
static const WCHAR S_DotSoW [] = {'.','s','o','\0'}
 
static const WCHAR S_DotDylibW [] = {'.','d','y','l','i','b','\0'}
 
static const WCHAR S_DotPdbW [] = {'.','p','d','b','\0'}
 
static const WCHAR S_DotDbgW [] = {'.','d','b','g','\0'}
 
const WCHAR S_SlashW [] = {'/','\0'}
 
static const WCHAR S_AcmW [] = {'.','a','c','m','\0'}
 
static const WCHAR S_DllW [] = {'.','d','l','l','\0'}
 
static const WCHAR S_DrvW [] = {'.','d','r','v','\0'}
 
static const WCHAR S_ExeW [] = {'.','e','x','e','\0'}
 
static const WCHAR S_OcxW [] = {'.','o','c','x','\0'}
 
static const WCHAR S_VxdW [] = {'.','v','x','d','\0'}
 
static const WCHAR *const ext [] = {S_AcmW, S_DllW, S_DrvW, S_ExeW, S_OcxW, S_VxdW, NULL}
 

Function Documentation

◆ dbghelp_str_WtoA()

static void dbghelp_str_WtoA ( const WCHAR src,
char dst,
int  dst_len 
)
static

Definition at line 942 of file module.c.

943 {
944  WideCharToMultiByte(CP_ACP, 0, src, -1, dst, dst_len - 1, NULL, NULL);
945  dst[dst_len - 1] = 0;
946 }
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
smooth NULL
Definition: ftsmooth.c:416
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

Referenced by SymGetModuleInfo(), and SymGetModuleInfo64().

◆ enum_load_modW64_32()

static BOOL CALLBACK enum_load_modW64_32 ( PCWSTR  name,
DWORD64  base,
ULONG  size,
PVOID  user 
)
static

Definition at line 882 of file module.c.

884 {
885  struct enum_load_modW64_32* x = user;
886  WideCharToMultiByte(CP_ACP, 0, name, -1, x->module, sizeof(x->module), NULL, NULL);
887  return x->cb(x->module, (DWORD)base, size, x->user);
888 }
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: name.c:36
void user(int argc, const char *argv[])
Definition: cmds.c:1350

◆ enum_load_modW64_64()

static BOOL CALLBACK enum_load_modW64_64 ( PCWSTR  name,
DWORD64  base,
ULONG  size,
PVOID  user 
)
static

Definition at line 850 of file module.c.

852 {
853  struct enum_load_modW64_64* x = user;
854 
855  WideCharToMultiByte(CP_ACP, 0, name, -1, x->module, sizeof(x->module), NULL, NULL);
856  return x->cb(x->module, base, size, x->user);
857 }
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
Definition: name.c:36
void user(int argc, const char *argv[])
Definition: cmds.c:1350

◆ enum_modW64_32()

static BOOL CALLBACK enum_modW64_32 ( PCWSTR  name,
DWORD64  base,
PVOID  user 
)
static

Definition at line 762 of file module.c.

763 {
764  struct enum_modW64_32* x = user;
765 
766  WideCharToMultiByte(CP_ACP, 0, name, -1, x->module, sizeof(x->module), NULL, NULL);
767  return x->cb(x->module, (DWORD)base, x->user);
768 }
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: name.c:36
void user(int argc, const char *argv[])
Definition: cmds.c:1350

◆ enum_modW64_64()

static BOOL CALLBACK enum_modW64_64 ( PCWSTR  name,
DWORD64  base,
PVOID  user 
)
static

Definition at line 793 of file module.c.

794 {
795  struct enum_modW64_64* x = user;
796 
797  WideCharToMultiByte(CP_ACP, 0, name, -1, x->module, sizeof(x->module), NULL, NULL);
798  return x->cb(x->module, base, x->user);
799 }
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
smooth NULL
Definition: ftsmooth.c:416
Definition: name.c:36
void user(int argc, const char *argv[])
Definition: cmds.c:1350

◆ EnumerateLoadedModules()

BOOL WINAPI EnumerateLoadedModules ( HANDLE  hProcess,
PENUMLOADED_MODULES_CALLBACK  EnumLoadedModulesCallback,
PVOID  UserContext 
)

Definition at line 890 of file module.c.

893 {
894  struct enum_load_modW64_32 x;
895 
896  x.cb = EnumLoadedModulesCallback;
897  x.user = UserContext;
898 
900 }
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
BOOL WINAPI EnumerateLoadedModulesW64(HANDLE hProcess, PENUMLOADED_MODULES_CALLBACKW64 EnumLoadedModulesCallback, PVOID UserContext)
Definition: module.c:906
PENUMLOADED_MODULES_CALLBACK cb
Definition: module.c:877

◆ EnumerateLoadedModules64()

BOOL WINAPI EnumerateLoadedModules64 ( HANDLE  hProcess,
PENUMLOADED_MODULES_CALLBACK64  EnumLoadedModulesCallback,
PVOID  UserContext 
)

Definition at line 859 of file module.c.

862 {
863  struct enum_load_modW64_64 x;
864 
865  x.cb = EnumLoadedModulesCallback;
866  x.user = UserContext;
867 
869 }
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
PENUMLOADED_MODULES_CALLBACK64 cb
Definition: module.c:845
BOOL WINAPI EnumerateLoadedModulesW64(HANDLE hProcess, PENUMLOADED_MODULES_CALLBACKW64 EnumLoadedModulesCallback, PVOID UserContext)
Definition: module.c:906

◆ EnumerateLoadedModulesW64()

BOOL WINAPI EnumerateLoadedModulesW64 ( HANDLE  hProcess,
PENUMLOADED_MODULES_CALLBACKW64  EnumLoadedModulesCallback,
PVOID  UserContext 
)

Definition at line 906 of file module.c.

909 {
910  HMODULE* hMods;
911  WCHAR baseW[256], modW[256];
912  DWORD i, sz;
913  MODULEINFO mi;
914 
915  hMods = HeapAlloc(GetProcessHeap(), 0, 256 * sizeof(hMods[0]));
916  if (!hMods) return FALSE;
917 
918  if (!EnumProcessModules(hProcess, hMods, 256 * sizeof(hMods[0]), &sz))
919  {
920  /* hProcess should also be a valid process handle !! */
921  FIXME("If this happens, bump the number in mod\n");
922  HeapFree(GetProcessHeap(), 0, hMods);
923  return FALSE;
924  }
925  sz /= sizeof(HMODULE);
926  for (i = 0; i < sz; i++)
927  {
928  if (!GetModuleInformation(hProcess, hMods[i], &mi, sizeof(mi)) ||
929  !GetModuleBaseNameW(hProcess, hMods[i], baseW, sizeof(baseW) / sizeof(WCHAR)))
930  continue;
931  module_fill_module(baseW, modW, sizeof(modW) / sizeof(modW[0]));
932  EnumLoadedModulesCallback(modW, (DWORD_PTR)mi.lpBaseOfDll, mi.SizeOfImage,
933  UserContext);
934  }
935  HeapFree(GetProcessHeap(), 0, hMods);
936 
937  return sz != 0 && i == sz;
938 }
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
static MONITORINFO mi
Definition: win.c:7331
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define FIXME(fmt,...)
Definition: debug.h:110
DWORD WINAPI GetModuleBaseNameW(HANDLE hProcess, HMODULE hModule, LPWSTR lpBaseName, DWORD nSize)
Definition: psapi.c:930
BOOL WINAPI EnumProcessModules(HANDLE hProcess, HMODULE *lphModule, DWORD cb, LPDWORD lpcbNeeded)
Definition: psapi.c:542
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
uint32_t DWORD_PTR
Definition: typedefs.h:63
static const WCHAR modW[]
Definition: lex.c:64
HANDLE HMODULE
Definition: typedefs.h:75
BOOL WINAPI GetModuleInformation(HANDLE hProcess, HMODULE hModule, LPMODULEINFO lpmodinfo, DWORD cb)
Definition: psapi.c:1080
static void module_fill_module(const WCHAR *in, WCHAR *out, size_t size)
Definition: module.c:80
static WCHAR baseW[MAX_PATH]
Definition: FindFiles.c:23
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by EnumerateLoadedModules(), EnumerateLoadedModules64(), fetch_modules_info(), and SymInitializeW().

◆ get_filename()

static const WCHAR* get_filename ( const WCHAR name,
const WCHAR endptr 
)
static

Definition at line 68 of file module.c.

69 {
70  const WCHAR* ptr;
71 
72  if (!endptr) endptr = name + strlenW(name);
73  for (ptr = endptr - 1; ptr >= name; ptr--)
74  {
75  if (*ptr == '/' || *ptr == '\\') break;
76  }
77  return ++ptr;
78 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
static PVOID ptr
Definition: dispmode.c:27
__wchar_t WCHAR
Definition: xmlstorage.h:180
Definition: name.c:36
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by basic_tests(), module_fill_module(), module_is_already_loaded(), and module_is_container_loaded().

◆ get_module_type()

static const char* get_module_type ( enum module_type  type,
BOOL  virtual 
)
static

Definition at line 149 of file module.c.

150 {
151  switch (type)
152  {
153  case DMT_ELF: return virtual ? "Virtual ELF" : "ELF";
154  case DMT_PE: return virtual ? "Virtual PE" : "PE";
155  case DMT_MACHO: return virtual ? "Virtual Mach-O" : "Mach-O";
156  default: return "---";
157  }
158 }
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

Referenced by module_new().

◆ get_wine_loader_name()

const WCHAR* get_wine_loader_name ( void  )

Definition at line 110 of file module.c.

111 {
112  static const BOOL is_win64 = sizeof(void *) > sizeof(int); /* FIXME: should depend on target process */
113  static const WCHAR wineW[] = {'w','i','n','e',0};
114  static const WCHAR suffixW[] = {'6','4',0};
115  static const WCHAR *loader;
116 
117  if (!loader)
118  {
119  WCHAR *p, *buffer;
120  const char *ptr;
121 
122  /* All binaries are loaded with WINELOADER (if run from tree) or by the
123  * main executable
124  */
125  if ((ptr = getenv("WINELOADER")))
126  {
127  DWORD len = 2 + MultiByteToWideChar( CP_UNIXCP, 0, ptr, -1, NULL, 0 );
128  buffer = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
130  }
131  else
132  {
133  buffer = HeapAlloc( GetProcessHeap(), 0, sizeof(wineW) + 2 * sizeof(WCHAR) );
134  strcpyW( buffer, wineW );
135  }
136  p = buffer + strlenW( buffer ) - strlenW( suffixW );
137  if (p > buffer && !strcmpW( p, suffixW ))
138  {
139  if (!is_win64) *p = 0;
140  }
141  else if (is_win64) strcatW( buffer, suffixW );
142 
143  TRACE( "returning %s\n", debugstr_w(buffer) );
144  loader = buffer;
145  }
146  return loader;
147 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
GLuint buffer
Definition: glext.h:5915
static WCHAR wineW[]
Definition: localmon.c:116
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
static PVOID ptr
Definition: dispmode.c:27
static const BOOL is_win64
Definition: shellpath.c:54
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define CP_UNIXCP
Definition: compat.h:69
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
#define MultiByteToWideChar
Definition: compat.h:100
WINE_UNICODE_INLINE int strcmpW(const WCHAR *str1, const WCHAR *str2)
Definition: unicode.h:229
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by module_fill_module(), and module_get_type_by_name().

◆ match_ext()

static int match_ext ( const WCHAR ptr,
size_t  len 
)
static

Definition at line 53 of file module.c.

54 {
55  const WCHAR* const *e;
56  size_t l;
57 
58  for (e = ext; *e; e++)
59  {
60  l = strlenW(*e);
61  if (l >= len) return 0;
62  if (strncmpiW(&ptr[len - l], *e, l)) continue;
63  return l;
64  }
65  return 0;
66 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
#define e
Definition: ke_i.h:82
static PVOID ptr
Definition: dispmode.c:27
r l[0]
Definition: byte_order.h:167
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum GLsizei len
Definition: glext.h:6722
static const WCHAR *const ext[]
Definition: module.c:51

Referenced by module_fill_module().

◆ module_fill_module()

static void module_fill_module ( const WCHAR in,
WCHAR out,
size_t  size 
)
static

Definition at line 80 of file module.c.

81 {
82  const WCHAR *loader = get_wine_loader_name();
83  const WCHAR *ptr, *endptr;
84  size_t len, l;
85 
86  ptr = get_filename(in, endptr = in + strlenW(in));
87  len = min(endptr - ptr, size - 1);
88  memcpy(out, ptr, len * sizeof(WCHAR));
89  out[len] = '\0';
90  if (len > 4 && (l = match_ext(out, len)))
91  out[len - l] = '\0';
92  else if (len > strlenW(loader) && !strcmpiW(out + len - strlenW(loader), loader))
94  else
95  {
96  if (len > 3 && !strcmpiW(&out[len - 3], S_DotSoW) &&
97  (l = match_ext(out, len - 3)))
98  strcpyW(&out[len - l - 3], S_ElfW);
99  }
100  while ((*out = tolowerW(*out))) out++;
101 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
static int match_ext(const WCHAR *ptr, size_t len)
Definition: module.c:53
#define lstrcpynW
Definition: compat.h:397
static PVOID ptr
Definition: dispmode.c:27
static const WCHAR * get_filename(const WCHAR *name, const WCHAR *endptr)
Definition: module.c:68
r l[0]
Definition: byte_order.h:167
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR S_ElfW[]
Definition: module.c:37
static FILE * out
Definition: regtests2xml.c:44
WINE_UNICODE_INLINE WCHAR tolowerW(WCHAR ch)
Definition: unicode.h:135
const WCHAR * get_wine_loader_name(void)
Definition: module.c:110
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
static const WCHAR S_DotSoW[]
Definition: module.c:39
#define strcmpiW(s1, s2)
Definition: unicode.h:39
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
GLuint in
Definition: glext.h:9616
const WCHAR S_WineLoaderW[]
Definition: module.c:38
#define min(a, b)
Definition: monoChain.cc:55

Referenced by EnumerateLoadedModulesW64(), and module_set_module().

◆ module_find_by_addr()

struct module* module_find_by_addr ( const struct process pcs,
DWORD64  addr,
enum module_type  type 
)

Definition at line 399 of file module.c.

401 {
402  struct module* module;
403 
404  if (type == DMT_UNKNOWN)
405  {
406  if ((module = module_find_by_addr(pcs, addr, DMT_PE)) ||
407  (module = module_find_by_addr(pcs, addr, DMT_ELF)) ||
409  return module;
410  }
411  else
412  {
413  for (module = pcs->lmodules; module; module = module->next)
414  {
415  if (type == module->type && addr >= module->module.BaseOfImage &&
417  return module;
418  }
419  }
421  return module;
422 }
struct module * module_find_by_addr(const struct process *pcs, DWORD64 addr, enum module_type type)
Definition: module.c:399
DWORD64 BaseOfImage
Definition: compat.h:719
static HMODULE module
Definition: module.c:32
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
enum module_type type
struct module * lmodules
#define SetLastError(x)
Definition: compat.h:409
GLenum const GLvoid * addr
Definition: glext.h:9621
#define ERROR_MOD_NOT_FOUND
Definition: compat.h:94
IMAGEHLP_MODULEW64 module
struct module * next

Referenced by dwarf2_virtual_unwind(), pdb_virtual_unwind(), sym_enum(), SymAddSymbolW(), SymEnumLines(), SymEnumSourceFilesW(), SymEnumTypes(), SymFromAddr(), SymFunctionTableAccess64(), SymGetLineFromAddr64(), SymGetLineNext64(), SymGetLinePrev64(), SymGetModuleBase64(), SymGetModuleInfoW64(), SymGetTypeFromName(), SymGetTypeInfo(), symt_enum_locals(), SymUnloadModule(), SymUnloadModule64(), and x86_64_fetch_minidump_module().

◆ module_find_by_nameA()

struct module* module_find_by_nameA ( const struct process pcs,
const char name 
)

Definition at line 256 of file module.c.

257 {
258  WCHAR wname[MAX_PATH];
259 
260  MultiByteToWideChar(CP_ACP, 0, name, -1, wname, sizeof(wname) / sizeof(WCHAR));
261  return module_find_by_nameW(pcs, wname);
262 }
struct module * module_find_by_nameW(const struct process *pcs, const WCHAR *name)
Definition: module.c:244
#define CP_ACP
Definition: compat.h:99
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
#define MultiByteToWideChar
Definition: compat.h:100
Definition: name.c:36

Referenced by SymFromName().

◆ module_find_by_nameW()

struct module* module_find_by_nameW ( const struct process pcs,
const WCHAR name 
)

Definition at line 244 of file module.c.

245 {
246  struct module* module;
247 
248  for (module = pcs->lmodules; module; module = module->next)
249  {
250  if (!strcmpiW(name, module->module.ModuleName)) return module;
251  }
253  return NULL;
254 }
WCHAR ModuleName[32]
Definition: compat.h:725
static HMODULE module
Definition: module.c:32
struct module * lmodules
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:409
#define strcmpiW(s1, s2)
Definition: unicode.h:39
Definition: name.c:36
#define ERROR_INVALID_NAME
Definition: compat.h:93
IMAGEHLP_MODULEW64 module
struct module * next

Referenced by module_find_by_nameA(), and SymEnumSourceFilesW().

◆ module_get_containee()

struct module* module_get_containee ( const struct process pcs,
const struct module outter 
)

Definition at line 314 of file module.c.

316 {
317  struct module* module;
318 
319  for (module = pcs->lmodules; module; module = module->next)
320  {
321  if (module != outter &&
323  outter->module.BaseOfImage + outter->module.ImageSize >=
325  return module;
326  }
327  return NULL;
328 }
DWORD64 BaseOfImage
Definition: compat.h:719
static HMODULE module
Definition: module.c:32
struct module * lmodules
smooth NULL
Definition: ftsmooth.c:416
IMAGEHLP_MODULEW64 module
struct module * next

Referenced by sym_enum(), and SymFromName().

◆ module_get_container()

static struct module* module_get_container ( const struct process pcs,
const struct module inner 
)
static

Definition at line 294 of file module.c.

296 {
297  struct module* module;
298 
299  for (module = pcs->lmodules; module; module = module->next)
300  {
301  if (module != inner &&
304  inner->module.BaseOfImage + inner->module.ImageSize)
305  return module;
306  }
307  return NULL;
308 }
DWORD64 BaseOfImage
Definition: compat.h:719
static HMODULE module
Definition: module.c:32
struct module * lmodules
smooth NULL
Definition: ftsmooth.c:416
IMAGEHLP_MODULEW64 module
struct module * next

Referenced by module_get_debug(), and SymGetModuleInfoW64().

◆ module_get_debug()

BOOL module_get_debug ( struct module_pair pair)

Definition at line 340 of file module.c.

341 {
343 
344  if (!pair->requested) return FALSE;
345  /* for a PE builtin, always get info from container */
346  if (!(pair->effective = module_get_container(pair->pcs, pair->requested)))
347  pair->effective = pair->requested;
348  /* if deferred, force loading */
349  if (pair->effective->module.SymType == SymDeferred)
350  {
351  BOOL ret;
352 
353  if (pair->effective->is_virtual) ret = FALSE;
354  else switch (pair->effective->type)
355  {
356 #ifndef DBGHELP_STATIC_LIB
357  case DMT_ELF:
358  ret = elf_load_debug_info(pair->effective);
359  break;
360 #endif
361  case DMT_PE:
362  idslW64.SizeOfStruct = sizeof(idslW64);
363  idslW64.BaseOfImage = pair->effective->module.BaseOfImage;
364  idslW64.CheckSum = pair->effective->module.CheckSum;
365  idslW64.TimeDateStamp = pair->effective->module.TimeDateStamp;
366  memcpy(idslW64.FileName, pair->effective->module.ImageName,
367  sizeof(pair->effective->module.ImageName));
368  idslW64.Reparse = FALSE;
369  idslW64.hFile = INVALID_HANDLE_VALUE;
370 
372  ret = pe_load_debug_info(pair->pcs, pair->effective);
373  pcs_callback(pair->pcs,
375  &idslW64);
376  break;
377 #ifndef DBGHELP_STATIC_LIB
378  case DMT_MACHO:
379  ret = macho_load_debug_info(pair->effective);
380  break;
381 #endif
382  default:
383  ret = FALSE;
384  break;
385  }
386  if (!ret) pair->effective->module.SymType = SymNone;
387  assert(pair->effective->module.SymType != SymDeferred);
388  pair->effective->module.NumSyms = pair->effective->ht_symbols.num_elts;
389  }
390  return pair->effective->module.SymType != SymNone;
391 }
#define CBA_DEFERRED_SYMBOL_LOAD_COMPLETE
Definition: compat.h:626
static struct module * module_get_container(const struct process *pcs, const struct module *inner)
Definition: module.c:294
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define assert(x)
Definition: debug.h:53
WCHAR FileName[MAX_PATH+1]
Definition: compat.h:808
BOOL pcs_callback(const struct process *pcs, ULONG action, void *data)
Definition: dbghelp.c:551
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL pe_load_debug_info(const struct process *pcs, struct module *module) DECLSPEC_HIDDEN
Definition: pe_module.c:746
#define CBA_DEFERRED_SYMBOL_LOAD_FAILURE
Definition: compat.h:627
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define CBA_DEFERRED_SYMBOL_LOAD_START
Definition: compat.h:625
Definition: _pair.h:47
BOOL elf_load_debug_info(struct module *module) DECLSPEC_HIDDEN
Definition: elf_module.c:1835
BOOL macho_load_debug_info(struct module *module) DECLSPEC_HIDDEN

Referenced by dwarf2_virtual_unwind(), find_name(), pdb_virtual_unwind(), sym_enum(), SymAddSymbolW(), SymEnumLines(), SymEnumSourceFilesW(), SymEnumTypes(), SymFromAddr(), SymGetLineFromAddr64(), SymGetLineNext64(), SymGetLinePrev64(), SymGetTypeFromName(), SymGetTypeInfo(), and symt_enum_locals().

◆ module_get_type_by_name()

enum module_type module_get_type_by_name ( const WCHAR name)

Definition at line 465 of file module.c.

466 {
467  int loader_len, len = strlenW(name);
468  const WCHAR *loader;
469 
470  /* Skip all version extensions (.[digits]) regex: "(\.\d+)*$" */
471  do
472  {
473  int i = len;
474 
475  while (i && name[i - 1] >= '0' && name[i - 1] <= '9') i--;
476 
477  if (i && name[i - 1] == '.')
478  len = i - 1;
479  else
480  break;
481  } while (len);
482 
483  /* check for terminating .so or .so.[digit] */
484  /* FIXME: Can't rely solely on extension; have to check magic or
485  * stop using .so on Mac OS X. For now, base on platform. */
486  if (len > 3 && !memcmp(name + len - 3, S_DotSoW, 3))
487 #ifdef __APPLE__
488  return DMT_MACHO;
489 #else
490  return DMT_ELF;
491 #endif
492 
493  if (len > 6 && !strncmpiW(name + len - 6, S_DotDylibW, 6))
494  return DMT_MACHO;
495 
496  if (len > 4 && !strncmpiW(name + len - 4, S_DotPdbW, 4))
497  return DMT_PDB;
498 
499  if (len > 4 && !strncmpiW(name + len - 4, S_DotDbgW, 4))
500  return DMT_DBG;
501 
502  /* wine is also a native module (Mach-O on Mac OS X, ELF elsewhere) */
503  loader = get_wine_loader_name();
504  loader_len = strlenW( loader );
505  if ((len == loader_len || (len > loader_len && name[len - loader_len - 1] == '/')) &&
506  !strcmpiW(name + len - loader_len, loader))
507  {
508 #ifdef __APPLE__
509  return DMT_MACHO;
510 #else
511  return DMT_ELF;
512 #endif
513  }
514  return DMT_PE;
515 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
static const WCHAR S_DotDbgW[]
Definition: module.c:42
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * get_wine_loader_name(void)
Definition: module.c:110
GLenum GLsizei len
Definition: glext.h:6722
static const WCHAR S_DotSoW[]
Definition: module.c:39
static const WCHAR S_DotPdbW[]
Definition: module.c:41
#define strcmpiW(s1, s2)
Definition: unicode.h:39
Definition: name.c:36
static const WCHAR S_DotDylibW[]
Definition: module.c:40

Referenced by path_find_symbol_file(), and SymLoadModuleExW().

◆ module_is_already_loaded()

struct module* module_is_already_loaded ( const struct process pcs,
const WCHAR name 
)

Definition at line 268 of file module.c.

269 {
270  struct module* module;
271  const WCHAR* filename;
272 
273  /* first compare the loaded image name... */
274  for (module = pcs->lmodules; module; module = module->next)
275  {
277  return module;
278  }
279  /* then compare the standard filenames (without the path) ... */
281  for (module = pcs->lmodules; module; module = module->next)
282  {
284  return module;
285  }
287  return NULL;
288 }
static HMODULE module
Definition: module.c:32
const char * filename
Definition: ioapi.h:135
WCHAR LoadedImageName[256]
Definition: compat.h:727
struct module * lmodules
static const WCHAR * get_filename(const WCHAR *name, const WCHAR *endptr)
Definition: module.c:68
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SetLastError(x)
Definition: compat.h:409
#define strcmpiW(s1, s2)
Definition: unicode.h:39
Definition: name.c:36
#define ERROR_INVALID_NAME
Definition: compat.h:93
IMAGEHLP_MODULEW64 module
struct module * next

Referenced by SymLoadModuleExW().

◆ module_is_container_loaded()

static BOOL module_is_container_loaded ( const struct process pcs,
const WCHAR ImageName,
DWORD64  base 
)
static

Definition at line 430 of file module.c.

432 {
433  size_t len;
434  struct module* module;
435  PCWSTR filename, modname;
436 
437  if (!base) return FALSE;
439  len = strlenW(filename);
440 
441  for (module = pcs->lmodules; module; module = module->next)
442  {
443  if ((module->type == DMT_ELF || module->type == DMT_MACHO) &&
446  {
448  if (!strncmpiW(modname, filename, len) &&
449  !memcmp(modname + len, S_DotSoW, 3 * sizeof(WCHAR)))
450  {
451  return TRUE;
452  }
453  }
454  }
455  /* likely a native PE module */
456  WARN("Couldn't find container for %s\n", debugstr_w(ImageName));
457  return FALSE;
458 }
const uint16_t * PCWSTR
Definition: typedefs.h:55
#define TRUE
Definition: types.h:120
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
DWORD64 BaseOfImage
Definition: compat.h:719
#define WARN(fmt,...)
Definition: debug.h:111
static HMODULE module
Definition: module.c:32
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
const char * filename
Definition: ioapi.h:135
enum module_type type
WCHAR LoadedImageName[256]
Definition: compat.h:727
struct module * lmodules
#define debugstr_w
Definition: kernel32.h:32
static const WCHAR * get_filename(const WCHAR *name, const WCHAR *endptr)
Definition: module.c:68
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const char * ImageName
Definition: image.c:34
GLenum GLsizei len
Definition: glext.h:6722
static const WCHAR S_DotSoW[]
Definition: module.c:39
IMAGEHLP_MODULEW64 module
struct module * next

Referenced by SymLoadModuleExW().

◆ module_new()

struct module* module_new ( struct process pcs,
const WCHAR name,
enum module_type  type,
BOOL  virtual,
DWORD64  mod_addr,
DWORD64  size,
unsigned long  stamp,
unsigned long  checksum 
)

Definition at line 163 of file module.c.

167 {
168  struct module* module;
169  unsigned i;
170 
171  assert(type == DMT_ELF || type == DMT_PE || type == DMT_MACHO);
172  if (!(module = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*module))))
173  return NULL;
174 
175  module->next = pcs->lmodules;
176  pcs->lmodules = module;
177 
178  TRACE("=> %s %s-%s %s\n",
179  get_module_type(type, virtual),
180  wine_dbgstr_longlong(mod_addr), wine_dbgstr_longlong(mod_addr + size),
181  debugstr_w(name));
182 
183  pool_init(&module->pool, 65536);
184 
185  module->process = pcs;
186  module->module.SizeOfStruct = sizeof(module->module);
187  module->module.BaseOfImage = mod_addr;
190  module->module.ImageName[0] = '\0';
193  module->module.NumSyms = 0;
194  module->module.TimeDateStamp = stamp;
196 
198  module->module.CVSig = 0;
199  memset(module->module.CVData, 0, sizeof(module->module.CVData));
200  module->module.PdbSig = 0;
202  module->module.PdbAge = 0;
210 
211  module->reloc_delta = 0;
212  module->type = type;
213  module->is_virtual = virtual;
214  for (i = 0; i < DFI_LAST; i++) module->format_info[i] = NULL;
216  module->sorttab_size = 0;
218  module->num_sorttab = 0;
219  module->num_symbols = 0;
220 
221  vector_init(&module->vsymt, sizeof(struct symt*), 128);
222  /* FIXME: this seems a bit too high (on a per module basis)
223  * need some statistics about this
224  */
227 #ifdef __x86_64__
228  hash_table_init(&module->pool, &module->ht_symaddr, 4096);
229 #endif
230  vector_init(&module->vtypes, sizeof(struct symt*), 32);
231 
232  module->sources_used = 0;
233  module->sources_alloc = 0;
234  module->sources = 0;
236 
237  return module;
238 }
unsigned sources_alloc
DWORD64 BaseOfImage
Definition: compat.h:719
unsigned sources_used
struct hash_table ht_symbols
struct vector vsymt
static HMODULE module
Definition: module.c:32
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
struct wine_rb_tree sources_offsets_tree
unsigned num_symbols
char * sources
#define lstrcpynW
Definition: compat.h:397
enum module_type type
WCHAR LoadedImageName[256]
Definition: compat.h:727
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
struct module * lmodules
int sortlist_valid
int source_rb_compare(const void *key, const struct wine_rb_entry *entry) DECLSPEC_HIDDEN
Definition: source.c:41
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
void vector_init(struct vector *v, unsigned elt_sz, unsigned bucket_sz) DECLSPEC_HIDDEN
Definition: storage.c:134
unsigned num_sorttab
static void wine_rb_init(struct wine_rb_tree *tree, wine_rb_compare_func_t compare)
Definition: rbtree.h:179
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
DWORD64 reloc_delta
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
struct vector vtypes
WCHAR ImageName[256]
Definition: compat.h:726
void module_set_module(struct module *module, const WCHAR *name)
Definition: module.c:103
void pool_init(struct pool *a, size_t arena_size) DECLSPEC_HIDDEN
Definition: storage.c:44
static const char * get_module_type(enum module_type type, BOOL virtual)
Definition: module.c:149
DWORD SizeOfStruct
Definition: compat.h:718
SYM_TYPE SymType
Definition: compat.h:724
static cab_ULONG checksum(const cab_UBYTE *data, cab_UWORD bytes, cab_ULONG csum)
Definition: fdi.c:353
struct pool pool
struct process * process
unsigned short is_virtual
DWORD TimeDateStamp
Definition: compat.h:721
struct hash_table ht_types
WCHAR CVData[MAX_PATH *3]
Definition: compat.h:730
unsigned sorttab_size
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
WCHAR LoadedPdbName[256]
Definition: compat.h:728
void hash_table_init(struct pool *pool, struct hash_table *ht, unsigned num_buckets) DECLSPEC_HIDDEN
Definition: storage.c:335
Definition: name.c:36
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41
struct symt_ht ** addr_sorttab
#define memset(x, y, z)
Definition: compat.h:39
struct module_format * format_info[DFI_LAST]
IMAGEHLP_MODULEW64 module
struct module * next

Referenced by pe_load_builtin_module(), pe_load_native_module(), and SymLoadModuleExW().

◆ module_remove()

BOOL module_remove ( struct process pcs,
struct module module 
)

Definition at line 684 of file module.c.

685 {
686  struct module_format*modfmt;
687  struct module** p;
688  unsigned i;
689 
690  TRACE("%s (%p)\n", debugstr_w(module->module.ModuleName), module);
691 
692  for (i = 0; i < DFI_LAST; i++)
693  {
694  if ((modfmt = module->format_info[i]) && modfmt->remove)
695  modfmt->remove(pcs, module->format_info[i]);
696  }
702  /* native dbghelp doesn't invoke registered callback(,CBA_SYMBOLS_UNLOADED,) here
703  * so do we
704  */
705  for (p = &pcs->lmodules; *p; p = &(*p)->next)
706  {
707  if (*p == module)
708  {
709  *p = module->next;
711  return TRUE;
712  }
713  }
714  FIXME("This shouldn't happen\n");
715  return FALSE;
716 }
void(* remove)(struct process *pcs, struct module_format *modfmt)
#define TRUE
Definition: types.h:120
WCHAR ModuleName[32]
Definition: compat.h:725
struct hash_table ht_symbols
char * sources
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
struct module * lmodules
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
struct pool pool
void hash_table_destroy(struct hash_table *ht) DECLSPEC_HIDDEN
Definition: storage.c:343
void pool_destroy(struct pool *a) DECLSPEC_HIDDEN
Definition: storage.c:51
struct hash_table ht_types
struct symt_ht ** addr_sorttab
GLfloat GLfloat p
Definition: glext.h:8902
struct module_format * format_info[DFI_LAST]
IMAGEHLP_MODULEW64 module
struct module * next
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by SymCleanup(), SymUnloadModule(), and SymUnloadModule64().

◆ module_reset_debug_info()

void module_reset_debug_info ( struct module module)

Definition at line 1122 of file module.c.

1123 {
1125  module->sorttab_size = 0;
1129  module->ht_symbols.num_buckets = 0;
1130  module->ht_symbols.buckets = NULL;
1132  module->ht_types.num_buckets = 0;
1133  module->ht_types.buckets = NULL;
1134  module->vtypes.num_elts = 0;
1137  module->sources = NULL;
1138 }
#define TRUE
Definition: types.h:120
unsigned sources_alloc
unsigned sources_used
struct hash_table ht_symbols
unsigned num_symbols
char * sources
int sortlist_valid
smooth NULL
Definition: ftsmooth.c:416
unsigned num_sorttab
struct vector vtypes
void hash_table_destroy(struct hash_table *ht) DECLSPEC_HIDDEN
Definition: storage.c:343
struct hash_table ht_types
unsigned sorttab_size
struct symt_ht ** addr_sorttab

Referenced by stabs_parse().

◆ module_set_module()

void module_set_module ( struct module module,
const WCHAR name 
)

Definition at line 103 of file module.c.

104 {
106  sizeof(module->module.ModuleName) / sizeof(module->module.ModuleName[0]));
108 }
WCHAR ModuleName[32]
Definition: compat.h:725
WCHAR modulename[64]
static void module_fill_module(const WCHAR *in, WCHAR *out, size_t size)
Definition: module.c:80
Definition: name.c:36
IMAGEHLP_MODULEW64 module

Referenced by module_new(), and SymLoadModuleExW().

◆ refresh_module_list()

static BOOL refresh_module_list ( struct process pcs)
static

Definition at line 521 of file module.c.

522 {
523  /* force transparent ELF and Mach-O loading / unloading */
525 }
BOOL elf_synchronize_module_list(struct process *pcs) DECLSPEC_HIDDEN
Definition: elf_module.c:1809
BOOL macho_synchronize_module_list(struct process *pcs) DECLSPEC_HIDDEN

Referenced by SymLoadModuleExW(), and SymRefreshModuleList().

◆ SymEnumerateModules()

BOOL WINAPI SymEnumerateModules ( HANDLE  hProcess,
PSYM_ENUMMODULES_CALLBACK  EnumModulesCallback,
PVOID  UserContext 
)

Definition at line 770 of file module.c.

773 {
774  struct enum_modW64_32 x;
775 
776  x.cb = EnumModulesCallback;
777  x.user = UserContext;
778 
780 }
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
BOOL WINAPI SymEnumerateModulesW64(HANDLE hProcess, PSYM_ENUMMODULES_CALLBACKW64 EnumModulesCallback, PVOID UserContext)
Definition: module.c:817
PSYM_ENUMMODULES_CALLBACK cb
Definition: module.c:757

◆ SymEnumerateModules64()

BOOL WINAPI SymEnumerateModules64 ( HANDLE  hProcess,
PSYM_ENUMMODULES_CALLBACK64  EnumModulesCallback,
PVOID  UserContext 
)

Definition at line 801 of file module.c.

804 {
805  struct enum_modW64_64 x;
806 
807  x.cb = EnumModulesCallback;
808  x.user = UserContext;
809 
811 }
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
BOOL WINAPI SymEnumerateModulesW64(HANDLE hProcess, PSYM_ENUMMODULES_CALLBACKW64 EnumModulesCallback, PVOID UserContext)
Definition: module.c:817
PSYM_ENUMMODULES_CALLBACK64 cb
Definition: module.c:788

◆ SymEnumerateModulesW64()

BOOL WINAPI SymEnumerateModulesW64 ( HANDLE  hProcess,
PSYM_ENUMMODULES_CALLBACKW64  EnumModulesCallback,
PVOID  UserContext 
)

Definition at line 817 of file module.c.

820 {
821  struct process* pcs = process_find_by_handle(hProcess);
822  struct module* module;
823 
824  if (!pcs) return FALSE;
825 
826  for (module = pcs->lmodules; module; module = module->next)
827  {
829  (module->type == DMT_ELF || module->type == DMT_MACHO))
830  continue;
831  if (!EnumModulesCallback(module->modulename,
832  module->module.BaseOfImage, UserContext))
833  break;
834  }
835  return TRUE;
836 }
#define TRUE
Definition: types.h:120
#define SYMOPT_WINE_WITH_NATIVE_MODULES
struct process * process_find_by_handle(HANDLE hProcess)
Definition: dbghelp.c:80
DWORD64 BaseOfImage
Definition: compat.h:719
static HMODULE module
Definition: module.c:32
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
enum module_type type
struct module * lmodules
WCHAR modulename[64]
unsigned dbghelp_options
Definition: dbghelp.c:72
IMAGEHLP_MODULEW64 module
struct module * next

Referenced by SymEnumerateModules(), and SymEnumerateModules64().

◆ SymFunctionTableAccess()

PVOID WINAPI SymFunctionTableAccess ( HANDLE  hProcess,
DWORD  AddrBase 
)

Definition at line 1161 of file module.c.

1162 {
1163  return SymFunctionTableAccess64(hProcess, AddrBase);
1164 }
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
PVOID WINAPI SymFunctionTableAccess64(HANDLE hProcess, DWORD64 AddrBase)
Definition: module.c:1169

Referenced by StackWalk().

◆ SymFunctionTableAccess64()

PVOID WINAPI SymFunctionTableAccess64 ( HANDLE  hProcess,
DWORD64  AddrBase 
)

Definition at line 1169 of file module.c.

1170 {
1171  struct process* pcs = process_find_by_handle(hProcess);
1172  struct module* module;
1173 
1174  if (!pcs || !dbghelp_current_cpu->find_runtime_function) return NULL;
1175  module = module_find_by_addr(pcs, AddrBase, DMT_UNKNOWN);
1176  if (!module) return NULL;
1177 
1178  return dbghelp_current_cpu->find_runtime_function(module, AddrBase);
1179 }
struct process * process_find_by_handle(HANDLE hProcess)
Definition: dbghelp.c:80
struct cpu * dbghelp_current_cpu
Definition: dbghelp.c:150
struct module * module_find_by_addr(const struct process *pcs, DWORD64 addr, enum module_type type)
Definition: module.c:399
static HMODULE module
Definition: module.c:32
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
smooth NULL
Definition: ftsmooth.c:416

Referenced by PrintStackBacktrace(), StackWalk64(), and SymFunctionTableAccess().

◆ SymGetModuleBase()

DWORD WINAPI SymGetModuleBase ( HANDLE  hProcess,
DWORD  dwAddr 
)

Definition at line 1096 of file module.c.

1097 {
1098  DWORD64 ret;
1099 
1100  ret = SymGetModuleBase64(hProcess, dwAddr);
1101  return validate_addr64(ret) ? ret : 0;
1102 }
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
DWORD64 WINAPI SymGetModuleBase64(HANDLE hProcess, DWORD64 dwAddr)
Definition: module.c:1107
int ret
uint64_t DWORD64
Definition: typedefs.h:65
BOOL validate_addr64(DWORD64 addr)
Definition: dbghelp.c:93

Referenced by StackWalk().

◆ SymGetModuleBase64()

DWORD64 WINAPI SymGetModuleBase64 ( HANDLE  hProcess,
DWORD64  dwAddr 
)

Definition at line 1107 of file module.c.

1108 {
1109  struct process* pcs = process_find_by_handle(hProcess);
1110  struct module* module;
1111 
1112  if (!pcs) return 0;
1113  module = module_find_by_addr(pcs, dwAddr, DMT_UNKNOWN);
1114  if (!module) return 0;
1115  return module->module.BaseOfImage;
1116 }
struct process * process_find_by_handle(HANDLE hProcess)
Definition: dbghelp.c:80
struct module * module_find_by_addr(const struct process *pcs, DWORD64 addr, enum module_type type)
Definition: module.c:399
DWORD64 BaseOfImage
Definition: compat.h:719
static HMODULE module
Definition: module.c:32
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
IMAGEHLP_MODULEW64 module

Referenced by PrintStackBacktrace(), StackWalk64(), and SymGetModuleBase().

◆ SymGetModuleInfo()

BOOL WINAPI SymGetModuleInfo ( HANDLE  hProcess,
DWORD  dwAddr,
PIMAGEHLP_MODULE  ModuleInfo 
)

Definition at line 952 of file module.c.

954 {
956  IMAGEHLP_MODULEW64 miw64;
957 
958  if (sizeof(mi) < ModuleInfo->SizeOfStruct) FIXME("Wrong size\n");
959 
960  miw64.SizeOfStruct = sizeof(miw64);
961  if (!SymGetModuleInfoW64(hProcess, dwAddr, &miw64)) return FALSE;
962 
963  mi.SizeOfStruct = ModuleInfo->SizeOfStruct;
964  mi.BaseOfImage = miw64.BaseOfImage;
965  mi.ImageSize = miw64.ImageSize;
966  mi.TimeDateStamp = miw64.TimeDateStamp;
967  mi.CheckSum = miw64.CheckSum;
968  mi.NumSyms = miw64.NumSyms;
969  mi.SymType = miw64.SymType;
970  dbghelp_str_WtoA(miw64.ModuleName, mi.ModuleName, sizeof(mi.ModuleName));
971  dbghelp_str_WtoA(miw64.ImageName, mi.ImageName, sizeof(mi.ImageName));
972  dbghelp_str_WtoA(miw64.LoadedImageName, mi.LoadedImageName, sizeof(mi.LoadedImageName));
973 
974  memcpy(ModuleInfo, &mi, ModuleInfo->SizeOfStruct);
975 
976  return TRUE;
977 }
static void dbghelp_str_WtoA(const WCHAR *src, char *dst, int dst_len)
Definition: module.c:942
#define TRUE
Definition: types.h:120
WCHAR ModuleName[32]
Definition: compat.h:725
DWORD64 BaseOfImage
Definition: compat.h:719
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
static MONITORINFO mi
Definition: win.c:7331
WCHAR LoadedImageName[256]
Definition: compat.h:727
#define FIXME(fmt,...)
Definition: debug.h:110
WCHAR ImageName[256]
Definition: compat.h:726
BOOL WINAPI SymGetModuleInfoW64(HANDLE hProcess, DWORD64 dwAddr, PIMAGEHLP_MODULEW64 ModuleInfo)
Definition: module.c:1063
DWORD SizeOfStruct
Definition: compat.h:718
SYM_TYPE SymType
Definition: compat.h:724
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
DWORD TimeDateStamp
Definition: compat.h:721
DWORD SizeOfStruct
Definition: compat.h:843

◆ SymGetModuleInfo64()

BOOL WINAPI SymGetModuleInfo64 ( HANDLE  hProcess,
DWORD64  dwAddr,
PIMAGEHLP_MODULE64  ModuleInfo 
)

Definition at line 1013 of file module.c.

1015 {
1016  IMAGEHLP_MODULE64 mi64;
1017  IMAGEHLP_MODULEW64 miw64;
1018 
1019  if (sizeof(mi64) < ModuleInfo->SizeOfStruct)
1020  {
1021  SetLastError(ERROR_MOD_NOT_FOUND); /* NOTE: native returns this error */
1022  WARN("Wrong size %u\n", ModuleInfo->SizeOfStruct);
1023  return FALSE;
1024  }
1025 
1026  miw64.SizeOfStruct = sizeof(miw64);
1027  if (!SymGetModuleInfoW64(hProcess, dwAddr, &miw64)) return FALSE;
1028 
1029  mi64.SizeOfStruct = ModuleInfo->SizeOfStruct;
1030  mi64.BaseOfImage = miw64.BaseOfImage;
1031  mi64.ImageSize = miw64.ImageSize;
1032  mi64.TimeDateStamp = miw64.TimeDateStamp;
1033  mi64.CheckSum = miw64.CheckSum;
1034  mi64.NumSyms = miw64.NumSyms;
1035  mi64.SymType = miw64.SymType;
1036  dbghelp_str_WtoA(miw64.ModuleName, mi64.ModuleName, sizeof(mi64.ModuleName));
1037  dbghelp_str_WtoA(miw64.ImageName, mi64.ImageName, sizeof(mi64.ImageName));
1039  dbghelp_str_WtoA(miw64.LoadedPdbName, mi64.LoadedPdbName, sizeof(mi64.LoadedPdbName));
1040 
1041  mi64.CVSig = miw64.CVSig;
1042  dbghelp_str_WtoA(miw64.CVData, mi64.CVData, sizeof(mi64.CVData));
1043  mi64.PdbSig = miw64.PdbSig;
1044  mi64.PdbSig70 = miw64.PdbSig70;
1045  mi64.PdbAge = miw64.PdbAge;
1046  mi64.PdbUnmatched = miw64.PdbUnmatched;
1047  mi64.DbgUnmatched = miw64.DbgUnmatched;
1048  mi64.LineNumbers = miw64.LineNumbers;
1049  mi64.GlobalSymbols = miw64.GlobalSymbols;
1050  mi64.TypeInfo = miw64.TypeInfo;
1051  mi64.SourceIndexed = miw64.SourceIndexed;
1052  mi64.Publics = miw64.Publics;
1053 
1054  memcpy(ModuleInfo, &mi64, ModuleInfo->SizeOfStruct);
1055 
1056  return TRUE;
1057 }
SYM_TYPE SymType
Definition: compat.h:885
static void dbghelp_str_WtoA(const WCHAR *src, char *dst, int dst_len)
Definition: module.c:942
#define TRUE
Definition: types.h:120
WCHAR ModuleName[32]
Definition: compat.h:725
DWORD64 BaseOfImage
Definition: compat.h:719
CHAR LoadedPdbName[256]
Definition: compat.h:889
#define WARN(fmt,...)
Definition: debug.h:111
CHAR ModuleName[32]
Definition: compat.h:886
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
DWORD TimeDateStamp
Definition: compat.h:882
WCHAR LoadedImageName[256]
Definition: compat.h:727
DWORD SizeOfStruct
Definition: compat.h:879
BOOL GlobalSymbols
Definition: compat.h:898
DWORD64 BaseOfImage
Definition: compat.h:880
WCHAR ImageName[256]
Definition: compat.h:726
#define SetLastError(x)
Definition: compat.h:409
BOOL WINAPI SymGetModuleInfoW64(HANDLE hProcess, DWORD64 dwAddr, PIMAGEHLP_MODULEW64 ModuleInfo)
Definition: module.c:1063
DWORD SizeOfStruct
Definition: compat.h:718
SYM_TYPE SymType
Definition: compat.h:724
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
BOOL SourceIndexed
Definition: compat.h:900
CHAR CVData[MAX_PATH *3]
Definition: compat.h:891
DWORD TimeDateStamp
Definition: compat.h:721
WCHAR CVData[MAX_PATH *3]
Definition: compat.h:730
WCHAR LoadedPdbName[256]
Definition: compat.h:728
CHAR ImageName[256]
Definition: compat.h:887
#define ERROR_MOD_NOT_FOUND
Definition: compat.h:94
CHAR LoadedImageName[256]
Definition: compat.h:888

Referenced by can_enumerate(), PrintStackBacktrace(), and supports_rsym().

◆ SymGetModuleInfoW()

BOOL WINAPI SymGetModuleInfoW ( HANDLE  hProcess,
DWORD  dwAddr,
PIMAGEHLP_MODULEW  ModuleInfo 
)

Definition at line 983 of file module.c.

985 {
986  IMAGEHLP_MODULEW64 miw64;
987  IMAGEHLP_MODULEW miw;
988 
989  if (sizeof(miw) < ModuleInfo->SizeOfStruct) FIXME("Wrong size\n");
990 
991  miw64.SizeOfStruct = sizeof(miw64);
992  if (!SymGetModuleInfoW64(hProcess, dwAddr, &miw64)) return FALSE;
993 
994  miw.SizeOfStruct = ModuleInfo->SizeOfStruct;
995  miw.BaseOfImage = miw64.BaseOfImage;
996  miw.ImageSize = miw64.ImageSize;
997  miw.TimeDateStamp = miw64.TimeDateStamp;
998  miw.CheckSum = miw64.CheckSum;
999  miw.NumSyms = miw64.NumSyms;
1000  miw.SymType = miw64.SymType;
1001  strcpyW(miw.ModuleName, miw64.ModuleName);
1002  strcpyW(miw.ImageName, miw64.ImageName);
1004  memcpy(ModuleInfo, &miw, ModuleInfo->SizeOfStruct);
1005 
1006  return TRUE;
1007 }
#define TRUE
Definition: types.h:120
WCHAR ModuleName[32]
Definition: compat.h:725
DWORD64 BaseOfImage
Definition: compat.h:719
DWORD BaseOfImage
Definition: compat.h:857
WCHAR ImageName[256]
Definition: compat.h:864
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
DWORD CheckSum
Definition: compat.h:860
WCHAR LoadedImageName[256]
Definition: compat.h:727
#define FIXME(fmt,...)
Definition: debug.h:110
WCHAR LoadedImageName[256]
Definition: compat.h:865
WCHAR ImageName[256]
Definition: compat.h:726
DWORD SizeOfStruct
Definition: compat.h:856
SYM_TYPE SymType
Definition: compat.h:862
DWORD ImageSize
Definition: compat.h:858
WCHAR ModuleName[32]
Definition: compat.h:863
BOOL WINAPI SymGetModuleInfoW64(HANDLE hProcess, DWORD64 dwAddr, PIMAGEHLP_MODULEW64 ModuleInfo)
Definition: module.c:1063
DWORD SizeOfStruct
Definition: compat.h:718
SYM_TYPE SymType
Definition: compat.h:724
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
DWORD TimeDateStamp
Definition: compat.h:721
DWORD TimeDateStamp
Definition: compat.h:859

◆ SymGetModuleInfoW64()

BOOL WINAPI SymGetModuleInfoW64 ( HANDLE  hProcess,
DWORD64  dwAddr,
PIMAGEHLP_MODULEW64  ModuleInfo 
)

Definition at line 1063 of file module.c.

1065 {
1066  struct process* pcs = process_find_by_handle(hProcess);
1067  struct module* module;
1068  IMAGEHLP_MODULEW64 miw64;
1069 
1070  TRACE("%p %s %p\n", hProcess, wine_dbgstr_longlong(dwAddr), ModuleInfo);
1071 
1072  if (!pcs) return FALSE;
1073  if (ModuleInfo->SizeOfStruct > sizeof(*ModuleInfo)) return FALSE;
1074  module = module_find_by_addr(pcs, dwAddr, DMT_UNKNOWN);
1075  if (!module) return FALSE;
1076 
1077  miw64 = module->module;
1078 
1079  /* update debug information from container if any */
1080  if (module->module.SymType == SymNone)
1081  {
1083  if (module && module->module.SymType != SymNone)
1084  {
1085  miw64.SymType = module->module.SymType;
1086  miw64.NumSyms = module->module.NumSyms;
1087  }
1088  }
1089  memcpy(ModuleInfo, &miw64, ModuleInfo->SizeOfStruct);
1090  return TRUE;
1091 }
#define TRUE
Definition: types.h:120
struct process * process_find_by_handle(HANDLE hProcess)
Definition: dbghelp.c:80
struct module * module_find_by_addr(const struct process *pcs, DWORD64 addr, enum module_type type)
Definition: module.c:399
static struct module * module_get_container(const struct process *pcs, const struct module *inner)
Definition: module.c:294
static HMODULE module
Definition: module.c:32
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
#define TRACE(s)
Definition: solgame.cpp:4
DWORD SizeOfStruct
Definition: compat.h:718
SYM_TYPE SymType
Definition: compat.h:724
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41
IMAGEHLP_MODULEW64 module

Referenced by SymGetModuleInfo(), SymGetModuleInfo64(), and SymGetModuleInfoW().

◆ SymLoadModule()

DWORD WINAPI SymLoadModule ( HANDLE  hProcess,
HANDLE  hFile,
PCSTR  ImageName,
PCSTR  ModuleName,
DWORD  BaseOfDll,
DWORD  SizeOfDll 
)

Definition at line 531 of file module.c.

533 {
534  return SymLoadModuleEx(hProcess, hFile, ImageName, ModuleName, BaseOfDll,
535  SizeOfDll, NULL, 0);
536 }
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char const char * ModuleName
Definition: acpixf.h:1252
smooth NULL
Definition: ftsmooth.c:416
static const char * ImageName
Definition: image.c:34
_In_ HANDLE hFile
Definition: mswsock.h:90
DWORD64 WINAPI SymLoadModuleEx(HANDLE hProcess, HANDLE hFile, PCSTR ImageName, PCSTR ModuleName, DWORD64 BaseOfDll, DWORD DllSize, PMODLOAD_DATA Data, DWORD Flags)
Definition: module.c:541

Referenced by main().

◆ SymLoadModule64()

DWORD64 WINAPI SymLoadModule64 ( HANDLE  hProcess,
HANDLE  hFile,
PCSTR  ImageName,
PCSTR  ModuleName,
DWORD64  BaseOfDll,
DWORD  SizeOfDll 
)

Definition at line 673 of file module.c.

675 {
676  return SymLoadModuleEx(hProcess, hFile, ImageName, ModuleName, BaseOfDll, SizeOfDll,
677  NULL, 0);
678 }
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char const char * ModuleName
Definition: acpixf.h:1252
smooth NULL
Definition: ftsmooth.c:416
static const char * ImageName
Definition: image.c:34
_In_ HANDLE hFile
Definition: mswsock.h:90
DWORD64 WINAPI SymLoadModuleEx(HANDLE hProcess, HANDLE hFile, PCSTR ImageName, PCSTR ModuleName, DWORD64 BaseOfDll, DWORD DllSize, PMODLOAD_DATA Data, DWORD Flags)
Definition: module.c:541

Referenced by LoadModuleWithSymbolsFullPath(), main(), test_SymEnumSymbols(), test_SymFromAddr(), test_SymFromName(), and test_SymRegCallback().

◆ SymLoadModuleEx()

DWORD64 WINAPI SymLoadModuleEx ( HANDLE  hProcess,
HANDLE  hFile,
PCSTR  ImageName,
PCSTR  ModuleName,
DWORD64  BaseOfDll,
DWORD  DllSize,
PMODLOAD_DATA  Data,
DWORD  Flags 
)

Definition at line 541 of file module.c.

544 {
545  PWSTR wImageName, wModuleName;
546  unsigned len;
547  DWORD64 ret;
548 
549  TRACE("(%p %p %s %s %s %08x %p %08x)\n",
551  wine_dbgstr_longlong(BaseOfDll), DllSize, Data, Flags);
552 
553  if (ImageName)
554  {
556  wImageName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
557  MultiByteToWideChar(CP_ACP, 0, ImageName, -1, wImageName, len);
558  }
559  else wImageName = NULL;
560  if (ModuleName)
561  {
563  wModuleName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
564  MultiByteToWideChar(CP_ACP, 0, ModuleName, -1, wModuleName, len);
565  }
566  else wModuleName = NULL;
567 
568  ret = SymLoadModuleExW(hProcess, hFile, wImageName, wModuleName,
569  BaseOfDll, DllSize, Data, Flags);
570  HeapFree(GetProcessHeap(), 0, wImageName);
571  HeapFree(GetProcessHeap(), 0, wModuleName);
572  return ret;
573 }
uint16_t * PWSTR
Definition: typedefs.h:54
#define CP_ACP
Definition: compat.h:99
DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageName, PCWSTR wModuleName, DWORD64 BaseOfDll, DWORD SizeOfDll, PMODLOAD_DATA Data, DWORD Flags)
Definition: module.c:578
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char const char * ModuleName
Definition: acpixf.h:1252
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
int ret
static const char * ImageName
Definition: image.c:34
GLenum GLsizei len
Definition: glext.h:6722
_In_ HANDLE hFile
Definition: mswsock.h:90
uint64_t DWORD64
Definition: typedefs.h:65
#define MultiByteToWideChar
Definition: compat.h:100
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by SymLoadModule(), and SymLoadModule64().

◆ SymLoadModuleExW()

DWORD64 WINAPI SymLoadModuleExW ( HANDLE  hProcess,
HANDLE  hFile,
PCWSTR  wImageName,
PCWSTR  wModuleName,
DWORD64  BaseOfDll,
DWORD  SizeOfDll,
PMODLOAD_DATA  Data,
DWORD  Flags 
)

Definition at line 578 of file module.c.

581 {
582  struct process* pcs;
583  struct module* module = NULL;
584 
585  TRACE("(%p %p %s %s %s %08x %p %08x)\n",
586  hProcess, hFile, debugstr_w(wImageName), debugstr_w(wModuleName),
587  wine_dbgstr_longlong(BaseOfDll), SizeOfDll, Data, Flags);
588 
589  if (Data)
590  FIXME("Unsupported load data parameter %p for %s\n",
591  Data, debugstr_w(wImageName));
592  if (!validate_addr64(BaseOfDll)) return FALSE;
593 
594  if (!(pcs = process_find_by_handle(hProcess))) return FALSE;
595 
596  if (Flags & SLMFLAG_VIRTUAL)
597  {
598  if (!wImageName) return FALSE;
599  module = module_new(pcs, wImageName, module_get_type_by_name(wImageName),
600  TRUE, BaseOfDll, SizeOfDll, 0, 0);
601  if (!module) return FALSE;
602  if (wModuleName) module_set_module(module, wModuleName);
604 
605  return TRUE;
606  }
607  if (Flags & ~(SLMFLAG_VIRTUAL))
608  FIXME("Unsupported Flags %08x for %s\n", Flags, debugstr_w(wImageName));
609 
610 #ifndef DBGHELP_STATIC_LIB
611  refresh_module_list(pcs);
612 #endif
613 
614  /* this is a Wine extension to the API just to redo the synchronisation */
615  if (!wImageName && !hFile) return 0;
616 
617  /* check if the module is already loaded, or if it's a builtin PE module with
618  * an containing ELF module
619  */
620  if (wImageName)
621  {
622  module = module_is_already_loaded(pcs, wImageName);
623  if (!module && module_is_container_loaded(pcs, wImageName, BaseOfDll))
624  {
625  /* force the loading of DLL as builtin */
626  module = pe_load_builtin_module(pcs, wImageName, BaseOfDll, SizeOfDll);
627  }
628  }
629  if (!module)
630  {
631  /* otherwise, try a regular PE module */
632  if (!(module = pe_load_native_module(pcs, wImageName, hFile, BaseOfDll, SizeOfDll)) &&
633  wImageName)
634  {
635  /* and finally an ELF or Mach-O module */
636 #ifndef DBGHELP_STATIC_LIB
637  switch (module_get_type_by_name(wImageName))
638  {
639  case DMT_ELF:
640  module = elf_load_module(pcs, wImageName, BaseOfDll);
641  break;
642  case DMT_MACHO:
643  module = macho_load_module(pcs, wImageName, BaseOfDll);
644  break;
645  default:
646  /* Ignored */
647  break;
648  }
649 #endif
650  }
651  }
652  if (!module)
653  {
654  WARN("Couldn't locate %s\n", debugstr_w(wImageName));
655  return 0;
656  }
657  module->module.NumSyms = module->ht_symbols.num_elts;
658  /* by default module_new fills module.ModuleName from a derivation
659  * of LoadedImageName. Overwrite it, if we have better information
660  */
661  if (wModuleName)
662  module_set_module(module, wModuleName);
663  if (wImageName)
664  lstrcpynW(module->module.ImageName, wImageName,
665  sizeof(module->module.ImageName) / sizeof(WCHAR));
666 
667  return module->module.BaseOfImage;
668 }
struct module * elf_load_module(struct process *pcs, const WCHAR *name, unsigned long) DECLSPEC_HIDDEN
Definition: elf_module.c:1830
#define TRUE
Definition: types.h:120
struct process * process_find_by_handle(HANDLE hProcess)
Definition: dbghelp.c:80
DWORD64 BaseOfImage
Definition: compat.h:719
struct hash_table ht_symbols
#define WARN(fmt,...)
Definition: debug.h:111
struct module * module_new(struct process *pcs, const WCHAR *name, enum module_type type, BOOL virtual, DWORD64 mod_addr, DWORD64 size, unsigned long stamp, unsigned long checksum)
Definition: module.c:163
struct module * module_is_already_loaded(const struct process *pcs, const WCHAR *name)
Definition: module.c:268
#define SLMFLAG_VIRTUAL
Definition: compat.h:675
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
#define lstrcpynW
Definition: compat.h:397
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
enum module_type module_get_type_by_name(const WCHAR *name)
Definition: module.c:465
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
struct module * macho_load_module(struct process *pcs, const WCHAR *name, unsigned long) DECLSPEC_HIDDEN
static BOOL refresh_module_list(struct process *pcs)
Definition: module.c:521
struct module * pe_load_native_module(struct process *pcs, const WCHAR *name, HANDLE hFile, DWORD64 base, DWORD size) DECLSPEC_HIDDEN
Definition: pe_module.c:776
static BOOL module_is_container_loaded(const struct process *pcs, const WCHAR *ImageName, DWORD64 base)
Definition: module.c:430
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR ImageName[256]
Definition: compat.h:726
struct module * pe_load_builtin_module(struct process *pcs, const WCHAR *name, DWORD64 base, DWORD64 size) DECLSPEC_HIDDEN
Definition: pe_module.c:852
void module_set_module(struct module *module, const WCHAR *name)
Definition: module.c:103
SYM_TYPE SymType
Definition: compat.h:724
_In_ HANDLE hFile
Definition: mswsock.h:90
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41
BOOL validate_addr64(DWORD64 addr)
Definition: dbghelp.c:93
IMAGEHLP_MODULEW64 module

Referenced by process_invade_cb(), and SymLoadModuleEx().

◆ SymRefreshModuleList()

BOOL WINAPI SymRefreshModuleList ( HANDLE  hProcess)

Definition at line 1143 of file module.c.

1144 {
1145  struct process* pcs;
1146 
1147  TRACE("(%p)\n", hProcess);
1148 
1149  if (!(pcs = process_find_by_handle(hProcess))) return FALSE;
1150 
1151 #ifndef DBGHELP_STATIC_LIB
1152  return refresh_module_list(pcs);
1153 #else
1154  return TRUE;
1155 #endif
1156 }
#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
static BOOL refresh_module_list(struct process *pcs)
Definition: module.c:521
#define TRACE(s)
Definition: solgame.cpp:4

◆ SymUnloadModule()

BOOL WINAPI SymUnloadModule ( HANDLE  hProcess,
DWORD  BaseOfDll 
)

Definition at line 722 of file module.c.

723 {
724  struct process* pcs;
725  struct module* module;
726 
728  if (!pcs) return FALSE;
729  module = module_find_by_addr(pcs, BaseOfDll, DMT_UNKNOWN);
730  if (!module) return FALSE;
731  return module_remove(pcs, module);
732 }
struct process * process_find_by_handle(HANDLE hProcess)
Definition: dbghelp.c:80
struct module * module_find_by_addr(const struct process *pcs, DWORD64 addr, enum module_type type)
Definition: module.c:399
static HMODULE module
Definition: module.c:32
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
BOOL module_remove(struct process *pcs, struct module *module)
Definition: module.c:684

Referenced by main().

◆ SymUnloadModule64()

BOOL WINAPI SymUnloadModule64 ( HANDLE  hProcess,
DWORD64  BaseOfDll 
)

Definition at line 738 of file module.c.

739 {
740  struct process* pcs;
741  struct module* module;
742 
744  if (!pcs) return FALSE;
745  if (!validate_addr64(BaseOfDll)) return FALSE;
746  module = module_find_by_addr(pcs, BaseOfDll, DMT_UNKNOWN);
747  if (!module) return FALSE;
748  return module_remove(pcs, module);
749 }
struct process * process_find_by_handle(HANDLE hProcess)
Definition: dbghelp.c:80
struct module * module_find_by_addr(const struct process *pcs, DWORD64 addr, enum module_type type)
Definition: module.c:399
static HMODULE module
Definition: module.c:32
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
BOOL module_remove(struct process *pcs, struct module *module)
Definition: module.c:684
BOOL validate_addr64(DWORD64 addr)
Definition: dbghelp.c:93

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( dbghelp  )

Variable Documentation

◆ ext

Definition at line 51 of file module.c.

Referenced by match_ext().

◆ S_AcmW

const WCHAR S_AcmW[] = {'.','a','c','m','\0'}
static

Definition at line 45 of file module.c.

◆ S_DllW

const WCHAR S_DllW[] = {'.','d','l','l','\0'}
static

Definition at line 46 of file module.c.

◆ S_DotDbgW

const WCHAR S_DotDbgW[] = {'.','d','b','g','\0'}
static

Definition at line 42 of file module.c.

Referenced by module_get_type_by_name().

◆ S_DotDylibW

const WCHAR S_DotDylibW[] = {'.','d','y','l','i','b','\0'}
static

Definition at line 40 of file module.c.

Referenced by module_get_type_by_name().

◆ S_DotPdbW

const WCHAR S_DotPdbW[] = {'.','p','d','b','\0'}
static

Definition at line 41 of file module.c.

Referenced by module_get_type_by_name().

◆ S_DotSoW

const WCHAR S_DotSoW[] = {'.','s','o','\0'}
static

◆ S_DrvW

const WCHAR S_DrvW[] = {'.','d','r','v','\0'}
static

Definition at line 47 of file module.c.

◆ S_ElfW

const WCHAR S_ElfW = {'<','e','l','f','>','\0'}

Definition at line 37 of file module.c.

Referenced by module_fill_module().

◆ S_ExeW

const WCHAR S_ExeW[] = {'.','e','x','e','\0'}
static

Definition at line 48 of file module.c.

◆ S_OcxW

const WCHAR S_OcxW[] = {'.','o','c','x','\0'}
static

Definition at line 49 of file module.c.

◆ S_SlashW

const WCHAR S_SlashW = {'/','\0'}

Definition at line 43 of file module.c.

◆ S_VxdW

const WCHAR S_VxdW[] = {'.','v','x','d','\0'}
static

Definition at line 50 of file module.c.

◆ S_WineLoaderW

const WCHAR S_WineLoaderW = {'<','w','i','n','e','-','l','o','a','d','e','r','>','\0'}

Definition at line 38 of file module.c.

Referenced by module_fill_module().