How to use the hachoir.field.UInt32 function in hachoir

To help you get started, we’ve selected a few hachoir examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vstinner / hachoir / hachoir / parser / container / realmedia.py View on Github external
def parseFileProperties(self):
    yield UInt32(self, "max_bit_rate", "Maximum bit rate")
    yield UInt32(self, "avg_bit_rate", "Average bit rate")
    yield UInt32(self, "max_pkt_size", "Size of largest data packet")
    yield UInt32(self, "avg_pkt_size", "Size of average data packet")
    yield UInt32(self, "num_pkts", "Number of data packets")
    yield UInt32(self, "duration", "File duration in milliseconds")
    yield UInt32(self, "preroll", "Suggested preroll in milliseconds")
    yield textHandler(UInt32(self, "index_offset", "Absolute offset of first index chunk"), hexadecimal)
    yield textHandler(UInt32(self, "data_offset", "Absolute offset of first data chunk"), hexadecimal)
    yield UInt16(self, "stream_count", "Number of streams in the file")
    yield RawBits(self, "reserved", 13)
    yield Bit(self, "is_live", "Whether file is a live broadcast")
    yield Bit(self, "is_perfect_play", "Whether PerfectPlay can be used")
    yield Bit(self, "is_saveable", "Whether file can be saved")
github vstinner / hachoir / hachoir / parser / container / mp4.py View on Github external
def createFields(self):
        yield UInt8(self, "version")
        yield NullBits(self, "flags", 24)
        yield UInt32(self, "reference_ID")
        yield UInt32(self, "timescale")
        if self["version"].value == 0:
            yield UInt32(self, "earliest_presentation_time")
            yield UInt32(self, "first_offset")
        else:
            yield UInt64(self, "earliest_presentation_time")
            yield UInt64(self, "first_offset")
        yield NullBits(self, "reserved", 16)
        yield UInt16(self, "reference_count")
        for i in range(self["reference_count"].value):
            yield SegmentIndexBoxReference(self, "reference[]")
github vstinner / hachoir / hachoir / parser / archive / mar.py View on Github external
def createFields(self):
        yield String(self, "magic", 4, "File signature (MARC)", charset="ASCII")
        yield UInt32(self, "version")
        yield UInt32(self, "nb_file")
        files = []
        for index in range(self["nb_file"].value):
            item = FileIndex(self, "file[]")
            yield item
            if item["filesize"].value:
                files.append(item)
        files.sort(key=lambda item: item["offset"].value)
        for index in files:
            padding = self.seekByte(index["offset"].value)
            if padding:
                yield padding
            size = index["filesize"].value
            desc = "File %s" % index["filename"].value
            yield SubFile(self, "data[]", size, desc, filename=index["filename"].value)
github vstinner / hachoir / hachoir / parser / archive / zip.py View on Github external
def createFields(self):
        yield textHandler(UInt32(self, "file_crc32",
                                 "Checksum (CRC32)"), hexadecimal)
        yield filesizeHandler(UInt32(self, "file_compressed_size",
                                     "Compressed size (bytes)"))
        yield filesizeHandler(UInt32(self, "file_uncompressed_size",
                                     "Uncompressed size (bytes)"))
github vstinner / hachoir / hachoir / parser / program / macho.py View on Github external
def createFields(self):
        yield String(self, "segname", 16, strip="\0")
        yield textHandler(UInt32(self, "vmaddr"), hexadecimal)
        yield textHandler(UInt32(self, "vmsize"), hexadecimal)
        yield textHandler(UInt32(self, "fileoff"), hexadecimal)
        yield textHandler(UInt32(self, "filesize"), hexadecimal)
        yield UInt32(self, "maxprot")
        yield UInt32(self, "initprot")
        yield UInt32(self, "nsects")
        yield UInt32(self, "flags")
        for i in range(self['nsects'].value):
            yield MachoSection(self, "section[]")
github vstinner / hachoir / hachoir / parser / container / mp4.py View on Github external
def createFields(self):
        yield UInt8(self, "version", "Version")
        yield NullBits(self, "flags", 24)
        yield UInt16(self, "max_pdu_size")
        yield UInt16(self, "avg_pdu_size")
        yield UInt32(self, "max_bit_rate")
        yield UInt32(self, "avg_bit_rate")
        yield UInt32(self, "reserved[]")
github vstinner / hachoir / hachoir / parser / file_system / ntfs.py View on Github external
def parseFilename(self):
        yield UInt64(self, "ref", "File reference to the parent directory")
        yield TimestampWin64(self, "ctime", "File Creation")
        yield TimestampWin64(self, "atime", "File Altered")
        yield TimestampWin64(self, "mtime", "MFT Changed")
        yield TimestampWin64(self, "rtime", "File Read")
        yield filesizeHandler(UInt64(self, "alloc_size", "Allocated size of the file"))
        yield filesizeHandler(UInt64(self, "real_size", "Real size of the file"))
        yield UInt32(self, "file_flags")
        yield UInt32(self, "file_flags2", "Used by EAs and Reparse")
        yield UInt8(self, "filename_length", "Filename length in characters")
        yield Enum(UInt8(self, "filename_namespace"), self.FILENAME_NAMESPACE)
        size = self["filename_length"].value * 2
        if size:
            yield String(self, "filename", size, charset="UTF-16-LE")
github vstinner / hachoir / hachoir / parser / audio / modplug.py View on Github external
def createFields(self):
        yield textHandler(UInt32(self, "plugin_id1"), hexadecimal)
        yield textHandler(UInt32(self, "plugin_id2"), hexadecimal)
        yield UInt32(self, "input_routing")
        yield UInt32(self, "output_routing")
        yield GenericVector(self, "routing_info", 4, UInt32, "reserved")
        yield String(self, "name", 32, strip='\0')
        yield String(self, "dll_name", 64, desc="Original DLL name", strip='\0')
github vstinner / hachoir / hachoir / parser / container / mp4.py View on Github external
def createFields(self):
        flags = self["../flags"].value
        if flags & 0x100:
            yield UInt32(self, "sample_duration")
        if flags & 0x200:
            yield UInt32(self, "sample_size")
        if flags & 0x400:
            yield UInt32(self, "sample_flags")
        if flags & 0x800:
            yield UInt32(self, "sample_composition_time_offset")
github vstinner / hachoir / hachoir / parser / game / blp.py View on Github external
def createFields(self):
        yield String(self, "magic", 4, "Signature (BLP1)")
        yield Enum(UInt32(self, "compression"), {
            0: "JPEG Compression",
            1: "Uncompressed"})
        yield UInt32(self, "flags")
        yield UInt32(self, "width")
        yield UInt32(self, "height")
        yield Enum(UInt32(self, "type"), {
            3: "Uncompressed Index List + Alpha List",
            4: "Uncompressed Index List + Alpha List",
            5: "Uncompressed Index List"})
        yield UInt32(self, "subtype")
        for i in range(16):
            yield UInt32(self, "mipmap_offset[]")
        for i in range(16):
            yield UInt32(self, "mipmap_size[]")

        compression = self["compression"].value
        image_type = self["type"].value
        width = self["width"].value
        height = self["height"].value