How to create a kernel dump using WinDbg
Asked Answered
P

2

9

I'm debugging a kernel-mode device driver for Windows, using WinDbg. Is it possible to create a minidump on-demand?

I mean, one of my breakpoints is hit, the system is stopped. I want to create a minidump (let's say stack only). Is there a WinDbg keyword for this?

Thanks in advance

Perm answered 22/11, 2012 at 20:40 Comment(0)
C
14

You can write a minidump like so when it hits your breakpoint:

bp myDLL!myFunc ".dump /ma c:\myDump.dmp;g"

This will add a breakpoint to your function and execute the commands in the quotation marks, this will write a minidump with most flags and then continue.

See here for more info on .dump and here on bp syntax.

To dump the complete memory in user or kernel mode:

.dump /f

but /ma switch actually puts more information in for user-mode.

If you get the error:

Unable to create file 'c:\myDump.dmp' - Win32 error 0n5
    "Access is denied."

try writing the file to the c:\users\public\ directory.

.dump /f c:\users\public\myDump.dmp
Coquelicot answered 22/11, 2012 at 21:18 Comment(0)
P
1

Note that .dump cannot create a Kernel Memory Dump, only Complete or Small Memory dumps (/f or /m). To get a kernel memory dump, you need to use the Control Panel to enable writing of dump files, then use .crash in the debugger to trigger a crash which will cause a dump file to be written.

See the windbg help for .crash for more details on how to use it, including a link to "Creating a Kernel-Mode Dump File".

Peculiarity answered 23/4, 2014 at 15:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.