can't load objc class from dylib
Posted: Wed Dec 25, 2019 4:38 am
Hi.
I'm testing VMProtect on macOS latest demo version.
My product is dynamic library with objc classes. I did load dylib successfully with turning off packing option. But it seems to fail load objc classes in dylib. (tested on 10.15)
Test code:
Linking with VMP version libHello.dylib, class Hello is nil so it will not work correctly.
I can lookup C-level symbols with dlsym like this:
but [cls alloc] will rise runtime error "no class for metaclass 0x10037e0d8".
I think C-level linking works successfully but objc runtime don't load classes correctly. Is there way to fix?
I'm testing VMProtect on macOS latest demo version.
My product is dynamic library with objc classes. I did load dylib successfully with turning off packing option. But it seems to fail load objc classes in dylib. (tested on 10.15)
Test code:
Code: Select all
//
// in dylib
//
@interface Hello : NSObject
- (void)greeting;
@end
Code: Select all
//
// in app linking with dylib
//
- (void)someMethod {
//
// This code is work well with non protect code.
//
Hello *hello = [[Hello alloc] init];
[hello greeting];
}
I can lookup C-level symbols with dlsym like this:
Code: Select all
Class cls = (__bridge Class)dlsym(RTLD_DEFAULT, "OBJC_CLASS_$_Hello");
I think C-level linking works successfully but objc runtime don't load classes correctly. Is there way to fix?