9.3.4 Interrupt Trapping Functions

Interrupt-trapping functions determine the interrupt level or vector that a network interface card uses. A detection DDL calls DetectSetInterruptTrap to register interrupt handlers on each of the interrupts specified. After calling this function, the detection DLL causes the NIC to generate an interrupt. Then, the detection DLL calls DetectQueryInterruptTrap to determine on which level interrupts have occurred.

The detection DLL waits an appropriate length of time for an interrupt and then performs the specific operations to dismiss the interrupt on the NIC. During interrupt trapping, DetectQueryInterruptTrap can be called several times. When the detection DLL is through trapping interrupts, it calls DetectRemoveInterruptTrap.

DetectSetInterruptTrap Function

DetectSetInterruptTrap obtains a provided array of vector or level numbers. The detection DLL attempts to register interrupt handlers on each of the interrupts specified. A subset of these typically succeeds, based on the other devices in the system. The operation fails if all of the interrupts are in use simultaneously. The function prototype is as follows:

NTSTATUS DetectSetInterruptTrap(
IN INTERFACE_TYPE InterfaceType,
IN ULONG
BusNumber,
OUT PHANDLE
TrapHandle,
IN UCHAR
InterruptList[ ],
IN ULONG
InterruptListLength
);

DetectQueryInterruptTrap

DetectQueryInterruptTrap determines which of the interrupts previously passed to DetechSetInterruptTrap have occurred. Each entry in the given InterruptList[ ] displays one of the following:

Value Meanin
0 No interrupt has occurred.
1 One interrupt has occurred.
2 More than one interrupt has occurred.
3 The interrupt is in use by another device.

DetectQueryInterruptTrap can be called repeatedly to return the results since the most recent call. The function prototype is as follows:

NTSTATUS DetectQueryInterruptTrap(
IN HANDLE TrapHandle,
IN OUT UCHAR
InterruptList[ ]
);

DetectRemoveInterruptTrap Function

DetectRemoveInterruptTrap removes handlers originally set up with DetectSetInterruptTrap. The function prototype is as follows:

NTSTATUS DetectRemoveInterruptTrap(
IN HANDLE TrapHandle
);