Getting 299 error when trying to read data menu

User Tag List

Results 1 to 3 of 3
  1. #1
    ensirius's Avatar Member
    Reputation
    1
    Join Date
    Feb 2020
    Posts
    3
    Thanks G/R
    3/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting 299 error when trying to read data

    I am trying to do some basic memory reads and got hit by 299 error. Not sure in which direction i should dig. Any suggestions?

    Code:
    using namespace std;
    
    #include <iostream>
    #include <Windows.h>
    #include <stdio.h>
    #include <Psapi.h>
    #include <string.h>
    
    HMODULE getModule(HANDLE processHandle) {
        HMODULE hMods[1024];
        DWORD cbNeeded;
        unsigned int i;
    
        cout << "Finding module for " << processHandle << endl;
    
        if (!EnumProcessModules(processHandle, hMods, sizeof(hMods), &cbNeeded)) {
            cout << "Failed to list process modules: " << GetLastError() << endl;
            return nullptr;
        }
    
        for (i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) {
            TCHAR szModName[MAX_PATH];
    
            if (GetModuleFileNameEx(processHandle, hMods[i], szModName, sizeof(szModName) / sizeof(TCHAR))) {
                wstring wstrModName = szModName;
                wstring wstrModContain = L"WowClassic.exe";
    
                if (wstrModName.find(wstrModContain) != string::npos) {
                    return hMods[i];
                }
            }
        }
    
        return nullptr;
    }
    
    int main() {
        cout << "Trying to hook in World of Warcraft!" << endl;
    
        HWND hwnd = FindWindow(NULL, L"World of Warcraft");
    
        if (hwnd == 0) {
            cout << "Window was not found" << endl;
            return 1;
        }
    
        DWORD processId;
        GetWindowThreadProcessId(hwnd, &processId);
    
        if (processId == 0) {
            cout << "Failed to get process id" << endl;
            return 1;
        }
    
        cout << "World of Wacraft was found with process id " << processId << endl;
    
        HANDLE processHandle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, false, processId);
    
        if (processHandle == 0) {
            cout << "Failed to open process" << endl;
            return 1;
        }
    
        cout << "Open process with handle id " << processHandle << endl;
    
        HMODULE module = getModule(processHandle);
    
        if (module == nullptr) {
            cout << "Failed to find module" << endl;
            CloseHandle(processHandle);
            return 1;
        }
    
        DWORD baseAddress = (DWORD) module;
        DWORD offset = 0x258ACF8; // 1.13.3 .33526 InGameFlag 
        DWORD address = baseAddress + offset ;
    
        cout << "Base address are " << uppercase << hex << baseAddress << endl;
        cout << "Offset address " << baseAddress << "+" << offset << " (" << address << ")" << dec << endl;
    
        uint32_t value;
    
        if (!ReadProcessMemory(processHandle, (LPVOID) address, &value, sizeof(value), NULL)) {
            cout << "Failed to read process memory: " << GetLastError() << endl;
            CloseHandle(processHandle);
            return 1;
        }
    
        cout << "Value " << value << endl;
    
        CloseHandle(processHandle);
        return 0;
    }

    Getting 299 error when trying to read data
  2. #2
    Icesythe7's Avatar Contributor
    Reputation
    231
    Join Date
    Feb 2017
    Posts
    168
    Thanks G/R
    10/111
    Trade Feedback
    0 (0%)
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Try this, also make sure to run as admin and compile as x64

    Code:
    #include <iostream>
    #include <windows.h>
    #include <TlHelp32.h>
    
    uintptr_t GetModuleBaseAddress(const DWORD procId, const wchar_t* modName)
    {
        uintptr_t modBaseAddr = 0;
        const auto hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, procId);
        if (hSnap != INVALID_HANDLE_VALUE)
        {
            MODULEENTRY32 modEntry;
            modEntry.dwSize = sizeof(modEntry);
            if (Module32First(hSnap, &modEntry))
            {
                do
                {
                    if (!_wcsicmp(modEntry.szModule, modName))
                    {
                        modBaseAddr = reinterpret_cast<uintptr_t>(modEntry.modBaseAddr);
                        break;
                    }
                } while (Module32Next(hSnap, &modEntry));
            }
        }
        CloseHandle(hSnap);
        return modBaseAddr;
    }
    
    template<typename T>
    T ReadMemory(HANDLE hProcess, const uintptr_t address) {
        T buffer;
        return ReadProcessMemory(hProcess, reinterpret_cast<BYTE*>(address), &buffer, sizeof T, nullptr) ? buffer : 0;
    }
    
    template<typename T>
    bool WriteMemory(HANDLE hProcess, const uintptr_t address, T buffer) {
        return WriteProcessMemory(hProcess, reinterpret_cast<BYTE*>(address), &buffer, sizeof T, nullptr);
    }
    
    int main()
    {
        std::cout << "Trying to find World of Warcraft!\n";
    
        const auto hwnd = FindWindow(nullptr, L"World of Warcraft");
        DWORD processId;
        GetWindowThreadProcessId(hwnd, &processId);
    
        if (hwnd && processId) 
        {
            std::cout << "World of Wacraft was found with process id " << processId << "\n";
            const auto base = GetModuleBaseAddress(processId, L"WowClassic.exe");
            const uintptr_t inGame = 0x258ACF8;
            std::cout << "Base address is 0x" << std::hex << base << "\n";
            const auto processHandle = OpenProcess(PROCESS_ALL_ACCESS, false, processId);
            std::cout << "InGame offset value is " << static_cast<int32_t>(ReadMemory<uint8_t>(processHandle, base + inGame)) << "\n";
            CloseHandle(processHandle);
            std::cin.get();
            return 0;
        }
    
        std::cout << "Window was not found\n";
        return 1;
    }
    also note that the ingame offset is a byte not an int so we read as a byte then cast it to an int just to print it

  3. Thanks ensirius (1 members gave Thanks to Icesythe7 for this useful post)
  4. #3
    ensirius's Avatar Member
    Reputation
    1
    Join Date
    Feb 2020
    Posts
    3
    Thanks G/R
    3/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks! Issue resolved

Similar Threads

  1. [Question] Getting Cmake Error when trying to compile server (maybe someone ran into this issue)
    By jakeyup in forum WoW EMU Questions & Requests
    Replies: 1
    Last Post: 01-06-2019, 10:29 AM
  2. [How-To] Get past "Instance not found" error when trying to go to draenor
    By drkd11 in forum World of Warcraft Guides
    Replies: 0
    Last Post: 11-14-2014, 04:17 AM
  3. [Help] A few errors when trying to update to rev 4337
    By MisterEMU in forum World of Warcraft Emulator Servers
    Replies: 15
    Last Post: 04-21-2008, 06:11 PM
  4. Unable to Connect error when trying to logon my server
    By Rizzano in forum World of Warcraft Emulator Servers
    Replies: 0
    Last Post: 09-27-2007, 01:12 PM
  5. getting error when trying to change size
    By kanezfan in forum WoW ME Questions and Requests
    Replies: 3
    Last Post: 07-31-2007, 08:57 PM
All times are GMT -5. The time now is 11:06 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search