示例#1
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
示例#2
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()