mirror of
https://github.com/ReVanced/revanced-patcher.git
synced 2026-01-24 03:31:04 +00:00
Compare commits
193 Commits
v1.0.0-dev
...
v1.2.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
54aa04ca34 | ||
|
|
0eda84eaef | ||
|
|
b68b0bf3d7 | ||
|
|
c692202f67 | ||
|
|
8ce3535427 | ||
|
|
6a5c8735fb | ||
|
|
8f32bc9c08 | ||
|
|
d3a580ea19 | ||
|
|
4c8eb0e5c7 | ||
|
|
bc92eb7fd8 | ||
|
|
cf89bd4171 | ||
|
|
566ecefa2b | ||
|
|
8eb4a8f87a | ||
|
|
afcba5c212 | ||
|
|
2dcbd8d079 | ||
|
|
81895c7d5c | ||
|
|
22267883b1 | ||
|
|
26fca60b53 | ||
|
|
31815ca9ea | ||
|
|
1ce6098cad | ||
|
|
46a6396114 | ||
|
|
41e88605c3 | ||
|
|
893d4c699b | ||
|
|
bf8655ead8 | ||
|
|
6c65952d80 | ||
|
|
26f3e7336b | ||
|
|
849616dc2b | ||
|
|
e8a131fb08 | ||
|
|
11abc67d9a | ||
|
|
8615798711 | ||
|
|
070e02ea28 | ||
|
|
54511a4fc6 | ||
|
|
94f3c9116e | ||
|
|
fe56c0cadb | ||
|
|
bf4894592b | ||
|
|
5a96f2d99f | ||
|
|
839a5ef22a | ||
|
|
0ebdb100fd | ||
|
|
4f60bea81e | ||
|
|
1a49d9439f | ||
|
|
5535eb4f01 | ||
|
|
5dc6aa9bfd | ||
|
|
6c0d28191b | ||
|
|
9d067b9b0d | ||
|
|
a4d8be20fc | ||
|
|
ec9fd15f9b | ||
|
|
d20f7fd6e1 | ||
|
|
ebbcf78e56 | ||
|
|
024fa867e1 | ||
|
|
e506d8fd8c | ||
|
|
f5b5c52e55 | ||
|
|
fc05fe79de | ||
|
|
79909cf260 | ||
|
|
8f12873200 | ||
|
|
cc9416dd11 | ||
|
|
99319e63da | ||
|
|
c459beb5f8 | ||
|
|
e5ae970009 | ||
|
|
612515acf8 | ||
|
|
b1eebc99a7 | ||
|
|
6cb7cdb0b2 | ||
|
|
beff1df9b0 | ||
|
|
f58a498849 | ||
|
|
6cb1fdf617 | ||
|
|
7399450139 | ||
|
|
193eae298a | ||
|
|
4e56652429 | ||
|
|
7755bbc645 | ||
|
|
f3b5f67b39 | ||
|
|
7f18bbf66e | ||
|
|
c8b68e36e0 | ||
|
|
5ca5a1c29e | ||
|
|
d677d9e800 | ||
|
|
e5bea06353 | ||
|
|
8f1a629191 | ||
|
|
e6086511e5 | ||
|
|
c612676543 | ||
|
|
bca948658e | ||
|
|
0e5f4ba2d5 | ||
|
|
6ca05769ef | ||
|
|
c21e5affba | ||
|
|
1c5a04caf9 | ||
|
|
3d6a1d38f3 | ||
|
|
715a2ad025 | ||
|
|
9889ec9d03 | ||
|
|
01bfbd656e | ||
|
|
6c9797583d | ||
|
|
3cf07f5ce2 | ||
|
|
0bfb92a0cb | ||
|
|
042638a399 | ||
|
|
4178a1eedc | ||
|
|
338bd9f739 | ||
|
|
c55c62a57e | ||
|
|
1f08da8b2a | ||
|
|
b2dab3fabf | ||
|
|
0f30eac32c | ||
|
|
642e9031eb | ||
|
|
7a56dca004 | ||
|
|
18853f70a4 | ||
|
|
6b8b0573d4 | ||
|
|
3889d72927 | ||
|
|
3f97cc8e1f | ||
|
|
1db735b1e2 | ||
|
|
996c4acb20 | ||
|
|
5b28523eea | ||
|
|
72f3cad3f9 | ||
|
|
9659a61c5c | ||
|
|
b892729332 | ||
|
|
6e4db110c8 | ||
|
|
e810197e2a | ||
|
|
e65ebd27c2 | ||
|
|
5bd416b409 | ||
|
|
a6c6b4979a | ||
|
|
db10ab03be | ||
|
|
94dbb573cf | ||
|
|
08253ee010 | ||
|
|
3144ec872a | ||
|
|
48c4ea2f6d | ||
|
|
c63b20fa65 | ||
|
|
f806cb38c5 | ||
|
|
6c3e2d79ea | ||
|
|
cca12aa34a | ||
|
|
c267b12a7d | ||
|
|
eef448cc39 | ||
|
|
45303f66ec | ||
|
|
783fbf43f2 | ||
|
|
59189058ac | ||
|
|
dfac8f03a3 | ||
|
|
b44bf4c267 | ||
|
|
066ad274ed | ||
|
|
a8653fe6a0 | ||
|
|
139a23b750 | ||
|
|
0d8d19e708 | ||
|
|
a1e909b163 | ||
|
|
e4157332d3 | ||
|
|
923efc4caf | ||
|
|
bea0cbc550 | ||
|
|
1ee2e4ba56 | ||
|
|
fac44a50c3 | ||
|
|
544bcf76bd | ||
|
|
a16c8cabf2 | ||
|
|
2777117da2 | ||
|
|
66a9b76845 | ||
|
|
f068fc87ff | ||
|
|
7cc8a7dec3 | ||
|
|
398239dc10 | ||
|
|
d18a3b6a28 | ||
|
|
bfe4e3e298 | ||
|
|
a1b6b06bd3 | ||
|
|
4087f49863 | ||
|
|
00c85b5d75 | ||
|
|
cb78c5a86f | ||
|
|
9991f39c9a | ||
|
|
650bf71124 | ||
|
|
1dd3394ea3 | ||
|
|
e6c2501539 | ||
|
|
4b26305bd5 | ||
|
|
ce21bd60f3 | ||
|
|
3651981161 | ||
|
|
6299b9e951 | ||
|
|
24b544708f | ||
|
|
c7ef2644d8 | ||
|
|
fa6e454ae9 | ||
|
|
cbd8df2df0 | ||
|
|
f3d8b917de | ||
|
|
82c530650f | ||
|
|
81d0cf20f3 | ||
|
|
36d4f71325 | ||
|
|
699c730a7c | ||
|
|
b197956e39 | ||
|
|
be992a3e6f | ||
|
|
e0437397df | ||
|
|
41749ba829 | ||
|
|
8161ce4fa6 | ||
|
|
6626014ef3 | ||
|
|
e6e468fbb5 | ||
|
|
2fabbdf71b | ||
|
|
7faa001406 | ||
|
|
70872307e3 | ||
|
|
310a7c446b | ||
|
|
c236ebe078 | ||
|
|
674461f08d | ||
|
|
bbb2c547aa | ||
|
|
b957501e70 | ||
|
|
b6ca31a970 | ||
|
|
cbcf93f7d6 | ||
|
|
d5b4c99c00 | ||
|
|
4dd820ffdf | ||
|
|
cb9b1b9416 | ||
|
|
428f7f4dec | ||
|
|
77536cce8f | ||
|
|
7b6a61b674 | ||
|
|
7f5f3b217d |
1
.github/workflows/release.yml
vendored
1
.github/workflows/release.yml
vendored
@@ -1,5 +1,6 @@
|
|||||||
name: Release
|
name: Release
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
|||||||
220
CHANGELOG.md
220
CHANGELOG.md
@@ -1,3 +1,223 @@
|
|||||||
|
## [1.2.2](https://github.com/revanced/revanced-patcher/compare/v1.2.1...v1.2.2) (2022-06-14)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* enforce aapt v2 ([b68b0bf](https://github.com/revanced/revanced-patcher/commit/b68b0bf3d735f54b92ad7dad8132f77e9007063f))
|
||||||
|
|
||||||
|
## [1.2.1](https://github.com/revanced/revanced-patcher/compare/v1.2.0...v1.2.1) (2022-06-14)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Patcher setting BuildOptions too late ([6a5c873](https://github.com/revanced/revanced-patcher/commit/6a5c8735fb8a5d6f7e9c606734b6684c7fa99e7f))
|
||||||
|
|
||||||
|
# [1.2.0](https://github.com/revanced/revanced-patcher/compare/v1.1.0...v1.2.0) (2022-06-14)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* allow custom framework path to be specified ([d3a580e](https://github.com/revanced/revanced-patcher/commit/d3a580ea19d7c2d5d8c97650b1e6396ea0a7fc25))
|
||||||
|
|
||||||
|
# [1.1.0](https://github.com/revanced/revanced-patcher/compare/v1.0.0...v1.1.0) (2022-06-11)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* resource patcher ([31815ca](https://github.com/revanced/revanced-patcher/commit/31815ca9ea990f16b3600d61fd570c1805be1c82))
|
||||||
|
* update apktool to fork ([566ecef](https://github.com/revanced/revanced-patcher/commit/566ecefa2bd4cde5ebfb2b22dc56cd8bf9f396bd))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* allow custom aapt path to be specified ([8eb4a8f](https://github.com/revanced/revanced-patcher/commit/8eb4a8f87ae7679a272f3224273a37a31d4bb121))
|
||||||
|
|
||||||
|
# 1.0.0 (2022-06-05)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* `compareSignatureToMethod` not matching correctly in case opcodes are null ([cca12aa](https://github.com/revanced/revanced-patcher/commit/cca12aa34a60d766c02e55241df847f7d230d4d7))
|
||||||
|
* `ConcurrentModificationException` while iterating through `proxies` and modifying it ([6cb7cdb](https://github.com/revanced/revanced-patcher/commit/6cb7cdb0b2a2b954adb04033e0f2d3ccb4604545))
|
||||||
|
* `JarPatchBundle` loading non-class files to class loader ([849616d](https://github.com/revanced/revanced-patcher/commit/849616dc2b6e30ec1fa1d8a8f9c1f881fc11676a))
|
||||||
|
* `PackageMetadata` ([7399450](https://github.com/revanced/revanced-patcher/commit/739945013962fd80d2635fff126d84046870f956))
|
||||||
|
* `replaceWith` not replacing classes with used class proxies ([4178a1e](https://github.com/revanced/revanced-patcher/commit/4178a1eedce1436ffeb3ddd6952ce0b6ec87d5a0))
|
||||||
|
* adding existing classes to the patchers cache ([9659a61](https://github.com/revanced/revanced-patcher/commit/9659a61c5c3a84714160b78b32cc337a97c8caa9))
|
||||||
|
* always return PatchResultSuccess on patch success ([996c4ac](https://github.com/revanced/revanced-patcher/commit/996c4acb2061db776430ad8b07bfdb3fe32861f6))
|
||||||
|
* applying no patches throwing error ([5ca5a1c](https://github.com/revanced/revanced-patcher/commit/5ca5a1c29e087ce7e4b6d5e593b775365803151d))
|
||||||
|
* applyPatches not returning successful patches ([f806cb3](https://github.com/revanced/revanced-patcher/commit/f806cb38c571cdd22016396ee1874ee18c91b79f))
|
||||||
|
* avoid ignoring test resources (fixes [#1](https://github.com/revanced/revanced-patcher/issues/1)) ([d5a3c76](https://github.com/revanced/revanced-patcher/commit/d5a3c76389ba902c22ddc8b7ba1a110b7ff852df))
|
||||||
|
* Classes not being written properly because of array shifting ([6e4db11](https://github.com/revanced/revanced-patcher/commit/6e4db110c8fdd16fb0c0ce81f427d84f2a3b6ee0))
|
||||||
|
* current must be calculated after increment ([5f12bab](https://github.com/revanced/revanced-patcher/commit/5f12bab5df97fbe6e2e62c1bf2814a2e682ab4f3))
|
||||||
|
* failing tests temporarily ([fc05fe7](https://github.com/revanced/revanced-patcher/commit/fc05fe79deec2486bb746d33e803ad052e68f8de))
|
||||||
|
* fix classes having multiple instances of fields ([7cc8a7d](https://github.com/revanced/revanced-patcher/commit/7cc8a7dec321774c1d3f2f1a87ac91f952c4fb7e))
|
||||||
|
* fix classes having multiple method instances ([398239d](https://github.com/revanced/revanced-patcher/commit/398239dc10a3ea04e46adb3be176c897876e5587))
|
||||||
|
* Fixed writer & signature resolver, improved tests & speed, minor refactoring ([e6c2501](https://github.com/revanced/revanced-patcher/commit/e6c2501539540301d5b70014de460e5452a09b04))
|
||||||
|
* fuzzy resolver warning params were turned around ([e5bea06](https://github.com/revanced/revanced-patcher/commit/e5bea06353805f004d607124a8ebed138f84d583))
|
||||||
|
* give ClassWriter a ClassReader for symtable ([41749ba](https://github.com/revanced/revanced-patcher/commit/41749ba8290b2dec5dd2ab6e0bc9d714887a1a05))
|
||||||
|
* **gradle:** publish source and javadocs ([c236ebe](https://github.com/revanced/revanced-patcher/commit/c236ebe0789f9c78d610769f0feda2b64fa4a128))
|
||||||
|
* incorrect pattern offset ([f3b5f67](https://github.com/revanced/revanced-patcher/commit/f3b5f67b395167c1b9411b2374f3ef584b57b6cf))
|
||||||
|
* **Io:** fix finding classes by name ([b957501](https://github.com/revanced/revanced-patcher/commit/b957501e709028005c4d6c7857022980205b6861))
|
||||||
|
* **Io:** JAR loading and saving ([#8](https://github.com/revanced/revanced-patcher/issues/8)) ([310a7c4](https://github.com/revanced/revanced-patcher/commit/310a7c446b547d84b02c5da2161958e77ce69f0d))
|
||||||
|
* make `methodMetadata` nullable in `MethodSignatureMetadata` ([4e56652](https://github.com/revanced/revanced-patcher/commit/4e566524299674426fb0344d09db3b0c1cb3d300))
|
||||||
|
* make warnings nullable instead of lateinit ([8f1a629](https://github.com/revanced/revanced-patcher/commit/8f1a629191668e05917dc797e486647e55276d59))
|
||||||
|
* match to correct signature method parameters ([1ee2e4b](https://github.com/revanced/revanced-patcher/commit/1ee2e4ba56097c5e06c93c9ce04cb5543f0e4a67))
|
||||||
|
* **MethodResolver:** fix cd57a8c9a0db7e3ae5ad0bca202e5955930319ab ([cbd8df2](https://github.com/revanced/revanced-patcher/commit/cbd8df2df008ef37c6b43e2a8442c41f24be9358))
|
||||||
|
* **MethodResolver:** strip labels and line numbers so opcode patterns match ([699c730](https://github.com/revanced/revanced-patcher/commit/699c730a7cecf31878827d645e845490a37de4cb))
|
||||||
|
* **MethodResolver:** strip labels nodes so opcode patterns match ([82c5306](https://github.com/revanced/revanced-patcher/commit/82c530650f926dd026d263cfe23a7d67cb27bbf2))
|
||||||
|
* MethodSignature#resolved throwing an exception ([c612676](https://github.com/revanced/revanced-patcher/commit/c612676543282155143471b71a095e26023806ea))
|
||||||
|
* Move proxy package out of cache package ([ce21bd6](https://github.com/revanced/revanced-patcher/commit/ce21bd60f34d78b94d6d85f2c5375bc934ed4091))
|
||||||
|
* null check causing an exception ([338bd9f](https://github.com/revanced/revanced-patcher/commit/338bd9f7394afd84e5e195a7f8155c813812cfb5))
|
||||||
|
* nullable signature members ([#10](https://github.com/revanced/revanced-patcher/issues/10)) ([674461f](https://github.com/revanced/revanced-patcher/commit/674461f08daabbf92cb54e4eadb408226fac47af))
|
||||||
|
* Patch should have access to the Cache ([4dd820f](https://github.com/revanced/revanced-patcher/commit/4dd820ffdf1b98fe41b50f7cb2670b89acfbb99d))
|
||||||
|
* Patcher not writing resolved methods ([fac44a5](https://github.com/revanced/revanced-patcher/commit/fac44a50c39d8c102bd3e7ca4dd1bb86d29f7b57))
|
||||||
|
* qualifying `Element` with wrong package ([024fa86](https://github.com/revanced/revanced-patcher/commit/024fa867e115f984cfa3e395b78f4f43aa81709b))
|
||||||
|
* reaching all constructors not possible ([c459beb](https://github.com/revanced/revanced-patcher/commit/c459beb5f898d797f2f03ed36326bd9cfad03d31))
|
||||||
|
* reformat (trigger release) ([bf48945](https://github.com/revanced/revanced-patcher/commit/bf4894592bf9ee9c6233abc91f538b7b8ef986a0))
|
||||||
|
* remove broken code ([0e72a6e](https://github.com/revanced/revanced-patcher/commit/0e72a6e85ff9a6035510680fc5e33ab0cd14144f))
|
||||||
|
* remove dependency to fork of Apktool ([11abc67](https://github.com/revanced/revanced-patcher/commit/11abc67d9ab7d7b273fd4cd4c53af54008a80585))
|
||||||
|
* remove leftover debug code ([0f30eac](https://github.com/revanced/revanced-patcher/commit/0f30eac32ce66d8b90906c02ef7e7854feeecc33))
|
||||||
|
* return mutable set of classes ([66a9b76](https://github.com/revanced/revanced-patcher/commit/66a9b768457e98fdde0b61f9a8d6aed4c1872027))
|
||||||
|
* returning failure on success ([48c4ea2](https://github.com/revanced/revanced-patcher/commit/48c4ea2f6d9de319383a49ea2d4c6ffb4f687a2b))
|
||||||
|
* Search method map for existing class proxy ([a1e909b](https://github.com/revanced/revanced-patcher/commit/a1e909b16337c538f8f8b475801d8b1804163bfe))
|
||||||
|
* set index for insertAt to 0 by default ([d5b4c99](https://github.com/revanced/revanced-patcher/commit/d5b4c99c00272e3e5afec2fa0a489ba618f2a81a))
|
||||||
|
* set marklimit to Integer.MAX_VALUE ([e6e468f](https://github.com/revanced/revanced-patcher/commit/e6e468fbb5c20b08c8bd59bafc794acea907e4b4))
|
||||||
|
* string signature in `SignatureResolver` ([e5ae970](https://github.com/revanced/revanced-patcher/commit/e5ae9700096924e63b15a08079dce40ae07202d8))
|
||||||
|
* Suppress unused for addFiles ([3d6a1d3](https://github.com/revanced/revanced-patcher/commit/3d6a1d38f339ce2c5d82b7ac46c208c6702d6d44))
|
||||||
|
* throwing in case the opcode patterns do not match ([3144ec8](https://github.com/revanced/revanced-patcher/commit/3144ec872ac8651b8c0a9311ae508d5c3cc734ce))
|
||||||
|
* use Array instead of Iterable for methodParameters ([dfac8f0](https://github.com/revanced/revanced-patcher/commit/dfac8f03a362fd273527f552d9eae121505fd4e0))
|
||||||
|
* using old instance of `Androlib` when saving ([a4d8be2](https://github.com/revanced/revanced-patcher/commit/a4d8be20fcd444b08ec9c43f9f7029f8bacbbc41))
|
||||||
|
* workflow on dev branch ([428f7f4](https://github.com/revanced/revanced-patcher/commit/428f7f4decb00d28c9bf137ef4cd1d5fd4a0821e))
|
||||||
|
* write all classes ([f068fc8](https://github.com/revanced/revanced-patcher/commit/f068fc87ff8e204826639318af39e48e683254da))
|
||||||
|
|
||||||
|
|
||||||
|
### Code Refactoring
|
||||||
|
|
||||||
|
* bump multidexlib2 to 2.5.2.r2 ([a6c6b49](https://github.com/revanced/revanced-patcher/commit/a6c6b4979af42936cb26608541a4f7a66393b3f0))
|
||||||
|
* Change all references from Array to Iterable ([72f3cad](https://github.com/revanced/revanced-patcher/commit/72f3cad3f98001b0109b07373ed9cc57a9001cfa))
|
||||||
|
* convert Patch to abstract class ([cb9b1b9](https://github.com/revanced/revanced-patcher/commit/cb9b1b9416c699c68d0fca228d4f8ca6fb634cb5))
|
||||||
|
* Optimize Signature class ([#11](https://github.com/revanced/revanced-patcher/issues/11)) ([7faa001](https://github.com/revanced/revanced-patcher/commit/7faa001406c1f28dc2182cf6d1ab19504f4e3eb9))
|
||||||
|
* Rename `net.revanced` to `app.revanced` ([7087230](https://github.com/revanced/revanced-patcher/commit/70872307e33282b37dd5fb315b56022ab73bf582))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* `Dependencies` annotation ([893d4c6](https://github.com/revanced/revanced-patcher/commit/893d4c699bad4c70002fc691c261447d01948b5c))
|
||||||
|
* `PatchLoader` ([ec9fd15](https://github.com/revanced/revanced-patcher/commit/ec9fd15f9b9b9968be7fb5cb384eb8ee2a0c9ba3))
|
||||||
|
* Add `findParentMethod` utility method ([#4](https://github.com/revanced/revanced-patcher/issues/4)) ([bbb2c54](https://github.com/revanced/revanced-patcher/commit/bbb2c547aae8dd774a1a883de24fe45da463fa35))
|
||||||
|
* add `MethodWalker` ([7755bbc](https://github.com/revanced/revanced-patcher/commit/7755bbc645773e49053fb9ad2b6fd18a7f488659))
|
||||||
|
* add `p` naming scheme to smali compiler ([79909cf](https://github.com/revanced/revanced-patcher/commit/79909cf260c0578e88ad22d63397957dbaa91702))
|
||||||
|
* add extensions for cloning methods ([01bfbd6](https://github.com/revanced/revanced-patcher/commit/01bfbd656ee06cb2cab951c43d7f76a465a40830))
|
||||||
|
* add findClass method with className ([4087f49](https://github.com/revanced/revanced-patcher/commit/4087f498638ee88ba3eaca792039fe481f404732))
|
||||||
|
* Add first tests ([544bcf7](https://github.com/revanced/revanced-patcher/commit/544bcf76bd8a8c790c2f799606ad8c9ac7d2aa82))
|
||||||
|
* add fuzzy resolver ([7a56dca](https://github.com/revanced/revanced-patcher/commit/7a56dca004cd793121a59ea854c77f4c1a01bd6f))
|
||||||
|
* add immutableMethod ([c63b20f](https://github.com/revanced/revanced-patcher/commit/c63b20fa65aba8bb060a4a7a652747cba7198c2b))
|
||||||
|
* add inline smali compiler ([bfe4e3e](https://github.com/revanced/revanced-patcher/commit/bfe4e3e298ac963936ca9621e12aefbe56260826))
|
||||||
|
* add missing test for fields ([6b8b057](https://github.com/revanced/revanced-patcher/commit/6b8b0573d479e227b45dc36a6abac622c3ccebdd))
|
||||||
|
* add or extension for AccessFlags ([00c85b5](https://github.com/revanced/revanced-patcher/commit/00c85b5d750ccc8de69ad4101220b19eeaf99bcb))
|
||||||
|
* Add patch metadata ([642e903](https://github.com/revanced/revanced-patcher/commit/642e9031eb3727ebdca22c75b7c5c602a8775da0)), closes [ReVancedTeam/revanced-patches#1](https://github.com/ReVancedTeam/revanced-patches/issues/1)
|
||||||
|
* add SafeClassWriter ([6626014](https://github.com/revanced/revanced-patcher/commit/6626014ef3dde2f98a53f75d71eeb0de85189bf3))
|
||||||
|
* Add warnings for Fuzzy resolver ([715a2ad](https://github.com/revanced/revanced-patcher/commit/715a2ad025d127b5a8225ce50202a859f53c7f50))
|
||||||
|
* allow classes to be overwritten in addFiles and resolve signatures when applyPatches is called ([1db735b](https://github.com/revanced/revanced-patcher/commit/1db735b1e2b570bdb1ddce0b9cd724c580113a84))
|
||||||
|
* Allow unknown opcodes using `null` ([0e5f4ba](https://github.com/revanced/revanced-patcher/commit/0e5f4ba2d55288415c4d1be70ab6a8ab8c1c0d10))
|
||||||
|
* Finish first patcher test ([0d8d19e](https://github.com/revanced/revanced-patcher/commit/0d8d19e708a47315e28e7493618568ea40f1e062))
|
||||||
|
* Improve `SignatureResolver` ([139a23b](https://github.com/revanced/revanced-patcher/commit/139a23b7500a2d2577df47caf3fd0c5ec891a8d8))
|
||||||
|
* migrate to `DexPatchBundle` and `JarPatchBundle` ([8615798](https://github.com/revanced/revanced-patcher/commit/8615798711185b30ce622d9d09faba21f3a92f97))
|
||||||
|
* migrate to dexlib ([3651981](https://github.com/revanced/revanced-patcher/commit/36519811610192e299834e9d00627a94faad56a9))
|
||||||
|
* Minor refactor and return proxy, if class has been proxied already ([4b26305](https://github.com/revanced/revanced-patcher/commit/4b26305bd57ba9e3eb3e34218ffe10d6c5a2f598))
|
||||||
|
* optional `forStaticMethod` parameter for `InlineSmaliCompiler.compileMethodInstructions` ([41e8860](https://github.com/revanced/revanced-patcher/commit/41e88605c33d1f0d9e7f5466cac03a3b339afb82))
|
||||||
|
* patch dependencies annotation and `PatcherOptions` ([6c65952](https://github.com/revanced/revanced-patcher/commit/6c65952d80a795a3ef4a37877123e9375025d3ae))
|
||||||
|
* properly manage `ClassProxy` & add `ProxyBackedClassList` ([6cb1fdf](https://github.com/revanced/revanced-patcher/commit/6cb1fdf6171e1ab75b7ee28163965eacc00cc5a0))
|
||||||
|
* remaining mutable `EncodedValue` classes ([3f97cc8](https://github.com/revanced/revanced-patcher/commit/3f97cc8e1fa10546d7069e01e5e66a537b0d6f7e))
|
||||||
|
* string signature ([#22](https://github.com/revanced/revanced-patcher/issues/22)) ([612515a](https://github.com/revanced/revanced-patcher/commit/612515acf8539febf952f258d30aa3d4b631e3b7))
|
||||||
|
* use annotations instead of metadata objects ([d20f7fd](https://github.com/revanced/revanced-patcher/commit/d20f7fd6e1ede6ec7baccb1500ab3fc66d78df73))
|
||||||
|
* utility functions to get metadata of patch & sigs ([54511a4](https://github.com/revanced/revanced-patcher/commit/54511a4fc6417d7fe0c868d441e7d6b0ec9e218d))
|
||||||
|
|
||||||
|
|
||||||
|
### Performance Improvements
|
||||||
|
|
||||||
|
* check type instead of class ([c7ef264](https://github.com/revanced/revanced-patcher/commit/c7ef2644d83e1d8e84decb0631a6549d394180fc))
|
||||||
|
* decode manifest only when not using resource patcher ([4f60bea](https://github.com/revanced/revanced-patcher/commit/4f60bea81e0bbe85dc6c3150238980292a1e52ab))
|
||||||
|
* depend on `androlib` instead of `ApkDecoder` ([cc9416d](https://github.com/revanced/revanced-patcher/commit/cc9416dd11b66140c2882021cbe5088659d85371))
|
||||||
|
* do not resolve empty signatures list ([b1eebc9](https://github.com/revanced/revanced-patcher/commit/b1eebc99a71269df33c37f35c1f56ea20a9d6bc0))
|
||||||
|
* lazy-ify all mutable clones ([d18a3b6](https://github.com/revanced/revanced-patcher/commit/d18a3b6a28cae4fcb1c4986903208298ee50b083))
|
||||||
|
* optimize indexOf call away ([9991f39](https://github.com/revanced/revanced-patcher/commit/9991f39c9a4fa22a221aab0bbf9e08ca7f967fa9))
|
||||||
|
* use Set instead of List since there are no dupes ([e65ebd2](https://github.com/revanced/revanced-patcher/commit/e65ebd27c250b1735acf73af0f6b03274b0137f6))
|
||||||
|
* use String List and compare instead of any lambda ([5bd416b](https://github.com/revanced/revanced-patcher/commit/5bd416b409290906a6378344f70391e8692ae27f))
|
||||||
|
|
||||||
|
|
||||||
|
### Reverts
|
||||||
|
|
||||||
|
* AccessFlag extensions not working with IDE ([0bfb92a](https://github.com/revanced/revanced-patcher/commit/0bfb92a0cbd72df5ba513264efb583e201cfcf82))
|
||||||
|
* previous commits check for dupes in dexFile, not cache ([e810197](https://github.com/revanced/revanced-patcher/commit/e810197e2aa64534f2e8637165d884cbefbce8ae))
|
||||||
|
|
||||||
|
|
||||||
|
### BREAKING CHANGES
|
||||||
|
|
||||||
|
* arrayOf has to be changed to listOf.
|
||||||
|
* Method signature of Patcher#save() was changed to comply with the changes of multidexlib2.
|
||||||
|
* Removed usage of ASM library
|
||||||
|
* Array<Int> was changed to IntArray. This breaks existing patches.
|
||||||
|
* Package name was changed from "net.revanced" to "app.revanced"
|
||||||
|
* Method signature of execute() was changed to include the cache, this will break existing implementations of the Patch class.
|
||||||
|
* Patch class is now an abstract class. You must implement it. You can use anonymous implements, like done in the tests.
|
||||||
|
|
||||||
|
# [1.0.0-dev.18](https://github.com/revanced/revanced-patcher/compare/v1.0.0-dev.17...v1.0.0-dev.18) (2022-06-04)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* `Dependencies` annotation ([83d608a](https://github.com/revanced/revanced-patcher/commit/83d608ac06a7d5ceb31b6e0022b501d99edb63a3))
|
||||||
|
* optional `forStaticMethod` parameter for `InlineSmaliCompiler.compileMethodInstructions` ([28b9847](https://github.com/revanced/revanced-patcher/commit/28b98478e4e8e8f238e82f7fa2307aeb1547955d))
|
||||||
|
|
||||||
|
# [1.0.0-dev.17](https://github.com/revanced/revanced-patcher/compare/v1.0.0-dev.16...v1.0.0-dev.17) (2022-05-31)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* patch dependencies annotation and `PatcherOptions` ([8442991](https://github.com/revanced/revanced-patcher/commit/84429912900872405b44804943357dda8430a550))
|
||||||
|
|
||||||
|
# [1.0.0-dev.16](https://github.com/revanced/revanced-patcher/compare/v1.0.0-dev.15...v1.0.0-dev.16) (2022-05-27)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* `JarPatchBundle` loading non-class files to class loader ([3f0c740](https://github.com/revanced/revanced-patcher/commit/3f0c740200dd91a060426638c2f8f516938b4c53))
|
||||||
|
* remove dependency to fork of Apktool ([0fa529f](https://github.com/revanced/revanced-patcher/commit/0fa529fcdf9a7b5ea9a361b9f9f32f3f3fce009f))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* migrate to `DexPatchBundle` and `JarPatchBundle` ([7573db2](https://github.com/revanced/revanced-patcher/commit/7573db25757de89824af4f3aea167e500120eabb))
|
||||||
|
|
||||||
|
# [1.0.0-dev.15](https://github.com/revanced/revanced-patcher/compare/v1.0.0-dev.14...v1.0.0-dev.15) (2022-05-25)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* utility functions to get metadata of patch & sigs ([72f16b7](https://github.com/revanced/revanced-patcher/commit/72f16b778587c28d8f8e91da502f197e7dc35d6d))
|
||||||
|
|
||||||
|
# [1.0.0-dev.14](https://github.com/revanced/revanced-patcher/compare/v1.0.0-dev.13...v1.0.0-dev.14) (2022-05-24)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* reformat (trigger release) ([45a167e](https://github.com/revanced/revanced-patcher/commit/45a167e7856da0306f796953775c7b7543d9bec0))
|
||||||
|
|
||||||
|
# [1.0.0-dev.13](https://github.com/revanced/revanced-patcher/compare/v1.0.0-dev.12...v1.0.0-dev.13) (2022-05-24)
|
||||||
|
|
||||||
|
|
||||||
|
### Performance Improvements
|
||||||
|
|
||||||
|
* decode manifest only when not using resource patcher ([40b1fa4](https://github.com/revanced/revanced-patcher/commit/40b1fa43e1704ace29d3e349df2f4a8ea828c5c2))
|
||||||
|
|
||||||
|
# [1.0.0-dev.12](https://github.com/revanced/revanced-patcher/compare/v1.0.0-dev.11...v1.0.0-dev.12) (2022-05-22)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* using old instance of `Androlib` when saving ([5630e49](https://github.com/revanced/revanced-patcher/commit/5630e4966310311cdfd53e2ba128255047626adc))
|
||||||
|
|
||||||
# [1.0.0-dev.11](https://github.com/revanced/revanced-patcher/compare/v1.0.0-dev.10...v1.0.0-dev.11) (2022-05-22)
|
# [1.0.0-dev.11](https://github.com/revanced/revanced-patcher/compare/v1.0.0-dev.10...v1.0.0-dev.11) (2022-05-22)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,22 +1,21 @@
|
|||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "1.6.20"
|
kotlin("jvm") version "1.7.0"
|
||||||
java
|
java
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "app.revanced"
|
group = "app.revanced"
|
||||||
|
|
||||||
|
val githubUsername: String = project.findProperty("gpr.user") as? String ?: System.getenv("GITHUB_ACTOR")
|
||||||
|
val githubPassword: String = project.findProperty("gpr.key") as? String ?: System.getenv("GITHUB_TOKEN")
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven {
|
maven {
|
||||||
url = uri("https://maven.pkg.github.com/revanced/multidexlib2")
|
url = uri("https://maven.pkg.github.com/revanced/multidexlib2")
|
||||||
credentials {
|
credentials {
|
||||||
// DO NOT set these variables in the project's gradle.properties.
|
username = githubUsername
|
||||||
// Instead, you should set them in:
|
password = githubPassword
|
||||||
// Windows: %homepath%\.gradle\gradle.properties
|
|
||||||
// Linux: ~/.gradle/gradle.properties
|
|
||||||
username = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_ACTOR") // DO NOT CHANGE!
|
|
||||||
password = project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_TOKEN") // DO NOT CHANGE!
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -24,13 +23,13 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation(kotlin("stdlib"))
|
implementation(kotlin("stdlib"))
|
||||||
|
|
||||||
api("org.apktool:apktool-lib:2.6.1")
|
api("xpp3:xpp3:1.1.4c")
|
||||||
|
api("org.apktool:apktool-lib:2.6.2-SNAPSHOT")
|
||||||
api("app.revanced:multidexlib2:2.5.2.r2")
|
api("app.revanced:multidexlib2:2.5.2.r2")
|
||||||
api("org.smali:smali:2.5.2")
|
api("org.smali:smali:2.5.2")
|
||||||
|
|
||||||
testImplementation(kotlin("test"))
|
testImplementation(kotlin("test"))
|
||||||
implementation(kotlin("reflect"))
|
implementation(kotlin("reflect"))}
|
||||||
}
|
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
test {
|
test {
|
||||||
@@ -46,11 +45,8 @@ java {
|
|||||||
withJavadocJar()
|
withJavadocJar()
|
||||||
}
|
}
|
||||||
|
|
||||||
val isGitHubCI = System.getenv("GITHUB_ACTOR") != null
|
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
repositories {
|
repositories {
|
||||||
if (isGitHubCI) {
|
|
||||||
maven {
|
maven {
|
||||||
name = "GitHubPackages"
|
name = "GitHubPackages"
|
||||||
url = uri("https://maven.pkg.github.com/revanced/revanced-patcher")
|
url = uri("https://maven.pkg.github.com/revanced/revanced-patcher")
|
||||||
@@ -59,9 +55,6 @@ publishing {
|
|||||||
password = System.getenv("GITHUB_TOKEN")
|
password = System.getenv("GITHUB_TOKEN")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
mavenLocal()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
publications {
|
publications {
|
||||||
register<MavenPublication>("gpr") {
|
register<MavenPublication>("gpr") {
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
kotlin.code.style = official
|
kotlin.code.style = official
|
||||||
version = 1.0.0-dev.11
|
version = 1.2.2
|
||||||
|
|||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
269
gradlew
vendored
269
gradlew
vendored
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env sh
|
#!/bin/sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright 2015 the original author or authors.
|
# Copyright <20> 2015-2021 the original authors.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -17,67 +17,101 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
##
|
#
|
||||||
## Gradle start up script for UN*X
|
# Gradle start up script for POSIX generated by Gradle.
|
||||||
##
|
#
|
||||||
|
# Important for running:
|
||||||
|
#
|
||||||
|
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||||
|
# noncompliant, but you have some other compliant shell such as ksh or
|
||||||
|
# bash, then to run this script, type that shell name before the whole
|
||||||
|
# command line, like:
|
||||||
|
#
|
||||||
|
# ksh Gradle
|
||||||
|
#
|
||||||
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
|
# requires all of these POSIX shell features:
|
||||||
|
# * functions;
|
||||||
|
# * expansions <20>$var<61>, <20>${var}<7D>, <20>${var:-default}<7D>, <20>${var+SET}<7D>,
|
||||||
|
# <20>${var#prefix}<7D>, <20>${var%suffix}<7D>, and <20>$( cmd )<29>;
|
||||||
|
# * compound commands having a testable exit status, especially <20>case<73>;
|
||||||
|
# * various built-in commands including <20>command<6E>, <20>set<65>, and <20>ulimit<69>.
|
||||||
|
#
|
||||||
|
# Important for patching:
|
||||||
|
#
|
||||||
|
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||||
|
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||||
|
#
|
||||||
|
# The "traditional" practice of packing multiple parameters into a
|
||||||
|
# space-separated string is a well documented source of bugs and security
|
||||||
|
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||||
|
# options in "$@", and eventually passing that to Java.
|
||||||
|
#
|
||||||
|
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||||
|
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||||
|
# see the in-line comments for details.
|
||||||
|
#
|
||||||
|
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||||
|
# Darwin, MinGW, and NonStop.
|
||||||
|
#
|
||||||
|
# (3) This script is generated from the Groovy template
|
||||||
|
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
|
# within the Gradle project.
|
||||||
|
#
|
||||||
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
# Attempt to set APP_HOME
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
# Resolve links: $0 may be a link
|
# Resolve links: $0 may be a link
|
||||||
PRG="$0"
|
app_path=$0
|
||||||
# Need this for relative symlinks.
|
|
||||||
while [ -h "$PRG" ] ; do
|
# Need this for daisy-chained symlinks.
|
||||||
ls=`ls -ld "$PRG"`
|
while
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
[ -h "$app_path" ]
|
||||||
PRG="$link"
|
do
|
||||||
else
|
ls=$( ls -ld "$app_path" )
|
||||||
PRG=`dirname "$PRG"`"/$link"
|
link=${ls#*' -> '}
|
||||||
fi
|
case $link in #(
|
||||||
|
/*) app_path=$link ;; #(
|
||||||
|
*) app_path=$APP_HOME$link ;;
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
SAVED="`pwd`"
|
|
||||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||||
APP_HOME="`pwd -P`"
|
|
||||||
cd "$SAVED" >/dev/null
|
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
APP_NAME="Gradle"
|
||||||
APP_BASE_NAME=`basename "$0"`
|
APP_BASE_NAME=${0##*/}
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD="maximum"
|
MAX_FD=maximum
|
||||||
|
|
||||||
warn () {
|
warn () {
|
||||||
echo "$*"
|
echo "$*"
|
||||||
}
|
} >&2
|
||||||
|
|
||||||
die () {
|
die () {
|
||||||
echo
|
echo
|
||||||
echo "$*"
|
echo "$*"
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
}
|
} >&2
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
# OS specific support (must be 'true' or 'false').
|
||||||
cygwin=false
|
cygwin=false
|
||||||
msys=false
|
msys=false
|
||||||
darwin=false
|
darwin=false
|
||||||
nonstop=false
|
nonstop=false
|
||||||
case "`uname`" in
|
case "$( uname )" in #(
|
||||||
CYGWIN* )
|
CYGWIN* ) cygwin=true ;; #(
|
||||||
cygwin=true
|
Darwin* ) darwin=true ;; #(
|
||||||
;;
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
Darwin* )
|
NONSTOP* ) nonstop=true ;;
|
||||||
darwin=true
|
|
||||||
;;
|
|
||||||
MSYS* | MINGW* )
|
|
||||||
msys=true
|
|
||||||
;;
|
|
||||||
NONSTOP* )
|
|
||||||
nonstop=true
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
@@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
|||||||
if [ -n "$JAVA_HOME" ] ; then
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||||
else
|
else
|
||||||
JAVACMD="$JAVA_HOME/bin/java"
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
fi
|
fi
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
@@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
|
|||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD="java"
|
JAVACMD=java
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
@@ -106,80 +140,95 @@ location of your Java installation."
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
MAX_FD_LIMIT=`ulimit -H -n`
|
case $MAX_FD in #(
|
||||||
if [ $? -eq 0 ] ; then
|
max*)
|
||||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
MAX_FD="$MAX_FD_LIMIT"
|
warn "Could not query maximum file descriptor limit"
|
||||||
fi
|
esac
|
||||||
ulimit -n $MAX_FD
|
case $MAX_FD in #(
|
||||||
if [ $? -ne 0 ] ; then
|
'' | soft) :;; #(
|
||||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
*)
|
||||||
fi
|
ulimit -n "$MAX_FD" ||
|
||||||
else
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For Darwin, add options to specify how the application appears in the dock
|
|
||||||
if $darwin; then
|
|
||||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
|
||||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
|
||||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
|
||||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
|
||||||
|
|
||||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
|
||||||
|
|
||||||
# We build the pattern for arguments to be converted via cygpath
|
|
||||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
|
||||||
SEP=""
|
|
||||||
for dir in $ROOTDIRSRAW ; do
|
|
||||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
|
||||||
SEP="|"
|
|
||||||
done
|
|
||||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
|
||||||
# Add a user-defined pattern to the cygpath arguments
|
|
||||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
|
||||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
|
||||||
fi
|
|
||||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
|
||||||
i=0
|
|
||||||
for arg in "$@" ; do
|
|
||||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
|
||||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
|
||||||
|
|
||||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
|
||||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
|
||||||
else
|
|
||||||
eval `echo args$i`="\"$arg\""
|
|
||||||
fi
|
|
||||||
i=`expr $i + 1`
|
|
||||||
done
|
|
||||||
case $i in
|
|
||||||
0) set -- ;;
|
|
||||||
1) set -- "$args0" ;;
|
|
||||||
2) set -- "$args0" "$args1" ;;
|
|
||||||
3) set -- "$args0" "$args1" "$args2" ;;
|
|
||||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
|
||||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
|
||||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
|
||||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
|
||||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
|
||||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Escape application args
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
save () {
|
# * args from the command line
|
||||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
# * the main class name
|
||||||
echo " "
|
# * -classpath
|
||||||
}
|
# * -D...appname settings
|
||||||
APP_ARGS=`save "$@"`
|
# * --module-path (only if needed)
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||||
|
|
||||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
if "$cygwin" || "$msys" ; then
|
||||||
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
|
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||||
|
|
||||||
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
for arg do
|
||||||
|
if
|
||||||
|
case $arg in #(
|
||||||
|
-*) false ;; # don't mess with options #(
|
||||||
|
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||||
|
[ -e "$t" ] ;; #(
|
||||||
|
*) false ;;
|
||||||
|
esac
|
||||||
|
then
|
||||||
|
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||||
|
fi
|
||||||
|
# Roll the args list around exactly as many times as the number of
|
||||||
|
# args, so each arg winds up back in the position where it started, but
|
||||||
|
# possibly modified.
|
||||||
|
#
|
||||||
|
# NB: a `for` loop captures its iteration list before it begins, so
|
||||||
|
# changing the positional parameters here affects neither the number of
|
||||||
|
# iterations, nor the values presented in `arg`.
|
||||||
|
shift # remove old arg
|
||||||
|
set -- "$@" "$arg" # push replacement arg
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Collect all arguments for the java command;
|
||||||
|
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||||
|
# shell script including quotes and variable substitutions, so put them in
|
||||||
|
# double quotes to make sure that they get re-expanded; and
|
||||||
|
# * put everything else in single quotes, so that it's not re-expanded.
|
||||||
|
|
||||||
|
set -- \
|
||||||
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
-classpath "$CLASSPATH" \
|
||||||
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# Use "xargs" to parse quoted args.
|
||||||
|
#
|
||||||
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
#
|
||||||
|
# In Bash we could simply go:
|
||||||
|
#
|
||||||
|
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||||
|
# set -- "${ARGS[@]}" "$@"
|
||||||
|
#
|
||||||
|
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||||
|
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||||
|
# character that might be a shell metacharacter, then use eval to reverse
|
||||||
|
# that process (while maintaining the separation between arguments), and wrap
|
||||||
|
# the whole thing up as a single "set" statement.
|
||||||
|
#
|
||||||
|
# This will of course break if any of these variables contains a newline or
|
||||||
|
# an unmatched quote.
|
||||||
|
#
|
||||||
|
|
||||||
|
eval "set -- $(
|
||||||
|
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||||
|
xargs -n1 |
|
||||||
|
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||||
|
tr '\n' ' '
|
||||||
|
)" '"$@"'
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
exec "$JAVACMD" "$@"
|
||||||
|
|||||||
@@ -1,19 +1,29 @@
|
|||||||
package app.revanced.patcher
|
package app.revanced.patcher
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.data.PackageMetadata
|
||||||
import app.revanced.patcher.data.PatcherData
|
import app.revanced.patcher.data.PatcherData
|
||||||
import app.revanced.patcher.data.base.Data
|
import app.revanced.patcher.data.base.Data
|
||||||
import app.revanced.patcher.data.implementation.findIndexed
|
import app.revanced.patcher.data.implementation.findIndexed
|
||||||
import app.revanced.patcher.extensions.findAnnotationRecursively
|
import app.revanced.patcher.extensions.PatchExtensions.dependencies
|
||||||
|
import app.revanced.patcher.extensions.PatchExtensions.patchName
|
||||||
|
import app.revanced.patcher.extensions.nullOutputStream
|
||||||
import app.revanced.patcher.patch.base.Patch
|
import app.revanced.patcher.patch.base.Patch
|
||||||
import app.revanced.patcher.patch.implementation.BytecodePatch
|
import app.revanced.patcher.patch.implementation.BytecodePatch
|
||||||
import app.revanced.patcher.patch.implementation.ResourcePatch
|
import app.revanced.patcher.patch.implementation.ResourcePatch
|
||||||
|
import app.revanced.patcher.patch.implementation.misc.PatchResult
|
||||||
|
import app.revanced.patcher.patch.implementation.misc.PatchResultError
|
||||||
import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess
|
import app.revanced.patcher.patch.implementation.misc.PatchResultSuccess
|
||||||
import app.revanced.patcher.signature.implementation.method.MethodSignature
|
|
||||||
import app.revanced.patcher.signature.implementation.method.resolver.MethodSignatureResolver
|
import app.revanced.patcher.signature.implementation.method.resolver.MethodSignatureResolver
|
||||||
import app.revanced.patcher.util.ListBackedSet
|
import app.revanced.patcher.util.ListBackedSet
|
||||||
import brut.androlib.Androlib
|
import brut.androlib.Androlib
|
||||||
import brut.androlib.meta.UsesFramework
|
import brut.androlib.meta.UsesFramework
|
||||||
|
import brut.androlib.options.BuildOptions
|
||||||
|
import brut.androlib.res.AndrolibResources
|
||||||
|
import brut.androlib.res.data.ResPackage
|
||||||
|
import brut.androlib.res.decoder.AXmlResourceParser
|
||||||
|
import brut.androlib.res.decoder.ResAttrDecoder
|
||||||
|
import brut.androlib.res.decoder.XmlPullStreamDecoder
|
||||||
|
import brut.androlib.res.xml.ResXmlPatcher
|
||||||
import brut.directory.ExtFile
|
import brut.directory.ExtFile
|
||||||
import lanchon.multidexlib2.BasicDexFileNamer
|
import lanchon.multidexlib2.BasicDexFileNamer
|
||||||
import lanchon.multidexlib2.DexIO
|
import lanchon.multidexlib2.DexIO
|
||||||
@@ -23,57 +33,75 @@ import org.jf.dexlib2.iface.ClassDef
|
|||||||
import org.jf.dexlib2.iface.DexFile
|
import org.jf.dexlib2.iface.DexFile
|
||||||
import org.jf.dexlib2.writer.io.MemoryDataStore
|
import org.jf.dexlib2.writer.io.MemoryDataStore
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.nio.file.Files
|
||||||
|
|
||||||
val NAMER = BasicDexFileNamer()
|
val NAMER = BasicDexFileNamer()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ReVanced Patcher.
|
* The ReVanced Patcher.
|
||||||
* @param inputFile The input file (usually an apk file).
|
* @param options The options for the patcher.
|
||||||
* @param resourceCacheDirectory Directory to cache resources.
|
|
||||||
* @param patchResources Weather to use the resource patcher. Resources will still need to be decoded.
|
|
||||||
*/
|
*/
|
||||||
class Patcher(
|
class Patcher(private val options: PatcherOptions) {
|
||||||
inputFile: File,
|
val data: PatcherData
|
||||||
// TODO: maybe a file system in memory is better. Could cause high memory usage.
|
|
||||||
private val resourceCacheDirectory: String,
|
|
||||||
private val patchResources: Boolean = false
|
|
||||||
) {
|
|
||||||
val packageVersion: String
|
|
||||||
val packageName: String
|
|
||||||
|
|
||||||
private val usesFramework: UsesFramework
|
|
||||||
private val patcherData: PatcherData
|
|
||||||
private val opcodes: Opcodes
|
private val opcodes: Opcodes
|
||||||
private var signaturesResolved = false
|
|
||||||
private val androlib = Androlib()
|
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val extFileInput = ExtFile(inputFile)
|
val extInputFile = ExtFile(options.inputFile)
|
||||||
val resourceTable = androlib.getResTable(extFileInput, true)
|
val outDir = File(options.resourceCacheDirectory)
|
||||||
val outDir = File(resourceCacheDirectory)
|
|
||||||
|
|
||||||
if (outDir.exists()) outDir.deleteRecursively()
|
if (outDir.exists()) outDir.deleteRecursively()
|
||||||
outDir.mkdir()
|
outDir.mkdirs()
|
||||||
|
|
||||||
// 1. decode resources to cache directory
|
val androlib = Androlib(BuildOptions().also { it.setBuildOptions(options) })
|
||||||
androlib.decodeManifestWithResources(extFileInput, outDir, resourceTable)
|
val resourceTable = androlib.getResTable(extInputFile, true)
|
||||||
androlib.decodeResourcesFull(extFileInput, outDir, resourceTable)
|
|
||||||
|
|
||||||
// 2. read framework ids from the resource table
|
val packageMetadata = PackageMetadata()
|
||||||
usesFramework = UsesFramework()
|
|
||||||
usesFramework.ids = resourceTable.listFramePackages().map { it.id }.sorted()
|
|
||||||
|
|
||||||
// 3. read package info
|
if (options.patchResources) {
|
||||||
packageName = resourceTable.packageOriginal
|
// decode resources to cache directory
|
||||||
packageVersion = resourceTable.versionInfo.versionName
|
androlib.decodeManifestWithResources(extInputFile, outDir, resourceTable)
|
||||||
|
androlib.decodeResourcesFull(extInputFile, outDir, resourceTable)
|
||||||
|
|
||||||
|
// read additional metadata from the resource table
|
||||||
|
packageMetadata.metaInfo.usesFramework = UsesFramework().also { framework ->
|
||||||
|
framework.ids = resourceTable.listFramePackages().map { it.id }.sorted()
|
||||||
|
}
|
||||||
|
|
||||||
|
packageMetadata.metaInfo.doNotCompress = buildList {
|
||||||
|
androlib.recordUncompressedFiles(extInputFile, this)
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// create decoder for the resource table
|
||||||
|
val decoder = ResAttrDecoder()
|
||||||
|
decoder.currentPackage = ResPackage(resourceTable, 0, null)
|
||||||
|
|
||||||
|
// create xml parser with the decoder
|
||||||
|
val axmlParser = AXmlResourceParser()
|
||||||
|
axmlParser.attrDecoder = decoder
|
||||||
|
|
||||||
|
// parse package information with the decoder and parser which will set required values in the resource table
|
||||||
|
// instead of decodeManifest another more low level solution can be created to make it faster/better
|
||||||
|
XmlPullStreamDecoder(
|
||||||
|
axmlParser, AndrolibResources().resXmlSerializer
|
||||||
|
).decodeManifest(
|
||||||
|
extInputFile.directory.getFileInput("AndroidManifest.xml"), nullOutputStream
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
packageMetadata.packageName = resourceTable.currentResPackage.name
|
||||||
|
packageMetadata.packageVersion = resourceTable.versionInfo.versionName
|
||||||
|
packageMetadata.metaInfo.versionInfo = resourceTable.versionInfo
|
||||||
|
packageMetadata.metaInfo.sdkInfo = resourceTable.sdkInfo
|
||||||
|
|
||||||
// read dex files
|
// read dex files
|
||||||
val dexFile = MultiDexIO.readDexFile(true, inputFile, NAMER, null, null)
|
val dexFile = MultiDexIO.readDexFile(true, options.inputFile, NAMER, null, null)
|
||||||
|
// get the opcodes
|
||||||
opcodes = dexFile.opcodes
|
opcodes = dexFile.opcodes
|
||||||
|
|
||||||
// save to patcher data
|
// finally create patcher data
|
||||||
patcherData = PatcherData(dexFile.classes.toMutableList(), resourceCacheDirectory)
|
data = PatcherData(
|
||||||
|
dexFile.classes.toMutableList(), options.resourceCacheDirectory, packageMetadata
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -83,25 +111,22 @@ class Patcher(
|
|||||||
* @param throwOnDuplicates If this is set to true, the patcher will throw an exception if a duplicate class has been found.
|
* @param throwOnDuplicates If this is set to true, the patcher will throw an exception if a duplicate class has been found.
|
||||||
*/
|
*/
|
||||||
fun addFiles(
|
fun addFiles(
|
||||||
files: Iterable<File>,
|
files: List<File>, allowedOverwrites: Iterable<String> = emptyList(), throwOnDuplicates: Boolean = false
|
||||||
allowedOverwrites: Iterable<String> = emptyList(),
|
|
||||||
throwOnDuplicates: Boolean = false
|
|
||||||
) {
|
) {
|
||||||
for (file in files) {
|
for (file in files) {
|
||||||
val dexFile = MultiDexIO.readDexFile(true, file, NAMER, null, null)
|
for (classDef in MultiDexIO.readDexFile(true, file, NAMER, null, null).classes) {
|
||||||
for (classDef in dexFile.classes) {
|
val e = data.bytecodeData.classes.internalClasses.findIndexed { it.type == classDef.type }
|
||||||
val e = patcherData.bytecodeData.classes.internalClasses.findIndexed { it.type == classDef.type }
|
|
||||||
if (e != null) {
|
if (e != null) {
|
||||||
if (throwOnDuplicates) {
|
if (throwOnDuplicates) {
|
||||||
throw Exception("Class ${classDef.type} has already been added to the patcher.")
|
throw Exception("Class ${classDef.type} has already been added to the patcher.")
|
||||||
}
|
}
|
||||||
val (_, idx) = e
|
val (_, idx) = e
|
||||||
if (allowedOverwrites.contains(classDef.type)) {
|
if (allowedOverwrites.contains(classDef.type)) {
|
||||||
patcherData.bytecodeData.classes.internalClasses[idx] = classDef
|
data.bytecodeData.classes.internalClasses[idx] = classDef
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
patcherData.bytecodeData.classes.internalClasses.add(classDef)
|
data.bytecodeData.classes.internalClasses.add(classDef)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -109,11 +134,58 @@ class Patcher(
|
|||||||
/**
|
/**
|
||||||
* Save the patched dex file.
|
* Save the patched dex file.
|
||||||
*/
|
*/
|
||||||
fun save(): Map<String, MemoryDataStore> {
|
fun save(): PatcherResult {
|
||||||
|
val packageMetadata = data.packageMetadata
|
||||||
|
val metaInfo = packageMetadata.metaInfo
|
||||||
|
|
||||||
|
if (options.patchResources) {
|
||||||
|
val cacheDirectory = ExtFile(options.resourceCacheDirectory)
|
||||||
|
|
||||||
|
val androlibResources = AndrolibResources().also { resources ->
|
||||||
|
resources.buildOptions = BuildOptions().also { buildOptions ->
|
||||||
|
buildOptions.setBuildOptions(options)
|
||||||
|
buildOptions.isFramework = metaInfo.isFrameworkApk
|
||||||
|
buildOptions.resourcesAreCompressed = metaInfo.compressionType
|
||||||
|
buildOptions.doNotCompress = metaInfo.doNotCompress
|
||||||
|
}
|
||||||
|
|
||||||
|
resources.setSdkInfo(metaInfo.sdkInfo)
|
||||||
|
resources.setVersionInfo(metaInfo.versionInfo)
|
||||||
|
resources.setSharedLibrary(metaInfo.sharedLibrary)
|
||||||
|
resources.setSparseResources(metaInfo.sparseResources)
|
||||||
|
}
|
||||||
|
|
||||||
|
val manifestFile = cacheDirectory.resolve("AndroidManifest.xml")
|
||||||
|
|
||||||
|
ResXmlPatcher.fixingPublicAttrsInProviderAttributes(manifestFile)
|
||||||
|
|
||||||
|
val aaptFile = cacheDirectory.resolve("aapt_temp_file")
|
||||||
|
|
||||||
|
// delete if it exists
|
||||||
|
Files.deleteIfExists(aaptFile.toPath())
|
||||||
|
|
||||||
|
val resDirectory = cacheDirectory.resolve("res")
|
||||||
|
val includedFiles = metaInfo.usesFramework.ids.map { id ->
|
||||||
|
androlibResources.getFrameworkApk(
|
||||||
|
id,
|
||||||
|
metaInfo.usesFramework.tag
|
||||||
|
)
|
||||||
|
}.toTypedArray()
|
||||||
|
|
||||||
|
androlibResources.aaptPackage(
|
||||||
|
aaptFile, manifestFile, resDirectory, null,
|
||||||
|
null, includedFiles
|
||||||
|
)
|
||||||
|
|
||||||
|
// write packaged resources to cache directory
|
||||||
|
ExtFile(aaptFile).directory.copyToDir(cacheDirectory.resolve("build/"))
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
val newDexFile = object : DexFile {
|
val newDexFile = object : DexFile {
|
||||||
override fun getClasses(): Set<ClassDef> {
|
override fun getClasses(): Set<ClassDef> {
|
||||||
patcherData.bytecodeData.classes.applyProxies()
|
data.bytecodeData.classes.applyProxies()
|
||||||
return ListBackedSet(patcherData.bytecodeData.classes.internalClasses)
|
return ListBackedSet(data.bytecodeData.classes.internalClasses)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getOpcodes(): Opcodes {
|
override fun getOpcodes(): Opcodes {
|
||||||
@@ -121,51 +193,78 @@ class Patcher(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// build modified resources
|
|
||||||
if (patchResources) {
|
|
||||||
val extDir = ExtFile(resourceCacheDirectory)
|
|
||||||
androlib.buildResources(extDir, usesFramework)
|
|
||||||
}
|
|
||||||
|
|
||||||
// write dex modified files
|
// write dex modified files
|
||||||
val output = mutableMapOf<String, MemoryDataStore>()
|
val dexFiles = mutableMapOf<String, MemoryDataStore>()
|
||||||
MultiDexIO.writeDexFile(
|
MultiDexIO.writeDexFile(
|
||||||
true, -1, // core count
|
true, -1, // core count
|
||||||
output, NAMER, newDexFile,
|
dexFiles, NAMER, newDexFile, DexIO.DEFAULT_MAX_DEX_POOL_SIZE, null
|
||||||
DexIO.DEFAULT_MAX_DEX_POOL_SIZE,
|
)
|
||||||
null
|
|
||||||
|
return PatcherResult(
|
||||||
|
dexFiles.map {
|
||||||
|
app.revanced.patcher.util.dex.DexFile(it.key, it.value)
|
||||||
|
},
|
||||||
|
metaInfo.doNotCompress.toList()
|
||||||
)
|
)
|
||||||
return output
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a patch to the patcher.
|
* Add [Patch]es to the patcher.
|
||||||
* @param patches The patches to add.
|
* @param patches [Patch]es The patches to add.
|
||||||
*/
|
*/
|
||||||
fun addPatches(patches: Iterable<Patch<Data>>) {
|
fun addPatches(patches: Iterable<Class<out Patch<Data>>>) {
|
||||||
patcherData.patches.addAll(patches)
|
data.patches.addAll(patches)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolves all signatures.
|
* Apply a [patch] and its dependencies recursively.
|
||||||
|
* @param patch The [patch] to apply.
|
||||||
|
* @param appliedPatches A list of [patch] names, to prevent applying [patch]es twice.
|
||||||
|
* @return The result of executing the [patch].
|
||||||
*/
|
*/
|
||||||
fun resolveSignatures(): List<MethodSignature> {
|
private fun applyPatch(
|
||||||
val signatures = buildList {
|
patch: Class<out Patch<Data>>, appliedPatches: MutableList<String>
|
||||||
for (patch in patcherData.patches) {
|
): PatchResult {
|
||||||
if (patch !is BytecodePatch) continue
|
val patchName = patch.patchName
|
||||||
this.addAll(patch.signatures)
|
|
||||||
}
|
// if the patch has already applied silently skip it
|
||||||
}
|
if (appliedPatches.contains(patchName)) return PatchResultSuccess()
|
||||||
if (signatures.isEmpty()) {
|
appliedPatches.add(patchName)
|
||||||
return emptyList()
|
|
||||||
|
// recursively apply all dependency patches
|
||||||
|
patch.dependencies?.forEach {
|
||||||
|
val patchDependency = it.java
|
||||||
|
|
||||||
|
val result = applyPatch(patchDependency, appliedPatches)
|
||||||
|
if (result.isSuccess()) return@forEach
|
||||||
|
|
||||||
|
val errorMessage = result.error()!!.message
|
||||||
|
return PatchResultError("$patchName depends on ${patchDependency.patchName} but the following error was raised: $errorMessage")
|
||||||
}
|
}
|
||||||
|
|
||||||
MethodSignatureResolver(patcherData.bytecodeData.classes.internalClasses, signatures).resolve(patcherData)
|
val patchInstance = patch.getDeclaredConstructor().newInstance()
|
||||||
signaturesResolved = true
|
|
||||||
return signatures
|
// if the current patch is a resource patch but resource patching is disabled, return an error
|
||||||
|
val isResourcePatch = patchInstance is ResourcePatch
|
||||||
|
if (!options.patchResources && isResourcePatch) return PatchResultError("$patchName is a resource patch, but resource patching is disabled.")
|
||||||
|
|
||||||
|
// TODO: find a solution for this
|
||||||
|
val data = if (isResourcePatch) {
|
||||||
|
data.resourceData
|
||||||
|
} else {
|
||||||
|
MethodSignatureResolver(
|
||||||
|
data.bytecodeData.classes.internalClasses, (patchInstance as BytecodePatch).signatures
|
||||||
|
).resolve(data)
|
||||||
|
data.bytecodeData
|
||||||
|
}
|
||||||
|
|
||||||
|
return try {
|
||||||
|
patchInstance.execute(data)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
PatchResultError(e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply patches loaded into the patcher.
|
* Apply patches loaded into the patcher.
|
||||||
* @param stopOnError If true, the patches will stop on the first error.
|
* @param stopOnError If true, the patches will stop on the first error.
|
||||||
@@ -174,47 +273,31 @@ class Patcher(
|
|||||||
* If the [Patch] failed to apply, an Exception will always be returned to the wrapping Result object.
|
* If the [Patch] failed to apply, an Exception will always be returned to the wrapping Result object.
|
||||||
*/
|
*/
|
||||||
fun applyPatches(
|
fun applyPatches(
|
||||||
stopOnError: Boolean = false,
|
stopOnError: Boolean = false, callback: (String) -> Unit = {}
|
||||||
callback: (String) -> Unit = {}
|
|
||||||
): Map<String, Result<PatchResultSuccess>> {
|
): Map<String, Result<PatchResultSuccess>> {
|
||||||
if (!signaturesResolved) {
|
val appliedPatches = mutableListOf<String>()
|
||||||
resolveSignatures()
|
|
||||||
}
|
|
||||||
return buildMap {
|
return buildMap {
|
||||||
for (patch in patcherData.patches) {
|
for (patch in data.patches) {
|
||||||
val resourcePatch = patch is ResourcePatch
|
val result = applyPatch(patch, appliedPatches)
|
||||||
if (!patchResources && resourcePatch) continue
|
|
||||||
|
|
||||||
val patchNameAnnotation = patch::class.java.findAnnotationRecursively(Name::class.java)
|
val name = patch.patchName
|
||||||
|
callback(name)
|
||||||
|
|
||||||
patchNameAnnotation?.let {
|
this[name] = if (result.isSuccess()) {
|
||||||
callback(it.name)
|
Result.success(result.success()!!)
|
||||||
|
} else {
|
||||||
|
Result.failure(result.error()!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
val result: Result<PatchResultSuccess> = try {
|
if (stopOnError && result.isError()) break
|
||||||
val data = if (resourcePatch) {
|
|
||||||
patcherData.resourceData
|
|
||||||
} else {
|
|
||||||
patcherData.bytecodeData
|
|
||||||
}
|
|
||||||
|
|
||||||
val pr = patch.execute(data)
|
|
||||||
|
|
||||||
if (pr.isSuccess()) {
|
|
||||||
Result.success(pr.success()!!)
|
|
||||||
} else {
|
|
||||||
Result.failure(Exception(pr.error()?.errorMessage() ?: "Unknown error"))
|
|
||||||
}
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Result.failure(e)
|
|
||||||
}
|
|
||||||
|
|
||||||
patchNameAnnotation?.let {
|
|
||||||
this[patchNameAnnotation.name] = result
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result.isFailure && stopOnError) break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun BuildOptions.setBuildOptions(options: PatcherOptions) {
|
||||||
|
this.aaptPath = options.aaptPath
|
||||||
|
this.useAapt2 = true
|
||||||
|
this.frameworkFolderLocation = options.frameworkFolderLocation
|
||||||
|
}
|
||||||
19
src/main/kotlin/app/revanced/patcher/PatcherOptions.kt
Normal file
19
src/main/kotlin/app/revanced/patcher/PatcherOptions.kt
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package app.revanced.patcher
|
||||||
|
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Options for a patcher.
|
||||||
|
* @param inputFile The input file (usually an apk file).
|
||||||
|
* @param resourceCacheDirectory Directory to cache resources.
|
||||||
|
* @param patchResources Weather to use the resource patcher. Resources will still need to be decoded.
|
||||||
|
* @param aaptPath Optional path to a custom aapt binary.
|
||||||
|
* @param frameworkFolderLocation Optional path to a custom framework folder.
|
||||||
|
*/
|
||||||
|
data class PatcherOptions(
|
||||||
|
internal val inputFile: File,
|
||||||
|
internal val resourceCacheDirectory: String,
|
||||||
|
internal val patchResources: Boolean = false,
|
||||||
|
internal val aaptPath: String = "",
|
||||||
|
internal val frameworkFolderLocation: String? = null
|
||||||
|
)
|
||||||
13
src/main/kotlin/app/revanced/patcher/PatcherResult.kt
Normal file
13
src/main/kotlin/app/revanced/patcher/PatcherResult.kt
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package app.revanced.patcher
|
||||||
|
|
||||||
|
import app.revanced.patcher.util.dex.DexFile
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The result of a patcher.
|
||||||
|
* @param dexFiles The patched dex files.
|
||||||
|
* @param doNotCompress List of relative paths to files to exclude from compressing.
|
||||||
|
*/
|
||||||
|
data class PatcherResult(
|
||||||
|
val dexFiles: List<DexFile>,
|
||||||
|
val doNotCompress: List<String>? = null
|
||||||
|
)
|
||||||
13
src/main/kotlin/app/revanced/patcher/data/PackageMetadata.kt
Normal file
13
src/main/kotlin/app/revanced/patcher/data/PackageMetadata.kt
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package app.revanced.patcher.data
|
||||||
|
|
||||||
|
import brut.androlib.meta.MetaInfo
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Metadata about a package.
|
||||||
|
*/
|
||||||
|
class PackageMetadata {
|
||||||
|
lateinit var packageName: String
|
||||||
|
lateinit var packageVersion: String
|
||||||
|
|
||||||
|
internal val metaInfo: MetaInfo = MetaInfo()
|
||||||
|
}
|
||||||
@@ -7,12 +7,14 @@ import app.revanced.patcher.patch.base.Patch
|
|||||||
import org.jf.dexlib2.iface.ClassDef
|
import org.jf.dexlib2.iface.ClassDef
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
internal data class PatcherData(
|
data class PatcherData(
|
||||||
val internalClasses: MutableList<ClassDef>,
|
internal val internalClasses: MutableList<ClassDef>,
|
||||||
val resourceCacheDirectory: String
|
internal val resourceCacheDirectory: String,
|
||||||
|
val packageMetadata: PackageMetadata
|
||||||
) {
|
) {
|
||||||
internal val patches = mutableListOf<Patch<Data>>()
|
|
||||||
|
|
||||||
internal val bytecodeData = BytecodeData(patches, internalClasses)
|
internal val patches = mutableListOf<Class<out Patch<Data>>>()
|
||||||
|
|
||||||
|
internal val bytecodeData = BytecodeData(internalClasses)
|
||||||
internal val resourceData = ResourceData(File(resourceCacheDirectory))
|
internal val resourceData = ResourceData(File(resourceCacheDirectory))
|
||||||
}
|
}
|
||||||
@@ -1,55 +1,33 @@
|
|||||||
package app.revanced.patcher.data.implementation
|
package app.revanced.patcher.data.implementation
|
||||||
|
|
||||||
import app.revanced.patcher.data.base.Data
|
import app.revanced.patcher.data.base.Data
|
||||||
import app.revanced.patcher.patch.base.Patch
|
|
||||||
import app.revanced.patcher.patch.implementation.BytecodePatch
|
|
||||||
import app.revanced.patcher.signature.implementation.method.resolver.SignatureResolverResult
|
|
||||||
import app.revanced.patcher.util.ProxyBackedClassList
|
import app.revanced.patcher.util.ProxyBackedClassList
|
||||||
import app.revanced.patcher.util.method.MethodWalker
|
import app.revanced.patcher.util.method.MethodWalker
|
||||||
import org.jf.dexlib2.iface.ClassDef
|
import org.jf.dexlib2.iface.ClassDef
|
||||||
import org.jf.dexlib2.iface.Method
|
import org.jf.dexlib2.iface.Method
|
||||||
|
|
||||||
class BytecodeData(
|
class BytecodeData(
|
||||||
// FIXME: ugly solution due to design.
|
|
||||||
// It does not make sense for a BytecodeData instance to have access to the patches
|
|
||||||
private val patches: List<Patch<Data>>,
|
|
||||||
internalClasses: MutableList<ClassDef>
|
internalClasses: MutableList<ClassDef>
|
||||||
) : Data {
|
) : Data {
|
||||||
val classes = ProxyBackedClassList(internalClasses)
|
val classes = ProxyBackedClassList(internalClasses)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find a class by a given class name
|
* Find a class by a given class name.
|
||||||
* @return A proxy for the first class that matches the class name
|
* @param className The name of the class.
|
||||||
|
* @return A proxy for the first class that matches the class name.
|
||||||
*/
|
*/
|
||||||
fun findClass(className: String) = findClass { it.type.contains(className) }
|
fun findClass(className: String) = findClass { it.type.contains(className) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find a class by a given predicate
|
* Find a class by a given predicate.
|
||||||
* @return A proxy for the first class that matches the predicate
|
* @param predicate A predicate to match the class.
|
||||||
|
* @return A proxy for the first class that matches the predicate.
|
||||||
*/
|
*/
|
||||||
fun findClass(predicate: (ClassDef) -> Boolean): app.revanced.patcher.util.proxy.ClassProxy? {
|
fun findClass(predicate: (ClassDef) -> Boolean) =
|
||||||
// if we already proxied the class matching the predicate...
|
// if we already proxied the class matching the predicate...
|
||||||
for (patch in patches) {
|
classes.proxies.firstOrNull { predicate(it.immutableClass) } ?:
|
||||||
if (patch !is BytecodePatch) continue
|
|
||||||
for (signature in patch.signatures) {
|
|
||||||
val result = signature.result
|
|
||||||
result ?: continue
|
|
||||||
|
|
||||||
if (predicate(result.definingClassProxy.immutableClass)) return result.definingClassProxy // ...then return that proxy
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// else resolve the class to a proxy and return it, if the predicate is matching a class
|
// else resolve the class to a proxy and return it, if the predicate is matching a class
|
||||||
return classes.find(predicate)?.let {
|
classes.find(predicate)?.let { proxy(it) }
|
||||||
proxy(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class MethodMap : LinkedHashMap<String, SignatureResolverResult>() {
|
|
||||||
override fun get(key: String): SignatureResolverResult {
|
|
||||||
return super.get(key) ?: throw MethodNotFoundException("Method $key was not found in the method cache")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class MethodNotFoundException(s: String) : Exception(s)
|
internal class MethodNotFoundException(s: String) : Exception(s)
|
||||||
@@ -63,6 +41,11 @@ internal inline fun <reified T> Iterable<T>.find(predicate: (T) -> Boolean): T?
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a [MethodWalker] instance for the current [BytecodeData].
|
||||||
|
* @param startMethod The method to start at.
|
||||||
|
* @return A [MethodWalker] instance.
|
||||||
|
*/
|
||||||
fun BytecodeData.toMethodWalker(startMethod: Method): MethodWalker {
|
fun BytecodeData.toMethodWalker(startMethod: Method): MethodWalker {
|
||||||
return MethodWalker(this, startMethod)
|
return MethodWalker(this, startMethod)
|
||||||
}
|
}
|
||||||
@@ -80,7 +63,7 @@ fun BytecodeData.proxy(classDef: ClassDef): app.revanced.patcher.util.proxy.Clas
|
|||||||
var proxy = this.classes.proxies.find { it.immutableClass.type == classDef.type }
|
var proxy = this.classes.proxies.find { it.immutableClass.type == classDef.type }
|
||||||
if (proxy == null) {
|
if (proxy == null) {
|
||||||
proxy = app.revanced.patcher.util.proxy.ClassProxy(classDef)
|
proxy = app.revanced.patcher.util.proxy.ClassProxy(classDef)
|
||||||
this.classes.proxies.add(proxy)
|
this.classes.add(proxy)
|
||||||
}
|
}
|
||||||
return proxy
|
return proxy
|
||||||
}
|
}
|
||||||
@@ -14,8 +14,7 @@ class ResourceData(private val resourceCacheDirectory: File) : Data {
|
|||||||
private fun resolve(path: String) = resourceCacheDirectory.resolve(path)
|
private fun resolve(path: String) = resourceCacheDirectory.resolve(path)
|
||||||
|
|
||||||
fun forEach(action: (File) -> Unit) = resourceCacheDirectory.walkTopDown().forEach(action)
|
fun forEach(action: (File) -> Unit) = resourceCacheDirectory.walkTopDown().forEach(action)
|
||||||
fun reader(path: String) = resolve(path).reader()
|
fun get(path: String) = resolve(path)
|
||||||
fun writer(path: String) = resolve(path).writer()
|
|
||||||
|
|
||||||
fun replace(path: String, oldValue: String, newValue: String, oldValueIsRegex: Boolean = false) {
|
fun replace(path: String, oldValue: String, newValue: String, oldValueIsRegex: Boolean = false) {
|
||||||
// TODO: buffer this somehow
|
// TODO: buffer this somehow
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package app.revanced.patcher.extensions
|
||||||
|
|
||||||
|
import app.revanced.patcher.annotation.Compatibility
|
||||||
|
import app.revanced.patcher.annotation.Description
|
||||||
|
import app.revanced.patcher.annotation.Name
|
||||||
|
import app.revanced.patcher.annotation.Version
|
||||||
|
import app.revanced.patcher.data.base.Data
|
||||||
|
import app.revanced.patcher.patch.base.Patch
|
||||||
|
import app.revanced.patcher.signature.implementation.method.MethodSignature
|
||||||
|
import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod
|
||||||
|
import app.revanced.patcher.signature.implementation.method.annotation.MatchingMethod
|
||||||
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recursively find a given annotation on a class.
|
||||||
|
* @param targetAnnotation The annotation to find.
|
||||||
|
* @return The annotation.
|
||||||
|
*/
|
||||||
|
private fun <T : Annotation> Class<*>.recursiveAnnotation(targetAnnotation: KClass<T>) =
|
||||||
|
this.findAnnotationRecursively(targetAnnotation.java, mutableSetOf())
|
||||||
|
|
||||||
|
|
||||||
|
private fun <T : Annotation> Class<*>.findAnnotationRecursively(
|
||||||
|
targetAnnotation: Class<T>, traversed: MutableSet<Annotation>
|
||||||
|
): T? {
|
||||||
|
val found = this.annotations.firstOrNull { it.annotationClass.java.name == targetAnnotation.name }
|
||||||
|
|
||||||
|
@Suppress("UNCHECKED_CAST") if (found != null) return found as T
|
||||||
|
|
||||||
|
for (annotation in this.annotations) {
|
||||||
|
if (traversed.contains(annotation)) continue
|
||||||
|
traversed.add(annotation)
|
||||||
|
|
||||||
|
return (annotation.annotationClass.java.findAnnotationRecursively(targetAnnotation, traversed)) ?: continue
|
||||||
|
}
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
object PatchExtensions {
|
||||||
|
val Class<out Patch<Data>>.patchName: String
|
||||||
|
get() = recursiveAnnotation(Name::class)?.name ?: this.javaClass.simpleName
|
||||||
|
val Class<out Patch<Data>>.version get() = recursiveAnnotation(Version::class)?.version
|
||||||
|
val Class<out Patch<Data>>.include get() = recursiveAnnotation(app.revanced.patcher.patch.annotations.Patch::class)!!.include
|
||||||
|
val Class<out Patch<Data>>.description get() = recursiveAnnotation(Description::class)?.description
|
||||||
|
val Class<out Patch<Data>>.dependencies get() = recursiveAnnotation(app.revanced.patcher.patch.annotations.Dependencies::class)?.dependencies
|
||||||
|
val Class<out Patch<Data>>.compatiblePackages get() = recursiveAnnotation(Compatibility::class)?.compatiblePackages
|
||||||
|
}
|
||||||
|
|
||||||
|
object MethodSignatureExtensions {
|
||||||
|
val MethodSignature.name: String
|
||||||
|
get() = javaClass.recursiveAnnotation(Name::class)?.name ?: this.javaClass.simpleName
|
||||||
|
val MethodSignature.version get() = javaClass.recursiveAnnotation(Version::class)?.version ?: "0.0.1"
|
||||||
|
val MethodSignature.description get() = javaClass.recursiveAnnotation(Description::class)?.description
|
||||||
|
val MethodSignature.compatiblePackages get() = javaClass.recursiveAnnotation(Compatibility::class)?.compatiblePackages
|
||||||
|
val MethodSignature.matchingMethod get() = javaClass.recursiveAnnotation(MatchingMethod::class)
|
||||||
|
val MethodSignature.fuzzyPatternScanMethod get() = javaClass.recursiveAnnotation(FuzzyPatternScanMethod::class)
|
||||||
|
val MethodSignature.fuzzyThreshold get() = fuzzyPatternScanMethod?.threshold ?: 0
|
||||||
|
}
|
||||||
@@ -9,33 +9,7 @@ import org.jf.dexlib2.iface.reference.MethodReference
|
|||||||
import org.jf.dexlib2.immutable.ImmutableMethod
|
import org.jf.dexlib2.immutable.ImmutableMethod
|
||||||
import org.jf.dexlib2.immutable.ImmutableMethodImplementation
|
import org.jf.dexlib2.immutable.ImmutableMethodImplementation
|
||||||
import org.jf.dexlib2.util.MethodUtil
|
import org.jf.dexlib2.util.MethodUtil
|
||||||
|
import java.io.OutputStream
|
||||||
/**
|
|
||||||
* Recursively find a given annotation on a class
|
|
||||||
* @param targetAnnotation The annotation to find
|
|
||||||
* @return The annotation
|
|
||||||
*/
|
|
||||||
fun <T : Annotation> Class<*>.findAnnotationRecursively(targetAnnotation: Class<T>) =
|
|
||||||
this.findAnnotationRecursively(targetAnnotation, mutableSetOf())
|
|
||||||
|
|
||||||
private fun <T : Annotation> Class<*>.findAnnotationRecursively(
|
|
||||||
targetAnnotation: Class<T>,
|
|
||||||
traversed: MutableSet<Annotation>
|
|
||||||
): T? {
|
|
||||||
val found = this.annotations.firstOrNull { it.annotationClass.java.name == targetAnnotation.name }
|
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
|
||||||
if (found != null) return found as T
|
|
||||||
|
|
||||||
for (annotation in this.annotations) {
|
|
||||||
if (traversed.contains(annotation)) continue
|
|
||||||
traversed.add(annotation)
|
|
||||||
|
|
||||||
return (annotation.annotationClass.java.findAnnotationRecursively(targetAnnotation, traversed)) ?: continue
|
|
||||||
}
|
|
||||||
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
infix fun AccessFlags.or(other: AccessFlags) = this.value or other.value
|
infix fun AccessFlags.or(other: AccessFlags) = this.value or other.value
|
||||||
infix fun Int.or(other: AccessFlags) = this or other.value
|
infix fun Int.or(other: AccessFlags) = this or other.value
|
||||||
@@ -46,6 +20,19 @@ fun MutableMethodImplementation.addInstructions(index: Int, instructions: List<B
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compare a method to another, considering constructors and parameters.
|
||||||
|
* @param otherMethod The method to compare against.
|
||||||
|
* @return True if the methods match given the conditions.
|
||||||
|
*/
|
||||||
|
fun Method.softCompareTo(
|
||||||
|
otherMethod: MethodReference
|
||||||
|
): Boolean {
|
||||||
|
if (MethodUtil.isConstructor(this) && !parametersEqual(this.parameterTypes, otherMethod.parameterTypes))
|
||||||
|
return false
|
||||||
|
return this.name == otherMethod.name
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clones the method.
|
* Clones the method.
|
||||||
* @param registerCount This parameter allows you to change the register count of the method.
|
* @param registerCount This parameter allows you to change the register count of the method.
|
||||||
@@ -85,14 +72,6 @@ internal fun Method.cloneMutable(
|
|||||||
registerCount: Int = 0,
|
registerCount: Int = 0,
|
||||||
) = clone(registerCount).toMutable()
|
) = clone(registerCount).toMutable()
|
||||||
|
|
||||||
internal fun Method.softCompareTo(
|
|
||||||
otherMethod: MethodReference
|
|
||||||
): Boolean {
|
|
||||||
if (MethodUtil.isConstructor(this) && !parametersEqual(this.parameterTypes, otherMethod.parameterTypes))
|
|
||||||
return false
|
|
||||||
return this.name == otherMethod.name
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: also check the order of parameters as different order equals different method overload
|
// FIXME: also check the order of parameters as different order equals different method overload
|
||||||
internal fun parametersEqual(
|
internal fun parametersEqual(
|
||||||
parameters1: Iterable<CharSequence>,
|
parameters1: Iterable<CharSequence>,
|
||||||
@@ -105,4 +84,9 @@ internal fun parametersEqual(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal val nullOutputStream: OutputStream =
|
||||||
|
object : OutputStream() {
|
||||||
|
override fun write(b: Int) {}
|
||||||
|
}
|
||||||
@@ -1,9 +1,24 @@
|
|||||||
package app.revanced.patcher.patch.annotations
|
package app.revanced.patcher.patch.annotations
|
||||||
|
|
||||||
|
import app.revanced.patcher.data.base.Data
|
||||||
|
import app.revanced.patcher.patch.base.Patch
|
||||||
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Annotation to mark a Class as a patch.
|
* Annotation to mark a Class as a patch.
|
||||||
|
* @param include If false, the patch should be treated as optional by default.
|
||||||
*/
|
*/
|
||||||
@Target(AnnotationTarget.CLASS)
|
@Target(AnnotationTarget.CLASS)
|
||||||
@Retention(AnnotationRetention.RUNTIME)
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
@MustBeDocumented
|
@MustBeDocumented
|
||||||
annotation class Patch
|
annotation class Patch(val include: Boolean = true)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Annotation for dependencies of [Patch]es .
|
||||||
|
*/
|
||||||
|
@Target(AnnotationTarget.CLASS)
|
||||||
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
|
@MustBeDocumented
|
||||||
|
annotation class Dependencies(
|
||||||
|
val dependencies: Array<KClass<out Patch<Data>>> = []
|
||||||
|
)
|
||||||
@@ -11,8 +11,9 @@ import app.revanced.patcher.patch.implementation.misc.PatchResult
|
|||||||
* Can either be a [ResourcePatch] or a [BytecodePatch].
|
* Can either be a [ResourcePatch] or a [BytecodePatch].
|
||||||
*/
|
*/
|
||||||
abstract class Patch<out T : Data> {
|
abstract class Patch<out T : Data> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main function of the [Patch] which the patcher will call.
|
* The main function of the [Patch] which the patcher will call.
|
||||||
*/
|
*/
|
||||||
abstract fun execute(data: @UnsafeVariance T): PatchResult // FIXME: remove the UnsafeVariance annotation
|
abstract fun execute(data: @UnsafeVariance T): PatchResult
|
||||||
}
|
}
|
||||||
@@ -24,10 +24,12 @@ interface PatchResult {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PatchResultError(private val errorMessage: String) : PatchResult {
|
class PatchResultError(
|
||||||
fun errorMessage(): String {
|
errorMessage: String?, cause: Exception?
|
||||||
return errorMessage
|
) : Exception(errorMessage, cause), PatchResult {
|
||||||
}
|
constructor(errorMessage: String) : this(errorMessage, null)
|
||||||
|
constructor(cause: Exception) : this(cause.message, cause)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class PatchResultSuccess : PatchResult
|
class PatchResultSuccess : PatchResult
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package app.revanced.patcher.signature.implementation.method
|
package app.revanced.patcher.signature.implementation.method
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Name
|
|
||||||
import app.revanced.patcher.data.implementation.MethodNotFoundException
|
import app.revanced.patcher.data.implementation.MethodNotFoundException
|
||||||
|
import app.revanced.patcher.extensions.MethodSignatureExtensions.name
|
||||||
import app.revanced.patcher.signature.base.Signature
|
import app.revanced.patcher.signature.base.Signature
|
||||||
import app.revanced.patcher.signature.implementation.method.resolver.SignatureResolverResult
|
import app.revanced.patcher.signature.implementation.method.resolver.SignatureResolverResult
|
||||||
import org.jf.dexlib2.Opcode
|
import org.jf.dexlib2.Opcode
|
||||||
@@ -26,22 +26,8 @@ abstract class MethodSignature(
|
|||||||
* The result of the signature
|
* The result of the signature
|
||||||
*/
|
*/
|
||||||
var result: SignatureResolverResult? = null
|
var result: SignatureResolverResult? = null
|
||||||
|
@Throws(MethodNotFoundException::class)
|
||||||
get() {
|
get() {
|
||||||
return field ?: throw MethodNotFoundException(
|
return field ?: throw MethodNotFoundException("Could not resolve required signature ${this.name}")
|
||||||
"Could not resolve required signature ${
|
|
||||||
(this::class.annotations.find { it is Name }?.let {
|
|
||||||
(it as Name).name
|
|
||||||
})
|
|
||||||
}"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
val resolved: Boolean
|
|
||||||
get() {
|
|
||||||
var resolved = false
|
|
||||||
try {
|
|
||||||
resolved = result != null
|
|
||||||
} catch (_: Exception) {
|
|
||||||
}
|
|
||||||
return resolved
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,7 @@ import app.revanced.patcher.signature.implementation.method.MethodSignature
|
|||||||
@Target(AnnotationTarget.CLASS)
|
@Target(AnnotationTarget.CLASS)
|
||||||
@Retention(AnnotationRetention.RUNTIME)
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
annotation class MatchingMethod(
|
annotation class MatchingMethod(
|
||||||
val definingClass: String = "L<unspecified-class>",
|
val definingClass: String = "L<unspecified-class>;",
|
||||||
val name: String = "<unspecified-method>"
|
val name: String = "<unspecified-method>"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,9 @@ package app.revanced.patcher.signature.implementation.method.resolver
|
|||||||
|
|
||||||
import app.revanced.patcher.data.PatcherData
|
import app.revanced.patcher.data.PatcherData
|
||||||
import app.revanced.patcher.data.implementation.proxy
|
import app.revanced.patcher.data.implementation.proxy
|
||||||
import app.revanced.patcher.extensions.findAnnotationRecursively
|
import app.revanced.patcher.extensions.MethodSignatureExtensions.fuzzyThreshold
|
||||||
import app.revanced.patcher.extensions.parametersEqual
|
import app.revanced.patcher.extensions.parametersEqual
|
||||||
import app.revanced.patcher.signature.implementation.method.MethodSignature
|
import app.revanced.patcher.signature.implementation.method.MethodSignature
|
||||||
import app.revanced.patcher.signature.implementation.method.annotation.FuzzyPatternScanMethod
|
|
||||||
import org.jf.dexlib2.Opcode
|
import org.jf.dexlib2.Opcode
|
||||||
import org.jf.dexlib2.iface.ClassDef
|
import org.jf.dexlib2.iface.ClassDef
|
||||||
import org.jf.dexlib2.iface.Method
|
import org.jf.dexlib2.iface.Method
|
||||||
@@ -77,19 +76,17 @@ internal class MethodSignatureResolver(
|
|||||||
signature.strings?.let { strings ->
|
signature.strings?.let { strings ->
|
||||||
method.implementation ?: return null
|
method.implementation ?: return null
|
||||||
|
|
||||||
method.implementation!!.instructions.let { instructions ->
|
val stringsList = strings.toMutableList()
|
||||||
val stringsList = strings.toMutableList()
|
|
||||||
|
|
||||||
for (instruction in instructions) {
|
for (instruction in method.implementation!!.instructions) {
|
||||||
if (instruction.opcode != Opcode.CONST_STRING) continue
|
if (instruction.opcode != Opcode.CONST_STRING) continue
|
||||||
|
|
||||||
val string = ((instruction as Instruction21c).reference as StringReference).string
|
val string = ((instruction as Instruction21c).reference as StringReference).string
|
||||||
val i = stringsList.indexOfFirst { it == string }
|
val i = stringsList.indexOfFirst { it == string }
|
||||||
if (i != -1) stringsList.removeAt(i)
|
if (i != -1) stringsList.removeAt(i)
|
||||||
}
|
|
||||||
|
|
||||||
if (stringsList.isNotEmpty()) return null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stringsList.isNotEmpty()) return null
|
||||||
}
|
}
|
||||||
|
|
||||||
return if (signature.opcodes == null) {
|
return if (signature.opcodes == null) {
|
||||||
@@ -109,9 +106,7 @@ internal class MethodSignatureResolver(
|
|||||||
val pattern = signature.opcodes!!
|
val pattern = signature.opcodes!!
|
||||||
val size = pattern.count()
|
val size = pattern.count()
|
||||||
|
|
||||||
val threshold =
|
val threshold = signature.fuzzyThreshold
|
||||||
signature::class.java.findAnnotationRecursively(FuzzyPatternScanMethod::class.java)?.threshold
|
|
||||||
?: 0
|
|
||||||
|
|
||||||
for (instructionIndex in 0 until count) {
|
for (instructionIndex in 0 until count) {
|
||||||
var patternIndex = 0
|
var patternIndex = 0
|
||||||
|
|||||||
@@ -1,24 +1,21 @@
|
|||||||
package app.revanced.patcher.util
|
package app.revanced.patcher.util
|
||||||
|
|
||||||
|
import app.revanced.patcher.util.proxy.ClassProxy
|
||||||
import org.jf.dexlib2.iface.ClassDef
|
import org.jf.dexlib2.iface.ClassDef
|
||||||
|
|
||||||
class ProxyBackedClassList(internal val internalClasses: MutableList<ClassDef>) : List<ClassDef> {
|
class ProxyBackedClassList(internal val internalClasses: MutableList<ClassDef>) : List<ClassDef> {
|
||||||
internal val proxies = mutableListOf<app.revanced.patcher.util.proxy.ClassProxy>()
|
private val internalProxies = mutableListOf<ClassProxy>()
|
||||||
|
internal val proxies: List<ClassProxy> = internalProxies
|
||||||
|
|
||||||
fun add(classDef: ClassDef) {
|
fun add(classDef: ClassDef) = internalClasses.add(classDef)
|
||||||
internalClasses.add(classDef)
|
fun add(classProxy: ClassProxy) = internalProxies.add(classProxy)
|
||||||
}
|
|
||||||
|
|
||||||
fun add(classProxy: app.revanced.patcher.util.proxy.ClassProxy) {
|
|
||||||
proxies.add(classProxy)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply all resolved classes into [internalClasses] and clean the [proxies] list.
|
* Apply all resolved classes into [internalClasses] and clean the [proxies] list.
|
||||||
*/
|
*/
|
||||||
fun applyProxies() {
|
internal fun applyProxies() {
|
||||||
// FIXME: check if this could cause issues when multiple patches use the same proxy
|
// FIXME: check if this could cause issues when multiple patches use the same proxy
|
||||||
proxies.removeIf { proxy ->
|
internalProxies.removeIf { proxy ->
|
||||||
// if the proxy is unused, keep it in the list
|
// if the proxy is unused, keep it in the list
|
||||||
if (!proxy.proxyUsed) return@removeIf false
|
if (!proxy.proxyUsed) return@removeIf false
|
||||||
|
|
||||||
|
|||||||
10
src/main/kotlin/app/revanced/patcher/util/dex/DexFile.kt
Normal file
10
src/main/kotlin/app/revanced/patcher/util/dex/DexFile.kt
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package app.revanced.patcher.util.dex
|
||||||
|
|
||||||
|
import org.jf.dexlib2.writer.io.MemoryDataStore
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper for dex files.
|
||||||
|
* @param name The original name of the dex file
|
||||||
|
* @param memoryDataStore The data store for the dex file.
|
||||||
|
*/
|
||||||
|
data class DexFile(val name: String, val memoryDataStore: MemoryDataStore)
|
||||||
@@ -33,7 +33,7 @@ class MethodWalker internal constructor(
|
|||||||
* @param walkMutable If this is true, the class of the method will be resolved mutably.
|
* @param walkMutable If this is true, the class of the method will be resolved mutably.
|
||||||
* The current method will be mutable.
|
* The current method will be mutable.
|
||||||
*/
|
*/
|
||||||
fun walk(offset: Int, walkMutable: Boolean = false): MethodWalker {
|
fun nextMethod(offset: Int, walkMutable: Boolean = false): MethodWalker {
|
||||||
currentMethod.implementation?.instructions?.let { instructions ->
|
currentMethod.implementation?.instructions?.let { instructions ->
|
||||||
val instruction = instructions.elementAt(offset)
|
val instruction = instructions.elementAt(offset)
|
||||||
|
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
package app.revanced.patcher.util.patch
|
|
||||||
|
|
||||||
import app.revanced.patcher.patch.base.Patch
|
|
||||||
import java.io.File
|
|
||||||
import java.net.URLClassLoader
|
|
||||||
import java.util.jar.JarFile
|
|
||||||
|
|
||||||
object PatchLoader {
|
|
||||||
/**
|
|
||||||
* This method loads patches from a given jar file containing [Patch]es
|
|
||||||
* @return the loaded patches represented as a list of [Patch] classes
|
|
||||||
*/
|
|
||||||
fun loadFromFile(patchesJar: File) = buildList {
|
|
||||||
val jarFile = JarFile(patchesJar)
|
|
||||||
val classLoader = URLClassLoader(arrayOf(patchesJar.toURI().toURL()))
|
|
||||||
|
|
||||||
val entries = jarFile.entries()
|
|
||||||
while (entries.hasMoreElements()) {
|
|
||||||
val entry = entries.nextElement()
|
|
||||||
if (!entry.name.endsWith(".class") || entry.name.contains("$")) continue
|
|
||||||
|
|
||||||
val clazz = classLoader.loadClass(entry.realName.replace('/', '.').replace(".class", ""))
|
|
||||||
|
|
||||||
if (!clazz.isAnnotationPresent(app.revanced.patcher.patch.annotations.Patch::class.java)) continue
|
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
|
||||||
val patch = clazz as Class<Patch<*>>
|
|
||||||
|
|
||||||
// TODO: include declared classes from patch
|
|
||||||
|
|
||||||
this.add(patch)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package app.revanced.patcher.util.patch.base
|
||||||
|
|
||||||
|
import app.revanced.patcher.data.base.Data
|
||||||
|
import app.revanced.patcher.patch.base.Patch
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param patchBundlePath The path to the patch bundle.
|
||||||
|
*/
|
||||||
|
abstract class PatchBundle(patchBundlePath: String) : File(patchBundlePath) {
|
||||||
|
internal fun loadPatches(classLoader: ClassLoader, classNames: Iterator<String>) = buildList {
|
||||||
|
classNames.forEach { className ->
|
||||||
|
val clazz = classLoader.loadClass(className)
|
||||||
|
if (!clazz.isAnnotationPresent(app.revanced.patcher.patch.annotations.Patch::class.java)) return@forEach
|
||||||
|
@Suppress("UNCHECKED_CAST") this.add(clazz as Class<out Patch<Data>>)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package app.revanced.patcher.util.patch.implementation
|
||||||
|
|
||||||
|
import app.revanced.patcher.util.patch.base.PatchBundle
|
||||||
|
import app.revanced.patcher.util.patch.util.StringIterator
|
||||||
|
import org.jf.dexlib2.DexFileFactory
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A patch bundle of the ReVanced [DexPatchBundle] format.
|
||||||
|
* @param patchBundlePath The path to a patch bundle of dex format.
|
||||||
|
* @param dexClassLoader The dex class loader.
|
||||||
|
*/
|
||||||
|
class DexPatchBundle(patchBundlePath: String, private val dexClassLoader: ClassLoader) : PatchBundle(patchBundlePath) {
|
||||||
|
fun loadPatches() = loadPatches(dexClassLoader,
|
||||||
|
StringIterator(DexFileFactory.loadDexFile(path, null).classes.iterator()) { classDef ->
|
||||||
|
classDef.type.substring(1, classDef.length - 1).replace('/', '.')
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package app.revanced.patcher.util.patch.implementation
|
||||||
|
|
||||||
|
import app.revanced.patcher.util.patch.base.PatchBundle
|
||||||
|
import app.revanced.patcher.util.patch.util.StringIterator
|
||||||
|
import java.net.URLClassLoader
|
||||||
|
import java.util.jar.JarFile
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A patch bundle of the ReVanced [JarPatchBundle] format.
|
||||||
|
* @param patchBundlePath The path to the patch bundle.
|
||||||
|
*/
|
||||||
|
class JarPatchBundle(patchBundlePath: String) : PatchBundle(patchBundlePath) {
|
||||||
|
fun loadPatches() = loadPatches(
|
||||||
|
URLClassLoader(
|
||||||
|
arrayOf(this.toURI().toURL()),
|
||||||
|
Thread.currentThread().contextClassLoader // TODO: find out why this is required
|
||||||
|
),
|
||||||
|
StringIterator(
|
||||||
|
JarFile(this)
|
||||||
|
.entries()
|
||||||
|
.toList() // TODO: find a cleaner solution than that to filter non class files
|
||||||
|
.filter {
|
||||||
|
it.name.endsWith(".class") && !it.name.contains("$")
|
||||||
|
}
|
||||||
|
.iterator()
|
||||||
|
) {
|
||||||
|
it.realName.replace('/', '.').replace(".class", "")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package app.revanced.patcher.util.patch.util
|
||||||
|
|
||||||
|
internal class StringIterator<T, I : Iterator<T>>(
|
||||||
|
private val iterator: I,
|
||||||
|
private val _next: (T) -> String
|
||||||
|
) : Iterator<String> {
|
||||||
|
override fun hasNext() = iterator.hasNext()
|
||||||
|
|
||||||
|
override fun next() = _next(iterator.next())
|
||||||
|
}
|
||||||
@@ -13,9 +13,9 @@ import org.jf.smali.smaliTreeWalker
|
|||||||
import java.io.InputStreamReader
|
import java.io.InputStreamReader
|
||||||
|
|
||||||
private const val METHOD_TEMPLATE = """
|
private const val METHOD_TEMPLATE = """
|
||||||
.class public Linlinecompiler;
|
.class LInlineCompiler;
|
||||||
.super Ljava/lang/Object;
|
.super Ljava/lang/Object;
|
||||||
.method public static compiler(%s)V
|
.method %s dummyMethod(%s)V
|
||||||
.registers %d
|
.registers %d
|
||||||
%s
|
%s
|
||||||
.end method
|
.end method
|
||||||
@@ -35,9 +35,10 @@ class InlineSmaliCompiler {
|
|||||||
fun compileMethodInstructions(
|
fun compileMethodInstructions(
|
||||||
instructions: String,
|
instructions: String,
|
||||||
parameters: String,
|
parameters: String,
|
||||||
registers: Int
|
registers: Int,
|
||||||
|
forStaticMethod: Boolean
|
||||||
): List<BuilderInstruction> {
|
): List<BuilderInstruction> {
|
||||||
val input = METHOD_TEMPLATE.format(parameters, registers, instructions)
|
val input = METHOD_TEMPLATE.format(if (forStaticMethod) "static" else "", parameters, registers, instructions)
|
||||||
val reader = InputStreamReader(input.byteInputStream())
|
val reader = InputStreamReader(input.byteInputStream())
|
||||||
val lexer: LexerErrorInterface = smaliFlexLexer(reader, 15)
|
val lexer: LexerErrorInterface = smaliFlexLexer(reader, 15)
|
||||||
val tokens = CommonTokenStream(lexer as TokenSource)
|
val tokens = CommonTokenStream(lexer as TokenSource)
|
||||||
@@ -58,8 +59,8 @@ class InlineSmaliCompiler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun String.toInstructions(parameters: String = "", registers: Int = 1) =
|
fun String.toInstructions(parameters: String = "", registers: Int = 1, forStaticMethod: Boolean = true) =
|
||||||
InlineSmaliCompiler.compileMethodInstructions(this, parameters, registers)
|
InlineSmaliCompiler.compileMethodInstructions(this, parameters, registers, forStaticMethod)
|
||||||
|
|
||||||
fun String.toInstruction(parameters: String = "", registers: Int = 1) =
|
fun String.toInstruction(parameters: String = "", registers: Int = 1, forStaticMethod: Boolean = true) =
|
||||||
this.toInstructions(parameters, registers).first()
|
this.toInstructions(parameters, registers, forStaticMethod).first()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patcher
|
package app.revanced.patcher.usage
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
@@ -18,21 +18,17 @@ import org.w3c.dom.Element
|
|||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class ExampleResourcePatch : ResourcePatch() {
|
class ExampleResourcePatch : ResourcePatch() {
|
||||||
override fun execute(data: ResourceData): PatchResult {
|
override fun execute(data: ResourceData): PatchResult {
|
||||||
val editor = data.getXmlEditor("AndroidManifest.xml")
|
data.getXmlEditor("AndroidManifest.xml").use { domFileEditor ->
|
||||||
|
val element = domFileEditor // regular DomFileEditor
|
||||||
// regular DomFileEditor
|
.file
|
||||||
val element = editor
|
.getElementsByTagName("application")
|
||||||
.file
|
.item(0) as Element
|
||||||
.getElementsByTagName("application")
|
element
|
||||||
.item(0) as Element
|
.setAttribute(
|
||||||
element
|
"exampleAttribute",
|
||||||
.setAttribute(
|
"exampleValue"
|
||||||
"exampleAttribute",
|
)
|
||||||
"exampleValue"
|
}
|
||||||
)
|
|
||||||
|
|
||||||
// close the editor to write changes
|
|
||||||
editor.close()
|
|
||||||
|
|
||||||
// iterate through all available resources
|
// iterate through all available resources
|
||||||
data.forEach {
|
data.forEach {
|
||||||
|
|||||||
Reference in New Issue
Block a user