MiniDumpWriteDump

Writes user-mode minidump information to the specified file.

Syntax

BOOL MiniDumpWriteDump(
         HANDLE hProcess,
         DWORD ProcessId,
         HANDLE hFile,
         MINIDUMP_TYPE DumpType,
         PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,
         PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,
         PMINIDUMP_CALLBACK_INFORMATION CallbackParam
)  

Parameters

hProcess
Type: HANDLE 

[in]

A handle to the process for which the information is to be generated.

This handle must have PROCESS_QUERY_INFORMATION and PROCESS_VM_READ access to the process. If handle information is to be collected then PROCESS_DUP_HANDLE access is also required. For more information, see Process Security and Access Rights. The caller must also be able to get THREAD_ALL_ACCESS access to the threads in the process. For more information, see Thread Security and Access Rights.

ProcessId
Type: DWORD 

[in] The identifier of the process for which the information is to be generated.

hFile
Type: HANDLE 

[in] A handle to the file in which the information is to be written.

DumpType
Type: MINIDUMP_TYPE 

[in] The type of information to be generated. This parameter can be one or more of the values from the MINIDUMP_TYPE enumeration.

ExceptionParam
Type: PMINIDUMP_EXCEPTION_INFORMATION 

[in, optional] A pointer to a MINIDUMP_EXCEPTION_INFORMATION structure describing the client exception that caused the minidump to be generated. If the value of this parameter is NULL, no exception information is included in the minidump file.

UserStreamParam
Type: PMINIDUMP_USER_STREAM_INFORMATION 

[in, optional] A pointer to a MINIDUMP_USER_STREAM_INFORMATION structure. If the value of this parameter is NULL, no user-defined information is included in the minidump file.

CallbackParam
Type: PMINIDUMP_CALLBACK_INFORMATION 

[in, optional] Currently unsupported. Passing a value other than NULL will result in MiniDumpWriteDump returning E_INVALIDARG.

Return value

Type: BOOL 

If the function succeeds, the return value is TRUE; otherwise, the return value is FALSE. To retrieve extended error information, call GetLastError. Note that the last error will be an HRESULT value.

If the operation is canceled, the last error code is HRESULT_FROM_WIN32(ERROR_CANCELLED).

Remarks

MiniDumpWriteDump should be called from a separate process or thread if at all possible, rather than from within the target process being dumped. This is especially true when the target process is already not stable. For example, if it just crashed. A loader deadlock is one of many potential side effects of calling MiniDumpWriteDump from within the target process.

MiniDumpWriteDump may not produce a valid stack trace for the calling thread. To work around this problem, you must capture the state of the calling thread before calling MiniDumpWriteDump and use it as the ExceptionParam parameter. One way to do this is to force an exception inside a __try/__except block and use the EXCEPTION_POINTERS information provided by GetExceptionInformation. Alternatively, you can call the function from a new worker thread and filter this worker thread from the dump.

All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more than one thread to this function.

Requirements

Header: Declared in dbghelp.h.

Library: Use dbghelp.lib.

See also

MiniDumpWriteDump Overview

MINIDUMP_EXCEPTION_INFORMATION

MINIDUMP_USER_STREAM_INFORMATION