|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
potentialunexplored How do I cheat? Reputation: 0
Joined: 06 Mar 2023 Posts: 8
|
Posted: Sat Nov 02, 2024 1:08 pm Post subject: Writing a string into a register |
|
|
Hi, I'm not well versed in Lua at all so forgive me if this is an obvious question.
Here's a script that writes a string into a specific address (2A639EA8). That's the address stored in ecx and it changes every time, so obviously not very convenient.
How do I write it into ecx directly?
Code: | [ENABLE]
{$lua}
local str = "teststring"
local bytes = {}
for i = 1, #str do
local codepoint = string.byte(str:sub(i, i))
if codepoint < 128 then
table.insert(bytes, codepoint)
elseif codepoint < 2048 then
table.insert(bytes, 0xC0 + math.floor(codepoint / 64))
table.insert(bytes, 0x80 + (codepoint % 64))
else
table.insert(bytes, 0xE0 + math.floor(codepoint / 4096))
table.insert(bytes, 0x80 + math.floor((codepoint % 4096) / 64))
table.insert(bytes, 0x80 + (codepoint % 64))
end
end
writeBytes(0x2A639EA8, bytes)
{$asm}
aobscanmodule(INJECT,Game.dll,8D 41 02 89 44 24 14 8D 64) // should be unique
alloc(newmem,$1000)
label(code)
label(return)
newmem:
code:
lea eax,[ecx+02]
mov [esp+14],eax
jmp return
INJECT:
jmp newmem
nop 2
return:
registersymbol(INJECT)
[DISABLE]
//code from here till the end of the code will be used to disable the cheat
INJECT:
db 8D 41 02 89 44 24 14
unregistersymbol(INJECT)
dealloc(newmem) |
|
|
Back to top |
|
|
xxhehe Expert Cheater Reputation: 0
Joined: 11 Mar 2015 Posts: 153
|
Posted: Thu Nov 14, 2024 7:40 pm Post subject: Re: Writing a string into a register |
|
|
potentialunexplored wrote: | Hi, I'm not well versed in Lua at all so forgive me if this is an obvious question.
Here's a script that writes a string into a specific address (2A639EA8). That's the address stored in ecx and it changes every time, so obviously not very convenient.
How do I write it into ecx directly?
Code: | [ENABLE]
{$lua}
local str = "teststring"
local bytes = {}
for i = 1, #str do
local codepoint = string.byte(str:sub(i, i))
if codepoint < 128 then
table.insert(bytes, codepoint)
elseif codepoint < 2048 then
table.insert(bytes, 0xC0 + math.floor(codepoint / 64))
table.insert(bytes, 0x80 + (codepoint % 64))
else
table.insert(bytes, 0xE0 + math.floor(codepoint / 4096))
table.insert(bytes, 0x80 + math.floor((codepoint % 4096) / 64))
table.insert(bytes, 0x80 + (codepoint % 64))
end
end
writeBytes(0x2A639EA8, bytes)
{$asm}
aobscanmodule(INJECT,Game.dll,8D 41 02 89 44 24 14 8D 64) // should be unique
alloc(newmem,$1000)
label(code)
label(return)
newmem:
code:
lea eax,[ecx+02]
mov [esp+14],eax
jmp return
INJECT:
jmp newmem
nop 2
return:
registersymbol(INJECT)
[DISABLE]
//code from here till the end of the code will be used to disable the cheat
INJECT:
db 8D 41 02 89 44 24 14
unregistersymbol(INJECT)
dealloc(newmem) |
|
Write it into to ECX directly
{$asm}
aobscanmodule(INJECT,Game.dll,8D 41 02 89 44 24 14 8D 64) // should be unique
alloc(newmem,$1000)
label(code)
label(return)
newmem:
mov ecx, [esp+4]
writeBytes(ecx, bytes)
jmp return
INJECT:
jmp newmem
nop 2
return:
registersymbol(INJECT)
[DISABLE]
// code from here till the end of the code will be used to disable the cheat
INJECT:
db 8D 41 02 89 44 24 14
unregistersymbol(INJECT)
dealloc(newmem)
|
|
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
|
|