Solved Getting the contents of a memory location as a string

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

Shadoninja

Newbie
Dank Tier Donator
Apr 24, 2013
36
214
0
I am trying to print out my player's x coordinate to the gui of my dll injected hack.

I know that xposition contains a DWORD of the address containing the player's x position, but I can't get it to assign its contents to the label xposStatus:

What is working (kinda)
C++:
xposStatus->Text = xposition.ToString();
This prints out what I wanted it to: the memory location holding my player's x coordinates. But that is only a small proof that I am on the right path.

Attempt 1: (The compiler yells at me)
C++:
xposStatus->Text = *xposition.ToString();
Attempt 2: ("Error: invalid type conversion")
C++:
xposStatus->Text = *(DWORD *)xposition.ToString();

Attempt 3: (This compiles, but doesn't change the label at all)
C++:
int test = *(DWORD *)xposition;
xposStatus->Text = test.ToString();



How can I get that float value contained in xposition?
 
Last edited:

till0sch

Respected Hacker
Dank Tier VIP
Dank Tier Donator
Oct 14, 2012
1,104
12,593
51
I am trying to print out my player's x coordinate to the gui of my dll injected hack.

I know that xposition contains a DWORD of the address containing the player's x position, but I can't get it to assign its contents to the label xposStatus:

What is working (kinda)
C++:
xposStatus->Text = xposition.ToString();
This prints out what I wanted it to: the memory location holding my player's x coordinates. But that is only a small proof that I am on the right path.

Attempt 1: (The compiler yells at me)
C++:
xposStatus->Text = *xposition.ToString();
Attempt 2: ("Error: invalid type conversion")
C++:
xposStatus->Text = *(DWORD *)xposition.ToString();

Attempt 3: (This compiles, but doesn't change the label at all)
C++:
int test = *(DWORD *)xposition;
xposStatus->Text = test.ToString();



How can I get that float value contained in xposition?
So basically you have a DLL which is injected in the process. This DLL opens a window in which you want to write something. Did I understand that correclty?
 

Shadoninja

Newbie
Dank Tier Donator
Apr 24, 2013
36
214
0
Yeah, it opens up a gui created from visual studios built in win32 application support. So the object on the gui that I am trying to change is the Text element of a Label^ object from System::Windows::Forms::Label^;



This is the same structure Fleep uses in one of his tutorials, but he only uses string literals to change certain label's text to "on" or "off." I want real-time information presented, which obviously requires variable input, and the label just isn't having it.
 

c5

Kim Kong Trasher
Dank Tier VIP
Dank Tier Donator
Jul 19, 2012
1,187
12,638
76
He wants to read a float from memory and convert it to a string
 

c5

Kim Kong Trasher
Dank Tier VIP
Dank Tier Donator
Jul 19, 2012
1,187
12,638
76
C++:
DWORD position = *(DWORD_PTR*)xposition;
xposStatus->Text = *(float*)position.ToString();
 

Shadoninja

Newbie
Dank Tier Donator
Apr 24, 2013
36
214
0
That line is giving me the "Invalid type conversion" error.

C++:
xposStatus->Text = *(float*)position.ToString();
      underlined red^  (the carrot is pointing to it)
And the same error happens when I do it like this

C++:
char* test = *(float*)position.ToString();
underlined red^
Honestly if there is a better way to set up the gui, I will be happy to do that. Even if its just a console window. I just want to learn a decent way of setting this all up
 

CyanideByte

Newbie
May 31, 2012
12
348
0
Order of operations is important, otherwise you'll be trying to deference a float from a string.
https://en.cppreference.com/w/cpp/language/operator_precedence
As you can see here the member access operator has a higher priority than a typecast or a dereference operator so you would need to put those in parenthese.
That said, a native float doesn't have a ToString function.

Give this a try:
C++:
xposStatus->Text = Convert::ToString(*(float*)position);
 
Last edited:
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods