 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
DTeCH Newbie cheater
Reputation: 0
Joined: 19 Jul 2013 Posts: 23 Location: Cayman Islands
|
Posted: Wed Nov 27, 2013 5:24 am Post subject: [VB.NET] Writing Strings with Null Terminator |
|
|
Hello again dudes!
I have written 2 new functions that finally matches the speed of CE's scanning for strings, & Array of Bytes (with, or without ?? wildcards). When scanning for strings, it would usually take up lots of ram, but I've solved that too.
My problems now revolve around writing Strings back to the addresses found. They worked before, but somehow in all the coding jungles I've amassed, I did some alterations to gain as much speed as possible, & the dreaded game crash is now back full swing.
I know it has to be the Strings being written that is causing it, because it was the culprit some time ago, & someone here told me about the 0x00 (&H0) null Char terminator that must follow strings when being written back to memory.
I scan with the debug version of my test app alongside CE to see if the addresses are correct, & they are... same results every time in both progs. This leads me to wonder what encoding is best. I remember using ASCII once, & it worked flawlessly, then I used UTF-8 another time when ASCII stopped working. They were both targeting the same online game process.
Now, I'm back to UTF-8, & the desired effect in game is successful, but the game crashes seconds later.
I have eye-balled the code, & vbNullChar is there!?!?!
UTF-8...
Code: | ' //"any string of crap here" must be the same length as the original value found
' //at the address being written to
Dim iWritten As Integer = 0
Dim tmpVal As Byte() = Encoding.UTF8.GetBytes("any string of crap here" & vbNullChar)
WriteProcessMemory(pH, AddressX, tmpVal, tmpVal.Length, iWritten)
... |
Or ASCII...
Code: |
Dim iWritten As Integer = 0
Dim tmpVal As Byte() = Encoding.ASCII.GetBytes("any string of crap here" & vbNullChar)
WriteProcessMemory(pH, AddressX, tmpVal, tmpVal.Length, iWritten)
... |
I also do the same thing in CE to see if there's an issue with writing to that location in the game, & CE does it with no problems. My attempts worked before too, but now I'm confused... No idea what's going on.
Does UTF-8 encode differently than ASCII? I thaught UTF-8 was identical to ASCII, but handles more characters than ASCII does... assuming that ASCII character range is still ASCII in the UTF-8 encoding, but UTF-8 also handles characters beyond the ASCII range.
Another question that arises is, what is the vbNullChar's encoding?
Is it a 2 Byte character [0 -> 255] (256) * [0 -> 255] (256) = 0 -> 65535 Char Unicode
or...
Single Byte character [0 -> 255](256) = 0 -> 255 Char ANSI?
Would love it if someone could shine a light on something else to check for, or whatever. In the mean time, I'm eye-balling the rest of the code.
[RESOLVED]
Turns out that all the coding is in order, & as it should be (with ASCII), but that was not the cause of my troubles. It was my AoBScan, & AobSwap functions... after tweaking for speed, I added a few cycle counters that counted each cycle of read bytes from memory to calculate, & keep track of the byte position, & as it was, it always returned 0x40000 (262144 bytes) more - which was un-needed coding remaining from older experiments... as I already start at the absolute lowest allowed Address of that memory block... the lowest possible memory location. So... when comparing with CE, I missed it every time till just now.
My Proggy's output ---------- CE's Output
Loc 0: &H1D5EA800 | 1D5AA800
Loc 1: &H233E3A02 | 233A3A02
Loc 2: &H29D4B720 | 29D0B720
Loc 3: &H29D4B900 | 29D0B900
Loc 4: &H359ABBC0 | 3596BBC0
Loc 5: &H38BE9E60 | 38BA9E60
Loc 6: &H3930EAC0 | 392CEAC0
All is well again. Was 3 seconds away from total mental shutdown.
_________________
Hitler... When all else fails, you'll be in the right state of mind. Jesus Saves.
Last edited by DTeCH on Wed Nov 27, 2013 4:50 pm; edited 3 times in total |
|
Back to top |
|
 |
justa_dude Grandmaster Cheater
Reputation: 23
Joined: 29 Jun 2010 Posts: 891
|
Posted: Wed Nov 27, 2013 7:29 am Post subject: |
|
|
Why not look at the memory you've just written with CE and, as you say, eyeball what gets written to vid the diff?
|
|
Back to top |
|
 |
DTeCH Newbie cheater
Reputation: 0
Joined: 19 Jul 2013 Posts: 23 Location: Cayman Islands
|
|
Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8585 Location: 127.0.0.1
|
Posted: Wed Nov 27, 2013 12:40 pm Post subject: |
|
|
UTF8 is Unicode encoding. That means that each letter takes up two bytes of space.
ASCII encoding only takes up one byte of space per-letter.
_________________
- Retired. |
|
Back to top |
|
 |
DTeCH Newbie cheater
Reputation: 0
Joined: 19 Jul 2013 Posts: 23 Location: Cayman Islands
|
|
Back to top |
|
 |
|
|
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
|
|