C++ MessageBox, LPCSTR Issue

Posts 115 of 16 · Page 1 of 2
C++ MessageBox, LPCSTR Issue
Code:
#define Address1			(*(short*)( 0x01234567 ) )
MessageBox( NULL, Address1, "Window Caption1", MB_ICONINFORMATION );
I'm just wondering the correct way of passing the value to a msgbox without creating memory leaks as this is something that will run over a long period of time.. Also how would you add to a C++ msgbox? I can show you an example in VB.Net if that helps..

Code:
MessageBox.Show("Value of Address1: " + Address1, "Window Caption1")
[php]
char* buffer;
char* message = "Value of address: ";

int value = (int)*(int*)0x12345678;

...

itoa(value,buffer,10);

message += buffer;

MessageBox(NULL,message,"Window caption",MB_OK);
[/php]

That was completely off the top of my head.. You should make use of the itoa() function, it converts an integer to a string, could be useful here.
Thanks for posting, but I am having trouble understanding how applies iota and getting many errors.. Is there possibly a tutorial that applies to my situation?
Quote Originally Posted by +NULL View Post
Thanks for posting, but I am having trouble understanding how applies iota and getting many errors.. Is there possibly a tutorial that applies to my situation?
itoa, ato(x), Etc, Are explained on the MSDN and/or other coding websites/books witch you would already have consulted if you followed the good method.
char mystr[256] = "";
sprintf(mystr, "Value of addr1: %x", Address1);
MessageBox(0, mystr, "ADDY", 0);
Hell_Demon that works perfectly but there's one problem.. The value at this address is much too large for this data type(I believe..?) The value is sometimes in the Billions, so how could I approach this using the same method?
Wider Char Array.
Quote Originally Posted by Melodia View Post
Wider Char Array.
Care to elaborate or possibly give an example of how to achieve such feat?
Quote Originally Posted by +NULL View Post
Care to elaborate or possibly give an example of how to achieve such feat?
char mystr[100000000] = "";
See this is what I figured, but raising the size above 100,000 or so causes the program to crash completely, and any less makes it so slow that it almost isn't operable.. Plus on top of that it doesn't return the correct value.. It should be 46,902 but it's "-16,791" when I use sprintf! I am baffled!
Quote Originally Posted by freedompeace View Post
char mystr[100000000] = "";
Quote Originally Posted by +NULL View Post
See this is what I figured, but raising the size above 100,000 or so causes the program to crash completely
HOLY STACK OVERFLOW, BATMAN
unsigned char array[ size here ] = stuff
Holy Cow, I can't believe this is such a hard thing to do lol.. Perhaps I am approaching it incorrectly or something? All I want to do is take the Value of a certain address, and display it in a messagebox..

For example
Target Address: 0x030F8CF0
Current Value(4 Byte): 46,902

How do I display the value of 0x030F8CF0 in a messagebox? :/
Quote Originally Posted by +NULL View Post
Holy Cow, I can't believe this is such a hard thing to do lol.. Perhaps I am approaching it incorrectly or something? All I want to do is take the Value of a certain address, and display it in a messagebox..

For example
Target Address: 0x030F8CF0
Current Value(4 Byte): 46,902

How do I display the value of 0x030F8CF0 in a messagebox? :/
The value as in *(DWORD*)0x030F8CF0 = 7; OR the value as in 0x030F8CF0?

Code:
DWORD *pDW = (DWORD*)0x030F8CF0;
char str[256]="";
sprintf(str, "Val: 0x%x", pDW); // Val: 0x30F8CF0
Code:
DWORD *pDW = (DWORD*)0x030F8CF0;
char str[256]="";
sprintf(str, "Val: %d", *pDW); // Val: 7
Yes! Thank you, when all else fails Hell_Demon doesn't!
Posts 115 of 16 · Page 1 of 2

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?