Feb 6, 2013 at 8:49 PM
Edited Feb 7, 2013 at 7:17 PM
I'm receiving an exception when initializing vhds that I created.
The exception being thrown is an "Index out of bounds" in the following line of DynamicStream.cs.
bool readFromParent = (_blockBitmaps[block][sectorInBlock / 8] & mask) == 0;
The code I am using that produces this error is:
using (var f = new FileStream("filename.vhd", FileMode.Create, FileAccess.ReadWrite, FileShare.None))
using ( var d = DiscUtils.Vhd.Disk.InitializeDynamic( f, Ownership.None, ( 4 * 1024 * 1024 * 1024), 2048))
DiscUtils.Partitions.BiosPartitionTable.Initialize( d ); // dies performing this line
In trying to hunt down the issue, I noticed that the DynamicStream constructor sets
in what looks to me like a very odd manner.
The line in question presently looks like this:
_blockBirmapSize = (int)Utilities.RoundUp((_dynamicHeader.BlockSize / Utilities.SectorSize) / 8, Utilities. SectorSize);
The sector size of the disk files I've been generating is always 512 bytes, so it looks to me that unless the block size of the vhd is set to at least 4096 (512 * 8), the first parameter to
will always be 0.
If this is the desired behaviour, any ideas where else I might be going wrong?
Edit: For reference, I am using code current as of commit 14fd51607559.