Commit Graph

22 Commits

Author SHA1 Message Date
JingMatrix 1436f692fb
Refactor dex2oat wrapper to solve long-standing issues (#515)
Manual library path injection via LD_LIBRARY_PATH has become unreliable due to symbol mismatches in core libraries (e.g., `libc++`) between the system and APEX partitions. Recent updates to `liblog` and `libbase` (in Android 16) have resulted in missing symbols like `__hash_memory` or `fmt` when the ART APEX binaries are forced to load system-partition shims.

This commit switches the wrapper to execute the runtime APEX linker directly (e.g., `/apex/com.android.runtime/bin/linker64`). By passing the dex2oat binary to the linker via `/proc/self/fd/`, the linker can properly initialize internal namespaces and resolve dependencies from the correct APEX and bootstrap locations.

Moreover, for the OatHeader hook, a bug introduced in 6703b45350 is now fixed, where the target functions of PLT hooks are overwritten by the our helper functions.

Details of the refactored project are explained in README.
2026-01-25 10:13:57 +01:00
JingMatrix 6703b45350
Fix oat_hook for recent Android versions (#387)
We used to hook functions `OatHeader::GetKeyValueStore` and `OatHeader::GetKeyValueStoreSize` to clean the `dex2oat` trace introduced by LSPosed. However, in recent versions of Android, these two functions are no longer exported. Moreover, the `OatHeader` structure has changed, which now sets certain entries to have fixed length by padding zeros.

To address these two changes, we hook `OatHeader::ComputeChecksum` as an entrypoint (fallback), and then employ the header file of `OatHeader` copied from AOSP to precisely locate its fields. Using this strategy, we modify `key_value_store` in memory, depending on whether the entry `dex2oat-cmdline` is padded.
2025-08-09 07:36:44 +02:00
JingMatrix 165ad94bf9 Adjust logs for dex2oat
1. Log dex2oat for debugging purpose
2. Avoid log formatting warning of type `dev_t` since it could be `%lu`
   or `%u`
3. Reformat changed files
2025-03-07 07:13:35 +01:00
JingMatrix bfa38b0d53 Fix liboat_hook.so inaccessible in some device (#190)
User has reported `dex2oat` failure with SELinux log:

```
W dex2oat64: type=1400 audit(0.0:922): avc: denied { read } for path="/data/adb/modules/zygisk_lsposed/bin/liboat_hook64.so" dev="dm-58" ino=91204 scontext=u:r:dex2oat:s0 tcontext=u:object_r:adb_data_file:s0 tclass=file permissive=0
```

Hence, we now set the SELinux context of `liboat_hook.so` in Dex2OatService.

Moreover, by the pull-request #194, we have to move `putenv` out of the if block by testing.
Indeed, if we call `putenv` inside the if block, then it is no longer valid out of the block.
2025-02-23 09:30:36 +01:00
JingMatrix c0478f593e
Hook dex2oat functions to remove LSPosed traces (#152)
We use the env LD_PRELOAD to hook the execution of `dex2oat`, which can be directly set to be a file descriptor.
2025-01-08 07:19:18 +01:00
JingMatrix e7a5835d8f
Clear compilation warnings (#121)
* Fix warnings of CMake

To completely remove CMake version warnings, one may need to change the CMakeLists.txt file in the NDK installation.

* Add compiler flag -Wpedantic

Show compilation errors for the core subject, while ignore some of them
2024-12-09 22:15:18 +01:00
JingMatrix 867252fb3b Fix LD_LIBRARY_PATH for dex2oat32
Close #107 as fixed.
2024-12-05 19:26:35 +01:00
JingMatrix b4d59feb27 Add missing LD_LIBRARY_PATH env (#34)
Tests passed on Android 13 and Android 15 devices
2024-09-22 14:25:45 +02:00
JingMatrix 17625a04d5 Fix CMake syntax error
Update cmake version
2024-07-24 01:23:05 +02:00
LoveSy 7aa50bb4f0
Fix dex2oat build 2023-04-15 17:02:54 +00:00
LoveSy f887d0116c
Upgrade gradle (#2487) 2023-04-12 16:46:09 +00:00
LoveSy b069da0323 Refine gradle scripts 2023-02-26 16:48:49 +08:00
南宫雪珊 3d11c2f0f7
Make dex2oat wrapper more compatible (#2372) 2023-02-19 21:24:54 +08:00
Nullptr 205138f638
Fix binary patch (#2096) 2022-08-30 19:14:11 +08:00
LoveSy 02f09247ae
Use striped so for debug build (#2047) 2022-07-25 00:33:00 +08:00
南宫雪珊 05129a0dd8
Set removeUnusedEntriesAfterDays=1 only for CI (#1948) 2022-05-18 07:40:55 +08:00
LoveSy dbc350a75e
Fix hooking internal used methods (#1900) 2022-04-28 11:38:10 +08:00
Nullptr dc6cd4b0fd
Fix incorrect mount point on Android 10 (#1870)
* Detect conditions when dex2oat wrapper doesn't work

* No enum

* Copy

* Update

* Update

* Fix dex2oat wrapper on Android 10

* Stupid typo

* Update dex2oat.cpp

Co-authored-by: LoveSy <shana@zju.edu.cn>
2022-04-21 01:40:48 +00:00
Nullptr ee2c1a3320
Fallback if dex2oat wrapper crashes (#1810)
* Fallback if dex2oat wrapper crashes

* Update daemon/src/main/java/org/lsposed/lspd/service/Dex2OatService.java

Co-authored-by: 残页 <31466456+canyie@users.noreply.github.com>

* Update

Co-authored-by: 残页 <31466456+canyie@users.noreply.github.com>
2022-04-05 09:14:28 +08:00
Nullptr 3ca1478a3a
Optimize dex2oat wrapper (#1805) 2022-04-03 11:30:15 +08:00
Nullptr 668ed3301d
Better way to disable method inline (#1804) 2022-04-02 14:22:18 +08:00
Nullptr 2f9e0e07b0
Resolve dex2oat parameters for Android 10+ (#1803) 2022-04-02 13:13:22 +08:00