GetPlayerName() menu

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    cloud_wizard's Avatar Member
    Reputation
    5
    Join Date
    Dec 2008
    Posts
    44
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    GetPlayerName()

    I attempted to make a rough translation of the AutoIt code I found at

    NoMorePasting.com

    These are the results, but it's not working for me. I think it has something to do with my misuse of &=.

    Not familiar with bitwise AND operators. Then again, the compiler isn't complaining... But just because the compiler isn't telling me my code is broken doesn't mean it's gonna do what I want it to do.

    Anyway...


    Code:
    string GetPlayerName(DWORD pGUID)
    {
    	using namespace std;
    	string Name;
    
    	DWORD nameStorePtr = 0x11AE3D0 + 0x8;
    	DWORD nameMaskOffset = 0x24;
    	DWORD nameBaseOffset = 0x1C;
    	DWORD nameStringOffset = 0x20;
    	DWORD Mask = MemoryRead(HBAI.Handle,(nameStorePtr+nameMaskOffset)* 4);
    	DWORD Base = MemoryRead(HBAI.Handle,(nameStorePtr+nameBaseOffset)* 4);
    
    	DWORD shortGUID = pGUID &= 0xFFFFFFFF;
    	if (Mask == 0xFFFFFFFF)
    	{
    		Name = "";
    		return false;
    	}
    
    	DWORD Offset  = 12 *(Mask &= shortGUID);
    	DWORD Current = MemoryRead(HBAI.Handle,(Base+Offset+8));
    	Offset = MemoryRead(HBAI.Handle,(Base+Offset));
    
    	if ((Current == 0) || (Current &= 0x1))
    	{
    		Name = "";
    		return false;
    	}
    
    	DWORD TestGUID = MemoryRead(HBAI.Handle,Current);
    	while(TestGUID != Current)
    	{
    		Current=MemoryRead(HBAI.Handle,(Current+Offset+0x4));
    		if ((Current == 0) || (Current &= 0x1))
    		{
    			Name = "";
    			return false;
    		}
    		TestGUID = MemoryRead(HBAI.Handle,Current);
    	}
    	Name = MemoryReadString(HBAI.Handle,(Current+nameStringOffset));
    	return Name;
    }
    Where did I go wrong?

    GetPlayerName()
  2. #2
    cloud_wizard's Avatar Member
    Reputation
    5
    Join Date
    Dec 2008
    Posts
    44
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nvm, before you say anything, I'm an idiot.

    & is what I needed to use, not &=.

    However, now I'm getting an access violation in strlen.asm


    Code:
    main_loop:
            mov     eax,dword ptr [ecx]     ; read 4 bytes  <----- ON THIS LINE
            mov     edx,7efefeffh
            add     edx,eax
            xor     eax,-1
            xor     eax,edx
            add     ecx,4
            test    eax,81010100h
            je      short main_loop
            ; found zero byte in the loop
            mov     eax,[ecx - 4]
            test    al,al                   ; is it byte 0
            je      short byte_0
            test    ah,ah                   ; is it byte 1
            je      short byte_1
            test    eax,00ff0000h           ; is it byte 2
            je      short byte_2
            test    eax,0ff000000h          ; is it byte 3
            je      short byte_3
            jmp     short main_loop         ; taken if bits 24-30 are clear and bit
                                            ; 31 is set

  3. #3
    Shynd's Avatar Contributor
    Reputation
    97
    Join Date
    May 2008
    Posts
    393
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Probably has to do with your MemoryReadString function.

  4. #4
    alek900's Avatar Contributor
    Reputation
    103
    Join Date
    Nov 2007
    Posts
    101
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    isent AND operators in c++ just a '&'??

    so
    Code:
    DWORD shortGUID = pGUID &= 0xFFFFFFFF;
    should be

    Code:
    DWORD shortGUID = pGUID & 0xFFFFFFFF;
    etc..

    edit: to slow again :S
    19+4 that means i score

  5. #5
    cloud_wizard's Avatar Member
    Reputation
    5
    Join Date
    Dec 2008
    Posts
    44
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alright. Mind taking a look for me please?

    Code:
    string MemoryReadString(HANDLE Handle, DWORD ReadAddress)
    {
    	SIZE_T BytesRead;
    	int BytesToRead = sizeof(ReadAddress);
    	string ContentsOfAddress;
    	ReadProcessMemory(Handle,(LPCVOID)ReadAddress,&ContentsOfAddress,BytesToRead,&BytesRead);
    	return ContentsOfAddress;
    }

  6. #6
    cloud_wizard's Avatar Member
    Reputation
    5
    Join Date
    Dec 2008
    Posts
    44
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    After an agonizingly thorough trace, discovered that it bombed out on me hwne I tried to return false from a function whose return type is string.

    Now it doesn't crash, rather it just gets stuck in the loop.

  7. #7
    Nesox's Avatar ★ Elder ★
    Reputation
    1280
    Join Date
    Mar 2007
    Posts
    1,238
    Thanks G/R
    0/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it's easier if you call GetObjectName vmt 47

  8. #8
    cloud_wizard's Avatar Member
    Reputation
    5
    Join Date
    Dec 2008
    Posts
    44
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ...

    ...

    ...huh?

    What do you mean? What is vmt 47?

  9. #9
    Robske's Avatar Contributor
    Reputation
    305
    Join Date
    May 2007
    Posts
    1,062
    Thanks G/R
    3/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Nesox View Post
    it's easier if you call GetObjectName vmt 47
    He said that he only wants to read memory in another thread.
    "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - Martin Golding
    "I cried a little earlier when I had to poop" - Sku

  10. #10
    Sillyboy72's Avatar Member
    Reputation
    13
    Join Date
    Jan 2009
    Posts
    66
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by cloud_wizard View Post
    Alright. Mind taking a look for me please?

    Code:
    string MemoryReadString(HANDLE Handle, DWORD ReadAddress)
    {
    	SIZE_T BytesRead;
    	int BytesToRead = sizeof(ReadAddress);
    	string ContentsOfAddress;
    	ReadProcessMemory(Handle,(LPCVOID)ReadAddress,&ContentsOfAddress,BytesToRead,&BytesRead);
    	return ContentsOfAddress;
    }
    ReadProcessMemory tries to copy memory from one process space... to another. The 3rd param is the address to copy the memory to. However, you need to have some space allocated to store the memory.

    I am not super familiar w/ the "string" class in c++, but I would more typically expect the buffer to be a byte array.
    BYTE *ContentsOfAddress = new BYTE[BytesToRead];

    actually, your BytesToRead looks weird too (always going to be 4... the sizeof a dword).

    -Silly

  11. #11
    cloud_wizard's Avatar Member
    Reputation
    5
    Join Date
    Dec 2008
    Posts
    44
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alright, and thanks for the effort. Nevermind trying to do it this way though. It's too complicated. Would be much easier to just get the unit name by calling an LUA function (I hope.)

  12. #12
    Shynd's Avatar Contributor
    Reputation
    97
    Join Date
    May 2008
    Posts
    393
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Everything is complicated when you don't know what the hell you're doing. Why don't you learn some basic programming before tackling something this large.

  13. #13
    cloud_wizard's Avatar Member
    Reputation
    5
    Join Date
    Dec 2008
    Posts
    44
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Sillyboy72 View Post
    ReadProcessMemory tries to copy memory from one process space... to another. The 3rd param is the address to copy the memory to. However, you need to have some space allocated to store the memory.

    I am not super familiar w/ the "string" class in c++, but I would more typically expect the buffer to be a byte array.
    BYTE *ContentsOfAddress = new BYTE[BytesToRead];

    actually, your BytesToRead looks weird too (always going to be 4... the sizeof a dword).

    -Silly
    Alright, now I've got:

    Code:
    char * Name = (char *)malloc(13);
    ~~~~~~~~~~~~~~~~~~~~
    char* MemoryReadString(HANDLE Handle, DWORD ReadAddress)
    {
    	SIZE_T BytesRead;
    	int BytesToRead = 13;
    	char * ContentsOfAddress = (char *)malloc(13);
    	ReadProcessMemory(Handle,(LPCVOID)ReadAddress,&ContentsOfAddress,BytesToRead,&BytesRead);
    	return ContentsOfAddress;
    }
    ~~~~~~~~~~~~~~~~~~~~
    char * GetPlayerName(DWORD pGUID)
    {
    	HANDLE Handle = OpenProcess(PROCESS_ALL_ACCESS,FALSE,HBAI.Instance[HBAI.CurrentWoWInstance].PID);
    	using namespace std;
    	Name = "";
    
    	DWORD nameStorePtr = 0x011AE3D0 + 0x8;
    	DWORD nameMaskOffset = 0x24;
    	DWORD nameBaseOffset = 0x1C;
    	DWORD nameStringOffset = 0x20;
    	DWORD Mask = MemoryRead(Handle,(nameStorePtr+nameMaskOffset));
    	DWORD Base = MemoryRead(Handle,(nameStorePtr+nameBaseOffset));
    
    	DWORD shortGUID = pGUID & 0xFFFFFFFF;
    	if (Mask == 0xFFFFFFFF)
    	{
    		Name = "";
    		return Name;
    	}
    
    	DWORD Offset  = 12 *(Mask & shortGUID);
    	DWORD Current = MemoryRead(Handle,(Base+Offset+8));
    	Offset = MemoryRead(Handle,(Base+Offset));
    
    	if ((Current == 0) || (Current & 0x1))
    	{
    		Name = "";
    		return Name;
    	}
    
    	DWORD TestGUID = MemoryRead(Handle,Current);
    	while(TestGUID != Current)
    	{
    		Current=MemoryRead(Handle,(Current+Offset+0x4));
    		if ((Current == 0) || (Current & 0x1))
    		{
    			Name = "";
    			return Name;
    		}
    		TestGUID = MemoryRead(Handle,Current);
    	}
    	Name = MemoryReadString(Handle,(Current+nameStringOffset));
    	return Name;
    	CloseHandle(Handle);
    }
    Name is returning (has been for a while now) but always blank.

  14. #14
    Sillyboy72's Avatar Member
    Reputation
    13
    Join Date
    Jan 2009
    Posts
    66
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Surprised it doesn't crash

    Code:
    char * ContentsOfAddress = (char *)malloc(13);
    ReadProcessMemory(Handle, LPCVOID)ReadAddress,&ContentsOfAddress,BytesToRead,&BytesRead);
    ContentsOfAddress is the address of your buffer;so you don't need to pass a reference to it in the 3rd param (nuke off the &)

  15. #15
    cloud_wizard's Avatar Member
    Reputation
    5
    Join Date
    Dec 2008
    Posts
    44
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alright, duly noted, done. Now stop. It has yet to even CALL the function MemoryReadString. The GetPlayerName function is the only function in which MemoryReadString is called, and it fails to call it because I'm reading the memory incorrectly. You're fixing a lot of mistakes in my code, but ones I haven't even gotten to yet. The main problem I'm having is with how I screwed up translating the code I found here: NoMorePasting.com to C++. Except I have no idea where I went wrong.

    Also... Why are you telling me how I need to allocate memory for a string when:

    I am not super familiar w/ the "string" class in c++
    It took me until now to realize this, but I've used strings without any kind of prior memory allocation several other places in my code with no problems. This should be no different. IDK what you do or don't know, but I kinda doubt you're "super familiar" with C++ (which makes asking for your help translating the code a dangerous endeavor in itself), but this problem (in fact, this whole forum) is about reading WoW's memory.

    A for effort, but I've just spent the last 4 hours chasing imaginary bugs through working code rather than focusing on what actually needs to be fixed.

Page 1 of 2 12 LastLast
All times are GMT -5. The time now is 03:43 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search