aboutsummaryrefslogtreecommitdiff
path: root/src/dutil/strutil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/dutil/strutil.cpp')
-rw-r--r--src/dutil/strutil.cpp144
1 files changed, 72 insertions, 72 deletions
diff --git a/src/dutil/strutil.cpp b/src/dutil/strutil.cpp
index 4e184c34..c1d701d3 100644
--- a/src/dutil/strutil.cpp
+++ b/src/dutil/strutil.cpp
@@ -7,19 +7,19 @@
7// Forward declarations. 7// Forward declarations.
8static HRESULT AllocHelper( 8static HRESULT AllocHelper(
9 __deref_out_ecount_part(cch, 0) LPWSTR* ppwz, 9 __deref_out_ecount_part(cch, 0) LPWSTR* ppwz,
10 __in DWORD_PTR cch, 10 __in SIZE_T cch,
11 __in BOOL fZeroOnRealloc 11 __in BOOL fZeroOnRealloc
12 ); 12 );
13static HRESULT AllocStringHelper( 13static HRESULT AllocStringHelper(
14 __deref_out_ecount_z(cchSource + 1) LPWSTR* ppwz, 14 __deref_out_ecount_z(cchSource + 1) LPWSTR* ppwz,
15 __in_z LPCWSTR wzSource, 15 __in_z LPCWSTR wzSource,
16 __in DWORD_PTR cchSource, 16 __in SIZE_T cchSource,
17 __in BOOL fZeroOnRealloc 17 __in BOOL fZeroOnRealloc
18 ); 18 );
19static HRESULT AllocConcatHelper( 19static HRESULT AllocConcatHelper(
20 __deref_out_z LPWSTR* ppwz, 20 __deref_out_z LPWSTR* ppwz,
21 __in_z LPCWSTR wzSource, 21 __in_z LPCWSTR wzSource,
22 __in DWORD_PTR cchSource, 22 __in SIZE_T cchSource,
23 __in BOOL fZeroOnRealloc 23 __in BOOL fZeroOnRealloc
24 ); 24 );
25static HRESULT AllocFormattedArgsHelper( 25static HRESULT AllocFormattedArgsHelper(
@@ -42,7 +42,7 @@ NOTE: caller is responsible for freeing ppwz even if function fails
42********************************************************************/ 42********************************************************************/
43extern "C" HRESULT DAPI StrAlloc( 43extern "C" HRESULT DAPI StrAlloc(
44 __deref_out_ecount_part(cch, 0) LPWSTR* ppwz, 44 __deref_out_ecount_part(cch, 0) LPWSTR* ppwz,
45 __in DWORD_PTR cch 45 __in SIZE_T cch
46 ) 46 )
47{ 47{
48 return AllocHelper(ppwz, cch, FALSE); 48 return AllocHelper(ppwz, cch, FALSE);
@@ -57,7 +57,7 @@ NOTE: caller is responsible for freeing ppwz even if function fails
57********************************************************************/ 57********************************************************************/
58extern "C" HRESULT DAPI StrAllocSecure( 58extern "C" HRESULT DAPI StrAllocSecure(
59 __deref_out_ecount_part(cch, 0) LPWSTR* ppwz, 59 __deref_out_ecount_part(cch, 0) LPWSTR* ppwz,
60 __in DWORD_PTR cch 60 __in SIZE_T cch
61 ) 61 )
62{ 62{
63 return AllocHelper(ppwz, cch, TRUE); 63 return AllocHelper(ppwz, cch, TRUE);
@@ -72,7 +72,7 @@ NOTE: caller is responsible for freeing ppwz even if function fails
72********************************************************************/ 72********************************************************************/
73static HRESULT AllocHelper( 73static HRESULT AllocHelper(
74 __deref_out_ecount_part(cch, 0) LPWSTR* ppwz, 74 __deref_out_ecount_part(cch, 0) LPWSTR* ppwz,
75 __in DWORD_PTR cch, 75 __in SIZE_T cch,
76 __in BOOL fZeroOnRealloc 76 __in BOOL fZeroOnRealloc
77 ) 77 )
78{ 78{
@@ -128,7 +128,7 @@ HRESULT DAPI StrTrimCapacity(
128 Assert(ppwz); 128 Assert(ppwz);
129 129
130 HRESULT hr = S_OK; 130 HRESULT hr = S_OK;
131 DWORD_PTR cchLen = 0; 131 SIZE_T cchLen = 0;
132 132
133 hr = ::StringCchLengthW(*ppwz, STRSAFE_MAX_CCH, reinterpret_cast<UINT_PTR*>(&cchLen)); 133 hr = ::StringCchLengthW(*ppwz, STRSAFE_MAX_CCH, reinterpret_cast<UINT_PTR*>(&cchLen));
134 ExitOnFailure(hr, "Failed to calculate length of string"); 134 ExitOnFailure(hr, "Failed to calculate length of string");
@@ -201,7 +201,7 @@ NOTE: caller is responsible for freeing ppsz even if function fails
201********************************************************************/ 201********************************************************************/
202extern "C" HRESULT DAPI StrAnsiAlloc( 202extern "C" HRESULT DAPI StrAnsiAlloc(
203 __deref_out_ecount_part(cch, 0) LPSTR* ppsz, 203 __deref_out_ecount_part(cch, 0) LPSTR* ppsz,
204 __in DWORD_PTR cch 204 __in SIZE_T cch
205 ) 205 )
206{ 206{
207 Assert(ppsz && cch); 207 Assert(ppsz && cch);
@@ -246,7 +246,7 @@ HRESULT DAPI StrAnsiTrimCapacity(
246 Assert(ppz); 246 Assert(ppz);
247 247
248 HRESULT hr = S_OK; 248 HRESULT hr = S_OK;
249 DWORD_PTR cchLen = 0; 249 SIZE_T cchLen = 0;
250 250
251#pragma prefast(push) 251#pragma prefast(push)
252#pragma prefast(disable:25068) 252#pragma prefast(disable:25068)
@@ -324,7 +324,7 @@ NOTE: if cchSource == 0, length of wzSource is used instead
324extern "C" HRESULT DAPI StrAllocString( 324extern "C" HRESULT DAPI StrAllocString(
325 __deref_out_ecount_z(cchSource+1) LPWSTR* ppwz, 325 __deref_out_ecount_z(cchSource+1) LPWSTR* ppwz,
326 __in_z LPCWSTR wzSource, 326 __in_z LPCWSTR wzSource,
327 __in DWORD_PTR cchSource 327 __in SIZE_T cchSource
328 ) 328 )
329{ 329{
330 return AllocStringHelper(ppwz, wzSource, cchSource, FALSE); 330 return AllocStringHelper(ppwz, wzSource, cchSource, FALSE);
@@ -342,7 +342,7 @@ NOTE: if cchSource == 0, length of wzSource is used instead
342extern "C" HRESULT DAPI StrAllocStringSecure( 342extern "C" HRESULT DAPI StrAllocStringSecure(
343 __deref_out_ecount_z(cchSource + 1) LPWSTR* ppwz, 343 __deref_out_ecount_z(cchSource + 1) LPWSTR* ppwz,
344 __in_z LPCWSTR wzSource, 344 __in_z LPCWSTR wzSource,
345 __in DWORD_PTR cchSource 345 __in SIZE_T cchSource
346 ) 346 )
347{ 347{
348 return AllocStringHelper(ppwz, wzSource, cchSource, TRUE); 348 return AllocStringHelper(ppwz, wzSource, cchSource, TRUE);
@@ -360,14 +360,14 @@ NOTE: if cchSource == 0, length of wzSource is used instead
360static HRESULT AllocStringHelper( 360static HRESULT AllocStringHelper(
361 __deref_out_ecount_z(cchSource + 1) LPWSTR* ppwz, 361 __deref_out_ecount_z(cchSource + 1) LPWSTR* ppwz,
362 __in_z LPCWSTR wzSource, 362 __in_z LPCWSTR wzSource,
363 __in DWORD_PTR cchSource, 363 __in SIZE_T cchSource,
364 __in BOOL fZeroOnRealloc 364 __in BOOL fZeroOnRealloc
365 ) 365 )
366{ 366{
367 Assert(ppwz && wzSource); // && *wzSource); 367 Assert(ppwz && wzSource); // && *wzSource);
368 368
369 HRESULT hr = S_OK; 369 HRESULT hr = S_OK;
370 DWORD_PTR cch = 0; 370 SIZE_T cch = 0;
371 371
372 if (*ppwz) 372 if (*ppwz)
373 { 373 {
@@ -385,7 +385,7 @@ static HRESULT AllocStringHelper(
385 cchSource = lstrlenW(wzSource); 385 cchSource = lstrlenW(wzSource);
386 } 386 }
387 387
388 DWORD_PTR cchNeeded; 388 SIZE_T cchNeeded;
389 hr = ::ULongPtrAdd(cchSource, 1, &cchNeeded); // add one for the null terminator 389 hr = ::ULongPtrAdd(cchSource, 1, &cchNeeded); // add one for the null terminator
390 ExitOnFailure(hr, "source string is too long"); 390 ExitOnFailure(hr, "source string is too long");
391 391
@@ -414,7 +414,7 @@ NOTE: if cchSource == 0, length of wzSource is used instead
414extern "C" HRESULT DAPI StrAnsiAllocString( 414extern "C" HRESULT DAPI StrAnsiAllocString(
415 __deref_out_ecount_z(cchSource+1) LPSTR* ppsz, 415 __deref_out_ecount_z(cchSource+1) LPSTR* ppsz,
416 __in_z LPCWSTR wzSource, 416 __in_z LPCWSTR wzSource,
417 __in DWORD_PTR cchSource, 417 __in SIZE_T cchSource,
418 __in UINT uiCodepage 418 __in UINT uiCodepage
419 ) 419 )
420{ 420{
@@ -422,8 +422,8 @@ extern "C" HRESULT DAPI StrAnsiAllocString(
422 422
423 HRESULT hr = S_OK; 423 HRESULT hr = S_OK;
424 LPSTR psz = NULL; 424 LPSTR psz = NULL;
425 DWORD_PTR cch = 0; 425 SIZE_T cch = 0;
426 DWORD_PTR cchDest = cchSource; // at least enough 426 SIZE_T cchDest = cchSource; // at least enough
427 427
428 if (*ppsz) 428 if (*ppsz)
429 { 429 {
@@ -494,7 +494,7 @@ NOTE: if cchSource == 0, length of wzSource is used instead
494extern "C" HRESULT DAPI StrAllocStringAnsi( 494extern "C" HRESULT DAPI StrAllocStringAnsi(
495 __deref_out_ecount_z(cchSource+1) LPWSTR* ppwz, 495 __deref_out_ecount_z(cchSource+1) LPWSTR* ppwz,
496 __in_z LPCSTR szSource, 496 __in_z LPCSTR szSource,
497 __in DWORD_PTR cchSource, 497 __in SIZE_T cchSource,
498 __in UINT uiCodepage 498 __in UINT uiCodepage
499 ) 499 )
500{ 500{
@@ -502,8 +502,8 @@ extern "C" HRESULT DAPI StrAllocStringAnsi(
502 502
503 HRESULT hr = S_OK; 503 HRESULT hr = S_OK;
504 LPWSTR pwz = NULL; 504 LPWSTR pwz = NULL;
505 DWORD_PTR cch = 0; 505 SIZE_T cch = 0;
506 DWORD_PTR cchDest = cchSource; // at least enough 506 SIZE_T cchDest = cchSource; // at least enough
507 507
508 if (*ppwz) 508 if (*ppwz)
509 { 509 {
@@ -575,13 +575,13 @@ NOTE: if cchSource == 0, length of wzSource is used instead
575HRESULT DAPI StrAnsiAllocStringAnsi( 575HRESULT DAPI StrAnsiAllocStringAnsi(
576 __deref_out_ecount_z(cchSource+1) LPSTR* ppsz, 576 __deref_out_ecount_z(cchSource+1) LPSTR* ppsz,
577 __in_z LPCSTR szSource, 577 __in_z LPCSTR szSource,
578 __in DWORD_PTR cchSource 578 __in SIZE_T cchSource
579 ) 579 )
580{ 580{
581 Assert(ppsz && szSource); // && *szSource); 581 Assert(ppsz && szSource); // && *szSource);
582 582
583 HRESULT hr = S_OK; 583 HRESULT hr = S_OK;
584 DWORD_PTR cch = 0; 584 SIZE_T cch = 0;
585 585
586 if (*ppsz) 586 if (*ppsz)
587 { 587 {
@@ -599,7 +599,7 @@ HRESULT DAPI StrAnsiAllocStringAnsi(
599 cchSource = lstrlenA(szSource); 599 cchSource = lstrlenA(szSource);
600 } 600 }
601 601
602 DWORD_PTR cchNeeded; 602 SIZE_T cchNeeded;
603 hr = ::ULongPtrAdd(cchSource, 1, &cchNeeded); // add one for the null terminator 603 hr = ::ULongPtrAdd(cchSource, 1, &cchNeeded); // add one for the null terminator
604 ExitOnFailure(hr, "source string is too long"); 604 ExitOnFailure(hr, "source string is too long");
605 605
@@ -632,14 +632,14 @@ NOTE: if cchPrefix == 0, length of wzPrefix is used instead
632extern "C" HRESULT DAPI StrAllocPrefix( 632extern "C" HRESULT DAPI StrAllocPrefix(
633 __deref_out_z LPWSTR* ppwz, 633 __deref_out_z LPWSTR* ppwz,
634 __in_z LPCWSTR wzPrefix, 634 __in_z LPCWSTR wzPrefix,
635 __in DWORD_PTR cchPrefix 635 __in SIZE_T cchPrefix
636 ) 636 )
637{ 637{
638 Assert(ppwz && wzPrefix); 638 Assert(ppwz && wzPrefix);
639 639
640 HRESULT hr = S_OK; 640 HRESULT hr = S_OK;
641 DWORD_PTR cch = 0; 641 SIZE_T cch = 0;
642 DWORD_PTR cchLen = 0; 642 SIZE_T cchLen = 0;
643 643
644 if (*ppwz) 644 if (*ppwz)
645 { 645 {
@@ -672,8 +672,8 @@ extern "C" HRESULT DAPI StrAllocPrefix(
672 672
673 if (*ppwz) 673 if (*ppwz)
674 { 674 {
675 DWORD_PTR cb = cch * sizeof(WCHAR); 675 SIZE_T cb = cch * sizeof(WCHAR);
676 DWORD_PTR cbPrefix = cchPrefix * sizeof(WCHAR); 676 SIZE_T cbPrefix = cchPrefix * sizeof(WCHAR);
677 677
678 memmove(*ppwz + cchPrefix, *ppwz, cb - cbPrefix); 678 memmove(*ppwz + cchPrefix, *ppwz, cb - cbPrefix);
679 memcpy(*ppwz, wzPrefix, cbPrefix); 679 memcpy(*ppwz, wzPrefix, cbPrefix);
@@ -699,7 +699,7 @@ NOTE: if cchSource == 0, length of wzSource is used instead
699extern "C" HRESULT DAPI StrAllocConcat( 699extern "C" HRESULT DAPI StrAllocConcat(
700 __deref_out_z LPWSTR* ppwz, 700 __deref_out_z LPWSTR* ppwz,
701 __in_z LPCWSTR wzSource, 701 __in_z LPCWSTR wzSource,
702 __in DWORD_PTR cchSource 702 __in SIZE_T cchSource
703 ) 703 )
704{ 704{
705 return AllocConcatHelper(ppwz, wzSource, cchSource, FALSE); 705 return AllocConcatHelper(ppwz, wzSource, cchSource, FALSE);
@@ -718,7 +718,7 @@ NOTE: if cchSource == 0, length of wzSource is used instead
718extern "C" HRESULT DAPI StrAllocConcatSecure( 718extern "C" HRESULT DAPI StrAllocConcatSecure(
719 __deref_out_z LPWSTR* ppwz, 719 __deref_out_z LPWSTR* ppwz,
720 __in_z LPCWSTR wzSource, 720 __in_z LPCWSTR wzSource,
721 __in DWORD_PTR cchSource 721 __in SIZE_T cchSource
722 ) 722 )
723{ 723{
724 return AllocConcatHelper(ppwz, wzSource, cchSource, TRUE); 724 return AllocConcatHelper(ppwz, wzSource, cchSource, TRUE);
@@ -737,15 +737,15 @@ NOTE: if cchSource == 0, length of wzSource is used instead
737static HRESULT AllocConcatHelper( 737static HRESULT AllocConcatHelper(
738 __deref_out_z LPWSTR* ppwz, 738 __deref_out_z LPWSTR* ppwz,
739 __in_z LPCWSTR wzSource, 739 __in_z LPCWSTR wzSource,
740 __in DWORD_PTR cchSource, 740 __in SIZE_T cchSource,
741 __in BOOL fZeroOnRealloc 741 __in BOOL fZeroOnRealloc
742 ) 742 )
743{ 743{
744 Assert(ppwz && wzSource); // && *wzSource); 744 Assert(ppwz && wzSource); // && *wzSource);
745 745
746 HRESULT hr = S_OK; 746 HRESULT hr = S_OK;
747 DWORD_PTR cch = 0; 747 SIZE_T cch = 0;
748 DWORD_PTR cchLen = 0; 748 SIZE_T cchLen = 0;
749 749
750 if (*ppwz) 750 if (*ppwz)
751 { 751 {
@@ -801,14 +801,14 @@ NOTE: if cchSource == 0, length of pzSource is used instead
801extern "C" HRESULT DAPI StrAnsiAllocConcat( 801extern "C" HRESULT DAPI StrAnsiAllocConcat(
802 __deref_out_z LPSTR* ppz, 802 __deref_out_z LPSTR* ppz,
803 __in_z LPCSTR pzSource, 803 __in_z LPCSTR pzSource,
804 __in DWORD_PTR cchSource 804 __in SIZE_T cchSource
805 ) 805 )
806{ 806{
807 Assert(ppz && pzSource); // && *pzSource); 807 Assert(ppz && pzSource); // && *pzSource);
808 808
809 HRESULT hr = S_OK; 809 HRESULT hr = S_OK;
810 DWORD_PTR cch = 0; 810 SIZE_T cch = 0;
811 DWORD_PTR cchLen = 0; 811 SIZE_T cchLen = 0;
812 812
813 if (*ppz) 813 if (*ppz)
814 { 814 {
@@ -842,7 +842,7 @@ extern "C" HRESULT DAPI StrAnsiAllocConcat(
842 { 842 {
843 cch = (cchSource + cchLen + 1) * 2; 843 cch = (cchSource + cchLen + 1) * 2;
844 hr = StrAnsiAlloc(ppz, cch); 844 hr = StrAnsiAlloc(ppz, cch);
845 ExitOnFailure(hr, "failed to allocate string from string: %ls", pzSource); 845 ExitOnFailure(hr, "failed to allocate string from string: %hs", pzSource);
846 } 846 }
847 847
848 if (*ppz) 848 if (*ppz)
@@ -1138,7 +1138,7 @@ extern "C" HRESULT DAPI StrAnsiAllocFormattedArgs(
1138 Assert(ppsz && szFormat && *szFormat); 1138 Assert(ppsz && szFormat && *szFormat);
1139 1139
1140 HRESULT hr = S_OK; 1140 HRESULT hr = S_OK;
1141 DWORD_PTR cch = *ppsz ? MemSize(*ppsz) / sizeof(CHAR) : 0; 1141 SIZE_T cch = *ppsz ? MemSize(*ppsz) / sizeof(CHAR) : 0;
1142 LPSTR pszOriginal = NULL; 1142 LPSTR pszOriginal = NULL;
1143 DWORD cchOriginal = 0; 1143 DWORD cchOriginal = 0;
1144 1144
@@ -1183,7 +1183,7 @@ extern "C" HRESULT DAPI StrAnsiAllocFormattedArgs(
1183 } 1183 }
1184 cch *= 2; 1184 cch *= 2;
1185 hr = StrAnsiAlloc(ppsz, cch); 1185 hr = StrAnsiAlloc(ppsz, cch);
1186 ExitOnFailure(hr, "failed to allocate string to format: %ls", szFormat); 1186 ExitOnFailure(hr, "failed to allocate string to format: %hs", szFormat);
1187 hr = S_FALSE; 1187 hr = S_FALSE;
1188 } 1188 }
1189 } while (S_FALSE == hr); 1189 } while (S_FALSE == hr);
@@ -1247,7 +1247,7 @@ NOTE: assumes Unicode string
1247********************************************************************/ 1247********************************************************************/
1248extern "C" HRESULT DAPI StrMaxLength( 1248extern "C" HRESULT DAPI StrMaxLength(
1249 __in LPCVOID p, 1249 __in LPCVOID p,
1250 __out DWORD_PTR* pcch 1250 __out SIZE_T* pcch
1251 ) 1251 )
1252{ 1252{
1253 Assert(pcch); 1253 Assert(pcch);
@@ -1281,7 +1281,7 @@ StrSize - returns count of bytes in dynamic string p
1281********************************************************************/ 1281********************************************************************/
1282extern "C" HRESULT DAPI StrSize( 1282extern "C" HRESULT DAPI StrSize(
1283 __in LPCVOID p, 1283 __in LPCVOID p,
1284 __out DWORD_PTR* pcb 1284 __out SIZE_T* pcb
1285 ) 1285 )
1286{ 1286{
1287 Assert(p && pcb); 1287 Assert(p && pcb);
@@ -1430,9 +1430,9 @@ NOTE: wzDest must have space for cbSource * 2 + 1 characters
1430****************************************************************************/ 1430****************************************************************************/
1431extern "C" HRESULT DAPI StrHexEncode( 1431extern "C" HRESULT DAPI StrHexEncode(
1432 __in_ecount(cbSource) const BYTE* pbSource, 1432 __in_ecount(cbSource) const BYTE* pbSource,
1433 __in DWORD_PTR cbSource, 1433 __in SIZE_T cbSource,
1434 __out_ecount(cchDest) LPWSTR wzDest, 1434 __out_ecount(cchDest) LPWSTR wzDest,
1435 __in DWORD_PTR cchDest 1435 __in SIZE_T cchDest
1436 ) 1436 )
1437{ 1437{
1438 Assert(pbSource && wzDest); 1438 Assert(pbSource && wzDest);
@@ -1469,12 +1469,12 @@ StrAllocHexEncode - converts an array of bytes to an allocated text string
1469****************************************************************************/ 1469****************************************************************************/
1470HRESULT DAPI StrAllocHexEncode( 1470HRESULT DAPI StrAllocHexEncode(
1471 __in_ecount(cbSource) const BYTE* pbSource, 1471 __in_ecount(cbSource) const BYTE* pbSource,
1472 __in DWORD_PTR cbSource, 1472 __in SIZE_T cbSource,
1473 __deref_out_ecount_z(2*(cbSource+1)) LPWSTR* ppwzDest 1473 __deref_out_ecount_z(2*(cbSource+1)) LPWSTR* ppwzDest
1474 ) 1474 )
1475{ 1475{
1476 HRESULT hr = S_OK; 1476 HRESULT hr = S_OK;
1477 DWORD_PTR cchSource = sizeof(WCHAR) * (cbSource + 1); 1477 SIZE_T cchSource = sizeof(WCHAR) * (cbSource + 1);
1478 1478
1479 hr = StrAlloc(ppwzDest, cchSource); 1479 hr = StrAlloc(ppwzDest, cchSource);
1480 ExitOnFailure(hr, "Failed to allocate hex string."); 1480 ExitOnFailure(hr, "Failed to allocate hex string.");
@@ -1495,7 +1495,7 @@ NOTE: wzSource must contain even number of characters
1495extern "C" HRESULT DAPI StrHexDecode( 1495extern "C" HRESULT DAPI StrHexDecode(
1496 __in_z LPCWSTR wzSource, 1496 __in_z LPCWSTR wzSource,
1497 __out_bcount(cbDest) BYTE* pbDest, 1497 __out_bcount(cbDest) BYTE* pbDest,
1498 __in DWORD_PTR cbDest 1498 __in SIZE_T cbDest
1499 ) 1499 )
1500{ 1500{
1501 Assert(wzSource && pbDest); 1501 Assert(wzSource && pbDest);
@@ -1612,12 +1612,12 @@ StrAllocBase85Encode - converts an array of bytes into an XML compatible string
1612****************************************************************************/ 1612****************************************************************************/
1613extern "C" HRESULT DAPI StrAllocBase85Encode( 1613extern "C" HRESULT DAPI StrAllocBase85Encode(
1614 __in_bcount_opt(cbSource) const BYTE* pbSource, 1614 __in_bcount_opt(cbSource) const BYTE* pbSource,
1615 __in DWORD_PTR cbSource, 1615 __in SIZE_T cbSource,
1616 __deref_out_z LPWSTR* pwzDest 1616 __deref_out_z LPWSTR* pwzDest
1617 ) 1617 )
1618{ 1618{
1619 HRESULT hr = S_OK; 1619 HRESULT hr = S_OK;
1620 DWORD_PTR cchDest = 0; 1620 SIZE_T cchDest = 0;
1621 LPWSTR wzDest; 1621 LPWSTR wzDest;
1622 DWORD_PTR iSource = 0; 1622 DWORD_PTR iSource = 0;
1623 DWORD_PTR iDest = 0; 1623 DWORD_PTR iDest = 0;
@@ -1709,15 +1709,15 @@ NOTE: Use MemFree() to release the allocated stream of bytes
1709extern "C" HRESULT DAPI StrAllocBase85Decode( 1709extern "C" HRESULT DAPI StrAllocBase85Decode(
1710 __in_z LPCWSTR wzSource, 1710 __in_z LPCWSTR wzSource,
1711 __deref_out_bcount(*pcbDest) BYTE** ppbDest, 1711 __deref_out_bcount(*pcbDest) BYTE** ppbDest,
1712 __out DWORD_PTR* pcbDest 1712 __out SIZE_T* pcbDest
1713 ) 1713 )
1714{ 1714{
1715 HRESULT hr = S_OK; 1715 HRESULT hr = S_OK;
1716 DWORD_PTR cchSource = lstrlenW(wzSource); 1716 SIZE_T cchSource = lstrlenW(wzSource);
1717 DWORD_PTR i, n, k; 1717 DWORD_PTR i, n, k;
1718 1718
1719 BYTE* pbDest; 1719 BYTE* pbDest;
1720 DWORD_PTR cbDest; 1720 SIZE_T cbDest;
1721 1721
1722 if (!wzSource || !ppbDest || !pcbDest) 1722 if (!wzSource || !ppbDest || !pcbDest)
1723 { 1723 {
@@ -1849,9 +1849,9 @@ including the double null terminator at the end of the MULTISZ.
1849NOTE: returns 0 if the multisz in not properly terminated with two nulls 1849NOTE: returns 0 if the multisz in not properly terminated with two nulls
1850****************************************************************************/ 1850****************************************************************************/
1851extern "C" HRESULT DAPI MultiSzLen( 1851extern "C" HRESULT DAPI MultiSzLen(
1852 __in __nullnullterminated LPCWSTR pwzMultiSz, 1852 __in_ecount(*pcch) __nullnullterminated LPCWSTR pwzMultiSz,
1853 __out DWORD_PTR* pcch 1853 __out SIZE_T* pcch
1854 ) 1854)
1855{ 1855{
1856 Assert(pcch); 1856 Assert(pcch);
1857 1857
@@ -1894,7 +1894,7 @@ MultiSzPrepend - prepends a string onto the front of a MUTLISZ
1894****************************************************************************/ 1894****************************************************************************/
1895extern "C" HRESULT DAPI MultiSzPrepend( 1895extern "C" HRESULT DAPI MultiSzPrepend(
1896 __deref_inout_ecount(*pcchMultiSz) __nullnullterminated LPWSTR* ppwzMultiSz, 1896 __deref_inout_ecount(*pcchMultiSz) __nullnullterminated LPWSTR* ppwzMultiSz,
1897 __inout_opt DWORD_PTR *pcchMultiSz, 1897 __inout_opt SIZE_T* pcchMultiSz,
1898 __in __nullnullterminated LPCWSTR pwzInsert 1898 __in __nullnullterminated LPCWSTR pwzInsert
1899 ) 1899 )
1900{ 1900{
@@ -1902,9 +1902,9 @@ extern "C" HRESULT DAPI MultiSzPrepend(
1902 1902
1903 HRESULT hr =S_OK; 1903 HRESULT hr =S_OK;
1904 LPWSTR pwzResult = NULL; 1904 LPWSTR pwzResult = NULL;
1905 DWORD_PTR cchResult = 0; 1905 SIZE_T cchResult = 0;
1906 DWORD_PTR cchInsert = 0; 1906 SIZE_T cchInsert = 0;
1907 DWORD_PTR cchMultiSz = 0; 1907 SIZE_T cchMultiSz = 0;
1908 1908
1909 // Get the lengths of the MULTISZ (and prime it if it's not initialized) 1909 // Get the lengths of the MULTISZ (and prime it if it's not initialized)
1910 if (pcchMultiSz && 0 != *pcchMultiSz) 1910 if (pcchMultiSz && 0 != *pcchMultiSz)
@@ -1979,8 +1979,8 @@ extern "C" HRESULT DAPI MultiSzFindSubstring(
1979 HRESULT hr = S_FALSE; // Assume we won't find it (the glass is half empty) 1979 HRESULT hr = S_FALSE; // Assume we won't find it (the glass is half empty)
1980 LPCWSTR wz = pwzMultiSz; 1980 LPCWSTR wz = pwzMultiSz;
1981 DWORD_PTR dwIndex = 0; 1981 DWORD_PTR dwIndex = 0;
1982 DWORD_PTR cchMultiSz = 0; 1982 SIZE_T cchMultiSz = 0;
1983 DWORD_PTR cchProgress = 0; 1983 SIZE_T cchProgress = 0;
1984 1984
1985 hr = MultiSzLen(pwzMultiSz, &cchMultiSz); 1985 hr = MultiSzLen(pwzMultiSz, &cchMultiSz);
1986 ExitOnFailure(hr, "failed to get the length of a MULTISZ string"); 1986 ExitOnFailure(hr, "failed to get the length of a MULTISZ string");
@@ -2045,8 +2045,8 @@ extern "C" HRESULT DAPI MultiSzFindString(
2045 HRESULT hr = S_FALSE; // Assume we won't find it 2045 HRESULT hr = S_FALSE; // Assume we won't find it
2046 LPCWSTR wz = pwzMultiSz; 2046 LPCWSTR wz = pwzMultiSz;
2047 DWORD_PTR dwIndex = 0; 2047 DWORD_PTR dwIndex = 0;
2048 DWORD_PTR cchMutliSz = 0; 2048 SIZE_T cchMutliSz = 0;
2049 DWORD_PTR cchProgress = 0; 2049 SIZE_T cchProgress = 0;
2050 2050
2051 hr = MultiSzLen(pwzMultiSz, &cchMutliSz); 2051 hr = MultiSzLen(pwzMultiSz, &cchMutliSz);
2052 ExitOnFailure(hr, "failed to get the length of a MULTISZ string"); 2052 ExitOnFailure(hr, "failed to get the length of a MULTISZ string");
@@ -2112,8 +2112,8 @@ extern "C" HRESULT DAPI MultiSzRemoveString(
2112 LPCWSTR wz = *ppwzMultiSz; 2112 LPCWSTR wz = *ppwzMultiSz;
2113 LPCWSTR wzNext = NULL; 2113 LPCWSTR wzNext = NULL;
2114 DWORD_PTR dwCurrentIndex = 0; 2114 DWORD_PTR dwCurrentIndex = 0;
2115 DWORD_PTR cchMultiSz = 0; 2115 SIZE_T cchMultiSz = 0;
2116 DWORD_PTR cchProgress = 0; 2116 SIZE_T cchProgress = 0;
2117 2117
2118 hr = MultiSzLen(*ppwzMultiSz, &cchMultiSz); 2118 hr = MultiSzLen(*ppwzMultiSz, &cchMultiSz);
2119 ExitOnFailure(hr, "failed to get the length of a MULTISZ string"); 2119 ExitOnFailure(hr, "failed to get the length of a MULTISZ string");
@@ -2179,7 +2179,7 @@ MultiSzInsertString - inserts new string at the specified index
2179****************************************************************************/ 2179****************************************************************************/
2180extern "C" HRESULT DAPI MultiSzInsertString( 2180extern "C" HRESULT DAPI MultiSzInsertString(
2181 __deref_inout __nullnullterminated LPWSTR* ppwzMultiSz, 2181 __deref_inout __nullnullterminated LPWSTR* ppwzMultiSz,
2182 __inout_opt DWORD_PTR *pcchMultiSz, 2182 __inout_opt SIZE_T* pcchMultiSz,
2183 __in DWORD_PTR dwIndex, 2183 __in DWORD_PTR dwIndex,
2184 __in __nullnullterminated LPCWSTR pwzInsert 2184 __in __nullnullterminated LPCWSTR pwzInsert
2185 ) 2185 )
@@ -2189,11 +2189,11 @@ extern "C" HRESULT DAPI MultiSzInsertString(
2189 HRESULT hr = S_OK; 2189 HRESULT hr = S_OK;
2190 LPCWSTR wz = *ppwzMultiSz; 2190 LPCWSTR wz = *ppwzMultiSz;
2191 DWORD_PTR dwCurrentIndex = 0; 2191 DWORD_PTR dwCurrentIndex = 0;
2192 DWORD_PTR cchProgress = 0; 2192 SIZE_T cchProgress = 0;
2193 LPWSTR pwzResult = NULL; 2193 LPWSTR pwzResult = NULL;
2194 DWORD_PTR cchResult = 0; 2194 SIZE_T cchResult = 0;
2195 DWORD_PTR cchString = lstrlenW(pwzInsert); 2195 SIZE_T cchString = lstrlenW(pwzInsert);
2196 DWORD_PTR cchMultiSz = 0; 2196 SIZE_T cchMultiSz = 0;
2197 2197
2198 if (pcchMultiSz && 0 != *pcchMultiSz) 2198 if (pcchMultiSz && 0 != *pcchMultiSz)
2199 { 2199 {
@@ -2302,7 +2302,7 @@ extern "C" LPCWSTR DAPI wcsistr(
2302{ 2302{
2303 LPCWSTR wzSource = wzString; 2303 LPCWSTR wzSource = wzString;
2304 LPCWSTR wzSearch = NULL; 2304 LPCWSTR wzSearch = NULL;
2305 DWORD_PTR cchSourceIndex = 0; 2305 SIZE_T cchSourceIndex = 0;
2306 2306
2307 // Walk through wzString (the source string) one character at a time 2307 // Walk through wzString (the source string) one character at a time
2308 while (*wzSource) 2308 while (*wzSource)
@@ -2600,7 +2600,7 @@ extern "C" HRESULT DAPI StrArrayAllocString(
2600 __deref_inout_ecount_opt(*pcStrArray) LPWSTR **prgsczStrArray, 2600 __deref_inout_ecount_opt(*pcStrArray) LPWSTR **prgsczStrArray,
2601 __inout LPUINT pcStrArray, 2601 __inout LPUINT pcStrArray,
2602 __in_z LPCWSTR wzSource, 2602 __in_z LPCWSTR wzSource,
2603 __in DWORD_PTR cchSource 2603 __in SIZE_T cchSource
2604 ) 2604 )
2605{ 2605{
2606 HRESULT hr = S_OK; 2606 HRESULT hr = S_OK;
@@ -2726,7 +2726,7 @@ extern "C" DAPI_(HRESULT) StrSecureZeroString(
2726 ) 2726 )
2727{ 2727{
2728 HRESULT hr = S_OK; 2728 HRESULT hr = S_OK;
2729 DWORD_PTR cch; 2729 SIZE_T cch;
2730 2730
2731 if (pwz) 2731 if (pwz)
2732 { 2732 {