module Hivex
Public Class Methods
open a hive file
Opens the hive named “filename” for reading.
Flags is an ORed list of the open flags (or 0 if you don't want to pass any flags). These flags are defined:
HIVEX_OPEN_VERBOSE Verbose messages.
HIVEX_OPEN_DEBUG Very verbose messages, suitable for debugging problems in the library itself.
This is also selected if the “HIVEX_DEBUG” environment variable is set to 1.
HIVEX_OPEN_WRITE Open the hive for writing. If omitted, the hive is read-only.
See “WRITING TO HIVE FILES” in hivex(3).
HIVEX_OPEN_UNSAFE Open the hive in unsafe mode that enables heuristics to handle corrupted hives.
This may allow to read or write registry keys/values that appear intact in an otherwise corrupted hive. Use at your own risk.
(For the C API documentation for this function, see hivex_open
[http://libguestfs.org/hivex.3.html#hivex_open]).
static VALUE ruby_hivex_open (VALUE modulev, VALUE filenamev, VALUE flagsv) { const char *filename = StringValueCStr (filenamev); int flags = 0; if (RTEST (rb_hash_lookup (flagsv, ID2SYM (rb_intern ("verbose"))))) flags += 1; if (RTEST (rb_hash_lookup (flagsv, ID2SYM (rb_intern ("debug"))))) flags += 2; if (RTEST (rb_hash_lookup (flagsv, ID2SYM (rb_intern ("write"))))) flags += 4; if (RTEST (rb_hash_lookup (flagsv, ID2SYM (rb_intern ("unsafe"))))) flags += 8; hive_h *r; r = hivex_open (filename, flags); if (r == NULL) rb_raise (e_Error, "%s", strerror (errno)); return Data_Wrap_Struct (c_hivex, NULL, ruby_hivex_free, r); }