fix(injectDex): Fixed the crash issue of the injection loader on some Android.

https://github.com/JingMatrix/LSPatch/pull/68
This commit is contained in:
NkBe 2025-12-08 22:15:53 +08:00
parent 5c8509e4f5
commit efeb758845
No known key found for this signature in database
GPG Key ID: 525137026FF031DF
1 changed files with 17 additions and 1 deletions

View File

@ -101,7 +101,23 @@ public class LSPAppComponentFactoryStub extends AppComponentFactory {
transfer(is, os); transfer(is, os);
dex = os.toByteArray(); dex = os.toByteArray();
} }
soPath = cl.getResource("assets/npatch/so/" + libName + "/libnpatch.so").getPath().substring(5); java.net.URL url = cl.getResource("assets/npatch/so/" + libName + "/libnpatch.so");
if (url == null) {
throw new RuntimeException("Should not happen: libnpatch.so not found in assets");
}
String rawPath = url.getPath();
if (rawPath.startsWith("file:")) {
soPath = rawPath.substring(5);
} else if (rawPath.startsWith("jar:file:")) {
soPath = rawPath.substring(9);
} else {
soPath = rawPath;
}
try {
soPath = java.net.URLDecoder.decode(soPath, "UTF-8");
} catch (java.io.UnsupportedEncodingException e) {
}
Log.i(TAG, "Loading native lib from: " + soPath);
} }
System.load(soPath); System.load(soPath);