dbghelp: Always use SymGetSrvIndexFileInfo() for files lookup.
This will help separate debug info files lookup from their actual loading once found and correctly matched. Signed-off-by: Eric Pouech <epouech@codeweavers.com>
This commit is contained in:
parent
ec099b8ea3
commit
f014745676
4 changed files with 9 additions and 91 deletions
|
@ -759,7 +759,6 @@ extern BOOL pe_load_debug_directory(const struct process* pcs,
|
|||
const IMAGE_DEBUG_DIRECTORY* dbg, int nDbg);
|
||||
extern DWORD msc_get_file_indexinfo(void* image, const IMAGE_DEBUG_DIRECTORY* dbgdir, DWORD size,
|
||||
SYMSRV_INDEX_INFOW* info);
|
||||
extern BOOL pdb_fetch_file_info(const struct pdb_lookup* pdb_lookup, unsigned* matched);
|
||||
struct pdb_cmd_pair {
|
||||
const char* name;
|
||||
DWORD* pvalue;
|
||||
|
|
|
@ -3996,34 +3996,6 @@ static BOOL pdb_process_file(const struct process* pcs,
|
|||
return ret;
|
||||
}
|
||||
|
||||
BOOL pdb_fetch_file_info(const struct pdb_lookup* pdb_lookup, unsigned* matched)
|
||||
{
|
||||
HANDLE hFile, hMap = NULL;
|
||||
char* image = NULL;
|
||||
BOOL ret;
|
||||
struct pdb_file_info pdb_file;
|
||||
|
||||
if ((hFile = CreateFileA(pdb_lookup->filename, GENERIC_READ, FILE_SHARE_READ, NULL,
|
||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE ||
|
||||
((hMap = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) == NULL) ||
|
||||
((image = MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)) == NULL))
|
||||
{
|
||||
WARN("Unable to open .PDB file: %s\n", pdb_lookup->filename);
|
||||
ret = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = pdb_init(pdb_lookup, &pdb_file, image, matched);
|
||||
pdb_free_file(&pdb_file);
|
||||
}
|
||||
|
||||
if (image) UnmapViewOfFile(image);
|
||||
if (hMap) CloseHandle(hMap);
|
||||
if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*========================================================================
|
||||
* FPO unwinding code
|
||||
*/
|
||||
|
|
|
@ -477,67 +477,15 @@ struct module_find
|
|||
static BOOL CALLBACK module_find_cb(PCWSTR buffer, PVOID user)
|
||||
{
|
||||
struct module_find* mf = user;
|
||||
DWORD timestamp;
|
||||
unsigned matched = 0;
|
||||
SYMSRV_INDEX_INFOW info;
|
||||
|
||||
/* the matching weights:
|
||||
* +1 if a file with same name is found and is a decent file of expected type
|
||||
* +1 if first parameter and second parameter match
|
||||
*/
|
||||
|
||||
if (mf->is_pdb)
|
||||
{
|
||||
struct pdb_lookup pdb_lookup;
|
||||
char fn[MAX_PATH];
|
||||
|
||||
WideCharToMultiByte(CP_ACP, 0, buffer, -1, fn, MAX_PATH, NULL, NULL);
|
||||
pdb_lookup.filename = fn;
|
||||
|
||||
if (mf->guid)
|
||||
{
|
||||
pdb_lookup.kind = PDB_DS;
|
||||
pdb_lookup.timestamp = 0;
|
||||
pdb_lookup.guid = *mf->guid;
|
||||
}
|
||||
else
|
||||
{
|
||||
pdb_lookup.kind = PDB_JG;
|
||||
pdb_lookup.timestamp = mf->dw1;
|
||||
/* pdb_loopkup.guid = */
|
||||
}
|
||||
pdb_lookup.age = mf->dw2;
|
||||
|
||||
if (!pdb_fetch_file_info(&pdb_lookup, &matched)) return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
HANDLE hFile, hMap;
|
||||
void* mapping;
|
||||
|
||||
timestamp = ~mf->dw1;
|
||||
hFile = CreateFileW(buffer, GENERIC_READ, FILE_SHARE_READ, NULL,
|
||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (hFile == INVALID_HANDLE_VALUE) return FALSE;
|
||||
if ((hMap = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != NULL)
|
||||
{
|
||||
if ((mapping = MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)) != NULL)
|
||||
{
|
||||
const IMAGE_SEPARATE_DEBUG_HEADER* hdr;
|
||||
hdr = mapping;
|
||||
|
||||
if (hdr->Signature == IMAGE_SEPARATE_DEBUG_SIGNATURE)
|
||||
{
|
||||
matched++;
|
||||
timestamp = hdr->TimeDateStamp;
|
||||
}
|
||||
UnmapViewOfFile(mapping);
|
||||
}
|
||||
CloseHandle(hMap);
|
||||
}
|
||||
CloseHandle(hFile);
|
||||
if (timestamp == mf->dw1) matched++;
|
||||
else WARN("Found %s, but wrong timestamp\n", debugstr_w(buffer));
|
||||
}
|
||||
info.sizeofstruct = sizeof(info);
|
||||
if (!SymSrvGetFileIndexInfoW(buffer, &info, 0))
|
||||
return FALSE;
|
||||
if (!memcmp(&info.guid, mf->guid, sizeof(GUID))) matched++;
|
||||
if (info.timestamp == mf->dw1) matched++;
|
||||
if (info.age == mf->dw2) matched++;
|
||||
|
||||
if (matched > mf->matched)
|
||||
{
|
||||
|
@ -547,7 +495,7 @@ static BOOL CALLBACK module_find_cb(PCWSTR buffer, PVOID user)
|
|||
/* yes, EnumDirTree/do_search and SymFindFileInPath callbacks use the opposite
|
||||
* convention to stop/continue enumeration. sigh.
|
||||
*/
|
||||
return mf->matched == 2;
|
||||
return mf->matched == 3;
|
||||
}
|
||||
|
||||
BOOL path_find_symbol_file(const struct process* pcs, const struct module* module,
|
||||
|
|
|
@ -1592,7 +1592,7 @@ static void test_load_modules_path(void)
|
|||
todo_wine
|
||||
ok(im.PdbAge == test_files[test->found_file].age_or_timestamp,
|
||||
"Expected %lx as pdb-age, got %lx instead\n", test_files[test->found_file].age_or_timestamp, im.PdbAge);
|
||||
todo_wine_if(i == 11 || i == 16 || i == 17)
|
||||
todo_wine_if(i == 11)
|
||||
ok(im.PdbUnmatched == !(test_files[test->found_file].age_or_timestamp == 0x0030cafe), "Expecting matched PDB\n");
|
||||
}
|
||||
todo_wine
|
||||
|
@ -1813,7 +1813,6 @@ static void test_load_modules_details(void)
|
|||
"Unexpected loaded image name '%ls' (%ls)\n", im.LoadedImageName, loaded_img_name);
|
||||
todo_wine_if(i == 3 || i == 4 || i == 6 || i == 8 || i == 10 || i == 12 || i == 14)
|
||||
ok(im.SymType == test->sym_type, "Unexpected module type %u\n", im.SymType);
|
||||
todo_wine_if(i == 8)
|
||||
ok(!im.TypeInfo, "No type info present\n");
|
||||
if (test->mismatch_in)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue