Release 960611

Tue Jun 11 15:20:43 1996  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [debugger/break.c] [loader/signal.c]
	Fixed breakpoints in 32-bit code.

	* [include/windows.h]
	Added many more Win32 versions of standard structures.

	* [include/winreg.h] [misc/registry.c]
	Moved private types into registry.c.

	* [memory/string.c] (New file)
	Moved most string functions from misc/lstr.c; added Win32 version
	of all functions.

	* [misc/wsprintf.c]
	Implemented Win32 wsprintf functions.

	* [objects/bitmap.c]
	Implemented Win32 bitmap functions.

	* [windows/dialog.c]
	Don't set dialog procedure before the controls are created. This
	avoids a crash in Winhelp.

Tue Jun 11 14:10:06 1996 Martin von Loewis <loewis@informatik.hu-berlin.de>

	* [controls/menu.c] [if1632/user.spec] [windows/message.c]
	Replace PeekMessage with PeekMessage16.

	* [if1632/kernel32.spec][misc/main.c]
	GetVersion32,GetVersionEx32A,GetVersionEx32W: new functions.
	MAIN_ParseVersion: new function, new command line option -winver.
	GetVersion: modified to take command line argument into account.

	* [if1632/kernel32.spec] [win32/process.c]
	FreeLibrary32: new function.
	TlsAlloc: initialize Tls to zero.
	InterlockedIncrement,InterlockedDecrement,InterlockedExchange: new
	functions.

	* [if1632/kernel32.spec]
	SetErrorMode,GetActiveWindow: new relays to existing functions.

	* [if1632/kernel32.spec][win32/user32.c]
	PeekMessage32A,PeekMessage32W: new functions.

	* [include/struct32.h][include/windows.h]
	Moved MSG32 to windows.h.
	Renamed MSG to MSG16.
	Modified prototypes to use MSG16

	* [include/winbase.h]
	OSVERSIONINFO32A,OSVERSIONINFO32W: new structures.

Sun Jun  9 20:53:30 1996  Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>

	* [if1632/Makefile.in] [loader/builtin.c]
	version.dll,lz32.dll added.

	* [include/lzexpand.h] [if1632/lz32.spec] [if1632/lzexpand.spec]
	  [misc/lzexpand.c]
	lz32.dll added.
	Modified to new function naming standard.

	* [include/ver.h] [if1632/ver.spec] [if1632/version.spec] [misc/ver.c]
	version.dll added (win32 version of ver.dll).
	Modified to new function naming standard.
	Use registry to look up a LOCALE langids too.
	(VerInstallFile,VerFindFile still stubs)

Fri Jun  7 20:40:20 1996  Albrecht Kleine  <kleine@ak.sax.de>

	* [files/file.c]
	Added a warning if GetTempFileName() gets a bad drive parameter.

	* [misc/commdlg.c]
	Changed file listbox color to gray in SaveFile dialog 
	(just like Windows does this).
diff --git a/ANNOUNCE b/ANNOUNCE
index 820759c..b4f14d3 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,13 +1,12 @@
-This is release 960606 of Wine, the MS Windows emulator.  This is still a
+This is release 960611 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-960606: (see ChangeLog for details)
-	- More Win32 code.
-	- Window repainting fixes.
+WHAT'S NEW with Wine-960611: (see ChangeLog for details)
+	- (surprise) More Win32 code.
 	- Lots of bug fixes.
 
 See the README file in the distribution for installation instructions.
@@ -16,10 +15,10 @@
 the release is available at the ftp sites.  The sources will be available
 from the following locations:
 
-    sunsite.unc.edu:/pub/Linux/ALPHA/wine/development/Wine-960606.tar.gz
-    tsx-11.mit.edu:/pub/linux/ALPHA/Wine/development/Wine-960606.tar.gz
-    ftp.infomagic.com:/pub/mirrors/linux/wine/development/Wine-960606.tar.gz
-    aris.com:/pub/linux/ALPHA/Wine/development/Wine-960606.tar.gz
+    sunsite.unc.edu:/pub/Linux/ALPHA/wine/development/Wine-960611.tar.gz
+    tsx-11.mit.edu:/pub/linux/ALPHA/Wine/development/Wine-960611.tar.gz
+    ftp.infomagic.com:/pub/mirrors/linux/wine/development/Wine-960611.tar.gz
+    aris.com:/pub/linux/ALPHA/Wine/development/Wine-960611.tar.gz
 
 It should also be available from any site that mirrors tsx-11 or sunsite.
 
diff --git a/ChangeLog b/ChangeLog
index 34238c6..0d6d6c1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,85 @@
 ----------------------------------------------------------------------
+Tue Jun 11 15:20:43 1996  Alexandre Julliard  <julliard@lrc.epfl.ch>
+
+	* [debugger/break.c] [loader/signal.c]
+	Fixed breakpoints in 32-bit code.
+
+	* [include/windows.h]
+	Added many more Win32 versions of standard structures.
+
+	* [include/winreg.h] [misc/registry.c]
+	Moved private types into registry.c.
+
+	* [memory/string.c] (New file)
+	Moved most string functions from misc/lstr.c; added Win32 version
+	of all functions.
+
+	* [misc/wsprintf.c]
+	Implemented Win32 wsprintf functions.
+
+	* [objects/bitmap.c]
+	Implemented Win32 bitmap functions.
+
+	* [windows/dialog.c]
+	Don't set dialog procedure before the controls are created. This
+	avoids a crash in Winhelp.
+
+Tue Jun 11 14:10:06 1996 Martin von Loewis <loewis@informatik.hu-berlin.de>
+
+	* [controls/menu.c] [if1632/user.spec] [windows/message.c]
+	Replace PeekMessage with PeekMessage16.
+
+	* [if1632/kernel32.spec][misc/main.c]
+	GetVersion32,GetVersionEx32A,GetVersionEx32W: new functions.
+	MAIN_ParseVersion: new function, new command line option -winver.
+	GetVersion: modified to take command line argument into account.
+
+	* [if1632/kernel32.spec] [win32/process.c]
+	FreeLibrary32: new function.
+	TlsAlloc: initialize Tls to zero.
+	InterlockedIncrement,InterlockedDecrement,InterlockedExchange: new
+	functions.
+
+	* [if1632/kernel32.spec]
+	SetErrorMode,GetActiveWindow: new relays to existing functions.
+
+	* [if1632/kernel32.spec][win32/user32.c]
+	PeekMessage32A,PeekMessage32W: new functions.
+
+	* [include/struct32.h][include/windows.h]
+	Moved MSG32 to windows.h.
+	Renamed MSG to MSG16.
+	Modified prototypes to use MSG16
+
+	* [include/winbase.h]
+	OSVERSIONINFO32A,OSVERSIONINFO32W: new structures.
+
+Sun Jun  9 20:53:30 1996  Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>
+
+	* [if1632/Makefile.in] [loader/builtin.c]
+	version.dll,lz32.dll added.
+
+	* [include/lzexpand.h] [if1632/lz32.spec] [if1632/lzexpand.spec]
+	  [misc/lzexpand.c]
+	lz32.dll added.
+	Modified to new function naming standard.
+
+	* [include/ver.h] [if1632/ver.spec] [if1632/version.spec] [misc/ver.c]
+	version.dll added (win32 version of ver.dll).
+	Modified to new function naming standard.
+	Use registry to look up a LOCALE langids too.
+	(VerInstallFile,VerFindFile still stubs)
+
+Fri Jun  7 20:40:20 1996  Albrecht Kleine  <kleine@ak.sax.de>
+
+	* [files/file.c]
+	Added a warning if GetTempFileName() gets a bad drive parameter.
+
+	* [misc/commdlg.c]
+	Changed file listbox color to gray in SaveFile dialog 
+	(just like Windows does this).
+
+----------------------------------------------------------------------
 Wed Jun  5 20:13:54 1996  Alexandre Julliard  <julliard@lrc.epfl.ch>
 
 	* [controls/button.c] [controls/listbox.c]
diff --git a/controls/button.c b/controls/button.c
index a7870ed..3181a56 100644
--- a/controls/button.c
+++ b/controls/button.c
@@ -20,7 +20,7 @@
 
 #define MAX_BTN_TYPE  12
 
-static WORD maxCheckState[MAX_BTN_TYPE] =
+static const WORD maxCheckState[MAX_BTN_TYPE] =
 {
     BUTTON_UNCHECKED,   /* BS_PUSHBUTTON */
     BUTTON_UNCHECKED,   /* BS_DEFPUSHBUTTON */
@@ -38,7 +38,7 @@
 
 typedef void (*pfPaint)( WND *wndPtr, HDC hdc, WORD action );
 
-static pfPaint btnPaintFunc[MAX_BTN_TYPE] =
+static const pfPaint btnPaintFunc[MAX_BTN_TYPE] =
 {
     PB_Paint,    /* BS_PUSHBUTTON */
     PB_Paint,    /* BS_DEFPUSHBUTTON */
@@ -97,9 +97,9 @@
     case WM_CREATE:
         if (!hbitmapCheckBoxes)
         {
-            BITMAP bmp;
+            BITMAP16 bmp;
             hbitmapCheckBoxes = LoadBitmap(0, MAKEINTRESOURCE(OBM_CHECKBOXES));
-            GetObject( hbitmapCheckBoxes, sizeof(bmp), (LPSTR)&bmp );
+            GetObject16( hbitmapCheckBoxes, sizeof(bmp), &bmp );
             checkBoxWidth  = bmp.bmWidth / 4;
             checkBoxHeight = bmp.bmHeight / 3;
         }
@@ -255,7 +255,7 @@
     HPEN16 hOldPen;
     HBRUSH hOldBrush;
     DWORD dwTextSize;
-    TEXTMETRIC tm;
+    TEXTMETRIC16 tm;
     BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
 
     GetClientRect16(wndPtr->hwndSelf, &rc);
@@ -296,8 +296,8 @@
     /* draw button label, if any: */
     if (wndPtr->text && wndPtr->text[0])
     {
-     LOGBRUSH lb;
-     GetObject(sysColorObjects.hbrushBtnFace,sizeof(LOGBRUSH),(LPSTR)&lb);
+     LOGBRUSH16 lb;
+     GetObject16( sysColorObjects.hbrushBtnFace, sizeof(lb), &lb );
      if (wndPtr->dwStyle & WS_DISABLED &&
          GetSysColor(COLOR_GRAYTEXT)==lb.lbColor)
          /* don't write gray text on gray bkg */
@@ -372,7 +372,7 @@
     RECT16 rc;
     HBRUSH hBrush;
     int textlen, delta, x, y;
-    TEXTMETRIC tm;
+    TEXTMETRIC16 tm;
     SIZE16 size;
     BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra;
 
diff --git a/controls/combo.c b/controls/combo.c
index 44540dd..10ed406 100644
--- a/controls/combo.c
+++ b/controls/combo.c
@@ -48,11 +48,11 @@
 
 static int COMBO_Init()
 {
-  BITMAP bm;
+  BITMAP16 bm;
   
   dprintf_combo(stddeb, "COMBO_Init\n");
   hComboBit = LoadBitmap(0, MAKEINTRESOURCE(OBM_COMBO));
-  GetObject(hComboBit, sizeof(BITMAP), (LPSTR)&bm);
+  GetObject16( hComboBit, sizeof(bm), &bm );
   CBitHeight = bm.bmHeight;
   CBitWidth = bm.bmWidth;
   return 0;
@@ -1208,7 +1208,7 @@
         char temp[512] = "A:\\";
         int drive = DRIVE_GetCurrentDrive();
         temp[0] += drive;
-        lstrcpyn( temp + 3, DRIVE_GetDosCwd(drive), sizeof(temp)-3 );
+        lstrcpyn32A( temp + 3, DRIVE_GetDosCwd(drive), sizeof(temp)-3 );
         AnsiLower( temp );
         SetDlgItemText32A( hDlg, idStatic, temp );
     } 
diff --git a/controls/desktop.c b/controls/desktop.c
index e70d85a..a71a6f8 100644
--- a/controls/desktop.c
+++ b/controls/desktop.c
@@ -198,8 +198,8 @@
     infoPtr->fTileWallPaper = GetProfileInt( "desktop", "TileWallPaper", 0 );
     if (hbitmap)
     {
-	BITMAP bmp;
-	GetObject( hbitmap, sizeof(bmp), (LPSTR)&bmp );
+	BITMAP16 bmp;
+	GetObject16( hbitmap, sizeof(bmp), &bmp );
 	infoPtr->bitmapSize.cx = (bmp.bmWidth != 0) ? bmp.bmWidth : 1;
 	infoPtr->bitmapSize.cy = (bmp.bmHeight != 0) ? bmp.bmHeight : 1;
     }
diff --git a/controls/edit.c b/controls/edit.c
index 4018290..7db7bd4 100644
--- a/controls/edit.c
+++ b/controls/edit.c
@@ -2743,7 +2743,7 @@
  */
 static LRESULT EDIT_WM_SetFont(WND *wndPtr, WPARAM wParam, LPARAM lParam)
 {
-	TEXTMETRIC tm;
+	TEXTMETRIC16 tm;
 	EDITSTATE *es = EDITSTATEPTR(wndPtr);
 	LPARAM sel = EDIT_EM_GetSel(wndPtr, 0, 0L);
 	HDC hdc;
diff --git a/controls/listbox.c b/controls/listbox.c
index 27a173a..da7d1f0 100644
--- a/controls/listbox.c
+++ b/controls/listbox.c
@@ -106,7 +106,7 @@
   /* create dummy hdc to set text height */
   if ((hdc = GetDC(0)))
   {
-      TEXTMETRIC tm;
+      TEXTMETRIC16 tm;
       GetTextMetrics( hdc, &tm );
       lphl->StdItemHeight = tm.tmHeight;
       dprintf_listbox(stddeb,"CreateListBoxStruct:  font height %d\n",
@@ -305,8 +305,8 @@
 
 void ListBoxAskMeasure(LPHEADLIST lphl, LPLISTSTRUCT lpls)  
 {
-  HANDLE hTemp = USER_HEAP_ALLOC( sizeof(MEASUREITEMSTRUCT) );
-  MEASUREITEMSTRUCT *lpmeasure = (MEASUREITEMSTRUCT *) USER_HEAP_LIN_ADDR(hTemp);
+  HANDLE hTemp = USER_HEAP_ALLOC( sizeof(MEASUREITEMSTRUCT16) );
+  MEASUREITEMSTRUCT16 *lpmeasure = (MEASUREITEMSTRUCT16 *) USER_HEAP_LIN_ADDR(hTemp);
 
   if (lpmeasure == NULL) {
     fprintf(stdnimp,"ListBoxAskMeasure() out of memory !\n");
@@ -1274,7 +1274,7 @@
   /* or are we guaranteed to get a LBSetFont before the first insert/add? */
   if ((hdc = GetDC(0)))
   {
-      TEXTMETRIC tm;
+      TEXTMETRIC16 tm;
       GetTextMetrics( hdc, &tm );
       lphl->StdItemHeight = tm.tmHeight;
       dprintf_listbox(stddeb,"LBSetFont:  new font %d with height %d\n",
@@ -2107,7 +2107,7 @@
                 p = filespec;
                 if ((p2 = strrchr( p, '\\' ))) p = p2 + 1;
                 if ((p2 = strrchr( p, '/' ))) p = p2 + 1;
-                lstrcpyn( mask, p, sizeof(mask) );
+                lstrcpyn32A( mask, p, sizeof(mask) );
                 if (p != filespec)
                 {
                     p[-1] = '\0';
@@ -2151,7 +2151,7 @@
         int drive = DRIVE_GetCurrentDrive();
         strcpy( temp, "A:\\" );
         temp[0] += drive;
-        lstrcpyn( temp + 3, DRIVE_GetDosCwd(drive), sizeof(temp)-3 );
+        lstrcpyn32A( temp + 3, DRIVE_GetDosCwd(drive), sizeof(temp)-3 );
         AnsiLower( temp );
         /* Can't use PostMessage() here, because the string is on the stack */
         SetDlgItemText32A( hDlg, idStatic, temp );
diff --git a/controls/menu.c b/controls/menu.c
index 093627c..bf6a69d 100644
--- a/controls/menu.c
+++ b/controls/menu.c
@@ -132,18 +132,18 @@
  */
 BOOL MENU_Init()
 {
-    BITMAP bm;
+    BITMAP16 bm;
 
       /* Load bitmaps */
 
     if (!(hStdCheck = LoadBitmap( 0, MAKEINTRESOURCE(OBM_CHECK) )))
 	return FALSE;
-    GetObject( hStdCheck, sizeof(BITMAP), (LPSTR)&bm );
+    GetObject16( hStdCheck, sizeof(bm), &bm );
     check_bitmap_width = bm.bmWidth;
     check_bitmap_height = bm.bmHeight;
     if (!(hStdMnArrow = LoadBitmap( 0, MAKEINTRESOURCE(OBM_MNARROW) )))
 	return FALSE;
-    GetObject( hStdMnArrow, sizeof(BITMAP), (LPSTR)&bm );
+    GetObject16( hStdMnArrow, sizeof(bm), &bm );
     arrow_bitmap_width = bm.bmWidth;
     arrow_bitmap_height = bm.bmHeight;
 
@@ -331,8 +331,8 @@
 
     if (lpitem->item_flags & MF_OWNERDRAW)
     {
-        MEASUREITEMSTRUCT *mis;
-        if (!(mis = SEGPTR_NEW(MEASUREITEMSTRUCT))) return;
+        MEASUREITEMSTRUCT16 *mis;
+        if (!(mis = SEGPTR_NEW(MEASUREITEMSTRUCT16))) return;
         mis->CtlType    = ODT_MENU;
         mis->itemID     = lpitem->item_id;
         mis->itemData   = (DWORD)lpitem->text;
@@ -362,9 +362,8 @@
 
     if (lpitem->item_flags & MF_BITMAP)
     {
-	BITMAP bm;
-        if (GetObject( (HBITMAP16)(UINT32)lpitem->text,
-                       sizeof(BITMAP), (LPSTR)&bm ))
+	BITMAP16 bm;
+        if (GetObject16( (HBITMAP16)(UINT32)lpitem->text, sizeof(bm), &bm ))
         {
             lpitem->rect.right  += bm.bmWidth;
             lpitem->rect.bottom += bm.bmHeight;
@@ -1119,7 +1118,7 @@
                      flags );
         str = res;
         if (!unicode) res += strlen(str) + 1;
-        else res += (STRING32_lstrlenW((LPCWSTR)str) + 1) * sizeof(WCHAR);
+        else res += (lstrlen32W((LPCWSTR)str) + 1) * sizeof(WCHAR);
         if (flags & MF_POPUP)
         {
             HMENU hSubMenu = CreatePopupMenu();
@@ -1540,7 +1539,7 @@
 static BOOL MENU_TrackMenu( HMENU hmenu, UINT wFlags, int x, int y,
 			    HWND hwnd, const RECT16 *lprect )
 {
-    MSG *msg;
+    MSG16 *msg;
     HLOCAL16 hMsg;
     POPUPMENU *menu;
     HMENU hmenuCurrent = hmenu;
@@ -1555,8 +1554,8 @@
 	MENU_ButtonDown( hwnd, hmenu, &hmenuCurrent, pt );
     }
     SetCapture( hwnd );
-    hMsg = USER_HEAP_ALLOC( sizeof(MSG) );
-    msg = (MSG *)USER_HEAP_LIN_ADDR( hMsg );
+    hMsg = USER_HEAP_ALLOC( sizeof(MSG16) );
+    msg = (MSG16 *)USER_HEAP_LIN_ADDR( hMsg );
     while (!fClosed)
     {
 	if (!MSG_InternalGetMessage( (SEGPTR)USER_HEAP_SEG_ADDR(hMsg), 0,
@@ -1695,7 +1694,7 @@
 	if (!fClosed) fRemove = TRUE;
 
         if (fRemove)  /* Remove the message from the queue */
-	    PeekMessage( msg, 0, msg->message, msg->message, PM_REMOVE );
+	    PeekMessage16( msg, 0, msg->message, msg->message, PM_REMOVE );
     }
     USER_HEAP_FREE( hMsg );
     ReleaseCapture();
@@ -2019,7 +2018,7 @@
     str[0] = '\0';
     if (!(item = MENU_FindItem( &hMenu, &wItemID, wFlags ))) return 0;
     if (!IS_STRING_ITEM(item->item_flags)) return 0;
-    lstrcpyn( str, item->text, nMaxSiz );
+    lstrcpyn32A( str, item->text, nMaxSiz );
     dprintf_menu( stddeb, "GetMenuString: returning '%s'\n", str );
     return strlen(str);
 }
diff --git a/debugger/break.c b/debugger/break.c
index edbddb8..1726c16 100644
--- a/debugger/break.c
+++ b/debugger/break.c
@@ -288,7 +288,7 @@
                 0 : CS_reg(DEBUG_context);
     addr.off = EIP_reg(DEBUG_context);
         
-    bpnum  = DEBUG_FindBreakpoint( &addr );
+    bpnum = DEBUG_FindBreakpoint( &addr );
     breakpoints[0].enabled = 0;  /* disable the step-over breakpoint */
 
     if ((bpnum != 0) && (bpnum != -1))
@@ -299,6 +299,12 @@
         fprintf( stderr, "\n" );
         return FALSE;
     }
+
+    /* If there's no breakpoint and we are not single-stepping, then we     */
+    /* must have encountered an int3 in the Windows program; let's skip it. */
+    if ((bpnum == -1) && !(EFL_reg(DEBUG_context) & STEP_FLAG))
+        EIP_reg(DEBUG_context)++;
+
       /* no breakpoint, continue if in continuous mode */
     return (mode == EXEC_CONT);
 }
diff --git a/debugger/db_disasm.c b/debugger/db_disasm.c
index 8d38f5a..ab59a97 100644
--- a/debugger/db_disasm.c
+++ b/debugger/db_disasm.c
@@ -123,11 +123,11 @@
 #define	XA	34			/* for 'fstcw %ax' */
 
 struct inst {
-	char *	i_name;			/* name */
-	short	i_has_modrm;		/* has regmodrm byte */
-	short	i_size;			/* operand size */
-	int	i_mode;			/* addressing modes */
-	char *	i_extra;		/* pointer to extra opcode table */
+	const char *i_name;		/* name */
+	short       i_has_modrm;	/* has regmodrm byte */
+	short       i_size;		/* operand size */
+	int         i_mode;		/* addressing modes */
+	const char *i_extra;		/* pointer to extra opcode table */
 };
 
 #define	op1(x)		(x)
@@ -135,14 +135,14 @@
 #define	op3(x,y,z)	((x)|((y)<<8)|((z)<<16))
 
 struct finst {
-	char *	f_name;			/* name for memory instruction */
-	int	f_size;			/* size for memory instruction */
-	int	f_rrmode;		/* mode for rr instruction */
-	char *	f_rrname;		/* name for rr instruction
+	const char *f_name;		/* name for memory instruction */
+	int         f_size;		/* size for memory instruction */
+	int         f_rrmode;		/* mode for rr instruction */
+	const char *f_rrname;		/* name for rr instruction
 					   (or pointer to table) */
 };
 
-static char *	db_Grp6[] = {
+static const char * const db_Grp6[] = {
 	"sldt",
 	"str",
 	"lldt",
@@ -153,7 +153,7 @@
 	""
 };
 
-static char *	db_Grp7[] = {
+static const char * const db_Grp7[] = {
 	"sgdt",
 	"sidt",
 	"lgdt",
@@ -164,7 +164,7 @@
 	"invlpg"
 };
 
-static char *	db_Grp8[] = {
+static const char * const db_Grp8[] = {
 	"",
 	"",
 	"",
@@ -175,7 +175,7 @@
 	"btc"
 };
 
-static struct inst db_inst_0f0x[] = {
+static const struct inst db_inst_0f0x[] = {
 /*00*/	{ "",	   TRUE,  NONE,  op1(Ew),     (char *)db_Grp6 },
 /*01*/	{ "",	   TRUE,  NONE,  op1(Ew),     (char *)db_Grp7 },
 /*02*/	{ "lar",   TRUE,  LONG,  op2(E,R),    0 },
@@ -195,7 +195,7 @@
 /*0f*/	{ "",      FALSE, NONE,  0,	      0 },
 };
 
-static struct inst	db_inst_0f2x[] = {
+static const struct inst db_inst_0f2x[] = {
 /*20*/	{ "mov",   TRUE,  LONG,  op2(CR,E),   0 }, /* use E for reg */
 /*21*/	{ "mov",   TRUE,  LONG,  op2(DR,E),   0 }, /* since mod == 11 */
 /*22*/	{ "mov",   TRUE,  LONG,  op2(E,CR),   0 },
@@ -215,7 +215,7 @@
 /*2f*/	{ "",      FALSE, NONE,  0,	      0 },
 };
 
-static struct inst	db_inst_0f8x[] = {
+static const struct inst db_inst_0f8x[] = {
 /*80*/	{ "jo",    FALSE, NONE,  op1(Dl),     0 },
 /*81*/	{ "jno",   FALSE, NONE,  op1(Dl),     0 },
 /*82*/	{ "jb",    FALSE, NONE,  op1(Dl),     0 },
@@ -235,7 +235,7 @@
 /*8f*/	{ "jnle",  FALSE, NONE,  op1(Dl),     0 },
 };
 
-static struct inst	db_inst_0f9x[] = {
+static const struct inst db_inst_0f9x[] = {
 /*90*/	{ "seto",  TRUE,  NONE,  op1(Eb),     0 },
 /*91*/	{ "setno", TRUE,  NONE,  op1(Eb),     0 },
 /*92*/	{ "setb",  TRUE,  NONE,  op1(Eb),     0 },
@@ -255,7 +255,7 @@
 /*9f*/	{ "setnle",TRUE,  NONE,  op1(Eb),     0 },
 };
 
-static struct inst	db_inst_0fax[] = {
+static const struct inst db_inst_0fax[] = {
 /*a0*/	{ "push",  FALSE, NONE,  op1(Si),     0 },
 /*a1*/	{ "pop",   FALSE, NONE,  op1(Si),     0 },
 /*a2*/	{ "",      FALSE, NONE,  0,	      0 },
@@ -275,7 +275,7 @@
 /*a7*/	{ "imul",  TRUE,  LONG,  op2(E,R),    0 },
 };
 
-static struct inst	db_inst_0fbx[] = {
+static const struct inst db_inst_0fbx[] = {
 /*b0*/	{ "",      FALSE, NONE,  0,	      0 },
 /*b1*/	{ "",      FALSE, NONE,  0,	      0 },
 /*b2*/	{ "lss",   TRUE,  LONG,  op2(E, R),   0 },
@@ -295,7 +295,7 @@
 /*bf*/	{ "movsw", TRUE,  LONG,  op2(E, R),   0 },
 };
 
-static struct inst	db_inst_0fcx[] = {
+static const struct inst db_inst_0fcx[] = {
 /*c0*/	{ "xadd",  TRUE,  BYTE,	 op2(R, E),   0 },
 /*c1*/	{ "xadd",  TRUE,  LONG,	 op2(R, E),   0 },
 /*c2*/	{ "",	   FALSE, NONE,	 0,	      0 },
@@ -314,7 +314,7 @@
 /*cf*/	{ "bswap", FALSE, LONG,  op1(Ri),     0 },
 };
 
-static struct inst	db_inst_0fdx[] = {
+static const struct inst db_inst_0fdx[] = {
 /*c0*/	{ "cmpxchg",TRUE, BYTE,	 op2(R, E),   0 },
 /*c1*/	{ "cmpxchg",TRUE, LONG,	 op2(R, E),   0 },
 /*c2*/	{ "",	   FALSE, NONE,	 0,	      0 },
@@ -333,7 +333,7 @@
 /*cf*/	{ "",	   FALSE, NONE,	 0,	      0 },
 };
 
-static struct inst *db_inst_0f[] = {
+static const struct inst * const db_inst_0f[] = {
 	db_inst_0f0x,
 	0,
 	db_inst_0f2x,
@@ -352,43 +352,43 @@
 	0
 };
 
-static char *	db_Esc92[] = {
+static const char * const db_Esc92[] = {
 	"fnop",	"",	"",	"",	"",	"",	"",	""
 };
-static char *	db_Esc93[] = {
+static const char * const db_Esc93[] = {
 	"",	"",	"",	"",	"",	"",	"",	""
 };
-static char *	db_Esc94[] = {
+static const char * const db_Esc94[] = {
 	"fchs",	"fabs",	"",	"",	"ftst",	"fxam",	"",	""
 };
-static char *	db_Esc95[] = {
+static const char * const db_Esc95[] = {
 	"fld1",	"fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz",""
 };
-static char *	db_Esc96[] = {
+static const char * const db_Esc96[] = {
 	"f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp",
 	"fincstp"
 };
-static char *	db_Esc97[] = {
+static const char * const db_Esc97[] = {
 	"fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos"
 };
 
-static char *	db_Esca4[] = {
+static const char * const db_Esca4[] = {
 	"",	"fucompp","",	"",	"",	"",	"",	""
 };
 
-static char *	db_Escb4[] = {
+static const char * const db_Escb4[] = {
 	"",	"",	"fnclex","fninit","",	"",	"",	""
 };
 
-static char *	db_Esce3[] = {
+static const char * const db_Esce3[] = {
 	"",	"fcompp","",	"",	"",	"",	"",	""
 };
 
-static char *	db_Escf4[] = {
+static const char * const db_Escf4[] = {
 	"fnstsw","",	"",	"",	"",	"",	"",	""
 };
 
-static struct finst db_Esc8[] = {
+static const struct finst db_Esc8[] = {
 /*0*/	{ "fadd",   SNGL,  op2(STI,ST),	0 },
 /*1*/	{ "fmul",   SNGL,  op2(STI,ST),	0 },
 /*2*/	{ "fcom",   SNGL,  op2(STI,ST),	0 },
@@ -399,7 +399,7 @@
 /*7*/	{ "fdivr",  SNGL,  op2(STI,ST),	0 },
 };
 
-static struct finst db_Esc9[] = {
+static const struct finst db_Esc9[] = {
 /*0*/	{ "fld",    SNGL,  op1(STI),	0 },
 /*1*/	{ "",       NONE,  op1(STI),	"fxch" },
 /*2*/	{ "fst",    SNGL,  op1(X),	(char *)db_Esc92 },
@@ -410,7 +410,7 @@
 /*7*/	{ "fnstcw", NONE,  op1(X),	(char *)db_Esc97 },
 };
 
-static struct finst db_Esca[] = {
+static const struct finst db_Esca[] = {
 /*0*/	{ "fiadd",  WORD,  0,		0 },
 /*1*/	{ "fimul",  WORD,  0,		0 },
 /*2*/	{ "ficom",  WORD,  0,		0 },
@@ -421,7 +421,7 @@
 /*7*/	{ "fidivr", WORD,  0,		0 }
 };
 
-static struct finst db_Escb[] = {
+static const struct finst db_Escb[] = {
 /*0*/	{ "fild",   WORD,  0,		0 },
 /*1*/	{ "",       NONE,  0,		0 },
 /*2*/	{ "fist",   WORD,  0,		0 },
@@ -432,7 +432,7 @@
 /*7*/	{ "fstp",   EXTR,  0,		0 },
 };
 
-static struct finst db_Escc[] = {
+static const struct finst db_Escc[] = {
 /*0*/	{ "fadd",   DBLR,  op2(ST,STI),	0 },
 /*1*/	{ "fmul",   DBLR,  op2(ST,STI),	0 },
 /*2*/	{ "fcom",   DBLR,  op2(ST,STI),	0 },
@@ -443,7 +443,7 @@
 /*7*/	{ "fdivr",  DBLR,  op2(ST,STI),	"fdiv" },
 };
 
-static struct finst db_Escd[] = {
+static const struct finst db_Escd[] = {
 /*0*/	{ "fld",    DBLR,  op1(STI),	"ffree" },
 /*1*/	{ "",       NONE,  0,		0 },
 /*2*/	{ "fst",    DBLR,  op1(STI),	0 },
@@ -454,7 +454,7 @@
 /*7*/	{ "fnstsw", NONE,  0,		0 },
 };
 
-static struct finst db_Esce[] = {
+static const struct finst db_Esce[] = {
 /*0*/	{ "fiadd",  LONG,  op2(ST,STI),	"faddp" },
 /*1*/	{ "fimul",  LONG,  op2(ST,STI),	"fmulp" },
 /*2*/	{ "ficom",  LONG,  0,		0 },
@@ -465,7 +465,7 @@
 /*7*/	{ "fidivr", LONG,  op2(ST,STI),	"fdivp" },
 };
 
-static struct finst db_Escf[] = {
+static const struct finst db_Escf[] = {
 /*0*/	{ "fild",   LONG,  0,		0 },
 /*1*/	{ "",       LONG,  0,		0 },
 /*2*/	{ "fist",   LONG,  0,		0 },
@@ -476,12 +476,12 @@
 /*7*/	{ "fstp",   QUAD,  0,		0 },
 };
 
-static struct finst *db_Esc_inst[] = {
+static const struct finst * const db_Esc_inst[] = {
 	db_Esc8, db_Esc9, db_Esca, db_Escb,
 	db_Escc, db_Escd, db_Esce, db_Escf
 };
 
-static char *	db_Grp1[] = {
+static const char * const db_Grp1[] = {
 	"add",
 	"or",
 	"adc",
@@ -492,7 +492,7 @@
 	"cmp"
 };
 
-static char *	db_Grp2[] = {
+static const char * const db_Grp2[] = {
 	"rol",
 	"ror",
 	"rcl",
@@ -503,7 +503,7 @@
 	"sar"
 };
 
-static struct inst db_Grp3[] = {
+static const struct inst db_Grp3[] = {
 	{ "test",  TRUE, NONE, op2(I,E), 0 },
 	{ "test",  TRUE, NONE, op2(I,E), 0 },
 	{ "not",   TRUE, NONE, op1(E),   0 },
@@ -514,7 +514,7 @@
 	{ "idiv",  TRUE, NONE, op2(E,A), 0 },
 };
 
-static struct inst	db_Grp4[] = {
+static const struct inst db_Grp4[] = {
 	{ "inc",   TRUE, BYTE, op1(E),   0 },
 	{ "dec",   TRUE, BYTE, op1(E),   0 },
 	{ "",      TRUE, NONE, 0,	 0 },
@@ -525,7 +525,7 @@
 	{ "",      TRUE, NONE, 0,	 0 }
 };
 
-static struct inst	db_Grp5[] = {
+static const struct inst db_Grp5[] = {
 	{ "inc",   TRUE, LONG, op1(E),   0 },
 	{ "dec",   TRUE, LONG, op1(E),   0 },
 	{ "call",  TRUE, NONE, op1(Eind),0 },
@@ -536,7 +536,7 @@
 	{ "",      TRUE, NONE, 0,	 0 }
 };
 
-static struct inst db_inst_table[256] = {
+static const struct inst db_inst_table[256] = {
 /*00*/	{ "add",   TRUE,  BYTE,  op2(R, E),  0 },
 /*01*/	{ "add",   TRUE,  LONG,  op2(R, E),  0 },
 /*02*/	{ "add",   TRUE,  BYTE,  op2(E, R),  0 },
@@ -827,7 +827,7 @@
 /*ff*/	{ "",	   TRUE,  NONE,  0,	     (char *)db_Grp5 },
 };
 
-static struct inst	db_bad_inst =
+static const struct inst db_bad_inst =
 	{ "???",   FALSE, NONE,  0,	      0 }
 ;
 
@@ -842,12 +842,12 @@
 struct i_addr {
 	int		is_reg;	/* if reg, reg number is in 'disp' */
 	int		disp;
-	char *		base;
-	char *		index;
+	const char *	base;
+	const char *	index;
 	int		ss;
 };
 
-static char *	db_index_reg_16[8] = {
+static const char * const db_index_reg_16[8] = {
 	"%bx,%si",
 	"%bx,%di",
 	"%bp,%si",
@@ -858,20 +858,20 @@
 	"%bx"
 };
 
-static char *	db_reg[3][8] = {
+static const char * const db_reg[3][8] = {
 	{ "%al",  "%cl",  "%dl",  "%bl",  "%ah",  "%ch",  "%dh",  "%bh" },
 	{ "%ax",  "%cx",  "%dx",  "%bx",  "%sp",  "%bp",  "%si",  "%di" },
 	{ "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi" }
 };
 
-static char *	db_seg_reg[8] = {
+static const char * const db_seg_reg[8] = {
 	"%es", "%cs", "%ss", "%ds", "%fs", "%gs", "", ""
 };
 
 /*
  * lengths for size attributes
  */
-static int db_lengths[] = {
+static const int db_lengths[] = {
 	1,	/* BYTE */
 	2,	/* WORD */
 	4,	/* LONG */
@@ -1051,10 +1051,10 @@
                     int size, char *seg )
 {
 	int		regmodrm;
-	struct finst	*fp;
+	const struct finst *fp;
 	int		mod;
 	struct i_addr	address;
-	char *		name;
+	const char *	name;
 
 	get_value_inc(regmodrm, addr, 1, FALSE);
 	fp = &db_Esc_inst[inst - 0xd8][f_reg(regmodrm)];
@@ -1134,8 +1134,8 @@
 	int	size;
 	int	short_addr;
 	char *	seg;
-	struct inst *	ip;
-	char *	i_name;
+	const struct inst *ip;
+	const char *i_name;
 	int	i_size;
 	int	i_mode;
 	int	regmodrm = 0;
diff --git a/debugger/hash.c b/debugger/hash.c
index c0e6e28..56af9e5 100644
--- a/debugger/hash.c
+++ b/debugger/hash.c
@@ -25,7 +25,7 @@
 
 #define NR_NAME_HASH 128
 
-static struct name_hash * name_hash_table[NR_NAME_HASH] = {0,};
+static struct name_hash * name_hash_table[NR_NAME_HASH];
 
 static unsigned int name_hash( const char * name )
 {
diff --git a/debugger/info.c b/debugger/info.c
index b656879..36e5cab 100644
--- a/debugger/info.c
+++ b/debugger/info.c
@@ -95,7 +95,7 @@
 void DEBUG_Help(void)
 {
     int i = 0;
-    static const char * helptext[] =
+    static const char * const helptext[] =
 {
 "The commands accepted by the Wine debugger are a small subset",
 "of the commands that gdb would accept.  The commands currently",
diff --git a/files/directory.c b/files/directory.c
index 85542dd..432b8c4 100644
--- a/files/directory.c
+++ b/files/directory.c
@@ -182,7 +182,7 @@
  */
 UINT DIR_GetTempDosDir( LPSTR path, UINT count )
 {
-    if (path) lstrcpyn( path, DIR_TempDosDir, count );
+    if (path) lstrcpyn32A( path, DIR_TempDosDir, count );
     return strlen( DIR_TempDosDir );
 }
 
@@ -192,7 +192,7 @@
  */
 UINT DIR_GetTempUnixDir( LPSTR path, UINT count )
 {
-    if (path) lstrcpyn( path, DIR_TempUnixDir, count );
+    if (path) lstrcpyn32A( path, DIR_TempUnixDir, count );
     return strlen( DIR_TempUnixDir );
 }
 
@@ -202,7 +202,7 @@
  */
 UINT DIR_GetWindowsUnixDir( LPSTR path, UINT count )
 {
-    if (path) lstrcpyn( path, DIR_WindowsUnixDir, count );
+    if (path) lstrcpyn32A( path, DIR_WindowsUnixDir, count );
     return strlen( DIR_WindowsUnixDir );
 }
 
@@ -212,7 +212,7 @@
  */
 UINT DIR_GetSystemUnixDir( LPSTR path, UINT count )
 {
-    if (path) lstrcpyn( path, DIR_SystemUnixDir, count );
+    if (path) lstrcpyn32A( path, DIR_SystemUnixDir, count );
     return strlen( DIR_SystemUnixDir );
 }
 
@@ -223,7 +223,7 @@
 UINT DIR_GetDosPath( int element, LPSTR path, UINT count )
 {
     if ((element < 0) || (element >= DIR_PathElements)) return 0;
-    if (path) lstrcpyn( path, DIR_DosPath[element], count );
+    if (path) lstrcpyn32A( path, DIR_DosPath[element], count );
     return strlen( DIR_DosPath[element] );
 }
 
@@ -242,7 +242,7 @@
  */
 UINT GetWindowsDirectory( LPSTR path, UINT count )
 {
-    if (path) lstrcpyn( path, DIR_WindowsDosDir, count );
+    if (path) lstrcpyn32A( path, DIR_WindowsDosDir, count );
     return strlen( DIR_WindowsDosDir );
 }
 
@@ -252,6 +252,6 @@
  */
 UINT GetSystemDirectory( LPSTR path, UINT count )
 {
-    if (path) lstrcpyn( path, DIR_SystemDosDir, count );
+    if (path) lstrcpyn32A( path, DIR_SystemDosDir, count );
     return strlen( DIR_SystemDosDir );
 }
diff --git a/files/dos_fs.c b/files/dos_fs.c
index 6565361..6e3efd8 100644
--- a/files/dos_fs.c
+++ b/files/dos_fs.c
@@ -397,7 +397,7 @@
             if (!strcmp( dos_name, hash_name )) break;
         }
     }
-    if (dirent) lstrcpyn( buffer, dirent->d_name, maxlen );
+    if (dirent) lstrcpyn32A( buffer, dirent->d_name, maxlen );
     closedir( dir );
     dprintf_dosfs( stddeb, "DOSFS_FindUnixName(%s,%s) -> %s\n",
                    path, name, dirent ? buffer : "** Not found **" );
@@ -422,7 +422,7 @@
     for (i = 0; i < sizeof(DOSFS_Devices)/sizeof(DOSFS_Devices[0]); i++)
     {
         const char *dev = DOSFS_Devices[i][0];
-        if (!lstrncmpi( dev, name, strlen(dev) ))
+        if (!lstrncmpi32A( dev, name, strlen(dev) ))
         {
             p = name + strlen( dev );
             if (!*p || (*p == '.')) return DOSFS_Devices[i][1];
@@ -468,7 +468,7 @@
         DOS_ERROR( ER_InvalidDrive, EC_MediaError, SA_Abort, EL_Disk );
         return NULL;
     }
-    lstrcpyn( buffer, DRIVE_GetRoot(drive), MAX_PATHNAME_LEN );
+    lstrcpyn32A( buffer, DRIVE_GetRoot(drive), MAX_PATHNAME_LEN );
     if (buffer[1]) root = buffer + strlen(buffer);
     else root = buffer;  /* root directory */
 
@@ -478,8 +478,8 @@
     }
     else
     {
-        lstrcpyn( root + 1, DRIVE_GetUnixCwd(drive),
-                  MAX_PATHNAME_LEN - (int)(root - buffer) - 1 );
+        lstrcpyn32A( root + 1, DRIVE_GetUnixCwd(drive),
+                     MAX_PATHNAME_LEN - (int)(root - buffer) - 1 );
         if (root[1]) *root = '/';
     }
 
@@ -582,7 +582,7 @@
     else
     {
         *p++ = '\\';
-        lstrcpyn( p, DRIVE_GetDosCwd(drive), sizeof(buffer) - 3 );
+        lstrcpyn32A( p, DRIVE_GetDosCwd(drive), sizeof(buffer) - 3 );
         if (*p) p += strlen(p); else p--;
     }
     *p = '\0';
@@ -605,7 +605,7 @@
         *p++ = '\\';
         if (unix_format)  /* Hash it into a DOS name */
         {
-            lstrcpyn( p, DOSFS_Hash( name, FALSE ), len );
+            lstrcpyn32A( p, DOSFS_Hash( name, FALSE ), len );
             len -= strlen(p);
             p += strlen(p);
             while (!IS_END_OF_NAME(*name)) name++;
@@ -678,7 +678,7 @@
             if (!*drive_path) drive_root = 1;
         }
         dprintf_dosfs(stddeb, "DOSFS_FindNext: drive_root = %d\n", drive_root);
-        lstrcpyn( buffer, path, sizeof(buffer) - 1 );
+        lstrcpyn32A( buffer, path, sizeof(buffer) - 1 );
         
     }
     strcat( buffer, "/" );
@@ -695,7 +695,7 @@
         if (drive_root && (dirent->d_name[0] == '.') &&
             (!dirent->d_name[1] ||
              ((dirent->d_name[1] == '.') && !dirent->d_name[2]))) continue;
-        lstrcpyn( p, dirent->d_name, sizeof(buffer) - (int)(p - buffer) );
+        lstrcpyn32A( p, dirent->d_name, sizeof(buffer) - (int)(p - buffer) );
 
         if (!FILE_Stat( buffer, &entry->attr, &entry->size,
                         &entry->date, &entry->time ))
@@ -705,7 +705,7 @@
         }
         if (entry->attr & ~attr) continue;
         strcpy( entry->name, hash_name );
-        lstrcpyn( entry->unixname, dirent->d_name, sizeof(entry->unixname) );
+        lstrcpyn32A( entry->unixname, dirent->d_name, sizeof(entry->unixname));
         dprintf_dosfs( stddeb, "DOSFS_FindNext: returning %s %02x %ld\n",
                        entry->name, entry->attr, entry->size );
         cur_pos += count;
diff --git a/files/drive.c b/files/drive.c
index c51c2f5..8813696 100644
--- a/files/drive.c
+++ b/files/drive.c
@@ -72,7 +72,7 @@
     PROFILE_GetWineIniString( name, "Type", "hd", buffer, sizeof(buffer) );
     for (i = 0; i < sizeof(DRIVE_Types)/sizeof(DRIVE_Types[0]); i++)
     {
-        if (!lstrcmpi( buffer, DRIVE_Types[i] )) return (DRIVETYPE)i;
+        if (!lstrcmpi32A( buffer, DRIVE_Types[i] )) return (DRIVETYPE)i;
     }
     fprintf( stderr, "%s: unknown type '%s', defaulting to 'hd'.\n",
              name, buffer );
@@ -362,7 +362,7 @@
     dprintf_dosfs( stddeb, "DRIVE_Chdir(%c:,%s)\n", 'A' + drive, path );
     strcpy( buffer, "A:" );
     buffer[0] += drive;
-    lstrcpyn( buffer + 2, path, sizeof(buffer) - 2 );
+    lstrcpyn32A( buffer + 2, path, sizeof(buffer) - 2 );
 
     if (!(unix_cwd = DOSFS_GetUnixFileName( buffer, TRUE ))) return 0;
     if (!FILE_Stat( unix_cwd, &attr, NULL, NULL, NULL )) return 0;
@@ -374,7 +374,7 @@
     unix_cwd += strlen( DOSDrives[drive].root );
     while (*unix_cwd == '/') unix_cwd++;
     buffer[2] = '/';
-    lstrcpyn( buffer + 3, unix_cwd, sizeof(buffer) - 3 );
+    lstrcpyn32A( buffer + 3, unix_cwd, sizeof(buffer) - 3 );
     if (!(dos_cwd = DOSFS_GetDosTrueName( buffer, TRUE ))) return 0;
 
     dprintf_dosfs( stddeb, "DRIVE_Chdir(%c:): unix_cwd=%s dos_cwd=%s\n",
@@ -388,7 +388,7 @@
     if (pTask && (pTask->curdrive & 0x80) && 
         ((pTask->curdrive & ~0x80) == drive))
     {
-        lstrcpyn( pTask->curdir, dos_cwd + 2, sizeof(pTask->curdir) );
+        lstrcpyn32A( pTask->curdir, dos_cwd + 2, sizeof(pTask->curdir) );
         DRIVE_LastTask = GetCurrentTask();
     }
     return 1;
@@ -511,7 +511,7 @@
         *buf = '\0';
         return 0;
     }
-    lstrcpyn( buf, s, buflen );
+    lstrcpyn32A( buf, s, buflen );
     return strlen(s); /* yes */
 }
 
diff --git a/files/file.c b/files/file.c
index e9881a0..9662636 100644
--- a/files/file.c
+++ b/files/file.c
@@ -5,6 +5,7 @@
  * Copyright 1996 Alexandre Julliard
  */
 
+#include <ctype.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
@@ -43,7 +44,7 @@
 } DOS_FILE;
 
 /* Global files array */
-static DOS_FILE DOSFiles[MAX_OPEN_FILES] = { { 0, }, };
+static DOS_FILE DOSFiles[MAX_OPEN_FILES];
 
 static DOS_FILE *FILE_First = DOSFiles;
 static DOS_FILE *FILE_LastUsed = DOSFiles;
@@ -599,12 +600,12 @@
 /***********************************************************************
  *           FILE_Read
  */
-LONG FILE_Read( HFILE hFile, void *buffer, LONG count )
+INT32 FILE_Read( HFILE hFile, LPVOID buffer, UINT32 count )
 {
     DOS_FILE *file;
-    LONG result;
+    INT32 result;
 
-    dprintf_file( stddeb, "FILE_Read: %d %p %ld\n", hFile, buffer, count );
+    dprintf_file( stddeb, "FILE_Read: %d %p %d\n", hFile, buffer, count );
     if (!(file = FILE_GetFile( hFile ))) return -1;
     if (!count) return 0;
     if ((result = read( file->unix_handle, buffer, count )) == -1)
@@ -622,6 +623,14 @@
     UINT num = unique ? (unique & 0xffff) : time(NULL) & 0xffff;
     char *p;
 
+    if ((drive & TF_FORCEDRIVE) &&
+        !DRIVE_IsValid( toupper(drive & ~TF_FORCEDRIVE) - 'A' ))
+    {
+        drive &= ~TF_FORCEDRIVE;
+        fprintf( stderr, "Warning: GetTempFileName: invalid drive %d specified\n",
+                 drive );
+    }
+
     if (drive & TF_FORCEDRIVE)
     {
         sprintf( buffer, "%c:", drive & ~TF_FORCEDRIVE );
@@ -638,7 +647,7 @@
 
     if (unique)
     {
-        lstrcpyn( buffer, DOSFS_GetDosTrueName( buffer, FALSE ), 144 );
+        lstrcpyn32A( buffer, DOSFS_GetDosTrueName( buffer, FALSE ), 144 );
         dprintf_file( stddeb, "GetTempFileName: returning %s\n", buffer );
         return unique;
     }
@@ -659,7 +668,7 @@
         sprintf( p, "%04x.tmp", num );
     } while (num != (unique & 0xffff));
 
-    lstrcpyn( buffer, DOSFS_GetDosTrueName( buffer, FALSE ), 144 );
+    lstrcpyn32A( buffer, DOSFS_GetDosTrueName( buffer, FALSE ), 144 );
     dprintf_file( stddeb, "GetTempFileName: returning %s\n", buffer );
     return num;
 }
@@ -696,7 +705,7 @@
     if (mode & OF_PARSE)
     {
         if (!(dosName = DOSFS_GetDosTrueName( name, FALSE ))) goto error;
-        lstrcpyn( ofs->szPathName, dosName, sizeof(ofs->szPathName) );
+        lstrcpyn32A( ofs->szPathName, dosName, sizeof(ofs->szPathName) );
         ofs->fFixedDisk = (GetDriveType( dosName[0]-'A' ) != DRIVE_REMOVABLE);
         dprintf_file( stddeb, "OpenFile(%s): OF_PARSE, res = '%s', %d\n",
                       name, ofs->szPathName, hFileRet );
@@ -712,8 +721,8 @@
     if (mode & OF_CREATE)
     {
         if (!(file = FILE_Create( name, 0666, FALSE ))) goto error;
-        lstrcpyn( ofs->szPathName, DOSFS_GetDosTrueName( name, FALSE ),
-                  sizeof(ofs->szPathName) );
+        lstrcpyn32A( ofs->szPathName, DOSFS_GetDosTrueName( name, FALSE ),
+                     sizeof(ofs->szPathName) );
         goto success;
     }
 
@@ -721,7 +730,7 @@
 
     /* First try the current directory */
 
-    lstrcpyn( ofs->szPathName, name, sizeof(ofs->szPathName) );
+    lstrcpyn32A( ofs->szPathName, name, sizeof(ofs->szPathName) );
     if ((unixName = DOSFS_GetUnixFileName( ofs->szPathName, TRUE )) != NULL)
         goto found;
 
@@ -784,8 +793,8 @@
 
 found:
     dprintf_file( stddeb, "OpenFile: found '%s'\n", unixName );
-    lstrcpyn( ofs->szPathName, DOSFS_GetDosTrueName( ofs->szPathName, FALSE ),
-              sizeof(ofs->szPathName) );
+    lstrcpyn32A(ofs->szPathName, DOSFS_GetDosTrueName( ofs->szPathName, FALSE),
+                sizeof(ofs->szPathName) );
 
     if (mode & OF_DELETE)
     {
diff --git a/files/profile.c b/files/profile.c
index 9932328..ec45261 100644
--- a/files/profile.c
+++ b/files/profile.c
@@ -73,7 +73,7 @@
 
     if (!handle_env)
     {
-        lstrcpyn( buffer, value, len );
+        lstrcpyn32A( buffer, value, len );
         if (quote && (len >= strlen(value))) buffer[strlen(buffer)-1] = '\0';
         return;
     }
@@ -86,10 +86,10 @@
             const char *env_p;
             const char *p2 = strchr( p, '}' );
             if (!p2) continue;  /* ignore it */
-            lstrcpyn( env_val, p + 2, MIN( sizeof(env_val), (int)(p2-p)-1 ) );
+            lstrcpyn32A(env_val, p + 2, MIN( sizeof(env_val), (int)(p2-p)-1 ));
             if ((env_p = getenv( env_val )) != NULL)
             {
-                lstrcpyn( buffer, env_p, len );
+                lstrcpyn32A( buffer, env_p, len );
                 buffer += strlen( buffer );
                 len -= strlen( buffer );
             }
@@ -230,7 +230,7 @@
 {
     while (*section)
     {
-        if ((*section)->name && !lstrcmpi( (*section)->name, name ))
+        if ((*section)->name && !lstrcmpi32A( (*section)->name, name ))
         {
             PROFILESECTION *to_del = *section;
             *section = to_del->next;
@@ -254,12 +254,12 @@
 {
     while (*section)
     {
-        if ((*section)->name && !lstrcmpi( (*section)->name, section_name ))
+        if ((*section)->name && !lstrcmpi32A( (*section)->name, section_name ))
         {
             PROFILEKEY **key = &(*section)->key;
             while (*key)
             {
-                if (!lstrcmpi( (*key)->name, key_name ))
+                if (!lstrcmpi32A( (*key)->name, key_name ))
                 {
                     PROFILEKEY *to_del = *key;
                     *key = to_del->next;
@@ -288,12 +288,12 @@
 {
     while (*section)
     {
-        if ((*section)->name && !lstrcmpi( (*section)->name, section_name ))
+        if ((*section)->name && !lstrcmpi32A( (*section)->name, section_name ))
         {
             PROFILEKEY **key = &(*section)->key;
             while (*key)
             {
-                if (!lstrcmpi( (*key)->name, key_name )) return *key;
+                if (!lstrcmpi32A( (*key)->name, key_name )) return *key;
                 key = &(*key)->next;
             }
             if (!create) return NULL;
@@ -446,7 +446,7 @@
     PROFILEKEY *key;
     while (section)
     {
-        if (section->name && !lstrcmpi( section->name, section_name ))
+        if (section->name && !lstrcmpi32A( section->name, section_name ))
         {
             INT oldlen = len;
             for (key = section->key; key; key = key->next)
@@ -574,7 +574,7 @@
 
     if ((p = getenv( "HOME" )) != NULL)
     {
-        lstrcpyn( buffer, p, MAX_PATHNAME_LEN - sizeof(PROFILE_WineIniName) );
+        lstrcpyn32A(buffer, p, MAX_PATHNAME_LEN - sizeof(PROFILE_WineIniName));
         strcat( buffer, PROFILE_WineIniName );
         if ((f = fopen( buffer, "r" )) != NULL)
         {
@@ -662,7 +662,7 @@
 {
     if (PROFILE_Open( filename ))
         return PROFILE_GetString( section, entry, def_val, buffer, len );
-    lstrcpyn( buffer, def_val, len );
+    lstrcpyn32A( buffer, def_val, len );
     return strlen( buffer );
 }
 
diff --git a/if1632/Makefile.in b/if1632/Makefile.in
index 5cb814c..c4bd7cc 100644
--- a/if1632/Makefile.in
+++ b/if1632/Makefile.in
@@ -15,6 +15,7 @@
 	kernel.spec \
 	kernel32.spec \
 	keyboard.spec \
+	lz32.spec \
 	lzexpand.spec \
 	mmsystem.spec \
 	mouse.spec \
@@ -37,6 +38,7 @@
 	user.spec \
 	user32.spec \
 	ver.spec \
+	version.spec \
 	w32sys.spec \
 	win87em.spec \
 	winsock.spec \
diff --git a/if1632/gdi.spec b/if1632/gdi.spec
index ef8e645..635e163 100644
--- a/if1632/gdi.spec
+++ b/if1632/gdi.spec
@@ -56,7 +56,7 @@
 #46  pascal __GP?
 47  pascal16 CombineRgn(word word word s_word) CombineRgn
 48  pascal16 CreateBitmap(word word word word ptr) CreateBitmap
-49  pascal16 CreateBitmapIndirect(ptr) CreateBitmapIndirect
+49  pascal16 CreateBitmapIndirect(ptr) CreateBitmapIndirect16
 50  pascal16 CreateBrushIndirect(ptr) CreateBrushIndirect
 51  pascal16 CreateCompatibleBitmap(word word word) CreateCompatibleBitmap
 52  pascal16 CreateCompatibleDC(word) CreateCompatibleDC
@@ -89,7 +89,7 @@
 79  pascal GetDCOrg(word) GetDCOrg
 80  pascal16 GetDeviceCaps(word s_word) GetDeviceCaps
 81  pascal16 GetMapMode(word) GetMapMode
-82  pascal16 GetObject(word word ptr) GetObject
+82  pascal16 GetObject(word s_word ptr) GetObject16
 83  pascal GetPixel(word s_word s_word) GetPixel
 84  pascal16 GetPolyFillMode(word) GetPolyFillMode
 85  pascal16 GetROP2(word) GetROP2
diff --git a/if1632/gdi32.spec b/if1632/gdi32.spec
index afa0d1c..e7dc132 100644
--- a/if1632/gdi32.spec
+++ b/if1632/gdi32.spec
@@ -27,8 +27,8 @@
 0022 stub CopyEnhMetaFileW
 0023 stub CopyMetaFileA
 0024 stub CopyMetaFileW
-0025 stub CreateBitmap
-0026 stub CreateBitmapIndirect
+0025 stdcall CreateBitmap(long long long long ptr) CreateBitmap
+0026 stdcall CreateBitmapIndirect(ptr) CreateBitmapIndirect32
 0027 stub CreateBrushIndirect
 0028 stub CreateColorSpaceA
 0029 stub CreateColorSpaceW
@@ -40,7 +40,7 @@
 0035 stub CreateDIBPatternBrushPt
 0036 stub CreateDIBSection
 0037 stub CreateDIBitmap
-0038 stub CreateDiscardableBitmap
+0038 stdcall CreateDiscardableBitmap(long long long) CreateDiscardableBitmap
 0039 stdcall CreateEllipticRgn(long long long long) CreateEllipticRgn
 0040 stdcall CreateEllipticRgnIndirect(ptr) CreateEllipticRgnIndirect32
 0041 stub CreateEnhMetaFileA
@@ -145,7 +145,7 @@
 0140 stub GdiSetServerAttr
 0141 stub GetArcDirection
 0142 stub GetAspectRatioFilterEx
-0143 stub GetBitmapBits
+0143 stdcall GetBitmapBits(long long ptr) GetBitmapBits
 0144 stdcall GetBitmapDimensionEx(long ptr) GetBitmapDimensionEx32
 0145 stub GetBkColor
 0146 stub GetBkMode
@@ -206,9 +206,9 @@
 0201 stub GetMiterLimit
 0202 stdcall GetNearestColor(long long) GetNearestColor
 0203 stub GetNearestPaletteIndex
-0204 stdcall GetObjectA(long long ptr) WIN32_GetObject
+0204 stdcall GetObjectA(long long ptr) GetObject32A
 0205 stub GetObjectType
-0206 stub GetObjectW
+0206 stdcall GetObjectW(long long ptr) GetObject32W
 0207 stub GetOutlineTextMetricsA
 0208 stub GetOutlineTextMetricsW
 0209 stub GetPaletteEntries
@@ -305,7 +305,7 @@
 0300 stub SelectPalette
 0301 stub SetAbortProc
 0302 stub SetArcDirection
-0303 stub SetBitmapBits
+0303 stdcall SetBitmapBits(long long ptr) SetBitmapBits
 0304 stdcall SetBitmapDimensionEx(long long long ptr) SetBitmapDimensionEx32
 0305 stdcall SetBkColor(long long) SetBkColor
 0306 stub SetBkMode
diff --git a/if1632/kernel.spec b/if1632/kernel.spec
index fb441e5..00fbace 100644
--- a/if1632/kernel.spec
+++ b/if1632/kernel.spec
@@ -83,10 +83,10 @@
 84  pascal   _llseek(word long word) _llseek
 85  pascal16 _lopen(ptr word) _lopen
 86  pascal16 _lwrite(word ptr word) _lwrite
-87  pascal16 RESERVED5(ptr ptr) lstrcmp
-88  pascal lstrcpy(segptr segptr) lstrcpy
-89  pascal lstrcat(segptr segptr) lstrcat
-90  pascal16 lstrlen(ptr) lstrlen
+87  pascal16 RESERVED5(ptr ptr) lstrcmp16
+88  pascal   lstrcpy(segptr segptr) lstrcpy16
+89  pascal   lstrcat(segptr segptr) lstrcat16
+90  pascal16 lstrlen(ptr) lstrlen16
 91  register InitTask() InitTask
 92  pascal16 GetTempDrive(byte) GetTempDrive
 93  pascal16 GetCodeHandle(segptr) GetCodeHandle
@@ -259,8 +259,8 @@
 349 pascal   _hread(word segptr long) _hread
 350 pascal   _hwrite(word ptr long) _hwrite
 #351 BUNNY_351
-352 stub lstrcatn
-353 pascal lstrcpyn(segptr segptr word) WIN16_lstrcpyn
+352 pascal   lstrcatn(segptr segptr word) lstrcatn16
+353 pascal   lstrcpyn(segptr segptr word) lstrcpyn16
 354 stub GetAppCompatFlags
 355 pascal16 GetWinDebugInfo(ptr word) GetWinDebugInfo
 356 pascal16 SetWinDebugInfo(ptr) SetWinDebugInfo
diff --git a/if1632/kernel32.spec b/if1632/kernel32.spec
index 82ced33..50982f9 100644
--- a/if1632/kernel32.spec
+++ b/if1632/kernel32.spec
@@ -145,7 +145,7 @@
 0140 stub FreeConsole
 0141 stdcall FreeEnvironmentStringsA(ptr)	FreeEnvironmentStringsA
 0142 stdcall FreeEnvironmentStringsW(ptr)	FreeEnvironmentStringsW
-0143 stub FreeLibrary
+0143 stdcall FreeLibrary(long) FreeLibrary32
 0144 stub FreeLibraryAndExitThread
 0145 stdcall FreeResource(long) FreeResource32
 0146 stub FreeVirtualBuffer
@@ -308,10 +308,9 @@
 0303 stub GetUserDefaultLCID
 0304 stub GetUserDefaultLangID
 0305 stub GetVDMCurrentDirectories
-#Use Win 3.1 GetVersion for now
-0306	stdcall GetVersion()	GetVersion
-0307 stub GetVersionExA
-0308 stub GetVersionExW
+0306 stdcall GetVersion() GetVersion32
+0307 stdcall GetVersionExA(ptr) GetVersionEx32A
+0308 stdcall GetVersionExW(ptr) GetVersionEx32W
 0309 stub GetVolumeInformationA
 0310 stub GetVolumeInformationW
 0311 stdcall GetWindowsDirectoryA(ptr long) GetWindowsDirectory
@@ -350,9 +349,9 @@
 0344 stdcall HeapWalk(long ptr) HeapWalk
 0345 stub InitAtomTable
 0346 stdcall InitializeCriticalSection(ptr) InitializeCriticalSection
-0347 stub InterlockedDecrement
-0348 stub InterlockedExchange
-0349 stub InterlockedIncrement
+0347 stdcall InterlockedDecrement(ptr) InterlockedDecrement
+0348 stdcall InterlockedExchange(ptr) InterlockedExchange
+0349 stdcall InterlockedIncrement(ptr) InterlockedIncrement
 0350 stub InvalidateConsoleDIBits
 0351 stdcall IsBadCodePtr(ptr long)	WIN32_IsBadCodePtr
 0352 stub IsBadHugeReadPtr
@@ -489,7 +488,7 @@
 0483 stub SetEndOfFile
 0484    stdcall SetEnvironmentVariableA(ptr ptr) SetEnvironmentVariableA
 0485 stub SetEnvironmentVariableW
-0486 stub SetErrorMode
+0486 stdcall SetErrorMode(long) SetErrorMode
 0487 	stdcall	SetEvent(long) SetEvent
 0488 stub SetFileApisToANSI
 0489 stub SetFileApisToOEM
@@ -601,24 +600,24 @@
 0595 stub _lopen
 0596 stub _lread
 0597 stub _lwrite
-0598    stdcall lstrcat(ptr ptr) strcat
-0599    stdcall lstrcatA(ptr ptr) strcat
-0600 stub lstrcatW
-0601    stdcall lstrcmp(ptr ptr) strcmp
-0602    stdcall lstrcmpA(ptr ptr) strcmp
-0603 stub lstrcmpW
-0604 stub lstrcmpi
-0605 stub lstrcmpiA
-0606 stub lstrcmpiW
-0607    stdcall lstrcpy(ptr ptr) strcpy
-0608 	stdcall lstrcpyA(ptr ptr) strcpy
-0609 stub lstrcpyW
-0610 stub lstrcpyn
-0611 stub lstrcpynA
-0612 stub lstrcpynW
-0613    stdcall lstrlen(ptr) strlen
-0614 	stdcall lstrlenA(ptr) strlen
-0615 stub lstrlenW
+0598 stdcall lstrcat(ptr ptr) lstrcat32A
+0599 stdcall lstrcatA(ptr ptr) lstrcat32A
+0600 stdcall lstrcatW(ptr ptr) lstrcat32W
+0601 stdcall lstrcmp(ptr ptr) lstrcmp32A
+0602 stdcall lstrcmpA(ptr ptr) lstrcmp32A
+0603 stdcall lstrcmpW(ptr ptr) lstrcmp32W
+0604 stdcall lstrcmpi(ptr ptr) lstrcmpi32A
+0605 stdcall lstrcmpiA(ptr ptr) lstrcmpi32A
+0606 stdcall lstrcmpiW(ptr ptr) lstrcmpi32W
+0607 stdcall lstrcpy(ptr ptr) lstrcpy32A
+0608 stdcall lstrcpyA(ptr ptr) lstrcpy32A
+0609 stdcall lstrcpyW(ptr ptr) lstrcpy32W
+0610 stdcall lstrcpyn(ptr ptr long) lstrcpyn32A
+0611 stdcall lstrcpynA(ptr ptr long) lstrcpyn32A
+0612 stdcall lstrcpynW(ptr ptr long) lstrcpyn32W
+0613 stdcall lstrlen(ptr) lstrlen32A
+0614 stdcall lstrlenA(ptr) lstrlen32A
+0615 stdcall lstrlenW(ptr) lstrlen32W
 #late additions
 0616 stub GetPrivateProfileSectionNamesA
 0617 stub GetPrivateProfileSectionNamesW
diff --git a/if1632/lz32.spec b/if1632/lz32.spec
new file mode 100644
index 0000000..6b4b0d4
--- /dev/null
+++ b/if1632/lz32.spec
@@ -0,0 +1,15 @@
+name	lz32
+type	win32
+
+0 stdcall LZCopy(word word) LZCopy
+1 stdcall LZOpenFileA(ptr ptr word) LZOpenFile32A
+2 stdcall LZInit(word) LZInit
+3 stdcall LZSeek(word long word) LZSeek
+4 stdcall LZRead(word ptr long) LZRead32
+5 stdcall LZClose(word) LZClose
+6 stdcall LZStart() LZStart
+7 stdcall CopyLZFile(word word) CopyLZFile
+8 stdcall LZDone() LZDone
+9 stdcall GetExpandedNameA(ptr ptr) GetExpandedName32A
+10 stdcall LZOpenFileW(ptr ptr word) LZOpenFile32W
+11 stdcall GetExpandedNameW(ptr ptr) GetExpandedName32W
diff --git a/if1632/lzexpand.spec b/if1632/lzexpand.spec
index ca0e9d3..e05997a 100644
--- a/if1632/lzexpand.spec
+++ b/if1632/lzexpand.spec
@@ -2,14 +2,14 @@
 type	win16
 
 1  pascal   LZCopy(word word) LZCopy
-2  pascal16 LZOpenFile(ptr ptr word) LZOpenFile
+2  pascal16 LZOpenFile(ptr ptr word) LZOpenFile16
 3  pascal16 LZInit(word) LZInit
 4  pascal   LZSeek(word long word) LZSeek
-5  pascal16 LZRead(word segptr word) LZRead
+5  pascal16 LZRead(word segptr word) LZRead16
 6  pascal16 LZClose(word) LZClose
 7  pascal16 LZStart() LZStart
 8  pascal   CopyLZFile(word word) CopyLZFile
 9  pascal16 LZDone() LZDone
-10 pascal16 GetExpandedName(ptr ptr) GetExpandedName
+10 pascal16 GetExpandedName(ptr ptr) GetExpandedName16
 #11 WEP
 #12 ___EXPORTEDSTUB 
diff --git a/if1632/user.spec b/if1632/user.spec
index 0a3c3bf..9afd4b4 100644
--- a/if1632/user.spec
+++ b/if1632/user.spec
@@ -108,7 +108,7 @@
 106 pascal16 GetKeyState(word) GetKeyState
 107 pascal   DefWindowProc(word word word long) DefWindowProc16
 108 pascal16 GetMessage(segptr word word word) GetMessage
-109 pascal16 PeekMessage(ptr word word word word) PeekMessage
+109 pascal16 PeekMessage(ptr word word word word) PeekMessage16
 110 pascal16 PostMessage(word word word long) PostMessage
 111 pascal   SendMessage(word word word long) SendMessage16
 112 pascal16 WaitMessage() WaitMessage
@@ -184,7 +184,7 @@
 182 pascal16 KillSystemTimer(word word) KillSystemTimer
 183 pascal16 GetCaretPos(ptr) GetCaretPos16
 184 stub QuerySendMessage
-185 pascal16 GrayString(word word ptr ptr word word word word word) GrayString
+185 pascal16 GrayString(word word segptr segptr s_word s_word s_word s_word s_word) GrayString
 186 pascal16 SwapMouseButton(word) SwapMouseButton
 187 pascal16 EndMenu() EndMenu
 188 pascal16 SetSysModalWindow(word) SetSysModalWindow
@@ -372,14 +372,14 @@
 416 pascal16 TrackPopupMenu(word word s_word s_word s_word word ptr) TrackPopupMenu16
 417 pascal   GetMenuCheckMarkDimensions() GetMenuCheckMarkDimensions
 418 pascal16 SetMenuItemBitmaps(word word word word word) SetMenuItemBitmaps
-420 pascal16 wsprintf() wsprintf
-421 pascal16 wvsprintf(ptr ptr ptr) wvsprintf
+420 pascal16 wsprintf() WIN16_wsprintf16
+421 pascal16 wvsprintf(ptr ptr ptr) wvsprintf16
 422 stub DlgDirSelectEx
 423 stub DlgDirSelectComboBoxEx
 427 pascal16 FindWindowEx(word word segptr ptr) FindWindowEx16
 428 stub TileWindows
 429 stub CascadeWindows
-430 pascal16 lstrcmp(ptr ptr) lstrcmp
+430 pascal16 lstrcmp(ptr ptr) lstrcmp16
 431 pascal   AnsiUpper(segptr) WIN16_AnsiUpper
 432 pascal   AnsiLower(segptr) WIN16_AnsiLower
 433 pascal16 IsCharAlpha(byte) IsCharAlpha
@@ -413,7 +413,7 @@
 465 pascal16 DragDetect(word long) DragDetect
 466 pascal16 DrawFocusRect(word ptr) DrawFocusRect16
 470 stub StringFunc
-471 pascal16 lstrcmpi(ptr ptr) lstrcmpi
+471 pascal16 lstrcmpi(ptr ptr) lstrcmpi16
 472 pascal   AnsiNext(segptr) AnsiNext
 473 pascal   AnsiPrev(segptr segptr) AnsiPrev
 475 stub SetScrollInfo
diff --git a/if1632/user32.spec b/if1632/user32.spec
index f764aca..6681bff 100644
--- a/if1632/user32.spec
+++ b/if1632/user32.spec
@@ -208,7 +208,7 @@
 0201 stdcall FlashWindow(long long) FlashWindow
 0202 stdcall FrameRect(long ptr long) FrameRect32
 0203 stub FreeDDElParam
-0204 stub GetActiveWindow
+0204 stdcall GetActiveWindow() GetActiveWindow
 0205 stub GetAppCompatFlags
 0206 stub GetAsyncKeyState
 0207 stub GetCapture
@@ -419,8 +419,8 @@
 0412 stub OpenWindowStationW
 0413 stub PackDDElParam
 0414 stub PaintDesktop
-0415 stub PeekMessageA
-0416 stub PeekMessageW
+0415 stdcall PeekMessageA(ptr long long long long) PeekMessage32A
+0416 stdcall PeekMessageW(ptr long long long long) PeekMessage32W
 0417 stub PlaySoundEvent
 0418 stdcall PostMessageA(long long long long) PostMessage
 0419 stub PostMessageW
@@ -588,10 +588,10 @@
 0581 stdcall WindowFromPoint(long long) WindowFromPoint32
 0582 stub keybd_event
 0583 stub mouse_event
-0584 stdcall wsprintfA() USER32_wsprintfA
-0585 stub wsprintfW
-0586 stub wvsprintfA
-0587 stub wvsprintfW
+0584 stdcall wsprintfA() WIN32_wsprintf32A
+0585 stdcall wsprintfW() WIN32_wsprintf32W
+0586 stdcall wvsprintfA(ptr ptr ptr) wvsprintf32A
+0587 stdcall wvsprintfW(ptr ptr ptr) wvsprintf32W
 #late additions
 0588 stub ChangeDisplaySettingsA
 0588 stub ChangeDisplaySettingsW
diff --git a/if1632/ver.spec b/if1632/ver.spec
index 60cadc8..11aa1e0 100644
--- a/if1632/ver.spec
+++ b/if1632/ver.spec
@@ -5,12 +5,12 @@
 
 2 pascal GetFileResourceSize(ptr segptr segptr ptr) GetFileResourceSize
 3 pascal GetFileResource(ptr segptr segptr long long ptr) GetFileResource
-6 pascal GetFileVersionInfoSize(ptr ptr) GetFileVersionInfoSize
-7 pascal GetFileVersionInfo(ptr long long ptr) GetFileVersionInfo
-8 pascal VerFindFile(word ptr ptr ptr ptr ptr ptr ptr) VerFindFile
-9 pascal VerInstallFile(word ptr ptr ptr ptr ptr ptr ptr) VerInstallFile
-10 pascal VerLanguageName(word ptr word) VerLanguageName
-11 pascal VerQueryValue(segptr ptr ptr ptr) VerQueryValue
+6 pascal GetFileVersionInfoSize(ptr ptr) GetFileVersionInfoSize16
+7 pascal GetFileVersionInfo(ptr long long ptr) GetFileVersionInfo16
+8 pascal VerFindFile(word ptr ptr ptr ptr ptr ptr ptr) VerFindFile16
+9 pascal VerInstallFile(word ptr ptr ptr ptr ptr ptr ptr) VerInstallFile16
+10 pascal VerLanguageName(word ptr word) VerLanguageName16
+11 pascal VerQueryValue(segptr ptr ptr ptr) VerQueryValue16
 20 stub GETFILEVERSIONINFORAW
 #21 VERFTHK_THUNKDATA16
 #22 VERTHKSL_THUNKDATA16
diff --git a/if1632/version.spec b/if1632/version.spec
new file mode 100644
index 0000000..3d8ec38
--- /dev/null
+++ b/if1632/version.spec
@@ -0,0 +1,17 @@
+name version
+type win32
+
+0 stdcall GetFileVersionInfoA(ptr long long ptr) GetFileVersionInfo32A
+1 stdcall GetFileVersionInfoSizeA(ptr ptr) GetFileVersionInfoSize32A
+2 stdcall GetFileVersionInfoSizeW(ptr ptr) GetFileVersionInfoSize32W
+3 stdcall GetFileVersionInfoW(ptr long long ptr) GetFileVersionInfo32W
+#4 stub VerFThk_ThunkData32
+5 stdcall VerFindFileA(word ptr ptr ptr ptr ptr ptr ptr) VerFindFile32A
+6 stdcall VerFindFileW(word ptr ptr ptr ptr ptr ptr ptr) VerFindFile32W
+7 stdcall VerInstallFileA(word ptr ptr ptr ptr ptr ptr ptr) VerInstallFile32A
+8 stdcall VerInstallFileW(word ptr ptr ptr ptr ptr ptr ptr) VerInstallFile32W
+9 stdcall VerLanguageNameA(word ptr word) VerLanguageName32A
+10 stdcall VerLanguageNameW(word ptr word) VerLanguageName32W
+11 stdcall VerQueryValueA(segptr ptr ptr ptr) VerQueryValue32A
+12 stdcall VerQueryValueW(segptr ptr ptr ptr) VerQueryValue32W
+#13 stub VerThkSL_ThunkData32
diff --git a/include/bitmap.h b/include/bitmap.h
index 5f0d360..e9cafb7 100644
--- a/include/bitmap.h
+++ b/include/bitmap.h
@@ -13,7 +13,7 @@
 typedef struct
 {
     GDIOBJHDR   header;
-    BITMAP      bitmap;
+    BITMAP16    bitmap;
     Pixmap      pixmap;
     SIZE16      size;   /* For SetBitmapDimension() */
 } BITMAPOBJ;
@@ -37,7 +37,8 @@
 
   /* objects/bitmap.c */
 extern BOOL BITMAP_Init(void);
-extern int BITMAP_GetObject( BITMAPOBJ * bmp, int count, LPSTR buffer );
+extern INT16 BITMAP_GetObject16( BITMAPOBJ * bmp, INT16 count, LPVOID buffer );
+extern INT32 BITMAP_GetObject32( BITMAPOBJ * bmp, INT32 count, LPVOID buffer );
 extern BOOL BITMAP_DeleteObject( HBITMAP hbitmap, BITMAPOBJ * bitmap );
 extern HBITMAP BITMAP_SelectObject( DC * dc, HBITMAP hbitmap,
                                     BITMAPOBJ * bmp );
diff --git a/include/brush.h b/include/brush.h
index daa2eaa..6803254 100644
--- a/include/brush.h
+++ b/include/brush.h
@@ -17,7 +17,7 @@
 typedef struct
 {
     GDIOBJHDR   header;
-    LOGBRUSH    logbrush WINE_PACKED;
+    LOGBRUSH16  logbrush WINE_PACKED;
 } BRUSHOBJ;
 
 #ifndef WINELIB
diff --git a/include/callback.h b/include/callback.h
index fb07a71..537cfa9 100644
--- a/include/callback.h
+++ b/include/callback.h
@@ -20,28 +20,28 @@
 /* by the build program to generate the file if1632/callto16.S */
 
                                /* func     ds    parameters */
-extern WORD CallTo16_word_     ( FARPROC, WORD );
+extern WORD CallTo16_word_     ( FARPROC16, WORD );
 
 #ifndef WINELIB
 
-extern WORD CallTo16_word_ww   ( FARPROC, WORD, WORD, WORD );
-extern WORD CallTo16_word_wl   ( FARPROC, WORD, WORD, LONG );
-extern WORD CallTo16_word_ll   ( FARPROC, WORD, LONG, LONG );
-extern WORD CallTo16_word_www  ( FARPROC, WORD, WORD, WORD, WORD );
-extern WORD CallTo16_word_wwl  ( FARPROC, WORD, WORD, WORD, LONG );
-extern WORD CallTo16_word_wlw  ( FARPROC, WORD, WORD, LONG, WORD );
-extern LONG CallTo16_long_wwl  ( FARPROC, WORD, WORD, WORD, LONG );
-extern WORD CallTo16_word_llwl ( FARPROC, WORD, LONG, LONG, WORD, LONG );
-extern LONG CallTo16_long_wwwl ( FARPROC, WORD, WORD, WORD, WORD, LONG );
-extern WORD CallTo16_word_lwww ( FARPROC, WORD, LONG, WORD, WORD, WORD );
-extern WORD CallTo16_word_wwll ( FARPROC, WORD, WORD, WORD, LONG, LONG);
-extern WORD CallTo16_word_wllwl( FARPROC, WORD, WORD, LONG, LONG, WORD, LONG );
-extern WORD CallTo16_word_wwlll( FARPROC, WORD, WORD, WORD, LONG, LONG, LONG );
-extern LONG CallTo16_long_lllllllwlwwwl( FARPROC, WORD, LONG, LONG, LONG,
+extern WORD CallTo16_word_ww   (FARPROC16, WORD, WORD, WORD);
+extern WORD CallTo16_word_wl   (FARPROC16, WORD, WORD, LONG);
+extern WORD CallTo16_word_ll   (FARPROC16, WORD, LONG, LONG);
+extern WORD CallTo16_word_www  (FARPROC16, WORD, WORD, WORD, WORD);
+extern WORD CallTo16_word_wwl  (FARPROC16, WORD, WORD, WORD, LONG);
+extern WORD CallTo16_word_wlw  (FARPROC16, WORD, WORD, LONG, WORD);
+extern LONG CallTo16_long_wwl  (FARPROC16, WORD, WORD, WORD, LONG);
+extern WORD CallTo16_word_llwl (FARPROC16, WORD, LONG, LONG, WORD, LONG);
+extern LONG CallTo16_long_wwwl (FARPROC16, WORD, WORD, WORD, WORD, LONG);
+extern WORD CallTo16_word_lwww (FARPROC16, WORD, LONG, WORD, WORD, WORD);
+extern WORD CallTo16_word_wwll (FARPROC16, WORD, WORD, WORD, LONG, LONG);
+extern WORD CallTo16_word_wllwl(FARPROC16, WORD, WORD, LONG, LONG, WORD, LONG);
+extern WORD CallTo16_word_wwlll(FARPROC16, WORD, WORD, WORD, LONG, LONG, LONG);
+extern LONG CallTo16_long_lllllllwlwwwl( FARPROC16, WORD, LONG, LONG, LONG,
                                          LONG, LONG, LONG, LONG, WORD, LONG,
                                          WORD, WORD, WORD, LONG );
 
-extern WORD CallTo16_regs_( FARPROC func, WORD ds, WORD es, WORD bp, WORD ax,
+extern WORD CallTo16_regs_( FARPROC16 func, WORD ds, WORD es, WORD bp, WORD ax,
                             WORD bx, WORD cx, WORD dx, WORD si, WORD di );
 
 #define CallEnumChildProc( func, hwnd, lParam ) \
diff --git a/include/compobj.h b/include/compobj.h
deleted file mode 100644
index d9482dc..0000000
--- a/include/compobj.h
+++ /dev/null
@@ -1,5 +0,0 @@
-/*
- *	compobj.h	-	Declarations for COMPOBJ
- */
-
-typedef	LPVOID	LPUNKNOWN;
diff --git a/include/except.h b/include/except.h
index 1c2ec01..ee93e3e 100644
--- a/include/except.h
+++ b/include/except.h
@@ -6,15 +6,7 @@
 #ifndef __WINE_EXCEPT_H
 #define __WINE_EXCEPT_H
 
-#include"windows.h"
-
-/* 
- * general definitions
- */
- 
-#ifndef PVOID
-#define PVOID void *
-#endif
+#include"wintypes.h"
 
 /*
  * exception codes
@@ -162,7 +154,7 @@
     DWORD    ExceptionFlags;
     struct __EXCEPTION_RECORD *ExceptionRecord;
 
-    PVOID    ExceptionAddress;
+    LPVOID   ExceptionAddress;
     DWORD    NumberParameters;
     DWORD    ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
 } EXCEPTION_RECORD;
@@ -173,7 +165,7 @@
     DWORD    ExceptionFlags;
     struct __EXCEPTION_RECORD *ExceptionRecord;
 
-    PVOID    ExceptionAddress;
+    LPVOID   ExceptionAddress;
     DWORD    NumberParameters;
     DWORD    ExceptionInformation[0];
 } EXCEPTION_RECORD_MIN;
@@ -203,7 +195,7 @@
 typedef DWORD ( *PEXCEPTION_HANDLER)( PEXCEPTION_RECORD          pexcrec,
                                       struct __EXCEPTION_FRAME  *pestframe,
                                       PCONTEXT                   pcontext,
-                                      PVOID                      pdispatcher);
+                                      LPVOID                     pdispatcher);
 
 /*
  * function pointer to a UnhandledExceptionFilter();
diff --git a/include/file.h b/include/file.h
index 7893a96..8b9de03 100644
--- a/include/file.h
+++ b/include/file.h
@@ -24,7 +24,7 @@
 extern int FILE_RemoveDir( LPCSTR path );
 extern HFILE FILE_Dup( HFILE hFile );
 extern HFILE FILE_Dup2( HFILE hFile1, HFILE hFile2 );
-extern LONG FILE_Read( HFILE hFile, void *buffer, LONG count );
+extern INT32 FILE_Read( HFILE hFile, LPVOID buffer, UINT32 count );
 extern INT _lcreat_uniq( LPCSTR path, INT attr );
 
 #endif  /* __WINE_FILE_H */
diff --git a/include/font.h b/include/font.h
index 8a8dae7..8372ebd 100644
--- a/include/font.h
+++ b/include/font.h
@@ -17,7 +17,7 @@
 typedef struct
 {
     GDIOBJHDR   header;
-    LOGFONT     logfont WINE_PACKED;
+    LOGFONT16   logfont WINE_PACKED;
 } FONTOBJ;
 
 /* may be switched... */
diff --git a/include/gdi.h b/include/gdi.h
index ac9b3a6..398b9c5 100644
--- a/include/gdi.h
+++ b/include/gdi.h
@@ -158,7 +158,7 @@
 typedef struct
 {
     XFontStruct * fstruct;
-    TEXTMETRIC    metrics;
+    TEXTMETRIC16  metrics;
 } X_PHYSFONT;
 
   /* X physical palette information */
@@ -281,9 +281,6 @@
 extern GDIOBJHDR * GDI_GetObjPtr( HANDLE, WORD );
 extern FARPROC16 GDI_GetDefDCHook(void);
 
-#define UpdateDirtyDC(dc) \
-	    DC_CallHookProc(dc, DCHC_INVALIDVISRGN, 0)
-
 extern Display * display;
 extern Screen * screen;
 extern Window rootWindow;
diff --git a/include/global.h b/include/global.h
index 42014fc..dc8c939 100644
--- a/include/global.h
+++ b/include/global.h
@@ -17,12 +17,13 @@
 } SHMDATA;
 
 extern HGLOBAL16 GLOBAL_CreateBlock( UINT16 flags, const void *ptr, DWORD size,
-                                     HGLOBAL16 hOwner, BOOL isCode,
-                                     BOOL is32Bit, BOOL isReadOnly,
+                                     HGLOBAL16 hOwner, BOOL16 isCode,
+                                     BOOL16 is32Bit, BOOL16 isReadOnly,
                                      SHMDATA *shmdata);
-extern BOOL GLOBAL_FreeBlock( HGLOBAL16 handle );
+extern BOOL16 GLOBAL_FreeBlock( HGLOBAL16 handle );
 extern HGLOBAL16 GLOBAL_Alloc( WORD flags, DWORD size, HGLOBAL16 hOwner,
-                               BOOL isCode, BOOL is32Bit, BOOL isReadOnly );
+                               BOOL16 isCode, BOOL16 is32Bit,
+                               BOOL16 isReadOnly );
 extern WORD GlobalHandleToSel( HGLOBAL16 handle );
 
 #endif  /* __WINE_GLOBAL_H */
diff --git a/include/keyboard.h b/include/keyboard.h
deleted file mode 100644
index c9f784f..0000000
--- a/include/keyboard.h
+++ /dev/null
@@ -1,114 +0,0 @@
-#ifndef __WINE_KEYBOARD_H
-#define __WINE_KEYBOARD_H
-
-struct KeyTableEntry {
-	int virtualkey;
-	int ASCII;
-	int scancode;
-	char *name;
-};
-
-struct KeyTableEntry KeyTable[] = {
-	{ 0x3, 0x3, 0x0, "" },
-	{ 0x8, 0x8, 0xe, "Backspace" },
-	{ 0x9, 0x9, 0xf, "Tab" },
-	{ 0xc, 0x0, 0x4c, "Num 5" },
-	{ 0xd, 0xd, 0x1c, "Enter" },
-	{ 0x10, 0x0, 0x2a, "Shift" },
-	{ 0x11, 0x0, 0x1d, "Ctrl" },
-	{ 0x12, 0x0, 0x38, "Alt" },
-	{ 0x14, 0x0, 0x3a, "Caps Lock" },
-	{ 0x1b, 0x1b, 0x1, "Esc" },
-	{ 0x20, 0x20, 0x39, "Space" },
-	{ 0x21, 0x0, 0x49, "Num 9" },
-	{ 0x22, 0x0, 0x51, "Num 3" },
-	{ 0x23, 0x0, 0x4f, "Num 1" },
-	{ 0x24, 0x0, 0x47, "Num 7" },
-	{ 0x25, 0x0, 0x4b, "Num 4" },
-	{ 0x26, 0x0, 0x48, "Num 8" },
-	{ 0x27, 0x0, 0x4d, "Num 6" },
-	{ 0x28, 0x0, 0x50, "Num 2" },
-	{ 0x2d, 0x0, 0x52, "Num 0" },
-	{ 0x2e, 0x0, 0x53, "Num Del" },
-	{ 0x30, 0x30, 0xb, "0" },
-	{ 0x31, 0x31, 0x2, "1" },
-	{ 0x32, 0x32, 0x3, "2" },
-	{ 0x33, 0x33, 0x4, "3" },
-	{ 0x34, 0x34, 0x5, "4" },
-	{ 0x35, 0x35, 0x6, "5" },
-	{ 0x36, 0x36, 0x7, "6" },
-	{ 0x37, 0x37, 0x8, "7" },
-	{ 0x38, 0x38, 0x9, "8" },
-	{ 0x39, 0x39, 0xa, "9" },
-	{ 0x41, 0x41, 0x1e, "A" },
-	{ 0x42, 0x42, 0x30, "B" },
-	{ 0x43, 0x43, 0x2e, "C" },
-	{ 0x44, 0x44, 0x20, "D" },
-	{ 0x45, 0x45, 0x12, "E" },
-	{ 0x46, 0x46, 0x21, "F" },
-	{ 0x47, 0x47, 0x22, "G" },
-	{ 0x48, 0x48, 0x23, "H" },
-	{ 0x49, 0x49, 0x17, "I" },
-	{ 0x4a, 0x4a, 0x24, "J" },
-	{ 0x4b, 0x4b, 0x25, "K" },
-	{ 0x4c, 0x4c, 0x26, "L" },
-	{ 0x4d, 0x4d, 0x32, "M" },
-	{ 0x4e, 0x4e, 0x31, "N" },
-	{ 0x4f, 0x4f, 0x18, "O" },
-	{ 0x50, 0x50, 0x19, "P" },
-	{ 0x51, 0x51, 0x10, "Q" },
-	{ 0x52, 0x52, 0x13, "R" },
-	{ 0x53, 0x53, 0x1f, "S" },
-	{ 0x54, 0x54, 0x14, "T" },
-	{ 0x55, 0x55, 0x16, "U" },
-	{ 0x56, 0x56, 0x2f, "V" },
-	{ 0x57, 0x57, 0x11, "W" },
-	{ 0x58, 0x58, 0x2d, "X" },
-	{ 0x59, 0x59, 0x15, "Y" },
-	{ 0x5a, 0x5a, 0x2c, "Z" },
-	{ 0x60, 0x0, 0x52, "Num 0" },
-	{ 0x61, 0x0, 0x4f, "Num 1" },
-	{ 0x62, 0x0, 0x50, "Num 2" },
-	{ 0x63, 0x0, 0x51, "Num 3" },
-	{ 0x64, 0x0, 0x4b, "Num 4" },
-	{ 0x65, 0x0, 0x4c, "Num 5" },
-	{ 0x66, 0x0, 0x4d, "Num 6" },
-	{ 0x67, 0x0, 0x47, "Num 7" },
-	{ 0x68, 0x0, 0x48, "Num 8" },
-	{ 0x69, 0x0, 0x49, "Num 9" },
-	{ 0x6a, 0x2a, 0x37, "Num *" },
-	{ 0x6b, 0x2b, 0x4e, "Num +" },
-	{ 0x6c, 0x0, 0x0, "" },
-	{ 0x6d, 0x2d, 0x4a, "Num -" },
-	{ 0x6e, 0x2e, 0x53, "Num Del" },
-	{ 0x6f, 0x2f, 0x0, "" },
-	{ 0x70, 0x0, 0x3b, "F1" },
-	{ 0x71, 0x0, 0x3c, "F2" },
-	{ 0x72, 0x0, 0x3d, "F3" },
-	{ 0x73, 0x0, 0x3e, "F4" },
-	{ 0x74, 0x0, 0x3f, "F5" },
-	{ 0x75, 0x0, 0x40, "F6" },
-	{ 0x76, 0x0, 0x41, "F7" },
-	{ 0x77, 0x0, 0x42, "F8" },
-	{ 0x78, 0x0, 0x43, "F9" },
-	{ 0x79, 0x0, 0x44, "F10" },
-	{ 0x7a, 0x0, 0x57, "F11" },
-	{ 0x7b, 0x0, 0x58, "F12" },
-	{ 0x90, 0x0, 0x45, "Pause" },
-	{ 0x91, 0x0, 0x46, "Scroll Lock" },
-	{ 0xba, 0x3b, 0x27, ";" },
-	{ 0xbb, 0x3d, 0xd, "=" },
-	{ 0xbc, 0x2c, 0x33, "," },
-	{ 0xbd, 0x2d, 0xc, "-" },
-	{ 0xbe, 0x2e, 0x34, "." },
-	{ 0xbf, 0x2f, 0x35, "/" },
-	{ 0xc0, 0x60, 0x29, "`" },
-	{ 0xdb, 0x5b, 0x1a, "[" },
-	{ 0xdc, 0x5c, 0x2b, "\\" },
-	{ 0xdd, 0x5d, 0x1b, "]" },
-	{ 0xde, 0x27, 0x28, "\'" },
-	{ 0xe2, 0x5c, 0x56, "\\" },
-};
-#define KeyTableSize	sizeof(KeyTable) / sizeof(struct KeyTableEntry)
-
-#endif /* __WINE_KEYBOARD_H */
diff --git a/include/listbox.h b/include/listbox.h
index 8dfcf65..cdd82cb 100644
--- a/include/listbox.h
+++ b/include/listbox.h
@@ -3,7 +3,7 @@
  */
 
 typedef struct tagLISTSTRUCT {
-        MEASUREITEMSTRUCT mis;
+        MEASUREITEMSTRUCT16 mis;
         UINT            itemState;
         RECT16          itemRect;
 	HANDLE		hData;
diff --git a/include/lzexpand.h b/include/lzexpand.h
index bf58839..380ee98 100644
--- a/include/lzexpand.h
+++ b/include/lzexpand.h
@@ -3,17 +3,25 @@
  * Copyright 1996 Marcus Meissner
  */
 
-LONG	LZCopy(HFILE,HFILE);
-HFILE	LZOpenFile(LPCSTR,LPOFSTRUCT,UINT);
-HFILE	LZInit(HFILE);
-LONG	LZSeek(HFILE,LONG,INT);
-INT	LZRead(HFILE,SEGPTR,WORD); 
-void	LZClose(HFILE);
-INT	LZStart(void);
-LONG	CopyLZFile(HFILE,HFILE);
-void	LZDone(void);
-INT	GetExpandedName(LPCSTR,LPSTR);
+INT16      LZStart(void);
+HFILE      LZInit(HFILE);
+void       LZDone(void);
+LONG       LZSeek(HFILE,LONG,INT32);
+LONG       LZCopy(HFILE,HFILE);
+void       LZClose(HFILE);
+LONG       CopyLZFile(HFILE,HFILE);
 
+INT16      GetExpandedName16(LPCSTR,LPSTR);
+INT32      GetExpandedName32A(LPCSTR,LPSTR);
+INT32      GetExpandedName32W(LPCWSTR,LPWSTR);
+#define    GetExpandedName WINELIB_NAME_AW(GetExpandedName)
+HFILE      LZOpenFile16(LPCSTR,LPOFSTRUCT,UINT16);
+HFILE      LZOpenFile32A(LPCSTR,LPOFSTRUCT,UINT32);
+HFILE      LZOpenFile32W(LPCWSTR,LPOFSTRUCT,UINT32);
+#define    LZOpenFile WINELIB_NAME_AW(LZOpenFile)
+INT16      LZRead16(HFILE,SEGPTR,UINT16); 
+INT32      LZRead32(HFILE,LPVOID,UINT32); 
+#define    LZRead WINELIB_NAME(LZRead)
 
 #define LZERROR_BADINHANDLE	0xFFFF	/* -1 */
 #define LZERROR_BADOUTHANDLE	0xFFFE	/* -2 */
diff --git a/include/message.h b/include/message.h
index 1fc0266..72f64ad 100644
--- a/include/message.h
+++ b/include/message.h
@@ -13,7 +13,7 @@
 extern DWORD MSG_WineStartTicks;  /* Ticks at Wine startup */
 
 /* message.c */
-extern BOOL MSG_GetHardwareMessage( LPMSG msg );
+extern BOOL MSG_GetHardwareMessage( LPMSG16 msg );
 extern BOOL MSG_InternalGetMessage( SEGPTR msg, HWND hwnd, HWND hwndOwner,
 				    short code, WORD flags, BOOL sendIdle );
 
diff --git a/include/metafile.h b/include/metafile.h
index 7951832..0d2c306 100644
--- a/include/metafile.h
+++ b/include/metafile.h
@@ -26,10 +26,10 @@
 BOOL MF_MetaParam8(DC *dc, short func, short param1, short param2, 
 		   short param3, short param4, short param5,
 		   short param6, short param7, short param8);
-BOOL MF_CreateBrushIndirect(DC *dc, HBRUSH hBrush, LOGBRUSH *logbrush);
-BOOL MF_CreatePatternBrush(DC *dc, HBRUSH hBrush, LOGBRUSH *logbrush);
-BOOL MF_CreatePenIndirect(DC *dc, HPEN16 hPen, LOGPEN *logpen);
-BOOL MF_CreateFontIndirect(DC *dc, HFONT hFont, LOGFONT *logfont);
+BOOL MF_CreateBrushIndirect(DC *dc, HBRUSH hBrush, LOGBRUSH16 *logbrush);
+BOOL MF_CreatePatternBrush(DC *dc, HBRUSH hBrush, LOGBRUSH16 *logbrush);
+BOOL MF_CreatePenIndirect(DC *dc, HPEN16 hPen, LOGPEN16 *logpen);
+BOOL MF_CreateFontIndirect(DC *dc, HFONT hFont, LOGFONT16 *logfont);
 BOOL MF_TextOut(DC *dc, short x, short y, LPCSTR str, short count);
 BOOL MF_MetaPoly(DC *dc, short func, LPPOINT16 pt, short count);
 BOOL MF_BitBlt(DC *dcDest, short xDest, short yDest, short width,
diff --git a/include/neexe.h b/include/neexe.h
index 096050b..7cc36e4 100644
--- a/include/neexe.h
+++ b/include/neexe.h
@@ -199,7 +199,7 @@
     unsigned short length;
     unsigned short flags;
     unsigned short id;
-            HANDLE handle;
+    HANDLE16 handle;
     unsigned short usage;
 };
 
diff --git a/include/ole.h b/include/ole.h
index 9cc310a..9e3795d 100644
--- a/include/ole.h
+++ b/include/ole.h
@@ -2,6 +2,12 @@
  *	ole.h	-	Declarations for OLESVR and OLECLI
  */
 
+#ifndef __WINE_OLE_H
+#define __WINE_OLE_H
+
+#include "windows.h"
+
+typedef	LPVOID	LPUNKNOWN;
 typedef LPCSTR	OLE_LPCSTR;
 
 /* object types */
@@ -160,6 +166,7 @@
 	OLESTATUS	(*Close)(LPOLESERVERDOC);
 	OLESTATUS	(*SetHostNames)(LPOLESERVERDOC,OLE_LPCSTR,OLE_LPCSTR);
 	OLESTATUS	(*SetDocDimensions)(LPOLESERVERDOC,LPRECT16);
+#undef GetObject  /* FIXME */
 	OLESTATUS	(*GetObject)(LPOLESERVERDOC,OLE_LPCSTR,LPOLEOBJECT*,LPOLECLIENT);
 	OLESTATUS	(*Release)(LPOLESERVERDOC);
 	OLESTATUS	(*SetColorScheme)(LPOLESERVERDOC,LPLOGPALETTE);
@@ -251,3 +258,5 @@
 OLESTATUS OleRevokeServerDoc(LHSERVERDOC);
 OLESTATUS OleRevokeClientDoc(LHCLIENTDOC);
 OLESTATUS OleRevokeServer(LHSERVER);
+
+#endif  /* __WINE_OLE_H */
diff --git a/include/pen.h b/include/pen.h
index 7016d24..55858ec 100644
--- a/include/pen.h
+++ b/include/pen.h
@@ -17,7 +17,7 @@
 typedef struct
 {
     GDIOBJHDR   header;
-    LOGPEN      logpen WINE_PACKED;
+    LOGPEN16    logpen WINE_PACKED;
 } PENOBJ;
 
 #ifndef WINELIB
diff --git a/include/queue.h b/include/queue.h
index 6230b89..553f7a4 100644
--- a/include/queue.h
+++ b/include/queue.h
@@ -17,7 +17,7 @@
 typedef struct tagQMSG
 {
     DWORD   extraInfo;  /* Only in 3.1 */
-    MSG     msg;
+    MSG16   msg;
 } QMSG;
 
 
@@ -84,7 +84,7 @@
 extern BOOL QUEUE_CreateSysMsgQueue( int size );
 extern BOOL QUEUE_DeleteMsgQueue( HQUEUE hQueue );
 extern HTASK QUEUE_GetQueueTask( HQUEUE hQueue );
-extern BOOL QUEUE_AddMsg( HQUEUE hQueue, MSG * msg, DWORD extraInfo );
+extern BOOL QUEUE_AddMsg( HQUEUE hQueue, MSG16 * msg, DWORD extraInfo );
 extern int QUEUE_FindMsg( MESSAGEQUEUE * msgQueue, HWND hwnd,
                           int first, int last );
 extern void QUEUE_RemoveMsg( MESSAGEQUEUE * msgQueue, int pos );
diff --git a/include/resource.h b/include/resource.h
index 358a43e..e054b4f 100644
--- a/include/resource.h
+++ b/include/resource.h
@@ -7,7 +7,7 @@
 #ifndef __WINE_RESOURCE_H
 #define __WINE_RESOURCE_H
 
-#include "wintypes.h"
+#include "windows.h"
 
 struct resource
 {
diff --git a/include/string32.h b/include/string32.h
index 1431a59..7791411 100644
--- a/include/string32.h
+++ b/include/string32.h
@@ -10,16 +10,10 @@
 
 #include "wintypes.h"
 
-int	STRING32_UniLen(LPCWSTR s);
 void	STRING32_UniToAnsi(LPSTR dest,LPCWSTR src);
 void	STRING32_AnsiToUni(LPWSTR dest,LPCSTR src);
 LPSTR	STRING32_DupUniToAnsi(LPCWSTR src);
 LPWSTR	STRING32_DupAnsiToUni(LPCSTR src);
-LPWSTR  STRING32_lstrcpyW(LPWSTR dst, LPCWSTR src);
-int	STRING32_lstrcmpnW(LPCWSTR a,LPCWSTR b,DWORD len);
-int	STRING32_lstrcmpniW(LPCWSTR a,LPCWSTR b,DWORD len);
-DWORD	STRING32_lstrlenW(LPCWSTR);
 LPWSTR	STRING32_strdupW(LPCWSTR);
-int	STRING32_lstrcmpW(LPCWSTR,LPCWSTR);
 
 #endif
diff --git a/include/struct32.h b/include/struct32.h
index 702b918..0fe7769 100644
--- a/include/struct32.h
+++ b/include/struct32.h
@@ -35,18 +35,8 @@
 	WORD cy WINE_PACKED;
 } DLGTEMPLATE32;
 
-typedef struct tagMSG32
-{
-	DWORD hwnd;
-	DWORD message;
-	DWORD wParam;
-	DWORD lParam;
-	DWORD time;
-	POINT32 pt;
-} MSG32;
-
-void STRUCT32_MSG16to32(MSG *msg16,MSG32 *msg32);
-void STRUCT32_MSG32to16(MSG32 *msg32,MSG *msg16);
+void STRUCT32_MSG16to32(const MSG16 *msg16,MSG32 *msg32);
+void STRUCT32_MSG32to16(const MSG32 *msg32,MSG16 *msg16);
 
 void STRUCT32_CREATESTRUCT32Ato16(const CREATESTRUCT32A*,CREATESTRUCT16*);
 void STRUCT32_CREATESTRUCT16to32A(const CREATESTRUCT16*,CREATESTRUCT32A*);
diff --git a/include/task.h b/include/task.h
index ce56b76..b00f6fb 100644
--- a/include/task.h
+++ b/include/task.h
@@ -119,7 +119,4 @@
                               HANDLE hPrevInstance, HANDLE hEnvironment,
                               char *cmdLine, WORD cmdShow );
 
-  /* TASK_Reschedule() 16-bit entry point */
-extern FARPROC RELAY_RescheduleProcAddr;
-
 #endif /* _WINE_TASK_H */
diff --git a/include/ver.h b/include/ver.h
index 2324603..8672d86 100644
--- a/include/ver.h
+++ b/include/ver.h
@@ -127,6 +127,7 @@
 	DWORD   dwFileDateLS;
 } VS_FIXEDFILEINFO;
 
+/* following two aren't in version.dll */
 DWORD
 GetFileResourceSize(LPCSTR filename,SEGPTR restype,SEGPTR resid,LPDWORD off);
 
@@ -135,34 +136,60 @@
 		DWORD off,DWORD reslen,LPVOID data
 );
 
-DWORD
-GetFileVersionInfoSize(LPCSTR filename,LPDWORD handle);
+DWORD GetFileVersionInfoSize16(LPCSTR filename,LPDWORD handle);
+DWORD GetFileVersionInfoSize32A(LPCSTR filename,LPDWORD handle);
+DWORD GetFileVersionInfoSize32W(LPCWSTR filename,LPDWORD handle);
+#define GetFileVersionInfoSize WINELIB_NAME_AW(GetFileVersionInfoSize)
+
+DWORD GetFileVersionInfo16(LPCSTR filename,DWORD handle,DWORD datasize,LPVOID data);
+DWORD GetFileVersionInfo32A(LPCSTR filename,DWORD handle,DWORD datasize,LPVOID data);
+DWORD GetFileVersionInfo32W(LPCWSTR filename,DWORD handle,DWORD datasize,LPVOID data);
+#define GetFileVersionInfo WINELIB_NAME_AW(GetFileVersionInfo)
 
 DWORD
-GetFileVersionInfo(LPCSTR filename,DWORD handle,DWORD datasize,LPVOID data);
-
-DWORD
-VerFindFile(
-	UINT flags,LPCSTR filename,LPCSTR windir,LPCSTR appdir,
-	LPSTR curdir,UINT *curdirlen,LPSTR destdir,UINT*destdirlen
+VerFindFile16(
+	UINT16 flags,LPCSTR filename,LPCSTR windir,LPCSTR appdir,
+	LPSTR curdir,UINT16 *curdirlen,LPSTR destdir,UINT16 *destdirlen
 );
-
 DWORD
-VerInstallFile(
-	UINT flags,LPCSTR srcfilename,LPCSTR destfilename,LPCSTR srcdir,
-	LPCSTR destdir,LPSTR tmpfile,UINT*tmpfilelen
+VerFindFile32A(
+	UINT32 flags,LPCSTR filename,LPCSTR windir,LPCSTR appdir,
+	LPSTR curdir,UINT32 *curdirlen,LPSTR destdir,UINT32 *destdirlen
 );
+DWORD
+VerFindFile32W(
+	UINT32 flags,LPCWSTR filename,LPCWSTR windir,LPCWSTR appdir,
+	LPWSTR curdir,UINT32 *curdirlen,LPWSTR destdir,UINT32 *destdirlen
+);
+#define VerFindFile WINELIB_NAME_AW(VerFindFile)
 
 DWORD
-VerLanguageName(UINT lang,LPSTR langname,UINT langnamelen);
-
+VerInstallFile16(
+	UINT16 flags,LPCSTR srcfilename,LPCSTR destfilename,LPCSTR srcdir,
+	LPCSTR destdir,LPSTR tmpfile,UINT16 *tmpfilelen
+);
 DWORD
-VerQueryValue(SEGPTR block,LPCSTR subblock,SEGPTR *buffer,UINT *buflen);
+VerInstallFile32A(
+	UINT32 flags,LPCSTR srcfilename,LPCSTR destfilename,LPCSTR srcdir,
+	LPCSTR destdir,LPSTR tmpfile,UINT32 *tmpfilelen
+);
+DWORD
+VerInstallFile32W(
+	UINT32 flags,LPCWSTR srcfilename,LPCWSTR destfilename,LPCWSTR srcdir,
+	LPCWSTR destdir,LPWSTR tmpfile,UINT32 *tmpfilelen
+);
+#define VerInstallFile WINELIB_NAME_AW(VerInstallFile)
 
-/*
-   20 GETFILEVERSIONINFORAW
-   21 VERFTHK_THUNKDATA16
-   22 VERTHKSL_THUNKDATA16
-*/
+DWORD VerLanguageName16(UINT16 lang,LPSTR langname,UINT16 langnamelen);
+DWORD VerLanguageName32A(UINT32 lang,LPSTR langname,UINT32 langnamelen);
+DWORD VerLanguageName32W(UINT32 lang,LPWSTR langname,UINT32 langnamelen);
+#define VerLanguageName WINELIB_NAME_AW(VerLanguageName)
+
+DWORD VerQueryValue16(SEGPTR block,LPCSTR subblock,SEGPTR *buffer,UINT16 *buflen);
+DWORD VerQueryValue32A(LPVOID block,LPCSTR subblock,LPVOID *buffer,UINT32 *buflen);
+DWORD VerQueryValue32W(LPVOID block,LPCWSTR subblock,LPVOID *buffer,UINT32 *buflen);
+#define VerQueryValue WINELIB_NAME_AW(VerQueryValue)
+
+/* 20 GETFILEVERSIONINFORAW */
 
 #endif	/* __WINE_VER_H */
diff --git a/include/winbase.h b/include/winbase.h
index 27ef776..6775098 100644
--- a/include/winbase.h
+++ b/include/winbase.h
@@ -1,7 +1,7 @@
 #ifndef __WINE_WINBASE_H
 #define __WINE_WINBASE_H
 
-
+#include "wintypes.h"
 
 #ifdef UNICODE
 #define LoadAccelerators LoadAcceleratorsW
@@ -112,7 +112,34 @@
 	DWORD Reserved;
 }CRITICAL_SECTION;
 
+typedef struct {
+	DWORD dwOSVersionInfoSize;
+	DWORD dwMajorVersion;
+	DWORD dwMinorVersion;
+	DWORD dwBuildNumber;
+	DWORD dwPlatformId;
+	CHAR szCSDVersion[128];
+} OSVERSIONINFO32A;
+
+typedef struct {
+	DWORD dwOSVersionInfoSize;
+	DWORD dwMajorVersion;
+	DWORD dwMinorVersion;
+	DWORD dwBuildNumber;
+	DWORD dwPlatformId;
+	WCHAR szCSDVersion[128];
+} OSVERSIONINFO32W;
+
+DECL_WINELIB_TYPE_AW(OSVERSIONINFO);
+
+#define VER_PLATFORM_WIN32s             0
+#define VER_PLATFORM_WIN32_WINDOWS      1
+#define VER_PLATFORM_WIN32_NT           2
+
 /*DWORD WINAPI GetVersion( void );*/
+BOOL32 GetVersionEx32A(OSVERSIONINFO32A*);
+BOOL32 GetVersionEx32W(OSVERSIONINFO32W*);
+#define GetVersionEx WINELIB_NAME_AW(GetVersionEx)
 
 int WinMain(HINSTANCE, HINSTANCE prev, char *cmd, int show);
 
diff --git a/include/windows.h b/include/windows.h
index 3a1dcec..64363f0 100644
--- a/include/windows.h
+++ b/include/windows.h
@@ -91,12 +91,22 @@
     ((r16)->left  = (INT16)(r32)->left,  (r16)->top    = (INT16)(r32)->top, \
      (r16)->right = (INT16)(r32)->right, (r16)->bottom = (INT16)(r32)->bottom)
 
+typedef struct
+{
+    WORD   wFirst;
+    WORD   wSecond;
+    INT16  iKernAmount;
+} KERNINGPAIR16, *LPKERNINGPAIR16;
 
-typedef struct tagKERNINGPAIR {
-        WORD wFirst;
-        WORD wSecond;
-        INT  iKernAmount;
-} KERNINGPAIR, *LPKERNINGPAIR;
+typedef struct
+{
+    WORD   wFirst;
+    WORD   wSecond;
+    INT32  iKernAmount;
+} KERNINGPAIR32, *LPKERNINGPAIR32;
+
+DECL_WINELIB_TYPE(KERNINGPAIR);
+DECL_WINELIB_TYPE(LPKERNINGPAIR);
 
 typedef struct
 {
@@ -177,25 +187,64 @@
 
 typedef struct 
 {
-    HMENU     hWindowMenu;
-    WORD      idFirstChild;
-} CLIENTCREATESTRUCT, *LPCLIENTCREATESTRUCT;
+    HMENU16   hWindowMenu;
+    UINT16    idFirstChild;
+} CLIENTCREATESTRUCT16, *LPCLIENTCREATESTRUCT16;
+
+typedef struct 
+{
+    HMENU32   hWindowMenu;
+    UINT32    idFirstChild;
+} CLIENTCREATESTRUCT32, *LPCLIENTCREATESTRUCT32;
+
+DECL_WINELIB_TYPE(CLIENTCREATESTRUCT);
+DECL_WINELIB_TYPE(LPCLIENTCREATESTRUCT);
 
 typedef struct
 {
-    SEGPTR    szClass;
-    SEGPTR    szTitle;
-    HANDLE    hOwner;
-    INT       x;
-    INT       y;
-    INT       cx;
-    INT	      cy;
-    LONG      style WINE_PACKED;
-    LONG      lParam WINE_PACKED;
-} MDICREATESTRUCT, *LPMDICREATESTRUCT;
+    SEGPTR       szClass;
+    SEGPTR       szTitle;
+    HINSTANCE16  hOwner;
+    INT16        x;
+    INT16        y;
+    INT16        cx;
+    INT16        cy;
+    DWORD        style WINE_PACKED;
+    LPARAM       lParam WINE_PACKED;
+} MDICREATESTRUCT16, *LPMDICREATESTRUCT16;
+
+typedef struct
+{
+    LPCSTR       szClass;
+    LPCSTR       szTitle;
+    HINSTANCE32  hOwner;
+    INT32        x;
+    INT32        y;
+    INT32        cx;
+    INT32        cy;
+    DWORD        style;
+    LPARAM       lParam;
+} MDICREATESTRUCT32A, *LPMDICREATESTRUCT32A;
+
+typedef struct
+{
+    LPCWSTR      szClass;
+    LPCWSTR      szTitle;
+    HINSTANCE32  hOwner;
+    INT32        x;
+    INT32        y;
+    INT32        cx;
+    INT32        cy;
+    DWORD        style;
+    LPARAM       lParam;
+} MDICREATESTRUCT32W, *LPMDICREATESTRUCT32W;
+
+DECL_WINELIB_TYPE_AW(MDICREATESTRUCT);
+DECL_WINELIB_TYPE_AW(LPMDICREATESTRUCT);
 
 #define MDITILE_VERTICAL    0    
 #define MDITILE_HORIZONTAL  1
+#define MDIS_ALLCHILDSTYLES 0x0001
 
   /* Offsets for GetWindowLong() and GetWindowWord() */
 #define GWL_USERDATA        (-21)
@@ -429,31 +478,68 @@
 #define MSGF_USER        4096
 
   /* Journalling hook structure */
-typedef struct tagEVENTMSG
+
+typedef struct
 {
-    UINT    message;
-    UINT    paramL;
-    UINT    paramH;
+    UINT16  message;
+    UINT16  paramL;
+    UINT16  paramH;
     DWORD   time WINE_PACKED;
-} EVENTMSG, *LPEVENTMSG;
+} EVENTMSG16, *LPEVENTMSG16;
+
+typedef struct
+{
+    UINT32  message;
+    UINT32  paramL;
+    UINT32  paramH;
+    DWORD   time;
+    HWND32  hwnd;
+} EVENTMSG32, *LPEVENTMSG32;
+
+DECL_WINELIB_TYPE(EVENTMSG);
+DECL_WINELIB_TYPE(LPEVENTMSG);
 
   /* Mouse hook structure */
-typedef struct tagMOUSEHOOKSTRUCT
+
+typedef struct
 {
     POINT16 pt;
     HWND16  hwnd;
-    WORD    wHitTestCode;
+    UINT16  wHitTestCode;
     DWORD   dwExtraInfo;
-} MOUSEHOOKSTRUCT, *LPMOUSEHOOKSTRUCT;
+} MOUSEHOOKSTRUCT16, *LPMOUSEHOOKSTRUCT16;
+
+typedef struct
+{
+    POINT32 pt;
+    HWND32  hwnd;
+    UINT32  wHitTestCode;
+    DWORD   dwExtraInfo;
+} MOUSEHOOKSTRUCT32, *LPMOUSEHOOKSTRUCT32;
+
+DECL_WINELIB_TYPE(MOUSEHOOKSTRUCT);
+DECL_WINELIB_TYPE(LPMOUSEHOOKSTRUCT);
 
   /* Hardware hook structure */
-typedef struct tagHARDWAREHOOKSTRUCT
+
+typedef struct
 {
-    HWND    hWnd;
-    UINT    wMessage;
-    WPARAM  wParam;
-    LPARAM  lParam WINE_PACKED;
-} HARDWAREHOOKSTRUCT;
+    HWND16    hWnd;
+    UINT16    wMessage;
+    WPARAM16  wParam;
+    LPARAM    lParam WINE_PACKED;
+} HARDWAREHOOKSTRUCT16, *LPHARDWAREHOOKSTRUCT16;
+
+typedef struct
+{
+    HWND32    hWnd;
+    UINT32    wMessage;
+    WPARAM32  wParam;
+    LPARAM    lParam;
+} HARDWAREHOOKSTRUCT32, *LPHARDWAREHOOKSTRUCT32;
+
+DECL_WINELIB_TYPE(HARDWAREHOOKSTRUCT);
+DECL_WINELIB_TYPE(LPHARDWAREHOOKSTRUCT);
 
   /* CBT hook values */
 #define HCBT_MOVESIZE	    0
@@ -468,17 +554,41 @@
 #define HCBT_SETFOCUS	    9
 
   /* CBT hook structures */
-typedef struct tagCBT_CREATEWND
-{
-    CREATESTRUCT16 *lpcs;
-    HWND            hwndInsertAfter;
-} CBT_CREATEWND, *LPCBT_CREATEWND;
 
-typedef struct tagCBTACTIVATESTRUCT
+typedef struct
 {
-    BOOL    fMouse;
-    HWND    hWndActive;
-} CBTACTIVATESTRUCT;
+    CREATESTRUCT16  *lpcs;
+    HWND16           hwndInsertAfter;
+} CBT_CREATEWND16, *LPCBT_CREATEWND16;
+
+typedef struct
+{
+    CREATESTRUCT32A *lpcs;
+    HWND32           hwndInsertAfter;
+} CBT_CREATEWND32A, *LPCBT_CREATEWND32A;
+
+typedef struct
+{
+    CREATESTRUCT32W *lpcs;
+    HWND32           hwndInsertAfter;
+} CBT_CREATEWND32W, *LPCBT_CREATEWND32W;
+
+DECL_WINELIB_TYPE_AW(CBT_CREATEWND);
+DECL_WINELIB_TYPE_AW(LPCBT_CREATEWND);
+
+typedef struct
+{
+    BOOL16    fMouse;
+    HWND16    hWndActive;
+} CBTACTIVATESTRUCT16;
+
+typedef struct
+{
+    BOOL32    fMouse;
+    HWND32    hWndActive;
+} CBTACTIVATESTRUCT32;
+
+DECL_WINELIB_TYPE(CBTACTIVATESTRUCT);
 
   /* Shell hook values */
 #define HSHELL_WINDOWCREATED       1
@@ -486,15 +596,27 @@
 #define HSHELL_ACTIVATESHELLWINDOW 3
 
   /* Debug hook structure */
-typedef struct tagDEBUGHOOKINFO
+
+typedef struct
 {
-    HANDLE	hModuleHook;
+    HMODULE16   hModuleHook;
     LPARAM	reserved WINE_PACKED;
     LPARAM	lParam WINE_PACKED;
-    WPARAM	wParam;
-    short       code;
-} DEBUGHOOKINFO, *LPDEBUGHOOKINFO;
+    WPARAM16    wParam;
+    INT16       code;
+} DEBUGHOOKINFO16, *LPDEBUGHOOKINFO16;
 
+typedef struct
+{
+    DWORD       idThread;
+    DWORD       idThreadInstaller;
+    LPARAM      lParam;
+    WPARAM32    wParam;
+    INT32       code;
+} DEBUGHOOKINFO32, *LPDEBUGHOOKINFO32;
+
+DECL_WINELIB_TYPE(DEBUGHOOKINFO);
+DECL_WINELIB_TYPE(LPDEBUGHOOKINFO);
 
 /***** Dialogs *****/
 
@@ -538,15 +660,28 @@
 #define IDNO                7
 
 
-typedef struct tagMSG
+typedef struct
 {
-  HWND16    hwnd;
-  UINT16    message;
-  WPARAM16  wParam;
-  LPARAM    lParam WINE_PACKED;
-  DWORD     time WINE_PACKED;
-  POINT16   pt WINE_PACKED;
-} MSG, *LPMSG;
+    HWND16    hwnd;
+    UINT16    message;
+    WPARAM16  wParam;
+    LPARAM    lParam WINE_PACKED;
+    DWORD     time WINE_PACKED;
+    POINT16   pt WINE_PACKED;
+} MSG16, *LPMSG16;
+
+typedef struct
+{
+    HWND32    hwnd;
+    UINT32    message;
+    WPARAM32  wParam;
+    LPARAM    lParam;
+    DWORD     time;
+    POINT32   pt;
+} MSG32, *LPMSG32;
+
+DECL_WINELIB_TYPE(MSG);
+DECL_WINELIB_TYPE(LPMSG);
 	
   /* Raster operations */
 
@@ -638,29 +773,49 @@
 
   /* Bitmaps */
 
-typedef struct tagBITMAP
+typedef struct
 {
-    INT  bmType;
-    INT  bmWidth;
-    INT  bmHeight;
-    INT  bmWidthBytes;
+    INT16  bmType;
+    INT16  bmWidth;
+    INT16  bmHeight;
+    INT16  bmWidthBytes;
     BYTE   bmPlanes;
     BYTE   bmBitsPixel;
     SEGPTR bmBits WINE_PACKED;
-} BITMAP;
+} BITMAP16, *LPBITMAP16;
 
-typedef BITMAP *PBITMAP;
-typedef BITMAP *NPBITMAP;
-typedef BITMAP *LPBITMAP;
+typedef struct
+{
+    INT32  bmType;
+    INT32  bmWidth;
+    INT32  bmHeight;
+    INT32  bmWidthBytes;
+    WORD   bmPlanes;
+    WORD   bmBitsPixel;
+    LPVOID bmBits WINE_PACKED;
+} BITMAP32, *LPBITMAP32;
+
+DECL_WINELIB_TYPE(BITMAP);
+DECL_WINELIB_TYPE(LPBITMAP);
 
   /* Brushes */
 
-typedef struct tagLOGBRUSH
+typedef struct
 { 
-    WORD       lbStyle; 
+    UINT16     lbStyle; 
     COLORREF   lbColor WINE_PACKED;
-    INT        lbHatch; 
-} LOGBRUSH, *PLOGBRUSH, *NPLOGBRUSH, *LPLOGBRUSH;
+    INT16      lbHatch; 
+} LOGBRUSH16, *LPLOGBRUSH16;
+
+typedef struct
+{ 
+    UINT32     lbStyle; 
+    COLORREF   lbColor;
+    INT32      lbHatch; 
+} LOGBRUSH32, *LPLOGBRUSH32;
+
+DECL_WINELIB_TYPE(LOGBRUSH);
+DECL_WINELIB_TYPE(LPLOGBRUSH);
 
   /* Brush styles */
 #define BS_SOLID	    0
@@ -684,20 +839,86 @@
 #define LF_FACESIZE     32
 #define LF_FULLFACESIZE 64
 
-typedef struct tagLOGFONT
+typedef struct
 {
-    INT lfHeight, lfWidth, lfEscapement, lfOrientation, lfWeight;
-    BYTE lfItalic, lfUnderline, lfStrikeOut, lfCharSet;
-    BYTE lfOutPrecision, lfClipPrecision, lfQuality, lfPitchAndFamily;
-    BYTE lfFaceName[LF_FACESIZE] WINE_PACKED;
-} LOGFONT, *PLOGFONT, *NPLOGFONT, *LPLOGFONT;
+    INT16  lfHeight;
+    INT16  lfWidth;
+    INT16  lfEscapement;
+    INT16  lfOrientation;
+    INT16  lfWeight;
+    BYTE   lfItalic;
+    BYTE   lfUnderline;
+    BYTE   lfStrikeOut;
+    BYTE   lfCharSet;
+    BYTE   lfOutPrecision;
+    BYTE   lfClipPrecision;
+    BYTE   lfQuality;
+    BYTE   lfPitchAndFamily;
+    CHAR   lfFaceName[LF_FACESIZE] WINE_PACKED;
+} LOGFONT16, *LPLOGFONT16;
 
-typedef struct tagENUMLOGFONT
+typedef struct
 {
-  LOGFONT elfLogFont;
-  BYTE elfFullName[LF_FULLFACESIZE] WINE_PACKED;
-  BYTE elfStyle[LF_FACESIZE] WINE_PACKED;
-} ENUMLOGFONT,*PENUMLOGFONT,*NPENUMLOGFONT,*LPENUMLOGFONT;
+    INT32  lfHeight;
+    INT32  lfWidth;
+    INT32  lfEscapement;
+    INT32  lfOrientation;
+    INT32  lfWeight;
+    BYTE   lfItalic;
+    BYTE   lfUnderline;
+    BYTE   lfStrikeOut;
+    BYTE   lfCharSet;
+    BYTE   lfOutPrecision;
+    BYTE   lfClipPrecision;
+    BYTE   lfQuality;
+    BYTE   lfPitchAndFamily;
+    CHAR   lfFaceName[LF_FACESIZE];
+} LOGFONT32A, *LPLOGFONT32A;
+
+typedef struct
+{
+    INT32  lfHeight;
+    INT32  lfWidth;
+    INT32  lfEscapement;
+    INT32  lfOrientation;
+    INT32  lfWeight;
+    BYTE   lfItalic;
+    BYTE   lfUnderline;
+    BYTE   lfStrikeOut;
+    BYTE   lfCharSet;
+    BYTE   lfOutPrecision;
+    BYTE   lfClipPrecision;
+    BYTE   lfQuality;
+    BYTE   lfPitchAndFamily;
+    WCHAR  lfFaceName[LF_FACESIZE];
+} LOGFONT32W, *LPLOGFONT32W;
+
+DECL_WINELIB_TYPE_AW(LOGFONT);
+DECL_WINELIB_TYPE_AW(LPLOGFONT);
+
+typedef struct
+{
+  LOGFONT16  elfLogFont;
+  BYTE       elfFullName[LF_FULLFACESIZE] WINE_PACKED;
+  BYTE       elfStyle[LF_FACESIZE] WINE_PACKED;
+} ENUMLOGFONT16, *LPENUMLOGFONT16;
+
+typedef struct
+{
+  LOGFONT32A elfLogFont;
+  BYTE       elfFullName[LF_FULLFACESIZE] WINE_PACKED;
+  BYTE       elfStyle[LF_FACESIZE] WINE_PACKED;
+} ENUMLOGFONT32A, *LPENUMLOGFONT32A;
+
+typedef struct
+{
+  LOGFONT32W elfLogFont;
+  WCHAR      elfFullName[LF_FULLFACESIZE] WINE_PACKED;
+  WCHAR      elfStyle[LF_FACESIZE] WINE_PACKED;
+} ENUMLOGFONT32W, *LPENUMLOGFONT32W;
+
+DECL_WINELIB_TYPE_AW(ENUMLOGFONT);
+DECL_WINELIB_TYPE_AW(LPENUMLOGFONT);
 
   /* lfWeight values */
 #define FW_DONTCARE	    0
@@ -758,29 +979,80 @@
 #define FF_SCRIPT           0x40
 #define FF_DECORATIVE       0x50
 
-typedef struct tagTEXTMETRIC
+typedef struct
 {
-    INT     tmHeight;
-    INT     tmAscent;
-    INT     tmDescent;
-    INT     tmInternalLeading;
-    INT     tmExternalLeading;
-    INT     tmAveCharWidth;
-    INT     tmMaxCharWidth;
-    INT     tmWeight;
-    BYTE    tmItalic;
-    BYTE    tmUnderlined;
-    BYTE    tmStruckOut;
-    BYTE    tmFirstChar;
-    BYTE    tmLastChar;
-    BYTE    tmDefaultChar;
-    BYTE    tmBreakChar;
-    BYTE    tmPitchAndFamily;
-    BYTE    tmCharSet;
-    INT     tmOverhang WINE_PACKED;
-    INT     tmDigitizedAspectX WINE_PACKED;
-    INT     tmDigitizedAspectY WINE_PACKED;
-} TEXTMETRIC, *PTEXTMETRIC, *NPTEXTMETRIC, *LPTEXTMETRIC;
+    INT16     tmHeight;
+    INT16     tmAscent;
+    INT16     tmDescent;
+    INT16     tmInternalLeading;
+    INT16     tmExternalLeading;
+    INT16     tmAveCharWidth;
+    INT16     tmMaxCharWidth;
+    INT16     tmWeight;
+    BYTE      tmItalic;
+    BYTE      tmUnderlined;
+    BYTE      tmStruckOut;
+    BYTE      tmFirstChar;
+    BYTE      tmLastChar;
+    BYTE      tmDefaultChar;
+    BYTE      tmBreakChar;
+    BYTE      tmPitchAndFamily;
+    BYTE      tmCharSet;
+    INT16     tmOverhang WINE_PACKED;
+    INT16     tmDigitizedAspectX WINE_PACKED;
+    INT16     tmDigitizedAspectY WINE_PACKED;
+} TEXTMETRIC16, *LPTEXTMETRIC16;
+
+typedef struct
+{
+    INT32     tmHeight;
+    INT32     tmAscent;
+    INT32     tmDescent;
+    INT32     tmInternalLeading;
+    INT32     tmExternalLeading;
+    INT32     tmAveCharWidth;
+    INT32     tmMaxCharWidth;
+    INT32     tmWeight;
+    INT32     tmOverhang;
+    INT32     tmDigitizedAspectX;
+    INT32     tmDigitizedAspectY;
+    BYTE      tmFirstChar;
+    BYTE      tmLastChar;
+    BYTE      tmDefaultChar;
+    BYTE      tmBreakChar;
+    BYTE      tmItalic;
+    BYTE      tmUnderlined;
+    BYTE      tmStruckOut;
+    BYTE      tmPitchAndFamily;
+    BYTE      tmCharSet;
+} TEXTMETRIC32A, *LPTEXTMETRIC32A;
+
+typedef struct
+{
+    INT32     tmHeight;
+    INT32     tmAscent;
+    INT32     tmDescent;
+    INT32     tmInternalLeading;
+    INT32     tmExternalLeading;
+    INT32     tmAveCharWidth;
+    INT32     tmMaxCharWidth;
+    INT32     tmWeight;
+    INT32     tmOverhang;
+    INT32     tmDigitizedAspectX;
+    INT32     tmDigitizedAspectY;
+    WCHAR     tmFirstChar;
+    WCHAR     tmLastChar;
+    WCHAR     tmDefaultChar;
+    WCHAR     tmBreakChar;
+    BYTE      tmItalic;
+    BYTE      tmUnderlined;
+    BYTE      tmStruckOut;
+    BYTE      tmPitchAndFamily;
+    BYTE      tmCharSet;
+} TEXTMETRIC32W, *LPTEXTMETRIC32W;
+
+DECL_WINELIB_TYPE_AW(TEXTMETRIC);
+DECL_WINELIB_TYPE_AW(LPTEXTMETRIC);
 
   /* tmPitchAndFamily values */
 #define TMPF_FIXED_PITCH    1
@@ -804,12 +1076,22 @@
 #define ETO_CLIPPED         0x04
 
   /* for GetCharABCWidths() */
-typedef struct tagABC
+typedef struct
 {
-    INT   abcA;
-    UINT  abcB;
-    INT   abcC;
-} ABC, *LPABC;
+    INT16   abcA;
+    UINT16  abcB;
+    INT16   abcC;
+} ABC16, *LPABC16;
+
+typedef struct
+{
+    INT32   abcA;
+    UINT32  abcB;
+    INT32   abcC;
+} ABC32, *LPABC32;
+
+DECL_WINELIB_TYPE(ABC);
+DECL_WINELIB_TYPE(LPABC);
 
   /* Rasterizer status */
 typedef struct
@@ -831,22 +1113,31 @@
 	BYTE peRed, peGreen, peBlue, peFlags;
 } PALETTEENTRY, *LPPALETTEENTRY;
 
-typedef struct tagLOGPALETTE
+typedef struct
 { 
     WORD           palVersion;
     WORD           palNumEntries;
     PALETTEENTRY   palPalEntry[1] WINE_PACKED;
-} LOGPALETTE, *PLOGPALETTE, *NPLOGPALETTE, *LPLOGPALETTE;
-
+} LOGPALETTE, *LPLOGPALETTE;
 
   /* Pens */
 
-typedef struct tagLOGPEN
+typedef struct
 {
-    WORD     lopnStyle; 
+    UINT16   lopnStyle; 
     POINT16  lopnWidth WINE_PACKED;
     COLORREF lopnColor WINE_PACKED;
-} LOGPEN, *PLOGPEN, *NPLOGPEN, *LPLOGPEN;
+} LOGPEN16, *LPLOGPEN16;
+
+typedef struct
+{
+    UINT32   lopnStyle; 
+    POINT32  lopnWidth WINE_PACKED;
+    COLORREF lopnColor WINE_PACKED;
+} LOGPEN32, *LPLOGPEN32;
+
+DECL_WINELIB_TYPE(LOGPEN);
+DECL_WINELIB_TYPE(LPLOGPEN);
 
 #define PS_SOLID	  0
 #define PS_DASH           1
@@ -1079,14 +1370,14 @@
 
 typedef struct
 {
-    UINT    bfType;
+    UINT16  bfType;
     DWORD   bfSize WINE_PACKED;
-    UINT    bfReserved1 WINE_PACKED;
-    UINT    bfReserved2 WINE_PACKED;
+    UINT16  bfReserved1 WINE_PACKED;
+    UINT16  bfReserved2 WINE_PACKED;
     DWORD   bfOffBits WINE_PACKED;
 } BITMAPFILEHEADER;
 
-typedef struct tagBITMAPINFOHEADER
+typedef struct
 {
     DWORD 	biSize;
     DWORD 	biWidth;
@@ -1099,11 +1390,7 @@
     DWORD 	biYPelsPerMeter;
     DWORD 	biClrUsed;
     DWORD 	biClrImportant;
-} BITMAPINFOHEADER;
-
-typedef BITMAPINFOHEADER * LPBITMAPINFOHEADER;
-typedef BITMAPINFOHEADER * NPBITMAPINFOHEADER;
-typedef BITMAPINFOHEADER * PBITMAPINFOHEADER;
+} BITMAPINFOHEADER, *LPBITMAPINFOHEADER;
 
   /* biCompression */
 #define BI_RGB           0
@@ -1120,11 +1407,11 @@
 
 typedef struct
 {
-    DWORD bcSize;
-    UINT bcWidth;
-    UINT bcHeight;
-    UINT bcPlanes;
-    UINT bcBitCount;
+    DWORD   bcSize;
+    UINT16  bcWidth;
+    UINT16  bcHeight;
+    UINT16  bcPlanes;
+    UINT16  bcBitCount;
 } BITMAPCOREHEADER;
 
 typedef struct
@@ -1211,16 +1498,17 @@
 
 /* The security attributes structure 
  */
-typedef struct {
-    DWORD nLength;
-    void *lpSecurityDescriptor;
-    BOOL bInheritHandle;
+typedef struct
+{
+    DWORD   nLength;
+    LPVOID  lpSecurityDescriptor;
+    BOOL32  bInheritHandle;
 } SECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES;
 
 typedef struct
 {
-  int dwLowDateTime;
-  int dwHighDateTime;
+  INT32  dwLowDateTime;
+  INT32  dwHighDateTime;
 } FILETIME;
 
 /* comm */
@@ -1311,47 +1599,47 @@
 
 typedef struct tagDCB
 {
-    BYTE Id;
-    UINT BaudRate WINE_PACKED;
-    BYTE ByteSize;
-    BYTE Parity;
-    BYTE StopBits;
-    UINT RlsTimeout;
-    UINT CtsTimeout;
-    UINT DsrTimeout;
+    BYTE   Id;
+    UINT16 BaudRate WINE_PACKED;
+    BYTE   ByteSize;
+    BYTE   Parity;
+    BYTE   StopBits;
+    UINT16 RlsTimeout;
+    UINT16 CtsTimeout;
+    UINT16 DsrTimeout;
 
-    UINT fBinary        :1;
-    UINT fRtsDisable    :1;
-    UINT fParity        :1;
-    UINT fOutxCtsFlow   :1;
-    UINT fOutxDsrFlow   :1;
-    UINT fDummy         :2;
-    UINT fDtrDisable    :1;
+    UINT16 fBinary        :1;
+    UINT16 fRtsDisable    :1;
+    UINT16 fParity        :1;
+    UINT16 fOutxCtsFlow   :1;
+    UINT16 fOutxDsrFlow   :1;
+    UINT16 fDummy         :2;
+    UINT16 fDtrDisable    :1;
 
-    UINT fOutX          :1;
-    UINT fInX           :1;
-    UINT fPeChar        :1;
-    UINT fNull          :1;
-    UINT fChEvt         :1;
-    UINT fDtrflow       :1;
-    UINT fRtsflow       :1;
-    UINT fDummy2        :1;
+    UINT16 fOutX          :1;
+    UINT16 fInX           :1;
+    UINT16 fPeChar        :1;
+    UINT16 fNull          :1;
+    UINT16 fChEvt         :1;
+    UINT16 fDtrflow       :1;
+    UINT16 fRtsflow       :1;
+    UINT16 fDummy2        :1;
 
-    char XonChar;
-    char XoffChar;
-    UINT XonLim;
-    UINT XoffLim;
-    char PeChar;
-    char EofChar;
-    char EvtChar;
-    UINT TxDelay WINE_PACKED;
+    CHAR   XonChar;
+    CHAR   XoffChar;
+    UINT16 XonLim;
+    UINT16 XoffLim;
+    CHAR   PeChar;
+    CHAR   EofChar;
+    CHAR   EvtChar;
+    UINT16 TxDelay WINE_PACKED;
 } DCB, *LPDCB;
 
 typedef struct tagCOMSTAT
 {
-    BYTE status;
-    UINT cbInQue WINE_PACKED;
-    UINT cbOutQue WINE_PACKED;
+    BYTE   status;
+    UINT16 cbInQue WINE_PACKED;
+    UINT16 cbOutQue WINE_PACKED;
 } COMSTAT;
 
 #define CSTF_CTSHOLD	0x01
@@ -1555,14 +1843,15 @@
 
 /* DragObject stuff */
 
-typedef struct tagDRAGINFO {
-	HWND 	hWnd;
-	HANDLE	hScope;
-	WORD	wFlags;
-	HANDLE  hList;
-	HANDLE  hOfStruct;
-	POINT16 pt WINE_PACKED;
-	LONG	l  WINE_PACKED;
+typedef struct
+{
+    HWND16     hWnd;
+    HANDLE16   hScope;
+    WORD       wFlags;
+    HANDLE16   hList;
+    HANDLE16   hOfStruct;
+    POINT16 pt WINE_PACKED;
+    LONG       l WINE_PACKED;
 } DRAGINFO, *LPDRAGINFO;
 
 #define DRAGOBJ_PROGRAM		0x0001
@@ -2357,33 +2646,74 @@
 
 typedef struct
 {
-    UINT        CtlType;
-    UINT        CtlID;
-    UINT        itemID;
-    UINT        itemWidth;
-    UINT        itemHeight;
+    UINT16      CtlType;
+    UINT16      CtlID;
+    UINT16      itemID;
+    UINT16      itemWidth;
+    UINT16      itemHeight;
     DWORD       itemData WINE_PACKED;
-} MEASUREITEMSTRUCT, *PMEASUREITEMSTRUCT, *LPMEASUREITEMSTRUCT;
+} MEASUREITEMSTRUCT16, *PMEASUREITEMSTRUCT16, *LPMEASUREITEMSTRUCT16;
 
 typedef struct
 {
-    UINT       CtlType;
-    UINT       CtlID;
-    UINT       itemID;
-    HWND       hwndItem;
+    UINT32      CtlType;
+    UINT32      CtlID;
+    UINT32      itemID;
+    UINT32      itemWidth;
+    UINT32      itemHeight;
+    DWORD       itemData;
+} MEASUREITEMSTRUCT32, *PMEASUREITEMSTRUCT32, *LPMEASUREITEMSTRUCT32;
+
+DECL_WINELIB_TYPE(MEASUREITEMSTRUCT);
+DECL_WINELIB_TYPE(PMEASUREITEMSTRUCT);
+DECL_WINELIB_TYPE(LPMEASUREITEMSTRUCT);
+
+typedef struct
+{
+    UINT16     CtlType;
+    UINT16     CtlID;
+    UINT16     itemID;
+    HWND16     hwndItem;
     DWORD      itemData;
-} DELETEITEMSTRUCT, *PDELETEITEMSTRUCT, *LPDELETEITEMSTRUCT;
+} DELETEITEMSTRUCT16, *LPDELETEITEMSTRUCT16;
 
 typedef struct
 {
-    UINT        CtlType;
-    UINT        CtlID;
-    HWND        hwndItem;
-    UINT        itemID1;
+    UINT32     CtlType;
+    UINT32     CtlID;
+    UINT32     itemID;
+    HWND32     hwndItem;
+    DWORD      itemData;
+} DELETEITEMSTRUCT32, *LPDELETEITEMSTRUCT32;
+
+DECL_WINELIB_TYPE(DELETEITEMSTRUCT);
+DECL_WINELIB_TYPE(LPDELETEITEMSTRUCT);
+
+typedef struct
+{
+    UINT16      CtlType;
+    UINT16      CtlID;
+    HWND16      hwndItem;
+    UINT16      itemID1;
     DWORD       itemData1;
-    UINT        itemID2;
+    UINT16      itemID2;
     DWORD       itemData2 WINE_PACKED;
-} COMPAREITEMSTRUCT, *PCOMPAREITEMSTRUCT, *LPCOMPAREITEMSTRUCT;
+} COMPAREITEMSTRUCT16, *LPCOMPAREITEMSTRUCT16;
+
+typedef struct
+{
+    UINT32      CtlType;
+    UINT32      CtlID;
+    HWND32      hwndItem;
+    UINT32      itemID1;
+    DWORD       itemData1;
+    UINT32      itemID2;
+    DWORD       itemData2;
+    DWORD       dwLocaleId;
+} COMPAREITEMSTRUCT32, *LPCOMPAREITEMSTRUCT32;
+
+DECL_WINELIB_TYPE(COMPAREITEMSTRUCT);
+DECL_WINELIB_TYPE(LPCOMPAREITEMSTRUCT);
 
 /* WM_KEYUP/DOWN/CHAR HIWORD(lParam) flags */
 #define KF_EXTENDED         0x0100
@@ -2571,7 +2901,7 @@
 /* Handle table structure */
 typedef struct
 {
-    HANDLE     objectHandle[1];
+    HANDLE16   objectHandle[1];
 } HANDLETABLE;
 typedef HANDLETABLE *PHANDLETABLE;
 typedef HANDLETABLE *LPHANDLETABLE;
@@ -2579,12 +2909,11 @@
 /* Clipboard metafile picture structure */
 typedef struct
 {
-    INT        mm;
-    INT        xExt;
-    INT        yExt;
-    HMETAFILE  hMF;
-} METAFILEPICT;
-typedef METAFILEPICT *LPMETAFILEPICT;
+    INT16        mm;
+    INT16        xExt;
+    INT16        yExt;
+    HMETAFILE16  hMF;
+} METAFILEPICT, *LPMETAFILEPICT;
 
 /* Metafile functions */
 #define META_SETBKCOLOR              0x0201
@@ -2669,10 +2998,10 @@
 /* Debugging support (DEBUG SYSTEM ONLY) */
 typedef struct
 {
-    UINT    flags;
+    UINT16  flags;
     DWORD   dwOptions WINE_PACKED;
     DWORD   dwFilter WINE_PACKED;
-    char    achAllocModule[8] WINE_PACKED;
+    CHAR    achAllocModule[8] WINE_PACKED;
     DWORD   dwAllocBreak WINE_PACKED;
     DWORD   dwAllocCount WINE_PACKED;
 } WINDEBUGINFO, *LPWINDEBUGINFO;
@@ -2737,10 +3066,11 @@
 	WORD ofsData;
 } WINHELP,*LPWINHELP;
 
-typedef struct {
-	UINT mkSize;
-	BYTE mkKeyList;
-	BYTE szKeyPhrase[1];
+typedef struct
+{
+    UINT16  mkSize;
+    BYTE    mkKeyList;
+    BYTE    szKeyPhrase[1];
 } MULTIKEYHELP, *LPMULTIKEYHELP;
 
 typedef struct {
@@ -2799,7 +3129,7 @@
 
 typedef struct _SYSTEM_POWER_STATUS
 {
-  BOOL    ACLineStatus;
+  BOOL16  ACLineStatus;
   BYTE    BatteryFlag;
   BYTE    BatteryLifePercent;
   BYTE    reserved;
@@ -2812,596 +3142,42 @@
 #pragma pack(4)
 #endif
 
+/* Declarations for functions that exist only in Win16 */
 
-INT        AccessResource(HINSTANCE,HRSRC);
-ATOM       AddAtom(SEGPTR);
-INT        AddFontResource(LPCSTR);
-WORD       AllocCStoDSAlias(WORD);
-WORD       AllocDStoCSAlias(WORD);
-HGLOBAL    AllocResource(HINSTANCE,HRSRC,DWORD);
-WORD       AllocSelector(WORD);
-WORD       AllocSelectorArray(WORD);
-BOOL       AnimatePalette(HPALETTE16,UINT,UINT,LPPALETTEENTRY);
-LPSTR      AnsiLower(LPSTR);
-UINT       AnsiLowerBuff(LPSTR,UINT);
-SEGPTR     AnsiNext(SEGPTR);
-SEGPTR     AnsiPrev(SEGPTR,SEGPTR);
-INT        AnsiToOem(LPSTR,LPSTR);
-void       AnsiToOemBuff(LPCSTR,LPSTR,UINT);
-LPSTR      AnsiUpper(LPSTR);
-UINT       AnsiUpperBuff(LPSTR,UINT);
-BOOL       AnyPopup(void);
-BOOL       Arc(HDC,INT,INT,INT,INT,INT,INT,INT,INT);
-UINT       ArrangeIconicWindows(HWND);
-HDWP16     BeginDeferWindowPos(INT);
-BOOL       BitBlt(HDC,INT,INT,INT,INT,HDC,INT,INT,DWORD);
-BOOL       BringWindowToTop(HWND);
-BOOL       BuildCommDCB(LPCSTR,DCB*);
-void       CalcChildScroll(HWND,WORD);
-BOOL       CallMsgFilter(SEGPTR,INT);
-LRESULT    CallNextHookEx(HHOOK,INT,WPARAM,LPARAM);
-INT        Catch(LPCATCHBUF);
-BOOL       ChangeClipboardChain(HWND,HWND);
-WORD       ChangeSelector(WORD,WORD);
-BOOL       CheckDlgButton(HWND,INT,UINT);
-INT        CheckMenuItem(HMENU,UINT,UINT);
-BOOL       CheckRadioButton(HWND,UINT,UINT,UINT);
-BOOL       Chord(HDC,INT,INT,INT,INT,INT,INT,INT,INT);
-int        ClearCommBreak(int);
-BOOL       CloseClipboard(void);
-int        CloseComm(int);
-HMETAFILE  CloseMetaFile(HDC);
-void       CloseSound(void);
-BOOL       CloseWindow(HWND);
-INT16      CombineRgn(HRGN32,HRGN32,HRGN32,INT32);
-int        ConvertRequest(HWND,LPKANJISTRUCT);
-#ifdef WINELIB32
-HCURSOR    CopyCursor(HCURSOR); /* Win32 */
-HICON      CopyIcon(HICON); /* Win32 */
-#else
-HCURSOR    CopyCursor(HINSTANCE,HCURSOR); /* Win16 */
-HICON      CopyIcon(HINSTANCE,HICON); /* Win16 */
-#endif
-HMETAFILE  CopyMetaFile(HMETAFILE,LPCSTR);
-INT        CountClipboardFormats(void);
-INT        CountVoiceNotes(INT);
-HBITMAP    CreateBitmap(INT,INT,UINT,UINT,LPVOID);
-HBITMAP    CreateBitmapIndirect(const BITMAP*);
-HBRUSH     CreateBrushIndirect(const LOGBRUSH*);
-BOOL       CreateCaret(HWND,HBITMAP,INT,INT);
-HBITMAP    CreateCompatibleBitmap(HDC,INT,INT);
-HDC        CreateCompatibleDC(HDC);
-HCURSOR    CreateCursor(HANDLE,INT,INT,INT,INT,const BYTE*,const BYTE*);
-HANDLE     CreateCursorIconIndirect(HANDLE,CURSORICONINFO*,const BYTE*,const BYTE*);
-HDC        CreateDC(LPCSTR,LPCSTR,LPCSTR,const DEVMODE*);
-HBRUSH     CreateDIBPatternBrush(HGLOBAL,UINT);
-HBITMAP    CreateDIBitmap(HDC,BITMAPINFOHEADER*,DWORD,LPVOID,BITMAPINFO*,UINT);
-HBITMAP    CreateDiscardableBitmap(HDC,INT,INT);
-HRGN       CreateEllipticRgn(INT32,INT32,INT32,INT32);
-HFONT      CreateFont(INT,INT,INT,INT,INT,BYTE,BYTE,BYTE,BYTE,BYTE,BYTE,BYTE,BYTE,LPCSTR);
-HFONT      CreateFontIndirect(const LOGFONT*);
-HBRUSH     CreateHatchBrush(INT,COLORREF);
-HDC        CreateIC(LPCSTR,LPCSTR,LPCSTR,const DEVMODE*);
-HICON      CreateIcon(HINSTANCE,INT,INT,BYTE,BYTE,const BYTE*,const BYTE*);
-HMENU      CreateMenu(void);
-HDC        CreateMetaFile(LPCSTR);
-HPALETTE16 CreatePalette(const LOGPALETTE*);
-HBRUSH     CreatePatternBrush(HBITMAP);
-HPEN16     CreatePen(INT,INT,COLORREF);
-HPEN16     CreatePenIndirect(const LOGPEN*);
-HMENU      CreatePopupMenu(void);
-HRGN       CreateRectRgn(INT32,INT32,INT32,INT32);
-HRGN       CreateRoundRectRgn(INT32,INT32,INT32,INT32,INT32,INT32);
-HBRUSH     CreateSolidBrush(COLORREF);
-void       DebugBreak(void);
-DWORD      DefHookProc(short,WORD,DWORD,HHOOK*);
-HDWP16     DeferWindowPos(HDWP16,HWND,HWND,INT,INT,INT,INT,UINT);
-ATOM       DeleteAtom(ATOM);
-BOOL       DeleteDC(HDC);
-BOOL       DeleteMenu(HMENU,UINT,UINT);
-BOOL       DeleteMetaFile(HMETAFILE);
-BOOL       DeleteObject(HGDIOBJ16);
-BOOL       DestroyCaret(void);
-BOOL       DestroyCursor(HCURSOR);
-BOOL       DestroyIcon(HICON);
-BOOL       DestroyMenu(HMENU);
-BOOL       DestroyWindow(HWND);
-HANDLE     DirectResAlloc(HANDLE,WORD,WORD);
-void       DirectedYield(HTASK);
-LONG       DispatchMessage(const MSG*);
-INT        DlgDirList(HWND,SEGPTR,INT,INT,UINT);
-BOOL       DlgDirSelect(HWND,LPSTR,INT);
-BOOL       DlgDirSelectComboBox(HWND,LPSTR,INT);
-BOOL16     DragDetect(HWND16,POINT16);
-DWORD      DragObject(HWND, HWND, WORD, HANDLE, WORD, HCURSOR);
-BOOL       DrawIcon(HDC,INT,INT,HICON);
-void       DrawMenuBar(HWND);
-DWORD      DumpIcon(SEGPTR,WORD*,SEGPTR*,SEGPTR*);
-BOOL       Ellipse(HDC,INT,INT,INT,INT);
-BOOL       EmptyClipboard(void);
-BOOL       EnableHardwareInput(BOOL);
-BOOL       EnableMenuItem(HMENU,UINT,UINT);
-BOOL       EnableScrollBar(HWND,UINT,UINT);
-BOOL       EnableWindow(HWND,BOOL);
-BOOL       EndDeferWindowPos(HDWP16);
-BOOL       EnumChildWindows(HWND,WNDENUMPROC,LPARAM);
-UINT       EnumClipboardFormats(UINT);
-INT        EnumFontFamilies(HDC,LPCSTR,FONTENUMPROC,LPARAM);
-INT        EnumFonts(HDC,LPCSTR,FONTENUMPROC,LPARAM);
-BOOL       EnumMetaFile(HDC,HMETAFILE,MFENUMPROC,LPARAM);
-INT        EnumObjects(HDC,INT,GOBJENUMPROC,LPARAM);
-INT        EnumProps(HWND,PROPENUMPROC);
-BOOL       EnumTaskWindows(HTASK,WNDENUMPROC,LPARAM);
-BOOL       EnumWindows(WNDENUMPROC,LPARAM);
-BOOL       EqualRgn(HRGN32,HRGN32);
-INT        Escape(HDC,INT,INT,LPCSTR,LPVOID);
-LONG       EscapeCommFunction(int,int);
-int        ExcludeClipRect(HDC,short,short,short,short);
-int        ExcludeVisRect(HDC,short,short,short,short);
-BOOL       ExitWindows(DWORD,WORD);
-BOOL       ExtFloodFill(HDC,INT,INT,COLORREF,WORD);
-HICON      ExtractIcon(HINSTANCE,LPCSTR,WORD);
-WORD       FarGetOwner(HANDLE);
-void       FarSetOwner(HANDLE,HANDLE);
-void       FatalAppExit(UINT,LPCSTR);
-void       FatalExit(int);
-BOOL       FillRgn(HDC,HRGN,HBRUSH);
-ATOM       FindAtom(SEGPTR);
-HINSTANCE  FindExecutable(LPCSTR,LPCSTR,LPSTR);
-HRSRC      FindResource(HINSTANCE,SEGPTR,SEGPTR);
-BOOL       FlashWindow(HWND,BOOL);
-BOOL       FloodFill(HDC,INT,INT,COLORREF);
-int        FlushComm(int,int);
-BOOL       FrameRgn(HDC,HRGN,HBRUSH,int,int);
-void       FreeLibrary(HANDLE);
-BOOL       FreeModule(HANDLE);
-void       FreeProcInstance(FARPROC);
-BOOL       FreeResource(HGLOBAL);
-WORD       FreeSelector(WORD);
-UINT       GDIRealizePalette(HDC);
-HPALETTE16 GDISelectPalette(HDC,HPALETTE16);
-HWND       GetActiveWindow(void);
-DWORD      GetAspectRatioFilter(HDC);
-int        GetAsyncKeyState(int);
-HANDLE     GetAtomHandle(ATOM);
-WORD       GetAtomName(ATOM,LPSTR,short);
-LONG       GetBitmapBits(HBITMAP,LONG,LPSTR);
-COLORREF   GetBkColor(HDC);
-WORD       GetBkMode(HDC);
-DWORD      GetBrushOrg(HDC);
-HWND       GetCapture(void);
-WORD       GetCaretBlinkTime(void);
-BOOL       GetCharABCWidths(HDC,UINT,UINT,LPABC);
-BOOL       GetCharWidth(HDC,WORD,WORD,LPINT16);
-HRGN       GetClipRgn(HDC);
-HANDLE     GetClipboardData(WORD);
-int        GetClipboardFormatName(WORD,LPSTR,short);
-HWND       GetClipboardOwner(void);
-HWND       GetClipboardViewer(void);
-HANDLE     GetCodeHandle(FARPROC);
-void       GetCodeInfo(FARPROC,LPVOID);
-int        GetCommError(int,COMSTAT*);
-UINT       GetCommEventMask(int,int);
-int        GetCommState(int,DCB*);
-HBRUSH     GetControlBrush(HWND,HDC,WORD);
-UINT32     GetCurrentDirectory(UINT32,LPSTR);
-HANDLE     GetCurrentPDB(void);
-DWORD      GetCurrentPosition(HDC);
-HANDLE     GetCurrentTask(void);
-DWORD      GetCurrentTime(void);
-HCURSOR    GetCursor(void);
-HDC        GetDC(HWND);
-HDC        GetDCEx(HWND,HRGN,DWORD);
-DWORD      GetDCHook(HDC,FARPROC16*);
-DWORD      GetDCOrg(HDC);
-HDC        GetDCState(HDC);
-int        GetDIBits(HDC,HANDLE,WORD,WORD,LPSTR,LPBITMAPINFO,WORD);
-SEGPTR     GetDOSEnvironment(void);
-HWND       GetDesktopHwnd(void);
-HWND       GetDesktopWindow(void);
-int        GetDeviceCaps(HDC,WORD);
-DWORD      GetDialogBaseUnits(void);
-int        GetDlgCtrlID(HWND);
-HWND       GetDlgItem(HWND,WORD);
-WORD       GetDlgItemInt(HWND,WORD,BOOL*,BOOL);
-WORD       GetDoubleClickTime(void);
-WORD       GetDriveType(INT);
-int        GetEnvironment(LPSTR,LPSTR,WORD);
-HMODULE    GetExePtr(HANDLE);
-HWND       GetFocus(void);
-DWORD      GetFreeSpace(UINT16);
-DWORD      GetHeapSpaces(HMODULE);
-BOOL       GetInputState(void);
-int        GetInstanceData(HANDLE,WORD,int);
-int        GetKBCodePage(void);
-int        GetKerningPairs(HDC,int,LPKERNINGPAIR);
-int        GetKeyNameText(LONG,LPSTR,int);
-INT        GetKeyState(INT);
-void       GetKeyboardState(BYTE*);
-int        GetKeyboardType(int);
-HWND       GetLastActivePopup(HWND);
-VOID       GetLocalTime(LPSYSTEMTIME); /* Win32 */
-WORD       GetMapMode(HDC);
-HMENU      GetMenu(HWND);
-DWORD      GetMenuCheckMarkDimensions(void);
-INT        GetMenuItemCount(HMENU);
-UINT       GetMenuItemID(HMENU,int);
-UINT       GetMenuState(HMENU,UINT,UINT);
-int        GetMenuString(HMENU,UINT,LPSTR,short,UINT);
-BOOL       GetMessage(SEGPTR,HWND,UINT,UINT);
-LONG       GetMessageExtraInfo(void);
-DWORD      GetMessagePos(void);
-LONG       GetMessageTime(void);
-HANDLE     GetMetaFile(LPSTR);
-HANDLE     GetMetaFileBits(HANDLE);
-int        GetModuleFileName(HANDLE,LPSTR,short);
-HANDLE     GetModuleHandle(LPCSTR);
-int        GetModuleUsage(HANDLE);
-FARPROC    GetMouseEventProc(void);
-DWORD      GetNearestColor(HDC,DWORD);
-WORD       GetNearestPaletteIndex(HPALETTE16,DWORD);
-HWND       GetNextDlgGroupItem(HWND,HWND,BOOL);
-HWND       GetNextDlgTabItem(HWND,HWND,BOOL);
-HWND       GetNextWindow(HWND,WORD);
-WORD       GetNumTasks(void);
-int        GetObject(HANDLE,int,LPSTR);
-HWND       GetOpenClipboardWindow(void);
-WORD       GetPaletteEntries(HPALETTE16,WORD,WORD,LPPALETTEENTRY);
-HWND       GetParent(HWND);
-DWORD      GetPixel(HDC,short,short);
-WORD       GetPolyFillMode(HDC);
-int        GetPriorityClipboardFormat(WORD*,short);
-UINT       GetPrivateProfileInt(LPCSTR,LPCSTR,INT,LPCSTR);
-INT        GetPrivateProfileString(LPCSTR,LPCSTR,LPCSTR,LPSTR,INT,LPCSTR);
-FARPROC    GetProcAddress(HANDLE,SEGPTR);
-UINT       GetProfileInt(LPCSTR,LPCSTR,INT);
-INT        GetProfileString(LPCSTR,LPCSTR,LPCSTR,LPSTR,INT);
-HANDLE     GetProp(HWND,SEGPTR);
-DWORD      GetQueueStatus(UINT);
-BOOL       GetRasterizerCaps(LPRASTERIZER_STATUS,UINT);
-WORD       GetROP2(HDC);
-WORD       GetRelAbs(HDC);
-int        GetScrollPos(HWND,int);
-void       GetScrollRange(HWND,int,LPINT16,LPINT16);
-DWORD      GetSelectorBase(WORD);
-DWORD      GetSelectorLimit(WORD);
-HANDLE     GetStockObject(int);
-WORD       GetStretchBltMode(HDC);
-HMENU      GetSubMenu(HMENU,short);
-COLORREF   GetSysColor(short);
-HWND       GetSysModalWindow(void);
-UINT       GetSystemDirectory(LPSTR,UINT);
-HMENU      GetSystemMenu(HWND,BOOL);
-int        GetSystemMetrics(WORD);
-WORD       GetSystemPaletteEntries(HDC,WORD,WORD,LPPALETTEENTRY);
-WORD       GetSystemPaletteUse(HDC);
-BOOL       GetSystemPowerStatus(LPSYSTEM_POWER_STATUS);
-VOID       GetSystemTime(LPSYSTEMTIME); /* Win32 */
-DWORD      GetTabbedTextExtent(HDC,LPSTR,int,int,LPINT16);
-HINSTANCE  GetTaskDS(void);
-HQUEUE     GetTaskQueue(HTASK);
-BYTE       GetTempDrive(BYTE);
-INT        GetTempFileName(BYTE,LPCSTR,UINT,LPSTR);
-WORD       GetTextAlign(HDC);
-short      GetTextCharacterExtra(HDC);
-COLORREF   GetTextColor(HDC);
-DWORD      GetTextExtent(HDC,LPCSTR,short);
-INT        GetTextFace(HDC,INT,LPSTR);
-BOOL       GetTextMetrics(HDC,LPTEXTMETRIC);
-LPINT16    GetThresholdEvent(void);
-int        GetThresholdStatus(void);
-DWORD      GetTickCount(void);
-HWND       GetTopWindow(HWND);
-LONG       GetVersion(void);
-DWORD      GetViewportExt(HDC);
-DWORD      GetViewportOrg(HDC);
-BOOL       GetWinDebugInfo(LPWINDEBUGINFO,UINT);
-LONG       GetWinFlags(void);
-HWND       GetWindow(HWND,WORD);
-HDC        GetWindowDC(HWND);
-DWORD      GetWindowExt(HDC);
-DWORD      GetWindowOrg(HDC);
-HANDLE     GetWindowTask(HWND);
-int        GetWindowTextLength(HWND);
-UINT       GetWindowsDirectory(LPSTR,UINT);
-DWORD      GlobalDOSAlloc(DWORD);
-WORD       GlobalDOSFree(WORD);
-ATOM       GlobalDeleteAtom(ATOM);
-void       GlobalFix(HGLOBAL16);
-void       GlobalFreeAll(HGLOBAL16);
-HGLOBAL16  GlobalLRUNewest(HGLOBAL16);
-HGLOBAL16  GlobalLRUOldest(HGLOBAL16);
-void       GlobalNotify(FARPROC);
-WORD       GlobalPageLock(HGLOBAL16);
-WORD       GlobalPageUnlock(HGLOBAL16);
-BOOL       GlobalUnWire(HGLOBAL16);
-void       GlobalUnfix(HGLOBAL16);
-SEGPTR     GlobalWire(HGLOBAL16);
-BOOL       GrayString(HDC,HBRUSH,FARPROC,LPARAM,INT,INT,INT,INT,INT);
-void       HideCaret(HWND);
-BOOL       HiliteMenuItem(HWND,HMENU,UINT,UINT);
-BOOL       InSendMessage(void);
-WORD       InitAtomTable(WORD);
-HRGN       InquireVisRgn(HDC);
-int        IntersectClipRect(HDC,short,short,short,short);
-int        IntersectVisRect(HDC,short,short,short,short);
-void       InvalidateRgn(HWND32,HRGN32,BOOL32);
-BOOL       InvertRgn(HDC,HRGN);
-BOOL       IsBadCodePtr(SEGPTR);
-BOOL       IsBadHugeReadPtr(SEGPTR,DWORD);
-BOOL       IsBadHugeWritePtr(SEGPTR,DWORD);
-BOOL       IsBadReadPtr(SEGPTR,WORD);
-BOOL       IsBadStringPtr(SEGPTR,WORD);
-BOOL       IsBadWritePtr(SEGPTR,WORD);
-BOOL       IsCharAlpha(char);
-BOOL       IsCharAlphaNumeric(char);
-BOOL       IsCharLower(char);
-BOOL       IsCharUpper(char);
-BOOL       IsChild(HWND,HWND);
-BOOL       IsClipboardFormatAvailable(WORD);
-BOOL       IsDialogMessage(HWND,LPMSG);
-WORD       IsDlgButtonChecked(HWND,WORD);
-BOOL       IsGDIObject(HANDLE);
-BOOL       IsIconic(HWND);
-BOOL       IsMenu(HMENU);
-BOOL       IsTask(HTASK);
-HTASK      IsTaskLocked(void);
-BOOL       IsWindow(HWND);
-BOOL       IsWindowEnabled(HWND);
-BOOL       IsWindowUnicode(HWND);
-BOOL       IsWindowVisible(HWND);
-BOOL       IsZoomed(HWND);
-BOOL       KillSystemTimer(HWND,WORD);
-BOOL       KillTimer(HWND,WORD);
-void       LimitEmsPages(DWORD);
-void       LineDDA(short,short,short,short,FARPROC,long);
-BOOL       LineTo(HDC,short,short);
-HANDLE     LoadAccelerators(HANDLE,SEGPTR);
-HBITMAP    LoadBitmap(HANDLE,SEGPTR);
-HCURSOR    LoadCursor(HANDLE,SEGPTR);
-HICON      LoadIcon(HANDLE,SEGPTR);
-HANDLE     LoadLibrary(LPCSTR);
-HMENU      LoadMenu(HANDLE,SEGPTR);
-HANDLE     LoadModule(LPCSTR,LPVOID);
-HGLOBAL    LoadResource(HINSTANCE,HRSRC);
-int        LoadString(HANDLE,WORD,LPSTR,int);
-BOOL       LocalInit(HANDLE,WORD,WORD);
-FARPROC    LocalNotify(FARPROC);
-LPVOID     LockResource(HGLOBAL);
-HGLOBAL    LockSegment(HGLOBAL);
-HMENU      LookupMenuHandle(HMENU,INT);
-FARPROC    MakeProcInstance(FARPROC,HANDLE);
-WORD       MapVirtualKey(WORD,WORD);
-void       MessageBeep(WORD);
-int        MessageBox(HWND,LPCSTR,LPCSTR,WORD);
-DWORD      MoveTo(HDC,short,short);
-BOOL       MoveWindow(HWND,short,short,short,short,BOOL);
-DWORD      OemKeyScan(WORD);
-BOOL       OemToAnsi(LPSTR,LPSTR);
-void       OemToAnsiBuff(LPSTR,LPSTR,INT);
-int        OffsetClipRgn(HDC,short,short);
-BOOL       OpenClipboard(HWND);
-int        OpenComm(LPCSTR,UINT,UINT);
-HFILE      OpenFile(LPCSTR,OFSTRUCT*,UINT);
-BOOL       OpenIcon(HWND);
-int        OpenSound(void);
-void       OutputDebugString(LPCSTR);
-BOOL       PaintRgn(HDC,HRGN);
-BOOL       PatBlt(HDC,short,short,short,short,DWORD);
-BOOL       PeekMessage(LPMSG,HWND,WORD,WORD,WORD);
-BOOL       Pie(HDC,INT,INT,INT,INT,INT,INT,INT,INT);
-BOOL       PlayMetaFile(HDC,HANDLE);
-void       PlayMetaFileRecord(HDC,LPHANDLETABLE,LPMETARECORD,WORD);
-BOOL       PostAppMessage(HANDLE,WORD,WORD,LONG);
-void       PostEvent(HTASK);
-BOOL       PostMessage(HWND,WORD,WORD,LONG);
-void       PostQuitMessage(INT);
-WORD       PrestoChangoSelector(WORD,WORD);
-void       ProfClear(void);
-void       ProfFinish(void);
-void       ProfFlush(void);
-int        ProfInsChk(void);
-void       ProfSampRate(int,int);
-void       ProfSetup(int,int);
-void       ProfStart(void);
-void       ProfStop(void);
-BOOL       PtInRegion(HRGN32,INT32,INT32);
-BOOL       PtVisible(HDC,short,short);
-int        ReadComm(int,LPSTR,int);
-WORD       RealizeDefaultPalette(HDC);
-UINT       RealizePalette(HDC);
-BOOL       Rectangle(HDC,INT,INT,INT,INT);
-WORD       RegisterClipboardFormat(LPCSTR);
-void       ReleaseCapture(void);
-int        ReleaseDC(HWND,HDC);
-BOOL       RemoveFontResource(LPSTR);
-BOOL       RemoveMenu(HMENU,UINT,UINT);
-HANDLE     RemoveProp(HWND,SEGPTR);
-void       ReplyMessage(LRESULT);
-HDC        ResetDC(HDC,LPVOID);
-BOOL       ResizePalette(HPALETTE16,UINT);
-BOOL       RestoreDC(HDC,short);
-int        RestoreVisRgn(HDC);
-BOOL       RoundRect(HDC,INT,INT,INT,INT,INT,INT);
-int        SaveDC(HDC);
-HRGN       SaveVisRgn(HDC);
-void       ScrollChildren(HWND,UINT,WPARAM,LPARAM);
-BOOL       ScrollDC(HDC,short,short,LPRECT16,LPRECT16,HRGN,LPRECT16);
-void       ScrollWindow(HWND,short,short,LPRECT16,LPRECT16);
-int        ScrollWindowEx(HWND,short,short,LPRECT16,LPRECT16,HRGN,LPRECT16,WORD);
-int        SelectClipRgn(HDC,HRGN);
-HANDLE     SelectObject(HDC,HANDLE);
-HPALETTE16 SelectPalette(HDC,HPALETTE16,BOOL);
-int        SelectVisRgn(HDC,HRGN);
-WORD       SelectorAccessRights(WORD,WORD,WORD);
-HWND       SetActiveWindow(HWND);
-LONG       SetBitmapBits(HBITMAP,LONG,LPSTR);
-DWORD      SetBkColor(HDC,COLORREF);
-WORD       SetBkMode(HDC,WORD);
-DWORD      SetBrushOrg(HDC,short,short);
-HWND       SetCapture(HWND);
-void       SetCaretBlinkTime(WORD);
-void       SetCaretPos(short,short);
-HANDLE     SetClipboardData(WORD,HANDLE);
-HWND       SetClipboardViewer(HWND);
-int        SetCommBreak(int);
-UINT*      SetCommEventMask(int,UINT);
-int        SetCommState(DCB*);
-void       SetConvertHook(BOOL);
-BOOL       SetConvertParams(int,int);
-BOOL32     SetCurrentDirectory(LPCSTR);
-HCURSOR    SetCursor(HCURSOR);
-void       SetCursorPos(short,short);
-BOOL       SetDCHook(HDC,FARPROC16,DWORD);
-void       SetDCState(HDC,HDC);
-int        SetDIBits(HDC,HANDLE,WORD,WORD,LPSTR,LPBITMAPINFO,WORD);
-int        SetDIBitsToDevice(HDC,short,short,WORD,WORD,WORD,WORD,WORD,WORD,LPSTR,LPBITMAPINFO,WORD);
-BOOL       SetDeskPattern(void);
-BOOL       SetDeskWallPaper(LPCSTR);
-void       SetDoubleClickTime(WORD);
-int        SetEnvironment(LPSTR,LPSTR,WORD);
-UINT       SetErrorMode(UINT);
-HWND       SetFocus(HWND);
-WORD       SetHandleCount(WORD);
-WORD       SetHookFlags(HDC,WORD);
-void       SetKeyboardState(BYTE*);
-WORD       SetMapMode(HDC,WORD);
-DWORD      SetMapperFlags(HDC,DWORD);
-BOOL       SetMenu(HWND,HMENU);
-BOOL       SetMenuItemBitmaps(HMENU,UINT,UINT,HBITMAP,HBITMAP);
-BOOL       SetMessageQueue(int);
-HANDLE     SetMetaFileBits(HANDLE);
-WORD       SetPaletteEntries(HPALETTE16,WORD,WORD,LPPALETTEENTRY);
-HWND       SetParent(HWND,HWND);
-COLORREF   SetPixel(HDC,short,short,COLORREF);
-WORD       SetPolyFillMode(HDC,WORD);
-BOOL       SetProp(HWND,SEGPTR,HANDLE);
-WORD       SetROP2(HDC,WORD);
-void       SetRectRgn(HRGN32,INT32,INT32,INT32,INT32);
-WORD       SetRelAbs(HDC,WORD);
-FARPROC    SetResourceHandler(HANDLE,LPSTR,FARPROC);
-int        SetScrollPos(HWND,int,int,BOOL);
-void       SetScrollRange(HWND,int,int,int,BOOL);
-WORD       SetSelectorBase(WORD,DWORD);
-WORD       SetSelectorLimit(WORD,DWORD);
-int        SetSoundNoise(int,int);
-WORD       SetStretchBltMode(HDC,WORD);
-LONG       SetSwapAreaSize(WORD);
-void       SetSysColors(int,LPINT16,COLORREF*);
-HWND       SetSysModalWindow(HWND);
-WORD       SetSystemPaletteUse(HDC,WORD);
-BOOL       SetSystemPowerState(BOOL, BOOL);
-BOOL       SetSystemTime(const SYSTEMTIME*);
-WORD       SetSystemTimer(HWND,WORD,WORD,FARPROC);
-HQUEUE     SetTaskQueue(HTASK,HQUEUE);
-WORD       SetTextAlign(HDC,WORD);
-short      SetTextCharacterExtra(HDC,short);
-DWORD      SetTextColor(HDC,DWORD);
-short      SetTextJustification(HDC,short,short);
-WORD       SetTimer(HWND,WORD,WORD,FARPROC);
-int        SetVoiceAccent(int,int,int,int,int);
-int        SetVoiceEnvelope(int,int,int);
-int        SetVoiceNote(int,int,int,int);
-int        SetVoiceQueueSize(int,int);
-int        SetVoiceSound(int,LONG,int);
-int        SetVoiceThreshold(int,int);
-BOOL       SetWinDebugInfo(LPWINDEBUGINFO);
-BOOL       SetWindowPos(HWND,HWND,INT,INT,INT,INT,WORD);
-FARPROC    SetWindowsHook(short,FARPROC);
-HHOOK      SetWindowsHookEx(short,HOOKPROC,HINSTANCE,HTASK);
-HINSTANCE  ShellExecute(HWND,LPCSTR,LPCSTR,LPSTR,LPCSTR,INT);
-void       ShowCaret(HWND);
-int        ShowCursor(BOOL);
-void       ShowOwnedPopups(HWND,BOOL);
-void       ShowScrollBar(HWND,WORD,BOOL);
-BOOL       ShowWindow(HWND,int);
-DWORD      SizeofResource(HINSTANCE,HRSRC);
-VOID       Sleep(DWORD); /* Win32 */
-int        StartSound(void);
-int        StopSound(void);
-BOOL       StretchBlt(HDC,short,short,short,short,HDC,short,short,short,short,DWORD);
-int        StretchDIBits(HDC,WORD,WORD,WORD,WORD,WORD,WORD,WORD,WORD,LPSTR,LPBITMAPINFO,WORD,DWORD);
-BOOL       SwapMouseButton(BOOL);
-void       SwapRecording(WORD);
-void       SwitchStackBack(void);
-void       SwitchStackTo(WORD,WORD,WORD);
-int        SyncAllVoices(void);
-BOOL       SystemParametersInfo(UINT,UINT,LPVOID,UINT);
-LONG       TabbedTextOut(HDC,short,short,LPSTR,short,short,LPINT16,short);
-int        Throw(LPCATCHBUF,int);
-int        ToAscii(WORD,WORD,LPSTR,LPVOID,WORD);
-int        TranslateAccelerator(HWND,HANDLE,LPMSG);
-BOOL       TranslateMDISysAccel(HWND,LPMSG);
-BOOL       TranslateMessage(LPMSG);
-int        TransmitCommChar(int,char);
-int        UngetCommChar(int,char);
-BOOL       UnhookWindowsHook(short,FARPROC);
-BOOL       UnhookWindowsHookEx(HHOOK);
-void       UnlockSegment(HGLOBAL);
-BOOL       UnrealizeObject(HBRUSH);
-int        UpdateColors(HDC);
-void       UpdateWindow(HWND32);
-void       UserYield(void);
-void       ValidateCodeSegments(void);
-LPSTR      ValidateFreeSpaces(void);
-void       ValidateRgn(HWND32,HRGN32);
-WORD       VkKeyScan(WORD);
-SEGPTR     WIN16_GlobalLock16(HGLOBAL16);
-SEGPTR     WIN16_LockResource(HANDLE);
-SEGPTR     WIN16_lstrcpyn(SEGPTR,SEGPTR,WORD);
-BOOL       WaitEvent(HTASK);
-void       WaitMessage(void);
-int        WaitSoundState(int);
-HANDLE     WinExec(LPSTR,WORD);
-BOOL       WinHelp(HWND,LPSTR,WORD,DWORD);
-int        WriteComm(int,LPSTR,int);
-void       WriteOutProfiles(void);
-BOOL       WritePrivateProfileString(LPCSTR,LPCSTR,LPCSTR,LPCSTR);
-BOOL       WriteProfileString(LPCSTR,LPCSTR,LPCSTR);
-void       Yield(void);
-LONG       _hread(HFILE,SEGPTR,LONG);
-LONG       _hwrite(HFILE,LPCSTR,LONG);
-HFILE      _lclose(HFILE);
-HFILE      _lcreat(LPCSTR,INT);
-LONG       _llseek(HFILE,LONG,INT);
-HFILE      _lopen(LPCSTR,INT);
-INT        _lread(HFILE,SEGPTR,WORD);
-INT        _lwrite(HFILE,LPCSTR,WORD);
-void       hmemcpy(LPVOID,LPCVOID,LONG);
-SEGPTR     lstrcat(SEGPTR,SEGPTR);
-INT        lstrcmp(LPCSTR,LPCSTR);
-INT        lstrcmpi(LPCSTR,LPCSTR);
-INT        lstrncmpi(LPCSTR,LPCSTR,int);
-SEGPTR     lstrcpy(SEGPTR,SEGPTR);
-LPSTR      lstrcpyn(LPSTR,LPCSTR,int);
-INT        lstrlen(LPCSTR);
-int        wsprintf(LPSTR,LPSTR,...);
-int        wvsprintf(LPSTR,LPCSTR,LPCSTR);
-
-/* Declarations for functions that are the same in Win16 and Win32 */
-
-BOOL16     EndDialog(HWND32,INT32);
-INT16      ExcludeUpdateRgn(HDC32,HWND32);
-void       FillWindow(HWND16,HWND16,HDC16,HBRUSH16);
+VOID       FillWindow(HWND16,HWND16,HDC16,HBRUSH16);
 DWORD      GetBitmapDimension(HBITMAP16);
-WORD       GetClassWord(HWND32,INT32);
-DWORD      GetLogicalDrives(void);
-INT16      GetUpdateRgn(HWND32,HRGN32,BOOL32);
-WORD       GetWindowWord(HWND32,INT32);
-INT16      OffsetRgn(HRGN32,INT32,INT32);
 DWORD      OffsetViewportOrg(HDC16,INT16,INT16);
 DWORD      OffsetWindowOrg(HDC16,INT16,INT16);
-void       PaintRect(HWND16,HWND16,HDC16,HBRUSH16,const RECT16*);
-DWORD      RegCloseKey(HKEY);
-DWORD      RegFlushKey(HKEY);
+VOID       PaintRect(HWND16,HWND16,HDC16,HBRUSH16,const RECT16*);
 DWORD      ScaleViewportExt(HDC16,INT16,INT16,INT16,INT16);
 DWORD      ScaleWindowExt(HDC16,INT16,INT16,INT16,INT16);
 DWORD      SetBitmapDimension(HBITMAP16,INT16,INT16);
-WORD       SetClassWord(HWND32,INT32,WORD);
 DWORD      SetViewportExt(HDC16,INT16,INT16);
 DWORD      SetViewportOrg(HDC16,INT16,INT16);
 DWORD      SetWindowExt(HDC16,INT16,INT16);
 DWORD      SetWindowOrg(HDC16,INT16,INT16);
+VOID       hmemcpy(LPVOID,LPCVOID,LONG);
+
+/* Declarations for functions that exist only in Win32 */
+
+DWORD      GetLogicalDrives(void);
+
+/* Declarations for functions that are the same in Win16 and Win32 */
+
+HBITMAP16  CreateBitmap(INT32,INT32,UINT32,UINT32,LPCVOID);
+HBITMAP16  CreateCompatibleBitmap(HDC32,INT32,INT32);
+HBITMAP16  CreateDiscardableBitmap(HDC32,INT32,INT32);
+BOOL16     EndDialog(HWND32,INT32);
+INT16      ExcludeUpdateRgn(HDC32,HWND32);
+LONG       GetBitmapBits(HBITMAP32,LONG,LPVOID);
+WORD       GetClassWord(HWND32,INT32);
+INT16      GetUpdateRgn(HWND32,HRGN32,BOOL32);
+WORD       GetWindowWord(HWND32,INT32);
+INT16      OffsetRgn(HRGN32,INT32,INT32);
+DWORD      RegCloseKey(HKEY);
+DWORD      RegFlushKey(HKEY);
+LONG       SetBitmapBits(HBITMAP32,LONG,LPCVOID);
+WORD       SetClassWord(HWND32,INT32,WORD);
 WORD       SetWindowWord(HWND32,INT32,WORD);
 
 /* Declarations for functions that change between Win16 and Win32 */
@@ -3439,25 +3215,28 @@
 BOOL16     CopyRect16(RECT16*,const RECT16*);
 BOOL32     CopyRect32(RECT32*,const RECT32*);
 #define    CopyRect WINELIB_NAME(CopyRect)
-HWND16     CreateDialog16(HINSTANCE16,SEGPTR,HWND16,DLGPROC);
+HBITMAP16  CreateBitmapIndirect16(const BITMAP16*);
+HBITMAP32  CreateBitmapIndirect32(const BITMAP32*);
+#define    CreateBitmapIndirect WINELIB_NAME(CreateBitmapIndirect)
+HWND16     CreateDialog16(HINSTANCE16,SEGPTR,HWND16,DLGPROC16);
 #define    CreateDialog32A(inst,ptr,hwnd,dlg) \
            CreateDialogParam32A(inst,ptr,hwnd,dlg,0)
 #define    CreateDialog32W(inst,ptr,hwnd,dlg) \
            CreateDialogParam32W(inst,ptr,hwnd,dlg,0)
 #define    CreateDialog WINELIB_NAME_AW(CreateDialog)
-HWND16     CreateDialogIndirect16(HINSTANCE16,LPCVOID,HWND16,DLGPROC);
+HWND16     CreateDialogIndirect16(HINSTANCE16,LPCVOID,HWND16,DLGPROC16);
 #define    CreateDialogIndirect32A(inst,ptr,hwnd,dlg) \
            CreateDialogIndirectParam32A(inst,ptr,hwnd,dlg,0)
 #define    CreateDialogIndirect32W(inst,ptr,hwnd,dlg) \
            CreateDialogIndirectParam32W(inst,ptr,hwnd,dlg,0)
 #define    CreateDialogIndirect WINELIB_NAME_AW(CreateDialogIndirect)
-HWND16     CreateDialogIndirectParam16(HINSTANCE16,LPCVOID,HWND16,DLGPROC,LPARAM);
-HWND32     CreateDialogIndirectParam32A(HINSTANCE32,LPCVOID,HWND32,DLGPROC,LPARAM);
-HWND32     CreateDialogIndirectParam32W(HINSTANCE32,LPCVOID,HWND32,DLGPROC,LPARAM);
+HWND16     CreateDialogIndirectParam16(HINSTANCE16,LPCVOID,HWND16,DLGPROC16,LPARAM);
+HWND32     CreateDialogIndirectParam32A(HINSTANCE32,LPCVOID,HWND32,DLGPROC32,LPARAM);
+HWND32     CreateDialogIndirectParam32W(HINSTANCE32,LPCVOID,HWND32,DLGPROC32,LPARAM);
 #define    CreateDialogIndirectParam WINELIB_NAME_AW(CreateDialogIndirectParam)
-HWND16     CreateDialogParam16(HINSTANCE16,SEGPTR,HWND16,DLGPROC,LPARAM);
-HWND32     CreateDialogParam32A(HINSTANCE32,LPCSTR,HWND32,DLGPROC,LPARAM);
-HWND32     CreateDialogParam32W(HINSTANCE32,LPCWSTR,HWND32,DLGPROC,LPARAM);
+HWND16     CreateDialogParam16(HINSTANCE16,SEGPTR,HWND16,DLGPROC16,LPARAM);
+HWND32     CreateDialogParam32A(HINSTANCE32,LPCSTR,HWND32,DLGPROC32,LPARAM);
+HWND32     CreateDialogParam32W(HINSTANCE32,LPCWSTR,HWND32,DLGPROC32,LPARAM);
 #define    CreateDialogParam WINELIB_NAME_AW(CreateDialogParam)
 HRGN16     CreateEllipticRgnIndirect16(const RECT16 *);
 HRGN32     CreateEllipticRgnIndirect32(const RECT32 *);
@@ -3501,25 +3280,25 @@
 LRESULT    DefWindowProc32A(HWND32,UINT32,WPARAM32,LPARAM);
 LRESULT    DefWindowProc32W(HWND32,UINT32,WPARAM32,LPARAM);
 #define    DefWindowProc WINELIB_NAME_AW(DefWindowProc)
-INT16      DialogBox16(HINSTANCE16,SEGPTR,HWND16,DLGPROC);
+INT16      DialogBox16(HINSTANCE16,SEGPTR,HWND16,DLGPROC16);
 #define    DialogBox32A(inst,template,owner,func) \
            DialogBoxParam32A(inst,template,owner,func,0)
 #define    DialogBox32W(inst,template,owner,func) \
            DialogBoxParam32W(inst,template,owner,func,0)
 #define    DialogBox WINELIB_NAME_AW(DialogBox)
-INT16      DialogBoxIndirect16(HINSTANCE16,HANDLE16,HWND16,DLGPROC);
+INT16      DialogBoxIndirect16(HINSTANCE16,HANDLE16,HWND16,DLGPROC16);
 #define    DialogBoxIndirect32A(inst,template,owner,func) \
            DialogBoxIndirectParam32A(inst,template,owner,func,0)
 #define    DialogBoxIndirect32W(inst,template,owner,func) \
            DialogBoxIndirectParam32W(inst,template,owner,func,0)
 #define    DialogBoxIndirect WINELIB_NAME_AW(DialogBoxIndirect)
-INT16      DialogBoxIndirectParam16(HINSTANCE16,HANDLE16,HWND16,DLGPROC,LPARAM);
-INT32      DialogBoxIndirectParam32A(HINSTANCE32,LPCVOID,HWND32,DLGPROC,LPARAM);
-INT32      DialogBoxIndirectParam32W(HINSTANCE32,LPCVOID,HWND32,DLGPROC,LPARAM);
+INT16      DialogBoxIndirectParam16(HINSTANCE16,HANDLE16,HWND16,DLGPROC16,LPARAM);
+INT32      DialogBoxIndirectParam32A(HINSTANCE32,LPCVOID,HWND32,DLGPROC32,LPARAM);
+INT32      DialogBoxIndirectParam32W(HINSTANCE32,LPCVOID,HWND32,DLGPROC32,LPARAM);
 #define    DialogBoxIndirectParam WINELIB_NAME_AW(DialogBoxIndirectParam)
-INT16      DialogBoxParam16(HINSTANCE16,SEGPTR,HWND16,DLGPROC,LPARAM);
-INT32      DialogBoxParam32A(HINSTANCE32,LPCSTR,HWND32,DLGPROC,LPARAM);
-INT32      DialogBoxParam32W(HINSTANCE32,LPCWSTR,HWND32,DLGPROC,LPARAM);
+INT16      DialogBoxParam16(HINSTANCE16,SEGPTR,HWND16,DLGPROC16,LPARAM);
+INT32      DialogBoxParam32A(HINSTANCE32,LPCSTR,HWND32,DLGPROC32,LPARAM);
+INT32      DialogBoxParam32W(HINSTANCE32,LPCWSTR,HWND32,DLGPROC32,LPARAM);
 #define    DialogBoxParam WINELIB_NAME_AW(DialogBoxParam)
 INT16      DlgDirListComboBox16(HWND16,LPCSTR,INT16,INT16,UINT16);
 INT32      DlgDirListComboBox32A(HWND32,LPCSTR,INT32,INT32,UINT32);
@@ -3548,13 +3327,13 @@
 INT16      FillRect16(HDC16,const RECT16*,HBRUSH16);
 INT32      FillRect32(HDC32,const RECT32*,HBRUSH32);
 #define    FillRect WINELIB_NAME(FillRect)
-HWND       FindWindow16(SEGPTR,LPCSTR);
-HWND       FindWindow32A(LPCSTR,LPCSTR);
-HWND       FindWindow32W(LPCWSTR,LPCWSTR);
+HWND16     FindWindow16(SEGPTR,LPCSTR);
+HWND32     FindWindow32A(LPCSTR,LPCSTR);
+HWND32     FindWindow32W(LPCWSTR,LPCWSTR);
 #define    FindWindow WINELIB_NAME_AW(FindWindow)
-HWND       FindWindowEx16(HWND,HWND,SEGPTR,LPCSTR);
-HWND       FindWindowEx32A(HWND,HWND,LPCSTR,LPCSTR);
-HWND       FindWindowEx32W(HWND,HWND,LPCWSTR,LPCWSTR);
+HWND16     FindWindowEx16(HWND16,HWND16,SEGPTR,LPCSTR);
+HWND32     FindWindowEx32A(HWND32,HWND32,LPCSTR,LPCSTR);
+HWND32     FindWindowEx32W(HWND32,HWND32,LPCWSTR,LPCWSTR);
 #define    FindWindowEx WINELIB_NAME_AW(FindWindowEx)
 INT16      FrameRect16(HDC16,const RECT16*,HBRUSH16);
 INT32      FrameRect32(HDC32,const RECT32*,HBRUSH32);
@@ -3568,21 +3347,21 @@
 void       GetCaretPos16(LPPOINT16);
 void       GetCaretPos32(LPPOINT32);
 #define    GetCaretPos WINELIB_NAME(GetCaretPos)
-BOOL       GetClassInfo16(HINSTANCE16,SEGPTR,WNDCLASS16 *);
-BOOL       GetClassInfo32A(HINSTANCE32,LPCSTR,WNDCLASS32A *);
-BOOL       GetClassInfo32W(HINSTANCE32,LPCWSTR,WNDCLASS32W *);
+BOOL16     GetClassInfo16(HINSTANCE16,SEGPTR,WNDCLASS16 *);
+BOOL32     GetClassInfo32A(HINSTANCE32,LPCSTR,WNDCLASS32A *);
+BOOL32     GetClassInfo32W(HINSTANCE32,LPCWSTR,WNDCLASS32W *);
 #define    GetClassInfo WINELIB_NAME_AW(GetClassInfo)
-BOOL       GetClassInfoEx16(HINSTANCE16,SEGPTR,WNDCLASSEX16 *);
-BOOL       GetClassInfoEx32A(HINSTANCE32,LPCSTR,WNDCLASSEX32A *);
-BOOL       GetClassInfoEx32W(HINSTANCE32,LPCWSTR,WNDCLASSEX32W *);
+BOOL16     GetClassInfoEx16(HINSTANCE16,SEGPTR,WNDCLASSEX16 *);
+BOOL32     GetClassInfoEx32A(HINSTANCE32,LPCSTR,WNDCLASSEX32A *);
+BOOL32     GetClassInfoEx32W(HINSTANCE32,LPCWSTR,WNDCLASSEX32W *);
 #define    GetClassInfoEx WINELIB_NAME_AW(GetClassInfoEx)
-LONG       GetClassLong16(HWND,INT16);
-LONG       GetClassLong32A(HWND,INT32);
-LONG       GetClassLong32W(HWND,INT32);
+LONG       GetClassLong16(HWND16,INT16);
+LONG       GetClassLong32A(HWND32,INT32);
+LONG       GetClassLong32W(HWND32,INT32);
 #define    GetClassLong WINELIB_NAME_AW(GetClassLong)
-INT16      GetClassName16(HWND,LPSTR,INT16);
-INT32      GetClassName32A(HWND,LPSTR,INT32);
-INT32      GetClassName32W(HWND,LPWSTR,INT32);
+INT16      GetClassName16(HWND16,LPSTR,INT16);
+INT32      GetClassName32A(HWND32,LPSTR,INT32);
+INT32      GetClassName32W(HWND32,LPWSTR,INT32);
 #define    GetClassName WINELIB_NAME_AW(GetClassName)
 void       GetClientRect16(HWND16,LPRECT16);
 void       GetClientRect32(HWND32,LPRECT32);
@@ -3609,6 +3388,10 @@
 UINT32     GetLogicalDriveStrings32A(UINT32,LPSTR);
 UINT32     GetLogicalDriveStrings32W(UINT32,LPWSTR);
 #define    GetLogicalDriveStrings WINELIB_NAME(GetLogicalDriveStrings)
+INT16      GetObject16(HANDLE16,INT16,LPVOID);
+INT32      GetObject32A(HANDLE32,INT32,LPVOID);
+INT32      GetObject32W(HANDLE32,INT32,LPVOID);
+#define    GetObject WINELIB_NAME_AW(GetObject)
 INT16      GetRgnBox16(HRGN16,LPRECT16);
 INT32      GetRgnBox32(HRGN32,LPRECT32);
 #define    GetRgnBox WINELIB_NAME(GetRgnBox)
@@ -3765,6 +3548,10 @@
 BOOL16     OffsetWindowOrgEx16(HDC16,INT16,INT16,LPPOINT16);
 BOOL32     OffsetWindowOrgEx32(HDC32,INT32,INT32,LPPOINT32);
 #define    OffsetWindowOrgEx WINELIB_NAME(OffsetWindowOrgEx)
+BOOL16     PeekMessage16(LPMSG16,HWND16,UINT16,UINT16,UINT16);
+BOOL32     PeekMessage32A(LPMSG32,HWND32,UINT32,UINT32,UINT32);
+BOOL32     PeekMessage32W(LPMSG32,HWND32,UINT32,UINT32,UINT32);
+#define    PeekMessage WINELIB_NAME_AW(PeekMessage)
 BOOL16     PolyPolygon16(HDC16,LPPOINT16,LPINT16,UINT16);
 BOOL32     PolyPolygon32(HDC32,LPPOINT32,LPINT32,UINT32);
 #define    PolyPolygon WINELIB_NAME(PolyPolygon)
@@ -3878,9 +3665,9 @@
 BOOL16     SetBitmapDimensionEx16(HBITMAP16,INT16,INT16,LPSIZE16);
 BOOL32     SetBitmapDimensionEx32(HBITMAP32,INT32,INT32,LPSIZE32);
 #define    SetBitmapDimensionEx WINELIB_NAME(SetBitmapDimensionEx)
-LONG       SetClassLong16(HWND,INT16,LONG);
-LONG       SetClassLong32A(HWND,INT32,LONG);
-LONG       SetClassLong32W(HWND,INT32,LONG);
+LONG       SetClassLong16(HWND16,INT16,LONG);
+LONG       SetClassLong32A(HWND32,INT32,LONG);
+LONG       SetClassLong32W(HWND32,INT32,LONG);
 #define    SetClassLong WINELIB_NAME_AW(SetClassLong)
 void       SetDlgItemInt16(HWND16,INT16,UINT16,BOOL16);
 void       SetDlgItemInt32(HWND32,INT32,UINT32,BOOL32);
@@ -3944,6 +3731,669 @@
 HWND16     WindowFromPoint16(POINT16);
 HWND32     WindowFromPoint32(POINT32);
 #define    WindowFromPoint WINELIB_NAME(WindowFromPoint)
+SEGPTR     lstrcat16(SEGPTR,SEGPTR);
+LPSTR      lstrcat32A(LPSTR,LPCSTR);
+LPWSTR     lstrcat32W(LPWSTR,LPCWSTR);
+#define    lstrcat WINELIB_NAME_AW(lstrcat)
+SEGPTR     lstrcatn16(SEGPTR,SEGPTR,INT16);
+LPSTR      lstrcatn32A(LPSTR,LPCSTR,INT32);
+LPWSTR     lstrcatn32W(LPWSTR,LPCWSTR,INT32);
+#define    lstrcatn WINELIB_NAME_AW(lstrcatn)
+INT16      lstrcmp16(LPCSTR,LPCSTR);
+INT32      lstrcmp32A(LPCSTR,LPCSTR);
+INT32      lstrcmp32W(LPCWSTR,LPCWSTR);
+#define    lstrcmp WINELIB_NAME_AW(lstrcmp)
+INT16      lstrcmpi16(LPCSTR,LPCSTR);
+INT32      lstrcmpi32A(LPCSTR,LPCSTR);
+INT32      lstrcmpi32W(LPCWSTR,LPCWSTR);
+#define    lstrcmpi WINELIB_NAME_AW(lstrcmpi)
+SEGPTR     lstrcpy16(SEGPTR,SEGPTR);
+LPSTR      lstrcpy32A(LPSTR,LPCSTR);
+LPWSTR     lstrcpy32W(LPWSTR,LPCWSTR);
+#define    lstrcpy WINELIB_NAME_AW(lstrcpy)
+SEGPTR     lstrcpyn16(SEGPTR,SEGPTR,INT16);
+LPSTR      lstrcpyn32A(LPSTR,LPCSTR,INT32);
+LPWSTR     lstrcpyn32W(LPWSTR,LPCWSTR,INT32);
+#define    lstrcpyn WINELIB_NAME_AW(lstrcpyn)
+INT16      lstrlen16(LPCSTR);
+INT32      lstrlen32A(LPCSTR);
+INT32      lstrlen32W(LPCWSTR);
+#define    lstrlen WINELIB_NAME_AW(lstrlen)
+INT16      lstrncmp16(LPCSTR,LPCSTR,INT16);
+INT32      lstrncmp32A(LPCSTR,LPCSTR,INT32);
+INT32      lstrncmp32W(LPCWSTR,LPCWSTR,INT32);
+#define    lstrncmp WINELIB_NAME_AW(lstrncmp)
+INT16      lstrncmpi16(LPCSTR,LPCSTR,INT16);
+INT32      lstrncmpi32A(LPCSTR,LPCSTR,INT32);
+INT32      lstrncmpi32W(LPCWSTR,LPCWSTR,INT32);
+#define    lstrncmpi WINELIB_NAME_AW(lstrncmpi)
+INT16      wsnprintf16(LPSTR,UINT16,LPCSTR,...);
+INT32      wsnprintf32A(LPSTR,UINT32,LPCSTR,...);
+INT32      wsnprintf32W(LPWSTR,UINT32,LPCWSTR,...);
+#define    wsnprintf WINELIB_NAME_AW(wsnprintf)
+INT16      wsprintf16(LPSTR,LPCSTR,...);
+INT32      wsprintf32A(LPSTR,LPCSTR,...);
+INT32      wsprintf32W(LPWSTR,LPCWSTR,...);
+#define    wsprintf WINELIB_NAME_AW(wsprintf)
+INT16      wvsnprintf16(LPSTR,UINT16,LPCSTR,LPCVOID);
+INT32      wvsnprintf32A(LPSTR,UINT32,LPCSTR,LPCVOID);
+INT32      wvsnprintf32W(LPWSTR,UINT32,LPCWSTR,LPCVOID);
+#define    wvsnprintf WINELIB_NAME_AW(wvsnprintf)
+INT16      wvsprintf16(LPSTR,LPCSTR,LPCVOID);
+INT32      wvsprintf32A(LPSTR,LPCSTR,LPCVOID);
+INT32      wvsprintf32W(LPWSTR,LPCWSTR,LPCVOID);
+#define    wvsprintf WINELIB_NAME_AW(wvsprintf)
+
+/* Library data types defined as a transition aid for the emulator. */
+/* These should _not_ be used in the emulator and will be removed someday. */
+
+#ifndef NO_TRANSITION_TYPES
+
+#ifndef WINELIB
+typedef INT16 INT;
+typedef UINT16 UINT;
+typedef BOOL16 BOOL;
+typedef WPARAM16 WPARAM;
+typedef HANDLE16 HANDLE;
+typedef HANDLE16 HBITMAP;
+typedef HANDLE16 HBRUSH;
+typedef HANDLE16 HCURSOR;
+typedef HANDLE16 HDC;
+typedef HANDLE16 HDRVR;
+typedef HANDLE16 HFONT;
+typedef HANDLE16 HGLOBAL;
+typedef HANDLE16 HICON;
+typedef HANDLE16 HINSTANCE;
+typedef HANDLE16 HMENU;
+typedef HANDLE16 HMETAFILE;
+typedef HANDLE16 HMIDI;
+typedef HANDLE16 HMIDIIN;
+typedef HANDLE16 HMIDIOUT;
+typedef HANDLE16 HMMIO;
+typedef HANDLE16 HMODULE;
+typedef HANDLE16 HQUEUE;
+typedef HANDLE16 HRGN;
+typedef HANDLE16 HRSRC;
+typedef HANDLE16 HTASK;
+typedef HANDLE16 HWAVE;
+typedef HANDLE16 HWAVEIN;
+typedef HANDLE16 HWAVEOUT;
+typedef HANDLE16 HWND;
+typedef FARPROC16 FARPROC;
+#endif  /* WINELIB */
+
+/* Callback function pointers types. */
+
+#ifdef WINELIB
+typedef LONG (*DRIVERPROC)(DWORD, HDRVR, UINT, LPARAM, LPARAM);
+typedef int (*EDITWORDBREAKPROC)(LPSTR lpch, int ichCurrent, int cch,int code);
+/*typedef int (*FONTENUMPROC)(const LOGFONT*,const TEXTMETRIC*,DWORD,LPARAM);*/
+typedef int (*FONTENUMPROC)(const void*,const void*,DWORD,LPARAM);
+typedef int (*GOBJENUMPROC)(LPVOID,LPARAM);
+/*typedef int (*MFENUMPROC)(HDC,HANDLETABLE*,METARECORD*,int,LPARAM);*/
+typedef int (*MFENUMPROC)(HDC,void*,void*,int,LPARAM);
+typedef BOOL (*PROPENUMPROC)(HWND,LPCTSTR,HANDLE);
+typedef LRESULT (*WNDENUMPROC)(HWND,LPARAM);
+#else
+typedef SEGPTR DRIVERPROC;
+typedef SEGPTR EDITWORDBREAKPROC;
+typedef SEGPTR FONTENUMPROC;
+typedef SEGPTR GOBJENUMPROC;
+typedef SEGPTR MFENUMPROC;
+typedef SEGPTR PROPENUMPROC;
+typedef SEGPTR WNDENUMPROC;
+#endif
+typedef FARPROC HOOKPROC;
+
+#endif  /* NO_TRANSITION_TYPES */
+
+
+INT        AccessResource(HINSTANCE,HRSRC);
+ATOM       AddAtom(SEGPTR);
+INT        AddFontResource(LPCSTR);
+WORD       AllocCStoDSAlias(WORD);
+WORD       AllocDStoCSAlias(WORD);
+HGLOBAL    AllocResource(HINSTANCE,HRSRC,DWORD);
+WORD       AllocSelector(WORD);
+WORD       AllocSelectorArray(WORD);
+BOOL       AnimatePalette(HPALETTE16,UINT,UINT,LPPALETTEENTRY);
+LPSTR      AnsiLower(LPSTR);
+UINT       AnsiLowerBuff(LPSTR,UINT);
+SEGPTR     AnsiNext(SEGPTR);
+SEGPTR     AnsiPrev(SEGPTR,SEGPTR);
+INT        AnsiToOem(LPSTR,LPSTR);
+void       AnsiToOemBuff(LPCSTR,LPSTR,UINT);
+LPSTR      AnsiUpper(LPSTR);
+UINT       AnsiUpperBuff(LPSTR,UINT);
+BOOL       AnyPopup(void);
+BOOL       Arc(HDC,INT,INT,INT,INT,INT,INT,INT,INT);
+UINT       ArrangeIconicWindows(HWND);
+HDWP16     BeginDeferWindowPos(INT);
+BOOL       BitBlt(HDC,INT,INT,INT,INT,HDC,INT,INT,DWORD);
+BOOL       BringWindowToTop(HWND);
+BOOL       BuildCommDCB(LPCSTR,DCB*);
+void       CalcChildScroll(HWND,WORD);
+BOOL       CallMsgFilter(SEGPTR,INT);
+LRESULT    CallNextHookEx(HHOOK,INT,WPARAM,LPARAM);
+INT        Catch(LPCATCHBUF);
+BOOL       ChangeClipboardChain(HWND,HWND);
+WORD       ChangeSelector(WORD,WORD);
+BOOL       CheckDlgButton(HWND,INT,UINT);
+INT        CheckMenuItem(HMENU,UINT,UINT);
+BOOL       CheckRadioButton(HWND,UINT,UINT,UINT);
+BOOL       Chord(HDC,INT,INT,INT,INT,INT,INT,INT,INT);
+int        ClearCommBreak(int);
+BOOL       CloseClipboard(void);
+int        CloseComm(int);
+HMETAFILE  CloseMetaFile(HDC);
+void       CloseSound(void);
+BOOL       CloseWindow(HWND);
+INT16      CombineRgn(HRGN32,HRGN32,HRGN32,INT32);
+int        ConvertRequest(HWND,LPKANJISTRUCT);
+#ifdef WINELIB32
+HCURSOR    CopyCursor(HCURSOR); /* Win32 */
+HICON      CopyIcon(HICON); /* Win32 */
+#else
+HCURSOR    CopyCursor(HINSTANCE,HCURSOR); /* Win16 */
+HICON      CopyIcon(HINSTANCE,HICON); /* Win16 */
+#endif
+HMETAFILE  CopyMetaFile(HMETAFILE,LPCSTR);
+INT        CountClipboardFormats(void);
+INT        CountVoiceNotes(INT);
+HBRUSH     CreateBrushIndirect(const LOGBRUSH16*);
+BOOL       CreateCaret(HWND,HBITMAP,INT,INT);
+HDC        CreateCompatibleDC(HDC);
+HCURSOR    CreateCursor(HANDLE,INT,INT,INT,INT,const BYTE*,const BYTE*);
+HANDLE     CreateCursorIconIndirect(HANDLE,CURSORICONINFO*,const BYTE*,const BYTE*);
+HDC        CreateDC(LPCSTR,LPCSTR,LPCSTR,const DEVMODE*);
+HBRUSH     CreateDIBPatternBrush(HGLOBAL,UINT);
+HBITMAP    CreateDIBitmap(HDC,BITMAPINFOHEADER*,DWORD,LPVOID,BITMAPINFO*,UINT);
+HRGN       CreateEllipticRgn(INT32,INT32,INT32,INT32);
+HFONT      CreateFont(INT,INT,INT,INT,INT,BYTE,BYTE,BYTE,BYTE,BYTE,BYTE,BYTE,BYTE,LPCSTR);
+HFONT      CreateFontIndirect(const LOGFONT16*);
+HBRUSH     CreateHatchBrush(INT,COLORREF);
+HDC        CreateIC(LPCSTR,LPCSTR,LPCSTR,const DEVMODE*);
+HICON      CreateIcon(HINSTANCE,INT,INT,BYTE,BYTE,const BYTE*,const BYTE*);
+HMENU      CreateMenu(void);
+HDC        CreateMetaFile(LPCSTR);
+HPALETTE16 CreatePalette(const LOGPALETTE*);
+HBRUSH     CreatePatternBrush(HBITMAP);
+HPEN16     CreatePen(INT,INT,COLORREF);
+HPEN16     CreatePenIndirect(const LOGPEN16*);
+HMENU      CreatePopupMenu(void);
+HRGN       CreateRectRgn(INT32,INT32,INT32,INT32);
+HRGN       CreateRoundRectRgn(INT32,INT32,INT32,INT32,INT32,INT32);
+HBRUSH     CreateSolidBrush(COLORREF);
+void       DebugBreak(void);
+DWORD      DefHookProc(short,WORD,DWORD,HHOOK*);
+HDWP16     DeferWindowPos(HDWP16,HWND,HWND,INT,INT,INT,INT,UINT);
+ATOM       DeleteAtom(ATOM);
+BOOL       DeleteDC(HDC);
+BOOL       DeleteMenu(HMENU,UINT,UINT);
+BOOL       DeleteMetaFile(HMETAFILE);
+BOOL       DeleteObject(HGDIOBJ16);
+BOOL       DestroyCaret(void);
+BOOL       DestroyCursor(HCURSOR);
+BOOL       DestroyIcon(HICON);
+BOOL       DestroyMenu(HMENU);
+BOOL       DestroyWindow(HWND);
+HANDLE     DirectResAlloc(HANDLE,WORD,WORD);
+void       DirectedYield(HTASK);
+LONG       DispatchMessage(const MSG16*);
+INT        DlgDirList(HWND,SEGPTR,INT,INT,UINT);
+BOOL       DlgDirSelect(HWND,LPSTR,INT);
+BOOL       DlgDirSelectComboBox(HWND,LPSTR,INT);
+BOOL16     DragDetect(HWND16,POINT16);
+DWORD      DragObject(HWND, HWND, WORD, HANDLE, WORD, HCURSOR);
+BOOL       DrawIcon(HDC,INT,INT,HICON);
+void       DrawMenuBar(HWND);
+DWORD      DumpIcon(SEGPTR,WORD*,SEGPTR*,SEGPTR*);
+BOOL       Ellipse(HDC,INT,INT,INT,INT);
+BOOL       EmptyClipboard(void);
+BOOL       EnableHardwareInput(BOOL);
+BOOL       EnableMenuItem(HMENU,UINT,UINT);
+BOOL       EnableScrollBar(HWND,UINT,UINT);
+BOOL       EnableWindow(HWND,BOOL);
+BOOL       EndDeferWindowPos(HDWP16);
+BOOL       EnumChildWindows(HWND,WNDENUMPROC,LPARAM);
+UINT       EnumClipboardFormats(UINT);
+INT        EnumFontFamilies(HDC,LPCSTR,FONTENUMPROC,LPARAM);
+INT        EnumFonts(HDC,LPCSTR,FONTENUMPROC,LPARAM);
+BOOL       EnumMetaFile(HDC,HMETAFILE,MFENUMPROC,LPARAM);
+INT        EnumObjects(HDC,INT,GOBJENUMPROC,LPARAM);
+INT        EnumProps(HWND,PROPENUMPROC);
+BOOL       EnumTaskWindows(HTASK,WNDENUMPROC,LPARAM);
+BOOL       EnumWindows(WNDENUMPROC,LPARAM);
+BOOL       EqualRgn(HRGN32,HRGN32);
+INT        Escape(HDC,INT,INT,LPCSTR,LPVOID);
+LONG       EscapeCommFunction(int,int);
+int        ExcludeClipRect(HDC,short,short,short,short);
+int        ExcludeVisRect(HDC,short,short,short,short);
+BOOL       ExitWindows(DWORD,WORD);
+BOOL       ExtFloodFill(HDC,INT,INT,COLORREF,WORD);
+HICON      ExtractIcon(HINSTANCE,LPCSTR,WORD);
+WORD       FarGetOwner(HANDLE);
+void       FarSetOwner(HANDLE,HANDLE);
+void       FatalAppExit(UINT,LPCSTR);
+void       FatalExit(int);
+BOOL       FillRgn(HDC,HRGN,HBRUSH);
+ATOM       FindAtom(SEGPTR);
+HINSTANCE  FindExecutable(LPCSTR,LPCSTR,LPSTR);
+HRSRC      FindResource(HINSTANCE,SEGPTR,SEGPTR);
+BOOL       FlashWindow(HWND,BOOL);
+BOOL       FloodFill(HDC,INT,INT,COLORREF);
+int        FlushComm(int,int);
+BOOL       FrameRgn(HDC,HRGN,HBRUSH,int,int);
+void       FreeLibrary(HANDLE);
+BOOL       FreeModule(HANDLE);
+void       FreeProcInstance(FARPROC);
+BOOL       FreeResource(HGLOBAL);
+WORD       FreeSelector(WORD);
+UINT       GDIRealizePalette(HDC);
+HPALETTE16 GDISelectPalette(HDC,HPALETTE16);
+HWND       GetActiveWindow(void);
+DWORD      GetAspectRatioFilter(HDC);
+int        GetAsyncKeyState(int);
+HANDLE     GetAtomHandle(ATOM);
+WORD       GetAtomName(ATOM,LPSTR,short);
+COLORREF   GetBkColor(HDC);
+WORD       GetBkMode(HDC);
+DWORD      GetBrushOrg(HDC);
+HWND       GetCapture(void);
+WORD       GetCaretBlinkTime(void);
+BOOL       GetCharABCWidths(HDC,UINT,UINT,LPABC16);
+BOOL       GetCharWidth(HDC,WORD,WORD,LPINT16);
+HRGN       GetClipRgn(HDC);
+HANDLE     GetClipboardData(WORD);
+int        GetClipboardFormatName(WORD,LPSTR,short);
+HWND       GetClipboardOwner(void);
+HWND       GetClipboardViewer(void);
+HANDLE     GetCodeHandle(FARPROC);
+void       GetCodeInfo(FARPROC,LPVOID);
+int        GetCommError(int,COMSTAT*);
+UINT       GetCommEventMask(int,int);
+int        GetCommState(int,DCB*);
+HBRUSH     GetControlBrush(HWND,HDC,WORD);
+UINT32     GetCurrentDirectory(UINT32,LPSTR);
+HANDLE     GetCurrentPDB(void);
+DWORD      GetCurrentPosition(HDC);
+HANDLE     GetCurrentTask(void);
+DWORD      GetCurrentTime(void);
+HCURSOR    GetCursor(void);
+HDC        GetDC(HWND);
+HDC        GetDCEx(HWND,HRGN,DWORD);
+DWORD      GetDCHook(HDC,FARPROC16*);
+DWORD      GetDCOrg(HDC);
+HDC        GetDCState(HDC);
+int        GetDIBits(HDC,HANDLE,WORD,WORD,LPSTR,LPBITMAPINFO,WORD);
+SEGPTR     GetDOSEnvironment(void);
+HWND       GetDesktopHwnd(void);
+HWND       GetDesktopWindow(void);
+int        GetDeviceCaps(HDC,WORD);
+DWORD      GetDialogBaseUnits(void);
+int        GetDlgCtrlID(HWND);
+HWND       GetDlgItem(HWND,WORD);
+WORD       GetDlgItemInt(HWND,WORD,BOOL*,BOOL);
+WORD       GetDoubleClickTime(void);
+WORD       GetDriveType(INT);
+int        GetEnvironment(LPSTR,LPSTR,WORD);
+HMODULE    GetExePtr(HANDLE);
+HWND       GetFocus(void);
+DWORD      GetFreeSpace(UINT16);
+DWORD      GetHeapSpaces(HMODULE);
+BOOL       GetInputState(void);
+int        GetInstanceData(HANDLE,WORD,int);
+int        GetKBCodePage(void);
+int        GetKerningPairs(HDC,int,LPKERNINGPAIR16);
+int        GetKeyNameText(LONG,LPSTR,int);
+INT        GetKeyState(INT);
+void       GetKeyboardState(BYTE*);
+int        GetKeyboardType(int);
+HWND       GetLastActivePopup(HWND);
+VOID       GetLocalTime(LPSYSTEMTIME); /* Win32 */
+WORD       GetMapMode(HDC);
+HMENU      GetMenu(HWND);
+DWORD      GetMenuCheckMarkDimensions(void);
+INT        GetMenuItemCount(HMENU);
+UINT       GetMenuItemID(HMENU,int);
+UINT       GetMenuState(HMENU,UINT,UINT);
+int        GetMenuString(HMENU,UINT,LPSTR,short,UINT);
+BOOL       GetMessage(SEGPTR,HWND,UINT,UINT);
+LONG       GetMessageExtraInfo(void);
+DWORD      GetMessagePos(void);
+LONG       GetMessageTime(void);
+HANDLE     GetMetaFile(LPSTR);
+HANDLE     GetMetaFileBits(HANDLE);
+int        GetModuleFileName(HANDLE,LPSTR,short);
+HANDLE     GetModuleHandle(LPCSTR);
+int        GetModuleUsage(HANDLE);
+FARPROC    GetMouseEventProc(void);
+DWORD      GetNearestColor(HDC,DWORD);
+WORD       GetNearestPaletteIndex(HPALETTE16,DWORD);
+HWND       GetNextDlgGroupItem(HWND,HWND,BOOL);
+HWND       GetNextDlgTabItem(HWND,HWND,BOOL);
+HWND       GetNextWindow(HWND,WORD);
+WORD       GetNumTasks(void);
+HWND       GetOpenClipboardWindow(void);
+WORD       GetPaletteEntries(HPALETTE16,WORD,WORD,LPPALETTEENTRY);
+HWND       GetParent(HWND);
+DWORD      GetPixel(HDC,short,short);
+WORD       GetPolyFillMode(HDC);
+int        GetPriorityClipboardFormat(WORD*,short);
+UINT       GetPrivateProfileInt(LPCSTR,LPCSTR,INT,LPCSTR);
+INT        GetPrivateProfileString(LPCSTR,LPCSTR,LPCSTR,LPSTR,INT,LPCSTR);
+FARPROC    GetProcAddress(HANDLE,SEGPTR);
+UINT       GetProfileInt(LPCSTR,LPCSTR,INT);
+INT        GetProfileString(LPCSTR,LPCSTR,LPCSTR,LPSTR,INT);
+HANDLE     GetProp(HWND,SEGPTR);
+DWORD      GetQueueStatus(UINT);
+BOOL       GetRasterizerCaps(LPRASTERIZER_STATUS,UINT);
+WORD       GetROP2(HDC);
+WORD       GetRelAbs(HDC);
+int        GetScrollPos(HWND,int);
+void       GetScrollRange(HWND,int,LPINT16,LPINT16);
+DWORD      GetSelectorBase(WORD);
+DWORD      GetSelectorLimit(WORD);
+HANDLE     GetStockObject(int);
+WORD       GetStretchBltMode(HDC);
+HMENU      GetSubMenu(HMENU,short);
+COLORREF   GetSysColor(short);
+HWND       GetSysModalWindow(void);
+UINT       GetSystemDirectory(LPSTR,UINT);
+HMENU      GetSystemMenu(HWND,BOOL);
+int        GetSystemMetrics(WORD);
+WORD       GetSystemPaletteEntries(HDC,WORD,WORD,LPPALETTEENTRY);
+WORD       GetSystemPaletteUse(HDC);
+BOOL       GetSystemPowerStatus(LPSYSTEM_POWER_STATUS);
+VOID       GetSystemTime(LPSYSTEMTIME); /* Win32 */
+DWORD      GetTabbedTextExtent(HDC,LPSTR,int,int,LPINT16);
+HINSTANCE  GetTaskDS(void);
+HQUEUE     GetTaskQueue(HTASK);
+BYTE       GetTempDrive(BYTE);
+INT        GetTempFileName(BYTE,LPCSTR,UINT,LPSTR);
+WORD       GetTextAlign(HDC);
+short      GetTextCharacterExtra(HDC);
+COLORREF   GetTextColor(HDC);
+DWORD      GetTextExtent(HDC,LPCSTR,short);
+INT        GetTextFace(HDC,INT,LPSTR);
+BOOL       GetTextMetrics(HDC,LPTEXTMETRIC16);
+LPINT16    GetThresholdEvent(void);
+int        GetThresholdStatus(void);
+DWORD      GetTickCount(void);
+HWND       GetTopWindow(HWND);
+LONG       GetVersion(void);
+DWORD      GetViewportExt(HDC);
+DWORD      GetViewportOrg(HDC);
+BOOL       GetWinDebugInfo(LPWINDEBUGINFO,UINT);
+LONG       GetWinFlags(void);
+HWND       GetWindow(HWND,WORD);
+HDC        GetWindowDC(HWND);
+DWORD      GetWindowExt(HDC);
+DWORD      GetWindowOrg(HDC);
+HANDLE     GetWindowTask(HWND);
+int        GetWindowTextLength(HWND);
+UINT       GetWindowsDirectory(LPSTR,UINT);
+DWORD      GlobalDOSAlloc(DWORD);
+WORD       GlobalDOSFree(WORD);
+ATOM       GlobalDeleteAtom(ATOM);
+void       GlobalFix(HGLOBAL16);
+void       GlobalFreeAll(HGLOBAL16);
+HGLOBAL16  GlobalLRUNewest(HGLOBAL16);
+HGLOBAL16  GlobalLRUOldest(HGLOBAL16);
+void       GlobalNotify(FARPROC);
+WORD       GlobalPageLock(HGLOBAL16);
+WORD       GlobalPageUnlock(HGLOBAL16);
+BOOL       GlobalUnWire(HGLOBAL16);
+void       GlobalUnfix(HGLOBAL16);
+SEGPTR     GlobalWire(HGLOBAL16);
+BOOL       GrayString(HDC,HBRUSH,FARPROC,LPARAM,INT,INT,INT,INT,INT);
+void       HideCaret(HWND);
+BOOL       HiliteMenuItem(HWND,HMENU,UINT,UINT);
+BOOL       InSendMessage(void);
+WORD       InitAtomTable(WORD);
+HRGN       InquireVisRgn(HDC);
+int        IntersectClipRect(HDC,short,short,short,short);
+int        IntersectVisRect(HDC,short,short,short,short);
+void       InvalidateRgn(HWND32,HRGN32,BOOL32);
+BOOL       InvertRgn(HDC,HRGN);
+BOOL       IsBadCodePtr(SEGPTR);
+BOOL       IsBadHugeReadPtr(SEGPTR,DWORD);
+BOOL       IsBadHugeWritePtr(SEGPTR,DWORD);
+BOOL       IsBadReadPtr(SEGPTR,WORD);
+BOOL       IsBadStringPtr(SEGPTR,WORD);
+BOOL       IsBadWritePtr(SEGPTR,WORD);
+BOOL       IsCharAlpha(char);
+BOOL       IsCharAlphaNumeric(char);
+BOOL       IsCharLower(char);
+BOOL       IsCharUpper(char);
+BOOL       IsChild(HWND,HWND);
+BOOL       IsClipboardFormatAvailable(WORD);
+BOOL       IsDialogMessage(HWND,LPMSG16);
+WORD       IsDlgButtonChecked(HWND,WORD);
+BOOL       IsGDIObject(HANDLE);
+BOOL       IsIconic(HWND);
+BOOL       IsMenu(HMENU);
+BOOL       IsTask(HTASK);
+HTASK      IsTaskLocked(void);
+BOOL       IsWindow(HWND);
+BOOL       IsWindowEnabled(HWND);
+BOOL       IsWindowUnicode(HWND);
+BOOL       IsWindowVisible(HWND);
+BOOL       IsZoomed(HWND);
+BOOL       KillSystemTimer(HWND,WORD);
+BOOL       KillTimer(HWND,WORD);
+void       LimitEmsPages(DWORD);
+void       LineDDA(short,short,short,short,FARPROC,long);
+BOOL       LineTo(HDC,short,short);
+HANDLE     LoadAccelerators(HANDLE,SEGPTR);
+HBITMAP    LoadBitmap(HANDLE,SEGPTR);
+HCURSOR    LoadCursor(HANDLE,SEGPTR);
+HICON      LoadIcon(HANDLE,SEGPTR);
+HANDLE     LoadLibrary(LPCSTR);
+HMENU      LoadMenu(HANDLE,SEGPTR);
+HANDLE     LoadModule(LPCSTR,LPVOID);
+HGLOBAL    LoadResource(HINSTANCE,HRSRC);
+int        LoadString(HANDLE,WORD,LPSTR,int);
+BOOL       LocalInit(HANDLE,WORD,WORD);
+FARPROC    LocalNotify(FARPROC);
+LPVOID     LockResource(HGLOBAL);
+HGLOBAL    LockSegment(HGLOBAL);
+HMENU      LookupMenuHandle(HMENU,INT);
+FARPROC    MakeProcInstance(FARPROC,HANDLE);
+WORD       MapVirtualKey(WORD,WORD);
+void       MessageBeep(WORD);
+int        MessageBox(HWND,LPCSTR,LPCSTR,WORD);
+DWORD      MoveTo(HDC,short,short);
+BOOL       MoveWindow(HWND,short,short,short,short,BOOL);
+DWORD      OemKeyScan(WORD);
+BOOL       OemToAnsi(LPSTR,LPSTR);
+void       OemToAnsiBuff(LPSTR,LPSTR,INT);
+int        OffsetClipRgn(HDC,short,short);
+BOOL       OpenClipboard(HWND);
+int        OpenComm(LPCSTR,UINT,UINT);
+HFILE      OpenFile(LPCSTR,OFSTRUCT*,UINT);
+BOOL       OpenIcon(HWND);
+int        OpenSound(void);
+void       OutputDebugString(LPCSTR);
+BOOL       PaintRgn(HDC,HRGN);
+BOOL       PatBlt(HDC,short,short,short,short,DWORD);
+BOOL       Pie(HDC,INT,INT,INT,INT,INT,INT,INT,INT);
+BOOL       PlayMetaFile(HDC,HANDLE);
+void       PlayMetaFileRecord(HDC,LPHANDLETABLE,LPMETARECORD,WORD);
+BOOL       PostAppMessage(HANDLE,WORD,WORD,LONG);
+void       PostEvent(HTASK);
+BOOL       PostMessage(HWND,WORD,WORD,LONG);
+void       PostQuitMessage(INT);
+WORD       PrestoChangoSelector(WORD,WORD);
+void       ProfClear(void);
+void       ProfFinish(void);
+void       ProfFlush(void);
+int        ProfInsChk(void);
+void       ProfSampRate(int,int);
+void       ProfSetup(int,int);
+void       ProfStart(void);
+void       ProfStop(void);
+BOOL       PtInRegion(HRGN32,INT32,INT32);
+BOOL       PtVisible(HDC,short,short);
+int        ReadComm(int,LPSTR,int);
+WORD       RealizeDefaultPalette(HDC);
+UINT       RealizePalette(HDC);
+BOOL       Rectangle(HDC,INT,INT,INT,INT);
+WORD       RegisterClipboardFormat(LPCSTR);
+void       ReleaseCapture(void);
+int        ReleaseDC(HWND,HDC);
+BOOL       RemoveFontResource(LPSTR);
+BOOL       RemoveMenu(HMENU,UINT,UINT);
+HANDLE     RemoveProp(HWND,SEGPTR);
+void       ReplyMessage(LRESULT);
+HDC        ResetDC(HDC,LPVOID);
+BOOL       ResizePalette(HPALETTE16,UINT);
+BOOL       RestoreDC(HDC,short);
+int        RestoreVisRgn(HDC);
+BOOL       RoundRect(HDC,INT,INT,INT,INT,INT,INT);
+int        SaveDC(HDC);
+HRGN       SaveVisRgn(HDC);
+void       ScrollChildren(HWND,UINT,WPARAM,LPARAM);
+BOOL       ScrollDC(HDC,short,short,LPRECT16,LPRECT16,HRGN,LPRECT16);
+void       ScrollWindow(HWND,short,short,LPRECT16,LPRECT16);
+int        ScrollWindowEx(HWND,short,short,LPRECT16,LPRECT16,HRGN,LPRECT16,WORD);
+int        SelectClipRgn(HDC,HRGN);
+HANDLE     SelectObject(HDC,HANDLE);
+HPALETTE16 SelectPalette(HDC,HPALETTE16,BOOL);
+int        SelectVisRgn(HDC,HRGN);
+WORD       SelectorAccessRights(WORD,WORD,WORD);
+HWND       SetActiveWindow(HWND);
+DWORD      SetBkColor(HDC,COLORREF);
+WORD       SetBkMode(HDC,WORD);
+DWORD      SetBrushOrg(HDC,short,short);
+HWND       SetCapture(HWND);
+void       SetCaretBlinkTime(WORD);
+void       SetCaretPos(short,short);
+HANDLE     SetClipboardData(WORD,HANDLE);
+HWND       SetClipboardViewer(HWND);
+int        SetCommBreak(int);
+UINT*      SetCommEventMask(int,UINT);
+int        SetCommState(DCB*);
+void       SetConvertHook(BOOL);
+BOOL       SetConvertParams(int,int);
+BOOL32     SetCurrentDirectory(LPCSTR);
+HCURSOR    SetCursor(HCURSOR);
+void       SetCursorPos(short,short);
+BOOL       SetDCHook(HDC,FARPROC16,DWORD);
+void       SetDCState(HDC,HDC);
+int        SetDIBits(HDC,HANDLE,WORD,WORD,LPSTR,LPBITMAPINFO,WORD);
+int        SetDIBitsToDevice(HDC,short,short,WORD,WORD,WORD,WORD,WORD,WORD,LPSTR,LPBITMAPINFO,WORD);
+BOOL       SetDeskPattern(void);
+BOOL       SetDeskWallPaper(LPCSTR);
+void       SetDoubleClickTime(WORD);
+int        SetEnvironment(LPSTR,LPSTR,WORD);
+UINT       SetErrorMode(UINT);
+HWND       SetFocus(HWND);
+WORD       SetHandleCount(WORD);
+WORD       SetHookFlags(HDC,WORD);
+void       SetKeyboardState(BYTE*);
+WORD       SetMapMode(HDC,WORD);
+DWORD      SetMapperFlags(HDC,DWORD);
+BOOL       SetMenu(HWND,HMENU);
+BOOL       SetMenuItemBitmaps(HMENU,UINT,UINT,HBITMAP,HBITMAP);
+BOOL       SetMessageQueue(int);
+HANDLE     SetMetaFileBits(HANDLE);
+WORD       SetPaletteEntries(HPALETTE16,WORD,WORD,LPPALETTEENTRY);
+HWND       SetParent(HWND,HWND);
+COLORREF   SetPixel(HDC,short,short,COLORREF);
+WORD       SetPolyFillMode(HDC,WORD);
+BOOL       SetProp(HWND,SEGPTR,HANDLE);
+WORD       SetROP2(HDC,WORD);
+void       SetRectRgn(HRGN32,INT32,INT32,INT32,INT32);
+WORD       SetRelAbs(HDC,WORD);
+FARPROC    SetResourceHandler(HANDLE,LPSTR,FARPROC);
+int        SetScrollPos(HWND,int,int,BOOL);
+void       SetScrollRange(HWND,int,int,int,BOOL);
+WORD       SetSelectorBase(WORD,DWORD);
+WORD       SetSelectorLimit(WORD,DWORD);
+int        SetSoundNoise(int,int);
+WORD       SetStretchBltMode(HDC,WORD);
+LONG       SetSwapAreaSize(WORD);
+void       SetSysColors(int,LPINT16,COLORREF*);
+HWND       SetSysModalWindow(HWND);
+WORD       SetSystemPaletteUse(HDC,WORD);
+BOOL       SetSystemPowerState(BOOL, BOOL);
+BOOL       SetSystemTime(const SYSTEMTIME*);
+WORD       SetSystemTimer(HWND,WORD,WORD,FARPROC);
+HQUEUE     SetTaskQueue(HTASK,HQUEUE);
+WORD       SetTextAlign(HDC,WORD);
+short      SetTextCharacterExtra(HDC,short);
+DWORD      SetTextColor(HDC,DWORD);
+short      SetTextJustification(HDC,short,short);
+WORD       SetTimer(HWND,WORD,WORD,FARPROC);
+int        SetVoiceAccent(int,int,int,int,int);
+int        SetVoiceEnvelope(int,int,int);
+int        SetVoiceNote(int,int,int,int);
+int        SetVoiceQueueSize(int,int);
+int        SetVoiceSound(int,LONG,int);
+int        SetVoiceThreshold(int,int);
+BOOL       SetWinDebugInfo(LPWINDEBUGINFO);
+BOOL       SetWindowPos(HWND,HWND,INT,INT,INT,INT,WORD);
+FARPROC    SetWindowsHook(short,FARPROC);
+HHOOK      SetWindowsHookEx(short,HOOKPROC,HINSTANCE,HTASK);
+HINSTANCE  ShellExecute(HWND,LPCSTR,LPCSTR,LPSTR,LPCSTR,INT);
+void       ShowCaret(HWND);
+int        ShowCursor(BOOL);
+void       ShowOwnedPopups(HWND,BOOL);
+void       ShowScrollBar(HWND,WORD,BOOL);
+BOOL       ShowWindow(HWND,int);
+DWORD      SizeofResource(HINSTANCE,HRSRC);
+VOID       Sleep(DWORD); /* Win32 */
+int        StartSound(void);
+int        StopSound(void);
+BOOL       StretchBlt(HDC,short,short,short,short,HDC,short,short,short,short,DWORD);
+int        StretchDIBits(HDC,WORD,WORD,WORD,WORD,WORD,WORD,WORD,WORD,LPSTR,LPBITMAPINFO,WORD,DWORD);
+BOOL       SwapMouseButton(BOOL);
+void       SwapRecording(WORD);
+void       SwitchStackBack(void);
+void       SwitchStackTo(WORD,WORD,WORD);
+int        SyncAllVoices(void);
+BOOL       SystemParametersInfo(UINT,UINT,LPVOID,UINT);
+LONG       TabbedTextOut(HDC,short,short,LPSTR,short,short,LPINT16,short);
+int        Throw(LPCATCHBUF,int);
+int        ToAscii(WORD,WORD,LPSTR,LPVOID,WORD);
+int        TranslateAccelerator(HWND,HANDLE,LPMSG16);
+BOOL       TranslateMDISysAccel(HWND,LPMSG16);
+BOOL       TranslateMessage(LPMSG16);
+int        TransmitCommChar(int,char);
+int        UngetCommChar(int,char);
+BOOL       UnhookWindowsHook(short,FARPROC);
+BOOL       UnhookWindowsHookEx(HHOOK);
+void       UnlockSegment(HGLOBAL);
+BOOL       UnrealizeObject(HBRUSH);
+int        UpdateColors(HDC);
+void       UpdateWindow(HWND32);
+void       UserYield(void);
+void       ValidateCodeSegments(void);
+LPSTR      ValidateFreeSpaces(void);
+void       ValidateRgn(HWND32,HRGN32);
+WORD       VkKeyScan(WORD);
+SEGPTR     WIN16_GlobalLock16(HGLOBAL16);
+SEGPTR     WIN16_LockResource(HANDLE);
+BOOL       WaitEvent(HTASK);
+void       WaitMessage(void);
+int        WaitSoundState(int);
+HANDLE     WinExec(LPSTR,WORD);
+BOOL       WinHelp(HWND,LPSTR,WORD,DWORD);
+int        WriteComm(int,LPSTR,int);
+void       WriteOutProfiles(void);
+BOOL       WritePrivateProfileString(LPCSTR,LPCSTR,LPCSTR,LPCSTR);
+BOOL       WriteProfileString(LPCSTR,LPCSTR,LPCSTR);
+void       Yield(void);
+LONG       _hread(HFILE,SEGPTR,LONG);
+LONG       _hwrite(HFILE,LPCSTR,LONG);
+HFILE      _lclose(HFILE);
+HFILE      _lcreat(LPCSTR,INT);
+LONG       _llseek(HFILE,LONG,INT);
+HFILE      _lopen(LPCSTR,INT);
+INT        _lread(HFILE,SEGPTR,WORD);
+INT        _lwrite(HFILE,LPCSTR,WORD);
+
 
 #ifdef WINELIB
 #define WINELIB_UNIMP(x) fprintf (stderr, "WineLib: Unimplemented %s\n", x)
diff --git a/include/winreg.h b/include/winreg.h
index 62c4529..f5954ad 100644
--- a/include/winreg.h
+++ b/include/winreg.h
@@ -1,8 +1,6 @@
 /*
  * 				Shell Library definitions
  */
-#include "wintypes.h"
-
 #ifndef __WINE_WINREG_H
 #define __WINE_WINREG_H
 
@@ -85,27 +83,6 @@
 				 KEY_READ|KEY_WRITE|	\
 				 KEY_CREATE_LINK	\
 				)
-/* one value of a key */
-typedef struct tagKEYVALUE {
-	LPWSTR	name;	/* name of value (UNICODE) or NULL for win31 */
-	DWORD	type;	/* type of value */
-	DWORD	len;	/* length of data */
-	DWORD	lastmodified; /* time of seconds since 1.1.1970 */
-	LPBYTE	data;	/* content, may be strings, binaries, etc. */
-} KEYVALUE,*LPKEYVALUE;
-
-/* a registry key */
-typedef struct tagKEYSTRUCT {
-	LPWSTR			keyname;	/* name of THIS key (UNICODE) */
-	DWORD			flags;		/* flags. */
-	LPWSTR			class;
-	/* values */
-	DWORD			nrofvalues;	/* nr of values in THIS key */
-	LPKEYVALUE		values;		/* values in THIS key */
-	/* key management pointers */
-	struct tagKEYSTRUCT	*next;		/* next key on same hierarchy */
-	struct tagKEYSTRUCT	*nextsub;	/* keys that hang below THIS key */
-} KEYSTRUCT, *LPKEYSTRUCT;
 
 void SHELL_Init();
 void SHELL_SaveRegistry();
diff --git a/include/wintypes.h b/include/wintypes.h
index 97718cc..33bcebd 100644
--- a/include/wintypes.h
+++ b/include/wintypes.h
@@ -152,16 +152,19 @@
 /* Callback function pointers types for Win16. */
 
 #ifdef WINELIB
-typedef LRESULT (*WNDPROC16)(HWND16,UINT16,WPARAM16,LPARAM);
+typedef LRESULT (*DLGPROC16)(HWND16,UINT16,WPARAM16,LPARAM);
 typedef LRESULT (*FARPROC16)();
+typedef LRESULT (*WNDPROC16)(HWND16,UINT16,WPARAM16,LPARAM);
 #else
 /* Function pointers are SEGPTR in Win16 */
+typedef SEGPTR DLGPROC16;
 typedef SEGPTR FARPROC16;
 typedef SEGPTR WNDPROC16;
 #endif
 
 /* Callback function pointers types for Win32. */
 
+typedef LRESULT (*DLGPROC32)(HWND32,UINT32,WPARAM32,LPARAM);
 typedef LRESULT (*FARPROC32)();
 typedef LRESULT (*WNDPROC32)(HWND32,UINT32,WPARAM32,LPARAM);
 
@@ -226,71 +229,6 @@
 DECL_WINELIB_TYPE(FARPROC);
 DECL_WINELIB_TYPE(WNDPROC);
 
-/* Library data types defined as a transition aid for the emulator. */
-/* These should _not_ be used in the emulator and will be removed someday. */
-
-#ifndef NO_TRANSITION_TYPES
-
-#ifndef WINELIB
-typedef INT16 INT;
-typedef UINT16 UINT;
-typedef BOOL16 BOOL;
-typedef WPARAM16 WPARAM;
-typedef HANDLE16 HANDLE;
-typedef HANDLE16 HBITMAP;
-typedef HANDLE16 HBRUSH;
-typedef HANDLE16 HCURSOR;
-typedef HANDLE16 HDC;
-typedef HANDLE16 HDRVR;
-typedef HANDLE16 HFONT;
-typedef HANDLE16 HGLOBAL;
-typedef HANDLE16 HICON;
-typedef HANDLE16 HINSTANCE;
-typedef HANDLE16 HMENU;
-typedef HANDLE16 HMETAFILE;
-typedef HANDLE16 HMIDI;
-typedef HANDLE16 HMIDIIN;
-typedef HANDLE16 HMIDIOUT;
-typedef HANDLE16 HMMIO;
-typedef HANDLE16 HMODULE;
-typedef HANDLE16 HQUEUE;
-typedef HANDLE16 HRGN;
-typedef HANDLE16 HRSRC;
-typedef HANDLE16 HTASK;
-typedef HANDLE16 HWAVE;
-typedef HANDLE16 HWAVEIN;
-typedef HANDLE16 HWAVEOUT;
-typedef HANDLE16 HWND;
-typedef FARPROC16 FARPROC;
-typedef WNDPROC16 WNDPROC;
-#endif  /* WINELIB */
-
-/* Callback function pointers types. */
-
-#ifdef WINELIB
-typedef LONG (*DRIVERPROC)(DWORD, HDRVR, UINT, LPARAM, LPARAM);
-typedef int (*EDITWORDBREAKPROC)(LPSTR lpch, int ichCurrent, int cch,int code);
-/*typedef int (*FONTENUMPROC)(const LOGFONT*,const TEXTMETRIC*,DWORD,LPARAM);*/
-typedef int (*FONTENUMPROC)(const void*,const void*,DWORD,LPARAM);
-typedef int (*GOBJENUMPROC)(LPVOID,LPARAM);
-/*typedef int (*MFENUMPROC)(HDC,HANDLETABLE*,METARECORD*,int,LPARAM);*/
-typedef int (*MFENUMPROC)(HDC,void*,void*,int,LPARAM);
-typedef BOOL (*PROPENUMPROC)(HWND,LPCTSTR,HANDLE);
-typedef LRESULT (*WNDENUMPROC)(HWND,LPARAM);
-#else
-typedef SEGPTR DRIVERPROC;
-typedef SEGPTR EDITWORDBREAKPROC;
-typedef SEGPTR FONTENUMPROC;
-typedef SEGPTR GOBJENUMPROC;
-typedef SEGPTR MFENUMPROC;
-typedef SEGPTR PROPENUMPROC;
-typedef SEGPTR WNDENUMPROC;
-#endif
-typedef FARPROC DLGPROC;
-typedef FARPROC HOOKPROC;
-
-#endif  /* NO_TRANSITION_TYPES */
-
 /* Misc. constants. */
 
 #ifdef FALSE
diff --git a/loader/Makefile.in b/loader/Makefile.in
index 7ae4cf8..166ce95 100644
--- a/loader/Makefile.in
+++ b/loader/Makefile.in
@@ -9,8 +9,8 @@
 	ne_resource.c \
 	pe_image.c \
 	pe_resource.c \
-	signal.c \
 	resource.c \
+	signal.c \
 	task.c
 
 all: $(MODULE).o
diff --git a/loader/builtin.c b/loader/builtin.c
index 76c0d29..7cfb347 100644
--- a/loader/builtin.c
+++ b/loader/builtin.c
@@ -100,9 +100,11 @@
 extern const DLL_DESCRIPTOR OLE32_Descriptor;
 extern const DLL_DESCRIPTOR GDI32_Descriptor;
 extern const DLL_DESCRIPTOR KERNEL32_Descriptor;
+extern const DLL_DESCRIPTOR LZ32_Descriptor;
 extern const DLL_DESCRIPTOR NTDLL_Descriptor;
 extern const DLL_DESCRIPTOR SHELL32_Descriptor;
 extern const DLL_DESCRIPTOR USER32_Descriptor;
+extern const DLL_DESCRIPTOR VERSION_Descriptor;
 extern const DLL_DESCRIPTOR WINSPOOL_Descriptor;
 extern const DLL_DESCRIPTOR WSOCK32_Descriptor;
 
@@ -147,9 +149,11 @@
     { &OLE32_Descriptor,    0 },
     { &GDI32_Descriptor,    0 },
     { &KERNEL32_Descriptor, DLL_FLAG_ALWAYS_USED },
+    { &LZ32_Descriptor,     0 },
     { &NTDLL_Descriptor,    0 },
     { &SHELL32_Descriptor,  0 },
     { &USER32_Descriptor,   0 },
+    { &VERSION_Descriptor,  0 },
     { &WINSPOOL_Descriptor, 0 },
     { &WSOCK32_Descriptor,  0 },
     /* Last entry */
@@ -202,11 +206,11 @@
     /* Fix the name in case we have a full path and extension */
 
     if ((p = strrchr( name, '\\' ))) name = p + 1;
-    lstrcpyn( dllname, name, sizeof(dllname) );
+    lstrcpyn32A( dllname, name, sizeof(dllname) );
     if ((p = strrchr( dllname, '.' ))) *p = '\0';
 
     for (table = BuiltinDLLs; table->descr; table++)
-        if (!lstrcmpi( table->descr->name, dllname )) break;
+        if (!lstrcmpi32A( table->descr->name, dllname )) break;
     if (!table->descr) return 0;
     if ((table->flags & DLL_FLAG_NOT_USED) && !force) return 0;
 
@@ -389,7 +393,7 @@
         if (p == str) return FALSE;
         for (dll = BuiltinDLLs; dll->descr; dll++)
         {
-            if (!lstrncmpi( str, dll->descr->name, (int)(p - str) ))
+            if (!lstrncmpi32A( str, dll->descr->name, (int)(p - str) ))
             {
                 if (str[-1] == '-')
                 {
diff --git a/loader/module.c b/loader/module.c
index 9257c75..d394aa3 100644
--- a/loader/module.c
+++ b/loader/module.c
@@ -827,10 +827,10 @@
         if (!(modulename = strrchr( modulepath, '\\' )))
             modulename = modulepath;
         else modulename++;
-        if (!lstrcmpi( modulename, filename )) return hModule;
+        if (!lstrcmpi32A( modulename, filename )) return hModule;
 
         name_table = (BYTE *)pModule + pModule->name_table;
-        if ((*name_table == len) && !lstrncmpi(filename, name_table+1, len))
+        if ((*name_table == len) && !lstrncmpi32A(filename, name_table+1, len))
             return hModule;
         hModule = pModule->next;
     }
@@ -1193,7 +1193,7 @@
 
     hModule = GetExePtr( hModule );  /* In case we were passed an hInstance */
     if (!(pModule = MODULE_GetPtr( hModule ))) return 0;
-    lstrcpyn( lpFileName, NE_MODULE_NAME(pModule), nSize );
+    lstrcpyn32A( lpFileName, NE_MODULE_NAME(pModule), nSize );
     dprintf_module( stddeb, "GetModuleFilename: %s\n", lpFileName );
     return strlen(lpFileName);
 }
@@ -1221,7 +1221,7 @@
     if (handle == (HANDLE)2)  /* file not found */
     {
         char buffer[256];
-        lstrcpyn( buffer, libname, 252 );
+        lstrcpyn32A( buffer, libname, 252 );
         strcat( buffer, ".dll" );
         handle = LoadModule( buffer, (LPVOID)-1 );
     }
@@ -1253,8 +1253,13 @@
     char *p, *cmdline, filename[256];
     static int use_load_module = 1;
 
-    if (!(cmdShowHandle = GlobalAlloc16( 0, 2 * sizeof(WORD) ))) return 0;
-    if (!(cmdLineHandle = GlobalAlloc16( 0, 256 ))) return 0;
+    if (!(cmdShowHandle = GlobalAlloc16( 0, 2 * sizeof(WORD) )))
+        return 8;  /* Out of memory */
+    if (!(cmdLineHandle = GlobalAlloc16( 0, 256 )))
+    {
+        GlobalFree16( cmdShowHandle );
+        return 8;  /* Out of memory */
+    }
 
       /* Store nCmdShow */
 
@@ -1265,9 +1270,9 @@
       /* Build the filename and command-line */
 
     cmdline = (char *)GlobalLock16( cmdLineHandle );
-    lstrcpyn( filename, lpCmdLine, sizeof(filename) - 4 /* for extension */ );
+    lstrcpyn32A(filename, lpCmdLine, sizeof(filename) - 4 /* for extension */);
     for (p = filename; *p && (*p != ' ') && (*p != '\t'); p++);
-    if (*p) lstrcpyn( cmdline, p + 1, 128 );
+    if (*p) lstrcpyn32A( cmdline, p + 1, 128 );
     else cmdline[0] = '\0';
     *p = '\0';
 
diff --git a/loader/ne_resource.c b/loader/ne_resource.c
index bf88022..fc3081b 100644
--- a/loader/ne_resource.c
+++ b/loader/ne_resource.c
@@ -64,8 +64,8 @@
                 if (p[1] & 0x8000)
                 {
                     if (!HIWORD(typeId)) continue;
-                    if (lstrcmpi( (char *)PTR_SEG_TO_LIN(typeId),
-                                  (char *)(p + 3) )) continue;
+                    if (lstrcmpi32A( (char *)PTR_SEG_TO_LIN(typeId),
+                                     (char *)(p + 3) )) continue;
                 }
                 else if (HIWORD(typeId) || ((typeId & ~0x8000)!= p[1]))
                   continue;
@@ -75,7 +75,7 @@
                 if (p[2] & 0x8000)
                 {
                     if (!HIWORD(resId)) continue;
-                    if (lstrcmpi( (char *)PTR_SEG_TO_LIN(resId),
+                    if (lstrcmpi32A( (char *)PTR_SEG_TO_LIN(resId),
                                (char*)(p+3)+strlen((char*)(p+3))+1 )) continue;
                     
                 }
@@ -116,7 +116,7 @@
         {
             if (pNameInfo->id & 0x8000) continue;
             p = (BYTE *)pModule + pModule->res_table + pNameInfo->id;
-            if ((*p == len) && !lstrncmpi( p+1, str, len ))
+            if ((*p == len) && !lstrncmpi32A( p+1, str, len ))
                 return (HRSRC)((int)pNameInfo - (int)pModule);
         }
     }
@@ -163,7 +163,7 @@
             if (!(pTypeInfo->type_id & 0x8000))
             {
                 BYTE *p = (BYTE*)pModule+pModule->res_table+pTypeInfo->type_id;
-                if ((*p == len) && !lstrncmpi( p+1, str, len ))
+                if ((*p == len) && !lstrncmpi32A( p+1, str, len ))
                 {
                     dprintf_resource( stddeb, "  Found type '%s'\n", str );
                     hRsrc = NE_FindResourceFromType(pModule, pTypeInfo, resId);
diff --git a/loader/resource.c b/loader/resource.c
index 56de36f..9f0aa83 100644
--- a/loader/resource.c
+++ b/loader/resource.c
@@ -304,7 +304,7 @@
 /**********************************************************************
  *			TranslateAccelerator 	[USER.178]
  */
-int TranslateAccelerator(HWND hWnd, HANDLE hAccel, LPMSG msg)
+int TranslateAccelerator(HWND hWnd, HANDLE hAccel, LPMSG16 msg)
 {
     ACCELHEADER	*lpAccelTbl;
     int 	i;
diff --git a/loader/signal.c b/loader/signal.c
index c0f422f..0d200ca 100644
--- a/loader/signal.c
+++ b/loader/signal.c
@@ -70,50 +70,54 @@
 
 
 /**********************************************************************
- *		win_fault
+ *		SIGNAL_trap
+ *
+ * SIGTRAP handler.
+ */
+#ifdef linux
+static void SIGNAL_trap(int signal, struct sigcontext_struct context_struct)
+{
+    struct sigcontext_struct *context = &context_struct;
+#elif defined(__svr4__) || defined(_SCO_DS)
+static void SIGNAL_trap(int signal, void *siginfo, ucontext_t *context)
+{
+#else
+static void SIGNAL_trap(int signal, int code, struct sigcontext *context)
+{
+#endif
+    wine_debug( signal, context );  /* Enter our debugger */
+}
+
+
+/**********************************************************************
+ *		SIGNAL_fault
  *
  * Segfault handler.
  */
 #ifdef linux
-static void win_fault(int signal, struct sigcontext_struct context_struct)
+static void SIGNAL_fault(int signal, struct sigcontext_struct context_struct)
 {
     struct sigcontext_struct *context = &context_struct;
 #elif defined(__svr4__) || defined(_SCO_DS)
-static void win_fault(int signal, void *siginfo, ucontext_t *context)
+static void SIGNAL_fault(int signal, void *siginfo, ucontext_t *context)
 {
 #else
-static void win_fault(int signal, int code, struct sigcontext *context)
+static void SIGNAL_fault(int signal, int code, struct sigcontext *context)
 {
 #endif
-    if (signal == SIGTRAP)
+    if (CS_reg(context) == WINE_CODE_SELECTOR)
     {
-        /* If SIGTRAP not caused by breakpoint or single step 
-           don't jump into the debugger */
-        if (!(EFL_reg(context) & STEP_FLAG))
-        {
-            DBG_ADDR addr;
-            addr.seg = CS_reg(context);
-            addr.off = EIP_reg(context) - 1;
-            if (DEBUG_FindBreakpoint(&addr) == -1) return;
-        }
+        fprintf( stderr, "Segmentation fault in Wine program (%x:%lx)."
+                         "  Please debug.\n",
+                 CS_reg(context), EIP_reg(context) );
     }
-    else if (signal != SIGHUP)
+    else
     {
-        if (CS_reg(context) == WINE_CODE_SELECTOR)
-        {
-            fprintf(stderr, "Segmentation fault in Wine program (%x:%lx)."
-                            "  Please debug.\n",
-                            CS_reg(context), EIP_reg(context) );
-        }
-        else
-        {
-            if (INSTR_EmulateInstruction( context )) return;
-            fprintf( stderr, "Segmentation fault in Windows program %x:%lx.\n",
-                     CS_reg(context), EIP_reg(context) );
-        }
+        if (INSTR_EmulateInstruction( context )) return;
+        fprintf( stderr, "Segmentation fault in Windows program %x:%lx.\n",
+                 CS_reg(context), EIP_reg(context) );
     }
-
-    wine_debug( signal, context );  /* Enter our debugger */
+    wine_debug( signal, context );
 }
 
 
@@ -201,13 +205,13 @@
 #endif  /* __svr4__ || _SCO_DS */
     
     SIGNAL_SetHandler( SIGALRM, (void (*)())wine_timer );
-    SIGNAL_SetHandler( SIGSEGV, (void (*)())win_fault );
-    SIGNAL_SetHandler( SIGILL,  (void (*)())win_fault );
-    SIGNAL_SetHandler( SIGFPE,  (void (*)())win_fault );
-    SIGNAL_SetHandler( SIGTRAP, (void (*)())win_fault ); /* For debugger */
-    SIGNAL_SetHandler( SIGHUP,  (void (*)())win_fault ); /* For forced break */
+    SIGNAL_SetHandler( SIGSEGV, (void (*)())SIGNAL_fault );
+    SIGNAL_SetHandler( SIGILL,  (void (*)())SIGNAL_fault );
+    SIGNAL_SetHandler( SIGFPE,  (void (*)())SIGNAL_fault );
+    SIGNAL_SetHandler( SIGTRAP, (void (*)())SIGNAL_trap ); /* debugger */
+    SIGNAL_SetHandler( SIGHUP,  (void (*)())SIGNAL_trap ); /* forced break */
 #ifdef SIGBUS
-    SIGNAL_SetHandler( SIGBUS,  (void (*)())win_fault );
+    SIGNAL_SetHandler( SIGBUS,  (void (*)())SIGNAL_fault );
 #endif
 #ifdef CONFIG_IPC
     SIGNAL_SetHandler( SIGUSR2, (void (*)())stop_wait ); /* For IPC */
diff --git a/loader/task.c b/loader/task.c
index db91fd0..8132b9d 100644
--- a/loader/task.c
+++ b/loader/task.c
@@ -127,7 +127,7 @@
 
     for (e = environ, size = initial_size; *e; e++)
     {
-	if (lstrncmpi(*e, "path=", 5))
+	if (lstrncmpi32A(*e, "path=", 5))
 	{
             int len = strlen(*e) + 1;
             if (size + len >= 32767)
@@ -149,7 +149,7 @@
 
     for (e = environ, size = initial_size; *e; e++)
     {
-	if (lstrncmpi(*e, "path=", 5))
+	if (lstrncmpi32A(*e, "path=", 5))
 	{
             int len = strlen(*e) + 1;
             if (size + len >= 32767) break;
@@ -478,7 +478,7 @@
     memset( pTask->pdb.fileHandles, 0xff, sizeof(pTask->pdb.fileHandles) );
     pTask->pdb.environment    = hEnvironment;
     pTask->pdb.nbFiles        = 20;
-    lstrcpyn( pTask->pdb.cmdLine + 1, cmdLine, 127 );
+    lstrcpyn32A( pTask->pdb.cmdLine + 1, cmdLine, 127 );
     pTask->pdb.cmdLine[0] = strlen( pTask->pdb.cmdLine + 1 );
 
       /* Get the compatibility flags */
diff --git a/memory/Makefile.in b/memory/Makefile.in
index 4287234..a2e5b36 100644
--- a/memory/Makefile.in
+++ b/memory/Makefile.in
@@ -7,7 +7,8 @@
 	heap.c \
 	ldt.c \
 	local.c \
-	selector.c
+	selector.c \
+	string.c
 
 all: $(MODULE).o
 
diff --git a/memory/atom.c b/memory/atom.c
index bde08be..4d8db56 100644
--- a/memory/atom.c
+++ b/memory/atom.c
@@ -141,7 +141,7 @@
     {
 	entryPtr = ATOM_MakePtr( selector, entry );
 	if ((entryPtr->length == len) && 
-	    (!lstrncmpi( entryPtr->str, str, len )))
+	    (!lstrncmpi32A( entryPtr->str, str, len )))
 	{
 	    entryPtr->refCount++;
 	    return HANDLETOATOM( entry );
@@ -218,7 +218,7 @@
     {
 	ATOMENTRY * entryPtr = ATOM_MakePtr( selector, entry );
 	if ((entryPtr->length == len) && 
-	    (!lstrncmpi( entryPtr->str, str, len )))
+	    (!lstrncmpi32A( entryPtr->str, str, len )))
 	    return HANDLETOATOM( entry );
 	entry = entryPtr->next;
     }
@@ -294,7 +294,7 @@
         /* If the string is in the same data segment as the atom table, make */
         /* a copy of the string to be sure it doesn't move in linear memory. */
         char buffer[256];
-        lstrcpyn( buffer, (char *)PTR_SEG_TO_LIN(str), sizeof(buffer) );
+        lstrcpyn32A( buffer, (char *)PTR_SEG_TO_LIN(str), sizeof(buffer) );
         atom = ATOM_AddAtom( ds, buffer );
     }
     else atom = ATOM_AddAtom( ds, (LPCSTR)PTR_SEG_TO_LIN(str) );
diff --git a/memory/global.c b/memory/global.c
index c8e4d5d..1f58f09 100644
--- a/memory/global.c
+++ b/memory/global.c
@@ -93,8 +93,8 @@
  * Create a global heap block for a fixed range of linear memory.
  */
 HGLOBAL16 GLOBAL_CreateBlock( WORD flags, const void *ptr, DWORD size,
-                              HGLOBAL16 hOwner, BOOL isCode,
-                              BOOL is32Bit, BOOL isReadOnly,
+                              HGLOBAL16 hOwner, BOOL16 isCode,
+                              BOOL16 is32Bit, BOOL16 isReadOnly,
                               SHMDATA *shmdata  )
 {
     WORD sel, selcount;
@@ -156,7 +156,7 @@
  * Free a block allocated by GLOBAL_CreateBlock, without touching
  * the associated linear memory range.
  */
-BOOL GLOBAL_FreeBlock( HGLOBAL16 handle )
+BOOL16 GLOBAL_FreeBlock( HGLOBAL16 handle )
 {
     WORD sel;
 
@@ -174,7 +174,7 @@
  * Implementation of GlobalAlloc16()
  */
 HGLOBAL16 GLOBAL_Alloc( UINT16 flags, DWORD size, HGLOBAL16 hOwner,
-                        BOOL isCode, BOOL is32Bit, BOOL isReadOnly )
+                        BOOL16 isCode, BOOL16 is32Bit, BOOL16 isReadOnly )
 {
     void *ptr;
     HGLOBAL16 handle;
diff --git a/memory/heap.c b/memory/heap.c
index 8ba60e8..462cf77 100644
--- a/memory/heap.c
+++ b/memory/heap.c
@@ -1199,7 +1199,7 @@
  */
 LPSTR HEAP_strdupA( HANDLE32 heap, DWORD flags, LPCSTR str )
 {
-    INT32 len = lstrlen(str) + 1;
+    INT32 len = lstrlen32A(str) + 1;
     LPSTR p = HeapAlloc( heap, flags, len );
     if (p) strcpy( p, str );
     return p;
diff --git a/memory/ldt.c b/memory/ldt.c
index 87323db..5ed3cbfd 100644
--- a/memory/ldt.c
+++ b/memory/ldt.c
@@ -37,8 +37,8 @@
 #endif  /* ifndef WINELIB */
 
 
-ldt_copy_entry ldt_copy[LDT_SIZE] = { {0,0}, };
-unsigned char ldt_flags_copy[LDT_SIZE] = { 0, };
+ldt_copy_entry ldt_copy[LDT_SIZE];
+unsigned char ldt_flags_copy[LDT_SIZE];
 
         
 /***********************************************************************
diff --git a/memory/string.c b/memory/string.c
new file mode 100644
index 0000000..3348ec8
--- /dev/null
+++ b/memory/string.c
@@ -0,0 +1,335 @@
+/*
+ * String functions
+ *
+ * Copyright 1993 Yngvi Sigurjonsson
+ * Copyright 1996 Alexandre Julliard
+ */
+
+#include <ctype.h>
+#include <string.h>
+#include "windows.h"
+#include "ldt.h"
+
+
+/***********************************************************************
+ *           hmemcpy   (KERNEL.348)
+ */
+void hmemcpy( LPVOID dst, LPCVOID src, LONG count )
+{
+    memcpy( dst, src, count );
+}
+
+
+/***********************************************************************
+ *           lstrcat16   (KERNEL.89)
+ */
+SEGPTR lstrcat16( SEGPTR dst, SEGPTR src )
+{
+    lstrcat32A( (LPSTR)PTR_SEG_TO_LIN(dst), (LPCSTR)PTR_SEG_TO_LIN(src) );
+    return dst;
+}
+
+
+/***********************************************************************
+ *           lstrcat32A   (KERNEL32.599)
+ */
+LPSTR lstrcat32A( LPSTR dst, LPCSTR src )
+{
+    strcat( dst, src );
+    return dst;
+}
+
+
+/***********************************************************************
+ *           lstrcat32W   (KERNEL32.600)
+ */
+LPWSTR lstrcat32W( LPWSTR dst, LPCWSTR src )
+{
+    register LPWSTR p = dst;
+    while (*p) p++;
+    while ((*p++ = *src++));
+    return dst;
+}
+
+
+/***********************************************************************
+ *           lstrcatn16   (KERNEL.352)
+ */
+SEGPTR lstrcatn16( SEGPTR dst, SEGPTR src, INT16 n )
+{
+    lstrcatn32A( (LPSTR)PTR_SEG_TO_LIN(dst), (LPCSTR)PTR_SEG_TO_LIN(src), n );
+    return dst;
+}
+
+
+/***********************************************************************
+ *           lstrcatn32A   (Not a Windows API)
+ */
+LPSTR lstrcatn32A( LPSTR dst, LPCSTR src, INT32 n )
+{
+    register LPSTR p = dst;
+    while (*p) p++;
+    if ((n -= (INT32)(p - dst)) <= 0) return dst;
+    lstrcpyn32A( p, src, n );
+    return dst;
+}
+
+
+/***********************************************************************
+ *           lstrcatn32W   (Not a Windows API)
+ */
+LPWSTR lstrcatn32W( LPWSTR dst, LPCWSTR src, INT32 n )
+{
+    register LPWSTR p = dst;
+    while (*p) p++;
+    if ((n -= (INT32)(p - dst)) <= 0) return dst;
+    lstrcpyn32W( p, src, n );
+    return dst;
+}
+
+
+/***********************************************************************
+ *           lstrcmp16   (USER.430)
+ */
+INT16 lstrcmp16( LPCSTR str1, LPCSTR str2 )
+{
+    return (INT16)lstrcmp32A( str1, str2 );
+}
+
+
+/***********************************************************************
+ *           lstrcmp32A   (KERNEL.602)
+ */
+INT32 lstrcmp32A( LPCSTR str1, LPCSTR str2 )
+{
+    return (INT32)strcmp( str1, str2 );
+}
+
+
+/***********************************************************************
+ *           lstrcmp32W   (KERNEL.603)
+ */
+INT32 lstrcmp32W( LPCWSTR str1, LPCWSTR str2 )
+{
+    while (*str1 && (*str1 == *str2)) { str1++; str2++; }
+    return (INT32)(*str1 - *str2);
+}
+
+
+/***********************************************************************
+ *           lstrcmpi16   (USER.471)
+ */
+INT16 lstrcmpi16( LPCSTR str1, LPCSTR str2 )
+{
+    return (INT16)lstrcmpi32A( str1, str2 );
+}
+
+
+/***********************************************************************
+ *           lstrcmpi32A   (KERNEL32.605)
+ */
+INT32 lstrcmpi32A( LPCSTR str1, LPCSTR str2 )
+{
+    INT32 res;
+
+    while (*str1)
+    {
+        if ((res = toupper(*str1) - toupper(*str2)) != 0) return res;
+        str1++;
+        str2++;
+    }
+    return toupper(*str1) - toupper(*str2);
+}
+
+
+/***********************************************************************
+ *           lstrcmpi32W   (KERNEL32.606)
+ */
+INT32 lstrcmpi32W( LPCWSTR str1, LPCWSTR str2 )
+{
+    INT32 res;
+
+    while (*str1)
+    {
+        /* FIXME: Unicode */
+        if ((res = toupper(*str1) - toupper(*str2)) != 0) return res;
+        str1++;
+        str2++;
+    }
+    return toupper(*str1) - toupper(*str2);
+}
+
+
+/***********************************************************************
+ *           lstrcpy16   (KERNEL.88)
+ */
+SEGPTR lstrcpy16( SEGPTR dst, SEGPTR src )
+{
+    lstrcpy32A( (LPSTR)PTR_SEG_TO_LIN(dst), (LPCSTR)PTR_SEG_TO_LIN(src) );
+    return dst;
+}
+
+
+/***********************************************************************
+ *           lstrcpy32A   (KERNEL32.608)
+ */
+LPSTR lstrcpy32A( LPSTR dst, LPCSTR src )
+{
+    strcpy( dst, src );
+    return dst;
+}
+
+
+/***********************************************************************
+ *           lstrcpy32W   (KERNEL32.609)
+ */
+LPWSTR lstrcpy32W( LPWSTR dst, LPCWSTR src )
+{
+    register LPWSTR p = dst;
+    while ((*p++ = *src++));
+    return dst;
+}
+
+
+/***********************************************************************
+ *           lstrcpyn16   (KERNEL.353)
+ */
+SEGPTR lstrcpyn16( SEGPTR dst, SEGPTR src, INT16 n )
+{
+    lstrcpyn32A( (LPSTR)PTR_SEG_TO_LIN(dst), (LPCSTR)PTR_SEG_TO_LIN(src), n );
+    return dst;
+}
+
+
+/***********************************************************************
+ *           lstrcpyn32A   (KERNEL32.611)
+ */
+LPSTR lstrcpyn32A( LPSTR dst, LPCSTR src, INT32 n )
+{
+    LPSTR p = dst;
+    while ((n-- > 1) && *src) *p++ = *src++;
+    *p = 0;
+    return dst;
+}
+
+
+/***********************************************************************
+ *           lstrcpyn32W   (KERNEL32.612)
+ */
+LPWSTR lstrcpyn32W( LPWSTR dst, LPCWSTR src, INT32 n )
+{
+    LPWSTR p = dst;
+    while ((n-- > 1) && *src) *p++ = *src++;
+    *p = 0;
+    return dst;
+}
+
+
+/***********************************************************************
+ *           lstrlen16   (KERNEL.90)
+ */
+INT16 lstrlen16( LPCSTR str )
+{
+    return (INT16)lstrlen32A( str );
+}
+
+
+/***********************************************************************
+ *           lstrlen32A   (KERNEL32.614)
+ */
+INT32 lstrlen32A( LPCSTR str )
+{
+    /* looks weird, but win3.1 KERNEL got a GeneralProtection handler
+     * in lstrlen() ... we check only for NULL pointer reference.
+     * - Marcus Meissner
+     */
+    if (!str) return 0;
+    return (INT32)strlen(str);
+}
+
+
+/***********************************************************************
+ *           lstrlen32W   (KERNEL32.615)
+ */
+INT32 lstrlen32W( LPCWSTR str )
+{
+    INT32 len = 0;
+    if (!str) return 0;
+    while (*str++) len++;
+    return len;
+}
+
+
+/***********************************************************************
+ *           lstrncmp16   (Not a Windows API)
+ */
+INT16 lstrncmp16( LPCSTR str1, LPCSTR str2, INT16 n )
+{
+    return (INT16)lstrncmp32A( str1, str2, n );
+}
+
+
+/***********************************************************************
+ *           lstrncmp32A   (Not a Windows API)
+ */
+INT32 lstrncmp32A( LPCSTR str1, LPCSTR str2, INT32 n )
+{
+    return (INT32)strncmp( str1, str2, n );
+}
+
+
+/***********************************************************************
+ *           lstrncmp32W   (Not a Windows API)
+ */
+INT32 lstrncmp32W( LPCWSTR str1, LPCWSTR str2, INT32 n )
+{
+    if (!n) return 0;
+    while ((--n > 0) && *str1 && (*str1 == *str2)) { str1++; str2++; }
+    return (INT32)(*str1 - *str2);
+}
+
+
+/***********************************************************************
+ *           lstrncmpi16   (Not a Windows API)
+ */
+INT16 lstrncmpi16( LPCSTR str1, LPCSTR str2, INT16 n )
+{
+    return (INT16)lstrncmpi32A( str1, str2, n );
+}
+
+
+/***********************************************************************
+ *           lstrncmpi32A   (Not a Windows API)
+ */
+INT32 lstrncmpi32A( LPCSTR str1, LPCSTR str2, INT32 n )
+{
+    INT32 res;
+
+    if (!n) return 0;
+    while ((--n > 0) && *str1)
+    {
+        if ((res = toupper(*str1) - toupper(*str2)) != 0) return res;
+        str1++;
+        str2++;
+    }
+    return toupper(*str1) - toupper(*str2);
+}
+
+
+/***********************************************************************
+ *           lstrncmpi32W   (Not a Windows API)
+ */
+INT32 lstrncmpi32W( LPCWSTR str1, LPCWSTR str2, INT32 n )
+{
+    INT32 res;
+
+    if (!n) return 0;
+    while ((--n > 0) && *str1)
+    {
+        /* FIXME: Unicode */
+        if ((res = toupper(*str1) - toupper(*str2)) != 0) return res;
+        str1++;
+        str2++;
+    }
+    return toupper(*str1) - toupper(*str2);
+}
diff --git a/misc/Makefile.in b/misc/Makefile.in
index 6ef8e00..45872d9 100644
--- a/misc/Makefile.in
+++ b/misc/Makefile.in
@@ -32,6 +32,7 @@
 	ver.c \
 	w32sys.c \
 	winsocket.c \
+	wsprintf.c \
 	xmalloc.c
 
 all: $(MODULE).o
diff --git a/misc/clipboard.c b/misc/clipboard.c
index a9c01d9..4ff267c 100644
--- a/misc/clipboard.c
+++ b/misc/clipboard.c
@@ -32,8 +32,8 @@
     LPSTR	Name;
     HANDLE	hData;
     DWORD	BufSize;
-    void	*PrevFormat;
-    void	*NextFormat;
+    struct tagCLIPFORMAT *PrevFormat;
+    struct tagCLIPFORMAT *NextFormat;
 } CLIPFORMAT, *LPCLIPFORMAT;
 
 /* *************************************************************************
@@ -50,7 +50,7 @@
 static Bool wait_for_selection = False;
 static Bool wineOwnsSelection = False;
 
-CLIPFORMAT ClipFormats[16]  = {
+static CLIPFORMAT ClipFormats[16]  = {
     { CF_TEXT, 1, 0, "Text", (HANDLE)NULL, 0, NULL, &ClipFormats[1] },
     { CF_BITMAP, 1, 0, "Bitmap", (HANDLE)NULL, 0, &ClipFormats[0], &ClipFormats[2] },
     { CF_METAFILEPICT, 1, 0, "MetaFile Picture", (HANDLE)NULL, 0, &ClipFormats[1], &ClipFormats[3] },
@@ -117,12 +117,16 @@
  */
 BOOL CLIPBOARD_RequestXSelection()
 {
+  HWND hWnd = hWndClipWindow;
+
+  if( !hWnd ) hWnd = GetActiveWindow(); 
+
   wait_for_selection=True;
   dprintf_clipboard(stddeb,"Requesting selection\n");
 
   XConvertSelection(display,XA_PRIMARY,XA_STRING,
                     XInternAtom(display,"PRIMARY_TEXT",False),
-                    WIN_GetXWindow(hWndClipWindow),CurrentTime);
+                    WIN_GetXWindow(hWnd),CurrentTime);
 
   /* TODO: need time-out for broken clients */
   while(wait_for_selection) EVENT_WaitXEvent(-1);
diff --git a/misc/comm.c b/misc/comm.c
index 73811a9..a68542a 100644
--- a/misc/comm.c
+++ b/misc/comm.c
@@ -138,7 +138,7 @@
 		"BuildCommDCB: (%s), ptr %p\n", device, lpdcb);
 	commerror = 0;
 
-	if (!lstrncmpi(device,"COM",3)) {
+	if (!lstrncmpi32A(device,"COM",3)) {
 		port = device[3] - '0';
 	
 
@@ -229,7 +229,7 @@
 		"OpenComm: %s, %d, %d\n", device, cbInQueue, cbOutQueue);
 	commerror = 0;
 
-	if (!lstrncmpi(device,"COM",3)) {
+	if (!lstrncmpi32A(device,"COM",3)) {
 		port = device[3] - '0';
 
 		if (port-- == 0) {
@@ -258,7 +258,7 @@
 		}
 	} 
 	else 
-	if (!lstrncmpi(device,"LPT",3)) {
+	if (!lstrncmpi32A(device,"LPT",3)) {
 		port = device[3] - '0';
 	
 		if (!ValidLPTPort(port)) {
diff --git a/misc/commdlg.c b/misc/commdlg.c
index 95b18f9..4ca2ee7 100644
--- a/misc/commdlg.c
+++ b/misc/commdlg.c
@@ -206,13 +206,13 @@
 /***********************************************************************
  *                              FILEDLG_WMDrawItem              [internal]
  */
-static LONG FILEDLG_WMDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
+static LONG FILEDLG_WMDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam,int savedlg)
 {
     LPDRAWITEMSTRUCT16 lpdis = (LPDRAWITEMSTRUCT16)PTR_SEG_TO_LIN(lParam);
     char str[512];
     HBRUSH hBrush;
     HBITMAP hBitmap, hPrevBitmap;
-    BITMAP bm;
+    BITMAP16 bm;
     HDC hMemDC;
 
     str[0]=0;
@@ -222,6 +222,14 @@
 	FillRect16(lpdis->hDC, &lpdis->rcItem, hBrush);
 	SendMessage16(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID, 
                       (LPARAM)MAKE_SEGPTR(str));
+
+	if (savedlg)       /* use _gray_ text in FileSaveDlg */
+	  if (!lpdis->itemState)
+	    SetTextColor(lpdis->hDC,GetSysColor(COLOR_GRAYTEXT) );
+	  else  
+	    SetTextColor(lpdis->hDC,GetSysColor(COLOR_WINDOWTEXT) );
+	    /* inversion of gray would be bad readable */	  	  
+
 	TextOut16(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
                   str, strlen(str));
 	if (lpdis->itemState != 0) {
@@ -238,7 +246,7 @@
                       (LPARAM)MAKE_SEGPTR(str));
 
 	hBitmap = hFolder;
-	GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&bm);
+	GetObject16( hBitmap, sizeof(bm), &bm );
 	TextOut16(lpdis->hDC, lpdis->rcItem.left + bm.bmWidth, 
                   lpdis->rcItem.top, str, strlen(str));
 	hMemDC = CreateCompatibleDC(lpdis->hDC);
@@ -266,7 +274,7 @@
         case TYPE_NETWORK:
         default:           hBitmap = hHDisk; break;
         }
-	GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&bm);
+	GetObject16( hBitmap, sizeof(bm), &bm );
 	TextOut16(lpdis->hDC, lpdis->rcItem.left + bm.bmWidth, 
                   lpdis->rcItem.top, str, strlen(str));
 	hMemDC = CreateCompatibleDC(lpdis->hDC);
@@ -288,11 +296,11 @@
  */
 static LONG FILEDLG_WMMeasureItem(HWND hWnd, WPARAM wParam, LPARAM lParam) 
 {
-    BITMAP bm;
-    LPMEASUREITEMSTRUCT lpmeasure;
+    BITMAP16 bm;
+    LPMEASUREITEMSTRUCT16 lpmeasure;
     
-    GetObject(hFolder2, sizeof(BITMAP), (LPSTR)&bm);
-    lpmeasure = (LPMEASUREITEMSTRUCT)PTR_SEG_TO_LIN(lParam);
+    GetObject16( hFolder2, sizeof(bm), &bm );
+    lpmeasure = (LPMEASUREITEMSTRUCT16)PTR_SEG_TO_LIN(lParam);
     lpmeasure->itemHeight = bm.bmHeight;
     return TRUE;
 }
@@ -512,7 +520,7 @@
       if (lRet == LB_ERR) return TRUE;
       lpofn->nFilterIndex = lRet + 1;
       dprintf_commdlg(stddeb,"commdlg: lpofn->nFilterIndex=%ld\n", lpofn->nFilterIndex);
-      lstrcpyn(tmpstr2, 
+      lstrcpyn32A(tmpstr2, 
 	     FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn->lpstrCustomFilter),
 				 PTR_SEG_TO_LIN(lpofn->lpstrFilter),
 				 lRet), sizeof(tmpstr2));
@@ -526,7 +534,7 @@
 	  /* strip off the pathname */
 	  *pstr = 0;
           SetDlgItemText32A( hWnd, edt1, pstr + 1 );
-	  lstrcpyn(tmpstr2, pstr+1, sizeof(tmpstr2) );
+	  lstrcpyn32A(tmpstr2, pstr+1, sizeof(tmpstr2) );
 	  /* Should we MessageBox() if this fails? */
 	  if (!FILEDLG_ScanDir(hWnd, tmpstr)) return TRUE;
 	  strcpy(tmpstr, tmpstr2);
@@ -607,7 +615,7 @@
     case WM_MEASUREITEM:
       return FILEDLG_WMMeasureItem(hWnd, wParam, lParam);
     case WM_DRAWITEM:
-      return FILEDLG_WMDrawItem(hWnd, wParam, lParam);
+      return FILEDLG_WMDrawItem(hWnd, wParam, lParam, FALSE);
     case WM_COMMAND:
       return FILEDLG_WMCommand(hWnd, wParam, lParam);
 #if 0
@@ -651,7 +659,7 @@
       return FILEDLG_WMMeasureItem(hWnd, wParam, lParam);
     
    case WM_DRAWITEM:
-      return FILEDLG_WMDrawItem(hWnd, wParam, lParam);
+      return FILEDLG_WMDrawItem(hWnd, wParam, lParam, TRUE);
 
    case WM_COMMAND:
       return FILEDLG_WMCommand(hWnd, wParam, lParam);
@@ -1403,7 +1411,7 @@
  long editpos;
  char buffer[30];
  GetWindowText32A(hwnd,buffer,sizeof(buffer));
- m=lstrlen(buffer);
+ m=strlen(buffer);
  result=0;
 
  for (i=0;i<m;i++)
@@ -2228,7 +2236,7 @@
 /***********************************************************************
  *                FontFamilyEnumProc                       (COMMDLG.19)
  */
-int FontFamilyEnumProc(LPLOGFONT lplf ,LPTEXTMETRIC lptm, int nFontType, LPARAM lParam)
+int FontFamilyEnumProc(LPLOGFONT16 lplf, LPTEXTMETRIC16 lptm, int nFontType, LPARAM lParam)
 {
   int i;
   WORD w;
@@ -2265,7 +2273,7 @@
  *
  * Fill font style information into combobox  (without using font.c directly)
  */
-static int SetFontStylesToCombo2(HWND hwnd, HDC hdc, LPLOGFONT lplf ,LPTEXTMETRIC lptm)
+static int SetFontStylesToCombo2(HWND hwnd, HDC hdc, LPLOGFONT16 lplf ,LPTEXTMETRIC16 lptm)
 {
    #define FSTYLES 4
    struct FONTSTYLE
@@ -2304,7 +2312,7 @@
 /*************************************************************************
  *              SetFontSizesToCombo3                           [internal]
  */
-static int SetFontSizesToCombo3(HWND hwnd, LPLOGFONT lplf, LPCHOOSEFONT lpcf)
+static int SetFontSizesToCombo3(HWND hwnd, LPLOGFONT16 lplf, LPCHOOSEFONT lpcf)
 {
   int sizes[]={8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72,0};
   int h,i,j;
@@ -2335,7 +2343,7 @@
 /***********************************************************************
  *                 FontStyleEnumProc                     (COMMDLG.18)
  */
-int FontStyleEnumProc(LPLOGFONT lplf ,LPTEXTMETRIC lptm, int nFontType, LPARAM lParam)
+int FontStyleEnumProc(LPLOGFONT16 lplf ,LPTEXTMETRIC16 lptm, int nFontType, LPARAM lParam)
 {
   HWND hcmb2=LOWORD(lParam);
   HWND hcmb3=HIWORD(lParam);
@@ -2374,7 +2382,7 @@
   int i,j,res,init=0;
   long l;
   FARPROC enumCallback = MODULE_GetWndProcEntry16("FontFamilyEnumProc");
-  LPLOGFONT lpxx;
+  LPLOGFONT16 lpxx;
   HCURSOR hcursor=SetCursor(LoadCursor(0,IDC_WAIT));
   LPCHOOSEFONT lpcf;
 
@@ -2484,11 +2492,11 @@
  */
 LRESULT CFn_WMMeasureItem(HWND hDlg, WPARAM wParam, LPARAM lParam)
 {
-  BITMAP bm;
-  LPMEASUREITEMSTRUCT lpmi=PTR_SEG_TO_LIN((LPMEASUREITEMSTRUCT)lParam);
+  BITMAP16 bm;
+  LPMEASUREITEMSTRUCT16 lpmi=PTR_SEG_TO_LIN((LPMEASUREITEMSTRUCT16)lParam);
   if (!hBitmapTT)
     hBitmapTT = LoadBitmap(0, MAKEINTRESOURCE(OBM_TRTYPE));
-  GetObject(hBitmapTT, sizeof(BITMAP), (LPSTR)&bm);
+  GetObject16( hBitmapTT, sizeof(bm), &bm );
   lpmi->itemHeight=bm.bmHeight;
   /* FIXME: use MAX of bm.bmHeight and tm.tmHeight .*/
   return 0;
@@ -2502,7 +2510,7 @@
 {
   HBRUSH hBrush;
   char buffer[40];
-  BITMAP bm;
+  BITMAP16 bm;
   COLORREF cr;
   RECT16 rect;
 #if 0  
@@ -2531,9 +2539,9 @@
     case cmb1:	/* dprintf_commdlg(stddeb,"WM_Drawitem cmb1\n"); */
 		SendMessage16(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
 			(LPARAM)MAKE_SEGPTR(buffer));	          
-		GetObject(hBitmapTT, sizeof(BITMAP), (LPSTR)&bm);
+		GetObject16( hBitmapTT, sizeof(bm), &bm );
 		TextOut16(lpdi->hDC, lpdi->rcItem.left + bm.bmWidth + 10,
-                          lpdi->rcItem.top, buffer, lstrlen(buffer));
+                          lpdi->rcItem.top, buffer, lstrlen16(buffer));
 #if 0
 		nFontType = SendMessage16(lpdi->hwndItem, CB_GETITEMDATA, lpdi->itemID,0L);
 		  /* FIXME: draw bitmap if truetype usage */
@@ -2553,14 +2561,14 @@
 		SendMessage16(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
 			(LPARAM)MAKE_SEGPTR(buffer));
 		TextOut16(lpdi->hDC, lpdi->rcItem.left,
-                          lpdi->rcItem.top, buffer, lstrlen(buffer));
+                          lpdi->rcItem.top, buffer, lstrlen16(buffer));
 		break;
 
     case cmb4:	/* dprintf_commdlg(stddeb,"WM_DRAWITEM cmb4 (=COLOR)\n"); */
 		SendMessage16(lpdi->hwndItem, CB_GETLBTEXT, lpdi->itemID,
     		    (LPARAM)MAKE_SEGPTR(buffer));
 		TextOut16(lpdi->hDC, lpdi->rcItem.left +  25+5,
-                          lpdi->rcItem.top, buffer, lstrlen(buffer));
+                          lpdi->rcItem.top, buffer, lstrlen16(buffer));
 		cr = SendMessage16(lpdi->hwndItem, CB_GETITEMDATA, lpdi->itemID,0L);
 		hBrush = CreateSolidBrush(cr);
 		if (hBrush)
@@ -2613,7 +2621,7 @@
   long l;
   HDC hdc;
   LPCHOOSEFONT lpcf=(LPCHOOSEFONT)GetWindowLong32A(hDlg, DWL_USER); 
-  LPLOGFONT lpxx=PTR_SEG_TO_LIN(lpcf->lpLogFont);
+  LPLOGFONT16 lpxx=PTR_SEG_TO_LIN(lpcf->lpLogFont);
   
   dprintf_commdlg(stddeb,"FormatCharDlgProc // WM_COMMAND lParam=%08lX\n", lParam);
   switch (wParam)
diff --git a/misc/compobj.c b/misc/compobj.c
index 106aaed..c7c76a2 100644
--- a/misc/compobj.c
+++ b/misc/compobj.c
@@ -7,8 +7,6 @@
 /*	At the moment, these are only empty stubs.
  */
 
-#include "windows.h"
-#include "compobj.h"
 #include "ole.h"
 #include "ole2.h"
 #include "stddebug.h"
diff --git a/misc/keyboard.c b/misc/keyboard.c
index 8f8c31b..750a645 100644
--- a/misc/keyboard.c
+++ b/misc/keyboard.c
@@ -8,11 +8,123 @@
 #include <string.h>
 #include <ctype.h>
 #include "windows.h"
-#include "keyboard.h"
 #include "stddebug.h"
 /* #define DEBUG_KEYBOARD */
 #include "debug.h"
 
+
+struct KeyTableEntry {
+	int virtualkey;
+	int ASCII;
+	int scancode;
+	const char *name;
+};
+
+static const struct KeyTableEntry KeyTable[] =
+{
+	{ 0x3, 0x3, 0x0, "" },
+	{ 0x8, 0x8, 0xe, "Backspace" },
+	{ 0x9, 0x9, 0xf, "Tab" },
+	{ 0xc, 0x0, 0x4c, "Num 5" },
+	{ 0xd, 0xd, 0x1c, "Enter" },
+	{ 0x10, 0x0, 0x2a, "Shift" },
+	{ 0x11, 0x0, 0x1d, "Ctrl" },
+	{ 0x12, 0x0, 0x38, "Alt" },
+	{ 0x14, 0x0, 0x3a, "Caps Lock" },
+	{ 0x1b, 0x1b, 0x1, "Esc" },
+	{ 0x20, 0x20, 0x39, "Space" },
+	{ 0x21, 0x0, 0x49, "Num 9" },
+	{ 0x22, 0x0, 0x51, "Num 3" },
+	{ 0x23, 0x0, 0x4f, "Num 1" },
+	{ 0x24, 0x0, 0x47, "Num 7" },
+	{ 0x25, 0x0, 0x4b, "Num 4" },
+	{ 0x26, 0x0, 0x48, "Num 8" },
+	{ 0x27, 0x0, 0x4d, "Num 6" },
+	{ 0x28, 0x0, 0x50, "Num 2" },
+	{ 0x2d, 0x0, 0x52, "Num 0" },
+	{ 0x2e, 0x0, 0x53, "Num Del" },
+	{ 0x30, 0x30, 0xb, "0" },
+	{ 0x31, 0x31, 0x2, "1" },
+	{ 0x32, 0x32, 0x3, "2" },
+	{ 0x33, 0x33, 0x4, "3" },
+	{ 0x34, 0x34, 0x5, "4" },
+	{ 0x35, 0x35, 0x6, "5" },
+	{ 0x36, 0x36, 0x7, "6" },
+	{ 0x37, 0x37, 0x8, "7" },
+	{ 0x38, 0x38, 0x9, "8" },
+	{ 0x39, 0x39, 0xa, "9" },
+	{ 0x41, 0x41, 0x1e, "A" },
+	{ 0x42, 0x42, 0x30, "B" },
+	{ 0x43, 0x43, 0x2e, "C" },
+	{ 0x44, 0x44, 0x20, "D" },
+	{ 0x45, 0x45, 0x12, "E" },
+	{ 0x46, 0x46, 0x21, "F" },
+	{ 0x47, 0x47, 0x22, "G" },
+	{ 0x48, 0x48, 0x23, "H" },
+	{ 0x49, 0x49, 0x17, "I" },
+	{ 0x4a, 0x4a, 0x24, "J" },
+	{ 0x4b, 0x4b, 0x25, "K" },
+	{ 0x4c, 0x4c, 0x26, "L" },
+	{ 0x4d, 0x4d, 0x32, "M" },
+	{ 0x4e, 0x4e, 0x31, "N" },
+	{ 0x4f, 0x4f, 0x18, "O" },
+	{ 0x50, 0x50, 0x19, "P" },
+	{ 0x51, 0x51, 0x10, "Q" },
+	{ 0x52, 0x52, 0x13, "R" },
+	{ 0x53, 0x53, 0x1f, "S" },
+	{ 0x54, 0x54, 0x14, "T" },
+	{ 0x55, 0x55, 0x16, "U" },
+	{ 0x56, 0x56, 0x2f, "V" },
+	{ 0x57, 0x57, 0x11, "W" },
+	{ 0x58, 0x58, 0x2d, "X" },
+	{ 0x59, 0x59, 0x15, "Y" },
+	{ 0x5a, 0x5a, 0x2c, "Z" },
+	{ 0x60, 0x0, 0x52, "Num 0" },
+	{ 0x61, 0x0, 0x4f, "Num 1" },
+	{ 0x62, 0x0, 0x50, "Num 2" },
+	{ 0x63, 0x0, 0x51, "Num 3" },
+	{ 0x64, 0x0, 0x4b, "Num 4" },
+	{ 0x65, 0x0, 0x4c, "Num 5" },
+	{ 0x66, 0x0, 0x4d, "Num 6" },
+	{ 0x67, 0x0, 0x47, "Num 7" },
+	{ 0x68, 0x0, 0x48, "Num 8" },
+	{ 0x69, 0x0, 0x49, "Num 9" },
+	{ 0x6a, 0x2a, 0x37, "Num *" },
+	{ 0x6b, 0x2b, 0x4e, "Num +" },
+	{ 0x6c, 0x0, 0x0, "" },
+	{ 0x6d, 0x2d, 0x4a, "Num -" },
+	{ 0x6e, 0x2e, 0x53, "Num Del" },
+	{ 0x6f, 0x2f, 0x0, "" },
+	{ 0x70, 0x0, 0x3b, "F1" },
+	{ 0x71, 0x0, 0x3c, "F2" },
+	{ 0x72, 0x0, 0x3d, "F3" },
+	{ 0x73, 0x0, 0x3e, "F4" },
+	{ 0x74, 0x0, 0x3f, "F5" },
+	{ 0x75, 0x0, 0x40, "F6" },
+	{ 0x76, 0x0, 0x41, "F7" },
+	{ 0x77, 0x0, 0x42, "F8" },
+	{ 0x78, 0x0, 0x43, "F9" },
+	{ 0x79, 0x0, 0x44, "F10" },
+	{ 0x7a, 0x0, 0x57, "F11" },
+	{ 0x7b, 0x0, 0x58, "F12" },
+	{ 0x90, 0x0, 0x45, "Pause" },
+	{ 0x91, 0x0, 0x46, "Scroll Lock" },
+	{ 0xba, 0x3b, 0x27, ";" },
+	{ 0xbb, 0x3d, 0xd, "=" },
+	{ 0xbc, 0x2c, 0x33, "," },
+	{ 0xbd, 0x2d, 0xc, "-" },
+	{ 0xbe, 0x2e, 0x34, "." },
+	{ 0xbf, 0x2f, 0x35, "/" },
+	{ 0xc0, 0x60, 0x29, "`" },
+	{ 0xdb, 0x5b, 0x1a, "[" },
+	{ 0xdc, 0x5c, 0x2b, "\\" },
+	{ 0xdd, 0x5d, 0x1b, "]" },
+	{ 0xde, 0x27, 0x28, "\'" },
+	{ 0xe2, 0x5c, 0x56, "\\" },
+};
+
+#define KeyTableSize	sizeof(KeyTable) / sizeof(struct KeyTableEntry)
+
 int ToAscii(WORD wVirtKey, WORD wScanCode, LPSTR lpKeyState, 
 	LPVOID lpChar, WORD wFlags) 
 {
@@ -138,7 +250,7 @@
 
 	for (i = 0 ; i != KeyTableSize ; i++) 
 		if (KeyTable[i].scancode == lParam)  {
-			lstrcpyn(lpBuffer, KeyTable[i].name, nSize);
+			lstrcpyn32A( lpBuffer, KeyTable[i].name, nSize );
 			return strlen(lpBuffer);
 		}
 
diff --git a/misc/lstr.c b/misc/lstr.c
index 5ebd79c..e01fb7f 100644
--- a/misc/lstr.c
+++ b/misc/lstr.c
@@ -60,86 +60,6 @@
 
 /* Funny to divide them between user and kernel. */
 
-/* KERNEL.89 */
-SEGPTR lstrcat( SEGPTR target, SEGPTR source )
-{
-    strcat( (char *)PTR_SEG_TO_LIN(target), (char *)PTR_SEG_TO_LIN(source) );
-    return target;
-}
-
-/* USER.430 */
-INT lstrcmp(LPCSTR str1,LPCSTR str2)
-{
-    return strcmp( str1, str2 );
-}
-
-/* USER.471 */
-INT lstrcmpi( LPCSTR str1, LPCSTR str2 )
-{
-    INT res;
-
-    while (*str1)
-    {
-        if ((res = toupper(*str1) - toupper(*str2)) != 0) return res;
-        str1++;
-        str2++;
-    }
-    return toupper(*str1) - toupper(*str2);
-}
-
-/* Not a Windows API*/
-INT lstrncmpi( LPCSTR str1, LPCSTR str2, int n )
-{
-    INT res;
-
-    if (!n) return 0;
-    while ((--n > 0) && *str1)
-    {
-        if ((res = toupper(*str1) - toupper(*str2)) != 0) return res;
-        str1++;
-        str2++;
-    }
-    return toupper(*str1) - toupper(*str2);
-}
-
-/* KERNEL.88 */
-SEGPTR lstrcpy( SEGPTR target, SEGPTR source )
-{
-    strcpy( (char *)PTR_SEG_TO_LIN(target), (char *)PTR_SEG_TO_LIN(source) );
-    return target;
-}
-
-/* KERNEL.353 32-bit version*/
-LPSTR lstrcpyn( LPSTR dst, LPCSTR src, int n )
-{
-    char *tmp = dst;
-    while(n-- > 1 && *src)
-    	*tmp++ = *src++;
-    *tmp = 0;
-    return dst;
-}
-
-/* KERNEL.353 16-bit version*/
-SEGPTR WIN16_lstrcpyn( SEGPTR target, SEGPTR source, WORD n )
-{
-    lstrcpyn((char *)PTR_SEG_TO_LIN(target), (char *)PTR_SEG_TO_LIN(source),n);
-    return target;
-}
-
-/* KERNEL.90 */
-INT lstrlen(LPCSTR str)
-{
-  /* looks weird, but win3.1 KERNEL got a GeneralProtection handler
-   * in lstrlen() ... we check only for NULL pointer reference.
-   * - Marcus Meissner
-   */
-  if (str==NULL) {
-  	fprintf(stddeb,"lstrlen(NULL) caught, returning 0.\n");
-  	return 0;
-  }
-  return strlen(str);
-}
-
 /* IsCharAlpha USER 433 */
 BOOL IsCharAlpha(char ch)
 {
@@ -335,111 +255,5 @@
     module = MODULE_GetModuleName( GetExePtr(GetCurrentTask()) );
     fprintf( stderr, "OutputDebugString: %s says '%s'\n",
              module ? module : "???", buffer );
-             
-}
-
-
-/***********************************************************************
- *           wsprintf   (USER.420)
- */
-#ifndef WINELIB
-int wsprintf( LPSTR dummy1, LPSTR dummy2, ... )
-{
-    LPSTR lpOutput, lpFormat;
-    DWORD *win_stack = (DWORD *)CURRENT_STACK16->args;
-
-    lpOutput = (LPSTR) PTR_SEG_TO_LIN(*win_stack);
-    win_stack++;
-    lpFormat = (LPSTR) PTR_SEG_TO_LIN(*win_stack);
-    win_stack++;
-
-    return wvsprintf( lpOutput, lpFormat, (LPCSTR)win_stack );
-}
-#else  /* WINELIB */
-int wsprintf(LPSTR lpOutput, LPSTR lpFormat, ...)
-{
-    va_list valist;
-    int ArgCnt;
-
-    va_start(valist, lpFormat);
-    ArgCnt = vsprintf(lpOutput, lpFormat, valist);
-    va_end(valist);
-
-    return ArgCnt;
-}
-#endif  /* WINELIB */
-
-
-/***********************************************************************
- *           wvsprintf   (USER.421)
- */
-int wvsprintf( LPSTR buf, LPCSTR format, LPCSTR args )
-{
-    LPCSTR ptr;
-    DWORD stack[512], *stack_ptr;
-    BOOL fLarge;
-
-    /* Create the 32-bit stack for libc's vsprintf() */
-
-    for (stack_ptr = stack, ptr = format; *ptr; ptr++)
-    {
-        if (*ptr != '%' || *++ptr == '%')
-            continue;
-
-        /* skip width/precision */
-        while (*ptr == '-' || *ptr == '+' || *ptr == '.' ||
-               *ptr == ' ' || isdigit(*ptr) || *ptr == '#')
-            ptr++;
-
-        /* handle modifier */
-        fLarge = ((*ptr == 'l') || (*ptr == 'L'));
-        if (fLarge) ptr++;
-
-        switch (*ptr)
-        {
-        case 's':
-            *stack_ptr++ = (DWORD)PTR_SEG_TO_LIN(*(DWORD*)args);
-            args += sizeof(DWORD);
-            break;
-
-        case 'c':
-/* windows' wsprintf() %c ignores 0's, we replace 0 with SPACE to make sure
-   that the remaining part of the string isn't ignored by the winapp */
-            *stack_ptr++ = (DWORD)(*(WORD*)args ? *(WORD*)args : ' ');
-            args += sizeof(WORD);
-            break;
-
-        case 'd':
-        case 'i':
-            if (!fLarge)
-            {
-                *stack_ptr++ = (DWORD)(INT32)(*(INT16 *)args);
-                args += sizeof(INT16);
-                break;
-            }
-            /* else fall through */
-        case 'u':
-        case 'x':
-        case 'X':
-            if (fLarge)
-            {
-                *stack_ptr++ = *(DWORD*)args;
-                args += sizeof(DWORD);
-            }
-            else
-            {
-                *stack_ptr++ = *(WORD*)args;
-                args += sizeof(WORD);
-            }
-            break;
-
-        default:
-            *stack_ptr++ = 0;
-            args += sizeof(WORD);
-            fprintf( stderr, "wsprintf: oops, unknown format %c!\n", *ptr );
-            break;
-        }
-    }
-
-    return vsprintf( buf, format, stack );
+    free( buffer );
 }
diff --git a/misc/lzexpand.c b/misc/lzexpand.c
index 4b4b500..e907bfd 100644
--- a/misc/lzexpand.c
+++ b/misc/lzexpand.c
@@ -21,6 +21,12 @@
 #include "stddebug.h"
 #include "debug.h"
 #include "xmalloc.h"
+#include "string32.h"
+
+#define strdupW2A(x)	STRING32_DupUniToAnsi(x)
+#define strdupA2W(x)	STRING32_DupAnsiToUni(x)
+#define strcpyWA(a,b)	STRING32_UniToAnsi(a,b)
+#define strcpyAW(a,b)	STRING32_AnsiToUni(a,b)
 
 /* The readahead length of the decompressor. Reading single bytes
  * using _lread() would be SLOW.
@@ -64,7 +70,7 @@
 #define GET(lzs,b)	_lzget(lzs,&b)
 #define GET_FLUSH(lzs)	lzs->getcur=lzs->getlen;
 
-int
+static int
 _lzget(struct lzstate *lzs,BYTE *b) {
 	if (lzs->getcur<lzs->getlen) {
 		*b		= lzs->get[lzs->getcur++];
@@ -113,16 +119,16 @@
 	return 1;
 }
 /* 
- * LZSTART							[LZEXPAND.7] 
+ * LZStart				[LZEXPAND.7] [LZ32.6]
  */
-INT
-LZStart(void) {
-	dprintf_file(stddeb,"LZStart(void)\n");
-	return 1;
+INT16 LZStart(void)
+{
+    dprintf_file(stddeb,"LZStart(void)\n");
+    return 1;
 }
 
 /*
- * LZINIT							[LZEXPAND.3]
+ * LZInit				[LZEXPAND.3] [LZ32.2]
  * 
  * initializes internal decompression buffers, returns lzfiledescriptor.
  * (return value the same as hfSrc, if hfSrc is not compressed)
@@ -166,7 +172,7 @@
 }
 
 /*
- * LZDone					[LZEXPAND.9] 
+ * LZDone				[LZEXPAND.9]  [LZ32.8]
  */
 
 void
@@ -175,7 +181,7 @@
 }
 
 /*
- * GetExpandedName				[LZEXPAND.10]
+ * GetExpandedName			[LZEXPAND.10]
  *
  * gets the full filename of the compressed file 'in' by opening it
  * and reading the header
@@ -185,8 +191,8 @@
  * "FILE.BL_" (with lastchar 'a') is being translated to "FILE.BLA"
  */
 
-INT
-GetExpandedName(LPCSTR in,LPSTR out) {
+INT16
+GetExpandedName16(LPCSTR in,LPSTR out) {
 	struct lzfileheader	head;
 	HFILE		fd;
 	OFSTRUCT	ofs;
@@ -252,27 +258,58 @@
 	return 1;
 }
 
+/* 
+ * GetExpandedNameW			[LZ32.11] 
+ */
+INT32
+GetExpandedName32W(LPCWSTR in,LPWSTR out) {
+	char	*xin,*xout;
+	INT32	ret;
+
+	xout	= malloc(lstrlen32W(in)+3);
+	xin	= strdupW2A(in);
+	ret	= GetExpandedName16(xin,xout);
+	if (ret>0)
+		strcpyAW(out,xout);
+	free(xin);
+	free(xout);
+	return	ret;
+}
+
+/* 
+ * GetExpandedNameA			[LZ32.9] 
+ */
+INT32
+GetExpandedName32A(LPCSTR in,LPSTR out) {
+	return	GetExpandedName16(in,out);
+}
+
 /*
- * LZRead				[LZEXPAND.5]
+ * LZRead				[LZEXPAND.5] [LZ32.4]
  * just as normal read, but reads from LZ special fd and uncompresses.
  */
-INT
-LZRead(HFILE fd,SEGPTR segbuf,WORD toread) {
+INT16
+LZRead16(HFILE fd,SEGPTR segbuf,UINT16 toread) {
+	dprintf_file(stddeb,"LZRead16(%d,%08lx,%d)\n",fd,(DWORD)segbuf,toread);
+	return LZRead32(fd,(LPBYTE)PTR_SEG_TO_LIN(segbuf),toread);
+}
+
+INT32
+LZRead32(HFILE fd,LPVOID vbuf,UINT32 toread) {
 	int	i,howmuch;
-	BYTE	b;
-	BYTE	*buf;
+	BYTE	b,*buf;
 	struct	lzstate	*lzs;
 
-	dprintf_file(stddeb,"LZRead(%d,%08lx,%d)\n",fd,(DWORD)segbuf,toread);
+	buf=(LPBYTE)vbuf;
+	dprintf_file(stddeb,"LZRead32(%d,%p,%d)\n",fd,buf,toread);
 	howmuch=toread;
 	for (i=0;i<nroflzstates;i++)
 		if (lzstates[i].lzfd==fd)
 			break;
 	if (i==nroflzstates)
-		return _lread(fd,segbuf,toread);
+		return FILE_Read(fd,buf,toread);
 	lzs=lzstates+i;
 
-
 /* The decompressor itself is in a define, cause we need it twice
  * in this function. (the decompressed byte will be in b)
  */
@@ -339,7 +376,6 @@
 		}
 	}
 
-	buf=PTR_SEG_TO_LIN(segbuf);
 	while (howmuch) {
 		DECOMPRESS_ONE_BYTE;
 		lzs->realwanted++;
@@ -351,13 +387,13 @@
 }
 
 /* 
- * LZSeek				[LZEXPAND.4]
+ * LZSeek				[LZEXPAND.4] [LZ32.3]
  *
  * works as the usual _llseek
  */
 
 LONG
-LZSeek(HFILE fd,LONG off,INT type) {
+LZSeek(HFILE fd,LONG off,INT32 type) {
 	int	i;
 	struct	lzstate	*lzs;
 	LONG	lastwanted,newwanted;
@@ -392,7 +428,7 @@
 }
 
 /* 
- * LZCopy				[LZEXPAND.1]
+ * LZCopy			[LZEXPAND.1] [LZ32.0]
  *
  * Copies everything from src to dest
  * if src is a LZ compressed file, it will be uncompressed.
@@ -404,7 +440,7 @@
 	LONG	len;
 #define BUFLEN	1000
 	BYTE	buf[BUFLEN];
-	INT	(*xread)(HFILE,SEGPTR,WORD);
+	INT32	(*xread)(HFILE,LPVOID,UINT32);
 
 	dprintf_file(stddeb,"LZCopy(%d,%d)\n",src,dest);
 	for (i=0;i<nroflzstates;i++)
@@ -413,12 +449,12 @@
 
 	/* not compressed? just copy */
 	if (i==nroflzstates)
-		xread=_lread;
+		xread=FILE_Read;
 	else
-		xread=LZRead;
+		xread=LZRead32;
 	len=0;
 	while (1) {
-		ret=xread(src,MAKE_SEGPTR(buf),BUFLEN);
+		ret=xread(src,buf,BUFLEN);
 		if (ret<=0) {
 			if (ret==0)
 				break;
@@ -440,7 +476,7 @@
  * Opens a file. If not compressed, open it as a normal file.
  */
 HFILE
-LZOpenFile(LPCSTR fn,LPOFSTRUCT ofs,UINT mode) {
+LZOpenFile16(LPCSTR fn,LPOFSTRUCT ofs,UINT16 mode) {
 	HFILE	fd,cfd;
 
 	dprintf_file(stddeb,"LZOpenFile(%s,%p,%d)\n",fn,ofs,mode);
@@ -456,8 +492,37 @@
 	return cfd;
 }
 
+/* 
+ * LZOpenFileA				[LZ32.1]
+ */
+HFILE
+LZOpenFile32A(LPCSTR fn,LPOFSTRUCT ofs,UINT32 mode) {
+	return LZOpenFile16(fn,ofs,mode);
+}
+
+/* 
+ * LZOpenFileW				[LZ32.10]
+ */
+HFILE
+LZOpenFile32W(LPCWSTR fn,LPOFSTRUCT ofs,UINT32 mode) {
+	LPSTR	xfn;
+	LPWSTR	yfn;
+	HFILE	ret;
+
+	xfn	= strdupW2A(fn);
+	ret	= LZOpenFile16(xfn,ofs,mode);
+	free(xfn);
+	if (ret!=HFILE_ERROR) {
+		/* ofs->szPathName is an array with the OFSTRUCT */
+		yfn 	= strdupA2W(ofs->szPathName);
+		memcpy(ofs->szPathName,yfn,lstrlen32W(yfn)*2+2);
+		free(yfn);
+	}
+	return	ret;
+}
+
 /*
- * LZClose				[LZEXPAND.6]
+ * LZClose			[LZEXPAND.6] [LZ32.5]
  */
 void
 LZClose(HFILE fd) {
@@ -480,7 +545,7 @@
 }
 
 /*
- * CopyLZFile					[LZEXPAND.8]
+ * CopyLZFile				[LZEXPAND.8] [LZ32.7]
  *
  * Copy src to dest (including uncompressing src).
  * NOTE: Yes. This is exactly the same function as LZCopy.
diff --git a/misc/main.c b/misc/main.c
index 85455f7..adc8255 100644
--- a/misc/main.c
+++ b/misc/main.c
@@ -26,6 +26,8 @@
 #include "options.h"
 #include "desktop.h"
 #include "shell.h"
+#include "winbase.h"
+#include "string32.h"
 #define DEBUG_DEFINE_VARIABLES
 #include "stddebug.h"
 #include "debug.h"
@@ -53,7 +55,7 @@
 "Jan Willamowius, Carl Williams, Karl Guenter Wuensch, Eric Youngdale, "
 "and James Youngman. ";
 
-const char *langNames[] =
+const char * langNames[] =
 {
     "En",  /* LANG_En */
     "Es",  /* LANG_Es */
@@ -87,6 +89,9 @@
 int screenWidth = 0, screenHeight = 0;  /* Desktop window dimensions */
 int screenDepth = 0;  /* Screen depth to use */
 int desktopX = 0, desktopY = 0;  /* Desktop window position (if any) */
+int getVersion16 = 0;
+int getVersion32 = 0;
+OSVERSIONINFO32A getVersionEx;
 
 struct options Options =
 {  /* default options */
@@ -128,7 +133,8 @@
     { "-dll",           ".dll",             XrmoptionSepArg, (caddr_t)NULL },
     { "-allowreadonly", ".allowreadonly",   XrmoptionNoArg,  (caddr_t)"on" },
     { "-mode",          ".mode",            XrmoptionSepArg, (caddr_t)NULL },
-    { "-managed",       ".managed",         XrmoptionNoArg,  (caddr_t)"off"}
+    { "-managed",       ".managed",         XrmoptionNoArg,  (caddr_t)"off"},
+    { "-winver",        ".winver",          XrmoptionSepArg, (caddr_t)NULL }
 };
 
 #define NB_OPTIONS  (sizeof(optionsTable) / sizeof(optionsTable[0]))
@@ -153,7 +159,8 @@
   "    -mode mode      Start Wine in a particular mode (standard or enhanced)\n" \
   "    -name name      Set the application name\n" \
   "    -privatemap     Use a private color map\n" \
-  "    -synchronous    Turn on synchronous display mode\n"
+  "    -synchronous    Turn on synchronous display mode\n" \
+  "    -winver         Version to imitate (one of win31,win95,nt351)\n"
 
 
 
@@ -237,7 +244,7 @@
       l=strchr(options,',')-options;
     else
       l=strlen(options);
-    if (!lstrncmpi(options+1,"all",l-1))
+    if (!lstrncmpi32A(options+1,"all",l-1))
       {
 	int i;
 	for (i=0;i<sizeof(debug_msg_enabled)/sizeof(short);i++)
@@ -247,7 +254,7 @@
       {
 	int i;
 	for (i=0;i<sizeof(debug_msg_enabled)/sizeof(short);i++)
-	  if (debug_msg_name && (!lstrncmpi(options+1,debug_msg_name[i],l-1)))
+	  if (debug_msg_name && (!lstrncmpi32A(options+1,debug_msg_name[i],l-1)))
 	    {
 	      debug_msg_enabled[i]=(*options=='+');
 	      break;
@@ -279,7 +286,7 @@
     Options.language = LANG_En;  /* First language */
     for (p = langNames; *p; p++)
     {
-        if (!lstrcmpi( *p, arg )) return;
+        if (!lstrcmpi32A( *p, arg )) return;
         Options.language++;
     }
     fprintf( stderr, "Invalid language specified '%s'. Supported languages are: ", arg );
@@ -296,8 +303,8 @@
  */
 static void MAIN_ParseModeOption( char *arg )
 {
-    if (!lstrcmpi("enhanced", arg)) Options.mode = MODE_ENHANCED;
-    else if (!lstrcmpi("standard", arg)) Options.mode = MODE_STANDARD;
+    if (!lstrcmpi32A("enhanced", arg)) Options.mode = MODE_ENHANCED;
+    else if (!lstrcmpi32A("standard", arg)) Options.mode = MODE_STANDARD;
     else
     {
         fprintf(stderr, "Invalid mode '%s' specified.\n", arg);
@@ -306,6 +313,47 @@
     }
 }
 
+/**********************************************************************
+ *           MAIN_ParseVersion
+ */
+static void MAIN_ParseVersion( char *arg )
+{
+    /* If you add any other options, 
+       verify the values you return on the real thing */
+    if(strcmp(arg,"win31")==0) 
+    {
+        getVersion16 = 0x06160A03;
+        /* FIXME: My Win32s installation failed to execute the
+           MSVC 4 test program. So check these values */
+        getVersion32 = 0x80000A03;
+        getVersionEx.dwMajorVersion=3;
+        getVersionEx.dwMinorVersion=10;
+        getVersionEx.dwBuildNumber=0;
+        getVersionEx.dwPlatformId=VER_PLATFORM_WIN32s;
+        strcpy(getVersionEx.szCSDVersion,"Win32s 1.3");
+    }
+    else if(strcmp(arg, "win95")==0)
+    {
+        getVersion16 = 0x07005F03;
+        getVersion32 = 0xC0000004;
+        getVersionEx.dwMajorVersion=4;
+        getVersionEx.dwMinorVersion=0;
+        getVersionEx.dwBuildNumber=0x40003B6;
+        getVersionEx.dwPlatformId=VER_PLATFORM_WIN32_WINDOWS;
+        strcpy(getVersionEx.szCSDVersion,"");
+    }
+    else if(strcmp(arg, "nt351")==0)
+    {
+        getVersion16 = 0x05000A03;
+        getVersion32 = 0x04213303;
+        getVersionEx.dwMajorVersion=3;
+        getVersionEx.dwMinorVersion=51;
+        getVersionEx.dwBuildNumber=0x421;
+        getVersionEx.dwPlatformId=VER_PLATFORM_WIN32_NT;
+        strcpy(getVersionEx.szCSDVersion,"Service Pack 2");
+    }
+    else fprintf(stderr, "Unknown winver system code - ignored\n");
+}
 
 /***********************************************************************
  *           MAIN_ParseOptions
@@ -326,7 +374,7 @@
 #ifdef WINELIB
     /* Need to assemble command line and pass it to WinMain */
 #else
-    if (*argc < 2 || lstrcmpi(argv[1], "-h") == 0) 
+    if (*argc < 2 || lstrcmpi32A(argv[1], "-h") == 0) 
     	MAIN_Usage( argv[0] );
 #endif
 
@@ -414,6 +462,9 @@
           fprintf(stderr,"-dll not supported in libwine\n");
 #endif
       }
+
+      if(MAIN_GetResource( db, ".winver", &value))
+          MAIN_ParseVersion( (char*)value.addr );
 }
 
 
@@ -593,6 +644,7 @@
     return ret_val;
 }
 
+
 /***********************************************************************
  *           MessageBeep    (USER.104)
  */
@@ -601,14 +653,77 @@
 	XBell(display, 100);
 }
 
+
 /***********************************************************************
  *      GetVersion (KERNEL.3)
  */
 LONG GetVersion(void)
 {
+    if (getVersion16) return getVersion16;
     return MAKELONG( WINVERSION, WINDOSVER );
 }
 
+
+/***********************************************************************
+ *      GetVersion32
+ */
+LONG GetVersion32(void)
+{
+    if (getVersion32) return getVersion32;
+    return MAKELONG( 4, DOSVERSION);
+}
+
+
+/***********************************************************************
+ *      GetVersionExA
+ */
+BOOL32 GetVersionEx32A(OSVERSIONINFO32A *v)
+{
+    if(v->dwOSVersionInfoSize!=sizeof(OSVERSIONINFO32A))
+    {
+        fprintf(stddeb,"wrong OSVERSIONINFO size from app");
+        return FALSE;
+    }
+    if(!getVersion32)
+    {
+        /* Return something like NT 3.5 */
+        v->dwMajorVersion = 3;
+        v->dwMinorVersion = 5;
+        v->dwBuildNumber = 42;
+        v->dwPlatformId = VER_PLATFORM_WIN32_NT;
+        strcpy(v->szCSDVersion, "Wine is not an emulator");
+        return TRUE;
+    }
+    v->dwMajorVersion = getVersionEx.dwMajorVersion;
+    v->dwMinorVersion = getVersionEx.dwMinorVersion;
+    v->dwBuildNumber = getVersionEx.dwBuildNumber;
+    v->dwPlatformId = getVersionEx.dwPlatformId;
+    strcpy(v->szCSDVersion, getVersionEx.szCSDVersion);
+    return TRUE;
+}
+
+
+/***********************************************************************
+ *     GetVersionExW
+ */
+BOOL32 GetVersionEx32W(OSVERSIONINFO32W *v)
+{
+	OSVERSIONINFO32A v1;
+	if(v->dwOSVersionInfoSize!=sizeof(OSVERSIONINFO32W))
+	{
+		fprintf(stddeb,"wrong OSVERSIONINFO size from app");
+		return FALSE;
+	}
+	v1.dwOSVersionInfoSize=sizeof(v1);
+	GetVersionEx32A(&v1);
+	v->dwMajorVersion = v1.dwMajorVersion;
+	v->dwMinorVersion = v1.dwMinorVersion;
+	v->dwBuildNumber = v1.dwBuildNumber;
+	v->dwPlatformId = v1.dwPlatformId;
+	STRING32_AnsiToUni(v->szCSDVersion, v1.szCSDVersion);
+	return TRUE;
+}
+
 /***********************************************************************
  *	GetWinFlags (KERNEL.132)
  */
@@ -984,7 +1099,7 @@
 	        case SPI_GETICONTITLELOGFONT: 
 	        {
 		    /* FIXME GetProfileString( "?", "?", "?" ) */
-		  LPLOGFONT lpLogFont = (LPLOGFONT)lpvParam;
+		  LPLOGFONT16 lpLogFont = (LPLOGFONT16)lpvParam;
 		  lpLogFont->lfHeight = 10;
 		  lpLogFont->lfWidth = 0;
 		  lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
@@ -1015,14 +1130,6 @@
 }
 
 /***********************************************************************
-*	HMEMCPY (KERNEL.348)
-*/
-void hmemcpy(LPVOID hpvDest, LPCVOID hpvSource, LONG cbCopy)
-{
-	memcpy(hpvDest,	hpvSource, cbCopy);
-}
-
-/***********************************************************************
 *	COPY (GDI.250)
 */
 void Copy(LPVOID lpSource, LPVOID lpDest, WORD nBytes)
diff --git a/misc/ole2nls.c b/misc/ole2nls.c
index 3f120a5..110fa55 100644
--- a/misc/ole2nls.c
+++ b/misc/ole2nls.c
@@ -665,7 +665,7 @@
 	}
 
 	if(retLen>len)retLen=len;
-	lstrcpyn(buf,retString,len);
+	lstrcpyn32A(buf,retString,len);
 	return retLen;
 }
 
@@ -690,8 +690,7 @@
 	l2 = (l2==-1)?strlen(s2):l2;
 	len = l1<l2 ? l1:l2;
 	ret = (fdwStyle & NORM_IGNORECASE) ?
-		lstrncmpi(s1,s2,len)	:
-		strncmp(s1,s2,len);
+		lstrncmpi32A(s1,s2,len)	: lstrncmp32A(s1,s2,len);
 	/* not equal, return 1 or 3 */
 	if(ret!=0)return ret+2;
 	/* same len, return 2 */
diff --git a/misc/registry.c b/misc/registry.c
index 9a71264..11fcf67 100644
--- a/misc/registry.c
+++ b/misc/registry.c
@@ -41,6 +41,31 @@
 #define KEY_REGISTRY	"Software\\The WINE team\\WINE\\Registry"
 #define VAL_SAVEUPDATED	"SaveOnlyUpdatedKeys"
 
+/* one value of a key */
+typedef struct tagKEYVALUE
+{
+    LPWSTR   name;          /* name of value (UNICODE) or NULL for win31 */
+    DWORD    type;          /* type of value */
+    DWORD    len;           /* length of data */
+    DWORD    lastmodified;  /* time of seconds since 1.1.1970 */
+    LPBYTE   data;          /* content, may be strings, binaries, etc. */
+} KEYVALUE,*LPKEYVALUE;
+
+/* a registry key */
+typedef struct tagKEYSTRUCT
+{
+    LPWSTR               keyname;       /* name of THIS key (UNICODE) */
+    DWORD                flags;         /* flags. */
+    LPWSTR               class;
+    /* values */
+    DWORD                nrofvalues;    /* nr of values in THIS key */
+    LPKEYVALUE           values;        /* values in THIS key */
+    /* key management pointers */
+    struct tagKEYSTRUCT	*next;          /* next key on same hierarchy */
+    struct tagKEYSTRUCT	*nextsub;       /* keys that hang below THIS key */
+} KEYSTRUCT, *LPKEYSTRUCT;
+
+
 static KEYSTRUCT	*key_classes_root=NULL;	/* windows 3.1 global values */
 static KEYSTRUCT	*key_current_user=NULL;	/* user specific values */
 static KEYSTRUCT	*key_local_machine=NULL;/* machine specific values */
@@ -57,10 +82,10 @@
 #define strdupA2W(x)	STRING32_DupAnsiToUni(x)
 #define strdupW2A(x)	STRING32_DupUniToAnsi(x)
 #define strdupW(x)	STRING32_strdupW(x)
-#define strcmpW(a,b)	STRING32_lstrcmpW(a,b)
+#define strcmpW(a,b)	lstrcmp32W(a,b)
 #define strcmpniW(a,b)	STRING32_lstrcmpniW(a,b)
 #define strchrW(a,c)	STRING32_lstrchrW(a,c)
-#define strlenW(a)	STRING32_UniLen(a)
+#define strlenW(a)	lstrlen32W(a)
 #define strcpyWA(a,b)	STRING32_UniToAnsi(a,b)
 
 static struct openhandle {
diff --git a/misc/shell.c b/misc/shell.c
index 6228161..1eb5f54 100644
--- a/misc/shell.c
+++ b/misc/shell.c
@@ -573,7 +573,7 @@
   UINT 	l = strlen(entry); 
   for( ; *lpEnv ; lpEnv+=strlen(lpEnv)+1 )
      {
-       if( lstrncmpi(lpEnv, entry, l) ) continue;
+       if( lstrncmpi32A(lpEnv, entry, l) ) continue;
        
        if( !*(lpEnv+l) )
          return (lpEnv + l); 		/* empty entry */
diff --git a/misc/spy.c b/misc/spy.c
index f1cbabe..f5fbd4d 100644
--- a/misc/spy.c
+++ b/misc/spy.c
@@ -18,7 +18,7 @@
 #define SPY_MAX_MSGNUM   WM_USER
 #define SPY_INDENT_UNIT  4  /* 4 spaces */
 
-static const char *MessageTypeNames[SPY_MAX_MSGNUM + 1] =
+static const char * const MessageTypeNames[SPY_MAX_MSGNUM + 1] =
 {
     "WM_NULL",			/* 0x00 */
     "WM_CREATE",	
@@ -411,7 +411,7 @@
 };
 
 
-static BOOL SPY_Exclude[SPY_MAX_MSGNUM+1] = { FALSE, };
+static BOOL SPY_Exclude[SPY_MAX_MSGNUM+1];
 static int SPY_IndentLevel  = 0;
 
 #define SPY_EXCLUDE(msg) \
diff --git a/misc/ver.c b/misc/ver.c
index 40308c1..7541a82 100644
--- a/misc/ver.c
+++ b/misc/ver.c
@@ -15,20 +15,23 @@
 #include "lzexpand.h"
 #include "module.h"
 #include "neexe.h"
-#include "stackframe.h"	/* MAKE_SEGPTR */
 #include "stddebug.h"
 #include "debug.h"
 #include "xmalloc.h"
 #include "winreg.h"
+#include "string32.h"
 
-#define LZREAD(what)	if (sizeof(*what)!=LZRead(lzfd,MAKE_SEGPTR(what),sizeof(*what))) return 0;
+#define LZREAD(what)	if (sizeof(*what)!=LZRead32(lzfd,what,sizeof(*what))) return 0;
+
+#define strdupW2A(x)	STRING32_DupUniToAnsi(x)
+#define strdupA2W(x)	STRING32_DupAnsiToUni(x)
 
 int
 read_ne_header(HFILE lzfd,struct ne_header_s *nehd) {
 	struct	mz_header_s	mzh;
 
 	LZSeek(lzfd,0,SEEK_SET);
-	if (sizeof(mzh)!=LZRead(lzfd,MAKE_SEGPTR(&mzh),sizeof(mzh)))
+	if (sizeof(mzh)!=LZRead32(lzfd,&mzh,sizeof(mzh)))
 		return 0;
 	if (mzh.mz_magic!=MZ_SIGNATURE)
 		return 0;
@@ -87,12 +90,12 @@
 				);
 				LZREAD(&len);
 				str=xmalloc(len);
-				if (len!=LZRead(lzfd,MAKE_SEGPTR(str),len))
+				if (len!=LZRead32(lzfd,str,len))
 					return 0;
 				dprintf_resource(stderr,"read %s to compare it with %s\n",
 					str,(char*)PTR_SEG_TO_LIN(typeid)
 				);
-				if (lstrcmpi(str,(char*)PTR_SEG_TO_LIN(typeid)))
+				if (lstrcmpi32A(str,(char*)PTR_SEG_TO_LIN(typeid)))
 					skipflag=1;
 				free(str);
 				LZSeek(lzfd,whereleft,SEEK_SET);
@@ -127,12 +130,12 @@
 					);
 					LZREAD(&len);
 					str=xmalloc(len);
-					if (len!=LZRead(lzfd,MAKE_SEGPTR(str),len))
+					if (len!=LZRead32(lzfd,str,len))
 						return 0;
 					dprintf_resource(stderr,"read %s to compare it with %s\n",
 						str,(char*)PTR_SEG_TO_LIN(typeid)
 					);
-					if (!lstrcmpi(str,(char*)PTR_SEG_TO_LIN(typeid)))
+					if (!lstrcmpi32A(str,(char*)PTR_SEG_TO_LIN(typeid)))
 						skipflag=0;
 					free(str);
 					LZSeek(lzfd,whereleft,SEEK_SET);
@@ -144,7 +147,7 @@
 			*off	= (int)ni.offset<<shiftcount;
 			len	= ni.length<<shiftcount;
 			rdata=(WORD*)xmalloc(len);
-			if (len!=LZRead(lzfd,MAKE_SEGPTR(rdata),len)) {
+			if (len!=LZRead32(lzfd,rdata,len)) {
 				free(rdata);
 				return 0;
 			}
@@ -156,6 +159,7 @@
 	}
 }
 
+/* GetFileResourceSize				[VER.2] */
 DWORD
 GetFileResourceSize(LPCSTR filename,SEGPTR restype,SEGPTR resid,LPDWORD off) {
 	HFILE	lzfd;
@@ -167,7 +171,7 @@
 	fprintf(stderr,"GetFileResourceSize(%s,%lx,%lx,%p)\n",
 		filename,(LONG)restype,(LONG)resid,off
 	);
-	lzfd=LZOpenFile(filename,&ofs,OF_READ);
+	lzfd=LZOpenFile16(filename,&ofs,OF_READ);
 	if (lzfd==0)
 		return 0;
 	if (!read_ne_header(lzfd,&nehd)) {
@@ -183,6 +187,7 @@
 	return reslen;
 }
 
+/* GetFileResourceSize				[VER.3] */
 DWORD
 GetFileResource(LPCSTR filename,SEGPTR restype,SEGPTR resid,
 		DWORD off,DWORD datalen,LPVOID data
@@ -196,7 +201,7 @@
 		filename,(LONG)restype,(LONG)resid,off,datalen,data
 	);
 
-	lzfd=LZOpenFile(filename,&ofs,OF_READ);
+	lzfd=LZOpenFile16(filename,&ofs,OF_READ);
 	if (lzfd==0)
 		return 0;
 	if (!off) {
@@ -213,19 +218,19 @@
 	LZSeek(lzfd,off,SEEK_SET);
 	if (reslen>datalen)
 		reslen=datalen;
-	LZRead(lzfd,MAKE_SEGPTR(data),reslen);
+	LZRead32(lzfd,data,reslen);
 	LZClose(lzfd);
 	return reslen;
 }
 
+/* GetFileVersionInfoSize			[VER.6] */
 DWORD
-GetFileVersionInfoSize(LPCSTR filename,LPDWORD handle) {
+GetFileVersionInfoSize16(LPCSTR filename,LPDWORD handle) {
 	DWORD	len,ret;
 	BYTE	buf[72];
 	VS_FIXEDFILEINFO *vffi;
 
-	fprintf(stderr,"GetFileVersionInfoSize(%s,%p)\n",filename,handle);
-
+	dprintf_resource(stderr,"GetFileVersionInfoSize16(%s,%p)\n",filename,handle);
 	len=GetFileResourceSize(filename,VS_FILE_INFO,VS_VERSION_INFO,handle);
 	if (!len)
 		return 0;
@@ -330,9 +335,29 @@
 	return len;
 }
 
+/* GetFileVersionInfoSize32A			[VERSION.1] */
+DWORD
+GetFileVersionInfoSize32A(LPCSTR filename,LPDWORD handle) {
+	dprintf_resource(stderr,"GetFileVersionInfoSize32A(%s,%p)\n",filename,handle);
+	return GetFileVersionInfoSize16(filename,handle);
+}
+
+/* GetFileVersionInfoSize32W			[VERSION.2] */
+DWORD
+GetFileVersionInfoSize32W(LPCWSTR filename,LPDWORD handle) {
+	LPSTR	xfn;
+	DWORD	ret;
+
+	xfn	= strdupW2A(filename);
+	ret=GetFileVersionInfoSize16(xfn,handle);
+	free(xfn);
+	return	ret;
+}
+
+/* GetFileVersionInfo				[VER.7] */
 DWORD 
-GetFileVersionInfo(LPCSTR filename,DWORD handle,DWORD datasize,LPVOID data) {
-	fprintf(stderr,"GetFileVersionInfo(%s,%ld,%ld,%p)\n->",
+GetFileVersionInfo16(LPCSTR filename,DWORD handle,DWORD datasize,LPVOID data) {
+	dprintf_resource(stderr,"GetFileVersionInfo16(%s,%ld,%ld,%p)\n->",
 		filename,handle,datasize,data
 	);
 	return GetFileResource(
@@ -340,10 +365,29 @@
 	);
 }
 
+/* GetFileVersionInfoA				[VERSION.0] */
 DWORD 
-VerFindFile(
-	UINT flags,LPCSTR filename,LPCSTR windir,LPCSTR appdir,
-	LPSTR curdir,UINT *curdirlen,LPSTR destdir,UINT*destdirlen
+GetFileVersionInfo32A(LPCSTR filename,DWORD handle,DWORD datasize,LPVOID data) {
+	return GetFileVersionInfo16(filename,handle,datasize,data);
+}
+
+/* GetFileVersionInfoW				[VERSION.3] */
+DWORD 
+GetFileVersionInfo32W(LPCWSTR filename,DWORD handle,DWORD datasize,LPVOID data){
+	DWORD	ret;
+	LPSTR	fn;
+
+	fn	= strdupW2A(filename);
+	ret	= GetFileVersionInfo16(fn,handle,datasize,data);
+	free(fn);
+	return	ret;
+}
+
+/* VerFindFile				[VER.8] */
+DWORD
+VerFindFile16(
+	UINT16 flags,LPCSTR filename,LPCSTR windir,LPCSTR appdir,
+	LPSTR curdir,UINT16 *curdirlen,LPSTR destdir,UINT16 *destdirlen
 ) {
 	fprintf(stderr,"VerFindFile(%x,%s,%s,%s,%p,%d,%p,%d)\n",
 		flags,filename,windir,appdir,curdir,*curdirlen,destdir,*destdirlen
@@ -355,21 +399,88 @@
 	return 0;
 }
 
+/* VerFindFileA						[VERSION.5] */
 DWORD
-VerInstallFile(
-	UINT flags,LPCSTR srcfilename,LPCSTR destfilename,LPCSTR srcdir,
-	LPCSTR destdir,LPSTR tmpfile,UINT*tmpfilelen
+VerFindFile32A(
+	UINT32 flags,LPCSTR filename,LPCSTR windir,LPCSTR appdir,
+	LPSTR curdir,UINT32 *curdirlen,LPSTR destdir,UINT32 *destdirlen
+) {
+	return VerFindFile16(flags,filename,windir,appdir,curdir,curdirlen,destdir,destdirlen);
+}
+
+/* VerFindFileW						[VERSION.6] */
+DWORD
+VerFindFile32W(
+	UINT32 flags,LPCWSTR filename,LPCWSTR windir,LPCWSTR appdir,
+	LPWSTR curdir,UINT32 *curdirlen,LPWSTR destdir,UINT32 *destdirlen
+) {
+	LPSTR	wfn,wwd,wad,wdd,wcd;
+	DWORD	ret;
+
+	wfn = strdupW2A(filename);
+	wwd = strdupW2A(windir);
+	wad = strdupW2A(appdir);
+	wcd = (LPSTR)malloc(*curdirlen);
+	wdd = (LPSTR)malloc(*destdirlen);
+	ret=VerFindFile16(flags,wfn,wwd,wad,wcd,curdirlen,wdd,destdirlen);
+	STRING32_AnsiToUni(curdir,wcd);
+	STRING32_AnsiToUni(destdir,wdd);
+	*curdirlen	= strlen(wcd);
+	*destdirlen	= strlen(wdd);
+	return ret;
+}
+
+/* VerInstallFile					[VER.9] */
+DWORD
+VerInstallFile16(
+	UINT16 flags,LPCSTR srcfilename,LPCSTR destfilename,LPCSTR srcdir,
+	LPCSTR destdir,LPSTR tmpfile,UINT16 *tmpfilelen
 ) {
 	fprintf(stderr,"VerInstallFile(%x,%s,%s,%s,%s,%p,%d)\n",
 		flags,srcfilename,destfilename,srcdir,destdir,tmpfile,*tmpfilelen
 	);
+
+	/* FIXME: Implementation still missing .... */
+
 	return VIF_SRCOLD;
 }
 
+/* VerFindFileA					[VERSION.5] */
+DWORD
+VerInstallFile32A(
+	UINT32 flags,LPCSTR srcfilename,LPCSTR destfilename,LPCSTR srcdir,
+	LPCSTR destdir,LPSTR tmpfile,UINT32 *tmpfilelen
+) {
+	return VerInstallFile16(flags,srcfilename,destfilename,srcdir,destdir,tmpfile,tmpfilelen);
+}
+
+/* VerFindFileW					[VERSION.6] */
+DWORD
+VerInstallFile32W(
+	UINT32 flags,LPCWSTR srcfilename,LPCWSTR destfilename,LPCWSTR srcdir,
+	LPCWSTR destdir,LPWSTR tmpfile,UINT32 *tmpfilelen
+) {
+	LPSTR	wsrcf,wsrcd,wdestf,wdestd,wtmpf;
+	DWORD	ret;
+
+	wsrcf	= strdupW2A(srcfilename);
+	wsrcd	= strdupW2A(srcdir);
+	wdestf	= strdupW2A(destfilename);
+	wdestd	= strdupW2A(destdir);
+	wtmpf	= strdupW2A(tmpfile);
+	ret=VerInstallFile32A(flags,wsrcf,wdestf,wsrcd,wdestd,wtmpf,tmpfilelen);
+	free(wsrcf);
+	free(wsrcd);
+	free(wdestf);
+	free(wdestd);
+	free(wtmpf);
+	return ret;
+}
+
 /* FIXME: This table should, of course, be language dependend */
-static struct map_id2str {
+static const struct map_id2str {
 	UINT	langid;
-	char	*langname;
+	const char *langname;
 } languages[]={
 	{0x0401,"Arabisch"},
 	{0x0402,"Bulgarisch"},
@@ -419,12 +530,23 @@
 	{0x0000,"Unbekannt"},
 };
 
-
+/* VerLanguageName				[VER.10] */
 DWORD
-VerLanguageName(UINT langid,LPSTR langname,UINT langnamelen) {
+VerLanguageName16(UINT16 langid,LPSTR langname,UINT16 langnamelen) {
 	int	i;
+	char	*buf;
 
 	fprintf(stderr,"VerLanguageName(%d,%p,%d)\n",langid,langname,langnamelen);
+	/* First, check \System\CurrentControlSet\control\Nls\Locale\<langid>
+	 * from the registry. 
+	 */
+	buf=(char*)malloc(strlen("\\System\\CurrentControlSet\\control\\Nls\\Locale\\")+9);
+	sprintf(buf,"\\System\\CurrentControlSet\\control\\Nls\\Locale\\%08x",langid);
+	if (ERROR_SUCCESS==RegQueryValue16(HKEY_LOCAL_MACHINE,buf,langname,(LPDWORD)&langnamelen)) {
+		langname[langnamelen-1]='\0';
+		return langnamelen;
+	}
+	/* if that fails, use the interal table */
 	for (i=0;languages[i].langid!=0;i++)
 		if (langid==languages[i].langid)
 			break;
@@ -433,6 +555,45 @@
 	return strlen(languages[i].langname);
 }
 
+/* VerLanguageNameA				[VERSION.9] */
+DWORD
+VerLanguageName32A(UINT32 langid,LPSTR langname,UINT32 langnamelen) {
+	return VerLanguageName16(langid,langname,langnamelen);
+}
+
+/* VerLanguageNameW				[VERSION.10] */
+DWORD
+VerLanguageName32W(UINT32 langid,LPWSTR langname,UINT32 langnamelen) {
+	int	i;
+	char	*buf;
+	LPWSTR	keyname,result;
+
+	/* First, check \System\CurrentControlSet\control\Nls\Locale\<langid>
+	 * from the registry. 
+	 */
+	buf=(char*)malloc(strlen("\\System\\CurrentControlSet\\control\\Nls\\Locale\\")+9);
+	sprintf(buf,"\\System\\CurrentControlSet\\control\\Nls\\Locale\\%08x",langid);
+	keyname=strdupA2W(buf);free(buf);
+	if (ERROR_SUCCESS==RegQueryValue32W(HKEY_LOCAL_MACHINE,keyname,langname,(LPDWORD)&langnamelen)) {
+		free(keyname);
+		return langnamelen;
+	}
+	free(keyname);
+	/* if that fails, use the interal table */
+	for (i=0;languages[i].langid!=0;i++)
+		if (langid==languages[i].langid)
+			break;
+	result=strdupA2W(languages[i].langname);
+	i=lstrlen32W(result)*sizeof(WCHAR);
+	if (i>langnamelen)
+		i=langnamelen;
+	memcpy(langname,result,i);
+	langname[langnamelen-1]='\0';
+	free(result);
+	return strlen(languages[i].langname); /* same as strlenW(result); */
+}
+
+/* FIXME: UNICODE? */
 struct db {
 	WORD	nextoff;
 	WORD	datalen;
@@ -484,17 +645,18 @@
 		}
 		block=block+((db->nextoff+3)&~3);
 	}
-
 }
 
+/* VerQueryValue 			[VER.11] */
 /* take care, 'buffer' is NOT a SEGPTR, it just points to one */
 DWORD
-VerQueryValue(SEGPTR segblock,LPCSTR subblock,SEGPTR *buffer,UINT *buflen) {
+VerQueryValue16(SEGPTR segblock,LPCSTR subblock,SEGPTR *buffer,UINT16 *buflen)
+{
 	BYTE	*block=PTR_SEG_TO_LIN(segblock),*b;
 	struct	db	*db;
 	char	*s;
 
-	fprintf(stderr,"VerQueryValue(%p,%s,%p,%d)\n",
+	fprintf(stderr,"VerQueryValue16(%p,%s,%p,%d)\n",
 		block,subblock,buffer,*buflen
 	);
 	s=(char*)xmalloc(strlen("VS_VERSION_INFO")+strlen(subblock)+1);
@@ -516,8 +678,60 @@
 	return 1;
 }
 
-/*
-   20 GETFILEVERSIONINFORAW
-   21 VERFTHK_THUNKDATA16
-   22 VERTHKSL_THUNKDATA16
-*/
+DWORD
+VerQueryValue32A(LPVOID vblock,LPCSTR subblock,LPVOID *vbuffer,UINT32 *buflen)
+{
+	BYTE	*b,*block=(LPBYTE)vblock,**buffer=(LPBYTE*)vbuffer;
+	struct	db	*db;
+	char	*s;
+
+	fprintf(stderr,"VerQueryValue32A(%p,%s,%p,%d)\n",
+		block,subblock,buffer,*buflen
+	);
+	s=(char*)xmalloc(strlen("VS_VERSION_INFO")+strlen(subblock)+1);
+	strcpy(s,"VS_VERSION_INFO");strcat(s,subblock);
+	b=_find_data(block,s);
+	if (b==NULL) {
+		*buflen=0;
+		return 0;
+	}
+	db=(struct db*)b;
+	*buflen	= db->datalen;
+	/* let b point to data area */
+	b	= b+4+((strlen(db->name)+4)&3);
+	*buffer	= b;
+	fprintf(stderr,"	-> %s=%s\n",subblock,b);
+	return 1;
+}
+
+DWORD
+VerQueryValue32W(LPVOID vblock,LPCWSTR subblock,LPVOID *vbuffer,UINT32 *buflen)
+{
+	/* FIXME: hmm, we not only need to convert subblock, but also 
+	 *        the content...or?
+	 * And what about UNICODE version info?
+	 * And the NAMES of the values?
+	 */
+	BYTE		*b,**buffer=(LPBYTE*)vbuffer,*block=(LPBYTE)vblock;
+	struct	db	*db;
+	char		*s,*sb;
+
+	sb=strdupW2A(subblock);
+	s=(char*)xmalloc(strlen("VS_VERSION_INFO")+strlen(sb)+1);
+	strcpy(s,"VS_VERSION_INFO");strcat(s,sb);
+	b=_find_data(block,s);
+	if (b==NULL) {
+		*buflen=0;
+		free(sb);
+		return 0;
+	}
+	db=(struct db*)b;
+	*buflen	= db->datalen;
+	/* let b point to data area */
+	b	= b+4+((strlen(db->name)+4)&3);
+	*buffer	= b;
+	fprintf(stderr,"	-> %s=%s\n",sb,b);
+	free(sb);
+	return 1;
+}
+/* 20 GETFILEVERSIONINFORAW */
diff --git a/misc/wsprintf.c b/misc/wsprintf.c
new file mode 100644
index 0000000..ac3b8bc
--- /dev/null
+++ b/misc/wsprintf.c
@@ -0,0 +1,555 @@
+/*
+ * wsprintf functions
+ *
+ * Copyright 1996 Alexandre Julliard
+ */
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+#include "windows.h"
+#include "ldt.h"
+#include "stackframe.h"
+
+#define WPRINTF_LEFTALIGN   0x0001  /* Align output on the left ('-' prefix) */
+#define WPRINTF_PREFIX_HEX  0x0002  /* Prefix hex with 0x ('#' prefix) */
+#define WPRINTF_ZEROPAD     0x0004  /* Pad with zeros ('0' prefix) */
+#define WPRINTF_LONG        0x0008  /* Long arg ('l' prefix) */
+#define WPRINTF_SHORT       0x0010  /* Short arg ('h' prefix) */
+#define WPRINTF_UPPER_HEX   0x0020  /* Upper-case hex ('X' specifier) */
+
+typedef enum
+{
+    WPR_CHAR,
+    WPR_WCHAR,
+    WPR_STRING,
+    WPR_WSTRING,
+    WPR_SIGNED,
+    WPR_UNSIGNED,
+    WPR_HEXA
+} WPRINTF_TYPE;
+
+typedef struct
+{
+    UINT32         flags;
+    UINT32         width;
+    UINT32         precision;
+    WPRINTF_TYPE   type;
+} WPRINTF_FORMAT;
+
+
+/***********************************************************************
+ *           WPRINTF_ParseFormatA
+ *
+ * Parse a format specification. A format specification has the form:
+ *
+ * [-][#][0][width][.precision]type
+ *
+ * Return value is the length of the format specification in characters.
+ */
+static INT32 WPRINTF_ParseFormatA( LPCSTR format, WPRINTF_FORMAT *res )
+{
+    LPCSTR p = format;
+
+    res->flags = 0;
+    res->width = 0;
+    res->precision = 0;
+    if (*p == '-') { res->flags |= WPRINTF_LEFTALIGN; p++; }
+    if (*p == '#') { res->flags |= WPRINTF_PREFIX_HEX; p++; }
+    if (*p == '0') { res->flags |= WPRINTF_ZEROPAD; p++; }
+    while ((*p >= '0') && (*p <= '9'))  /* width field */
+    {
+        res->width = res->width * 10 + *p - '0';
+        p++;
+    }
+    if (*p == '.')  /* precision field */
+    {
+        p++;
+        while ((*p >= '0') && (*p <= '9'))
+        {
+            res->precision = res->precision * 10 + *p - '0';
+            p++;
+        }
+    }
+    if (*p == 'l') { res->flags |= WPRINTF_LONG; p++; }
+    else if (*p == 'h') { res->flags |= WPRINTF_SHORT; p++; }
+    switch(*p)
+    {
+    case 'c':
+        res->type = (res->flags & WPRINTF_LONG) ? WPR_WCHAR : WPR_CHAR;
+        break;
+    case 'C':
+        res->type = (res->flags & WPRINTF_SHORT) ? WPR_CHAR : WPR_WCHAR;
+        break;
+    case 'd':
+    case 'i':
+        res->type = WPR_SIGNED;
+        break;
+    case 's':
+        res->type = (res->flags & WPRINTF_LONG) ? WPR_WSTRING : WPR_STRING;
+        break;
+    case 'S':
+        res->type = (res->flags & WPRINTF_SHORT) ? WPR_STRING : WPR_WSTRING;
+        break;
+    case 'u':
+        res->type = WPR_UNSIGNED;
+        break;
+    case 'X':
+        res->flags |= WPRINTF_UPPER_HEX;
+        /* fall through */
+    case 'x':
+        res->type = WPR_HEXA;
+        break;
+    default:
+        fprintf( stderr, "wvsprintf32A: unknown format '%c'\n", *p );
+        break;
+    }
+    return (INT32)(p - format) + 1;
+}
+
+
+/***********************************************************************
+ *           WPRINTF_ParseFormatW
+ *
+ * Parse a format specification. A format specification has the form:
+ *
+ * [-][#][0][width][.precision]type
+ *
+ * Return value is the length of the format specification in characters.
+ */
+static INT32 WPRINTF_ParseFormatW( LPCWSTR format, WPRINTF_FORMAT *res )
+{
+    LPCWSTR p = format;
+
+    res->flags = 0;
+    res->width = 0;
+    res->precision = 0;
+    if (*p == '-') { res->flags |= WPRINTF_LEFTALIGN; p++; }
+    if (*p == '#') { res->flags |= WPRINTF_PREFIX_HEX; p++; }
+    if (*p == '0') { res->flags |= WPRINTF_ZEROPAD; p++; }
+    while ((*p >= '0') && (*p <= '9'))  /* width field */
+    {
+        res->width = res->width * 10 + *p - '0';
+        p++;
+    }
+    if (*p == '.')  /* precision field */
+    {
+        p++;
+        while ((*p >= '0') && (*p <= '9'))
+        {
+            res->precision = res->precision * 10 + *p - '0';
+            p++;
+        }
+    }
+    if (*p == 'l') { res->flags |= WPRINTF_LONG; p++; }
+    else if (*p == 'h') { res->flags |= WPRINTF_SHORT; p++; }
+    switch((CHAR)*p)
+    {
+    case 'c':
+        res->type = (res->flags & WPRINTF_SHORT) ? WPR_CHAR : WPR_WCHAR;
+        break;
+    case 'C':
+        res->type = (res->flags & WPRINTF_LONG) ? WPR_WCHAR : WPR_CHAR;
+        break;
+    case 'd':
+    case 'i':
+        res->type = WPR_SIGNED;
+        break;
+    case 's':
+        res->type = (res->flags & WPRINTF_SHORT) ? WPR_STRING : WPR_WSTRING;
+        break;
+    case 'S':
+        res->type = (res->flags & WPRINTF_LONG) ? WPR_WSTRING : WPR_STRING;
+        break;
+    case 'u':
+        res->type = WPR_UNSIGNED;
+        break;
+    case 'X':
+        res->flags |= WPRINTF_UPPER_HEX;
+        /* fall through */
+    case 'x':
+        res->type = WPR_HEXA;
+        break;
+    default:
+        fprintf( stderr, "wvsprintf32W: unknown format '%c'\n", (CHAR)*p );
+        break;
+    }
+    return (INT32)(p - format) + 1;
+}
+
+
+/***********************************************************************
+ *           WPRINTF_GetLen
+ */
+static UINT32 WPRINTF_GetLen( WPRINTF_FORMAT *format, LPCVOID arg,
+                              LPSTR number, UINT32 maxlen )
+{
+    UINT32 len;
+
+    if (format->flags & WPRINTF_LEFTALIGN) format->flags &= ~WPRINTF_ZEROPAD;
+    if (format->width > maxlen) format->width = maxlen;
+    switch(format->type)
+    {
+    case WPR_CHAR:
+    case WPR_WCHAR:
+        return (format->precision = 1);
+    case WPR_STRING:
+        for (len = 0; !format->precision || (len < format->precision); len++)
+            if (!*(*(LPCSTR *)arg + len)) break;
+        if (len > maxlen) len = maxlen;
+        return (format->precision = len);
+    case WPR_WSTRING:
+        for (len = 0; !format->precision || (len < format->precision); len++)
+            if (!*(*(LPCWSTR *)arg + len)) break;
+        if (len > maxlen) len = maxlen;
+        return (format->precision = len);
+    case WPR_SIGNED:
+        len = sprintf( number, "%d", *(INT32 *)arg );
+        break;
+    case WPR_UNSIGNED:
+        len = sprintf( number, "%u", *(UINT32 *)arg );
+        break;
+    case WPR_HEXA:
+        len = sprintf( number,
+                        (format->flags & WPRINTF_UPPER_HEX) ? "%X" : "%x",
+                        *(UINT32 *)arg );
+        if (format->flags & WPRINTF_PREFIX_HEX) len += 2;
+        break;
+    default:
+        return 0;
+    }
+    if (len > maxlen) len = maxlen;
+    if (format->precision < len) format->precision = len;
+    if (format->precision > maxlen) format->precision = maxlen;
+    if ((format->flags & WPRINTF_ZEROPAD) && (format->width > format->precision))
+        format->precision = format->width;
+    return len;
+}
+
+
+/***********************************************************************
+ *           wvsnprintf16   (Not a Windows API)
+ */
+INT16 wvsnprintf16( LPSTR buffer, UINT16 maxlen, LPCSTR spec, LPCVOID args )
+{
+    WPRINTF_FORMAT format;
+    LPSTR p = buffer;
+    UINT32 i, len;
+    CHAR number[20];
+    DWORD cur_arg;
+
+    while (*spec && (maxlen > 1))
+    {
+        if (*spec != '%') { *p++ = *spec++; maxlen--; continue; }
+        spec++;
+        if (*spec == '%') { *p++ = *spec++; maxlen--; continue; }
+        spec += WPRINTF_ParseFormatA( spec, &format );
+        switch(format.type)
+        {
+        case WPR_CHAR:
+            cur_arg = (DWORD)*(CHAR *)args;
+            args = (CHAR *)args + 1;
+            break;
+        case WPR_STRING:
+            cur_arg = (DWORD)PTR_SEG_TO_LIN( *(SEGPTR *)args );
+            args = (SEGPTR *)args + 1;
+            break;
+        case WPR_HEXA:
+        case WPR_SIGNED:
+        case WPR_UNSIGNED:
+            if (format.flags & WPRINTF_LONG)
+            {
+                cur_arg = (DWORD)*(UINT32 *)args;
+                args = (UINT32 *)args + 1;
+            }
+            else
+            {
+                cur_arg = (DWORD)*(UINT16 *)args;
+                args = (UINT16 *)args + 1;
+            }
+            break;
+        case WPR_WCHAR:
+        case WPR_WSTRING:
+            fprintf( stderr, "Unicode not supported in wsprintf16\n" );
+            continue;
+        }
+        len = WPRINTF_GetLen( &format, &cur_arg, number, maxlen - 1 );
+        if (!(format.flags & WPRINTF_LEFTALIGN))
+            for (i = format.precision; i < format.width; i++, maxlen--)
+                *p++ = ' ';
+        switch(format.type)
+        {
+        case WPR_CHAR:
+            if ((*p = (CHAR)cur_arg)) p++;
+            else if (format.width > 1) *p++ = ' ';
+            else len = 0;
+            break;
+        case WPR_STRING:
+            if (len) memcpy( p, (LPCSTR)cur_arg, len );
+            p += len;
+            break;
+        case WPR_HEXA:
+            if ((format.flags & WPRINTF_PREFIX_HEX) && (maxlen > 3))
+            {
+                *p++ = '0';
+                *p++ = (format.flags & WPRINTF_UPPER_HEX) ? 'X' : 'x';
+                maxlen -= 2;
+                len -= 2;
+                format.precision -= 2;
+                format.width -= 2;
+            }
+            /* fall through */
+        case WPR_SIGNED:
+        case WPR_UNSIGNED:
+            for (i = len; i < format.precision; i++, maxlen--) *p++ = '0';
+            if (len) memcpy( p, number, len );
+            p += len;
+            break;
+        case WPR_WCHAR:
+        case WPR_WSTRING:
+            fprintf( stderr, "Unicode not supported in wsprintf16\n" );
+            break;
+        }
+        if (format.flags & WPRINTF_LEFTALIGN)
+            for (i = format.precision; i < format.width; i++, maxlen--)
+                *p++ = ' ';
+        maxlen -= len;
+    }
+    *p = 0;
+    return (maxlen > 1) ? (INT32)(p - buffer) : -1;
+}
+
+
+/***********************************************************************
+ *           wvsnprintf32A   (Not a Windows API)
+ */
+INT32 wvsnprintf32A( LPSTR buffer, UINT32 maxlen, LPCSTR spec, LPCVOID args )
+{
+    WPRINTF_FORMAT format;
+    LPSTR p = buffer;
+    UINT32 i, len;
+    CHAR number[20];
+
+    while (*spec && (maxlen > 1))
+    {
+        if (*spec != '%') { *p++ = *spec++; maxlen--; continue; }
+        spec++;
+        if (*spec == '%') { *p++ = *spec++; maxlen--; continue; }
+        spec += WPRINTF_ParseFormatA( spec, &format );
+        len = WPRINTF_GetLen( &format, args, number, maxlen - 1 );
+        if (!(format.flags & WPRINTF_LEFTALIGN))
+            for (i = format.precision; i < format.width; i++, maxlen--)
+                *p++ = ' ';
+        switch(format.type)
+        {
+        case WPR_WCHAR:
+            if ((*p = (CHAR)*(WCHAR *)args)) p++;
+            else if (format.width > 1) *p++ = ' ';
+            else len = 0;
+            break;
+        case WPR_CHAR:
+            if ((*p = *(CHAR *)args)) p++;
+            else if (format.width > 1) *p++ = ' ';
+            else len = 0;
+            break;
+        case WPR_STRING:
+            if (len) memcpy( p, *(LPCSTR *)args, len );
+            p += len;
+            break;
+        case WPR_WSTRING:
+            for (i = 0; i < len; i++) *p++ = (CHAR)*(*(LPCWSTR *)args + i);
+            break;
+        case WPR_HEXA:
+            if ((format.flags & WPRINTF_PREFIX_HEX) && (maxlen > 3))
+            {
+                *p++ = '0';
+                *p++ = (format.flags & WPRINTF_UPPER_HEX) ? 'X' : 'x';
+                maxlen -= 2;
+                len -= 2;
+                format.precision -= 2;
+                format.width -= 2;
+            }
+            /* fall through */
+        case WPR_SIGNED:
+        case WPR_UNSIGNED:
+            for (i = len; i < format.precision; i++, maxlen--) *p++ = '0';
+            if (len) memcpy( p, number, len );
+            p += len;
+            break;
+        }
+        if (format.flags & WPRINTF_LEFTALIGN)
+            for (i = format.precision; i < format.width; i++, maxlen--)
+                *p++ = ' ';
+        args = (INT32 *)args + 1;
+        maxlen -= len;
+    }
+    *p = 0;
+    return (maxlen > 1) ? (INT32)(p - buffer) : -1;
+}
+
+
+/***********************************************************************
+ *           wvsnprintf32W   (Not a Windows API)
+ */
+INT32 wvsnprintf32W( LPWSTR buffer, UINT32 maxlen, LPCWSTR spec, LPCVOID args )
+{
+    WPRINTF_FORMAT format;
+    LPWSTR p = buffer;
+    UINT32 i, len;
+    CHAR number[20];
+
+    while (*spec && (maxlen > 1))
+    {
+        if (*spec != '%') { *p++ = *spec++; maxlen--; continue; }
+        spec++;
+        if (*spec == '%') { *p++ = *spec++; maxlen--; continue; }
+        spec += WPRINTF_ParseFormatW( spec, &format );
+        len = WPRINTF_GetLen( &format, args, number, maxlen - 1 );
+        if (!(format.flags & WPRINTF_LEFTALIGN))
+            for (i = format.precision; i < format.width; i++, maxlen--)
+                *p++ = ' ';
+        switch(format.type)
+        {
+        case WPR_WCHAR:
+            if ((*p = *(WCHAR *)args)) p++;
+            else if (format.width > 1) *p++ = ' ';
+            else len = 0;
+            break;
+        case WPR_CHAR:
+            if ((*p = (WCHAR)*(CHAR *)args)) p++;
+            else if (format.width > 1) *p++ = ' ';
+            else len = 0;
+            break;
+        case WPR_STRING:
+            for (i = 0; i < len; i++) *p++ = (WCHAR)*(*(LPCSTR *)args + i);
+            break;
+        case WPR_WSTRING:
+            if (len) memcpy( p, *(LPCWSTR *)args, len * sizeof(WCHAR) );
+            p += len;
+            break;
+        case WPR_HEXA:
+            if ((format.flags & WPRINTF_PREFIX_HEX) && (maxlen > 3))
+            {
+                *p++ = '0';
+                *p++ = (format.flags & WPRINTF_UPPER_HEX) ? 'X' : 'x';
+                maxlen -= 2;
+                len -= 2;
+                format.precision -= 2;
+                format.width -= 2;
+            }
+            /* fall through */
+        case WPR_SIGNED:
+        case WPR_UNSIGNED:
+            for (i = len; i < format.precision; i++, maxlen--) *p++ = '0';
+            for (i = 0; i < len; i++) *p++ = (WCHAR)number[i];
+            break;
+        }
+        if (format.flags & WPRINTF_LEFTALIGN)
+            for (i = format.precision; i < format.width; i++, maxlen--)
+                *p++ = ' ';
+        args = (INT32 *)args + 1;
+        maxlen -= len;
+    }
+    *p = 0;
+    return (maxlen > 1) ? (INT32)(p - buffer) : -1;
+}
+
+
+/***********************************************************************
+ *           wvsprintf16   (USER.421)
+ */
+INT16 wvsprintf16( LPSTR buffer, LPCSTR spec, LPCVOID args )
+{
+    return wvsnprintf16( buffer, 0xffff, spec, args );
+}
+
+
+/***********************************************************************
+ *           wvsprintf32A   (USER32.586)
+ */
+INT32 wvsprintf32A( LPSTR buffer, LPCSTR spec, LPCVOID args )
+{
+    return wvsnprintf32A( buffer, 0xffffffff, spec, args );
+}
+
+
+/***********************************************************************
+ *           wvsprintf32W   (USER32.587)
+ */
+INT32 wvsprintf32W( LPWSTR buffer, LPCWSTR spec, LPCVOID args )
+{
+    return wvsnprintf32W( buffer, 0xffffffff, spec, args );
+}
+
+
+/***********************************************************************
+ *           wsprintf16   (USER.420)
+ */
+/* Winelib version */
+INT16 wsprintf16( LPSTR buffer, LPCSTR spec, ... )
+{
+    va_list valist;
+    INT16 res;
+
+    va_start( valist, spec );
+    /* Note: we call the 32-bit version, because the args are 32-bit */
+    res = (INT16)wvsprintf32A( buffer, spec, (LPCVOID)valist );
+    va_end( valist );
+    return res;
+}
+
+/* Emulator version */
+#ifndef WINELIB
+INT16 WIN16_wsprintf16(void)
+{
+    SEGPTR *win_stack = (DWORD *)CURRENT_STACK16->args;
+    LPSTR buffer = (LPSTR)PTR_SEG_TO_LIN(win_stack[0]);
+    LPCSTR spec  = (LPCSTR)PTR_SEG_TO_LIN(win_stack[1]);
+    return wvsprintf16( buffer, spec, &win_stack[2] );
+
+}
+#endif  /* WINELIB */
+
+
+/***********************************************************************
+ *           wsprintf32A   (USER32.584)
+ */
+/* Winelib version */
+INT32 wsprintf32A( LPSTR buffer, LPCSTR spec, ... )
+{
+    va_list valist;
+    INT32 res;
+
+    va_start( valist, spec );
+    res = wvsprintf32A( buffer, spec, (LPCVOID)valist );
+    va_end( valist );
+    return res;
+}
+
+/* Emulator version */
+INT32 WIN32_wsprintf32A( int *args )
+{
+    return wvsprintf32A( (LPSTR)args[0], (LPCSTR)args[1], (LPCVOID)&args[2] );
+}
+
+
+/***********************************************************************
+ *           wsprintf32W   (USER32.585)
+ */
+/* Winelib version */
+INT32 wsprintf32W( LPWSTR buffer, LPCWSTR spec, ... )
+{
+    va_list valist;
+    INT32 res;
+
+    va_start( valist, spec );
+    res = wvsprintf32W( buffer, spec, (LPCVOID)valist );
+    va_end( valist );
+    return res;
+}
+
+/* Emulator version */
+INT32 WIN32_wsprintf32W( int *args )
+{
+    return wvsprintf32W( (LPWSTR)args[0], (LPCWSTR)args[1], (LPCVOID)&args[2]);
+}
diff --git a/miscemu/cpu.c b/miscemu/cpu.c
index a17f635..63211bd 100644
--- a/miscemu/cpu.c
+++ b/miscemu/cpu.c
@@ -24,7 +24,7 @@
 	{
 	  char info[5], value[5];
 	  while (fscanf (f, " %4s%*s : %4s%*s", info, value) == 2)
-	    if (!lstrcmpi (info, "cpu"))
+	    if (!lstrcmpi32A(info, "cpu"))
 	      {
 		if (isdigit (value[0]) && value[1] == '8'
 		    && value[2] == '6' && value[3] == 0)
diff --git a/miscemu/int21.c b/miscemu/int21.c
index 7d00ee2..b698d2c 100644
--- a/miscemu/int21.c
+++ b/miscemu/int21.c
@@ -631,7 +631,7 @@
         return 0;
     }
 
-    lstrcpyn( ptr, DRIVE_GetDosCwd(drive), 64 );
+    lstrcpyn32A( ptr, DRIVE_GetDosCwd(drive), 64 );
     if (!ptr[0]) strcpy( ptr, "\\" );
     return 1;
 }
@@ -1358,8 +1358,10 @@
         break;
 	
     case 0x4b: /* "EXEC" - LOAD AND/OR EXECUTE PROGRAM */
-        WinExec( PTR_SEG_OFF_TO_LIN( DS_reg(&context), DX_reg(&context) ),
-                 SW_NORMAL );
+        AX_reg(&context) = WinExec( PTR_SEG_OFF_TO_LIN( DS_reg(&context),
+                                                        DX_reg(&context) ),
+                                    SW_NORMAL );
+        if (AX_reg(&context) < 32) SET_CFLAG(&context);
         break;		
 	
     case 0x4c: /* "EXIT" - TERMINATE WITH RETURN CODE */
@@ -1507,8 +1509,9 @@
             }
             else
             {
-                lstrcpyn(PTR_SEG_OFF_TO_LIN(ES_reg(&context),DI_reg(&context)),
-                         truename, 128 );
+                lstrcpyn32A( PTR_SEG_OFF_TO_LIN( ES_reg(&context),
+                                                 DI_reg(&context) ),
+                             truename, 128 );
                 AX_reg(&context) = 0;
             }
         }
@@ -1519,6 +1522,7 @@
     case 0x64: /* OS/2 DOS BOX */
     case 0x65: /* GET EXTENDED COUNTRY INFORMATION */
         INT_BARF( &context, 0x21 );
+        SET_CFLAG(&context);
         break;
 	
     case 0x66: /* GLOBAL CODE PAGE TABLE */
diff --git a/multimedia/mcistring.c b/multimedia/mcistring.c
index 4630c7d..c21081a 100644
--- a/multimedia/mcistring.c
+++ b/multimedia/mcistring.c
@@ -52,7 +52,7 @@
 /* The reason why I just don't lowercase the keywords array in 
  * mciSendString is left as an exercise to the reader.
  */
-#define STRCMP(x,y) lstrcmpi(x,y)
+#define STRCMP(x,y) lstrcmpi32A(x,y)
 
 /* standard functionparameters for all functions */
 #define _MCISTR_PROTO_ \
@@ -65,7 +65,7 @@
 #define _MCI_STR(s) do {\
 	dprintf_mci(stddeb,"->returns \"%s\"",s);\
 	if (lpstrReturnString) {\
-	    lstrcpyn(lpstrReturnString,s,uReturnLength);\
+	    lstrcpyn32A(lpstrReturnString,s,uReturnLength);\
 	    dprintf_mci(stddeb,"-->\"%s\"\n",lpstrReturnString);\
 	}\
 } while(0)
diff --git a/multimedia/mmsystem.c b/multimedia/mmsystem.c
index 465f8c1..f2d40f0 100644
--- a/multimedia/mmsystem.c
+++ b/multimedia/mmsystem.c
@@ -526,7 +526,7 @@
 			msgptr = "Unknown MCI Error !\n";
 			break;
 		}
-        lstrcpyn(lpstrBuffer, msgptr, uLength);
+        lstrcpyn32A(lpstrBuffer, msgptr, uLength);
 	return TRUE;
 }
 
@@ -701,7 +701,7 @@
 				}
 			}
 			if (lpParms->dwRetSize < InstalledListLen)
-				lstrcpyn(lpstrReturn, lpInstallNames, lpParms->dwRetSize - 1);
+				lstrcpyn32A(lpstrReturn, lpInstallNames, lpParms->dwRetSize - 1);
 			else
 				strcpy(lpstrReturn, lpInstallNames);
 			return 0;
@@ -888,7 +888,7 @@
 			msgptr = "Unknown MIDI Error !\n";
 			break;
 		}
-	lstrcpyn(lpText, msgptr, uSize);
+	lstrcpyn32A(lpText, msgptr, uSize);
 	return TRUE;
 }
 
@@ -1341,7 +1341,7 @@
 			msgptr = "Unknown MMSYSTEM Error !\n";
 			break;
 		}
-	lstrcpyn(lpText, msgptr, uSize);
+	lstrcpyn32A(lpText, msgptr, uSize);
 	return TRUE;
 }
 
diff --git a/objects/bitmap.c b/objects/bitmap.c
index 870667e..f54cdc7 100644
--- a/objects/bitmap.c
+++ b/objects/bitmap.c
@@ -3,6 +3,7 @@
  *
  * Copyright 1993 Alexandre Julliard
  */
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <X11/Xlib.h>
@@ -12,8 +13,6 @@
 #include "dc.h"
 #include "bitmap.h"
 #include "stddebug.h"
-/* #define DEBUG_GDI    */
-/* #define DEBUG_BITMAP */
 #include "debug.h"
 
   /* GCs used for B&W and color bitmap operations */
@@ -55,7 +54,7 @@
  *
  * Create an XImage pointing to the bitmap data.
  */
-static XImage *BITMAP_BmpToImage( BITMAP * bmp, void * bmpData )
+static XImage *BITMAP_BmpToImage( BITMAP16 * bmp, LPVOID bmpData )
 {
     extern void _XInitImageFuncPtrs( XImage* );
     XImage * image;
@@ -73,12 +72,13 @@
 
 
 /***********************************************************************
- *           CreateBitmap    (GDI.48)
+ *           CreateBitmap    (GDI.48) (GDI32.25)
  */
-HBITMAP CreateBitmap( INT width, INT height, UINT planes, UINT bpp, LPVOID bits )
+HBITMAP16 CreateBitmap( INT32 width, INT32 height, UINT32 planes,
+                        UINT32 bpp, LPCVOID bits )
 {
     BITMAPOBJ * bmpObjPtr;
-    HBITMAP hbitmap;
+    HBITMAP16 hbitmap;
 
     dprintf_gdi( stddeb, "CreateBitmap: %dx%d, %d colors\n", 
                  width, height, 1 << (planes*bpp) );
@@ -97,11 +97,11 @@
     bmpObjPtr->size.cx = 0;
     bmpObjPtr->size.cy = 0;
     bmpObjPtr->bitmap.bmType = 0;
-    bmpObjPtr->bitmap.bmWidth = width;
-    bmpObjPtr->bitmap.bmHeight = height;
-    bmpObjPtr->bitmap.bmPlanes = planes;
-    bmpObjPtr->bitmap.bmBitsPixel = bpp;
-    bmpObjPtr->bitmap.bmWidthBytes = BITMAP_WIDTH_BYTES( width, bpp );
+    bmpObjPtr->bitmap.bmWidth = (INT16)width;
+    bmpObjPtr->bitmap.bmHeight = (INT16)height;
+    bmpObjPtr->bitmap.bmPlanes = (BYTE)planes;
+    bmpObjPtr->bitmap.bmBitsPixel = (BYTE)bpp;
+    bmpObjPtr->bitmap.bmWidthBytes = (INT16)BITMAP_WIDTH_BYTES( width, bpp );
     bmpObjPtr->bitmap.bmBits = NULL;
 
       /* Create the pixmap */
@@ -118,28 +118,27 @@
 
 
 /***********************************************************************
- *           CreateCompatibleBitmap    (GDI.51)
+ *           CreateCompatibleBitmap    (GDI.51) (GDI32.30)
  */
-HBITMAP CreateCompatibleBitmap( HDC hdc, INT width, INT height )
+HBITMAP16 CreateCompatibleBitmap( HDC32 hdc, INT32 width, INT32 height )
 {
-    HBITMAP	hbmpRet = 0;
-    DC * 	dc;
-    dprintf_gdi(stddeb, "CreateCompatibleBitmap(%04x,%d,%d) = \n", 
-		hdc, width, height );
+    HBITMAP hbmpRet = 0;
+    DC *dc;
+
+    dprintf_gdi( stddeb, "CreateCompatibleBitmap(%04x,%d,%d) = \n", 
+                 hdc, width, height );
     if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ))) return 0;
     
     hbmpRet = CreateBitmap( width, height, 1, dc->w.bitsPerPixel, NULL );
-
     dprintf_gdi(stddeb,"\t\t%04x\n", hbmpRet);
-
     return hbmpRet;
 }
 
 
 /***********************************************************************
- *           CreateBitmapIndirect    (GDI.49)
+ *           CreateBitmapIndirect16    (GDI.49)
  */
-HBITMAP CreateBitmapIndirect( const BITMAP * bmp )
+HBITMAP16 CreateBitmapIndirect16( const BITMAP16 * bmp )
 {
     return CreateBitmap( bmp->bmWidth, bmp->bmHeight, bmp->bmPlanes,
                          bmp->bmBitsPixel, PTR_SEG_TO_LIN( bmp->bmBits ) );
@@ -147,9 +146,19 @@
 
 
 /***********************************************************************
- *           GetBitmapBits    (GDI.74)
+ *           CreateBitmapIndirect32    (GDI32.26)
  */
-LONG GetBitmapBits( HBITMAP hbitmap, LONG count, LPSTR buffer )
+HBITMAP32 CreateBitmapIndirect32( const BITMAP32 * bmp )
+{
+    return CreateBitmap( bmp->bmWidth, bmp->bmHeight, bmp->bmPlanes,
+                         bmp->bmBitsPixel, bmp->bmBits );
+}
+
+
+/***********************************************************************
+ *           GetBitmapBits    (GDI.74) (GDI32.143)
+ */
+LONG GetBitmapBits( HBITMAP32 hbitmap, LONG count, LPVOID buffer )
 {
     BITMAPOBJ * bmp;
     LONG height;
@@ -182,9 +191,9 @@
 
 
 /***********************************************************************
- *           SetBitmapBits    (GDI.106)
+ *           SetBitmapBits    (GDI.106) (GDI32.303)
  */
-LONG SetBitmapBits( HBITMAP hbitmap, LONG count, LPSTR buffer )
+LONG SetBitmapBits( HBITMAP32 hbitmap, LONG count, LPCVOID buffer )
 {
     BITMAPOBJ * bmp;
     LONG height;
@@ -207,7 +216,7 @@
     if (height > bmp->bitmap.bmHeight) height = bmp->bitmap.bmHeight;
     if (!height) return 0;
     	
-    if (!(image = BITMAP_BmpToImage( &bmp->bitmap, buffer ))) return 0;
+    if (!(image = BITMAP_BmpToImage( &bmp->bitmap, (LPVOID)buffer ))) return 0;
     CallTo32_LargeStack( XPutImage, 10,
                          display, bmp->pixmap, BITMAP_GC(bmp), image, 0, 0,
                          0, 0, bmp->bitmap.bmWidth, height );
@@ -271,17 +280,36 @@
 
 	
 /***********************************************************************
- *           BITMAP_GetObject
+ *           BITMAP_GetObject16
  */
-int BITMAP_GetObject( BITMAPOBJ * bmp, int count, LPSTR buffer )
+INT16 BITMAP_GetObject16( BITMAPOBJ * bmp, INT16 count, LPVOID buffer )
 {
-    if (count > sizeof(BITMAP)) count = sizeof(BITMAP);
+    if (count > sizeof(bmp->bitmap)) count = sizeof(bmp->bitmap);
     memcpy( buffer, &bmp->bitmap, count );
     return count;
 }
     
 
 /***********************************************************************
+ *           BITMAP_GetObject32
+ */
+INT32 BITMAP_GetObject32( BITMAPOBJ * bmp, INT32 count, LPVOID buffer )
+{
+    BITMAP32 bmp32;
+    bmp32.bmType       = bmp->bitmap.bmType;
+    bmp32.bmWidth      = bmp->bitmap.bmWidth;
+    bmp32.bmHeight     = bmp->bitmap.bmHeight;
+    bmp32.bmWidthBytes = bmp->bitmap.bmWidthBytes;
+    bmp32.bmPlanes     = bmp->bitmap.bmPlanes;
+    bmp32.bmBitsPixel  = bmp->bitmap.bmBitsPixel;
+    bmp32.bmBits       = NULL;
+    if (count > sizeof(bmp32)) count = sizeof(bmp32);
+    memcpy( buffer, &bmp32, count );
+    return count;
+}
+    
+
+/***********************************************************************
  *           BITMAP_SelectObject
  */
 HBITMAP BITMAP_SelectObject( DC * dc, HBITMAP hbitmap,
@@ -313,9 +341,9 @@
 }
 
 /***********************************************************************
- *           CreateDiscardableBitmap    (GDI.156)
+ *           CreateDiscardableBitmap    (GDI.156) (GDI32.38)
  */
-HBITMAP CreateDiscardableBitmap(HDC hdc, INT width, INT height)
+HBITMAP16 CreateDiscardableBitmap( HDC32 hdc, INT32 width, INT32 height )
 {
     dprintf_bitmap(stddeb,"CreateDiscardableBitmap(%04x, %d, %d); "
 	   "// call CreateCompatibleBitmap() for now!\n",
@@ -337,7 +365,7 @@
 
 
 /***********************************************************************
- *           GetBitmapDimensionEx32    (GDI.468)
+ *           GetBitmapDimensionEx32    (GDI32.144)
  */
 BOOL32 GetBitmapDimensionEx32( HBITMAP32 hbitmap, LPSIZE32 size )
 {
@@ -376,7 +404,7 @@
 
 
 /***********************************************************************
- *           SetBitmapDimensionEx32    (GDI.478)
+ *           SetBitmapDimensionEx32    (GDI32.304)
  */
 BOOL32 SetBitmapDimensionEx32( HBITMAP32 hbitmap, INT32 x, INT32 y,
                                LPSIZE32 prevSize )
diff --git a/objects/brush.c b/objects/brush.c
index a1780ba..6331df0 100644
--- a/objects/brush.c
+++ b/objects/brush.c
@@ -141,13 +141,13 @@
 /***********************************************************************
  *           CreateBrushIndirect    (GDI.50)
  */
-HBRUSH CreateBrushIndirect( const LOGBRUSH * brush )
+HBRUSH CreateBrushIndirect( const LOGBRUSH16 * brush )
 {
     BRUSHOBJ * brushPtr;
     HBRUSH hbrush = GDI_AllocObject( sizeof(BRUSHOBJ), BRUSH_MAGIC );
     if (!hbrush) return 0;
     brushPtr = (BRUSHOBJ *) GDI_HEAP_LIN_ADDR( hbrush );
-    memcpy( &brushPtr->logbrush, brush, sizeof(LOGBRUSH) );
+    memcpy( &brushPtr->logbrush, brush, sizeof(*brush) );
     return hbrush;
 }
 
@@ -157,7 +157,7 @@
  */
 HBRUSH CreateHatchBrush( INT style, COLORREF color )
 {
-    LOGBRUSH logbrush = { BS_HATCHED, color, style };
+    LOGBRUSH16 logbrush = { BS_HATCHED, color, style };
     dprintf_gdi(stddeb, "CreateHatchBrush: %d %06lx\n", style, color );
     if ((style < 0) || (style >= NB_HATCH_STYLES)) return 0;
     return CreateBrushIndirect( &logbrush );
@@ -169,7 +169,7 @@
  */
 HBRUSH CreatePatternBrush( HBITMAP hbitmap )
 {
-    LOGBRUSH logbrush = { BS_PATTERN, 0, 0 };
+    LOGBRUSH16 logbrush = { BS_PATTERN, 0, 0 };
     BITMAPOBJ *bmp, *newbmp;
 
     dprintf_gdi(stddeb, "CreatePatternBrush: %04x\n", hbitmap );
@@ -178,7 +178,7 @@
 
     if (!(bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC )))
 	return 0;
-    logbrush.lbHatch = (INT)CreateBitmapIndirect( &bmp->bitmap );
+    logbrush.lbHatch = (INT16)CreateBitmapIndirect16( &bmp->bitmap );
     newbmp = (BITMAPOBJ *) GDI_GetObjPtr( (HANDLE)logbrush.lbHatch, BITMAP_MAGIC );
     if (!newbmp) return 0;
     XCopyArea( display, bmp->pixmap, newbmp->pixmap, BITMAP_GC(bmp),
@@ -192,7 +192,7 @@
  */
 HBRUSH CreateDIBPatternBrush( HGLOBAL hbitmap, UINT coloruse )
 {
-    LOGBRUSH logbrush = { BS_DIBPATTERN, coloruse, 0 };
+    LOGBRUSH16 logbrush = { BS_DIBPATTERN, coloruse, 0 };
     BITMAPINFO *info, *newInfo;
     int size;
     
@@ -202,8 +202,9 @@
 
     if (!(info = (BITMAPINFO *) GlobalLock16( hbitmap ))) return 0;
 
-    size = info->bmiHeader.biSizeImage;
-    if (!size)
+    if (info->bmiHeader.biCompression)
+        size = info->bmiHeader.biSizeImage;
+    else
 	size = (info->bmiHeader.biWidth * info->bmiHeader.biBitCount + 31) / 32
 	         * 8 * info->bmiHeader.biHeight;
     size += DIB_BitmapInfoSize( info, coloruse );
@@ -226,7 +227,7 @@
  */
 HBRUSH CreateSolidBrush( COLORREF color )
 {
-    LOGBRUSH logbrush = { BS_SOLID, color, 0 };
+    LOGBRUSH16 logbrush = { BS_SOLID, color, 0 };
     dprintf_gdi(stddeb, "CreateSolidBrush: %06lx\n", color );
     return CreateBrushIndirect( &logbrush );
 }
@@ -277,7 +278,7 @@
  */
 int BRUSH_GetObject( BRUSHOBJ * brush, int count, LPSTR buffer )
 {
-    if (count > sizeof(LOGBRUSH)) count = sizeof(LOGBRUSH);
+    if (count > sizeof(brush->logbrush)) count = sizeof(brush->logbrush);
     memcpy( buffer, &brush->logbrush, count );
     return count;
 }
diff --git a/objects/clipping.c b/objects/clipping.c
index 3683d58..8339a42 100644
--- a/objects/clipping.c
+++ b/objects/clipping.c
@@ -5,12 +5,15 @@
  */
 
 #include <stdio.h>
-#include "region.h"
+#include "dc.h"
 #include "metafile.h"
+#include "region.h"
 #include "stddebug.h"
 /* #define DEBUG_CLIPPING */
 #include "debug.h"
 
+#define UpdateDirtyDC(dc) DC_CallHookProc( dc, DCHC_INVALIDVISRGN, 0 )
+
 /***********************************************************************
  *           CLIPPING_SetDeviceClipping
  *
diff --git a/objects/color.c b/objects/color.c
index 41e612a..6868a22 100644
--- a/objects/color.c
+++ b/objects/color.c
@@ -32,7 +32,7 @@
 #define NB_RESERVED_COLORS  20
 
   /* The first and last eight colors are EGA colors */
-static PALETTEENTRY COLOR_sysPaletteEntries[NB_RESERVED_COLORS] =
+static const PALETTEENTRY COLOR_sysPaletteEntries[NB_RESERVED_COLORS] =
 {
     /* red  green blue  flags */
     { 0x00, 0x00, 0x00, 0 },
@@ -271,7 +271,7 @@
 BOOL COLOR_IsSolid( COLORREF color )
 {
     int i;
-    PALETTEENTRY *pEntry = COLOR_sysPaletteEntries;
+    const PALETTEENTRY *pEntry = COLOR_sysPaletteEntries;
 
     if (color & 0xff000000) return TRUE;
     if (!color || (color == 0xffffff)) return TRUE;
diff --git a/objects/font.c b/objects/font.c
index 8f3b4a1..5cde975 100644
--- a/objects/font.c
+++ b/objects/font.c
@@ -24,7 +24,7 @@
 
 #define FONTCACHE 	32	/* dynamic font cache size */
 #define MAX_FONTS	256
-static LPLOGFONT lpLogFontList[MAX_FONTS] = { NULL };
+static LPLOGFONT16 lpLogFontList[MAX_FONTS];
 
 static int ParseFontParms(LPSTR lpFont, WORD wParmsNo, LPSTR lpRetStr, WORD wMaxSiz);
 
@@ -146,7 +146,7 @@
  *
  * Find a X font matching the logical font.
  */
-static XFontStruct * FONT_MatchFont( LOGFONT * font, DC * dc )
+static XFontStruct * FONT_MatchFont( LOGFONT16 * font, DC * dc )
 {
     char pattern[100];
     const char *family, *weight, *charset;
@@ -276,8 +276,8 @@
 /***********************************************************************
  *           FONT_GetMetrics
  */
-void FONT_GetMetrics( LOGFONT * logfont, XFontStruct * xfont,
-		      TEXTMETRIC * metrics )
+void FONT_GetMetrics( LOGFONT16 * logfont, XFontStruct * xfont,
+		      TEXTMETRIC16 * metrics )
 {    
     int average, i, count;
     unsigned long prop;
@@ -357,7 +357,7 @@
 /***********************************************************************
  *           CreateFontIndirect    (GDI.57)
  */
-HFONT CreateFontIndirect( const LOGFONT * font )
+HFONT CreateFontIndirect( const LOGFONT16 * font )
 {
     FONTOBJ * fontPtr;
     HFONT hfont;
@@ -370,7 +370,7 @@
     hfont = GDI_AllocObject( sizeof(FONTOBJ), FONT_MAGIC );
     if (!hfont) return 0;
     fontPtr = (FONTOBJ *) GDI_HEAP_LIN_ADDR( hfont );
-    memcpy( &fontPtr->logfont, font, sizeof(LOGFONT) );
+    memcpy( &fontPtr->logfont, font, sizeof(LOGFONT16) );
     AnsiLower( fontPtr->logfont.lfFaceName );
     dprintf_font(stddeb,"CreateFontIndirect(%p (%d,%d)); return %04x\n",
 	font, font->lfHeight, font->lfWidth, hfont);
@@ -386,8 +386,8 @@
 		  BYTE outpres, BYTE clippres, BYTE quality, BYTE pitch,
 		  LPCSTR name )
 {
-    LOGFONT logfont = { height, width, esc, orient, weight, italic, underline,
-		    strikeout, charset, outpres, clippres, quality, pitch, };
+    LOGFONT16 logfont = {height, width, esc, orient, weight, italic, underline,
+                      strikeout, charset, outpres, clippres, quality, pitch, };
     dprintf_font(stddeb,"CreateFont(%d,%d)\n", height, width);
     if (name)
 	{
@@ -404,7 +404,7 @@
  */
 int FONT_GetObject( FONTOBJ * font, int count, LPSTR buffer )
 {
-    if (count > sizeof(LOGFONT)) count = sizeof(LOGFONT);
+    if (count > sizeof(LOGFONT16)) count = sizeof(LOGFONT16);
     memcpy( buffer, &font->logfont, count );
     return count;
 }
@@ -419,7 +419,7 @@
 
     static struct {
 		HFONT		id;
-		LOGFONT		logfont;
+		LOGFONT16	logfont;
 		int		access;
 		int		used;
 		X_PHYSFONT	cacheFont; } cacheFonts[FONTCACHE], *cacheFontsMin;
@@ -462,7 +462,7 @@
 		/*
 		 * Check if Handle matches the font 
 		 */
-		if(memcmp(&cacheFonts[i].logfont,&(font->logfont), sizeof(LOGFONT))) {
+		if(memcmp(&cacheFonts[i].logfont,&(font->logfont), sizeof(LOGFONT16))) {
 			/* No: remove handle id from dynamic font cache */
 			cacheFonts[i].access=0;
 			cacheFonts[i].used=0;
@@ -470,7 +470,7 @@
 			/* may be there is an unused handle which contains the font */
 			for(i=0; i<FONTCACHE; i++) {
 				if((cacheFonts[i].used == 0) &&
-				  (memcmp(&cacheFonts[i].logfont,&(font->logfont), sizeof(LOGFONT)))== 0) {
+				  (memcmp(&cacheFonts[i].logfont,&(font->logfont), sizeof(LOGFONT16)))== 0) {
 					/* got it load from cache and set new handle id */
 					stockPtr = &cacheFonts[i].cacheFont;
 					cacheFonts[i].access=1;
@@ -564,7 +564,7 @@
 	cacheFontsMin->used=1;
 	cacheFontsMin->id=hfont;
 	memcpy( &dc->u.x.font, &(cacheFontsMin->cacheFont), sizeof(cacheFontsMin->cacheFont) );
-	memcpy(&cacheFontsMin->logfont,&(font->logfont), sizeof(LOGFONT));
+	memcpy(&cacheFontsMin->logfont,&(font->logfont), sizeof(LOGFONT16));
 
     }
     return prevHandle;
@@ -635,7 +635,7 @@
     if (!dc) return 0;
     if (!(font = (FONTOBJ *) GDI_GetObjPtr( dc->w.hFont, FONT_MAGIC )))
         return 0;
-    lstrcpyn( name, font->logfont.lfFaceName, count );
+    lstrcpyn32A( name, font->logfont.lfFaceName, count );
     return strlen(name);
 }
 
@@ -703,7 +703,7 @@
 /***********************************************************************
  *           GetTextMetrics    (GDI.93)
  */
-BOOL GetTextMetrics( HDC hdc, LPTEXTMETRIC metrics )
+BOOL GetTextMetrics( HDC hdc, LPTEXTMETRIC16 metrics )
 {
     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
     if (!dc) return FALSE;
@@ -783,7 +783,7 @@
 /***********************************************************************
  *           GetCharABCWidths   (GDI.307)
  */
-BOOL GetCharABCWidths(HDC hdc, UINT wFirstChar, UINT wLastChar, LPABC lpABC)
+BOOL GetCharABCWidths(HDC hdc, UINT wFirstChar, UINT wLastChar, LPABC16 lpABC)
 {
 
     /* No TrueType fonts in Wine so far */
@@ -881,7 +881,8 @@
 
 static int logfcmp(const void *a,const void *b) 
 {
-  return strcmp( (*(LPLOGFONT *)a)->lfFaceName, (*(LPLOGFONT *)b)->lfFaceName );
+  return strcmp( (*(LPLOGFONT16 *)a)->lfFaceName,
+                 (*(LPLOGFONT16 *)b)->lfFaceName );
 }
 
 void InitFontsList(void)
@@ -892,7 +893,7 @@
   char 	**names;
   char 	slant, spacing;
   int 	i, count;
-  LPLOGFONT lpNewFont;
+  LPLOGFONT16 lpNewFont;
   weight = "medium";
   slant = 'r';
   spacing = '*';
@@ -904,7 +905,7 @@
   names = XListFonts( display, pattern, MAX_FONTS, &count );
   dprintf_font(stddeb,"InitFontsList // count=%d \n", count);
   for (i = 0; i < count; i++) {
-    lpNewFont = malloc(sizeof(LOGFONT) + LF_FACESIZE);
+    lpNewFont = malloc(sizeof(LOGFONT16) + LF_FACESIZE);
     if (lpNewFont == NULL) {
       dprintf_font(stddeb, "InitFontsList // Error alloc new font structure !\n");
       break;
@@ -969,8 +970,8 @@
   HANDLE       hMet;
   HFONT	       hFont;
   HFONT	       hOldFont;
-  LPLOGFONT    lpLogFont;
-  LPTEXTMETRIC lptm;
+  LPLOGFONT16  lpLogFont;
+  LPTEXTMETRIC16 lptm;
   LPSTR	       lpOldName;
   char	       FaceName[LF_FACESIZE];
   int          nRet = 0;
@@ -979,14 +980,14 @@
   dprintf_font(stddeb,"EnumFonts(%04x, %p='%s', %08lx, %08lx)\n", 
 	       hDC, lpFaceName, lpFaceName, (LONG)lpEnumFunc, lpData);
   if (lpEnumFunc == 0) return 0;
-  hLog = GDI_HEAP_ALLOC( sizeof(LOGFONT) + LF_FACESIZE );
-  lpLogFont = (LPLOGFONT) GDI_HEAP_LIN_ADDR(hLog);
+  hLog = GDI_HEAP_ALLOC( sizeof(LOGFONT16) + LF_FACESIZE );
+  lpLogFont = (LPLOGFONT16) GDI_HEAP_LIN_ADDR(hLog);
   if (lpLogFont == NULL) {
     fprintf(stderr,"EnumFonts // can't alloc LOGFONT struct !\n");
     return 0;
   }
-  hMet = GDI_HEAP_ALLOC( sizeof(TEXTMETRIC) );
-  lptm = (LPTEXTMETRIC) GDI_HEAP_LIN_ADDR(hMet);
+  hMet = GDI_HEAP_ALLOC( sizeof(TEXTMETRIC16) );
+  lptm = (LPTEXTMETRIC16) GDI_HEAP_LIN_ADDR(hMet);
   if (lptm == NULL) {
     GDI_HEAP_FREE(hLog);
     fprintf(stderr, "EnumFonts // can't alloc TEXTMETRIC struct !\n");
@@ -1010,7 +1011,7 @@
     }
     dprintf_font(stddeb,"EnumFonts // enum '%s' !\n", lpLogFontList[i]->lfFaceName);
     dprintf_font(stddeb,"EnumFonts // %p !\n", lpLogFontList[i]);
-    memcpy(lpLogFont, lpLogFontList[i], sizeof(LOGFONT) + LF_FACESIZE);
+    memcpy(lpLogFont, lpLogFontList[i], sizeof(LOGFONT16) + LF_FACESIZE);
     hFont = CreateFontIndirect(lpLogFont);
     hOldFont = SelectObject(hDC, hFont);
     GetTextMetrics(hDC, lptm);
@@ -1039,8 +1040,8 @@
   HANDLE       	hMet;
   HFONT	       	hFont;
   HFONT	       	hOldFont;
-  LPENUMLOGFONT lpEnumLogFont;
-  LPTEXTMETRIC	lptm;
+  LPENUMLOGFONT16 lpEnumLogFont;
+  LPTEXTMETRIC16 lptm;
   LPSTR	       	lpOldName;
   char	       	FaceName[LF_FACESIZE];
   int	       	nRet = 0;
@@ -1049,14 +1050,14 @@
   dprintf_font(stddeb,"EnumFontFamilies(%04x, %p, %08lx, %08lx)\n",
 	       hDC, lpszFamily, (DWORD)lpEnumFunc, lpData);
   if (lpEnumFunc == 0) return 0;
-  hLog = GDI_HEAP_ALLOC( sizeof(ENUMLOGFONT) );
-  lpEnumLogFont = (LPENUMLOGFONT) GDI_HEAP_LIN_ADDR(hLog);
+  hLog = GDI_HEAP_ALLOC( sizeof(ENUMLOGFONT16) );
+  lpEnumLogFont = (LPENUMLOGFONT16) GDI_HEAP_LIN_ADDR(hLog);
   if (lpEnumLogFont == NULL) {
     fprintf(stderr,"EnumFontFamilies // can't alloc LOGFONT struct !\n");
     return 0;
   }
-  hMet = GDI_HEAP_ALLOC( sizeof(TEXTMETRIC) );
-  lptm = (LPTEXTMETRIC) GDI_HEAP_LIN_ADDR(hMet);
+  hMet = GDI_HEAP_ALLOC( sizeof(TEXTMETRIC16) );
+  lptm = (LPTEXTMETRIC16) GDI_HEAP_LIN_ADDR(hMet);
   if (lptm == NULL) {
     GDI_HEAP_FREE(hLog);
     fprintf(stderr,"EnumFontFamilies // can't alloc TEXTMETRIC struct !\n");
@@ -1077,10 +1078,10 @@
     } else {
       if (strcmp(FaceName, lpLogFontList[i]->lfFaceName) != 0) continue;
     }
-    memcpy(lpEnumLogFont, lpLogFontList[i], sizeof(LOGFONT));
+    memcpy(lpEnumLogFont, lpLogFontList[i], sizeof(LOGFONT16));
     strcpy(lpEnumLogFont->elfFullName,"");
     strcpy(lpEnumLogFont->elfStyle,"");
-    hFont = CreateFontIndirect((LPLOGFONT)lpEnumLogFont);
+    hFont = CreateFontIndirect((LPLOGFONT16)lpEnumLogFont);
     hOldFont = SelectObject(hDC, hFont);
     GetTextMetrics(hDC, lptm);
     SelectObject(hDC, hOldFont);
@@ -1119,7 +1120,7 @@
 /*************************************************************************
  *             GetKerningPairs      [GDI.332]
  */
-int GetKerningPairs(HDC hDC,int cBufLen,LPKERNINGPAIR lpKerningPairs)
+int GetKerningPairs(HDC hDC,int cBufLen,LPKERNINGPAIR16 lpKerningPairs)
 {
 	/* Wine fonts are ugly and don't support kerning :) */
 	return 0;
diff --git a/objects/gdiobj.c b/objects/gdiobj.c
index 81c1c16..ddf0a21 100644
--- a/objects/gdiobj.c
+++ b/objects/gdiobj.c
@@ -299,12 +299,12 @@
 
 
 /***********************************************************************
- *           GetObject    (GDI.82)
+ *           GetObject16    (GDI.82)
  */
-int GetObject( HANDLE handle, int count, LPSTR buffer )
+INT16 GetObject16( HANDLE16 handle, INT16 count, LPVOID buffer )
 {
     GDIOBJHDR * ptr = NULL;
-    dprintf_gdi(stddeb, "GetObject: %04x %d %p\n", handle, count, buffer );
+    dprintf_gdi(stddeb, "GetObject16: %04x %d %p\n", handle, count, buffer );
     if (!count) return 0;
 
     if ((handle >= FIRST_STOCK_HANDLE) && (handle <= LAST_STOCK_HANDLE))
@@ -320,7 +320,7 @@
       case BRUSH_MAGIC: 
 	  return BRUSH_GetObject( (BRUSHOBJ *)ptr, count, buffer );
       case BITMAP_MAGIC: 
-	  return BITMAP_GetObject( (BITMAPOBJ *)ptr, count, buffer );
+	  return BITMAP_GetObject16( (BITMAPOBJ *)ptr, count, buffer );
       case FONT_MAGIC:
 	  return FONT_GetObject( (FONTOBJ *)ptr, count, buffer );
       case PALETTE_MAGIC:
@@ -331,6 +331,46 @@
 
 
 /***********************************************************************
+ *           GetObject32A    (GDI32.204)
+ */
+INT32 GetObject32A( HANDLE32 handle, INT32 count, LPVOID buffer )
+{
+    GDIOBJHDR * ptr = NULL;
+    dprintf_gdi(stddeb, "GetObject32A: %08x %d %p\n", handle, count, buffer );
+    if (!count) return 0;
+
+    if ((handle >= FIRST_STOCK_HANDLE) && (handle <= LAST_STOCK_HANDLE))
+      ptr = StockObjects[handle - FIRST_STOCK_HANDLE];
+    else
+      ptr = (GDIOBJHDR *) GDI_HEAP_LIN_ADDR( handle );
+    if (!ptr) return 0;
+    
+    switch(ptr->wMagic)
+    {
+      case BITMAP_MAGIC: 
+	  return BITMAP_GetObject32( (BITMAPOBJ *)ptr, count, buffer );
+      case PEN_MAGIC:
+      case BRUSH_MAGIC: 
+      case FONT_MAGIC:
+      case PALETTE_MAGIC:
+          fprintf( stderr, "GetObject32: magic %04x not implemented\n",
+                   ptr->wMagic );
+          break;
+    }
+    return 0;
+}
+
+
+/***********************************************************************
+ *           GetObject32W    (GDI32.206)
+ */
+INT32 GetObject32W( HANDLE32 handle, INT32 count, LPVOID buffer )
+{
+    return GetObject32A( handle, count, buffer );
+}
+
+
+/***********************************************************************
  *           SelectObject    (GDI.45)
  */
 HANDLE SelectObject( HDC hdc, HANDLE handle )
@@ -397,8 +437,8 @@
     };
     
     int i, retval = 0;
-    LOGPEN *pen;
-    LOGBRUSH *brush = NULL;
+    LOGPEN16 *pen;
+    LOGBRUSH16 *brush = NULL;
 
     dprintf_gdi( stddeb, "EnumObjects: %04x %d %08lx %08lx\n",
                  hdc, nObjType, (DWORD)lpEnumFunc, lParam );
@@ -406,7 +446,7 @@
     {
     case OBJ_PEN:
         /* Enumerate solid pens */
-        if (!(pen = SEGPTR_NEW(LOGPEN))) break;
+        if (!(pen = SEGPTR_NEW(LOGPEN16))) break;
         for (i = 0; i < sizeof(solid_colors)/sizeof(solid_colors[0]); i++)
         {
             pen->lopnStyle   = PS_SOLID;
@@ -424,7 +464,7 @@
 
     case OBJ_BRUSH:
         /* Enumerate solid brushes */
-        if (!(brush = SEGPTR_NEW(LOGBRUSH))) break;
+        if (!(brush = SEGPTR_NEW(LOGBRUSH16))) break;
         for (i = 0; i < sizeof(solid_colors)/sizeof(solid_colors[0]); i++)
         {
             brush->lbStyle = BS_SOLID;
diff --git a/objects/metafile.c b/objects/metafile.c
index 983b419..bbaa8c4 100644
--- a/objects/metafile.c
+++ b/objects/metafile.c
@@ -563,17 +563,17 @@
 	
     case META_CREATEPENINDIRECT:
 	MF_AddHandle(ht, nHandles, 
-		     CreatePenIndirect((LOGPEN *)(&(mr->rdParam))));
+		     CreatePenIndirect((LOGPEN16 *)(&(mr->rdParam))));
 	break;
 
     case META_CREATEFONTINDIRECT:
 	MF_AddHandle(ht, nHandles, 
-		     CreateFontIndirect((LOGFONT *)(&(mr->rdParam))));
+		     CreateFontIndirect((LOGFONT16 *)(&(mr->rdParam))));
 	break;
 
     case META_CREATEBRUSHINDIRECT:
 	MF_AddHandle(ht, nHandles, 
-		     CreateBrushIndirect((LOGBRUSH *)(&(mr->rdParam))));
+		     CreateBrushIndirect((LOGBRUSH16 *)(&(mr->rdParam))));
 	break;
 
     /* W. Magro: Some new metafile operations.  Not all debugged. */
@@ -930,17 +930,17 @@
  *         MF_CreateBrushIndirect
  */
 
-BOOL MF_CreateBrushIndirect(DC *dc, HBRUSH hBrush, LOGBRUSH *logbrush)
+BOOL MF_CreateBrushIndirect(DC *dc, HBRUSH hBrush, LOGBRUSH16 *logbrush)
 {
     int index;
     HMETAFILE handle;
-    char buffer[sizeof(METARECORD) - 2 + sizeof(LOGBRUSH)];
+    char buffer[sizeof(METARECORD) - 2 + sizeof(LOGBRUSH16)];
     METARECORD *mr = (METARECORD *)&buffer;
     METAHEADER *mh;
 
-    mr->rdSize = (sizeof(METARECORD) + sizeof(LOGBRUSH) - 2) / 2;
+    mr->rdSize = (sizeof(METARECORD) + sizeof(LOGBRUSH16) - 2) / 2;
     mr->rdFunction = META_CREATEBRUSHINDIRECT;
-    memcpy(&(mr->rdParam), logbrush, sizeof(LOGBRUSH));
+    memcpy(&(mr->rdParam), logbrush, sizeof(LOGBRUSH16));
     if (!(dc->w.hMetaFile = MF_WriteRecord(dc->w.hMetaFile, 
 					  mr, mr->rdSize * 2)))
 	return FALSE;
@@ -968,7 +968,7 @@
  *         MF_CreatePatternBrush
  */
 
-BOOL MF_CreatePatternBrush(DC *dc, HBRUSH hBrush, LOGBRUSH *logbrush)
+BOOL MF_CreatePatternBrush(DC *dc, HBRUSH hBrush, LOGBRUSH16 *logbrush)
 {
     DWORD len, bmSize, biSize;
     HANDLE hmr;
@@ -1009,8 +1009,9 @@
 
     case BS_DIBPATTERN:
 	info = (BITMAPINFO *)GlobalLock16((HANDLE)logbrush->lbHatch);
-	bmSize = info->bmiHeader.biSizeImage;
-	if (!bmSize)
+	if (info->bmiHeader.biCompression)
+            bmSize = info->bmiHeader.biSizeImage;
+        else
 	    bmSize = (info->bmiHeader.biWidth * info->bmiHeader.biBitCount 
 		    + 31) / 32 * 8 * info->bmiHeader.biHeight;
 	biSize = DIB_BitmapInfoSize(info, LOWORD(logbrush->lbColor)); 
@@ -1058,17 +1059,17 @@
  *         MF_CreatePenIndirect
  */
 
-BOOL MF_CreatePenIndirect(DC *dc, HPEN16 hPen, LOGPEN *logpen)
+BOOL MF_CreatePenIndirect(DC *dc, HPEN16 hPen, LOGPEN16 *logpen)
 {
     int index;
     HMETAFILE handle;
-    char buffer[sizeof(METARECORD) - 2 + sizeof(LOGPEN)];
+    char buffer[sizeof(METARECORD) - 2 + sizeof(LOGPEN16)];
     METARECORD *mr = (METARECORD *)&buffer;
     METAHEADER *mh;
 
-    mr->rdSize = (sizeof(METARECORD) + sizeof(LOGPEN) - 2) / 2;
+    mr->rdSize = (sizeof(METARECORD) + sizeof(LOGPEN16) - 2) / 2;
     mr->rdFunction = META_CREATEPENINDIRECT;
-    memcpy(&(mr->rdParam), logpen, sizeof(LOGPEN));
+    memcpy(&(mr->rdParam), logpen, sizeof(LOGPEN16));
     if (!(dc->w.hMetaFile = MF_WriteRecord(dc->w.hMetaFile, mr, 
 					   mr->rdSize * 2)))
 	return FALSE;
@@ -1095,17 +1096,17 @@
  *         MF_CreateFontIndirect
  */
 
-BOOL MF_CreateFontIndirect(DC *dc, HFONT hFont, LOGFONT *logfont)
+BOOL MF_CreateFontIndirect(DC *dc, HFONT hFont, LOGFONT16 *logfont)
 {
     int index;
     HMETAFILE handle;
-    char buffer[sizeof(METARECORD) - 2 + sizeof(LOGFONT)];
+    char buffer[sizeof(METARECORD) - 2 + sizeof(LOGFONT16)];
     METARECORD *mr = (METARECORD *)&buffer;
     METAHEADER *mh;
 
-    mr->rdSize = (sizeof(METARECORD) + sizeof(LOGFONT) - 2) / 2;
+    mr->rdSize = (sizeof(METARECORD) + sizeof(LOGFONT16) - 2) / 2;
     mr->rdFunction = META_CREATEFONTINDIRECT;
-    memcpy(&(mr->rdParam), logfont, sizeof(LOGFONT));
+    memcpy(&(mr->rdParam), logfont, sizeof(LOGFONT16));
     if (!(dc->w.hMetaFile = MF_WriteRecord(dc->w.hMetaFile, mr, 
 					  mr->rdSize * 2)))
 	return FALSE;
diff --git a/objects/oembitmap.c b/objects/oembitmap.c
index 13f4627..bb5939c 100644
--- a/objects/oembitmap.c
+++ b/objects/oembitmap.c
@@ -149,7 +149,7 @@
 #define OIC_FIRST  OIC_SAMPLE      /* First OEM icon */
 #define OIC_LAST   OIC_WINEICON   /* Last OEM icon */
 
-static char **OBM_Icons_Data[OIC_LAST-OIC_FIRST+1] =
+static char ** const OBM_Icons_Data[OIC_LAST-OIC_FIRST+1] =
 {
     oic_sample,    /* OIC_SAMPLE */
     oic_hand,      /* OIC_HAND */
@@ -216,7 +216,7 @@
 #endif
 };
 
-static HCURSOR OBM_Cursors[NB_CURSORS] = { 0, };
+static HCURSOR OBM_Cursors[NB_CURSORS];
 
 
   /* All the colors used in the xpm files must be included in this   */
diff --git a/objects/pen.c b/objects/pen.c
index f28ce04..c32ca20 100644
--- a/objects/pen.c
+++ b/objects/pen.c
@@ -15,7 +15,7 @@
  */
 HPEN16 CreatePen( INT style, INT width, COLORREF color )
 {
-    LOGPEN logpen = { style, { width, 0 }, color };
+    LOGPEN16 logpen = { style, { width, 0 }, color };
     dprintf_gdi(stddeb, "CreatePen: %d %d %06lx\n", style, width, color );
     return CreatePenIndirect( &logpen );
 }
@@ -24,7 +24,7 @@
 /***********************************************************************
  *           CreatePenIndirect    (GDI.62)
  */
-HPEN16 CreatePenIndirect( const LOGPEN * pen )
+HPEN16 CreatePenIndirect( const LOGPEN16 * pen )
 {
     PENOBJ * penPtr;
     HPEN16 hpen;
@@ -33,7 +33,7 @@
     hpen = GDI_AllocObject( sizeof(PENOBJ), PEN_MAGIC );
     if (!hpen) return 0;
     penPtr = (PENOBJ *) GDI_HEAP_LIN_ADDR( hpen );    
-    memcpy( &penPtr->logpen, pen, sizeof(LOGPEN) );
+    memcpy( &penPtr->logpen, pen, sizeof(*pen) );
     return hpen;
 }
 
@@ -43,7 +43,7 @@
  */
 int PEN_GetObject( PENOBJ * pen, int count, LPSTR buffer )
 {
-    if (count > sizeof(LOGPEN)) count = sizeof(LOGPEN);
+    if (count > sizeof(pen->logpen)) count = sizeof(pen->logpen);
     memcpy( buffer, &pen->logpen, count );
     return count;
 }
diff --git a/objects/text.c b/objects/text.c
index 1d5a5e1..a9a67d3 100644
--- a/objects/text.c
+++ b/objects/text.c
@@ -194,7 +194,7 @@
     int len, lh, count=i_count;
     int prefix_x = 0;
     int prefix_end = 0;
-    TEXTMETRIC tm;
+    TEXTMETRIC16 tm;
     int x = rect->left, y = rect->top;
     int width = rect->right - rect->left;
     int max_width = 0;
@@ -581,20 +581,16 @@
 BOOL GrayString(HDC hdc, HBRUSH hbr, FARPROC gsprc, LPARAM lParam, 
 		INT cch, INT x, INT y, INT cx, INT cy)
 {
-	int s, current_color;
+    BOOL ret;
+    COLORREF current_color;
 
-	if (gsprc) {
-		return CallGrayStringProc(gsprc, hdc, lParam, 
-					cch ? cch : lstrlen((LPCSTR) lParam) );
-	} else {
-		current_color = GetTextColor(hdc);
-		SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT) );
-		s = TextOut16(hdc, x, y, (LPSTR) lParam, 
-                              cch ? cch : lstrlen((LPCSTR) lParam) );
-		SetTextColor(hdc, current_color);
-		
-		return s;
-	}
+    if (!cch) cch = lstrlen16( (LPCSTR)PTR_SEG_TO_LIN(lParam) );
+    if (gsprc) return CallGrayStringProc( gsprc, hdc, lParam, cch );
+    current_color = GetTextColor( hdc );
+    SetTextColor( hdc, GetSysColor(COLOR_GRAYTEXT) );
+    ret = TextOut16( hdc, x, y, (LPCSTR)PTR_SEG_TO_LIN(lParam), cch );
+    SetTextColor( hdc, current_color );
+    return ret;
 }
 
 
@@ -621,7 +617,7 @@
     }
     else
     {
-        TEXTMETRIC tm;
+        TEXTMETRIC16 tm;
         GetTextMetrics( hdc, &tm );
         defWidth = 8 * tm.tmAveCharWidth;
     }
diff --git a/win32/Makefile.in b/win32/Makefile.in
index 1b36259..452f909 100644
--- a/win32/Makefile.in
+++ b/win32/Makefile.in
@@ -10,7 +10,6 @@
 	error.c \
 	except.c \
 	file.c \
-	gdi32.c \
 	init.c \
 	memory.c \
 	newfns.c \
diff --git a/win32/except.c b/win32/except.c
index e98ce4a..8e42cc4 100644
--- a/win32/except.c
+++ b/win32/except.c
@@ -57,7 +57,7 @@
  *  
  */
 
-void EXC_RtlUnwind(PEXCEPTION_FRAME pEndFrame,PVOID unusedEip, 
+void EXC_RtlUnwind(PEXCEPTION_FRAME pEndFrame,LPVOID unusedEip, 
                    PEXCEPTION_RECORD pRecord, DWORD returnEax,
                    PCONTEXT pcontext)
 {   
@@ -73,7 +73,7 @@
      record.ExceptionCode=   0xC0000026;  /* invalid disposition */ 
      record.ExceptionFlags=  0;
      record.ExceptionRecord= NULL;
-     record.ExceptionAddress=(PVOID) pcontext->Eip; 
+     record.ExceptionAddress=(LPVOID) pcontext->Eip; 
      record.NumberParameters= 0;
      pRecord=&record;     
    }
@@ -99,7 +99,7 @@
                               retval, (int) dispatch);
   
        if(retval==ExceptionCollidedUnwind)
-          TebExceptionFrame=(PVOID) dispatch;
+          TebExceptionFrame=(LPVOID) dispatch;
        else if(TebExceptionFrame!=pEndFrame)
           TebExceptionFrame=TebExceptionFrame->Prev;
        else
@@ -130,7 +130,7 @@
     record.ExceptionFlags      = dwExceptionFlags;
     record.ExceptionRecord     = NULL;
     record.NumberParameters    = cArguments;
-    record.ExceptionAddress    = (PVOID) pcontext->Eip;
+    record.ExceptionAddress    = (LPVOID) pcontext->Eip;
     
     for(i=0;i<cArguments;i++)
        record.ExceptionInformation[i]=lpArguments[i];
diff --git a/win32/gdi32.c b/win32/gdi32.c
deleted file mode 100644
index 782c0b3..0000000
--- a/win32/gdi32.c
+++ /dev/null
@@ -1,74 +0,0 @@
-
-/*
- * Win32 GDI functions
- *
- * Copyright 1996 Thomas Sandford t.d.g.sandford@prds-grn.demon.co.uk
- */
-
-#include <windows.h>
-#include <gdi.h>
-#include <pen.h>
-#include <brush.h>
-#include <bitmap.h>
-#include <font.h>
-#include <palette.h>
-#include <debug.h>
-
-int WIN32_GetObject( HANDLE handle, int count, LPVOID buffer )
-
-/* largely a copy of GetObject, but with size mangling capabilities to
-convert between win16 and win32 objects. Yeuch! */
-
-{
-    void *temp = alloca(count);
-    GDIOBJHDR * ptr = NULL;
-
-    dprintf_win32(stddeb, "WIN32_GetObject: %d %d %p\n", handle, count, buffer);
-
-    if ((!count) || (temp == NULL))
-	return 0;
-
-    ptr = GDI_GetObjPtr(handle, MAGIC_DONTCARE);
-    if (!ptr) return 0;
-
-    /* FIXME: only bitmaps fixed so far */
-
-    switch(ptr->wMagic)
-    {
-      case PEN_MAGIC:
-          return PEN_GetObject( (PENOBJ *)ptr, count, buffer );
-      case BRUSH_MAGIC:
-          return BRUSH_GetObject( (BRUSHOBJ *)ptr, count, buffer );
-      case BITMAP_MAGIC: {
-	BITMAP *pbm = (BITMAP *)temp;
-	int *pdest = (int *)buffer;
-
-	if (buffer == NULL)
-		return 28;
-
-	BITMAP_GetObject( (BITMAPOBJ *)ptr, count, temp );
-	if (count > 3)
-		pdest[0] = pbm->bmType;
-	if (count > 7)
-		pdest[1] = pbm->bmWidth;
-	if (count > 11)
-		pdest[2] = pbm->bmHeight;
-	if (count > 15)
-		pdest[3] = pbm->bmWidthBytes;
-	if (count > 19)
-		pdest[4] = pbm->bmPlanes;
-	if (count > 23)
-		pdest[5] = pbm->bmBitsPixel;
-	if (count > 27)
-		pdest[6] = pbm->bmBits;
-	
-	return (count > 28) ? 28 : count - (count % 4);
-      }
-      case FONT_MAGIC:
-          return FONT_GetObject( (FONTOBJ *)ptr, count, buffer );
-      case PALETTE_MAGIC:
-          return PALETTE_GetObject( (PALETTEOBJ *)ptr, count, buffer );
-    }
-    return 0;
-}
-
diff --git a/win32/process.c b/win32/process.c
index 4ed4c7e..44ec155 100644
--- a/win32/process.c
+++ b/win32/process.c
@@ -119,6 +119,14 @@
 	return handle;
 }
 
+/***********************************************************************
+ *           FreeLibrary
+ */
+BOOL FreeLibrary32(HINSTANCE hLibModule)
+{
+	fprintf(stderr,"FreeLibrary: empty stub\n");
+	return TRUE;
+}
 
 #ifndef WINELIB
 /***********************************************************************
diff --git a/win32/resource.c b/win32/resource.c
index 4b4598d..3252379 100644
--- a/win32/resource.c
+++ b/win32/resource.c
@@ -59,7 +59,7 @@
 	entryTable = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) (
 			(BYTE *) resdirptr + 
                         sizeof(IMAGE_RESOURCE_DIRECTORY));
-	namelen = STRING32_lstrlenW(name);
+	namelen = lstrlen32W(name);
 	for (entrynum = 0; entrynum < resdirptr->NumberOfNamedEntries; entrynum++)
 	{
 		PIMAGE_RESOURCE_DIR_STRING_U str =
@@ -67,7 +67,7 @@
 			(entryTable[entrynum].Name & 0x7fffffff));
 		if(namelen != str->Length)
 			continue;
-		if(STRING32_lstrcmpniW(name,str->NameString,str->Length)==0)
+		if(lstrncmpi32W(name,str->NameString,str->Length)==0)
 			return (PIMAGE_RESOURCE_DIRECTORY) (
 				root +
 				(entryTable[entrynum].OffsetToData & 0x7fffffff));
diff --git a/win32/string32.c b/win32/string32.c
index c888d11..011b445 100644
--- a/win32/string32.c
+++ b/win32/string32.c
@@ -11,18 +11,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <ctype.h>
+#include "windows.h"
 #include "string32.h"
 #include "xmalloc.h"
 
-int
-STRING32_UniLen(LPCWSTR s)
-{
-	int i;
-	for(i=0;*s;s++)
-		i++;
-	return i;
-}
-
 void STRING32_UniToAnsi(LPSTR dest,LPCWSTR src)
 {
 	static int have_warned=0;
@@ -55,7 +47,7 @@
 
 LPSTR STRING32_DupUniToAnsi(LPCWSTR src)
 {
-	LPSTR dest=xmalloc(STRING32_UniLen(src)+1);
+	LPSTR dest=xmalloc(lstrlen32W(src)+1);
 	STRING32_UniToAnsi(dest,src);
 	return dest;
 }
@@ -67,22 +59,6 @@
 	return dest;
 }
 
-LPWSTR STRING32_lstrcpyW(LPWSTR dst, LPCWSTR src)
-{
-    register LPWSTR p = dst;
-    while ((*p++ = *src++));
-    return dst;
-}
-
-
-DWORD STRING32_lstrlenW(LPCWSTR str)
-{
-	int len;
-	for(len=0;*str;str++)
-		len++;
-	return len;
-}
-
 /* not an API function */
 
 WCHAR STRING32_tolowerW(WCHAR c)
@@ -91,39 +67,6 @@
 	return tolower(c);
 }
 
-int STRING32_lstrcmpniW(LPCWSTR a,LPCWSTR b,DWORD len)
-{
-	while(len--)
-	{
-		WCHAR c1,c2;
-		c1 = STRING32_tolowerW(*a);
-		c2 = STRING32_tolowerW(*b);
-		if(c1<c2)return -1;
-		if(c1>c2)return 1;
-		if(c1==0 && c2==0)return 0;
-		if(c1==0)return -1;
-		if(c2==0)return 1;
-		a++;
-		b++;
-	}
-	return 0;
-}
-
-int
-STRING32_lstrcmpW(LPCWSTR a,LPCWSTR b) {
-	WCHAR	diff;
-
-	while(*a && *b) {
-		diff=*a-*b;
-		if (diff) return diff;
-		a++;
-		b++;
-	}
-	if (*a) return *a;
-	if (*b) return -*b;
-	return 0;
-}
-
 LPWSTR
 STRING32_lstrchrW(LPCWSTR a,WCHAR c) {
 	while(*a) {
@@ -139,7 +82,7 @@
 	LPWSTR	b;
 	int	len;
 
-	len=sizeof(WCHAR)*(STRING32_UniLen(a)+1);
+	len=sizeof(WCHAR)*(lstrlen32W(a)+1);
 	b=(LPWSTR)xmalloc(len);
 	memcpy(b,a,len);
 	return b;
diff --git a/win32/struct32.c b/win32/struct32.c
index 2d76d8f..15047e9 100644
--- a/win32/struct32.c
+++ b/win32/struct32.c
@@ -30,7 +30,7 @@
         p32->cy = p16->cy;
 }
 
-void STRUCT32_MSG16to32(MSG *msg16,MSG32 *msg32)
+void STRUCT32_MSG16to32(const MSG16 *msg16,MSG32 *msg32)
 {
 	msg32->hwnd=(DWORD)msg16->hwnd;
 	msg32->message=msg16->message;
@@ -41,7 +41,7 @@
 	msg32->pt.y=msg16->pt.y;
 }
 
-void STRUCT32_MSG32to16(MSG32 *msg32,MSG *msg16)
+void STRUCT32_MSG32to16(const MSG32 *msg32,MSG16 *msg16)
 {
 	msg16->hwnd=(HWND)msg32->hwnd;
 	msg16->message=msg32->message;
diff --git a/win32/thread.c b/win32/thread.c
index b538002..00e5daa 100644
--- a/win32/thread.c
+++ b/win32/thread.c
@@ -79,9 +79,12 @@
 	if(!Tls){
 		TlsCount++;
 		Tls=xmalloc(sizeof(LPVOID));
+		/* Tls needs to be zero initialized */
+		Tls[0]=0;
 		return 0;
 	}
 	Tls=xrealloc(Tls,sizeof(LPVOID)*(++TlsCount));
+	Tls[TlsCount-1]=0;
 	return TlsCount-1;
 }
 
@@ -110,3 +113,59 @@
 	}
 	Tls[index]=value;
 }
+
+/* FIXME: This is required to work cross-addres space as well */
+static CRITICAL_SECTION interlocked;
+static int interlocked_init;
+
+static void get_interlocked()
+{
+	if(!interlocked_init)
+		InitializeCriticalSection(&interlocked);
+	interlocked_init=1;
+	EnterCriticalSection(&interlocked);
+}
+
+static void release_interlocked()
+{
+	LeaveCriticalSection(&interlocked);
+}
+
+/***********************************************************************
+ *           InterlockedIncrement
+ */
+LONG InterlockedIncrement(LPLONG lpAddend)
+{
+	int ret;
+	get_interlocked();
+	(*lpAddend)++;
+	ret=*lpAddend;
+	release_interlocked();
+	return ret;
+}
+
+/***********************************************************************
+ *           InterlockedDecrement
+ */
+LONG InterlockedDecrement(LPLONG lpAddend)
+{
+	int ret;
+	get_interlocked();
+	(*lpAddend)--;
+	ret=*lpAddend;
+	release_interlocked();
+	return ret;
+}
+
+/***********************************************************************
+ *           InterlockedExchange
+ */
+LONG InterlockedExchange(LPLONG target, LONG value)
+{
+	int ret;
+	get_interlocked();
+	ret=*target;
+	*target=value;
+	release_interlocked();
+	return ret;
+}
diff --git a/win32/user32.c b/win32/user32.c
index 290e1cc..39ef0d7 100644
--- a/win32/user32.c
+++ b/win32/user32.c
@@ -29,7 +29,7 @@
 BOOL USER32_GetMessageA(MSG32* lpmsg,DWORD hwnd,DWORD min,DWORD max)
 {
 	BOOL ret;
-	MSG msg;
+	MSG16 msg;
 	ret=GetMessage(MAKE_SEGPTR(&msg),(HWND)hwnd,min,max);
 	STRUCT32_MSG16to32(&msg,lpmsg);
 	return ret;
@@ -40,7 +40,7 @@
  */
 LONG USER32_DispatchMessageA(MSG32* lpmsg)
 {
-	MSG msg;
+	MSG16 msg;
 	LONG ret;
 	STRUCT32_MSG32to16(lpmsg,&msg);
 	ret=DispatchMessage(&msg);
@@ -53,11 +53,34 @@
  */
 BOOL USER32_TranslateMessage(MSG32* lpmsg)
 {
-	MSG msg;
+	MSG16 msg;
 	STRUCT32_MSG32to16(lpmsg,&msg);
 	return TranslateMessage(&msg);
 }
 
+/***********************************************************************
+ *         PeekMessageA
+ */
+BOOL32 PeekMessage32A( LPMSG32 lpmsg, HWND32 hwnd,
+                       UINT32 min,UINT32 max,UINT32 wRemoveMsg)
+{
+	MSG16 msg;
+	BOOL ret;
+	ret=PeekMessage16(&msg,hwnd,min,max,wRemoveMsg);
+        /* FIXME: should translate the message to Win32 */
+	STRUCT32_MSG16to32(&msg,lpmsg);
+	return ret;
+}
+
+/***********************************************************************
+ *         PeekMessageW
+ */
+BOOL32 PeekMessage32W( LPMSG32 lpmsg, HWND32 hwnd,
+                       UINT32 min,UINT32 max,UINT32 wRemoveMsg)
+{
+	/* FIXME: Should perform Unicode translation on specific messages */
+	return PeekMessage32A(lpmsg,hwnd,min,max,wRemoveMsg);
+}
 
 UINT USER32_SetTimer(HWND hwnd, UINT id, UINT timeout, void *proc)
 
@@ -66,9 +89,3 @@
 (LONG)proc );
     return SetTimer( hwnd, id, timeout, MAKE_SEGPTR(proc));
 }   
-
-
-int USER32_wsprintfA( int *args )
-{
-    return vsprintf( (char *)args[0], (char *)args[1], (va_list)&args[2] );
-}
diff --git a/windows/caret.c b/windows/caret.c
index 526ac9b..902d309 100644
--- a/windows/caret.c
+++ b/windows/caret.c
@@ -131,8 +131,8 @@
 
     if (bitmap && (bitmap != 1))
     {
-        BITMAP bmp;
-        if (!GetObject( bitmap, sizeof(bmp), (LPSTR)&bmp )) return FALSE;
+        BITMAP16 bmp;
+        if (!GetObject16( bitmap, sizeof(bmp), &bmp )) return FALSE;
         Caret.width = bmp.bmWidth;
         Caret.height = bmp.bmHeight;
         /* FIXME: we should make a copy of the bitmap instead of a brush */
diff --git a/windows/class.c b/windows/class.c
index 4cf9e11..dc9865c 100644
--- a/windows/class.c
+++ b/windows/class.c
@@ -93,7 +93,7 @@
     {
         /* We need to copy the Unicode string */
         if ((classPtr->menuNameA = SEGPTR_ALLOC(
-                                 STRING32_lstrlenW(classPtr->menuNameW) + 1 )))
+                                        lstrlen32W(classPtr->menuNameW) + 1 )))
             STRING32_UniToAnsi( classPtr->menuNameA, classPtr->menuNameW );
     }
     return classPtr->menuNameA;
@@ -149,8 +149,8 @@
     if (HIWORD(classPtr->menuNameA)) SEGPTR_FREE( classPtr->menuNameA );
     if (classPtr->menuNameW) HeapFree( SystemHeap, 0, classPtr->menuNameW );
     if ((classPtr->menuNameW = HeapAlloc( SystemHeap, 0,
-                                 (STRING32_lstrlenW(name)+1)*sizeof(WCHAR) )))
-        STRING32_lstrcpyW( classPtr->menuNameW, name );
+                                         (lstrlen32W(name)+1)*sizeof(WCHAR) )))
+        lstrcpy32W( classPtr->menuNameW, name );
     classPtr->menuNameA = 0;
 }
 
@@ -619,7 +619,7 @@
 /***********************************************************************
  *           GetClassLong16    (USER.131)
  */
-LONG GetClassLong16( HWND hwnd, INT16 offset )
+LONG GetClassLong16( HWND16 hwnd, INT16 offset )
 {
     LONG ret;
 
@@ -641,7 +641,7 @@
 /***********************************************************************
  *           GetClassLong32A    (USER32.214)
  */
-LONG GetClassLong32A( HWND hwnd, INT32 offset )
+LONG GetClassLong32A( HWND32 hwnd, INT32 offset )
 {
     WND * wndPtr;
     
@@ -675,7 +675,7 @@
 /***********************************************************************
  *           GetClassLong32W    (USER32.215)
  */
-LONG GetClassLong32W( HWND hwnd, INT32 offset )
+LONG GetClassLong32W( HWND32 hwnd, INT32 offset )
 {
     WND * wndPtr;
     
@@ -731,7 +731,7 @@
 /***********************************************************************
  *           SetClassLong16    (USER.132)
  */
-LONG SetClassLong16( HWND hwnd, INT16 offset, LONG newval )
+LONG SetClassLong16( HWND16 hwnd, INT16 offset, LONG newval )
 {
     WND *wndPtr;
 
@@ -752,7 +752,7 @@
 /***********************************************************************
  *           SetClassLong32A    (USER32.466)
  */
-LONG SetClassLong32A( HWND hwnd, INT32 offset, LONG newval )
+LONG SetClassLong32A( HWND32 hwnd, INT32 offset, LONG newval )
 {
     WND * wndPtr;
     LONG retval = 0;
@@ -801,7 +801,7 @@
 /***********************************************************************
  *           SetClassLong32W    (USER32.467)
  */
-LONG SetClassLong32W( HWND hwnd, INT32 offset, LONG newval )
+LONG SetClassLong32W( HWND32 hwnd, INT32 offset, LONG newval )
 {
     WND *wndPtr;
     if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
@@ -823,7 +823,7 @@
 /***********************************************************************
  *           GetClassName16      (USER.58)
  */
-INT16 GetClassName16( HWND hwnd, LPSTR buffer, INT16 count )
+INT16 GetClassName16( HWND16 hwnd, LPSTR buffer, INT16 count )
 {
     WND *wndPtr;
     if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
@@ -834,7 +834,7 @@
 /***********************************************************************
  *           GetClassName32A      (USER32.216)
  */
-INT32 GetClassName32A( HWND hwnd, LPSTR buffer, INT32 count )
+INT32 GetClassName32A( HWND32 hwnd, LPSTR buffer, INT32 count )
 {
     WND *wndPtr;
     if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
@@ -845,7 +845,7 @@
 /***********************************************************************
  *           GetClassName32W      (USER32.217)
  */
-INT32 GetClassName32W( HWND hwnd, LPWSTR buffer, INT32 count )
+INT32 GetClassName32W( HWND32 hwnd, LPWSTR buffer, INT32 count )
 {
     WND *wndPtr;
     if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0;
@@ -856,7 +856,7 @@
 /***********************************************************************
  *           GetClassInfo16      (USER.404)
  */
-BOOL GetClassInfo16( HINSTANCE16 hInstance, SEGPTR name, WNDCLASS16 *wc )
+BOOL16 GetClassInfo16( HINSTANCE16 hInstance, SEGPTR name, WNDCLASS16 *wc )
 {
     ATOM atom;
     CLASS *classPtr;
@@ -884,7 +884,7 @@
 /***********************************************************************
  *           GetClassInfo32A      (USER32.210)
  */
-BOOL GetClassInfo32A( HINSTANCE32 hInstance, LPCSTR name, WNDCLASS32A *wc )
+BOOL32 GetClassInfo32A( HINSTANCE32 hInstance, LPCSTR name, WNDCLASS32A *wc )
 {
     ATOM atom;
     CLASS *classPtr;
@@ -910,7 +910,7 @@
 /***********************************************************************
  *           GetClassInfo32W      (USER32.213)
  */
-BOOL GetClassInfo32W( HINSTANCE32 hInstance, LPCWSTR name, WNDCLASS32W *wc )
+BOOL32 GetClassInfo32W( HINSTANCE32 hInstance, LPCWSTR name, WNDCLASS32W *wc )
 {
     ATOM atom;
     CLASS *classPtr;
@@ -939,7 +939,7 @@
  * FIXME: this is just a guess, I have no idea if GetClassInfoEx() is the
  * same in Win16 as in Win32. --AJ
  */
-BOOL GetClassInfoEx16( HINSTANCE16 hInstance, SEGPTR name, WNDCLASSEX16 *wc )
+BOOL16 GetClassInfoEx16( HINSTANCE16 hInstance, SEGPTR name, WNDCLASSEX16 *wc )
 {
     ATOM atom;
     CLASS *classPtr;
@@ -968,7 +968,8 @@
 /***********************************************************************
  *           GetClassInfoEx32A      (USER32.211)
  */
-BOOL GetClassInfoEx32A( HINSTANCE32 hInstance, LPCSTR name, WNDCLASSEX32A *wc )
+BOOL32 GetClassInfoEx32A( HINSTANCE32 hInstance, LPCSTR name,
+                          WNDCLASSEX32A *wc )
 {
     ATOM atom;
     CLASS *classPtr;
@@ -995,7 +996,8 @@
 /***********************************************************************
  *           GetClassInfoEx32W      (USER32.212)
  */
-BOOL GetClassInfoEx32W( HINSTANCE32 hInstance, LPCWSTR name, WNDCLASSEX32W *wc)
+BOOL32 GetClassInfoEx32W( HINSTANCE32 hInstance, LPCWSTR name,
+                          WNDCLASSEX32W *wc )
 {
     ATOM atom;
     CLASS *classPtr;
diff --git a/windows/dce.c b/windows/dce.c
index 4ec7624..8a809c9 100644
--- a/windows/dce.c
+++ b/windows/dce.c
@@ -15,6 +15,7 @@
  * DCX_WINDOWPAINT - BeginPaint specific flag
  */
 
+#include "options.h"
 #include "dce.h"
 #include "class.h"
 #include "win.h"
@@ -119,6 +120,9 @@
 
 /***********************************************************************
  *   DCE_InvalidateDCE
+ *
+ * It is called from SetWindowPos - we have to invalidate all busy
+ * DCE's for windows whose client rect intersects with update rectangle 
  */
 BOOL DCE_InvalidateDCE(WND* wndScope, RECT16* pRectUpdate)
 {
@@ -130,6 +134,7 @@
  dprintf_dc(stddeb,"InvalidateDCE: scope hwnd = %04x, (%i,%i - %i,%i)\n",
                     wndScope->hwndSelf, pRectUpdate->left,pRectUpdate->top,
 				        pRectUpdate->right,pRectUpdate->bottom);
+ /* walk all DCE's */
 
  for( hdce = firstDCE; (hdce); hdce=dce->hNext)
   { 
@@ -141,9 +146,11 @@
 
 	wnd = wndCurrent = WIN_FindWndPtr(dce->hwndCurrent);
 
-	/* desktop is not critical */
+	/* desktop is not critical (DC is not owned anyway) */
 
-	if( wnd == WIN_GetDesktop() ) continue;
+	if( wnd == WIN_GetDesktop() ) continue; 
+
+	/* check if DCE window is within z-order scope */
 
 	for( ; wnd ; wnd = wnd->parent )
 	    if( wnd == wndScope )
@@ -152,8 +159,9 @@
 
 	        dprintf_dc(stddeb,"\tgot hwnd %04x\n", wndCurrent->hwndSelf);
   
-	        MapWindowPoints16(wndCurrent->parent->hwndSelf, wndScope->hwndSelf,
-			 				(LPPOINT16)&wndRect, 2);
+	        if( wndCurrent->parent != wndScope )
+	            MapWindowPoints16(wndCurrent->parent->hwndSelf, wndScope->hwndSelf,
+			 				         (LPPOINT16)&wndRect, 2);
 	        if( IntersectRect16(&wndRect,&wndRect,pRectUpdate) )
 	            SetHookFlags(dce->hDC, DCHF_INVALIDATEVISRGN);
 	        break;
@@ -496,8 +504,11 @@
             else OffsetRgn( hrgnVisible, -wndPtr->rectClient.left,
                                          -wndPtr->rectClient.top );
         }
-      else if( hwnd==GetDesktopWindow() ) hrgnVisible = CreateRectRgn( 0, 0, SYSMETRICS_CXSCREEN,
-                                     SYSMETRICS_CYSCREEN);
+           /* optimize away GetVisRgn for desktop if it isn't there */
+
+      else if( hwnd==GetDesktopWindow() && !Options.desktopGeometry ) 
+	       hrgnVisible = CreateRectRgn( 0, 0, SYSMETRICS_CXSCREEN,
+                                                  SYSMETRICS_CYSCREEN);
       else hrgnVisible = DCE_GetVisRgn( hwnd, flags );
 
       dc->w.flags &= ~DC_DIRTY;
@@ -581,11 +592,9 @@
 	if( dce->DCXflags & DCX_KEEPCLIPRGN )
 	    dce->DCXflags &= ~DCX_KEEPCLIPRGN;
 	else
-	  {
 	    if( dce->hClipRgn > 1 )
 	        DeleteObject( dce->hClipRgn );
-	    dce->hClipRgn = 0;
-	  } 
+
         dce->hClipRgn = 0;
 	RestoreVisRgn(dce->hDC);
     }
@@ -593,7 +602,7 @@
     if (dce->DCXflags & DCX_CACHE)
     {
 	SetDCState( dce->hDC, defaultDCstate );
-	dce->DCXflags &= ~DCX_DCEBUSY;
+	dce->DCXflags = DCX_CACHE;
     }
     return 1;
 }
diff --git a/windows/defwnd.c b/windows/defwnd.c
index bed9009..caca49e 100644
--- a/windows/defwnd.c
+++ b/windows/defwnd.c
@@ -1,7 +1,7 @@
 /*
  * Default window procedure
  *
- * Copyright 1993 Alexandre Julliard
+ * Copyright 1993, 1996 Alexandre Julliard
  *	     1995 Alex Korobka
  */
 
@@ -15,7 +15,6 @@
 #include "string32.h"
 #include "syscolor.h"
 #include "stddebug.h"
-/* #define DEBUG_MESSAGE */
 #include "debug.h"
 #include "spy.h"
 
@@ -100,26 +99,24 @@
 static LRESULT DEFWND_DefWinProc( WND *wndPtr, UINT32 msg, WPARAM32 wParam,
                                   LPARAM lParam )
 {
-    HWND16 hwnd = wndPtr->hwndSelf;
-
     switch(msg)
     {
     case WM_PAINTICON: 
     case WM_NCPAINT:
-	return NC_HandleNCPaint( hwnd, (HRGN)wParam );
+	return NC_HandleNCPaint( wndPtr->hwndSelf, (HRGN)wParam );
 
     case WM_NCHITTEST:
-        return NC_HandleNCHitTest( hwnd, MAKEPOINT16(lParam) );
+        return NC_HandleNCHitTest( wndPtr->hwndSelf, MAKEPOINT16(lParam) );
 
     case WM_NCLBUTTONDOWN:
-	return NC_HandleNCLButtonDown( hwnd, wParam, lParam );
+	return NC_HandleNCLButtonDown( wndPtr->hwndSelf, wParam, lParam );
 
     case WM_LBUTTONDBLCLK:
     case WM_NCLBUTTONDBLCLK:
 	return NC_HandleNCLButtonDblClk( wndPtr, wParam, lParam );
 
     case WM_NCACTIVATE:
-	return NC_HandleNCActivate( hwnd, wParam );
+	return NC_HandleNCActivate( wndPtr->hwndSelf, wParam );
 
     case WM_NCDESTROY:
 	if (wndPtr->text) HeapFree( SystemHeap, 0, wndPtr->text );
@@ -132,35 +129,35 @@
     case WM_PAINT:
 	{
 	    PAINTSTRUCT16 paintstruct;
-	    BeginPaint16( hwnd, &paintstruct );
-	    EndPaint16( hwnd, &paintstruct );
+	    BeginPaint16( wndPtr->hwndSelf, &paintstruct );
+	    EndPaint16( wndPtr->hwndSelf, &paintstruct );
 	    return 0;
 	}
 
     case WM_SETREDRAW:
         if (!wParam)
         {
-            ValidateRect32( hwnd, NULL );
+            ValidateRect32( wndPtr->hwndSelf, NULL );
             wndPtr->flags |= WIN_NO_REDRAW;
         }
         else wndPtr->flags &= ~WIN_NO_REDRAW;
         return 0;
 
     case WM_CLOSE:
-	DestroyWindow( hwnd );
+	DestroyWindow( wndPtr->hwndSelf );
 	return 0;
 
     case WM_MOUSEACTIVATE:
 	if (wndPtr->dwStyle & WS_CHILD)
 	{
-	    LONG ret = SendMessage16( wndPtr->parent->hwndSelf, WM_MOUSEACTIVATE,
-				    wParam, lParam );
+	    LONG ret = SendMessage16( wndPtr->parent->hwndSelf,
+                                      WM_MOUSEACTIVATE, wParam, lParam );
 	    if (ret) return ret;
 	}
 	return MA_ACTIVATE;
 
     case WM_ACTIVATE:
-	if (LOWORD(wParam) != WA_INACTIVE) SetFocus( hwnd );
+	if (LOWORD(wParam) != WA_INACTIVE) SetFocus( wndPtr->hwndSelf );
 	break;
 
     case WM_ERASEBKGND:
@@ -172,12 +169,13 @@
                  HBRUSH hbrush;
                  hbrush = CreateSolidBrush(
                      GetSysColor(((DWORD)wndPtr->class->hbrBackground)-1));
-                 FillWindow( GetParent(hwnd), hwnd, (HDC)wParam, hbrush);
+                 FillWindow( GetParent(wndPtr->hwndSelf), wndPtr->hwndSelf,
+                             (HDC)wParam, hbrush);
                  DeleteObject (hbrush);
             }
             else
-	         FillWindow( GetParent(hwnd), hwnd, (HDC)wParam,
-                             wndPtr->class->hbrBackground );
+	         FillWindow( GetParent(wndPtr->hwndSelf), wndPtr->hwndSelf,
+                             (HDC)wParam, wndPtr->class->hbrBackground );
 	    return 1;
 	}
 
@@ -226,10 +224,11 @@
 	    if (SendMessage16(wndPtr->parent->hwndSelf, WM_SETCURSOR,
                             wParam, lParam))
 		return TRUE;
-	return NC_HandleSetCursor( hwnd, wParam, lParam );
+	return NC_HandleSetCursor( wndPtr->hwndSelf, wParam, lParam );
 
     case WM_SYSCOMMAND:
-        return NC_HandleSysCommand( hwnd, wParam, MAKEPOINT16(lParam) );
+        return NC_HandleSysCommand( wndPtr->hwndSelf, wParam,
+                                    MAKEPOINT16(lParam) );
 
     case WM_KEYDOWN:
 	if(wParam == VK_F10) iF10Key = VK_F10;
@@ -251,8 +250,8 @@
 	         iF10Key = 1;
 	     else
 	         if( wParam == VK_ESCAPE && GetKeyState(VK_SHIFT) < 0 )
-		     SendMessage16( hwnd, WM_SYSCOMMAND, (WPARAM)SC_KEYMENU, 
- 						       (LPARAM)VK_SPACE);
+		     SendMessage16( wndPtr->hwndSelf, WM_SYSCOMMAND,
+                                    (WPARAM)SC_KEYMENU, (LPARAM)VK_SPACE);
 	break;
 
     case WM_KEYUP:
@@ -260,8 +259,8 @@
 	/* Press and release F10 or ALT */
 	if (((wParam == VK_MENU) && iMenuSysKey) ||
             ((wParam == VK_F10) && iF10Key))
-	      SendMessage16( WIN_GetTopParent(hwnd), WM_SYSCOMMAND,
-			   SC_KEYMENU, 0L );
+	      SendMessage16( WIN_GetTopParent(wndPtr->hwndSelf),
+                             WM_SYSCOMMAND, SC_KEYMENU, 0L );
 	iMenuSysKey = iF10Key = 0;
         break;
 
@@ -269,7 +268,8 @@
 	iMenuSysKey = 0;
 	if (wParam == VK_RETURN && (wndPtr->dwStyle & WS_MINIMIZE))
         {
-	    PostMessage(hwnd, WM_SYSCOMMAND, (WPARAM)SC_RESTORE, 0L ); 
+	    PostMessage( wndPtr->hwndSelf, WM_SYSCOMMAND,
+                         (WPARAM)SC_RESTORE, 0L ); 
 	    break;
         } 
 	if ((HIWORD(lParam) & KEYDATA_ALT) && wParam)
@@ -278,7 +278,8 @@
 	    if (wParam == VK_SPACE && (wndPtr->dwStyle & WS_CHILD))
                 SendMessage16( wndPtr->parent->hwndSelf, msg, wParam, lParam );
 	    else
-                SendMessage16( hwnd, WM_SYSCOMMAND, (WPARAM)SC_KEYMENU, (LPARAM)(DWORD)wParam );
+                SendMessage16( wndPtr->hwndSelf, WM_SYSCOMMAND,
+                               (WPARAM)SC_KEYMENU, (LPARAM)(DWORD)wParam );
         } 
 	else /* check for Ctrl-Esc */
             if (wParam != VK_ESCAPE) MessageBeep(0);
@@ -289,7 +290,7 @@
         if (!(wndPtr->dwStyle & WS_POPUP) || !wndPtr->owner) return 0;
         if ((wndPtr->dwStyle & WS_VISIBLE) && wParam) return 0;
 	else if (!(wndPtr->dwStyle & WS_VISIBLE) && !wParam) return 0;
-        ShowWindow( hwnd, wParam ? SW_SHOWNOACTIVATE : SW_HIDE );
+        ShowWindow( wndPtr->hwndSelf, wParam ? SW_SHOWNOACTIVATE : SW_HIDE );
 	break; 
 
     case WM_INITMENUPOPUP:
@@ -302,7 +303,7 @@
     case WM_CANCELMODE:
 	/* EndMenu() should be called if in menu state but currently it's
 	   impossible to detect - menu code should be updated*/
-	if (GetCapture() == hwnd) ReleaseCapture();
+	if (GetCapture() == wndPtr->hwndSelf) ReleaseCapture();
 	break;
 
     case WM_VKEYTOITEM:
@@ -344,6 +345,7 @@
     WND * wndPtr = WIN_FindWndPtr( hwnd );
     LRESULT result = 0;
 
+    if (!wndPtr) return 0;
     SPY_EnterMessage( SPY_DEFWNDPROC16, hwnd, msg, wParam, lParam );
 
     switch(msg)
@@ -376,7 +378,7 @@
     case WM_GETTEXT:
         if (wParam && wndPtr->text)
         {
-            lstrcpyn( (LPSTR)PTR_SEG_TO_LIN(lParam), wndPtr->text, wParam );
+            lstrcpyn32A( (LPSTR)PTR_SEG_TO_LIN(lParam), wndPtr->text, wParam );
             result = (LRESULT)strlen( (LPSTR)PTR_SEG_TO_LIN(lParam) ) + 1;
         }
         break;
@@ -405,6 +407,7 @@
     WND * wndPtr = WIN_FindWndPtr( hwnd );
     LRESULT result = 0;
 
+    if (!wndPtr) return 0;
     SPY_EnterMessage( SPY_DEFWNDPROC32, hwnd, msg, wParam, lParam );
 
     switch(msg)
@@ -441,7 +444,7 @@
     case WM_GETTEXT:
         if (wParam && wndPtr->text)
         {
-            lstrcpyn( (LPSTR)lParam, wndPtr->text, wParam );
+            lstrcpyn32A( (LPSTR)lParam, wndPtr->text, wParam );
             result = (LRESULT)strlen( (LPSTR)lParam ) + 1;
         }
         break;
@@ -483,6 +486,7 @@
             }
 	    result = 1;
 	}
+        break;
 
     case WM_GETTEXT:
         {
diff --git a/windows/dialog.c b/windows/dialog.c
index 4e010bc..8d4c82b 100644
--- a/windows/dialog.c
+++ b/windows/dialog.c
@@ -65,7 +65,7 @@
  */
 BOOL DIALOG_Init()
 {
-    TEXTMETRIC tm;
+    TEXTMETRIC16 tm;
     HDC hdc;
     
       /* Calculate the dialog base units */
@@ -154,7 +154,7 @@
         dprintf_dialog(stddeb,"'%s'", info->windowName );
     }
 
-    info->data = (LPVOID)(*p ? p + 1 : NULL);  /* FIXME: is this right? */
+    info->data = (LPVOID)(*p ? p + 1 : NULL);  /* FIXME: should be a segptr */
     p += *p + 1;
 
     dprintf_dialog( stddeb," %d, %d, %d, %d, %d, %08lx, %08lx\n", 
@@ -200,7 +200,7 @@
     else
     {
         info->className = (LPCSTR)p;
-        p += STRING32_lstrlenW( (LPCWSTR)p ) + 1;
+        p += lstrlen32W( (LPCWSTR)p ) + 1;
     }
     dprintf_dialog(stddeb, "   %p ", info->className );
 
@@ -213,7 +213,7 @@
     else
     {
 	info->windowName = (LPCSTR)p;
-        p += STRING32_lstrlenW( (LPCWSTR)p ) + 1;
+        p += lstrlen32W( (LPCWSTR)p ) + 1;
         dprintf_dialog(stddeb,"'%p'", info->windowName );
     }
 
@@ -427,7 +427,7 @@
     default:
         result->menuName = (LPCSTR)p;
         dprintf_dialog( stddeb, " MENU '%p'\n", p );
-        p += STRING32_lstrlenW( (LPCWSTR)p ) + 1;
+        p += lstrlen32W( (LPCWSTR)p ) + 1;
         break;
     }
 
@@ -447,14 +447,14 @@
     default:
         result->className = (LPCSTR)p;
         dprintf_dialog( stddeb, " CLASS '%p'\n", p );
-        p += STRING32_lstrlenW( (LPCWSTR)p ) + 1;
+        p += lstrlen32W( (LPCWSTR)p ) + 1;
         break;
     }
 
     /* Get the window caption */
 
     result->caption = (LPCSTR)p;
-    p += STRING32_lstrlenW( (LPCWSTR)p ) + 1;
+    p += lstrlen32W( (LPCWSTR)p ) + 1;
     dprintf_dialog( stddeb, " CAPTION '%p'\n", result->caption );
 
     /* Get the font name */
@@ -464,7 +464,7 @@
 	result->pointSize = GET_WORD(p);
         p++;
 	result->faceName = (LPCSTR)p;
-        p += STRING32_lstrlenW( (LPCWSTR)p ) + 1;
+        p += lstrlen32W( (LPCWSTR)p ) + 1;
 	dprintf_dialog( stddeb, " FONT %d,'%p'\n",
                         result->pointSize, result->faceName );
     }
@@ -517,7 +517,7 @@
                             template.faceName );  /* FIXME: win32 */
 	if (hFont)
 	{
-	    TEXTMETRIC tm;
+	    TEXTMETRIC16 tm;
 	    HFONT oldFont;
 	    HDC hdc;
 
@@ -577,7 +577,6 @@
       /* Initialise dialog extra data */
 
     dlgInfo = (DIALOGINFO *)wndPtr->wExtra;
-    dlgInfo->dlgProc   = dlgProc;
     dlgInfo->hUserFont = hFont;
     dlgInfo->hMenu     = hMenu;
     dlgInfo->xBaseUnit = xUnit;
@@ -596,6 +595,7 @@
 
     /* Send initialisation messages and set focus */
 
+    dlgInfo->dlgProc   = dlgProc;
     dlgInfo->hwndFocus = DIALOG_GetFirstTabItem( hwnd );
     if (dlgInfo->hUserFont)
 	SendMessage32A( hwnd, WM_SETFONT, (WPARAM)dlgInfo->hUserFont, 0 );
@@ -610,7 +610,7 @@
  *           CreateDialog16   (USER.89)
  */
 HWND16 CreateDialog16( HINSTANCE16 hInst, SEGPTR dlgTemplate,
-                       HWND16 owner, DLGPROC dlgProc )
+                       HWND16 owner, DLGPROC16 dlgProc )
 {
     return CreateDialogParam16( hInst, dlgTemplate, owner, dlgProc, 0 );
 }
@@ -620,7 +620,7 @@
  *           CreateDialogParam16   (USER.241)
  */
 HWND16 CreateDialogParam16( HINSTANCE16 hInst, SEGPTR dlgTemplate,
-                            HWND16 owner, DLGPROC dlgProc, LPARAM param )
+                            HWND16 owner, DLGPROC16 dlgProc, LPARAM param )
 {
     HWND16 hwnd = 0;
     HRSRC hRsrc;
@@ -644,7 +644,7 @@
  *           CreateDialogParam32A   (USER32.72)
  */
 HWND32 CreateDialogParam32A( HINSTANCE32 hInst, LPCSTR name,
-                             HWND32 owner, DLGPROC dlgProc, LPARAM param )
+                             HWND32 owner, DLGPROC32 dlgProc, LPARAM param )
 {
     if (HIWORD(name))
     {
@@ -661,7 +661,7 @@
  *           CreateDialogParam32W   (USER32.73)
  */
 HWND32 CreateDialogParam32W( HINSTANCE32 hInst, LPCWSTR name,
-                             HWND32 owner, DLGPROC dlgProc, LPARAM param )
+                             HWND32 owner, DLGPROC32 dlgProc, LPARAM param )
 {
     HANDLE32 hrsrc = FindResource32( hInst, name, (LPWSTR)RT_DIALOG );
     if (!hrsrc) return 0;
@@ -674,7 +674,7 @@
  *           CreateDialogIndirect16   (USER.219)
  */
 HWND16 CreateDialogIndirect16( HINSTANCE16 hInst, LPCVOID dlgTemplate,
-                               HWND16 owner, DLGPROC dlgProc )
+                               HWND16 owner, DLGPROC16 dlgProc )
 {
     return CreateDialogIndirectParam16( hInst, dlgTemplate, owner, dlgProc, 0);
 }
@@ -684,7 +684,7 @@
  *           CreateDialogIndirectParam16   (USER.242)
  */
 HWND16 CreateDialogIndirectParam16( HINSTANCE16 hInst, LPCVOID dlgTemplate,
-                                    HWND16 owner, DLGPROC dlgProc,
+                                    HWND16 owner, DLGPROC16 dlgProc,
                                     LPARAM param )
 {
     HANDLE32 proc = WINPROC_AllocWinProc( (UINT32)dlgProc, WIN_PROC_16 );
@@ -697,7 +697,7 @@
  *           CreateDialogIndirectParam32A   (USER32.69)
  */
 HWND32 CreateDialogIndirectParam32A( HINSTANCE32 hInst, LPCVOID dlgTemplate,
-                                     HWND32 owner, DLGPROC dlgProc,
+                                     HWND32 owner, DLGPROC32 dlgProc,
                                      LPARAM param )
 {
     HANDLE32 proc = WINPROC_AllocWinProc( (UINT32)dlgProc, WIN_PROC_32A );
@@ -710,7 +710,7 @@
  *           CreateDialogIndirectParam32W   (USER32.71)
  */
 HWND32 CreateDialogIndirectParam32W( HINSTANCE32 hInst, LPCVOID dlgTemplate,
-                                     HWND32 owner, DLGPROC dlgProc,
+                                     HWND32 owner, DLGPROC32 dlgProc,
                                      LPARAM param )
 {
     HANDLE32 proc = WINPROC_AllocWinProc( (UINT32)dlgProc, WIN_PROC_32W );
@@ -727,14 +727,14 @@
     WND * wndPtr;
     DIALOGINFO * dlgInfo;
     HANDLE msgHandle;
-    MSG* lpmsg;
+    MSG16* lpmsg;
     INT32 retval;
 
       /* Owner must be a top-level window */
     owner = WIN_GetTopParent( owner );
     if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return -1;
-    if (!(msgHandle = USER_HEAP_ALLOC( sizeof(MSG) ))) return -1;
-    lpmsg = (MSG *) USER_HEAP_LIN_ADDR( msgHandle );
+    if (!(msgHandle = USER_HEAP_ALLOC( sizeof(MSG16) ))) return -1;
+    lpmsg = (MSG16 *) USER_HEAP_LIN_ADDR( msgHandle );
     dlgInfo = (DIALOGINFO *)wndPtr->wExtra;
     EnableWindow( owner, FALSE );
     ShowWindow( hwnd, SW_SHOW );
@@ -762,7 +762,7 @@
  *           DialogBox16   (USER.87)
  */
 INT16 DialogBox16( HINSTANCE16 hInst, SEGPTR dlgTemplate,
-                   HWND16 owner, DLGPROC dlgProc )
+                   HWND16 owner, DLGPROC16 dlgProc )
 {
     return DialogBoxParam16( hInst, dlgTemplate, owner, dlgProc, 0 );
 }
@@ -772,7 +772,7 @@
  *           DialogBoxParam16   (USER.239)
  */
 INT16 DialogBoxParam16( HINSTANCE16 hInst, SEGPTR template,
-                        HWND16 owner, DLGPROC dlgProc, LPARAM param )
+                        HWND16 owner, DLGPROC16 dlgProc, LPARAM param )
 {
     HWND16 hwnd = CreateDialogParam16( hInst, template, owner, dlgProc, param);
     if (hwnd) return (INT16)DIALOG_DoDialogBox( hwnd, owner );
@@ -784,7 +784,7 @@
  *           DialogBoxParam32A   (USER32.138)
  */
 INT32 DialogBoxParam32A( HINSTANCE32 hInst, LPCSTR name,
-                         HWND32 owner, DLGPROC dlgProc, LPARAM param )
+                         HWND32 owner, DLGPROC32 dlgProc, LPARAM param )
 {
     HWND32 hwnd = CreateDialogParam32A( hInst, name, owner, dlgProc, param );
     if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
@@ -796,7 +796,7 @@
  *           DialogBoxParam32W   (USER32.139)
  */
 INT32 DialogBoxParam32W( HINSTANCE32 hInst, LPCWSTR name,
-                         HWND32 owner, DLGPROC dlgProc, LPARAM param )
+                         HWND32 owner, DLGPROC32 dlgProc, LPARAM param )
 {
     HWND32 hwnd = CreateDialogParam32W( hInst, name, owner, dlgProc, param );
     if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
@@ -808,7 +808,7 @@
  *           DialogBoxIndirect16   (USER.218)
  */
 INT16 DialogBoxIndirect16( HINSTANCE16 hInst, HANDLE16 dlgTemplate,
-                           HWND16 owner, DLGPROC dlgProc )
+                           HWND16 owner, DLGPROC16 dlgProc )
 {
     return DialogBoxIndirectParam16( hInst, dlgTemplate, owner, dlgProc, 0 );
 }
@@ -818,7 +818,7 @@
  *           DialogBoxIndirectParam16   (USER.240)
  */
 INT16 DialogBoxIndirectParam16( HINSTANCE16 hInst, HANDLE16 dlgTemplate,
-                                HWND16 owner, DLGPROC dlgProc, LPARAM param )
+                                HWND16 owner, DLGPROC16 dlgProc, LPARAM param )
 {
     HWND16 hwnd;
     LPCVOID ptr;
@@ -835,7 +835,7 @@
  *           DialogBoxIndirectParam32A   (USER32.135)
  */
 INT32 DialogBoxIndirectParam32A( HINSTANCE32 hInstance, LPCVOID template,
-                                 HWND32 owner, DLGPROC dlgProc ,LPARAM param )
+                                 HWND32 owner, DLGPROC32 dlgProc ,LPARAM param)
 {
     HWND32 hwnd = CreateDialogIndirectParam32A( hInstance, template,
                                                 owner, dlgProc, param );
@@ -848,7 +848,7 @@
  *           DialogBoxIndirectParam32W   (USER32.137)
  */
 INT32 DialogBoxIndirectParam32W( HINSTANCE32 hInstance, LPCVOID template,
-                                 HWND32 owner, DLGPROC dlgProc ,LPARAM param )
+                                 HWND32 owner, DLGPROC32 dlgProc ,LPARAM param)
 {
     HWND32 hwnd = CreateDialogIndirectParam32W( hInstance, template,
                                                 owner, dlgProc, param );
@@ -874,7 +874,7 @@
 /***********************************************************************
  *           IsDialogMessage   (USER.90)
  */
-BOOL IsDialogMessage( HWND hwndDlg, LPMSG msg )
+BOOL IsDialogMessage( HWND hwndDlg, LPMSG16 msg )
 {
     WND * wndPtr;
     int dlgCode;
diff --git a/windows/event.c b/windows/event.c
index ce75d90..66fb819 100644
--- a/windows/event.c
+++ b/windows/event.c
@@ -54,8 +54,8 @@
 static XContext winContext = 0;
 
   /* State variables */
-BOOL MouseButtonsStates[NB_BUTTONS] = { FALSE, FALSE, FALSE };
-BOOL AsyncMouseButtonsStates[NB_BUTTONS] = { FALSE, FALSE, FALSE };
+BOOL MouseButtonsStates[NB_BUTTONS];
+BOOL AsyncMouseButtonsStates[NB_BUTTONS];
 BYTE KeyStateTable[256];
 BYTE AsyncKeyStateTable[256];
 
@@ -67,26 +67,26 @@
 static BOOL	InputEnabled = TRUE;
 
 /* Keyboard translation tables */
-static int special_key[] =
+static const int special_key[] =
 {
     VK_BACK, VK_TAB, 0, VK_CLEAR, 0, VK_RETURN, 0, 0,           /* FF08 */
     0, 0, 0, VK_PAUSE, VK_SCROLL, 0, 0, 0,                      /* FF10 */
     0, 0, 0, VK_ESCAPE                                          /* FF18 */
 };
 
-static cursor_key[] =
+static const int cursor_key[] =
 {
     VK_HOME, VK_LEFT, VK_UP, VK_RIGHT, VK_DOWN, VK_PRIOR, 
                                        VK_NEXT, VK_END          /* FF50 */
 };
 
-static misc_key[] =
+static const int misc_key[] =
 {
     VK_SELECT, VK_SNAPSHOT, VK_EXECUTE, VK_INSERT, 0, 0, 0, 0,  /* FF60 */
     VK_CANCEL, VK_HELP, VK_CANCEL, VK_MENU                      /* FF68 */
 };
 
-static keypad_key[] =
+static const int keypad_key[] =
 {
     VK_MENU, VK_NUMLOCK,                                        /* FF7E */
     0, 0, 0, 0, 0, 0, 0, 0,                                     /* FF80 */
@@ -101,14 +101,14 @@
     VK_NUMPAD8, VK_NUMPAD9                                      /* FFB8 */
 };
     
-static function_key[] =
+static const int function_key[] =
 {
     VK_F1, VK_F2,                                               /* FFBE */
     VK_F3, VK_F4, VK_F5, VK_F6, VK_F7, VK_F8, VK_F9, VK_F10,    /* FFC0 */
     VK_F11, VK_F12, VK_F13, VK_F14, VK_F15, VK_F16              /* FFC8 */
 };
 
-static modifier_key[] =
+static const int modifier_key[] =
 {
     VK_SHIFT, VK_SHIFT, VK_CONTROL, VK_CONTROL, VK_CAPITAL,
                                                 0, 0,           /* FFE1 */
@@ -133,7 +133,7 @@
 
 static BOOL KeyDown = FALSE;
 
-static const char *event_names[] =
+static const char * const event_names[] =
 {
     "", "", "KeyPress", "KeyRelease", "ButtonPress", "ButtonRelease",
     "MotionNotify", "EnterNotify", "LeaveNotify", "FocusIn", "FocusOut",
diff --git a/windows/mdi.c b/windows/mdi.c
index a48aea3..01b0fcf 100644
--- a/windows/mdi.c
+++ b/windows/mdi.c
@@ -31,7 +31,6 @@
 #include "stddebug.h"
 #include "debug.h"
 
-#define MDIS_ALLCHILDSTYLES	0x1
 
 static HBITMAP hBmpClose   = 0;
 static HBITMAP hBmpRestore = 0;
@@ -104,7 +103,7 @@
 
  if( !clientInfo->hWindowMenu ) return 0;
 
- if (wndPtr->text) lstrcpyn(buffer + n, wndPtr->text, sizeof(buffer) - n );
+ if (wndPtr->text) lstrcpyn32A(buffer + n, wndPtr->text, sizeof(buffer) - n );
 
  n    = GetMenuState(clientInfo->hWindowMenu,wndPtr->wIDmenu ,MF_BYCOMMAND); 
  bRet = ModifyMenu32A(clientInfo->hWindowMenu , wndPtr->wIDmenu, 
@@ -148,7 +147,7 @@
 
 	n = sprintf(buffer, "%d ",index - clientInfo->idFirstChild);
 	if (wndPtr->text)
-            lstrcpyn(buffer + n, wndPtr->text, sizeof(buffer) - n );	
+            lstrcpyn32A(buffer + n, wndPtr->text, sizeof(buffer) - n );	
 
 	/* change menu */
 	ModifyMenu32A(clientInfo->hWindowMenu ,index ,MF_BYCOMMAND | MF_STRING,
@@ -305,7 +304,7 @@
 HWND MDICreateChild(WND *w, MDICLIENTINFO *ci, HWND parent, LPARAM lParam )
 {
     POINT16          pos[2]; 
-    MDICREATESTRUCT *cs = (MDICREATESTRUCT *)PTR_SEG_TO_LIN(lParam);
+    MDICREATESTRUCT16 *cs = (MDICREATESTRUCT16 *)PTR_SEG_TO_LIN(lParam);
     DWORD	     style = cs->style | (WS_CHILD | WS_CLIPSIBLINGS);
     HWND 	     hwnd, hwndMax = 0;
     WORD	     wIDmenu = ci->idFirstChild + ci->nActiveChildren;
@@ -911,7 +910,7 @@
 	 int	i_frame_text_length = strlen(ci->frameTitle);
 	 int    i_child_text_length = strlen(childWnd->text);
 
-	 lstrcpyn( lpBuffer, ci->frameTitle, MDI_MAXTITLELENGTH);
+	 lstrcpyn32A( lpBuffer, ci->frameTitle, MDI_MAXTITLELENGTH);
 
 	 if( i_frame_text_length + 6 < MDI_MAXTITLELENGTH )
          {
@@ -924,9 +923,9 @@
              }
 	     else
              {
-                 lstrcpyn( lpBuffer + i_frame_text_length + 4, 
-                           childWnd->text,
-                           MDI_MAXTITLELENGTH - i_frame_text_length - 5 );
+                 lstrcpyn32A( lpBuffer + i_frame_text_length + 4, 
+                              childWnd->text,
+                              MDI_MAXTITLELENGTH - i_frame_text_length - 5 );
                  strcat( lpBuffer, "]" );
 		}
 	   }
@@ -958,7 +957,7 @@
 LRESULT MDIClientWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 {
     LPCREATESTRUCT16     cs;
-    LPCLIENTCREATESTRUCT ccs;
+    LPCLIENTCREATESTRUCT16 ccs;
     MDICLIENTINFO       *ci;
     RECT16		 rect;
     WND                 *w 	  = WIN_FindWndPtr(hwnd);
@@ -970,7 +969,7 @@
     {
       case WM_CREATE:
 	cs                      = (LPCREATESTRUCT16) PTR_SEG_TO_LIN(lParam);
-	ccs                     = (LPCLIENTCREATESTRUCT) PTR_SEG_TO_LIN(cs->lpCreateParams);
+	ccs                     = (LPCLIENTCREATESTRUCT16) PTR_SEG_TO_LIN(cs->lpCreateParams);
 
 	ci->hWindowMenu         = ccs->hWindowMenu;
 	ci->idFirstChild        = ccs->idFirstChild;
@@ -1501,7 +1500,7 @@
  *					TranslateMDISysAccel (USER.451)
  *
  */
-BOOL TranslateMDISysAccel(HWND hwndClient, LPMSG msg)
+BOOL TranslateMDISysAccel(HWND hwndClient, LPMSG16 msg)
 {
   WND* clientWnd = WIN_FindWndPtr( hwndClient);
   WND* wnd;
diff --git a/windows/message.c b/windows/message.c
index e12db33..8ff4af2 100644
--- a/windows/message.c
+++ b/windows/message.c
@@ -29,7 +29,7 @@
 extern BYTE* 	KeyStateTable;				 /* event.c */
 extern WPARAM	lastEventChar;				 /* event.c */
 
-extern BOOL TIMER_CheckTimer( LONG *next, MSG *msg,
+extern BOOL TIMER_CheckTimer( LONG *next, MSG16 *msg,
 			      HWND hwnd, BOOL remove );  /* timer.c */
 
 DWORD MSG_WineStartTicks;  				 /* Ticks at Wine startup */
@@ -51,7 +51,7 @@
  *   the coordinates to client coordinates.
  * - Send the WM_SETCURSOR message.
  */
-static BOOL MSG_TranslateMouseMsg( MSG *msg, BOOL remove )
+static BOOL MSG_TranslateMouseMsg( MSG16 *msg, BOOL remove )
 {
     WND *pWnd;
     BOOL eatMsg = FALSE;
@@ -60,7 +60,7 @@
     static WORD  lastClickMsg = 0;
     static POINT16 lastClickPos = { 0, 0 };
     POINT16 pt = msg->pt;
-    MOUSEHOOKSTRUCT hook = { msg->pt, 0, HTCLIENT, 0 };
+    MOUSEHOOKSTRUCT16 hook = { msg->pt, 0, HTCLIENT, 0 };
 
     BOOL mouseClick = ((msg->message == WM_LBUTTONDOWN) ||
 		       (msg->message == WM_RBUTTONDOWN) ||
@@ -170,7 +170,7 @@
  * Return value indicates whether the translated message must be passed
  * to the user.
  */
-static BOOL MSG_TranslateKeyboardMsg( MSG *msg, BOOL remove )
+static BOOL MSG_TranslateKeyboardMsg( MSG16 *msg, BOOL remove )
 {
       /* Should check Ctrl-Esc and PrintScreen here */
 
@@ -195,7 +195,7 @@
  *
  * Peek for a hardware message matching the hwnd and message filters.
  */
-static BOOL MSG_PeekHardwareMsg( MSG *msg, HWND hwnd, WORD first, WORD last,
+static BOOL MSG_PeekHardwareMsg( MSG16 *msg, HWND hwnd, WORD first, WORD last,
                                  BOOL remove )
 {
     MESSAGEQUEUE *sysMsgQueue = QUEUE_GetSysQueue();
@@ -221,8 +221,8 @@
         }
         else  /* Non-standard hardware event */
         {
-            HARDWAREHOOKSTRUCT hook = { msg->hwnd, msg->message,
-                                        msg->wParam, msg->lParam };
+            HARDWAREHOOKSTRUCT16 hook = { msg->hwnd, msg->message,
+                                          msg->wParam, msg->lParam };
             if (HOOK_CallHooks( WH_HARDWARE, remove ? HC_ACTION : HC_NOREMOVE,
                                 0, (LPARAM)MAKE_SEGPTR(&hook) )) continue;
         }
@@ -237,7 +237,7 @@
             continue;  /* Not for this task */
         if (remove)
         {
-            MSG tmpMsg = *msg; /* FIXME */
+            MSG16 tmpMsg = *msg; /* FIXME */
             HOOK_CallHooks( WH_JOURNALRECORD, HC_ACTION,
                             0, (LPARAM)MAKE_SEGPTR(&tmpMsg) );
             QUEUE_RemoveMsg( sysMsgQueue, pos );
@@ -274,7 +274,7 @@
  * are not translated.
  * Warning: msg->hwnd is always 0.
  */
-BOOL MSG_GetHardwareMessage( LPMSG msg )
+BOOL MSG_GetHardwareMessage( LPMSG16 msg )
 {
 #if 0
     int pos;
@@ -375,7 +375,7 @@
 /***********************************************************************
  *           MSG_PeekMessage
  */
-static BOOL MSG_PeekMessage( LPMSG msg, HWND hwnd, WORD first, WORD last,
+static BOOL MSG_PeekMessage( LPMSG16 msg, HWND hwnd, WORD first, WORD last,
                              WORD flags, BOOL peek )
 {
     int pos, mask;
@@ -525,37 +525,38 @@
     {
 	if (sendIdle)
 	{
-	    if (!MSG_PeekMessage( (MSG *)PTR_SEG_TO_LIN(msg),
+	    if (!MSG_PeekMessage( (MSG16 *)PTR_SEG_TO_LIN(msg),
                                   0, 0, 0, flags, TRUE ))
 	    {
 		  /* No message present -> send ENTERIDLE and wait */
                 if (IsWindow(hwndOwner))
                     SendMessage16( hwndOwner, WM_ENTERIDLE,
                                    code, (LPARAM)hwnd );
-		MSG_PeekMessage( (MSG *)PTR_SEG_TO_LIN(msg),
+		MSG_PeekMessage( (MSG16 *)PTR_SEG_TO_LIN(msg),
                                  0, 0, 0, flags, FALSE );
 	    }
 	}
 	else  /* Always wait for a message */
-	    MSG_PeekMessage( (MSG *)PTR_SEG_TO_LIN(msg),
+	    MSG_PeekMessage( (MSG16 *)PTR_SEG_TO_LIN(msg),
                              0, 0, 0, flags, FALSE );
 
 	if (!CallMsgFilter( msg, code ))
-            return (((MSG *)PTR_SEG_TO_LIN(msg))->message != WM_QUIT);
+            return (((MSG16 *)PTR_SEG_TO_LIN(msg))->message != WM_QUIT);
 
 	  /* Message filtered -> remove it from the queue */
 	  /* if it's still there. */
 	if (!(flags & PM_REMOVE))
-	    MSG_PeekMessage( (MSG *)PTR_SEG_TO_LIN(msg),
+	    MSG_PeekMessage( (MSG16 *)PTR_SEG_TO_LIN(msg),
                              0, 0, 0, PM_REMOVE, TRUE );
     }
 }
 
 
 /***********************************************************************
- *           PeekMessage   (USER.109)
+ *           PeekMessage16   (USER.109)
  */
-BOOL PeekMessage( LPMSG msg, HWND hwnd, WORD first, WORD last, WORD flags )
+BOOL16 PeekMessage16( LPMSG16 msg, HWND16 hwnd, UINT16 first,
+                      UINT16 last, UINT16 flags )
 {
     return MSG_PeekMessage( msg, hwnd, first, last, flags, TRUE );
 }
@@ -566,7 +567,7 @@
  */
 BOOL GetMessage( SEGPTR msg, HWND hwnd, UINT first, UINT last ) 
 {
-    MSG* lpmsg = (MSG *)PTR_SEG_TO_LIN(msg);
+    MSG16 *lpmsg = (MSG16 *)PTR_SEG_TO_LIN(msg);
     MSG_PeekMessage( lpmsg,
                      hwnd, first, last, PM_REMOVE, FALSE );
 
@@ -582,7 +583,7 @@
  */
 BOOL PostMessage( HWND hwnd, WORD message, WORD wParam, LONG lParam )
 {
-    MSG 	msg;
+    MSG16 	msg;
     WND 	*wndPtr;
 
     msg.hwnd    = hwnd;
@@ -625,7 +626,7 @@
  */
 BOOL PostAppMessage( HTASK hTask, WORD message, WORD wParam, LONG lParam )
 {
-    MSG 	msg;
+    MSG16 msg;
 
     if (GetTaskQueue(hTask) == 0) return FALSE;
     msg.hwnd    = 0;
@@ -791,7 +792,7 @@
  */
 void WaitMessage( void )
 {
-    MSG msg;
+    MSG16 msg;
     MESSAGEQUEUE *queue;
     LONG nextExp = -1;  /* Next timer expiration time */
 
@@ -820,7 +821,7 @@
 
 #define ASCII_CHAR_HACK 0x0800
 
-BOOL TranslateMessage( LPMSG msg )
+BOOL TranslateMessage( LPMSG16 msg )
 {
     UINT message = msg->message;
     /* BYTE wparam[2]; */
@@ -851,7 +852,7 @@
 /***********************************************************************
  *           DispatchMessage   (USER.114)
  */
-LONG DispatchMessage( const MSG* msg )
+LONG DispatchMessage( const MSG16* msg )
 {
     WND * wndPtr;
     LONG retval;
@@ -863,7 +864,7 @@
 	if (msg->lParam)
         {
 /*            HOOK_CallHooks( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
-	    return CallWindowProc16( (WNDPROC)msg->lParam, msg->hwnd,
+	    return CallWindowProc16( (WNDPROC16)msg->lParam, msg->hwnd,
                                    msg->message, msg->wParam, GetTickCount() );
         }
     }
diff --git a/windows/nonclient.c b/windows/nonclient.c
index 37a916f..a51ae71 100644
--- a/windows/nonclient.c
+++ b/windows/nonclient.c
@@ -882,7 +882,7 @@
 {
     LONG hittest = 0;
     POINT16 pt;
-    MSG msg;
+    MSG16 msg;
     WND * wndPtr = WIN_FindWndPtr( hwnd );
 
     if ((wParam & 0xfff0) == SC_MOVE)
@@ -963,7 +963,7 @@
  */
 static void NC_DoSizeMove( HWND hwnd, WORD wParam, POINT16 pt )
 {
-    MSG msg;
+    MSG16 msg;
     LONG hittest;
     RECT16 sizingRect, mouseRect;
     HDC hdc;
@@ -1137,7 +1137,7 @@
  */
 static void NC_TrackMinMaxBox( HWND hwnd, WORD wParam )
 {
-    MSG msg;
+    MSG16 msg;
     HDC hdc = GetWindowDC( hwnd );
     BOOL pressed = TRUE;
 
@@ -1180,7 +1180,7 @@
  */
 static void NC_TrackScrollBar( HWND hwnd, WORD wParam, POINT16 pt )
 {
-    MSG *msg;
+    MSG16 *msg;
     WORD scrollbar;
     WND *wndPtr = WIN_FindWndPtr( hwnd );
 
@@ -1195,7 +1195,7 @@
 	scrollbar = SB_VERT;
     }
 
-    if (!(msg = SEGPTR_NEW(MSG))) return;
+    if (!(msg = SEGPTR_NEW(MSG16))) return;
     pt.x -= wndPtr->rectWindow.left;
     pt.y -= wndPtr->rectWindow.top;
     SetCapture( hwnd );
diff --git a/windows/property.c b/windows/property.c
index 6927be0..9d3a0dc 100644
--- a/windows/property.c
+++ b/windows/property.c
@@ -71,7 +71,7 @@
         PROPERTY *prop = (PROPERTY *)USER_HEAP_LIN_ADDR(hProp);
         if (HIWORD(str))
         {
-            if (!prop->atom && !lstrcmpi( prop->string, PTR_SEG_TO_LIN(str)))
+            if (!prop->atom && !lstrcmpi32A(prop->string, PTR_SEG_TO_LIN(str)))
                 return prop->hData;
         }
         else if (prop->atom && (prop->atom == LOWORD(str))) return prop->hData;
@@ -96,7 +96,7 @@
     {
         PROPERTY *prop = (PROPERTY *)USER_HEAP_LIN_ADDR( *hProp );
         if ((HIWORD(str) && !prop->atom &&
-             !lstrcmpi( prop->string, PTR_SEG_TO_LIN(str))) ||
+             !lstrcmpi32A( prop->string, PTR_SEG_TO_LIN(str))) ||
             (!HIWORD(str) && prop->atom && (prop->atom == LOWORD(str))))
         {
             HANDLE hNext = prop->next;
diff --git a/windows/queue.c b/windows/queue.c
index e465ebb..eb457ed 100644
--- a/windows/queue.c
+++ b/windows/queue.c
@@ -272,7 +272,7 @@
  *
  * Add a message to the queue. Return FALSE if queue is full.
  */
-BOOL QUEUE_AddMsg( HQUEUE hQueue, MSG * msg, DWORD extraInfo )
+BOOL QUEUE_AddMsg( HQUEUE hQueue, MSG16 * msg, DWORD extraInfo )
 {
     int pos;
     MESSAGEQUEUE *msgQueue;
@@ -315,7 +315,7 @@
         
     for (i = 0; i < msgQueue->msgCount; i++)
     {
-	MSG * msg = &msgQueue->messages[pos].msg;
+	MSG16 * msg = &msgQueue->messages[pos].msg;
 
 	if (!hwnd || (msg->hwnd == hwnd))
 	{
@@ -405,7 +405,7 @@
 void hardware_event( WORD message, WORD wParam, LONG lParam,
 		     int xPos, int yPos, DWORD time, DWORD extraInfo )
 {
-    MSG *msg;
+    MSG16 *msg;
     int pos;
 
     if (!sysMsgQueue) return;
diff --git a/windows/syscolor.c b/windows/syscolor.c
index 50e03b8..3c3ddee 100644
--- a/windows/syscolor.c
+++ b/windows/syscolor.c
@@ -14,9 +14,9 @@
 /* #define DEBUG_SYSCOLOR */
 #include "debug.h"
 
-struct SysColorObjects sysColorObjects = { 0, };
+struct SysColorObjects sysColorObjects;
 
-static char * DefSysColors[] =
+static const char * const DefSysColors[] =
 {
     "Scrollbar", "224 224 224",      /* COLOR_SCROLLBAR           */
     "Background", "192 192 192",     /* COLOR_BACKGROUND          */
@@ -132,7 +132,7 @@
 void SYSCOLOR_Init(void)
 {
     int i, r, g, b;
-    char **p;
+    const char * const *p;
     char buffer[100];
 
     for (i = 0, p = DefSysColors; i < NUM_SYS_COLORS; i++, p += 2)
diff --git a/windows/timer.c b/windows/timer.c
index 189fc36..53156d2 100644
--- a/windows/timer.c
+++ b/windows/timer.c
@@ -169,7 +169,7 @@
  * If 'hwnd' is not NULL, only consider timers for this window.
  * If 'remove' is TRUE, remove all expired timers up to the returned one.
  */
-BOOL TIMER_CheckTimer( LONG *next, MSG *msg, HWND hwnd, BOOL remove )
+BOOL TIMER_CheckTimer( LONG *next, MSG16 *msg, HWND hwnd, BOOL remove )
 {
     TIMER * pTimer = pNextTimer;
     DWORD curTime = GetTickCount();
diff --git a/windows/win.c b/windows/win.c
index a59225c..8c23889 100644
--- a/windows/win.c
+++ b/windows/win.c
@@ -1005,7 +1005,7 @@
 /***********************************************************************
  *           FindWindow16   (USER.50)
  */
-HWND FindWindow16( SEGPTR className, LPCSTR title )
+HWND16 FindWindow16( SEGPTR className, LPCSTR title )
 {
     return FindWindowEx16( 0, 0, className, title );
 }
@@ -1014,7 +1014,8 @@
 /***********************************************************************
  *           FindWindowEx16   (USER.427)
  */
-HWND FindWindowEx16( HWND parent, HWND child, SEGPTR className, LPCSTR title )
+HWND16 FindWindowEx16( HWND16 parent, HWND16 child,
+                       SEGPTR className, LPCSTR title )
 {
     ATOM atom;
 
@@ -1026,7 +1027,7 @@
 /***********************************************************************
  *           FindWindow32A   (USER32.197)
  */
-HWND FindWindow32A( LPCSTR className, LPCSTR title )
+HWND32 FindWindow32A( LPCSTR className, LPCSTR title )
 {
     return FindWindowEx32A( 0, 0, className, title );
 }
@@ -1035,7 +1036,8 @@
 /***********************************************************************
  *           FindWindowEx32A   (USER32.198)
  */
-HWND FindWindowEx32A( HWND parent, HWND child, LPCSTR className, LPCSTR title )
+HWND32 FindWindowEx32A( HWND32 parent, HWND32 child,
+                        LPCSTR className, LPCSTR title )
 {
     ATOM atom;
 
@@ -1047,7 +1049,8 @@
 /***********************************************************************
  *           FindWindowEx32W   (USER32.199)
  */
-HWND FindWindowEx32W(HWND parent, HWND child, LPCWSTR className, LPCWSTR title)
+HWND32 FindWindowEx32W( HWND32 parent, HWND32 child,
+                        LPCWSTR className, LPCWSTR title )
 {
     ATOM atom;
     char *buffer;
@@ -1064,7 +1067,7 @@
 /***********************************************************************
  *           FindWindow32W   (USER32.200)
  */
-HWND FindWindow32W( LPCWSTR className, LPCWSTR title )
+HWND32 FindWindow32W( LPCWSTR className, LPCWSTR title )
 {
     return FindWindowEx32W( 0, 0, className, title );
 }
@@ -1838,7 +1841,7 @@
  */
 BOOL16 DragDetect(HWND16 hWnd, POINT16 pt)
 {
-  MSG   msg;
+  MSG16 msg;
   RECT16  rect;
 
   rect.left = pt.x - wDragWidth;
@@ -1851,7 +1854,7 @@
 
   while(1)
    {
-        while(PeekMessage(&msg ,0 ,WM_MOUSEFIRST ,WM_MOUSELAST ,PM_REMOVE))
+        while(PeekMessage16(&msg ,0 ,WM_MOUSEFIRST ,WM_MOUSELAST ,PM_REMOVE))
          {
            if( msg.message == WM_LBUTTONUP )
                 {
@@ -1880,7 +1883,7 @@
 DWORD DragObject(HWND hwndScope, HWND hWnd, WORD wObj, HANDLE hOfStruct,
                 WORD szList , HCURSOR hCursor)
 {
- MSG	 	msg;
+ MSG16	 	msg;
  LPDRAGINFO	lpDragInfo;
  SEGPTR		spDragInfo;
  HCURSOR 	hDragCursor=0, hOldCursor=0, hBummer=0;
@@ -1933,7 +1936,7 @@
   {
     WaitMessage();
 
-    if( !PeekMessage(&msg,0,WM_MOUSEFIRST,WM_MOUSELAST,PM_REMOVE) )
+    if( !PeekMessage16(&msg,0,WM_MOUSEFIRST,WM_MOUSELAST,PM_REMOVE) )
 	 continue;
 
    *(lpDragInfo+1) = *lpDragInfo;
diff --git a/windows/winpos.c b/windows/winpos.c
index 5088673..b1f1de3 100644
--- a/windows/winpos.c
+++ b/windows/winpos.c
@@ -848,7 +848,7 @@
 {
     WND                   *wndPtr          = WIN_FindWndPtr(hWnd);
     WND                   *wndTemp         = WIN_FindWndPtr(hwndActive);
-    CBTACTIVATESTRUCT     *cbtStruct;
+    CBTACTIVATESTRUCT16   *cbtStruct;
     FARPROC                enumCallback    = MODULE_GetWndProcEntry16("ActivateAppProc");
     ACTIVATESTRUCT         actStruct;
     WORD                   wIconized=0;
@@ -872,7 +872,7 @@
 	dprintf_win(stddeb,"WINPOS_ActivateWindow: no current active window.\n");
 
     /* call CBT hook chain */
-    if ((cbtStruct = SEGPTR_NEW(CBTACTIVATESTRUCT)))
+    if ((cbtStruct = SEGPTR_NEW(CBTACTIVATESTRUCT16)))
     {
         LRESULT wRet;
         cbtStruct->fMouse     = fMouse;
diff --git a/windows/winproc.c b/windows/winproc.c
index 05d2a24..f206657 100644
--- a/windows/winproc.c
+++ b/windows/winproc.c
@@ -722,7 +722,7 @@
 	
     case WM_SETTEXT:
         {
-            LPSTR str = SEGPTR_ALLOC( STRING32_lstrlenW( (LPWSTR)lParam ) );
+            LPSTR str = SEGPTR_ALLOC( lstrlen32W( (LPWSTR)lParam ) );
             if (!str) return 0;
             STRING32_UniToAnsi( str, (LPWSTR)lParam );
             result = CallWndProc16( func, ds, hwnd, msg, (WPARAM16)wParam,