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 


New to LUA

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
sitapea1337
Newbie cheater
Reputation: 0

Joined: 29 Mar 2010
Posts: 19

PostPosted: Thu Aug 16, 2012 6:51 am    Post subject: New to LUA Reply with quote

Hello

I've been trying to get this script working, but no success.
It does print address quite fine (in HEX), but doesn't change value of address to "08".

Code:
function DEC_HEX(IN)
    local B,K,OUT,I,D=16,"0123456789ABCDEF","",0
    while IN>0 do
        I=I+1
        IN,D=math.floor(IN/B),math.mod(IN,B)+1
        OUT=string.sub(K,D,D)..OUT
    end
    return OUT
end
debugProcess()  -- Attach Debugger to the process.
function debugger_onBreakpoint()
  HEXADDR=DEC_HEX(ESI+19105885)
  print(HEXADDR)
  writeInteger(HEXADDR,08)
  return 1  --Not Break
end

debug_setBreakpoint(0x005057C2)  -- Address where to set breakpoint


Weird thing is that when I print "ESI" value, then it's in dec, not hex.
So do I need to convert "ESI+19105885" into HEX or I can simply change that address value while it's in DEC?

PS: Is it possible to breakpoint address "test.exe+1057C2"?
"debug_setBreakpoint(test.exe+0x1057C2)" doesn't work.

Thanks in advance,
Sitapea1337
Back to top
View user's profile Send private message
oLaudix
Expert Cheater
Reputation: 3

Joined: 25 Mar 2010
Posts: 138

PostPosted: Thu Aug 16, 2012 8:40 am    Post subject: Reply with quote

Do you want to use ESI as value it stores or [ESI] as address under which the value is stored? I dont know how LUA in cheat engine handle this stuff but when i tried to get addresses they were coming out in string -_-
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

Joined: 09 May 2003
Posts: 25296
Location: The netherlands

PostPosted: Thu Aug 16, 2012 8:47 am    Post subject: Reply with quote

Use getAddress.
getAddress takes a string formatted in ce's symbolhandler and returns the address as a value

two methods

1:
address=getAddress("test.exe")+0x1057c2

2:
address=getAddress("test.exe+1057c2")

and then debug_setBreakpoint(address)




use getAddress to get the

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
sitapea1337
Newbie cheater
Reputation: 0

Joined: 29 Mar 2010
Posts: 19

PostPosted: Thu Aug 16, 2012 8:59 am    Post subject: Reply with quote

oLaudix wrote:
Do you want to use ESI as value it stores or [ESI] as address under which the value is stored? I dont know how LUA in cheat engine handle this stuff but when i tried to get addresses they were coming out in string -_-

Value which ESI stores - not the address of ESI.
At the moment print shows ESI value as decimal.

Code:
  HEXADDR=DEC_HEX(ESI+19105885)
  print(HEXADDR)
writeInteger(HEXADDR,08)
Shows correct address, but "writeInteger(HEXADDR,0Cool" part doesn't change the value of address, which HEXADDR contains, to "08".


Dark Byte wrote:
Use getAddress.
getAddress takes a string formatted in ce's symbolhandler and returns the address as a value

two methods

1:
address=getAddress("test.exe")+0x1057c2

2:
address=getAddress("test.exe+1057c2")

and then debug_setBreakpoint(address)

use getAddress to get the
Thank you very much - works perfectly Smile
Back to top
View user's profile Send private message
oLaudix
Expert Cheater
Reputation: 3

Joined: 25 Mar 2010
Posts: 138

PostPosted: Thu Aug 16, 2012 9:34 am    Post subject: Reply with quote

Oh, now i know what you mean. I dont really know if LUA treats HEXADDR as int in this place. Try $HEXADDR.
Back to top
View user's profile Send private message
sitapea1337
Newbie cheater
Reputation: 0

Joined: 29 Mar 2010
Posts: 19

PostPosted: Thu Aug 16, 2012 11:29 am    Post subject: Reply with quote

Nope - only gives an error.
Print prints HEXADDR correctly - as HEX address-
Though "writeInteger" doesn't change that addresses value...

Is "writeInteger" even the right command for changing memory address value?

EDIT: It seems like that DEC_HEX function returns string value which cannot be used.
Though - "ESI+0x123885D" returns decimal value, it still is correct (tested manually with calculator).

How can I use that decimal value as address? I'd like to change "ESI+0x123885D" address value to "08".

Manually, when address is in HEX, using writeInteger works perfectly.
I think right now the problem is that "ESI+0x123885D" returns as DEC, not HEX, so I can't use it as an address...

Could anyone help me out here? It's the only problem that's standing in my way...


EDIT2:
I feel a bit stupid... I'm trying to change that addresses value and it does change, but very soon after it gets changed again to normal.
Breakpoint hits BEFORE actual ASM code.
I set breakpoint to next address and now my code works fine Smile
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