Page 1 of 1

How to unpack RPA files

Posted: Thu Oct 04, 2012 3:54 pm
by TeenPhilosopher
Hey, TeenPhilosopher here, I want to use some sprites from a different game (I have permission, of course) but all the game data is archived in an RPA file ("data.rpa"). I honestly haven't the slightest idea how to do this. This page: http://www.renpy.org/wiki/renpy/doc/coo ... s_from_rpa shows how to unarchive a specific file, but I don't know the names of each specific file, nor would I like to unarchive file by file. Is there another way to unarchive the data.rpa as a whole?

Re: How to unpack RPA files

Posted: Thu Oct 04, 2012 4:55 pm
by AxemRed
There's a Python script floating around the internet named "unrpa.py" which does what you want.

Disclaimer: blah blah only use for educational purposes or when you have explicit permission, etc.

Re: How to unpack RPA files

Posted: Thu Oct 04, 2012 11:07 pm
by tigerkidde
It may be best for the one that gave permission to provide those items you seek to you. That way you don't have to worry about fiddling with unpacking funness.

Re: How to unpack RPA files

Posted: Fri Oct 05, 2012 10:10 pm
by TeenPhilosopher
tigerkidde wrote:It may be best for the one that gave permission to provide those items you seek to you. That way you don't have to worry about fiddling with unpacking funness.
Maybe. I asked him to, but I haven't the slightest idea when it'll be online. It might be tomorrow, next week, hell, it might be next month. Have any of you gotten the unrpa script to work? I just dragged it onto Editra, but Renpy doesn't seem to like the tab characters. I have no idea why.

Re: How to unpack RPA files

Posted: Fri Oct 05, 2012 10:59 pm
by nottiebutt
TeenPhilosopher wrote:
tigerkidde wrote:It may be best for the one that gave permission to provide those items you seek to you. That way you don't have to worry about fiddling with unpacking funness.
Maybe. I asked him to, but I haven't the slightest idea when it'll be online. It might be tomorrow, next week, hell, it might be next month. Have any of you gotten the unrpa script to work? I just dragged it onto Editra, but Renpy doesn't seem to like the tab characters. I have no idea why.
I played around with unrpa and unrpyc myself, and it depends on the version of renpy with distribution I think.
I had to mess with the codes of the action script as well as edit the renpy files in the distribution files to allow it.
I've gotten into a few games, but then there are some I can't find a solution to, so it all depends.

Did you use cmd prompt to run unrpa? If you can then paste the error message you get from that if it doesn't work, you might be able to temporarily disable those lines of the script as long as you remember to add them again once you've got the files.

Re: How to unpack RPA files

Posted: Fri Oct 05, 2012 11:11 pm
by TeenPhilosopher
nottiebutt wrote:
TeenPhilosopher wrote:
tigerkidde wrote:It may be best for the one that gave permission to provide those items you seek to you. That way you don't have to worry about fiddling with unpacking funness.
Maybe. I asked him to, but I haven't the slightest idea when it'll be online. It might be tomorrow, next week, hell, it might be next month. Have any of you gotten the unrpa script to work? I just dragged it onto Editra, but Renpy doesn't seem to like the tab characters. I have no idea why.
I played around with unrpa and unrpyc myself, and it depends on the version of renpy with distribution I think.
I had to mess with the codes of the action script as well as edit the renpy files in the distribution files to allow it.
I've gotten into a few games, but then there are some I can't find a solution to, so it all depends.

Did you use cmd prompt to run unrpa? If you can then paste the error message you get from that if it doesn't work, you might be able to temporarily disable those lines of the script as long as you remember to add them again once you've got the files.
cmd prompt? Sounds familiar, but unfortunately I'm not entirely sure what you mean. Sorry, I'm only 12 and an amateur coder at best. I wouldn't have guessed that unrpa's results would vary from Ren'Py version to Ren'Py version... Ha, I guess I'm a little overjoyed about the easiness of Ren'Py.

Re: How to unpack RPA files

Posted: Sat Oct 06, 2012 1:19 am
by nottiebutt
Well, I'll assume your using windows. Open up your taskbar and search 'cmd'. Press enter or open the cmd prompt. Put unrpa in the file of the rpa you want disassembled. If it's set up as a python file, you should be able to enter 'C:\foldername\gamename\unrpyc.py -m -p C:\foldername\gamename\foldertheextractedfilesgointo C:\foldername\gamename\game\date.rpa'

If that doesn't work, what game are you trying to extract from? What python version do you have? What system do you run?

Re: How to unpack RPA files

Posted: Sat Oct 06, 2012 10:35 am
by TeenPhilosopher
Oh. cmd. Duh. *Shakes head in shame*.

Well, I typed this in: C:\Users\alex\Desktop\Homeward-all\game\unrpa.py -m -p C:\Users\alex\Desktop\Homeward-all\game C:\Users\alex\Desktop\Homeward-all\game\data.rpa

For some reason, It doesn't seem to work, even though I have the latest version of Python (2.7.3, I'm not using Python 3) and the latest "version"of unrpa. I get this error message when I run:

C:\Users\alex>Desktop\Homeward-all\game\unrpa.py -m -p C:\Users\alex\Desktop\Homeward-all C:\Users\alex\Desktop\Homeward-all\data.rpa

unrpa: extracting files.
Traceback (most recent call last):
File "C:\Users\alex\Desktop\Homeward-all\game\unrpa.py", line 189, in <module>

unarchiver.extract_files()
File "C:\Users\alex\Desktop\Homeward-all\game\unrpa.py", line 65, in extract_files
index = self.get_index()
File "C:\Users\alex\Desktop\Homeward-all\game\unrpa.py", line 111, in get_index
with open(self.archive, "rb") as f:
IOError: [Errno 2] No such file or directory: 'C:\\Users\\alex\\Desktop\\Homeward-all\\data.rpa'



Yeah. I honestly can't make out what's wrong. The file is there. C:\Users\alex\Desktop\Homeward-all\game\data.rpa Weird. I'm using Python 2.7.3, Windows 7, and I'm trying to extract from the Homeward game http://games.renpy.org/game/homeward.shtml It seems to be up to date. At least, enough, it's version is Ren'Py 6.13.11.

Re: How to unpack RPA files

Posted: Sat Oct 06, 2012 11:17 am
by nottiebutt
Hmm.
I looked up the unrpa script and had a quick look through, and while I can't see the immediate problem, you said the guide tells you how to unarchive specific files, yes?
It might be troublesome, but it'll probably be easier than dissecting the whole code.
So try this 'C:\Users\alex>Desktop\Homeward-all\game\unrpa.py -l C:\Users\alex\Desktop\Homeward-all\data.rpa' to get a list of the contents of the rpa package. If you don't want to go through all the typing, to save time, 'cmd /K "cd C:\Users\alex\Desktop\Homeward-all"' then 'cd /k' which will make you not have to type the location up again.

fakeedit: I've just noticed that you entered "C:\Users\alex>Desktop\Homeward-all\game\unrpa.py" which doesn't seem to be a problem as its found the unrpa.py file fine, but I thought I should mention.

fakeedit2: if unrpa doesn't work, I've found another script called unpacker which might work.

Code: Select all

from cPickle import loads
import zlib, os
 
f = file("data.rpa", "rb")
 
header = f.readline().split()
indexoffset = int(header[1], 16)
key = int(header[2], 16)
 
f.seek(indexoffset)
indexcomp = f.read()
index = loads(zlib.decompress(indexcomp))
 
for k in index.keys():
    print k
    fn = k.split('/')
    shortfn = fn.pop()
    dir = 'dump/' + '/'.join(fn)
   
    offset = index[k][0][0] ^ key
    size = index[k][0][1] ^ key
   
    if not os.path.exists(dir):
        os.makedirs(dir)
    of = file(dir + '/' + shortfn, "wb")
   
    of.write(index[k][0][2])
    f.seek(offset)
    of.write(f.read(size))
    of.close()

Re: How to unpack RPA files

Posted: Sat Oct 06, 2012 11:17 am
by AxemRed
Look closely at the paths:

you typed: C:\Users\alex\Desktop\Homeward-all\data.rpa
actual file: C:\Users\alex\Desktop\Homeward-all\game\data.rpa

Re: How to unpack RPA files

Posted: Sat Oct 06, 2012 11:29 am
by TeenPhilosopher
AxemRed wrote:Look closely at the paths:

you typed: C:\Users\alex\Desktop\Homeward-all\data.rpa
actual file: C:\Users\alex\Desktop\Homeward-all\game\data.rpa
Huh?? Oh sh*t. I knew it would be a typo error. ARGH. I'll try it out again!

IT WORKED! YAY! Sorry, I just tend to get a little overjoyed when something like that is finally working.
nottiebutt wrote:Hmm.
I looked up the unrpa script and had a quick look through, and while I can't see the immediate problem, you said the guide tells you how to unarchive specific files, yes?
It might be troublesome, but it'll probably be easier than dissecting the whole code.
So try this 'C:\Users\alex>Desktop\Homeward-all\game\unrpa.py -l C:\Users\alex\Desktop\Homeward-all\data.rpa' to get a list of the contents of the rpa package. If you don't want to go through all the typing, to save time, 'cmd /K "cd C:\Users\alex\Desktop\Homeward-all"' then 'cd /k' which will make you not have to type the location up again.

fakeedit: I've just noticed that you entered "C:\Users\alex>Desktop\Homeward-all\game\unrpa.py" which doesn't seem to be a problem as its found the unrpa.py file fine, but I thought I should mention.

fakeedit2: if unrpa doesn't work, I've found another script called unpacker which might work.

Code: Select all

from cPickle import loads
import zlib, os
 
f = file("data.rpa", "rb")
 
header = f.readline().split()
indexoffset = int(header[1], 16)
key = int(header[2], 16)
 
f.seek(indexoffset)
indexcomp = f.read()
index = loads(zlib.decompress(indexcomp))
 
for k in index.keys():
    print k
    fn = k.split('/')
    shortfn = fn.pop()
    dir = 'dump/' + '/'.join(fn)
   
    offset = index[k][0][0] ^ key
    size = index[k][0][1] ^ key
   
    if not os.path.exists(dir):
        os.makedirs(dir)
    of = file(dir + '/' + shortfn, "wb")
   
    of.write(index[k][0][2])
    f.seek(offset)
    of.write(f.read(size))
    of.close()
Thanks, it won't be necessary, but I really appreciate all the help!! THANKS!

Re: How to unpack RPA files

Posted: Tue Jan 20, 2015 6:58 pm
by knova
If someone else want to unpack RPA files on windows and don't want to install all python stuff and mess with cmd line, here is a little GUI app I made to do the job. The only prerequisite is to have at least Microsoft .Net 4 Framework installed (Often the case if you had an up to date computer or using Win 8 ).

http://www.mediafire.com/download/x19dx ... PATool.rar

Image

edit: It support only RPA-3.0 files.