Skip to content

Commit

Permalink
Fix more message passing breaking some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
robmen committed Feb 29, 2024
1 parent 6a854af commit 8daad15
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 24 deletions.
63 changes: 39 additions & 24 deletions src/api/burn/balutil/msg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,13 +504,16 @@ static HRESULT OnCacheAcquireResolving(
hr = BuffReaderReadNumber(pReader, &cSearchPaths);
ExitOnFailure(hr, "Failed to read overall percentage of OnCacheAcquireResolving args.");

rgsczSearchPaths = static_cast<LPWSTR*>(MemAlloc(sizeof(LPWSTR) * cSearchPaths, TRUE));
ExitOnNull(rgsczSearchPaths, hr, E_OUTOFMEMORY, "Failed to allocate memory for search paths.");

for (DWORD i = 0; i < cSearchPaths; ++i)
if (cSearchPaths)
{
hr = BuffReaderReadString(pReader, &rgsczSearchPaths[i]);
ExitOnFailure(hr, "Failed to read search path[%u] of OnCacheAcquireResolving args.", i);
rgsczSearchPaths = static_cast<LPWSTR*>(MemAlloc(sizeof(LPWSTR) * cSearchPaths, TRUE));
ExitOnNull(rgsczSearchPaths, hr, E_OUTOFMEMORY, "Failed to allocate memory for search paths of OnCacheAcquireResolving args.");

for (DWORD i = 0; i < cSearchPaths; ++i)
{
hr = BuffReaderReadString(pReader, &rgsczSearchPaths[i]);
ExitOnFailure(hr, "Failed to read search path[%u] of OnCacheAcquireResolving args.", i);
}
}

args.cSearchPaths = cSearchPaths;
Expand Down Expand Up @@ -943,6 +946,9 @@ static HRESULT OnCachePackageComplete(
hr = BuffReaderReadNumber(pReader, &results.cbSize);
ExitOnFailure(hr, "Failed to read size of OnCachePackageComplete results.");

hr = BuffReaderReadNumber(pReader, reinterpret_cast<DWORD*>(&results.action));
ExitOnFailure(hr, "Failed to read action of OnCachePackageComplete results.");

// Callback.
hr = pApplication->BAProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONCACHEPACKAGECOMPLETE, &args, &results);

Expand Down Expand Up @@ -2669,13 +2675,16 @@ static HRESULT OnError(
hr = BuffReaderReadNumber(pReader, &cData);
ExitOnFailure(hr, "Failed to read count of data of OnError args.");

rgsczData = static_cast<LPWSTR*>(MemAlloc(sizeof(LPWSTR) * cData, TRUE));
ExitOnNull(rgsczData, hr, E_OUTOFMEMORY, "Failed to allocate memory for search paths.");

for (DWORD i = 0; i < cData; ++i)
if (cData)
{
hr = BuffReaderReadString(pReader, &rgsczData[i]);
ExitOnFailure(hr, "Failed to read search path[%u] of OnCacheAcquireResolving args.", i);
rgsczData = static_cast<LPWSTR*>(MemAlloc(sizeof(LPWSTR) * cData, TRUE));
ExitOnNull(rgsczData, hr, E_OUTOFMEMORY, "Failed to allocate memory for data of OnError args.");

for (DWORD i = 0; i < cData; ++i)
{
hr = BuffReaderReadString(pReader, &rgsczData[i]);
ExitOnFailure(hr, "Failed to read search path[%u] of OnError args.", i);
}
}

args.cData = cData;
Expand Down Expand Up @@ -2839,13 +2848,16 @@ static HRESULT OnExecuteFilesInUse(
hr = BuffReaderReadNumber(pReader, &cFiles);
ExitOnFailure(hr, "Failed to read count of files of OnExecuteFilesInUse args.");

rgsczFiles = static_cast<LPWSTR*>(MemAlloc(sizeof(LPWSTR) * cFiles, TRUE));
ExitOnNull(rgsczFiles, hr, E_OUTOFMEMORY, "Failed to allocate memory for files in OnExecuteFilesInUse.");

for (DWORD i = 0; i < cFiles; ++i)
if (cFiles)
{
hr = BuffReaderReadString(pReader, &rgsczFiles[i]);
ExitOnFailure(hr, "Failed to read file[%u] of OnExecuteFilesInUse args.", i);
rgsczFiles = static_cast<LPWSTR*>(MemAlloc(sizeof(LPWSTR) * cFiles, TRUE));
ExitOnNull(rgsczFiles, hr, E_OUTOFMEMORY, "Failed to allocate memory for files of OnExecuteFilesInUse args.");

for (DWORD i = 0; i < cFiles; ++i)
{
hr = BuffReaderReadString(pReader, &rgsczFiles[i]);
ExitOnFailure(hr, "Failed to read file[%u] of OnExecuteFilesInUse args.", i);
}
}

args.cFiles = cFiles;
Expand Down Expand Up @@ -2933,13 +2945,16 @@ static HRESULT OnExecuteMsiMessage(
hr = BuffReaderReadNumber(pReader, &cData);
ExitOnFailure(hr, "Failed to read count of files of OnExecuteMsiMessage args.");

rgsczData = static_cast<LPWSTR*>(MemAlloc(sizeof(LPWSTR) * cData, TRUE));
ExitOnNull(rgsczData, hr, E_OUTOFMEMORY, "Failed to allocate memory for files in OnExecuteMsiMessage.");

for (DWORD i = 0; i < cData; ++i)
if (cData)
{
hr = BuffReaderReadString(pReader, &rgsczData[i]);
ExitOnFailure(hr, "Failed to read data[%u] of OnExecuteMsiMessage args.", i);
rgsczData = static_cast<LPWSTR*>(MemAlloc(sizeof(LPWSTR) * cData, TRUE));
ExitOnNull(rgsczData, hr, E_OUTOFMEMORY, "Failed to allocate memory for data of OnExecuteMsiMessage args.");

for (DWORD i = 0; i < cData; ++i)
{
hr = BuffReaderReadString(pReader, &rgsczData[i]);
ExitOnFailure(hr, "Failed to read data[%u] of OnExecuteMsiMessage args.", i);
}
}

args.cData = cData;
Expand Down
3 changes: 3 additions & 0 deletions src/burn/engine/bacallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,9 @@ EXTERN_C HRESULT BACallbackOnCachePackageComplete(
hr = BuffWriteNumberToBuffer(&buffer, results.cbSize);
ExitOnFailure(hr, "Failed to write size of OnCachePackageComplete results.");

hr = BuffWriteNumberToBuffer(&buffer, results.action);
ExitOnFailure(hr, "Failed to write action of OnCachePackageComplete results.");

hr = BuffEnsurePaddingInBuffer(&buffer, args.cbSize + results.cbSize);
ExitOnFailure(hr, "Failed to add padding to OnCachePackageComplete results.");

Expand Down

0 comments on commit 8daad15

Please sign in to comment.