def register() -> None: if HM.existClass(gClassName): return # Register class HMProgressHUD.show(f"Register {gClassName}...") HM.DPrint(f"Register {gClassName}...") classValue = HM.allocateClass(gClassName, HMDebugBaseViewController.gClassName) HM.addIvar(classValue.GetValue(), "_leftTextArray", "NSMutableArray *") HM.addIvar(classValue.GetValue(), "_rightTextArray", "NSMutableArray *") HM.registerClass(classValue.GetValue()) # Add methods HM.DPrint(f"Add methods to {gClassName}...") viewDidLoadIMPValue = makeViewDidLoadIMP() if not HM.judgeSBValueHasValue(viewDidLoadIMPValue): HMProgressHUD.hide() return HM.addInstanceMethod(gClassName, "viewDidLoad", viewDidLoadIMPValue.GetValue(), "v@:") # Methods related to tableView. HM.DPrint(f"Add methods to {gClassName}......") if not addTableViewMethods(): HMProgressHUD.hide() return HM.DPrint(f"Register {gClassName} done!") HMProgressHUD.hide()
def register() -> None: if HM.existClass(gClassName): return # Register class HM.DPrint(f"Register {gClassName}...") classValue = HM.allocateClass(gClassName, "UIView") HM.addIvar(classValue.GetValue(), "_contentView", "UIView *") HM.addIvar(classValue.GetValue(), "_indicator", "UIActivityIndicatorView *") HM.addIvar(classValue.GetValue(), "_textLab", "UILabel *") HM.addIvar(classValue.GetValue(), "_hideDelayTimer", "NSTimer *") HM.registerClass(classValue.GetValue()) # Add Class methods HM.DPrint(f"Add methods to {gClassName}...") sharedInstanceIMPValue = makeSharedInstanceIMP() if not HM.judgeSBValueHasValue(sharedInstanceIMPValue): return HM.addClassMethod(gClassName, "sharedInstance", sharedInstanceIMPValue.GetValue(), "@@:") showHUDIMPValue = makeShowHUDIMP() if not HM.judgeSBValueHasValue(showHUDIMPValue): return HM.addClassMethod(gClassName, "showHUD", showHUDIMPValue.GetValue(), "@@:") showOnlyTextIMPValue = makeShowOnlyTextHiddenAfterDelayIMP() if not HM.judgeSBValueHasValue(showOnlyTextIMPValue): return HM.addClassMethod(gClassName, "showOnlyText:hiddenAfterDelay:", showOnlyTextIMPValue.GetValue(), "@@:@i") hideHUDIMPValue = makeHideHUDIMP() if not HM.judgeSBValueHasValue(hideHUDIMPValue): return HM.addClassMethod(gClassName, "hideHUD", hideHUDIMPValue.GetValue(), "@@:") setTextIMPValue = makeSetTextIMP() if not HM.judgeSBValueHasValue(setTextIMPValue): return HM.addClassMethod(gClassName, "setText:", setTextIMPValue.GetValue(), "v@:@") # Add Instance methods HM.DPrint(f"Add methods to {gClassName}......") initWithFrameIMPValue = makeInitWithFrameIMP() if not HM.judgeSBValueHasValue(initWithFrameIMPValue): return HM.addInstanceMethod(gClassName, "initWithFrame:", initWithFrameIMPValue.GetValue(), "@@:{CGRect={CGPoint=dd}{CGSize=dd}}") layoutSubviewsIMPValue = makeLayoutSubviewsIMP() if not HM.judgeSBValueHasValue(layoutSubviewsIMPValue): return HM.addInstanceMethod(gClassName, "layoutSubviews", layoutSubviewsIMPValue.GetValue(), "v@:") HM.DPrint(f"Register {gClassName} done!")
def showFPS(debugger, command, exe_ctx, result, internal_dict): """ Syntax: showfps Examples: (lldb) showfps Notice: showfps is deprecated. Use showhud instead. This command is implemented in HMFPSLabel.py """ HM.DPrint("showfps is deprecated. Use showhud instead.") FPSClassName = "HMFPSLabel" if HM.existClass(FPSClassName): HM.DPrint("HMFPSLabel is already on display") return # Register class FPSLabelClassValue = HM.allocateClass(FPSClassName, "UILabel") HM.addIvar(FPSLabelClassValue.GetValue(), "_link", "CADisplayLink *") HM.addIvar(FPSLabelClassValue.GetValue(), "_count", "int") HM.addIvar(FPSLabelClassValue.GetValue(), "_lastTime", "double") HM.registerClass(FPSLabelClassValue.GetValue()) addToKeyWindowIMPValue = makeAddToKeyWindowIMP() if not HM.judgeSBValueHasValue(addToKeyWindowIMPValue): return HM.addClassMethod(FPSClassName, "addToKeyWindow", addToKeyWindowIMPValue.GetValue(), "@@:") tickIMPValue = makeTickIMP() if not HM.judgeSBValueHasValue(tickIMPValue): return HM.addInstanceMethod(FPSClassName, "tick:", tickIMPValue.GetValue(), "v@:@") # Show fps command addToKeyWindowCommand = ''' Class fps = NSClassFromString(@"HMFPSLabel"); (UILabel *)[fps performSelector:@selector(addToKeyWindow)]; ''' HM.evaluateExpressionValue(addToKeyWindowCommand) HM.DPrint("showfps Done!") HM.processContinue()
def register() -> None: if HM.existClass(gClassName): return HMProgressHUD.register() HMDebugWindow.register() HMDebugBaseViewController.register() # Register class HMProgressHUD.show(f"Register {gClassName}...") HM.DPrint(f"Register {gClassName}...") classValue = HM.allocateClass(gClassName, HMDebugBaseViewController.gClassName) HM.addIvar(classValue.GetValue(), "_previousKeyWindow", "UIWindow *") HM.addIvar(classValue.GetValue(), "_highlightView", "UIView *") HM.addIvar(classValue.GetValue(), "_targetView", "UIView *") HM.addIvar(classValue.GetValue(), "_exitBtn", "UIButton *") HM.addIvar(classValue.GetValue(), "_infoView", "UIView *") HM.addIvar(classValue.GetValue(), "_actionView", "UIButton *") HM.registerClass(classValue.GetValue()) HM.DPrint(f"Add methods to {gClassName}...") startIMPValue = makeStartIMP() if not HM.judgeSBValueHasValue(startIMPValue): HMProgressHUD.hide() return HM.addClassMethod(gClassName, "start", startIMPValue.GetValue(), "@@:") viewDidLoadIMPValue = makeViewDidLoadIMP() if not HM.judgeSBValueHasValue(viewDidLoadIMPValue): HMProgressHUD.hide() return HM.addInstanceMethod(gClassName, "viewDidLoad", viewDidLoadIMPValue.GetValue(), "v@:") viewDidLayoutSubviewsIMPValue = makeViewDidLayoutSubviewsIMP() if not HM.judgeSBValueHasValue(viewDidLayoutSubviewsIMPValue): HMProgressHUD.hide() return HM.addInstanceMethod(gClassName, "viewDidLayoutSubviews", viewDidLayoutSubviewsIMPValue.GetValue(), "v@:") # event HM.DPrint(f"Add methods to {gClassName}......") clickExitBtnIMPValue = makeClickExitBtnIMP() if not HM.judgeSBValueHasValue(clickExitBtnIMPValue): HMProgressHUD.hide() return HM.addInstanceMethod(gClassName, "clickExitBtn", clickExitBtnIMPValue.GetValue(), "v@:") clickCloseBtnIMPValue = makeClickCloseBtnIMP() if not HM.judgeSBValueHasValue(clickCloseBtnIMPValue): HMProgressHUD.hide() return HM.addInstanceMethod(gClassName, "clickCloseBtn", clickCloseBtnIMPValue.GetValue(), "v@:") handleTapRecognizerIMPValue = makeHandleTapRecognizerIMP() if not HM.judgeSBValueHasValue(handleTapRecognizerIMPValue): HMProgressHUD.hide() return HM.addInstanceMethod(gClassName, "handleTapRecognizer:", handleTapRecognizerIMPValue.GetValue(), "v@:@") findSubviewAtPointInViewIMPValue = makeFindSubviewAtPointInViewIMP() if not HM.judgeSBValueHasValue(findSubviewAtPointInViewIMPValue): HMProgressHUD.hide() return HM.addInstanceMethod(gClassName, "findSubviewAtPoint:inView:", findSubviewAtPointInViewIMPValue.GetValue(), "@@:{CGPoint=dd}@") refreshTargetViewIMPValue = makeRefreshTargetViewIMP() if not HM.judgeSBValueHasValue(refreshTargetViewIMPValue): HMProgressHUD.hide() return HM.addInstanceMethod(gClassName, "refreshTargetView:", refreshTargetViewIMPValue.GetValue(), "v@:@") getInfoArrayFromTargetViewIMPValue = makeGetInfoArrayFromTargetViewIMP() if not HM.judgeSBValueHasValue(getInfoArrayFromTargetViewIMPValue): HMProgressHUD.hide() return HM.addInstanceMethod(gClassName, "getInfoArrayFromTargetView:", getInfoArrayFromTargetViewIMPValue.GetValue(), "@@:@") # function action HM.DPrint(f"Add methods to {gClassName}.........") if not addFunctionMethods(): HMProgressHUD.hide() return HM.DPrint(f"Register {gClassName} done!") HMProgressHUD.hide()
def register() -> None: if HM.existClass(gClassName): return HMProgressHUD.register() HMDebugBaseViewController.register() # Register class HMProgressHUD.show(f"Register {gClassName}...") HM.DPrint(f"Register {gClassName}...") classValue = HM.allocateClass(gClassName, HMDebugBaseViewController.gClassName) HM.addIvar(classValue.GetValue(), "_tableView", "UITableView *") HM.addIvar(classValue.GetValue(), "_currentPath", "NSString *") HM.addIvar(classValue.GetValue(), "_childPaths", "NSMutableArray *") HM.registerClass(classValue.GetValue()) # Add methods HM.DPrint(f"Add methods to {gClassName}...") viewDidLoadIMPValue = makeViewDidLoadIMP() if not HM.judgeSBValueHasValue(viewDidLoadIMPValue): HMProgressHUD.hide() return HM.addInstanceMethod(gClassName, "viewDidLoad", viewDidLoadIMPValue.GetValue(), "v@:") loadPathIMPValue = makeLoadPathIMP() if not HM.judgeSBValueHasValue(loadPathIMPValue): HMProgressHUD.hide() return HM.addInstanceMethod(gClassName, "loadPath:", loadPathIMPValue.GetValue(), "v@:@") clickBackItemIMPValue = makeClickBackItemIMP() if not HM.judgeSBValueHasValue(clickBackItemIMPValue): HMProgressHUD.hide() return HM.addInstanceMethod(gClassName, "clickBackItem", clickBackItemIMPValue.GetValue(), "v@:") clickPopItemIMPValue = makeClickPopItemIMP() if not HM.judgeSBValueHasValue(clickPopItemIMPValue): HMProgressHUD.hide() return HM.addInstanceMethod(gClassName, "clickPopItem", clickPopItemIMPValue.GetValue(), "v@:") deleteFileOrDirIMPValue = makeDeleteFileOrDirIMP() if not HM.judgeSBValueHasValue(deleteFileOrDirIMPValue): HMProgressHUD.hide() return HM.addInstanceMethod(gClassName, "deleteFileOrDir:", deleteFileOrDirIMPValue.GetValue(), "v@:@") # Methods related to tableView. HM.DPrint(f"Add methods to {gClassName}......") if not addTableViewMethods(): HMProgressHUD.hide() return HM.DPrint(f"Register {gClassName} done!") HMProgressHUD.hide()
def showDebugHUD(debugger, command, exe_ctx, result, internal_dict): """ Syntax: showhud Examples: (lldb) showhud Summary: Show debug HUD. 1.Memory footprint. 2.CPU utilization. 3.FPS in main thread. The UI style is based on https://github.com/meitu/MTHawkeye This command is implemented in HMDebugHUD.py """ global gClassName if isDisplayingHUD(): HM.DPrint(f"{gClassName} is already on display") HM.processContinue() return elif HM.existClass(gClassName): showHUDFunc() HM.processContinue() return # Register class HMProgressHUD.show(f"Register {gClassName}...") HM.DPrint(f"Register {gClassName}...") classValue = HM.allocateClass(gClassName, "UIView") HM.addIvar(classValue.GetValue(), "_link", "CADisplayLink *") HM.addIvar(classValue.GetValue(), "_count", "int") # count in 1 second HM.addIvar(classValue.GetValue(), "_lastTime", "double") HM.addIvar(classValue.GetValue(), "_memoryLab", "UILabel *") HM.addIvar(classValue.GetValue(), "_cpuUtilizationLab", "UILabel *") HM.addIvar(classValue.GetValue(), "_fpsLab", "UILabel *") HM.registerClass(classValue.GetValue()) # Add methods HM.DPrint(f"Add methods to {gClassName}...") addToKeyWindowIMPValue = makeAddToKeyWindowIMP() if not HM.judgeSBValueHasValue(addToKeyWindowIMPValue): HMProgressHUD.hide() return HM.addClassMethod(gClassName, "addToKeyWindow", addToKeyWindowIMPValue.GetValue(), "@@:") tapSelfIMPValue = makeTapSelfIMP() if not HM.judgeSBValueHasValue(tapSelfIMPValue): HMProgressHUD.hide() return HM.addInstanceMethod(gClassName, "tapSelf", tapSelfIMPValue.GetValue(), "v@:") # Add methods(update) if not addUpdateMethods(): HMProgressHUD.hide() return # Add methods(move) HM.DPrint(f"Add methods to {gClassName}......") if not addMoveMethods(): HMProgressHUD.hide() return # Add breakpoint in tapSelf HM.DPrint("Add breakpoint to hook method...") HM.addOneShotBreakPointInIMP(tapSelfIMPValue, "HMDebugHUD.tapSelfBreakPointHandler", "HMDebugHUD_TapSelf_Breakpoint") HM.DPrint(f"Register {gClassName} done!") # Show HUD command showHUDFunc() HMProgressHUD.hide() HM.processContinue()