| View previous topic :: View next topic |
| Author |
Message |
peddroelm Advanced Cheater
Reputation: 0
Joined: 03 Oct 2014 Posts: 84
|
Posted: Fri Mar 11, 2016 10:34 am Post subject: How do I run different code for multiple BPs in debugger_onB |
|
|
| Code: |
debug_removeBreakpoint(addressbp1)
isDebugging=nil
addressbp1=nil
end
addressbp1=0x24BEEAF4
function debugger_onBreakpoint()
-- if (EIP == addressbp1) then
print(EIP)
print (addressbp1)
print(2500-readFloat(addressbp1))
writeFloat(addressbp1, 2500.0)
debug_continueFromBreakpoint(co_run)
-- end
return 1
end
debug_setBreakpoint(addressbp1, 4, bptWrite)
isDebugging=true
Output
...
4468405 // EIP
618431220 // addressbp1
135.0 // damage received
4468405 // EIP
618431220 //addressbp1
236.0 //damage received
..
|
the 1 breakpoint works flawlessly but how can I add code for a different BP since apparently EIP doesn't wanna tell which BP triggered the function debugger_onBreakpoint?
EDIT1
had an idea - since EIP is not cooperating (data breakpoint not execution one - to check some of the general purpose registers.)
| Code: | print (addressbp1)
print (EAX)
print (ESI)
print (EDI)
print(2500-readFloat(addressbp1))
Output:
612821748
612821748
33662396
632301888
133.0
612821748
612821748
33658444
632301888
1347.0
612821748
612821748
33662396
632301888
1852.0
|
EAX has the BP address in this case. Don't know enough - but it seems a safe bet 1 of the general purpose registers to hold the guilty address.
Perhaps I'll need to check them all with OR. Perhaps EAX will work every time for this game ...
Would've been better if CE transferred BP number as a parameter but ..
|
|
| Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Fri Mar 11, 2016 12:21 pm Post subject: |
|
|
You are setting your breakpoint on a variable's address.
EIP contains the current address of the INSTRUCTION which touched your variable.
Normally, you would set your breakpoint on the instruction itself.
This is how you would use EIP to differentiate between each breakpoint.
Maybe try this instead
| Code: | function invoke_bp1()
-- blah blah
end
debug_setBreakpoint(addressbp1, 4, bptWrite, invoke_bp1) |
|
|
| Back to top |
|
 |
peddroelm Advanced Cheater
Reputation: 0
Joined: 03 Oct 2014 Posts: 84
|
Posted: Fri Mar 11, 2016 12:42 pm Post subject: |
|
|
the "application" is damage combat log:
Hardware write breakpoint on the address of the variable that holds shield/armor/health hit point values.
(I think )There might be multiple instructions that modify that address - but I want to catch all changes to HP. Plus is easier for my limited skill level to find the variable address than the (multiple) instructions that mess with it.
About the code snippet. Tried that before but couldn't get it to work (~same code inside the invoke_bpl function with the code in debugger_onBreakpoint ) for some reason - the execution would not resume after the breakpoint triggered. I had to manually F9 to resume execution (millisecond take more damage (automated weapon) - stuck again ) ..
Gave up, tried this other option which to my surprise (so far) appears to be working
| Code: | if (isDebugging~=nil) and (addressbp1~=nil) then
debug_removeBreakpoint(addressbp1)
isDebugging=nil
addressbp1=nil
end
addressbp1=0x248FEAF4
timestampbp1 = 0
function debugger_onBreakpoint()
if (EAX == addressbp1) then
print(string.format("Timediff: %9.3f Shield Damage : %5.3f ", os.clock()-timestampbp1, 2500-readFloat(addressbp1) ))
writeFloat(addressbp1, 2500.0)
timestampbp1 = os.clock()
debug_continueFromBreakpoint(co_run)
end
return 1
end
debug_setBreakpoint(addressbp1, 4, bptWrite)
isDebugging=true
Output
Timediff: 750.114 Shield Damage : 1347.000
Timediff: 3.584 Shield Damage : 1852.000
Timediff: 1.077 Shield Damage : 1852.000
Timediff: 3.298 Shield Damage : 1852.000
Timediff: 1.077 Shield Damage : 1852.000
Timediff: 1.077 Shield Damage : 1852.000
Timediff: 3.117 Shield Damage : 1852.000
Timediff: 1.081 Shield Damage : 1852.000
Timediff: 1.082 Shield Damage : 1852.000
Timediff: 1.085 Shield Damage : 1852.000
Timediff: 3.209 Shield Damage : 1852.000
Timediff: 1.078 Shield Damage : 1852.000
Timediff: 3.414 Shield Damage : 1347.000
Timediff: 2.714 Shield Damage : 1852.000
Timediff: 8.004 Shield Damage : 1852.000
Timediff: 3.164 Shield Damage : 1347.000
Timediff: 2.563 Shield Damage : 1852.000 |
(..context mass effect 3 SP grissom academy mission Atlas shooting level 37 Sheppard (inflated shields value) with guns , rockets and occasionally melee attacks ..)
will soon try with 2 breakpoints
|
|
| Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Fri Mar 11, 2016 3:04 pm Post subject: |
|
|
Sounds like your previous invoke_bp1 function didn't contain BOTH
| Code: | debug_continueFromBreakpoint(co_run)
return 1 |
|
|
| Back to top |
|
 |
peddroelm Advanced Cheater
Reputation: 0
Joined: 03 Oct 2014 Posts: 84
|
Posted: Fri Mar 11, 2016 3:07 pm Post subject: |
|
|
| Zanzer wrote: | Sounds like your previous invoke_bp1 function didn't contain BOTH
| Code: | debug_continueFromBreakpoint(co_run)
return 1 |
|
. It did. But for some strange reason ..it didn't work
| Code: | -- comment
if (isDebugging~=nil) and (addressBP1~=nil) then
debug_removeBreakpoint(addressBP1)
isDebugging=nil
address=nil -- should be addressBP1 here could this be it ?"
end
addressBP1=0x24D996F4
function debugger_onBreakpointBP1()
print(500-readFloat(addressBP1))
writeFloat(addressBP1, 500.0)
debug_continueFromBreakpoint(co_run)
return 1
end
debug_setBreakpoint(addressBP1, 4, bptWrite,debugger_onBreakpointBP1())
isDebugging=true |
I also had () to the function name when declaring the breakpoint but the function did get called ..
Last edited by peddroelm on Fri Mar 11, 2016 3:10 pm; edited 1 time in total |
|
| Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Fri Mar 11, 2016 3:10 pm Post subject: |
|
|
Parenthesis are for calling a function, you only want to pass the variable containing the function (its name).
| Code: | | debug_setBreakpoint(addressBP1, 4, bptWrite,debugger_onBreakpointBP1) |
|
|
| Back to top |
|
 |
peddroelm Advanced Cheater
Reputation: 0
Joined: 03 Oct 2014 Posts: 84
|
Posted: Fri Mar 11, 2016 3:12 pm Post subject: |
|
|
| Zanzer wrote: | Parenthesis are for calling a function, you only want to pass the variable containing the function (its name).
| Code: | | debug_setBreakpoint(addressBP1, 4, bptWrite,debugger_onBreakpointBP1) |
|
will try again tomorrow. It would be a much better solution than praying for the address to be in one of the usual registers.
|
|
| Back to top |
|
 |
peddroelm Advanced Cheater
Reputation: 0
Joined: 03 Oct 2014 Posts: 84
|
Posted: Fri Mar 11, 2016 11:36 pm Post subject: |
|
|
You were right. Worked great.
| Code: | if (isDebugging~=nil) and (addressbp1~=nil) then
debug_removeBreakpoint(addressbp1)
debug_removeBreakpoint(addressbp2)
isDebugging=nil
addressbp1=nil
addressbp2=nil
end
addressbp1=0x24BDEEF4
addressbp2=0x08623AF4
timestamp = 0
function debugger_onBreakpointBP1()
print(string.format("SHEP Timediff: %9.3f Shield Damage : %5.3f ", os.clock()-timestamp, 2500-readFloat(addressbp1) ))
writeFloat(addressbp1, 2500.0)
timestamp = os.clock()
debug_continueFromBreakpoint(co_run)
return 1
end
function debugger_onBreakpointBP2()
print(string.format("Atlas Timediff: %9.3f Shield Damage : %5.3f ", os.clock()-timestamp, 8000-readFloat(addressbp2) ))
writeFloat(addressbp2, 8000.0)
timestamp = os.clock()
debug_continueFromBreakpoint(co_run)
return 1
end
debug_setBreakpoint(addressbp1, 4, bptWrite , debugger_onBreakpointBP1)
debug_setBreakpoint(addressbp2, 4, bptWrite , debugger_onBreakpointBP2)
isDebugging=true
output:
..
Atlas Timediff: 2103.552 Shield Damage : 77.000
Atlas Timediff: 0.086 Shield Damage : 77.000
Atlas Timediff: 0.010 Shield Damage : 0.000
Atlas Timediff: 0.099 Shield Damage : 77.000
Atlas Timediff: 0.262 Shield Damage : 0.000
Atlas Timediff: 0.494 Shield Damage : 0.000
Atlas Timediff: 0.493 Shield Damage : 0.000
Atlas Timediff: 0.493 Shield Damage : 0.000
Atlas Timediff: 0.493 Shield Damage : 0.000
Atlas Timediff: 0.493 Shield Damage : 0.000
Atlas Timediff: 2.512 Shield Damage : 77.000
Atlas Timediff: 0.010 Shield Damage : 0.000
Atlas Timediff: 0.075 Shield Damage : 77.000
Atlas Timediff: 0.010 Shield Damage : 0.000
Atlas Timediff: 0.085 Shield Damage : 77.000
Atlas Timediff: 0.010 Shield Damage : 0.000
SHEP Timediff: 0.077 Shield Damage : 1852.000
Atlas Timediff: 0.168 Shield Damage : 0.000
Atlas Timediff: 0.489 Shield Damage : 0.000
SHEP Timediff: 0.392 Shield Damage : 1852.000
Atlas Timediff: 0.105 Shield Damage : 0.000
Atlas Timediff: 0.480 Shield Damage : 0.000
Atlas Timediff: 0.493 Shield Damage : 0.000
Atlas Timediff: 0.493 Shield Damage : 0.000
Atlas Timediff: 0.542 Shield Damage : 77.000
Atlas Timediff: 0.087 Shield Damage : 77.000
.. |
|
|
| Back to top |
|
 |
|