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.

1894 lines
56 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_NO_TCB 0x10
  456. #define PRIMARY_CRED_LOGON_PACKAGE_SHIFT 24
  457. #define PRIMARY_CRED_PACKAGE_MASK 0xff000000
  458. //
  459. // For cached logons, the RPC id of the package doing the logon is identified
  460. // by shifting the flags to the right by the PRIMARY_CRED_LOGON_PACKAGE_SHIFT.
  461. //
  462. typedef struct _SECPKG_PRIMARY_CRED {
  463. LUID LogonId;
  464. UNICODE_STRING DownlevelName; // Sam Account Name
  465. UNICODE_STRING DomainName; // Netbios domain name where account is located
  466. UNICODE_STRING Password;
  467. UNICODE_STRING OldPassword;
  468. PSID UserSid;
  469. ULONG Flags;
  470. UNICODE_STRING DnsDomainName; // DNS domain name where account is located (if known)
  471. UNICODE_STRING Upn; // UPN of account (if known)
  472. UNICODE_STRING LogonServer;
  473. UNICODE_STRING Spare1;
  474. UNICODE_STRING Spare2;
  475. UNICODE_STRING Spare3;
  476. UNICODE_STRING Spare4;
  477. } SECPKG_PRIMARY_CRED, *PSECPKG_PRIMARY_CRED;
  478. //
  479. // Maximum size of stored credentials.
  480. //
  481. #define MAX_CRED_SIZE 1024
  482. // Values for MachineState
  483. #define SECPKG_STATE_ENCRYPTION_PERMITTED 0x01
  484. #define SECPKG_STATE_STRONG_ENCRYPTION_PERMITTED 0x02
  485. #define SECPKG_STATE_DOMAIN_CONTROLLER 0x04
  486. #define SECPKG_STATE_WORKSTATION 0x08
  487. #define SECPKG_STATE_STANDALONE 0x10
  488. typedef struct _SECPKG_PARAMETERS {
  489. ULONG Version;
  490. ULONG MachineState;
  491. ULONG SetupMode;
  492. PSID DomainSid;
  493. UNICODE_STRING DomainName;
  494. UNICODE_STRING DnsDomainName;
  495. GUID DomainGuid;
  496. } SECPKG_PARAMETERS, *PSECPKG_PARAMETERS;
  497. //
  498. // Extended Package information structures
  499. //
  500. typedef enum _SECPKG_EXTENDED_INFORMATION_CLASS {
  501. SecpkgGssInfo = 1,
  502. SecpkgContextThunks,
  503. SecpkgMutualAuthLevel,
  504. SecpkgWowClientDll,
  505. SecpkgExtraOids,
  506. SecpkgMaxInfo
  507. } SECPKG_EXTENDED_INFORMATION_CLASS ;
  508. typedef struct _SECPKG_GSS_INFO {
  509. ULONG EncodedIdLength ;
  510. UCHAR EncodedId[4] ;
  511. } SECPKG_GSS_INFO, * PSECPKG_GSS_INFO ;
  512. typedef struct _SECPKG_CONTEXT_THUNKS {
  513. ULONG InfoLevelCount ;
  514. ULONG Levels[1] ;
  515. } SECPKG_CONTEXT_THUNKS, *PSECPKG_CONTEXT_THUNKS ;
  516. typedef struct _SECPKG_MUTUAL_AUTH_LEVEL {
  517. ULONG MutualAuthLevel ;
  518. } SECPKG_MUTUAL_AUTH_LEVEL, * PSECPKG_MUTUAL_AUTH_LEVEL ;
  519. typedef struct _SECPKG_WOW_CLIENT_DLL {
  520. SECURITY_STRING WowClientDllPath;
  521. } SECPKG_WOW_CLIENT_DLL, * PSECPKG_WOW_CLIENT_DLL ;
  522. #define SECPKG_MAX_OID_LENGTH 32
  523. typedef struct _SECPKG_SERIALIZED_OID {
  524. ULONG OidLength ;
  525. ULONG OidAttributes ;
  526. UCHAR OidValue[ SECPKG_MAX_OID_LENGTH ];
  527. } SECPKG_SERIALIZED_OID, * PSECPKG_SERIALIZED_OID ;
  528. typedef struct _SECPKG_EXTRA_OIDS {
  529. ULONG OidCount ;
  530. SECPKG_SERIALIZED_OID Oids[ 1 ];
  531. } SECPKG_EXTRA_OIDS, * PSECPKG_EXTRA_OIDS;
  532. typedef struct _SECPKG_EXTENDED_INFORMATION {
  533. SECPKG_EXTENDED_INFORMATION_CLASS Class ;
  534. union {
  535. SECPKG_GSS_INFO GssInfo ;
  536. SECPKG_CONTEXT_THUNKS ContextThunks ;
  537. SECPKG_MUTUAL_AUTH_LEVEL MutualAuthLevel ;
  538. SECPKG_WOW_CLIENT_DLL WowClientDll ;
  539. SECPKG_EXTRA_OIDS ExtraOids ;
  540. } Info ;
  541. } SECPKG_EXTENDED_INFORMATION, * PSECPKG_EXTENDED_INFORMATION ;
  542. #define SECPKG_ATTR_SASL_CONTEXT 0x00010000
  543. typedef struct _SecPkgContext_SaslContext {
  544. PVOID SaslContext ;
  545. } SecPkgContext_SaslContext, * PSecPkgContext_SaslContext ;
  546. //
  547. // Setting this value as the first context thunk value will cause all
  548. // calls to go to the LSA:
  549. //
  550. #define SECPKG_ATTR_THUNK_ALL 0x00010000
  551. #ifndef SECURITY_USER_DATA_DEFINED
  552. #define SECURITY_USER_DATA_DEFINED
  553. typedef struct _SECURITY_USER_DATA {
  554. SECURITY_STRING UserName; // User name
  555. SECURITY_STRING LogonDomainName; // Domain the user logged on to
  556. SECURITY_STRING LogonServer; // Server that logged the user on
  557. PSID pSid; // SID of user
  558. } SECURITY_USER_DATA, *PSECURITY_USER_DATA;
  559. typedef SECURITY_USER_DATA SecurityUserData, * PSecurityUserData;
  560. #define UNDERSTANDS_LONG_NAMES 1
  561. #define NO_LONG_NAMES 2
  562. #endif // SECURITY_USER_DATA_DEFINED
  563. //////////////////////////////////////////////////////////////////////////
  564. //
  565. // The following prototypes are to functions that are provided by the SPMgr
  566. // to security packages.
  567. //
  568. //////////////////////////////////////////////////////////////////////////
  569. typedef NTSTATUS
  570. (NTAPI LSA_IMPERSONATE_CLIENT) (
  571. VOID
  572. );
  573. typedef NTSTATUS
  574. (NTAPI LSA_UNLOAD_PACKAGE)(
  575. VOID
  576. );
  577. typedef NTSTATUS
  578. (NTAPI LSA_DUPLICATE_HANDLE)(
  579. IN HANDLE SourceHandle,
  580. OUT PHANDLE DestionationHandle);
  581. typedef NTSTATUS
  582. (NTAPI LSA_SAVE_SUPPLEMENTAL_CREDENTIALS)(
  583. IN PLUID LogonId,
  584. IN ULONG SupplementalCredSize,
  585. IN PVOID SupplementalCreds,
  586. IN BOOLEAN Synchronous
  587. );
  588. typedef HANDLE
  589. (NTAPI LSA_CREATE_THREAD)(
  590. IN SEC_ATTRS SecurityAttributes,
  591. IN ULONG StackSize,
  592. IN SEC_THREAD_START StartFunction,
  593. IN PVOID ThreadParameter,
  594. IN ULONG CreationFlags,
  595. OUT PULONG ThreadId
  596. );
  597. typedef NTSTATUS
  598. (NTAPI LSA_GET_CLIENT_INFO)(
  599. OUT PSECPKG_CLIENT_INFO ClientInfo
  600. );
  601. typedef HANDLE
  602. (NTAPI LSA_REGISTER_NOTIFICATION)(
  603. IN SEC_THREAD_START StartFunction,
  604. IN PVOID Parameter,
  605. IN ULONG NotificationType,
  606. IN ULONG NotificationClass,
  607. IN ULONG NotificationFlags,
  608. IN ULONG IntervalMinutes,
  609. IN OPTIONAL HANDLE WaitEvent
  610. );
  611. typedef NTSTATUS
  612. (NTAPI LSA_CANCEL_NOTIFICATION)(
  613. IN HANDLE NotifyHandle
  614. );
  615. typedef NTSTATUS
  616. (NTAPI LSA_MAP_BUFFER)(
  617. IN PSecBuffer InputBuffer,
  618. OUT PSecBuffer OutputBuffer
  619. );
  620. typedef NTSTATUS
  621. (NTAPI LSA_CREATE_TOKEN) (
  622. IN PLUID LogonId,
  623. IN PTOKEN_SOURCE TokenSource,
  624. IN SECURITY_LOGON_TYPE LogonType,
  625. IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
  626. IN LSA_TOKEN_INFORMATION_TYPE TokenInformationType,
  627. IN PVOID TokenInformation,
  628. IN PTOKEN_GROUPS TokenGroups,
  629. IN PUNICODE_STRING AccountName,
  630. IN PUNICODE_STRING AuthorityName,
  631. IN PUNICODE_STRING Workstation,
  632. IN PUNICODE_STRING ProfilePath,
  633. OUT PHANDLE Token,
  634. OUT PNTSTATUS SubStatus
  635. );
  636. typedef enum _SECPKG_SESSIONINFO_TYPE {
  637. SecSessionPrimaryCred // SessionInformation is SECPKG_PRIMARY_CRED
  638. } SECPKG_SESSIONINFO_TYPE ;
  639. typedef NTSTATUS
  640. (NTAPI LSA_CREATE_TOKEN_EX) (
  641. IN PLUID LogonId,
  642. IN PTOKEN_SOURCE TokenSource,
  643. IN SECURITY_LOGON_TYPE LogonType,
  644. IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
  645. IN LSA_TOKEN_INFORMATION_TYPE TokenInformationType,
  646. IN PVOID TokenInformation,
  647. IN PTOKEN_GROUPS TokenGroups,
  648. IN PUNICODE_STRING Workstation,
  649. IN PUNICODE_STRING ProfilePath,
  650. IN PVOID SessionInformation,
  651. IN SECPKG_SESSIONINFO_TYPE SessionInformationType,
  652. OUT PHANDLE Token,
  653. OUT PNTSTATUS SubStatus
  654. );
  655. typedef VOID
  656. (NTAPI LSA_AUDIT_LOGON) (
  657. IN NTSTATUS Status,
  658. IN NTSTATUS SubStatus,
  659. IN PUNICODE_STRING AccountName,
  660. IN PUNICODE_STRING AuthenticatingAuthority,
  661. IN PUNICODE_STRING WorkstationName,
  662. IN OPTIONAL PSID UserSid,
  663. IN SECURITY_LOGON_TYPE LogonType,
  664. IN PTOKEN_SOURCE TokenSource,
  665. IN PLUID LogonId
  666. );
  667. typedef NTSTATUS
  668. (NTAPI LSA_CALL_PACKAGE) (
  669. IN PUNICODE_STRING AuthenticationPackage,
  670. IN PVOID ProtocolSubmitBuffer,
  671. IN ULONG SubmitBufferLength,
  672. OUT PVOID *ProtocolReturnBuffer,
  673. OUT PULONG ReturnBufferLength,
  674. OUT PNTSTATUS ProtocolStatus
  675. );
  676. typedef NTSTATUS
  677. (NTAPI LSA_CALL_PACKAGEEX) (
  678. IN PUNICODE_STRING AuthenticationPackage,
  679. IN PVOID ClientBufferBase,
  680. IN PVOID ProtocolSubmitBuffer,
  681. IN ULONG SubmitBufferLength,
  682. OUT PVOID *ProtocolReturnBuffer,
  683. OUT PULONG ReturnBufferLength,
  684. OUT PNTSTATUS ProtocolStatus
  685. );
  686. typedef NTSTATUS
  687. (NTAPI LSA_CALL_PACKAGE_PASSTHROUGH) (
  688. IN PUNICODE_STRING AuthenticationPackage,
  689. IN PVOID ClientBufferBase,
  690. IN PVOID ProtocolSubmitBuffer,
  691. IN ULONG SubmitBufferLength,
  692. OUT PVOID *ProtocolReturnBuffer,
  693. OUT PULONG ReturnBufferLength,
  694. OUT PNTSTATUS ProtocolStatus
  695. );
  696. typedef BOOLEAN
  697. (NTAPI LSA_GET_CALL_INFO) (
  698. OUT PSECPKG_CALL_INFO Info
  699. );
  700. typedef PVOID
  701. (NTAPI LSA_CREATE_SHARED_MEMORY)(
  702. ULONG MaxSize,
  703. ULONG InitialSize
  704. );
  705. typedef PVOID
  706. (NTAPI LSA_ALLOCATE_SHARED_MEMORY)(
  707. PVOID SharedMem,
  708. ULONG Size
  709. );
  710. typedef VOID
  711. (NTAPI LSA_FREE_SHARED_MEMORY)(
  712. PVOID SharedMem,
  713. PVOID Memory
  714. );
  715. typedef BOOLEAN
  716. (NTAPI LSA_DELETE_SHARED_MEMORY)(
  717. PVOID SharedMem
  718. );
  719. //
  720. // Account Access
  721. //
  722. typedef enum _SECPKG_NAME_TYPE {
  723. SecNameSamCompatible,
  724. SecNameAlternateId,
  725. SecNameFlat,
  726. SecNameDN,
  727. SecNameSPN
  728. } SECPKG_NAME_TYPE ;
  729. typedef NTSTATUS
  730. (NTAPI LSA_OPEN_SAM_USER)(
  731. PSECURITY_STRING Name,
  732. SECPKG_NAME_TYPE NameType,
  733. PSECURITY_STRING Prefix,
  734. BOOLEAN AllowGuest,
  735. ULONG Reserved,
  736. PVOID * UserHandle
  737. );
  738. typedef NTSTATUS
  739. (NTAPI LSA_GET_USER_CREDENTIALS)(
  740. PVOID UserHandle,
  741. PVOID * PrimaryCreds,
  742. PULONG PrimaryCredsSize,
  743. PVOID * SupplementalCreds,
  744. PULONG SupplementalCredsSize
  745. );
  746. typedef NTSTATUS
  747. (NTAPI LSA_GET_USER_AUTH_DATA)(
  748. PVOID UserHandle,
  749. PUCHAR * UserAuthData,
  750. PULONG UserAuthDataSize
  751. );
  752. typedef NTSTATUS
  753. (NTAPI LSA_CLOSE_SAM_USER)(
  754. PVOID UserHandle
  755. );
  756. typedef NTSTATUS
  757. (NTAPI LSA_GET_AUTH_DATA_FOR_USER)(
  758. PSECURITY_STRING Name,
  759. SECPKG_NAME_TYPE NameType,
  760. PSECURITY_STRING Prefix,
  761. PUCHAR * UserAuthData,
  762. PULONG UserAuthDataSize,
  763. PUNICODE_STRING UserFlatName
  764. );
  765. typedef NTSTATUS
  766. (NTAPI LSA_CONVERT_AUTH_DATA_TO_TOKEN)(
  767. IN PVOID UserAuthData,
  768. IN ULONG UserAuthDataSize,
  769. IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
  770. IN PTOKEN_SOURCE TokenSource,
  771. IN SECURITY_LOGON_TYPE LogonType,
  772. IN PUNICODE_STRING AuthorityName,
  773. OUT PHANDLE Token,
  774. OUT PLUID LogonId,
  775. OUT PUNICODE_STRING AccountName,
  776. OUT PNTSTATUS SubStatus
  777. );
  778. typedef NTSTATUS
  779. (NTAPI LSA_CRACK_SINGLE_NAME)(
  780. IN ULONG FormatOffered,
  781. IN BOOLEAN PerformAtGC,
  782. IN PUNICODE_STRING NameInput,
  783. IN PUNICODE_STRING Prefix OPTIONAL,
  784. IN ULONG RequestedFormat,
  785. OUT PUNICODE_STRING CrackedName,
  786. OUT PUNICODE_STRING DnsDomainName,
  787. OUT PULONG SubStatus
  788. );
  789. typedef NTSTATUS
  790. (NTAPI LSA_AUDIT_ACCOUNT_LOGON)(
  791. IN ULONG AuditId,
  792. IN BOOLEAN Success,
  793. IN PUNICODE_STRING Source,
  794. IN PUNICODE_STRING ClientName,
  795. IN PUNICODE_STRING MappedName,
  796. IN NTSTATUS Status
  797. );
  798. typedef NTSTATUS
  799. (NTAPI LSA_CLIENT_CALLBACK)(
  800. PCHAR Callback,
  801. ULONG_PTR Argument1,
  802. ULONG_PTR Argument2,
  803. PSecBuffer Input,
  804. PSecBuffer Output
  805. );
  806. typedef
  807. NTSTATUS
  808. (NTAPI LSA_REGISTER_CALLBACK)(
  809. ULONG CallbackId,
  810. PLSA_CALLBACK_FUNCTION Callback
  811. );
  812. #define NOTIFIER_FLAG_NEW_THREAD 0x00000001
  813. #define NOTIFIER_FLAG_ONE_SHOT 0x00000002
  814. #define NOTIFIER_FLAG_SECONDS 0x80000000
  815. #define NOTIFIER_TYPE_INTERVAL 1
  816. #define NOTIFIER_TYPE_HANDLE_WAIT 2
  817. #define NOTIFIER_TYPE_STATE_CHANGE 3
  818. #define NOTIFIER_TYPE_NOTIFY_EVENT 4
  819. #define NOTIFIER_TYPE_IMMEDIATE 16
  820. #define NOTIFY_CLASS_PACKAGE_CHANGE 1
  821. #define NOTIFY_CLASS_ROLE_CHANGE 2
  822. #define NOTIFY_CLASS_DOMAIN_CHANGE 3
  823. #define NOTIFY_CLASS_REGISTRY_CHANGE 4
  824. typedef struct _SECPKG_EVENT_PACKAGE_CHANGE {
  825. ULONG ChangeType;
  826. LSA_SEC_HANDLE PackageId;
  827. SECURITY_STRING PackageName;
  828. } SECPKG_EVENT_PACKAGE_CHANGE, * PSECPKG_EVENT_PACKAGE_CHANGE ;
  829. #define SECPKG_PACKAGE_CHANGE_LOAD 0
  830. #define SECPKG_PACKAGE_CHANGE_UNLOAD 1
  831. #define SECPKG_PACKAGE_CHANGE_SELECT 2
  832. typedef struct _SECPKG_EVENT_ROLE_CHANGE {
  833. ULONG PreviousRole ;
  834. ULONG NewRole ;
  835. } SECPKG_EVENT_ROLE_CHANGE, * PSECPKG_EVENT_ROLE_CHANGE ;
  836. typedef struct _SECPKG_PARAMETERS SECPKG_EVENT_DOMAIN_CHANGE ;
  837. typedef struct _SECPKG_PARAMETERS * PSECPKG_EVENT_DOMAIN_CHANGE ;
  838. typedef struct _SECPKG_EVENT_NOTIFY {
  839. ULONG EventClass;
  840. ULONG Reserved;
  841. ULONG EventDataSize;
  842. PVOID EventData;
  843. PVOID PackageParameter;
  844. } SECPKG_EVENT_NOTIFY, *PSECPKG_EVENT_NOTIFY ;
  845. typedef
  846. NTSTATUS
  847. (NTAPI LSA_UPDATE_PRIMARY_CREDENTIALS)(
  848. IN PSECPKG_PRIMARY_CRED PrimaryCredentials,
  849. IN OPTIONAL PSECPKG_SUPPLEMENTAL_CRED_ARRAY Credentials
  850. );
  851. typedef
  852. VOID
  853. (NTAPI LSA_PROTECT_MEMORY)(
  854. IN PVOID Buffer,
  855. IN ULONG BufferSize
  856. );
  857. typedef
  858. NTSTATUS
  859. (NTAPI LSA_OPEN_TOKEN_BY_LOGON_ID)(
  860. IN PLUID LogonId,
  861. OUT HANDLE *RetTokenHandle
  862. );
  863. typedef
  864. NTSTATUS
  865. (NTAPI LSA_EXPAND_AUTH_DATA_FOR_DOMAIN)(
  866. IN PUCHAR UserAuthData,
  867. IN ULONG UserAuthDataSize,
  868. IN PVOID Reserved,
  869. OUT PUCHAR * ExpandedAuthData,
  870. OUT PULONG ExpandedAuthDataSize
  871. );
  872. typedef LSA_IMPERSONATE_CLIENT * PLSA_IMPERSONATE_CLIENT;
  873. typedef LSA_UNLOAD_PACKAGE * PLSA_UNLOAD_PACKAGE;
  874. typedef LSA_DUPLICATE_HANDLE * PLSA_DUPLICATE_HANDLE ;
  875. typedef LSA_SAVE_SUPPLEMENTAL_CREDENTIALS * PLSA_SAVE_SUPPLEMENTAL_CREDENTIALS;
  876. typedef LSA_CREATE_THREAD * PLSA_CREATE_THREAD;
  877. typedef LSA_GET_CLIENT_INFO * PLSA_GET_CLIENT_INFO;
  878. typedef LSA_REGISTER_NOTIFICATION * PLSA_REGISTER_NOTIFICATION;
  879. typedef LSA_CANCEL_NOTIFICATION * PLSA_CANCEL_NOTIFICATION;
  880. typedef LSA_MAP_BUFFER * PLSA_MAP_BUFFER;
  881. typedef LSA_CREATE_TOKEN * PLSA_CREATE_TOKEN;
  882. typedef LSA_AUDIT_LOGON * PLSA_AUDIT_LOGON;
  883. typedef LSA_CALL_PACKAGE * PLSA_CALL_PACKAGE;
  884. typedef LSA_CALL_PACKAGEEX * PLSA_CALL_PACKAGEEX;
  885. typedef LSA_GET_CALL_INFO * PLSA_GET_CALL_INFO ;
  886. typedef LSA_CREATE_SHARED_MEMORY * PLSA_CREATE_SHARED_MEMORY ;
  887. typedef LSA_ALLOCATE_SHARED_MEMORY * PLSA_ALLOCATE_SHARED_MEMORY ;
  888. typedef LSA_FREE_SHARED_MEMORY * PLSA_FREE_SHARED_MEMORY ;
  889. typedef LSA_DELETE_SHARED_MEMORY * PLSA_DELETE_SHARED_MEMORY ;
  890. typedef LSA_OPEN_SAM_USER * PLSA_OPEN_SAM_USER ;
  891. typedef LSA_GET_USER_CREDENTIALS * PLSA_GET_USER_CREDENTIALS ;
  892. typedef LSA_GET_USER_AUTH_DATA * PLSA_GET_USER_AUTH_DATA ;
  893. typedef LSA_CLOSE_SAM_USER * PLSA_CLOSE_SAM_USER ;
  894. typedef LSA_CONVERT_AUTH_DATA_TO_TOKEN * PLSA_CONVERT_AUTH_DATA_TO_TOKEN ;
  895. typedef LSA_CLIENT_CALLBACK * PLSA_CLIENT_CALLBACK ;
  896. typedef LSA_REGISTER_CALLBACK * PLSA_REGISTER_CALLBACK ;
  897. typedef LSA_UPDATE_PRIMARY_CREDENTIALS * PLSA_UPDATE_PRIMARY_CREDENTIALS;
  898. typedef LSA_GET_AUTH_DATA_FOR_USER * PLSA_GET_AUTH_DATA_FOR_USER ;
  899. typedef LSA_CRACK_SINGLE_NAME * PLSA_CRACK_SINGLE_NAME ;
  900. typedef LSA_AUDIT_ACCOUNT_LOGON * PLSA_AUDIT_ACCOUNT_LOGON ;
  901. typedef LSA_CALL_PACKAGE_PASSTHROUGH * PLSA_CALL_PACKAGE_PASSTHROUGH;
  902. typedef LSA_PROTECT_MEMORY * PLSA_PROTECT_MEMORY;
  903. typedef LSA_OPEN_TOKEN_BY_LOGON_ID * PLSA_OPEN_TOKEN_BY_LOGON_ID;
  904. typedef LSA_EXPAND_AUTH_DATA_FOR_DOMAIN * PLSA_EXPAND_AUTH_DATA_FOR_DOMAIN;
  905. typedef LSA_CREATE_TOKEN_EX * PLSA_CREATE_TOKEN_EX;
  906. #ifdef _WINCRED_H_
  907. //
  908. // When passing a credential around, the CredentialBlob field is encrypted.
  909. // This structure describes this encrypted form.
  910. //
  911. //
  912. #ifndef _ENCRYPTED_CREDENTIAL_DEFINED
  913. #define _ENCRYPTED_CREDENTIAL_DEFINED
  914. typedef struct _ENCRYPTED_CREDENTIALW {
  915. //
  916. // The credential
  917. //
  918. // The CredentialBlob field points to the encrypted credential
  919. // The CredentialBlobSize field is the length (in bytes) of the encrypted credential
  920. //
  921. CREDENTIALW Cred;
  922. //
  923. // The size in bytes of the clear text credential blob
  924. //
  925. ULONG ClearCredentialBlobSize;
  926. } ENCRYPTED_CREDENTIALW, *PENCRYPTED_CREDENTIALW;
  927. #endif // _ENCRYPTED_CREDENTIAL_DEFINED
  928. //
  929. // Values for CredFlags parameter
  930. //
  931. #define CREDP_FLAGS_IN_PROCESS 0x01 // Caller is in-process. Password data may be returned
  932. #define CREDP_FLAGS_USE_MIDL_HEAP 0x02 // Allocated buffer should use MIDL_user_allocte
  933. #define CREDP_FLAGS_DONT_CACHE_TI 0x04 // TargetInformation shouldn't be cached for CredGetTargetInfo
  934. #define CREDP_FLAGS_CLEAR_PASSWORD 0x08 // Credential blob is passed in in-the-clear
  935. #define CREDP_FLAGS_USER_ENCRYPTED_PASSWORD 0x10 // Credential blob is passed protected by RtlEncryptMemory
  936. typedef NTSTATUS
  937. (NTAPI CredReadFn) (
  938. IN PLUID LogonId,
  939. IN ULONG CredFlags,
  940. IN LPWSTR TargetName,
  941. IN ULONG Type,
  942. IN ULONG Flags,
  943. OUT PENCRYPTED_CREDENTIALW *Credential
  944. );
  945. typedef NTSTATUS
  946. (NTAPI CredReadDomainCredentialsFn) (
  947. IN PLUID LogonId,
  948. IN ULONG CredFlags,
  949. IN PCREDENTIAL_TARGET_INFORMATIONW TargetInfo,
  950. IN ULONG Flags,
  951. OUT PULONG Count,
  952. OUT PENCRYPTED_CREDENTIALW **Credential
  953. );
  954. typedef VOID
  955. (NTAPI CredFreeCredentialsFn) (
  956. IN ULONG Count,
  957. IN PENCRYPTED_CREDENTIALW *Credentials OPTIONAL
  958. );
  959. typedef NTSTATUS
  960. (NTAPI CredWriteFn) (
  961. IN PLUID LogonId,
  962. IN ULONG CredFlags,
  963. IN PENCRYPTED_CREDENTIALW Credential,
  964. IN ULONG Flags
  965. );
  966. NTSTATUS
  967. CredMarshalTargetInfo (
  968. IN PCREDENTIAL_TARGET_INFORMATIONW InTargetInfo,
  969. OUT PUSHORT *Buffer,
  970. OUT PULONG BufferSize
  971. );
  972. NTSTATUS
  973. CredUnmarshalTargetInfo (
  974. IN PUSHORT Buffer,
  975. IN ULONG BufferSize,
  976. OUT PCREDENTIAL_TARGET_INFORMATIONW *RetTargetInfo OPTIONAL,
  977. OUT PULONG RetActualSize OPTIONAL
  978. );
  979. // Number of bytes consumed by the trailing size ULONG
  980. #define CRED_MARSHALED_TI_SIZE_SIZE 12
  981. #endif // _WINCRED_H_
  982. //
  983. // Pure 32-bit versions of credential structures for packages
  984. // running wow64:
  985. //
  986. typedef struct _SEC_WINNT_AUTH_IDENTITY32 {
  987. ULONG User ;
  988. ULONG UserLength ;
  989. ULONG Domain ;
  990. ULONG DomainLength ;
  991. ULONG Password ;
  992. ULONG PasswordLength ;
  993. ULONG Flags ;
  994. } SEC_WINNT_AUTH_IDENTITY32, * PSEC_WINNT_AUTH_IDENTITY32 ;
  995. typedef struct _SEC_WINNT_AUTH_IDENTITY_EX32 {
  996. ULONG Version ;
  997. ULONG Length ;
  998. ULONG User ;
  999. ULONG UserLength ;
  1000. ULONG Domain ;
  1001. ULONG DomainLength ;
  1002. ULONG Password ;
  1003. ULONG PasswordLength ;
  1004. ULONG Flags ;
  1005. ULONG PackageList ;
  1006. ULONG PackageListLength ;
  1007. } SEC_WINNT_AUTH_IDENTITY_EX32, * PSEC_WINNT_AUTH_IDENTITY_EX32 ;
  1008. // Functions provided by the SPM to the packages:
  1009. typedef struct _LSA_SECPKG_FUNCTION_TABLE {
  1010. PLSA_CREATE_LOGON_SESSION CreateLogonSession;
  1011. PLSA_DELETE_LOGON_SESSION DeleteLogonSession;
  1012. PLSA_ADD_CREDENTIAL AddCredential;
  1013. PLSA_GET_CREDENTIALS GetCredentials;
  1014. PLSA_DELETE_CREDENTIAL DeleteCredential;
  1015. PLSA_ALLOCATE_LSA_HEAP AllocateLsaHeap;
  1016. PLSA_FREE_LSA_HEAP FreeLsaHeap;
  1017. PLSA_ALLOCATE_CLIENT_BUFFER AllocateClientBuffer;
  1018. PLSA_FREE_CLIENT_BUFFER FreeClientBuffer;
  1019. PLSA_COPY_TO_CLIENT_BUFFER CopyToClientBuffer;
  1020. PLSA_COPY_FROM_CLIENT_BUFFER CopyFromClientBuffer;
  1021. PLSA_IMPERSONATE_CLIENT ImpersonateClient;
  1022. PLSA_UNLOAD_PACKAGE UnloadPackage;
  1023. PLSA_DUPLICATE_HANDLE DuplicateHandle;
  1024. PLSA_SAVE_SUPPLEMENTAL_CREDENTIALS SaveSupplementalCredentials;
  1025. PLSA_CREATE_THREAD CreateThread;
  1026. PLSA_GET_CLIENT_INFO GetClientInfo;
  1027. PLSA_REGISTER_NOTIFICATION RegisterNotification;
  1028. PLSA_CANCEL_NOTIFICATION CancelNotification;
  1029. PLSA_MAP_BUFFER MapBuffer;
  1030. PLSA_CREATE_TOKEN CreateToken;
  1031. PLSA_AUDIT_LOGON AuditLogon;
  1032. PLSA_CALL_PACKAGE CallPackage;
  1033. PLSA_FREE_LSA_HEAP FreeReturnBuffer;
  1034. PLSA_GET_CALL_INFO GetCallInfo;
  1035. PLSA_CALL_PACKAGEEX CallPackageEx;
  1036. PLSA_CREATE_SHARED_MEMORY CreateSharedMemory;
  1037. PLSA_ALLOCATE_SHARED_MEMORY AllocateSharedMemory;
  1038. PLSA_FREE_SHARED_MEMORY FreeSharedMemory;
  1039. PLSA_DELETE_SHARED_MEMORY DeleteSharedMemory;
  1040. PLSA_OPEN_SAM_USER OpenSamUser ;
  1041. PLSA_GET_USER_CREDENTIALS GetUserCredentials ;
  1042. PLSA_GET_USER_AUTH_DATA GetUserAuthData ;
  1043. PLSA_CLOSE_SAM_USER CloseSamUser ;
  1044. PLSA_CONVERT_AUTH_DATA_TO_TOKEN ConvertAuthDataToToken ;
  1045. PLSA_CLIENT_CALLBACK ClientCallback ;
  1046. PLSA_UPDATE_PRIMARY_CREDENTIALS UpdateCredentials ;
  1047. PLSA_GET_AUTH_DATA_FOR_USER GetAuthDataForUser ;
  1048. PLSA_CRACK_SINGLE_NAME CrackSingleName ;
  1049. PLSA_AUDIT_ACCOUNT_LOGON AuditAccountLogon ;
  1050. PLSA_CALL_PACKAGE_PASSTHROUGH CallPackagePassthrough ;
  1051. #ifdef _WINCRED_H_
  1052. CredReadFn *CrediRead;
  1053. CredReadDomainCredentialsFn *CrediReadDomainCredentials;
  1054. CredFreeCredentialsFn *CrediFreeCredentials;
  1055. #else // _WINCRED_H_
  1056. PLSA_PROTECT_MEMORY DummyFunction1;
  1057. PLSA_PROTECT_MEMORY DummyFunction2;
  1058. PLSA_PROTECT_MEMORY DummyFunction3;
  1059. #endif // _WINCRED_H_
  1060. PLSA_PROTECT_MEMORY LsaProtectMemory;
  1061. PLSA_PROTECT_MEMORY LsaUnprotectMemory;
  1062. PLSA_OPEN_TOKEN_BY_LOGON_ID OpenTokenByLogonId;
  1063. PLSA_EXPAND_AUTH_DATA_FOR_DOMAIN ExpandAuthDataForDomain;
  1064. PLSA_ALLOCATE_PRIVATE_HEAP AllocatePrivateHeap;
  1065. PLSA_FREE_PRIVATE_HEAP FreePrivateHeap;
  1066. PLSA_CREATE_TOKEN_EX CreateTokenEx;
  1067. #ifdef _WINCRED_H_
  1068. CredWriteFn *CrediWrite;
  1069. #else // _WINCRED_H_
  1070. PLSA_PROTECT_MEMORY DummyFunction4;
  1071. #endif // _WINCRED_H_
  1072. } LSA_SECPKG_FUNCTION_TABLE, *PLSA_SECPKG_FUNCTION_TABLE;
  1073. typedef struct _SECPKG_DLL_FUNCTIONS {
  1074. PLSA_ALLOCATE_LSA_HEAP AllocateHeap;
  1075. PLSA_FREE_LSA_HEAP FreeHeap;
  1076. PLSA_REGISTER_CALLBACK RegisterCallback ;
  1077. } SECPKG_DLL_FUNCTIONS, * PSECPKG_DLL_FUNCTIONS;
  1078. //
  1079. // The following prototypes are to functions that will be called only while
  1080. // in the Security Package Manager context.
  1081. //
  1082. typedef NTSTATUS
  1083. (NTAPI SpInitializeFn)(
  1084. IN ULONG_PTR PackageId,
  1085. IN PSECPKG_PARAMETERS Parameters,
  1086. IN PLSA_SECPKG_FUNCTION_TABLE FunctionTable
  1087. );
  1088. typedef NTSTATUS
  1089. (NTAPI SpShutdownFn)(
  1090. VOID
  1091. );
  1092. typedef NTSTATUS
  1093. (NTAPI SpGetInfoFn)(
  1094. OUT PSecPkgInfo PackageInfo
  1095. );
  1096. typedef NTSTATUS
  1097. (NTAPI SpGetExtendedInformationFn)(
  1098. IN SECPKG_EXTENDED_INFORMATION_CLASS Class,
  1099. OUT PSECPKG_EXTENDED_INFORMATION * ppInformation
  1100. );
  1101. typedef NTSTATUS
  1102. (NTAPI SpSetExtendedInformationFn)(
  1103. IN SECPKG_EXTENDED_INFORMATION_CLASS Class,
  1104. IN PSECPKG_EXTENDED_INFORMATION Info
  1105. );
  1106. typedef NTSTATUS
  1107. (LSA_AP_LOGON_USER_EX2) (
  1108. IN PLSA_CLIENT_REQUEST ClientRequest,
  1109. IN SECURITY_LOGON_TYPE LogonType,
  1110. IN PVOID AuthenticationInformation,
  1111. IN PVOID ClientAuthenticationBase,
  1112. IN ULONG AuthenticationInformationLength,
  1113. OUT PVOID *ProfileBuffer,
  1114. OUT PULONG ProfileBufferLength,
  1115. OUT PLUID LogonId,
  1116. OUT PNTSTATUS SubStatus,
  1117. OUT PLSA_TOKEN_INFORMATION_TYPE TokenInformationType,
  1118. OUT PVOID *TokenInformation,
  1119. OUT PUNICODE_STRING *AccountName,
  1120. OUT PUNICODE_STRING *AuthenticatingAuthority,
  1121. OUT PUNICODE_STRING *MachineName,
  1122. OUT PSECPKG_PRIMARY_CRED PrimaryCredentials,
  1123. OUT PSECPKG_SUPPLEMENTAL_CRED_ARRAY * CachedCredentials
  1124. );
  1125. typedef LSA_AP_LOGON_USER_EX2 *PLSA_AP_LOGON_USER_EX2;
  1126. #define LSA_AP_NAME_LOGON_USER_EX2 "LsaApLogonUserEx2\0"
  1127. typedef NTSTATUS
  1128. (NTAPI SpAcceptCredentialsFn)(
  1129. IN SECURITY_LOGON_TYPE LogonType,
  1130. IN PUNICODE_STRING AccountName,
  1131. IN PSECPKG_PRIMARY_CRED PrimaryCredentials,
  1132. IN PSECPKG_SUPPLEMENTAL_CRED SupplementalCredentials
  1133. );
  1134. #define SP_ACCEPT_CREDENTIALS_NAME "SpAcceptCredentials\0"
  1135. typedef NTSTATUS
  1136. (NTAPI SpAcquireCredentialsHandleFn)(
  1137. IN OPTIONAL PUNICODE_STRING PrincipalName,
  1138. IN ULONG CredentialUseFlags,
  1139. IN OPTIONAL PLUID LogonId,
  1140. IN PVOID AuthorizationData,
  1141. IN PVOID GetKeyFunciton,
  1142. IN PVOID GetKeyArgument,
  1143. OUT PLSA_SEC_HANDLE CredentialHandle,
  1144. OUT PTimeStamp ExpirationTime
  1145. );
  1146. typedef NTSTATUS
  1147. (NTAPI SpFreeCredentialsHandleFn)(
  1148. IN LSA_SEC_HANDLE CredentialHandle
  1149. );
  1150. typedef NTSTATUS
  1151. (NTAPI SpQueryCredentialsAttributesFn)(
  1152. IN LSA_SEC_HANDLE CredentialHandle,
  1153. IN ULONG CredentialAttribute,
  1154. IN OUT PVOID Buffer
  1155. );
  1156. typedef NTSTATUS
  1157. (NTAPI SpAddCredentialsFn)(
  1158. IN LSA_SEC_HANDLE CredentialHandle,
  1159. IN OPTIONAL PUNICODE_STRING PrincipalName,
  1160. IN PUNICODE_STRING Package,
  1161. IN ULONG CredentialUseFlags,
  1162. IN PVOID AuthorizationData,
  1163. IN PVOID GetKeyFunciton,
  1164. IN PVOID GetKeyArgument,
  1165. OUT PTimeStamp ExpirationTime
  1166. );
  1167. typedef NTSTATUS
  1168. (NTAPI SpSaveCredentialsFn)(
  1169. IN LSA_SEC_HANDLE CredentialHandle,
  1170. IN PSecBuffer Credentials);
  1171. typedef NTSTATUS
  1172. (NTAPI SpGetCredentialsFn)(
  1173. IN LSA_SEC_HANDLE CredentialHandle,
  1174. IN OUT PSecBuffer Credentials
  1175. );
  1176. typedef NTSTATUS
  1177. (NTAPI SpDeleteCredentialsFn)(
  1178. IN LSA_SEC_HANDLE CredentialHandle,
  1179. IN PSecBuffer Key
  1180. );
  1181. typedef NTSTATUS
  1182. (NTAPI SpInitLsaModeContextFn)(
  1183. IN OPTIONAL LSA_SEC_HANDLE CredentialHandle,
  1184. IN OPTIONAL LSA_SEC_HANDLE ContextHandle,
  1185. IN OPTIONAL PUNICODE_STRING TargetName,
  1186. IN ULONG ContextRequirements,
  1187. IN ULONG TargetDataRep,
  1188. IN PSecBufferDesc InputBuffers,
  1189. OUT PLSA_SEC_HANDLE NewContextHandle,
  1190. IN OUT PSecBufferDesc OutputBuffers,
  1191. OUT PULONG ContextAttributes,
  1192. OUT PTimeStamp ExpirationTime,
  1193. OUT PBOOLEAN MappedContext,
  1194. OUT PSecBuffer ContextData
  1195. );
  1196. typedef NTSTATUS
  1197. (NTAPI SpDeleteContextFn)(
  1198. IN LSA_SEC_HANDLE ContextHandle
  1199. );
  1200. typedef NTSTATUS
  1201. (NTAPI SpApplyControlTokenFn)(
  1202. IN LSA_SEC_HANDLE ContextHandle,
  1203. IN PSecBufferDesc ControlToken);
  1204. typedef NTSTATUS
  1205. (NTAPI SpAcceptLsaModeContextFn)(
  1206. IN OPTIONAL LSA_SEC_HANDLE CredentialHandle,
  1207. IN OPTIONAL LSA_SEC_HANDLE ContextHandle,
  1208. IN PSecBufferDesc InputBuffer,
  1209. IN ULONG ContextRequirements,
  1210. IN ULONG TargetDataRep,
  1211. OUT PLSA_SEC_HANDLE NewContextHandle,
  1212. OUT PSecBufferDesc OutputBuffer,
  1213. OUT PULONG ContextAttributes,
  1214. OUT PTimeStamp ExpirationTime,
  1215. OUT PBOOLEAN MappedContext,
  1216. OUT PSecBuffer ContextData
  1217. );
  1218. typedef NTSTATUS
  1219. (NTAPI SpGetUserInfoFn)(
  1220. IN PLUID LogonId,
  1221. IN ULONG Flags,
  1222. OUT PSecurityUserData * UserData
  1223. );
  1224. typedef NTSTATUS
  1225. (NTAPI SpQueryContextAttributesFn)(
  1226. IN LSA_SEC_HANDLE ContextHandle,
  1227. IN ULONG ContextAttribute,
  1228. IN OUT PVOID Buffer);
  1229. typedef NTSTATUS
  1230. (NTAPI SpSetContextAttributesFn)(
  1231. IN LSA_SEC_HANDLE ContextHandle,
  1232. IN ULONG ContextAttribute,
  1233. IN PVOID Buffer,
  1234. IN ULONG BufferSize );
  1235. typedef struct _SECPKG_FUNCTION_TABLE {
  1236. PLSA_AP_INITIALIZE_PACKAGE InitializePackage;
  1237. PLSA_AP_LOGON_USER LogonUser;
  1238. PLSA_AP_CALL_PACKAGE CallPackage;
  1239. PLSA_AP_LOGON_TERMINATED LogonTerminated;
  1240. PLSA_AP_CALL_PACKAGE_UNTRUSTED CallPackageUntrusted;
  1241. PLSA_AP_CALL_PACKAGE_PASSTHROUGH CallPackagePassthrough;
  1242. PLSA_AP_LOGON_USER_EX LogonUserEx;
  1243. PLSA_AP_LOGON_USER_EX2 LogonUserEx2;
  1244. SpInitializeFn * Initialize;
  1245. SpShutdownFn * Shutdown;
  1246. SpGetInfoFn * GetInfo;
  1247. SpAcceptCredentialsFn * AcceptCredentials;
  1248. SpAcquireCredentialsHandleFn * AcquireCredentialsHandle;
  1249. SpQueryCredentialsAttributesFn * QueryCredentialsAttributes;
  1250. SpFreeCredentialsHandleFn * FreeCredentialsHandle;
  1251. SpSaveCredentialsFn * SaveCredentials;
  1252. SpGetCredentialsFn * GetCredentials;
  1253. SpDeleteCredentialsFn * DeleteCredentials;
  1254. SpInitLsaModeContextFn * InitLsaModeContext;
  1255. SpAcceptLsaModeContextFn * AcceptLsaModeContext;
  1256. SpDeleteContextFn * DeleteContext;
  1257. SpApplyControlTokenFn * ApplyControlToken;
  1258. SpGetUserInfoFn * GetUserInfo;
  1259. SpGetExtendedInformationFn * GetExtendedInformation ;
  1260. SpQueryContextAttributesFn * QueryContextAttributes ;
  1261. SpAddCredentialsFn * AddCredentials ;
  1262. SpSetExtendedInformationFn * SetExtendedInformation ;
  1263. SpSetContextAttributesFn * SetContextAttributes ;
  1264. } SECPKG_FUNCTION_TABLE, *PSECPKG_FUNCTION_TABLE;
  1265. //
  1266. // The following prototypes are to functions that will be called while in the
  1267. // context of a user process that is using the functions through the security
  1268. // DLL.
  1269. //
  1270. typedef NTSTATUS
  1271. (NTAPI SpInstanceInitFn)(
  1272. IN ULONG Version,
  1273. IN PSECPKG_DLL_FUNCTIONS FunctionTable,
  1274. OUT PVOID * UserFunctions
  1275. );
  1276. typedef NTSTATUS
  1277. (NTAPI SpInitUserModeContextFn)(
  1278. IN LSA_SEC_HANDLE ContextHandle,
  1279. IN PSecBuffer PackedContext
  1280. );
  1281. typedef NTSTATUS
  1282. (NTAPI SpMakeSignatureFn)(
  1283. IN LSA_SEC_HANDLE ContextHandle,
  1284. IN ULONG QualityOfProtection,
  1285. IN PSecBufferDesc MessageBuffers,
  1286. IN ULONG MessageSequenceNumber
  1287. );
  1288. typedef NTSTATUS
  1289. (NTAPI SpVerifySignatureFn)(
  1290. IN LSA_SEC_HANDLE ContextHandle,
  1291. IN PSecBufferDesc MessageBuffers,
  1292. IN ULONG MessageSequenceNumber,
  1293. OUT PULONG QualityOfProtection
  1294. );
  1295. typedef NTSTATUS
  1296. (NTAPI SpSealMessageFn)(
  1297. IN LSA_SEC_HANDLE ContextHandle,
  1298. IN ULONG QualityOfProtection,
  1299. IN PSecBufferDesc MessageBuffers,
  1300. IN ULONG MessageSequenceNumber
  1301. );
  1302. typedef NTSTATUS
  1303. (NTAPI SpUnsealMessageFn)(
  1304. IN LSA_SEC_HANDLE ContextHandle,
  1305. IN PSecBufferDesc MessageBuffers,
  1306. IN ULONG MessageSequenceNumber,
  1307. OUT PULONG QualityOfProtection
  1308. );
  1309. typedef NTSTATUS
  1310. (NTAPI SpGetContextTokenFn)(
  1311. IN LSA_SEC_HANDLE ContextHandle,
  1312. OUT PHANDLE ImpersonationToken
  1313. );
  1314. typedef NTSTATUS
  1315. (NTAPI SpExportSecurityContextFn)(
  1316. LSA_SEC_HANDLE phContext, // (in) context to export
  1317. ULONG fFlags, // (in) option flags
  1318. PSecBuffer pPackedContext, // (out) marshalled context
  1319. PHANDLE pToken // (out, optional) token handle for impersonation
  1320. );
  1321. typedef NTSTATUS
  1322. (NTAPI SpImportSecurityContextFn)(
  1323. PSecBuffer pPackedContext, // (in) marshalled context
  1324. HANDLE Token, // (in, optional) handle to token for context
  1325. PLSA_SEC_HANDLE phContext // (out) new context handle
  1326. );
  1327. typedef NTSTATUS
  1328. (NTAPI SpCompleteAuthTokenFn)(
  1329. IN LSA_SEC_HANDLE ContextHandle,
  1330. IN PSecBufferDesc InputBuffer
  1331. );
  1332. typedef NTSTATUS
  1333. (NTAPI SpFormatCredentialsFn)(
  1334. IN PSecBuffer Credentials,
  1335. OUT PSecBuffer FormattedCredentials
  1336. );
  1337. typedef NTSTATUS
  1338. (NTAPI SpMarshallSupplementalCredsFn)(
  1339. IN ULONG CredentialSize,
  1340. IN PUCHAR Credentials,
  1341. OUT PULONG MarshalledCredSize,
  1342. OUT PVOID * MarshalledCreds);
  1343. typedef struct _SECPKG_USER_FUNCTION_TABLE {
  1344. SpInstanceInitFn * InstanceInit;
  1345. SpInitUserModeContextFn * InitUserModeContext;
  1346. SpMakeSignatureFn * MakeSignature;
  1347. SpVerifySignatureFn * VerifySignature;
  1348. SpSealMessageFn * SealMessage;
  1349. SpUnsealMessageFn * UnsealMessage;
  1350. SpGetContextTokenFn * GetContextToken;
  1351. SpQueryContextAttributesFn * QueryContextAttributes;
  1352. SpCompleteAuthTokenFn * CompleteAuthToken;
  1353. SpDeleteContextFn * DeleteUserModeContext;
  1354. SpFormatCredentialsFn * FormatCredentials;
  1355. SpMarshallSupplementalCredsFn * MarshallSupplementalCreds;
  1356. SpExportSecurityContextFn * ExportContext;
  1357. SpImportSecurityContextFn * ImportContext;
  1358. } SECPKG_USER_FUNCTION_TABLE, *PSECPKG_USER_FUNCTION_TABLE;
  1359. typedef NTSTATUS
  1360. (SEC_ENTRY * SpLsaModeInitializeFn)(
  1361. IN ULONG LsaVersion,
  1362. OUT PULONG PackageVersion,
  1363. OUT PSECPKG_FUNCTION_TABLE * ppTables,
  1364. OUT PULONG pcTables);
  1365. typedef NTSTATUS
  1366. (SEC_ENTRY * SpUserModeInitializeFn)(
  1367. IN ULONG LsaVersion,
  1368. OUT PULONG PackageVersion,
  1369. OUT PSECPKG_USER_FUNCTION_TABLE *ppTables,
  1370. OUT PULONG pcTables
  1371. );
  1372. #define SECPKG_LSAMODEINIT_NAME "SpLsaModeInitialize"
  1373. #define SECPKG_USERMODEINIT_NAME "SpUserModeInitialize"
  1374. //
  1375. // Version of the security package interface.
  1376. //
  1377. // These define are used for all of the following:
  1378. // * Passed by the LSA to SpLsaModeInitializeFn to indicate the version of the LSA.
  1379. // All packages currently expect the LSA to pass SECPKG_INTERFACE_VERSION.
  1380. // * Passed by secur32.dll to SpUserModeInitialzeFn to indicate the version of the secur32 DLL.
  1381. // All packages currently expect secur32 to pass SECPKG_INTERFACE_VERSION.
  1382. // * Returned from SpLsaModeInitializeFn to indicate the version of SECPKG_FUNCTION_TABLE.
  1383. // SECPKG_INTERFACE_VERSION indicates all fields through SetExtendedInformation are defined (potentially to NULL)
  1384. // SECPKG_INTERFACE_VERSION_2 indicates all fields through SetContextAttributes are defined (potentially to NULL)
  1385. // * Returned from SpUserModeInitializeFn to indicate the version of the auth package.
  1386. // All packages currently return SECPKG_INTERFACE_VERSION
  1387. //
  1388. #define SECPKG_INTERFACE_VERSION 0x00010000
  1389. #define SECPKG_INTERFACE_VERSION_2 0x00020000
  1390. typedef enum _KSEC_CONTEXT_TYPE {
  1391. KSecPaged,
  1392. KSecNonPaged
  1393. } KSEC_CONTEXT_TYPE ;
  1394. typedef struct _KSEC_LIST_ENTRY {
  1395. LIST_ENTRY List ;
  1396. LONG RefCount ;
  1397. ULONG Signature ;
  1398. PVOID OwningList ;
  1399. PVOID Reserved ;
  1400. } KSEC_LIST_ENTRY, * PKSEC_LIST_ENTRY ;
  1401. #define KsecInitializeListEntry( Entry, SigValue ) \
  1402. ((PKSEC_LIST_ENTRY) Entry)->List.Flink = ((PKSEC_LIST_ENTRY) Entry)->List.Blink = NULL ; \
  1403. ((PKSEC_LIST_ENTRY) Entry)->RefCount = 1 ; \
  1404. ((PKSEC_LIST_ENTRY) Entry)->Signature = SigValue ; \
  1405. ((PKSEC_LIST_ENTRY) Entry)->OwningList = NULL ; \
  1406. ((PKSEC_LIST_ENTRY) Entry)->Reserved = NULL ;
  1407. typedef PVOID
  1408. (SEC_ENTRY KSEC_CREATE_CONTEXT_LIST)(
  1409. IN KSEC_CONTEXT_TYPE Type
  1410. );
  1411. typedef VOID
  1412. (SEC_ENTRY KSEC_INSERT_LIST_ENTRY)(
  1413. IN PVOID List,
  1414. IN PKSEC_LIST_ENTRY Entry
  1415. );
  1416. typedef NTSTATUS
  1417. (SEC_ENTRY KSEC_REFERENCE_LIST_ENTRY)(
  1418. IN PKSEC_LIST_ENTRY Entry,
  1419. IN ULONG Signature,
  1420. IN BOOLEAN RemoveNoRef
  1421. );
  1422. typedef VOID
  1423. (SEC_ENTRY KSEC_DEREFERENCE_LIST_ENTRY)(
  1424. IN PKSEC_LIST_ENTRY Entry,
  1425. OUT BOOLEAN * Delete OPTIONAL
  1426. );
  1427. typedef NTSTATUS
  1428. (SEC_ENTRY KSEC_SERIALIZE_WINNT_AUTH_DATA)(
  1429. IN PVOID pvAuthData,
  1430. OUT PULONG Size,
  1431. OUT PVOID * SerializedData );
  1432. #ifndef MIDL_PASS
  1433. KSEC_CREATE_CONTEXT_LIST KSecCreateContextList ;
  1434. KSEC_INSERT_LIST_ENTRY KSecInsertListEntry ;
  1435. KSEC_REFERENCE_LIST_ENTRY KSecReferenceListEntry ;
  1436. KSEC_DEREFERENCE_LIST_ENTRY KSecDereferenceListEntry ;
  1437. KSEC_SERIALIZE_WINNT_AUTH_DATA KSecSerializeWinntAuthData ;
  1438. #endif // not valid for MIDL_PASS
  1439. typedef KSEC_CREATE_CONTEXT_LIST * PKSEC_CREATE_CONTEXT_LIST ;
  1440. typedef KSEC_INSERT_LIST_ENTRY * PKSEC_INSERT_LIST_ENTRY ;
  1441. typedef KSEC_REFERENCE_LIST_ENTRY * PKSEC_REFERENCE_LIST_ENTRY ;
  1442. typedef KSEC_DEREFERENCE_LIST_ENTRY * PKSEC_DEREFERENCE_LIST_ENTRY ;
  1443. typedef KSEC_SERIALIZE_WINNT_AUTH_DATA * PKSEC_SERIALIZE_WINNT_AUTH_DATA ;
  1444. typedef struct _SECPKG_KERNEL_FUNCTIONS {
  1445. PLSA_ALLOCATE_LSA_HEAP AllocateHeap;
  1446. PLSA_FREE_LSA_HEAP FreeHeap;
  1447. PKSEC_CREATE_CONTEXT_LIST CreateContextList ;
  1448. PKSEC_INSERT_LIST_ENTRY InsertListEntry ;
  1449. PKSEC_REFERENCE_LIST_ENTRY ReferenceListEntry ;
  1450. PKSEC_DEREFERENCE_LIST_ENTRY DereferenceListEntry ;
  1451. PKSEC_SERIALIZE_WINNT_AUTH_DATA SerializeWinntAuthData ;
  1452. } SECPKG_KERNEL_FUNCTIONS, *PSECPKG_KERNEL_FUNCTIONS;
  1453. typedef NTSTATUS
  1454. (NTAPI KspInitPackageFn)(
  1455. PSECPKG_KERNEL_FUNCTIONS FunctionTable
  1456. );
  1457. typedef NTSTATUS
  1458. (NTAPI KspDeleteContextFn)(
  1459. IN LSA_SEC_HANDLE ContextId,
  1460. OUT PLSA_SEC_HANDLE LsaContextId
  1461. );
  1462. typedef NTSTATUS
  1463. (NTAPI KspInitContextFn)(
  1464. IN LSA_SEC_HANDLE ContextId,
  1465. IN PSecBuffer ContextData,
  1466. OUT PLSA_SEC_HANDLE NewContextId
  1467. );
  1468. typedef NTSTATUS
  1469. (NTAPI KspMakeSignatureFn)(
  1470. IN LSA_SEC_HANDLE ContextId,
  1471. IN ULONG fQOP,
  1472. IN OUT PSecBufferDesc Message,
  1473. IN ULONG MessageSeqNo
  1474. );
  1475. typedef NTSTATUS
  1476. (NTAPI KspVerifySignatureFn)(
  1477. IN LSA_SEC_HANDLE ContextId,
  1478. IN OUT PSecBufferDesc Message,
  1479. IN ULONG MessageSeqNo,
  1480. OUT PULONG pfQOP
  1481. );
  1482. typedef NTSTATUS
  1483. (NTAPI KspSealMessageFn)(
  1484. IN LSA_SEC_HANDLE ContextId,
  1485. IN ULONG fQOP,
  1486. IN OUT PSecBufferDesc Message,
  1487. IN ULONG MessageSeqNo
  1488. );
  1489. typedef NTSTATUS
  1490. (NTAPI KspUnsealMessageFn)(
  1491. IN LSA_SEC_HANDLE ContextId,
  1492. IN OUT PSecBufferDesc Message,
  1493. IN ULONG MessageSeqNo,
  1494. OUT PULONG pfQOP
  1495. );
  1496. typedef NTSTATUS
  1497. (NTAPI KspGetTokenFn)(
  1498. IN LSA_SEC_HANDLE ContextId,
  1499. OUT PHANDLE ImpersonationToken,
  1500. OUT OPTIONAL PACCESS_TOKEN * RawToken
  1501. );
  1502. typedef NTSTATUS
  1503. (NTAPI KspQueryAttributesFn)(
  1504. IN LSA_SEC_HANDLE ContextId,
  1505. IN ULONG Attribute,
  1506. IN OUT PVOID Buffer
  1507. );
  1508. typedef NTSTATUS
  1509. (NTAPI KspCompleteTokenFn)(
  1510. IN LSA_SEC_HANDLE ContextId,
  1511. IN PSecBufferDesc Token
  1512. );
  1513. typedef NTSTATUS
  1514. (NTAPI KspMapHandleFn)(
  1515. IN LSA_SEC_HANDLE ContextId,
  1516. OUT PLSA_SEC_HANDLE LsaContextId
  1517. );
  1518. typedef NTSTATUS
  1519. (NTAPI KspSetPagingModeFn)(
  1520. IN BOOLEAN PagingMode
  1521. );
  1522. typedef NTSTATUS
  1523. (NTAPI KspSerializeAuthDataFn)(
  1524. IN PVOID pvAuthData,
  1525. OUT PULONG Size,
  1526. OUT PVOID * SerializedData
  1527. );
  1528. typedef struct _SECPKG_KERNEL_FUNCTION_TABLE {
  1529. KspInitPackageFn * Initialize;
  1530. KspDeleteContextFn * DeleteContext;
  1531. KspInitContextFn * InitContext;
  1532. KspMapHandleFn * MapHandle;
  1533. KspMakeSignatureFn * Sign;
  1534. KspVerifySignatureFn * Verify;
  1535. KspSealMessageFn * Seal;
  1536. KspUnsealMessageFn * Unseal;
  1537. KspGetTokenFn * GetToken;
  1538. KspQueryAttributesFn * QueryAttributes;
  1539. KspCompleteTokenFn * CompleteToken;
  1540. SpExportSecurityContextFn * ExportContext;
  1541. SpImportSecurityContextFn * ImportContext;
  1542. KspSetPagingModeFn * SetPackagePagingMode ;
  1543. KspSerializeAuthDataFn * SerializeAuthData ;
  1544. } SECPKG_KERNEL_FUNCTION_TABLE, *PSECPKG_KERNEL_FUNCTION_TABLE;
  1545. SECURITY_STATUS
  1546. SEC_ENTRY
  1547. KSecRegisterSecurityProvider(
  1548. PSECURITY_STRING ProviderName,
  1549. PSECPKG_KERNEL_FUNCTION_TABLE Table
  1550. );
  1551. extern SECPKG_KERNEL_FUNCTIONS KspKernelFunctions;
  1552. #ifdef __cplusplus
  1553. }
  1554. #endif
  1555. #endif /* _NTSECPKG_ */