Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[C++] ReadProcessMemory Problem
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
DjSt3rios
Newbie cheater
Reputation: 0

Joined: 06 Jun 2013
Posts: 20

PostPosted: Thu Aug 01, 2013 5:49 pm    Post subject: Reply with quote

Not really, Nowadays server do not use GameGuard, as they were problems. Most of the servers just disabled game guard. I found out that only if i add a breakpoint it crashes.. i debugged it with no breakpoints and no BSOD. Now about the variable thingy, a 10 digit number is 10 bytes right? but how could I store it if the maximum amount of bytes is 8? Damn C++ is really confusing. As I saw the key is always 10 digits long, either negative or positive. I also tried saving it as a text but i found out its not working that way. By the way, I am not sure but, In cheat engine the value is shown as 4 byte. That doesn't mean that a long variable can hold it, right? I am really confused..
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Thu Aug 01, 2013 8:28 pm    Post subject: Reply with quote

DjSt3rios wrote:
Not really, Nowadays server do not use GameGuard, as they were problems. Most of the servers just disabled game guard. I found out that only if i add a breakpoint it crashes.. i debugged it with no breakpoints and no BSOD. Now about the variable thingy, a 10 digit number is 10 bytes right? but how could I store it if the maximum amount of bytes is 8? Damn C++ is really confusing. As I saw the key is always 10 digits long, either negative or positive. I also tried saving it as a text but i found out its not working that way. By the way, I am not sure but, In cheat engine the value is shown as 4 byte. That doesn't mean that a long variable can hold it, right? I am really confused..


If setting a breakpoint is causing you to BSOD, it sounds like an anti-cheat or something is still running and causing the crash.

Integers store upto: 2,147,483,647 (4 bytes) [int]
Unsigned integers store upto: 4,294,967,295 (4 bytes) [unsigned int]

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
DjSt3rios
Newbie cheater
Reputation: 0

Joined: 06 Jun 2013
Posts: 20

PostPosted: Thu Aug 01, 2013 8:57 pm    Post subject: Reply with quote

Hmmm Okay. I will try to create an unsigned int, and i will also check its maximum value of the key. Otherwise I will try with an unsigned long.
Also, What exactly do you mean by an anti-cheat might still be running? the weird thing is I never had issues with Dev C++ and debugging.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Fri Aug 02, 2013 2:44 am    Post subject: Reply with quote

DjSt3rios wrote:
Hmmm Okay. I will try to create an unsigned int, and i will also check its maximum value of the key. Otherwise I will try with an unsigned long.
Also, What exactly do you mean by an anti-cheat might still be running? the weird thing is I never had issues with Dev C++ and debugging.


If you can, try to write down the information of the bluescreen and post it here. You shouldn't be bluescreening while debugging unless something is triggering the system to halt because of the breakpoints. Typically that only happens as a result to an anti-cheat, virus-scanner, etc.

But just bluescreening from setting a breakpoint sounds like there is something detecting you debugging and is crashing the system.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
DjSt3rios
Newbie cheater
Reputation: 0

Joined: 06 Jun 2013
Posts: 20

PostPosted: Fri Aug 02, 2013 9:30 am    Post subject: Reply with quote

I have AVG Anti-virus, I disabled it temporarily, and now I didn't get BSOD. The application now seems to be okay with the memory problems, although now my application cannot read the username of the player properly. It might be another memory problem but for some reason, I don't think so. I will try to stop all threads and only pick the username, and see what happens. I will edit this post soon.

edit: Yep it doesn't seem its like memory problem. I disabled all threads, and it still gives me some weird letters every time I run it. I also tried to run it as administrator and with/out debugging. The text is unicode so I suspected maybe using Visual Studio's compiler it might require some more work to read unicode text, even though, with the way I use ReadMemoryString, it shouldn't be happening, because it reads 1 character each time... I changed strcpy to sprintf... if i use strcpy it gives me a really huge message with a lot of "M" characters..
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sat Aug 03, 2013 12:24 am    Post subject: Reply with quote

If the string is unicode you need to treat it as such.

'char' is specific to multibyte (ASCII), wchar_t is specific to unicode.
std::string is also specific to char. If you need the unicode version use 'std::wstring'.

Both your ReadUsername and ReadProcessMemoryString are specific to char types and not unicode. Its an issue with your code, not Visual Studio.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
DjSt3rios
Newbie cheater
Reputation: 0

Joined: 06 Jun 2013
Posts: 20

PostPosted: Sat Aug 03, 2013 10:08 am    Post subject: Reply with quote

Hmm. I tried what you said, After a few tries I managed to make it work a bit, but I still had problem converting wstring to char, I mean I did but some weird characters were printed instead of the username. Now I managed to fix the problem using char, just like I had it, i just increased the number of the bytes to read from 1 to 2, and works like a charm. I don't know if this can cause any problems, but looks okay so far. I will fully test it now and see how it will go.

Edit: Seems okay so far. Thanks a lot, I will update if anything goes wrong.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sat Aug 03, 2013 7:33 pm    Post subject: Reply with quote

You can convert a wstring to chars using:

std::wstring wstr = L"Some random unicode string.";
std::string str( wstr.begin(), wstr.end() );
const char* pszString = str.c_str();

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
DjSt3rios
Newbie cheater
Reputation: 0

Joined: 06 Jun 2013
Posts: 20

PostPosted: Sun Aug 04, 2013 11:45 am    Post subject: Reply with quote

Mhm, Thanks for the info but I still have problems using those. In the username alot of "M" characters appear... maybe I should just use normal char and string?
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sun Aug 04, 2013 12:54 pm    Post subject: Reply with quote

If the string in memory is unicode you will need to read it as unicode.

You can just stay to using the unicode string instead of converting it afterward though. There is unicode versions of every string function you use in your code.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
DjSt3rios
Newbie cheater
Reputation: 0

Joined: 06 Jun 2013
Posts: 20

PostPosted: Mon Aug 05, 2013 8:54 am    Post subject: Reply with quote

Wiccaan wrote:
If the string in memory is unicode you will need to read it as unicode.

You can just stay to using the unicode string instead of converting it afterward though. There is unicode versions of every string function you use in your code.


Well the thing is I need to convert it to char in order to send it using winsock, to the server, and when I convert it to char the text is a mess... I searched a bit on google but I couldn't find any way to use wchar_t with winsock. Also I saw that people use a loop to read a text char by char, just like I do, because the string is unicode. So I guess since it only reads a char and adds it to the string, using char or a normal string shouldn't be an issue
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites