Release 970629

Thu Jun 26 02:14:03 1997  Slaven Rezic  <eserte@cs.tu-berlin.de>

	* [Makefile.in]
	New target install_includes.

	* [rc/parser.h] [rc/parser.y] [rc/winerc.c]
	Some bug fixes.

Wed Jun 25 14:43:41 1997  Victor Schneider <vischne@ibm.net>

	* [controls/edit.c]
	Fixed WM_GETTEXT return value.

Tue Jun 24 23:46:04 1997  Michiel van Loon <mfvl@xs4all.nl>

	* [multimedia/*.c] [include/mmsystem.h]
	Added more callback code, including (I hope) function callback.
	Changed some linear pointers into segmented.

	* [multimedia/audio.c]
	Removed some bugs.

Sat Jun 28 11:37:56 1997  Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>

	* [if1632/commdlg.spec][if1632/comdlg32.spec][misc/commdlg.c]
	  [include/commdlg.h]
	Implemented parts of comdlg32: GetOpenFileName32*,
	GetSaveFileName32*, GetFileTitle32* using the 16 bit equivalents.

	* [windows/event.c]
	EVENT_QueryZOrder: check for children !=NULL (happens when
	using -managed).

	* [BUGS][DEVELOPER-HINTS]
	Updated.

	* [objects/text.c]
	Added GetTextCharset... (stub mostly).

Sat Jun 21 08:47:58 1997  Philippe De Muyter  <phdm@info.ucl.ac.be>

	* [if1632/kernel.spec] [if1632/gdi.spec] [include/windows.h]
	  [loader/resource.c] [graphics/x11drv/xfont.c]
	SetResourceHandler & RemoveFontResource prototypes fixed.

	* [if1632/relay.c] [if1632/kernel.spec] [if1632/user.spec]
	  [if1632/olesvr.spec] [if1632/commdlg.spec] [if1632/ddeml.spec]
	  [if1632/gdi.spec] [if1632/lzexpand.spec] [if1632/shell.spec]
	  [include/windows.h] [memory/string.c] [tools/build.c]
	New type of parameter allowed in .spec files : str, printed
	as a string with -debugmsg +relay. .spec files updated.

	* [objects/dc.c]
	In DC_SetupGCForPen, call BlackPixelOfScreen, not BlackPixel.
	Likewise for WhitePixel.

	* [objects/gdiobj.c] [graphics/x11drv/brush.c]
	Use BS_HATCHED with an added entry in HatchBrushes for DkGrayBrush,
 	instead of BS_SOLID.

Fri May 30 17:58:00 1997  Chris Faherty <chrisf@america.com>

	* [windows/keyboard.c]
	Added vkey to scancode translation table.
	This was primarily to fix Citrix WinFrame client which
	always needs scancodes in WM_KEYDOWN.
	Tested with Exceed 5.1.0.1 & XFree86 3.1.2.
diff --git a/ANNOUNCE b/ANNOUNCE
index 20b0e35..3a4afcc 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,16 +1,13 @@
-This is release 970616 of Wine, the MS Windows emulator.  This is still a
+This is release 970629 of Wine, the MS Windows emulator.  This is still a
 developer's only release.  There are many bugs and many unimplemented API
 features.  Most applications still do not work correctly.
 
 Patches should be submitted to "julliard@lrc.epfl.ch".  Please don't
 forget to include a ChangeLog entry.
 
-WHAT'S NEW with Wine-970616: (see ChangeLog for details)
-	- More improvements to multimedia code.
-	- New font mapper.
-	- Icon titles.
-	- Print spooling.
-	- Direct I/O ports access.
+WHAT'S NEW with Wine-970629: (see ChangeLog for details)
+	- Start of COMDLG32 implementation.
+	- Relay debugging knows about strings.
 	- Lots of bug fixes.
 
 See the README file in the distribution for installation instructions.
@@ -19,10 +16,10 @@
 the release is available at the ftp sites.  The sources will be available
 from the following locations:
 
-  ftp://sunsite.unc.edu/pub/Linux/ALPHA/wine/development/Wine-970616.tar.gz
-  ftp://tsx-11.mit.edu/pub/linux/ALPHA/Wine/development/Wine-970616.tar.gz
-  ftp://ftp.infomagic.com/pub/mirrors/linux/wine/development/Wine-970616.tar.gz
-  ftp://ftp.progsoc.uts.edu.au/pub/Wine/development/Wine-970616.tar.gz
+  ftp://sunsite.unc.edu/pub/Linux/ALPHA/wine/development/Wine-970629.tar.gz
+  ftp://tsx-11.mit.edu/pub/linux/ALPHA/Wine/development/Wine-970629.tar.gz
+  ftp://ftp.infomagic.com/pub/mirrors/linux/wine/development/Wine-970629.tar.gz
+  ftp://ftp.progsoc.uts.edu.au/pub/Wine/development/Wine-970629.tar.gz
 
 It should also be available from any site that mirrors tsx-11 or sunsite.
 
diff --git a/BUGS b/BUGS
index f706ac6..473e87e 100644
--- a/BUGS
+++ b/BUGS
@@ -11,7 +11,7 @@
 
  * TrueType, .FON rasterizer.
 
- * No thread/process/kernel-object support in Win32 code. 
+ * No thread/process scheduling support in Win32 code. 
 
  * Very alpha printing code. [john@division.co.uk]
 
@@ -20,23 +20,19 @@
  * No MS Video support (perhaps interface with xanim, don't hold
    your breath for this one).
 
- * No COMDLG32 support. (Needed badly, the Windows95 comdlg32.dll
-   doesn't work with WINE.)
+ * COMDLG32 support not complete yet.
 
  * No COMMCTRL/COMCTL32 support.
 
- * No icon titles.
-	- Windows uses a special window class to display icon titles.
-	  Handles to these title windows are stored in the icon window
-	  properties.
-
  * No manual pages describing the various Windows calls.
 	- You can find information about most of the Win32 API calls
           on the www.microsoft.com (go to 'search').
 
 Miscellaneous:
 
- * New font mapping scheme can be improved.
+ * Text alignment problems in Word and Write (variable pitch fonts).
+
+ * Font mapper weights
 
  * "Cursor XXXX has more than 1 bpp!"
 
diff --git a/ChangeLog b/ChangeLog
index f8b8b96..50fa2fe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,73 @@
 ----------------------------------------------------------------------
+Thu Jun 26 02:14:03 1997  Slaven Rezic  <eserte@cs.tu-berlin.de>
+
+	* [Makefile.in]
+	New target install_includes.
+
+	* [rc/parser.h] [rc/parser.y] [rc/winerc.c]
+	Some bug fixes.
+
+Wed Jun 25 14:43:41 1997  Victor Schneider <vischne@ibm.net>
+
+	* [controls/edit.c]
+	Fixed WM_GETTEXT return value.
+
+Tue Jun 24 23:46:04 1997  Michiel van Loon <mfvl@xs4all.nl>
+
+	* [multimedia/*.c] [include/mmsystem.h]
+	Added more callback code, including (I hope) function callback.
+	Changed some linear pointers into segmented.
+
+	* [multimedia/audio.c]
+	Removed some bugs.
+
+Sat Jun 28 11:37:56 1997  Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>
+
+	* [if1632/commdlg.spec][if1632/comdlg32.spec][misc/commdlg.c]
+	  [include/commdlg.h]
+	Implemented parts of comdlg32: GetOpenFileName32*,
+	GetSaveFileName32*, GetFileTitle32* using the 16 bit equivalents.
+
+	* [windows/event.c]
+	EVENT_QueryZOrder: check for children !=NULL (happens when
+	using -managed).
+
+	* [BUGS][DEVELOPER-HINTS]
+	Updated.
+
+	* [objects/text.c]
+	Added GetTextCharset... (stub mostly).
+
+Sat Jun 21 08:47:58 1997  Philippe De Muyter  <phdm@info.ucl.ac.be>
+
+	* [if1632/kernel.spec] [if1632/gdi.spec] [include/windows.h]
+	  [loader/resource.c] [graphics/x11drv/xfont.c]
+	SetResourceHandler & RemoveFontResource prototypes fixed.
+
+	* [if1632/relay.c] [if1632/kernel.spec] [if1632/user.spec]
+	  [if1632/olesvr.spec] [if1632/commdlg.spec] [if1632/ddeml.spec]
+	  [if1632/gdi.spec] [if1632/lzexpand.spec] [if1632/shell.spec]
+	  [include/windows.h] [memory/string.c] [tools/build.c]
+	New type of parameter allowed in .spec files : str, printed
+	as a string with -debugmsg +relay. .spec files updated.
+
+	* [objects/dc.c]
+	In DC_SetupGCForPen, call BlackPixelOfScreen, not BlackPixel.
+	Likewise for WhitePixel.
+
+	* [objects/gdiobj.c] [graphics/x11drv/brush.c]
+	Use BS_HATCHED with an added entry in HatchBrushes for DkGrayBrush,
+ 	instead of BS_SOLID.
+
+Fri May 30 17:58:00 1997  Chris Faherty <chrisf@america.com>
+
+	* [windows/keyboard.c]
+	Added vkey to scancode translation table.
+	This was primarily to fix Citrix WinFrame client which
+	always needs scancodes in WM_KEYDOWN.
+	Tested with Exceed 5.1.0.1 & XFree86 3.1.2.
+
+----------------------------------------------------------------------
 Sat Jun 14 13:05:23 1997  Andreas Mohr <100.30936@germany.net>
 
 	* [include/mmsystem.h]
diff --git a/DEVELOPERS-HINTS b/DEVELOPERS-HINTS
index 14b47e1..7f68ba4 100644
--- a/DEVELOPERS-HINTS
+++ b/DEVELOPERS-HINTS
@@ -243,9 +243,12 @@
 MORE INFO
 =========
 
-1. http://www.sonic.net/~undoc/bookstore.html
+1. There is a FREE online version of the MSDN library (including
+   documentation for the Win32 API) on http://www.microsoft.com/msdn/
 
-2. In 1993 Dr. Dobbs Journal published a column called "Undocumented Corner".
+2. http://www.sonic.net/~undoc/bookstore.html
 
-3. You might want to check out BYTE from December 1983 as well :-)
+3. In 1993 Dr. Dobbs Journal published a column called "Undocumented Corner".
+
+4. You might want to check out BYTE from December 1983 as well :-)
 
diff --git a/Makefile.in b/Makefile.in
index 039c741..c62eb54 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -23,6 +23,7 @@
 AR        = ar rc
 RANLIB    = @RANLIB@
 RM        = rm -f
+MKDIR     = mkdir
 SUBMAKE   = $(MAKE) 'CC=$(CC)' 'CFLAGS=$(CFLAGS)' 'OPTIONS=$(OPTIONS)'
 @SET_MAKE@
 
@@ -37,6 +38,7 @@
 libdir          = @libdir@
 mandir          = @mandir@/man1
 manext          = .1
+includedir      = @includedir@/wine
 
 # Main target to build
 
@@ -118,15 +120,19 @@
 	$(AR) $@ $(COMMONOBJS) $(LIBOBJS)
 	$(RANLIB) $@
 
-install_libwine.a: dummy
+install_libwine.a: install_includes
 	$(INSTALL_DATA) libwine.a $(libdir)
 
 libwine.so.1.0: $(COMMONSUBDIRS) $(LIBSUBDIRS) dummy
 	$(CC) -shared -Wl,-soname,libwine.so -o$@ $(COMMONOBJS) $(LIBOBJS) $(LDOPTIONS) $(X_LIBS) $(XPM_LIB) $(XLIB) $(LDLIBS)
 
-install_libwine.so.1.0: dummy
+install_libwine.so.1.0: install_includes
 	$(INSTALL_DATA) libwine.so.1.0 $(libdir)
 
+install_includes: dummy
+	if [ -d $(includedir) ]; then : ; else $(MKDIR) $(includedir); fi 
+	cd include; $(INSTALL_DATA) windows.h wintypes.h $(includedir)
+
 $(ALLSUBDIRS): dummy
 	@cd $@; $(SUBMAKE)
 
@@ -143,9 +149,8 @@
 
 clean:
 	for i in $(ALLSUBDIRS); do (cd $$i; $(MAKE) clean) || exit 1; done
-	$(RM) *.o \#*\# *~ *.bak *.orig *.rej *.flc
+	for i in . include documentation; do (cd $$i; $(RM) *.o \#*\# *~ *.bak *.orig *.rej *.flc); done
 	$(RM) wine wine.sym libwine.a libwine.so.1.0 TAGS
-	(cd include; $(RM) *.o \#*\# *~ *.bak *.orig *.rej *.flc)
 
 distclean: clean
 	$(RM) config.* Make.rules include/config.h
diff --git a/controls/edit.c b/controls/edit.c
index f557b62..707bc69 100644
--- a/controls/edit.c
+++ b/controls/edit.c
@@ -3078,9 +3078,9 @@
 
 	if (count > len) {
 		lstrcpy32A(text, es->text);
-		return len + 1;
+		return len;
 	} else
-		return 0;
+		return -1;
 }
 
 
diff --git a/controls/listbox.c b/controls/listbox.c
index 516fb24..71f56be 100644
--- a/controls/listbox.c
+++ b/controls/listbox.c
@@ -1731,9 +1731,12 @@
     if (LISTBOX_Timer != LB_TIMER_NONE)
         KillSystemTimer32( wnd->hwndSelf, LB_TIMER_ID );
     LISTBOX_Timer = LB_TIMER_NONE;
-    if (GetCapture32() == wnd->hwndSelf) ReleaseCapture();
-    if (descr->style & LBS_NOTIFY)
-        SEND_NOTIFICATION( wnd, descr, LBN_SELCHANGE );
+    if (GetCapture32() == wnd->hwndSelf)
+    {
+        ReleaseCapture();
+        if (descr->style & LBS_NOTIFY)
+            SEND_NOTIFICATION( wnd, descr, LBN_SELCHANGE );
+    }
     return 0;
 }
 
diff --git a/documentation/fonts b/documentation/fonts
index 3237613..00ef738 100644
--- a/documentation/fonts
+++ b/documentation/fonts
@@ -4,8 +4,8 @@
 
 If you have access to Windows installation you should use 
 fnt2bdf utility (found in the 'tools)' directory to convert
-bitmap fonts (SYSTEM.FON, SSERIFE.FON, and SERIFE.FON) into 
-the format that X Window System can recognize.
+bitmap fonts (VGASYS.FON, SSERIFE.FON, and SERIFE.FON) into 
+the format that X Window System can recognize. 
 
 Step 1. Extract bitmap fonts with 'fnt2bdf'.
 
@@ -14,14 +14,25 @@
 
 Step 3. Copy .pcf files to the font server directory which
 	is usually /usr/lib/X11/fonts/misc (you will probably 
-        need superuser privileges).
+        need superuser privileges). If you want to create a new
+	font directory you will need to add it to the font path.
 
 Step 4. Run 'mkfontdir' for the directory you copied fonts to.
 	If you are already in X you should run 'xset fp rehash' 
         to make X server aware of the new fonts.
 
+Step 5. Edit wine.conf file to remove aliases for the fonts 
+	you've just installed.
+
 Wine can get by without these fonts but 'the look and feel'
-will be quite different. 
+will be quite different. Also, some applications try to load
+their custom fonts on the fly (WinWord 6.0) and since Wine does
+not implement this yet it instead prints out something like;
+
+STUB: AddFontResource( somefile.FON )
+
+You can convert this file too. Note that .FON file may not hold 
+any bitmap fonts and fnt2bdf will fail if this is the case.
 
 What to do with TrueType fonts? There are several commercial
 font tools that can convert them to the Type1 format but the 
@@ -87,7 +98,9 @@
 in the fonts.dir.  Therefore WINE uses the following entry to determine 
 which font to check first.
 
-Default = ...
+Example:
+
+Default = -adobe-times-
 
 Comments:
     It is better to have a scalable font family (bolds and italics included) 
diff --git a/graphics/x11drv/brush.c b/graphics/x11drv/brush.c
index 62bc41f..1fe88da 100644
--- a/graphics/x11drv/brush.c
+++ b/graphics/x11drv/brush.c
@@ -12,14 +12,15 @@
 #include "stddebug.h"
 #include "debug.h"
 
-static const char HatchBrushes[NB_HATCH_STYLES][8] =
+static const char HatchBrushes[NB_HATCH_STYLES + 1][8] =
 {
     { 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00 }, /* HS_HORIZONTAL */
     { 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08 }, /* HS_VERTICAL   */
     { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }, /* HS_FDIAGONAL  */
     { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }, /* HS_BDIAGONAL  */
     { 0x08, 0x08, 0x08, 0xff, 0x08, 0x08, 0x08, 0x08 }, /* HS_CROSS      */
-    { 0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81 }  /* HS_DIAGCROSS  */
+    { 0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81 }, /* HS_DIAGCROSS  */
+    { 0xee, 0xbb, 0xee, 0xbb, 0xee, 0xbb, 0xee, 0xbb }  /* Hack for DKGRAY */
 };
 
   /* Levels of each primary for dithering */
diff --git a/graphics/x11drv/text.c b/graphics/x11drv/text.c
index cc7249d..0b90d62 100644
--- a/graphics/x11drv/text.c
+++ b/graphics/x11drv/text.c
@@ -107,20 +107,17 @@
 
       /* Compute text starting position */
 
-    XTextExtents( font, str, count, &dir, &ascent, &descent, &info );
-
-    if (lpDx) /* have explicit character cell x offsets */
+    if (lpDx) /* have explicit character cell x offsets in logical coordinates */
     {
-	/* sum lpDx array and add the width of last character */
-
-        info.width = XTextWidth( font, str + count - 1, 1) + dc->w.charExtra;
-        if (str[count-1] == dfBreakChar)
-            info.width += dc->w.breakExtra;
-
-        for (i = 0; i < count; i++) info.width += lpDx[i];
+	int extra = dc->wndExtX / 2;
+        for (i = info.width = 0; i < count; i++) info.width += lpDx[i];
+	info.width = (info.width * dc->vportExtX + extra ) / dc->wndExtX;
     }
     else
-       info.width += count*dc->w.charExtra + dc->w.breakExtra*dc->w.breakCount;
+    {
+	XTextExtents( font, str, count, &dir, &ascent, &descent, &info );
+        info.width += count*dc->w.charExtra + dc->w.breakExtra*dc->w.breakCount;
+    }
 
     switch( dc->w.textAlign & (TA_LEFT | TA_RIGHT | TA_CENTER) )
     {
@@ -200,32 +197,50 @@
 
         pitem = items = xmalloc( count * sizeof(XTextItem) );
         delta = i = 0;
-        while (i < count)
-        {
-	    /* initialize text item with accumulated delta */
+	if( lpDx ) /* explicit character widths */
+	{
+	    int extra = dc->wndExtX / 2;
 
-            pitem->chars  = (char *)str + i;
-	    pitem->delta  = delta; 
-            pitem->nchars = 0;
-            pitem->font   = None;
-            delta = 0;
+	    while (i < count)
+	    {
+		/* initialize text item with accumulated delta */
 
-	    /* stuff characters into the same XTextItem until new delta 
-	     * becomes  non-zero */
+		pitem->chars  = (char *)str + i;
+		pitem->delta  = delta;
+		pitem->nchars = 0;
+		pitem->font   = None;
+		delta = 0;
 
-	    do
+		/* add characters  to the same XTextItem until new delta
+		 * becomes  non-zero */
+
+		do
+		{
+		    delta += (lpDx[i] * dc->vportExtX + extra) / dc->wndExtX
+					    - XTextWidth( font, str + i, 1);
+		    pitem->nchars++;
+		} while ((++i < count) && !delta);
+		pitem++;
+	   }
+	}
+	else /* charExtra or breakExtra */
+	{
+            while (i < count)
             {
-                if (lpDx) delta += lpDx[i] - XTextWidth( font, str + i, 1);
-                else
+		pitem->chars  = (char *)str + i;
+		pitem->delta  = delta;
+		pitem->nchars = 0;
+		pitem->font   = None;
+		delta = 0;
+
+		do
                 {
                     delta += dc->w.charExtra;
-                    if (str[i] == (char)dfBreakChar)
-                        delta += dc->w.breakExtra;
-                }
-                pitem->nchars++;
+                    if (str[i] == (char)dfBreakChar) delta += dc->w.breakExtra;
+		    pitem->nchars++;
+                } while ((++i < count) && !delta);
+		pitem++;
             } 
-	    while ((++i < count) && !delta);
-            pitem++;
         }
 
         XDrawText( display, dc->u.x.drawable, dc->u.x.gc,
diff --git a/graphics/x11drv/xfont.c b/graphics/x11drv/xfont.c
index 60aa82f..f12d89f 100644
--- a/graphics/x11drv/xfont.c
+++ b/graphics/x11drv/xfont.c
@@ -606,6 +606,7 @@
 
     pTM->tmCharSet = pdf->dfCharSet;
     pTM->tmPitchAndFamily = pdf->dfPitchAndFamily;
+
     pTM->tmDigitizedAspectX = pdf->dfHorizRes;
     pTM->tmDigitizedAspectY = pdf->dfVertRes;
 }
@@ -1147,10 +1148,10 @@
 
 	if( !fr ) /* add new family */
 	{
-	   if( n_ff++ > MAX_FONT_FAMILIES ) break;
-
+	   if( n_ff >= MAX_FONT_FAMILIES ) break;
 	   if( !LFD_InitFontInfo( fi, lpstr) ) continue;
 
+	   n_ff++;
 	   fr = (fontResource*) HeapAlloc(SystemHeap, 0, sizeof(fontResource)); 
 	   memset(fr, 0, sizeof(fontResource));
 	   fr->resource = (char*) HeapAlloc(SystemHeap, 0, j + 1 );
@@ -1318,8 +1319,11 @@
 
    pfm->flags = 0;
 
-   if( plf->lfCharSet != DEFAULT_CHARSET &&
-       plf->lfCharSet != pfi->df.dfCharSet ) penalty += 0x200;
+   if( plf->lfCharSet == DEFAULT_CHARSET )
+   {
+       if( (pfi->df.dfCharSet!= ANSI_CHARSET) && (pfi->df.dfCharSet!=DEFAULT_CHARSET) ) penalty += 0x200;
+   }
+   else if (plf->lfCharSet != pfi->df.dfCharSet) penalty += 0x200;
 
    /* TMPF_FIXED_PITCH means exactly the opposite */
 
@@ -1937,7 +1941,7 @@
 		    cs = &xfs->per_char[(i - xfs->min_char_or_byte2)]; 
 		    if (CI_NONEXISTCHAR(cs)) cs = def; 
   		} else cs = def;
-		*buffer++ = MAX( cs->width, 0 );
+		*buffer++ = MAX(cs->width, 0 );
 	    }
 	}
 	return TRUE;
@@ -1993,9 +1997,14 @@
 /***********************************************************************
  *           RemoveFontResource16    (GDI.136)
  */
-BOOL16 RemoveFontResource16( LPCSTR str )
+BOOL16 RemoveFontResource16( SEGPTR str )
 {
-    return RemoveFontResource32A( str );
+    if (HIWORD(str))
+        fprintf( stdnimp, "STUB: RemoveFontResource('%s')\n",
+		(char *)PTR_SEG_TO_LIN( str) );
+    else
+        fprintf( stdnimp, "STUB: RemoveFontResource(%04x)\n", LOWORD(str) );
+    return TRUE;
 }
 
 
diff --git a/if1632/advapi32.spec b/if1632/advapi32.spec
index 4a88641..7920995 100644
--- a/if1632/advapi32.spec
+++ b/if1632/advapi32.spec
@@ -12,7 +12,7 @@
 0007 stub AddAce
 0008 stub AddAuditAccessAce
 0009 stub AdjustTokenGroups
-0010 stub AdjustTokenPrivileges
+0010 stdcall AdjustTokenPrivileges(long long ptr long ptr ptr) AdjustTokenPrivileges
 0011 stdcall AllocateAndInitializeSid(ptr long long long long long long long long long ptr) AllocateAndInitializeSid
 0012 stdcall AllocateLocallyUniqueId(ptr) AllocateLocallyUniqueId
 0013 stub AreAllAccessesGranted
@@ -94,7 +94,7 @@
 0089 stub LookupPrivilegeDisplayNameW
 0090 stub LookupPrivilegeNameA
 0091 stub LookupPrivilegeNameW
-0092 stub LookupPrivilegeValueA
+0092 stdcall LookupPrivilegeValueA(ptr ptr ptr) LookupPrivilegeValue32A
 0093 stub LookupPrivilegeValueW
 0094 stub MakeAbsoluteSD
 0095 stub MakeSelfRelativeSD
diff --git a/if1632/builtin.c b/if1632/builtin.c
index 288e363..1675687 100644
--- a/if1632/builtin.c
+++ b/if1632/builtin.c
@@ -148,7 +148,7 @@
     /* Win32 DLLs */
     { &ADVAPI32_Descriptor, 0 },
     { &COMCTL32_Descriptor, DLL_FLAG_NOT_USED },
-    { &COMDLG32_Descriptor, DLL_FLAG_NOT_USED },
+    { &COMDLG32_Descriptor, 0 },
     { &CRTDLL_Descriptor,   0 },
     { &OLE32_Descriptor,    DLL_FLAG_NOT_USED },
     { &GDI32_Descriptor,    0 },
diff --git a/if1632/comdlg32.spec b/if1632/comdlg32.spec
index b6fa002..a42e1a1 100644
--- a/if1632/comdlg32.spec
+++ b/if1632/comdlg32.spec
@@ -7,15 +7,15 @@
 0002 stub ChooseColorW
 0003 stub ChooseFontA
 0004 stub ChooseFontW
-0005 stub CommDlgExtendedError
+0005 stdcall CommDlgExtendedError() CommDlgExtendedError
 0006 stub FindTextA
 0007 stub FindTextW
-0008 stub GetFileTitleA
-0009 stub GetFileTitleW
-0010 stub GetOpenFileNameA
-0011 stub GetOpenFileNameW
-0012 stub GetSaveFileNameA
-0013 stub GetSaveFileNameW
+0008 stdcall GetFileTitleA(ptr ptr long) GetFileTitle32A
+0009 stdcall GetFileTitleW(ptr ptr long) GetFileTitle32W
+0010 stdcall GetOpenFileNameA(ptr) GetOpenFileName32A
+0011 stdcall GetOpenFileNameW(ptr) GetOpenFileName32W
+0012 stdcall GetSaveFileNameA(ptr) GetSaveFileName32A
+0013 stdcall GetSaveFileNameW(ptr) GetSaveFileName32A
 0014 stub LoadAlterBitmap
 0015 stub PageSetupDlgA
 0016 stub PageSetupDlgW
diff --git a/if1632/commdlg.spec b/if1632/commdlg.spec
index 5eb6181..1a705ea 100644
--- a/if1632/commdlg.spec
+++ b/if1632/commdlg.spec
@@ -1,8 +1,8 @@
 name	commdlg
 type	win16
 
-1   pascal16 GetOpenFileName(segptr) GetOpenFileName
-2   pascal16 GetSaveFileName(segptr) GetSaveFileName
+1   pascal16 GetOpenFileName(segptr) GetOpenFileName16
+2   pascal16 GetSaveFileName(segptr) GetSaveFileName16
 5   pascal16 ChooseColor(ptr) ChooseColor
 6   pascal   FileOpenDlgProc(word word word long) FileOpenDlgProc
 7   pascal   FileSaveDlgProc(word word word long) FileSaveDlgProc
@@ -22,7 +22,7 @@
 #23  pascal  EDITINTEGERONLY exported, shared data
 #25  pascal  WANTARROWS exported, shared data
 26  pascal   CommDlgExtendedError() CommDlgExtendedError
-27  pascal16 GetFileTitle(ptr ptr word) GetFileTitle
+27  pascal16 GetFileTitle(str ptr word) GetFileTitle16
 #28  pascal  WEP exported, shared data
 #29  pascal  DWLBSUBCLASS exported, shared data
 #30  pascal  DWUPARROWHACK exported, shared data
diff --git a/if1632/crtdll.spec b/if1632/crtdll.spec
index 7e43ce9..42a8805 100644
--- a/if1632/crtdll.spec
+++ b/if1632/crtdll.spec
@@ -431,7 +431,7 @@
 426 stub longjmp
 427 cdecl malloc(ptr) CRTDLL_malloc
 428 stub mblen
-429 stub mbstowcs
+429 cdecl mbstowcs(ptr ptr long) CRTDLL_mbstowcs
 430 cdecl mbtowc(long) CRTDLL_mbtowc
 431 cdecl memchr(ptr long long) memchr
 432 cdecl memcmp(ptr ptr long) memcmp
diff --git a/if1632/ddeml.spec b/if1632/ddeml.spec
index 12c1420..8da729c 100644
--- a/if1632/ddeml.spec
+++ b/if1632/ddeml.spec
@@ -20,9 +20,9 @@
 18 stub DdeUnaccessData #(word) DdeUnaccessData
 19 stub DdeFreeDataHandle #(word) DdeFreeDataHandle
 20 stub DdeGetLastError #(long) DdeGetLastError
-21 stub DdeCreateStringHandle #(long ptr word) DdeCreateStringHandle
+21 stub DdeCreateStringHandle #(long str word) DdeCreateStringHandle
 22 stub DdeFreeStringHandle #(long word) DdeFreeStringHandle
-23 stub   DdeQueryString #(long word ptr long word) DdeQueryString
+23 stub DdeQueryString #(long word ptr long word) DdeQueryString
 24 stub DdeKeepStringHandle #(long word) DdeKeepStringHandle
 
 26 stub DdeEnableCallback #(long word word) DdeEnableCallback
diff --git a/if1632/dummy.c b/if1632/dummy.c
index cb0758e..abc792e 100644
--- a/if1632/dummy.c
+++ b/if1632/dummy.c
@@ -44,3 +44,4 @@
 long stub_USER_920(void) { fprintf(stderr, "Warning: USER_920: unimplemented stub\n"); return 0; }
 long stub_USER_922(void) { fprintf(stderr, "Warning: USER_922: unimplemented stub\n"); return 0; }
 long stub_USER_923(void) { fprintf(stderr, "Warning: USER_923: unimplemented stub\n"); return 0; }
+long stub_KERNEL_700(void) { fprintf(stderr, "Warning: KERNEL_700: unimplemented stub\n"); return 1; }
diff --git a/if1632/gdi.spec b/if1632/gdi.spec
index 4db37d0..f1ef2bd 100644
--- a/if1632/gdi.spec
+++ b/if1632/gdi.spec
@@ -63,7 +63,7 @@
 54  pascal16 CreateEllipticRgn(s_word s_word s_word s_word) CreateEllipticRgn16
 55  pascal16 CreateEllipticRgnIndirect(ptr) CreateEllipticRgnIndirect16
 56  pascal16 CreateFont(s_word s_word s_word s_word s_word word word word
-                        word word word word word ptr) CreateFont16
+                        word word word word word str) CreateFont16
 57  pascal16 CreateFontIndirect(ptr) CreateFontIndirect16
 58  pascal16 CreateHatchBrush(word long) CreateHatchBrush16
 60  pascal16 CreatePatternBrush(word) CreatePatternBrush16
@@ -76,7 +76,7 @@
 67  pascal16 DPtoLP(word ptr s_word) DPtoLP16
 68  pascal16 DeleteDC(word) DeleteDC16
 69  pascal16 DeleteObject(word) DeleteObject16
-70  pascal16 EnumFonts(word ptr segptr long) THUNK_EnumFonts16
+70  pascal16 EnumFonts(word str segptr long) THUNK_EnumFonts16
 71  pascal16 EnumObjects(word word segptr long) THUNK_EnumObjects16
 72  pascal16 EqualRgn(word word) EqualRgn16
 73  pascal16 ExcludeVisRect(word s_word s_word s_word s_word) ExcludeVisRect
@@ -115,28 +115,28 @@
 105 pascal16 SelectVisRgn(word word) SelectVisRgn
 106 pascal SetBitmapBits(word long ptr) SetBitmapBits16
 117 pascal SetDCOrg(word s_word s_word) SetDCOrg
-119 pascal16 AddFontResource(ptr) AddFontResource16
+119 pascal16 AddFontResource(str) AddFontResource16
 #121 pascal Death
 #122 pascal ReSurRection
 123 pascal16 PlayMetaFile(word word) PlayMetaFile16
-124 pascal16 GetMetaFile(ptr) GetMetaFile16
-125 pascal16 CreateMetaFile(ptr) CreateMetaFile16
+124 pascal16 GetMetaFile(str) GetMetaFile16
+125 pascal16 CreateMetaFile(str) CreateMetaFile16
 126 pascal16 CloseMetaFile(word) CloseMetaFile16
 127 pascal16 DeleteMetaFile(word) DeleteMetaFile16
 128 pascal16 MulDiv(s_word s_word s_word) MulDiv16
 129 pascal16 SaveVisRgn(word) SaveVisRgn
 130 pascal16 RestoreVisRgn(word) RestoreVisRgn
 131 pascal16 InquireVisRgn(word) InquireVisRgn
-132 pascal16 SetEnvironment(ptr ptr word) SetEnvironment
-133 pascal16 GetEnvironment(ptr ptr word) GetEnvironment
+132 pascal16 SetEnvironment(str str word) SetEnvironment
+133 pascal16 GetEnvironment(str str word) GetEnvironment
 134 pascal16 GetRgnBox(word ptr) GetRgnBox16
 #135 pascal ScanLr
-136 pascal16 RemoveFontResource(ptr) RemoveFontResource16
+136 pascal16 RemoveFontResource(segptr) RemoveFontResource16
 148 pascal SetBrushOrg(word s_word s_word) SetBrushOrg
 149 pascal GetBrushOrg(word) GetBrushOrg
 150 pascal16 UnrealizeObject(word) UnrealizeObject16
-151 pascal16 CopyMetaFile(word ptr) CopyMetaFile16
-153 pascal16 CreateIC(ptr ptr ptr ptr) CreateIC16
+151 pascal16 CopyMetaFile(word str) CopyMetaFile16
+153 pascal16 CreateIC(str str str ptr) CreateIC16
 154 pascal   GetNearestColor(word long) GetNearestColor16
 155 stub QueryAbort
 156 pascal16 CreateDiscardableBitmap(word word word) CreateDiscardableBitmap16
@@ -219,7 +219,7 @@
 307 pascal16 GetCharABCWidths(word word word ptr) GetCharABCWidths16
 308 stub GetOutLineTextMetrics
 309 pascal   GetGlyphOutline(word word word ptr long ptr ptr) GetGlyphOutline16
-310 pascal16 CreateScalableFontResource(word ptr ptr ptr) CreateScalableFontResource16
+310 pascal16 CreateScalableFontResource(word str str str) CreateScalableFontResource16
 311 stub GetFontData
 312 stub ConvertOutLineFontFile
 313 pascal16 GetRasterizerCaps(ptr word) GetRasterizerCaps16
@@ -227,7 +227,7 @@
 315 stub EngineRealizeFontExt
 316 stub EngineGetCharWidthStr
 317 stub EngineGetGlyphBmpExt
-330 pascal16 EnumFontFamilies(word ptr segptr long) THUNK_EnumFontFamilies16
+330 pascal16 EnumFontFamilies(word str segptr long) THUNK_EnumFontFamilies16
 332 pascal16 GetKerningPairs(word word ptr) GetKerningPairs16
 345 pascal16 GetTextAlign(word) GetTextAlign16
 346 pascal16 SetTextAlign(word word) SetTextAlign16
@@ -380,7 +380,7 @@
 609 stub GDIFreeResources
 610 stub GDISignalProc32
 611 stub GetRandomRgn
-612 stub GetTextCharSet
+612 pascal16 GetTextCharset(word) GetTextCharset16
 613 pascal16 EnumFontFamiliesEx(word ptr segptr long long) THUNK_EnumFontFamiliesEx16
 614 stub AddLpkToGDI
 615 stub GetCharacterPlacement
diff --git a/if1632/gdi32.spec b/if1632/gdi32.spec
index 7e6131e..5cf890a 100644
--- a/if1632/gdi32.spec
+++ b/if1632/gdi32.spec
@@ -134,7 +134,7 @@
 0126 stub GdiDeleteLocalDC
 0127 stub GdiDeleteLocalObject
 0128 stub GdiFlush
-0129 stub GdiGetBatchLimit
+0129 return GdiGetBatchLimit 0 1
 0130 stub GdiGetLocalBrush
 0131 stub GdiGetLocalDC
 0132 stub GdiGetLocalFont
@@ -193,7 +193,7 @@
 0185 stub GetGlyphOutline
 0186 stdcall GetGlyphOutlineA(long long long ptr long ptr ptr) GetGlyphOutline32A
 0187 stdcall GetGlyphOutlineW(long long long ptr long ptr ptr) GetGlyphOutline32W
-0188 stub GetGraphicsMode
+0188 return GetGraphicsMode 4 1 	# just return 1
 0189 stub GetICMProfileA
 0190 stub GetICMProfileW
 0191 stub GetKerningPairs
@@ -231,7 +231,7 @@
 0223 stdcall GetSystemPaletteUse() GetSystemPaletteUse32
 0224 stdcall GetTextAlign(long) GetTextAlign32
 0225 stdcall GetTextCharacterExtra(long) GetTextCharacterExtra32
-0226 stub GetTextCharset
+0226 stdcall GetTextCharset(long) GetTextCharset32
 0227 stdcall GetTextColor(long) GetTextColor32
 0228 stdcall GetTextExtentExPointA(long ptr long long ptr ptr ptr) GetTextExtentExPoint32A
 0229 stdcall GetTextExtentExPointW(long ptr long long ptr ptr ptr) GetTextExtentExPoint32W
@@ -249,7 +249,7 @@
 0241 stub GetWinMetaFileBits
 0242 stdcall GetWindowExtEx(long ptr) GetWindowExtEx32
 0243 stdcall GetWindowOrgEx(long ptr) GetWindowOrgEx32
-0244 stub GetWorldTransform
+0244 return GetWorldTransform 8 0
 0245 stdcall IntersectClipRect(long long long long long) IntersectClipRect32
 0246 stdcall InvertRgn(long long) InvertRgn32
 0247 stdcall LPtoDP(long ptr long) LPtoDP32
@@ -323,7 +323,7 @@
 0314 stub SetDeviceGammaRamp
 0315 stub SetEnhMetaFileBits
 0316 stub SetFontEnumeration
-0317 stub SetGraphicsMode
+0317 return SetGraphicsMode 8 1
 0318 stub SetICMMode
 0319 stub SetICMProfileA
 0320 stub SetICMProfileW
diff --git a/if1632/kernel.spec b/if1632/kernel.spec
index af3761c..6c4c9a9 100644
--- a/if1632/kernel.spec
+++ b/if1632/kernel.spec
@@ -41,7 +41,7 @@
 38  pascal   SetTaskSignalProc(word segptr) SetTaskSignalProc
 41  return EnableDos 0 0
 42  return DisableDos 0 0
-45  pascal16 LoadModule(ptr ptr) LoadModule16
+45  pascal16 LoadModule(str ptr) LoadModule16
 46  pascal16 FreeModule(word) FreeModule16
 47  pascal16 GetModuleHandle(segptr) WIN16_GetModuleHandle
 48  pascal16 GetModuleUsage(word) GetModuleUsage
@@ -53,9 +53,9 @@
 54  pascal16 GetInstanceData(word word word) GetInstanceData
 55  pascal16 Catch(ptr) Catch 
 56  pascal16 Throw(ptr word) Throw
-57  pascal16 GetProfileInt(ptr ptr s_word) GetProfileInt16
-58  pascal16 GetProfileString(ptr ptr ptr ptr word) GetProfileString16
-59  pascal16 WriteProfileString(ptr ptr ptr) WriteProfileString16
+57  pascal16 GetProfileInt(str str s_word) GetProfileInt16
+58  pascal16 GetProfileString(str str str ptr word) GetProfileString16
+59  pascal16 WriteProfileString(str str str) WriteProfileString16
 60  pascal16 FindResource(word segptr segptr) FindResource16
 61  pascal16 LoadResource(word word) LoadResource16
 62  pascal LockResource(word) WIN16_LockResource16
@@ -63,14 +63,14 @@
 64  pascal16 AccessResource(word word) AccessResource16
 65  pascal SizeofResource(word word) SizeofResource16
 66  pascal16 AllocResource(word word long) AllocResource16
-67  pascal SetResourceHandler(word ptr ptr) SetResourceHandler
+67  pascal SetResourceHandler(word segptr ptr) SetResourceHandler
 68  pascal16 InitAtomTable(word) InitAtomTable16
 69  pascal16 FindAtom(segptr) FindAtom16
 70  pascal16 AddAtom(segptr) AddAtom16
 71  pascal16 DeleteAtom(word) DeleteAtom16
 72  pascal16 GetAtomName(word ptr word) GetAtomName16
 73  pascal16 GetAtomHandle(word) GetAtomHandle
-74  pascal16 OpenFile(ptr ptr word) OpenFile16
+74  pascal16 OpenFile(str ptr word) OpenFile16
 75  stub OpenPathName
 76  stub DeletePathName
 77 stub KERNEL_77		#RESERVED1
@@ -79,21 +79,21 @@
 #80 RESERVED4
 81  pascal16 _lclose(word) _lclose16
 82  pascal16 _lread(word segptr word) WIN16_lread
-83  pascal16 _lcreat(ptr word) _lcreat16
+83  pascal16 _lcreat(str word) _lcreat16
 84  pascal   _llseek(word long word) _llseek16
-85  pascal16 _lopen(ptr word) _lopen16
+85  pascal16 _lopen(str word) _lopen16
 86  pascal16 _lwrite(word ptr word) _lwrite16
-87  pascal16 RESERVED5(ptr ptr) lstrcmp16
-88  pascal   lstrcpy(segptr segptr) lstrcpy16
-89  pascal   lstrcat(segptr segptr) lstrcat16
-90  pascal16 lstrlen(ptr) lstrlen16
+87  pascal16 RESERVED5(str str) lstrcmp16
+88  pascal   lstrcpy(segptr str) lstrcpy16
+89  pascal   lstrcat(segptr str) lstrcat16
+90  pascal16 lstrlen(str) lstrlen16
 91  register InitTask() InitTask
 92  pascal   GetTempDrive(byte) WIN16_GetTempDrive
 93  pascal16 GetCodeHandle(segptr) GetCodeHandle
 94  stub DefineHandleTable
-95  pascal16 LoadLibrary(ptr) LoadLibrary16
+95  pascal16 LoadLibrary(str) LoadLibrary16
 96  pascal16 FreeLibrary(word) FreeLibrary16
-97  pascal16 GetTempFileName(byte ptr word ptr) GetTempFileName16
+97  pascal16 GetTempFileName(byte str word ptr) GetTempFileName16
 98  return GetLastDiskChange 0 0
 99  stub GetLPErrMode
 100 return ValidateCodeSegments 0 0
@@ -111,7 +111,7 @@
 112 pascal16 GlobalUnWire(word) GlobalUnWire16
 113 equate __AHSHIFT 3
 114 equate __AHINCR 8
-115 pascal16 OutputDebugString(ptr) OutputDebugString16
+115 pascal16 OutputDebugString(str) OutputDebugString16
 116 stub InitLib
 117 pascal16 OldYield() OldYield
 118 register GetTaskQueueDS() GetTaskQueueDS
@@ -123,10 +123,10 @@
 124 return EnableKernel 0 0
 125 return DisableKernel 0 0
 126 stub MemoryFreed
-127 pascal16 GetPrivateProfileInt(ptr ptr s_word ptr) GetPrivateProfileInt16
-128 pascal16 GetPrivateProfileString(ptr ptr ptr ptr word ptr)
+127 pascal16 GetPrivateProfileInt(str str s_word str) GetPrivateProfileInt16
+128 pascal16 GetPrivateProfileString(str str str ptr word str)
              GetPrivateProfileString16
-129 pascal16 WritePrivateProfileString(ptr ptr ptr ptr)
+129 pascal16 WritePrivateProfileString(str str str str)
              WritePrivateProfileString16
 130 pascal FileCDR(ptr) FileCDR
 131 pascal GetDOSEnvironment() GetDOSEnvironment
@@ -135,7 +135,7 @@
 134 pascal16 GetWindowsDirectory(ptr word) GetWindowsDirectory16
 135 pascal16 GetSystemDirectory(ptr word) GetSystemDirectory16
 136 pascal16 GetDriveType(byte) GetDriveType16
-137 pascal16 FatalAppExit(word ptr) FatalAppExit16
+137 pascal16 FatalAppExit(word str) FatalAppExit16
 138 pascal GetHeapSpaces(word) GetHeapSpaces
 139 stub DoSignal
 140 pascal16 SetSigHandler(segptr ptr ptr word word) SetSigHandler
@@ -163,7 +163,7 @@
 163 pascal16 GlobalLRUOldest(word) GlobalLRUOldest
 164 pascal16 GlobalLRUNewest(word) GlobalLRUNewest
 165 return A20Proc 2 0
-166 pascal16 WinExec(ptr word) WinExec16
+166 pascal16 WinExec(str word) WinExec16
 167 pascal16 GetExpWinVer(word) GetExpWinVer
 168 pascal16 DirectResAlloc(word word word) DirectResAlloc
 169 pascal GetFreeSpace(word) GetFreeSpace16
@@ -268,8 +268,8 @@
 349 pascal   _hread(word segptr long) WIN16_hread
 350 pascal   _hwrite(word ptr long) _hwrite16
 #351 BUNNY_351
-352 pascal   lstrcatn(segptr segptr word) lstrcatn16
-353 pascal   lstrcpyn(segptr segptr word) lstrcpyn16
+352 pascal   lstrcatn(segptr str word) lstrcatn16
+353 pascal   lstrcpyn(segptr str word) lstrcpyn16
 354 pascal   GetAppCompatFlags(word) GetAppCompatFlags16
 355 pascal16 GetWinDebugInfo(ptr word) GetWinDebugInfo
 356 pascal16 SetWinDebugInfo(ptr) SetWinDebugInfo
@@ -311,6 +311,7 @@
 472 stub KERNEL_472
 473 stub KERNEL_473
 482 stub KERNEL_482
+485 stub KERNEL_485
 491 stub RegisterServiceProcess
 500 stub KERNEL_500
 502 stub KERNEL_502
@@ -338,4 +339,4 @@
 630 stub KERNEL_630
 631 stub FUNC004	# shell hook
 651 stub KERNEL_651
-700 return KERNEL_700 0 1
+700 pascal KERNEL_700() stub_KERNEL_700
diff --git a/if1632/lzexpand.spec b/if1632/lzexpand.spec
index a12c7e2..134347c 100644
--- a/if1632/lzexpand.spec
+++ b/if1632/lzexpand.spec
@@ -2,7 +2,7 @@
 type	win16
 
 1  pascal   LZCopy(word word) LZCopy16
-2  pascal16 LZOpenFile(ptr ptr word) LZOpenFile16
+2  pascal16 LZOpenFile(str ptr word) LZOpenFile16
 3  pascal16 LZInit(word) LZInit16
 4  pascal   LZSeek(word long word) LZSeek16
 5  pascal16 LZRead(word ptr word) LZRead16
@@ -10,6 +10,6 @@
 7  pascal16 LZStart() LZStart16
 8  pascal   CopyLZFile(word word) CopyLZFile16
 9  pascal16 LZDone() LZDone
-10 pascal16 GetExpandedName(ptr ptr) GetExpandedName16
+10 pascal16 GetExpandedName(str ptr) GetExpandedName16
 #11 WEP
 #12 ___EXPORTEDSTUB 
diff --git a/if1632/olesvr.spec b/if1632/olesvr.spec
index 922da54..3eac977 100644
--- a/if1632/olesvr.spec
+++ b/if1632/olesvr.spec
@@ -2,11 +2,11 @@
 type	win16
 
 #1 WEP
-2  pascal OleRegisterServer(ptr ptr ptr word word) OleRegisterServer
+2  pascal OleRegisterServer(str ptr ptr word word) OleRegisterServer
 3  pascal OleRevokeServer(long) OleRevokeServer
 4  pascal OleBlockServer(long) OleBlockServer
 5  pascal OleUnblockServer(long ptr) OleUnblockServer
-6  pascal OleRegisterServerDoc(long ptr ptr ptr) OleRegisterServerDoc
+6  pascal OleRegisterServerDoc(long str ptr ptr) OleRegisterServerDoc
 7  pascal OleRevokeServerDoc(long) OleRevokeServerDoc
 8 stub OLERENAMESERVERDOC
 9 stub OLEREVERTSERVERDOC
diff --git a/if1632/relay.c b/if1632/relay.c
index 7f478f1..642f0e7 100644
--- a/if1632/relay.c
+++ b/if1632/relay.c
@@ -82,6 +82,7 @@
             break;
         case 'l':
         case 'p':
+        case 't':
             args16 += 4;
             break;
         }
@@ -100,6 +101,14 @@
             args16 -= 4;
             printf( "0x%08x", *(int *)args16 );
             break;
+        case 't':
+            args16 -= 4;
+            if (HIWORD(*(int *)args16))
+                printf( "0x%08x \"%s\"", *(int *)args16,
+                        (char *)PTR_SEG_TO_LIN(*(int *)args16) );
+            else
+                printf( "0x%08x", *(int *)args16 );
+            break;
         case 'p':
             args16 -= 4;
             printf( "%04x:%04x", *(WORD *)(args16+2), *(WORD *)args16 );
@@ -386,6 +395,7 @@
 	DWORD	argconvmask = win_stack[1];
 	FARPROC32	proc32 = (FARPROC32)win_stack[2];
 	DWORD	*args,ret;
+        STACK16FRAME stf16;
 	int	i;
 
 	fprintf(stderr,"CallProc32W(%ld,%ld,%p,args[",nrofargs,argconvmask,proc32);
@@ -419,6 +429,16 @@
 		ret = 0;
 		break;
 	}
+	/* POP nrofargs DWORD arguments and 3 DWORD parameters */
+	/* FIXME: this is a BAD hack, but I don't see any other way to
+	 * pop a variable number of arguments.  -MM
+	 * The -2 in the size is for not copying WORD args[0] (which would
+	 * overwrite the top WORD on the return stack)
+	 */
+	memcpy(&stf16,CURRENT_STACK16,sizeof(stf16)-2);
+	IF1632_Saved16_sp += (3+nrofargs)*sizeof(DWORD);
+	memcpy(CURRENT_STACK16,&stf16,sizeof(stf16)-2);
+
 	fprintf(stderr,"returns %08lx\n",ret);
 	free(args);
 	return ret;
diff --git a/if1632/shell.spec b/if1632/shell.spec
index 74e9ef3..00ec20e 100644
--- a/if1632/shell.spec
+++ b/if1632/shell.spec
@@ -1,22 +1,22 @@
 name	shell
 type	win16
 
-  1 pascal   RegOpenKey(long ptr ptr) RegOpenKey16
-  2 pascal   RegCreateKey(long ptr ptr) RegCreateKey16
+  1 pascal   RegOpenKey(long str ptr) RegOpenKey16
+  2 pascal   RegCreateKey(long str ptr) RegCreateKey16
   3 pascal   RegCloseKey(long) RegCloseKey
-  4 pascal   RegDeleteKey(long ptr) RegDeleteKey16
-  5 pascal   RegSetValue(long ptr long ptr long) RegSetValue16
-  6 pascal   RegQueryValue(long ptr ptr ptr) RegQueryValue16
+  4 pascal   RegDeleteKey(long str) RegDeleteKey16
+  5 pascal   RegSetValue(long str long str long) RegSetValue16
+  6 pascal   RegQueryValue(long str ptr ptr) RegQueryValue16
   7 pascal   RegEnumKey(long long ptr long) RegEnumKey16
   9 pascal16 DragAcceptFiles(word word) DragAcceptFiles
  11 pascal16 DragQueryFile(word s_word ptr s_word) DragQueryFile
  12 pascal16 DragFinish(word) DragFinish
  13 pascal16 DragQueryPoint(word ptr) DragQueryPoint
- 20 pascal16 ShellExecute(word ptr ptr ptr ptr s_word) ShellExecute16
- 21 pascal16 FindExecutable(ptr ptr ptr) FindExecutable16
+ 20 pascal16 ShellExecute(word str str str str s_word) ShellExecute16
+ 21 pascal16 FindExecutable(str str ptr) FindExecutable16
  22 pascal16 ShellAbout(word ptr ptr word) ShellAbout16
  33 pascal16 AboutDlgProc(word word word long) AboutDlgProc16
- 34 pascal16 ExtractIcon(word ptr s_word) ExtractIcon16
+ 34 pascal16 ExtractIcon(word str s_word) ExtractIcon16
  36 pascal16 ExtractAssociatedIcon(word ptr ptr) ExtractAssociatedIcon
  37 pascal   DoEnvironmentSubst(ptr word) DoEnvironmentSubst
  38 pascal   FindEnvironmentString(ptr) FindEnvironmentString
diff --git a/if1632/user.spec b/if1632/user.spec
index fe0c4f7..2977f4a 100644
--- a/if1632/user.spec
+++ b/if1632/user.spec
@@ -2,7 +2,7 @@
 type	win16
 heap	65520
 
-1   pascal16 MessageBox(word ptr ptr word) MessageBox16
+1   pascal16 MessageBox(word str str word) MessageBox16
 2   stub OldExitWindows
 3   stub EnableOEMLayer
 4   stub DisableOEMLayer
@@ -40,7 +40,7 @@
 38  pascal16 GetWindowTextLength(word) GetWindowTextLength16
 39  pascal16 BeginPaint(word ptr) BeginPaint16
 40  pascal16 EndPaint(word ptr) EndPaint16
-41  pascal16 CreateWindow(ptr ptr long s_word s_word s_word s_word
+41  pascal16 CreateWindow(str str long s_word s_word s_word s_word
 	                  word word word segptr) CreateWindow16
 42  pascal16 ShowWindow(word word) ShowWindow16
 43  pascal16 CloseWindow(word) CloseWindow16
@@ -50,7 +50,7 @@
 47  pascal16 IsWindow(word) IsWindow16
 48  pascal16 IsChild(word word) IsChild16
 49  pascal16 IsWindowVisible(word) IsWindowVisible16
-50  pascal16 FindWindow(segptr ptr) FindWindow16
+50  pascal16 FindWindow(segptr str) FindWindow16
 #51 BEAR51
 52  pascal16 AnyPopup() AnyPopup16
 53  pascal16 DestroyWindow(word) DestroyWindow16
@@ -170,7 +170,7 @@
 168 pascal16 SetCaretBlinkTime(word) SetCaretBlinkTime16
 169 pascal16 GetCaretBlinkTime() GetCaretBlinkTime16
 170 pascal16 ArrangeIconicWindows(word) ArrangeIconicWindows16
-171 pascal16 WinHelp(word ptr word long) WinHelp16
+171 pascal16 WinHelp(word str word long) WinHelp16
 172 pascal16 SwitchToThisWindow(word word) SwitchToThisWindow16
 173 pascal16 LoadCursor(word segptr) LoadCursor16
 174 pascal16 LoadIcon(word segptr) LoadIcon16
@@ -200,7 +200,7 @@
 197 pascal   GetTabbedTextExtent(word ptr word word ptr) GetTabbedTextExtent16
 198 pascal16 CascadeChildWindows(word word) CascadeChildWindows
 199 pascal16 TileChildWindows(word word) TileChildWindows
-200 pascal16 OpenComm(ptr word word) OpenComm
+200 pascal16 OpenComm(str word word) OpenComm
 201 pascal16 SetCommState(ptr) SetCommState16
 202 pascal16 GetCommState(word ptr) GetCommState16
 203 pascal16 GetCommError(word ptr) GetCommError
@@ -254,7 +254,7 @@
 249 pascal16 GetAsyncKeyState(word) GetAsyncKeyState16
 250 pascal16 GetMenuState(word word word) GetMenuState16
 251 pascal   SendDriverMessage(word word long long) SendDriverMessage
-252 pascal16 OpenDriver(ptr ptr long) OpenDriver
+252 pascal16 OpenDriver(str str long) OpenDriver
 253 pascal   CloseDriver(word long long) CloseDriver
 254 pascal16 GetDriverModuleHandle(word) GetDriverModuleHandle
 255 pascal   DefDriverProc(long word word long long) DefDriverProc
@@ -377,15 +377,15 @@
 427 pascal16 FindWindowEx(word word segptr ptr) FindWindowEx16
 428 stub TileWindows
 429 stub CascadeWindows
-430 pascal16 lstrcmp(ptr ptr) lstrcmp16
+430 pascal16 lstrcmp(str str) lstrcmp16
 431 pascal   AnsiUpper(segptr) AnsiUpper16
 432 pascal   AnsiLower(segptr) AnsiLower16
 433 pascal16 IsCharAlpha(byte) IsCharAlpha16
 434 pascal16 IsCharAlphanumeric(byte) IsCharAlphanumeric16
 435 pascal16 IsCharUpper(byte) IsCharUpper16
 436 pascal16 IsCharLower(byte) IsCharLower16
-437 pascal16 AnsiUpperBuff(ptr word) AnsiUpperBuff16
-438 pascal16 AnsiLowerBuff(ptr word) AnsiLowerBuff16
+437 pascal16 AnsiUpperBuff(str word) AnsiUpperBuff16
+438 pascal16 AnsiLowerBuff(str word) AnsiLowerBuff16
 441 stub InsertMenuItem
 443 stub GetMenuItemInfo
 445 pascal   DefFrameProc(word word word word long) DefFrameProc16
@@ -395,7 +395,7 @@
 449 stub DrawState
 450 stub CreateIconFromResourceEx
 451 pascal16 TranslateMDISysAccel(word ptr) TranslateMDISysAccel16
-452 pascal16 CreateWindowEx(long ptr ptr long s_word s_word s_word s_word
+452 pascal16 CreateWindowEx(long str str long s_word s_word s_word s_word
                             word word word segptr) CreateWindowEx16
 454 pascal16 AdjustWindowRectEx(ptr long word long) AdjustWindowRectEx16
 455 pascal16 GetIconID(word long) GetIconID
@@ -411,7 +411,7 @@
 465 pascal16 DragDetect(word long) DragDetect16
 466 pascal16 DrawFocusRect(word ptr) DrawFocusRect16
 470 stub StringFunc
-471 pascal16 lstrcmpi(ptr ptr) lstrcmpi16
+471 pascal16 lstrcmpi(str str) lstrcmpi16
 472 pascal   AnsiNext(segptr) AnsiNext16
 473 pascal   AnsiPrev(segptr segptr) AnsiPrev16
 475 pascal16 SetScrollInfo(word s_word ptr word) SetScrollInfo16
diff --git a/if1632/user32.spec b/if1632/user32.spec
index ff7dd1a..0256cb0 100644
--- a/if1632/user32.spec
+++ b/if1632/user32.spec
@@ -140,7 +140,7 @@
 0133 stdcall DestroyMenu(long) DestroyMenu32
 0134 stdcall DestroyWindow(long) DestroyWindow32
 0135 stdcall DialogBoxIndirectParamA(long ptr long ptr long) DialogBoxIndirectParam32A
-0136 stub DialogBoxIndirectParamAorW
+0136 stdcall DialogBoxIndirectParamAorW(long ptr long ptr long) DialogBoxIndirectParam32A
 0137 stdcall DialogBoxIndirectParamW(long ptr long ptr long) DialogBoxIndirectParam32W
 0138 stdcall DialogBoxParamA(long ptr long ptr long) DialogBoxParam32A
 0139 stdcall DialogBoxParamW(long ptr long ptr long) DialogBoxParam32W
diff --git a/include/commdlg.h b/include/commdlg.h
index 4e85561..61ac06f 100644
--- a/include/commdlg.h
+++ b/include/commdlg.h
@@ -43,6 +43,9 @@
 #define OFN_NOREADONLYRETURN         0x00008000
 #define OFN_NOTESTFILECREATE         0x00010000
 
+#define OFN_UNICODE		     0x40000000	/*to differ between 32W/A hook*/
+#define OFN_WINE32		     0x80000000	/* comdlg32 */
+
 #define OFN_SHAREFALLTHROUGH     2
 #define OFN_SHARENOWARN          1
 #define OFN_SHAREWARN            0
@@ -68,9 +71,56 @@
 	LPARAM 		lCustData;
         WNDPROC16       lpfnHook;
 	SEGPTR 		lpTemplateName;
-	}   OPENFILENAME;
-typedef OPENFILENAME * LPOPENFILENAME;
+}   OPENFILENAME16,*LPOPENFILENAME16;
 
+typedef struct {
+	DWORD		lStructSize;
+	HWND32		hwndOwner;
+	HINSTANCE32	hInstance;
+	LPCSTR		lpstrFilter;
+	LPSTR		lpstrCustomFilter;
+	DWORD		nMaxCustFilter;
+	DWORD		nFilterIndex;
+	LPSTR		lpstrFile;
+	DWORD		nMaxFile;
+	LPSTR		lpstrFileTitle;
+	DWORD		nMaxFileTitle;
+	LPCSTR		lpstrInitialDir;
+	LPCSTR		lpstrTitle;
+	DWORD		Flags;
+	WORD		nFileOffset;
+	WORD		nFileExtension;
+	LPCSTR		lpstrDefExt;
+	LPARAM		lCustData;
+	WNDPROC32	lpfnHook;
+	LPCSTR		lpTemplateName;
+} OPENFILENAME32A,*LPOPENFILENAME32A;
+
+typedef struct {
+	DWORD		lStructSize;
+	HWND32		hwndOwner;
+	HINSTANCE32	hInstance;
+	LPCWSTR		lpstrFilter;
+	LPWSTR		lpstrCustomFilter;
+	DWORD		nMaxCustFilter;
+	DWORD		nFilterIndex;
+	LPWSTR		lpstrFile;
+	DWORD		nMaxFile;
+	LPWSTR		lpstrFileTitle;
+	DWORD		nMaxFileTitle;
+	LPCWSTR		lpstrInitialDir;
+	LPCWSTR		lpstrTitle;
+	DWORD		Flags;
+	WORD		nFileOffset;
+	WORD		nFileExtension;
+	LPCWSTR		lpstrDefExt;
+	LPARAM		lCustData;
+	WNDPROC32	lpfnHook;
+	LPCWSTR		lpTemplateName;
+} OPENFILENAME32W,*LPOPENFILENAME32W;
+
+DECL_WINELIB_TYPE_AW(OPENFILENAME);
+DECL_WINELIB_TYPE_AW(LPOPENFILENAME);
 
 typedef struct {
 	DWORD		lStructSize;
@@ -82,7 +132,7 @@
 	LPARAM		lCustData;
         WNDPROC16       lpfnHook;
 	SEGPTR 		lpTemplateName;
-	} CHOOSECOLOR;
+} CHOOSECOLOR;
 typedef CHOOSECOLOR *LPCHOOSECOLOR;
 
 #define CC_RGBINIT               0x00000001
@@ -278,9 +328,18 @@
 BOOL16  ChooseColor(LPCHOOSECOLOR lpChCol);
 DWORD CommDlgExtendedError(void);
 HWND16 FindText( SEGPTR find);
-short GetFileTitle(LPCSTR lpFile, LPSTR lpTitle, UINT16 cbBuf);
-BOOL16  GetOpenFileName(SEGPTR ofn);
-BOOL16  GetSaveFileName(SEGPTR ofn);
+INT16 GetFileTitle16(LPCSTR lpFile, LPSTR lpTitle, UINT16 cbBuf);
+INT16 GetFileTitle32A(LPCSTR lpFile, LPSTR lpTitle, UINT32 cbBuf);
+INT16 GetFileTitle32W(LPCWSTR lpFile, LPWSTR lpTitle, UINT32 cbBuf);
+#define GetFileTitle WINELIB_NAME_AW(GetFileTitle)
+BOOL16  GetOpenFileName16(SEGPTR ofn);
+BOOL32  GetOpenFileName32A(LPOPENFILENAME32A ofn);
+BOOL32  GetOpenFileName32W(LPOPENFILENAME32W ofn);
+#define GetOpenFileName WINELIB_NAME_AW(GetOpenFileName)
+BOOL16  GetSaveFileName16(SEGPTR ofn);
+BOOL32  GetSaveFileName32A(LPOPENFILENAME32A ofn);
+BOOL32  GetSaveFileName32W(LPOPENFILENAME32W ofn);
+#define GetSaveFileName WINELIB_NAME_AW(GetSaveFileName)
 BOOL16  PrintDlg( SEGPTR print);
 HWND16 ReplaceText( SEGPTR find);
 BOOL16  ChooseFont(LPCHOOSEFONT lpChFont);
diff --git a/include/mmsystem.h b/include/mmsystem.h
index 29cb8ea..2941b4a 100644
--- a/include/mmsystem.h
+++ b/include/mmsystem.h
@@ -171,7 +171,8 @@
     DWORD       dwUser;                 /* for client's use */
     DWORD       dwFlags;                /* assorted flags (see defines) */
     DWORD       dwLoops;                /* loop control counter */
-    struct wavehdr_tag *lpNext;         /* reserved for driver */
+/*    struct wavehdr_tag *lpNext;*/         
+    SEGPTR      lp16Next;               /* reserved for driver */
     DWORD       reserved;               /* reserved for driver */
 } WAVEHDR, *LPWAVEHDR;
 
diff --git a/include/windows.h b/include/windows.h
index dc3a494..fe00984 100644
--- a/include/windows.h
+++ b/include/windows.h
@@ -5122,7 +5122,7 @@
 WORD       SetHookFlags(HDC16,WORD);
 HMETAFILE16 SetMetaFileBits(HGLOBAL16);
 VOID       SetPriority(HTASK16,INT16);
-FARPROC16  SetResourceHandler(HINSTANCE16,LPSTR,FARPROC16);
+FARPROC16  SetResourceHandler(HINSTANCE16,SEGPTR,FARPROC16);
 WORD       SetSelectorBase(WORD,DWORD);
 WORD       SetSelectorLimit(WORD,DWORD);
 LONG       SetSwapAreaSize(WORD);
@@ -6949,7 +6949,7 @@
 BOOL32     RemoveDirectory32A(LPCSTR);
 BOOL32     RemoveDirectory32W(LPCWSTR);
 #define    RemoveDirectory WINELIB_NAME_AW(RemoveDirectory)
-BOOL16     RemoveFontResource16(LPCSTR);
+BOOL16     RemoveFontResource16(SEGPTR);
 BOOL32     RemoveFontResource32A(LPCSTR);
 BOOL32     RemoveFontResource32W(LPCWSTR);
 #define    RemoveFontResource WINELIB_NAME_AW(RemoveFontResource)
@@ -7413,11 +7413,11 @@
 BOOL32     WriteProfileString32A(LPCSTR,LPCSTR,LPCSTR);
 BOOL32     WriteProfileString32W(LPCWSTR,LPCWSTR,LPCWSTR);
 #define    WriteProfileString WINELIB_NAME_AW(WriteProfileString)
-SEGPTR     lstrcat16(SEGPTR,SEGPTR);
+SEGPTR     lstrcat16(SEGPTR,LPCSTR);
 LPSTR      lstrcat32A(LPSTR,LPCSTR);
 LPWSTR     lstrcat32W(LPWSTR,LPCWSTR);
 #define    lstrcat WINELIB_NAME_AW(lstrcat)
-SEGPTR     lstrcatn16(SEGPTR,SEGPTR,INT16);
+SEGPTR     lstrcatn16(SEGPTR,LPCSTR,INT16);
 LPSTR      lstrcatn32A(LPSTR,LPCSTR,INT32);
 LPWSTR     lstrcatn32W(LPWSTR,LPCWSTR,INT32);
 #define    lstrcatn WINELIB_NAME_AW(lstrcatn)
@@ -7429,11 +7429,11 @@
 INT32      lstrcmpi32A(LPCSTR,LPCSTR);
 INT32      lstrcmpi32W(LPCWSTR,LPCWSTR);
 #define    lstrcmpi WINELIB_NAME_AW(lstrcmpi)
-SEGPTR     lstrcpy16(SEGPTR,SEGPTR);
+SEGPTR     lstrcpy16(SEGPTR,LPCSTR);
 LPSTR      lstrcpy32A(LPSTR,LPCSTR);
 LPWSTR     lstrcpy32W(LPWSTR,LPCWSTR);
 #define    lstrcpy WINELIB_NAME_AW(lstrcpy)
-SEGPTR     lstrcpyn16(SEGPTR,SEGPTR,INT16);
+SEGPTR     lstrcpyn16(SEGPTR,LPCSTR,INT16);
 LPSTR      lstrcpyn32A(LPSTR,LPCSTR,INT32);
 LPWSTR     lstrcpyn32W(LPWSTR,LPCWSTR,INT32);
 #define    lstrcpyn WINELIB_NAME_AW(lstrcpyn)
diff --git a/loader/resource.c b/loader/resource.c
index 37dc9c1..a569850 100644
--- a/loader/resource.c
+++ b/loader/resource.c
@@ -748,12 +748,14 @@
  *	SetResourceHandler	(KERNEL.43)
  */
 FARPROC16
-SetResourceHandler(HINSTANCE16 instance,LPSTR s,FARPROC16 farproc)
+SetResourceHandler(HINSTANCE16 instance,SEGPTR s,FARPROC16 farproc)
 {
     if (HIWORD(s))
-	fprintf(stderr,"SetResourceHandler(%04x,%s,%p), empty STUB!\n",instance,s,farproc);
+	fprintf(stderr,"SetResourceHandler(%04x,%s,%p), empty STUB!\n",
+		instance,(char*)PTR_SEG_TO_LIN(s),farproc);
     else
-	fprintf(stderr,"SetResourceHandler(%04x,0x%04x,%p), empty STUB!\n",instance,LOWORD(s),farproc);
+	fprintf(stderr,"SetResourceHandler(%04x,0x%04x,%p), empty STUB!\n",
+		instance,LOWORD(s),farproc);
     return NULL;
 }
 
diff --git a/memory/string.c b/memory/string.c
index 4df0d00..05beae1 100644
--- a/memory/string.c
+++ b/memory/string.c
@@ -64,9 +64,9 @@
 /***********************************************************************
  *           lstrcat16   (KERNEL.89)
  */
-SEGPTR lstrcat16( SEGPTR dst, SEGPTR src )
+SEGPTR lstrcat16( SEGPTR dst, LPCSTR src )
 {
-    lstrcat32A( (LPSTR)PTR_SEG_TO_LIN(dst), (LPCSTR)PTR_SEG_TO_LIN(src) );
+    lstrcat32A( (LPSTR)PTR_SEG_TO_LIN(dst), src );
     return dst;
 }
 
@@ -98,9 +98,9 @@
 /***********************************************************************
  *           lstrcatn16   (KERNEL.352)
  */
-SEGPTR lstrcatn16( SEGPTR dst, SEGPTR src, INT16 n )
+SEGPTR lstrcatn16( SEGPTR dst, LPCSTR src, INT16 n )
 {
-    lstrcatn32A( (LPSTR)PTR_SEG_TO_LIN(dst), (LPCSTR)PTR_SEG_TO_LIN(src), n );
+    lstrcatn32A( (LPSTR)PTR_SEG_TO_LIN(dst), src, n );
     return dst;
 }
 
@@ -212,9 +212,9 @@
 /***********************************************************************
  *           lstrcpy16   (KERNEL.88)
  */
-SEGPTR lstrcpy16( SEGPTR dst, SEGPTR src )
+SEGPTR lstrcpy16( SEGPTR dst, LPCSTR src )
 {
-    lstrcpy32A( (LPSTR)PTR_SEG_TO_LIN(dst), (LPCSTR)PTR_SEG_TO_LIN(src) );
+    lstrcpy32A( (LPSTR)PTR_SEG_TO_LIN(dst), src );
     return dst;
 }
 
@@ -246,9 +246,9 @@
 /***********************************************************************
  *           lstrcpyn16   (KERNEL.353)
  */
-SEGPTR lstrcpyn16( SEGPTR dst, SEGPTR src, INT16 n )
+SEGPTR lstrcpyn16( SEGPTR dst, LPCSTR src, INT16 n )
 {
-    lstrcpyn32A( (LPSTR)PTR_SEG_TO_LIN(dst), (LPCSTR)PTR_SEG_TO_LIN(src), n );
+    lstrcpyn32A( (LPSTR)PTR_SEG_TO_LIN(dst), src, n );
     return dst;
 }
 
diff --git a/misc/comm.c b/misc/comm.c
index 9572070..df5b7c4 100644
--- a/misc/comm.c
+++ b/misc/comm.c
@@ -22,10 +22,9 @@
 #include <ctype.h>
 #include <sys/stat.h>
 #if defined(__NetBSD__) || defined(__FreeBSD__)
-#include <sys/ioctl.h>
-#else
-#include <sys/ioctl.h>
+#include <sys/filio.h>
 #endif
+#include <sys/ioctl.h>
 #include <unistd.h>
 
 #include "windows.h"
@@ -36,6 +35,10 @@
 #include "debug.h"
 #include "handle32.h"
 
+#ifndef TIOCINQ
+#define	TIOCINQ FIONREAD
+#endif
+
 /*
  * [RER] These are globals are wrong.  They should be in DosDeviceStruct
  * on a per port basis.
diff --git a/misc/commdlg.c b/misc/commdlg.c
index 2f053da..4a4af0b 100644
--- a/misc/commdlg.c
+++ b/misc/commdlg.c
@@ -56,44 +56,71 @@
 /***********************************************************************
  *           GetOpenFileName   (COMMDLG.1)
  */
-BOOL16 GetOpenFileName( SEGPTR ofn )
+BOOL16 GetOpenFileName16( SEGPTR ofn )
 {
     HINSTANCE16 hInst;
-    HANDLE16 hDlgTmpl = 0, hResInfo;
+    HANDLE32 hDlgTmpl = 0, hResInfo;
     BOOL32 bRet = FALSE, win32Format = FALSE;
     HWND32 hwndDialog;
-    LPOPENFILENAME lpofn = (LPOPENFILENAME)PTR_SEG_TO_LIN(ofn);
+    LPOPENFILENAME16 lpofn = (LPOPENFILENAME16)PTR_SEG_TO_LIN(ofn);
     LPCVOID template;
 
     if (!lpofn || !FileDlg_Init()) return FALSE;
 
-    if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE)
-    {
-        if (!(template = LockResource16( lpofn->hInstance )))
-        {
-            CommDlgLastError = CDERR_LOADRESFAILURE;
-            return FALSE;
-        }
-    }
-    else if (lpofn->Flags & OFN_ENABLETEMPLATE)
-    {
-        if (!(hResInfo = FindResource16(lpofn->hInstance,
-                                        lpofn->lpTemplateName, RT_DIALOG)))
-        {
-            CommDlgLastError = CDERR_FINDRESFAILURE;
-            return FALSE;
-        }
-        if (!(hDlgTmpl = LoadResource16( lpofn->hInstance, hResInfo )) ||
-            !(template = LockResource16( hDlgTmpl )))
-        {
-            CommDlgLastError = CDERR_LOADRESFAILURE;
-            return FALSE;
-        }
-    }
-    else
-    {
-        template = SYSRES_GetResPtr( SYSRES_DIALOG_OPEN_FILE );
-        win32Format = TRUE;
+    if (lpofn->Flags & OFN_WINE32) {
+	    if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE)
+	    {
+		if (!(template = LockResource32( lpofn->hInstance )))
+		{
+		    CommDlgLastError = CDERR_LOADRESFAILURE;
+		    return FALSE;
+		}
+	    }
+	    else if (lpofn->Flags & OFN_ENABLETEMPLATE)
+	    {
+		if (!(hResInfo = FindResource32A(lpofn->hInstance,
+						PTR_SEG_TO_LIN(lpofn->lpTemplateName), (LPSTR)RT_DIALOG)))
+		{
+		    CommDlgLastError = CDERR_FINDRESFAILURE;
+		    return FALSE;
+		}
+		if (!(hDlgTmpl = LoadResource32( lpofn->hInstance, hResInfo )) ||
+		    !(template = LockResource32( hDlgTmpl )))
+		{
+		    CommDlgLastError = CDERR_LOADRESFAILURE;
+		    return FALSE;
+		}
+	    } else {
+		template = SYSRES_GetResPtr( SYSRES_DIALOG_OPEN_FILE );
+	    }
+	    win32Format = TRUE;
+    } else {
+	    if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE)
+	    {
+		if (!(template = LockResource16( lpofn->hInstance )))
+		{
+		    CommDlgLastError = CDERR_LOADRESFAILURE;
+		    return FALSE;
+		}
+	    }
+	    else if (lpofn->Flags & OFN_ENABLETEMPLATE)
+	    {
+		if (!(hResInfo = FindResource16(lpofn->hInstance,
+						lpofn->lpTemplateName, RT_DIALOG)))
+		{
+		    CommDlgLastError = CDERR_FINDRESFAILURE;
+		    return FALSE;
+		}
+		if (!(hDlgTmpl = LoadResource16( lpofn->hInstance, hResInfo )) ||
+		    !(template = LockResource16( hDlgTmpl )))
+		{
+		    CommDlgLastError = CDERR_LOADRESFAILURE;
+		    return FALSE;
+		}
+	    } else {
+		template = SYSRES_GetResPtr( SYSRES_DIALOG_OPEN_FILE );
+		win32Format = TRUE;
+	    }
     }
 
     hInst = WIN_GetWindowInstance( lpofn->hwndOwner );
@@ -103,7 +130,12 @@
                                         ofn, WIN_PROC_16 );
     if (hwndDialog) bRet = DIALOG_DoDialogBox( hwndDialog, lpofn->hwndOwner );
 
-    if (hDlgTmpl) FreeResource16( hDlgTmpl );
+    if (hDlgTmpl) {
+	    if (lpofn->Flags & OFN_WINE32)
+		    FreeResource32( hDlgTmpl );
+	    else
+		    FreeResource16( hDlgTmpl );
+    }
 
     dprintf_commdlg(stddeb,"GetOpenFileName // return lpstrFile='%s' !\n", 
            (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrFile));
@@ -114,45 +146,74 @@
 /***********************************************************************
  *           GetSaveFileName   (COMMDLG.2)
  */
-BOOL16 GetSaveFileName( SEGPTR ofn)
+BOOL16 GetSaveFileName16( SEGPTR ofn)
 {
     HINSTANCE16 hInst;
-    HANDLE16 hDlgTmpl = 0;
+    HANDLE32 hDlgTmpl = 0;
     BOOL32 bRet = FALSE, win32Format = FALSE;
-    LPOPENFILENAME lpofn = (LPOPENFILENAME)PTR_SEG_TO_LIN(ofn);
+    LPOPENFILENAME16 lpofn = (LPOPENFILENAME16)PTR_SEG_TO_LIN(ofn);
     LPCVOID template;
     HWND32 hwndDialog;
 
     if (!lpofn || !FileDlg_Init()) return FALSE;
 
-    if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE)
-    {
-        if (!(template = LockResource16( lpofn->hInstance )))
-        {
-            CommDlgLastError = CDERR_LOADRESFAILURE;
-            return FALSE;
-        }
-    }
-    else if (lpofn->Flags & OFN_ENABLETEMPLATE)
-    {
-        HANDLE16 hResInfo;
-        if (!(hResInfo = FindResource16(lpofn->hInstance,
-                                        lpofn->lpTemplateName, RT_DIALOG)))
-        {
-            CommDlgLastError = CDERR_FINDRESFAILURE;
-            return FALSE;
-        }
-        if (!(hDlgTmpl = LoadResource16( lpofn->hInstance, hResInfo )) ||
-            !(template = LockResource16( hDlgTmpl )))
-        {
-            CommDlgLastError = CDERR_LOADRESFAILURE;
-            return FALSE;
-        }
-    }
-    else
-    {
-        template = SYSRES_GetResPtr( SYSRES_DIALOG_SAVE_FILE );
-        win32Format = TRUE;
+    if (lpofn->Flags & OFN_WINE32) {
+	    if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE)
+	    {
+		if (!(template = LockResource32( lpofn->hInstance )))
+		{
+		    CommDlgLastError = CDERR_LOADRESFAILURE;
+		    return FALSE;
+		}
+	    }
+	    else if (lpofn->Flags & OFN_ENABLETEMPLATE)
+	    {
+		HANDLE32 hResInfo;
+		if (!(hResInfo = FindResource32A(lpofn->hInstance,
+						 PTR_SEG_TO_LIN(lpofn->lpTemplateName), (LPSTR)RT_DIALOG)))
+		{
+		    CommDlgLastError = CDERR_FINDRESFAILURE;
+		    return FALSE;
+		}
+		if (!(hDlgTmpl = LoadResource32(lpofn->hInstance,hResInfo)) ||
+		    !(template = LockResource32(hDlgTmpl)))
+		{
+		    CommDlgLastError = CDERR_LOADRESFAILURE;
+		    return FALSE;
+		}
+		win32Format= TRUE;
+	    } else {
+		template = SYSRES_GetResPtr( SYSRES_DIALOG_SAVE_FILE );
+		win32Format = TRUE;
+	    }
+    } else {
+	    if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE)
+	    {
+		if (!(template = LockResource16( lpofn->hInstance )))
+		{
+		    CommDlgLastError = CDERR_LOADRESFAILURE;
+		    return FALSE;
+		}
+	    }
+	    else if (lpofn->Flags & OFN_ENABLETEMPLATE)
+	    {
+		HANDLE16 hResInfo;
+		if (!(hResInfo = FindResource16(lpofn->hInstance,
+						lpofn->lpTemplateName, RT_DIALOG)))
+		{
+		    CommDlgLastError = CDERR_FINDRESFAILURE;
+		    return FALSE;
+		}
+		if (!(hDlgTmpl = LoadResource16( lpofn->hInstance, hResInfo )) ||
+		    !(template = LockResource16( hDlgTmpl )))
+		{
+		    CommDlgLastError = CDERR_LOADRESFAILURE;
+		    return FALSE;
+		}
+	} else {
+		template = SYSRES_GetResPtr( SYSRES_DIALOG_SAVE_FILE );
+		win32Format = TRUE;
+	}
     }
 
     hInst = WIN_GetWindowInstance( lpofn->hwndOwner );
@@ -163,7 +224,12 @@
                                         ofn, WIN_PROC_16 );
     if (hwndDialog) bRet = DIALOG_DoDialogBox( hwndDialog, lpofn->hwndOwner );
 
-    if (hDlgTmpl) FreeResource16( hDlgTmpl );
+    if (hDlgTmpl) {
+	    if (lpofn->Flags & OFN_WINE32)
+		    FreeResource32( hDlgTmpl );
+	    else
+		    FreeResource16( hDlgTmpl );
+    }
 
     dprintf_commdlg(stddeb, "GetSaveFileName // return lpstrFile='%s' !\n", 
             (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrFile));
@@ -342,7 +408,7 @@
 /***********************************************************************
  *                              FILEDLG_HookCallChk             [internal]
  */
-static int FILEDLG_HookCallChk(LPOPENFILENAME lpofn)
+static int FILEDLG_HookCallChk(LPOPENFILENAME16 lpofn)
 {
  if (lpofn)
   if (lpofn->Flags & OFN_ENABLEHOOK)
@@ -351,6 +417,25 @@
  return 0;   
 } 
 
+static BOOL32 FILEDLG_CallWindowProc(LPOPENFILENAME16 lpofn,HWND32 hwnd,
+	UINT32 wMsg,WPARAM32 wParam,LPARAM lParam
+) {
+	if (!(lpofn->Flags & OFN_WINE32))
+		return (BOOL32)CallWindowProc16(
+			lpofn->lpfnHook,hwnd,(UINT16)wMsg,(WPARAM16)wParam,lParam
+		);
+	/* |OFN_WINE32 */
+	if (lpofn->Flags & OFN_UNICODE)
+		return (BOOL32)CallWindowProc32W(
+			(WNDPROC32)lpofn->lpfnHook,hwnd,wMsg,wParam,lParam
+		);
+	/* ! |OFN_UNICODE */
+	return (BOOL32)CallWindowProc32A(
+		(WNDPROC32)lpofn->lpfnHook,hwnd,wMsg,wParam,lParam
+	);
+
+}
+
 /***********************************************************************
  *                              FILEDLG_WMInitDialog            [internal]
  */
@@ -358,11 +443,11 @@
 static LONG FILEDLG_WMInitDialog(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam) 
 {
   int i, n;
-  LPOPENFILENAME lpofn;
+  LPOPENFILENAME16 lpofn;
   char tmpstr[512];
   LPSTR pstr;
   SetWindowLong32A(hWnd, DWL_USER, lParam);
-  lpofn = (LPOPENFILENAME)PTR_SEG_TO_LIN(lParam);
+  lpofn = (LPOPENFILENAME16)PTR_SEG_TO_LIN(lParam);
   if (lpofn->lpstrTitle) SetWindowText16( hWnd, lpofn->lpstrTitle );
   /* read custom filter information */
   if (lpofn->lpstrCustomFilter)
@@ -433,8 +518,7 @@
   if (lpofn->Flags & OFN_HIDEREADONLY)
     ShowWindow32(GetDlgItem32(hWnd, chx1), SW_HIDE); 
   if (FILEDLG_HookCallChk(lpofn))
-     return (BOOL16)CallWindowProc16(lpofn->lpfnHook, 
-                                     hWnd,  WM_INITDIALOG, wParam, lParam );
+     return (BOOL16)FILEDLG_CallWindowProc(lpofn,hWnd,WM_INITDIALOG,wParam,lParam );
   else  
      return TRUE;
 }
@@ -445,8 +529,8 @@
 static LRESULT FILEDLG_WMCommand(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam) 
 {
   LONG lRet;
-  LPOPENFILENAME lpofn;
-  OPENFILENAME ofn2;
+  LPOPENFILENAME16 lpofn;
+  OPENFILENAME16 ofn2;
   char tmpstr[512], tmpstr2[512];
   LPSTR pstr, pstr2;
   UINT16 control,notification;
@@ -455,7 +539,7 @@
   control = wParam;
   notification = HIWORD(lParam);
     
-  lpofn = (LPOPENFILENAME)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd, DWL_USER));
+  lpofn = (LPOPENFILENAME16)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd, DWL_USER));
   switch (control)
     {
     case lst1: /* file list */
@@ -472,7 +556,7 @@
           SEGPTR_FREE(pstr);
       }
       if (FILEDLG_HookCallChk(lpofn))
-       CallWindowProc16(lpofn->lpfnHook, hWnd,
+       FILEDLG_CallWindowProc(lpofn,hWnd,
                   RegisterWindowMessage32A( LBSELCHSTRING ),
                   control, MAKELONG(lRet,CD_LBSELCHANGE));       
       /* FIXME: for OFN_ALLOWMULTISELECT we need CD_LBSELSUB, CD_SELADD, CD_LBSELNOITEMS */                  
@@ -610,7 +694,7 @@
 	}
       if (FILEDLG_HookCallChk(lpofn))
       {
-       lRet= (BOOL16)CallWindowProc16(lpofn->lpfnHook,
+       lRet= (BOOL16)FILEDLG_CallWindowProc(lpofn,
                hWnd, RegisterWindowMessage32A( FILEOKSTRING ), 0, lParam );
        if (lRet)       
        {
@@ -636,12 +720,12 @@
  */
 LRESULT FileOpenDlgProc(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam, LPARAM lParam)
 {  
- LPOPENFILENAME lpofn = (LPOPENFILENAME)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd, DWL_USER));
+ LPOPENFILENAME16 lpofn = (LPOPENFILENAME16)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd, DWL_USER));
  
  if (wMsg!=WM_INITDIALOG)
   if (FILEDLG_HookCallChk(lpofn))
   {
-   LRESULT  lRet=(BOOL16)CallWindowProc16(lpofn->lpfnHook, hWnd, wMsg, wParam, lParam);
+   LRESULT  lRet=(BOOL16)FILEDLG_CallWindowProc(lpofn,hWnd,wMsg,wParam,lParam);
    if (lRet)   
     return lRet;         /* else continue message processing */
   }             
@@ -679,12 +763,12 @@
  */
 LRESULT FileSaveDlgProc(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam, LPARAM lParam)
 {
- LPOPENFILENAME lpofn = (LPOPENFILENAME)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd, DWL_USER));
+ LPOPENFILENAME16 lpofn = (LPOPENFILENAME16)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd, DWL_USER));
  
  if (wMsg!=WM_INITDIALOG)
   if (FILEDLG_HookCallChk(lpofn))
   {
-   LRESULT  lRet=(BOOL16)CallWindowProc16(lpofn->lpfnHook, hWnd, wMsg, wParam, lParam);
+   LRESULT  lRet=(BOOL16)FILEDLG_CallWindowProc(lpofn,hWnd,wMsg,wParam,lParam);
    if (lRet)   
     return lRet;         /* else continue message processing */
   }             
@@ -1089,11 +1173,10 @@
   return CommDlgLastError;
 }
 
-
 /***********************************************************************
- *           GetFileTitle   (COMMDLG.27)
+ *           GetFileTitleA   (COMDLG32.8)
  */
-short GetFileTitle(LPCSTR lpFile, LPSTR lpTitle, UINT16 cbBuf)
+short GetFileTitle32A(LPCSTR lpFile, LPSTR lpTitle, UINT32 cbBuf)
 {
     int i, len;
     dprintf_commdlg(stddeb,"GetFileTitle(%p %p %d); \n", lpFile, lpTitle, cbBuf);
@@ -1124,6 +1207,30 @@
 }
 
 
+/***********************************************************************
+ *           GetFileTitleA   (COMDLG32.8)
+ */
+short GetFileTitle32W(LPCWSTR lpFile, LPWSTR lpTitle, UINT32 cbBuf)
+{
+	LPSTR file = HEAP_strdupWtoA(GetProcessHeap(),0,lpFile);
+	LPSTR title = HeapAlloc(GetProcessHeap(),0,cbBuf);
+	short	ret;
+
+	ret = GetFileTitle32A(file,title,cbBuf);
+
+	lstrcpynAtoW(lpTitle,title,cbBuf);
+	HeapFree(GetProcessHeap(),0,file);
+	HeapFree(GetProcessHeap(),0,title);
+	return ret;
+}
+/***********************************************************************
+ *           GetFileTitle   (COMMDLG.27)
+ */
+short GetFileTitle16(LPCSTR lpFile, LPSTR lpTitle, UINT16 cbBuf) {
+    return GetFileTitle32A(lpFile,lpTitle,cbBuf);
+}
+
+
 /* ------------------------ Choose Color Dialog --------------------------- */
 
 /***********************************************************************
@@ -2873,3 +2980,183 @@
     }
   return FALSE;
 }
+
+
+#define GET_XXX_FILENAME(xxx) 						\
+BOOL32 xxx##32A( LPOPENFILENAME32A ofn )				\
+{									\
+	BOOL16 ret;							\
+	LPOPENFILENAME16 ofn16 = SEGPTR_ALLOC(sizeof(OPENFILENAME16));	\
+									\
+	memset(ofn16,'\0',sizeof(*ofn16));				\
+	ofn16->lStructSize = sizeof(*ofn16);				\
+	ofn16->hwndOwner = ofn->hwndOwner;				\
+	ofn16->hInstance = ofn->hInstance;				\
+	if (ofn->lpstrFilter) {						\
+		LPSTR	s,x;						\
+									\
+		/* filter is a list...  title\0ext\0......\0\0 */	\
+		s = (LPSTR)ofn->lpstrFilter;				\
+		while (*s)						\
+			s = s+strlen(s)+1;				\
+		s++;							\
+		x = (LPSTR)SEGPTR_ALLOC(s-ofn->lpstrFilter);		\
+		memcpy(x,ofn->lpstrFilter,s-ofn->lpstrFilter);		\
+		ofn16->lpstrFilter = SEGPTR_GET(x);			\
+	}								\
+	if (ofn->lpstrCustomFilter) {					\
+		LPSTR	s,x;						\
+									\
+		/* filter is a list...  title\0ext\0......\0\0 */	\
+		s = (LPSTR)ofn->lpstrCustomFilter;			\
+		while (*s)						\
+			s = s+strlen(s)+1;				\
+		x = SEGPTR_ALLOC(s-ofn->lpstrCustomFilter);		\
+		s++;							\
+		memcpy(x,ofn->lpstrCustomFilter,s-ofn->lpstrCustomFilter);\
+		ofn16->lpstrCustomFilter = SEGPTR_GET(x);		\
+	}								\
+	ofn16->nMaxCustFilter = ofn->nMaxCustFilter;			\
+	ofn16->nFilterIndex = ofn->nFilterIndex;			\
+	ofn16->lpstrFile = SEGPTR_GET(SEGPTR_ALLOC(ofn->nMaxFile));	\
+	ofn16->nMaxFile = ofn->nMaxFile;				\
+	if (ofn->lpstrFileTitle)					\
+		ofn16->lpstrFileTitle= SEGPTR_GET(SEGPTR_STRDUP(ofn->lpstrFileTitle));\
+	ofn16->nMaxFileTitle = ofn->nMaxFileTitle;			\
+	if (ofn->lpstrInitialDir)					\
+		ofn16->lpstrInitialDir = SEGPTR_GET(SEGPTR_STRDUP(ofn->lpstrInitialDir));\
+	if (ofn->lpstrTitle)						\
+		ofn16->lpstrTitle = SEGPTR_GET(SEGPTR_STRDUP(ofn->lpstrTitle));\
+	ofn16->Flags = ofn->Flags|OFN_WINE32;				\
+	ofn16->nFileOffset = ofn->nFileOffset;				\
+	ofn16->nFileExtension = ofn->nFileExtension;			\
+	if (ofn->lpstrDefExt)						\
+		ofn16->lpstrDefExt = SEGPTR_GET(SEGPTR_STRDUP(ofn->lpstrDefExt));\
+	ofn16->lCustData = ofn->lCustData;				\
+	ofn16->lpfnHook = (WNDPROC16)ofn->lpfnHook;			\
+									\
+	if (ofn->lpTemplateName)					\
+		ofn16->lpTemplateName = SEGPTR_GET(SEGPTR_STRDUP(ofn->lpTemplateName));\
+									\
+	ret = xxx##16(SEGPTR_GET(ofn16));				\
+									\
+	if (ofn16->lpstrFilter)						\
+		SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFilter));	\
+	if (ofn16->lpTemplateName)					\
+		SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpTemplateName));	\
+	if (ofn16->lpstrDefExt)						\
+		SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrDefExt));	\
+	if (ofn16->lpstrTitle)						\
+		SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrTitle));		\
+	if (ofn16->lpstrInitialDir)					\
+		SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrInitialDir));	\
+	if (ofn16->lpstrCustomFilter)					\
+		SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrCustomFilter));	\
+									\
+	strcpy(ofn->lpstrFile,PTR_SEG_TO_LIN(ofn16->lpstrFile));	\
+	SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFile));			\
+									\
+	if (ofn16->lpstrFileTitle)					\
+		SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFileTitle));	\
+	SEGPTR_FREE(ofn16);						\
+	return ret;							\
+}									\
+									\
+BOOL32 xxx##32W( LPOPENFILENAME32W ofn )				\
+{									\
+	BOOL16 ret;							\
+	LPOPENFILENAME16 ofn16 = SEGPTR_ALLOC(sizeof(OPENFILENAME16));	\
+									\
+	memset(ofn16,'\0',sizeof(*ofn16));				\
+	ofn16->lStructSize = sizeof(*ofn16);				\
+	ofn16->hwndOwner = ofn->hwndOwner;				\
+	ofn16->hInstance = ofn->hInstance;				\
+	if (ofn->lpstrFilter) {						\
+		LPWSTR	s;						\
+		LPSTR	x,y;						\
+		int	n;						\
+									\
+		/* filter is a list...  title\0ext\0......\0\0 */	\
+		s = (LPWSTR)ofn->lpstrFilter;				\
+		while (*s)						\
+			s = s+lstrlen32W(s)+1;				\
+		s++;							\
+		n = s - ofn->lpstrFilter; /* already divides by 2. ptr magic */\
+		x = y = (LPSTR)SEGPTR_ALLOC(n);			\
+		s = (LPWSTR)ofn->lpstrFilter;				\
+		while (*s) {						\
+			lstrcpyWtoA(x,s);				\
+			x+=lstrlen32A(x)+1;				\
+			s+=lstrlen32W(s)+1;				\
+		}							\
+		*x=0;							\
+		ofn16->lpstrFilter = SEGPTR_GET(y);			\
+	}								\
+	if (ofn->lpstrCustomFilter) {					\
+		LPWSTR	s;						\
+		LPSTR	x,y;						\
+		int	n;						\
+									\
+		/* filter is a list...  title\0ext\0......\0\0 */	\
+		s = (LPWSTR)ofn->lpstrCustomFilter;			\
+		while (*s)						\
+			s = s+lstrlen32W(s)+1;				\
+		s++;							\
+		n = s - ofn->lpstrCustomFilter;				\
+		x = y = (LPSTR)SEGPTR_ALLOC(n);				\
+		s = (LPWSTR)ofn->lpstrCustomFilter;			\
+		while (*s) {						\
+			lstrcpyWtoA(x,s);				\
+			x+=lstrlen32A(x)+1;				\
+			s+=lstrlen32W(s)+1;				\
+		}							\
+		*x=0;							\
+		ofn16->lpstrCustomFilter = SEGPTR_GET(y);		\
+	}								\
+	ofn16->nMaxCustFilter = ofn->nMaxCustFilter;			\
+	ofn16->nFilterIndex = ofn->nFilterIndex;			\
+	ofn16->lpstrFile = SEGPTR_GET(SEGPTR_ALLOC(ofn->nMaxFile));	\
+	ofn16->nMaxFile = ofn->nMaxFile;				\
+	if (ofn->lpstrFileTitle)					\
+		ofn16->lpstrFileTitle= SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpstrFileTitle));\
+	ofn16->nMaxFileTitle = ofn->nMaxFileTitle;			\
+	if (ofn->lpstrInitialDir)					\
+		ofn16->lpstrInitialDir = SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpstrInitialDir));\
+	if (ofn->lpstrTitle)						\
+		ofn16->lpstrTitle = SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpstrTitle));\
+	ofn16->Flags = ofn->Flags|OFN_WINE32|OFN_UNICODE;		\
+	ofn16->nFileOffset = ofn->nFileOffset;				\
+	ofn16->nFileExtension = ofn->nFileExtension;			\
+	if (ofn->lpstrDefExt)						\
+		ofn16->lpstrDefExt = SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpstrDefExt));\
+	ofn16->lCustData = ofn->lCustData;				\
+	ofn16->lpfnHook = (WNDPROC16)ofn->lpfnHook;			\
+	if (ofn->lpTemplateName) {					\
+		ofn16->lpTemplateName = SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpTemplateName));\
+	}								\
+	ret = xxx##16(SEGPTR_GET(ofn16));				\
+									\
+	if (ofn16->lpstrFilter)						\
+		SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFilter));	\
+	if (ofn16->lpTemplateName)					\
+		SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpTemplateName));	\
+	if (ofn16->lpstrDefExt)						\
+		SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrDefExt));	\
+	if (ofn16->lpstrTitle)						\
+		SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrTitle));		\
+	if (ofn16->lpstrInitialDir)					\
+		SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrInitialDir));	\
+	if (ofn16->lpstrCustomFilter)					\
+		SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrCustomFilter));	\
+									\
+	lstrcpyAtoW(ofn->lpstrFile,PTR_SEG_TO_LIN(ofn16->lpstrFile));	\
+	SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFile));			\
+									\
+	if (ofn16->lpstrFileTitle)					\
+		SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFileTitle));	\
+	SEGPTR_FREE(ofn16);						\
+	return ret;							\
+}
+
+GET_XXX_FILENAME(GetOpenFileName)
+GET_XXX_FILENAME(GetSaveFileName)
diff --git a/misc/crtdll.c b/misc/crtdll.c
index 60d3aeb..0015d92 100644
--- a/misc/crtdll.c
+++ b/misc/crtdll.c
@@ -913,6 +913,19 @@
 }
 
 /*********************************************************************
+ *                  mbstowcs           (CRTDLL.429)
+ * FIXME: check multibyte support
+ */
+INT32
+CRTDLL_mbstowcs(LPWSTR a,LPSTR b,INT32 nr) {
+	int	i;
+	for (i=0;(i<nr) && b[i];i++) {
+		a[i] = (WCHAR)b[i];
+	}
+	return i;
+}
+
+/*********************************************************************
  *                  mbtowc           (CRTDLL.430)
  * FIXME: check multibyte support
  */
diff --git a/misc/printdrv.c b/misc/printdrv.c
index 9583c38..df0bb96 100644
--- a/misc/printdrv.c
+++ b/misc/printdrv.c
@@ -40,8 +40,16 @@
 DrvGetPrinterData(LPSTR lpPrinter, LPSTR lpProfile, LPDWORD lpType,
                   LPBYTE lpPrinterData, int cbData, LPDWORD lpNeeded)
 {
-    fprintf(stderr,"In DrvGetPrinterData printer %p profile %p lpType %p \n",
-           lpPrinter, lpProfile, lpType);
+    fprintf(stderr,"In DrvGetPrinterData ");
+    if (HIWORD(lpPrinter))
+	    fprintf(stderr,"printer %s ",lpPrinter);
+    else
+	    fprintf(stderr,"printer %p ",lpPrinter);
+    if (HIWORD(lpProfile))
+	    fprintf(stderr,"profile %s ",lpProfile);
+    else
+	    fprintf(stderr,"profile %p ",lpProfile);
+    fprintf(stderr,"lpType %p\n",lpType);
     return 0;
 }
 
@@ -51,8 +59,16 @@
 DrvSetPrinterData(LPSTR lpPrinter, LPSTR lpProfile, LPDWORD lpType,
                   LPBYTE lpPrinterData, DWORD dwSize)
 {
-    fprintf(stderr,"In DrvSetPrinterData printer %p profile %p lpType %p \n",
-           lpPrinter, lpProfile, lpType);
+    fprintf(stderr,"In DrvSetPrinterData ");
+    if (HIWORD(lpPrinter))
+	    fprintf(stderr,"printer %s ",lpPrinter);
+    else
+	    fprintf(stderr,"printer %p ",lpPrinter);
+    if (HIWORD(lpProfile))
+	    fprintf(stderr,"profile %s ",lpProfile);
+    else
+	    fprintf(stderr,"profile %p ",lpProfile);
+    fprintf(stderr,"lpType %p\n",lpType);
     return 0;
 }
 
diff --git a/multimedia/audio.c b/multimedia/audio.c
index 517325f..039521e 100644
--- a/multimedia/audio.c
+++ b/multimedia/audio.c
@@ -47,7 +47,7 @@
 	WAVEOPENDESC        waveDesc;
 	WORD                wFlags;
 	PCMWAVEFORMAT	    Format;
-	LPWAVEHDR 	    lpQueueHdr;
+	SEGPTR  	    lp16QueueHdr;  /* Segmented LPWAVEHDR */
 	DWORD		    dwTotalPlayed;
 	} LINUX_WAVEOUT;
 
@@ -58,7 +58,7 @@
 	WAVEOPENDESC        waveDesc;
 	WORD                wFlags;
 	PCMWAVEFORMAT       Format;
-	LPWAVEHDR           lpQueueHdr;
+	SEGPTR              lp16QueueHdr;  /* Segmented LPWAVEHDR */
 	DWORD               dwTotalRecorded;
 	} LINUX_WAVEIN;
 
@@ -296,6 +296,7 @@
 	        dwRet = wodMessage(wDevID, WODM_CLOSE, 0, 0L, 0L);
 	        if (dwRet != MMSYSERR_NOERROR) return MCIERR_INTERNAL;
 	        dwRet = widMessage(wDevID, WIDM_OPEN, 0, (DWORD)lpDesc, CALLBACK_NULL);
+		MCIWavDev[wDevID].fInput = TRUE;
 	}
 	else if (MCIWavDev[wDevID].fInput) {
 /* FIXME this is just a hack WInDev should be hidden here */
@@ -304,6 +305,7 @@
 	        dwRet = widMessage(wDevID, WIDM_CLOSE, 0, 0L, 0L);
 	        if (dwRet != MMSYSERR_NOERROR) return MCIERR_INTERNAL;
 	        dwRet = wodMessage(wDevID, WODM_OPEN, 0, (DWORD)lpDesc, CALLBACK_NULL);
+		MCIWavDev[wDevID].fInput = FALSE;
 	}
 
 	USER_HEAP_FREE(hDesc);
@@ -347,7 +349,7 @@
 	HGLOBAL16		hData;
 	HLOCAL16		hWaveHdr;
 	LPWAVEHDR		lpWaveHdr;
-	LPWAVEHDR		lp16WaveHdr;
+	SEGPTR  		lp16WaveHdr;
 	DWORD			dwRet;
 
 	dprintf_mciwave(stddeb,
@@ -398,10 +400,10 @@
 	lpWaveHdr->dwFlags = 0L;
 	lpWaveHdr->dwLoops = 0L;
 	hWaveHdr = USER_HEAP_ALLOC(sizeof(WAVEHDR));
-	lp16WaveHdr = (LPWAVEHDR) USER_HEAP_SEG_ADDR(hWaveHdr);
+	lp16WaveHdr = USER_HEAP_SEG_ADDR(hWaveHdr);
 	memcpy(PTR_SEG_TO_LIN(lp16WaveHdr), lpWaveHdr, sizeof(WAVEHDR));
 	lpWaveHdr = PTR_SEG_TO_LIN(lp16WaveHdr);
-	dwRet = wodMessage(wDevID, WODM_PREPARE, 0, (DWORD)lp16WaveHdr, sizeof(WAVEHDR));
+	dwRet = wodMessage(wDevID, WODM_PREPARE, 0, lp16WaveHdr, sizeof(WAVEHDR));
 	while(TRUE) {
 		count = mmioRead(MCIWavDev[wDevID].hFile, 
 			PTR_SEG_TO_LIN(lpWaveHdr->lpData), bufsize);
@@ -411,9 +413,9 @@
 /*		lpWaveHdr->dwBytesRecorded = count; */
 		dprintf_mciwave(stddeb,"WAVE_mciPlay // before WODM_WRITE lpWaveHdr=%p dwBufferLength=%lu dwBytesRecorded=%lu\n",
 				lpWaveHdr, lpWaveHdr->dwBufferLength, lpWaveHdr->dwBytesRecorded);
-		dwRet = wodMessage(wDevID, WODM_WRITE, 0, (DWORD)lp16WaveHdr, sizeof(WAVEHDR));
+		dwRet = wodMessage(wDevID, WODM_WRITE, 0, lp16WaveHdr, sizeof(WAVEHDR));
 		}
-	dwRet = wodMessage(wDevID, WODM_UNPREPARE, 0, (DWORD)lp16WaveHdr, sizeof(WAVEHDR));
+	dwRet = wodMessage(wDevID, WODM_UNPREPARE, 0, lp16WaveHdr, sizeof(WAVEHDR));
 	if (lpWaveHdr->lpData != NULL) {
 		GlobalUnlock16(hData);
 		GlobalFree16(hData);
@@ -439,7 +441,7 @@
 	HGLOBAL16		hData;
 	HLOCAL16		hWaveHdr;
 	LPWAVEHDR		lpWaveHdr;
-	LPWAVEHDR		lp16WaveHdr;
+	SEGPTR   		lp16WaveHdr;
 	DWORD			dwRet;
 
 	dprintf_mciwave(stddeb,
@@ -474,7 +476,7 @@
 	lpWaveHdr->dwFlags = 0L;
 	lpWaveHdr->dwLoops = 0L;
 	hWaveHdr = USER_HEAP_ALLOC(sizeof(WAVEHDR));
-	lp16WaveHdr = (LPWAVEHDR) USER_HEAP_SEG_ADDR(hWaveHdr);
+	lp16WaveHdr = USER_HEAP_SEG_ADDR(hWaveHdr);
 	memcpy(PTR_SEG_TO_LIN(lp16WaveHdr), lpWaveHdr, sizeof(WAVEHDR));
 	lpWaveHdr = PTR_SEG_TO_LIN(lp16WaveHdr);
 	dwRet = widMessage(wDevID, WIDM_PREPARE, 0, (DWORD)lp16WaveHdr, sizeof(WAVEHDR));
@@ -926,7 +928,7 @@
 			dprintf_mciwave(stddeb,	"Linux 'wodOpen' // CALLBACK_FUNCTION !\n");
 			break;
 		}
-	WOutDev[wDevID].lpQueueHdr = NULL;
+	WOutDev[wDevID].lp16QueueHdr = NULL;
 	WOutDev[wDevID].unixdev = audio;
 	WOutDev[wDevID].dwTotalPlayed = 0;
 	WOutDev[wDevID].bufsize = abuf_size;
@@ -986,10 +988,14 @@
 		dprintf_mciwave(stddeb,"Linux 'wodClose' // can't close !\n");
 		return MMSYSERR_NOTENABLED;
 		}
+	if (WOutDev[wDevID].lp16QueueHdr != NULL) {
+	        dprintf_mciwave(stddeb,"linux 'wodclose' // still buffers open !\n");
+		return WAVERR_STILLPLAYING;
+	}
 	close(WOutDev[wDevID].unixdev);
 	WOutDev[wDevID].unixdev = 0;
 	WOutDev[wDevID].bufsize = 0;
-	WOutDev[wDevID].lpQueueHdr = NULL;
+	WOutDev[wDevID].lp16QueueHdr = NULL;
 	if (WAVE_NotifyClient(wDevID, WOM_CLOSE, 0L, 0L) != MMSYSERR_NOERROR) {
 		dprintf_mciwave(stddeb,"Linux 'wodClose' // can't notify client !\n");
 		return MMSYSERR_INVALPARAM;
@@ -1000,11 +1006,11 @@
 /**************************************************************************
 * 				wodWrite			[internal]
 */
-static DWORD wodWrite(WORD wDevID, DWORD lpWH, DWORD dwSize)
+static DWORD wodWrite(WORD wDevID, SEGPTR lp16WaveHdr, DWORD dwSize)
 {
 	int		count;
 	LPSTR	        lpData;
-	LPWAVEHDR       lpWaveHdr = (LPWAVEHDR)PTR_SEG_TO_LIN(lpWH);
+	LPWAVEHDR       lpWaveHdr = (LPWAVEHDR)PTR_SEG_TO_LIN(lp16WaveHdr);
 
 	dprintf_mciwave(stddeb,"wodWrite(%u, %p, %08lX);\n", wDevID, lpWaveHdr, dwSize);
 	if (WOutDev[wDevID].unixdev == 0) {
@@ -1031,7 +1037,7 @@
 	WOutDev[wDevID].dwTotalPlayed += count;
 	lpWaveHdr->dwFlags &= ~WHDR_INQUEUE;
 	lpWaveHdr->dwFlags |= WHDR_DONE;
-	if (WAVE_NotifyClient(wDevID, WOM_DONE, lpWH, 0) != MMSYSERR_NOERROR) {
+	if (WAVE_NotifyClient(wDevID, WOM_DONE, lp16WaveHdr, count) != MMSYSERR_NOERROR) {
 		dprintf_mciwave(stddeb,"Linux 'wodWrite' // can't notify client !\n");
 		return MMSYSERR_INVALPARAM;
 		}
@@ -1041,14 +1047,19 @@
 /**************************************************************************
 * 				wodPrepare			[internal]
 */
-static DWORD wodPrepare(WORD wDevID, LPWAVEHDR lpWaveHdr, DWORD dwSize)
+static DWORD wodPrepare(WORD wDevID, SEGPTR lp16WaveHdr, DWORD dwSize)
 {
+        LPWAVEHDR lpWaveHdr;
+
 	dprintf_mciwave(stddeb,
-		"wodPrepare(%u, %p, %08lX);\n", wDevID, lpWaveHdr, dwSize);
+		"wodPrepare(%u, %p, %08lX);\n", wDevID, (void *)lp16WaveHdr, dwSize);
 	if (WOutDev[wDevID].unixdev == 0) {
 		dprintf_mciwave(stddeb,"Linux 'wodPrepare' // can't prepare !\n");
 		return MMSYSERR_NOTENABLED;
 		}
+
+	lpWaveHdr = PTR_SEG_TO_LIN(lp16WaveHdr);
+
 	/* the COOL waveeditor feels much better without this check... 
 	 * someone please have a look at available documentation
 	if (WOutDev[wDevID].lpQueueHdr != NULL) {
@@ -1057,7 +1068,7 @@
 	}
 	*/
 	WOutDev[wDevID].dwTotalPlayed = 0;
-	WOutDev[wDevID].lpQueueHdr = lpWaveHdr;
+	WOutDev[wDevID].lp16QueueHdr = lp16WaveHdr;
 	if (lpWaveHdr->dwFlags & WHDR_INQUEUE) return WAVERR_STILLPLAYING;
 	lpWaveHdr->dwFlags |= WHDR_PREPARED;
 	lpWaveHdr->dwFlags &= ~WHDR_DONE;
@@ -1075,6 +1086,13 @@
 		dprintf_mciwave(stddeb,"Linux 'wodUnprepare' // can't unprepare !\n");
 		return MMSYSERR_NOTENABLED;
 		}
+	
+	lpWaveHdr->dwFlags &= ~WHDR_PREPARED;
+	lpWaveHdr->dwFlags &= ~WHDR_INQUEUE;
+	lpWaveHdr->dwFlags |= WHDR_DONE;
+	WOutDev[wDevID].lp16QueueHdr = NULL;
+	dprintf_mciwave(stddeb,
+		"Linux 'wodUnprepare' // all headers unprepared !\n");
 	return MMSYSERR_NOERROR;
 }
 
@@ -1123,6 +1141,16 @@
 		return MMSYSERR_NOTENABLED;
 		}
 	if (lpTime == NULL)	return MMSYSERR_INVALPARAM;
+	dprintf_mciwave(stddeb,"wodGetPosition // wType=%04X !\n", 
+			lpTime->wType);
+	dprintf_mciwave(stddeb,"wodGetPosition // wBitsPerSample=%u\n",
+			WOutDev[wDevID].Format.wBitsPerSample); 
+	dprintf_mciwave(stddeb,"wodGetPosition // nSamplesPerSec=%lu\n",
+			WOutDev[wDevID].Format.wf.nSamplesPerSec); 
+	dprintf_mciwave(stddeb,"wodGetPosition // nChannels=%u\n",
+			WOutDev[wDevID].Format.wf.nChannels); 
+	dprintf_mciwave(stddeb,"wodGetPosition // nAvgBytesPerSec=%lu\n",
+			WOutDev[wDevID].Format.wf.nAvgBytesPerSec); 
 	switch(lpTime->wType) {
 		case TIME_BYTES:
 			lpTime->u.cb = WOutDev[wDevID].dwTotalPlayed;
@@ -1232,15 +1260,15 @@
 		case WODM_WRITE:
 			return wodWrite(wDevID, dwParam1, dwParam2);
 		case WODM_PAUSE:
-			return 0L;
+			return MMSYSERR_NOTSUPPORTED;
 	        case WODM_STOP:
-			return 0L;
+			return MMSYSERR_NOTSUPPORTED;
 		case WODM_GETPOS:
 			return wodGetPosition(wDevID, (LPMMTIME)PTR_SEG_TO_LIN(dwParam1), dwParam2);
 		case WODM_BREAKLOOP:
-			return 0L;
+			return MMSYSERR_NOTSUPPORTED;
 		case WODM_PREPARE:
-			return wodPrepare(wDevID, (LPWAVEHDR)PTR_SEG_TO_LIN(dwParam1), dwParam2);
+			return wodPrepare(wDevID, dwParam1, dwParam2);
 		case WODM_UNPREPARE:
 			return wodUnprepare(wDevID, (LPWAVEHDR)PTR_SEG_TO_LIN(dwParam1), dwParam2);
 		case WODM_GETDEVCAPS:
@@ -1389,7 +1417,7 @@
 			dprintf_mciwave(stddeb,	"Linux 'widOpen' // CALLBACK_FUNCTION !\n");
 			break;
 		}
-	WInDev[wDevID].lpQueueHdr = NULL;
+	WInDev[wDevID].lp16QueueHdr = NULL;
 	WInDev[wDevID].unixdev = audio;
 	WInDev[wDevID].bufsize = abuf_size;
 	WInDev[wDevID].dwTotalRecorded = 0;
@@ -1442,6 +1470,10 @@
 		dprintf_mciwave(stddeb,"Linux 'widClose' // can't close !\n");
 		return MMSYSERR_NOTENABLED;
 		}
+	if (WInDev[wDevID].lp16QueueHdr != NULL) {
+	        dprintf_mciwave(stddeb,"linux 'widclose' // still buffers open !\n");
+		return WAVERR_STILLPLAYING;
+	}
 	close(WInDev[wDevID].unixdev);
 	WInDev[wDevID].unixdev = 0;
 	WInDev[wDevID].bufsize = 0;
@@ -1455,10 +1487,12 @@
 /**************************************************************************
 * 				widAddBuffer		[internal]
 */
-static DWORD widAddBuffer(WORD wDevID, LPWAVEHDR lpWaveHdr, DWORD dwSize)
+static DWORD widAddBuffer(WORD wDevID, SEGPTR lp16WaveHdr, DWORD dwSize)
 {
 	int			count	= 1;
 	LPWAVEHDR 	lpWIHdr;
+	LPWAVEHDR       lpWaveHdr = (LPWAVEHDR)PTR_SEG_TO_LIN(lp16WaveHdr);
+
 	dprintf_mciwave(stddeb,
 		"widAddBuffer(%u, %p, %08lX);\n", wDevID, lpWaveHdr, dwSize);
 	if (WInDev[wDevID].unixdev == 0) {
@@ -1477,19 +1511,19 @@
 	lpWaveHdr->dwFlags |= WHDR_INQUEUE;
 	lpWaveHdr->dwFlags &= ~WHDR_DONE;
 	lpWaveHdr->dwBytesRecorded = 0;
-	if (WInDev[wDevID].lpQueueHdr == NULL) {
+	if (WInDev[wDevID].lp16QueueHdr == NULL) {
 		/* begin the queue with a first header ... */
-		WInDev[wDevID].lpQueueHdr = lpWaveHdr;
+		WInDev[wDevID].lp16QueueHdr = lp16WaveHdr;
 		WInDev[wDevID].dwTotalRecorded = 0;
 		}
 	else {
 		/* added to the queue, except if it's the one just prepared ... */
-		lpWIHdr = WInDev[wDevID].lpQueueHdr;
-		while (lpWIHdr->lpNext != NULL) {
-			lpWIHdr = lpWIHdr->lpNext;
+		lpWIHdr = (LPWAVEHDR)PTR_SEG_TO_LIN(WInDev[wDevID].lp16QueueHdr);
+		while (lpWIHdr->lp16Next != NULL) {
+			lpWIHdr = (LPWAVEHDR)PTR_SEG_TO_LIN(lpWIHdr->lp16Next);
 			count++;
 			}
-		lpWIHdr->lpNext = lpWaveHdr;
+		lpWIHdr->lp16Next = lp16WaveHdr;
 		count++;
 		}
 	dprintf_mciwave(stddeb,
@@ -1508,7 +1542,7 @@
 		dprintf_mciwave(stddeb,"Linux 'widPrepare' // can't prepare !\n");
 		return MMSYSERR_NOTENABLED;
 		}
-	if (WInDev[wDevID].lpQueueHdr != NULL) {
+	if (WInDev[wDevID].lp16QueueHdr != NULL) {
 		dprintf_mciwave(stddeb,"Linux 'widPrepare' // already prepare !\n");
 		return WAVERR_BADFORMAT;
 		}
@@ -1535,7 +1569,7 @@
 	lpWaveHdr->dwFlags &= ~WHDR_PREPARED;
 	lpWaveHdr->dwFlags &= ~WHDR_INQUEUE;
 	lpWaveHdr->dwFlags |= WHDR_DONE;
-	WInDev[wDevID].lpQueueHdr = NULL;
+	WInDev[wDevID].lp16QueueHdr = NULL;
 	dprintf_mciwave(stddeb,
 		"Linux 'widUnprepare' // all headers unprepared !\n");
 	return MMSYSERR_NOERROR;
@@ -1547,40 +1581,45 @@
 static DWORD widStart(WORD wDevID)
 {
 	int			count	= 1;
+	int             bytesRead;
 	LPWAVEHDR 	lpWIHdr;
+	SEGPTR          lp16WaveHdr;
+
 	dprintf_mciwave(stddeb,"widStart(%u);\n", wDevID);
 	if (WInDev[wDevID].unixdev == 0) {
 		dprintf_mciwave(stddeb,	"Linux 'widStart' // can't start recording !\n");
 		return MMSYSERR_NOTENABLED;
 		}
-	if (WInDev[wDevID].lpQueueHdr == NULL || 
-		WInDev[wDevID].lpQueueHdr->lpData == NULL) {
+
+	lp16WaveHdr = WInDev[wDevID].lp16QueueHdr;
+	dprintf_mciwave(stddeb,"Linux 'widstart'// lp16WaveHdr = %08lx\n",(DWORD)lp16WaveHdr);
+	if (lp16WaveHdr == NULL || 
+		((LPWAVEHDR)PTR_SEG_TO_LIN(lp16WaveHdr))->lpData == NULL) {
 		dprintf_mciwave(stddeb,"Linux 'widStart' // never been prepared !\n");
 		return WAVERR_UNPREPARED;
 		}
-	lpWIHdr = WInDev[wDevID].lpQueueHdr;
-	while(lpWIHdr != NULL) {
+
+	while(lp16WaveHdr != NULL) {
+	        lpWIHdr = (LPWAVEHDR)PTR_SEG_TO_LIN(lp16WaveHdr);
 		lpWIHdr->dwBufferLength &= 0xFFFF;
 		dprintf_mciwave(stddeb,
 			"widStart // recording buf#%u=%p size=%lu \n",
 			count, lpWIHdr->lpData, lpWIHdr->dwBufferLength);
 		fflush(stddeb);
-		read (WInDev[wDevID].unixdev, 
+		bytesRead = read (WInDev[wDevID].unixdev, 
 			PTR_SEG_TO_LIN(lpWIHdr->lpData),
 			lpWIHdr->dwBufferLength);
-		lpWIHdr->dwBytesRecorded = lpWIHdr->dwBufferLength;
+		lpWIHdr->dwBytesRecorded = bytesRead;
 		WInDev[wDevID].dwTotalRecorded += lpWIHdr->dwBytesRecorded;
 		lpWIHdr->dwFlags &= ~WHDR_INQUEUE;
 		lpWIHdr->dwFlags |= WHDR_DONE;
 
-/* FIXME here should be a segmented address in stead of lpWIHdr */
-
-		if (WAVE_NotifyClient(wDevID, WIM_DATA, (DWORD)lpWIHdr, 0L) != 
+		if (WAVE_NotifyClient(wDevID, WIM_DATA, (DWORD)lp16WaveHdr, lpWIHdr->dwBytesRecorded) != 
 			MMSYSERR_NOERROR) {
 			dprintf_mciwave(stddeb,	"Linux 'widStart' // can't notify client !\n");
 			return MMSYSERR_INVALPARAM;
 			}
-		lpWIHdr = lpWIHdr->lpNext;
+		lp16WaveHdr = lpWIHdr->lp16Next ;
 		count++;
 		}
 	dprintf_mciwave(stddeb,"widStart // end of recording !\n");
@@ -1697,7 +1736,7 @@
 		case WIDM_CLOSE:
 			return widClose(wDevID);
 		case WIDM_ADDBUFFER:
-			return widAddBuffer(wDevID, (LPWAVEHDR)PTR_SEG_TO_LIN(dwParam1), dwParam2);
+			return widAddBuffer(wDevID, dwParam1, dwParam2);
 		case WIDM_PREPARE:
 			return widPrepare(wDevID, (LPWAVEHDR)PTR_SEG_TO_LIN(dwParam1), dwParam2);
 		case WIDM_UNPREPARE:
diff --git a/multimedia/mcianim.c b/multimedia/mcianim.c
index 6ab5ddf..59a9f46 100644
--- a/multimedia/mcianim.c
+++ b/multimedia/mcianim.c
@@ -92,6 +92,9 @@
 	AnimDev[wDevID].dwTotalLen = 0;
 	AnimDev[wDevID].lpdwTrackLen = NULL;
 	AnimDev[wDevID].lpdwTrackPos = NULL;
+/*
+   Moved to mmsystem.c mciOpen routine 
+
 	if (dwFlags & MCI_NOTIFY) {
 		dprintf_mcianim(stddeb,
 			"ANIM_mciOpen // MCI_NOTIFY_SUCCESSFUL %08lX !\n", 
@@ -99,6 +102,7 @@
 		mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback), 
 			AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
 		}
+*/
  	return 0;
 #else
 	return MCIERR_HARDWARE;
diff --git a/multimedia/mcicda.c b/multimedia/mcicda.c
index 4213933..bfde0cc 100644
--- a/multimedia/mcicda.c
+++ b/multimedia/mcicda.c
@@ -270,6 +270,10 @@
 		dprintf_cdaudio(stddeb,"CDAUDIO_mciOpen // error reading TracksInfo !\n");
 /*		return MCIERR_INTERNAL; */
 		}
+
+/*
+   Moved to mmsystem.c mciOpen routine
+
 	if (dwFlags & MCI_NOTIFY) {
         	dprintf_cdaudio(stddeb,
 			"CDAUDIO_mciOpen // MCI_NOTIFY_SUCCESSFUL %08lX !\n", 
@@ -277,6 +281,7 @@
 		mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback), 
 			CDADev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
 		}
+*/
  	return 0;
 #else
 	return MCIERR_HARDWARE;
diff --git a/multimedia/mcistring.c b/multimedia/mcistring.c
index be6c706..36d3389 100644
--- a/multimedia/mcistring.c
+++ b/multimedia/mcistring.c
@@ -6,6 +6,11 @@
 /* FIXME: special commands of device drivers should be handled by those drivers
  */
 
+/* FIXME: this current implementation does not allow commands like
+ * capability <filename> can play
+ * which is allowed by the MCI standard.
+ */
+
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -57,7 +62,8 @@
 /* standard functionparameters for all functions */
 #define _MCISTR_PROTO_ \
 	WORD wDevID,WORD uDevTyp,LPSTR lpstrReturnString,UINT16 uReturnLength,\
-	LPCSTR dev,LPSTR *keywords,UINT16 nrofkeywords,DWORD dwFlags
+	LPCSTR dev,LPSTR *keywords,UINT16 nrofkeywords,DWORD dwFlags,\
+        HWND16 hwndCallback
 
 /* copy string to return pointer including necessary checks 
  * for use in mciSendString()
@@ -340,7 +346,7 @@
 	}
 	GetDrv(wDevID)->wType		= uDevTyp;
 	GetDrv(wDevID)->wDeviceID	= 0;  /* FIXME? for multiple devices */
-	pU->openParams.dwCallback	= 0;
+	pU->openParams.dwCallback	= hwndCallback ;
 	pU->openParams.wDeviceID	= wDevID;
 	pU->ovlyopenParams.dwStyle	= 0; 
 	pU->animopenParams.dwStyle	= 0; 
@@ -543,7 +549,7 @@
 	MCI_STATUS_PARMS	*statusParams = SEGPTR_NEW(MCI_STATUS_PARMS);
 	int			type = 0,i,res,timef;
 
-	statusParams->dwCallback = 0;
+	statusParams->dwCallback = hwndCallback;
 	dwFlags	|= MCI_STATUS_ITEM;
 	res = _MCISTR_determine_timeformat(dev,wDevID,uDevTyp,&timef);
 	if (res) return res;
@@ -672,7 +678,7 @@
         union U *pU = SEGPTR_NEW(union U);
 	int	i,res;
 
-	pU->setParams.dwCallback = 0;
+	pU->setParams.dwCallback = hwndCallback;
 	i = 0;
 	while (i<nrofkeywords) {
 		FLAG2("door","open",MCI_SET_DOOR_OPEN);
@@ -931,7 +937,7 @@
 	MCI_GETDEVCAPS_PARMS *gdcParams = SEGPTR_NEW(MCI_GETDEVCAPS_PARMS);
 	int	type=0,i,res;
 
-	gdcParams->dwCallback = 0;
+	gdcParams->dwCallback = hwndCallback;
 	if (!nrofkeywords)
 		return MCIERR_MISSING_STRING_ARGUMENT;
 	/* well , thats default */
@@ -995,7 +1001,7 @@
 {
     MCI_GENERIC_PARMS *genParams = SEGPTR_NEW(MCI_GENERIC_PARMS);
     int	res;
-    genParams->dwCallback = 0;
+    genParams->dwCallback = hwndCallback;
     _MCI_CALL_DRIVER( MCI_RESUME, SEGPTR_GET(genParams) );
     return res;
 }
@@ -1006,7 +1012,7 @@
 {
     MCI_GENERIC_PARMS *genParams = SEGPTR_NEW(MCI_GENERIC_PARMS);
     int res;
-    genParams->dwCallback = 0;
+    genParams->dwCallback = hwndCallback;
     _MCI_CALL_DRIVER( MCI_PAUSE, SEGPTR_GET(genParams) );
     return res;
 }
@@ -1017,7 +1023,7 @@
 {
     MCI_GENERIC_PARMS *genParams = SEGPTR_NEW(MCI_GENERIC_PARMS);
     int res;
-    genParams->dwCallback = 0;
+    genParams->dwCallback = hwndCallback;
     _MCI_CALL_DRIVER( MCI_STOP, SEGPTR_GET(genParams) );
     return res;
 }
@@ -1060,7 +1066,7 @@
 		nrargs=1;
 		break;
 	}
-	recordParams->dwCallback = 0;
+	recordParams->dwCallback = hwndCallback;
 	i = 0;
 	while (i<nrofkeywords) {
 		if (!strcmp(keywords[i],"to") && (i+1<nrofkeywords)) {
@@ -1149,7 +1155,7 @@
 		nrargs=1;
 		break;
 	}
-	pU->playParams.dwCallback=0;
+	pU->playParams.dwCallback=hwndCallback;
 	i=0;
 	while (i<nrofkeywords) {
 		if (!strcmp(keywords[i],"to") && (i+1<nrofkeywords)) {
@@ -1246,7 +1252,7 @@
 		nrargs=1;
 		break;
 	}
-	seekParams->dwCallback=0;
+	seekParams->dwCallback=hwndCallback;
 	i=0;
 	while (i<nrofkeywords) {
 		if (	!STRCMP(keywords[i],"to") && (i+1<nrofkeywords)) {
@@ -2157,8 +2163,7 @@
 			continue;
 		}
 		if (!STRCMP(keywords[i],"notify")) {
-			/* how should we callback?  I don't know. */
-			/*dwFlags |= MCI_NOTIFY;*/
+		        dwFlags |= MCI_NOTIFY;
 			memcpy(keywords+i,keywords+(i+1),(nrofkeywords-i-1)*sizeof(char *));
 			nrofkeywords--;
 			continue;
@@ -2181,7 +2186,7 @@
 			if (!MMSYSTEM_DevIDValid(wDevID)) {
 				dprintf_mci(stddeb, __FILE__":mciSendString:MAXMCIDRIVERS reached!\n");
 				free(keywords);free(cmd);
-				return MCIERR_INTERNAL;
+				return MCIERR_INVALID_DEVICE_NAME;
 			}
 		}
 		uDevTyp=GetDrv(wDevID)->wType;
@@ -2192,7 +2197,7 @@
  			res=MCISTR_cmdtable[i].fun(
  				wDevID,uDevTyp,lpstrReturnString,
  				uReturnLength,dev,(LPSTR*)keywords,nrofkeywords,
- 				dwFlags
+ 				dwFlags,hwndCallback
  			);
  			break;
  		}
diff --git a/multimedia/midi.c b/multimedia/midi.c
index 4706a45..7384f8d 100644
--- a/multimedia/midi.c
+++ b/multimedia/midi.c
@@ -91,14 +91,42 @@
 static DWORD MIDI_NotifyClient(UINT16 wDevID, WORD wMsg, 
 				DWORD dwParam1, DWORD dwParam2)
 {
+	dprintf_midi(stddeb,"MIDI_NotifyClient // wDevID = %04X wMsg = %d dwParm1 = %04lX dwParam2 = %04lX\n",wDevID, wMsg, dwParam1, dwParam2);
+
 #if defined(linux) || defined(__FreeBSD__)
+
+	switch (wMsg) {
+	case MOM_OPEN:
+	case MOM_CLOSE:
+	case MOM_DONE:
+	  if (wDevID > MAX_MIDIOUTDRV) return MCIERR_INTERNAL;
+	  
+	  if (MidiOutDev[wDevID].wFlags != DCB_NULL && !DriverCallback(
+		MidiOutDev[wDevID].midiDesc.dwCallback, 
+		MidiOutDev[wDevID].wFlags, 
+		MidiOutDev[wDevID].midiDesc.hMidi, 
+                wMsg, 
+		MidiOutDev[wDevID].midiDesc.dwInstance, 
+                dwParam1, 
+                dwParam2)) {
+	    dprintf_midi(stddeb,"MIDI_NotifyClient // can't notify client !\n");
+	    return MMSYSERR_NOERROR;
+	  }
+	  break;
+
+	case MIM_OPEN:
+	case MIM_CLOSE:
+	  if (wDevID > MAX_MIDIINDRV) return MCIERR_INTERNAL;
+	  
 	if (MidiInDev[wDevID].wFlags != DCB_NULL && !DriverCallback(
 		MidiInDev[wDevID].midiDesc.dwCallback, MidiInDev[wDevID].wFlags, 
 		MidiInDev[wDevID].midiDesc.hMidi, wMsg, 
 		MidiInDev[wDevID].midiDesc.dwInstance, dwParam1, dwParam2)) {
-		dprintf_midi(stddeb, "MIDI_NotifyClient // can't notify client !\n");
+	    dprintf_mciwave(stddeb,"MIDI_NotifyClient // can't notify client !\n");
 		return MMSYSERR_NOERROR;
 		}
+	  break;
+	}
         return 0;
 #else
 	return MMSYSERR_NOTENABLED;
@@ -293,6 +321,7 @@
 		MCIMidiDev[wDevID].fShareable = dwFlags & MCI_OPEN_SHAREABLE;
 		MCIMidiDev[wDevID].hMidiHdr = USER_HEAP_ALLOC(sizeof(MIDIHDR));
 		}
+
 	dprintf_midi(stddeb, "MIDI_mciOpen // wDevID=%04X\n", wDevID);
 /*	lpParms->wDeviceID = wDevID;*/
 	dprintf_midi(stddeb, "MIDI_mciOpen // lpParms->wDevID=%04X\n", lpParms->wDeviceID);
@@ -352,15 +381,16 @@
 				(LPSTR)&ckMainRIFF.ckid, (LPSTR)&ckMainRIFF.fccType,
 				ckMainRIFF.cksize);
 		}
+
 	dwRet = modMessage(wDevID, MODM_OPEN, 0, (DWORD)&MidiDesc, CALLBACK_NULL);
-/*	dwRet = midMessage(wDevID, MIDM_OPEN, 0, (DWORD)&MidiDesc, CALLBACK_NULL); */
+/*	dwRet = midMessage(wDevID, MIDM_OPEN, 0, (DWORD)&MidiDesc, CALLBACK_NULL);*/
+
 	return 0;
 #else
 	return MMSYSERR_NOTENABLED;
 #endif
 }
 
-
 /**************************************************************************
 * 				MIDI_mciStop			[internal]
 */
@@ -868,7 +898,12 @@
 static DWORD midGetDevCaps(WORD wDevID, LPMIDIINCAPS lpCaps, DWORD dwSize)
 {
 	dprintf_midi(stddeb, "midGetDevCaps(%04X, %p, %08lX);\n", wDevID, lpCaps, dwSize);
-	return MMSYSERR_NOTENABLED;
+	lpCaps->wMid = 0x00FF; 	        /* Manufac ID */
+	lpCaps->wPid = 0x0001; 	        /* Product ID */
+	lpCaps->vDriverVersion = 0x001; /* Product Version */
+	strcpy(lpCaps->szPname, "Linux MIDIIN Driver");
+
+	return MMSYSERR_NOERROR;
 }
 
 /**************************************************************************
@@ -1051,7 +1086,21 @@
 static DWORD modGetDevCaps(WORD wDevID, LPMIDIOUTCAPS lpCaps, DWORD dwSize)
 {
 	dprintf_midi(stddeb, "modGetDevCaps(%04X, %p, %08lX);\n", wDevID, lpCaps, dwSize);
-	return MMSYSERR_NOTENABLED;
+	lpCaps->wMid = 0x00FF; 	/* Manufac ID */
+	lpCaps->wPid = 0x0001; 	/* Product ID */
+	lpCaps->vDriverVersion = 0x001; /* Product Version */
+	strcpy(lpCaps->szPname, "Linux MIDIOUT Driver version 0.01");
+/* FIXME
+   Values are the same as I get with Borland TC 4.5
+*/
+
+	lpCaps->wTechnology = MOD_FMSYNTH;
+	lpCaps->wVoices     = 14;       /* make it ioctl */
+	lpCaps->wNotes      = 14;       /* make it ioctl */
+	lpCaps->dwSupport   = MIDICAPS_VOLUME|MIDICAPS_LRVOLUME;
+	dprintf_midi(stddeb,"Linux modGetDevCaps // techn = %d voices=%d notes = %d support = %ld\n",lpCaps->wTechnology,lpCaps->wVoices,lpCaps->wNotes,lpCaps->dwSupport);
+
+	return MMSYSERR_NOERROR;
 }
 
 
diff --git a/multimedia/mmsystem.c b/multimedia/mmsystem.c
index e8d094a..42eace9 100644
--- a/multimedia/mmsystem.c
+++ b/multimedia/mmsystem.c
@@ -12,6 +12,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <fcntl.h>
+#include <errno.h>
 #include <sys/ioctl.h>
 #include "windows.h"
 #include "win.h"
@@ -280,20 +281,19 @@
 			dprintf_mmsys(stddeb, "DriverCallback() // CALLBACK_NULL !\n");
 			break;
 		case DCB_WINDOW:
-			dprintf_mmsys(stddeb, "DriverCallback() // CALLBACK_WINDOW = %04lX!\n",dwCallBack);
+			dprintf_mmsys(stddeb, "DriverCallback() // CALLBACK_WINDOW = %04lX handle = %04X!\n",dwCallBack,hDev);
 			if (!IsWindow32(dwCallBack)) return FALSE;
-			dprintf_mmsys(stddeb, "DriverCallback() // Device Handle = %04X\n", hDev);
 			lpDesc = (LPWAVEOPENDESC) USER_HEAP_LIN_ADDR(hDev);
 			if (lpDesc == NULL) return FALSE;
 
-			dprintf_mmsys(stddeb, "DriverCallback() // Before PostMessage16\n");
 			PostMessage16((HWND16)dwCallBack, wMsg, hDev, dwParam1);
 			break;
 		case DCB_TASK:
 			dprintf_mmsys(stddeb, "DriverCallback() // CALLBACK_TASK !\n");
-			break;
+			return FALSE;
 		case DCB_FUNCTION:
 			dprintf_mmsys(stddeb, "DriverCallback() // CALLBACK_FUNCTION !\n");
+			CallTo16_word_wwlll((FARPROC16)dwCallBack,hDev,wMsg,dwUser,dwParam1,dwParam2);
 			break;
 		}
 	return TRUE;
@@ -715,7 +715,7 @@
 			uDevTyp = LOWORD((DWORD)lpParms->lpstrDeviceType);
  			GetOpenDrv(wDevID)->lpstrDeviceType=lpParms->lpstrDeviceType;
 		} else {
-			if (lpParms->lpstrDeviceType == NULL) return MCIERR_INTERNAL;
+			if (lpParms->lpstrDeviceType == (SEGPTR)NULL) return MCIERR_INTERNAL;
 			dprintf_mmsys(stddeb, "MCI_OPEN // Dev='%s' !\n",
                               (char*)PTR_SEG_TO_LIN(lpParms->lpstrDeviceType));
                         GetOpenDrv(wDevID)->lpstrDeviceType = SEGPTR_GET(
@@ -770,11 +770,14 @@
 	  return MCIERR_INVALID_DEVICE_NAME;
         }
 
+
+	if (dwParam&MCI_NOTIFY)
+	  mciDriverNotify(lpParms->dwCallback,wDevID,
+			  (dwret==0?MCI_NOTIFY_SUCCESSFUL:MCI_NOTIFY_FAILURE));
+
 	/* only handled devices fall through */
 	dprintf_mmsys(stddeb, "MCI_OPEN // wDevID = %04X wDeviceID = %d dwret = %ld\n",wDevID, lpParms->wDeviceID, dwret);
 	return dwret;
-
-/*	return MCIERR_INTERNAL; */
 }
 
 
@@ -811,6 +814,11 @@
 			dwRet = MCIERR_DEVICE_NOT_INSTALLED;
 		}
 	GetDrv(wDevID)->wType = 0;
+
+	if (dwParam&MCI_NOTIFY)
+	  mciDriverNotify(lpParms->dwCallback,wDevID,
+			  (dwRet==0?MCI_NOTIFY_SUCCESSFUL:MCI_NOTIFY_FAILURE));
+
 	dprintf_mmsys(stddeb, "mciClose() // returns %ld\n",dwRet);
 	return dwRet;
 }
@@ -1046,7 +1054,7 @@
 UINT16 midiOutGetDevCaps(UINT16 uDeviceID, MIDIOUTCAPS * lpCaps, UINT16 uSize)
 {
 	dprintf_mmsys(stddeb, "midiOutGetDevCaps\n");
-	return 0;
+	return modMessage(uDeviceID,MODM_GETDEVCAPS,0,(DWORD)lpCaps,uSize);
 }
 
 /**************************************************************************
@@ -1307,7 +1315,7 @@
     LPMIDIINCAPS lpCaps, UINT16 uSize)
 {
 	dprintf_mmsys(stddeb, "midiInGetDevCaps\n");
-	return 0;
+	return midMessage(uDeviceID,MIDM_GETDEVCAPS,0,(DWORD)lpCaps,uSize);;
 }
 
 /**************************************************************************
@@ -1592,6 +1600,7 @@
 	lpDesc->lpFormat = lpFormat;  /* should the struct be copied iso pointer? */
 	lpDesc->dwCallBack = dwCallback;
 	lpDesc->dwInstance = dwInstance;
+	if (uDeviceID >= MAXWAVEDRIVERS) uDeviceID = 0;
 	while(uDeviceID < MAXWAVEDRIVERS) {
 		dwRet = wodMessage(uDeviceID, WODM_OPEN, 
 			lpDesc->dwInstance, (DWORD)lp16Desc, dwFlags);
@@ -1899,7 +1908,7 @@
 	lpDesc->uDeviceID = uDeviceID;
 	if (dwFlags & WAVE_FORMAT_QUERY) {
 		dprintf_mmsys(stddeb, "waveInOpen	// End of WAVE_FORMAT_QUERY !\n");
-		waveInClose(hWaveIn);
+		dwRet = waveInClose(hWaveIn);
 		}
 	return dwRet;
 }
@@ -1934,7 +1943,7 @@
 	if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
 	if (lpWaveInHdr == NULL) return MMSYSERR_INVALHANDLE;
 	lp32WaveInHdr = PTR_SEG_TO_LIN(lpWaveInHdr);
-	lp32WaveInHdr->lpNext = NULL;
+	lp32WaveInHdr->lp16Next = (SEGPTR)NULL;
     lp32WaveInHdr->dwBytesRecorded = 0;
 	dprintf_mmsys(stddeb, "waveInPrepareHeader // lpData=%p size=%lu \n", 
 		lp32WaveInHdr->lpData, lp32WaveInHdr->dwBufferLength);
@@ -1960,7 +1969,7 @@
 	lp32WaveInHdr = PTR_SEG_TO_LIN(lpWaveInHdr);
 	USER_HEAP_FREE(HIWORD((DWORD)lp32WaveInHdr->lpData));
 	lp32WaveInHdr->lpData = NULL;
-	lp32WaveInHdr->lpNext = NULL;
+	lp32WaveInHdr->lp16Next = (SEGPTR)NULL;
 	return widMessage(lpDesc->uDeviceID, WIDM_UNPREPARE, lpDesc->dwInstance, 
 							(DWORD)lpWaveInHdr, uSize);
 }
@@ -1980,7 +1989,7 @@
 	if (lpDesc == NULL) return MMSYSERR_INVALHANDLE;
 	if (lpWaveInHdr == NULL) return MMSYSERR_INVALHANDLE;
 	lp32WaveInHdr = PTR_SEG_TO_LIN(lpWaveInHdr);
-	lp32WaveInHdr->lpNext = NULL;
+	lp32WaveInHdr->lp16Next = (SEGPTR)NULL;
     lp32WaveInHdr->dwBytesRecorded = 0;
 	dprintf_mmsys(stddeb, "waveInAddBuffer // lpData=%p size=%lu \n", 
 		lp32WaveInHdr->lpData, lp32WaveInHdr->dwBufferLength);
diff --git a/objects/dc.c b/objects/dc.c
index 4f25c90..0210fc3 100644
--- a/objects/dc.c
+++ b/objects/dc.c
@@ -305,11 +305,11 @@
     switch (dc->w.ROPmode)
     {
     case R2_BLACK :
-	val.foreground = BlackPixel(display, DefaultScreen(display));
+	val.foreground = BlackPixelOfScreen( screen );
 	val.function = GXcopy;
 	break;
     case R2_WHITE :
-	val.foreground = WhitePixel(display, DefaultScreen(display));
+	val.foreground = WhitePixelOfScreen( screen );
 	val.function = GXcopy;
 	break;
     case R2_XORPEN :
@@ -317,8 +317,8 @@
 	/* It is very unlikely someone wants to XOR with 0 */
 	/* This fixes the rubber-drawings in paintbrush */
 	if (val.foreground == 0)
-	    val.foreground = BlackPixel(display, DefaultScreen(display))
-			    ^ WhitePixel(display, DefaultScreen(display));
+	    val.foreground = BlackPixelOfScreen( screen )
+			    ^ WhitePixelOfScreen( screen );
 	val.function = GXxor;
 	break;
     default :
diff --git a/objects/font.c b/objects/font.c
index e79c6b6..75dcf63 100644
--- a/objects/font.c
+++ b/objects/font.c
@@ -797,6 +797,7 @@
     Italic = % 3i\t LastChar = %03i\t\t MaxCharWidth = %i
     UnderLined = %01i\t DefaultChar = %03i\t Overhang = %i
     StruckOut = %01i\t BreakChar = %03i\t CharSet = %i
+    PitchAndFamily = %02x
     --------------------
     InternalLeading = %i
     Ascent = %i
@@ -806,6 +807,7 @@
     metrics->tmItalic, metrics->tmLastChar, metrics->tmMaxCharWidth,
     metrics->tmUnderlined, metrics->tmDefaultChar, metrics->tmOverhang,
     metrics->tmStruckOut, metrics->tmBreakChar, metrics->tmCharSet,
+    metrics->tmPitchAndFamily,
     metrics->tmInternalLeading,
     metrics->tmAscent,
     metrics->tmDescent,
@@ -852,11 +854,11 @@
 	    HeapFree(SystemHeap, 0, obuf32);
 	}
     }
-    else
+    else /* happens quite often to warrant a special treatment */
     {
 	INT32 chWidth;
 	retVal = GetCharWidth32A(hdc, firstChar, lastChar, &chWidth );
-	*buffer = chWidth;
+       *buffer = chWidth;
     }
     return retVal;
 }
@@ -868,6 +870,7 @@
 BOOL32 GetCharWidth32A( HDC32 hdc, UINT32 firstChar, UINT32 lastChar,
                         LPINT32 buffer )
 {
+    UINT32 i, extra;
     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
     if (!dc)
     {
@@ -879,6 +882,12 @@
         !dc->funcs->pGetCharWidth( dc, firstChar, lastChar, buffer))
         return FALSE;
 
+    /* convert device units to logical */
+
+    extra = dc->vportExtX >> 1;
+    for( i = firstChar; i <= lastChar; i++, buffer++ )
+         *buffer = (*buffer * dc->wndExtX + extra) / dc->vportExtX;
+
     return TRUE;
 }
 
diff --git a/objects/gdiobj.c b/objects/gdiobj.c
index 52c8bd5..813fa6f 100644
--- a/objects/gdiobj.c
+++ b/objects/gdiobj.c
@@ -37,19 +37,23 @@
 static BRUSHOBJ LtGrayBrush =
 {
     { 0, BRUSH_MAGIC, 1 },             /* header */
+/* FIXME : this should perhaps be BS_HATCHED, at least for 1 bitperpixel */
     { BS_SOLID, RGB(192,192,192), 0 }  /* logbrush */
 };
 
 static BRUSHOBJ GrayBrush =
 {
     { 0, BRUSH_MAGIC, 1 },             /* header */
+/* FIXME : this should perhaps be BS_HATCHED, at least for 1 bitperpixel */
     { BS_SOLID, RGB(128,128,128), 0 }  /* logbrush */
 };
 
 static BRUSHOBJ DkGrayBrush =
 {
     { 0, BRUSH_MAGIC, 1 },          /* header */
-    { BS_SOLID, RGB(64,64,64), 0 }  /* logbrush */
+/* This is BS_HATCHED, for 1 bitperpixel. This makes the spray work in pbrush */
+/* NB_HATCH_STYLES is an index into HatchBrushes */
+    { BS_HATCHED, RGB(0,0,0), NB_HATCH_STYLES }  /* logbrush */
 };
 
 static BRUSHOBJ BlackBrush =
@@ -106,7 +110,7 @@
 static FONTOBJ SystemFont =
 {
     { 0, FONT_MAGIC, 1 },
-    { 12, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET,
+    { 16, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET,
       0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, "System" }
 };
 
diff --git a/objects/text.c b/objects/text.c
index ce7572b..176ddd6 100644
--- a/objects/text.c
+++ b/objects/text.c
@@ -601,3 +601,15 @@
     HeapFree( GetProcessHeap(), 0, p );
     return ret;
 }
+
+/***********************************************************************
+ *           GetTextCharset    (USER32.226) (USER.612)
+ */
+INT32 GetTextCharset32(HDC32 hdc) {
+    fprintf(stdnimp,"GetTextCharset(0x%x)\n",hdc);
+    return DEFAULT_CHARSET; /* FIXME */
+}
+
+INT16 GetTextCharset16(HDC16 hdc) {
+    return GetTextCharset32(hdc);
+}
diff --git a/programs/winhelp/ChangeLog b/programs/winhelp/ChangeLog
index 3845ae3..63484af 100644
--- a/programs/winhelp/ChangeLog
+++ b/programs/winhelp/ChangeLog
@@ -1,3 +1,8 @@
+Tue Jun  3 07:47:42 1997  Marcel Baur <mbaur@g26.ethz.ch
+
+	* [Va.rc] (new)
+	Added Vallader (Rumantsch Ladin) language support.
+
 Wed Feb 12 00:58:37 1997  Elker Cavina <elker@mail.asianet.it>
 
 	* [It.rc] (new)
diff --git a/programs/winhelp/Makefile.in b/programs/winhelp/Makefile.in
index 9a9edfd..0e5ea16 100644
--- a/programs/winhelp/Makefile.in
+++ b/programs/winhelp/Makefile.in
@@ -7,7 +7,7 @@
 ALL_LIBS  = $(WINELIB) $(X_LIBS) $(XPM_LIB) $(XLIB) $(LDLIBS)
 RCFLAGS   = -w32
 
-LANGUAGES   = En De Fr Fi Ko Hu It
+LANGUAGES   = En De Fr Fi Ko Hu It Va
 
 # Installation infos
 
diff --git a/programs/winhelp/Va.rc b/programs/winhelp/Va.rc
new file mode 100644
index 0000000..62d0424
--- /dev/null
+++ b/programs/winhelp/Va.rc
@@ -0,0 +1,51 @@
+/*
+ * Help Viewer
+ * 
+ * Copyright 1996 Ulrich Schmid
+ *
+ * Rumantsch Ladin (Vallader) by mbaur@g26.ethz.ch
+ *
+ */
+
+/* This file is not yet complete !! */
+
+#define LANGUAGE_ID                  Rl
+#define LANGUAGE_NUMBER              C
+
+/* Menu */
+
+#define MENU_FILE                    "&Datoteca"
+#define MENU_FILE_OPEN               "&Rivir"
+#define MENU_FILE_PRINT              "&Stampar tema"
+#define MENU_FILE_PRINTER_SETUP      "&Installaziun dal stampader..."
+#define MENU_FILE_EXIT               "&Finir"
+
+#define MENU_EDIT                    "&Lavurar"
+#define MENU_EDIT_COPY_DIALOG        "&Capchar"
+#define MENU_EDIT_ANNOTATE           "&Annotaziun..."
+
+#define MENU_BOOKMARK                "&Marca"
+#define MENU_BOOKMARK_DEFINE         "&Definir..."
+
+#define MENU_HELP                    "&Agüd"
+#define MENU_HELP_ON_HELP            "&Douvrar l'agüd"
+#define MENU_HELP_ON_TOP             "Adüna da&vant"
+#define MENU_HELP_INFO               "I&nfuormaziuns"
+#define MENU_HELP_ABOUT_WINE         "Davart &WINE"
+
+/* Strings */
+
+#define STRING_WINE_HELP             "WINE agüd"
+#define STRING_ERROR                 "SBAGL"
+#define STRING_WARNING               "ATTENZIUN"
+#define STRING_INFO                  "INFUORMAZIUN"
+#define STRING_NOT_IMPLEMENTED       "Na implementa"
+#define STRING_HLPFILE_ERROR_s       "Sbagl cun leger la datoteca d'agüd `%s'"
+#define STRING_CONTENTS              "&Cuntgnü"
+#define STRING_SEARCH                "&Tscherchar"
+#define STRING_BACK                  "&Inavo"
+#define STRING_HISTORY               "&Fin qua"
+#define STRING_ALL_FILES             "Tuot las datotecas (*.*)"
+#define STRING_HELP_FILES_HLP        "Datotecas d'agüd (*.hlp)"
+
+#include "Xx.rc"
diff --git a/programs/winhelp/winhelp.c b/programs/winhelp/winhelp.c
index 8c338e3..8b53055 100644
--- a/programs/winhelp/winhelp.c
+++ b/programs/winhelp/winhelp.c
@@ -21,6 +21,7 @@
 VOID LIBWINE_Register_It(void);
 VOID LIBWINE_Register_Ko(void);
 VOID LIBWINE_Register_Hu(void);
+VOID LIBWINE_Register_Va(void);
 
 static BOOL    WINHELP_RegisterWinClasses();
 static LRESULT WINHELP_MainWndProc(HWND, UINT, WPARAM, LPARAM);
@@ -62,6 +63,7 @@
   LIBWINE_Register_It();
   LIBWINE_Register_Ko();
   LIBWINE_Register_Hu();
+  LIBWINE_Register_Va();
 #endif
 
   Globals.hInstance = hInstance;
diff --git a/rc/parser.h b/rc/parser.h
index c0d2d27..cb345ae 100644
--- a/rc/parser.h
+++ b/rc/parser.h
@@ -67,7 +67,8 @@
 gen_res* dialog_caption(char*,gen_res*);
 gen_res* dialog_font(short,char*,gen_res*);
 gen_res* dialog_class(char*,gen_res*);
-gen_res* dialog_menu(char*,gen_res*);
+gen_res* dialog_menu_id(short,gen_res*);
+gen_res* dialog_menu_str(char*,gen_res*);
 gen_res* create_control_desc(int,int,int,int,int,rc_style*);
 gen_res* label_control_desc(char*,gen_res*);
 gen_res* create_generic_control(char*,int,char*,rc_style*,int,int,int,int);
diff --git a/rc/parser.y b/rc/parser.y
index bbf38fa..cae8a1a 100644
--- a/rc/parser.y
+++ b/rc/parser.y
@@ -72,7 +72,7 @@
                 ;
 
 /* have to use tBEGIN because BEGIN is predefined */
-accelerators:	ACCELERATORS  tBEGIN  events tEND {$$=$3;$$->type=acc;}
+accelerators:	ACCELERATORS load_and_memoption tBEGIN  events tEND {$$=$4;$$->type=acc;}
 /* the events are collected in a gen_res, as the accelerator resource is just
    an array of events */
 events:		{$$=new_res();}
@@ -113,7 +113,9 @@
 		| CLASS tSTRING dlg_attributes
 		  {$$=dialog_class($2,$3);}
 		| MENU tSTRING dlg_attributes
-		  {$$=dialog_menu($2,$3);}
+		  {$$=dialog_menu_str($2,$3);}
+		| MENU NUMBER dlg_attributes
+		  {$$=dialog_menu_id($2,$3);}
 
 /* the controls are collected into a gen_res, and finally the dialog header 
    is put at the beginning */
diff --git a/rc/winerc.c b/rc/winerc.c
index 9dbcf90..66f7efe 100644
--- a/rc/winerc.c
+++ b/rc/winerc.c
@@ -354,7 +354,16 @@
 	return insert_string(attr,cap,dialog_get_class(attr),0);
 }
 
-gen_res* dialog_menu(char* cap, gen_res*attr)
+gen_res* dialog_menu_id(short nr, gen_res*attr)
+{
+	char c_nr[2];
+	int offs=dialog_get_menu(attr);
+	attr->res[offs] = 0xff;
+	if (win32) attr->res[offs+1] = 0xff;
+	put_WORD(c_nr,nr);
+	return insert_bytes(attr,c_nr,offs+(win32?2:1),2);
+}
+gen_res* dialog_menu_str(char* cap, gen_res*attr)
 {
 	return insert_string(attr,cap,dialog_get_menu(attr),0);
 }
@@ -415,10 +424,12 @@
 gen_res* create_generic_control(char* label,int id,char* class,
 	rc_style*style,int x,int y,int cx,int cy)
 {	gen_res* ret=new_res();
+	int s=WS_VISIBLE|WS_CHILD; /*default styles for any control*/
+	if(style)s=(s|style->or)&style->and;
 	if(win32)
 	{
 		WORD cl;
-		put_DWORD(ret->res+0,style->or);
+		put_DWORD(ret->res+0,s);
 		/* FIXME */
 		/* put_DWORD(ret->res+4,exstyle->or); */
 		put_WORD(ret->res+8,x);
@@ -430,12 +441,12 @@
 		ret=insert_string(ret,label,20,0);
 		/* is it a predefined class? */
 		cl=0;
-		if(!strcmp(class,"BUTTON"))cl=CT_BUTTON;
-		if(!strcmp(class,"EDIT"))cl=CT_EDIT;
-		if(!strcmp(class,"STATIC"))cl=CT_STATIC;
-		if(!strcmp(class,"LISTBOX"))cl=CT_LISTBOX;
-		if(!strcmp(class,"SCROLLBAR"))cl=CT_SCROLLBAR;
-		if(!strcmp(class,"COMBOBOX"))cl=CT_COMBOBOX;
+		if(!strcasecmp(class,"BUTTON"))cl=CT_BUTTON;
+		if(!strcasecmp(class,"EDIT"))cl=CT_EDIT;
+		if(!strcasecmp(class,"STATIC"))cl=CT_STATIC;
+		if(!strcasecmp(class,"LISTBOX"))cl=CT_LISTBOX;
+		if(!strcasecmp(class,"SCROLLBAR"))cl=CT_SCROLLBAR;
+		if(!strcasecmp(class,"COMBOBOX"))cl=CT_COMBOBOX;
 		if(cl) {
 			char ffff[2]={0xff, 0xff};
 			ret=insert_bytes(ret,ffff,18,2);
@@ -451,17 +462,17 @@
 		put_WORD(ret->res+4,cx);
 		put_WORD(ret->res+6,cy);
 		put_WORD(ret->res+8,id);
-		put_DWORD(ret->res+10,style->or);
+		put_DWORD(ret->res+10,s);
 		ret->size=17;
 		ret=insert_string(ret,label,15,0);
 		/* is it a predefined class? */
 		cl=0;
-		if(!strcmp(class,"BUTTON"))cl=CT_BUTTON;
-		if(!strcmp(class,"EDIT"))cl=CT_EDIT;
-		if(!strcmp(class,"STATIC"))cl=CT_STATIC;
-		if(!strcmp(class,"LISTBOX"))cl=CT_LISTBOX;
-		if(!strcmp(class,"SCROLLBAR"))cl=CT_SCROLLBAR;
-		if(!strcmp(class,"COMBOBOX"))cl=CT_COMBOBOX;
+		if(!strcasecmp(class,"BUTTON"))cl=CT_BUTTON;
+		if(!strcasecmp(class,"EDIT"))cl=CT_EDIT;
+		if(!strcasecmp(class,"STATIC"))cl=CT_STATIC;
+		if(!strcasecmp(class,"LISTBOX"))cl=CT_LISTBOX;
+		if(!strcasecmp(class,"SCROLLBAR"))cl=CT_SCROLLBAR;
+		if(!strcasecmp(class,"COMBOBOX"))cl=CT_COMBOBOX;
 		if(cl)ret->res[14]=cl;
 		else ret=insert_string(ret,class,14,0);
 	}
@@ -583,7 +594,11 @@
 	gen_res *res;
 	struct stat st;
 	int f=open(name,O_RDONLY);
-	if(!f)perror(name);
+	if(f<0)
+	{
+	  perror(name);
+	  exit(1);
+	}
 	fstat(f,&st);
 	res=new_res();
 	while(res->space<st.st_size)res=grow(res);
@@ -656,7 +671,9 @@
   while(*elm && (*elm)->group<group) elm=&(*elm)->next;
   if(!*elm || (*elm)->group!=group)
   {
+    int i;
     str_tbl_elm* new=xmalloc(sizeof(str_tbl_elm));
+    for(i=0; i<16; i++) new->strings[i] = NULL;
     new->group=group;
     new->next=*elm;
     *elm=new;
diff --git a/tools/build-spec.txt b/tools/build-spec.txt
index cb78f01..4c980a5 100644
--- a/tools/build-spec.txt
+++ b/tools/build-spec.txt
@@ -62,12 +62,13 @@
 - "word"
 - "long"
 - "ptr" (linear pointer)
+- "str" (linear pointer to a string)
 - "s_byte" (signed byte)
 - "s_word" (signed word)
 - "s_long" (signed long)
 - "segptr" (segmented pointer).
 
-Only "ptr" and "long" are valid for Win32 functions.
+Only "ptr", "str" and "long" are valid for Win32 functions.
 
 "HANDLERNAME" is the name of the actual Wine function that will
 process the request in 32-bit mode.
diff --git a/tools/build.c b/tools/build.c
index 53e6780..c38785f 100644
--- a/tools/build.c
+++ b/tools/build.c
@@ -370,6 +370,8 @@
             odp->u.func.arg_types[i] = 'l';
         else if (!strcmp(token, "ptr"))
             odp->u.func.arg_types[i] = 'p';
+	else if (!strcmp(token, "str"))
+	    odp->u.func.arg_types[i] = 't';
         else
         {
             fprintf(stderr, "%d: Unknown variable type '%s'\n", Line, token);
@@ -1442,6 +1444,7 @@
             break;
 
         case 'p':  /* ptr */
+        case 't':  /* string */
             /* Get the selector */
             fprintf( outfile, "\tmovw %d(%%ebp),%%ax\n", pos16 + 2 );
             /* Get the selector base */
@@ -1574,7 +1577,7 @@
  * Build a 16-bit-to-Wine callback function. The syntax of the function
  * profile is: type_xxxxx, where 'type' is one of 'regs', 'word' or
  * 'long' and each 'x' is an argument ('w'=word, 's'=signed word,
- * 'l'=long, 'p'=pointer).
+ * 'l'=long, 'p'=pointer, 't'=string).
  * For register functions, the arguments are ignored, but they are still
  * removed from the stack upon return.
  *
@@ -1736,6 +1739,7 @@
                 argsize += 2;
                 break;
             case 'p':
+            case 't':
             case 'l':
                 argsize += 4;
                 break;
diff --git a/win32/newfns.c b/win32/newfns.c
index 1bc9a98..b53a503 100644
--- a/win32/newfns.c
+++ b/win32/newfns.c
@@ -26,10 +26,10 @@
 
 /****************************************************************************
  *		DisableThreadLibraryCalls (KERNEL32.74)
+ * Don't call DllEntryPoint for DLL_THREAD_{ATTACH,DETACH} if set.
  */
 BOOL32
 DisableThreadLibraryCalls(HMODULE32 hModule) {
-	/* FIXME: stub for now */
     fprintf(stdnimp, "DisableThreadLibraryCalls Stub called!\n");
     return TRUE;
 }
diff --git a/windows/dce.c b/windows/dce.c
index d259fe0..92622b1 100644
--- a/windows/dce.c
+++ b/windows/dce.c
@@ -461,27 +461,25 @@
     }
 
     if( flags & DCX_NOCLIPCHILDREN )
-      {
+    {
         flags |= DCX_CACHE;
         flags &= ~(DCX_PARENTCLIP | DCX_CLIPCHILDREN);
-      }
-
-    if (hwnd == GetDesktopWindow32() || !(wndPtr->dwStyle & WS_CHILD))
-        flags &= ~DCX_PARENTCLIP;
+    }
 
     if (flags & DCX_WINDOW) flags = (flags & ~DCX_CLIPCHILDREN) | DCX_CACHE;
 
-    if( flags & DCX_PARENTCLIP )
-      {
+    if (!(wndPtr->dwStyle & WS_CHILD) || !wndPtr->parent ) flags &= ~DCX_PARENTCLIP;
+    else if( flags & DCX_PARENTCLIP )
+    {
         flags |= DCX_CACHE;
         if( !(flags & (DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN)) )
           if( (wndPtr->dwStyle & WS_VISIBLE) && (wndPtr->parent->dwStyle & WS_VISIBLE) )
-            {
+          {
               flags &= ~DCX_CLIPCHILDREN;
               if( wndPtr->parent->dwStyle & WS_CLIPSIBLINGS )
-                flags |= DCX_CLIPSIBLINGS;
-            }
-      }
+                  flags |= DCX_CLIPSIBLINGS;
+          }
+    }
 
     if (flags & DCX_CACHE)
     {
@@ -494,17 +492,17 @@
     {
         dce = (wndPtr->class->style & CS_OWNDC)?wndPtr->dce:wndPtr->class->dce;
 	if( dce->hwndCurrent == hwnd )
-	  {
+	{
 	    dprintf_dc(stddeb,"\tskipping hVisRgn update\n");
 	    need_update = FALSE;
-	  }
+	}
 
 	if( hrgnClip && dce->hClipRgn && !(dce->DCXflags & DCX_KEEPCLIPRGN))
-	  {
+	{
 	    fprintf(stdnimp,"GetDCEx: hClipRgn collision!\n");
             DeleteObject32( dce->hClipRgn ); 
 	    need_update = TRUE;
-	  }
+	}
     }
 
     dcx_flags = flags & ( DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN | DCX_CACHE | DCX_WINDOW | DCX_WINDOWPAINT);
@@ -561,7 +559,7 @@
     }
     else hrgnVisible = CreateRectRgn32( 0, 0, 0, 0 );
 
-    if ((flags & DCX_INTERSECTRGN) || (flags & DCX_EXCLUDERGN))
+    if( flags & (DCX_EXCLUDERGN | DCX_INTERSECTRGN) )
     {
 	dce->DCXflags |= flags & (DCX_KEEPCLIPRGN | DCX_INTERSECTRGN | DCX_EXCLUDERGN);
 	dce->hClipRgn = hrgnClip;
diff --git a/windows/event.c b/windows/event.c
index c03c98c..42c8f34 100644
--- a/windows/event.c
+++ b/windows/event.c
@@ -451,7 +451,7 @@
 
     parent = __get_common_ancestor( pWndZ->window, pWnd->window,
                                       &children, &total );
-    if( parent )
+    if( parent && children )
     {
         w = __get_top_decoration( pWndCheck->window, parent );
         if( w != children[total - 1] )
diff --git a/windows/keyboard.c b/windows/keyboard.c
index d1a6b11..c1965ca 100644
--- a/windows/keyboard.c
+++ b/windows/keyboard.c
@@ -105,6 +105,44 @@
     VK_MENU, VK_MENU, VK_MENU, VK_MENU                         /* FFE7 */
 };
 
+/*
+ * Table for vkey to scancode translation - 5/29/97 chrisf@america.com 
+ */
+static BYTE vkey2scode[512] = {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x0e,0x0f,0x00,0x00,0x00,0x1c,0x00,0x00,
+  0x2a,0x1d,0x38,0x00,0x3a,0x00,0x00,0x00, 0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,
+  0x39,0x49,0x51,0x4f,0x47,0x4b,0x48,0x4d, 0x50,0x00,0x00,0x00,0x00,0x52,0x53,0x00,
+  0x0b,0x02,0x03,0x04,0x05,0x06,0x07,0x08, 0x09,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x1e,0x30,0x2e,0x20,0x12,0x21,0x22, 0x23,0x17,0x24,0x25,0x26,0x32,0x31,0x18,
+  0x19,0x10,0x13,0x1f,0x14,0x16,0x2f,0x11, 0x2d,0x15,0x2c,0x00,0x00,0x00,0x00,0x00,
+  0x0b,0x02,0x03,0x04,0x05,0x06,0x07,0x08, 0x09,0x0a,0x37,0x4e,0x00,0x4a,0x34,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x46,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x29,0x0c,0x0d,0x1a,0x1b,0x2b,
+  0x27,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x28,0x33,0x34,0x35,0x4c,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+/* 256 */
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x1c,0x00,0x00,
+  0x00,0x1d,0x38,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x49,0x51,0x4f,0x47,0x4b,0x48,0x4d, 0x50,0x00,0x00,0x00,0x00,0x52,0x53,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x35,
+  0x3b,0x3c,0x3d,0x3e,0x3f,0x40,0x41,0x42, 0x43,0x44,0x57,0x58,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+};
 
 static WORD EVENT_event_to_vkey( XKeyEvent *e)
 {
@@ -367,7 +405,7 @@
    if (vkey)
    {
     keylp.lp1.count = 1;
-    keylp.lp1.code = LOBYTE(event->keycode) - 8;
+    keylp.lp1.code = vkey2scode[vkey]; /* 5/29/97 chrisf@america.com */
     keylp.lp1.extended = (vkey & 0x100 ? 1 : 0);
     keylp.lp1.win_internal = 0; /* this has something to do with dialogs, 
 				* don't remember where I read it - AK */
diff --git a/windows/message.c b/windows/message.c
index 5b70ee2..0c22b8a 100644
--- a/windows/message.c
+++ b/windows/message.c
@@ -1012,8 +1012,9 @@
 
     if (hwnd == HWND_BROADCAST)
     {
+        if (!(list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL )))
+            return TRUE;
         dprintf_msg(stddeb,"SendMessage // HWND_BROADCAST !\n");
-        list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL );
         for (ppWnd = list; *ppWnd; ppWnd++)
         {
             wndPtr = *ppWnd;
@@ -1023,9 +1024,9 @@
                 dprintf_msg(stddeb,"BROADCAST Message to hWnd=%04x m=%04X w=%04lX l=%08lX !\n",
                             wndPtr->hwndSelf, msg, (DWORD)wParam, lParam);
                 SendMessage16( wndPtr->hwndSelf, msg, wParam, lParam );
-	    }
+            }
         }
-	HeapFree( SystemHeap, 0, list );
+        HeapFree( SystemHeap, 0, list );
         dprintf_msg(stddeb,"SendMessage // End of HWND_BROADCAST !\n");
         return TRUE;
     }
@@ -1099,7 +1100,8 @@
 
     if (hwnd == HWND_BROADCAST)
     {
-        list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL );
+        if (!(list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL )))
+            return TRUE;
         for (ppWnd = list; *ppWnd; ppWnd++)
         {
             wndPtr = *ppWnd;
@@ -1148,7 +1150,8 @@
 
     if (hwnd == HWND_BROADCAST)
     {
-        list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL );
+        if (!(list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL )))
+            return TRUE;
         for (ppWnd = list; *ppWnd; ppWnd++)
         {
             wndPtr = *ppWnd;
diff --git a/wine.ini b/wine.ini
index 1eff793..af8f3ca 100644
--- a/wine.ini
+++ b/wine.ini
@@ -48,11 +48,11 @@
 AllocSystemColors=100
 
 [fonts]
-; see documentation/fonts
-;Alias0 = System, --international-
-;Alias1 = MS Sans Serif, -adobe-helvetica-
-;Alias2 = Arial, -adobe-helvetica-, subst
-;Alias3 = Times New Roman, -adobe-times-, subst
+;Read documentation/fonts before changing this
+Alias0 = MS Sans Serif, -adobe-helvetica-
+;Alias1 = Arial, -adobe-helvetica-, subst
+;Alias2 = Times New Roman, -adobe-times-, subst
+Default = -adobe-times-
 
 [serialports]
 Com1=/dev/cua0