How to debug random BSOD

Hi everybody,

I’ve started showing a lot more interest recently in windows kernel development. So far what I did was mostly “tinkering” in the kernel, meaning playing around a bit with the various APIs that are available: creating a device, setup some IOCTL communication with my usermode process, then do simple things such as parsing the list of executable processes and sending back the information to usermode. So far everything worked perfectly

I am now working on another project: a minifilter driver. I am facing a lot of random BSOD, random in the sense that:

  1. BSOD never occurs in my driver, it can actually happen after I successfully exited the driver
  2. BSOD location varies from one run to another: sometimes it’s in FltMgr.sys, sometimes in nvidia driver, sometimes svchost.exe, looks a bit random
  3. BSOD code varies from one run to another (sometimes BAD_POOL_HEADER, sometimes SYSTEM_THREAD_EXCEPTION, sometimes something else)

I am looking for advice on how to debug properly those “randoms” BSOD. I can also post some crash dump here if you are interested.

Thank you very much for your help and I wish you a very pleasant day.

It’s very likely you are stomping on someone else’s memory, either through a buffer over/underrun, or via a stray pointer. There are other causes, but that would be the first thing to look for. Run it with Driver Verifier on with all checks except Low Memory Simulation.
Good hunting!

1 Like

I found one ugly bug, thank you very much, I actually allocated a buffer with sizeof(PSTRUCT) instead of sizeof(STRUCT).
Fixing this fixed my BSOD issue.