OLEAUT32 patch
Andreas Mohr
a.mohr at mailto.de
Sun Sep 30 16:33:13 CDT 2001
Hello all,
this is a rewrite of OaBuildVersion().
Now we just return the highest version value possible (0xffff) and
have a config file option to tweak the version value to return if this
is causing problems.
Added docu for it, of course.
Additionally some cleanup of OLEAUT32 things.
Alexandre: yes, I think a config file setting is needed, since we've had
an awful lot of problems with OLEAUT versioning already (I get one mail
about this problem every two weeks), so I suspect that programs are
pretty rigid about this.
If it actually turns out to be unnecessary, then we'll just be able
to remove it anyway.
--
Andreas Mohr Stauferstr. 6, D-71272 Renningen, Germany
-------------- next part --------------
Determining best CVS host...
Using CVSROOT :pserver:cvs at rhlx01.fht-esslingen.de:/home/wine
Index: dlls/oleaut32/ole2disp.c
===================================================================
RCS file: /home/wine/wine/dlls/oleaut32/ole2disp.c,v
retrieving revision 1.19
diff -u -r1.19 ole2disp.c
--- dlls/oleaut32/ole2disp.c 23 Jul 2001 23:50:19 -0000 1.19
+++ dlls/oleaut32/ole2disp.c 30 Sep 2001 19:26:45 -0000
@@ -63,7 +63,7 @@
if (!in) return 0;
out = BSTR_AllocBytes(strlen(in)+1);
- if(!out)return 0;
+ if (!out) return 0;
strcpy(BSTR_GetAddr(out),in);
return out;
}
@@ -270,7 +270,7 @@
bufferPointer--;
/*
- * Free the memory from it's "real" origin.
+ * Free the memory from its "real" origin.
*/
HeapFree(GetProcessHeap(), 0, bufferPointer);
}
@@ -485,7 +485,7 @@
/*
* Allocate a new buffer to hold the string.
- * dont't forget to keep an empty spot at the begining of the
+ * dont't forget to keep an empty spot at the beginning of the
* buffer for the character count and an extra character at the
* end for the NULL.
*/
Index: dlls/oleaut32/oleaut.c
===================================================================
RCS file: /home/wine/wine/dlls/oleaut32/oleaut.c,v
retrieving revision 1.20
diff -u -r1.20 oleaut.c
--- dlls/oleaut32/oleaut.c 26 Jul 2001 21:44:23 -0000 1.20
+++ dlls/oleaut32/oleaut.c 30 Sep 2001 19:26:45 -0000
@@ -3,12 +3,13 @@
*
*/
#include <string.h>
+#include <stdio.h>
-#include "windef.h"
#include "winbase.h"
+#include "wine/winbase16.h"
#include "wingdi.h"
-#include "winuser.h"
#include "winerror.h"
+#include "winreg.h"
#include "ole2.h"
#include "olectl.h"
@@ -88,34 +89,120 @@
return ret;
}
+/*
+ * query for a certain key name
+ * first in the AppDefaults section, then in the global section
+ */
+BOOL OLEAUT32_GetAppKey(LPSTR KeyName, DWORD *version)
+{
+ char buffer[MAX_PATH+32], modname[MAX_PATH+32];
+ char *p = buffer, *appname;
+ DWORD type, count = sizeof(buffer);
+ HKEY hconfkey = 0, hkey = 0;
+ int major = 0, minor = 0, build = 0;
+ BOOL res = FALSE, found = FALSE;
+
+ *version = 0xffffffff;
+
+ if (RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config", &hconfkey ))
+ return FALSE;
+
+ /* (try to) open the app-specific key */
+ if (!GetModuleFileName16( GetCurrentTask(), modname, MAX_PATH ) &&
+ !GetModuleFileNameA( 0, modname, MAX_PATH ))
+ {
+ WARN( "could not get module file name\n");
+ goto not_found;
+ }
+ appname = modname;
+ /* remove path part if given */
+ if ((p = strrchr( appname, '/' ))) appname = p + 1;
+ if ((p = strrchr( appname, '\\' ))) appname = p + 1;
+
+ /* open app-specific key */
+ strcpy(buffer, "AppDefaults\\");
+ strcat(buffer, appname);
+ strcat(buffer, "\\wine");
+ TRACE( "searching '%s' in %s\n", KeyName, buffer);
+
+ count = sizeof(buffer);
+ if ( (!RegOpenKeyA( hconfkey, buffer, &hkey ))
+ && (!RegQueryValueExA(hkey, KeyName, 0, &type, buffer, &count))
+ )
+ found = TRUE;
+ RegCloseKey(hkey);
+
+ count = sizeof(buffer);
+ if ( (!found)
+ && (!RegOpenKeyA(hconfkey, "wine", &hkey))
+ && (!RegQueryValueExA(hkey, KeyName, 0, &type, buffer, &count))
+ )
+ found = TRUE;
+ RegCloseKey(hkey);
+
+ if ((found) && (type == REG_SZ))
+ {
+ sscanf(buffer, "%01d.%02d.%04d", &major, &minor, &build);
+ *version = MAKELONG(build, minor);
+ res = TRUE;
+ }
+
+not_found:
+ if (hconfkey)
+ RegCloseKey(hconfkey);
+ if (hkey)
+ RegCloseKey(hkey);
+ return res;
+}
+
/***********************************************************************
* OaBuildVersion [OLEAUT32.170]
*
* known OLEAUT32.DLL versions:
* OLE 2.1 NT 1993-95 10 3023
* OLE 2.1 10 3027
+ * Win32s 1.1e 20 4049
* OLE 2.20 W95/NT 1993-96 20 4112
* OLE 2.20 W95/NT 1993-96 20 4118
* OLE 2.20 W95/NT 1993-96 20 4122
* OLE 2.30 W95/NT 1993-98 30 4265
* OLE 2.40 NT?? 1993-98 40 4267
* OLE 2.40 W98 SE orig. file 1993-98 40 4275
+ * OLE 2.40 W2K orig. file 1993-XX 40 4514
+ *
+ * I just decided to use version 2.20 for Win3.1, 2.30 for Win95 & NT 3.51,
+ * and 2.40 for all newer OSs. The build number is maximum, i.e. 0xffff.
+ * If this still causes version errors, the user can supply a global or a
+ * per app BuildVersion_OLEAUT32 value needed for the application.
*/
UINT WINAPI OaBuildVersion()
{
- FIXME("Please report to a.mohr at mailto.de if you get version error messages !\n");
+ static DWORD version = 0;
+
+ /* check once for user-supplied key */
+ if (!version)
+ {
+ OLEAUT32_GetAppKey("BuildVersion_OLEAUT32", &version);
+ }
+ if ((version) && (version != 0xffffffff))
+ return version;
+
switch(GetVersion() & 0x8000ffff) /* mask off build number */
{
case 0x80000a03: /* WIN31 */
- return MAKELONG(4049, 20); /* from Win32s 1.1e */
- case 0x80000004: /* WIN95 */
- return MAKELONG(4265, 30);
- case 0x80000a04: /* WIN98 */
- return MAKELONG(4275, 40); /* value of W98 SE; orig. W98 AFAIK has 4265, 30 just as W95 */
+ return MAKELONG(0xffff, 20);
case 0x00003303: /* NT351 */
- return MAKELONG(4265, 30); /* value borrowed from Win95 */
+ return MAKELONG(0xffff, 30);
+ case 0x80000004: /* WIN95; I'd like to use the "standard" w95 minor
+ version here (30), but as we still use w95
+ as default winver (which is good IMHO), I better
+ play safe and use the latest value for w95 for now.
+ Change this as soon as default winver gets changed
+ to something more recent */
+ case 0x80000a04: /* WIN98 */
case 0x00000004: /* NT40 */
- return MAKELONG(4122, 20); /* ouch ! Quite old, I guess */
+ case 0x00000005: /* W2K */
+ return MAKELONG(0xffff, 40);
default:
ERR("Version value not known yet. Please investigate it !\n");
return 0x0;
Index: dlls/oleaut32/variant.c
===================================================================
RCS file: /home/wine/wine/dlls/oleaut32/variant.c,v
retrieving revision 1.26
diff -u -r1.26 variant.c
--- dlls/oleaut32/variant.c 21 Sep 2001 21:01:31 -0000 1.26
+++ dlls/oleaut32/variant.c 30 Sep 2001 19:26:46 -0000
@@ -85,7 +85,7 @@
* but not of a 100. Except if it is a multiple of
* 400 then it is a leap year.
*/
-/* According to postgeSQL date parsing functions there is
+/* According to postgreSQL date parsing functions there is
* a leap year when this expression is true.
* (((y % 4) == 0) && (((y % 100) != 0) || ((y % 400) == 0)))
* So according to this there is 365.2515 days in one year.
@@ -100,6 +100,7 @@
*/
static const double DAYS_IN_ONE_YEAR = 365.2425;
+
/******************************************************************************
* DateTimeStringToTm [INTERNAL]
*
@@ -230,10 +231,9 @@
*/
static BOOL TmToDATE( struct tm* pTm, DATE *pDateOut )
{
+ int leapYear = 0;
if( (pTm->tm_year - 1900) >= 0 )
{
- int leapYear = 0;
-
/* Start at 1. This is the way DATE is defined.
* January 1, 1900 at Midnight is 1.00.
* January 1, 1900 at 6AM is 1.25.
@@ -334,14 +334,13 @@
*/
static BOOL DateToTm( DATE dateIn, DWORD dwFlags, struct tm* pTm )
{
+ double decimalPart = 0.0;
+ double wholePart = 0.0;
/* Do not process dates smaller than January 1, 1900.
* Which corresponds to 2.0 in the windows DATE format.
*/
if( dateIn >= 2.0 )
{
- double decimalPart = 0.0;
- double wholePart = 0.0;
-
memset(pTm,0,sizeof(*pTm));
/* Because of the nature of DATE format which
@@ -611,7 +610,6 @@
LPSTR pNewString = NULL;
LPSTR strToken = NULL;
-
/* Check if we have a valid argument
*/
if( str != NULL )
@@ -1672,8 +1670,8 @@
/******************************************************************************
* VariantInit [OLEAUT32.8]
*
- * Initializes the Variant. Unlike VariantClear it does not interpret the current
- * contents of the Variant.
+ * Initializes the Variant. Unlike VariantClear it does not interpret
+ * the current contents of the Variant.
*/
void WINAPI VariantInit(VARIANTARG* pvarg)
{
@@ -1789,9 +1787,9 @@
else
{
/* In the case of by value we need to
- * copy the actuall value. In the case of
+ * copy the actual value. In the case of
* VT_BSTR a copy of the string is made,
- * if VT_DISPATCH or VT_IUNKNOWN AddReff is
+ * if VT_DISPATCH or VT_IUNKNOWN AddRef is
* called to increment the object's reference count.
*/
switch( V_VT(pvargSrc) & VT_TYPEMASK )
@@ -3243,7 +3241,7 @@
* VarBstrFromCy [OLEAUT32.113]
*/
HRESULT WINAPI VarBstrFromCy(CY cyIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut) {
- /* FIXME */
+ FIXME("([cyIn], %08lx, %08lx, %p), stub.\n", lcid, dwFlags, pbstrOut);
return E_NOTIMPL;
}
@@ -3308,14 +3306,7 @@
{
TRACE("( %d, %ld, %ld, %p ), stub\n", boolIn, lcid, dwFlags, pbstrOut );
- if( boolIn == VARIANT_FALSE )
- {
- sprintf( pBuffer, "False" );
- }
- else
- {
- sprintf( pBuffer, "True" );
- }
+ sprintf( pBuffer, (boolIn == VARIANT_FALSE) ? "False" : "True" );
*pbstrOut = StringDupAtoBstr( pBuffer );
@@ -3384,14 +3375,7 @@
{
TRACE("( %d, %p ), stub\n", sIn, pboolOut );
- if( sIn == 0 )
- {
- *pboolOut = VARIANT_FALSE;
- }
- else
- {
- *pboolOut = VARIANT_TRUE;
- }
+ *pboolOut = (sIn) ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
}
@@ -3403,14 +3387,7 @@
{
TRACE("( %ld, %p ), stub\n", lIn, pboolOut );
- if( lIn == 0 )
- {
- *pboolOut = VARIANT_FALSE;
- }
- else
- {
- *pboolOut = VARIANT_TRUE;
- }
+ *pboolOut = (lIn) ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
}
@@ -3422,14 +3399,7 @@
{
TRACE("( %f, %p ), stub\n", fltIn, pboolOut );
- if( fltIn == 0.0 )
- {
- *pboolOut = VARIANT_FALSE;
- }
- else
- {
- *pboolOut = VARIANT_TRUE;
- }
+ *pboolOut = (fltIn == 0.0) ? VARIANT_FALSE : VARIANT_TRUE;
return S_OK;
}
@@ -3441,14 +3411,7 @@
{
TRACE("( %f, %p ), stub\n", dblIn, pboolOut );
- if( dblIn == 0.0 )
- {
- *pboolOut = VARIANT_FALSE;
- }
- else
- {
- *pboolOut = VARIANT_TRUE;
- }
+ *pboolOut = (dblIn == 0.0) ? VARIANT_FALSE : VARIANT_TRUE;
return S_OK;
}
@@ -3460,14 +3423,7 @@
{
TRACE("( %f, %p ), stub\n", dateIn, pboolOut );
- if( dateIn == 0.0 )
- {
- *pboolOut = VARIANT_FALSE;
- }
- else
- {
- *pboolOut = VARIANT_TRUE;
- }
+ *pboolOut = (dateIn == 0.0) ? VARIANT_FALSE : VARIANT_TRUE;
return S_OK;
}
@@ -3509,14 +3465,9 @@
{
ret = DISP_E_TYPEMISMATCH;
}
- else if( dValue == 0.0 )
- {
- *pboolOut = VARIANT_FALSE;
- }
else
- {
- *pboolOut = VARIANT_TRUE;
- }
+ *pboolOut = (dValue == 0.0) ?
+ VARIANT_FALSE : VARIANT_TRUE;
}
}
@@ -3532,14 +3483,7 @@
{
TRACE("( %c, %p ), stub\n", cIn, pboolOut );
- if( cIn == 0 )
- {
- *pboolOut = VARIANT_FALSE;
- }
- else
- {
- *pboolOut = VARIANT_TRUE;
- }
+ *pboolOut = (cIn == 0) ? VARIANT_FALSE : VARIANT_TRUE;
return S_OK;
}
@@ -3551,14 +3495,7 @@
{
TRACE("( %d, %p ), stub\n", uiIn, pboolOut );
- if( uiIn == 0 )
- {
- *pboolOut = VARIANT_FALSE;
- }
- else
- {
- *pboolOut = VARIANT_TRUE;
- }
+ *pboolOut = (uiIn == 0) ? VARIANT_FALSE : VARIANT_TRUE;
return S_OK;
}
@@ -3570,14 +3507,7 @@
{
TRACE("( %ld, %p ), stub\n", ulIn, pboolOut );
- if( ulIn == 0 )
- {
- *pboolOut = VARIANT_FALSE;
- }
- else
- {
- *pboolOut = VARIANT_TRUE;
- }
+ *pboolOut = (ulIn == 0) ? VARIANT_FALSE : VARIANT_TRUE;
return S_OK;
}
@@ -4103,11 +4033,11 @@
{
TRACE("( %f, %p ), stub\n", dblIn, pulOut );
- dblIn = round( dblIn );
+ dblIn = round( dblIn );
if( dblIn < UI4_MIN || dblIn > UI4_MAX )
{
return DISP_E_OVERFLOW;
- }
+ }
*pulOut = (ULONG) dblIn;
@@ -4121,8 +4051,8 @@
{
TRACE("( %f, %p ), stub\n", dateIn, pulOut );
- dateIn = round( dateIn );
- if( dateIn < UI4_MIN || dateIn > UI4_MAX )
+ dateIn = round( dateIn );
+ if( dateIn < UI4_MIN || dateIn > UI4_MAX )
{
return DISP_E_OVERFLOW;
}
@@ -4187,10 +4117,10 @@
* Convert unsigned char to currency
*/
HRESULT WINAPI VarCyFromUI1(BYTE bIn, CY* pcyOut) {
- pcyOut->s.Hi = 0;
- pcyOut->s.Lo = ((ULONG)bIn) * 10000;
-
- return S_OK;
+ pcyOut->s.Hi = 0;
+ pcyOut->s.Lo = ((ULONG)bIn) * 10000;
+
+ return S_OK;
}
/**********************************************************************
@@ -4198,11 +4128,11 @@
* Convert signed short to currency
*/
HRESULT WINAPI VarCyFromI2(short sIn, CY* pcyOut) {
- if (sIn < 0) pcyOut->s.Hi = -1;
- else pcyOut->s.Hi = 0;
- pcyOut->s.Lo = ((ULONG)sIn) * 10000;
-
- return S_OK;
+ if (sIn < 0) pcyOut->s.Hi = -1;
+ else pcyOut->s.Hi = 0;
+ pcyOut->s.Lo = ((ULONG)sIn) * 10000;
+
+ return S_OK;
}
/**********************************************************************
@@ -4261,8 +4191,8 @@
* VarCyFromStr [OLEAUT32.104]
*/
HRESULT WINAPI VarCyFromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, CY *pcyOut) {
- /* FIXME */
- return E_NOTIMPL;
+ FIXME("(%p, %08lx, %08lx, %p), stub.\n", strIn, lcid, dwFlags, pcyOut);
+ return E_NOTIMPL;
}
Index: documentation/samples/config
===================================================================
RCS file: /home/wine/wine/documentation/samples/config,v
retrieving revision 1.15
diff -u -r1.15 config
--- documentation/samples/config 17 Sep 2001 20:25:26 -0000 1.15
+++ documentation/samples/config 30 Sep 2001 19:26:46 -0000
@@ -64,6 +64,11 @@
; subdir tree in case of a symlink pointing back to itself.
;"ShowDirSymlinks" = "1"
"ShellLinker" = "wineshelllink"
+; Overrides the builtin values of the build version of OLEAUT32.DLL.
+; Format X.YY.ZZZZ, where X = (2), YY = (20, 30, 40) and ZZZZ = build number.
+; Use this if you get strange OLE or OLEAUT32 "too old" or "version" errors.
+; Can also be given in the [AppDefaults\\AppName.exe\\DllSettings] section.
+;"BuildVersion_OLEAUT32" = "2.40.4515"
# <wineconf>
Index: documentation/configuring.sgml
===================================================================
RCS file: /home/wine/wine/documentation/configuring.sgml,v
retrieving revision 1.9
diff -u -r1.9 configuring.sgml
--- documentation/configuring.sgml 26 Sep 2001 23:02:31 -0000 1.9
+++ documentation/configuring.sgml 30 Sep 2001 19:26:47 -0000
@@ -328,6 +328,17 @@
system directory (For this setup, it must have
<filename>"c:\\windows;c:\\windows\\system"</filename>).
</para>
+ <programlisting>"BuildVersion_OLEAUT32" = "X.YY.ZZZZ"</programlisting>
+ Overrides the build version of OLEAUT32.DLL that Wine is to
+ return. The OLEAUT32 version consists of a major, a minor and a
+ build number. Normally, Wine returns an appropriate build version
+ for the --winver that's currently used (i.e. 2.xx.0xffff).
+ If applications still don't like this version, even though
+ we're returning the very high build version of 0xffff (65535),
+ then you can specify your own custom version value here.
+ This setting can be specified on a per-app basis, too
+ (under [AppDefaults\\AppName.exe\\wine]).
+ </para>
<para>
<programlisting>"GraphicsDriver" = "x11drv|ttydrv"</programlisting>
Sets the graphics driver to use for Wine output.
More information about the wine-patches
mailing list