Clean up more 32-bit assumptions.
This commit is contained in:
Родитель
cacae742b2
Коммит
46897fefd6
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Nerdbank.GitVersioning" version="2.1.65" developmentDependency="true" targetFramework="net40" />
|
||||
<package id="WixToolset.DUtil" version="4.0.62" targetFramework="native" />
|
||||
<package id="WixToolset.DUtil" version="4.0.72" targetFramework="native" />
|
||||
</packages>
|
|
@ -54,10 +54,10 @@ BOOL WIXAPI IsVerboseLogging()
|
|||
// if the property wasn't set, check the MsiLogging property (MSI 4.0+)
|
||||
HRESULT hr = WcaGetProperty(L"MsiLogging", &pwzMsiLogging);
|
||||
ExitOnFailure(hr, "failed to get MsiLogging property");
|
||||
int cchMsiLogging = lstrlenW(pwzMsiLogging);
|
||||
if (0 < cchMsiLogging)
|
||||
|
||||
if (pwzMsiLogging)
|
||||
{
|
||||
for (int i = 0; i < cchMsiLogging; i++)
|
||||
for (int i = 0; pwzMsiLogging[i]; i++)
|
||||
{
|
||||
if (L'v' == pwzMsiLogging[i] || L'V' == pwzMsiLogging[i])
|
||||
{
|
||||
|
|
|
@ -247,9 +247,8 @@ extern "C" HRESULT WIXAPI WcaCaScriptWriteString(
|
|||
{
|
||||
HRESULT hr = S_OK;
|
||||
DWORD cbFile = 0;
|
||||
DWORD cbWrite = 0;
|
||||
DWORD cbTotalWritten = 0;
|
||||
WCHAR delim[] = { MAGIC_MULTISZ_DELIM }; // magic char followed by NULL terminator
|
||||
SIZE_T cch = 0;
|
||||
|
||||
cbFile = ::SetFilePointer(hScript->hScriptFile, 0, NULL, FILE_END);
|
||||
if (INVALID_SET_FILE_POINTER == cbFile)
|
||||
|
@ -261,32 +260,15 @@ extern "C" HRESULT WIXAPI WcaCaScriptWriteString(
|
|||
// before adding our new data on the end of the file.
|
||||
if (0 < cbFile)
|
||||
{
|
||||
cbWrite = sizeof(delim);
|
||||
cbTotalWritten = 0;
|
||||
while (cbTotalWritten < cbWrite)
|
||||
{
|
||||
DWORD cbWritten = 0;
|
||||
if (!::WriteFile(hScript->hScriptFile, reinterpret_cast<BYTE*>(delim) + cbTotalWritten, cbWrite - cbTotalWritten, &cbWritten, NULL))
|
||||
{
|
||||
ExitWithLastError(hr, "Failed to write data to ca script.");
|
||||
}
|
||||
|
||||
cbTotalWritten += cbWritten;
|
||||
}
|
||||
hr = FileWriteHandle(hScript->hScriptFile, reinterpret_cast<LPCBYTE>(delim), sizeof(delim));
|
||||
ExitOnFailure(hr, "Failed to write data to ca script.");
|
||||
}
|
||||
|
||||
cbWrite = lstrlenW(wzValue) * sizeof(WCHAR);
|
||||
cbTotalWritten = 0;
|
||||
while (cbTotalWritten < cbWrite)
|
||||
{
|
||||
DWORD cbWritten = 0;
|
||||
if (!::WriteFile(hScript->hScriptFile, reinterpret_cast<const BYTE*>(wzValue) + cbTotalWritten, cbWrite - cbTotalWritten, &cbWritten, NULL))
|
||||
{
|
||||
ExitWithLastError(hr, "Failed to write data to ca script.");
|
||||
}
|
||||
hr = ::StringCchLengthW(wzValue, STRSAFE_MAX_CCH, reinterpret_cast<size_t*>(&cch));
|
||||
ExitOnRootFailure(hr, "Failed to get length of ca script string.");
|
||||
|
||||
cbTotalWritten += cbWritten;
|
||||
}
|
||||
hr = FileWriteHandle(hScript->hScriptFile, reinterpret_cast<LPCBYTE>(wzValue), static_cast<DWORD>(cch) * sizeof(WCHAR));
|
||||
ExitOnFailure(hr, "Failed to write data to ca script.");
|
||||
|
||||
LExit:
|
||||
return hr;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\..\packages\WixToolset.DUtil.4.0.62\build\WixToolset.DUtil.props" Condition="Exists('..\..\packages\WixToolset.DUtil.4.0.62\build\WixToolset.DUtil.props')" />
|
||||
<Import Project="..\..\packages\WixToolset.DUtil.4.0.72\build\WixToolset.DUtil.props" Condition="Exists('..\..\packages\WixToolset.DUtil.4.0.72\build\WixToolset.DUtil.props')" />
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|ARM64">
|
||||
<Configuration>Debug</Configuration>
|
||||
|
@ -89,6 +89,6 @@
|
|||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets'))" />
|
||||
<Error Condition="!Exists('..\..\packages\WixToolset.DUtil.4.0.62\build\WixToolset.DUtil.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.DUtil.4.0.62\build\WixToolset.DUtil.props'))" />
|
||||
<Error Condition="!Exists('..\..\packages\WixToolset.DUtil.4.0.72\build\WixToolset.DUtil.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixToolset.DUtil.4.0.72\build\WixToolset.DUtil.props'))" />
|
||||
</Target>
|
||||
</Project>
|
|
@ -467,12 +467,13 @@ extern "C" HRESULT WIXAPI WcaGetProperty(
|
|||
|
||||
HRESULT hr = S_OK;
|
||||
UINT er = ERROR_SUCCESS;
|
||||
DWORD_PTR cch = 0;
|
||||
DWORD cch = 0;
|
||||
SIZE_T cchMax = 0;
|
||||
|
||||
if (!*ppwzData)
|
||||
{
|
||||
WCHAR szEmpty[1] = L"";
|
||||
er = ::MsiGetPropertyW(WcaGetInstallHandle(), wzProperty, szEmpty, (DWORD *)&cch);
|
||||
er = ::MsiGetPropertyW(WcaGetInstallHandle(), wzProperty, szEmpty, &cch);
|
||||
if (ERROR_MORE_DATA == er || ERROR_SUCCESS == er)
|
||||
{
|
||||
hr = StrAlloc(ppwzData, ++cch);
|
||||
|
@ -481,22 +482,24 @@ extern "C" HRESULT WIXAPI WcaGetProperty(
|
|||
{
|
||||
hr = HRESULT_FROM_WIN32(er);
|
||||
}
|
||||
ExitOnFailure(hr, "Failed to allocate string for Property '%ls'", wzProperty);
|
||||
ExitOnRootFailure(hr, "Failed to allocate string for Property '%ls'", wzProperty);
|
||||
}
|
||||
else
|
||||
{
|
||||
hr = StrMaxLength(*ppwzData, &cch);
|
||||
hr = StrMaxLength(*ppwzData, &cchMax);
|
||||
ExitOnFailure(hr, "Failed to get previous size of property data string.");
|
||||
|
||||
cch = (DWORD)min(MAXDWORD, cchMax);
|
||||
}
|
||||
|
||||
er = ::MsiGetPropertyW(WcaGetInstallHandle(), wzProperty, *ppwzData, (DWORD *)&cch);
|
||||
er = ::MsiGetPropertyW(WcaGetInstallHandle(), wzProperty, *ppwzData, &cch);
|
||||
if (ERROR_MORE_DATA == er)
|
||||
{
|
||||
Assert(*ppwzData);
|
||||
hr = StrAlloc(ppwzData, ++cch);
|
||||
ExitOnFailure(hr, "Failed to allocate string for Property '%ls'", wzProperty);
|
||||
|
||||
er = ::MsiGetPropertyW(WcaGetInstallHandle(), wzProperty, *ppwzData, (DWORD *)&cch);
|
||||
er = ::MsiGetPropertyW(WcaGetInstallHandle(), wzProperty, *ppwzData, &cch);
|
||||
}
|
||||
ExitOnWin32Error(er, hr, "Failed to get data for property '%ls'", wzProperty);
|
||||
|
||||
|
@ -554,7 +557,8 @@ extern "C" HRESULT WIXAPI WcaGetFormattedString(
|
|||
HRESULT hr = S_OK;
|
||||
UINT er = ERROR_SUCCESS;
|
||||
PMSIHANDLE hRecord = ::MsiCreateRecord(1);
|
||||
DWORD_PTR cch = 0;
|
||||
DWORD cch = 0;
|
||||
SIZE_T cchMax = 0;
|
||||
|
||||
er = ::MsiRecordSetStringW(hRecord, 0, wzString);
|
||||
ExitOnWin32Error(er, hr, "Failed to set record field 0 with '%ls'", wzString);
|
||||
|
@ -562,7 +566,7 @@ extern "C" HRESULT WIXAPI WcaGetFormattedString(
|
|||
if (!*ppwzData)
|
||||
{
|
||||
WCHAR szEmpty[1] = L"";
|
||||
er = ::MsiFormatRecordW(WcaGetInstallHandle(), hRecord, szEmpty, (DWORD *)&cch);
|
||||
er = ::MsiFormatRecordW(WcaGetInstallHandle(), hRecord, szEmpty, &cch);
|
||||
if (ERROR_MORE_DATA == er || ERROR_SUCCESS == er)
|
||||
{
|
||||
hr = StrAlloc(ppwzData, ++cch);
|
||||
|
@ -575,17 +579,19 @@ extern "C" HRESULT WIXAPI WcaGetFormattedString(
|
|||
}
|
||||
else
|
||||
{
|
||||
hr = StrMaxLength(*ppwzData, &cch);
|
||||
hr = StrMaxLength(*ppwzData, &cchMax);
|
||||
ExitOnFailure(hr, "Failed to get previous size of property data string");
|
||||
|
||||
cch = (DWORD)min(MAXDWORD, cchMax);
|
||||
}
|
||||
|
||||
er = ::MsiFormatRecordW(WcaGetInstallHandle(), hRecord, *ppwzData, (DWORD *)&cch);
|
||||
er = ::MsiFormatRecordW(WcaGetInstallHandle(), hRecord, *ppwzData, &cch);
|
||||
if (ERROR_MORE_DATA == er)
|
||||
{
|
||||
hr = StrAlloc(ppwzData, ++cch);
|
||||
ExitOnFailure(hr, "Failed to allocate string for formatted string: '%ls'", wzString);
|
||||
|
||||
er = ::MsiFormatRecordW(WcaGetInstallHandle(), hRecord, *ppwzData, (DWORD *)&cch);
|
||||
er = ::MsiFormatRecordW(WcaGetInstallHandle(), hRecord, *ppwzData, &cch);
|
||||
}
|
||||
ExitOnWin32Error(er, hr, "Failed to get formatted string: '%ls'", wzString);
|
||||
|
||||
|
@ -637,12 +643,13 @@ extern "C" HRESULT WIXAPI WcaGetTargetPath(
|
|||
HRESULT hr = S_OK;
|
||||
|
||||
UINT er = ERROR_SUCCESS;
|
||||
DWORD_PTR cch = 0;
|
||||
DWORD cch = 0;
|
||||
SIZE_T cchMax = 0;
|
||||
|
||||
if (!*ppwzData)
|
||||
{
|
||||
WCHAR szEmpty[1] = L"";
|
||||
er = ::MsiGetTargetPathW(WcaGetInstallHandle(), wzFolder, szEmpty, (DWORD*)&cch);
|
||||
er = ::MsiGetTargetPathW(WcaGetInstallHandle(), wzFolder, szEmpty, &cch);
|
||||
if (ERROR_MORE_DATA == er || ERROR_SUCCESS == er)
|
||||
{
|
||||
++cch; //Add one for the null terminator
|
||||
|
@ -656,18 +663,20 @@ extern "C" HRESULT WIXAPI WcaGetTargetPath(
|
|||
}
|
||||
else
|
||||
{
|
||||
hr = StrMaxLength(*ppwzData, &cch);
|
||||
hr = StrMaxLength(*ppwzData, &cchMax);
|
||||
ExitOnFailure(hr, "Failed to get previous size of string");
|
||||
|
||||
cch = (DWORD)min(MAXDWORD, cchMax);
|
||||
}
|
||||
|
||||
er = ::MsiGetTargetPathW(WcaGetInstallHandle(), wzFolder, *ppwzData, (DWORD*)&cch);
|
||||
er = ::MsiGetTargetPathW(WcaGetInstallHandle(), wzFolder, *ppwzData, &cch);
|
||||
if (ERROR_MORE_DATA == er)
|
||||
{
|
||||
++cch;
|
||||
hr = StrAlloc(ppwzData, cch);
|
||||
ExitOnFailure(hr, "Failed to allocate string for target path of folder: '%ls'", wzFolder);
|
||||
|
||||
er = ::MsiGetTargetPathW(WcaGetInstallHandle(), wzFolder, *ppwzData, (DWORD*)&cch);
|
||||
er = ::MsiGetTargetPathW(WcaGetInstallHandle(), wzFolder, *ppwzData, &cch);
|
||||
}
|
||||
ExitOnWin32Error(er, hr, "Failed to get target path for folder '%ls'", wzFolder);
|
||||
|
||||
|
@ -802,12 +811,13 @@ extern "C" HRESULT WIXAPI WcaGetRecordString(
|
|||
|
||||
HRESULT hr = S_OK;
|
||||
UINT er;
|
||||
DWORD_PTR cch = 0;
|
||||
DWORD cch = 0;
|
||||
SIZE_T cchMax = 0;
|
||||
|
||||
if (!*ppwzData)
|
||||
{
|
||||
WCHAR szEmpty[1] = L"";
|
||||
er = ::MsiRecordGetStringW(hRec, uiField, szEmpty, (DWORD*)&cch);
|
||||
er = ::MsiRecordGetStringW(hRec, uiField, szEmpty, &cch);
|
||||
if (ERROR_MORE_DATA == er || ERROR_SUCCESS == er)
|
||||
{
|
||||
hr = StrAlloc(ppwzData, ++cch);
|
||||
|
@ -820,17 +830,19 @@ extern "C" HRESULT WIXAPI WcaGetRecordString(
|
|||
}
|
||||
else
|
||||
{
|
||||
hr = StrMaxLength(*ppwzData, &cch);
|
||||
hr = StrMaxLength(*ppwzData, &cchMax);
|
||||
ExitOnFailure(hr, "Failed to get previous size of string");
|
||||
|
||||
cch = (DWORD)min(MAXDWORD, cchMax);
|
||||
}
|
||||
|
||||
er = ::MsiRecordGetStringW(hRec, uiField, *ppwzData, (DWORD*)&cch);
|
||||
er = ::MsiRecordGetStringW(hRec, uiField, *ppwzData, &cch);
|
||||
if (ERROR_MORE_DATA == er)
|
||||
{
|
||||
hr = StrAlloc(ppwzData, ++cch);
|
||||
ExitOnFailure(hr, "Failed to allocate memory for record string");
|
||||
|
||||
er = ::MsiRecordGetStringW(hRec, uiField, *ppwzData, (DWORD*)&cch);
|
||||
er = ::MsiRecordGetStringW(hRec, uiField, *ppwzData, &cch);
|
||||
}
|
||||
ExitOnWin32Error(er, hr, "Failed to get string from record");
|
||||
|
||||
|
@ -910,7 +922,8 @@ extern "C" HRESULT WIXAPI WcaGetRecordFormattedString(
|
|||
|
||||
HRESULT hr = S_OK;
|
||||
UINT er;
|
||||
DWORD_PTR cch = 0;
|
||||
DWORD cch = 0;
|
||||
SIZE_T cchMax = 0;
|
||||
PMSIHANDLE hRecFormat;
|
||||
|
||||
// get the format string
|
||||
|
@ -932,16 +945,18 @@ extern "C" HRESULT WIXAPI WcaGetRecordFormattedString(
|
|||
ExitOnFailure(hr, "failed to set string to format record");
|
||||
|
||||
// format the string
|
||||
hr = StrMaxLength(*ppwzData, &cch);
|
||||
hr = StrMaxLength(*ppwzData, &cchMax);
|
||||
ExitOnFailure(hr, "failed to get max length of string");
|
||||
|
||||
er = ::MsiFormatRecordW(WcaGetInstallHandle(), hRecFormat, *ppwzData, (DWORD*)&cch);
|
||||
cch = (DWORD)min(MAXDWORD, cchMax);
|
||||
|
||||
er = ::MsiFormatRecordW(WcaGetInstallHandle(), hRecFormat, *ppwzData, &cch);
|
||||
if (ERROR_MORE_DATA == er)
|
||||
{
|
||||
hr = StrAlloc(ppwzData, ++cch);
|
||||
ExitOnFailure(hr, "Failed to allocate memory for record string");
|
||||
|
||||
er = ::MsiFormatRecordW(WcaGetInstallHandle(), hRecFormat, *ppwzData, (DWORD*)&cch);
|
||||
er = ::MsiFormatRecordW(WcaGetInstallHandle(), hRecFormat, *ppwzData, &cch);
|
||||
}
|
||||
ExitOnWin32Error(er, hr, "Failed to format string");
|
||||
|
||||
|
@ -1273,7 +1288,7 @@ extern "C" HRESULT WIXAPI WcaReadIntegerFromCaData(
|
|||
)
|
||||
{
|
||||
LPCWSTR pwz = BreakDownCustomActionData(ppwzCustomActionData);
|
||||
if (!pwz || 0 == wcslen(pwz))
|
||||
if (!pwz || !*pwz)
|
||||
return E_NOMOREITEMS;
|
||||
|
||||
*piResult = wcstol(pwz, NULL, 10);
|
||||
|
@ -1319,24 +1334,34 @@ extern "C" HRESULT WIXAPI WcaWriteStringToCaData(
|
|||
{
|
||||
HRESULT hr = S_OK;
|
||||
WCHAR delim[] = {MAGIC_MULTISZ_DELIM, 0}; // magic char followed by NULL terminator
|
||||
SIZE_T cchString = 0;
|
||||
SIZE_T cchCustomActionData = 0;
|
||||
SIZE_T cchMax = 0;
|
||||
|
||||
if (!ppwzCustomActionData)
|
||||
{
|
||||
ExitFunction1(hr = E_INVALIDARG);
|
||||
}
|
||||
|
||||
DWORD cchString = lstrlenW(wzString) + 1; // assume we'll be adding the delim
|
||||
DWORD_PTR cchCustomActionData = 0;
|
||||
hr = ::StringCchLengthW(wzString, STRSAFE_MAX_LENGTH, reinterpret_cast<size_t*>(&cchString));
|
||||
ExitOnRootFailure(hr, "failed to get length of ca data string");
|
||||
|
||||
++cchString; // assume we'll be adding the delim
|
||||
|
||||
if (*ppwzCustomActionData)
|
||||
{
|
||||
hr = StrMaxLength(*ppwzCustomActionData, &cchCustomActionData);
|
||||
ExitOnFailure(hr, "failed to get length of custom action data");
|
||||
ExitOnFailure(hr, "failed to get max length of custom action data");
|
||||
|
||||
hr = ::StringCchLengthW(*ppwzCustomActionData, STRSAFE_MAX_LENGTH, reinterpret_cast<size_t*>(&cchMax));
|
||||
ExitOnRootFailure(hr, "failed to get length of custom action data");
|
||||
}
|
||||
|
||||
if ((cchCustomActionData - lstrlenW(*ppwzCustomActionData)) < cchString + 1)
|
||||
if ((cchCustomActionData - cchMax) < cchString + 1)
|
||||
{
|
||||
cchCustomActionData += cchString + 1 + 255; // add 255 for good measure
|
||||
cchCustomActionData = min(STRSAFE_MAX_LENGTH, cchCustomActionData);
|
||||
|
||||
hr = StrAlloc(ppwzCustomActionData, cchCustomActionData);
|
||||
ExitOnFailure(hr, "Failed to allocate memory for CustomActionData string");
|
||||
}
|
||||
|
@ -1344,11 +1369,11 @@ extern "C" HRESULT WIXAPI WcaWriteStringToCaData(
|
|||
if (**ppwzCustomActionData) // if data exists toss the delimiter on before adding more to the end
|
||||
{
|
||||
hr = ::StringCchCatW(*ppwzCustomActionData, cchCustomActionData, delim);
|
||||
ExitOnFailure(hr, "Failed to concatenate CustomActionData string");
|
||||
ExitOnRootFailure(hr, "Failed to concatenate CustomActionData string");
|
||||
}
|
||||
|
||||
hr = ::StringCchCatW(*ppwzCustomActionData, cchCustomActionData, wzString);
|
||||
ExitOnFailure(hr, "Failed to concatenate CustomActionData string");
|
||||
ExitOnRootFailure(hr, "Failed to concatenate CustomActionData string");
|
||||
|
||||
LExit:
|
||||
return hr;
|
||||
|
|
|
@ -88,7 +88,7 @@ eColumnDataType WIXAPI GetDataTypeFromString(
|
|||
LPCWSTR pwzTypeString
|
||||
)
|
||||
{
|
||||
if (NULL == pwzTypeString || 0 == wcslen(pwzTypeString))
|
||||
if (!pwzTypeString || !*pwzTypeString)
|
||||
{
|
||||
return cdtUnknown;
|
||||
}
|
||||
|
@ -350,7 +350,7 @@ HRESULT WIXAPI WcaWrapQuery(
|
|||
hr = WcaGetRecordString(hRec, dwComponentColumn, &pwzData);
|
||||
ExitOnFailure(hr, "Failed to get component from column %d while adding extra columns", dwComponentColumn);
|
||||
|
||||
if (0 == lstrlenW(pwzData))
|
||||
if (!pwzData || !*pwzData)
|
||||
{
|
||||
// If no component was provided, set these both to zero as though a structure to store them were allocated with memory zero'd out
|
||||
isInstalled = (INSTALLSTATE)0;
|
||||
|
|
Загрузка…
Ссылка в новой задаче