Executing MiniDumpWriteDump within the specific process provides healthy dump file.
Executing MiniDumpWriteDump from external process, where hProcess and processId point to the mentioned specific process, provides a zero length dump file
Same as #2 just pointing to FireFox for example provides healthy dump file
The specific process I am trying to dump is running with low privilege as far as I know, and my external process is being executed from Administrator CMD window.
[DllImport("dbghelp.dll",
EntryPoint = "MiniDumpWriteDump",
CallingConvention = CallingConvention.Winapi,
CharSet = CharSet.Unicode,
ExactSpelling = true,
SetLastError = true)]
private static extern bool MiniDumpWriteDump(IntPtr hProcess,
uint processId,
SafeHandle hFile,
uint dumpType,
IntPtr expParam,
IntPtr userStreamParam,
IntPtr callbackParam);
Notes:
- I am flushing, closing and disposing correctly the file stream
- MiniDumpWriteDump return false and GetLastWin32Error returns : -2147024597
- The mentioned specific process (a dot net server project) has the same Security options as FireFox (the dump works on Notepad++ process for example).
Ok.. found the solution for that..
The external process project was build for "AnyCPU" platform (and as it doesn't execute only-64 bit commands, it was running for 32-bit). Setting it to x64 made it possible to dump another 64 bit process.
And I would recommend to anyone who encounter this issue, to create separated projects, one for 32 bit and one for 64 bit.
来源:https://stackoverflow.com/questions/33868483/minidumpwritedump-c-produces-zero-length-dump-files-for-specific-process