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.

556 lines
10 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  5. //
  6. // File: protos.h
  7. //
  8. // Contents:
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 9-21-94 RichardW Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #ifndef __PROTOS_H__
  18. #define __PROTOS_H__
  19. BOOL
  20. AddPackageToRegistry(
  21. PSECURITY_STRING Package
  22. );
  23. NTSTATUS
  24. LoadParameters(
  25. VOID
  26. );
  27. NTSTATUS
  28. LoadPackage(
  29. PUNICODE_STRING pName,
  30. ULONG_PTR dwPackageID,
  31. PSECPKG_PARAMETERS pParameters
  32. );
  33. NTSTATUS
  34. LoadOldPackage(
  35. PUNICODE_STRING pName,
  36. ULONG_PTR dwPackageID
  37. );
  38. void
  39. UnloadPackages(
  40. void
  41. );
  42. VOID
  43. LsapShutdownInprocDll(
  44. VOID
  45. );
  46. BOOL
  47. SpConsoleHandler(
  48. ULONG dwCtrlType
  49. );
  50. NTSTATUS
  51. ServerStop(
  52. void
  53. );
  54. NTSTATUS
  55. StopRPC(
  56. void
  57. );
  58. void
  59. TimeStampToString(
  60. PTimeStamp,
  61. PUNICODE_STRING
  62. );
  63. //
  64. // Control constants for LsapBuildSD
  65. //
  66. #define BUILD_KSEC_SD 0
  67. #define BUILD_LPC_SD 1
  68. NTSTATUS
  69. LsapBuildSD(
  70. IN ULONG dwType,
  71. OUT PSECURITY_DESCRIPTOR *ppSD OPTIONAL
  72. );
  73. NTSTATUS
  74. StartLpcThread(
  75. void
  76. );
  77. NTSTATUS
  78. StopLpcThread(
  79. void
  80. );
  81. HANDLE
  82. SpmCreateEvent(
  83. LPSECURITY_ATTRIBUTES lpsa,
  84. BOOL fManualReset,
  85. BOOL fInitialState,
  86. LPWSTR pszEventName
  87. );
  88. HANDLE
  89. SpmOpenEvent(
  90. ACCESS_MASK DesiredAccess,
  91. BOOL fInherit,
  92. LPWSTR pszEventName
  93. );
  94. BOOLEAN
  95. SpmpIsSetupPass( VOID );
  96. BOOLEAN
  97. SpmpIsMiniSetupPass( VOID );
  98. NTSTATUS
  99. SPException(
  100. NTSTATUS Status,
  101. ULONG_PTR PackageId
  102. );
  103. void
  104. ScavengerThread();
  105. BOOL
  106. LsapInitializeScavenger(
  107. VOID
  108. );
  109. BOOLEAN
  110. NTAPI
  111. LsapEventNotify(
  112. ULONG Class,
  113. ULONG Flags,
  114. ULONG EventSize,
  115. PVOID Event);
  116. BOOL
  117. SpmpInitializePackageControl(
  118. VOID
  119. );
  120. BOOL
  121. SpmpLoadDll(
  122. PWSTR pszDll,
  123. PSECPKG_PARAMETERS pParameters);
  124. BOOL
  125. SpmpLoadAuthPkgDll(
  126. PWSTR pszDll);
  127. BOOL
  128. SpmpLoadBuiltinAuthPkg(
  129. PSECPKG_FUNCTION_TABLE pTable);
  130. PLSAP_SECURITY_PACKAGE
  131. SpmpValidRequest(
  132. ULONG_PTR PackageHandle,
  133. ULONG ApiCode);
  134. PLSAP_SECURITY_PACKAGE
  135. SpmpValidateHandle(
  136. ULONG_PTR PackageHandle);
  137. PLSAP_SECURITY_PACKAGE
  138. SpmpLocatePackage(
  139. ULONG_PTR PackageId);
  140. PLSAP_SECURITY_PACKAGE
  141. SpmpLookupPackage(
  142. PUNICODE_STRING pszPackageName);
  143. PLSAP_SECURITY_PACKAGE
  144. SpmpLookupPackageByRpcId(
  145. ULONG RpcId);
  146. PLSAP_SECURITY_PACKAGE
  147. SpmpLookupPackageAndRequest(
  148. PUNICODE_STRING pszPackageName,
  149. ULONG ApiCode);
  150. PLSAP_SECURITY_PACKAGE
  151. SpmpIteratePackages(
  152. PLSAP_SECURITY_PACKAGE pInitialPackage);
  153. PLSAP_SECURITY_PACKAGE
  154. SpmpIteratePackagesByRequest(
  155. PLSAP_SECURITY_PACKAGE pInitialPackage,
  156. ULONG ApiCode);
  157. ULONG
  158. SpmpCurrentPackageCount(
  159. VOID);
  160. NTSTATUS
  161. SpmpBootAuthPackage(
  162. PLSAP_SECURITY_PACKAGE pPackage);
  163. BOOL
  164. SpmpLoadBuiltin(
  165. ULONG Flags,
  166. PSECPKG_FUNCTION_TABLE pTable,
  167. PSECPKG_PARAMETERS pParameters);
  168. VOID
  169. LsapAddPackageHandle(
  170. ULONG_PTR PackageId,
  171. BOOL IsContext
  172. );
  173. VOID
  174. LsapDelPackageHandle(
  175. PLSAP_SECURITY_PACKAGE Package,
  176. BOOL IsContext
  177. );
  178. BOOL
  179. IsValidApi(ULONG ApiNum, ULONG_PTR dwPackageId);
  180. BOOL
  181. UnloadPackage(ULONG_PTR dwPackageId);
  182. NTSTATUS
  183. CreateMsvEntry();
  184. NTSTATUS
  185. SpmpInitPolicyFiltering();
  186. void
  187. SpmpCleanupPolicyFiltering();
  188. void
  189. SpmpPurgeEntriesByPackage(ULONG_PTR dwPackageId);
  190. void
  191. InitFastMem(void);
  192. ULONG
  193. RegisterFastMem(ULONG cBytes);
  194. void *
  195. AllocFastMem(ULONG FastMemKey);
  196. void
  197. FreeFastMem(ULONG Key, PVOID pMem);
  198. PVOID
  199. WaitAllocFastMem(ULONG Key, ULONG Retry);
  200. ULONG
  201. FastMemScavenger(PVOID pvIgnored);
  202. //
  203. // NOTE: NOT FOR EXPORT TO SECURITY PACKAGES!
  204. //
  205. PVOID
  206. LsapAssignThread(LPTHREAD_START_ROUTINE pFunction,
  207. PVOID pvParameter,
  208. PSession pSession,
  209. BOOLEAN fUrgent);
  210. BOOL
  211. CreateSubordinateQueue(
  212. PSession pSession,
  213. PLSAP_TASK_QUEUE pOriginalQueue);
  214. BOOL
  215. DeleteSubordinateQueue(
  216. PLSAP_TASK_QUEUE pQueue,
  217. ULONG Flags
  218. );
  219. #define DELETEQ_SYNC_DRAIN 0x00000001
  220. PKSEC_LSA_MEMORY_HEADER
  221. LsapCreateKsecBuffer(
  222. SIZE_T InitialSize
  223. );
  224. PVOID
  225. LsapAllocateFromKsecBuffer(
  226. PKSEC_LSA_MEMORY_HEADER Header,
  227. ULONG Size
  228. );
  229. BOOL
  230. LsapChangeHandle(
  231. SECHANDLE_OPS HandleOp,
  232. PSecHandle OldHandle,
  233. PSecHandle NewHandle
  234. );
  235. NTSTATUS
  236. LsapChangeBuffer(
  237. PSecBuffer Old,
  238. PSecBuffer New
  239. );
  240. // Worker functions:
  241. NTSTATUS
  242. WLsaEstablishCreds(PUNICODE_STRING, PUNICODE_STRING, ULONG, PBYTE, PCredHandle, PTimeStamp);
  243. NTSTATUS
  244. WLsaLogonUser(PUNICODE_STRING, ULONG, PBYTE, ULONG, ULONG *, PBYTE, NTSTATUS *);
  245. NTSTATUS
  246. WLsaAcquireCredHandle(PUNICODE_STRING, PUNICODE_STRING, ULONG, PLUID, PVOID, PVOID, PVOID, PCredHandle, PTimeStamp);
  247. NTSTATUS
  248. WLsaInitContext(PCredHandle, PCtxtHandle, PUNICODE_STRING, ULONG, ULONG, ULONG, PSecBufferDesc, ULONG, PCtxtHandle, PSecBufferDesc, ULONG *, PTimeStamp, PBOOLEAN, PSecBuffer);
  249. NTSTATUS
  250. WLsaAcceptContext(PCredHandle, PCtxtHandle, PSecBufferDesc, ULONG, ULONG, PCtxtHandle, PSecBufferDesc, ULONG *, PTimeStamp, PBOOLEAN, PSecBuffer);
  251. NTSTATUS
  252. WLsaControlFunction(PUNICODE_STRING, ULONG, PSecBuffer, PSecBuffer);
  253. NTSTATUS
  254. WLsaFreeCredHandle(PCredHandle phCred);
  255. NTSTATUS
  256. WLsaDeleteContext(PCtxtHandle phContext );
  257. NTSTATUS
  258. WLsaGetSecurityUserInfo(PLUID pLogonId, ULONG fFlags, PSecurityUserData * pUserInfo);
  259. NTSTATUS
  260. WLsaSaveSupplementalCredentials(PCredHandle phCred, PSecBuffer pCredentials);
  261. NTSTATUS
  262. WLsaGetSupplementalCredentials(PCredHandle phCred, PSecBuffer pCredentials);
  263. NTSTATUS
  264. WLsaDeleteSupplementalCredentials(PCredHandle phCred, PSecBuffer pKey);
  265. NTSTATUS
  266. WLsaGetBinding( ULONG_PTR dwPackageID,
  267. PSEC_PACKAGE_BINDING_INFO BindingInfo,
  268. PULONG TotalSize,
  269. PWSTR * Base);
  270. NTSTATUS
  271. WLsaFindPackage(PUNICODE_STRING pssName, PULONG_PTR pulPackageId);
  272. NTSTATUS
  273. WLsaEnumeratePackages(PULONG pcPackages, PSecPkgInfo * ppPackageInfo);
  274. NTSTATUS
  275. WLsaApplyControlToken(PCtxtHandle phContext, PSecBufferDesc pInput);
  276. NTSTATUS
  277. WLsaQueryPackageInfo(PUNICODE_STRING pssPackageName, PSecPkgInfo * ppPackageInfo);
  278. NTSTATUS
  279. WLsaDeletePackage(
  280. PSECURITY_STRING PackageName);
  281. NTSTATUS
  282. WLsaAddPackage(
  283. PSECURITY_STRING PackageName,
  284. PSECURITY_PACKAGE_OPTIONS Options);
  285. NTSTATUS
  286. WLsaQueryContextAttributes( PCtxtHandle, ULONG, PVOID );
  287. NTSTATUS
  288. WLsaSetContextAttributes(
  289. PCtxtHandle phContext,
  290. ULONG ulAttribute,
  291. PVOID pvBuffer,
  292. ULONG cbBuffer
  293. );
  294. NTSTATUS
  295. WLsaLogonUser2(
  296. IN PSTRING pOriginName,
  297. IN ULONG AuthPkg,
  298. IN SECURITY_LOGON_TYPE LogonType,
  299. IN PVOID AuthInfo,
  300. IN ULONG AuthInfoLength,
  301. IN PTOKEN_GROUPS pTokenGroups,
  302. IN PTOKEN_SOURCE pSourceContext,
  303. IN BOOLEAN CallLicenseServer,
  304. OUT PVOID * ProfileBuffer,
  305. OUT PULONG ProfileBufferLength,
  306. OUT PLUID LogonId,
  307. OUT PNTSTATUS SubStatus,
  308. OUT PHANDLE phToken,
  309. OUT PQUOTA_LIMITS pQuota
  310. );
  311. NTSTATUS WLsaQueryCredAttributes( PCredHandle phCredentials, ULONG ulAttribute, PVOID pBuffer);
  312. NTSTATUS
  313. WLsaAddCredentials(
  314. PCredHandle phCredential,
  315. PSECURITY_STRING pPrincipal,
  316. PSECURITY_STRING pSecPackage,
  317. DWORD fCredentialUse,
  318. PVOID pvAuthData,
  319. PVOID pvGetKeyFn,
  320. PVOID pvGetKeyArgument,
  321. PTimeStamp ptsExpiry);
  322. NTSTATUS
  323. WLsaEnumerateLogonSession(
  324. PULONG Count,
  325. PLUID * Sessions
  326. );
  327. NTSTATUS
  328. WLsaGetLogonSessionData(
  329. PLUID LogonId,
  330. PVOID * LogonData
  331. );
  332. NTSTATUS
  333. LsapSetSessionOptions(
  334. ULONG Request,
  335. ULONG_PTR Argument,
  336. PULONG_PTR Resonse
  337. );
  338. LSA_DISPATCH_FN DispatchAPIDirect;
  339. extern PLSA_DISPATCH_FN DllCallbackHandler ;
  340. NTSTATUS
  341. GetRegistryString(HKEY hKey,
  342. PWSTR pwszSubKey,
  343. PWSTR pwszValue,
  344. PWSTR pwszData,
  345. PULONG pdwCount);
  346. BOOL
  347. InitializeThreadPool(
  348. void
  349. );
  350. NTSTATUS
  351. SpmBuildNtToken(
  352. IN PLUID LogonId,
  353. IN PTOKEN_SOURCE TokenSource,
  354. IN SECURITY_LOGON_TYPE LogonType,
  355. IN LSA_TOKEN_INFORMATION_TYPE TokenInformationType,
  356. IN PVOID TokenInformation,
  357. IN PTOKEN_GROUPS LocalGroups,
  358. IN PUNICODE_STRING AccountName,
  359. IN PUNICODE_STRING AuthorityName,
  360. OUT PHANDLE Token,
  361. OUT PSID * UserSid,
  362. OUT PNTSTATUS SubStatus
  363. );
  364. BOOLEAN
  365. LsapIsEncryptionPermitted(
  366. VOID
  367. );
  368. NTSTATUS
  369. LsapGetExtendedPackageInfo(
  370. PLSAP_SECURITY_PACKAGE Package,
  371. SECPKG_EXTENDED_INFORMATION_CLASS Class,
  372. PSECPKG_EXTENDED_INFORMATION * Info
  373. );
  374. NTSTATUS
  375. LsapSetExtendedPackageInfo(
  376. PLSAP_SECURITY_PACKAGE Package,
  377. SECPKG_EXTENDED_INFORMATION_CLASS Class,
  378. PSECPKG_EXTENDED_INFORMATION Info
  379. );
  380. #ifdef __cplusplus
  381. extern "C"
  382. #endif
  383. NTSTATUS
  384. LsapDuplicateSid(
  385. OUT PSID * DestinationSid,
  386. IN PSID SourceSid
  387. );
  388. #ifdef __cplusplus
  389. extern "C"
  390. #endif
  391. NTSTATUS
  392. LsapDuplicateSid2(
  393. OUT PSID * DestinationSid,
  394. IN PSID SourceSid
  395. );
  396. #ifdef __cplusplus
  397. extern "C"
  398. #endif
  399. PSID
  400. LsapMakeDomainRelativeSid(
  401. IN PSID DomainId,
  402. IN ULONG RelativeId
  403. );
  404. #ifdef __cplusplus
  405. extern "C"
  406. #endif
  407. PSID
  408. LsapMakeDomainRelativeSid2(
  409. IN PSID DomainId,
  410. IN ULONG RelativeId
  411. );
  412. //
  413. // Debug helpers to track down bogus handle use
  414. //
  415. #if DBG > 0
  416. #define SpmSetEvent(hHandle) ASSERT(SetEvent(hHandle))
  417. #define SpmCloseHandle(hHandle) ASSERT(CloseHandle(hHandle))
  418. #else
  419. #define SpmSetEvent(hHandle) SetEvent(hHandle)
  420. #define SpmCloseHandle(hHandle) CloseHandle(hHandle)
  421. #endif
  422. VOID
  423. InitScavengerControl(VOID);
  424. ULONG
  425. SpmpReportEvent(
  426. IN BOOL Unicode,
  427. IN WORD EventType,
  428. IN ULONG EventId,
  429. IN ULONG Category,
  430. IN ULONG SizeOfRawData,
  431. IN PVOID RawData,
  432. IN ULONG NumberOfStrings,
  433. ...
  434. );
  435. ULONG
  436. SpmpReportEventU(
  437. IN WORD EventType,
  438. IN ULONG EventId,
  439. IN ULONG Category,
  440. IN ULONG SizeOfRawData,
  441. IN PVOID RawData,
  442. IN ULONG NumberOfStrings,
  443. ...
  444. );
  445. #endif // __PROTOS_H__