Skip to content

Commit

Permalink
Create directory
Browse files Browse the repository at this point in the history
  • Loading branch information
TheEasyPeasy committed Apr 21, 2022
1 parent 9c6b83d commit ce22d15
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions jvm_dumper.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include "jvm_dumper.h"
#include "MinHook.h"
#include <stdio.h>
#include <ShlObj_core.h>


const char* folderName = "C:\\JavaClassDump\\";

/* Convert java string to UTF char*. Use local buffer if possible,
otherwise malloc new memory. Returns null IFF malloc failed. */
Expand Down Expand Up @@ -62,9 +64,8 @@ jclass JNICALL hookedDefineClass(JNIEnv* env, jobject loader, jstring name, jbyt
#endif
char finalName[128];
snprintf(finalName, 128, "%s.class", utfName);
const char* folder = "C:\\JavaClassDump\\"; //TODO create dir if not exists
char fullPath[1024];
snprintf(fullPath, 1024, "%s%s", folder, finalName);
snprintf(fullPath, 1024, "%s%s", folderName, finalName);
FILE* out = fopen(fullPath, "wb");
fwrite(body, 1, (*env)->GetArrayLength(env, data), out);
fclose(out);
Expand Down Expand Up @@ -108,5 +109,6 @@ void hookSetup(void) {
puts("Enabling hook failed!");
return;
}
CreateDirectoryA(folderName, NULL);
puts("Java Runtime Class Dumper created by TheEasyPeasy (https://github.com/TheEasyPeasy)");
}

0 comments on commit ce22d15

Please sign in to comment.