1
"""Debug events handler: test [un-]load modules notification"""
9
class ModuleLoadHandler(pykd.eventHandler):
10
"""Track load/unload module implementation"""
11
def __init__(self, moduleMask):
12
pykd.eventHandler.__init__(self)
14
self.moduleMask = moduleMask.lower()
17
self.wasUnload = False
19
def onLoadModule(self, modBase, name):
20
"""Load module handler"""
22
if ( fnmatch.fnmatch(name.lower(), self.moduleMask) ):
23
self.wasLoad = modBase
25
return pykd.executionStatus.NoChange
27
def onUnloadModule(self, modBase, name):
28
"""Unload module handler"""
30
if ( self.wasLoad and (self.wasLoad == modBase) ):
33
return pykd.executionStatus.NoChange
35
class EhLoadTest(unittest.TestCase):
36
"""Unit tests of [un-]load modules notification"""
38
def testLoadUnload(self):
39
"""Start new process and track loading and unloading modules"""
40
pykd.startProcess(target.appPath + " loadunloadmodule")
41
with testutils.ContextCallIt( pykd.killProcess ) as contextCallIt:
43
pykd.go() # skip initail break
45
modLoadHandler = ModuleLoadHandler( "ws2_32*" )
49
#with testutils.ContextCallIt( getattr(modLoadHandler, "reset") ) as resetEventHandler:
53
# except pykd.WaitEventException:
56
self.assertTrue(modLoadHandler.wasLoad)
57
self.assertTrue(modLoadHandler.wasUnload)