diff options
author | comex | 2015-01-10 16:33:13 -0500 |
---|---|---|
committer | comex | 2015-01-10 16:33:13 -0500 |
commit | c15c71d9f02e7650fa7b87fc8cbe0f25ead2782c (patch) | |
tree | 115626b669f50033e83fbc9bd9dc06240205172f | |
parent | substrate (diff) | |
download | substitute-c15c71d9f02e7650fa7b87fc8cbe0f25ead2782c.tar.gz |
fixes
-rw-r--r-- | Makefile | 12 | ||||
-rw-r--r-- | lib/substrate-compat.c | 2 | ||||
-rw-r--r-- | test/test-substrate.cpp | 15 |
3 files changed, 18 insertions, 11 deletions
@@ -14,9 +14,9 @@ all: \ generated/transform-dis-arm.inc \ generated/transform-dis-arm64.inc \ out/libsubstitute.dylib \ - test/test-find-syms \ - test/test-find-syms-cpp \ - test/test-substrate + out/test-find-syms \ + out/test-find-syms-cpp \ + out/test-substrate out: mkdir out @@ -28,11 +28,11 @@ LIB_OBJS := out/find-syms.o out/substrate-compat.o out/libsubstitute.dylib: $(LIB_OBJS) lib/*.h out $(CC) -dynamiclib -fvisibility=hidden -o $@ $(LIB_OBJS) -test/test-%: test/test-%.c Makefile out/libsubstitute.dylib +out/test-%: test/test-%.c Makefile out/libsubstitute.dylib $(CC) -std=c89 -o $@ $< -Ilib -Lout -lsubstitute -test/test-%-cpp: test/test-%.c Makefile out/libsubstitute.dylib +out/test-%-cpp: test/test-%.c Makefile out/libsubstitute.dylib $(CXX) -x c++ -std=c++98 -o $@ $< -Ilib -Lout -lsubstitute -test/test-%: test/test-%.cpp Makefile out/libsubstitute.dylib +out/test-%: test/test-%.cpp Makefile out/libsubstitute.dylib $(CXX) -std=c++11 -o $@ $< -Ilib -Isubstrate -Lout -lsubstitute generated: Makefile diff --git a/lib/substrate-compat.c b/lib/substrate-compat.c index 6bbe316..3658ac7 100644 --- a/lib/substrate-compat.c +++ b/lib/substrate-compat.c @@ -13,7 +13,7 @@ EXPORT void *SubFindSymbol(void *image, const char *name) __asm__("SubFindSymbol"); void *SubFindSymbol(void *image, const char *name) { if (!image) { - const char *s = "SubFindSymbol: 'any image' specified, which is incredibly slow - like, 2ms. I'm going to do it since it seems to be somewhat common, but you should be ashamed of yourself."; + const char *s = "SubFindSymbol: 'any image' specified, which is incredibly slow - like, 2ms on a fast x86. I'm going to do it since it seems to be somewhat common, but you should be ashamed of yourself."; syslog(LOG_WARNING, "%s", s); fprintf(stderr, "%s\n", s); /* and it isn't thread safe, but neither is MS */ diff --git a/test/test-substrate.cpp b/test/test-substrate.cpp index f30918e..9cf50e8 100644 --- a/test/test-substrate.cpp +++ b/test/test-substrate.cpp @@ -11,13 +11,20 @@ int main() { MSImageRef im = MSGetImageByName(foundation); assert(im); - int (*f)(int); + int (*f)(int); + clock_t a = clock(); + MSHookSymbol(f, "_absolute_from_gregorian", im); + clock_t b = clock(); + printf("init: %ld\n", (long) (b - a)); + a = clock(); MSHookSymbol(f, "_absolute_from_gregorian", im); + b = clock(); + printf("spec: %ld\n", (long) (b - a)); assert(f(12345) < 0); - clock_t a = clock(); + a = clock(); MSHookSymbol(f, "_absolute_from_gregorian"); - clock_t b = clock(); - printf("%ld\n", (long) (b - a)); + b = clock(); + printf("gen: %ld\n", (long) (b - a)); assert(f(12345) < 0); } |