2004-04-06 00:21:27 +02:00
|
|
|
/*
|
|
|
|
* File module.c - module handling for the wine debugger
|
|
|
|
*
|
|
|
|
* Copyright (C) 1993, Eric Youngdale.
|
|
|
|
* 2000-2004, Eric Pouech
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-04-06 00:21:27 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include "dbghelp_private.h"
|
|
|
|
#include "psapi.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "winternl.h"
|
|
|
|
#include "wine/debug.h"
|
2006-05-10 21:35:15 +02:00
|
|
|
#include "winnls.h"
|
2004-04-06 00:21:27 +02:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
|
|
|
|
|
2006-12-14 15:46:48 +01:00
|
|
|
static const char * const ext[] = {".acm", ".dll", ".drv", ".exe", ".ocx", ".vxd", NULL};
|
2005-12-22 11:11:39 +01:00
|
|
|
|
|
|
|
static int match_ext(const char* ptr, size_t len)
|
|
|
|
{
|
2006-12-14 15:46:48 +01:00
|
|
|
const char * const *e;
|
2005-12-22 11:11:39 +01:00
|
|
|
size_t l;
|
|
|
|
|
|
|
|
for (e = ext; *e; e++)
|
|
|
|
{
|
|
|
|
l = strlen(*e);
|
|
|
|
if (l >= len) return FALSE;
|
|
|
|
if (strncasecmp(&ptr[len - l], *e, l)) continue;
|
|
|
|
return l;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void module_fill_module(const char* in, char* out, size_t size)
|
2004-05-18 23:29:09 +02:00
|
|
|
{
|
2005-12-22 11:11:39 +01:00
|
|
|
const char *ptr,*endptr;
|
|
|
|
size_t len, l;
|
2004-05-18 23:29:09 +02:00
|
|
|
|
2005-04-18 17:33:31 +02:00
|
|
|
endptr = in + strlen(in);
|
|
|
|
for (ptr = endptr - 1;
|
|
|
|
ptr >= in && *ptr != '/' && *ptr != '\\';
|
2004-05-18 23:29:09 +02:00
|
|
|
ptr--);
|
2005-04-18 17:33:31 +02:00
|
|
|
ptr++;
|
|
|
|
len = min(endptr-ptr,size-1);
|
|
|
|
memcpy(out, ptr, len);
|
|
|
|
out[len] = '\0';
|
2005-12-22 11:11:39 +01:00
|
|
|
if (len > 4 && (l = match_ext(out, len)))
|
|
|
|
out[len - l] = '\0';
|
|
|
|
else if (len > 12 &&
|
2005-03-01 11:39:49 +01:00
|
|
|
(!strcasecmp(out + len - 12, "wine-pthread") ||
|
|
|
|
!strcasecmp(out + len - 12, "wine-kthread")))
|
2005-12-22 11:11:39 +01:00
|
|
|
lstrcpynA(out, "<wine-loader>", size);
|
2004-05-24 21:08:19 +02:00
|
|
|
else
|
|
|
|
{
|
2005-12-22 11:11:39 +01:00
|
|
|
if (len > 3 && !strcasecmp(&out[len - 3], ".so") &&
|
|
|
|
(l = match_ext(out, len - 3)))
|
|
|
|
strcpy(&out[len - l - 3], "<elf>");
|
2004-05-24 21:08:19 +02:00
|
|
|
}
|
2004-05-18 23:29:09 +02:00
|
|
|
while ((*out = tolower(*out))) out++;
|
|
|
|
}
|
|
|
|
|
2006-02-20 12:16:08 +01:00
|
|
|
static const char* get_module_type(enum module_type type, BOOL virtual)
|
2005-11-29 11:47:40 +01:00
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
2006-02-20 12:16:08 +01:00
|
|
|
case DMT_ELF: return virtual ? "Virtual ELF" : "ELF";
|
|
|
|
case DMT_PE: return virtual ? "Virtual PE" : "PE";
|
2005-11-29 11:47:40 +01:00
|
|
|
default: return "---";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* Creates and links a new module to a process
|
|
|
|
*/
|
|
|
|
struct module* module_new(struct process* pcs, const char* name,
|
2006-02-20 12:16:08 +01:00
|
|
|
enum module_type type, BOOL virtual,
|
2004-04-06 00:21:27 +02:00
|
|
|
unsigned long mod_addr, unsigned long size,
|
|
|
|
unsigned long stamp, unsigned long checksum)
|
|
|
|
{
|
|
|
|
struct module* module;
|
|
|
|
|
2006-02-20 12:16:08 +01:00
|
|
|
assert(type == DMT_ELF || type == DMT_PE);
|
2004-04-06 00:21:27 +02:00
|
|
|
if (!(module = HeapAlloc(GetProcessHeap(), 0, sizeof(*module))))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
memset(module, 0, sizeof(*module));
|
|
|
|
|
|
|
|
module->next = pcs->lmodules;
|
|
|
|
pcs->lmodules = module;
|
|
|
|
|
|
|
|
TRACE("=> %s %08lx-%08lx %s\n",
|
2006-02-20 12:16:08 +01:00
|
|
|
get_module_type(type, virtual), mod_addr, mod_addr + size, name);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
|
|
|
pool_init(&module->pool, 65536);
|
|
|
|
|
|
|
|
module->module.SizeOfStruct = sizeof(module->module);
|
|
|
|
module->module.BaseOfImage = mod_addr;
|
|
|
|
module->module.ImageSize = size;
|
2005-03-29 15:14:08 +02:00
|
|
|
module_fill_module(name, module->module.ModuleName,
|
|
|
|
sizeof(module->module.ModuleName));
|
2004-04-06 00:21:27 +02:00
|
|
|
module->module.ImageName[0] = '\0';
|
2005-03-28 16:17:51 +02:00
|
|
|
lstrcpynA(module->module.LoadedImageName, name, sizeof(module->module.LoadedImageName));
|
2004-04-06 00:21:27 +02:00
|
|
|
module->module.SymType = SymNone;
|
|
|
|
module->module.NumSyms = 0;
|
|
|
|
module->module.TimeDateStamp = stamp;
|
|
|
|
module->module.CheckSum = checksum;
|
|
|
|
|
2006-06-26 21:37:32 +02:00
|
|
|
memset(module->module.LoadedPdbName, 0, sizeof(module->module.CVData));
|
|
|
|
module->module.CVSig = 0;
|
|
|
|
memset(module->module.CVData, 0, sizeof(module->module.CVData));
|
|
|
|
module->module.PdbSig = 0;
|
|
|
|
memset(&module->module.PdbSig70, 0, sizeof(module->module.PdbSig70));
|
|
|
|
module->module.PdbAge = 0;
|
|
|
|
module->module.PdbUnmatched = FALSE;
|
|
|
|
module->module.DbgUnmatched = FALSE;
|
|
|
|
module->module.LineNumbers = FALSE;
|
|
|
|
module->module.GlobalSymbols = FALSE;
|
|
|
|
module->module.TypeInfo = FALSE;
|
2006-11-06 20:05:38 +01:00
|
|
|
module->module.SourceIndexed = FALSE;
|
|
|
|
module->module.Publics = FALSE;
|
2006-06-26 21:37:32 +02:00
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
module->type = type;
|
2006-02-20 12:16:08 +01:00
|
|
|
module->is_virtual = virtual ? TRUE : FALSE;
|
2004-04-06 00:21:27 +02:00
|
|
|
module->sortlist_valid = FALSE;
|
|
|
|
module->addr_sorttab = NULL;
|
|
|
|
/* FIXME: this seems a bit too high (on a per module basis)
|
|
|
|
* need some statistics about this
|
|
|
|
*/
|
|
|
|
hash_table_init(&module->pool, &module->ht_symbols, 4096);
|
|
|
|
hash_table_init(&module->pool, &module->ht_types, 4096);
|
2004-09-27 22:31:42 +02:00
|
|
|
vector_init(&module->vtypes, sizeof(struct symt*), 32);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
|
|
|
module->sources_used = 0;
|
|
|
|
module->sources_alloc = 0;
|
|
|
|
module->sources = 0;
|
|
|
|
|
|
|
|
return module;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* module_find_by_name
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
struct module* module_find_by_name(const struct process* pcs,
|
2004-05-18 23:29:09 +02:00
|
|
|
const char* name, enum module_type type)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
|
|
|
struct module* module;
|
|
|
|
|
|
|
|
if (type == DMT_UNKNOWN)
|
|
|
|
{
|
|
|
|
if ((module = module_find_by_name(pcs, name, DMT_PE)) ||
|
2006-02-20 12:16:08 +01:00
|
|
|
(module = module_find_by_name(pcs, name, DMT_ELF)))
|
2004-04-06 00:21:27 +02:00
|
|
|
return module;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-03-01 11:39:49 +01:00
|
|
|
char modname[MAX_PATH];
|
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
for (module = pcs->lmodules; module; module = module->next)
|
|
|
|
{
|
2005-03-29 15:14:08 +02:00
|
|
|
if (type == module->type &&
|
|
|
|
!strcasecmp(name, module->module.LoadedImageName))
|
2004-04-06 00:21:27 +02:00
|
|
|
return module;
|
|
|
|
}
|
2005-03-01 11:39:49 +01:00
|
|
|
module_fill_module(name, modname, sizeof(modname));
|
2004-04-06 00:21:27 +02:00
|
|
|
for (module = pcs->lmodules; module; module = module->next)
|
|
|
|
{
|
2005-03-29 15:14:08 +02:00
|
|
|
if (type == module->type &&
|
|
|
|
!strcasecmp(modname, module->module.ModuleName))
|
2004-04-06 00:21:27 +02:00
|
|
|
return module;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SetLastError(ERROR_INVALID_NAME);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2004-07-04 02:10:54 +02:00
|
|
|
* module_get_container
|
2004-04-06 00:21:27 +02:00
|
|
|
*
|
|
|
|
*/
|
2004-07-04 02:10:54 +02:00
|
|
|
struct module* module_get_container(const struct process* pcs,
|
|
|
|
const struct module* inner)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
|
|
|
struct module* module;
|
|
|
|
|
|
|
|
for (module = pcs->lmodules; module; module = module->next)
|
|
|
|
{
|
|
|
|
if (module != inner &&
|
|
|
|
module->module.BaseOfImage <= inner->module.BaseOfImage &&
|
|
|
|
module->module.BaseOfImage + module->module.ImageSize >=
|
|
|
|
inner->module.BaseOfImage + inner->module.ImageSize)
|
|
|
|
return module;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-07-04 02:10:54 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* module_get_containee
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
struct module* module_get_containee(const struct process* pcs,
|
|
|
|
const struct module* outter)
|
|
|
|
{
|
|
|
|
struct module* module;
|
|
|
|
|
|
|
|
for (module = pcs->lmodules; module; module = module->next)
|
|
|
|
{
|
|
|
|
if (module != outter &&
|
|
|
|
outter->module.BaseOfImage <= module->module.BaseOfImage &&
|
|
|
|
outter->module.BaseOfImage + outter->module.ImageSize >=
|
|
|
|
module->module.BaseOfImage + module->module.ImageSize)
|
|
|
|
return module;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
/******************************************************************
|
|
|
|
* module_get_debug
|
|
|
|
*
|
|
|
|
* get the debug information from a module:
|
|
|
|
* - if the module's type is deferred, then force loading of debug info (and return
|
|
|
|
* the module itself)
|
|
|
|
* - if the module has no debug info and has an ELF container, then return the ELF
|
|
|
|
* container (and also force the ELF container's debug info loading if deferred)
|
|
|
|
* - otherwise return the module itself if it has some debug info
|
|
|
|
*/
|
2006-11-24 22:17:10 +01:00
|
|
|
BOOL module_get_debug(struct module_pair* pair)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2006-01-23 16:29:21 +01:00
|
|
|
IMAGEHLP_DEFERRED_SYMBOL_LOAD64 idsl64;
|
2004-08-30 21:31:13 +02:00
|
|
|
|
2006-05-07 14:29:49 +02:00
|
|
|
if (!pair->requested) return FALSE;
|
|
|
|
/* for a PE builtin, always get info from container */
|
2006-11-24 22:17:10 +01:00
|
|
|
if (!(pair->effective = module_get_container(pair->pcs, pair->requested)))
|
2006-05-07 14:29:49 +02:00
|
|
|
pair->effective = pair->requested;
|
2004-11-08 21:26:22 +01:00
|
|
|
/* if deferred, force loading */
|
2006-05-07 14:29:49 +02:00
|
|
|
if (pair->effective->module.SymType == SymDeferred)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2004-11-08 21:26:22 +01:00
|
|
|
BOOL ret;
|
2006-02-20 12:16:08 +01:00
|
|
|
|
2006-05-07 14:29:49 +02:00
|
|
|
if (pair->effective->is_virtual) ret = FALSE;
|
|
|
|
else switch (pair->effective->type)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2006-01-23 16:29:21 +01:00
|
|
|
case DMT_ELF:
|
2006-05-07 14:29:49 +02:00
|
|
|
ret = elf_load_debug_info(pair->effective, NULL);
|
2006-01-23 16:29:21 +01:00
|
|
|
break;
|
|
|
|
case DMT_PE:
|
|
|
|
idsl64.SizeOfStruct = sizeof(idsl64);
|
2006-05-07 14:29:49 +02:00
|
|
|
idsl64.BaseOfImage = pair->effective->module.BaseOfImage;
|
|
|
|
idsl64.CheckSum = pair->effective->module.CheckSum;
|
|
|
|
idsl64.TimeDateStamp = pair->effective->module.TimeDateStamp;
|
|
|
|
strcpy(idsl64.FileName, pair->effective->module.ImageName);
|
2006-01-23 16:29:21 +01:00
|
|
|
idsl64.Reparse = FALSE;
|
|
|
|
idsl64.hFile = INVALID_HANDLE_VALUE;
|
|
|
|
|
2006-11-24 22:17:10 +01:00
|
|
|
pcs_callback(pair->pcs, CBA_DEFERRED_SYMBOL_LOAD_START, &idsl64);
|
|
|
|
ret = pe_load_debug_info(pair->pcs, pair->effective);
|
|
|
|
pcs_callback(pair->pcs,
|
2006-01-23 16:29:21 +01:00
|
|
|
ret ? CBA_DEFERRED_SYMBOL_LOAD_COMPLETE : CBA_DEFERRED_SYMBOL_LOAD_FAILURE,
|
|
|
|
&idsl64);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = FALSE;
|
|
|
|
break;
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
2006-05-07 14:29:49 +02:00
|
|
|
if (!ret) pair->effective->module.SymType = SymNone;
|
|
|
|
assert(pair->effective->module.SymType != SymDeferred);
|
2006-12-05 22:13:27 +01:00
|
|
|
pair->effective->module.NumSyms = pair->effective->ht_symbols.num_elts;
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
2006-05-07 14:29:49 +02:00
|
|
|
return pair->effective->module.SymType != SymNone;
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* module_find_by_addr
|
|
|
|
*
|
|
|
|
* either the addr where module is loaded, or any address inside the
|
|
|
|
* module
|
|
|
|
*/
|
|
|
|
struct module* module_find_by_addr(const struct process* pcs, unsigned long addr,
|
2004-05-18 23:29:09 +02:00
|
|
|
enum module_type type)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
|
|
|
struct module* module;
|
|
|
|
|
|
|
|
if (type == DMT_UNKNOWN)
|
|
|
|
{
|
|
|
|
if ((module = module_find_by_addr(pcs, addr, DMT_PE)) ||
|
2006-02-20 12:16:08 +01:00
|
|
|
(module = module_find_by_addr(pcs, addr, DMT_ELF)))
|
2004-04-06 00:21:27 +02:00
|
|
|
return module;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (module = pcs->lmodules; module; module = module->next)
|
|
|
|
{
|
|
|
|
if (type == module->type && addr >= module->module.BaseOfImage &&
|
|
|
|
addr < module->module.BaseOfImage + module->module.ImageSize)
|
|
|
|
return module;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SetLastError(ERROR_INVALID_ADDRESS);
|
|
|
|
return module;
|
|
|
|
}
|
|
|
|
|
2005-03-29 15:14:08 +02:00
|
|
|
static BOOL module_is_elf_container_loaded(struct process* pcs, const char* ImageName,
|
2004-05-24 21:08:19 +02:00
|
|
|
const char* ModuleName)
|
|
|
|
{
|
|
|
|
char buffer[MAX_PATH];
|
|
|
|
size_t len;
|
|
|
|
struct module* module;
|
|
|
|
|
|
|
|
if (!ModuleName)
|
|
|
|
{
|
|
|
|
module_fill_module(ImageName, buffer, sizeof(buffer));
|
|
|
|
ModuleName = buffer;
|
|
|
|
}
|
|
|
|
len = strlen(ModuleName);
|
|
|
|
for (module = pcs->lmodules; module; module = module->next)
|
|
|
|
{
|
|
|
|
if (!strncasecmp(module->module.ModuleName, ModuleName, len) &&
|
|
|
|
module->type == DMT_ELF &&
|
|
|
|
!strcmp(module->module.ModuleName + len, "<elf>"))
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-03-29 15:14:08 +02:00
|
|
|
/******************************************************************
|
|
|
|
* module_get_type_by_name
|
|
|
|
*
|
|
|
|
* Guesses a filename type from its extension
|
|
|
|
*/
|
|
|
|
enum module_type module_get_type_by_name(const char* name)
|
2005-03-01 11:39:49 +01:00
|
|
|
{
|
|
|
|
const char* ptr;
|
|
|
|
int len = strlen(name);
|
|
|
|
|
2005-03-29 15:14:08 +02:00
|
|
|
/* check for terminating .so or .so.[digit] */
|
|
|
|
ptr = strrchr(name, '.');
|
|
|
|
if (ptr)
|
2005-03-01 11:39:49 +01:00
|
|
|
{
|
2005-03-29 15:14:08 +02:00
|
|
|
if (!strcmp(ptr, ".so") ||
|
|
|
|
(isdigit(ptr[1]) && !ptr[2] && ptr >= name + 3 && !memcmp(ptr - 3, ".so", 3)))
|
|
|
|
return DMT_ELF;
|
|
|
|
else if (!strcasecmp(ptr, ".pdb"))
|
|
|
|
return DMT_PDB;
|
2005-03-01 11:39:49 +01:00
|
|
|
}
|
2005-03-29 15:14:08 +02:00
|
|
|
/* wine-[kp]thread is also an ELF module */
|
|
|
|
else if (((len > 12 && name[len - 13] == '/') || len == 12) &&
|
2005-03-01 11:39:49 +01:00
|
|
|
(!strcasecmp(name + len - 12, "wine-pthread") ||
|
|
|
|
!strcasecmp(name + len - 12, "wine-kthread")))
|
2005-03-29 15:14:08 +02:00
|
|
|
{
|
|
|
|
return DMT_ELF;
|
|
|
|
}
|
|
|
|
return DMT_PE;
|
2005-03-01 11:39:49 +01:00
|
|
|
}
|
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SymLoadModule (DBGHELP.@)
|
|
|
|
*/
|
2006-01-23 16:37:48 +01:00
|
|
|
DWORD WINAPI SymLoadModule(HANDLE hProcess, HANDLE hFile, const char* ImageName,
|
|
|
|
const char* ModuleName, DWORD BaseOfDll, DWORD SizeOfDll)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
|
|
|
struct process* pcs;
|
|
|
|
struct module* module = NULL;
|
|
|
|
|
2006-11-29 22:04:27 +01:00
|
|
|
TRACE("(%p %p %s %s %08x %08x)\n",
|
|
|
|
hProcess, hFile, debugstr_a(ImageName), debugstr_a(ModuleName),
|
2004-04-06 00:21:27 +02:00
|
|
|
BaseOfDll, SizeOfDll);
|
|
|
|
|
|
|
|
pcs = process_find_by_handle(hProcess);
|
|
|
|
if (!pcs) return FALSE;
|
|
|
|
|
2004-05-24 21:08:19 +02:00
|
|
|
/* force transparent ELF loading / unloading */
|
|
|
|
elf_synchronize_module_list(pcs);
|
|
|
|
|
|
|
|
/* this is a Wine extension to the API just to redo the synchronisation */
|
|
|
|
if (!ImageName && !hFile) return 0;
|
|
|
|
|
|
|
|
if (module_is_elf_container_loaded(pcs, ImageName, ModuleName))
|
2004-05-18 23:29:09 +02:00
|
|
|
{
|
2004-05-24 21:08:19 +02:00
|
|
|
/* force the loading of DLL as builtin */
|
2005-03-29 15:14:08 +02:00
|
|
|
if ((module = pe_load_module_from_pcs(pcs, ImageName, ModuleName,
|
|
|
|
BaseOfDll, SizeOfDll)))
|
2004-05-24 21:08:19 +02:00
|
|
|
goto done;
|
|
|
|
WARN("Couldn't locate %s\n", ImageName);
|
2004-05-18 23:29:09 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2004-05-24 21:08:19 +02:00
|
|
|
TRACE("Assuming %s as native DLL\n", ImageName);
|
2004-04-06 00:21:27 +02:00
|
|
|
if (!(module = pe_load_module(pcs, ImageName, hFile, BaseOfDll, SizeOfDll)))
|
|
|
|
{
|
2005-03-29 15:14:08 +02:00
|
|
|
if (module_get_type_by_name(ImageName) == DMT_ELF &&
|
2005-03-01 11:39:49 +01:00
|
|
|
(module = elf_load_module(pcs, ImageName, BaseOfDll)))
|
|
|
|
goto done;
|
|
|
|
FIXME("Should have successfully loaded debug information for image %s\n",
|
|
|
|
ImageName);
|
2005-03-29 15:14:08 +02:00
|
|
|
if ((module = pe_load_module_from_pcs(pcs, ImageName, ModuleName,
|
|
|
|
BaseOfDll, SizeOfDll)))
|
2004-04-06 00:21:27 +02:00
|
|
|
goto done;
|
|
|
|
WARN("Couldn't locate %s\n", ImageName);
|
|
|
|
return 0;
|
|
|
|
}
|
2006-12-05 22:13:27 +01:00
|
|
|
module->module.NumSyms = module->ht_symbols.num_elts;
|
2004-04-06 00:21:27 +02:00
|
|
|
done:
|
|
|
|
/* by default pe_load_module fills module.ModuleName from a derivation
|
|
|
|
* of ImageName. Overwrite it, if we have better information
|
|
|
|
*/
|
|
|
|
if (ModuleName)
|
2005-03-28 16:17:51 +02:00
|
|
|
lstrcpynA(module->module.ModuleName, ModuleName, sizeof(module->module.ModuleName));
|
|
|
|
lstrcpynA(module->module.ImageName, ImageName, sizeof(module->module.ImageName));
|
2004-04-06 00:21:27 +02:00
|
|
|
|
|
|
|
return module->module.BaseOfImage;
|
|
|
|
}
|
|
|
|
|
2005-11-29 11:24:46 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* SymLoadModuleEx (DBGHELP.@)
|
|
|
|
*/
|
|
|
|
DWORD64 WINAPI SymLoadModuleEx(HANDLE hProcess, HANDLE hFile, PCSTR ImageName,
|
|
|
|
PCSTR ModuleName, DWORD64 BaseOfDll, DWORD DllSize,
|
|
|
|
PMODLOAD_DATA Data, DWORD Flags)
|
|
|
|
{
|
2006-11-29 22:04:27 +01:00
|
|
|
TRACE("(%p %p %s %s %s %08x %p %08x)\n",
|
|
|
|
hProcess, hFile, debugstr_a(ImageName), debugstr_a(ModuleName),
|
2006-02-20 12:16:08 +01:00
|
|
|
wine_dbgstr_longlong(BaseOfDll), DllSize, Data, Flags);
|
|
|
|
|
2005-11-29 11:47:40 +01:00
|
|
|
if (Data)
|
|
|
|
FIXME("Unsupported load data parameter %p for %s\n", Data, ImageName);
|
|
|
|
if (!validate_addr64(BaseOfDll)) return FALSE;
|
|
|
|
if (Flags & SLMFLAG_VIRTUAL)
|
2005-11-29 11:24:46 +01:00
|
|
|
{
|
2005-11-29 11:47:40 +01:00
|
|
|
struct process* pcs = process_find_by_handle(hProcess);
|
|
|
|
struct module* module;
|
|
|
|
if (!pcs) return FALSE;
|
|
|
|
|
2006-02-20 12:16:08 +01:00
|
|
|
module = module_new(pcs, ImageName, module_get_type_by_name(ImageName), TRUE,
|
|
|
|
(DWORD)BaseOfDll, DllSize, 0, 0);
|
2005-11-29 11:47:40 +01:00
|
|
|
if (!module) return FALSE;
|
|
|
|
if (ModuleName)
|
|
|
|
lstrcpynA(module->module.ModuleName, ModuleName, sizeof(module->module.ModuleName));
|
2006-01-23 16:38:57 +01:00
|
|
|
module->module.SymType = SymVirtual;
|
2005-11-29 11:47:40 +01:00
|
|
|
|
|
|
|
return TRUE;
|
2005-11-29 11:24:46 +01:00
|
|
|
}
|
2005-11-29 11:47:40 +01:00
|
|
|
if (Flags & ~(SLMFLAG_VIRTUAL))
|
2006-11-29 22:04:27 +01:00
|
|
|
FIXME("Unsupported Flags %08x for %s\n", Flags, ImageName);
|
2005-11-29 11:47:40 +01:00
|
|
|
|
2006-09-06 18:55:40 +02:00
|
|
|
return SymLoadModule(hProcess, hFile, ImageName, ModuleName, (DWORD)BaseOfDll, DllSize);
|
2005-11-29 11:24:46 +01:00
|
|
|
}
|
|
|
|
|
2006-05-10 21:35:15 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SymLoadModuleExW (DBGHELP.@)
|
|
|
|
*/
|
|
|
|
DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageName,
|
|
|
|
PCWSTR wModuleName, DWORD64 BaseOfDll, DWORD DllSize,
|
|
|
|
PMODLOAD_DATA Data, DWORD Flags)
|
|
|
|
{
|
|
|
|
LPSTR ImageName, ModuleName;
|
|
|
|
unsigned len;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
if (wImageName)
|
|
|
|
{
|
|
|
|
len = WideCharToMultiByte(CP_ACP,0, wImageName, -1, NULL, 0, NULL, NULL);
|
|
|
|
ImageName = HeapAlloc(GetProcessHeap(), 0, len);
|
|
|
|
WideCharToMultiByte(CP_ACP,0, wImageName, -1, ImageName, len, NULL, NULL);
|
|
|
|
}
|
|
|
|
else ImageName = NULL;
|
|
|
|
if (wModuleName)
|
|
|
|
{
|
|
|
|
len = WideCharToMultiByte(CP_ACP,0, wModuleName, -1, NULL, 0, NULL, NULL);
|
|
|
|
ModuleName = HeapAlloc(GetProcessHeap(), 0, len);
|
|
|
|
WideCharToMultiByte(CP_ACP,0, wModuleName, -1, ModuleName, len, NULL, NULL);
|
|
|
|
}
|
|
|
|
else ModuleName = NULL;
|
|
|
|
|
|
|
|
ret = SymLoadModuleEx(hProcess, hFile, ImageName, ModuleName,
|
|
|
|
BaseOfDll, DllSize, Data, Flags);
|
|
|
|
HeapFree(GetProcessHeap(), 0, ImageName);
|
|
|
|
HeapFree(GetProcessHeap(), 0, ModuleName);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-05-29 22:02:42 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* SymLoadModule64 (DBGHELP.@)
|
|
|
|
*/
|
2006-01-23 16:37:48 +01:00
|
|
|
DWORD64 WINAPI SymLoadModule64(HANDLE hProcess, HANDLE hFile, PCSTR ImageName,
|
|
|
|
PCSTR ModuleName, DWORD64 BaseOfDll, DWORD SizeOfDll)
|
2005-05-29 22:02:42 +02:00
|
|
|
{
|
2005-11-29 11:45:16 +01:00
|
|
|
if (!validate_addr64(BaseOfDll)) return FALSE;
|
2005-05-29 22:02:42 +02:00
|
|
|
return SymLoadModule(hProcess, hFile, ImageName, ModuleName, (DWORD)BaseOfDll, SizeOfDll);
|
|
|
|
}
|
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
/******************************************************************
|
|
|
|
* module_remove
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL module_remove(struct process* pcs, struct module* module)
|
|
|
|
{
|
|
|
|
struct module** p;
|
|
|
|
|
|
|
|
TRACE("%s (%p)\n", module->module.ModuleName, module);
|
|
|
|
hash_table_destroy(&module->ht_symbols);
|
|
|
|
hash_table_destroy(&module->ht_types);
|
|
|
|
HeapFree(GetProcessHeap(), 0, (char*)module->sources);
|
|
|
|
HeapFree(GetProcessHeap(), 0, module->addr_sorttab);
|
2006-11-24 22:17:26 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, module->dwarf2_info);
|
2004-04-06 00:21:27 +02:00
|
|
|
pool_destroy(&module->pool);
|
2006-05-10 21:35:47 +02:00
|
|
|
/* native dbghelp doesn't invoke registered callback(,CBA_SYMBOLS_UNLOADED,) here
|
|
|
|
* so do we
|
|
|
|
*/
|
2004-04-06 00:21:27 +02:00
|
|
|
for (p = &pcs->lmodules; *p; p = &(*p)->next)
|
|
|
|
{
|
|
|
|
if (*p == module)
|
|
|
|
{
|
|
|
|
*p = module->next;
|
|
|
|
HeapFree(GetProcessHeap(), 0, module);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FIXME("This shouldn't happen\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* SymUnloadModule (DBGHELP.@)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SymUnloadModule(HANDLE hProcess, DWORD BaseOfDll)
|
|
|
|
{
|
|
|
|
struct process* pcs;
|
|
|
|
struct module* module;
|
|
|
|
|
|
|
|
pcs = process_find_by_handle(hProcess);
|
|
|
|
if (!pcs) return FALSE;
|
|
|
|
module = module_find_by_addr(pcs, BaseOfDll, DMT_UNKNOWN);
|
|
|
|
if (!module) return FALSE;
|
|
|
|
return module_remove(pcs, module);
|
|
|
|
}
|
|
|
|
|
2005-11-29 11:35:10 +01:00
|
|
|
/******************************************************************
|
|
|
|
* SymUnloadModule64 (DBGHELP.@)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SymUnloadModule64(HANDLE hProcess, DWORD64 BaseOfDll)
|
|
|
|
{
|
|
|
|
struct process* pcs;
|
|
|
|
struct module* module;
|
|
|
|
|
|
|
|
pcs = process_find_by_handle(hProcess);
|
|
|
|
if (!pcs) return FALSE;
|
|
|
|
if (!validate_addr64(BaseOfDll)) return FALSE;
|
|
|
|
module = module_find_by_addr(pcs, (DWORD)BaseOfDll, DMT_UNKNOWN);
|
|
|
|
if (!module) return FALSE;
|
|
|
|
return module_remove(pcs, module);
|
|
|
|
}
|
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
/******************************************************************
|
|
|
|
* SymEnumerateModules (DBGHELP.@)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SymEnumerateModules(HANDLE hProcess,
|
|
|
|
PSYM_ENUMMODULES_CALLBACK EnumModulesCallback,
|
|
|
|
PVOID UserContext)
|
|
|
|
{
|
|
|
|
struct process* pcs = process_find_by_handle(hProcess);
|
|
|
|
struct module* module;
|
|
|
|
|
|
|
|
if (!pcs) return FALSE;
|
|
|
|
|
|
|
|
for (module = pcs->lmodules; module; module = module->next)
|
|
|
|
{
|
2005-11-29 11:47:40 +01:00
|
|
|
if (!(dbghelp_options & SYMOPT_WINE_WITH_ELF_MODULES) && module->type == DMT_ELF)
|
2004-05-18 23:29:09 +02:00
|
|
|
continue;
|
2004-04-06 00:21:27 +02:00
|
|
|
if (!EnumModulesCallback(module->module.ModuleName,
|
|
|
|
module->module.BaseOfImage, UserContext))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-06-26 21:37:36 +02:00
|
|
|
/******************************************************************
|
|
|
|
* SymEnumerateModules64 (DBGHELP.@)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SymEnumerateModules64(HANDLE hProcess,
|
|
|
|
PSYM_ENUMMODULES_CALLBACK64 EnumModulesCallback,
|
|
|
|
PVOID UserContext)
|
|
|
|
{
|
|
|
|
struct process* pcs = process_find_by_handle(hProcess);
|
|
|
|
struct module* module;
|
|
|
|
|
|
|
|
if (!pcs) return FALSE;
|
|
|
|
|
|
|
|
for (module = pcs->lmodules; module; module = module->next)
|
|
|
|
{
|
|
|
|
if (!(dbghelp_options & SYMOPT_WINE_WITH_ELF_MODULES) && module->type == DMT_ELF)
|
|
|
|
continue;
|
|
|
|
if (!EnumModulesCallback(module->module.ModuleName,
|
|
|
|
module->module.BaseOfImage, UserContext))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
/******************************************************************
|
|
|
|
* EnumerateLoadedModules (DBGHELP.@)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI EnumerateLoadedModules(HANDLE hProcess,
|
|
|
|
PENUMLOADED_MODULES_CALLBACK EnumLoadedModulesCallback,
|
|
|
|
PVOID UserContext)
|
|
|
|
{
|
|
|
|
HMODULE* hMods;
|
2004-05-18 23:29:09 +02:00
|
|
|
char base[256], mod[256];
|
2004-04-06 00:21:27 +02:00
|
|
|
DWORD i, sz;
|
|
|
|
MODULEINFO mi;
|
|
|
|
|
2005-03-01 11:39:49 +01:00
|
|
|
hMods = HeapAlloc(GetProcessHeap(), 0, 256 * sizeof(hMods[0]));
|
2004-04-06 00:21:27 +02:00
|
|
|
if (!hMods) return FALSE;
|
|
|
|
|
|
|
|
if (!EnumProcessModules(hProcess, hMods, 256 * sizeof(hMods[0]), &sz))
|
|
|
|
{
|
|
|
|
/* hProcess should also be a valid process handle !! */
|
|
|
|
FIXME("If this happens, bump the number in mod\n");
|
|
|
|
HeapFree(GetProcessHeap(), 0, hMods);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
sz /= sizeof(HMODULE);
|
|
|
|
for (i = 0; i < sz; i++)
|
|
|
|
{
|
|
|
|
if (!GetModuleInformation(hProcess, hMods[i], &mi, sizeof(mi)) ||
|
2004-05-18 23:29:09 +02:00
|
|
|
!GetModuleBaseNameA(hProcess, hMods[i], base, sizeof(base)))
|
|
|
|
continue;
|
|
|
|
module_fill_module(base, mod, sizeof(mod));
|
2004-04-06 00:21:27 +02:00
|
|
|
EnumLoadedModulesCallback(mod, (DWORD)mi.lpBaseOfDll, mi.SizeOfImage,
|
|
|
|
UserContext);
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, hMods);
|
|
|
|
|
|
|
|
return sz != 0 && i == sz;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* SymGetModuleInfo (DBGHELP.@)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SymGetModuleInfo(HANDLE hProcess, DWORD dwAddr,
|
|
|
|
PIMAGEHLP_MODULE ModuleInfo)
|
|
|
|
{
|
|
|
|
struct process* pcs = process_find_by_handle(hProcess);
|
|
|
|
struct module* module;
|
2006-06-26 21:37:32 +02:00
|
|
|
IMAGEHLP_MODULE mod;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
|
|
|
if (!pcs) return FALSE;
|
|
|
|
if (ModuleInfo->SizeOfStruct < sizeof(*ModuleInfo)) return FALSE;
|
|
|
|
module = module_find_by_addr(pcs, dwAddr, DMT_UNKNOWN);
|
|
|
|
if (!module) return FALSE;
|
|
|
|
|
2006-06-26 21:37:32 +02:00
|
|
|
mod.SizeOfStruct = ModuleInfo->SizeOfStruct;
|
|
|
|
mod.BaseOfImage = module->module.BaseOfImage;
|
|
|
|
mod.ImageSize = module->module.ImageSize;
|
|
|
|
mod.TimeDateStamp = module->module.TimeDateStamp;
|
|
|
|
mod.CheckSum = module->module.CheckSum;
|
|
|
|
mod.NumSyms = module->module.NumSyms;
|
|
|
|
mod.SymType = module->module.SymType;
|
|
|
|
strcpy(mod.ModuleName, module->module.ModuleName);
|
|
|
|
strcpy(mod.ImageName, module->module.ImageName);
|
|
|
|
strcpy(mod.LoadedImageName, module->module.LoadedImageName);
|
|
|
|
|
2004-08-30 21:31:13 +02:00
|
|
|
if (module->module.SymType == SymNone)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
|
|
|
module = module_get_container(pcs, module);
|
2004-08-30 21:31:13 +02:00
|
|
|
if (module && module->module.SymType != SymNone)
|
2006-01-23 16:38:57 +01:00
|
|
|
{
|
2006-06-26 21:37:32 +02:00
|
|
|
mod.SymType = module->module.SymType;
|
|
|
|
mod.NumSyms = module->module.NumSyms;
|
2006-01-23 16:38:57 +01:00
|
|
|
}
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
2006-06-26 21:37:32 +02:00
|
|
|
memcpy(ModuleInfo, &mod, ModuleInfo->SizeOfStruct);
|
2004-04-06 00:21:27 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-05-10 21:35:18 +02:00
|
|
|
/******************************************************************
|
|
|
|
* SymGetModuleInfoW (DBGHELP.@)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SymGetModuleInfoW(HANDLE hProcess, DWORD dwAddr,
|
|
|
|
PIMAGEHLP_MODULEW ModuleInfo)
|
|
|
|
{
|
|
|
|
IMAGEHLP_MODULE mi;
|
|
|
|
IMAGEHLP_MODULEW miw;
|
|
|
|
|
|
|
|
if (sizeof(miw) < ModuleInfo->SizeOfStruct) FIXME("Wrong size\n");
|
|
|
|
|
|
|
|
mi.SizeOfStruct = sizeof(mi);
|
|
|
|
if (!SymGetModuleInfo(hProcess, dwAddr, &mi)) return FALSE;
|
|
|
|
|
|
|
|
miw.SizeOfStruct = mi.SizeOfStruct;
|
|
|
|
miw.BaseOfImage = mi.BaseOfImage;
|
|
|
|
miw.ImageSize = mi.ImageSize;
|
|
|
|
miw.TimeDateStamp = mi.TimeDateStamp;
|
|
|
|
miw.CheckSum = mi.CheckSum;
|
|
|
|
miw.NumSyms = mi.NumSyms;
|
|
|
|
miw.SymType = mi.SymType;
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, mi.ModuleName, -1,
|
|
|
|
miw.ModuleName, sizeof(miw.ModuleName) / sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, mi.ImageName, -1,
|
|
|
|
miw.ImageName, sizeof(miw.ImageName) / sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, mi.LoadedImageName, -1,
|
|
|
|
miw.LoadedImageName, sizeof(miw.LoadedImageName) / sizeof(WCHAR));
|
|
|
|
memcpy(ModuleInfo, &miw, ModuleInfo->SizeOfStruct);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-11-29 11:42:13 +01:00
|
|
|
/******************************************************************
|
|
|
|
* SymGetModuleInfo64 (DBGHELP.@)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SymGetModuleInfo64(HANDLE hProcess, DWORD64 dwAddr,
|
|
|
|
PIMAGEHLP_MODULE64 ModuleInfo)
|
|
|
|
{
|
|
|
|
struct process* pcs = process_find_by_handle(hProcess);
|
|
|
|
struct module* module;
|
|
|
|
|
|
|
|
TRACE("%p %s %p\n", hProcess, wine_dbgstr_longlong(dwAddr), ModuleInfo);
|
|
|
|
|
|
|
|
if (!pcs) return FALSE;
|
|
|
|
if (ModuleInfo->SizeOfStruct > sizeof(*ModuleInfo)) return FALSE;
|
|
|
|
module = module_find_by_addr(pcs, dwAddr, DMT_UNKNOWN);
|
|
|
|
if (!module) return FALSE;
|
|
|
|
|
2006-06-26 21:37:32 +02:00
|
|
|
memcpy(ModuleInfo, &module->module, ModuleInfo->SizeOfStruct);
|
2005-11-29 11:42:13 +01:00
|
|
|
|
|
|
|
if (module->module.SymType == SymNone)
|
|
|
|
{
|
|
|
|
module = module_get_container(pcs, module);
|
|
|
|
if (module && module->module.SymType != SymNone)
|
2006-01-23 16:38:57 +01:00
|
|
|
{
|
2006-06-26 21:37:32 +02:00
|
|
|
ModuleInfo->SymType = module->module.SymType;
|
|
|
|
ModuleInfo->NumSyms = module->module.NumSyms;
|
2006-01-23 16:38:57 +01:00
|
|
|
}
|
2005-11-29 11:42:13 +01:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-05-10 21:35:18 +02:00
|
|
|
/******************************************************************
|
|
|
|
* SymGetModuleInfoW64 (DBGHELP.@)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SymGetModuleInfoW64(HANDLE hProcess, DWORD64 dwAddr,
|
|
|
|
PIMAGEHLP_MODULEW64 ModuleInfo)
|
|
|
|
{
|
|
|
|
IMAGEHLP_MODULE64 mi;
|
|
|
|
IMAGEHLP_MODULEW64 miw;
|
|
|
|
|
|
|
|
if (sizeof(miw) < ModuleInfo->SizeOfStruct) FIXME("Wrong size\n");
|
|
|
|
|
|
|
|
mi.SizeOfStruct = sizeof(mi);
|
|
|
|
if (!SymGetModuleInfo64(hProcess, dwAddr, &mi)) return FALSE;
|
|
|
|
|
|
|
|
miw.SizeOfStruct = mi.SizeOfStruct;
|
|
|
|
miw.BaseOfImage = mi.BaseOfImage;
|
|
|
|
miw.ImageSize = mi.ImageSize;
|
|
|
|
miw.TimeDateStamp = mi.TimeDateStamp;
|
|
|
|
miw.CheckSum = mi.CheckSum;
|
|
|
|
miw.NumSyms = mi.NumSyms;
|
|
|
|
miw.SymType = mi.SymType;
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, mi.ModuleName, -1,
|
|
|
|
miw.ModuleName, sizeof(miw.ModuleName) / sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, mi.ImageName, -1,
|
|
|
|
miw.ImageName, sizeof(miw.ImageName) / sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, mi.LoadedImageName, -1,
|
|
|
|
miw.LoadedImageName, sizeof(miw.LoadedImageName) / sizeof(WCHAR));
|
2006-06-26 21:37:32 +02:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, mi.LoadedPdbName, -1,
|
|
|
|
miw.LoadedPdbName, sizeof(miw.LoadedPdbName) / sizeof(WCHAR));
|
2006-05-10 21:35:18 +02:00
|
|
|
|
|
|
|
miw.CVSig = mi.CVSig;
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, mi.CVData, -1,
|
|
|
|
miw.CVData, sizeof(miw.CVData) / sizeof(WCHAR));
|
|
|
|
miw.PdbSig = mi.PdbSig;
|
|
|
|
miw.PdbSig70 = mi.PdbSig70;
|
|
|
|
miw.PdbAge = mi.PdbAge;
|
|
|
|
miw.PdbUnmatched = mi.PdbUnmatched;
|
|
|
|
miw.DbgUnmatched = mi.DbgUnmatched;
|
|
|
|
miw.LineNumbers = mi.LineNumbers;
|
|
|
|
miw.GlobalSymbols = mi.GlobalSymbols;
|
|
|
|
miw.TypeInfo = mi.TypeInfo;
|
|
|
|
miw.SourceIndexed = mi.SourceIndexed;
|
|
|
|
miw.Publics = mi.Publics;
|
|
|
|
|
|
|
|
memcpy(ModuleInfo, &miw, ModuleInfo->SizeOfStruct);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
/***********************************************************************
|
2006-01-05 13:41:25 +01:00
|
|
|
* SymGetModuleBase (DBGHELP.@)
|
2004-04-06 00:21:27 +02:00
|
|
|
*/
|
|
|
|
DWORD WINAPI SymGetModuleBase(HANDLE hProcess, DWORD dwAddr)
|
|
|
|
{
|
|
|
|
struct process* pcs = process_find_by_handle(hProcess);
|
|
|
|
struct module* module;
|
|
|
|
|
|
|
|
if (!pcs) return 0;
|
|
|
|
module = module_find_by_addr(pcs, dwAddr, DMT_UNKNOWN);
|
|
|
|
if (!module) return 0;
|
|
|
|
return module->module.BaseOfImage;
|
|
|
|
}
|
2004-07-04 02:10:54 +02:00
|
|
|
|
2006-01-05 13:41:25 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* SymGetModuleBase64 (DBGHELP.@)
|
|
|
|
*/
|
|
|
|
DWORD64 WINAPI SymGetModuleBase64(HANDLE hProcess, DWORD64 dwAddr)
|
|
|
|
{
|
|
|
|
if (!validate_addr64(dwAddr)) return 0;
|
|
|
|
return SymGetModuleBase(hProcess, (DWORD)dwAddr);
|
|
|
|
}
|
|
|
|
|
2004-07-04 02:10:54 +02:00
|
|
|
/******************************************************************
|
|
|
|
* module_reset_debug_info
|
|
|
|
* Removes any debug information linked to a given module.
|
|
|
|
*/
|
|
|
|
void module_reset_debug_info(struct module* module)
|
|
|
|
{
|
|
|
|
module->sortlist_valid = TRUE;
|
|
|
|
module->addr_sorttab = NULL;
|
|
|
|
hash_table_destroy(&module->ht_symbols);
|
|
|
|
module->ht_symbols.num_buckets = 0;
|
|
|
|
module->ht_symbols.buckets = NULL;
|
|
|
|
hash_table_destroy(&module->ht_types);
|
|
|
|
module->ht_types.num_buckets = 0;
|
|
|
|
module->ht_types.buckets = NULL;
|
2004-09-27 22:31:42 +02:00
|
|
|
module->vtypes.num_elts = 0;
|
2004-07-04 02:10:54 +02:00
|
|
|
hash_table_destroy(&module->ht_symbols);
|
|
|
|
module->sources_used = module->sources_alloc = 0;
|
|
|
|
module->sources = NULL;
|
|
|
|
}
|