diff --git a/selfpatch/src/targets.c b/selfpatch/src/targets.c index 8e9f2ba..96850cd 100644 --- a/selfpatch/src/targets.c +++ b/selfpatch/src/targets.c @@ -2,7 +2,6 @@ #include "spslr_program.h" #include -#include #include static void seed_rand_time() { @@ -352,12 +351,6 @@ int spslr_randomize(uint32_t target) { ff->offset = f->offset; } - printf("Randomization of target %u...\n", target); - for (uint32_t i = 0; i < t->field_count; i++) { - const struct FinalField* ff = &t->final_fields[i]; - printf(" Field %u: %u -> %u\n", i, ff->initial_offset, ff->offset); - } - return 0; } diff --git a/subject/main.c b/subject/main.c index 260ce9c..0555413 100644 --- a/subject/main.c +++ b/subject/main.c @@ -7,9 +7,18 @@ int third_pid(); struct task_struct global = { .pid = 42, .comm = "main_global" }; +static void print_layout() { + // TODO -> Make builtin __spslr_initial_offsetof(type, field) that is not patched + printf("Current task_struct layout:\n"); + printf(" pid (int) : %2llu -> %2llu\n", 0, offsetof(struct task_struct, pid)); + printf(" comm (const char*) : %2llu -> %2llu\n", 8, offsetof(struct task_struct, comm)); + printf(" tasks (struct list_head) : %2llu -> %2llu\n", 16, offsetof(struct task_struct, tasks)); +} + int main(void) { spslr_selfpatch(); + print_layout(); struct list_head task_list; INIT_LIST_HEAD(&task_list);