Virtual Serial port with UMDF / WriteFile Error when using FILE_FLAG_OVERLAPPED

Hi,

When I use CreateFile with FILE_FLAG_OVERLAPPED flag, and try to write to my driver using WriteFile, it returns an error although my driver received the data just fine.

When not using FILE_FLAG_OVERLAPPED everything is ok.

same happens with the virtual serial port example comes with winDDK 7000.0

any suggestions ??

thanks

What was the win32 error? Did you pass a valid OVERLAPPED with a valid hEvent handle?

d

Sent from my phone with no t9, all spilling mistakes are not intentional.

-----Original Message-----
From: xxxxx@gmail.com
Sent: Sunday, May 17, 2009 3:55 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Virtual Serial port with UMDF / WriteFile Error when using FILE_FLAG_OVERLAPPED

Hi,

When I use CreateFile with FILE_FLAG_OVERLAPPED flag, and try to write to my driver using WriteFile, it returns an error although my driver received the data just fine.

When not using FILE_FLAG_OVERLAPPED everything is ok.

same happens with the virtual serial port example comes with winDDK 7000.0

any suggestions ??

thanks


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

the error is :

ERROR_IO_PENDING
997 (0x3E5) Overlapped I/O operation is in progress.

I think I pass a vaild OVERLAPPED, here is they way I create it:

_OVERLAPPED overlp;
overlp.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
overlp.Internal = NULL;
overlp.InternalHigh = NULL;
overlp.Offset =0;
overlp.OffsetHigh =0;
overlp.Pointer=NULL;

From:
> the error is :
> ERROR_IO_PENDING
> 997 (0x3E5) Overlapped I/O operation is in progress.

Well, duh! That’s an EXPECTED error. You just need to call
GetOverlappedResult and wait for the operation to finish.

Walter Oney
Consulting and Training
www.oneysoft.com

> ERROR_IO_PENDING

997 (0x3E5) Overlapped I/O operation is in progress.

That is normal for overlapped IO and is not an error.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

Note that certain buggy OCX (MSCOMM) may not work with your driver.

As do many other virtualization solutions. I considered mentioning that, but the similarities to USB passthrough vs. hardware-level bugs on the USB controllers that might have commonly shipped with 440BX systems are probably a dubious thing to draw conclusions from.

  • S

-----Original Message-----
From: xxxxx@broadcom.com
Sent: Monday, May 18, 2009 17:02
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Virtual Serial port with UMDF / WriteFile Error when using FILE_FLAG_OVERLAPPED

Note that certain buggy OCX (MSCOMM) may not work with your driver.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

AFAIK, the ocx issues are related to reads, not writes

d

Sent from my phone with no t9, all spilling mistakes are not intentional.

-----Original Message-----
From: xxxxx@broadcom.com
Sent: Monday, May 18, 2009 5:04 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Virtual Serial port with UMDF / WriteFile Error when using FILE_FLAG_OVERLAPPED

Note that certain buggy OCX (MSCOMM) may not work with your driver.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

You guys are right, that is not a problem. I was looking for a reason why .NET’s ports write() function is throwing me timeout, now i see that it is not the reason.

Looking deeper into the BCL, the only difference i see is that .net looks into the OVERLAPPED object and with it determines the number of bytes where written, if the number is 0 it throws the time out.

I was debugging my driver and comparing it to a real COM port, the difference i see is that in OVERLAPPED.Internal my driver puts 0, and the real COM puts 259. Could it be the reason ? I don’t see any other place where it can get the number of byes written to the port(although MSDN says internal means the error code).

any ideas ? thanks …

Found the bug !!

in OnWrite() instead of using :

pWdfRequest->Complete(hr);

use:

pWdfRequest->CompleteWithInformation(hr, BytesToWrite);

it should be changed in the exampls too i guess.

thanks for the help !

I assume you mean OnWrite in virtualserial\queue.cpp right?

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Monday, May 18, 2009 10:47 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Virtual Serial port with UMDF / WriteFile Error when using FILE_FLAG_OVERLAPPED

Found the bug !!

in OnWrite() instead of using :

pWdfRequest->Complete(hr);

use:

pWdfRequest->CompleteWithInformation(hr, BytesToWrite);

it should be changed in the exampls too i guess.

thanks for the help !


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Yes exactly.