Commit Graph

10 Commits

Author SHA1 Message Date
JingMatrix 89b71ebe0a Put original dex files in patched APK
Count the number of dex files and rename classes.dex correctly.
Skip loading lspatch.so when currentActivityThread is null.
2023-12-28 13:29:27 +01:00
LoveSy bbe8d93fb9
Fix typo (#282)
Fix #281
2023-12-13 12:54:48 +08:00
LoveSy c9c5708d2f
Fix getApplicationInfo on non-primary user (#247)
Fix #224
2023-10-12 15:05:23 +08:00
Howard Wu 941726d559
Core upgrade (#213)
Co-authored-by: LoveSy <shana@zju.edu.cn>
2023-06-29 02:17:00 +08:00
南宫雪珊 e79bf0e004
Revert "Handling duplicate System.load calls" (#202)
Reverts LSPosed/LSPatch#200

Let it crash
2023-06-05 14:35:14 +08:00
Harshit Shah f23eb7f32c
Handling duplicate System.load calls (#200)
We have seen apps to be crashing due to multiple System.load calls.
As seen from the log lines:
```
06-01 16:43:41.615 I/LSPosed-Bridge(16031): Caused by: java.lang.UnsatisfiedLinkError: Shared library "/data/app/com.example.sample-some_random_string/base.apk!/assets/lspatch/so/arm64-v8a/liblspatch.so" already opened by ClassLoader 0x1c7(dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.sample-some_random_string/base.apk"],nativeLibraryDirectories=[/data/app/com.example.sample-some_random_string/lib/arm64, /data/app/com.example.sample-some_random_string/base.apk!/lib/arm64-v8a, /system/lib64, /product/lib64]]]); can't open in ClassLoader 0x7ffc869ecc(dalvik.system.PathClassLoader[DexPathList[[zip file "/data/user/0/org.houstonmethodist.methodistmobile.debug/cache/lspatch/origin/4198609975.apk", zip file "/data/app/com.example.sample-some_random_string/base.apk"],nativeLibraryDirectories=[/data/app/com.example.sample-some_random_string/lib/arm64, /data/user/0/org.houstonmethodist.methodistmobile.debug/cache/lspatch/origin/4198609975.apk!/lib/arm64-v8a, /system/lib64, /product/lib64]]])
```
Looks like we are trying to load liblspatch.so file even when it was
loaded earlier by the ClassLoader, due to which it is causing the error.

This is similar to this issue:
https://stackoverflow.com/questions/54155086/preventing-duplicate-system-loadlibrary-calls-when-dynamically-loading-reloading

Have added try ... catch block around `System.load` method to handle
exceptions / error raised from it, and have added log line to debug the
issue in cases of actual errors.
2023-06-05 14:14:22 +08:00
AAGaming e4657377b5
Fix Map.of crash on certain Motorola devices (#186)
Using Map.of here results in compiler optimization generating a class
`a.a` with a method `a` that returns the Map.

The class looks like this (jadx decompilation):
```java
package a;

import java.util.AbstractMap;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/* loaded from: classes.dex */
public abstract /* synthetic */ class a {
    public static /* synthetic */ Map a() {
        Map.Entry[] entryArr = {new AbstractMap.SimpleEntry("arm", "armeabi-v7a"), new AbstractMap.SimpleEntry("arm64", "arm64-v8a"), new AbstractMap.SimpleEntry("x86", "x86"), new AbstractMap.SimpleEntry("x86_64", "x86_64")};
        HashMap hashMap = new HashMap(4);
        for (int i = 0; i < 4; i++) {
            Map.Entry entry = entryArr[i];
            Object key = entry.getKey();
            Objects.requireNonNull(key);
            Object value = entry.getValue();
            Objects.requireNonNull(value);
            if (hashMap.put(key, value) != null) {
                throw new IllegalArgumentException("duplicate key: " + key);
            }
        }
        return Collections.unmodifiableMap(hashMap);
    }
}
```

For whatever ridiculous reason, on a moto g stylus 5G (2022), when this
method is called in `LSPAppComponentFactoryStub`, the app crashes with
`java.lang.NoSuchMethodError: No static method a()Ljava/util/Map; in
class La/a; or its super classes`. Using a normal HashMap here instead
prevents this optimization from occurring, which prevents the crash.
2023-05-01 23:56:24 +08:00
Howard Wu 0964a8eece
Update core to 1.8.6 (#168)
With
- update AGP to 7.4.0
- update Android Build Tools to 33.0.1
2023-01-28 11:54:06 +08:00
Nullptr 0bc6407caf
Further fix for Android 13 2022-10-24 00:41:32 +08:00
Nullptr f8888b81e8
Support bootstrapping loader dynamically for local mode (#118) 2022-10-21 15:24:16 +08:00