()
fire it up
fire it up
fire it up
def run_dwarf():
    """ fire it up
    """
    os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "1"
    # os.environ["QT_SCALE_FACTOR"] = "1"
    # os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "0"
    # os.environ["QT_SCREEN_SCALE_FACTORS"] = "1"

    from dwarf_debugger.lib import utils
    from dwarf_debugger.lib.git import Git
    from dwarf_debugger.lib.prefs import Prefs
    from dwarf_debugger.ui.app import AppWindow

    from PyQt5.QtCore import Qt
    from PyQt5.QtGui import QIcon
    from PyQt5.QtWidgets import QApplication

    import dwarf_debugger.resources  # pylint: disable=unused-import

    QApplication.setDesktopSettingsAware(True)
    QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
    QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
    QApplication.setLayoutDirection(Qt.LeftToRight)

    QApplication.setOrganizationName("https://github.com/iGio90/Dwarf")
    QApplication.setApplicationName("Dwarf")
    QApplication.setApplicationDisplayName('Dwarf')

    qapp = QApplication([])

    # set icon
    _icon = None
    if os.name == "nt":
        if os.path.exists(utils.resource_path('assets/dwarf.ico')):
            _icon = QIcon(utils.resource_path('assets/dwarf.ico'))
        else:
            _icon = QIcon(':/assets/dwarf.ico')
    else:
        if os.path.exists(utils.resource_path('assets/dwarf.png')):
            _icon = QIcon(utils.resource_path('assets/dwarf.png'))
        else:
            _icon = QIcon(':/assets/dwarf.png')

    if _icon:
        qapp.setWindowIcon(_icon)

    _prefs = Prefs()
    local_update_disabled = _prefs.get('disable_local_frida_update', False)

    args = process_args()

    """
    did_first_run = _prefs.get('did_first_run', False)
    if False:
        from dwarf_debugger.ui.dialogs.dialog_setup import SetupDialog
        # did_first_run:
        _prefs.put('did_first_run', True)
        SetupDialog.showDialog(_prefs)
    """

    if not local_update_disabled:
        _git = Git()
        import frida
        remote_frida = _git.get_frida_version()
        local_frida = frida.__version__

        if remote_frida and local_frida != remote_frida['tag_name']:
            print('Updating local frida version to ' + remote_frida['tag_name'])
            try:
                res = utils.do_shell_command('pip3 install frida --upgrade --user')
                if 'Successfully installed frida-' + remote_frida['tag_name'] in res:
                    _on_restart()
                elif 'Requirement already up-to-date' in res:
                    if os.path.exists('.git_cache'):
                        shutil.rmtree('.git_cache', ignore_errors=True)
                else:
                    print('failed to update local frida')
                    print(res)
            except Exception as e:  # pylint: disable=broad-except, invalid-name
                print('failed to update local frida')
                print(str(e))

    if os.name == 'nt':
        # windows stuff
        import ctypes
        try:
            if os.path.exists(utils.resource_path('assets/dwarf.ico')):
                # write ini to show folder with dwarficon
                folder_stuff = "[.ShellClassInfo]\n"
                folder_stuff += "IconResource=dwarf\\assets\\dwarf.ico,0\n"
                folder_stuff += "[ViewState]\n"
                folder_stuff += "Mode=\n"
                folder_stuff += "Vid=\n"
                folder_stuff += "FolderType=Generic\n"
                try:
                    ini_path = os.path.dirname(os.path.abspath(__file__)) + os.sep + os.pardir + os.sep + 'desktop.ini'
                    with open(ini_path, 'w') as ini:
                        ini.writelines(folder_stuff)

                    # set fileattributes to hidden + systemfile
                    ctypes.windll.kernel32.SetFileAttributesW(
                        ini_path, 0x02 | 0x04 | ~0x20
                    )  # FILE_ATTRIBUTE_HIDDEN = 0x02 | FILE_ATTRIBUTE_SYSTEM = 0x04
                except PermissionError:
                    # its hidden+system already
                    pass

            # fix for showing dwarf icon in windows taskbar instead of pythonicon
            _appid = u'iGio90.dwarf.debugger'
            ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(
                _appid)

            ctypes.windll.user32.SetProcessDPIAware()

        except Exception:  # pylint: disable=broad-except
            pass

    try:
        # parse target as pid
        args.pid = int(args.any)
    except ValueError:
        args.pid = 0

    # default to local if not specified
    if args.target is None:
        args.target = 'local'

    app_window = AppWindow(args)
    if _icon:
        app_window.setWindowIcon(_icon)

    app_window.onRestart.connect(_on_restart)

    try:
        sys.exit(qapp.exec_())
    except SystemExit as sys_err:
        if sys_err.code == 0:
            # thanks for using dwarf
            print('Thank\'s for using Dwarf\nHave a nice day...')
        else:
            # something was wrong
            print('sysexit with: %d' % sys_err.code)
def run_dwarf ( ) : os . environ [ "QT_AUTO_SCREEN_SCALE_FACTOR" ] = "1" # os.environ["QT_SCALE_FACTOR"] = "1" # os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "0" # os.environ["QT_SCREEN_SCALE_FACTORS"] = "1" from dwarf_debugger . lib import utils from dwarf_debugger . lib . git import Git from dwarf_debugger . lib . prefs import Prefs from dwarf_debugger . ui . app import AppWindow from PyQt5 . QtCore import Qt from PyQt5 . QtGui import QIcon from PyQt5 . QtWidgets import QApplication import dwarf_debugger . resources # pylint: disable=unused-import QApplication . setDesktopSettingsAware ( True ) QApplication . setAttribute ( Qt . AA_EnableHighDpiScaling ) QApplication . setAttribute ( Qt . AA_UseHighDpiPixmaps ) QApplication . setLayoutDirection ( Qt . LeftToRight ) QApplication . setOrganizationName ( "https://github.com/iGio90/Dwarf" ) QApplication . setApplicationName ( "Dwarf" ) QApplication . setApplicationDisplayName ( 'Dwarf' ) qapp = QApplication ( [ ] ) # set icon _icon = None if os . name == "nt" : if os . path . exists ( utils . resource_path ( 'assets/dwarf.ico' ) ) : _icon = QIcon ( utils . resource_path ( 'assets/dwarf.ico' ) ) else : _icon = QIcon ( ':/assets/dwarf.ico' ) else : if os . path . exists ( utils . resource_path ( 'assets/dwarf.png' ) ) : _icon = QIcon ( utils . resource_path ( 'assets/dwarf.png' ) ) else : _icon = QIcon ( ':/assets/dwarf.png' ) if _icon : qapp . setWindowIcon ( _icon ) _prefs = Prefs ( ) local_update_disabled = _prefs . get ( 'disable_local_frida_update' , False ) args = process_args ( ) """
    did_first_run = _prefs.get('did_first_run', False)
    if False:
        from dwarf_debugger.ui.dialogs.dialog_setup import SetupDialog
        # did_first_run:
        _prefs.put('did_first_run', True)
        SetupDialog.showDialog(_prefs)
    """ if not local_update_disabled : _git = Git ( ) import frida remote_frida = _git . get_frida_version ( ) local_frida = frida . __version__ if remote_frida and local_frida != remote_frida [ 'tag_name' ] : print ( 'Updating local frida version to ' + remote_frida [ 'tag_name' ] ) try : res = utils . do_shell_command ( 'pip3 install frida --upgrade --user' ) if 'Successfully installed frida-' + remote_frida [ 'tag_name' ] in res : _on_restart ( ) elif 'Requirement already up-to-date' in res : if os . path . exists ( '.git_cache' ) : shutil . rmtree ( '.git_cache' , ignore_errors = True ) else : print ( 'failed to update local frida' ) print ( res ) except Exception as e : # pylint: disable=broad-except, invalid-name print ( 'failed to update local frida' ) print ( str ( e ) ) if os . name == 'nt' : # windows stuff import ctypes try : if os . path . exists ( utils . resource_path ( 'assets/dwarf.ico' ) ) : # write ini to show folder with dwarficon folder_stuff = "[.ShellClassInfo]\n" folder_stuff += "IconResource=dwarf\\assets\\dwarf.ico,0\n" folder_stuff += "[ViewState]\n" folder_stuff += "Mode=\n" folder_stuff += "Vid=\n" folder_stuff += "FolderType=Generic\n" try : ini_path = os . path . dirname ( os . path . abspath ( __file__ ) ) + os . sep + os . pardir + os . sep + 'desktop.ini' with open ( ini_path , 'w' ) as ini : ini . writelines ( folder_stuff ) # set fileattributes to hidden + systemfile ctypes . windll . kernel32 . SetFileAttributesW ( ini_path , 0x02 | 0x04 | ~ 0x20 ) # FILE_ATTRIBUTE_HIDDEN = 0x02 | FILE_ATTRIBUTE_SYSTEM = 0x04 except PermissionError : # its hidden+system already pass # fix for showing dwarf icon in windows taskbar instead of pythonicon _appid = u'iGio90.dwarf.debugger' ctypes . windll . shell32 . SetCurrentProcessExplicitAppUserModelID ( _appid ) ctypes . windll . user32 . SetProcessDPIAware ( ) except Exception : # pylint: disable=broad-except pass try : # parse target as pid args . pid = int ( args . any ) except ValueError : args . pid = 0 # default to local if not specified if args . target is None : args . target = 'local' app_window = AppWindow ( args ) if _icon : app_window . setWindowIcon ( _icon ) app_window . onRestart . connect ( _on_restart ) try : sys . exit ( qapp . exec_ ( ) ) except SystemExit as sys_err : if sys_err . code == 0 : # thanks for using dwarf print ( 'Thank\'s for using Dwarf\nHave a nice day...' ) else : # something was wrong print ( 'sysexit with: %d' % sys_err . code )