Mini Dump erstellen will nicht so richtig klappen



  • Ich möchte mit Hilfe der dbghelp.dll ein Mini Dump erstellen, allerdings nicht nur wenn eine Ausnahme auftritt sondern jederzeit (also auch wenn eine c++ Ausnahme auftritt, oder einfach so)

    Meine Funktion(en) die das tun sehen so aus:

    void MiniDumpWriteHelper( HANDLE fh, EXCEPTION_POINTERS* excepPtrs )
    {
    	if( !excepPtrs ) //If we have no exception information we have to raise
    	{				 //an exception to get proper exception information for
    		__try		 //our dump
    		{
    			RaiseException( EXCEPTION_BREAKPOINT, 0, 0, NULL );
    		}
    		__except( MiniDumpWriteHelper( fh, GetExceptionInformation() ),
    				EXCEPTION_CONTINUE_EXECUTION )
    		{
    		}
    	}
    	else
    	{
    		MINIDUMP_EXCEPTION_INFORMATION exInfo;
    		exInfo.ThreadId = GetCurrentThreadId();
    		exInfo.ExceptionPointers = excepPtrs;
    		exInfo.ClientPointers = false;
    
    		if( !MiniDumpWriteDump( GetCurrentProcess(), GetCurrentProcessId(),
    								fh,	MiniDumpNormal, &exInfo, NULL, NULL ) )
    		{
    			assert( 0 && "Could not write the mini dump." );
    		}
    	}
    }
    
    void WriteMiniDump( const std::string& path, _EXCEPTION_POINTERS* excepPtrs = NULL )
    {
    	string fileName( path );
    	fileName += "\\dump.dmp";
    
    	HANDLE fh = CreateFile( fileName.c_str(), GENERIC_WRITE, FILE_SHARE_WRITE,
    							NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
    
    	if( fh == INVALID_HANDLE_VALUE )
    	{
    		assert( 0 && "Could not create the file for the mini dump." );
    
    		return;
    	}
    
    	MiniDumpWriteHelper( fh,  excepPtrs );
    
    	CloseHandle( fh );
    }
    

    Ich rufe die Funktion, dann einfach mit Default-Parameter auf und möchte selber eine Ausnahme auslösen um an die exception pointers zu kommen, allerdings klappt das nicht so ganz, wenn der Debugger mitläuft passiert nichts und ohne bekomme ich ne Fehlermeldung, dass der Wert im ESP-Register nicht richtig gespeichert werden konnte über einen Funktionsaufruf hinweg (kommt nachdem bei RaiseException weitergemacht wird).

    Wie kann ich nen Mini Dump "richtig" bzw. erfolgreich erstellen?



  • Hab es jetzt so weit, dass es läuft wenn ich ne "echte" Ausnahme habe und, wenn ich als Parameter für MiniDumpWriteDump NULL übergebe als INIDUMP_EXCEPTION_INFORMATION läuft es jetzt auch ohne Fehler aber da ist das Dump irgendwie nicht richtig, also ich habe da im Callstack nur Informationen über RaiseException und sonst nichts.


Anmelden zum Antworten