diff options
author | comex | 2015-01-10 16:31:00 -0500 |
---|---|---|
committer | comex | 2015-01-10 16:31:00 -0500 |
commit | e910f0d9ddbd2f2a6b774ca364ac838c717ebc9f (patch) | |
tree | d9d5ebc9cfa7564c76eac91109607be08fd37fc0 /test/test-substrate.cpp | |
parent | private syms starting to look good (diff) | |
download | substitute-e910f0d9ddbd2f2a6b774ca364ac838c717ebc9f.tar.gz |
substrate
Diffstat (limited to 'test/test-substrate.cpp')
-rw-r--r-- | test/test-substrate.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/test-substrate.cpp b/test/test-substrate.cpp new file mode 100644 index 0000000..f30918e --- /dev/null +++ b/test/test-substrate.cpp @@ -0,0 +1,23 @@ +#include <substrate.h> +#include <stdio.h> +#include <assert.h> +#include <dlfcn.h> +#include <time.h> + +int main() { + const char *foundation = "/System/Library/Frameworks/Foundation.framework/Foundation"; + dlopen(foundation, RTLD_LAZY); + + MSImageRef im = MSGetImageByName(foundation); + assert(im); + + int (*f)(int); + MSHookSymbol(f, "_absolute_from_gregorian", im); + assert(f(12345) < 0); + clock_t a = clock(); + MSHookSymbol(f, "_absolute_from_gregorian"); + clock_t b = clock(); + printf("%ld\n", (long) (b - a)); + assert(f(12345) < 0); +} + |