-
-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Native Library patching and File Handle provider for arbitrary files #265
Comments
In regards:
|
You mention a possibility that |
If no
|
That's actually not a bad idea to be honest, and LibraryPatch will probably inherit from FilePatch, though long-term it would be interesting to expand upon it by adding convenience functions specific to libraries, such as locating a symbol in a library and such |
A |
Oh right that makes sense |
Couldn't I just implement this by mostly modifying The whole closing mechanism is somewhat confusing to me tbh, it seems that it only actually writes out the file on a "close" and the file is otherwise held in memory? |
It will be held in memory unless you do not close the stream. The reason for the closing mechanism is that two patches may attempt to write to the same file which can be a problem. |
Fair, however, I can see this potentially being problematic when trying to patch large files/libraries Especially stuff like Unity bundles which can exceed sizes in the gigabytes |
The locking mechanism is currently only present when you use DomFileEditor. For input streams, no locking mechanism is needed. The locking process is only necessary when you open a write stream |
Ah, that makes sense so the patch would just, for example, effectively store addresses and data to write at those addresses, then on the close operation, it would just modify the inputstream as it's being written to the outputstream At the moment I'm mainly just looking into modifying I do kind of feel like I'm overthinking this though |
DomFileEditor was specifically made for XML and other kinds of DOM files. If you want to open file streams you can currently do so with context["file"].inputStream() |
wait is that actually currently implemented or are you just proposing implementation? |
This is implemented |
oh lol |
Also, is there any reason copying the general structure of the |
It was primarily done for DomFileEditor as we would have to introduce custom write and read methods or properly implement all overloads for File if we were want to include the locking mechanism for arbitrary files as well. |
Well didn't you mention that we would need the locking mechanism anyway? Mostly for consistency and also because I'm lazy and it seems easy to do (famous last words) |
Your context allows opening read and write streams only. This means that implementing the locking mechanism doesn't require the overhead mentioned in my previous comment as you'd only need to consider the two methods to open read and write streams. Feel free to refactor the code in a way that makes it suitable for arbitrary files as well, the current strategy to just support locking for DomFileEditor is slightly arbitrary and not really ideal. |
Right... Couldn't I also have something like the current To be honest I don't really know what I'm doing and I'm just trying to implement this by modifying existing code as much as possible... |
context["file"] returns you a |
Wait so can't I just use that to patch arbitrary files anyway? |
As it tries to open a file in a directory, but the libraries are not present it would fail. You'd need to read it from the APK file as a stream for example and if you modify it, write back to disk. More particularly you can find the full procedure in my initial comment above |
Oh right, that makes sense To be honest, whilst it's somewhat jank, as an initial implementation I'll probably just make a modified version of the resource patch |
Feature description
It would be extremely useful to support binary patching native libs as well as the ability to obtain a file handle to any file in the APK
This would be especially useful for patching more advanced applications, ie: Google Photos, or patching games, such as Unity games where patching the native libraries could allow for code changes whilst arbitrary file patching would let you modify asset bundles at ease
I think it would be important to provide a file handle rather than the traditional patched API as it may be important to include a custom parser or the ability to create and delete files as needed
Motivation
This feature should be implemented because it would allow a significant number of apps and games to be patchable through Revanced than otherwise and would allow for further changes to apps than otherwise, especially for games
Acknowledgements
The text was updated successfully, but these errors were encountered: