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 


writeInteger() sometime fails

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
danrevella
Master Cheater
Reputation: 2

Joined: 11 Jun 2008
Posts: 290

PostPosted: Fri Apr 10, 2015 5:53 am    Post subject: writeInteger() sometime fails Reply with quote

Hi!!
suppose I have attacched the VEH debugger at program "test.exe"
This code work OK!!!
Code:

myaddress=getAddress("test.exe")+0x1384
debug_setBreakpoint(myaddress); -- Address where to set breakpoint

ind_val_numerico=getAddress("test.exe+1d090")
writeInteger(ind_val_numerico,55)--ottenuto da getAddresses
return 1; --con 0 visualizza memory interface



This code does NOT work, to be more precise the line:
writeInteger(ind_val_numerico,55)--ottenuto da getAddresses
have no effect!!

Code:

myaddress=getAddress("test.exe")+0x1384
debug_setBreakpoint(myaddress); -- Address where to set breakpoint
function debugger_onBreakpoint()
ind_val_numerico=getAddress("test.exe+1d090")
writeInteger(ind_val_numerico,55)--ottenuto da getAddresses
return 1; --con 0 visualizza memory interface
end


Please were is my error?
Back to top
View user's profile Send private message
ZacTheSin
I post too much
Reputation: 6

Joined: 09 May 2006
Posts: 2657

PostPosted: Fri Apr 10, 2015 6:52 am    Post subject: Reply with quote

Are you calling the function somewhere not in your code displayed?

like just running debugger_onBreakpoint()

_________________
If someone helps you, why not Rep them?
Back to top
View user's profile Send private message
danrevella
Master Cheater
Reputation: 2

Joined: 11 Jun 2008
Posts: 290

PostPosted: Fri Apr 10, 2015 8:38 am    Post subject: Reply with quote

ZacTheSin wrote:
Are you calling the function somewhere not in your code displayed?

like just running debugger_onBreakpoint()

Yes, as you may see at line 3 of "code NOT working" I utilize the debugger_onBreakpoint() function, as I need that every time that breakpoint happens i would like that :
Code:
writeInteger(ind_val_numerico,55)

but it fails.
Thanks
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Fri Apr 10, 2015 9:23 am    Post subject: Reply with quote

make sure the breakpoint is after the write, else when you continue the value you wrote will be undone
_________________
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
danrevella
Master Cheater
Reputation: 2

Joined: 11 Jun 2008
Posts: 290

PostPosted: Fri Apr 10, 2015 9:46 am    Post subject: Reply with quote

Dark Byte wrote:
make sure the breakpoint is after the write, else when you continue the value you wrote will be undone

Thanks, but in many case I get the memory location only elaborating the breakpoint output, f.e. I know that the memory location I must patch is f.e. :
memory_to_write=RAX+1258
but I need the value of Rax when the breakpoint does appears...
I need to perform this patch every time I reach breakpoint...
Any possibility?
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Fri Apr 10, 2015 1:13 pm    Post subject: Reply with quote

What Dark Byte was pointing out is that if you set your breakpoint on the following instruction:
mov [ebx],eax

And your code essentially writes a value into the same address of EBX...
Then your code will execute, followed by the normal game code...
Overwriting whatever you just put into [ebx] with what was in EAX.
So you should set your breakpoint on the instruction AFTER mov [ebx],eax

Also, I know LUA has access to the registers, but I don't know if it can update them.
Instead of writeInteger(), try simply "EAX = 55". Will that work Dark Byte? Smile
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Fri Apr 10, 2015 2:00 pm    Post subject: Reply with quote

EAX=55 will work yes
_________________
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
danrevella
Master Cheater
Reputation: 2

Joined: 11 Jun 2008
Posts: 290

PostPosted: Fri Apr 10, 2015 2:50 pm    Post subject: Reply with quote

Ok, I understand the point about overwriting...
BTW, (and please excuse for my very poor english...) what I need is the follows:
I have set a "permanent" breakpoint f.e. at Test.exe+0x2120, and I want that every time breakpoint is reached, the memory location at f.e.: "test.exe+1d090" is filled with the fix value of 0x55.
I have defined this in my code with:
writeInteger(ind_val_numerico,55)
but seem to be that inside the function debugger_onBreakpoint() is possible execute many type of code, f.e. about setting register, etc, but seem to be impossible write a value to a memory location, at least in the mode I have definited the code (please look at the top of the post: code NOT working)

Thanks...
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Fri Apr 10, 2015 3:03 pm    Post subject: Reply with quote

use fullAccess(address, size) to make read only sections writable first
_________________
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
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Fri Apr 10, 2015 3:07 pm    Post subject: Reply with quote

Copy (CTRL+C) the instruction at Test.exe+0x2120 and the one after it so we can see where you're setting the breakpoint.

As we've said, chances are the game is directly overwriting the value you just wrote into that integer.

Or the instruction at Test.exe+0x2120 is not executing like you think and so your code is never run.
Back to top
View user's profile Send private message
danrevella
Master Cheater
Reputation: 2

Joined: 11 Jun 2008
Posts: 290

PostPosted: Fri Apr 10, 2015 4:07 pm    Post subject: Reply with quote

here is the test prog with the (not)working table.
File is really tiny
https://www.sendspace.com/file/ac6l3u
I woul like to precise that the file test.exe was original supplied on the old cheat prog: Magic Trainer Creator by Olivier Pasqualini.
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