Skip to content

Commit

Permalink
反编译崩溃修复
Browse files Browse the repository at this point in the history
* 由于图片使用 java awt 类库,暂不处理
  • Loading branch information
lulululbj committed Oct 24, 2019
1 parent e149830 commit 602f81e
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
23 changes: 20 additions & 3 deletions app/src/main/java/luyao/box/adapter/AppAdapter.kt
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
package luyao.box.adapter

import android.content.Context
import android.os.Environment
import android.util.Log
import android.view.View
import android.widget.ImageButton
import android.widget.PopupMenu
import android.widget.Toast
import com.afollestad.materialdialogs.MaterialDialog
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import jadx.api.JadxArgs
import jadx.api.JadxDecompiler
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.launch
import luyao.box.*
import luyao.box.bean.AppBean
import luyao.box.ui.appManager.AppDetailActivity
Expand Down Expand Up @@ -52,12 +54,27 @@ class AppAdapter(layoutResId: Int = R.layout.item_app) : BaseQuickAdapter<AppBea
R.id.menu_save_apk -> saveApk(helper, context, appBean)
R.id.menu_share_apk -> shareApk(appBean)
R.id.menu_open_in_store -> context.openInAppStore(appBean.packageName)
R.id.menu_app_reverse -> reverseApp(appBean)
}
true
}
popupMenu.show()
}

private fun reverseApp(appBean: AppBean){
val apkFile = File(appBean.sourceDir)

GlobalScope.launch(Dispatchers.IO) {
val args = JadxArgs().apply {
inputFiles.add(apkFile)
outDir = File(Environment.getExternalStorageDirectory(),"jadx")
}
val decompiler = JadxDecompiler(args)
decompiler.load()
decompiler.save()
}
}

private fun saveApk(helper: BaseViewHolder, context: Context, appBean: AppBean) {
MaterialDialog(context)
.title(R.string.backup)
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/menu/menu_app.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
android:id="@+id/menu_app_properties"
android:title="@string/properties"/>

<item
android:id="@+id/menu_app_reverse"
android:title="@string/reverse"/>

<item
android:id="@+id/menu_app_detail"
android:title="@string/app_detail"/>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,6 @@
<string name="hash_sha256">SHA-256</string>
<string name="file">文件</string>
<string name="folder">文件夹</string>
<string name="reverse">反编译</string>

</resources>
2 changes: 2 additions & 0 deletions jadx-core/src/main/java/jadx/api/JadxDecompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ private ExecutorService getSaveExecutor(boolean saveSources, boolean saveResourc

private void appendResourcesSave(ExecutorService executor, File outDir) {
for (ResourceFile resourceFile : getResources()) {
System.out.println("box: save resource "+resourceFile.getName());
executor.execute(new ResourcesSaver(outDir, resourceFile));
}
}
Expand All @@ -196,6 +197,7 @@ private void appendSourcesSave(ExecutorService executor, File outDir) {
if (classFilter != null && !classFilter.test(cls.getFullName())) {
continue;
}
System.out.println("box: save source "+cls.getName());
executor.execute(() -> {
try {
ICodeInfo code = cls.getCodeInfo();
Expand Down
5 changes: 3 additions & 2 deletions jadx-core/src/main/java/jadx/api/ResourcesLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ private static ResContainer loadContent(JadxDecompiler jadxRef, ResourceFile rf,
case ARSC:
return new ResTableParser(jadxRef.getRoot()).decodeFiles(inputStream);

case IMG:
return decodeImage(rf, inputStream);
// TODO 暂不处理图片
// case IMG:
// return decodeImage(rf, inputStream);

default:
return ResContainer.resourceFileLink(rf);
Expand Down

0 comments on commit 602f81e

Please sign in to comment.