Skip to content

Commit

Permalink
Merge pull request #329 from gdt050579/dissasm_view
Browse files Browse the repository at this point in the history
Added about window, improved config consistency and some dissasm refractoring
  • Loading branch information
rzaharia authored Jul 28, 2024
2 parents f617230 + 8f80325 commit 38828bf
Show file tree
Hide file tree
Showing 25 changed files with 864 additions and 760 deletions.
2 changes: 1 addition & 1 deletion GViewCore/include/GView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct CORE_EXPORT TypeInterface {

virtual std::string_view GetTypeName() = 0;
virtual void RunCommand(std::string_view commandName) = 0;
virtual ~TypeInterface(){};
virtual ~TypeInterface(){}

struct SelectionZone {
uint64 start, end;
Expand Down
38 changes: 38 additions & 0 deletions GViewCore/src/App/AboutWindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include "Internal.hpp"

using namespace GView::App;
using namespace AppCUI::Application;
using namespace AppCUI::Controls;
using namespace AppCUI::Input;
using namespace AppCUI::Utils;

class AboutWindow : public Window, public Handlers::OnButtonPressedInterface
{
Reference<Button> closeButton;
public:
AboutWindow() : Window("About", "t:10,l:10,w:74,h:13", WindowFlags::Sizeable)
{
Factory::Label::Create(this, "GView is a cross-platform framework for reverse-engineering. Users can leverage the diverse range of available visualization options to effectively analyze and interpret the information.", "t:2,l:5,w:60");
Factory::Label::Create(this, "Users can leverage the diverse range of available visualization options to effectively analyze and interpret the information.", "t:3,l:5,w:64");
Factory::Label::Create(this, "options to effectively analyze and interpret the information.", "t:4,l:5,w:64");

Factory::Label::Create(this, "Read more on https://github.com/gdt050579/GView", "t:6,l:8,w:64");

Factory::Label::Create(this, "License: MIT", "t:8,l:25,w:64");
Factory::Label::Create(this, "Version: " GVIEW_VERSION, "t:9,l:25,w:64");

closeButton = Factory::Button::Create(this, "Close", "t:11,l:26,w:13", 100, ButtonFlags::Flat);
closeButton->Handlers()->OnButtonPressed = this;
}

void OnButtonPressed(Reference<Controls::Button> r) override
{
Exit();
}
};

void Instance::ShowAboutWindow()
{
AboutWindow aboutWindow{};
aboutWindow.Show();
}
1 change: 1 addition & 0 deletions GViewCore/src/App/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ target_sources(GViewCore PRIVATE
Instance.cpp
SelectTypeDialog.cpp
TutorialWindow.cpp
AboutWindow.cpp
)
2 changes: 1 addition & 1 deletion GViewCore/src/App/GViewApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ bool GView::App::ResetConfiguration()
GView::View::TextViewer::Config::Update(ini["View.Text"]);
GView::View::ImageViewer::Config::Update(ini["View.Image"]);
GView::View::GridViewer::Config::Update(ini["View.Grid"]);
GView::View::DissasmViewer::Config::Update(ini["DissasmView"]);
GView::View::DissasmViewer::Config::Update(ini["View.Dissasm"]);
GView::View::LexicalViewer::Config::Update(ini["View.Lexical"]);

// parse types and add specs
Expand Down
8 changes: 8 additions & 0 deletions GViewCore/src/App/Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ constexpr GViewMenuCommand menuHelpList[] = {
{ "&About", MenuCommands::ABOUT, Key::None },
};

constexpr ItemHandle menuHelpListDisabledCommandsList[] = { 0 };

bool AddMenuCommands(Menu* mnu, const GViewMenuCommand* list, size_t count)
{
while (count > 0) {
Expand Down Expand Up @@ -125,6 +127,9 @@ bool Instance::BuildMainMenus()
CHECK(AddMenuCommands(mnuWindow, menuWindowList, ARRAY_LEN(menuWindowList)), false, "");
CHECK(mnuHelp = AppCUI::Application::AddMenu("&Help"), false, "Unable to create 'Help' menu");
CHECK(AddMenuCommands(mnuHelp, menuHelpList, ARRAY_LEN(menuHelpList)), false, "");
for (auto itemHandle : menuHelpListDisabledCommandsList) {
CHECK(mnuHelp->SetEnable(itemHandle, false), false, "Fail to disable menu item");
}
return true;
}

Expand Down Expand Up @@ -552,6 +557,9 @@ bool Instance::OnEvent(Reference<Control> control, Event eventType, int ID)
case MenuCommands::OPEN_FOLDER:
OpenFolder();
return true;
case MenuCommands::ABOUT:
ShowAboutWindow();
return true;
}
if ((ID >= GENERIC_PLUGINS_CMDID) && (ID < GENERIC_PLUGINS_CMDID + GENERIC_PLUGINS_FRAME * 1000)) {
auto packedValue = ((uint32) ID) - GENERIC_PLUGINS_CMDID;
Expand Down
4 changes: 4 additions & 0 deletions GViewCore/src/View/DissasmViewer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ target_sources(
AdvancedSelection.cpp
DissasmDataTypes.hpp
DissasmDataTypes.cpp
DissasmCodeZone.hpp
DissasmCodeZone.cpp
DissasmFunctionUtils.hpp
DissasmFunctionUtils.cpp

x86_x64/DissasmX86.hpp
x86_x64/DissasmX86.cpp
Expand Down
18 changes: 10 additions & 8 deletions GViewCore/src/View/DissasmViewer/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ void ColorManager::OnGainedFocus()

void Config::Update(AppCUI::Utils::IniSection sect)
{
LocalString<128> buffer;
for (const auto& cmd : AllKeyboardCommands) {
sect.UpdateValue(cmd.get().Caption, cmd.get().Key, true);
buffer.SetFormat("Key.%s", cmd.get().Caption);
sect.UpdateValue(buffer.GetText(), cmd.get().Key, true);
}

sect.UpdateValue("ShowFileContent", true, true);
sect.UpdateValue("ShowOnlyDissasm", false, true);
sect.UpdateValue("DeepScanDissasmOnStart", false, true);
sect.UpdateValue("Config.ShowFileContent", true, true);
sect.UpdateValue("Config.ShowOnlyDissasm", false, true);
sect.UpdateValue("Config.DeepScanDissasmOnStart", false, true);
}
void Config::Initialize()
{
Expand Down Expand Up @@ -95,15 +97,15 @@ void Config::Initialize()
bool foundSettings = false;
auto ini = AppCUI::Application::GetAppSettings();
if (ini) {
auto sect = ini->GetSection("DissasmView");
auto sect = ini->GetSection("View.Dissasm");
if (sect.Exists()) {
for (auto& cmd : AllKeyboardCommands) {
cmd.get().Key = sect.GetValue(cmd.get().Caption).ToKey(cmd.get().Key);
}

this->ShowFileContent = sect.GetValue("ShowFileContent").ToBool(true);
this->ShowOnlyDissasm = sect.GetValue("ShowOnlyDissasm").ToBool(false);
this->EnableDeepScanDissasmOnStart = sect.GetValue("DeepScanDissasmOnStart").ToBool(false);
this->ShowFileContent = sect.GetValue("Config.ShowFileContent").ToBool(true);
this->ShowOnlyDissasm = sect.GetValue("Config.ShowOnlyDissasm").ToBool(false);
this->EnableDeepScanDissasmOnStart = sect.GetValue("Config.DeepScanDissasmOnStart").ToBool(false);
foundSettings = true;
}
}
Expand Down
29 changes: 15 additions & 14 deletions GViewCore/src/View/DissasmViewer/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ constexpr int32 RIGHT_CLICK_CLEAR_SELECTION = 7;
constexpr int32 RIGHT_CLICK_DISSASM_COLLAPSE_ZONE = 8;
constexpr int32 RIGHT_CLICK_DISSASM_EXPAND_ZONE = 9;

constexpr int32 RIGHT_CLICK_CODE_ZONE_EDIT = 10;

struct RightClickCommand {
int commandID;
std::string_view text;
// Input::Key shortcutKey = Input::Key::None;
AppCUI::Controls::ItemHandle handle = AppCUI::Controls::InvalidItemHandle;
// AppCUI::Controls::ItemHandle handle = AppCUI::Controls::InvalidItemHandle;
};

inline RightClickCommand RIGHT_CLICK_MENU_COMMANDS[] = {
Expand All @@ -45,21 +47,20 @@ inline RightClickCommand RIGHT_CLICK_MENU_COMMANDS[] = {
struct RightClickSubMenus {
const char* name;
std::vector<RightClickCommand> commands;
AppCUI::Controls::ItemHandle handle;
// AppCUI::Controls::ItemHandle handle;
};

inline RightClickSubMenus RIGHT_CLICK_SUB_MENUS_COMMANDS[] = { { "CollapsibleZone",
{
{ RIGHT_CLICK_MENU_CMD_NEW_COLLAPSE_ZONE, "Add collapse zone" },
{ RIGHT_CLICK_DISSASM_REMOVE_COLLAPSE_ZONE, "Remove collapse zone" },
{ RIGHT_CLICK_DISSASM_COLLAPSE_ZONE, "Collapse zone" },
{ RIGHT_CLICK_DISSASM_EXPAND_ZONE, "Expand zone" },
} },
{ "Comment",
{
{ RIGHT_CLICK_ADD_COMMENT, "Add comment" },
{ RIGHT_CLICK_REMOVE_COMMENT, "Remove comment" },
} } };
const RightClickSubMenus RIGHT_CLICK_SUB_MENUS_COMMANDS[] = {
{ "CollapsibleZone",
{
{ RIGHT_CLICK_MENU_CMD_NEW_COLLAPSE_ZONE, "Add collapse zone" },
{ RIGHT_CLICK_DISSASM_REMOVE_COLLAPSE_ZONE, "Remove collapse zone" },
{ RIGHT_CLICK_DISSASM_COLLAPSE_ZONE, "Collapse zone" },
{ RIGHT_CLICK_DISSASM_EXPAND_ZONE, "Expand zone" }
} },
{ "Comment", { { RIGHT_CLICK_ADD_COMMENT, "Add comment" }, { RIGHT_CLICK_REMOVE_COMMENT, "Remove comment" } } },
{ "CodeZone", { { RIGHT_CLICK_CODE_ZONE_EDIT, "Edit zone" } } }
};

namespace GView
{
Expand Down
Loading

0 comments on commit 38828bf

Please sign in to comment.