Example #1
0
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()
Example #2
0
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!")
Example #3
0
def addMoveMethods() -> bool:
    global gClassName

    touchesMovedWithEventIMPValue = makeTouchesMovedWithEventIMP()
    if not HM.judgeSBValueHasValue(touchesMovedWithEventIMPValue):
        return False
    HM.addInstanceMethod(gClassName, "touchesMoved:withEvent:",
                         touchesMovedWithEventIMPValue.GetValue(), "v@:@@")

    touchesEndedWithEventIMPValue = makeTouchesEndedWithEventIMP()
    if not HM.judgeSBValueHasValue(touchesEndedWithEventIMPValue):
        return False
    HM.addInstanceMethod(gClassName, "touchesEnded:withEvent:",
                         touchesEndedWithEventIMPValue.GetValue(), "v@:@@")

    touchesCancelledWithEventIMPValue = makeTouchesCancelledWithEventIMP()
    if not HM.judgeSBValueHasValue(touchesCancelledWithEventIMPValue):
        return False
    HM.addInstanceMethod(gClassName, "touchesCancelled:withEvent:",
                         touchesCancelledWithEventIMPValue.GetValue(), "v@:@@")

    attachToEdgeIMPValue = makeAttachToEdgeIMP()
    if not HM.judgeSBValueHasValue(attachToEdgeIMPValue):
        return False
    HM.addInstanceMethod(gClassName, "attachToEdge",
                         attachToEdgeIMPValue.GetValue(), "v@:")

    return True
Example #4
0
def addUpdateMethods() -> bool:
    global gClassName

    debugHUDtickIMPValue = makeDebugHUDtickIMP()
    if not HM.judgeSBValueHasValue(debugHUDtickIMPValue):
        return False
    HM.addInstanceMethod(gClassName, "debugHUDtick:",
                         debugHUDtickIMPValue.GetValue(), "v@:@")

    updateMemoryFootprintIMPValue = makeUpdateMemoryFootprintIMP()
    if not HM.judgeSBValueHasValue(updateMemoryFootprintIMPValue):
        return False
    HM.addInstanceMethod(gClassName, "updateMemoryFootprint",
                         updateMemoryFootprintIMPValue.GetValue(), "v@:")

    updateCPUUtilizationIMPValue = makeUpdateCPUUtilizationIMP()
    if not HM.judgeSBValueHasValue(updateCPUUtilizationIMPValue):
        return False
    HM.addInstanceMethod(gClassName, "updateCPUUtilization",
                         updateCPUUtilizationIMPValue.GetValue(), "v@:")

    updateFPSIMPValue = makeUpdateFPSIMP()
    if not HM.judgeSBValueHasValue(updateFPSIMPValue):
        return False
    HM.addInstanceMethod(gClassName, "updateFPS:",
                         updateFPSIMPValue.GetValue(), "v@:i")

    return True
Example #5
0
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()
Example #6
0
def register() -> None:

    if HM.existClass(gClassName):
        return

    HMDebugBaseViewController.register()

    # Register class
    HMProgressHUD.show(f"Register {gClassName}...")
    HM.DPrint(f"Register {gClassName}...")

    classValue = HM.allocateClass(gClassName, HMDebugBaseViewController.gClassName)
    HM.registerClass(classValue.GetValue())

    # Add methods
    HM.DPrint(f"Add methods to {gClassName}...")
    presentIMPValue = makePresentIMP()
    if not HM.judgeSBValueHasValue(presentIMPValue):
        HMProgressHUD.hide()
        return
    HM.addClassMethod(gClassName, "present", presentIMPValue.GetValue(), "@@:")

    viewDidLoadIMPValue = makeViewDidLoadIMP()
    if not HM.judgeSBValueHasValue(viewDidLoadIMPValue):
        HMProgressHUD.hide()
        return
    HM.addInstanceMethod(gClassName, "viewDidLoad", viewDidLoadIMPValue.GetValue(), "v@:")

    dismissSelfIMPValue = makeDismissSelfIMP()
    if not HM.judgeSBValueHasValue(dismissSelfIMPValue):
        HMProgressHUD.hide()
        return
    HM.addInstanceMethod(gClassName, "dismissSelf", dismissSelfIMPValue.GetValue(), "v@:")

    # Methods related to tableView.
    HM.DPrint(f"Add methods to {gClassName}......")
    if not addTableViewMethods():
        HMProgressHUD.hide()
        return

    # Methods related to features.
    HM.DPrint(f"Add methods to {gClassName}.........")
    if not addFeatureMethods():
        HMProgressHUD.hide()
        return

    HM.DPrint(f"Register {gClassName} done!")
    HMProgressHUD.hide()
Example #7
0
def addTableViewMethods() -> bool:
    global gClassName

    numberOfRowsInSectionIMPValue = makeNumberOfRowsInSectionIMP()
    if not HM.judgeSBValueHasValue(numberOfRowsInSectionIMPValue):
        return False
    HM.addInstanceMethod(gClassName, "tableView:numberOfRowsInSection:",
                         numberOfRowsInSectionIMPValue.GetValue(), "q@:@q")

    cellForRowAtIndexPathIMPValue = makeCellForRowAtIndexPathIMP()
    if not HM.judgeSBValueHasValue(cellForRowAtIndexPathIMPValue):
        return False
    HM.addInstanceMethod(gClassName, "tableView:cellForRowAtIndexPath:",
                         cellForRowAtIndexPathIMPValue.GetValue(), "@@:@@")

    return True
def register() -> None:
    if HM.existClass(gClassName):
        return

    # Register class
    HMProgressHUD.show(f"Register {gClassName}...")
    HM.DPrint(f"Register {gClassName}...")

    classValue = HM.allocateClass(gClassName, "UIViewController")
    HM.registerClass(classValue.GetValue())

    # Add methods
    HM.DPrint(f"Add methods to {gClassName}...")
    viewDidLoadIMPValue = makeViewDidLoadIMP()
    if not HM.judgeSBValueHasValue(viewDidLoadIMPValue):
        return
    HM.addInstanceMethod(gClassName, "viewDidLoad", viewDidLoadIMPValue.GetValue(), "v@:")

    HM.DPrint(f"Register {gClassName} done!")
Example #9
0
def swizzlingProtocolClasses():
    global gCustomizedSELString

    # add customized method
    clsName = "__NSCFURLSessionConfiguration"
    if not HM.existClass(clsName):
        clsName = "NSURLSessionConfiguration"

    HMLLDBProtocolClassesIMPValue = makeHMLLDBProtocolClassesIMP()
    if not HM.judgeSBValueHasValue(HMLLDBProtocolClassesIMPValue):
        return
    HM.addInstanceMethod(clsName, gCustomizedSELString,
                         HMLLDBProtocolClassesIMPValue.GetValue(), "@@:")

    # exchange implementation
    command_script = f'''
        Class cls = NSClassFromString(@"{clsName}");
        Method m1 = class_getInstanceMethod(cls, NSSelectorFromString(@"protocolClasses"));
        Method m2 = class_getInstanceMethod(cls, NSSelectorFromString(@"{gCustomizedSELString}"));
        method_exchangeImplementations(m1, m2);
    '''
    HM.evaluateExpressionValue(command_script)
Example #10
0
def addFeatureMethods() -> bool:
    global gClassName

    selectedAPPInfoIMPValue = makeSelectedAPPInfoIMP()
    if not HM.judgeSBValueHasValue(selectedAPPInfoIMPValue):
        return False
    HM.addInstanceMethod(gClassName, "selectedAPPInfo", selectedAPPInfoIMPValue.GetValue(), "v@:")

    selectedSandboxIMPValue = makeSelectedSandboxIMP()
    if not HM.judgeSBValueHasValue(selectedSandboxIMPValue):
        return False
    HM.addInstanceMethod(gClassName, "selectedSandbox", selectedSandboxIMPValue.GetValue(), "v@:")

    selectedInspectViewIMPValue = makeSelectedInspectViewIMP()
    if not HM.judgeSBValueHasValue(selectedInspectViewIMPValue):
        return False
    HM.addInstanceMethod(gClassName, "selectedInspectView", selectedInspectViewIMPValue.GetValue(), "v@:")

    HM.DPrint("Add breakpoints to hook method...")
    HM.addOneShotBreakPointInIMP(selectedAPPInfoIMPValue, "HMDebugMainViewController.selectedAPPInfoBreakPointHandler", "HMDebugMainViewController_selectedAPPInfo_Breakpoint")
    HM.addOneShotBreakPointInIMP(selectedSandboxIMPValue, "HMDebugMainViewController.selectedSandboxBreakPointHandler", "HMDebugMainViewController_selectedSandbox_Breakpoint")
    HM.addOneShotBreakPointInIMP(selectedInspectViewIMPValue, "HMDebugMainViewController.selectedInspectViewBreakPointHandler", "HMDebugMainViewController_selectedInspectView_Breakpoint")

    return True
Example #11
0
def addFunctionMethods() -> bool:
    clickMoveBtnIMPValue = makeClickMoveBtnIMP()
    if not HM.judgeSBValueHasValue(clickMoveBtnIMPValue):
        return False
    HM.addInstanceMethod(gClassName, "clickMoveBtn:", clickMoveBtnIMPValue.GetValue(), "v@:@")

    ivarsActionIMPValue = makeIvarsActionIMP()
    if not HM.judgeSBValueHasValue(ivarsActionIMPValue):
        return False
    HM.addInstanceMethod(gClassName, "ivarsAction", ivarsActionIMPValue.GetValue(), "v@:")

    propertiesActionIMPValue = makePropertiesActionIMP()
    if not HM.judgeSBValueHasValue(propertiesActionIMPValue):
        return False
    HM.addInstanceMethod(gClassName, "propertiesAction", propertiesActionIMPValue.GetValue(), "v@:")

    methodsActionIMPValue = makeMethodsActionIMP()
    if not HM.judgeSBValueHasValue(methodsActionIMPValue):
        return False
    HM.addInstanceMethod(gClassName, "methodsAction", methodsActionIMPValue.GetValue(), "v@:")

    siblingNextActionIMPValue = makeSiblingNextActionIMP()
    if not HM.judgeSBValueHasValue(siblingNextActionIMPValue):
        return False
    HM.addInstanceMethod(gClassName, "siblingNextAction", siblingNextActionIMPValue.GetValue(), "v@:")

    siblingPreviousActionIMPValue = makeSiblingPreviousActionIMP()
    if not HM.judgeSBValueHasValue(siblingPreviousActionIMPValue):
        return False
    HM.addInstanceMethod(gClassName, "siblingPreviousAction", siblingPreviousActionIMPValue.GetValue(), "v@:")

    superviewActionIMPValue = makeSuperviewActionIMP()
    if not HM.judgeSBValueHasValue(superviewActionIMPValue):
        return False
    HM.addInstanceMethod(gClassName, "superviewAction", superviewActionIMPValue.GetValue(), "v@:")

    subviewActionIMPValue = makeSubviewActionIMP()
    if not HM.judgeSBValueHasValue(subviewActionIMPValue):
        return False
    HM.addInstanceMethod(gClassName, "subviewAction", subviewActionIMPValue.GetValue(), "v@:")

    return True
Example #12
0
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()
Example #13
0
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()
Example #14
0
def addTableViewMethods() -> bool:
    global gClassName

    # data source
    numberOfRowsInSectionIMPValue = makeNumberOfRowsInSectionIMP()
    if not HM.judgeSBValueHasValue(numberOfRowsInSectionIMPValue):
        return False
    HM.addInstanceMethod(gClassName, "tableView:numberOfRowsInSection:",
                         numberOfRowsInSectionIMPValue.GetValue(), "q@:@q")

    cellForRowAtIndexPathIMPValue = makeCellForRowAtIndexPathIMP()
    if not HM.judgeSBValueHasValue(cellForRowAtIndexPathIMPValue):
        return False
    HM.addInstanceMethod(gClassName, "tableView:cellForRowAtIndexPath:",
                         cellForRowAtIndexPathIMPValue.GetValue(), "@@:@@")

    canEditRowAtIndexPathIMPValue = makeCanEditRowAtIndexPathIMP()
    if not HM.judgeSBValueHasValue(canEditRowAtIndexPathIMPValue):
        return False
    HM.addInstanceMethod(gClassName, "tableView:canEditRowAtIndexPath:",
                         canEditRowAtIndexPathIMPValue.GetValue(), "B@:@@")

    commitEditingStyleForRowAtIndexPathIMPValue = makeCommitEditingStyleForRowAtIndexPathIMP(
    )
    if not HM.judgeSBValueHasValue(
            commitEditingStyleForRowAtIndexPathIMPValue):
        return False
    HM.addInstanceMethod(
        gClassName, "tableView:commitEditingStyle:forRowAtIndexPath:",
        commitEditingStyleForRowAtIndexPathIMPValue.GetValue(), "v@:@q@")

    # delegate
    didSelectRowAtIndexPathIMPValue = makeDidSelectRowAtIndexPathIMP()
    if not HM.judgeSBValueHasValue(didSelectRowAtIndexPathIMPValue):
        return False
    HM.addInstanceMethod(gClassName, "tableView:didSelectRowAtIndexPath:",
                         didSelectRowAtIndexPathIMPValue.GetValue(), "v@:@@")

    viewForHeaderInSectionIMPValue = makeViewForHeaderInSectionIMP()
    if not HM.judgeSBValueHasValue(viewForHeaderInSectionIMPValue):
        return False
    HM.addInstanceMethod(gClassName, "tableView:viewForHeaderInSection:",
                         viewForHeaderInSectionIMPValue.GetValue(), "@@:@q")

    editingStyleForRowAtIndexPathIMPValue = makeEditingStyleForRowAtIndexPathIMP(
    )
    if not HM.judgeSBValueHasValue(editingStyleForRowAtIndexPathIMPValue):
        return False
    HM.addInstanceMethod(gClassName,
                         "tableView:editingStyleForRowAtIndexPath:",
                         editingStyleForRowAtIndexPathIMPValue.GetValue(),
                         "q@:@@")

    return True
Example #15
0
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()