parent
55e24b5e23
commit
c761054805
@ -59,6 +59,7 @@ add_imhex_plugin(
|
|||||||
source/content/providers/memory_file_provider.cpp
|
source/content/providers/memory_file_provider.cpp
|
||||||
source/content/providers/process_memory_provider.cpp
|
source/content/providers/process_memory_provider.cpp
|
||||||
source/content/providers/base64_provider.cpp
|
source/content/providers/base64_provider.cpp
|
||||||
|
source/content/providers/view_provider.cpp
|
||||||
|
|
||||||
source/content/tools/ascii_table.cpp
|
source/content/tools/ascii_table.cpp
|
||||||
source/content/tools/base_converter.cpp
|
source/content/tools/base_converter.cpp
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <hex/providers/provider.hpp>
|
#include <hex/providers/provider.hpp>
|
||||||
#include <hex/helpers/fmt.hpp>
|
|
||||||
|
|
||||||
#include <hex/api/event_manager.hpp>
|
|
||||||
|
|
||||||
namespace hex::plugin::builtin {
|
namespace hex::plugin::builtin {
|
||||||
|
|
||||||
@ -12,151 +9,49 @@ namespace hex::plugin::builtin {
|
|||||||
ViewProvider() = default;
|
ViewProvider() = default;
|
||||||
~ViewProvider() override = default;
|
~ViewProvider() override = default;
|
||||||
|
|
||||||
[[nodiscard]] bool isAvailable() const override {
|
[[nodiscard]] bool isAvailable() const override;
|
||||||
if (m_provider == nullptr)
|
[[nodiscard]] bool isReadable() const override;
|
||||||
return false;
|
[[nodiscard]] bool isWritable() const override;
|
||||||
else
|
[[nodiscard]] bool isResizable() const override;
|
||||||
return m_provider->isAvailable();
|
[[nodiscard]] bool isSavable() const override;
|
||||||
}
|
[[nodiscard]] bool isSavableAsRecent() const override;
|
||||||
[[nodiscard]] bool isReadable() const override {
|
|
||||||
if (m_provider == nullptr)
|
|
||||||
return false;
|
|
||||||
else
|
|
||||||
return m_provider->isReadable();
|
|
||||||
}
|
|
||||||
[[nodiscard]] bool isWritable() const override {
|
|
||||||
if (m_provider == nullptr)
|
|
||||||
return false;
|
|
||||||
else
|
|
||||||
return m_provider->isWritable();
|
|
||||||
}
|
|
||||||
[[nodiscard]] bool isResizable() const override { return true; }
|
|
||||||
|
|
||||||
[[nodiscard]] bool isSavable() const override {
|
void save() override;
|
||||||
if (m_provider == nullptr)
|
[[nodiscard]] bool open() override;
|
||||||
return false;
|
void close() override;
|
||||||
else
|
|
||||||
return m_provider->isSavable();
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] bool isSavableAsRecent() const override { return false; }
|
void resizeRaw(u64 newSize) override;
|
||||||
|
void insertRaw(u64 offset, u64 size) override;
|
||||||
|
void removeRaw(u64 offset, u64 size) override;
|
||||||
|
void readRaw(u64 offset, void *buffer, size_t size) override;
|
||||||
|
void writeRaw(u64 offset, const void *buffer, size_t size) override;
|
||||||
|
|
||||||
void save() override {
|
[[nodiscard]] u64 getActualSize() const override;
|
||||||
m_provider->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] bool open() override {
|
[[nodiscard]] std::string getName() const override;
|
||||||
if (m_provider == this)
|
[[nodiscard]] std::vector<Description> getDataDescription() const override;
|
||||||
return false;
|
[[nodiscard]] std::string getTypeName() const override;
|
||||||
|
|
||||||
EventProviderClosing::subscribe(this, [this](const prv::Provider *provider, bool*) {
|
void loadSettings(const nlohmann::json &settings) override;
|
||||||
if (m_provider == provider)
|
[[nodiscard]] nlohmann::json storeSettings(nlohmann::json settings) const override;
|
||||||
ImHexApi::Provider::remove(this, false);
|
|
||||||
});
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
void close() override {
|
|
||||||
EventProviderClosing::unsubscribe(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void resizeRaw(u64 newSize) override {
|
void setProvider(u64 startAddress, size_t size, hex::prv::Provider *provider);
|
||||||
m_size = newSize;
|
void setName(const std::string &name);
|
||||||
}
|
|
||||||
void insertRaw(u64 offset, u64 size) override {
|
|
||||||
if (m_provider == nullptr)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_size += size;
|
[[nodiscard]] std::pair<Region, bool> getRegionValidity(u64 address) const override;
|
||||||
m_provider->insert(offset + m_startAddress, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void removeRaw(u64 offset, u64 size) override {
|
std::vector<MenuEntry> getMenuEntries() override;
|
||||||
if (m_provider == nullptr)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_size -= size;
|
|
||||||
m_provider->remove(offset + m_startAddress, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void readRaw(u64 offset, void *buffer, size_t size) override {
|
|
||||||
if (m_provider == nullptr)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_provider->read(offset + m_startAddress, buffer, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeRaw(u64 offset, const void *buffer, size_t size) override {
|
|
||||||
if (m_provider == nullptr)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_provider->write(offset + m_startAddress, buffer, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] u64 getActualSize() const override { return m_size; }
|
|
||||||
|
|
||||||
[[nodiscard]] std::string getName() const override {
|
|
||||||
if (m_provider == nullptr)
|
|
||||||
return "View";
|
|
||||||
else
|
|
||||||
return hex::format("{} View", m_provider->getName());
|
|
||||||
}
|
|
||||||
[[nodiscard]] std::vector<Description> getDataDescription() const override {
|
|
||||||
if (m_provider == nullptr)
|
|
||||||
return { };
|
|
||||||
|
|
||||||
return m_provider->getDataDescription();
|
|
||||||
}
|
|
||||||
|
|
||||||
void loadSettings(const nlohmann::json &settings) override {
|
|
||||||
Provider::loadSettings(settings);
|
|
||||||
|
|
||||||
auto id = settings.at("id").get<u64>();
|
|
||||||
m_startAddress = settings.at("start_address").get<u64>();
|
|
||||||
m_size = settings.at("size").get<size_t>();
|
|
||||||
|
|
||||||
const auto &providers = ImHexApi::Provider::getProviders();
|
|
||||||
auto provider = std::ranges::find_if(providers, [id](const prv::Provider *provider) {
|
|
||||||
return provider->getID() == id;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (provider == providers.end())
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_provider = *provider;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] nlohmann::json storeSettings(nlohmann::json settings) const override {
|
|
||||||
settings["id"] = m_provider->getID();
|
|
||||||
settings["start_address"] = m_startAddress;
|
|
||||||
settings["size"] = m_size;
|
|
||||||
|
|
||||||
return Provider::storeSettings(settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] std::string getTypeName() const override {
|
|
||||||
return "hex.builtin.provider.view";
|
|
||||||
}
|
|
||||||
|
|
||||||
void setProvider(u64 startAddress, size_t size, hex::prv::Provider *provider) {
|
|
||||||
m_startAddress = startAddress;
|
|
||||||
m_size = size;
|
|
||||||
m_provider = provider;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] std::pair<Region, bool> getRegionValidity(u64 address) const override {
|
|
||||||
address -= this->getBaseAddress();
|
|
||||||
|
|
||||||
if (address < this->getActualSize())
|
|
||||||
return { Region { this->getBaseAddress() + address, this->getActualSize() - address }, true };
|
|
||||||
else
|
|
||||||
return { Region::Invalid(), false };
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void renameFile();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string m_name;
|
||||||
|
|
||||||
u64 m_startAddress = 0x00;
|
u64 m_startAddress = 0x00;
|
||||||
size_t m_size = 0x00;
|
size_t m_size = 0x00;
|
||||||
prv::Provider *m_provider = nullptr;
|
prv::Provider *m_provider = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -393,6 +393,8 @@
|
|||||||
"hex.builtin.popup.save_layout.title": "Layout speichern",
|
"hex.builtin.popup.save_layout.title": "Layout speichern",
|
||||||
"hex.builtin.popup.waiting_for_tasks.desc": "Einige Tasks laufen immer noch im Hintergrund.\nImHex wird geschlossen, nachdem diese Abgeschlossen wurden.",
|
"hex.builtin.popup.waiting_for_tasks.desc": "Einige Tasks laufen immer noch im Hintergrund.\nImHex wird geschlossen, nachdem diese Abgeschlossen wurden.",
|
||||||
"hex.builtin.popup.waiting_for_tasks.title": "Warten auf Tasks",
|
"hex.builtin.popup.waiting_for_tasks.title": "Warten auf Tasks",
|
||||||
|
"hex.builtin.provider.rename": "Umbenennen",
|
||||||
|
"hex.builtin.provider.rename.desc": "Gib einen neuen Namen für die Datei ein",
|
||||||
"hex.builtin.provider.base64": "Base64",
|
"hex.builtin.provider.base64": "Base64",
|
||||||
"hex.builtin.provider.disk": "Datenträger Provider",
|
"hex.builtin.provider.disk": "Datenträger Provider",
|
||||||
"hex.builtin.provider.disk.disk_size": "Datenträgergrösse",
|
"hex.builtin.provider.disk.disk_size": "Datenträgergrösse",
|
||||||
@ -421,8 +423,6 @@
|
|||||||
"hex.builtin.provider.intel_hex": "Intel Hex Provider",
|
"hex.builtin.provider.intel_hex": "Intel Hex Provider",
|
||||||
"hex.builtin.provider.intel_hex.name": "Intel Hex {0}",
|
"hex.builtin.provider.intel_hex.name": "Intel Hex {0}",
|
||||||
"hex.builtin.provider.mem_file": "RAM Datei",
|
"hex.builtin.provider.mem_file": "RAM Datei",
|
||||||
"hex.builtin.provider.mem_file.rename": "Umbenennen",
|
|
||||||
"hex.builtin.provider.mem_file.rename.desc": "Gib einen neuen Namen für die Datei ein",
|
|
||||||
"hex.builtin.provider.mem_file.unsaved": "Ungespeicherte Datei",
|
"hex.builtin.provider.mem_file.unsaved": "Ungespeicherte Datei",
|
||||||
"hex.builtin.provider.motorola_srec": "Motorola SREC Provider",
|
"hex.builtin.provider.motorola_srec": "Motorola SREC Provider",
|
||||||
"hex.builtin.provider.motorola_srec.name": "Motorola SREC {0}",
|
"hex.builtin.provider.motorola_srec.name": "Motorola SREC {0}",
|
||||||
|
@ -383,6 +383,8 @@
|
|||||||
"hex.builtin.popup.save_layout.title": "Save Layout",
|
"hex.builtin.popup.save_layout.title": "Save Layout",
|
||||||
"hex.builtin.popup.save_layout.desc": "Enter a name under which to save the current layout.",
|
"hex.builtin.popup.save_layout.desc": "Enter a name under which to save the current layout.",
|
||||||
"hex.builtin.popup.waiting_for_tasks.desc": "There are still tasks running in the background.\nImHex will close after they are finished.",
|
"hex.builtin.popup.waiting_for_tasks.desc": "There are still tasks running in the background.\nImHex will close after they are finished.",
|
||||||
|
"hex.builtin.provider.rename": "Rename",
|
||||||
|
"hex.builtin.provider.rename.desc": "Enter a name for this provider.",
|
||||||
"hex.builtin.provider.tooltip.show_more": "Hold SHIFT for more information",
|
"hex.builtin.provider.tooltip.show_more": "Hold SHIFT for more information",
|
||||||
"hex.builtin.provider.error.open": "Failed to open provider: {}",
|
"hex.builtin.provider.error.open": "Failed to open provider: {}",
|
||||||
"hex.builtin.provider.base64": "Base64 Provider",
|
"hex.builtin.provider.base64": "Base64 Provider",
|
||||||
@ -415,8 +417,6 @@
|
|||||||
"hex.builtin.provider.intel_hex.name": "Intel Hex {0}",
|
"hex.builtin.provider.intel_hex.name": "Intel Hex {0}",
|
||||||
"hex.builtin.provider.mem_file": "Memory File",
|
"hex.builtin.provider.mem_file": "Memory File",
|
||||||
"hex.builtin.provider.mem_file.unsaved": "Unsaved File",
|
"hex.builtin.provider.mem_file.unsaved": "Unsaved File",
|
||||||
"hex.builtin.provider.mem_file.rename": "Rename",
|
|
||||||
"hex.builtin.provider.mem_file.rename.desc": "Enter a name for this memory file.",
|
|
||||||
"hex.builtin.provider.motorola_srec": "Motorola SREC Provider",
|
"hex.builtin.provider.motorola_srec": "Motorola SREC Provider",
|
||||||
"hex.builtin.provider.motorola_srec.name": "Motorola SREC {0}",
|
"hex.builtin.provider.motorola_srec.name": "Motorola SREC {0}",
|
||||||
"hex.builtin.provider.process_memory": "Process Memory Provider",
|
"hex.builtin.provider.process_memory": "Process Memory Provider",
|
||||||
|
@ -392,6 +392,8 @@
|
|||||||
"hex.builtin.popup.save_layout.title": "",
|
"hex.builtin.popup.save_layout.title": "",
|
||||||
"hex.builtin.popup.waiting_for_tasks.desc": "Aún hay tareas ejecutándose en el fondo.\nImHex se cerrará una vez hayan finalizado.",
|
"hex.builtin.popup.waiting_for_tasks.desc": "Aún hay tareas ejecutándose en el fondo.\nImHex se cerrará una vez hayan finalizado.",
|
||||||
"hex.builtin.popup.waiting_for_tasks.title": "Esperando a Procesos",
|
"hex.builtin.popup.waiting_for_tasks.title": "Esperando a Procesos",
|
||||||
|
"hex.builtin.provider.rename": "",
|
||||||
|
"hex.builtin.provider.rename.desc": "",
|
||||||
"hex.builtin.provider.base64": "",
|
"hex.builtin.provider.base64": "",
|
||||||
"hex.builtin.provider.disk": "Proveedor de Disco en Bruto",
|
"hex.builtin.provider.disk": "Proveedor de Disco en Bruto",
|
||||||
"hex.builtin.provider.disk.disk_size": "Tamaño de Disco",
|
"hex.builtin.provider.disk.disk_size": "Tamaño de Disco",
|
||||||
@ -420,8 +422,6 @@
|
|||||||
"hex.builtin.provider.intel_hex": "Proveedor de Intel Hex",
|
"hex.builtin.provider.intel_hex": "Proveedor de Intel Hex",
|
||||||
"hex.builtin.provider.intel_hex.name": "Intel Hex {0}",
|
"hex.builtin.provider.intel_hex.name": "Intel Hex {0}",
|
||||||
"hex.builtin.provider.mem_file": "Archivo de Memoria",
|
"hex.builtin.provider.mem_file": "Archivo de Memoria",
|
||||||
"hex.builtin.provider.mem_file.rename": "",
|
|
||||||
"hex.builtin.provider.mem_file.rename.desc": "",
|
|
||||||
"hex.builtin.provider.mem_file.unsaved": "Archivo No Guardado",
|
"hex.builtin.provider.mem_file.unsaved": "Archivo No Guardado",
|
||||||
"hex.builtin.provider.motorola_srec": "Proveedor de Motorola SREC",
|
"hex.builtin.provider.motorola_srec": "Proveedor de Motorola SREC",
|
||||||
"hex.builtin.provider.motorola_srec.name": "Motorola SREC {0}",
|
"hex.builtin.provider.motorola_srec.name": "Motorola SREC {0}",
|
||||||
|
@ -385,6 +385,8 @@
|
|||||||
"hex.builtin.popup.waiting_for_tasks.desc": "Egyes háttérfeladatok még folyamatban vannak.\nAz ImHex bezáródik miután minden háttérfolyamat véget ért.",
|
"hex.builtin.popup.waiting_for_tasks.desc": "Egyes háttérfeladatok még folyamatban vannak.\nAz ImHex bezáródik miután minden háttérfolyamat véget ért.",
|
||||||
"hex.builtin.provider.tooltip.show_more": "Nyomd le a SHIFT-et további információkért",
|
"hex.builtin.provider.tooltip.show_more": "Nyomd le a SHIFT-et további információkért",
|
||||||
"hex.builtin.provider.error.open": "Nem sikerült megnyitni a forrást: {}",
|
"hex.builtin.provider.error.open": "Nem sikerült megnyitni a forrást: {}",
|
||||||
|
"hex.builtin.provider.rename": "Átnevezés",
|
||||||
|
"hex.builtin.provider.rename.desc": "Add meg a memóriafájl nevét.",
|
||||||
"hex.builtin.provider.base64": "Base64 forrás",
|
"hex.builtin.provider.base64": "Base64 forrás",
|
||||||
"hex.builtin.provider.disk": "Nyers lemez forrás",
|
"hex.builtin.provider.disk": "Nyers lemez forrás",
|
||||||
"hex.builtin.provider.disk.disk_size": "Lemez mérete",
|
"hex.builtin.provider.disk.disk_size": "Lemez mérete",
|
||||||
@ -415,8 +417,6 @@
|
|||||||
"hex.builtin.provider.intel_hex.name": "Intel Hex {0}",
|
"hex.builtin.provider.intel_hex.name": "Intel Hex {0}",
|
||||||
"hex.builtin.provider.mem_file": "Memória fájl",
|
"hex.builtin.provider.mem_file": "Memória fájl",
|
||||||
"hex.builtin.provider.mem_file.unsaved": "Nem mentett fájl",
|
"hex.builtin.provider.mem_file.unsaved": "Nem mentett fájl",
|
||||||
"hex.builtin.provider.mem_file.rename": "Átnevezés",
|
|
||||||
"hex.builtin.provider.mem_file.rename.desc": "Add meg a memóriafájl nevét.",
|
|
||||||
"hex.builtin.provider.motorola_srec": "Motorola SREC forrás",
|
"hex.builtin.provider.motorola_srec": "Motorola SREC forrás",
|
||||||
"hex.builtin.provider.motorola_srec.name": "Motorola SREC {0}",
|
"hex.builtin.provider.motorola_srec.name": "Motorola SREC {0}",
|
||||||
"hex.builtin.provider.process_memory": "Folyamatmemória forrás",
|
"hex.builtin.provider.process_memory": "Folyamatmemória forrás",
|
||||||
|
@ -392,6 +392,8 @@
|
|||||||
"hex.builtin.popup.save_layout.title": "",
|
"hex.builtin.popup.save_layout.title": "",
|
||||||
"hex.builtin.popup.waiting_for_tasks.desc": "",
|
"hex.builtin.popup.waiting_for_tasks.desc": "",
|
||||||
"hex.builtin.popup.waiting_for_tasks.title": "",
|
"hex.builtin.popup.waiting_for_tasks.title": "",
|
||||||
|
"hex.builtin.provider.rename": "",
|
||||||
|
"hex.builtin.provider.rename.desc": "",
|
||||||
"hex.builtin.provider.base64": "",
|
"hex.builtin.provider.base64": "",
|
||||||
"hex.builtin.provider.disk": "Provider di dischi raw",
|
"hex.builtin.provider.disk": "Provider di dischi raw",
|
||||||
"hex.builtin.provider.disk.disk_size": "Dimensione disco",
|
"hex.builtin.provider.disk.disk_size": "Dimensione disco",
|
||||||
@ -420,8 +422,6 @@
|
|||||||
"hex.builtin.provider.intel_hex": "",
|
"hex.builtin.provider.intel_hex": "",
|
||||||
"hex.builtin.provider.intel_hex.name": "",
|
"hex.builtin.provider.intel_hex.name": "",
|
||||||
"hex.builtin.provider.mem_file": "",
|
"hex.builtin.provider.mem_file": "",
|
||||||
"hex.builtin.provider.mem_file.rename": "",
|
|
||||||
"hex.builtin.provider.mem_file.rename.desc": "",
|
|
||||||
"hex.builtin.provider.mem_file.unsaved": "",
|
"hex.builtin.provider.mem_file.unsaved": "",
|
||||||
"hex.builtin.provider.motorola_srec": "",
|
"hex.builtin.provider.motorola_srec": "",
|
||||||
"hex.builtin.provider.motorola_srec.name": "",
|
"hex.builtin.provider.motorola_srec.name": "",
|
||||||
|
@ -392,6 +392,8 @@
|
|||||||
"hex.builtin.popup.save_layout.title": "",
|
"hex.builtin.popup.save_layout.title": "",
|
||||||
"hex.builtin.popup.waiting_for_tasks.desc": "",
|
"hex.builtin.popup.waiting_for_tasks.desc": "",
|
||||||
"hex.builtin.popup.waiting_for_tasks.title": "",
|
"hex.builtin.popup.waiting_for_tasks.title": "",
|
||||||
|
"hex.builtin.provider.rename": "",
|
||||||
|
"hex.builtin.provider.rename.desc": "",
|
||||||
"hex.builtin.provider.base64": "",
|
"hex.builtin.provider.base64": "",
|
||||||
"hex.builtin.provider.disk": "ディスクイメージ",
|
"hex.builtin.provider.disk": "ディスクイメージ",
|
||||||
"hex.builtin.provider.disk.disk_size": "ディスクサイズ",
|
"hex.builtin.provider.disk.disk_size": "ディスクサイズ",
|
||||||
@ -420,8 +422,6 @@
|
|||||||
"hex.builtin.provider.intel_hex": "",
|
"hex.builtin.provider.intel_hex": "",
|
||||||
"hex.builtin.provider.intel_hex.name": "",
|
"hex.builtin.provider.intel_hex.name": "",
|
||||||
"hex.builtin.provider.mem_file": "",
|
"hex.builtin.provider.mem_file": "",
|
||||||
"hex.builtin.provider.mem_file.rename": "",
|
|
||||||
"hex.builtin.provider.mem_file.rename.desc": "",
|
|
||||||
"hex.builtin.provider.mem_file.unsaved": "",
|
"hex.builtin.provider.mem_file.unsaved": "",
|
||||||
"hex.builtin.provider.motorola_srec": "",
|
"hex.builtin.provider.motorola_srec": "",
|
||||||
"hex.builtin.provider.motorola_srec.name": "",
|
"hex.builtin.provider.motorola_srec.name": "",
|
||||||
|
@ -392,6 +392,8 @@
|
|||||||
"hex.builtin.popup.save_layout.title": "레이아웃 저장",
|
"hex.builtin.popup.save_layout.title": "레이아웃 저장",
|
||||||
"hex.builtin.popup.waiting_for_tasks.desc": "아직 백그라운드에서 실행 중인 작업이 있습니다.\n작업이 완료되면 ImHex가 닫힙니다.",
|
"hex.builtin.popup.waiting_for_tasks.desc": "아직 백그라운드에서 실행 중인 작업이 있습니다.\n작업이 완료되면 ImHex가 닫힙니다.",
|
||||||
"hex.builtin.popup.waiting_for_tasks.title": "작업 기다리는 중",
|
"hex.builtin.popup.waiting_for_tasks.title": "작업 기다리는 중",
|
||||||
|
"hex.builtin.provider.rename": "이름 바꾸기",
|
||||||
|
"hex.builtin.provider.rename.desc": "이 메모리 파일의 이름을 입력합니다.",
|
||||||
"hex.builtin.provider.base64": "",
|
"hex.builtin.provider.base64": "",
|
||||||
"hex.builtin.provider.disk": "Raw 디스크 공급자",
|
"hex.builtin.provider.disk": "Raw 디스크 공급자",
|
||||||
"hex.builtin.provider.disk.disk_size": "디스크 크기",
|
"hex.builtin.provider.disk.disk_size": "디스크 크기",
|
||||||
@ -420,8 +422,6 @@
|
|||||||
"hex.builtin.provider.intel_hex": "인텔 Hex 공급자",
|
"hex.builtin.provider.intel_hex": "인텔 Hex 공급자",
|
||||||
"hex.builtin.provider.intel_hex.name": "인텔 Hex {0}",
|
"hex.builtin.provider.intel_hex.name": "인텔 Hex {0}",
|
||||||
"hex.builtin.provider.mem_file": "메모리 파일",
|
"hex.builtin.provider.mem_file": "메모리 파일",
|
||||||
"hex.builtin.provider.mem_file.rename": "이름 바꾸기",
|
|
||||||
"hex.builtin.provider.mem_file.rename.desc": "이 메모리 파일의 이름을 입력합니다.",
|
|
||||||
"hex.builtin.provider.mem_file.unsaved": "저장되지 않은 파일",
|
"hex.builtin.provider.mem_file.unsaved": "저장되지 않은 파일",
|
||||||
"hex.builtin.provider.motorola_srec": "모토로라 SREC 공급자",
|
"hex.builtin.provider.motorola_srec": "모토로라 SREC 공급자",
|
||||||
"hex.builtin.provider.motorola_srec.name": "모토로라 SREC {0}",
|
"hex.builtin.provider.motorola_srec.name": "모토로라 SREC {0}",
|
||||||
|
@ -392,6 +392,8 @@
|
|||||||
"hex.builtin.popup.save_layout.title": "",
|
"hex.builtin.popup.save_layout.title": "",
|
||||||
"hex.builtin.popup.waiting_for_tasks.desc": "",
|
"hex.builtin.popup.waiting_for_tasks.desc": "",
|
||||||
"hex.builtin.popup.waiting_for_tasks.title": "",
|
"hex.builtin.popup.waiting_for_tasks.title": "",
|
||||||
|
"hex.builtin.provider.rename": "",
|
||||||
|
"hex.builtin.provider.rename.desc": "",
|
||||||
"hex.builtin.provider.base64": "",
|
"hex.builtin.provider.base64": "",
|
||||||
"hex.builtin.provider.disk": "Provedor de disco bruto",
|
"hex.builtin.provider.disk": "Provedor de disco bruto",
|
||||||
"hex.builtin.provider.disk.disk_size": "Tamanho do Disco",
|
"hex.builtin.provider.disk.disk_size": "Tamanho do Disco",
|
||||||
@ -420,8 +422,6 @@
|
|||||||
"hex.builtin.provider.intel_hex": "",
|
"hex.builtin.provider.intel_hex": "",
|
||||||
"hex.builtin.provider.intel_hex.name": "",
|
"hex.builtin.provider.intel_hex.name": "",
|
||||||
"hex.builtin.provider.mem_file": "",
|
"hex.builtin.provider.mem_file": "",
|
||||||
"hex.builtin.provider.mem_file.rename": "",
|
|
||||||
"hex.builtin.provider.mem_file.rename.desc": "",
|
|
||||||
"hex.builtin.provider.mem_file.unsaved": "",
|
"hex.builtin.provider.mem_file.unsaved": "",
|
||||||
"hex.builtin.provider.motorola_srec": "",
|
"hex.builtin.provider.motorola_srec": "",
|
||||||
"hex.builtin.provider.motorola_srec.name": "",
|
"hex.builtin.provider.motorola_srec.name": "",
|
||||||
|
@ -427,6 +427,8 @@
|
|||||||
"hex.builtin.popup.save_layout.title": "保存布局",
|
"hex.builtin.popup.save_layout.title": "保存布局",
|
||||||
"hex.builtin.popup.waiting_for_tasks.desc": "仍有任务在后台运行。\nImHex 将在完成后关闭。",
|
"hex.builtin.popup.waiting_for_tasks.desc": "仍有任务在后台运行。\nImHex 将在完成后关闭。",
|
||||||
"hex.builtin.popup.waiting_for_tasks.title": "等待任务进行",
|
"hex.builtin.popup.waiting_for_tasks.title": "等待任务进行",
|
||||||
|
"hex.builtin.provider.rename": "重命名",
|
||||||
|
"hex.builtin.provider.rename.desc": "输入此内存文件的名称。",
|
||||||
"hex.builtin.provider.base64": "Base64",
|
"hex.builtin.provider.base64": "Base64",
|
||||||
"hex.builtin.provider.disk": "原始磁盘",
|
"hex.builtin.provider.disk": "原始磁盘",
|
||||||
"hex.builtin.provider.disk.disk_size": "磁盘大小",
|
"hex.builtin.provider.disk.disk_size": "磁盘大小",
|
||||||
@ -457,8 +459,6 @@
|
|||||||
"hex.builtin.provider.intel_hex": "Intel Hex",
|
"hex.builtin.provider.intel_hex": "Intel Hex",
|
||||||
"hex.builtin.provider.intel_hex.name": "Intel Hex {0}",
|
"hex.builtin.provider.intel_hex.name": "Intel Hex {0}",
|
||||||
"hex.builtin.provider.mem_file": "临时文件",
|
"hex.builtin.provider.mem_file": "临时文件",
|
||||||
"hex.builtin.provider.mem_file.rename": "重命名",
|
|
||||||
"hex.builtin.provider.mem_file.rename.desc": "输入此内存文件的名称。",
|
|
||||||
"hex.builtin.provider.mem_file.unsaved": "未保存的文件",
|
"hex.builtin.provider.mem_file.unsaved": "未保存的文件",
|
||||||
"hex.builtin.provider.motorola_srec": "Motorola SREC",
|
"hex.builtin.provider.motorola_srec": "Motorola SREC",
|
||||||
"hex.builtin.provider.motorola_srec.name": "Motorola SREC {0}",
|
"hex.builtin.provider.motorola_srec.name": "Motorola SREC {0}",
|
||||||
|
@ -393,6 +393,8 @@
|
|||||||
"hex.builtin.popup.waiting_for_tasks.desc": "還有工作在背景執行。\nImHex 將在工作完成後關閉。",
|
"hex.builtin.popup.waiting_for_tasks.desc": "還有工作在背景執行。\nImHex 將在工作完成後關閉。",
|
||||||
"hex.builtin.popup.waiting_for_tasks.title": "正在等待工作完成",
|
"hex.builtin.popup.waiting_for_tasks.title": "正在等待工作完成",
|
||||||
"hex.builtin.provider.base64": "",
|
"hex.builtin.provider.base64": "",
|
||||||
|
"hex.builtin.provider.rename": "重新命名",
|
||||||
|
"hex.builtin.provider.rename.desc": "",
|
||||||
"hex.builtin.provider.disk": "原始磁碟提供者",
|
"hex.builtin.provider.disk": "原始磁碟提供者",
|
||||||
"hex.builtin.provider.disk.disk_size": "磁碟大小",
|
"hex.builtin.provider.disk.disk_size": "磁碟大小",
|
||||||
"hex.builtin.provider.disk.elevation": "",
|
"hex.builtin.provider.disk.elevation": "",
|
||||||
@ -420,8 +422,6 @@
|
|||||||
"hex.builtin.provider.intel_hex": "Intel Hex 提供者",
|
"hex.builtin.provider.intel_hex": "Intel Hex 提供者",
|
||||||
"hex.builtin.provider.intel_hex.name": "Intel Hex {0}",
|
"hex.builtin.provider.intel_hex.name": "Intel Hex {0}",
|
||||||
"hex.builtin.provider.mem_file": "記憶體檔案",
|
"hex.builtin.provider.mem_file": "記憶體檔案",
|
||||||
"hex.builtin.provider.mem_file.rename": "重新命名",
|
|
||||||
"hex.builtin.provider.mem_file.rename.desc": "Enter a name for this memory file.",
|
|
||||||
"hex.builtin.provider.mem_file.unsaved": "未儲存的檔案",
|
"hex.builtin.provider.mem_file.unsaved": "未儲存的檔案",
|
||||||
"hex.builtin.provider.motorola_srec": "Motorola SREC 提供者",
|
"hex.builtin.provider.motorola_srec": "Motorola SREC 提供者",
|
||||||
"hex.builtin.provider.motorola_srec.name": "Motorola SREC {0}",
|
"hex.builtin.provider.motorola_srec.name": "Motorola SREC {0}",
|
||||||
|
@ -108,7 +108,7 @@ namespace hex::plugin::builtin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MemoryFileProvider::renameFile() {
|
void MemoryFileProvider::renameFile() {
|
||||||
ui::PopupTextInput::open("hex.builtin.provider.mem_file.rename", "hex.builtin.provider.mem_file.rename.desc", [this](const std::string &name) {
|
ui::PopupTextInput::open("hex.builtin.provider.rename", "hex.builtin.provider.rename.desc", [this](const std::string &name) {
|
||||||
m_name = name;
|
m_name = name;
|
||||||
RequestUpdateWindowTitle::post();
|
RequestUpdateWindowTitle::post();
|
||||||
});
|
});
|
||||||
|
180
plugins/builtin/source/content/providers/view_provider.cpp
Normal file
180
plugins/builtin/source/content/providers/view_provider.cpp
Normal file
@ -0,0 +1,180 @@
|
|||||||
|
#include <content/providers/view_provider.hpp>
|
||||||
|
|
||||||
|
#include <hex/helpers/fmt.hpp>
|
||||||
|
|
||||||
|
#include <hex/api/event_manager.hpp>
|
||||||
|
#include <popups/popup_text_input.hpp>
|
||||||
|
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
namespace hex::plugin::builtin {
|
||||||
|
|
||||||
|
[[nodiscard]] bool ViewProvider::isAvailable() const {
|
||||||
|
if (m_provider == nullptr)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return m_provider->isAvailable();
|
||||||
|
}
|
||||||
|
[[nodiscard]] bool ViewProvider::isReadable() const {
|
||||||
|
if (m_provider == nullptr)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return m_provider->isReadable();
|
||||||
|
}
|
||||||
|
[[nodiscard]] bool ViewProvider::isWritable() const {
|
||||||
|
if (m_provider == nullptr)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return m_provider->isWritable();
|
||||||
|
}
|
||||||
|
[[nodiscard]] bool ViewProvider::isResizable() const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool ViewProvider::isSavable() const {
|
||||||
|
if (m_provider == nullptr)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return m_provider->isSavable();
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool ViewProvider::isSavableAsRecent() const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewProvider::save() {
|
||||||
|
m_provider->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool ViewProvider::open() {
|
||||||
|
if (m_provider == this)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
EventProviderClosing::subscribe(this, [this](const prv::Provider *provider, bool*) {
|
||||||
|
if (m_provider == provider)
|
||||||
|
ImHexApi::Provider::remove(this, false);
|
||||||
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void ViewProvider::close() {
|
||||||
|
EventProviderClosing::unsubscribe(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewProvider::resizeRaw(u64 newSize) {
|
||||||
|
m_size = newSize;
|
||||||
|
}
|
||||||
|
void ViewProvider::insertRaw(u64 offset, u64 size) {
|
||||||
|
if (m_provider == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_size += size;
|
||||||
|
m_provider->insert(offset + m_startAddress, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewProvider::removeRaw(u64 offset, u64 size) {
|
||||||
|
if (m_provider == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_size -= size;
|
||||||
|
m_provider->remove(offset + m_startAddress, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewProvider::readRaw(u64 offset, void *buffer, size_t size) {
|
||||||
|
if (m_provider == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_provider->read(offset + m_startAddress, buffer, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewProvider::writeRaw(u64 offset, const void *buffer, size_t size) {
|
||||||
|
if (m_provider == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_provider->write(offset + m_startAddress, buffer, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] u64 ViewProvider::getActualSize() const {
|
||||||
|
return m_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] std::string ViewProvider::getName() const {
|
||||||
|
if (!m_name.empty())
|
||||||
|
return m_name;
|
||||||
|
|
||||||
|
if (m_provider == nullptr)
|
||||||
|
return "View";
|
||||||
|
else
|
||||||
|
return hex::format("{} View", m_provider->getName());
|
||||||
|
}
|
||||||
|
[[nodiscard]] std::vector<ViewProvider::Description> ViewProvider::getDataDescription() const {
|
||||||
|
if (m_provider == nullptr)
|
||||||
|
return { };
|
||||||
|
|
||||||
|
return m_provider->getDataDescription();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewProvider::loadSettings(const nlohmann::json &settings) {
|
||||||
|
Provider::loadSettings(settings);
|
||||||
|
|
||||||
|
auto id = settings.at("id").get<u64>();
|
||||||
|
m_startAddress = settings.at("start_address").get<u64>();
|
||||||
|
m_size = settings.at("size").get<size_t>();
|
||||||
|
|
||||||
|
const auto &providers = ImHexApi::Provider::getProviders();
|
||||||
|
auto provider = std::ranges::find_if(providers, [id](const prv::Provider *provider) {
|
||||||
|
return provider->getID() == id;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (provider == providers.end())
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_provider = *provider;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] nlohmann::json ViewProvider::storeSettings(nlohmann::json settings) const {
|
||||||
|
settings["id"] = m_provider->getID();
|
||||||
|
settings["start_address"] = m_startAddress;
|
||||||
|
settings["size"] = m_size;
|
||||||
|
|
||||||
|
return Provider::storeSettings(settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] std::string ViewProvider::getTypeName() const {
|
||||||
|
return "hex.builtin.provider.view";
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewProvider::setProvider(u64 startAddress, size_t size, hex::prv::Provider *provider) {
|
||||||
|
m_startAddress = startAddress;
|
||||||
|
m_size = size;
|
||||||
|
m_provider = provider;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewProvider::setName(const std::string& name) {
|
||||||
|
m_name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[[nodiscard]] std::pair<Region, bool> ViewProvider::getRegionValidity(u64 address) const {
|
||||||
|
address -= this->getBaseAddress();
|
||||||
|
|
||||||
|
if (address < this->getActualSize())
|
||||||
|
return { Region { this->getBaseAddress() + address, this->getActualSize() - address }, true };
|
||||||
|
else
|
||||||
|
return { Region::Invalid(), false };
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<prv::Provider::MenuEntry> ViewProvider::getMenuEntries() {
|
||||||
|
return {
|
||||||
|
MenuEntry { Lang("hex.builtin.provider.rename"), [this] { this->renameFile(); } }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewProvider::renameFile() {
|
||||||
|
ui::PopupTextInput::open("hex.builtin.provider.rename", "hex.builtin.provider.rename.desc", [this](const std::string &name) {
|
||||||
|
m_name = name;
|
||||||
|
RequestUpdateWindowTitle::post();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -345,10 +345,12 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
// Draw open in new view button
|
// Draw open in new view button
|
||||||
if (ImGuiExt::DimmedIconButton(ICON_VS_GO_TO_FILE, ImGui::GetStyleColorVec4(ImGuiCol_Text))) {
|
if (ImGuiExt::DimmedIconButton(ICON_VS_GO_TO_FILE, ImGui::GetStyleColorVec4(ImGuiCol_Text))) {
|
||||||
TaskManager::doLater([region, provider]{
|
TaskManager::doLater([region, provider, name]{
|
||||||
auto newProvider = ImHexApi::Provider::createProvider("hex.builtin.provider.view", true);
|
auto newProvider = ImHexApi::Provider::createProvider("hex.builtin.provider.view", true);
|
||||||
if (auto *viewProvider = dynamic_cast<ViewProvider*>(newProvider); viewProvider != nullptr) {
|
if (auto *viewProvider = dynamic_cast<ViewProvider*>(newProvider); viewProvider != nullptr) {
|
||||||
viewProvider->setProvider(region.getStartAddress(), region.getSize(), provider);
|
viewProvider->setProvider(region.getStartAddress(), region.getSize(), provider);
|
||||||
|
viewProvider->setName(hex::format("'{}' View", name));
|
||||||
|
|
||||||
if (viewProvider->open()) {
|
if (viewProvider->open()) {
|
||||||
EventProviderOpened::post(viewProvider);
|
EventProviderOpened::post(viewProvider);
|
||||||
AchievementManager::unlockAchievement("hex.builtin.achievement.hex_editor", "hex.builtin.achievement.hex_editor.open_new_view.name");
|
AchievementManager::unlockAchievement("hex.builtin.achievement.hex_editor", "hex.builtin.achievement.hex_editor.open_new_view.name");
|
||||||
|
Loading…
Reference in New Issue
Block a user