Exemplo n.º 1
0
def registerProtocol():
    global gProtocolName
    if HM.existClass(gProtocolName):
        return

    # Register class
    HM.DPrint(f"Register {gProtocolName}...")

    classValue = HM.allocateClass(gProtocolName, "NSURLProtocol")
    HM.registerClass(classValue.GetValue())

    # Add methods
    HM.DPrint(f"Add methods to {gProtocolName}...")

    canInitWithRequestIMPValue = makeCanInitWithRequestIMP()
    if not HM.judgeSBValueHasValue(canInitWithRequestIMPValue):
        return
    HM.addClassMethod(gProtocolName, "canInitWithRequest:",
                      canInitWithRequestIMPValue.GetValue(), "B@:@")

    HM.DPrint(f"Register {gProtocolName} done!")

    # register NSURLProtocol
    registerClassExp = f"[NSURLProtocol registerClass:(Class){classValue.GetValue()}]"
    HM.evaluateExpressionValue(registerClassExp)
Exemplo n.º 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!")
Exemplo n.º 3
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()
Exemplo n.º 4
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()
Exemplo n.º 5
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()
Exemplo n.º 6
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()