#rest

macro lazy-re

A library for lazy reverse engineers

2 releases

0.1.1 Jul 19, 2022
0.1.0 Jul 7, 2022

#1339 in Procedural macros

Custom license

11KB
141 lines

Lazy-RE

A simple proc macro for the lazy reverse engineers. It basically creates the padding for you.

#[repr(C, packed)]
#[lazy_re]
struct Lights {
    #[lazy_re(offset = 0x10)]
    x: f32,
    y: f32,
    z: f32
}

#[repr(C, packed)]
#[lazy_re]
struct PlayerEntity {
    #[lazy_re(offset = 0x48)]
    light: Lights,

    #[lazy_re(offset = 0x90)]
    player_x: f32,
    player_y: f32,
    player_z: f32,
}

That would create the padding for the Light struct at the beginning, i.e. the x field will be at the offset 0x10, and the rest is filled with [u8; 0x10].

Similarly, the PlayerEntity will have padding until the Light struct, and then it'll pad between the light and the player position, doing the math for you.


lib.rs:

Lazy RE

Sometimes we're lazy and we don't need to fully reverse engineer a struct, so we can omit some fields we're not interested in.

With this library, you can generate padding without the need of doing mental math every time you need to change your struct, so you won't have to keep track of the padding in your head, this proc macro will generate it for you!

Dependencies

~1.5MB
~37K SLoC