This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 8449 - Definition of System.Threading.NativeOverlapped structure does not correspond to Win32 OVERLAPPED
: Definition of System.Threading.NativeOverlapped structure does not correspond...
Status: VERIFIED FIXED
Product: Class Libraries
Classification: Mono
Component: System
: unspecified
: PC Windows
: --- normal
: ---
Assigned To: Bugzilla
:
:
:
:
  Show dependency treegraph
 
Reported: 2012-11-15 21:59 EST by Alex
Modified: 2012-12-11 08:38 EST (History)
3 users (show)

See Also:
Tags:
Test Case URL:
External Submit: ---


Attachments

Description Alex 2012-11-15 21:59:01 EST
Hi,

NativeOverlapped should represent a Win32 OVERLAPPED structure. In Mono it is
declared as follows

public struct NativeOverlapped {
    public IntPtr EventHandle;
    public IntPtr InternalHigh;
    public IntPtr InternalLow;
    public int OffsetHigh;
    public int OffsetLow;
    // additional fields
}

however Win32 OVERLAPPED is

typedef struct _OVERLAPPED {
  ULONG_PTR Internal;
  ULONG_PTR InternalHigh;
  union {
    struct {
      DWORD Offset;
      DWORD OffsetHigh;
    };
    PVOID  Pointer;
  };
  HANDLE    hEvent;
} OVERLAPPED, *LPOVERLAPPED;

therefore definition of NativeOverlapped should be something like

public struct NativeOverlapped
{ 
    public IntPtr  InternalLow; 
    public IntPtr  InternalHigh;
    public int     OffsetLow; 
    public int     OffsetHigh;
    public IntPtr  EventHandle;
    // additional fields
}


Win32 overlapped IO depends on NativeOverlapped, particularly the SerialPort
class is affected - it is not possible to run concurrent reads and writes on
serial ports. Please correct the order of fields of NativeOverlapped.
Comment 1 Jonathan Pryor 2012-11-15 23:38:07 EST
For reference, the WinAPI documentation for OVERLAPPED:

http://msdn.microsoft.com/en-us/library/windows/desktop/ms684342(v=vs.85).aspx
Comment 2 Marek Safar 2012-11-20 07:04:59 EST
Fixed in master

Note You need to log in before you can comment on or make changes to this bug.