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.
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.p... 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
On Mon, Dec 03, 2012 at 10:29:52PM +0000, Richard W.M. Jones wrote:
On Mon, Dec 03, 2012 at 03:35:49PM -0500, Skippy VonDrake wrote:
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:
Or even easier: guestfs_hivex_open (g, filename, GUESTFS_HIVEX_OPEN_VERBOSE, 1, GUESTFS_HIVEX_OPEN_DEBUG, 1, -1); However you will still need to enable libguestfs debugging (guestfs_set_verbose (g, 1)) in order to see any output from hivex, since it's all running inside the appliance. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
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
participants (2)
-
Richard W.M. Jones -
Skippy VonDrake