public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] windres (ungarbled): (7) don't confuse version and STYLE
@ 2002-03-19 15:27 Gunnar Degnbol
  2002-04-09  9:38 ` Nick Clifton
  0 siblings, 1 reply; 2+ messages in thread
From: Gunnar Degnbol @ 2002-03-19 15:27 UTC (permalink / raw)
  To: binutils

windres dies with the message "unexpected dialog signature 
X" when decompiling a resource file with a DIALOG with STYLE 
1 (WS_TABSTOP) style and no other bits set in the lower half 
of style. X is the upper 16 bits of style. 

The STYLE of a DIALOG overlaps with the version and signature 
of a DIALOGEX. windres identifies DIALOGEX resource by 
checking the version number (1), which is a valid value for 
the lower 16 bits of STYLE (dialogs used as controls may be 
tabstops), instead of checking the signature (0xffff), which 
is not valid for the upper 16 bits of STYLE (WS_POPUP cannot 
be combined with WS_CHILD). 

The fix is to swap the checks for version and signature in 
resbin.c. 

ChangeLog:

2002-03-19 Gunnar Degnbol <degnbol@danbbs.dk>

	* resbin.c: Use signature to identify DIALOGEX

dialogsignature.rc:

101 DIALOG DISCARDABLE  0, 0, 186, 95
STYLE 1
BEGIN
    DEFPUSHBUTTON "OK",1,129,7,50,14
END

Before patch:

$ /bin/windres.exe -i dialogsignature.rc -o dialogsignature.o  

$ /bin/windres.exe -i dialogsignature.o 
/bin/windres.exe: unexpected dialog signature 32904

After patch:

$ windres.exe -i dialogsignature.o
LANGUAGE 0, 0

101 DIALOG 0, 0, 186, 95
STYLE 0x80880001
BEGIN
  DEFPUSHBUTTON "OK", 1, 129, 7, 50, 14, 0x50010001
END

dialogsignature.patch:
--- binutils/resbin.c	Sun Mar 17 14:51:23 2002
+++ binutils.new/resbin.c	Sun Mar 17 14:51:34 2002
@@ -460,7 +460,7 @@
      unsigned long length;
      int big_endian;
 {
-  int version;
+  int signature;
   struct dialog *d;
   int c, sublen, i;
   unsigned int off;
@@ -472,8 +472,8 @@
 
   d = (struct dialog *) res_alloc (sizeof *d);
 
-  version = get_16 (big_endian, data);
-  if (version != 1)
+  signature = get_16 (big_endian, data + 2);
+  if (signature != 0xffff)
     {
       d->ex = NULL;
       d->style = get_32 (big_endian, data);
@@ -482,11 +482,11 @@
     }
   else
     {
-      int signature;
-
-      signature = get_16 (big_endian, data + 2);
-      if (signature != 0xffff)
-	fatal (_("unexpected dialog signature %d"), signature);
+      int version;
+      
+      version = get_16 (big_endian, data);
+      if (version != 1)
+	fatal (_("unexpected DIALOGEX version %d"), version);
 
       d->ex = (struct dialog_ex *) res_alloc (sizeof (struct dialog_ex));
       d->ex->help = get_32 (big_endian, data + 4);

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] windres (ungarbled): (7) don't confuse version and STYLE
  2002-03-19 15:27 [PATCH] windres (ungarbled): (7) don't confuse version and STYLE Gunnar Degnbol
@ 2002-04-09  9:38 ` Nick Clifton
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Clifton @ 2002-04-09  9:38 UTC (permalink / raw)
  To: gunnar; +Cc: binutils

Hi Gunnar Degnbol,

: 2002-03-19 Gunnar Degnbol <degnbol@danbbs.dk>
: 
: 	* resbin.c: Use signature to identify DIALOGEX

Approved and applied.

I also added a testcase based on the code you submitted, although
strictly speaking it does not test the problem as it does not use
windres to disassemble the binary object.  Oh well.

Cheers
	Nick

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-04-09 16:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-19 15:27 [PATCH] windres (ungarbled): (7) don't confuse version and STYLE Gunnar Degnbol
2002-04-09  9:38 ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).