[C++] Getting Player Information menu

User Tag List

Results 1 to 4 of 4
  1. #1
    BananasMelona's Avatar Member
    Reputation
    1
    Join Date
    Jun 2017
    Posts
    4
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [C++] Getting Player Information

    Hi,
    I'm attempting to read player data from the client but unfortunately I've been unable to.
    I followed the tutorial shown here: http://www.ownedcore.com/forums/worl...ete-newbs.html ([Guide] How to make a Wow bot for complete newbs!)

    What I'm currently trying to do is simply find the information related to the player (HP, Mana, etc).

    Here's my code so far:
    Code:
    #include <Windows.h>
    #include <iostream>
    #include <string>
    #include <Psapi.h>
    
    enum ObjectManager
    {
    	CurMgrPointer = 0x00C79CE0,                 // 3.3.5a 12340
    	CurMgrOffset = 0x00002ED0,                  // 3.3.5a 12340
    	NextObject = 0x3C,                          // 3.3.5a 12340
    	FirstObject = 0xAC,                         // 3.3.5a 12340
    	LocalGUID = 0xC0,                           // 3.3.5a 12340
    };
    
    enum WoWObjectFields
    {
    	OBJECT_FIELD_GUID = 0x0,
    	OBJECT_FIELD_TYPE = 0x2,
    	OBJECT_FIELD_ENTRY = 0x3,
    	OBJECT_FIELD_SCALE_X = 0x4,
    	OBJECT_FIELD_PADDING = 0x5,
    	//TOTAL_OBJECT_FIELDS = 0x5
    };
    
    UINT READUInt(HANDLE WowHandle, UINT address) {
    	SIZE_T read;
    	UINT val;
    	ReadProcessMemory(WowHandle, (LPVOID)(address), (LPVOID)(&val), sizeof(UINT), &read);
    	if (read == 0) {
    		std::cout << "Failed to read data" << std::endl;
    	}
    	return val;
    }
    UINT64 READUInt64(HANDLE WowHandle, UINT address) {
    	SIZE_T read;
    	UINT64 val;
    	ReadProcessMemory(WowHandle, (LPVOID)(address), (LPVOID)(&val), sizeof(UINT64), &read);
    	if (read == 0) {
    		std::cout << "Failed to read data" << std::endl;
    	}
    	return val;
    }
    std::string READString(HANDLE WowHandle, UINT address,  size_t length) {
    	std::string res(length, 0);
    	SIZE_T read;
    	ReadProcessMemory(WowHandle, (LPVOID)(address), (LPVOID)(&res[0]), sizeof(char) * length, &read);
    	if (read == 0) {
    		std::cout << "Failed to read data" << std::endl;
    	}
    	return res;
    }
    
    DWORD GetMemLocByGUID(HANDLE WowHandle, UINT64 guid, DWORD curMgr) {
    	DWORD nextObject = READUInt(WowHandle, curMgr + FirstObject );
    	DWORD ObjType = READUInt(WowHandle, nextObject + OBJECT_FIELD_TYPE);
    
    	while ((ObjType <= 7) && (ObjType > 0)) {
    		if (READUInt64(WowHandle, nextObject + OBJECT_FIELD_GUID) == guid) {
    			return nextObject;
    		}
    		nextObject = READUInt(WowHandle, nextObject + NextObject);
    		ObjType = READUInt(WowHandle, nextObject + OBJECT_FIELD_TYPE);
    	}
    
    	return 0;
    }
    
    DWORD GetModuleBase(HANDLE hProc, std::string sModuleName)
    {
    	HMODULE *hModules;
    	char szBuf[50];
    	DWORD cModules;
    	DWORD dwBase = -1;
    	//------ 
    
    	EnumProcessModules(hProc, NULL, 0, &cModules);
    	hModules = new HMODULE[cModules / sizeof(HMODULE)];
    
    	if (EnumProcessModules(hProc, hModules, cModules / sizeof(HMODULE), &cModules)) {
    		for (int i = 0; i < cModules / sizeof(HMODULE); i++) {
    			if (GetModuleBaseName(hProc, hModules[i], szBuf, sizeof(szBuf))) {
    				if (sModuleName.compare(szBuf) == 0) {
    					dwBase = (DWORD)hModules[i];
    					break;
    				}
    			}
    		}
    	}
    
    	delete[] hModules;
    
    	return dwBase;
    }
    
    int main(int argc, char* argv[]) {
    
    	HWND Wow = FindWindow(NULL, "World of Warcraft");
    	if (!Wow) {
    		std::cout << "Failed to find window process" << std::endl;
    		return 0;
    	}
    	DWORD pId;
    	GetWindowThreadProcessId(Wow, &pId);
    	HANDLE wowHandle = OpenProcess(PROCESS_ALL_ACCESS, 0, pId);
    	DWORD baseAddress = GetModuleBase(wowHandle, "Wow.exe");
    	SIZE_T read;
    	DWORD currentManager_pre = READUInt(wowHandle, baseAddress + CurMgrPointer);
    	DWORD currentManager = READUInt(wowHandle, currentManager_pre + CurMgrOffset);
    	UINT64 pGuid = READUInt64(wowHandle, currentManager + LocalGUID);
    	DWORD player = GetMemLocByGUID(wowHandle, pGuid, currentManager);
    	
    	return 0;
    }
    It currently isn't working at all . It reads succesfully the currentManager_pre but afterwards all goes downhill and it fails to read anything. I was hoping a kind soul would would be willing to help me and give some advice Am I reading the wrong address somewhere?

    I also had a few more general questions:
    -From what i understand, the GUID is a 64 bit number, so the offset should be 8 bytes. Thus I assume I should multiply the values of the offsets(taken from the info dump) by 4 as the ReadProcessMemory takes the base address in bytes? If so, does that apply to all offsets?
    - Is there a guide someone could link me to explaining in a bit of detail the way the data seems to be organized? Particularly the aspects related to randomization.

    [C++] Getting Player Information
  2. #2
    BananasMelona's Avatar Member
    Reputation
    1
    Join Date
    Jun 2017
    Posts
    4
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok after some searching with cheat engine I seem to have realized that CurMgrPointer = 0x00C79CE0 is not relative to my base address as in the tutorial but seems to be absolute.
    After doing this I seem to be getting the correct LocalPlayer GUID (at least when i try it out it seems to be unique to each character I connect to and is the same as if I use the static LocalGUID).

    However, I'm still unable to find the player in the list of objects. As I assume my CurMgr is correct (because I used it to find the LocalGUID), I must assume there's something wrong with the way I'm traversing the list of objects.

    If I understand correctly, (CurMgr + FirstObject) contains the pointer to the array of objects in the game. It then seems to contain at the end the pointer to the next object in a linked list sort of fashion.

    Could someone please say if my assumptions are correct? Also, could someone please tell me what I'm doing wrong when attempting to retrieve the information?
    Last edited by BananasMelona; 06-11-2017 at 09:12 AM.

  3. #3
    BananasMelona's Avatar Member
    Reputation
    1
    Join Date
    Jun 2017
    Posts
    4
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok so after looking at other offsets I see that indeed I need to multiply some offsets by 4. However I tryed almost every permutation and can't really get what I want.
    Could this possibly be because I'm playing on warmane 3.3.5a and thus the offsets are different from the live servers?
    If so, could someone how u go about finding the new offsets for the object manager?
    Thanks
    Last edited by BananasMelona; 06-13-2017 at 02:32 PM.

  4. #4
    Torpedoes's Avatar ★ Elder ★ Doomsayer
    Authenticator enabled
    Reputation
    1147
    Join Date
    Sep 2013
    Posts
    956
    Thanks G/R
    148/415
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Shameless plug but if you ever get sick of the Windows API, be sure to check out robot. I even have WoW reversing tutorials for the JavaScript (Writing Bots with Robot-js)version. I also post detailed Cheat Engine tables in the offset threads that might come in handy! Take a look :-)

Similar Threads

  1. Failed to get player information from the server
    By insanehadi in forum Pokemon GO Chat
    Replies: 1
    Last Post: 07-25-2016, 11:15 PM
  2. Get Player Base NO TLS + Delphi code [2.3.3]
    By robotkid in forum WoW Memory Editing
    Replies: 26
    Last Post: 05-08-2008, 08:33 PM
  3. Is there a way to get players to start with gold?
    By Wow Raiders in forum World of Warcraft Emulator Servers
    Replies: 5
    Last Post: 03-22-2008, 02:15 PM
  4. [Warlock] Get players killed by their own guards.
    By jacko666 in forum World of Warcraft Exploits
    Replies: 6
    Last Post: 03-17-2008, 04:21 PM
  5. [Help] getting players
    By House.MD in forum World of Warcraft Emulator Servers
    Replies: 2
    Last Post: 02-16-2008, 09:36 AM
All times are GMT -5. The time now is 07:37 PM. 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