[PATCH 4/4] [Kernel32]: add ability to load additional terminfo data from Wine registry

Eric Pouech eric.pouech at orange.fr
Tue Jan 18 15:02:44 CST 2011




A+
---

 dlls/kernel32/term.c |   74 +++++++++++++++++++++++++++++++++++++++++++++++++-
 tools/wine.inf.in    |    3 ++
 2 files changed, 76 insertions(+), 1 deletions(-)


diff --git a/dlls/kernel32/term.c b/dlls/kernel32/term.c
index 8111f0b..f4c29b9 100644
--- a/dlls/kernel32/term.c
+++ b/dlls/kernel32/term.c
@@ -39,6 +39,7 @@
 #include "console_private.h"
 #include "wine/library.h"
 #include "wine/debug.h"
+#include "winternl.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(console);
 
@@ -308,12 +309,83 @@ static BOOL TERM_AddKeyDescr(const char* string, struct dbkey_descr* descr)
 
 static BOOL TERM_BuildKeyDB(void)
 {
-    unsigned i;
+    unsigned            i;
+    HANDLE              hkey;
+    OBJECT_ATTRIBUTES   attr;
+    UNICODE_STRING      nameW;
+    static const WCHAR  termW[] = {'S','o','f','t','w','a','r','e','\\','W','i','n','e','\\','T','e','r','m',0};
+
     for (i = 0; i < sizeof(TERM_dbkey_init) / sizeof(TERM_dbkey_init[0]); i++)
     {
         if (!TERM_AddKeyDescr(tigetstr(TERM_dbkey_init[i].string), &TERM_dbkey_init[i].descr))
             return FALSE;
     }
+
+    /* now read from registry */
+    attr.Length = sizeof(OBJECT_ATTRIBUTES);
+    RtlOpenCurrentUser(KEY_READ, &attr.RootDirectory);
+    attr.ObjectName = &nameW;
+    attr.Attributes = 0;
+    attr.SecurityDescriptor = NULL;
+    attr.SecurityQualityOfService = NULL;
+    RtlInitUnicodeString(&nameW, termW);
+
+    /* @@ Wine registry key: HKCU\Software\Wine\Term */
+    if (!NtOpenKey(&hkey, KEY_READ, &attr))
+    {
+        unsigned i, j, k;
+        BYTE tmp[128];
+        char name[64];
+        KEY_VALUE_FULL_INFORMATION *info = (KEY_VALUE_FULL_INFORMATION*)tmp;
+        DWORD cb, gotten;
+        BYTE* data;
+        struct dbkey_descr d;
+        UNICODE_STRING us;
+        ANSI_STRING as;
+
+        for (k = 0; ; k++)
+        {
+            cb = sizeof(tmp);
+            if (NtEnumerateValueKey(hkey, k, KeyValueFullInformation, tmp, cb, &gotten) != 0)
+                break; /* assume end of enumeration (FIXME check buffer overflow) */
+
+            data = &tmp[info->DataOffset];
+            if (gotten == info->DataOffset + 6 /* size */ && data[0] == 1 /* version */)
+            {
+                d.kind = data[1];
+                d.p1 = data[2];
+                d.p2 = data[3];
+                d.p3 = data[4] + (data[5] << 8);
+                us.Buffer = info->Name;
+                us.Length = us.MaximumLength = info->NameLength;
+                as.Buffer = name;
+                as.Length = as.MaximumLength = sizeof(name);
+                RtlUnicodeStringToAnsiString(&as, &us, FALSE);
+                for (i = j = 0; name[i] != '\0'; i++, j++)
+                {
+                    if (name[i] == '^')
+                    {
+                        if (name[i+1] >= '@' && name[i+1] <= '_')
+                        {
+                            name[j] = name[++i] - '@';
+                        }
+                        else if (name[i+1] == '^')
+                        {
+                            name[j] = name[++i];
+                        }
+                        else name[j] = name[i];
+                    }
+                    else name[j] = name[i];
+                }
+                name[j] = '\0';
+                TRACE("key %s: k=%x p1=%lx p2=%lx p3=%lx\n", wine_dbgstr_a(name), d.kind, d.p1, d.p2, d.p3);
+                if (!TERM_AddKeyDescr(strdup(name), &d)) return FALSE;
+            }
+            else ERR("Wrong key size %d\n", gotten - info->DataOffset);
+        }
+        NtClose(hkey);
+    }
+    NtClose(attr.RootDirectory);
     return TRUE;
 }
 
diff --git a/tools/wine.inf.in b/tools/wine.inf.in
index b2667af..42c589c 100644
--- a/tools/wine.inf.in
+++ b/tools/wine.inf.in
@@ -690,6 +690,9 @@ HKLM,SOFTWARE\Microsoft\Active Setup\Installed Components\{de5aed00-a4bf-11d1-99
 HKLM,SOFTWARE\Microsoft\Active Setup\Installed Components\{de5aed00-a4bf-11d1-9948-00c04f98bbc9},"IsInstalled",2,1
 HKLM,SOFTWARE\Microsoft\Active Setup\Installed Components\{de5aed00-a4bf-11d1-9948-00c04f98bbc9},"Locale",2,"*"
 HKLM,SOFTWARE\Microsoft\Active Setup\Installed Components\{de5aed00-a4bf-11d1-9948-00c04f98bbc9},"Version",2,"4,74,9273,0"
+; Some missing key mapping in libterm 
+HKCU,Software\Wine\Term,"^[[1;5C",3,01,01,4d,27,08,00
+HKCU,Software\Wine\Term,"^[[1;5D",3,01,01,4b,25,08,00
 
 [Nls]
 HKLM,System\CurrentControlSet\Control\Nls\Codepage,"37",,""




More information about the wine-patches mailing list