ui: Make sure modified bytes are correctly highlighted

This commit is contained in:
WerWolv 2022-10-08 10:00:37 +02:00
parent 8024b0a186
commit 2cea561468
1 changed files with 9 additions and 2 deletions

View File

@ -31,11 +31,18 @@ namespace hex::plugin::builtin {
});
ImHexApi::HexEditor::addForegroundHighlightingProvider([](u64 offset, const u8* buffer, size_t, bool) -> std::optional<color_t> {
hex::unused(buffer);
if (!ImHexApi::Provider::isValid())
return std::nullopt;
auto &patches = ImHexApi::Provider::get()->getPatches();
if (patches.contains(offset) && patches[offset] != buffer[0])
auto provider = ImHexApi::Provider::get();
u8 byte = 0x00;
provider->readRaw(offset, &byte, sizeof(u8));
const auto &patches = provider->getPatches();
if (patches.contains(offset) && patches.at(offset) != byte)
return ImGui::GetCustomColorU32(ImGuiCustomCol_ToolbarRed);
else
return std::nullopt;