Skip to content

Instantly share code, notes, and snippets.

@MaKiPL
Created October 31, 2019 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MaKiPL/927d9162f7b0e9ba994c32d42cb84657 to your computer and use it in GitHub Desktop.
Save MaKiPL/927d9162f7b0e9ba994c32d42cb84657 to your computer and use it in GitHub Desktop.
Kingdom Hearts 2.5 HD ReMix PS3 file extractor
import sys
import struct
import os
def ReadEntry():
filename = str(fd.read(0x20)).strip('\x00')
offset = struct.unpack('>Q', fd.read(8))[0]
entrySize = struct.unpack('>Q', fd.read(8))[0]
fd.seek(0x10, 1) # unk
return [filename, offset, entrySize]
def GetDirectoryName(oldpath):
ir = str(oldpath).rfind('\\')
if ir == -1:
return oldpath
return oldpath[:ir]
def RipEntry(filename, offset, size):
fd.seek(offset, 0)
buffer = fd.read(size)
fdout = open(filename, 'wb')
fdout.write(buffer)
fdout.close()
# q for qword > for bigendian
fd = open('kingdom2.mself', 'rb')
magic = str(fd.read(4)).strip('\0')
print(magic)
if magic != 'MSF':
exit()
print('ok')
version = struct.unpack('>I', fd.read(4))[0]
fileSize = struct.unpack('>Q', fd.read(8))[0]
fileCount = struct.unpack('>I', fd.read(4))[0]
fd.seek(struct.unpack('>I', fd.read(4))[0], 0) # pointer to first entry
for i in range(0,fileCount):
newEntry = ReadEntry()
print('File:\t{0:d}/{1:d}\t{2:s}\t\t{3:016x}\t{4:016x}'.format(i, fileCount ,newEntry[0], newEntry[1], newEntry[2]))
lastPos = fd.tell()
RipEntry(newEntry[0], newEntry[1], newEntry[2])
fd.seek(lastPos, 0)
@MaKiPL
Copy link
Author

MaKiPL commented Oct 19, 2021

wtf? this is mine? wtf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment