mirror of
https://github.com/xiaozhou233/JuiceAgent.git
synced 2026-12-05 13:05:53 +08:00
[Update] BootstrapAPI
[Add] Entry can use JuiceLoader Now!
This commit is contained in:
1 parent
1e11e7e164
commit
d01517f09c
4 files changed
+33
-8
No files matched your search
+27
-6
@@ -23,15 +23,30 @@ DWORD WINAPI ThreadProc(LPVOID lpParam) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
log_info("%s ThreadProc got param: \nJuiceLoaderJarPath: %s\nJuiceLoaderLibPath: %s\nEntryJarPath: %s", LOG_PREFIX,
|
||||
log_info("%s ThreadProc got param: \nJuiceLoaderJarPath: %s\nJuiceLoaderLibPath: %s\nEntryJarPath: %s\nBootstrapApiPath: %s", LOG_PREFIX,
|
||||
param->JuiceLoaderJarPath,
|
||||
param->JuiceLoaderLibPath,
|
||||
param->EntryJarPath);
|
||||
param->EntryJarPath,
|
||||
param->BootstrapApiPath);
|
||||
|
||||
const char* bootstrapApiJar = param->BootstrapApiPath;
|
||||
if (bootstrapApiJar == NULL) {
|
||||
log_error("%s BootstrapApiPath is not set", LOG_PREFIX);
|
||||
MessageBoxA(NULL, "BootstrapApiPath is not set", "Error", MB_OK);
|
||||
return 1;
|
||||
}
|
||||
|
||||
log_trace("%s Checking bootstrap-api.jar", LOG_PREFIX);
|
||||
if (access(bootstrapApiJar, 0) == -1) {
|
||||
log_error("%s bootstrap-api.jar not found", LOG_PREFIX);
|
||||
MessageBoxA(NULL, "bootstrap-api.jar not found", "Error", MB_OK);
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char* loaderJar = param->JuiceLoaderJarPath;
|
||||
if (loaderJar == NULL) {
|
||||
log_error("%s LoaderDir is not set", LOG_PREFIX);
|
||||
MessageBoxA(NULL, "LoaderDir is not set", "Error", MB_OK);
|
||||
log_error("%s JuiceLoaderJarPath is not set", LOG_PREFIX);
|
||||
MessageBoxA(NULL, "JuiceLoaderJarPath is not set", "Error", MB_OK);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -81,6 +96,10 @@ DWORD WINAPI ThreadProc(LPVOID lpParam) {
|
||||
log_info("%s Enabled jvmti", LOG_PREFIX);
|
||||
|
||||
// Inject jars
|
||||
log_info("%s injecting bootstrap-api jar...", LOG_PREFIX);
|
||||
(*jvmti)->AddToBootstrapClassLoaderSearch(jvmti, bootstrapApiJar);
|
||||
log_info("%s injected bootstrap-api jar", LOG_PREFIX);
|
||||
|
||||
log_info("%s injecting loader jar...", LOG_PREFIX);
|
||||
(*jvmti)->AddToBootstrapClassLoaderSearch(jvmti, loaderJar);
|
||||
log_info("%s injected loader jar", LOG_PREFIX);
|
||||
@@ -143,11 +162,13 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpReserved){
|
||||
safe_copy(localParm->JuiceLoaderJarPath, remoteParm->JuiceLoaderJarPath, sizeof(localParm->JuiceLoaderJarPath));
|
||||
safe_copy(localParm->JuiceLoaderLibPath, remoteParm->JuiceLoaderLibPath, sizeof(localParm->JuiceLoaderLibPath));
|
||||
safe_copy(localParm->EntryJarPath, remoteParm->EntryJarPath, sizeof(localParm->EntryJarPath));
|
||||
safe_copy(localParm->BootstrapApiPath, remoteParm->BootstrapApiPath, sizeof(localParm->BootstrapApiPath));
|
||||
|
||||
log_info("%s DllMain got param: \nJuiceLoaderJarPath: %s\nJuiceLoaderLibPath: %s\nEntryJarPath: %s", LOG_PREFIX,
|
||||
log_info("%s DllMain got param: \nJuiceLoaderJarPath: %s\nJuiceLoaderLibPath: %s\nEntryJarPath: %s\nBootstrapApiPath: %s", LOG_PREFIX,
|
||||
localParm->JuiceLoaderJarPath,
|
||||
localParm->JuiceLoaderLibPath,
|
||||
localParm->EntryJarPath);
|
||||
localParm->EntryJarPath,
|
||||
localParm->BootstrapApiPath);
|
||||
|
||||
HANDLE hThread = CreateThread(NULL, 0, ThreadProc, localParm, 0, NULL);
|
||||
if (hThread) {
|
||||
|
||||
@@ -13,7 +13,7 @@ extern "C" {
|
||||
* Signature: (ILjava/lang/String;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_cn_xiaozhou233_orangex_injector_InjectorNative_inject
|
||||
(JNIEnv *, jobject, jint, jstring, jstring, jstring, jstring);
|
||||
(JNIEnv *, jobject, jint, jstring, jstring, jstring, jstring, jstring);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -223,12 +223,13 @@ int inject_pid(int pid){
|
||||
|
||||
/* JNI interface */
|
||||
JNIEXPORT jboolean JNICALL Java_cn_xiaozhou233_orangex_injector_InjectorNative_inject
|
||||
(JNIEnv *env, jobject obj, jint pid,jstring jAgentPth, jstring jJuiceLoaderJarPath, jstring jJuiceLoaderLibPath, jstring jEntryJarPath) {
|
||||
(JNIEnv *env, jobject obj, jint pid,jstring jAgentPth, jstring jJuiceLoaderJarPath, jstring jJuiceLoaderLibPath, jstring jEntryJarPath, jstring jBootStrapApiPath) {
|
||||
|
||||
const char* localAgentPath = (*env)->GetStringUTFChars(env, jAgentPth, NULL);
|
||||
const char* localLoaderJar = (*env)->GetStringUTFChars(env, jJuiceLoaderJarPath, NULL);
|
||||
const char* localLoaderLib = (*env)->GetStringUTFChars(env, jJuiceLoaderLibPath, NULL);
|
||||
const char* localEntryJar = (*env)->GetStringUTFChars(env, jEntryJarPath, NULL);
|
||||
const char* bootstrapApiPath = (*env)->GetStringUTFChars(env, jBootStrapApiPath, NULL);
|
||||
|
||||
InjectParameters params;
|
||||
memset(¶ms, 0, sizeof(params));
|
||||
@@ -236,6 +237,7 @@ JNIEXPORT jboolean JNICALL Java_cn_xiaozhou233_orangex_injector_InjectorNative_i
|
||||
strncpy(params.JuiceLoaderJarPath, localLoaderJar ? localLoaderJar : "", sizeof(params.JuiceLoaderJarPath)-1);
|
||||
strncpy(params.JuiceLoaderLibPath, localLoaderLib ? localLoaderLib : "", sizeof(params.JuiceLoaderLibPath)-1);
|
||||
strncpy(params.EntryJarPath, localEntryJar ? localEntryJar : "", sizeof(params.EntryJarPath)-1);
|
||||
strncpy(params.BootstrapApiPath, bootstrapApiPath ? bootstrapApiPath : "", sizeof(params.BootstrapApiPath)-1);
|
||||
|
||||
int ret = inject(pid, (char*)localAgentPath, ¶ms);
|
||||
|
||||
@@ -243,6 +245,7 @@ JNIEXPORT jboolean JNICALL Java_cn_xiaozhou233_orangex_injector_InjectorNative_i
|
||||
if (localLoaderJar) (*env)->ReleaseStringUTFChars(env, jJuiceLoaderJarPath, localLoaderJar);
|
||||
if (localLoaderLib) (*env)->ReleaseStringUTFChars(env, jJuiceLoaderLibPath, localLoaderLib);
|
||||
if (localEntryJar) (*env)->ReleaseStringUTFChars(env, jEntryJarPath, localEntryJar);
|
||||
if (bootstrapApiPath) (*env)->ReleaseStringUTFChars(env, jBootStrapApiPath, bootstrapApiPath);
|
||||
|
||||
return (ret == 0) ? JNI_TRUE : JNI_FALSE;
|
||||
}
|
||||
Reference in new issue
Block a user