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.

329 lines
7.5 KiB

  1. /*++
  2. Copyright (c) 1987-1992 Microsoft Corporation
  3. Module Name:
  4. logonp.h
  5. Abstract:
  6. Private Netlogon service routines useful by both the Netlogon service
  7. and others that pass mailslot messages to/from the Netlogon service.
  8. Author:
  9. Cliff Van Dyke (cliffv) 7-Jun-1991
  10. Environment:
  11. User mode only.
  12. Contains NT-specific code.
  13. Requires ANSI C extensions: slash-slash comments, long external names.
  14. Revision History:
  15. --*/
  16. #ifndef _LOGONP_H_
  17. #define _LOGONP_H_
  18. #include <dsgetdc.h> // PDS_DOMAIN_TRUSTSW
  19. //
  20. // Message versions returned from NetpLogonGetMessageVersion
  21. //
  22. #define LMUNKNOWN_MESSAGE 0 // No version tokens on end of message
  23. #define LM20_MESSAGE 1 // Just LM 2.0 token on end of message
  24. #define LMNT_MESSAGE 2 // LM 2.0 and LM NT token on end of message
  25. #define LMUNKNOWNNT_MESSAGE 3 // LM 2.0 and LM NT token on end of
  26. // message, but the version is not
  27. // supported.
  28. #define LMWFW_MESSAGE 4 // LM WFW token on end of message
  29. //
  30. // Define the token placed in the last two bytes of a LanMan 2.0 message
  31. //
  32. #define LM20_TOKENBYTE 0xFF
  33. //
  34. // Define the token placed in the last four bytes of a NT LanMan message
  35. // Notice that such a message is by definition a LanMan 2.0 message
  36. //
  37. #define LMNT_TOKENBYTE 0xFF
  38. //
  39. // Define the token placed in the next to last byte of the PRIMARY_QUERY
  40. // message from newer (8/8/94) WFW and Chicago clients. This byte (followed
  41. // by a LM20_TOKENBYTE) indicates the client is WAN-aware and sends the
  42. // PRIMARY_QUERY to the DOMAIN<1B> name. As such, BDC on the same subnet need
  43. // not respond to this query.
  44. //
  45. #define LMWFW_TOKENBYTE 0xFE
  46. //
  47. // Put the LANMAN NT token onto the end of a message.
  48. //
  49. // The token is always followed by a LM 2.0 token so LM 2.0 systems will
  50. // think this message is from a LM 2.0 system.
  51. //
  52. // Also append a version flag before the NT TOKEN so that the future
  53. // versions of software can handle the newer messages effectively.
  54. //
  55. //Arguments:
  56. //
  57. // Where - Indirectly points to the current location in the buffer. The
  58. // 'String' is copied to the current location. This current location is
  59. // updated to point to the byte following the token.
  60. //
  61. // NtVersion - Additional version information to be or'ed into the NtVersion
  62. // field of the message.
  63. #define NetpLogonPutNtToken( _Where, _NtVersion ) \
  64. { \
  65. SmbPutUlong( (*_Where), NETLOGON_NT_VERSION_1 | (_NtVersion) ); \
  66. (*_Where) += sizeof(ULONG); \
  67. *((PUCHAR)((*_Where)++)) = LMNT_TOKENBYTE; \
  68. *((PUCHAR)((*_Where)++)) = LMNT_TOKENBYTE; \
  69. NetpLogonPutLM20Token( _Where ); \
  70. }
  71. //
  72. // Put the LANMAN 2.0 token onto the end of a message.
  73. //
  74. //Arguments:
  75. //
  76. // Where - Indirectly points to the current location in the buffer. The
  77. // 'String' is copied to the current location. This current location is
  78. // updated to point to the byte following the token.
  79. #define NetpLogonPutLM20Token( _Where ) \
  80. { \
  81. *((PUCHAR)((*_Where)++)) = LM20_TOKENBYTE; \
  82. *((PUCHAR)((*_Where)++)) = LM20_TOKENBYTE; \
  83. }
  84. #define NetpLogonPutGuid( _Guid, _Where ) \
  85. NetpLogonPutBytes( (_Guid), sizeof(GUID), _Where )
  86. #define NetpLogonGetGuid( _Message, _MessageSize, _Where, _Guid ) \
  87. NetpLogonGetBytes( \
  88. (_Message), \
  89. (_MessageSize),\
  90. (_Where), \
  91. sizeof(GUID), \
  92. (_Guid) )
  93. //
  94. // Name of binary Forest Trust List file
  95. //
  96. #define NL_FOREST_BINARY_LOG_FILE L"\\system32\\config\\netlogon.ftl"
  97. #define NL_FOREST_BINARY_LOG_FILE_JOIN L"\\system32\\config\\netlogon.ftj"
  98. //
  99. // Header for binary Forest Trust List file.
  100. //
  101. typedef struct _DS_DISK_TRUSTED_DOMAIN_HEADER {
  102. ULONG Version;
  103. } DS_DISK_TRUSTED_DOMAIN_HEADER, *PDS_DISK_TRUSTED_DOMAIN_HEADER;
  104. #define DS_DISK_TRUSTED_DOMAIN_VERSION 1
  105. //
  106. // Entry for binary Forest Trust List file.
  107. //
  108. typedef struct _PDS_DISK_TRUSTED_DOMAIN {
  109. //
  110. // Size of entire entry
  111. //
  112. ULONG EntrySize;
  113. //
  114. // Name of the trusted domain.
  115. //
  116. ULONG NetbiosDomainNameSize;
  117. ULONG DnsDomainNameSize;
  118. //
  119. // Flags defining attributes of the trust.
  120. //
  121. ULONG Flags;
  122. //
  123. // Index to the domain that is the parent of this domain.
  124. // Only defined if NETLOGON_DOMAIN_IN_FOREST is set and
  125. // NETLOGON_DOMAIN_TREE_ROOT is not set.
  126. //
  127. ULONG ParentIndex;
  128. //
  129. // The trust type and attributes of this trust.
  130. //
  131. // If NETLOGON_DOMAIN_DIRECTLY_TRUSTED is not set,
  132. // these value are infered.
  133. //
  134. ULONG TrustType;
  135. ULONG TrustAttributes;
  136. //
  137. // The SID of the trusted domain.
  138. //
  139. // If NETLOGON_DOMAIN_DIRECTLY_TRUSTED is not set,
  140. // this value will be NULL.
  141. //
  142. ULONG DomainSidSize;
  143. //
  144. // The GUID of the trusted domain.
  145. //
  146. GUID DomainGuid;
  147. } DS_DISK_TRUSTED_DOMAINS, *PDS_DISK_TRUSTED_DOMAINS;
  148. //
  149. // Procedure forwards from logonp.c
  150. //
  151. VOID
  152. NetpLogonPutOemString(
  153. IN LPSTR String,
  154. IN DWORD MaxStringLength,
  155. IN OUT PCHAR * Where
  156. );
  157. VOID
  158. NetpLogonPutUnicodeString(
  159. IN LPWSTR String,
  160. IN DWORD MaxStringLength,
  161. IN OUT PCHAR * Where
  162. );
  163. VOID
  164. NetpLogonPutBytes(
  165. IN LPVOID Data,
  166. IN DWORD Size,
  167. IN OUT PCHAR * Where
  168. );
  169. DWORD
  170. NetpLogonGetMessageVersion(
  171. IN PVOID Message,
  172. IN PDWORD MessageSize,
  173. OUT PULONG Version
  174. );
  175. BOOL
  176. NetpLogonGetOemString(
  177. IN PVOID Message,
  178. IN DWORD MessageSize,
  179. IN OUT PCHAR *Where,
  180. IN DWORD MaxStringLength,
  181. OUT LPSTR *String
  182. );
  183. BOOL
  184. NetpLogonGetUnicodeString(
  185. IN PVOID Message,
  186. IN DWORD MessageSize,
  187. IN OUT PCHAR *Where,
  188. IN DWORD MaxStringSize,
  189. OUT LPWSTR *String
  190. );
  191. BOOL
  192. NetpLogonGetBytes(
  193. IN PVOID Message,
  194. IN DWORD MessageSize,
  195. IN OUT PCHAR *Where,
  196. IN DWORD DataSize,
  197. OUT LPVOID Data
  198. );
  199. BOOL
  200. NetpLogonGetDBInfo(
  201. IN PVOID Message,
  202. IN DWORD MessageSize,
  203. IN OUT PCHAR *Where,
  204. OUT PDB_CHANGE_INFO Data
  205. );
  206. LPWSTR
  207. NetpLogonOemToUnicode(
  208. IN LPSTR Ansi
  209. );
  210. LPSTR
  211. NetpLogonUnicodeToOem(
  212. IN LPWSTR Unicode
  213. );
  214. NET_API_STATUS
  215. NetpLogonWriteMailslot(
  216. IN LPWSTR MailslotName,
  217. IN LPVOID Buffer,
  218. IN DWORD BufferSize
  219. );
  220. //
  221. // Define the largest message returned by a mailslot created by
  222. // NetpLogonCreateRandomMailslot(). The 64 byte value allows expansion
  223. // of the messages in the future.
  224. //
  225. #define MAX_RANDOM_MAILSLOT_RESPONSE (max(sizeof(NETLOGON_LOGON_RESPONSE), sizeof(NETLOGON_PRIMARY)) + 64 )
  226. NET_API_STATUS
  227. NetpLogonCreateRandomMailslot(
  228. IN LPSTR path,
  229. OUT PHANDLE MsHandle
  230. );
  231. VOID
  232. NetpLogonPutDomainSID(
  233. IN PCHAR Sid,
  234. IN DWORD SidLength,
  235. IN OUT PCHAR * Where
  236. );
  237. BOOL
  238. NetpLogonGetDomainSID(
  239. IN PVOID Message,
  240. IN DWORD MessageSize,
  241. IN OUT PCHAR *Where,
  242. IN DWORD SIDSize,
  243. OUT PCHAR *Sid
  244. );
  245. BOOLEAN
  246. NetpLogonTimeHasElapsed(
  247. IN LARGE_INTEGER StartTime,
  248. IN DWORD Timeout
  249. );
  250. NET_API_STATUS
  251. NlWriteBinaryLog(
  252. IN LPWSTR FileSuffix,
  253. IN LPBYTE Buffer,
  254. IN ULONG BufferSize
  255. );
  256. NET_API_STATUS
  257. NlWriteFileForestTrustList (
  258. IN LPWSTR FileSuffix,
  259. IN PDS_DOMAIN_TRUSTSW ForestTrustList,
  260. IN ULONG ForestTrustListCount
  261. );
  262. #endif // _LOGONP_H_