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 


Conditional Breakpoint and Script em loop

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

Joined: 20 Jul 2023
Posts: 5

PostPosted: Sat Jul 22, 2023 6:51 pm    Post subject: Conditional Breakpoint and Script em loop Reply with quote

Hello!

[RDI + 18] --> POINTER A (8 BYTES ADDRESS) --> POINTER A + OFFSET 0x20 --> VALUE (for instance: value = 0x4DA)

How can I make a conditional breakpoint where [RDI+18] contains an 8 byte address and that address added to 0x20 results in a certain value.

How would a script that would be in a loop checking the instruction game.exe + 232F0D1 and when the 4DA value was written
in memory would make a breakpoint.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4702

PostPosted: Sat Jul 22, 2023 9:25 pm    Post subject: Reply with quote

What type is the value? 4 byte?
toto92 wrote:
[RDI + 18] --> POINTER A (8 BYTES ADDRESS) --> POINTER A + OFFSET 0x20 --> VALUE (for instance: value = 0x4DA)
This is confusingly worded. Normally an arrow `->` means "this pointer points to...", but you seem to be using "POINTER A" twice...?
If that's supposed to be a level 1 pointer w/ base address RDI+0x18 and 1 offset of 0x20, then use this simple condition:
Code:
readInteger(readPointer(RDI+0x18)+0x20) == 0x4DA


toto92 wrote:
How would a script that would be in a loop checking the instruction game.exe + 232F0D1 and when the 4DA value was written
in memory would make a breakpoint.
That's not how conditional breakpoints work. You set a breakpoint on an instruction. It always gets triggered every time it's run. If the condition is false, tell the game to continue running. If the condition is true, then collect debug information and present it to the user.

Select an instruction and set a breakpoint in the memory viewer using the "Debug" menu or by pressing F5. Right click the instruction after it's set and set a condition.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
toto92
How do I cheat?
Reputation: 0

Joined: 20 Jul 2023
Posts: 5

PostPosted: Sun Jul 23, 2023 9:46 am    Post subject: Reply with quote

ParkourPenguin wrote:
What type is the value? 4 byte?
toto92 wrote:
[RDI + 18] --> POINTER A (8 BYTES ADDRESS) --> POINTER A + OFFSET 0x20 --> VALUE (for instance: value = 0x4DA)
This is confusingly worded. Normally an arrow `->` means "this pointer points to...", but you seem to be using "POINTER A" twice...?
If that's supposed to be a level 1 pointer w/ base address RDI+0x18 and 1 offset of 0x20, then use this simple condition:
Code:
readInteger(readPointer(RDI+0x18)+0x20) == 0x4DA


toto92 wrote:
How would a script that would be in a loop checking the instruction game.exe + 232F0D1 and when the 4DA value was written
in memory would make a breakpoint.
That's not how conditional breakpoints work. You set a breakpoint on an instruction. It always gets triggered every time it's run. If the condition is false, tell the game to continue running. If the condition is true, then collect debug information and present it to the user.

Select an instruction and set a breakpoint in the memory viewer using the "Debug" menu or by pressing F5. Right click the instruction after it's set and set a condition.


Thank you very much!

The game has the following instruction:

game.exe+232F0D1 - 48 8B 77 18 - mov rsi,[rdi+18]

I would like to make a script in lua similar to the example below, and that would check all the time at the address game.exe + 232F0D1 and when y = 0x00000000000004DA, a breakpoint would be made. I would like an automatic check to be made until finding the value recorded in memory. The game is 64-bit and the saved value can be 8 bytes.

It's possible?

debugProcess()
debug_setBreakpoint("game.exe+232F0D1")
x = readQword(RDI+0x18) -- x stores an 8-byte address.
y = readQword (x + 0x20) -- the address (8 bytes) contained in x + offset 20 stores the value of y
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4702

PostPosted: Sun Jul 23, 2023 11:14 am    Post subject: Reply with quote

Code:
local addr = getAddress'game.exe+232F0D1'

debug_removeBreakpoint(addr)

debug_setBreakpoint(addr, function()
  if readQword(readPointer(RDI+0x18)+0x20) == 0x4DA then
    return 1
  else
    return 0
  end
end)

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
toto92
How do I cheat?
Reputation: 0

Joined: 20 Jul 2023
Posts: 5

PostPosted: Sun Jul 23, 2023 6:06 pm    Post subject: Reply with quote

ParkourPenguin wrote:
Code:
local addr = getAddress'game.exe+232F0D1'

debug_removeBreakpoint(addr)

debug_setBreakpoint(addr, function()
  if readQword(readPointer(RDI+0x18)+0x20) == 0x4DA then
    return 1
  else
    return 0
  end
end)


Thank you very much for your help.
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