msvcrt: some exported data

Rein Klazes wijn at wanadoo.nl
Fri Dec 10 07:13:16 CST 2004


Hi,

This fixes a crash when using msvcirt.dll and mfc42.dll (must be native
as there are no wine implementations) with built-in msvcrt.dll. 

The crash happens when those dll's are using certain exported data items
from msvcrt. These data items are defined as stubs, so containing some
assembly stub code that are meant to give a helpful back trace when
accessed ("unimplemented function bla bla"). If they are not called as a
function this results in very strange crash results, all I got was
exception stack overflows.
This is not good I think, without the stubs the program when loading
will get deadbeef messages and when accessed a crash on accessing
deadbeef.
The attached patch removes the spec stubs for all data area's and
implements a couple that gave crashes to an application (Power Tab
editor to be precise).

Changelog:
	dlls/msvcrt	: msvcrt.spec, file.c, main.c
	- implement __pioinfo, __badioinfo and _adjust_fdiv;
	- remove all stubs of data item from the spec file, those
	actually may hide problems.

Rein.
-------------- next part --------------
--- wine/dlls/msvcrt/msvcrt.spec	2004-12-09 19:07:26.000000000 +0100
+++ mywine/dlls/msvcrt/msvcrt.spec	2004-12-10 11:33:57.000000000 +0100
@@ -83,7 +83,7 @@
 @ stub __STRINGTOLD #(ptr ptr str long)
 @ extern __argc MSVCRT___argc
 @ extern __argv MSVCRT___argv
-@ stub __badioinfo
+@ extern __badioinfo MSVCRT___badioinfo;
 @ stub __crtCompareStringA
 @ stub __crtGetLocaleInfoW
 @ cdecl __crtLCMapStringA(long long str long ptr long long long)
@@ -95,9 +95,9 @@
 @ cdecl __isascii(long) MSVCRT___isascii
 @ cdecl __iscsym(long) MSVCRT___iscsym
 @ cdecl __iscsymf(long) MSVCRT___iscsymf
-@ stub __lc_codepage
+# extern __lc_codepage
 @ stub __lc_collate
-@ stub __lc_handle
+# extern __lc_handle
 @ cdecl __lconv_init()
 @ extern __mb_cur_max MSVCRT___mb_cur_max
 @ cdecl __p___argc()
@@ -106,7 +106,7 @@
 @ cdecl __p___mb_cur_max()
 @ cdecl __p___wargv()
 @ cdecl __p___winitenv()
-@ cdecl __p__acmdln()
+# extern __p__acmdln()
 @ stub __p__amblksiz #()
 @ cdecl __p__commode()
 @ cdecl __p__daylight() MSVCRT___p__daylight
@@ -129,7 +129,7 @@
 @ cdecl __p__winminor()
 @ cdecl __p__winver()
 @ cdecl __p__wpgmptr()
-@ stub __pioinfo #()
+@ extern __pioinfo MSVCRT___pioinfo
 @ stub __pxcptinfoptrs #()
 @ cdecl __set_app_type(long) MSVCRT___set_app_type
 @ extern __setlc_active MSVCRT___setlc_active
@@ -159,8 +159,8 @@
 @ cdecl _adj_fprem()
 @ cdecl _adj_fprem1()
 @ cdecl _adj_fptan()
-@ cdecl _adjust_fdiv()
-@ extern _aexit_rtn
+@ extern _adjust_fdiv MSVCRT__adjust_fdiv 
+# extern _aexit_rtn
 @ cdecl _amsg_exit(long)
 @ cdecl _assert(str str long) MSVCRT__assert
 @ stub _atodbl #(ptr str)
@@ -194,13 +194,13 @@
 @ extern _ctype MSVCRT__ctype
 @ cdecl _cwait(ptr long long)
 @ extern _daylight MSVCRT___daylight
-@ stub _dstbias
+# extern _dstbias
 @ cdecl _dup (long)
 @ cdecl _dup2 (long long)
 @ cdecl _ecvt(double long ptr ptr)
 @ cdecl _endthread ()
 @ cdecl _endthreadex(long)
-@ extern _environ
+# extern _environ
 @ cdecl _eof(long)
 @ cdecl _errno() MSVCRT__errno
 @ cdecl _except_handler2(ptr ptr ptr ptr)
@@ -221,7 +221,7 @@
 @ cdecl _fgetchar()
 @ cdecl _fgetwchar()
 @ cdecl _filbuf(ptr) MSVCRT__filbuf
-@ stub _fileinfo
+# extern _fileinfo
 @ cdecl _filelength(long)
 @ cdecl -ret64 _filelengthi64(long)
 @ cdecl _fileno(ptr) MSVCRT__fileno
@@ -334,7 +334,7 @@
 @ cdecl _matherr(ptr) MSVCRT__matherr
 @ cdecl _mbbtombc(long)
 @ stub _mbbtype #(long long)
-@ stub _mbcasemap
+# extern _mbcasemap
 @ cdecl _mbccpy (str str) strcpy
 @ stub _mbcjistojms #(long)
 @ stub _mbcjmstojis #(long)
@@ -410,7 +410,7 @@
 @ cdecl _putenv(str)
 @ cdecl _putw(long ptr) MSVCRT__putw
 @ cdecl _putws(wstr)
-@ stub _pwctype
+# extern _pwctype
 @ cdecl _read(long ptr long)
 @ cdecl _rmdir(str)
 @ cdecl _rmtmp()
@@ -469,10 +469,10 @@
 @ cdecl _tell(long)
 @ cdecl -ret64 _telli64(long)
 @ cdecl _tempnam(str str)
-@ stub _timezone # extern
+# extern _timezone
 @ cdecl _tolower(long) MSVCRT__tolower
 @ cdecl _toupper(long) MSVCRT__toupper
-@ stub _tzname # extern
+# extern _tzname
 @ cdecl _tzset() tzset
 @ cdecl _ui64toa(long long ptr long) ntdll._ui64toa
 @ cdecl _ui64tow(long long ptr long) ntdll._ui64tow
@@ -504,7 +504,7 @@
 @ cdecl _wcsset(wstr long)
 @ cdecl _wcsupr(wstr) ntdll._wcsupr
 @ stub _wctime #(ptr)
-@ extern _wenviron
+# extern _wenviron
 @ stub _wexecl #(wstr wstr) varargs
 @ stub _wexecle #(wstr wstr) varargs
 @ stub _wexeclp #(wstr wstr) varargs
@@ -763,4 +763,4 @@
 @ varargs wprintf(wstr) MSVCRT_wprintf
 @ varargs wscanf(wstr) MSVCRT_wscanf
 @ cdecl _Gettnames() _Gettnames
-@ stub __lc_collate_cp
+# extern __lc_collate_cp
--- wine/dlls/msvcrt/file.c	2004-12-09 19:07:26.000000000 +0100
+++ mywine/dlls/msvcrt/file.c	2004-12-10 13:05:33.000000000 +0100
@@ -60,12 +60,16 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
 #define WX_APPEND         0x20
 #define WX_TEXT           0x80
 
+/* FIXME: this should be allocated dynamically */
 #define MSVCRT_MAX_FILES 2048
 
-static struct {
+typedef struct {
     HANDLE              handle;
     unsigned char       wxflag;
-} MSVCRT_fdesc[MSVCRT_MAX_FILES];
+    DWORD               unkn[7]; /* critical section and init flag */       
+} ioinfo;
+
+ioinfo MSVCRT_fdesc[MSVCRT_MAX_FILES];
 
 MSVCRT_FILE MSVCRT__iob[3];
 
@@ -2888,3 +2892,26 @@ int MSVCRT_wprintf(const MSVCRT_wchar_t 
     va_end(valist);
     return res;
 }
+
+/*********************************************************************
+ *		__pioinfo (MSVCRT.@)
+ * FIXME: see MSVCRT_MAX_FILES define.
+ */
+ioinfo * MSVCRT___pioinfo[] = { /* array of pointers to ioinfo arrays [64] */
+    &MSVCRT_fdesc[0 * 64], &MSVCRT_fdesc[1 * 64], &MSVCRT_fdesc[2 * 64],
+    &MSVCRT_fdesc[3 * 64], &MSVCRT_fdesc[4 * 64], &MSVCRT_fdesc[5 * 64],
+    &MSVCRT_fdesc[6 * 64], &MSVCRT_fdesc[7 * 64], &MSVCRT_fdesc[8 * 64],
+    &MSVCRT_fdesc[9 * 64], &MSVCRT_fdesc[10 * 64], &MSVCRT_fdesc[11 * 64],
+    &MSVCRT_fdesc[12 * 64], &MSVCRT_fdesc[13 * 64], &MSVCRT_fdesc[14 * 64],
+    &MSVCRT_fdesc[15 * 64], &MSVCRT_fdesc[16 * 64], &MSVCRT_fdesc[17 * 64],
+    &MSVCRT_fdesc[18 * 64], &MSVCRT_fdesc[19 * 64], &MSVCRT_fdesc[20 * 64],
+    &MSVCRT_fdesc[21 * 64], &MSVCRT_fdesc[22 * 64], &MSVCRT_fdesc[23 * 64],
+    &MSVCRT_fdesc[24 * 64], &MSVCRT_fdesc[25 * 64], &MSVCRT_fdesc[26 * 64],
+    &MSVCRT_fdesc[27 * 64], &MSVCRT_fdesc[28 * 64], &MSVCRT_fdesc[29 * 64],
+    &MSVCRT_fdesc[30 * 64], &MSVCRT_fdesc[31 * 64]
+} ;
+
+/*********************************************************************
+ *		__badioinfo (MSVCRT.@)
+ */
+ioinfo MSVCRT___badioinfo = { INVALID_HANDLE_VALUE, WX_TEXT };
--- wine/dlls/msvcrt/main.c	2004-11-09 08:31:32.000000000 +0100
+++ mywine/dlls/msvcrt/main.c	2004-12-10 11:30:02.000000000 +0100
@@ -117,4 +117,13 @@ const char* msvcrt_get_reason(DWORD reas
 void MSVCRT_I10_OUTPUT(void)
 {
   /* FIXME: This is probably data, not a function */
+  /* no it is a function. I10 is an Int of 10 bytes */
+  /* also known as 80 bit flotaing point (long double */
+  /* for some compilers, not MSVC) */
 }
+
+/*********************************************************************
+ *		_adjust_fdiv (MSVCRT.@)
+ * Used by the MSVC compiler to work around the Pentium FDIV bug;
+ */
+int MSVCRT__adjust_fdiv;


More information about the wine-patches mailing list