Skip to content

Commit

Permalink
ui: Make sure modified bytes are correctly highlighted
Browse files Browse the repository at this point in the history
  • Loading branch information
WerWolv committed Oct 8, 2022
1 parent 8024b0a commit 2cea561
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions plugins/builtin/source/content/views/view_patches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2cea561

Please sign in to comment.