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.

725 lines
13 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995.
  5. //
  6. // File: ccache.cxx
  7. //
  8. // Contents: Class Cache functionality for the NT Provider
  9. //
  10. //
  11. //----------------------------------------------------------------------------
  12. #include "winnt.hxx"
  13. HRESULT
  14. SetOctetPropertyInCache(
  15. CPropertyCache *pPropertyCache,
  16. LPTSTR pszProperty,
  17. BYTE *pByte,
  18. DWORD dwLength,
  19. BOOL fExplicit
  20. )
  21. {
  22. HRESULT hr;
  23. OctetString octString;
  24. if(!pPropertyCache){
  25. RRETURN(E_POINTER);
  26. }
  27. octString.pByte = pByte;
  28. octString.dwSize = dwLength;
  29. hr = pPropertyCache->unmarshallproperty(
  30. pszProperty,
  31. (LPBYTE)&octString,
  32. 1,
  33. NT_SYNTAX_ID_OCTETSTRING,
  34. fExplicit
  35. );
  36. BAIL_ON_FAILURE(hr);
  37. error:
  38. RRETURN(hr);
  39. }
  40. HRESULT
  41. SetLPTSTRPropertyInCache(
  42. CPropertyCache *pPropertyCache,
  43. LPTSTR pszProperty,
  44. LPTSTR pszValue,
  45. BOOL fExplicit
  46. )
  47. {
  48. HRESULT hr;
  49. if(!pPropertyCache){
  50. RRETURN(E_POINTER);
  51. }
  52. hr = pPropertyCache->unmarshallproperty(
  53. pszProperty,
  54. (LPBYTE)pszValue,
  55. 1,
  56. NT_SYNTAX_ID_LPTSTR,
  57. fExplicit
  58. );
  59. BAIL_ON_FAILURE(hr);
  60. error:
  61. RRETURN(hr);
  62. }
  63. HRESULT
  64. SetDWORDPropertyInCache(
  65. CPropertyCache *pPropertyCache,
  66. LPTSTR pszProperty,
  67. DWORD dwValue,
  68. BOOL fExplicit
  69. )
  70. {
  71. HRESULT hr;
  72. if(!pPropertyCache){
  73. RRETURN(E_POINTER);
  74. }
  75. hr = pPropertyCache->unmarshallproperty(
  76. pszProperty,
  77. (LPBYTE)&dwValue,
  78. 1,
  79. NT_SYNTAX_ID_DWORD,
  80. fExplicit
  81. );
  82. BAIL_ON_FAILURE(hr);
  83. error:
  84. RRETURN(hr);
  85. }
  86. HRESULT
  87. SetDATE70PropertyInCache(
  88. CPropertyCache *pPropertyCache,
  89. LPTSTR pszProperty,
  90. DWORD dwValue,
  91. BOOL fExplicit
  92. )
  93. {
  94. HRESULT hr;
  95. if(!pPropertyCache){
  96. RRETURN(E_POINTER);
  97. }
  98. hr = pPropertyCache->unmarshallproperty(
  99. pszProperty,
  100. (LPBYTE)&dwValue,
  101. 1,
  102. NT_SYNTAX_ID_DATE_1970,
  103. fExplicit
  104. );
  105. BAIL_ON_FAILURE(hr);
  106. error:
  107. RRETURN(hr);
  108. }
  109. HRESULT
  110. SetDATEPropertyInCache(
  111. CPropertyCache *pPropertyCache,
  112. LPTSTR pszProperty,
  113. DWORD dwValue,
  114. BOOL fExplicit
  115. )
  116. {
  117. HRESULT hr;
  118. if(!pPropertyCache){
  119. RRETURN(E_POINTER);
  120. }
  121. hr = pPropertyCache->unmarshallproperty(
  122. pszProperty,
  123. (LPBYTE)&dwValue,
  124. 1,
  125. NT_SYNTAX_ID_DATE,
  126. fExplicit
  127. );
  128. BAIL_ON_FAILURE(hr);
  129. error:
  130. RRETURN(hr);
  131. }
  132. HRESULT
  133. SetBOOLPropertyInCache(
  134. CPropertyCache *pPropertyCache,
  135. LPTSTR pszProperty,
  136. BOOL fValue,
  137. BOOL fExplicit
  138. )
  139. {
  140. HRESULT hr;
  141. if(!pPropertyCache){
  142. RRETURN(E_POINTER);
  143. }
  144. hr = pPropertyCache->unmarshallproperty(
  145. pszProperty,
  146. (LPBYTE)&fValue,
  147. 1,
  148. NT_SYNTAX_ID_BOOL,
  149. fExplicit
  150. );
  151. BAIL_ON_FAILURE(hr);
  152. error:
  153. RRETURN(hr);
  154. }
  155. HRESULT
  156. SetSYSTEMTIMEPropertyInCache(
  157. CPropertyCache *pPropertyCache,
  158. LPTSTR pszProperty,
  159. SYSTEMTIME stValue,
  160. BOOL fExplicit
  161. )
  162. {
  163. HRESULT hr;
  164. if(!pPropertyCache){
  165. RRETURN(E_POINTER);
  166. }
  167. hr = pPropertyCache->unmarshallproperty(
  168. pszProperty,
  169. (LPBYTE)&stValue,
  170. 1,
  171. NT_SYNTAX_ID_SYSTEMTIME,
  172. fExplicit
  173. );
  174. BAIL_ON_FAILURE(hr);
  175. error:
  176. RRETURN(hr);
  177. }
  178. HRESULT
  179. SetDelimitedStringPropertyInCache(
  180. CPropertyCache *pPropertyCache,
  181. LPTSTR pszProperty,
  182. LPTSTR pszValue,
  183. BOOL fExplicit
  184. )
  185. {
  186. HRESULT hr;
  187. DWORD dwNumValues = 0;
  188. LPWSTR pszString = AllocADsStr(pszValue);
  189. if(!pszString){
  190. hr = E_OUTOFMEMORY;
  191. goto error;
  192. }
  193. if(!pPropertyCache){
  194. RRETURN(E_POINTER);
  195. }
  196. //
  197. // Find the size of the delimited String
  198. //
  199. if((dwNumValues = DelimitedStrSize(pszString, TEXT(',')))== 0){
  200. hr = E_FAIL;
  201. goto error;
  202. }
  203. hr = pPropertyCache->unmarshallproperty(
  204. pszProperty,
  205. (LPBYTE)pszString,
  206. dwNumValues,
  207. NT_SYNTAX_ID_DelimitedString,
  208. fExplicit
  209. );
  210. BAIL_ON_FAILURE(hr);
  211. error:
  212. if(pszString){
  213. FreeADsStr(pszString);
  214. }
  215. RRETURN(hr);
  216. }
  217. HRESULT
  218. SetNulledStringPropertyInCache(
  219. CPropertyCache *pPropertyCache,
  220. LPTSTR pszProperty,
  221. LPTSTR pszValue,
  222. BOOL fExplicit
  223. )
  224. {
  225. HRESULT hr;
  226. DWORD dwNumValues = 0;
  227. if(!pPropertyCache){
  228. RRETURN(E_POINTER);
  229. }
  230. //
  231. // Find the size of the nulled String
  232. //
  233. if((dwNumValues = NulledStrSize(pszValue))== 0){
  234. hr = E_FAIL;
  235. goto error;
  236. }
  237. hr = pPropertyCache->unmarshallproperty(
  238. pszProperty,
  239. (LPBYTE)pszValue,
  240. dwNumValues,
  241. NT_SYNTAX_ID_NulledString,
  242. fExplicit
  243. );
  244. BAIL_ON_FAILURE(hr);
  245. error:
  246. RRETURN(hr);
  247. }
  248. HRESULT
  249. GetOctetPropertyFromCache(
  250. CPropertyCache * pPropertyCache,
  251. LPTSTR pszProperty,
  252. OctetString *pOctet)
  253. {
  254. HRESULT hr = S_OK;
  255. DWORD dwSyntaxId = 0;
  256. DWORD dwNumValues = 0;
  257. PNTOBJECT pNTObject = NULL;
  258. hr = pPropertyCache->marshallgetproperty(
  259. pszProperty,
  260. &dwSyntaxId,
  261. &dwNumValues,
  262. &pNTObject
  263. );
  264. BAIL_ON_FAILURE(hr);
  265. hr = MarshallNTSynIdToNT(
  266. dwSyntaxId,
  267. pNTObject,
  268. dwNumValues,
  269. (LPBYTE)pOctet
  270. );
  271. BAIL_ON_FAILURE(hr);
  272. error:
  273. if (pNTObject) {
  274. NTTypeFreeNTObjects(
  275. pNTObject,
  276. dwNumValues
  277. );
  278. }
  279. RRETURN (hr);
  280. }
  281. HRESULT
  282. GetLPTSTRPropertyFromCache(
  283. CPropertyCache * pPropertyCache,
  284. LPTSTR pszProperty,
  285. LPTSTR * ppszValue
  286. )
  287. {
  288. HRESULT hr = S_OK;
  289. DWORD dwSyntaxId = 0;
  290. DWORD dwNumValues = 0;
  291. PNTOBJECT pNTObject = NULL;
  292. hr = pPropertyCache->marshallgetproperty(
  293. pszProperty,
  294. &dwSyntaxId,
  295. &dwNumValues,
  296. &pNTObject
  297. );
  298. BAIL_ON_FAILURE(hr);
  299. hr = MarshallNTSynIdToNT(
  300. dwSyntaxId,
  301. pNTObject,
  302. dwNumValues,
  303. (LPBYTE)ppszValue
  304. );
  305. BAIL_ON_FAILURE(hr);
  306. error:
  307. if (pNTObject) {
  308. NTTypeFreeNTObjects(
  309. pNTObject,
  310. dwNumValues
  311. );
  312. }
  313. RRETURN (hr);
  314. }
  315. HRESULT
  316. GetDelimitedStringPropertyFromCache(
  317. CPropertyCache * pPropertyCache,
  318. LPTSTR pszProperty,
  319. LPTSTR * ppszValue
  320. )
  321. {
  322. HRESULT hr = S_OK;
  323. DWORD dwSyntaxId = 0;
  324. DWORD dwNumValues = 0;
  325. PNTOBJECT pNTObject = NULL;
  326. hr = pPropertyCache->marshallgetproperty(
  327. pszProperty,
  328. &dwSyntaxId,
  329. &dwNumValues,
  330. &pNTObject
  331. );
  332. BAIL_ON_FAILURE(hr);
  333. if(SUCCEEDED(hr)){
  334. hr = MarshallNTSynIdToNT(
  335. dwSyntaxId,
  336. pNTObject,
  337. dwNumValues,
  338. (LPBYTE)ppszValue
  339. );
  340. }
  341. error:
  342. if (pNTObject) {
  343. NTTypeFreeNTObjects(
  344. pNTObject,
  345. dwNumValues
  346. );
  347. }
  348. RRETURN (hr);
  349. }
  350. HRESULT
  351. GetNulledStringPropertyFromCache(
  352. CPropertyCache * pPropertyCache,
  353. LPTSTR pszProperty,
  354. LPTSTR * ppszValue
  355. )
  356. {
  357. HRESULT hr = S_OK;
  358. DWORD dwSyntaxId = 0;
  359. DWORD dwNumValues = 0;
  360. PNTOBJECT pNTObject = NULL;
  361. hr = pPropertyCache->marshallgetproperty(
  362. pszProperty,
  363. &dwSyntaxId,
  364. &dwNumValues,
  365. &pNTObject
  366. );
  367. BAIL_ON_FAILURE(hr);
  368. if(SUCCEEDED(hr)){
  369. hr = MarshallNTSynIdToNT(
  370. dwSyntaxId,
  371. pNTObject,
  372. dwNumValues,
  373. (LPBYTE)ppszValue
  374. );
  375. }
  376. error:
  377. if (pNTObject) {
  378. NTTypeFreeNTObjects(
  379. pNTObject,
  380. dwNumValues
  381. );
  382. }
  383. RRETURN (hr);
  384. }
  385. HRESULT
  386. GetBOOLPropertyFromCache(
  387. CPropertyCache * pPropertyCache,
  388. LPTSTR pszProperty,
  389. PBOOL pBool
  390. )
  391. {
  392. HRESULT hr = S_OK;
  393. DWORD dwSyntaxId = 0;
  394. DWORD dwNumValues = 0;
  395. PNTOBJECT pNTObject = NULL;
  396. hr = pPropertyCache->marshallgetproperty(
  397. pszProperty,
  398. &dwSyntaxId,
  399. &dwNumValues,
  400. &pNTObject
  401. );
  402. BAIL_ON_FAILURE(hr);
  403. if(SUCCEEDED(hr)){
  404. hr = MarshallNTSynIdToNT(
  405. dwSyntaxId,
  406. pNTObject,
  407. dwNumValues,
  408. (LPBYTE)pBool
  409. );
  410. }
  411. error:
  412. if (pNTObject) {
  413. NTTypeFreeNTObjects(
  414. pNTObject,
  415. dwNumValues
  416. );
  417. }
  418. RRETURN (hr);
  419. }
  420. HRESULT
  421. GetDWORDPropertyFromCache(
  422. CPropertyCache * pPropertyCache,
  423. LPTSTR pszProperty,
  424. LPDWORD pdwDWORD
  425. )
  426. {
  427. HRESULT hr = S_OK;
  428. DWORD dwSyntaxId = 0;
  429. DWORD dwNumValues = 0;
  430. PNTOBJECT pNTObject = NULL;
  431. hr = pPropertyCache->marshallgetproperty(
  432. pszProperty,
  433. &dwSyntaxId,
  434. &dwNumValues,
  435. &pNTObject
  436. );
  437. BAIL_ON_FAILURE(hr);
  438. if(SUCCEEDED(hr)){
  439. hr = MarshallNTSynIdToNT(
  440. dwSyntaxId,
  441. pNTObject,
  442. dwNumValues,
  443. (LPBYTE)pdwDWORD
  444. );
  445. }
  446. error:
  447. if (pNTObject) {
  448. NTTypeFreeNTObjects(
  449. pNTObject,
  450. dwNumValues
  451. );
  452. }
  453. RRETURN (hr);
  454. }
  455. HRESULT
  456. GetDATE70PropertyFromCache(
  457. CPropertyCache * pPropertyCache,
  458. LPTSTR pszProperty,
  459. LPDWORD pdwDWORD
  460. )
  461. {
  462. HRESULT hr = S_OK;
  463. DWORD dwSyntaxId = 0;
  464. DWORD dwNumValues = 0;
  465. PNTOBJECT pNTObject = NULL;
  466. hr = pPropertyCache->marshallgetproperty(
  467. pszProperty,
  468. &dwSyntaxId,
  469. &dwNumValues,
  470. &pNTObject
  471. );
  472. BAIL_ON_FAILURE(hr);
  473. if(SUCCEEDED(hr)){
  474. hr = MarshallNTSynIdToNT(
  475. dwSyntaxId,
  476. pNTObject,
  477. dwNumValues,
  478. (LPBYTE)pdwDWORD
  479. );
  480. }
  481. error:
  482. if (pNTObject) {
  483. NTTypeFreeNTObjects(
  484. pNTObject,
  485. dwNumValues
  486. );
  487. }
  488. RRETURN (hr);
  489. }
  490. HRESULT
  491. GetDATEPropertyFromCache(
  492. CPropertyCache * pPropertyCache,
  493. LPTSTR pszProperty,
  494. PDWORD pdwDate
  495. )
  496. {
  497. HRESULT hr = S_OK;
  498. DWORD dwSyntaxId = 0;
  499. DWORD dwNumValues = 0;
  500. PNTOBJECT pNTObject = NULL;
  501. hr = pPropertyCache->marshallgetproperty(
  502. pszProperty,
  503. &dwSyntaxId,
  504. &dwNumValues,
  505. &pNTObject
  506. );
  507. BAIL_ON_FAILURE(hr);
  508. if(SUCCEEDED(hr)){
  509. hr = MarshallNTSynIdToNT(
  510. dwSyntaxId,
  511. pNTObject,
  512. dwNumValues,
  513. (LPBYTE)pdwDate
  514. );
  515. }
  516. error:
  517. if (pNTObject) {
  518. NTTypeFreeNTObjects(
  519. pNTObject,
  520. dwNumValues
  521. );
  522. }
  523. RRETURN (hr);
  524. }
  525. HRESULT
  526. GetSYSTEMTIMEPropertyFromCache(
  527. CPropertyCache * pPropertyCache,
  528. LPTSTR pszProperty,
  529. SYSTEMTIME * pstTime
  530. )
  531. {
  532. HRESULT hr = S_OK;
  533. DWORD dwSyntaxId = 0;
  534. DWORD dwNumValues = 0;
  535. PNTOBJECT pNTObject = NULL;
  536. hr = pPropertyCache->marshallgetproperty(
  537. pszProperty,
  538. &dwSyntaxId,
  539. &dwNumValues,
  540. &pNTObject
  541. );
  542. BAIL_ON_FAILURE(hr);
  543. if(SUCCEEDED(hr)){
  544. hr = MarshallNTSynIdToNT(
  545. dwSyntaxId,
  546. pNTObject,
  547. dwNumValues,
  548. (LPBYTE)pstTime
  549. );
  550. }
  551. error:
  552. if (pNTObject) {
  553. NTTypeFreeNTObjects(
  554. pNTObject,
  555. dwNumValues
  556. );
  557. }
  558. RRETURN (hr);
  559. }