Skippy VonDrake
2012-Dec-03 20:35 UTC
[Libguestfs] sample code for guestfs_hivex_node_set_value
Is there any sample code available to demonstrate the use of the guestfs_hivex_node_set_value API? I have no problem traversing and reading keys using libguestfs hivex wrappers - but continue to fail on any write attempts. The return is always -1 and errno is unchanged. I've set the environment variable HIVEX_DEBUG to 1 on a chance that this may help - but it doesn't. The only sample I can find in the sources that use hivex is the "virt-dhcp-address.c" sample. But it does not write to the registry.
Richard W.M. Jones
2012-Dec-03 22:29 UTC
[Libguestfs] sample code for guestfs_hivex_node_set_value
On Mon, Dec 03, 2012 at 03:35:49PM -0500, Skippy VonDrake wrote:> Is there any sample code available to demonstrate the use of the > guestfs_hivex_node_set_value API?I don't think any real code uses this API. They all use the more useful hivex_node_set_values instead (which is not bound yet via the libguestfs API -- a missing feature). However there is some test code: https://github.com/libguestfs/hivex/blob/master/perl/t/210-setvalue.t> I have no problem traversing and reading keys using libguestfs hivex > wrappers - but continue to fail on any write attempts. > The return is always -1 and errno is unchanged.It's entirely possible that the libguestfs bindings are buggy. See: https://github.com/libguestfs/libguestfs/blob/master/daemon/hivex.c#L383> I've set the environment variable HIVEX_DEBUG to 1 on a chance that > this may help - but it doesn't.No, unfortunately this environment variable is not passed through to the daemon. You could try doing: guestfs_h *g = guestfs_create (); guestfs_set_verbose (g, 1); // ... guestfs_launch (g); // ... char *env[] = { "HIVEX_DEBUG", 1 }; guestfs_debug (g, "setenv", env); all before calling guestfs_hivex_open.> The only sample I can find in the sources that use hivex is the > "virt-dhcp-address.c" sample. > But it does not write to the registry.Probably best to look at perl code in hivex for some ideas, eg: https://github.com/libguestfs/hivex/blob/master/perl/lib/Win/Hivex/Regedit.pm Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v
Richard W.M. Jones
2012-Dec-04 17:01 UTC
[Libguestfs] sample code for guestfs_hivex_node_set_value
On Mon, Dec 03, 2012 at 03:35:49PM -0500, Skippy VonDrake wrote:> Is there any sample code available to demonstrate the use of the > guestfs_hivex_node_set_value API? > > I have no problem traversing and reading keys using libguestfs hivex > wrappers - but continue to fail on any write attempts. > The return is always -1 and errno is unchanged. > > I've set the environment variable HIVEX_DEBUG to 1 on a chance that > this may help - but it doesn't. > The only sample I can find in the sources that use hivex is the > "virt-dhcp-address.c" sample. > But it does not write to the registry.Just to close this issue for other readers, the problem was not supplying the 'write' flag when calling guestfs_hivex_open. If you don't supply this flag, then writes will fail with guestfs_last_errno(g) => EROFS. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v
Apparently Analagous Threads
- inspect_os error with Win7 image
- [Qemu-devel] debugging qemu-nbd.c
- libguestfs-test-tool error, libcap.so - no such file
- Re: does guestfs_list_partitions() work with Windows 95 images?
- [PATCH 0/6] Update the way that API versions are generated for the man page.