need startup help with memory reading (C++, ReadProcessMemory) menu

User Tag List

Results 1 to 14 of 14
  1. #1
    sixpounder's Avatar Member
    Reputation
    1
    Join Date
    Sep 2010
    Posts
    5
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    need startup help with memory reading (C++, ReadProcessMemory)

    Hello Folks,

    iam very new to memory editing (and also c++) and currently trying to write a programm, which reads x,y,z coords from the local player.
    i red some of the guides in this section, but iam at a point where i cant get any further. iam relatively sure, that it is an logical problem and any advanced person in wow memory editing can easily figuring out what iam doing wrong, so iam asking:

    Where is the mistake in my code? The 'tempbuf' variable which sould be filled by ReadProcessMemory in the 'readDWORD' or 'readFLOAT' function is ALWAYS zero (contains nothing), so i think i give the wrong memoryaddress to it...

    here's my code snippet ( i know the base-address of wow.exe is normally not hardcoded)

    Code:
    int main(void)
    {
    	const UINT u32WowBase = 0x00390000;
    
    	const UINT u32ClientConnection = 0x8BF1A8;	// Object Manager Pointer
    	const UINT u32CurMgrOffset = 0x462C;		// Offset to Object Manager
    	
    	const UINT u32FirstObjectOffset = 0xB4;		// First Object from Object Manager
    	const UINT u32NextObjectOffset = 0x3C;		// Next Object
    
    	const UINT u32GameObjTypeOffset = 0x14;
    	const UINT u32GameObjGUIDOffset = 0x30;
    
    	const UINT u32PlayerGUID = 0xB8;		// Local GUID
    	
    	UINT u32CurrMgr_pre = 0x0;
    	UINT u32CurrMgr = 0x0;
    	UINT u32pGUID = 0x0;	
    
    	const UINT u32UnitPosXOffset = 0x898;
    	const UINT u32UnitPosYOffset = u32UnitPosXOffset + 0x4;
    	const UINT u32UnitPosZOffset = u32UnitPosXOffset + 0x8;
    	
    	UINT u32NextObject = 0x0;
    	UINT u32ObjectType = 0x0;
    
    	UINT u32PlayerObject = 0x0;	
    
    	float X = 0.;
    	float Y = 0.;
    	float Z = 0.;
    	
    	HANDLE hWow = NULL;
    
    	DWORD dwWowPid = 0;
    	if (!GetWowProc(dwWowPid))  			// get wow PID
    		printError ( TEXT("GetWowProc FALSE") );
    
    	if( ( hWow = OpenProcess ( PROCESS_ALL_ACCESS, FALSE, dwWowPid )) == NULL)
    		printError ( TEXT("OpenProcess Failed due to open WoW process") );
    
    
    	u32CurrMgr_pre = readDWORD ( hWow, (u32WowBase + u32ClientConnection));
    	u32CurrMgr = readDWORD ( hWow, (u32CurrMgr_pre + u32CurMgrOffset));
    
    	u32pGUID = readDWORD ( hWow, (u32CurrMgr + u32PlayerGUID ) ); // UINT64?
    
    	u32NextObject = readDWORD ( hWow, (u32CurrMgr + u32FirstObjectOffset) );
    	u32ObjectType = readDWORD ( hWow, (u32NextObject + u32GameObjTypeOffset));
    	
    	while ( u32ObjectType <= 7 && u32ObjectType > 0)
    	{
    		cout << "Valid Object Found!\n";
    		
    		if ( readDWORD( hWow, (u32NextObject + u32GameObjGUIDOffset)) == u32pGUID )
    		{
    			cout <<"Mem Location by Player GUID found!!!\n";
    			u32PlayerObject = u32NextObject;
    			break;
    		}
    		
    		u32NextObject = readDWORD (hWow, (u32NextObject + u32NextObjectOffset));
    		u32ObjectType = readDWORD ( hWow, (u32NextObject + u32GameObjTypeOffset));
    	}
    
    	X = readFLOAT ( hWow, (u32PlayerObject + u32UnitPosXOffset));
    	Y = readFLOAT ( hWow, (u32PlayerObject + u32UnitPosYOffset));
    	Z = readFLOAT ( hWow, (u32PlayerObject + u32UnitPosZOffset));
    }
    my readDWORD function:
    Code:
    DWORD readDWORD ( HANDLE hWow, DWORD dwAddr )
    {
    	DWORD tempbuf = 0;
    	unsigned int bytes_read = 0;
    	
    	if (ReadProcessMemory ( hWow, &dwAddr, &tempbuf, sizeof(DWORD), (DWORD*)&bytes_read ) == 0)
    	{
    		printError ( TEXT("ReadProcessMemory DWORD failed!") );
    	}
    	
    	_tprintf ( TEXT("read %u Bytes\n "),bytes_read );
    	cout << "tempbuf:" << tempbuf << "\n";          // HERE IS THE MISTAKE, tempbuf is always 0
    	return tempbuf;
    }
    and my readFLOAT function (similar to readDWORD)
    Code:
    float readFLOAT ( HANDLE hWow, DWORD dwAddr )
    {
    	float tempbuf = 0.;
    	unsigned int bytes_read = 0;
    
    	if (ReadProcessMemory ( hWow, &dwAddr, &tempbuf, sizeof(FLOAT), (DWORD*)&bytes_read ) == 0)
    	{
    		printError ( TEXT("ReadProcessMemory FLOAT Failed!") );
    	}
    
    	cout << "tempbuf:" << tempbuf << "\n";          // HERE IS THE MISTAKE, tempbuf is always 0
    	
    	_tprintf( TEXT("read %u Bytes\n "),bytes_read );
    
    	return tempbuf;
    }
    so finding the PID and creating the Handle is working correctly, but it starts to fails at this point :
    Code:
    u32CurrMgr_pre = readDWORD ( hWow, (u32WowBase + u32ClientConnection));
    as mentioned above the tempbuf in 'readDWORD' is always zero, so of course 'u32CurrMgr_pre' and everything else is empty too.

    iam wondering why 'tempbuf' is empty and not giving some random numbers stored in the memory!

    thanks to everyone reading this and thanks for every help ! iam very happy about this forum and all the helpful skilled people around here.

    greetings,
    sixpounder

    need startup help with memory reading (C++, ReadProcessMemory)
  2. #2
    unbekannter2's Avatar Private
    Reputation
    1
    Join Date
    Feb 2011
    Posts
    4
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to enable Debug Privileges before you start reading other applications memory

    Code:
    BOOL EnableDebugPrivileges()
    {
        HANDLE tokenHandle;
        LUID luid;
        TOKEN_PRIVILEGES newPrivileges;
    
        if(!OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &tokenHandle))
            return FALSE;
    
        if(!LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &luid))
        {
            CloseHandle(tokenHandle);
            return FALSE;
        }
    
        newPrivileges.PrivilegeCount = 1;
        newPrivileges.Privileges[0].Luid = luid;
        newPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
    
        if(!AdjustTokenPrivileges(tokenHandle, FALSE, &newPrivileges, sizeof(newPrivileges), NULL, NULL))
        {
            CloseHandle(tokenHandle);
            return FALSE;
        }
    
       CloseHandle(tokenHandle);
    
       return TRUE;
    }

  3. #3
    Syltex's Avatar Sergeant Major
    Reputation
    23
    Join Date
    Jul 2010
    Posts
    174
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You accualy seam to know alot but that above + run c++ visual studio/express and admin or disable UAC.

  4. #4
    _Mike's Avatar Contributor
    Reputation
    310
    Join Date
    Apr 2008
    Posts
    531
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by unbekannter2 View Post
    You need to enable Debug Privileges before you start reading other applications memory
    No you don't. How to obtain a handle to any process with SeDebugPrivilege
    This functionality is provided for system-level debugging purposes. For debugging non-system processes, it is not necessary to grant or enable this privilege.
    Originally Posted by Syltex View Post
    You accualy seam to know alot but that above + run c++ visual studio/express and admin or disable UAC.
    I also know alot. He's not happy today.
    Mixing stream and stdio output.. Terrible error handling.. Inconsistent hungarian notation.. Bad advice.. This thread has it all.

    On topic: Check your base address.

  5. #5
    sixpounder's Avatar Member
    Reputation
    1
    Join Date
    Sep 2010
    Posts
    5
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @unbekannter2: wow, first time i red about that. this was explained nowhere i was looking before. thanks for your post!
    i copy and pasted your code, nothing changed expect the very first time i ran this, there tempbuf was always "1395667493" or "0x53303225" no matter what address it was trying to read.

    now everytime i run my program all is zero again.
    btw. iam not exactly sure how to implement EnableDebugPrivileges()... i simply added it as function in my program and called it asap..

    @syltex: i tried it under win7 (uac disabled) and winxp, on both OS the same behaviour

    iam glad to hear other suggestions

    @_mike : ok, ty ! will do
    Last edited by sixpounder; 02-20-2011 at 04:53 PM.

  6. #6
    _Mike's Avatar Contributor
    Reputation
    310
    Join Date
    Apr 2008
    Posts
    531
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @sixpounder:
    Ignore my last post.. I fail at reading.
    Code:
    if (ReadProcessMemory ( hWow, &dwAddr, &tempbuf, sizeof(DWORD), (DWORD*)&bytes_read ) == 0)
    There's your problem..

  7. #7
    sixpounder's Avatar Member
    Reputation
    1
    Join Date
    Sep 2010
    Posts
    5
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hell, yeah...
    you wont believe me how many times i checked the parameters for RPM and did not see that! typically noobstyle

    everything runs flawless now. thanks man. i will clean up my code and contribute it soon. i think it could be a good entrypoint for beginners like me.
    Last edited by sixpounder; 02-20-2011 at 05:14 PM.

  8. #8
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1356
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by _Mike View Post
    No you don't. How to obtain a handle to any process with SeDebugPrivilege



    I also know alot. He's not happy today.
    Mixing stream and stdio output.. Terrible error handling.. Inconsistent hungarian notation.. Bad advice.. This thread has it all.

    On topic: Check your base address.
    "You must spread some Reputation around before giving it to _Mike again."



    Originally Posted by sixpounder View Post
    hell, yeah...
    you wont believe me how many times i checked the parameters for RPM and did not see that! typically noobstyle

    everything runs flawless now. thanks man. i will clean up my code and contribute it soon. i think it could be a good entrypoint for beginners like me.
    If you release C++ code with functions like:
    ReadDWORD
    ReadFLOAT
    ReadDOUBLE
    etc

    I will hunt you down. Why the **** do you think C++ has templates?

    There's enough terrible "getting started" code examples in the wild at the moment. If you're going to release a new one, at least put some effort in and TRY to get it right. >_>
    Last edited by Cypher; 02-21-2011 at 01:08 AM.

  9. #9
    gononono64's Avatar Contributor
    Reputation
    100
    Join Date
    Jul 2009
    Posts
    85
    Thanks G/R
    1/5
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I will hunt you down. Why the **** do you think C++ has templates?
    Cypher scares me. God whatever you do don't let me **** up in the presence of the almighty Cypher.
    Hi! My name is Devon and I’m an alcoholic. Moving on…
    https://www.ownedcore.com/forums/world-of-warcraft/world-of-warcraft-bots-programs/wow-memory-editing/319172-guide-how-make-wow-bot-complete-newbs.html

  10. #10
    miceiken's Avatar Contributor Authenticator enabled
    Reputation
    208
    Join Date
    Dec 2007
    Posts
    401
    Thanks G/R
    7/8
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by gononono64 View Post
    Cypher scares me. God whatever you do don't let me **** up in the presence of the almighty Cypher.
    Necro bump, and stop trolling.

  11. #11
    snigelmannen's Avatar Member
    Reputation
    27
    Join Date
    Jul 2007
    Posts
    318
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by gononono64 View Post
    Cypher scares me. God whatever you do don't let me **** up in the presence of the almighty Cypher.
    He scares you? So far he's only been encouraging me to read up on stuff before posting, he is quite sweet/kind imo.
    " Spy sappin mah sentry! "

  12. #12
    ~OddBall~'s Avatar Contributor
    Reputation
    207
    Join Date
    Jan 2008
    Posts
    1,156
    Thanks G/R
    4/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    watch out guys, suck any harder and his dik will fall off
    https://www.mmowned.com/forums/world-of-warcraft/guides/278302-selecting-bot-you.html - SELECTING THE BOT FOR YOU

    PHWOOOOAAAAAR - Parog was here. <3 <----Wtf's a Parog?

  13. #13
    gononono64's Avatar Contributor
    Reputation
    100
    Join Date
    Jul 2009
    Posts
    85
    Thanks G/R
    1/5
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by miceiken View Post
    Necro bump, and stop trolling.
    1 week before i unintentionally bumped it is not considered a necro bump. Also i was just joking around. I really like cypher cuz hes funny (in a ****ed up way) and has yet to yell at me. ^_^

    I found this on the first page so it wasn't really old.

    On topic: I think this code could really be useful for people. Although i'm not sure why cypher does not like the read functions. But then again i do not program much in c++ and im still fairly new to reading memory
    Hi! My name is Devon and I’m an alcoholic. Moving on…
    https://www.ownedcore.com/forums/world-of-warcraft/world-of-warcraft-bots-programs/wow-memory-editing/319172-guide-how-make-wow-bot-complete-newbs.html

  14. #14
    reggggg's Avatar Member
    Reputation
    1
    Join Date
    Sep 2009
    Posts
    22
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use generics .......

    read<dword>
    read<char>
    read<qword>

    Templates - C++ Documentation

Similar Threads

  1. Replies: 2
    Last Post: 11-28-2013, 10:23 AM
  2. Replies: 2
    Last Post: 01-18-2012, 05:15 AM
  3. [Misc] Need help with memory addresses [1.12.1]
    By Lysolfs in forum WoW EMU Questions & Requests
    Replies: 4
    Last Post: 06-13-2011, 05:48 PM
  4. [C#/CE help] Need help with memory reading
    By dididii in forum Programming
    Replies: 0
    Last Post: 10-07-2010, 12:26 PM
  5. NEED SOME HELP with Model Editing
    By Dwarf in forum World of Warcraft Model Editing
    Replies: 4
    Last Post: 09-12-2006, 08:12 PM
All times are GMT -5. The time now is 09:56 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