[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wine-devel
Subject:    Re: VS_VERSION_INFO alignment
From:       Ulrich Weigand <weigand () informatik ! uni-erlangen ! de>
Date:       1999-12-22 13:30:56
[Download RAW message or body]


Andreas Mohr <mohr@elektron.ikp.physik.tu-darmstadt.de> wrote:

> Some setup does the following:
> size = GetFileVersionInfoSizeA("file", &handle);
> hGlb = GlobalAlloc(GMEM_MOVEABLE, 0x5921);
> buf = GlobalLock(hGlb);
> and then it happens:
> GetFileVersionInfoA("file", handle, size, buf+1);
>                                           ^^^^^ !!
> 
> This drives Wine's DWORD alignment code of the PE->NE version info
> conversion function completely nuts :-)
> (as the buffer address isn't properly DWORD aligned *from the beginning* !)
> So one approach would be to completely remove the alignment code as the
> data probably should already be aligned correctly in the binary:

Eh?  *Because* the data *is* aligned in the binary, we *need* to have
the correct alignment code so as to find the location where the data
resides in the binary!

> The alternative would be to take into account the misalignment of the buffer
> by adding that misalignment offset to each of these defines instead of
> completely removing alignment.

Yes, the alignment should probably be relative to the start of the
version info, *not* the absolute addresses.  Could you try this patch:

--- info.c.orig Wed Dec 22 14:24:27 1999
+++ info.c      Wed Dec 22 14:28:15 1999
@@ -172,12 +172,10 @@
 #define VersionInfoIs16( ver ) \
     ( ((VS_VERSION_INFO_STRUCT16 *)ver)->szKey[0] >= ' ' )
 
-#define DWORD_ALIGN( ptr ) ((LPBYTE)( (((DWORD)(ptr)) + 3) & ~3 ))
-
 #define VersionInfo16_Value( ver )  \
-    DWORD_ALIGN( (ver)->szKey + lstrlenA((ver)->szKey) + 1 )
+    (LPSTR)((LPBYTE)ver + ( (4 + lstrlenA((ver)->szKey)+1 + 3) & ~3 ))
 #define VersionInfo32_Value( ver )  \
-    DWORD_ALIGN( (ver)->szKey + lstrlenW((ver)->szKey) + 1 )
+    (LPWSTR)((LPBYTE)ver + ( (6 + 2*(lstrlenW((ver)->szKey)+1) + 3) & ~3 ))
 
 #define VersionInfo16_Children( ver )  \
     (VS_VERSION_INFO_STRUCT16 *)( VersionInfo16_Value( ver ) + \

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic