Question

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.

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top