[Winpcap-users] WriteFile fails with ERROR_GEN_FAILURE

Gianluca Varenni gianluca.varenni at cacetech.com
Mon Nov 6 16:24:28 GMT 2006


Eli, 

I'd need a small code sample to reproduce the problem.

Regarding your approach, please remember that we strongly discourage people from using the Packet.dll interface because subject to change. In your case you are basically modifying the internals of Packet.dll. Again, the interface that we use to communicate with the kernel driver changes from version to version of WinPcap (in fact there was a major change sometime between 3.1 and 4.0beta), so if you use your custom version of packet.dll, you are bound to a specific version of the kernel driver.

Hope it helps
GV

  ----- Original Message ----- 
  From: Eli Iser 
  To: winpcap-users at winpcap.org 
  Sent: Monday, November 06, 2006 6:51 AM
  Subject: [Winpcap-users] WriteFile fails with ERROR_GEN_FAILURE


  I'm having a problem with using the Packet32 code in my application. When sending a packet using PacketSendPacket it sometimes failes with GetLastError returning 31 - ERROR_GEN_FAILURE.

  A little more detail:

  I'm running WinXP SP2 on a P4 with a copy of Packet32 obtained from the WinPCap site from the 3.1 developer's pack.
  I'm using the code directly in my appliction, and not in a separate dll.
  Also, I've made several small changes to the code, most of little concern, but I did change the way to open the adapter to overlapped. Accordingly, I've modified all of the appropriate function calls that are affected by overlapped to use the overlapped structure (WriteFile, ReadFile and DeviveIoCtl). 
  I've added three overlapped structures to the ADAPTER struct - one for reading, one for writing and one for DeviveIoCtl. 
  The relavent changes from the overlapped are in the PacketReceivePacket and the PacketSendPacket:

  The applications basic design is as like a bridge - read a packet from adapter A and write it to adapter B; read a packet from adapter B and write it to adapter A. I have two threads that perform the receives - one for each adapter. 

  When sending a packet I first call GetOverlappedResult with bWait being TRUE to make sure no IO is pending, so that I can send my packet. The I check if the WriteFile returns FALSE, and if so check the GetLastError(). If it's ERROR_IO_PENDING I return TRUE from the PacketSendPacket. Else I return FALSE. Here I don't care if the packet was actually sent already. I want to return to doing my own stuff. 

  When receiving a packet I call the ReadFile fucntion, and then call GetOverlappedResult with bWait being TRUE to make sure I get the packet. I must have the packet, since I have nothing else to do while waiting for it. 

  On quite rare occasions the WriteFile in the PacketSendPacket fails with GetLastError() returning 31 - ERROR_GEN_FAILURE. After this happens all calls to function with this adapter's handle fails. Furthermore, because I wait before sending I get stuck on the GetOverlappedResult (bWait is true - so I'm stuck until any IO is complete, which obviosly ain't gonna happen...). 

  Any suggestions will be welcomed.
  Maybe it's all the overlapped's fault? I found that it gave quite a performance boost, so I'd rather not return to non-overlapped working. 
  Maybe I'm using the overlapped wrong? Something I forgot to do? I'm not well versed in working with overlapped. 




  Thanks much,

  Eli Iser


------------------------------------------------------------------------------


  _______________________________________________
  Winpcap-users mailing list
  Winpcap-users at winpcap.org
  https://www.winpcap.org/mailman/listinfo/winpcap-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winpcap.org/pipermail/winpcap-users/attachments/20061106/d3ba3a64/attachment.htm


More information about the Winpcap-users mailing list