()
Save the IDA database
Save the IDA database
Save the IDA database
def save_ida():
    """Save the IDA database"""
    if not pwndbg.ida.available():
        return

    path = pwndbg.ida.GetIdbPath()

    # Need to handle emulated paths for Wine
    if path.startswith('Z:'):
        path = path[2:].replace('\\', '/')
        pwndbg.ida.SaveBase(path)

    basename = os.path.basename(path)
    dirname = os.path.dirname(path)
    backups = os.path.join(dirname, 'ida-backup')

    if not os.path.isdir(backups):
        os.mkdir(backups)

    basename, ext = os.path.splitext(basename)
    basename += '-%s' % datetime.datetime.now().isoformat()
    basename += ext

    # Windows doesn't like colons in paths
    basename = basename.replace(':', '_')

    full_path = os.path.join(backups, basename)

    pwndbg.ida.SaveBase(full_path)

    data = open(full_path, 'rb').read()

    # Compress!
    full_path_compressed = full_path + '.bz2'
    bz2.BZ2File(full_path_compressed, 'w').write(data)

    # Remove old version
    os.unlink(full_path)
def save_ida ( ) : if not pwndbg . ida . available ( ) : return path = pwndbg . ida . GetIdbPath ( ) # Need to handle emulated paths for Wine if path . startswith ( 'Z:' ) : path = path [ 2 : ] . replace ( '\\' , '/' ) pwndbg . ida . SaveBase ( path ) basename = os . path . basename ( path ) dirname = os . path . dirname ( path ) backups = os . path . join ( dirname , 'ida-backup' ) if not os . path . isdir ( backups ) : os . mkdir ( backups ) basename , ext = os . path . splitext ( basename ) basename += '-%s' % datetime . datetime . now ( ) . isoformat ( ) basename += ext # Windows doesn't like colons in paths basename = basename . replace ( ':' , '_' ) full_path = os . path . join ( backups , basename ) pwndbg . ida . SaveBase ( full_path ) data = open ( full_path , 'rb' ) . read ( ) # Compress! full_path_compressed = full_path + '.bz2' bz2 . BZ2File ( full_path_compressed , 'w' ) . write ( data ) # Remove old version os . unlink ( full_path )