Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

Commit

Permalink
Use dyldAPI to deal with images that ain't automatically loaded.Check…
Browse files Browse the repository at this point in the history
… CoreTelephony for more info
  • Loading branch information
Naville committed Feb 16, 2016
1 parent dbfe2ab commit e685b09
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
17 changes: 14 additions & 3 deletions Hooks/APIHooks/CoreTelephony.xm
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,22 @@ typedef void (*CTServerConnectionCallback)(CTServerConnectionRef, CFStringRef, C
int _CTServerConnectionSetVibratorState(int *, void *, int, int, int, int, int);
*/


extern void init_CoreTelephony_hook(){
static void CTdyldCallBack(const struct mach_header* mh, intptr_t vmaddr_slide){
Dl_info image_info;
dladdr(mh, &image_info);//Will This Trigger Our Hook in DLFCN?
const char *image_name = image_info.dli_fname;
NSString* name=[NSString stringWithUTF8String:image_name];
if([name containsString:@"CoreTelephony"]){
%init(CoreTelephony);
MSHookFunction(((void*)MSFindSymbol(NULL, "__CTServerConnectionCopyMobileEquipmentInfo")),(void*)new_CTServerConnectionCopyMobileEquipmentInfo, (void**)&old_CTServerConnectionCopyMobileEquipmentInfo);
MSHookFunction(((void*)MSFindSymbol(NULL, "__CTServerConnectionCellMonitorGetCellCount")),(void*)_CTServerConnectionCellMonitorGetCellCount, (void**)&old_CTServerConnectionCellMonitorGetCellCount);
MSHookFunction(((void*)MSFindSymbol(NULL, "__CTServerConnectionCellMonitorGetCellInfo")),(void*)_CTServerConnectionCellMonitorGetCellInfo, (void**)&old_CTServerConnectionCellMonitorGetCellInfo);

}

}


extern void init_CoreTelephony_hook(){
_dyld_register_func_for_add_image(&CTdyldCallBack);
}
20 changes: 16 additions & 4 deletions Hooks/APIHooks/libMobileGestalt.xm
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,23 @@ int MGSetAnswer(CFStringRef question, CFTypeRef answer){


}
static void MobileGestaltdyldCallBack(const struct mach_header* mh, intptr_t vmaddr_slide){
Dl_info image_info;
dladdr(mh, &image_info);//Will This Trigger Our Hook in DLFCN?
const char *image_name = image_info.dli_fname;
NSString* name=[NSString stringWithUTF8String:image_name];
if([name containsString:@"MobileGestalt"]){
MSHookFunction(((void*)MSFindSymbol(NULL, "_MGCopyAnswer")),(void*)MGCopyAnswer, (void**)&old_MGCopyAnswer);
MSHookFunction(((void*)MSFindSymbol(NULL, "_MGCopyMultipleAnswers")),(void*)MGCopyMultipleAnswers, (void**)&old_MGCopyMultipleAnswers);
MSHookFunction(((void*)MSFindSymbol(NULL, "_MGSetAnswer")),(void*)MGSetAnswer, (void**)&old_MGSetAnswer);

}

}


extern void init_libMobileGestalt_hook(){
MSHookFunction(((void*)MSFindSymbol(NULL, "_MGCopyAnswer")),(void*)MGCopyAnswer, (void**)&old_MGCopyAnswer);
MSHookFunction(((void*)MSFindSymbol(NULL, "_MGCopyMultipleAnswers")),(void*)MGCopyMultipleAnswers, (void**)&old_MGCopyMultipleAnswers);
MSHookFunction(((void*)MSFindSymbol(NULL, "_MGSetAnswer")),(void*)MGSetAnswer, (void**)&old_MGSetAnswer);
_dyld_register_func_for_add_image(&MobileGestaltdyldCallBack);
}

//Shall We Check Entitlement com.apple.private.MobileGestalt.AllowedProtectedKeys
//Shall We Check Entitlement com.apple.private.MobileGestalt.AllowedProtectedKeys ,which is needed for certain keys?
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
204
206

0 comments on commit e685b09

Please sign in to comment.