diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..87b157a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ + +LatestBuild +.DS_Store diff --git a/unitySpeedTools2020.xcodeproj/project.pbxproj b/unitySpeedTools2020.xcodeproj/project.pbxproj index ab26913..1c93992 100644 --- a/unitySpeedTools2020.xcodeproj/project.pbxproj +++ b/unitySpeedTools2020.xcodeproj/project.pbxproj @@ -496,8 +496,7 @@ B1B0C23124519E0600F25F9D /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CODE_SIGN_IDENTITY = x5code; - CODE_SIGN_STYLE = Manual; + CODE_SIGN_IDENTITY = "Apple Development: ZhengDa Xu (7B37679NQV)"; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -523,8 +522,7 @@ B1B0C23224519E0600F25F9D /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CODE_SIGN_IDENTITY = x5code; - CODE_SIGN_STYLE = Manual; + CODE_SIGN_IDENTITY = "Apple Development: ZhengDa Xu (7B37679NQV)"; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; GCC_PRECOMPILE_PREFIX_HEADER = YES; diff --git a/unitySpeedTools2020.xcodeproj/project.xcworkspace/xcuserdata/xuzhengda.xcuserdatad/UserInterfaceState.xcuserstate b/unitySpeedTools2020.xcodeproj/project.xcworkspace/xcuserdata/xuzhengda.xcuserdatad/UserInterfaceState.xcuserstate index b96fd48..f749a0d 100644 Binary files a/unitySpeedTools2020.xcodeproj/project.xcworkspace/xcuserdata/xuzhengda.xcuserdatad/UserInterfaceState.xcuserstate and b/unitySpeedTools2020.xcodeproj/project.xcworkspace/xcuserdata/xuzhengda.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/unitySpeedTools2020/getU3dsystemfunc.mm b/unitySpeedTools2020/getU3dsystemfunc.mm index a5d12b9..bd8029f 100644 --- a/unitySpeedTools2020/getU3dsystemfunc.mm +++ b/unitySpeedTools2020/getU3dsystemfunc.mm @@ -62,133 +62,258 @@ long doLoadFramework(){ mach_port_t *object_name ); +//static int getMap(void* dst, long* ad1, long *ad2){ +// mach_port_t task; +// int rev = 0; +// vm_address_t region = (vm_address_t)dst; +// vm_size_t region_size = 0; +//// XLog(@"getMap dst %lx",dst) +// +// +// vm_region_basic_info_data_64_t info; +// mach_msg_type_number_t info_count = VM_REGION_BASIC_INFO_COUNT_64; +// vm_region_flavor_t flavor = VM_REGION_BASIC_INFO_64; +// if (mach_vm_region(mach_task_self(), ®ion, ®ion_size, flavor, (vm_region_info_t)&info, (mach_msg_type_number_t*)&info_count, (mach_port_t*)&task) != KERN_SUCCESS) +// { +// return rev; +// } +// else{ +// rev = 64; +// } +// +// *ad1 =region; +// *ad2 =region + region_size; +// +// if (info.protection<1) { +// return 0; +// } +// XLog(@"getMap from %lx to %lx",region,region + region_size) +// return rev; +//} +//long dosearch(){ +// long *ad1, *ad2; +// ad1 = (long*)malloc(sizeof(long)); +// ad2 = (long*)malloc(sizeof(long)); +// *ad2=doLoadFramework(); +// /* 判断是否含有il2cpp_resolve_icall_0 函数*/ +// void *il2cpp_resolve_icall_0 = MSFindSymbol(0,"_il2cpp_resolve_icall"); +// if(il2cpp_resolve_icall_0){ +//// il2cpp_resolve_icall位置需要跳转的位置 +// XLog(@"*(int*)il2cpp_resolve_icall_0 %lx %lx ",il2cpp_resolve_icall_0,*(long*)il2cpp_resolve_icall_0 & 0xff000000) +//// 往下查找第一个b +// long baseaddr =(long)il2cpp_resolve_icall_0; +// int whilecount=0; +// while (*(long*)baseaddr & 0xff000000!=0x14000000 && whilecount <10) { +// whilecount+=1; +// baseaddr+=4; +// } +//// 计算偏移:取第一个b的相对位移,先取前3位,然后乘4 +// long bsr=(long)(*(long*)baseaddr & 0xffffff )*4; +// XLog(@"baseaddr %lx:%lx,bsr:%lx",baseaddr,*(long*)baseaddr & 0xffffff ,bsr) +//// 加和 +// long addrforil2cppresolveicall=bsr+(long)baseaddr; +// XLog(@"il2cpp_resolve_icall_0 %lx",addrforil2cppresolveicall); +// return addrforil2cppresolveicall; +// } +// +// /* 未找到il2cpp_resolve_icall_0 函数*/ +// long rev=0; +// while (getMap((void*)(*ad2),ad1,ad2) != 0) { +// rev=searchintarget(*ad1,*ad2); +// if (rev!=0){ +// break; +// } +// } +// return rev; +//} static int getMap(void* dst, long* ad1, long *ad2){ mach_port_t task; - int rev = 0; vm_address_t region = (vm_address_t)dst; vm_size_t region_size = 0; -// XLog(@"getMap dst %lx",dst) - vm_region_basic_info_data_64_t info; mach_msg_type_number_t info_count = VM_REGION_BASIC_INFO_COUNT_64; vm_region_flavor_t flavor = VM_REGION_BASIC_INFO_64; - if (mach_vm_region(mach_task_self(), ®ion, ®ion_size, flavor, (vm_region_info_t)&info, (mach_msg_type_number_t*)&info_count, (mach_port_t*)&task) != KERN_SUCCESS) + kern_return_t kr = mach_vm_region(mach_task_self(), ®ion, ®ion_size, flavor, (vm_region_info_t)&info, (mach_msg_type_number_t*)&info_count, (mach_port_t*)&task); + if (kr != KERN_SUCCESS) { - return rev; - } - else{ - rev = 64; + return 0; } - *ad1 =region; - *ad2 =region + region_size; - - if (info.protection<1) { + *ad1 = region; + *ad2 = region + region_size; + + if (info.protection < 1) { return 0; } - XLog(@"getMap from %lx to %lx",region,region + region_size) - return rev; + XLog(@"getMap from %lx to %lx", region, region + region_size) + return 64; } -long dosearch(){ - long *ad1, *ad2; - ad1 = (long*)malloc(sizeof(long)); - ad2 = (long*)malloc(sizeof(long)); - *ad2=doLoadFramework(); - /* 判断是否含有il2cpp_resolve_icall_0 函数*/ - void *il2cpp_resolve_icall_0 = MSFindSymbol(0,"_il2cpp_resolve_icall"); - if(il2cpp_resolve_icall_0){ -// il2cpp_resolve_icall位置需要跳转的位置 - XLog(@"*(int*)il2cpp_resolve_icall_0 %lx %lx ",il2cpp_resolve_icall_0,*(long*)il2cpp_resolve_icall_0 & 0xff000000) -// 往下查找第一个b - long baseaddr =(long)il2cpp_resolve_icall_0; - int whilecount=0; - while (*(long*)baseaddr & 0xff000000!=0x14000000 && whilecount <10) { - whilecount+=1; - baseaddr+=4; +long dosearch() { + // 分配两个 long 类型指针变量 ad1 和 ad2 的内存空间,大小均为一个 long 类型的字节大小。 + long *ad1 = (long*)malloc(sizeof(long)); + long *ad2 = (long*)malloc(sizeof(long)); + *ad2 = doLoadFramework(); + + // 判断是否含有 il2cpp_resolve_icall_0 函数 + void *il2cpp_resolve_icall_0 = MSFindSymbol(0, "_il2cpp_resolve_icall"); + if (il2cpp_resolve_icall_0) { + // il2cpp_resolve_icall 位置需要跳转的位置 + XLog(@"*(int*)il2cpp_resolve_icall_0 %lx %lx ", il2cpp_resolve_icall_0, *(long*)il2cpp_resolve_icall_0 & 0xff000000); + + // 往下查找第一个 0x14000000 + long baseaddr = (long)il2cpp_resolve_icall_0; + for (int i = 0; i < 10; ++i) { + long value = *(long*)baseaddr; + if ((value & 0xff000000) == 0x14000000) { + long bsr = ((value & 0xffffff) << 2); // 计算偏移 + long addrforil2cppresolveicall = baseaddr + bsr; // 加和 + XLog(@"il2cpp_resolve_icall_0 %lx", addrforil2cppresolveicall); + return addrforil2cppresolveicall; + } + baseaddr += 4; } -// 计算偏移:取第一个b的相对位移,先取前3位,然后乘4 - long bsr=(long)(*(long*)baseaddr & 0xffffff )*4; - XLog(@"baseaddr %lx:%lx,bsr:%lx",baseaddr,*(long*)baseaddr & 0xffffff ,bsr) -// 加和 - long addrforil2cppresolveicall=bsr+(long)baseaddr; - XLog(@"il2cpp_resolve_icall_0 %lx",addrforil2cppresolveicall); - return addrforil2cppresolveicall; } - /* 未找到il2cpp_resolve_icall_0 函数*/ - long rev=0; - while (getMap((void*)(*ad2),ad1,ad2) != 0) { - rev=searchintarget(*ad1,*ad2); - if (rev!=0){ + // 未找到 il2cpp_resolve_icall_0 函数 + long rev = 0; + while (getMap((void*)(*ad2), ad1, ad2) != 0) { + rev = searchintarget(*ad1, *ad2); + if (rev != 0) { break; } } return rev; } -long searchintarget(long ad1,long ad2){ - /* framework 类型的unity */ - int target[]={0xFF03,0x02D1,0xF85F,0x04A9,0xF657,0x05A9,0xF44F,0x06A9,0xFD7B,0x07A9,0xFDC3,0x0191,0xF303,0x00AA,0xFFFF,0x02A9,0xFF13,0x00F9}; - /* 普通类型的unity */ +//long searchintarget(long ad1,long ad2){ +// /* framework 类型的unity */ +// int target[]={0xFF03,0x02D1,0xF85F,0x04A9,0xF657,0x05A9,0xF44F,0x06A9,0xFD7B,0x07A9,0xFDC3,0x0191,0xF303,0x00AA,0xFFFF,0x02A9,0xFF13,0x00F9}; +// /* 普通类型的unity */ +// int target1[] = {0xF657, 0xBDA9, 0xF44F, 0x01A9, 0xFD7B, 0x02A9, 0xFD83, 0x0091, 0xFF43, 0x01D1, 0xF403, 0x00AA, 0xFF7F, 0x04A9, 0xFF1F, 0x00F9}; +// long now = (long)ad1; +// long end = (long)ad2; +// long rev = 0; +// long temprev = 0; +// +// XLog(@"\tnow 0x%lx-0x%lx ",now,end); +// unsigned long len = sizeof(target)/sizeof(int); +// int * bearray = (int*)malloc(sizeof(int)*len); +// for (int i=0;itv_usec *= SPEEDLEVEL; + tv->tv_sec *= SPEEDLEVEL; + } + return ret; +} diff --git a/unitySpeedTools2020/unitySpeedTools2020.mm b/unitySpeedTools2020/unitySpeedTools2020.mm index 9f60f2c..f5b1e17 100644 --- a/unitySpeedTools2020/unitySpeedTools2020.mm +++ b/unitySpeedTools2020/unitySpeedTools2020.mm @@ -1,4 +1,4 @@ -#line 1 "/Users/xuzhengda/Documents/GitHub/unitySpeedTools/unitySpeedTools2020/unitySpeedTools2020.xm" +#line 1 "/Users/xuzhengda/Documents/Github/unitySpeedTools/unitySpeedTools2020/unitySpeedTools2020.xm" #import "p_inc.h" #import @@ -77,12 +77,13 @@ + (void)ss1:(bool)isOn{ cspeed64(); break; case SW_COCO2D: + cspeed64_cocos2dx(); break; default: break; } - + } + (void)ss2:(float)spValue{ @@ -99,9 +100,9 @@ + (void)ss2:(float)spValue{ spValue/=len; spValue=1-spValue; } - - - + + + vF1 = spValue; @@ -110,6 +111,7 @@ + (void)ss2:(float)spValue{ cspeed64(); break; case SW_COCO2D: + cspeed64_cocos2dx(); break; default: break; @@ -141,8 +143,8 @@ static enum ENGINE_STATE execSearch(){ - void memPrint64(long start, long len, int type){ - XLog(@"memPrint64 start:0x%lx",start) +void memPrint64(long start, long len, int type){ + XLog(@"memPrint64 start:0x%lx",start) long now = start; long end = start+len; while (now<=end) { @@ -176,6 +178,9 @@ void unhooku3dsystemfuncAddr64(){ extern "C" { void aSimpleUnhook(bool isHook){ + if(speedType==SW_COCO2D){ + return; + } XLog(@"set to hook=%d? 1=hook,0=unhook",isHook) long thisAddr=set_timeScale_addr[0]; if (vm_protect(mach_task_self(), (vm_address_t) (thisAddr ), 0x10, 0, VM_PROT_READ | VM_PROT_WRITE | VM_PROT_COPY)== KERN_SUCCESS) @@ -199,7 +204,7 @@ void aSimpleUnhook(bool isHook){ } } static enum ENGINE_STATE setU3DHook(){ - + gb_state=SP_INIT_NIL; long u3dsystemfuncAddr64=0; u3dsystemfuncAddr64=dosearch(); @@ -271,18 +276,18 @@ static enum ENGINE_STATE setU3DHook(){ #define _LOGOS_RETURN_RETAINED #endif -@class UnityView; @class UnityAppController; +@class UnityAppController; @class UnityView; static void (*_logos_orig$_ungrouped$UnityView$touchesBegan$withEvent$)(_LOGOS_SELF_TYPE_NORMAL UnityView* _LOGOS_SELF_CONST, SEL, id, id); static void _logos_method$_ungrouped$UnityView$touchesBegan$withEvent$(_LOGOS_SELF_TYPE_NORMAL UnityView* _LOGOS_SELF_CONST, SEL, id, id); static BOOL (*_logos_orig$_ungrouped$UnityAppController$application$didFinishLaunchingWithOptions$)(_LOGOS_SELF_TYPE_NORMAL UnityAppController* _LOGOS_SELF_CONST, SEL, id, id); static BOOL _logos_method$_ungrouped$UnityAppController$application$didFinishLaunchingWithOptions$(_LOGOS_SELF_TYPE_NORMAL UnityAppController* _LOGOS_SELF_CONST, SEL, id, id); -#line 252 "/Users/xuzhengda/Documents/GitHub/unitySpeedTools/unitySpeedTools2020/unitySpeedTools2020.xm" +#line 257 "/Users/xuzhengda/Documents/Github/unitySpeedTools/unitySpeedTools2020/unitySpeedTools2020.xm" static void _logos_method$_ungrouped$UnityView$touchesBegan$withEvent$(_LOGOS_SELF_TYPE_NORMAL UnityView* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd, id touches, id event){ - XLog(@"touchesBegan %d %lx",gb_state,sys_speed_control); - - - - - XLog(@"show x5 icon") + + + + + + [x5fPmc showIcon]; _logos_orig$_ungrouped$UnityView$touchesBegan$withEvent$(self, _cmd, touches, event); } @@ -294,17 +299,17 @@ void startSearchAndInject(){ return; } dispatch_queue_t queue = dispatch_queue_create("1212", DISPATCH_QUEUE_CONCURRENT); - dispatch_async(queue, ^{ - gb_state=SP_INIT_WAIT; - XLog(@"1---%@",[NSThread currentThread]); - XLog(@"Loading UnitySpeedTools for unity engine") - if([preread(@"sw_f1") boolValue]){ - speedType = SW_UNITY; - XLog(@"#########2"); - execSearch(); - XLog(@"--- init rev %d ---", gb_state); - } - }); + dispatch_async(queue, ^{ + gb_state=SP_INIT_WAIT; + XLog(@"1---%@",[NSThread currentThread]); + XLog(@"Loading UnitySpeedTools for unity engine") + if([preread(@"sw_f1") boolValue]){ + speedType = SW_UNITY; + XLog(@"#########2"); + execSearch(); + XLog(@"--- init rev %d ---", gb_state); + } + }); } } long doLoadFramework(); @@ -313,6 +318,140 @@ void constructor(void) { XLog(@"Loading UnitySpeedTools for unity engine, delay 30s") doLoadFramework(); + + + + + + + + + + + + + + + +} + + + + + + +static BOOL _logos_method$_ungrouped$UnityAppController$application$didFinishLaunchingWithOptions$(_LOGOS_SELF_TYPE_NORMAL UnityAppController* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd, id application, id options) { + XLog(@"-(BOOL)application:(id)application didFinishLaunchingWithOptions:(id)options") + startSearchAndInject(); + [x5fPmc defaultCenter]; + + return _logos_orig$_ungrouped$UnityAppController$application$didFinishLaunchingWithOptions$(self, _cmd, application, options); +} + +#import +NSString * getFilePath() { + NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); + NSString *documentsDirectory = [documentPaths objectAtIndex:0]; + return [documentsDirectory stringByAppendingPathComponent:@"bundleIDs.plist"]; +} +NSString * getBundleID() { + return [[NSBundle mainBundle] bundleIdentifier]; +} +void saveBundleIDConfirmation(id confirmation) { + NSString *bundleID = getBundleID(); + NSString *filePath = getFilePath(); + + NSDictionary *data = [NSDictionary dictionaryWithContentsOfFile:filePath]; + NSMutableDictionary *savedData = [NSMutableDictionary dictionaryWithDictionary:data]; + + if (!savedData) { + savedData = [NSMutableDictionary dictionary]; + } + + [savedData setObject:confirmation forKey:bundleID]; + [savedData writeToFile:filePath atomically:YES]; +} + +void showChoiced(){ + + dispatch_async(dispatch_get_main_queue(), ^{ + UIViewController *rootViewController = [[[UIApplication sharedApplication] keyWindow] rootViewController]; + UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"确认" + message:@"是否确认该 Bundle ID?" + preferredStyle:UIAlertControllerStyleAlert]; + + + + + UIAlertAction *yesAction = [UIAlertAction actionWithTitle:@"是" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { + saveBundleIDConfirmation(@"YES"); + }]; + UIAlertAction *noAction = [UIAlertAction actionWithTitle:@"否" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { + saveBundleIDConfirmation(@"NO"); + }]; + + UIAlertAction *disableAction = [UIAlertAction actionWithTitle:@"禁用" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { + saveBundleIDConfirmation(@"AB"); + }]; + + [alertController addAction:yesAction]; + [alertController addAction:noAction]; + [alertController addAction:disableAction]; + + [rootViewController presentViewController:alertController animated:YES completion:nil]; + }); +} +extern int (*orig_gettimeofday)(struct timeval * __restrict, void * __restrict); +extern int mygettimeofday(struct timeval*tv,struct timezone *tz ); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -326,21 +465,12 @@ void constructor(void) - -} -static BOOL _logos_method$_ungrouped$UnityAppController$application$didFinishLaunchingWithOptions$(_LOGOS_SELF_TYPE_NORMAL UnityAppController* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd, id application, id options) { - XLog(@"-(BOOL)application:(id)application didFinishLaunchingWithOptions:(id)options") - startSearchAndInject(); - [x5fPmc defaultCenter]; - - return _logos_orig$_ungrouped$UnityAppController$application$didFinishLaunchingWithOptions$(self, _cmd, application, options); -} static __attribute__((constructor)) void _logosLocalInit() { {Class _logos_class$_ungrouped$UnityView = objc_getClass("UnityView"); { MSHookMessageEx(_logos_class$_ungrouped$UnityView, @selector(touchesBegan:withEvent:), (IMP)&_logos_method$_ungrouped$UnityView$touchesBegan$withEvent$, (IMP*)&_logos_orig$_ungrouped$UnityView$touchesBegan$withEvent$);}Class _logos_class$_ungrouped$UnityAppController = objc_getClass("UnityAppController"); { MSHookMessageEx(_logos_class$_ungrouped$UnityAppController, @selector(application:didFinishLaunchingWithOptions:), (IMP)&_logos_method$_ungrouped$UnityAppController$application$didFinishLaunchingWithOptions$, (IMP*)&_logos_orig$_ungrouped$UnityAppController$application$didFinishLaunchingWithOptions$);}} } -#line 318 "/Users/xuzhengda/Documents/GitHub/unitySpeedTools/unitySpeedTools2020/unitySpeedTools2020.xm" +#line 448 "/Users/xuzhengda/Documents/Github/unitySpeedTools/unitySpeedTools2020/unitySpeedTools2020.xm" diff --git a/unitySpeedTools2020/unitySpeedTools2020.xm b/unitySpeedTools2020/unitySpeedTools2020.xm index 39793c5..5ca2375 100644 --- a/unitySpeedTools2020/unitySpeedTools2020.xm +++ b/unitySpeedTools2020/unitySpeedTools2020.xm @@ -76,12 +76,13 @@ NSMutableArray * cptm, * cpts, *cptm64, *cpts64; cspeed64(); break; case SW_COCO2D: + cspeed64_cocos2dx(); break; default: break; } - + } + (void)ss2:(float)spValue{ @@ -98,9 +99,9 @@ NSMutableArray * cptm, * cpts, *cptm64, *cpts64; spValue/=len; spValue=1-spValue; } - - -// XLog(@"setVf1:%f isF1 %d",spValue,isF1); + + + // XLog(@"setVf1:%f isF1 %d",spValue,isF1); vF1 = spValue; @@ -109,6 +110,7 @@ NSMutableArray * cptm, * cpts, *cptm64, *cpts64; cspeed64(); break; case SW_COCO2D: + cspeed64_cocos2dx(); break; default: break; @@ -140,8 +142,8 @@ static enum ENGINE_STATE execSearch(){ - void memPrint64(long start, long len, int type){ - XLog(@"memPrint64 start:0x%lx",start) +void memPrint64(long start, long len, int type){ + XLog(@"memPrint64 start:0x%lx",start) long now = start; long end = start+len; while (now<=end) { @@ -175,6 +177,9 @@ void unhooku3dsystemfuncAddr64(){ extern "C" { void aSimpleUnhook(bool isHook){ + if(speedType==SW_COCO2D){ + return; + } XLog(@"set to hook=%d? 1=hook,0=unhook",isHook) long thisAddr=set_timeScale_addr[0]; if (vm_protect(mach_task_self(), (vm_address_t) (thisAddr ), 0x10, 0, VM_PROT_READ | VM_PROT_WRITE | VM_PROT_COPY)== KERN_SUCCESS) @@ -198,7 +203,7 @@ void aSimpleUnhook(bool isHook){ } } static enum ENGINE_STATE setU3DHook(){ -// enum ENGINE_STATE rev = SP_INIT_NIL; + // enum ENGINE_STATE rev = SP_INIT_NIL; gb_state=SP_INIT_NIL; long u3dsystemfuncAddr64=0; u3dsystemfuncAddr64=dosearch(); @@ -251,12 +256,12 @@ extern long ne_sys_speed_control(float a1); /*******************Hook Functions***********************/ %hook UnityView - (void)touchesBegan:(id)touches withEvent:(id)event{ - XLog(@"touchesBegan %d %lx",gb_state,sys_speed_control); -// if(gb_state==2 && sys_speed_control){ -// XLog(@"show x5 icon") -// [x5fPmc showIcon]; -// } - XLog(@"show x5 icon") + // XLog(@"touchesBegan %d %lx",gb_state,sys_speed_control); + // if(gb_state==2 && sys_speed_control){ + // XLog(@"show x5 icon") + // [x5fPmc showIcon]; + // } + // XLog(@"show x5 icon") [x5fPmc showIcon]; %orig; } @@ -268,17 +273,17 @@ void startSearchAndInject(){ return; } dispatch_queue_t queue = dispatch_queue_create("1212", DISPATCH_QUEUE_CONCURRENT); - dispatch_async(queue, ^{ - gb_state=SP_INIT_WAIT; - XLog(@"1---%@",[NSThread currentThread]); // 打印当前线程 - XLog(@"Loading UnitySpeedTools for unity engine") - if([preread(@"sw_f1") boolValue]){ - speedType = SW_UNITY; - XLog(@"#########2"); - execSearch(); - XLog(@"--- init rev %d ---", gb_state); - } - }); + dispatch_async(queue, ^{ + gb_state=SP_INIT_WAIT; + XLog(@"1---%@",[NSThread currentThread]); // 打印当前线程 + XLog(@"Loading UnitySpeedTools for unity engine") + if([preread(@"sw_f1") boolValue]){ + speedType = SW_UNITY; + XLog(@"#########2"); + execSearch(); + XLog(@"--- init rev %d ---", gb_state); + } + }); } } long doLoadFramework(); @@ -287,22 +292,24 @@ void constructor(void) { XLog(@"Loading UnitySpeedTools for unity engine, delay 30s") doLoadFramework(); -//dispatch_queue_t queue = dispatch_queue_create("1212", DISPATCH_QUEUE_CONCURRENT); -// dispatch_async(queue, ^{ -// // 追加任务 1 -// [NSThread sleepForTimeInterval:40]; // 模拟耗时操作 -// XLog(@"1---%@",[NSThread currentThread]); // 打印当前线程 -// XLog(@"Loading UnitySpeedTools for unity engine") -// if([preread(@"sw_f1") boolValue]){ -// speedType = SW_UNITY; -// XLog(@"#########2"); -// execSearch(); -// XLog(@"--- init rev %d ---", gb_state); -// } -// }); + + //dispatch_queue_t queue = dispatch_queue_create("1212", DISPATCH_QUEUE_CONCURRENT); + // dispatch_async(queue, ^{ + // // 追加任务 1 + // [NSThread sleepForTimeInterval:40]; // 模拟耗时操作 + // XLog(@"1---%@",[NSThread currentThread]); // 打印当前线程 + // XLog(@"Loading UnitySpeedTools for unity engine") + // if([preread(@"sw_f1") boolValue]){ + // speedType = SW_UNITY; + // XLog(@"#########2"); + // execSearch(); + // XLog(@"--- init rev %d ---", gb_state); + // } + // }); } + //#import "/usr/include/Availability.h" %hook UnityAppController // @@ -315,3 +322,126 @@ void constructor(void) return %orig; } %end +#import +NSString * getFilePath() { + NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); + NSString *documentsDirectory = [documentPaths objectAtIndex:0]; + return [documentsDirectory stringByAppendingPathComponent:@"bundleIDs.plist"]; +} +NSString * getBundleID() { + return [[NSBundle mainBundle] bundleIdentifier]; +} +void saveBundleIDConfirmation(id confirmation) { + NSString *bundleID = getBundleID(); + NSString *filePath = getFilePath(); + + NSDictionary *data = [NSDictionary dictionaryWithContentsOfFile:filePath]; + NSMutableDictionary *savedData = [NSMutableDictionary dictionaryWithDictionary:data]; + + if (!savedData) { + savedData = [NSMutableDictionary dictionary]; + } + + [savedData setObject:confirmation forKey:bundleID]; + [savedData writeToFile:filePath atomically:YES]; +} + +void showChoiced(){ + // 弹出确认框 + dispatch_async(dispatch_get_main_queue(), ^{ + UIViewController *rootViewController = [[[UIApplication sharedApplication] keyWindow] rootViewController]; + UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"确认" + message:@"是否确认该 Bundle ID?" + preferredStyle:UIAlertControllerStyleAlert]; + // UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"确认" + // message:@"是否确认该 Bundle ID?" + // preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction *yesAction = [UIAlertAction actionWithTitle:@"是" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { + saveBundleIDConfirmation(@"YES"); + }]; + UIAlertAction *noAction = [UIAlertAction actionWithTitle:@"否" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { + saveBundleIDConfirmation(@"NO"); + }]; + + UIAlertAction *disableAction = [UIAlertAction actionWithTitle:@"禁用" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { + saveBundleIDConfirmation(@"AB"); + }]; + + [alertController addAction:yesAction]; + [alertController addAction:noAction]; + [alertController addAction:disableAction]; + + [rootViewController presentViewController:alertController animated:YES completion:nil]; + }); +} +extern int (*orig_gettimeofday)(struct timeval * __restrict, void * __restrict); +extern int mygettimeofday(struct timeval*tv,struct timezone *tz ); + + +//#include +//%hook AppController +//- (BOOL)application:(id)application didFinishLaunchingWithOptions:(id)launchOptions { +// NSString *filePath = getFilePath(); // 获取文件路径 +// +// // 检查文件是否存在 +// if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) { +// NSDictionary *savedData = [NSDictionary dictionaryWithContentsOfFile:filePath]; +// NSString *bundleID = getBundleID(); +// +// // 检查文件中是否已经记录了该 Bundle ID +// id savedopt = [savedData objectForKey:bundleID]; +// if (savedopt) { +// // 已记录,不再弹框 +// XLog(@"Bundle ID: %@ 已经记录, key is %@", bundleID, savedopt); +// if ([savedopt isEqualToString:@"AB"]) { +// return %orig; // 禁用,直接返回 +// } +// else if ([savedopt isEqualToString:@"YES"]) { +// // 执行加速 +// // 获取应用程序的委托对象 +//// XLog(@"_gettimeofday %lx",MSFindSymbol(NULL,"_gettimeofday")) +//// MSHookFunction((void *)MSFindSymbol(NULL,"_gettimeofday"), (void *)mygettimeofday, (void **)&orig_gettimeofday); +// dispatch_async(dispatch_get_main_queue(), ^{ +// // 获取应用程序的主窗口 +// UIWindow *mainWindow = [UIApplication sharedApplication].keyWindow; +// +// // 创建并显示自动消失的提示框 +// UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" +// message:@"已开启" +// preferredStyle:UIAlertControllerStyleAlert]; +// +// [mainWindow.rootViewController presentViewController:alertController animated:YES completion:nil]; +// +// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ +// [alertController dismissViewControllerAnimated:YES completion:nil]; +// }); +// +// }); +//// XLog(@"_gettimeofday %lx",MSFindSymbol("/usr/lib/libc++.1.dylib","_gettimeofday")) +// MSHookFunction((void *)gettimeofday, (void *)mygettimeofday, (void **)&orig_gettimeofday);; +// speedType=SW_COCO2D; +// gb_state=SP_INIT_DONE; +// [x5fPmc defaultCenter]; +// [x5fPmc showIcon]; +// return %orig; +// } else{ +// showChoiced(); +// } +// return %orig; +// } +// }else{ +// showChoiced(); +// } +// +// +// return %orig; +//} +// +//%end