def nw_handler(code, old=0):
    # delete notifications
    if code == ida_idaapi.NW_OPENIDB:
        if not ida_bytes.register_data_types_and_formats(new_formats):
            print("Failed to register types!")
    elif code == ida_idaapi.NW_CLOSEIDB:
        ida_bytes.unregister_data_types_and_formats(new_formats)
    elif code == ida_idaapi.NW_TERMIDA:
        f = ida_idaapi.NW_TERMIDA | ida_idaapi.NW_OPENIDB | ida_idaapi.NW_CLOSEIDB | ida_idaapi.NW_REMOVE
        ida_idaapi.notify_when(f, nw_handler)
Beispiel #2
0
def nw_handler(code, old=0):
    if code == ida_idaapi.NW_OPENIDB:
        print("nw_handler(): installing CLI")
        mycli.register()
    elif code == ida_idaapi.NW_CLOSEIDB:
        print("nw_handler(): removing CLI")
        mycli.unregister()
    elif code == ida_idaapi.NW_TERMIDA:
        print("nw_handler(): uninstalled nw handler")
        when = ida_idaapi.NW_TERMIDA | ida_idaapi.NW_OPENIDB | ida_idaapi.NW_CLOSEIDB | ida_idaapi.NW_REMOVE
        ida_idaapi.notify_when(when, nw_handler)
try:
    if platform.system() == 'Windows':
        new_formats.append((rsrc_string_format(),))
except:
    pass

# -----------------------------------------------------------------------
def nw_handler(code, old=0):
    # delete notifications
    if code == ida_idaapi.NW_OPENIDB:
        if not ida_bytes.register_data_types_and_formats(new_formats):
            print("Failed to register types!")
    elif code == ida_idaapi.NW_CLOSEIDB:
        ida_bytes.unregister_data_types_and_formats(new_formats)
    elif code == ida_idaapi.NW_TERMIDA:
        f = ida_idaapi.NW_TERMIDA | ida_idaapi.NW_OPENIDB | ida_idaapi.NW_CLOSEIDB | ida_idaapi.NW_REMOVE
        ida_idaapi.notify_when(f, nw_handler)

# -----------------------------------------------------------------------
# Check if already installed
if ida_bytes.find_custom_data_type(pascal_data_format.FORMAT_NAME) == -1:
    if not ida_bytes.register_data_types_and_formats(new_formats):
        print("Failed to register types!")
    else:
        f = ida_idaapi.NW_TERMIDA | ida_idaapi.NW_OPENIDB | ida_idaapi.NW_CLOSEIDB
        ida_idaapi.notify_when(f, nw_handler)
        print("Formats installed!")
else:
    print("Formats already installed!")