Thread: Memory hacking

Results 1 to 2 of 2
  1. #1
    rida_44's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Posts
    8
    Reputation
    10
    Thanks
    0

    Memory hacking

    console trainer base [CREDITS] Kwak
    //==============================
    [HTML]#include <iostream>
    #include <Windows.h>
    #include <string>
    #include <ctime>

    std::string GameStatus;
    bool IsGameAvailable;
    bool UpdateOnNextRun;

    //////////////////////////////
    // Params //
    //////////////////////////////

    // Game window title
    LPCSTR LGameWindow = "MyGame"; // MODIFY ME --------------

    // Feature 1
    std::string sFeature1Status = "OFF";
    bool Feature1Status;
    int iFeature1Key = VK_F1; // EDIT ME --------------
    std::string sFeature1Key = "F1"; // EDIT ME --------------
    std::string sFeature1Desc = "Feature 1"; // EDIT ME --------------
    BYTE Feature1Value[] = {0xF, 0xF, 0x0, 0x0}; // EDIT ME --------------
    DWORD Feature1BaseAddress = {0x00000000}; // EDIT ME --------------
    int iFeature1Levels = 2; // EDIT ME --------------
    DWORD Feature1Offsets[] = {0x0, 0x0}; // EDIT ME --------------

    // Feature 2
    std::string sFeature2Status = "OFF";
    bool Feature2Status;
    int iFeature2Key = VK_F2; // EDIT ME --------------
    std::string sFeature2Key = "F2"; // EDIT ME --------------
    std::string sFeature2Desc = "Feature 2"; // EDIT ME --------------
    BYTE Feature2Value[] = {0xF, 0xF, 0x0, 0x0}; // EDIT ME --------------
    DWORD Feature2BaseAddress = {0x00000000}; // EDIT ME --------------
    int iFeature2Levels = 2; // EDIT ME --------------
    DWORD Feature2Offsets[] = {0x0, 0x0}; // EDIT ME --------------

    // Feature 3
    std::string sFeature3Status = "OFF";
    bool Feature3Status;
    int iFeature3Key = VK_F3; // EDIT ME --------------
    std::string sFeature3Key = "F3"; // EDIT ME --------------
    std::string sFeature3Desc = "Feature 3"; // EDIT ME --------------
    BYTE Feature3Value[] = {0xF, 0xF, 0x0, 0x0}; // EDIT ME --------------
    DWORD Feature3BaseAddress = {0x00000000}; // EDIT ME --------------
    int iFeature3Levels = 2; // EDIT ME --------------
    DWORD Feature3Offsets[] = {0x0, 0x0}; // EDIT ME --------------

    DWORD findDmaAddress(HANDLE hProcHandle, int levelNumber, DWORD Offsets[], DWORD BaseAddress)
    {
    DWORD pointer = BaseAddress;
    DWORD pTemp;
    DWORD pointerAddress;

    for (int i=0; i<levelNumber; i++)
    {
    if (i == 0)
    {
    ReadProcessMemory(hProcHandle, (LPCVOID) pointer, &pTemp, sizeof(pTemp), NULL);
    }

    pointerAddress = pTemp + Offsets[i];
    ReadProcessMemory(hProcHandle, (LPCVOID) pointerAddress, &pTemp, sizeof(pTemp), NULL);
    }

    return pointerAddress;
    }

    int main()
    {
    HWND hGameWindow = NULL;
    int iTimeSinceLastUpdate = clock();
    int iGameAvailableTMR = clock();
    int iOnePressTMR = clock();
    DWORD dwProcID = NULL;
    HANDLE hProcHandle = NULL;
    UpdateOnNextRun = true;

    while (!GetAsyncKeyState(VK_INSERT))
    {
    if (clock() - iGameAvailableTMR > 100)
    {
    iGameAvailableTMR = clock();
    IsGameAvailable = false;
    hGameWindow = FindWindow(NULL, LGameWindow);
    if (hGameWindow)
    {
    GetWindowThreadProcessId(hGameWindow, &dwProcID);
    if (dwProcID != 0)
    {
    hProcHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwProcID);
    if (hProcHandle == INVALID_HANDLE_VALUE || hProcHandle == NULL)
    {
    GameStatus = "[ERROR] Failed to open process for valid handle";
    }
    else
    {
    GameStatus = "[SUCCESS] Game is ready to hack";
    IsGameAvailable = true;
    }
    }
    else
    {
    GameStatus = "[ERROR] Failed to get process ID";
    }
    }
    else
    {
    GameStatus = "[ERROR] Game cannot be found";
    }
    }

    if (UpdateOnNextRun || clock() - iTimeSinceLastUpdate > 5000)
    {
    system("cls");
    std::cout << "--------------------------------------------" << std::endl;
    std::cout << " MMHT" << std::endl;
    std::cout << " My memory hack tool" << std::endl;
    std::cout << "--------------------------------------------" << std::endl << std::endl;
    std::cout << "Status: " << GameStatus << std::endl << std::endl;
    std::cout << "[" << sFeature1Key << "] " << sFeature1Desc << " ->" << sFeature1Status << "<-" << std::endl;
    std::cout << "[" << sFeature2Key << "] " << sFeature2Desc << " ->" << sFeature2Status << "<-" << std::endl;
    std::cout << "[" << sFeature3Key << "] " << sFeature3Desc << " ->" << sFeature3Status << "<-" << std::endl;
    std::cout << std::endl << "[INSERT] Exit" << std::endl;

    UpdateOnNextRun = false;
    iTimeSinceLastUpdate = clock();
    }

    if (IsGameAvailable)
    {
    DWORD AddressToWrite;

    // Memory hacking
    if (Feature1Status)
    {
    AddressToWrite = findDmaAddress(hProcHandle, iFeature1Levels, Feature1Offsets, Feature1BaseAddress);
    WriteProcessMemory(hProcHandle, (BYTE*) AddressToWrite, &Feature1Value, sizeof(Feature1Value), NULL);
    }
    else if (Feature2Status)
    {
    AddressToWrite = findDmaAddress(hProcHandle, iFeature2Levels, Feature2Offsets, Feature2BaseAddress);
    WriteProcessMemory(hProcHandle, (BYTE*) AddressToWrite, &Feature2Value, sizeof(Feature2Value), NULL);
    }
    else if (Feature3Status)
    {
    AddressToWrite = findDmaAddress(hProcHandle, iFeature3Levels, Feature3Offsets, Feature3BaseAddress);
    WriteProcessMemory(hProcHandle, (BYTE*) AddressToWrite, &Feature3Value, sizeof(Feature3Value), NULL);
    }
    }

    if (IsGameAvailable && clock() - iOnePressTMR > 400)
    {
    // Key pressed
    if (GetAsyncKeyState(iFeature1Key))
    {
    iOnePressTMR = clock();
    Feature1Status = !Feature1Status;
    UpdateOnNextRun = true;
    sFeature1Status = Feature1Status ? "ON" : "OFF";
    }
    else if (GetAsyncKeyState(iFeature2Key))
    {
    iOnePressTMR = clock();
    Feature2Status = !Feature2Status;
    UpdateOnNextRun = true;
    sFeature2Status = Feature2Status ? "ON" : "OFF";
    }
    else if (GetAsyncKeyState(iFeature3Key))
    {
    iOnePressTMR = clock();
    Feature3Status = !Feature3Status;
    UpdateOnNextRun = true;
    sFeature3Status = Feature3Status ? "ON" : "OFF";
    }
    }
    }

    CloseHandle(hProcHandle);
    CloseHandle(hGameWindow);

    return ERROR_SUCCESS;
    }[/HTML]
    Last edited by rida_44; 11-27-2012 at 12:41 PM.

  2. #2
    Geomatrical the 7th's Avatar
    Join Date
    Oct 2012
    Gender
    male
    Location
    ?
    Posts
    669
    Reputation
    17
    Thanks
    768
    Code:
    #include <iostream>
     #include <Windows.h>
     #include <string>
     #include <ctime>
    
     std::string GameStatus;
     bool IsGameAvailable;
     bool UpdateOnNextRun;
    
     //////////////////////////////
     // Params //
     //////////////////////////////
    
     // Game window title
     LPCSTR LGameWindow = "MyGame"; // MODIFY ME --------------
    
     // Feature 1
     std::string sFeature1Status = "OFF";
     bool Feature1Status;
     int iFeature1Key = VK_F1; // EDIT ME --------------
     std::string sFeature1Key = "F1"; // EDIT ME --------------
     std::string sFeature1Desc = "Feature 1"; // EDIT ME --------------
     BYTE Feature1Value[] = {0xF, 0xF, 0x0, 0x0}; // EDIT ME --------------
     DWORD Feature1BaseAddress = {0x00000000}; // EDIT ME --------------
     int iFeature1Levels = 2; // EDIT ME --------------
     DWORD Feature1Offsets[] = {0x0, 0x0}; // EDIT ME --------------
    
     // Feature 2
     std::string sFeature2Status = "OFF";
     bool Feature2Status;
     int iFeature2Key = VK_F2; // EDIT ME --------------
     std::string sFeature2Key = "F2"; // EDIT ME --------------
     std::string sFeature2Desc = "Feature 2"; // EDIT ME --------------
     BYTE Feature2Value[] = {0xF, 0xF, 0x0, 0x0}; // EDIT ME --------------
     DWORD Feature2BaseAddress = {0x00000000}; // EDIT ME --------------
     int iFeature2Levels = 2; // EDIT ME --------------
     DWORD Feature2Offsets[] = {0x0, 0x0}; // EDIT ME --------------
    
     // Feature 3
     std::string sFeature3Status = "OFF";
     bool Feature3Status;
     int iFeature3Key = VK_F3; // EDIT ME --------------
     std::string sFeature3Key = "F3"; // EDIT ME --------------
     std::string sFeature3Desc = "Feature 3"; // EDIT ME --------------
     BYTE Feature3Value[] = {0xF, 0xF, 0x0, 0x0}; // EDIT ME --------------
     DWORD Feature3BaseAddress = {0x00000000}; // EDIT ME --------------
     int iFeature3Levels = 2; // EDIT ME --------------
     DWORD Feature3Offsets[] = {0x0, 0x0}; // EDIT ME --------------
    
     DWORD findDmaAddress(HANDLE hProcHandle, int levelNumber, DWORD Offsets[], DWORD BaseAddress)
     {
     DWORD pointer = BaseAddress;
     DWORD pTemp;
     DWORD pointerAddress;
    
     for (int i=0; i<levelNumber; i++)
     {
     if (i == 0)
     {
     ReadProcessMemory(hProcHandle, (LPCVOID) pointer, &pTemp, sizeof(pTemp), NULL);
     }
    
     pointerAddress = pTemp + Offsets[i];
     ReadProcessMemory(hProcHandle, (LPCVOID) pointerAddress, &pTemp, sizeof(pTemp), NULL);
     }
    
     return pointerAddress;
     }
    
     int main()
     {
     HWND hGameWindow = NULL;
     int iTimeSinceLastUpdate = clock();
     int iGameAvailableTMR = clock();
     int iOnePressTMR = clock();
     DWORD dwProcID = NULL;
     HANDLE hProcHandle = NULL;
     UpdateOnNextRun = true;
    
     while (!GetAsyncKeyState(VK_INSERT))
     {
     if (clock() - iGameAvailableTMR > 100)
     {
     iGameAvailableTMR = clock();
     IsGameAvailable = false;
     hGameWindow = FindWindow(NULL, LGameWindow);
     if (hGameWindow)
     {
     GetWindowThreadProcessId(hGameWindow, &dwProcID);
     if (dwProcID != 0)
     {
     hProcHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwProcID);
     if (hProcHandle == INVALID_HANDLE_VALUE || hProcHandle == NULL)
     {
     GameStatus = "[ERROR] Failed to open process for valid handle";
     }
     else
     {
     GameStatus = "[SUCCESS] Game is ready to hack";
     IsGameAvailable = true;
     }
     }
     else
     {
     GameStatus = "[ERROR] Failed to get process ID";
     }
     }
     else
     {
     GameStatus = "[ERROR] Game cannot be found";
     }
     }
    
     if (UpdateOnNextRun || clock() - iTimeSinceLastUpdate > 5000)
     {
     system("cls");
     std::cout << "--------------------------------------------" << std::endl;
     std::cout << " MMHT" << std::endl;
     std::cout << " My memory hack tool" << std::endl;
     std::cout << "--------------------------------------------" << std::endl << std::endl;
     std::cout << "Status: " << GameStatus << std::endl << std::endl;
     std::cout << "[" << sFeature1Key << "] " << sFeature1Desc << " ->" << sFeature1Status << "<-" << std::endl;
     std::cout << "[" << sFeature2Key << "] " << sFeature2Desc << " ->" << sFeature2Status << "<-" << std::endl;
     std::cout << "[" << sFeature3Key << "] " << sFeature3Desc << " ->" << sFeature3Status << "<-" << std::endl;
     std::cout << std::endl << "[INSERT] Exit" << std::endl;
    
     UpdateOnNextRun = false;
     iTimeSinceLastUpdate = clock();
     }
    
     if (IsGameAvailable)
     {
     DWORD AddressToWrite;
    
     // Memory hacking
     if (Feature1Status)
     {
     AddressToWrite = findDmaAddress(hProcHandle, iFeature1Levels, Feature1Offsets, Feature1BaseAddress);
     WriteProcessMemory(hProcHandle, (BYTE*) AddressToWrite, &Feature1Value, sizeof(Feature1Value), NULL);
     }
     else if (Feature2Status)
     {
     AddressToWrite = findDmaAddress(hProcHandle, iFeature2Levels, Feature2Offsets, Feature2BaseAddress);
     WriteProcessMemory(hProcHandle, (BYTE*) AddressToWrite, &Feature2Value, sizeof(Feature2Value), NULL);
     }
     else if (Feature3Status)
     {
     AddressToWrite = findDmaAddress(hProcHandle, iFeature3Levels, Feature3Offsets, Feature3BaseAddress);
     WriteProcessMemory(hProcHandle, (BYTE*) AddressToWrite, &Feature3Value, sizeof(Feature3Value), NULL);
     }
     }
    
     if (IsGameAvailable && clock() - iOnePressTMR > 400)
     {
     // Key pressed
     if (GetAsyncKeyState(iFeature1Key))
     {
     iOnePressTMR = clock();
     Feature1Status = !Feature1Status;
     UpdateOnNextRun = true;
     sFeature1Status = Feature1Status ? "ON" : "OFF";
     }
     else if (GetAsyncKeyState(iFeature2Key))
     {
     iOnePressTMR = clock();
     Feature2Status = !Feature2Status;
     UpdateOnNextRun = true;
     sFeature2Status = Feature2Status ? "ON" : "OFF";
     }
     else if (GetAsyncKeyState(iFeature3Key))
     {
     iOnePressTMR = clock();
     Feature3Status = !Feature3Status;
     UpdateOnNextRun = true;
     sFeature3Status = Feature3Status ? "ON" : "OFF";
     }
     }
     }
    
     CloseHandle(hProcHandle);
     CloseHandle(hGameWindow);
    
     return ERROR_SUCCESS;
     }

Similar Threads

  1. Source code for any d3d/memory hack
    By Ragehax in forum C++/C Programming
    Replies: 6
    Last Post: 10-01-2009, 10:10 PM
  2. Wats possible and not possible through memory hacking?
    By ClanTag in forum C++/C Programming
    Replies: 13
    Last Post: 07-13-2009, 07:48 PM
  3. where can i find memory hacking software?
    By headsup in forum General Hacking
    Replies: 4
    Last Post: 06-22-2009, 10:57 AM
  4. Memory Hacking (the ones that works/doesn't work)
    By Kuro Tenshi in forum Combat Arms Europe Hacks
    Replies: 2
    Last Post: 04-12-2009, 03:36 AM
  5. Memory Hacking Software (MHS)
    By ElmoCA in forum Combat Arms Hacks & Cheats
    Replies: 5
    Last Post: 02-04-2009, 06:56 PM