Skip to content
TheChatArchiveThe Chat Archive
Metallama-3.3-70b-instruct· MetaHugging Face LMArena Human Preference 140K

I need to create DLL that will be injected into the game. It will do two things - Create…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Kimikimi-k2-0711-preview’s answer.
  1. User

    I need to create DLL that will be injected into the game. It will do two things -

    Create thread on injection Write packet into available free memory place Execute ASM code

    I have some code written in delphi we need to base on that and convert it to C++ we need to make sure that the ASM stays the same! or will do exactly the same.

    Procedure Send_Packet_Raw(packetsize:DWORD); const SendFunc:DWORD=Fn_PacketOut_Send; EncFunc:DWORD=Fn_PacketOut_Encrypt; begin try asm pushad mov ecx,packetsize LEA eax,[PacketAddress] // packet data in own address push ecx push eax MOV ecx,DWORD PTR DS:[ADR_PacketOut_Temp] call EncFunc MOV ecx,DWORD PTR DS:[ADR_PacketOut_Temp] call SendFunc popad end; except end; end;

    Procedure Send_Packet_Array(packet:Cabal_Memory.TByteArray;Delay:DWORD=0); begin WriteIt(ptr(PACKETADDRESS),packet); Send_Packet_Raw(Length(packet)); if Delay > 0 then FixedSleep(Delay); end;

    Where variables are -

    PACKETADDRESS = 0x1AD00000; ADR_PacketOut_Temp = 0x19C454C0; Fn_PacketOut_Encrypt = 0x006687A6; Fn_PacketOut_Send = 0x00668C3A; packet = { 0xE2, 0xB7, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE5, 0x01, 0xB4, 0x10, 0x00, 0x00 };

    I've also had a partial code for starting the thread on inject -

    BOOL WINAPI DllMain ( HMODULE hModule, DWORD dwReason, LPVOID lpvReserved ) { switch ( dwReason ) { case DLL_PROCESS_ATTACH:

    text

        if ( CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)MainThread, NULL, 0, NULL) == NULL ) {
            return FALSE;
        }
        break;
        
    case DLL_PROCESS_DETACH:
        break;
    
    case DLL_THREAD_ATTACH:
        
        break;
    
    case DLL_THREAD_DETACH:
        break;
    

    } return TRUE; }

  2. Meta Assistant

    To create a DLL in C++ that injects into a game and performs the specified tasks, we'll need to convert the provided Delphi code to C++ and ensure the ASM code remains the same or achieves the same functionality.

    Below is the C++ code that accomplishes this:

    #include <Windows.h>
    #include <iostream>
    
    // Define constants
    const DWORD PACKETADDRESS = 0x1AD00000;
    const DWORD ADR_PacketOut_Temp = 0x19C454C0;
    const DWORD Fn_PacketOut_Encrypt = 0x006687A6;
    const DWORD Fn_PacketOut_Send = 0x00668C3A;
    
    // Define the packet data
    const BYTE packet[] = { 0xE2, 0xB7, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE5, 0x01, 0xB4, 0x10, 0x00, 0x00 };
    
    // Function to write packet data to memory
    void WriteIt(DWORD address, const BYTE* packet, DWORD size) {
        memcpy((void*)address, packet, size);
    }
    
    // Function to send packet raw
    void Send_Packet_Raw(DWORD packetsize) {
        __asm {
            pushad
            mov ecx, packetsize
            lea eax, [packet]
            push ecx
            push eax
            mov ecx, DWORD PTR DS:[ADR_PacketOut_Temp]
            call Fn_PacketOut_Encrypt
            mov ecx, DWORD PTR DS:[ADR_PacketOut_Temp]
            call Fn_PacketOut_Send
            popad
        }
    }
    
    // Function to send packet array
    void Send_Packet_Array(const BYTE* packet, DWORD size, DWORD delay) {
        WriteIt(PACKETADDRESS, packet, size);
        Send_Packet_Raw(size);
        if (delay > 0) {
            Sleep(delay);
        }
    }
    
    // Main thread function
    DWORD WINAPI MainThread(LPVOID lpParameter) {
        // Send packet array
        Send_Packet_Array(packet, sizeof(packet), 0);
        return 0;
    }
    
    // DllMain function
    BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpvReserved) {
        switch (dwReason) {
        case DLL_PROCESS_ATTACH:
            // Create main thread
            if (CreateThread(NULL, 0, MainThread, NULL, 0, NULL) == NULL) {
                return FALSE;
            }
            break;
    
        case DLL_PROCESS_DETACH:
            break;
    
        case DLL_THREAD_ATTACH:
            break;
    
        case DLL_THREAD_DETACH:
            break;
        }
        return TRUE;
    }
    

    This C++ code defines the necessary constants, packet data, and functions to write packet data to memory, send packet raw, and send packet array. The MainThread function is the entry point for the main thread, which sends the packet array using the Send_Packet_Array function. The DllMain function creates the main thread when the DLL is attached to the process.

    Note that the __asm block in the Send_Packet_Raw function is specific to the Microsoft Visual C++ compiler and may not work with other compilers. Also, the Sleep function is used to introduce a delay, but you may want to use a more precise timing mechanism depending on your requirements.

    To compile this code, create a new DLL project in Visual Studio, add the above code to the project, and build the DLL. You can then inject the DLL into the game process using your preferred method (e.g., using a DLL injector tool or writing a custom injector).

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.