Wh0ba / XPatcher

GUI front-end for flips and xdelta patching libraries
GNU General Public License v2.0
46 stars 3 forks source link

BUG: Issue when patching using a “vcdiff” patch #6

Open lonkelle opened 2 years ago

lonkelle commented 2 years ago

Apparently, there is the vcdiff file extension for patches which is synonymous with the xdelta file format.

BUT, no matter how hard I’ve tried to make this vcdiff (xdelta) patch work in XPatcher, it errors out every time thinking the file is wrong (despite the file matching the MD5 checksum of the patch). Here’s the link to the patch to see if you can get it working where I couldn’t:

https://www.romhacking.net/hacks/2881/

lonkelle commented 2 years ago

Using macOS's MultiPatch app (https://projects.sappharad.com/multipatch/) and editing the ".vcdiff" patch extension to ".xdelta" and applying the patch worked perfectly. The same method did not work in XPatcher so there's still something off about this format of patch since MultiPatch patched it just fine as long as I changed the file extension to ".xdelta". 🤔

Wh0ba commented 2 years ago

Hmmm I've made the app recognize the vcdiff as an xdelta patch but still it shows the same error although the MD5 checks with the one mentioned in the hack description. What I suspect after looking into the vcdiff patch itself is that it contains two file names for the rom and I didn't really notice any Hashes mentioned inside it, so maybe the reason it's not working is because it expects a file name to match it with the one inside the patch . But the way the adapters were written in Multipatch passes them as file streams which XDelta directly reads bytes from. Although I'm not really sure if that is the case

lonkelle commented 2 years ago

@Wh0ba Does XPatcher work differently than MultiPatch in the "file stream" sense? ".xdelta" is such a common file format and all of the research I did told me that ".vcdiff" and ".xdelta" are exactly the same file type.

Are you using the same library as MultiPatch does to handle ".xdelta" files - cause if so, I'd be very confused. Were you also able to get it to patch correctly by changing the extension to ".xdelta" and using MultiPatch? I mean, I'm happy I got it too work, but I absolutely love patching on my phone with XPatcher a lot so if I can help you debug this, let me know. :)

Wh0ba commented 2 years ago

Hmmm I believe it works the exact same way since I've included the same xdelta library used by MultiPatch. I even used the same exact adapter for patching with it, which is why I'm also confused on why exactly it is not working like it should. I did not try to patch it with MultiPatch since I don't have an access to a machine running MacOS, so I'm stuck with this weird behavior. And currently the problem is that the library it self is returning this error as shown in this if statement: https://github.com/Wh0ba/XPatcher/blob/c9b7a6a463d925681163ee05a672b4f5fc6fd6dd/MC/adapters/XDeltaAdapter.m#L24-L26

lonkelle commented 2 years ago

I wonder if MultiPatch has a function to remove / add header when trying to patch. I'll do some experiments. Also, I found another VCDiff patch file and it worked in MultiPatch and didn't work in Xpatcher. Maybe this will help shed some light on what's going on there: https://www.romhacking.net/hacks/2905/