summaryrefslogtreecommitdiffstats
path: root/images
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2010-02-24 17:30:37 +0000
committerRichard Jones <rjones@redhat.com>2010-02-24 18:26:00 +0000
commitaef7470a0492d3fea1a00ef2de8381417fb23b83 (patch)
tree64d3b5b25c78b9e1e8eeefc7dd472700652730df /images
parentc5e92b725ba8c029df2d407aa27bdebc56ed717e (diff)
downloadhivex-aef7470a0492d3fea1a00ef2de8381417fb23b83.tar.gz
hivex-aef7470a0492d3fea1a00ef2de8381417fb23b83.tar.xz
hivex-aef7470a0492d3fea1a00ef2de8381417fb23b83.zip
Move test images to images/ and add a large, generated test image.
Previously we had one minimal test image. This was located in hivex/t (a subdirectory of the main library). This adds a large, procedurally generated test image. Because this needs to be built using hivex code, and because subdirectories are built before the parent directory by automake, we have to also move the directory location to a top-level directory called images/.
Diffstat (limited to 'images')
-rw-r--r--images/Makefile.am33
-rw-r--r--images/README13
-rwxr-xr-ximages/minimalbin0 -> 8192 bytes
-rw-r--r--images/mklarge.c103
4 files changed, 149 insertions, 0 deletions
diff --git a/images/Makefile.am b/images/Makefile.am
new file mode 100644
index 0000000..9a32c87
--- /dev/null
+++ b/images/Makefile.am
@@ -0,0 +1,33 @@
+# hivex
+# Copyright (C) 2009-2010 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+EXTRA_DIST = minimal
+
+# 'large' is a large hive used for testing purposes. It is generated
+# by the mklarge C program, to avoid having to distribute this large
+# binary blob.
+noinst_PROGRAMS = mklarge
+mklarge_SOURCES = mklarge.c
+mklarge_CFLAGS = \
+ -I$(srcdir)/../hivex \
+ $(WARN_CFLAGS) $(WERROR_CFLAGS)
+mklarge_LDADD = ../hivex/libhivex.la
+
+noinst_DATA = large
+
+large: mklarge
+ ./mklarge $(srcdir)/minimal large
diff --git a/images/README b/images/README
new file mode 100644
index 0000000..2131885
--- /dev/null
+++ b/images/README
@@ -0,0 +1,13 @@
+This directory contains test images for the hivex library.
+
+'minimal' is a valid registry containing a single root nk (with
+associated sk) which was created by chopping out everything possible
+from a Windows 2003 software hive and then doing lots of hand edits on
+the result. There is no "source" for it as such, it is just a
+hand-crafted binary blob.
+
+'large' is a procedurally generated, large hive. The program
+'mklarge.c' is used to make this during the build. It is used during
+tests.
+
+- Richard W.M. Jones 2010-02-24.
diff --git a/images/minimal b/images/minimal
new file mode 100755
index 0000000..3f4ee58
--- /dev/null
+++ b/images/minimal
Binary files differ
diff --git a/images/mklarge.c b/images/mklarge.c
new file mode 100644
index 0000000..c818df8
--- /dev/null
+++ b/images/mklarge.c
@@ -0,0 +1,103 @@
+/* mklarge - Make a large hive for testing purposes.
+ * Copyright (C) 2010 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <hivex.h>
+
+static int degrees[] = { 3, 1, 4, 1, 5, 9, 2 }; /* ~1000 nodes */
+static const int nr_degrees = sizeof degrees / sizeof degrees[0];
+static const char *strings[][10] = {
+ { "The", "A", "Another" }, /* level 0 */
+ { "giant" },
+ { "mongoose", "goat", "zebra", "elephant" },
+ { "was" },
+ { "found in", "seen in", "spotted over", "sent to", "fired at" },
+ { "Paris", "London", "Rome", "Oslo", "Madrid", "Nicosia", "Amsterdam",
+ "Moscow", "Riga" },
+ { "today", "yesterday" } /* level 6 */
+};
+static hive_set_value values[] = {
+ /* char* casts are needed to work around a stupidity of C */
+ { (char *) "A", hive_t_REG_SZ, 4, (char *) "a\0\0\0" },
+ { (char *) "B", hive_t_REG_DWORD, 4, (char *) "\x78\x56\x34\x12" },
+ { (char *) "C", hive_t_REG_EXPAND_SZ, 6, (char *) "c\0c\0\0\0" },
+ { (char *) "D", hive_t_REG_SZ, 8, (char *) "d\0d\0d\0\0\0" },
+ { (char *) "E", hive_t_REG_QWORD, 8, (char *) "\xf0\xde\xbc\x9a\x78\x56\x34\x12" },
+ { (char *) "F", hive_t_REG_SZ, 4, (char *) "f\0\0\0" },
+ { (char *) "G", hive_t_REG_EXPAND_SZ, 4, (char *) "g\0\0\0" }
+};
+
+static void
+iter (hive_h *h, int depth, int posn, hive_node_h parent, char *name)
+{
+ if (depth < nr_degrees) {
+ int degree = degrees[depth];
+ int i, len;
+ hive_node_h node;
+
+ len = strlen (name);
+ if (len > 0) name[len++] = ' ';
+
+ for (i = 0; i < degree; ++i) {
+ strcpy (&name[len], strings[depth][i]);
+ node = hivex_node_add_child (h, parent, name);
+ if (node == 0) {
+ perror ("mklarge: hivex_node_add_child");
+ exit (1);
+ }
+ iter (h, depth+1, i, node, name);
+ }
+
+ if (hivex_node_set_values (h, parent, depth, values, 0) == -1) {
+ perror ("mklarge: hivex_node_set_values");
+ exit (1);
+ }
+ }
+}
+
+int
+main (int argc, char *argv[])
+{
+ hive_h *h;
+ char name[4096] = { '\0' };
+
+ h = hivex_open (argv[1], HIVEX_OPEN_WRITE);
+ if (h == NULL) {
+ perror (argv[1]);
+ exit (1);
+ }
+
+ iter (h, 0, 0, hivex_root (h), name);
+
+ if (hivex_commit (h, argv[2], 0) == -1) {
+ perror (argv[2]);
+ exit (1);
+ }
+
+ if (hivex_close (h) == -1) {
+ perror ("mklarge: close");
+ exit (1);
+ }
+
+ exit (0);
+}