(f, neflags, format)
return 1
load the given file into the current IDA Pro database.

    Args:
      f (file): the file-like object to load.
      neflags (Any): unused
      format (Any): unused

    Returns:
      int: 1 on success, 0 on failure
load the given file into the current IDA Pro database.
load the given file into the current IDA Pro database .
def load_file(f, neflags, format):
    '''
    load the given file into the current IDA Pro database.

    Args:
      f (file): the file-like object to load.
      neflags (Any): unused
      format (Any): unused

    Returns:
      int: 1 on success, 0 on failure
    '''

    # compute file size, then read the entire contents
    f.seek(0x0, os.SEEK_END)
    flen = f.tell()
    f.seek(0x0)
    buf = f.read(flen)

    # mark the proc type, so IDA can invoke the correct disassembler/processor.
    # this must match `processor.wasm_processor_t.psnames`
    idaapi.set_processor_type('wasm', idaapi.SETPROC_ALL)

    f.seek(0x0)
    # load the entire file directly at address zero.
    f.file2base(0, 0, len(buf), True)

    p = 0
    sections = wasm.decode.decode_module(buf)
    for i, section in enumerate(sections):
        if i == 0:
            sname = 'header'
        else:
            if section.data.id == 0:
                # fetch custom name
                sname = ''
            else:
                sname = idawasm.const.WASM_SECTION_NAMES.get(section.data.id, 'unknown')

        if sname != 'header' and section.data.id in (wasm.wasmtypes.SEC_CODE, wasm.wasmtypes.SEC_GLOBAL):
            stype = 'CODE'
        else:
            stype = 'DATA'

        # add IDA segment with type, name, size as appropriate
        slen = sum(section.data.get_decoder_meta()['lengths'].values())
        idaapi.add_segm(0, p, p + slen, sname, stype)

        if sname != 'header':
            loader = SECTION_LOADERS.get(section.data.id)
            if loader is not None:
                loader(section, p)

            load_section(section, p)

        p += slen

    # magic
    idc.MakeDword(0x0)
    idc.MakeName(0x0, 'WASM_MAGIC')
    # version
    idc.MakeDword(0x4)
    idc.MakeName(0x4, 'WASM_VERSION')

    return 1
def load_file ( f , neflags , format ) : # compute file size, then read the entire contents f . seek ( 0x0 , os . SEEK_END ) flen = f . tell ( ) f . seek ( 0x0 ) buf = f . read ( flen ) # mark the proc type, so IDA can invoke the correct disassembler/processor. # this must match `processor.wasm_processor_t.psnames` idaapi . set_processor_type ( 'wasm' , idaapi . SETPROC_ALL ) f . seek ( 0x0 ) # load the entire file directly at address zero. f . file2base ( 0 , 0 , len ( buf ) , True ) p = 0 sections = wasm . decode . decode_module ( buf ) for i , section in enumerate ( sections ) : if i == 0 : sname = 'header' else : if section . data . id == 0 : # fetch custom name sname = '' else : sname = idawasm . const . WASM_SECTION_NAMES . get ( section . data . id , 'unknown' ) if sname != 'header' and section . data . id in ( wasm . wasmtypes . SEC_CODE , wasm . wasmtypes . SEC_GLOBAL ) : stype = 'CODE' else : stype = 'DATA' # add IDA segment with type, name, size as appropriate slen = sum ( section . data . get_decoder_meta ( ) [ 'lengths' ] . values ( ) ) idaapi . add_segm ( 0 , p , p + slen , sname , stype ) if sname != 'header' : loader = SECTION_LOADERS . get ( section . data . id ) if loader is not None : loader ( section , p ) load_section ( section , p ) p += slen # magic idc . MakeDword ( 0x0 ) idc . MakeName ( 0x0 , 'WASM_MAGIC' ) # version idc . MakeDword ( 0x4 ) idc . MakeName ( 0x4 , 'WASM_VERSION' ) return 1