dbghelp: Symbol info.
- better coding for SYMBOL_INFO filling - some fixes on some fields (parameters) - now using the max size for symbol info
This commit is contained in:
parent
9d0b5f5372
commit
3792b1add3
|
@ -448,13 +448,16 @@ static void symt_fill_sym_info(const struct module* module,
|
||||||
if (!symt_get_info(sym, TI_GET_TYPE, &sym_info->TypeIndex))
|
if (!symt_get_info(sym, TI_GET_TYPE, &sym_info->TypeIndex))
|
||||||
sym_info->TypeIndex = 0;
|
sym_info->TypeIndex = 0;
|
||||||
sym_info->info = (DWORD)sym;
|
sym_info->info = (DWORD)sym;
|
||||||
|
sym_info->Reserved[0] = sym_info->Reserved[1] = 0;
|
||||||
if (!symt_get_info(sym, TI_GET_LENGTH, &size) &&
|
if (!symt_get_info(sym, TI_GET_LENGTH, &size) &&
|
||||||
sym_info->TypeIndex &&
|
(!sym_info->TypeIndex ||
|
||||||
!symt_get_info((struct symt*)sym_info->TypeIndex, TI_GET_LENGTH, &size))
|
!symt_get_info((struct symt*)sym_info->TypeIndex, TI_GET_LENGTH, &size)))
|
||||||
size = 0;
|
size = 0;
|
||||||
sym_info->Size = (DWORD)size;
|
sym_info->Size = (DWORD)size;
|
||||||
sym_info->ModBase = module->module.BaseOfImage;
|
sym_info->ModBase = module->module.BaseOfImage;
|
||||||
sym_info->Flags = 0;
|
sym_info->Flags = 0;
|
||||||
|
sym_info->Value = 0;
|
||||||
|
|
||||||
switch (sym->tag)
|
switch (sym->tag)
|
||||||
{
|
{
|
||||||
case SymTagData:
|
case SymTagData:
|
||||||
|
@ -472,10 +475,9 @@ static void symt_fill_sym_info(const struct module* module,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (data->u.s.offset < 0)
|
sym_info->Flags |= SYMFLAG_LOCAL | SYMFLAG_REGREL;
|
||||||
sym_info->Flags |= SYMFLAG_LOCAL | SYMFLAG_FRAMEREL;
|
/* FIXME: this is i386 dependent */
|
||||||
else
|
if (data->u.s.offset >= 0) sym_info->Flags |= SYMFLAG_PARAMETER;
|
||||||
sym_info->Flags |= SYMFLAG_LOCAL | SYMFLAG_PARAMETER | SYMFLAG_FRAMEREL;
|
|
||||||
/* FIXME: needed ? moreover, it's i386 dependent !!! */
|
/* FIXME: needed ? moreover, it's i386 dependent !!! */
|
||||||
sym_info->Register = CV_REG_EBP;
|
sym_info->Register = CV_REG_EBP;
|
||||||
sym_info->Address = data->u.s.offset / 8;
|
sym_info->Address = data->u.s.offset / 8;
|
||||||
|
@ -544,7 +546,7 @@ static void symt_fill_sym_info(const struct module* module,
|
||||||
static BOOL symt_enum_module(struct module* module, regex_t* regex,
|
static BOOL symt_enum_module(struct module* module, regex_t* regex,
|
||||||
PSYM_ENUMERATESYMBOLS_CALLBACK cb, PVOID user)
|
PSYM_ENUMERATESYMBOLS_CALLBACK cb, PVOID user)
|
||||||
{
|
{
|
||||||
char buffer[sizeof(SYMBOL_INFO) + 256];
|
char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME];
|
||||||
SYMBOL_INFO* sym_info = (SYMBOL_INFO*)buffer;
|
SYMBOL_INFO* sym_info = (SYMBOL_INFO*)buffer;
|
||||||
void* ptr;
|
void* ptr;
|
||||||
struct symt_ht* sym = NULL;
|
struct symt_ht* sym = NULL;
|
||||||
|
@ -720,7 +722,7 @@ static BOOL symt_enum_locals(struct process* pcs, const char* mask,
|
||||||
{
|
{
|
||||||
struct module* module;
|
struct module* module;
|
||||||
struct symt_ht* sym;
|
struct symt_ht* sym;
|
||||||
char buffer[sizeof(SYMBOL_INFO) + 256];
|
char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME];
|
||||||
SYMBOL_INFO* sym_info = (SYMBOL_INFO*)buffer;
|
SYMBOL_INFO* sym_info = (SYMBOL_INFO*)buffer;
|
||||||
DWORD pc = pcs->ctx_frame.InstructionOffset;
|
DWORD pc = pcs->ctx_frame.InstructionOffset;
|
||||||
int idx;
|
int idx;
|
||||||
|
@ -898,14 +900,14 @@ BOOL WINAPI SymFromAddr(HANDLE hProcess, DWORD64 Address,
|
||||||
BOOL WINAPI SymGetSymFromAddr(HANDLE hProcess, DWORD Address,
|
BOOL WINAPI SymGetSymFromAddr(HANDLE hProcess, DWORD Address,
|
||||||
PDWORD Displacement, PIMAGEHLP_SYMBOL Symbol)
|
PDWORD Displacement, PIMAGEHLP_SYMBOL Symbol)
|
||||||
{
|
{
|
||||||
char buffer[sizeof(SYMBOL_INFO) + 256];
|
char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME];
|
||||||
SYMBOL_INFO*si = (SYMBOL_INFO*)buffer;
|
SYMBOL_INFO*si = (SYMBOL_INFO*)buffer;
|
||||||
size_t len;
|
size_t len;
|
||||||
DWORD64 Displacement64;
|
DWORD64 Displacement64;
|
||||||
|
|
||||||
if (Symbol->SizeOfStruct < sizeof(*Symbol)) return FALSE;
|
if (Symbol->SizeOfStruct < sizeof(*Symbol)) return FALSE;
|
||||||
si->SizeOfStruct = sizeof(*si);
|
si->SizeOfStruct = sizeof(*si);
|
||||||
si->MaxNameLen = 256;
|
si->MaxNameLen = MAX_SYM_NAME;
|
||||||
if (!SymFromAddr(hProcess, Address, &Displacement64, si))
|
if (!SymFromAddr(hProcess, Address, &Displacement64, si))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@ -977,13 +979,13 @@ BOOL WINAPI SymFromName(HANDLE hProcess, LPSTR Name, PSYMBOL_INFO Symbol)
|
||||||
*/
|
*/
|
||||||
BOOL WINAPI SymGetSymFromName(HANDLE hProcess, LPSTR Name, PIMAGEHLP_SYMBOL Symbol)
|
BOOL WINAPI SymGetSymFromName(HANDLE hProcess, LPSTR Name, PIMAGEHLP_SYMBOL Symbol)
|
||||||
{
|
{
|
||||||
char buffer[sizeof(SYMBOL_INFO) + 256];
|
char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME];
|
||||||
SYMBOL_INFO*si = (SYMBOL_INFO*)buffer;
|
SYMBOL_INFO*si = (SYMBOL_INFO*)buffer;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
if (Symbol->SizeOfStruct < sizeof(*Symbol)) return FALSE;
|
if (Symbol->SizeOfStruct < sizeof(*Symbol)) return FALSE;
|
||||||
si->SizeOfStruct = sizeof(*si);
|
si->SizeOfStruct = sizeof(*si);
|
||||||
si->MaxNameLen = 256;
|
si->MaxNameLen = MAX_SYM_NAME;
|
||||||
if (!SymFromName(hProcess, Name, si)) return FALSE;
|
if (!SymFromName(hProcess, Name, si)) return FALSE;
|
||||||
|
|
||||||
Symbol->Address = si->Address;
|
Symbol->Address = si->Address;
|
||||||
|
|
|
@ -726,6 +726,8 @@ BOOL WINAPI SymUnloadModule64(HANDLE, DWORD64);
|
||||||
#define SYMFLAG_THUNK 0x00002000
|
#define SYMFLAG_THUNK 0x00002000
|
||||||
#define SYMFLAG_TLSREL 0x00004000
|
#define SYMFLAG_TLSREL 0x00004000
|
||||||
|
|
||||||
|
#define MAX_SYM_NAME 2000
|
||||||
|
|
||||||
typedef struct _SYMBOL_INFO
|
typedef struct _SYMBOL_INFO
|
||||||
{
|
{
|
||||||
ULONG SizeOfStruct;
|
ULONG SizeOfStruct;
|
||||||
|
|
Loading…
Reference in New Issue