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 | |
parent | private syms starting to look good (diff) | |
download | substitute-e910f0d9ddbd2f2a6b774ca364ac838c717ebc9f.tar.gz |
substrate
Diffstat (limited to 'test')
-rw-r--r-- | test/test-find-syms.c | 2 | ||||
-rw-r--r-- | test/test-substrate.cpp | 23 |
2 files changed, 24 insertions, 1 deletions
diff --git a/test/test-find-syms.c b/test/test-find-syms.c index 6a8d600..acd31ba 100644 --- a/test/test-find-syms.c +++ b/test/test-find-syms.c @@ -13,7 +13,7 @@ int main() { assert(!substitute_find_private_syms(im, names, syms, 1)); assert(syms[0]); - int (*f)(int) = substitute_sym_to_ptr(im, syms[0]); + int (*f)(int) = (int (*)(int)) substitute_sym_to_ptr(im, syms[0]); assert(f(12345) < 0); substitute_close_image(im); 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); +} + |