コード例 #1
0
VendorHeader = c.Struct(
    "_start_offset" / c.Tell,
    "magic" / c.Const(b"TRZV"),
    "_header_len" / c.Padding(4),
    "expiry" / c.Int32ul,
    "version" / c.Struct(
        "major" / c.Int8ul,
        "minor" / c.Int8ul,
    ),
    "vendor_sigs_required" / c.Int8ul,
    "vendor_sigs_n" / c.Rebuild(c.Int8ul, c.len_(c.this.pubkeys)),
    "vendor_trust" / VendorTrust,
    "reserved" / c.Padding(14),
    "pubkeys" / c.Bytes(32)[c.this.vendor_sigs_n],
    "vendor_string" / c.Aligned(4, c.PascalString(c.Int8ul, "utf-8")),
    "vendor_image" / Toif,
    "_data_end_offset" / c.Tell,
    c.Padding(-(c.this._data_end_offset + 65) % 512),
    "sigmask" / c.Byte,
    "signature" / c.Bytes(64),
    "_end_offset" / c.Tell,
    "header_len" /
    c.Pointer(c.this._start_offset + 4,
              c.Rebuild(c.Int32ul, c.this._end_offset - c.this._start_offset)),
)

VersionLong = c.Struct(
    "major" / c.Int8ul,
    "minor" / c.Int8ul,
    "patch" / c.Int8ul,
コード例 #2
0
PermalinkBinary = construct.FocusedSeq(
    "fields",
    schema_version=construct.Const(_CURRENT_SCHEMA_VERSION, construct.Byte),
    fields=construct.RawCopy(
        construct.Aligned(
            3,
            construct.Struct(
                header=construct.BitStruct(
                    has_seed_hash=construct.Rebuild(
                        construct.Flag, construct.this._.seed_hash != None),
                    bytes_rotation=construct.Rebuild(
                        construct.BitsInteger(7),
                        lambda ctx: single_byte_hash(ctx._.generator_params) >>
                        1,
                    )),
                seed_hash=construct.If(construct.this.header.has_seed_hash,
                                       construct.Bytes(5)),
                randovania_version=construct.Bytes(4),  # short git hash
                generator_params=construct.ExprAdapter(
                    construct.Prefixed(construct.VarInt,
                                       construct.GreedyBytes),
                    # parsing
                    decoder=create_rotator(inverse=True),
                    # building
                    encoder=create_rotator(inverse=False),
                ),
            ))),
    permalink_checksum=construct.Checksum(
        construct.Bytes(2),
        lambda data: hashlib.blake2b(data, digest_size=2).digest(),
        construct.this.fields.data,
コード例 #3
0
ファイル: fsm_handling.py プロジェクト: Silvris/MHW-Fsm
)

ClassDefinition = DataPointer(
    Int64ul,
    Struct("hash" / Int64ul,
           "members" / C.PrefixedArray(Int64ul, ClassMemberDefinition)),
    "definitionData")

ClassDefinitionList = C.FocusedSeq(
    "definitions", "_count" / C.Rebuild(Int32ul, C.len_(this.definitions)),
    "definitions" / C.Prefixed(
        Int32ul,
        C.Aligned(
            8,
            C.FocusedSeq(
                "definitions",
                "definitions" / ClassDefinition[this._._count],
                DataEntries("definitionData"),
                DataEntries("names"),
            ))))

# Hierarchy handling
varcount = 0


def varHandling(this):
    global varcount
    ret = varcount
    varcount += 1
    return ret

コード例 #4
0
VendorHeader = c.Struct(
    "_start_offset" / c.Tell,
    "magic" / c.Const(b"TRZV"),
    "header_len" / c.Int32ul,
    "expiry" / c.Int32ul,
    "version" / c.Struct(
        "major" / c.Int8ul,
        "minor" / c.Int8ul,
    ),
    "sig_m" / c.Int8ul,
    "sig_n" / c.Rebuild(c.Int8ul, c.len_(c.this.pubkeys)),
    "trust" / VendorTrust,
    "_reserved" / c.Padding(14),
    "pubkeys" / c.Bytes(32)[c.this.sig_n],
    "text" / c.Aligned(4, c.PascalString(c.Int8ul, "utf-8")),
    "image" / Toif,
    "_end_offset" / c.Tell,
    "_min_header_len" / c.Check(
        c.this.header_len > (c.this._end_offset - c.this._start_offset) + 65),
    "_header_len_aligned" / c.Check(c.this.header_len % 512 == 0),
    c.Padding(c.this.header_len - c.this._end_offset + c.this._start_offset -
              65),
    "sigmask" / c.Byte,
    "signature" / c.Bytes(64),
)

VersionLong = c.Struct(
    "major" / c.Int8ul,
    "minor" / c.Int8ul,
    "patch" / c.Int8ul,
コード例 #5
0
ファイル: parse.py プロジェクト: GeoThings/python-gpmf
                       double=ord(b'd'),
                       fourcc=ord(b'F'),
                       uuid=ord(b'G'),
                       int64_t=ord(b'j'),
                       uint64_t=ord(b'J'),
                       Q1516=ord(b'q'),
                       Q3132=ord(b'Q'),
                       utcdate=ord(b'U'),
                       complex=ord(b'?'),
                       nested=0x0,
                       unknown=0xfe)

FOURCC = construct.Struct(
    "key" / construct.Bytes(4), "type" / construct.Byte,
    "size" / construct.Byte, "repeat" / construct.Int16ub,
    "data" / construct.Aligned(
        4, construct.Bytes(construct.this.size * construct.this.repeat)))


def parse_value(element):
    """Parses element value"""
    type_parsed = TYPES.parse(bytes([element.type]))
    #print("DEBUG: type_parsed={}, element.repeat={}, element.size={}, len(element.data): {}".format(type_parsed, element.repeat, element.size, len(element.data)))

    # Special cases
    if type_parsed == 'char' and element.key == b'GPSU':
        return parse_goprodate(element)
    if type_parsed == 'utcdate':
        return parse_goprodate(element)

    # Basic number types
    struct_key = None