mxmssh / idapython

Automatically exported from code.google.com/p/idapython
Other
0 stars 0 forks source link

PYTHON25.DLL crashes with debughook.hook() when not in a script's global scope. #57

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It can be reproduced with this code:

def main():        
    debughook = MyDbgHook() # A basic inheritance from DBGHooks
    debughook.hook()
    debughook.steps = 0

    end = GetLongPrm(INF_MAX_EA)
    request_run_to(end)
    run_requests()

if __name__ == "__main__":
    main()

IDA tries to run the debuggee but it crashes just at the beginning.
It happens at least with IDA5.5 & 5.6

I've found a workaround for this that i think explains in someway where the 
problem resides. If i register the hook outside the main() function it works 
flawlessly so i think the problem is related to the scope at the moment of  the 
debughook.hook() call.

Workaround example:

def main():        
    run_requests()

if __name__ == "__main__":
    # Install the debug hook
    debughook = MyDbgHook()
    debughook.hook()
    debughook.steps = 0

    end = GetLongPrm(INF_MAX_EA)
    request_run_to(end)
    main()   

Original issue reported on code.google.com by aLS.a...@gmail.com on 22 Sep 2010 at 4:50

GoogleCodeExporter commented 9 years ago
Does this problem exist in IDA 5.7?

Original comment by elias.ba...@gmail.com on 23 Sep 2010 at 2:27

GoogleCodeExporter commented 9 years ago
Yes, sorry. I mean 5.6 & 5.7

Original comment by aLS.a...@gmail.com on 23 Sep 2010 at 4:18

GoogleCodeExporter commented 9 years ago
Yes this is natural. If the debug hook is created in a local scope, it will be 
stale when function exists.

Either write a plugin script to properly hook / unhook OR just use a global 
hook.

This is not a bug.

Original comment by elias.ba...@gmail.com on 30 Sep 2010 at 9:02