Пример #1
0
                assert unk1 % 0x100 == 0x02
                f.stream.seek(offset)
                data = f.stream.read(size1 + 0x08)[8:]
                content = data
            
            header_id, unk1, unk2, unk3 = struct.unpack("<LLLL", content[:0x10])
            print "%08X %08X %08X %08X" % (header_id, unk1, unk2, unk3)
            assert header_id == file_id
            if unk1 != 0:
                assert unk1 == 0x00200000 + header_id
            assert unk2 == 0x00000000
            assert unk3 == 0x00000441

            # @@@ just grab the first 0x441 * 2 anyway
            data = content[0x10:0x10 + (0x441 * 2)]
            if len(data) < 0x441 * 2:
                return
            pixels = {}
            for y in range(32):
                for x in range(32):
                    o = (y * (33) + x) * 2
                    h = struct.unpack("<H", data[o:o + 2])[0]
                    c = int(math.log(((16 * h) % 65535) + 1, 1.045))
                    pixels[(y, 32 - x - 1)] = (c, c, c)
            png.output_png("cells/%08X.png" % file_id, 32, 32, pixels)
    else:
        print "%08X" % file_id


f.visit_file_entries(dump_cell_file)
Пример #2
0
            data = f.stream.read(size1 + 0x08)[12:]
            content = zlib.decompress(data)
            assert l == len(content)
        else:
            # print "uncompressed"
            assert unk1 % 0x100 == 0x02
            f.stream.seek(offset)
            data = f.stream.read(size1 + 0x08)[8:]
            content = data

        # print "%08X %08X" % struct.unpack("<LL", content[:8]),
        magic = content[8:12]
        if magic == "OggS":
            pass  # print "OGG"
        else:
            # print "%08X %08X %08X %08X %08X" % struct.unpack("<LLLLL", content[:20])
            if len(content) > 24:
                header_id, unk1, width, height, unk2, lngth = struct.unpack("<LLLLLL", data[:24])
                if unk2 == 0x1F4:
                    print "%08X" % file_id
                    # image_0x1F4(file_id, content[24:])
                elif unk2 == 0x15:
                    print "%08X %08X %08X %08X %08X %08X" % struct.unpack("<LLLLLL", content[:24])
                    assert width * height * 4 == lngth
                    image_0x15(header_id, width, height, content[24:])

    else:
        pass

f.visit_file_entries(dump_local_file)
Пример #3
0
            data = f.stream.read(size1 + 0x08)[12:]
            content = zlib.decompress(data)
            assert l == len(content)
        else:
            # print "uncompressed"
            assert unk1 % 0x100 == 0x02
            f.stream.seek(offset)
            data = f.stream.read(size1 + 0x08)[8:]
            content = data
        
        # print "%08X %08X" % struct.unpack("<LL", content[:8]),
        magic = content[8:12]
        if magic == "OggS":
            pass  # print "OGG"
        else:
            # print "%08X %08X %08X %08X %08X" % struct.unpack("<LLLLL", content[:20])
            if len(content) > 24:
                header_id, unk1, width, height, unk2, lngth = struct.unpack("<LLLLLL", data[:24])
                if unk2 == 0x1F4:
                    print "%08X" % file_id
                    # image_0x1F4(file_id, content[24:])
                elif unk2 == 0x15:
                    print "%08X %08X %08X %08X %08X %08X" % struct.unpack("<LLLLLL", content[:24])
                    assert width * height * 4 == lngth
                    image_0x15(header_id, width, height, content[24:])
                    
    else:
        pass

f.visit_file_entries(dump_local_file)
Пример #4
0

filename = "LOTRO/client_sound.dat"

f = DatFile(filename)


def dump_sound_file(entry):
    j, unk1, file_id, offset, size1, timestamp, version, size2, unk2 = entry
    f.stream.seek(offset)
    j, k, l, m = struct.unpack("<LLLL", f.stream.read(0x10))

    if j == 0 and k == 0 and l == file_id and m == size1 - 0x10:
        magic = f.stream.read(0x04)
        print "%08X %08X %08X %s %08X | %08X %08X %08X | %08X |" % (file_id, offset, size1, time.ctime(timestamp), version, size2, unk1, unk2, size2 - size1),
        print "%08X %08X" % (l, m),
        print magic

        f.stream.seek(offset + 0x10)
        data = f.stream.read(m + 0x08)

        if magic == "RIFF":
            with open("sound/%08X.wav" % file_id, "w") as sound_file:
                sound_file.write(data)
        elif magic == "OggS":
            with open("sound/%08X.ogg" % file_id, "w") as sound_file:
                sound_file.write(data)


f.visit_file_entries(dump_sound_file)
Пример #5
0
        
    print hex(file_id)
    if unk2 == 0x15:
        assert width * height * 4 == lngth
        image_0x15(header_id, width, height, content[24:])
    elif unk2 == 0x14:
        assert width * height * 3 == lngth
        image_0x14(header_id, width, height, content[24:])
    elif unk2 == 0x31545844:  # DXT1
        assert width * height == lngth * 2
        image_0x31545844(header_id, width, height, content[24:])
    elif unk2 == 0x33545844:  # DXT3
        assert width * height == lngth
        image_0x33545844(header_id, width, height, content[24:])
    elif unk2 == 0x35545844:  # DXT5
        assert width * height == lngth
        image_0x35545844(header_id, width, height, content[24:])
    elif unk2 == 0x1C:
        assert width * height == lngth
        image_0x1C(header_id, width, height, content[24:])
    elif unk2 == 0x1F4:
        image_0x1F4(header_id, content[24:])
    else:
        print "%08X %04X %04X" % (l, m, n)
        print "%08s %08s %08s %08s %08s %08s" % ("file_id", "unk1", "width", "height", "unk2", "lngth")
        print "%08X %08X %08X %08X %08X %08X" % (header_id, unk1, width, height, unk2, lngth)
        dump(content[24:])


f.visit_file_entries(dump_image_file)
Пример #6
0
def show_list(filename):
    """
    list all the files in the DAT
    """
    f = DatFile(filename)
    f.visit_file_entries(print_entry)
Пример #7
0
filename = "LOTRO/client_sound.dat"

f = DatFile(filename)


def dump_sound_file(entry):
    j, unk1, file_id, offset, size1, timestamp, version, size2, unk2 = entry
    f.stream.seek(offset)
    j, k, l, m = struct.unpack("<LLLL", f.stream.read(0x10))

    if j == 0 and k == 0 and l == file_id and m == size1 - 0x10:
        magic = f.stream.read(0x04)
        print "%08X %08X %08X %s %08X | %08X %08X %08X | %08X |" % (
            file_id, offset, size1, time.ctime(timestamp), version, size2,
            unk1, unk2, size2 - size1),
        print "%08X %08X" % (l, m),
        print magic

        f.stream.seek(offset + 0x10)
        data = f.stream.read(m + 0x08)

        if magic == "RIFF":
            with open("sound/%08X.wav" % file_id, "w") as sound_file:
                sound_file.write(data)
        elif magic == "OggS":
            with open("sound/%08X.ogg" % file_id, "w") as sound_file:
                sound_file.write(data)


f.visit_file_entries(dump_sound_file)
Пример #8
0
def dump_anim_file(entry):
    j, unk1, file_id, offset, size1, timestamp, version, size2, unk2 = entry
    print "%08X %08X %08X %s %08X | %08X %08X %08X | %08X" % (file_id, offset, size1, time.ctime(timestamp), version, size2, unk1, unk2, size2 - size1)
    
    f.stream.seek(offset)
    
    j, k, l, m, n = struct.unpack("<LLLHH", f.stream.read(0x10))
    print "%08X %08X %08X %04X %04X" % (j, k, l, m, n)
    
    assert j == 0
    assert k == 0
    
    if m == 0xDA78:
        print "compressed"
        assert unk1 % 0x100 == 0x03
        f.stream.seek(offset)
        data = f.stream.read(size1 + 0x08)[12:]
        content = zlib.decompress(data)
        assert l == len(content)
    else:
        print "uncompressed"
        assert unk1 % 0x100 == 0x02
        f.stream.seek(offset)
        data = f.stream.read(size1 + 0x08)[8:]
        content = data
    
    dump(content[:0x100])


f.visit_file_entries(dump_anim_file)
Пример #9
0
    if unk2 == 0x15:
        assert width * height * 4 == lngth
        image_0x15(header_id, width, height, content[24:])
    elif unk2 == 0x14:
        assert width * height * 3 == lngth
        image_0x14(header_id, width, height, content[24:])
    elif unk2 == 0x31545844:  # DXT1
        assert width * height == lngth * 2
        image_0x31545844(header_id, width, height, content[24:])
    elif unk2 == 0x33545844:  # DXT3
        assert width * height == lngth
        image_0x33545844(header_id, width, height, content[24:])
    elif unk2 == 0x35545844:  # DXT5
        assert width * height == lngth
        image_0x35545844(header_id, width, height, content[24:])
    elif unk2 == 0x1C:
        assert width * height == lngth
        image_0x1C(header_id, width, height, content[24:])
    elif unk2 == 0x1F4:
        image_0x1F4(header_id, content[24:])
    else:
        print "%08X %04X %04X" % (l, m, n)
        print "%08s %08s %08s %08s %08s %08s" % ("file_id", "unk1", "width",
                                                 "height", "unk2", "lngth")
        print "%08X %08X %08X %08X %08X %08X" % (header_id, unk1, width,
                                                 height, unk2, lngth)
        dump(content[24:])


f.visit_file_entries(dump_image_file)
Пример #10
0
def show_list(filename):
    """
    list all the files in the DAT
    """
    f = DatFile(filename)
    f.visit_file_entries(print_entry)
Пример #11
0
def dump_anim_file(entry):
    j, unk1, file_id, offset, size1, timestamp, version, size2, unk2 = entry
    print "%08X %08X %08X %s %08X | %08X %08X %08X | %08X" % (file_id, offset, size1, time.ctime(timestamp), version, size2, unk1, unk2, size2 - size1)

    f.stream.seek(offset)

    j, k, l, m, n = struct.unpack("<LLLHH", f.stream.read(0x10))
    print "%08X %08X %08X %04X %04X" % (j, k, l, m, n)

    assert j == 0
    assert k == 0

    if m == 0xDA78:
        print "compressed"
        assert unk1 % 0x100 == 0x03
        f.stream.seek(offset)
        data = f.stream.read(size1 + 0x08)[12:]
        content = zlib.decompress(data)
        assert l == len(content)
    else:
        print "uncompressed"
        assert unk1 % 0x100 == 0x02
        f.stream.seek(offset)
        data = f.stream.read(size1 + 0x08)[8:]
        content = data

    dump(content[:0x100])


f.visit_file_entries(dump_anim_file)
Пример #12
0
                f.stream.seek(offset)
                data = f.stream.read(size1 + 0x08)[8:]
                content = data

            header_id, unk1, unk2, unk3 = struct.unpack(
                "<LLLL", content[:0x10])
            print "%08X %08X %08X %08X" % (header_id, unk1, unk2, unk3)
            assert header_id == file_id
            if unk1 != 0:
                assert unk1 == 0x00200000 + header_id
            assert unk2 == 0x00000000
            assert unk3 == 0x00000441

            # @@@ just grab the first 0x441 * 2 anyway
            data = content[0x10:0x10 + (0x441 * 2)]
            if len(data) < 0x441 * 2:
                return
            pixels = {}
            for y in range(32):
                for x in range(32):
                    o = (y * (33) + x) * 2
                    h = struct.unpack("<H", data[o:o + 2])[0]
                    c = int(math.log(((16 * h) % 65535) + 1, 1.045))
                    pixels[(y, 32 - x - 1)] = (c, c, c)
            png.output_png("cells/%08X.png" % file_id, 32, 32, pixels)
    else:
        print "%08X" % file_id


f.visit_file_entries(dump_cell_file)