Quantcast
Channel: archassembler Wiki Rss Feed
Viewing all articles
Browse latest Browse all 3

Updated Wiki: Home

$
0
0

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;

publicstaticclass Program
{
    publicstaticvoid Main()
    {
        // imagevar image = new Image32();
        image.Subsystem = ImageSubsystem.Windows;

        // code sectionvar codeSection = new ImageSection(".text", ImageSectionType.Code);
        image.Sections.Add(codeSection);
        
        // readonly data sectionvar dataSection = new ImageSection(".data", ImageSectionType.ReadonlyData);
        image.Sections.Add(dataSection);

        // import tablevar importTable = new ImportTableElement();
        dataSection.Elements.Add(importTable);
        image.Directories[ImageDirectory.Import] = importTable;

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

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

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

        main.Push32(0x00000040);
        main.Push32(caption);
        main.Push32(message);
        main.Push32(0);
        main.Call32(new EffectiveAddress(messageBoxFunction));
        main.Push32(0);
        main.Call32(new EffectiveAddress(exitProcessFunction));

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

Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images