def createFields(self):
        yield String(self, "name", 32, strip="\0")
        yield UInt32(self, "id")
        yield UInt32(self, "geometry_mode")
        yield UInt32(self, "lighting_mode")
        yield UInt32(self, "texture_mode")
        yield UInt32(self, "nmesh_vertices")
        yield UInt32(self, "ntexture_vertices")
        yield UInt32(self, "nfaces")

        nb_vert = self["nmesh_vertices"].value
        if nb_vert:
            yield Vector(self, "vertices",
                nb_vert, Vertex, "vertex")
        if self["ntexture_vertices"].value:
            yield Vector(self, "texture vertices",
                self["ntexture_vertices"].value, MapUV, "texture_vertex")
        if nb_vert:
            yield Vector(self, "light vertices",
                nb_vert, Float32, "extra_light")
            yield Vector(self, "unknown[]",
                nb_vert, Float32, "unknown")
        if self["nfaces"].value:
            yield Vector(self, "faces", self["nfaces"].value, Face, "face")
        if nb_vert:
            yield Vector(self, "vertex normals",
                nb_vert, Vertex, "normal")

        yield UInt32(self, "has_shadow")
        yield Float32(self, "unknown[]")
        yield Float32(self, "radius")
        yield Vertex(self, "unknown[]")
        yield Vertex(self, "unknown[]")
 def createFields(self):
     yield String(self, "name", 32, strip="\0")
     yield PaddingBytes(self, "unknown[]", 32, pattern="\xCC")
     yield UInt32(self, "flags")
     yield UInt32(self, "id")
     yield UInt32(self, "type")
     yield Int32(self, "mesh_id")
     yield UInt32(self, "depth")
     yield Int32(self, "parent_offset")
     yield UInt32(self, "nchildren")
     yield UInt32(self, "first_child_offset")
     yield UInt32(self, "next_sibling_offset")
     yield Vertex(self, "pivot")
     yield Vertex(self, "position")
     yield Float32(self, "pitch")
     yield Float32(self, "yaw")
     yield Float32(self, "roll")
     for index in xrange(4):
         yield Vertex(self, "unknown_vertex[]")
     if self["parent_offset"].value != 0:
         yield UInt32(self, "parent_id")
     if self["first_child_offset"].value != 0:
         yield UInt32(self, "first_child_id")
     if self["next_sibling_offset"].value != 0:
         yield UInt32(self, "next_sibling_id")
Exemple #3
0
 def createFields(self):
     yield Enum(UInt16(self, "style"), {
         0: 'centered',
         1: 'size to fit',
         2: 'user defined'
     })
     yield Float32(self, "x_location")
     yield Float32(self, "y_location")
     yield Float32(self, "scale")
Exemple #4
0
    def createFields(self):

        for index in range(1, 2 + 1):
            yield Int32(
                self, "unknown long[%s]" % index,
                "these may be binary type flags (as in ScanEventPreamble)")

        for index in range(3, 4 + 1):
            yield UInt32(self, "unknown long[%s]" % index)

        yield Float64(self, "unknown double[%s]" % 1)

        yield Float32(self, "unknown float[%s]" % 1)

        yield UInt32(
            self, "resolution",
            "As in:  FTMS + p norm !corona !pi res=60000 o(400.0-2000.0)")

        yield Float32(self, "unknown float[%s]" % 2)
        yield Float32(self, "unknown float[%s]" % 3)

        for index in range(6, 19 + 1):
            yield UInt32(self, "unknown long[%s]" % index)

        yield Float64(self, "unknown double[%s]" % 4)

        yield UInt32(self, "default charge state")
        yield UInt32(self, "unknown long[%s]" % 21)

        yield Float64(self, "unknown double[%s]" % 5)
        yield Float64(self, "unknown double[%s]" % 6)

        for index in range(4, 19 + 1):
            yield Float32(self, "unknown float[%s]" % index)

        yield UInt32(self, "n_act_param")
        for n in range(1, self["n_act_param"].value + 1):
            yield ActivationParam(self, "ActivationParam[%s]" % n)

        yield UInt32(self, "unknown long[%s]" % 23)
        yield UInt32(self, "unknown long[%s]" % 24)

        yield Float64(self, "low mz")
        yield Float64(self, "high mz")
        yield Float64(self, "unknown double[%s]" % 24)

        for index in range(20, 27 + 1):
            yield Float32(self, "unknown float[%s]" % index)

        for index in range(25, 25 + 1):
            yield UInt32(self, "unknown long[%s]" % index)
Exemple #5
0
 def createFields(self):
     yield UInt32(self, "size")
     while not self.eof:
         yield UInt32(self, "marker")
         if self["marker"].value == 'DWRT':
             yield Float32(self, "dry_ratio")
         elif self["marker"].value == 'PORG':
             yield UInt32(self, "default_program")
Exemple #6
0
def Float(parent):
    size = parent['size'].value
    if size == 4:
        return Float32(parent, 'float')
    elif size == 8:
        return Float64(parent, 'double')
    else:
        return RawBytes(parent, 'INVALID_FLOAT', size)
Exemple #7
0
    def createFields(self):

        for index in range(1, 9 + 1):
            yield Float32(self, "unknown float[%s]" % index)

        yield UInt32(self, "unknown long[%s]" % 1)
        yield UInt32(self, "n_events")
        for n in range(1, self["n_events"].value + 1):
            yield ScanEvent52(self, "ScanEvent[%s]" % n)
Exemple #8
0
    def createFields(self):

        for index in range(2, 5 + 1):
            yield UInt32(self, "unknown long[%s]" % index)

        yield Float64(self, "unknown double[%s]" % 1)
        yield Float32(self, "unknown float[%s]" % 10)

        for index in range(46, 55 + 1):
            yield UInt32(self, "unknown long[%s]" % index)

        for index in range(2, 4 + 1):
            yield Float64(self, "unknown double[%s]" % index)

        for index in range(11, 16 + 1):
            yield Float32(self, "unknown float[%s]" % index)

        # Undecoded tail
        if self.current_size < self._size:
            yield self.seekBit(self._size, "trailer")
Exemple #9
0
 def createFields(self):
     yield Enum(UInt8(self, "tag"), self.root.CONSTANT_TYPES)
     if self["tag"].value not in self.root.CONSTANT_TYPES:
         raise ParserError("Java: unknown constant type (%s)" %
                           self["tag"].value)
     self.constant_type = self.root.CONSTANT_TYPES[self["tag"].value]
     if self.constant_type == "Utf8":
         yield PascalString16(self, "bytes", charset="UTF-8")
     elif self.constant_type == "Integer":
         yield Int32(self, "bytes")
     elif self.constant_type == "Float":
         yield Float32(self, "bytes")
     elif self.constant_type == "Long":
         yield Int64(self, "bytes")
     elif self.constant_type == "Double":
         yield Float64(self, "bytes")
     elif self.constant_type == "Class":
         yield CPIndex(self,
                       "name_index",
                       "Class or interface name",
                       target_types="Utf8")
     elif self.constant_type == "String":
         yield CPIndex(self, "string_index", target_types="Utf8")
     elif self.constant_type == "Fieldref":
         yield CPIndex(self,
                       "class_index",
                       "Field class or interface name",
                       target_types="Class")
         yield CPIndex(self,
                       "name_and_type_index",
                       target_types="NameAndType")
     elif self.constant_type == "Methodref":
         yield CPIndex(self,
                       "class_index",
                       "Method class name",
                       target_types="Class")
         yield CPIndex(self,
                       "name_and_type_index",
                       target_types="NameAndType")
     elif self.constant_type == "InterfaceMethodref":
         yield CPIndex(self,
                       "class_index",
                       "Method interface name",
                       target_types="Class")
         yield CPIndex(self,
                       "name_and_type_index",
                       target_types="NameAndType")
     elif self.constant_type == "NameAndType":
         yield CPIndex(self, "name_index", target_types="Utf8")
         yield CPIndex(self, "descriptor_index", target_types="Utf8")
     else:
         raise ParserError("Not a valid constant pool element type: " +
                           self["tag"].value)
 def createFields(self):
     yield UInt32(self, "id")
     yield UInt32(self, "type")
     yield UInt32(self, "geometry_mode")
     yield UInt32(self, "lighting_mode")
     yield UInt32(self, "texture_mode")
     yield UInt32(self, "nvertices")
     yield Float32(self, "unknown[]", "unknown")
     yield UInt32(self, "has_texture", "Has texture?")
     yield UInt32(self, "has_material", "Has material?")
     yield Vertex(self, "unknown[]")
     yield Float32(self, "extra_light")
     yield Vertex(self, "unknown[]")
     yield Vertex(self, "normal")
     if self["nvertices"].value:
         yield Vector(self, "vertex_indices",
             self["nvertices"].value, UInt32, "vertex")
     if self["has_texture"].value:
         yield Vector(self, "texture_vertex_indices",
             self["nvertices"].value, UInt32, "texture_vertex")
     if self["has_material"].value:
         yield UInt32(self, "material_index", "material index")
Exemple #11
0
    def createFields(self):

        for index in range(1, 2 + 1):
            yield UInt32(self, "unknown long[%s]" % index)

        for index in range(1, 3 + 1):
            yield Float64(self, "unknown double[%s]" % index)

        yield Float32(self, "unknown float[%s]" % 1)

        yield UInt32(self, "unknown long[%s]" % 3)

        yield Float64(self, "unknown double[%s]" % 4)
        yield Float64(self, "unknown double[%s]" % 5)
Exemple #12
0
    def createFields(self):

        for index in range(2, 10 + 1):
            yield Float32(self, "unknown float[%s]" % index)

        yield UInt32(self, "unknown long[%s]" % 45)

        for index in range(11, 13 + 1):
            yield Float64(self, "unknown double[%s]" % index)

        for index in range(46, 57 + 1):
            yield UInt32(self, "unknown long[%s]" % index)

        for index in range(14, 18 + 1):
            yield Float64(self, "unknown double[%s]" % index)
    def createFields(self):
        # Read file signature, and fix endian if needed
        yield String(self, "file_sig", 4, "File signature", charset="ASCII")
        if self["file_sig"].value == "MODL":
            self.endian = BIG_ENDIAN

        # Read file content
        yield Materials(self, "materials")
        yield String(self, "model_name", 32, "model file name", strip="\0")
        yield RawBytes(self, "unknown[]", 4)
        yield UInt32(self, "ngeosets")
        for index in xrange(self["ngeosets"].value):
            yield Geoset(self, "geoset[]")
        yield RawBytes(self, "unknown[]", 4)
        yield Nodes(self, "nodes")
        yield Float32(self, "model_radius")
        yield Vertex(self, "insertion_offset")

        # Read the end of the file
        if self.current_size < self._size:
            yield self.seekBit(self._size, "end")
    def createFields(self):
        yield Enum(Bits(self, "marker_type", 4),
                    {0: "Simple",
                     1: "Int",
                     2: "Real",
                     3: "Date",
                     4: "Data",
                     5: "ASCII String",
                     6: "UTF-16-BE String",
                     8: "UID",
                     10: "Array",
                     13: "Dict",})
        markertype = self['marker_type'].value
        if markertype == 0:
            # Simple (Null)
            yield Enum(Bits(self, "value", 4),
                        {0: "Null",
                         8: "False",
                         9: "True",
                         15: "Fill Byte",})
            if self['value'].display == "False":
                self.xml=lambda prefix:prefix + "<false/>"
            elif self['value'].display == "True":
                self.xml=lambda prefix:prefix + "<true/>"
            else:
                self.xml=lambda prefix:prefix + ""

        elif markertype == 1:
            # Int
            yield Bits(self, "size", 4, "log2 of number of bytes")
            size=self['size'].value
            # 8-bit (size=0), 16-bit (size=1) and 32-bit (size=2) numbers are unsigned
            # 64-bit (size=3) numbers are signed
            yield GenericInteger(self, "value", (size>=3), (2**size)*8)
            self.xml=lambda prefix:prefix + "<integer>%s</integer>"%self['value'].value

        elif markertype == 2:
            # Real
            yield Bits(self, "size", 4, "log2 of number of bytes")
            if self['size'].value == 2: # 2**2 = 4 byte float
                yield Float32(self, "value")
            elif self['size'].value == 3: # 2**3 = 8 byte float
                yield Float64(self, "value")
            else:
                # FIXME: What is the format of the real?
                yield Bits(self, "value", (2**self['size'].value)*8)
            self.xml=lambda prefix:prefix + "<real>%s</real>"%self['value'].value

        elif markertype == 3:
            # Date
            yield Bits(self, "extra", 4, "Extra value, should be 3")
            cvt_time=lambda v:datetime(2001,1,1) + timedelta(seconds=v)
            yield displayHandler(Float64(self, "value"),lambda x:humanDatetime(cvt_time(x)))
            self.xml=lambda prefix:prefix + "<date>%s</date>"%(cvt_time(self['value'].value).isoformat())

        elif markertype == 4:
            # Data
            yield BPListSize(self, "size")
            if self['size'].value:
                yield Bytes(self, "value", self['size'].value)
                self.xml=lambda prefix:prefix + "<data>\n%s\n%s</data>"%(self['value'].value.encode('base64').strip(),prefix)
            else:
                self.xml=lambda prefix:prefix + '<data></data>'

        elif markertype == 5:
            # ASCII String
            yield BPListSize(self, "size")
            if self['size'].value:
                yield String(self, "value", self['size'].value, charset="ASCII")
                self.xml=lambda prefix:prefix + "<string>%s</string>"%(self['value'].value.encode('iso-8859-1'))
            else:
                self.xml=lambda prefix:prefix + '<string></string>'

        elif markertype == 6:
            # UTF-16-BE String
            yield BPListSize(self, "size")
            if self['size'].value:
                yield String(self, "value", self['size'].value*2, charset="UTF-16-BE")
                self.xml=lambda prefix:prefix + "<string>%s</string>"%(self['value'].value.encode('utf-8'))
            else:
                self.xml=lambda prefix:prefix + '<string></string>'

        elif markertype == 8:
            # UID
            yield Bits(self, "size", 4, "Number of bytes minus 1")
            yield GenericInteger(self, "value", False, (self['size'].value + 1)*8)
            self.xml=lambda prefix:prefix + "" # no equivalent?

        elif markertype == 10:
            # Array
            yield BPListSize(self, "size")
            size = self['size'].value
            if size:
                yield BPListArray(self, "value", size)
                self.xml=lambda prefix:self['value'].createXML(prefix)

        elif markertype == 13:
            # Dict
            yield BPListSize(self, "size")
            yield BPListDict(self, "value", self['size'].value)
            self.xml=lambda prefix:self['value'].createXML(prefix)

        else:
            yield Bits(self, "value", 4)
            self.xml=lambda prefix:''
Exemple #15
0
    def createFields(self):
        yield String(self, "header_id", 4, "Track Item Header Markup (\"mhit\")", charset="ISO-8859-1")
        yield UInt32(self, "header_length", "Header Length")
        yield UInt32(self, "entry_length", "Entry Length")
        yield UInt32(self, "string_number", "Number of Strings")
        yield UInt32(self, "unique_id", "Unique ID")
        yield UInt32(self, "visible_tag", "Visible Tag")
        yield String(self, "file_type", 4, "File Type")
        yield Enum(UInt8(self, "x1_type", "Extended Type 1"),self.x1_type_name)
        yield Enum(UInt8(self, "x2_type", "Extended type 2"),self.x2_type_name)
        yield UInt8(self, "compilation_flag", "Compilation Flag")
        yield UInt8(self, "rating", "Rating")
        yield TimestampMac32(self, "added_date", "Date when the item was added")
        yield filesizeHandler(UInt32(self, "size", "Track size in bytes"))
        yield displayHandler(UInt32(self, "length", "Track length in milliseconds"), humanDuration)
        yield UInt32(self, "track_number", "Number of this track")
        yield UInt32(self, "total_track", "Total number of tracks")
        yield UInt32(self, "year", "Year of the track")
        yield UInt32(self, "bitrate", "Bitrate")
        yield UInt32(self, "samplerate", "Sample Rate")
        yield UInt32(self, "volume", "volume")
        yield UInt32(self, "start_time", "Start playing at, in milliseconds")
        yield UInt32(self, "stop_time", "Stop playing at,  in milliseconds")
        yield UInt32(self, "soundcheck", "SoundCheck preamp")
        yield UInt32(self, "playcount_1", "Play count of the track")
        yield UInt32(self, "playcount_2", "Play count of the track (identical to playcount_1)")
        yield UInt32(self, "last_played_time", "Time the song was last played")
        yield UInt32(self, "disc_number", "disc number in multi disc sets")
        yield UInt32(self, "total_discs", "Total number of discs in the disc set")
        yield UInt32(self, "userid", "User ID in the DRM scheme")
        yield TimestampMac32(self, "last_modified", "Time of the last modification of the track")
        yield UInt32(self, "bookmark_time", "Bookmark time for AudioBook")
        yield UInt64(self, "dbid", "Unique DataBase ID for the song (identical in mhit and in mhii)")
        yield UInt8(self, "checked", "song is checked")
        yield UInt8(self, "application_rating", "Last Rating before change")
        yield UInt16(self, "BPM", "BPM of the track")
        yield UInt16(self, "artwork_count", "number of artworks fo this item")
        yield UInt16(self, "unknown[]")
        yield UInt32(self, "artwork_size", "Total size of artworks in bytes")
        yield UInt32(self, "unknown[]")
        yield Float32(self, "sample_rate_2", "Sample Rate express in float")
        yield UInt32(self, "released_date", "Date of release in Music Store or in Podcast")
        yield UInt32(self, "unknown[]")
        yield UInt32(self, "unknown[]")
        yield UInt32(self, "unknown[]")
        yield UInt32(self, "unknown[]")
        yield UInt32(self, "unknown[]")
        yield UInt8(self, "has_artwork", "0x01 for track with artwork, 0x02 otherwise")
        yield UInt8(self, "skip_wen_shuffling", "Skip that track when shuffling")
        yield UInt8(self, "remember_playback_position", "Remember playback position")
        yield UInt8(self, "flag4", "Flag 4")
        yield UInt64(self, "dbid2", "Unique DataBase ID for the song (identical as above)")
        yield UInt8(self, "lyrics_flag", "Lyrics Flag")
        yield UInt8(self, "movie_file_flag", "Movie File Flag")
        yield UInt8(self, "played_mark", "Track has been played")
        yield UInt8(self, "unknown[]")
        yield UInt32(self, "unknown[]")
        yield UInt32(self, "unknown[]")
        yield UInt32(self, "sample_count", "Number of samples in the song (only for WAV and AAC files)")
        yield UInt32(self, "unknown[]")
        yield UInt32(self, "unknown[]")
        yield UInt32(self, "unknown[]")
        yield UInt32(self, "unknown[]")
        yield Enum(UInt32(self, "media_type", "Media Type for video iPod"),self.media_type_name)
        yield UInt32(self, "season_number", "Season Number")
        yield UInt32(self, "episode_number", "Episode Number")
        yield UInt32(self, "unknown[]")
        yield UInt32(self, "unknown[]")
        yield UInt32(self, "unknown[]")
        yield UInt32(self, "unknown[]")
        yield UInt32(self, "unknown[]")
        yield UInt32(self, "unknown[]")
        padding = self.seekByte(self["header_length"].value, "header padding")
        if padding:
            yield padding

        #while ((self.stream.readBytes(0, 4) == 'mhod') and  ((self.current_size/8) < self["entry_length"].value)):
        for i in xrange(self["string_number"].value):
            yield DataObject(self, "data[]")
        padding = self.seekBit(self._size, "entry padding")
        if padding:
            yield padding