extern "C" HRESULT CatalogElevatedUpdateCatalogFile( __in BURN_CATALOGS* pCatalogs, __in_z LPCWSTR wzId, __in_z LPCWSTR wzPath ) { HRESULT hr = S_OK; BURN_CATALOG* pCatalog = NULL; // Find the catalog hr = CatalogFindById(pCatalogs, wzId, &pCatalog); ExitOnFailure(hr, "Failed to locate catalog information."); if (NULL == pCatalog->sczLocalFilePath) { hr = StrAllocString(&pCatalog->sczLocalFilePath, wzPath, 0); ExitOnFailure(hr, "Failed to allocated catalog path."); // Get a handle to the file pCatalog->hFile = ::CreateFileW(pCatalog->sczLocalFilePath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL); if (INVALID_HANDLE_VALUE == pCatalog->hFile) { ExitWithLastError1(hr, "Failed to open catalog in working path: %ls", pCatalog->sczLocalFilePath); } } LExit: return hr; }
extern "C" HRESULT PayloadsParseFromXml( __in BURN_PAYLOADS* pPayloads, __in_opt BURN_CONTAINERS* pContainers, __in_opt BURN_CATALOGS* pCatalogs, __in IXMLDOMNode* pixnBundle ) { HRESULT hr = S_OK; IXMLDOMNodeList* pixnNodes = NULL; IXMLDOMNode* pixnNode = NULL; DWORD cNodes = 0; LPWSTR scz = NULL; // select payload nodes hr = XmlSelectNodes(pixnBundle, L"Payload", &pixnNodes); ExitOnFailure(hr, "Failed to select payload nodes."); // get payload node count hr = pixnNodes->get_length((long*)&cNodes); ExitOnFailure(hr, "Failed to get payload node count."); if (!cNodes) { ExitFunction(); } // allocate memory for payloads pPayloads->rgPayloads = (BURN_PAYLOAD*)MemAlloc(sizeof(BURN_PAYLOAD) * cNodes, TRUE); ExitOnNull(pPayloads->rgPayloads, hr, E_OUTOFMEMORY, "Failed to allocate memory for payload structs."); pPayloads->cPayloads = cNodes; // parse search elements for (DWORD i = 0; i < cNodes; ++i) { BURN_PAYLOAD* pPayload = &pPayloads->rgPayloads[i]; hr = XmlNextElement(pixnNodes, &pixnNode, NULL); ExitOnFailure(hr, "Failed to get next node."); // @Id hr = XmlGetAttributeEx(pixnNode, L"Id", &pPayload->sczKey); ExitOnFailure(hr, "Failed to get @Id."); // @FilePath hr = XmlGetAttributeEx(pixnNode, L"FilePath", &pPayload->sczFilePath); ExitOnFailure(hr, "Failed to get @FilePath."); // @Packaging hr = XmlGetAttributeEx(pixnNode, L"Packaging", &scz); ExitOnFailure(hr, "Failed to get @Packaging."); if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"download", -1)) { pPayload->packaging = BURN_PAYLOAD_PACKAGING_DOWNLOAD; } else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"embedded", -1)) { pPayload->packaging = BURN_PAYLOAD_PACKAGING_EMBEDDED; } else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"external", -1)) { pPayload->packaging = BURN_PAYLOAD_PACKAGING_EXTERNAL; } else { hr = E_INVALIDARG; ExitOnFailure(hr, "Invalid value for @Packaging: %ls", scz); } // @Container if (pContainers) { hr = XmlGetAttributeEx(pixnNode, L"Container", &scz); if (E_NOTFOUND != hr || BURN_PAYLOAD_PACKAGING_EMBEDDED == pPayload->packaging) { ExitOnFailure(hr, "Failed to get @Container."); // find container hr = ContainerFindById(pContainers, scz, &pPayload->pContainer); ExitOnFailure(hr, "Failed to to find container: %ls", scz); } } // @LayoutOnly hr = XmlGetYesNoAttribute(pixnNode, L"LayoutOnly", &pPayload->fLayoutOnly); if (E_NOTFOUND != hr) { ExitOnFailure(hr, "Failed to get @LayoutOnly."); } // @SourcePath hr = XmlGetAttributeEx(pixnNode, L"SourcePath", &pPayload->sczSourcePath); if (E_NOTFOUND != hr || BURN_PAYLOAD_PACKAGING_DOWNLOAD != pPayload->packaging) { ExitOnFailure(hr, "Failed to get @SourcePath."); } // @DownloadUrl hr = XmlGetAttributeEx(pixnNode, L"DownloadUrl", &pPayload->downloadSource.sczUrl); if (E_NOTFOUND != hr || BURN_PAYLOAD_PACKAGING_DOWNLOAD == pPayload->packaging) { ExitOnFailure(hr, "Failed to get @DownloadUrl."); } // @FileSize hr = XmlGetAttributeEx(pixnNode, L"FileSize", &scz); if (E_NOTFOUND != hr) { ExitOnFailure(hr, "Failed to get @FileSize."); hr = StrStringToUInt64(scz, 0, &pPayload->qwFileSize); ExitOnFailure(hr, "Failed to parse @FileSize."); } // @CertificateAuthorityKeyIdentifier hr = XmlGetAttributeEx(pixnNode, L"CertificateRootPublicKeyIdentifier", &scz); if (E_NOTFOUND != hr) { ExitOnFailure(hr, "Failed to get @CertificateRootPublicKeyIdentifier."); hr = StrAllocHexDecode(scz, &pPayload->pbCertificateRootPublicKeyIdentifier, &pPayload->cbCertificateRootPublicKeyIdentifier); ExitOnFailure(hr, "Failed to hex decode @CertificateRootPublicKeyIdentifier."); } // @CertificateThumbprint hr = XmlGetAttributeEx(pixnNode, L"CertificateRootThumbprint", &scz); if (E_NOTFOUND != hr) { ExitOnFailure(hr, "Failed to get @CertificateRootThumbprint."); hr = StrAllocHexDecode(scz, &pPayload->pbCertificateRootThumbprint, &pPayload->cbCertificateRootThumbprint); ExitOnFailure(hr, "Failed to hex decode @CertificateRootThumbprint."); } // @Hash hr = XmlGetAttributeEx(pixnNode, L"Hash", &scz); ExitOnFailure(hr, "Failed to get @Hash."); hr = StrAllocHexDecode(scz, &pPayload->pbHash, &pPayload->cbHash); ExitOnFailure(hr, "Failed to hex decode the Payload/@Hash."); // @Catalog hr = XmlGetAttributeEx(pixnNode, L"Catalog", &scz); if (E_NOTFOUND != hr) { ExitOnFailure(hr, "Failed to get @Catalog."); hr = CatalogFindById(pCatalogs, scz, &pPayload->pCatalog); ExitOnFailure(hr, "Failed to find catalog."); } // prepare next iteration ReleaseNullObject(pixnNode); } hr = S_OK; LExit: ReleaseObject(pixnNodes); ReleaseObject(pixnNode); ReleaseStr(scz); return hr; }