|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Hatschi Master Cheater Reputation: 2
Joined: 28 Jan 2010 Posts: 327
|
Posted: Thu Apr 13, 2017 6:21 pm Post subject: Auto Assembler - Unicode |
|
|
The following line will write the string "money". How can I write this string in uncode without using byte array?
Code: | db 'money' //equal to db 6D 6F 6E 65 79' |
Unicode:
Code: | db ??? //equal to db 6D 00 6F 00 6E 00 65 00 79 |
|
|
Back to top |
|
|
FreeER Grandmaster Cheater Supreme Reputation: 53
Joined: 09 Aug 2013 Posts: 1091
|
Posted: Thu Apr 13, 2017 6:36 pm Post subject: |
|
|
99% sure you'd just use
so that each value is written using 2 bytes, or dd for 4 bytes, though you may also want a terminating 0 depending on how it's used.
|
|
Back to top |
|
|
panraven Grandmaster Cheater Reputation: 55
Joined: 01 Oct 2008 Posts: 942
|
Posted: Thu Apr 13, 2017 8:12 pm Post subject: |
|
|
...(oops, edited ;p )
CE have functions to convert wideString (utf8->utf16?).
The following custom function make use of them to convert a possible wideString to aob format so that it can be db-ize (also add zero terminate option and prefix size option, ie. mono string)
Code: |
function wideStr2Aob(s, zeroTerminate, prefixSize)
local b = assert(wideStringToByteTable(s),"Can't convert WideStr2Aob")
if prefixSize then
local sz = math.floor(#b/2)
for c in string.pack(">I4",sz):gmatch"." do
table.insert(b,1,c:byte())
end
end
if zeroTerminate then b[#b+1],b[#b+2] = 0,0 end
return byteTableToString(b):gsub(".",
function(c)return string.format(" %02X",c:byte())end):sub(2)
end |
Usage, in AA:
Code: |
SomeAddress:
{$lua}
return "db "..wideStr2Aob([[Дракон]],true, true) -- Russian 'dragon'
{$asm}
|
will write bytes
06 00 00 00 14 04 40 04 30 04 3A 04 3E 04 3D 04 00 00
on SomeAddress.
_________________
- Retarded. |
|
Back to top |
|
|
Hatschi Master Cheater Reputation: 2
Joined: 28 Jan 2010 Posts: 327
|
Posted: Fri Apr 14, 2017 3:55 am Post subject: |
|
|
Amazing, thank you very much!
|
|
Back to top |
|
|
FreeER Grandmaster Cheater Supreme Reputation: 53
Joined: 09 Aug 2013 Posts: 1091
|
Posted: Fri Apr 14, 2017 12:18 pm Post subject: |
|
|
panraven wrote: | The following custom function make use of them to convert a possible wideString to aob format |
Nice, thanks for that! Gives some "advanced" things in lua for me to learn about (and obviously superior to my suggestion)
Though I do have to ask something semi-related. Is there any way to get CE's "Text"/String type to read the length from memory instead of having to give it a length (or even use terminating 0s to find the length)? I haven't really needed to so I can understand if there isn't, just curious.
edit: is the string.pack... because dwordToByteTable would use a signed 4 byte conversion (as unlikely as a string being long enough for that to matter is)? Or is there another reason I'm not seeing?
edit2: Actually since it gets "reversed" from 0,0,0,6 to 6,0,0,0 wouldn't large strings (more than 255 in length) actually cause problems with this method?
|
|
Back to top |
|
|
panraven Grandmaster Cheater Reputation: 55
Joined: 01 Oct 2008 Posts: 942
|
Posted: Sat Apr 15, 2017 2:32 am Post subject: |
|
|
Not sure I get what ' give it a length' means.
If it is about the Lua function
Code: | readString(address, maxlength, widechar OPTIONAL) : Reads a string till it encounters a 0-terminator. Maxlength is just so you won't freeze for too long, set to 6000 if you don't care too much. Set WideChar to true if it is encoded using a widechar formatting |
to get the string from a known address.
If we know the usage of the string ( eg a item-string-id should not be too long?, unless we are ripping someone's cetrainer ), a reasonable maxlength should be enough?
If it is about scanning, I guess it depend on how the game (target process) define a 'string', c style zero terminate (ascii/unicode) string or some structure like mono-string (should be always unicode?):
ie.
length (prefixSize) is 4byte at +08(32bit)/+10 (64bit) from the 'string' base, and
characters start at +0c/+14.
(I know little beside this 2 type of string)
But we usually scan for a known string (and known unicode or not), and don't care about the length, or zero terminate or structural ?
I can only think of using the known prefixSize in mono string type that differential a certain string IN GAME (with prefixSize) and IN ASSEMBLY (without prefixSize?) in an aob scanning. (But same I've not ever do such thing)
@edit:
the dwordToByteTable is littleEndian and may need a variable to use in a for loop, using string.pack with bigEndian + gmatch seems handy to do reversing. I actually see the bytes get reversed then I add the ">".
ie. ">" -> big endian in packing, "<"->little endian
@edit2:
This is output of a long string with prefixSize, seems no problem?
AF 01 00 00 66 00 75 00 6E 00 63 ...
_________________
- Retarded. |
|
Back to top |
|
|
FreeER Grandmaster Cheater Supreme Reputation: 53
Joined: 09 Aug 2013 Posts: 1091
|
Posted: Sat Apr 15, 2017 11:52 am Post subject: |
|
|
@panraven, I meant in the address list more than anything else eg.
edits: ok, yeah that makes sense. Thanks for your time!
You should be able to use this though (tested) Code: | for k,v in ipairs(dwordToByteTable(sz)) do
table.insert(b,k,v)
end |
Seems a lot more obvious to me
|
|
Back to top |
|
|
panraven Grandmaster Cheater Reputation: 55
Joined: 01 Oct 2008 Posts: 942
|
|
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
|
|