--- lib/hivex.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/lib/hivex.c b/lib/hivex.c index 13d7556..8a774de 100644 --- a/lib/hivex.c +++ b/lib/hivex.c @@ -543,6 +543,9 @@ hivex_close (hive_h *h) free (h->filename); free (h); + if (h->msglvl >= 1) + fprintf (stderr, "hivex_close\n"); + return r; } -- 1.7.2.1
Richard W.M. Jones
2010-Aug-13 16:45 UTC
[Libguestfs] [PATCH] Add debug output to hivex_close
On Fri, Aug 13, 2010 at 05:26:58PM +0100, Matthew Booth wrote:> --- > lib/hivex.c | 3 +++ > 1 files changed, 3 insertions(+), 0 deletions(-) > > diff --git a/lib/hivex.c b/lib/hivex.c > index 13d7556..8a774de 100644 > --- a/lib/hivex.c > +++ b/lib/hivex.c > @@ -543,6 +543,9 @@ hivex_close (hive_h *h) > free (h->filename); > free (h); > > + if (h->msglvl >= 1) > + fprintf (stderr, "hivex_close\n"); > + > return r; > }Thanks, ACKed and applied upstream. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 80 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora
Richard W.M. Jones
2010-Aug-13 16:51 UTC
[Libguestfs] Problem with hivex_commit (was: Re: [PATCH] Add debug output to hivex_close)
17:00 < mdbooth> $h->node_set_values($node, \@new); 17:00 < mdbooth> print Dumper (\@new); I don't think you posted the output of this statement. 17:00 < mdbooth> foreach ($h->node_values($node)) { 17:00 < mdbooth> my $key = $h->value_key($_); 17:00 < mdbooth> my (undef, $value) = $h->value_value($_); 17:01 < mdbooth> print STDERR "$key: $value\n" 17:01 < mdbooth> } 17:01 < mdbooth> $h->commit(undef); 17:01 < mdbooth> undef $node; 17:01 < mdbooth> undef $h; 17:01 < mdbooth> # Upload the new registry. 17:01 < mdbooth> $g->upload($sw_local, $sw_guest); Merely doing $h->commit (undef) should be sufficient. The rest is just gravy. Did you open the file with the correct flags? $h = Win::Hivex->open ($filename, write => 1); I believe that commit is supposed to give an error if the handle wasn't opened with this flag, but possibly that might be broken. Anyway, it is totally possible to write to hivex from Perl, because all the tools like hivexregedit and virt-win-reg are written in Perl. There must be some other problem such as downloading or uploading an incorrect file. 17:02 < mdbooth> I've also tried putting everything from the definition of $h to the commit in its own code block 17:02 < mdbooth> And copying the file outside the code block 17:02 < mdbooth> That should hopefully clear any possibility of dangling references to $h 17:03 * mdbooth notes that there is no explicit close... 17:16 < mdbooth> Hmm, hivex_close doesn't have any debug output either 17:24 < mdbooth> Ok, added debug output to hivex_close. It's definitely being called 17:27 < mdbooth> So, node_set_values() is being called with the correct data 17:27 < mdbooth> commit() is being called You don't need to call close. Just calling commit is sufficient to save the file to disk. 17:27 < mdbooth> and the handle is closed 17:28 < mdbooth> But the result is incorrect 17:28 < mdbooth> I give up on this one for today Can you summarise a bit more what is happening and/or send me the code? Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 80 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora