MiniDumpWriteDump (C#) produces zero length dump files for specific process

1.2k Views Asked by At
  1. Executing MiniDumpWriteDump within the specific process provides healthy dump file.

  2. Executing MiniDumpWriteDump from external process, where hProcess and processId point to the mentioned specific process, provides a zero length dump file

  3. 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).
1

There are 1 best solutions below

0
On BEST ANSWER

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.