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 


set data access breakpoint on the address esp+04 immediate

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
skynet888
!BEWARE! Deletes post on answer
Reputation: 1

Joined: 12 Apr 2021
Posts: 106

PostPosted: Thu Dec 03, 2026 6:05 am    Post subject: set data access breakpoint on the address esp+04 immediate Reply with quote

As shown in the screenshot: I want to set a data access breakpoint on the address esp+04 immediately after the instruction mov [esp+04],eax executes. I wrote a Lua script for this, but it has a bug. It causes the Lua output window to spam nonstop, and may crash the target process or Cheat Engine.

Code:
local nextAddr = 0x6933BACB

local function onAccess()
    print(string.format("onAccess:EIP=%X,Addr=%X", EIP, ESP + 4))
    debug_removeBreakpoint(ESP + 4, 4)
    debug_continueFromBreakpoint(co_run)
end

local function onNext()
    debug_removeBreakpoint(nextAddr, 1)
    debug_setBreakpoint(ESP + 4, 4, bptAccess, bpmDebugRegister, onAccess)
    debug_continueFromBreakpoint(co_run)
end

debug_setBreakpoint(nextAddr, 1, bptExecute, bpmDebugRegister, onNext)


[/quote][/code]



111111111111111111111111111111111111111111.png
 Description:
 Filesize:  4.98 KB
 Viewed:  856 Time(s)

111111111111111111111111111111111111111111.png


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

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

PostPosted: Thu Dec 03, 2026 8:10 am    Post subject: Reply with quote

never call debug_continueFromBreakpoint from inside breakpoint handlers
_________________
Tools give you results. Knowledge gives you control.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
skynet888
!BEWARE! Deletes post on answer
Reputation: 1

Joined: 12 Apr 2021
Posts: 106

PostPosted: Fri Dec 04, 2026 1:43 am    Post subject: Reply with quote

Dark Byte wrote:
never call debug_continueFromBreakpoint from inside breakpoint handlers

However, even after modifying the code, there is still a bug:  debug_removeBreakpoint  does not actually remove the breakpoint. As a result, the  print  call inside  onAccess  keeps getting triggered nonstop.
Code:

local nextAddr = 0x9DABACB
local watchedAddr = 0

local function onAccess()
    print(string.format("onAccess触发:EIP=%X,watchedAddr=%X", EIP, watchedAddr))
    debug_removeBreakpoint(watchedAddr, 4)
end

local function onNext()
    watchedAddr = ESP + 4
    print(string.format("onNext触发:EIP=%X,watchedAddr=%X", EIP, watchedAddr))
    debug_removeBreakpoint(nextAddr, 1)
    debug_setBreakpoint(watchedAddr, 4, bptAccess, bpmDebugRegister, onAccess)
end

debug_setBreakpoint(nextAddr, 1, bptExecute, bpmDebugRegister, onNext)



IMG_20261204_153218.jpg
 Description:
 Filesize:  688.09 KB
 Viewed:  417 Time(s)

IMG_20261204_153218.jpg


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

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

PostPosted: Fri Dec 04, 2026 2:13 am    Post subject: Reply with quote

removeBreakpoint takes only 1 parameter, it assumes an error if you give more than 1
_________________
Tools give you results. Knowledge gives you control.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Csimbi
I post too much
Reputation: 99

Joined: 14 Jul 2007
Posts: 3445

PostPosted: Fri Dec 04, 2026 1:07 pm    Post subject: Reply with quote

That did not work for me either, I do it via the UI, manually.
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 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