mirror of
https://github.com/Karmaz95/Snake_Apple.git
synced 2026-08-13 21:30:18 +02:00
This commit is contained in:
@@ -0,0 +1,8 @@
|
|||||||
|
// clang -o hello hello.c
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
printf("Hello!\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
// clang -dynamiclib -o libinterpose.dylib interpose.c
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
// Define the interpose macro
|
||||||
|
#define DYLD_INTERPOSE(_replacement,_replacee) \
|
||||||
|
__attribute__((used)) static struct { \
|
||||||
|
const void* replacement; \
|
||||||
|
const void* replacee; \
|
||||||
|
} \
|
||||||
|
_interpose_##_replacee \
|
||||||
|
__attribute__ ((section ("__DATA,__interpose,interposing"))) = { \
|
||||||
|
(const void*)(unsigned long)&_replacement, \
|
||||||
|
(const void*)(unsigned long)&_replacee };
|
||||||
|
|
||||||
|
// Define the replacement function
|
||||||
|
int my_printf(const char *format, ...) {
|
||||||
|
int ret = printf("Hello from my_printf!\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply the interposing macro to replace printf with my_printf
|
||||||
|
DYLD_INTERPOSE(my_printf, printf)
|
||||||
@@ -1480,6 +1480,8 @@ class SnakeV(SnakeIV):
|
|||||||
for cmd in all_dyld_env:
|
for cmd in all_dyld_env:
|
||||||
print(cmd.value)
|
print(cmd.value)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### --- ARGUMENT PARSER --- ###
|
### --- ARGUMENT PARSER --- ###
|
||||||
class ArgumentParser:
|
class ArgumentParser:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user