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
Summary: Definition of System.Threading.NativeOverlapped structure does not correspond...
Status: VERIFIED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-11-15 21:59 UTC by Alex
Modified: 2012-12-11 08:38 UTC (History)
3 users (show)

See Also:
Tags:


Attachments

Description Alex 2012-11-15 21:59:01 UTC
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 UTC
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 UTC
Fixed in master

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