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.

816 lines
20 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. Regqval.c
  5. Abstract:
  6. This module contains the client side wrappers for the Win32 Registry
  7. query value APIs. That is:
  8. - RegQueryValueA
  9. - RegQueryValueW
  10. - RegQueryValueExA
  11. - RegQueryValueExW
  12. Author:
  13. David J. Gilman (davegi) 18-Mar-1992
  14. Notes:
  15. See the notes in server\regqval.c.
  16. --*/
  17. #include <rpc.h>
  18. #include "regrpc.h"
  19. #include "client.h"
  20. LONG
  21. RegQueryValueA (
  22. HKEY hKey,
  23. LPCSTR lpSubKey,
  24. LPSTR lpData,
  25. PLONG lpcbData
  26. )
  27. /*++
  28. Routine Description:
  29. Win 3.1 ANSI RPC wrapper for querying a value.
  30. --*/
  31. {
  32. HKEY ChildKey;
  33. LONG Error;
  34. DWORD ValueType;
  35. LONG InitialCbData;
  36. HKEY TempHandle = NULL;
  37. #if DBG
  38. if ( BreakPointOnEntry ) {
  39. DbgBreakPoint();
  40. }
  41. #endif
  42. //
  43. // Limit the capabilities associated with HKEY_PERFORMANCE_DATA.
  44. //
  45. if( hKey == HKEY_PERFORMANCE_DATA ) {
  46. return ERROR_INVALID_HANDLE;
  47. }
  48. hKey = MapPredefinedHandle( hKey, &TempHandle );
  49. if( hKey == NULL ) {
  50. Error = ERROR_INVALID_HANDLE;
  51. goto ExitCleanup;
  52. }
  53. //
  54. // If the sub-key is NULL or points to an empty string then the value is
  55. // to be queried from this key (i.e. hKey) otherwise the sub-key needs
  56. // to be opened.
  57. //
  58. if(( lpSubKey == NULL ) || ( *lpSubKey == '\0' )) {
  59. ChildKey = hKey;
  60. } else {
  61. //
  62. // The sub-key was supplied so impersonate the
  63. // client and attempt to open it.
  64. //
  65. Error = RegOpenKeyExA(
  66. hKey,
  67. lpSubKey,
  68. 0,
  69. KEY_QUERY_VALUE,
  70. &ChildKey
  71. );
  72. if( Error != ERROR_SUCCESS ) {
  73. goto ExitCleanup;
  74. }
  75. }
  76. InitialCbData = ARGUMENT_PRESENT(lpcbData) ? (*lpcbData) : 0;
  77. //
  78. // ChildKey contains an HKEY which may be the one supplied (hKey) or
  79. // returned from RegOpenKeyExA. Query the value using the special value
  80. // name NULL.
  81. //
  82. Error = RegQueryValueExA(
  83. ChildKey,
  84. NULL,
  85. NULL,
  86. &ValueType,
  87. lpData,
  88. lpcbData
  89. );
  90. //
  91. // If the sub key was opened, close it.
  92. //
  93. if( ChildKey != hKey ) {
  94. if( IsLocalHandle( ChildKey )) {
  95. LocalBaseRegCloseKey( &ChildKey );
  96. } else {
  97. ChildKey = DereferenceRemoteHandle( ChildKey );
  98. BaseRegCloseKey( &ChildKey );
  99. }
  100. }
  101. //
  102. // If the type of the value is not a null terminate string, then return
  103. // an error. (Win 3.1 compatibility)
  104. //
  105. if (!Error && ((ValueType != REG_SZ) && (ValueType != REG_EXPAND_SZ))) {
  106. Error = ERROR_INVALID_DATA;
  107. }
  108. //
  109. // If value doesn't exist, return ERROR_SUCCESS and an empty string.
  110. // (Win 3.1 compatibility)
  111. //
  112. if( Error == ERROR_FILE_NOT_FOUND ) {
  113. if( ARGUMENT_PRESENT( lpcbData ) ) {
  114. *lpcbData = sizeof( CHAR );
  115. }
  116. if( ARGUMENT_PRESENT( lpData ) ) {
  117. *lpData = '\0';
  118. }
  119. Error = ERROR_SUCCESS;
  120. }
  121. //
  122. // Expand if necessary (VB compatibility)
  123. //
  124. if (!Error && (ValueType == REG_EXPAND_SZ)) {
  125. if ( (!ARGUMENT_PRESENT(lpcbData)) || (!ARGUMENT_PRESENT(lpData)) ) {
  126. Error = ERROR_INVALID_DATA;
  127. } else {
  128. LPSTR ExpandBuffer;
  129. LONG ExpandedSize;
  130. LONG BufferSize = (InitialCbData>*lpcbData)?InitialCbData:*lpcbData;
  131. //
  132. // if InitialCbData was 0, allocate a buffer of the real size
  133. //
  134. ExpandBuffer = RtlAllocateHeap( RtlProcessHeap(), 0, BufferSize);
  135. if (ExpandBuffer == NULL) {
  136. Error = ERROR_NOT_ENOUGH_MEMORY;
  137. } else {
  138. RtlCopyMemory(ExpandBuffer, lpData, *lpcbData);
  139. ExpandedSize = ExpandEnvironmentStringsA(ExpandBuffer, lpData, BufferSize);
  140. if (ExpandedSize > InitialCbData) {
  141. Error = ERROR_MORE_DATA;
  142. }
  143. *lpcbData = ExpandedSize;
  144. RtlFreeHeap( RtlProcessHeap(), 0, ExpandBuffer );
  145. }
  146. }
  147. }
  148. //
  149. // Return the results of querying the value.
  150. //
  151. ExitCleanup:
  152. CLOSE_LOCAL_HANDLE(TempHandle);
  153. return Error;
  154. }
  155. LONG
  156. RegQueryValueW (
  157. HKEY hKey,
  158. LPCWSTR lpSubKey,
  159. LPWSTR lpData,
  160. PLONG lpcbData
  161. )
  162. /*++
  163. Routine Description:
  164. Win 3.1 Unicode RPC wrapper for querying a value.
  165. --*/
  166. {
  167. HKEY ChildKey;
  168. LONG Error;
  169. DWORD ValueType;
  170. LONG InitialCbData;
  171. HKEY TempHandle = NULL;
  172. #if DBG
  173. if ( BreakPointOnEntry ) {
  174. DbgBreakPoint();
  175. }
  176. #endif
  177. //
  178. // Limit the capabilities associated with HKEY_PERFORMANCE_DATA.
  179. //
  180. if( hKey == HKEY_PERFORMANCE_DATA ) {
  181. return ERROR_INVALID_HANDLE;
  182. }
  183. hKey = MapPredefinedHandle( hKey, &TempHandle );
  184. if( hKey == NULL ) {
  185. Error = ERROR_INVALID_HANDLE;
  186. goto ExitCleanup;
  187. }
  188. //
  189. // If the sub-key is NULL or points to an empty string then the value is
  190. // to be queried from this key (i.e. hKey) otherwise the sub-key needs
  191. // to be opened.
  192. //
  193. if(( lpSubKey == NULL ) || ( *lpSubKey == '\0' )) {
  194. ChildKey = hKey;
  195. } else {
  196. //
  197. // The sub-key was supplied so attempt to open it.
  198. //
  199. Error = RegOpenKeyExW(
  200. hKey,
  201. lpSubKey,
  202. 0,
  203. KEY_QUERY_VALUE,
  204. &ChildKey
  205. );
  206. if( Error != ERROR_SUCCESS ) {
  207. goto ExitCleanup;
  208. }
  209. }
  210. InitialCbData = ARGUMENT_PRESENT(lpcbData) ? (*lpcbData) : 0;
  211. //
  212. // ChildKey contains an HKEY which may be the one supplied (hKey) or
  213. // returned from RegOpenKeyExA. Query the value using the special value
  214. // name NULL.
  215. //
  216. Error = RegQueryValueExW(
  217. ChildKey,
  218. NULL,
  219. NULL,
  220. &ValueType,
  221. ( LPBYTE )lpData,
  222. lpcbData
  223. );
  224. //
  225. // If the sub key was opened, close it.
  226. //
  227. if( ChildKey != hKey ) {
  228. if( IsLocalHandle( ChildKey )) {
  229. LocalBaseRegCloseKey( &ChildKey );
  230. } else {
  231. ChildKey = DereferenceRemoteHandle( ChildKey );
  232. BaseRegCloseKey( &ChildKey );
  233. }
  234. }
  235. //
  236. // If the type of the value is not a null terminate string, then return
  237. // an error. (Win 3.1 compatibility)
  238. //
  239. if (!Error && ((ValueType != REG_SZ) && (ValueType != REG_EXPAND_SZ))) {
  240. Error = ERROR_INVALID_DATA;
  241. }
  242. //
  243. // If value doesn't exist, return ERROR_SUCCESS and an empty string.
  244. // (Win 3.1 compatibility)
  245. //
  246. if( Error == ERROR_FILE_NOT_FOUND ) {
  247. if( ARGUMENT_PRESENT( lpcbData ) ) {
  248. *lpcbData = sizeof( WCHAR );
  249. }
  250. if( ARGUMENT_PRESENT( lpData ) ) {
  251. *lpData = ( WCHAR )'\0';
  252. }
  253. Error = ERROR_SUCCESS;
  254. }
  255. //
  256. // Expand if necessary (VB compatibility)
  257. //
  258. if (!Error && (ValueType == REG_EXPAND_SZ)) {
  259. if ( (!ARGUMENT_PRESENT(lpcbData)) || (!ARGUMENT_PRESENT(lpData)) ) {
  260. Error = ERROR_INVALID_DATA;
  261. } else {
  262. LPWSTR ExpandBuffer;
  263. LONG ExpandedSize;
  264. LONG BufferSize = (InitialCbData>*lpcbData)?InitialCbData:*lpcbData;
  265. //
  266. // if InitialCbData was 0, allocate a buffer of the real size
  267. //
  268. ExpandBuffer = RtlAllocateHeap( RtlProcessHeap(), 0, BufferSize);
  269. if (ExpandBuffer == NULL) {
  270. Error = ERROR_NOT_ENOUGH_MEMORY;
  271. } else {
  272. RtlCopyMemory(ExpandBuffer, lpData, *lpcbData);
  273. ExpandedSize = ExpandEnvironmentStringsW(ExpandBuffer, lpData, BufferSize / sizeof(WCHAR));
  274. if (ExpandedSize > (LONG)(InitialCbData / sizeof(WCHAR))) {
  275. Error = ERROR_MORE_DATA;
  276. }
  277. *lpcbData = ExpandedSize;
  278. RtlFreeHeap( RtlProcessHeap(), 0, ExpandBuffer );
  279. }
  280. }
  281. }
  282. //
  283. // Return the results of querying the value.
  284. //
  285. ExitCleanup:
  286. CLOSE_LOCAL_HANDLE(TempHandle);
  287. return Error;
  288. }
  289. LONG
  290. APIENTRY
  291. RegQueryValueExA (
  292. HKEY hKey,
  293. LPCSTR lpValueName,
  294. LPDWORD lpReserved,
  295. LPDWORD lpdwType,
  296. LPBYTE lpData,
  297. LPDWORD lpcbData
  298. )
  299. /*++
  300. Routine Description:
  301. Win32 ANSI RPC wrapper for querying a value.
  302. RegQueryValueExA converts the lpValueName argument to a counted Unicode
  303. string and then calls BaseRegQueryValue.
  304. --*/
  305. {
  306. PUNICODE_STRING ValueName;
  307. UNICODE_STRING StubValueName;
  308. DWORD ValueType;
  309. ANSI_STRING AnsiString;
  310. NTSTATUS Status;
  311. LONG Error;
  312. DWORD ValueLength;
  313. DWORD InputLength;
  314. PWSTR UnicodeValueBuffer;
  315. ULONG UnicodeValueLength;
  316. PSTR AnsiValueBuffer;
  317. ULONG AnsiValueLength;
  318. ULONG Index;
  319. ULONG cbAnsi = 0;
  320. HKEY TempHandle = NULL;
  321. #if DBG
  322. if ( BreakPointOnEntry ) {
  323. DbgBreakPoint();
  324. }
  325. #endif
  326. //
  327. // Validate dependency between lpData and lpcbData parameters.
  328. //
  329. if( ARGUMENT_PRESENT( lpReserved ) ||
  330. (ARGUMENT_PRESENT( lpData ) && ( ! ARGUMENT_PRESENT( lpcbData )))) {
  331. return ERROR_INVALID_PARAMETER;
  332. }
  333. hKey = MapPredefinedHandle( hKey, &TempHandle );
  334. if( hKey == NULL ) {
  335. Error = ERROR_INVALID_HANDLE;
  336. goto ExitCleanup;
  337. }
  338. //
  339. // Convert the value name to a counted Unicode string using the static
  340. // Unicode string in the TEB.
  341. //
  342. StubValueName.Buffer = NULL;
  343. ValueName = &NtCurrentTeb( )->StaticUnicodeString;
  344. ASSERT( ValueName != NULL );
  345. RtlInitAnsiString( &AnsiString, lpValueName );
  346. Status = RtlAnsiStringToUnicodeString(
  347. ValueName,
  348. &AnsiString,
  349. FALSE
  350. );
  351. if( ! NT_SUCCESS( Status )) {
  352. //
  353. // The StaticUnicodeString is not long enough; Try to allocate a bigger one
  354. //
  355. Status = RtlAnsiStringToUnicodeString(
  356. &StubValueName,
  357. &AnsiString,
  358. TRUE
  359. );
  360. if( ! NT_SUCCESS( Status )) {
  361. Error = RtlNtStatusToDosError( Status );
  362. goto ExitCleanup;
  363. }
  364. ValueName = &StubValueName;
  365. }
  366. //
  367. // Add the terminating NULL to the Length so that RPC transmits
  368. // it.
  369. //
  370. ValueName->Length += sizeof( UNICODE_NULL );
  371. //
  372. // Call the Base API, passing it the supplied parameters and the
  373. // counted Unicode strings. Note that zero bytes are transmitted (i.e.
  374. // InputLength = 0) for the data.
  375. //
  376. ValueLength = ARGUMENT_PRESENT( lpcbData )? *lpcbData : 0;
  377. InputLength = 0;
  378. if( IsLocalHandle( hKey )) {
  379. Error = (LONG)LocalBaseRegQueryValue (
  380. hKey,
  381. ValueName,
  382. &ValueType,
  383. lpData,
  384. &ValueLength,
  385. &InputLength
  386. );
  387. //
  388. // Make sure that the local side didn't destroy the Buffer in
  389. // the StaticUnicodeString
  390. //
  391. ASSERT( ValueName->Buffer );
  392. } else {
  393. Error = (LONG)BaseRegQueryValue (
  394. DereferenceRemoteHandle( hKey ),
  395. ValueName,
  396. &ValueType,
  397. lpData,
  398. &ValueLength,
  399. &InputLength
  400. );
  401. }
  402. //
  403. // If no error or callers buffer too small, and type is one of the null
  404. // terminated string types, then do the UNICODE to ANSI translation.
  405. // We handle the buffer too small case, because the callers buffer may
  406. // be big enough for the ANSI representation, but not the UNICODE one.
  407. // In this case, we need to allocate a buffer big enough, do the query
  408. // again and then the translation into the callers buffer. We only do
  409. // this if the caller actually wants the value data (lpData != NULL)
  410. //
  411. if ((Error == ERROR_SUCCESS || Error == ERROR_MORE_DATA) &&
  412. (ARGUMENT_PRESENT( lpData ) || ARGUMENT_PRESENT( lpcbData ))&&
  413. (ValueType == REG_SZ ||
  414. ValueType == REG_EXPAND_SZ ||
  415. ValueType == REG_MULTI_SZ)
  416. ) {
  417. UnicodeValueLength = ValueLength;
  418. AnsiValueBuffer = lpData;
  419. AnsiValueLength = ARGUMENT_PRESENT( lpcbData )?
  420. *lpcbData : 0;
  421. //
  422. // Allocate a buffer for the UNICODE value and reissue the query.
  423. //
  424. UnicodeValueBuffer = RtlAllocateHeap( RtlProcessHeap(), 0,
  425. UnicodeValueLength
  426. );
  427. if (UnicodeValueBuffer == NULL) {
  428. Error = ERROR_NOT_ENOUGH_MEMORY;
  429. } else {
  430. InputLength = 0;
  431. if( IsLocalHandle( hKey )) {
  432. //
  433. // Add the terminating NULL to the Length
  434. // (remember that in the local case, ValueName->Length
  435. // was decremented by sizeof( UNICODE_NULL ) in the first
  436. // call to LocalBaseRegQueryValue).
  437. // This won't happen in the remote case, since the
  438. // server side will decrement ValueName->Length on
  439. // the transmitted structure (a copy of ValueName), and
  440. // the new Valuename->Length won't be transmitted back to
  441. // the client.
  442. //
  443. ValueName->Length += sizeof( UNICODE_NULL );
  444. Error = (LONG)LocalBaseRegQueryValue (
  445. hKey,
  446. ValueName,
  447. &ValueType,
  448. (LPBYTE)UnicodeValueBuffer,
  449. &ValueLength,
  450. &InputLength
  451. );
  452. //
  453. // Make sure that the local side didn't destroy the
  454. // Buffer in the StaticUnicodeString
  455. //
  456. ASSERT(ValueName->Buffer);
  457. } else {
  458. Error = (LONG)BaseRegQueryValue (
  459. DereferenceRemoteHandle( hKey ),
  460. ValueName,
  461. &ValueType,
  462. (LPBYTE)UnicodeValueBuffer,
  463. &ValueLength,
  464. &InputLength
  465. );
  466. }
  467. if( Error == ERROR_SUCCESS ) {
  468. // Compute needed buffer size , cbAnsi will keeps the byte
  469. // counts to keep MBCS string after following step.
  470. RtlUnicodeToMultiByteSize( &cbAnsi ,
  471. UnicodeValueBuffer ,
  472. ValueLength );
  473. // If we could not store all MBCS string to buffer that
  474. // Apps gives me. We set ERROR_MORE_DATA to Error
  475. if( ARGUMENT_PRESENT( lpcbData ) ) {
  476. if( cbAnsi > *lpcbData && lpData != NULL ) {
  477. Error = ERROR_MORE_DATA;
  478. }
  479. }
  480. } else {
  481. // to be used below
  482. cbAnsi = ValueLength;
  483. }
  484. }
  485. if ((Error == ERROR_SUCCESS) && (AnsiValueBuffer != NULL) ) {
  486. //
  487. // We have a UNICODE value, so translate it to ANSI in the callers
  488. // buffer. In the case where the caller's buffer was big enough
  489. // for the UNICODE version, we do the conversion in place, which
  490. // works since the ANSI version is smaller than the UNICODE version.
  491. //
  492. Index = 0;
  493. Status = RtlUnicodeToMultiByteN( AnsiValueBuffer,
  494. AnsiValueLength,
  495. &Index,
  496. UnicodeValueBuffer,
  497. UnicodeValueLength
  498. );
  499. if (!NT_SUCCESS( Status )) {
  500. Error = RtlNtStatusToDosError( Status );
  501. }
  502. // Now Index keeps Byte counts of MBCS string in AnsiValueBuffer
  503. cbAnsi = Index;
  504. }
  505. //
  506. // Free the buffer if it was successfully allocated
  507. //
  508. if (UnicodeValueBuffer != NULL) {
  509. RtlFreeHeap( RtlProcessHeap(), 0, UnicodeValueBuffer );
  510. }
  511. //
  512. // Return the length of the ANSI version to the caller.
  513. //
  514. ValueLength = cbAnsi;
  515. //
  516. // Special hack to help out all the people who
  517. // believe the length of a NULL terminated string is
  518. // strlen(foo) instead of strlen(foo) + 1.
  519. // If the last character of the buffer is not a NULL
  520. // and there is enough space left in the caller's buffer,
  521. // slap a NULL in there to prevent him from going nuts
  522. // trying to do a strlen().
  523. //
  524. if (ARGUMENT_PRESENT( lpData ) &&
  525. (*lpcbData > ValueLength) &&
  526. (ValueLength > 0) &&
  527. (lpData[ValueLength-1] != '\0')) {
  528. lpData[ValueLength] = '\0';
  529. }
  530. }
  531. //
  532. // Stored the returned length in the caller specified location and
  533. // return the error code.
  534. //
  535. if (lpdwType != NULL) {
  536. *lpdwType = ValueType;
  537. }
  538. if( ARGUMENT_PRESENT( lpcbData ) ) {
  539. *lpcbData = ValueLength;
  540. }
  541. //
  542. // Free the temporary Unicode string stub allocated for the ValueName
  543. //
  544. RtlFreeUnicodeString(&StubValueName);
  545. ExitCleanup:
  546. CLOSE_LOCAL_HANDLE(TempHandle);
  547. return Error;
  548. }
  549. LONG
  550. APIENTRY
  551. RegQueryValueExW (
  552. HKEY hKey,
  553. LPCWSTR lpValueName,
  554. LPDWORD lpReserved,
  555. LPDWORD lpdwType,
  556. LPBYTE lpData,
  557. LPDWORD lpcbData
  558. )
  559. /*++
  560. Routine Description:
  561. Win32 Unicode RPC wrapper for querying a value.
  562. RegQueryValueExW converts the lpValueName argument to a counted Unicode
  563. string and then calls BaseRegQueryValue.
  564. --*/
  565. {
  566. UNICODE_STRING ValueName;
  567. DWORD InputLength;
  568. DWORD ValueLength;
  569. DWORD ValueType;
  570. LONG Error;
  571. UNALIGNED WCHAR *String;
  572. HKEY TempHandle = NULL;
  573. #if DBG
  574. if ( BreakPointOnEntry ) {
  575. DbgBreakPoint();
  576. }
  577. #endif
  578. //
  579. // Validate dependency between lpData and lpcbData parameters.
  580. //
  581. if( ARGUMENT_PRESENT( lpReserved ) ||
  582. (ARGUMENT_PRESENT( lpData ) && ( ! ARGUMENT_PRESENT( lpcbData )))) {
  583. return ERROR_INVALID_PARAMETER;
  584. }
  585. hKey = MapPredefinedHandle( hKey, &TempHandle );
  586. if( hKey == NULL ) {
  587. Error = ERROR_INVALID_HANDLE;
  588. goto ExitCleanup;
  589. }
  590. //
  591. // Convert the value name to a counted Unicode string.
  592. //
  593. RtlInitUnicodeString( &ValueName, lpValueName );
  594. //
  595. // Add the terminating NULL to the Length so that RPC transmits
  596. // it.
  597. //
  598. ValueName.Length += sizeof( UNICODE_NULL );
  599. //
  600. // Call the Base API, passing it the supplied parameters and the
  601. // counted Unicode strings. Note that zero bytes are transmitted (i.e.
  602. // InputLength = 0) for the data.
  603. //
  604. InputLength = 0;
  605. ValueLength = ( ARGUMENT_PRESENT( lpcbData ) )? *lpcbData : 0;
  606. if( IsLocalHandle( hKey )) {
  607. Error = (LONG)LocalBaseRegQueryValue (
  608. hKey,
  609. &ValueName,
  610. &ValueType,
  611. lpData,
  612. &ValueLength,
  613. &InputLength
  614. );
  615. } else {
  616. Error = (LONG)BaseRegQueryValue (
  617. DereferenceRemoteHandle( hKey ),
  618. &ValueName,
  619. &ValueType,
  620. lpData,
  621. &ValueLength,
  622. &InputLength
  623. );
  624. }
  625. //
  626. // Special hack to help out all the people who
  627. // believe the length of a NULL terminated string is
  628. // strlen(foo) instead of strlen(foo) + 1.
  629. // If the last character of the buffer is not a NULL
  630. // and there is enough space left in the caller's buffer,
  631. // slap a NULL in there to prevent him from going nuts
  632. // trying to do a strlen().
  633. //
  634. if ( (Error == ERROR_SUCCESS) &&
  635. ARGUMENT_PRESENT( lpData ) &&
  636. ( (ValueType == REG_SZ) ||
  637. (ValueType == REG_EXPAND_SZ) ||
  638. (ValueType==REG_MULTI_SZ)) &&
  639. ( ValueLength > sizeof(WCHAR))) {
  640. UNALIGNED WCHAR *String = (UNALIGNED WCHAR *)lpData;
  641. DWORD Length = ValueLength/sizeof(WCHAR);
  642. if ((String[Length-1] != UNICODE_NULL) &&
  643. (ValueLength+sizeof(WCHAR) <= *lpcbData)) {
  644. String[Length] = UNICODE_NULL;
  645. }
  646. }
  647. if( ARGUMENT_PRESENT( lpcbData ) ) {
  648. *lpcbData = ValueLength;
  649. }
  650. if ( ARGUMENT_PRESENT( lpdwType )) {
  651. *lpdwType = ValueType;
  652. }
  653. ExitCleanup:
  654. CLOSE_LOCAL_HANDLE(TempHandle);
  655. return Error;
  656. }