<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Seltsames Verhalten in __except]]></title><description><![CDATA[<p>Hallo,</p>
<p>mein Testprogramm reagiert nicht so, wie es sollte. Prinzipiell funktioniert alles, der Minidump für die erste Exception ist korrekt, der zweite Minidump für die zweite Exception allerdings nicht! <em>MiniDumpWriteDump</em> schlägt in der zweiten Exception mit &quot;error 18: Es sind keine weiteren Daten vorhanden&quot; fehl.<br />
Die PEXCEPTION_POINTERS Struktur ist aber mit richtig ausgefüllt.</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;stdio.h&gt;
#include &lt;dbghelp.h&gt;

#pragma comment (lib, &quot;Dbghelp.lib&quot;)
#pragma comment (lib, &quot;user32.lib&quot;)

LONG CALLBACK SelfProtect (PEXCEPTION_POINTERS pExcPointers)
{
	HANDLE hDumpFile = CreateFile (L&quot;C:\\minidumpSelfProtect.dmp&quot;, FILE_ALL_ACCESS, 0, NULL, CREATE_ALWAYS, 0, NULL);
	if (hDumpFile != INVALID_HANDLE_VALUE)
	{
		MINIDUMP_EXCEPTION_INFORMATION	MiniDumpInfo;

		memset (&amp;MiniDumpInfo, 0, sizeof (MINIDUMP_EXCEPTION_INFORMATION));

		MiniDumpInfo.ThreadId = GetCurrentThreadId();
		MiniDumpInfo.ClientPointers = NULL;
		MiniDumpInfo.ExceptionPointers = pExcPointers;

		// Das hier schlägt fehl!
		MiniDumpWriteDump (GetCurrentProcess(),
						   GetCurrentProcessId(),
						   hDumpFile,
						   MiniDumpNormal,
						   &amp;MiniDumpInfo,
						   NULL,
						   NULL

		CloseHandle (hDumpFile); 
	}

	return 0;
}

LONG CALLBACK Handler (PEXCEPTION_POINTERS pExcPointers)
{
	HANDLE hDumpFile = CreateFile (L&quot;C:\\minidumpHandler.dmp&quot;, FILE_ALL_ACCESS, 0, NULL, CREATE_ALWAYS, 0, NULL);
	if (hDumpFile != INVALID_HANDLE_VALUE)
	{
		MINIDUMP_EXCEPTION_INFORMATION	MiniDumpInfo;

		memset (&amp;MiniDumpInfo, 0, sizeof (MINIDUMP_EXCEPTION_INFORMATION));

		MiniDumpInfo.ThreadId = GetCurrentThreadId();
		MiniDumpInfo.ClientPointers = NULL;
		MiniDumpInfo.ExceptionPointers = pExcPointers;

		// Das hier funktioniert
		MiniDumpWriteDump (GetCurrentProcess(),
						   GetCurrentProcessId(),
						   hDumpFile,
						   MiniDumpNormal,
						   &amp;MiniDumpInfo,
						   NULL,
						   NULL
						   );

		CloseHandle (hDumpFile); 
	}

	// Wenn diese Funktion verwendet wird, wird SelfProtect bei einer Exception nicht aufgerufen!
	//SetUnhandledExceptionFilter (SelfProtect);		

	__try
	{
		char *p = 0;
		p[0] = 5;
	}
	__except (SelfProtect (GetExceptionInformation ()))
	{
	}

	return 0;
}

int main ()
{
	SetUnhandledExceptionFilter (Handler);

	char *p = 0;
	p[0] = 0;

	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/186411/seltsames-verhalten-in-__except</link><generator>RSS for Node</generator><lastBuildDate>Sun, 05 Jul 2026 06:33:48 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/186411.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 08 Jul 2007 17:04:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Seltsames Verhalten in __except on Sun, 08 Jul 2007 17:04:41 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>mein Testprogramm reagiert nicht so, wie es sollte. Prinzipiell funktioniert alles, der Minidump für die erste Exception ist korrekt, der zweite Minidump für die zweite Exception allerdings nicht! <em>MiniDumpWriteDump</em> schlägt in der zweiten Exception mit &quot;error 18: Es sind keine weiteren Daten vorhanden&quot; fehl.<br />
Die PEXCEPTION_POINTERS Struktur ist aber mit richtig ausgefüllt.</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;stdio.h&gt;
#include &lt;dbghelp.h&gt;

#pragma comment (lib, &quot;Dbghelp.lib&quot;)
#pragma comment (lib, &quot;user32.lib&quot;)

LONG CALLBACK SelfProtect (PEXCEPTION_POINTERS pExcPointers)
{
	HANDLE hDumpFile = CreateFile (L&quot;C:\\minidumpSelfProtect.dmp&quot;, FILE_ALL_ACCESS, 0, NULL, CREATE_ALWAYS, 0, NULL);
	if (hDumpFile != INVALID_HANDLE_VALUE)
	{
		MINIDUMP_EXCEPTION_INFORMATION	MiniDumpInfo;

		memset (&amp;MiniDumpInfo, 0, sizeof (MINIDUMP_EXCEPTION_INFORMATION));

		MiniDumpInfo.ThreadId = GetCurrentThreadId();
		MiniDumpInfo.ClientPointers = NULL;
		MiniDumpInfo.ExceptionPointers = pExcPointers;

		// Das hier schlägt fehl!
		MiniDumpWriteDump (GetCurrentProcess(),
						   GetCurrentProcessId(),
						   hDumpFile,
						   MiniDumpNormal,
						   &amp;MiniDumpInfo,
						   NULL,
						   NULL

		CloseHandle (hDumpFile); 
	}

	return 0;
}

LONG CALLBACK Handler (PEXCEPTION_POINTERS pExcPointers)
{
	HANDLE hDumpFile = CreateFile (L&quot;C:\\minidumpHandler.dmp&quot;, FILE_ALL_ACCESS, 0, NULL, CREATE_ALWAYS, 0, NULL);
	if (hDumpFile != INVALID_HANDLE_VALUE)
	{
		MINIDUMP_EXCEPTION_INFORMATION	MiniDumpInfo;

		memset (&amp;MiniDumpInfo, 0, sizeof (MINIDUMP_EXCEPTION_INFORMATION));

		MiniDumpInfo.ThreadId = GetCurrentThreadId();
		MiniDumpInfo.ClientPointers = NULL;
		MiniDumpInfo.ExceptionPointers = pExcPointers;

		// Das hier funktioniert
		MiniDumpWriteDump (GetCurrentProcess(),
						   GetCurrentProcessId(),
						   hDumpFile,
						   MiniDumpNormal,
						   &amp;MiniDumpInfo,
						   NULL,
						   NULL
						   );

		CloseHandle (hDumpFile); 
	}

	// Wenn diese Funktion verwendet wird, wird SelfProtect bei einer Exception nicht aufgerufen!
	//SetUnhandledExceptionFilter (SelfProtect);		

	__try
	{
		char *p = 0;
		p[0] = 5;
	}
	__except (SelfProtect (GetExceptionInformation ()))
	{
	}

	return 0;
}

int main ()
{
	SetUnhandledExceptionFilter (Handler);

	char *p = 0;
	p[0] = 0;

	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1320870</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1320870</guid><dc:creator><![CDATA[yogle]]></dc:creator><pubDate>Sun, 08 Jul 2007 17:04:41 GMT</pubDate></item><item><title><![CDATA[Reply to Seltsames Verhalten in __except on Mon, 09 Jul 2007 17:23:01 GMT]]></title><description><![CDATA[<p>IMHO kanst Du in einem Unhandled Exception Handler nicht den Unhandled Exception Handler umbiegen. Du bearbeitest ja immer noch die entsprechende Exception.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1321739</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1321739</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Mon, 09 Jul 2007 17:23:01 GMT</pubDate></item><item><title><![CDATA[Reply to Seltsames Verhalten in __except on Tue, 10 Jul 2007 16:25:51 GMT]]></title><description><![CDATA[<p>Das Verhalten ist allgemein etwas komisch. Eine Exception lässt sich in einem Unhandled Exception Handler noch durch einen __try __except Block abfangen (wahrscheinlich da dies Threadbasierend ist) und die PEXCEPTION_POINTER Struktur wird korrekt ausgefüllt. MiniDumpWriteDump aber funktioniert nicht richtig...<br />
Bei FAULTING_IP wird die richtige Adresse angezeigt, der Rest sind aber noch die Informationen vom alten MiniDump!</p>
<p>BTW: Was Spricht eigentlich dagegen ein komplettes Programm über einen __try __except Block abzusichern?</p>
<p>Und könntest du mir vl. erklären, wie ungefähr SetUnhandledExceptionFilter funktioniert, da dieser ja alle Exceptions eines Programmes abfängt, __try __except nur die innerhalb der Klammern = Threadbasierend/SEH Frame?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1322490</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1322490</guid><dc:creator><![CDATA[yogle]]></dc:creator><pubDate>Tue, 10 Jul 2007 16:25:51 GMT</pubDate></item><item><title><![CDATA[Reply to Seltsames Verhalten in __except on Tue, 10 Jul 2007 17:05:25 GMT]]></title><description><![CDATA[<p>Stell Dir einfach vor, dass wenn ein Thread gestartet wird, er als aller erstes einen __try/__except Block bekommt. Und die entsprechende Handlerfunktion die ausgeführt wird bestimmst Du prozessweit mit SetUnhandledExceptionFilter.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1322527</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1322527</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Tue, 10 Jul 2007 17:05:25 GMT</pubDate></item></channel></rss>