diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2021-04-28 18:12:36 -0500 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2021-04-29 14:02:02 -0500 |
commit | 46897fefd6aef4168f35c1f366c833d715c3bdaa (patch) | |
tree | 852312345c583c35315f283af76f85d6f0b7674c /src/wcautil/wcascript.cpp | |
parent | cacae742b21e42c6c7a1cd7c9ddd102264ac0782 (diff) | |
download | wix-46897fefd6aef4168f35c1f366c833d715c3bdaa.tar.gz wix-46897fefd6aef4168f35c1f366c833d715c3bdaa.tar.bz2 wix-46897fefd6aef4168f35c1f366c833d715c3bdaa.zip |
Clean up more 32-bit assumptions.
Diffstat (limited to 'src/wcautil/wcascript.cpp')
-rw-r--r-- | src/wcautil/wcascript.cpp | 32 |
1 files changed, 7 insertions, 25 deletions
diff --git a/src/wcautil/wcascript.cpp b/src/wcautil/wcascript.cpp index b6629850..a7e98491 100644 --- a/src/wcautil/wcascript.cpp +++ b/src/wcautil/wcascript.cpp | |||
@@ -247,9 +247,8 @@ extern "C" HRESULT WIXAPI WcaCaScriptWriteString( | |||
247 | { | 247 | { |
248 | HRESULT hr = S_OK; | 248 | HRESULT hr = S_OK; |
249 | DWORD cbFile = 0; | 249 | DWORD cbFile = 0; |
250 | DWORD cbWrite = 0; | ||
251 | DWORD cbTotalWritten = 0; | ||
252 | WCHAR delim[] = { MAGIC_MULTISZ_DELIM }; // magic char followed by NULL terminator | 250 | WCHAR delim[] = { MAGIC_MULTISZ_DELIM }; // magic char followed by NULL terminator |
251 | SIZE_T cch = 0; | ||
253 | 252 | ||
254 | cbFile = ::SetFilePointer(hScript->hScriptFile, 0, NULL, FILE_END); | 253 | cbFile = ::SetFilePointer(hScript->hScriptFile, 0, NULL, FILE_END); |
255 | if (INVALID_SET_FILE_POINTER == cbFile) | 254 | if (INVALID_SET_FILE_POINTER == cbFile) |
@@ -261,32 +260,15 @@ extern "C" HRESULT WIXAPI WcaCaScriptWriteString( | |||
261 | // before adding our new data on the end of the file. | 260 | // before adding our new data on the end of the file. |
262 | if (0 < cbFile) | 261 | if (0 < cbFile) |
263 | { | 262 | { |
264 | cbWrite = sizeof(delim); | 263 | hr = FileWriteHandle(hScript->hScriptFile, reinterpret_cast<LPCBYTE>(delim), sizeof(delim)); |
265 | cbTotalWritten = 0; | 264 | ExitOnFailure(hr, "Failed to write data to ca script."); |
266 | while (cbTotalWritten < cbWrite) | ||
267 | { | ||
268 | DWORD cbWritten = 0; | ||
269 | if (!::WriteFile(hScript->hScriptFile, reinterpret_cast<BYTE*>(delim) + cbTotalWritten, cbWrite - cbTotalWritten, &cbWritten, NULL)) | ||
270 | { | ||
271 | ExitWithLastError(hr, "Failed to write data to ca script."); | ||
272 | } | ||
273 | |||
274 | cbTotalWritten += cbWritten; | ||
275 | } | ||
276 | } | 265 | } |
277 | 266 | ||
278 | cbWrite = lstrlenW(wzValue) * sizeof(WCHAR); | 267 | hr = ::StringCchLengthW(wzValue, STRSAFE_MAX_CCH, reinterpret_cast<size_t*>(&cch)); |
279 | cbTotalWritten = 0; | 268 | ExitOnRootFailure(hr, "Failed to get length of ca script string."); |
280 | while (cbTotalWritten < cbWrite) | ||
281 | { | ||
282 | DWORD cbWritten = 0; | ||
283 | if (!::WriteFile(hScript->hScriptFile, reinterpret_cast<const BYTE*>(wzValue) + cbTotalWritten, cbWrite - cbTotalWritten, &cbWritten, NULL)) | ||
284 | { | ||
285 | ExitWithLastError(hr, "Failed to write data to ca script."); | ||
286 | } | ||
287 | 269 | ||
288 | cbTotalWritten += cbWritten; | 270 | hr = FileWriteHandle(hScript->hScriptFile, reinterpret_cast<LPCBYTE>(wzValue), static_cast<DWORD>(cch) * sizeof(WCHAR)); |
289 | } | 271 | ExitOnFailure(hr, "Failed to write data to ca script."); |
290 | 272 | ||
291 | LExit: | 273 | LExit: |
292 | return hr; | 274 | return hr; |