Made layout printing responsibility of subject

This commit is contained in:
York Jasper Niebuhr 2025-10-28 22:08:19 +01:00
parent 45481c8403
commit db19da4a23
2 changed files with 9 additions and 7 deletions

View File

@ -2,7 +2,6 @@
#include "spslr_program.h"
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
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;
}

View File

@ -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);