9.3.2 Port Access Functions

Port access functions read or write data from or to I/O ports (for example, 0x300) on the NIC. The return code for each function indicates whether the data has been successfully read or written.

A detection DLL first ensures that such a port is available by using DetectCheckPortUsage before calling any of these functions, declared as follows:

NTSTATUS DetectReadPortUchar(
IN INTERFACE_TYPE   InterfaceType,
IN ULONG
   BusNumber,
IN ULONG
   Port,
OUT PUCHAR
   Value
);

NTSTATUS DetectWritePortUchar(
IN INTERFACE_TYPE   InterfaceType,
IN ULONG
   BusNumber,
IN ULONG
   Port,
IN UCHAR
   Value
);

NTSTATUS DetectReadPortUshort(
IN INTERFACE_TYPE InterfaceType,
IN ULONG
   BusNumber,
IN ULONG
Port,
OUT PUSHORT
   Value
);

NTSTATUS DetectWritePortUshort(
IN INTERFACE_TYPE InterfaceType,
IN ULONG BusNumber,
IN ULONG
Port,
IN USHORT
   Value
);

NTSTATUS DetectReadPortUlong(
IN INTERFACE_TYPE InterfaceType,
IN ULONG
BusNumber,
IN ULONG
   Port,
OUT PULONG
   Value
);

NTSTATUS DetectWritePortUlong(
IN ULONG    BusNumber,
IN ULONG
    Port,
N ULONG
Value
);

Depending on the function, each reads or writes a byte, two-byte, or four-byte value for a given I/O port range.