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.

1311 lines
37 KiB

  1. #include <pch.cpp>
  2. #pragma hdrstop
  3. BOOL
  4. InitCallState(
  5. CALL_STATE *CallState, // result call state
  6. PST_CALL_CONTEXT *CallerContext, // client caller context
  7. handle_t h // binding handle
  8. );
  9. BOOL
  10. FAcquireProvider(
  11. const PST_PROVIDERID* pProviderID
  12. );
  13. extern HANDLE hServerStopEvent;
  14. extern PROV_LIST_ITEM g_liProv;
  15. BOOL g_fBaseInitialized = FALSE;
  16. static LPCWSTR g_szBaseDLL = L"psbase.dll";
  17. const PST_PROVIDERID g_guidBaseProvider = MS_BASE_PSTPROVIDER_ID;
  18. DWORD g_dwLastHandleIssued = 0;
  19. BOOL InitMyProviderHandle()
  20. {
  21. // load the base provider!
  22. return FAcquireProvider(&g_guidBaseProvider);
  23. }
  24. void UnInitMyProviderHandle()
  25. {
  26. PROV_LIST_ITEM *pliProv = &g_liProv;
  27. if (pliProv->hInst)
  28. FreeLibrary(pliProv->hInst);
  29. if (pliProv->sProviderInfo.szProviderName)
  30. SSFree(pliProv->sProviderInfo.szProviderName);
  31. ZeroMemory(pliProv, sizeof(PROV_LIST_ITEM));
  32. g_fBaseInitialized = FALSE;
  33. }
  34. BOOL FAcquireProvider(
  35. const PST_PROVIDERID* pProviderID
  36. )
  37. {
  38. PPROV_LIST_ITEM pliProv = &g_liProv;
  39. WCHAR szFullPath[ 256 ];
  40. DWORD cchFullPath = sizeof(szFullPath) / sizeof(WCHAR);
  41. HANDLE hFile;
  42. SS_ASSERT(pProviderID);
  43. if (0 != memcmp(pProviderID, &g_guidBaseProvider, sizeof(PST_PROVIDERID))) {
  44. SetLastError( ERROR_INVALID_PARAMETER );
  45. return FALSE;
  46. }
  47. if( g_fBaseInitialized )
  48. return TRUE;
  49. if(!FindAndOpenFile( g_szBaseDLL, szFullPath, cchFullPath, &hFile ))
  50. return FALSE;
  51. CloseHandle( hFile );
  52. pliProv->hInst = LoadLibraryU( szFullPath );
  53. if(pliProv->hInst == NULL)
  54. goto Ret;
  55. // everything loaded correctly
  56. // init callbacks
  57. {
  58. SPPROVIDERINITIALIZE* pfnProvInit;
  59. if (NULL == (pfnProvInit = (SPPROVIDERINITIALIZE*) GetProcAddress(pliProv->hInst, "SPProviderInitialize")))
  60. goto Ret;
  61. DISPIF_CALLBACKS sCallbacks;
  62. sCallbacks.cbSize = sizeof(DISPIF_CALLBACKS);
  63. sCallbacks.pfnFIsACLSatisfied = FIsACLSatisfied;
  64. sCallbacks.pfnFGetUser = FGetUser;
  65. sCallbacks.pfnFGetCallerName = FGetCallerName;
  66. sCallbacks.pfnFImpersonateClient = FImpersonateClient;
  67. sCallbacks.pfnFRevertToSelf = FRevertToSelf;
  68. sCallbacks.pfnFGetServerParam = FGetServerParam;
  69. sCallbacks.pfnFSetServerParam = FSetServerParam;
  70. // register the callbacks I expose
  71. if (PST_E_OK != pfnProvInit( &sCallbacks ))
  72. goto Ret;
  73. }
  74. // everything okay - load list element pfns
  75. if (NULL == (pliProv->fnList.SPAcquireContext = (SPACQUIRECONTEXT*) GetProcAddress(pliProv->hInst, "SPAcquireContext")))
  76. goto Ret;
  77. if (NULL == (pliProv->fnList.SPReleaseContext = (SPRELEASECONTEXT*) GetProcAddress(pliProv->hInst, "SPReleaseContext")))
  78. goto Ret;
  79. if (NULL == (pliProv->fnList.SPGetProvInfo = (SPGETPROVINFO*) GetProcAddress(pliProv->hInst, "SPGetProvInfo")))
  80. goto Ret;
  81. if (NULL == (pliProv->fnList.SPGetTypeInfo = (SPGETTYPEINFO*) GetProcAddress(pliProv->hInst, "SPGetTypeInfo")))
  82. goto Ret;
  83. if (NULL == (pliProv->fnList.SPGetSubtypeInfo = (SPGETSUBTYPEINFO*) GetProcAddress(pliProv->hInst, "SPGetSubtypeInfo")))
  84. goto Ret;
  85. if (NULL == (pliProv->fnList.SPGetProvParam = (SPGETPROVPARAM*) GetProcAddress(pliProv->hInst, "SPGetProvParam")))
  86. goto Ret;
  87. if (NULL == (pliProv->fnList.SPSetProvParam = (SPSETPROVPARAM*) GetProcAddress(pliProv->hInst, "SPSetProvParam")))
  88. goto Ret;
  89. if (NULL == (pliProv->fnList.SPEnumTypes = (SPENUMTYPES*) GetProcAddress(pliProv->hInst, "SPEnumTypes")))
  90. goto Ret;
  91. if (NULL == (pliProv->fnList.SPEnumSubtypes = (SPENUMSUBTYPES*) GetProcAddress(pliProv->hInst, "SPEnumSubtypes")))
  92. goto Ret;
  93. if (NULL == (pliProv->fnList.SPEnumItems = (SPENUMITEMS*) GetProcAddress(pliProv->hInst, "SPEnumItems")))
  94. goto Ret;
  95. if (NULL == (pliProv->fnList.SPCreateType = (SPCREATETYPE*) GetProcAddress(pliProv->hInst, "SPCreateType")))
  96. goto Ret;
  97. if (NULL == (pliProv->fnList.SPDeleteType = (SPDELETETYPE*) GetProcAddress(pliProv->hInst, "SPDeleteType")))
  98. goto Ret;
  99. if (NULL == (pliProv->fnList.SPCreateSubtype = (SPCREATESUBTYPE*) GetProcAddress(pliProv->hInst, "SPCreateSubtype")))
  100. goto Ret;
  101. if (NULL == (pliProv->fnList.SPDeleteSubtype = (SPDELETESUBTYPE*) GetProcAddress(pliProv->hInst, "SPDeleteSubtype")))
  102. goto Ret;
  103. if (NULL == (pliProv->fnList.SPDeleteItem = (SPDELETEITEM*) GetProcAddress(pliProv->hInst, "SPDeleteItem")))
  104. goto Ret;
  105. if (NULL == (pliProv->fnList.SPReadItem = (SPREADITEM*) GetProcAddress(pliProv->hInst, "SPReadItem")))
  106. goto Ret;
  107. if (NULL == (pliProv->fnList.SPWriteItem = (SPWRITEITEM*) GetProcAddress(pliProv->hInst, "SPWriteItem")))
  108. goto Ret;
  109. if (NULL == (pliProv->fnList.SPOpenItem = (SPOPENITEM*) GetProcAddress(pliProv->hInst, "SPOpenItem")))
  110. goto Ret;
  111. if (NULL == (pliProv->fnList.SPCloseItem = (SPCLOSEITEM*) GetProcAddress(pliProv->hInst, "SPCloseItem")))
  112. goto Ret;
  113. // side door interface
  114. if (NULL == (pliProv->fnList.FPasswordChangeNotify = (FPASSWORDCHANGENOTIFY*)GetProcAddress(pliProv->hInst, "FPasswordChangeNotify")))
  115. goto Ret;
  116. // fill in the provider info
  117. {
  118. PPST_PROVIDERINFO pReportedProviderInfo;
  119. if (RPC_S_OK !=
  120. pliProv->fnList.SPGetProvInfo(
  121. &pReportedProviderInfo,
  122. 0))
  123. goto Ret;
  124. // They better report the friendly name they're registered as having
  125. if (0 != memcmp(&pReportedProviderInfo->ID, pProviderID, sizeof(PST_PROVIDERID)))
  126. goto Ret;
  127. CopyMemory(&pliProv->sProviderInfo, pReportedProviderInfo, sizeof(PST_PROVIDERINFO));
  128. // don't free the indirections -- pliProv->sProviderInfo owns them
  129. SSFree(pReportedProviderInfo);
  130. }
  131. g_fBaseInitialized = TRUE;
  132. Ret:
  133. return g_fBaseInitialized;
  134. }
  135. /////////////////////////////////////////////////////////////////////////
  136. // Dispatcher-only routines
  137. HRESULT s_SSPStoreEnumProviders(
  138. /* [in] */ handle_t h,
  139. /* [in] */ PST_CALL_CONTEXT CallerContext,
  140. /* [out] */ PPST_PROVIDERINFO* ppPSTInfo,
  141. /* [in] */ DWORD dwIndex,
  142. /* [in] */ DWORD dwFlags)
  143. {
  144. HRESULT hr;
  145. PST_PROVIDERID ProvID;
  146. __try
  147. {
  148. PPROV_LIST_ITEM pli;
  149. if (dwIndex != 0)
  150. {
  151. hr = ERROR_NO_MORE_ITEMS;
  152. goto Ret;
  153. }
  154. else
  155. {
  156. // base provider is index 0; not in list
  157. CopyMemory(&ProvID, &g_guidBaseProvider, sizeof(PST_PROVIDERID));
  158. }
  159. // now we have the Provider ID
  160. *ppPSTInfo = (PST_PROVIDERINFO*)SSAlloc(sizeof(PST_PROVIDERINFO));
  161. if( *ppPSTInfo == NULL ) {
  162. hr = E_OUTOFMEMORY;
  163. goto Ret;
  164. }
  165. ZeroMemory(*ppPSTInfo, sizeof(PST_PROVIDERINFO));
  166. // retrieve from list
  167. if (NULL == (pli = SearchProvListByID(&ProvID)))
  168. {
  169. hr = PST_E_PROV_DLL_NOT_FOUND;
  170. goto RefuseLoad;
  171. }
  172. // copy direct members
  173. CopyMemory(*ppPSTInfo, &pli->sProviderInfo, sizeof(PST_PROVIDERINFO));
  174. // copy indirects
  175. (*ppPSTInfo)->szProviderName = (LPWSTR)SSAlloc(WSZ_BYTECOUNT(pli->sProviderInfo.szProviderName));
  176. if( (*ppPSTInfo)->szProviderName == NULL ) {
  177. hr = E_OUTOFMEMORY;
  178. goto Ret;
  179. }
  180. wcscpy((*ppPSTInfo)->szProviderName, pli->sProviderInfo.szProviderName);
  181. hr = PST_E_OK;
  182. }
  183. __except(EXCEPTION_EXECUTE_HANDLER)
  184. {
  185. hr = GetExceptionCode();
  186. }
  187. Ret:
  188. if(hr != PST_E_OK)
  189. {
  190. if( *ppPSTInfo ) {
  191. if( (*ppPSTInfo)->szProviderName )
  192. SSFree( (*ppPSTInfo)->szProviderName );
  193. SSFree( *ppPSTInfo );
  194. *ppPSTInfo = NULL;
  195. }
  196. }
  197. return hr;
  198. RefuseLoad:
  199. // copy dummy provider info
  200. (*ppPSTInfo)->cbSize = sizeof(PST_PROVIDERINFO);
  201. CopyMemory(&(*ppPSTInfo)->ID, &ProvID, sizeof(GUID));
  202. // notify that we couldn't touch this provider (in a graceful way)
  203. (*ppPSTInfo)->Capabilities = PST_PC_NOT_AVAILABLE;
  204. // eat error code here -- they can see it during acquire ctxt if they want
  205. return PST_E_OK;
  206. }
  207. BOOL
  208. AllocatePseudoUniqueHandle(
  209. PST_PROVIDER_HANDLE *phPSTProv
  210. )
  211. /*++
  212. This is here because:
  213. AllocateLocallyUniqueId() is not present on Win95.
  214. UuidCreate() requires too much baggage and memory to store handle.
  215. --*/
  216. {
  217. static LONG HighPart;
  218. //
  219. // GetTickCount() yields ~49 days of unique handles
  220. //
  221. phPSTProv->LowPart = GetTickCount(); // sneaky, huh?
  222. //
  223. // interlocked increment thread-safe insurance of no collision at same time
  224. // ~4 billion values
  225. //
  226. phPSTProv->HighPart = InterlockedIncrement(&HighPart);
  227. //
  228. // after ~49 days, we may collide with old handles
  229. // this is here just to be correct, but slim likelihood of no reboot
  230. // within 49 days on most machines.
  231. //
  232. //
  233. // update time of last handle issue.
  234. //
  235. g_dwLastHandleIssued = GetTickCount();
  236. return TRUE;
  237. }
  238. BOOL
  239. InitCallState(
  240. CALL_STATE *CallState, // result call state
  241. PST_CALL_CONTEXT *CallerContext, // client caller context
  242. handle_t h // binding handle
  243. )
  244. {
  245. HANDLE hThread;
  246. DWORD dwProcessId;
  247. BOOL bSuccess = FALSE;
  248. if(CallerContext == NULL)
  249. return FALSE;
  250. ZeroMemory( CallState, sizeof(CALL_STATE) );
  251. CallState->hBinding = h;
  252. CallState->dwProcessId = CallerContext->Address;
  253. CallState->hProcess = OpenProcess( PROCESS_ALL_ACCESS, FALSE, CallState->dwProcessId );
  254. if( CallState->hProcess == NULL )
  255. return FALSE;
  256. if(DuplicateHandle(
  257. CallState->hProcess,
  258. (HANDLE)CallerContext->Handle, // source handle
  259. GetCurrentProcess(),
  260. &hThread,
  261. THREAD_ALL_ACCESS, // tone down later
  262. FALSE,
  263. 0)) {
  264. CallState->hThread = hThread;
  265. bSuccess = TRUE;
  266. }
  267. if(!bSuccess) {
  268. if( CallState->hProcess )
  269. CloseHandle( CallState->hProcess );
  270. }
  271. return bSuccess;
  272. }
  273. BOOL
  274. DeleteCallState(
  275. CALL_STATE *CallState
  276. )
  277. {
  278. BOOL bSuccess;
  279. __try {
  280. if(CallState->hThread != NULL)
  281. CloseHandle(CallState->hThread);
  282. if(CallState->hProcess)
  283. CloseHandle(CallState->hProcess);
  284. memset(CallState, 0, sizeof(CALL_STATE));
  285. bSuccess = TRUE;
  286. } __except (EXCEPTION_EXECUTE_HANDLER) {
  287. bSuccess = FALSE;
  288. }
  289. return bSuccess;
  290. }
  291. HRESULT s_SSAcquireContext(
  292. /* [in] */ handle_t h,
  293. /* [in] */ PPST_PROVIDERID pProviderID,
  294. /* [in] */ PST_CALL_CONTEXT CallerContext,
  295. /* [in] */ DWORD pidCaller,
  296. /* [out] */ PST_PROVIDER_HANDLE* phPSTProv,
  297. /* [in] */ DWORD_PTR lpReserved,
  298. /* [in] */ DWORD dwFlags)
  299. {
  300. PPROV_LIST_ITEM pliProv;
  301. CALL_STATE CallState;
  302. BOOL bDelItemFromList = FALSE; // free list item on failure?
  303. BOOL bCallState = FALSE;
  304. HRESULT hr = PST_E_FAIL;
  305. //
  306. // lpReserved must currently be NULL.
  307. //
  308. if(lpReserved != 0)
  309. return ERROR_INVALID_PARAMETER;
  310. __try
  311. {
  312. if(!AllocatePseudoUniqueHandle(phPSTProv))
  313. return PST_E_FAIL;
  314. bCallState = InitCallState(&CallState, &CallerContext, h);
  315. if(!bCallState) {
  316. hr = PST_E_INVALID_HANDLE;
  317. goto cleanup;
  318. }
  319. // now allow SPAcquireContext to be called: look up interface
  320. // (call state already initialized)
  321. if (NULL == (pliProv = SearchProvListByID(pProviderID)))
  322. {
  323. hr = PST_E_INVALID_HANDLE;
  324. goto cleanup;
  325. }
  326. hr = pliProv->fnList.SPAcquireContext(
  327. (PST_PROVIDER_HANDLE *)&CallState,
  328. dwFlags);
  329. }
  330. __except(EXCEPTION_EXECUTE_HANDLER)
  331. {
  332. SetLastError(GetExceptionCode());
  333. hr = PST_E_UNKNOWN_EXCEPTION;
  334. }
  335. cleanup:
  336. if(bCallState)
  337. DeleteCallState(&CallState);
  338. return hr;
  339. }
  340. HRESULT s_SSReleaseContext(
  341. /* [in] */ handle_t h,
  342. /* [in] */ PST_PROVIDER_HANDLE hPSTProv,
  343. /* [in] */ PST_CALL_CONTEXT CallerContext,
  344. /* [in] */ DWORD dwFlags)
  345. {
  346. CALL_STATE CallState;
  347. HRESULT hr;
  348. __try
  349. {
  350. PPROV_LIST_ITEM pliProv;
  351. if (NULL == (pliProv = SearchProvListByID(&g_guidBaseProvider)))
  352. return PST_E_INVALID_HANDLE;
  353. if(!InitCallState(&CallState, &CallerContext, h))
  354. return PST_E_INVALID_HANDLE;
  355. hr = pliProv->fnList.SPReleaseContext(
  356. (PST_PROVIDER_HANDLE *)&CallState,
  357. dwFlags);
  358. }
  359. __except(EXCEPTION_EXECUTE_HANDLER)
  360. {
  361. SetLastError(GetExceptionCode());
  362. hr = PST_E_UNKNOWN_EXCEPTION;
  363. }
  364. DeleteCallState(&CallState);
  365. return hr;
  366. }
  367. // interface to communicate passwords from external sources
  368. // such as credential managers.
  369. // this is a currently a private interface and is likely to stay that way
  370. HRESULT s_SSPasswordInterface(
  371. /* [in] */ handle_t h,
  372. /* [in] */ DWORD dwParam,
  373. /* [in] */ DWORD cbData,
  374. /* [in][size_is(cbData)] */ BYTE* pbData)
  375. {
  376. __try {
  377. PLUID pLogonID;
  378. PBYTE pHashedUsername;
  379. PBYTE pHashedPassword;
  380. switch(dwParam) {
  381. case PASSWORD_LOGON_NT:
  382. {
  383. if(cbData == A_SHA_DIGEST_LEN + sizeof(LUID)) {
  384. pLogonID = (PLUID)pbData;
  385. pHashedPassword = (PBYTE)pbData + sizeof(LUID);
  386. SetPasswordNT(pLogonID, pHashedPassword);
  387. return PST_E_OK;
  388. }
  389. }
  390. #ifdef WIN95_LEGACY
  391. //
  392. // legacy case-sensitive password material for Win95
  393. //
  394. case PASSWORD_LOGON_LEGACY_95:
  395. {
  396. if(cbData == A_SHA_DIGEST_LEN + A_SHA_DIGEST_LEN) {
  397. // for legacy logon notification, just flush Win95 password.
  398. SetPassword95(NULL, NULL);
  399. return PST_E_OK;
  400. }
  401. }
  402. //
  403. // case-insensitive password material for Win95
  404. //
  405. case PASSWORD_LOGON_95:
  406. {
  407. if(cbData == A_SHA_DIGEST_LEN + A_SHA_DIGEST_LEN) {
  408. pHashedUsername = pbData;
  409. pHashedPassword = pbData + A_SHA_DIGEST_LEN;
  410. SetPassword95(pHashedUsername, pHashedPassword);
  411. return PST_E_OK;
  412. }
  413. }
  414. case PASSWORD_LOGOFF_95:
  415. {
  416. HRESULT hr = ERROR_INVALID_PARAMETER;
  417. //
  418. // scrub existing password material on logoff
  419. //
  420. if(cbData == 0) {
  421. SetPassword95(NULL, NULL);
  422. hr = PST_E_OK;
  423. }
  424. //
  425. // shutdown server (us) at logoff on Win95.
  426. //
  427. PulseEvent(hServerStopEvent);
  428. return hr;
  429. }
  430. #endif // WIN95_LEGACY
  431. default:
  432. return ERROR_INVALID_PARAMETER;
  433. }
  434. } __except(EXCEPTION_EXECUTE_HANDLER) {
  435. SetLastError(GetExceptionCode());
  436. return PST_E_UNKNOWN_EXCEPTION;
  437. }
  438. }
  439. /////////////////////////////////////////////////////////////////////////
  440. // Wrapper functions destined for provider
  441. HRESULT s_SSGetProvInfo(
  442. /* [in] */ handle_t h,
  443. /* [in] */ PST_PROVIDER_HANDLE hPSTProv,
  444. /* [in] */ PST_CALL_CONTEXT CallerContext,
  445. /* [out] */ PPST_PROVIDERINFO* ppPSTInfo,
  446. /* [in] */ DWORD dwFlags)
  447. {
  448. __try
  449. {
  450. PPROV_LIST_ITEM pliProv;
  451. if (NULL == (pliProv = SearchProvListByID(&g_guidBaseProvider)))
  452. return PST_E_INVALID_HANDLE;
  453. return (pliProv->fnList.SPGetProvInfo(
  454. ppPSTInfo,
  455. dwFlags));
  456. }
  457. __except(EXCEPTION_EXECUTE_HANDLER)
  458. {
  459. SetLastError(GetExceptionCode());
  460. return PST_E_UNKNOWN_EXCEPTION;
  461. }
  462. }
  463. HRESULT s_SSGetTypeInfo(
  464. /* [in] */ handle_t h,
  465. /* [in] */ PST_PROVIDER_HANDLE hPSTProv,
  466. /* [in] */ PST_CALL_CONTEXT CallerContext,
  467. /* [in] */ PST_KEY Key,
  468. /* [in] */ const GUID* pguidType,
  469. /* [in] */ PPST_TYPEINFO *ppinfoType,
  470. /* [in] */ DWORD dwFlags)
  471. {
  472. CALL_STATE CallState;
  473. HRESULT hr;
  474. __try
  475. {
  476. PPROV_LIST_ITEM pliProv;
  477. if (NULL == (pliProv = SearchProvListByID(&g_guidBaseProvider)))
  478. return PST_E_INVALID_HANDLE;
  479. if(!InitCallState(&CallState, &CallerContext, h))
  480. return PST_E_INVALID_HANDLE;
  481. hr = pliProv->fnList.SPGetTypeInfo(
  482. (PST_PROVIDER_HANDLE *)&CallState,
  483. Key,
  484. pguidType,
  485. ppinfoType,
  486. dwFlags);
  487. }
  488. __except(EXCEPTION_EXECUTE_HANDLER)
  489. {
  490. SetLastError(GetExceptionCode());
  491. hr = PST_E_UNKNOWN_EXCEPTION;
  492. }
  493. DeleteCallState(&CallState);
  494. return hr;
  495. }
  496. HRESULT s_SSGetSubtypeInfo(
  497. /* [in] */ handle_t h,
  498. /* [in] */ PST_PROVIDER_HANDLE hPSTProv,
  499. /* [in] */ PST_CALL_CONTEXT CallerContext,
  500. /* [in] */ PST_KEY Key,
  501. /* [in] */ const GUID* pguidType,
  502. /* [in] */ const GUID* pguidSubtype,
  503. /* [in] */ PPST_TYPEINFO *ppinfoSubtype,
  504. /* [in] */ DWORD dwFlags)
  505. {
  506. CALL_STATE CallState;
  507. HRESULT hr;
  508. __try
  509. {
  510. PPROV_LIST_ITEM pliProv;
  511. if (NULL == (pliProv = SearchProvListByID(&g_guidBaseProvider)))
  512. return PST_E_INVALID_HANDLE;
  513. if(!InitCallState(&CallState, &CallerContext, h))
  514. return PST_E_INVALID_HANDLE;
  515. hr = pliProv->fnList.SPGetSubtypeInfo(
  516. (PST_PROVIDER_HANDLE *)&CallState,
  517. Key,
  518. pguidType,
  519. pguidSubtype,
  520. ppinfoSubtype,
  521. dwFlags);
  522. }
  523. __except(EXCEPTION_EXECUTE_HANDLER)
  524. {
  525. SetLastError(GetExceptionCode());
  526. hr = PST_E_UNKNOWN_EXCEPTION;
  527. }
  528. DeleteCallState(&CallState);
  529. return hr;
  530. }
  531. HRESULT s_SSGetProvParam(
  532. /* [in] */ handle_t h,
  533. /* [in] */ PST_PROVIDER_HANDLE hPSTProv,
  534. /* [in] */ PST_CALL_CONTEXT CallerContext,
  535. /* [in] */ DWORD dwParam,
  536. /* [out] */ DWORD __RPC_FAR *pcbData,
  537. /* [size_is][size_is][out] */
  538. BYTE __RPC_FAR *__RPC_FAR *ppbData,
  539. /* [in] */ DWORD dwFlags)
  540. {
  541. CALL_STATE CallState;
  542. HRESULT hr;
  543. __try
  544. {
  545. PPROV_LIST_ITEM pliProv;
  546. if (NULL == (pliProv = SearchProvListByID(&g_guidBaseProvider)))
  547. return PST_E_INVALID_HANDLE;
  548. if(!InitCallState(&CallState, &CallerContext, h))
  549. return PST_E_INVALID_HANDLE;
  550. hr = pliProv->fnList.SPGetProvParam(
  551. (PST_PROVIDER_HANDLE *)&CallState,
  552. dwParam,
  553. pcbData,
  554. ppbData,
  555. dwFlags);
  556. }
  557. __except(EXCEPTION_EXECUTE_HANDLER)
  558. {
  559. SetLastError(GetExceptionCode());
  560. hr = PST_E_UNKNOWN_EXCEPTION;
  561. }
  562. DeleteCallState(&CallState);
  563. return hr;
  564. }
  565. HRESULT s_SSSetProvParam(
  566. /* [in] */ handle_t h,
  567. /* [in] */ PST_PROVIDER_HANDLE hPSTProv,
  568. /* [in] */ PST_CALL_CONTEXT CallerContext,
  569. /* [in] */ DWORD dwParam,
  570. /* [in] */ DWORD cbData,
  571. /* [in] */ BYTE* pbData,
  572. /* [in] */ DWORD dwFlags)
  573. {
  574. CALL_STATE CallState;
  575. HRESULT hr;
  576. __try
  577. {
  578. PPROV_LIST_ITEM pliProv;
  579. if (NULL == (pliProv = SearchProvListByID(&g_guidBaseProvider)))
  580. return PST_E_INVALID_HANDLE;
  581. if(!InitCallState(&CallState, &CallerContext, h))
  582. return PST_E_INVALID_HANDLE;
  583. hr = pliProv->fnList.SPSetProvParam(
  584. (PST_PROVIDER_HANDLE *)&CallState,
  585. dwParam,
  586. cbData,
  587. pbData,
  588. dwFlags);
  589. }
  590. __except(EXCEPTION_EXECUTE_HANDLER)
  591. {
  592. SetLastError(GetExceptionCode());
  593. hr = PST_E_UNKNOWN_EXCEPTION;
  594. }
  595. DeleteCallState(&CallState);
  596. return hr;
  597. }
  598. HRESULT s_SSEnumTypes(
  599. /* [in] */ handle_t h,
  600. /* [in] */ PST_PROVIDER_HANDLE hPSTProv,
  601. /* [in] */ PST_CALL_CONTEXT CallerContext,
  602. /* [in] */ PST_KEY Key,
  603. /* [out] */GUID* pguidType,
  604. /* [in] */ DWORD dwIndex,
  605. /* [in] */ DWORD dwFlags)
  606. {
  607. CALL_STATE CallState;
  608. HRESULT hr;
  609. __try
  610. {
  611. PPROV_LIST_ITEM pliProv;
  612. if (NULL == (pliProv = SearchProvListByID(&g_guidBaseProvider)))
  613. return PST_E_INVALID_HANDLE;
  614. if(!InitCallState(&CallState, &CallerContext, h))
  615. return PST_E_INVALID_HANDLE;
  616. hr = pliProv->fnList.SPEnumTypes(
  617. (PST_PROVIDER_HANDLE *)&CallState,
  618. Key,
  619. pguidType,
  620. dwIndex,
  621. dwFlags);
  622. }
  623. __except(EXCEPTION_EXECUTE_HANDLER)
  624. {
  625. SetLastError(GetExceptionCode());
  626. hr = PST_E_UNKNOWN_EXCEPTION;
  627. }
  628. DeleteCallState(&CallState);
  629. return hr;
  630. }
  631. HRESULT s_SSEnumSubtypes(
  632. /* [in] */ handle_t h,
  633. /* [in] */ PST_PROVIDER_HANDLE hPSTProv,
  634. /* [in] */ PST_CALL_CONTEXT CallerContext,
  635. /* [in] */ PST_KEY Key,
  636. /* [in] */ const GUID __RPC_FAR *pguidType,
  637. /* [out] */ GUID __RPC_FAR *pguidSubtype,
  638. /* [in] */ DWORD dwIndex,
  639. /* [in] */ DWORD dwFlags)
  640. {
  641. CALL_STATE CallState;
  642. HRESULT hr;
  643. __try
  644. {
  645. PPROV_LIST_ITEM pliProv;
  646. if (NULL == (pliProv = SearchProvListByID(&g_guidBaseProvider)))
  647. return PST_E_INVALID_HANDLE;
  648. if(!InitCallState(&CallState, &CallerContext, h))
  649. return PST_E_INVALID_HANDLE;
  650. hr = pliProv->fnList.SPEnumSubtypes(
  651. (PST_PROVIDER_HANDLE *)&CallState,
  652. Key,
  653. pguidType,
  654. pguidSubtype,
  655. dwIndex,
  656. dwFlags);
  657. }
  658. __except(EXCEPTION_EXECUTE_HANDLER)
  659. {
  660. SetLastError(GetExceptionCode());
  661. hr = PST_E_UNKNOWN_EXCEPTION;
  662. }
  663. DeleteCallState(&CallState);
  664. return hr;
  665. }
  666. HRESULT s_SSEnumItems(
  667. /* [in] */ handle_t h,
  668. /* [in] */ PST_PROVIDER_HANDLE hPSTProv,
  669. /* [in] */ PST_CALL_CONTEXT CallerContext,
  670. /* [in] */ PST_KEY Key,
  671. /* [in] */ const GUID __RPC_FAR *pguidType,
  672. /* [in] */ const GUID __RPC_FAR *pguidSubtype,
  673. /* [out] */ LPWSTR __RPC_FAR *ppszItemName,
  674. /* [in] */ DWORD dwIndex,
  675. /* [in] */ DWORD dwFlags)
  676. {
  677. CALL_STATE CallState;
  678. HRESULT hr;
  679. __try
  680. {
  681. PPROV_LIST_ITEM pliProv;
  682. if (NULL == (pliProv = SearchProvListByID(&g_guidBaseProvider)))
  683. return PST_E_INVALID_HANDLE;
  684. if(!InitCallState(&CallState, &CallerContext, h))
  685. return PST_E_INVALID_HANDLE;
  686. hr = pliProv->fnList.SPEnumItems(
  687. (PST_PROVIDER_HANDLE *)&CallState,
  688. Key,
  689. pguidType,
  690. pguidSubtype,
  691. ppszItemName,
  692. dwIndex,
  693. dwFlags);
  694. }
  695. __except(EXCEPTION_EXECUTE_HANDLER)
  696. {
  697. SetLastError(GetExceptionCode());
  698. hr = PST_E_UNKNOWN_EXCEPTION;
  699. }
  700. DeleteCallState(&CallState);
  701. return hr;
  702. }
  703. HRESULT s_SSCreateType(
  704. /* [in] */ handle_t h,
  705. /* [in] */ PST_PROVIDER_HANDLE hPSTProv,
  706. /* [in] */ PST_CALL_CONTEXT CallerContext,
  707. /* [in] */ PST_KEY Key,
  708. /* [in] */ const GUID* pguidType,
  709. /* [in] */ PPST_TYPEINFO pinfoType,
  710. /* [in] */ DWORD dwFlags)
  711. {
  712. PPROV_LIST_ITEM pliProv;
  713. CALL_STATE CallState;
  714. HRESULT hr;
  715. __try
  716. {
  717. if (NULL == (pliProv = SearchProvListByID(&g_guidBaseProvider)))
  718. return PST_E_INVALID_HANDLE;
  719. if(!InitCallState(&CallState, &CallerContext, h))
  720. return PST_E_INVALID_HANDLE;
  721. hr = pliProv->fnList.SPCreateType(
  722. (PST_PROVIDER_HANDLE *)&CallState,
  723. Key,
  724. pguidType,
  725. pinfoType,
  726. dwFlags);
  727. }
  728. __except(EXCEPTION_EXECUTE_HANDLER)
  729. {
  730. SetLastError(GetExceptionCode());
  731. hr = PST_E_UNKNOWN_EXCEPTION;
  732. }
  733. DeleteCallState(&CallState);
  734. return hr;
  735. }
  736. HRESULT s_SSCreateSubtype(
  737. /* [in] */ handle_t h,
  738. /* [in] */ PST_PROVIDER_HANDLE hPSTProv,
  739. /* [in] */ PST_CALL_CONTEXT CallerContext,
  740. /* [in] */ PST_KEY Key,
  741. /* [in] */ const GUID* pguidType,
  742. /* [in] */ const GUID* pguidSubtype,
  743. /* [in] */ PPST_TYPEINFO pinfoSubtype,
  744. /* [in] */ PPST_ACCESSRULESET psRules,
  745. /* [in] */ DWORD dwFlags)
  746. {
  747. PPROV_LIST_ITEM pliProv;
  748. CALL_STATE CallState;
  749. HRESULT hr;
  750. __try
  751. {
  752. if (NULL == (pliProv = SearchProvListByID(&g_guidBaseProvider)))
  753. return PST_E_INVALID_HANDLE;
  754. if(!InitCallState(&CallState, &CallerContext, h))
  755. return PST_E_INVALID_HANDLE;
  756. hr = pliProv->fnList.SPCreateSubtype(
  757. (PST_PROVIDER_HANDLE *)&CallState,
  758. Key,
  759. pguidType,
  760. pguidSubtype,
  761. pinfoSubtype,
  762. psRules,
  763. dwFlags);
  764. }
  765. __except(EXCEPTION_EXECUTE_HANDLER)
  766. {
  767. SetLastError(GetExceptionCode());
  768. hr = PST_E_UNKNOWN_EXCEPTION;
  769. }
  770. DeleteCallState(&CallState);
  771. return hr;
  772. }
  773. HRESULT s_SSDeleteType(
  774. /* [in] */ handle_t h,
  775. /* [in] */ PST_PROVIDER_HANDLE hPSTProv,
  776. /* [in] */ PST_CALL_CONTEXT CallerContext,
  777. /* [in] */ PST_KEY Key,
  778. /* [in] */ const GUID* pguidType,
  779. /* [in] */ DWORD dwFlags)
  780. {
  781. PPROV_LIST_ITEM pliProv;
  782. PPST_TYPEINFO ppinfoType = NULL;
  783. CALL_STATE CallState;
  784. HRESULT hr;
  785. HRESULT hrTypeInfo = E_FAIL;
  786. __try
  787. {
  788. if (NULL == (pliProv = SearchProvListByID(&g_guidBaseProvider)))
  789. return PST_E_INVALID_HANDLE;
  790. if(!InitCallState(&CallState, &CallerContext, h))
  791. return PST_E_INVALID_HANDLE;
  792. hr = pliProv->fnList.SPDeleteType(
  793. (PST_PROVIDER_HANDLE *)&CallState,
  794. Key,
  795. pguidType,
  796. dwFlags);
  797. }
  798. __except(EXCEPTION_EXECUTE_HANDLER)
  799. {
  800. SetLastError(GetExceptionCode());
  801. hr = PST_E_UNKNOWN_EXCEPTION;
  802. }
  803. DeleteCallState(&CallState);
  804. return hr;
  805. }
  806. HRESULT s_SSDeleteSubtype(
  807. /* [in] */ handle_t h,
  808. /* [in] */ PST_PROVIDER_HANDLE hPSTProv,
  809. /* [in] */ PST_CALL_CONTEXT CallerContext,
  810. /* [in] */ PST_KEY Key,
  811. /* [in] */ const GUID* pguidType,
  812. /* [in] */ const GUID* pguidSubtype,
  813. /* [in] */ DWORD dwFlags)
  814. {
  815. PPROV_LIST_ITEM pliProv;
  816. PPST_TYPEINFO ppinfoSubtype = NULL;
  817. CALL_STATE CallState;
  818. HRESULT hr;
  819. HRESULT hrSubtypeInfo = E_FAIL;
  820. __try
  821. {
  822. if (NULL == (pliProv = SearchProvListByID(&g_guidBaseProvider)))
  823. return PST_E_INVALID_HANDLE;
  824. if(!InitCallState(&CallState, &CallerContext, h))
  825. return PST_E_INVALID_HANDLE;
  826. hr = pliProv->fnList.SPDeleteSubtype(
  827. (PST_PROVIDER_HANDLE *)&CallState,
  828. Key,
  829. pguidType,
  830. pguidSubtype,
  831. dwFlags);
  832. }
  833. __except(EXCEPTION_EXECUTE_HANDLER)
  834. {
  835. SetLastError(GetExceptionCode());
  836. hr = PST_E_UNKNOWN_EXCEPTION;
  837. }
  838. DeleteCallState(&CallState);
  839. return hr;
  840. }
  841. HRESULT s_SSDeleteItem(
  842. /* [in] */ handle_t h,
  843. /* [in] */ PST_PROVIDER_HANDLE hPSTProv,
  844. /* [in] */ PST_CALL_CONTEXT CallerContext,
  845. /* [in] */ PST_KEY Key,
  846. /* [in] */ const GUID __RPC_FAR *pguidType,
  847. /* [in] */ const GUID __RPC_FAR *pguidSubtype,
  848. /* [in] */ LPCWSTR szItemName,
  849. /* [in] */ PPST_PROMPTINFO psPrompt,
  850. /* [in] */ DWORD dwFlags)
  851. {
  852. PPROV_LIST_ITEM pliProv;
  853. PPST_TYPEINFO ppinfoType = NULL;
  854. PPST_TYPEINFO ppinfoSubtype = NULL;
  855. CALL_STATE CallState;
  856. HRESULT hr;
  857. HRESULT hrTypeInfo = E_FAIL;
  858. HRESULT hrSubtypeInfo = E_FAIL;
  859. __try
  860. {
  861. if (NULL == (pliProv = SearchProvListByID(&g_guidBaseProvider)))
  862. return PST_E_INVALID_HANDLE;
  863. if(!InitCallState(&CallState, &CallerContext, h))
  864. return PST_E_INVALID_HANDLE;
  865. hr = pliProv->fnList.SPDeleteItem(
  866. (PST_PROVIDER_HANDLE *)&CallState,
  867. Key,
  868. pguidType,
  869. pguidSubtype,
  870. szItemName,
  871. psPrompt,
  872. dwFlags);
  873. }
  874. __except(EXCEPTION_EXECUTE_HANDLER)
  875. {
  876. SetLastError(GetExceptionCode());
  877. hr = PST_E_UNKNOWN_EXCEPTION;
  878. }
  879. DeleteCallState(&CallState);
  880. return hr;
  881. }
  882. HRESULT s_SSReadItem(
  883. /* [in] */ handle_t h,
  884. /* [in] */ PST_PROVIDER_HANDLE hPSTProv,
  885. /* [in] */ PST_CALL_CONTEXT CallerContext,
  886. /* [in] */ PST_KEY Key,
  887. /* [in] */ const GUID __RPC_FAR *pguidType,
  888. /* [in] */ const GUID __RPC_FAR *pguidSubtype,
  889. /* [in] */ LPCWSTR szItemName,
  890. /* [out] */ DWORD __RPC_FAR *pcbData,
  891. /* [size_is][size_is][out] */ BYTE __RPC_FAR *__RPC_FAR *ppbData,
  892. /* [in] */ PPST_PROMPTINFO psPrompt,
  893. /* [in] */ DWORD dwFlags)
  894. {
  895. PPROV_LIST_ITEM pliProv;
  896. PPST_TYPEINFO ppinfoType = NULL;
  897. PPST_TYPEINFO ppinfoSubtype = NULL;
  898. CALL_STATE CallState;
  899. HRESULT hr;
  900. __try
  901. {
  902. if (NULL == (pliProv = SearchProvListByID(&g_guidBaseProvider)))
  903. return PST_E_INVALID_HANDLE;
  904. if(!InitCallState(&CallState, &CallerContext, h))
  905. return PST_E_INVALID_HANDLE;
  906. hr = pliProv->fnList.SPReadItem(
  907. (PST_PROVIDER_HANDLE *)&CallState,
  908. Key,
  909. pguidType,
  910. pguidSubtype,
  911. szItemName,
  912. pcbData,
  913. ppbData,
  914. psPrompt,
  915. dwFlags);
  916. }
  917. __except(EXCEPTION_EXECUTE_HANDLER)
  918. {
  919. SetLastError(GetExceptionCode());
  920. hr = PST_E_UNKNOWN_EXCEPTION;
  921. }
  922. DeleteCallState(&CallState);
  923. return hr;
  924. }
  925. HRESULT s_SSWriteItem(
  926. /* [in] */ handle_t h,
  927. /* [in] */ PST_PROVIDER_HANDLE hPSTProv,
  928. /* [in] */ PST_CALL_CONTEXT CallerContext,
  929. /* [in] */ PST_KEY Key,
  930. /* [in] */ const GUID __RPC_FAR *pguidType,
  931. /* [in] */ const GUID __RPC_FAR *pguidSubtype,
  932. /* [in] */ LPCWSTR szItemName,
  933. /* [in] */ DWORD cbData,
  934. /* [size_is][in] */ BYTE __RPC_FAR *pbData,
  935. /* [in] */ PPST_PROMPTINFO psPrompt,
  936. /* [in] */ DWORD dwDefaultConfirmationStyle,
  937. /* [in] */ DWORD dwFlags)
  938. {
  939. PPST_TYPEINFO ppinfoType = NULL;
  940. PPST_TYPEINFO ppinfoSubtype = NULL;
  941. PPROV_LIST_ITEM pliProv;
  942. CALL_STATE CallState;
  943. HRESULT hr;
  944. __try
  945. {
  946. if (NULL == (pliProv = SearchProvListByID(&g_guidBaseProvider)))
  947. return PST_E_INVALID_HANDLE;
  948. if(!InitCallState(&CallState, &CallerContext, h))
  949. return PST_E_INVALID_HANDLE;
  950. hr = pliProv->fnList.SPWriteItem(
  951. (PST_PROVIDER_HANDLE *)&CallState,
  952. Key,
  953. pguidType,
  954. pguidSubtype,
  955. szItemName,
  956. cbData,
  957. pbData,
  958. psPrompt,
  959. dwDefaultConfirmationStyle,
  960. dwFlags);
  961. }
  962. __except(EXCEPTION_EXECUTE_HANDLER)
  963. {
  964. SetLastError(GetExceptionCode());
  965. hr = PST_E_UNKNOWN_EXCEPTION;
  966. }
  967. DeleteCallState(&CallState);
  968. return hr;
  969. }
  970. HRESULT s_SSReadAccessRuleset(
  971. /* [in] */ handle_t h,
  972. /* [in] */ PST_PROVIDER_HANDLE hPSTProv,
  973. /* [in] */ PST_CALL_CONTEXT CallerContext,
  974. /* [in] */ PST_KEY Key,
  975. /* [in] */ const GUID __RPC_FAR *pguidType,
  976. /* [in] */ const GUID __RPC_FAR *pguidSubtype,
  977. /* [out] */ PPST_ACCESSRULESET *ppsRules,
  978. /* [in] */ DWORD dwFlags)
  979. {
  980. return ERROR_NOT_SUPPORTED;
  981. }
  982. HRESULT s_SSWriteAccessRuleset(
  983. /* [in] */ handle_t h,
  984. /* [in] */ PST_PROVIDER_HANDLE hPSTProv,
  985. /* [in] */ PST_CALL_CONTEXT CallerContext,
  986. /* [in] */ PST_KEY Key,
  987. /* [in] */ const GUID __RPC_FAR *pguidType,
  988. /* [in] */ const GUID __RPC_FAR *pguidSubtype,
  989. /* [in] */ PPST_ACCESSRULESET psRules,
  990. /* [in] */ DWORD dwFlags)
  991. {
  992. return ERROR_NOT_SUPPORTED;
  993. }
  994. HRESULT s_SSOpenItem(
  995. /* [in] */ handle_t h,
  996. /* [in] */ PST_PROVIDER_HANDLE hPSTProv,
  997. /* [in] */ PST_CALL_CONTEXT CallerContext,
  998. /* [in] */ PST_KEY Key,
  999. /* [in] */ const GUID __RPC_FAR *pguidType,
  1000. /* [in] */ const GUID __RPC_FAR *pguidSubtype,
  1001. /* [in] */ LPCWSTR szItemName,
  1002. /* [in] */ PST_ACCESSMODE ModeFlags,
  1003. /* [in] */ PPST_PROMPTINFO psPrompt,
  1004. /* [in] */ DWORD dwFlags)
  1005. {
  1006. PPST_TYPEINFO ppinfoType = NULL;
  1007. PPST_TYPEINFO ppinfoSubtype = NULL;
  1008. PPROV_LIST_ITEM pliProv;
  1009. CALL_STATE CallState;
  1010. HRESULT hr;
  1011. __try
  1012. {
  1013. if (NULL == (pliProv = SearchProvListByID(&g_guidBaseProvider)))
  1014. return PST_E_INVALID_HANDLE;
  1015. if(!InitCallState(&CallState, &CallerContext, h))
  1016. return PST_E_INVALID_HANDLE;
  1017. hr = pliProv->fnList.SPOpenItem(
  1018. (PST_PROVIDER_HANDLE *)&CallState,
  1019. Key,
  1020. pguidType,
  1021. pguidSubtype,
  1022. szItemName,
  1023. ModeFlags,
  1024. psPrompt,
  1025. dwFlags);
  1026. }
  1027. __except(EXCEPTION_EXECUTE_HANDLER)
  1028. {
  1029. SetLastError(GetExceptionCode());
  1030. hr = PST_E_UNKNOWN_EXCEPTION;
  1031. }
  1032. DeleteCallState(&CallState);
  1033. return hr;
  1034. }
  1035. HRESULT s_SSCloseItem(
  1036. /* [in] */ handle_t h,
  1037. /* [in] */ PST_PROVIDER_HANDLE hPSTProv,
  1038. /* [in] */ PST_CALL_CONTEXT CallerContext,
  1039. /* [in] */ PST_KEY Key,
  1040. /* [in] */ const GUID __RPC_FAR *pguidType,
  1041. /* [in] */ const GUID __RPC_FAR *pguidSubtype,
  1042. /* [in] */ LPCWSTR szItemName,
  1043. /* [in] */ DWORD dwFlags)
  1044. {
  1045. CALL_STATE CallState;
  1046. HRESULT hr;
  1047. __try
  1048. {
  1049. PPROV_LIST_ITEM pliProv;
  1050. if (NULL == (pliProv = SearchProvListByID(&g_guidBaseProvider)))
  1051. return PST_E_INVALID_HANDLE;
  1052. if(!InitCallState(&CallState, &CallerContext, h))
  1053. return PST_E_INVALID_HANDLE;
  1054. hr = pliProv->fnList.SPCloseItem(
  1055. (PST_PROVIDER_HANDLE *)&CallState,
  1056. Key,
  1057. pguidType,
  1058. pguidSubtype,
  1059. szItemName,
  1060. dwFlags);
  1061. }
  1062. __except(EXCEPTION_EXECUTE_HANDLER)
  1063. {
  1064. SetLastError(GetExceptionCode());
  1065. hr = PST_E_UNKNOWN_EXCEPTION;
  1066. }
  1067. DeleteCallState(&CallState);
  1068. return hr;
  1069. }