Using pykd , I came up with the following solution:
First write a Python script (loadModule.py in my example) with the following contents:
from pykd import * import sys event = lastEvent() if event != eventType.LoadModule: sys.exit() # get module load event details in string format details = dbgCommand(".lastevent") # remove the debugger time details = details.split("\n")[0] # get everything behind "Load module" details = details.split("Load module ")[1] # remove address details = details.split(" at ")[0] # remove full path details = details.split("\\")[-1] # remove extension details = ".".join(details.split(".")[0:-1]) # compare case-insensitive details = details.upper() if details in [x.upper() for x in sys.argv[1:]]: breakin()
Then set a breakpoint in the load event as follows:
sxe -c "!py loadModule.py clr mscorwks coreclr;g" ld
This will cause the Python script to execute on every module load event. the script breaks into a debugger (breakin () in the Python script) if the module is found, otherwise it continues (g in WinDbg).
You can use any number of modules. The comparison is case insensitive.
Please note that this may not be the most elegant solution. There seems to be another way: subclassing eventHandler :: onModuleLoad.
source share