Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1625 lines
57 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. afdstr.h
  5. Abstract:
  6. This module contains typedefs for structures used by AFD.
  7. Author:
  8. David Treadwell (davidtr) 21-Feb-1992
  9. Revision History:
  10. --*/
  11. #ifndef _AFDSTR_
  12. #define _AFDSTR_
  13. //
  14. // Make sure that queued spinlocks are not used with
  15. // regular spinlock functions by wrapping them into
  16. // a different structure.
  17. //
  18. typedef struct _AFD_QSPIN_LOCK {
  19. KSPIN_LOCK ActualSpinLock;
  20. } AFD_QSPIN_LOCK, *PAFD_QSPIN_LOCK;
  21. #if DBG
  22. #ifndef REFERENCE_DEBUG
  23. #define REFERENCE_DEBUG 1
  24. #endif
  25. #ifndef GLOBAL_REFERENCE_DEBUG
  26. #define GLOBAL_REFERENCE_DEBUG 0
  27. #endif
  28. //
  29. // Debug aid for queued spinlocks
  30. // Allows us to verify that spinlock is released using
  31. // the same handle as it was taken with.
  32. //
  33. typedef struct _AFD_LOCK_QUEUE_HANDLE {
  34. KLOCK_QUEUE_HANDLE LockHandle;
  35. PAFD_QSPIN_LOCK SpinLock;
  36. } AFD_LOCK_QUEUE_HANDLE, *PAFD_LOCK_QUEUE_HANDLE;
  37. #else
  38. #ifndef REFERENCE_DEBUG
  39. #define REFERENCE_DEBUG 0
  40. #endif
  41. #ifndef GLOBAL_REFERENCE_DEBUG
  42. #define GLOBAL_REFERENCE_DEBUG 0
  43. #endif
  44. #define AFD_LOCK_QUEUE_HANDLE KLOCK_QUEUE_HANDLE
  45. #define PAFD_LOCK_QUEUE_HANDLE PKLOCK_QUEUE_HANDLE
  46. #endif // DBG
  47. #if REFERENCE_DEBUG
  48. #define MAX_REFERENCE 64
  49. typedef union _AFD_REFERENCE_DEBUG {
  50. struct {
  51. ULONGLONG NewCount:4;
  52. ULONGLONG LocationId:12;
  53. ULONGLONG TickCount:16;
  54. ULONGLONG Param:32;
  55. };
  56. ULONGLONG QuadPart;
  57. } AFD_REFERENCE_DEBUG, *PAFD_REFERENCE_DEBUG;
  58. C_ASSERT (sizeof (AFD_REFERENCE_DEBUG)==sizeof (ULONGLONG));
  59. typedef struct _AFD_REFERENCE_LOCATION {
  60. PCHAR Format;
  61. PVOID Address;
  62. } AFD_REFERENCE_LOCATION, *PAFD_REFERENCE_LOCATION;
  63. LONG
  64. AfdFindReferenceLocation (
  65. IN PCHAR Format,
  66. OUT PLONG LocationId
  67. );
  68. #define AFD_GET_ARL(_s) (_arl ? _arl : AfdFindReferenceLocation((_s),&_arl))
  69. #define AFD_UPDATE_REFERENCE_DEBUG(_rd,_r,_l,_p) { \
  70. PAFD_REFERENCE_DEBUG _s; \
  71. LONG _n; \
  72. LARGE_INTEGER _t; \
  73. _n = InterlockedIncrement( &(_rd)->CurrentReferenceSlot ); \
  74. _s = &(_rd)->ReferenceDebug[_n % MAX_REFERENCE]; \
  75. _s->NewCount = _r; \
  76. _s->LocationId = _l; \
  77. _s->Param = _p; \
  78. KeQueryTickCount (&_t); \
  79. _s->TickCount = _t.QuadPart; \
  80. }
  81. #if GLOBAL_REFERENCE_DEBUG
  82. #define MAX_GLOBAL_REFERENCE 4096
  83. typedef struct _AFD_GLOBAL_REFERENCE_DEBUG {
  84. PVOID Info1;
  85. PVOID Info2;
  86. PVOID Connection;
  87. ULONG_PTR Action;
  88. LARGE_INTEGER TickCounter;
  89. ULONG NewCount;
  90. ULONG Dummy;
  91. } AFD_GLOBAL_REFERENCE_DEBUG, *PAFD_GLOBAL_REFERENCE_DEBUG;
  92. #endif
  93. #endif
  94. //
  95. // A structure for maintaining work queue information in AFD.
  96. //
  97. typedef struct _AFD_WORK_ITEM {
  98. LIST_ENTRY WorkItemListEntry;
  99. PWORKER_THREAD_ROUTINE AfdWorkerRoutine;
  100. PVOID Context;
  101. } AFD_WORK_ITEM, *PAFD_WORK_ITEM;
  102. //
  103. // Structures for holding connect data pointers and lengths. This is
  104. // kept separate from the normal structures to save space in those
  105. // structures for transports that do not support and applications
  106. // which do not use connect data.
  107. //
  108. typedef struct _AFD_CONNECT_DATA_INFO {
  109. PVOID Buffer;
  110. ULONG BufferLength;
  111. } AFD_CONNECT_DATA_INFO, *PAFD_CONNECT_DATA_INFO;
  112. typedef struct _AFD_CONNECT_DATA_BUFFERS {
  113. AFD_CONNECT_DATA_INFO SendConnectData;
  114. AFD_CONNECT_DATA_INFO SendConnectOptions;
  115. AFD_CONNECT_DATA_INFO ReceiveConnectData;
  116. AFD_CONNECT_DATA_INFO ReceiveConnectOptions;
  117. AFD_CONNECT_DATA_INFO SendDisconnectData;
  118. AFD_CONNECT_DATA_INFO SendDisconnectOptions;
  119. AFD_CONNECT_DATA_INFO ReceiveDisconnectData;
  120. AFD_CONNECT_DATA_INFO ReceiveDisconnectOptions;
  121. TDI_CONNECTION_INFORMATION RequestConnectionInfo;
  122. TDI_CONNECTION_INFORMATION ReturnConnectionInfo;
  123. ULONG Flags;
  124. } AFD_CONNECT_DATA_BUFFERS, *PAFD_CONNECT_DATA_BUFFERS;
  125. //
  126. // Structure used for holding disconnect context information.
  127. //
  128. struct _AFD_ENDPOINT;
  129. struct _AFD_CONNECTION;
  130. typedef struct _AFD_DISCONNECT_CONTEXT {
  131. LARGE_INTEGER Timeout;
  132. PIRP Irp;
  133. } AFD_DISCONNECT_CONTEXT, *PAFD_DISCONNECT_CONTEXT;
  134. typedef struct _AFD_LR_LIST_ITEM AFD_LR_LIST_ITEM, *PAFD_LR_LIST_ITEM;
  135. typedef BOOLEAN (* PAFD_LR_LIST_ROUTINE) (PAFD_LR_LIST_ITEM Item);
  136. struct _AFD_LR_LIST_ITEM {
  137. SINGLE_LIST_ENTRY SListLink; // Link in the list
  138. PAFD_LR_LIST_ROUTINE Routine; // Processing routine;
  139. };
  140. //
  141. // Endpoint and connection structures and related informaion.
  142. //
  143. //
  144. // Block types that identify which fields are
  145. // available in the strucutures.
  146. //
  147. #define AfdBlockTypeEndpoint 0xAFD0
  148. #define AfdBlockTypeDatagram 0xAFD1
  149. #define AfdBlockTypeVcConnecting 0xAFD2
  150. #define AfdBlockTypeVcListening 0xAFD4
  151. #define AfdBlockTypeVcBoth 0xAFD6
  152. #define AfdBlockTypeConnection 0xAFD8
  153. #define AfdBlockTypeHelper 0xAAFD
  154. #define AfdBlockTypeInvalidConnection 0xEAFD
  155. #define AfdBlockTypeInvalidEndpoint 0xCAFD
  156. #define AfdBlockTypeSanHelper 0x0AFD
  157. #define AfdBlockTypeSanEndpoint 0x1AFD
  158. #if DBG
  159. #define IS_AFD_ENDPOINT_TYPE( endpoint ) \
  160. ( (endpoint)->Type == AfdBlockTypeEndpoint || \
  161. (endpoint)->Type == AfdBlockTypeDatagram || \
  162. (endpoint)->Type == AfdBlockTypeVcConnecting || \
  163. (endpoint)->Type == AfdBlockTypeVcListening || \
  164. (endpoint)->Type == AfdBlockTypeVcBoth || \
  165. (endpoint)->Type == AfdBlockTypeHelper || \
  166. (endpoint)->Type == AfdBlockTypeSanHelper || \
  167. (endpoint)->Type == AfdBlockTypeSanEndpoint )
  168. #endif
  169. #define AfdConnectionStateFree 0
  170. #define AfdConnectionStateUnaccepted 1
  171. #define AfdConnectionStateReturned 2
  172. #define AfdConnectionStateConnected 3
  173. #define AfdConnectionStateClosing 4
  174. //
  175. // Flags that further qualify the state of the connection
  176. //
  177. typedef struct AFD_CONNECTION_STATE_FLAGS {
  178. union {
  179. struct {
  180. LOGICAL TdiBufferring:1, // (Does not really belon here)
  181. :3, // This spacing makes strcutures
  182. // much more readable (hex) in the
  183. // debugger and has no effect
  184. // on the generated code as long
  185. // as number of flags is less than
  186. // 8 (we still take up full 32 bits
  187. // because of aligment requiremens
  188. // of most other fields)
  189. AbortIndicated:1,
  190. :3,
  191. DisconnectIndicated:1,
  192. :3,
  193. ConnectedReferenceAdded:1,
  194. :3,
  195. SpecialCondition:1,
  196. :3,
  197. CleanupBegun:1,
  198. :3,
  199. ClosePendedTransmit:1,
  200. :3,
  201. OnLRList:1,
  202. SanConnection:1,
  203. :2;
  204. };
  205. LOGICAL ConnectionStateFlags;
  206. };
  207. } AFD_CONNECTION_STATE_FLAGS;
  208. C_ASSERT (sizeof (AFD_CONNECTION_STATE_FLAGS)==sizeof (LOGICAL));
  209. typedef struct _AFD_CONNECTION {
  210. // *** Frequently used, mostly read-only fields (state/type/flag changes are rare).
  211. USHORT Type;
  212. USHORT State;
  213. AFD_CONNECTION_STATE_FLAGS ;
  214. struct _AFD_ENDPOINT *Endpoint;
  215. PFILE_OBJECT FileObject;
  216. PDEVICE_OBJECT DeviceObject;
  217. PEPROCESS OwningProcess;
  218. union {
  219. LONGLONG ConnectTime;
  220. PIRP AcceptIrp;
  221. PIRP ListenIrp;
  222. PIRP ConnectIrp; // for SAN
  223. };
  224. // *** Frequently used volatile fields.
  225. volatile LONG ReferenceCount;
  226. union {
  227. struct {
  228. LARGE_INTEGER ReceiveBytesIndicated;
  229. LARGE_INTEGER ReceiveBytesTaken;
  230. LARGE_INTEGER ReceiveBytesOutstanding;
  231. LARGE_INTEGER ReceiveExpeditedBytesIndicated;
  232. LARGE_INTEGER ReceiveExpeditedBytesTaken;
  233. LARGE_INTEGER ReceiveExpeditedBytesOutstanding;
  234. BOOLEAN NonBlockingSendPossible;
  235. BOOLEAN ZeroByteReceiveIndicated;
  236. } Bufferring;
  237. struct {
  238. LIST_ENTRY ReceiveIrpListHead;
  239. LIST_ENTRY ReceiveBufferListHead;
  240. CLONG BufferredReceiveBytes;
  241. CLONG BufferredExpeditedBytes;
  242. USHORT BufferredReceiveCount;
  243. USHORT BufferredExpeditedCount;
  244. CLONG ReceiveBytesInTransport;
  245. LIST_ENTRY SendIrpListHead;
  246. CLONG BufferredSendBytes;
  247. CLONG BufferredSendCount;
  248. PIRP DisconnectIrp;
  249. LONG ReceiveIrpsInTransport; // debug only.
  250. } NonBufferring;
  251. } Common;
  252. CLONG MaxBufferredReceiveBytes;
  253. CLONG MaxBufferredSendBytes;
  254. PTRANSPORT_ADDRESS RemoteAddress;
  255. ULONG RemoteAddressLength;
  256. LONG Sequence;
  257. HANDLE Handle;
  258. union {
  259. AFD_WORK_ITEM WorkItem; // Work item to free the connection
  260. // Connection has to be at ref 0 to be
  261. // on the work queue, so it cannot be
  262. // on the lists below or being disconnected
  263. // because when on any of these lists the
  264. // ref count is above 0.
  265. struct {
  266. union {
  267. AFD_DISCONNECT_CONTEXT DisconnectContext;
  268. // Disconnect operation context, we cannot be
  269. // on the listening endpoint list
  270. SINGLE_LIST_ENTRY SListEntry;
  271. // Links for listening endpoint lists
  272. LIST_ENTRY ListEntry;
  273. };
  274. AFD_LR_LIST_ITEM LRListItem; // Link for low resource list. When on this
  275. // list connection is referenced, but it can
  276. // also be on the listening endpoint list or
  277. // in the process of disconnecting.
  278. };
  279. };
  280. PAFD_CONNECT_DATA_BUFFERS ConnectDataBuffers;
  281. #if REFERENCE_DEBUG
  282. LONG CurrentReferenceSlot;
  283. AFD_REFERENCE_DEBUG ReferenceDebug[MAX_REFERENCE];
  284. #endif
  285. #ifdef _AFD_VERIFY_DATA_
  286. ULONGLONG VerifySequenceNumber;
  287. #endif // _AFD_VERIFY_DATA_
  288. } AFD_CONNECTION, *PAFD_CONNECTION;
  289. #ifdef _AFD_VERIFY_DATA_
  290. VOID
  291. AfdVerifyBuffer (
  292. PAFD_CONNECTION Connection,
  293. PVOID Buffer,
  294. ULONG Length
  295. );
  296. VOID
  297. AfdVerifyMdl (
  298. PAFD_CONNECTION Connection,
  299. PMDL Mdl,
  300. ULONG Offset,
  301. ULONG Length
  302. );
  303. VOID
  304. AfdVerifyAddress (
  305. PAFD_CONNECTION Connection,
  306. PTRANSPORT_ADDRESS Address
  307. );
  308. #define AFD_VERIFY_BUFFER(_connection,_buffer,_length) \
  309. AfdVerifyBuffer(_connection,_buffer,_length)
  310. #define AFD_VERIFY_MDL(_connection,_mdl,_offset,_length) \
  311. AfdVerifyMdl(_connection,_mdl,_offset,_length)
  312. #define AFD_VERIFY_ADDRESS(_connection,_address) \
  313. AfdVerifyAddress(_connection,_address)
  314. #else
  315. #define AFD_VERIFY_BUFFER(_connection,_buffer,_length)
  316. #define AFD_VERIFY_MDL(_connection,_mdl,_offset,_length)
  317. #define AFD_VERIFY_ADDRESS(_connection,_address)
  318. #endif // _AFD_VERIFY_DATA_
  319. //
  320. // Some macros that make code more readable.
  321. //
  322. #define VcNonBlockingSendPossible Common.Bufferring.NonBlockingSendPossible
  323. #define VcZeroByteReceiveIndicated Common.Bufferring.ZeroByteReceiveIndicated
  324. #define VcReceiveIrpListHead Common.NonBufferring.ReceiveIrpListHead
  325. #define VcReceiveBufferListHead Common.NonBufferring.ReceiveBufferListHead
  326. #define VcSendIrpListHead Common.NonBufferring.SendIrpListHead
  327. #define VcBufferredReceiveBytes Common.NonBufferring.BufferredReceiveBytes
  328. #define VcBufferredExpeditedBytes Common.NonBufferring.BufferredExpeditedBytes
  329. #define VcBufferredReceiveCount Common.NonBufferring.BufferredReceiveCount
  330. #define VcBufferredExpeditedCount Common.NonBufferring.BufferredExpeditedCount
  331. #define VcReceiveBytesInTransport Common.NonBufferring.ReceiveBytesInTransport
  332. #if DBG
  333. #define VcReceiveIrpsInTransport Common.NonBufferring.ReceiveIrpsInTransport
  334. #endif
  335. #define VcBufferredSendBytes Common.NonBufferring.BufferredSendBytes
  336. #define VcBufferredSendCount Common.NonBufferring.BufferredSendCount
  337. #define VcDisconnectIrp Common.NonBufferring.DisconnectIrp
  338. //
  339. // Information stored about each transport device name for which there
  340. // is an open endpoint.
  341. //
  342. typedef struct _AFD_TRANSPORT_INFO {
  343. LIST_ENTRY TransportInfoListEntry;
  344. volatile LONG ReferenceCount;
  345. BOOLEAN InfoValid;
  346. UNICODE_STRING TransportDeviceName;
  347. TDI_PROVIDER_INFO ProviderInfo;
  348. //WCHAR TransportDeviceNameStructure;
  349. } AFD_TRANSPORT_INFO, *PAFD_TRANSPORT_INFO;
  350. //
  351. // Endpoint state definitions (can't be zero or state change
  352. // macros won't work correctly).
  353. //
  354. #define AfdEndpointStateOpen 1
  355. #define AfdEndpointStateBound 2
  356. #define AfdEndpointStateConnected 3
  357. #define AfdEndpointStateCleanup 4
  358. #define AfdEndpointStateClosing 5
  359. #define AfdEndpointStateTransmitClosing 6
  360. #define AfdEndpointStateInvalid 7
  361. //
  362. // Flags that further qualify the state of the endpoint
  363. //
  364. typedef struct AFD_ENDPOINT_STATE_FLAGS {
  365. union {
  366. struct {
  367. LOGICAL Listening:1,
  368. DelayedAcceptance:1,
  369. :2, // This spacing makes strcutures
  370. // much more readable (hex) in the
  371. // debugger and has no effect
  372. // on the generated code as long
  373. // as number of flags is less than
  374. // 8 (we still take up full 32 bits
  375. // because of aligment requiremens
  376. // of most other fields)
  377. NonBlocking:1,
  378. :3,
  379. InLine:1,
  380. :3,
  381. EndpointCleanedUp:1,
  382. :3,
  383. PollCalled:1,
  384. :3,
  385. RoutingQueryReferenced:1,
  386. RoutingQueryIPv6:1,
  387. :2,
  388. DisableFastIoSend:1,
  389. EnableSendEvent:1,
  390. :2,
  391. DisableFastIoRecv:1,
  392. :3;
  393. };
  394. LOGICAL EndpointStateFlags;
  395. };
  396. } AFD_ENDPOINT_STATE_FLAGS;
  397. C_ASSERT (sizeof (AFD_ENDPOINT_STATE_FLAGS)==sizeof (LOGICAL));
  398. typedef struct _AFD_ENDPOINT {
  399. // *** Frequently used, mostly read-only fields (state/type/flag changes are rare).
  400. USHORT Type;
  401. UCHAR State;
  402. BOOLEAN AdminAccessGranted;
  403. ULONG TdiServiceFlags; // Tdi transport flags cached for quick access.
  404. AFD_ENDPOINT_FLAGS __f; // As requested by the application through the
  405. // Winsock2 provider flags and/or socket type
  406. AFD_ENDPOINT_STATE_FLAGS ;
  407. PFILE_OBJECT AddressFileObject;
  408. PDEVICE_OBJECT AddressDeviceObject;
  409. PEPROCESS OwningProcess;
  410. // *** Frequently used volatile fields.
  411. AFD_QSPIN_LOCK SpinLock; // Pointer sized.
  412. volatile LONG ReferenceCount;
  413. ULONG EventsActive;
  414. //
  415. // Use a union to overlap the fields that are exclusive to datagram
  416. // connecting, or listening endpoints. Since many fields are
  417. // relevant to only one type of socket, it makes no sense to
  418. // maintain the fields for all sockets--instead, save some nonpaged
  419. // pool by combining them.
  420. //
  421. union {
  422. //
  423. // Information for circuit-based endpoints
  424. //
  425. struct {
  426. union {
  427. struct {
  428. // These members are valid for listening endpoints
  429. // (AfdBlockTypeVcListening).
  430. LIST_ENTRY UnacceptedConnectionListHead;
  431. LIST_ENTRY ReturnedConnectionListHead;
  432. LIST_ENTRY ListeningIrpListHead;
  433. // The below lists have their own lock which gets
  434. // used on the machines that do not support 64-bit
  435. // interlocked compare and exchange. On these machines
  436. // using endpoint spinlock to synchronize causes all kinds
  437. // of nasty deadlock conditions.
  438. union {
  439. LIST_ENTRY ListenConnectionListHead; // Delayed accept
  440. SLIST_HEADER FreeConnectionListHead;
  441. };
  442. SLIST_HEADER PreacceptedConnectionsListHead;
  443. LONG FailedConnectionAdds;
  444. LONG TdiAcceptPendingCount;
  445. LONG Sequence;
  446. BOOLEAN EnableDynamicBacklog;
  447. BOOLEAN BacklogReplenishActive; // Worker is scheduled
  448. USHORT MaxExtraConnections; // Extra connections we keep in the free queue
  449. // based on maximum number of AcceptEx requests
  450. } Listening;
  451. struct {
  452. KAPC Apc;
  453. USHORT RemoteSocketAddressOffset; // Offset inside of socket context
  454. // pointing to remote address.
  455. USHORT RemoteSocketAddressLength; // Length of the address.
  456. #ifndef i386
  457. BOOLEAN FixAddressAlignment; // Fix address alignment in
  458. // SuperAccept
  459. #endif
  460. };
  461. };
  462. // These members are valid for all vc endpoints (but
  463. // can be NULL)
  464. PAFD_CONNECTION Connection;
  465. struct _AFD_ENDPOINT *ListenEndpoint;
  466. PAFD_CONNECT_DATA_BUFFERS ConnectDataBuffers;
  467. } VirtualCircuit;
  468. #define VcConnecting VirtualCircuit
  469. #define VcListening VirtualCircuit.Listening
  470. #define VcConnection VirtualCircuit.Connection
  471. //
  472. // Information for datagram endpoints. Note that different
  473. // information is kept depending on whether the underlying
  474. // transport buffers internally.
  475. //
  476. struct {
  477. LIST_ENTRY ReceiveIrpListHead;
  478. LIST_ENTRY PeekIrpListHead;
  479. LIST_ENTRY ReceiveBufferListHead;
  480. CLONG BufferredReceiveBytes;
  481. CLONG BufferredReceiveCount;
  482. CLONG MaxBufferredReceiveBytes;
  483. CLONG BufferredSendBytes;
  484. CLONG MaxBufferredSendBytes;
  485. ULONG RemoteAddressLength;
  486. PTRANSPORT_ADDRESS RemoteAddress;
  487. union {
  488. struct {
  489. LOGICAL CircularQueueing:1,
  490. :3,
  491. HalfConnect:1,
  492. :3,
  493. DisablePUError:1,
  494. :3,
  495. AddressDrop:1,
  496. ResourceDrop:1,
  497. BufferDrop:1,
  498. ErrorDrop:1;
  499. };
  500. LOGICAL Flags;
  501. };
  502. } Datagram;
  503. struct {
  504. LIST_ENTRY SanListLink;
  505. PVOID IoCompletionPort;
  506. PKEVENT IoCompletionEvent;
  507. LONG Plsn; // Provider list sequence number
  508. } SanHlpr;
  509. struct {
  510. struct _AFD_ENDPOINT *SanHlpr;
  511. PFILE_OBJECT FileObject;
  512. union {
  513. //
  514. // We can only have either one of two at any given time.
  515. //
  516. PAFD_SWITCH_CONTEXT SwitchContext;
  517. PVOID SavedContext;
  518. };
  519. PAFD_SWITCH_CONTEXT LocalContext;
  520. LIST_ENTRY IrpList;
  521. ULONG SavedContextLength;
  522. ULONG RequestId;
  523. ULONG SelectEventsActive;
  524. NTSTATUS CtxTransferStatus;
  525. BOOLEAN ImplicitDup; // Dup-ed into another process without
  526. // explicit request from the applicaiton
  527. } SanEndp;
  528. } Common;
  529. volatile PVOID Context;
  530. CLONG ContextLength;
  531. ULONG LocalAddressLength;
  532. PTRANSPORT_ADDRESS LocalAddress;
  533. CLONG DisconnectMode;
  534. CLONG OutstandingIrpCount;
  535. HANDLE AddressHandle; // TDI transport address object
  536. PAFD_TRANSPORT_INFO TransportInfo;
  537. LIST_ENTRY RoutingNotifications; // For non-blocking sockets
  538. LIST_ENTRY RequestList; // For misc requests
  539. LIST_ENTRY GlobalEndpointListEntry;
  540. AFD_WORK_ITEM WorkItem;
  541. PIRP Irp; // AcceptEx or TransmitPackets IRP
  542. //
  543. // Non-zero when state change such as binding, accepting,
  544. // conntecting, and transmit file are in progress.
  545. LONG StateChangeInProgress;
  546. //
  547. // EventSelect info.
  548. //
  549. ULONG EventsEnabled;
  550. NTSTATUS EventStatus[AFD_NUM_POLL_EVENTS]; // Currently 13 events
  551. PKEVENT EventObject;
  552. //
  553. // Socket grouping.
  554. //
  555. LONG GroupID;
  556. AFD_GROUP_TYPE GroupType;
  557. LIST_ENTRY ConstrainedEndpointListEntry;
  558. //
  559. // Debug stuff.
  560. //
  561. #if REFERENCE_DEBUG
  562. LONG CurrentReferenceSlot;
  563. AFD_REFERENCE_DEBUG ReferenceDebug[MAX_REFERENCE];
  564. #endif
  565. #if DBG
  566. LIST_ENTRY OutstandingIrpListHead;
  567. LONG ObReferenceBias;
  568. #endif
  569. } AFD_ENDPOINT, *PAFD_ENDPOINT;
  570. typedef struct _AFD_POLL_ENDPOINT_INFO {
  571. PAFD_ENDPOINT Endpoint;
  572. PFILE_OBJECT FileObject;
  573. HANDLE Handle;
  574. ULONG PollEvents;
  575. } AFD_POLL_ENDPOINT_INFO, *PAFD_POLL_ENDPOINT_INFO;
  576. typedef struct _AFD_POLL_INFO_INTERNAL {
  577. LIST_ENTRY PollListEntry;
  578. ULONG NumberOfEndpoints;
  579. PIRP Irp;
  580. union {
  581. struct {
  582. KDPC Dpc;
  583. KTIMER Timer;
  584. };
  585. KAPC Apc; // for SAN
  586. };
  587. BOOLEAN Unique;
  588. BOOLEAN TimerStarted;
  589. BOOLEAN SanPoll;
  590. AFD_POLL_ENDPOINT_INFO EndpointInfo[1];
  591. } AFD_POLL_INFO_INTERNAL, *PAFD_POLL_INFO_INTERNAL;
  592. //
  593. // A couple of useful manifests that make code more readable.
  594. //
  595. #define ReceiveDatagramIrpListHead Common.Datagram.ReceiveIrpListHead
  596. #define PeekDatagramIrpListHead Common.Datagram.PeekIrpListHead
  597. #define ReceiveDatagramBufferListHead Common.Datagram.ReceiveBufferListHead
  598. #define DgBufferredReceiveCount Common.Datagram.BufferredReceiveCount
  599. #define DgBufferredReceiveBytes Common.Datagram.BufferredReceiveBytes
  600. #define DgBufferredSendBytes Common.Datagram.BufferredSendBytes
  601. #define AFD_CONNECTION_FROM_ENDPOINT( endpoint ) ( \
  602. (((endpoint)->Type & AfdBlockTypeVcConnecting)==AfdBlockTypeVcConnecting) \
  603. ? (endpoint)->Common.VirtualCircuit.Connection \
  604. : NULL \
  605. )
  606. //
  607. // A structure which describes buffers used by AFD to perform bufferring
  608. // for TDI providers which do not perform internal bufferring.
  609. // It is also used in other code path as buffer descriptors.
  610. //
  611. typedef struct _AFD_BUFFER_HEADER AFD_BUFFER_HEADER, *PAFD_BUFFER_HEADER;
  612. #define _AFD_BUFFER_HEADER_ \
  613. union { \
  614. TDI_CONNECTION_INFORMATION TdiInfo; /*holds info for TDI requests */ \
  615. /*with remote address */ \
  616. struct { \
  617. union { /* Links */ \
  618. struct { \
  619. union { \
  620. SINGLE_LIST_ENTRY SList; /* for buffer lookaside lists */ \
  621. PAFD_BUFFER_HEADER Next; /* for transmit packet lists */ \
  622. }; \
  623. PFILE_OBJECT FileObject; /* for cached file in transmit file */ \
  624. }; \
  625. LIST_ENTRY BufferListEntry; /* for endpoint/connection lists */ \
  626. }; \
  627. union { \
  628. struct { \
  629. CLONG DataOffset; /* offset in buffer to start of unread data*/\
  630. union { \
  631. ULONG DatagramFlags; /* flags for datagrams with control info */\
  632. CLONG RefCount; /* Permit partial copy outside the lock*/ \
  633. }; \
  634. }; \
  635. LARGE_INTEGER FileOffset; /* data offset from the start of the file */\
  636. }; \
  637. UCHAR _Test; /* used to test relative field pos in the union */ \
  638. }; \
  639. }; \
  640. union { \
  641. PVOID Context; /* stores context info (endp/conn/etc)*/ \
  642. NTSTATUS Status;/* stores status of completed operation */ \
  643. }; \
  644. PMDL Mdl; /* pointer to an MDL describing the buffer*/ \
  645. CLONG DataLength; /* actual data in the buffer */ \
  646. CLONG BufferLength; /* amount of space allocated for the buffer */ \
  647. union { \
  648. struct { \
  649. /* Flags that describe data in the buffer */ \
  650. UCHAR ExpeditedData:1, /* The buffer contains expedited data*/ \
  651. :3, \
  652. PartialMessage:1,/* This is a partial message*/ \
  653. :3; \
  654. /* Flags that keep allocation information */ \
  655. UCHAR NdisPacket:1, /* Context is a packet to return to NDIS/TDI*/ \
  656. :3, \
  657. Placement:2, /* Relative placement of the pieces */ \
  658. AlignmentAdjusted:1, /* MM block alignment was adjusted to */ \
  659. /* meet AFD buffer alignment requirement */ \
  660. Lookaside:1; /* Poped from Slist (no quota charge)*/ \
  661. }; \
  662. USHORT Flags; \
  663. }; \
  664. USHORT AllocatedAddressLength/* length allocated for address */ \
  665. struct _AFD_BUFFER_HEADER {
  666. _AFD_BUFFER_HEADER_ ;
  667. };
  668. //
  669. // The buffer management code makes the following assumptions
  670. // about the union at the top the buffer header so that list
  671. // links and DataOffset field are not in conflict with
  672. // RemoteAddress fields of the TDI_CONNECTION_INFORMATION.
  673. //
  674. C_ASSERT (FIELD_OFFSET (AFD_BUFFER_HEADER, TdiInfo.RemoteAddress) >=
  675. FIELD_OFFSET (AFD_BUFFER_HEADER, _Test));
  676. C_ASSERT (FIELD_OFFSET (AFD_BUFFER_HEADER, TdiInfo.RemoteAddressLength)>=
  677. FIELD_OFFSET (AFD_BUFFER_HEADER, _Test));
  678. C_ASSERT(FIELD_OFFSET (AFD_BUFFER_HEADER, AllocatedAddressLength)==
  679. FIELD_OFFSET(AFD_BUFFER_HEADER, Flags)+sizeof (USHORT));
  680. typedef struct AFD_BUFFER_TAG {
  681. union {
  682. struct {
  683. _AFD_BUFFER_HEADER_; // easy access to individual members
  684. };
  685. AFD_BUFFER_HEADER Header; // access to the header as a whole
  686. };
  687. #if DBG
  688. PVOID Caller;
  689. PVOID CallersCaller;
  690. #endif
  691. // UCHAR Address[]; // address of datagram sender
  692. } AFD_BUFFER_TAG, *PAFD_BUFFER_TAG;
  693. typedef DECLSPEC_ALIGN(MEMORY_ALLOCATION_ALIGNMENT) struct _AFD_BUFFER {
  694. union {
  695. struct {
  696. _AFD_BUFFER_HEADER_; // easy access to individual members
  697. };
  698. AFD_BUFFER_HEADER Header; // access to the header as a whole
  699. };
  700. PIRP Irp; // pointer to the IRP associated w/the buffer
  701. PVOID Buffer; // a pointer to the actual data buffer
  702. #if DBG
  703. LIST_ENTRY DebugListEntry;
  704. PVOID Caller;
  705. PVOID CallersCaller;
  706. #endif
  707. // IRP Irp; // the IRP follows this structure
  708. // MDL Mdl; // the MDL follows the IRP
  709. // UCHAR Address[]; // address of datagram sender
  710. // UCHAR Buffer[BufferLength]; // the actual data buffer is last
  711. } AFD_BUFFER, *PAFD_BUFFER;
  712. //
  713. // Placement of pieces that comprise the AFD_BUFFER.
  714. // We have four pieces: header, IRP, MDL, data buffer
  715. // and use 2 bits to encode each.
  716. // We need to save the first piece so we know where the memory block
  717. // starts when we need to return it to the memory manager.
  718. //
  719. #define AFD_PLACEMENT_HDR 0
  720. #define AFD_PLACEMENT_IRP 1
  721. #define AFD_PLACEMENT_MDL 2
  722. #define AFD_PLACEMENT_BUFFER 3
  723. #define AFD_PLACEMENT_HDR_IRP (AFD_PLACEMENT_HDR|(AFD_PLACEMENT_IRP<<2))
  724. #define AFD_PLACEMENT_HDR_MDL (AFD_PLACEMENT_HDR|(AFD_PLACEMENT_MDL<<2))
  725. #define AFD_PLACEMENT_IRP_MDL (AFD_PLACEMENT_IRP|(AFD_PLACEMENT_MDL<<2))
  726. #define AFD_PLACEMENT_HDR_IRP_MDL (AFD_PLACEMENT_HDR|(AFD_PLACEMENT_IRP<<2)|(AFD_PLACEMENT_MDL<<4))
  727. //
  728. // ALIGN_DOWN_A aligns to given alignment requirement
  729. // (as opposed to the type in the original ALIGN_DOWN macro)
  730. //
  731. #define ALIGN_DOWN_A(length,alignment) \
  732. (((ULONG)(length)) & ~ ((alignment)-1))
  733. //
  734. // ALIGN_DOWN_A for pointers.
  735. //
  736. #define ALIGN_DOWN_A_POINTER(address,alignment) \
  737. ((PVOID)(((ULONG_PTR)(address)) & ~ ((ULONG_PTR)(alignment)-1)))
  738. //
  739. // ALIGN_UP_A aligns to given alignment requirement
  740. // (as opposed to the type in the original ALIGN_UP macro)
  741. //
  742. #define ALIGN_UP_A(length,alignment) \
  743. ((((ULONG)(length)) + (alignment)-1) & ~ ((alignment)-1))
  744. //
  745. // ALIGN_UP_A for pointers.
  746. //
  747. #define ALIGN_UP_A_POINTER(address,alignment) \
  748. ALIGN_DOWN_A_POINTER(((ULONG_PTR)(address) + alignment-1), alignment)
  749. //
  750. // ALIGN_UP_TO_TYPE aligns size to make sure it meets
  751. // the type alignment requirement
  752. //
  753. #define ALIGN_UP_TO_TYPE(length,type) \
  754. ALIGN_UP_A(length,TYPE_ALIGNMENT(type))
  755. //
  756. // ALIGN_UP_TO_TYPE for pointers.
  757. //
  758. #define ALIGN_UP_TO_TYPE_POINTER(address,type) \
  759. ALIGN_UP_A_POINTER(address,TYPE_ALIGNMENT(type))
  760. #if DBG
  761. #define IS_VALID_AFD_BUFFER(b) ( \
  762. ((b)->Placement==AFD_PLACEMENT_HDR) \
  763. ? ((PUCHAR)b<(PUCHAR)(b)->Buffer && (PUCHAR)b<(PUCHAR)(b)->Mdl && (PUCHAR)b<(PUCHAR)(b)->Irp) \
  764. : (((b)->Placement==AFD_PLACEMENT_MDL) \
  765. ? ((PUCHAR)(b)->Mdl<(PUCHAR)(b)->Buffer && (PUCHAR)(b)->Mdl<(PUCHAR)b && (PUCHAR)(b)->Mdl<(PUCHAR)(b)->Irp) \
  766. : ((b->Placement==AFD_PLACEMENT_IRP) \
  767. ? ((PUCHAR)(b)->Irp<(PUCHAR)(b)->Buffer && (PUCHAR)(b)->Irp<(PUCHAR)b && (PUCHAR)(b)->Irp<(PUCHAR)(b)->Mdl) \
  768. : ((PUCHAR)(b)->Buffer<(PUCHAR)(b)->Irp && (PUCHAR)(b)->Buffer<(PUCHAR)b && (PUCHAR)(b)->Buffer<(PUCHAR)(b)->Mdl)) \
  769. ) \
  770. ) \
  771. #endif
  772. //
  773. // Pointer to an IRP cleanup routine. This is used as a parameter to
  774. // AfdCompleteIrpList().
  775. //
  776. typedef
  777. BOOLEAN
  778. (NTAPI * PAFD_IRP_CLEANUP_ROUTINE)(
  779. IN PIRP Irp
  780. );
  781. //
  782. // Debug statistics.
  783. //
  784. typedef struct _AFD_QUOTA_STATS {
  785. LARGE_INTEGER Charged;
  786. LARGE_INTEGER Returned;
  787. } AFD_QUOTA_STATS;
  788. typedef struct _AFD_HANDLE_STATS {
  789. LONG AddrOpened;
  790. LONG AddrClosed;
  791. LONG AddrRef;
  792. LONG AddrDeref;
  793. LONG ConnOpened;
  794. LONG ConnClosed;
  795. LONG ConnRef;
  796. LONG ConnDeref;
  797. LONG FileRef;
  798. LONG FileDeref;
  799. } AFD_HANDLE_STATS;
  800. typedef struct _AFD_QUEUE_STATS {
  801. LONG AfdWorkItemsQueued;
  802. LONG ExWorkItemsQueued;
  803. LONG WorkerEnter;
  804. LONG WorkerLeave;
  805. LONG AfdWorkItemsProcessed;
  806. PETHREAD AfdWorkerThread;
  807. } AFD_QUEUE_STATS;
  808. typedef struct _AFD_CONNECTION_STATS {
  809. LONG ConnectedReferencesAdded;
  810. LONG ConnectedReferencesDeleted;
  811. LONG GracefulDisconnectsInitiated;
  812. LONG GracefulDisconnectsCompleted;
  813. LONG GracefulDisconnectIndications;
  814. LONG AbortiveDisconnectsInitiated;
  815. LONG AbortiveDisconnectsCompleted;
  816. LONG AbortiveDisconnectIndications;
  817. LONG ConnectionIndications;
  818. LONG ConnectionsDropped;
  819. LONG ConnectionsAccepted;
  820. LONG ConnectionsPreaccepted;
  821. LONG ConnectionsReused;
  822. LONG EndpointsReused;
  823. } AFD_CONNECTION_STATS;
  824. //
  825. // Global data. Resouces and lookaside list descriptors
  826. // cannot be statically allocated, as they need to ALWAYS be nonpageable,
  827. // even when the entire driver is paged out.
  828. // Alignment table is variable-size and also cannot be statically allocated.
  829. //
  830. enum {
  831. AFD_LARGE_BUFFER_LIST=0,
  832. AFD_MEDIUM_BUFFER_LIST,
  833. AFD_SMALL_BUFFER_LIST,
  834. AFD_BUFFER_TAG_LIST,
  835. AFD_TP_INFO_LIST,
  836. AFD_REMOTE_ADDR_LIST,
  837. AFD_NUM_LOOKASIDE_LISTS
  838. } AFD_LOOKASIDE_LISTS_INDEX;
  839. typedef struct _AFD_GLOBAL_DATA {
  840. ERESOURCE Resource;
  841. NPAGED_LOOKASIDE_LIST List[AFD_NUM_LOOKASIDE_LISTS];
  842. #define LargeBufferList List[AFD_LARGE_BUFFER_LIST]
  843. #define MediumBufferList List[AFD_MEDIUM_BUFFER_LIST]
  844. #define SmallBufferList List[AFD_SMALL_BUFFER_LIST]
  845. #define BufferTagList List[AFD_BUFFER_TAG_LIST]
  846. #define TpInfoList List[AFD_TP_INFO_LIST]
  847. #define RemoteAddrList List[AFD_REMOTE_ADDR_LIST]
  848. LONG TrimFlags;
  849. KTIMER Timer;
  850. KDPC Dpc;
  851. UCHAR BufferAlignmentTable[ANYSIZE_ARRAY];
  852. } AFD_GLOBAL_DATA, *PAFD_GLOBAL_DATA;
  853. //
  854. // Context structure for misc requests pended in AFD.
  855. //
  856. typedef struct _AFD_REQUEST_CONTEXT AFD_REQUEST_CONTEXT, *PAFD_REQUEST_CONTEXT;
  857. //
  858. // The routine is called after request is removed from endpoint list
  859. // for cleanup purposes
  860. //
  861. typedef BOOLEAN (* PAFD_REQUEST_CLEANUP) (
  862. PAFD_ENDPOINT Endpoint,
  863. PAFD_REQUEST_CONTEXT NotifyCtx
  864. );
  865. //
  866. // This structure has to no more 16 bytes long so we can
  867. // reuse IrpSp->Parameters for it.
  868. //
  869. typedef struct _AFD_REQUEST_CONTEXT {
  870. LIST_ENTRY EndpointListLink; // Link in endpoint list
  871. PAFD_REQUEST_CLEANUP CleanupRoutine; // Routine to call to cancel
  872. PVOID Context; // Request dependent context
  873. // (PIRP)
  874. };
  875. //
  876. // We use list entry fields to synchronize completion with cleanup/cancel
  877. // routine assuming that as long as the entry is in the list
  878. // both Flink and Blink fields cannot be NULL. (using these
  879. // fields for synchronization allows us to cut down on
  880. // cancel spinlock usage)
  881. //
  882. #define AfdEnqueueRequest(Endpoint,Request) \
  883. ExInterlockedInsertTailList(&(Endpoint)->RequestList, \
  884. &(Request)->EndpointListLink, \
  885. &(Endpoint)->SpinLock)
  886. #define AfdIsRequestInQueue(Request) \
  887. ((Request)->EndpointListLink.Flink!=NULL)
  888. #define AfdMarkRequestCompleted(Request) \
  889. (Request)->EndpointListLink.Blink = NULL
  890. #define AfdIsRequestCompleted(Request) \
  891. ((Request)->EndpointListLink.Blink==NULL)
  892. typedef struct _ROUTING_NOTIFY {
  893. LIST_ENTRY NotifyListLink;
  894. PIRP NotifyIrp;
  895. PVOID NotifyContext;
  896. } ROUTING_NOTIFY, *PROUTING_NOTIFY;
  897. typedef struct _AFD_ADDRESS_ENTRY {
  898. LIST_ENTRY AddressListLink;
  899. UNICODE_STRING DeviceName;
  900. TA_ADDRESS Address;
  901. } AFD_ADDRESS_ENTRY, *PAFD_ADDRESS_ENTRY;
  902. typedef struct _AFD_ADDRESS_CHANGE {
  903. LIST_ENTRY ChangeListLink;
  904. union {
  905. PAFD_ENDPOINT Endpoint;
  906. PIRP Irp;
  907. };
  908. USHORT AddressType;
  909. BOOLEAN NonBlocking;
  910. } AFD_ADDRESS_CHANGE, *PAFD_ADDRESS_CHANGE;
  911. typedef
  912. NTSTATUS
  913. (* PAFD_IMMEDIATE_CALL) (
  914. IN PFILE_OBJECT FileObject,
  915. IN ULONG IoctlCode,
  916. IN KPROCESSOR_MODE RequestorMode,
  917. IN PVOID InputBuffer,
  918. IN ULONG InputBufferLength,
  919. IN PVOID OutputBuffer,
  920. IN ULONG OutputBufferLength,
  921. OUT PUINT_PTR Information
  922. );
  923. typedef
  924. NTSTATUS
  925. (FASTCALL * PAFD_IRP_CALL) (
  926. IN PIRP Irp,
  927. IN PIO_STACK_LOCATION IrpSp
  928. );
  929. typedef struct _AFD_TRANSMIT_PACKETS_ELEMENT {
  930. #define TP_MDL 0x80000000
  931. #define TP_COMBINE 0x40000000
  932. ULONG Flags;
  933. ULONG Length;
  934. union {
  935. struct {
  936. LARGE_INTEGER FileOffset;
  937. PFILE_OBJECT FileObject;
  938. };
  939. struct {
  940. PVOID Buffer;
  941. PMDL Mdl;
  942. };
  943. };
  944. } AFD_TRANSMIT_PACKETS_ELEMENT, *PAFD_TRANSMIT_PACKETS_ELEMENT;
  945. //
  946. // Structure to keep track of transmit packets request
  947. //
  948. typedef struct _AFD_TPACKETS_INFO_INTERNAL AFD_TPACKETS_INFO_INTERNAL, *PAFD_TPACKETS_INFO_INTERNAL;
  949. struct _AFD_TPACKETS_INFO_INTERNAL {
  950. union {
  951. SINGLE_LIST_ENTRY SListEntry; // Link on S-List
  952. PFILE_OBJECT TdiFileObject; // Tdi objects (sending to)
  953. };
  954. PDEVICE_OBJECT TdiDeviceObject;
  955. PMDL HeadMdl; // Ready to send chain
  956. PMDL *TailMdl;
  957. PAFD_BUFFER_HEADER HeadPd; // Corresponding packet chain
  958. PAFD_BUFFER_HEADER *TailPd;
  959. PIRP ReadIrp; // Irp used for file reads.
  960. PAFD_TRANSMIT_PACKETS_ELEMENT
  961. ElementArray; // Packet array
  962. ULONG NextElement; // Next element to send.
  963. ULONG ElementCount; // Total number of elements in the array
  964. ULONG RemainingPkts; // Number of packets remaining to be sent.
  965. USHORT NumSendIrps; // Actual number of send IRPs
  966. BOOLEAN ArrayAllocated; // Element array is allocated (not built-in).
  967. BOOLEAN PdNeedsPps; // Packet descriptor being built needs post-
  968. // processing after completion.
  969. ULONG PdLength; // Currently accumulated send length
  970. ULONG SendPacketLength; // Maximum length of the packet
  971. // APC/Work item for worker scheduling
  972. union {
  973. KAPC Apc;
  974. WORK_QUEUE_ITEM WorkItem;
  975. };
  976. #if REFERENCE_DEBUG
  977. LONG CurrentReferenceSlot;
  978. AFD_REFERENCE_DEBUG ReferenceDebug[MAX_REFERENCE];
  979. #endif
  980. #if AFD_PERF_DBG
  981. LONG WorkersExecuted;
  982. #endif
  983. #define AFD_TP_MIN_SEND_IRPS 2 // Need at least two to keep transport busy
  984. #define AFD_TP_MAX_SEND_IRPS 8 // Max is based on current flags layout below
  985. PIRP SendIrp[AFD_TP_MAX_SEND_IRPS];
  986. // ElementArray
  987. // SendIrp1
  988. // SendIrp2
  989. };
  990. //
  991. // Structure maintained in driver context of the TPackets IRP
  992. //
  993. typedef struct _AFD_TPACKETS_IRP_CTX {
  994. LIST_ENTRY EndpQueueEntry;
  995. volatile LONG ReferenceCount;
  996. volatile LONG StateFlags;
  997. } AFD_TPACKETS_IRP_CTX, *PAFD_TPACKETS_IRP_CTX;
  998. #define AFD_TP_ABORT_PENDING 0x00000001 // Request is being aborted
  999. #define AFD_TP_WORKER_SCHEDULED 0x00000010 // Worker is scheduled or active
  1000. #ifdef TDI_SERVICE_SEND_AND_DISCONNECT
  1001. #define AFD_TP_SEND_AND_DISCONNECT 0x00000100 // S&D is enabled
  1002. #endif // TDI_SERVICE_SEND_AND_DISCONNECT
  1003. #define AFD_TP_READ_CALL_PENDING 0x00001000 // MDL_READ call is imminent or in progress on ReadIrp
  1004. #define AFD_TP_READ_COMP_PENDING 0x00002000 // Read completion is expected on ReadIrp
  1005. #define AFD_TP_READ_BUSY (AFD_TP_READ_CALL_PENDING|AFD_TP_READ_COMP_PENDING)
  1006. // TDI_SEND call is imminent or in progress on send Irp i
  1007. #define AFD_TP_SEND_CALL_PENDING(i) (0x00010000<<((i)*2))
  1008. // Send completion is expected on send Irp i
  1009. #define AFD_TP_SEND_COMP_PENDING(i) (0x00020000<<((i)*2))
  1010. #define AFD_TP_SEND_BUSY(i) (0x00030000<<((i)*2))
  1011. #define AFD_TP_SEND_MASK (0x55550000)
  1012. #define AFD_GET_TPIC(_i) ((PAFD_TPACKETS_IRP_CTX)&(_i)->Tail.Overlay.DriverContext)
  1013. //
  1014. // This macro verifies that the 32-bit mapping of the structures in 64-bit
  1015. // compiler match original 32-bit structures. Note, that the verification is
  1016. // performed when this file is compiled by 32 bit compiler, but
  1017. // the actual structures are used by 64 bit code.
  1018. //
  1019. #ifdef _WIN64
  1020. #define AFD_CHECK32on64(_str,_fld)
  1021. #define AFD_MAX_NATURAL_ALIGNMENT32 sizeof(ULONG)
  1022. #else
  1023. #define AFD_CHECK32on64(_str,_fld) \
  1024. C_ASSERT (FIELD_OFFSET (_str,_fld)==FIELD_OFFSET(_str##32,_fld))
  1025. #endif
  1026. //
  1027. // Structures for mapping IOCTL parameters for 32-bit clients on 64-bit
  1028. // platform.
  1029. //
  1030. typedef UNALIGNED struct _WSABUF32 {
  1031. ULONG len;
  1032. CHAR * POINTER_32 buf;
  1033. } WSABUF32, *LPWSABUF32;
  1034. AFD_CHECK32on64(WSABUF,len);
  1035. AFD_CHECK32on64(WSABUF,buf);
  1036. typedef UNALIGNED struct _QualityOfService32 {
  1037. FLOWSPEC SendingFlowspec; /* the flow spec for data sending */
  1038. FLOWSPEC ReceivingFlowspec; /* the flow spec for data receiving */
  1039. WSABUF32 ProviderSpecific; /* additional provider specific stuff */
  1040. } QOS32, * LPQOS32;
  1041. AFD_CHECK32on64(QOS,SendingFlowspec);
  1042. AFD_CHECK32on64(QOS,ReceivingFlowspec);
  1043. AFD_CHECK32on64(QOS,ProviderSpecific);
  1044. typedef UNALIGNED struct _AFD_ACCEPT_INFO32 {
  1045. BOOLEAN SanActive;
  1046. LONG Sequence;
  1047. VOID * POINTER_32 AcceptHandle;
  1048. } AFD_ACCEPT_INFO32, *PAFD_ACCEPT_INFO32;
  1049. AFD_CHECK32on64(AFD_ACCEPT_INFO,SanActive);
  1050. AFD_CHECK32on64(AFD_ACCEPT_INFO,Sequence);
  1051. AFD_CHECK32on64(AFD_ACCEPT_INFO,AcceptHandle);
  1052. typedef UNALIGNED struct _AFD_SUPER_ACCEPT_INFO32 {
  1053. BOOLEAN SanActive;
  1054. BOOLEAN FixAddressAlignment;
  1055. VOID * POINTER_32 AcceptHandle;
  1056. ULONG ReceiveDataLength;
  1057. ULONG LocalAddressLength;
  1058. ULONG RemoteAddressLength;
  1059. } AFD_SUPER_ACCEPT_INFO32, *PAFD_SUPER_ACCEPT_INFO32;
  1060. AFD_CHECK32on64(AFD_SUPER_ACCEPT_INFO,SanActive);
  1061. AFD_CHECK32on64(AFD_SUPER_ACCEPT_INFO,FixAddressAlignment);
  1062. AFD_CHECK32on64(AFD_SUPER_ACCEPT_INFO,AcceptHandle);
  1063. AFD_CHECK32on64(AFD_SUPER_ACCEPT_INFO,ReceiveDataLength);
  1064. AFD_CHECK32on64(AFD_SUPER_ACCEPT_INFO,LocalAddressLength);
  1065. AFD_CHECK32on64(AFD_SUPER_ACCEPT_INFO,RemoteAddressLength);
  1066. typedef UNALIGNED struct _AFD_POLL_HANDLE_INFO32 {
  1067. VOID * POINTER_32 Handle;
  1068. ULONG PollEvents;
  1069. NTSTATUS Status;
  1070. } AFD_POLL_HANDLE_INFO32, *PAFD_POLL_HANDLE_INFO32;
  1071. AFD_CHECK32on64(AFD_POLL_HANDLE_INFO,Handle);
  1072. AFD_CHECK32on64(AFD_POLL_HANDLE_INFO,PollEvents);
  1073. AFD_CHECK32on64(AFD_POLL_HANDLE_INFO,Status);
  1074. typedef UNALIGNED struct _AFD_POLL_INFO32 {
  1075. LARGE_INTEGER Timeout;
  1076. ULONG NumberOfHandles;
  1077. BOOLEAN Unique;
  1078. AFD_POLL_HANDLE_INFO32 Handles[1];
  1079. } AFD_POLL_INFO32, *PAFD_POLL_INFO32;
  1080. AFD_CHECK32on64(AFD_POLL_INFO,Timeout);
  1081. AFD_CHECK32on64(AFD_POLL_INFO,NumberOfHandles);
  1082. AFD_CHECK32on64(AFD_POLL_INFO,Unique);
  1083. AFD_CHECK32on64(AFD_POLL_INFO,Handles);
  1084. typedef UNALIGNED struct _AFD_HANDLE_INFO632 {
  1085. VOID * POINTER_32 TdiAddressHandle;
  1086. VOID * POINTER_32 TdiConnectionHandle;
  1087. } AFD_HANDLE_INFO32, *PAFD_HANDLE_INFO32;
  1088. AFD_CHECK32on64(AFD_HANDLE_INFO,TdiAddressHandle);
  1089. AFD_CHECK32on64(AFD_HANDLE_INFO,TdiConnectionHandle);
  1090. typedef UNALIGNED struct _AFD_TRANSMIT_FILE_INFO32 {
  1091. LARGE_INTEGER Offset;
  1092. LARGE_INTEGER WriteLength;
  1093. ULONG SendPacketLength;
  1094. VOID * POINTER_32 FileHandle;
  1095. VOID * POINTER_32 Head;
  1096. ULONG HeadLength;
  1097. VOID * POINTER_32 Tail;
  1098. ULONG TailLength;
  1099. ULONG Flags;
  1100. } AFD_TRANSMIT_FILE_INFO32, *PAFD_TRANSMIT_FILE_INFO32;
  1101. AFD_CHECK32on64(AFD_TRANSMIT_FILE_INFO,Offset);
  1102. AFD_CHECK32on64(AFD_TRANSMIT_FILE_INFO,WriteLength);
  1103. AFD_CHECK32on64(AFD_TRANSMIT_FILE_INFO,SendPacketLength);
  1104. AFD_CHECK32on64(AFD_TRANSMIT_FILE_INFO,FileHandle);
  1105. AFD_CHECK32on64(AFD_TRANSMIT_FILE_INFO,Head);
  1106. AFD_CHECK32on64(AFD_TRANSMIT_FILE_INFO,HeadLength);
  1107. AFD_CHECK32on64(AFD_TRANSMIT_FILE_INFO,Tail);
  1108. AFD_CHECK32on64(AFD_TRANSMIT_FILE_INFO,TailLength);
  1109. AFD_CHECK32on64(AFD_TRANSMIT_FILE_INFO,Flags);
  1110. typedef UNALIGNED struct _AFD_SEND_INFO32 {
  1111. WSABUF32 * POINTER_32 BufferArray;
  1112. ULONG BufferCount;
  1113. ULONG AfdFlags;
  1114. ULONG TdiFlags;
  1115. } AFD_SEND_INFO32, *PAFD_SEND_INFO32;
  1116. AFD_CHECK32on64(AFD_SEND_INFO,BufferArray);
  1117. AFD_CHECK32on64(AFD_SEND_INFO,BufferCount);
  1118. AFD_CHECK32on64(AFD_SEND_INFO,AfdFlags);
  1119. AFD_CHECK32on64(AFD_SEND_INFO,TdiFlags);
  1120. typedef UNALIGNED struct _TDI_REQUEST32 {
  1121. union {
  1122. VOID * POINTER_32 AddressHandle;
  1123. VOID * POINTER_32 ConnectionContext;
  1124. VOID * POINTER_32 ControlChannel;
  1125. } Handle;
  1126. VOID * POINTER_32 RequestNotifyObject;
  1127. VOID * POINTER_32 RequestContext;
  1128. TDI_STATUS TdiStatus;
  1129. } TDI_REQUEST32, *PTDI_REQUEST32;
  1130. AFD_CHECK32on64(TDI_REQUEST,Handle);
  1131. AFD_CHECK32on64(TDI_REQUEST,RequestNotifyObject);
  1132. AFD_CHECK32on64(TDI_REQUEST,RequestContext);
  1133. AFD_CHECK32on64(TDI_REQUEST,TdiStatus);
  1134. typedef UNALIGNED struct _TDI_CONNECTION_INFORMATION32 {
  1135. LONG UserDataLength; // length of user data buffer
  1136. VOID * POINTER_32 UserData; // pointer to user data buffer
  1137. LONG OptionsLength; // length of follwoing buffer
  1138. VOID * POINTER_32 Options; // pointer to buffer containing options
  1139. LONG RemoteAddressLength; // length of following buffer
  1140. VOID * POINTER_32 RemoteAddress;// buffer containing the remote address
  1141. } TDI_CONNECTION_INFORMATION32, *PTDI_CONNECTION_INFORMATION32;
  1142. AFD_CHECK32on64(TDI_CONNECTION_INFORMATION,UserDataLength);
  1143. AFD_CHECK32on64(TDI_CONNECTION_INFORMATION,UserData);
  1144. AFD_CHECK32on64(TDI_CONNECTION_INFORMATION,OptionsLength);
  1145. AFD_CHECK32on64(TDI_CONNECTION_INFORMATION,Options);
  1146. AFD_CHECK32on64(TDI_CONNECTION_INFORMATION,RemoteAddressLength);
  1147. AFD_CHECK32on64(TDI_CONNECTION_INFORMATION,RemoteAddress);
  1148. typedef UNALIGNED struct _TDI_REQUEST_SEND_DATAGRAM32 {
  1149. TDI_REQUEST32 Request;
  1150. TDI_CONNECTION_INFORMATION32 * POINTER_32 SendDatagramInformation;
  1151. } TDI_REQUEST_SEND_DATAGRAM32, *PTDI_REQUEST_SEND_DATAGRAM32;
  1152. AFD_CHECK32on64(TDI_REQUEST_SEND_DATAGRAM,Request);
  1153. AFD_CHECK32on64(TDI_REQUEST_SEND_DATAGRAM,SendDatagramInformation);
  1154. typedef UNALIGNED struct _AFD_SEND_DATAGRAM_INFO32 {
  1155. WSABUF32 * POINTER_32 BufferArray;
  1156. ULONG BufferCount;
  1157. ULONG AfdFlags;
  1158. TDI_REQUEST_SEND_DATAGRAM32 TdiRequest;
  1159. TDI_CONNECTION_INFORMATION32 TdiConnInfo;
  1160. } AFD_SEND_DATAGRAM_INFO32, *PAFD_SEND_DATAGRAM_INFO32;
  1161. AFD_CHECK32on64(AFD_SEND_DATAGRAM_INFO,BufferArray);
  1162. AFD_CHECK32on64(AFD_SEND_DATAGRAM_INFO,BufferCount);
  1163. AFD_CHECK32on64(AFD_SEND_DATAGRAM_INFO,AfdFlags);
  1164. AFD_CHECK32on64(AFD_SEND_DATAGRAM_INFO,TdiRequest);
  1165. AFD_CHECK32on64(AFD_SEND_DATAGRAM_INFO,TdiConnInfo);
  1166. typedef UNALIGNED struct _AFD_RECV_INFO32 {
  1167. WSABUF32 * POINTER_32 BufferArray;
  1168. ULONG BufferCount;
  1169. ULONG AfdFlags;
  1170. ULONG TdiFlags;
  1171. } AFD_RECV_INFO32, *PAFD_RECV_INFO32;
  1172. AFD_CHECK32on64(AFD_RECV_INFO,BufferArray);
  1173. AFD_CHECK32on64(AFD_RECV_INFO,BufferCount);
  1174. AFD_CHECK32on64(AFD_RECV_INFO,AfdFlags);
  1175. AFD_CHECK32on64(AFD_RECV_INFO,TdiFlags);
  1176. typedef UNALIGNED struct _AFD_RECV_DATAGRAM_INFO32 {
  1177. WSABUF32 * POINTER_32 BufferArray;
  1178. ULONG BufferCount;
  1179. ULONG AfdFlags;
  1180. ULONG TdiFlags;
  1181. VOID * POINTER_32 Address;
  1182. ULONG * POINTER_32 AddressLength;
  1183. } AFD_RECV_DATAGRAM_INFO32, *PAFD_RECV_DATAGRAM_INFO32;
  1184. AFD_CHECK32on64(AFD_RECV_DATAGRAM_INFO,BufferArray);
  1185. AFD_CHECK32on64(AFD_RECV_DATAGRAM_INFO,BufferCount);
  1186. AFD_CHECK32on64(AFD_RECV_DATAGRAM_INFO,AfdFlags);
  1187. AFD_CHECK32on64(AFD_RECV_DATAGRAM_INFO,TdiFlags);
  1188. AFD_CHECK32on64(AFD_RECV_DATAGRAM_INFO,Address);
  1189. AFD_CHECK32on64(AFD_RECV_DATAGRAM_INFO,AddressLength);
  1190. typedef UNALIGNED struct _AFD_CONNECT_JOIN_INFO32 {
  1191. BOOLEAN SanActive;
  1192. VOID * POINTER_32 RootEndpoint; // Root endpoint for joins
  1193. VOID * POINTER_32 ConnectEndpoint;// Connect/leaf endpoint for async connects
  1194. TRANSPORT_ADDRESS RemoteAddress; // Remote address
  1195. } AFD_CONNECT_JOIN_INFO32, *PAFD_CONNECT_JOIN_INFO32;
  1196. AFD_CHECK32on64(AFD_CONNECT_JOIN_INFO,SanActive);
  1197. AFD_CHECK32on64(AFD_CONNECT_JOIN_INFO,RootEndpoint);
  1198. AFD_CHECK32on64(AFD_CONNECT_JOIN_INFO,ConnectEndpoint);
  1199. AFD_CHECK32on64(AFD_CONNECT_JOIN_INFO,RemoteAddress);
  1200. typedef UNALIGNED struct _AFD_EVENT_SELECT_INFO32 {
  1201. VOID * POINTER_32 Event;
  1202. ULONG PollEvents;
  1203. } AFD_EVENT_SELECT_INFO32, *PAFD_EVENT_SELECT_INFO32;
  1204. AFD_CHECK32on64(AFD_EVENT_SELECT_INFO,Event);
  1205. AFD_CHECK32on64(AFD_EVENT_SELECT_INFO,PollEvents);
  1206. typedef UNALIGNED struct _AFD_QOS_INFO32 {
  1207. QOS32 Qos;
  1208. BOOLEAN GroupQos;
  1209. } AFD_QOS_INFO32, *PAFD_QOS_INFO32;
  1210. AFD_CHECK32on64(AFD_QOS_INFO,Qos);
  1211. AFD_CHECK32on64(AFD_QOS_INFO,GroupQos);
  1212. typedef UNALIGNED struct _AFD_TRANSPORT_IOCTL_INFO32 {
  1213. VOID * POINTER_32 Handle;
  1214. VOID * POINTER_32 InputBuffer;
  1215. ULONG InputBufferLength;
  1216. ULONG IoControlCode;
  1217. ULONG AfdFlags;
  1218. ULONG PollEvent;
  1219. } AFD_TRANSPORT_IOCTL_INFO32, *PAFD_TRANSPORT_IOCTL_INFO32;
  1220. AFD_CHECK32on64(AFD_TRANSPORT_IOCTL_INFO,Handle);
  1221. AFD_CHECK32on64(AFD_TRANSPORT_IOCTL_INFO,InputBuffer);
  1222. AFD_CHECK32on64(AFD_TRANSPORT_IOCTL_INFO,InputBufferLength);
  1223. AFD_CHECK32on64(AFD_TRANSPORT_IOCTL_INFO,IoControlCode);
  1224. AFD_CHECK32on64(AFD_TRANSPORT_IOCTL_INFO,AfdFlags);
  1225. AFD_CHECK32on64(AFD_TRANSPORT_IOCTL_INFO,PollEvent);
  1226. typedef UNALIGNED struct _TRANSMIT_PACKETS_ELEMENT32 {
  1227. ULONG dwElFlags;
  1228. #define TP_MEMORY 1
  1229. #define TP_FILE 2
  1230. #define TP_EOP 4
  1231. ULONG cLength;
  1232. union {
  1233. struct {
  1234. LARGE_INTEGER nFileOffset;
  1235. VOID * POINTER_32 hFile;
  1236. };
  1237. VOID * POINTER_32 pBuffer;
  1238. };
  1239. } TRANSMIT_PACKETS_ELEMENT32, *LPTRANSMIT_PACKETS_ELEMENT32;
  1240. AFD_CHECK32on64(TRANSMIT_PACKETS_ELEMENT,dwElFlags);
  1241. AFD_CHECK32on64(TRANSMIT_PACKETS_ELEMENT,nFileOffset);
  1242. AFD_CHECK32on64(TRANSMIT_PACKETS_ELEMENT,hFile);
  1243. AFD_CHECK32on64(TRANSMIT_PACKETS_ELEMENT,pBuffer);
  1244. typedef UNALIGNED struct _AFD_TPACKETS_INFO32 {
  1245. TRANSMIT_PACKETS_ELEMENT * POINTER_32 ElementArray;
  1246. ULONG ElementCount;
  1247. ULONG SendSize;
  1248. ULONG Flags;
  1249. } AFD_TPACKETS_INFO32, *PAFD_TPACKETS_INFO32;
  1250. AFD_CHECK32on64(AFD_TPACKETS_INFO,ElementArray);
  1251. AFD_CHECK32on64(AFD_TPACKETS_INFO,ElementCount);
  1252. AFD_CHECK32on64(AFD_TPACKETS_INFO,SendSize);
  1253. AFD_CHECK32on64(AFD_TPACKETS_INFO,Flags);
  1254. typedef UNALIGNED struct _AFD_RECV_MESSAGE_INFO32 {
  1255. AFD_RECV_DATAGRAM_INFO32 dgi;
  1256. VOID * POINTER_32 ControlBuffer;
  1257. ULONG * POINTER_32 ControlLength;
  1258. ULONG * POINTER_32 MsgFlags;
  1259. } AFD_RECV_MESSAGE_INFO32, *PAFD_RECV_MESSAGE_INFO32;
  1260. AFD_CHECK32on64(AFD_RECV_MESSAGE_INFO,dgi);
  1261. AFD_CHECK32on64(AFD_RECV_MESSAGE_INFO,MsgFlags);
  1262. AFD_CHECK32on64(AFD_RECV_MESSAGE_INFO,ControlBuffer);
  1263. AFD_CHECK32on64(AFD_RECV_MESSAGE_INFO,ControlLength);
  1264. typedef UNALIGNED struct _AFD_SWITCH_OPEN_PACKET32 {
  1265. VOID * POINTER_32 CompletionPort;
  1266. VOID * POINTER_32 CompletionEvent;
  1267. } AFD_SWITCH_OPEN_PACKET32, *PAFD_SWITCH_OPEN_PACKET32;
  1268. AFD_CHECK32on64(AFD_SWITCH_OPEN_PACKET,CompletionPort);
  1269. AFD_CHECK32on64(AFD_SWITCH_OPEN_PACKET,CompletionEvent);
  1270. typedef UNALIGNED struct _AFD_SWITCH_CONTEXT_INFO32 {
  1271. VOID * POINTER_32 SocketHandle;
  1272. AFD_SWITCH_CONTEXT * POINTER_32 SwitchContext;
  1273. } AFD_SWITCH_CONTEXT_INFO32, *PAFD_SWITCH_CONTEXT_INFO32;
  1274. AFD_CHECK32on64(AFD_SWITCH_CONTEXT_INFO,SocketHandle);
  1275. AFD_CHECK32on64(AFD_SWITCH_CONTEXT_INFO,SwitchContext);
  1276. typedef UNALIGNED struct _AFD_SWITCH_CONNECT_INFO32 {
  1277. VOID * POINTER_32 ListenHandle;
  1278. AFD_SWITCH_CONTEXT * POINTER_32 SwitchContext;
  1279. TRANSPORT_ADDRESS RemoteAddress;
  1280. } AFD_SWITCH_CONNECT_INFO32, *PAFD_SWITCH_CONNECT_INFO32;
  1281. AFD_CHECK32on64(AFD_SWITCH_CONNECT_INFO,ListenHandle);
  1282. AFD_CHECK32on64(AFD_SWITCH_CONNECT_INFO,SwitchContext);
  1283. AFD_CHECK32on64(AFD_SWITCH_CONNECT_INFO,RemoteAddress);
  1284. typedef UNALIGNED struct _AFD_SWITCH_ACCEPT_INFO32 {
  1285. VOID * POINTER_32 AcceptHandle;
  1286. ULONG ReceiveLength;
  1287. } AFD_SWITCH_ACCEPT_INFO32, *PAFD_SWITCH_ACCEPT_INFO32;
  1288. AFD_CHECK32on64(AFD_SWITCH_ACCEPT_INFO,AcceptHandle);
  1289. AFD_CHECK32on64(AFD_SWITCH_ACCEPT_INFO,ReceiveLength);
  1290. typedef UNALIGNED struct _AFD_SWITCH_EVENT_INFO32 {
  1291. VOID * POINTER_32 SocketHandle;
  1292. AFD_SWITCH_CONTEXT * POINTER_32 SwitchContext;
  1293. ULONG EventBit;
  1294. NTSTATUS Status;
  1295. } AFD_SWITCH_EVENT_INFO32, *PAFD_SWITCH_EVENT_INFO32;
  1296. AFD_CHECK32on64(AFD_SWITCH_EVENT_INFO,SocketHandle);
  1297. AFD_CHECK32on64(AFD_SWITCH_EVENT_INFO,SwitchContext);
  1298. AFD_CHECK32on64(AFD_SWITCH_EVENT_INFO,EventBit);
  1299. AFD_CHECK32on64(AFD_SWITCH_EVENT_INFO,Status);
  1300. typedef UNALIGNED struct _AFD_SWITCH_REQUEST_INFO32 {
  1301. VOID * POINTER_32 SocketHandle;
  1302. AFD_SWITCH_CONTEXT * POINTER_32 SwitchContext;
  1303. VOID * POINTER_32 RequestContext;
  1304. NTSTATUS RequestStatus;
  1305. ULONG DataOffset;
  1306. } AFD_SWITCH_REQUEST_INFO32, *PAFD_SWITCH_REQUEST_INFO32;
  1307. AFD_CHECK32on64(AFD_SWITCH_REQUEST_INFO,SocketHandle);
  1308. AFD_CHECK32on64(AFD_SWITCH_REQUEST_INFO,SwitchContext);
  1309. AFD_CHECK32on64(AFD_SWITCH_REQUEST_INFO,RequestContext);
  1310. AFD_CHECK32on64(AFD_SWITCH_REQUEST_INFO,RequestStatus);
  1311. AFD_CHECK32on64(AFD_SWITCH_REQUEST_INFO,DataOffset);
  1312. typedef UNALIGNED struct _AFD_SWITCH_ACQUIRE_CTX_INFO32 {
  1313. VOID * POINTER_32 SocketHandle;
  1314. AFD_SWITCH_CONTEXT * POINTER_32 SwitchContext;
  1315. VOID * POINTER_32 SocketCtxBuf;
  1316. ULONG SocketCtxBufSize;
  1317. } AFD_SWITCH_ACQUIRE_CTX_INFO32, *PAFD_SWITCH_ACQUIRE_CTX_INFO32;
  1318. AFD_CHECK32on64(AFD_SWITCH_ACQUIRE_CTX_INFO,SocketHandle);
  1319. AFD_CHECK32on64(AFD_SWITCH_ACQUIRE_CTX_INFO,SwitchContext);
  1320. AFD_CHECK32on64(AFD_SWITCH_ACQUIRE_CTX_INFO,SocketCtxBuf);
  1321. AFD_CHECK32on64(AFD_SWITCH_ACQUIRE_CTX_INFO,SocketCtxBufSize);
  1322. typedef UNALIGNED struct _AFD_SWITCH_TRANSFER_CTX_INFO32 {
  1323. VOID * POINTER_32 SocketHandle;
  1324. AFD_SWITCH_CONTEXT * POINTER_32 SwitchContext;
  1325. VOID * POINTER_32 RequestContext;
  1326. VOID * POINTER_32 SocketCtxBuf;
  1327. ULONG SocketCtxBufSize;
  1328. WSABUF * POINTER_32 RcvBufferArray;
  1329. ULONG RcvBufferCount;
  1330. NTSTATUS Status;
  1331. } AFD_SWITCH_TRANSFER_CTX_INFO32, *PAFD_SWITCH_TRANSFER_CTX_INFO32;
  1332. AFD_CHECK32on64(AFD_SWITCH_TRANSFER_CTX_INFO,SocketHandle);
  1333. AFD_CHECK32on64(AFD_SWITCH_TRANSFER_CTX_INFO,SwitchContext);
  1334. AFD_CHECK32on64(AFD_SWITCH_TRANSFER_CTX_INFO,RequestContext);
  1335. AFD_CHECK32on64(AFD_SWITCH_TRANSFER_CTX_INFO,SocketCtxBuf);
  1336. AFD_CHECK32on64(AFD_SWITCH_TRANSFER_CTX_INFO,SocketCtxBufSize);
  1337. AFD_CHECK32on64(AFD_SWITCH_TRANSFER_CTX_INFO,RcvBufferArray);
  1338. AFD_CHECK32on64(AFD_SWITCH_TRANSFER_CTX_INFO,RcvBufferCount);
  1339. AFD_CHECK32on64(AFD_SWITCH_TRANSFER_CTX_INFO,Status);
  1340. typedef UNALIGNED struct _AFD_PARTIAL_DISCONNECT_INFO32 {
  1341. ULONG DisconnectMode;
  1342. LARGE_INTEGER Timeout;
  1343. } AFD_PARTIAL_DISCONNECT_INFO32, *PAFD_PARTIAL_DISCONNECT_INFO32;
  1344. AFD_CHECK32on64(AFD_PARTIAL_DISCONNECT_INFO,DisconnectMode);
  1345. AFD_CHECK32on64(AFD_PARTIAL_DISCONNECT_INFO,Timeout);
  1346. typedef UNALIGNED struct _AFD_SUPER_DISCONNECT_INFO32 {
  1347. ULONG Flags;
  1348. } AFD_SUPER_DISCONNECT_INFO32, *PAFD_SUPER_DISCONNECT_INFO32;
  1349. AFD_CHECK32on64(AFD_SUPER_DISCONNECT_INFO,Flags);
  1350. typedef UNALIGNED struct _AFD_INFORMATION32 {
  1351. ULONG InformationType;
  1352. union {
  1353. BOOLEAN Boolean;
  1354. ULONG Ulong;
  1355. LARGE_INTEGER LargeInteger;
  1356. } Information;
  1357. } AFD_INFORMATION32, *PAFD_INFORMATION32;
  1358. AFD_CHECK32on64(AFD_INFORMATION,InformationType);
  1359. AFD_CHECK32on64(AFD_INFORMATION,Information);
  1360. AFD_CHECK32on64(AFD_INFORMATION,Information.Boolean);
  1361. AFD_CHECK32on64(AFD_INFORMATION,Information.Ulong);
  1362. AFD_CHECK32on64(AFD_INFORMATION,Information.LargeInteger);
  1363. typedef UNALIGNED struct _TDI_CMSGHDR32 {
  1364. ULONG cmsg_len;
  1365. LONG cmsg_level;
  1366. LONG cmsg_type;
  1367. /* followed by UCHAR cmsg_data[] */
  1368. } TDI_CMSGHDR32, *PTDI_CMSGHDR32;
  1369. AFD_CHECK32on64(TDI_CMSGHDR,cmsg_len);
  1370. AFD_CHECK32on64(TDI_CMSGHDR,cmsg_level);
  1371. AFD_CHECK32on64(TDI_CMSGHDR,cmsg_type);
  1372. #ifdef _WIN64
  1373. #define TDI_CMSGHDR_ALIGN32(length) \
  1374. ( ((length) + TYPE_ALIGNMENT(TDI_CMSGHDR32)-1) &\
  1375. (~(TYPE_ALIGNMENT(TDI_CMSGHDR32)-1)) ) \
  1376. #define TDI_CMSGDATA_ALIGN32(length) \
  1377. ( ((length) + AFD_MAX_NATURAL_ALIGNMENT32-1) & \
  1378. (~(AFD_MAX_NATURAL_ALIGNMENT32-1)) )
  1379. #endif //_WIN64
  1380. #endif // ndef _AFDSTR_