diff options
Diffstat (limited to 'src/engine/pseudobundle.cpp')
| -rw-r--r-- | src/engine/pseudobundle.cpp | 75 |
1 files changed, 22 insertions, 53 deletions
diff --git a/src/engine/pseudobundle.cpp b/src/engine/pseudobundle.cpp index 73fbb019..db25096b 100644 --- a/src/engine/pseudobundle.cpp +++ b/src/engine/pseudobundle.cpp | |||
| @@ -26,6 +26,7 @@ extern "C" HRESULT PseudoBundleInitialize( | |||
| 26 | { | 26 | { |
| 27 | HRESULT hr = S_OK; | 27 | HRESULT hr = S_OK; |
| 28 | LPWSTR sczRelationTypeCommandLineSwitch = NULL; | 28 | LPWSTR sczRelationTypeCommandLineSwitch = NULL; |
| 29 | BURN_PAYLOAD* pPayload = NULL; | ||
| 29 | 30 | ||
| 30 | LPCWSTR wzRelationTypeCommandLine = CoreRelationTypeToCommandLineString(relationType); | 31 | LPCWSTR wzRelationTypeCommandLine = CoreRelationTypeToCommandLineString(relationType); |
| 31 | if (wzRelationTypeCommandLine) | 32 | if (wzRelationTypeCommandLine) |
| @@ -34,41 +35,40 @@ extern "C" HRESULT PseudoBundleInitialize( | |||
| 34 | } | 35 | } |
| 35 | 36 | ||
| 36 | // Initialize the single payload, and fill out all the necessary fields | 37 | // Initialize the single payload, and fill out all the necessary fields |
| 37 | pPackage->rgPayloads = (BURN_PACKAGE_PAYLOAD *)MemAlloc(sizeof(BURN_PACKAGE_PAYLOAD), TRUE); | 38 | pPackage->payloads.rgpPayloads = (BURN_PAYLOAD**)MemAlloc(sizeof(BURN_PAYLOAD*), TRUE); |
| 38 | ExitOnNull(pPackage->rgPayloads, hr, E_OUTOFMEMORY, "Failed to allocate space for burn package payload inside of related bundle struct"); | 39 | ExitOnNull(pPackage->payloads.rgpPayloads, hr, E_OUTOFMEMORY, "Failed to allocate space for burn payload group inside of related bundle struct"); |
| 39 | pPackage->cPayloads = 1; | 40 | pPackage->payloads.cPayloads = 1; |
| 40 | 41 | ||
| 41 | pPackage->rgPayloads->pPayload = (BURN_PAYLOAD *)MemAlloc(sizeof(BURN_PAYLOAD), TRUE); | 42 | pPayload = (BURN_PAYLOAD*)MemAlloc(sizeof(BURN_PAYLOAD), TRUE); |
| 42 | ExitOnNull(pPackage->rgPayloads, hr, E_OUTOFMEMORY, "Failed to allocate space for burn payload inside of related bundle struct"); | 43 | ExitOnNull(pPayload, hr, E_OUTOFMEMORY, "Failed to allocate space for burn payload inside of related bundle struct"); |
| 43 | pPackage->rgPayloads->pPayload->packaging = BURN_PAYLOAD_PACKAGING_EXTERNAL; | 44 | pPackage->payloads.rgpPayloads[0] = pPayload; |
| 44 | pPackage->rgPayloads->pPayload->qwFileSize = qwSize; | 45 | pPayload->packaging = BURN_PAYLOAD_PACKAGING_EXTERNAL; |
| 46 | pPayload->qwFileSize = qwSize; | ||
| 45 | 47 | ||
| 46 | hr = StrAllocString(&pPackage->rgPayloads->pPayload->sczKey, wzId, 0); | 48 | hr = StrAllocString(&pPayload->sczKey, wzId, 0); |
| 47 | ExitOnFailure(hr, "Failed to copy key for pseudo bundle payload."); | 49 | ExitOnFailure(hr, "Failed to copy key for pseudo bundle payload."); |
| 48 | 50 | ||
| 49 | hr = StrAllocString(&pPackage->rgPayloads->pPayload->sczFilePath, wzFilePath, 0); | 51 | hr = StrAllocString(&pPayload->sczFilePath, wzFilePath, 0); |
| 50 | ExitOnFailure(hr, "Failed to copy filename for pseudo bundle."); | 52 | ExitOnFailure(hr, "Failed to copy filename for pseudo bundle."); |
| 51 | 53 | ||
| 52 | hr = StrAllocString(&pPackage->rgPayloads->pPayload->sczSourcePath, wzLocalSource, 0); | 54 | hr = StrAllocString(&pPayload->sczSourcePath, wzLocalSource, 0); |
| 53 | ExitOnFailure(hr, "Failed to copy local source path for pseudo bundle."); | 55 | ExitOnFailure(hr, "Failed to copy local source path for pseudo bundle."); |
| 54 | 56 | ||
| 55 | if (wzDownloadSource && *wzDownloadSource) | 57 | if (wzDownloadSource && *wzDownloadSource) |
| 56 | { | 58 | { |
| 57 | hr = StrAllocString(&pPackage->rgPayloads->pPayload->downloadSource.sczUrl, wzDownloadSource, 0); | 59 | hr = StrAllocString(&pPayload->downloadSource.sczUrl, wzDownloadSource, 0); |
| 58 | ExitOnFailure(hr, "Failed to copy download source for pseudo bundle."); | 60 | ExitOnFailure(hr, "Failed to copy download source for pseudo bundle."); |
| 59 | } | 61 | } |
| 60 | 62 | ||
| 61 | if (pbHash) | 63 | if (pbHash) |
| 62 | { | 64 | { |
| 63 | pPackage->rgPayloads->pPayload->pbHash = static_cast<BYTE*>(MemAlloc(cbHash, FALSE)); | 65 | pPayload->pbHash = static_cast<BYTE*>(MemAlloc(cbHash, FALSE)); |
| 64 | ExitOnNull(pPackage->rgPayloads->pPayload->pbHash, hr, E_OUTOFMEMORY, "Failed to allocate memory for pseudo bundle payload hash."); | 66 | ExitOnNull(pPayload->pbHash, hr, E_OUTOFMEMORY, "Failed to allocate memory for pseudo bundle payload hash."); |
| 65 | 67 | ||
| 66 | pPackage->rgPayloads->pPayload->cbHash = cbHash; | 68 | pPayload->cbHash = cbHash; |
| 67 | memcpy_s(pPackage->rgPayloads->pPayload->pbHash, pPackage->rgPayloads->pPayload->cbHash, pbHash, cbHash); | 69 | memcpy_s(pPayload->pbHash, pPayload->cbHash, pbHash, cbHash); |
| 68 | } | 70 | } |
| 69 | 71 | ||
| 70 | pPackage->rgPayloads->fCached = fCached; | ||
| 71 | |||
| 72 | pPackage->Exe.fPseudoBundle = TRUE; | 72 | pPackage->Exe.fPseudoBundle = TRUE; |
| 73 | 73 | ||
| 74 | pPackage->type = BURN_PACKAGE_TYPE_EXE; | 74 | pPackage->type = BURN_PACKAGE_TYPE_EXE; |
| @@ -171,44 +171,13 @@ extern "C" HRESULT PseudoBundleInitializePassthrough( | |||
| 171 | LPWSTR sczArguments = NULL; | 171 | LPWSTR sczArguments = NULL; |
| 172 | 172 | ||
| 173 | // Initialize the payloads, and copy the necessary fields. | 173 | // Initialize the payloads, and copy the necessary fields. |
| 174 | pPassthroughPackage->rgPayloads = (BURN_PACKAGE_PAYLOAD *)MemAlloc(sizeof(BURN_PACKAGE_PAYLOAD) * pPackage->cPayloads, TRUE); | 174 | pPassthroughPackage->payloads.rgpPayloads = (BURN_PAYLOAD**)MemAlloc(sizeof(BURN_PAYLOAD*) * pPackage->payloads.cPayloads, TRUE); |
| 175 | ExitOnNull(pPassthroughPackage->rgPayloads, hr, E_OUTOFMEMORY, "Failed to allocate space for burn package payload inside of passthrough bundle."); | 175 | ExitOnNull(pPassthroughPackage->payloads.rgpPayloads, hr, E_OUTOFMEMORY, "Failed to allocate space for burn package payload inside of passthrough bundle."); |
| 176 | pPassthroughPackage->cPayloads = pPackage->cPayloads; | 176 | pPassthroughPackage->payloads.cPayloads = pPackage->payloads.cPayloads; |
| 177 | 177 | ||
| 178 | for (DWORD iPayload = 0; iPayload < pPackage->cPayloads; ++iPayload) | 178 | for (DWORD iPayload = 0; iPayload < pPackage->payloads.cPayloads; ++iPayload) |
| 179 | { | 179 | { |
| 180 | BURN_PACKAGE_PAYLOAD* pPayload = pPackage->rgPayloads + iPayload; | 180 | pPassthroughPackage->payloads.rgpPayloads[iPayload] = pPackage->payloads.rgpPayloads[iPayload]; |
| 181 | |||
| 182 | pPassthroughPackage->rgPayloads[iPayload].pPayload = (BURN_PAYLOAD *)MemAlloc(sizeof(BURN_PAYLOAD), TRUE); | ||
| 183 | ExitOnNull(pPassthroughPackage->rgPayloads[iPayload].pPayload, hr, E_OUTOFMEMORY, "Failed to allocate space for burn payload inside of related bundle struct"); | ||
| 184 | pPassthroughPackage->rgPayloads[iPayload].pPayload->packaging = pPayload->pPayload->packaging; | ||
| 185 | pPassthroughPackage->rgPayloads[iPayload].pPayload->qwFileSize = pPayload->pPayload->qwFileSize; | ||
| 186 | |||
| 187 | hr = StrAllocString(&pPassthroughPackage->rgPayloads[iPayload].pPayload->sczKey, pPayload->pPayload->sczKey, 0); | ||
| 188 | ExitOnFailure(hr, "Failed to copy key for passthrough pseudo bundle payload."); | ||
| 189 | |||
| 190 | hr = StrAllocString(&pPassthroughPackage->rgPayloads[iPayload].pPayload->sczFilePath, pPayload->pPayload->sczFilePath, 0); | ||
| 191 | ExitOnFailure(hr, "Failed to copy filename for passthrough pseudo bundle."); | ||
| 192 | |||
| 193 | hr = StrAllocString(&pPassthroughPackage->rgPayloads[iPayload].pPayload->sczSourcePath, pPayload->pPayload->sczSourcePath, 0); | ||
| 194 | ExitOnFailure(hr, "Failed to copy local source path for passthrough pseudo bundle."); | ||
| 195 | |||
| 196 | if (pPayload->pPayload->downloadSource.sczUrl) | ||
| 197 | { | ||
| 198 | hr = StrAllocString(&pPassthroughPackage->rgPayloads[iPayload].pPayload->downloadSource.sczUrl, pPayload->pPayload->downloadSource.sczUrl, 0); | ||
| 199 | ExitOnFailure(hr, "Failed to copy download source for passthrough pseudo bundle."); | ||
| 200 | } | ||
| 201 | |||
| 202 | if (pPayload->pPayload->pbHash) | ||
| 203 | { | ||
| 204 | pPassthroughPackage->rgPayloads[iPayload].pPayload->pbHash = static_cast<BYTE*>(MemAlloc(pPayload->pPayload->cbHash, FALSE)); | ||
| 205 | ExitOnNull(pPassthroughPackage->rgPayloads[iPayload].pPayload->pbHash, hr, E_OUTOFMEMORY, "Failed to allocate memory for pseudo bundle payload hash."); | ||
| 206 | |||
| 207 | pPassthroughPackage->rgPayloads[iPayload].pPayload->cbHash = pPayload->pPayload->cbHash; | ||
| 208 | memcpy_s(pPassthroughPackage->rgPayloads[iPayload].pPayload->pbHash, pPassthroughPackage->rgPayloads[iPayload].pPayload->cbHash, pPayload->pPayload->pbHash, pPayload->pPayload->cbHash); | ||
| 209 | } | ||
| 210 | |||
| 211 | pPassthroughPackage->rgPayloads[iPayload].fCached = pPayload->fCached; | ||
| 212 | } | 181 | } |
| 213 | 182 | ||
| 214 | pPassthroughPackage->Exe.fPseudoBundle = TRUE; | 183 | pPassthroughPackage->Exe.fPseudoBundle = TRUE; |
