Created
October 31, 2019 13:19
-
-
Save MaKiPL/927d9162f7b0e9ba994c32d42cb84657 to your computer and use it in GitHub Desktop.
Kingdom Hearts 2.5 HD ReMix PS3 file extractor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
wtf? this is mine? wtf