开发环境:VS2013+WDK8.1
驱动层服务层:
#include <ntddk.h>
#define DEVICE_NAME "\\Device\\MyReadDevice"
#define SYM_LINK_NAME "\\??\\MyRead"
NTSTATUS DriverUnload(PDRIVER_OBJECT driver)
{
DbgPrint("unload me");
return STATUS_SUCCESS;
}
NTSTATUS MyDriverRead(PDEVICE_OBJECT device,PIRP pirp)
{
PIO_STACK_LOCATION stack = IoGetCurrentIrpStackLocation(pirp);
ULONG readLength = stack->Parameters.Read.Length;
pirp->IoStatus.Status = STATUS_SUCCESS;
pirp->IoStatus.Information = readLength;
memset(pirp->AssociatedIrp.SystemBuffer, 0x90, readLength);
IoCompleteRequest(pirp, IO_NO_INCREMENT);
DbgPrint("ReadOver\n")