Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
.vscode/
coverage.info
/cov-out/
/src/bench
/src/cpp/iced-x86/build
/build-disasm
/src/cpp/iced-x86/build-decoder-only
/src/cpp/yaxpeax-ref
/build
49 changes: 49 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
cmake_minimum_required(VERSION 3.25)
project(disassembler)

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Configure iced-x86 for decoder-only build
set(ICED_X86_DECODER ON)
set(ICED_X86_ENCODER OFF)
set(ICED_X86_BLOCK_ENCODER OFF)
set(ICED_X86_OP_CODE_INFO OFF)
set(ICED_X86_INSTR_INFO OFF)
set(ICED_X86_GAS OFF)
set(ICED_X86_INTEL OFF)
set(ICED_X86_MASM OFF)
set(ICED_X86_NASM OFF)
set(ICED_X86_FAST_FMT OFF)

# Include the iced-x86 source files directly
include_directories(src/cpp/iced-x86/include)

# Source files from iced-x86
set(ICED_SOURCES
src/cpp/iced-x86/src/instruction.cpp
src/cpp/iced-x86/src/instruction_create.cpp
src/cpp/iced-x86/src/tables.cpp
src/cpp/iced-x86/src/register_info.cpp
src/cpp/iced-x86/src/memory_size_info.cpp
src/cpp/iced-x86/src/mvex_info_data.cpp
src/cpp/iced-x86/src/decoder.cpp
src/cpp/iced-x86/src/handlers.cpp
src/cpp/iced-x86/src/table_deserializer.cpp
)

# Create the disassembler executable with iced sources
add_executable(disassembler disassembler.cpp ${ICED_SOURCES})

# Set compile definitions for decoder-only
target_compile_definitions(disassembler PRIVATE
ICED_X86_NO_ENCODER
ICED_X86_NO_BLOCK_ENCODER
ICED_X86_NO_OP_CODE_INFO
ICED_X86_NO_INSTR_INFO
ICED_X86_NO_GAS
ICED_X86_NO_INTEL
ICED_X86_NO_MASM
ICED_X86_NO_NASM
ICED_X86_NO_FAST_FMT
)
65 changes: 65 additions & 0 deletions DISASSEMBLER_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Minimal iced-x86 C++ Disassembler

This is a minimal example that demonstrates how to use the iced-x86 C++ library (decoder-only build) to disassemble binary files.

## Building

The project includes a CMakeLists.txt that builds the disassembler along with the necessary iced-x86 source files:

```bash
mkdir build
cd build
cmake -G "Unix Makefiles" ..
make
```

This creates `disassembler.exe` in the build directory.

## Usage

```
disassembler.exe <filename> [bitness]
```

- `filename`: Path to the binary file to disassemble
- `bitness`: Optional CPU mode (16, 32, or 64-bit, default: 64)

## Example

```bash
# Create a test binary file
python3 -c "
data = bytes([0x90, 0x89, 0xD8, 0x05, 0x78, 0x56, 0x34, 0x12, 0xC3])
with open('test.bin', 'wb') as f:
f.write(data)
"

# Disassemble it
./disassembler.exe test.bin
```

Output:
```
Disassembling test.bin (64-bit mode):

00001000: 90 nop
00001001: 89 d8 mov eax, ebx
00001003: 05 78 56 34 12 add eax, 0x12345678
00001008: c3 ret

Disassembly complete.
```

## Features

- Disassembles entire binary files
- Supports 16-bit, 32-bit, and 64-bit modes
- Shows instruction addresses, bytes, and disassembly
- Simple text-based output format
- Minimal dependencies (only standard C++ libraries)

## Notes

- This is a decoder-only build of iced-x86 (no encoding or formatting features)
- The output format is basic - for more advanced formatting, the full iced-x86 formatter would be needed
- Instructions are disassembled starting from address 0x1000
160 changes: 0 additions & 160 deletions build/build-dotnet

This file was deleted.

53 changes: 0 additions & 53 deletions build/build-java

This file was deleted.

Loading