📄 isr.c
字号:
#include "Driver.h"
/*************************************************************************************************/
BOOLEAN EnableIRQ(IN PVOID SynchronizeContext)
{
PFDO_DATA deviceExtension = (PFDO_DATA)SynchronizeContext;
// TODO: Enable IRQ in the hardware.
return TRUE;
}
/*************************************************************************************************/
BOOLEAN DisableIRQ(IN PVOID SynchronizeContext)
{
PFDO_DATA deviceExtension = (PFDO_DATA)SynchronizeContext;
// TODO: Disable IRQ in the hardware.
return TRUE;
}
/*************************************************************************************************/
BOOLEAN IsrRoutine(IN PKINTERRUPT Interrupt, IN PVOID ServiceContext)
{
PFDO_DATA deviceExtension = (PFDO_DATA)ServiceContext;
// Disable further interrupts.
DisableIRQ(deviceExtension);
// Start DPC to handle the interrupt.
KeInsertQueueDpc(&deviceExtension->DpcForPortIsr, NULL, NULL);
return TRUE;
}
/*************************************************************************************************/
VOID DpcForIsrRoutine(PKDPC pDpc, PVOID pContext, PVOID pArg1, PVOID pArg2)
{
PFDO_DATA deviceExtension = (PFDO_DATA)pContext;
PIO_STACK_LOCATION IrpStack;
PIRP Irp;
PUCHAR Buffer;
ULONG NumberOfBytesPutInTheBuffer;
// Get an IRP from the queue.
Irp = IoCsqRemoveNextIrp(&deviceExtension->CSReadQueue, NULL);
if (Irp != NULL)
{
IrpStack = IoGetCurrentIrpStackLocation(Irp);
// Get access to user buffer.
Buffer = (PUCHAR)MmGetSystemAddressForMdl(Irp->MdlAddress);
// Put something into the buffer. The size of the buffer is in IrpStack->Parameters.Read.Length
NumberOfBytesPutInTheBuffer = IrpStack->Parameters.Read.Length;
RtlFillMemory(Buffer, NumberOfBytesPutInTheBuffer, 0xaa);
// Complete the IRP and return the number of bytes we actually put into the buffer.
Irp->IoStatus.Information = NumberOfBytesPutInTheBuffer;
Irp->IoStatus.Status = STATUS_SUCCESS;
KeFlushIoBuffers(Irp->MdlAddress, TRUE, FALSE);
IoCompleteRequest(Irp, IO_NO_INCREMENT);
}
// DCP routine finished, enable interrupts again.
EnableIRQ(deviceExtension);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -