can't load objc class from dylib

Issues related to VMProtect
Post Reply
K.H.Cyp
Posts: 1
Joined: Wed Dec 25, 2019 3:11 am

can't load objc class from dylib

Post by K.H.Cyp »

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:

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];
}
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:

Code: Select all

Class cls = (__bridge Class)dlsym(RTLD_DEFAULT, "OBJC_CLASS_$_Hello");
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?
Admin
Site Admin
Posts: 2694
Joined: Mon Aug 21, 2006 8:19 pm
Location: Russia, E-burg
Contact:

Re: can't load objc class from dylib

Post by Admin »

Please send us a very simple example (app linking with dylib + original dylib) that shows your problem.
Post Reply