mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-14 04:34:16 +01:00
Fix bad exit condition when looping exception records
This commit is contained in:
parent
9c2d2b7c1d
commit
e09c43b8de
1 changed files with 43 additions and 35 deletions
|
|
@ -292,35 +292,43 @@ std::wstring to_address_string(const DWORD64 address, const bool try_ptrderef =
|
||||||
|
|
||||||
void print_exception_info(HANDLE hThread, const EXCEPTION_POINTERS& ex, const CONTEXT& ctx, std::wostringstream& log) {
|
void print_exception_info(HANDLE hThread, const EXCEPTION_POINTERS& ex, const CONTEXT& ctx, std::wostringstream& log) {
|
||||||
std::vector<EXCEPTION_RECORD> exRecs;
|
std::vector<EXCEPTION_RECORD> exRecs;
|
||||||
if (ex.ExceptionRecord) {
|
if (ex.ExceptionRecord)
|
||||||
|
{
|
||||||
size_t rec_index = 0;
|
size_t rec_index = 0;
|
||||||
size_t read;
|
size_t read;
|
||||||
exRecs.emplace_back();
|
|
||||||
for (auto pRemoteExRec = ex.ExceptionRecord;
|
for (auto pRemoteExRec = ex.ExceptionRecord;
|
||||||
pRemoteExRec
|
pRemoteExRec && rec_index < 64;
|
||||||
&& rec_index < 64
|
rec_index++)
|
||||||
&& ReadProcessMemory(g_hProcess, pRemoteExRec, &exRecs.back(), sizeof exRecs.back(), &read)
|
{
|
||||||
&& read >= offsetof(EXCEPTION_RECORD, ExceptionInformation)
|
exRecs.emplace_back();
|
||||||
&& read >= static_cast<size_t>(reinterpret_cast<const char*>(&exRecs.back().ExceptionInformation[exRecs.back().NumberParameters]) - reinterpret_cast<const char*>(&exRecs.back()));
|
|
||||||
rec_index++) {
|
if (!ReadProcessMemory(g_hProcess, pRemoteExRec, &exRecs.back(), sizeof exRecs.back(), &read)
|
||||||
|
|| read < offsetof(EXCEPTION_RECORD, ExceptionInformation)
|
||||||
|
|| read < static_cast<size_t>(reinterpret_cast<const char*>(&exRecs.back().ExceptionInformation[exRecs.
|
||||||
|
back().NumberParameters]) - reinterpret_cast<const char*>(&exRecs.back())))
|
||||||
|
{
|
||||||
|
exRecs.pop_back();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
log << std::format(L"\nException Info #{}\n", rec_index);
|
log << std::format(L"\nException Info #{}\n", rec_index);
|
||||||
log << std::format(L"Address: {:X}\n", exRecs.back().ExceptionCode);
|
log << std::format(L"Address: {:X}\n", exRecs.back().ExceptionCode);
|
||||||
log << std::format(L"Flags: {:X}\n", exRecs.back().ExceptionFlags);
|
log << std::format(L"Flags: {:X}\n", exRecs.back().ExceptionFlags);
|
||||||
log << std::format(L"Address: {:X}\n", reinterpret_cast<size_t>(exRecs.back().ExceptionAddress));
|
log << std::format(L"Address: {:X}\n", reinterpret_cast<size_t>(exRecs.back().ExceptionAddress));
|
||||||
if (!exRecs.back().NumberParameters)
|
if (exRecs.back().NumberParameters)
|
||||||
continue;
|
{
|
||||||
log << L"Parameters: ";
|
log << L"Parameters: ";
|
||||||
for (DWORD i = 0; i < exRecs.back().NumberParameters; ++i) {
|
for (DWORD i = 0; i < exRecs.back().NumberParameters; ++i)
|
||||||
|
{
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
log << L", ";
|
log << L", ";
|
||||||
log << std::format(L"{:X}", exRecs.back().ExceptionInformation[i]);
|
log << std::format(L"{:X}", exRecs.back().ExceptionInformation[i]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pRemoteExRec = exRecs.back().ExceptionRecord;
|
pRemoteExRec = exRecs.back().ExceptionRecord;
|
||||||
exRecs.emplace_back();
|
|
||||||
}
|
}
|
||||||
exRecs.pop_back();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log << L"\nCall Stack\n{";
|
log << L"\nCall Stack\n{";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue