oleaut32: typelib - fix regression in MSFT typelib parsing (RESEND)

Alex Villací­s Lasso a_villacis at palosanto.com
Wed Nov 8 18:33:46 CST 2006


(Resending, this regression crashes some typelibs since 0.9.24)

Finally, I managed to figure out the proper fix for the crash on regsvr32
msvbvm60.dll (and probably some other DLLs too). It turns out that the
field from which TLBFuncDesc->Entry is filled is supposed to indicate the
function entry point that implements the function described in the
typelib. The proper interpretation of the entry is right there as a
comment:

    BSTR Entry;            /* if its Hiword==0, it numeric; -1 is not present*/

What this means is that if TLBFuncDesc->Entry has a high word of 0, it is
supposed to be a DLL function ordinal. Otherwise, it is an offset of the
function name (for lookup-by-name in the DLL). When this field was
directly copied from the binary block (and the block kept around, with a
memory leak), everything worked as expected. However, the patch to
allocate space for the function name in the Entry-as-funcname case broke
the Entry-as-ordinal case, since the ordinal value is not a proper
pointer, and therefore it is incorrect to use it as such (like calling
SysAllocString on it). This patch fixes the regression by copying the
ordinal value when indicated by the FKCCIC flag, and checking the HIWORD
before trying to free the allocated string in the Entry-as-funcname case.

Changelog:
* Fix regression on MSFT typelib parsing of function records by allocating
  a string copy only when indicated by FKCCIC flag, and preserving the
meaning of value as function ordinal otherwise.

Alex Villacís Lasso

-- 
The following cryptic message was allegedly found in the inner edge of a Windows
XP installation CD:

4F6E65204F5320746F2072756C65207468656D20616C6C2C204F6E65204F5320746F2066696E6420
7468656D2C0D0A4F6E65204F5320746F206272696E67207468656D20616C6C20616E6420696E2074
6865206461726B6E6573732062696E64207468656D2E0A

It is rumored that only a true Unix Wizard can decypher this mysterious message,
which supposedly encodes the true nature and purpose of the software.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: wine-oleaut32-typelib-MSFT-Entry.patch
Type: text/x-patch
Size: 1599 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-patches/attachments/20061108/e5b150e4/wine-oleaut32-typelib-MSFT-Entry.bin


More information about the wine-patches mailing list