I'm debugging a user-mode process "myprocess.exe" which has a long running operations, constantly doing system calls to kernel mode, how can i break on syscalls, for example: i want to break and examine all ZwCreateEvent calls, that are called from "myprocess.exe" ?
If i just do bp nt!ZwCreateEvent i get thousands of breakpoints from across the system, not related to the "myprocess.exe" and it is impbossible to catch ones that are coming from "myprocess.exe"
I know that there are conditional breakpoints, but i don't have a specific parameter to which i can bind myself ( the one with constant known value or string )
You can set kernel breakpoints per process using the
bp /pcommand (doc):To get the
EPROCESSstructure (which represents a process object in kernel land), you can issue the!processcommand:Example with notepad:
The hexadecimal number right at the top of the output (
ffffbe8e593d3080above) is the address of the EPROCESS structure. If you have more than one process with the same name, you can discriminate between them using theCid(otherwise known a PID, Process identifier).Setting a BP:
Debugging a userland process in kernel mode is sometimes a bit contrived. I'd suggest to debug your process using windbg in user mode and setting a breakpoint at the user / kernel boundary (that is, in
ntdll.dll), simply:Note that in this case (from a user-mode debugger) you're setting a breakpoint in the function that performs the syscall (transitioning to kernel mode):
Obviously, you won't be able to step in kernel mode from there.