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

Patrick ragamuffin at datacomm.ch
Mon Mar 2 04:50:58 CST 2009


On Son, 2009-03-01 at 19:07 -0600, Austin English wrote:
> On Sun, Mar 1, 2009 at 11:41 AM, Patrick <ragamuffin at datacomm.ch> wrote:
> > On Sam, 2009-02-28 at 19:04 -0600, Austin English wrote:
> >> On Sat, Feb 28, 2009 at 7:04 PM, Austin English <austinenglish at gmail.com> wrote:
> >> > On Sat, Feb 28, 2009 at 12:37 AM, Patrick <ragamuffin at datacomm.ch> wrote:
> >> >> 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

> >> >> --- registry.c  2009-02-27 19:44:14.000000000 +0100
> >> >> +++ registry.PP2.c      2009-02-27 19:59:28.000000000 +0100
> >> >>
> >> >
> >> > Patches should be sent in git diff format to wine-patches at winehq.org.
> >> >
> >> > See http://wiki.winehq.org/Patching
> >> >
> >> > Thanks for helping Wine!
> >> >
> >> > --
> >> > -Austin
> >> >
> >>
> >> Err, make that http://wiki.winehq.org/SubmittingPatches
> >>
> >
> > Sorry, lenghty conformance tests & learning git would take me another
> > day.... It's unlikely that I'll do that before Christmas 2010 or so...
> > Thank you for the reply anyway!
> >
> > In case anybody wants to use the code - put it through the whole
> > preocess - modify it or implement the idea in another way, he should
> > feel free to do so. It's hereby set free from any license/copyright or
> > other obstacles. You could even claim that you wrote it yourself ;-) I
> > won't mind. Just get it into wine somehow.
> >
> > Patrick
> >
> >
> 
> Is this supposed to apply to server/registry.c? It doesn't apply in latest git..
> 
Yes, server/registry.c
I've improved V2 slightly and made it apply on latest git. And I tested
it now - it builds and does what it's supposed to do. Which means
PDFXChange-Viewer works, keeps its settings and there are no side
effects.

One line there 
 class.len = c_len - (c - (info->tmp + len / sizeof(WCHAR)) + 1) * sizeof(WCHAR);
looks "ugly" to my eyes as well, but it's correct, so...



>From 8a7fd46edc1192461fa2f7ea48e2b40769352a44 Mon Sep 17 00:00:00 2001
From: Patrick <ragamuffin at datacomm.ch>
Date: Mon, 2 Mar 2009 10:12:26 +0100
Subject: save/load registry key class names

---
 server/registry.c |   41 +++++++++++++++++++++++++++++++++++++----
 1 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/server/registry.c b/server/registry.c
index d83486b..afe7771 100644
--- a/server/registry.c
+++ b/server/registry.c
@@ -246,6 +246,10 @@ static void save_subkeys( const struct key *key, const struct key *base, FILE *f
     {
         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, "] %u\n", (unsigned int)((key->modif - ticks_1601_to_1970) / TICKS_PER_SEC) );
         for (i = 0; i <= key->last_value; i++) dump_value( &key->values[i], f );
     }
@@ -1107,12 +1111,12 @@ static int get_data_type( const char *buffer, int *type, int *parse_type )
 static struct key *load_key( struct key *base, const char *buffer, int flags,
                              int prefix_len, struct file_load_info *info )
 {
-    WCHAR *p;
-    struct unicode_str name;
-    int res;
+    WCHAR *p, *c;
+    struct unicode_str name, class;
+    int res, c_res;
     unsigned int mod;
     timeout_t modif = current_time;
-    data_size_t len;
+    data_size_t len, c_len;
 
     if (!get_file_tmp_space( info, strlen(buffer) * sizeof(WCHAR) )) return NULL;
 
@@ -1122,6 +1126,32 @@ static struct key *load_key( struct key *base, const char *buffer, int flags,
         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)
+    {
+	/* no class name */
+        class.len = 0;
+    }
+    else
+    {
+	res += c_res;
+
+        c = info->tmp + len / sizeof(WCHAR);
+        while (*c) { if (*c++ == '[') break; }
+
+        if (!*c)
+        {
+            /* malformed class name - ignore */
+            class.len = 0;
+        }
+	else
+	{
+            class.str = c;
+            class.len = c_len - (c - (info->tmp + len / sizeof(WCHAR)) + 1) * sizeof(WCHAR);
+        }
+    }
+
     if (sscanf( buffer + res, " %u", &mod ) == 1)
         modif = (timeout_t)mod * TICKS_PER_SEC + ticks_1601_to_1970;
 
@@ -1140,6 +1170,9 @@ static struct key *load_key( struct key *base, const char *buffer, int flags,
     }
     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 );
 }
 
-- 
1.6.1.3






More information about the wine-devel mailing list