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.

195 lines
4.2 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. Winsockp.h
  5. Abstract:
  6. Private header file for WOW winsock support.
  7. Author:
  8. David Treadwell (davidtr) 02-Oct-1992
  9. Revision History:
  10. --*/
  11. #include "wow32.h"
  12. #include <winsock.h>
  13. #include <wowwsock.h>
  14. #include "wcall16.h"
  15. #include "wsocktbl.h"
  16. typedef struct _WINSOCK_THREAD_DATA {
  17. VPVOID vIpAddress;
  18. VPHOSTENT16 vHostent;
  19. VPSERVENT16 vServent;
  20. VPPROTOENT16 vProtoent;
  21. VPPROC vBlockingHook;
  22. DWORD ThreadSerialNumber;
  23. DWORD ThreadStartupCount;
  24. WORD ThreadVersion;
  25. } WINSOCK_THREAD_DATA, *PWINSOCK_THREAD_DATA;
  26. extern DWORD WWS32TlsSlot;
  27. extern RTL_CRITICAL_SECTION WWS32CriticalSection;
  28. extern LIST_ENTRY WWS32AsyncContextBlockListHead;
  29. extern WORD WWS32AsyncTaskHandleCounter;
  30. extern LIST_ENTRY WWS32SocketHandleListHead;
  31. extern WORD WWS32SocketHandleCounter;
  32. extern BOOL WWS32SocketHandleCounterWrapped;
  33. extern DWORD WWS32ThreadSerialNumberCounter;
  34. #define WWS32IpAddress \
  35. ( ((PWINSOCK_THREAD_DATA)(TlsGetValue( WWS32TlsSlot )))->IpAddress )
  36. #define WWS32vIpAddress \
  37. ( ((PWINSOCK_THREAD_DATA)(TlsGetValue( WWS32TlsSlot )))->vIpAddress )
  38. #define WWS32vHostent \
  39. ( ((PWINSOCK_THREAD_DATA)(TlsGetValue( WWS32TlsSlot )))->vHostent )
  40. #define WWS32vServent \
  41. ( ((PWINSOCK_THREAD_DATA)(TlsGetValue( WWS32TlsSlot )))->vServent )
  42. #define WWS32vProtoent \
  43. ( ((PWINSOCK_THREAD_DATA)(TlsGetValue( WWS32TlsSlot )))->vProtoent )
  44. #define WWS32vBlockingHook \
  45. ( ((PWINSOCK_THREAD_DATA)(TlsGetValue( WWS32TlsSlot )))->vBlockingHook )
  46. #define WWS32ThreadSerialNumber \
  47. ( ((PWINSOCK_THREAD_DATA)(TlsGetValue( WWS32TlsSlot )))->ThreadSerialNumber )
  48. #define WWS32ThreadStartupCount \
  49. ( ((PWINSOCK_THREAD_DATA)(TlsGetValue( WWS32TlsSlot )))->ThreadStartupCount )
  50. #define WWS32ThreadVersion \
  51. ( ((PWINSOCK_THREAD_DATA)(TlsGetValue( WWS32TlsSlot )))->ThreadVersion )
  52. #define WWS32IsThreadVersion10 ( WWS32ThreadVersion == MAKEWORD(1, 0) )
  53. #define WWS32IsThreadVersion11 ( WWS32ThreadVersion == MAKEWORD(1, 1) )
  54. #define WWS32IsThreadInitialized \
  55. ( TlsGetValue( WWS32TlsSlot ) == NULL ? FALSE : TRUE )
  56. typedef struct _WINSOCK_ASYNC_CONTEXT_BLOCK {
  57. LIST_ENTRY ContextBlockListEntry;
  58. HANDLE AsyncTaskHandle32;
  59. HAND16 AsyncTaskHandle16;
  60. VPVOID vBuffer16;
  61. DWORD Buffer16Length;
  62. PVOID Buffer32;
  63. } WINSOCK_ASYNC_CONTEXT_BLOCK, *PWINSOCK_ASYNC_CONTEXT_BLOCK;
  64. typedef struct _WINSOCK_SOCKET_INFO {
  65. LIST_ENTRY GlobalSocketListEntry;
  66. SOCKET SocketHandle32;
  67. DWORD ThreadSerialNumber;
  68. HAND16 SocketHandle16;
  69. } WINSOCK_SOCKET_INFO, *PWINSOCK_SOCKET_INFO;
  70. PFD_SET
  71. AllocateFdSet32 (
  72. IN PFD_SET16 FdSet16
  73. );
  74. INT
  75. ConvertFdSet16To32 (
  76. IN PFD_SET16 FdSet16,
  77. IN PFD_SET FdSet32
  78. );
  79. VOID
  80. ConvertFdSet32To16 (
  81. IN PFD_SET FdSet32,
  82. IN PFD_SET16 FdSet16
  83. );
  84. int PASCAL
  85. WSApSetPostRoutine (
  86. IN PVOID PostRoutine
  87. );
  88. typedef
  89. BOOL
  90. (*PWINSOCK_POST_ROUTINE) (
  91. HWND hWnd,
  92. UINT Msg,
  93. WPARAM wParam,
  94. LPARAM lParam
  95. );
  96. BOOL
  97. WWS32DispatchPostMessage (
  98. HWND hWnd,
  99. UINT Msg,
  100. WPARAM wParam,
  101. LPARAM lParam
  102. );
  103. BOOL
  104. WWS32PostAsyncSelect (
  105. HWND hWnd,
  106. UINT Msg,
  107. WPARAM wParam,
  108. LPARAM lParam
  109. );
  110. BOOL
  111. WWS32PostAsyncGetHost (
  112. HWND hWnd,
  113. UINT Msg,
  114. WPARAM wParam,
  115. LPARAM lParam
  116. );
  117. BOOL
  118. WWS32PostAsyncGetProto (
  119. HWND hWnd,
  120. UINT Msg,
  121. WPARAM wParam,
  122. LPARAM lParam
  123. );
  124. BOOL
  125. WWS32PostAsyncGetServ (
  126. HWND hWnd,
  127. UINT Msg,
  128. WPARAM wParam,
  129. LPARAM lParam
  130. );
  131. PWINSOCK_ASYNC_CONTEXT_BLOCK
  132. WWS32FindAndRemoveAsyncContext (
  133. IN HANDLE AsyncTaskHandle32
  134. );
  135. HAND16
  136. WWS32GetAsyncTaskHandle16 (
  137. VOID
  138. );
  139. VOID
  140. WWS32TaskCleanup(
  141. VOID
  142. );
  143. //
  144. // Message types used by WWS32DispatchPostMessage to dispatch a post
  145. // message call to the appropriate routine.
  146. //
  147. #define WWS32_MESSAGE_ASYNC_SELECT 0
  148. #define WWS32_MESSAGE_ASYNC_GETHOST 1
  149. #define WWS32_MESSAGE_ASYNC_GETPROTO 2
  150. #define WWS32_MESSAGE_ASYNC_GETSERV 3
  151. //
  152. // An arbitrary value that indicates the default blocking hook is in use.
  153. //
  154. #define WWS32_DEFAULT_BLOCKING_HOOK 0xFFFFFFFF
  155. //
  156. // Determine if a pointer is DWORD aligned.
  157. //
  158. #define IS_DWORD_ALIGNED(p) (((DWORD)(p) & (sizeof(DWORD)-1)) == 0)