Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "main.h"
- #include <fstream>
- Java_org_lwjgl_opengl_WindowsContextImplementation_nSwapBuffers_t origSwapBuffers = NULL;
- Java_org_lwjgl_WindowsSysImplementation_nGetTime_t origGetTime = NULL;
- bool JNICALL hookedJava_org_lwjgl_opengl_WindowsContextImplementation_nSwapBuffers( JNIEnvCrystalix* env, jclass klass, jobject obj ) {
- g_env = env;
- return origSwapBuffers( env, klass, obj );
- }
- #include <iomanip>
- void mainloop( ) {
- if ( !g_env ) {
- g_env = (JNIEnvCrystalix*)attachCurrentThread( );
- fieldObfValue = JNU_GetStaticFieldByName( g_env, nullptr, "auXX", "a", "I" ).i;
- printf( "fieldObfValue: %d\n", fieldObfValue );
- }
- jclass mc_class = g_env->FindClass( "up" );
- jmethodID mtd = g_env->GetStaticMethodID( mc_class, "a", "()Lup;" );
- theMinecraft = g_env->CallStaticObjectMethod( mc_class, mtd );
- if ( !theMinecraft ) {
- printf( "theMinecraft is null\n" );
- return;
- }
- jmethodID method_id = g_env->GetMethodID( g_env->GetObjectClass( theMinecraft ), "a", "()Lvp;" );
- if ( method_id ) {
- thePlayer = g_env->CallObjectMethod( theMinecraft, method_id );
- //printf( "thePlayer: 0x%X\n", thePlayer );
- }
- if ( !thePlayer ) {
- printf( "thePlayer is null\n" );
- Sleep( 1000 );
- return;
- }
- if ( JNU_CallMethodByName( g_env, nullptr, thePlayer, "isOnGround", "()Z" ).z ) {
- union floatint {
- float f;
- int i;
- } f;
- int iMoveForward = JNU_GetFieldByName( g_env, nullptr, thePlayer, "N", "I" ).i ^ fieldObfValue;
- f.i = iMoveForward;
- std::cout << f.f << "\n";
- }
- //
- g_env->DeleteLocalRef( theMinecraft );
- g_env->DeleteLocalRef( thePlayer );
- }
- void StartRoutine( ) {
- printf( "[+]start thread %d\n", __threadid( ) );
- while ( true ) {
- mainloop( );
- Sleep( 5 );
- }
- }
- bool APIENTRY DllMain( HMODULE hModule, DWORD edx, void* )
- {
- if ( edx == DLL_PROCESS_ATTACH ) {
- char buf[ 144 ];
- FreeConsole( );
- AllocConsole( );
- FILE* stream;
- freopen_s( &stream, "conout$", "w", stdout );
- printf( "[+]allocated console\n" );
- if ( MH_Initialize( ) != MH_OK )
- return true;
- printf( "[+]mh init\n" );
- /*auto addr = FindPattern<void*>( "jvm.dll", "4C 8B DC 4D 89 4B ? 49 89 4B ? 55 57 48 81 EC" ); // STALCRAFT
- auto addr = FindPattern<void*>( "jvm.dll", "4C 8B DC 4D 89 4B ? 49 89 4B" ); // HCS
- printf( "jvm_define_class_common -> 0x%X\n", addr );
- MH_CreateHook( addr, hooked_jvm_define_class_common, reinterpret_cast<void**>( &orig_jvm_define_class_common ) );
- MH_EnableHook( addr );
- void* pSwapBuf = FindExportAddress( GetModuleBaseWChar( L"lwjgl64.dll" ), "Java_org_lwjgl_opengl_WindowsContextImplementation_nSwapBuffers" );
- MH_CreateHook( pSwapBuf, hookedJava_org_lwjgl_opengl_WindowsContextImplementation_nSwapBuffers, reinterpret_cast<void**>( &origSwapBuffers ) );
- MH_EnableHook( pSwapBuf );*/
- std::thread( StartRoutine ).detach( );
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement