diff options
Diffstat (limited to '')
-rw-r--r-- | CPP/7zip/Archive/VhdxHandler.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/CPP/7zip/Archive/VhdxHandler.cpp b/CPP/7zip/Archive/VhdxHandler.cpp index e1e4692..0fc83ac 100644 --- a/CPP/7zip/Archive/VhdxHandler.cpp +++ b/CPP/7zip/Archive/VhdxHandler.cpp | |||
@@ -171,6 +171,20 @@ struct CHeader | |||
171 | UInt64 LogOffset; | 171 | UInt64 LogOffset; |
172 | CGuid Guids[3]; | 172 | CGuid Guids[3]; |
173 | 173 | ||
174 | bool IsEqualTo(const CHeader &h) const | ||
175 | { | ||
176 | if (SequenceNumber != h.SequenceNumber) | ||
177 | return false; | ||
178 | if (LogLength != h.LogLength) | ||
179 | return false; | ||
180 | if (LogOffset != h.LogOffset) | ||
181 | return false; | ||
182 | for (unsigned i = 0; i < 3; i++) | ||
183 | if (!Guids[i].IsEqualTo(h.Guids[i])) | ||
184 | return false; | ||
185 | return true; | ||
186 | }; | ||
187 | |||
174 | bool Parse(Byte *p); | 188 | bool Parse(Byte *p); |
175 | }; | 189 | }; |
176 | 190 | ||
@@ -1174,7 +1188,18 @@ HRESULT CHandler::Open3() | |||
1174 | unsigned mainIndex; | 1188 | unsigned mainIndex; |
1175 | if (headers[0].SequenceNumber > headers[1].SequenceNumber) mainIndex = 0; | 1189 | if (headers[0].SequenceNumber > headers[1].SequenceNumber) mainIndex = 0; |
1176 | else if (headers[0].SequenceNumber < headers[1].SequenceNumber) mainIndex = 1; | 1190 | else if (headers[0].SequenceNumber < headers[1].SequenceNumber) mainIndex = 1; |
1177 | else return S_FALSE; | 1191 | else |
1192 | { | ||
1193 | /* Disk2vhd v2.02 can create image with 2 full copies of headers. | ||
1194 | It's violation of VHDX specification: | ||
1195 | "A header is current if it is the only valid header | ||
1196 | or if it is valid and its SequenceNumber field is | ||
1197 | greater than the other header's SequenceNumber". | ||
1198 | but we support such Disk2vhd archives. */ | ||
1199 | if (!headers[0].IsEqualTo(headers[1])) | ||
1200 | return S_FALSE; | ||
1201 | mainIndex = 0; | ||
1202 | } | ||
1178 | 1203 | ||
1179 | const CHeader &h = headers[mainIndex]; | 1204 | const CHeader &h = headers[mainIndex]; |
1180 | Header = h; | 1205 | Header = h; |
@@ -1567,6 +1592,7 @@ static void AddComment_BlockSize(UString &s, const char *name, unsigned logSize) | |||
1567 | 1592 | ||
1568 | void CHandler::AddComment(UString &s) const | 1593 | void CHandler::AddComment(UString &s) const |
1569 | { | 1594 | { |
1595 | AddComment_UInt64(s, "VirtualDiskSize", Meta.VirtualDiskSize); | ||
1570 | AddComment_UInt64(s, "PhysicalSize", _phySize); | 1596 | AddComment_UInt64(s, "PhysicalSize", _phySize); |
1571 | 1597 | ||
1572 | if (!_errorMessage.IsEmpty()) | 1598 | if (!_errorMessage.IsEmpty()) |