Release 970215

Sat Feb 15 11:59:17 1997  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [*/*]
	Converted a lot of functions to Win32 types.
	Removed HWND type.

Fri Feb 14 15:09:19 1997  Onno Hovers <onno@stack.nl>

	* [memory/global.c]
	Implemented GMEM_MOVEABLE blocks for Win32.

Fri Feb 14 00:24:39 1997  Alex Korobka <alex@trantor.pharm.sunysb.edu>

	* [loader/task.c] [windows/queue.c]
	Do not read X events while in the intertask SendMessage().

	* [misc/lstr.c]
	Fixed CharPrev32A().

	* [windows/hook.c] [include/hook.h]
	Restored broken WH_CALLWNDPROC functionality for dialogs, etc...

	* [windows/win.c] [windows/defwnd.c] [windows/mdi.c]
	  [windows/event.c] [controls/edit.c] 
	Added WIN_ISWIN32 flag to windows created by Win32 calls. 
	Several new Win32 messages are sent when this flag is on.
	
	* [msdos/dosmem.c] [memory/global.c]
	Some changes in DOS memory allocation.

Fri Feb  7 21:46:03 1997  Andrew Taylor  <andrew@riscan.com>

	* [win32/security.c]
	Added SID manipulation functions.

	* [include/debug.h]
	Added debugging class "security".

Fri  Feb 7 20:46:33 1997  Robert Pouliot <krynos@clic.net>

	* [debugger/msc.c] [debugger/source.c] 
	  [documentation/wine_os2.txt] [loader/signal.c]
	Some more changes for OS/2. Doesn't work yet.

Fri  Feb 7 09:31:17 1997  Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>

	* [scheduler/process.c]
	Added ExpandEnvironmentStrings*.

	* [misc/ntdll.c] [include/ntdll.h]
	Added some new functions.

	* [objects/cursoricon.c]
	CURSORICON_LoadHandler: check against some bizarre out of memory
	conditions.
	
	* [windows/mdi.c]
	Fixed DefFrameProc32*, added TranslateMDISysAccel32.

Wed Feb  5 01:31:05 1997  John Zero <john@globe.graphisoft.hu>

	* [resources/sysres_Hu.rc] [misc/ole2nls.c] [misc/main.c]
	  [programs/progman/Hu.rc] [programs/winhelp/Hu.rc]
	Added Hungarian language support.
diff --git a/ANNOUNCE b/ANNOUNCE
index 4e2d1f3..10dc576 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,13 +1,13 @@
-This is release 970202 of Wine, the MS Windows emulator.  This is still a
+This is release 970215 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-970202: (see ChangeLog for details)
-	- More printer support.
-	- Some new Win32 functions.
+WHAT'S NEW with Wine-970215: (see ChangeLog for details)
+	- Many more Win32 functions.
+	- Hungarian language support.
 	- Lots of bug fixes.
 
 See the README file in the distribution for installation instructions.
@@ -16,10 +16,10 @@
 the release is available at the ftp sites.  The sources will be available
 from the following locations:
 
-  ftp://sunsite.unc.edu/pub/Linux/ALPHA/wine/development/Wine-970202.tar.gz
-  ftp://tsx-11.mit.edu/pub/linux/ALPHA/Wine/development/Wine-970202.tar.gz
-  ftp://ftp.infomagic.com/pub/mirrors/linux/wine/development/Wine-970202.tar.gz
-  ftp://aris.com/pub/linux/ALPHA/Wine/development/Wine-970202.tar.gz
+  ftp://sunsite.unc.edu/pub/Linux/ALPHA/wine/development/Wine-970215.tar.gz
+  ftp://tsx-11.mit.edu/pub/linux/ALPHA/Wine/development/Wine-970215.tar.gz
+  ftp://ftp.infomagic.com/pub/mirrors/linux/wine/development/Wine-970215.tar.gz
+  ftp://aris.com/pub/linux/ALPHA/Wine/development/Wine-970215.tar.gz
 
 It should also be available from any site that mirrors tsx-11 or sunsite.
 
diff --git a/ChangeLog b/ChangeLog
index cce92fd..2b492bf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,70 @@
 ----------------------------------------------------------------------
+Sat Feb 15 11:59:17 1997  Alexandre Julliard  <julliard@lrc.epfl.ch>
+
+	* [*/*]
+	Converted a lot of functions to Win32 types.
+	Removed HWND type.
+
+Fri Feb 14 15:09:19 1997  Onno Hovers <onno@stack.nl>
+
+	* [memory/global.c]
+	Implemented GMEM_MOVEABLE blocks for Win32.
+
+Fri Feb 14 00:24:39 1997  Alex Korobka <alex@trantor.pharm.sunysb.edu>
+
+	* [loader/task.c] [windows/queue.c]
+	Do not read X events while in the intertask SendMessage().
+
+	* [misc/lstr.c]
+	Fixed CharPrev32A().
+
+	* [windows/hook.c] [include/hook.h]
+	Restored broken WH_CALLWNDPROC functionality for dialogs, etc...
+
+	* [windows/win.c] [windows/defwnd.c] [windows/mdi.c]
+	  [windows/event.c] [controls/edit.c] 
+	Added WIN_ISWIN32 flag to windows created by Win32 calls. 
+	Several new Win32 messages are sent when this flag is on.
+	
+	* [msdos/dosmem.c] [memory/global.c]
+	Some changes in DOS memory allocation.
+
+Fri Feb  7 21:46:03 1997  Andrew Taylor  <andrew@riscan.com>
+
+	* [win32/security.c]
+	Added SID manipulation functions.
+
+	* [include/debug.h]
+	Added debugging class "security".
+
+Fri  Feb 7 20:46:33 1997  Robert Pouliot <krynos@clic.net>
+
+	* [debugger/msc.c] [debugger/source.c] 
+	  [documentation/wine_os2.txt] [loader/signal.c]
+	Some more changes for OS/2. Doesn't work yet.
+
+Fri  Feb 7 09:31:17 1997  Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>
+
+	* [scheduler/process.c]
+	Added ExpandEnvironmentStrings*.
+
+	* [misc/ntdll.c] [include/ntdll.h]
+	Added some new functions.
+
+	* [objects/cursoricon.c]
+	CURSORICON_LoadHandler: check against some bizarre out of memory
+	conditions.
+	
+	* [windows/mdi.c]
+	Fixed DefFrameProc32*, added TranslateMDISysAccel32.
+
+Wed Feb  5 01:31:05 1997  John Zero <john@globe.graphisoft.hu>
+
+	* [resources/sysres_Hu.rc] [misc/ole2nls.c] [misc/main.c]
+	  [programs/progman/Hu.rc] [programs/winhelp/Hu.rc]
+	Added Hungarian language support.
+
+----------------------------------------------------------------------
 Sun Feb  2 12:31:03 1997  Alexandre Julliard  <julliard@lrc.epfl.ch>
 
 	* [files/drive.c]
diff --git a/controls/button.c b/controls/button.c
index b9bbe05..92759b7 100644
--- a/controls/button.c
+++ b/controls/button.c
@@ -268,10 +268,10 @@
     Rectangle32(hDC, rc.left, rc.top, rc.right, rc.bottom);
     if (action == ODA_DRAWENTIRE)
     {
-        SetPixel32( hDC, rc.left, rc.top, GetSysColor(COLOR_WINDOW) );
-        SetPixel32( hDC, rc.left, rc.bottom-1, GetSysColor(COLOR_WINDOW) );
-        SetPixel32( hDC, rc.right-1, rc.top, GetSysColor(COLOR_WINDOW) );
-        SetPixel32( hDC, rc.right-1, rc.bottom-1, GetSysColor(COLOR_WINDOW) );
+        SetPixel32( hDC, rc.left, rc.top, GetSysColor32(COLOR_WINDOW) );
+        SetPixel32( hDC, rc.left, rc.bottom-1, GetSysColor32(COLOR_WINDOW) );
+        SetPixel32( hDC, rc.right-1, rc.top, GetSysColor32(COLOR_WINDOW) );
+        SetPixel32( hDC, rc.right-1, rc.bottom-1, GetSysColor32(COLOR_WINDOW));
     }
     InflateRect32( &rc, -1, -1 );
 
@@ -298,13 +298,14 @@
         LOGBRUSH16 lb;
         GetObject16( sysColorObjects.hbrushBtnFace, sizeof(lb), &lb );
         if (wndPtr->dwStyle & WS_DISABLED &&
-            GetSysColor(COLOR_GRAYTEXT)==lb.lbColor)
+            GetSysColor32(COLOR_GRAYTEXT)==lb.lbColor)
             /* don't write gray text on gray bkg */
             PB_PaintGrayOnGray(hDC,infoPtr->hFont,&rc,wndPtr->text);
         else
         {
             SetTextColor( hDC, (wndPtr->dwStyle & WS_DISABLED) ?
-                     GetSysColor(COLOR_GRAYTEXT) : GetSysColor(COLOR_BTNTEXT));
+                                GetSysColor32(COLOR_GRAYTEXT) :
+                                GetSysColor32(COLOR_BTNTEXT) );
             DrawText32A( hDC, wndPtr->text, -1, &rc,
                          DT_SINGLELINE | DT_CENTER | DT_VCENTER );
             /* do we have the focus? */
@@ -416,7 +417,7 @@
         if( textlen && action != ODA_SELECT )
         {
             if (wndPtr->dwStyle & WS_DISABLED)
-                SetTextColor( hDC, GetSysColor(COLOR_GRAYTEXT) );
+                SetTextColor( hDC, GetSysColor32(COLOR_GRAYTEXT) );
             DrawText16( hDC, wndPtr->text, textlen, &rtext,
                         DT_SINGLELINE | DT_VCENTER );
         }
@@ -485,7 +486,7 @@
 
     if (!wndPtr->text) return;
     if (wndPtr->dwStyle & WS_DISABLED)
-        SetTextColor( hDC, GetSysColor(COLOR_GRAYTEXT) );
+        SetTextColor( hDC, GetSysColor32(COLOR_GRAYTEXT) );
     rc.left += 10;
     DrawText16( hDC, wndPtr->text, -1, &rc, DT_SINGLELINE | DT_NOCLIP );
 }
diff --git a/controls/combo.c b/controls/combo.c
index 5ece877..72aca44 100644
--- a/controls/combo.c
+++ b/controls/combo.c
@@ -38,8 +38,8 @@
 #define CBLMM_EDGE   4    /* distance inside box which is same as moving mouse
 			     outside box, to trigger scrolling of CBL */
 
-static BOOL CBCheckSize(HWND hwnd);
-static BOOL CBLCheckSize(HWND hwnd);
+static BOOL CBCheckSize(HWND16 hwnd);
+static BOOL CBLCheckSize(HWND16 hwnd);
 
 static HBITMAP16 hComboBit = 0;
 static WORD CBitHeight, CBitWidth;
@@ -56,17 +56,17 @@
   return 0;
 }
 
-LPHEADCOMBO ComboGetStorageHeader(HWND hwnd)
+LPHEADCOMBO ComboGetStorageHeader(HWND16 hwnd)
 {
   return (LPHEADCOMBO)GetWindowLong32A(hwnd,4);
 }
 
-LPHEADLIST ComboGetListHeader(HWND hwnd)
+LPHEADLIST ComboGetListHeader(HWND16 hwnd)
 {
   return (LPHEADLIST)GetWindowLong32A(hwnd,0);
 }
 
-int CreateComboStruct(HWND hwnd, LONG style)
+int CreateComboStruct(HWND16 hwnd, LONG style)
 {
   LPHEADCOMBO lphc;
 
@@ -81,7 +81,7 @@
   return TRUE;
 }
 
-void ComboUpdateWindow(HWND hwnd, LPHEADLIST lphl, LPHEADCOMBO lphc, BOOL repaint)
+void ComboUpdateWindow(HWND16 hwnd, LPHEADLIST lphl, LPHEADCOMBO lphc, BOOL repaint)
 {
   WND *wndPtr = WIN_FindWndPtr(hwnd);
 
@@ -93,7 +93,7 @@
 /***********************************************************************
  *           CBNCCreate
  */
-static LRESULT CBNCCreate(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBNCCreate(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
   CREATESTRUCT16 *createStruct;
 
@@ -111,7 +111,7 @@
 /***********************************************************************
  *           CBCreate
  */
-static LRESULT CBCreate(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBCreate(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
   LPHEADLIST   lphl;
   LPHEADCOMBO  lphc;
@@ -121,7 +121,7 @@
   WND*         wndPtr = WIN_FindWndPtr(hwnd);
   char className[] = "COMBOLBOX";  /* Hack so that class names are > 0x10000 */
   char editName[] = "EDIT";
-  HWND hwndp=0;
+  HWND16 hwndp=0;
 
   /* translate combo into listbox styles */
   cstyle |= WS_BORDER;
@@ -205,7 +205,7 @@
 /***********************************************************************
  *           CBDestroy
  */
-static LRESULT CBDestroy(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBDestroy(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
   LPHEADCOMBO lphc = ComboGetStorageHeader(hwnd);
 
@@ -217,7 +217,7 @@
 /***********************************************************************
  *           CBPaint
  */
-static LRESULT CBPaint(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBPaint(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
   LPHEADLIST lphl = ComboGetListHeader(hwnd);
   LPHEADCOMBO lphc = ComboGetStorageHeader(hwnd);
@@ -277,7 +277,7 @@
 /***********************************************************************
  *           CBGetDlgCode
  */
-static LRESULT CBGetDlgCode(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBGetDlgCode(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
   return DLGC_WANTARROWS | DLGC_WANTCHARS;
 }
@@ -285,7 +285,7 @@
 /***********************************************************************
  *           CBLButtonDown
  */
-static LRESULT CBLButtonDown(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBLButtonDown(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
   LPHEADCOMBO lphc = ComboGetStorageHeader(hwnd);
   SendMessage16(hwnd,CB_SHOWDROPDOWN16,!lphc->DropDownVisible,0);
@@ -295,7 +295,7 @@
 /***********************************************************************
  *           CBKeyDown
  */
-static LRESULT CBKeyDown(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBKeyDown(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
   LPHEADLIST lphl = ComboGetListHeader(hwnd);
   WORD       newFocused = lphl->ItemFocused;
@@ -335,7 +335,7 @@
 /***********************************************************************
  *           CBChar
  */
-static LRESULT CBChar(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBChar(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
   LPHEADLIST lphl = ComboGetListHeader(hwnd);
   WORD       newFocused;
@@ -361,7 +361,7 @@
 /***********************************************************************
  *           CBKillFocus
  */
-static LRESULT CBKillFocus(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBKillFocus(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
   return 0;
 }
@@ -369,7 +369,7 @@
 /***********************************************************************
  *           CBSetFocus
  */
-static LRESULT CBSetFocus(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBSetFocus(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
   return 0;
 }
@@ -377,7 +377,7 @@
 /***********************************************************************
  *           CBResetContent
  */
-static LRESULT CBResetContent(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBResetContent(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
   LPHEADLIST lphl = ComboGetListHeader(hwnd);
   LPHEADCOMBO lphc = ComboGetStorageHeader(hwnd);
@@ -390,7 +390,7 @@
 /***********************************************************************
  *           CBDir
  */
-static LRESULT CBDir(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBDir(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
   WORD wRet;
   LPHEADLIST lphl = ComboGetListHeader(hwnd);
@@ -404,7 +404,7 @@
 /***********************************************************************
  *           CBInsertString
  */
-static LRESULT CBInsertString(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBInsertString(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
   WORD  wRet;
   LPHEADLIST lphl = ComboGetListHeader(hwnd);
@@ -421,7 +421,7 @@
 /***********************************************************************
  *           CBAddString
  */
-static LRESULT CBAddString(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBAddString(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
   WORD  wRet;
   LPHEADLIST lphl = ComboGetListHeader(hwnd);
@@ -436,7 +436,7 @@
 /***********************************************************************
  *           CBDeleteString
  */
-static LRESULT CBDeleteString(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBDeleteString(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
   LPHEADLIST lphl = ComboGetListHeader(hwnd);
   LPHEADCOMBO lphc = ComboGetStorageHeader(hwnd);
@@ -449,7 +449,7 @@
 /***********************************************************************
  *           CBSelectString
  */
-static LRESULT CBSelectString(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBSelectString(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
   LPHEADLIST lphl = ComboGetListHeader(hwnd);
   WORD  wRet;
@@ -464,7 +464,7 @@
 /***********************************************************************
  *           CBFindString
  */
-static LRESULT CBFindString(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBFindString(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
   LPHEADLIST lphl = ComboGetListHeader(hwnd);
   return ListBoxFindString(lphl, wParam, (SEGPTR)lParam);
@@ -473,7 +473,7 @@
 /***********************************************************************
  *           CBFindStringExact
  */
-static LRESULT CBFindStringExact(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBFindStringExact(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
   LPHEADLIST lphl = ComboGetListHeader(hwnd);
   return ListBoxFindStringExact(lphl, wParam, (SEGPTR)lParam);
@@ -482,7 +482,7 @@
 /***********************************************************************
  *           CBGetCount
  */
-static LRESULT CBGetCount(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBGetCount(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
   LPHEADLIST lphl = ComboGetListHeader(hwnd);
   return lphl->ItemsCount;
@@ -491,7 +491,7 @@
 /***********************************************************************
  *           CBSetCurSel
  */
-static LRESULT CBSetCurSel(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBSetCurSel(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
   LPHEADLIST lphl = ComboGetListHeader(hwnd);
   WORD  wRet;
@@ -509,7 +509,7 @@
 /***********************************************************************
  *           CBGetCurSel
  */
-static LRESULT CBGetCurSel(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBGetCurSel(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
   LPHEADLIST lphl = ComboGetListHeader(hwnd);
   return lphl->ItemFocused;
@@ -518,7 +518,7 @@
 /***********************************************************************
  *           CBGetItemHeight
  */
-static LRESULT CBGetItemHeight(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBGetItemHeight(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
   LPHEADLIST lphl = ComboGetListHeader(hwnd);
   LPLISTSTRUCT lpls = ListBoxGetItem (lphl, wParam);
@@ -530,7 +530,7 @@
 /***********************************************************************
  *           CBSetItemHeight
  */
-static LRESULT CBSetItemHeight(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBSetItemHeight(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
   LPHEADLIST lphl = ComboGetListHeader(hwnd);
   return ListBoxSetItemHeight(lphl, wParam, lParam);
@@ -539,7 +539,7 @@
 /***********************************************************************
  *           CBSetRedraw
  */
-static LRESULT CBSetRedraw(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBSetRedraw(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
   LPHEADLIST lphl = ComboGetListHeader(hwnd);
   lphl->bRedrawFlag = wParam;
@@ -549,7 +549,7 @@
 /***********************************************************************
  *           CBSetFont
  */
-static LRESULT CBSetFont(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBSetFont(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
   LPHEADLIST  lphl = ComboGetListHeader(hwnd);
   LPHEADCOMBO lphc = ComboGetStorageHeader(hwnd);
@@ -566,7 +566,7 @@
 /***********************************************************************
  *           CBGetLBTextLen
  */
-static LRESULT CBGetLBTextLen(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBGetLBTextLen(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
   LPHEADLIST   lphl = ComboGetListHeader(hwnd);
   LPLISTSTRUCT lpls = ListBoxGetItem(lphl,wParam);
@@ -578,7 +578,7 @@
 /***********************************************************************
  *           CBGetLBText
  */
-static LRESULT CBGetLBText(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBGetLBText(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
   LPHEADLIST lphl = ComboGetListHeader(hwnd);
   return ListBoxGetText(lphl, wParam, (LPSTR)PTR_SEG_TO_LIN(lParam));
@@ -587,7 +587,7 @@
 /***********************************************************************
  *           CBGetItemData
  */
-static LRESULT CBGetItemData(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBGetItemData(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
   LPHEADLIST lphl = ComboGetListHeader(hwnd);
   return ListBoxGetItemData(lphl, wParam);
@@ -596,7 +596,7 @@
 /***********************************************************************
  *           CBSetItemData
  */
-static LRESULT CBSetItemData(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBSetItemData(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
   LPHEADLIST lphl = ComboGetListHeader(hwnd);
   return ListBoxSetItemData(lphl, wParam, lParam);
@@ -605,7 +605,7 @@
 /***********************************************************************
  *           CBShowDropDown
  */
-static LRESULT CBShowDropDown(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBShowDropDown(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
   LPHEADCOMBO lphc = ComboGetStorageHeader(hwnd);
   RECT32 rect;
@@ -628,7 +628,7 @@
 /***********************************************************************
  *             CBCheckSize
  */
-static BOOL CBCheckSize(HWND hwnd)
+static BOOL CBCheckSize(HWND16 hwnd)
 {
   LPHEADCOMBO  lphc = ComboGetStorageHeader(hwnd);
   LPHEADLIST   lphl = ComboGetListHeader(hwnd);
@@ -690,7 +690,7 @@
 /***********************************************************************
  *           CBCommand        
  */
-static LRESULT CBCommand(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBCommand(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
   LPHEADCOMBO lphc = ComboGetStorageHeader(hwnd);
   LPHEADLIST lphl = ComboGetListHeader(hwnd);
@@ -750,7 +750,7 @@
  *           CBGetEditSel
  * Look out! Under Win32, the parameter packing is very different.
  */
-static LRESULT CBGetEditSel(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBGetEditSel(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
     LPHEADCOMBO lphc = ComboGetStorageHeader(hwnd);
 
@@ -764,7 +764,7 @@
  *           CBSetEditSel
  * Look out! Under Win32, the parameter packing is very different.
  */
-static LRESULT CBSetEditSel(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBSetEditSel(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
     LPHEADCOMBO lphc = ComboGetStorageHeader(hwnd);
 
@@ -776,7 +776,7 @@
 /***********************************************************************
  *           CBGetText
  */
-static LRESULT CBGetText(HWND hwnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT CBGetText(HWND16 hwnd, WPARAM16 wParam, LPARAM lParam)
 {
     LPHEADCOMBO lphc = ComboGetStorageHeader(hwnd);
 
@@ -786,7 +786,7 @@
 /***********************************************************************
  *           ComboWndProc
  */
-LRESULT ComboBoxWndProc(HWND hwnd, UINT message, WPARAM16 wParam, LPARAM lParam)
+LRESULT ComboBoxWndProc(HWND16 hwnd, UINT message, WPARAM16 wParam, LPARAM lParam)
 {
     switch(message) {	
      case WM_NCCREATE: return CBNCCreate(hwnd, wParam, lParam);
@@ -831,12 +831,12 @@
 /*--------------------------------------------------------------------*/
 /* ComboLBox code starts here */
 
-HWND CLBoxGetCombo(HWND hwnd)
+HWND16 CLBoxGetCombo(HWND16 hwnd)
 {
-  return (HWND)GetWindowLong32A(hwnd,0);
+  return (HWND16)GetWindowLong32A(hwnd,0);
 }
 
-LPHEADLIST CLBoxGetListHeader(HWND hwnd)
+LPHEADLIST CLBoxGetListHeader(HWND16 hwnd)
 {
   return ComboGetListHeader(CLBoxGetCombo(hwnd));
 }
@@ -844,7 +844,7 @@
 /***********************************************************************
  *           CBLCreate
  */
-static LRESULT CBLCreate( HWND hwnd, WPARAM16 wParam, LPARAM lParam )
+static LRESULT CBLCreate( HWND16 hwnd, WPARAM16 wParam, LPARAM lParam )
 {
   CREATESTRUCT16 *createStruct = (CREATESTRUCT16 *)PTR_SEG_TO_LIN(lParam);
   SetWindowLong32A(hwnd,0,(LONG)createStruct->lpCreateParams);
@@ -854,7 +854,7 @@
 /***********************************************************************
  *           CBLGetDlgCode
  */
-static LRESULT CBLGetDlgCode( HWND hwnd, WPARAM16 wParam, LPARAM lParam )
+static LRESULT CBLGetDlgCode( HWND16 hwnd, WPARAM16 wParam, LPARAM lParam )
 {
   return DLGC_WANTARROWS | DLGC_WANTCHARS;
 }
@@ -862,7 +862,7 @@
 /***********************************************************************
  *           CBLKeyDown
  */
-static LRESULT CBLKeyDown( HWND hwnd, WPARAM16 wParam, LPARAM lParam ) 
+static LRESULT CBLKeyDown( HWND16 hwnd, WPARAM16 wParam, LPARAM lParam ) 
 {
   LPHEADLIST lphl = CLBoxGetListHeader(hwnd);
   WORD newFocused = lphl->ItemFocused;
@@ -910,7 +910,7 @@
 /***********************************************************************
  *           CBLChar
  */
-static LRESULT CBLChar( HWND hwnd, WPARAM16 wParam, LPARAM lParam )
+static LRESULT CBLChar( HWND16 hwnd, WPARAM16 wParam, LPARAM lParam )
 {
   return 0;
 }
@@ -918,7 +918,7 @@
 /***********************************************************************
  *           CBLPaint
  */
-static LRESULT CBLPaint( HWND hwnd, WPARAM16 wParam, LPARAM lParam )
+static LRESULT CBLPaint( HWND16 hwnd, WPARAM16 wParam, LPARAM lParam )
 {
   LPHEADLIST   lphl = CLBoxGetListHeader(hwnd);
   LPLISTSTRUCT lpls;
@@ -926,7 +926,7 @@
   HBRUSH32 hBrush;
   HFONT32 hOldFont;
   WND * wndPtr = WIN_FindWndPtr(hwnd);
-  HWND  combohwnd = CLBoxGetCombo(hwnd);
+  HWND16  combohwnd = CLBoxGetCombo(hwnd);
   HDC16 hdc;
   RECT16 rect;
   int   i, top, height;
@@ -1000,7 +1000,7 @@
 /***********************************************************************
  *           CBLKillFocus
  */
-static LRESULT CBLKillFocus( HWND hwnd, WPARAM16 wParam, LPARAM lParam )
+static LRESULT CBLKillFocus( HWND16 hwnd, WPARAM16 wParam, LPARAM lParam )
 {
 /*  SendMessage16(CLBoxGetCombo(hwnd),CB_SHOWDROPDOWN16,0,0);*/
   return 0;
@@ -1009,7 +1009,7 @@
 /***********************************************************************
  *           CBLActivate
  */
-static LRESULT CBLActivate( HWND hwnd, WPARAM16 wParam, LPARAM lParam )
+static LRESULT CBLActivate( HWND16 hwnd, WPARAM16 wParam, LPARAM lParam )
 {
   if (wParam == WA_INACTIVE)
     SendMessage16(CLBoxGetCombo(hwnd),CB_SHOWDROPDOWN16,0,0);
@@ -1019,7 +1019,7 @@
 /***********************************************************************
  *           CBLLButtonDown
  */
-static LRESULT CBLLButtonDown( HWND hwnd, WPARAM16 wParam, LPARAM lParam )
+static LRESULT CBLLButtonDown( HWND16 hwnd, WPARAM16 wParam, LPARAM lParam )
 {
   LPHEADLIST lphl = CLBoxGetListHeader(hwnd);
   int        y;
@@ -1044,7 +1044,7 @@
 /***********************************************************************
  *           CBLLButtonUp
  */
-static LRESULT CBLLButtonUp( HWND hwnd, WPARAM16 wParam, LPARAM lParam )
+static LRESULT CBLLButtonUp( HWND16 hwnd, WPARAM16 wParam, LPARAM lParam )
 {
   LPHEADLIST lphl = CLBoxGetListHeader(hwnd);
 
@@ -1069,7 +1069,7 @@
 /***********************************************************************
  *           CBLMouseMove
  */
-static LRESULT CBLMouseMove( HWND hwnd, WPARAM16 wParam, LPARAM lParam )
+static LRESULT CBLMouseMove( HWND16 hwnd, WPARAM16 wParam, LPARAM lParam )
 {
   LPHEADLIST lphl = CLBoxGetListHeader(hwnd);
   short y;
@@ -1116,7 +1116,7 @@
 /***********************************************************************
  *           CBLVScroll
  */
-static LRESULT CBLVScroll( HWND hwnd, WPARAM16 wParam, LPARAM lParam )
+static LRESULT CBLVScroll( HWND16 hwnd, WPARAM16 wParam, LPARAM lParam )
 {
   LPHEADLIST lphl = CLBoxGetListHeader(hwnd);
   int  y;
@@ -1165,12 +1165,12 @@
 /***********************************************************************
  *             CBLCheckSize
  */
-static BOOL CBLCheckSize(HWND hwnd)
+static BOOL CBLCheckSize(HWND16 hwnd)
 {
   LPHEADCOMBO  lphc = ComboGetStorageHeader(hwnd);
   LPHEADLIST   lphl = ComboGetListHeader(hwnd);
   LPLISTSTRUCT lpls;
-  HWND         hWndLBox;
+  HWND16         hWndLBox;
   RECT16 cRect,wRect,lRect,lwRect;
   int totheight,dw;
   char className[80];
@@ -1218,7 +1218,7 @@
 /***********************************************************************
  *           ComboLBoxWndProc
  */
-LRESULT ComboLBoxWndProc(HWND hwnd, UINT message, WPARAM16 wParam, LPARAM lParam)
+LRESULT ComboLBoxWndProc(HWND16 hwnd, UINT message, WPARAM16 wParam, LPARAM lParam)
 {
     switch(message) {	
      case WM_CREATE: return CBLCreate(hwnd, wParam, lParam);
diff --git a/controls/desktop.c b/controls/desktop.c
index 895fec4..db876a8 100644
--- a/controls/desktop.c
+++ b/controls/desktop.c
@@ -92,7 +92,7 @@
     {
 	  /* Set colors in case pattern is a monochrome bitmap */
 	SetBkColor( hdc, RGB(0,0,0) );
-	SetTextColor( hdc, GetSysColor(COLOR_BACKGROUND) );
+	SetTextColor( hdc, GetSysColor32(COLOR_BACKGROUND) );
 	FillRect32( hdc, &rect, infoPtr->hbrushPattern );
     }
 
@@ -159,7 +159,7 @@
 	ExitWindows16( 0, 0 ); 
 
     case WM_SETCURSOR:
-        return (LRESULT)SetCursor( LoadCursor16( 0, IDC_ARROW ) );
+        return (LRESULT)SetCursor16( LoadCursor16( 0, IDC_ARROW ) );
     }
     
     return 0;
@@ -247,7 +247,7 @@
 	infoPtr->hbrushPattern = CreatePatternBrush32( hbitmap );
 	DeleteObject32( hbitmap );
     }
-    else infoPtr->hbrushPattern = CreateSolidBrush32( GetSysColor(COLOR_BACKGROUND) );
+    else infoPtr->hbrushPattern = CreateSolidBrush32( GetSysColor32(COLOR_BACKGROUND) );
     return TRUE;
 }
 
diff --git a/controls/edit.c b/controls/edit.c
index b333222..8e7b59f 100644
--- a/controls/edit.c
+++ b/controls/edit.c
@@ -98,7 +98,7 @@
 	INT32 SelStart;		/* offset of selection start, == SelEnd if no selection */
 	INT32 SelEnd;		/* offset of selection end == current caret position */
 	INT32 NumTabStops;
-	LPINT16 TabStops;
+	LPINT32 TabStops;
 	/*
 	 *	FIXME: The following should probably be a (VOID *) that is
 	 *	typecast to either 16- or 32-bit callback when used,
@@ -667,15 +667,8 @@
 		lResult = EDIT_WM_Command(wndPtr, wParam, lParam);
 		break;
 
-/*
- *	FIXME: when this one is added to WINE, change RBUTTONUP to CONTEXTMENU
- *	Furthermore, coordinate conversion should no longer be required
- *
- *	case WM_CONTEXTMENU:
- */
- 	case WM_RBUTTONUP:
-		DPRINTF_EDIT_MSG32("WM_RBUTTONUP");
-		ClientToScreen16(wndPtr->hwndSelf, (LPPOINT16)&lParam);
+ 	case WM_CONTEXTMENU:
+		DPRINTF_EDIT_MSG32("WM_CONTEXTMENU");
 		lResult = EDIT_WM_ContextMenu(wndPtr, wParam, lParam);
 		break;
 
@@ -865,7 +858,7 @@
 		es->LineDefs[0].offset = 0;
 		es->LineDefs[0].length = EDIT_WM_GetTextLength(wndPtr, 0, 0);
 		es->LineDefs[0].ending = END_0;
-		es->TextWidth = (INT32)LOWORD(GetTabbedTextExtent(hdc, text,
+		es->TextWidth = (INT32)LOWORD(GetTabbedTextExtent32A(hdc, text,
 					es->LineDefs[0].length,
 					es->NumTabStops, es->TabStops));
 	} else {
@@ -882,7 +875,7 @@
 				ending = END_HARD;
 				length = cp - start;
 			}
-			width = (INT32)LOWORD(GetTabbedTextExtent(hdc, start, length,
+			width = (INT32)LOWORD(GetTabbedTextExtent32A(hdc, start, length,
 						es->NumTabStops, es->TabStops));
 
 			if (IsWordWrap(wndPtr) && (width > ww)) {
@@ -891,7 +884,7 @@
 					prev = next;
 					next = EDIT_CallWordBreakProc(wndPtr, start,
 							prev + 1, length, WB_RIGHT);
-					width = (INT32)LOWORD(GetTabbedTextExtent(hdc, start, next,
+					width = (INT32)LOWORD(GetTabbedTextExtent32A(hdc, start, next,
 							es->NumTabStops, es->TabStops));
 				} while (width <= ww);
 				if (!prev) {
@@ -899,7 +892,7 @@
 					do {
 						prev = next;
 						next++;
-						width = (INT32)LOWORD(GetTabbedTextExtent(hdc, start, next,
+						width = (INT32)LOWORD(GetTabbedTextExtent32A(hdc, start, next,
 								es->NumTabStops, es->TabStops));
 					} while (width <= ww);
 					if(!prev) prev = 1;
@@ -911,7 +904,7 @@
 					ending = END_DELIMIT;
 				} else
 					ending = END_NONE;
-				width = (INT32)LOWORD(GetTabbedTextExtent(hdc, start, length,
+				width = (INT32)LOWORD(GetTabbedTextExtent32A(hdc, start, length,
 							es->NumTabStops, es->TabStops));
 			}
 
@@ -1786,13 +1779,13 @@
 	BkColor = GetBkColor32(hdc);
 	TextColor = GetTextColor32(hdc);
 	if (rev) {
-		SetBkColor(hdc, GetSysColor(COLOR_HIGHLIGHT));
-		SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
+		SetBkColor(hdc, GetSysColor32(COLOR_HIGHLIGHT));
+		SetTextColor(hdc, GetSysColor32(COLOR_HIGHLIGHTTEXT));
 	}
 	text = EDIT_GetPasswordPointer(wndPtr);
 	li = (INT32)EDIT_EM_LineIndex(wndPtr, line, 0);
 	xoff = EDIT_GetXOffset(wndPtr);
-	ret = (INT32)LOWORD(TabbedTextOut(hdc, x, y, text + li + col, count,
+	ret = (INT32)LOWORD(TabbedTextOut32A(hdc, x, y, text + li + col, count,
 					es->NumTabStops, es->TabStops, -xoff));
 	free(text);
 	if (rev) {
@@ -1911,7 +1904,7 @@
 	if (hFont) oldFont = SelectObject32(hdc, hFont);
 	line = MAX(0, MIN(line, lc - 1));
 	col = MIN(col, ll);
-	ret = (INT32)LOWORD(GetTabbedTextExtent(hdc,
+	ret = (INT32)LOWORD(GetTabbedTextExtent32A(hdc,
 			text + li, col,
 			es->NumTabStops, es->TabStops)) - xoff;
 	if (hFont) SelectObject32(hdc, oldFont);
@@ -2910,7 +2903,6 @@
 static LRESULT EDIT_EM_SetTabStops(WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
 {
 	EDITSTATE *es = EDITSTATEPTR(wndPtr);
-	INT32 i;
 
 	if (!IsMultiLine(wndPtr))
 		return FALSE;
@@ -2920,9 +2912,9 @@
 	if (!wParam)
 		es->TabStops = NULL;
 	else {
-		es->TabStops = (LPINT16)xmalloc(wParam * sizeof(INT16));
-		for ( i = 0 ; i < (INT32)wParam ; i++ )
-			es->TabStops[i] = (INT16)((LPINT32)lParam)[i];
+		es->TabStops = (LPINT32)xmalloc(wParam * sizeof(INT32));
+		memcpy( es->TabStops, (LPINT32)lParam,
+                        (INT32)wParam * sizeof(INT32) );
 	}
 	return TRUE;
 }
@@ -2936,6 +2928,7 @@
 static LRESULT EDIT_EM_SetTabStops16(WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
 {
 	EDITSTATE *es = EDITSTATEPTR(wndPtr);
+	INT32 i;
 
 	if (!IsMultiLine(wndPtr))
 		return FALSE;
@@ -2944,10 +2937,11 @@
 	es->NumTabStops = (INT32)wParam;
 	if (!wParam)
 		es->TabStops = NULL;
-	else {
-		es->TabStops = (LPINT16)xmalloc(wParam * sizeof(INT16));
-		memcpy(es->TabStops, (LPINT16)PTR_SEG_TO_LIN(lParam),
-				(INT32)wParam * sizeof(INT16));
+	else
+        {
+            LPINT16 p = (LPINT16)PTR_SEG_TO_LIN(lParam);
+            es->TabStops = (LPINT32)xmalloc(wParam * sizeof(INT32));
+            for ( i = 0 ; i < (INT32)wParam ; i++) es->TabStops[i] = *p++;
 	}
 	return TRUE;
 }
@@ -3126,10 +3120,10 @@
 	text = EDIT_GetPointer(wndPtr);
 	lstrcpyn32A(dst, text + s, e - s + 1);
 	GlobalUnlock16(hdst);
-	OpenClipboard(wndPtr->hwndSelf);
-	EmptyClipboard();
+	OpenClipboard32(wndPtr->hwndSelf);
+	EmptyClipboard32();
 	SetClipboardData(CF_TEXT, hdst);
-	CloseClipboard();
+	CloseClipboard32();
 	return -1;
 }
 
@@ -3423,7 +3417,7 @@
 		((e - s) && !IsPassword(wndPtr) ? MF_ENABLED : MF_GRAYED));
 	/* paste */
 	EnableMenuItem32(hPopup, 4, MF_BYPOSITION |
-		(IsClipboardFormatAvailable(CF_TEXT) ? MF_ENABLED : MF_GRAYED));
+		(IsClipboardFormatAvailable32(CF_TEXT) ? MF_ENABLED : MF_GRAYED));
 	/* delete */
 	EnableMenuItem32(hPopup, 5, MF_BYPOSITION |
 		((e - s) ? MF_ENABLED : MF_GRAYED));
@@ -3694,7 +3688,7 @@
 		oldFont = (HFONT32)SelectObject32(hdc, hFont);
 	EDIT_SEND_CTLCOLOR(wndPtr, hdc);
 	if (!IsWindowEnabled32(wndPtr->hwndSelf))
-		SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT));
+		SetTextColor(hdc, GetSysColor32(COLOR_GRAYTEXT));
 	GetClipBox32(hdc, &rcRgn);
 	for (i = fv ; i <= MIN(fv + vlc, fv + lc - 1) ; i++ ) {
 		EDIT_GetLineRect(wndPtr, i, 0, -1, &rcLine);
@@ -3722,13 +3716,13 @@
 	HGLOBAL16 hsrc;
 	LPSTR src;
 
-	OpenClipboard(wndPtr->hwndSelf);
+	OpenClipboard32(wndPtr->hwndSelf);
 	if ((hsrc = GetClipboardData(CF_TEXT))) {
 		src = (LPSTR)GlobalLock16(hsrc);
 		EDIT_EM_ReplaceSel(wndPtr, (WPARAM32)TRUE, (LPARAM)src);
 		GlobalUnlock16(hsrc);
 	}
-	CloseClipboard();
+	CloseClipboard32();
 	return -1;
 }
 
@@ -3741,7 +3735,7 @@
 static LRESULT EDIT_WM_SetCursor(WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
 {
 	if (LOWORD(lParam) == HTCLIENT) {
-		SetCursor(LoadCursor16(0, IDC_IBEAM));
+		SetCursor16(LoadCursor16(0, IDC_IBEAM));
 		return -1;
 	} else
 		return 0;
@@ -3763,7 +3757,7 @@
 	EDIT_SetSel(wndPtr, s, e);
 	if(!(wndPtr->dwStyle & ES_NOHIDESEL))
 		EDIT_InvalidateText(wndPtr, s, e);
-	ShowCaret(wndPtr->hwndSelf);
+	ShowCaret32(wndPtr->hwndSelf);
 	dprintf_edit(stddeb, "edit: notification EN_SETFOCUS sent\n");
 	EDIT_NOTIFY_PARENT(wndPtr, EN_SETFOCUS);
 	return 0;
@@ -3800,7 +3794,7 @@
 		DestroyCaret();
 		CreateCaret(wndPtr->hwndSelf, 0, 2, EDIT_GetLineHeight(wndPtr));
 		EDIT_SetSel(wndPtr, s, e);
-		ShowCaret(wndPtr->hwndSelf);
+		ShowCaret32(wndPtr->hwndSelf);
 	}
 	return 0;
 }
diff --git a/controls/listbox.c b/controls/listbox.c
index fd8c665..db00116 100644
--- a/controls/listbox.c
+++ b/controls/listbox.c
@@ -470,16 +470,16 @@
         }
         if (item && item->selected)
         {
-            SetBkColor( hdc, GetSysColor( COLOR_HIGHLIGHT ) );
-            SetTextColor( hdc, GetSysColor( COLOR_HIGHLIGHTTEXT ) );
+            SetBkColor( hdc, GetSysColor32( COLOR_HIGHLIGHT ) );
+            SetTextColor( hdc, GetSysColor32( COLOR_HIGHLIGHTTEXT ) );
         }
         else
         {
-            SetBkColor( hdc, GetSysColor( COLOR_WINDOW ) );
+            SetBkColor( hdc, GetSysColor32( COLOR_WINDOW ) );
             if (wnd->dwStyle & WS_DISABLED)
-                SetTextColor( hdc, GetSysColor( COLOR_GRAYTEXT ) );
+                SetTextColor( hdc, GetSysColor32( COLOR_GRAYTEXT ) );
             else
-                SetTextColor( hdc, GetSysColor( COLOR_WINDOWTEXT ) );
+                SetTextColor( hdc, GetSysColor32( COLOR_WINDOWTEXT ) );
         }
         dprintf_listbox( stddeb, "Listbox %04x: painting %d (%s) action=%02x "
                          "rect=%d,%d-%d,%d\n",
@@ -856,7 +856,7 @@
             if (!IS_OWNERDRAW(descr))
             {
                 /* Clear the bottom of the column */
-                SetBkColor( hdc, GetSysColor( COLOR_WINDOW ) );
+                SetBkColor( hdc, GetSysColor32( COLOR_WINDOW ) );
                 if (rect.top < descr->height)
                 {
                     rect.bottom = descr->height;
@@ -881,7 +881,7 @@
     if (!IS_OWNERDRAW(descr))
     {
         /* Clear the remainder of the client area */
-        SetBkColor( hdc, GetSysColor( COLOR_WINDOW ) );
+        SetBkColor( hdc, GetSysColor32( COLOR_WINDOW ) );
         if (rect.top < descr->height)
         {
             rect.bottom = descr->height;
@@ -1691,8 +1691,8 @@
                             MAKELPARAM( x, y ) );
         if (wnd->dwExStyle & WS_EX_DRAGDETECT)
         {
-            POINT16 pt = { x, y };
-            if (DragDetect( wnd->hwndSelf, pt ))
+            POINT32 pt = { x, y };
+            if (DragDetect32( wnd->hwndSelf, pt ))
                 SendMessage32A( descr->owner, WM_BEGINDRAG, 0, 0 );
         }
     }
diff --git a/controls/menu.c b/controls/menu.c
index bedd677..6f0c071 100644
--- a/controls/menu.c
+++ b/controls/menu.c
@@ -600,18 +600,18 @@
     if (lpitem->item_flags & MF_HILITE)
     {
 	if (lpitem->item_flags & MF_GRAYED)
-	    SetTextColor( hdc, GetSysColor( COLOR_GRAYTEXT ) );
+	    SetTextColor( hdc, GetSysColor32( COLOR_GRAYTEXT ) );
 	else
-	    SetTextColor( hdc, GetSysColor( COLOR_HIGHLIGHTTEXT ) );
-	SetBkColor( hdc, GetSysColor( COLOR_HIGHLIGHT ) );
+	    SetTextColor( hdc, GetSysColor32( COLOR_HIGHLIGHTTEXT ) );
+	SetBkColor( hdc, GetSysColor32( COLOR_HIGHLIGHT ) );
     }
     else
     {
 	if (lpitem->item_flags & MF_GRAYED)
-	    SetTextColor( hdc, GetSysColor( COLOR_GRAYTEXT ) );
+	    SetTextColor( hdc, GetSysColor32( COLOR_GRAYTEXT ) );
 	else
-	    SetTextColor( hdc, GetSysColor( COLOR_MENUTEXT ) );
-	SetBkColor( hdc, GetSysColor( COLOR_MENU ) );
+	    SetTextColor( hdc, GetSysColor32( COLOR_MENUTEXT ) );
+	SetBkColor( hdc, GetSysColor32( COLOR_MENU ) );
     }
 
     if (!menuBar)
@@ -1676,7 +1676,7 @@
 					      PM_NOREMOVE, TRUE ))
 	    break;
 
-        TranslateMessage( &msg );
+        TranslateMessage16( &msg );
         CONV_POINT16TO32( &msg.pt, &pt );
 
         fRemove = FALSE;
@@ -1790,7 +1790,7 @@
 		    if ((msg.wParam <= 32) || (msg.wParam >= 127)) break;
 		    pos = MENU_FindItemByKey( hwnd, hmenuCurrent, msg.wParam );
 		    if (pos == (UINT32)-2) fClosed = TRUE;
-		    else if (pos == (UINT32)-1) MessageBeep(0);
+		    else if (pos == (UINT32)-1) MessageBeep32(0);
 		    else
 		    {
 			MENU_SelectItem( hwnd, hmenuCurrent, pos, TRUE );
@@ -1804,7 +1804,7 @@
 	}
 	else
 	{
-	    DispatchMessage( &msg );
+	    DispatchMessage16( &msg );
 	}
 	if (fEndMenuCalled) fClosed = TRUE;
 	if (!fClosed) fRemove = TRUE;
@@ -1873,7 +1873,7 @@
 
     if (IsMenu32(hMenu))
     {
-	HideCaret(0);
+	HideCaret32(0);
 	SendMessage16( hWnd, WM_ENTERMENULOOP, 0, 0 );
 	SendMessage16( hWnd, WM_INITMENU, hMenu, 0 );
 	if( bTrackSys )
@@ -1882,7 +1882,7 @@
 	    MENU_TrackMenu( hMenu, TPM_LEFTALIGN | TPM_LEFTBUTTON,
 			    pt.x, pt.y, hWnd, NULL );
 	SendMessage16( hWnd, WM_EXITMENULOOP, 0, 0 );
-	ShowCaret(0);
+	ShowCaret32(0);
     }
 }
 
@@ -1911,7 +1911,7 @@
 
     if (IsMenu32( hTrackMenu ))
     {
-        HideCaret(0);
+        HideCaret32(0);
         SendMessage16( wndPtr->hwndSelf, WM_ENTERMENULOOP, 0, 0 );
         SendMessage16( wndPtr->hwndSelf, WM_INITMENU, hTrackMenu, 0 );
 
@@ -1926,7 +1926,7 @@
 		    : MENU_FindItemByKey( wndPtr->hwndSelf, wndPtr->wIDmenu, vkey );
 	    if( uItem >= 0xFFFE )
 	    {
-	        if( uItem == 0xFFFF ) MessageBeep(0);
+	        if( uItem == 0xFFFF ) MessageBeep32(0);
 		htMenu = 0;
 	    }
         }
@@ -1946,12 +1946,10 @@
 
 	    case HTSYSMENU:
 		MENU_TrackSysPopup( wndPtr );
-
-	    default:
 	}
 
         SendMessage16( wndPtr->hwndSelf, WM_EXITMENULOOP, 0, 0 );
-        ShowCaret(0);
+        ShowCaret32(0);
     }
 }
 
@@ -1978,10 +1976,10 @@
 {
     BOOL32 ret = FALSE;
 
-    HideCaret(0);
+    HideCaret32(0);
     if (MENU_ShowPopup( hWnd, hMenu, 0, x, y, 0, 0 )) 
 	ret = MENU_TrackMenu( hMenu, wFlags, 0, 0, hWnd, lpRect );
-    ShowCaret(0);
+    ShowCaret32(0);
     return ret;
 }
 
diff --git a/controls/oldlbox.c b/controls/oldlbox.c
index 1eef33c..87e6a5a 100644
--- a/controls/oldlbox.c
+++ b/controls/oldlbox.c
@@ -57,7 +57,7 @@
   lphl->PrevFocused    = -1;
 }
 
-void CreateListBoxStruct(HWND hwnd, WORD CtlType, LONG styles, HWND parent)
+void CreateListBoxStruct(HWND16 hwnd, WORD CtlType, LONG styles, HWND16 parent)
 {
   LPHEADLIST lphl;
   HDC32         hdc;
@@ -173,7 +173,7 @@
 }
 
 
-void ListBoxDrawItem(HWND hwnd, LPHEADLIST lphl, HDC16 hdc, LPLISTSTRUCT lpls, 
+void ListBoxDrawItem(HWND16 hwnd, LPHEADLIST lphl, HDC16 hdc, LPLISTSTRUCT lpls, 
                      RECT16 *rect, WORD itemAction, WORD itemState)
 {
     if (lphl->OwnerDrawn)
@@ -204,7 +204,7 @@
       }
 
       if (lphl->dwStyle & LBS_USETABSTOPS) {
-	TabbedTextOut(hdc, rect->left + 5, rect->top + 2, 
+	TabbedTextOut16(hdc, rect->left + 5, rect->top + 2, 
 		      (char *)lpls->itemText, strlen((char *)lpls->itemText), 
 		      lphl->iNumStops, lphl->TabStops, 0);
       } else {
diff --git a/controls/static.c b/controls/static.c
index 9184cf5..9842f06 100644
--- a/controls/static.c
+++ b/controls/static.c
@@ -67,7 +67,7 @@
 /***********************************************************************
  *           StaticWndProc
  */
-LRESULT StaticWndProc(HWND hWnd, UINT uMsg, WPARAM16 wParam, LPARAM lParam)
+LRESULT StaticWndProc( HWND16 hWnd, UINT uMsg, WPARAM16 wParam, LPARAM lParam)
 {
     LRESULT lResult = 0;
     WND *wndPtr = WIN_FindWndPtr(hWnd);
@@ -103,14 +103,14 @@
 		break;
             }
 	    /* initialise colours */
-	    color_windowframe  = GetSysColor(COLOR_WINDOWFRAME);
-	    color_background   = GetSysColor(COLOR_BACKGROUND);
-	    color_window       = GetSysColor(COLOR_WINDOW);
+	    color_windowframe  = GetSysColor32(COLOR_WINDOWFRAME);
+	    color_background   = GetSysColor32(COLOR_BACKGROUND);
+	    color_window       = GetSysColor32(COLOR_WINDOW);
 	    break;
 
         case WM_NCDESTROY:
             if (style == SS_ICON)
-                DestroyIcon( STATIC_SetIcon( wndPtr, 0 ) );
+                DestroyIcon32( STATIC_SetIcon( wndPtr, 0 ) );
             else 
                 lResult = DefWindowProc16(hWnd, uMsg, wParam, lParam);
             break;
@@ -126,9 +126,9 @@
 	    break;
 
 	case WM_SYSCOLORCHANGE:
-	    color_windowframe  = GetSysColor(COLOR_WINDOWFRAME);
-	    color_background   = GetSysColor(COLOR_BACKGROUND);
-	    color_window       = GetSysColor(COLOR_WINDOW);
+	    color_windowframe  = GetSysColor32(COLOR_WINDOWFRAME);
+	    color_background   = GetSysColor32(COLOR_BACKGROUND);
+	    color_window       = GetSysColor32(COLOR_WINDOW);
 	    InvalidateRect32( hWnd, NULL, TRUE );
 	    break;
 
@@ -270,13 +270,13 @@
 
 static void STATIC_PaintIconfn( WND *wndPtr, HDC32 hdc )
 {
-    RECT16 rc;
-    HBRUSH16 hbrush;
+    RECT32 rc;
+    HBRUSH32 hbrush;
     STATICINFO *infoPtr = (STATICINFO *)wndPtr->wExtra;
 
-    GetClientRect16( wndPtr->hwndSelf, &rc);
+    GetClientRect32( wndPtr->hwndSelf, &rc );
     hbrush = SendMessage32A( GetParent32(wndPtr->hwndSelf), WM_CTLCOLORSTATIC,
                              hdc, wndPtr->hwndSelf );
-    FillRect16( hdc, &rc, hbrush );
-    if (infoPtr->hIcon) DrawIcon( hdc, rc.left, rc.top, infoPtr->hIcon );
+    FillRect32( hdc, &rc, hbrush );
+    if (infoPtr->hIcon) DrawIcon32( hdc, rc.left, rc.top, infoPtr->hIcon );
 }
diff --git a/debugger/msc.c b/debugger/msc.c
index 6514f37..fd8da77 100644
--- a/debugger/msc.c
+++ b/debugger/msc.c
@@ -17,6 +17,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+#include <sys/types.h>
 #include <sys/mman.h>
 #include <fcntl.h>
 #include <sys/stat.h>
@@ -24,7 +25,9 @@
 #include <string.h>
 #include <unistd.h>
 #include <malloc.h>
-
+#ifndef PATH_MAX
+#define PATH_MAX _MAX_PATH
+#endif
 #include "win.h"
 #include "pe_image.h"
 #include "peexe.h"
diff --git a/debugger/source.c b/debugger/source.c
index 8cad568..d9c6412 100644
--- a/debugger/source.c
+++ b/debugger/source.c
@@ -8,6 +8,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+#include <sys/types.h>
 #include <sys/mman.h>
 #include <fcntl.h>
 #include <sys/stat.h>
@@ -15,6 +16,9 @@
 #include <string.h>
 #include <unistd.h>
 #include <malloc.h>
+#ifndef PATH_MAX
+#define PATH_MAX _MAX_PATH
+#endif
 
 #include "win.h"
 #include "pe_image.h"
diff --git a/debugger/stabs.c b/debugger/stabs.c
index 8a1bea1..9e64a36 100644
--- a/debugger/stabs.c
+++ b/debugger/stabs.c
@@ -4,8 +4,10 @@
  * Copyright (C) 1996, Eric Youngdale.
  */
 
+#include <sys/types.h>
 #include <fcntl.h>
 #include <sys/stat.h>
+#include <sys/mman.h>
 #include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/documentation/wine_os2.txt b/documentation/wine_os2.txt
index 97ad044..f66fb71 100644
--- a/documentation/wine_os2.txt
+++ b/documentation/wine_os2.txt
@@ -1,5 +1,9 @@
 	Running & Compiling WINE in OS/2
 
+If you want to help for the port of WINE to OS/2, 
+send me a message at krynos@clic.net
+I currently don't want beta testers. It must work before we can test it.
+
 Here is what you need to (try to) compile Wine for OS/2:
 EMX 0.9c (fix 2)
 XFree86 3.2 OS/2 (with development libraries)
@@ -7,35 +11,35 @@
 sed (a working copy of)
 xpm
 diff and patch are recommended
+Lots of disk space (about 40-50 megs after EMX and XFree installed)
 
 To compile:
 sh 
 tools/make_os2.sh
 make depend
-make (make doesn't work yet... I will need to do some others patch, or
-      you may do it...)
+make
+emxbind wine
 
 Currently:
 - configure and make depend work...
-- make doesn't work well...
-- the selectors numbers (0) are wrong...
+- make compiles (with a modified Linux mman.h), but doesn't link.
 - signal handling is horrible... (if any)
-- EMX doesn't seem to support mmap
-- debugger don't compile at all
-- sigcontext.h isn't right (incomplete structure?).
+- EMX doesn't support mmap (and related), SysV IPC and stafs()
+- XFree86/OS2 3.2 doesn't support XShmQueryExtension() and XShmPixmapFormat()
+  due to the same lack in EMX...
 
 What needs to be redone:
+- LDT (using DosAllocSeg in memory/ldt.c) *
+- implement mmap() and SysV IPC in EMX *
 - File functions, 
 - I/O access (do it!),
 - Communication (modem),
 - Interrupt (if int unknow, call current RealMode one...), 
 - verify that everything is thread safe (how does Win95/NT handle multi-thread?), 
 - move X functions in some files (and make a wrapper, to use PM instead latter), 
-- implement mmap (or find something else), 
-- make debugger work, 
 - return right CPU type, 
 - make winsock work
-
+* Top priority
 
 The good things:
 - OS/2 have DOS interrupts
diff --git a/graphics/win16drv/init.c b/graphics/win16drv/init.c
index 930d005..3a9b742 100644
--- a/graphics/win16drv/init.c
+++ b/graphics/win16drv/init.c
@@ -813,7 +813,7 @@
     if ((pLPD = FindPrinterDriverFromPDEVICE(lpDestDev)) != NULL)
     {
 	LONG lP1, lP4, lP5, lP7, lP8, lP9, lP10, lP11;  
-	WORD wP2, wP3, wP6, wP12;
+	WORD wP2, wP3, wP12;
         INT16 iP6;
 
 	SEGPTR SegPtr = pLPD->ThunkBufSegPtr;
@@ -945,7 +945,7 @@
 ExtractPQ(HPQ hPQ) 
 { 
     struct hpq *queue, *prev, *current, *currentPrev;
-    int key, tag = -1;
+    int key = 0, tag = -1;
     currentPrev = prev = NULL;
     queue = current = hpqueue;
     if (current)
@@ -1146,7 +1146,7 @@
 
     dprintf_win16drv(stddeb, "WriteDialog: %04x %04x \"%s\"\n", hJob,  cchMsg, lpMsg);
 
-    nRet = MessageBox16(NULL, lpMsg, "Printing Error", MB_OKCANCEL);
+    nRet = MessageBox16( 0, lpMsg, "Printing Error", MB_OKCANCEL);
     return nRet;
 }
 
diff --git a/graphics/win16drv/text.c b/graphics/win16drv/text.c
index 0620ddc..fe07463 100644
--- a/graphics/win16drv/text.c
+++ b/graphics/win16drv/text.c
@@ -87,10 +87,10 @@
 	lpOpaqueRect->top = y;
 	lpOpaqueRect->right = 0x3a1;
 	lpOpaqueRect->bottom = 0x01;
-        printf("drawmode ropt 0x%x bkMode 0x%x bkColor 0x%x textColor 0x%x tbbreakExtra 0x%x breakextra 0x%x\n",
+        printf("drawmode ropt 0x%x bkMode 0x%x bkColor 0x%lx textColor 0x%lx tbbreakExtra 0x%x breakextra 0x%x\n",
                lpDrawMode->Rop2,    lpDrawMode->bkMode,    lpDrawMode->bkColor,
                lpDrawMode->TextColor,    lpDrawMode->TBreakExtra,    lpDrawMode->BreakExtra);
-        printf("breakerr 0x%x breakrem 0x%x breakcount 0x%x chextra 0x%x lbkcolor 0x%x ltextcolor 0x%x\n",
+        printf("breakerr 0x%x breakrem 0x%x breakcount 0x%x chextra 0x%x lbkcolor 0x%lx ltextcolor 0x%lx\n",
                lpDrawMode->BreakErr,    lpDrawMode->BreakRem,    lpDrawMode->BreakCount,
                lpDrawMode->CharExtra,	   lpDrawMode->LbkColor,    lpDrawMode->LTextColor);
 
diff --git a/if1632/advapi32.spec b/if1632/advapi32.spec
index a78d78d..fb584e4 100644
--- a/if1632/advapi32.spec
+++ b/if1632/advapi32.spec
@@ -13,7 +13,7 @@
 0008 stub AddAuditAccessAce
 0009 stub AdjustTokenGroups
 0010 stub AdjustTokenPrivileges
-0011 stub AllocateAndInitializeSid
+0011 stdcall AllocateAndInitializeSid(ptr long long long long long long long long long ptr) AllocateAndInitializeSid
 0012 stub AllocateLocallyUniqueId
 0013 stub AreAllAccessesGranted
 0014 stub AreAnyAccessesGranted
@@ -26,7 +26,7 @@
 0021 stub CloseEventLog
 0022 stub CloseServiceHandle
 0023 stub ControlService
-0024 stub CopySid
+0024 stdcall CopySid(long ptr ptr) CopySid
 0025 stub CreatePrivateObjectSecurity
 0026 stub CreateProcessAsUserA
 0027 stub CreateProcessAsUserW
@@ -41,16 +41,16 @@
 0036 stub EnumDependentServicesW
 0037 stub EnumServicesStatusA
 0038 stub EnumServicesStatusW
-0039 stub EqualPrefixSid
-0040 stub EqualSid
+0039 stdcall EqualPrefixSid(ptr ptr) EqualPrefixSid
+0040 stdcall EqualSid(ptr ptr) EqualSid
 0041 stub FindFirstFreeAce
-0042 stub FreeSid
+0042 stdcall FreeSid(ptr) FreeSid
 0043 stub GetAce
 0044 stub GetAclInformation
 0045 stub GetFileSecurityA
 0046 stub GetFileSecurityW
 0047 stub GetKernelObjectSecurity
-0048 stub GetLengthSid
+0048 stdcall GetLengthSid(ptr) GetLengthSid
 0049 stub GetNumberOfEventLogRecords
 0050 stub GetOldestEventLogRecord
 0051 stub GetPrivateObjectSecurity
@@ -64,10 +64,10 @@
 0059 stub GetServiceDisplayNameW
 0060 stub GetServiceKeyNameA
 0061 stub GetServiceKeyNameW
-0062 stub GetSidIdentifierAuthority
-0063 stub GetSidLengthRequired
-0064 stub GetSidSubAuthority
-0065 stub GetSidSubAuthorityCount
+0062 stdcall GetSidIdentifierAuthority(ptr) GetSidIdentifierAuthority
+0063 stdcall GetSidLengthRequired(long) GetSidLengthRequired
+0064 stdcall GetSidSubAuthority(ptr long) GetSidSubAuthority
+0065 stdcall GetSidSubAuthorityCount(ptr) GetSidSubAuthorityCount
 0066 stub GetTokenInformation
 0067 stdcall GetUserNameA(ptr ptr) GetUserName32A
 0068 stdcall GetUserNameW(ptr ptr) GetUserName32W
@@ -76,13 +76,13 @@
 0071 stub ImpersonateSelf
 0072 stub InitializeAcl
 0073 return InitializeSecurityDescriptor 8 1
-0074 stub InitializeSid
+0074 stdcall InitializeSid(ptr ptr long) InitializeSid
 0075 stub InitiateSystemShutdownA
 0076 stub InitiateSystemShutdownW
 0077 stub IsTextUnicode
 0078 stub IsValidAcl
 0079 stub IsValidSecurityDescriptor
-0080 stub IsValidSid
+0080 stdcall IsValidSid(ptr) IsValidSid
 0081 stub LockServiceDatabase
 0082 stub LogonUserA
 0083 stub LogonUserW
diff --git a/if1632/builtin.c b/if1632/builtin.c
index a023ef3..3a4386c 100644
--- a/if1632/builtin.c
+++ b/if1632/builtin.c
@@ -199,21 +199,7 @@
 
     /* Initialize the real-mode selector entry points */
 
-#define SET_ENTRY_POINT(num,addr) \
-    MODULE_SetEntryPoint( hModule, (num), GLOBAL_CreateBlock( GMEM_FIXED, \
-                                  DOSMEM_dosmem+(addr), 0x10000, hModule, \
-                                  FALSE, FALSE, FALSE, NULL ))
-
-    SET_ENTRY_POINT( 174, 0xa0000 );  /* KERNEL.174: __A000H */
-    SET_ENTRY_POINT( 181, 0xb0000 );  /* KERNEL.181: __B000H */
-    SET_ENTRY_POINT( 182, 0xb8000 );  /* KERNEL.182: __B800H */
-    SET_ENTRY_POINT( 195, 0xc0000 );  /* KERNEL.195: __C000H */
-    SET_ENTRY_POINT( 179, 0xd0000 );  /* KERNEL.179: __D000H */
-    SET_ENTRY_POINT( 190, 0xe0000 );  /* KERNEL.190: __E000H */
-    SET_ENTRY_POINT( 173, 0xf0000 );  /* KERNEL.173: __ROMBIOS */
-    SET_ENTRY_POINT( 194, 0xf0000 );  /* KERNEL.194: __F000H */
-    MODULE_SetEntryPoint(hModule,193,DOSMEM_BiosSeg); /* KERNEL.193: __0040H */
-#undef SET_ENTRY_POINT
+    DOSMEM_InitExports( hModule );
 
     /* Set interrupt vectors from entry points in WPROCS.DLL */
 
diff --git a/if1632/crtdll.spec b/if1632/crtdll.spec
index a1279f9..be34155 100644
--- a/if1632/crtdll.spec
+++ b/if1632/crtdll.spec
@@ -323,12 +323,12 @@
 318 stub _vsnprintf
 319 stub _vsnwprintf
 320 stub _wcsdup
-321 stub _wcsicmp
+321 cdecl _wcsicmp(ptr ptr) lstrcmpi32W
 322 cdecl _wcsicoll(ptr ptr) CRTDLL__wcsicoll
 323 cdecl _wcslwr(ptr) CRTDLL__wcslwr
 324 stub _wcsnicmp
 325 stub _wcsnset
-326 stub _wcsrev
+326 cdecl _wcsrev(ptr) CRTDLL__wcsrev
 327 stub _wcsset
 328 cdecl _wcsupr(ptr) CRTDLL__wcsupr
 329 extern _winmajor_dll CRTDLL_winmajor_dll
diff --git a/if1632/gdi.spec b/if1632/gdi.spec
index ca8d1f1..af8dc31 100644
--- a/if1632/gdi.spec
+++ b/if1632/gdi.spec
@@ -86,7 +86,7 @@
 77  pascal16 GetClipBox(word ptr) GetClipBox16
 78  pascal   GetCurrentPosition(word) GetCurrentPosition
 79  pascal   GetDCOrg(word) GetDCOrg
-80  pascal16 GetDeviceCaps(word s_word) GetDeviceCaps
+80  pascal16 GetDeviceCaps(word s_word) GetDeviceCaps16
 81  pascal16 GetMapMode(word) GetMapMode16
 82  pascal16 GetObject(word s_word ptr) GetObject16
 83  pascal   GetPixel(word s_word s_word) GetPixel16
@@ -118,8 +118,8 @@
 119 pascal16 AddFontResource(ptr) AddFontResource
 #121 pascal Death
 #122 pascal ReSurRection
-123 pascal16 PlayMetaFile(word word) PlayMetaFile
-124 pascal16 GetMetaFile(ptr) GetMetaFile
+123 pascal16 PlayMetaFile(word word) PlayMetaFile16
+124 pascal16 GetMetaFile(ptr) GetMetaFile16
 125 pascal16 CreateMetaFile(ptr) CreateMetaFile16
 126 pascal16 CloseMetaFile(word) CloseMetaFile16
 127 pascal16 DeleteMetaFile(word) DeleteMetaFile16
@@ -135,9 +135,9 @@
 148 pascal SetBrushOrg(word s_word s_word) SetBrushOrg
 149 pascal GetBrushOrg(word) GetBrushOrg
 150 pascal16 UnrealizeObject(word) UnrealizeObject16
-151 pascal16 CopyMetaFile(word ptr) CopyMetaFile
+151 pascal16 CopyMetaFile(word ptr) CopyMetaFile16
 153 pascal16 CreateIC(ptr ptr ptr ptr) CreateIC16
-154 pascal GetNearestColor(word long) GetNearestColor
+154 pascal   GetNearestColor(word long) GetNearestColor16
 155 stub QueryAbort
 156 pascal16 CreateDiscardableBitmap(word word word) CreateDiscardableBitmap
 158 pascal16 EnumCallback(ptr ptr word long) WineEnumDFontCallback
@@ -233,28 +233,27 @@
 346 pascal16 SetTextAlign(word word) SetTextAlign16
 348 pascal16 Chord(word s_word s_word s_word s_word s_word s_word
                    s_word s_word) Chord16
-349 pascal SetMapperFlags(word long) SetMapperFlags
+349 pascal SetMapperFlags(word long) SetMapperFlags16
 350 pascal16 GetCharWidth(word word word ptr) GetCharWidth16
 351 pascal16 ExtTextOut(word s_word s_word word ptr ptr word ptr) ExtTextOut16
 352 stub GetPhysicalFontHandle
 353 stub GetAspectRatioFilter
 354 stub ShrinkGDIHeap
 355 stub FTrapping0
-360 pascal16 CreatePalette(ptr) CreatePalette
+360 pascal16 CreatePalette(ptr) CreatePalette16
 361 pascal16 GDISelectPalette(word word word) GDISelectPalette
 362 pascal16 GDIRealizePalette(word) GDIRealizePalette
-363 pascal16 GetPaletteEntries(word word word ptr) GetPaletteEntries
-364 pascal16 SetPaletteEntries(word word word ptr) SetPaletteEntries
+363 pascal16 GetPaletteEntries(word word word ptr) GetPaletteEntries16
+364 pascal16 SetPaletteEntries(word word word ptr) SetPaletteEntries16
 365 pascal16 RealizeDefaultPalette(word) RealizeDefaultPalette
 366 pascal16 UpdateColors(word) UpdateColors
-367 pascal16 AnimatePalette(word word word ptr) AnimatePalette
-368 pascal16 ResizePalette(word word) ResizePalette
-370 pascal16 GetNearestPaletteIndex(word long) GetNearestPaletteIndex
+367 pascal16 AnimatePalette(word word word ptr) AnimatePalette16
+368 pascal16 ResizePalette(word word) ResizePalette16
+370 pascal16 GetNearestPaletteIndex(word long) GetNearestPaletteIndex16
 372 pascal16 ExtFloodFill(word s_word s_word long word) ExtFloodFill16
-373 pascal16 SetSystemPaletteUse(word word) SetSystemPaletteUse
-374 pascal16 GetSystemPaletteUse(word) GetSystemPaletteUse
-375 pascal16 GetSystemPaletteEntries(word word word ptr)
-             GetSystemPaletteEntries
+373 pascal16 SetSystemPaletteUse(word word) SetSystemPaletteUse16
+374 pascal16 GetSystemPaletteUse(word) GetSystemPaletteUse16
+375 pascal16 GetSystemPaletteEntries(word word word ptr) GetSystemPaletteEntries16
 376 pascal16 ResetDC(word ptr) ResetDC16
 377 stub STARTDOC
 378 stub ENDDOC
diff --git a/if1632/gdi32.spec b/if1632/gdi32.spec
index a7033df..dd65603 100644
--- a/if1632/gdi32.spec
+++ b/if1632/gdi32.spec
@@ -8,7 +8,7 @@
 0003 stub AddFontResourceTracking
 0004 stub AddFontResourceW
 0005 stub AngleArc
-0006 stub AnimatePalette
+0006 stdcall AnimatePalette(long long long ptr) AnimatePalette32
 0007 stdcall Arc(long long long long long long long long long) Arc32
 0008 stub ArcTo
 0009 stub BeginPath
@@ -25,8 +25,8 @@
 0020 stub CombineTransform
 0021 stub CopyEnhMetaFileA
 0022 stub CopyEnhMetaFileW
-0023 stub CopyMetaFileA
-0024 stub CopyMetaFileW
+0023 stdcall CopyMetaFileA(long ptr) CopyMetaFile32A
+0024 stdcall CopyMetaFileW(long ptr) CopyMetaFile32W
 0025 stdcall CreateBitmap(long long long long ptr) CreateBitmap
 0026 stdcall CreateBitmapIndirect(ptr) CreateBitmapIndirect32
 0027 stdcall CreateBrushIndirect(ptr) CreateBrushIndirect32
@@ -57,7 +57,7 @@
 0050 stdcall CreateICW(ptr ptr ptr ptr) CreateIC32W
 0051 stub CreateMetaFileA
 0052 stub CreateMetaFileW
-0053 stdcall CreatePalette(ptr) CreatePalette
+0053 stdcall CreatePalette(ptr) CreatePalette32
 0054 stdcall CreatePatternBrush(long) CreatePatternBrush32
 0055 stdcall CreatePen(long long long) CreatePen32
 0056 stdcall CreatePenIndirect(ptr) CreatePenIndirect32
@@ -176,7 +176,7 @@
 0168 stdcall GetDCOrgEx(long ptr) GetDCOrgEx
 0169 stub GetDIBColorTable
 0170 stdcall GetDIBits(long long long long ptr ptr long) GetDIBits32
-0171 stdcall GetDeviceCaps(long long) GetDeviceCaps
+0171 stdcall GetDeviceCaps(long long) GetDeviceCaps32
 0172 stub GetDeviceGammaRamp
 0173 stub GetETM
 0174 stub GetEnhMetaFileA
@@ -202,19 +202,19 @@
 0194 stub GetLogColorSpaceA
 0195 stub GetLogColorSpaceW
 0196 stdcall GetMapMode(long) GetMapMode32
-0197 stub GetMetaFileA
+0197 stdcall GetMetaFileA(ptr) GetMetaFile32A
 0198 stub GetMetaFileBitsEx
-0199 stub GetMetaFileW
+0199 stdcall GetMetaFileW(ptr) GetMetaFile32W
 0200 stub GetMetaRgn
 0201 stub GetMiterLimit
-0202 stdcall GetNearestColor(long long) GetNearestColor
-0203 stub GetNearestPaletteIndex
+0202 stdcall GetNearestColor(long long) GetNearestColor32
+0203 stdcall GetNearestPaletteIndex(long long) GetNearestPaletteIndex32
 0204 stdcall GetObjectA(long long ptr) GetObject32A
 0205 stub GetObjectType
 0206 stdcall GetObjectW(long long ptr) GetObject32W
 0207 stub GetOutlineTextMetricsA
 0208 stub GetOutlineTextMetricsW
-0209 stdcall GetPaletteEntries(long long long ptr) GetPaletteEntries
+0209 stdcall GetPaletteEntries(long long long ptr) GetPaletteEntries32
 0210 stub GetPath
 0211 stdcall GetPixel(long long long) GetPixel32
 0212 stub GetPixelFormat
@@ -227,8 +227,8 @@
 0219 stdcall GetRgnBox(long ptr) GetRgnBox32
 0220 stdcall GetStockObject(long) GetStockObject32
 0221 stdcall GetStretchBltMode(long) GetStretchBltMode32
-0222 stdcall GetSystemPaletteEntries(long long long ptr) GetSystemPaletteEntries
-0223 stub GetSystemPaletteUse
+0222 stdcall GetSystemPaletteEntries(long long long ptr) GetSystemPaletteEntries32
+0223 stdcall GetSystemPaletteUse() GetSystemPaletteUse32
 0224 stdcall GetTextAlign(long) GetTextAlign32
 0225 stdcall GetTextCharacterExtra(long) GetTextCharacterExtra32
 0226 stub GetTextCharset
@@ -270,7 +270,7 @@
 0262 stdcall Pie(long long long long long long long long long) Pie32
 0263 stub PlayEnhMetaFile
 0264 stub PlayEnhMetaFileRecord
-0265 stub PlayMetaFile
+0265 stdcall PlayMetaFile(long long) PlayMetaFile32
 0266 stub PlayMetaFileRecord
 0267 stub PlgBlt
 0268 stub PolyBezier
@@ -285,7 +285,7 @@
 0277 stub PolylineTo
 0278 stdcall PtInRegion(long long long) PtInRegion32
 0279 stdcall PtVisible(long long long) PtVisible32
-0280 stdcall RealizePalette(long) RealizePalette
+0280 stdcall RealizePalette(long) RealizePalette32
 0281 stdcall RectInRegion(long ptr) RectInRegion32
 0282 stdcall RectVisible(long ptr) RectVisible32
 0283 stdcall Rectangle(long long long long long) Rectangle32
@@ -294,7 +294,7 @@
 0286 stub RemoveFontResourceW
 0287 stdcall ResetDCA(long ptr) ResetDC32A
 0288 stdcall ResetDCW(long ptr) ResetDC32W
-0289 stdcall ResizePalette(long long) ResizePalette
+0289 stdcall ResizePalette(long long) ResizePalette32
 0290 stdcall RestoreDC(long long) RestoreDC32
 0291 stdcall RoundRect(long long long long long long long) RoundRect32
 0292 stdcall SaveDC(long) SaveDC32
@@ -305,7 +305,7 @@
 0297 stdcall SelectClipRgn(long long) SelectClipRgn32
 0298 stub SelectFontLocal
 0299 stdcall SelectObject(long long) SelectObject32
-0300 stdcall SelectPalette(long long long) SelectPalette
+0300 stdcall SelectPalette(long long long) SelectPalette32
 0301 stub SetAbortProc
 0302 stub SetArcDirection
 0303 stdcall SetBitmapBits(long long ptr) SetBitmapBits
@@ -328,11 +328,11 @@
 0319 stub SetICMProfileA
 0320 stub SetICMProfileW
 0321 stdcall SetMapMode(long long) SetMapMode32
-0322 stdcall SetMapperFlags(long long) SetMapperFlags
+0322 stdcall SetMapperFlags(long long) SetMapperFlags32
 0323 stub SetMetaFileBitsEx
 0324 stub SetMetaRgn
 0325 stub SetMiterLimit
-0326 stdcall SetPaletteEntries(long long long ptr) SetPaletteEntries
+0326 stdcall SetPaletteEntries(long long long ptr) SetPaletteEntries32
 0327 stdcall SetPixel(long long long long) SetPixel32
 0328 stub SetPixelFormat
 0329 stub SetPixelV
@@ -341,7 +341,7 @@
 0332 stdcall SetRectRgn(long long long long long) SetRectRgn
 0333 stdcall SetRelAbs(long long) SetRelAbs32
 0334 stdcall SetStretchBltMode(long long) SetStretchBltMode32
-0335 stdcall SetSystemPaletteUse(long long) SetSystemPaletteUse
+0335 stdcall SetSystemPaletteUse(long long) SetSystemPaletteUse32
 0336 stdcall SetTextAlign(long long) SetTextAlign32
 0337 stdcall SetTextCharacterExtra(long long) SetTextCharacterExtra32
 0338 stdcall SetTextColor(long long) SetTextColor
diff --git a/if1632/kernel.spec b/if1632/kernel.spec
index d934dad..75faa9b 100644
--- a/if1632/kernel.spec
+++ b/if1632/kernel.spec
@@ -64,11 +64,11 @@
 65  pascal SizeofResource(word word) SizeofResource16
 66  pascal16 AllocResource(word word long) AllocResource16
 67  pascal SetResourceHandler(word ptr ptr) SetResourceHandler
-68  pascal16 InitAtomTable(word) InitAtomTable
-69  pascal16 FindAtom(segptr) FindAtom
-70  pascal16 AddAtom(segptr) AddAtom
-71  pascal16 DeleteAtom(word) DeleteAtom
-72  pascal16 GetAtomName(word ptr word) GetAtomName
+68  pascal16 InitAtomTable(word) InitAtomTable16
+69  pascal16 FindAtom(segptr) FindAtom16
+70  pascal16 AddAtom(segptr) AddAtom16
+71  pascal16 DeleteAtom(word) DeleteAtom16
+72  pascal16 GetAtomName(word ptr word) GetAtomName16
 73  pascal16 GetAtomHandle(word) GetAtomHandle
 74  pascal16 OpenFile(ptr ptr word) OpenFile16
 75  stub OpenPathName
@@ -107,8 +107,8 @@
 108 pascal16 SwitchStackTo(word word word) SwitchStackTo
 109 register SwitchStackBack() SwitchStackBack
 110 pascal16 PatchCodeHandle(word) PatchCodeHandle
-111 pascal GlobalWire(word) GlobalWire
-112 pascal16 GlobalUnWire(word) GlobalUnWire
+111 pascal   GlobalWire(word) GlobalWire16
+112 pascal16 GlobalUnWire(word) GlobalUnWire16
 113 equate __AHSHIFT 3
 114 equate __AHINCR 8
 115 pascal16 OutputDebugString(ptr) OutputDebugString
@@ -166,7 +166,7 @@
 166 pascal16 WinExec(ptr word) WinExec16
 167 pascal16 GetExpWinVer(word) GetExpWinVer
 168 pascal16 DirectResAlloc(word word word) DirectResAlloc
-169 pascal GetFreeSpace(word) GetFreeSpace
+169 pascal GetFreeSpace(word) GetFreeSpace16
 170 pascal16 AllocCStoDSAlias(word) AllocCStoDSAlias
 171 pascal16 AllocDStoCSAlias(word) AllocDStoCSAlias
 172 pascal16 AllocAlias(word) AllocCStoDSAlias
@@ -194,8 +194,8 @@
 194 equate __F000H 0
 195 equate __C000H 0
 196 pascal16 SelectorAccessRights(word word word) SelectorAccessRights
-197 pascal16 GlobalFix(word) GlobalFix
-198 pascal16 GlobalUnfix(word) GlobalUnfix
+197 pascal16 GlobalFix(word) GlobalFix16
+198 pascal16 GlobalUnfix(word) GlobalUnfix16
 199 pascal16 SetHandleCount(word) SetHandleCount16
 200 return ValidateFreeSpaces 0 0
 201 stub ReplaceInst
diff --git a/if1632/kernel32.spec b/if1632/kernel32.spec
index fa859e4..2c51b8f 100644
--- a/if1632/kernel32.spec
+++ b/if1632/kernel32.spec
@@ -2,8 +2,8 @@
 type	win32
 base	1
 
-0000 stub AddAtomA
-0001 stub AddAtomW
+0000 stdcall AddAtomA(ptr) AddAtom32A
+0001 stdcall AddAtomW(ptr) AddAtom32W
 0002 stub AddConsoleAliasA
 0003 stub AddConsoleAliasW
 0004 stub AllocConsole
@@ -71,7 +71,7 @@
 0066 stub DebugBreak
 0067 stub DefineDosDeviceA
 0068 stub DefineDosDeviceW
-0069 stub DeleteAtom
+0069 stdcall DeleteAtom(long) DeleteAtom32
 0070 stdcall DeleteCriticalSection(ptr)	DeleteCriticalSection
 0071 stdcall DeleteFileA(ptr) DeleteFile32A
 0072 stdcall DeleteFileW(ptr) DeleteFile32W
@@ -105,8 +105,8 @@
 0100 stdcall ExitProcess(long) ExitProcess
 0101 stub ExitThread
 0102 stub ExitVDM
-0103 stub ExpandEnvironmentStringsA
-0104 stub ExpandEnvironmentStringsW
+0103 stdcall ExpandEnvironmentStringsA(ptr ptr long) ExpandEnvironmentStrings32A
+0104 stdcall ExpandEnvironmentStringsW(ptr ptr long) ExpandEnvironmentStrings32W
 0105 stub ExpungeConsoleCommandHistoryA
 0106 stub ExpungeConsoleCommandHistoryW
 0107 stub ExtendVirtualBuffer
@@ -119,8 +119,8 @@
 0114 stub FillConsoleOutputAttribute
 0115 stub FillConsoleOutputCharacterA
 0116 stub FillConsoleOutputCharacterW
-0117 stub FindAtomA
-0118 stub FindAtomW
+0117 stdcall FindAtomA(ptr) FindAtom32A
+0118 stdcall FindAtomW(ptr) FindAtom32W
 0119 stdcall FindClose(long) FindClose32
 0120 stub FindCloseChangeNotification
 0121 stub FindFirstChangeNotificationA
@@ -151,8 +151,8 @@
 0146 stub FreeVirtualBuffer
 0147 stub GenerateConsoleCtrlEvent
 0148    stdcall GetACP() GetACP
-0149 stub GetAtomNameA
-0150 stub GetAtomNameW
+0149 stdcall GetAtomNameA(long ptr long) GetAtomName32A
+0150 stdcall GetAtomNameW(long ptr long) GetAtomName32W
 0151 stub GetBinaryType
 0152 stub GetBinaryTypeA
 0153 stub GetBinaryTypeW
@@ -322,7 +322,7 @@
 0317 stdcall GlobalDeleteAtom(long) GlobalDeleteAtom
 0318 stdcall GlobalFindAtomA(ptr) GlobalFindAtom32A
 0319 stdcall GlobalFindAtomW(ptr) GlobalFindAtom32W
-0320 stub GlobalFix
+0320 stdcall GlobalFix(long) GlobalFix32
 0321 stdcall GlobalFlags(long) GlobalFlags32
 0322 stdcall GlobalFree(long) GlobalFree32
 0323 stdcall GlobalGetAtomNameA(long ptr long) GlobalGetAtomName32A
@@ -332,10 +332,10 @@
 0327 stdcall GlobalMemoryStatus(ptr) GlobalMemoryStatus
 0328 stdcall GlobalReAlloc(long long long) GlobalReAlloc32
 0329 stdcall GlobalSize(long) GlobalSize32
-0330 stub GlobalUnWire
-0331 stub GlobalUnfix
+0330 stdcall GlobalUnWire(long) GlobalUnWire32
+0331 stdcall GlobalUnfix(long) GlobalUnfix32
 0332 stdcall GlobalUnlock(long) GlobalUnlock32
-0333 stub GlobalWire
+0333 stdcall GlobalWire(long) GlobalWire32
 0334 stdcall HeapAlloc(long long long) HeapAlloc
 0335 stdcall HeapCompact(long long) HeapCompact
 0336 stdcall HeapCreate(long long long)	HeapCreate
@@ -554,7 +554,7 @@
 0549 stub VirtualBufferExceptionHandler
 0550    stdcall VirtualFree(ptr long long) VirtualFree
 0551 stub VirtualLock
-0552 stub VirtualProtect
+0552 stdcall VirtualProtect(ptr long long ptr) VirtualProtect
 0553 stub VirtualProtectEx
 0554 stdcall VirtualQuery(ptr ptr long) VirtualQuery
 0555 stub VirtualQueryEx
@@ -656,3 +656,6 @@
 0650 stub Process32Next
 0651 stub Thread32First
 0652 stub Thread32Next
+0653 stub RegisterServiceProcess
+0654 stub QueueUserAPC
+0655 stub ConvertToGlobalHandle
diff --git a/if1632/keyboard.spec b/if1632/keyboard.spec
index e23d3cc..5d0cb91 100644
--- a/if1632/keyboard.spec
+++ b/if1632/keyboard.spec
@@ -15,7 +15,7 @@
 129 pascal16 VkKeyScan(byte) VkKeyScan16
 130 pascal16 GetKeyboardType(byte) GetKeyboardType16
 131 pascal16 MapVirtualKey(word word) MapVirtualKey16
-132 pascal16 GetKbCodePage() GetKbCodePage
+132 pascal16 GetKBCodePage() GetKBCodePage16
 133 pascal16 GetKeyNameText(long ptr word) GetKeyNameText16
 134 pascal16 AnsiToOemBuff(ptr ptr word) AnsiToOemBuff16
 135 pascal16 OemToAnsiBuff(ptr ptr word) OemToAnsiBuff16
diff --git a/if1632/mpr.spec b/if1632/mpr.spec
index f040dca..15a75a0 100644
--- a/if1632/mpr.spec
+++ b/if1632/mpr.spec
@@ -81,3 +81,5 @@
 0100 stub WNetUseConnectionW
 0101 stub WNetVerifyPasswordA
 0102 stub WNetVerifyPasswordW 
+#additions
+0103 stub WNetRestoreConnection
diff --git a/if1632/ntdll.spec b/if1632/ntdll.spec
index 45261b4..2208e91 100644
--- a/if1632/ntdll.spec
+++ b/if1632/ntdll.spec
@@ -128,7 +128,7 @@
 124 stub NtOpenDirectoryObject
 125 stub NtOpenEvent
 126 stub NtOpenEventPair
-127 stub NtOpenFile
+127 stdcall NtOpenFile(ptr long ptr ptr long long) NtOpenFile
 128 stub NtOpenIoCompletion
 129 stub NtOpenKey
 130 stub NtOpenMutant
@@ -261,7 +261,7 @@
 257 stub RtlAcquireResourceShared
 258 stub RtlAddAccessAllowedAce
 259 stub RtlAddAccessDeniedAce
-260 stub RtlAddAce
+260 stdcall RtlAddAce(ptr long long ptr long) RtlAddAce
 261 stub RtlAddActionToRXact
 262 stub RtlAddAttributeActionToRXact
 263 stub RtlAddAuditAccessAce
@@ -307,14 +307,14 @@
 303 stub RtlCopySidAndAttributesArray
 304 stub RtlCopyString
 305 stub RtlCopyUnicodeString
-306 stub RtlCreateAcl
+306 stdcall RtlCreateAcl(ptr long long) RtlCreateAcl
 307 stub RtlCreateAndSetSD
 308 stub RtlCreateEnvironment
 309 stdcall RtlCreateHeap(long long long) HeapCreate
 310 stub RtlCreateProcessParameters
 311 stub RtlCreateQueryDebugBuffer
 312 stub RtlCreateRegistryKey
-313 stub RtlCreateSecurityDescriptor
+313 stdcall RtlCreateSecurityDescriptor(ptr long) RtlCreateSecurityDescriptor
 314 stub RtlCreateTagHeap
 315 stub RtlCreateUnicodeString
 316 stub RtlCreateUnicodeStringFromAsciiz
@@ -339,7 +339,7 @@
 335 stub RtlDestroyQueryDebugBuffer
 336 stub RtlDetermineDosPathNameType_U
 337 stub RtlDoesFileExists_U
-338 stub RtlDosPathNameToNtPathName_U
+338 stdcall RtlDosPathNameToNtPathName_U(ptr ptr long long) RtlDosPathNameToNtPathName_U
 339 stub RtlDosSearchPath_U
 340 stub RtlDumpResource
 341 stub RtlEnlargedIntegerMultiply
@@ -371,7 +371,7 @@
 367 stub RtlFindMessage
 368 stub RtlFindSetBits
 369 stub RtlFindSetBitsAndClear
-370 stub RtlFirstFreeAce
+370 stdcall RtlFirstFreeAce(ptr ptr) RtlFirstFreeAce
 371 stub RtlFormatCurrentUserKeyPath
 372 stub RtlFormatMessage
 373 stub RtlFreeAnsiString
@@ -400,7 +400,7 @@
 396 stub RtlImageDirectoryEntryToData
 397 stub RtlImageNtHeader
 398 stub RtlImpersonateSelf
-399 stub RtlInitAnsiString
+399 stdcall RtlInitAnsiString(ptr ptr) RtlInitAnsiString
 400 stub RtlInitCodePageTable
 401 stub RtlInitNlsTables
 402 stdcall RtlInitString(ptr ptr) RtlInitString
@@ -430,14 +430,14 @@
 426 stdcall RtlLeaveCriticalSection(ptr) LeaveCriticalSection
 427 stdcall RtlLengthRequiredSid(long) RtlLengthRequiredSid
 428 stub RtlLengthSecurityDescriptor
-429 stub RtlLengthSid
+429 stdcall RtlLengthSid(ptr) RtlLengthSid
 430 stub RtlLocalTimeToSystemTime
 431 stub RtlLockHeap
 432 stub RtlLookupElementGenericTable
 433 stub RtlMakeSelfRelativeSD
 434 stub RtlMapGenericMask
 435 stdcall RtlMoveMemory(ptr ptr long) RtlMoveMemory
-436 stub RtlMultiByteToUnicodeN
+436 stdcall RtlMultiByteToUnicodeN(ptr long ptr ptr long) RtlMultiByteToUnicodeN
 437 stub RtlMultiByteToUnicodeSize
 438 stub RtlNewInstanceSecurityObject
 439 stub RtlNewSecurityGrantedAccess
@@ -484,12 +484,12 @@
 480 stub RtlSetBits
 481 stub RtlSetCurrentDirectory_U
 482 stub RtlSetCurrentEnvironment
-483 stub RtlSetDaclSecurityDescriptor
+483 stdcall RtlSetDaclSecurityDescriptor(ptr long ptr long) RtlSetDaclSecurityDescriptor
 484 stub RtlSetEnvironmentVariable
-485 stub RtlSetGroupSecurityDescriptor
+485 stdcall RtlSetGroupSecurityDescriptor(ptr ptr long) RtlSetGroupSecurityDescriptor
 486 stub RtlSetInformationAcl
-487 stub RtlSetOwnerSecurityDescriptor
-488 stub RtlSetSaclSecurityDescriptor
+487 stdcall RtlSetOwnerSecurityDescriptor(ptr ptr long) RtlSetOwnerSecurityDescriptor
+488 stdcall RtlSetSaclSecurityDescriptor(ptr long ptr long) RtlSetSaclSecurityDescriptor
 489 stub RtlSetSecurityObject
 490 stub RtlSetTimeZoneInformation
 491 stub RtlSetUserFlagsHeap
diff --git a/if1632/sound.spec b/if1632/sound.spec
index a0ab624..8a8e0bf 100644
--- a/if1632/sound.spec
+++ b/if1632/sound.spec
@@ -1,20 +1,20 @@
 name	sound
 type	win16
 
-1  pascal16 OpenSound() OpenSound
+1  pascal16 OpenSound() OpenSound16
 2  pascal16 CloseSound() CloseSound
-3  pascal16 SetVoiceQueueSize(word word) SetVoiceQueueSize
-4  pascal16 SetVoiceNote(word word word word) SetVoiceNote
-5  pascal16 SetVoiceAccent(word word word word word) SetVoiceAccent
-6  pascal16 SetVoiceEnvelope(word word word) SetVoiceEnvelope
-7  pascal16 SetSoundNoise(word word) SetSoundNoise
-8  pascal16 SetVoiceSound(word long word) SetVoiceSound
-9  pascal16 StartSound() StartSound
-10 pascal16 StopSound() StopSound
-11 pascal16 WaitSoundState(word) WaitSoundState
-12 pascal16 SyncAllVoices() SyncAllVoices
-13 pascal16 CountVoiceNotes(word) CountVoiceNotes
-14 pascal   GetThresholdEvent() GetThresholdEvent
-15 pascal16 GetThresholdStatus() GetThresholdStatus
-16 pascal16 SetVoiceThreshold(word word) SetVoiceThreshold
+3  pascal16 SetVoiceQueueSize(word word) SetVoiceQueueSize16
+4  pascal16 SetVoiceNote(word word word word) SetVoiceNote16
+5  pascal16 SetVoiceAccent(word word word word word) SetVoiceAccent16
+6  pascal16 SetVoiceEnvelope(word word word) SetVoiceEnvelope16
+7  pascal16 SetSoundNoise(word word) SetSoundNoise16
+8  pascal16 SetVoiceSound(word long word) SetVoiceSound16
+9  pascal16 StartSound() StartSound16
+10 pascal16 StopSound() StopSound16
+11 pascal16 WaitSoundState(word) WaitSoundState16
+12 pascal16 SyncAllVoices() SyncAllVoices16
+13 pascal16 CountVoiceNotes(word) CountVoiceNotes16
+14 pascal   GetThresholdEvent() GetThresholdEvent16
+15 pascal16 GetThresholdStatus() GetThresholdStatus16
+16 pascal16 SetVoiceThreshold(word word) SetVoiceThreshold16
 17 pascal16 DoBeep() DoBeep
diff --git a/if1632/thunk.c b/if1632/thunk.c
index 03299d7..1d33e67 100644
--- a/if1632/thunk.c
+++ b/if1632/thunk.c
@@ -418,19 +418,21 @@
 /***********************************************************************
  *           THUNK_EnumResourceNames32A   (KERNEL32.88)
  */
-BOOL32 THUNK_EnumResourceNames32A( HMODULE32 hmod,LPCWSTR type,ENUMRESNAMEPROC32A func, LONG lParam )
+BOOL32 THUNK_EnumResourceNames32A( HMODULE32 hmod, LPCSTR type,
+                                   ENUMRESNAMEPROC32A func, LONG lParam )
 {
     DECL_THUNK( thunk, func, CallTo32_4 );
-    return EnumResourceNames32A( hmod,type,(ENUMRESNAMEPROC32A)&thunk, lParam );
+    return EnumResourceNames32A( hmod,type,(ENUMRESNAMEPROC32A)&thunk,lParam );
 }
 
 /***********************************************************************
  *           THUNK_EnumResourceNames32W   (KERNEL32.89)
  */
-BOOL32 THUNK_EnumResourceNames32W( HMODULE32 hmod,LPCWSTR type,ENUMRESNAMEPROC32W func, LONG lParam )
+BOOL32 THUNK_EnumResourceNames32W( HMODULE32 hmod, LPCWSTR type,
+                                   ENUMRESNAMEPROC32W func, LONG lParam )
 {
     DECL_THUNK( thunk, func, CallTo32_4 );
-    return EnumResourceNames32W( hmod,type,(ENUMRESNAMEPROC32W)&thunk, lParam );
+    return EnumResourceNames32W( hmod,type,(ENUMRESNAMEPROC32W)&thunk, lParam);
 }
 
 /***********************************************************************
@@ -461,10 +463,42 @@
 {
     DECL_THUNK( thunk, func, CallTo16_word_wlw );
     if (!func)
-        return GrayString( hdc, hbr, NULL, lParam, cch, x, y, cx, cy );
+        return GrayString16( hdc, hbr, NULL, lParam, cch, x, y, cx, cy );
     else
-        return GrayString( hdc, hbr, (GRAYSTRINGPROC16)&thunk, lParam, cch,
-                           x, y, cx, cy );
+        return GrayString16( hdc, hbr, (GRAYSTRINGPROC16)&thunk, lParam, cch,
+                             x, y, cx, cy );
+}
+
+
+/***********************************************************************
+ *           THUNK_GrayString32A   (USER32.314)
+ */
+BOOL32 THUNK_GrayString32A( HDC32 hdc, HBRUSH32 hbr, GRAYSTRINGPROC32 func,
+                            LPARAM lParam, INT32 cch, INT32 x, INT32 y,
+                            INT32 cx, INT32 cy )
+{
+    DECL_THUNK( thunk, func, CallTo32_3 );
+    if (!func)
+        return GrayString32A( hdc, hbr, NULL, lParam, cch, x, y, cx, cy );
+    else
+        return GrayString32A( hdc, hbr, (GRAYSTRINGPROC32)&thunk, lParam, cch,
+                              x, y, cx, cy );
+}
+
+
+/***********************************************************************
+ *           THUNK_GrayString32W   (USER32.315)
+ */
+BOOL32 THUNK_GrayString32W( HDC32 hdc, HBRUSH32 hbr, GRAYSTRINGPROC32 func,
+                            LPARAM lParam, INT32 cch, INT32 x, INT32 y,
+                            INT32 cx, INT32 cy )
+{
+    DECL_THUNK( thunk, func, CallTo32_3 );
+    if (!func)
+        return GrayString32W( hdc, hbr, NULL, lParam, cch, x, y, cx, cy );
+    else
+        return GrayString32W( hdc, hbr, (GRAYSTRINGPROC32)&thunk, lParam, cch,
+                              x, y, cx, cy );
 }
 
 
diff --git a/if1632/user.spec b/if1632/user.spec
index 9493ead..1bff1ca 100644
--- a/if1632/user.spec
+++ b/if1632/user.spec
@@ -7,20 +7,20 @@
 3   stub EnableOEMLayer
 4   stub DisableOEMLayer
 5   pascal16 InitApp(word) InitApp
-6   pascal16 PostQuitMessage(word) PostQuitMessage
+6   pascal16 PostQuitMessage(word) PostQuitMessage16
 7   pascal16 ExitWindows(long word) ExitWindows16
 10  pascal16 SetTimer(word word word segptr) SetTimer16
 11  pascal16 SetSystemTimer(word word word segptr) SetSystemTimer16
 12  pascal16 KillTimer(word word) KillTimer16
 13  pascal   GetTickCount() GetTickCount
 14  pascal   GetTimerResolution() GetTimerResolution
-15  pascal   GetCurrentTime() GetCurrentTime
+15  pascal   GetCurrentTime() GetCurrentTime16
 16  pascal16 ClipCursor(ptr) ClipCursor16
 17  pascal16 GetCursorPos(ptr) GetCursorPos16
 18  pascal16 SetCapture(word) SetCapture16
 19  pascal16 ReleaseCapture() ReleaseCapture
-20  pascal16 SetDoubleClickTime(word) SetDoubleClickTime
-21  pascal16 GetDoubleClickTime() GetDoubleClickTime
+20  pascal16 SetDoubleClickTime(word) SetDoubleClickTime16
+21  pascal16 GetDoubleClickTime() GetDoubleClickTime16
 22  pascal16 SetFocus(word) SetFocus16
 23  pascal16 GetFocus() GetFocus16
 24  pascal16 RemoveProp(word ptr) RemoveProp16
@@ -43,8 +43,8 @@
 41  pascal16 CreateWindow(ptr ptr long s_word s_word s_word s_word
 	                  word word word segptr) CreateWindow16
 42  pascal16 ShowWindow(word word) ShowWindow16
-43  pascal16 CloseWindow(word) CloseWindow
-44  pascal16 OpenIcon(word) OpenIcon
+43  pascal16 CloseWindow(word) CloseWindow16
+44  pascal16 OpenIcon(word) OpenIcon16
 45  pascal16 BringWindowToTop(word) BringWindowToTop16
 46  pascal16 GetParent(word) GetParent16
 47  pascal16 IsWindow(word) IsWindow
@@ -52,7 +52,7 @@
 49  pascal16 IsWindowVisible(word) IsWindowVisible16
 50  pascal16 FindWindow(segptr ptr) FindWindow16
 #51 BEAR51
-52  pascal16 AnyPopup() AnyPopup
+52  pascal16 AnyPopup() AnyPopup16
 53  pascal16 DestroyWindow(word) DestroyWindow16
 54  pascal16 EnumWindows(segptr long) THUNK_EnumWindows16
 55  pascal16 EnumChildWindows(word segptr long) THUNK_EnumChildWindows16
@@ -69,9 +69,9 @@
 66  pascal16 GetDC(word) GetDC16
 67  pascal16 GetWindowDC(word) GetWindowDC16
 68  pascal16 ReleaseDC(word word) ReleaseDC16
-69  pascal16 SetCursor(word) SetCursor
-70  pascal16 SetCursorPos(word word) SetCursorPos
-71  pascal16 ShowCursor(word) ShowCursor
+69  pascal16 SetCursor(word) SetCursor16
+70  pascal16 SetCursorPos(word word) SetCursorPos16
+71  pascal16 ShowCursor(word) ShowCursor16
 72  pascal16 SetRect(ptr s_word s_word s_word s_word) SetRect16
 73  pascal16 SetRectEmpty(ptr) SetRectEmpty16
 74  pascal16 CopyRect(ptr ptr) CopyRect16
@@ -84,12 +84,12 @@
 81  pascal16 FillRect(word ptr word) FillRect16
 82  pascal16 InvertRect(word ptr) InvertRect16
 83  pascal16 FrameRect(word ptr word) FrameRect16
-84  pascal16 DrawIcon(word s_word s_word word) DrawIcon
+84  pascal16 DrawIcon(word s_word s_word word) DrawIcon16
 85  pascal16 DrawText(word ptr s_word ptr word) DrawText16
 87  pascal16 DialogBox(word segptr word segptr) DialogBox16
-88  pascal16 EndDialog(word s_word) EndDialog
+88  pascal16 EndDialog(word s_word) EndDialog16
 89  pascal16 CreateDialog(word segptr word segptr) CreateDialog16
-90  pascal16 IsDialogMessage(word ptr) IsDialogMessage
+90  pascal16 IsDialogMessage(word ptr) IsDialogMessage16
 91  pascal16 GetDlgItem(word word) GetDlgItem16
 92  pascal16 SetDlgItemText(word word segptr) SetDlgItemText16
 93  pascal16 GetDlgItemText(word word segptr word) GetDlgItemText16
@@ -103,8 +103,8 @@
 101 pascal   SendDlgItemMessage(word word word word long) SendDlgItemMessage16
 102 pascal16 AdjustWindowRect(ptr long word) AdjustWindowRect16
 103 pascal16 MapDialogRect(word ptr) MapDialogRect16
-104 pascal16 MessageBeep(word) MessageBeep
-105 pascal16 FlashWindow(word word) FlashWindow
+104 pascal16 MessageBeep(word) MessageBeep16
+105 pascal16 FlashWindow(word word) FlashWindow16
 106 pascal16 GetKeyState(word) GetKeyState16
 107 pascal   DefWindowProc(word word word long) DefWindowProc16
 108 pascal16 GetMessage(segptr word word word) GetMessage
@@ -112,8 +112,8 @@
 110 pascal16 PostMessage(word word word long) PostMessage
 111 pascal   SendMessage(word word word long) SendMessage16
 112 pascal16 WaitMessage() WaitMessage
-113 pascal16 TranslateMessage(ptr) TranslateMessage
-114 pascal   DispatchMessage(ptr) DispatchMessage
+113 pascal16 TranslateMessage(ptr) TranslateMessage16
+114 pascal   DispatchMessage(ptr) DispatchMessage16
 115 pascal16 ReplyMessage(long) ReplyMessage
 116 pascal16 PostAppMessage(word word word long) PostAppMessage16
 118 pascal16 RegisterWindowMessage(segptr) RegisterWindowMessage16
@@ -136,18 +136,18 @@
 134 pascal16 SetWindowWord(word s_word word) SetWindowWord
 135 pascal   GetWindowLong(word s_word) GetWindowLong16
 136 pascal   SetWindowLong(word s_word long) SetWindowLong16
-137 pascal16 OpenClipboard(word) OpenClipboard
-138 pascal16 CloseClipboard() CloseClipboard
-139 pascal16 EmptyClipboard() EmptyClipboard
-140 pascal16 GetClipboardOwner() GetClipboardOwner
+137 pascal16 OpenClipboard(word) OpenClipboard16
+138 pascal16 CloseClipboard() CloseClipboard16
+139 pascal16 EmptyClipboard() EmptyClipboard16
+140 pascal16 GetClipboardOwner() GetClipboardOwner16
 141 pascal16 SetClipboardData(word word) SetClipboardData
 142 pascal16 GetClipboardData(word) GetClipboardData
-143 pascal16 CountClipboardFormats() CountClipboardFormats
-144 pascal16 EnumClipboardFormats(word) EnumClipboardFormats
+143 pascal16 CountClipboardFormats() CountClipboardFormats16
+144 pascal16 EnumClipboardFormats(word) EnumClipboardFormats16
 145 pascal16 RegisterClipboardFormat(ptr) RegisterClipboardFormat16
 146 pascal16 GetClipboardFormatName(word ptr s_word) GetClipboardFormatName
-147 pascal16 SetClipboardViewer(word) SetClipboardViewer
-148 pascal16 GetClipboardViewer() GetClipboardViewer
+147 pascal16 SetClipboardViewer(word) SetClipboardViewer16
+148 pascal16 GetClipboardViewer() GetClipboardViewer16
 149 pascal16 ChangeClipboardChain(word ptr) ChangeClipboardChain16
 150 pascal16 LoadMenu(word segptr) LoadMenu16
 151 pascal16 CreateMenu() CreateMenu16
@@ -165,8 +165,8 @@
 163 pascal16 CreateCaret(word word word word) CreateCaret
 164 pascal16 DestroyCaret() DestroyCaret
 165 pascal16 SetCaretPos(word word) SetCaretPos
-166 pascal16 HideCaret(word) HideCaret
-167 pascal16 ShowCaret(word) ShowCaret
+166 pascal16 HideCaret(word) HideCaret16
+167 pascal16 ShowCaret(word) ShowCaret16
 168 pascal16 SetCaretBlinkTime(word) SetCaretBlinkTime
 169 pascal16 GetCaretBlinkTime() GetCaretBlinkTime16
 170 pascal16 ArrangeIconicWindows(word) ArrangeIconicWindows16
@@ -178,26 +178,26 @@
 176 pascal16 LoadString(word word ptr s_word) LoadString16
 177 pascal16 LoadAccelerators(word segptr) LoadAccelerators16
 178 pascal16 TranslateAccelerator(word word ptr) TranslateAccelerator16
-179 pascal16 GetSystemMetrics(word) GetSystemMetrics
-180 pascal   GetSysColor(word) GetSysColor
-181 pascal16 SetSysColors(word ptr ptr) SetSysColors
+179 pascal16 GetSystemMetrics(s_word) GetSystemMetrics16
+180 pascal   GetSysColor(word) GetSysColor16
+181 pascal16 SetSysColors(word ptr ptr) SetSysColors16
 182 pascal16 KillSystemTimer(word word) KillSystemTimer16
 183 pascal16 GetCaretPos(ptr) GetCaretPos16
 184 stub QuerySendMessage
 185 pascal16 GrayString(word word segptr segptr s_word s_word s_word s_word s_word) THUNK_GrayString16
-186 pascal16 SwapMouseButton(word) SwapMouseButton
+186 pascal16 SwapMouseButton(word) SwapMouseButton16
 187 pascal16 EndMenu() EndMenu
 188 pascal16 SetSysModalWindow(word) SetSysModalWindow16
 189 pascal16 GetSysModalWindow() GetSysModalWindow16
 190 pascal16 GetUpdateRect(word ptr word) GetUpdateRect16
 191 pascal16 ChildWindowFromPoint(word long) ChildWindowFromPoint16
-192 pascal16 InSendMessage() InSendMessage
-193 pascal16 IsClipboardFormatAvailable(word) IsClipboardFormatAvailable
+192 pascal16 InSendMessage() InSendMessage16
+193 pascal16 IsClipboardFormatAvailable(word) IsClipboardFormatAvailable16
 194 pascal16 DlgDirSelectComboBox(word ptr word) DlgDirSelectComboBox
 195 pascal16 DlgDirListComboBox(word ptr word word word) DlgDirListComboBox16
 196 pascal   TabbedTextOut(word s_word s_word ptr s_word s_word ptr s_word)
-             TabbedTextOut
-197 pascal   GetTabbedTextExtent(word ptr word word ptr) GetTabbedTextExtent
+             TabbedTextOut16
+197 pascal   GetTabbedTextExtent(word ptr word word ptr) GetTabbedTextExtent16
 198 pascal16 CascadeChildWindows(word word) CascadeChildWindows
 199 pascal16 TileChildWindows(word word) TileChildWindows
 200 pascal16 OpenComm(ptr word word) OpenComm
@@ -233,7 +233,7 @@
 230 pascal16 GetNextWindow(word word) GetNextWindow16
 231 stub GetSystemDebugState
 232 pascal16 SetWindowPos(word word word word word word word) SetWindowPos16
-233 pascal16 SetParent(word word) SetParent
+233 pascal16 SetParent(word word) SetParent16
 234 pascal16 UnhookWindowsHook(s_word segptr) THUNK_UnhookWindowsHook16
 235 pascal   DefHookProc(s_word word long ptr) DefHookProc16
 236 pascal16 GetCapture() GetCapture16
@@ -249,8 +249,8 @@
 244 pascal16 EqualRect(ptr ptr) EqualRect16
 245 stub EnableCommNotification
 246 stub ExitWindowsExec
-247 pascal16 GetCursor() GetCursor
-248 pascal16 GetOpenClipboardWindow() GetOpenClipboardWindow
+247 pascal16 GetCursor() GetCursor16
+248 pascal16 GetOpenClipboardWindow() GetOpenClipboardWindow16
 249 pascal16 GetAsyncKeyState(word) GetAsyncKeyState16
 250 pascal16 GetMenuState(word word word) GetMenuState16
 251 pascal   SendDriverMessage(word word long long) SendDriverMessage
@@ -268,8 +268,8 @@
 262 pascal16 GetWindow(word word) GetWindow16
 263 pascal16 GetMenuItemCount(word) GetMenuItemCount16
 264 pascal16 GetMenuItemID(word word) GetMenuItemID16
-265 pascal16 ShowOwnedPopups(word word) ShowOwnedPopups
-266 pascal16 SetMessageQueue(word) SetMessageQueue
+265 pascal16 ShowOwnedPopups(word word) ShowOwnedPopups16
+266 pascal16 SetMessageQueue(word) SetMessageQueue16
 267 pascal16 ShowScrollBar(word word word) ShowScrollBar16
 268 pascal16 GlobalAddAtom(segptr) GlobalAddAtom16
 269 pascal16 GlobalDeleteAtom(word) GlobalDeleteAtom
@@ -285,12 +285,12 @@
 279 stub OldSetDeskPattern
 280 pascal16 SetSystemMenu(word word) SetSystemMenu16
 281 pascal16 GetSysColorBrush(word) GetSysColorBrush16
-282 pascal16 SelectPalette(word word word) SelectPalette
-283 pascal16 RealizePalette(word) RealizePalette
+282 pascal16 SelectPalette(word word word) SelectPalette16
+283 pascal16 RealizePalette(word) RealizePalette16
 284 pascal16 GetFreeSystemResources(word) GetFreeSystemResources
 285 pascal16 SetDeskWallPaper(ptr) SetDeskWallPaper16
 286 pascal16 GetDesktopWindow() GetDesktopWindow16
-287 pascal16 GetLastActivePopup(word) GetLastActivePopup
+287 pascal16 GetLastActivePopup(word) GetLastActivePopup16
 288 pascal   GetMessageExtraInfo() GetMessageExtraInfo
 #289 KEYB_EVENT
 290 pascal16 RedrawWindow(word ptr word word) RedrawWindow16
@@ -317,7 +317,7 @@
 332 pascal16 UserYield() UserYield
 333 stub IsUserIdle
 334 pascal   GetQueueStatus(word) GetQueueStatus
-335 pascal16 GetInputState() GetInputState
+335 pascal16 GetInputState() GetInputState16
 336 stub LoadCursorIconHandler
 337 pascal   GetMouseEventProc() GetMouseEventProc
 #341 _FFFE_FARFRAME
@@ -357,8 +357,8 @@
              GetPriorityClipboardFormat
 403 pascal16 UnregisterClass(segptr word) UnregisterClass16
 404 pascal16 GetClassInfo(word segptr ptr) GetClassInfo16
-406 pascal16 CreateCursor(word word word word word ptr ptr) CreateCursor
-407 pascal16 CreateIcon(word word word word word ptr ptr) CreateIcon
+406 pascal16 CreateCursor(word word word word word ptr ptr) CreateCursor16
+407 pascal16 CreateIcon(word word word word word ptr ptr) CreateIcon16
 408 pascal16 CreateCursorIconIndirect(word ptr ptr ptr)
 	     CreateCursorIconIndirect
 409 stub InitThreadInput
@@ -395,21 +395,21 @@
 448 stub DrawAnimatedRects
 449 stub DrawState
 450 stub CreateIconFromResourceEx
-451 pascal16 TranslateMDISysAccel(word ptr) TranslateMDISysAccel
+451 pascal16 TranslateMDISysAccel(word ptr) TranslateMDISysAccel16
 452 pascal16 CreateWindowEx(long ptr ptr long s_word s_word s_word s_word
                             word word word segptr) CreateWindowEx16
 454 pascal16 AdjustWindowRectEx(ptr long word long) AdjustWindowRectEx16
 455 pascal16 GetIconID(word long) GetIconID
 456 pascal16 LoadIconHandler(word word) LoadIconHandler
-457 pascal16 DestroyIcon(word) DestroyIcon
-458 pascal16 DestroyCursor(word) DestroyCursor
+457 pascal16 DestroyIcon(word) DestroyIcon16
+458 pascal16 DestroyCursor(word) DestroyCursor16
 459 pascal   DumpIcon(segptr ptr ptr ptr) DumpIcon
 460 pascal16 GetInternalWindowPos(word ptr ptr) GetInternalWindowPos16
 461 pascal16 SetInternalWindowPos(word word ptr ptr) SetInternalWindowPos16
 462 pascal16 CalcChildScroll(word word) CalcChildScroll
-463 pascal16 ScrollChildren(word word word long) ScrollChildren
+463 pascal16 ScrollChildren(word word word long) ScrollChildren16
 464 pascal   DragObject(word word word word word word) DragObject
-465 pascal16 DragDetect(word long) DragDetect
+465 pascal16 DragDetect(word long) DragDetect16
 466 pascal16 DrawFocusRect(word ptr) DrawFocusRect16
 470 stub StringFunc
 471 pascal16 lstrcmpi(ptr ptr) lstrcmpi16
@@ -465,7 +465,6 @@
 532 pascal16 WNetGetPropertyText(word word word ptr word) WNetGetPropertyText
 533 stub WNetInitialize
 534 stub WNetLogon
-669 stub SetWindowRgn
 600 stub GetShellWindow
 601 stub DoHotkeyStuff
 602 stub SetCheckCursorTimer
diff --git a/if1632/user32.spec b/if1632/user32.spec
index bf7f131..20ac214 100644
--- a/if1632/user32.spec
+++ b/if1632/user32.spec
@@ -5,7 +5,7 @@
 0000 stub ActivateKeyboardLayout
 0001 stdcall AdjustWindowRect(ptr long long) AdjustWindowRect32
 0002 stdcall AdjustWindowRectEx(ptr long long long) AdjustWindowRectEx32
-0003 stub AnyPopup
+0003 stdcall AnyPopup() AnyPopup32
 0004 stdcall AppendMenuA(long long long ptr) AppendMenu32A
 0005 stdcall AppendMenuW(long long long ptr) AppendMenu32W
 0006 stdcall ArrangeIconicWindows(long) ArrangeIconicWindows32
@@ -55,20 +55,20 @@
 0050 stub ClientThreadConnect
 0051 stdcall ClientToScreen(long ptr) ClientToScreen32
 0052 stdcall ClipCursor(ptr) ClipCursor32
-0053 stdcall CloseClipboard() CloseClipboard
+0053 stdcall CloseClipboard() CloseClipboard32
 0054 stub CloseDesktop
-0055 stub CloseWindow
+0055 stdcall CloseWindow(long) CloseWindow32
 0056 stub CloseWindowStation
 0057 stub CopyAcceleratorTableA
 0058 stub CopyAcceleratorTableW
 0059 stdcall CopyIcon(long) CopyIcon32
 0060 stdcall CopyImage(long long long long long) CopyImage32
 0061 stdcall CopyRect(ptr ptr) CopyRect32
-0062 stub CountClipboardFormats
+0062 stdcall CountClipboardFormats() CountClipboardFormats32
 0063 stub CreateAcceleratorTableA
 0064 stub CreateAcceleratorTableW
 0065 stdcall CreateCaret(long long long long) CreateCaret
-0066 stub CreateCursor
+0066 stdcall CreateCursor(long long long long long ptr ptr) CreateCursor32
 0067 stub CreateDesktopA
 0068 stub CreateDesktopW
 0069 stdcall CreateDialogIndirectParamA(long ptr long ptr long) CreateDialogIndirectParam32A
@@ -76,7 +76,7 @@
 0071 stdcall CreateDialogIndirectParamW(long ptr long ptr long) CreateDialogIndirectParam32W
 0072 stdcall CreateDialogParamA(long ptr long ptr long) CreateDialogParam32A
 0073 stdcall CreateDialogParamW(long ptr long ptr long) CreateDialogParam32W
-0074 stub CreateIcon
+0074 stdcall CreateIcon(long long long long long ptr ptr) CreateIcon32
 0075 stub CreateIconFromResource
 0076 stub CreateIconFromResourceEx
 0077 stub CreateIconIndirect
@@ -93,14 +93,14 @@
 0086 stub DdeAbandonTransaction
 0087 stub DdeAccessData
 0088 stub DdeAddData
-0089 stub DdeClientTransaction
+0089 return DdeClientTransaction 32 0
 0090 stub DdeCmpStringHandles
-0091 stub DdeConnect
+0091 return DdeConnect 16 0
 0092 stub DdeConnectList
 0093 stub DdeCreateDataHandle
 0094 return DdeCreateStringHandleA 12 0
-0095 stub DdeCreateStringHandleW
-0096 stub DdeDisconnect
+0095 return DdeCreateStringHandleW 12 0
+0096 return DdeDisconnect 4 0
 0097 stub DdeDisconnectList
 0098 stub DdeEnableCallback
 0099 stub DdeFreeDataHandle
@@ -110,7 +110,7 @@
 0103 stub DdeGetQualityOfService
 0104 stub DdeImpersonateClient
 0105 return DdeInitializeA 16 0
-0106 stub DdeInitializeW
+0106 return DdeInitializeW 16 0
 0107 stub DdeKeepStringHandle
 0108 return DdeNameService 16 0
 0109 stub DdePostAdvise
@@ -135,8 +135,8 @@
 0128 stdcall DeleteMenu(long long long) DeleteMenu32
 0129 stub DestroyAcceleratorTable
 0130 stdcall DestroyCaret() DestroyCaret
-0131 stub DestroyCursor
-0132 stub DestroyIcon
+0131 stdcall DestroyCursor(long) DestroyCursor32
+0132 stdcall DestroyIcon(long) DestroyIcon32
 0133 stdcall DestroyMenu(long) DestroyMenu32
 0134 stdcall DestroyWindow(long) DestroyWindow32
 0135 stdcall DialogBoxIndirectParamA(long ptr long ptr long) DialogBoxIndirectParam32A
@@ -144,8 +144,8 @@
 0137 stdcall DialogBoxIndirectParamW(long ptr long ptr long) DialogBoxIndirectParam32W
 0138 stdcall DialogBoxParamA(long ptr long ptr long) DialogBoxParam32A
 0139 stdcall DialogBoxParamW(long ptr long ptr long) DialogBoxParam32W
-0140 stdcall DispatchMessageA(ptr) USER32_DispatchMessageA
-0141 stdcall DispatchMessageW(ptr) USER32_DispatchMessageA
+0140 stdcall DispatchMessageA(ptr) DispatchMessage32A
+0141 stdcall DispatchMessageW(ptr) DispatchMessage32W
 0142 stdcall DlgDirListA(long ptr long long long) DlgDirList32A
 0143 stdcall DlgDirListComboBoxA(long ptr long long long) DlgDirListComboBox32A
 0144 stdcall DlgDirListComboBoxW(long ptr long long long) DlgDirListComboBox32W
@@ -154,7 +154,7 @@
 0147 stdcall DlgDirSelectComboBoxExW(long ptr long long) DlgDirSelectComboBoxEx32W
 0148 stdcall DlgDirSelectExA(long ptr long long) DlgDirSelectEx32A
 0149 stdcall DlgDirSelectExW(long ptr long long) DlgDirSelectEx32W
-0150 stub DragDetect
+0150 stdcall DragDetect(long long long) DragDetect32
 0151 stub DragObject
 0152 stub DrawAnimatedRects
 0153 stub DrawCaption
@@ -162,7 +162,7 @@
 0155 stdcall DrawFocusRect(long ptr) DrawFocusRect32
 0156 stub DrawFrame
 0157 stdcall DrawFrameControl(long ptr long long) DrawFrameControl32
-0158 stdcall DrawIcon(long long long long) DrawIcon
+0158 stdcall DrawIcon(long long long long) DrawIcon32
 0159 stub DrawIconEx
 0160 stdcall DrawMenuBar(long) DrawMenuBar32
 0161 stub DrawStateA
@@ -172,17 +172,17 @@
 0165 stub DrawTextExW
 0166 stdcall DrawTextW(long ptr long ptr long) DrawText32W
 0167 stub EditWndProc
-0168 stdcall EmptyClipboard() EmptyClipboard
+0168 stdcall EmptyClipboard() EmptyClipboard32
 0169 stdcall EnableMenuItem(long long long) EnableMenuItem32
 0170 stdcall EnableScrollBar(long long long) EnableScrollBar32
 0171 stdcall EnableWindow(long long) EnableWindow32
 0172 stdcall EndDeferWindowPos(long) EndDeferWindowPos32
-0173 stdcall EndDialog(long long) EndDialog
+0173 stdcall EndDialog(long long) EndDialog32
 0174 stdcall EndMenu() EndMenu
 0175 stdcall EndPaint(long ptr) EndPaint32
 0176 stub EndTask
 0177 stdcall EnumChildWindows(long ptr long) THUNK_EnumChildWindows32
-0178 stub EnumClipboardFormats
+0178 stdcall EnumClipboardFormats(long) EnumClipboardFormats32
 0179 stub EnumDesktopsA
 0180 stub EnumDesktopsW
 0181 stub EnumDisplayDeviceModesA
@@ -205,7 +205,7 @@
 0198 stdcall FindWindowExA(long long ptr ptr) FindWindowEx32A
 0199 stdcall FindWindowExW(long long ptr ptr) FindWindowEx32W
 0200 stdcall FindWindowW(ptr ptr) FindWindow32W
-0201 stdcall FlashWindow(long long) FlashWindow
+0201 stdcall FlashWindow(long long) FlashWindow32
 0202 stdcall FrameRect(long ptr long) FrameRect32
 0203 stub FreeDDElParam
 0204 stdcall GetActiveWindow() GetActiveWindow32
@@ -225,12 +225,12 @@
 0218 stdcall GetClassWord(long long) GetClassWord
 0219 stdcall GetClientRect(long long) GetClientRect32
 0220 stdcall GetClipCursor(ptr) GetClipCursor32
-0221 stub GetClipboardData
+0221 stdcall GetClipboardData(long) GetClipboardData
 0222 stub GetClipboardFormatNameA
 0223 stub GetClipboardFormatNameW
-0224 stub GetClipboardOwner
-0225 stdcall GetClipboardViewer(long) GetClipboardViewer
-0226 stdcall GetCursor() GetCursor
+0224 stdcall GetClipboardOwner() GetClipboardOwner32
+0225 stdcall GetClipboardViewer(long) GetClipboardViewer32
+0226 stdcall GetCursor() GetCursor32
 0227 stub GetCursorInfo
 0228 stdcall GetCursorPos(ptr) GetCursorPos32
 0229 stdcall GetDC(long) GetDC32
@@ -242,14 +242,14 @@
 0235 stdcall GetDlgItemInt(long long ptr long) GetDlgItemInt32
 0236 stdcall GetDlgItemTextA(long long ptr long) GetDlgItemText32A
 0237 stdcall GetDlgItemTextW(long long ptr long) GetDlgItemText32W
-0238 stub GetDoubleClickTime
+0238 stdcall GetDoubleClickTime() GetDoubleClickTime32
 0239 stdcall GetFocus() GetFocus32
 0240 return GetForegroundWindow 0 0		#FIXME
 0241 stub GetIconInfo
 0242 stub GetInputDesktop
-0243 stub GetInputState
+0243 stdcall GetInputState() GetInputState32
 0244 stdcall GetInternalWindowPos(long ptr ptr) GetInternalWindowPos32
-0245 stub GetKBCodePage
+0245 stdcall GetKBCodePage() GetKBCodePage32
 0246 stdcall GetKeyNameTextA(long ptr long) GetKeyNameText32A
 0247 stdcall GetKeyNameTextW(long ptr long) GetKeyNameText32W
 0248 stdcall GetKeyState(long) GetKeyState32
@@ -259,7 +259,7 @@
 0252 stub GetKeyboardLayoutNameW
 0253 stdcall GetKeyboardState(ptr) GetKeyboardState
 0254 stdcall GetKeyboardType(long) GetKeyboardType32
-0255 stdcall GetLastActivePopup(long) GetLastActivePopup
+0255 stdcall GetLastActivePopup(long) GetLastActivePopup32
 0256 stdcall GetMenu(long) GetMenu32
 0257 stdcall GetMenuCheckMarkDimensions() GetMenuCheckMarkDimensions
 0258 stub GetMenuContextHelpId
@@ -274,13 +274,13 @@
 0267 stdcall GetMenuStringA(long long ptr long long) GetMenuString32A
 0268 stdcall GetMenuStringW(long long ptr long long) GetMenuString32W
 0269 stdcall GetMessageA(ptr long long long) USER32_GetMessageA
-0270 stub GetMessageExtraInfo
+0270 stdcall GetMessageExtraInfo() GetMessageExtraInfo
 0271 stdcall GetMessagePos() GetMessagePos
-0272 stub GetMessageTime
+0272 stdcall GetMessageTime() GetMessageTime
 0273 stdcall GetMessageW(ptr long long long) USER32_GetMessageA
 0274 stdcall GetNextDlgGroupItem(long long long) GetNextDlgGroupItem32
 0275 stdcall GetNextDlgTabItem(long long long) GetNextDlgTabItem32
-0276 stub GetOpenClipboardWindow
+0276 stdcall GetOpenClipboardWindow() GetOpenClipboardWindow32
 0277 stdcall GetParent(long) GetParent32
 0278 stub GetPriorityClipboardFormat
 0279 stub GetProcessWindowStation
@@ -292,12 +292,12 @@
 0285 stdcall GetScrollRange(long long ptr ptr) GetScrollRange32
 0286 return GetShellWindow 0 0
 0287 stdcall GetSubMenu(long long) GetSubMenu32
-0288 stdcall GetSysColor(long) GetSysColor
+0288 stdcall GetSysColor(long) GetSysColor32
 0289 stdcall GetSysColorBrush(long) GetSysColorBrush32
 0290 stdcall GetSystemMenu(long long) GetSystemMenu32
-0291 stdcall GetSystemMetrics(long) GetSystemMetrics
-0292 stdcall GetTabbedTextExtentA(long ptr long long ptr) GetTabbedTextExtent
-0293 stub GetTabbedTextExtentW
+0291 stdcall GetSystemMetrics(long) GetSystemMetrics32
+0292 stdcall GetTabbedTextExtentA(long ptr long long ptr) GetTabbedTextExtent32A
+0293 stdcall GetTabbedTextExtentW(long ptr long long ptr) GetTabbedTextExtent32W
 0294 stub GetThreadDesktop
 0295 stdcall GetTopWindow(long) GetTopWindow32
 0296 stdcall GetUpdateRect(long ptr long) GetUpdateRect32
@@ -318,12 +318,12 @@
 0311 stdcall GetWindowTextW(long ptr long) GetWindowText32W
 0312 stdcall GetWindowThreadProcessId(long ptr) GetWindowThreadProcessId
 0313 stdcall GetWindowWord(long long) GetWindowWord
-0314 stub GrayStringA
-0315 stub GrayStringW
-0316 stdcall HideCaret(long) HideCaret
+0314 stdcall GrayStringA(long long ptr long long long long long long) THUNK_GrayString32A
+0315 stdcall GrayStringW(long long ptr long long long long long long) THUNK_GrayString32W
+0316 stdcall HideCaret(long) HideCaret32
 0317 stdcall HiliteMenuItem(long long long long) HiliteMenuItem32
 0318 stub ImpersonateDdeClientWindow
-0319 stub InSendMessage
+0319 stdcall InSendMessage() InSendMessage32
 0320 stdcall InflateRect(ptr long long) InflateRect32
 0321 stdcall InsertMenuA(long long long long ptr) InsertMenu32A
 0322 stub InsertMenuItemA
@@ -343,7 +343,7 @@
 0336 stdcall IsCharUpperA(long) IsCharUpper32A
 0337 stdcall IsCharUpperW(long) IsCharUpper32W
 0338 stdcall IsChild(long long) IsChild32
-0339 stdcall IsClipboardFormatAvailable(long) IsClipboardFormatAvailable
+0339 stdcall IsClipboardFormatAvailable(long) IsClipboardFormatAvailable32
 0340 stub IsDialogMessage
 0341 stdcall IsDialogMessageA(long ptr) IsDialogMessage32A
 0342 stdcall IsDialogMessageW(long ptr) IsDialogMessage32W
@@ -393,7 +393,7 @@
 0386 stub MenuItemFromPoint
 0387 stub MenuWindowProcA
 0388 stub MenuWindowProcW
-0389 stdcall MessageBeep(long) MessageBeep
+0389 stdcall MessageBeep(long) MessageBeep32
 0390 stdcall MessageBoxA(long ptr ptr long) MessageBox32A
 0391 stdcall MessageBoxExA(long ptr ptr long long) MessageBoxEx32A
 0392 stdcall MessageBoxExW(long ptr ptr long long) MessageBoxEx32W
@@ -410,10 +410,10 @@
 0403 stdcall OemToCharBuffW(ptr ptr long) OemToCharBuff32W
 0404 stdcall OemToCharW(ptr ptr) OemToChar32W
 0405 stdcall OffsetRect(ptr long long) OffsetRect32
-0406 stdcall OpenClipboard(long) OpenClipboard
+0406 stdcall OpenClipboard(long) OpenClipboard32
 0407 stub OpenDesktopA
 0408 stub OpenDesktopW
-0409 stub OpenIcon
+0409 stdcall OpenIcon(long) OpenIcon32
 0410 stub OpenInputDesktop
 0411 stub OpenWindowStationA
 0412 stub OpenWindowStationW
@@ -424,7 +424,7 @@
 0417 stub PlaySoundEvent
 0418 stdcall PostMessageA(long long long long) PostMessage
 0419 stdcall PostMessageW(long long long long) PostMessage
-0420 stdcall PostQuitMessage(long) PostQuitMessage
+0420 stdcall PostQuitMessage(long) PostQuitMessage32
 0421 stub PostThreadMessageA
 0422 stub PostThreadMessageW
 0423 stdcall PtInRect(ptr long long) PtInRect32
@@ -451,7 +451,7 @@
 0444 stub ResetDisplay
 0445 stub ReuseDDElParam
 0446 stdcall ScreenToClient(long ptr) ScreenToClient32
-0447 stub ScrollChildren
+0447 stdcall ScrollChildren(long long long long) ScrollChildren32
 0448 stdcall ScrollDC(long long long ptr ptr long ptr) ScrollDC32
 0449 stdcall ScrollWindow(long long long ptr ptr) ScrollWindow32
 0450 stdcall ScrollWindowEx(long long long ptr ptr long ptr long) ScrollWindowEx32
@@ -473,17 +473,17 @@
 0466 stdcall SetClassLongA(long long long) SetClassLong32A
 0467 stdcall SetClassLongW(long long long) SetClassLong32W
 0468 stdcall SetClassWord(long long long) SetClassWord
-0469 stub SetClipboardData
-0470 stdcall SetClipboardViewer(long) SetClipboardViewer
-0471 	stdcall SetCursor(long) SetCursor
+0469 stdcall SetClipboardData(long long) SetClipboardData
+0470 stdcall SetClipboardViewer(long) SetClipboardViewer32
+0471 stdcall SetCursor(long) SetCursor32
 0472 stub SetCursorContents
-0473 stub SetCursorPos
+0473 stdcall SetCursorPos(long long) SetCursorPos32
 0474 stub SetDebugErrorLevel
 0475 stdcall SetDeskWallPaper(ptr) SetDeskWallPaper32
 0476 stdcall SetDlgItemInt(long long long long) SetDlgItemInt32
 0477 stdcall SetDlgItemTextA(long long ptr) SetDlgItemText32A
 0478 stdcall SetDlgItemTextW(long long ptr) SetDlgItemText32W
-0479 stub SetDoubleClickTime
+0479 stdcall SetDoubleClickTime(long) SetDoubleClickTime32
 0480 stdcall SetFocus(long) SetFocus32
 0481 return SetForegroundWindow 4 0
 0482 stdcall SetInternalWindowPos(long long ptr ptr) SetInternalWindowPos32
@@ -497,8 +497,8 @@
 0490 stub SetMenuItemInfoA
 0491 stub SetMenuItemInfoW
 0492 stub SetMessageExtraInfo
-0493 stdcall  SetMessageQueue(long) SetMessageQueue
-0494 stdcall SetParent(long long) SetParent
+0493 stdcall SetMessageQueue(long) SetMessageQueue32
+0494 stdcall SetParent(long long) SetParent32
 0495 stub SetProcessWindowStation
 0496 stdcall SetPropA(long ptr long) SetProp32A
 0497 stdcall SetPropW(long ptr long) SetProp32W
@@ -508,7 +508,7 @@
 0501 stdcall SetScrollPos(long long long long) SetScrollPos32
 0502 stdcall SetScrollRange(long long long long long) SetScrollRange32
 0503 stub SetShellWindow
-0504 stub SetSysColors
+0504 stdcall SetSysColors(long ptr ptr) SetSysColors32
 0505 stub SetSysColorsTemp
 0506 stub SetSystemCursor
 0507 stdcall SetSystemMenu(long long) SetSystemMenu32
@@ -532,24 +532,24 @@
 0525 stdcall SetWindowsHookExA(long long long long) SetWindowsHookEx32A
 0526 stdcall SetWindowsHookExW(long long long long) SetWindowsHookEx32W
 0527 stdcall SetWindowsHookW(long long long long) SetWindowsHook32W
-0528 stdcall ShowCaret(long) ShowCaret
-0529 stdcall ShowCursor(long) ShowCursor
-0530 stub ShowOwnedPopups
+0528 stdcall ShowCaret(long) ShowCaret32
+0529 stdcall ShowCursor(long) ShowCursor32
+0530 stdcall ShowOwnedPopups(long long) ShowOwnedPopups32
 0531 stdcall ShowScrollBar(long long long) ShowScrollBar32
 0532 stub ShowStartGlass
 0533 stdcall ShowWindow(long long) ShowWindow32
 0534 stub ShowWindowAsync
 0535 stdcall SubtractRect(ptr ptr ptr) SubtractRect32
-0536 stdcall SwapMouseButton(long) SwapMouseButton
+0536 stdcall SwapMouseButton(long) SwapMouseButton32
 0537 stub SwitchDesktop
 0538 stub SwitchToThisWindow
 0539 stdcall SystemParametersInfoA(long long ptr long) SystemParametersInfo32A
 0540 stdcall SystemParametersInfoW(long long ptr long) SystemParametersInfo32W
-0541 stub TabbedTextOutA
-0542 stub TabbedTextOutW
+0541 stdcall TabbedTextOutA(long long long ptr long long ptr long) TabbedTextOut32A
+0542 stdcall TabbedTextOutW(long long long ptr long long ptr long) TabbedTextOut32W
 0543 stub TileChildWindows
 0544 stub TileWindows
-0545 stdcall ToAscii32(long long ptr ptr long) ToAscii32
+0545 stdcall ToAscii(long long ptr ptr long) ToAscii32
 0546 stub ToAsciiEx
 0547 stub ToUnicode
 0548 stdcall TrackPopupMenu(long long long long long long ptr) TrackPopupMenu32
@@ -558,8 +558,8 @@
 0551 stdcall TranslateAcceleratorA(long long ptr) TranslateAccelerator32
 0552 stdcall TranslateAcceleratorW(long long ptr) TranslateAccelerator32
 0553 stub TranslateCharsetInfo
-0554 stub TranslateMDISysAccel
-0555 stdcall TranslateMessage(ptr) USER32_TranslateMessage
+0554 stdcall TranslateMDISysAccel(long ptr) TranslateMDISysAccel32
+0555 stdcall TranslateMessage(ptr) TranslateMessage32
 0556 stdcall UnhookWindowsHook(long ptr) UnhookWindowsHook32
 0557 stdcall UnhookWindowsHookEx(long) UnhookWindowsHookEx32
 0558 stdcall UnionRect(ptr ptr ptr) UnionRect32
@@ -581,7 +581,7 @@
 0574 stub VkKeyScanExW
 0575 stdcall VkKeyScanW(long) VkKeyScan32W
 0576 stub WaitForInputIdle
-0577 stub WaitMessage
+0577 stdcall WaitMessage() WaitMessage
 0578 stdcall WinHelpA(long ptr long long) WinHelp32A
 0579 stdcall WinHelpW(long ptr long long) WinHelp32W
 0580 stdcall WindowFromDC(long) WindowFromDC32
@@ -594,12 +594,12 @@
 0587 stdcall wvsprintfW(ptr ptr ptr) wvsprintf32W
 #late additions
 0588 stub ChangeDisplaySettingsA
-0588 stub ChangeDisplaySettingsW
-0588 stub EnumDesktopWindows
-0588 stub EnumDisplaySettingsA
-0588 stub EnumDisplaySettingsW
-0588 stub GetWindowRgn
-0588 stub MapVirtualKeyExW
-0588 stub RegisterServicesProcess
-0588 stub SetWindowRgn
-0588 stub ToUnicodeEx
+0589 stub ChangeDisplaySettingsW
+0590 stub EnumDesktopWindows
+0591 stub EnumDisplaySettingsA
+0592 stub EnumDisplaySettingsW
+0593 stub GetWindowRgn
+0594 stub MapVirtualKeyExW
+0595 stub RegisterServicesProcess
+0596 stub SetWindowRgn
+0597 stub ToUnicodeEx
diff --git a/if1632/wsock32.spec b/if1632/wsock32.spec
index 8503c3d..f868690 100644
--- a/if1632/wsock32.spec
+++ b/if1632/wsock32.spec
@@ -9,14 +9,14 @@
 005 stub getpeername
 006 stub getsockname
 007 stub getsockopt
-008 stdcall htonl(long) htonl
-009 stdcall htons(long) htons
+008 stdcall htonl(long) WINSOCK_htonl
+009 stdcall htons(long) WINSOCK_htons
 010 stdcall inet_addr(ptr) inet_addr
 011 stdcall inet_ntoa(ptr) inet_ntoa
 012 stub ioctlsocket
 013 stub listen
-014 stub ntohl
-015 stdcall ntohs(long) ntohs
+014 stdcall ntohl(long) WINSOCK_ntohl
+015 stdcall ntohs(long) WINSOCK_ntohs
 016 stub recv
 017 stub recvfrom
 018 stub select
@@ -24,7 +24,7 @@
 020 stub sendto
 021 stub setsockopt
 022 stub shutdown
-023 stub socket
+023 stdcall socket(long long long) WINSOCK_socket
 051 stdcall gethostbyaddr(ptr long long) gethostbyaddr
 052 stdcall gethostbyname(ptr) gethostbyname
 053 stub getprotobyname
diff --git a/include/clipboard.h b/include/clipboard.h
index 17cc340..34f3bcf 100644
--- a/include/clipboard.h
+++ b/include/clipboard.h
@@ -2,7 +2,7 @@
 #define __WINE_CLIPBOARD_H
 
 void CLIPBOARD_ReadSelection(Window w,Atom prop);
-void CLIPBOARD_ReleaseSelection(Window w,HWND hwnd);
+void CLIPBOARD_ReleaseSelection(Window w,HWND32 hwnd);
 void CLIPBOARD_DisOwn(WND* pWnd);
 BOOL CLIPBOARD_IsPresent(WORD wFormat);
 
diff --git a/include/color.h b/include/color.h
index 8eada96..1bd269b 100644
--- a/include/color.h
+++ b/include/color.h
@@ -13,18 +13,19 @@
 #define PC_SYS_RESERVED 0x40		/* system palentry is not to be mapped to */
 #define PC_SYS_MAPPED   0x10		/* logical palentry is a direct alias for system palentry */
 
-extern HPALETTE16 	COLOR_Init(void);
-extern void		COLOR_Cleanup(void);
-extern COLORREF		COLOR_ToLogical(int pixel);
-extern int 		COLOR_ToPhysical( DC *dc, COLORREF color );
-extern int 		COLOR_SetMapping( PALETTEOBJ* pal, BOOL32 mapOnly );
-extern BOOL32 		COLOR_IsSolid( COLORREF color );
-extern Colormap		COLOR_GetColormap();
-extern UINT16		COLOR_GetSystemPaletteSize();
-extern UINT16		COLOR_GetSystemPaletteFlags();
+extern HPALETTE16 COLOR_Init(void);
+extern void	  COLOR_Cleanup(void);
+extern COLORREF	  COLOR_ToLogical(int pixel);
+extern int 	  COLOR_ToPhysical( DC *dc, COLORREF color );
+extern int 	  COLOR_SetMapping( PALETTEOBJ* pal, BOOL32 mapOnly );
+extern BOOL32 	  COLOR_IsSolid( COLORREF color );
+extern Colormap	  COLOR_GetColormap();
+extern UINT16	  COLOR_GetSystemPaletteSize();
+extern UINT16	  COLOR_GetSystemPaletteFlags();
 
-extern COLORREF		COLOR_LookupNearestColor( PALETTEENTRY*, int, COLORREF );
-extern int		COLOR_PaletteLookupPixel( PALETTEENTRY*, int, int* , COLORREF, BOOL32 );
+extern COLORREF	  COLOR_LookupNearestColor( PALETTEENTRY*, int, COLORREF );
+extern int        COLOR_PaletteLookupPixel( PALETTEENTRY*, int, int* , COLORREF, BOOL32 );
+extern COLORREF   COLOR_GetSystemPaletteEntry(UINT32);
 
 extern int 	COLOR_mapEGAPixel[16];
 extern int* 	COLOR_PaletteToPixel;
diff --git a/include/combo.h b/include/combo.h
index 7d74776..64511e5 100644
--- a/include/combo.h
+++ b/include/combo.h
@@ -7,15 +7,15 @@
   WND*	  wndSelf;
   DWORD   dwStyle;
   DWORD   dwState;
-  HWND    hWndEdit;
-  HWND    hWndLBox;
+  HWND16  hWndEdit;
+  HWND16  hWndLBox;
   WORD    LBoxTop;
-  BOOL    DropDownVisible;
+  BOOL16  DropDownVisible;
   short   LastSel;
   RECT16  RectEdit;
   RECT16  RectButton;
-  BOOL    bRedrawFlag;
+  BOOL16  bRedrawFlag;
 } HEADCOMBO,*LPHEADCOMBO;
 
-LRESULT ComboBoxWndProc(HWND hwnd, UINT message, WPARAM16 wParam, LPARAM lParam);
-LRESULT ComboLBoxWndProc(HWND hwnd, UINT message, WPARAM16 wParam, LPARAM lParam);
+LRESULT ComboBoxWndProc(HWND16 hwnd, UINT message, WPARAM16 wParam, LPARAM lParam);
+LRESULT ComboLBoxWndProc(HWND16 hwnd, UINT message, WPARAM16 wParam, LPARAM lParam);
diff --git a/include/commdlg.h b/include/commdlg.h
index e7a8eab..1761991 100644
--- a/include/commdlg.h
+++ b/include/commdlg.h
@@ -49,7 +49,7 @@
 
 typedef struct {
 	DWORD		lStructSize;
-	HWND		hwndOwner;
+	HWND16		hwndOwner;
 	HINSTANCE16	hInstance;
 	SEGPTR	        lpstrFilter;
 	SEGPTR          lpstrCustomFilter;
@@ -74,8 +74,8 @@
 
 typedef struct {
 	DWORD		lStructSize;
-	HWND		hwndOwner;
-	HWND		hInstance;
+	HWND16		hwndOwner;
+	HWND16		hInstance;
 	COLORREF	rgbResult;
 	COLORREF       *lpCustColors;
 	DWORD 		Flags;
@@ -95,7 +95,7 @@
 
 typedef struct {
 	DWORD		lStructSize; 			/* size of this struct 0x20 */
-	HWND		hwndOwner; 				/* handle to owner's window */
+	HWND16		hwndOwner; 				/* handle to owner's window */
 	HINSTANCE16	hInstance; 				/* instance handle of.EXE that  */
 										/*	contains cust. dlg. template */
 	DWORD		Flags;                  /* one or more of the FR_?? */
@@ -132,7 +132,7 @@
 
 typedef struct {
 	DWORD			lStructSize;
-	HWND			hwndOwner;          /* caller's window handle   */
+	HWND16			hwndOwner;          /* caller's window handle   */
 	HDC16          	        hDC;                /* printer DC/IC or NULL    */
 	SEGPTR                  lpLogFont;          /* ptr. to a LOGFONT struct */
 	short			iPointSize;         /* 10 * size in points of selected font */
@@ -205,7 +205,7 @@
 
 typedef struct {
 	DWORD 		lStructSize;
-	HWND 		hwndOwner;
+	HWND16 		hwndOwner;
 	HGLOBAL16       hDevMode;
 	HGLOBAL16       hDevNames;
 	HDC16	       	hDC;
@@ -285,14 +285,14 @@
 HWND16 ReplaceText( SEGPTR find);
 BOOL  ChooseFont(LPCHOOSEFONT lpChFont);
 
-LRESULT FileOpenDlgProc(HWND hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam);
-LRESULT FileSaveDlgProc(HWND hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam);
-LRESULT ColorDlgProc(HWND hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam);
-LRESULT FindTextDlgProc(HWND hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam);
-LRESULT ReplaceTextDlgProc(HWND hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam);
-LRESULT PrintDlgProc(HWND hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam);
-LRESULT PrintSetupDlgProc(HWND hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam);
-LRESULT FormatCharDlgProc(HWND hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam);
+LRESULT FileOpenDlgProc(HWND16 hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam);
+LRESULT FileSaveDlgProc(HWND16 hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam);
+LRESULT ColorDlgProc(HWND16 hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam);
+LRESULT FindTextDlgProc(HWND16 hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam);
+LRESULT ReplaceTextDlgProc(HWND16 hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam);
+LRESULT PrintDlgProc(HWND16 hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam);
+LRESULT PrintSetupDlgProc(HWND16 hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam);
+LRESULT FormatCharDlgProc(HWND16 hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam);
 
 #ifdef __cplusplus
 }
diff --git a/include/dde_proc.h b/include/dde_proc.h
index 29397d7..84697cf 100644
--- a/include/dde_proc.h
+++ b/include/dde_proc.h
@@ -34,7 +34,7 @@
 
 typedef struct {
     WORD  proc_idx;		/* index into wine's process table  */
-    HWND  wnd;			/* Window on the local proccess */
+    HWND16  wnd;		/* Window on the local proccess */
 } WND_DATA;
 extern enum stop_wait_op stop_wait_op;
 extern int had_SIGUSR2;
@@ -51,12 +51,12 @@
 void dde_wnd_setup();		   /* setup Data structure of DDE windows */
 
 /* Send ack. to hnd indicating that posted/sent msg. got to destination*/
-void dde_proc_send_ack(HWND wnd, BOOL val);
+void dde_proc_send_ack(HWND16 wnd, BOOL val);
 BOOL DDE_PostMessage( MSG16 *msg);
 BOOL DDE_SendMessage( MSG16 *msg);
 int DDE_GetRemoteMessage();
-void DDE_DestroyWindow(HWND hwnd); /* delete DDE info regarding hwnd */
-void DDE_TestDDE(HWND hwnd);	   /* do we have dde handling in the window ?*/
+void DDE_DestroyWindow(HWND16 hwnd); /* delete DDE info regarding hwnd */
+void DDE_TestDDE(HWND16 hwnd);	   /* do we have dde handling in the window ?*/
 
 #endif  /* CONFIG_IPC */
 
diff --git a/include/debug.h b/include/debug.h
index 14bc9d0..7dc0330 100644
--- a/include/debug.h
+++ b/include/debug.h
@@ -73,7 +73,6 @@
 #undef DEBUG_SENDMSG
 #undef DEBUG_SHM
 #undef DEBUG_STRESS
-#undef DEBUG_SYSCOLOR
 #undef DEBUG_TASK
 #undef DEBUG_TEXT
 #undef DEBUG_TIMER
@@ -154,7 +153,6 @@
 #define DEBUG_SENDMSG
 #define DEBUG_SHM
 #define DEBUG_STRESS
-#define DEBUG_SYSCOLOR
 #define DEBUG_TASK
 #define DEBUG_TEXT
 #define DEBUG_TIMER
@@ -505,11 +503,6 @@
 #else
     0,
 #endif
-#ifdef DEBUG_SYSCOLOR
-    1,
-#else
-    0,
-#endif
 #ifdef DEBUG_TASK
     1,
 #else
@@ -1439,21 +1432,8 @@
 #endif
 
 #ifdef DEBUG_RUNTIME
-#define dprintf_syscolor if(!debug_msg_enabled[67]) ; else fprintf
-#define debugging_syscolor debug_msg_enabled[67]
-#else
-#ifdef DEBUG_SYSCOLOR
-#define dprintf_syscolor fprintf
-#define debugging_syscolor 1
-#else
-#define dprintf_syscolor while(0) fprintf
-#define debugging_syscolor 0
-#endif
-#endif
-
-#ifdef DEBUG_RUNTIME
-#define dprintf_task if(!debug_msg_enabled[68]) ; else fprintf
-#define debugging_task debug_msg_enabled[68]
+#define dprintf_task if(!debug_msg_enabled[67]) ; else fprintf
+#define debugging_task debug_msg_enabled[67]
 #else
 #ifdef DEBUG_TASK
 #define dprintf_task fprintf
@@ -1465,8 +1445,8 @@
 #endif
 
 #ifdef DEBUG_RUNTIME
-#define dprintf_text if(!debug_msg_enabled[69]) ; else fprintf
-#define debugging_text debug_msg_enabled[69]
+#define dprintf_text if(!debug_msg_enabled[68]) ; else fprintf
+#define debugging_text debug_msg_enabled[68]
 #else
 #ifdef DEBUG_TEXT
 #define dprintf_text fprintf
@@ -1478,8 +1458,8 @@
 #endif
 
 #ifdef DEBUG_RUNTIME
-#define dprintf_timer if(!debug_msg_enabled[70]) ; else fprintf
-#define debugging_timer debug_msg_enabled[70]
+#define dprintf_timer if(!debug_msg_enabled[69]) ; else fprintf
+#define debugging_timer debug_msg_enabled[69]
 #else
 #ifdef DEBUG_TIMER
 #define dprintf_timer fprintf
@@ -1491,8 +1471,8 @@
 #endif
 
 #ifdef DEBUG_RUNTIME
-#define dprintf_toolhelp if(!debug_msg_enabled[71]) ; else fprintf
-#define debugging_toolhelp debug_msg_enabled[71]
+#define dprintf_toolhelp if(!debug_msg_enabled[70]) ; else fprintf
+#define debugging_toolhelp debug_msg_enabled[70]
 #else
 #ifdef DEBUG_TOOLHELP
 #define dprintf_toolhelp fprintf
@@ -1504,8 +1484,8 @@
 #endif
 
 #ifdef DEBUG_RUNTIME
-#define dprintf_ver if(!debug_msg_enabled[72]) ; else fprintf
-#define debugging_ver debug_msg_enabled[72]
+#define dprintf_ver if(!debug_msg_enabled[71]) ; else fprintf
+#define debugging_ver debug_msg_enabled[71]
 #else
 #ifdef DEBUG_VER
 #define dprintf_ver fprintf
@@ -1517,8 +1497,8 @@
 #endif
 
 #ifdef DEBUG_RUNTIME
-#define dprintf_vxd if(!debug_msg_enabled[73]) ; else fprintf
-#define debugging_vxd debug_msg_enabled[73]
+#define dprintf_vxd if(!debug_msg_enabled[72]) ; else fprintf
+#define debugging_vxd debug_msg_enabled[72]
 #else
 #ifdef DEBUG_VXD
 #define dprintf_vxd fprintf
@@ -1530,8 +1510,8 @@
 #endif
 
 #ifdef DEBUG_RUNTIME
-#define dprintf_win if(!debug_msg_enabled[74]) ; else fprintf
-#define debugging_win debug_msg_enabled[74]
+#define dprintf_win if(!debug_msg_enabled[73]) ; else fprintf
+#define debugging_win debug_msg_enabled[73]
 #else
 #ifdef DEBUG_WIN
 #define dprintf_win fprintf
@@ -1543,8 +1523,8 @@
 #endif
 
 #ifdef DEBUG_RUNTIME
-#define dprintf_win16drv if(!debug_msg_enabled[75]) ; else fprintf
-#define debugging_win16drv debug_msg_enabled[75]
+#define dprintf_win16drv if(!debug_msg_enabled[74]) ; else fprintf
+#define debugging_win16drv debug_msg_enabled[74]
 #else
 #ifdef DEBUG_WIN16DRV
 #define dprintf_win16drv fprintf
@@ -1556,8 +1536,8 @@
 #endif
 
 #ifdef DEBUG_RUNTIME
-#define dprintf_win32 if(!debug_msg_enabled[76]) ; else fprintf
-#define debugging_win32 debug_msg_enabled[76]
+#define dprintf_win32 if(!debug_msg_enabled[75]) ; else fprintf
+#define debugging_win32 debug_msg_enabled[75]
 #else
 #ifdef DEBUG_WIN32
 #define dprintf_win32 fprintf
@@ -1569,8 +1549,8 @@
 #endif
 
 #ifdef DEBUG_RUNTIME
-#define dprintf_winsock if(!debug_msg_enabled[77]) ; else fprintf
-#define debugging_winsock debug_msg_enabled[77]
+#define dprintf_winsock if(!debug_msg_enabled[76]) ; else fprintf
+#define debugging_winsock debug_msg_enabled[76]
 #else
 #ifdef DEBUG_WINSOCK
 #define dprintf_winsock fprintf
@@ -1652,7 +1632,6 @@
     "sendmsg",
     "shm",
     "stress",
-    "syscolor",
     "task",
     "text",
     "timer",
diff --git a/include/hook.h b/include/hook.h
index b9ea056..f3ffd54 100644
--- a/include/hook.h
+++ b/include/hook.h
@@ -9,12 +9,29 @@
 
 #include "windows.h"
 
-#define HOOK_WIN16	0x0
-#define HOOK_WIN32A	0x1
-#define HOOK_WIN32W	0x2
+#define HOOK_WIN16	0x00
+#define HOOK_WIN32A	0x01
+#define HOOK_WIN32W	0x02
+#define HOOK_INUSE	0x80
+
+typedef struct
+{
+   LPARAM   lParam;
+   WPARAM16 wParam;
+   UINT16   message;
+   HWND16   hwnd;
+} CWPSTRUCT16, *LPCWPSTRUCT16;
+
+typedef struct
+{
+  LPARAM        lParam;
+  WPARAM32      wParam;
+  UINT32        message;
+  HWND32        hwnd;
+} CWPSTRUCT32, *LPCWPSTRUCT32;
 
 /* hook type mask */
-#define HOOK_MAPTYPE (3)
+#define HOOK_MAPTYPE (HOOK_WIN16 | HOOK_WIN32A | HOOK_WIN32W)
 
 extern HOOKPROC16 HOOK_GetProc16( HHOOK hhook );
 extern BOOL32 HOOK_IsHooked( INT16 id );
diff --git a/include/listbox.h b/include/listbox.h
index ebee813..d3f97ad 100644
--- a/include/listbox.h
+++ b/include/listbox.h
@@ -24,9 +24,9 @@
 	WORD    DrawCtlType;
         WORD    CtlID;
 	LPLISTSTRUCT lpFirst;
-	HWND	hSelf;
+	HWND16	hSelf;
 	DWORD   dwStyle;      /* added for COMBOLBOX style faking */
-	HWND    hParent;
+	HWND16  hParent;
 	HFONT16 hFont;
 	BOOL    bRedrawFlag;
         BOOL    HasStrings;
@@ -39,7 +39,7 @@
 } HEADLIST,*LPHEADLIST;
 
 /* shared code between listbox and combo controls */
-extern void CreateListBoxStruct(HWND hwnd, WORD CtlType, LONG styles, HWND parent);
+extern void CreateListBoxStruct(HWND16 hwnd, WORD CtlType, LONG styles, HWND16 parent);
 extern void DestroyListBoxStruct(LPHEADLIST lphl);
 
 extern void ListBoxSendNotification(LPHEADLIST lphl, WORD code);
@@ -64,7 +64,7 @@
 extern int ListBoxSetItemHeight(LPHEADLIST lphl, WORD wIndex, long height);
 extern int ListBoxFindNextMatch(LPHEADLIST lphl, WORD wChar);
 
-extern void ListBoxDrawItem (HWND hwnd, LPHEADLIST lphl, HDC16 hdc,
+extern void ListBoxDrawItem (HWND16 hwnd, LPHEADLIST lphl, HDC16 hdc,
 			     LPLISTSTRUCT lpls, RECT16 *rect, WORD itemAction,
 			     WORD itemState);
 extern int ListBoxFindMouse(LPHEADLIST lphl, int X, int Y);
diff --git a/include/mdi.h b/include/mdi.h
index 5db75b6..ee6171f 100644
--- a/include/mdi.h
+++ b/include/mdi.h
@@ -20,27 +20,27 @@
 
 #define WM_MDICALCCHILDSCROLL   0x10AC /* this is exactly what Windows uses */
 
-extern LRESULT MDIClientWndProc(HWND hwnd, UINT message, 
+extern LRESULT MDIClientWndProc(HWND16 hwnd, UINT message, 
 				WPARAM16 wParam, LPARAM lParam); /* mdi.c */
 
 typedef struct tagMDIWCL
 {
-  HWND		 	 hChild;
+  HWND16	 	 hChild;
   struct tagMDIWCL	*prev;
 } MDIWCL;
 
 typedef struct 
 {
     WORD   	nActiveChildren;
-    HWND   	hwndChildMaximized;
-    HWND   	hwndActiveChild;
+    HWND16   	hwndChildMaximized;
+    HWND16   	hwndActiveChild;
     HMENU16  	hWindowMenu;
     WORD   	idFirstChild;
     WORD	nTotalCreated;
     LPSTR 	frameTitle;
     WORD   	sbNeedUpdate;
     WORD   	sbRecalc;
-    HWND   	self;
+    HWND16   	self;
 } MDICLIENTINFO;
 
 #endif /* __WINE_MDI_H */
diff --git a/include/miscemu.h b/include/miscemu.h
index 04e523a..532681f 100644
--- a/include/miscemu.h
+++ b/include/miscemu.h
@@ -11,16 +11,19 @@
 #include "winnt.h"
 
   /* miscemu/dosmem.c */
-extern BOOL32 DOSMEM_Init(void);
-extern void DOSMEM_Tick(void);
-extern void DOSMEM_FillBiosSegment(void);
-extern void DOSMEM_InitMemoryHandling();
-extern LPVOID DOSMEM_RealMode2Linear(DWORD);
-extern WORD DOSMEM_AllocSelector(WORD);
 extern HANDLE16 DOSMEM_BiosSeg;
-extern char *DOSMEM_dosmem;
 extern DWORD DOSMEM_CollateTable;
 
+extern BOOL32 DOSMEM_Init(void);
+extern void   DOSMEM_InitExports(HMODULE16);
+extern void   DOSMEM_Tick(void);
+extern WORD   DOSMEM_AllocSelector(WORD);
+extern LPVOID DOSMEM_GetBlock(UINT32 size, UINT16* p);
+extern BOOL32 DOSMEM_FreeBlock(void* ptr);
+extern LPVOID DOSMEM_MapRealToLinear(DWORD); /* real-mode to linear */
+extern LPVOID DOSMEM_MapDosToLinear(UINT32); /* linear DOS to Wine */
+extern UINT32 DOSMEM_MapLinearToDos(LPVOID); /* linear Wine to DOS */
+
 /* miscemu/interrupts.c */
 extern BOOL32 INT_Init(void);
 
diff --git a/include/mmsystem.h b/include/mmsystem.h
index cd1c9b7..4f96014 100644
--- a/include/mmsystem.h
+++ b/include/mmsystem.h
@@ -506,7 +506,7 @@
 UINT joyGetPos(UINT uJoyID, JOYINFO * lpInfo);
 UINT joyGetThreshold(UINT uJoyID, UINT * lpuThreshold);
 UINT joyReleaseCapture(UINT uJoyID);
-UINT joySetCapture(HWND hwnd, UINT uJoyID, UINT uPeriod,
+UINT joySetCapture(HWND16 hwnd, UINT uJoyID, UINT uPeriod,
     BOOL bChanged);
 UINT joySetThreshold(UINT uJoyID, UINT uThreshold);
 
@@ -652,7 +652,7 @@
 DWORD mciSendCommand (UINT uDeviceID, UINT uMessage,
     DWORD dwParam1, DWORD dwParam2);
 DWORD mciSendString (LPCSTR lpstrCommand,
-    LPSTR lpstrReturnString, UINT uReturnLength, HWND hwndCallback);
+    LPSTR lpstrReturnString, UINT uReturnLength, HWND16 hwndCallback);
 UINT mciGetDeviceID (LPCSTR lpstrName);
 UINT mciGetDeviceIDFromElementID (DWORD dwElementID,
     LPCSTR lpstrType);
@@ -984,7 +984,7 @@
 	DWORD   dwCallback;
 	int     nVirtKey;
 	UINT    wReserved0;
-	HWND    hwndBreak;
+	HWND16  hwndBreak;
 	UINT    wReserved1;
 } MCI_BREAK_PARMS, *LPMCI_BREAK_PARMS;
 
@@ -1219,7 +1219,7 @@
 	LPCSTR  lpstrElementName;
 	LPCSTR  lpstrAlias;
 	DWORD   dwStyle;
-	HWND    hWndParent;
+	HWND16  hWndParent;
 	UINT    wReserved1;
 } MCI_ANIM_OPEN_PARMS, *LPMCI_ANIM_OPEN_PARMS;
 
@@ -1237,7 +1237,7 @@
 
 typedef struct {
 	DWORD   dwCallback;
-	HWND    hWnd;
+	HWND16  hWnd;
 	UINT    wReserved1;
 	UINT    nCmdShow;
 	UINT    wReserved2;
@@ -1299,13 +1299,13 @@
 	LPCSTR  lpstrElementName;
 	LPCSTR  lpstrAlias;
 	DWORD   dwStyle;
-	HWND    hWndParent;
+	HWND16  hWndParent;
 	UINT    wReserved1;
 } MCI_OVLY_OPEN_PARMS, *LPMCI_OVLY_OPEN_PARMS;
 
 typedef struct {
 	DWORD   dwCallback;
-	HWND    hWnd;
+	HWND16  hWnd;
 	UINT    wReserved1;
 	UINT    nCmdShow;
 	UINT    wReserved2;
@@ -1513,7 +1513,7 @@
 DWORD mciGetDriverData(UINT uDeviceID);
 BOOL  mciSetDriverData(UINT uDeviceID, DWORD dwData);
 UINT  mciDriverYield(UINT uDeviceID);
-BOOL  mciDriverNotify(HWND hwndCallback, UINT uDeviceID,
+BOOL  mciDriverNotify(HWND16 hwndCallback, UINT uDeviceID,
     UINT uStatus);
 UINT  mciLoadCommandResource(HINSTANCE16 hInstance,
     LPCSTR lpResName, UINT uType);
diff --git a/include/ntdll.h b/include/ntdll.h
new file mode 100644
index 0000000..820425e
--- /dev/null
+++ b/include/ntdll.h
@@ -0,0 +1,152 @@
+#ifndef __WINE_NTDLL_H
+#define __WINE_NTDLL_H
+/* ntdll.h 
+ *
+ * contains NT internal defines that don't show on the Win32 API level
+ *
+ * Copyright 1997 Marcus Meissner
+ */
+
+/* assumes windows.h already included */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Security Ids of NT */
+
+typedef struct {
+	BYTE	Value[6];
+} SID_IDENTIFIER_AUTHORITY,*LPSID_IDENTIFIER_AUTHORITY;
+
+typedef struct _SID {
+	BYTE	Revision;
+	BYTE	SubAuthorityCount;
+	SID_IDENTIFIER_AUTHORITY	IdentifierAuthority;
+	DWORD	SubAuthority[1];	/* more than one */
+} SID,*LPSID;
+
+#define	SID_REVISION			(1)	/* Current revision */
+#define	SID_MAX_SUB_AUTHORITIES		(15)	/* current max subauths */
+#define	SID_RECOMMENDED_SUB_AUTHORITIES	(1)	/* recommended subauths */
+
+/* ACLs of NT */
+
+#define	ACL_REVISION	2
+
+#define	ACL_REVISION1	1
+#define	ACL_REVISION2	2
+
+typedef struct _ACL {
+	BYTE	AclRevision;
+	BYTE	Sbz1;
+	WORD	AclSize;
+	WORD	AceCount;
+	WORD	Sbz2;
+} ACL,*LPACL;
+
+/* ACEs, directly starting after an ACL */
+typedef struct _ACE_HEADER {
+	BYTE	AceType;
+	BYTE	AceFlags;
+	WORD	AceSize;
+} ACE_HEADER,*LPACE_HEADER;
+
+/* AceType */
+#define	ACCESS_ALLOWED_ACE_TYPE		0
+#define	ACCESS_DENIED_ACE_TYPE		1
+#define	SYSTEM_AUDIT_ACE_TYPE		2
+#define	SYSTEM_ALARM_ACE_TYPE		3
+
+/* inherit AceFlags */
+#define	OBJECT_INHERIT_ACE		0x01
+#define	CONTAINER_INHERIT_ACE		0x02
+#define	NO_PROPAGATE_INHERIT_ACE	0x04
+#define	INHERIT_ONLY_ACE		0x08
+#define	VALID_INHERIT_FLAGS		0x0F
+
+/* AceFlags mask for what events we (should) audit */
+#define	SUCCESSFUL_ACCESS_ACE_FLAG	0x40
+#define	FAILED_ACCESS_ACE_FLAG		0x80
+
+/* different ACEs depending on AceType 
+ * SidStart marks the begin of a SID
+ * so the thing finally looks like this:
+ * 0: ACE_HEADER
+ * 4: ACCESS_MASK
+ * 8... : SID
+ */
+typedef struct _ACCESS_ALLOWED_ACE {
+	ACE_HEADER	Header;
+	DWORD		Mask;
+	DWORD		SidStart;
+} ACCESS_ALLOWED_ACE,*LPACCESS_ALLOWED_ACE;
+
+typedef struct _ACCESS_DENIED_ACE {
+	ACE_HEADER	Header;
+	DWORD		Mask;
+	DWORD		SidStart;
+} ACCESS_DENIED_ACE,*LPACCESS_DENIED_ACE;
+
+typedef struct _SYSTEM_AUDIT_ACE {
+	ACE_HEADER	Header;
+	DWORD		Mask;
+	DWORD		SidStart;
+} SYSTEM_AUDIT_ACE,*LPSYSTEM_AUDIT_ACE;
+
+typedef struct _SYSTEM_ALARM_ACE {
+	ACE_HEADER	Header;
+	DWORD		Mask;
+	DWORD		SidStart;
+} SYSTEM_ALARM_ACE,*LPSYSTEM_ALARM_ACE;
+
+#define	SECURITY_DESCRIPTOR_REVISION	1
+#define	SECURITY_DESCRIPTOR_REVISION1	1
+
+typedef WORD SECURITY_DESCRIPTOR_CONTROL;
+
+#define	SE_OWNER_DEFAULTED	0x0001
+#define	SE_GROUP_DEFAULTED	0x0002
+#define	SE_DACL_PRESENT		0x0004
+#define	SE_DACL_DEFAULTED	0x0008
+#define	SE_SACL_PRESENT		0x0010
+#define	SE_SACL_DEFAULTED	0x0020
+#define	SE_SELF_RELATIVE	0x8000
+
+typedef struct {
+	BYTE	Revision;
+	BYTE	Sbz1;
+	SECURITY_DESCRIPTOR_CONTROL Control;
+	LPSID	Owner;
+	LPSID	Group;
+	LPACL	Sacl;
+	LPACL	Dacl;
+} SECURITY_DESCRIPTOR,*LPSECURITY_DESCRIPTOR;
+
+/* NT lowlevel Strings (handled by Rtl* functions in NTDLL)
+ * If they are zero terminated, Length does not include the terminating 0.
+ */
+
+typedef struct _STRING {
+	UINT16	Length;
+	UINT16	MaximumLength;
+	LPSTR	Buffer;
+} STRING,*LPSTRING,ANSI_STRING,*LPANSI_STRING;
+
+typedef struct _CSTRING {
+	UINT16	Length;
+	UINT16	MaximumLength;
+	LPCSTR	Buffer;
+} CSTRING,*LPCSTRING;
+
+typedef struct _UNICODE_STRING {
+	UINT16	Length;		/* bytes */
+	UINT16	MaximumLength;	/* bytes */
+	LPWSTR	Buffer;
+} UNICODE_STRING,*LPUNICODE_STRING;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif  /* __WINE_NTDLL_H */
diff --git a/include/ole.h b/include/ole.h
index df9ae1a..fdff577 100644
--- a/include/ole.h
+++ b/include/ole.h
@@ -222,7 +222,7 @@
 	OLESTATUS	(*Equal)(LPOLEOBJECT,LPOLEOBJECT);
 	OLESTATUS	(*CopyToClipBoard)(LPOLEOBJECT);
 	OLESTATUS	(*Draw)(LPOLEOBJECT,HDC16,LPRECT16,LPRECT16,HDC16);
-	OLESTATUS	(*Activate)(LPOLEOBJECT,UINT,BOOL,BOOL,HWND,LPRECT16);
+	OLESTATUS	(*Activate)(LPOLEOBJECT,UINT,BOOL,BOOL,HWND16,LPRECT16);
 	OLESTATUS	(*Execute)(LPOLEOBJECT,HGLOBAL16,UINT);
 	OLESTATUS	(*Close)(LPOLEOBJECT);
 	OLESTATUS	(*Update)(LPOLEOBJECT);
diff --git a/include/options.h b/include/options.h
index 6fcf570..421f3e6 100644
--- a/include/options.h
+++ b/include/options.h
@@ -22,7 +22,8 @@
     LANG_Cz,  /* Czech */
     LANG_Eo,  /* Esperanto */
     LANG_It,  /* Italian */
-    LANG_Ko   /* Korean */
+    LANG_Ko,  /* Korean */
+    LANG_Hu   /* Hungarian */
 } WINE_LANGUAGE;
 
 typedef struct
diff --git a/include/static.h b/include/static.h
index 0dd624e..c664cc4 100644
--- a/include/static.h
+++ b/include/static.h
@@ -17,6 +17,6 @@
     HICON16  hIcon;   /* Icon handle for SS_ICON controls */ 
 } STATICINFO;
 
-extern LRESULT StaticWndProc(HWND hWnd,UINT uMsg,WPARAM16 wParam,LPARAM lParam );
+extern LRESULT StaticWndProc(HWND16 hWnd,UINT uMsg,WPARAM16 wParam,LPARAM lParam );
 
 #endif  /* __WINE_STATIC_H */
diff --git a/include/stddebug.h b/include/stddebug.h
index 8f7190b..d09f25d 100644
--- a/include/stddebug.h
+++ b/include/stddebug.h
@@ -143,7 +143,6 @@
 #undef DEBUG_SENDMSG
 #undef DEBUG_SHM
 #undef DEBUG_STRESS
-#undef DEBUG_SYSCOLOR
 #undef DEBUG_TASK
 #undef DEBUG_TEXT
 #undef DEBUG_TIMER
@@ -224,7 +223,6 @@
 #define DEBUG_SENDMSG
 #define DEBUG_SHM
 #define DEBUG_STRESS
-#define DEBUG_SYSCOLOR
 #define DEBUG_TASK
 #define DEBUG_TEXT
 #define DEBUG_TIMER
diff --git a/include/win.h b/include/win.h
index b8b778a..0179249 100644
--- a/include/win.h
+++ b/include/win.h
@@ -57,7 +57,7 @@
     struct tagDCE *dce;           /* Window DCE (if CS_OWNDC or CS_CLASSDC) */
     HGLOBAL16      hmemTaskQ;     /* Task queue global memory handle */
     HRGN16         hrgnUpdate;    /* Update region */
-    HWND16         hwndLastActive;/* Last active popup hwnd */
+    HWND32         hwndLastActive;/* Last active popup hwnd */
     DWORD          dwStyle;       /* Window style (from CreateWindow) */
     DWORD          dwExStyle;     /* Extended style (from CreateWindowEx) */
     UINT16         wIDmenu;       /* ID or hmenu (from CreateWindow) */
@@ -79,7 +79,8 @@
 #define WIN_NCACTIVATED        0x0080 /* last WM_NCACTIVATE was positive */
 #define WIN_MANAGED            0x0100 /* Window managed by the X wm */
 #define WIN_ISDIALOG           0x0200 /* Window is a dialog */
-#define WIN_SAVEUNDER_OVERRIDE 0x0400
+#define WIN_ISWIN32            0x0400 /* Understands Win32 messages */
+#define WIN_SAVEUNDER_OVERRIDE 0x0800
 
   /* Window functions */
 extern WND *WIN_FindWndPtr( HWND32 hwnd );
diff --git a/include/winbase.h b/include/winbase.h
index 919124f..45ce754 100644
--- a/include/winbase.h
+++ b/include/winbase.h
@@ -53,11 +53,14 @@
 #define	STATUS_BUFFER_OVERFLOW           0x80000005
 #define STATUS_ACCESS_VIOLATION          0xC0000005    
 #define STATUS_IN_PAGE_ERROR             0xC0000006    
+#define STATUS_INVALID_PARAMETER         0xC000000D
 #define STATUS_NO_MEMORY                 0xC0000017    
 #define STATUS_ILLEGAL_INSTRUCTION       0xC000001D    
 #define	STATUS_BUFFER_TOO_SMALL          0xC0000023
 #define STATUS_NONCONTINUABLE_EXCEPTION  0xC0000025    
 #define STATUS_INVALID_DISPOSITION       0xC0000026    
+#define	STATUS_UNKNOWN_REVISION          0xC0000058
+#define	STATUS_INVALID_SECURITY_DESCR    0xC0000079
 #define STATUS_ARRAY_BOUNDS_EXCEEDED     0xC000008C    
 #define STATUS_FLOAT_DENORMAL_OPERAND    0xC000008D    
 #define STATUS_FLOAT_DIVIDE_BY_ZERO      0xC000008E    
diff --git a/include/windows.h b/include/windows.h
index 338bf13..3bc9505 100644
--- a/include/windows.h
+++ b/include/windows.h
@@ -239,6 +239,11 @@
 #define MDITILE_HORIZONTAL  1
 #define MDIS_ALLCHILDSTYLES 0x0001
 
+typedef struct {
+    DWORD   styleOld;
+    DWORD   styleNew;
+} STYLESTRUCT, *LPSTYLESTRUCT;
+
   /* Offsets for GetWindowLong() and GetWindowWord() */
 #define GWL_USERDATA        (-21)
 #define GWL_EXSTYLE         (-20)
@@ -2444,13 +2449,28 @@
 #define WM_OTHERWINDOWDESTROYED	0x003d
 #define WM_ACTIVATESHELLWINDOW	0x003e
 
-#define WM_COMPACTING	    0x0041
+#define WM_COMPACTING		0x0041
 
-#define WM_COMMNOTIFY	    0x0044
-#define WM_WINDOWPOSCHANGING 0x0046
-#define WM_WINDOWPOSCHANGED  0x0047
-#define WM_POWER	    0x0048
+#define WM_COMMNOTIFY		0x0044
+#define WM_WINDOWPOSCHANGING 	0x0046
+#define WM_WINDOWPOSCHANGED 	0x0047
+#define WM_POWER		0x0048
 
+  /* Win32 4.0 messages */
+#define WM_COPYDATA		0x004a
+#define WM_CANCELJOURNAL	0x004b
+#define WM_NOTIFY		0x004e
+#define WM_HELP			0x0053
+#define WM_NOTIFYFORMAT		0x0055
+
+#define WM_CONTEXTMENU		0x007b
+#define WM_STYLECHANGING 	0x007c
+#define WM_STYLECHANGED		0x007d
+
+#define WM_GETICON		0x007f
+#define WM_SETICON		0x0080
+
+  /* Non-client system messages */
 #define WM_NCCREATE         0x0081
 #define WM_NCDESTROY        0x0082
 #define WM_NCCALCSIZE       0x0083
@@ -2534,6 +2554,12 @@
 #define WM_EXITMENULOOP     0x0212
 #define WM_NEXTMENU	    0x0213
 
+  /* Win32 4.0 messages */
+#define WM_SIZING	    0x0214
+#define WM_CAPTURECHANGED   0x0215
+#define WM_MOVING	    0x0216
+
+  /* MDI messages */
 #define WM_MDICREATE	    0x0220
 #define WM_MDIDESTROY	    0x0221
 #define WM_MDIACTIVATE	    0x0222
@@ -2544,6 +2570,8 @@
 #define WM_MDICASCADE	    0x0227
 #define WM_MDIICONARRANGE   0x0228
 #define WM_MDIGETACTIVE     0x0229
+
+  /* D&D messages */
 #define WM_DROPOBJECT	    0x022A
 #define WM_QUERYDROPOBJECT  0x022B
 #define WM_BEGINDRAG	    0x022C
@@ -2574,6 +2602,10 @@
 #define WM_QUERYNEWPALETTE   0x030F
 #define WM_PALETTEISCHANGING 0x0310
 #define WM_PALETTECHANGED    0x0311
+#define WM_HOTKEY	     0x0312
+
+#define WM_PRINT             0x0317
+#define WM_PRINTCLIENT       0x0318
 
 #define WM_COALESCE_FIRST    0x0390
 #define WM_COALESCE_LAST     0x039F
@@ -2669,7 +2701,7 @@
 #define SWP_NOSENDCHANGING  0x0400
 #define SWP_DEFERERASE      0x2000
 
-#define HWND_BROADCAST	    ((HWND)0xffff)
+#define HWND_BROADCAST      ((HWND32)0xffff)
 
 /* SetWindowPos() hwndInsertAfter field values */
 #define HWND_TOP            ((HWND32)0)
@@ -4035,6 +4067,18 @@
 /* Win32-specific structures */
 
 typedef struct {
+    DWORD dwData;
+    DWORD cbData;
+    LPVOID lpData;
+} COPYDATASTRUCT, *PCOPYDATASTRUCT, *LPCOPYDATASTRUCT;
+
+typedef struct {
+    HMENU32 hmenuIn;
+    HMENU32 hmenuNext;
+    HWND32  hwndNext;
+} MDINEXTMENU, *PMDINEXTMENU, *LPMDINEXTMENU;
+
+typedef struct {
         WORD wYear;
         WORD wMonth;
         WORD wDayOfWeek;
@@ -4189,6 +4233,17 @@
 #define FILE_ATTRIBUTE_XACTION_WRITE    0x0400
 #define FILE_ATTRIBUTE_COMPRESSED       0x0800
 
+/* File alignments (NT) */
+#define	FILE_BYTE_ALIGNMENT		0x00000000
+#define	FILE_WORD_ALIGNMENT		0x00000001
+#define	FILE_LONG_ALIGNMENT		0x00000003
+#define	FILE_QUAD_ALIGNMENT		0x00000007
+#define	FILE_OCTA_ALIGNMENT		0x0000000f
+#define	FILE_32_BYTE_ALIGNMENT		0x0000001f
+#define	FILE_64_BYTE_ALIGNMENT		0x0000003f
+#define	FILE_128_BYTE_ALIGNMENT		0x0000007f
+#define	FILE_256_BYTE_ALIGNMENT		0x000000ff
+#define	FILE_512_BYTE_ALIGNMENT		0x000001ff
 
 /* WinHelp internal structure */
 typedef struct {
@@ -4487,45 +4542,6 @@
 DECL_WINELIB_TYPE_AW(SERVICE_TABLE_ENTRY);
 DECL_WINELIB_TYPE_AW(LPSERVICE_TABLE_ENTRY);
 
-/* Security Ids of NT */
-
-typedef struct {
-	BYTE	Value[6];
-} SID_IDENTIFIER_AUTHORITY,*LPSID_IDENTIFIER_AUTHORITY;
-
-typedef struct _SID {
-	BYTE	Revision;
-	BYTE	SubAuthorityCount;
-	SID_IDENTIFIER_AUTHORITY	IdentifierAuthority;
-	DWORD	SubAuthority[1];	/* more than one */
-} SID,*LPSID;
-
-#define	SID_REVISION			(1)	/* Current revision */
-#define	SID_MAX_SUB_AUTHORITIES		(15)	/* current max subauths */
-#define	SID_RECOMMENDED_SUB_AUTHORITIES	(1)	/* recommended subauths */
-
-/* NT lowlevel Strings (handled by Rtl* functions in NTDLL)
- * If they are zero terminated, Length does not include the terminating 0.
- */
-
-typedef struct _STRING {
-	UINT16	Length;
-	UINT16	MaximumLength;
-	LPSTR	Buffer;
-} STRING,*LPSTRING,ANSI_STRING,*LPANSI_STRING;
-
-typedef struct _CSTRING {
-	UINT16	Length;
-	UINT16	MaximumLength;
-	LPCSTR	Buffer;
-} CSTRING,*LPCSTRING;
-
-typedef struct _UNICODE_STRING {
-	UINT16	Length;		/* bytes */
-	UINT16	MaximumLength;	/* bytes */
-	LPWSTR	Buffer;
-} UNICODE_STRING,*LPUNICODE_STRING;
-
 /* {G,S}etPriorityClass */
 #define	NORMAL_PRIORITY_CLASS	0x00000020
 #define	IDLE_PRIORITY_CLASS	0x00000040
@@ -4651,14 +4667,17 @@
 WORD       AllocDStoCSAlias(WORD);
 WORD       AllocSelector(WORD);
 WORD       AllocSelectorArray(WORD);
+VOID       CalcChildScroll(HWND16,WORD);
 INT16      Catch(LPCATCHBUF);
 WORD       ChangeSelector(WORD,WORD);
 INT16      CloseComm(INT16);
+HGLOBAL16  CreateCursorIconIndirect(HINSTANCE16,CURSORICONINFO*,LPCVOID,LPCVOID);
 BOOL16     DCHook(HDC16,WORD,DWORD,LPARAM);
 VOID       DirectedYield(HTASK16);
 HGLOBAL16  DirectResAlloc(HINSTANCE16,WORD,UINT16);
 BOOL16     DlgDirSelect(HWND16,LPSTR,INT16);
 BOOL16     DlgDirSelectComboBox(HWND16,LPSTR,INT16);
+DWORD      DumpIcon(SEGPTR,WORD*,SEGPTR*,SEGPTR*);
 BOOL16     EnableHardwareInput(BOOL16);
 INT16      ExcludeVisRect(HDC16,INT16,INT16,INT16,INT16);
 HANDLE16   FarGetOwner(HGLOBAL16);
@@ -4667,12 +4686,15 @@
 VOID       FillWindow(HWND16,HWND16,HDC16,HBRUSH16);
 INT16      FlushComm(INT16,INT16);
 WORD       FreeSelector(WORD);
+UINT16     GDIRealizePalette(HDC16);
+HPALETTE16 GDISelectPalette(HDC16,HPALETTE16,WORD);
 HANDLE16   GetAtomHandle(ATOM);
 DWORD      GetBitmapDimension(HBITMAP16);
 DWORD      GetBrushOrg(HDC16);
 HANDLE16   GetCodeHandle(FARPROC16);
 INT16      GetCommError(INT16,LPCOMSTAT);
 UINT16     GetCommEventMask(INT16,UINT16);
+HBRUSH16   GetControlBrush(HWND16,HDC16,UINT16);
 VOID       GetCodeInfo(FARPROC16,LPVOID);
 HANDLE16   GetCurrentPDB(void);
 DWORD      GetCurrentPosition(HDC16);
@@ -4681,10 +4703,13 @@
 DWORD      GetDCOrg(HDC16);
 HDC16      GetDCState(HDC16);
 HWND16     GetDesktopHwnd(void);
+SEGPTR     GetDOSEnvironment(void);
 HMODULE16  GetExePtr(HANDLE16);
 WORD       GetExeVersion(void);
+DWORD      GetHeapSpaces(HMODULE16);
 INT16      GetKbCodePage(VOID);
 INT16      GetInstanceData(HINSTANCE16,WORD,INT16);
+HGLOBAL16  GetMetaFileBits(HMETAFILE16);
 BOOL16     GetModuleName(HINSTANCE16,LPSTR,INT16);
 FARPROC16  GetMouseEventProc(void);
 UINT16     GetNumTasks(void);
@@ -4692,9 +4717,11 @@
 DWORD      GetSelectorLimit(WORD);
 HINSTANCE16 GetTaskDS(void);
 HQUEUE16   GetTaskQueue(HTASK16);
+BYTE       GetTempDrive(BYTE);
 DWORD      GetTextExtent(HDC16,LPCSTR,INT16);
 DWORD      GetViewportExt(HDC16);
 DWORD      GetViewportOrg(HDC16);
+BOOL16     GetWinDebugInfo(LPWINDEBUGINFO,UINT16);
 DWORD      GetWindowExt(HDC16);
 DWORD      GetWindowOrg(HDC16);
 DWORD      GetWinFlags(void);
@@ -4709,11 +4736,14 @@
 INT16      InitApp(HINSTANCE16);
 HRGN16     InquireVisRgn(HDC16);
 INT16      IntersectVisRect(HDC16,INT16,INT16,INT16,INT16);
+BOOL16     IsDCCurrentPalette(HDC16);
 BOOL16     IsGDIObject(HGDIOBJ16);
 BOOL16     IsSharedSelector(HANDLE16);
 BOOL16     IsTask(HTASK16);
 HTASK16    IsTaskLocked(void);
+BOOL16     IsValidMetaFile(HMETAFILE16);
 BOOL16     LocalInit(HANDLE16,WORD,WORD);
+FARPROC16  LocalNotify(FARPROC16);
 HTASK16    LockCurrentTask(BOOL16);
 HMENU16    LookupMenuHandle(HMENU16,INT16);
 DWORD      MoveTo(HDC16,INT16,INT16);
@@ -4726,6 +4756,7 @@
 VOID       PostEvent(HTASK16);
 WORD       PrestoChangoSelector(WORD,WORD);
 INT16      ReadComm(INT16,LPSTR,INT16);
+UINT16     RealizeDefaultPalette(HDC16);
 INT16      RestoreVisRgn(HDC16);
 HRGN16     SaveVisRgn(HDC16);
 DWORD      ScaleViewportExt(HDC16,INT16,INT16,INT16,INT16);
@@ -4739,7 +4770,10 @@
 DWORD      SetDCOrg(HDC16,INT16,INT16);
 VOID       SetDCState(HDC16,HDC16);
 BOOL16     SetDeskPattern(void);
+WORD       SetHookFlags(HDC16,WORD);
+HMETAFILE16 SetMetaFileBits(HGLOBAL16);
 VOID       SetPriority(HTASK16,INT16);
+FARPROC16  SetResourceHandler(HINSTANCE16,LPSTR,FARPROC16);
 WORD       SetSelectorBase(WORD,DWORD);
 WORD       SetSelectorLimit(WORD,DWORD);
 LONG       SetSwapAreaSize(WORD);
@@ -4747,6 +4781,7 @@
 FARPROC16  SetTaskSignalProc(HTASK16,FARPROC16);
 DWORD      SetViewportExt(HDC16,INT16,INT16);
 DWORD      SetViewportOrg(HDC16,INT16,INT16);
+BOOL16     SetWinDebugInfo(LPWINDEBUGINFO);
 DWORD      SetWindowExt(HDC16,INT16,INT16);
 DWORD      SetWindowOrg(HDC16,INT16,INT16);
 VOID       SwitchStackBack(void);
@@ -4797,6 +4832,9 @@
 BOOL32     EnumThreadWindows(DWORD,WNDENUMPROC32,LPARAM);
 void       ExitProcess(DWORD);
 BOOL32     ExitWindowsEx(UINT32,DWORD);
+DWORD      ExpandEnvironmentStrings32A(LPCSTR,LPSTR,DWORD);
+DWORD      ExpandEnvironmentStrings32W(LPCWSTR,LPWSTR,DWORD);
+#define    ExpandEnvironmentStrings WINELIB_NAME_AW(ExpandEnvironmentStrings)
 BOOL32     FileTimeToDosDateTime(const FILETIME*,LPWORD,LPWORD);
 BOOL32     FileTimeToLocalFileTime(const FILETIME*,LPFILETIME);
 BOOL32     FileTimeToSystemTime(const FILETIME*,LPSYSTEMTIME);
@@ -4934,12 +4972,12 @@
 
 /* Declarations for functions that are the same in Win16 and Win32 */
 
+VOID       CloseSound(VOID);
 HBITMAP16  CreateBitmap(INT32,INT32,UINT32,UINT32,LPCVOID);
 BOOL16     CreateCaret(HWND32,HBITMAP32,INT32,INT32);
 HBITMAP16  CreateCompatibleBitmap(HDC32,INT32,INT32);
 HBITMAP16  CreateDiscardableBitmap(HDC32,INT32,INT32);
 BOOL16     DestroyCaret(void);
-BOOL16     EndDialog(HWND32,INT32);
 INT16      ExcludeUpdateRgn(HDC32,HWND32);
 DWORD      GetAppCompatFlags(HTASK32);
 LONG       GetBitmapBits(HBITMAP32,LONG,LPVOID);
@@ -4948,15 +4986,16 @@
 VOID       GetKeyboardState(LPBYTE);
 DWORD      GetLastError(void);
 DWORD      GetMenuCheckMarkDimensions(void);
-COLORREF   GetSysColor(INT32);
+LONG       GetMessageExtraInfo(void);
+DWORD      GetMessagePos(void);
+LONG       GetMessageTime(void);
 DWORD      GetTickCount(void);
 INT16      GetUpdateRgn(HWND32,HRGN32,BOOL32);
 WORD       GetWindowWord(HWND32,INT32);
-BOOL16     HideCaret(HWND32);
+ATOM       GlobalDeleteAtom(ATOM);
 BOOL16     IsWindow(HWND32);
 VOID       LZDone(void);
 DWORD      OemKeyScan(WORD);
-UINT16     RealizePalette(HDC32);
 DWORD      RegCloseKey(HKEY);
 DWORD      RegFlushKey(HKEY);
 VOID       ReleaseCapture(void);
@@ -4970,14 +5009,18 @@
 VOID       SetRectRgn(HRGN32,INT32,INT32,INT32,INT32);
 COLORREF   SetTextColor(HDC32,COLORREF);
 WORD       SetWindowWord(HWND32,INT32,WORD);
-BOOL16     ShowCaret(HWND32);
 VOID       UpdateWindow(HWND32);
+VOID       WaitMessage(VOID);
 
 /* Declarations for functions that change between Win16 and Win32 */
 
 INT16      AccessResource16(HINSTANCE16,HRSRC16);
 INT32      AccessResource32(HINSTANCE32,HRSRC32);
 #define    AccessResource WINELIB_NAME(AccessResource)
+ATOM       AddAtom16(SEGPTR);
+ATOM       AddAtom32A(LPCSTR);
+ATOM       AddAtom32W(LPCWSTR);
+#define    AddAtom WINELIB_NAME_AW(AddAtom)
 BOOL16     AdjustWindowRect16(LPRECT16,DWORD,BOOL16);
 BOOL32     AdjustWindowRect32(LPRECT32,DWORD,BOOL32);
 #define    AdjustWindowRect WINELIB_NAME(AdjustWindowRect)
@@ -4987,6 +5030,9 @@
 HGLOBAL16  AllocResource16(HINSTANCE16,HRSRC16,DWORD);
 HGLOBAL32  AllocResource32(HINSTANCE32,HRSRC32,DWORD);
 #define    AllocResource WINELIB_NAME(AllocResource)
+BOOL16     AnimatePalette16(HPALETTE16,UINT16,UINT16,LPPALETTEENTRY);
+BOOL32     AnimatePalette32(HPALETTE32,UINT32,UINT32,LPPALETTEENTRY);
+#define    AnimatePalette WINELIB_NAME(AnimatePalette)
 SEGPTR     AnsiLower16(SEGPTR);
 #define    AnsiLower32A CharLower32A
 #define    AnsiLower32W CharLower32W
@@ -5019,6 +5065,9 @@
 #define    AnsiUpperBuff32A CharUpperBuff32A
 #define    AnsiUpperBuff32W CharUpperBuff32W
 #define    AnsiUpperBuff WINELIB_NAME_AW(AnsiUpperBuff)
+BOOL16     AnyPopup16(void);
+BOOL32     AnyPopup32(void);
+#define    AnyPopup WINELIB_NAME(AnyPopup)
 BOOL16     AppendMenu16(HMENU16,UINT16,UINT16,SEGPTR);
 BOOL32     AppendMenu32A(HMENU32,UINT32,UINT32,LPCSTR);
 BOOL32     AppendMenu32W(HMENU32,UINT32,UINT32,LPCWSTR);
@@ -5048,6 +5097,10 @@
 BOOL32     BuildCommDCBAndTimeouts32A(LPCSTR,LPDCB32,LPCOMMTIMEOUTS);
 BOOL32     BuildCommDCBAndTimeouts32W(LPCWSTR,LPDCB32,LPCOMMTIMEOUTS);
 #define    BuildCommDCBAndTimeouts WINELIB_NAME_AW(BuildCommDCBAndTimeouts)
+BOOL16     CallMsgFilter16(SEGPTR,INT16);
+BOOL32     CallMsgFilter32A(LPMSG32,INT32);
+BOOL32     CallMsgFilter32W(LPMSG32,INT32);
+#define    CallMsgFilter WINELIB_NAME_AW(CallMsgFilter)
 LRESULT    CallNextHookEx16(HHOOK,INT16,WPARAM16,LPARAM);
 LRESULT    CallNextHookEx32(HHOOK,INT32,WPARAM32,LPARAM);
 #define    CallNextHookEx WINELIB_NAME(CallNextHookEx)
@@ -5116,9 +5169,15 @@
 BOOL16     ClipCursor16(const RECT16*);
 BOOL32     ClipCursor32(const RECT32*);
 #define    ClipCursor WINELIB_NAME(ClipCursor)
+BOOL16     CloseClipboard16(void);
+BOOL32     CloseClipboard32(void);
+#define    CloseClipboard WINELIB_NAME(CloseClipboard)
 HMETAFILE16 CloseMetaFile16(HDC16);
 HMETAFILE32 CloseMetaFile32(HDC32);
 #define    CloseMetaFile WINELIB_NAME(CloseMetaFile)
+BOOL16     CloseWindow16(HWND16);
+BOOL32     CloseWindow32(HWND32);
+#define    CloseWindow WINELIB_NAME(CloseWindow)
 INT16      CombineRgn16(HRGN16,HRGN16,HRGN16,INT16);
 INT32      CombineRgn32(HRGN32,HRGN32,HRGN32,INT32);
 #define    CombineRgn WINELIB_NAME(CombineRgn)
@@ -5135,9 +5194,19 @@
 LONG       CopyLZFile16(HFILE16,HFILE16);
 LONG       CopyLZFile32(HFILE32,HFILE32);
 #define    CopyLZFile WINELIB_NAME(CopyLZFile)
+HMETAFILE16 CopyMetaFile16(HMETAFILE16,LPCSTR);
+HMETAFILE32 CopyMetaFile32A(HMETAFILE32,LPCSTR);
+HMETAFILE32 CopyMetaFile32W(HMETAFILE32,LPCWSTR);
+#define    CopyMetaFile WINELIB_NAME_AW(CopyMetaFile)
 BOOL16     CopyRect16(RECT16*,const RECT16*);
 BOOL32     CopyRect32(RECT32*,const RECT32*);
 #define    CopyRect WINELIB_NAME(CopyRect)
+INT16      CountClipboardFormats16(void);
+INT32      CountClipboardFormats32(void);
+#define    CountClipboardFormats WINELIB_NAME(CountClipboardFormats)
+INT16      CountVoiceNotes16(INT16);
+DWORD      CountVoiceNotes32(DWORD);
+#define    CountVoiceNotes WINELIB_NAME(CountVoiceNotes)
 HBITMAP16  CreateBitmapIndirect16(const BITMAP16*);
 HBITMAP32  CreateBitmapIndirect32(const BITMAP32*);
 #define    CreateBitmapIndirect WINELIB_NAME(CreateBitmapIndirect)
@@ -5147,6 +5216,9 @@
 HDC16      CreateCompatibleDC16(HDC16);
 HDC32      CreateCompatibleDC32(HDC32);
 #define    CreateCompatibleDC WINELIB_NAME(CreateCompatibleDC)
+HCURSOR16  CreateCursor16(HINSTANCE16,INT16,INT16,INT16,INT16,LPCVOID,LPCVOID);
+HCURSOR32  CreateCursor32(HINSTANCE32,INT32,INT32,INT32,INT32,LPCVOID,LPCVOID);
+#define    CreateCursor WINELIB_NAME(CreateCursor)
 HDC16      CreateDC16(LPCSTR,LPCSTR,LPCSTR,const DEVMODE16*);
 HDC32      CreateDC32A(LPCSTR,LPCSTR,LPCSTR,const DEVMODE32A*);
 HDC32      CreateDC32W(LPCWSTR,LPCWSTR,LPCWSTR,const DEVMODE32W*);
@@ -5207,6 +5279,9 @@
 HDC32      CreateIC32A(LPCSTR,LPCSTR,LPCSTR,const DEVMODE32A*);
 HDC32      CreateIC32W(LPCWSTR,LPCWSTR,LPCWSTR,const DEVMODE32W*);
 #define    CreateIC WINELIB_NAME_AW(CreateIC)
+HICON16    CreateIcon16(HINSTANCE16,INT16,INT16,BYTE,BYTE,LPCVOID,LPCVOID);
+HICON32    CreateIcon32(HINSTANCE32,INT32,INT32,BYTE,BYTE,LPCVOID,LPCVOID);
+#define    CreateIcon WINELIB_NAME(CreateIcon)
 HMENU16    CreateMenu16(void);
 HMENU32    CreateMenu32(void);
 #define    CreateMenu WINELIB_NAME(CreateMenu)
@@ -5214,6 +5289,9 @@
 HDC32      CreateMetaFile32A(LPCSTR);
 HDC32      CreateMetaFile32W(LPCWSTR);
 #define    CreateMetaFile WINELIB_NAME_AW(CreateMetaFile)
+HPALETTE16 CreatePalette16(const LOGPALETTE*);
+HPALETTE32 CreatePalette32(const LOGPALETTE*);
+#define    CreatePalette WINELIB_NAME(CreatePalette)
 HBRUSH16   CreatePatternBrush16(HBITMAP16);
 HBRUSH32   CreatePatternBrush32(HBITMAP32);
 #define    CreatePatternBrush WINELIB_NAME(CreatePatternBrush)
@@ -5281,6 +5359,9 @@
 LRESULT    DefWindowProc32A(HWND32,UINT32,WPARAM32,LPARAM);
 LRESULT    DefWindowProc32W(HWND32,UINT32,WPARAM32,LPARAM);
 #define    DefWindowProc WINELIB_NAME_AW(DefWindowProc)
+ATOM       DeleteAtom16(ATOM);
+ATOM       DeleteAtom32(ATOM);
+#define    DeleteAtom WINELIB_NAME(DeleteAtom)
 BOOL16     DeleteDC16(HDC16);
 BOOL32     DeleteDC32(HDC32);
 #define    DeleteDC WINELIB_NAME(DeleteDC)
@@ -5297,6 +5378,12 @@
 BOOL16     DeleteObject16(HGDIOBJ16);
 BOOL32     DeleteObject32(HGDIOBJ32);
 #define    DeleteObject WINELIB_NAME(DeleteObject)
+BOOL16     DestroyCursor16(HCURSOR16);
+BOOL32     DestroyCursor32(HCURSOR32);
+#define    DestroyCursor WINELIB_NAME(DestroyCursor)
+BOOL16     DestroyIcon16(HICON16);
+BOOL32     DestroyIcon32(HICON32);
+#define    DestroyIcon WINELIB_NAME(DestroyIcon)
 BOOL16     DestroyMenu16(HMENU16);
 BOOL32     DestroyMenu32(HMENU32);
 #define    DestroyMenu WINELIB_NAME(DestroyMenu)
@@ -5323,6 +5410,10 @@
 INT32      DialogBoxParam32A(HINSTANCE32,LPCSTR,HWND32,DLGPROC32,LPARAM);
 INT32      DialogBoxParam32W(HINSTANCE32,LPCWSTR,HWND32,DLGPROC32,LPARAM);
 #define    DialogBoxParam WINELIB_NAME_AW(DialogBoxParam)
+LONG       DispatchMessage16(const MSG16*);
+LONG       DispatchMessage32A(const MSG32*);
+LONG       DispatchMessage32W(const MSG32*);
+#define    DispatchMessage WINELIB_NAME_AW(DispatchMessage)
 INT16      DlgDirList16(HWND16,LPCSTR,INT16,INT16,UINT16);
 INT32      DlgDirList32A(HWND32,LPCSTR,INT32,INT32,UINT32);
 INT32      DlgDirList32W(HWND32,LPCWSTR,INT32,INT32,UINT32);
@@ -5342,6 +5433,9 @@
 BOOL16     DPtoLP16(HDC16,LPPOINT16,INT16);
 BOOL32     DPtoLP32(HDC32,LPPOINT32,INT32);
 #define    DPtoLP WINELIB_NAME(DPtoLP)
+BOOL16     DragDetect16(HWND16,POINT16);
+BOOL32     DragDetect32(HWND32,POINT32);
+#define    DragDetect WINELIB_NAME(DragDetect)
 BOOL16     DrawEdge16(HDC16,LPRECT16,UINT16,UINT16);
 BOOL32     DrawEdge32(HDC32,LPRECT32,UINT32,UINT32);
 #define    DrawEdge WINELIB_NAME(DrawEdge)
@@ -5351,6 +5445,9 @@
 BOOL16     DrawFrameControl16(HDC16,LPRECT16,UINT16,UINT16);
 BOOL32     DrawFrameControl32(HDC32,LPRECT32,UINT32,UINT32);
 #define    DrawFrameControl WINELIB_NAME(DrawFrameControl)
+BOOL16     DrawIcon16(HDC16,INT16,INT16,HICON16);
+BOOL32     DrawIcon32(HDC32,INT32,INT32,HICON32);
+#define    DrawIcon WINELIB_NAME(DrawIcon)
 VOID       DrawMenuBar16(HWND16);
 BOOL32     DrawMenuBar32(HWND32);
 #define    DrawMenuBar WINELIB_NAME(DrawMenuBar)
@@ -5361,6 +5458,9 @@
 BOOL16     Ellipse16(HDC16,INT16,INT16,INT16,INT16);
 BOOL32     Ellipse32(HDC32,INT32,INT32,INT32,INT32);
 #define    Ellipse WINELIB_NAME(Ellipse)
+BOOL16     EmptyClipboard16(void);
+BOOL32     EmptyClipboard32(void);
+#define    EmptyClipboard WINELIB_NAME(EmptyClipboard)
 BOOL16     EnableMenuItem16(HMENU16,UINT16,UINT16);
 BOOL32     EnableMenuItem32(HMENU32,UINT32,UINT32);
 #define    EnableMenuItem WINELIB_NAME(EnableMenuItem)
@@ -5373,12 +5473,18 @@
 BOOL16     EndDeferWindowPos16(HDWP16);
 BOOL32     EndDeferWindowPos32(HDWP32);
 #define    EndDeferWindowPos WINELIB_NAME(EndDeferWindowPos)
+BOOL16     EndDialog16(HWND16,INT16);
+BOOL32     EndDialog32(HWND32,INT32);
+#define    EndDialog WINELIB_NAME(EndDialog)
 BOOL16     EndPaint16(HWND16,const PAINTSTRUCT16*);
 BOOL32     EndPaint32(HWND32,const PAINTSTRUCT32*);
 #define    EndPaint WINELIB_NAME(EndPaint)
 BOOL16     EnumChildWindows16(HWND16,WNDENUMPROC16,LPARAM);
 BOOL32     EnumChildWindows32(HWND32,WNDENUMPROC32,LPARAM);
 #define    EnumChildWindows WINELIB_NAME(EnumChildWindows)
+UINT16     EnumClipboardFormats16(UINT16);
+UINT32     EnumClipboardFormats32(UINT32);
+#define    EnumClipboardFormats WINELIB_NAME(EnumClipboardFormats)
 INT16      EnumFontFamilies16(HDC16,LPCSTR,FONTENUMPROC16,LPARAM);
 INT32      EnumFontFamilies32A(HDC32,LPCSTR,FONTENUMPROC32A,LPARAM);
 INT32      EnumFontFamilies32W(HDC32,LPCWSTR,FONTENUMPROC32W,LPARAM);
@@ -5440,6 +5546,10 @@
 BOOL16     FillRgn16(HDC16,HRGN16,HBRUSH16);
 BOOL32     FillRgn32(HDC32,HRGN32,HBRUSH32);
 #define    FillRgn WINELIB_NAME(FillRgn)
+ATOM       FindAtom16(SEGPTR);
+ATOM       FindAtom32A(LPCSTR);
+ATOM       FindAtom32W(LPCWSTR);
+#define    FindAtom WINELIB_NAME_AW(FindAtom)
 BOOL16     FindClose16(HANDLE16);
 BOOL32     FindClose32(HANDLE32);
 #define    FindClose WINELIB_NAME(FindClose)
@@ -5463,6 +5573,9 @@
 HWND32     FindWindowEx32A(HWND32,HWND32,LPCSTR,LPCSTR);
 HWND32     FindWindowEx32W(HWND32,HWND32,LPCWSTR,LPCWSTR);
 #define    FindWindowEx WINELIB_NAME_AW(FindWindowEx)
+BOOL16     FlashWindow16(HWND16,BOOL16);
+BOOL32     FlashWindow32(HWND32,BOOL32);
+#define    FlashWindow WINELIB_NAME(FlashWindow)
 BOOL16     FloodFill16(HDC16,INT16,INT16,COLORREF);
 BOOL32     FloodFill32(HDC32,INT32,INT32,COLORREF);
 #define    FloodFill WINELIB_NAME(FloodFill)
@@ -5487,6 +5600,10 @@
 WORD       GetAsyncKeyState16(INT16);
 WORD       GetAsyncKeyState32(INT32);
 #define    GetAsyncKeyState WINELIB_NAME(GetAsyncKeyState)
+UINT16     GetAtomName16(ATOM,LPSTR,INT16);
+UINT32     GetAtomName32A(ATOM,LPSTR,INT32);
+UINT32     GetAtomName32W(ATOM,LPWSTR,INT32);
+#define    GetAtomName WINELIB_NAME_AW(GetAtomName)
 BOOL16     GetBitmapDimensionEx16(HBITMAP16,LPSIZE16);
 BOOL32     GetBitmapDimensionEx32(HBITMAP32,LPSIZE32);
 #define    GetBitmapDimensionEx WINELIB_NAME(GetBitmapDimensionEx)
@@ -5535,6 +5652,12 @@
 void       GetClientRect16(HWND16,LPRECT16);
 void       GetClientRect32(HWND32,LPRECT32);
 #define    GetClientRect WINELIB_NAME(GetClientRect)
+HWND16     GetClipboardOwner16(void);
+HWND32     GetClipboardOwner32(void);
+#define    GetClipboardOwner WINELIB_NAME(GetClipboardOwner)
+HWND16     GetClipboardViewer16(void);
+HWND32     GetClipboardViewer32(void);
+#define    GetClipboardViewer WINELIB_NAME(GetClipboardViewer)
 INT16      GetClipBox16(HDC16,LPRECT16);
 INT32      GetClipBox32(HDC32,LPRECT32);
 #define    GetClipBox WINELIB_NAME(GetClipBox)
@@ -5554,6 +5677,12 @@
 BOOL16     GetCurrentPositionEx16(HDC16,LPPOINT16);
 BOOL32     GetCurrentPositionEx32(HDC32,LPPOINT32);
 #define    GetCurrentPositionEx WINELIB_NAME(GetCurrentPositionEx)
+DWORD      GetCurrentTime16(void);
+#define    GetCurrentTime32() GetTickCount()
+#define    GetCurrentTime WINELIB_NAME(GetCurrentTime)
+HCURSOR16  GetCursor16(void);
+HCURSOR32  GetCursor32(void);
+#define    GetCursor WINELIB_NAME(GetCursor)
 void       GetCursorPos16(LPPOINT16);
 void       GetCursorPos32(LPPOINT32);
 #define    GetCursorPos WINELIB_NAME(GetCursorPos)
@@ -5566,6 +5695,9 @@
 HWND16     GetDesktopWindow16(void);
 HWND32     GetDesktopWindow32(void);
 #define    GetDesktopWindow WINELIB_NAME(GetDesktopWindow)
+INT16      GetDeviceCaps16(HDC16,INT16);
+INT32      GetDeviceCaps32(HDC32,INT32);
+#define    GetDeviceCaps WINELIB_NAME(GetDeviceCaps)
 INT16      GetDIBits16(HDC16,HBITMAP16,UINT16,UINT16,LPSTR,LPBITMAPINFO,UINT16);
 INT32      GetDIBits32(HDC32,HBITMAP32,UINT32,UINT32,LPSTR,LPBITMAPINFO,UINT32);
 #define    GetDIBits WINELIB_NAME(GetDIBits)
@@ -5586,6 +5718,9 @@
 INT32      GetDlgItemText32A(HWND32,INT32,LPSTR,UINT32);
 INT32      GetDlgItemText32W(HWND32,INT32,LPWSTR,UINT32);
 #define    GetDlgItemText WINELIB_NAME_AW(GetDlgItemText)
+UINT16     GetDoubleClickTime16(void);
+UINT32     GetDoubleClickTime32(void);
+#define    GetDoubleClickTime WINELIB_NAME(GetDoubleClickTime)
 UINT16     GetDriveType16(UINT16); /* yes, the arguments differ */
 UINT32     GetDriveType32A(LPCSTR);
 UINT32     GetDriveType32W(LPCWSTR);
@@ -5609,9 +5744,18 @@
 HWND16     GetFocus16(void);
 HWND32     GetFocus32(void);
 #define    GetFocus WINELIB_NAME(GetFocus)
+DWORD      GetFreeSpace16(UINT16);
+#define    GetFreeSpace32(w) (0x100000L)
+#define    GetFreeSpace WINELIB_NAME(GetFreeSpace)
+BOOL16     GetInputState16(void);
+BOOL32     GetInputState32(void);
+#define    GetInputState WINELIB_NAME(GetInputState)
 UINT16     GetInternalWindowPos16(HWND16,LPRECT16,LPPOINT16);
 UINT32     GetInternalWindowPos32(HWND32,LPRECT32,LPPOINT32);
 #define    GetInternalWindowPos WINELIB_NAME(GetInternalWindowPos)
+INT16      GetKBCodePage16(void);
+UINT32     GetKBCodePage32(void);
+#define    GetKBCodePage WINELIB_NAME(GetKBCodePage)
 INT16      GetKeyboardType16(INT16);
 INT32      GetKeyboardType32(INT32);
 #define    GetKeyboardType WINELIB_NAME(GetKeyboardType)
@@ -5622,6 +5766,9 @@
 WORD       GetKeyState16(INT16);
 WORD       GetKeyState32(INT32);
 #define    GetKeyState WINELIB_NAME(GetKeyState)
+HWND16     GetLastActivePopup16(HWND16);
+HWND32     GetLastActivePopup32(HWND32);
+#define    GetLastActivePopup WINELIB_NAME(GetLastActivePopup)
 UINT32     GetLogicalDriveStrings32A(UINT32,LPSTR);
 UINT32     GetLogicalDriveStrings32W(UINT32,LPWSTR);
 #define    GetLogicalDriveStrings WINELIB_NAME_AW(GetLogicalDriveStrings)
@@ -5644,10 +5791,20 @@
 INT32      GetMenuString32A(HMENU32,UINT32,LPSTR,INT32,UINT32);
 INT32      GetMenuString32W(HMENU32,UINT32,LPWSTR,INT32,UINT32);
 #define    GetMenuString WINELIB_NAME_AW(GetMenuString)
+HMETAFILE16 GetMetaFile16(LPCSTR);
+HMETAFILE32 GetMetaFile32A(LPCSTR);
+HMETAFILE32 GetMetaFile32W(LPCWSTR);
+#define    GetMetaFile WINELIB_NAME_AW(GetMetaFile)
 INT16      GetModuleFileName16(HINSTANCE16,LPSTR,INT16);
 DWORD      GetModuleFileName32A(HMODULE32,LPSTR,DWORD);
 DWORD      GetModuleFileName32W(HMODULE32,LPWSTR,DWORD);
 #define    GetModuleFileName WINELIB_NAME_AW(GetModuleFileName)
+DWORD      GetNearestColor16(HDC16,DWORD);
+DWORD      GetNearestColor32(HDC32,DWORD);
+#define    GetNearestColor WINELIB_NAME(GetNearestColor)
+UINT16     GetNearestPaletteIndex16(HPALETTE16,COLORREF);
+UINT32     GetNearestPaletteIndex32(HPALETTE32,COLORREF);
+#define    GetNearestPaletteIndex WINELIB_NAME(GetNearestPaletteIndex)
 HWND16     GetNextDlgGroupItem16(HWND16,HWND16,BOOL16);
 HWND32     GetNextDlgGroupItem32(HWND32,HWND32,BOOL32);
 #define    GetNextDlgGroupItem WINELIB_NAME(GetNextDlgGroupItem)
@@ -5661,6 +5818,12 @@
 INT32      GetObject32A(HANDLE32,INT32,LPVOID);
 INT32      GetObject32W(HANDLE32,INT32,LPVOID);
 #define    GetObject WINELIB_NAME_AW(GetObject)
+HWND16     GetOpenClipboardWindow16(void);
+HWND32     GetOpenClipboardWindow32(void);
+#define    GetOpenClipboardWindow WINELIB_NAME(GetOpenClipboardWindow)
+UINT16     GetPaletteEntries16(HPALETTE16,UINT16,UINT16,LPPALETTEENTRY);
+UINT32     GetPaletteEntries32(HPALETTE32,UINT32,UINT32,LPPALETTEENTRY);
+#define    GetPaletteEntries WINELIB_NAME(GetPaletteEntries)
 HWND16     GetParent16(HWND16);
 HWND32     GetParent32(HWND32);
 #define    GetParent WINELIB_NAME(GetParent)
@@ -5720,6 +5883,9 @@
 HMENU16    GetSubMenu16(HMENU16,INT16);
 HMENU32    GetSubMenu32(HMENU32,INT32);
 #define    GetSubMenu WINELIB_NAME(GetSubMenu)
+COLORREF   GetSysColor16(INT16);
+COLORREF   GetSysColor32(INT32);
+#define    GetSysColor WINELIB_NAME(GetSysColor)
 HBRUSH16   GetSysColorBrush16(INT16);
 HBRUSH32   GetSysColorBrush32(INT32);
 #define    GetSysColorBrush WINELIB_NAME(GetSysColorBrush)
@@ -5733,6 +5899,19 @@
 HMENU16    GetSystemMenu16(HWND16,BOOL16);
 HMENU32    GetSystemMenu32(HWND32,BOOL32);
 #define    GetSystemMenu WINELIB_NAME(GetSystemMenu)
+INT16      GetSystemMetrics16(INT16);
+INT32      GetSystemMetrics32(INT32);
+#define    GetSystemMetrics WINELIB_NAME(GetSystemMetrics)
+UINT16     GetSystemPaletteEntries16(HDC16,UINT16,UINT16,LPPALETTEENTRY);
+UINT32     GetSystemPaletteEntries32(HDC32,UINT32,UINT32,LPPALETTEENTRY);
+#define    GetSystemPaletteEntries WINELIB_NAME(GetSystemPaletteEntries)
+UINT16     GetSystemPaletteUse16(HDC16);
+UINT32     GetSystemPaletteUse32(HDC32);
+#define    GetSystemPaletteUse WINELIB_NAME(GetSystemPaletteUse)
+DWORD      GetTabbedTextExtent16(HDC16,LPCSTR,INT16,INT16,const INT16*);
+DWORD      GetTabbedTextExtent32A(HDC32,LPCSTR,INT32,INT32,const INT32*);
+DWORD      GetTabbedTextExtent32W(HDC32,LPCWSTR,INT32,INT32,const INT32*);
+#define    GetTabbedTextExtent WINELIB_NAME_AW(GetTabbedTextExtent)
 UINT16     GetTempFileName16(BYTE,LPCSTR,UINT16,LPSTR);
 UINT32     GetTempFileName32A(LPCSTR,LPCSTR,UINT32,LPSTR);
 UINT32     GetTempFileName32W(LPCWSTR,LPCWSTR,UINT32,LPWSTR);
@@ -5761,6 +5940,12 @@
 BOOL32     GetTextMetrics32A(HDC32,LPTEXTMETRIC32A);
 BOOL32     GetTextMetrics32W(HDC32,LPTEXTMETRIC32W);
 #define    GetTextMetrics WINELIB_NAME_AW(GetTextMetrics)
+LPINT16    GetThresholdEvent16(void);
+LPDWORD    GetThresholdEvent32(void);
+#define    GetThresholdEvent WINELIB_NAME(GetThresholdEvent)
+INT16      GetThresholdStatus16(void);
+DWORD      GetThresholdStatus32(void);
+#define    GetThresholdStatus WINELIB_NAME(GetThresholdStatus)
 HWND16     GetTopWindow16(HWND16);
 HWND32     GetTopWindow32(HWND32);
 #define    GetTopWindow WINELIB_NAME(GetTopWindow)
@@ -5843,6 +6028,9 @@
 DWORD      GlobalHandle16(WORD);
 HGLOBAL32  GlobalHandle32(LPCVOID);
 #define    GlobalHandle WINELIB_NAME(GlobalHandle)
+VOID       GlobalFix16(HGLOBAL16);
+VOID       GlobalFix32(HGLOBAL32);
+#define    GlobalFix WINELIB_NAME(GlobalFix)
 LPVOID     GlobalLock16(HGLOBAL16);
 LPVOID     GlobalLock32(HGLOBAL32);
 #define    GlobalLock WINELIB_NAME(GlobalLock)
@@ -5852,15 +6040,40 @@
 DWORD      GlobalSize16(HGLOBAL16);
 DWORD      GlobalSize32(HGLOBAL32);
 #define    GlobalSize WINELIB_NAME(GlobalSize)
+VOID       GlobalUnfix16(HGLOBAL16);
+VOID       GlobalUnfix32(HGLOBAL32);
+#define    GlobalUnfix WINELIB_NAME(GlobalUnfix)
 BOOL16     GlobalUnlock16(HGLOBAL16);
 BOOL32     GlobalUnlock32(HGLOBAL32);
 #define    GlobalUnlock WINELIB_NAME(GlobalUnlock)
+BOOL16     GlobalUnWire16(HGLOBAL16);
+BOOL32     GlobalUnWire32(HGLOBAL32);
+#define    GlobalUnWire WINELIB_NAME(GlobalUnWire)
+SEGPTR     GlobalWire16(HGLOBAL16);
+LPVOID     GlobalWire32(HGLOBAL32);
+#define    GlobalWire WINELIB_NAME(GlobalWire)
+BOOL16     GrayString16(HDC16,HBRUSH16,GRAYSTRINGPROC16,LPARAM,
+                        INT16,INT16,INT16,INT16,INT16);
+BOOL32     GrayString32A(HDC32,HBRUSH32,GRAYSTRINGPROC32,LPARAM,
+                         INT32,INT32,INT32,INT32,INT32);
+BOOL32     GrayString32W(HDC32,HBRUSH32,GRAYSTRINGPROC32,LPARAM,
+                         INT32,INT32,INT32,INT32,INT32);
+#define    GrayString WINELIB_NAME_AW(GrayString)
+BOOL16     HideCaret16(HWND16);
+BOOL32     HideCaret32(HWND32);
+#define    HideCaret WINELIB_NAME(HideCaret)
 BOOL16     HiliteMenuItem16(HWND16,HMENU16,UINT16,UINT16);
 BOOL32     HiliteMenuItem32(HWND32,HMENU32,UINT32,UINT32);
 #define    HiliteMenuItem WINELIB_NAME(HiliteMenuItem)
 void       InflateRect16(LPRECT16,INT16,INT16);
 void       InflateRect32(LPRECT32,INT32,INT32);
 #define    InflateRect WINELIB_NAME(InflateRect)
+WORD       InitAtomTable16(WORD);
+BOOL32     InitAtomTable32(DWORD);
+#define    InitAtomTable WINELIB_NAME(InitAtomTable)
+BOOL16     InSendMessage16(void);
+BOOL32     InSendMessage32(void);
+#define    InSendMessage WINELIB_NAME(InSendMessage)
 BOOL16     InsertMenu16(HMENU16,UINT16,UINT16,UINT16,SEGPTR);
 BOOL32     InsertMenu32A(HMENU32,UINT32,UINT32,UINT32,LPCSTR);
 BOOL32     InsertMenu32W(HMENU32,UINT32,UINT32,UINT32,LPCWSTR);
@@ -5921,9 +6134,16 @@
 BOOL16     IsChild16(HWND16,HWND16);
 BOOL32     IsChild32(HWND32,HWND32);
 #define    IsChild WINELIB_NAME(IsChild)
+BOOL16     IsClipboardFormatAvailable16(UINT16);
+BOOL32     IsClipboardFormatAvailable32(UINT32);
+#define    IsClipboardFormatAvailable WINELIB_NAME(IsClipboardFormatAvailable)
 BOOL16     IsDBCSLeadByte16(BYTE);
 BOOL32     IsDBCSLeadByte32(BYTE);
 #define    IsDBCSLeadByte WINELIB_NAME(IsDBCSLeadByte)
+BOOL16     IsDialogMessage16(HWND16,LPMSG16);
+BOOL32     IsDialogMessage32A(HWND32,LPMSG32);
+BOOL32     IsDialogMessage32W(HWND32,LPMSG32);
+#define    IsDialogMessage WINELIB_NAME(IsDialogMessage)
 UINT16     IsDlgButtonChecked16(HWND16,UINT16);
 UINT32     IsDlgButtonChecked32(HWND32,UINT32);
 #define    IsDlgButtonChecked WINELIB_NAME(IsDlgButtonChecked)
@@ -6036,7 +6256,7 @@
 LPVOID     LockResource32(HGLOBAL32);
 #define    LockResource WINELIB_NAME(LockResource)
 HGLOBAL16  LockSegment16(HGLOBAL16);
-#define    LockSegment32(handle) GlobalFix((HANDLE32)(handle))
+#define    LockSegment32(handle) GlobalFix32((HANDLE32)(handle))
 #define    LockSegment WINELIB_NAME(LockSegment)
 BOOL16     LPtoDP16(HDC16,LPPOINT16,INT16);
 BOOL32     LPtoDP32(HDC32,LPPOINT32,INT32);
@@ -6066,6 +6286,9 @@
 void       MapWindowPoints16(HWND16,HWND16,LPPOINT16,UINT16);
 void       MapWindowPoints32(HWND32,HWND32,LPPOINT32,UINT32);
 #define    MapWindowPoints WINELIB_NAME(MapWindowPoints)
+VOID       MessageBeep16(UINT16);
+BOOL32     MessageBeep32(UINT32);
+#define    MessageBeep WINELIB_NAME(MessageBeep)
 INT16      MessageBox16(HWND16,LPCSTR,LPCSTR,UINT16);
 INT32      MessageBox32A(HWND32,LPCSTR,LPCSTR,UINT32);
 INT32      MessageBox32W(HWND32,LPCWSTR,LPCWSTR,UINT32);
@@ -6112,9 +6335,18 @@
 BOOL16     OffsetWindowOrgEx16(HDC16,INT16,INT16,LPPOINT16);
 BOOL32     OffsetWindowOrgEx32(HDC32,INT32,INT32,LPPOINT32);
 #define    OffsetWindowOrgEx WINELIB_NAME(OffsetWindowOrgEx)
+BOOL16     OpenClipboard16(HWND16);
+BOOL32     OpenClipboard32(HWND32);
+#define    OpenClipboard WINELIB_NAME(OpenClipboard)
 HFILE16    OpenFile16(LPCSTR,OFSTRUCT*,UINT16);
 HFILE32    OpenFile32(LPCSTR,OFSTRUCT*,UINT32);
 #define    OpenFile WINELIB_NAME(OpenFile)
+BOOL16     OpenIcon16(HWND16);
+BOOL32     OpenIcon32(HWND32);
+#define    OpenIcon WINELIB_NAME(OpenIcon)
+INT16      OpenSound16(void);
+VOID       OpenSound32(void);
+#define    OpenSound WINELIB_NAME(OpenSound)
 BOOL16     PaintRgn16(HDC16,HRGN16);
 BOOL32     PaintRgn32(HDC32,HRGN32);
 #define    PaintRgn WINELIB_NAME(PaintRgn)
@@ -6128,6 +6360,9 @@
 BOOL16     Pie16(HDC16,INT16,INT16,INT16,INT16,INT16,INT16,INT16,INT16);
 BOOL32     Pie32(HDC32,INT32,INT32,INT32,INT32,INT32,INT32,INT32,INT32);
 #define    Pie WINELIB_NAME(Pie)
+BOOL16     PlayMetaFile16(HDC16,HMETAFILE16);
+BOOL32     PlayMetaFile32(HDC32,HMETAFILE32);
+#define    PlayMetaFile WINELIB_NAME(PlayMetaFile)
 BOOL16     PolyPolygon16(HDC16,LPPOINT16,LPINT16,UINT16);
 BOOL32     PolyPolygon32(HDC32,LPPOINT32,LPINT32,UINT32);
 #define    PolyPolygon WINELIB_NAME(PolyPolygon)
@@ -6143,6 +6378,9 @@
 #define    PostAppMessage32W(thread,msg,wparam,lparam) \
            PostThreadMessage32W((DWORD)(thread),msg,wparam,lparam)
 #define    PostAppMessage WINELIB_NAME_AW(PostAppMessage)
+void       PostQuitMessage16(INT16);
+void       PostQuitMessage32(INT32);
+#define    PostQuitMessage WINELIB_NAME(PostQuitMessage)
 BOOL16     PtInRect16(const RECT16*,POINT16);
 BOOL32     PtInRect32(const RECT32*,POINT32);
 #define    PtInRect WINELIB_NAME(PtInRect)
@@ -6152,6 +6390,9 @@
 BOOL16     PtVisible16(HDC16,INT16,INT16);
 BOOL32     PtVisible32(HDC32,INT32,INT32);
 #define    PtVisible WINELIB_NAME(PtVisible)
+UINT16     RealizePalette16(HDC16);
+UINT32     RealizePalette32(HDC32);
+#define    RealizePalette WINELIB_NAME(RealizePalette)
 BOOL16     Rectangle16(HDC16,INT16,INT16,INT16,INT16);
 BOOL32     Rectangle32(HDC32,INT32,INT32,INT32,INT32);
 #define    Rectangle WINELIB_NAME(Rectangle)
@@ -6238,6 +6479,9 @@
 HDC32      ResetDC32A(HDC32,const DEVMODE32A *);
 HDC32      ResetDC32W(HDC32,const DEVMODE32W *);
 #define    ResetDC WINELIB_NAME_AW(ResetDC)
+BOOL16     ResizePalette16(HPALETTE16,UINT16);
+BOOL32     ResizePalette32(HPALETTE32,UINT32);
+#define    ResizePalette WINELIB_NAME(ResizePalette)
 BOOL16     RestoreDC16(HDC16,INT16);
 BOOL32     RestoreDC32(HDC32,INT32);
 #define    RestoreDC WINELIB_NAME(RestoreDC)
@@ -6256,6 +6500,9 @@
 void       ScreenToClient16(HWND16,LPPOINT16);
 void       ScreenToClient32(HWND32,LPPOINT32);
 #define    ScreenToClient WINELIB_NAME(ScreenToClient)
+VOID       ScrollChildren16(HWND16,UINT16,WPARAM16,LPARAM);
+VOID       ScrollChildren32(HWND32,UINT32,WPARAM32,LPARAM);
+#define    ScrollChildren WINELIB_NAME(ScrollChildren)
 BOOL16     ScrollDC16(HDC16,INT16,INT16,const RECT16*,const RECT16*,
                       HRGN16,LPRECT16);
 BOOL32     ScrollDC32(HDC32,INT32,INT32,const RECT32*,const RECT32*,
@@ -6275,6 +6522,9 @@
 HGDIOBJ16  SelectObject16(HDC16,HGDIOBJ16);
 HGDIOBJ32  SelectObject32(HDC32,HGDIOBJ32);
 #define    SelectObject WINELIB_NAME(SelectObject)
+HPALETTE16 SelectPalette16(HDC16,HPALETTE16,BOOL16);
+HPALETTE32 SelectPalette32(HDC32,HPALETTE32,BOOL32);
+#define    SelectPalette WINELIB_NAME(SelectPalette)
 LRESULT    SendDlgItemMessage16(HWND16,INT16,UINT16,WPARAM16,LPARAM);
 LRESULT    SendDlgItemMessage32A(HWND32,INT32,UINT32,WPARAM32,LPARAM);
 LRESULT    SendDlgItemMessage32W(HWND32,INT32,UINT32,WPARAM32,LPARAM);
@@ -6299,6 +6549,9 @@
 LONG       SetClassLong32A(HWND32,INT32,LONG);
 LONG       SetClassLong32W(HWND32,INT32,LONG);
 #define    SetClassLong WINELIB_NAME_AW(SetClassLong)
+HWND16     SetClipboardViewer16(HWND16);
+HWND32     SetClipboardViewer32(HWND32);
+#define    SetClipboardViewer WINELIB_NAME(SetClipboardViewer)
 INT16      SetCommBreak16(INT16);
 BOOL32     SetCommBreak32(INT32);
 #define    SetCommBreak WINELIB_NAME(SetCommBreak)
@@ -6309,6 +6562,12 @@
 BOOL32     SetCurrentDirectory32A(LPCSTR);
 BOOL32     SetCurrentDirectory32W(LPCWSTR);
 #define    SetCurrentDirectory WINELIB_NAME_AW(SetCurrentDirectory)
+HCURSOR16  SetCursor16(HCURSOR16);
+HCURSOR32  SetCursor32(HCURSOR32);
+#define    SetCursor WINELIB_NAME(SetCursor)
+void       SetCursorPos16(INT16,INT16);
+BOOL32     SetCursorPos32(INT32,INT32);
+#define    SetCursorPos WINELIB_NAME(SetCursorPos)
 BOOL16     SetDeskWallPaper16(LPCSTR);
 BOOL32     SetDeskWallPaper32(LPCSTR);
 #define    SetDeskWallPaper WINELIB_NAME(SetDeskWallPaper)
@@ -6327,6 +6586,9 @@
 void       SetDlgItemText32A(HWND32,INT32,LPCSTR);
 void       SetDlgItemText32W(HWND32,INT32,LPCWSTR);
 #define    SetDlgItemText WINELIB_NAME_AW(SetDlgItemText)
+VOID       SetDoubleClickTime16(UINT16);
+BOOL32     SetDoubleClickTime32(UINT32);
+#define    SetDoubleClickTime WINELIB_NAME(SetDoubleClickTime)
 UINT16     SetErrorMode16(UINT16);
 UINT32     SetErrorMode32(UINT32);
 #define    SetErrorMode WINELIB_NAME(SetErrorMode)
@@ -6346,12 +6608,24 @@
 INT16      SetMapMode16(HDC16,INT16);
 INT32      SetMapMode32(HDC32,INT32);
 #define    SetMapMode WINELIB_NAME(SetMapMode)
+DWORD      SetMapperFlags16(HDC16,DWORD);
+DWORD      SetMapperFlags32(HDC32,DWORD);
+#define    SetMapperFlags WINELIB_NAME(SetMapperFlags)
 BOOL16     SetMenu16(HWND16,HMENU16);
 BOOL32     SetMenu32(HWND32,HMENU32);
 #define    SetMenu WINELIB_NAME(SetMenu)
 BOOL16     SetMenuItemBitmaps16(HMENU16,UINT16,UINT16,HBITMAP16,HBITMAP16);
 BOOL32     SetMenuItemBitmaps32(HMENU32,UINT32,UINT32,HBITMAP32,HBITMAP32);
 #define    SetMenuItemBitmaps WINELIB_NAME(SetMenuItemBitmaps)
+BOOL16     SetMessageQueue16(INT16);
+BOOL32     SetMessageQueue32(INT32);
+#define    SetMessageQueue WINELIB_NAME(SetMessageQueue)
+UINT16     SetPaletteEntries16(HPALETTE16,UINT16,UINT16,LPPALETTEENTRY);
+UINT32     SetPaletteEntries32(HPALETTE32,UINT32,UINT32,LPPALETTEENTRY);
+#define    SetPaletteEntries WINELIB_NAME(SetPaletteEntries)
+HWND16     SetParent16(HWND16,HWND16);
+HWND32     SetParent32(HWND32,HWND32);
+#define    SetParent WINELIB_NAME(SetParent)
 COLORREF   SetPixel16(HDC16,INT16,INT16,COLORREF);
 COLORREF   SetPixel32(HDC32,INT32,INT32,COLORREF);
 #define    SetPixel WINELIB_NAME(SetPixel)
@@ -6383,18 +6657,27 @@
 void       SetScrollRange16(HWND16,INT16,INT16,INT16,BOOL16);
 BOOL32     SetScrollRange32(HWND32,INT32,INT32,INT32,BOOL32);
 #define    SetScrollRange WINELIB_NAME(SetScrollRange)
+INT16      SetSoundNoise16(INT16,INT16);
+DWORD      SetSoundNoise32(DWORD,DWORD);
+#define    SetSoundNoise WINELIB_NAME(SetSoundNoise)
 INT16      SetStretchBltMode16(HDC16,INT16);
 INT32      SetStretchBltMode32(HDC32,INT32);
 #define    SetStretchBltMode WINELIB_NAME(SetStretchBltMode)
+VOID       SetSysColors16(INT16,const INT16*,const COLORREF*);
+BOOL32     SetSysColors32(INT32,const INT32*,const COLORREF*);
+#define    SetSysColors WINELIB_NAME(SetSysColors)
 HWND16     SetSysModalWindow16(HWND16);
 #define    SetSysModalWindow32(hwnd) ((HWND32)0)
 #define    SetSysModalWindow WINELIB_NAME(SetSysModalWindow)
-UINT16     SetSystemTimer16(HWND16,UINT16,UINT16,TIMERPROC16);
-UINT32     SetSystemTimer32(HWND32,UINT32,UINT32,TIMERPROC32);
-#define    SetSystemTimer WINELIB_NAME(SetSystemTimer)
 BOOL16     SetSystemMenu16(HWND16,HMENU16);
 BOOL32     SetSystemMenu32(HWND32,HMENU32);
 #define    SetSystemMenu WINELIB_NAME(SetSystemMenu)
+UINT16     SetSystemPaletteUse16(HDC16,UINT16);
+UINT32     SetSystemPaletteUse32(HDC32,UINT32);
+#define    SetSystemPaletteUse WINELIB_NAME(SetSystemPaletteUse)
+UINT16     SetSystemTimer16(HWND16,UINT16,UINT16,TIMERPROC16);
+UINT32     SetSystemTimer32(HWND32,UINT32,UINT32,TIMERPROC32);
+#define    SetSystemTimer WINELIB_NAME(SetSystemTimer)
 UINT16     SetTextAlign16(HDC16,UINT16);
 UINT32     SetTextAlign32(HDC32,UINT32);
 #define    SetTextAlign WINELIB_NAME(SetTextAlign)
@@ -6413,6 +6696,24 @@
 BOOL16     SetViewportOrgEx16(HDC16,INT16,INT16,LPPOINT16);
 BOOL32     SetViewportOrgEx32(HDC32,INT32,INT32,LPPOINT32);
 #define    SetViewportOrgEx WINELIB_NAME(SetViewportOrgEx)
+INT16      SetVoiceAccent16(INT16,INT16,INT16,INT16,INT16);
+DWORD      SetVoiceAccent32(DWORD,DWORD,DWORD,DWORD,DWORD);
+#define    SetVoiceAccent WINELIB_NAME(SetVoiceAccent)
+INT16      SetVoiceEnvelope16(INT16,INT16,INT16);
+DWORD      SetVoiceEnvelope32(DWORD,DWORD,DWORD);
+#define    SetVoiceEnvelope WINELIB_NAME(SetVoiceEnvelope)
+INT16      SetVoiceNote16(INT16,INT16,INT16,INT16);
+DWORD      SetVoiceNote32(DWORD,DWORD,DWORD,DWORD);
+#define    SetVoiceNote WINELIB_NAME(SetVoiceNote)
+INT16      SetVoiceQueueSize16(INT16,INT16);
+DWORD      SetVoiceQueueSize32(DWORD,DWORD);
+#define    SetVoiceQueueSize WINELIB_NAME(SetVoiceQueueSize)
+INT16      SetVoiceSound16(INT16,DWORD,INT16);
+DWORD      SetVoiceSound32(DWORD,DWORD,DWORD);
+#define    SetVoiceSound WINELIB_NAME(SetVoiceSound)
+INT16      SetVoiceThreshold16(INT16,INT16);
+DWORD      SetVoiceThreshold32(DWORD,DWORD);
+#define    SetVoiceThreshold WINELIB_NAME(SetVoiceThreshold)
 BOOL16     SetWindowExtEx16(HDC16,INT16,INT16,LPSIZE16);
 BOOL32     SetWindowExtEx32(HDC32,INT32,INT32,LPSIZE32);
 #define    SetWindowExtEx WINELIB_NAME(SetWindowExtEx)
@@ -6445,15 +6746,30 @@
 BOOL32     ShellAbout32A(HWND32,LPCSTR,LPCSTR,HICON32);
 BOOL32     ShellAbout32W(HWND32,LPCWSTR,LPCWSTR,HICON32);
 #define    ShellAbout WINELIB_NAME_AW(ShellAbout)
+BOOL16     ShowCaret16(HWND16);
+BOOL32     ShowCaret32(HWND32);
+#define    ShowCaret WINELIB_NAME(ShowCaret)
+INT16      ShowCursor16(BOOL16);
+INT32      ShowCursor32(BOOL32);
+#define    ShowCursor WINELIB_NAME(ShowCursor)
 void       ShowScrollBar16(HWND16,INT16,BOOL16);
 BOOL32     ShowScrollBar32(HWND32,INT32,BOOL32);
 #define    ShowScrollBar WINELIB_NAME(ShowScrollBar)
+VOID       ShowOwnedPopups16(HWND16,BOOL16);
+BOOL32     ShowOwnedPopups32(HWND32,BOOL32);
+#define    ShowOwnedPopups WINELIB_NAME(ShowOwnedPopups)
 BOOL16     ShowWindow16(HWND16,INT16);
 BOOL32     ShowWindow32(HWND32,INT32);
 #define    ShowWindow WINELIB_NAME(ShowWindow)
 DWORD      SizeofResource16(HMODULE16,HRSRC16);
 DWORD      SizeofResource32(HMODULE32,HRSRC32);
 #define    SizeofResource WINELIB_NAME(SizeofResource)
+INT16      StartSound16(void);
+VOID       StartSound32(void);
+#define    StartSound WINELIB_NAME(StartSound)
+INT16      StopSound16(void);
+VOID       StopSound32(void);
+#define    StopSound WINELIB_NAME(StopSound)
 BOOL16     StretchBlt16(HDC16,INT16,INT16,INT16,INT16,HDC16,INT16,INT16,
                         INT16,INT16,DWORD);
 BOOL32     StretchBlt32(HDC32,INT32,INT32,INT32,INT32,HDC32,INT32,INT32,
@@ -6467,10 +6783,20 @@
 BOOL16     SubtractRect16(LPRECT16,const RECT16*,const RECT16*);
 BOOL32     SubtractRect32(LPRECT32,const RECT32*,const RECT32*);
 #define    SubtractRect WINELIB_NAME(SubtractRect)
+BOOL16     SwapMouseButton16(BOOL16);
+BOOL32     SwapMouseButton32(BOOL32);
+#define    SwapMouseButton WINELIB_NAME(SwapMouseButton)
+INT16      SyncAllVoices16(void);
+DWORD      SyncAllVoices32(void);
+#define    SyncAllVoices WINELIB_NAME(SyncAllVoices)
 BOOL16     SystemParametersInfo16(UINT16,UINT16,LPVOID,UINT16);
 BOOL32     SystemParametersInfo32A(UINT32,UINT32,LPVOID,UINT32);
 BOOL32     SystemParametersInfo32W(UINT32,UINT32,LPVOID,UINT32);
 #define    SystemParametersInfo WINELIB_NAME_AW(SystemParametersInfo)
+LONG       TabbedTextOut16(HDC16,INT16,INT16,LPCSTR,INT16,INT16,const INT16*,INT16);
+LONG       TabbedTextOut32A(HDC32,INT32,INT32,LPCSTR,INT32,INT32,const INT32*,INT32);
+LONG       TabbedTextOut32W(HDC32,INT32,INT32,LPCWSTR,INT32,INT32,const INT32*,INT32);
+#define    TabbedTextOut WINELIB_NAME_AW(TabbedTextOut)
 BOOL16     TextOut16(HDC16,INT16,INT16,LPCSTR,INT16);
 BOOL32     TextOut32A(HDC32,INT32,INT32,LPCSTR,INT32);
 BOOL32     TextOut32W(HDC32,INT32,INT32,LPCWSTR,INT32);
@@ -6484,6 +6810,12 @@
 INT16      TranslateAccelerator16(HWND16,HACCEL16,LPMSG16);
 INT32      TranslateAccelerator32(HWND32,HACCEL32,LPMSG32);
 #define    TranslateAccelerator WINELIB_NAME(TranslateAccelerator)
+BOOL16     TranslateMDISysAccel16(HWND16,LPMSG16);
+BOOL32     TranslateMDISysAccel32(HWND32,LPMSG32);
+#define    TranslateMDISysAccel WINELIB_NAME(TranslateMDISysAccel)
+BOOL16     TranslateMessage16(const MSG16*);
+BOOL32     TranslateMessage32(const MSG32*);
+#define    TranslateMessage WINELIB_NAME(TranslateMessage)
 INT16      TransmitCommChar16(INT16,CHAR);
 BOOL32     TransmitCommChar32(INT32,CHAR);
 #define    TransmitCommChar WINELIB_NAME(TransmitCommChar)
@@ -6532,6 +6864,9 @@
 WORD       VkKeyScan32A(CHAR);
 WORD       VkKeyScan32W(WCHAR);
 #define    VkKeyScan WINELIB_NAME_AW(VkKeyScan)
+INT16      WaitSoundState16(INT16);
+DWORD      WaitSoundState32(DWORD);
+#define    WaitSoundState WINELIB_NAME(WaitSoundState)
 HWND16     WindowFromDC16(HDC16);
 HWND32     WindowFromDC32(HDC32);
 #define    WindowFromDC WINELIB_NAME(WindowFromDC)
@@ -6647,15 +6982,41 @@
 typedef INT32 INT;
 typedef UINT32 UINT;
 typedef BOOL32 BOOL;
-typedef HANDLE32 HWND;
 # else  /* WINELIB32 */
 typedef INT16 INT;
 typedef UINT16 UINT;
 typedef BOOL16 BOOL;
-typedef HANDLE16 HWND;
 # endif  /* WINELIB32 */
 #endif  /* __WINE__ */
 
+INT        AddFontResource(LPCSTR);
+int        ConvertRequest(HWND16,LPKANJISTRUCT);
+DWORD      DragObject(HWND16, HWND16, WORD, HANDLE16, WORD, HCURSOR16);
+BOOL       EnumMetaFile(HDC16,HMETAFILE16,MFENUMPROC16,LPARAM);
+HICON16    ExtractIcon(HINSTANCE16,LPCSTR,WORD);
+HINSTANCE16 FindExecutable(LPCSTR,LPCSTR,LPSTR);
+void       FreeLibrary(HINSTANCE16);
+HANDLE16   GetClipboardData(WORD);
+int        GetClipboardFormatName(WORD,LPSTR,short);
+int        GetEnvironment(LPSTR,LPSTR,WORD);
+int        GetKerningPairs(HDC16,int,LPKERNINGPAIR16);
+BOOL       GetMessage(SEGPTR,HWND16,UINT,UINT);
+HMODULE16  GetModuleHandle(LPCSTR);
+INT16      GetModuleUsage(HINSTANCE16);
+int        GetPriorityClipboardFormat(WORD*,short);
+DWORD      GetQueueStatus(UINT);
+BOOL       GetRasterizerCaps(LPRASTERIZER_STATUS,UINT);
+HINSTANCE16 LoadModule(LPCSTR,LPVOID);
+void       OutputDebugString(LPCSTR);
+void       PlayMetaFileRecord(HDC16,LPHANDLETABLE16,LPMETARECORD,WORD);
+BOOL       PostMessage(HWND16,WORD,WORD,LONG);
+BOOL       RemoveFontResource(LPSTR);
+void       ReplyMessage(LRESULT);
+HANDLE16   SetClipboardData(WORD,HANDLE16);
+int        SetEnvironment(LPCSTR,LPCSTR,WORD);
+HINSTANCE16 ShellExecute(HWND16,LPCSTR,LPCSTR,LPSTR,LPCSTR,INT);
+int        UpdateColors(HDC16);
+
 /* Callback function pointers types. */
 
 #ifdef WINELIB
@@ -6666,160 +7027,6 @@
 typedef SEGPTR EDITWORDBREAKPROC;
 #endif
 
-ATOM       AddAtom(SEGPTR);
-INT        AddFontResource(LPCSTR);
-BOOL       AnimatePalette(HPALETTE16,UINT,UINT,LPPALETTEENTRY);
-BOOL       AnyPopup(void);
-void       CalcChildScroll(HWND,WORD);
-BOOL       CallMsgFilter(SEGPTR,INT);
-BOOL       CloseClipboard(void);
-void       CloseSound(void);
-BOOL       CloseWindow(HWND);
-int        ConvertRequest(HWND,LPKANJISTRUCT);
-HMETAFILE16 CopyMetaFile(HMETAFILE16,LPCSTR);
-INT        CountClipboardFormats(void);
-INT        CountVoiceNotes(INT);
-HCURSOR16  CreateCursor(HINSTANCE16,INT,INT,INT,INT,const BYTE*,const BYTE*);
-HGLOBAL16  CreateCursorIconIndirect(HINSTANCE16,CURSORICONINFO*,const BYTE*,const BYTE*);
-HICON16    CreateIcon(HINSTANCE16,INT,INT,BYTE,BYTE,const BYTE*,const BYTE*);
-HPALETTE16 CreatePalette(const LOGPALETTE*);
-ATOM       DeleteAtom(ATOM);
-BOOL       DestroyCursor(HCURSOR16);
-BOOL       DestroyIcon(HICON16);
-LONG       DispatchMessage(const MSG16*);
-BOOL16     DragDetect(HWND16,POINT16);
-DWORD      DragObject(HWND, HWND, WORD, HANDLE16, WORD, HCURSOR16);
-BOOL       DrawIcon(HDC16,INT,INT,HICON16);
-DWORD      DumpIcon(SEGPTR,WORD*,SEGPTR*,SEGPTR*);
-BOOL       EmptyClipboard(void);
-UINT16     EnumClipboardFormats(UINT16);
-BOOL       EnumMetaFile(HDC16,HMETAFILE16,MFENUMPROC16,LPARAM);
-HICON16    ExtractIcon(HINSTANCE16,LPCSTR,WORD);
-void       FatalExit(int);
-ATOM       FindAtom(SEGPTR);
-HINSTANCE16 FindExecutable(LPCSTR,LPCSTR,LPSTR);
-BOOL       FlashWindow(HWND,BOOL);
-void       FreeLibrary(HINSTANCE16);
-UINT       GDIRealizePalette(HDC16);
-HPALETTE16 GDISelectPalette(HDC16,HPALETTE16,WORD);
-DWORD      GetAspectRatioFilter(HDC16);
-WORD       GetAtomName(ATOM,LPSTR,short);
-HANDLE16   GetClipboardData(WORD);
-int        GetClipboardFormatName(WORD,LPSTR,short);
-HWND       GetClipboardOwner(void);
-HWND       GetClipboardViewer(void);
-HBRUSH16   GetControlBrush(HWND,HDC16,WORD);
-DWORD      GetCurrentTime(void);
-HCURSOR16  GetCursor(void);
-SEGPTR     GetDOSEnvironment(void);
-int        GetDeviceCaps(HDC16,WORD);
-WORD       GetDoubleClickTime(void);
-int        GetEnvironment(LPSTR,LPSTR,WORD);
-DWORD      GetFreeSpace(UINT16);
-DWORD      GetHeapSpaces(HMODULE16);
-BOOL       GetInputState(void);
-int        GetKBCodePage(void);
-int        GetKerningPairs(HDC16,int,LPKERNINGPAIR16);
-HWND       GetLastActivePopup(HWND);
-BOOL       GetMessage(SEGPTR,HWND,UINT,UINT);
-LONG       GetMessageExtraInfo(void);
-DWORD      GetMessagePos(void);
-LONG       GetMessageTime(void);
-HMETAFILE16 GetMetaFile(LPSTR);
-HGLOBAL16  GetMetaFileBits(HMETAFILE16);
-HMODULE16  GetModuleHandle(LPCSTR);
-INT16      GetModuleUsage(HINSTANCE16);
-DWORD      GetNearestColor(HDC16,DWORD);
-WORD       GetNearestPaletteIndex(HPALETTE16,DWORD);
-HWND       GetOpenClipboardWindow(void);
-WORD       GetPaletteEntries(HPALETTE16,WORD,WORD,LPPALETTEENTRY);
-int        GetPriorityClipboardFormat(WORD*,short);
-DWORD      GetQueueStatus(UINT);
-BOOL       GetRasterizerCaps(LPRASTERIZER_STATUS,UINT);
-int        GetSystemMetrics(WORD);
-WORD       GetSystemPaletteEntries(HDC16,WORD,WORD,LPPALETTEENTRY);
-WORD       GetSystemPaletteUse(HDC16);
-DWORD      GetTabbedTextExtent(HDC16,LPSTR,int,int,LPINT16);
-BYTE       GetTempDrive(BYTE);
-LPINT16    GetThresholdEvent(void);
-int        GetThresholdStatus(void);
-BOOL       GetWinDebugInfo(LPWINDEBUGINFO,UINT);
-ATOM       GlobalDeleteAtom(ATOM);
-void       GlobalFix(HGLOBAL16);
-BOOL16     GlobalUnWire(HGLOBAL16);
-void       GlobalUnfix(HGLOBAL16);
-SEGPTR     GlobalWire(HGLOBAL16);
-BOOL       GrayString(HDC16,HBRUSH16,GRAYSTRINGPROC16,LPARAM,INT,INT,INT,INT,INT);
-BOOL       InSendMessage(void);
-WORD       InitAtomTable(WORD);
-BOOL       IsClipboardFormatAvailable(WORD);
-BOOL16     IsDialogMessage(HWND16,LPMSG16);
-BOOL       IsValidMetaFile(HMETAFILE16);
-HINSTANCE16 LoadModule(LPCSTR,LPVOID);
-FARPROC16  LocalNotify(FARPROC16);
-void       MessageBeep(WORD);
-BOOL       OpenClipboard(HWND);
-BOOL       OpenIcon(HWND);
-int        OpenSound(void);
-void       OutputDebugString(LPCSTR);
-BOOL       PlayMetaFile(HDC16,HMETAFILE16);
-void       PlayMetaFileRecord(HDC16,LPHANDLETABLE16,LPMETARECORD,WORD);
-BOOL       PostMessage(HWND,WORD,WORD,LONG);
-void       PostQuitMessage(INT);
-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);
-WORD       RealizeDefaultPalette(HDC16);
-BOOL       RemoveFontResource(LPSTR);
-void       ReplyMessage(LRESULT);
-BOOL       ResizePalette(HPALETTE16,UINT);
-void       ScrollChildren(HWND,UINT,WPARAM16,LPARAM);
-HPALETTE16 SelectPalette(HDC16,HPALETTE16,BOOL);
-HANDLE16   SetClipboardData(WORD,HANDLE16);
-HWND       SetClipboardViewer(HWND);
-void       SetConvertHook(BOOL);
-BOOL       SetConvertParams(int,int);
-HCURSOR16  SetCursor(HCURSOR16);
-void       SetCursorPos(short,short);
-void       SetDoubleClickTime(WORD);
-int        SetEnvironment(LPCSTR,LPCSTR,WORD);
-WORD       SetHookFlags(HDC16,WORD);
-DWORD      SetMapperFlags(HDC16,DWORD);
-BOOL       SetMessageQueue(int);
-HMETAFILE16 SetMetaFileBits(HGLOBAL16);
-WORD       SetPaletteEntries(HPALETTE16,WORD,WORD,LPPALETTEENTRY);
-HWND       SetParent(HWND,HWND);
-FARPROC16  SetResourceHandler(HINSTANCE16,LPSTR,FARPROC16);
-int        SetSoundNoise(int,int);
-void       SetSysColors(int,LPINT16,COLORREF*);
-WORD       SetSystemPaletteUse(HDC16,WORD);
-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);
-HINSTANCE16 ShellExecute(HWND,LPCSTR,LPCSTR,LPSTR,LPCSTR,INT);
-int        ShowCursor(BOOL);
-void       ShowOwnedPopups(HWND,BOOL);
-int        StartSound(void);
-int        StopSound(void);
-BOOL       SwapMouseButton(BOOL);
-void       SwapRecording(WORD);
-int        SyncAllVoices(void);
-LONG       TabbedTextOut(HDC16,short,short,LPSTR,short,short,LPINT16,short);
-BOOL       TranslateMDISysAccel(HWND,LPMSG16);
-BOOL       TranslateMessage(LPMSG16);
-int        UpdateColors(HDC16);
-void       WaitMessage(void);
-int        WaitSoundState(int);
-
 #endif  /* NO_TRANSITION_TYPES */
 
 #define WINELIB_UNIMP(x) fprintf (stderr, "WineLib: Unimplemented %s\n", x)
diff --git a/library/miscstubs.c b/library/miscstubs.c
index a9986a4..e6177ee 100644
--- a/library/miscstubs.c
+++ b/library/miscstubs.c
@@ -45,18 +45,18 @@
   }
 }
 
-extern LRESULT ColorDlgProc(HWND,UINT,WPARAM16,LPARAM);
-extern LRESULT ComboBoxWndProc(HWND,UINT,WPARAM16,LPARAM);
-extern LRESULT ComboLBoxWndProc(HWND,UINT,WPARAM16,LPARAM);
-extern LRESULT FileOpenDlgProc(HWND,UINT,WPARAM16,LPARAM);
-extern LRESULT FileSaveDlgProc(HWND,UINT,WPARAM16,LPARAM);
-extern LRESULT FindTextDlgProc(HWND,UINT,WPARAM16,LPARAM);
-extern LRESULT MDIClientWndProc(HWND,UINT,WPARAM16,LPARAM);
-extern LRESULT PrintDlgProc(HWND,UINT,WPARAM16,LPARAM);
-extern LRESULT PrintSetupDlgProc(HWND,UINT,WPARAM16,LPARAM);
-extern LRESULT ReplaceTextDlgProc(HWND,UINT,WPARAM16,LPARAM);
-extern LRESULT ScrollBarWndProc(HWND,UINT,WPARAM16,LPARAM);
-extern LRESULT StaticWndProc(HWND,UINT,WPARAM16,LPARAM);
+extern LRESULT ColorDlgProc(HWND16,UINT,WPARAM16,LPARAM);
+extern LRESULT ComboBoxWndProc(HWND16,UINT,WPARAM16,LPARAM);
+extern LRESULT ComboLBoxWndProc(HWND16,UINT,WPARAM16,LPARAM);
+extern LRESULT FileOpenDlgProc(HWND16,UINT,WPARAM16,LPARAM);
+extern LRESULT FileSaveDlgProc(HWND16,UINT,WPARAM16,LPARAM);
+extern LRESULT FindTextDlgProc(HWND16,UINT,WPARAM16,LPARAM);
+extern LRESULT MDIClientWndProc(HWND16,UINT,WPARAM16,LPARAM);
+extern LRESULT PrintDlgProc(HWND16,UINT,WPARAM16,LPARAM);
+extern LRESULT PrintSetupDlgProc(HWND16,UINT,WPARAM16,LPARAM);
+extern LRESULT ReplaceTextDlgProc(HWND16,UINT,WPARAM16,LPARAM);
+extern LRESULT ScrollBarWndProc(HWND16,UINT,WPARAM16,LPARAM);
+extern LRESULT StaticWndProc(HWND16,UINT,WPARAM16,LPARAM);
 extern LRESULT TASK_Reschedule(void);
 
 /***********************************************************************
diff --git a/loader/main.c b/loader/main.c
index 1c1ee9c..64854d6 100644
--- a/loader/main.c
+++ b/loader/main.c
@@ -148,7 +148,7 @@
     if (!QUEUE_CreateSysMsgQueue( queueSize )) return 0;
 
     /* Set double click time */
-    SetDoubleClickTime( GetProfileInt32A("windows","DoubleClickSpeed",452) );
+    SetDoubleClickTime32( GetProfileInt32A("windows","DoubleClickSpeed",452) );
 
     return 1;
 }
diff --git a/loader/pe_image.c b/loader/pe_image.c
index d30b09b..59d15cb 100644
--- a/loader/pe_image.c
+++ b/loader/pe_image.c
@@ -37,7 +37,7 @@
 
 void dump_exports(IMAGE_EXPORT_DIRECTORY * pe_exports, unsigned int load_addr)
 { 
-  char		*Module;
+  char		*Module,*s;
   int		i;
   u_short	*ordinal;
   u_long	*function,*functions;
@@ -73,6 +73,7 @@
 	  daddr.off=RVA(*functions);
 	  function++;
       }
+      while ((s=strchr(buffer,'.'))) *s='_';
       DEBUG_AddSymbol(buffer,&daddr, NULL, SYM_WIN32 | SYM_FUNC);
   }
 }
@@ -536,6 +537,8 @@
 	if(pe->pe_export) dump_exports(pe->pe_export,load_addr);
   		
 	if (pe->pe_export) {
+		char	*s;
+
 		/* add start of sections as debugsymbols */
 		for(i=0;i<pe->pe_header->FileHeader.NumberOfSections;i++) {
 			sprintf(buffer,"%s_%s",
@@ -543,11 +546,13 @@
 				pe->pe_seg[i].Name
 			);
 			daddr.off= RVA(pe->pe_seg[i].VirtualAddress);
+      			while ((s=strchr(buffer,'.'))) *s='_';
 			DEBUG_AddSymbol(buffer,&daddr, NULL, SYM_WIN32 | SYM_FUNC);
 		}
 		/* add entry point */
 		sprintf(buffer,"%s_EntryPoint",(char*)RVA(pe->pe_export->Name));
 		daddr.off=RVA(pe->pe_header->OptionalHeader.AddressOfEntryPoint);
+      		while ((s=strchr(buffer,'.'))) *s='_';
 		DEBUG_AddSymbol(buffer,&daddr, NULL, SYM_WIN32 | SYM_FUNC);
 		/* add start of DLL */
 		daddr.off=load_addr;
diff --git a/loader/signal.c b/loader/signal.c
index 769b510..e1fba1f 100644
--- a/loader/signal.c
+++ b/loader/signal.c
@@ -99,7 +99,7 @@
  */
 static void SIGNAL_child(void)
 {
-#ifdef __svr4__
+#if defined(__svr4__) || defined(__EMX__)
     wait(NULL);
 #else
     wait4( 0, NULL, WNOHANG, NULL);
@@ -195,6 +195,15 @@
     ret = sigaction( sig, &sig_act, NULL );
 #endif  /* __svr4__ || _SCO_DS */
 
+#if defined(__EMX__)
+    sigset_t sig_mask;
+    sigemptyset(&sig_mask);
+    sig_act.sa_handler = func;
+    sig_act.sa_flags = 0; /* FIXME: EMX has only SA_ACK and SA_SYSV */
+    sig_act.sa_mask = sig_mask;
+    ret = sigaction( sig, &sig_act, NULL );
+#endif  /* __EMX__ */
+
     if (ret < 0)
     {
         perror( "sigaction" );
diff --git a/loader/task.c b/loader/task.c
index 864abad..d9a666f 100644
--- a/loader/task.c
+++ b/loader/task.c
@@ -833,7 +833,8 @@
   if( pTask )
   {
     pQ = (MESSAGEQUEUE*)GlobalLock16(pTask->hQueue);
-    if( pQ && pQ->flags & QUEUE_FLAG_XEVENT )
+    if( pQ && pQ->flags & QUEUE_FLAG_XEVENT &&
+	    !(pQ->wakeBits & (QS_SENDMESSAGE | QS_SMRESULT)) )
     {
       pQ->flags &= ~QUEUE_FLAG_XEVENT;
       EVENT_WaitXEvent( FALSE, FALSE );
diff --git a/memory/atom.c b/memory/atom.c
index 581de04..598c267 100644
--- a/memory/atom.c
+++ b/memory/atom.c
@@ -132,7 +132,7 @@
     int len;
 
     if (str[0] == '#') return atoi( &str[1] );  /* Check for integer atom */
-    if ((len = strlen( str )) > 255) len = 255;
+    if ((len = strlen( str )) > MAX_ATOM_LEN) len = MAX_ATOM_LEN;
     if (!(table = ATOM_GetTable( selector, TRUE ))) return 0;
     hash = ATOM_Hash( table->size, str, len );
     entry = table->entries[hash];
@@ -261,9 +261,9 @@
 
 
 /***********************************************************************
- *           InitAtomTable   (KERNEL.68)
+ *           InitAtomTable16   (KERNEL.68)
  */
-WORD InitAtomTable( WORD entries )
+WORD InitAtomTable16( WORD entries )
 {
     return ATOM_InitTable( CURRENT_DS, entries );
 }
@@ -280,9 +280,9 @@
 
 
 /***********************************************************************
- *           AddAtom   (KERNEL.70)
+ *           AddAtom16   (KERNEL.70)
  */
-ATOM AddAtom( SEGPTR str )
+ATOM AddAtom16( SEGPTR str )
 {
     ATOM atom;
     HANDLE16 ds = CURRENT_DS;
@@ -292,7 +292,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];
+        char buffer[MAX_ATOM_LEN+1];
         lstrcpyn32A( buffer, (char *)PTR_SEG_TO_LIN(str), sizeof(buffer) );
         atom = ATOM_AddAtom( ds, buffer );
     }
@@ -302,18 +302,45 @@
 
 
 /***********************************************************************
- *           DeleteAtom   (KERNEL.71)
+ *           AddAtom32A   (KERNEL32.0)
  */
-ATOM DeleteAtom( ATOM atom )
+ATOM AddAtom32A( LPCSTR str )
+{
+    return GlobalAddAtom32A( str );  /* FIXME */
+}
+
+
+/***********************************************************************
+ *           AddAtom32W   (KERNEL32.1)
+ */
+ATOM AddAtom32W( LPCWSTR str )
+{
+    return GlobalAddAtom32W( str );  /* FIXME */
+}
+
+
+/***********************************************************************
+ *           DeleteAtom16   (KERNEL.71)
+ */
+ATOM DeleteAtom16( ATOM atom )
 {
     return ATOM_DeleteAtom( CURRENT_DS, atom );
 }
 
 
 /***********************************************************************
- *           FindAtom   (KERNEL.69)
+ *           DeleteAtom32   (KERNEL32.69)
  */
-ATOM FindAtom( SEGPTR str )
+ATOM DeleteAtom32( ATOM atom )
+{
+    return GlobalDeleteAtom( atom );  /* FIXME */
+}
+
+
+/***********************************************************************
+ *           FindAtom16   (KERNEL.69)
+ */
+ATOM FindAtom16( SEGPTR str )
 {
     if (!HIWORD(str)) return (ATOM)LOWORD(str);  /* Integer atom */
     return ATOM_FindAtom( CURRENT_DS, (LPCSTR)PTR_SEG_TO_LIN(str) );
@@ -321,11 +348,47 @@
 
 
 /***********************************************************************
- *           GetAtomName   (KERNEL.72)
+ *           FindAtom32A   (KERNEL32.117)
  */
-WORD GetAtomName( ATOM atom, LPSTR buffer, short count )
+ATOM FindAtom32A( LPCSTR str )
 {
-    return (WORD)ATOM_GetAtomName( CURRENT_DS, atom, buffer, count );
+    return GlobalFindAtom32A( str );  /* FIXME */
+}
+
+
+/***********************************************************************
+ *           FindAtom32W   (KERNEL32.118)
+ */
+ATOM FindAtom32W( LPCWSTR str )
+{
+    return GlobalFindAtom32W( str );  /* FIXME */
+}
+
+
+/***********************************************************************
+ *           GetAtomName16   (KERNEL.72)
+ */
+UINT16 GetAtomName16( ATOM atom, LPSTR buffer, INT16 count )
+{
+    return (UINT16)ATOM_GetAtomName( CURRENT_DS, atom, buffer, count );
+}
+
+
+/***********************************************************************
+ *           GetAtomName32A   (KERNEL32.149)
+ */
+UINT32 GetAtomName32A( ATOM atom, LPSTR buffer, INT32 count )
+{
+    return GlobalGetAtomName32A( atom, buffer, count );  /* FIXME */
+}
+
+
+/***********************************************************************
+ *           GetAtomName32W   (KERNEL32.150)
+ */
+UINT32 GetAtomName32W( ATOM atom, LPWSTR buffer, INT32 count )
+{
+    return GlobalGetAtomName32W( atom, buffer, count );  /* FIXME */
 }
 
 
diff --git a/memory/global.c b/memory/global.c
index 5c3998f..3b15549 100644
--- a/memory/global.c
+++ b/memory/global.c
@@ -14,11 +14,13 @@
 #include "heap.h"
 #include "toolhelp.h"
 #include "selectors.h"
+#include "miscemu.h"
 #include "dde_mem.h"
 #include "stackframe.h"
 #include "options.h"
 #include "stddebug.h"
 #include "debug.h"
+#include "winerror.h"
 
   /* Global arena block */
 typedef struct
@@ -533,18 +535,18 @@
 
 
 /***********************************************************************
- *           GlobalWire   (KERNEL.111)
+ *           GlobalWire16   (KERNEL.111)
  */
-SEGPTR GlobalWire( HGLOBAL16 handle )
+SEGPTR GlobalWire16( HGLOBAL16 handle )
 {
     return WIN16_GlobalLock16( handle );
 }
 
 
 /***********************************************************************
- *           GlobalUnWire   (KERNEL.112)
+ *           GlobalUnWire16   (KERNEL.112)
  */
-BOOL16 GlobalUnWire( HGLOBAL16 handle )
+BOOL16 GlobalUnWire16( HGLOBAL16 handle )
 {
     return GlobalUnlock16( handle );
 }
@@ -583,16 +585,51 @@
 
 
 /***********************************************************************
- *           GetFreeSpace   (KERNEL.169)
+ *           GetFreeSpace16   (KERNEL.169)
  */
-DWORD GetFreeSpace( UINT16 wFlags )
+DWORD GetFreeSpace16( UINT16 wFlags )
 {
-    MEMORYSTATUS	ms;
-
+    MEMORYSTATUS ms;
     GlobalMemoryStatus( &ms );
     return ms.dwAvailVirtual;
 }
 
+/***********************************************************************
+ *           GlobalDOSAlloc   (KERNEL.184)
+ */
+DWORD GlobalDOSAlloc(DWORD size)
+{
+   UINT16    uParagraph;
+   LPVOID    lpBlock = DOSMEM_GetBlock( size, &uParagraph );
+   
+   if( lpBlock )
+   {
+       HMODULE16 hModule = GetModuleHandle("KERNEL");
+       WORD	 wSelector;
+   
+       wSelector = GLOBAL_CreateBlock(GMEM_FIXED, lpBlock, size, 
+				      hModule, 0, 0, 0, NULL );
+       return MAKELONG(wSelector,uParagraph);
+   }
+   return 0;
+}
+
+/***********************************************************************
+ *           GlobalDOSFree      (KERNEL.185)
+ */
+WORD GlobalDOSFree(WORD sel)
+{
+   DWORD   block = GetSelectorBase(sel);
+
+   if( block && block < 0x100000 ) 
+   {
+       LPVOID lpBlock = DOSMEM_MapDosToLinear( block );
+       if( DOSMEM_FreeBlock( lpBlock ) )
+	   GLOBAL_FreeBlock( sel );
+       sel = 0;
+   }
+   return sel;
+}
 
 /***********************************************************************
  *           GlobalPageLock   (KERNEL.191)
@@ -615,21 +652,21 @@
 
 
 /***********************************************************************
- *           GlobalFix   (KERNEL.197)
+ *           GlobalFix16   (KERNEL.197)
  */
-void GlobalFix( HGLOBAL16 handle )
+void GlobalFix16( HGLOBAL16 handle )
 {
-    dprintf_global( stddeb, "GlobalFix: %04x\n", handle );
+    dprintf_global( stddeb, "GlobalFix16: %04x\n", handle );
     GET_ARENA_PTR(handle)->lockCount++;
 }
 
 
 /***********************************************************************
- *           GlobalUnfix   (KERNEL.198)
+ *           GlobalUnfix16   (KERNEL.198)
  */
-void GlobalUnfix( HGLOBAL16 handle )
+void GlobalUnfix16( HGLOBAL16 handle )
 {
-    dprintf_global( stddeb, "GlobalUnfix: %04x\n", handle );
+    dprintf_global( stddeb, "GlobalUnfix16: %04x\n", handle );
     GET_ARENA_PTR(handle)->lockCount--;
 }
 
@@ -776,19 +813,365 @@
     return TRUE;
 }
 
+/*
+ * Win32 Global heap functions (GlobalXXX).
+ * These functions included in Win32 for compatibility with 16 bit Windows
+ * Especially the moveable blocks and handles are oldish. 
+ * But the ability to directly allocate memory with GPTR and LPTR is widely
+ * used.
+ *
+ * The handle stuff looks horrible, but it's implemented almost like Win95
+ * does it. 
+ *
+ */
+
+#define MAGIC_GLOBAL_USED 0x5342
+#define GLOBAL_LOCK_MAX   0xFF
+#define HANDLE_TO_INTERN(h)  (PGLOBAL32_INTERN)(((char *)(h))-2)
+#define INTERN_TO_HANDLE(i)  ((HGLOBAL32) &((i)->Pointer))
+#define POINTER_TO_HANDLE(p) (*(((HGLOBAL32 *)(p))-1))
+#define ISHANDLE(h)          (((DWORD)(h)&2)!=0)
+#define ISPOINTER(h)         (((DWORD)(h)&2)==0)
+
+typedef struct __GLOBAL32_INTERN
+{
+   WORD         Magic;
+   LPVOID       Pointer WINE_PACKED;
+   BYTE         Flags;
+   BYTE         LockCount;
+} GLOBAL32_INTERN, *PGLOBAL32_INTERN;
+
 
 /***********************************************************************
  *           GlobalAlloc32   (KERNEL32.315)
  */
-HGLOBAL32 GlobalAlloc32( UINT32 flags, DWORD size )
+HGLOBAL32 GlobalAlloc32(UINT32 flags, DWORD size)
 {
-    DWORD heapFlags = 0;
+   PGLOBAL32_INTERN     pintern;
+   DWORD		hpflags;
+   LPVOID               palloc;
 
-    if (flags & GMEM_MOVEABLE)
-        fprintf( stderr, "GlobalAlloc32: unimplemented flag GMEM_MOVEABLE\n" );
+   if(flags&GMEM_ZEROINIT)
+      hpflags=HEAP_ZERO_MEMORY;
+   else
+      hpflags=0;
+   
+   if((flags & GMEM_MOVEABLE)==0) /* POINTER */
+   {
+      palloc=HeapAlloc(GetProcessHeap(), hpflags, size);
+      return (HGLOBAL32) palloc;
+   }
+   else  /* HANDLE */
+   {
+      /* HeapLock(GetProcessHeap()); */
 
-    if (flags & GMEM_ZEROINIT) heapFlags |= HEAP_ZERO_MEMORY;
-    return (HGLOBAL32)HeapAlloc( GetProcessHeap(), heapFlags, size );
+      pintern=HeapAlloc(GetProcessHeap(), 0,  sizeof(GLOBAL32_INTERN));
+      if(size)
+      {
+	 palloc=HeapAlloc(GetProcessHeap(), 0, size+sizeof(HGLOBAL32));
+	 *(HGLOBAL32 *)palloc=INTERN_TO_HANDLE(pintern);
+	 pintern->Pointer=palloc+sizeof(HGLOBAL32);
+      }
+      else
+	 pintern->Pointer=NULL;
+      pintern->Magic=MAGIC_GLOBAL_USED;
+      pintern->Flags=flags>>8;
+      pintern->LockCount=0;
+      
+      /* HeapUnlock(GetProcessHeap()); */
+       
+      return INTERN_TO_HANDLE(pintern);
+   }
+}
+
+
+/***********************************************************************
+ *           GlobalLock32   (KERNEL32.326)
+ */
+LPVOID  GlobalLock32(HGLOBAL32 hmem)
+{
+   PGLOBAL32_INTERN pintern;
+   LPVOID           palloc;
+
+   if(ISPOINTER(hmem))
+      return (LPVOID) hmem;
+
+   /* HeapLock(GetProcessHeap()); */
+   
+   pintern=HANDLE_TO_INTERN(hmem);
+   if(pintern->Magic==MAGIC_GLOBAL_USED)
+   {
+      if(pintern->LockCount<GLOBAL_LOCK_MAX)
+	 pintern->LockCount++;
+      palloc=pintern->Pointer;
+   }
+   else
+   {
+      dprintf_global(stddeb, "GlobalLock32: invalid handle\n");
+      palloc=(LPVOID) NULL;
+   }
+   /* HeapUnlock(GetProcessHeap()); */;
+   return palloc;
+}
+
+
+/***********************************************************************
+ *           GlobalUnlock32   (KERNEL32.332)
+ */
+BOOL32 GlobalUnlock32(HGLOBAL32 hmem)
+{
+   PGLOBAL32_INTERN       pintern;
+   BOOL32                 locked;
+
+   if(ISPOINTER(hmem))
+      return FALSE;
+
+   /* HeapLock(GetProcessHeap()); */
+   pintern=HANDLE_TO_INTERN(hmem);
+   
+   if(pintern->Magic==MAGIC_GLOBAL_USED)
+   {
+      if((pintern->LockCount<GLOBAL_LOCK_MAX)&&(pintern->LockCount>0))
+	 pintern->LockCount--;
+
+      locked=(pintern->LockCount==0) ? FALSE : TRUE;
+   }
+   else
+   {
+      dprintf_global(stddeb, "GlobalUnlock32: invalid handle\n");
+      locked=FALSE;
+   }
+   /* HeapUnlock(GetProcessHeap()); */
+   return locked;
+}
+
+
+/***********************************************************************
+ *           GlobalHandle32   (KERNEL32.325)
+ */
+HGLOBAL32 GlobalHandle32(LPCVOID pmem)
+{
+   return (HGLOBAL32) POINTER_TO_HANDLE(pmem);
+}
+
+
+/***********************************************************************
+ *           GlobalReAlloc32   (KERNEL32.328)
+ */
+HGLOBAL32 GlobalReAlloc32(HGLOBAL32 hmem, DWORD size, UINT32 flags)
+{
+   LPVOID               palloc;
+   HGLOBAL32            hnew;
+   PGLOBAL32_INTERN     pintern;
+
+   hnew=NULL;
+   /* HeapLock(GetProcessHeap()); */
+   if(flags & GMEM_MODIFY) /* modify flags */
+   {
+      if( ISPOINTER(hmem) && (flags & GMEM_MOVEABLE))
+      {
+	 /* make a fixed block moveable
+	  * actually only NT is able to do this. But it's soo simple
+	  */
+	 size=HeapSize(GetProcessHeap(), 0, (LPVOID) hmem);
+	 hnew=GlobalAlloc32( flags, size);
+	 palloc=GlobalLock32(hnew);
+	 memcpy(palloc, (LPVOID) hmem, size);
+	 GlobalUnlock32(hnew);
+	 GlobalFree32(hmem);
+      }
+      else if( ISPOINTER(hmem) &&(flags & GMEM_DISCARDABLE))
+      {
+	 /* change the flags to make our block "discardable" */
+	 pintern=HANDLE_TO_INTERN(hmem);
+	 pintern->Flags = pintern->Flags | (GMEM_DISCARDABLE >> 8);
+	 hnew=hmem;
+      }
+      else
+      {
+	 SetLastError(ERROR_INVALID_PARAMETER);
+	 hnew=NULL;
+      }
+   }
+   else
+   {
+      if(ISPOINTER(hmem))
+      {
+	 /* reallocate fixed memory */
+	 hnew=(HGLOBAL32)HeapReAlloc(GetProcessHeap(), 0, (LPVOID) hmem, size);
+      }
+      else
+      {
+	 /* reallocate a moveable block */
+	 pintern=HANDLE_TO_INTERN(hmem);
+	 if(pintern->LockCount!=0)
+	    SetLastError(ERROR_INVALID_HANDLE);
+	 else if(size!=0)
+	 {
+	    hnew=hmem;
+	    if(pintern->Pointer)
+	    {
+	       palloc=HeapReAlloc(GetProcessHeap(), 0,
+				  pintern->Pointer-sizeof(HGLOBAL32),
+				  size+sizeof(HGLOBAL32) );
+	       pintern->Pointer=palloc+sizeof(HGLOBAL32);
+	    }
+	    else
+	    {
+	       palloc=HeapAlloc(GetProcessHeap(), 0, size+sizeof(HGLOBAL32));
+	       *(HGLOBAL32 *)palloc=hmem;
+	       pintern->Pointer=palloc+sizeof(HGLOBAL32);
+	    }
+	 }
+	 else
+	 {
+	    if(pintern->Pointer)
+	    {
+	       HeapFree(GetProcessHeap(), 0, pintern->Pointer-sizeof(HGLOBAL32));
+	       pintern->Pointer=NULL;
+	    }
+	 }
+      }
+   }
+   /* HeapUnlock(GetProcessHeap()); */
+   return hnew;
+}
+
+
+/***********************************************************************
+ *           GlobalFree32   (KERNEL32.322)
+ */
+HGLOBAL32 GlobalFree32(HGLOBAL32 hmem)
+{
+   PGLOBAL32_INTERN pintern;
+   HGLOBAL32        hreturned=NULL;
+   
+   if(ISPOINTER(hmem)) /* POINTER */
+   {
+      if(!HeapFree(GetProcessHeap(), 0, (LPVOID) hmem))
+         hmem=NULL;
+   }
+   else  /* HANDLE */
+   {
+      /* HeapLock(GetProcessHeap()); */      
+      pintern=HANDLE_TO_INTERN(hmem);
+      
+      if(pintern->Magic==MAGIC_GLOBAL_USED)
+      {	 
+	 if(pintern->LockCount!=0)
+	    SetLastError(ERROR_INVALID_HANDLE);
+	 if(pintern->Pointer)
+	    if(!HeapFree(GetProcessHeap(), 0, 
+	                 (char *)(pintern->Pointer)-sizeof(HGLOBAL32)))
+	       hreturned=hmem;
+	 if(!HeapFree(GetProcessHeap(), 0, pintern)) 
+	    hreturned=hmem;
+      }      
+      /* HeapUnlock(GetProcessHeap()); */
+   }
+   return hreturned;
+}
+
+
+/***********************************************************************
+ *           GlobalSize32   (KERNEL32.329)
+ */
+DWORD  GlobalSize32(HGLOBAL32 hmem)
+{
+   DWORD                retval;
+   PGLOBAL32_INTERN     pintern;
+
+   if(ISPOINTER(hmem)) 
+   {
+      retval=HeapSize(GetProcessHeap(), 0,  (LPVOID) hmem);
+   }
+   else
+   {
+      /* HeapLock(GetProcessHeap()); */
+      pintern=HANDLE_TO_INTERN(hmem);
+      
+      if(pintern->Magic==MAGIC_GLOBAL_USED)
+      {
+	 retval=HeapSize(GetProcessHeap(), 0, 
+	                 (char *)(pintern->Pointer)-sizeof(HGLOBAL32))-4;
+      }
+      else
+      {
+	 dprintf_global(stddeb, "GlobalSize32: invalid handle\n");
+	 retval=0;
+      }
+      /* HeapUnlock(GetProcessHeap()); */
+   }
+   return retval;
+}
+
+
+/***********************************************************************
+ *           GlobalWire32   (KERNEL32.333)
+ */
+LPVOID  GlobalWire32(HGLOBAL32 hmem)
+{
+   return GlobalLock32( hmem );
+}
+
+
+/***********************************************************************
+ *           GlobalUnWire32   (KERNEL32.330)
+ */
+BOOL32  GlobalUnWire32(HGLOBAL32 hmem)
+{
+   return GlobalUnlock32( hmem);
+}
+
+
+/***********************************************************************
+ *           GlobalFix32   (KERNEL32.320)
+ */
+VOID  GlobalFix32(HGLOBAL32 hmem)
+{
+    GlobalLock32( hmem );
+}
+
+
+/***********************************************************************
+ *           GlobalUnfix32   (KERNEL32.331)
+ */
+VOID  GlobalUnfix32(HGLOBAL32 hmem)
+{
+   GlobalUnlock32( hmem);
+}
+
+
+/***********************************************************************
+ *           GlobalFlags32   (KERNEL32.321)
+ */
+UINT32  GlobalFlags32(HGLOBAL32 hmem)
+{
+   DWORD                retval;
+   PGLOBAL32_INTERN     pintern;
+   
+   if(ISPOINTER(hmem))
+   {
+      retval=0;
+   }
+   else
+   {
+      /* HeapLock(GetProcessHeap()); */
+      pintern=HANDLE_TO_INTERN(hmem);
+      if(pintern->Magic==MAGIC_GLOBAL_USED)
+      {               
+	 retval=pintern->LockCount + (pintern->Flags<<8);
+	 if(pintern->Pointer==0)
+	    retval|= GMEM_DISCARDED;
+      }
+      else
+      {
+	 dprintf_global(stddeb,"GlobalFlags32: invalid handle\n");
+	 retval=0;
+      }
+      /* HeapUnlock(GetProcessHeap()); */
+   }
+   return retval;
 }
 
 
@@ -802,75 +1185,6 @@
 
 
 /***********************************************************************
- *           GlobalFlags32   (KERNEL32.321)
- */
-UINT32 GlobalFlags32( HGLOBAL32 handle )
-{
-    return 0;
-}
-
-
-/***********************************************************************
- *           GlobalFree32   (KERNEL32.322)
- */
-HGLOBAL32 GlobalFree32( HGLOBAL32 handle )
-{
-    return HeapFree( GetProcessHeap(), 0, (LPVOID)handle ) ? 0 : handle;
-}
-
-
-/***********************************************************************
- *           GlobalHandle32   (KERNEL32.325)
- */
-HGLOBAL32 GlobalHandle32( LPCVOID ptr )
-{
-    return (HGLOBAL32)ptr;
-}
-
-
-/***********************************************************************
- *           GlobalLock32   (KERNEL32.326)
- */
-LPVOID GlobalLock32( HGLOBAL32 handle )
-{
-    return (LPVOID)handle;
-}
-
-
-/***********************************************************************
- *           GlobalReAlloc32   (KERNEL32.328)
- */
-HGLOBAL32 GlobalReAlloc32( HGLOBAL32 handle, DWORD size, UINT32 flags )
-{
-    if (flags & GMEM_MODIFY)
-    {
-        fprintf( stderr, "GlobalReAlloc32: GMEM_MODIFY not supported\n" );
-        return 0;
-    }
-
-    return (HGLOBAL32)HeapReAlloc( GetProcessHeap(), 0, (LPVOID)handle, size );
-}
-
-
-/***********************************************************************
- *           GlobalSize32   (KERNEL32.329)
- */
-DWORD GlobalSize32( HGLOBAL32 handle )
-{
-    return HeapSize( GetProcessHeap(), 0, (LPVOID)handle );
-}
-
-
-/***********************************************************************
- *           GlobalUnlock32   (KERNEL32.332)
- */
-BOOL32 GlobalUnlock32( HGLOBAL32 handle )
-{
-    return TRUE;
-}
-
-
-/***********************************************************************
  *           GlobalMemoryStatus   (KERNEL32.327)
  */
 VOID GlobalMemoryStatus( LPMEMORYSTATUS lpmem )
diff --git a/memory/selector.c b/memory/selector.c
index 9d76477..bbb25c6 100644
--- a/memory/selector.c
+++ b/memory/selector.c
@@ -266,17 +266,12 @@
  */
 DWORD GetSelectorBase( WORD sel )
 {
-    extern char* DOSMEM_dosmem;
-    DWORD base;
-
-    base = GET_SEL_BASE(sel);
+    DWORD base = GET_SEL_BASE(sel);
 
     /* if base points into DOSMEM, assume we have to
-     * return pointer into physical lower 1MB
-     */
-    if ((base >= (DWORD)DOSMEM_dosmem) &&
-        (base < (DWORD)DOSMEM_dosmem+0x100000)) base -= (DWORD)DOSMEM_dosmem;
-    return base;
+     * return pointer into physical lower 1MB */
+
+    return DOSMEM_MapLinearToDos( (LPVOID)base );
 }
 
 
@@ -285,23 +280,12 @@
  */
 WORD SetSelectorBase( WORD sel, DWORD base )
 {
-    extern char* DOSMEM_dosmem;
     ldt_entry entry;
 
     LDT_GetEntry( SELECTOR_TO_ENTRY(sel), &entry );
-#ifndef WINELIB
-    if (base < 0x100000)
-    {
-    	/* Assume pointers in the lower 1MB range are
-	 * in fact physical addresses into DOS memory.
-	 * Translate the base to our internal representation
-	 *
-	 * (NETAPI.DLL of Win95 does use SetSelectorBase this way)
-	 */
-	entry.base = (DWORD)(DOSMEM_dosmem+base);
-    }
-    else entry.base = base;
-#endif
+
+    entry.base = (DWORD)DOSMEM_MapDosToLinear(base);
+
     LDT_SetEntry( SELECTOR_TO_ENTRY(sel), &entry );
     return sel;
 }
diff --git a/misc/clipboard.c b/misc/clipboard.c
index f7d38ae..bc64aac 100644
--- a/misc/clipboard.c
+++ b/misc/clipboard.c
@@ -41,9 +41,9 @@
  *			internal variables
  */
 
-static HWND hWndClipOwner  = 0;		/* current clipboard owner */
-static HWND hWndClipWindow = 0;		/* window that opened clipboard */
-static HWND hWndViewer     = 0;		/* start of viewers chain */
+static HWND32 hWndClipOwner  = 0;   /* current clipboard owner */
+static HWND32 hWndClipWindow = 0;   /* window that opened clipboard */
+static HWND32 hWndViewer     = 0;   /* start of viewers chain */
 
 static BOOL bClipChanged  = FALSE;
 static WORD LastRegFormat = CF_REGFORMATBASE;
@@ -160,7 +160,7 @@
  */
 BOOL CLIPBOARD_RequestXSelection()
 {
-  HWND hWnd = (hWndClipWindow) ? hWndClipWindow : GetActiveWindow16();
+  HWND32 hWnd = (hWndClipWindow) ? hWndClipWindow : GetActiveWindow32();
 
   if( !hWnd ) return FALSE;
 
@@ -197,7 +197,7 @@
     /* special case */
 
     if( wFormat == CF_TEXT || wFormat == CF_OEMTEXT )
-        return lpFormat[CF_TEXT-1].wDataPresent | 
+        return lpFormat[CF_TEXT-1].wDataPresent ||
                lpFormat[CF_OEMTEXT-1].wDataPresent;
 
     while(TRUE) {
@@ -210,11 +210,20 @@
 }
 
 /**************************************************************************
- *			OpenClipboard		[USER.137]
+ *            OpenClipboard16   (USER.137)
  */
-BOOL OpenClipboard(HWND hWnd)
+BOOL16 OpenClipboard16( HWND16 hWnd )
 {
-    BOOL bRet = FALSE;
+    return OpenClipboard32( hWnd );
+}
+
+
+/**************************************************************************
+ *            OpenClipboard32   (USER32.406)
+ */
+BOOL32 OpenClipboard32( HWND32 hWnd )
+{
+    BOOL32 bRet = FALSE;
     dprintf_clipboard(stddeb,"OpenClipboard(%04x) = ", hWnd);
 
     if (!hWndClipWindow)
@@ -230,9 +239,18 @@
 
 
 /**************************************************************************
- *			CloseClipboard		[USER.138]
+ *            CloseClipboard16   (USER.138)
  */
-BOOL CloseClipboard()
+BOOL16 CloseClipboard16(void)
+{
+    return CloseClipboard32();
+}
+
+
+/**************************************************************************
+ *            CloseClipboard32   (USER32.53)
+ */
+BOOL32 CloseClipboard32(void)
 {
     dprintf_clipboard(stddeb,"CloseClipboard(); !\n");
 
@@ -246,9 +264,18 @@
 
 
 /**************************************************************************
- *			EmptyClipboard		[USER.139]
+ *            EmptyClipboard16   (USER.139)
  */
-BOOL EmptyClipboard()
+BOOL16 EmptyClipboard16(void)
+{
+    return EmptyClipboard32();
+}
+
+
+/**************************************************************************
+ *            EmptyClipboard32   (USER32.168)
+ */
+BOOL32 EmptyClipboard32(void)
 {
     LPCLIPFORMAT lpFormat = ClipFormats; 
 
@@ -287,12 +314,19 @@
 
 
 /**************************************************************************
- *			GetClipboardOwner	[USER.140]
+ *            GetClipboardOwner16   (USER.140)
  */
-HWND GetClipboardOwner()
+HWND16 GetClipboardOwner16(void)
 {
-    dprintf_clipboard(stddeb,
-		"GetClipboardOwner() = %04x !\n", hWndClipOwner);
+    return hWndClipOwner;
+}
+
+
+/**************************************************************************
+ *            GetClipboardOwner32   (USER32.224)
+ */
+HWND32 GetClipboardOwner32(void)
+{
     return hWndClipOwner;
 }
 
@@ -452,11 +486,20 @@
 
 
 /**************************************************************************
- *			CountClipboardFormats	[USER.143]
+ *           CountClipboardFormats16   (USER.143)
  */
-INT CountClipboardFormats()
+INT16 CountClipboardFormats16(void)
 {
-    int 	 FormatCount = 0;
+    return CountClipboardFormats32();
+}
+
+
+/**************************************************************************
+ *           CountClipboardFormats32   (USER32.62)
+ */
+INT32 CountClipboardFormats32(void)
+{
+    INT32 FormatCount = 0;
     LPCLIPFORMAT lpFormat = ClipFormats; 
 
     dprintf_clipboard(stddeb,"CountClipboardFormats()\n");
@@ -483,9 +526,18 @@
 
 
 /**************************************************************************
- *			EnumClipboardFormats	[USER.144]
+ *            EnumClipboardFormats16   (USER.144)
  */
-UINT16 EnumClipboardFormats(UINT16 wFormat)
+UINT16 EnumClipboardFormats16( UINT16 wFormat )
+{
+    return EnumClipboardFormats32( wFormat );
+}
+
+
+/**************************************************************************
+ *            EnumClipboardFormats32   (USER32.178)
+ */
+UINT32 EnumClipboardFormats32( UINT32 wFormat )
 {
     LPCLIPFORMAT lpFormat = ClipFormats; 
 
@@ -621,11 +673,20 @@
 
 
 /**************************************************************************
- *			SetClipboardViewer	[USER.147]
+ *            SetClipboardViewer16   (USER.147)
  */
-HWND SetClipboardViewer(HWND hWnd)
+HWND16 SetClipboardViewer16( HWND16 hWnd )
 {
-    HWND hwndPrev = hWndViewer;
+    return SetClipboardViewer32( hWnd );
+}
+
+
+/**************************************************************************
+ *            SetClipboardViewer32   (USER32.470)
+ */
+HWND32 SetClipboardViewer32( HWND32 hWnd )
+{
+    HWND32 hwndPrev = hWndViewer;
 
     dprintf_clipboard(stddeb,"SetClipboardViewer(%04x)\n", hWnd);
 
@@ -635,12 +696,19 @@
 
 
 /**************************************************************************
- *			GetClipboardViewer	[USER.148]
+ *           GetClipboardViewer16   (USER.148)
  */
-HWND GetClipboardViewer()
+HWND16 GetClipboardViewer16(void)
 {
-    dprintf_clipboard(stddeb,"GetClipboardFormat() = %04x\n", hWndViewer);
+    return hWndViewer;
+}
 
+
+/**************************************************************************
+ *           GetClipboardViewer32   (USER32.225)
+ */
+HWND32 GetClipboardViewer32(void)
+{
     return hWndViewer;
 }
 
@@ -676,9 +744,18 @@
 
 
 /**************************************************************************
- *			IsClipboardFormatAvailable	[USER.193]
+ *           IsClipboardFormatAvailable16   (USER.193)
  */
-BOOL IsClipboardFormatAvailable(WORD wFormat)
+BOOL16 IsClipboardFormatAvailable16( UINT16 wFormat )
+{
+    return IsClipboardFormatAvailable32( wFormat );
+}
+
+
+/**************************************************************************
+ *           IsClipboardFormatAvailable32   (USER32.339)
+ */
+BOOL32 IsClipboardFormatAvailable32( UINT32 wFormat )
 {
     dprintf_clipboard(stddeb,"IsClipboardFormatAvailable(%04X) !\n", wFormat);
 
@@ -690,12 +767,19 @@
 
 
 /**************************************************************************
- *			GetOpenClipboardWindow	[USER.248]
+ *             GetOpenClipboardWindow16   (USER.248)
  */
-HWND GetOpenClipboardWindow()
+HWND16 GetOpenClipboardWindow16(void)
 {
-    dprintf_clipboard(stddeb,
-		"GetOpenClipboardWindow() = %04x\n", hWndClipWindow);
+    return hWndClipWindow;
+}
+
+
+/**************************************************************************
+ *             GetOpenClipboardWindow32   (USER32.276)
+ */
+HWND32 GetOpenClipboardWindow32(void)
+{
     return hWndClipWindow;
 }
 
@@ -793,7 +877,7 @@
  * Wine might have lost XA_PRIMARY selection because of
  * EmptyClipboard() or other client. 
  */
-void CLIPBOARD_ReleaseSelection(Window w, HWND hwnd)
+void CLIPBOARD_ReleaseSelection(Window w, HWND32 hwnd)
 {
   /* w is the window that lost selection,
    * 
diff --git a/misc/commdlg.c b/misc/commdlg.c
index ece3f03..7ebe94c 100644
--- a/misc/commdlg.c
+++ b/misc/commdlg.c
@@ -174,7 +174,7 @@
  *                              FILEDLG_StripEditControl        [internal]
  * Strip pathnames off the contents of the edit control.
  */
-static void FILEDLG_StripEditControl(HWND hwnd)
+static void FILEDLG_StripEditControl(HWND16 hwnd)
 {
     char temp[512], *cp;
 
@@ -193,7 +193,7 @@
 /***********************************************************************
  * 				FILEDLG_ScanDir			[internal]
  */
-static BOOL FILEDLG_ScanDir(HWND hWnd, LPSTR newPath)
+static BOOL FILEDLG_ScanDir(HWND16 hWnd, LPSTR newPath)
 {
     int len;
     char str[512];
@@ -235,7 +235,7 @@
 /***********************************************************************
  *                              FILEDLG_WMDrawItem              [internal]
  */
-static LONG FILEDLG_WMDrawItem(HWND hWnd, WPARAM16 wParam, LPARAM lParam,int savedlg)
+static LONG FILEDLG_WMDrawItem(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam,int savedlg)
 {
     LPDRAWITEMSTRUCT16 lpdis = (LPDRAWITEMSTRUCT16)PTR_SEG_TO_LIN(lParam);
     char *str;
@@ -255,9 +255,9 @@
 
 	if (savedlg)       /* use _gray_ text in FileSaveDlg */
 	  if (!lpdis->itemState)
-	    SetTextColor(lpdis->hDC,GetSysColor(COLOR_GRAYTEXT) );
+	    SetTextColor(lpdis->hDC,GetSysColor32(COLOR_GRAYTEXT) );
 	  else  
-	    SetTextColor(lpdis->hDC,GetSysColor(COLOR_WINDOWTEXT) );
+	    SetTextColor(lpdis->hDC,GetSysColor32(COLOR_WINDOWTEXT) );
 	    /* inversion of gray would be bad readable */	  	  
 
 	TextOut16(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
@@ -327,7 +327,7 @@
 /***********************************************************************
  *                              FILEDLG_WMMeasureItem           [internal]
  */
-static LONG FILEDLG_WMMeasureItem(HWND hWnd, WPARAM16 wParam, LPARAM lParam) 
+static LONG FILEDLG_WMMeasureItem(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam) 
 {
     BITMAP16 bm;
     LPMEASUREITEMSTRUCT16 lpmeasure;
@@ -354,7 +354,7 @@
  *                              FILEDLG_WMInitDialog            [internal]
  */
 
-static LONG FILEDLG_WMInitDialog(HWND hWnd, WPARAM16 wParam, LPARAM lParam) 
+static LONG FILEDLG_WMInitDialog(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam) 
 {
   int i, n;
   LPOPENFILENAME lpofn;
@@ -440,7 +440,7 @@
 /***********************************************************************
  *                              FILEDLG_WMCommand               [internal]
  */
-static LRESULT FILEDLG_WMCommand(HWND hWnd, WPARAM16 wParam, LPARAM lParam) 
+static LRESULT FILEDLG_WMCommand(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam) 
 {
   LONG lRet;
   LPOPENFILENAME lpofn;
@@ -619,10 +619,10 @@
          break;
        }
       }
-      EndDialog(hWnd, TRUE);
+      EndDialog32(hWnd, TRUE);
       return TRUE;
     case IDCANCEL:
-      EndDialog(hWnd, FALSE);
+      EndDialog32(hWnd, FALSE);
       return TRUE;
     }
   return FALSE;
@@ -632,7 +632,7 @@
 /***********************************************************************
  *           FileOpenDlgProc   (COMMDLG.6)
  */
-LRESULT FileOpenDlgProc(HWND hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam)
+LRESULT FileOpenDlgProc(HWND16 hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam)
 {  
  LPOPENFILENAME lpofn = (LPOPENFILENAME)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd, DWL_USER));
  
@@ -675,7 +675,7 @@
 /***********************************************************************
  *           FileSaveDlgProc   (COMMDLG.7)
  */
-LRESULT FileSaveDlgProc(HWND hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam)
+LRESULT FileSaveDlgProc(HWND16 hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam)
 {
  LPOPENFILENAME lpofn = (LPOPENFILENAME)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd, DWL_USER));
  
@@ -772,7 +772,7 @@
 /***********************************************************************
  *                              FINDDLG_WMInitDialog            [internal]
  */
-static LRESULT FINDDLG_WMInitDialog(HWND hWnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT FINDDLG_WMInitDialog(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam)
 {
     LPFINDREPLACE lpfr;
 
@@ -817,7 +817,7 @@
 /***********************************************************************
  *                              FINDDLG_WMCommand               [internal]
  */
-static LRESULT FINDDLG_WMCommand(HWND hWnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT FINDDLG_WMCommand(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam)
 {
     LPFINDREPLACE lpfr;
     int uFindReplaceMessage = RegisterWindowMessage32A( FINDMSGSTRING );
@@ -860,7 +860,7 @@
 /***********************************************************************
  *           FindTextDlgProc   (COMMDLG.13)
  */
-LRESULT FindTextDlgProc(HWND hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam)
+LRESULT FindTextDlgProc(HWND16 hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam)
 {
     switch (wMsg) {
 	case WM_INITDIALOG:
@@ -875,7 +875,7 @@
 /***********************************************************************
  *                              REPLACEDLG_WMInitDialog         [internal]
  */
-static LRESULT REPLACEDLG_WMInitDialog(HWND hWnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT REPLACEDLG_WMInitDialog(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam)
 {
     LPFINDREPLACE lpfr;
 
@@ -911,7 +911,7 @@
 /***********************************************************************
  *                              REPLACEDLG_WMCommand            [internal]
  */
-static LRESULT REPLACEDLG_WMCommand(HWND hWnd, WPARAM16 wParam, LPARAM lParam)
+static LRESULT REPLACEDLG_WMCommand(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam)
 {
     LPFINDREPLACE lpfr;
     int uFindReplaceMessage = RegisterWindowMessage32A( FINDMSGSTRING );
@@ -980,7 +980,7 @@
 /***********************************************************************
  *           ReplaceTextDlgProc   (COMMDLG.14)
  */
-LRESULT ReplaceTextDlgProc(HWND hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam)
+LRESULT ReplaceTextDlgProc(HWND16 hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam)
 {
     switch (wMsg) {
 	case WM_INITDIALOG:
@@ -1029,7 +1029,7 @@
 /***********************************************************************
  *           PrintDlgProc   (COMMDLG.21)
  */
-LRESULT PrintDlgProc(HWND hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam)
+LRESULT PrintDlgProc(HWND16 hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam)
 {
   switch (wMsg)
     {
@@ -1041,10 +1041,10 @@
       switch (wParam)
 	{
 	case IDOK:
-	  EndDialog(hWnd, TRUE);
+	  EndDialog32(hWnd, TRUE);
 	  return(TRUE);
 	case IDCANCEL:
-	  EndDialog(hWnd, FALSE);
+	  EndDialog32(hWnd, FALSE);
 	  return(TRUE);
 	}
       return(FALSE);
@@ -1056,7 +1056,7 @@
 /***********************************************************************
  *           PrintSetupDlgProc   (COMMDLG.22)
  */
-LRESULT PrintSetupDlgProc(HWND hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam)
+LRESULT PrintSetupDlgProc(HWND16 hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam)
 {
   switch (wMsg)
     {
@@ -1067,10 +1067,10 @@
     case WM_COMMAND:
       switch (wParam) {
       case IDOK:
-	EndDialog(hWnd, TRUE);
+	EndDialog32(hWnd, TRUE);
 	return(TRUE);
       case IDCANCEL:
-	EndDialog(hWnd, FALSE);
+	EndDialog32(hWnd, FALSE);
 	return(TRUE);
       }
       return(FALSE);
@@ -1330,10 +1330,10 @@
 /***********************************************************************
  *                CC_MouseCheckPredefColorArray               [internal]
  */
-static int CC_MouseCheckPredefColorArray(HWND hDlg,int dlgitem,int rows,int cols,
+static int CC_MouseCheckPredefColorArray(HWND16 hDlg,int dlgitem,int rows,int cols,
 	    LPARAM lParam,COLORREF *cr)
 {
- HWND hwnd;
+ HWND16 hwnd;
  POINT16 point = MAKEPOINT16(lParam);
  RECT16 rect;
  int dx,dy,x,y;
@@ -1362,10 +1362,10 @@
 /***********************************************************************
  *                  CC_MouseCheckUserColorArray               [internal]
  */
-static int CC_MouseCheckUserColorArray(HWND hDlg,int dlgitem,int rows,int cols,
+static int CC_MouseCheckUserColorArray(HWND16 hDlg,int dlgitem,int rows,int cols,
 	    LPARAM lParam,COLORREF *cr,COLORREF*crarr)
 {
- HWND hwnd;
+ HWND16 hwnd;
  POINT16 point = MAKEPOINT16(lParam);
  RECT16 rect;
  int dx,dy,x,y;
@@ -1404,7 +1404,7 @@
 /***********************************************************************
  *                  CC_MouseCheckColorGraph                   [internal]
  */
-static int CC_MouseCheckColorGraph(HWND hDlg,int dlgitem,int *hori,int *vert,LPARAM lParam)
+static int CC_MouseCheckColorGraph(HWND16 hDlg,int dlgitem,int *hori,int *vert,LPARAM lParam)
 {
  HWND32 hwnd;
  POINT16 point = MAKEPOINT16(lParam);
@@ -1436,9 +1436,9 @@
 /***********************************************************************
  *                  CC_MouseCheckResultWindow                 [internal]
  */
-static int CC_MouseCheckResultWindow(HWND hDlg,LPARAM lParam)
+static int CC_MouseCheckResultWindow(HWND16 hDlg,LPARAM lParam)
 {
- HWND hwnd;
+ HWND16 hwnd;
  POINT16 point = MAKEPOINT16(lParam);
  RECT16 rect;
 
@@ -1456,7 +1456,7 @@
 /***********************************************************************
  *                       CC_CheckDigitsInEdit                 [internal]
  */
-static int CC_CheckDigitsInEdit(HWND hwnd,int maxval)
+static int CC_CheckDigitsInEdit(HWND16 hwnd,int maxval)
 {
  int i,k,m,result,value;
  long editpos;
@@ -1497,7 +1497,7 @@
 /***********************************************************************
  *                    CC_PaintSelectedColor                   [internal]
  */
-static void CC_PaintSelectedColor(HWND hDlg,COLORREF cr)
+static void CC_PaintSelectedColor(HWND16 hDlg,COLORREF cr)
 {
  RECT16 rect;
  HDC32  hdc;
@@ -1513,7 +1513,7 @@
    hBrush = SelectObject32 (hdc, hBrush) ;
    Rectangle32(hdc, rect.left,rect.top,rect.right/2,rect.bottom);
    DeleteObject32 (SelectObject32 (hdc,hBrush)) ;
-   hBrush=CreateSolidBrush32(GetNearestColor(hdc,cr));
+   hBrush=CreateSolidBrush32(GetNearestColor32(hdc,cr));
    if (hBrush)
    {
     hBrush= SelectObject32 (hdc, hBrush) ;
@@ -1528,7 +1528,7 @@
 /***********************************************************************
  *                    CC_PaintTriangle                        [internal]
  */
-static void CC_PaintTriangle(HWND hDlg,int y)
+static void CC_PaintTriangle(HWND16 hDlg,int y)
 {
  HDC32 hDC;
  long temp;
@@ -1537,7 +1537,7 @@
  int height;
  int oben;
  RECT16 rect;
- HWND hwnd=GetDlgItem32(hDlg,0x2be);
+ HWND16 hwnd=GetDlgItem32(hDlg,0x2be);
  struct CCPRIVATE *lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER); 
 
  if (IsWindowVisible32(GetDlgItem32(hDlg,0x2c6)))   /* if full size */
@@ -1573,11 +1573,11 @@
 /***********************************************************************
  *                    CC_PaintCross                           [internal]
  */
-static void CC_PaintCross(HWND hDlg,int x,int y)
+static void CC_PaintCross(HWND16 hDlg,int x,int y)
 {
  HDC32 hDC;
  int w=GetDialogBaseUnits();
- HWND hwnd=GetDlgItem32(hDlg,0x2c6);
+ HWND16 hwnd=GetDlgItem32(hDlg,0x2c6);
  struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER); 
  RECT16 rect;
  POINT16 point;
@@ -1619,7 +1619,7 @@
 /***********************************************************************
  *                    CC_PrepareColorGraph                    [internal]
  */
-static void CC_PrepareColorGraph(HWND hDlg)    
+static void CC_PrepareColorGraph(HWND16 hDlg)    
 {
  int sdif,hdif,xdif,ydif,r,g,b,hue,sat;
  HWND32 hwnd=GetDlgItem32(hDlg,0x2c6);
@@ -1627,7 +1627,7 @@
  HBRUSH32 hbrush;
  HDC32 hdc ;
  RECT16 rect,client;
- HCURSOR16 hcursor=SetCursor(LoadCursor16(0,IDC_WAIT));
+ HCURSOR16 hcursor=SetCursor16(LoadCursor16(0,IDC_WAIT));
 
  GetClientRect16(hwnd,&client);
  hdc=GetDC32(hwnd);
@@ -1657,13 +1657,13 @@
   rect.left=rect.right;
  }
  ReleaseDC32(hwnd,hdc);
- SetCursor(hcursor);
+ SetCursor16(hcursor);
 }
 
 /***********************************************************************
  *                          CC_PaintColorGraph                [internal]
  */
-static void CC_PaintColorGraph(HWND hDlg)
+static void CC_PaintColorGraph(HWND16 hDlg)
 {
  HWND32 hwnd=GetDlgItem32(hDlg,0x2c6);
  struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER); 
@@ -1686,7 +1686,7 @@
 /***********************************************************************
  *                           CC_PaintLumBar                   [internal]
  */
-static void CC_PaintLumBar(HWND hDlg,int hue,int sat)
+static void CC_PaintLumBar(HWND16 hDlg,int hue,int sat)
 {
  HWND32 hwnd=GetDlgItem32(hDlg,0x2be);
  RECT16 rect,client;
@@ -1722,7 +1722,7 @@
 /***********************************************************************
  *                             CC_EditSetRGB                  [internal]
  */
-static void CC_EditSetRGB(HWND hDlg,COLORREF cr)
+static void CC_EditSetRGB(HWND16 hDlg,COLORREF cr)
 {
  char buffer[10];
  struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER); 
@@ -1745,7 +1745,7 @@
 /***********************************************************************
  *                             CC_EditSetHSL                  [internal]
  */
-static void CC_EditSetHSL(HWND hDlg,int h,int s,int l)
+static void CC_EditSetHSL(HWND16 hDlg,int h,int s,int l)
 {
  char buffer[10];
  struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER); 
@@ -1767,7 +1767,7 @@
 /***********************************************************************
  *                       CC_SwitchToFullSize                  [internal]
  */
-static void CC_SwitchToFullSize(HWND hDlg,COLORREF result,LPRECT16 lprect)
+static void CC_SwitchToFullSize(HWND16 hDlg,COLORREF result,LPRECT16 lprect)
 {
  int i;
  struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER); 
@@ -1796,7 +1796,7 @@
 /***********************************************************************
  *                           CC_PaintPredefColorArray         [internal]
  */
-static void CC_PaintPredefColorArray(HWND hDlg,int rows,int cols)
+static void CC_PaintPredefColorArray(HWND16 hDlg,int rows,int cols)
 {
  HWND32 hwnd=GetDlgItem32(hDlg,0x2d0);
  RECT16 rect;
@@ -1835,7 +1835,7 @@
 /***********************************************************************
  *                             CC_PaintUserColorArray         [internal]
  */
-static void CC_PaintUserColorArray(HWND hDlg,int rows,int cols,COLORREF* lpcr)
+static void CC_PaintUserColorArray(HWND16 hDlg,int rows,int cols,COLORREF* lpcr)
 {
  HWND32 hwnd=GetDlgItem32(hDlg,0x2d1);
  RECT16 rect;
@@ -1891,10 +1891,10 @@
 /***********************************************************************
  *                            CC_WMInitDialog                 [internal]
  */
-static LONG CC_WMInitDialog(HWND hDlg, WPARAM16 wParam, LPARAM lParam) 
+static LONG CC_WMInitDialog(HWND16 hDlg, WPARAM16 wParam, LPARAM lParam) 
 {
    int i,res;
-   HWND hwnd;
+   HWND16 hwnd;
    RECT16 rect;
    POINT16 point;
    struct CCPRIVATE * lpp; 
@@ -1904,7 +1904,7 @@
    lpp->lpcc=(LPCHOOSECOLOR)lParam;
    if (lpp->lpcc->lStructSize != sizeof(CHOOSECOLOR))
    {
-      EndDialog (hDlg, 0) ;
+      EndDialog32 (hDlg, 0) ;
       return FALSE;
    }
    SetWindowLong32A(hDlg, DWL_USER, (LONG)lpp); 
@@ -1942,7 +1942,7 @@
       ClientToScreen16(hwnd,&point);
       ScreenToClient16(hDlg,&point);
       GetClientRect16(hDlg,&rect);
-      point.x+=GetSystemMetrics(SM_CXDLGFRAME);
+      point.x+=GetSystemMetrics32(SM_CXDLGFRAME);
       SetWindowPos32(hDlg,NULL,0,0,point.x,res,SWP_NOMOVE|SWP_NOZORDER);
 
       ShowWindow32(GetDlgItem32(hDlg,0x2c6),SW_HIDE);
@@ -1961,7 +1961,7 @@
 /***********************************************************************
  *                              CC_WMCommand                  [internal]
  */
-static LRESULT CC_WMCommand(HWND hDlg, WPARAM16 wParam, LPARAM lParam) 
+static LRESULT CC_WMCommand(HWND16 hDlg, WPARAM16 wParam, LPARAM lParam) 
 {
     int r,g,b,i,xx;
     UINT cokmsg;
@@ -2044,7 +2044,7 @@
 
           case 0x2c9:              /* resulting color */
 	       hdc=GetDC32(hDlg);
-	       lpp->lpcc->rgbResult=GetNearestColor(hdc,lpp->lpcc->rgbResult);
+	       lpp->lpcc->rgbResult=GetNearestColor32(hdc,lpp->lpcc->rgbResult);
 	       ReleaseDC32(hDlg,hdc);
 	       CC_EditSetRGB(hDlg,lpp->lpcc->rgbResult);
 	       CC_PaintSelectedColor(hDlg,lpp->lpcc->rgbResult);
@@ -2074,11 +2074,11 @@
 			if (SendMessage16(lpp->lpcc->hwndOwner,cokmsg,0,(LPARAM)lpp->lpcc))
 			   break;    /* do NOT close */
 
-		EndDialog (hDlg, 1) ;
+		EndDialog32 (hDlg, 1) ;
 		return TRUE ;
 	
 	  case IDCANCEL :
-		EndDialog (hDlg, 0) ;
+		EndDialog32 (hDlg, 0) ;
 		return TRUE ;
 
        }
@@ -2088,7 +2088,7 @@
 /***********************************************************************
  *                              CC_WMPaint                    [internal]
  */
-static LRESULT CC_WMPaint(HWND hDlg, WPARAM16 wParam, LPARAM lParam) 
+static LRESULT CC_WMPaint(HWND16 hDlg, WPARAM16 wParam, LPARAM lParam) 
 {
     struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER); 
     /* we have to paint dialog children except text and buttons */
@@ -2115,7 +2115,7 @@
 /***********************************************************************
  *                              CC_WMLButtonDown              [internal]
  */
-static LRESULT CC_WMLButtonDown(HWND hDlg, WPARAM16 wParam, LPARAM lParam) 
+static LRESULT CC_WMLButtonDown(HWND16 hDlg, WPARAM16 wParam, LPARAM lParam) 
 {
    struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER); 
    int r,g,b,i;
@@ -2163,7 +2163,7 @@
 /***********************************************************************
  *           ColorDlgProc   (COMMDLG.8)
  */
-LRESULT ColorDlgProc(HWND hDlg, UINT message,
+LRESULT ColorDlgProc(HWND16 hDlg, UINT message,
                      WPARAM16 wParam, LONG lParam)
 {
  int res;
@@ -2307,8 +2307,8 @@
 {
   int i;
   WORD w;
-  HWND hwnd=LOWORD(lParam);
-  HWND hDlg=GetParent16(hwnd);
+  HWND16 hwnd=LOWORD(lParam);
+  HWND16 hDlg=GetParent16(hwnd);
   LPCHOOSEFONT lpcf=(LPCHOOSEFONT)GetWindowLong32A(hDlg, DWL_USER); 
   LOGFONT16 *lplf = (LOGFONT16 *)PTR_SEG_TO_LIN( logfont );
 
@@ -2342,7 +2342,7 @@
  *
  * Fill font style information into combobox  (without using font.c directly)
  */
-static int SetFontStylesToCombo2(HWND hwnd, HDC16 hdc, LPLOGFONT16 lplf,
+static int SetFontStylesToCombo2(HWND16 hwnd, HDC16 hdc, LPLOGFONT16 lplf,
                                  LPTEXTMETRIC16 lptm)
 {
    #define FSTYLES 4
@@ -2384,7 +2384,7 @@
 /*************************************************************************
  *              SetFontSizesToCombo3                           [internal]
  */
-static int SetFontSizesToCombo3(HWND hwnd, LPLOGFONT16 lplf, LPCHOOSEFONT lpcf)
+static int SetFontSizesToCombo3(HWND16 hwnd, LPLOGFONT16 lplf, LPCHOOSEFONT lpcf)
 {
   static const int sizes[]={8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72,0};
   int h,i,j;
@@ -2423,9 +2423,9 @@
 INT16 FontStyleEnumProc( SEGPTR logfont, SEGPTR metrics,
                          UINT16 nFontType, LPARAM lParam )
 {
-  HWND hcmb2=LOWORD(lParam);
-  HWND hcmb3=HIWORD(lParam);
-  HWND hDlg=GetParent16(hcmb3);
+  HWND16 hcmb2=LOWORD(lParam);
+  HWND16 hcmb3=HIWORD(lParam);
+  HWND16 hDlg=GetParent16(hcmb3);
   LPCHOOSEFONT lpcf=(LPCHOOSEFONT)GetWindowLong32A(hDlg, DWL_USER); 
   LOGFONT16 *lplf = (LOGFONT16 *)PTR_SEG_TO_LIN(logfont);
   TEXTMETRIC16 *lptm = (TEXTMETRIC16 *)PTR_SEG_TO_LIN(metrics);
@@ -2456,13 +2456,13 @@
 /***********************************************************************
  *           CFn_WMInitDialog                            [internal]
  */
-LRESULT CFn_WMInitDialog(HWND hDlg, WPARAM16 wParam, LPARAM lParam)
+LRESULT CFn_WMInitDialog(HWND16 hDlg, WPARAM16 wParam, LPARAM lParam)
 {
   HDC32 hdc;
   int i,j,res,init=0;
   long l;
   LPLOGFONT16 lpxx;
-  HCURSOR16 hcursor=SetCursor(LoadCursor16(0,IDC_WAIT));
+  HCURSOR16 hcursor=SetCursor16(LoadCursor16(0,IDC_WAIT));
   LPCHOOSEFONT lpcf;
 
   SetWindowLong32A(hDlg, DWL_USER, lParam); 
@@ -2473,7 +2473,7 @@
   if (lpcf->lStructSize != sizeof(CHOOSEFONT))
   {
     dprintf_commdlg(stddeb,"WM_INITDIALOG: structure size failure !!!\n");
-    EndDialog (hDlg, 0); 
+    EndDialog32 (hDlg, 0); 
     return FALSE;
   }
   if (!hBitmapTT)
@@ -2559,7 +2559,7 @@
   else
   {
     dprintf_commdlg(stddeb,"WM_INITDIALOG: HDC failure !!!\n");
-    EndDialog (hDlg, 0); 
+    EndDialog32 (hDlg, 0); 
     return FALSE;
   }
 
@@ -2568,7 +2568,7 @@
   res=TRUE;
   if (CFn_HookCallChk(lpcf))
     res=CallWindowProc16(lpcf->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
-  SetCursor(hcursor);   
+  SetCursor16(hcursor);   
   return res;
 }
 
@@ -2576,7 +2576,7 @@
 /***********************************************************************
  *           CFn_WMMeasureItem                           [internal]
  */
-LRESULT CFn_WMMeasureItem(HWND hDlg, WPARAM16 wParam, LPARAM lParam)
+LRESULT CFn_WMMeasureItem(HWND16 hDlg, WPARAM16 wParam, LPARAM lParam)
 {
   BITMAP16 bm;
   LPMEASUREITEMSTRUCT16 lpmi=PTR_SEG_TO_LIN((LPMEASUREITEMSTRUCT16)lParam);
@@ -2592,7 +2592,7 @@
 /***********************************************************************
  *           CFn_WMDrawItem                              [internal]
  */
-LRESULT CFn_WMDrawItem(HWND hDlg, WPARAM16 wParam, LPARAM lParam)
+LRESULT CFn_WMDrawItem(HWND16 hDlg, WPARAM16 wParam, LPARAM lParam)
 {
   HBRUSH16 hBrush;
   char *buffer;
@@ -2685,7 +2685,7 @@
 /***********************************************************************
  *           CFn_WMCtlColor                              [internal]
  */
-LRESULT CFn_WMCtlColor(HWND hDlg, WPARAM16 wParam, LPARAM lParam)
+LRESULT CFn_WMCtlColor(HWND16 hDlg, WPARAM16 wParam, LPARAM lParam)
 {
   LPCHOOSEFONT lpcf=(LPCHOOSEFONT)GetWindowLong32A(hDlg, DWL_USER); 
 
@@ -2701,7 +2701,7 @@
 /***********************************************************************
  *           CFn_WMCommand                               [internal]
  */
-LRESULT CFn_WMCommand(HWND hDlg, WPARAM16 wParam, LPARAM lParam)
+LRESULT CFn_WMCommand(HWND16 hDlg, WPARAM16 wParam, LPARAM lParam)
 {
   HFONT16 hFont;
   int i,j;
@@ -2723,14 +2723,14 @@
 		      i=SendDlgItemMessage16(hDlg,cmb1,CB_GETCURSEL16,0,0);
 		      if (i!=CB_ERR)
 		      {
-		        HCURSOR16 hcursor=SetCursor(LoadCursor16(0,IDC_WAIT));
+		        HCURSOR16 hcursor=SetCursor16(LoadCursor16(0,IDC_WAIT));
                         char *str = SEGPTR_ALLOC(256);
                         SendDlgItemMessage16(hDlg,cmb1,CB_GETLBTEXT16,i,
                                              (LPARAM)SEGPTR_GET(str));
 	                dprintf_commdlg(stddeb,"WM_COMMAND/cmb1 =>%s\n",str);
        		        EnumFontFamilies16(hdc,str,FontStyleEnumProc,
 		             MAKELONG(GetDlgItem32(hDlg,cmb2),GetDlgItem32(hDlg,cmb3)));
-		        SetCursor(hcursor);     
+		        SetCursor16(hcursor);
                         SEGPTR_FREE(str);
 		      }
 		      if (!(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC))
@@ -2739,7 +2739,7 @@
  		    else
                     {
                       dprintf_commdlg(stddeb,"WM_COMMAND: HDC failure !!!\n");
-                      EndDialog (hDlg, 0); 
+                      EndDialog32 (hDlg, 0); 
                       return TRUE;
                     }
 	          }
@@ -2816,7 +2816,7 @@
                      ( (lpcf->Flags & CF_LIMITSIZE) && 
                       (-lpxx->lfHeight >= lpcf->nSizeMin) && 
                       (-lpxx->lfHeight <= lpcf->nSizeMax)))
-	             EndDialog(hDlg, TRUE);
+	             EndDialog32(hDlg, TRUE);
 	          else
 	          {
                    char buffer[80];
@@ -2825,7 +2825,7 @@
 	           MessageBox16(hDlg,buffer,NULL,MB_OK);
 	          } 
 		  return(TRUE);
-	case IDCANCEL:EndDialog(hDlg, FALSE);
+	case IDCANCEL:EndDialog32(hDlg, FALSE);
 		  return(TRUE);
 	}
       return(FALSE);
@@ -2838,7 +2838,7 @@
                     2. some CF_.. flags are not supported
                     3. some TType extensions
  */
-LRESULT FormatCharDlgProc(HWND hDlg, UINT message, WPARAM16 wParam, LPARAM lParam)
+LRESULT FormatCharDlgProc(HWND16 hDlg, UINT message, WPARAM16 wParam, LPARAM lParam)
 {
   LPCHOOSEFONT lpcf=(LPCHOOSEFONT)GetWindowLong32A(hDlg, DWL_USER);  
   if (message!=WM_INITDIALOG)
diff --git a/misc/crtdll.c b/misc/crtdll.c
index 98fc384..ea185ac 100644
--- a/misc/crtdll.c
+++ b/misc/crtdll.c
@@ -831,6 +831,23 @@
 }
 
 /*********************************************************************
+ *                  _wcsrev           (CRTDLL.326)
+ */
+VOID CRTDLL__wcsrev(LPWSTR s) {
+	LPWSTR	e;
+
+	e=s;
+	while (*e)
+		e++;
+	while (s<e) {
+		WCHAR	a;
+
+		a=*s;*s=*e;*e=a;
+		s++;e--;
+	}
+}
+
+/*********************************************************************
  *                  wcsstr           (CRTDLL.517)
  */
 LPWSTR CRTDLL_wcsstr(LPWSTR s,LPWSTR b)
diff --git a/misc/driver.c b/misc/driver.c
index 82a6414..c535ffd 100644
--- a/misc/driver.c
+++ b/misc/driver.c
@@ -232,8 +232,7 @@
 	return (LRESULT)0L;
 
       case DRV_CONFIGURE:
-	MessageBox16( (HWND)NULL, "Driver isn't configurable !", 
-                      "Wine Driver", MB_OK );
+	MessageBox16( 0, "Driver isn't configurable !", "Wine Driver", MB_OK );
 	return (LRESULT)0L;
 
       case DRV_INSTALL:
diff --git a/misc/lstr.c b/misc/lstr.c
index 5ea4509..735a59e 100644
--- a/misc/lstr.c
+++ b/misc/lstr.c
@@ -193,7 +193,7 @@
     while (*start && (start < ptr))
     {
         LPCSTR next = CharNext32A( start );
-        if (next > ptr) break;
+        if (next >= ptr) break;
         start = next;
     }
     return (LPSTR)start;
diff --git a/misc/main.c b/misc/main.c
index 5790976..1687226 100644
--- a/misc/main.c
+++ b/misc/main.c
@@ -69,6 +69,7 @@
     {"Eo",     0},	/* LANG_Eo */ /* FIXME languageid */
     {"It",0x0410},	/* LANG_It */
     {"Ko",0x0412},	/* LANG_Ko */
+    {"Hu",0x0436},	/* LANG_Hu */
     {NULL,0}
 };
 
@@ -161,7 +162,7 @@
   "    -fixedmap       Use a \"standard\" color map\n" \
   "    -iconic         Start as an icon\n" \
   "    -ipc            Enable IPC facilities\n" \
-  "    -language xx    Set the language (one of En,Es,De,No,Fr,Fi,Da,Cz,Eo,It,Ko)\n" \
+  "    -language xx    Set the language (one of En,Es,De,No,Fr,Fi,Da,Cz,Eo,It,Ko,Hu)\n" \
   "    -managed        Allow the window manager to manage created windows\n" \
   "    -mode mode      Start Wine in a particular mode (standard or enhanced)\n" \
   "    -name name      Set the application name\n" \
@@ -682,11 +683,21 @@
 
 
 /***********************************************************************
- *           MessageBeep    (USER.104)
+ *           MessageBeep16   (USER.104)
  */
-void MessageBeep(WORD i)
+void MessageBeep16( UINT16 i )
 {
-	XBell(display, 100);
+    MessageBeep32( i );
+}
+
+
+/***********************************************************************
+ *           MessageBeep32   (USER32.389)
+ */
+BOOL32 MessageBeep32( UINT32 i )
+{
+    XBell( display, 100 );
+    return TRUE;
 }
 
 
@@ -939,7 +950,7 @@
 			break;
 		
 		case SPI_GETBORDER:
-			*(INT *)lpvParam = GetSystemMetrics( SM_CXFRAME );
+			*(INT16 *)lpvParam = GetSystemMetrics16( SM_CXFRAME );
 			break;
 
 		case SPI_GETFASTTASKSWITCH:
@@ -973,7 +984,7 @@
                     break;
 
 		case SPI_GETMENUDROPALIGNMENT:
-			*(BOOL *) lpvParam = GetSystemMetrics( SM_MENUDROPALIGNMENT ); /* XXX check this */
+			*(BOOL16 *) lpvParam = GetSystemMetrics16( SM_MENUDROPALIGNMENT ); /* XXX check this */
 			break;
 
 		case SPI_GETSCREENSAVEACTIVE:
@@ -994,7 +1005,7 @@
 			if (lpvParam == NULL)
                             /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
                         else
-                            *(INT *) lpvParam = GetSystemMetrics( SM_CXICONSPACING );
+                            *(INT16 *)lpvParam = GetSystemMetrics16( SM_CXICONSPACING );
 			break;
 
 		case SPI_ICONVERTICALSPACING:
@@ -1002,7 +1013,7 @@
                     if (lpvParam == NULL)
                         /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
 		    else
-                        *(INT *) lpvParam = GetSystemMetrics(SM_CYICONSPACING);
+                        *(INT16 *)lpvParam = GetSystemMetrics16(SM_CYICONSPACING);
                     break;
 
 		case SPI_SETBEEP:
@@ -1071,8 +1082,8 @@
 
                 case SPI_GETWORKAREA:
                     SetRect16( (RECT16 *)lpvParam, 0, 0,
-                               GetSystemMetrics( SM_CXSCREEN ),
-                               GetSystemMetrics( SM_CYSCREEN ) );
+                               GetSystemMetrics16( SM_CXSCREEN ),
+                               GetSystemMetrics16( SM_CYSCREEN ) );
                     break;
 
 		default:
@@ -1140,14 +1151,6 @@
 
 
 /***********************************************************************
-*	SWAPMOUSEBUTTON (USER.186)
-*/
-BOOL SwapMouseButton(BOOL fSwap)
-{
-	return 0;	/* don't swap */
-}
-
-/***********************************************************************
 *	FileCDR (KERNEL.130)
 */
 void FileCDR(FARPROC16 x)
@@ -1158,7 +1161,7 @@
 /***********************************************************************
 *	GetWinDebugInfo (KERNEL.355)
 */
-BOOL GetWinDebugInfo(WINDEBUGINFO *lpwdi, UINT flags)
+BOOL16 GetWinDebugInfo(WINDEBUGINFO *lpwdi, UINT16 flags)
 {
 	printf("GetWinDebugInfo(%8lx,%d) stub returning 0\n", (unsigned long)lpwdi, flags);
 	/* 0 means not in debugging mode/version */
@@ -1170,7 +1173,7 @@
 /***********************************************************************
 *	GetWinDebugInfo (KERNEL.355)
 */
-BOOL SetWinDebugInfo(WINDEBUGINFO *lpwdi)
+BOOL16 SetWinDebugInfo(WINDEBUGINFO *lpwdi)
 {
 	printf("SetWinDebugInfo(%8lx) stub returning 0\n", (unsigned long)lpwdi);
 	/* 0 means not in debugging mode/version */
diff --git a/misc/network.c b/misc/network.c
index f6267b4..156db53 100644
--- a/misc/network.c
+++ b/misc/network.c
@@ -115,7 +115,7 @@
 /**************************************************************************
  *              WNetWatchQueue       [USER.508]
  */
-int WNetWatchQueue(HWND hWnd,LPSTR szLocal,LPSTR szUser,WORD nQueue)
+int WNetWatchQueue(HWND16 hWnd,LPSTR szLocal,LPSTR szUser,WORD nQueue)
 {
 	printf("EMPTY STUB !!! WNetWatchQueue(%04x,'%s','%s',%x)\n",
 		hWnd,szLocal,szUser,nQueue);
@@ -191,7 +191,7 @@
 /**************************************************************************
  *              WNetDeviceMode       [USER.514]
  */
-int WNetDeviceMode(HWND hWndOwner)
+int WNetDeviceMode(HWND16 hWndOwner)
 {
 	printf("EMPTY STUB !!! WNetDeviceMode(%04x)\n",hWndOwner);
 	return WN_NET_ERROR;
@@ -200,7 +200,7 @@
 /**************************************************************************
  *              WNetBrowseDialog       [USER.515]
  */
-int WNetBrowseDialog(HWND hParent,WORD nType,LPSTR szPath)
+int WNetBrowseDialog(HWND16 hParent,WORD nType,LPSTR szPath)
 {
 	printf("EMPTY STUB !!! WNetBrowseDialog(%04x,%x,'%s')\n",
 		hParent,nType,szPath);
@@ -260,7 +260,7 @@
 /**************************************************************************
  *              WNetRestoreConnection       [USER.523]
  */
-int WNetRestoreConnection(HWND hwndOwner,LPSTR lpszDevice)
+int WNetRestoreConnection(HWND16 hwndOwner,LPSTR lpszDevice)
 {
 	printf("EMPTY STUB !!! WNetRestoreConnection(%04x,'%s')\n",
 		hwndOwner,lpszDevice);
@@ -280,7 +280,7 @@
 /**************************************************************************
  *              WnetConnectDialog       [USER.525]
  */
-UINT WNetConnectDialog(HWND hWndParent, WORD iType)
+UINT WNetConnectDialog(HWND16 hWndParent, WORD iType)
 {
 	printf("EMPTY STUB !!! WNetConnectDialog(%04x, %4X)\n", hWndParent, iType);
 	return WN_SUCCESS;
@@ -289,7 +289,7 @@
 /**************************************************************************
  *              WNetDisconnectDialog       [USER.526]
  */
-int WNetDisconnectDialog(HWND hwndOwner, WORD iType)
+int WNetDisconnectDialog(HWND16 hwndOwner, WORD iType)
 {
 	printf("EMPTY STUB !!! WNetDisconnectDialog(%04x,%x)\n",
 		hwndOwner,iType);
@@ -299,7 +299,7 @@
 /**************************************************************************
  *              WnetConnectionDialog     [USER.527]
  */
-UINT WNetConnectionDialog(HWND hWndParent, WORD iType)
+UINT WNetConnectionDialog(HWND16 hWndParent, WORD iType)
 {
 	printf("EMPTY STUB !!! WNetConnectionDialog(%04x, %4X)\n", 
 		hWndParent, iType);
@@ -309,7 +309,7 @@
 /**************************************************************************
  *              WNetViewQueueDialog       [USER.528]
  */
-int WNetViewQueueDialog(HWND hwndOwner,LPSTR lpszQueue)
+int WNetViewQueueDialog(HWND16 hwndOwner,LPSTR lpszQueue)
 {
 	printf("EMPTY STUB !!! WNetViewQueueDialog(%04x,'%s')\n",
 		hwndOwner,lpszQueue);
@@ -319,7 +319,7 @@
 /**************************************************************************
  *              WNetPropertyDialog       [USER.529]
  */
-int WNetPropertyDialog(HWND hwndParent,WORD iButton,
+int WNetPropertyDialog(HWND16 hwndParent,WORD iButton,
 	WORD nPropSel,LPSTR lpszName,WORD nType)
 {
 	printf("EMPTY STUB !!! WNetPropertyDialog(%04x,%x,%x,'%s',%x)\n",
@@ -340,7 +340,7 @@
 /**************************************************************************
  *              WNetDirectoryNotify       [USER.531]
  */
-int WNetDirectoryNotify(HWND hwndOwner,void *lpDir,WORD wOper)
+int WNetDirectoryNotify(HWND16 hwndOwner,void *lpDir,WORD wOper)
 {
 	printf("EMPTY STUB !!! WNetDirectoryNotify(%04x,%p,%x)\n",
 		hwndOwner,lpDir,wOper);
@@ -350,7 +350,7 @@
 /**************************************************************************
  *              WNetGetPropertyText       [USER.532]
  */
-int WNetGetPropertyText(HWND hwndParent,WORD iButton,WORD nPropSel,
+int WNetGetPropertyText(HWND16 hwndParent,WORD iButton,WORD nPropSel,
 	LPSTR lpszName,WORD nType)
 {
 	printf("EMPTY STUB !!! WNetGetPropertyText(%04x,%x,%x,'%s',%x)\n",
diff --git a/misc/ntdll.c b/misc/ntdll.c
index 6f18e26..f9d8985 100644
--- a/misc/ntdll.c
+++ b/misc/ntdll.c
@@ -12,6 +12,7 @@
 #include <math.h>
 #include "win.h"
 #include "windows.h"
+#include "ntdll.h"
 #include "heap.h"
 #include "stddebug.h"
 #include "debug.h"
@@ -27,6 +28,177 @@
 }
 
 /**************************************************************************
+ *                 RtlLengthSid				[NTDLL]
+ */
+DWORD
+RtlLengthSid(LPSID sid) {
+	return sizeof(DWORD)*sid->SubAuthorityCount+sizeof(SID);
+}
+
+/**************************************************************************
+ *                 RtlCreateAcl				[NTDLL]
+ */
+DWORD /* NTSTATUS */
+RtlCreateAcl(LPACL acl,DWORD size,DWORD rev) {
+	if (rev!=ACL_REVISION)
+		return STATUS_INVALID_PARAMETER;
+	if (size<sizeof(ACL))
+		return STATUS_BUFFER_TOO_SMALL;
+	if (size>0xFFFF)
+		return STATUS_INVALID_PARAMETER;
+
+	memset(acl,'\0',sizeof(ACL));
+	acl->AclRevision	= rev;
+	acl->AclSize		= size;
+	acl->AceCount		= 0;
+	return 0;
+}
+
+/**************************************************************************
+ *                 RtlFirstFreeAce			[NTDLL]
+ * looks for the AceCount+1 ACE, and if it is still within the alloced
+ * ACL, return a pointer to it
+ */
+BOOL32
+RtlFirstFreeAce(LPACL acl,LPACE_HEADER *x) {
+	LPACE_HEADER	ace;
+	int		i;
+
+	*x = 0;
+	ace = (LPACE_HEADER)(acl+1);
+	for (i=0;i<acl->AceCount;i++) {
+		if ((DWORD)ace>=(((DWORD)acl)+acl->AclSize))
+			return 0;
+		ace = (LPACE_HEADER)(((BYTE*)ace)+ace->AceSize);
+	}
+	if ((DWORD)ace>=(((DWORD)acl)+acl->AclSize))
+		return 0;
+	*x = ace;
+	return 1;
+}
+
+/**************************************************************************
+ *                 RtlAddAce				[NTDLL]
+ */
+DWORD /* NTSTATUS */
+RtlAddAce(LPACL acl,DWORD rev,DWORD xnrofaces,LPACE_HEADER acestart,DWORD acelen){
+	LPACE_HEADER	ace,targetace;
+	int		nrofaces;
+
+	if (acl->AclRevision != ACL_REVISION)
+		return STATUS_INVALID_PARAMETER;
+	if (!RtlFirstFreeAce(acl,&targetace))
+		return STATUS_INVALID_PARAMETER;
+	nrofaces=0;ace=acestart;
+	while (((DWORD)ace-(DWORD)acestart)<acelen) {
+		nrofaces++;
+		ace = (LPACE_HEADER)(((BYTE*)ace)+ace->AceSize);
+	}
+	if ((DWORD)targetace+acelen>(DWORD)acl+acl->AclSize) /* too much aces */
+		return STATUS_INVALID_PARAMETER;
+	memcpy((LPBYTE)targetace,acestart,acelen);
+	acl->AceCount+=nrofaces;
+	return 0;
+}
+
+/**************************************************************************
+ *                 RtlCreateSecurityDescriptor		[NTDLL]
+ */
+DWORD /* NTSTATUS */
+RtlCreateSecurityDescriptor(LPSECURITY_DESCRIPTOR lpsd,DWORD rev) {
+	if (rev!=SECURITY_DESCRIPTOR_REVISION)
+		return STATUS_UNKNOWN_REVISION;
+	memset(lpsd,'\0',sizeof(*lpsd));
+	lpsd->Revision = SECURITY_DESCRIPTOR_REVISION;
+	return 0;
+}
+
+/**************************************************************************
+ *                 RtlSetDaclSecurityDescriptor		[NTDLL]
+ */
+DWORD /* NTSTATUS */
+RtlSetDaclSecurityDescriptor (
+LPSECURITY_DESCRIPTOR lpsd,BOOL32 daclpresent,LPACL dacl,BOOL32 dacldefaulted
+) {
+	if (lpsd->Revision!=SECURITY_DESCRIPTOR_REVISION)
+		return STATUS_UNKNOWN_REVISION;
+	if (lpsd->Control & SE_SELF_RELATIVE)
+		return STATUS_INVALID_SECURITY_DESCR;
+	if (!daclpresent) {
+		lpsd->Control &= ~SE_DACL_PRESENT;
+		return 0;
+	}
+	lpsd->Control |= SE_DACL_PRESENT;
+	lpsd->Dacl = dacl;
+	if (dacldefaulted)
+		lpsd->Control |= SE_DACL_DEFAULTED;
+	else
+		lpsd->Control &= ~SE_DACL_DEFAULTED;
+	return 0;
+}
+
+/**************************************************************************
+ *                 RtlSetSaclSecurityDescriptor		[NTDLL]
+ */
+DWORD /* NTSTATUS */
+RtlSetSaclSecurityDescriptor (
+LPSECURITY_DESCRIPTOR lpsd,BOOL32 saclpresent,LPACL sacl,BOOL32 sacldefaulted
+) {
+	if (lpsd->Revision!=SECURITY_DESCRIPTOR_REVISION)
+		return STATUS_UNKNOWN_REVISION;
+	if (lpsd->Control & SE_SELF_RELATIVE)
+		return STATUS_INVALID_SECURITY_DESCR;
+	if (!saclpresent) {
+		lpsd->Control &= ~SE_SACL_PRESENT;
+		return 0;
+	}
+	lpsd->Control |= SE_SACL_PRESENT;
+	lpsd->Sacl = sacl;
+	if (sacldefaulted)
+		lpsd->Control |= SE_SACL_DEFAULTED;
+	else
+		lpsd->Control &= ~SE_SACL_DEFAULTED;
+	return 0;
+}
+
+/**************************************************************************
+ *                 RtlSetOwnerSecurityDescriptor		[NTDLL]
+ */
+DWORD /* NTSTATUS */
+RtlSetOwnerSecurityDescriptor (LPSECURITY_DESCRIPTOR lpsd,LPSID owner,BOOL32 ownerdefaulted) {
+	if (lpsd->Revision!=SECURITY_DESCRIPTOR_REVISION)
+		return STATUS_UNKNOWN_REVISION;
+	if (lpsd->Control & SE_SELF_RELATIVE)
+		return STATUS_INVALID_SECURITY_DESCR;
+
+	lpsd->Owner = owner;
+	if (ownerdefaulted)
+		lpsd->Control |= SE_OWNER_DEFAULTED;
+	else
+		lpsd->Control &= ~SE_OWNER_DEFAULTED;
+	return 0;
+}
+
+/**************************************************************************
+ *                 RtlSetOwnerSecurityDescriptor		[NTDLL]
+ */
+DWORD /* NTSTATUS */
+RtlSetGroupSecurityDescriptor (LPSECURITY_DESCRIPTOR lpsd,LPSID group,BOOL32 groupdefaulted) {
+	if (lpsd->Revision!=SECURITY_DESCRIPTOR_REVISION)
+		return STATUS_UNKNOWN_REVISION;
+	if (lpsd->Control & SE_SELF_RELATIVE)
+		return STATUS_INVALID_SECURITY_DESCR;
+
+	lpsd->Group = group;
+	if (groupdefaulted)
+		lpsd->Control |= SE_GROUP_DEFAULTED;
+	else
+		lpsd->Control &= ~SE_GROUP_DEFAULTED;
+	return 0;
+}
+
+
+/**************************************************************************
  *                 RtlNormalizeProcessParams		[NTDLL]
  */
 LPVOID
@@ -122,6 +294,25 @@
 	return STATUS_SUCCESS;
 }
 /**************************************************************************
+ *                 RtlMultiByteToUnicodeN		[NTDLL]
+ * FIXME: multibyte support
+ */
+DWORD /* NTSTATUS */
+RtlMultiByteToUnicodeN(LPWSTR unistr,DWORD unilen,LPDWORD reslen,LPSTR oemstr,DWORD oemlen) {
+	DWORD	len;
+	LPWSTR	x;
+
+	len = oemlen;
+	if (unilen/2 < len)
+		len = unilen/2;
+	x=(LPWSTR)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,(len+1)*sizeof(WCHAR));
+	lstrcpynAtoW(x,oemstr,len+1);
+	memcpy(unistr,x,len*2);
+	if (reslen) *reslen = len*2;
+	return 0;
+}
+
+/**************************************************************************
  *                 RtlOemToUnicodeN			[NTDLL]
  */
 DWORD /* NTSTATUS */
@@ -270,3 +461,34 @@
 RtlxAnsiStringToUnicodeSize(LPANSI_STRING str) {
 	return str->Length*2+2;
 }
+
+/**************************************************************************
+ *                 RtlDosPathNameToNtPathName_U		[NTDLL]
+ *
+ * FIXME: convert to UNC or whatever is expected here
+ */
+BOOL32 
+RtlDosPathNameToNtPathName_U(
+	LPWSTR from,LPUNICODE_STRING us,DWORD x2,DWORD x3
+) {
+	LPSTR	fromA = HEAP_strdupWtoA(GetProcessHeap(),0,from);
+
+	fprintf(stderr,"RtlDosPathNameToNtPathName_U(%s,%p,%08lx,%08lx)\n",
+		fromA,us,x2,x3
+	);
+	if (us)
+		RtlInitUnicodeString(us,HEAP_strdupW(GetProcessHeap(),0,from));
+	return TRUE;
+}
+
+/**************************************************************************
+ *                 NtOpenFile				[NTDLL]
+ */
+DWORD
+NtOpenFile(DWORD x1,DWORD flags,DWORD x3,DWORD x4,DWORD alignment,DWORD x6) {
+	fprintf(stderr,"NtOpenFile(%08lx,%08lx,%08lx,%08lx,%08lx,%08lx)\n",
+		x1,flags,x3,x4,alignment,x6
+	);
+	/* returns file io completion status */
+	return 0;
+}
diff --git a/misc/ole2nls.c b/misc/ole2nls.c
index 61a1b1f..6cb3b1d 100644
--- a/misc/ole2nls.c
+++ b/misc/ole2nls.c
@@ -143,7 +143,7 @@
     case LANG_Es: return 0x0a;         /* Spanish */
     case LANG_Fi: return 0x0b;         /* Finnish */
     case LANG_Fr: return 0x0c;         /* French */
- /* case LANG_Hu: return 0x0e; */      /* Hungarian */
+    case LANG_Hu: return 0x0e;         /* Hungarian */
  /* case LANG_Ic: return 0x0f; */      /* Icelandic */
     case LANG_It: return 0x10;         /* Italian */
  /* case LANG_Jp: return 0x11; */      /* Japanese */
@@ -1261,6 +1261,131 @@
         }
     break;  /* LANG(Ko) */
 
+    case LANG_Hu:
+    	switch (LCType) {
+LOCVAL(LOCALE_ILANGUAGE,"9")
+LOCVAL(LOCALE_SLANGUAGE,"Magyar")
+LOCVAL(LOCALE_SENGLANGUAGE,"Hungarian")
+LOCVAL(LOCALE_SABBREVLANGNAME,"hun")
+LOCVAL(LOCALE_SNATIVELANGNAME,"Magyar")
+LOCVAL(LOCALE_ICOUNTRY,"36")
+LOCVAL(LOCALE_SCOUNTRY,"Magyarország")
+LOCVAL(LOCALE_SENGCOUNTRY,"Hungary")
+LOCVAL(LOCALE_SABBREVCTRYNAME,"Hu")
+LOCVAL(LOCALE_SNATIVECTRYNAME,"Magyarország")
+LOCVAL(LOCALE_IDEFAULTLANGUAGE,"9")
+LOCVAL(LOCALE_IDEFAULTCOUNTRY,"36")
+LOCVAL(LOCALE_IDEFAULTCODEPAGE,"852")
+LOCVAL(LOCALE_IDEFAULTANSICODEPAGE,"852")
+LOCVAL(LOCALE_SLIST,";")
+LOCVAL(LOCALE_IMEASURE,"0")
+LOCVAL(LOCALE_SDECIMAL,".")
+LOCVAL(LOCALE_STHOUSAND,",")
+/*
+LOCVAL(LOCALE_SGROUPING)
+*/
+LOCVAL(LOCALE_IDIGITS,"2")
+LOCVAL(LOCALE_ILZERO,"1")
+/*
+LOCVAL(LOCALE_INEGNUMBER)
+Is this "0123456789" ??
+LOCVAL(LOCALE_SNATIVEDIGITS)
+*/
+LOCVAL(LOCALE_SCURRENCY,"Ft")
+/*
+LOCVAL(LOCALE_SINTLSYMBOL)
+LOCVAL(LOCALE_SMONDECIMALSEP)
+LOCVAL(LOCALE_SMONTHOUSANDSEP)
+LOCVAL(LOCALE_SMONGROUPING)
+*/
+LOCVAL(LOCALE_ICURRDIGITS,"0")
+/*
+LOCVAL(LOCALE_IINTLCURRDIGITS)
+*/
+LOCVAL(LOCALE_ICURRENCY,"3")
+LOCVAL(LOCALE_INEGCURR,"8")
+LOCVAL(LOCALE_SDATE,"/")
+LOCVAL(LOCALE_STIME,":")
+LOCVAL(LOCALE_SSHORTDATE,"yyyy.MM.dd")
+LOCVAL(LOCALE_SLONGDATE,"ddd, yyyy. MMMM d")
+/*
+LOCVAL(LOCALE_STIMEFORMAT)
+*/
+LOCVAL(LOCALE_IDATE,"1")
+/*
+LOCVAL(LOCALE_ILDATE)
+*/
+LOCVAL(LOCALE_ITIME,"1")
+/*
+LOCVAL(LOCALE_ITIMEMARKPOSN)
+LOCVAL(LOCALE_ICENTURY)
+*/
+LOCVAL(LOCALE_ITLZERO,"1")
+/*
+LOCVAL(LOCALE_IDAYLZERO)
+LOCVAL(LOCALE_IMONLZERO)
+LOCVAL(LOCALE_S1159)
+LOCVAL(LOCALE_S2359)
+LOCVAL(LOCALE_ICALENDARTYPE)
+LOCVAL(LOCALE_IOPTIONALCALENDAR)
+LOCVAL(LOCALE_IFIRSTDAYOFWEEK)
+LOCVAL(LOCALE_IFIRSTWEEKOFYEAR)
+*/
+LOCVAL(LOCALE_SDAYNAME1,"Hétfõ")
+LOCVAL(LOCALE_SDAYNAME2,"Kedd")
+LOCVAL(LOCALE_SDAYNAME3,"Szerda")
+LOCVAL(LOCALE_SDAYNAME4,"Csütörtök")
+LOCVAL(LOCALE_SDAYNAME5,"Péntek")
+LOCVAL(LOCALE_SDAYNAME6,"Szombat")
+LOCVAL(LOCALE_SDAYNAME7,"Vasárnap")
+LOCVAL(LOCALE_SABBREVDAYNAME1,"Hé")
+LOCVAL(LOCALE_SABBREVDAYNAME2,"Ke")
+LOCVAL(LOCALE_SABBREVDAYNAME3,"Se")
+LOCVAL(LOCALE_SABBREVDAYNAME4,"Cs")
+LOCVAL(LOCALE_SABBREVDAYNAME5,"Pé")
+LOCVAL(LOCALE_SABBREVDAYNAME6,"So")
+LOCVAL(LOCALE_SABBREVDAYNAME7,"Va")
+LOCVAL(LOCALE_SMONTHNAME1,"Január")
+LOCVAL(LOCALE_SMONTHNAME2,"Február")
+LOCVAL(LOCALE_SMONTHNAME3,"Március")
+LOCVAL(LOCALE_SMONTHNAME4,"Április")
+LOCVAL(LOCALE_SMONTHNAME5,"Május")
+LOCVAL(LOCALE_SMONTHNAME6,"Június")
+LOCVAL(LOCALE_SMONTHNAME7,"Július")
+LOCVAL(LOCALE_SMONTHNAME8,"Augusztus")
+LOCVAL(LOCALE_SMONTHNAME9,"Szeptember")
+LOCVAL(LOCALE_SMONTHNAME10,"Október")
+LOCVAL(LOCALE_SMONTHNAME11,"November")
+LOCVAL(LOCALE_SMONTHNAME12,"December")
+LOCVAL(LOCALE_SMONTHNAME13,"")
+LOCVAL(LOCALE_SABBREVMONTHNAME1,"Jan")
+LOCVAL(LOCALE_SABBREVMONTHNAME2,"Feb")
+LOCVAL(LOCALE_SABBREVMONTHNAME3,"Már")
+LOCVAL(LOCALE_SABBREVMONTHNAME4,"Ápr")
+LOCVAL(LOCALE_SABBREVMONTHNAME5,"Máj")
+LOCVAL(LOCALE_SABBREVMONTHNAME6,"Jún")
+LOCVAL(LOCALE_SABBREVMONTHNAME7,"Júl")
+LOCVAL(LOCALE_SABBREVMONTHNAME8,"Aug")
+LOCVAL(LOCALE_SABBREVMONTHNAME9,"Sze")
+LOCVAL(LOCALE_SABBREVMONTHNAME10,"Okt")
+LOCVAL(LOCALE_SABBREVMONTHNAME11,"Nov")
+LOCVAL(LOCALE_SABBREVMONTHNAME12,"Dec")
+LOCVAL(LOCALE_SABBREVMONTHNAME13,"")
+/*
+LOCVAL(LOCALE_SPOSITIVESIGN)
+LOCVAL(LOCALE_SNEGATIVESIGN)
+LOCVAL(LOCALE_IPOSSIGNPOSN)
+LOCVAL(LOCALE_INEGSIGNPOSN)
+LOCVAL(LOCALE_IPOSSYMPRECEDES)
+LOCVAL(LOCALE_IPOSSEPBYSPACE)
+LOCVAL(LOCALE_INEGSYMPRECEDES)
+LOCVAL(LOCALE_INEGSEPBYSPACE)
+*/
+	default: found=0;break;
+	}
+    break;  /* LANG(En) */
+
+
 /*Insert other languages here*/
 
     default:
diff --git a/misc/registry.c b/misc/registry.c
index 222d994..668ebf8 100644
--- a/misc/registry.c
+++ b/misc/registry.c
@@ -3017,7 +3017,7 @@
 }
 /* RegConnectRegistryA		[ADVAPI32.127] */
 DWORD RegConnectRegistry32A(LPCSTR machine,HKEY hkey,LPHKEY reskey) {
-	fprintf(stderr,"RegConnectRegistry32A(%s,%08lx,%p), STUB.\n",
+	fprintf(stderr,"RegConnectRegistry32A(%s,%08x,%p), STUB.\n",
 		machine,hkey,reskey
 	);
 	return ERROR_FILE_NOT_FOUND; /* FIXME */
diff --git a/misc/shell.c b/misc/shell.c
index ad492c0..7a1bce9 100644
--- a/misc/shell.c
+++ b/misc/shell.c
@@ -53,7 +53,7 @@
 /*************************************************************************
  *				DragAcceptFiles		[SHELL.9]
  */
-void DragAcceptFiles(HWND hWnd, BOOL b)
+void DragAcceptFiles(HWND16 hWnd, BOOL b)
 {
     WND* wnd = WIN_FindWndPtr(hWnd);
 
@@ -283,7 +283,7 @@
 /*************************************************************************
  *				ShellExecute		[SHELL.20]
  */
-HINSTANCE16 ShellExecute(HWND hWnd, LPCSTR lpOperation, LPCSTR lpFile,
+HINSTANCE16 ShellExecute(HWND16 hWnd, LPCSTR lpOperation, LPCSTR lpFile,
                          LPSTR lpParameters, LPCSTR lpDirectory,
                          INT iShowCmd)
 {
@@ -374,11 +374,11 @@
             }
         }
         return 1;
-    
+
     case WM_COMMAND:
         if (wParam == IDOK)
         {
-            EndDialog(hWnd, TRUE);
+            EndDialog32(hWnd, TRUE);
             return TRUE;
         }
         break;
diff --git a/misc/sound.c b/misc/sound.c
index 9b72416..7c06aea 100644
--- a/misc/sound.c
+++ b/misc/sound.c
@@ -7,110 +7,181 @@
 #include <stdio.h>
 #include "windows.h"
 
-int OpenSound(void)
+INT16 OpenSound16(void)
 {
-  printf("OpenSound()\n");
+  printf("OpenSound16()\n");
   return -1;
 }
 
+void OpenSound32(void)
+{
+  printf("OpenSound32()\n");
+}
+
 void CloseSound(void)
 {
   printf("CloseSound()\n");
 }
 
-int SetVoiceQueueSize(int nVoice, int nBytes)
+INT16 SetVoiceQueueSize16(INT16 nVoice, INT16 nBytes)
 {
-  printf("SetVoiceQueueSize (%d,%d)\n",nVoice,nBytes);
+  printf("SetVoiceQueueSize16 (%d,%d)\n",nVoice,nBytes);
   return 0;
 }
 
-int SetVoiceNote(int nVoice, int nValue, int nLength, int nCdots)
+DWORD SetVoiceQueueSize32(DWORD nVoice, DWORD nBytes)
 {
-  printf("SetVoiceNote (%d,%d,%d,%d)\n",nVoice,nValue,nLength,nCdots);
+  printf("SetVoiceQueueSize32 (%ld,%ld)\n",nVoice,nBytes);
   return 0;
 }
 
-int SetVoiceAccent(int nVoice, int nTempo, int nVolume, int nMode, int nPitch)
+INT16 SetVoiceNote16(INT16 nVoice, INT16 nValue, INT16 nLength, INT16 nCdots)
 {
-  printf("SetVoiceAccent(%d,%d,%d,%d,%d)\n", nVoice, nTempo, 
+  printf("SetVoiceNote16 (%d,%d,%d,%d)\n",nVoice,nValue,nLength,nCdots);
+  return 0;
+}
+
+DWORD SetVoiceNote32(DWORD nVoice, DWORD nValue, DWORD nLength, DWORD nCdots)
+{
+  printf("SetVoiceNote32 (%ld,%ld,%ld,%ld)\n",nVoice,nValue,nLength,nCdots);
+  return 0;
+}
+
+INT16 SetVoiceAccent16(INT16 nVoice, INT16 nTempo, INT16 nVolume,
+                       INT16 nMode, INT16 nPitch)
+{
+  printf("SetVoiceAccent16(%d,%d,%d,%d,%d)\n", nVoice, nTempo, 
 	 nVolume, nMode, nPitch);
   return 0;
 }
 
-int SetVoiceEnvelope(int nVoice, int nShape, int nRepeat)
+DWORD SetVoiceAccent32(DWORD nVoice, DWORD nTempo, DWORD nVolume,
+                       DWORD nMode, DWORD nPitch)
 {
-  printf("SetVoiceEnvelope(%d,%d,%d)\n",nVoice,nShape,nRepeat);
+  printf("SetVoiceAccent32(%ld,%ld,%ld,%ld,%ld)\n", nVoice, nTempo, 
+	 nVolume, nMode, nPitch);
   return 0;
 }
 
-int SetSoundNoise(int nSource, int nDuration)
+INT16 SetVoiceEnvelope16(INT16 nVoice, INT16 nShape, INT16 nRepeat)
 {
-  printf("SetSoundNoise(%d,%d)\n",nSource,nDuration);
+  printf("SetVoiceEnvelope16(%d,%d,%d)\n",nVoice,nShape,nRepeat);
   return 0;
 }
 
-int SetVoiceSound(int nVoice, long lFrequency, int nDuration)
+DWORD SetVoiceEnvelope32(DWORD nVoice, DWORD nShape, DWORD nRepeat)
 {
-  printf("SetVoiceSound(%d, %ld, %d)\n",nVoice,lFrequency, nDuration);
+  printf("SetVoiceEnvelope32(%ld,%ld,%ld)\n",nVoice,nShape,nRepeat);
   return 0;
 }
 
-int StartSound(void)
+INT16 SetSoundNoise16(INT16 nSource, INT16 nDuration)
+{
+  printf("SetSoundNoise16(%d,%d)\n",nSource,nDuration);
+  return 0;
+}
+
+DWORD SetSoundNoise32(DWORD nSource, DWORD nDuration)
+{
+  printf("SetSoundNoise32(%ld,%ld)\n",nSource,nDuration);
+  return 0;
+}
+
+INT16 SetVoiceSound16(INT16 nVoice, DWORD lFrequency, INT16 nDuration)
+{
+  printf("SetVoiceSound16(%d, %ld, %d)\n",nVoice,lFrequency, nDuration);
+  return 0;
+}
+
+DWORD SetVoiceSound32(DWORD nVoice, DWORD lFrequency, DWORD nDuration)
+{
+  printf("SetVoiceSound32(%ld, %ld, %ld)\n",nVoice,lFrequency, nDuration);
+  return 0;
+}
+
+INT16 StartSound16(void)
 {
   return 0;
 }
 
-int StopSound(void)
+INT16 StopSound16(void)
 {
   return 0;
 }
 
-int WaitSoundState(int x)
+INT16 WaitSoundState16(INT16 x)
 {
-	fprintf(stderr, "WaitSoundState(%d)\n", x);
+    fprintf(stderr, "WaitSoundState16(%d)\n", x);
+    return 0;
+}
+
+DWORD WaitSoundState32(DWORD x)
+{
+    fprintf(stderr, "WaitSoundState32(%ld)\n", x);
+    return 0;
+}
+
+INT16 SyncAllVoices16(void)
+{
+    fprintf(stderr, "SyncAllVoices16()\n");
+    return 0;
+}
+
+DWORD SyncAllVoices32(void)
+{
+    fprintf(stderr, "SyncAllVoices32()\n");
+    return 0;
+}
+
+INT16 CountVoiceNotes16(INT16 x)
+{
+    fprintf(stderr, "CountVoiceNotes16(%d)\n", x);
+    return 0;
+}
+
+DWORD CountVoiceNotes32(DWORD x)
+{
+    fprintf(stderr, "CountVoiceNotes32(%ld)\n", x);
+    return 0;
+}
+
+LPINT16 GetThresholdEvent16(void)
+{
+    fprintf(stderr, "GetThresholdEvent16()\n");
+    return NULL;
+}
+
+LPDWORD GetThresholdEvent32(void)
+{
+    fprintf(stderr, "GetThresholdEvent32()\n");
+    return NULL;
+}
+
+INT16 GetThresholdStatus16(void)
+{
+    fprintf(stderr, "GetThresholdStatus16()\n");
+    return 0;
+}
+
+DWORD GetThresholdStatus32(void)
+{
+    fprintf(stderr, "GetThresholdStatus32()\n");
+    return 0;
+}
+
+INT16 SetVoiceThreshold16(INT16 a, INT16 b)
+{
+	fprintf(stderr, "SetVoiceThreshold16(%d,%d)\n", a, b);
         return 0;
 }
 
-int SyncAllVoices(void)
+DWORD SetVoiceThreshold32(DWORD a, DWORD b)
 {
-	fprintf(stderr, "SyncAllVoices()\n");
-        return 0;
-}
-
-INT CountVoiceNotes(INT x)
-{
-	fprintf(stderr, "CountVoiceNotes(%d)\n", x);
-        return 0;
-}
-
-LPINT16 GetThresholdEvent(void)
-{
-	fprintf(stderr, "GetThresholdEvent()\n");
-        return NULL;
-}
-
-int GetThresholdStatus(void)
-{
-	fprintf(stderr, "GetThresholdStatus()\n");
-        return 0;
-}
-
-int SetVoiceThreshold(int a, int b)
-{
-	fprintf(stderr, "SetVoiceThreshold(%d,%d)\n", a, b);
-        return 0;
+    fprintf(stderr, "SetVoiceThreshold32(%ld,%ld)\n", a, b);
+    return 0;
 }
 
 void DoBeep(void)
 {
 	fprintf(stderr, "BEEP!\n");
 }
-
-/*
-11   pascal  WAITSOUNDSTATE(word) WaitSoundState(1)
-12   pascal  SYNCALLVOICES() SyncAllVoices()
-13   pascal  COUNTVOICENOTES(word) CountVoiceNotes(1)
-14   pascal  GETTHRESHOLDEVENT() GetThresholdEvent()
-15   pascal  GETTHRESHOLDSTATUS() GetThresholdStatus()
-16   pascal  SETVOICETHRESHOLD(word word) SetVoiceThreshold(1 2)
-*/
diff --git a/misc/spy.c b/misc/spy.c
index 24906ab..7b19a34 100644
--- a/misc/spy.c
+++ b/misc/spy.c
@@ -93,10 +93,16 @@
     "WM_WINDOWPOSCHANGED",	/* 0x0047 */
     "WM_POWER", NULL, 
     "WM_COPYDATA", 
-    "WM_CANCELJOURNAL", NULL, NULL, NULL, NULL,
+    "WM_CANCELJOURNAL", NULL, NULL, 
+    "WM_NOTIFY", NULL,
 
-    NULL, 		        /* 0x0050 */
-    NULL, NULL, NULL, NULL, NULL, NULL, NULL, 
+    /* 0x0050 */
+    "WM_INPUTLANGCHANGEREQUEST",
+    "WM_INPUTLANGCHANGE", 
+    "WM_TCARD", 
+    "WM_HELP", 
+    "WM_USERCHANGED", 
+    "WM_NOTIFYFORMAT", NULL, NULL, 
     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 
     /* 0x0060 */
@@ -105,9 +111,14 @@
 
     /* 0x0070 */
     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+    NULL, NULL, NULL, 
+    "WM_CONTEXTMENU", 
+    "WM_STYLECHANGING", 
+    "WM_STYLECHANGED", 
+    "WM_DISPLAYCHANGE", 
+    "WM_GETICON",
 
-    NULL,			/* 0x0080 */
+    "WM_SETICON",		/* 0x0080 */
     "WM_NCCREATE",		/* 0x0081 */
     "WM_NCDESTROY",		/* 0x0082 */
     "WM_NCCALCSIZE",		/* 0x0083 */
@@ -374,8 +385,11 @@
     "WM_ENTERMENULOOP",         /* 0x0211 */
     "WM_EXITMENULOOP",          /* 0x0212 */
     "wm_nextmenu", 		/* 0x0213 */
-                            NULL, NULL, NULL, NULL,
-    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+    "WM_SIZING", 
+    "WM_CAPTURECHANGED",
+    "WM_MOVING", NULL,
+    "WM_POWERBROADCAST", 
+    "WM_DEVICECHANGE", NULL, NULL, NULL, NULL, NULL, NULL,
 
     "WM_MDICREATE",             /* 0x0220 */
     "WM_MDIDESTROY",            /* 0x0221 */
@@ -460,7 +474,9 @@
     "WM_PALETTEISCHANGING",
     "WM_PALETTECHANGED",
     "WM_HOTKEY", 		/* 0x0312 */
-	  NULL, NULL, NULL, NULL, NULL, NULL, 
+	  NULL, NULL, NULL, NULL, 
+    "WM_PRINT", 
+    "WM_PRINTCLIENT", 
     NULL, NULL, NULL, NULL, NULL, NULL, NULL, 
 
     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
diff --git a/misc/user.c b/misc/user.c
index 7fd72874..0d0ecb8 100644
--- a/misc/user.c
+++ b/misc/user.c
@@ -100,7 +100,7 @@
 
       /* Create task message queue */
     queueSize = GetProfileInt32A( "windows", "DefaultQueueSize", 8 );
-    if (!SetMessageQueue( queueSize )) return 0;
+    if (!SetMessageQueue32( queueSize )) return 0;
 
     return 1;
 }
diff --git a/misc/winsock.c b/misc/winsock.c
index 5fc4db7..b84cf6c 100644
--- a/misc/winsock.c
+++ b/misc/winsock.c
@@ -581,7 +581,7 @@
   return SOCKET_ERROR;
 }
 
-u_long  WINSOCK_htonl(u_long hostlong)   { return( htonl(hostlong) ); }         
+u_long  WINSOCK_htonl(u_long hostlong)   { return( htonl(hostlong) ); }
 u_short WINSOCK_htons(u_short hostshort) { return( htons(hostshort) ); }
 u_long  WINSOCK_inet_addr(char *cp)      { return( inet_addr(cp) ); }
 u_long  WINSOCK_ntohl(u_long netlong)    { return( ntohl(netlong) ); }
diff --git a/misc/winsock_async.c b/misc/winsock_async.c
index 64433f4..5cd0382 100644
--- a/misc/winsock_async.c
+++ b/misc/winsock_async.c
@@ -18,9 +18,6 @@
 #include <sys/so_ioctl.h>
 #include <sys/param.h>
 #endif
-#ifndef FASYNC
-#define FASYNC FIOASYNC
-#endif
 #ifdef __svr4__
 #include <sys/file.h>
 #include <sys/filio.h>
@@ -32,6 +29,10 @@
 #include "winsock.h"
 #include "debug.h"
 
+#ifndef FASYNC
+#define FASYNC FIOASYNC
+#endif
+
 #define __WS_ASYNC_DEBUG	0
 
 static int		__async_io_max_fd = 0;
diff --git a/msdos/dosmem.c b/msdos/dosmem.c
index aa84593..07d781f 100644
--- a/msdos/dosmem.c
+++ b/msdos/dosmem.c
@@ -17,10 +17,8 @@
 #include "module.h"
 #include "debug.h"
 
-
 HANDLE16 DOSMEM_BiosSeg;  /* BIOS data segment at 0x40:0 */
 
-
 #pragma pack(1)
 
 typedef struct
@@ -76,106 +74,45 @@
 
 #pragma pack(4)
 
-
 static BIOSDATA *pBiosData = NULL;
-char	*DOSMEM_dosmem;
-struct dosmem_entry {
-	struct	dosmem_entry	*next;
-	BYTE			isfree;
-};
+static char	*DOSMEM_dosmem;
+static char	*DOSMEM_top;
 
+       DWORD 	 DOSMEM_CollateTable;
 
-/***********************************************************************
- *           DOSMEM_InitCollateTable
- *
- * Initialises the collate table (character sorting, language dependend)
+/* use 2 low bits of 'size' for the housekeeping */
+
+#define DM_BLOCK_DEBUG		0xABE00000
+#define DM_BLOCK_TERMINAL	0x00000001
+#define DM_BLOCK_FREE		0x00000002
+#define DM_BLOCK_MASK		0x001FFFFC
+
+/*
+#define __DOSMEM_DEBUG__
  */
-DWORD DOSMEM_CollateTable;
 
-static void DOSMEM_InitCollateTable()
-{
-	DWORD		x;
-	unsigned char	*tbl;
-	int		i;
+typedef struct {
+   unsigned	size;
+} dosmem_entry;
 
-	x=GlobalDOSAlloc(258);
-	DOSMEM_CollateTable=MAKELONG(0,(x>>16));
-	tbl=DOSMEM_RealMode2Linear(DOSMEM_CollateTable);
-	*(WORD*)tbl	= 0x100;
-	tbl+=2;
-	for (i=0;i<0x100;i++)
-		*tbl++=i;
-}
+typedef struct {
+  unsigned      blocks;
+  unsigned      free;
+} dosmem_info;
 
+static dosmem_entry* 	root_block = NULL;
+static dosmem_info*	info_block = NULL;
 
-/***********************************************************************
- *           DOSMEM_Init
- *
- * Create the dos memory segments, and store them into the KERNEL
- * exported values.
- */
-BOOL32 DOSMEM_Init(void)
-{
-    /* Allocate 1 MB dosmemory */
-    /* Yes, allocating 1 MB of memory, which is usually not even used, is a 
-     * waste of memory. But I (MM) don't see any easy method to use 
-     * GlobalDOS{Alloc,Free} within an area of memory, with protected mode
-     * selectors pointing into it, and the possibilty, that the userprogram
-     * calls SetSelectorBase(,physical_address_in_DOSMEM); that includes 
-     * dynamical enlarging (reallocing) the dosmem area.
-     * Yes, one could walk the ldt_copy on every realloc() on DOSMEM, but
-     * this feels more like a hack to me than this current implementation is.
-     * If you find another, better, method, just change it. -Marcus Meissner
-     */
-    DOSMEM_dosmem = VirtualAlloc(NULL,0x100000,MEM_COMMIT,PAGE_EXECUTE_READWRITE);
-    if (!DOSMEM_dosmem)
-    {
-        fprintf( stderr, "Could not allocate DOS memory.\n" );
-        return FALSE;
-    }
-    DOSMEM_BiosSeg = GLOBAL_CreateBlock(GMEM_FIXED,DOSMEM_dosmem+0x400,0x100,
-                                        0, FALSE, FALSE, FALSE, NULL );
-    DOSMEM_FillBiosSegment();
-    DOSMEM_InitMemoryHandling();
-    DOSMEM_InitCollateTable();
-    return TRUE;
-}
-
-/***********************************************************************
- *           DOSMEM_InitMemoryHandling
- *
- * Initialises the DOS Memory structures.
- */
-void
-DOSMEM_InitMemoryHandling()
-{
-    struct	dosmem_entry	*dm;
-
-    dm = (struct dosmem_entry*)(DOSMEM_dosmem+0x10000);
-    dm->isfree	=  1;
-    dm->next	=  (struct dosmem_entry*)(DOSMEM_dosmem+0x9FFF0);
-    dm		=  dm->next;
-    dm->isfree	= 0;
-    dm->next	= NULL;
-}
-
-/***********************************************************************
- *           DOSMEM_Tick
- *
- * Increment the BIOS tick counter. Called by timer signal handler.
- */
-void DOSMEM_Tick(void)
-{
-    if (pBiosData) pBiosData->Ticks++;
-}
-
+#define NEXT_BLOCK(block) \
+        (dosmem_entry*)(((char*)(block)) + \
+	 sizeof(dosmem_entry) + ((block)->size & DM_BLOCK_MASK))
 
 /***********************************************************************
  *           DOSMEM_FillBiosSegment
  *
  * Fill the BIOS data segment with dummy values.
  */
-void DOSMEM_FillBiosSegment(void)
+static void DOSMEM_FillBiosSegment(void)
 {
     pBiosData = (BIOSDATA *)GlobalLock16( DOSMEM_BiosSeg );
 
@@ -204,104 +141,254 @@
 }
 
 /***********************************************************************
- *           GlobalDOSAlloc	(KERNEL.184)
+ *           DOSMEM_InitCollateTable
  *
- * Allocates a piece of DOS Memory, in the first 1 MB physical memory.
- * 
- * operates on the preallocated DOSMEM_dosmem (1MB). The useable area
- * starts at 1000:0000 and ends at 9FFF:FFEF
- * Memory allocation strategy is First Fit. (FIXME: Yes,I know that First Fit
- * is a rather bad strategy. But since those functions are rather seldom
- * called, it's easyness fits the purpose well.)
- * 
+ * Initialises the collate table (character sorting, language dependent)
  */
-
-DWORD GlobalDOSAlloc(DWORD size)
+static void DOSMEM_InitCollateTable()
 {
-	struct	dosmem_entry	*dm,*ndm;
-	DWORD	start,blocksize;
-	WORD	sel;
-	HMODULE16 hModule=GetModuleHandle("KERNEL");
+	DWORD		x;
+	unsigned char	*tbl;
+	int		i;
 
-
-	start	= 0;
-	dm	= (struct dosmem_entry*)(DOSMEM_dosmem+0x10000);
-	size	= (size+0xf)&~0xf;
-	while (dm && dm->next) {
-		blocksize = ((char*)dm->next-(char*)dm)-16;
-		if ((dm->isfree) && (blocksize>=size)) {
-			dm->isfree = 0;
-			start = ((((char*)dm)-DOSMEM_dosmem)+0x10)& ~0xf;
-			if ((blocksize-size) >= 0x20) {
-				/* if enough memory is left for a new block
-				 * split this area into two blocks
-				 */
-				ndm=(struct dosmem_entry*)((char*)dm+0x10+size);
-				ndm->isfree	= 1;
-				ndm->next	= dm->next;
-				dm->next	= ndm;
-			}
-			break;
-		}
-		dm=dm->next;
-	}
-	if (!start)
-		return 0;
-	sel=GLOBAL_CreateBlock(
-		GMEM_FIXED,DOSMEM_dosmem+start,size,
-		hModule,FALSE,FALSE,FALSE,NULL
-	);
-	return MAKELONG(sel,start>>4);
+	x = GlobalDOSAlloc(258);
+	DOSMEM_CollateTable = MAKELONG(0,(x>>16));
+	tbl = DOSMEM_MapRealToLinear(DOSMEM_CollateTable);
+	*(WORD*)tbl	= 0x100;
+	tbl += 2;
+	for ( i = 0; i < 0x100; i++) *tbl++ = i;
 }
 
 /***********************************************************************
- *           GlobalDOSFree	(KERNEL.185)
+ *           DOSMEM_InitMemory
  *
- * Frees allocated dosmemory and corresponding selector.
+ * Initialises the DOS memory structures.
  */
-
-WORD
-GlobalDOSFree(WORD sel)
+static void DOSMEM_InitMemory()
 {
-	DWORD	base;
-	struct	dosmem_entry	*dm;
+   /* Low 64Kb are reserved for DOS/BIOS so the useable area starts at
+    * 1000:0000 and ends at 9FFF:FFEF. */
 
-	base = GetSelectorBase(sel);
-	/* base has already been conversed to a physical address */
-	if (base>=0x100000)
-		return sel;
-	dm	= (struct dosmem_entry*)(DOSMEM_dosmem+base-0x10);
-	if (dm->isfree) {
-		fprintf(stderr,"Freeing already freed DOSMEM.\n");
-		return 0;
-	}
-	dm->isfree = 1;
+    dosmem_entry*       dm;
 
-	/* collapse adjunct free blocks into one */
-	dm = (struct dosmem_entry*)(DOSMEM_dosmem+0x10000);
-	while (dm && dm->next) {
-		if (dm->isfree && dm->next->isfree)
-			dm->next = dm->next->next;
-		dm = dm->next;
-	}
-	GLOBAL_FreeBlock(sel);
-	return 0;
+    DOSMEM_top = DOSMEM_dosmem+0x9FFFC; /* 640K */
+    info_block = (dosmem_info*)( DOSMEM_dosmem + 0x10000 );
+
+    /* first block has to be paragraph-aligned relative to the DOSMEM_dosmem */
+
+    root_block = (dosmem_entry*)( DOSMEM_dosmem + 0x10000 +
+                 ((((sizeof(dosmem_info) + 0xf) & ~0xf) - sizeof(dosmem_entry))));
+    root_block->size = DOSMEM_top - (((char*)root_block) + sizeof(dosmem_entry));
+
+    info_block->blocks = 0;
+    info_block->free = root_block->size;
+
+    dm = NEXT_BLOCK(root_block);
+    dm->size = DM_BLOCK_TERMINAL;
+    root_block->size |= DM_BLOCK_FREE 
+#ifdef __DOSMEM_DEBUG__
+		     | DM_BLOCK_DEBUG;
+#endif
+		     ;
 }
 
 /***********************************************************************
- *           DOSMEM_RealMode2Linear
+ *           DOSMEM_Init
  *
- * Converts a realmode segment:offset address into a linear pointer
+ * Create the dos memory segments, and store them into the KERNEL
+ * exported values.
  */
-LPVOID DOSMEM_RealMode2Linear(DWORD x)
+BOOL32 DOSMEM_Init(void)
 {
-	LPVOID	lin;
+    /* Allocate 1 MB dosmemory 
+     * - it is mostly wasted but we use can some of it to 
+     *   store internal translation tables, etc...
+     */
+    DOSMEM_dosmem = VirtualAlloc(NULL,0x100000,MEM_COMMIT,PAGE_EXECUTE_READWRITE);
+    if (!DOSMEM_dosmem)
+    {
+        fprintf( stderr, "Could not allocate DOS memory.\n" );
+        return FALSE;
+    }
+    DOSMEM_BiosSeg = GLOBAL_CreateBlock(GMEM_FIXED,DOSMEM_dosmem+0x400,0x100,
+                                        0, FALSE, FALSE, FALSE, NULL );
+    DOSMEM_FillBiosSegment();
+    DOSMEM_InitMemory();
+    DOSMEM_InitCollateTable();
+    return TRUE;
+}
 
-	lin=DOSMEM_dosmem+(x&0xffff)+(((x&0xffff0000)>>16)*16);
-	dprintf_selector(stddeb,"DOSMEM_RealMode2Linear(0x%08lx) returns 0x%p.\n",
-		x,lin
-	);
-	return lin;
+void DOSMEM_InitExports(HMODULE16 hKernel)
+{
+#define SET_ENTRY_POINT(num,addr) \
+    MODULE_SetEntryPoint( hKernel, (num), GLOBAL_CreateBlock( GMEM_FIXED, \
+                                  DOSMEM_dosmem+(addr), 0x10000, hKernel, \
+                                  FALSE, FALSE, FALSE, NULL ))
+
+    SET_ENTRY_POINT( 174, 0xa0000 );  /* KERNEL.174: __A000H */
+    SET_ENTRY_POINT( 181, 0xb0000 );  /* KERNEL.181: __B000H */
+    SET_ENTRY_POINT( 182, 0xb8000 );  /* KERNEL.182: __B800H */
+    SET_ENTRY_POINT( 195, 0xc0000 );  /* KERNEL.195: __C000H */
+    SET_ENTRY_POINT( 179, 0xd0000 );  /* KERNEL.179: __D000H */
+    SET_ENTRY_POINT( 190, 0xe0000 );  /* KERNEL.190: __E000H */
+    SET_ENTRY_POINT( 173, 0xf0000 );  /* KERNEL.173: __ROMBIOS */
+    SET_ENTRY_POINT( 194, 0xf0000 );  /* KERNEL.194: __F000H */
+    MODULE_SetEntryPoint(hKernel, 193,DOSMEM_BiosSeg); /* KERNEL.193: __0040H */
+
+#undef SET_ENTRY_POINT
+}
+
+/***********************************************************************
+ *           DOSMEM_Tick
+ *
+ * Increment the BIOS tick counter. Called by timer signal handler.
+ */
+void DOSMEM_Tick(void)
+{
+    if (pBiosData) pBiosData->Ticks++;
+}
+
+/***********************************************************************
+ *           DOSMEM_GetBlock
+ *
+ * Carve a chunk of the DOS memory block (without selector).
+ */
+LPVOID DOSMEM_GetBlock(UINT32 size, UINT16* pseg)
+{
+   UINT32  	 blocksize;
+   char         *block = NULL;
+   dosmem_entry *dm;
+#ifdef __DOSMEM_DEBUG_
+   dosmem_entry *prev = NULL;
+#endif
+ 
+   if( size > info_block->free ) return NULL;
+   dm = root_block;
+
+   while (dm && dm->size != DM_BLOCK_TERMINAL)
+   {
+#ifdef __DOSMEM_DEBUG__
+       if( (dm->size & DM_BLOCK_DEBUG) != DM_BLOCK_DEBUG )
+       {
+	    fprintf(stderr,"DOSMEM_GetBlock: MCB overrun! [prev = 0x%08x]\n", 4 + (UINT32)prev);
+	    return NULL;
+       }
+       prev = dm;
+#endif
+       if( dm->size & DM_BLOCK_FREE )
+       {
+	   dosmem_entry  *next = NEXT_BLOCK(dm);
+
+	   while( next->size & DM_BLOCK_FREE ) /* collapse free blocks */
+	   {
+	       dm->size += sizeof(dosmem_entry) + (next->size & DM_BLOCK_MASK);
+	       next->size = (DM_BLOCK_FREE | DM_BLOCK_TERMINAL);
+	       next = NEXT_BLOCK(dm);
+	   }
+
+	   blocksize = dm->size & DM_BLOCK_MASK;
+	   if( blocksize >= size )
+           {
+	       block = ((char*)dm) + sizeof(dosmem_entry);
+	       if( blocksize - size > 0x20 )
+	       {
+		   /* split dm so that the next one stays
+		    * paragraph-aligned (and dm loses free bit) */
+
+	           dm->size = (((size + 0xf + sizeof(dosmem_entry)) & ~0xf) -
+			         	      sizeof(dosmem_entry));
+	           next = (dosmem_entry*)(((char*)dm) + 
+	 		   sizeof(dosmem_entry) + dm->size);
+	           next->size = (blocksize - (dm->size + 
+			   sizeof(dosmem_entry))) | DM_BLOCK_FREE 
+#ifdef __DOSMEM_DEBUG__
+					          | DM_BLOCK_DEBUG
+#endif
+						  ;
+	       } else dm->size &= DM_BLOCK_MASK;
+
+	       info_block->blocks++;
+	       info_block->free -= dm->size;
+	       if( pseg ) *pseg = (block - DOSMEM_dosmem) >> 4;
+#ifdef __DOSMEM_DEBUG__
+               dm->size |= DM_BLOCK_DEBUG;
+#endif
+	       break;
+	   }
+ 	   dm = next;
+       }
+       else dm = NEXT_BLOCK(dm);
+   }
+   return (LPVOID)block;
+}
+
+/***********************************************************************
+ *           DOSMEM_FreeBlock
+ */
+BOOL32 DOSMEM_FreeBlock(void* ptr)
+{
+   if( ptr >= (void*)(((char*)root_block) + sizeof(dosmem_entry)) &&
+       ptr < (void*)DOSMEM_top && !((((char*)ptr) - DOSMEM_dosmem) & 0xf) )
+   {
+       dosmem_entry  *dm = (dosmem_entry*)(((char*)ptr) - sizeof(dosmem_entry));
+
+       if( !(dm->size & (DM_BLOCK_FREE | DM_BLOCK_TERMINAL))
+#ifdef __DOSMEM_DEBUG__
+	 && ((dm->size & DM_BLOCK_DEBUG) == DM_BLOCK_DEBUG )
+#endif
+	 )
+       {
+	     info_block->blocks--;
+	     info_block->free += dm->size;
+
+	     dm->size |= DM_BLOCK_FREE;
+	     return TRUE;
+       }
+   }
+   return FALSE;
+}
+
+/***********************************************************************
+ *           DOSMEM_MapLinearToDos
+ *
+ * Linear address to the DOS address space.
+ */
+UINT32 DOSMEM_MapLinearToDos(LPVOID ptr)
+{
+#ifndef WINELIB
+   if (((char*)ptr >= DOSMEM_dosmem) &&
+        ((char*)ptr < DOSMEM_dosmem+0x100000))  
+	  return (UINT32)ptr - (UINT32)DOSMEM_dosmem;
+#endif
+   return (UINT32)ptr;
+}
+
+/***********************************************************************
+ *           DOSMEM_MapDosToLinear
+ *
+ * DOS linear address to the linear address space.
+ */
+LPVOID DOSMEM_MapDosToLinear(UINT32 ptr)
+{
+#ifndef WINELIB
+   if ( ptr < 1000000 ) return (LPVOID)(ptr + (UINT32)DOSMEM_dosmem);
+#endif
+   return (LPVOID)ptr;
+}
+
+/***********************************************************************
+ *           DOSMEM_MapRealToLinear
+ *
+ * Real mode DOS address into a linear pointer
+ */
+LPVOID DOSMEM_MapRealToLinear(DWORD x)
+{
+   LPVOID       lin;
+
+   lin=DOSMEM_dosmem+(x&0xffff)+(((x&0xffff0000)>>16)*16);
+   dprintf_selector(stddeb,"DOSMEM_MapR2L(0x%08lx) returns 0x%p.\n",
+                    x,lin );
+   return lin;
 }
 
 /***********************************************************************
@@ -311,7 +398,7 @@
  */
 WORD DOSMEM_AllocSelector(WORD realsel)
 {
-	HMODULE16 hModule=GetModuleHandle("KERNEL");
+	HMODULE16 hModule = GetModuleHandle("KERNEL");
 	WORD	sel;
 
 	sel=GLOBAL_CreateBlock(
@@ -323,3 +410,4 @@
 	);
 	return sel;
 }
+
diff --git a/msdos/dpmi.c b/msdos/dpmi.c
index 2c46b59..5096368 100644
--- a/msdos/dpmi.c
+++ b/msdos/dpmi.c
@@ -235,7 +235,7 @@
 		        /* ES:DI is a REALMODE pointer to 5 byte dosmem 
 			 * we fill that with 0x6, realmode pointer to collateTB
 			 */
-			table = DOSMEM_RealMode2Linear(MAKELONG(p->edi,p->es));
+			table = DOSMEM_MapRealToLinear(MAKELONG(p->edi,p->es));
 			*(BYTE*)table		= 0x06;
 			*(DWORD*)(table+1)	= DOSMEM_CollateTable;
 
@@ -249,7 +249,7 @@
 		case 0x44:
 		    switch (p->eax & 0xFF) {
 		    case 0x0D:{/* generic block device request */
-		    	BYTE	*dataptr = DOSMEM_RealMode2Linear((p->ds)*0x1000+(p->edx & 0xFFFF));
+		    	BYTE	*dataptr = DOSMEM_MapRealToLinear((p->ds)*0x1000+(p->edx & 0xFFFF));
 			int	drive = DOS_GET_DRIVE(p->ebx&0xFF); 
 
 		    	if ((p->ecx & 0xFF00) != 0x0800) {
diff --git a/multimedia/audio.c b/multimedia/audio.c
index a822632..5a9b45f 100644
--- a/multimedia/audio.c
+++ b/multimedia/audio.c
@@ -317,7 +317,7 @@
 	USER_HEAP_FREE(hWaveHdr);
 	if (dwFlags & MCI_NOTIFY) {
 		dprintf_mciwave(stddeb,"WAVE_mciPlay // MCI_NOTIFY_SUCCESSFUL %08lX !\n", lpParms->dwCallback);
-		mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), 
+		mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback), 
 			MCIWavDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
 		}
 	return 0;
@@ -387,7 +387,7 @@
 	USER_HEAP_FREE(hWaveHdr);
 	if (dwFlags & MCI_NOTIFY) {
 	  dprintf_mciwave(stddeb,"WAVE_mciRecord // MCI_NOTIFY_SUCCESSFUL %08lX !\n", lpParms->dwCallback);
-		mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), 
+		mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback), 
 			MCIWavDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
 		}
 	return 0;
@@ -590,7 +590,7 @@
 		}
 	if (dwFlags & MCI_NOTIFY) {
 		dprintf_mciwave(stddeb,"WAVE_mciStatus // MCI_NOTIFY_SUCCESSFUL %08lX !\n", lpParms->dwCallback);
-		mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), 
+		mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback), 
 			MCIWavDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
 		}
  	return 0;
@@ -1603,7 +1603,7 @@
 		case DRV_QUERYCONFIGURE:
 			return 1;
 		case DRV_CONFIGURE:
-			MessageBox16((HWND)NULL, "Sample MultiMedia Linux Driver !", 
+			MessageBox16(0, "Sample MultiMedia Linux Driver !", 
 								"MMLinux Driver", MB_OK);
 			return 1;
 		case DRV_INSTALL:
diff --git a/multimedia/joystick.c b/multimedia/joystick.c
index 301ba6c..ab28190 100644
--- a/multimedia/joystick.c
+++ b/multimedia/joystick.c
@@ -67,7 +67,7 @@
 /**************************************************************************
  * 				JoySetCapture		[MMSYSTEM.106]
  */
-WORD JoySetCapture(HWND hWnd, WORD wID, WORD wPeriod, BOOL bChanged)
+WORD JoySetCapture(HWND16 hWnd, WORD wID, WORD wPeriod, BOOL bChanged)
 {
     fprintf(stdnimp, "EMPTY STUB !!! JoySetCapture(%04X, %04X, %d, %d);\n",
 	    hWnd, wID, wPeriod, bChanged);
diff --git a/multimedia/mcianim.c b/multimedia/mcianim.c
index ceef8bf..e6e84f3 100644
--- a/multimedia/mcianim.c
+++ b/multimedia/mcianim.c
@@ -101,7 +101,7 @@
 		dprintf_mcianim(stddeb,
 			"ANIM_mciOpen // MCI_NOTIFY_SUCCESSFUL %08lX !\n", 
 			lpParms->dwCallback);
-		mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), 
+		mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback), 
 			AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
 		}
  	return 0;
@@ -330,7 +330,7 @@
 		dprintf_mcianim(stddeb,
 			"ANIM_mciStatus // MCI_NOTIFY_SUCCESSFUL %08lX !\n", 
 			lpParms->dwCallback);
-		mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), 
+		mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback), 
 			AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
 		}
 	if (dwFlags & MCI_STATUS_ITEM) {
@@ -436,7 +436,7 @@
 		dprintf_mcianim(stddeb,
 			"ANIM_mciPlay // MCI_NOTIFY_SUCCESSFUL %08lX !\n", 
 			lpParms->dwCallback);
-		mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), 
+		mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback), 
 			AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
 		}
 	return 0;
@@ -459,7 +459,7 @@
 		dprintf_mcianim(stddeb,
 			"ANIM_mciStop // MCI_NOTIFY_SUCCESSFUL %08lX !\n", 
 			lpParms->dwCallback);
-		mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), 
+		mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback), 
 			AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
 		}
  	return 0;
@@ -482,7 +482,7 @@
 		dprintf_mcianim(stddeb,
 			"ANIM_mciPause // MCI_NOTIFY_SUCCESSFUL %08lX !\n", 
 			lpParms->dwCallback);
-		mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), 
+		mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback), 
 			AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
 		}
 	return 0;
@@ -505,7 +505,7 @@
 		dprintf_mcianim(stddeb,
 			"ANIM_mciResume // MCI_NOTIFY_SUCCESSFUL %08lX !\n", 
 			lpParms->dwCallback);
-		mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), 
+		mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback), 
 			AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
 		}
 	return 0;
@@ -544,7 +544,7 @@
 		dprintf_mcianim(stddeb,
 			"ANIM_mciSeek // MCI_NOTIFY_SUCCESSFUL %08lX !\n", 
 			lpParms->dwCallback);
-		mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), 
+		mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback), 
 			AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
 		}
 	return dwRet;
@@ -592,7 +592,7 @@
 		dprintf_mcianim(stddeb,
 			"ANIM_mciSet // MCI_NOTIFY_SUCCESSFUL %08lX !\n", 
 			lpParms->dwCallback);
-		mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), 
+		mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback), 
 			AnimDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
 		}
 	return 0;
@@ -631,7 +631,7 @@
 		case DRV_QUERYCONFIGURE:
 			return 1;
 		case DRV_CONFIGURE:
-			MessageBox16((HWND)NULL, "Sample MultiMedia Linux Driver !", 
+			MessageBox16(0, "Sample MultiMedia Linux Driver !", 
 								"MMLinux Driver", MB_OK);
 			return 1;
 		case DRV_INSTALL:
diff --git a/multimedia/mcicda.c b/multimedia/mcicda.c
index bbc0ce3..febab84 100644
--- a/multimedia/mcicda.c
+++ b/multimedia/mcicda.c
@@ -279,7 +279,7 @@
         	dprintf_cdaudio(stddeb,
 			"CDAUDIO_mciOpen // MCI_NOTIFY_SUCCESSFUL %08lX !\n", 
 			lpParms->dwCallback);
-		mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), 
+		mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback), 
 			CDADev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
 		}
  	return 0;
@@ -626,7 +626,7 @@
         	dprintf_cdaudio(stddeb,
 			"CDAUDIO_mciStatus // MCI_NOTIFY_SUCCESSFUL %08lX !\n", 
 			lpParms->dwCallback);
-		mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), 
+		mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback), 
 			CDADev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
 		}
 	if (dwFlags & MCI_STATUS_ITEM) {
@@ -797,7 +797,7 @@
 			"CDAUDIO_mciPlay // MCI_NOTIFY_SUCCESSFUL %08lX !\n", 
 			lpParms->dwCallback);
 /*
-		mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), 
+		mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback), 
 			CDADev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
 */
 		}
@@ -828,7 +828,7 @@
         	dprintf_cdaudio(stddeb,
 			"CDAUDIO_mciStop // MCI_NOTIFY_SUCCESSFUL %08lX !\n", 
 			lpParms->dwCallback);
-		mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), 
+		mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback), 
 			CDADev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
 		}
  	return 0;
@@ -858,7 +858,7 @@
         dprintf_cdaudio(stddeb,
 		"CDAUDIO_mciPause // MCI_NOTIFY_SUCCESSFUL %08lX !\n", 
 		lpParms->dwCallback);
-		mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), 
+		mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback), 
 			CDADev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
 		}
 	return 0;
@@ -888,7 +888,7 @@
         	dprintf_cdaudio(stddeb,
 			"CDAUDIO_mciResume // MCI_NOTIFY_SUCCESSFUL %08lX !\n", 
 			lpParms->dwCallback);
-		mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), 
+		mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback), 
 			CDADev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
 		}
 	return 0;
@@ -937,7 +937,7 @@
         	dprintf_cdaudio(stddeb,
 			"CDAUDIO_mciSeek // MCI_NOTIFY_SUCCESSFUL %08lX !\n", 
 			lpParms->dwCallback);
-		mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), 
+		mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback), 
 			CDADev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
 		}
 	return dwRet;
@@ -1010,7 +1010,7 @@
         	dprintf_cdaudio(stddeb,
 			"CDAUDIO_mciSet // MCI_NOTIFY_SUCCESSFUL %08lX !\n", 
 			lpParms->dwCallback);
-		mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), 
+		mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback), 
 			CDADev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
 		}
 	return 0;
@@ -1047,7 +1047,7 @@
 		case DRV_QUERYCONFIGURE:
 			return 1;
 		case DRV_CONFIGURE:
-			MessageBox16((HWND)NULL, "Sample MultiMedia Linux Driver !", 
+			MessageBox16(0, "Sample MultiMedia Linux Driver !", 
 								"MMLinux Driver", MB_OK);
 			return 1;
 		case DRV_INSTALL:
diff --git a/multimedia/mcistring.c b/multimedia/mcistring.c
index 93fa060..91af08d 100644
--- a/multimedia/mcistring.c
+++ b/multimedia/mcistring.c
@@ -2095,7 +2095,7 @@
  * it is used. (imagine "close all"). Not implemented yet.
  */
 DWORD mciSendString (LPCSTR lpstrCommand, LPSTR lpstrReturnString, 
-	UINT uReturnLength, HWND hwndCallback)
+	UINT uReturnLength, HWND16 hwndCallback)
 {
 	char	*cmd,*dev,*args,**keywords;
 	WORD	uDevTyp=0,wDevID=0;
diff --git a/multimedia/midi.c b/multimedia/midi.c
index addbf16..5d08d7b 100644
--- a/multimedia/midi.c
+++ b/multimedia/midi.c
@@ -485,7 +485,7 @@
 	MCIMidiDev[wDevID].dwStatus = MCI_MODE_STOP;
 	if (dwFlags & MCI_NOTIFY) {
 		dprintf_midi(stddeb, "MIDI_mciPlay // MCI_NOTIFY_SUCCESSFUL %08lX !\n", lpParms->dwCallback);
-		mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), 
+		mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback), 
 			MCIMidiDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
 #if 0
 		exit(1);
@@ -550,7 +550,7 @@
 	MCIMidiDev[wDevID].dwStatus = MCI_MODE_STOP;
 	if (dwFlags & MCI_NOTIFY) {
 		dprintf_midi(stddeb, "MIDI_mciRecord // MCI_NOTIFY_SUCCESSFUL %08lX !\n", lpParms->dwCallback);
-		mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), 
+		mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback), 
 			MCIMidiDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
 		}
 	return 0;
@@ -735,7 +735,7 @@
 		}
 	if (dwFlags & MCI_NOTIFY) {
 		dprintf_midi(stddeb, "MIDI_mciStatus // MCI_NOTIFY_SUCCESSFUL %08lX !\n", lpParms->dwCallback);
-		mciDriverNotify((HWND)LOWORD(lpParms->dwCallback), 
+		mciDriverNotify((HWND16)LOWORD(lpParms->dwCallback), 
 			MCIMidiDev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
 		}
  	return 0;
diff --git a/multimedia/mmsystem.c b/multimedia/mmsystem.c
index bfe0588..12337a6 100644
--- a/multimedia/mmsystem.c
+++ b/multimedia/mmsystem.c
@@ -537,7 +537,7 @@
 /**************************************************************************
 * 				mciDriverNotify			[MMSYSTEM.711]
 */
-BOOL mciDriverNotify(HWND hWndCallBack, UINT wDevID, UINT wStatus)
+BOOL mciDriverNotify(HWND16 hWndCallBack, UINT wDevID, UINT wStatus)
 {
 	dprintf_mmsys(stddeb, "mciDriverNotify(%04X, %u, %04X)\n", hWndCallBack, wDevID, wStatus);
 	if (!IsWindow(hWndCallBack)) return FALSE;
diff --git a/objects/color.c b/objects/color.c
index 76a24cb..5d1abd9 100644
--- a/objects/color.c
+++ b/objects/color.c
@@ -135,7 +135,7 @@
     return cSpace.flags;
 }
 
-COLORREF COLOR_GetSystemPaletteEntry(BYTE i)
+COLORREF COLOR_GetSystemPaletteEntry(UINT32 i)
 {
  return *(COLORREF*)(COLOR_sysPal + i) & 0x00ffffff;
 }
@@ -567,7 +567,7 @@
         palPtr->palPalEntry[i].peBlue = __sysPalTemplate[i].peBlue;
         palPtr->palPalEntry[i].peFlags = 0;  
     }
-    hpalette = CreatePalette( palPtr );
+    hpalette = CreatePalette16( palPtr );
 
     palObj = (PALETTEOBJ*) GDI_GetObjPtr( hpalette, PALETTE_MAGIC );
 
diff --git a/objects/cursoricon.c b/objects/cursoricon.c
index 46a5405..62b4823 100644
--- a/objects/cursoricon.c
+++ b/objects/cursoricon.c
@@ -22,6 +22,7 @@
  * the bits directly :-(
  */
 
+#define NO_TRANSITION_TYPES  /* This file is Win32-clean */
 #include <string.h>
 #include <stdlib.h>
 #include "windows.h"
@@ -38,9 +39,9 @@
 
 extern UINT16 COLOR_GetSystemPaletteSize();
 
-Cursor CURSORICON_XCursor = None;  /* Current X cursor */
-static HCURSOR16 hActiveCursor = 0;  /* Active cursor */
-static int CURSOR_ShowCount = 0;   /* Cursor display count */
+Cursor CURSORICON_XCursor = None;    /* Current X cursor */
+static HCURSOR32 hActiveCursor = 0;  /* Active cursor */
+static INT32 CURSOR_ShowCount = 0;   /* Cursor display count */
 static RECT32 CURSOR_ClipRect;       /* Cursor clipping rect */
 
 /**********************************************************************
@@ -200,9 +201,10 @@
  * Load the icon/cursor directory for a given resource name and find the
  * best matching entry.
  */
-static BOOL CURSORICON_LoadDirEntry(HINSTANCE32 hInstance, SEGPTR name,
-                                    int width, int height, int colors,
-                                    BOOL fCursor, CURSORICONDIRENTRY *dirEntry)
+static BOOL32 CURSORICON_LoadDirEntry( HINSTANCE32 hInstance, SEGPTR name,
+                                       INT32 width, INT32 height,
+                                       INT32 colors, BOOL32 fCursor,
+                                       CURSORICONDIRENTRY *dirEntry )
 {
     HRSRC16 hRsrc;
     HGLOBAL16 hMem;
@@ -234,7 +236,7 @@
  * Create a cursor or icon from a resource.
  */
 HGLOBAL16 CURSORICON_LoadHandler( HGLOBAL16 handle, HINSTANCE16 hInstance,
-                                  BOOL fCursor )
+                                  BOOL32 fCursor )
 {
     HBITMAP32 hAndBits, hXorBits;
     HDC32 hdc;
@@ -294,6 +296,11 @@
 
     hXorBits = CreateDIBitmap32( hdc, &pInfo->bmiHeader, CBM_INIT,
                                  (char*)bmi + size, pInfo, DIB_RGB_COLORS );
+    if (!hXorBits) {
+        free( pInfo );
+    	ReleaseDC32( 0, hdc );
+    	return 0;
+    }
 
     /* Fix the bitmap header to load the monochrome mask */
 
@@ -325,6 +332,11 @@
     hAndBits = CreateDIBitmap32( hdc, &pInfo->bmiHeader, CBM_INIT,
                                  bits, pInfo, DIB_RGB_COLORS );
     ReleaseDC32( 0, hdc );
+    if (!hAndBits) {
+        DeleteObject32( hXorBits );
+        free( pInfo );
+    	return 0;
+    }
 
     /* Now create the CURSORICONINFO structure */
 
@@ -369,8 +381,8 @@
  * Load a cursor or icon.
  */
 static HGLOBAL16 CURSORICON_Load( HINSTANCE16 hInstance, SEGPTR name,
-                                  int width, int height, int colors,
-                                  BOOL fCursor )
+                                  INT32 width, INT32 height, INT32 colors,
+                                  BOOL32 fCursor )
 {
     HGLOBAL16 handle, hRet;
     HRSRC16 hRsrc;
@@ -513,8 +525,9 @@
  return hRet;
 }
 
+
 /***********************************************************************
- *           LoadCursor    (USER.173)
+ *           LoadCursor16    (USER.173)
  */
 HCURSOR16 LoadCursor16( HINSTANCE16 hInstance, SEGPTR name )
 {
@@ -531,9 +544,9 @@
 
 
 /***********************************************************************
- *           LoadIcon    (USER.174)
+ *           LoadIcon16    (USER.174)
  */
-HICON16 LoadIcon16(HINSTANCE16 hInstance,SEGPTR name)
+HICON16 LoadIcon16( HINSTANCE16 hInstance, SEGPTR name )
 {
     if (HIWORD(name))
         dprintf_icon( stddeb, "LoadIcon: %04x '%s'\n",
@@ -549,11 +562,11 @@
 
 
 /***********************************************************************
- *           CreateCursor    (USER.406)
+ *           CreateCursor16    (USER.406)
  */
-HCURSOR16 CreateCursor( HINSTANCE16 hInstance, INT xHotSpot, INT yHotSpot,
-                        INT nWidth, INT nHeight,
-                        const BYTE *lpANDbits, const BYTE *lpXORbits )
+HCURSOR16 CreateCursor16(HINSTANCE16 hInstance, INT16 xHotSpot, INT16 yHotSpot,
+                         INT16 nWidth, INT16 nHeight,
+                         LPCVOID lpANDbits, LPCVOID lpXORbits )
 {
     CURSORICONINFO info = { { xHotSpot, yHotSpot }, nWidth, nHeight, 0, 1, 1 };
 
@@ -564,12 +577,43 @@
 
 
 /***********************************************************************
- *           CreateIcon    (USER.407)
+ *           CreateCursor32    (USER32.66)
  */
-HICON16 CreateIcon( HINSTANCE16 hInstance, INT nWidth, INT nHeight, BYTE bPlanes,
-                  BYTE bBitsPixel, const BYTE* lpANDbits, const BYTE* lpXORbits)
+HCURSOR32 CreateCursor32(HINSTANCE32 hInstance, INT32 xHotSpot, INT32 yHotSpot,
+                         INT32 nWidth, INT32 nHeight,
+                         LPCVOID lpANDbits, LPCVOID lpXORbits )
 {
-    CURSORICONINFO info = { { 0, 0 }, nWidth, nHeight, 0, bPlanes, bBitsPixel };
+    CURSORICONINFO info = { { xHotSpot, yHotSpot }, nWidth, nHeight, 0, 1, 1 };
+
+    dprintf_cursor( stddeb, "CreateCursor: %dx%d spot=%d,%d xor=%p and=%p\n",
+                    nWidth, nHeight, xHotSpot, yHotSpot, lpXORbits, lpANDbits);
+    return CreateCursorIconIndirect( hInstance, &info, lpANDbits, lpXORbits );
+}
+
+
+/***********************************************************************
+ *           CreateIcon16    (USER.407)
+ */
+HICON16 CreateIcon16( HINSTANCE16 hInstance, INT16 nWidth, INT16 nHeight,
+                      BYTE bPlanes, BYTE bBitsPixel,
+                      LPCVOID lpANDbits, LPCVOID lpXORbits )
+{
+    CURSORICONINFO info = { { 0, 0 }, nWidth, nHeight, 0, bPlanes, bBitsPixel};
+
+    dprintf_icon( stddeb, "CreateIcon: %dx%dx%d, xor=%p, and=%p\n",
+                  nWidth, nHeight, bPlanes * bBitsPixel, lpXORbits, lpANDbits);
+    return CreateCursorIconIndirect( hInstance, &info, lpANDbits, lpXORbits );
+}
+
+
+/***********************************************************************
+ *           CreateIcon32    (USER32.74)
+ */
+HICON32 CreateIcon32( HINSTANCE32 hInstance, INT32 nWidth, INT32 nHeight,
+                      BYTE bPlanes, BYTE bBitsPixel,
+                      LPCVOID lpANDbits, LPCVOID lpXORbits )
+{
+    CURSORICONINFO info = { { 0, 0 }, nWidth, nHeight, 0, bPlanes, bBitsPixel};
 
     dprintf_icon( stddeb, "CreateIcon: %dx%dx%d, xor=%p, and=%p\n",
                   nWidth, nHeight, bPlanes * bBitsPixel, lpXORbits, lpANDbits);
@@ -580,10 +624,8 @@
 /***********************************************************************
  *           CreateCursorIconIndirect    (USER.408)
  */
-HGLOBAL16 CreateCursorIconIndirect( HINSTANCE16 hInstance,
-                                    CURSORICONINFO *info,
-                                    const BYTE *lpANDbits,
-                                    const BYTE *lpXORbits )
+HGLOBAL16 CreateCursorIconIndirect(HINSTANCE16 hInstance, CURSORICONINFO *info,
+                                   LPCVOID lpANDbits, LPCVOID lpXORbits )
 {
     HGLOBAL16 handle;
     char *ptr;
@@ -637,9 +679,18 @@
 
 
 /***********************************************************************
- *           DestroyIcon    (USER.457)
+ *           DestroyIcon16    (USER.457)
  */
-BOOL DestroyIcon( HICON16 hIcon )
+BOOL16 DestroyIcon16( HICON16 hIcon )
+{
+    return DestroyIcon32( hIcon );
+}
+
+
+/***********************************************************************
+ *           DestroyIcon32    (USER32.132)
+ */
+BOOL32 DestroyIcon32( HICON32 hIcon )
 {
     dprintf_icon( stddeb, "DestroyIcon: %04x\n", hIcon );
     /* FIXME: should check for OEM icon here */
@@ -648,9 +699,18 @@
 
 
 /***********************************************************************
- *           DestroyCursor    (USER.458)
+ *           DestroyCursor16    (USER.458)
  */
-BOOL DestroyCursor( HCURSOR16 hCursor )
+BOOL16 DestroyCursor16( HCURSOR16 hCursor )
+{
+    return DestroyCursor32( hCursor );
+}
+
+
+/***********************************************************************
+ *           DestroyCursor32    (USER32.131)
+ */
+BOOL32 DestroyCursor32( HCURSOR32 hCursor )
 {
     dprintf_cursor( stddeb, "DestroyCursor: %04x\n", hCursor );
     /* FIXME: should check for OEM cursor here */
@@ -659,13 +719,22 @@
 
 
 /***********************************************************************
- *           DrawIcon    (USER.84)
+ *           DrawIcon16    (USER.84)
  */
-BOOL DrawIcon( HDC16 hdc, INT x, INT y, HICON16 hIcon )
+BOOL16 DrawIcon16( HDC16 hdc, INT16 x, INT16 y, HICON16 hIcon )
+{
+    return DrawIcon32( hdc, x, y, hIcon );
+}
+
+
+/***********************************************************************
+ *           DrawIcon32    (USER32.158)
+ */
+BOOL32 DrawIcon32( HDC32 hdc, INT32 x, INT32 y, HICON32 hIcon )
 {
     CURSORICONINFO *ptr;
     HDC32 hMemDC;
-    HBITMAP16 hXorBits, hAndBits;
+    HBITMAP32 hXorBits, hAndBits;
     COLORREF oldFg, oldBg;
 
     if (!(ptr = (CURSORICONINFO *)GlobalLock16( hIcon ))) return FALSE;
@@ -719,7 +788,7 @@
  *
  * Change the X cursor. Helper function for SetCursor() and ShowCursor().
  */
-static BOOL CURSORICON_SetCursor( HCURSOR16 hCursor )
+static BOOL32 CURSORICON_SetCursor( HCURSOR16 hCursor )
 {
     Pixmap pixmapBits, pixmapMask, pixmapAll;
     XColor fg, bg;
@@ -842,7 +911,7 @@
     else
     {
         /* Set the same cursor for all top-level windows */
-        HWND hwnd = GetWindow32( GetDesktopWindow32(), GW_CHILD );
+        HWND32 hwnd = GetWindow32( GetDesktopWindow32(), GW_CHILD );
         while(hwnd)
         {
             Window win = WIN_GetXWindow( hwnd );
@@ -855,11 +924,20 @@
 
 
 /***********************************************************************
- *           SetCursor    (USER.69)
+ *           SetCursor16    (USER.69)
  */
-HCURSOR16 SetCursor( HCURSOR16 hCursor )
+HCURSOR16 SetCursor16( HCURSOR16 hCursor )
 {
-    HCURSOR16 hOldCursor;
+    return (HCURSOR16)SetCursor32( hCursor );
+}
+
+
+/***********************************************************************
+ *           SetCursor32    (USER32.471)
+ */
+HCURSOR32 SetCursor32( HCURSOR32 hCursor )
+{
+    HCURSOR32 hOldCursor;
 
     if (hCursor == hActiveCursor) return hActiveCursor;  /* No change */
     dprintf_cursor( stddeb, "SetCursor: %04x\n", hCursor );
@@ -872,19 +950,38 @@
 
 
 /***********************************************************************
- *           SetCursorPos    (USER.70)
+ *           SetCursorPos16    (USER.70)
  */
-void SetCursorPos( short x, short y )
+void SetCursorPos16( INT16 x, INT16 y )
 {
-    dprintf_cursor( stddeb, "SetCursorPos: x=%d y=%d\n", x, y );
-    XWarpPointer( display, rootWindow, rootWindow, 0, 0, 0, 0, x, y );
+    SetCursorPos32( x, y );
 }
 
 
 /***********************************************************************
- *           ShowCursor    (USER.71)
+ *           SetCursorPos32    (USER32.473)
  */
-int ShowCursor( BOOL bShow )
+BOOL32 SetCursorPos32( INT32 x, INT32 y )
+{
+    dprintf_cursor( stddeb, "SetCursorPos: x=%d y=%d\n", x, y );
+    XWarpPointer( display, rootWindow, rootWindow, 0, 0, 0, 0, x, y );
+    return TRUE;
+}
+
+
+/***********************************************************************
+ *           ShowCursor16    (USER.71)
+ */
+INT16 ShowCursor16( BOOL16 bShow )
+{
+    return ShowCursor32( bShow );
+}
+
+
+/***********************************************************************
+ *           ShowCursor32    (USER32.529)
+ */
+INT32 ShowCursor32( BOOL32 bShow )
 {
     dprintf_cursor( stddeb, "ShowCursor: %d, count=%d\n",
                     bShow, CURSOR_ShowCount );
@@ -904,9 +1001,18 @@
 
 
 /***********************************************************************
- *           GetCursor    (USER.247)
+ *           GetCursor16    (USER.247)
  */
-HCURSOR16 GetCursor(void)
+HCURSOR16 GetCursor16(void)
+{
+    return hActiveCursor;
+}
+
+
+/***********************************************************************
+ *           GetCursor32    (USER32.226)
+ */
+HCURSOR32 GetCursor32(void)
 {
     return hActiveCursor;
 }
@@ -1027,7 +1133,7 @@
 /**********************************************************************
  *	    LoadIconHandler    (USER.456)
  */
-HICON16 LoadIconHandler( HGLOBAL16 hResource, BOOL bNew )
+HICON16 LoadIconHandler( HGLOBAL16 hResource, BOOL16 bNew )
 {
     dprintf_cursor(stddeb,"LoadIconHandler: hRes=%04x\n",hResource);
 
diff --git a/objects/dc.c b/objects/dc.c
index 02bc5ce..889518f 100644
--- a/objects/dc.c
+++ b/objects/dc.c
@@ -791,14 +791,23 @@
 
 
 /***********************************************************************
- *           GetDeviceCaps    (GDI.80)
+ *           GetDeviceCaps16    (GDI.80)
  */
-int GetDeviceCaps( HDC16 hdc, WORD cap )
+INT16 GetDeviceCaps16( HDC16 hdc, INT16 cap )
+{
+    return GetDeviceCaps32( hdc, cap );
+}
+
+
+/***********************************************************************
+ *           GetDeviceCaps32    (GDI32.171)
+ */
+INT32 GetDeviceCaps32( HDC32 hdc, INT32 cap )
 {
     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
     if (!dc) return 0;
 
-    if (cap > sizeof(DeviceCaps)-sizeof(WORD)) return 0;
+    if ((cap < 0) || (cap > sizeof(DeviceCaps)-sizeof(WORD))) return 0;
     
     dprintf_dc(stddeb, "GetDeviceCaps(%04x,%d): returning %d\n",
 	    hdc, cap, *(WORD *)(((char *)dc->w.devCaps) + cap) );
diff --git a/objects/font.c b/objects/font.c
index b4a3a32..edf0266 100644
--- a/objects/font.c
+++ b/objects/font.c
@@ -754,9 +754,18 @@
 
 
 /***********************************************************************
- *           SetMapperFlags    (GDI.349)
+ *           SetMapperFlags16    (GDI.349)
  */
-DWORD SetMapperFlags(HDC16 hDC, DWORD dwFlag)
+DWORD SetMapperFlags16( HDC16 hDC, DWORD dwFlag )
+{
+    return SetMapperFlags32( hDC, dwFlag );
+}
+
+
+/***********************************************************************
+ *           SetMapperFlags32    (GDI32.322)
+ */
+DWORD SetMapperFlags32( HDC32 hDC, DWORD dwFlag )
 {
     dprintf_font(stdnimp,"SetmapperFlags(%04x, %08lX) // Empty Stub !\n", 
 		 hDC, dwFlag); 
diff --git a/objects/gdiobj.c b/objects/gdiobj.c
index 0359343..d8eccaa 100644
--- a/objects/gdiobj.c
+++ b/objects/gdiobj.c
@@ -7,10 +7,10 @@
 #define NO_TRANSITION_TYPES  /* This file is Win32-clean */
 #include <stdlib.h>
 #include <stdio.h>
-#include "gdi.h"
 #include "color.h"
 #include "bitmap.h"
 #include "brush.h"
+#include "dc.h"
 #include "font.h"
 #include "heap.h"
 #include "palette.h"
diff --git a/objects/metafile.c b/objects/metafile.c
index 0174c92..d5dcf12 100644
--- a/objects/metafile.c
+++ b/objects/metafile.c
@@ -55,10 +55,18 @@
 
 
 /******************************************************************
- *         GetMetafile         GDI.124 By Kenny MacDonald 30 Nov 94
+ *         GetMetafile16   (GDI.124)
  */
+HMETAFILE16 GetMetaFile16( LPCSTR lpFilename )
+{
+    return GetMetaFile32A( lpFilename );
+}
 
-HMETAFILE16 GetMetaFile(LPSTR lpFilename)
+
+/******************************************************************
+ *         GetMetafile32A   (GDI32.197)
+ */
+HMETAFILE32 GetMetaFile32A( LPCSTR lpFilename )
 {
   HMETAFILE16 hmf;
   METAHEADER *mh;
@@ -73,17 +81,21 @@
   hmf = GlobalAlloc16(GMEM_MOVEABLE, MFHEADERSIZE);
   mh = (METAHEADER *)GlobalLock16(hmf);
   
-  if (!mh) {
+  if (!mh)
+  {
     GlobalFree16(hmf);
     return 0;
   }
   
-  if ((hFile = _lopen32(lpFilename, OF_READ)) == HFILE_ERROR32) {
+  if ((hFile = _lopen32(lpFilename, OF_READ)) == HFILE_ERROR32)
+  {
     GlobalFree16(hmf);
     return 0;
   }
   
-  if (_lread32(hFile, (char *)mh, MFHEADERSIZE) == HFILE_ERROR32) {
+  if (_lread32(hFile, (char *)mh, MFHEADERSIZE) == HFILE_ERROR32)
+  {
+    _lclose32( hFile );
     GlobalFree16(hmf);
     return 0;
   }
@@ -93,20 +105,25 @@
   hmf = GlobalReAlloc16(hmf,size,GMEM_MOVEABLE);
   mh = (METAHEADER *)GlobalLock16(hmf);
   
-  if (!mh) {
+  if (!mh)
+  {
+    _lclose32( hFile );
     GlobalFree16(hmf);
     return 0;
   }
   
   if (_lread32(hFile, (char*)mh + mh->mtHeaderSize * 2, 
-	        size - mh->mtHeaderSize * 2) == HFILE_ERROR32) {
+	        size - mh->mtHeaderSize * 2) == HFILE_ERROR32)
+  {
+    _lclose32( hFile );
     GlobalFree16(hmf);
     return 0;
   }
   
   _lclose32(hFile);
 
-  if (mh->mtType != 1) {
+  if (mh->mtType != 1)
+  {
     GlobalFree16(hmf);
     return 0;
   }
@@ -118,10 +135,31 @@
 
 
 /******************************************************************
- *         CopyMetafile         GDI.151 Niels de Carpentier, April 1996
+ *         GetMetafile32W   (GDI32.199)
+ */
+HMETAFILE32 GetMetaFile32W( LPCWSTR lpFilename )
+{
+    LPSTR p = HEAP_strdupWtoA( GetProcessHeap(), 0, lpFilename );
+    HMETAFILE32 ret = GetMetaFile32A( p );
+    HeapFree( GetProcessHeap(), 0, p );
+    return ret;
+}
+
+
+/******************************************************************
+ *         CopyMetaFile16   (GDI.151)
  */
 
-HMETAFILE16 CopyMetaFile(HMETAFILE16 hSrcMetaFile, LPCSTR lpFilename)
+HMETAFILE16 CopyMetaFile16( HMETAFILE16 hSrcMetaFile, LPCSTR lpFilename )
+{
+    return CopyMetaFile32A( hSrcMetaFile, lpFilename );
+}
+
+
+/******************************************************************
+ *         CopyMetaFile32A   (GDI32.23)
+ */
+HMETAFILE32 CopyMetaFile32A( HMETAFILE32 hSrcMetaFile, LPCSTR lpFilename )
 {
     HMETAFILE16 handle = 0;
     METAHEADER *mh;
@@ -146,6 +184,7 @@
         _lclose32(hFile);
 	if (i == -1)
 	    return 0;
+        /* FIXME: return value */
         }
     else                     /* memory based metafile */
         {
@@ -158,12 +197,25 @@
     return handle;
 }
 
+
+/******************************************************************
+ *         CopyMetaFile32W   (GDI32.24)
+ */
+HMETAFILE32 CopyMetaFile32W( HMETAFILE32 hSrcMetaFile, LPCWSTR lpFilename )
+{
+    LPSTR p = HEAP_strdupWtoA( GetProcessHeap(), 0, lpFilename );
+    HMETAFILE32 ret = CopyMetaFile32A( hSrcMetaFile, p );
+    HeapFree( GetProcessHeap(), 0, p );
+    return ret;
+}
+
+
 /******************************************************************
  *         IsValidMetaFile   (GDI.410)
  *         (This is not exactly what windows does, see "Undoc Win")
  */
 
-BOOL IsValidMetaFile(HMETAFILE16 hmf)
+BOOL16 IsValidMetaFile(HMETAFILE16 hmf)
 {
     BOOL resu=FALSE;
     METAHEADER *mh = (METAHEADER *)GlobalLock16(hmf);
@@ -179,82 +231,19 @@
 }
 
 
-#if 0
 /******************************************************************
- *         CloseMetafile         GDI.126
+ *         PlayMetafile16   (GDI.123)
  */
-
-HMETAFILE16 CloseMetaFile(HDC16 hdc)
+BOOL16 PlayMetaFile16( HDC16 hdc, HMETAFILE16 hmf )
 {
-    DC *dc;
-    METAHEADER *mh;
-    HMETAFILE16 hmf;
-    HFILE hFile;
-    METAFILEDRV_PDEVICE *physDev;
-    
-    dprintf_metafile(stddeb,"CloseMetaFile\n");
-
-    if (!(dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC))) return 0;
-
-    physDev = (METAFILEDRV_PDEVICE *)dc->physDev;
-    mh = (METAHEADER *)GlobalLock16( physDev->hMetafile );
-
-    /* Construct the end of metafile record - this is documented
-     * in SDK Knowledgebase Q99334.
-     */
-
-    if (!MF_MetaParam0(dc, META_EOF))
-    {
-        DeleteDC32( hdc );
-	return 0;
-    }	
-
-    if (mh->mtType == 1)        /* disk based metafile */
-    {
-        hFile = mh->mtNoParameters;
-	mh->mtNoParameters = 0;
-        if (_llseek(hFile, 0L, 0) == -1)
-        {
-            DeleteDC32( hdc );
-            return 0;
-        }
-        if (_lwrite32(hFile, (char *)mh, MFHEADERSIZE) == -1)
-        {
-            DeleteDC32( hdc );
-            return 0;
-        }
-        _lclose(hFile);
-    }
-
-    hmf = physDev->hMetafile;
-    GlobalUnlock16( hmf );
-    physDev->hMetafile = 0;  /* So it won't be deleted */
-    DeleteDC32( hdc );
-    return hmf;
+    return PlayMetaFile32( hdc, hmf );
 }
 
 
 /******************************************************************
- *         DeleteMetafile         GDI.127
+ *         PlayMetafile32   (GDI32.265)
  */
-
-BOOL DeleteMetaFile(HMETAFILE16 hmf)
-{
-    METAHEADER *mh = (METAHEADER *)GlobalLock16(hmf);
-
-    if (!mh)
-	return FALSE;
-
-    GlobalFree16(hmf);
-    return TRUE;
-}
-#endif
-
-/******************************************************************
- *         PlayMetafile         GDI.123
- */
-
-BOOL PlayMetaFile(HDC16 hdc, HMETAFILE16 hmf)
+BOOL32 PlayMetaFile32( HDC32 hdc, HMETAFILE32 hmf )
 {
     METAHEADER *mh = (METAHEADER *)GlobalLock16(hmf);
     METARECORD *mr;
@@ -592,7 +581,7 @@
     /* W. Magro: Some new metafile operations.  Not all debugged. */
     case META_CREATEPALETTE:
 	MF_AddHandle(ht, nHandles, 
-		     CreatePalette((LPLOGPALETTE)mr->rdParam));
+		     CreatePalette16((LPLOGPALETTE)mr->rdParam));
 	break;
 
     case META_SETTEXTALIGN:
@@ -600,15 +589,15 @@
 	break;
 
     case META_SELECTPALETTE:
-	SelectPalette(hdc, *(ht->objectHandle + *(mr->rdParam+1)),*(mr->rdParam));
+	SelectPalette16(hdc, *(ht->objectHandle + *(mr->rdParam+1)),*(mr->rdParam));
 	break;
 
     case META_SETMAPPERFLAGS:
-	SetMapperFlags(hdc, *(mr->rdParam));
+	SetMapperFlags16(hdc, *(mr->rdParam));
 	break;
 
     case META_REALIZEPALETTE:
-	RealizePalette(hdc);
+	RealizePalette16(hdc);
 	break;
 
     case META_ESCAPE:
@@ -735,7 +724,7 @@
 
 
 /******************************************************************
- *         GetMetaFileBits		by William Magro, 19 Sep 1995
+ *         GetMetaFileBits   (GDI.159)
  *
  * Trade in a meta file object handle for a handle to the meta file memory
  */
@@ -748,11 +737,10 @@
 }
 
 /******************************************************************
- *         SetMetaFileBits		by William Magro, 19 Sep 1995
+ *         SetMetaFileBits   (GDI.160)
  *
  * Trade in a meta file memory handle for a handle to a meta file object
  */
-
 HMETAFILE16 SetMetaFileBits( HGLOBAL16 hMem )
 {
     dprintf_metafile(stddeb,"SetMetaFileBits: hmf out: %04x\n", hMem);
diff --git a/objects/oembitmap.c b/objects/oembitmap.c
index 87929bc..224f658 100644
--- a/objects/oembitmap.c
+++ b/objects/oembitmap.c
@@ -284,7 +284,7 @@
         OBM_Colors[i].value = NULL;
         if (OBM_SymbolicColors[i].color & 0xff000000)  /* PALETTEINDEX */
             OBM_Colors[i].pixel = COLOR_ToPhysical( NULL,
-                              GetSysColor(OBM_SymbolicColors[i].color & 0xff));
+                            GetSysColor32(OBM_SymbolicColors[i].color & 0xff));
         else  /* RGB*/
             OBM_Colors[i].pixel = COLOR_ToPhysical( NULL,
                                                  OBM_SymbolicColors[i].color );
diff --git a/objects/palette.c b/objects/palette.c
index 53089a9..5c38d23 100644
--- a/objects/palette.c
+++ b/objects/palette.c
@@ -5,6 +5,8 @@
  * Copyright 1996 Alex Korobka
  *
  */
+
+#define NO_TRANSITION_TYPES  /* This file is Win32-clean */
 #include <stdlib.h>
 #include <string.h>
 #include <X11/Xlib.h>
@@ -17,11 +19,10 @@
 /* #define DEBUG_PALETTE */
 #include "debug.h"
 
-extern int              COLOR_LookupSystemPixel(COLORREF);      /* lookup pixel among static entries 
-                                                                 * of the system palette */
-extern COLORREF		COLOR_GetSystemPaletteEntry(BYTE);
+ /* lookup pixel among static entries of the system palette */
+extern int COLOR_LookupSystemPixel(COLORREF);
 
-static WORD SystemPaletteUse = SYSPAL_STATIC;	/* currently not considered */
+static UINT32 SystemPaletteUse = SYSPAL_STATIC;  /* currently not considered */
 
 static HPALETTE16 hPrimaryPalette = 0; /* used for WM_PALETTECHANGED */
 static HPALETTE16 hLastRealizedPalette = 0; /* UnrealizeObject() needs it */
@@ -39,17 +40,25 @@
 
 
 /***********************************************************************
- *           CreatePalette    (GDI.360)
+ *           CreatePalette16    (GDI.360)
  */
-HPALETTE16 CreatePalette( const LOGPALETTE* palette )
+HPALETTE16 CreatePalette16( const LOGPALETTE* palette )
+{
+    return CreatePalette32( palette );
+}
+
+
+/***********************************************************************
+ *           CreatePalette32    (GDI32.53)
+ */
+HPALETTE32 CreatePalette32( const LOGPALETTE* palette )
 {
     PALETTEOBJ * palettePtr;
-    HPALETTE16 hpalette;
+    HPALETTE32 hpalette;
     int size = sizeof(LOGPALETTE) + (palette->palNumEntries - 1) * sizeof(PALETTEENTRY);
 
-    dprintf_palette(stddeb,"CreatePalette: ");
-
-    dprintf_palette(stddeb,"%i entries, ", palette->palNumEntries);
+    dprintf_palette(stddeb,"CreatePalette: %i entries, ",
+                    palette->palNumEntries);
 
     hpalette = GDI_AllocObject( size + sizeof(int*) +sizeof(GDIOBJHDR) , PALETTE_MAGIC );
     if (!hpalette) return 0;
@@ -66,15 +75,26 @@
 
 
 /***********************************************************************
- *           GetPaletteEntries    (GDI.363)
+ *           GetPaletteEntries16    (GDI.363)
  */
-WORD GetPaletteEntries( HPALETTE16 hpalette, WORD start, WORD count,
-		        LPPALETTEENTRY entries )
+UINT16 GetPaletteEntries16( HPALETTE16 hpalette, UINT16 start, UINT16 count,
+                            LPPALETTEENTRY entries )
+{
+    return GetPaletteEntries32( hpalette, start, count, entries );
+}
+
+
+/***********************************************************************
+ *           GetPaletteEntries32    (GDI32.209)
+ */
+UINT32 GetPaletteEntries32( HPALETTE32 hpalette, UINT32 start, UINT32 count,
+                            LPPALETTEENTRY entries )
 {
     PALETTEOBJ * palPtr;
-    int numEntries;
+    INT32 numEntries;
 
-    dprintf_palette(stddeb,"GetPaletteEntries: hpal = %04x, %i entries\n", hpalette, count);
+    dprintf_palette( stddeb,"GetPaletteEntries: hpal = %04x, %i entries\n",
+                     hpalette, count );
         
     palPtr = (PALETTEOBJ *) GDI_GetObjPtr( hpalette, PALETTE_MAGIC );
     if (!palPtr) return 0;
@@ -85,21 +105,33 @@
     memcpy( entries, &palPtr->logpalette.palPalEntry[start],
 	    count * sizeof(PALETTEENTRY) );
     for( numEntries = 0; numEntries < count ; numEntries++ )
-         if( entries[numEntries].peFlags & 0xF0 ) entries[numEntries].peFlags = 0;
+         if (entries[numEntries].peFlags & 0xF0)
+             entries[numEntries].peFlags = 0;
     return count;
 }
 
 
 /***********************************************************************
- *           SetPaletteEntries    (GDI.364)
+ *           SetPaletteEntries16    (GDI.364)
  */
-WORD SetPaletteEntries( HPALETTE16 hpalette, WORD start, WORD count,
-		        LPPALETTEENTRY entries )
+UINT16 SetPaletteEntries16( HPALETTE16 hpalette, UINT16 start, UINT16 count,
+                            LPPALETTEENTRY entries )
+{
+    return SetPaletteEntries32( hpalette, start, count, entries );
+}
+
+
+/***********************************************************************
+ *           SetPaletteEntries32    (GDI32.326)
+ */
+UINT32 SetPaletteEntries32( HPALETTE32 hpalette, UINT32 start, UINT32 count,
+                            LPPALETTEENTRY entries )
 {
     PALETTEOBJ * palPtr;
-    int numEntries;
+    INT32 numEntries;
 
-    dprintf_palette(stddeb,"SetPaletteEntries: hpal = %04x, %i entries\n", hpalette, count);
+    dprintf_palette( stddeb,"SetPaletteEntries: hpal = %04x, %i entries\n",
+                     hpalette, count );
 
     palPtr = (PALETTEOBJ *) GDI_GetObjPtr( hpalette, PALETTE_MAGIC );
     if (!palPtr) return 0;
@@ -117,13 +149,23 @@
     return count;
 }
 
+
 /***********************************************************************
- *           ResizePalette          (GDI.368)
+ *           ResizePalette16   (GDI.368)
  */
-BOOL ResizePalette(HPALETTE16 hPal, UINT cEntries)
+BOOL16 ResizePalette16( HPALETTE16 hPal, UINT16 cEntries )
+{
+    return ResizePalette32( hPal, cEntries );
+}
+
+
+/***********************************************************************
+ *           ResizePalette32   (GDI32.289)
+ */
+BOOL32 ResizePalette32( HPALETTE32 hPal, UINT32 cEntries )
 {
     PALETTEOBJ * palPtr = (PALETTEOBJ *) GDI_GetObjPtr( hPal, PALETTE_MAGIC );
-    UINT	 cPrevEnt, prevVer;
+    UINT32	 cPrevEnt, prevVer;
     int		 prevsize, size = sizeof(LOGPALETTE) + (cEntries - 1) * sizeof(PALETTEENTRY);
     int*	 mapping = NULL;
 
@@ -156,44 +198,85 @@
     return TRUE;
 }
 
+
 /***********************************************************************
- *           AnimatePalette          (GDI.367)
+ *           AnimatePalette16   (GDI.367)
  */
-BOOL AnimatePalette(HPALETTE16 hPal, UINT StartIndex, UINT NumEntries,
-		    LPPALETTEENTRY PaletteColors)
+BOOL16 AnimatePalette16( HPALETTE16 hPal, UINT16 StartIndex, UINT16 NumEntries,
+                         LPPALETTEENTRY PaletteColors )
+{
+    return AnimatePalette32( hPal, StartIndex, NumEntries, PaletteColors );
+}
+
+
+/***********************************************************************
+ *           AnimatePalette32   (GDI32.6)
+ */
+BOOL32 AnimatePalette32( HPALETTE32 hPal, UINT32 StartIndex, UINT32 NumEntries,
+                         LPPALETTEENTRY PaletteColors )
 {
     fprintf(stdnimp,"AnimatePalette: empty stub! \n");
     return TRUE;
 }
 
-/***********************************************************************
- *           SetSystemPaletteUse    (GDI.373)
- */
-WORD SetSystemPaletteUse( HDC16 hdc, WORD use)
-{
-	 WORD old=SystemPaletteUse;
-	 fprintf(stdnimp,"SetSystemPaletteUse(%04x,%04x) // empty stub !!!\n", hdc, use);
-	 SystemPaletteUse=use;
-	 return old;
-}
 
 /***********************************************************************
- *           GetSystemPaletteUse    (GDI.374)
+ *           SetSystemPaletteUse16   (GDI.373)
  */
-WORD GetSystemPaletteUse( HDC16 hdc )
+UINT16 SetSystemPaletteUse16( HDC16 hdc, UINT16 use )
 {
-	fprintf(stdnimp,"GetSystemPaletteUse(%04x) // empty stub !!!\n", hdc);
-	return SystemPaletteUse;
+    return SetSystemPaletteUse32( hdc, use );
 }
 
 
 /***********************************************************************
- *           GetSystemPaletteEntries    (GDI.375)
+ *           SetSystemPaletteUse32   (GDI32.335)
  */
-WORD GetSystemPaletteEntries( HDC16 hdc, WORD start, WORD count,
-			      LPPALETTEENTRY entries )
+UINT32 SetSystemPaletteUse32( HDC32 hdc, UINT32 use )
 {
-    WORD i;
+    UINT32 old = SystemPaletteUse;
+    fprintf( stdnimp,"SetSystemPaletteUse(%04x,%04x) // empty stub !!!\n",
+             hdc, use );
+    SystemPaletteUse = use;
+    return old;
+}
+
+
+/***********************************************************************
+ *           GetSystemPaletteUse16   (GDI.374)
+ */
+UINT16 GetSystemPaletteUse16( HDC16 hdc )
+{
+    return SystemPaletteUse;
+}
+
+
+/***********************************************************************
+ *           GetSystemPaletteUse32   (GDI32.223)
+ */
+UINT32 GetSystemPaletteUse32( HDC32 hdc )
+{
+    return SystemPaletteUse;
+}
+
+
+/***********************************************************************
+ *           GetSystemPaletteEntries16   (GDI.375)
+ */
+UINT16 GetSystemPaletteEntries16( HDC16 hdc, UINT16 start, UINT16 count,
+                                  LPPALETTEENTRY entries )
+{
+    return GetSystemPaletteEntries32( hdc, start, count, entries );
+}
+
+
+/***********************************************************************
+ *           GetSystemPaletteEntries32   (GDI32.222)
+ */
+UINT32 GetSystemPaletteEntries32( HDC32 hdc, UINT32 start, UINT32 count,
+                                  LPPALETTEENTRY entries )
+{
+    UINT32 i;
     DC *dc;
 
     dprintf_palette(stddeb,"GetSystemPaletteEntries: hdc = %04x, cound = %i", hdc, count );
@@ -204,27 +287,36 @@
 	count = dc->w.devCaps->sizePalette - start;
     for (i = 0; i < count; i++)
     {
-	*(COLORREF*)(entries + i) = COLOR_GetSystemPaletteEntry((BYTE)(start + i));
+	*(COLORREF*)(entries + i) = COLOR_GetSystemPaletteEntry( start + i );
 
-        dprintf_palette(stddeb,"\tidx(%02x) -> RGB(%08lx)\n", (unsigned char)(start + i), 
-							    *(COLORREF*)(entries + i) );
+        dprintf_palette( stddeb,"\tidx(%02x) -> RGB(%08lx)\n",
+                         start + i, *(COLORREF*)(entries + i) );
     }
     return count;
 }
 
 
 /***********************************************************************
- *           GetNearestPaletteIndex    (GDI.370)
+ *           GetNearestPaletteIndex16   (GDI.370)
  */
-WORD GetNearestPaletteIndex( HPALETTE16 hpalette, COLORREF color )
+UINT16 GetNearestPaletteIndex16( HPALETTE16 hpalette, COLORREF color )
 {
-    PALETTEOBJ*	palObj = (PALETTEOBJ*) GDI_GetObjPtr( hpalette, PALETTE_MAGIC );
-    WORD	index  = 0;
+    return GetNearestPaletteIndex32( hpalette, color );
+}
+
+
+/***********************************************************************
+ *           GetNearestPaletteIndex32   (GDI32.203)
+ */
+UINT32 GetNearestPaletteIndex32( HPALETTE32 hpalette, COLORREF color )
+{
+    PALETTEOBJ*	palObj = (PALETTEOBJ*)GDI_GetObjPtr( hpalette, PALETTE_MAGIC );
+    UINT32 index  = 0;
 
     if( palObj )
         index = COLOR_PaletteLookupPixel( palObj->logpalette.palPalEntry, 
-				          palObj->logpalette.palNumEntries, NULL,
-					  color, FALSE );
+				          palObj->logpalette.palNumEntries,
+                                          NULL, color, FALSE );
 
     dprintf_palette(stddeb,"GetNearestPaletteIndex(%04x,%06lx): returning %d\n", 
                     hpalette, color, index );
@@ -233,9 +325,18 @@
 
 
 /***********************************************************************
- *           GetNearestColor    (GDI.154)
+ *           GetNearestColor16   (GDI.154)
  */
-COLORREF GetNearestColor( HDC16 hdc, COLORREF color )
+COLORREF GetNearestColor16( HDC16 hdc, COLORREF color )
+{
+    return GetNearestColor32( hdc, color );
+}
+
+
+/***********************************************************************
+ *           GetNearestColor32   (GDI32.202)
+ */
+COLORREF GetNearestColor32( HDC32 hdc, COLORREF color )
 {
     COLORREF 	 nearest = 0xFADECAFE;
     DC 		*dc;
@@ -318,12 +419,11 @@
 
 /***********************************************************************
  *           GDIRealizePalette    (GDI.362)
- *
  */
-UINT GDIRealizePalette( HDC16 hdc )
+UINT16 GDIRealizePalette( HDC16 hdc )
 {
     PALETTEOBJ* palPtr;
-    int		realized = 0;
+    int realized = 0;
     DC*		dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
     if (!dc) 
     {
@@ -347,14 +447,14 @@
     else dprintf_palette(stddeb, " skipping ");
     
     dprintf_palette(stdnimp, " realized %i colors\n", realized );
-    return (UINT)realized;
+    return (UINT16)realized;
 }
 
 
 /***********************************************************************
  *           RealizeDefaultPalette    (GDI.365)
  */
-WORD RealizeDefaultPalette( HDC16 hdc )
+UINT16 RealizeDefaultPalette( HDC16 hdc )
 {
     DC          *dc;
     PALETTEOBJ*  palPtr;
@@ -392,16 +492,28 @@
 /***********************************************************************
  *           IsDCCurrentPalette   (GDI.412)
  */
-BOOL IsDCCurrentPalette(HDC16 hDC)
+BOOL16 IsDCCurrentPalette(HDC16 hDC)
 {
     DC* dc = (DC *)GDI_GetObjPtr( hDC, DC_MAGIC );
     return (dc)?(dc->w.hPalette == hPrimaryPalette):FALSE;
 }
 
+
 /***********************************************************************
- *           SelectPalette    (USER.282)
+ *           SelectPalette16    (USER.282)
  */
-HPALETTE16 SelectPalette( HDC16 hDC, HPALETTE16 hPal, BOOL bForceBackground )
+HPALETTE16 SelectPalette16( HDC16 hDC, HPALETTE16 hPal,
+                            BOOL16 bForceBackground )
+{
+    return SelectPalette32( hDC, hPal, bForceBackground );
+}
+
+
+/***********************************************************************
+ *           SelectPalette32    (GDI32.300)
+ */
+HPALETTE32 SelectPalette32( HDC32 hDC, HPALETTE32 hPal,
+                            BOOL32 bForceBackground )
 {
     WORD	wBkgPalette = 1;
     PALETTEOBJ* lpt = (PALETTEOBJ*) GDI_GetObjPtr( hPal, PALETTE_MAGIC );
@@ -429,11 +541,20 @@
 
 
 /***********************************************************************
- *           RealizePalette    (USER.283) (GDI32.280)
+ *           RealizePalette16    (USER.283)
  */
-UINT16 RealizePalette( HDC32 hDC )
+UINT16 RealizePalette16( HDC16 hDC )
 {
-    UINT16 realized = GDIRealizePalette( hDC );
+    return RealizePalette32( hDC );
+}
+
+
+/***********************************************************************
+ *           RealizePalette32    (GDI32.280)
+ */
+UINT32 RealizePalette32( HDC32 hDC )
+{
+    UINT32 realized = GDIRealizePalette( hDC );
 
     /* do not send anything if no colors were changed */
 
@@ -462,7 +583,7 @@
      * but it would take forever given the speed of XGet/PutPixel.
      */
     if (hWnd && !(COLOR_GetSystemPaletteFlags() & COLOR_VIRTUAL) ) 
-	InvalidateRect16( hWnd, NULL, FALSE );
+	InvalidateRect32( hWnd, NULL, FALSE );
     return 0x666;
 }
 
diff --git a/objects/text.c b/objects/text.c
index d178a35..1fcf622 100644
--- a/objects/text.c
+++ b/objects/text.c
@@ -390,18 +390,19 @@
 
 
 /***********************************************************************
- *           GrayString   (USER.185)
+ *           GrayString16   (USER.185)
  */
-BOOL GrayString(HDC16 hdc, HBRUSH16 hbr, GRAYSTRINGPROC16 gsprc, LPARAM lParam, 
-		INT cch, INT x, INT y, INT cx, INT cy)
+BOOL16 GrayString16( HDC16 hdc, HBRUSH16 hbr, GRAYSTRINGPROC16 gsprc,
+                     LPARAM lParam, INT16 cch, INT16 x, INT16 y,
+                     INT16 cx, INT16 cy )
 {
-    BOOL ret;
+    BOOL16 ret;
     COLORREF current_color;
 
     if (!cch) cch = lstrlen16( (LPCSTR)PTR_SEG_TO_LIN(lParam) );
     if (gsprc) return gsprc( hdc, lParam, cch );
     current_color = GetTextColor32( hdc );
-    SetTextColor( hdc, GetSysColor(COLOR_GRAYTEXT) );
+    SetTextColor( hdc, GetSysColor32(COLOR_GRAYTEXT) );
     ret = TextOut16( hdc, x, y, (LPCSTR)PTR_SEG_TO_LIN(lParam), cch );
     SetTextColor( hdc, current_color );
     return ret;
@@ -409,24 +410,65 @@
 
 
 /***********************************************************************
+ *           GrayString32A   (USER32.314)
+ */
+BOOL32 GrayString32A( HDC32 hdc, HBRUSH32 hbr, GRAYSTRINGPROC32 gsprc,
+                      LPARAM lParam, INT32 cch, INT32 x, INT32 y,
+                      INT32 cx, INT32 cy )
+{
+    BOOL32 ret;
+    COLORREF current_color;
+
+    if (!cch) cch = lstrlen32A( (LPCSTR)lParam );
+    if (gsprc) return gsprc( hdc, lParam, cch );
+    current_color = GetTextColor32( hdc );
+    SetTextColor( hdc, GetSysColor32(COLOR_GRAYTEXT) );
+    ret = TextOut32A( hdc, x, y, (LPCSTR)lParam, cch );
+    SetTextColor( hdc, current_color );
+    return ret;
+}
+
+
+/***********************************************************************
+ *           GrayString32W   (USER32.315)
+ */
+BOOL32 GrayString32W( HDC32 hdc, HBRUSH32 hbr, GRAYSTRINGPROC32 gsprc,
+                      LPARAM lParam, INT32 cch, INT32 x, INT32 y,
+                      INT32 cx, INT32 cy )
+{
+    BOOL32 ret;
+    COLORREF current_color;
+
+    if (!cch) cch = lstrlen32W( (LPCWSTR)lParam );
+    if (gsprc) return gsprc( hdc, lParam, cch );
+    current_color = GetTextColor32( hdc );
+    SetTextColor( hdc, GetSysColor32(COLOR_GRAYTEXT) );
+    ret = TextOut32W( hdc, x, y, (LPCWSTR)lParam, cch );
+    SetTextColor( hdc, current_color );
+    return ret;
+}
+
+
+/***********************************************************************
  *           TEXT_TabbedTextOut
  *
  * Helper function for TabbedTextOut() and GetTabbedTextExtent().
  * Note: this doesn't work too well for text-alignment modes other
  *       than TA_LEFT|TA_TOP. But we want bug-for-bug compatibility :-)
  */
-LONG TEXT_TabbedTextOut( HDC16 hdc, int x, int y, LPSTR lpstr, int count, 
-                         int cTabStops, LPINT16 lpTabPos, int nTabOrg,
-                         BOOL fDisplayText)
+LONG TEXT_TabbedTextOut( HDC32 hdc, INT32 x, INT32 y, LPCSTR lpstr,
+                         INT32 count, INT32 cTabStops, const INT16 *lpTabPos16,
+                         const INT32 *lpTabPos32, INT32 nTabOrg,
+                         BOOL32 fDisplayText )
 {
-    WORD defWidth;
+    INT32 defWidth;
     DWORD extent = 0;
     int i, tabPos = x;
     int start = x;
 
     if (cTabStops == 1)
     {
-        defWidth = *lpTabPos;
+        defWidth = lpTabPos32 ? *lpTabPos32 : *lpTabPos16;
         cTabStops = 0;
     }
     else
@@ -441,24 +483,37 @@
         for (i = 0; i < count; i++)
             if (lpstr[i] == '\t') break;
         extent = GetTextExtent( hdc, lpstr, i );
-        while ((cTabStops > 0) && (nTabOrg + *lpTabPos <= x + LOWORD(extent)))
+        if (lpTabPos32)
         {
-            lpTabPos++;
-            cTabStops--;
+            while ((cTabStops > 0) &&
+                   (nTabOrg + *lpTabPos32 <= x + LOWORD(extent)))
+            {
+                lpTabPos32++;
+                cTabStops--;
+            }
+        }
+        else
+        {
+            while ((cTabStops > 0) &&
+                   (nTabOrg + *lpTabPos16 <= x + LOWORD(extent)))
+            {
+                lpTabPos16++;
+                cTabStops--;
+            }
         }
         if (i == count)
             tabPos = x + LOWORD(extent);
         else if (cTabStops > 0)
-            tabPos = nTabOrg + *lpTabPos;
+            tabPos = nTabOrg + (lpTabPos32 ? *lpTabPos32 : *lpTabPos16);
         else
             tabPos = nTabOrg + ((x + LOWORD(extent) - nTabOrg) / defWidth + 1) * defWidth;
         if (fDisplayText)
         {
-            RECT16 r;
-            SetRect16( &r, x, y, tabPos, y+HIWORD(extent) );
-            ExtTextOut16( hdc, x, y,
-                          GetBkMode32(hdc) == OPAQUE ? ETO_OPAQUE : 0,
-                          &r, lpstr, i, NULL );
+            RECT32 r;
+            SetRect32( &r, x, y, tabPos, y+HIWORD(extent) );
+            ExtTextOut32A( hdc, x, y,
+                           GetBkMode32(hdc) == OPAQUE ? ETO_OPAQUE : 0,
+                           &r, lpstr, i, NULL );
         }
         x = tabPos;
         count -= i+1;
@@ -469,26 +524,83 @@
 
 
 /***********************************************************************
- *           TabbedTextOut    (USER.196)
+ *           TabbedTextOut16    (USER.196)
  */
-LONG TabbedTextOut( HDC16 hdc, short x, short y, LPSTR lpstr, short count, 
-                    short cTabStops, LPINT16 lpTabPos, short nTabOrg )
+LONG TabbedTextOut16( HDC16 hdc, INT16 x, INT16 y, LPCSTR lpstr, INT16 count, 
+                      INT16 cTabStops, const INT16 *lpTabPos, INT16 nTabOrg )
 {
-    dprintf_text( stddeb, "TabbedTextOut: %04x %d,%d '%*.*s' %d\n",
-                  hdc, x, y, count, count, lpstr, count );
+    dprintf_text( stddeb, "TabbedTextOut16: %04x %d,%d '%.*s' %d\n",
+                  hdc, x, y, count, lpstr, count );
     return TEXT_TabbedTextOut( hdc, x, y, lpstr, count, cTabStops,
-                               lpTabPos, nTabOrg, TRUE );
+                               lpTabPos, NULL, nTabOrg, TRUE );
 }
 
 
 /***********************************************************************
- *           GetTabbedTextExtent    (USER.197)
+ *           TabbedTextOut32A    (USER32.541)
  */
-DWORD GetTabbedTextExtent( HDC16 hdc, LPSTR lpstr, int count, 
-                          int cTabStops, LPINT16 lpTabPos )
+LONG TabbedTextOut32A( HDC32 hdc, INT32 x, INT32 y, LPCSTR lpstr, INT32 count, 
+                       INT32 cTabStops, const INT32 *lpTabPos, INT32 nTabOrg )
 {
-    dprintf_text( stddeb, "GetTabbedTextExtent: %04x '%*.*s' %d\n",
-                  hdc, count, count, lpstr, count );
+    dprintf_text( stddeb, "TabbedTextOut32A: %04x %d,%d '%.*s' %d\n",
+                  hdc, x, y, count, lpstr, count );
+    return TEXT_TabbedTextOut( hdc, x, y, lpstr, count, cTabStops,
+                               NULL, lpTabPos, nTabOrg, TRUE );
+}
+
+
+/***********************************************************************
+ *           TabbedTextOut32W    (USER32.542)
+ */
+LONG TabbedTextOut32W( HDC32 hdc, INT32 x, INT32 y, LPCWSTR str, INT32 count, 
+                       INT32 cTabStops, const INT32 *lpTabPos, INT32 nTabOrg )
+{
+    LONG ret;
+    LPSTR p = HEAP_xalloc( GetProcessHeap(), 0, count + 1 );
+    lstrcpynWtoA( p, str, count + 1 );
+    ret = TabbedTextOut32A( hdc, x, y, p, count, cTabStops,
+                            lpTabPos, nTabOrg );
+    HeapFree( GetProcessHeap(), 0, p );
+    return ret;
+}
+
+
+/***********************************************************************
+ *           GetTabbedTextExtent16    (USER.197)
+ */
+DWORD GetTabbedTextExtent16( HDC16 hdc, LPCSTR lpstr, INT16 count, 
+                             INT16 cTabStops, const INT16 *lpTabPos )
+{
+    dprintf_text( stddeb, "GetTabbedTextExtent: %04x '%.*s' %d\n",
+                  hdc, count, lpstr, count );
     return TEXT_TabbedTextOut( hdc, 0, 0, lpstr, count, cTabStops,
-                               lpTabPos, 0, FALSE );
+                               lpTabPos, NULL, 0, FALSE );
+}
+
+
+/***********************************************************************
+ *           GetTabbedTextExtent32A    (USER32.292)
+ */
+DWORD GetTabbedTextExtent32A( HDC32 hdc, LPCSTR lpstr, INT32 count, 
+                              INT32 cTabStops, const INT32 *lpTabPos )
+{
+    dprintf_text( stddeb, "GetTabbedTextExtent: %04x '%.*s' %d\n",
+                  hdc, count, lpstr, count );
+    return TEXT_TabbedTextOut( hdc, 0, 0, lpstr, count, cTabStops,
+                               NULL, lpTabPos, 0, FALSE );
+}
+
+
+/***********************************************************************
+ *           GetTabbedTextExtent32W    (USER32.293)
+ */
+DWORD GetTabbedTextExtent32W( HDC32 hdc, LPCWSTR lpstr, INT32 count, 
+                              INT32 cTabStops, const INT32 *lpTabPos )
+{
+    LONG ret;
+    LPSTR p = HEAP_xalloc( GetProcessHeap(), 0, count + 1 );
+    lstrcpynWtoA( p, lpstr, count + 1 );
+    ret = GetTabbedTextExtent32A( hdc, p, count, cTabStops, lpTabPos );
+    HeapFree( GetProcessHeap(), 0, p );
+    return ret;
 }
diff --git a/programs/progman/ChangeLog b/programs/progman/ChangeLog
index aeea3e2..8e1fac0 100644
--- a/programs/progman/ChangeLog
+++ b/programs/progman/ChangeLog
@@ -1,3 +1,8 @@
+Wed Feb 12 00:58:37 1997  Elker Cavina <elker@mail.asianet.it>
+
+	* [It.rc] (new)
+	Added Italian language support.
+
 Fri Jan 24 11:21:30 1997  Bang Jun-Young  <bangjy@nownuri.nowcom.co.kr>
 
 	* [Ko.rc] (new)
diff --git a/programs/progman/Hu.rc b/programs/progman/Hu.rc
new file mode 100644
index 0000000..26c567a
--- /dev/null
+++ b/programs/progman/Hu.rc
@@ -0,0 +1,119 @@
+/*
+ * Program Manager
+ *
+ * Copyright 1996 Ulrich Schmid
+ */
+
+#define LANGUAGE_ID                  Hu
+#define LANGUAGE_NUMBER              7
+#define LANGUAGE_MENU_ITEM           "&Magyar"
+
+/* Menu */
+
+#define MENU_FILE                    "&File"
+#define MENU_FILE_NEW                "&Új..."
+#define MENU_FILE_OPEN               "&Megnyitás\tEnter"
+#define MENU_FILE_MOVE               "M&ozgatás...\tF7"
+#define MENU_FILE_COPY               "Má&solás...\tF8"
+#define MENU_FILE_DELETE             "&Törlés\tDel"
+#define MENU_FILE_ATTRIBUTES         "&Jellemzõk...\tAlt+Enter"
+#define MENU_FILE_EXECUTE            "&Futtatás..."
+#define MENU_FILE_EXIT               "&Kilépés a Windows-ból..."
+
+#define MENU_OPTIONS                 "&Beállítások"
+#define MENU_OPTIONS_AUTO_ARRANGE    "&Automatikus elrendezés"
+#define MENU_OPTIONS_MIN_ON_RUN      "&Minimalizálás futtatáskor"
+#define MENU_OPTIONS_SAVE_SETTINGS   "&Beállítások mentése kilépéskor"
+
+#define MENU_WINDOWS                 "&Ablakok"
+#define MENU_WINDOWS_OVERLAP         "Á&tlapolás\tShift+F5"
+#define MENU_WINDOWS_SIDE_BY_SIDE    "&Egymás mellé rakás\tShift+F4"
+#define MENU_WINDOWS_ARRANGE         "&Ikonok rendezése"
+
+#define MENU_LANGUAGE                "&Nyelv"
+
+#define MENU_HELP                    "&Segítség"
+#define MENU_HELP_CONTENTS           "&Tartalom"
+#define MENU_HELP_SEARCH             "&Keresés..."
+#define MENU_HELP_HELP_ON_HELP       "&Segítség a Segítségrõl"
+#define MENU_HELP_TUTORIAL           "T&anító"
+
+#define MENU_INFO                    "&Információ..."
+#define MENU_INFO_LICENSE            "&Licensz"
+#define MENU_INFO_NO_WARRANTY        "&SEMMI GARANCIA"
+#define MENU_INFO_ABOUT_WINE         "&A WINE-ról"
+
+/* Dialogs */
+
+#define DIALOG_OK                    "OK"
+#define DIALOG_CANCEL                "Mégsem"
+#define DIALOG_BROWSE                "&Válogatás"
+#define DIALOG_HELP                  "&Segítség"
+
+#define DIALOG_NEW_CAPTION           "Új program objektum"
+#define DIALOG_NEW_NEW               "Új"
+#define DIALOG_NEW_GROUP             "Program &csoport"
+#define DIALOG_NEW_PROGRAM           "&Program"
+
+#define DIALOG_MOVE_CAPTION          "Program mozgatása"
+#define DIALOG_MOVE_PROGRAM          "Mozgatandó &program:"
+#define DIALOG_MOVE_FROM_GROUP       "&Melyik csoportból:"
+#define DIALOG_MOVE_TO_GROUP         "M&elyik csoportba:"
+
+#define DIALOG_COPY_CAPTION          "Program másolása"
+#define DIALOG_COPY_PROGRAM          "Másolandó program:"
+#define DIALOG_COPY_FROM_GROUP       DIALOG_MOVE_FROM_GROUP
+#define DIALOG_COPY_TO_GROUP         DIALOG_MOVE_TO_GROUP
+
+#define DIALOG_GROUP_CAPTION         "Program csoport jellemzõi"
+#define DIALOG_GROUP_DESCRIPTION     "&Leírás:"
+#define DIALOG_GROUP_FILE            "&Csoport file:"
+
+#define DIALOG_PROGRAM_CAPTION       "Program jellemzõi"
+#define DIALOG_PROGRAM_DESCRIPTION   DIALOG_GROUP_DESCRIPTION
+#define DIALOG_PROGRAM_COMMAND_LINE  "&Parancssor:"
+#define DIALOG_PROGRAM_DIRECTORY     "&Mûködési könyvtár:"
+#define DIALOG_PROGRAM_HOT_KEY       "&Billentyû kombináció:"
+#define DIALOG_PROGRAM_SYMBOL        "&Ikonként futtat"
+#define DIALOG_PROGRAM_OTHER_SYMBOL  "&Más ikon..."
+
+#define DIALOG_SYMBOL_CAPTION        "Ikon kiválasztása"
+#define DIALOG_SYMBOL_FILE           "&Filenév:"
+#define DIALOG_SYMBOL_CURRENT        "&Jelenlegi ikon:"
+
+#define DIALOG_EXECUTE_CAPTION       "Program végrehajtása"
+#define DIALOG_EXECUTE_COMMAND_LINE  DIALOG_PROGRAM_COMMAND_LINE
+#define DIALOG_EXECUTE_SYMBOL        DIALOG_PROGRAM_SYMBOL
+
+/* Strings */
+
+#define STRING_PROGRAM_MANAGER            "Programkezelõ"
+#define STRING_ERROR                      "HIBA"
+#define STRING_WARNING                    "FIGYELMEZTETÉS"
+#define STRING_INFO                       "Információ"
+#define STRING_DELETE                     "Törlés"
+#define STRING_DELETE_GROUP_s             "Töröljem a `%s' csoportot ?"
+#define STRING_DELETE_PROGRAM_s           "Töröljem a `%s' programot ?"
+#define STRING_NOT_IMPLEMENTED            "Nincs implementálva"
+#define STRING_FILE_READ_ERROR_s          "Hiba a `%s' olvasásánál"
+#define STRING_FILE_WRITE_ERROR_s         "Hiba a `%s' írásánál"
+
+#define STRING_GRPFILE_READ_ERROR_s       "\
+Nem tudom megnyitni a `%s' csoport file-t.\n\
+Továbbá is megpróbáljam majd?"
+
+#define STRING_OUT_OF_MEMORY              "Nincs elég memória"
+#define STRING_WINHELP_ERROR              "Segítség nem elérhetõ"
+#define STRING_UNKNOWN_FEATURE_s          "Ismeretlen feature %s-ben"
+#define STRING_FILE_NOT_OVERWRITTEN_s     "A `%s' már létezik. Nem írtam felül."
+#define STRING_SAVE_GROUP_AS_s            "`%s'-ként ments el a csoportot, hogy megelõzd a file felülírását"
+
+#define STRING_NO_HOT_KEY                 "None"
+
+#define STRING_ALL_FILES                  "Minden file (*.*)"
+#define STRING_PROGRAMS                   "Programok"
+#define STRING_LIBRARIES_DLL              "Library-k (*.dll)"
+#define STRING_SYMBOL_FILES               "Ikon file-ok"
+#define STRING_SYMBOLS_ICO                "Ikonok (*.ico)"
+
+#include "Xx.rc"
diff --git a/programs/progman/It.rc b/programs/progman/It.rc
new file mode 100644
index 0000000..6c6d962
--- /dev/null
+++ b/programs/progman/It.rc
@@ -0,0 +1,119 @@
+/*
+ * Program Manager
+ *
+ * Copyright 1996 Ulrich Schmid
+ */
+
+#define LANGUAGE_ID                  It
+#define LANGUAGE_NUMBER              9
+#define LANGUAGE_MENU_ITEM           "&Italiano"
+
+/* Menu */
+
+#define MENU_FILE                    "&File"
+#define MENU_FILE_NEW                "&Nuovo..."
+#define MENU_FILE_OPEN               "&Apri\tEnter"
+#define MENU_FILE_MOVE               "&Sposta...\tF7"
+#define MENU_FILE_COPY               "&Copia...\tF8"
+#define MENU_FILE_DELETE             "E&limina\tEntf"
+#define MENU_FILE_ATTRIBUTES         "Pr&oprieta'...\tAlt+Enter"
+#define MENU_FILE_EXECUTE            "&Esegui..."
+#define MENU_FILE_EXIT               "Esc&i"
+
+#define MENU_OPTIONS                 "&Opzioni"
+#define MENU_OPTIONS_AUTO_ARRANGE    "&Disposizione automatica"
+#define MENU_OPTIONS_MIN_ON_RUN      "&Riduci a icona in esecuzione"
+#define MENU_OPTIONS_SAVE_SETTINGS   "&Salva impostazioni in uscita"
+
+#define MENU_WINDOWS                 "F&inestra"
+#define MENU_WINDOWS_OVERLAP         "&Sovrapponi\tShift+F5"
+#define MENU_WINDOWS_SIDE_BY_SIDE    "A&ffianca\tShift+F4"
+#define MENU_WINDOWS_ARRANGE         "&Disponi icone"
+
+#define MENU_LANGUAGE                "&Lingua"
+
+#define MENU_HELP                    "&?"
+#define MENU_HELP_CONTENTS           "&Sommario"
+#define MENU_HELP_SEARCH             "&Ricerca..."
+#define MENU_HELP_HELP_ON_HELP       "&Aiuto sulla Guida"
+#define MENU_HELP_TUTORIAL           "&Tutorial"
+
+#define MENU_INFO                    "&Informazioni su..."
+#define MENU_INFO_LICENSE            "&Licenza"
+#define MENU_INFO_NO_WARRANTY        "&NESSUNA GARANZIA"
+#define MENU_INFO_ABOUT_WINE         "&Informazioni su WINE"
+
+/* Dialogs */
+
+#define DIALOG_OK                    "OK"
+#define DIALOG_CANCEL                "Annulla"
+#define DIALOG_BROWSE                "S&foglia"
+#define DIALOG_HELP                  "&?"
+
+#define DIALOG_NEW_CAPTION           "Nuovo elemento"
+#define DIALOG_NEW_NEW               "Nuovo"
+#define DIALOG_NEW_GROUP             "&Gruppo di programmi"
+#define DIALOG_NEW_PROGRAM           "&Programma"
+
+#define DIALOG_MOVE_CAPTION          "Sposta programma"
+#define DIALOG_MOVE_PROGRAM          "Sposta programma:"
+#define DIALOG_MOVE_FROM_GROUP       "Dal gruppo:"
+#define DIALOG_MOVE_TO_GROUP         "&Al gruppo:"
+
+#define DIALOG_COPY_CAPTION          "Copia programma"
+#define DIALOG_COPY_PROGRAM          "Copia programma:"
+#define DIALOG_COPY_FROM_GROUP       DIALOG_MOVE_FROM_GROUP
+#define DIALOG_COPY_TO_GROUP         DIALOG_MOVE_TO_GROUP
+
+#define DIALOG_GROUP_CAPTION         "Proprieta' del gruppo di programmi"
+#define DIALOG_GROUP_DESCRIPTION     "&Descrizione:"
+#define DIALOG_GROUP_FILE            "&File di gruppo:"
+
+#define DIALOG_PROGRAM_CAPTION       "Proprieta' del programma"
+#define DIALOG_PROGRAM_DESCRIPTION   DIALOG_GROUP_DESCRIPTION
+#define DIALOG_PROGRAM_COMMAND_LINE  "&Riga di comando:"
+#define DIALOG_PROGRAM_DIRECTORY     "Directory di &lavoro:"
+#define DIALOG_PROGRAM_HOT_KEY       "&Tasto di scelta rapida"
+#define DIALOG_PROGRAM_SYMBOL        "&Avvia ridotto a icona"
+#define DIALOG_PROGRAM_OTHER_SYMBOL  "&Cambia icona..."
+
+#define DIALOG_SYMBOL_CAPTION        "Cambia icona"
+#define DIALOG_SYMBOL_FILE           "&Nome del file:"
+#define DIALOG_SYMBOL_CURRENT        "I&cona corrente:"
+
+#define DIALOG_EXECUTE_CAPTION       "Execute Program"
+#define DIALOG_EXECUTE_COMMAND_LINE  DIALOG_PROGRAM_COMMAND_LINE
+#define DIALOG_EXECUTE_SYMBOL        DIALOG_PROGRAM_SYMBOL
+
+/* Strings */
+
+#define STRING_PROGRAM_MANAGER            "Program Manager"
+#define STRING_ERROR                      "ERRORE"
+#define STRING_WARNING                    "ATTENZONE"
+#define STRING_INFO                       "Informazione"
+#define STRING_DELETE                     "Elimina"
+#define STRING_DELETE_GROUP_s             "Eliminare il gruppo `%s'?"
+#define STRING_DELETE_PROGRAM_s           "Eliminare `%s'?"
+#define STRING_NOT_IMPLEMENTED            "Non ancora implementato"
+#define STRING_FILE_READ_ERROR_s          "Errore di lettura `%s'"
+#define STRING_FILE_WRITE_ERROR_s         "Errore di scrittura `%s'"
+
+#define STRING_GRPFILE_READ_ERROR_s       "\
+Il file di gruppo `%s' non puo' essere aperto.\n\
+Provare ad aprirlo in futuro?"
+
+#define STRING_OUT_OF_MEMORY              "Memoria esaurita"
+#define STRING_WINHELP_ERROR              "Guida non disponibile"
+#define STRING_UNKNOWN_FEATURE_s          "Funzione sconosciuta nel file %s"
+#define STRING_FILE_NOT_OVERWRITTEN_s     "Il file `%s' esiste. Sovrascriverlo."
+#define STRING_SAVE_GROUP_AS_s            "Salvare il gruppo come `%s' per non sovrascrivere i file originali"
+
+#define STRING_NO_HOT_KEY                 "Nessuno"
+
+#define STRING_ALL_FILES                  "Tutti i files (*.*)"
+#define STRING_PROGRAMS                   "Programmi"
+#define STRING_LIBRARIES_DLL              "Librerie (*.dll)"
+#define STRING_SYMBOL_FILES               "File icona"
+#define STRING_SYMBOLS_ICO                "Icone (*.ico)"
+
+#include "Xx.rc"
diff --git a/programs/progman/Ko.rc b/programs/progman/Ko.rc
index d6d92a4..4073b3a 100644
--- a/programs/progman/Ko.rc
+++ b/programs/progman/Ko.rc
@@ -5,7 +5,7 @@
  */
 
 #define LANGUAGE_ID                  Ko
-#define LANGUAGE_NUMBER              6
+#define LANGUAGE_NUMBER              A
 #define LANGUAGE_MENU_ITEM           "&Korean"
 
 /* Menu */
diff --git a/programs/progman/Makefile.in b/programs/progman/Makefile.in
index 16d1167..52e380e 100644
--- a/programs/progman/Makefile.in
+++ b/programs/progman/Makefile.in
@@ -8,7 +8,7 @@
 DEFS      = -I$(SRCDIR)
 RCFLAGS   = -w32
 
-LANGUAGES   = En De Fr Fi Ko
+LANGUAGES   = En De Fr Fi Ko Hu It
 LICENSELANG = En
 
 # Installation infos
diff --git a/programs/progman/main.c b/programs/progman/main.c
index abfc430..bc9b843 100644
--- a/programs/progman/main.c
+++ b/programs/progman/main.c
@@ -17,6 +17,9 @@
 void LIBWINE_Register_En();
 void LIBWINE_Register_Fi();
 void LIBWINE_Register_Fr();
+void LIBWINE_Register_It();
+void LIBWINE_Register_Ko();
+void LIBWINE_Register_Hu();
 #endif
 
 GLOBALS Globals;
@@ -46,6 +49,9 @@
   LIBWINE_Register_En();
   LIBWINE_Register_Fi();
   LIBWINE_Register_Fr();
+  LIBWINE_Register_It();
+  LIBWINE_Register_Ko();
+  LIBWINE_Register_Hu();
 #endif
 
 #ifndef WINELIB
diff --git a/programs/winhelp/ChangeLog b/programs/winhelp/ChangeLog
index f86e4c6..3845ae3 100644
--- a/programs/winhelp/ChangeLog
+++ b/programs/winhelp/ChangeLog
@@ -1,3 +1,8 @@
+Wed Feb 12 00:58:37 1997  Elker Cavina <elker@mail.asianet.it>
+
+	* [It.rc] (new)
+	Added Italian language support.
+
 Fri Jan 24 11:27:37 1997  Bang Jun-Young  <bangjy@nownuri.nowcom.co.kr>
 
 	* [Ko.rc] (new)
diff --git a/programs/winhelp/Hu.rc b/programs/winhelp/Hu.rc
new file mode 100644
index 0000000..1c98a7a
--- /dev/null
+++ b/programs/winhelp/Hu.rc
@@ -0,0 +1,48 @@
+/*
+ * Help Viewer
+ *
+ * Copyright 1996 Ulrich Schmid
+ */
+
+/* This file is not yet complete !! */
+
+#define LANGUAGE_ID                  Hu
+#define LANGUAGE_NUMBER              7
+
+/* Menu */
+
+#define MENU_FILE                    "&File"
+#define MENU_FILE_OPEN               "&Megnyitás..."
+#define MENU_FILE_PRINT              "&Nyomtatás"
+#define MENU_FILE_PRINTER_SETUP      "Nyomtató &beállítás..."
+#define MENU_FILE_EXIT               "&Kilépés"
+
+#define MENU_EDIT                    "&Szerkesztés"
+#define MENU_EDIT_COPY_DIALOG        "&Másolás..."
+#define MENU_EDIT_ANNOTATE           "&Annotate..."
+
+#define MENU_BOOKMARK                "&Könyvjelzõ"
+#define MENU_BOOKMARK_DEFINE         "&Definiálás..."
+
+#define MENU_HELP                    "&Segítség"
+#define MENU_HELP_ON_HELP            "Segítség &a segítségrõl"
+#define MENU_HELP_ON_TOP             "Mindig &legfelül"
+#define MENU_HELP_INFO               "&Információ..."
+#define MENU_HELP_ABOUT_WINE         "&A WINE-ról"
+
+/* Strings */
+
+#define STRING_WINE_HELP             "WINE segítség"
+#define STRING_ERROR                 "HIBA"
+#define STRING_WARNING               "FIGYELMEZTETÉS"
+#define STRING_INFO                  "Információ"
+#define STRING_NOT_IMPLEMENTED       "Nincs implementálva"
+#define STRING_HLPFILE_ERROR_s       "Hiba a `%s' file olvasásakor"
+#define STRING_CONTENTS              "&Tartalom"
+#define STRING_SEARCH                "&Keresés"
+#define STRING_BACK                  "&Vissza"
+#define STRING_HISTORY               "&History"
+#define STRING_ALL_FILES             "Minden file (*.*)"
+#define STRING_HELP_FILES_HLP        "Segítség file-ok (*.hlp)"
+
+#include "Xx.rc"
diff --git a/programs/winhelp/It.rc b/programs/winhelp/It.rc
new file mode 100644
index 0000000..1655d7a
--- /dev/null
+++ b/programs/winhelp/It.rc
@@ -0,0 +1,48 @@
+/*
+ * Help Viewer
+ *
+ * Copyright 1996 Ulrich Schmid
+ */
+
+/* This file is not yet complete !! */
+
+#define LANGUAGE_ID                  It
+#define LANGUAGE_NUMBER              9
+
+/* Menu */
+
+#define MENU_FILE                    "&File"
+#define MENU_FILE_OPEN               "&Apri..."
+#define MENU_FILE_PRINT              "s&tampa"
+#define MENU_FILE_PRINTER_SETUP      "&Setup stampante..."
+#define MENU_FILE_EXIT               "&Esci"
+
+#define MENU_EDIT                    "&Modifica"
+#define MENU_EDIT_COPY_DIALOG        "&Copia..."
+#define MENU_EDIT_ANNOTATE           "&Annota..."
+
+#define MENU_BOOKMARK                "&Segnalibro"
+#define MENU_BOOKMARK_DEFINE         "&Definisci..."
+
+#define MENU_HELP                    "&?"
+#define MENU_HELP_ON_HELP            "&Aiuto sulla guida"
+#define MENU_HELP_ON_TOP             "Sempre in primo &piano"
+#define MENU_HELP_INFO               "&Informazioni su..."
+#define MENU_HELP_ABOUT_WINE         "&Informazion su WINE"
+
+/* Strings */
+
+#define STRING_WINE_HELP             "Guida di WINE"
+#define STRING_ERROR                 "ERRORE"
+#define STRING_WARNING               "ATTENZIONE"
+#define STRING_INFO                  "Informazione"
+#define STRING_NOT_IMPLEMENTED       "Non ancora implementato"
+#define STRING_HLPFILE_ERROR_s       "Errore di lettura HelpFile `%s'"
+#define STRING_CONTENTS              "&Sommario"
+#define STRING_SEARCH                "&Ricerca"
+#define STRING_BACK                  "&Precedente"
+#define STRING_HISTORY               "&Indice"
+#define STRING_ALL_FILES             "Tutti i file (*.*)"
+#define STRING_HELP_FILES_HLP        "HelpFiles (*.hlp)"
+
+#include "Xx.rc"
diff --git a/programs/winhelp/Ko.rc b/programs/winhelp/Ko.rc
index 4bb23ae..f12b59a 100644
--- a/programs/winhelp/Ko.rc
+++ b/programs/winhelp/Ko.rc
@@ -7,7 +7,7 @@
 /* This file is not yet complete !! */
 
 #define LANGUAGE_ID                  Ko
-#define LANGUAGE_NUMBER              6
+#define LANGUAGE_NUMBER              A
 
 /* Menu */
 
diff --git a/programs/winhelp/Makefile.in b/programs/winhelp/Makefile.in
index 56ed29a..9a9edfd 100644
--- a/programs/winhelp/Makefile.in
+++ b/programs/winhelp/Makefile.in
@@ -7,7 +7,7 @@
 ALL_LIBS  = $(WINELIB) $(X_LIBS) $(XPM_LIB) $(XLIB) $(LDLIBS)
 RCFLAGS   = -w32
 
-LANGUAGES   = En De Fr Fi Ko
+LANGUAGES   = En De Fr Fi Ko Hu It
 
 # Installation infos
 
diff --git a/programs/winhelp/winhelp.c b/programs/winhelp/winhelp.c
index ec9436a..8c338e3 100644
--- a/programs/winhelp/winhelp.c
+++ b/programs/winhelp/winhelp.c
@@ -18,6 +18,9 @@
 VOID LIBWINE_Register_En(void);
 VOID LIBWINE_Register_Fi(void);
 VOID LIBWINE_Register_Fr(void);
+VOID LIBWINE_Register_It(void);
+VOID LIBWINE_Register_Ko(void);
+VOID LIBWINE_Register_Hu(void);
 
 static BOOL    WINHELP_RegisterWinClasses();
 static LRESULT WINHELP_MainWndProc(HWND, UINT, WPARAM, LPARAM);
@@ -56,6 +59,9 @@
   LIBWINE_Register_En();
   LIBWINE_Register_Fi();
   LIBWINE_Register_Fr();
+  LIBWINE_Register_It();
+  LIBWINE_Register_Ko();
+  LIBWINE_Register_Hu();
 #endif
 
   Globals.hInstance = hInstance;
diff --git a/resources/Makefile.in b/resources/Makefile.in
index 24251ec..e54a75f 100644
--- a/resources/Makefile.in
+++ b/resources/Makefile.in
@@ -15,6 +15,7 @@
 	sysres_Es.c \
 	sysres_Fi.c \
 	sysres_Fr.c \
+	sysres_Hu.c \
 	sysres_It.c \
 	sysres_Ko.c \
 	sysres_No.c
diff --git a/resources/sysres.c b/resources/sysres.c
index 8714ee1..0bc3514 100644
--- a/resources/sysres.c
+++ b/resources/sysres.c
@@ -20,6 +20,7 @@
 #include "sysres_Eo.h"
 #include "sysres_It.h"
 #include "sysres_Ko.h"
+#include "sysres_Hu.h"
 
 static const struct resource * const * SYSRES_Resources[] =
 {
@@ -33,7 +34,8 @@
     sysres_Cz_Table,  /* LANG_Cz */
     sysres_Eo_Table,  /* LANG_Eo */
     sysres_It_Table,  /* LANG_It */
-    sysres_Ko_Table   /* LANG_Ko */
+    sysres_Ko_Table,  /* LANG_Ko */
+    sysres_Hu_Table   /* LANG_Hu */
 };
 
 
diff --git a/resources/sysres_Hu.rc b/resources/sysres_Hu.rc
new file mode 100644
index 0000000..c6ae6c2
--- /dev/null
+++ b/resources/sysres_Hu.rc
@@ -0,0 +1,244 @@
+SYSMENU MENU LOADONCALL MOVEABLE DISCARDABLE
+BEGIN
+ MENUITEM "&Visszaállítás", 61728
+ MENUITEM "&Mozgatás", 61456
+ MENUITEM "Á&tméretezés", 61440
+ MENUITEM "&Kicsinyítés", 61472
+ MENUITEM "&Nagyítás", 61488
+ MENUITEM SEPARATOR
+ MENUITEM "&Bezárás\tAlt-F4", 61536
+ MENUITEM SEPARATOR
+ MENUITEM "Ta&szkváltás...\tCtrl-Esc", 61744
+ MENUITEM SEPARATOR
+ MENUITEM "A &WINE-ról ...", 61761
+END
+
+EDITMENU MENU LOADONCALL MOVEABLE DISCARDABLE
+BEGIN
+        POPUP ""
+        BEGIN
+                MENUITEM "&Visszavonás", EM_UNDO32
+                MENUITEM SEPARATOR
+                MENUITEM "&Kivágás", WM_CUT
+                MENUITEM "&Másolás", WM_COPY
+                MENUITEM "&Beillesztés", WM_PASTE
+                MENUITEM "&Törlés", WM_CLEAR
+                MENUITEM SEPARATOR
+                MENUITEM "M&inden kijelölése", EM_SETSEL32
+        END
+END
+
+MSGBOX DIALOG 100, 80, 216, 168
+STYLE DS_SYSMODAL | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+BEGIN
+        ICON "", 1088, 8, 20, 16, 16, WS_CHILD | WS_VISIBLE
+        LTEXT "", 100, 32, 4, 176, 48, WS_CHILD | WS_VISIBLE | WS_GROUP
+        PUSHBUTTON "&Ok", 1, 16, 56, 40, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
+        PUSHBUTTON "&Mégsem", 2, 64, 56, 40, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
+        PUSHBUTTON "&Abortálás", 3, 112, 56, 40, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
+        PUSHBUTTON "Újra &próbál", 4, 160, 56, 40, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
+        PUSHBUTTON "I&gnorálás", 5, 208, 56, 40, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
+        PUSHBUTTON "&Igen", 6, 256, 56, 40, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
+        PUSHBUTTON "&Nem", 7, 304, 56, 40, 14, WS_CHILD | WS_VISIBLE | WS_TABSTOP
+END
+
+SHELL_ABOUT_MSGBOX DIALOG LOADONCALL MOVEABLE DISCARDABLE 50, 44, 223, 270
+STYLE DS_LOCALEDIT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+CAPTION "A %s-rõl"
+FONT 10, "System"
+{
+ DEFPUSHBUTTON "OK", 1, 91, 250, 40, 14
+ CONTROL "", -1, "STATIC", SS_BLACKFRAME | WS_CHILD | WS_VISIBLE | WS_DISABLED, 4, 35, 215, 210
+ LTEXT "Text", 100, 11, 40, 200, 200, SS_NOPREFIX | WS_GROUP
+ ICON "", 1088, 195, 10, 18, 20
+}
+
+
+OPEN_FILE DIALOG 36, 24, 275, 134
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Megnyitás"
+FONT 8, "Helv"
+BEGIN
+        LTEXT "File &neve:", 1090, 6, 6, 76, 9
+        EDITTEXT 1152, 6, 16, 90, 12, ES_AUTOHSCROLL | ES_OEMCONVERT | WS_BORDER | WS_TABSTOP
+        LISTBOX 1120, 6, 32, 90, 68, LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_DISABLENOSCROLL | WS_TABSTOP
+        LTEXT "&Könyvtárak:", -1, 110, 6, 92, 9
+        CONTROL "", 1088, "STATIC", SS_NOPREFIX | WS_GROUP, 110, 18, 92, 9
+        LISTBOX 1121, 110, 32, 92, 68, LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_DISABLENOSCROLL | WS_TABSTOP
+        LTEXT "File &típusok:", 1089, 6, 104, 90, 9
+        CONTROL "", 1136, "COMBOBOX", CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_BORDER | WS_VSCROLL | WS_TABSTOP, 6, 114, 90, 36
+        LTEXT "&Meghajtók:", 1091, 110, 104, 92, 9
+        CONTROL "", 1137, "COMBOBOX", CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP, 110, 114, 92, 68
+        CONTROL "Megnyitás", 1, "BUTTON", BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP, 208, 6, 56, 14
+        CONTROL "Mégsem", 2, "BUTTON", WS_GROUP | WS_TABSTOP, 208, 24, 56, 14
+        CONTROL "&Segítség", 1038, "BUTTON", WS_GROUP | WS_TABSTOP, 208, 46, 56, 14
+        CONTROL "&Csak olvasható", 1040, "BUTTON", BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP, 208, 68, 63, 12
+END
+
+SAVE_FILE DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 275, 134
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Mentés új néven ..."
+FONT 8, "Helv"
+{
+ LTEXT "File &neve:", 1090, 6, 6, 76, 9
+ EDITTEXT 1152, 6, 16, 90, 12, ES_AUTOHSCROLL | ES_OEMCONVERT | WS_BORDER | WS_TABSTOP
+ LISTBOX 1120, 6, 32, 90, 68, LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_DISABLENOSCROLL | WS_TABSTOP
+ LTEXT "&Könyvtárak:", -1, 110, 6, 92, 9
+ LTEXT "", 1088, 110, 18, 92, 9, SS_NOPREFIX | WS_GROUP
+ LISTBOX 1121, 110, 32, 92, 68, LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_DISABLENOSCROLL | WS_TABSTOP
+ LTEXT "File &típusok:", 1089, 6, 104, 90, 9
+ COMBOBOX 1136, 6, 114, 90, 36, CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_BORDER | WS_VSCROLL | WS_TABSTOP
+ LTEXT "&Meghajtók:", 1091, 110, 104, 92, 9
+ COMBOBOX 1137, 110, 114, 92, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP
+ DEFPUSHBUTTON "Mentés új néven", 1, 208, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Mégsem", 2, 208, 24, 56, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Segítség", 1038, 208, 46, 56, 14, WS_GROUP | WS_TABSTOP
+ CHECKBOX "&Csak olvasható", 1040, 208, 68, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+}
+
+
+PRINT DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 134
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Nyomtatás"
+FONT 8, "Helv"
+{
+ LTEXT "Nyomtató:", 1088, 6, 6, 40, 9
+ LTEXT "", 1089, 60, 6, 150, 9
+ GROUPBOX "Nyomtatandó terület", 1072, 6, 30, 160, 65, BS_GROUPBOX
+ RADIOBUTTON "&Mind", 1056, 16, 45, 60, 12
+ RADIOBUTTON "&Kiválasztott", 1057, 16, 60, 60, 12
+ RADIOBUTTON "&Lapok", 1058, 16, 75, 60, 12
+ DEFPUSHBUTTON "Nyomtatás", 1, 206, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Mégsem", 2, 206, 24, 56, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Beállítás", 1024, 206, 46, 56, 14, WS_GROUP | WS_TABSTOP
+ LTEXT "-&tól:", 1090, 60, 80, 30, 9
+ LTEXT "-&ig:", 1091, 120, 80, 30, 9
+ LTEXT "Mi&nõség:", 1092, 6, 100, 76, 9
+ COMBOBOX 1136, 80, 100, 92, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP
+ CHECKBOX "&File-ba nyomtat", 1040, 20, 100, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+ CHECKBOX "Sûrû", 1041, 160, 100, 50, 12, BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP
+}
+
+
+PRINT_SETUP DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 264, 134
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Nyomtató beállítása"
+FONT 8, "Helv"
+{
+ GROUPBOX "Nyomtató", 1072, 6, 10, 180, 65, BS_GROUPBOX
+ RADIOBUTTON "&Alapértelmezett nyomtató", 1056, 16, 20, 80, 12
+ LTEXT "[nincs]", 1088, 35, 35, 120, 9
+ RADIOBUTTON "&Adott nyomtató", 1057, 16, 50, 80, 12
+ COMBOBOX 1136, 35, 65, 149, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP
+ DEFPUSHBUTTON "Ok", 1, 206, 6, 56, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Mégsem", 2, 206, 24, 56, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "&Beállítás", 1024, 206, 46, 56, 14, WS_GROUP | WS_TABSTOP
+ GROUPBOX "Oldalfekvés", 1073, 6, 85, 100, 50, BS_GROUPBOX
+ RADIOBUTTON "Á&lló", 1058, 50, 100, 40, 12
+ RADIOBUTTON "&Fekvõ", 1059, 50, 115, 40, 12
+ ICON "LANDSCAP", 1097, 10, 95, 32, 32
+ ICON "PORTRAIT", 1098, 10, 95, 32, 32
+ GROUPBOX "Papír", 1074, 120, 85, 180, 50, BS_GROUPBOX
+ LTEXT "&Mérete", 1089, 130, 95, 30, 9
+ LTEXT "Fo&rrása", 1090, 130, 110, 30, 9
+ COMBOBOX 1137, 155, 95, 92, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP
+ COMBOBOX 1138, 155, 110, 92, 68, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_AUTOHSCROLL | CBS_SORT | CBS_HASSTRINGS | WS_BORDER | WS_VSCROLL | WS_TABSTOP
+}
+
+
+CHOOSE_FONT DIALOG DISCARDABLE  13, 54, 264, 147
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Font"
+FONT 8, "Helv"
+{
+    LTEXT           "&Font:",1088 ,6,3,40,9
+    COMBOBOX        1136 ,6,13,94,54,  CBS_OWNERDRAWFIXED | CBS_HASSTRINGS | CBS_DISABLENOSCROLL |
+                    CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP | CBS_SIMPLE
+    LTEXT           "Font &stílus:",1089 ,108,3,44,9
+    COMBOBOX        1137,108,13,64,54, CBS_OWNERDRAWFIXED | CBS_HASSTRINGS | CBS_DISABLENOSCROLL |
+                    WS_VSCROLL | WS_TABSTOP | CBS_SIMPLE
+    LTEXT           "&Méret:",1090,179,3,30,9
+    COMBOBOX        1138,179,13,32,54, CBS_OWNERDRAWFIXED | CBS_HASSTRINGS | CBS_DISABLENOSCROLL |
+                    WS_VSCROLL | WS_TABSTOP | CBS_SIMPLE | CBS_SORT
+    DEFPUSHBUTTON   "OK",IDOK,218,6,40,14,WS_GROUP
+    PUSHBUTTON      "Mégsem",IDCANCEL,218,23,40,14,WS_GROUP
+    PUSHBUTTON      "&Alkalmaz", 1026,218,40,40,14,WS_GROUP
+    PUSHBUTTON      "&Segítség" , 1038,218,57,40,14,WS_GROUP
+    GROUPBOX        "Effektusok",1072,6,72,84,34,WS_GROUP
+    CHECKBOX        "Á&thúzott", 1040, 10,82,50,10, BS_AUTOCHECKBOX | WS_TABSTOP
+    CHECKBOX        "&Aláhúzott", 1041, 10,94,50,10, BS_AUTOCHECKBOX
+    LTEXT           "&Szín:", 1091 ,6,110,30,9
+    COMBOBOX        1139,6,120,84,100,CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_HASSTRINGS |
+                    CBS_AUTOHSCROLL |  WS_BORDER | WS_VSCROLL | WS_TABSTOP
+    GROUPBOX        "Minta",1073,98,72,160,49,WS_GROUP
+    CTEXT           "AaBbYyZzÁáÕõÉé",1093,104,81,149,37,SS_NOPREFIX | WS_VISIBLE
+}
+
+
+CHOOSE_COLOR DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 300, 200
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Szín"
+FONT 8, "Helv"
+{
+ LTEXT "&Alap színek:",   1088, 4,    4,  140, 10
+ LTEXT "&Egyedi színek:",  1089, 4,   106, 140, 10
+ LTEXT "Szín |  &Tömör",  1090, 150, 151,  48, 10
+ LTEXT   "&Vörös:", 726 /*1094*/,249,126,24,10
+ EDITTEXT 706, 275,124,18,12, WS_BORDER | WS_GROUP | WS_TABSTOP
+ LTEXT   "&Zöld:",727/*1095*/,249,140,24,10
+ EDITTEXT 707, 275,138,18,12, WS_BORDER | WS_GROUP | WS_TABSTOP
+ LTEXT   "&Kék:",728 /*1096*/,249,154,24,10
+ EDITTEXT 708, 275,152,18,12, WS_BORDER | WS_GROUP | WS_TABSTOP
+ LTEXT  "&Hue:" ,723 /*1091*/,202,126,22,10
+ EDITTEXT 703, 226,124,18,12, WS_BORDER | WS_GROUP | WS_TABSTOP
+ LTEXT  "&Sat:" ,724 /*1092*/,202,140,22,10
+ EDITTEXT 704, 226,138,18,12, WS_BORDER | WS_GROUP | WS_TABSTOP
+ LTEXT  "&Lum:" ,725 /*1093*/,202,154,22,10
+ EDITTEXT 705, 226,152,18,12, WS_BORDER | WS_GROUP | WS_TABSTOP
+ CONTROL "" ,720,"STATIC",SS_SIMPLE|WS_TABSTOP|WS_GROUP,4,14,140,86
+ CONTROL "" ,721,"STATIC",SS_SIMPLE|WS_TABSTOP|WS_GROUP,4,116,140,28
+ CONTROL "" ,710,"STATIC",WS_BORDER|SS_SIMPLE|WS_TABSTOP|WS_GROUP, 152,4,118,116
+ CONTROL "" ,702,"STATIC",SS_SIMPLE|WS_TABSTOP|WS_GROUP, 278,4,8,116
+ CONTROL "" ,709,"STATIC",SS_SIMPLE|WS_TABSTOP|WS_GROUP, 152,124,40,26
+ DEFPUSHBUTTON "Ok",  1,  4, 166, 44, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Mégsem", 2, 52, 166, 44, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "Segítség", 1038,100,166, 44, 14
+ PUSHBUTTON "&Egyedi színekhez adás",    712/*1024*/, 152, 166, 142, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON "E&gyedi szín definiálás >>", 719/*1025*/,   4, 150, 142, 14, WS_GROUP | WS_TABSTOP
+ PUSHBUTTON  "&t",713,300,200,4,14   /* just a dummy:  'i' is  like  &i  in "sol&id"  */
+}
+
+FIND_TEXT DIALOG 36, 24, 236, 62
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Keresés"
+FONT 8, "Helv"
+BEGIN
+        LTEXT "&Mit keressen:", -1, 4, 8, 48, 8
+        EDITTEXT 1152, 51, 7, 124, 12, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP
+        CONTROL "Teljes &szavak keresése", 1040, "BUTTON", BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP, 4, 26, 100, 12
+        CONTROL "Kis/&nagybetû különb.", 1041, "BUTTON", BS_AUTOCHECKBOX | WS_TABSTOP, 4, 42, 92, 12
+        GROUPBOX "Irány", 1072, 97, 26, 78, 28
+        CONTROL "&Vissza", 1056, "BUTTON", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP, 102, 38, 32, 12
+        CONTROL "&Elõre", 1057, "BUTTON", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 138, 38, 30, 12
+        CONTROL "&Következõ", 1, "BUTTON", WS_GROUP | WS_TABSTOP, 182, 5, 50, 14
+        CONTROL "Mégsem", 2, "BUTTON", WS_GROUP | WS_TABSTOP, 182, 23, 50, 14
+        PUSHBUTTON "&Segítség", 1038, 182, 45, 50, 14, WS_GROUP | WS_TABSTOP
+END
+
+REPLACE_TEXT DIALOG 36, 24, 230, 94
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Cserélés"
+FONT 8, "Helv"
+BEGIN
+        LTEXT "&Mit keressen:", -1, 4, 9, 48, 8
+        EDITTEXT 1152, 57, 7, 111, 12, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP
+        LTEXT "Mire &cseréljem:", -1, 4, 26, 53, 8
+        EDITTEXT 1153, 57, 24, 111, 12, ES_AUTOHSCROLL | WS_BORDER | WS_GROUP | WS_TABSTOP
+        CONTROL "Teljes &szavak keresése", 1040, "BUTTON", BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP, 5, 46, 104, 12
+        CONTROL "Kis/&nagybetû különb.", 1041, "BUTTON", BS_AUTOCHECKBOX | WS_TABSTOP, 5, 62, 99, 12
+        CONTROL "&Következõ", 1, "BUTTON", BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP, 174, 4, 53, 14
+        CONTROL "C&serél", 1024, "BUTTON", WS_GROUP | WS_TABSTOP, 174, 21, 53, 14
+        CONTROL "M&indent cserél", 1025, "BUTTON", WS_GROUP | WS_TABSTOP, 174, 38, 53, 14
+        CONTROL "Mégsem", 2, "BUTTON", WS_GROUP | WS_TABSTOP, 174, 55, 53, 14
+        CONTROL "&Segítség", 1038, "BUTTON", WS_GROUP | WS_TABSTOP, 174, 75, 53, 14
+END
diff --git a/scheduler/process.c b/scheduler/process.c
index a7e1991..c474d54 100644
--- a/scheduler/process.c
+++ b/scheduler/process.c
@@ -540,6 +540,93 @@
     return ret;
 }
 
+/***********************************************************************
+ *           ExpandEnvironmentVariablesA   (KERNEL32.103)
+ */
+DWORD ExpandEnvironmentStrings32A( LPCSTR src, LPSTR dst, DWORD len) {
+	LPCSTR s;
+        LPSTR d;
+	HANDLE32	heap = GetProcessHeap();
+	LPSTR		xdst = HeapAlloc(heap,0,10);
+	DWORD		cursize = 10;
+	DWORD		ret;
+
+	fprintf(stderr,"ExpandEnvironmentStrings32A(%s)\n",src);
+	s=src;
+	d=xdst;
+	memset(dst,'\0',len);
+#define CHECK_FREE(n)  {				\
+	DWORD	_needed = (n);				\
+							\
+	while (cursize-(d-xdst)<_needed) {		\
+		DWORD	ind = d-xdst;			\
+							\
+		cursize+=100;				\
+		xdst=(LPSTR)HeapReAlloc(heap,0,xdst,cursize);\
+		d = xdst+ind;				\
+	}						\
+}
+
+	while (*s) {
+		if (*s=='%') {
+			LPCSTR end;
+
+			end = s;do { end++; } while (*end && *end!='%');
+			if (*end=='%') {
+				LPSTR	x = HeapAlloc(heap,0,end-s+1);
+				char	buf[2];
+
+				lstrcpyn32A(x,s+1,end-s-1);
+				x[end-s-1]=0;
+
+				/* put expanded variable directly into 
+				 * destination string, so we don't have
+				 * to use temporary buffers.
+				 */
+				ret = GetEnvironmentVariable32A(x,buf,2);
+				CHECK_FREE(ret+2);
+				ret = GetEnvironmentVariable32A(x,d,d-xdst);
+				if (ret) {
+					d+=strlen(d);
+				} else {
+					CHECK_FREE(strlen(x)+2);
+					*d++='%';
+					lstrcpy32A(d,x);
+					d+=strlen(x);
+					*d++='%';
+				}
+				HeapFree(heap,0,x);
+			} else
+				*d=*s;
+
+			s++;d++;
+		} else {
+			CHECK_FREE(1);
+			*d++=*s++;
+		}
+	}
+	*d	= '\0';
+	ret	= lstrlen32A(xdst)+1;
+	if (d-xdst<len)
+		lstrcpy32A(dst,xdst);
+	HeapFree(heap,0,xdst);
+	return ret;
+}
+
+/***********************************************************************
+ *           ExpandEnvironmentVariablesA   (KERNEL32.104)
+ */
+DWORD ExpandEnvironmentStrings32W( LPCWSTR src, LPWSTR dst, DWORD len) {
+	HANDLE32	heap = GetProcessHeap();
+	LPSTR		srcA = HEAP_strdupWtoA(heap,0,src);
+	LPSTR		dstA = HeapAlloc(heap,0,len);
+	DWORD		ret = ExpandEnvironmentStrings32A(srcA,dstA,len);
+
+	lstrcpyAtoW(dst,dstA);
+	HeapFree(heap,0,dstA);
+	HeapFree(heap,0,srcA);
+	return ret;
+}
 
 /***********************************************************************
  *           GetProcessHeap    (KERNEL32.259)
diff --git a/win32/Makefile.in b/win32/Makefile.in
index e09e8ea..dbdae2a 100644
--- a/win32/Makefile.in
+++ b/win32/Makefile.in
@@ -19,6 +19,7 @@
 	memory.c \
 	newfns.c \
 	process.c \
+	security.c \
 	string32.c \
 	struct32.c \
 	thread.c \
diff --git a/win32/memory.c b/win32/memory.c
index 9a22615..8cb1ae5 100644
--- a/win32/memory.c
+++ b/win32/memory.c
@@ -9,6 +9,7 @@
 #include <string.h>
 #include <sys/time.h>
 #include <unistd.h>
+#include <sys/types.h>
 #include <sys/mman.h>
 #include <string.h>
 #include <stdlib.h>
@@ -283,6 +284,15 @@
 	return TRUE;
 }
 
+/***********************************************************************
+ *           VirtualProtect               (KERNEL32.552)
+ */
+BOOL32 VirtualProtect(LPVOID lpAddress,DWORD dwSize,DWORD flNewProtect,LPDWORD lpflOldProtect) {
+	/* FIXME: do protection ... see mprotect(). */
+	return TRUE;
+}
+
+
 int TranslateProtectionFlags(DWORD protection_flags)
 {
     int prot;
diff --git a/win32/security.c b/win32/security.c
new file mode 100644
index 0000000..f8e9afa
--- /dev/null
+++ b/win32/security.c
@@ -0,0 +1,182 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "windows.h"
+#include "ntdll.h"
+#include "xmalloc.h"
+#include "stddebug.h"
+#include "debug.h"
+
+BOOL32 IsValidSid (LPSID pSid);
+BOOL32 EqualSid (LPSID pSid1, LPSID pSid2);
+BOOL32 EqualPrefixSid (LPSID pSid1, LPSID pSid2);
+DWORD GetSidLengthRequired (BYTE nSubAuthorityCount);
+BOOL32 AllocateAndInitializeSid (LPSID_IDENTIFIER_AUTHORITY pIdentifierAuthority, BYTE nSubAuthorityCount, DWORD nSubAuthority0, DWORD nSubAuthority1, DWORD nSubAuthority2, DWORD nSubAuthority3,    DWORD nSubAuthority4, DWORD nSubAuthority5, DWORD nSubAuthority6, DWORD nSubAuthority7, LPSID *pSid);
+VOID *FreeSid(LPSID pSid);
+BOOL32 InitializeSid (LPSID pSid, LPSID_IDENTIFIER_AUTHORITY pIdentifierAuthority, BYTE nSubAuthorityCount);
+LPSID_IDENTIFIER_AUTHORITY GetSidIdentifierAuthority (LPSID pSid);
+DWORD *GetSidSubAuthority (LPSID pSid, DWORD nSubAuthority);
+BYTE *GetSidSubAuthorityCount (LPSID pSid);
+DWORD GetLengthSid (LPSID pSid);
+BOOL32 CopySid (DWORD nDestinationSidLength, LPSID pDestinationSid, LPSID pSourceSid);
+
+/***********************************************************************
+ *           IsValidSid  (ADVAPI.80)
+ */
+BOOL32 IsValidSid (LPSID pSid) {
+    if (!pSid || pSid->Revision != SID_REVISION)
+        return FALSE;
+
+    return TRUE;
+}
+
+/***********************************************************************
+ *           EqualSid  (ADVAPI.40)
+ */
+BOOL32 EqualSid (LPSID pSid1, LPSID pSid2) {
+    if (!IsValidSid(pSid1) || !IsValidSid(pSid2))
+        return FALSE;
+
+    if (*GetSidSubAuthorityCount(pSid1) != *GetSidSubAuthorityCount(pSid2))
+        return FALSE;
+
+    if (memcmp(pSid1, pSid2, GetLengthSid(pSid1)) != 0)
+        return FALSE;
+
+    return TRUE;
+}
+
+/***********************************************************************
+ *           EqualPrefixSid  (ADVAPI.39)
+ */
+BOOL32 EqualPrefixSid (LPSID pSid1, LPSID pSid2) {
+    if (!IsValidSid(pSid1) || !IsValidSid(pSid2))
+        return FALSE;
+
+    if (*GetSidSubAuthorityCount(pSid1) != *GetSidSubAuthorityCount(pSid2))
+        return FALSE;
+
+    if (memcmp(pSid1, pSid2, GetSidLengthRequired(pSid1->SubAuthorityCount - 1))
+ != 0)
+        return FALSE;
+
+    return TRUE;
+}
+
+/***********************************************************************
+ *           GetSidLengthRequired  (ADVAPI.63)
+ */
+DWORD GetSidLengthRequired (BYTE nSubAuthorityCount) {
+    return sizeof (SID) + (nSubAuthorityCount - 1 * sizeof (DWORD));
+}
+
+/***********************************************************************
+ *           AllocateAndInitializeSid  (ADVAPI.11)
+ */
+BOOL32 AllocateAndInitializeSid (LPSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
+    BYTE nSubAuthorityCount,
+    DWORD nSubAuthority0, DWORD nSubAuthority1,
+    DWORD nSubAuthority2, DWORD nSubAuthority3,
+    DWORD nSubAuthority4, DWORD nSubAuthority5,
+    DWORD nSubAuthority6, DWORD nSubAuthority7,
+    LPSID *pSid) {
+
+    *pSid = xmalloc(GetSidLengthRequired(nSubAuthorityCount));
+    (*pSid)->Revision = SID_REVISION;
+    if (pIdentifierAuthority)
+        memcpy(&(*pSid)->IdentifierAuthority, pIdentifierAuthority,
+               sizeof (SID_IDENTIFIER_AUTHORITY));
+    *GetSidSubAuthorityCount(*pSid) = nSubAuthorityCount;
+
+    if (nSubAuthorityCount > 0)
+        *GetSidSubAuthority(*pSid, 0) = nSubAuthority0;
+    if (nSubAuthorityCount > 1)
+        *GetSidSubAuthority(*pSid, 1) = nSubAuthority1;
+    if (nSubAuthorityCount > 2)
+        *GetSidSubAuthority(*pSid, 2) = nSubAuthority2;
+    if (nSubAuthorityCount > 3)
+        *GetSidSubAuthority(*pSid, 3) = nSubAuthority3;
+    if (nSubAuthorityCount > 4)
+        *GetSidSubAuthority(*pSid, 4) = nSubAuthority4;
+    if (nSubAuthorityCount > 5)
+        *GetSidSubAuthority(*pSid, 5) = nSubAuthority5;
+    if (nSubAuthorityCount > 6)
+        *GetSidSubAuthority(*pSid, 6) = nSubAuthority6;
+    if (nSubAuthorityCount > 7)
+        *GetSidSubAuthority(*pSid, 7) = nSubAuthority7;
+
+    return TRUE;
+}
+
+/***********************************************************************
+ *           FreeSid  (ADVAPI.42)
+ */
+VOID *FreeSid(LPSID pSid) {
+    free(pSid);
+    return NULL;
+}
+
+/***********************************************************************
+ *           InitializeSid  (ADVAPI.74)
+ */
+BOOL32 InitializeSid (LPSID pSid, LPSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
+                    BYTE nSubAuthorityCount) {
+    int i;
+
+    pSid->Revision = SID_REVISION;
+    if (pIdentifierAuthority)
+        memcpy(&pSid->IdentifierAuthority, pIdentifierAuthority,
+               sizeof (SID_IDENTIFIER_AUTHORITY));
+    *GetSidSubAuthorityCount(pSid) = nSubAuthorityCount;
+
+    for (i = 0; i < nSubAuthorityCount; i++)
+        *GetSidSubAuthority(pSid, i) = 0;
+
+    return TRUE;
+}
+
+/***********************************************************************
+ *           GetSidIdentifierAuthority  (ADVAPI.62)
+ */
+LPSID_IDENTIFIER_AUTHORITY GetSidIdentifierAuthority (LPSID pSid) {
+    return &pSid->IdentifierAuthority;
+}
+
+/***********************************************************************
+ *           GetSidSubAuthority  (ADVAPI.64)
+ */
+DWORD *GetSidSubAuthority (LPSID pSid, DWORD nSubAuthority) {
+    return &pSid->SubAuthority[nSubAuthority];
+}
+
+/***********************************************************************
+ *           GetSidSubAuthorityCount  (ADVAPI.65)
+ */
+BYTE *GetSidSubAuthorityCount (LPSID pSid) {
+    return &pSid->SubAuthorityCount;
+}
+
+/***********************************************************************
+ *           GetLengthSid  (ADVAPI.48)
+ */
+DWORD GetLengthSid (LPSID pSid) {
+    return GetSidLengthRequired(*GetSidSubAuthorityCount(pSid));
+}
+
+/***********************************************************************
+ *           CopySid  (ADVAPI.24)
+ */
+BOOL32 CopySid (DWORD nDestinationSidLength, LPSID pDestinationSid,
+              LPSID pSourceSid) {
+
+    if (!IsValidSid(pSourceSid))
+        return FALSE;
+
+    if (nDestinationSidLength < GetLengthSid(pSourceSid))
+        return FALSE;
+
+    memcpy(pDestinationSid, pSourceSid, GetLengthSid(pSourceSid));
+
+    return TRUE;
+}
diff --git a/win32/struct32.c b/win32/struct32.c
index 7795c9e..f0631e0 100644
--- a/win32/struct32.c
+++ b/win32/struct32.c
@@ -13,7 +13,7 @@
 
 void STRUCT32_MSG16to32(const MSG16 *msg16,MSG32 *msg32)
 {
-	msg32->hwnd=(DWORD)msg16->hwnd;
+	msg32->hwnd=(HWND32)msg16->hwnd;
 	msg32->message=msg16->message;
 	msg32->wParam=msg16->wParam;
 	msg32->lParam=msg16->lParam;
@@ -24,7 +24,7 @@
 
 void STRUCT32_MSG32to16(const MSG32 *msg32,MSG16 *msg16)
 {
-	msg16->hwnd=(HWND)msg32->hwnd;
+	msg16->hwnd=(HWND16)msg32->hwnd;
 	msg16->message=msg32->message;
 	msg16->wParam=msg32->wParam;
 	msg16->lParam=msg32->lParam;
diff --git a/win32/user32.c b/win32/user32.c
index 4d64343..b7dff9c 100644
--- a/win32/user32.c
+++ b/win32/user32.c
@@ -22,61 +22,18 @@
 /***********************************************************************
  *          GetMessageA          (USER32.269)
  */
-BOOL USER32_GetMessageA(MSG32* lpmsg,DWORD hwnd,DWORD min,DWORD max)
+BOOL USER32_GetMessageA(MSG32* lpmsg,HWND32 hwnd,DWORD min,DWORD max)
 {
 	BOOL ret;
 	MSG16 *msg = SEGPTR_NEW(MSG16);
         if (!msg) return 0;
-        ret=GetMessage(SEGPTR_GET(msg),(HWND)hwnd,min,max);
+        ret=GetMessage(SEGPTR_GET(msg),(HWND16)hwnd,min,max);
 	STRUCT32_MSG16to32(msg,lpmsg);
         SEGPTR_FREE(msg);
 	return ret;
 }
 
 /***********************************************************************
- *          IsDialogMessageA     (USER32.341)
- */
-BOOL IsDialogMessage32A(DWORD hwnd, MSG32* lpmsg)
-{
-	MSG16 msg;
-	STRUCT32_MSG32to16(lpmsg, &msg);
-	return IsDialogMessage(hwnd, &msg);
-}
-
-/***********************************************************************
- *          IsDialogMessage32W     (USER32.342)
- */
-BOOL IsDialogMessage32W(DWORD hwnd, MSG32* lpmsg)
-{
-	MSG16 msg;
-	STRUCT32_MSG32to16(lpmsg, &msg);
-	return IsDialogMessage(hwnd, &msg);
-}
-
-/***********************************************************************
- *         DispatchMessageA       (USER32.140)
- */
-LONG USER32_DispatchMessageA(MSG32* lpmsg)
-{
-	MSG16 msg;
-	LONG ret;
-	STRUCT32_MSG32to16(lpmsg,&msg);
-	ret=DispatchMessage(&msg);
-	STRUCT32_MSG16to32(&msg,lpmsg);
-	return ret;
-}
-
-/***********************************************************************
- *         TranslateMessage       (USER32.555)
- */
-BOOL USER32_TranslateMessage(MSG32* lpmsg)
-{
-	MSG16 msg;
-	STRUCT32_MSG32to16(lpmsg,&msg);
-	return TranslateMessage(&msg);
-}
-
-/***********************************************************************
  *         PeekMessageA
  */
 BOOL32 PeekMessage32A( LPMSG32 lpmsg, HWND32 hwnd,
diff --git a/windows/caret.c b/windows/caret.c
index 2419d96..0fdc6ef 100644
--- a/windows/caret.c
+++ b/windows/caret.c
@@ -145,10 +145,11 @@
     }
     else
     {
-        Caret.width = width ? width : GetSystemMetrics(SM_CXBORDER);
-        Caret.height = height ? height : GetSystemMetrics(SM_CYBORDER);
-        Caret.hBrush = CreateSolidBrush32(bitmap ? GetSysColor(COLOR_GRAYTEXT):
-                                          GetSysColor(COLOR_WINDOW) );
+        Caret.width = width ? width : GetSystemMetrics32(SM_CXBORDER);
+        Caret.height = height ? height : GetSystemMetrics32(SM_CYBORDER);
+        Caret.hBrush = CreateSolidBrush32(bitmap ?
+                                          GetSysColor32(COLOR_GRAYTEXT) :
+                                          GetSysColor32(COLOR_WINDOW) );
     }
 
     Caret.hwnd = hwnd;
@@ -204,9 +205,18 @@
 
 
 /*****************************************************************
- *           HideCaret   (USER.166) (USER32.316)
+ *           HideCaret16   (USER.166)
  */
-BOOL16 HideCaret( HWND32 hwnd )
+BOOL16 HideCaret16( HWND16 hwnd )
+{
+    return HideCaret32( hwnd );
+}
+
+
+/*****************************************************************
+ *           HideCaret32   (USER32.316)
+ */
+BOOL32 HideCaret32( HWND32 hwnd )
 {
     if (!Caret.hwnd) return FALSE;
     if (hwnd && (Caret.hwnd != hwnd)) return FALSE;
@@ -222,9 +232,18 @@
 
 
 /*****************************************************************
- *           ShowCaret   (USER.167) (USER32.528)
+ *           ShowCaret16   (USER.167)
  */
-BOOL16 ShowCaret( HWND32 hwnd )
+BOOL16 ShowCaret16( HWND16 hwnd )
+{
+    return ShowCaret32( hwnd );
+}
+
+
+/*****************************************************************
+ *           ShowCaret32   (USER32.528)
+ */
+BOOL32 ShowCaret32( HWND32 hwnd )
 {
     if (!Caret.hwnd) return FALSE;
     if (hwnd && (Caret.hwnd != hwnd)) return FALSE;
diff --git a/windows/defdlg.c b/windows/defdlg.c
index 0ec5c44..d5d2f33 100644
--- a/windows/defdlg.c
+++ b/windows/defdlg.c
@@ -196,7 +196,7 @@
 	    return dlgInfo->hUserFont;
 
         case WM_CLOSE:
-            EndDialog( hwnd, TRUE );
+            EndDialog32( hwnd, TRUE );
             DestroyWindow32( hwnd );
             return 0;
     }
diff --git a/windows/defwnd.c b/windows/defwnd.c
index d408432..5581bf7 100644
--- a/windows/defwnd.c
+++ b/windows/defwnd.c
@@ -93,6 +93,25 @@
     case WM_NCLBUTTONDBLCLK:
 	return NC_HandleNCLButtonDblClk( wndPtr, wParam, lParam );
 
+    case WM_RBUTTONDOWN:
+    case WM_NCRBUTTONDOWN:
+        if( wndPtr->flags & WIN_ISWIN32 ) 
+        {
+	    ClientToScreen16(wndPtr->hwndSelf, (LPPOINT16)&lParam);
+            SendMessage32A( wndPtr->hwndSelf, WM_CONTEXTMENU,
+			    wndPtr->hwndSelf, lParam);
+        }
+        break;
+
+    case WM_CONTEXTMENU:
+	if( wndPtr->dwStyle & WS_CHILD )
+	    SendMessage32A( wndPtr->parent->hwndSelf, msg, wParam, lParam );
+
+     /* else 
+      *     FIXME: Track system popup if click was in the caption area. */
+
+	break;
+
     case WM_NCACTIVATE:
 	return NC_HandleNCActivate( wndPtr, wParam );
 
@@ -119,7 +138,7 @@
 			SYSMETRICS_CYICON)/2;
 		dprintf_win(stddeb,"Painting class icon: vis rect=(%i,%i - %i,%i)\n",
 		ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom );
-	        DrawIcon( hdc, x, y, wndPtr->class->hIcon );
+	        DrawIcon32( hdc, x, y, wndPtr->class->hIcon );
 	      }
 	      EndPaint16( wndPtr->hwndSelf, &ps );
 	    }
@@ -172,15 +191,12 @@
                                (HDC16)wParam, sysColorObjects.hbrushActiveCaption );
 		   return 1;
 		 }
-
-		 /* FIXME: should draw parent' background somehow
-			     (e.g for textured desktop) ? */
 	    }
 
 	    if (wndPtr->class->hbrBackground <= (HBRUSH16)(COLOR_MAX+1))
             {
                 HBRUSH32 hbrush = CreateSolidBrush32( 
-			 GetSysColor(((DWORD)wndPtr->class->hbrBackground)-1));
+                       GetSysColor32(((DWORD)wndPtr->class->hbrBackground)-1));
                  FillWindow( GetParent16(wndPtr->hwndSelf), wndPtr->hwndSelf,
                              (HDC16)wParam, hbrush);
                  DeleteObject32( hbrush );
@@ -199,8 +215,8 @@
     case WM_CTLCOLORBTN:
     case WM_CTLCOLORDLG:
     case WM_CTLCOLORSTATIC:
-        SetBkColor( (HDC32)wParam, GetSysColor(COLOR_WINDOW) );
-        SetTextColor( (HDC32)wParam, GetSysColor(COLOR_WINDOWTEXT) );
+        SetBkColor( (HDC32)wParam, GetSysColor32(COLOR_WINDOW) );
+        SetTextColor( (HDC32)wParam, GetSysColor32(COLOR_WINDOWTEXT) );
         return (LRESULT)sysColorObjects.hbrushWindow;
 
     case WM_CTLCOLORSCROLLBAR:
@@ -220,8 +236,8 @@
 	    }
 	    else
 	    {
-		SetBkColor( (HDC32)wParam, GetSysColor(COLOR_WINDOW) );
-		SetTextColor( (HDC32)wParam, GetSysColor(COLOR_WINDOWTEXT) );
+		SetBkColor( (HDC32)wParam, GetSysColor32(COLOR_WINDOW) );
+		SetTextColor( (HDC32)wParam, GetSysColor32(COLOR_WINDOWTEXT) );
 		return (LRESULT)sysColorObjects.hbrushWindow;
 	    }
 	}
@@ -293,7 +309,7 @@
                                (WPARAM16)SC_KEYMENU, (LPARAM)(DWORD)wParam );
         } 
 	else /* check for Ctrl-Esc */
-            if (wParam != VK_ESCAPE) MessageBeep(0);
+            if (wParam != VK_ESCAPE) MessageBeep32(0);
 	break;
 
     case WM_SHOWWINDOW:
diff --git a/windows/dialog.c b/windows/dialog.c
index 7be07fe..17d1680 100644
--- a/windows/dialog.c
+++ b/windows/dialog.c
@@ -745,10 +745,10 @@
     while (MSG_InternalGetMessage(&msg, hwnd, owner, MSGF_DIALOGBOX, PM_REMOVE,
                                   !(wndPtr->dwStyle & DS_NOIDLEMSG) ))
     {
-	if (!IsDialogMessage( hwnd, &msg))
+	if (!IsDialogMessage16( hwnd, &msg))
 	{
-	    TranslateMessage( &msg );
-	    DispatchMessage( &msg );
+	    TranslateMessage16( &msg );
+	    DispatchMessage16( &msg );
 	}
 	if (dlgInfo->fEnd) break;
     }
@@ -859,9 +859,18 @@
 
 
 /***********************************************************************
- *           EndDialog   (USER.88) (USER32.173)
+ *           EndDialog16   (USER32.173)
  */
-BOOL16 EndDialog( HWND32 hwnd, INT32 retval )
+BOOL16 EndDialog16( HWND16 hwnd, INT16 retval )
+{
+    return EndDialog32( hwnd, retval );
+}
+
+
+/***********************************************************************
+ *           EndDialog32   (USER32.173)
+ */
+BOOL32 EndDialog32( HWND32 hwnd, INT32 retval )
 {
     WND * wndPtr = WIN_FindWndPtr( hwnd );
     DIALOGINFO * dlgInfo = (DIALOGINFO *)wndPtr->wExtra;
@@ -873,40 +882,41 @@
 
 
 /***********************************************************************
- *           IsDialogMessage   (USER.90)
+ *           DIALOG_IsDialogMessage
  */
-BOOL16 IsDialogMessage( HWND16 hwndDlg, LPMSG16 msg )
+static BOOL32 DIALOG_IsDialogMessage( HWND32 hwnd, HWND32 hwndDlg,
+                                      UINT32 message, WPARAM32 wParam,
+                                      LPARAM lParam, BOOL32 *translate,
+                                      BOOL32 *dispatch )
 {
-    WND * wndPtr;
-    int dlgCode;
+    INT32 dlgCode;
 
-    if (!(wndPtr = WIN_FindWndPtr( hwndDlg ))) return FALSE;
-    if ((hwndDlg != msg->hwnd) && !IsChild16( hwndDlg, msg->hwnd )) return FALSE;
+    *translate = *dispatch = FALSE;
 
       /* Only the key messages get special processing */
-    if ((msg->message != WM_KEYDOWN) &&
-        (msg->message != WM_SYSCHAR) &&
-	(msg->message != WM_CHAR))
+    if ((message != WM_KEYDOWN) &&
+        (message != WM_SYSCHAR) &&
+	(message != WM_CHAR))
         return FALSE;
 
-    dlgCode = SendMessage16( msg->hwnd, WM_GETDLGCODE, 0, 0 );
+    dlgCode = SendMessage32A( hwnd, WM_GETDLGCODE, 0, 0 );
     if (dlgCode & DLGC_WANTMESSAGE)
     {
-        DispatchMessage( msg );
+        *dispatch = TRUE;
         return TRUE;
     }
 
-    switch(msg->message)
+    switch(message)
     {
     case WM_KEYDOWN:
         if (dlgCode & DLGC_WANTALLKEYS) break;
-        switch(msg->wParam)
+        switch(wParam)
         {
         case VK_TAB:
             if (!(dlgCode & DLGC_WANTTAB))
             {
-                SendMessage16( hwndDlg, WM_NEXTDLGCTL,
-                             (GetKeyState32(VK_SHIFT) & 0x8000), 0 );
+                SendMessage32A( hwndDlg, WM_NEXTDLGCTL,
+                                (GetKeyState32(VK_SHIFT) & 0x8000), 0 );
                 return TRUE;
             }
             break;
@@ -949,8 +959,9 @@
             }
             break;
 
-	default: 
-	    TranslateMessage( msg );
+	default:
+            *translate = TRUE;
+            break;
         }
         break;  /* case WM_KEYDOWN */
 
@@ -964,13 +975,70 @@
         break;
     }
 
-      /* If we get here, the message has not been treated specially */
-      /* and can be sent to its destination window. */
-    DispatchMessage( msg );
+    /* If we get here, the message has not been treated specially */
+    /* and can be sent to its destination window. */
+    *dispatch = TRUE;
     return TRUE;
 }
 
 
+/***********************************************************************
+ *           IsDialogMessage16   (USER.90)
+ */
+BOOL16 IsDialogMessage16( HWND16 hwndDlg, LPMSG16 msg )
+{
+    BOOL32 ret, translate, dispatch;
+
+    if ((hwndDlg != msg->hwnd) && !IsChild16( hwndDlg, msg->hwnd ))
+        return FALSE;
+
+    ret = DIALOG_IsDialogMessage( msg->hwnd, hwndDlg, msg->message,
+                                  msg->wParam, msg->lParam,
+                                  &translate, &dispatch );
+    if (translate) TranslateMessage16( msg );
+    if (dispatch) DispatchMessage16( msg );
+    return ret;
+}
+
+
+/***********************************************************************
+ *           IsDialogMessage32A   (USER32.341)
+ */
+BOOL32 IsDialogMessage32A( HWND32 hwndDlg, LPMSG32 msg )
+{
+    BOOL32 ret, translate, dispatch;
+
+    if ((hwndDlg != msg->hwnd) && !IsChild32( hwndDlg, msg->hwnd ))
+        return FALSE;
+
+    ret = DIALOG_IsDialogMessage( msg->hwnd, hwndDlg, msg->message,
+                                  msg->wParam, msg->lParam,
+                                  &translate, &dispatch );
+    if (translate) TranslateMessage32( msg );
+    if (dispatch) DispatchMessage32A( msg );
+    return ret;
+}
+
+
+/***********************************************************************
+ *           IsDialogMessage32W   (USER32.342)
+ */
+BOOL32 IsDialogMessage32W( HWND32 hwndDlg, LPMSG32 msg )
+{
+    BOOL32 ret, translate, dispatch;
+
+    if ((hwndDlg != msg->hwnd) && !IsChild32( hwndDlg, msg->hwnd ))
+        return FALSE;
+
+    ret = DIALOG_IsDialogMessage( msg->hwnd, hwndDlg, msg->message,
+                                  msg->wParam, msg->lParam,
+                                  &translate, &dispatch );
+    if (translate) TranslateMessage32( msg );
+    if (dispatch) DispatchMessage32W( msg );
+    return ret;
+}
+
+
 /****************************************************************
  *         GetDlgCtrlID16   (USER.277)
  */
diff --git a/windows/event.c b/windows/event.c
index d8e6dfb..4800aed 100644
--- a/windows/event.c
+++ b/windows/event.c
@@ -61,6 +61,7 @@
 static INT16  captureHT = HTCLIENT;
 static HWND32 captureWnd = 0;
 static BOOL32 InputEnabled = TRUE;
+static BOOL32 SwappedButtons = FALSE;
 
 static Atom wmProtocols = None;
 static Atom wmDeleteWindow = None;
@@ -84,23 +85,23 @@
 static void EVENT_ButtonPress( XButtonEvent *event );
 static void EVENT_ButtonRelease( XButtonEvent *event );
 static void EVENT_MotionNotify( XMotionEvent *event );
-static void EVENT_FocusIn( HWND hwnd, XFocusChangeEvent *event );
-static void EVENT_FocusOut( HWND hwnd, XFocusChangeEvent *event );
+static void EVENT_FocusIn( HWND32 hwnd, XFocusChangeEvent *event );
+static void EVENT_FocusOut( HWND32 hwnd, XFocusChangeEvent *event );
 static void EVENT_Expose( WND *pWnd, XExposeEvent *event );
 static void EVENT_GraphicsExpose( WND *pWnd, XGraphicsExposeEvent *event );
-static void EVENT_ConfigureNotify( HWND hwnd, XConfigureEvent *event );
+static void EVENT_ConfigureNotify( HWND32 hwnd, XConfigureEvent *event );
 static void EVENT_SelectionRequest( WND *pWnd, XSelectionRequestEvent *event);
 static void EVENT_SelectionNotify( XSelectionEvent *event);
 static void EVENT_SelectionClear( WND *pWnd, XSelectionClearEvent *event);
 static void EVENT_ClientMessage( WND *pWnd, XClientMessageEvent *event );
-static void EVENT_MapNotify( HWND hwnd, XMapEvent *event );
+static void EVENT_MapNotify( HWND32 hwnd, XMapEvent *event );
 
 /* Usable only with OLVWM - compile option perhaps?
 static void EVENT_EnterNotify( WND *pWnd, XCrossingEvent *event );
 */
 
 extern void FOCUS_SetXFocus( HWND32 );
-extern BOOL16 DRAG_QueryUpdate( HWND, SEGPTR, BOOL32 );
+extern BOOL16 DRAG_QueryUpdate( HWND16, SEGPTR, BOOL32 );
 
 /***********************************************************************
  *           EVENT_ProcessEvent
@@ -333,7 +334,8 @@
                             (char **)&pWnd ) || (event.type == NoExpose))
               continue;
 
-	  /* check for the "safe" hardware events */
+	  /* Check only for those events which can be processed
+	   * internally. */
 
 	  if( event.type == MotionNotify ||
 	      event.type == ButtonPress || event.type == ButtonRelease ||
@@ -491,6 +493,7 @@
     int buttonNum = event->button - 1;
 
     if (buttonNum >= NB_BUTTONS) return;
+    if (SwappedButtons) buttonNum = NB_BUTTONS - 1 - buttonNum;
     MouseButtonsStates[buttonNum] = 0x8000;
     AsyncMouseButtonsStates[buttonNum] = 0x8000;
     hardware_event( messages[buttonNum],
@@ -510,6 +513,7 @@
     int buttonNum = event->button - 1;
 
     if (buttonNum >= NB_BUTTONS) return;    
+    if (SwappedButtons) buttonNum = NB_BUTTONS - 1 - buttonNum;
     MouseButtonsStates[buttonNum] = FALSE;
     hardware_event( messages[buttonNum],
 		    EVENT_XStateToKeyState( event->state ), 0L,
@@ -521,7 +525,7 @@
 /**********************************************************************
  *              EVENT_FocusIn
  */
-static void EVENT_FocusIn (HWND hwnd, XFocusChangeEvent *event )
+static void EVENT_FocusIn( HWND32 hwnd, XFocusChangeEvent *event )
 {
     if (event->detail == NotifyPointer) return;
     if (hwnd != GetActiveWindow32()) WINPOS_ChangeActiveWindow( hwnd, FALSE );
@@ -535,7 +539,7 @@
  *
  * Note: only top-level override-redirect windows get FocusOut events.
  */
-static void EVENT_FocusOut( HWND hwnd, XFocusChangeEvent *event )
+static void EVENT_FocusOut( HWND32 hwnd, XFocusChangeEvent *event )
 {
     if (event->detail == NotifyPointer) return;
     if (hwnd == GetActiveWindow32()) WINPOS_ChangeActiveWindow( 0, FALSE );
@@ -543,6 +547,21 @@
         SetFocus32( 0 );
 }
 
+/**********************************************************************
+ *              EVENT_CheckFocus
+ */
+BOOL32 EVENT_CheckFocus(void)
+{
+    WND*   pWnd;
+    Window xW;
+    int	   state;
+
+    XGetInputFocus(display, &xW, &state);
+    if( xW == None ||
+        XFindContext(display, xW, winContext, (char **)&pWnd) ) 
+        return FALSE;
+    return TRUE;
+}
 
 /**********************************************************************
  *              EVENT_ConfigureNotify
@@ -550,7 +569,7 @@
  * The ConfigureNotify event is only selected on the desktop window
  * and on top-level windows when the -managed flag is used.
  */
-static void EVENT_ConfigureNotify( HWND hwnd, XConfigureEvent *event )
+static void EVENT_ConfigureNotify( HWND32 hwnd, XConfigureEvent *event )
 {
     /* FIXME: with -desktop xxx we get this event _before_ desktop 
      * window structure is created. WIN_GetDesktop() check is a hack.
@@ -574,10 +593,6 @@
 	
         if (!(winpos = SEGPTR_NEW(WINDOWPOS16))) return;
 
-/*	XTranslateCoordinates(display, event->window, rootWindow,
-	    event->x, event->y, &event->x, &event->y, &child);
-            */
-
 	/* Fill WINDOWPOS struct */
 	winpos->flags = SWP_NOACTIVATE | SWP_NOZORDER;
 	winpos->hwnd = hwnd;
@@ -652,8 +667,8 @@
 	{
             /* open to make sure that clipboard is available */
 
-	    BOOL 	couldOpen = OpenClipboard( pWnd->hwndSelf );
-	    char*	lpstr = 0;
+	    BOOL32 couldOpen = OpenClipboard32( pWnd->hwndSelf );
+	    char* lpstr = 0;
 
 	    hText = GetClipboardData(CF_TEXT);
 	    text = GlobalLock16(hText);
@@ -677,7 +692,7 @@
 
 	    /* close only if we opened before */
 
-	    if(couldOpen) CloseClipboard();
+	    if(couldOpen) CloseClipboard32();
 	}
     }
 
@@ -858,7 +873,7 @@
 /**********************************************************************
  *		EVENT_MapNotify
  */
-void EVENT_MapNotify( HWND hWnd, XMapEvent *event )
+void EVENT_MapNotify( HWND32 hWnd, XMapEvent *event )
 {
     HWND32 hwndFocus = GetFocus32();
 
@@ -877,27 +892,36 @@
 HWND32 EVENT_Capture(HWND32 hwnd, INT16 ht)
 {
     Window win;
-    HWND32 old_capture_wnd = captureWnd;
+    HWND32 capturePrev = captureWnd;
 
     if (!hwnd)
     {
-        ReleaseCapture();
-        return old_capture_wnd;
+        XUngrabPointer(display, CurrentTime );
+        captureWnd = NULL; captureHT = 0; 
     }
-    if ((win = WIN_GetXWindow( hwnd )))
+    else if ((win = WIN_GetXWindow( hwnd )))
     {
-        if (XGrabPointer(display, win, False,
-                     ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
-                     GrabModeAsync, GrabModeAsync,
-                     None, None, CurrentTime ) == GrabSuccess)
+	WND* wndPtr = WIN_FindWndPtr( hwnd );
+
+        if ( wndPtr && 
+	     (XGrabPointer(display, win, False, 
+			   ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
+                           GrabModeAsync, GrabModeAsync,
+                           None, None, CurrentTime ) == GrabSuccess) )
 	{
-            dprintf_win(stddeb, "SetCapture: %04x\n", hwnd);
+            dprintf_win(stddeb, "SetCapture(0x%04x)\n", hwnd );
             captureWnd   = hwnd;
 	    captureHT    = ht;
-            return old_capture_wnd;
         }
     }
-    return 0;
+
+    if( capturePrev && capturePrev != captureWnd )
+    {
+	WND* wndPtr = WIN_FindWndPtr( capturePrev );
+        if( wndPtr && (wndPtr->flags & WIN_ISWIN32) )
+            SendMessage32A( capturePrev, WM_CAPTURECHANGED, 0L, hwnd);
+    }
+    return capturePrev;
 }
 
 /**********************************************************************
@@ -931,10 +955,8 @@
  */
 void ReleaseCapture(void)
 {
-    if (captureWnd == 0) return;
-    XUngrabPointer( display, CurrentTime );
-    captureWnd = 0;
-    dprintf_win(stddeb, "ReleaseCapture\n");
+    dprintf_win(stddeb, "ReleaseCapture() [%04x]\n", captureWnd );
+    if( captureWnd ) EVENT_Capture( 0, 0 );
 }
 
 
@@ -943,7 +965,7 @@
  */
 HWND16 GetCapture16(void)
 {
-    return (HWND16)captureWnd;
+    return captureWnd;
 }
 
 
@@ -1018,3 +1040,24 @@
   return bOldState;
 }
 
+
+/***********************************************************************
+ *	     SwapMouseButton16   (USER.186)
+ */
+BOOL16 SwapMouseButton16( BOOL16 fSwap )
+{
+    BOOL16 ret = SwappedButtons;
+    SwappedButtons = fSwap;
+    return ret;
+}
+
+
+/***********************************************************************
+ *	     SwapMouseButton32   (USER32.536)
+ */
+BOOL32 SwapMouseButton32( BOOL32 fSwap )
+{
+    BOOL32 ret = SwappedButtons;
+    SwappedButtons = fSwap;
+    return ret;
+}
diff --git a/windows/focus.c b/windows/focus.c
index f40c5db..06467a6 100644
--- a/windows/focus.c
+++ b/windows/focus.c
@@ -60,11 +60,21 @@
 {
     hwndFocus = hFocusTo;
 
+#if 0
     if (hFocusFrom) SendMessage32A( hFocusFrom, WM_KILLFOCUS, hFocusTo, 0 );
+#else
+    /* FIXME: must be SendMessage16() because 32A doesn't do
+     * intertask at this time */
+    if (hFocusFrom) SendMessage16( hFocusFrom, WM_KILLFOCUS, hFocusTo, 0 );
+#endif
     if( !hFocusTo || hFocusTo != hwndFocus )
 	return;
 
+#if 0
     SendMessage32A( hFocusTo, WM_SETFOCUS, hFocusFrom, 0 );
+#else
+    SendMessage16( hFocusTo, WM_SETFOCUS, hFocusFrom, 0 );
+#endif
     FOCUS_SetXFocus( hFocusTo );
 }
 
diff --git a/windows/hook.c b/windows/hook.c
index 1a9b793..59ffd20 100644
--- a/windows/hook.c
+++ b/windows/hook.c
@@ -22,6 +22,7 @@
 #include "user.h"
 #include "heap.h"
 #include "struct32.h"
+#include "winproc.h"
 #include "stddebug.h"
 #include "debug.h"
 
@@ -35,8 +36,7 @@
     INT16      id;                 /* 06 Hook id (WH_xxx) */
     HQUEUE16   ownerQueue;         /* 08 Owner queue (0 for system hook) */
     HMODULE16  ownerModule;        /* 0a Owner module */
-    WORD       inHookProc;         /* 0c TRUE if in this->proc */
-    INT32      flags;
+    WORD       flags;              /* 0c flags */
 } HOOKDATA;
 
 #pragma pack(4)
@@ -50,33 +50,29 @@
 typedef VOID (*HOOK_UnMapFunc)(INT32, INT32, WPARAM32, LPARAM, WPARAM32,
 			       LPARAM);
 
-
-/***********************************************************************
- *           Hook Mapping Functions
- */
-
-
 /***********************************************************************
  *           HOOK_Map16To32Common
  */
 static void HOOK_Map16To32Common(INT32 id, INT32 code, WPARAM32 *pwParam,
-				 LPARAM *plParam)
+				 LPARAM *plParam, BOOL32 bA )
 {
-    switch (id)
-    {
-    case WH_MSGFILTER:
-    case WH_SYSMSGFILTER:
-    case WH_GETMESSAGE:
-    case WH_JOURNALRECORD:
+
+   switch( id )
+   {
+	case WH_MSGFILTER:
+	case WH_SYSMSGFILTER: 
+	case WH_GETMESSAGE: 
+	case WH_JOURNALRECORD:
         {
             LPMSG16 lpmsg16 = PTR_SEG_TO_LIN(*plParam);
             LPMSG32 lpmsg32 = HeapAlloc( SystemHeap, 0, sizeof(*lpmsg32) );
 	
             STRUCT32_MSG16to32( lpmsg16, lpmsg32 );
             *plParam = (LPARAM)lpmsg32;
-            break;
-        }
-    case WH_JOURNALPLAYBACK:
+	    break;
+        } 
+
+	case WH_JOURNALPLAYBACK:
         {
             LPEVENTMSG16 lpem16 = PTR_SEG_TO_LIN(*plParam);
             LPEVENTMSG32 lpem32 = HeapAlloc( SystemHeap, 0, sizeof(*lpem32) );
@@ -88,12 +84,61 @@
             lpem32->hwnd = 0;	/* FIXME */
 
             *plParam = (LPARAM)lpem32;
-            break;
-        }
-    case WH_CBT:
-	switch (code)
+	    break;
+        } 
+
+	case WH_CALLWNDPROC:
 	{
-        case HCBT_ACTIVATE:
+	    INT32	(*localMap)(UINT16, WPARAM16, UINT32*, WPARAM32*, LPARAM*)
+			  = (bA) ? WINPROC_MapMsg16To32A : WINPROC_MapMsg16To32W;
+	    LPCWPSTRUCT16   lpcwp16 = PTR_SEG_TO_LIN(*plParam);
+	    LPCWPSTRUCT32   lpcwp32 = HeapAlloc( SystemHeap, 0, sizeof(*lpcwp32) );
+	    
+	    lpcwp32->hwnd = lpcwp16->hwnd;
+	    lpcwp32->lParam = lpcwp16->lParam;
+	    
+	    (*localMap)(lpcwp16->message, lpcwp16->wParam, 
+		       &lpcwp32->message, &lpcwp32->wParam, &lpcwp32->lParam );
+	    break;
+	}
+
+	case WH_CBT:
+	  switch (code)
+	  {
+	    case HCBT_CREATEWND:
+	    {
+		LPCBT_CREATEWND16  lpcbtcw16 = PTR_SEG_TO_LIN(*plParam);
+		LPCREATESTRUCT16   lpcs16 = PTR_SEG_TO_LIN(lpcbtcw16->lpcs);
+		LPCBT_CREATEWND32A lpcbtcw32 = HeapAlloc( SystemHeap, 0,
+							  sizeof(*lpcbtcw32) );
+		lpcbtcw32->lpcs = HeapAlloc( SystemHeap, 0,
+					     sizeof(*lpcbtcw32->lpcs) );
+
+		STRUCT32_CREATESTRUCT16to32A( lpcs16,
+					     (LPCREATESTRUCT32A)lpcbtcw32->lpcs );
+
+		if (HIWORD(lpcs16->lpszName))
+		    lpcbtcw32->lpcs->lpszName = 
+			(bA) ? PTR_SEG_TO_LIN(lpcs16->lpszName)
+			     : HEAP_strdupAtoW( SystemHeap, 0,
+                                                PTR_SEG_TO_LIN(lpcs16->lpszName) );
+		else
+		    lpcbtcw32->lpcs->lpszName = (LPCSTR)lpcs16->lpszName;
+
+		if (HIWORD(lpcs16->lpszClass))
+		    lpcbtcw32->lpcs->lpszClass =
+			(bA) ? PTR_SEG_TO_LIN(lpcs16->lpszClass)
+			     : HEAP_strdupAtoW( SystemHeap, 0,
+                                                PTR_SEG_TO_LIN(lpcs16->lpszClass) );
+		else
+		    lpcbtcw32->lpcs->lpszClass = (LPCSTR)lpcs16->lpszClass;
+
+		lpcbtcw32->hwndInsertAfter = lpcbtcw16->hwndInsertAfter;
+
+		*plParam = (LPARAM)lpcbtcw32;
+		break;
+	    } 
+	    case HCBT_ACTIVATE:
             {
                 LPCBTACTIVATESTRUCT16 lpcas16 = PTR_SEG_TO_LIN(*plParam);
                 LPCBTACTIVATESTRUCT32 lpcas32 = HeapAlloc( SystemHeap, 0,
@@ -103,7 +148,7 @@
                 *plParam = (LPARAM)lpcas32;
                 break;
             }
-        case HCBT_CLICKSKIPPED:
+            case HCBT_CLICKSKIPPED:
             {
                 LPMOUSEHOOKSTRUCT16 lpms16 = PTR_SEG_TO_LIN(*plParam);
                 LPMOUSEHOOKSTRUCT32 lpms32 = HeapAlloc( SystemHeap, 0,
@@ -120,7 +165,7 @@
                 *plParam = (LPARAM)lpms32;
                 break;
             }
-        case HCBT_MOVESIZE:
+            case HCBT_MOVESIZE:
             {
                 LPRECT16 lprect16 = PTR_SEG_TO_LIN(*plParam);
                 LPRECT32 lprect32 = HeapAlloc( SystemHeap, 0,
@@ -130,9 +175,10 @@
                 *plParam = (LPARAM)lprect32;
                 break;
             }
-	}
-	break;
-    case WH_MOUSE:
+	    break;
+	  } 
+
+	case WH_MOUSE:
         {
             LPMOUSEHOOKSTRUCT16 lpms16 = PTR_SEG_TO_LIN(*plParam);
             LPMOUSEHOOKSTRUCT32 lpms32 = HeapAlloc( SystemHeap, 0,
@@ -146,9 +192,10 @@
             lpms32->dwExtraInfo = lpms16->dwExtraInfo;
             lpms32->hwnd = lpms16->hwnd;
             *plParam = (LPARAM)lpms32;
-            break;
-        }
-    case WH_DEBUG:
+	    break;
+        } 
+
+	case WH_DEBUG:
         {
             LPDEBUGHOOKINFO16 lpdh16 = PTR_SEG_TO_LIN(*plParam);
             LPDEBUGHOOKINFO32 lpdh32 = HeapAlloc( SystemHeap, 0,
@@ -164,19 +211,17 @@
             if (*pwParam == 0xffff) *pwParam = WH_MSGFILTER;
 
             *plParam = (LPARAM)lpdh32;
-            break;
+	    break;
         }
-    case WH_SHELL:
-    case WH_KEYBOARD:
-	break;
 
-    case WH_CALLWNDPROC:
-    case WH_HARDWARE:
-	break;	/* NYI */
+	case WH_SHELL:
+	case WH_KEYBOARD:
+	    break;
 
-    default:
-	fprintf(stderr, "Unknown hook id: %d\n", id);
-	return;
+	case WH_HARDWARE: 
+	case WH_FOREGROUNDIDLE: 
+	case WH_CALLWNDPROCRET:
+	    fprintf(stderr, "\t[%i] 16to32 translation unimplemented\n", id);
     }
 }
 
@@ -187,34 +232,7 @@
 static void HOOK_Map16To32A(INT32 id, INT32 code, WPARAM32 *pwParam,
 			    LPARAM *plParam)
 {
-    if (id == WH_CBT && code == HCBT_CREATEWND)
-    {
-	LPCBT_CREATEWND16 lpcbtcw16 = PTR_SEG_TO_LIN(*plParam);
-	LPCBT_CREATEWND32A lpcbtcw32 = HeapAlloc( SystemHeap, 0,
-						  sizeof(*lpcbtcw32) );
-	lpcbtcw32->lpcs = HeapAlloc( SystemHeap, 0,
-				     sizeof(*lpcbtcw32->lpcs) );
-
-	STRUCT32_CREATESTRUCT16to32A( lpcbtcw16->lpcs, lpcbtcw32->lpcs );
-
-	if (HIWORD(lpcbtcw16->lpcs->lpszName))
-            lpcbtcw32->lpcs->lpszName
-                = PTR_SEG_TO_LIN(lpcbtcw16->lpcs->lpszName);
-	else
-            lpcbtcw32->lpcs->lpszName = (LPSTR)lpcbtcw16->lpcs->lpszName;
-
-	if (HIWORD(lpcbtcw16->lpcs->lpszClass))
-            lpcbtcw32->lpcs->lpszClass
-                = PTR_SEG_TO_LIN(lpcbtcw16->lpcs->lpszClass);
-	else
-            lpcbtcw32->lpcs->lpszClass = (LPSTR)lpcbtcw16->lpcs->lpszClass;
-
-	lpcbtcw32->hwndInsertAfter = lpcbtcw16->hwndInsertAfter;
-
-	*plParam = (LPARAM)lpcbtcw32;
-    }
-    else
-        HOOK_Map16To32Common( id, code, pwParam, plParam );
+    HOOK_Map16To32Common( id, code, pwParam, plParam, TRUE );
 }
 
 
@@ -224,35 +242,7 @@
 static void HOOK_Map16To32W(INT32 id, INT32 code, WPARAM32 *pwParam,
 			    LPARAM *plParam)
 {
-    if (id == WH_CBT && code == HCBT_CREATEWND)
-    {
-	LPCBT_CREATEWND16 lpcbtcw16 = PTR_SEG_TO_LIN(*plParam);
-	LPCREATESTRUCT16 lpcs16 = PTR_SEG_TO_LIN(lpcbtcw16->lpcs);
-	LPCBT_CREATEWND32W lpcbtcw32 = HeapAlloc( SystemHeap, 0,
-						  sizeof(*lpcbtcw32) );
-	lpcbtcw32->lpcs = HeapAlloc( SystemHeap, 0,
-				     sizeof(*lpcbtcw32->lpcs) );
-
-	STRUCT32_CREATESTRUCT16to32A( lpcs16,
-				      (LPCREATESTRUCT32A)lpcbtcw32->lpcs );
-
-	if (HIWORD(lpcs16->lpszName))
-            lpcbtcw32->lpcs->lpszName = HEAP_strdupAtoW( SystemHeap, 0,
-                                            PTR_SEG_TO_LIN(lpcs16->lpszName) );
-	else
-            lpcbtcw32->lpcs->lpszName = (LPWSTR)lpcs16->lpszName;
-
-	if (HIWORD(lpcs16->lpszClass))
-            lpcbtcw32->lpcs->lpszClass = HEAP_strdupAtoW( SystemHeap, 0,
-                                           PTR_SEG_TO_LIN(lpcs16->lpszClass) );
-	else
-            lpcbtcw32->lpcs->lpszClass = (LPWSTR)lpcs16->lpszClass;
-
-	lpcbtcw32->hwndInsertAfter = lpcbtcw16->hwndInsertAfter;
-
-	*plParam = (LPARAM)lpcbtcw32;
-    }
-    else HOOK_Map16To32Common( id, code, pwParam, plParam );
+    HOOK_Map16To32Common( id, code, pwParam, plParam, FALSE );
 }
 
 
@@ -261,56 +251,82 @@
  */
 static void HOOK_UnMap16To32Common(INT32 id, INT32 code, WPARAM32 wParamOrig,
 				   LPARAM lParamOrig, WPARAM32 wParam,
-				   LPARAM lParam)
+				   LPARAM lParam, BOOL32 bA)
 {
     switch (id)
     {
-      case WH_MSGFILTER:
-      case WH_SYSMSGFILTER:
-      case WH_JOURNALRECORD:
-      case WH_JOURNALPLAYBACK:
-      {
-	  HeapFree( SystemHeap, 0, (LPVOID)lParam );
-	  break;
-      }
-
-      case WH_GETMESSAGE:
-      {
-	  LPMSG16 lpmsg16 = PTR_SEG_TO_LIN(lParamOrig);
-	  STRUCT32_MSG32to16( (LPMSG32)lParam, lpmsg16 );
-	  HeapFree( SystemHeap, 0, (LPVOID)lParam );
-	  break;
-      }
-
-      case WH_MOUSE:
-      case WH_DEBUG:
-	HeapFree( SystemHeap, 0, (LPVOID)lParam );
-	break;
-
-	/* I don't think any of these need to be copied */
-      case WH_CBT:
-	switch (code)
-	{
-	  case HCBT_ACTIVATE:
-	  case HCBT_CLICKSKIPPED:
-	  case HCBT_MOVESIZE:
-	    HeapFree( SystemHeap, 0, (LPVOID)lParam);
+	case WH_MSGFILTER:
+	case WH_SYSMSGFILTER:
+	case WH_JOURNALRECORD:
+	case WH_JOURNALPLAYBACK:
+      
+	    HeapFree( SystemHeap, 0, (LPVOID)lParam );
 	    break;
+
+	case WH_CALLWNDPROC:
+	{
+            void          (*localUnMap)(UINT32, WPARAM32, LPARAM)
+                            = (bA) ? WINPROC_UnmapMsg16To32A : WINPROC_UnmapMsg16To32W;
+            LPCWPSTRUCT32   lpcwp32 = (LPCWPSTRUCT32)lParam;
+
+            (*localUnMap)(lpcwp32->message, lpcwp32->wParam, lpcwp32->lParam );
+	    HeapFree( SystemHeap, 0, lpcwp32 );
+            break;
 	}
-	break;
 
-      case WH_SHELL:
-      case WH_KEYBOARD:
-	break;
+	case WH_GETMESSAGE:
+        {
+	    LPMSG16 lpmsg16 = PTR_SEG_TO_LIN(lParamOrig);
+	    STRUCT32_MSG32to16( (LPMSG32)lParam, lpmsg16 );
+	    HeapFree( SystemHeap, 0, (LPVOID)lParam );
+	    break;
+        }
 
-      case WH_CALLWNDPROC:
-      case WH_HARDWARE:
-	fprintf(stderr, "Can't map hook id: %d\n", id);
-	break;
+        case WH_MOUSE:
+        case WH_DEBUG:
 
-      default:
-	fprintf(stderr, "Unknown hook id: %d\n", id);
-	return;
+	    HeapFree( SystemHeap, 0, (LPVOID)lParam );
+	    break;
+
+        case WH_CBT:
+	    switch (code)
+  	    {
+	      case HCBT_CREATEWND:
+	      {
+		LPCBT_CREATEWND32A lpcbtcw32 = (LPCBT_CREATEWND32A)lParam;
+		LPCBT_CREATEWND16  lpcbtcw16 = PTR_SEG_TO_LIN(lParamOrig);
+
+		if( !bA )
+		{
+		   if (HIWORD(lpcbtcw32->lpcs->lpszName))
+                       HeapFree( SystemHeap, 0, (LPWSTR)lpcbtcw32->lpcs->lpszName );
+		   if (HIWORD(lpcbtcw32->lpcs->lpszClass))
+                       HeapFree( SystemHeap, 0, (LPWSTR)lpcbtcw32->lpcs->lpszClass );
+		}
+
+		lpcbtcw16->hwndInsertAfter = lpcbtcw32->hwndInsertAfter;
+
+		HeapFree( SystemHeap, 0, lpcbtcw32->lpcs );
+	      } /* fall through */
+
+	      case HCBT_ACTIVATE:
+	      case HCBT_CLICKSKIPPED:
+	      case HCBT_MOVESIZE:
+
+	        HeapFree( SystemHeap, 0, (LPVOID)lParam);
+	        break;
+	    }
+  	    break;
+
+        case WH_SHELL:
+        case WH_KEYBOARD:
+	    break;
+
+        case WH_HARDWARE:
+	case WH_FOREGROUNDIDLE:
+	case WH_CALLWNDPROCRET:
+	    fprintf(stderr, "\t[%i] skipping unmap\n", id);
+  	    break;
     }
 }
 
@@ -322,16 +338,8 @@
 			      LPARAM lParamOrig, WPARAM32 wParam,
 			      LPARAM lParam)
 {
-    if (id == WH_CBT && code == HCBT_CREATEWND)
-    {
-	LPCBT_CREATEWND32A lpcbtcw32 = (LPCBT_CREATEWND32A)lParam;
-	HeapFree( SystemHeap, 0, lpcbtcw32->lpcs );
-	HeapFree( SystemHeap, 0, lpcbtcw32 );
-    }
-    else
-      HOOK_UnMap16To32Common( id, code, wParamOrig, lParamOrig, wParam,
-			      lParam);
-    return;
+    HOOK_UnMap16To32Common( id, code, wParamOrig, lParamOrig, wParam,
+			    lParam, TRUE );
 }
 
 
@@ -342,18 +350,8 @@
 			      LPARAM lParamOrig, WPARAM32 wParam,
 			      LPARAM lParam)
 {
-    if (id == WH_CBT && code == HCBT_CREATEWND)
-    {
-	LPCBT_CREATEWND32W lpcbtcw32 = (LPCBT_CREATEWND32W)lParam;
-	if (HIWORD(lpcbtcw32->lpcs->lpszName))
-            HeapFree( SystemHeap, 0, (LPWSTR)lpcbtcw32->lpcs->lpszName );
-	if (HIWORD(lpcbtcw32->lpcs->lpszClass))
-            HeapFree( SystemHeap, 0, (LPWSTR)lpcbtcw32->lpcs->lpszClass );
-	HeapFree( SystemHeap, 0, lpcbtcw32->lpcs );
-	HeapFree( SystemHeap, 0, lpcbtcw32 );
-    }
-    else
-      HOOK_UnMap16To32Common(id, code, wParamOrig, lParamOrig, wParam, lParam);
+    HOOK_UnMap16To32Common( id, code, wParamOrig, lParamOrig, wParam, 
+			    lParam, FALSE );
 }
 
 
@@ -361,7 +359,7 @@
  *           HOOK_Map32To16Common
  */
 static void HOOK_Map32To16Common(INT32 id, INT32 code, WPARAM32 *pwParam,
-				 LPARAM *plParam)
+				 LPARAM *plParam, BOOL32 bA)
 {
     switch (id)
     {
@@ -393,6 +391,22 @@
 	  break;
       }
 
+      case WH_CALLWNDPROC:
+      {
+          INT32       (*localMap)(UINT32, WPARAM32, UINT16*, WPARAM16*, LPARAM*)
+                          = (bA) ? WINPROC_MapMsg32ATo16 : WINPROC_MapMsg32WTo16;
+          LPCWPSTRUCT32   lpcwp32 = (LPCWPSTRUCT32)*plParam;
+	  LPCWPSTRUCT16   lpcwp16 = SEGPTR_NEW( CWPSTRUCT16 );
+
+          lpcwp16->hwnd = lpcwp32->hwnd;
+          lpcwp16->lParam = lpcwp32->lParam;
+
+         (*localMap)(lpcwp32->message, lpcwp32->wParam,
+                    &lpcwp16->message, &lpcwp16->wParam, &lpcwp16->lParam );
+	  *plParam = (LPARAM)SEGPTR_GET( lpcwp16 );
+          break;
+      }
+
       case WH_CBT:
 	switch (code)
 	{
@@ -402,8 +416,8 @@
 	      LPCBTACTIVATESTRUCT16 lpcas16 =SEGPTR_NEW( CBTACTIVATESTRUCT16 );
 
 	      lpcas16->fMouse     = lpcas32->fMouse;
-	      lpcas16->hWndActive = lpcas32->hWndActive
-;
+	      lpcas16->hWndActive = lpcas32->hWndActive;
+
 	      *plParam = (LPARAM)SEGPTR_GET( lpcas16 );
 	      break;
 	  }
@@ -470,14 +484,10 @@
       case WH_KEYBOARD:
 	break;
 
-      case WH_CALLWNDPROC:
       case WH_HARDWARE:
-	fprintf(stderr, "Can't map hook id: %d\n", id);
-	break;
-
-      default:
-	fprintf(stderr, "Unknown hook id: %d\n", id);
-	return;
+      case WH_FOREGROUNDIDLE:
+      case WH_CALLWNDPROCRET:
+	fprintf(stderr,"\t[%i] 32to16 translation unimplemented\n", id);
     }
 }
 
@@ -513,7 +523,7 @@
 
 	*plParam = (LPARAM)SEGPTR_GET( lpcbtcw16 );
     }
-    else HOOK_Map32To16Common(id, code, pwParam, plParam);
+    else HOOK_Map32To16Common(id, code, pwParam, plParam, TRUE);
 }
 
 
@@ -542,7 +552,7 @@
 
 	*plParam = (LPARAM)SEGPTR_GET( lpcbtcw16 );
     }
-    else HOOK_Map32To16Common(id, code, pwParam, plParam);
+    else HOOK_Map32To16Common(id, code, pwParam, plParam, FALSE);
 }
 
 
@@ -551,7 +561,7 @@
  */
 static void HOOK_UnMap32To16Common(INT32 id, INT32 code, WPARAM32 wParamOrig,
 				   LPARAM lParamOrig, WPARAM32 wParam,
-				   LPARAM lParam)
+				   LPARAM lParam, BOOL32 bA)
 {
     switch (id)
     {
@@ -564,6 +574,18 @@
 	SEGPTR_FREE( PTR_SEG_TO_LIN(lParam) );
 	break;
 
+      case WH_CALLWNDPROC:
+      {
+          void          (*localUnMap)(UINT32, WPARAM16, LPARAM)
+                          = (bA) ? WINPROC_UnmapMsg32ATo16 : WINPROC_UnmapMsg32WTo16;
+          LPCWPSTRUCT16   lpcwp16 = (LPCWPSTRUCT16)PTR_SEG_TO_LIN(lParam);
+	  LPCWPSTRUCT32   lpcwp32 = (LPCWPSTRUCT32)lParamOrig;
+
+          (*localUnMap)(lpcwp32->message, lpcwp16->wParam, lpcwp16->lParam );
+	  SEGPTR_FREE( PTR_SEG_TO_LIN(lParam) );
+          break;
+      }
+
       case WH_GETMESSAGE:
       {
 	  LPMSG32 lpmsg32 = (LPMSG32)lParamOrig;
@@ -576,11 +598,29 @@
       case WH_CBT:
 	switch (code)
 	{
+	  case HCBT_CREATEWND:
+	  {
+	       LPCBT_CREATEWND32A lpcbtcw32 = (LPCBT_CREATEWND32A)(lParamOrig);
+               LPCBT_CREATEWND16 lpcbtcw16 = PTR_SEG_TO_LIN(lParam);
+               LPCREATESTRUCT16  lpcs16 = PTR_SEG_TO_LIN(lpcbtcw16->lpcs);
+
+               if (HIWORD(lpcs16->lpszName))
+                   SEGPTR_FREE( PTR_SEG_TO_LIN(lpcs16->lpszName) );
+
+               if (HIWORD(lpcs16->lpszClass))
+                   SEGPTR_FREE( PTR_SEG_TO_LIN(lpcs16->lpszClass) );
+
+	       lpcbtcw32->hwndInsertAfter = lpcbtcw16->hwndInsertAfter;
+
+               SEGPTR_FREE( lpcs16 );
+	  } /* fall through */
+
 	  case HCBT_ACTIVATE:
 	  case HCBT_CLICKSKIPPED:
 	  case HCBT_MOVESIZE:
-	    SEGPTR_FREE( (LPVOID)lParam );
-	    break;
+
+	       SEGPTR_FREE( PTR_SEG_TO_LIN(lParam) );
+	       break;
 	}
 	break;
 
@@ -588,14 +628,10 @@
       case WH_KEYBOARD:
 	break;
 
-      case WH_CALLWNDPROC:
       case WH_HARDWARE:
-	fprintf(stderr, "Can't map hook id: %d\n", id);
-	break;
-
-      default:
-	fprintf(stderr, "Unknown hook id: %d\n", id);
-	return;
+      case WH_FOREGROUNDIDLE:
+      case WH_CALLWNDPROCRET:
+	fprintf(stderr, "\t[%i] skipping unmap\n", id);
     }
 }
 
@@ -607,24 +643,8 @@
 			      LPARAM lParamOrig, WPARAM32 wParam,
 			      LPARAM lParam)
 {
-    if (id == WH_CBT && code == HCBT_CREATEWND)
-    {
-	LPCBT_CREATEWND16 lpcbtcw16 = PTR_SEG_TO_LIN(lParam);
-	LPCREATESTRUCT16 lpcs16 = PTR_SEG_TO_LIN(lpcbtcw16->lpcs);
-
-	if (HIWORD(lpcs16->lpszName))
-	  SEGPTR_FREE( PTR_SEG_TO_LIN(lpcs16->lpszName) );
-
-	if (HIWORD(lpcs16->lpszClass))
-	  SEGPTR_FREE( PTR_SEG_TO_LIN(lpcs16->lpszClass) );
-
-	SEGPTR_FREE( lpcs16 );
-	SEGPTR_FREE( lpcbtcw16 );
-    }
-    else
-      return HOOK_UnMap32To16Common( id, code, wParamOrig, lParamOrig, wParam,
-				     lParam );
-    return;
+    HOOK_UnMap32To16Common( id, code, wParamOrig, lParamOrig, wParam,
+			    lParam, TRUE );
 }
 
 
@@ -635,7 +655,8 @@
 			      LPARAM lParamOrig, WPARAM32 wParam,
 			      LPARAM lParam)
 {
-    HOOK_UnMap32ATo16( id, code, wParamOrig, lParamOrig, wParam, lParam );
+    HOOK_UnMap32To16Common( id, code, wParamOrig, lParamOrig, wParam,
+                            lParam, FALSE );
 }
 
 
@@ -841,7 +862,6 @@
     data->id          = id;
     data->ownerQueue  = hQueue;
     data->ownerModule = hInst;
-    data->inHookProc  = 0;
     data->flags       = type;
 
     /* Insert it in the correct linked list */
@@ -876,7 +896,7 @@
     dprintf_hook( stddeb, "Removing hook %04x\n", hook );
 
     if (!(data = (HOOKDATA *)USER_HEAP_LIN_ADDR(hook))) return FALSE;
-    if (data->inHookProc)
+    if (data->flags & HOOK_INUSE)
     {
         /* Mark it for deletion later on */
         dprintf_hook( stddeb, "Hook still running, deletion delayed\n" );
@@ -952,7 +972,7 @@
     if (!(queue = (MESSAGEQUEUE *)GlobalLock16( GetTaskQueue(0) ))) return 0;
     prevHook = queue->hCurHook;
     queue->hCurHook = hook;
-    data->inHookProc = TRUE;
+    data->flags |= HOOK_INUSE;
 
     dprintf_hook( stddeb, "Calling hook %04x: %d %08x %08lx\n",
                   hook, code, wParam, lParam );
@@ -965,7 +985,7 @@
 
     dprintf_hook( stddeb, "Ret hook %04x = %08lx\n", hook, ret );
 
-    data->inHookProc = FALSE;
+    data->flags &= ~HOOK_INUSE;
     queue->hCurHook = prevHook;
 
     if (UnMapFunc)
@@ -1100,7 +1120,7 @@
 	      next = hptr->next;
 	      if( hptr->ownerModule == hModule )
                 {
-                  hptr->inHookProc = 0;
+                  hptr->flags &= HOOK_MAPTYPE;
                   HOOK_RemoveHook(hook);
                 }
 	      hook = next;
@@ -1130,7 +1150,7 @@
 	  hptr = (HOOKDATA *)USER_HEAP_LIN_ADDR(hook);
 	  if( hptr && hptr->ownerQueue == hQueue )
 	    {
-	      hptr->inHookProc = 0;
+	      hptr->flags &= HOOK_MAPTYPE;
 	      HOOK_RemoveHook(hook);
 	    }
 	  hook = next;
diff --git a/windows/keyboard.c b/windows/keyboard.c
index f83cc16..8ed9eeb 100644
--- a/windows/keyboard.c
+++ b/windows/keyboard.c
@@ -864,15 +864,27 @@
 	return 0;
 }
 
+
 /****************************************************************************
- *	GetKbCodePage   (KEYBOARD.132)
+ *	GetKBCodePage16   (KEYBOARD.132)
  */
-INT16 GetKbCodePage(VOID)
+INT16 GetKBCodePage16(void)
 {
-    	dprintf_keyboard(stddeb,"GetKbCodePage()\n");
-	return 850;
+    dprintf_keyboard(stddeb,"GetKBCodePage()\n");
+    return 850;
 }
 
+
+/****************************************************************************
+ *	GetKBCodePage32   (USER32.245)
+ */
+UINT32 GetKBCodePage32(void)
+{
+    dprintf_keyboard(stddeb,"GetKbCodePage()\n");
+    return 850;
+}
+
+
 /****************************************************************************
  *	GetKeyNameText32W   (USER32.247)
  */
diff --git a/windows/mdi.c b/windows/mdi.c
index 317c8ae..395a4ea 100644
--- a/windows/mdi.c
+++ b/windows/mdi.c
@@ -37,25 +37,25 @@
 DWORD SCROLL_SetNCSbState(WND*,int,int,int,int,int,int);
 
 /* ----------------- declarations ----------------- */
-void MDI_UpdateFrameText(WND *, HWND, BOOL, LPCSTR);
-BOOL MDI_AugmentFrameMenu(MDICLIENTINFO*, WND *, HWND);
-BOOL MDI_RestoreFrameMenu(WND *, HWND);
+static void MDI_UpdateFrameText(WND *, HWND16, BOOL32, LPCSTR);
+static BOOL32 MDI_AugmentFrameMenu(MDICLIENTINFO*, WND *, HWND16);
+static BOOL32 MDI_RestoreFrameMenu(WND *, HWND16);
 
-static LONG MDI_ChildActivate(WND* ,HWND );
+static LONG MDI_ChildActivate(WND* ,HWND16 );
 
 /* -------- Miscellaneous service functions ----------
  *
  *			MDI_GetChildByID
  */
 
-static HWND MDI_GetChildByID(WND* wndPtr,int id)
+static HWND16 MDI_GetChildByID(WND* wndPtr,int id)
 {
     for (wndPtr = wndPtr->child; wndPtr; wndPtr = wndPtr->next)
         if (wndPtr->wIDmenu == id) return wndPtr->hwndSelf;
     return 0;
 }
 
-static void MDI_PostUpdate(HWND hwnd, MDICLIENTINFO* ci, WORD recalc)
+static void MDI_PostUpdate(HWND16 hwnd, MDICLIENTINFO* ci, WORD recalc)
 {
  if( !ci->sbNeedUpdate )
    {
@@ -69,7 +69,7 @@
  *			MDI_MenuAppendItem
  */
 #ifdef SUPERFLUOUS_FUNCTIONS
-static BOOL MDI_MenuAppendItem(WND *clientWnd, HWND hWndChild)
+static BOOL MDI_MenuAppendItem(WND *clientWnd, HWND16 hWndChild)
 {
  char buffer[128];
  MDICLIENTINFO  *clientInfo = (MDICLIENTINFO*)clientWnd->wExtra;
@@ -88,7 +88,7 @@
 /**********************************************************************
  *			MDI_MenuModifyItem
  */
-static BOOL MDI_MenuModifyItem(WND* clientWnd, HWND hWndChild )
+static BOOL MDI_MenuModifyItem(WND* clientWnd, HWND16 hWndChild )
 {
  char            buffer[128];
  MDICLIENTINFO  *clientInfo = (MDICLIENTINFO*)clientWnd->wExtra;
@@ -111,7 +111,7 @@
 /**********************************************************************
  *			MDI_MenuDeleteItem
  */
-static BOOL MDI_MenuDeleteItem(WND* clientWnd, HWND hWndChild )
+static BOOL MDI_MenuDeleteItem(WND* clientWnd, HWND16 hWndChild )
 {
  char    	 buffer[128];
  MDICLIENTINFO  *clientInfo = (MDICLIENTINFO*)clientWnd->wExtra;
@@ -156,7 +156,7 @@
  *
  * returns "activateable" child  or zero
  */
-HWND MDI_GetWindow(WND  *clientWnd, HWND hWnd, WORD wTo )
+static HWND16 MDI_GetWindow(WND  *clientWnd, HWND16 hWnd, WORD wTo )
 {
     MDICLIENTINFO *clientInfo = (MDICLIENTINFO*)clientWnd->wExtra;
     WND *wndPtr, *pWnd, *pWndLast;
@@ -194,10 +194,11 @@
  *
  *  It seems that default height is 2/3 of client rect
  */
-void MDI_CalcDefaultChildPos(WND* w, WORD n, LPPOINT16 lpPos, INT delta)
+static void MDI_CalcDefaultChildPos(WND* w, WORD n, LPPOINT16 lpPos, INT delta)
 {
  RECT16 rect = w->rectClient;
- INT  spacing = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYFRAME) - 1; 
+ INT  spacing = GetSystemMetrics32(SM_CYCAPTION) +
+                GetSystemMetrics32(SM_CYFRAME) - 1; 
  INT  nstagger;
 
  if( rect.bottom - rect.top - delta >= spacing ) 
@@ -210,10 +211,10 @@
 }
 
 /**********************************************************************
- *					MDISetMenu
+ *            MDISetMenu
  */
-HMENU16 MDISetMenu(HWND hwnd, BOOL fRefresh, HMENU16 hmenuFrame,
-                   HMENU16 hmenuWindow)
+static HMENU16 MDISetMenu(HWND16 hwnd, BOOL32 fRefresh, HMENU16 hmenuFrame,
+                          HMENU16 hmenuWindow)
 {
     WND           *w         = WIN_FindWndPtr(hwnd);
     MDICLIENTINFO *ci;
@@ -225,7 +226,7 @@
 
     if (!fRefresh) 
        {
-	HWND hwndFrame = GetParent16(hwnd);
+	HWND16 hwndFrame = GetParent16(hwnd);
 	HMENU32 oldFrameMenu = GetMenu32(hwndFrame);
         
 	if( ci->hwndChildMaximized && hmenuFrame && hmenuFrame!=oldFrameMenu )
@@ -280,9 +281,9 @@
 }
 
 /**********************************************************************
- *					MDIIconArrange
+ *            MDIIconArrange
  */
-WORD MDIIconArrange(HWND parent)
+static WORD MDIIconArrange(HWND16 parent)
 {
   return ArrangeIconicWindows16(parent);	/* Any reason why the    */
 						/* existing icon arrange */
@@ -297,20 +298,15 @@
 /**********************************************************************
  *					MDICreateChild
  */
-HWND MDICreateChild(WND *w, MDICLIENTINFO *ci, HWND parent, LPARAM lParam )
+static HWND16 MDICreateChild( WND *w, MDICLIENTINFO *ci, HWND16 parent, 
+                              LPMDICREATESTRUCT16 cs, LPARAM lParam )
 {
     POINT16          pos[2]; 
-    MDICREATESTRUCT16 *cs = (MDICREATESTRUCT16 *)PTR_SEG_TO_LIN(lParam);
     DWORD	     style = cs->style | (WS_CHILD | WS_CLIPSIBLINGS);
-    HWND 	     hwnd, hwndMax = 0;
+    HWND16 	     hwnd, hwndMax = 0;
     WORD	     wIDmenu = ci->idFirstChild + ci->nActiveChildren;
     char	     lpstrDef[]="junk!";
 
-    /*
-     * Create child window
-     *
-     */
-
     dprintf_mdi(stdnimp,"MDICreateChild: origin %i,%i - dim %i,%i, style %08x\n", 
 					 cs->x, cs->y, cs->cx, cs->cy, (unsigned)cs->style);    
     /* calculate placement */
@@ -353,9 +349,9 @@
 
     hwnd = CreateWindow16( (LPCSTR)PTR_SEG_TO_LIN(cs->szClass),
                            (LPCSTR)PTR_SEG_TO_LIN(cs->szTitle), style, 
-			  cs->x, cs->y, cs->cx, cs->cy, parent, 
-                         (HMENU16)wIDmenu, w->hInstance, 
-			 (LPVOID)lParam);
+                           cs->x, cs->y, cs->cx, cs->cy, parent, 
+                           (HMENU16)wIDmenu, w->hInstance, 
+                           (LPVOID)lParam);
 
     /* MDI windows are WS_CHILD so they won't be activated by CreateWindow */
 
@@ -397,7 +393,8 @@
 /**********************************************************************
  *			MDI_ChildGetMinMaxInfo
  */
-void MDI_ChildGetMinMaxInfo(WND* clientWnd, HWND hwnd, MINMAXINFO16* lpMinMax )
+static void MDI_ChildGetMinMaxInfo( WND* clientWnd, HWND16 hwnd,
+                                    MINMAXINFO16* lpMinMax )
 {
  WND*	childWnd = WIN_FindWndPtr(hwnd);
  RECT16	rect 	 = clientWnd->rectClient;
@@ -426,11 +423,12 @@
  *	  wTo is basically lParam of WM_MDINEXT message or explicit 
  *        window handle
  */
-void MDI_SwitchActiveChild(HWND clientHwnd, HWND childHwnd, BOOL wTo )
+static void MDI_SwitchActiveChild( HWND16 clientHwnd, HWND16 childHwnd,
+                                   BOOL32 wTo )
 {
     WND		  *w	     = WIN_FindWndPtr(clientHwnd);
-    HWND	   hwndTo    = 0;
-    HWND	   hwndPrev  = 0;
+    HWND16	   hwndTo    = 0;
+    HWND16	   hwndPrev  = 0;
     MDICLIENTINFO *ci;
 
     hwndTo = MDI_GetWindow(w,childHwnd,(WORD)wTo);
@@ -470,8 +468,8 @@
 /**********************************************************************
  *                                      MDIDestroyChild
  */
-HWND MDIDestroyChild(WND *w_parent, MDICLIENTINFO *ci, HWND parent,
-                     HWND child, BOOL flagDestroy)
+static HWND16 MDIDestroyChild( WND *w_parent, MDICLIENTINFO *ci, HWND16 parent,
+                               HWND16 child, BOOL32 flagDestroy )
 {
     WND         *childPtr = WIN_FindWndPtr(child);
 
@@ -516,10 +514,10 @@
  *
  * Note: hWndChild is NULL when last child is being destroyed
  */
-LONG MDI_ChildActivate(WND *clientPtr, HWND hWndChild)
+static LONG MDI_ChildActivate( WND *clientPtr, HWND16 hWndChild )
 {
     MDICLIENTINFO       *clientInfo = (MDICLIENTINFO*)clientPtr->wExtra; 
-    HWND                 prevActiveWnd = clientInfo->hwndActiveChild;
+    HWND16                 prevActiveWnd = clientInfo->hwndActiveChild;
     WND                 *wndPtr = WIN_FindWndPtr( hWndChild );
     WND			*wndPrev = WIN_FindWndPtr( prevActiveWnd );
     BOOL		 isActiveFrameWnd = 0;	 
@@ -610,7 +608,7 @@
  *
  *  iTotal returns number of children available for tiling or cascading
  */
-MDIWCL* MDI_BuildWCL(WND* clientWnd, INT16* iTotal)
+static MDIWCL* MDI_BuildWCL(WND* clientWnd, INT16* iTotal)
 {
     MDIWCL *listTop,*listNext;
     WND    *childWnd;
@@ -628,6 +626,9 @@
     {
 	listNext = (MDIWCL*)xmalloc(sizeof(MDIWCL));
 	
+	/* FIXME: pay attention to MDITILE_SKIPDISABLED 
+	 *        when WIN_ISWIN32 is set.
+	 */
 	if( (childWnd->dwStyle & WS_DISABLED) ||
 	    (childWnd->dwStyle & WS_MINIMIZE) ||
 	    !(childWnd->dwStyle & WS_VISIBLE)   )
@@ -661,7 +662,7 @@
 /**********************************************************************
  *				CreateMDIMenuBitmap
  */
-HBITMAP16 CreateMDIMenuBitmap(void)
+static HBITMAP16 CreateMDIMenuBitmap(void)
 {
  HDC32 		hDCSrc  = CreateCompatibleDC32(0);
  HDC32		hDCDest	= CreateCompatibleDC32(hDCSrc);
@@ -689,7 +690,7 @@
 /**********************************************************************
  *				MDICascade
  */
-LONG MDICascade(WND* clientWnd, MDICLIENTINFO *ci)
+static LONG MDICascade(WND* clientWnd, MDICLIENTINFO *ci)
 {
     MDIWCL	 *listTop,*listPrev;
     INT16	  delta = 0,iToPosition = 0, n = 0;
@@ -733,7 +734,7 @@
  *					MDITile
  *
  */
-LONG MDITile(WND* wndClient, MDICLIENTINFO *ci,WORD wParam)
+static LONG MDITile(WND* wndClient, MDICLIENTINFO *ci,WORD wParam)
 {
     MDIWCL       *listTop,*listPrev;
     RECT16        rect;
@@ -835,7 +836,8 @@
 /**********************************************************************
  *					MDI_AugmentFrameMenu
  */
-BOOL MDI_AugmentFrameMenu(MDICLIENTINFO* ci, WND *frame, HWND hChild)
+static BOOL32 MDI_AugmentFrameMenu( MDICLIENTINFO* ci, WND *frame,
+                                    HWND16 hChild )
 {
  WND*		child = WIN_FindWndPtr(hChild);
  HMENU16  	hSysPopup = 0;
@@ -875,7 +877,7 @@
 /**********************************************************************
  *					MDI_RestoreFrameMenu
  */
-BOOL MDI_RestoreFrameMenu( WND *frameWnd, HWND hChild)
+static BOOL32 MDI_RestoreFrameMenu( WND *frameWnd, HWND16 hChild )
 {
  INT32 nItems = GetMenuItemCount32(frameWnd->wIDmenu) - 1;
 
@@ -900,7 +902,8 @@
  *
  * Note: lpTitle can be NULL
  */
-void MDI_UpdateFrameText(WND *frameWnd, HWND hClient, BOOL repaint, LPCSTR lpTitle)
+static void MDI_UpdateFrameText( WND *frameWnd, HWND16 hClient,
+                                 BOOL32 repaint, LPCSTR lpTitle )
 {
  char   lpBuffer[MDI_MAXTITLELENGTH+1];
  WND* 	clientWnd = WIN_FindWndPtr(hClient);
@@ -972,7 +975,7 @@
  *
  * This function is the handler for all MDI requests.
  */
-LRESULT MDIClientWndProc(HWND hwnd, UINT message, WPARAM16 wParam, LPARAM lParam)
+LRESULT MDIClientWndProc(HWND16 hwnd, UINT message, WPARAM16 wParam, LPARAM lParam)
 {
     LPCREATESTRUCT16     cs;
     LPCLIENTCREATESTRUCT16 ccs;
@@ -987,8 +990,16 @@
     switch (message)
     {
       case WM_CREATE:
-	cs                      = (LPCREATESTRUCT16) PTR_SEG_TO_LIN(lParam);
-	ccs                     = (LPCLIENTCREATESTRUCT16) PTR_SEG_TO_LIN(cs->lpCreateParams);
+
+	cs = (LPCREATESTRUCT16) PTR_SEG_TO_LIN(lParam);
+
+	/* Translation layer doesn't know what's in the cs->lpCreateParams
+	 * so we have to keep track of what environment we're in. */
+
+	if( w->flags & WIN_ISWIN32 )
+	    ccs = (LPCLIENTCREATESTRUCT16) cs->lpCreateParams;
+        else    
+	    ccs = (LPCLIENTCREATESTRUCT16) PTR_SEG_TO_LIN(cs->lpCreateParams);
 
 	ci->hWindowMenu         = ccs->hWindowMenu;
 	ci->idFirstChild        = ccs->idFirstChild;
@@ -1028,18 +1039,23 @@
 	return 0;
 
       case WM_MDIACTIVATE:
-        if( ci->hwndActiveChild != (HWND)wParam )
-	    SetWindowPos32((HWND)wParam, 0,0,0,0,0, SWP_NOSIZE | SWP_NOMOVE ); 
+        if( ci->hwndActiveChild != (HWND16)wParam )
+	    SetWindowPos32((HWND32)wParam, 0,0,0,0,0, SWP_NOSIZE | SWP_NOMOVE ); 
 	return 0;
 
       case WM_MDICASCADE:
 	return MDICascade(w, ci);
 
       case WM_MDICREATE:
-	return (LONG)MDICreateChild(w, ci, hwnd, lParam );
+        if( lParam )
+	{
+	    MDICREATESTRUCT16* cs = (MDICREATESTRUCT16*) PTR_SEG_TO_LIN(lParam);
+	    return (LONG)MDICreateChild(w, ci, hwnd, cs, lParam );
+	}
+	return 0;
 
       case WM_MDIDESTROY:
-	return (LONG)MDIDestroyChild(w, ci, hwnd, (HWND)wParam, TRUE);
+	return (LONG)MDIDestroyChild(w, ci, hwnd, (HWND32)wParam, TRUE);
 
       case WM_MDIGETACTIVE:
 	return ((LONG) ci->hwndActiveChild | 
@@ -1057,7 +1073,7 @@
 	return 0;
 
       case WM_MDINEXT:
-	MDI_SwitchActiveChild(hwnd, (HWND)wParam, (lParam)?1:0);
+	MDI_SwitchActiveChild(hwnd, (HWND16)wParam, (lParam)?1:0);
 	break;
 	
       case WM_MDIRESTORE:
@@ -1081,7 +1097,7 @@
       case WM_VSCROLL:
       case WM_HSCROLL:
 	ci->sbNeedUpdate = TRUE;
-        ScrollChildren(hwnd,message,wParam,lParam);
+        ScrollChildren32(hwnd,message,wParam,lParam);
 	ci->sbNeedUpdate = FALSE;
         return 0;
 
@@ -1103,21 +1119,14 @@
         if( wParam == WM_LBUTTONDOWN )
         {
             POINT16  pt = MAKEPOINT16(lParam);
-            HWND     child = ChildWindowFromPoint16(hwnd, pt);
+            HWND16 child = ChildWindowFromPoint16(hwnd, pt);
 
 	    dprintf_mdi(stddeb,"MDIClient: notification from %04x (%i,%i)\n",child,pt.x,pt.y);
 
-            if( child && child != hwnd )
-              {
-                WND*    wnd = WIN_FindWndPtr( child );
-
-                /* if we got owned popup */
-                if( wnd->owner ) child = wnd->owner->hwndSelf;
-
-                if( child != ci->hwndActiveChild )
-                    SetWindowPos32(child, 0,0,0,0,0, SWP_NOSIZE | SWP_NOMOVE );
-              }
-          }
+            if( child && child != hwnd &&
+			 child != ci->hwndActiveChild )
+                SetWindowPos32(child, 0,0,0,0,0, SWP_NOSIZE | SWP_NOMOVE );
+        }
         return 0;
 
       case WM_SIZE:
@@ -1155,7 +1164,7 @@
 LRESULT DefFrameProc16( HWND16 hwnd, HWND16 hwndMDIClient, UINT16 message, 
                         WPARAM16 wParam, LPARAM lParam )
 {
-    HWND	         childHwnd;
+    HWND16	         childHwnd;
     MDICLIENTINFO*       ci;
     WND*                 wndPtr;
 
@@ -1169,9 +1178,10 @@
 
 	    /* check for possible syscommands for maximized MDI child */
 
-	    if( wParam <  ci->idFirstChild || 
-		wParam >= ci->idFirstChild + ci->nActiveChildren )
-	      {
+	    if( ci && (
+	    	wParam <  ci->idFirstChild || 
+		wParam >= ci->idFirstChild + ci->nActiveChildren
+	    )){
 		if( (wParam - 0xF000) & 0xF00F ) break;
 		switch( wParam )
 		  {
@@ -1265,9 +1275,15 @@
 	    SendMessage32A(hwndMDIClient, message, wParam, lParam);
 	    break;
 
-	  case WM_SETTEXT:
-              return DefFrameProc16( hwnd, hwndMDIClient, message,
-                                     wParam, (LPARAM)PTR_SEG_TO_LIN(lParam) );
+	  case WM_SETTEXT: {
+	  	LRESULT	ret;
+		LPSTR	segstr = SEGPTR_STRDUP((LPSTR)lParam);
+
+                ret = DefFrameProc16(hwnd, hwndMDIClient, message,
+                                     wParam, (LPARAM)SEGPTR_GET(segstr) );
+	        SEGPTR_FREE(segstr);
+		return ret;
+	  }
 	
 	  case WM_SETFOCUS:
 	  case WM_SIZE:
@@ -1299,11 +1315,13 @@
 	    SendMessage32W(hwndMDIClient, message, wParam, lParam);
 	    break;
 
-	  case WM_SETTEXT:
-              /* FIXME: Unicode */
-              return DefFrameProc32A( hwnd, hwndMDIClient, message,
-                                     wParam, lParam );
-	
+	  case WM_SETTEXT: {
+	      LPSTR txt = HEAP_strdupWtoA(GetProcessHeap(),0,(LPWSTR)lParam);
+	      LRESULT ret = DefFrameProc32A( hwnd, hwndMDIClient, message,
+                                     wParam, (DWORD)txt );
+	      HeapFree(GetProcessHeap(),0,txt);
+	      return ret;
+	  }
 	  case WM_SETFOCUS:
 	  case WM_SIZE:
               return DefFrameProc32A( hwnd, hwndMDIClient, message,
@@ -1405,7 +1423,7 @@
 
 	if( wParam == SIZE_MAXIMIZED )
 	  {
-	    HWND hMaxChild = ci->hwndChildMaximized;
+	    HWND16 hMaxChild = ci->hwndChildMaximized;
 
 	    if( hMaxChild == hwnd ) break;
 
@@ -1430,7 +1448,7 @@
 
 	if( wParam == SIZE_MINIMIZED )
 	  {
-	    HWND switchTo = MDI_GetWindow(clientWnd, hwnd, 0);
+	    HWND16 switchTo = MDI_GetWindow(clientWnd, hwnd, 0);
 
 	    if( switchTo )
 	        SendMessage16( switchTo, WM_CHILDACTIVATE, 0, 0L);
@@ -1553,10 +1571,30 @@
 
 
 /**********************************************************************
- *					TranslateMDISysAccel (USER.451)
- *
+ *              CreateMDIWindowA (USER32.78)
  */
-BOOL TranslateMDISysAccel(HWND hwndClient, LPMSG16 msg)
+
+/**********************************************************************
+ *              CreateMDIWindowW (USER32.79)
+ */
+
+/**********************************************************************
+ *             TranslateMDISysAccel32   (USER32.554)
+ */
+BOOL32 TranslateMDISysAccel32( HWND32 hwndClient, LPMSG32 msg )
+{
+    MSG16 msg16;
+ 
+    STRUCT32_MSG32to16(msg,&msg16);
+    /* MDICLIENTINFO is still the same for win32 and win16 ... */
+    return TranslateMDISysAccel16(hwndClient,&msg16);
+}
+
+
+/**********************************************************************
+ *             TranslateMDISysAccel16   (USER.451)
+ */
+BOOL16 TranslateMDISysAccel16( HWND16 hwndClient, LPMSG16 msg )
 {
   WND* clientWnd = WIN_FindWndPtr( hwndClient);
   WND* wnd;
@@ -1580,6 +1618,7 @@
 	case VK_SEPARATOR:
 	     wParam = ( GetKeyState32(VK_SHIFT) & 0x8000 )? SC_NEXTWINDOW: SC_PREVWINDOW;
 	     break;
+        case VK_F4:
 	case VK_RBUTTON:
 	     wParam = SC_CLOSE; 
 	     break;
@@ -1599,7 +1638,7 @@
 /***********************************************************************
  *           CalcChildScroll   (USER.462)
  */
-void CalcChildScroll( HWND hwnd, WORD scroll )
+void CalcChildScroll( HWND16 hwnd, WORD scroll )
 {
     RECT16 childRect, clientRect;
     INT  vmin, vmax, hmin, hmax, vpos, hpos;
@@ -1645,18 +1684,24 @@
       }    
 }
 
+
 /***********************************************************************
- *           ScrollChildren   (USER.463)
+ *           ScrollChildren16   (USER.463)
  */
-void ScrollChildren(HWND hWnd, UINT uMsg, WPARAM16 wParam, LPARAM lParam)
+void ScrollChildren16(HWND16 hWnd, UINT16 uMsg, WPARAM16 wParam, LPARAM lParam)
 {
- WND	*wndPtr = WIN_FindWndPtr(hWnd);
- short 	 newPos=-1;
- short 	 curPos;
- short 	 length;
- INT32 	 minPos;
- INT32 	 maxPos;
- short   shift;
+    return ScrollChildren32( hWnd, uMsg, wParam, lParam );
+}
+
+
+/***********************************************************************
+ *           ScrollChildren32   (USER32.447)
+ */
+void ScrollChildren32(HWND32 hWnd, UINT32 uMsg, WPARAM32 wParam, LPARAM lParam)
+{
+    WND	*wndPtr = WIN_FindWndPtr(hWnd);
+    INT32 newPos = -1;
+    INT32 curPos, length, minPos, maxPos, shift;
 
  if( !wndPtr ) return;
 
diff --git a/windows/message.c b/windows/message.c
index 4ceb269..dfce8b0 100644
--- a/windows/message.c
+++ b/windows/message.c
@@ -30,9 +30,6 @@
 #define WM_NCMOUSEFIRST         WM_NCMOUSEMOVE
 #define WM_NCMOUSELAST          WM_NCMBUTTONDBLCLK
 
-#define HWND_BROADCAST16  ((HWND16)0xffff)
-#define HWND_BROADCAST32  ((HWND32)0xffffffff)
-
 typedef enum { SYSQ_MSG_ABANDON, SYSQ_MSG_SKIP, 
                SYSQ_MSG_ACCEPT, SYSQ_MSG_CONTINUE } SYSQ_STATUS;
 
@@ -41,7 +38,7 @@
 
 DWORD MSG_WineStartTicks; /* Ticks at Wine startup */
 
-static WORD doubleClickSpeed = 452;
+static UINT32 doubleClickSpeed = 452;
 static INT32 debugSMRL = 0;       /* intertask SendMessage() recursion level */
 
 /***********************************************************************
@@ -172,7 +169,7 @@
 	eatMsg = sendSC = 1;
     else if( remove && mouseClick )
     {
-        HWND hwndTop = WIN_GetTopParent( hWnd );
+        HWND32 hwndTop = WIN_GetTopParent( hWnd );
 
 	if( mouseClick == 1 )
 	{
@@ -376,7 +373,7 @@
      AsyncKeyStateTable[VK_LBUTTON]= InputKeyStateTable[VK_LBUTTON] = MouseButtonsStates[0] << 8;
      AsyncKeyStateTable[VK_MBUTTON]= InputKeyStateTable[VK_MBUTTON] = MouseButtonsStates[1] << 8;
      AsyncKeyStateTable[VK_RBUTTON]= InputKeyStateTable[VK_RBUTTON] = MouseButtonsStates[2] << 8;
-     SetCursorPos(tmpMsg->paramL,tmpMsg->paramH);
+     SetCursorPos32(tmpMsg->paramL,tmpMsg->paramH);
      lParam=MAKELONG(tmpMsg->paramL,tmpMsg->paramH);
      wParam=0;             
      if (MouseButtonsStates[0]) wParam |= MK_LBUTTON;
@@ -505,18 +502,37 @@
 
 
 /**********************************************************************
- *           SetDoubleClickTime   (USER.20)
+ *           SetDoubleClickTime16   (USER.20)
  */
-void SetDoubleClickTime( WORD interval )
+void SetDoubleClickTime16( UINT16 interval )
 {
-    doubleClickSpeed = interval ? interval : 500;
+    SetDoubleClickTime32( interval );
 }		
 
 
 /**********************************************************************
- *           GetDoubleClickTime   (USER.21)
+ *           SetDoubleClickTime32   (USER32.479)
  */
-WORD GetDoubleClickTime()
+BOOL32 SetDoubleClickTime32( UINT32 interval )
+{
+    doubleClickSpeed = interval ? interval : 500;
+    return TRUE;
+}		
+
+
+/**********************************************************************
+ *           GetDoubleClickTime16   (USER.21)
+ */
+UINT16 GetDoubleClickTime16(void)
+{
+    return doubleClickSpeed;
+}		
+
+
+/**********************************************************************
+ *           GetDoubleClickTime32   (USER32.238)
+ */
+UINT32 GetDoubleClickTime32(void)
 {
     return doubleClickSpeed;
 }		
@@ -527,7 +543,7 @@
  *
  * Implementation of an inter-task SendMessage.
  */
-static LRESULT MSG_SendMessage( HQUEUE16 hDestQueue, HWND hwnd, UINT msg,
+static LRESULT MSG_SendMessage( HQUEUE16 hDestQueue, HWND16 hwnd, UINT msg,
                                 WPARAM16 wParam, LPARAM lParam )
 {
     INT32	  prevSMRL = debugSMRL;
@@ -643,7 +659,7 @@
 /***********************************************************************
  *           MSG_PeekMessage
  */
-static BOOL MSG_PeekMessage( LPMSG16 msg, HWND hwnd, WORD first, WORD last,
+static BOOL MSG_PeekMessage( LPMSG16 msg, HWND16 hwnd, WORD first, WORD last,
                              WORD flags, BOOL peek )
 {
     int pos, mask;
@@ -879,7 +895,7 @@
 /***********************************************************************
  *           GetMessage   (USER.108)
  */
-BOOL GetMessage( SEGPTR msg, HWND hwnd, UINT first, UINT last ) 
+BOOL GetMessage( SEGPTR msg, HWND16 hwnd, UINT first, UINT last ) 
 {
     MSG16 *lpmsg = (MSG16 *)PTR_SEG_TO_LIN(msg);
     MSG_PeekMessage( lpmsg,
@@ -895,7 +911,7 @@
 /***********************************************************************
  *           PostMessage   (USER.110)
  */
-BOOL PostMessage( HWND hwnd, WORD message, WORD wParam, LONG lParam )
+BOOL PostMessage( HWND16 hwnd, WORD message, WORD wParam, LONG lParam )
 {
     MSG16 	msg;
     WND 	*wndPtr;
@@ -913,7 +929,7 @@
        return TRUE;
 #endif  /* CONFIG_IPC */
     
-    if (hwnd == HWND_BROADCAST16)
+    if (hwnd == HWND_BROADCAST)
     {
         dprintf_msg(stddeb,"PostMessage // HWND_BROADCAST !\n");
         for (wndPtr = WIN_GetDesktop()->child; wndPtr; wndPtr = wndPtr->next)
@@ -970,7 +986,7 @@
     if (DDE_SendMessage(&DDE_msg)) return TRUE;
 #endif  /* CONFIG_IPC */
 
-    if (hwnd == HWND_BROADCAST16)
+    if (hwnd == HWND_BROADCAST)
     {
         dprintf_msg(stddeb,"SendMessage // HWND_BROADCAST !\n");
         list = WIN_BuildWinArray( WIN_GetDesktop() );
@@ -992,24 +1008,18 @@
 
     if (HOOK_IsHooked( WH_CALLWNDPROC ))
     {
-	struct msgstruct
-	{
-	    LPARAM   lParam;
-	    WPARAM16 wParam;
-	    UINT16   wMsg;
-	    HWND16   hWnd;
-	} *pmsg;
+	LPCWPSTRUCT16 pmsg;
 
-	if ((pmsg = SEGPTR_NEW(struct msgstruct)))
+	if ((pmsg = SEGPTR_NEW(CWPSTRUCT16)))
 	{
-	    pmsg->hWnd   = hwnd;
-	    pmsg->wMsg   = msg;
+	    pmsg->hwnd   = hwnd;
+	    pmsg->message= msg;
 	    pmsg->wParam = wParam;
 	    pmsg->lParam = lParam;
 	    HOOK_CallHooks16( WH_CALLWNDPROC, HC_ACTION, 1,
 			      (LPARAM)SEGPTR_GET(pmsg) );
-	    hwnd   = pmsg->hWnd;
-	    msg    = pmsg->wMsg;
+	    hwnd   = pmsg->hwnd;
+	    msg    = pmsg->message;
 	    wParam = pmsg->wParam;
 	    lParam = pmsg->lParam;
 	    SEGPTR_FREE( pmsg );
@@ -1033,6 +1043,26 @@
     return ret;
 }
 
+/************************************************************************
+ *	     MSG_CallWndProcHook32
+ */
+static void  MSG_CallWndProcHook32( LPMSG32 pmsg, BOOL32 bUnicode )
+{
+   CWPSTRUCT32 cwp;
+
+   cwp.lParam = pmsg->lParam;
+   cwp.wParam = pmsg->wParam;
+   cwp.message = pmsg->message;
+   cwp.hwnd = pmsg->hwnd;
+
+   if (bUnicode) HOOK_CallHooks32W(WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp);
+   else HOOK_CallHooks32A( WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp );
+
+   pmsg->lParam = cwp.lParam;
+   pmsg->wParam = cwp.wParam;
+   pmsg->message = cwp.message;
+   pmsg->hwnd = cwp.hwnd;
+}
 
 /***********************************************************************
  *           SendMessage32A   (USER32.453)
@@ -1043,7 +1073,7 @@
     WND **list, **ppWnd;
     LRESULT ret;
 
-    if (hwnd == HWND_BROADCAST32)
+    if (hwnd == HWND_BROADCAST)
     {
         list = WIN_BuildWinArray( WIN_GetDesktop() );
         for (ppWnd = list; *ppWnd; ppWnd++)
@@ -1057,7 +1087,8 @@
         return TRUE;
     }
 
-    /* FIXME: call hooks */
+    if (HOOK_IsHooked( WH_CALLWNDPROC ))
+	MSG_CallWndProcHook32( (LPMSG32)&hwnd, FALSE);
 
     if (!(wndPtr = WIN_FindWndPtr( hwnd )))
     {
@@ -1065,24 +1096,12 @@
         return 0;
     }
 
-    if (WINPROC_GetProcType( wndPtr->winproc ) == WIN_PROC_16)
-    {
-        /* Use SendMessage16 for now to get hooks right */
-        UINT16 msg16;
-        WPARAM16 wParam16;
-        if (WINPROC_MapMsg32ATo16( msg, wParam, &msg16, &wParam16, &lParam ) == -1)
-            return 0;
-        ret = SendMessage16( hwnd, msg16, wParam16, lParam );
-        WINPROC_UnmapMsg32ATo16( msg, wParam16, lParam );
-        return ret;
-    }
-
     if (QUEUE_IsDoomedQueue(wndPtr->hmemTaskQ))
         return 0;  /* Don't send anything if the task is dying */
 
     if (wndPtr->hmemTaskQ != GetTaskQueue(0))
     {
-        fprintf( stderr, "SendMessage32A: intertask message not supported\n" );
+        fprintf( stderr, "SendMessage32A: intertask message [%04x] not supported\n", msg );
         return 0;
     }
 
@@ -1103,7 +1122,7 @@
     WND **list, **ppWnd;
     LRESULT ret;
 
-    if (hwnd == HWND_BROADCAST32)
+    if (hwnd == HWND_BROADCAST)
     {
         list = WIN_BuildWinArray( WIN_GetDesktop() );
         for (ppWnd = list; *ppWnd; ppWnd++)
@@ -1117,7 +1136,8 @@
         return TRUE;
     }
 
-    /* FIXME: call hooks */
+    if (HOOK_IsHooked( WH_CALLWNDPROC ))
+        MSG_CallWndProcHook32( (LPMSG32)&hwnd, TRUE);
 
     if (!(wndPtr = WIN_FindWndPtr( hwnd )))
     {
@@ -1141,7 +1161,7 @@
 
 
 /***********************************************************************
- *           WaitMessage    (USER.112)
+ *           WaitMessage    (USER.112) (USER32.577)
  */
 void WaitMessage( void )
 {
@@ -1149,126 +1169,144 @@
 }
 
 
+struct accent_char
+{
+    BYTE ac_accent;
+    BYTE ac_char;
+    BYTE ac_result;
+};
+
+static const struct accent_char accent_chars[] =
+{
+    {'`', 'A', '\300'},  {'`', 'a', '\340'},
+    {'\'', 'A', '\301'}, {'\'', 'a', '\341'},
+    {'^', 'A', '\302'},  {'^', 'a', '\342'},
+    {'~', 'A', '\303'},  {'~', 'a', '\343'},
+    {'"', 'A', '\304'},  {'"', 'a', '\344'},
+    {'O', 'A', '\305'},  {'o', 'a', '\345'},
+    {'0', 'A', '\305'},  {'0', 'a', '\345'},
+    {'A', 'A', '\305'},  {'a', 'a', '\345'},
+    {'A', 'E', '\306'},  {'a', 'e', '\346'},
+    {',', 'C', '\307'},  {',', 'c', '\347'},
+    {'`', 'E', '\310'},  {'`', 'e', '\350'},
+    {'\'', 'E', '\311'}, {'\'', 'e', '\351'},
+    {'^', 'E', '\312'},  {'^', 'e', '\352'},
+    {'"', 'E', '\313'},  {'"', 'e', '\353'},
+    {'`', 'I', '\314'},  {'`', 'i', '\354'},
+    {'\'', 'I', '\315'}, {'\'', 'i', '\355'},
+    {'^', 'I', '\316'},  {'^', 'i', '\356'},
+    {'"', 'I', '\317'},  {'"', 'i', '\357'},
+    {'-', 'D', '\320'},  {'-', 'd', '\360'},
+    {'~', 'N', '\321'},  {'~', 'n', '\361'},
+    {'`', 'O', '\322'},  {'`', 'o', '\362'},
+    {'\'', 'O', '\323'}, {'\'', 'o', '\363'},
+    {'^', 'O', '\324'},  {'^', 'o', '\364'},
+    {'~', 'O', '\325'},  {'~', 'o', '\365'},
+    {'"', 'O', '\326'},  {'"', 'o', '\366'},
+    {'/', 'O', '\330'},  {'/', 'o', '\370'},
+    {'`', 'U', '\331'},  {'`', 'u', '\371'},
+    {'\'', 'U', '\332'}, {'\'', 'u', '\372'},
+    {'^', 'U', '\333'},  {'^', 'u', '\373'},
+    {'"', 'U', '\334'},  {'"', 'u', '\374'},
+    {'\'', 'Y', '\335'}, {'\'', 'y', '\375'},
+    {'T', 'H', '\336'},  {'t', 'h', '\376'},
+    {'s', 's', '\337'},  {'"', 'y', '\377'},
+    {'s', 'z', '\337'},  {'i', 'j', '\377'},
+};
+
+
 /***********************************************************************
- *           TranslateMessage   (USER.113)
+ *           MSG_DoTranslateMessage
  *
- * TranlateMessage translate virtual-key messages into character-messages,
+ * Implementation of TranslateMessage.
+ *
+ * TranslateMessage translates virtual-key messages into character-messages,
  * as follows :
  * WM_KEYDOWN/WM_KEYUP combinations produce a WM_CHAR or WM_DEADCHAR message.
  * ditto replacing WM_* with WM_SYS*
  * This produces WM_CHAR messages only for keys mapped to ASCII characters
  * by the keyboard driver.
  */
-
-const struct accent_char
-	{
-	BYTE ac_accent;
-	BYTE ac_char;
-	BYTE ac_result;
-	} accent_chars[] =
-	{
-	{'`', 'A', '\300'},	{'`', 'a', '\340'},
-	{'\'', 'A', '\301'},	{'\'', 'a', '\341'},
-	{'^', 'A', '\302'},	{'^', 'a', '\342'},
-	{'~', 'A', '\303'},	{'~', 'a', '\343'},
-	{'"', 'A', '\304'},	{'"', 'a', '\344'},
-	{'O', 'A', '\305'},	{'o', 'a', '\345'},
-	{'0', 'A', '\305'},	{'0', 'a', '\345'},
-	{'A', 'A', '\305'},	{'a', 'a', '\345'},
-	{'A', 'E', '\306'},	{'a', 'e', '\346'},
-	{',', 'C', '\307'},	{',', 'c', '\347'},
-	{'`', 'E', '\310'},	{'`', 'e', '\350'},
-	{'\'', 'E', '\311'},	{'\'', 'e', '\351'},
-	{'^', 'E', '\312'},	{'^', 'e', '\352'},
-	{'"', 'E', '\313'},	{'"', 'e', '\353'},
-	{'`', 'I', '\314'},	{'`', 'i', '\354'},
-	{'\'', 'I', '\315'},	{'\'', 'i', '\355'},
-	{'^', 'I', '\316'},	{'^', 'i', '\356'},
-	{'"', 'I', '\317'},	{'"', 'i', '\357'},
-	{'-', 'D', '\320'},	{'-', 'd', '\360'},
-	{'~', 'N', '\321'},	{'~', 'n', '\361'},
-	{'`', 'O', '\322'},	{'`', 'o', '\362'},
-	{'\'', 'O', '\323'},	{'\'', 'o', '\363'},
-	{'^', 'O', '\324'},	{'^', 'o', '\364'},
-	{'~', 'O', '\325'},	{'~', 'o', '\365'},
-	{'"', 'O', '\326'},	{'"', 'o', '\366'},
-	{'/', 'O', '\330'},	{'/', 'o', '\370'},
-	{'`', 'U', '\331'},	{'`', 'u', '\371'},
-	{'\'', 'U', '\332'},	{'\'', 'u', '\372'},
-	{'^', 'U', '\333'},	{'^', 'u', '\373'},
-	{'"', 'U', '\334'},	{'"', 'u', '\374'},
-	{'\'', 'Y', '\335'},	{'\'', 'y', '\375'},
-	{'T', 'H', '\336'},	{'t', 'h', '\376'},
-	{'s', 's', '\337'},	{'"', 'y', '\377'},
-	{'s', 'z', '\337'},	{'i', 'j', '\377'},
-	};
-
-BOOL TranslateMessage( LPMSG16 msg )
+static BOOL32 MSG_DoTranslateMessage( UINT32 message, HWND32 hwnd,
+                                      WPARAM32 wParam, LPARAM lParam )
 {
-    UINT message = msg->message;
-    BYTE wparam[2];
+    static int dead_char;
+    BYTE wp[2];
     
-    if ((debugging_msg
-	&& message != WM_MOUSEMOVE && message != WM_TIMER)
-    || (debugging_key
-	&& message >= WM_KEYFIRST && message <= WM_KEYLAST))
-	    fprintf(stddeb, "TranslateMessage(%s, %04X, %08lX)\n",
-		SPY_GetMsgName(msg->message), msg->wParam, msg->lParam);
-    if ((message == WM_KEYDOWN) || (message == WM_SYSKEYDOWN))
+    if ((debugging_msg && message != WM_MOUSEMOVE && message != WM_TIMER)
+        || (debugging_key
+            && message >= WM_KEYFIRST && message <= WM_KEYLAST))
+        fprintf(stddeb, "TranslateMessage(%s, %04X, %08lX)\n",
+		SPY_GetMsgName(message), wParam, lParam );
+
+    if ((message != WM_KEYDOWN) && (message != WM_SYSKEYDOWN)) return FALSE;
+
+    dprintf_key( stddeb, "Translating key %04X, scancode %04X\n",
+                 wParam, HIWORD(lParam) );
+
+    /* FIXME : should handle ToAscii yielding 2 */
+    switch (ToAscii32(wParam, HIWORD(lParam),
+                      QueueKeyStateTable,(LPWORD)wp, 0)) 
     {
-	static dead_char;
+    case 1 :
+        message = (message == WM_KEYDOWN) ? WM_CHAR : WM_SYSCHAR;
+        /* Should dead chars handling go in ToAscii ? */
+        if (dead_char)
+        {
+            int i;
 
-	if (debugging_msg || debugging_key)
-	    fprintf(stddeb, "Translating key %04X, scancode %04X\n",
-		msg->wParam, HIWORD(msg->lParam) );
+            if (wp[0] == ' ') wp[0] =  dead_char;
+            if (dead_char == 0xa8) dead_char = '"';
+            else if (dead_char == 0xb4) dead_char = '\'';
+            for (i = 0; i < sizeof(accent_chars)/sizeof(accent_chars[0]); i++)
+                if ((accent_chars[i].ac_accent == dead_char) &&
+                    (accent_chars[i].ac_char == wp[0]))
+                {
+                    wp[0] = accent_chars[i].ac_result;
+                    break;
+                }
+            dead_char = 0;
+        }
+        dprintf_key(stddeb, "1 -> PostMessage(%s)\n", SPY_GetMsgName(message));
+        PostMessage( hwnd, message, wp[0], lParam );
+        return TRUE;
 
-	/* FIXME : should handle ToAscii yielding 2 */
-	switch (ToAscii32(msg->wParam, HIWORD(msg->lParam),
-		QueueKeyStateTable,(LPWORD)wparam, 0)) 
-	    {
-	    case 1 :
-		message = message == WM_KEYDOWN ? WM_CHAR : WM_SYSCHAR;
-		/* Should dead chars handling go in ToAscii ? */
-		if (dead_char)
-		    {
-		    int i;
-
-		    if (wparam[0] == ' ')
-			wparam[0] =  dead_char;
-		    if (dead_char == 0xa8)
-			dead_char = '"';
-		    else if (dead_char == 0xb4)
-			dead_char = '\'';
-		    for (i = 0;
-			i < sizeof(accent_chars) / sizeof(accent_chars[0]);
-			i += 1)
-			if (accent_chars[i].ac_accent == dead_char
-			&& accent_chars[i].ac_char == wparam[0])
-			    {
-			    wparam[0] = accent_chars[i].ac_result;
-			    break;
-			    }
-		    dead_char = 0;
-		    }
-dprintf_key(stddeb, "1 -> PostMessage(%s)\n", SPY_GetMsgName(message));
-		PostMessage( msg->hwnd, message, wparam[0], msg->lParam );
-		return TRUE;
-	    case -1 :
-		message = message == WM_KEYDOWN ? WM_DEADCHAR : WM_SYSDEADCHAR;
-		dead_char = wparam[0];
-dprintf_key(stddeb, "-1 -> PostMessage(%s)\n", SPY_GetMsgName(message));
-		PostMessage( msg->hwnd, message, wparam[0], msg->lParam );
-		return TRUE;
-	    }
+    case -1 :
+        message = (message == WM_KEYDOWN) ? WM_DEADCHAR : WM_SYSDEADCHAR;
+        dead_char = wp[0];
+        dprintf_key( stddeb, "-1 -> PostMessage(%s)\n",
+                     SPY_GetMsgName(message));
+        PostMessage( hwnd, message, wp[0], lParam );
+        return TRUE;
     }
     return FALSE;
 }
 
 
 /***********************************************************************
- *           DispatchMessage   (USER.114)
+ *           TranslateMessage16   (USER.113)
  */
-LONG DispatchMessage( const MSG16* msg )
+BOOL16 TranslateMessage16( const MSG16 *msg )
+{
+    return MSG_DoTranslateMessage( msg->message, msg->hwnd,
+                                   msg->wParam, msg->lParam );
+}
+
+
+/***********************************************************************
+ *           TranslateMessage32   (USER32.555)
+ */
+BOOL32 TranslateMessage32( const MSG32 *msg )
+{
+    return MSG_DoTranslateMessage( msg->message, msg->hwnd,
+                                   msg->wParam, msg->lParam );
+}
+
+
+/***********************************************************************
+ *           DispatchMessage16   (USER.114)
+ */
+LONG DispatchMessage16( const MSG16* msg )
 {
     WND * wndPtr;
     LONG retval;
@@ -1313,6 +1351,100 @@
 
 
 /***********************************************************************
+ *           DispatchMessage32A   (USER32.140)
+ */
+LONG DispatchMessage32A( const MSG32* msg )
+{
+    WND * wndPtr;
+    LONG retval;
+    int painting;
+    
+      /* Process timer messages */
+    if ((msg->message == WM_TIMER) || (msg->message == WM_SYSTIMER))
+    {
+	if (msg->lParam)
+        {
+/*            HOOK_CallHooks32A( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
+	    return CallWindowProc32A( (WNDPROC32)msg->lParam, msg->hwnd,
+                                   msg->message, msg->wParam, GetTickCount() );
+        }
+    }
+
+    if (!msg->hwnd) return 0;
+    if (!(wndPtr = WIN_FindWndPtr( msg->hwnd ))) return 0;
+    if (!wndPtr->winproc) return 0;
+    painting = (msg->message == WM_PAINT);
+    if (painting) wndPtr->flags |= WIN_NEEDS_BEGINPAINT;
+/*    HOOK_CallHooks32A( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
+
+    SPY_EnterMessage( SPY_DISPATCHMESSAGE32, msg->hwnd, msg->message,
+                      msg->wParam, msg->lParam );
+    retval = CallWindowProc32A( (WNDPROC32)wndPtr->winproc,
+                                msg->hwnd, msg->message,
+                                msg->wParam, msg->lParam );
+    SPY_ExitMessage( SPY_RESULT_OK32, msg->hwnd, msg->message, retval );
+
+    if (painting && (wndPtr = WIN_FindWndPtr( msg->hwnd )) &&
+        (wndPtr->flags & WIN_NEEDS_BEGINPAINT) && wndPtr->hrgnUpdate)
+    {
+	fprintf(stderr, "BeginPaint not called on WM_PAINT for hwnd %04x!\n", 
+		msg->hwnd);
+	wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT;
+        /* Validate the update region to avoid infinite WM_PAINT loop */
+        ValidateRect32( msg->hwnd, NULL );
+    }
+    return retval;
+}
+
+
+/***********************************************************************
+ *           DispatchMessage32W   (USER32.141)
+ */
+LONG DispatchMessage32W( const MSG32* msg )
+{
+    WND * wndPtr;
+    LONG retval;
+    int painting;
+    
+      /* Process timer messages */
+    if ((msg->message == WM_TIMER) || (msg->message == WM_SYSTIMER))
+    {
+	if (msg->lParam)
+        {
+/*            HOOK_CallHooks32W( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
+	    return CallWindowProc32W( (WNDPROC32)msg->lParam, msg->hwnd,
+                                   msg->message, msg->wParam, GetTickCount() );
+        }
+    }
+
+    if (!msg->hwnd) return 0;
+    if (!(wndPtr = WIN_FindWndPtr( msg->hwnd ))) return 0;
+    if (!wndPtr->winproc) return 0;
+    painting = (msg->message == WM_PAINT);
+    if (painting) wndPtr->flags |= WIN_NEEDS_BEGINPAINT;
+/*    HOOK_CallHooks32W( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
+
+    SPY_EnterMessage( SPY_DISPATCHMESSAGE32, msg->hwnd, msg->message,
+                      msg->wParam, msg->lParam );
+    retval = CallWindowProc32W( (WNDPROC32)wndPtr->winproc,
+                                msg->hwnd, msg->message,
+                                msg->wParam, msg->lParam );
+    SPY_ExitMessage( SPY_RESULT_OK32, msg->hwnd, msg->message, retval );
+
+    if (painting && (wndPtr = WIN_FindWndPtr( msg->hwnd )) &&
+        (wndPtr->flags & WIN_NEEDS_BEGINPAINT) && wndPtr->hrgnUpdate)
+    {
+	fprintf(stderr, "BeginPaint not called on WM_PAINT for hwnd %04x!\n", 
+		msg->hwnd);
+	wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT;
+        /* Validate the update region to avoid infinite WM_PAINT loop */
+        ValidateRect32( msg->hwnd, NULL );
+    }
+    return retval;
+}
+
+
+/***********************************************************************
  *           RegisterWindowMessage16   (USER.118)
  */
 WORD RegisterWindowMessage16( SEGPTR str )
@@ -1354,24 +1486,33 @@
 
 
 /***********************************************************************
- *           GetCurrentTime    (USER.15)
+ *           GetCurrentTime16    (USER.15)
  *
  * (effectively identical to GetTickCount)
  */
-DWORD GetCurrentTime(void)
+DWORD GetCurrentTime16(void)
 {
     return GetTickCount();
 }
 
 
 /***********************************************************************
- *           InSendMessage    (USER.192)
+ *           InSendMessage16    (USER.192)
  */
-BOOL InSendMessage()
+BOOL16 InSendMessage16(void)
+{
+    return InSendMessage32();
+}
+
+
+/***********************************************************************
+ *           InSendMessage32    (USER32.319)
+ */
+BOOL32 InSendMessage32(void)
 {
     MESSAGEQUEUE *queue;
 
     if (!(queue = (MESSAGEQUEUE *)GlobalLock16( GetTaskQueue(0) )))
         return 0;
-    return (BOOL)queue->InSendMessageHandle;
+    return (BOOL32)queue->InSendMessageHandle;
 }
diff --git a/windows/msgbox.c b/windows/msgbox.c
index 1ad540d..d8a0978 100644
--- a/windows/msgbox.c
+++ b/windows/msgbox.c
@@ -173,7 +173,7 @@
      case IDIGNORE:
      case IDYES:
      case IDNO:
-      EndDialog(hwnd, wParam);
+      EndDialog32(hwnd, wParam);
       break;
     }
     break;
diff --git a/windows/nonclient.c b/windows/nonclient.c
index ba5f6cc..d4001a1 100644
--- a/windows/nonclient.c
+++ b/windows/nonclient.c
@@ -268,7 +268,7 @@
  * but without the borders (if any).
  * The rectangle is in window coordinates (for drawing with GetWindowDC()).
  */
-static void NC_GetInsideRect( HWND hwnd, RECT32 *rect )
+static void NC_GetInsideRect( HWND32 hwnd, RECT32 *rect )
 {
     WND * wndPtr = WIN_FindWndPtr( hwnd );
 
@@ -457,7 +457,7 @@
 /***********************************************************************
  *           NC_DrawMaxButton
  */
-static void NC_DrawMaxButton( HWND hwnd, HDC16 hdc, BOOL down )
+static void NC_DrawMaxButton( HWND32 hwnd, HDC16 hdc, BOOL down )
 {
     RECT32 rect;
     WND *wndPtr = WIN_FindWndPtr( hwnd );
@@ -477,7 +477,7 @@
 /***********************************************************************
  *           NC_DrawMinButton
  */
-static void NC_DrawMinButton( HWND hwnd, HDC16 hdc, BOOL down )
+static void NC_DrawMinButton( HWND32 hwnd, HDC16 hdc, BOOL down )
 {
     RECT32 rect;
     WND *wndPtr = WIN_FindWndPtr( hwnd );
@@ -589,7 +589,7 @@
  * Draw the window caption.
  * The correct pen for the window frame must be selected in the DC.
  */
-static void NC_DrawCaption( HDC16 hdc, RECT16 *rect, HWND hwnd,
+static void NC_DrawCaption( HDC16 hdc, RECT16 *rect, HWND32 hwnd,
 			    DWORD style, BOOL active )
 {
     RECT16 r = *rect;
@@ -647,8 +647,8 @@
 
     if (GetWindowText32A( hwnd, buffer, sizeof(buffer) ))
     {
-	if (active) SetTextColor( hdc, GetSysColor( COLOR_CAPTIONTEXT ) );
-	else SetTextColor( hdc, GetSysColor( COLOR_INACTIVECAPTIONTEXT ) );
+	if (active) SetTextColor( hdc, GetSysColor32( COLOR_CAPTIONTEXT ) );
+	else SetTextColor( hdc, GetSysColor32( COLOR_INACTIVECAPTIONTEXT ) );
 	SetBkMode32( hdc, TRANSPARENT );
 	DrawText16( hdc, buffer, -1, &r,
                     DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_NOPREFIX );
@@ -805,7 +805,7 @@
 	    WORD msg = HIWORD( lParam );
 	    if ((msg == WM_LBUTTONDOWN) || (msg == WM_MBUTTONDOWN) ||
 		(msg == WM_RBUTTONDOWN))
-		MessageBeep(0);
+		MessageBeep32(0);
 	}
 	break;
 
@@ -815,7 +815,7 @@
 	    if (!(wndPtr = WIN_FindWndPtr( hwnd ))) break;
 	    if (wndPtr->class->hCursor)
 	    {
-		SetCursor( wndPtr->class->hCursor );
+		SetCursor16( wndPtr->class->hCursor );
 		return TRUE;
 	    }
 	    else return FALSE;
@@ -823,23 +823,23 @@
 
     case HTLEFT:
     case HTRIGHT:
-	return (LONG)SetCursor( LoadCursor16( 0, IDC_SIZEWE ) );
+	return (LONG)SetCursor16( LoadCursor16( 0, IDC_SIZEWE ) );
 
     case HTTOP:
     case HTBOTTOM:
-	return (LONG)SetCursor( LoadCursor16( 0, IDC_SIZENS ) );
+	return (LONG)SetCursor16( LoadCursor16( 0, IDC_SIZENS ) );
 
     case HTTOPLEFT:
     case HTBOTTOMRIGHT:	
-	return (LONG)SetCursor( LoadCursor16( 0, IDC_SIZENWSE ) );
+	return (LONG)SetCursor16( LoadCursor16( 0, IDC_SIZENWSE ) );
 
     case HTTOPRIGHT:
     case HTBOTTOMLEFT:
-	return (LONG)SetCursor( LoadCursor16( 0, IDC_SIZENESW ) );
+	return (LONG)SetCursor16( LoadCursor16( 0, IDC_SIZENESW ) );
     }
 
     /* Default cursor: arrow */
-    return (LONG)SetCursor( LoadCursor16( 0, IDC_ARROW ) );
+    return (LONG)SetCursor16( LoadCursor16( 0, IDC_ARROW ) );
 }
 
 /***********************************************************************
@@ -870,7 +870,7 @@
  *
  * Track a mouse button press on the system menu.
  */
-static void NC_TrackSysMenu( HWND hwnd, POINT16 pt )
+static void NC_TrackSysMenu( HWND32 hwnd, POINT16 pt )
 {
     WND*	wndPtr = WIN_FindWndPtr( hwnd );
     
@@ -928,7 +928,8 @@
  * Initialisation of a move or resize, when initiatied from a menu choice.
  * Return hit test code for caption or sizing border.
  */
-static LONG NC_StartSizeMove( HWND hwnd, WPARAM16 wParam, POINT16 *capturePoint )
+static LONG NC_StartSizeMove( HWND32 hwnd, WPARAM16 wParam,
+                              POINT16 *capturePoint )
 {
     LONG hittest = 0;
     POINT16 pt;
@@ -1000,7 +1001,7 @@
 	}
     }
     *capturePoint = pt;
-    SetCursorPos( capturePoint->x, capturePoint->y );
+    SetCursorPos32( capturePoint->x, capturePoint->y );
     NC_HandleSetCursor( hwnd, (WPARAM16)hwnd, MAKELONG( hittest, WM_MOUSEMOVE ));
     return hittest;
 }
@@ -1011,7 +1012,7 @@
  *
  * Perform SC_MOVE and SC_SIZE commands.
  */
-static void NC_DoSizeMove( HWND hwnd, WORD wParam, POINT16 pt )
+static void NC_DoSizeMove( HWND32 hwnd, WORD wParam, POINT16 pt )
 {
     MSG16 msg;
     RECT16 sizingRect, mouseRect;
@@ -1099,8 +1100,8 @@
       if( hIcon )
       {
         hDragCursor =  CURSORICON_IconToCursor( hIcon, TRUE );
-        hOldCursor = SetCursor(hDragCursor);
-        ShowCursor(1);
+        hOldCursor = SetCursor32(hDragCursor);
+        ShowCursor32( TRUE );
       } else iconic = FALSE;
     }
 
@@ -1143,7 +1144,7 @@
 	if (dx || dy)
 	{
             moved = 1;
-	    if (msg.message == WM_KEYDOWN) SetCursorPos( pt.x, pt.y );
+	    if (msg.message == WM_KEYDOWN) SetCursorPos32( pt.x, pt.y );
 	    else
 	    {
 		RECT16 newRect = sizingRect;
@@ -1167,9 +1168,9 @@
     ReleaseCapture();
     if( iconic )
     {
-      ShowCursor(0);
-      SetCursor(hOldCursor);
-      if( hDragCursor ) DestroyCursor(hDragCursor);
+      ShowCursor32( FALSE );
+      SetCursor32(hOldCursor);
+      if( hDragCursor ) DestroyCursor32( hDragCursor );
     }
     else
       NC_DrawMovingFrame( hdc, &sizingRect, thickframe );
@@ -1225,7 +1226,7 @@
  *
  * Track a mouse button press on the minimize or maximize box.
  */
-static void NC_TrackMinMaxBox( HWND hwnd, WORD wParam )
+static void NC_TrackMinMaxBox( HWND32 hwnd, WORD wParam )
 {
     MSG16 msg;
     HDC32 hdc = GetWindowDC32( hwnd );
@@ -1306,8 +1307,8 @@
             SCROLL_HandleScrollEvent( hwnd, scrollbar, msg->message, pt );
 	    break;
         default:
-            TranslateMessage( msg );
-            DispatchMessage( msg );
+            TranslateMessage16( msg );
+            DispatchMessage16( msg );
             break;
 	}
         if (!IsWindow( hwnd ))
diff --git a/windows/painting.c b/windows/painting.c
index bdc5593..2c5e4f9 100644
--- a/windows/painting.c
+++ b/windows/painting.c
@@ -108,7 +108,7 @@
     wndPtr->hrgnUpdate = 0;
     wndPtr->flags &= ~WIN_INTERNAL_PAINT;
 
-    HideCaret( hwnd );
+    HideCaret32( hwnd );
 
     dprintf_win(stddeb,"hrgnUpdate = %04x, ", hrgnUpdate);
 
@@ -175,7 +175,7 @@
 BOOL16 EndPaint16( HWND16 hwnd, const PAINTSTRUCT16* lps )
 {
     ReleaseDC16( hwnd, lps->hdc );
-    ShowCaret( hwnd );
+    ShowCaret32( hwnd );
     return TRUE;
 }
 
@@ -186,7 +186,7 @@
 BOOL32 EndPaint32( HWND32 hwnd, const PAINTSTRUCT32 *lps )
 {
     ReleaseDC32( hwnd, lps->hdc );
-    ShowCaret( hwnd );
+    ShowCaret32( hwnd );
     return TRUE;
 }
 
@@ -225,7 +225,7 @@
 /***********************************************************************
  *           GetControlBrush    (USER.326)
  */
-HBRUSH16 GetControlBrush( HWND hwnd, HDC16 hdc, WORD control )
+HBRUSH16 GetControlBrush( HWND16 hwnd, HDC16 hdc, UINT16 control )
 {
     return (HBRUSH16)SendMessage32A( GetParent32(hwnd), WM_CTLCOLOR+control,
                                      (WPARAM32)hdc, (LPARAM)hwnd );
diff --git a/windows/queue.c b/windows/queue.c
index 709fa02..dc99aed 100644
--- a/windows/queue.c
+++ b/windows/queue.c
@@ -306,17 +306,20 @@
         !(senderQ = (MESSAGEQUEUE*)GlobalLock16( queue->hSendingTask))) 
 	{ dprintf_msg(stddeb,"\trcm: nothing to do\n"); return; }
 
-    queue->InSendMessageHandle = queue->hSendingTask;
-    if( !(queue->hSendingTask = senderQ->hPrevSendingTask) )
+    if( !senderQ->hPrevSendingTask )
     {
       queue->wakeBits &= ~QS_SENDMESSAGE;	/* no more sent messages */
       queue->changeBits &= ~QS_SENDMESSAGE;
     }
 
-    /* Remove sending queue from the list */
+    /* Save current state on stack */
     prevSender                 = queue->InSendMessageHandle;
     prevCtrlPtr		       = queue->smResultCurrent;
+
+    /* Remove sending queue from the list */
+    queue->InSendMessageHandle = queue->hSendingTask;
     queue->smResultCurrent     = senderQ->smResultInit;
+    queue->hSendingTask	       = senderQ->hPrevSendingTask;
 
     dprintf_msg(stddeb, "\trcm: smResultCurrent = %08x, prevCtrl = %08x\n", 
 				(unsigned)queue->smResultCurrent, (unsigned)prevCtrlPtr );
@@ -488,8 +491,8 @@
 static void QUEUE_WakeSomeone( UINT message )
 {
     WND*	  wndPtr = NULL;
-    HWND          hwnd;
     WORD          wakeBit;
+    HWND32 hwnd;
     MESSAGEQUEUE *queue = pCursorQueue;
 
     if( (message >= WM_KEYFIRST) && (message <= WM_KEYLAST) )
@@ -561,7 +564,7 @@
     if ((pos == sysMsgQueue->nextMessage) && sysMsgQueue->msgCount)
     {
         /* Queue is full, beep (but not on every mouse motion...) */
-        if (message != WM_MOUSEMOVE) MessageBeep(0);
+        if (message != WM_MOUSEMOVE) MessageBeep32(0);
         return;
     }
 
@@ -647,9 +650,18 @@
 
 
 /***********************************************************************
- *           PostQuitMessage   (USER.6)
+ *           PostQuitMessage16   (USER.6)
  */
-void PostQuitMessage( INT exitCode )
+void PostQuitMessage16( INT16 exitCode )
+{
+    PostQuitMessage32( exitCode );
+}
+
+
+/***********************************************************************
+ *           PostQuitMessage32   (USER32.420)
+ */
+void PostQuitMessage32( INT32 exitCode )
 {
     MESSAGEQUEUE *queue;
 
@@ -673,8 +685,8 @@
 /***********************************************************************
  *           GetWindowThreadProcessId   (USER32.312)
  */
-DWORD
-GetWindowThreadProcessId(HWND32 hwnd,LPDWORD process) {
+DWORD GetWindowThreadProcessId( HWND32 hwnd, LPDWORD process )
+{
     HTASK16 htask;
     TDB	*tdb;
 
@@ -695,9 +707,18 @@
 
 
 /***********************************************************************
- *           SetMessageQueue   (USER.266)
+ *           SetMessageQueue16   (USER.266)
  */
-BOOL SetMessageQueue( int size )
+BOOL16 SetMessageQueue16( INT16 size )
+{
+    return SetMessageQueue32( size );
+}
+
+
+/***********************************************************************
+ *           SetMessageQueue32   (USER32.493)
+ */
+BOOL32 SetMessageQueue32( INT32 size )
 {
     HQUEUE16 hQueue, hNewQueue;
     MESSAGEQUEUE *queuePtr;
@@ -757,19 +778,29 @@
 
 
 /***********************************************************************
- *           GetInputState   (USER.335)
+ *           GetInputState16   (USER.335)
  */
-BOOL GetInputState()
+BOOL16 GetInputState16(void)
+{
+    return GetInputState32();
+}
+
+
+/***********************************************************************
+ *           GetInputState32   (USER32.243)
+ */
+BOOL32 GetInputState32(void)
 {
     MESSAGEQUEUE *queue;
 
-    if (!(queue = (MESSAGEQUEUE *)GlobalLock16( GetTaskQueue(0) ))) return FALSE;
+    if (!(queue = (MESSAGEQUEUE *)GlobalLock16( GetTaskQueue(0) )))
+        return FALSE;
     return queue->wakeBits & (QS_KEY | QS_MOUSEBUTTON);
 }
 
 
 /***********************************************************************
- *           GetMessagePos   (USER.119)
+ *           GetMessagePos   (USER.119) (USER32.271)
  */
 DWORD GetMessagePos(void)
 {
@@ -781,7 +812,7 @@
 
 
 /***********************************************************************
- *           GetMessageTime   (USER.120)
+ *           GetMessageTime   (USER.120) (USER32.272)
  */
 LONG GetMessageTime(void)
 {
@@ -793,7 +824,7 @@
 
 
 /***********************************************************************
- *           GetMessageExtraInfo   (USER.288)
+ *           GetMessageExtraInfo   (USER.288) (USER32.270)
  */
 LONG GetMessageExtraInfo(void)
 {
diff --git a/windows/scroll.c b/windows/scroll.c
index 9fec3e0..682b438 100644
--- a/windows/scroll.c
+++ b/windows/scroll.c
@@ -65,7 +65,7 @@
 	  hrgnClip = CreateRectRgnIndirect32( &rc );
 
           if ((hCaretWnd == hwnd) || IsChild32(hwnd,hCaretWnd))
-              HideCaret(hCaretWnd);
+              HideCaret32(hCaretWnd);
           else hCaretWnd = 0;
  
 	  hdc = GetDCEx32(hwnd, hrgnClip, DCX_CACHE | DCX_CLIPSIBLINGS);
@@ -75,7 +75,7 @@
        {
 	  CopyRect32(&rc, rect);
 
-          if (hCaretWnd == hwnd) HideCaret(hCaretWnd);
+          if (hCaretWnd == hwnd) HideCaret32(hCaretWnd);
           else hCaretWnd = 0;
 
 	  hdc = GetDCEx32( hwnd, 0, DCX_CACHE | DCX_USESTYLE );
@@ -114,7 +114,7 @@
 	GetCaretPos32(&pt);
 	pt.x += dx; pt.y += dy;
 	SetCaretPos(pt.x, pt.y);
-	ShowCaret(hCaretWnd);
+	ShowCaret32(hCaretWnd);
     }
     return TRUE;
 }
@@ -331,7 +331,7 @@
            MapWindowPoints32( hCaret, hWnd, (LPPOINT32)&rc, 2 );
            if( IntersectRect32(lprc, lprc, &rc) )
            {
-               HideCaret(0);
+               HideCaret32(0);
   	       lprc->left = pt.x; lprc->top = pt.y;
 	       return TRUE;
            }
@@ -450,7 +450,7 @@
 	if( bCaret )
 	{
 	    SetCaretPos( rc.left + dx, rc.top + dy );
-	    ShowCaret(0);
+	    ShowCaret32(0);
 	}
 
 	if( bOwnRgn && hrgnUpdate ) DeleteObject32( hrgnUpdate );
diff --git a/windows/syscolor.c b/windows/syscolor.c
index 596eceb..7bc455b 100644
--- a/windows/syscolor.c
+++ b/windows/syscolor.c
@@ -46,7 +46,7 @@
 static COLORREF SysColors[NUM_SYS_COLORS];
 
 #define MAKE_SOLID(color) \
-         (PALETTEINDEX(GetNearestPaletteIndex(STOCK_DEFAULT_PALETTE,(color))))
+       (PALETTEINDEX(GetNearestPaletteIndex32(STOCK_DEFAULT_PALETTE,(color))))
 
 /*************************************************************************
  *             SYSCOLOR_SetColor
@@ -145,22 +145,28 @@
 
 
 /*************************************************************************
- *             GetSysColor   (USER.180) (USER32.288)
+ *             GetSysColor16   (USER.180)
  */
-
-COLORREF GetSysColor( INT32 nIndex )
+COLORREF GetSysColor16( INT16 nIndex )
 {
-    dprintf_syscolor(stddeb,"System Color %d = %8lx\n", 
-		    nIndex, SysColors[nIndex]);
     return SysColors[nIndex];
 }
 
 
 /*************************************************************************
- *             SetSysColors          (USER.181)
+ *             GetSysColor32   (USER32.288)
  */
+COLORREF GetSysColor32( INT32 nIndex )
+{
+    return SysColors[nIndex];
+}
 
-void SetSysColors(int nChanges, LPINT16 lpSysColor, COLORREF *lpColorValues)
+
+/*************************************************************************
+ *             SetSysColors16   (USER.181)
+ */
+VOID SetSysColors16( INT16 nChanges, const INT16 *lpSysColor,
+                     const COLORREF *lpColorValues )
 {
     int i;
 
@@ -171,9 +177,35 @@
 
     /* Send WM_SYSCOLORCHANGE message to all windows */
 
-    /* ................ */
+    SendMessage32A( HWND_BROADCAST, WM_SYSCOLORCHANGE, 0, 0 );
 
     /* Repaint affected portions of all visible windows */
 
-    /* ................ */
+    RedrawWindow32( GetDesktopWindow32(), NULL, 0,
+                RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN );
+}
+
+
+/*************************************************************************
+ *             SetSysColors32   (USER32.504)
+ */
+BOOL32 SetSysColors32( INT32 nChanges, const INT32 *lpSysColor,
+                       const COLORREF *lpColorValues )
+{
+    int i;
+
+    for (i = 0; i < nChanges; i++)
+    {
+	SYSCOLOR_SetColor( lpSysColor[i], lpColorValues[i] );
+    }
+
+    /* Send WM_SYSCOLORCHANGE message to all windows */
+
+    SendMessage32A( HWND_BROADCAST, WM_SYSCOLORCHANGE, 0, 0 );
+
+    /* Repaint affected portions of all visible windows */
+
+    RedrawWindow32( GetDesktopWindow32(), NULL, 0,
+                RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN );
+    return TRUE;
 }
diff --git a/windows/sysmetrics.c b/windows/sysmetrics.c
index 5325a86..8bbfb5e 100644
--- a/windows/sysmetrics.c
+++ b/windows/sysmetrics.c
@@ -67,10 +67,20 @@
 
 
 /***********************************************************************
- *           GetSystemMetrics    (USER.179)
+ *           GetSystemMetrics16    (USER.179)
  */
-int GetSystemMetrics( WORD index )
+INT16 GetSystemMetrics16( INT16 index )
 {
-    if (index > SM_CMETRICS) return 0;
+    if ((index < 0) || (index > SM_CMETRICS)) return 0;
+    else return sysMetrics[index];    
+}
+
+
+/***********************************************************************
+ *           GetSystemMetrics32    (USER32.291)
+ */
+INT32 GetSystemMetrics32( INT32 index )
+{
+    if ((index < 0) || (index > SM_CMETRICS)) return 0;
     else return sysMetrics[index];    
 }
diff --git a/windows/win.c b/windows/win.c
index 5d96ee1..da44073 100644
--- a/windows/win.c
+++ b/windows/win.c
@@ -38,7 +38,7 @@
 /* Desktop window */
 static WND *pWndDesktop = NULL;
 
-static HWND hwndSysModal = 0;
+static HWND32 hwndSysModal = 0;
 
 static WORD wDragWidth = 4;
 static WORD wDragHeight= 3;
@@ -47,6 +47,7 @@
 extern HWND32 CARET_GetHwnd(void);
 extern BOOL32 WINPOS_ActivateOtherWindow(WND* pWnd);
 extern void   WINPOS_CheckActive(HWND32);
+extern BOOL32 EVENT_CheckFocus(void);
 
 /***********************************************************************
  *           WIN_FindWndPtr
@@ -224,7 +225,7 @@
  */
 HWND32 WIN_FindWinToRepaint( HWND32 hwnd, HQUEUE16 hQueue )
 {
-    HWND hwndRet;
+    HWND32 hwndRet;
     WND *pWnd = pWndDesktop;
 
     /* Note: the desktop window never gets WM_PAINT messages 
@@ -306,9 +307,9 @@
  *
  * Destroy storage associated to a window. "Internals" p.358
  */
-static void WIN_DestroyWindow( WND* wndPtr )
+static WND* WIN_DestroyWindow( WND* wndPtr )
 {
-    HWND hwnd = wndPtr->hwndSelf;
+    HWND32 hwnd = wndPtr->hwndSelf;
     WND *pWnd;
 
     dprintf_win( stddeb, "WIN_DestroyWindow: %04x\n", wndPtr->hwndSelf );
@@ -321,11 +322,7 @@
     /* free child windows */
 
     while ((pWnd = wndPtr->child))
-    {
-        /* Make sure the linked list remains coherent */
-        wndPtr->child = pWnd->next;
-        WIN_DestroyWindow( pWnd );
-    }
+        wndPtr->child = WIN_DestroyWindow( pWnd );
 
     SendMessage32A( wndPtr->hwndSelf, WM_NCDESTROY, 0, 0);
 
@@ -370,8 +367,10 @@
 
     wndPtr->class->cWindows--;
     wndPtr->class = NULL;
+    pWnd = wndPtr->next;
 
     USER_HEAP_FREE( hwnd );
+    return pWnd;
 }
 
 /***********************************************************************
@@ -400,7 +399,7 @@
 BOOL32 WIN_CreateDesktopWindow(void)
 {
     CLASS *class;
-    HWND hwndDesktop;
+    HWND32 hwndDesktop;
 
     dprintf_win(stddeb,"Creating desktop window\n");
 
@@ -460,14 +459,14 @@
  *
  * Implementation of CreateWindowEx().
  */
-static HWND WIN_CreateWindowEx( CREATESTRUCT32A *cs, ATOM classAtom,
-                                BOOL unicode )
+static HWND32 WIN_CreateWindowEx( CREATESTRUCT32A *cs, ATOM classAtom,
+                                  BOOL32 win32, BOOL32 unicode )
 {
     CLASS *classPtr;
     WND *wndPtr;
     HWND16 hwnd, hwndLinkAfter;
     POINT16 maxSize, maxPos, minTrack, maxTrack;
-    LRESULT wmcreate;
+    LRESULT (*localSend32)(HWND32, UINT32, WPARAM32, LPARAM);
 
     dprintf_win( stddeb, "CreateWindowEx: " );
     if (HIWORD(cs->lpszName)) dprintf_win( stddeb, "'%s' ", cs->lpszName );
@@ -566,7 +565,7 @@
     wndPtr->dwStyle        = cs->style & ~WS_VISIBLE;
     wndPtr->dwExStyle      = cs->dwExStyle;
     wndPtr->wIDmenu        = 0;
-    wndPtr->flags          = 0;
+    wndPtr->flags          = win32 ? WIN_ISWIN32 : 0;
     wndPtr->pVScroll       = NULL;
     wndPtr->pHScroll       = NULL;
     wndPtr->pProp          = NULL;
@@ -585,9 +584,7 @@
 
 	cbtc.lpcs = cs;
 	cbtc.hwndInsertAfter = hwndLinkAfter;
-	wmcreate = !HOOK_CallHooks32A( WH_CBT, HCBT_CREATEWND, hwnd,
-				       (LPARAM)&cbtc );
-	if (!wmcreate)
+	if ( HOOK_CallHooks32A(WH_CBT, HCBT_CREATEWND, hwnd, (LPARAM)&cbtc) )
 	{
 	    dprintf_win(stddeb, "CreateWindowEx: CBT-hook returned 0\n");
 	    USER_HEAP_FREE( hwnd );
@@ -726,85 +723,70 @@
      */
 
     maxPos.x = wndPtr->rectWindow.left; maxPos.y = wndPtr->rectWindow.top;
-    if (unicode)
+
+    localSend32 = unicode ? SendMessage32W : SendMessage32A;
+    if( (*localSend32)( hwnd, WM_NCCREATE, 0, (LPARAM)cs) )
     {
-        if (!SendMessage32W( hwnd, WM_NCCREATE, 0, (LPARAM)cs)) wmcreate = -1;
-        else
-        {
-            WINPOS_SendNCCalcSize( hwnd, FALSE, &wndPtr->rectWindow,
-                                   NULL, NULL, 0, &wndPtr->rectClient );
-	    OffsetRect16(&wndPtr->rectWindow, maxPos.x - wndPtr->rectWindow.left,
-					    maxPos.y - wndPtr->rectWindow.top);
-            wmcreate = SendMessage32W( hwnd, WM_CREATE, 0, (LPARAM)cs );
-        }
-    }
-    else
-    {
-        if (!SendMessage32A( hwnd, WM_NCCREATE, 0, (LPARAM)cs)) wmcreate = -1;
-        else
-        {
-            WINPOS_SendNCCalcSize( hwnd, FALSE, &wndPtr->rectWindow,
-                                   NULL, NULL, 0, &wndPtr->rectClient );
-            OffsetRect16(&wndPtr->rectWindow, maxPos.x - wndPtr->rectWindow.left,
+        WINPOS_SendNCCalcSize( hwnd, FALSE, &wndPtr->rectWindow,
+                               NULL, NULL, 0, &wndPtr->rectClient );
+        OffsetRect16(&wndPtr->rectWindow, maxPos.x - wndPtr->rectWindow.left,
                                             maxPos.y - wndPtr->rectWindow.top);
-            wmcreate = SendMessage32A( hwnd, WM_CREATE, 0, (LPARAM)cs );
+        if( ((*localSend32)( hwnd, WM_CREATE, 0, (LPARAM)cs )) != -1 )
+        {
+            /* Send the size messages */
+
+            if (!(wndPtr->flags & WIN_NEED_SIZE))
+            {
+                /* send it anyway */
+                SendMessage16( hwnd, WM_SIZE, SIZE_RESTORED,
+                        MAKELONG(wndPtr->rectClient.right-wndPtr->rectClient.left,
+                        wndPtr->rectClient.bottom-wndPtr->rectClient.top));
+                SendMessage16( hwnd, WM_MOVE, 0, MAKELONG( wndPtr->rectClient.left,
+                                                   wndPtr->rectClient.top ));
+            }
+
+            WIN_SendParentNotify( hwnd, WM_CREATE, wndPtr->wIDmenu, (LPARAM)hwnd );
+            if (!IsWindow(hwnd)) return 0;
+
+            /* Show the window, maximizing or minimizing if needed */
+
+            if (wndPtr->dwStyle & WS_MINIMIZE)
+            {
+                /* MinMaximize(hwnd, SW_SHOWMINNOACTIVE, 1) in "Internals" */
+
+                wndPtr->dwStyle &= ~WS_MAXIMIZE;
+                WINPOS_FindIconPos( hwnd );
+                SetWindowPos32( hwnd, 0, wndPtr->ptIconPos.x, wndPtr->ptIconPos.y,
+                        SYSMETRICS_CXICON, SYSMETRICS_CYICON,
+                        SWP_FRAMECHANGED | ((GetActiveWindow32())? SWP_NOACTIVATE : 0)  );
+            }
+            else if (wndPtr->dwStyle & WS_MAXIMIZE)
+            {
+                /* MinMaximize(hwnd, SW_SHOWMAXIMIZED, 1) */
+
+                NC_GetMinMaxInfo( wndPtr, &maxSize, &maxPos, &minTrack, &maxTrack );
+                SetWindowPos32( hwnd, 0, maxPos.x, maxPos.y, maxSize.x, maxSize.y,
+                    ((GetActiveWindow32())? SWP_NOACTIVATE : 0) | SWP_FRAMECHANGED );
+            }
+
+            if (cs->style & WS_VISIBLE) ShowWindow32( hwnd, SW_SHOW );
+
+            /* Call WH_SHELL hook */
+
+            if (!(wndPtr->dwStyle & WS_CHILD) && !wndPtr->owner)
+                HOOK_CallHooks16( WH_SHELL, HSHELL_WINDOWCREATED, hwnd, 0 );
+
+            dprintf_win(stddeb, "CreateWindowEx: created window %04x\n", hwnd);
+            return hwnd;
         }
     }
-    
-    if (wmcreate == -1)
-    {
-	  /* Abort window creation */
-	dprintf_win(stddeb,"CreateWindowEx: wmcreate==-1, aborting\n");
-        WIN_UnlinkWindow( hwnd );
-        WIN_DestroyWindow( wndPtr );
-	return 0;
-    }
 
-    /* Send the size messages */
+    /* Abort window creation */
 
-    if (!(wndPtr->flags & WIN_NEED_SIZE))
-    {
-	/* send it anyway */
-	SendMessage16( hwnd, WM_SIZE, SIZE_RESTORED,
-                   MAKELONG(wndPtr->rectClient.right-wndPtr->rectClient.left,
-                            wndPtr->rectClient.bottom-wndPtr->rectClient.top));
-        SendMessage16( hwnd, WM_MOVE, 0, MAKELONG( wndPtr->rectClient.left,
-                                                   wndPtr->rectClient.top ));
-    } 
-
-    WIN_SendParentNotify( hwnd, WM_CREATE, wndPtr->wIDmenu, (LPARAM)hwnd );
-    if (!IsWindow(hwnd)) return 0;
-
-    /* Show the window, maximizing or minimizing if needed */
-
-    if (wndPtr->dwStyle & WS_MINIMIZE)
-    {
-	/* MinMaximize(hwnd, SW_SHOWMINNOACTIVE, 1) in "Internals" */
-
-        wndPtr->dwStyle &= ~WS_MAXIMIZE;
-        WINPOS_FindIconPos( hwnd );
-        SetWindowPos32( hwnd, 0, wndPtr->ptIconPos.x, wndPtr->ptIconPos.y,
-                        SYSMETRICS_CXICON, SYSMETRICS_CYICON, 
-                        SWP_FRAMECHANGED | ((GetActiveWindow32())? SWP_NOACTIVATE : 0)  );
-    }
-    else if (wndPtr->dwStyle & WS_MAXIMIZE)
-    {
-	/* MinMaximize(hwnd, SW_SHOWMAXIMIZED, 1) */
-
-        NC_GetMinMaxInfo( wndPtr, &maxSize, &maxPos, &minTrack, &maxTrack );
-        SetWindowPos32( hwnd, 0, maxPos.x, maxPos.y, maxSize.x, maxSize.y,
-            ((GetActiveWindow32())? SWP_NOACTIVATE : 0) | SWP_FRAMECHANGED );
-    }
-    
-    if (cs->style & WS_VISIBLE) ShowWindow32( hwnd, SW_SHOW );
-
-    /* Call WH_SHELL hook */
-
-    if (!(wndPtr->dwStyle & WS_CHILD) && !wndPtr->owner)
-        HOOK_CallHooks16( WH_SHELL, HSHELL_WINDOWCREATED, hwnd, 0 );
-
-    dprintf_win(stddeb, "CreateWindowEx: returning %04x\n", hwnd);
-    return hwnd;
+    dprintf_win(stddeb,"CreateWindowEx: aborted by WM_xxCREATE!\n");
+    WIN_UnlinkWindow( hwnd );
+    WIN_DestroyWindow( wndPtr );
+    return 0;
 }
 
 
@@ -859,7 +841,7 @@
     cs.lpszName       = windowName;
     cs.lpszClass      = className;
     cs.dwExStyle      = exStyle;
-    return WIN_CreateWindowEx( &cs, classAtom, FALSE );
+    return WIN_CreateWindowEx( &cs, classAtom, FALSE, FALSE );
 }
 
 
@@ -898,7 +880,7 @@
     cs.lpszName       = windowName;
     cs.lpszClass      = className;
     cs.dwExStyle      = exStyle;
-    return WIN_CreateWindowEx( &cs, classAtom, FALSE );
+    return WIN_CreateWindowEx( &cs, classAtom, TRUE, FALSE );
 }
 
 
@@ -944,7 +926,7 @@
     cs.dwExStyle      = exStyle;
     /* Note: we rely on the fact that CREATESTRUCT32A and */
     /* CREATESTRUCT32W have the same layout. */
-    return WIN_CreateWindowEx( (CREATESTRUCT32A *)&cs, classAtom, TRUE );
+    return WIN_CreateWindowEx( (CREATESTRUCT32A *)&cs, classAtom, TRUE, TRUE );
 }
 
 
@@ -1055,7 +1037,8 @@
         else break;
       }
 
-      WINPOS_ActivateOtherWindow(wndPtr);
+      if( !Options.managed || EVENT_CheckFocus() )
+          WINPOS_ActivateOtherWindow(wndPtr);
 
       if( wndPtr->owner &&
 	  wndPtr->owner->hwndLastActive == wndPtr->hwndSelf )
@@ -1079,25 +1062,43 @@
 
 
 /***********************************************************************
- *           CloseWindow   (USER.43)
+ *           CloseWindow16   (USER.43)
  */
-BOOL CloseWindow(HWND hWnd)
+BOOL16 CloseWindow16( HWND16 hwnd )
 {
-    WND * wndPtr = WIN_FindWndPtr(hWnd);
-    if (!wndPtr || (wndPtr->dwStyle & WS_CHILD)) return TRUE;
-    ShowWindow32(hWnd, SW_MINIMIZE);
+    return CloseWindow32( hwnd );
+}
+
+ 
+/***********************************************************************
+ *           CloseWindow32   (USER32.55)
+ */
+BOOL32 CloseWindow32( HWND32 hwnd )
+{
+    WND * wndPtr = WIN_FindWndPtr( hwnd );
+    if (!wndPtr || (wndPtr->dwStyle & WS_CHILD)) return FALSE;
+    ShowWindow32( hwnd, SW_MINIMIZE );
     return TRUE;
 }
 
  
 /***********************************************************************
- *           OpenIcon   (USER.44)
+ *           OpenIcon16   (USER.44)
  */
-BOOL OpenIcon(HWND hWnd)
+BOOL16 OpenIcon16( HWND16 hwnd )
 {
-    if (!IsIconic16(hWnd)) return FALSE;
-    ShowWindow32(hWnd, SW_SHOWNORMAL);
-    return(TRUE);
+    return OpenIcon32( hwnd );
+}
+
+
+/***********************************************************************
+ *           OpenIcon32   (USER32.409)
+ */
+BOOL32 OpenIcon32( HWND32 hwnd )
+{
+    if (!IsIconic32( hwnd )) return FALSE;
+    ShowWindow32( hwnd, SW_SHOWNORMAL );
+    return TRUE;
 }
 
 
@@ -1106,8 +1107,8 @@
  *
  * Implementation of FindWindow() and FindWindowEx().
  */
-static HWND WIN_FindWindow( HWND parent, HWND child, ATOM className,
-                            LPCSTR title )
+static HWND32 WIN_FindWindow( HWND32 parent, HWND32 child, ATOM className,
+                              LPCSTR title )
 {
     WND *pWnd;
     CLASS *pClass = NULL;
@@ -1220,7 +1221,7 @@
 {
     ATOM atom = 0;
     char *buffer;
-    HWND hwnd;
+    HWND32 hwnd;
 
     if (className)
     {
@@ -1415,7 +1416,7 @@
     {
 	case GWW_ID:        ptr = (WORD *)&wndPtr->wIDmenu; break;
 	case GWW_HINSTANCE: ptr = (WORD *)&wndPtr->hInstance; break;
-	case GWW_HWNDPARENT: return SetParent( hwnd, newval );
+	case GWW_HWNDPARENT: return SetParent32( hwnd, newval );
 	default:
             fprintf( stderr, "SetWindowWord: invalid offset %d\n", offset );
             return 0;
@@ -1504,6 +1505,9 @@
             WINPROC_SetProc( &wndPtr->winproc, (WNDPROC16)newval, type );
             return retval;
 	case GWL_STYLE:
+
+	    /* FIXME: WM_STYLE... messages for WIN_ISWIN32 windows */
+
             ptr = &wndPtr->dwStyle;
             /* Some bits can't be changed this way */
             newval &= ~(WS_VISIBLE | WS_CHILD);
@@ -1701,13 +1705,22 @@
 
 
 /*****************************************************************
- *         SetParent              (USER.233)
+ *         SetParent16   (USER.233)
  */
-HWND SetParent(HWND hwndChild, HWND hwndNewParent)
+HWND16 SetParent16( HWND16 hwndChild, HWND16 hwndNewParent )
 {
-    HWND oldParent;
+    return SetParent32( hwndChild, hwndNewParent );
+}
 
-    WND *wndPtr = WIN_FindWndPtr(hwndChild);
+
+/*****************************************************************
+ *         SetParent32   (USER32.494)
+ */
+HWND32 SetParent32( HWND32 hwndChild, HWND32 hwndNewParent )
+{
+    HWND32 oldParent;
+
+    WND *wndPtr = WIN_FindWndPtr( hwndChild );
     WND *pWndParent = WIN_FindWndPtr( hwndNewParent );
     if (!wndPtr || !pWndParent || !(wndPtr->dwStyle & WS_CHILD)) return 0;
 
@@ -1723,16 +1736,17 @@
 }
 
 
-
 /*******************************************************************
- *         IsChild    (USER.48)
+ *         IsChild16    (USER.48)
  */
 BOOL16 IsChild16( HWND16 parent, HWND16 child )
 {
     return IsChild32(parent,child);
 }
+
+
 /*******************************************************************
- *         IsChild    (USER32.338)
+ *         IsChild32    (USER32.338)
  */
 BOOL32 IsChild32( HWND32 parent, HWND32 child )
 {
@@ -1747,14 +1761,16 @@
 
 
 /***********************************************************************
- *           IsWindowVisible   (USER.49)
+ *           IsWindowVisible16   (USER.49)
  */
 BOOL16 IsWindowVisible16( HWND16 hwnd )
 {
     return IsWindowVisible32(hwnd);
 }
+
+
 /***********************************************************************
- *           IsWindowVisible   (USER32.350)
+ *           IsWindowVisible32   (USER32.350)
  */
 BOOL32 IsWindowVisible32( HWND32 hwnd )
 {
@@ -1767,6 +1783,7 @@
     return (wndPtr && (wndPtr->dwStyle & WS_VISIBLE));
 }
 
+
 /***********************************************************************
  *           WIN_IsWindowDrawable
  * 
@@ -1776,7 +1793,7 @@
  */
 BOOL32 WIN_IsWindowDrawable( WND* wnd , BOOL32 icon )
 {
-  HWND   hwnd= wnd->hwndSelf;
+  HWND32 hwnd = wnd->hwndSelf;
   BOOL32 yes = TRUE;
 
   while(wnd && yes)
@@ -1791,14 +1808,16 @@
 }
 
 /*******************************************************************
- *         GetTopWindow    (USER.229)
+ *         GetTopWindow16    (USER.229)
  */
 HWND16 GetTopWindow16( HWND16 hwnd )
 {
     return GetTopWindow32(hwnd);
 }
+
+
 /*******************************************************************
- *         GetTopWindow    (USER.229)
+ *         GetTopWindow32    (USER.229)
  */
 HWND32 GetTopWindow32( HWND32 hwnd )
 {
@@ -1809,14 +1828,16 @@
 
 
 /*******************************************************************
- *         GetWindow    (USER.262)
+ *         GetWindow16    (USER.262)
  */
 HWND16 GetWindow16( HWND16 hwnd, WORD rel )
 {
     return GetWindow32( hwnd,rel );
 }
+
+
 /*******************************************************************
- *         GetWindow    (USER32.301)
+ *         GetWindow32    (USER32.301)
  */
 HWND32 GetWindow32( HWND32 hwnd, WORD rel )
 {
@@ -1859,7 +1880,7 @@
 
 
 /*******************************************************************
- *         GetNextWindow    (USER.230)
+ *         GetNextWindow16    (USER.230)
  */
 HWND16 GetNextWindow16( HWND16 hwnd, WORD flag )
 {
@@ -1868,9 +1889,18 @@
 }
 
 /*******************************************************************
- *         ShowOwnedPopups  (USER.265)
+ *         ShowOwnedPopups16  (USER.265)
  */
-void ShowOwnedPopups( HWND owner, BOOL fShow )
+void ShowOwnedPopups16( HWND16 owner, BOOL16 fShow )
+{
+    ShowOwnedPopups32( owner, fShow );
+}
+
+
+/*******************************************************************
+ *         ShowOwnedPopups32  (USER32.530)
+ */
+BOOL32 ShowOwnedPopups32( HWND32 owner, BOOL32 fShow )
 {
     WND *pWnd = pWndDesktop->child;
     while (pWnd)
@@ -1880,13 +1910,22 @@
             ShowWindow32( pWnd->hwndSelf, fShow ? SW_SHOW : SW_HIDE );
         pWnd = pWnd->next;
     }
+    return TRUE;
 }
 
 
 /*******************************************************************
- *         GetLastActivePopup    (USER.287)
+ *         GetLastActivePopup16   (USER.287)
  */
-HWND GetLastActivePopup(HWND hwnd)
+HWND16 GetLastActivePopup16( HWND16 hwnd )
+{
+    return GetLastActivePopup32( hwnd );
+}
+
+/*******************************************************************
+ *         GetLastActivePopup32   (USER32.255)
+ */
+HWND32 GetLastActivePopup32( HWND32 hwnd )
 {
     WND *wndPtr;
     wndPtr = WIN_FindWndPtr(hwnd);
@@ -2050,9 +2089,18 @@
 
 
 /*******************************************************************
- *           AnyPopup   (USER.52)
+ *           AnyPopup16   (USER.52)
  */
-BOOL AnyPopup(void)
+BOOL16 AnyPopup16(void)
+{
+    return AnyPopup32();
+}
+
+
+/*******************************************************************
+ *           AnyPopup32   (USER32.3)
+ */
+BOOL32 AnyPopup32(void)
 {
     WND *wndPtr;
     for (wndPtr = pWndDesktop->child; wndPtr; wndPtr = wndPtr->next)
@@ -2060,10 +2108,20 @@
     return FALSE;
 }
 
+
 /*******************************************************************
- *			FlashWindow		[USER.105]
+ *            FlashWindow16   (USER.105)
  */
-BOOL FlashWindow(HWND hWnd, BOOL bInvert)
+BOOL16 FlashWindow16( HWND16 hWnd, BOOL16 bInvert )
+{
+    return FlashWindow32( hWnd, bInvert );
+}
+
+
+/*******************************************************************
+ *            FlashWindow32   (USER32.201)
+ */
+BOOL32 FlashWindow32( HWND32 hWnd, BOOL32 bInvert )
 {
     WND *wndPtr = WIN_FindWndPtr(hWnd);
 
@@ -2108,7 +2166,7 @@
  */
 HWND16 SetSysModalWindow16( HWND16 hWnd )
 {
-    HWND hWndOldModal = hwndSysModal;
+    HWND32 hWndOldModal = hwndSysModal;
     hwndSysModal = hWnd;
     dprintf_win(stdnimp,"EMPTY STUB !! SetSysModalWindow(%04x) !\n", hWnd);
     return hWndOldModal;
@@ -2130,7 +2188,7 @@
  * recursively find a child that contains spDragInfo->pt point 
  * and send WM_QUERYDROPOBJECT
  */
-BOOL16 DRAG_QueryUpdate( HWND hQueryWnd, SEGPTR spDragInfo, BOOL32 bNoSend )
+BOOL16 DRAG_QueryUpdate( HWND32 hQueryWnd, SEGPTR spDragInfo, BOOL32 bNoSend )
 {
  BOOL16		wParam,bResult = 0;
  POINT16        pt;
@@ -2196,11 +2254,21 @@
  return bResult;
 }
 
+
 /*******************************************************************
- *                      DragDetect ( USER.465 )
- *
+ *             DragDetect   (USER.465)
  */
-BOOL16 DragDetect(HWND16 hWnd, POINT16 pt)
+BOOL16 DragDetect16( HWND16 hWnd, POINT16 pt )
+{
+    POINT32 pt32;
+    CONV_POINT16TO32( &pt, &pt32 );
+    return DragDetect32( hWnd, pt32 );
+}
+
+/*******************************************************************
+ *             DragDetect32   (USER32.150)
+ */
+BOOL32 DragDetect32( HWND32 hWnd, POINT32 pt )
 {
   MSG16 msg;
   RECT16  rect;
@@ -2241,7 +2309,7 @@
  *                              DragObject ( USER.464 )
  *
  */
-DWORD DragObject(HWND hwndScope, HWND hWnd, WORD wObj, HANDLE16 hOfStruct,
+DWORD DragObject(HWND16 hwndScope, HWND16 hWnd, WORD wObj, HANDLE16 hOfStruct,
                 WORD szList , HCURSOR16 hCursor)
 {
  MSG16	 	msg;
@@ -2253,7 +2321,7 @@
  DWORD		dwRet = 0;
  short	 	dragDone = 0;
  HCURSOR16	hCurrentCursor = 0;
- HWND		hCurrentWnd = 0;
+ HWND16		hCurrentWnd = 0;
  BOOL16		b;
 
  lpDragInfo = (LPDRAGINFO) GlobalLock16(hDragInfo);
@@ -2280,7 +2348,7 @@
 	if( hDragCursor == hCursor ) hDragCursor = 0;
 	else hCursor = hDragCursor;
 
-	hOldCursor = SetCursor(hDragCursor);
+	hOldCursor = SetCursor32(hDragCursor);
    }
 
  lpDragInfo->hWnd   = hWnd;
@@ -2291,7 +2359,7 @@
  lpDragInfo->l = 0L; 
 
  SetCapture32(hWnd);
- ShowCursor(1);
+ ShowCursor32( TRUE );
 
  while( !dragDone )
   {
@@ -2315,7 +2383,7 @@
          lpDragInfo->hScope = 0;
 	}
     if( hCurrentCursor )
-        SetCursor(hCurrentCursor);
+        SetCursor32(hCurrentCursor);
 
     dprintf_msg(stddeb,"drag: got %04x\n", b);
 
@@ -2344,14 +2412,13 @@
   }
 
  ReleaseCapture();
- ShowCursor(0);
+ ShowCursor32( FALSE );
 
  if( hCursor )
-   {
-     SetCursor(hOldCursor);
-     if( hDragCursor )
-	 DestroyCursor(hDragCursor);
-   }
+ {
+     SetCursor32( hOldCursor );
+     if (hDragCursor) DestroyCursor32( hDragCursor );
+ }
 
  if( hCurrentCursor != hBummer ) 
 	dwRet = SendMessage16( lpDragInfo->hScope, WM_DROPOBJECT, 
diff --git a/windows/winpos.c b/windows/winpos.c
index adac82f..d802981 100644
--- a/windows/winpos.c
+++ b/windows/winpos.c
@@ -1034,9 +1034,16 @@
 	    /* disregard refusal if hWnd is sysmodal */
         }
 
+#if 0
 	SendMessage32A( hwndPrevActive, WM_ACTIVATE,
                         MAKEWPARAM( WA_INACTIVE, wIconized ),
                         (LPARAM)hWnd );
+#else
+	/* FIXME: must be SendMessage16() because 32A doesn't do
+	 * intertask at this time */
+	SendMessage16( hwndPrevActive, WM_ACTIVATE, WA_INACTIVE,
+				MAKELPARAM( (HWND16)hWnd, wIconized ) );
+#endif
 
 	/* check if something happened during message processing */
 	if( hwndPrevActive != hwndActive ) return 0;
@@ -1120,9 +1127,14 @@
 
         wIconized = HIWORD(wndTemp->dwStyle & WS_MINIMIZE);
         SendMessage16( hWnd, WM_NCACTIVATE, TRUE, 0 );
+#if 0
         SendMessage32A( hWnd, WM_ACTIVATE,
 		 MAKEWPARAM( (fMouse) ? WA_CLICKACTIVE : WA_ACTIVE, wIconized),
 		 (LPARAM)hwndPrevActive );
+#else
+        SendMessage16(hWnd, WM_ACTIVATE, (fMouse) ? WA_CLICKACTIVE : WA_ACTIVE,
+                      MAKELPARAM( (HWND16)hwndPrevActive, wIconized) );
+#endif
 
         if( !IsWindow(hWnd) ) return 0;
     }
diff --git a/wine.man b/wine.man
index 395b840..6445a31 100644
--- a/wine.man
+++ b/wine.man
@@ -109,7 +109,7 @@
 .I -language xx
 Set the language to
 .I xx
-(one of En, Es, De, No, Fr, Fi, Da, Cz, Eo, It, Ko)
+(one of En, Es, De, No, Fr, Fi, Da, Cz, Eo, It, Ko, Hu)
 .TP
 .I -managed
 Create each top-level window as a properly managed X window