Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public class Dex2OatService implements Runnable {
private static final String TAG = "LSPosedDex2Oat";
private static final String WRAPPER32 = "bin/dex2oat32";
private static final String WRAPPER64 = "bin/dex2oat64";
private static final String HOOKER32 = "bin/liboat_hook32.so";
private static final String HOOKER64 = "bin/liboat_hook64.so";

private final String[] dex2oatArray = new String[6];
private final FileDescriptor[] fdArray = new FileDescriptor[6];
Expand Down Expand Up @@ -186,6 +188,8 @@ public void run() {
SELinux.setFileContext(WRAPPER64, xposed_file);
setSockCreateContext("u:r:installd:s0");
}
SELinux.setFileContext(HOOKER32, xposed_file);
SELinux.setFileContext(HOOKER64, xposed_file);
try (var server = new LocalServerSocket(sockPath)) {
setSockCreateContext(null);
while (true) {
Expand Down
14 changes: 9 additions & 5 deletions dex2oat/src/main/cpp/dex2oat.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,15 @@ int main(int argc, char **argv) {
putenv((char *)libenv);
}

// Set LD_PRELOAD to load liboat_hook.so
const int STRING_BUFFER = 50;
char env_str[STRING_BUFFER];
snprintf(env_str, STRING_BUFFER, "LD_PRELOAD=/proc/%d/fd/%d", getpid(), hooker_fd);
putenv(env_str);
if (hooker_fd > 0) {
// Set LD_PRELOAD to load liboat_hook.so
const int STRING_BUFFER = 50;
char env_str[STRING_BUFFER];
snprintf(env_str, STRING_BUFFER, "LD_PRELOAD=/proc/%d/fd/%d", getpid(), hooker_fd);
putenv(env_str);
} else {
LOGE("Unable to read liboat_hook.so");
}

fexecve(stock_fd, (char **)new_argv, environ);

Expand Down