mirror of
https://github.com/ReVanced/revanced-patcher.git
synced 2026-01-19 09:23:56 +00:00
Compare commits
6 Commits
v1.0.0-dev
...
v1.0.0-dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51fb59a43c | ||
|
|
a78715133c | ||
|
|
e8f6973938 | ||
|
|
3cb1e01587 | ||
|
|
cb4ee207e1 | ||
|
|
ca6b94d943 |
14
CHANGELOG.md
14
CHANGELOG.md
@@ -1,3 +1,17 @@
|
|||||||
|
# [1.0.0-dev.4](https://github.com/ReVancedTeam/revanced-patcher/compare/v1.0.0-dev.3...v1.0.0-dev.4) (2022-03-23)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* give ClassWriter a ClassReader for symtable ([e8f6973](https://github.com/ReVancedTeam/revanced-patcher/commit/e8f6973938c70002f04a86f329aa5b134f6ef649))
|
||||||
|
|
||||||
|
# [1.0.0-dev.3](https://github.com/ReVancedTeam/revanced-patcher/compare/v1.0.0-dev.2...v1.0.0-dev.3) (2022-03-23)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add SafeClassWriter ([ca6b94d](https://github.com/ReVancedTeam/revanced-patcher/commit/ca6b94d943b7067aae87a4e282cfb323811c0462))
|
||||||
|
|
||||||
# [1.0.0-dev.2](https://github.com/ReVancedTeam/revanced-patcher/compare/v1.0.0-dev.1...v1.0.0-dev.2) (2022-03-23)
|
# [1.0.0-dev.2](https://github.com/ReVancedTeam/revanced-patcher/compare/v1.0.0-dev.1...v1.0.0-dev.2) (2022-03-23)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
kotlin.code.style = official
|
kotlin.code.style = official
|
||||||
version = 1.0.0-dev.2
|
version = 1.0.0-dev.4
|
||||||
|
|||||||
@@ -49,21 +49,21 @@ internal class Io(
|
|||||||
fun saveAsJar() {
|
fun saveAsJar() {
|
||||||
val jis = ZipInputStream(bufferedInputStream)
|
val jis = ZipInputStream(bufferedInputStream)
|
||||||
val jos = ZipOutputStream(output)
|
val jos = ZipOutputStream(output)
|
||||||
|
val classReaders = mutableMapOf<String, ClassReader>()
|
||||||
|
|
||||||
// first write all non .class zip entries from the original input stream to the output stream
|
// first write all non .class zip entries from the original input stream to the output stream
|
||||||
// we read it first to close the input stream as fast as possible
|
// we read it first to close the input stream as fast as possible
|
||||||
// TODO(oSumAtrIX): There is currently no way to remove non .class files.
|
// TODO(oSumAtrIX): There is currently no way to remove non .class files.
|
||||||
lateinit var zipEntry: ZipEntry
|
lateinit var zipEntry: ZipEntry
|
||||||
while (jis.nextEntry.also { if (it != null) zipEntry = it } != null) {
|
while (jis.nextEntry.also { if (it != null) zipEntry = it } != null) {
|
||||||
// skip all class files because we added them in the loop above
|
if (zipEntry.name.endsWith(".class")) {
|
||||||
// TODO(oSumAtrIX): Check for zipEntry.isDirectory
|
classReaders[zipEntry.name] = ClassReader(jis.readBytes())
|
||||||
if (zipEntry.name.endsWith(".class")) continue
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// create a new zipEntry and write the contents of the zipEntry to the output stream
|
// create a new zipEntry and write the contents of the zipEntry to the output stream and close it
|
||||||
jos.putNextEntry(ZipEntry(zipEntry))
|
jos.putNextEntry(ZipEntry(zipEntry))
|
||||||
jos.write(jis.readBytes())
|
jos.write(jis.readBytes())
|
||||||
|
|
||||||
// close the newly created zipEntry
|
|
||||||
jos.closeEntry()
|
jos.closeEntry()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,10 +75,14 @@ internal class Io(
|
|||||||
// now write all the patched classes to the output stream
|
// now write all the patched classes to the output stream
|
||||||
for (patchedClass in classes) {
|
for (patchedClass in classes) {
|
||||||
// create a new entry of the patched class
|
// create a new entry of the patched class
|
||||||
jos.putNextEntry(JarEntry(patchedClass.name + ".class"))
|
val name = patchedClass.name + ".class"
|
||||||
|
jos.putNextEntry(JarEntry(name))
|
||||||
|
|
||||||
// parse the patched class to a byte array and write it to the output stream
|
// parse the patched class to a byte array and write it to the output stream
|
||||||
val cw = ClassWriter(ClassWriter.COMPUTE_MAXS or ClassWriter.COMPUTE_FRAMES)
|
val cw = ClassWriter(
|
||||||
|
classReaders[name]!!,
|
||||||
|
ClassWriter.COMPUTE_FRAMES or ClassWriter.COMPUTE_MAXS
|
||||||
|
)
|
||||||
patchedClass.accept(cw)
|
patchedClass.accept(cw)
|
||||||
jos.write(cw.toByteArray())
|
jos.write(cw.toByteArray())
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,6 @@ internal class ReaderTest {
|
|||||||
@Test
|
@Test
|
||||||
fun `read jar containing multiple classes`() {
|
fun `read jar containing multiple classes`() {
|
||||||
val testData = PatcherTest::class.java.getResourceAsStream("/test2.jar")!!
|
val testData = PatcherTest::class.java.getResourceAsStream("/test2.jar")!!
|
||||||
Patcher(testData, ByteArrayOutputStream(), PatcherTest.testSignatures) // reusing test sigs from PatcherTest
|
Patcher(testData, ByteArrayOutputStream(), PatcherTest.testSignatures).save() // reusing test sigs from PatcherTest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user