summaryrefslogtreecommitdiff
path: root/src/burn/engine/container.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/burn/engine/container.cpp')
-rw-r--r--src/burn/engine/container.cpp32
1 files changed, 12 insertions, 20 deletions
diff --git a/src/burn/engine/container.cpp b/src/burn/engine/container.cpp
index aa123927..2f21baa8 100644
--- a/src/burn/engine/container.cpp
+++ b/src/burn/engine/container.cpp
@@ -15,6 +15,7 @@ extern "C" HRESULT ContainersParseFromXml(
15 IXMLDOMNode* pixnNode = NULL; 15 IXMLDOMNode* pixnNode = NULL;
16 DWORD cNodes = 0; 16 DWORD cNodes = 0;
17 LPWSTR scz = NULL; 17 LPWSTR scz = NULL;
18 BOOL fXmlFound = FALSE;
18 19
19 // select container nodes 20 // select container nodes
20 hr = XmlSelectNodes(pixnBundle, L"Container", &pixnNodes); 21 hr = XmlSelectNodes(pixnBundle, L"Container", &pixnNodes);
@@ -48,26 +49,20 @@ extern "C" HRESULT ContainersParseFromXml(
48 49
49 // @Id 50 // @Id
50 hr = XmlGetAttributeEx(pixnNode, L"Id", &pContainer->sczId); 51 hr = XmlGetAttributeEx(pixnNode, L"Id", &pContainer->sczId);
51 ExitOnFailure(hr, "Failed to get @Id."); 52 ExitOnRequiredXmlQueryFailure(hr, "Failed to get @Id.");
52 53
53 // @Attached 54 // @Attached
54 hr = XmlGetYesNoAttribute(pixnNode, L"Attached", &pContainer->fAttached); 55 hr = XmlGetYesNoAttribute(pixnNode, L"Attached", &pContainer->fAttached);
55 if (E_NOTFOUND != hr) 56 ExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to get @Attached.");
56 {
57 ExitOnFailure(hr, "Failed to get @Attached.");
58 }
59
60 // @AttachedIndex
61 hr = XmlGetAttributeNumber(pixnNode, L"AttachedIndex", &pContainer->dwAttachedIndex);
62 if (E_NOTFOUND != hr || pContainer->fAttached) // if it is an attached container it must have an index
63 {
64 ExitOnFailure(hr, "Failed to get @AttachedIndex.");
65 }
66 57
67 // Attached containers are always found attached to the current process, so use the current proccess's 58 // Attached containers are always found attached to the current process, so use the current proccess's
68 // name instead of what may be in the manifest. 59 // name instead of what may be in the manifest.
69 if (pContainer->fAttached) 60 if (pContainer->fAttached)
70 { 61 {
62 // @AttachedIndex
63 hr = XmlGetAttributeNumber(pixnNode, L"AttachedIndex", &pContainer->dwAttachedIndex);
64 ExitOnRequiredXmlQueryFailure(hr, "Failed to get @AttachedIndex.");
65
71 hr = PathForCurrentProcess(&scz, NULL); 66 hr = PathForCurrentProcess(&scz, NULL);
72 ExitOnFailure(hr, "Failed to get path to current process for attached container."); 67 ExitOnFailure(hr, "Failed to get path to current process for attached container.");
73 68
@@ -80,7 +75,7 @@ extern "C" HRESULT ContainersParseFromXml(
80 { 75 {
81 // @FilePath 76 // @FilePath
82 hr = XmlGetAttributeEx(pixnNode, L"FilePath", &pContainer->sczFilePath); 77 hr = XmlGetAttributeEx(pixnNode, L"FilePath", &pContainer->sczFilePath);
83 ExitOnFailure(hr, "Failed to get @FilePath."); 78 ExitOnRequiredXmlQueryFailure(hr, "Failed to get @FilePath.");
84 } 79 }
85 80
86 // The source path starts as the file path. 81 // The source path starts as the file path.
@@ -89,28 +84,25 @@ extern "C" HRESULT ContainersParseFromXml(
89 84
90 // @DownloadUrl 85 // @DownloadUrl
91 hr = XmlGetAttributeEx(pixnNode, L"DownloadUrl", &pContainer->downloadSource.sczUrl); 86 hr = XmlGetAttributeEx(pixnNode, L"DownloadUrl", &pContainer->downloadSource.sczUrl);
92 if (E_NOTFOUND != hr) 87 ExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to get @DownloadUrl.");
93 {
94 ExitOnFailure(hr, "Failed to get @DownloadUrl.");
95 }
96 88
97 // @Hash 89 // @Hash
98 hr = XmlGetAttributeEx(pixnNode, L"Hash", &pContainer->sczHash); 90 hr = XmlGetAttributeEx(pixnNode, L"Hash", &pContainer->sczHash);
99 ExitOnFailure(hr, "Failed to get @Hash."); 91 ExitOnRequiredXmlQueryFailure(hr, "Failed to get @Hash.");
100 92
101 hr = StrAllocHexDecode(pContainer->sczHash, &pContainer->pbHash, &pContainer->cbHash); 93 hr = StrAllocHexDecode(pContainer->sczHash, &pContainer->pbHash, &pContainer->cbHash);
102 ExitOnFailure(hr, "Failed to hex decode the Container/@Hash."); 94 ExitOnFailure(hr, "Failed to hex decode the Container/@Hash.");
103 95
104 // @FileSize 96 // @FileSize
105 hr = XmlGetAttributeEx(pixnNode, L"FileSize", &scz); 97 hr = XmlGetAttributeEx(pixnNode, L"FileSize", &scz);
106 ExitOnFailure(hr, "Failed to get @FileSize."); 98 ExitOnRequiredXmlQueryFailure(hr, "Failed to get @FileSize.");
107 99
108 hr = StrStringToUInt64(scz, 0, &pContainer->qwFileSize); 100 hr = StrStringToUInt64(scz, 0, &pContainer->qwFileSize);
109 ExitOnFailure(hr, "Failed to parse @FileSize."); 101 ExitOnFailure(hr, "Failed to parse @FileSize.");
110 102
111 if (!pContainer->qwFileSize) 103 if (!pContainer->qwFileSize)
112 { 104 {
113 ExitOnRootFailure(hr = E_INVALIDDATA, "File size is required when verifying by hash for container: %ls", pContainer->sczId); 105 ExitWithRootFailure(hr, E_INVALIDDATA, "File size is required when verifying by hash for container: %ls", pContainer->sczId);
114 } 106 }
115 107
116 pContainer->verification = BURN_CONTAINER_VERIFICATION_HASH; 108 pContainer->verification = BURN_CONTAINER_VERIFICATION_HASH;