16.4.2 Spcc

SPCC stands for 'Structure Parser C Compiler'. And it is just a small script that generates a dummy main() to call a user specified function over a block of data from radare. This way it is possible to parse any buffer using just C with all the libraries and includes like a real program will do. Use 'pm' command if you want a oneline and simplified version for reading structures.

$ rsc spcc
spcc - structure parser c compiler
Usage: spcc [-ht] [file.spc] ([gcc-flags])

The 'rsc spcc' command should be used like gcc against .spc files that are just .c files without main() and having a function called 'void parse(struct spcc *spcc, uchar *buffer)'.

$ rsc spcc -t
/*-- test.spcc --*/
struct foo {
        int id;
        void *next;
        void *prev;
};

void parse(struct spcc *spcc, uchar *buffer) {
        struct foo tmp;
        memcpy(&tmp, buffer, sizeof(struct foo));
        printf("id: %d\nnext: %p\nprev: %p\n",
                tmp.id, tmp.next, tmp.prev);
}