C++ Вопрос Проблема с вычислением оффсета, не меняется значение патрон | Assault Cube

Начинающий
Статус
Оффлайн
Регистрация
21 Сен 2021
Сообщения
8
Реакции[?]
1
Поинты[?]
1K
Помогите пожалуйста не получается изменить значение патрон в обойме , оффсет копировал с чит енджайна
C++:
    #include <iostream>
    #include <Windows.h>
    #include <TlHelp32.h>
    #include <tchar.h>
    #include <vector>

    using namespace std;
    DWORD GetModuleBaseAddress(TCHAR* lpszModuleName, DWORD pID) {
        DWORD dwModuleBaseAddress = 0;
        HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, pID);
        MODULEENTRY32 ModuleEntry32 = { 0 };
        ModuleEntry32.dwSize = sizeof(MODULEENTRY32);

        if (Module32First(hSnapshot, &ModuleEntry32))
        {
            do {
                if (_tcscmp(ModuleEntry32.szModule, lpszModuleName) == 0)
                {
                    dwModuleBaseAddress = (DWORD)ModuleEntry32.modBaseAddr;
                    break;
                }
            } while (Module32Next(hSnapshot, &ModuleEntry32));


        }
        CloseHandle(hSnapshot);
        return dwModuleBaseAddress;
    }

    DWORD GetPointerAddress(HWND hwnd, DWORD gameBaseAddr, DWORD address, vector<DWORD> offsets)
    {
        DWORD pID = NULL;
        GetWindowThreadProcessId(hwnd, &pID);
        HANDLE phandle = NULL;
        phandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pID);
        if (phandle == INVALID_HANDLE_VALUE || phandle == NULL);

        DWORD offset_null = NULL;
        ReadProcessMemory(phandle, (LPVOID*)(gameBaseAddr + address), &offset_null, sizeof(offset_null), 0);
        DWORD pointeraddress = offset_null;
        for (int i = 0; i < offsets.size() - 1; i++)
        {
            ReadProcessMemory(phandle, (LPVOID*)(pointeraddress + offsets.at(i)), &pointeraddress, sizeof(pointeraddress), 0);
        }
        return pointeraddress += offsets.at(offsets.size() - 1);
    }

    int main()
    {
        setlocale(LC_ALL, "ru");

        HWND hwnd_AC= FindWindowA(NULL, "AssaultCube"); // Получение хендлера окна

        if (hwnd_AC != FALSE);
        DWORD pID = NULL;
        GetWindowThreadProcessId(hwnd_AC, &pID);
        HANDLE phandle = NULL;
        phandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pID);
        if (phandle == INVALID_HANDLE_VALUE || phandle == NULL);

        char gamemodule1[] = "ac_client.exe";
        DWORD gamebaseaddress1 = GetModuleBaseAddress(_T(gamemodule1), pID);

        DWORD ammoAddr = 0x0094D7D0;
        vector<DWORD> ammoOffsets{ 0x140 , 0x17E0A8,};
        DWORD ammoPtrAddr = GetPointerAddress(hwnd_AC, gamebaseaddress1, ammoAddr, ammoOffsets);

        while (true)
        {
            int ammo = 1000;
            WriteProcessMemory(phandle, (LPVOID*)(ammoPtrAddr), &ammo, 4, 0);
        }

    }
 
Начинающий
Статус
Оффлайн
Регистрация
22 Окт 2022
Сообщения
93
Реакции[?]
14
Поинты[?]
15K
C++:
#include <iostream>
#include <Windows.h>
#include <TlHelp32.h>
#include <tchar.h>
#include <vector>

using namespace std;
DWORD GetModuleBaseAddress(const char* lpszModuleName, DWORD pID) {
    DWORD dwModuleBaseAddress = 0;
    HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, pID);
    MODULEENTRY32 ModuleEntry32 = { 0 };
    ModuleEntry32.dwSize = sizeof(MODULEENTRY32);

    if (Module32First(hSnapshot, &ModuleEntry32))
    {
        do {
            if (_strcmpi(ModuleEntry32.szModule, lpszModuleName) == 0)
            {
                dwModuleBaseAddress = (DWORD)ModuleEntry32.modBaseAddr;
                break;
            }
        } while (Module32Next(hSnapshot, &ModuleEntry32));


    }
    CloseHandle(hSnapshot);
    return dwModuleBaseAddress;
}

DWORD GetPointerAddress(HWND hwnd, DWORD gameBaseAddr, DWORD address, vector<DWORD> offsets)
{
    DWORD pID = NULL;
    GetWindowThreadProcessId(hwnd, &pID);
    HANDLE phandle = NULL;
    phandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pID);
    if (phandle == INVALID_HANDLE_VALUE || phandle == NULL);

    DWORD offset_null = NULL;
    ReadProcessMemory(phandle, (LPVOID*)(gameBaseAddr + address), &offset_null, sizeof(offset_null), 0);
    DWORD pointeraddress = offset_null;
    for (int i = 0; i < offsets.size() - 1; i++)
    {
        ReadProcessMemory(phandle, (LPVOID*)(pointeraddress + offsets.at(i)), &pointeraddress, sizeof(pointeraddress), 0);
    }
    return pointeraddress += offsets.at(offsets.size() - 1);
}

int main()
{
    setlocale(LC_ALL, "ru");

    HWND hwnd_AC = FindWindowA(NULL, "AssaultCube");

    if (hwnd_AC != FALSE);
    DWORD pID = NULL;
    GetWindowThreadProcessId(hwnd_AC, &pID);
    HANDLE phandle = NULL;
    phandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pID);
    if (phandle == INVALID_HANDLE_VALUE || phandle == NULL);

    const char *gamemodule1 = "ac_client.exe";
    DWORD gamebaseaddress1 = GetModuleBaseAddress(gamemodule1, pID);

    std::cout << std::hex << gamebaseaddress1;

    DWORD ammoAddr = 0x0017E0A8;
    vector<DWORD> ammoOffsets{ 0x140, };
    DWORD ammoPtrAddr = GetPointerAddress(hwnd_AC, gamebaseaddress1, ammoAddr, ammoOffsets);

    while (true)
    {
        int ammo = 1000;
        WriteProcessMemory(phandle, (LPVOID*)(ammoPtrAddr), &ammo, 4, 0);
    }

}
 
Сверху Снизу