Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. // dllmain.cpp : Definisce il punto di ingresso per l'applicazione DLL.
  2. #include "pch.h"
  3. #include "iostream"
  4. #include "fstream"
  5. #include "stdio.h"
  6. #include <jni.h>
  7.  
  8. using namespace std;
  9.  
  10.  
  11. BOOL APIENTRY DllMain( HMODULE hModule,DWORD ul_reason_for_call,LPVOID lpReserved)
  12. {
  13. switch(1)
  14. {
  15. case DLL_PROCESS_ATTACH:
  16. HMODULE m_hDllInstance = LoadLibrary("jvm.dll");
  17. if (m_hDllInstance == 0)
  18. {
  19.  
  20. cout << "jvm.dll error";
  21. }
  22.  
  23. JavaVM* jvm;
  24. JNIEnv* env;
  25.  
  26. typedef jint(JNICALL * GetCreatedJavaVMs)(JavaVM * *, jsize, jsize*);
  27. GetCreatedJavaVMs jni_GetCreatedJavaVMs = (GetCreatedJavaVMs)GetProcAddress(m_hDllInstance, "JNI_GetCreatedJavaVMs");
  28.  
  29. jint size = 1;
  30. jint vmCount;
  31.  
  32. jint ret = jni_GetCreatedJavaVMs(&jvm, size, &vmCount);
  33.  
  34. jint rc = jvm->AttachCurrentThread((void**)& env, NULL);
  35. jclass cls = env->FindClass("net/minecraft/client/entity/EntityPlayerSP");
  36. jfieldID field = env->GetFieldID(cls, "posX", "I");
  37. jint integer = 2;
  38. cout << field;
  39. env->SetIntField(cls, field, integer);
  40. jvm->DetachCurrentThread();
  41.  
  42.  
  43. }
  44. return true;
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement