<s> import sys <EOL> try : <EOL> import pywraps <EOL> pywraps_there = True <EOL> print "<STR_LIT>" <EOL> except : <EOL> pywraps_there = False <EOL> print "<STR_LIT>" <EOL> try : <EOL> import _idaapi <EOL> except : <EOL> print "<STR_LIT>" <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> import struct <EOL> if pywraps_there : <EOL> _idaapi . register_custom_data_type = pywraps . register_custom_data_type <EOL> _idaapi . unregister_custom_data_type = pywraps . unregister_custom_data_type <EOL> _idaapi . register_custom_data_format = pywraps . register_custom_data_format <EOL> _idaapi . unregister_custom_data_format = pywraps . unregister_custom_data_format <EOL> _idaapi . get_custom_data_format = pywraps . get_custom_data_format <EOL> _idaapi . get_custom_data_type = pywraps . get_custom_data_type <EOL> DTP_NODUP = <NUM_LIT> <EOL> class data_type_t ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , name , value_size = <NUM_LIT:0> , menu_name = None , hotkey = None , asm_keyword = None , props = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> self . name = name <EOL> self . props = props <EOL> self . menu_name = menu_name <EOL> self . hotkey = hotkey <EOL> self . asm_keyword = asm_keyword <EOL> self . value_size = value_size <EOL> self . id = - <NUM_LIT:1> <EOL> """<STR_LIT>""" <EOL> def register ( self ) : <EOL> """<STR_LIT>""" <EOL> return _idaapi . register_custom_data_type ( self ) <EOL> def unregister ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . id < <NUM_LIT:0> : <EOL> return True <EOL> r = _idaapi . unregister_custom_data_type ( self . id ) <EOL> if r : <EOL> self . id = - <NUM_LIT:1> <EOL> return r <EOL> class data_format_t ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , name , value_size = <NUM_LIT:0> , menu_name = None , props = <NUM_LIT:0> , hotkey = None , text_width = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> self . name = name <EOL> self . menu_name = menu_name <EOL> self . props = props <EOL> self . hotkey = hotkey <EOL> self . value_size = value_size <EOL> self . text_width = text_width <EOL> self . id = - <NUM_LIT:1> <EOL> """<STR_LIT>""" <EOL> def register ( self , dtid ) : <EOL> """<STR_LIT>""" <EOL> return _idaapi . register_custom_data_format ( dtid , self ) <EOL> def unregister ( self , dtid ) : <EOL> """<STR_LIT>""" <EOL> if self . id < <NUM_LIT:0> : <EOL> return True <EOL> r = _idaapi . unregister_custom_data_format ( dtid , self . id ) <EOL> if r : <EOL> self . id = - <NUM_LIT:1> <EOL> return r <EOL> def __walk_types_and_formats ( formats , type_action , format_action , installing ) : <EOL> broken = False <EOL> for f in formats : <EOL> if len ( f ) == <NUM_LIT:1> : <EOL> if not format_action ( f [ <NUM_LIT:0> ] , <NUM_LIT:0> ) : <EOL> broken = True <EOL> break <EOL> else : <EOL> dt = f [ <NUM_LIT:0> ] <EOL> dfs = f [ <NUM_LIT:1> : ] <EOL> if installing and not type_action ( dt ) : <EOL> broken = True <EOL> break <EOL> for df in dfs : <EOL> if not format_action ( df , dt . id ) : <EOL> broken = True <EOL> break <EOL> if not installing and not type_action ( dt ) : <EOL> broken = True <EOL> break <EOL> return not broken <EOL> def register_data_types_and_formats ( formats ) : <EOL> """<STR_LIT>""" <EOL> def __reg_format ( df , dtid ) : <EOL> df . register ( dtid ) <EOL> if dtid == <NUM_LIT:0> : <EOL> print "<STR_LIT>" % ( df . name , df . id ) <EOL> else : <EOL> print "<STR_LIT>" % ( df . name , df . id , dtid ) <EOL> return df . id != - <NUM_LIT:1> <EOL> def __reg_type ( dt ) : <EOL> dt . register ( ) <EOL> print "<STR_LIT>" % ( dt . name , dt . id ) <EOL> return dt . id != - <NUM_LIT:1> <EOL> ok = __walk_types_and_formats ( formats , __reg_type , __reg_format , True ) <EOL> return <NUM_LIT:1> if ok else - <NUM_LIT:1> <EOL> def unregister_data_types_and_formats ( formats ) : <EOL> """<STR_LIT>""" <EOL> def __unreg_format ( df , dtid ) : <EOL> print "<STR_LIT>" % ( "<STR_LIT>" if dtid == <NUM_LIT:0> else "<STR_LIT>" , df . name ) <EOL> df . unregister ( dtid ) <EOL> return True <EOL> def __unreg_type ( dt ) : <EOL> print "<STR_LIT>" % ( dt . name , dt . id ) <EOL> dt . unregister ( ) <EOL> return True <EOL> ok = __walk_types_and_formats ( formats , __unreg_type , __unreg_format , False ) <EOL> return <NUM_LIT:1> if ok else - <NUM_LIT:1> </s>
