Skip to content

Commit 81ac5b0

Browse files
authored
Fix and refactor DexParser implementation (#509)
In the LSPosedDexParser constructor, the methodIds array is allocated correctly, but the loop condition is wrong: its length is divided by 3 twice. We rewrite this class in Kotlin, marking the first commit of refactoring LSPosed into Vector.
1 parent 402d398 commit 81ac5b0

File tree

11 files changed

+392
-445
lines changed

11 files changed

+392
-445
lines changed

build.gradle.kts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,16 @@
2020
import com.android.build.api.dsl.ApplicationDefaultConfig
2121
import com.android.build.api.dsl.CommonExtension
2222
import com.android.build.gradle.api.AndroidBasePlugin
23+
import com.ncorti.ktfmt.gradle.tasks.KtfmtFormatTask
2324

2425
plugins {
2526
alias(libs.plugins.lsplugin.cmaker)
2627
alias(libs.plugins.lsplugin.jgit)
2728
alias(libs.plugins.agp.lib) apply false
2829
alias(libs.plugins.agp.app) apply false
2930
alias(libs.plugins.nav.safeargs) apply false
31+
alias(libs.plugins.kotlin) apply false
32+
alias(libs.plugins.ktfmt)
3033
}
3134

3235
cmaker {
@@ -119,3 +122,11 @@ subprojects {
119122
}
120123
}
121124
}
125+
126+
tasks.register<KtfmtFormatTask>("format") {
127+
source = project.fileTree(rootDir)
128+
include("*.gradle.kts", "*/build.gradle.kts")
129+
dependsOn(":xposed:ktfmtFormat")
130+
}
131+
132+
ktfmt { kotlinLangStyle() }

core/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ dependencies {
6262
implementation(projects.hiddenapi.bridge)
6363
implementation(projects.services.daemonService)
6464
implementation(projects.services.managerService)
65+
implementation(projects.xposed)
6566
compileOnly(libs.androidx.annotation)
6667
compileOnly(projects.hiddenapi.stubs)
6768
}

core/src/main/java/org/lsposed/lspd/impl/LSPosedContext.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313
import androidx.annotation.Nullable;
1414

1515
import org.lsposed.lspd.core.BuildConfig;
16-
import org.lsposed.lspd.impl.utils.LSPosedDexParser;
1716
import org.lsposed.lspd.models.Module;
1817
import org.lsposed.lspd.nativebridge.HookBridge;
1918
import org.lsposed.lspd.nativebridge.NativeAPI;
2019
import org.lsposed.lspd.service.ILSPInjectedModuleService;
2120
import org.lsposed.lspd.util.LspModuleClassLoader;
2221
import org.lsposed.lspd.util.Utils.Log;
2322

23+
import org.matrix.vector.impl.utils.VectorDexParser;
24+
2425
import java.io.File;
2526
import java.io.FileNotFoundException;
2627
import java.io.IOException;
@@ -288,7 +289,7 @@ public void log(@NonNull String message, @NonNull Throwable throwable) {
288289

289290
@Override
290291
public DexParser parseDex(@NonNull ByteBuffer dexData, boolean includeAnnotations) throws IOException {
291-
return new LSPosedDexParser(dexData, includeAnnotations);
292+
return new VectorDexParser(dexData, includeAnnotations);
292293
}
293294

294295
@NonNull

0 commit comments

Comments
 (0)