RegistryHive and Key and setValue => Exception: "Attemp to free non-allocated cell"

Jan 21, 2010 at 11:15 AM
Edited Jan 21, 2010 at 11:23 AM


I use the following Code to manipulate the registry in a vhd. But when I call the setValue Method there is always an exception: "Attemp to free non-allocated cell".
I've no idea, what I'm doing wrong. Can someone please give me a hint?

It happens in Bin.cs in the FreeCell, and the function Utilities.ToInt32LittleEndian(_buffer, freeIndex) returns 0. Why? :(


Ciao Ephraim



using (VirtualDisk d = VirtualDisk.OpenDisk(@"d:\drive.vhd", FileAccess.ReadWrite))
VolumeManager vm = new VolumeManager(d);
LogicalVolumeInfo[] lvi = vm.GetLogicalVolumes();
if (lvi.Length > 0)
DiscFileSystem fs = new DiscUtils.Ntfs.NtfsFileSystem(lvi[0].Open());

using (Stream s = fs.OpenFile(@"Windows\system32\config\system", FileMode.Open, FileAccess.ReadWrite)) { RegistryHive reg = new RegistryHive(s); RegistryKey k; RegistryKey sub = null; k = reg.Root.OpenSubKey(@"ControlSet001\Services"); try { sub = k.OpenSubKey("LSI_SCSI"); } finally { if (sub == null) { sub = k.CreateSubKey("LSI_SCSI"); } } sub.SetValue("Start", 1, RegistryValueType.Dword); } } }


Jan 21, 2010 at 1:01 PM

Happens with the latest changeset too ... (changeset: 38749)

Ciao Ephraim

Jan 21, 2010 at 11:30 PM

Hi Ephraim,

This is almost certainly a bug in DiscUtils registry handling - I'll create a new issue.  Can you post the registry file please.



Jan 21, 2010 at 11:33 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.