|
-
Aug 4th, 2001, 10:35 AM
#1
Thread Starter
Addicted Member
"Cant read memory" error
This code works but retuns an error saying:
The instruction at "0x6f746172" referenced memory at "0x6f746172". The memory could not be "read".
(this error seems to occur at the very end of the code).
Code:
#include <windows.h>
#include <stdio.h>
int main()
{
char s_username;
unsigned long i_length;
GetUserName (&s_username, &i_length);
printf(&s_username);
return 0;
}
Why is that?
Cbomb
Techie 
-
Aug 4th, 2001, 10:51 AM
#2
PowerPoster
It does not give me any error in vc++ but when I run it, it gives me some weird characters as the username
-
Aug 4th, 2001, 10:57 AM
#3
Thread Starter
Addicted Member
hmm
grrr....very weird...
I get: "Administrator" *error occurs here* "Press any key to exit"
Cbomb
Techie 
-
Aug 4th, 2001, 11:07 AM
#4
Monday Morning Lunatic
Re: "Cant read memory" error
You need to use a buffer:
Code:
#include <windows.h>
#include <stdio.h>
int main() {
char pcUserName[100];
unsigned long lLength = 100;
GetUserName(pcUserName, &lLength);
printf("%s\n", pcUsername);
return 0;
}
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 4th, 2001, 12:57 PM
#5
Thread Starter
Addicted Member
ohhhhhhhh
Thank you VERY much
Cbomb
Techie 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|