How suifei/asm2hex2 works
Project Type and Purpose
• Type: Cross-platform desktop GUI application (with a bundled CLI tool).
• Purpose: Bi-directional conversion between assembly and machine code (hex) using Capstone (disassembler) and Keystone (assembler), with a native GUI front-end powered by wxWidgets and a small CLI called cstool.
File Structure
Top-level view:
• CMakeLists.txt – build orchestrator
• dep/ – pre-downloaded dependencies:
– capstone/ + libcapstone.a
– keystone/ + libkeystone.a
– wxWidgets headers + libs (Windows)
• src/ – C++ source code:
– App.cpp/hpp, MainWindow.cpp/hpp, AboutDialog.cpp/hpp, Resources.*
– CsEngine.cpp/hpp, KsEngine.cpp/hpp (wrappers around Capstone/Keystone)
– OSCross.hpp (OS abstraction)
– cstool/ – standalone C CLI tool
• doc/, screenshots/, README.md – documentation and assets
README for Technical Stack
• GUI: wxWidgets (3.x)
• Engines: Capstone Engine (disassembly), Keystone Engine (assembly)
• Build: CMake, Ninja/MSVC/g++
• Languages: C++11, C for cstool
Main Components
A. Build System
– CMake + generator (Ninja, MSVC, make)
– Pulls in dep/lib and dep/include, compiles src, links static libs
B. UI Layer
– App (entry point)
– MainWindow (layout, menus, input controls: text fields, buttons)
– wxWidgets runtime library
C. Engine Layer
– KsEngine (wraps Keystone C API)
– CsEngine (wraps Capstone C API)
– OSCross (uniform OS calls if any)
D. External Libraries
– libkeystone.a, libcapstone.a (static)
– wxWidgets (static/dynamic)
E. CLI Sub-Tool
– cstool executable (links Capstone only, small printf wrapper)
F. OS Platform
– Windows, macOS, Linux (abstracted by wxWidgets & OSCross)
Relationships and Data Flows
• User enters ASM or HEX in UI → MainWindow controller
• MainWindow calls either KsEngine (assemble) or CsEngine (disassemble)
• Engine wrappers invoke Keystone/Capstone C API → process input → return results
• MainWindow renders output, syntax highlights via wxWidgets controls
• CLI: user invokes cstool → direct call into cstool.c source → Capstone → console output
• Build System fetches includes/libs from dep/, compiles everything per CMakeLists.txt
Architectural Patterns & Design Principles
• Layered separation:
– Presentation (wxWidgets UI)
– Application Logic (MainWindow, dialog controllers)
– Domain Logic (KsEngine, CsEngine wrappers)
– Infrastructure (external libs, OS abstraction)
• Single Responsibility: each engine wrapper handles one API.
• Cross-platform abstraction: wxWidgets + OSCross for OS-specific calls.
• Reuse of prebuilt deps under dep/ folder.