6
6
7
7
using namespace std ;
8
8
9
- typedef jclass JNICALL (*JVM_DefineClass)(JNIEnv *env, const char *name, jobject loader,
10
- const jbyte *buf, jsize len, jobject pd);
9
+ typedef jclass JNICALL (*sig_JVM_DefineClass)(JNIEnv *env, const char *name, jobject loader,
10
+ const jbyte *buf, jsize len, jobject pd);
11
+ typedef jclass JNICALL (*sig_JVM_DefineClassWithSource)(JNIEnv *env, const char *name, jobject loader, const jbyte *buf,
12
+ jsize len, jobject pd, const char *source);
13
+ typedef jclass JNICALL (*sig_JVM_DefineClassWithSourceCond)(JNIEnv *env, const char *name,
14
+ jobject loader, const jbyte *buf, jsize len, jobject pd,
15
+ const char *source, jboolean verify);
11
16
12
- typedef jclass JNICALL (*JVM_DefineClassWithSource)(JNIEnv *env, const char *name, jobject loader, const jbyte *buf,
13
- jsize len, jobject pd, const char *source);
14
-
15
- typedef jclass JNICALL (*JVM_DefineClassWithSourceCond)(JNIEnv *env, const char *name, jobject loader, const jbyte *buf,
16
- jsize len, jobject pd, const char *source, jboolean verify);
17
-
18
- JVM_DefineClass orig_JVM_DefineClass = NULL ;
19
- JVM_DefineClassWithSource orig_JVM_DefineClassWithSource = NULL ;
20
- JVM_DefineClassWithSourceCond orig_JVM_DefineClassWithSourceCond = NULL ;
17
+ sig_JVM_DefineClass orig_JVM_DefineClass = NULL ;
18
+ sig_JVM_DefineClassWithSource orig_JVM_DefineClassWithSource = NULL ;
19
+ sig_JVM_DefineClassWithSourceCond orig_JVM_DefineClassWithSourceCond = NULL ;
21
20
22
21
jclass JNICALL detour_JVM_DefineClass (JNIEnv *env, const char *name, jobject loader,
23
22
const jbyte *buf, jsize len, jobject pd) {
@@ -37,21 +36,21 @@ jclass JNICALL detour_JVM_DefineClassWithSourceCond(JNIEnv *env, const char *nam
37
36
return orig_JVM_DefineClassWithSourceCond (env, name, loader, buf, len, pd, source, verify);
38
37
}
39
38
40
- BOOL DoHook () {
39
+ bool doHook () {
41
40
HMODULE hJvm = LoadLibrary (" jvm.dll" );
42
41
if (!hJvm) {
43
42
return FALSE ;
44
43
}
45
- orig_JVM_DefineClass = (JVM_DefineClass ) GetProcAddress (hJvm, " JVM_DefineClass" );
44
+ orig_JVM_DefineClass = (sig_JVM_DefineClass ) GetProcAddress (hJvm, " JVM_DefineClass" );
46
45
if (!orig_JVM_DefineClass) {
47
46
return FALSE ;
48
47
}
49
- orig_JVM_DefineClassWithSource = (JVM_DefineClassWithSource ) GetProcAddress (hJvm, " JVM_DefineClassWithSource" );
48
+ orig_JVM_DefineClassWithSource = (sig_JVM_DefineClassWithSource ) GetProcAddress (hJvm, " JVM_DefineClassWithSource" );
50
49
if (!orig_JVM_DefineClassWithSource) {
51
50
return FALSE ;
52
51
}
53
- orig_JVM_DefineClassWithSourceCond = (JVM_DefineClassWithSourceCond ) GetProcAddress (hJvm,
54
- " JVM_DefineClassWithSourceCond" );
52
+ orig_JVM_DefineClassWithSourceCond = (sig_JVM_DefineClassWithSourceCond ) GetProcAddress (hJvm,
53
+ " JVM_DefineClassWithSourceCond" );
55
54
if (!orig_JVM_DefineClassWithSourceCond) {
56
55
return FALSE ;
57
56
}
@@ -62,10 +61,10 @@ BOOL DoHook() {
62
61
return Mhook_SetHookEx (hooks, 3 ) == 3 ;
63
62
}
64
63
65
- BOOL WINAPI DllMain (HMODULE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
64
+ bool WINAPI DllMain (HMODULE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
66
65
if (fdwReason == DLL_PROCESS_ATTACH) {
67
66
SourceInit ();
68
- if (DoHook ()) {
67
+ if (doHook ()) {
69
68
MessageBox (NULL , " Hooks initialized." , " Success" , MB_OK);
70
69
} else {
71
70
MessageBox (NULL , " Something went wrong." , " Error" , MB_OK);
0 commit comments