================
@@ -614,44 +614,82 @@ static std::optional<std::string>
GetFileNameByLoadAddress(HANDLE hProcess,
return dos_path;
}
+// Determine how many bytes can be read at `addr` in `hProcess` before crossing
+// out of the committed memory region containing it. Returns 0 if the address
is
+// not within a committed region.
+static SIZE_T BytesReadableAt(HANDLE hProcess, LPCVOID addr) {
+ MEMORY_BASIC_INFORMATION mbi{};
+ if (!::VirtualQueryEx(hProcess, addr, &mbi, sizeof(mbi)))
+ return 0;
+ if (mbi.State != MEM_COMMIT)
+ return 0;
+ uintptr_t region_end =
+ reinterpret_cast<uintptr_t>(mbi.BaseAddress) + mbi.RegionSize;
+ uintptr_t a = reinterpret_cast<uintptr_t>(addr);
+ if (a >= region_end)
+ return 0;
+ return region_end - a;
+}
+
+static std::optional<std::string> ReadRemoteStringW(HANDLE hProcess,
----------------
Nerixyz wrote:
Rename this to indicate that it reads a path bounded by `MAX_PATH`. Maybe
`ReadRemotePathStringW`?
https://github.com/llvm/llvm-project/pull/200230
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits