macho/research/scripts/bind.c
2023-05-31 16:17:45 +07:00

25 lines
733 B
C

#include <stdio.h>
#include <stdint.h>
struct dyld_chained_ptr_64_bind
{
uint64_t ordinal : 24,
addend : 8, // 0 thru 255
reserved : 19, // all zeros
next : 12, // 4-byte stride
bind : 1; // == 1
};
int main() {
// 0 = 0x8010000000000000 = 9227875636482146000
uint64_t x = 0x8000000000000010;
uint8_t y[] = {0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80};
struct dyld_chained_ptr_64_bind* bind = y;
// printf("x? %llx\n", x);
// printf("y? %llx\n", *(uint64_t*)y);
printf("bind? %d\n", bind->bind);
printf("next? %d\n", bind->next);
printf("ordinal? %d\n", bind->ordinal);
printf("addend? %d\n", bind->addend);
}