Module: wine Branch: master Commit: 767fc14ef758fdc7e9d4fddedf10dd9c5f71866c URL: https://gitlab.winehq.org/wine/wine/-/commit/767fc14ef758fdc7e9d4fddedf10dd9...
Author: Eric Pouech epouech@codeweavers.com Date: Wed Jan 31 18:03:13 2024 +0100
dbghelp: Implement SymSrvGetFileIndexInfo() for .dbg files.
Signed-off-by: Eric Pouech epouech@codeweavers.com
---
dlls/dbghelp/dbghelp_private.h | 1 + dlls/dbghelp/msc.c | 33 +++++++++++++++++++++++++++++++++ dlls/dbghelp/path.c | 2 ++ dlls/dbghelp/tests/path.c | 4 +--- 4 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h index acba5faca37..4f14433c7c4 100644 --- a/dlls/dbghelp/dbghelp_private.h +++ b/dlls/dbghelp/dbghelp_private.h @@ -767,6 +767,7 @@ struct pdb_cmd_pair { extern BOOL pdb_virtual_unwind(struct cpu_stack_walk *csw, DWORD_PTR ip, union ctx *context, struct pdb_cmd_pair *cpair); extern DWORD pdb_get_file_indexinfo(void* image, DWORD size, SYMSRV_INDEX_INFOW* info); +extern DWORD dbg_get_file_indexinfo(void* image, DWORD size, SYMSRV_INDEX_INFOW* info);
/* path.c */ extern BOOL path_find_symbol_file(const struct process* pcs, const struct module* module, diff --git a/dlls/dbghelp/msc.c b/dlls/dbghelp/msc.c index a62667ea8c3..0440530f6cf 100644 --- a/dlls/dbghelp/msc.c +++ b/dlls/dbghelp/msc.c @@ -4573,3 +4573,36 @@ DWORD msc_get_file_indexinfo(void* image, const IMAGE_DEBUG_DIRECTORY* debug_dir } return info->stripped && !num_misc_records ? ERROR_BAD_EXE_FORMAT : ERROR_SUCCESS; } + +DWORD dbg_get_file_indexinfo(void* image, DWORD size, SYMSRV_INDEX_INFOW* info) +{ + const IMAGE_SEPARATE_DEBUG_HEADER *header; + DWORD num_directories; + + if (size < sizeof(*header)) return ERROR_BAD_EXE_FORMAT; + header = image; + if (header->Signature != 0x4944 /* DI */ || + size < sizeof(*header) + header->NumberOfSections * sizeof(IMAGE_SECTION_HEADER) + header->ExportedNamesSize + header->DebugDirectorySize) + return ERROR_BAD_EXE_FORMAT; + + /* header is followed by: + * - header->NumberOfSections of IMAGE_SECTION_HEADER + * - header->ExportedNameSize + * - then num_directories of IMAGE_DEBUG_DIRECTORY + */ + num_directories = header->DebugDirectorySize / sizeof(IMAGE_DEBUG_DIRECTORY); + + if (!num_directories) return ERROR_BAD_EXE_FORMAT; + + info->age = 0; + memset(&info->guid, 0, sizeof(info->guid)); + info->sig = 0; + info->dbgfile[0] = L'\0'; + info->pdbfile[0] = L'\0'; + info->size = header->SizeOfImage; + /* seems to use header's timestamp, not debug_directory one */ + info->timestamp = header->TimeDateStamp; + info->stripped = FALSE; /* FIXME */ + + return ERROR_SUCCESS; +} diff --git a/dlls/dbghelp/path.c b/dlls/dbghelp/path.c index 2437a7b6131..ec182c969d3 100644 --- a/dlls/dbghelp/path.c +++ b/dlls/dbghelp/path.c @@ -860,6 +860,8 @@ BOOL WINAPI SymSrvGetFileIndexInfoW(const WCHAR *file, SYMSRV_INDEX_INFOW* info, ret = pe_get_file_indexinfo(image, fsize, info); if (ret == ERROR_BAD_FORMAT) ret = pdb_get_file_indexinfo(image, fsize, info); + if (ret == ERROR_BAD_FORMAT) + ret = dbg_get_file_indexinfo(image, fsize, info); } else ret = ERROR_FILE_NOT_FOUND;
diff --git a/dlls/dbghelp/tests/path.c b/dlls/dbghelp/tests/path.c index e1539bad966..fb7c103d845 100644 --- a/dlls/dbghelp/tests/path.c +++ b/dlls/dbghelp/tests/path.c @@ -907,10 +907,8 @@ static void test_srvgetindexes_dbg(void) memset(&ssii, 0x45, sizeof(ssii)); ssii.sizeofstruct = sizeof(ssii); ret = SymSrvGetFileIndexInfoW(filename, &ssii, 0); - todo_wine ok(ret, "SymSrvGetFileIndexInfo failed: %lu\n", GetLastError());
- if (ret){ ok(ssii.age == 0, "Mismatch in age: %lx\n", ssii.age); ok(!memcmp(&ssii.guid, &null_guid, sizeof(GUID)), "Mismatch in guid: guid=%s\n", wine_dbgstr_guid(&ssii.guid)); @@ -922,7 +920,7 @@ static void test_srvgetindexes_dbg(void) ok(!wcscmp(ssii.file, filename), "Mismatch in file: %ls\n", ssii.file); ok(!ssii.pdbfile[0], "Mismatch in pdbfile: %ls\n", ssii.pdbfile); ok(!ssii.dbgfile[0], "Mismatch in dbgfile: %ls\n", ssii.dbgfile); - } + DeleteFileW(filename); winetest_pop_context(); }