(struc, p, path)
return p
Load the given structure into the current IDA Pro at the given offset.

    Example::

        load_struc(sections[0].data, 0x0, 'foo-section')

    Args:
      struc (wasm.Structure): the structure to load.
      p (int): the effective address at which to load.
      path (str): the namespaced name of the given structure.

    Returns:
      int: the next offset following the loaded structure.
Load the given structure into the current IDA Pro at the given offset.
Load the given structure into the current IDA Pro at the given offset .
def load_struc(struc, p, path):
    '''
    Load the given structure into the current IDA Pro at the given offset.

    Example::

        load_struc(sections[0].data, 0x0, 'foo-section')

    Args:
      struc (wasm.Structure): the structure to load.
      p (int): the effective address at which to load.
      path (str): the namespaced name of the given structure.

    Returns:
      int: the next offset following the loaded structure.
    '''
    for field in idawasm.common.get_fields(struc):
        # build names like: `sections:2:payload:entries:0:module_str`
        name = path + ':' + field.name

        # recurse into nested structures
        if idawasm.common.is_struc(field.value):
            p = load_struc(field.value, p, name)

        # recurse into lists of structures
        elif (isinstance(field.value, list)
              and len(field.value) > 0
              and idawasm.common.is_struc(field.value[0])):

            for i, v in enumerate(field.value):
                p = load_struc(v, p, name + ':' + str(i))

        # emit primitive types
        else:
            # add annotations like follows:
            #
            #     imports:002D sections:2:payload:entries:0:module_len         <--- Add line prior to element.
            #     imports:002D                 db 3                    ;; 0x3  <--- Render element for human.
            #     imports:002E sections:2:payload:entries:0:module_str
            #     imports:002E                 db 0x65 ;; e            ;; env  <--- Pull out strings and lists nicely.
            #     imports:002F                 db 0x6E ;; n
            #     imports:0030                 db 0x76 ;; v

            # add line prior to element
            idc.ExtLinA(p, 0, name)

            # if primitive integer element, set it as such
            if isinstance(field.value, int):
                MakeN(p, field.size)

            # add comment containing human-readable representation
            idc.MakeComm(p, format_value(name, field.value).encode('utf-8'))

            p += field.size

    return p
def load_struc ( struc , p , path ) : for field in idawasm . common . get_fields ( struc ) : # build names like: `sections:2:payload:entries:0:module_str` name = path + ':' + field . name # recurse into nested structures if idawasm . common . is_struc ( field . value ) : p = load_struc ( field . value , p , name ) # recurse into lists of structures elif ( isinstance ( field . value , list ) and len ( field . value ) > 0 and idawasm . common . is_struc ( field . value [ 0 ] ) ) : for i , v in enumerate ( field . value ) : p = load_struc ( v , p , name + ':' + str ( i ) ) # emit primitive types else : # add annotations like follows: # #     imports:002D sections:2:payload:entries:0:module_len         <--- Add line prior to element. #     imports:002D                 db 3                    ;; 0x3  <--- Render element for human. #     imports:002E sections:2:payload:entries:0:module_str #     imports:002E                 db 0x65 ;; e            ;; env  <--- Pull out strings and lists nicely. #     imports:002F                 db 0x6E ;; n #     imports:0030                 db 0x76 ;; v # add line prior to element idc . ExtLinA ( p , 0 , name ) # if primitive integer element, set it as such if isinstance ( field . value , int ) : MakeN ( p , field . size ) # add comment containing human-readable representation idc . MakeComm ( p , format_value ( name , field . value ) . encode ( 'utf-8' ) ) p += field . size return p