Skip to content

Alon-Alush/CStructsToNASM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 

Repository files navigation

generated_text

Introduction

This tool converts C struct definitions to NASM (Netwide Assembler) format. It supports a lot of platforms specific types (GCC/Clang/WinAPI) etc, for example (uint64_t, ULONGLONG, unsigned __int64, UNICODE_STRING).

Example:

This is the C struct in my_structs.h:

typedef struct _TEB_ACTIVE_FRAME_CONTEXT
{
    ULONG Flags;
    PSTR FrameName;
} TEB_ACTIVE_FRAME_CONTEXT, * PTEB_ACTIVE_FRAME_CONTEXT;

This is the output struct in NASM syntax:

struc TEB_ACTIVE_FRAME_CONTEXT
    .Flags    resd 1
    .FrameName    resq 1
endstruc

Usage

Script

To use the script, you need to have Python 3 installed on your machine.

You have to install pycparser:

pip install pycparser

Example usage

python ctonasm.py -i <structs.h> -o <structs.inc>
image

We can see that the output nasm structs are nicely and correctly structred: image

Binaries

If you're too lazy to install Python, you can download the Windows .exe binary in the Releases page.

License

This tool is licened under MIT.

About

Convert C structs to NASM (Netwide Assembler) format

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages