NdisOpenFile function (ndis.h)

The NdisOpenFile function returns a handle for an opened file.

Syntax

void NdisOpenFile(
  [out] PNDIS_STATUS          Status,
  [out] PNDIS_HANDLE          FileHandle,
  [out] PUINT                 FileLength,
  [in]  PNDIS_STRING          FileName,
  [in]  NDIS_PHYSICAL_ADDRESS HighestAcceptableAddress
);

Parameters

[out] Status

A pointer to a caller-supplied variable in which this function returns the status of the open file operation, which can be one of the following:

NDIS_STATUS_SUCCESS

The handle at FileHandle is valid for a subsequent call to NdisMapFile.

NDIS_STATUS_FILE_NOT_FOUND

The given string at FileName did not specify a name found in the system object namespace.

NDIS_STATUS_RESOURCES

NDIS could not allocate the resources it needed to open the file and allocate a buffer for the file contents.

NDIS_STATUS_ERROR_READING_FILE

The specified file's data could not be read into system memory for subsequent access by the caller.

[out] FileHandle

A pointer to a caller-supplied variable in which this function returns the handle of the opened file if the call succeeds.

[out] FileLength

A pointer to a caller-supplied variable in which this function writes the number of bytes of data in the opened file if the call succeeds.

[in] FileName

A pointer to an NDIS_STRING type containing an initialized counted string, in the system-default character set, naming the file to be opened. For Windows 2000 and later drivers, this string contains Unicode characters. That is, for Windows 2000 and later, NDIS defines the NDIS_STRING type as a UNICODE_STRING type.

[in] HighestAcceptableAddress

The highest physical address in which the file data can be stored, or specifies -1 if the driver places no restrictions.

Return value

None

Remarks

NdisOpenFile opens a disk file, typically a file the driver will later download to program an intelligent NIC. NdisOpenFile also allocates storage to hold file contents for the driver's subsequent call to the NdisMapFile function.

A miniport driver should call NdisOpenFile only from the MiniportInitializeEx function.

When NdisOpenFile returns, the miniport driver can access file data by calling NdisMapFile. It can call the NdisUnmapFile function to page out the file so it does not consume resources unnecessarily while the driver is not accessing the file data. When finished using the file, MiniportInitializeEx must call the
NdisCloseFile function.

Note

NdisOpenFile, NdisCloseFile, NdisMapFile and NdisUnmapFile are not supported on ARM64. On ARM64, replace these functions with calls to ZwCreateFile, ZwReadFile, or other similar operations.

Requirements

Requirement Value
Minimum supported client Supported for NDIS 6.0 and NDIS 5.1 drivers (see NdisOpenFile (NDIS 5.1)) in Windows Vista. Supported for NDIS 5.1 drivers (see NdisOpenFile (NDIS 5.1)) in Windows XP.
Target Platform Universal
Header ndis.h (include Ndis.h)
Library Ndis.lib
IRQL PASSIVE_LEVEL
DDI compliance rules Irql_Miscellaneous_Function(ndis)

See also

MiniportInitializeEx

NdisCloseFile

NdisMapFile

NdisUnmapFile

UNICODE_STRING