Problem with writing mobilesubstrate plugins for iOS
Posted
by overboming
on Stack Overflow
See other posts from Stack Overflow
or by overboming
Published on 2010-06-13T13:08:30Z
Indexed on
2010/06/13
13:12 UTC
Read the original article
Hit count: 271
I am trying to hooking message sending for iOS 3.2, I implement my own hook on a working ExampleHook program I find on the web. But my hook apparently caused segmentation fault everytime it hooks and I don't know why. I want to hook to
[NSURL initWithString:(NSString *)URLString relativeToURL:(NSURL *)baseURL;
and here is my related implementation
static id __$GFWInterceptor_NSURL_initWithString2(NSURL<GFWInterceptor> *_NSURL, NSString *URLString, NSURL* baseURL){
NSLog(@"We have intercepted this url: %@",URLString);
[_NSURL __HelloNSURL_initWithString:URLString relativeToURL:baseURL];
establish hook
Class _$NSURL = objc_getClass("NSURL");
MSHookMessage(_$NSURL, @selector(initWithString:relativeToURL:), (IMP) &__$GFWInterceptor_NSURL_initWithString2, "__HelloNSURL_");
original method declaration
- (void)__HelloNSURL_initWithString:(NSString *)URLString relativeToURL:(NSURL *)baseURL;
and here is my gdb backtrace
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x74696e71 0x335625f8 in objc_msgSend () (gdb) bt
0 0x335625f8 in objc_msgSend ()
1 0x32c05b1a in CFStringGetLength ()
2 0x32c108a8 in _CFStringIsLegalURLString ()
3 0x32b1c32a in -[NSURL initWithString:relativeToURL:] ()
4 0x000877c0 in __$GFWInterceptor_NSURL_initWithString2 ()
5 0x32b1c220 in +[NSURL URLWithString:relativeToURL:] ()
6 0x32b1c1f4 in +[NSURL URLWithString:] ()
7 0x3061c614 in createUniqueWebDataURL ()
8 0x3061c212 in +[WebFrame(WebInternal) _createMainFrameWithSimpleHTMLDocumentWithPage:frameView:withStyle:editable:] ()
and apparently it hooks, but there is some memory issue there and I can't find anything to blame now
© Stack Overflow or respective owner