[GPL] Shipped rom extractor (Linux)

Search This thread

MartinEve

Senior Member
Aug 1, 2010
226
15
For the first time, I today attempted to extract a rom.zip from a shipped rom release (.exe) on Linux.

The process is problematic as, after launching the executable using wine, the application crashes, deleting all its files. You therefore have to be *very* quick looking inside the ~/.wine/users/username/Temp folder for the rom.zip.

Anyway, I have knocked up a quick python script that will monitor this directory for rom.zip and copy it to your home folder.

The only modification you need to make before running is to change the username field to your own username. I would have used getpass to obtain this but, for some reason, on certain systems you need to use sudo which messes this up.

Usage:
1.) Change username in script
2.) Run script
3.) Run RUU_xxxxxx.exe
4.) Get rom.zip from home folder

Anyway, I hope this is helpful and look forward to hearing feedback.

Best,

Martin

Code:
#!/usr/bin/python

'''
		ROM Extractor Copyright (c) 2010 Martin Paul Eve
		This program is free software: you can redistribute it and/or modify
		it under the terms of the GNU General Public License as published by
		the Free Software Foundation, either version 3 of the License, or
		(at your option) any later version.

		This program is distributed in the hope that it will be useful,
		but WITHOUT ANY WARRANTY; without even the implied warranty of
		MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
		GNU General Public License for more details.

		You should have received a copy of the GNU General Public License
		along with this program. If not, see <http://www.gnu.org/licenses/>.
'''

import os
import pyinotify
import io

# USERNAME IS REQUIRED (you may have to run as root using sudo)
username = "martin"

# Modify these if using a different wine location or rom name; HTC seem to use rom.zip
filename = "rom.zip"
monitor_path = "~/.wine/drive_c/users/%s/Temp/" % username


wm = pyinotify.WatchManager()
mask = pyinotify.IN_CREATE | pyinotify.IN_MODIFY | pyinotify.IN_DELETE | pyinotify.IN_MOVED_TO
bd = None

class RExtract(pyinotify.ProcessEvent):
	def process_IN_MOVED_TO(self, event):
		 # this seems to be the event fired; IN_CREATE is included just in case, though
		 if event.name.endswith(filename):
	 		 print "Found ROM. Awaiting completion of modification."
	 		 self.f = open(os.path.join(event.path, event.name), "r")
	 		 self.bd = self.f.read()
	def process_IN_CREATE(self, event):
		 if event.name.endswith(filename):
	 		 print "Found ROM. Awaiting completion of modification."
	 		 self.f = open(os.path.join(event.path, event.name), "r")
	def process_IN_MODIFY(self, event):
	 	# on modify, append to the file
	 	if event.name.endswith(filename):
	 	 	if hasattr(self, "bd"):
			 	self.bd = self.bd + self.f.read()
		 	else:
			 	self.bd = self.f.read()
 	def process_IN_DELETE(self, event):
		if event.name.endswith(filename):
			self.f.close()
			self.f = open(os.path.join("/home/%s/" % username, "rom.zip"), "w")
			self.f.write(self.bd)
			self.f.close()
			print "ROM Copied to /home/%s/rom.zip" % username
			raise KeyboardInterrupt

notifier = pyinotify.Notifier(wm, RExtract())
print "ROM Extractor Copyright (c) 2010 Martin Paul Eve"
print "This program comes with ABSOLUTELY NO WARRANTY."
print "This is free software, and you are welcome to redistribute it under certain conditions; see the included licence statement"
print ""
print "Monitoring: %(path)s for %(filename)s" % {"path": os.path.expanduser(monitor_path), "filename": filename}
print "Press CTRL+C to exit"

wdd = wm.add_watch(os.path.expanduser(monitor_path), mask, rec=True, auto_add=True)

while True:
	try:
	 notifier.process_events()
	 if notifier.check_events():
		notifier.read_events()
	except KeyboardInterrupt:
	 notifier.stop()
	 break
 
Last edited:

voodka2007

Member
Aug 28, 2010
8
0
Script can be run, it just can't found rom.zip... i have install python-pyinotify package, and it's same.

I have try 2 monitoring path :

~/.wine/dosdevices/c:/windows/temp
and

~/.wine/drive_c/windows/temp

I have try with root, sudo, check username, chmod the script, and it's same.
 

MartinEve

Senior Member
Aug 1, 2010
226
15
Script can be run, it just can't found rom.zip... i have install python-pyinotify package, and it's same.

I have try 2 monitoring path :

~/.wine/dosdevices/c:/windows/temp
and

~/.wine/drive_c/windows/temp

I have try with root, sudo, check username, chmod the script, and it's same.

Check the format of your path. It should be like this:

monitor_path = "~/.wine/drive_c/users/%s/Temp/" % username

This is because it won't extract to c:\Windows\Temp but to c:\Users\Username\Temp

Try leaving monitor path just as it was (but change the username)...
 

voodka2007

Member
Aug 28, 2010
8
0
Code:
[Pyinotify ERROR] add_watch: cannot watch /home/voodka/.wine/drive_c/users/voodka/Temp/ (WD=-1)
I haven't users folder in my .wine/drive_c/
 

MartinEve

Senior Member
Aug 1, 2010
226
15
What version of windows have you set in winecfg?

Sent from my HTC Wildfire using XDA App
 

voodka2007

Member
Aug 28, 2010
8
0
Thanks for your perseverance !
In my wincfg i use Windows XP
But i have try with Windows 7 and it's always same...
Do this problem can come from Wine 1.2 ? (i don't use 1.0)

Thanks...
 

lijn

New member
Oct 24, 2010
2
1
Worked for me.
Radio_13.53.55.24H_3.35.19.25_release_151892_signed.exe and Ubuntu 10.10

thanks!