parent
a09aec032f
commit
14adcc0e51
2
external/ImGui/include/imgui_memory_editor.h
vendored
2
external/ImGui/include/imgui_memory_editor.h
vendored
@ -580,7 +580,7 @@ struct MemoryEditor
|
||||
auto selectionEnd = std::max(DataPreviewAddr, DataPreviewAddrEnd);
|
||||
|
||||
size_t regionSize = (selectionEnd - selectionStart) + 1;
|
||||
ImGui::Text(format_selection, s.AddrDigitsCount, selectionStart, s.AddrDigitsCount, selectionEnd, regionSize, regionSize == 1 ? "byte" : "bytes");
|
||||
ImGui::Text(format_selection, s.AddrDigitsCount, base_display_addr + selectionStart, s.AddrDigitsCount, base_display_addr + selectionEnd, regionSize, regionSize == 1 ? "byte" : "bytes");
|
||||
}
|
||||
|
||||
if (GotoAddr != (size_t)-1)
|
||||
|
@ -45,6 +45,8 @@ namespace hex {
|
||||
|
||||
s64 m_gotoAddress = 0;
|
||||
|
||||
char m_baseAddressBuffer[0x20] = { 0 };
|
||||
|
||||
std::vector<u8> m_dataToSave;
|
||||
|
||||
std::string m_loaderScriptScriptPath;
|
||||
|
@ -36,7 +36,8 @@ namespace hex::prv {
|
||||
u32 getCurrentPage() const;
|
||||
void setCurrentPage(u32 page);
|
||||
|
||||
virtual size_t getBaseAddress();
|
||||
virtual void setBaseAddress(u64 address);
|
||||
virtual u64 getBaseAddress();
|
||||
virtual size_t getSize();
|
||||
virtual std::optional<u32> getPageOfAddress(u64 address);
|
||||
|
||||
@ -44,6 +45,7 @@ namespace hex::prv {
|
||||
|
||||
protected:
|
||||
u32 m_currPage = 0;
|
||||
u64 m_baseAddress = 0;
|
||||
|
||||
std::vector<std::map<u64, u8>> m_patches;
|
||||
};
|
||||
|
@ -46,8 +46,12 @@ namespace hex::prv {
|
||||
}
|
||||
|
||||
|
||||
size_t Provider::getBaseAddress() {
|
||||
return PageSize * this->m_currPage;
|
||||
void Provider::setBaseAddress(u64 address) {
|
||||
this->m_baseAddress = address;
|
||||
}
|
||||
|
||||
u64 Provider::getBaseAddress() {
|
||||
return this->m_baseAddress + PageSize * this->m_currPage;
|
||||
}
|
||||
|
||||
size_t Provider::getSize() {
|
||||
|
@ -21,13 +21,12 @@ namespace hex::prv {
|
||||
#if defined(OS_WINDOWS)
|
||||
std::wstring widePath;
|
||||
{
|
||||
int len;
|
||||
int slength = (int)path.length() + 1;
|
||||
len = MultiByteToWideChar(CP_UTF8, 0, path.data(), slength, 0, 0);
|
||||
wchar_t* buf = new wchar_t[len];
|
||||
MultiByteToWideChar(CP_UTF8, 0, path.data(), slength, buf, len);
|
||||
widePath = buf;
|
||||
delete[] buf;
|
||||
auto length = path.length() + 1;
|
||||
auto wideLength = MultiByteToWideChar(CP_UTF8, 0, path.data(), length, 0, 0);
|
||||
wchar_t* buffer = new wchar_t[wideLength];
|
||||
MultiByteToWideChar(CP_UTF8, 0, path.data(), length, buffer, wideLength);
|
||||
widePath = buffer;
|
||||
delete[] buffer;
|
||||
}
|
||||
|
||||
LARGE_INTEGER fileSize = { 0 };
|
||||
@ -129,35 +128,35 @@ namespace hex::prv {
|
||||
if ((offset + size) > this->getSize() || buffer == nullptr || size == 0)
|
||||
return;
|
||||
|
||||
std::memcpy(buffer, reinterpret_cast<u8*>(this->m_mappedFile) + offset, size);
|
||||
std::memcpy(buffer, reinterpret_cast<u8*>(this->m_mappedFile) + PageSize * this->m_currPage + offset, size);
|
||||
|
||||
for (u64 i = 0; i < size; i++)
|
||||
if (this->m_patches.back().contains(offset + i))
|
||||
reinterpret_cast<u8*>(buffer)[i] = this->m_patches.back()[offset + i];
|
||||
reinterpret_cast<u8*>(buffer)[i] = this->m_patches.back()[offset + PageSize * this->m_currPage + i];
|
||||
}
|
||||
|
||||
void FileProvider::write(u64 offset, const void *buffer, size_t size) {
|
||||
if (buffer == nullptr || size == 0)
|
||||
if ((offset + size) > this->getSize() || buffer == nullptr || size == 0)
|
||||
return;
|
||||
|
||||
this->m_patches.push_back(this->m_patches.back());
|
||||
|
||||
for (u64 i = 0; i < size; i++)
|
||||
this->m_patches.back()[offset + i] = reinterpret_cast<const u8*>(buffer)[i];
|
||||
this->m_patches.back()[offset + this->getBaseAddress() + i] = reinterpret_cast<const u8*>(buffer)[i];
|
||||
}
|
||||
|
||||
void FileProvider::readRaw(u64 offset, void *buffer, size_t size) {
|
||||
if ((offset + size) > this->getSize() || buffer == nullptr || size == 0)
|
||||
return;
|
||||
|
||||
std::memcpy(buffer, reinterpret_cast<u8*>(this->m_mappedFile) + offset, size);
|
||||
std::memcpy(buffer, reinterpret_cast<u8*>(this->m_mappedFile) + PageSize * this->m_currPage + offset, size);
|
||||
}
|
||||
|
||||
void FileProvider::writeRaw(u64 offset, const void *buffer, size_t size) {
|
||||
if (buffer == nullptr || size == 0)
|
||||
if ((offset + size) > this->getSize() || buffer == nullptr || size == 0)
|
||||
return;
|
||||
|
||||
std::memcpy(reinterpret_cast<u8*>(this->m_mappedFile) + offset, buffer, size);
|
||||
std::memcpy(reinterpret_cast<u8*>(this->m_mappedFile) + PageSize * this->m_currPage + offset, buffer, size);
|
||||
}
|
||||
size_t FileProvider::getActualSize() {
|
||||
return this->m_fileSize;
|
||||
|
@ -210,6 +210,20 @@ namespace hex {
|
||||
|
||||
}
|
||||
|
||||
if (ImGui::BeginPopupModal("Set base address", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
ImGui::InputText("Address", this->m_baseAddressBuffer, 16, ImGuiInputTextFlags_CharsHexadecimal);
|
||||
ImGui::NewLine();
|
||||
|
||||
if (ImGui::Button("Set"))
|
||||
provider->setBaseAddress(strtoull(this->m_baseAddressBuffer, nullptr, 16));
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button("Cancel"))
|
||||
ImGui::CloseCurrentPopup();
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
|
||||
if (this->m_fileBrowser.showFileDialog("Open File", imgui_addons::ImGuiFileBrowser::DialogMode::OPEN)) {
|
||||
this->openFile(this->m_fileBrowser.selected_path);
|
||||
@ -988,6 +1002,12 @@ R"(
|
||||
|
||||
View::postEvent(Events::AddBookmark, &bookmark);
|
||||
}
|
||||
|
||||
auto provider = *SharedData::get().currentProvider;
|
||||
if (ImGui::MenuItem("Set base address", nullptr, false, provider != nullptr && provider->isReadable())) {
|
||||
std::memset(this->m_baseAddressBuffer, sizeof(this->m_baseAddressBuffer), 0x00);
|
||||
View::doLater([]{ ImGui::OpenPopup("Set base address"); });
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user