-
Notifications
You must be signed in to change notification settings - Fork 6
[Draft] PRP Reader Script
Daniel Hunter edited this page Mar 13, 2020
·
1 revision
Just a small draft for a .PRP file reader, written in python.
What .PRP file's are used for we are unsure of.
A small part of the format explained.
\\Python Script
import sys, os, struct
class IFTABLE:
def __init__(self, fp):
self.file = fp
self.imports = []
self.importsSize = 0
def __del__(self):
self.file.close()
def read(self):
self.file.seek(0) # Jump to start
self.file.seek(0x1B) # Jump to IFTBL offset
self.importsSize = struct.unpack('i', self.file.read(4))[0]
self.file.seek(0x1F)
fOffset = self.file.tell()
wordStartOffset = fOffset
word = ""
while fOffset <= self.importsSize:
pB = self.file.read(1)
fOffset = self.file.tell()
if ord(pB) == 0x0 and len(word) > 0:
self.imports.append((wordStartOffset + 1, word))
word = ""
elif pB.isalnum():
word += pB
else:
wordStartOffset = fOffset
# Show IM table
for im in self.imports:
off, w = im
print "[{:8x}] = {}".format(off, w)
print " * TABLE SIZE {:8x} * ".format(self.importsSize)
def error(s):
print "Error: %s" % s
sys.exit(-1)
if len(sys.argv) < 2:
print "Usage: test.py [PRP file]"
sys.exit(0)
prpFile = sys.argv[1]
f = open(prpFile, "rb")
try:
header = f.read(0xD)
# If the header does not contain "IOPacked v0.1"
if header != "IOPacked v0.1":
# Give error an with a warning of "Wrong File, bad header"
error("Wrong file. Bad header")
PRPIF = IFTABLE(f)
PRPIF.read()
finally:
f.close()