Hi,
When I try to put a breakpoint on stack memory, it doesn't get hit, could somebody explain me why that is?
example code:
$ cat stackm.c
int main(){
int i=5;
while (i--)
printf("%i\n");
}
$cl stackm.c
$ cat stackbp.py
from pydbg.defines import *
from pydbg import *
dbg=pydbg()
dbg.load('stackm.exe')
def bp_h(dbg):
print 'breakpoint hit'
for i in dbg.disasm_around(0x40101B):
print "0x%08x %s" % i
dbg.bp_set_mem(0x12FF64,40,"memb",bp_h)
def bp_h2(dbg):
esp=dbg.context.Esp
eip=dbg.context.Eip
print "esp: 0x%08x" % dbg.context.Esp
print "eip: 0x%08x >> %s" % (eip , dbg.disasm(eip ))
return DBG_CONTINUE
dbg.bp_set(0x401020,"codebp",True,bp_h2)
print "bp is ours mem @ 0x%08x" % dbg.bp_is_ours_mem(0x0012ff68)
dbg.run()
$ python stackbp.py
0x0040100e mov ecx,[ebp-0x4]
0x00401011 sub ecx,0x1
0x00401014 mov [ebp-0x4],ecx
0x00401017 test eax,eax
0x00401019 jz 0x40102a
0x0040101b push 0x40c000
0x00401020 call 0x401030
0x00401025 add esp,0x4
0x00401028 jmp 0x40100b
0x0040102a xor eax,eax
0x0040102c mov esp,ebp
bp is ours mem @ 0x0012ff64
esp: 0x0012ff68
eip: 0x00401020 >> call 0x401030
4
esp: 0x0012ff68
eip: 0x00401020 >> call 0x401030
3
esp: 0x0012ff68
eip: 0x00401020 >> call 0x401030
2
esp: 0x0012ff68
eip: 0x00401020 >> call 0x401030
1
esp: 0x0012ff68
eip: 0x00401020 >> call 0x401030
0






