Blame SOURCES/0117-v2v-Add-support-for-REG_MULTI_SZ-multiple-strings-to.patch

ffd6ed
From f66959c79ab2d0ed26d9012024ac0ee4068b2aab Mon Sep 17 00:00:00 2001
ffd6ed
From: "Richard W.M. Jones" <rjones@redhat.com>
ffd6ed
Date: Tue, 7 Apr 2015 16:58:40 +0100
ffd6ed
Subject: [PATCH] v2v: Add support for REG_MULTI_SZ (multiple strings) to
ffd6ed
 registry editor.
ffd6ed
ffd6ed
(cherry picked from commit 4fd70eab4ff7d9a8e49db2938a80dcef45db150c)
ffd6ed
---
ffd6ed
 mllib/regedit.ml  | 8 ++++++++
ffd6ed
 mllib/regedit.mli | 1 +
ffd6ed
 2 files changed, 9 insertions(+)
ffd6ed
ffd6ed
diff --git a/mllib/regedit.ml b/mllib/regedit.ml
ffd6ed
index 673b215..0291fe4 100644
ffd6ed
--- a/mllib/regedit.ml
ffd6ed
+++ b/mllib/regedit.ml
ffd6ed
@@ -30,6 +30,7 @@ and regtype =
ffd6ed
 | REG_EXPAND_SZ of string
ffd6ed
 | REG_BINARY of string
ffd6ed
 | REG_DWORD of int32
ffd6ed
+| REG_MULTI_SZ of string list
ffd6ed
 
ffd6ed
 (* Take a 7 bit ASCII string and encode it as UTF16LE. *)
ffd6ed
 let encode_utf16le str =
ffd6ed
@@ -97,5 +98,12 @@ and import_value g node = function
ffd6ed
     g#hivex_node_set_value node key 3L bin
ffd6ed
   | key, REG_DWORD dw ->
ffd6ed
     g#hivex_node_set_value node key 4L (le32_of_int (Int64.of_int32 dw))
ffd6ed
+  | key, REG_MULTI_SZ ss ->
ffd6ed
+    (* http://blogs.msdn.com/oldnewthing/archive/2009/10/08/9904646.aspx *)
ffd6ed
+    List.iter (fun s -> assert (s <> "")) ss;
ffd6ed
+    let ss = ss @ [""] in
ffd6ed
+    let ss = List.map (fun s -> encode_utf16le s ^ "\000\000") ss in
ffd6ed
+    let ss = String.concat "" ss in
ffd6ed
+    g#hivex_node_set_value node key 7L ss
ffd6ed
 
ffd6ed
 let reg_import g root = List.iter (import_key g root)
ffd6ed
diff --git a/mllib/regedit.mli b/mllib/regedit.mli
ffd6ed
index 1f43cdd..985e405 100644
ffd6ed
--- a/mllib/regedit.mli
ffd6ed
+++ b/mllib/regedit.mli
ffd6ed
@@ -47,6 +47,7 @@ and regtype =
ffd6ed
 | REG_EXPAND_SZ of string               (** String with %env% *)
ffd6ed
 | REG_BINARY of string                  (** Blob of binary data *)
ffd6ed
 | REG_DWORD of int32                    (** Little endian 32 bit integer *)
ffd6ed
+| REG_MULTI_SZ of string list           (** List of strings *)
ffd6ed
 (* There are more types in the Registry, but we don't support them here... *)
ffd6ed
 (** Registry value type and data.
ffd6ed
 
ffd6ed
-- 
ffd6ed
1.8.3.1
ffd6ed