Hi All,
I am writing a non pnp driver to handle IOCTL requests from my application.
I have a below callback function registered in the driver to handle CreateFile routine from application when does request.
EVT_WDF_DEVICE_FILE_CREATE MyDeviceFileCreate;
//
VOID
MyEvtDeviceFileCreate (
IN WDFDEVICE Device,
IN WDFREQUEST Request,
IN WDFFILEOBJECT FileObject
)
{
//-------------------------------------
//---------------------------------------
status = ZwCreateFile (
&devExt->FileHandle,
SYNCHRONIZE | GENERIC_WRITE | GENERIC_READ,
&fileAttributes,
&ioStatus,
NULL,// alloc size = none
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ,
FILE_OPEN_IF,
FILE_SYNCHRONOUS_IO_NONALERT |FILE_NON_DIRECTORY_FILE,
NULL,// eabuffer
0// ealength
);
//-------------------------------------
//---------------------------------------
}
//
From application side it is required to create two different handles for the same file, one for Synchronous IO and another for Asynchronous IO as shown below.
Void init()
{
//-------------------------------------
//------------------------------------------------------
//Calling createfile to get a handle for Synchronous IO
//------------------------------------------------------
m_hDevice = CreateFile(szDriverPath,
GENERIC_READ | GENERIC_WRITE,// read and write enabled
0, // share mode
NULL, // security
OPEN_EXISTING, // fails if does not exist
FILE_ATTRIBUTE_NORMAL, // attributes
NULL // template file
);
//------------------------------------------------------
//Calling createfile to get a handle for Asynchronous IO
//------------------------------------------------------
m_hDeviceAsync = CreateFile(szDriverPath,
GENERIC_READ| GENERIC_WRITE,// read and write enabled
0, // share mode
NULL, // security
OPEN_EXISTING, // fails if does not exist
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, // attributes
NULL // template file
);
//------------------------------------------------------
//------------------------------------------------------
}
When the application started and when it tries to call first CreateFile is getting succeded but the second time CreateFile fails with GetLastError code C0000005.
Please help and provide me your thoughts on this.
Thanks & Regards,
Shivaprakash