From 2526eda0db65fb28ed3200f4387c858bb55bbdfe Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sun, 15 Nov 2020 00:46:38 +0100 Subject: [PATCH] Added tools window --- CMakeLists.txt | 1 + include/event.hpp | 3 +- include/views/view_tools.hpp | 32 +++++++++++++++++++ source/main.cpp | 2 ++ source/views/view_help.cpp | 2 +- source/views/view_tools.cpp | 61 ++++++++++++++++++++++++++++++++++++ 6 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 include/views/view_tools.hpp create mode 100644 source/views/view_tools.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index e67582488..264bca573 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,7 @@ add_executable(ImHex source/views/view_hashes.cpp source/views/view_information.cpp source/views/view_help.cpp + source/views/view_tools.cpp libs/glad/source/glad.c diff --git a/include/event.hpp b/include/event.hpp index e735177cb..8dd2ff8fd 100644 --- a/include/event.hpp +++ b/include/event.hpp @@ -6,7 +6,8 @@ namespace hex { enum class Events { - DataChanged + DataChanged, + PatternChanged }; struct EventHandler { diff --git a/include/views/view_tools.hpp b/include/views/view_tools.hpp new file mode 100644 index 000000000..8cfcb17c0 --- /dev/null +++ b/include/views/view_tools.hpp @@ -0,0 +1,32 @@ +#pragma once + +#include + +#include "imgui.h" +#include "views/view.hpp" +#include "views/pattern_data.hpp" + +#include +#include +#include + +namespace hex { + + namespace prv { class Provider; } + + class ViewTools : public View { + public: + ViewTools(); + ~ViewTools() override; + + void createView() override; + void createMenu() override; + + private: + bool m_windowOpen = true; + + char *m_mangledBuffer = nullptr; + char *m_demangledName = nullptr; + }; + +} \ No newline at end of file diff --git a/source/main.cpp b/source/main.cpp index bcb7ada48..d1465b7d6 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -7,6 +7,7 @@ #include "views/view_hashes.hpp" #include "views/view_information.hpp" #include "views/view_help.hpp" +#include "views/view_tools.hpp" #include "providers/provider.hpp" @@ -26,6 +27,7 @@ int main() { window.addView(dataProvider); window.addView(dataProvider); window.addView(); + window.addView(); window.loop(); diff --git a/source/views/view_help.cpp b/source/views/view_help.cpp index d411b4e3d..ff62dd5e6 100644 --- a/source/views/view_help.cpp +++ b/source/views/view_help.cpp @@ -156,7 +156,7 @@ namespace hex { if (ImGui::MenuItem("About", "")) this->m_aboutWindowOpen = true; ImGui::Separator(); - if (ImGui::MenuItem("Pattern Language Cheat Sheet", "")) + if (ImGui::MenuItem("Cheat Sheet", "")) this->m_patternHelpWindowOpen = true; ImGui::EndMenu(); } diff --git a/source/views/view_tools.cpp b/source/views/view_tools.cpp new file mode 100644 index 000000000..08ab2e25e --- /dev/null +++ b/source/views/view_tools.cpp @@ -0,0 +1,61 @@ +#include "views/view_tools.hpp" + +#include +#include + +namespace hex { + + ViewTools::ViewTools() { + this->m_mangledBuffer = new char[0xFF'FFFF]; + this->m_demangledName = static_cast(malloc(8)); + + std::memset(this->m_mangledBuffer, 0xFF'FFFF, 0x00); + strcpy(this->m_demangledName, "< ??? >"); + } + + ViewTools::~ViewTools() { + delete[] this->m_mangledBuffer; + free(this->m_demangledName); + } + + void ViewTools::createView() { + if (!this->m_windowOpen) + return; + + if (ImGui::Begin("Tools", &this->m_windowOpen)) { + + ImGui::Text("Itanium demangler"); + ImGui::Separator(); + ImGui::NewLine(); + + if (ImGui::InputText("Mangled name", this->m_mangledBuffer, 0xFF'FFFF)) { + size_t length = 0; + int status = 0; + + if (this->m_demangledName != nullptr) + free(this->m_demangledName); + + this->m_demangledName = abi::__cxa_demangle(this->m_mangledBuffer, nullptr, &length, &status); + + if (status != 0) { + this->m_demangledName = static_cast(malloc(8)); + strcpy(this->m_demangledName, "< ??? >"); + } + } + + ImGui::InputText("Demangled name", this->m_demangledName, strlen(this->m_demangledName), ImGuiInputTextFlags_ReadOnly); + + + + } + ImGui::End(); + } + + void ViewTools::createMenu() { + if (ImGui::BeginMenu("View")) { + ImGui::MenuItem("Tools View", "", &this->m_windowOpen); + ImGui::EndMenu(); + } + } + +} \ No newline at end of file