storing the registry key class name to make PDFXChange-Viewer happy

Patrick ragamuffin at datacomm.ch
Sat Feb 28 00:37:01 CST 2009


Dear Developpers of Wine

I like wine and I like Tracker Software's PDFXChange-Viewer as well.
http://www.docu-track.com/home/prod_user/PDF-XChange_Tools/pdfx_viewer

So, today I was not getting any rest until i found out why these two
won't work together nicely. I mean they DO, actually. But I'm kind of
touchy. I was wondering all the time, why most of the settings I changed
were not restored as I exited and restarted the app.

I then discovered that if wineserver was preserved ("-p" option) beween
restarts they WERE restored. Further investigations unveiled that the
problem is triggered by the fact that wineserver is not storing the
registry key class name attributes. Something M$ must have come up with
in XP but that is not very wideley used. PDFXChange-Viewer however seems
to rely on it when parsing it's preferences from the registry on
startup.

Wineservers unicode string handling gave me a though time in
implementing a solution to this but i finally managed. You can see that
I went quiet straightforward: adding the class name next to the key name
in the {system,user}.reg files. There are two different versions of the
fix. I would prefer the second one because it preserves backwards
compatibility: In case the key class attribute is set, it is put in
brackets between the key name and modification time. Otherwise nothing
changes.

It would be really nice if this could be somehow integrated into wine.
(Not only because I worked on it for a whole day, but also because i
really miss the feature because i don't want to reconfigure
PDFXChange-Viewer every time i start it and also because I would like to
make that functionality available to all of my friends and all linux
users as well.

Greets

Patrick


[Software\\Tracker Software\\PDFViewer\\FullScreen\\MainView\\Bars\\0011;ParamItem] 1235760987
"Break"=dword:00000001
"ID"=dword:000081c9
"Name"="Properties"

[Software\\Tracker Software\\PDFViewer\\FullScreen\\MainView\\Bars\\0011] [ParamItem] 1235761189
"Break"=dword:00000001
"ID"=dword:000081c9
"Name"="Properties"

--- registry.c	2009-02-27 19:44:14.000000000 +0100
+++ registry.PP1.c	2009-02-27 19:49:03.000000000 +0100
@@ -176,7 +176,7 @@
         dump_path( key->parent, base, f );
         fprintf( f, "\\\\" );
     }
-    dump_strW( key->name, key->namelen / sizeof(WCHAR), f, "[]" );
+    dump_strW( key->name, key->namelen / sizeof(WCHAR), f, "[;" );
 }
 
 /* dump a value to a text file */
@@ -245,6 +245,8 @@
     {
         fprintf( f, "\n[" );
         if (key != base) dump_path( key, base, f );
+        fprintf( f, ";" );
+        dump_strW( key->class, key->classlen / sizeof(WCHAR), f, "[]" );
         fprintf( f, "] %ld\n", (long)key->modif );
         for (i = 0; i <= key->last_value; i++) dump_value( &key->values[i], f );
     }
@@ -1108,20 +1110,22 @@
                              int prefix_len, struct file_load_info *info,
                              int default_modif )
 {
-    WCHAR *p;
-    struct unicode_str name;
-    int res, modif;
-    data_size_t len;
+    WCHAR *p, cls[256];
+    struct unicode_str name, class;
+    int res, res2, modif;
+    data_size_t len, len2 = 256;
 
     if (!get_file_tmp_space( info, strlen(buffer) * sizeof(WCHAR) )) return NULL;
 
     len = info->tmplen;
-    if ((res = parse_strW( info->tmp, &len, buffer, ']' )) == -1)
+    if ((res = parse_strW( info->tmp, &len, buffer, ';' )) == -1 ||
+        (res2 = parse_strW( cls, &len2, buffer+res, ']' ) == -1))
     {
         file_read_error( "Malformed key", info );
         return NULL;
     }
-    if (sscanf( buffer + res, " %d", &modif ) != 1) modif = default_modif;
+
+    if (sscanf( buffer + res + res2, " %d", &modif ) != 1) modif = default_modif;
 
     p = info->tmp;
     while (prefix_len && *p) { if (*p++ == '\\') prefix_len--; }
@@ -1138,7 +1142,10 @@
     }
     name.str = p;
     name.len = len - (p - info->tmp + 1) * sizeof(WCHAR);
-    return create_key( base, &name, NULL, flags, modif, &res );
+    class.str = cls;
+    class.len = len2 - sizeof(WCHAR);
+    
+    return create_key( base, &name, &class, flags, modif, &res );
 }
 
 /* parse a comma-separated list of hex digits */


--- registry.c	2009-02-27 19:44:14.000000000 +0100
+++ registry.PP2.c	2009-02-27 19:59:28.000000000 +0100
@@ -245,6 +245,10 @@
     {
         fprintf( f, "\n[" );
         if (key != base) dump_path( key, base, f );
+        if (key->class != NULL) {
+                fprintf( f, "] [" );
+                dump_strW( key->class, key->classlen / sizeof(WCHAR), f, "[]" );
+        }
         fprintf( f, "] %ld\n", (long)key->modif );
         for (i = 0; i <= key->last_value; i++) dump_value( &key->values[i], f );
     }
@@ -1108,10 +1112,10 @@
                              int prefix_len, struct file_load_info *info,
                              int default_modif )
 {
-    WCHAR *p;
-    struct unicode_str name;
-    int res, modif;
-    data_size_t len;
+    WCHAR *p, *c;
+    struct unicode_str name, class;
+    int res, c_res, modif;
+    data_size_t len, c_len;
 
     if (!get_file_tmp_space( info, strlen(buffer) * sizeof(WCHAR) )) return NULL;
 
@@ -1121,6 +1125,23 @@
         file_read_error( "Malformed key", info );
         return NULL;
     }
+
+    c_len = info->tmplen - len;
+    if ((c_res = parse_strW( info->tmp + len / sizeof(WCHAR), &c_len, buffer + res, ']' )) == -1)
+    {
+        class.len = 0;
+    }
+    else
+    {
+	res += c_res;
+
+        c = info->tmp + len / sizeof(WCHAR);
+        while (*c) { if (*c++ == '[') break; }
+
+        class.str = c;
+        class.len = c_len - (c - (info->tmp + len / sizeof(WCHAR)) + 1) * sizeof(WCHAR);
+    }
+
     if (sscanf( buffer + res, " %d", &modif ) != 1) modif = default_modif;
 
     p = info->tmp;
@@ -1138,6 +1159,9 @@
     }
     name.str = p;
     name.len = len - (p - info->tmp + 1) * sizeof(WCHAR);
+
+    if (class.len > 0)
+        return create_key( base, &name, &class, flags, modif, &res );
     return create_key( base, &name, NULL, flags, modif, &res );
 }
 





More information about the wine-devel mailing list