Giter Club home page Giter Club logo

x86_ldasm's Introduction

x86_ldasm

x86_ldasm is a relatively compact x86-64 instruction length disassembler (LDE) based on a stripped down and heavily modified version of x86_dasm. It is fully C99 compliant.

NB: This library is not particularly well-suited for disassembling "hostile" code (malformed, invalid, undefined behavior, etc.) since most of the error detection logic has been stripped out in favor of a smaller size. It should have no problems in correctly disassembling regular compiler-generated code.

Build

make clean && make all

Usage example

x86_dasm_context_t x86_dctx = {0};

uint8_t code[] = {
    0xeb, 0xfe
};

// Use the regular C library

// Disassemble 32-bit code
int len = x86_ldasm(&x86_dctx, X86_DMODE_32BIT, code);

if(len > 0)
{
    printf("Instruction's length: %02i", len);
    
    //
    // Print additional info such as:
    //      OPCODE, MODRM, SIB, DISP (see main.c)
    //
}

// Use the single-header precompiled library

#include "x86_ldasm_precompiled.h"

x86_ldasm_t x86_ldasm_pre = (x86_ldasm_t)x86_ldasm_lin64_bin;

// Disassemble 64-bit code, don't provide any dasm context struct
int len = x86_ldasm_pre(NULL, 64, code);

if(len > 0)
{
    printf("Instruction's length: %02i", len);
}

Output example

0000 |          6A 60  | LEN: 02 | OPCODE: 6A
0002 |             5A  | LEN: 01 | OPCODE: 5A
0003 | 68 63 61 6C 63  | LEN: 05 | OPCODE: 68
0008 |             54  | LEN: 01 | OPCODE: 54
0009 |             59  | LEN: 01 | OPCODE: 59
000A |       48 29 D4  | LEN: 03 | OPCODE: 29 | MODRM: D4
000D |    65 48 8B 32  | LEN: 04 | OPCODE: 8B | MODRM: 32
0011 |    48 8B 76 18  | LEN: 04 | OPCODE: 8B | MODRM: 76 | DISP: 18
0015 |    48 8B 76 10  | LEN: 04 | OPCODE: 8B | MODRM: 76 | DISP: 10
0019 |          48 AD  | LEN: 02 | OPCODE: AD
001B |       48 8B 30  | LEN: 03 | OPCODE: 8B | MODRM: 30
001E |    48 8B 7E 30  | LEN: 04 | OPCODE: 8B | MODRM: 7E | DISP: 30
0022 |       03 57 3C  | LEN: 03 | OPCODE: 03 | MODRM: 57 | DISP: 3C
0025 |    8B 5C 17 28  | LEN: 04 | OPCODE: 8B | MODRM: 5C | SIB: 17 | DISP: 28
0029 |    8B 74 1F 20  | LEN: 04 | OPCODE: 8B | MODRM: 74 | SIB: 1F | DISP: 20

License

x86_ldasm is licensed under the Apache License, Version 2.0

x86_ldasm's People

Contributors

thejanit0r avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.