RomRaider Logo

RomRaider

Open Source ECU Tools
 FAQ •  Register •  Login 

RomRaider

Documentation

Community

Developers

It is currently Mon Aug 08, 2022 10:15 pm

All times are UTC - 5 hours [ DST ]





Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: UTILITY: RomPatch.exe
PostPosted: Sat Dec 10, 2011 6:15 pm 
Offline
Moderator

Joined: Wed Nov 22, 2006 10:23 pm
Posts: 2565
RomPatch.exe is a utility for patching Subaru ROMs. In order to apply a patch to your ROM, you must have a patch that was created for your ROM. Currently there is only one patch available, for the A2WC522N ROM (click here), however I hope to see (and/or create) more patches in the future.

To apply a patch to your ROM, run this command:

Code:
RomPatch apply Patch.mot YourRomFile.bin


You should see results like this:

Code:
This patch file was intended for A2WC522N.
Validating patches...
Patch start: 000318DC, end: 00031911, length: 00000036 - Valid.
Patch start: 00090000, end: 000900C3, length: 000000C4 - Valid.
This patch file can be applied to this ROM file.
Applying patch.
Verifying patch.
ROM file modified successfully.


To remove a patch from your ROM:

Code:
RomPatch remove Patch.mot YourRomFile.bin


And expect results like this:

Code:
This patch file was intended for A2WC522N.
Preparing to remove patch.
Validating patches...
Patch start: 000318DC, end: 00031911, length: 00000036 - Valid.
Patch start: 00090000, end: 000900C3, length: 000000C4 - Valid.
This patch file was previously applied to this ROM file.
Removing patch.
Verifying patch.
ROM file modified successfully.


This will remove the patch without modifying other parts of your ROM. This step will generally be required before applying a different patch, or a newer version of the same patch.

If you run RomPatch with no parameters, or with parameters that it does not understand, RomPatch will try to help:

Code:
RomPatch Version 3.
Commands:

test       - determine whether a patch is suitable for a ROM
apply      - apply a patch to a ROM file
applied    - determine whether a patch has been applied to a ROM
remove     - remove a patch from a ROM file
dump       - dump the contents of a patch file
baseline   - generate baseline data for a ROM and a partial patch

Use "RomPatch help <command>" to show help for that command.


The "test" command can be used to determine whether it is possible to apply a given patch file to a given ROM file, and the "applied" command will tell you whether or not a patch file has already been applied to a ROM file. The same tests are performed when you use the "apply" and "remove" commands, however these two will not modify the ROM file.

For developers:

RomPatch reads patches from Motorola S-Record files, which makes it relatively easy to compile and test patches using Renesas' High Performance Embedded Workshop (HEW). You can validate your own code directly in the debugger, and then by patching and loading a ROM file you can also validate the integration of your code with the stock ECU code.

For more information about using RomPatch for patch development, please see the Hacking with HEW thread (viewtopic.php?f=25&t=7680), and please use that thread for questions about the development process. Let's keep this thread focused on end-user technical support.

Source code is available at:
https://github.com/LegacyNsfw/RomPatch


Attachments:
File comment: RomPatch, version 5.

This is the most current version of RomPatch. It is probably the one that you want.

RomPatch-v5.exe [29 KiB]
Downloaded 1400 times
File comment: RomPatch, version 3.

Only use this version if you need to remove my LC/FFS patch for A2WC522N - that's the only patch that requires version 3. Newer patches will use version 5 instead.

RomPatch-v3.exe [26 KiB]
Downloaded 580 times
File comment: Source code for RomPatch version 3.
RomPatch11.zip [1.84 MiB]
Downloaded 637 times

_________________
2005 Legacy GT w/ ATP 3076, IWG, MBC, BCS, BC 272, LC, FFS, OMG
Please don't send questions via PM. Post a thread and send me a link to it instead. Thanks!
Top
 Profile  
 
 Post subject: Re: RomPatch.exe
PostPosted: Mon Dec 12, 2011 4:59 am 
Offline
Moderator

Joined: Wed Nov 22, 2006 10:23 pm
Posts: 2565
(This space reserved for future updates.)

_________________
2005 Legacy GT w/ ATP 3076, IWG, MBC, BCS, BC 272, LC, FFS, OMG
Please don't send questions via PM. Post a thread and send me a link to it instead. Thanks!


Top
 Profile  
 
 Post subject: Re: UTILITY: RomPatch.exe
PostPosted: Tue Dec 13, 2011 1:39 am 
Offline
Newbie
User avatar

Joined: Thu Dec 03, 2009 4:52 am
Posts: 27
Location: CA Bay Area
I came in here to say AWESOME developments NSFW! I can't wait to see the 32 bit world filled with great patches!


Top
 Profile  
 
 Post subject: Re: UTILITY: RomPatch.exe
PostPosted: Fri Dec 23, 2011 5:00 am 
Offline
Moderator

Joined: Wed Nov 22, 2006 10:23 pm
Posts: 2565
Thanks!

I just noticed that you can only remove a patch if all of the tables created by the patch contain the same values as when the patch was applied. For example I can't remove my LC/FFS patch until I return the thresholds to their original values. Not a big deal for that particular patch, but it could turn into a nuisance when patches get more complicated.

I'll look into extending the patch format with a way to indicate that certain byte ranges are not critical to the validation that is done before removing a patch.

_________________
2005 Legacy GT w/ ATP 3076, IWG, MBC, BCS, BC 272, LC, FFS, OMG
Please don't send questions via PM. Post a thread and send me a link to it instead. Thanks!


Top
 Profile  
 
 Post subject: Re: UTILITY: RomPatch.exe
PostPosted: Fri Dec 23, 2011 4:44 pm 
Offline
Experienced
User avatar

Joined: Thu Jul 23, 2009 1:46 pm
Posts: 863
NSFW wrote:
Thanks!

I just noticed that you can only remove a patch if all of the tables created by the patch contain the same values as when the patch was applied. For example I can't remove my LC/FFS patch until I return the thresholds to their original values. Not a big deal for that particular patch, but it could turn into a nuisance when patches get more complicated.

I'll look into extending the patch format with a way to indicate that certain byte ranges are not critical to the validation that is done before removing a patch.


That would be a great addition. TinyPatcher has the same issue.

_________________
Please do not send me support questions via PM, use the forum instead!


Top
 Profile  
 
 Post subject: Re: UTILITY: RomPatch.exe
PostPosted: Tue Jan 17, 2012 11:00 pm 
Offline
Newbie

Joined: Tue Jan 17, 2012 7:50 pm
Posts: 2
Tried running this on Windows 7 as an administrator and it'll open for half of a second and automatically close. Trying to patch in LC and FFS for my 05 LGT.

Any ideas? Tried it on another computer and it did the same thing.


Top
 Profile  
 
 Post subject: Re: UTILITY: RomPatch.exe
PostPosted: Wed Jan 18, 2012 12:16 am 
Offline
Moderator

Joined: Wed Nov 22, 2006 10:23 pm
Posts: 2565
It's a command-line utility, so you'll need to open a command window to run it.
Press WindowKey + R, type cmd.exe, and then run RomPatch from that window.
If you get an error-message, copy-paste it into a new message and I'll try to address it.

_________________
2005 Legacy GT w/ ATP 3076, IWG, MBC, BCS, BC 272, LC, FFS, OMG
Please don't send questions via PM. Post a thread and send me a link to it instead. Thanks!


Top
 Profile  
 
 Post subject: Re: UTILITY: RomPatch.exe
PostPosted: Fri Apr 27, 2012 3:28 pm 
Offline
Experienced
User avatar

Joined: Thu Jul 23, 2009 1:46 pm
Posts: 863
I've made some changes to this program, if anyone is using it to create patches send me a pm.

Added a check between "old value" in metadata vs. the data in your baseline rom. In case you make a typo, in the address, no brick just an error. :)

Also made a fix for multiple patches, allowing more patch features.. and features that require numerous hooks.

This week I will be writing some code to differentiate between code sections and table sections, to allow for unpatching of edited tables.

_________________
Please do not send me support questions via PM, use the forum instead!


Top
 Profile  
 
 Post subject: Re: UTILITY: RomPatch.exe
PostPosted: Mon Apr 30, 2012 4:18 am 
Offline
Moderator

Joined: Wed Nov 22, 2006 10:23 pm
Posts: 2565
Thanks for picking up the baton... I got your PM a while back but haven't had a look at the code yet. I'll update the first post when I get a chance, hopefully in the next couple days.

_________________
2005 Legacy GT w/ ATP 3076, IWG, MBC, BCS, BC 272, LC, FFS, OMG
Please don't send questions via PM. Post a thread and send me a link to it instead. Thanks!


Top
 Profile  
 
 Post subject: Re: UTILITY: RomPatch.exe
PostPosted: Wed May 09, 2012 2:47 am 
Offline
Experienced
User avatar

Joined: Thu Jul 23, 2009 1:46 pm
Posts: 863
No problem, let me know how you want to work things out with a git repo for this.

Just noting some other changes for when I find some time to dig into this stuff:

Create cookie for "PatchNew" sections of metadata:
Used for adding new subroutines and tables to free space, not overwriting existing (use regular 'Patch' for that - change name to 'PatchOver')
-Allows for unpatching after editing tables/data
-While creating baseline data, checks that all rom data is h'FF bytes to avoid accidental overwrites
-Unpatch function recognizes the cookie and skips validation or only validates "markers" at beginning/end, writes all h'FF bytes to patch area

Make sure patch/unpatch functions don't modify rom if any section is invalid.
-had an issue with a changed table that resulted in an a half-unpatched rom. The above should fix that, but I still think it's a good practice especially if no validation is used on a 'PatchNew' (accidental unpatch of wrong rom could cause a brick).

I created a simple forms GUI a while ago that auto-detects CALID, has patch files incorporated into the binary, and successfully patched a test rom.
-write code to select proper patch files based upon CALID
-integrate exception/errors with GUI better (currently only pipes console to textbox)
-add ability to 'save patched rom as'

_________________
Please do not send me support questions via PM, use the forum instead!


Top
 Profile  
 
 Post subject: Re: UTILITY: RomPatch.exe
PostPosted: Thu Jun 14, 2012 9:43 pm 
Offline
Experienced
User avatar

Joined: Thu Jul 23, 2009 1:46 pm
Posts: 863
^^ All of the above is complete. Will be uploading the command line utility to my git after a few more rounds of debug testing :)

And here's a little teaser:

Attachment:
rommod2.gif
rommod2.gif [ 186.47 KiB | Viewed 13259 times ]

_________________
Please do not send me support questions via PM, use the forum instead!


Top
 Profile  
 
 Post subject: Re: UTILITY: RomPatch.exe
PostPosted: Fri Jun 15, 2012 12:40 am 
Offline
Moderator

Joined: Wed Nov 22, 2006 10:23 pm
Posts: 2565
Looks like you've done more work to it than I have, at this point. :)

When it's ready, just put it on your github and start a new RomPatch thread. I'll update the title of this one to say "[version 5 and earlier]" or something like that.

_________________
2005 Legacy GT w/ ATP 3076, IWG, MBC, BCS, BC 272, LC, FFS, OMG
Please don't send questions via PM. Post a thread and send me a link to it instead. Thanks!


Top
 Profile  
 
 Post subject: Re: UTILITY: RomPatch.exe
PostPosted: Mon Jul 30, 2012 1:42 pm 
Offline
Experienced
User avatar

Joined: Thu Jul 23, 2009 1:46 pm
Posts: 863
Put what I have so far up on GitHub, will make a thread soon enough.

https://github.com/Merp/SharpTune

_________________
Please do not send me support questions via PM, use the forum instead!


Top
 Profile  
 
 Post subject: Re: UTILITY: RomPatch.exe
PostPosted: Wed May 01, 2013 9:41 am 
Offline
Newbie

Joined: Fri Oct 12, 2012 2:20 pm
Posts: 51
here's my error....

is this EXE just a long batch command? What does it actually do to "patch" the rom, extend memory allocations?


Attachments:
File comment: screnshot
fail.jpg
fail.jpg [ 114.71 KiB | Viewed 11366 times ]
Top
 Profile  
 
 Post subject: Re: UTILITY: RomPatch.exe
PostPosted: Fri Nov 01, 2013 10:06 pm 
Offline
RomRaider Donator

Joined: Wed Dec 28, 2011 10:04 pm
Posts: 181
Hey NFSW,

Quick one, I have a srecord patch that is based on merp celflash. I have created a meta data file that hooks the initializer and main function and the patch tool seems to work for the hooks but I am getting an issue trying to patch the main source code. Any pointers ?

Image

I'll keep digging but if you can help me out that would be great. Awesome tools guys btw ... I know there is data in my patch at 0xE1000, I ran it through an S record parser script and it is telling me that I have a datablock at the specified addresses. Anything special that your tool is expecting there ?

Thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subsilver by phpBBservice.nl