29 #define WM_PH_MINIDUMP_STATUS_UPDATE (WM_APP + 301)
31 #define PH_MINIDUMP_STATUS_UPDATE 1
32 #define PH_MINIDUMP_COMPLETED 2
33 #define PH_MINIDUMP_ERROR 3
35 typedef struct _PROCESS_MINIDUMP_CONTEXT
74 { L
"Dump files (*.dmp)", L
"*.dmp" },
75 { L
"All files (*.*)", L
"*.*" }
98 MiniDumpWithFullMemory |
99 MiniDumpWithHandleData |
100 MiniDumpWithUnloadedModules |
101 MiniDumpWithFullMemoryInfo |
102 MiniDumpWithThreadInfo
118 context.FileName = FileName;
119 context.DumpType = DumpType;
122 &context.ProcessHandle,
127 PhShowStatus(hWnd, L
"Unable to open the process", status, 0);
138 FILE_GENERIC_WRITE | DELETE,
147 PhShowStatus(hWnd, L
"Unable to access the dump file", status, 0);
148 NtClose(context.ProcessHandle);
160 NtClose(context.FileHandle);
161 NtClose(context.ProcessHandle);
163 return context.Succeeded;
166 static BOOL CALLBACK PhpProcessMiniDumpCallback(
167 _In_ PVOID CallbackParam,
168 _In_
const PMINIDUMP_CALLBACK_INPUT CallbackInput,
169 _Inout_ PMINIDUMP_CALLBACK_OUTPUT CallbackOutput
176 if (context->ProcessId == NtCurrentProcessId())
183 switch (CallbackInput->CallbackType)
188 CallbackOutput->Cancel =
TRUE;
193 message =
PhFormatString(L
"Processing module %s...", CallbackInput->Module.FullPath);
198 message =
PhFormatString(L
"Processing thread %u...", CallbackInput->Thread.ThreadId);
206 context->WindowHandle,
222 MINIDUMP_CALLBACK_INFORMATION callbackInfo;
224 callbackInfo.CallbackRoutine = PhpProcessMiniDumpCallback;
225 callbackInfo.CallbackParam = context;
228 if (context->IsWow64)
240 context->ProcessHandle,
246 context->Succeeded =
TRUE;
252 context->ProcessHandle,
255 MiniDumpWithFullMemory | MiniDumpWithHandleData
258 context->Succeeded =
TRUE;
263 context->WindowHandle,
278 context->WindowHandle,
279 MB_YESNO | MB_ICONWARNING,
280 L
"The process is 32-bit, but the 32-bit version of Process Hacker could not be located. "
281 L
"A 64-bit dump will be created instead. Do you want to continue?"
303 context->ProcessHandle,
312 context->Succeeded =
TRUE;
318 context->ProcessHandle,
321 MiniDumpWithFullMemory | MiniDumpWithHandleData,
327 context->Succeeded =
TRUE;
332 context->WindowHandle,
335 (LPARAM)GetLastError()
344 context->WindowHandle,
350 return STATUS_SUCCESS;
374 context->WindowHandle = hwndDlg;
377 if (!context->ThreadHandle)
379 PhShowStatus(hwndDlg, L
"Unable to create the minidump thread", 0, GetLastError());
380 EndDialog(hwndDlg, IDCANCEL);
383 SetTimer(hwndDlg, 1, 500, NULL);
392 NtClose(context->ThreadHandle);
399 switch (LOWORD(wParam))
406 EnableWindow(GetDlgItem(hwndDlg, IDCANCEL),
FALSE);
407 context->Stop =
TRUE;
419 ULONG currentTickCount;
421 currentTickCount = GetTickCount();
423 if (currentTickCount - context->LastTickCount >= 2000)
428 (PWSTR)L
"Creating the dump file...");
431 context->LastTickCount = currentTickCount;
447 context->LastTickCount = GetTickCount();
450 PhShowStatus(hwndDlg, L
"Unable to create the minidump", 0, (ULONG)lParam);
453 EndDialog(hwndDlg, IDOK);