mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 05:27:41 -05:00
impr: Immensely improve provider read speeds
This commit is contained in:
@@ -19,35 +19,38 @@ namespace hex::plugin::builtin::ui {
|
||||
if (showHeader)
|
||||
ImGui::Header("hex.builtin.common.range"_lang, firstEntry);
|
||||
|
||||
if (ImGui::RadioButton("hex.builtin.common.range.entire_data"_lang, *type == RegionType::EntireData)) {
|
||||
*region = { provider->getBaseAddress(), provider->getActualSize() };
|
||||
if (ImGui::RadioButton("hex.builtin.common.range.entire_data"_lang, *type == RegionType::EntireData))
|
||||
*type = RegionType::EntireData;
|
||||
}
|
||||
if (ImGui::RadioButton("hex.builtin.common.range.selection"_lang, *type == RegionType::Selection)) {
|
||||
*region = ImHexApi::HexEditor::getSelection().value_or(ImHexApi::HexEditor::ProviderRegion { { 0, 1 }, provider });
|
||||
if (ImGui::RadioButton("hex.builtin.common.range.selection"_lang, *type == RegionType::Selection))
|
||||
*type = RegionType::Selection;
|
||||
}
|
||||
if (ImGui::RadioButton("hex.builtin.common.region"_lang, *type == RegionType::Region)) {
|
||||
if (ImGui::RadioButton("hex.builtin.common.region"_lang, *type == RegionType::Region))
|
||||
*type = RegionType::Region;
|
||||
}
|
||||
|
||||
if (*type == RegionType::Region) {
|
||||
ImGui::SameLine();
|
||||
switch (*type) {
|
||||
case RegionType::EntireData:
|
||||
*region = { provider->getBaseAddress(), provider->getActualSize() };
|
||||
break;
|
||||
case RegionType::Selection:
|
||||
*region = ImHexApi::HexEditor::getSelection().value_or(ImHexApi::HexEditor::ProviderRegion { { 0, 1 }, provider });
|
||||
break;
|
||||
case RegionType::Region:
|
||||
ImGui::SameLine();
|
||||
|
||||
const auto width = ImGui::GetContentRegionAvail().x / 2 - ImGui::CalcTextSize(" - ").x / 2 - ImGui::GetStyle().FramePadding.x * 4;
|
||||
u64 start = region->getStartAddress(), end = region->getEndAddress();
|
||||
const auto width = ImGui::GetContentRegionAvail().x / 2 - ImGui::CalcTextSize(" - ").x / 2 - ImGui::GetStyle().FramePadding.x * 4;
|
||||
u64 start = region->getStartAddress(), end = region->getEndAddress();
|
||||
|
||||
ImGui::PushItemWidth(width);
|
||||
ImGui::InputHexadecimal("##start", &start);
|
||||
ImGui::PopItemWidth();
|
||||
ImGui::SameLine();
|
||||
ImGui::TextUnformatted(" - ");
|
||||
ImGui::SameLine();
|
||||
ImGui::PushItemWidth(width);
|
||||
ImGui::InputHexadecimal("##end", &end);
|
||||
ImGui::PopItemWidth();
|
||||
ImGui::PushItemWidth(width);
|
||||
ImGui::InputHexadecimal("##start", &start);
|
||||
ImGui::PopItemWidth();
|
||||
ImGui::SameLine();
|
||||
ImGui::TextUnformatted(" - ");
|
||||
ImGui::SameLine();
|
||||
ImGui::PushItemWidth(width);
|
||||
ImGui::InputHexadecimal("##end", &end);
|
||||
ImGui::PopItemWidth();
|
||||
|
||||
*region = { start, (end - start) + 1 };
|
||||
*region = { start, (end - start) + 1 };
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,9 +41,10 @@ namespace hex::plugin::builtin {
|
||||
|
||||
if (overlays) {
|
||||
if (auto &patches = this->getPatches(); !patches.empty()) {
|
||||
for (u64 i = 0; i < size; i++)
|
||||
if (patches.contains(offset + i))
|
||||
reinterpret_cast<u8 *>(buffer)[i] = patches[offset + i];
|
||||
for (const auto&[patchOffset, patchData] : patches) {
|
||||
if (patchOffset >= offset && patchOffset <= (offset + size))
|
||||
reinterpret_cast<u8 *>(buffer)[patchOffset] = patchData;
|
||||
}
|
||||
}
|
||||
|
||||
this->applyOverlays(offset, buffer, size);
|
||||
|
||||
Reference in New Issue
Block a user