diff --git a/server/build.gradle.kts b/server/build.gradle.kts index 81e4c06..82b1438 100644 --- a/server/build.gradle.kts +++ b/server/build.gradle.kts @@ -64,7 +64,9 @@ dependencies { implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion") // dex2jar: https://github.com/DexPatcher/dex2jar/releases/tag/v2.1-20190905-lanchon - implementation(fileTree("lib/dex2jar/")) +// implementation(fileTree("lib/dex2jar/")) + implementation("com.github.DexPatcher:dex2jar:v2.1-20190905-lanchon") + // api implementation("io.javalin:javalin:3.12.0") diff --git a/server/lib/dex2jar/ST4-4.0.8.jar b/server/lib/dex2jar/ST4-4.0.8.jar deleted file mode 100644 index 144828b..0000000 Binary files a/server/lib/dex2jar/ST4-4.0.8.jar and /dev/null differ diff --git a/server/lib/dex2jar/antlr-3.5.2.jar b/server/lib/dex2jar/antlr-3.5.2.jar deleted file mode 100644 index 12b6140..0000000 Binary files a/server/lib/dex2jar/antlr-3.5.2.jar and /dev/null differ diff --git a/server/lib/dex2jar/antlr-runtime-3.5.2.jar b/server/lib/dex2jar/antlr-runtime-3.5.2.jar deleted file mode 100644 index d48e3e8..0000000 Binary files a/server/lib/dex2jar/antlr-runtime-3.5.2.jar and /dev/null differ diff --git a/server/lib/dex2jar/antlr4-4.5.jar b/server/lib/dex2jar/antlr4-4.5.jar deleted file mode 100644 index a20a536..0000000 Binary files a/server/lib/dex2jar/antlr4-4.5.jar and /dev/null differ diff --git a/server/lib/dex2jar/antlr4-runtime-4.5.jar b/server/lib/dex2jar/antlr4-runtime-4.5.jar deleted file mode 100644 index 924fcce..0000000 Binary files a/server/lib/dex2jar/antlr4-runtime-4.5.jar and /dev/null differ diff --git a/server/lib/dex2jar/asm-debug-all-5.0.3.jar b/server/lib/dex2jar/asm-debug-all-5.0.3.jar deleted file mode 100644 index c531dea..0000000 Binary files a/server/lib/dex2jar/asm-debug-all-5.0.3.jar and /dev/null differ diff --git a/server/lib/dex2jar/d2j-base-cmd-2.1-20190905-lanchon.jar b/server/lib/dex2jar/d2j-base-cmd-2.1-20190905-lanchon.jar deleted file mode 100644 index 035dcee..0000000 Binary files a/server/lib/dex2jar/d2j-base-cmd-2.1-20190905-lanchon.jar and /dev/null differ diff --git a/server/lib/dex2jar/d2j-jasmin-2.1-20190905-lanchon.jar b/server/lib/dex2jar/d2j-jasmin-2.1-20190905-lanchon.jar deleted file mode 100644 index 3209c77..0000000 Binary files a/server/lib/dex2jar/d2j-jasmin-2.1-20190905-lanchon.jar and /dev/null differ diff --git a/server/lib/dex2jar/d2j-smali-2.1-20190905-lanchon.jar b/server/lib/dex2jar/d2j-smali-2.1-20190905-lanchon.jar deleted file mode 100644 index ffefccd..0000000 Binary files a/server/lib/dex2jar/d2j-smali-2.1-20190905-lanchon.jar and /dev/null differ diff --git a/server/lib/dex2jar/dex-ir-2.1-20190905-lanchon.jar b/server/lib/dex2jar/dex-ir-2.1-20190905-lanchon.jar deleted file mode 100644 index 4803032..0000000 Binary files a/server/lib/dex2jar/dex-ir-2.1-20190905-lanchon.jar and /dev/null differ diff --git a/server/lib/dex2jar/dex-reader-2.1-20190905-lanchon.jar b/server/lib/dex2jar/dex-reader-2.1-20190905-lanchon.jar deleted file mode 100644 index ee7e519..0000000 Binary files a/server/lib/dex2jar/dex-reader-2.1-20190905-lanchon.jar and /dev/null differ diff --git a/server/lib/dex2jar/dex-reader-api-2.1-20190905-lanchon.jar b/server/lib/dex2jar/dex-reader-api-2.1-20190905-lanchon.jar deleted file mode 100644 index df2158e..0000000 Binary files a/server/lib/dex2jar/dex-reader-api-2.1-20190905-lanchon.jar and /dev/null differ diff --git a/server/lib/dex2jar/dex-tools-2.1-20190905-lanchon.jar b/server/lib/dex2jar/dex-tools-2.1-20190905-lanchon.jar deleted file mode 100644 index e249531..0000000 Binary files a/server/lib/dex2jar/dex-tools-2.1-20190905-lanchon.jar and /dev/null differ diff --git a/server/lib/dex2jar/dex-translator-2.1-20190905-lanchon.jar b/server/lib/dex2jar/dex-translator-2.1-20190905-lanchon.jar deleted file mode 100644 index dbb6ad2..0000000 Binary files a/server/lib/dex2jar/dex-translator-2.1-20190905-lanchon.jar and /dev/null differ diff --git a/server/lib/dex2jar/dex-writer-2.1-20190905-lanchon.jar b/server/lib/dex2jar/dex-writer-2.1-20190905-lanchon.jar deleted file mode 100644 index 4feda14..0000000 Binary files a/server/lib/dex2jar/dex-writer-2.1-20190905-lanchon.jar and /dev/null differ diff --git a/server/lib/dex2jar/dx-27.0.3.jar b/server/lib/dex2jar/dx-27.0.3.jar deleted file mode 100644 index 023b8da..0000000 Binary files a/server/lib/dex2jar/dx-27.0.3.jar and /dev/null differ diff --git a/server/lib/dex2jar/open-source-license.txt b/server/lib/dex2jar/open-source-license.txt deleted file mode 100644 index e8669c5..0000000 --- a/server/lib/dex2jar/open-source-license.txt +++ /dev/null @@ -1,67 +0,0 @@ -==== dx-*.jar -Apache 2.0 http://www.apache.org/licenses/LICENSE-2.0.html - - -==== antlr-*.jar -[The BSD License] -Copyright (c) 2003-2007, Terence Parr -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -* Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -* Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. -* Neither the name of the author nor the names of its contributors - may be used to endorse or promote products derived from this - software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. - - -==== asm-*.jar - - ASM: a very small and fast Java bytecode manipulation framework - Copyright (c) 2000-2005 INRIA, France Telecom - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the copyright holders nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - THE POSSIBILITY OF SUCH DAMAGE. - diff --git a/server/lib/dex2jar/org.abego.treelayout.core-1.0.1.jar b/server/lib/dex2jar/org.abego.treelayout.core-1.0.1.jar deleted file mode 100644 index 2350adc..0000000 Binary files a/server/lib/dex2jar/org.abego.treelayout.core-1.0.1.jar and /dev/null differ diff --git a/server/src/main/kotlin/ir/armor/tachidesk/util/Extension.kt b/server/src/main/kotlin/ir/armor/tachidesk/util/Extension.kt index a5d6fbe..44d5a42 100644 --- a/server/src/main/kotlin/ir/armor/tachidesk/util/Extension.kt +++ b/server/src/main/kotlin/ir/armor/tachidesk/util/Extension.kt @@ -4,7 +4,9 @@ package ir.armor.tachidesk.util * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -import com.googlecode.dex2jar.tools.Dex2jarCmd +import com.googlecode.d2j.dex.Dex2jar +import com.googlecode.d2j.reader.MultiDexFileReader +import com.googlecode.dex2jar.tools.BaksmaliBaseDexExceptionHandler import eu.kanade.tachiyomi.extension.api.ExtensionGithubApi import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.NetworkHelper @@ -29,9 +31,43 @@ import java.io.File import java.io.InputStream import java.net.URL import java.net.URLClassLoader +import java.nio.file.Files +import java.nio.file.Path private val logger = KotlinLogging.logger {} +private fun dex2jar(dexFile: String, jarFile: String, fileNameWithoutType: String) { + // adopted from com.googlecode.dex2jar.tools.Dex2jarCmd.doCommandLine + // source at: https://github.com/DexPatcher/dex2jar/tree/v2.1-20190905-lanchon/dex-tools/src/main/java/com/googlecode/dex2jar/tools/Dex2jarCmd.java + + val jarFilePath = File(jarFile).toPath() + val reader = MultiDexFileReader.open(Files.readAllBytes(File(dexFile).toPath())) + val handler = BaksmaliBaseDexExceptionHandler() + Dex2jar + .from(reader) + .withExceptionHandler(handler) + .reUseReg(false) + .topoLogicalSort() + .skipDebug(true) + .optimizeSynchronized(false) + .printIR(false) + .noCode(false) + .skipExceptions(false) + .to(jarFilePath) + if (handler.hasException()) { + val errorFile: Path = File(applicationDirs.extensionsRoot).toPath().resolve("$fileNameWithoutType-error.txt") + logger.error( + "Detail Error Information in File $errorFile\n" + + "Please report this file to one of following link if possible (any one).\n" + + " https://sourceforge.net/p/dex2jar/tickets/\n" + + " https://bitbucket.org/pxb1988/dex2jar/issues\n" + + " https://github.com/pxb1988/dex2jar/issues\n" + + " dex2jar@googlegroups.com" + ) + handler.dump(errorFile, emptyArray()) + } +} + fun installAPK(apkName: String): Int { logger.info("Installing $apkName") val extensionRecord = getExtensionList(true).first { it.apkName == apkName } @@ -55,7 +91,7 @@ fun installAPK(apkName: String): Int { val className: String = APKExtractor.extract_dex_and_read_className(apkFilePath, dexFilePath) logger.info(className) // dex -> jar - Dex2jarCmd.main(dexFilePath, "-o", jarFilePath, "--force") + dex2jar(dexFilePath, jarFilePath, fileNameWithoutType) // clean up File(apkFilePath).delete() @@ -81,7 +117,7 @@ fun installAPK(apkName: String): Int { it[extension] = extensionId } } - logger.info("Installed source ${httpSource.name} with id:${httpSource.id}") + logger.info("Installed source ${httpSource.name} with id {httpSource.id}") } } else { // multi source val sourceFactory = instance as SourceFactory diff --git a/server/src/main/kotlin/ir/armor/tachidesk/util/SourceList.kt b/server/src/main/kotlin/ir/armor/tachidesk/util/SourceList.kt index 3aa99e3..e7105dc 100644 --- a/server/src/main/kotlin/ir/armor/tachidesk/util/SourceList.kt +++ b/server/src/main/kotlin/ir/armor/tachidesk/util/SourceList.kt @@ -36,7 +36,6 @@ fun getHttpSource(sourceId: Long): HttpSource { return cachedResult.second } - val result: HttpSource = transaction { val extensionId = sourceRecord.extension.id.value val extensionRecord = ExtensionEntity.findById(extensionId)!!