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.

1460 lines
42 KiB

  1. //+-----------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (c) Microsoft Corporation 1991-1999
  6. //
  7. // File: secpkg.h
  8. //
  9. // Contents: Global definitions for security packages
  10. // This file will contain everything specific to writing
  11. // a security package.
  12. //
  13. //
  14. // History: 10 Mar 92 RichardW Created
  15. // 24-Mar-94 wader Changed EstablishCredentials to SystemLogon
  16. //
  17. //------------------------------------------------------------------------
  18. #ifndef __SECPKG_H__
  19. #define __SECPKG_H__
  20. #if _MSC_VER > 1000
  21. #pragma once
  22. #endif
  23. #include <ntlsa.h> // SECURITY_LOGON_TYPE
  24. // begin_ntsecpkg
  25. #ifdef SECURITY_KERNEL
  26. //
  27. // Can't use the windows.h def'ns in kernel mode.
  28. //
  29. typedef PVOID SEC_THREAD_START;
  30. typedef PVOID SEC_ATTRS;
  31. #else
  32. typedef LPTHREAD_START_ROUTINE SEC_THREAD_START;
  33. typedef LPSECURITY_ATTRIBUTES SEC_ATTRS;
  34. #endif
  35. #define SecEqualLuid(L1, L2) \
  36. ( ( ((PLUID)L1)->LowPart == ((PLUID)L2)->LowPart ) && \
  37. ( ((PLUID)L1)->HighPart == ((PLUID)L2)->HighPart ) ) \
  38. #define SecIsZeroLuid( L1 ) \
  39. ( ( L1->LowPart | L1->HighPart ) == 0 )
  40. //
  41. // The following structures are used by the helper functions
  42. //
  43. typedef struct _SECPKG_CLIENT_INFO {
  44. LUID LogonId; // Effective Logon Id
  45. ULONG ProcessID; // Process Id of caller
  46. ULONG ThreadID; // Thread Id of caller
  47. BOOLEAN HasTcbPrivilege; // Client has TCB
  48. BOOLEAN Impersonating; // Client is impersonating
  49. BOOLEAN Restricted; // Client is restricted
  50. //
  51. // NT 5.1
  52. //
  53. UCHAR ClientFlags; // Extra flags about the client
  54. SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; // Impersonation level of client
  55. } SECPKG_CLIENT_INFO, * PSECPKG_CLIENT_INFO;
  56. #define SECPKG_CLIENT_PROCESS_TERMINATED 0x01 // The client process has terminated
  57. #define SECPKG_CLIENT_THREAD_TERMINATED 0x02 // The client thread has terminated
  58. typedef struct _SECPKG_CALL_INFO {
  59. ULONG ProcessId ;
  60. ULONG ThreadId ;
  61. ULONG Attributes ;
  62. ULONG CallCount ;
  63. } SECPKG_CALL_INFO, * PSECPKG_CALL_INFO ;
  64. #define SECPKG_CALL_KERNEL_MODE 0x00000001 // Call originated in kernel mode
  65. #define SECPKG_CALL_ANSI 0x00000002 // Call came from ANSI stub
  66. #define SECPKG_CALL_URGENT 0x00000004 // Call designated urgent
  67. #define SECPKG_CALL_RECURSIVE 0x00000008 // Call is recursing
  68. #define SECPKG_CALL_IN_PROC 0x00000010 // Call originated in process
  69. #define SECPKG_CALL_CLEANUP 0x00000020 // Call is cleanup from a client
  70. #define SECPKG_CALL_WOWCLIENT 0x00000040 // Call is from a WOW client process
  71. #define SECPKG_CALL_THREAD_TERM 0x00000080 // Call is from a thread that has term'd
  72. #define SECPKG_CALL_PROCESS_TERM 0x00000100 // Call is from a process that has term'd
  73. #define SECPKG_CALL_IS_TCB 0x00000200 // Call is from TCB
  74. typedef struct _SECPKG_SUPPLEMENTAL_CRED {
  75. UNICODE_STRING PackageName;
  76. ULONG CredentialSize;
  77. #ifdef MIDL_PASS
  78. [size_is(CredentialSize)]
  79. #endif // MIDL_PASS
  80. PUCHAR Credentials;
  81. } SECPKG_SUPPLEMENTAL_CRED, *PSECPKG_SUPPLEMENTAL_CRED;
  82. typedef ULONG_PTR LSA_SEC_HANDLE ;
  83. typedef LSA_SEC_HANDLE * PLSA_SEC_HANDLE ;
  84. typedef struct _SECPKG_SUPPLEMENTAL_CRED_ARRAY {
  85. ULONG CredentialCount;
  86. #ifdef MIDL_PASS
  87. [size_is(CredentialCount)] SECPKG_SUPPLEMENTAL_CRED Credentials[*];
  88. #else // MIDL_PASS
  89. SECPKG_SUPPLEMENTAL_CRED Credentials[1];
  90. #endif // MIDL_PASS
  91. } SECPKG_SUPPLEMENTAL_CRED_ARRAY, *PSECPKG_SUPPLEMENTAL_CRED_ARRAY;
  92. //
  93. // This flag is used for to indicate which buffers in the LSA are located
  94. // in the client's address space
  95. //
  96. #define SECBUFFER_UNMAPPED 0x40000000
  97. //
  98. // This flag is used to indicate that the buffer was mapped into the LSA
  99. // from kernel mode.
  100. //
  101. #define SECBUFFER_KERNEL_MAP 0x20000000
  102. typedef NTSTATUS
  103. (NTAPI LSA_CALLBACK_FUNCTION)(
  104. ULONG_PTR Argument1,
  105. ULONG_PTR Argument2,
  106. PSecBuffer InputBuffer,
  107. PSecBuffer OutputBuffer
  108. );
  109. typedef LSA_CALLBACK_FUNCTION * PLSA_CALLBACK_FUNCTION ;
  110. #define PRIMARY_CRED_CLEAR_PASSWORD 0x1
  111. #define PRIMARY_CRED_OWF_PASSWORD 0x2
  112. #define PRIMARY_CRED_UPDATE 0x4 // this is a change of existing creds
  113. #define PRIMARY_CRED_CACHED_LOGON 0x8
  114. #define PRIMARY_CRED_LOGON_NO_TCB 0x10
  115. #define PRIMARY_CRED_LOGON_PACKAGE_SHIFT 24
  116. #define PRIMARY_CRED_PACKAGE_MASK 0xff000000
  117. //
  118. // For cached logons, the RPC id of the package doing the logon is identified
  119. // by shifting the flags to the right by the PRIMARY_CRED_LOGON_PACKAGE_SHIFT.
  120. //
  121. typedef struct _SECPKG_PRIMARY_CRED {
  122. LUID LogonId;
  123. UNICODE_STRING DownlevelName; // Sam Account Name
  124. UNICODE_STRING DomainName; // Netbios domain name where account is located
  125. UNICODE_STRING Password;
  126. UNICODE_STRING OldPassword;
  127. PSID UserSid;
  128. ULONG Flags;
  129. UNICODE_STRING DnsDomainName; // DNS domain name where account is located (if known)
  130. UNICODE_STRING Upn; // UPN of account (if known)
  131. UNICODE_STRING LogonServer;
  132. UNICODE_STRING Spare1;
  133. UNICODE_STRING Spare2;
  134. UNICODE_STRING Spare3;
  135. UNICODE_STRING Spare4;
  136. } SECPKG_PRIMARY_CRED, *PSECPKG_PRIMARY_CRED;
  137. //
  138. // Maximum size of stored credentials.
  139. //
  140. #define MAX_CRED_SIZE 1024
  141. // Values for MachineState
  142. #define SECPKG_STATE_ENCRYPTION_PERMITTED 0x01
  143. #define SECPKG_STATE_STRONG_ENCRYPTION_PERMITTED 0x02
  144. #define SECPKG_STATE_DOMAIN_CONTROLLER 0x04
  145. #define SECPKG_STATE_WORKSTATION 0x08
  146. #define SECPKG_STATE_STANDALONE 0x10
  147. typedef struct _SECPKG_PARAMETERS {
  148. ULONG Version;
  149. ULONG MachineState;
  150. ULONG SetupMode;
  151. PSID DomainSid;
  152. UNICODE_STRING DomainName;
  153. UNICODE_STRING DnsDomainName;
  154. GUID DomainGuid;
  155. } SECPKG_PARAMETERS, *PSECPKG_PARAMETERS;
  156. //
  157. // Extended Package information structures
  158. //
  159. typedef enum _SECPKG_EXTENDED_INFORMATION_CLASS {
  160. SecpkgGssInfo = 1,
  161. SecpkgContextThunks,
  162. SecpkgMutualAuthLevel,
  163. SecpkgWowClientDll,
  164. SecpkgExtraOids,
  165. SecpkgMaxInfo
  166. } SECPKG_EXTENDED_INFORMATION_CLASS ;
  167. typedef struct _SECPKG_GSS_INFO {
  168. ULONG EncodedIdLength ;
  169. UCHAR EncodedId[4] ;
  170. } SECPKG_GSS_INFO, * PSECPKG_GSS_INFO ;
  171. typedef struct _SECPKG_CONTEXT_THUNKS {
  172. ULONG InfoLevelCount ;
  173. ULONG Levels[1] ;
  174. } SECPKG_CONTEXT_THUNKS, *PSECPKG_CONTEXT_THUNKS ;
  175. typedef struct _SECPKG_MUTUAL_AUTH_LEVEL {
  176. ULONG MutualAuthLevel ;
  177. } SECPKG_MUTUAL_AUTH_LEVEL, * PSECPKG_MUTUAL_AUTH_LEVEL ;
  178. typedef struct _SECPKG_WOW_CLIENT_DLL {
  179. SECURITY_STRING WowClientDllPath;
  180. } SECPKG_WOW_CLIENT_DLL, * PSECPKG_WOW_CLIENT_DLL ;
  181. #define SECPKG_MAX_OID_LENGTH 32
  182. typedef struct _SECPKG_SERIALIZED_OID {
  183. ULONG OidLength ;
  184. ULONG OidAttributes ;
  185. UCHAR OidValue[ SECPKG_MAX_OID_LENGTH ];
  186. } SECPKG_SERIALIZED_OID, * PSECPKG_SERIALIZED_OID ;
  187. typedef struct _SECPKG_EXTRA_OIDS {
  188. ULONG OidCount ;
  189. SECPKG_SERIALIZED_OID Oids[ 1 ];
  190. } SECPKG_EXTRA_OIDS, * PSECPKG_EXTRA_OIDS;
  191. typedef struct _SECPKG_EXTENDED_INFORMATION {
  192. SECPKG_EXTENDED_INFORMATION_CLASS Class ;
  193. union {
  194. SECPKG_GSS_INFO GssInfo ;
  195. SECPKG_CONTEXT_THUNKS ContextThunks ;
  196. SECPKG_MUTUAL_AUTH_LEVEL MutualAuthLevel ;
  197. SECPKG_WOW_CLIENT_DLL WowClientDll ;
  198. SECPKG_EXTRA_OIDS ExtraOids ;
  199. } Info ;
  200. } SECPKG_EXTENDED_INFORMATION, * PSECPKG_EXTENDED_INFORMATION ;
  201. #define SECPKG_ATTR_SASL_CONTEXT 0x00010000
  202. typedef struct _SecPkgContext_SaslContext {
  203. PVOID SaslContext ;
  204. } SecPkgContext_SaslContext, * PSecPkgContext_SaslContext ;
  205. //
  206. // Setting this value as the first context thunk value will cause all
  207. // calls to go to the LSA:
  208. //
  209. #define SECPKG_ATTR_THUNK_ALL 0x00010000
  210. #ifndef SECURITY_USER_DATA_DEFINED
  211. #define SECURITY_USER_DATA_DEFINED
  212. typedef struct _SECURITY_USER_DATA {
  213. SECURITY_STRING UserName; // User name
  214. SECURITY_STRING LogonDomainName; // Domain the user logged on to
  215. SECURITY_STRING LogonServer; // Server that logged the user on
  216. PSID pSid; // SID of user
  217. } SECURITY_USER_DATA, *PSECURITY_USER_DATA;
  218. typedef SECURITY_USER_DATA SecurityUserData, * PSecurityUserData;
  219. #define UNDERSTANDS_LONG_NAMES 1
  220. #define NO_LONG_NAMES 2
  221. #endif // SECURITY_USER_DATA_DEFINED
  222. //////////////////////////////////////////////////////////////////////////
  223. //
  224. // The following prototypes are to functions that are provided by the SPMgr
  225. // to security packages.
  226. //
  227. //////////////////////////////////////////////////////////////////////////
  228. typedef NTSTATUS
  229. (NTAPI LSA_IMPERSONATE_CLIENT) (
  230. VOID
  231. );
  232. typedef NTSTATUS
  233. (NTAPI LSA_UNLOAD_PACKAGE)(
  234. VOID
  235. );
  236. typedef NTSTATUS
  237. (NTAPI LSA_DUPLICATE_HANDLE)(
  238. IN HANDLE SourceHandle,
  239. OUT PHANDLE DestionationHandle);
  240. typedef NTSTATUS
  241. (NTAPI LSA_SAVE_SUPPLEMENTAL_CREDENTIALS)(
  242. IN PLUID LogonId,
  243. IN ULONG SupplementalCredSize,
  244. IN PVOID SupplementalCreds,
  245. IN BOOLEAN Synchronous
  246. );
  247. typedef HANDLE
  248. (NTAPI LSA_CREATE_THREAD)(
  249. IN SEC_ATTRS SecurityAttributes,
  250. IN ULONG StackSize,
  251. IN SEC_THREAD_START StartFunction,
  252. IN PVOID ThreadParameter,
  253. IN ULONG CreationFlags,
  254. OUT PULONG ThreadId
  255. );
  256. typedef NTSTATUS
  257. (NTAPI LSA_GET_CLIENT_INFO)(
  258. OUT PSECPKG_CLIENT_INFO ClientInfo
  259. );
  260. typedef HANDLE
  261. (NTAPI LSA_REGISTER_NOTIFICATION)(
  262. IN SEC_THREAD_START StartFunction,
  263. IN PVOID Parameter,
  264. IN ULONG NotificationType,
  265. IN ULONG NotificationClass,
  266. IN ULONG NotificationFlags,
  267. IN ULONG IntervalMinutes,
  268. IN OPTIONAL HANDLE WaitEvent
  269. );
  270. typedef NTSTATUS
  271. (NTAPI LSA_CANCEL_NOTIFICATION)(
  272. IN HANDLE NotifyHandle
  273. );
  274. typedef NTSTATUS
  275. (NTAPI LSA_MAP_BUFFER)(
  276. IN PSecBuffer InputBuffer,
  277. OUT PSecBuffer OutputBuffer
  278. );
  279. typedef NTSTATUS
  280. (NTAPI LSA_CREATE_TOKEN) (
  281. IN PLUID LogonId,
  282. IN PTOKEN_SOURCE TokenSource,
  283. IN SECURITY_LOGON_TYPE LogonType,
  284. IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
  285. IN LSA_TOKEN_INFORMATION_TYPE TokenInformationType,
  286. IN PVOID TokenInformation,
  287. IN PTOKEN_GROUPS TokenGroups,
  288. IN PUNICODE_STRING AccountName,
  289. IN PUNICODE_STRING AuthorityName,
  290. IN PUNICODE_STRING Workstation,
  291. IN PUNICODE_STRING ProfilePath,
  292. OUT PHANDLE Token,
  293. OUT PNTSTATUS SubStatus
  294. );
  295. typedef enum _SECPKG_SESSIONINFO_TYPE {
  296. SecSessionPrimaryCred // SessionInformation is SECPKG_PRIMARY_CRED
  297. } SECPKG_SESSIONINFO_TYPE ;
  298. typedef NTSTATUS
  299. (NTAPI LSA_CREATE_TOKEN_EX) (
  300. IN PLUID LogonId,
  301. IN PTOKEN_SOURCE TokenSource,
  302. IN SECURITY_LOGON_TYPE LogonType,
  303. IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
  304. IN LSA_TOKEN_INFORMATION_TYPE TokenInformationType,
  305. IN PVOID TokenInformation,
  306. IN PTOKEN_GROUPS TokenGroups,
  307. IN PUNICODE_STRING Workstation,
  308. IN PUNICODE_STRING ProfilePath,
  309. IN PVOID SessionInformation,
  310. IN SECPKG_SESSIONINFO_TYPE SessionInformationType,
  311. OUT PHANDLE Token,
  312. OUT PNTSTATUS SubStatus
  313. );
  314. typedef VOID
  315. (NTAPI LSA_AUDIT_LOGON) (
  316. IN NTSTATUS Status,
  317. IN NTSTATUS SubStatus,
  318. IN PUNICODE_STRING AccountName,
  319. IN PUNICODE_STRING AuthenticatingAuthority,
  320. IN PUNICODE_STRING WorkstationName,
  321. IN OPTIONAL PSID UserSid,
  322. IN SECURITY_LOGON_TYPE LogonType,
  323. IN PTOKEN_SOURCE TokenSource,
  324. IN PLUID LogonId
  325. );
  326. typedef NTSTATUS
  327. (NTAPI LSA_CALL_PACKAGE) (
  328. IN PUNICODE_STRING AuthenticationPackage,
  329. IN PVOID ProtocolSubmitBuffer,
  330. IN ULONG SubmitBufferLength,
  331. OUT PVOID *ProtocolReturnBuffer,
  332. OUT PULONG ReturnBufferLength,
  333. OUT PNTSTATUS ProtocolStatus
  334. );
  335. typedef NTSTATUS
  336. (NTAPI LSA_CALL_PACKAGEEX) (
  337. IN PUNICODE_STRING AuthenticationPackage,
  338. IN PVOID ClientBufferBase,
  339. IN PVOID ProtocolSubmitBuffer,
  340. IN ULONG SubmitBufferLength,
  341. OUT PVOID *ProtocolReturnBuffer,
  342. OUT PULONG ReturnBufferLength,
  343. OUT PNTSTATUS ProtocolStatus
  344. );
  345. typedef NTSTATUS
  346. (NTAPI LSA_CALL_PACKAGE_PASSTHROUGH) (
  347. IN PUNICODE_STRING AuthenticationPackage,
  348. IN PVOID ClientBufferBase,
  349. IN PVOID ProtocolSubmitBuffer,
  350. IN ULONG SubmitBufferLength,
  351. OUT PVOID *ProtocolReturnBuffer,
  352. OUT PULONG ReturnBufferLength,
  353. OUT PNTSTATUS ProtocolStatus
  354. );
  355. typedef BOOLEAN
  356. (NTAPI LSA_GET_CALL_INFO) (
  357. OUT PSECPKG_CALL_INFO Info
  358. );
  359. typedef PVOID
  360. (NTAPI LSA_CREATE_SHARED_MEMORY)(
  361. ULONG MaxSize,
  362. ULONG InitialSize
  363. );
  364. typedef PVOID
  365. (NTAPI LSA_ALLOCATE_SHARED_MEMORY)(
  366. PVOID SharedMem,
  367. ULONG Size
  368. );
  369. typedef VOID
  370. (NTAPI LSA_FREE_SHARED_MEMORY)(
  371. PVOID SharedMem,
  372. PVOID Memory
  373. );
  374. typedef BOOLEAN
  375. (NTAPI LSA_DELETE_SHARED_MEMORY)(
  376. PVOID SharedMem
  377. );
  378. //
  379. // Account Access
  380. //
  381. typedef enum _SECPKG_NAME_TYPE {
  382. SecNameSamCompatible,
  383. SecNameAlternateId,
  384. SecNameFlat,
  385. SecNameDN,
  386. SecNameSPN
  387. } SECPKG_NAME_TYPE ;
  388. typedef NTSTATUS
  389. (NTAPI LSA_OPEN_SAM_USER)(
  390. PSECURITY_STRING Name,
  391. SECPKG_NAME_TYPE NameType,
  392. PSECURITY_STRING Prefix,
  393. BOOLEAN AllowGuest,
  394. ULONG Reserved,
  395. PVOID * UserHandle
  396. );
  397. typedef NTSTATUS
  398. (NTAPI LSA_GET_USER_CREDENTIALS)(
  399. PVOID UserHandle,
  400. PVOID * PrimaryCreds,
  401. PULONG PrimaryCredsSize,
  402. PVOID * SupplementalCreds,
  403. PULONG SupplementalCredsSize
  404. );
  405. typedef NTSTATUS
  406. (NTAPI LSA_GET_USER_AUTH_DATA)(
  407. PVOID UserHandle,
  408. PUCHAR * UserAuthData,
  409. PULONG UserAuthDataSize
  410. );
  411. typedef NTSTATUS
  412. (NTAPI LSA_CLOSE_SAM_USER)(
  413. PVOID UserHandle
  414. );
  415. typedef NTSTATUS
  416. (NTAPI LSA_GET_AUTH_DATA_FOR_USER)(
  417. PSECURITY_STRING Name,
  418. SECPKG_NAME_TYPE NameType,
  419. PSECURITY_STRING Prefix,
  420. PUCHAR * UserAuthData,
  421. PULONG UserAuthDataSize,
  422. PUNICODE_STRING UserFlatName
  423. );
  424. typedef NTSTATUS
  425. (NTAPI LSA_CONVERT_AUTH_DATA_TO_TOKEN)(
  426. IN PVOID UserAuthData,
  427. IN ULONG UserAuthDataSize,
  428. IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
  429. IN PTOKEN_SOURCE TokenSource,
  430. IN SECURITY_LOGON_TYPE LogonType,
  431. IN PUNICODE_STRING AuthorityName,
  432. OUT PHANDLE Token,
  433. OUT PLUID LogonId,
  434. OUT PUNICODE_STRING AccountName,
  435. OUT PNTSTATUS SubStatus
  436. );
  437. typedef NTSTATUS
  438. (NTAPI LSA_CRACK_SINGLE_NAME)(
  439. IN ULONG FormatOffered,
  440. IN BOOLEAN PerformAtGC,
  441. IN PUNICODE_STRING NameInput,
  442. IN PUNICODE_STRING Prefix OPTIONAL,
  443. IN ULONG RequestedFormat,
  444. OUT PUNICODE_STRING CrackedName,
  445. OUT PUNICODE_STRING DnsDomainName,
  446. OUT PULONG SubStatus
  447. );
  448. typedef NTSTATUS
  449. (NTAPI LSA_AUDIT_ACCOUNT_LOGON)(
  450. IN ULONG AuditId,
  451. IN BOOLEAN Success,
  452. IN PUNICODE_STRING Source,
  453. IN PUNICODE_STRING ClientName,
  454. IN PUNICODE_STRING MappedName,
  455. IN NTSTATUS Status
  456. );
  457. typedef NTSTATUS
  458. (NTAPI LSA_CLIENT_CALLBACK)(
  459. PCHAR Callback,
  460. ULONG_PTR Argument1,
  461. ULONG_PTR Argument2,
  462. PSecBuffer Input,
  463. PSecBuffer Output
  464. );
  465. typedef
  466. NTSTATUS
  467. (NTAPI LSA_REGISTER_CALLBACK)(
  468. ULONG CallbackId,
  469. PLSA_CALLBACK_FUNCTION Callback
  470. );
  471. #define NOTIFIER_FLAG_NEW_THREAD 0x00000001
  472. #define NOTIFIER_FLAG_ONE_SHOT 0x00000002
  473. #define NOTIFIER_FLAG_SECONDS 0x80000000
  474. #define NOTIFIER_TYPE_INTERVAL 1
  475. #define NOTIFIER_TYPE_HANDLE_WAIT 2
  476. #define NOTIFIER_TYPE_STATE_CHANGE 3
  477. #define NOTIFIER_TYPE_NOTIFY_EVENT 4
  478. #define NOTIFIER_TYPE_IMMEDIATE 16
  479. #define NOTIFY_CLASS_PACKAGE_CHANGE 1
  480. #define NOTIFY_CLASS_ROLE_CHANGE 2
  481. #define NOTIFY_CLASS_DOMAIN_CHANGE 3
  482. #define NOTIFY_CLASS_REGISTRY_CHANGE 4
  483. typedef struct _SECPKG_EVENT_PACKAGE_CHANGE {
  484. ULONG ChangeType;
  485. LSA_SEC_HANDLE PackageId;
  486. SECURITY_STRING PackageName;
  487. } SECPKG_EVENT_PACKAGE_CHANGE, * PSECPKG_EVENT_PACKAGE_CHANGE ;
  488. #define SECPKG_PACKAGE_CHANGE_LOAD 0
  489. #define SECPKG_PACKAGE_CHANGE_UNLOAD 1
  490. #define SECPKG_PACKAGE_CHANGE_SELECT 2
  491. typedef struct _SECPKG_EVENT_ROLE_CHANGE {
  492. ULONG PreviousRole ;
  493. ULONG NewRole ;
  494. } SECPKG_EVENT_ROLE_CHANGE, * PSECPKG_EVENT_ROLE_CHANGE ;
  495. typedef struct _SECPKG_PARAMETERS SECPKG_EVENT_DOMAIN_CHANGE ;
  496. typedef struct _SECPKG_PARAMETERS * PSECPKG_EVENT_DOMAIN_CHANGE ;
  497. typedef struct _SECPKG_EVENT_NOTIFY {
  498. ULONG EventClass;
  499. ULONG Reserved;
  500. ULONG EventDataSize;
  501. PVOID EventData;
  502. PVOID PackageParameter;
  503. } SECPKG_EVENT_NOTIFY, *PSECPKG_EVENT_NOTIFY ;
  504. typedef
  505. NTSTATUS
  506. (NTAPI LSA_UPDATE_PRIMARY_CREDENTIALS)(
  507. IN PSECPKG_PRIMARY_CRED PrimaryCredentials,
  508. IN OPTIONAL PSECPKG_SUPPLEMENTAL_CRED_ARRAY Credentials
  509. );
  510. typedef
  511. VOID
  512. (NTAPI LSA_PROTECT_MEMORY)(
  513. IN PVOID Buffer,
  514. IN ULONG BufferSize
  515. );
  516. typedef
  517. NTSTATUS
  518. (NTAPI LSA_OPEN_TOKEN_BY_LOGON_ID)(
  519. IN PLUID LogonId,
  520. OUT HANDLE *RetTokenHandle
  521. );
  522. typedef
  523. NTSTATUS
  524. (NTAPI LSA_EXPAND_AUTH_DATA_FOR_DOMAIN)(
  525. IN PUCHAR UserAuthData,
  526. IN ULONG UserAuthDataSize,
  527. IN PVOID Reserved,
  528. OUT PUCHAR * ExpandedAuthData,
  529. OUT PULONG ExpandedAuthDataSize
  530. );
  531. typedef LSA_IMPERSONATE_CLIENT * PLSA_IMPERSONATE_CLIENT;
  532. typedef LSA_UNLOAD_PACKAGE * PLSA_UNLOAD_PACKAGE;
  533. typedef LSA_DUPLICATE_HANDLE * PLSA_DUPLICATE_HANDLE ;
  534. typedef LSA_SAVE_SUPPLEMENTAL_CREDENTIALS * PLSA_SAVE_SUPPLEMENTAL_CREDENTIALS;
  535. typedef LSA_CREATE_THREAD * PLSA_CREATE_THREAD;
  536. typedef LSA_GET_CLIENT_INFO * PLSA_GET_CLIENT_INFO;
  537. typedef LSA_REGISTER_NOTIFICATION * PLSA_REGISTER_NOTIFICATION;
  538. typedef LSA_CANCEL_NOTIFICATION * PLSA_CANCEL_NOTIFICATION;
  539. typedef LSA_MAP_BUFFER * PLSA_MAP_BUFFER;
  540. typedef LSA_CREATE_TOKEN * PLSA_CREATE_TOKEN;
  541. typedef LSA_AUDIT_LOGON * PLSA_AUDIT_LOGON;
  542. typedef LSA_CALL_PACKAGE * PLSA_CALL_PACKAGE;
  543. typedef LSA_CALL_PACKAGEEX * PLSA_CALL_PACKAGEEX;
  544. typedef LSA_GET_CALL_INFO * PLSA_GET_CALL_INFO ;
  545. typedef LSA_CREATE_SHARED_MEMORY * PLSA_CREATE_SHARED_MEMORY ;
  546. typedef LSA_ALLOCATE_SHARED_MEMORY * PLSA_ALLOCATE_SHARED_MEMORY ;
  547. typedef LSA_FREE_SHARED_MEMORY * PLSA_FREE_SHARED_MEMORY ;
  548. typedef LSA_DELETE_SHARED_MEMORY * PLSA_DELETE_SHARED_MEMORY ;
  549. typedef LSA_OPEN_SAM_USER * PLSA_OPEN_SAM_USER ;
  550. typedef LSA_GET_USER_CREDENTIALS * PLSA_GET_USER_CREDENTIALS ;
  551. typedef LSA_GET_USER_AUTH_DATA * PLSA_GET_USER_AUTH_DATA ;
  552. typedef LSA_CLOSE_SAM_USER * PLSA_CLOSE_SAM_USER ;
  553. typedef LSA_CONVERT_AUTH_DATA_TO_TOKEN * PLSA_CONVERT_AUTH_DATA_TO_TOKEN ;
  554. typedef LSA_CLIENT_CALLBACK * PLSA_CLIENT_CALLBACK ;
  555. typedef LSA_REGISTER_CALLBACK * PLSA_REGISTER_CALLBACK ;
  556. typedef LSA_UPDATE_PRIMARY_CREDENTIALS * PLSA_UPDATE_PRIMARY_CREDENTIALS;
  557. typedef LSA_GET_AUTH_DATA_FOR_USER * PLSA_GET_AUTH_DATA_FOR_USER ;
  558. typedef LSA_CRACK_SINGLE_NAME * PLSA_CRACK_SINGLE_NAME ;
  559. typedef LSA_AUDIT_ACCOUNT_LOGON * PLSA_AUDIT_ACCOUNT_LOGON ;
  560. typedef LSA_CALL_PACKAGE_PASSTHROUGH * PLSA_CALL_PACKAGE_PASSTHROUGH;
  561. typedef LSA_PROTECT_MEMORY * PLSA_PROTECT_MEMORY;
  562. typedef LSA_OPEN_TOKEN_BY_LOGON_ID * PLSA_OPEN_TOKEN_BY_LOGON_ID;
  563. typedef LSA_EXPAND_AUTH_DATA_FOR_DOMAIN * PLSA_EXPAND_AUTH_DATA_FOR_DOMAIN;
  564. typedef LSA_CREATE_TOKEN_EX * PLSA_CREATE_TOKEN_EX;
  565. #ifdef _WINCRED_H_
  566. //
  567. // When passing a credential around, the CredentialBlob field is encrypted.
  568. // This structure describes this encrypted form.
  569. //
  570. //
  571. #ifndef _ENCRYPTED_CREDENTIAL_DEFINED
  572. #define _ENCRYPTED_CREDENTIAL_DEFINED
  573. typedef struct _ENCRYPTED_CREDENTIALW {
  574. //
  575. // The credential
  576. //
  577. // The CredentialBlob field points to the encrypted credential
  578. // The CredentialBlobSize field is the length (in bytes) of the encrypted credential
  579. //
  580. CREDENTIALW Cred;
  581. //
  582. // The size in bytes of the clear text credential blob
  583. //
  584. ULONG ClearCredentialBlobSize;
  585. } ENCRYPTED_CREDENTIALW, *PENCRYPTED_CREDENTIALW;
  586. #endif // _ENCRYPTED_CREDENTIAL_DEFINED
  587. //
  588. // Values for CredFlags parameter
  589. //
  590. #define CREDP_FLAGS_IN_PROCESS 0x01 // Caller is in-process. Password data may be returned
  591. #define CREDP_FLAGS_USE_MIDL_HEAP 0x02 // Allocated buffer should use MIDL_user_allocte
  592. #define CREDP_FLAGS_DONT_CACHE_TI 0x04 // TargetInformation shouldn't be cached for CredGetTargetInfo
  593. #define CREDP_FLAGS_CLEAR_PASSWORD 0x08 // Credential blob is passed in in-the-clear
  594. #define CREDP_FLAGS_USER_ENCRYPTED_PASSWORD 0x10 // Credential blob is passed protected by RtlEncryptMemory
  595. typedef NTSTATUS
  596. (NTAPI CredReadFn) (
  597. IN PLUID LogonId,
  598. IN ULONG CredFlags,
  599. IN LPWSTR TargetName,
  600. IN ULONG Type,
  601. IN ULONG Flags,
  602. OUT PENCRYPTED_CREDENTIALW *Credential
  603. );
  604. typedef NTSTATUS
  605. (NTAPI CredReadDomainCredentialsFn) (
  606. IN PLUID LogonId,
  607. IN ULONG CredFlags,
  608. IN PCREDENTIAL_TARGET_INFORMATIONW TargetInfo,
  609. IN ULONG Flags,
  610. OUT PULONG Count,
  611. OUT PENCRYPTED_CREDENTIALW **Credential
  612. );
  613. typedef VOID
  614. (NTAPI CredFreeCredentialsFn) (
  615. IN ULONG Count,
  616. IN PENCRYPTED_CREDENTIALW *Credentials OPTIONAL
  617. );
  618. typedef NTSTATUS
  619. (NTAPI CredWriteFn) (
  620. IN PLUID LogonId,
  621. IN ULONG CredFlags,
  622. IN PENCRYPTED_CREDENTIALW Credential,
  623. IN ULONG Flags
  624. );
  625. NTSTATUS
  626. CredMarshalTargetInfo (
  627. IN PCREDENTIAL_TARGET_INFORMATIONW InTargetInfo,
  628. OUT PUSHORT *Buffer,
  629. OUT PULONG BufferSize
  630. );
  631. NTSTATUS
  632. CredUnmarshalTargetInfo (
  633. IN PUSHORT Buffer,
  634. IN ULONG BufferSize,
  635. OUT PCREDENTIAL_TARGET_INFORMATIONW *RetTargetInfo OPTIONAL,
  636. OUT PULONG RetActualSize OPTIONAL
  637. );
  638. // Number of bytes consumed by the trailing size ULONG
  639. #define CRED_MARSHALED_TI_SIZE_SIZE 12
  640. #endif // _WINCRED_H_
  641. //
  642. // Pure 32-bit versions of credential structures for packages
  643. // running wow64:
  644. //
  645. typedef struct _SEC_WINNT_AUTH_IDENTITY32 {
  646. ULONG User ;
  647. ULONG UserLength ;
  648. ULONG Domain ;
  649. ULONG DomainLength ;
  650. ULONG Password ;
  651. ULONG PasswordLength ;
  652. ULONG Flags ;
  653. } SEC_WINNT_AUTH_IDENTITY32, * PSEC_WINNT_AUTH_IDENTITY32 ;
  654. typedef struct _SEC_WINNT_AUTH_IDENTITY_EX32 {
  655. ULONG Version ;
  656. ULONG Length ;
  657. ULONG User ;
  658. ULONG UserLength ;
  659. ULONG Domain ;
  660. ULONG DomainLength ;
  661. ULONG Password ;
  662. ULONG PasswordLength ;
  663. ULONG Flags ;
  664. ULONG PackageList ;
  665. ULONG PackageListLength ;
  666. } SEC_WINNT_AUTH_IDENTITY_EX32, * PSEC_WINNT_AUTH_IDENTITY_EX32 ;
  667. // Functions provided by the SPM to the packages:
  668. typedef struct _LSA_SECPKG_FUNCTION_TABLE {
  669. PLSA_CREATE_LOGON_SESSION CreateLogonSession;
  670. PLSA_DELETE_LOGON_SESSION DeleteLogonSession;
  671. PLSA_ADD_CREDENTIAL AddCredential;
  672. PLSA_GET_CREDENTIALS GetCredentials;
  673. PLSA_DELETE_CREDENTIAL DeleteCredential;
  674. PLSA_ALLOCATE_LSA_HEAP AllocateLsaHeap;
  675. PLSA_FREE_LSA_HEAP FreeLsaHeap;
  676. PLSA_ALLOCATE_CLIENT_BUFFER AllocateClientBuffer;
  677. PLSA_FREE_CLIENT_BUFFER FreeClientBuffer;
  678. PLSA_COPY_TO_CLIENT_BUFFER CopyToClientBuffer;
  679. PLSA_COPY_FROM_CLIENT_BUFFER CopyFromClientBuffer;
  680. PLSA_IMPERSONATE_CLIENT ImpersonateClient;
  681. PLSA_UNLOAD_PACKAGE UnloadPackage;
  682. PLSA_DUPLICATE_HANDLE DuplicateHandle;
  683. PLSA_SAVE_SUPPLEMENTAL_CREDENTIALS SaveSupplementalCredentials;
  684. PLSA_CREATE_THREAD CreateThread;
  685. PLSA_GET_CLIENT_INFO GetClientInfo;
  686. PLSA_REGISTER_NOTIFICATION RegisterNotification;
  687. PLSA_CANCEL_NOTIFICATION CancelNotification;
  688. PLSA_MAP_BUFFER MapBuffer;
  689. PLSA_CREATE_TOKEN CreateToken;
  690. PLSA_AUDIT_LOGON AuditLogon;
  691. PLSA_CALL_PACKAGE CallPackage;
  692. PLSA_FREE_LSA_HEAP FreeReturnBuffer;
  693. PLSA_GET_CALL_INFO GetCallInfo;
  694. PLSA_CALL_PACKAGEEX CallPackageEx;
  695. PLSA_CREATE_SHARED_MEMORY CreateSharedMemory;
  696. PLSA_ALLOCATE_SHARED_MEMORY AllocateSharedMemory;
  697. PLSA_FREE_SHARED_MEMORY FreeSharedMemory;
  698. PLSA_DELETE_SHARED_MEMORY DeleteSharedMemory;
  699. PLSA_OPEN_SAM_USER OpenSamUser ;
  700. PLSA_GET_USER_CREDENTIALS GetUserCredentials ;
  701. PLSA_GET_USER_AUTH_DATA GetUserAuthData ;
  702. PLSA_CLOSE_SAM_USER CloseSamUser ;
  703. PLSA_CONVERT_AUTH_DATA_TO_TOKEN ConvertAuthDataToToken ;
  704. PLSA_CLIENT_CALLBACK ClientCallback ;
  705. PLSA_UPDATE_PRIMARY_CREDENTIALS UpdateCredentials ;
  706. PLSA_GET_AUTH_DATA_FOR_USER GetAuthDataForUser ;
  707. PLSA_CRACK_SINGLE_NAME CrackSingleName ;
  708. PLSA_AUDIT_ACCOUNT_LOGON AuditAccountLogon ;
  709. PLSA_CALL_PACKAGE_PASSTHROUGH CallPackagePassthrough ;
  710. #ifdef _WINCRED_H_
  711. CredReadFn *CrediRead;
  712. CredReadDomainCredentialsFn *CrediReadDomainCredentials;
  713. CredFreeCredentialsFn *CrediFreeCredentials;
  714. #else // _WINCRED_H_
  715. PLSA_PROTECT_MEMORY DummyFunction1;
  716. PLSA_PROTECT_MEMORY DummyFunction2;
  717. PLSA_PROTECT_MEMORY DummyFunction3;
  718. #endif // _WINCRED_H_
  719. PLSA_PROTECT_MEMORY LsaProtectMemory;
  720. PLSA_PROTECT_MEMORY LsaUnprotectMemory;
  721. PLSA_OPEN_TOKEN_BY_LOGON_ID OpenTokenByLogonId;
  722. PLSA_EXPAND_AUTH_DATA_FOR_DOMAIN ExpandAuthDataForDomain;
  723. PLSA_ALLOCATE_PRIVATE_HEAP AllocatePrivateHeap;
  724. PLSA_FREE_PRIVATE_HEAP FreePrivateHeap;
  725. PLSA_CREATE_TOKEN_EX CreateTokenEx;
  726. #ifdef _WINCRED_H_
  727. CredWriteFn *CrediWrite;
  728. #else // _WINCRED_H_
  729. PLSA_PROTECT_MEMORY DummyFunction4;
  730. #endif // _WINCRED_H_
  731. } LSA_SECPKG_FUNCTION_TABLE, *PLSA_SECPKG_FUNCTION_TABLE;
  732. typedef struct _SECPKG_DLL_FUNCTIONS {
  733. PLSA_ALLOCATE_LSA_HEAP AllocateHeap;
  734. PLSA_FREE_LSA_HEAP FreeHeap;
  735. PLSA_REGISTER_CALLBACK RegisterCallback ;
  736. } SECPKG_DLL_FUNCTIONS, * PSECPKG_DLL_FUNCTIONS;
  737. //
  738. // The following prototypes are to functions that will be called only while
  739. // in the Security Package Manager context.
  740. //
  741. typedef NTSTATUS
  742. (NTAPI SpInitializeFn)(
  743. IN ULONG_PTR PackageId,
  744. IN PSECPKG_PARAMETERS Parameters,
  745. IN PLSA_SECPKG_FUNCTION_TABLE FunctionTable
  746. );
  747. typedef NTSTATUS
  748. (NTAPI SpShutdownFn)(
  749. VOID
  750. );
  751. typedef NTSTATUS
  752. (NTAPI SpGetInfoFn)(
  753. OUT PSecPkgInfo PackageInfo
  754. );
  755. typedef NTSTATUS
  756. (NTAPI SpGetExtendedInformationFn)(
  757. IN SECPKG_EXTENDED_INFORMATION_CLASS Class,
  758. OUT PSECPKG_EXTENDED_INFORMATION * ppInformation
  759. );
  760. typedef NTSTATUS
  761. (NTAPI SpSetExtendedInformationFn)(
  762. IN SECPKG_EXTENDED_INFORMATION_CLASS Class,
  763. IN PSECPKG_EXTENDED_INFORMATION Info
  764. );
  765. typedef NTSTATUS
  766. (LSA_AP_LOGON_USER_EX2) (
  767. IN PLSA_CLIENT_REQUEST ClientRequest,
  768. IN SECURITY_LOGON_TYPE LogonType,
  769. IN PVOID AuthenticationInformation,
  770. IN PVOID ClientAuthenticationBase,
  771. IN ULONG AuthenticationInformationLength,
  772. OUT PVOID *ProfileBuffer,
  773. OUT PULONG ProfileBufferLength,
  774. OUT PLUID LogonId,
  775. OUT PNTSTATUS SubStatus,
  776. OUT PLSA_TOKEN_INFORMATION_TYPE TokenInformationType,
  777. OUT PVOID *TokenInformation,
  778. OUT PUNICODE_STRING *AccountName,
  779. OUT PUNICODE_STRING *AuthenticatingAuthority,
  780. OUT PUNICODE_STRING *MachineName,
  781. OUT PSECPKG_PRIMARY_CRED PrimaryCredentials,
  782. OUT PSECPKG_SUPPLEMENTAL_CRED_ARRAY * CachedCredentials
  783. );
  784. typedef LSA_AP_LOGON_USER_EX2 *PLSA_AP_LOGON_USER_EX2;
  785. #define LSA_AP_NAME_LOGON_USER_EX2 "LsaApLogonUserEx2\0"
  786. typedef NTSTATUS
  787. (NTAPI SpAcceptCredentialsFn)(
  788. IN SECURITY_LOGON_TYPE LogonType,
  789. IN PUNICODE_STRING AccountName,
  790. IN PSECPKG_PRIMARY_CRED PrimaryCredentials,
  791. IN PSECPKG_SUPPLEMENTAL_CRED SupplementalCredentials
  792. );
  793. #define SP_ACCEPT_CREDENTIALS_NAME "SpAcceptCredentials\0"
  794. typedef NTSTATUS
  795. (NTAPI SpAcquireCredentialsHandleFn)(
  796. IN OPTIONAL PUNICODE_STRING PrincipalName,
  797. IN ULONG CredentialUseFlags,
  798. IN OPTIONAL PLUID LogonId,
  799. IN PVOID AuthorizationData,
  800. IN PVOID GetKeyFunciton,
  801. IN PVOID GetKeyArgument,
  802. OUT PLSA_SEC_HANDLE CredentialHandle,
  803. OUT PTimeStamp ExpirationTime
  804. );
  805. typedef NTSTATUS
  806. (NTAPI SpFreeCredentialsHandleFn)(
  807. IN LSA_SEC_HANDLE CredentialHandle
  808. );
  809. typedef NTSTATUS
  810. (NTAPI SpQueryCredentialsAttributesFn)(
  811. IN LSA_SEC_HANDLE CredentialHandle,
  812. IN ULONG CredentialAttribute,
  813. IN OUT PVOID Buffer
  814. );
  815. typedef NTSTATUS
  816. (NTAPI SpAddCredentialsFn)(
  817. IN LSA_SEC_HANDLE CredentialHandle,
  818. IN OPTIONAL PUNICODE_STRING PrincipalName,
  819. IN PUNICODE_STRING Package,
  820. IN ULONG CredentialUseFlags,
  821. IN PVOID AuthorizationData,
  822. IN PVOID GetKeyFunciton,
  823. IN PVOID GetKeyArgument,
  824. OUT PTimeStamp ExpirationTime
  825. );
  826. typedef NTSTATUS
  827. (NTAPI SpSaveCredentialsFn)(
  828. IN LSA_SEC_HANDLE CredentialHandle,
  829. IN PSecBuffer Credentials);
  830. typedef NTSTATUS
  831. (NTAPI SpGetCredentialsFn)(
  832. IN LSA_SEC_HANDLE CredentialHandle,
  833. IN OUT PSecBuffer Credentials
  834. );
  835. typedef NTSTATUS
  836. (NTAPI SpDeleteCredentialsFn)(
  837. IN LSA_SEC_HANDLE CredentialHandle,
  838. IN PSecBuffer Key
  839. );
  840. typedef NTSTATUS
  841. (NTAPI SpInitLsaModeContextFn)(
  842. IN OPTIONAL LSA_SEC_HANDLE CredentialHandle,
  843. IN OPTIONAL LSA_SEC_HANDLE ContextHandle,
  844. IN OPTIONAL PUNICODE_STRING TargetName,
  845. IN ULONG ContextRequirements,
  846. IN ULONG TargetDataRep,
  847. IN PSecBufferDesc InputBuffers,
  848. OUT PLSA_SEC_HANDLE NewContextHandle,
  849. IN OUT PSecBufferDesc OutputBuffers,
  850. OUT PULONG ContextAttributes,
  851. OUT PTimeStamp ExpirationTime,
  852. OUT PBOOLEAN MappedContext,
  853. OUT PSecBuffer ContextData
  854. );
  855. typedef NTSTATUS
  856. (NTAPI SpDeleteContextFn)(
  857. IN LSA_SEC_HANDLE ContextHandle
  858. );
  859. typedef NTSTATUS
  860. (NTAPI SpApplyControlTokenFn)(
  861. IN LSA_SEC_HANDLE ContextHandle,
  862. IN PSecBufferDesc ControlToken);
  863. typedef NTSTATUS
  864. (NTAPI SpAcceptLsaModeContextFn)(
  865. IN OPTIONAL LSA_SEC_HANDLE CredentialHandle,
  866. IN OPTIONAL LSA_SEC_HANDLE ContextHandle,
  867. IN PSecBufferDesc InputBuffer,
  868. IN ULONG ContextRequirements,
  869. IN ULONG TargetDataRep,
  870. OUT PLSA_SEC_HANDLE NewContextHandle,
  871. OUT PSecBufferDesc OutputBuffer,
  872. OUT PULONG ContextAttributes,
  873. OUT PTimeStamp ExpirationTime,
  874. OUT PBOOLEAN MappedContext,
  875. OUT PSecBuffer ContextData
  876. );
  877. typedef NTSTATUS
  878. (NTAPI SpGetUserInfoFn)(
  879. IN PLUID LogonId,
  880. IN ULONG Flags,
  881. OUT PSecurityUserData * UserData
  882. );
  883. typedef NTSTATUS
  884. (NTAPI SpQueryContextAttributesFn)(
  885. IN LSA_SEC_HANDLE ContextHandle,
  886. IN ULONG ContextAttribute,
  887. IN OUT PVOID Buffer);
  888. typedef NTSTATUS
  889. (NTAPI SpSetContextAttributesFn)(
  890. IN LSA_SEC_HANDLE ContextHandle,
  891. IN ULONG ContextAttribute,
  892. IN PVOID Buffer,
  893. IN ULONG BufferSize );
  894. typedef struct _SECPKG_FUNCTION_TABLE {
  895. PLSA_AP_INITIALIZE_PACKAGE InitializePackage;
  896. PLSA_AP_LOGON_USER LogonUser;
  897. PLSA_AP_CALL_PACKAGE CallPackage;
  898. PLSA_AP_LOGON_TERMINATED LogonTerminated;
  899. PLSA_AP_CALL_PACKAGE_UNTRUSTED CallPackageUntrusted;
  900. PLSA_AP_CALL_PACKAGE_PASSTHROUGH CallPackagePassthrough;
  901. PLSA_AP_LOGON_USER_EX LogonUserEx;
  902. PLSA_AP_LOGON_USER_EX2 LogonUserEx2;
  903. SpInitializeFn * Initialize;
  904. SpShutdownFn * Shutdown;
  905. SpGetInfoFn * GetInfo;
  906. SpAcceptCredentialsFn * AcceptCredentials;
  907. SpAcquireCredentialsHandleFn * AcquireCredentialsHandle;
  908. SpQueryCredentialsAttributesFn * QueryCredentialsAttributes;
  909. SpFreeCredentialsHandleFn * FreeCredentialsHandle;
  910. SpSaveCredentialsFn * SaveCredentials;
  911. SpGetCredentialsFn * GetCredentials;
  912. SpDeleteCredentialsFn * DeleteCredentials;
  913. SpInitLsaModeContextFn * InitLsaModeContext;
  914. SpAcceptLsaModeContextFn * AcceptLsaModeContext;
  915. SpDeleteContextFn * DeleteContext;
  916. SpApplyControlTokenFn * ApplyControlToken;
  917. SpGetUserInfoFn * GetUserInfo;
  918. SpGetExtendedInformationFn * GetExtendedInformation ;
  919. SpQueryContextAttributesFn * QueryContextAttributes ;
  920. SpAddCredentialsFn * AddCredentials ;
  921. SpSetExtendedInformationFn * SetExtendedInformation ;
  922. SpSetContextAttributesFn * SetContextAttributes ;
  923. } SECPKG_FUNCTION_TABLE, *PSECPKG_FUNCTION_TABLE;
  924. //
  925. // The following prototypes are to functions that will be called while in the
  926. // context of a user process that is using the functions through the security
  927. // DLL.
  928. //
  929. typedef NTSTATUS
  930. (NTAPI SpInstanceInitFn)(
  931. IN ULONG Version,
  932. IN PSECPKG_DLL_FUNCTIONS FunctionTable,
  933. OUT PVOID * UserFunctions
  934. );
  935. typedef NTSTATUS
  936. (NTAPI SpInitUserModeContextFn)(
  937. IN LSA_SEC_HANDLE ContextHandle,
  938. IN PSecBuffer PackedContext
  939. );
  940. typedef NTSTATUS
  941. (NTAPI SpMakeSignatureFn)(
  942. IN LSA_SEC_HANDLE ContextHandle,
  943. IN ULONG QualityOfProtection,
  944. IN PSecBufferDesc MessageBuffers,
  945. IN ULONG MessageSequenceNumber
  946. );
  947. typedef NTSTATUS
  948. (NTAPI SpVerifySignatureFn)(
  949. IN LSA_SEC_HANDLE ContextHandle,
  950. IN PSecBufferDesc MessageBuffers,
  951. IN ULONG MessageSequenceNumber,
  952. OUT PULONG QualityOfProtection
  953. );
  954. typedef NTSTATUS
  955. (NTAPI SpSealMessageFn)(
  956. IN LSA_SEC_HANDLE ContextHandle,
  957. IN ULONG QualityOfProtection,
  958. IN PSecBufferDesc MessageBuffers,
  959. IN ULONG MessageSequenceNumber
  960. );
  961. typedef NTSTATUS
  962. (NTAPI SpUnsealMessageFn)(
  963. IN LSA_SEC_HANDLE ContextHandle,
  964. IN PSecBufferDesc MessageBuffers,
  965. IN ULONG MessageSequenceNumber,
  966. OUT PULONG QualityOfProtection
  967. );
  968. typedef NTSTATUS
  969. (NTAPI SpGetContextTokenFn)(
  970. IN LSA_SEC_HANDLE ContextHandle,
  971. OUT PHANDLE ImpersonationToken
  972. );
  973. typedef NTSTATUS
  974. (NTAPI SpExportSecurityContextFn)(
  975. LSA_SEC_HANDLE phContext, // (in) context to export
  976. ULONG fFlags, // (in) option flags
  977. PSecBuffer pPackedContext, // (out) marshalled context
  978. PHANDLE pToken // (out, optional) token handle for impersonation
  979. );
  980. typedef NTSTATUS
  981. (NTAPI SpImportSecurityContextFn)(
  982. PSecBuffer pPackedContext, // (in) marshalled context
  983. HANDLE Token, // (in, optional) handle to token for context
  984. PLSA_SEC_HANDLE phContext // (out) new context handle
  985. );
  986. typedef NTSTATUS
  987. (NTAPI SpCompleteAuthTokenFn)(
  988. IN LSA_SEC_HANDLE ContextHandle,
  989. IN PSecBufferDesc InputBuffer
  990. );
  991. typedef NTSTATUS
  992. (NTAPI SpFormatCredentialsFn)(
  993. IN PSecBuffer Credentials,
  994. OUT PSecBuffer FormattedCredentials
  995. );
  996. typedef NTSTATUS
  997. (NTAPI SpMarshallSupplementalCredsFn)(
  998. IN ULONG CredentialSize,
  999. IN PUCHAR Credentials,
  1000. OUT PULONG MarshalledCredSize,
  1001. OUT PVOID * MarshalledCreds);
  1002. typedef struct _SECPKG_USER_FUNCTION_TABLE {
  1003. SpInstanceInitFn * InstanceInit;
  1004. SpInitUserModeContextFn * InitUserModeContext;
  1005. SpMakeSignatureFn * MakeSignature;
  1006. SpVerifySignatureFn * VerifySignature;
  1007. SpSealMessageFn * SealMessage;
  1008. SpUnsealMessageFn * UnsealMessage;
  1009. SpGetContextTokenFn * GetContextToken;
  1010. SpQueryContextAttributesFn * QueryContextAttributes;
  1011. SpCompleteAuthTokenFn * CompleteAuthToken;
  1012. SpDeleteContextFn * DeleteUserModeContext;
  1013. SpFormatCredentialsFn * FormatCredentials;
  1014. SpMarshallSupplementalCredsFn * MarshallSupplementalCreds;
  1015. SpExportSecurityContextFn * ExportContext;
  1016. SpImportSecurityContextFn * ImportContext;
  1017. } SECPKG_USER_FUNCTION_TABLE, *PSECPKG_USER_FUNCTION_TABLE;
  1018. typedef NTSTATUS
  1019. (SEC_ENTRY * SpLsaModeInitializeFn)(
  1020. IN ULONG LsaVersion,
  1021. OUT PULONG PackageVersion,
  1022. OUT PSECPKG_FUNCTION_TABLE * ppTables,
  1023. OUT PULONG pcTables);
  1024. typedef NTSTATUS
  1025. (SEC_ENTRY * SpUserModeInitializeFn)(
  1026. IN ULONG LsaVersion,
  1027. OUT PULONG PackageVersion,
  1028. OUT PSECPKG_USER_FUNCTION_TABLE *ppTables,
  1029. OUT PULONG pcTables
  1030. );
  1031. #define SECPKG_LSAMODEINIT_NAME "SpLsaModeInitialize"
  1032. #define SECPKG_USERMODEINIT_NAME "SpUserModeInitialize"
  1033. //
  1034. // Version of the security package interface.
  1035. //
  1036. // These define are used for all of the following:
  1037. // * Passed by the LSA to SpLsaModeInitializeFn to indicate the version of the LSA.
  1038. // All packages currently expect the LSA to pass SECPKG_INTERFACE_VERSION.
  1039. // * Passed by secur32.dll to SpUserModeInitialzeFn to indicate the version of the secur32 DLL.
  1040. // All packages currently expect secur32 to pass SECPKG_INTERFACE_VERSION.
  1041. // * Returned from SpLsaModeInitializeFn to indicate the version of SECPKG_FUNCTION_TABLE.
  1042. // SECPKG_INTERFACE_VERSION indicates all fields through SetExtendedInformation are defined (potentially to NULL)
  1043. // SECPKG_INTERFACE_VERSION_2 indicates all fields through SetContextAttributes are defined (potentially to NULL)
  1044. // * Returned from SpUserModeInitializeFn to indicate the version of the auth package.
  1045. // All packages currently return SECPKG_INTERFACE_VERSION
  1046. //
  1047. #define SECPKG_INTERFACE_VERSION 0x00010000
  1048. #define SECPKG_INTERFACE_VERSION_2 0x00020000
  1049. typedef enum _KSEC_CONTEXT_TYPE {
  1050. KSecPaged,
  1051. KSecNonPaged
  1052. } KSEC_CONTEXT_TYPE ;
  1053. typedef struct _KSEC_LIST_ENTRY {
  1054. LIST_ENTRY List ;
  1055. LONG RefCount ;
  1056. ULONG Signature ;
  1057. PVOID OwningList ;
  1058. PVOID Reserved ;
  1059. } KSEC_LIST_ENTRY, * PKSEC_LIST_ENTRY ;
  1060. #define KsecInitializeListEntry( Entry, SigValue ) \
  1061. ((PKSEC_LIST_ENTRY) Entry)->List.Flink = ((PKSEC_LIST_ENTRY) Entry)->List.Blink = NULL ; \
  1062. ((PKSEC_LIST_ENTRY) Entry)->RefCount = 1 ; \
  1063. ((PKSEC_LIST_ENTRY) Entry)->Signature = SigValue ; \
  1064. ((PKSEC_LIST_ENTRY) Entry)->OwningList = NULL ; \
  1065. ((PKSEC_LIST_ENTRY) Entry)->Reserved = NULL ;
  1066. typedef PVOID
  1067. (SEC_ENTRY KSEC_CREATE_CONTEXT_LIST)(
  1068. IN KSEC_CONTEXT_TYPE Type
  1069. );
  1070. typedef VOID
  1071. (SEC_ENTRY KSEC_INSERT_LIST_ENTRY)(
  1072. IN PVOID List,
  1073. IN PKSEC_LIST_ENTRY Entry
  1074. );
  1075. typedef NTSTATUS
  1076. (SEC_ENTRY KSEC_REFERENCE_LIST_ENTRY)(
  1077. IN PKSEC_LIST_ENTRY Entry,
  1078. IN ULONG Signature,
  1079. IN BOOLEAN RemoveNoRef
  1080. );
  1081. typedef VOID
  1082. (SEC_ENTRY KSEC_DEREFERENCE_LIST_ENTRY)(
  1083. IN PKSEC_LIST_ENTRY Entry,
  1084. OUT BOOLEAN * Delete OPTIONAL
  1085. );
  1086. typedef NTSTATUS
  1087. (SEC_ENTRY KSEC_SERIALIZE_WINNT_AUTH_DATA)(
  1088. IN PVOID pvAuthData,
  1089. OUT PULONG Size,
  1090. OUT PVOID * SerializedData );
  1091. #ifndef MIDL_PASS
  1092. KSEC_CREATE_CONTEXT_LIST KSecCreateContextList ;
  1093. KSEC_INSERT_LIST_ENTRY KSecInsertListEntry ;
  1094. KSEC_REFERENCE_LIST_ENTRY KSecReferenceListEntry ;
  1095. KSEC_DEREFERENCE_LIST_ENTRY KSecDereferenceListEntry ;
  1096. KSEC_SERIALIZE_WINNT_AUTH_DATA KSecSerializeWinntAuthData ;
  1097. #endif // not valid for MIDL_PASS
  1098. typedef KSEC_CREATE_CONTEXT_LIST * PKSEC_CREATE_CONTEXT_LIST ;
  1099. typedef KSEC_INSERT_LIST_ENTRY * PKSEC_INSERT_LIST_ENTRY ;
  1100. typedef KSEC_REFERENCE_LIST_ENTRY * PKSEC_REFERENCE_LIST_ENTRY ;
  1101. typedef KSEC_DEREFERENCE_LIST_ENTRY * PKSEC_DEREFERENCE_LIST_ENTRY ;
  1102. typedef KSEC_SERIALIZE_WINNT_AUTH_DATA * PKSEC_SERIALIZE_WINNT_AUTH_DATA ;
  1103. typedef struct _SECPKG_KERNEL_FUNCTIONS {
  1104. PLSA_ALLOCATE_LSA_HEAP AllocateHeap;
  1105. PLSA_FREE_LSA_HEAP FreeHeap;
  1106. PKSEC_CREATE_CONTEXT_LIST CreateContextList ;
  1107. PKSEC_INSERT_LIST_ENTRY InsertListEntry ;
  1108. PKSEC_REFERENCE_LIST_ENTRY ReferenceListEntry ;
  1109. PKSEC_DEREFERENCE_LIST_ENTRY DereferenceListEntry ;
  1110. PKSEC_SERIALIZE_WINNT_AUTH_DATA SerializeWinntAuthData ;
  1111. } SECPKG_KERNEL_FUNCTIONS, *PSECPKG_KERNEL_FUNCTIONS;
  1112. typedef NTSTATUS
  1113. (NTAPI KspInitPackageFn)(
  1114. PSECPKG_KERNEL_FUNCTIONS FunctionTable
  1115. );
  1116. typedef NTSTATUS
  1117. (NTAPI KspDeleteContextFn)(
  1118. IN LSA_SEC_HANDLE ContextId,
  1119. OUT PLSA_SEC_HANDLE LsaContextId
  1120. );
  1121. typedef NTSTATUS
  1122. (NTAPI KspInitContextFn)(
  1123. IN LSA_SEC_HANDLE ContextId,
  1124. IN PSecBuffer ContextData,
  1125. OUT PLSA_SEC_HANDLE NewContextId
  1126. );
  1127. typedef NTSTATUS
  1128. (NTAPI KspMakeSignatureFn)(
  1129. IN LSA_SEC_HANDLE ContextId,
  1130. IN ULONG fQOP,
  1131. IN OUT PSecBufferDesc Message,
  1132. IN ULONG MessageSeqNo
  1133. );
  1134. typedef NTSTATUS
  1135. (NTAPI KspVerifySignatureFn)(
  1136. IN LSA_SEC_HANDLE ContextId,
  1137. IN OUT PSecBufferDesc Message,
  1138. IN ULONG MessageSeqNo,
  1139. OUT PULONG pfQOP
  1140. );
  1141. typedef NTSTATUS
  1142. (NTAPI KspSealMessageFn)(
  1143. IN LSA_SEC_HANDLE ContextId,
  1144. IN ULONG fQOP,
  1145. IN OUT PSecBufferDesc Message,
  1146. IN ULONG MessageSeqNo
  1147. );
  1148. typedef NTSTATUS
  1149. (NTAPI KspUnsealMessageFn)(
  1150. IN LSA_SEC_HANDLE ContextId,
  1151. IN OUT PSecBufferDesc Message,
  1152. IN ULONG MessageSeqNo,
  1153. OUT PULONG pfQOP
  1154. );
  1155. typedef NTSTATUS
  1156. (NTAPI KspGetTokenFn)(
  1157. IN LSA_SEC_HANDLE ContextId,
  1158. OUT PHANDLE ImpersonationToken,
  1159. OUT OPTIONAL PACCESS_TOKEN * RawToken
  1160. );
  1161. typedef NTSTATUS
  1162. (NTAPI KspQueryAttributesFn)(
  1163. IN LSA_SEC_HANDLE ContextId,
  1164. IN ULONG Attribute,
  1165. IN OUT PVOID Buffer
  1166. );
  1167. typedef NTSTATUS
  1168. (NTAPI KspCompleteTokenFn)(
  1169. IN LSA_SEC_HANDLE ContextId,
  1170. IN PSecBufferDesc Token
  1171. );
  1172. typedef NTSTATUS
  1173. (NTAPI KspMapHandleFn)(
  1174. IN LSA_SEC_HANDLE ContextId,
  1175. OUT PLSA_SEC_HANDLE LsaContextId
  1176. );
  1177. typedef NTSTATUS
  1178. (NTAPI KspSetPagingModeFn)(
  1179. IN BOOLEAN PagingMode
  1180. );
  1181. typedef NTSTATUS
  1182. (NTAPI KspSerializeAuthDataFn)(
  1183. IN PVOID pvAuthData,
  1184. OUT PULONG Size,
  1185. OUT PVOID * SerializedData
  1186. );
  1187. typedef struct _SECPKG_KERNEL_FUNCTION_TABLE {
  1188. KspInitPackageFn * Initialize;
  1189. KspDeleteContextFn * DeleteContext;
  1190. KspInitContextFn * InitContext;
  1191. KspMapHandleFn * MapHandle;
  1192. KspMakeSignatureFn * Sign;
  1193. KspVerifySignatureFn * Verify;
  1194. KspSealMessageFn * Seal;
  1195. KspUnsealMessageFn * Unseal;
  1196. KspGetTokenFn * GetToken;
  1197. KspQueryAttributesFn * QueryAttributes;
  1198. KspCompleteTokenFn * CompleteToken;
  1199. SpExportSecurityContextFn * ExportContext;
  1200. SpImportSecurityContextFn * ImportContext;
  1201. KspSetPagingModeFn * SetPackagePagingMode ;
  1202. KspSerializeAuthDataFn * SerializeAuthData ;
  1203. } SECPKG_KERNEL_FUNCTION_TABLE, *PSECPKG_KERNEL_FUNCTION_TABLE;
  1204. SECURITY_STATUS
  1205. SEC_ENTRY
  1206. KSecRegisterSecurityProvider(
  1207. PSECURITY_STRING ProviderName,
  1208. PSECPKG_KERNEL_FUNCTION_TABLE Table
  1209. );
  1210. extern SECPKG_KERNEL_FUNCTIONS KspKernelFunctions;
  1211. // end_ntsecpkg
  1212. #endif // __SECPKG_H__