简体   繁体   English

虚拟硬盘映像格式规范中的错误?

[英]Mistake in Virtual Hard Disk Image Format Specification?

I want to calculate the end offset of a parent locator in a VHD. 我想计算VHD中父定位器的结束偏移量。 Here is a part of the VHD header: 以下是VHD标头的一部分:

Cookie: cxsparse
Data offset: 0xffffffffffffffff
Table offset: 0x2000
Header version: 0x00010000
Max table entries: 10240
Block size: 0x200000
Checksum: 4294956454
Parent Unique Id: 0x9678bf077e719640b55e40826ce5d178
Parent time stamp: 525527478
Reserved: 0
Parent Unicode name:
Parent locator 1:
- platform code: 0x57326b75
- platform_data_space: 4096
- platform_data_length: 86
- reserved: 0
- platform_data_offset: 0x1000
Parent locator 2:
- platform code: 0x57327275
- platform_data_space: 65536
- platform_data_length: 34
- reserved: 0
- platform_data_offset: 0xc000

Some definitions from the Virtual Hard Disk Image Format Specification : 虚拟硬盘映像格式规范中的一些定义:

"Table Offset: This field stores the absolute byte offset of the Block Allocation Table (BAT) in the file. Platform Data Space: This field stores the number of 512-byte sectors needed to store the parent hard disk locator. Platform Data Offset: This field stores the absolute file offset in bytes where the platform specific file locator data is stored. Platform Data Length. This field stores the actual length of the parent hard disk locator in bytes." “表偏移:此字段存储文件中块分配表(BAT)的绝对字节偏移量。平台数据空间:此字段存储存储父硬盘定位器所需的512字节扇区数。平台数据偏移量:此字段存储存储平台特定文件定位器数据的绝对文件偏移量(以字节为单位)。平台数据长度。此字段以字节为单位存储父硬盘定位器的实际长度。

Based on this the end offset of the two parent locators should be: data offset + 512 * data space: 基于此,两个父定位器的结束偏移量应为:数据偏移量+ 512 *数据空间:

0x1000 + 512 * 4096 = 0x201000
0xc000 + 512 * 65536 = 0x200c000

But if one uses only data offset + data space: 但如果只使用数据偏移+数据空间:

0x1000 + 4096 = 0x2000 //end of parent locator 1, begin of BAT
0xc000 + 65536 = 0x1c000

This latter calculation makes much more sense: the end of the first parent locator is the beginning of the BAT (see header data above); 后一种计算更有意义:第一个父定位符的结尾是BAT的开头(参见上面的标题数据); and since the first BAT entry is 0xe7 (sector offset), this corresponds to file offset 0x1ce00 (sector offset * 512), which is OK, if the second parent locator ends at 0x1c000. 并且由于第一个BAT条目是0xe7(扇区偏移),这对应于文件偏移量0x1ce00(扇区偏移* 512),如果第二个父定位符在0x1c000结束,则表示正常。

But if one uses the formula data offset + 512 * data space, he ends up having other data written in the parent locator. 但是如果使用公式数据偏移+ 512 *数据空间,他最终会在父定位器中写入其他数据。 (But, in this example there would be no data corruption, since Platform Data Length is very small) (但是,在这个例子中,没有数据损坏,因为平台数据长度非常小)

So is this a mistake in the specification, and the sentence 那么这是规范中的错误和句子

"Platform Data Space: This field stores the number of 512-byte sectors needed to store the parent hard disk locator." “平台数据空间:此字段存储存储父硬盘定位器所需的512字节扇区数。”

should be 应该

"Platform Data Space: This field stores the number of bytes needed to store the parent hard disk locator."? “平台数据空间:此字段存储存储父硬盘定位器所需的字节数。”?

Apparently Microsoft does not care about correcting their mistake, this being already discovered by Virtualbox developers. 显然,微软并不关心纠正他们的错误,这已经被Virtualbox开发者发现了。 VHD.cpp contains the following comment: VHD.cpp包含以下注释:

/*
 * The VHD spec states that the DataSpace field holds the number of sectors
 * required to store the parent locator path.
 * As it turned out VPC and Hyper-V store the amount of bytes reserved for the
 * path and not the number of sectors.
 */

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM