diff --git a/dlls/dbghelp/msc.c b/dlls/dbghelp/msc.c index e2e91e1abd2..d2bbf7f784c 100644 --- a/dlls/dbghelp/msc.c +++ b/dlls/dbghelp/msc.c @@ -4555,38 +4555,35 @@ DWORD msc_get_file_indexinfo(void* image, const IMAGE_DEBUG_DIRECTORY* debug_dir num_misc_records++; } } - return info->stripped && !num_misc_records ? ERROR_BAD_EXE_FORMAT : ERROR_SUCCESS; + return (!num_dir || (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; + IMAGE_DEBUG_DIRECTORY *dbg; DWORD num_directories; - if (size < sizeof(*header)) return ERROR_BAD_EXE_FORMAT; + if (size < sizeof(*header)) return ERROR_BAD_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; + return ERROR_BAD_FORMAT; + + info->size = header->SizeOfImage; + /* seems to use header's timestamp, not debug_directory one */ + info->timestamp = header->TimeDateStamp; + info->stripped = FALSE; /* FIXME */ /* header is followed by: * - header->NumberOfSections of IMAGE_SECTION_HEADER * - header->ExportedNameSize * - then num_directories of IMAGE_DEBUG_DIRECTORY */ + dbg = (IMAGE_DEBUG_DIRECTORY*)((char*)(header + 1) + + header->NumberOfSections * sizeof(IMAGE_SECTION_HEADER) + + header->ExportedNamesSize); 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; + return msc_get_file_indexinfo(image, dbg, num_directories, info); } diff --git a/dlls/dbghelp/path.c b/dlls/dbghelp/path.c index 0f52bca3684..c1fc6addb0c 100644 --- a/dlls/dbghelp/path.c +++ b/dlls/dbghelp/path.c @@ -832,7 +832,7 @@ BOOL WINAPI SymSrvGetFileIndexInfoW(const WCHAR *file, SYMSRV_INDEX_INFOW* info, if (hMap) CloseHandle(hMap); if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile); - if (ret == ERROR_SUCCESS) wcscpy(info->file, file_name(file)); /* overflow? */ + if (ret == ERROR_SUCCESS || ret == ERROR_BAD_EXE_FORMAT) wcscpy(info->file, file_name(file)); /* overflow? */ SetLastError(ret); return ret == ERROR_SUCCESS; } diff --git a/dlls/dbghelp/pe_module.c b/dlls/dbghelp/pe_module.c index 74f5b08e613..75060e2dfa6 100644 --- a/dlls/dbghelp/pe_module.c +++ b/dlls/dbghelp/pe_module.c @@ -1019,7 +1019,7 @@ DWORD pe_get_file_indexinfo(void* image, DWORD size, SYMSRV_INDEX_INFOW* info) if (!(nthdr = RtlImageNtHeader(image))) return ERROR_BAD_FORMAT; dbg = RtlImageDirectoryEntryToData(image, FALSE, IMAGE_DIRECTORY_ENTRY_DEBUG, &dirsize); - if (!dbg || dirsize < sizeof(dbg)) return ERROR_BAD_EXE_FORMAT; + if (!dbg) dirsize = 0; /* fill in information from NT header */ info->timestamp = nthdr->FileHeader.TimeDateStamp; diff --git a/dlls/dbghelp/tests/path.c b/dlls/dbghelp/tests/path.c index 16a0ad56220..73e211f89e4 100644 --- a/dlls/dbghelp/tests/path.c +++ b/dlls/dbghelp/tests/path.c @@ -817,8 +817,6 @@ static void test_srvgetindexes_pe(void) ok(ret, "SymSrvGetFileIndexInfo failed: %lu\n", GetLastError()); if (ret || indexes[i].last_error == ERROR_BAD_EXE_FORMAT) { - todo_wine_if(i==0||i==4) - { ok(ssii.age == indexes[i].age, "Mismatch in age: %lu\n", ssii.age); ok(IsEqualGUID(&ssii.guid, indexes[i].guid), "Mismatch in guid: guid=%s\n", wine_dbgstr_guid(&ssii.guid)); @@ -829,13 +827,9 @@ static void test_srvgetindexes_pe(void) (!ssii.stripped) == ((indexes[i].charac & IMAGE_FILE_DEBUG_STRIPPED) == 0), "Mismatch in stripped: %x\n", ssii.stripped); ok(ssii.timestamp == 0x67890000 + i, "Mismatch in timestamp: %lx\n", ssii.timestamp); - } - if (i > 4) - { ok(!wcscmp(ssii.file, filename + 2), "Mismatch in file: '%ls'\n", ssii.file); ok(!wcscmp(ssii.dbgfile, indexes[i].dbg_name), "Mismatch in dbgfile: '%ls'\n", ssii.dbgfile); ok(!wcscmp(ssii.pdbfile, indexes[i].pdb_name), "Mismatch in pdbfile: '%ls'\n", ssii.pdbfile); - } } ret = DeleteFileW(filename); ok(ret, "Couldn't delete test DLL file\n"); @@ -948,24 +942,15 @@ static void test_srvgetindexes_dbg(void) else ok(ret, "SymSrvGetFileIndexInfo failed: %lu\n", GetLastError()); - todo_wine - { ok(ssii.age == indexes[i].age, "Mismatch in age: %lx\n", ssii.age); ok(IsEqualGUID(&ssii.guid, indexes[i].guid), "Mismatch in guid: guid=%s\n", wine_dbgstr_guid(&ssii.guid)); - } - todo_wine_if(i < 2) - { ok(ssii.sig == 0, "Mismatch in sig: %lx\n", ssii.sig); ok(ssii.size == indexes[i].imagesize, "Mismatch in size: %lx\n", ssii.size); ok(!ssii.stripped, "Mismatch in stripped: %x\n", ssii.stripped); ok(ssii.timestamp == indexes[i].timestamp, "Mismatch in timestamp: %lx\n", ssii.timestamp); - } - if (i >= 2) ok(!wcscmp(ssii.file, filename), "Mismatch in file: %ls\n", ssii.file); - todo_wine ok(!wcscmp(ssii.pdbfile, indexes[i].pdbname), "Mismatch in pdbfile: %ls\n", ssii.pdbfile); - if (i >= 2) ok(!wcscmp(ssii.dbgfile, indexes[i].dbgname), "Mismatch in dbgfile: %ls\n", ssii.dbgfile); DeleteFileW(filename);