blob: e1bfd089d90c6728e58658f294881808b2fd361b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
/*============================================================
**
** Header: COMNativeOverlapped.h
**
** Purpose: Native methods for allocating and freeing NativeOverlapped
**
**
===========================================================*/
#ifndef _OVERLAPPED_H
#define _OVERLAPPED_H
struct NATIVEOVERLAPPED_AND_HANDLE
{
OVERLAPPED m_overlapped;
OBJECTHANDLE m_handle;
};
// This should match the managed Overlapped object.
// If you make any change here, you need to change the managed part Overlapped.
class OverlappedDataObject : public Object
{
public:
// OverlappedDataObject is very special. An async pin handle keeps it alive.
// During GC, we also make sure
// 1. m_userObject itself does not move if m_userObject is not array
// 2. Every object pointed by m_userObject does not move if m_userObject is array
OBJECTREF m_asyncResult;
OBJECTREF m_callback;
OBJECTREF m_overlapped;
OBJECTREF m_userObject;
LPOVERLAPPED m_pNativeOverlapped;
ULONG_PTR m_eventHandle;
int m_offsetLow;
int m_offsetHigh;
#ifndef DACCESS_COMPILE
static OverlappedDataObject* GetOverlapped(LPOVERLAPPED nativeOverlapped)
{
LIMITED_METHOD_CONTRACT;
_ASSERTE (nativeOverlapped != NULL);
return (OverlappedDataObject*)OBJECTREFToObject(ObjectFromHandle(((NATIVEOVERLAPPED_AND_HANDLE*)nativeOverlapped)->m_handle));
}
// Return the raw OverlappedDataObject* without going into cooperative mode for tracing
static OverlappedDataObject* GetOverlappedForTracing(LPOVERLAPPED nativeOverlapped)
{
LIMITED_METHOD_CONTRACT;
_ASSERTE(nativeOverlapped != NULL);
return *(OverlappedDataObject**)(((NATIVEOVERLAPPED_AND_HANDLE*)nativeOverlapped)->m_handle);
}
#endif // DACCESS_COMPILE
};
#ifdef USE_CHECKED_OBJECTREFS
typedef REF<OverlappedDataObject> OVERLAPPEDDATAREF;
#define ObjectToOVERLAPPEDDATAREF(obj) (OVERLAPPEDDATAREF(obj))
#define OVERLAPPEDDATAREFToObject(objref) (OBJECTREFToObject (objref))
#else
typedef OverlappedDataObject* OVERLAPPEDDATAREF;
#define ObjectToOVERLAPPEDDATAREF(obj) ((OverlappedDataObject*) (obj))
#define OVERLAPPEDDATAREFToObject(objref) ((OverlappedDataObject*) (objref))
#endif
FCDECL3(void, CheckVMForIOPacket, LPOVERLAPPED* lpOverlapped, DWORD* errorCode, DWORD* numBytes);
FCDECL1(LPOVERLAPPED, AllocateNativeOverlapped, OverlappedDataObject* overlapped);
FCDECL1(void, FreeNativeOverlapped, LPOVERLAPPED lpOverlapped);
FCDECL1(OverlappedDataObject*, GetOverlappedFromNative, LPOVERLAPPED lpOverlapped);
#endif
|