[Libguestfs] Problem with hivex_commit

Matthew Booth mbooth at redhat.com
Mon Aug 16 08:44:32 UTC 2010


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




More information about the Libguestfs mailing list