Skip to content

3443e/struct-build

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

struct-build

A tiny C library that builds a readable struct definition from a known and an unknown field list.

it matches everything by name and fills gaps with char pad_x[].

known fields that have no matching offset get put into the smallest gap they fit in (or get appended to the end)

Usage

#include <struct_build.h>

struct sb_struct_field_known known_arr[] = {
    {0x8, "value", "Value"},
    {0x4, "tt", "int"},
};

struct sb_struct_field_unk unk_arr[] = {
    {"value", 0x0, NULL},
    {"tt", 0xC, NULL},
};

char* result = sb_build_struct(unk_arr, 2, known_arr, 2, "TValue");
puts(result);
free(result);

Output

struct TValue {
    Value    value;  /* 0x00 */
    char pad_0[0x4]; /* 0x08 */
    int      tt;     /* 0x0C */
}; /* 0.012ms */
  • inferred means that the field had no known offset and was best-fit placed into a gap or appended

  • warnings get placed above the struct

Notes

  • Caller must free() the returned string
  • unk_arr gets sorted

About

A tiny C library for building struct definitions from known offsets.

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages