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.

1874 lines
53 KiB

  1. /*++ BUILD Version: 0000 Increment this if a change has global effects
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. ntsecpkg.h
  5. Abstract:
  6. This module defines the structures and APIs for use by a
  7. authentication or security package.
  8. Revision History:
  9. --*/
  10. #ifndef _NTSECPKG_
  11. #define _NTSECPKG_
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. /////////////////////////////////////////////////////////////////////////
  16. // //
  17. // Data types used by authentication packages //
  18. // //
  19. /////////////////////////////////////////////////////////////////////////
  20. //
  21. // opaque data type which represents a client request
  22. //
  23. typedef PVOID *PLSA_CLIENT_REQUEST;
  24. //
  25. // When a logon of a user is requested, the authentication package
  26. // is expected to return one of the following structures indicating
  27. // the contents of a user's token.
  28. //
  29. typedef enum _LSA_TOKEN_INFORMATION_TYPE {
  30. LsaTokenInformationNull, // Implies LSA_TOKEN_INFORMATION_NULL data type
  31. LsaTokenInformationV1, // Implies LSA_TOKEN_INFORMATION_V1 data type
  32. LsaTokenInformationV2 // Implies LSA_TOKEN_INFORMATION_V2 data type
  33. } LSA_TOKEN_INFORMATION_TYPE, *PLSA_TOKEN_INFORMATION_TYPE;
  34. //
  35. // The NULL information is used in cases where a non-authenticated
  36. // system access is needed. For example, a non-authentication network
  37. // circuit (such as LAN Manager's null session) can be given NULL
  38. // information. This will result in an anonymous token being generated
  39. // for the logon that gives the user no ability to access protected system
  40. // resources, but does allow access to non-protected system resources.
  41. //
  42. typedef struct _LSA_TOKEN_INFORMATION_NULL {
  43. //
  44. // Time at which the security context becomes invalid.
  45. // Use a value in the distant future if the context
  46. // never expires.
  47. //
  48. LARGE_INTEGER ExpirationTime;
  49. //
  50. // The SID(s) of groups the user is to be made a member of. This should
  51. // not include WORLD or other system defined and assigned
  52. // SIDs. These will be added automatically by LSA.
  53. //
  54. // Each SID is expected to be in a separately allocated block
  55. // of memory. The TOKEN_GROUPS structure is also expected to
  56. // be in a separately allocated block of memory.
  57. //
  58. PTOKEN_GROUPS Groups;
  59. } LSA_TOKEN_INFORMATION_NULL, *PLSA_TOKEN_INFORMATION_NULL;
  60. //
  61. // The V1 token information structure is superceeded by the V2 token
  62. // information structure. The V1 strucure should only be used for
  63. // backwards compatability.
  64. // This structure contains information that an authentication package
  65. // can place in a Version 1 NT token object.
  66. //
  67. typedef struct _LSA_TOKEN_INFORMATION_V1 {
  68. //
  69. // Time at which the security context becomes invalid.
  70. // Use a value in the distant future if the context
  71. // never expires.
  72. //
  73. LARGE_INTEGER ExpirationTime;
  74. //
  75. // The SID of the user logging on. The SID value is in a
  76. // separately allocated block of memory.
  77. //
  78. TOKEN_USER User;
  79. //
  80. // The SID(s) of groups the user is a member of. This should
  81. // not include WORLD or other system defined and assigned
  82. // SIDs. These will be added automatically by LSA.
  83. //
  84. // Each SID is expected to be in a separately allocated block
  85. // of memory. The TOKEN_GROUPS structure is also expected to
  86. // be in a separately allocated block of memory.
  87. //
  88. PTOKEN_GROUPS Groups;
  89. //
  90. // This field is used to establish the primary group of the user.
  91. // This value does not have to correspond to one of the SIDs
  92. // assigned to the user.
  93. //
  94. // The SID pointed to by this structure is expected to be in
  95. // a separately allocated block of memory.
  96. //
  97. // This field is mandatory and must be filled in.
  98. //
  99. TOKEN_PRIMARY_GROUP PrimaryGroup;
  100. //
  101. // The privileges the user is assigned. This list of privileges
  102. // will be augmented or over-ridden by any local security policy
  103. // assigned privileges.
  104. //
  105. // Each privilege is expected to be in a separately allocated
  106. // block of memory. The TOKEN_PRIVILEGES structure is also
  107. // expected to be in a separately allocated block of memory.
  108. //
  109. // If there are no privileges to assign to the user, this field
  110. // may be set to NULL.
  111. //
  112. PTOKEN_PRIVILEGES Privileges;
  113. //
  114. // This field may be used to establish an explicit default
  115. // owner. Normally, the user ID is used as the default owner.
  116. // If another value is desired, it must be specified here.
  117. //
  118. // The Owner.Sid field may be set to NULL to indicate there is no
  119. // alternate default owner value.
  120. //
  121. TOKEN_OWNER Owner;
  122. //
  123. // This field may be used to establish a default
  124. // protection for the user. If no value is provided, then
  125. // a default protection that grants everyone all access will
  126. // be established.
  127. //
  128. // The DefaultDacl.DefaultDacl field may be set to NULL to indicate
  129. // there is no default protection.
  130. //
  131. TOKEN_DEFAULT_DACL DefaultDacl;
  132. } LSA_TOKEN_INFORMATION_V1, *PLSA_TOKEN_INFORMATION_V1;
  133. //
  134. // The V2 information is used in most cases of logon. The structure is identical
  135. // to the V1 token information structure, with the exception that the memory allocation
  136. // is handled differently. The LSA_TOKEN_INFORMATION_V2 structure is intended to be
  137. // allocated monolithiclly, with the privileges, DACL, sids, and group array either part of
  138. // same allocation, or allocated and freed externally.
  139. //
  140. typedef LSA_TOKEN_INFORMATION_V1 LSA_TOKEN_INFORMATION_V2, *PLSA_TOKEN_INFORMATION_V2;
  141. /////////////////////////////////////////////////////////////////////////
  142. // //
  143. // Interface definitions available for use by authentication packages //
  144. // //
  145. /////////////////////////////////////////////////////////////////////////
  146. typedef NTSTATUS
  147. (NTAPI LSA_CREATE_LOGON_SESSION) (
  148. IN PLUID LogonId
  149. );
  150. typedef NTSTATUS
  151. (NTAPI LSA_DELETE_LOGON_SESSION) (
  152. IN PLUID LogonId
  153. );
  154. typedef NTSTATUS
  155. (NTAPI LSA_ADD_CREDENTIAL) (
  156. IN PLUID LogonId,
  157. IN ULONG AuthenticationPackage,
  158. IN PLSA_STRING PrimaryKeyValue,
  159. IN PLSA_STRING Credentials
  160. );
  161. typedef NTSTATUS
  162. (NTAPI LSA_GET_CREDENTIALS) (
  163. IN PLUID LogonId,
  164. IN ULONG AuthenticationPackage,
  165. IN OUT PULONG QueryContext,
  166. IN BOOLEAN RetrieveAllCredentials,
  167. IN PLSA_STRING PrimaryKeyValue,
  168. OUT PULONG PrimaryKeyLength,
  169. IN PLSA_STRING Credentials
  170. );
  171. typedef NTSTATUS
  172. (NTAPI LSA_DELETE_CREDENTIAL) (
  173. IN PLUID LogonId,
  174. IN ULONG AuthenticationPackage,
  175. IN PLSA_STRING PrimaryKeyValue
  176. );
  177. typedef PVOID
  178. (NTAPI LSA_ALLOCATE_LSA_HEAP) (
  179. IN ULONG Length
  180. );
  181. typedef VOID
  182. (NTAPI LSA_FREE_LSA_HEAP) (
  183. IN PVOID Base
  184. );
  185. typedef PVOID
  186. (NTAPI LSA_ALLOCATE_PRIVATE_HEAP) (
  187. IN SIZE_T Length
  188. );
  189. typedef VOID
  190. (NTAPI LSA_FREE_PRIVATE_HEAP) (
  191. IN PVOID Base
  192. );
  193. typedef NTSTATUS
  194. (NTAPI LSA_ALLOCATE_CLIENT_BUFFER) (
  195. IN PLSA_CLIENT_REQUEST ClientRequest,
  196. IN ULONG LengthRequired,
  197. OUT PVOID *ClientBaseAddress
  198. );
  199. typedef NTSTATUS
  200. (NTAPI LSA_FREE_CLIENT_BUFFER) (
  201. IN PLSA_CLIENT_REQUEST ClientRequest,
  202. IN PVOID ClientBaseAddress
  203. );
  204. typedef NTSTATUS
  205. (NTAPI LSA_COPY_TO_CLIENT_BUFFER) (
  206. IN PLSA_CLIENT_REQUEST ClientRequest,
  207. IN ULONG Length,
  208. IN PVOID ClientBaseAddress,
  209. IN PVOID BufferToCopy
  210. );
  211. typedef NTSTATUS
  212. (NTAPI LSA_COPY_FROM_CLIENT_BUFFER) (
  213. IN PLSA_CLIENT_REQUEST ClientRequest,
  214. IN ULONG Length,
  215. IN PVOID BufferToCopy,
  216. IN PVOID ClientBaseAddress
  217. );
  218. typedef LSA_CREATE_LOGON_SESSION * PLSA_CREATE_LOGON_SESSION ;
  219. typedef LSA_DELETE_LOGON_SESSION * PLSA_DELETE_LOGON_SESSION ;
  220. typedef LSA_ADD_CREDENTIAL * PLSA_ADD_CREDENTIAL ;
  221. typedef LSA_GET_CREDENTIALS * PLSA_GET_CREDENTIALS ;
  222. typedef LSA_DELETE_CREDENTIAL * PLSA_DELETE_CREDENTIAL ;
  223. typedef LSA_ALLOCATE_LSA_HEAP * PLSA_ALLOCATE_LSA_HEAP ;
  224. typedef LSA_FREE_LSA_HEAP * PLSA_FREE_LSA_HEAP ;
  225. typedef LSA_ALLOCATE_PRIVATE_HEAP * PLSA_ALLOCATE_PRIVATE_HEAP ;
  226. typedef LSA_FREE_PRIVATE_HEAP * PLSA_FREE_PRIVATE_HEAP ;
  227. typedef LSA_ALLOCATE_CLIENT_BUFFER * PLSA_ALLOCATE_CLIENT_BUFFER ;
  228. typedef LSA_FREE_CLIENT_BUFFER * PLSA_FREE_CLIENT_BUFFER ;
  229. typedef LSA_COPY_TO_CLIENT_BUFFER * PLSA_COPY_TO_CLIENT_BUFFER ;
  230. typedef LSA_COPY_FROM_CLIENT_BUFFER * PLSA_COPY_FROM_CLIENT_BUFFER ;
  231. //
  232. // The dispatch table of LSA services which are available to
  233. // authentication packages.
  234. //
  235. typedef struct _LSA_DISPATCH_TABLE {
  236. PLSA_CREATE_LOGON_SESSION CreateLogonSession;
  237. PLSA_DELETE_LOGON_SESSION DeleteLogonSession;
  238. PLSA_ADD_CREDENTIAL AddCredential;
  239. PLSA_GET_CREDENTIALS GetCredentials;
  240. PLSA_DELETE_CREDENTIAL DeleteCredential;
  241. PLSA_ALLOCATE_LSA_HEAP AllocateLsaHeap;
  242. PLSA_FREE_LSA_HEAP FreeLsaHeap;
  243. PLSA_ALLOCATE_CLIENT_BUFFER AllocateClientBuffer;
  244. PLSA_FREE_CLIENT_BUFFER FreeClientBuffer;
  245. PLSA_COPY_TO_CLIENT_BUFFER CopyToClientBuffer;
  246. PLSA_COPY_FROM_CLIENT_BUFFER CopyFromClientBuffer;
  247. } LSA_DISPATCH_TABLE, *PLSA_DISPATCH_TABLE;
  248. ////////////////////////////////////////////////////////////////////////////
  249. // //
  250. // Interface definitions of services provided by authentication packages //
  251. // //
  252. ////////////////////////////////////////////////////////////////////////////
  253. //
  254. // Routine names
  255. //
  256. // The routines provided by the DLL must be assigned the following names
  257. // so that their addresses can be retrieved when the DLL is loaded.
  258. //
  259. #define LSA_AP_NAME_INITIALIZE_PACKAGE "LsaApInitializePackage\0"
  260. #define LSA_AP_NAME_LOGON_USER "LsaApLogonUser\0"
  261. #define LSA_AP_NAME_LOGON_USER_EX "LsaApLogonUserEx\0"
  262. #define LSA_AP_NAME_CALL_PACKAGE "LsaApCallPackage\0"
  263. #define LSA_AP_NAME_LOGON_TERMINATED "LsaApLogonTerminated\0"
  264. #define LSA_AP_NAME_CALL_PACKAGE_UNTRUSTED "LsaApCallPackageUntrusted\0"
  265. #define LSA_AP_NAME_CALL_PACKAGE_PASSTHROUGH "LsaApCallPackagePassthrough\0"
  266. //
  267. // Routine templates
  268. //
  269. typedef NTSTATUS
  270. (NTAPI LSA_AP_INITIALIZE_PACKAGE) (
  271. IN ULONG AuthenticationPackageId,
  272. IN PLSA_DISPATCH_TABLE LsaDispatchTable,
  273. IN PLSA_STRING Database OPTIONAL,
  274. IN PLSA_STRING Confidentiality OPTIONAL,
  275. OUT PLSA_STRING *AuthenticationPackageName
  276. );
  277. typedef NTSTATUS
  278. (NTAPI LSA_AP_LOGON_USER) (
  279. IN PLSA_CLIENT_REQUEST ClientRequest,
  280. IN SECURITY_LOGON_TYPE LogonType,
  281. IN PVOID AuthenticationInformation,
  282. IN PVOID ClientAuthenticationBase,
  283. IN ULONG AuthenticationInformationLength,
  284. OUT PVOID *ProfileBuffer,
  285. OUT PULONG ProfileBufferLength,
  286. OUT PLUID LogonId,
  287. OUT PNTSTATUS SubStatus,
  288. OUT PLSA_TOKEN_INFORMATION_TYPE TokenInformationType,
  289. OUT PVOID *TokenInformation,
  290. OUT PLSA_UNICODE_STRING *AccountName,
  291. OUT PLSA_UNICODE_STRING *AuthenticatingAuthority
  292. );
  293. typedef NTSTATUS
  294. (NTAPI LSA_AP_LOGON_USER_EX) (
  295. IN PLSA_CLIENT_REQUEST ClientRequest,
  296. IN SECURITY_LOGON_TYPE LogonType,
  297. IN PVOID AuthenticationInformation,
  298. IN PVOID ClientAuthenticationBase,
  299. IN ULONG AuthenticationInformationLength,
  300. OUT PVOID *ProfileBuffer,
  301. OUT PULONG ProfileBufferLength,
  302. OUT PLUID LogonId,
  303. OUT PNTSTATUS SubStatus,
  304. OUT PLSA_TOKEN_INFORMATION_TYPE TokenInformationType,
  305. OUT PVOID *TokenInformation,
  306. OUT PUNICODE_STRING *AccountName,
  307. OUT PUNICODE_STRING *AuthenticatingAuthority,
  308. OUT PUNICODE_STRING *MachineName
  309. );
  310. typedef NTSTATUS
  311. (NTAPI LSA_AP_CALL_PACKAGE) (
  312. IN PLSA_CLIENT_REQUEST ClientRequest,
  313. IN PVOID ProtocolSubmitBuffer,
  314. IN PVOID ClientBufferBase,
  315. IN ULONG SubmitBufferLength,
  316. OUT PVOID *ProtocolReturnBuffer,
  317. OUT PULONG ReturnBufferLength,
  318. OUT PNTSTATUS ProtocolStatus
  319. );
  320. typedef NTSTATUS
  321. (NTAPI LSA_AP_CALL_PACKAGE_PASSTHROUGH) (
  322. IN PLSA_CLIENT_REQUEST ClientRequest,
  323. IN PVOID ProtocolSubmitBuffer,
  324. IN PVOID ClientBufferBase,
  325. IN ULONG SubmitBufferLength,
  326. OUT PVOID *ProtocolReturnBuffer,
  327. OUT PULONG ReturnBufferLength,
  328. OUT PNTSTATUS ProtocolStatus
  329. );
  330. typedef VOID
  331. (NTAPI LSA_AP_LOGON_TERMINATED) (
  332. IN PLUID LogonId
  333. );
  334. typedef LSA_AP_CALL_PACKAGE LSA_AP_CALL_PACKAGE_UNTRUSTED;
  335. typedef LSA_AP_INITIALIZE_PACKAGE * PLSA_AP_INITIALIZE_PACKAGE ;
  336. typedef LSA_AP_LOGON_USER * PLSA_AP_LOGON_USER ;
  337. typedef LSA_AP_LOGON_USER_EX * PLSA_AP_LOGON_USER_EX ;
  338. typedef LSA_AP_CALL_PACKAGE * PLSA_AP_CALL_PACKAGE ;
  339. typedef LSA_AP_CALL_PACKAGE_PASSTHROUGH * PLSA_AP_CALL_PACKAGE_PASSTHROUGH ;
  340. typedef LSA_AP_LOGON_TERMINATED * PLSA_AP_LOGON_TERMINATED ;
  341. typedef LSA_AP_CALL_PACKAGE_UNTRUSTED * PLSA_AP_CALL_PACKAGE_UNTRUSTED ;
  342. #ifndef _SAM_CREDENTIAL_UPDATE_DEFINED
  343. #define _SAM_CREDENTIAL_UPDATE_DEFINED
  344. typedef NTSTATUS (*PSAM_CREDENTIAL_UPDATE_NOTIFY_ROUTINE) (
  345. IN PUNICODE_STRING ClearPassword,
  346. IN PVOID OldCredentials,
  347. IN ULONG OldCredentialSize,
  348. IN ULONG UserAccountControl,
  349. IN PUNICODE_STRING UPN, OPTIONAL
  350. IN PUNICODE_STRING UserName,
  351. IN PUNICODE_STRING NetbiosDomainName,
  352. IN PUNICODE_STRING DnsDomainName,
  353. OUT PVOID * NewCredentials,
  354. OUT ULONG * NewCredentialSize
  355. );
  356. #define SAM_CREDENTIAL_UPDATE_NOTIFY_ROUTINE "CredentialUpdateNotify"
  357. typedef BOOLEAN (*PSAM_CREDENTIAL_UPDATE_REGISTER_ROUTINE) (
  358. OUT PUNICODE_STRING CredentialName
  359. );
  360. #define SAM_CREDENTIAL_UPDATE_REGISTER_ROUTINE "CredentialUpdateRegister"
  361. typedef VOID (*PSAM_CREDENTIAL_UPDATE_FREE_ROUTINE) (
  362. IN PVOID p
  363. );
  364. #define SAM_CREDENTIAL_UPDATE_FREE_ROUTINE "CredentialUpdateFree"
  365. #endif // _SAM_CREDENTIAL_UPDATE_DEFINED
  366. #ifdef SECURITY_KERNEL
  367. //
  368. // Can't use the windows.h def'ns in kernel mode.
  369. //
  370. typedef PVOID SEC_THREAD_START;
  371. typedef PVOID SEC_ATTRS;
  372. #else
  373. typedef LPTHREAD_START_ROUTINE SEC_THREAD_START;
  374. typedef LPSECURITY_ATTRIBUTES SEC_ATTRS;
  375. #endif
  376. #define SecEqualLuid(L1, L2) \
  377. ( ( ((PLUID)L1)->LowPart == ((PLUID)L2)->LowPart ) && \
  378. ( ((PLUID)L1)->HighPart == ((PLUID)L2)->HighPart ) ) \
  379. #define SecIsZeroLuid( L1 ) \
  380. ( ( L1->LowPart | L1->HighPart ) == 0 )
  381. //
  382. // The following structures are used by the helper functions
  383. //
  384. typedef struct _SECPKG_CLIENT_INFO {
  385. LUID LogonId; // Effective Logon Id
  386. ULONG ProcessID; // Process Id of caller
  387. ULONG ThreadID; // Thread Id of caller
  388. BOOLEAN HasTcbPrivilege; // Client has TCB
  389. BOOLEAN Impersonating; // Client is impersonating
  390. BOOLEAN Restricted; // Client is restricted
  391. //
  392. // NT 5.1
  393. //
  394. UCHAR ClientFlags; // Extra flags about the client
  395. SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; // Impersonation level of client
  396. } SECPKG_CLIENT_INFO, * PSECPKG_CLIENT_INFO;
  397. #define SECPKG_CLIENT_PROCESS_TERMINATED 0x01 // The client process has terminated
  398. #define SECPKG_CLIENT_THREAD_TERMINATED 0x02 // The client thread has terminated
  399. typedef struct _SECPKG_CALL_INFO {
  400. ULONG ProcessId ;
  401. ULONG ThreadId ;
  402. ULONG Attributes ;
  403. ULONG CallCount ;
  404. } SECPKG_CALL_INFO, * PSECPKG_CALL_INFO ;
  405. #define SECPKG_CALL_KERNEL_MODE 0x00000001 // Call originated in kernel mode
  406. #define SECPKG_CALL_ANSI 0x00000002 // Call came from ANSI stub
  407. #define SECPKG_CALL_URGENT 0x00000004 // Call designated urgent
  408. #define SECPKG_CALL_RECURSIVE 0x00000008 // Call is recursing
  409. #define SECPKG_CALL_IN_PROC 0x00000010 // Call originated in process
  410. #define SECPKG_CALL_CLEANUP 0x00000020 // Call is cleanup from a client
  411. #define SECPKG_CALL_WOWCLIENT 0x00000040 // Call is from a WOW client process
  412. #define SECPKG_CALL_THREAD_TERM 0x00000080 // Call is from a thread that has term'd
  413. #define SECPKG_CALL_PROCESS_TERM 0x00000100 // Call is from a process that has term'd
  414. #define SECPKG_CALL_IS_TCB 0x00000200 // Call is from TCB
  415. typedef struct _SECPKG_SUPPLEMENTAL_CRED {
  416. UNICODE_STRING PackageName;
  417. ULONG CredentialSize;
  418. #ifdef MIDL_PASS
  419. [size_is(CredentialSize)]
  420. #endif // MIDL_PASS
  421. PUCHAR Credentials;
  422. } SECPKG_SUPPLEMENTAL_CRED, *PSECPKG_SUPPLEMENTAL_CRED;
  423. typedef ULONG_PTR LSA_SEC_HANDLE ;
  424. typedef LSA_SEC_HANDLE * PLSA_SEC_HANDLE ;
  425. typedef struct _SECPKG_SUPPLEMENTAL_CRED_ARRAY {
  426. ULONG CredentialCount;
  427. #ifdef MIDL_PASS
  428. [size_is(CredentialCount)] SECPKG_SUPPLEMENTAL_CRED Credentials[*];
  429. #else // MIDL_PASS
  430. SECPKG_SUPPLEMENTAL_CRED Credentials[1];
  431. #endif // MIDL_PASS
  432. } SECPKG_SUPPLEMENTAL_CRED_ARRAY, *PSECPKG_SUPPLEMENTAL_CRED_ARRAY;
  433. //
  434. // This flag is used for to indicate which buffers in the LSA are located
  435. // in the client's address space
  436. //
  437. #define SECBUFFER_UNMAPPED 0x40000000
  438. //
  439. // This flag is used to indicate that the buffer was mapped into the LSA
  440. // from kernel mode.
  441. //
  442. #define SECBUFFER_KERNEL_MAP 0x20000000
  443. typedef NTSTATUS
  444. (NTAPI LSA_CALLBACK_FUNCTION)(
  445. ULONG_PTR Argument1,
  446. ULONG_PTR Argument2,
  447. PSecBuffer InputBuffer,
  448. PSecBuffer OutputBuffer
  449. );
  450. typedef LSA_CALLBACK_FUNCTION * PLSA_CALLBACK_FUNCTION ;
  451. #define PRIMARY_CRED_CLEAR_PASSWORD 0x1
  452. #define PRIMARY_CRED_OWF_PASSWORD 0x2
  453. #define PRIMARY_CRED_UPDATE 0x4 // this is a change of existing creds
  454. #define PRIMARY_CRED_CACHED_LOGON 0x8
  455. #define PRIMARY_CRED_LOGON_PACKAGE_SHIFT 24
  456. #define PRIMARY_CRED_PACKAGE_MASK 0xff000000
  457. //
  458. // For cached logons, the RPC id of the package doing the logon is identified
  459. // by shifting the flags to the right by the PRIMARY_CRED_LOGON_PACKAGE_SHIFT.
  460. //
  461. typedef struct _SECPKG_PRIMARY_CRED {
  462. LUID LogonId;
  463. UNICODE_STRING DownlevelName; // Sam Account Name
  464. UNICODE_STRING DomainName; // Netbios domain name where account is located
  465. UNICODE_STRING Password;
  466. UNICODE_STRING OldPassword;
  467. PSID UserSid;
  468. ULONG Flags;
  469. UNICODE_STRING DnsDomainName; // DNS domain name where account is located (if known)
  470. UNICODE_STRING Upn; // UPN of account (if known)
  471. UNICODE_STRING LogonServer;
  472. UNICODE_STRING Spare1;
  473. UNICODE_STRING Spare2;
  474. UNICODE_STRING Spare3;
  475. UNICODE_STRING Spare4;
  476. } SECPKG_PRIMARY_CRED, *PSECPKG_PRIMARY_CRED;
  477. //
  478. // Maximum size of stored credentials.
  479. //
  480. #define MAX_CRED_SIZE 1024
  481. // Values for MachineState
  482. #define SECPKG_STATE_ENCRYPTION_PERMITTED 0x01
  483. #define SECPKG_STATE_STRONG_ENCRYPTION_PERMITTED 0x02
  484. #define SECPKG_STATE_DOMAIN_CONTROLLER 0x04
  485. #define SECPKG_STATE_WORKSTATION 0x08
  486. #define SECPKG_STATE_STANDALONE 0x10
  487. typedef struct _SECPKG_PARAMETERS {
  488. ULONG Version;
  489. ULONG MachineState;
  490. ULONG SetupMode;
  491. PSID DomainSid;
  492. UNICODE_STRING DomainName;
  493. UNICODE_STRING DnsDomainName;
  494. GUID DomainGuid;
  495. } SECPKG_PARAMETERS, *PSECPKG_PARAMETERS;
  496. //
  497. // Extended Package information structures
  498. //
  499. typedef enum _SECPKG_EXTENDED_INFORMATION_CLASS {
  500. SecpkgGssInfo = 1,
  501. SecpkgContextThunks,
  502. SecpkgMutualAuthLevel,
  503. SecpkgWowClientDll,
  504. SecpkgExtraOids,
  505. SecpkgMaxInfo
  506. } SECPKG_EXTENDED_INFORMATION_CLASS ;
  507. typedef struct _SECPKG_GSS_INFO {
  508. ULONG EncodedIdLength ;
  509. UCHAR EncodedId[4] ;
  510. } SECPKG_GSS_INFO, * PSECPKG_GSS_INFO ;
  511. typedef struct _SECPKG_CONTEXT_THUNKS {
  512. ULONG InfoLevelCount ;
  513. ULONG Levels[1] ;
  514. } SECPKG_CONTEXT_THUNKS, *PSECPKG_CONTEXT_THUNKS ;
  515. typedef struct _SECPKG_MUTUAL_AUTH_LEVEL {
  516. ULONG MutualAuthLevel ;
  517. } SECPKG_MUTUAL_AUTH_LEVEL, * PSECPKG_MUTUAL_AUTH_LEVEL ;
  518. typedef struct _SECPKG_WOW_CLIENT_DLL {
  519. SECURITY_STRING WowClientDllPath;
  520. } SECPKG_WOW_CLIENT_DLL, * PSECPKG_WOW_CLIENT_DLL ;
  521. #define SECPKG_MAX_OID_LENGTH 32
  522. typedef struct _SECPKG_SERIALIZED_OID {
  523. ULONG OidLength ;
  524. ULONG OidAttributes ;
  525. UCHAR OidValue[ SECPKG_MAX_OID_LENGTH ];
  526. } SECPKG_SERIALIZED_OID, * PSECPKG_SERIALIZED_OID ;
  527. typedef struct _SECPKG_EXTRA_OIDS {
  528. ULONG OidCount ;
  529. SECPKG_SERIALIZED_OID Oids[ 1 ];
  530. } SECPKG_EXTRA_OIDS, * PSECPKG_EXTRA_OIDS;
  531. typedef struct _SECPKG_EXTENDED_INFORMATION {
  532. SECPKG_EXTENDED_INFORMATION_CLASS Class ;
  533. union {
  534. SECPKG_GSS_INFO GssInfo ;
  535. SECPKG_CONTEXT_THUNKS ContextThunks ;
  536. SECPKG_MUTUAL_AUTH_LEVEL MutualAuthLevel ;
  537. SECPKG_WOW_CLIENT_DLL WowClientDll ;
  538. SECPKG_EXTRA_OIDS ExtraOids ;
  539. } Info ;
  540. } SECPKG_EXTENDED_INFORMATION, * PSECPKG_EXTENDED_INFORMATION ;
  541. #define SECPKG_ATTR_SASL_CONTEXT 0x00010000
  542. typedef struct _SecPkgContext_SaslContext {
  543. PVOID SaslContext ;
  544. } SecPkgContext_SaslContext, * PSecPkgContext_SaslContext ;
  545. //
  546. // Setting this value as the first context thunk value will cause all
  547. // calls to go to the LSA:
  548. //
  549. #define SECPKG_ATTR_THUNK_ALL 0x00010000
  550. #ifndef SECURITY_USER_DATA_DEFINED
  551. #define SECURITY_USER_DATA_DEFINED
  552. typedef struct _SECURITY_USER_DATA {
  553. SECURITY_STRING UserName; // User name
  554. SECURITY_STRING LogonDomainName; // Domain the user logged on to
  555. SECURITY_STRING LogonServer; // Server that logged the user on
  556. PSID pSid; // SID of user
  557. } SECURITY_USER_DATA, *PSECURITY_USER_DATA;
  558. typedef SECURITY_USER_DATA SecurityUserData, * PSecurityUserData;
  559. #define UNDERSTANDS_LONG_NAMES 1
  560. #define NO_LONG_NAMES 2
  561. #endif // SECURITY_USER_DATA_DEFINED
  562. //////////////////////////////////////////////////////////////////////////
  563. //
  564. // The following prototypes are to functions that are provided by the SPMgr
  565. // to security packages.
  566. //
  567. //////////////////////////////////////////////////////////////////////////
  568. typedef NTSTATUS
  569. (NTAPI LSA_IMPERSONATE_CLIENT) (
  570. VOID
  571. );
  572. typedef NTSTATUS
  573. (NTAPI LSA_UNLOAD_PACKAGE)(
  574. VOID
  575. );
  576. typedef NTSTATUS
  577. (NTAPI LSA_DUPLICATE_HANDLE)(
  578. IN HANDLE SourceHandle,
  579. OUT PHANDLE DestionationHandle);
  580. typedef NTSTATUS
  581. (NTAPI LSA_SAVE_SUPPLEMENTAL_CREDENTIALS)(
  582. IN PLUID LogonId,
  583. IN ULONG SupplementalCredSize,
  584. IN PVOID SupplementalCreds,
  585. IN BOOLEAN Synchronous
  586. );
  587. typedef HANDLE
  588. (NTAPI LSA_CREATE_THREAD)(
  589. IN SEC_ATTRS SecurityAttributes,
  590. IN ULONG StackSize,
  591. IN SEC_THREAD_START StartFunction,
  592. IN PVOID ThreadParameter,
  593. IN ULONG CreationFlags,
  594. OUT PULONG ThreadId
  595. );
  596. typedef NTSTATUS
  597. (NTAPI LSA_GET_CLIENT_INFO)(
  598. OUT PSECPKG_CLIENT_INFO ClientInfo
  599. );
  600. typedef HANDLE
  601. (NTAPI LSA_REGISTER_NOTIFICATION)(
  602. IN SEC_THREAD_START StartFunction,
  603. IN PVOID Parameter,
  604. IN ULONG NotificationType,
  605. IN ULONG NotificationClass,
  606. IN ULONG NotificationFlags,
  607. IN ULONG IntervalMinutes,
  608. IN OPTIONAL HANDLE WaitEvent
  609. );
  610. typedef NTSTATUS
  611. (NTAPI LSA_CANCEL_NOTIFICATION)(
  612. IN HANDLE NotifyHandle
  613. );
  614. typedef NTSTATUS
  615. (NTAPI LSA_MAP_BUFFER)(
  616. IN PSecBuffer InputBuffer,
  617. OUT PSecBuffer OutputBuffer
  618. );
  619. typedef NTSTATUS
  620. (NTAPI LSA_CREATE_TOKEN) (
  621. IN PLUID LogonId,
  622. IN PTOKEN_SOURCE TokenSource,
  623. IN SECURITY_LOGON_TYPE LogonType,
  624. IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
  625. IN LSA_TOKEN_INFORMATION_TYPE TokenInformationType,
  626. IN PVOID TokenInformation,
  627. IN PTOKEN_GROUPS TokenGroups,
  628. IN PUNICODE_STRING AccountName,
  629. IN PUNICODE_STRING AuthorityName,
  630. IN PUNICODE_STRING Workstation,
  631. IN PUNICODE_STRING ProfilePath,
  632. OUT PHANDLE Token,
  633. OUT PNTSTATUS SubStatus
  634. );
  635. typedef enum _SECPKG_SESSIONINFO_TYPE {
  636. SecSessionPrimaryCred // SessionInformation is SECPKG_PRIMARY_CRED
  637. } SECPKG_SESSIONINFO_TYPE ;
  638. typedef NTSTATUS
  639. (NTAPI LSA_CREATE_TOKEN_EX) (
  640. IN PLUID LogonId,
  641. IN PTOKEN_SOURCE TokenSource,
  642. IN SECURITY_LOGON_TYPE LogonType,
  643. IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
  644. IN LSA_TOKEN_INFORMATION_TYPE TokenInformationType,
  645. IN PVOID TokenInformation,
  646. IN PTOKEN_GROUPS TokenGroups,
  647. IN PUNICODE_STRING Workstation,
  648. IN PUNICODE_STRING ProfilePath,
  649. IN PVOID SessionInformation,
  650. IN SECPKG_SESSIONINFO_TYPE SessionInformationType,
  651. OUT PHANDLE Token,
  652. OUT PNTSTATUS SubStatus
  653. );
  654. typedef VOID
  655. (NTAPI LSA_AUDIT_LOGON) (
  656. IN NTSTATUS Status,
  657. IN NTSTATUS SubStatus,
  658. IN PUNICODE_STRING AccountName,
  659. IN PUNICODE_STRING AuthenticatingAuthority,
  660. IN PUNICODE_STRING WorkstationName,
  661. IN OPTIONAL PSID UserSid,
  662. IN SECURITY_LOGON_TYPE LogonType,
  663. IN PTOKEN_SOURCE TokenSource,
  664. IN PLUID LogonId
  665. );
  666. typedef NTSTATUS
  667. (NTAPI LSA_CALL_PACKAGE) (
  668. IN PUNICODE_STRING AuthenticationPackage,
  669. IN PVOID ProtocolSubmitBuffer,
  670. IN ULONG SubmitBufferLength,
  671. OUT PVOID *ProtocolReturnBuffer,
  672. OUT PULONG ReturnBufferLength,
  673. OUT PNTSTATUS ProtocolStatus
  674. );
  675. typedef NTSTATUS
  676. (NTAPI LSA_CALL_PACKAGEEX) (
  677. IN PUNICODE_STRING AuthenticationPackage,
  678. IN PVOID ClientBufferBase,
  679. IN PVOID ProtocolSubmitBuffer,
  680. IN ULONG SubmitBufferLength,
  681. OUT PVOID *ProtocolReturnBuffer,
  682. OUT PULONG ReturnBufferLength,
  683. OUT PNTSTATUS ProtocolStatus
  684. );
  685. typedef NTSTATUS
  686. (NTAPI LSA_CALL_PACKAGE_PASSTHROUGH) (
  687. IN PUNICODE_STRING AuthenticationPackage,
  688. IN PVOID ClientBufferBase,
  689. IN PVOID ProtocolSubmitBuffer,
  690. IN ULONG SubmitBufferLength,
  691. OUT PVOID *ProtocolReturnBuffer,
  692. OUT PULONG ReturnBufferLength,
  693. OUT PNTSTATUS ProtocolStatus
  694. );
  695. typedef BOOLEAN
  696. (NTAPI LSA_GET_CALL_INFO) (
  697. OUT PSECPKG_CALL_INFO Info
  698. );
  699. typedef PVOID
  700. (NTAPI LSA_CREATE_SHARED_MEMORY)(
  701. ULONG MaxSize,
  702. ULONG InitialSize
  703. );
  704. typedef PVOID
  705. (NTAPI LSA_ALLOCATE_SHARED_MEMORY)(
  706. PVOID SharedMem,
  707. ULONG Size
  708. );
  709. typedef VOID
  710. (NTAPI LSA_FREE_SHARED_MEMORY)(
  711. PVOID SharedMem,
  712. PVOID Memory
  713. );
  714. typedef BOOLEAN
  715. (NTAPI LSA_DELETE_SHARED_MEMORY)(
  716. PVOID SharedMem
  717. );
  718. //
  719. // Account Access
  720. //
  721. typedef enum _SECPKG_NAME_TYPE {
  722. SecNameSamCompatible,
  723. SecNameAlternateId,
  724. SecNameFlat,
  725. SecNameDN
  726. } SECPKG_NAME_TYPE ;
  727. typedef NTSTATUS
  728. (NTAPI LSA_OPEN_SAM_USER)(
  729. PSECURITY_STRING Name,
  730. SECPKG_NAME_TYPE NameType,
  731. PSECURITY_STRING Prefix,
  732. BOOLEAN AllowGuest,
  733. ULONG Reserved,
  734. PVOID * UserHandle
  735. );
  736. typedef NTSTATUS
  737. (NTAPI LSA_GET_USER_CREDENTIALS)(
  738. PVOID UserHandle,
  739. PVOID * PrimaryCreds,
  740. PULONG PrimaryCredsSize,
  741. PVOID * SupplementalCreds,
  742. PULONG SupplementalCredsSize
  743. );
  744. typedef NTSTATUS
  745. (NTAPI LSA_GET_USER_AUTH_DATA)(
  746. PVOID UserHandle,
  747. PUCHAR * UserAuthData,
  748. PULONG UserAuthDataSize
  749. );
  750. typedef NTSTATUS
  751. (NTAPI LSA_CLOSE_SAM_USER)(
  752. PVOID UserHandle
  753. );
  754. typedef NTSTATUS
  755. (NTAPI LSA_GET_AUTH_DATA_FOR_USER)(
  756. PSECURITY_STRING Name,
  757. SECPKG_NAME_TYPE NameType,
  758. PSECURITY_STRING Prefix,
  759. PUCHAR * UserAuthData,
  760. PULONG UserAuthDataSize,
  761. PUNICODE_STRING UserFlatName
  762. );
  763. typedef NTSTATUS
  764. (NTAPI LSA_CONVERT_AUTH_DATA_TO_TOKEN)(
  765. IN PVOID UserAuthData,
  766. IN ULONG UserAuthDataSize,
  767. IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
  768. IN PTOKEN_SOURCE TokenSource,
  769. IN SECURITY_LOGON_TYPE LogonType,
  770. IN PUNICODE_STRING AuthorityName,
  771. OUT PHANDLE Token,
  772. OUT PLUID LogonId,
  773. OUT PUNICODE_STRING AccountName,
  774. OUT PNTSTATUS SubStatus
  775. );
  776. typedef NTSTATUS
  777. (NTAPI LSA_CRACK_SINGLE_NAME)(
  778. IN ULONG FormatOffered,
  779. IN BOOLEAN PerformAtGC,
  780. IN PUNICODE_STRING NameInput,
  781. IN PUNICODE_STRING Prefix OPTIONAL,
  782. IN ULONG RequestedFormat,
  783. OUT PUNICODE_STRING CrackedName,
  784. OUT PUNICODE_STRING DnsDomainName,
  785. OUT PULONG SubStatus
  786. );
  787. typedef NTSTATUS
  788. (NTAPI LSA_AUDIT_ACCOUNT_LOGON)(
  789. IN ULONG AuditId,
  790. IN BOOLEAN Success,
  791. IN PUNICODE_STRING Source,
  792. IN PUNICODE_STRING ClientName,
  793. IN PUNICODE_STRING MappedName,
  794. IN NTSTATUS Status
  795. );
  796. typedef NTSTATUS
  797. (NTAPI LSA_CLIENT_CALLBACK)(
  798. PCHAR Callback,
  799. ULONG_PTR Argument1,
  800. ULONG_PTR Argument2,
  801. PSecBuffer Input,
  802. PSecBuffer Output
  803. );
  804. typedef
  805. NTSTATUS
  806. (NTAPI LSA_REGISTER_CALLBACK)(
  807. ULONG CallbackId,
  808. PLSA_CALLBACK_FUNCTION Callback
  809. );
  810. #define NOTIFIER_FLAG_NEW_THREAD 0x00000001
  811. #define NOTIFIER_FLAG_ONE_SHOT 0x00000002
  812. #define NOTIFIER_FLAG_SECONDS 0x80000000
  813. #define NOTIFIER_TYPE_INTERVAL 1
  814. #define NOTIFIER_TYPE_HANDLE_WAIT 2
  815. #define NOTIFIER_TYPE_STATE_CHANGE 3
  816. #define NOTIFIER_TYPE_NOTIFY_EVENT 4
  817. #define NOTIFIER_TYPE_IMMEDIATE 16
  818. #define NOTIFY_CLASS_PACKAGE_CHANGE 1
  819. #define NOTIFY_CLASS_ROLE_CHANGE 2
  820. #define NOTIFY_CLASS_DOMAIN_CHANGE 3
  821. #define NOTIFY_CLASS_REGISTRY_CHANGE 4
  822. typedef struct _SECPKG_EVENT_PACKAGE_CHANGE {
  823. ULONG ChangeType;
  824. LSA_SEC_HANDLE PackageId;
  825. SECURITY_STRING PackageName;
  826. } SECPKG_EVENT_PACKAGE_CHANGE, * PSECPKG_EVENT_PACKAGE_CHANGE ;
  827. #define SECPKG_PACKAGE_CHANGE_LOAD 0
  828. #define SECPKG_PACKAGE_CHANGE_UNLOAD 1
  829. #define SECPKG_PACKAGE_CHANGE_SELECT 2
  830. typedef struct _SECPKG_EVENT_ROLE_CHANGE {
  831. ULONG PreviousRole ;
  832. ULONG NewRole ;
  833. } SECPKG_EVENT_ROLE_CHANGE, * PSECPKG_EVENT_ROLE_CHANGE ;
  834. typedef struct _SECPKG_PARAMETERS SECPKG_EVENT_DOMAIN_CHANGE ;
  835. typedef struct _SECPKG_PARAMETERS * PSECPKG_EVENT_DOMAIN_CHANGE ;
  836. typedef struct _SECPKG_EVENT_NOTIFY {
  837. ULONG EventClass;
  838. ULONG Reserved;
  839. ULONG EventDataSize;
  840. PVOID EventData;
  841. PVOID PackageParameter;
  842. } SECPKG_EVENT_NOTIFY, *PSECPKG_EVENT_NOTIFY ;
  843. typedef
  844. NTSTATUS
  845. (NTAPI LSA_UPDATE_PRIMARY_CREDENTIALS)(
  846. IN PSECPKG_PRIMARY_CRED PrimaryCredentials,
  847. IN OPTIONAL PSECPKG_SUPPLEMENTAL_CRED_ARRAY Credentials
  848. );
  849. typedef
  850. VOID
  851. (NTAPI LSA_PROTECT_MEMORY)(
  852. IN PVOID Buffer,
  853. IN ULONG BufferSize
  854. );
  855. typedef
  856. NTSTATUS
  857. (NTAPI LSA_OPEN_TOKEN_BY_LOGON_ID)(
  858. IN PLUID LogonId,
  859. OUT HANDLE *RetTokenHandle
  860. );
  861. typedef
  862. NTSTATUS
  863. (NTAPI LSA_EXPAND_AUTH_DATA_FOR_DOMAIN)(
  864. IN PUCHAR UserAuthData,
  865. IN ULONG UserAuthDataSize,
  866. IN PVOID Reserved,
  867. OUT PUCHAR * ExpandedAuthData,
  868. OUT PULONG ExpandedAuthDataSize
  869. );
  870. typedef LSA_IMPERSONATE_CLIENT * PLSA_IMPERSONATE_CLIENT;
  871. typedef LSA_UNLOAD_PACKAGE * PLSA_UNLOAD_PACKAGE;
  872. typedef LSA_DUPLICATE_HANDLE * PLSA_DUPLICATE_HANDLE ;
  873. typedef LSA_SAVE_SUPPLEMENTAL_CREDENTIALS * PLSA_SAVE_SUPPLEMENTAL_CREDENTIALS;
  874. typedef LSA_CREATE_THREAD * PLSA_CREATE_THREAD;
  875. typedef LSA_GET_CLIENT_INFO * PLSA_GET_CLIENT_INFO;
  876. typedef LSA_REGISTER_NOTIFICATION * PLSA_REGISTER_NOTIFICATION;
  877. typedef LSA_CANCEL_NOTIFICATION * PLSA_CANCEL_NOTIFICATION;
  878. typedef LSA_MAP_BUFFER * PLSA_MAP_BUFFER;
  879. typedef LSA_CREATE_TOKEN * PLSA_CREATE_TOKEN;
  880. typedef LSA_AUDIT_LOGON * PLSA_AUDIT_LOGON;
  881. typedef LSA_CALL_PACKAGE * PLSA_CALL_PACKAGE;
  882. typedef LSA_CALL_PACKAGEEX * PLSA_CALL_PACKAGEEX;
  883. typedef LSA_GET_CALL_INFO * PLSA_GET_CALL_INFO ;
  884. typedef LSA_CREATE_SHARED_MEMORY * PLSA_CREATE_SHARED_MEMORY ;
  885. typedef LSA_ALLOCATE_SHARED_MEMORY * PLSA_ALLOCATE_SHARED_MEMORY ;
  886. typedef LSA_FREE_SHARED_MEMORY * PLSA_FREE_SHARED_MEMORY ;
  887. typedef LSA_DELETE_SHARED_MEMORY * PLSA_DELETE_SHARED_MEMORY ;
  888. typedef LSA_OPEN_SAM_USER * PLSA_OPEN_SAM_USER ;
  889. typedef LSA_GET_USER_CREDENTIALS * PLSA_GET_USER_CREDENTIALS ;
  890. typedef LSA_GET_USER_AUTH_DATA * PLSA_GET_USER_AUTH_DATA ;
  891. typedef LSA_CLOSE_SAM_USER * PLSA_CLOSE_SAM_USER ;
  892. typedef LSA_CONVERT_AUTH_DATA_TO_TOKEN * PLSA_CONVERT_AUTH_DATA_TO_TOKEN ;
  893. typedef LSA_CLIENT_CALLBACK * PLSA_CLIENT_CALLBACK ;
  894. typedef LSA_REGISTER_CALLBACK * PLSA_REGISTER_CALLBACK ;
  895. typedef LSA_UPDATE_PRIMARY_CREDENTIALS * PLSA_UPDATE_PRIMARY_CREDENTIALS;
  896. typedef LSA_GET_AUTH_DATA_FOR_USER * PLSA_GET_AUTH_DATA_FOR_USER ;
  897. typedef LSA_CRACK_SINGLE_NAME * PLSA_CRACK_SINGLE_NAME ;
  898. typedef LSA_AUDIT_ACCOUNT_LOGON * PLSA_AUDIT_ACCOUNT_LOGON ;
  899. typedef LSA_CALL_PACKAGE_PASSTHROUGH * PLSA_CALL_PACKAGE_PASSTHROUGH;
  900. typedef LSA_PROTECT_MEMORY * PLSA_PROTECT_MEMORY;
  901. typedef LSA_OPEN_TOKEN_BY_LOGON_ID * PLSA_OPEN_TOKEN_BY_LOGON_ID;
  902. typedef LSA_EXPAND_AUTH_DATA_FOR_DOMAIN * PLSA_EXPAND_AUTH_DATA_FOR_DOMAIN;
  903. typedef LSA_CREATE_TOKEN_EX * PLSA_CREATE_TOKEN_EX;
  904. #ifdef _WINCRED_H_
  905. //
  906. // When passing a credential around, the CredentialBlob field is encrypted.
  907. // This structure describes this encrypted form.
  908. //
  909. //
  910. #ifndef _ENCRYPTED_CREDENTIAL_DEFINED
  911. #define _ENCRYPTED_CREDENTIAL_DEFINED
  912. typedef struct _ENCRYPTED_CREDENTIALW {
  913. //
  914. // The credential
  915. //
  916. // The CredentialBlob field points to the encrypted credential
  917. // The CredentialBlobSize field is the length (in bytes) of the encrypted credential
  918. //
  919. CREDENTIALW Cred;
  920. //
  921. // The size in bytes of the clear text credential blob
  922. //
  923. ULONG ClearCredentialBlobSize;
  924. } ENCRYPTED_CREDENTIALW, *PENCRYPTED_CREDENTIALW;
  925. #endif // _ENCRYPTED_CREDENTIAL_DEFINED
  926. //
  927. // Values for CredFlags parameter
  928. //
  929. #define CREDP_FLAGS_IN_PROCESS 0x01 // Caller is in-process. Password data may be returned
  930. #define CREDP_FLAGS_USE_MIDL_HEAP 0x02 // Allocated buffer should use MIDL_user_allocte
  931. #define CREDP_FLAGS_DONT_CACHE_TI 0x04 // TargetInformation shouldn't be cached for CredGetTargetInfo
  932. #define CREDP_FLAGS_CLEAR_PASSWORD 0x08 // Credential blob is passed in in-the-clear
  933. typedef NTSTATUS
  934. (NTAPI CredReadFn) (
  935. IN PLUID LogonId,
  936. IN ULONG CredFlags,
  937. IN LPWSTR TargetName,
  938. IN ULONG Type,
  939. IN ULONG Flags,
  940. OUT PENCRYPTED_CREDENTIALW *Credential
  941. );
  942. typedef NTSTATUS
  943. (NTAPI CredReadDomainCredentialsFn) (
  944. IN PLUID LogonId,
  945. IN ULONG CredFlags,
  946. IN PCREDENTIAL_TARGET_INFORMATIONW TargetInfo,
  947. IN ULONG Flags,
  948. OUT PULONG Count,
  949. OUT PENCRYPTED_CREDENTIALW **Credential
  950. );
  951. typedef VOID
  952. (NTAPI CredFreeCredentialsFn) (
  953. IN ULONG Count,
  954. IN PENCRYPTED_CREDENTIALW *Credentials OPTIONAL
  955. );
  956. NTSTATUS
  957. CredMarshalTargetInfo (
  958. IN PCREDENTIAL_TARGET_INFORMATIONW InTargetInfo,
  959. OUT PUSHORT *Buffer,
  960. OUT PULONG BufferSize
  961. );
  962. NTSTATUS
  963. CredUnmarshalTargetInfo (
  964. IN PUSHORT Buffer,
  965. IN ULONG BufferSize,
  966. OUT PCREDENTIAL_TARGET_INFORMATIONW *RetTargetInfo
  967. );
  968. #endif // _WINCRED_H_
  969. //
  970. // Pure 32-bit versions of credential structures for packages
  971. // running wow64:
  972. //
  973. typedef struct _SEC_WINNT_AUTH_IDENTITY32 {
  974. ULONG User ;
  975. ULONG UserLength ;
  976. ULONG Domain ;
  977. ULONG DomainLength ;
  978. ULONG Password ;
  979. ULONG PasswordLength ;
  980. ULONG Flags ;
  981. } SEC_WINNT_AUTH_IDENTITY32, * PSEC_WINNT_AUTH_IDENTITY32 ;
  982. typedef struct _SEC_WINNT_AUTH_IDENTITY_EX32 {
  983. ULONG Version ;
  984. ULONG Length ;
  985. ULONG User ;
  986. ULONG UserLength ;
  987. ULONG Domain ;
  988. ULONG DomainLength ;
  989. ULONG Password ;
  990. ULONG PasswordLength ;
  991. ULONG Flags ;
  992. ULONG PackageList ;
  993. ULONG PackageListLength ;
  994. } SEC_WINNT_AUTH_IDENTITY_EX32, * PSEC_WINNT_AUTH_IDENTITY_EX32 ;
  995. // Functions provided by the SPM to the packages:
  996. typedef struct _LSA_SECPKG_FUNCTION_TABLE {
  997. PLSA_CREATE_LOGON_SESSION CreateLogonSession;
  998. PLSA_DELETE_LOGON_SESSION DeleteLogonSession;
  999. PLSA_ADD_CREDENTIAL AddCredential;
  1000. PLSA_GET_CREDENTIALS GetCredentials;
  1001. PLSA_DELETE_CREDENTIAL DeleteCredential;
  1002. PLSA_ALLOCATE_LSA_HEAP AllocateLsaHeap;
  1003. PLSA_FREE_LSA_HEAP FreeLsaHeap;
  1004. PLSA_ALLOCATE_CLIENT_BUFFER AllocateClientBuffer;
  1005. PLSA_FREE_CLIENT_BUFFER FreeClientBuffer;
  1006. PLSA_COPY_TO_CLIENT_BUFFER CopyToClientBuffer;
  1007. PLSA_COPY_FROM_CLIENT_BUFFER CopyFromClientBuffer;
  1008. PLSA_IMPERSONATE_CLIENT ImpersonateClient;
  1009. PLSA_UNLOAD_PACKAGE UnloadPackage;
  1010. PLSA_DUPLICATE_HANDLE DuplicateHandle;
  1011. PLSA_SAVE_SUPPLEMENTAL_CREDENTIALS SaveSupplementalCredentials;
  1012. PLSA_CREATE_THREAD CreateThread;
  1013. PLSA_GET_CLIENT_INFO GetClientInfo;
  1014. PLSA_REGISTER_NOTIFICATION RegisterNotification;
  1015. PLSA_CANCEL_NOTIFICATION CancelNotification;
  1016. PLSA_MAP_BUFFER MapBuffer;
  1017. PLSA_CREATE_TOKEN CreateToken;
  1018. PLSA_AUDIT_LOGON AuditLogon;
  1019. PLSA_CALL_PACKAGE CallPackage;
  1020. PLSA_FREE_LSA_HEAP FreeReturnBuffer;
  1021. PLSA_GET_CALL_INFO GetCallInfo;
  1022. PLSA_CALL_PACKAGEEX CallPackageEx;
  1023. PLSA_CREATE_SHARED_MEMORY CreateSharedMemory;
  1024. PLSA_ALLOCATE_SHARED_MEMORY AllocateSharedMemory;
  1025. PLSA_FREE_SHARED_MEMORY FreeSharedMemory;
  1026. PLSA_DELETE_SHARED_MEMORY DeleteSharedMemory;
  1027. PLSA_OPEN_SAM_USER OpenSamUser ;
  1028. PLSA_GET_USER_CREDENTIALS GetUserCredentials ;
  1029. PLSA_GET_USER_AUTH_DATA GetUserAuthData ;
  1030. PLSA_CLOSE_SAM_USER CloseSamUser ;
  1031. PLSA_CONVERT_AUTH_DATA_TO_TOKEN ConvertAuthDataToToken ;
  1032. PLSA_CLIENT_CALLBACK ClientCallback ;
  1033. PLSA_UPDATE_PRIMARY_CREDENTIALS UpdateCredentials ;
  1034. PLSA_GET_AUTH_DATA_FOR_USER GetAuthDataForUser ;
  1035. PLSA_CRACK_SINGLE_NAME CrackSingleName ;
  1036. PLSA_AUDIT_ACCOUNT_LOGON AuditAccountLogon ;
  1037. PLSA_CALL_PACKAGE_PASSTHROUGH CallPackagePassthrough ;
  1038. #ifdef _WINCRED_H_
  1039. CredReadFn *CrediRead;
  1040. CredReadDomainCredentialsFn *CrediReadDomainCredentials;
  1041. CredFreeCredentialsFn *CrediFreeCredentials;
  1042. #else // _WINCRED_H_
  1043. PLSA_PROTECT_MEMORY DummyFunction1;
  1044. PLSA_PROTECT_MEMORY DummyFunction2;
  1045. PLSA_PROTECT_MEMORY DummyFunction3;
  1046. #endif // _WINCRED_H_
  1047. PLSA_PROTECT_MEMORY LsaProtectMemory;
  1048. PLSA_PROTECT_MEMORY LsaUnprotectMemory;
  1049. PLSA_OPEN_TOKEN_BY_LOGON_ID OpenTokenByLogonId;
  1050. PLSA_EXPAND_AUTH_DATA_FOR_DOMAIN ExpandAuthDataForDomain;
  1051. PLSA_ALLOCATE_PRIVATE_HEAP AllocatePrivateHeap;
  1052. PLSA_FREE_PRIVATE_HEAP FreePrivateHeap;
  1053. PLSA_CREATE_TOKEN_EX CreateTokenEx;
  1054. } LSA_SECPKG_FUNCTION_TABLE, *PLSA_SECPKG_FUNCTION_TABLE;
  1055. typedef struct _SECPKG_DLL_FUNCTIONS {
  1056. PLSA_ALLOCATE_LSA_HEAP AllocateHeap;
  1057. PLSA_FREE_LSA_HEAP FreeHeap;
  1058. PLSA_REGISTER_CALLBACK RegisterCallback ;
  1059. } SECPKG_DLL_FUNCTIONS, * PSECPKG_DLL_FUNCTIONS;
  1060. //
  1061. // The following prototypes are to functions that will be called only while
  1062. // in the Security Package Manager context.
  1063. //
  1064. typedef NTSTATUS
  1065. (NTAPI SpInitializeFn)(
  1066. IN ULONG_PTR PackageId,
  1067. IN PSECPKG_PARAMETERS Parameters,
  1068. IN PLSA_SECPKG_FUNCTION_TABLE FunctionTable
  1069. );
  1070. typedef NTSTATUS
  1071. (NTAPI SpShutdownFn)(
  1072. VOID
  1073. );
  1074. typedef NTSTATUS
  1075. (NTAPI SpGetInfoFn)(
  1076. OUT PSecPkgInfo PackageInfo
  1077. );
  1078. typedef NTSTATUS
  1079. (NTAPI SpGetExtendedInformationFn)(
  1080. IN SECPKG_EXTENDED_INFORMATION_CLASS Class,
  1081. OUT PSECPKG_EXTENDED_INFORMATION * ppInformation
  1082. );
  1083. typedef NTSTATUS
  1084. (NTAPI SpSetExtendedInformationFn)(
  1085. IN SECPKG_EXTENDED_INFORMATION_CLASS Class,
  1086. IN PSECPKG_EXTENDED_INFORMATION Info
  1087. );
  1088. typedef NTSTATUS
  1089. (LSA_AP_LOGON_USER_EX2) (
  1090. IN PLSA_CLIENT_REQUEST ClientRequest,
  1091. IN SECURITY_LOGON_TYPE LogonType,
  1092. IN PVOID AuthenticationInformation,
  1093. IN PVOID ClientAuthenticationBase,
  1094. IN ULONG AuthenticationInformationLength,
  1095. OUT PVOID *ProfileBuffer,
  1096. OUT PULONG ProfileBufferLength,
  1097. OUT PLUID LogonId,
  1098. OUT PNTSTATUS SubStatus,
  1099. OUT PLSA_TOKEN_INFORMATION_TYPE TokenInformationType,
  1100. OUT PVOID *TokenInformation,
  1101. OUT PUNICODE_STRING *AccountName,
  1102. OUT PUNICODE_STRING *AuthenticatingAuthority,
  1103. OUT PUNICODE_STRING *MachineName,
  1104. OUT PSECPKG_PRIMARY_CRED PrimaryCredentials,
  1105. OUT PSECPKG_SUPPLEMENTAL_CRED_ARRAY * CachedCredentials
  1106. );
  1107. typedef LSA_AP_LOGON_USER_EX2 *PLSA_AP_LOGON_USER_EX2;
  1108. #define LSA_AP_NAME_LOGON_USER_EX2 "LsaApLogonUserEx2\0"
  1109. typedef NTSTATUS
  1110. (NTAPI SpAcceptCredentialsFn)(
  1111. IN SECURITY_LOGON_TYPE LogonType,
  1112. IN PUNICODE_STRING AccountName,
  1113. IN PSECPKG_PRIMARY_CRED PrimaryCredentials,
  1114. IN PSECPKG_SUPPLEMENTAL_CRED SupplementalCredentials
  1115. );
  1116. #define SP_ACCEPT_CREDENTIALS_NAME "SpAcceptCredentials\0"
  1117. typedef NTSTATUS
  1118. (NTAPI SpAcquireCredentialsHandleFn)(
  1119. IN OPTIONAL PUNICODE_STRING PrincipalName,
  1120. IN ULONG CredentialUseFlags,
  1121. IN OPTIONAL PLUID LogonId,
  1122. IN PVOID AuthorizationData,
  1123. IN PVOID GetKeyFunciton,
  1124. IN PVOID GetKeyArgument,
  1125. OUT PLSA_SEC_HANDLE CredentialHandle,
  1126. OUT PTimeStamp ExpirationTime
  1127. );
  1128. typedef NTSTATUS
  1129. (NTAPI SpFreeCredentialsHandleFn)(
  1130. IN LSA_SEC_HANDLE CredentialHandle
  1131. );
  1132. typedef NTSTATUS
  1133. (NTAPI SpQueryCredentialsAttributesFn)(
  1134. IN LSA_SEC_HANDLE CredentialHandle,
  1135. IN ULONG CredentialAttribute,
  1136. IN OUT PVOID Buffer
  1137. );
  1138. typedef NTSTATUS
  1139. (NTAPI SpAddCredentialsFn)(
  1140. IN LSA_SEC_HANDLE CredentialHandle,
  1141. IN OPTIONAL PUNICODE_STRING PrincipalName,
  1142. IN PUNICODE_STRING Package,
  1143. IN ULONG CredentialUseFlags,
  1144. IN PVOID AuthorizationData,
  1145. IN PVOID GetKeyFunciton,
  1146. IN PVOID GetKeyArgument,
  1147. OUT PTimeStamp ExpirationTime
  1148. );
  1149. typedef NTSTATUS
  1150. (NTAPI SpSaveCredentialsFn)(
  1151. IN LSA_SEC_HANDLE CredentialHandle,
  1152. IN PSecBuffer Credentials);
  1153. typedef NTSTATUS
  1154. (NTAPI SpGetCredentialsFn)(
  1155. IN LSA_SEC_HANDLE CredentialHandle,
  1156. IN OUT PSecBuffer Credentials
  1157. );
  1158. typedef NTSTATUS
  1159. (NTAPI SpDeleteCredentialsFn)(
  1160. IN LSA_SEC_HANDLE CredentialHandle,
  1161. IN PSecBuffer Key
  1162. );
  1163. typedef NTSTATUS
  1164. (NTAPI SpInitLsaModeContextFn)(
  1165. IN OPTIONAL LSA_SEC_HANDLE CredentialHandle,
  1166. IN OPTIONAL LSA_SEC_HANDLE ContextHandle,
  1167. IN OPTIONAL PUNICODE_STRING TargetName,
  1168. IN ULONG ContextRequirements,
  1169. IN ULONG TargetDataRep,
  1170. IN PSecBufferDesc InputBuffers,
  1171. OUT PLSA_SEC_HANDLE NewContextHandle,
  1172. IN OUT PSecBufferDesc OutputBuffers,
  1173. OUT PULONG ContextAttributes,
  1174. OUT PTimeStamp ExpirationTime,
  1175. OUT PBOOLEAN MappedContext,
  1176. OUT PSecBuffer ContextData
  1177. );
  1178. typedef NTSTATUS
  1179. (NTAPI SpDeleteContextFn)(
  1180. IN LSA_SEC_HANDLE ContextHandle
  1181. );
  1182. typedef NTSTATUS
  1183. (NTAPI SpApplyControlTokenFn)(
  1184. IN LSA_SEC_HANDLE ContextHandle,
  1185. IN PSecBufferDesc ControlToken);
  1186. typedef NTSTATUS
  1187. (NTAPI SpAcceptLsaModeContextFn)(
  1188. IN OPTIONAL LSA_SEC_HANDLE CredentialHandle,
  1189. IN OPTIONAL LSA_SEC_HANDLE ContextHandle,
  1190. IN PSecBufferDesc InputBuffer,
  1191. IN ULONG ContextRequirements,
  1192. IN ULONG TargetDataRep,
  1193. OUT PLSA_SEC_HANDLE NewContextHandle,
  1194. OUT PSecBufferDesc OutputBuffer,
  1195. OUT PULONG ContextAttributes,
  1196. OUT PTimeStamp ExpirationTime,
  1197. OUT PBOOLEAN MappedContext,
  1198. OUT PSecBuffer ContextData
  1199. );
  1200. typedef NTSTATUS
  1201. (NTAPI SpGetUserInfoFn)(
  1202. IN PLUID LogonId,
  1203. IN ULONG Flags,
  1204. OUT PSecurityUserData * UserData
  1205. );
  1206. typedef NTSTATUS
  1207. (NTAPI SpQueryContextAttributesFn)(
  1208. IN LSA_SEC_HANDLE ContextHandle,
  1209. IN ULONG ContextAttribute,
  1210. IN OUT PVOID Buffer);
  1211. typedef NTSTATUS
  1212. (NTAPI SpSetContextAttributesFn)(
  1213. IN LSA_SEC_HANDLE ContextHandle,
  1214. IN ULONG ContextAttribute,
  1215. IN PVOID Buffer,
  1216. IN ULONG BufferSize );
  1217. typedef struct _SECPKG_FUNCTION_TABLE {
  1218. PLSA_AP_INITIALIZE_PACKAGE InitializePackage;
  1219. PLSA_AP_LOGON_USER LogonUser;
  1220. PLSA_AP_CALL_PACKAGE CallPackage;
  1221. PLSA_AP_LOGON_TERMINATED LogonTerminated;
  1222. PLSA_AP_CALL_PACKAGE_UNTRUSTED CallPackageUntrusted;
  1223. PLSA_AP_CALL_PACKAGE_PASSTHROUGH CallPackagePassthrough;
  1224. PLSA_AP_LOGON_USER_EX LogonUserEx;
  1225. PLSA_AP_LOGON_USER_EX2 LogonUserEx2;
  1226. SpInitializeFn * Initialize;
  1227. SpShutdownFn * Shutdown;
  1228. SpGetInfoFn * GetInfo;
  1229. SpAcceptCredentialsFn * AcceptCredentials;
  1230. SpAcquireCredentialsHandleFn * AcquireCredentialsHandle;
  1231. SpQueryCredentialsAttributesFn * QueryCredentialsAttributes;
  1232. SpFreeCredentialsHandleFn * FreeCredentialsHandle;
  1233. SpSaveCredentialsFn * SaveCredentials;
  1234. SpGetCredentialsFn * GetCredentials;
  1235. SpDeleteCredentialsFn * DeleteCredentials;
  1236. SpInitLsaModeContextFn * InitLsaModeContext;
  1237. SpAcceptLsaModeContextFn * AcceptLsaModeContext;
  1238. SpDeleteContextFn * DeleteContext;
  1239. SpApplyControlTokenFn * ApplyControlToken;
  1240. SpGetUserInfoFn * GetUserInfo;
  1241. SpGetExtendedInformationFn * GetExtendedInformation ;
  1242. SpQueryContextAttributesFn * QueryContextAttributes ;
  1243. SpAddCredentialsFn * AddCredentials ;
  1244. SpSetExtendedInformationFn * SetExtendedInformation ;
  1245. SpSetContextAttributesFn * SetContextAttributes ;
  1246. } SECPKG_FUNCTION_TABLE, *PSECPKG_FUNCTION_TABLE;
  1247. //
  1248. // The following prototypes are to functions that will be called while in the
  1249. // context of a user process that is using the functions through the security
  1250. // DLL.
  1251. //
  1252. typedef NTSTATUS
  1253. (NTAPI SpInstanceInitFn)(
  1254. IN ULONG Version,
  1255. IN PSECPKG_DLL_FUNCTIONS FunctionTable,
  1256. OUT PVOID * UserFunctions
  1257. );
  1258. typedef NTSTATUS
  1259. (NTAPI SpInitUserModeContextFn)(
  1260. IN LSA_SEC_HANDLE ContextHandle,
  1261. IN PSecBuffer PackedContext
  1262. );
  1263. typedef NTSTATUS
  1264. (NTAPI SpMakeSignatureFn)(
  1265. IN LSA_SEC_HANDLE ContextHandle,
  1266. IN ULONG QualityOfProtection,
  1267. IN PSecBufferDesc MessageBuffers,
  1268. IN ULONG MessageSequenceNumber
  1269. );
  1270. typedef NTSTATUS
  1271. (NTAPI SpVerifySignatureFn)(
  1272. IN LSA_SEC_HANDLE ContextHandle,
  1273. IN PSecBufferDesc MessageBuffers,
  1274. IN ULONG MessageSequenceNumber,
  1275. OUT PULONG QualityOfProtection
  1276. );
  1277. typedef NTSTATUS
  1278. (NTAPI SpSealMessageFn)(
  1279. IN LSA_SEC_HANDLE ContextHandle,
  1280. IN ULONG QualityOfProtection,
  1281. IN PSecBufferDesc MessageBuffers,
  1282. IN ULONG MessageSequenceNumber
  1283. );
  1284. typedef NTSTATUS
  1285. (NTAPI SpUnsealMessageFn)(
  1286. IN LSA_SEC_HANDLE ContextHandle,
  1287. IN PSecBufferDesc MessageBuffers,
  1288. IN ULONG MessageSequenceNumber,
  1289. OUT PULONG QualityOfProtection
  1290. );
  1291. typedef NTSTATUS
  1292. (NTAPI SpGetContextTokenFn)(
  1293. IN LSA_SEC_HANDLE ContextHandle,
  1294. OUT PHANDLE ImpersonationToken
  1295. );
  1296. typedef NTSTATUS
  1297. (NTAPI SpExportSecurityContextFn)(
  1298. LSA_SEC_HANDLE phContext, // (in) context to export
  1299. ULONG fFlags, // (in) option flags
  1300. PSecBuffer pPackedContext, // (out) marshalled context
  1301. PHANDLE pToken // (out, optional) token handle for impersonation
  1302. );
  1303. typedef NTSTATUS
  1304. (NTAPI SpImportSecurityContextFn)(
  1305. PSecBuffer pPackedContext, // (in) marshalled context
  1306. HANDLE Token, // (in, optional) handle to token for context
  1307. PLSA_SEC_HANDLE phContext // (out) new context handle
  1308. );
  1309. typedef NTSTATUS
  1310. (NTAPI SpCompleteAuthTokenFn)(
  1311. IN LSA_SEC_HANDLE ContextHandle,
  1312. IN PSecBufferDesc InputBuffer
  1313. );
  1314. typedef NTSTATUS
  1315. (NTAPI SpFormatCredentialsFn)(
  1316. IN PSecBuffer Credentials,
  1317. OUT PSecBuffer FormattedCredentials
  1318. );
  1319. typedef NTSTATUS
  1320. (NTAPI SpMarshallSupplementalCredsFn)(
  1321. IN ULONG CredentialSize,
  1322. IN PUCHAR Credentials,
  1323. OUT PULONG MarshalledCredSize,
  1324. OUT PVOID * MarshalledCreds);
  1325. typedef struct _SECPKG_USER_FUNCTION_TABLE {
  1326. SpInstanceInitFn * InstanceInit;
  1327. SpInitUserModeContextFn * InitUserModeContext;
  1328. SpMakeSignatureFn * MakeSignature;
  1329. SpVerifySignatureFn * VerifySignature;
  1330. SpSealMessageFn * SealMessage;
  1331. SpUnsealMessageFn * UnsealMessage;
  1332. SpGetContextTokenFn * GetContextToken;
  1333. SpQueryContextAttributesFn * QueryContextAttributes;
  1334. SpCompleteAuthTokenFn * CompleteAuthToken;
  1335. SpDeleteContextFn * DeleteUserModeContext;
  1336. SpFormatCredentialsFn * FormatCredentials;
  1337. SpMarshallSupplementalCredsFn * MarshallSupplementalCreds;
  1338. SpExportSecurityContextFn * ExportContext;
  1339. SpImportSecurityContextFn * ImportContext;
  1340. } SECPKG_USER_FUNCTION_TABLE, *PSECPKG_USER_FUNCTION_TABLE;
  1341. typedef NTSTATUS
  1342. (SEC_ENTRY * SpLsaModeInitializeFn)(
  1343. IN ULONG LsaVersion,
  1344. OUT PULONG PackageVersion,
  1345. OUT PSECPKG_FUNCTION_TABLE * ppTables,
  1346. OUT PULONG pcTables);
  1347. typedef NTSTATUS
  1348. (SEC_ENTRY * SpUserModeInitializeFn)(
  1349. IN ULONG LsaVersion,
  1350. OUT PULONG PackageVersion,
  1351. OUT PSECPKG_USER_FUNCTION_TABLE *ppTables,
  1352. OUT PULONG pcTables
  1353. );
  1354. #define SECPKG_LSAMODEINIT_NAME "SpLsaModeInitialize"
  1355. #define SECPKG_USERMODEINIT_NAME "SpUserModeInitialize"
  1356. //
  1357. // Version of the security package interface.
  1358. //
  1359. // These define are used for all of the following:
  1360. // * Passed by the LSA to SpLsaModeInitializeFn to indicate the version of the LSA.
  1361. // All packages currently expect the LSA to pass SECPKG_INTERFACE_VERSION.
  1362. // * Passed by secur32.dll to SpUserModeInitialzeFn to indicate the version of the secur32 DLL.
  1363. // All packages currently expect secur32 to pass SECPKG_INTERFACE_VERSION.
  1364. // * Returned from SpLsaModeInitializeFn to indicate the version of SECPKG_FUNCTION_TABLE.
  1365. // SECPKG_INTERFACE_VERSION indicates all fields through SetExtendedInformation are defined (potentially to NULL)
  1366. // SECPKG_INTERFACE_VERSION_2 indicates all fields through SetContextAttributes are defined (potentially to NULL)
  1367. // * Returned from SpUserModeInitializeFn to indicate the version of the auth package.
  1368. // All packages currently return SECPKG_INTERFACE_VERSION
  1369. //
  1370. #define SECPKG_INTERFACE_VERSION 0x00010000
  1371. #define SECPKG_INTERFACE_VERSION_2 0x00020000
  1372. typedef enum _KSEC_CONTEXT_TYPE {
  1373. KSecPaged,
  1374. KSecNonPaged
  1375. } KSEC_CONTEXT_TYPE ;
  1376. typedef struct _KSEC_LIST_ENTRY {
  1377. LIST_ENTRY List ;
  1378. LONG RefCount ;
  1379. ULONG Signature ;
  1380. PVOID OwningList ;
  1381. PVOID Reserved ;
  1382. } KSEC_LIST_ENTRY, * PKSEC_LIST_ENTRY ;
  1383. #define KsecInitializeListEntry( Entry, SigValue ) \
  1384. ((PKSEC_LIST_ENTRY) Entry)->List.Flink = ((PKSEC_LIST_ENTRY) Entry)->List.Blink = NULL ; \
  1385. ((PKSEC_LIST_ENTRY) Entry)->RefCount = 1 ; \
  1386. ((PKSEC_LIST_ENTRY) Entry)->Signature = SigValue ; \
  1387. ((PKSEC_LIST_ENTRY) Entry)->OwningList = NULL ; \
  1388. ((PKSEC_LIST_ENTRY) Entry)->Reserved = NULL ;
  1389. typedef PVOID
  1390. (SEC_ENTRY KSEC_CREATE_CONTEXT_LIST)(
  1391. IN KSEC_CONTEXT_TYPE Type
  1392. );
  1393. typedef VOID
  1394. (SEC_ENTRY KSEC_INSERT_LIST_ENTRY)(
  1395. IN PVOID List,
  1396. IN PKSEC_LIST_ENTRY Entry
  1397. );
  1398. typedef NTSTATUS
  1399. (SEC_ENTRY KSEC_REFERENCE_LIST_ENTRY)(
  1400. IN PKSEC_LIST_ENTRY Entry,
  1401. IN ULONG Signature,
  1402. IN BOOLEAN RemoveNoRef
  1403. );
  1404. typedef VOID
  1405. (SEC_ENTRY KSEC_DEREFERENCE_LIST_ENTRY)(
  1406. IN PKSEC_LIST_ENTRY Entry,
  1407. OUT BOOLEAN * Delete OPTIONAL
  1408. );
  1409. typedef NTSTATUS
  1410. (SEC_ENTRY KSEC_SERIALIZE_WINNT_AUTH_DATA)(
  1411. IN PVOID pvAuthData,
  1412. OUT PULONG Size,
  1413. OUT PVOID * SerializedData );
  1414. #ifndef MIDL_PASS
  1415. KSEC_CREATE_CONTEXT_LIST KSecCreateContextList ;
  1416. KSEC_INSERT_LIST_ENTRY KSecInsertListEntry ;
  1417. KSEC_REFERENCE_LIST_ENTRY KSecReferenceListEntry ;
  1418. KSEC_DEREFERENCE_LIST_ENTRY KSecDereferenceListEntry ;
  1419. KSEC_SERIALIZE_WINNT_AUTH_DATA KSecSerializeWinntAuthData ;
  1420. #endif // not valid for MIDL_PASS
  1421. typedef KSEC_CREATE_CONTEXT_LIST * PKSEC_CREATE_CONTEXT_LIST ;
  1422. typedef KSEC_INSERT_LIST_ENTRY * PKSEC_INSERT_LIST_ENTRY ;
  1423. typedef KSEC_REFERENCE_LIST_ENTRY * PKSEC_REFERENCE_LIST_ENTRY ;
  1424. typedef KSEC_DEREFERENCE_LIST_ENTRY * PKSEC_DEREFERENCE_LIST_ENTRY ;
  1425. typedef KSEC_SERIALIZE_WINNT_AUTH_DATA * PKSEC_SERIALIZE_WINNT_AUTH_DATA ;
  1426. typedef struct _SECPKG_KERNEL_FUNCTIONS {
  1427. PLSA_ALLOCATE_LSA_HEAP AllocateHeap;
  1428. PLSA_FREE_LSA_HEAP FreeHeap;
  1429. PKSEC_CREATE_CONTEXT_LIST CreateContextList ;
  1430. PKSEC_INSERT_LIST_ENTRY InsertListEntry ;
  1431. PKSEC_REFERENCE_LIST_ENTRY ReferenceListEntry ;
  1432. PKSEC_DEREFERENCE_LIST_ENTRY DereferenceListEntry ;
  1433. PKSEC_SERIALIZE_WINNT_AUTH_DATA SerializeWinntAuthData ;
  1434. } SECPKG_KERNEL_FUNCTIONS, *PSECPKG_KERNEL_FUNCTIONS;
  1435. typedef NTSTATUS
  1436. (NTAPI KspInitPackageFn)(
  1437. PSECPKG_KERNEL_FUNCTIONS FunctionTable
  1438. );
  1439. typedef NTSTATUS
  1440. (NTAPI KspDeleteContextFn)(
  1441. IN LSA_SEC_HANDLE ContextId,
  1442. OUT PLSA_SEC_HANDLE LsaContextId
  1443. );
  1444. typedef NTSTATUS
  1445. (NTAPI KspInitContextFn)(
  1446. IN LSA_SEC_HANDLE ContextId,
  1447. IN PSecBuffer ContextData,
  1448. OUT PLSA_SEC_HANDLE NewContextId
  1449. );
  1450. typedef NTSTATUS
  1451. (NTAPI KspMakeSignatureFn)(
  1452. IN LSA_SEC_HANDLE ContextId,
  1453. IN ULONG fQOP,
  1454. IN OUT PSecBufferDesc Message,
  1455. IN ULONG MessageSeqNo
  1456. );
  1457. typedef NTSTATUS
  1458. (NTAPI KspVerifySignatureFn)(
  1459. IN LSA_SEC_HANDLE ContextId,
  1460. IN OUT PSecBufferDesc Message,
  1461. IN ULONG MessageSeqNo,
  1462. OUT PULONG pfQOP
  1463. );
  1464. typedef NTSTATUS
  1465. (NTAPI KspSealMessageFn)(
  1466. IN LSA_SEC_HANDLE ContextId,
  1467. IN ULONG fQOP,
  1468. IN OUT PSecBufferDesc Message,
  1469. IN ULONG MessageSeqNo
  1470. );
  1471. typedef NTSTATUS
  1472. (NTAPI KspUnsealMessageFn)(
  1473. IN LSA_SEC_HANDLE ContextId,
  1474. IN OUT PSecBufferDesc Message,
  1475. IN ULONG MessageSeqNo,
  1476. OUT PULONG pfQOP
  1477. );
  1478. typedef NTSTATUS
  1479. (NTAPI KspGetTokenFn)(
  1480. IN LSA_SEC_HANDLE ContextId,
  1481. OUT PHANDLE ImpersonationToken,
  1482. OUT OPTIONAL PACCESS_TOKEN * RawToken
  1483. );
  1484. typedef NTSTATUS
  1485. (NTAPI KspQueryAttributesFn)(
  1486. IN LSA_SEC_HANDLE ContextId,
  1487. IN ULONG Attribute,
  1488. IN OUT PVOID Buffer
  1489. );
  1490. typedef NTSTATUS
  1491. (NTAPI KspCompleteTokenFn)(
  1492. IN LSA_SEC_HANDLE ContextId,
  1493. IN PSecBufferDesc Token
  1494. );
  1495. typedef NTSTATUS
  1496. (NTAPI KspMapHandleFn)(
  1497. IN LSA_SEC_HANDLE ContextId,
  1498. OUT PLSA_SEC_HANDLE LsaContextId
  1499. );
  1500. typedef NTSTATUS
  1501. (NTAPI KspSetPagingModeFn)(
  1502. IN BOOLEAN PagingMode
  1503. );
  1504. typedef NTSTATUS
  1505. (NTAPI KspSerializeAuthDataFn)(
  1506. IN PVOID pvAuthData,
  1507. OUT PULONG Size,
  1508. OUT PVOID * SerializedData
  1509. );
  1510. typedef struct _SECPKG_KERNEL_FUNCTION_TABLE {
  1511. KspInitPackageFn * Initialize;
  1512. KspDeleteContextFn * DeleteContext;
  1513. KspInitContextFn * InitContext;
  1514. KspMapHandleFn * MapHandle;
  1515. KspMakeSignatureFn * Sign;
  1516. KspVerifySignatureFn * Verify;
  1517. KspSealMessageFn * Seal;
  1518. KspUnsealMessageFn * Unseal;
  1519. KspGetTokenFn * GetToken;
  1520. KspQueryAttributesFn * QueryAttributes;
  1521. KspCompleteTokenFn * CompleteToken;
  1522. SpExportSecurityContextFn * ExportContext;
  1523. SpImportSecurityContextFn * ImportContext;
  1524. KspSetPagingModeFn * SetPackagePagingMode ;
  1525. KspSerializeAuthDataFn * SerializeAuthData ;
  1526. } SECPKG_KERNEL_FUNCTION_TABLE, *PSECPKG_KERNEL_FUNCTION_TABLE;
  1527. SECURITY_STATUS
  1528. SEC_ENTRY
  1529. KSecRegisterSecurityProvider(
  1530. PSECURITY_STRING ProviderName,
  1531. PSECPKG_KERNEL_FUNCTION_TABLE Table
  1532. );
  1533. extern SECPKG_KERNEL_FUNCTIONS KspKernelFunctions;
  1534. #ifdef __cplusplus
  1535. }
  1536. #endif
  1537. #endif /* _NTSECPKG_ */