mirror of
https://github.com/ReVanced/revanced-patcher.git
synced 2026-01-11 22:06:18 +00:00
Compare commits
8 Commits
v1.0.0-dev
...
v1.0.0-dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51fb59a43c | ||
|
|
a78715133c | ||
|
|
e8f6973938 | ||
|
|
3cb1e01587 | ||
|
|
cb4ee207e1 | ||
|
|
ca6b94d943 | ||
|
|
6cdb6887d4 | ||
|
|
ab6453ca8a |
21
CHANGELOG.md
21
CHANGELOG.md
@@ -1,3 +1,24 @@
|
||||
# [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)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* set marklimit to Integer.MAX_VALUE ([ab6453c](https://github.com/ReVancedTeam/revanced-patcher/commit/ab6453ca8a02af70da4468c1a63c68dde4d392ef))
|
||||
|
||||
# 1.0.0-dev.1 (2022-03-23)
|
||||
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
kotlin.code.style = official
|
||||
version = 1.0.0-dev.1
|
||||
version = 1.0.0-dev.4
|
||||
|
||||
@@ -20,7 +20,7 @@ internal class Io(
|
||||
private val bufferedInputStream = BufferedInputStream(input)
|
||||
|
||||
fun readFromJar() {
|
||||
bufferedInputStream.mark(0)
|
||||
bufferedInputStream.mark(Integer.MAX_VALUE)
|
||||
// create a BufferedInputStream in order to read the input stream again when calling saveAsJar(..)
|
||||
val jis = JarInputStream(bufferedInputStream)
|
||||
|
||||
@@ -49,21 +49,21 @@ internal class Io(
|
||||
fun saveAsJar() {
|
||||
val jis = ZipInputStream(bufferedInputStream)
|
||||
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
|
||||
// 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.
|
||||
lateinit var zipEntry: ZipEntry
|
||||
while (jis.nextEntry.also { if (it != null) zipEntry = it } != null) {
|
||||
// skip all class files because we added them in the loop above
|
||||
// TODO(oSumAtrIX): Check for zipEntry.isDirectory
|
||||
if (zipEntry.name.endsWith(".class")) continue
|
||||
if (zipEntry.name.endsWith(".class")) {
|
||||
classReaders[zipEntry.name] = ClassReader(jis.readBytes())
|
||||
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.write(jis.readBytes())
|
||||
|
||||
// close the newly created zipEntry
|
||||
jos.closeEntry()
|
||||
}
|
||||
|
||||
@@ -75,10 +75,14 @@ internal class Io(
|
||||
// now write all the patched classes to the output stream
|
||||
for (patchedClass in classes) {
|
||||
// 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
|
||||
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)
|
||||
jos.write(cw.toByteArray())
|
||||
|
||||
|
||||
@@ -7,6 +7,6 @@ internal class ReaderTest {
|
||||
@Test
|
||||
fun `read jar containing multiple classes`() {
|
||||
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