mirror of
https://github.com/xiaozhou233/JuiceAgent.git
synced 2026-12-05 13:05:53 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f317ea3e8d | ||
|
|
8b2ab3e588 |
No files matched your search
+1
-1
@@ -7,7 +7,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
# version
|
||||
set(PROJECT_VERSION_MAJOR 1)
|
||||
set(PROJECT_VERSION_MINOR 1)
|
||||
set(PROJECT_BUILD_NUMBER 25)
|
||||
set(PROJECT_BUILD_NUMBER 27)
|
||||
set(PROJECT_VERSION_STRING "v${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}-b${PROJECT_BUILD_NUMBER}")
|
||||
message(STATUS " ======== Build version: ${PROJECT_VERSION_STRING} ======== ")
|
||||
|
||||
|
||||
+49
-2
@@ -274,8 +274,52 @@ static void JNICALL vm_init(jvmtiEnv *jvmti, JNIEnv *env, jthread thread) {
|
||||
|
||||
log_info("Version: %d", (*env)->GetVersion(env));
|
||||
|
||||
//TODO: Impl vm_init and load agent
|
||||
// TODO: Remove Duplicated Code
|
||||
|
||||
// Check if agentpath_options is null
|
||||
if (agentpath_options == NULL) {
|
||||
// Use DLL path as default
|
||||
log_info("agentpath_options is null, use DLL path as default");
|
||||
char DllDir[INJECT_PATH_MAX] = {0};
|
||||
|
||||
if (GetModuleFileNameA(hAppInstance, DllDir, INJECT_PATH_MAX) == 0) {
|
||||
// Failed to get module file name
|
||||
DWORD err = GetLastError();
|
||||
if (err == ERROR_MOD_NOT_FOUND) {
|
||||
// Reflective detected, lpReserved must be set.
|
||||
log_fatal("Reflective load detected! Please set ConfigDir manually! Exit.");
|
||||
} else {
|
||||
log_error("Normal Inject: GetModuleFileNameA failed! Error: %lu", err);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
// Normal Inject(e.g. CreateRemoteThread+LoadLibraryA), lpReserved can be NULL.
|
||||
PathRemoveFileSpecA(DllDir);
|
||||
log_info("GetModuleFileNameA: %s", DllDir);
|
||||
agentpath_options = DllDir;
|
||||
}
|
||||
}
|
||||
log_trace("agentpath_options: %s", agentpath_options);
|
||||
|
||||
// Allocate memory for InjectParameters
|
||||
InjectParameters *localParm = (InjectParameters*)malloc(sizeof(InjectParameters));
|
||||
if (localParm == NULL) {
|
||||
log_error("malloc failed for InjectParameters");
|
||||
return;
|
||||
}
|
||||
memset(localParm, 0, sizeof(InjectParameters));
|
||||
|
||||
// safe copy
|
||||
safe_copy(localParm->ConfigDir, agentpath_options, INJECT_PATH_MAX);
|
||||
|
||||
// Start new thread
|
||||
HANDLE hThread = CreateThread(NULL, 0, ThreadProc, localParm, 0, NULL);
|
||||
if (hThread) {
|
||||
CloseHandle(hThread);
|
||||
} else {
|
||||
log_error("CreateThread failed %lu", GetLastError());
|
||||
free(localParm);
|
||||
}
|
||||
}
|
||||
|
||||
/// =========================================================== ///
|
||||
@@ -310,4 +354,7 @@ JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *vm, char *options, void *reserved) {
|
||||
|
||||
log_info("Agent_OnLoad: Done, waiting for JVM Init event.");
|
||||
return JNI_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/// Inject Method: JVM Options -agentpath
|
||||
/// =========================================================== ///
|
||||
Reference in new issue
Block a user