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 


Autoasm script fails inside lua script?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
nnamenb
How do I cheat?
Reputation: 0

Joined: 28 Dec 2017
Posts: 2

PostPosted: Thu Dec 28, 2017 1:35 am    Post subject: Autoasm script fails inside lua script? Reply with quote

Hello everyone, i am trying to make a little zoomhack for a first person shooter, i found the value and instruction that are responsible for it and i wanted to automate script enabling process.

Because of code integrity and dll injection checks i can't use stealthedit and veh debugger so i am forced to use cheat engine internal debugger to hook on my code.

All i need to do is to hook one function which is

Code:

movss [edx+00000280],xmm1


and move my own value instead of xmm1 or replace value in xmm1(which i did below)


This is my original code which works fine, yet i have to manually activate it:
Code:

[ENABLE]
//code from here to '[DISABLE]' will be used to enable the cheat
alloc(zoom,2048,"player.dll"+2F7B9E)
globalalloc(toggle,1)
label(returnhere)
label(originalcode)
label(exit)
registersymbol(zoom)

zoom:

originalcode:
//forum cheatengine org viewtopic.php?t=569608, tnx SteveAndrew
push eax
mov eax,#40 // default value should be around 80 in float, lesser values provide more magnification, we are moving half of it so we should get around x2 magnification
cvtsi2ss xmm1,eax
pop eax
movss [edx+00000280],xmm1
jmp "player.dll"+2F7BA6 //we done here, time to jump to our next function

exit:
jmp returnhere

"player.dll"+2F7B9E:
returnhere:

[DISABLE]
//code from here till the end of the code will be used to disable the cheat
dealloc(zoom)
unregistersymbol(zoom)


And here is the code that gives me error:
Code:

[ENABLE]
//code from
//youtube watch?v=ajIIlNQ5nSU

//potential problem at alloc when using lua?
{$lua}
_bang=[[
alloc(zoom,2048,"player.dll"+2F7B9E)
label(returnhere)
label(originalcode)
label(exit)
registersymbol(zoom)

zoom:

originalcode:
push eax
mov eax,#10
cvtsi2ss xmm1,eax
pop eax
movss [edx+00000280],xmm1
jmp "player.dll"+2F7BA6

exit:
jmp returnhere

"player.dll"+2F7B9E:
returnhere:

]]

print("testing")

function debugger_onBreakpoint()
EIP=getAddress(zoom)  -- EIP 32bit  RIP 64 Bit //potential problem n2?
debug_continueFromBreakpoint(co_run)
end
print("here we go.")
reinitializeSymbolhandler()
print("reinting symbol handler..")
autoAssemble(_bang)
print("autoassembling script...")
debugProcess(1)
print("launching debugger....")
debug_setBreakpoint("player.dll+2F7B9E")
print("adding breakpoint....")

[DISABLE]
{$lua}
debug_removeBreakpoint("player.dll+2F7B9E")

{$asm}

"player.dll"+2F7B9E:
movss [edx+00000280],xmm1


Thing is that this script above correctly sets breakpoint on address that i need, but is either unable to allocate autoassembly code or it just can't get it address and set it to eip.

Here is the lua engine output:
Code:

testing
here we go.
reinting symbol handler..
autoassembling script...
launching debugger....
adding breakpoint....
Error:Failure determining what  means


I would appreciate any info on how to fix problem or debug script Very Happy
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Thu Dec 28, 2017 10:43 am    Post subject: Reply with quote

Since the error message appears after all the debug statements that means they run first, which means the code runs, and it's some function setup by your code which runs later causing the error. The only function that's setup to run later is the breakpoint handler, so that's where the focus needs to be now, fortunately it's short.

Code:
EIP=getAddress(zoom)  -- EIP 32bit  RIP 64 Bit //potential problem n2?


tries to set EIP to the value returned by calling getAddress with the value of the variable zoom. Since zoom in your script is a registered symbol not a lua variable, and therefore the variable zoom is nil, getAddress can't figure out what nil aka "nothing" is. You should use EIP = getAddress('zoom')
Back to top
View user's profile Send private message
nnamenb
How do I cheat?
Reputation: 0

Joined: 28 Dec 2017
Posts: 2

PostPosted: Thu Dec 28, 2017 7:44 pm    Post subject: Reply with quote

FreeER wrote:
Since the error message appears after all the debug statements that means they run first, which means the code runs, and it's some function setup by your code which runs later causing the error. The only function that's setup to run later is the breakpoint handler, so that's where the focus needs to be now, fortunately it's short.

Code:
EIP=getAddress(zoom)  -- EIP 32bit  RIP 64 Bit //potential problem n2?


tries to set EIP to the value returned by calling getAddress with the value of the variable zoom. Since zoom in your script is a registered symbol not a lua variable, and therefore the variable zoom is nil, getAddress can't figure out what nil aka "nothing" is. You should use EIP = getAddress('zoom')

Thank you very much for reading my post and correcting my mistake Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
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