aboutsummaryrefslogtreecommitdiff
path: root/src/dutil/regutil.cpp
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2021-04-28 16:36:56 -0500
committerSean Hall <r.sean.hall@gmail.com>2021-04-29 13:58:14 -0500
commitbcd3ee7ab858d62beb36af9f5986544b68a3dd35 (patch)
tree424c4e61a580b7c4b7481712f69ab0193d76b9c4 /src/dutil/regutil.cpp
parentd73c29407fe5ec6a0207af7d9c2547457ae0854c (diff)
downloadwix-bcd3ee7ab858d62beb36af9f5986544b68a3dd35.tar.gz
wix-bcd3ee7ab858d62beb36af9f5986544b68a3dd35.tar.bz2
wix-bcd3ee7ab858d62beb36af9f5986544b68a3dd35.zip
Clean up more 32-bit assumptions.
Diffstat (limited to 'src/dutil/regutil.cpp')
-rw-r--r--src/dutil/regutil.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/dutil/regutil.cpp b/src/dutil/regutil.cpp
index afd2d089..cb617932 100644
--- a/src/dutil/regutil.cpp
+++ b/src/dutil/regutil.cpp
@@ -294,12 +294,15 @@ extern "C" HRESULT DAPI RegKeyEnum(
294{ 294{
295 HRESULT hr = S_OK; 295 HRESULT hr = S_OK;
296 DWORD er = ERROR_SUCCESS; 296 DWORD er = ERROR_SUCCESS;
297 SIZE_T cb = 0;
297 DWORD cch = 0; 298 DWORD cch = 0;
298 299
299 if (psczKey && *psczKey) 300 if (psczKey && *psczKey)
300 { 301 {
301 hr = StrMaxLength(*psczKey, reinterpret_cast<DWORD_PTR*>(&cch)); 302 hr = StrMaxLength(*psczKey, &cb);
302 RegExitOnFailure(hr, "Failed to determine length of string."); 303 RegExitOnFailure(hr, "Failed to determine length of string.");
304
305 cch = (DWORD)min(DWORD_MAX, cb);
303 } 306 }
304 307
305 if (2 > cch) 308 if (2 > cch)
@@ -462,6 +465,7 @@ extern "C" HRESULT DAPI RegReadString(
462{ 465{
463 HRESULT hr = S_OK; 466 HRESULT hr = S_OK;
464 DWORD er = ERROR_SUCCESS; 467 DWORD er = ERROR_SUCCESS;
468 SIZE_T cbValue = 0;
465 DWORD cch = 0; 469 DWORD cch = 0;
466 DWORD cb = 0; 470 DWORD cb = 0;
467 DWORD dwType = 0; 471 DWORD dwType = 0;
@@ -469,8 +473,10 @@ extern "C" HRESULT DAPI RegReadString(
469 473
470 if (psczValue && *psczValue) 474 if (psczValue && *psczValue)
471 { 475 {
472 hr = StrMaxLength(*psczValue, reinterpret_cast<DWORD_PTR*>(&cch)); 476 hr = StrMaxLength(*psczValue, &cbValue);
473 RegExitOnFailure(hr, "Failed to determine length of string."); 477 RegExitOnFailure(hr, "Failed to determine length of string.");
478
479 cch = (DWORD)min(DWORD_MAX, cbValue);
474 } 480 }
475 481
476 if (2 > cch) 482 if (2 > cch)
@@ -1000,18 +1006,18 @@ static HRESULT WriteStringToRegistry(
1000 __in_z_opt LPCWSTR wzName, 1006 __in_z_opt LPCWSTR wzName,
1001 __in_z_opt LPCWSTR wzValue, 1007 __in_z_opt LPCWSTR wzValue,
1002 __in DWORD dwType 1008 __in DWORD dwType
1003) 1009 )
1004{ 1010{
1005 HRESULT hr = S_OK; 1011 HRESULT hr = S_OK;
1006 DWORD er = ERROR_SUCCESS; 1012 DWORD er = ERROR_SUCCESS;
1007 DWORD cbValue = 0; 1013 size_t cbValue = 0;
1008 1014
1009 if (wzValue) 1015 if (wzValue)
1010 { 1016 {
1011 hr = ::StringCbLengthW(wzValue, STRSAFE_MAX_CCH * sizeof(TCHAR), reinterpret_cast<size_t*>(&cbValue)); 1017 hr = ::StringCbLengthW(wzValue, STRSAFE_MAX_CCH * sizeof(TCHAR), &cbValue);
1012 RegExitOnFailure(hr, "Failed to determine length of registry value: %ls", wzName); 1018 RegExitOnFailure(hr, "Failed to determine length of registry value: %ls", wzName);
1013 1019
1014 er = vpfnRegSetValueExW(hk, wzName, 0, dwType, reinterpret_cast<const BYTE *>(wzValue), cbValue); 1020 er = vpfnRegSetValueExW(hk, wzName, 0, dwType, reinterpret_cast<const BYTE *>(wzValue), static_cast<DWORD>(cbValue));
1015 RegExitOnWin32Error(er, hr, "Failed to set registry value: %ls", wzName); 1021 RegExitOnWin32Error(er, hr, "Failed to set registry value: %ls", wzName);
1016 } 1022 }
1017 else 1023 else