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.

439 lines
11 KiB

  1. //+-----------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (c) Microsoft Corporation 1992 - 1996
  6. //
  7. // File: kerb.h
  8. //
  9. // Contents: precompiled global include file for Kerberos security package
  10. //
  11. //
  12. // History: 14-Jan-1997 Created MikeSw
  13. //
  14. //------------------------------------------------------------------------
  15. #ifndef __KERB_H__
  16. #define __KERB_H__
  17. //
  18. // All global variables declared as EXTERN will be allocated in the file
  19. // that defines KERBP_ALLOCATE
  20. //
  21. #include "krbprgma.h"
  22. #ifndef WIN32_CHICAGO
  23. #ifndef UNICODE
  24. #define UNICODE
  25. #endif // UNICODE
  26. #endif // WIN32_CHICAGO
  27. #ifdef __cplusplus
  28. extern "C"
  29. {
  30. #endif // __cplusplus
  31. #include <nt.h>
  32. #include <ntrtl.h>
  33. #include <nturtl.h>
  34. #ifndef WIN32_CHICAGO
  35. #include <ntlsa.h>
  36. #include <ntsam.h>
  37. #ifndef WIN32_LEAN_AND_MEAN
  38. #define WIN32_LEAN_AND_MEAN
  39. #endif // WIN32_LEAN_AND_MEAN
  40. #endif // WIN32_CHICAGO
  41. #include <windows.h>
  42. #include <minmax.h>
  43. #ifndef WIN32_CHICAGO
  44. #ifndef RPC_NO_WINDOWS_H
  45. #define RPC_NO_WINDOWS_H
  46. #endif // RPC_NO_WINDOWS_H
  47. #include <rpc.h>
  48. #endif // WIN32_CHICAGO
  49. #ifndef SECURITY_WIN32
  50. #define SECURITY_WIN32
  51. #endif // SECURITY_WIN32
  52. #define SECURITY_PACKAGE
  53. #define SECURITY_KERBEROS
  54. #ifdef WIN32_CHICAGO
  55. typedef LONG NTSTATUS, *PNTSTATUS;
  56. #define STATUS_SUCCESS ((NTSTATUS)0x00000000L) // ntsubauth
  57. #define STATUS_UNSUCCESSFUL ((NTSTATUS)0xC0000001L)
  58. #define STATUS_INSUFFICIENT_RESOURCES ((NTSTATUS)0xC000009AL) // ntsubauth
  59. #define STATUS_INVALID_PARAMETER ((NTSTATUS)0xC000000DL)
  60. #define STATUS_OBJECT_NAME_NOT_FOUND ((NTSTATUS)0xC0000034L)
  61. #define STATUS_BUFFER_TOO_SMALL ((NTSTATUS)0xC0000023L)
  62. #define STATUS_INVALID_PARAMETER_2 ((NTSTATUS)0xC00000F0L)
  63. #define STATUS_BUFFER_OVERFLOW ((NTSTATUS)0x80000005L)
  64. #define STATUS_NOT_SUPPORTED ((NTSTATUS)0xC00000BBL)
  65. #define STATUS_INVALID_SERVER_STATE ((NTSTATUS)0xC00000DCL)
  66. #define STATUS_INTERNAL_ERROR ((NTSTATUS)0xC00000E5L)
  67. #define STATUS_ACCESS_DENIED ((NTSTATUS)0xC0000022L)
  68. #define STATUS_NO_SUCH_LOGON_SESSION ((NTSTATUS)0xC000005FL)
  69. #define STATUS_NETLOGON_NOT_STARTED ((NTSTATUS)0xC0000192L)
  70. #define STATUS_DOMAIN_CONTROLLER_NOT_FOUND ((NTSTATUS)0xC0000233L)
  71. #define STATUS_NO_LOGON_SERVERS ((NTSTATUS)0xC000005EL)
  72. #define STATUS_NO_SUCH_DOMAIN ((NTSTATUS)0xC00000DFL)
  73. #define STATUS_PRIVILEGE_NOT_HELD ((NTSTATUS)0xC0000061L)
  74. #define STATUS_INVALID_HANDLE ((NTSTATUS)0xC0000008L) // winnt
  75. #define STATUS_LOGON_FAILURE ((NTSTATUS)0xC000006DL) // ntsubauth
  76. #define STATUS_NO_SUCH_USER ((NTSTATUS)0xC0000064L) // ntsubauth
  77. #define STATUS_ACCOUNT_DISABLED ((NTSTATUS)0xC0000072L) // ntsubauth
  78. #define STATUS_ACCOUNT_RESTRICTION ((NTSTATUS)0xC000006EL) // ntsubauth
  79. #define STATUS_ACCOUNT_LOCKED_OUT ((NTSTATUS)0xC0000234L) // ntsubauth
  80. #define STATUS_WRONG_PASSWORD ((NTSTATUS)0xC000006AL) // ntsubauth
  81. #define STATUS_ACCOUNT_EXPIRED ((NTSTATUS)0xC0000193L) // ntsubauth
  82. #define STATUS_PASSWORD_EXPIRED ((NTSTATUS)0xC0000071L) // ntsubauth
  83. #define STATUS_ILL_FORMED_PASSWORD ((NTSTATUS)0xC000006BL)
  84. #define STATUS_NOT_COMMITTED ((NTSTATUS)0xC000002DL)
  85. #define STATUS_INVALID_INFO_CLASS ((NTSTATUS)0xC0000003L) // ntsubauth
  86. #define STATUS_INVALID_LOGON_TYPE ((NTSTATUS)0xC000010BL)
  87. #define STATUS_INVALID_LOGON_HOURS ((NTSTATUS)0xC000006FL) // ntsubauth
  88. #define STATUS_INVALID_WORKSTATION ((NTSTATUS)0xC0000070L) // ntsubauth
  89. #define STATUS_TIME_DIFFERENCE_AT_DC ((NTSTATUS)0xC0000133L)
  90. // from net\inc\ssi.h
  91. #define SSI_ACCOUNT_NAME_POSTFIX_CHAR L'$'
  92. typedef UNICODE_STRING *PUNICODE_STRING;
  93. #define UNICODE_NULL ((WCHAR)0) // winnt
  94. typedef ULONG CLONG;
  95. typedef short CSHORT;
  96. typedef STRING ANSI_STRING;
  97. typedef PSTRING PANSI_STRING;
  98. #endif // WIN32_CHICAGO
  99. #include <security.h>
  100. #include <wincred.h>
  101. #include <secint.h>
  102. #include <lsasecpk.h>
  103. #ifndef WIN32_CHICAGO
  104. #include <dsysdbg.h>
  105. #endif // !WIN32_CHICAGO
  106. #include <lmcons.h>
  107. #include <dsgetdc.h>
  108. #include <wincrypt.h>
  109. #include <dns.h>
  110. #include <winsock2.h>
  111. #ifndef WIN32_CHICAGO
  112. #include <lsarpc.h>
  113. #include <lsaisrv.h>
  114. #include <lsaitf.h>
  115. #include <lmapibuf.h>
  116. #include <dnsapi.h>
  117. #include <lmcons.h>
  118. #include <lmerr.h>
  119. #include <dnssrv.h>
  120. #include <crypt.h>
  121. #include <cryptdll.h>
  122. #include <ntmsv1_0.h>
  123. #include <logonmsv.h>
  124. #include <align.h>
  125. #include <netlib.h>
  126. #include <netlibnt.h> // NetpApiStatusToNtStatus
  127. #include <config.h> // NetpXXXConfigXXX
  128. #include <ssi.h> // SSI_ACCOUNT_NAME_POSTFIX_CHAR
  129. #include <lmsname.h>
  130. #define _AVOID_REPL_API
  131. #include <nlrepl.h>
  132. #undef _AVOID_REPL_API
  133. #else // WIN32_CHICAGO
  134. #include <assert.h> // C run-time definitions
  135. #include <limits.h>
  136. #endif // !WIN32_CHICAGO
  137. #include <sclogon.h>
  138. #include <sclogon2.h>
  139. #include <fileno.h>
  140. #ifdef __cplusplus
  141. }
  142. #endif // __cplusplus
  143. #ifdef WIN32_CHICAGO
  144. #define DsysAssert(exp) assert(exp)
  145. // from ntrtl.h
  146. // #define RtlOffsetToPointer(B,O) ((PCHAR)( ((PCHAR)(B)) + ((ULONG)(O)) ))
  147. #define RtlEqualMemory(Destination,Source,Length) (!memcmp((Destination),(Source),(Length)))
  148. // #define RtlEqualLuid(L1, L2) (((L1)->HighPart == (L2)->HighPart) && ((L1)->LowPart == (L2)->LowPart))
  149. //
  150. // Time conversion routines
  151. //
  152. typedef TIME_FIELDS *PTIME_FIELDS;
  153. //
  154. //
  155. // A time field record (Weekday ignored) -> 64 bit Time value
  156. //
  157. BOOLEAN
  158. MyRtlTimeFieldsToTime (
  159. PTIME_FIELDS TimeFields,
  160. PLARGE_INTEGER Time
  161. );
  162. #define RtlTimeFieldsToTime(x, y) MyRtlTimeFieldsToTime(x, y)
  163. VOID
  164. MyRtlTimeToTimeFields (
  165. PLARGE_INTEGER Time,
  166. PTIME_FIELDS TimeFields
  167. );
  168. #define RtlTimeToTimeFields(x, y) MyRtlTimeToTimeFields(x, y)
  169. VOID
  170. MyRtlFreeUnicodeString(
  171. PUNICODE_STRING UnicodeString
  172. );
  173. #define RtlFreeUnicodeString(x) MyRtlFreeUnicodeString(x)
  174. LONG
  175. MyRtlCompareUnicodeString(
  176. PUNICODE_STRING String1,
  177. PUNICODE_STRING String2,
  178. BOOLEAN CaseInSensitive
  179. );
  180. #define RtlCompareUnicodeString(x, y, z) MyRtlCompareUnicodeString(x, y, z)
  181. VOID
  182. MyRtlInitString(
  183. PSTRING DestinationString,
  184. PCSTR SourceString
  185. );
  186. #define RtlInitString(x, y) MyRtlInitString(x, y)
  187. VOID
  188. MyRtlInitAnsiString(
  189. PANSI_STRING DestinationString,
  190. PCSTR SourceString
  191. );
  192. #define RtlInitAnsiString(x, y) MyRtlInitAnsiString(x, y)
  193. VOID
  194. MyRtlFreeAnsiString(
  195. PANSI_STRING AnsiString
  196. );
  197. #define RtlFreeAnsiString(x) MyRtlFreeAnsiString(x)
  198. NTSTATUS
  199. MyRtlUnicodeStringToAnsiString(
  200. PANSI_STRING DestinationString,
  201. PUNICODE_STRING SourceString,
  202. BOOLEAN AllocateDestinationString
  203. );
  204. #define RtlUnicodeStringToAnsiString(x, y, z) MyRtlUnicodeStringToAnsiString(x, y, z)
  205. NTSTATUS
  206. MyRtlAnsiStringToUnicodeString(
  207. PUNICODE_STRING DestinationString,
  208. PANSI_STRING SourceString,
  209. BOOLEAN AllocateDestinationString
  210. );
  211. #define RtlAnsiStringToUnicodeString(x, y, z) MyRtlAnsiStringToUnicodeString(x, y, z)
  212. NTSYSAPI
  213. VOID
  214. NTAPI
  215. RtlRunDecodeUnicodeString(
  216. UCHAR Seed,
  217. PUNICODE_STRING String
  218. );
  219. BOOLEAN
  220. MyRtlEqualDomainName(
  221. IN PUNICODE_STRING String1,
  222. IN PUNICODE_STRING String2
  223. );
  224. #define RtlEqualDomainName(x, y) MyRtlEqualDomainName(x, y)
  225. #ifdef __cplusplus // cause it's called from passwd.c !!
  226. extern "C"
  227. {
  228. #endif // __cplusplus
  229. VOID
  230. MyRtlInitUnicodeString(
  231. PUNICODE_STRING DestinationString,
  232. PCWSTR SourceString
  233. );
  234. #define RtlInitUnicodeString(x,y) MyRtlInitUnicodeString(x, y)
  235. BOOLEAN
  236. MyRtlEqualUnicodeString(
  237. PUNICODE_STRING String1,
  238. PUNICODE_STRING String2,
  239. BOOLEAN CaseInSensitive
  240. );
  241. #define RtlEqualUnicodeString(x, y, z) MyRtlEqualUnicodeString(x, y, z)
  242. NTSTATUS
  243. MyRtlUpcaseUnicodeString(
  244. PUNICODE_STRING DestinationString,
  245. PUNICODE_STRING SourceString,
  246. BOOLEAN AllocateDestinationString
  247. );
  248. #define RtlUpcaseUnicodeString(x, y, z) MyRtlUpcaseUnicodeString(x, y, z)
  249. NTSTATUS
  250. NTAPI
  251. MyRtlConvertSidToUnicodeString(
  252. PUNICODE_STRING UnicodeString,
  253. PSID Sid,
  254. BOOLEAN AllocateDestinationString
  255. );
  256. #define RtlConvertSidToUnicodeString(x, y, z) MyRtlConvertSidToUnicodeString(x, y, z)
  257. #ifdef __cplusplus
  258. }
  259. #endif // __cplusplus
  260. NTSTATUS
  261. RtlDowncaseUnicodeString(
  262. OUT PUNICODE_STRING DestinationString,
  263. IN PUNICODE_STRING SourceString,
  264. IN BOOLEAN AllocateDestinationString
  265. );
  266. NTSYSAPI
  267. ULONG
  268. NTAPI
  269. RtlLengthSid (
  270. PSID Sid
  271. );
  272. NTSYSAPI // ntifs
  273. NTSTATUS // ntifs
  274. NTAPI // ntifs
  275. RtlCreateAcl ( // ntifs
  276. PACL Acl, // ntifs
  277. ULONG AclLength, // ntifs
  278. ULONG AclRevision // ntifs
  279. ); // ntifs
  280. NTSYSAPI // ntifs
  281. NTSTATUS // ntifs
  282. NTAPI // ntifs
  283. RtlAddAccessAllowedAce ( // ntifs
  284. PACL Acl, // ntifs
  285. ULONG AceRevision, // ntifs
  286. ACCESS_MASK AccessMask, // ntifs
  287. PSID Sid // ntifs
  288. ); // ntifs
  289. NTSYSAPI
  290. NTSTATUS
  291. NTAPI
  292. RtlCreateSecurityDescriptor (
  293. PSECURITY_DESCRIPTOR SecurityDescriptor,
  294. ULONG Revision
  295. );
  296. NTSYSAPI
  297. NTSTATUS
  298. NTAPI
  299. RtlSetDaclSecurityDescriptor (
  300. PSECURITY_DESCRIPTOR SecurityDescriptor,
  301. BOOLEAN DaclPresent,
  302. PACL Dacl,
  303. BOOLEAN DaclDefaulted
  304. );
  305. // from ntexapi.h
  306. NTSTATUS
  307. MyNtQuerySystemTime (
  308. OUT PTimeStamp SystemTime
  309. );
  310. #define NtQuerySystemTime(x) MyNtQuerySystemTime(x)
  311. NTSTATUS
  312. MyNtAllocateLocallyUniqueId(
  313. OUT PLUID Luid
  314. );
  315. #define NtAllocateLocallyUniqueId(x) MyNtAllocateLocallyUniqueId(x)
  316. // from ntobapi.h
  317. NTSYSAPI
  318. NTSTATUS
  319. NTAPI
  320. NtClose(
  321. IN HANDLE Handle
  322. );
  323. NTSYSAPI
  324. NTSTATUS
  325. NTAPI
  326. NtSetSecurityObject(
  327. IN HANDLE Handle,
  328. IN SECURITY_INFORMATION SecurityInformation,
  329. IN PSECURITY_DESCRIPTOR SecurityDescriptor
  330. );
  331. // from ntseapi.h
  332. //
  333. // used for password manipulations
  334. //
  335. NTSYSAPI
  336. NTSTATUS
  337. NTAPI
  338. NtOpenProcessToken(
  339. IN HANDLE ProcessHandle,
  340. IN ACCESS_MASK DesiredAccess,
  341. OUT PHANDLE TokenHandle
  342. );
  343. // from ntpsapi.h
  344. #define NtCurrentProcess() ( (HANDLE)(LONG_PTR) -1 )
  345. // from ntdef.h
  346. #define MAXUSHORT 0xffff
  347. BOOLEAN
  348. MyRtlCreateUnicodeStringFromAsciiz(
  349. OUT PUNICODE_STRING DestinationString,
  350. IN PCSTR SourceString
  351. );
  352. #define RtlCreateUnicodeStringFromAsciiz(x, y) MyRtlCreateUnicodeStringFromAsciiz(x, y)
  353. #define RtlInitializeCriticalSection(x) (InitializeCriticalSection(x),0)
  354. #define RtlDeleteCriticalSection(x) (DeleteCriticalSection(x),0)
  355. #define RtlEnterCriticalSection(x) (EnterCriticalSection(x),0)
  356. #define RtlLeaveCriticalSection(x) (LeaveCriticalSection(x),0)
  357. #define RtlInitializeResource(x) (InitializeCriticalSection(x),0)
  358. #define RtlDeleteResource(x) (DeleteCriticalSection(x))
  359. #endif // WIN32_CHICAGO
  360. #include <kerbcomm.h>
  361. #include <kdcexp.h>
  362. #define INITGUID
  363. #include "kerbtrace.h"
  364. #endif // __KERB_H__