19,502
社区成员
发帖
与我相关
我的任务
分享
BOOL CaptureDumpFileOnDevice(DWORD dwProcessId, DWORD dwThreadId, LPCWSTR pwzExtraFilesPath)
{
BOOL fHandled = FALSE;
DWORD dwArguments[5];
WCHAR wzCanonicalExtraFilesPath[MAX_PATH];
BOOL fReportFault = (dwProcessId == (-1)) && (dwThreadId == (-1));
DWORD dwArg2 = 0;
if (!fReportFault)
{
if (pwzExtraFilesPath)
{
if (!CeGetCanonicalPathNameW(pwzExtraFilesPath, wzCanonicalExtraFilesPath, ARRAY_SIZE(wzCanonicalExtraFilesPath), 0))
{
fHandled = FALSE;
SetLastError(ERROR_BAD_PATHNAME);
goto Exit;
}
dwArg2 = (DWORD)wzCanonicalExtraFilesPath;
}
}
else
{
// For ReportFault this is actually the pointer to the exception
dwArg2 = (DWORD)pwzExtraFilesPath;
}
dwArguments[0] = dwProcessId;
dwArguments[1] = dwThreadId;
dwArguments[2] = dwArg2;
// We pass in the CurrentTrust as an extra safety check in DwDmpGen.cpp
// DwDmpGen.cpp will do additional trust level checking.
dwArguments[3] = CeGetCurrentTrust();
dwArguments[4] = (DWORD)&CaptureDumpFileOnDevice;
__try
{
// This exception will be handled by OsAxsT0.dll if
// we succesfully generate a dump file. The RaisException
// will return if handled, otherwise it will caught by the
// the try catch block.
RaiseException(STATUS_CRASH_DUMP,0,5,&dwArguments[0]);
fHandled = TRUE;
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
// We end up here if no dump was captured, in which case we return FALSE
fHandled = FALSE;
if (ERROR_SUCCESS == GetLastError())
{
SetLastError(ERROR_NOT_SUPPORTED);
}
}
Exit:
return fHandled;
}