Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-3-7-sonnet-20250219-thinking-32k· AnthropicHugging Face LMArena Human Preference 140K

make a simple internal memory reader using windows api

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Geminigemini-2.5-flash’s answer.
  1. User

    make a simple internal memory reader using windows api

  2. Claude Assistant
    #include <Windows.h>
    #include <iostream>
    #include <vector>
    #include <iomanip>
    
    int main() {
        // Get process ID
        DWORD processId;
        std::cout << "Enter process ID: ";
        std::cin >> processId;
        
        // Open process
        HANDLE hProcess = OpenProcess(PROCESS_VM_READ, FALSE, processId);
        if (hProcess == NULL) {
            std::cout << "Failed to open process. Error: " << GetLastError() << std::endl;
            return 1;
        }
        
        // Memory address to read
        uintptr_t address;
        std::cout << "Enter memory address (hex): 0x";
        std::cin >> std::hex >> address;
        
        // How many bytes to read
        int size;
        std::cout << "Enter number of bytes to read: ";
        std::cin >> std::dec >> size;
        
        // Allocate buffer
        std::vector<unsigned char> buffer(size);
        
        // Read memory
        SIZE_T bytesRead;
        BOOL result = ReadProcessMemory(hProcess, (LPCVOID)address, buffer.data(), size, &bytesRead);
        
        // Close handle
        CloseHandle(hProcess);
        
        if (!result) {
            std::cout << "Failed to read memory. Error: " << GetLastError() << std::endl;
            return 1;
        }
        
        // Display the read memory
        std::cout << "\nMemory at 0x" << std::hex << address << ":" << std::endl;
        for (size_t i = 0; i < bytesRead; i++) {
            std::cout << std::setw(2) << std::setfill('0') << std::hex 
                      << static_cast<int>(buffer[i]) << " ";
            if ((i + 1) % 16 == 0) std::cout << std::endl;
        }
        std::cout << std::endl;
        
        std::cout << std::dec << "Successfully read " << bytesRead << " bytes." << std::endl;
        
        return 0;
    }
    

    Would you like me to explain or break down the code?

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