diff --git a/Source/Windows/ARM64EC/Module.cpp b/Source/Windows/ARM64EC/Module.cpp index e8cfb5fb6..71a87f26d 100644 --- a/Source/Windows/ARM64EC/Module.cpp +++ b/Source/Windows/ARM64EC/Module.cpp @@ -302,11 +302,14 @@ void LoadImageVolatileMetadata(uint64_t Address) { VolatileValidRanges.Insert({Address + It->Rva, Address + It->Rva + It->Size}); } + LogMan::Msg::DFmt("Loaded volatile metadata for {:X}: {} entries", Address, VolatileInstructions.size()); std::scoped_lock Lock(CTX->GetCodeInvalidationMutex()); CTX->AddForceTSOInformation(VolatileValidRanges, std::move(VolatileInstructions)); } void HandleImageMap(uint64_t Address) { + fextl::string ModuleName = FEX::Windows::GetSectionFilePath(Address); + LogMan::Msg::DFmt("Load module {}: {:X}", ModuleName, Address); FEX_CONFIG_OPT(VolatileMetadata, VOLATILEMETADATA); if (VolatileMetadata) { LoadImageVolatileMetadata(Address); diff --git a/Source/Windows/Common/Module.h b/Source/Windows/Common/Module.h index de5a44252..e19379cc2 100644 --- a/Source/Windows/Common/Module.h +++ b/Source/Windows/Common/Module.h @@ -21,4 +21,22 @@ fextl::string GetExecutableFilePath() { return Path.substr(Path.find_last_of('\\') + 1); } + +fextl::string GetSectionFilePath(uint64_t Address) { + struct { + MEMORY_SECTION_NAME Info; + std::array PathW; + } Buffer; + + if (NtQueryVirtualMemory(GetCurrentProcess(), reinterpret_cast(Address), MemoryMappedFilenameInformation, &Buffer, sizeof(Buffer), NULL)) { + return {}; + } + + STRING PathA; + RtlUnicodeStringToAnsiString(&PathA, &Buffer.Info.SectionFileName, TRUE); + fextl::string Path(PathA.Buffer); + RtlFreeAnsiString(&PathA); + + return Path.substr(Path.find_last_of('\\') + 1); +} } // namespace FEX::Windows diff --git a/Source/Windows/WOW64/Module.cpp b/Source/Windows/WOW64/Module.cpp index 500396602..fe9f08ced 100644 --- a/Source/Windows/WOW64/Module.cpp +++ b/Source/Windows/WOW64/Module.cpp @@ -159,6 +159,8 @@ bool IsAddressInJit(uint64_t Address) { } void HandleImageMap(uint64_t Address) { + fextl::string ModuleName = FEX::Windows::GetSectionFilePath(Address); + LogMan::Msg::DFmt("Load module {}: {:X}", ModuleName, Address); InvalidationTracker->HandleImageMap(Address); } } // namespace diff --git a/Source/Windows/include/winternl.h b/Source/Windows/include/winternl.h index ac3683b3c..20fc97bc4 100644 --- a/Source/Windows/include/winternl.h +++ b/Source/Windows/include/winternl.h @@ -476,6 +476,11 @@ typedef struct _MEMORY_FEX_STATS_SHM_INFORMATION { DWORD max_size; } MEMORY_FEX_STATS_SHM_INFORMATION, *PMEMORY_FEX_STATS_SHM_INFORMATION; +typedef struct _MEMORY_SECTION_NAME +{ + UNICODE_STRING SectionFileName; +} MEMORY_SECTION_NAME, *PMEMORY_SECTION_NAME; + NTSTATUS WINAPIV DbgPrint(LPCSTR fmt, ...); NTSTATUS WINAPI LdrDisableThreadCalloutsForDll(HMODULE); NTSTATUS WINAPI LdrGetDllFullName(HMODULE, UNICODE_STRING*);