EVT_SERCX2_FILEOPEN callback function (sercx.h)
The EvtSerCx2FileOpen event callback function is called by version 2 of the serial framework extension (SerCx2) to notify the serial controller driver that a client opened a logical connection to the serial controller device and that a file object has been created to represent this connection.
Syntax
EVT_SERCX2_FILEOPEN EvtSercx2Fileopen;
NTSTATUS EvtSercx2Fileopen(
[in] WDFDEVICE Device
)
{...}
Parameters
[in] Device
A WDFDEVICE handle to the framework device object that represents the serial controller. The serial controller driver created this object in its EvtDriverDeviceAdd callback function. For more information, see SerCx2InitializeDevice.
Return value
The EvtSerCx2FileOpen function returns STATUS_SUCCESS if the call is successful. Otherwise, it returns an appropriate error status code.
Remarks
Your serial controller driver can, as an option, implement this function. If implemented, the driver registers this function in the call to the SerCx2InitializeDevice method that finishes the initialization of the framework device object for the serial controller. SerCx2 calls the EvtSerCx2FileOpen function when a client driver opens a file handle to the serial controller driver stack.
For more information, see Framework File Objects.
Examples
To define an EvtSerCx2FileOpen callback function, you must first provide a function declaration that identifies the type of callback function you're defining. Windows provides a set of callback function types for drivers. Declaring a function using the callback function types helps Code Analysis for Drivers, Static Driver Verifier (SDV), and other verification tools find errors, and it's a requirement for writing drivers for the Windows operating system.
For example, to define an EvtSerCx2FileOpen callback function that is named MyFileOpen
, use the EVT_SERCX2_FILEOPEN function type, as shown in this code example:
EVT_SERCX2_FILEOPEN MyFileOpen;
Then, implement your callback function as follows:
_Use_decl_annotations_
NTSTATUS
MyFileOpen(
WDFDEVICE Device
)
{...}
The EVT_SERCX2_FILEOPEN function type is defined in the Sercx.h header file. To more accurately identify errors when you run the code analysis tools, be sure to add the Use_decl_annotations annotation to your function definition. The Use_decl_annotations annotation ensures that the annotations that are applied to the EVT_SERCX2_FILEOPEN function type in the header file are used. For more information about the requirements for function declarations, see Declaring Functions by Using Function Role Types for KMDF Drivers. For more information about Use_decl_annotations, see Annotating Function Behavior.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Available starting with Windows 8.1. |
Target Platform | Desktop |
Header | sercx.h |
IRQL | Called at IRQL <= DISPATCH_LEVEL. |