Various Debug Locals fixes. (#2426)

* Fixed Debug -> Locals crashing if the user added an invalid Local Read.
Fixed Debug Local addendum being way too wide on the page.

* Added the same boundary check for Debug -> Globals.
This commit is contained in:
gir489 2023-11-19 16:46:44 -05:00 committed by GitHub
parent 0b0bde5958
commit 6ec0478414
2 changed files with 39 additions and 7 deletions

View File

@ -84,12 +84,26 @@ namespace big
global_debug global_read;
load_global_menu(item.global_name, global_read);
if (auto ptr = get_global_ptr(global_read))
{
auto value = *ptr;
if (value < 0 || value > INT32_MAX)
{
LOG(WARNING) << item.global_name << " was out of bounds for a Read Global.";
continue;
}
if (item.size != 0)
global_to_read = global_to_read.at(*ptr, item.size);
{
global_to_read = global_to_read.at(value, item.size);
}
else
global_to_read = global_to_read.at(*ptr);
{
global_to_read = global_to_read.at(value);
}
}
else
{
LOG(WARNING) << "Failed to read " << item.global_name << "for get_global_ptr";
}
}
else if (item.type == GlobalAppendageType_PlayerId)
{

View File

@ -80,21 +80,39 @@ namespace big
if (item.type == LocalAppendageType_At)
{
if (item.size != 0)
{
local_to_read = local_to_read.at(item.index, item.size);
}
else
{
local_to_read = local_to_read.at(item.index);
}
}
else if (item.type == LocalAppendageType_ReadLocal)
{
local_debug local_read;
load_local_menu(item.local_name, local_read);
if (auto ptr = get_local_ptr(local_thread, local_read))
if (auto ptr = (PINT)get_local_ptr(local_thread, local_read))
{
auto value = *ptr;
if (value < 0 || value > INT16_MAX)
{
LOG(WARNING) << item.local_name << " was out of bounds for a Read Local.";
continue;
}
if (item.size != 0)
local_to_read = local_to_read.at(*ptr, item.size);
{
local_to_read = local_to_read.at(value, item.size);
}
else
local_to_read = local_to_read.at(*ptr);
{
local_to_read = local_to_read.at(value);
}
}
else
{
LOG(WARNING) << "Failed to read " << item.local_name << "for get_local_ptr";
}
}
else if (item.type == LocalAppendageType_PlayerId)
{
@ -214,8 +232,6 @@ namespace big
if (ImGui::InputScalar("VIEW_DEBUG_LOCALS_LOCAL"_T.data(), ImGuiDataType_U16, &local_test.local_index))
local_laddie = script_local(local_thread, local_test.local_index);
ImGui::PopItemWidth();
for (int i = 0; i < local_test.local_appendages.size(); i++)
{
auto item = local_test.local_appendages[i];
@ -239,6 +255,8 @@ namespace big
ImGui::PopID();
}
ImGui::PopItemWidth();
if (ImGui::Button("VIEW_DEBUG_GLOBAL_ADD_OFFSET"_T.data()))
local_test.local_appendages.push_back({LocalAppendageType_At, 0LL, 0ULL});
ImGui::SameLine();