Name ESP Using Radar Struct?

Posts 1–15 of 18 · Page 1 of 2
Name ESP Using Radar Struct?
My Current code:
Code:
//Reading
wchar_t PlayerName;
DWORD RadarEntityPointer;


RadarEntity = Mem.Read<DWORD>(dwClient + 0x04EFAC6C);
		 RadarEntityPointer = Mem.Read<DWORD>(RadarEntity + 0x50);
		 PlayerName = Mem.Read<wchar_t>(RadarEntityPointer + (0x1E8 * (Player + 1)) + 0x24);


//Drawing 

char Name = (char)pEntity->PlayerName;
			
DrawString(&Name, Head3[0], Head3[1], 255, 255, 255, mFont);
Gives

And I'm not quite sure were I messed up. Any help?
The symbols between the "i"s constantly change.
Quote Originally Posted by Skips View Post
My Current code:
Code:
//Reading
wchar_t PlayerName;
DWORD RadarEntityPointer;


RadarEntity = Mem.Read<DWORD>(dwClient + 0x04EFAC6C);
		 RadarEntityPointer = Mem.Read<DWORD>(RadarEntity + 0x50);
		 PlayerName = Mem.Read<wchar_t>(RadarEntityPointer + (0x1E8 * (Player + 1)) + 0x24);


//Drawing 

char Name = (char)pEntity->PlayerName;
			
DrawString(&Name, Head3[0], Head3[1], 255, 255, 255, mFont);
Gives

And I'm not quite sure were I messed up. Any help?
The symbols between the "i"s constantly change.
Its unicode.
This is how I do it.
Code:
currentent.Name = Mem.ReadStringUnicode(rpoint + (0x1E0 * (i + 1) + 0x24), 64);
Quote Originally Posted by NotCarlsson View Post
Its unicode.
This is how I do it.
Code:
currentent.Name = Mem.ReadStringUnicode(rpoint + (0x1E0 * (i + 1) + 0x24), 64);
Is wchar_t not unicode?
I use 0x54 as a pointer
You need to give it some encoding.

C#
Code:
		public virtual string ReadString(IntPtr address, Encoding encoding, int maximumLength = 512, bool isRelative = false)
		{
			Requires.NotEqual(address, IntPtr.Zero, nameof(address));
			Requires.NotNull(encoding, nameof(encoding));

			var buffer = ReadBytes(address, maximumLength, isRelative);
			var ret = encoding.GetString(buffer);
			if (ret.IndexOf('\0') != -1)
			{                       
				ret = ret.Remove(ret.IndexOf('\0'));
			}
			return ret;
		}
Usage:
Code:
                    string name = Core.Memory.ReadString((IntPtr) ptr, Encoding.ASCII, 32);
Code:
PlayerName = Mem.Read<wchar_t>(RadarEntityPointer + (0x1E8 * (Player + 1)) + 0x24);
Open up your Read function. Notice that the template is used to determine how much bytes ReadProcessMemory should read.
You are reading the size of _one_ wchar_t. Since you only read one byte, the beginning of the name ( assuming all the offsets are correct etc. ), your string is not null terminated and you pass a pointer to _one_ character to the draw string function, it will try to draw each character until it encounters a null terminator. Your string isn't null terminated and it will therefore print out garbage of whatever is currently on the stack until it encounters a null terminator.

Make a custom read function for reading strings, use a default amount of bytes to read ( can be larger than the actual name ), preferrably the maximum lenght of a name. For example, read 255 characters and store it in a buffer and then pass the buffer over to the draw string function. It will automatically stop at the null terminator and therefore only draw the string you want and disregard the rest
Quote Originally Posted by WasserEsser View Post
Code:
PlayerName = Mem.Read<wchar_t>(RadarEntityPointer + (0x1E8 * (Player + 1)) + 0x24);
Open up your Read function. Notice that the template is used to determine how much bytes ReadProcessMemory should read.
You are reading the size of _one_ wchar_t. Since you only read one byte, the beginning of the name ( assuming all the offsets are correct etc. ), your string is not null terminated and you pass a pointer to _one_ character to the draw string function, it will try to draw each character until it encounters a null terminator. Your string isn't null terminated and it will therefore print out garbage of whatever is currently on the stack until it encounters a null terminator.

Make a custom read function for reading strings, use a default amount of bytes to read ( can be larger than the actual name ), preferrably the maximum lenght of a name. For example, read 255 characters and store it in a buffer and then pass the buffer over to the draw string function. It will automatically stop at the null terminator and therefore only draw the string you want and disregard the rest
I'm using the ProcMem from your old C+ external and I believe there is a template for a wchar[256], thanks for the explanation and I look into it when I get home.

- - - Updated - - -

Quote Originally Posted by NotCarlsson View Post
You need to give it some encoding.

C#
Code:
		public virtual string ReadString(IntPtr address, Encoding encoding, int maximumLength = 512, bool isRelative = false)
		{
			Requires.NotEqual(address, IntPtr.Zero, nameof(address));
			Requires.NotNull(encoding, nameof(encoding));

			var buffer = ReadBytes(address, maximumLength, isRelative);
			var ret = encoding.GetString(buffer);
			if (ret.IndexOf('\0') != -1)
			{                       
				ret = ret.Remove(ret.IndexOf('\0'));
			}
			return ret;
		}
Usage:
Code:
                    string name = Core.Memory.ReadString((IntPtr) ptr, Encoding.ASCII, 32);
Thank you for the template.
Quote Originally Posted by WasserEsser View Post
~Snips~
So I've done what you said (Or atleast I think I did) and created a char array of [32] which I then read from memory.

My Reading Function:
Code:
bool Reads(DWORD_PTR dwAddress, LPVOID lpBuffer, DWORD_PTR dwSize) {
		

		return (ReadProcessMemory(hProcess, (LPCVOID)dwAddress, lpBuffer, dwSize, NULL) == TRUE);
	}
My Radar Reading:
Code:
 RadarEntity = Mem.Read<DWORD>(dwClient + 0x04EFCD2C);
		 RadarEntityPointer = Mem.Read<DWORD>(RadarEntity + 0x50);
		// PlayerName = Mem.Read<wchar_t>(RadarEntityPointer + (0x1E8 * (Player + 1)) + 0x24);
		  Mem.Reads(RadarEntityPointer + (0x1E8 * (Player + 1)) + 0x24, PlayerName, 32);
Draw Name:
Code:
DrawString(&pEntity->PlayerName[32], Head3[0], Head3[1], 255, 255, 255, mFont);
Draw String:
Code:
int DrawString(char* String, int x, int y, int r, int g, int b, ID3DXFont* ifont)
{
	RECT ShadowPos;
	ShadowPos.left = x + 1;
	ShadowPos.top = y + 1;

	RECT FontPos;
	FontPos.left = x;
	FontPos.top = y;
	ifont->DrawTextA(0, String, strlen(String), &ShadowPos, DT_NOCLIP, D3DCOLOR_ARGB(255, r / 3, g / 3, b / 3));
	ifont->DrawTextA(0, String, strlen(String), &FontPos, DT_NOCLIP, D3DCOLOR_ARGB(255, r, g, b));
	return 0;
}
Yet I get this.



So I'm not quite sure if it's my offsets (I've tried changing the 0xIE8 to 0xIE0) or if it could be something else.
Also, is the Char array automatically iterated through in order to create a string (kinda like a char*) or do I have to do this manually in some way to convert it to a string? I see that VS sees it as a char* so I'd assume yes but I just wanted to ask because you did say it would iterate through until it reached a null terminator... annd I answered that question for myself.
Here is how i get player's name in mine DDX Multihack:

PlayerObject.GetName();
Code:
                var nameCharArray = Encoding.Unicode.GetString(Global.Memory.ReadBytes(GlobalRead.RadarHandle + (_index + 1) * 0x1E0 + /* nameOffset */ 0x24, 32)).ToCharArray();
                var name = string.Empty;
                var lastEmpty = false;

                foreach (var nameChar in nameCharArray)
                {
                    if (nameChar == '\0')
                    {
                        if (lastEmpty)
                            break;

                        lastEmpty = true;
                        continue;
                    }

                    lastEmpty = false;
                    name += nameChar;
                }

                return name;
GlobalRead.RadarHandle;
Code:
                var radarBasePointer = (IntPtr)BitConverter.ToInt32(Global.Memory.ReadBytes(MemoryBase.ClientDll + /* radarBase */ 0x04EFCD2C, IntPtr.Size), 0);
                return (IntPtr)BitConverter.ToInt32(Global.Memory.ReadBytes(radarBasePointer + /* radarBasePointer */ 0x54, IntPtr.Size), 0);
_index = position in entityList array
entityList[0] = _index 0
entityList[1] = _index 1
etc. etc.
here is how i read it in c#. that template is not necessary at all.

RadarBase = ReadInt32((IntPtr)(Offsets.CLIENT + Offsets.dwRadarBase));
Radar = ReadInt32((IntPtr)(RadarBase + 0x54));
name = ReadStringUnicode((IntPtr)(Radar + ((0x1E0 * (id+1)) + 0x24)), 40);

0x54 is the pointer that works for me. not 0x50.
Quote Originally Posted by HexMurder View Post
here is how i read it in c#. that template is not necessary at all.

RadarBase = ReadInt32((IntPtr)(Offsets.CLIENT + Offsets.dwRadarBase));
Radar = ReadInt32((IntPtr)(RadarBase + 0x54));
name = ReadStringUnicode((IntPtr)(Radar + ((0x1E0 * (id+1)) + 0x24)), 40);

0x54 is the pointer that works for me. not 0x50.


The problem is I don't have a ReadStringUnicode function.

Well, my read function returns
Quote Originally Posted by Skips View Post
The problem is I don't have a ReadStringUnicode function.

Well, my read function returns
You don't need a special function, you're interpreting a wchar_t* as a char*. Use wchar_t* instead of char*.

Code:
DrawString(&pEntity->PlayerName[32], Head3[0], Head3[1], 255, 255, 255, mFont);
Lol. Get the address of the last character in the array and draw it? What's the purpose of this. I thought you want to draw the name and not the last character in your array...
Quote Originally Posted by WasserEsser View Post
You don't need a special function, you're interpreting a wchar_t* as a char*. Use wchar_t* instead of char*.

Code:
DrawString(&pEntity->PlayerName[32], Head3[0], Head3[1], 255, 255, 255, mFont);
Lol. Get the address of the last character in the array and draw it? What's the purpose of this. I thought you want to draw the name and not the last character in your array...
That was from when I was just messing around with stuff (Didn't mean to copy it over), I understand that I would print the pointer and not a particular character in the array whoops. Which would explain why in the above screenshot there was only one character.
Quote Originally Posted by Skips View Post
That was from when I was just messing around with stuff (Didn't mean to copy it over), I understand that I would print the pointer and not a particular character in the array whoops. Which would explain why in the above screenshot there was only one character.
So whats the problem then?
Quote Originally Posted by WasserEsser View Post
So whats the problem then?
Code:
Player = Mem.Read<uintptr_t>(dwClient + EntityList + (i * 0x10));
Code:
 Mem.Reads(RadarEntityPointer + +(0x1E0 * (Player + 1) + 0x24), PlayerName, 32);
That was my problem, I was reading the name as if it were from the entitybase, but I fixed it by just switching Player with
i.

Code:
 Mem.Reads(RadarEntityPointer + +(0x1E0 * (i + 1) + 0x24), PlayerName, sizeof(PlayerName));
Do you have any idea on how I can create dynamic text sizing so the names aren't always one size and then eventually are wayy bigger than the boxes.
Posts 1–15 of 18 · Page 1 of 2

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us