Advertisement
test12333

Untitled

Oct 29th, 2023
742
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.86 KB | None | 0 0
  1. #include "main.h"
  2. #include <fstream>
  3.  
  4. Java_org_lwjgl_opengl_WindowsContextImplementation_nSwapBuffers_t origSwapBuffers = NULL;
  5. Java_org_lwjgl_WindowsSysImplementation_nGetTime_t origGetTime = NULL;
  6.  
  7. bool JNICALL hookedJava_org_lwjgl_opengl_WindowsContextImplementation_nSwapBuffers( JNIEnvCrystalix* env, jclass klass, jobject obj ) {
  8.     g_env = env;
  9.     return origSwapBuffers( env, klass, obj );
  10. }
  11. #include <iomanip>
  12. void mainloop( ) {
  13.     if ( !g_env ) {
  14.         g_env = (JNIEnvCrystalix*)attachCurrentThread( );
  15.         fieldObfValue = JNU_GetStaticFieldByName( g_env, nullptr, "auXX", "a", "I" ).i;
  16.         printf( "fieldObfValue: %d\n", fieldObfValue );
  17.     }
  18.  
  19.     jclass mc_class = g_env->FindClass( "up" );
  20.     jmethodID mtd = g_env->GetStaticMethodID( mc_class, "a", "()Lup;" );
  21.     theMinecraft = g_env->CallStaticObjectMethod( mc_class, mtd );
  22.  
  23.     if ( !theMinecraft ) {
  24.         printf( "theMinecraft is null\n" );
  25.         return;
  26.     }
  27.  
  28.     jmethodID method_id = g_env->GetMethodID( g_env->GetObjectClass( theMinecraft ), "a", "()Lvp;" );
  29.     if ( method_id ) {
  30.         thePlayer = g_env->CallObjectMethod( theMinecraft, method_id );
  31.  
  32.         //printf( "thePlayer: 0x%X\n", thePlayer );
  33.     }
  34.  
  35.     if ( !thePlayer ) {
  36.         printf( "thePlayer is null\n" );
  37.         Sleep( 1000 );
  38.         return;
  39.     }
  40.  
  41.     if ( JNU_CallMethodByName( g_env, nullptr, thePlayer, "isOnGround", "()Z" ).z ) {
  42.         union floatint {
  43.             float f;
  44.             int i;
  45.         } f;
  46.  
  47.         int iMoveForward = JNU_GetFieldByName( g_env, nullptr, thePlayer, "N", "I" ).i ^ fieldObfValue;
  48.         f.i = iMoveForward;
  49.  
  50.         std::cout << f.f << "\n";
  51.     }
  52.     //
  53.     g_env->DeleteLocalRef( theMinecraft );
  54.     g_env->DeleteLocalRef( thePlayer );
  55. }
  56.  
  57. void StartRoutine( ) {
  58.     printf( "[+]start thread %d\n", __threadid( ) );
  59.  
  60.     while ( true ) {
  61.         mainloop( );
  62.         Sleep( 5 );
  63.     }
  64. }
  65.  
  66.  
  67. bool APIENTRY DllMain( HMODULE hModule, DWORD edx, void* )
  68. {
  69.     if ( edx == DLL_PROCESS_ATTACH ) {
  70.         char buf[ 144 ];
  71.  
  72.         FreeConsole( );
  73.         AllocConsole( );
  74.         FILE* stream;
  75.         freopen_s( &stream, "conout$", "w", stdout );
  76.  
  77.         printf( "[+]allocated console\n" );
  78.         if ( MH_Initialize( ) != MH_OK )
  79.             return true;
  80.         printf( "[+]mh init\n" );
  81.  
  82.         /*auto addr = FindPattern<void*>( "jvm.dll", "4C 8B DC 4D 89 4B ? 49 89 4B ? 55 57 48 81 EC" ); // STALCRAFT
  83.         auto addr = FindPattern<void*>( "jvm.dll", "4C 8B DC 4D 89 4B ? 49 89 4B" ); // HCS
  84.         printf( "jvm_define_class_common -> 0x%X\n", addr );
  85.  
  86.         MH_CreateHook( addr, hooked_jvm_define_class_common, reinterpret_cast<void**>( &orig_jvm_define_class_common ) );
  87.         MH_EnableHook( addr );
  88.  
  89.         void* pSwapBuf = FindExportAddress( GetModuleBaseWChar( L"lwjgl64.dll" ), "Java_org_lwjgl_opengl_WindowsContextImplementation_nSwapBuffers" );
  90.         MH_CreateHook( pSwapBuf, hookedJava_org_lwjgl_opengl_WindowsContextImplementation_nSwapBuffers, reinterpret_cast<void**>( &origSwapBuffers ) );
  91.         MH_EnableHook( pSwapBuf );*/
  92.  
  93.         std::thread( StartRoutine ).detach( );
  94.     }
  95.  
  96.     return true;
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement