I have a task to collect dumps of running processes in windows. For this purpose I use MiniDumpWriteDump function. I have no problems with this function on OS older than Windows 7. However, recently it stopped working on vindows 7. I had previously encountered implementation problems for version 7, then I had to set exceptionInfo.ClientPointers = TRUE; For systems older than 7: exceptionInfo.ClientPointers = FALSE; But now the MiniDumpWriteDump call returns 0. I tried to get the error code using EXCEPTION_POINTERS. But I'm getting back a value of 148696056, which doesn't match any described here.
for( const auto& process : GetActiveProcesses() )
{
if( process.ExeFile() == mProcessName )
{
try
{
String dump_name = GetDumpFileName( process.ProcessID() );
bfs::wpath dump_path = assembly_directory / dump_name;
MINIDUMP_EXCEPTION_INFORMATION exceptionInfo = { 0 };
if( IsWindows8OrGreater() )
exceptionInfo.ClientPointers = FALSE;
else
exceptionInfo.ClientPointers = TRUE;
HANDLE hProcess =
::OpenProcess( PROCESS_VM_READ | PROCESS_QUERY_INFORMATION, FALSE, process.ProcessID() );
exceptionInfo.ThreadId = GetThreadId(hProcess) ;
EXCEPTION_POINTERS exceptionPointers;
exceptionInfo.ExceptionPointers = &exceptionPointers;
if( hProcess == INVALID_HANDLE_VALUE )
{
// error log
}
HANDLE hDumpFile = ::CreateFile( dump_path.wstring().c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL );
if( hDumpFile == INVALID_HANDLE_VALUE )
{
::CloseHandle( hProcess );
// error log
}
auto res =
::MiniDumpWriteDump( hProcess, process.ProcessID(), hDumpFile,
( MINIDUMP_TYPE )( MiniDumpNormal | MiniDumpWithIndirectlyReferencedMemory |
MiniDumpWithDataSegs | MiniDumpWithFullMemory ),
&exceptionInfo, nullptr, nullptr );
::CloseHandle( hProcess );
::CloseHandle( hDumpFile );
if( res )
{
// work with dump
}
else
{
bfs::remove( dump_path );
DWORD exceptionCode = exceptionInfo.ExceptionPointers->ExceptionRecord->ExceptionCode;
String result = L"";
switch (exceptionCode)
{
case EXCEPTION_ACCESS_VIOLATION:
result = L"Access Violation Exception";
break;
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
result = L"Array Bounds Exceeded Exception";
break;
case EXCEPTION_BREAKPOINT:
result = L"Breakpoint Exception";
break;
case EXCEPTION_DATATYPE_MISALIGNMENT:
result = L"Datatype Misalignment Exception";
break;
case EXCEPTION_FLT_DENORMAL_OPERAND:
result = L"Floating Point Denormal Operand Exception";
break;
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
result = L"Floating Point Divide By Zero Exception";
break;
case EXCEPTION_ILLEGAL_INSTRUCTION:
result = L"Illegal Instruction Exception";
break;
case EXCEPTION_IN_PAGE_ERROR:
result = L"In Page Error Exception";
break;
case EXCEPTION_INT_DIVIDE_BY_ZERO:
result = L"Integer Divide By Zero Exception";
break;
case EXCEPTION_INVALID_DISPOSITION:
result = L"Invalid Disposition Exception";
break;
case EXCEPTION_NONCONTINUABLE_EXCEPTION:
result = L"Noncontinuable Exception";
break;
case EXCEPTION_PRIV_INSTRUCTION:
result = L"Privileged Instruction Exception";
break;
case EXCEPTION_STACK_OVERFLOW:
result = L"Stack Overflow Exception";
break;
default:
result = L"Unknown Exception";
break;
}
ErrorMsg( Format( L"Error type: %1%"_sv, result ) );
}
}
catch( ... )
{
// error log
}
}
}