1
0
mirror of synced 2025-01-29 19:17:28 +01:00

Make sure important data is synchronized between ImHex and plugins

This commit is contained in:
WerWolv 2021-01-04 00:19:56 +01:00
parent c7c654d310
commit eed7ef1ac3
24 changed files with 148 additions and 113 deletions

View File

@ -14,12 +14,12 @@ namespace hex {
Plugin(std::string_view path);
~Plugin();
void initializePlugin(ImGuiContext *ctx, prv::Provider **provider) const;
void initializePlugin(SharedData &sharedData) const;
View* createView() const;
void drawToolsEntry() const;
private:
using InitializePluginFunc = void(*)(ImGuiContext*, hex::prv::Provider**);
using InitializePluginFunc = void(*)(SharedData &sharedData);
using CreateViewFunc = View*(*)();
using DrawToolsEntryFunc = void(*)();

View File

@ -30,12 +30,9 @@ namespace hex {
class EventManager {
public:
void post(Events eventType, const void *userData);
void subscribe(Events eventType, void *owner, std::function<void(const void*)> callback);
void unsubscribe(Events eventType, void *sender);
private:
std::vector<EventHandler> m_eventHandlers;
static void post(Events eventType, const void *userData);
static void subscribe(Events eventType, void *owner, std::function<void(const void*)> callback);
static void unsubscribe(Events eventType, void *sender);
};
}

View File

@ -0,0 +1,71 @@
#pragma once
#include <functional>
#include <vector>
#include <helpers/event.hpp>
#include <imgui.h>
namespace hex { class SharedData; }
namespace hex::plugin::internal {
void initializePlugin(SharedData &sharedData);
}
namespace hex {
namespace prv { class Provider; }
class SharedData {
SharedData() = default;
public:
SharedData(const SharedData&) = delete;
SharedData(SharedData&&) = delete;
static auto& get() {
static SharedData instance;
return instance;
}
friend void hex::plugin::internal::initializePlugin(SharedData &sharedData);
friend class Window;
private:
void initializeData() {
static std::vector<EventHandler> eventHandlersStorage;
static std::vector<std::function<void()>> deferredCallsStorage;
static prv::Provider *currentProviderStorage;
static ImVec2 windowPosStorage, windowSizeStorage;
this->imguiContext = ImGui::GetCurrentContext();
this->eventHandlers = &eventHandlersStorage;
this->deferredCalls = &deferredCallsStorage;
this->currentProvider = &currentProviderStorage;
this->windowPos = &windowPosStorage;
this->windowSize = &windowSizeStorage;
}
void initializeData(const SharedData &other) {
this->imguiContext = other.imguiContext;
this->eventHandlers = other.eventHandlers;
this->deferredCalls = other.deferredCalls;
this->currentProvider = other.currentProvider;
this->windowPos = other.windowPos;
this->windowSize = other.windowSize;
}
public:
ImGuiContext *imguiContext;
std::vector<EventHandler> *eventHandlers;
std::vector<std::function<void()>> *deferredCalls;
prv::Provider **currentProvider;
ImVec2 *windowPos;
ImVec2 *windowSize;
};
}

View File

@ -6,13 +6,13 @@
#include <hex.hpp>
#include <views/view.hpp>
#include <providers/provider.hpp>
#include <helpers/shared_data.hpp>
#define IMHEX_PLUGIN namespace hex::plugin::internal { \
void initializePlugin(ImGuiContext *ctx, hex::prv::Provider **provider) { \
if (glGetString == NULL) \
gladLoadGL(); \
ImGui::SetCurrentContext(ctx); \
hex::prv::Provider::setProviderStorage(*provider); \
} \
} \
#define IMHEX_PLUGIN namespace hex::plugin::internal { \
void initializePlugin(SharedData &sharedData) { \
if (glGetString == NULL) \
gladLoadGL(); \
SharedData::get().initializeData(sharedData); \
} \
} \
namespace hex::plugin

View File

@ -7,6 +7,8 @@
#include <string>
#include <vector>
#include <helpers/shared_data.hpp>
namespace hex::prv {
class Provider {
@ -40,20 +42,10 @@ namespace hex::prv {
virtual std::vector<std::pair<std::string, std::string>> getDataInformation() = 0;
static void setProviderStorage(Provider* &provider) {
Provider::s_currProvider = &provider;
}
static Provider*& getCurrentProvider() {
return *Provider::s_currProvider;
}
protected:
u32 m_currPage = 0;
std::vector<std::map<u64, u8>> m_patches;
static inline Provider **s_currProvider = nullptr;
};
}

View File

@ -30,14 +30,6 @@ namespace hex {
static void showErrorPopup(std::string_view errorMessage);
static void setWindowPosition(s32 x, s32 y);
static const ImVec2& getWindowPosition();
static void setWindowSize(s32 width, s32 height);
static const ImVec2& getWindowSize();
virtual bool hasViewMenuItemEntry();
virtual ImVec2 getMinSize();
virtual ImVec2 getMaxSize();
@ -55,17 +47,12 @@ namespace hex {
protected:
void confirmButtons(const char *textLeft, const char *textRight, std::function<void()> leftButtonFn, std::function<void()> rightButtonFn);
private:
std::string m_viewName;
bool m_windowOpen = false;
static inline EventManager s_eventManager;
static inline std::vector<std::function<void()>> s_deferedCalls;
static inline std::string s_errorMessage;
static inline ImVec2 s_windowPos;
static inline ImVec2 s_windowSize;
};
}

View File

@ -1,23 +1,25 @@
#include "helpers/event.hpp"
#include <helpers/shared_data.hpp>
namespace hex {
void EventManager::post(Events eventType, const void *userData) {
for (auto &handler : this->m_eventHandlers)
for (auto &handler : *SharedData::get().eventHandlers)
if (eventType == handler.eventType)
handler.callback(userData);
}
void EventManager::subscribe(Events eventType, void *owner, std::function<void(const void*)> callback) {
for (auto &handler : this->m_eventHandlers)
for (auto &handler : *SharedData::get().eventHandlers)
if (eventType == handler.eventType && owner == handler.owner)
return;
this->m_eventHandlers.push_back(EventHandler { owner, eventType, callback });
SharedData::get().eventHandlers->push_back(EventHandler { owner, eventType, callback });
}
void EventManager::unsubscribe(Events eventType, void *sender) {
std::erase_if(this->m_eventHandlers, [&eventType, &sender](EventHandler handler) {
std::erase_if(*SharedData::get().eventHandlers, [&eventType, &sender](EventHandler handler) {
return eventType == handler.eventType && sender == handler.owner;
});
}

View File

@ -6,6 +6,8 @@
#include <string>
#include <vector>
#include <helpers/shared_data.hpp>
namespace hex {
@ -15,11 +17,11 @@ namespace hex {
bool View::handleShortcut(int key, int mods) { return false; }
std::vector<std::function<void()>>& View::getDeferedCalls() {
return View::s_deferedCalls;
return *SharedData::get().deferredCalls;
}
void View::postEvent(Events eventType, const void *userData) {
View::s_eventManager.post(eventType, userData);
EventManager::post(eventType, userData);
}
void View::drawCommonInterfaces() {
@ -44,22 +46,6 @@ namespace hex {
ImGui::OpenPopup("Error");
}
void View::setWindowPosition(s32 x, s32 y) {
View::s_windowPos = ImVec2(x, y);
}
const ImVec2& View::getWindowPosition() {
return View::s_windowPos;
}
void View::setWindowSize(s32 width, s32 height) {
View::s_windowSize = ImVec2(width, height);
}
const ImVec2& View::getWindowSize() {
return View::s_windowSize;
}
bool View::hasViewMenuItemEntry() {
return true;
}
@ -82,15 +68,15 @@ namespace hex {
}
void View::subscribeEvent(Events eventType, std::function<void(const void*)> callback) {
View::s_eventManager.subscribe(eventType, this, callback);
EventManager::subscribe(eventType, this, callback);
}
void View::unsubscribeEvent(Events eventType) {
View::s_eventManager.unsubscribe(eventType, this);
EventManager::unsubscribe(eventType, this);
}
void View::doLater(std::function<void()> &&function) {
View::s_deferedCalls.push_back(function);
SharedData::get().deferredCalls->push_back(function);
}
void View::confirmButtons(const char *textLeft, const char *textRight, std::function<void()> leftButtonFn, std::function<void()> rightButtonFn) {

View File

@ -81,7 +81,7 @@ namespace hex {
return nullptr;
}
hex::ScopeExit instanceCleanup([&]{ Py_DECREF(instance); });
SCOPE_EXIT( Py_DECREF(instance); );
if (instance->ob_type->tp_base == nullptr || instance->ob_type->tp_base->tp_name != "ImHexType"s) {
PyErr_SetString(PyExc_TypeError, "class type must extend from ImHexType");
@ -106,7 +106,7 @@ namespace hex {
return nullptr;
}
hex::ScopeExit listCleanup([&]{ Py_DECREF(list); });
SCOPE_EXIT( Py_DECREF(list); );
std::string code = keyword + " " + instance->ob_type->tp_name + " {\n";

View File

@ -9,8 +9,8 @@ namespace hex {
constexpr auto CreateViewSymbol = "_ZN3hex6plugin10createViewEv";
// hex::plugin::drawToolsEntry(void)
constexpr auto DrawToolsEntrySymbol = "_ZN3hex6plugin14drawToolsEntryEv";
// hex::plugin::internal::initializePlugin(ImGuiContext*, hex::prv::Provider**)
constexpr auto InitializePluginSymbol = "_ZN3hex6plugin8internal16initializePluginEP12ImGuiContextPPNS_3prv8ProviderE";
// hex::plugin::internal::initializePlugin(SharedData&)
constexpr auto InitializePluginSymbol = "_ZN3hex6plugin8internal16initializePluginER10SharedData";
Plugin::Plugin(std::string_view path) {
this->m_handle = dlopen(path.data(), RTLD_LAZY);
@ -28,9 +28,9 @@ namespace hex {
dlclose(this->m_handle);
}
void Plugin::initializePlugin(ImGuiContext *ctx, prv::Provider **provider) const {
void Plugin::initializePlugin(SharedData &sharedData) const {
if (this->m_initializePluginFunction != nullptr)
this->m_initializePluginFunction(ctx, provider);
this->m_initializePluginFunction(sharedData);
}
View* Plugin::createView() const {

View File

@ -31,8 +31,6 @@ int main(int argc, char **argv) {
// Shared Data
std::vector<hex::lang::PatternData*> patternData;
hex::prv::Provider *dataProvider = nullptr;
hex::prv::Provider::setProviderStorage(dataProvider);
// Create views
window.addView<hex::ViewHexEditor>(patternData);

View File

@ -55,7 +55,7 @@ namespace hex {
{
u8 bytes[10] = { 0 };
prv::Provider::getCurrentProvider()->read(region.address, bytes, std::min(region.size, size_t(10)));
(*SharedData::get().currentProvider)->read(region.address, bytes, std::min(region.size, size_t(10)));
std::string bytesString;
for (u8 i = 0; i < std::min(region.size, size_t(10)); i++) {

View File

@ -19,8 +19,8 @@ namespace hex {
void ViewCommandPalette::drawContent() {
auto windowPos = View::getWindowPosition();
auto windowSize = View::getWindowSize();
auto windowPos = *SharedData::get().windowPos;
auto windowSize = *SharedData::get().windowSize;
auto paletteSize = this->getMinSize();
ImGui::SetNextWindowPos(ImVec2(windowPos.x + (windowSize.x - paletteSize.x) / 2.0F, windowPos.y), ImGuiCond_Always);
if (ImGui::BeginPopup("Command Palette")) {

View File

@ -13,7 +13,7 @@ namespace hex {
View::subscribeEvent(Events::RegionSelected, [this](const void* userData){
Region region = *static_cast<const Region*>(userData);
auto provider = prv::Provider::getCurrentProvider();
auto provider = *SharedData::get().currentProvider;
if (provider == nullptr) {
this->m_validBytes = 0;
@ -137,7 +137,7 @@ namespace hex {
if (ImGui::Begin("Data Inspector", &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
auto provider = prv::Provider::getCurrentProvider();
auto provider = *SharedData::get().currentProvider;
if (provider != nullptr && provider->isReadable()) {
if (ImGui::BeginTable("##datainspector", 2,

View File

@ -51,7 +51,7 @@ namespace hex {
if (cs_open(Disassembler::toCapstoneArchictecture(this->m_architecture), mode, &capstoneHandle) == CS_ERR_OK) {
auto provider = prv::Provider::getCurrentProvider();
auto provider = *SharedData::get().currentProvider;
std::vector<u8> buffer(2048, 0x00);
for (u64 address = 0; address < (this->m_codeRegion[1] - this->m_codeRegion[0] + 1); address += 2048) {
size_t bufferSize = std::min(u64(2048), (this->m_codeRegion[1] - this->m_codeRegion[0] + 1) - address);
@ -95,7 +95,7 @@ namespace hex {
if (ImGui::Begin("Disassembler", &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
auto provider = prv::Provider::getCurrentProvider();
auto provider = *SharedData::get().currentProvider;
if (provider != nullptr && provider->isReadable()) {
ImGui::TextUnformatted("Position");
ImGui::Separator();

View File

@ -41,7 +41,7 @@ namespace hex {
if (ImGui::Begin("Hashing", &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
ImGui::BeginChild("##scrolling", ImVec2(0, 0), false, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoNav);
auto provider = prv::Provider::getCurrentProvider();
auto provider = *SharedData::get().currentProvider;
if (provider != nullptr && provider->isAvailable()) {
ImGui::TextUnformatted("Region");

View File

@ -19,7 +19,7 @@ namespace hex {
: View("Hex Editor"), m_patternData(patternData) {
this->m_memoryEditor.ReadFn = [](const ImU8 *data, size_t off) -> ImU8 {
auto provider = prv::Provider::getCurrentProvider();
auto provider = *SharedData::get().currentProvider;
if (!provider->isAvailable() || !provider->isReadable())
return 0x00;
@ -30,7 +30,7 @@ namespace hex {
};
this->m_memoryEditor.WriteFn = [](ImU8 *data, size_t off, ImU8 d) -> void {
auto provider = prv::Provider::getCurrentProvider();
auto provider = *SharedData::get().currentProvider;
if (!provider->isAvailable() || !provider->isWritable())
return;
@ -71,7 +71,7 @@ namespace hex {
View::subscribeEvent(Events::SelectionChangeRequest, [this](const void *userData) {
const Region &region = *reinterpret_cast<const Region*>(userData);
auto provider = prv::Provider::getCurrentProvider();
auto provider = *SharedData::get().currentProvider;
auto page = provider->getPageOfAddress(region.address);
if (!page.has_value())
return;
@ -110,7 +110,7 @@ namespace hex {
}
void ViewHexEditor::drawContent() {
auto provider = prv::Provider::getCurrentProvider();
auto provider = *SharedData::get().currentProvider;
size_t dataSize = (provider == nullptr || !provider->isReadable()) ? 0x00 : provider->getSize();
@ -277,7 +277,7 @@ namespace hex {
}
void ViewHexEditor::drawMenu() {
auto provider = prv::Provider::getCurrentProvider();
auto provider = *SharedData::get().currentProvider;
if (ImGui::BeginMenu("File")) {
if (ImGui::MenuItem("Open File...", "CTRL + O")) {
@ -432,7 +432,7 @@ namespace hex {
bool ViewHexEditor::handleShortcut(int key, int mods) {
if (mods == GLFW_MOD_CONTROL && key == GLFW_KEY_S) {
auto provider = prv::Provider::getCurrentProvider();
auto provider = *SharedData::get().currentProvider;
for (const auto &[address, value] : provider->getPatches())
provider->writeRaw(address, &value, sizeof(u8));
return true;
@ -461,7 +461,7 @@ namespace hex {
void ViewHexEditor::openFile(std::string path) {
auto& provider = prv::Provider::getCurrentProvider();
auto& provider = *SharedData::get().currentProvider;
if (provider != nullptr)
delete provider;
@ -509,7 +509,7 @@ namespace hex {
}
void ViewHexEditor::copyBytes() {
auto provider = prv::Provider::getCurrentProvider();
auto provider = *SharedData::get().currentProvider;
size_t start = std::min(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd);
size_t end = std::max(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd);
@ -528,7 +528,7 @@ namespace hex {
}
void ViewHexEditor::copyString() {
auto provider = prv::Provider::getCurrentProvider();
auto provider = *SharedData::get().currentProvider;
size_t start = std::min(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd);
size_t end = std::max(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd);
@ -543,7 +543,7 @@ namespace hex {
}
void ViewHexEditor::copyLanguageArray(Language language) {
auto provider = prv::Provider::getCurrentProvider();
auto provider = *SharedData::get().currentProvider;
size_t start = std::min(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd);
size_t end = std::max(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd);
@ -645,7 +645,7 @@ namespace hex {
}
void ViewHexEditor::copyHexView() {
auto provider = prv::Provider::getCurrentProvider();
auto provider = *SharedData::get().currentProvider;
size_t start = std::min(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd);
size_t end = std::max(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd);
@ -692,7 +692,7 @@ namespace hex {
}
void ViewHexEditor::copyHexViewHTML() {
auto provider = prv::Provider::getCurrentProvider();
auto provider = *SharedData::get().currentProvider;
size_t start = std::min(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd);
size_t end = std::max(this->m_memoryEditor.DataPreviewAddr, this->m_memoryEditor.DataPreviewAddrEnd);
@ -825,7 +825,7 @@ R"(
void ViewHexEditor::drawSearchPopup() {
static auto InputCallback = [](ImGuiInputTextCallbackData* data) -> int {
auto _this = static_cast<ViewHexEditor*>(data->UserData);
auto provider = prv::Provider::getCurrentProvider();
auto provider = *SharedData::get().currentProvider;
*_this->m_lastSearchBuffer = _this->m_searchFunction(provider, data->Buf);
_this->m_lastSearchIndex = 0;
@ -837,7 +837,7 @@ R"(
};
static auto Find = [this](char *buffer) {
auto provider = prv::Provider::getCurrentProvider();
auto provider = *SharedData::get().currentProvider;
*this->m_lastSearchBuffer = this->m_searchFunction(provider, buffer);
this->m_lastSearchIndex = 0;
@ -915,7 +915,7 @@ R"(
}
void ViewHexEditor::drawGotoPopup() {
auto provider = prv::Provider::getCurrentProvider();
auto provider = *SharedData::get().currentProvider;
if (ImGui::BeginPopup("Goto")) {
ImGui::TextUnformatted("Goto");

View File

@ -49,7 +49,7 @@ namespace hex {
if (ImGui::Begin("Data Information", &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
ImGui::BeginChild("##scrolling", ImVec2(0, 0), false, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoNav);
auto provider = prv::Provider::getCurrentProvider();
auto provider = *SharedData::get().currentProvider;
if (provider != nullptr && provider->isReadable()) {
if (this->m_shouldInvalidate) {
@ -135,7 +135,7 @@ namespace hex {
if (this->m_dataValid) {
for (auto &[name, value] : prv::Provider::getCurrentProvider()->getDataInformation()) {
for (auto &[name, value] : (*SharedData::get().currentProvider)->getDataInformation()) {
ImGui::LabelText(name.c_str(), "%s", value.c_str());
}

View File

@ -13,13 +13,13 @@ namespace hex {
ViewPatches::ViewPatches() : View("Patches") {
View::subscribeEvent(Events::ProjectFileStore, [this](const void*) {
auto provider = prv::Provider::getCurrentProvider();
auto provider = *SharedData::get().currentProvider;
if (provider != nullptr)
ProjectFile::setPatches(provider->getPatches());
});
View::subscribeEvent(Events::ProjectFileLoad, [this](const void*) {
auto provider = prv::Provider::getCurrentProvider();
auto provider = *SharedData::get().currentProvider;
if (provider != nullptr)
provider->getPatches() = ProjectFile::getPatches();
});
@ -32,7 +32,7 @@ namespace hex {
void ViewPatches::drawContent() {
if (ImGui::Begin("Patches", &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
auto provider = prv::Provider::getCurrentProvider();
auto provider = *SharedData::get().currentProvider;
if (provider != nullptr && provider->isReadable()) {

View File

@ -109,7 +109,7 @@ namespace hex {
if (error)
return;
auto provider = prv::Provider::getCurrentProvider();
auto provider = *SharedData::get().currentProvider;
if (provider == nullptr)
return;
@ -182,7 +182,7 @@ namespace hex {
void ViewPattern::drawContent() {
if (ImGui::Begin("Pattern", &this->getWindowOpenState(), ImGuiWindowFlags_None | ImGuiWindowFlags_NoCollapse)) {
auto provider = prv::Provider::getCurrentProvider();
auto provider = *SharedData::get().currentProvider;
if (provider != nullptr && provider->isAvailable()) {
this->m_textEditor.Render("Pattern");
@ -303,7 +303,7 @@ namespace hex {
return;
}
auto provider = prv::Provider::getCurrentProvider();
auto provider = *SharedData::get().currentProvider;
hex::lang::Evaluator evaluator(provider, defaultDataEndianess);
auto patternData = evaluator.evaluate(ast.value());
if (!patternData.has_value()) {

View File

@ -50,7 +50,7 @@ namespace hex {
void ViewPatternData::drawContent() {
if (ImGui::Begin("Pattern Data", &this->getWindowOpenState(), ImGuiWindowFlags_NoCollapse)) {
auto provider = prv::Provider::getCurrentProvider();
auto provider = *SharedData::get().currentProvider;
if (provider != nullptr && provider->isReadable()) {
if (beginPatternDataTable(provider, this->m_patternData, this->m_sortedPatternData)) {

View File

@ -47,7 +47,7 @@ namespace hex {
void ViewStrings::drawContent() {
auto provider = prv::Provider::getCurrentProvider();
auto provider = *SharedData::get().currentProvider;
if (this->m_shouldInvalidate) {
this->m_shouldInvalidate = false;

View File

@ -42,7 +42,7 @@ namespace hex {
this->m_mathEvaluator.setFunction("read", [this](auto args) -> std::optional<long double> {
u8 value = 0;
auto provider = prv::Provider::getCurrentProvider();
auto provider = *SharedData::get().currentProvider;
if (provider == nullptr || !provider->isReadable() || args[0] >= provider->getActualSize())
return { };
@ -52,7 +52,7 @@ namespace hex {
}, 1, 1);
this->m_mathEvaluator.setFunction("write", [this](auto args) -> std::optional<long double> {
auto provider = prv::Provider::getCurrentProvider();
auto provider = *SharedData::get().currentProvider;
if (provider == nullptr || !provider->isWritable() || args[0] >= provider->getActualSize())
return { };

View File

@ -48,6 +48,8 @@ namespace hex {
}
Window::Window() {
SharedData::get().initializeData();
this->initGLFW();
this->initImGui();
this->initPlugins();
@ -282,21 +284,21 @@ namespace hex {
{
int x = 0, y = 0;
glfwGetWindowPos(this->m_window, &x, &y);
View::setWindowPosition(x, y);
*SharedData::get().windowPos = ImVec2(x, y);
}
{
int width = 0, height = 0;
glfwGetWindowSize(this->m_window, &width, &height);
View::setWindowSize(width, height);
*SharedData::get().windowSize = ImVec2(width, height);
}
glfwSetWindowPosCallback(this->m_window, [](GLFWwindow *window, int x, int y) {
View::setWindowPosition(x, y);
*SharedData::get().windowPos = ImVec2(x, y);
});
glfwSetWindowSizeCallback(this->m_window, [](GLFWwindow *window, int width, int height) {
View::setWindowSize(width, height);
*SharedData::get().windowSize = ImVec2(width, height);
});
glfwSetKeyCallback(this->m_window, [](GLFWwindow *window, int key, int scancode, int action, int mods) {
@ -377,7 +379,7 @@ namespace hex {
PluginHandler::load((std::filesystem::path(mainArgv[0]).parent_path() / "plugins").string());
for (const auto &plugin : PluginHandler::getPlugins()) {
plugin.initializePlugin(ImGui::GetCurrentContext(), &prv::Provider::getCurrentProvider());
plugin.initializePlugin(SharedData::get());
if (auto view = plugin.createView(); view != nullptr)
this->m_pluginViews.push_back(view);
}