Alex Nelson
2011-Dec-13 05:59 UTC
[Libguestfs] [hivex] [PATCH 2/2] hivex: Expose embedded hive file name
Signed-off-by: Alex Nelson <ajnelson at cs.ucsc.edu>
---
generator/generator.ml | 6 ++++++
lib/hivex.c | 6 ++++++
xml/hivexml.c | 9 +++++++++
3 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/generator/generator.ml b/generator/generator.ml
index fc7b483..9e53f4e 100755
--- a/generator/generator.ml
+++ b/generator/generator.ml
@@ -159,6 +159,12 @@ but instead are lost. See L<hivex(3)/WRITING TO HIVE
FILES>.";
"\
Return root node of the hive. All valid hives must contain a root node.";
+ "name", (RString, [AHive]),
+ "return the name stored in the hive header",
+ "\
+Return hive file name stored in the hive header, null on error. Caller
+is responsible for freeing returned string.";
+
"major_version", (RInt32, [AHive]),
"return the major version of the hive",
"\
diff --git a/lib/hivex.c b/lib/hivex.c
index 455202f..11468f9 100644
--- a/lib/hivex.c
+++ b/lib/hivex.c
@@ -634,6 +634,12 @@ hivex_last_modified (hive_h *h)
return timestamp_check (h, 0, h->last_modified);
}
+char *
+hivex_name (hive_h *h)
+{
+ return (h && h->hdr) ? windows_utf16_to_utf8 (h->hdr->name,
64) : NULL;
+}
+
int32_t
hivex_major_version (hive_h *h)
{
diff --git a/xml/hivexml.c b/xml/hivexml.c
index 3a4d9b7..059da56 100644
--- a/xml/hivexml.c
+++ b/xml/hivexml.c
@@ -160,6 +160,15 @@ main (int argc, char *argv[])
}
}
+ char *hive_name = hivex_name (h);
+ if (hive_name) {
+ XML_CHECK (xmlTextWriterStartAttribute, (writer, BAD_CAST
"name"));
+ XML_CHECK (xmlTextWriterWriteString, (writer, BAD_CAST hive_name));
+ XML_CHECK (xmlTextWriterEndAttribute, (writer));
+ free (hive_name);
+ hive_name = NULL;
+ }
+
int64_t hive_mtime = hivex_last_modified (h);
if (hive_mtime >= 0) {
char *timebuf = filetime_to_8601 (hive_mtime);
--
1.7.6.4
Richard W.M. Jones
2012-Jan-05 14:02 UTC
[Libguestfs] [hivex] [PATCH 2/2] hivex: Expose embedded hive file name
On Mon, Dec 12, 2011 at 09:59:20PM -0800, Alex Nelson wrote:> Signed-off-by: Alex Nelson <ajnelson at cs.ucsc.edu> > --- > generator/generator.ml | 6 ++++++ > lib/hivex.c | 6 ++++++ > xml/hivexml.c | 9 +++++++++ > 3 files changed, 21 insertions(+), 0 deletions(-) > > diff --git a/generator/generator.ml b/generator/generator.ml > index fc7b483..9e53f4e 100755 > --- a/generator/generator.ml > +++ b/generator/generator.ml > @@ -159,6 +159,12 @@ but instead are lost. See L<hivex(3)/WRITING TO HIVE FILES>."; > "\ > Return root node of the hive. All valid hives must contain a root node."; > > + "name", (RString, [AHive]), > + "return the name stored in the hive header",I thought that calling hivex_node_name (h, hivex_root (h)) would return this string already? Or is it a different string we're talking about here?> + "\ > +Return hive file name stored in the hive header, null on error. Caller > +is responsible for freeing returned string.";You don't need to print the stuff about errors and freeing the string. The generator does it for you.> +char * > +hivex_name (hive_h *h) > +{ > + return (h && h->hdr) ? windows_utf16_to_utf8 (h->hdr->name, 64) : NULL; > +}This probably needs to be setting errno ... 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
Apparently Analagous Threads
- [hivex] [PATCH 1/2] hivex: Expose hive major and minor version
- [Hivex] [PATCH v3] Report last-modified time of hive root and nodes
- [PATCH] hivex: Add byte runs for nodes and values
- [Hivex][PATCH v2] Report last-modified time of hive root and nodes
- [PATCH] Report last-modified time of hive root and nodes