4

I have a .net app which is designed to run in a 32 bit environment and it runs in 64 bit OS in wow64 environment.

Now i am creating an utility(32 bit) to create dump for the application.

I use the following code to create a dump.

[DllImport("dbghelp.dll", EntryPoint = "MiniDumpWriteDump", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
static extern bool MiniDumpWriteDump(IntPtr hProcess, uint processId, SafeHandle hFile, uint dumpType, ref MiniDumpExceptionInformation expParam, IntPtr userStreamParam, IntPtr callbackParam);

This API call executes fine in 32bit OS but fails in 64 bit OS.

Any one has created a dump for a 32 bit app in 64 bit OS?Pls help.

Rockstart
  • 2,337
  • 5
  • 30
  • 59
  • Adding code might help. What is the error code returned by GetLastError()? – seva titov Oct 23 '12 at 16:48
  • 1
    We write minidumps in our 32-bit app running on windows 7 64 bit without any problems but using native c++ code like so: `MiniDumpWriteDump(*procHandle, procId, *fileHandle, kMiniDumpTokens, NULL, NULL, NULL)` the kMiniDumpTokens is just an UINT bit mask of the options we set. You should check what `GetLastError` returns which will be a HRESULT, also it may be possible that the problem is the flags `uint dumpType` I know that some of these flags are not supported in different versions of Windows but not heard of a problem where the different is just 32 vs 64 bit but may be worth investigating. – EdChum Oct 29 '12 at 09:53

1 Answers1

1

Make sure that you have Pack=4 on the struct definition for your MiniDumpExceptionInformation struct.

This is what I have used in both 32 and 64bit C# apps:

[StructLayout(LayoutKind.Sequential, Pack=4)]
public struct MINIDUMP_EXCEPTION_INFORMATION
{
    public uint ThreadId;
    /// PEXCEPTION_POINTERS->_EXCEPTION_POINTERS*
    public IntPtr ExceptionPointers;
    [MarshalAs(UnmanagedType.Bool)]
    public bool ClientPointers;
}

But we always use matching architectures (32-bit app for creating crash dumps on 32-bit processes, etc.)

josh poley
  • 7,236
  • 1
  • 25
  • 25