impr: Immensely improve provider read speeds

This commit is contained in:
WerWolv
2023-04-12 19:21:48 +02:00
parent 86b49f34d9
commit 803b99f2a9
4 changed files with 38 additions and 49 deletions

View File

@@ -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;
}
}

View File

@@ -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);