From e910f0d9ddbd2f2a6b774ca364ac838c717ebc9f Mon Sep 17 00:00:00 2001 From: comex Date: Sat, 10 Jan 2015 16:31:00 -0500 Subject: substrate --- test/test-substrate.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 test/test-substrate.cpp (limited to 'test/test-substrate.cpp') 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 +#include +#include +#include +#include + +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); +} + -- cgit v1.2.3