<?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[Filter driver + Bluescreen]]></title><description><![CDATA[<p>Hi schonwieder <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> ,<br />
ich möchte einen Filtertreiber schreiben, welcher Udp Pakete verändert. Ich wollte das so machen das so:</p>
<pre><code class="language-cpp">#define DO(s) {DbgPrint(s);}

PDEVICE_OBJECT pUDPObject=NULL;
PDEVICE_OBJECT pOldUDPObject=NULL;

NTSTATUS Entry(PDRIVER_OBJECT pDriverObject, PUNICODE_STRING pRegistryPath)
{
    DO(&quot;Entry begin...&quot;);

	for (int iFunction = 0; iFunction&lt;IRP_MJ_MAXIMUM_FUNCTION; iFunction++)
		pDriverObject-&gt;MajorFunction[iFunction] = Dispatch;
	pDriverObject-&gt;DriverUnload=Unload; 

	NTSTATUS Return = IoCreateDevice(pDriverObject,
							0,
							NULL,
							FILE_DEVICE_UNKNOWN,
							0,
							TRUE,
							&amp;pUDPObject);
	if (Return != STATUS_SUCCESS)
	{
		DOERR;
		return Return;
	}
	pUDPObject-&gt;Flags |= DO_DIRECT_IO;

	UNICODE_STRING UDPDeviceName;
	RtlInitUnicodeString(&amp;UDPDeviceName, L&quot;\\Device\\Tcp&quot;); //Hier zum Test erstmal TCP
	Return = IoAttachDevice(pUDPObject, &amp;UDPDeviceName, &amp;pOldUDPObject);
	if (Return != STATUS_SUCCESS)
	{
		IoDeleteDevice(pUDPObject);
		DOERR;
		return Return;
	}

    DO(&quot;Entry end&quot;);

	return Return;
}

typedef struct _EXAMPLE_FILTER_EXTENSION
{
    PDEVICE_OBJECT pNextDeviceInChain;

} EXAMPLE_FILTER_EXTENSION, *PEXAMPLE_FILTER_EXTENSION; // Aus tutorial

NTSTATUS Dispatch(PDEVICE_OBJECT pDeviceObject,PIRP pIRP)
{
	DO(&quot;Dispatch begin...&quot;);

	NTSTATUS NtStatus = STATUS_NOT_SUPPORTED;
    PEXAMPLE_FILTER_EXTENSION pExampleFilterDeviceContext = (PEXAMPLE_FILTER_EXTENSION)pDeviceObject-&gt;DeviceExtension;
    DbgPrint(&quot;ExampleFilter_UnSupportedFunction Called \r\n&quot;);
    IoSkipCurrentIrpStackLocation(pIRP);
	IoCallDriver(pExampleFilterDeviceContext-&gt;pNextDeviceInChain, pIRP);

	DO(&quot;Dispatch end...&quot;);

    return NtStatus;
}
</code></pre>
<p>leider bekomme ich direkt nach dem Laden des Treibers einen Bluescreen und der Rechner fährt sich selber herunter. Wenn ich nun die Dispatch-Funktion durch diese ersetzte, gibt es keinen Bluescreen...</p>
<pre><code class="language-cpp">NTSTATUS Dispatch(PDEVICE_OBJECT pDeviceObject,PIRP pIRP)
{
	DO(&quot;Dispatch begin...&quot;);

	if (!pIRP)
	{
		DOWARNING;
		return STATUS_SUCCESS;
	}

	SCompletion Completion;
	memset(&amp;Completion, NULL, sizeof(SCompletion));

	PIO_STACK_LOCATION pIoStackIrp=IoGetCurrentIrpStackLocation(pIRP);
	switch (pIoStackIrp-&gt;MajorFunction)
	{
		case IRP_MJ_CREATE:
			DO(&quot;IRP_MJ_CREATE&quot;);

			iNumDevicesCreated++;
			break;

		case IRP_MJ_DEVICE_CONTROL:
			DO(&quot;IRP_MJ_DEVICE_CONTROL&quot;);
			break;

		case IRP_MJ_INTERNAL_DEVICE_CONTROL:
			DO(&quot;IRP_MJ_INTERNAL_DEVICE_CONTROL&quot;);
			break;

		case IRP_MJ_CLEANUP:
			DO(&quot;IRP_MJ_CLEANUP&quot;);
			break;

		case IRP_MJ_CLOSE:
			DO(&quot;IRP_MJ_CLOSE&quot;);

			if(iNumDevicesCreated)
				iNumDevicesCreated--;
			break;

		default:
			DO(&quot;default&quot;);
			break;
	}

	NTSTATUS Return;
	pIRP-&gt;IoStatus.Status = STATUS_SUCCESS;
	Return=STATUS_SUCCESS;

	IoCompleteRequest(pIRP, IO_NO_INCREMENT);

	DO(&quot;Dispatch end&quot;);

	return Return;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/136885/filter-driver-bluescreen</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Jul 2026 18:15:03 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/136885.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 13 Feb 2006 20:30:20 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Filter driver + Bluescreen on Mon, 13 Feb 2006 20:30:20 GMT]]></title><description><![CDATA[<p>Hi schonwieder <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> ,<br />
ich möchte einen Filtertreiber schreiben, welcher Udp Pakete verändert. Ich wollte das so machen das so:</p>
<pre><code class="language-cpp">#define DO(s) {DbgPrint(s);}

PDEVICE_OBJECT pUDPObject=NULL;
PDEVICE_OBJECT pOldUDPObject=NULL;

NTSTATUS Entry(PDRIVER_OBJECT pDriverObject, PUNICODE_STRING pRegistryPath)
{
    DO(&quot;Entry begin...&quot;);

	for (int iFunction = 0; iFunction&lt;IRP_MJ_MAXIMUM_FUNCTION; iFunction++)
		pDriverObject-&gt;MajorFunction[iFunction] = Dispatch;
	pDriverObject-&gt;DriverUnload=Unload; 

	NTSTATUS Return = IoCreateDevice(pDriverObject,
							0,
							NULL,
							FILE_DEVICE_UNKNOWN,
							0,
							TRUE,
							&amp;pUDPObject);
	if (Return != STATUS_SUCCESS)
	{
		DOERR;
		return Return;
	}
	pUDPObject-&gt;Flags |= DO_DIRECT_IO;

	UNICODE_STRING UDPDeviceName;
	RtlInitUnicodeString(&amp;UDPDeviceName, L&quot;\\Device\\Tcp&quot;); //Hier zum Test erstmal TCP
	Return = IoAttachDevice(pUDPObject, &amp;UDPDeviceName, &amp;pOldUDPObject);
	if (Return != STATUS_SUCCESS)
	{
		IoDeleteDevice(pUDPObject);
		DOERR;
		return Return;
	}

    DO(&quot;Entry end&quot;);

	return Return;
}

typedef struct _EXAMPLE_FILTER_EXTENSION
{
    PDEVICE_OBJECT pNextDeviceInChain;

} EXAMPLE_FILTER_EXTENSION, *PEXAMPLE_FILTER_EXTENSION; // Aus tutorial

NTSTATUS Dispatch(PDEVICE_OBJECT pDeviceObject,PIRP pIRP)
{
	DO(&quot;Dispatch begin...&quot;);

	NTSTATUS NtStatus = STATUS_NOT_SUPPORTED;
    PEXAMPLE_FILTER_EXTENSION pExampleFilterDeviceContext = (PEXAMPLE_FILTER_EXTENSION)pDeviceObject-&gt;DeviceExtension;
    DbgPrint(&quot;ExampleFilter_UnSupportedFunction Called \r\n&quot;);
    IoSkipCurrentIrpStackLocation(pIRP);
	IoCallDriver(pExampleFilterDeviceContext-&gt;pNextDeviceInChain, pIRP);

	DO(&quot;Dispatch end...&quot;);

    return NtStatus;
}
</code></pre>
<p>leider bekomme ich direkt nach dem Laden des Treibers einen Bluescreen und der Rechner fährt sich selber herunter. Wenn ich nun die Dispatch-Funktion durch diese ersetzte, gibt es keinen Bluescreen...</p>
<pre><code class="language-cpp">NTSTATUS Dispatch(PDEVICE_OBJECT pDeviceObject,PIRP pIRP)
{
	DO(&quot;Dispatch begin...&quot;);

	if (!pIRP)
	{
		DOWARNING;
		return STATUS_SUCCESS;
	}

	SCompletion Completion;
	memset(&amp;Completion, NULL, sizeof(SCompletion));

	PIO_STACK_LOCATION pIoStackIrp=IoGetCurrentIrpStackLocation(pIRP);
	switch (pIoStackIrp-&gt;MajorFunction)
	{
		case IRP_MJ_CREATE:
			DO(&quot;IRP_MJ_CREATE&quot;);

			iNumDevicesCreated++;
			break;

		case IRP_MJ_DEVICE_CONTROL:
			DO(&quot;IRP_MJ_DEVICE_CONTROL&quot;);
			break;

		case IRP_MJ_INTERNAL_DEVICE_CONTROL:
			DO(&quot;IRP_MJ_INTERNAL_DEVICE_CONTROL&quot;);
			break;

		case IRP_MJ_CLEANUP:
			DO(&quot;IRP_MJ_CLEANUP&quot;);
			break;

		case IRP_MJ_CLOSE:
			DO(&quot;IRP_MJ_CLOSE&quot;);

			if(iNumDevicesCreated)
				iNumDevicesCreated--;
			break;

		default:
			DO(&quot;default&quot;);
			break;
	}

	NTSTATUS Return;
	pIRP-&gt;IoStatus.Status = STATUS_SUCCESS;
	Return=STATUS_SUCCESS;

	IoCompleteRequest(pIRP, IO_NO_INCREMENT);

	DO(&quot;Dispatch end&quot;);

	return Return;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/993496</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/993496</guid><dc:creator><![CDATA[Socker]]></dc:creator><pubDate>Mon, 13 Feb 2006 20:30:20 GMT</pubDate></item><item><title><![CDATA[Reply to Filter driver + Bluescreen on Mon, 13 Feb 2006 20:32:10 GMT]]></title><description><![CDATA[<p>Irgendwie blicke ich diese ganze Treiberprogrammierung nicht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /><br />
Kennt wer vllt. ein gutes Buch für mich?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/993497</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/993497</guid><dc:creator><![CDATA[Socker]]></dc:creator><pubDate>Mon, 13 Feb 2006 20:32:10 GMT</pubDate></item><item><title><![CDATA[Reply to Filter driver + Bluescreen on Mon, 13 Feb 2006 20:48:55 GMT]]></title><description><![CDATA[<p>Die erste DDispatch-Funktion muss natürlich heißen:</p>
<pre><code class="language-cpp">NTSTATUS Dispatch(PDEVICE_OBJECT pDeviceObject,PIRP pIRP)
{
    DO(&quot;Dispatch begin...&quot;);

IoSkipCurrentIrpStackLocation(pIRP);
	return IoCallDriver(pOriginalUdpDevice, pIRP);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/993515</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/993515</guid><dc:creator><![CDATA[Socker]]></dc:creator><pubDate>Mon, 13 Feb 2006 20:48:55 GMT</pubDate></item><item><title><![CDATA[Reply to Filter driver + Bluescreen on Mon, 13 Feb 2006 20:53:12 GMT]]></title><description><![CDATA[<p>Aus irgendeinem Grund klappt das jetzt?!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/993523</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/993523</guid><dc:creator><![CDATA[Socker]]></dc:creator><pubDate>Mon, 13 Feb 2006 20:53:12 GMT</pubDate></item></channel></rss>