feat:全局设置增加延迟注入秒数
This commit is contained in:
@@ -31,6 +31,13 @@ namespace Config {
|
||||
} else if (json[valueStart] == 't' || json[valueStart] == 'f') {
|
||||
// Boolean value
|
||||
return (json.substr(valueStart, 4) == "true") ? "true" : "false";
|
||||
} else {
|
||||
// Number value
|
||||
size_t valueEnd = json.find_first_of(",} \t\n", valueStart);
|
||||
if (valueEnd == std::string::npos) {
|
||||
return json.substr(valueStart);
|
||||
}
|
||||
return json.substr(valueStart, valueEnd - valueStart);
|
||||
}
|
||||
|
||||
return "";
|
||||
@@ -118,7 +125,13 @@ namespace Config {
|
||||
std::string hideStr = extractValue(json, "hideInjection");
|
||||
g_config.hideInjection = (hideStr == "true");
|
||||
|
||||
LOGD("Module enabled: %d, hide injection: %d", g_config.enabled, g_config.hideInjection);
|
||||
std::string delayStr = extractValue(json, "injectionDelay");
|
||||
if (!delayStr.empty()) {
|
||||
g_config.injectionDelay = std::stoi(delayStr);
|
||||
}
|
||||
|
||||
LOGD("Module enabled: %d, hide injection: %d, injection delay: %d",
|
||||
g_config.enabled, g_config.hideInjection, g_config.injectionDelay);
|
||||
|
||||
// Parse perAppConfig
|
||||
size_t perAppPos = json.find("\"perAppConfig\"");
|
||||
@@ -212,4 +225,11 @@ namespace Config {
|
||||
}
|
||||
return InjectionMethod::STANDARD;
|
||||
}
|
||||
|
||||
int getInjectionDelay() {
|
||||
if (!g_configLoaded) {
|
||||
readConfig();
|
||||
}
|
||||
return g_config.injectionDelay;
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ namespace Config {
|
||||
struct ModuleConfig {
|
||||
bool enabled = true;
|
||||
bool hideInjection = false;
|
||||
int injectionDelay = 2; // Default 2 seconds
|
||||
std::unordered_map<std::string, AppConfig> perAppConfig;
|
||||
};
|
||||
|
||||
@@ -45,6 +46,9 @@ namespace Config {
|
||||
|
||||
// Get injection method for specific app
|
||||
InjectionMethod getAppInjectionMethod(const std::string& packageName);
|
||||
|
||||
// Get injection delay in seconds
|
||||
int getInjectionDelay();
|
||||
}
|
||||
|
||||
#endif // CONFIG_H
|
||||
@@ -88,8 +88,12 @@ 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);
|
||||
|
||||
// Wait a bit for app to initialize and files to be copied
|
||||
sleep(2);
|
||||
// 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);
|
||||
|
||||
// Get injection method for this app
|
||||
Config::InjectionMethod method = Config::getAppInjectionMethod(package_name);
|
||||
|
||||
Reference in New Issue
Block a user