[Lldb-commits] [lldb] [lldb][windows] allow longer paths than MAX_PATH in GetFileNameByLoadAddress (PR #200225)
via lldb-commits
lldb-commits at lists.llvm.org
Fri May 29 04:11:54 PDT 2026
================
@@ -555,11 +556,21 @@ static std::optional<std::string> GetFileNameByLoadAddress(HANDLE hProcess,
}
// Fallback: ask the kernel for the file backing the mapping at this address.
- std::array<wchar_t, MAX_PATH + 1> mapped_filename;
- if (!::GetMappedFileNameW(hProcess, base_addr, mapped_filename.data(),
- mapped_filename.size()))
- return std::nullopt;
- return ConvertNtDevicePathToDosPath(mapped_filename);
+ std::vector<wchar_t> mapped_filename(MAX_PATH + 1);
+ DWORD mapped_len = 0;
+ while (true) {
+ mapped_len = ::GetMappedFileNameW(
+ hProcess, base_addr, mapped_filename.data(), mapped_filename.size());
+ if (mapped_len > 0)
+ break;
+ if (::GetLastError() != ERROR_INSUFFICIENT_BUFFER ||
+ mapped_filename.size() >= PATHCCH_MAX_CCH)
+ return std::nullopt;
----------------
Nerixyz wrote:
You'll need to check `GetLastError` before `mapped_len`:
> If the buffer is too small to hold the module name, the string is truncated to nSize characters (including the terminating null character), the function returns nSize, and the the last error is set to ERROR_INSUFFICIENT_BUFFER.
https://github.com/llvm/llvm-project/pull/200225
More information about the lldb-commits
mailing list