This project is read-only.

Project Description

ArchAssembler is a .net (c#) library providing the functionalities of an assembler. Target architecture is x86/x64 with streaming SIMD extensions. Target executable file format is Windows Portable Executable (PE).

Project Status

Under active developpement as of may 2011.

What is done:
  • Assembler framework.
  • Portable Executable file format is almost fully implemented. PE32 (32bits) and PE32+ (64bits).
  • X86 instruction set is ok (except system instructions).

What is not done yet:
  • X64 instruction set.
  • SSE instruction set.
  • Program Database (.pdb) file support.
  • Documentation and example code.

Quick example

This little program build an executable file that greets the world.

using System.IO;
using ArchAssembler.PortableExecutable;
using ArchAssembler.Elements;
using ArchAssembler.X86;

public static class Program
    public static void Main()
        // image
        var image = new Image32();
        image.Subsystem = ImageSubsystem.Windows;

        // code section
        var codeSection = new ImageSection(".text", ImageSectionType.Code);
        // readonly data section
        var dataSection = new ImageSection(".data", ImageSectionType.ReadonlyData);

        // import table
        var importTable = new ImportTableElement();
        image.Directories[ImageDirectory.Import] = importTable;

        // imported functions
        var exitProcessFunction = importTable.Import("KERNEL32.DLL", "ExitProcess");
        var messageBoxFunction = importTable.Import("USER32.DLL", "MessageBoxA");

        // strings
        var message = dataSection.VariableSizeString("Hello, world!");
        var caption = dataSection.VariableSizeString("Hum...");

        // main
        var main = codeSection.ElementCollection();
        image.EntryPoint = main;

        main.Call32(new EffectiveAddress(messageBoxFunction));
        main.Call32(new EffectiveAddress(exitProcessFunction));

        // let's do it!
        Stream stream = new FileStream("hello.exe", FileMode.Create, FileAccess.Write);
        image.Assemble(new BinaryWriter(stream));

Last edited May 18, 2011 at 8:13 AM by OddCode, version 6