add research folder

This commit is contained in:
2023-05-31 16:17:45 +07:00
parent 8b962dd88a
commit e3453ae127
12 changed files with 425 additions and 0 deletions

24
research/scripts/bind.c Normal file
View File

@ -0,0 +1,24 @@
#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);
}

Binary file not shown.

7
research/scripts/go.mod Normal file
View File

@ -0,0 +1,7 @@
module a
go 1.20
require github.com/blacktop/go-macho v1.1.155
require github.com/blacktop/go-dwarf v1.0.9 // indirect

4
research/scripts/go.sum Normal file
View File

@ -0,0 +1,4 @@
github.com/blacktop/go-dwarf v1.0.9 h1:eT/L7gt0gllvvgnRXY0MFKjNB6+jtOY5DTm2ynVX2dY=
github.com/blacktop/go-dwarf v1.0.9/go.mod h1:4W2FKgSFYcZLDwnR7k+apv5i3nrau4NGl9N6VQ9DSTo=
github.com/blacktop/go-macho v1.1.155 h1:1yIFj2PxtenaPiB3eGwUSxmZki55f5b4JHGtfrJVFHs=
github.com/blacktop/go-macho v1.1.155/go.mod h1:f2X4noFBob4G5bWUrzvPBKDVcFWZgDCM7rIn7ygTID0=

Binary file not shown.

View File

@ -0,0 +1,16 @@
package main
import "github.com/blacktop/go-macho/pkg/trie"
import "os"
import "bytes"
import "fmt"
func main() {
// buffer, _ := os.ReadFile("./dyld_export_trie.bin")
buffer, _ := os.ReadFile("./libc_export_trie.bin")
r := bytes.NewReader(buffer)
nodes, _ := trie.ParseTrieExports(r, 0x7ff80715c000)
for _, node := range nodes {
fmt.Println(node)
}
}

Binary file not shown.

Binary file not shown.