diff --git a/module/src/main/cpp/hack_new.cpp b/module/src/main/cpp/hack_new.cpp index 07ecf2f..c8059e5 100644 --- a/module/src/main/cpp/hack_new.cpp +++ b/module/src/main/cpp/hack_new.cpp @@ -88,12 +88,8 @@ void load_so_file_custom_linker(const char *game_data_dir, const Config::SoFile void hack_thread_func(const char *game_data_dir, const char *package_name, JavaVM *vm) { LOGI("Hack thread started for package: %s", package_name); - // Get injection delay from config - int delay = Config::getInjectionDelay(); - LOGI("Waiting %d seconds before injection", delay); - - // Wait for app to initialize and files to be copied - sleep(delay); + // Note: Delay is now handled in main thread before this thread is created + LOGI("Starting injection immediately (delay already applied in main thread)"); // Get injection method for this app Config::InjectionMethod method = Config::getAppInjectionMethod(package_name); diff --git a/module/src/main/cpp/main.cpp b/module/src/main/cpp/main.cpp index 4025c52..dbd24b7 100644 --- a/module/src/main/cpp/main.cpp +++ b/module/src/main/cpp/main.cpp @@ -45,6 +45,13 @@ public: // Get JavaVM JavaVM *vm = nullptr; if (env->GetJavaVM(&vm) == JNI_OK) { + // Get injection delay from config + int delay = Config::getInjectionDelay(); + LOGI("Main thread blocking for %d seconds before injection", delay); + + // Block main thread for the delay period + sleep(delay); + // Then start hack thread with JavaVM std::thread hack_thread(hack_prepare, _data_dir, _package_name, data, length, vm); hack_thread.detach();