Click here to Skip to main content
14,489,405 members
Rate this:
Please Sign up or sign in to vote.
See more:
Ok I am kind of confused, I am trying to create a mini dump of my process. Therefore I am calling the code like this.

HANDLE hFile =  CreateFile((LPCWSTR)"C:\\Test\\Reader4.dmp",                // name of the write
                       GENERIC_WRITE,          // open for writing
                       0,                      // do not share
                       NULL,                   // default security
                       CREATE_ALWAYS,             // create new file only
                       FILE_ATTRIBUTE_NORMAL,  // normal file
                       NULL);                  // no attr. template

	std::cout<< "Error:" << GetLastError() << std::endl;

	   if ( ( hFile != NULL ) && ( hFile != INVALID_HANDLE_VALUE ) )
	   {
			if (!MiniDumpWriteDump( GetCurrentProcess(), GetCurrentProcessId(),hFile, MiniDumpNormal,0,0,0))
			{
				std::cout<< "Mini Dump Error:" << GetLastError() << std::endl;
			}
	   }
	CloseHandle(hFile);


Everything checks out! GetLastError always returns 0. I finish my current process, however I never can find a dmp file like ever.
Posted
Rate this:
Please Sign up or sign in to vote.

Solution 1

Quote:
HANDLE hFile = CreateFile((LPCWSTR)"C:\\Test\\Reader4.dmp",
That's not the correct way to pass a wide string to the function. Change to:
HANDLE hFile =  CreateFile(L"C:\\Test\\Reader4.dmp",



(The OS interpreted the ASCII string as it was a WIDE one and you should be able to find a file named "㩃呜獥屴敒摡牥⸴浤p牅潲㩲", that is the dump :-D, in the project folder)
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

Solution 1 is accurate, you were passing the string in a wrong way.

But don't call MiniDumpWriteDump on the current process.

Let's say that you implement an exception handler.
when handler is called your application might be in an unstable state.
What if you ran out of stack space, or you experience corrupted memory.
You might be unable to write the minidump.

You should preferably spawn a new process that calls MiniDumpWriteDump on the first process.
   
Comments
CdnSecurityEngineer 31-Jan-14 10:31am
   
That's more or less what I was doing. However the code I posted was just debugging code to ensure that everything was functioning correctly. Once I had the bugs worked out I changed it to dump the correct process that I wanted.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100