diff --git a/V. Dyld/custom/hello.c b/V. Dyld/custom/hello.c new file mode 100644 index 0000000..5348fb5 --- /dev/null +++ b/V. Dyld/custom/hello.c @@ -0,0 +1,8 @@ +// clang -o hello hello.c +#include + +int main() { + printf("Hello!\n"); + return 0; +} + diff --git a/V. Dyld/custom/interpose.c b/V. Dyld/custom/interpose.c new file mode 100644 index 0000000..3653221 --- /dev/null +++ b/V. Dyld/custom/interpose.c @@ -0,0 +1,22 @@ +// clang -dynamiclib -o libinterpose.dylib interpose.c +#include + +// 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) diff --git a/V. Dyld/python/CrimsonUroboros.py b/V. Dyld/python/CrimsonUroboros.py index 616408a..57dece2 100755 --- a/V. Dyld/python/CrimsonUroboros.py +++ b/V. Dyld/python/CrimsonUroboros.py @@ -1480,6 +1480,8 @@ class SnakeV(SnakeIV): for cmd in all_dyld_env: print(cmd.value) + + ### --- ARGUMENT PARSER --- ### class ArgumentParser: def __init__(self):