[Libguestfs] sample code for guestfs_hivex_node_set_value

Richard W.M. Jones rjones at redhat.com
Mon Dec 3 22:29:52 UTC 2012


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




More information about the Libguestfs mailing list