Leaked source code of windows server 2003
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.

239 lines
4.4 KiB

  1. /*++
  2. Intel Corporation Proprietary Information
  3. Copyright (c) 1995 Intel Corporation
  4. This listing is supplied under the terms of a license agreement with
  5. Intel Corporation and may not be used, copied, nor disclosed except in
  6. accordance with the terms of that agreeement.
  7. Module Name:
  8. util.h
  9. Abstract:
  10. This module contains utility MACRO'S and definitions used for
  11. WINSOCK2 DLL
  12. Author:
  13. Dirk Brandewie dirk@mink.intel.com 11-JUL-1995
  14. Revision History:
  15. --*/
  16. #include <windows.h>
  17. #include "classfwd.h"
  18. //
  19. // The highest WinSock versions supported by this DLL.
  20. //
  21. #define WINSOCK_HIGH_API_VERSION MAKEWORD(2,2)
  22. #define WINSOCK_HIGH_SPI_VERSION MAKEWORD(2,2)
  23. //
  24. // The maximum allowed length for a catalog name such as "Protocol_Catalog9"
  25. // or "NameSpace_Catalog5". This makes ValidateCurrentCatalogName() a bit
  26. // simpler.
  27. //
  28. #define MAX_CATALOG_NAME_LENGTH 32
  29. //
  30. // Special value that keeps serial number of the registry catalog
  31. // and helps synchronize access to registry without "public"
  32. // mutex object
  33. //
  34. #define SERIAL_NUMBER_NAME "Serial_Access_Num"
  35. //
  36. // API prolog. Note that Prolog_v1 is always used for WinSock 1.1 apps,
  37. // and Prolog_v2 is always used for WinSock 2.x apps.
  38. //
  39. // Code within this DLL should call the prolog through the PROLOG macro.
  40. // This will make life a bit simpler if we decide to change it yet again
  41. // in the future.
  42. //
  43. INT
  44. WINAPI
  45. Prolog_v1(
  46. OUT PDPROCESS FAR * Process,
  47. OUT PDTHREAD FAR * Thread
  48. );
  49. INT
  50. WINAPI
  51. Prolog_v2(
  52. OUT PDPROCESS FAR * Process,
  53. OUT PDTHREAD FAR * Thread
  54. );
  55. INT
  56. WINAPI
  57. Prolog_Detached(
  58. OUT PDPROCESS FAR * Process,
  59. OUT PDTHREAD FAR * Thread
  60. );
  61. typedef
  62. INT
  63. (WINAPI * LPFN_PROLOG)(
  64. OUT PDPROCESS FAR * Process,
  65. OUT PDTHREAD FAR * Thread
  66. );
  67. extern LPFN_PROLOG PrologPointer;
  68. extern HANDLE gHeap;
  69. extern HINSTANCE gDllHandle;
  70. #define PROLOG(p,t) (PrologPointer)( (p), (t) )
  71. //
  72. // Optimized inline version for V2 apps to be used
  73. // on sensitive performance paths.
  74. //
  75. INT
  76. WINAPI
  77. SlowPrologOvlp (
  78. OUT PDTHREAD FAR * Thread
  79. );
  80. INT
  81. WINAPI
  82. SlowProlog (
  83. VOID
  84. );
  85. #define TURBO_PROLOG() \
  86. (((PrologPointer==Prolog_v2) && \
  87. (DPROCESS::GetCurrentDProcess()!=NULL)) \
  88. ? ERROR_SUCCESS \
  89. : SlowProlog())
  90. #define TURBO_PROLOG_OVLP(t) \
  91. (((PrologPointer==Prolog_v2) && \
  92. (DPROCESS::GetCurrentDProcess()!=NULL) && \
  93. ((*(t)=DTHREAD::GetCurrentDThread())!=NULL)) \
  94. ? ERROR_SUCCESS \
  95. : SlowPrologOvlp(t))
  96. //
  97. // NT WOW Support.
  98. //
  99. typedef
  100. BOOL
  101. (WINAPI * LPFN_POSTMESSAGE)(
  102. HWND hWnd,
  103. UINT Msg,
  104. WPARAM wParam,
  105. LPARAM lParam
  106. );
  107. //
  108. // Registry manipulation.
  109. //
  110. BOOL
  111. WriteRegistryEntry(
  112. IN HKEY EntryKey,
  113. IN LPCTSTR EntryName,
  114. IN PVOID Data,
  115. IN DWORD TypeFlag
  116. );
  117. BOOL
  118. ReadRegistryEntry(
  119. IN HKEY EntryKey,
  120. IN LPTSTR EntryName,
  121. OUT PVOID Data,
  122. IN DWORD MaxBytes,
  123. IN DWORD TypeFlag
  124. );
  125. LONG
  126. RegDeleteKeyRecursive(
  127. IN HKEY hkey,
  128. IN LPCTSTR lpszSubKey
  129. );
  130. LONG
  131. RegDeleteSubkeys(
  132. IN HKEY hkey
  133. );
  134. HKEY
  135. OpenWinSockRegistryRoot();
  136. VOID
  137. CloseWinSockRegistryRoot(
  138. HKEY RootKey
  139. );
  140. VOID
  141. ValidateCurrentCatalogName(
  142. HKEY RootKey,
  143. LPSTR ValueName,
  144. LPSTR ExpectedName
  145. );
  146. INT
  147. AcquireExclusiveCatalogAccess (
  148. IN HKEY CatalogKey,
  149. IN DWORD ExpextedSerialNum,
  150. OUT PHKEY AccessKey
  151. );
  152. VOID
  153. ReleaseExclusiveCatalogAccess (
  154. IN HKEY CatalogKey,
  155. IN DWORD CurrentSerialNum,
  156. IN HKEY access_key
  157. );
  158. INT
  159. SynchronizeSharedCatalogAccess (
  160. IN HKEY CatalogKey,
  161. IN HANDLE ChangeEvent,
  162. OUT LPDWORD CurrentSerialNum
  163. );
  164. BOOL
  165. HasCatalogChanged (
  166. IN HANDLE ChangeEvent
  167. );
  168. //
  169. // Ansi/Unicode conversions.
  170. //
  171. INT
  172. MapUnicodeProtocolInfoToAnsi(
  173. IN LPWSAPROTOCOL_INFOW UnicodeProtocolInfo,
  174. OUT LPWSAPROTOCOL_INFOA AnsiProtocolInfo
  175. );
  176. INT
  177. MapAnsiProtocolInfoToUnicode(
  178. IN LPWSAPROTOCOL_INFOA AnsiProtocolInfo,
  179. OUT LPWSAPROTOCOL_INFOW UnicodeProtocolInfo
  180. );
  181. BOOL
  182. CompareMemory(
  183. LPBYTE p1,
  184. LPBYTE p2,
  185. DWORD dwSize
  186. );