[PATCH] Add debug output to hivex_close
--- 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
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
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
On 13/08/10 17:51, Richard W.M. Jones wrote:
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?
I've pushed the code and a hive it's not working against to: http://people.redhat.com/mbooth/tmp/hivex-test.tar.xz I've also tested it against a hive from win2k3, and it's not working there either. I'd be very glad to find an error in my code rather than hivex :) Matt -- Matthew Booth, RHCA, RHCSS Red Hat Engineering, Virtualisation Team GPG ID: D33C3490 GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490
participants (2)
-
Matthew Booth -
Richard W.M. Jones