20 if (_MiniDumpWriteDump != NULL) {
23 HMODULE
lib = LoadLibraryA(
"dbghelp.dll");
24 if (!
lib)
return false;
26 FARPROC proc = GetProcAddress(
lib,
"MiniDumpWriteDump");
31 _MiniDumpWriteDump = (
BOOL(CALLBACK *)(
36 PMINIDUMP_EXCEPTION_INFORMATION,
37 PMINIDUMP_USER_STREAM_INFORMATION,
38 PMINIDUMP_CALLBACK_INFORMATION
41 if (_MiniDumpWriteDump != NULL) {
55 HANDLE procHndl = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);
56 if (procHndl == NULL) {
57 DWORD last_err = GetLastError();
58 if (last_err == ERROR_ACCESS_DENIED) {
60 procHndl = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);
64 if (procHndl == NULL) {
67 HANDLE outFile = CreateFileA(out_file.c_str(), GENERIC_ALL, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
68 if (outFile == INVALID_HANDLE_VALUE) {
69 CloseHandle(procHndl);
73 BOOL isDumped = _MiniDumpWriteDump(procHndl, pid, outFile, MiniDumpWithFullMemory, NULL, NULL, NULL);
76 CloseHandle(procHndl);
77 return (isDumped) ? true :
false;