3

I'm writing a handy reverse tool in C++ with manual assembling/disassembling shell, to automate my work!

I need an assembler library. Is there any library, embedding in C++?

  • 2
    What exactly the library should do ? Disassembling ? Shell ? – w s Jun 21 '14 at 14:00
2

Oleh Yuschuk released a light-weight open-source assembler library that you can download from http://ollydbg.de/srcdescr.htm

Assemble

Function Assemble(), as expected, converts command from ASCII form to binary 32 bit code.

Example:

  // Assemble one of the commands above. First try form with 32-bit immediate.
  pasm="ADD [DWORD 475AE0],1";
  printf("%s:\n",pasm);
  j=Assemble(pasm,0x400000,&am,0,0,errtext);
  n=sprintf(s,"%3i  ",j);
  for (i=0; i<j; i++) n+=sprintf(s+n,"%02X ",am.code[i]);
  if (j<=0) sprintf(s+n,"  error=\"%s\"",errtext);
  printf("%s\n",s);
| improve this answer | |
5

You can take one of these projects (I choose the alphabetic order to sort them):

Assembler/Disassembler

  • GNU binutils (Archs: i386, AMD64, ARM, Sparc, MIPS, ...; Formats: ELF, Mach-O, PE (partial)).
  • Miasm (Archs: i386, ARM, PowerPC, MSP430; Formats: ELF, PE)
  • Metasm (Archs: i386, AMD64, PowerPC, MIPS; Formats: ELF, Mach-O (partial), PE)
  • NASM (Archs: i386, AMD64; Formats: ELF, Mach-O, PE)
  • Radare2: rasm (Archs: i386, AMD64, ARM, PowerPC, Sparc, MIPS, ...; Formats: ELF, Mach-O, PE)
  • srcdescr (Archs: i386; Formats: PE)
  • YASM (Archs: i386, AMD64; Formats: ELF, Mach-O, PE)

Disassembler (only)

  • BAP (Archs: i386, AMD64; Formats: ELF, PE)
  • BeaEngine (Archs: i386, AMD64; Formats: PE)
  • Capstone Engine (Archs: i386, AMD64, ARM, PowePC, Sparc, MIPS, ...; Formats: ELF, Mach-O, PE)
  • distorm (Archs: i386, AMD64)
  • ERESI: libasm (Archs: i386, ARM, Sparc, MIPS; Formats: ELF)
  • GDSL (Archs: i386, MSP430, AVR)
  • Hopper (Archs: i386, AMD64; Formats: ELF, Mach-O, PE)
  • Insight (Archs: i386, AMD64, MSP430; Formats: ELF, PE (partial), Mach-O (partial))
  • libdasm (Archs: i386)
  • libdisasm (from bastard project) (Archs: i386; Formats: ELF, PE)
  • Opdis (Archs: i386, AMD64; Formats: ELF, Mach-O, PE)
  • Pyew (Archs: i386, AMD64; Formats: ELF, PE)
  • Udis86 (Archs: i386, AMD64)

Assembler (only)

  • FASM (Archs: i386, AMD64; Formats: ELF, PE)

EDIT: Each of these projects either contains a library that can be used as it is, or can be wrapped into a library that you will have to code by yourself with the features that you request.

| improve this answer | |
  • thanks @perror for fast and informative answer, but I'm looking for assembler library. except GDSL toolkit and METASM ( that i don't know what exactly they are), others are disassemblers. – sealed... Jun 21 '14 at 15:15
  • 1
    Then, you should look at Miasm and go a bit deeper in all the items. GAS (GNU ASsembler), NASM and others have also an assembler library inside. – perror Jun 21 '14 at 15:21
  • Yeap! but NASM & GAS are not lib and extracting parser and assembler is not easy work! I'm looking for easy way! – sealed... Jun 21 '14 at 15:27
  • You should definitely take a deeper look at all these projects. What you ask for is unclear and there is probably no such library. So, you will need some work at some point. Yet, Radare2, Miasm, GNU binutils and the ERESI project should contain everything you need (but maybe in a state that will require some work before being usable). – perror Jun 21 '14 at 15:41
  • 1
    Radare2 can of course assemble :) – jvoisin Jun 22 '14 at 9:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.