Release 971130

Sat Nov 29 12:35:26 1997  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [if1632/builtin.c]
	Build a complete PE header for builtin Win32 modules.

	* [loader/pe_image.c] [loader/module.c]
	HMODULE32 now points to the loading address of the module. There
	is no longer a separate PE_MODULE structure.

Fri Nov 28 11:21:47 1997  Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>

	* [ole/*][configure.in][Makefile.in][include/interfaces.h]
	  [if1632/olesvr32.spec][if1632/olecli32.spec]
	New directory, moved OLE stuff there.
	new .spec files for olecli32,olesvr32, some stubs added.

	* [misc/shell.c]
	Added support for extracting icons from PE dlls.

	* [misc/shellord.c][if1632/shell32.spec]
	Added a huge heap of ordinal only exported shell functions
	(will work only in Win95).

	* [loader/task.c]
	Hack to make MakeProcInstance16 work in all cases (mplayer.exe).

	* [win32/string32.c][include/string32.h]
	Obsolete, removed.

	* [windows/keyboard.c]
	Added *RegisterHotkey.

	* [objects/font.c][objects/text.c]
	Added GetFontLanguageInfo, GetTextCharsetInfo.

Wed Nov 26 18:10:40 1997  Uwe Bonnes  <bon@elektron.ikp.physik.tu-darmstadt.de>

	* [misc/network.c]
	In WNetGetConnection16 return the Drive label and not the DOS-Cwd.
	Makes Wordview 6 start on a network connected machine.

	* [controls/status.c]
	Catch a Null pointer in SW_SetText.

	* [files/dos_fs.c]
 	Add NT5 functions GetLongPathName32.

	* [files/file.c]
	Make GetTempFileName16 accept drive 0 (Current Drive) too.
	Handle more errors and be more verbose in FILE_SetDosError, fix
	an error in DeleteFile32W

	* [memory/virtual.c]
	Implement FlushViewOfFile.

	* [misc/crtdll]
	Implement _rotl and splitpath and add a stub for 
	_abnormal_termination.

	* [misc/printdrv.c]
	Stub for EnumPrinters32A.

	* [win32/newfns]
	Add Stub for QueryPerformanceFrequency, change return value
	for QueryPerformanceCounter.
 	Add stub for DeviceIoControl.

Tue Nov 25 15:55:01 1997 Martin Boehme <boehme@informatik.mu-luebeck.de>

	* [controls/combo.c] [controls/edit.c] [windows/defwnd.c]
	  [windows/winpos.c] [windows/win.c]
	Removed WIN_NO_REDRAW flag.

Tue Nov 25 13:20:35 1997  Douglas Ridgway <ridgway@taiga.v-wave.com>

	* [graphics/x11drv/bitblt.c]
	Fixed memory leak in BITBLT_GetDstArea.

Sun Nov 23 14:05:23 1997  Andreas Mohr <100.30936@germany.net>

	* [files/directory.c]
	Export windows system directory to environment.

	* [if1632/Makefile.in] [if1632/builtin.c] [if1632/w32skrnl.spec]
	  [if1632/win32s16.spec] [misc/w32scomb.c] [misc/w32skrnl.c]
	Added Win32s DLLs W32SKRNL and WIN32S16.

	* [if1632/kernel32.spec] [loader/module.c]
	Added misc functions for Win32s.

	* [if1632/kernel.spec] [loader/task.c]
	Added DefineHandleTable().

	* [scheduler/process.c]
	Fixed SetEnvironmentVariable32A() to avoid heap corruption.

Sat Nov 22 14:11:42 1997  Kristian Nielsen  <kristian.nielsen@risoe.dk>

	* [windows/painting.c]
	Fix leak in BeginPaint16() for CS_PARENTDC windows where the
	update region was not properly released.

Thu Nov 20 03:55:29 1997  Gordon Chaffee <chaffee@CS.Berkeley.EDU>

	* [loader/pe_image.c]
	Implemented forwarded DLL functions.

	* [objects/dib.c]
	Added support for 16- and 32-bit mode DIBs.
	Support negative bitmap heights.

	* [win32/process.c]
	Added stub for CreateProcess32W.

	* [win32/security.c] [include/ntdll.h]
	Added stubs for LookupAccountSid32A/W.

	* [scheduler/process.c]
	Use the size specified in the PE header for the process heap.

Mon Nov 17 00:53:35 1997  Len White <phreak@cgocable.net>

	* [msdos/int3d.c]
	New file. Stubs for int3d.

Sun Nov 16 12:30:00 PST 1997  Jason Schonberg  <schon@mti.sgi.com>

	* [include/aspi.h]
	Changed comment style from C++ to C.
diff --git a/ANNOUNCE b/ANNOUNCE
index d05e8fa..93c7b24 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,14 +1,14 @@
-This is release 971116 of Wine, the MS Windows emulator.  This is still a
+This is release 971130 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-971116: (see ChangeLog for details)
-	- Emulator and library unification.
-	- New About dialog.
-	- Menus improvements.
+WHAT'S NEW with Wine-971130: (see ChangeLog for details)
+	- Better Win32s support.
+	- Lots of new Win32 functions.
+	- DIB handling improvements.
 	- Lots of bug fixes.
 
 See the README file in the distribution for installation instructions.
@@ -17,10 +17,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-971116.tar.gz
-  ftp://tsx-11.mit.edu/pub/linux/ALPHA/Wine/development/Wine-971116.tar.gz
-  ftp://ftp.infomagic.com/pub/mirrors/linux/wine/development/Wine-971116.tar.gz
-  ftp://ftp.progsoc.uts.edu.au/pub/Wine/development/Wine-971116.tar.gz
+  ftp://sunsite.unc.edu/pub/Linux/ALPHA/wine/development/Wine-971130.tar.gz
+  ftp://tsx-11.mit.edu/pub/linux/ALPHA/Wine/development/Wine-971130.tar.gz
+  ftp://ftp.infomagic.com/pub/mirrors/linux/wine/development/Wine-971130.tar.gz
+  ftp://ftp.progsoc.uts.edu.au/pub/Wine/development/Wine-971130.tar.gz
 
 It should also be available from any site that mirrors tsx-11 or sunsite.
 
diff --git a/AUTHORS b/AUTHORS
index e26d62a..cd18940 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -11,6 +11,7 @@
 Peter Bajusz,
 Georg Beyerle,
 Ross Biro,
+Martin Boehme,
 Uwe Bonnes,
 Erik Bos,
 Fons Botman,
@@ -18,12 +19,14 @@
 Andrew Bulhak,
 John Burton,
 Niels de Carpentier,
+Gordon Chaffee,
 Jimen Ching,
 David A. Cuthbert,
 Huw D. M. Davies,
 Roman Dolejsi,
 Frans van Dorsselaer,
 Chris Faherty,
+Carsten Fallesen,
 Paul Falstad,
 David Faure,
 Claus Fischer,
@@ -71,6 +74,7 @@
 Andreas Mohr,
 Philippe De Muyter,
 Itai Nahshon,
+Kristian Nielsen,
 Henrik Olsen,
 Michael Patra,
 Dimitrie O. Paun,
@@ -114,11 +118,13 @@
 Eric Warnke,
 Manfred Weichel,
 Morten Welinder,
+Len White,
 Lawson Whitney,
 Jan Willamowius,
 Carl Williams,
 Karl Guenter Wuensch,
 Eric Youngdale,
 James Youngman,
+Nikita V. Youshchenko,
 Mikolaj Zalewski,
 and John Zero.
diff --git a/BUGS b/BUGS
index dff1e4d..cc9b8c0 100644
--- a/BUGS
+++ b/BUGS
@@ -9,10 +9,6 @@
 
 General:
 
- * We need to do InsertMenuItem32[AW] and then code most of the other
-   inserting function in terms of this.  Without this, we cannot support
-   all the new extended menus.  Not hard, but slightly big.
-
  * TrueType, .FON rasterizer.
 
  * No thread/process scheduling support in Win32 code. 
@@ -38,9 +34,11 @@
 
  * Invisible controls in BCW dialogs.
 
- * MIRC is unable to show 'Options' dialog.
+ * mIRC 'commands' menu stays on top and will not refresh.
 
- * Tab switching in MIRC 'Setup' dialog leaks memory.
+ * mIRC is unable to show 'Options' dialog.
+
+ * Tab switching in mIRC 'Setup' dialog leaks memory.
 
  * nBytesWidth in CURSORICONINFO is bogus for some bpp
    (doesn't reflect the fact that bits are packed and 16-bit aligned).
diff --git a/ChangeLog b/ChangeLog
index 8b4b830..76ac4ba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,135 @@
 ----------------------------------------------------------------------
+Sat Nov 29 12:35:26 1997  Alexandre Julliard  <julliard@lrc.epfl.ch>
+
+	* [if1632/builtin.c]
+	Build a complete PE header for builtin Win32 modules.
+
+	* [loader/pe_image.c] [loader/module.c]
+	HMODULE32 now points to the loading address of the module. There
+	is no longer a separate PE_MODULE structure.
+
+Fri Nov 28 11:21:47 1997  Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>
+
+	* [ole/*][configure.in][Makefile.in][include/interfaces.h]
+	  [if1632/olesvr32.spec][if1632/olecli32.spec]
+	New directory, moved OLE stuff there.
+	new .spec files for olecli32,olesvr32, some stubs added.
+
+	* [misc/shell.c]
+	Added support for extracting icons from PE dlls.
+
+	* [misc/shellord.c][if1632/shell32.spec]
+	Added a huge heap of ordinal only exported shell functions
+	(will work only in Win95).
+
+	* [loader/task.c]
+	Hack to make MakeProcInstance16 work in all cases (mplayer.exe).
+
+	* [win32/string32.c][include/string32.h]
+	Obsolete, removed.
+
+	* [windows/keyboard.c]
+	Added *RegisterHotkey.
+
+	* [objects/font.c][objects/text.c]
+	Added GetFontLanguageInfo, GetTextCharsetInfo.
+
+Wed Nov 26 18:10:40 1997  Uwe Bonnes  <bon@elektron.ikp.physik.tu-darmstadt.de>
+
+	* [misc/network.c]
+	In WNetGetConnection16 return the Drive label and not the DOS-Cwd.
+	Makes Wordview 6 start on a network connected machine.
+
+	* [controls/status.c]
+	Catch a Null pointer in SW_SetText.
+
+	* [files/dos_fs.c]
+ 	Add NT5 functions GetLongPathName32.
+
+	* [files/file.c]
+	Make GetTempFileName16 accept drive 0 (Current Drive) too.
+	Handle more errors and be more verbose in FILE_SetDosError, fix
+	an error in DeleteFile32W
+
+	* [memory/virtual.c]
+	Implement FlushViewOfFile.
+
+	* [misc/crtdll]
+	Implement _rotl and splitpath and add a stub for 
+	_abnormal_termination.
+
+	* [misc/printdrv.c]
+	Stub for EnumPrinters32A.
+
+	* [win32/newfns]
+	Add Stub for QueryPerformanceFrequency, change return value
+	for QueryPerformanceCounter.
+ 	Add stub for DeviceIoControl.
+
+Tue Nov 25 15:55:01 1997 Martin Boehme <boehme@informatik.mu-luebeck.de>
+
+	* [controls/combo.c] [controls/edit.c] [windows/defwnd.c]
+	  [windows/winpos.c] [windows/win.c]
+	Removed WIN_NO_REDRAW flag.
+
+Tue Nov 25 13:20:35 1997  Douglas Ridgway <ridgway@taiga.v-wave.com>
+
+	* [graphics/x11drv/bitblt.c]
+	Fixed memory leak in BITBLT_GetDstArea.
+
+Sun Nov 23 14:05:23 1997  Andreas Mohr <100.30936@germany.net>
+
+	* [files/directory.c]
+	Export windows system directory to environment.
+
+	* [if1632/Makefile.in] [if1632/builtin.c] [if1632/w32skrnl.spec]
+	  [if1632/win32s16.spec] [misc/w32scomb.c] [misc/w32skrnl.c]
+	Added Win32s DLLs W32SKRNL and WIN32S16.
+
+	* [if1632/kernel32.spec] [loader/module.c]
+	Added misc functions for Win32s.
+
+	* [if1632/kernel.spec] [loader/task.c]
+	Added DefineHandleTable().
+
+	* [scheduler/process.c]
+	Fixed SetEnvironmentVariable32A() to avoid heap corruption.
+
+Sat Nov 22 14:11:42 1997  Kristian Nielsen  <kristian.nielsen@risoe.dk>
+
+	* [windows/painting.c]
+	Fix leak in BeginPaint16() for CS_PARENTDC windows where the
+	update region was not properly released.
+
+Thu Nov 20 03:55:29 1997  Gordon Chaffee <chaffee@CS.Berkeley.EDU>
+
+	* [loader/pe_image.c]
+	Implemented forwarded DLL functions.
+
+	* [objects/dib.c]
+	Added support for 16- and 32-bit mode DIBs.
+	Support negative bitmap heights.
+
+	* [win32/process.c]
+	Added stub for CreateProcess32W.
+
+	* [win32/security.c] [include/ntdll.h]
+	Added stubs for LookupAccountSid32A/W.
+
+	* [scheduler/process.c]
+	Use the size specified in the PE header for the process heap.
+
+Mon Nov 17 00:53:35 1997  Len White <phreak@cgocable.net>
+
+	* [msdos/int3d.c]
+	New file. Stubs for int3d.
+
+Sun Nov 16 12:30:00 PST 1997  Jason Schonberg  <schon@mti.sgi.com>
+
+	* [include/aspi.h]
+	Changed comment style from C++ to C.
+
+----------------------------------------------------------------------
 Sun Nov 16 07:42:44 1997  Alex Korobka <alex@trantor.pharm.sunysb.edu>
 
 	* [windows/dce.c] [windows/clipboard.c] [windows/nonclient.c]
@@ -78,7 +209,7 @@
 	* [loader/resource.c] [user32.spec]
 	Stubs for CopyAcceleratorTable, Destroy AcceleratorTable.
 
-Thu Nov  6 22:37:04 1997  Morten Welinder  <welinder@rentec.com>
+Thu Nov  6 22:37:04 1997  Morten Welinder  <terra@diku.dk>
 
 	* [files/drive.c]
 	(GetDiskFreeSpace32A): Cap at 2GB.
diff --git a/Makefile.in b/Makefile.in
index 32b77ef..c326756 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -37,6 +37,7 @@
 	msdos \
 	multimedia \
 	objects \
+	ole \
 	resources \
 	scheduler \
 	win32 \
@@ -79,6 +80,7 @@
 	msdos/msdos.o \
 	multimedia/multimedia.o \
 	objects/objects.o \
+	ole/ole.o \
 	resources/resources.o \
 	scheduler/scheduler.o \
 	win32/win32.o \
@@ -98,18 +100,18 @@
 
 emu: wine
 
-lib: $(LIB_TARGET)
+lib: $(LIBSUBDIRS) $(LIB_TARGET)
 
-wine wine.sym: $(LIB_TARGET) $(EMUSUBDIRS) dummy
+wine wine.sym: $(LIBSUBDIRS) $(LIB_TARGET) $(EMUSUBDIRS) dummy
 	$(CC) -o wine $(EMUOBJS) $(LIB_TARGET) $(LDOPTIONS) $(X_LIBS) $(XPM_LIB) $(XLIB) $(LDLIBS)
 	nm -n wine | grep -v _compiled >wine.sym
 
-libwine.a: $(LIBSUBDIRS) dummy
+libwine.a: $(LIBOBJS)
 	$(RM) $@
 	$(AR) $@ $(LIBOBJS)
 	$(RANLIB) $@
 
-libwine.so.1.0: $(LIBSUBDIRS) dummy
+libwine.so.1.0: $(LIBOBJS)
 	$(CC) -shared -Wl,-soname,libwine.so -o$@ $(LIBOBJS) $(LDOPTIONS) $(X_LIBS) $(XPM_LIB) $(XLIB) $(LDLIBS)
 
 install_emu: dummy
diff --git a/configure b/configure
index 83ba008..5699464 100755
--- a/configure
+++ b/configure
@@ -2521,9 +2521,11 @@
 msdos/Makefile
 multimedia/Makefile
 objects/Makefile
+ole/Makefile
 programs/Makefile
 programs/progman/Makefile
 programs/winhelp/Makefile
+programs/winver/Makefile
 rc/Makefile
 resources/Makefile
 scheduler/Makefile
@@ -2643,9 +2645,11 @@
 msdos/Makefile
 multimedia/Makefile
 objects/Makefile
+ole/Makefile
 programs/Makefile
 programs/progman/Makefile
 programs/winhelp/Makefile
+programs/winver/Makefile
 rc/Makefile
 resources/Makefile
 scheduler/Makefile
diff --git a/configure.in b/configure.in
index 9e4d702..8c1186c 100644
--- a/configure.in
+++ b/configure.in
@@ -146,9 +146,11 @@
 msdos/Makefile
 multimedia/Makefile
 objects/Makefile
+ole/Makefile
 programs/Makefile
 programs/progman/Makefile
 programs/winhelp/Makefile
+programs/winver/Makefile
 rc/Makefile
 resources/Makefile
 scheduler/Makefile
diff --git a/controls/combo.c b/controls/combo.c
index b66173c..e1ccb16 100644
--- a/controls/combo.c
+++ b/controls/combo.c
@@ -363,6 +363,9 @@
     UINT32 	x, y;
     BOOL32 	bBool;
 
+    if( lphc->wState & CBF_NOREDRAW )
+        return;
+
     hPrevBrush = (HBRUSH32)SelectObject32(hdc, sysColorObjects.hbrushBtnFace);
     CONV_RECT16TO32( &lphc->RectButton, &r );
 
@@ -401,6 +404,9 @@
    INT32	id, size = 0;
    LPSTR	pText = NULL;
 
+   if( lphc->wState & CBF_NOREDRAW )
+        return;
+
    /* follow Windows combobox that sends a bunch of text 
     * inquiries to its listbox while processing WM_PAINT. */
 
@@ -508,7 +514,7 @@
   
   hDC = (hParamDC) ? hParamDC
 		   : BeginPaint16( lphc->self->hwndSelf, &ps);
-  if( hDC && !(lphc->self->flags & WIN_NO_REDRAW) )
+  if( hDC && !(lphc->wState & CBF_NOREDRAW) )
   {
       HBRUSH32	hPrevBrush, hBkgBrush;
 
@@ -673,11 +679,14 @@
 
    SetWindowPos32( lphc->hWndLBox, HWND_TOP, rect.left, rect.top, 
 		 rect.right - rect.left, rect.bottom - rect.top, 
-		 SWP_NOACTIVATE | SWP_NOSIZE );
-   if( pRect )
-       RedrawWindow16( lphc->self->hwndSelf, pRect, 0, RDW_INVALIDATE | 
+		 SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOREDRAW);
+   if( !(lphc->wState & CBF_NOREDRAW) )
+   {
+       if( pRect )
+           RedrawWindow16( lphc->self->hwndSelf, pRect, 0, RDW_INVALIDATE | 
 			   RDW_ERASE | RDW_UPDATENOW | RDW_NOCHILDREN );
-   ShowWindow32( lphc->hWndLBox, SW_SHOWNA );
+       ShowWindow32( lphc->hWndLBox, SW_SHOWNA );
+   }
 }
 
 /***********************************************************************
@@ -722,7 +731,7 @@
 	       bButton = TRUE;
 	   }
 
-	   if( bButton )
+	   if( bButton && !(lphc->wState & CBF_NOREDRAW) )
 	       RedrawWindow16( hWnd, &rect, 0, RDW_INVALIDATE | 
 			       RDW_ERASE | RDW_UPDATENOW | RDW_NOCHILDREN );
 	   CB_NOTIFY( lphc, CBN_CLOSEUP );
@@ -1036,7 +1045,7 @@
                        lphc->RectEdit.bottom - lphc->RectEdit.top,
                        SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW );
        lphc->wState &= ~CBF_NORESIZE;
-       if( bRedraw )
+       if( bRedraw && !(lphc->wState & CBF_NOREDRAW) )
            RedrawWindow32( lphc->self->hwndSelf, NULL, 0,
                            RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW );
    }
@@ -1336,6 +1345,11 @@
 		return TRUE;
 
 	case WM_SETREDRAW:
+		if( wParam )
+		    lphc->wState &= ~CBF_NOREDRAW;
+		else
+		    lphc->wState |= CBF_NOREDRAW;
+
 		if( lphc->wState & CBF_EDIT )
 		    SendMessage32A( lphc->hWndEdit, message, wParam, lParam );
 		SendMessage32A( lphc->hWndLBox, message, wParam, lParam );
diff --git a/controls/edit.c b/controls/edit.c
index a285895..b4cd3ac 100644
--- a/controls/edit.c
+++ b/controls/edit.c
@@ -84,6 +84,8 @@
 	INT32 left_margin;		/* in pixels */
 	INT32 right_margin;		/* in pixels */
 	RECT32 format_rect;
+	INT32 region_posx;		/* Position of cursor relative to region: */
+	INT32 region_posy;		/* -1: to left, 0: within, 1: to right */
 	EDITWORDBREAKPROC16 word_break_proc16;
 	EDITWORDBREAKPROC32A word_break_proc32A;
 	INT32 line_count;		/* number of lines */
@@ -1016,6 +1018,7 @@
 		INT32 line = (y - es->format_rect.top) / es->line_height + es->y_offset;
 		INT32 line_index = 0;
 		LINEDEF *line_def = es->first_line_def;
+		INT32 low, high;
 		while ((line > 0) && line_def->next) {
 			line_index += line_def->length;
 			line_def = line_def->next;
@@ -1035,11 +1038,16 @@
 		dc = GetDC32(wnd->hwndSelf);
 		if (es->font)
 			old_font = SelectObject32(dc, es->font);
-		/* FIXME: inefficient algorithm */
-		for (index = line_index + 1 ; index < line_index + line_def->net_length ; index++)
-			if (LOWORD(GetTabbedTextExtent32A(dc, es->text + line_index,
-					index - line_index, es->tabs_count, es->tabs)) >= x)
-				break;
+                    low = line_index + 1;
+                    high = line_index + line_def->net_length + 1;
+                    while (low < high - 1)
+                    {
+                        INT32 mid = (low + high) / 2;
+			if (LOWORD(GetTabbedTextExtent32A(dc, es->text + line_index,mid - line_index, es->tabs_count, es->tabs)) > x) high = mid;
+                        else low = mid;
+                    }
+                    index = low;
+
 		if (after_wrap)
 			*after_wrap = ((index == line_index + line_def->net_length) &&
 							(line_def->ending == END_WRAP));
@@ -2257,14 +2265,12 @@
 		nyoff = es->line_count - 1;
 	dy = (es->y_offset - nyoff) * es->line_height;
 	if (dx || dy) {
-		if (!(wnd->flags & WIN_NO_REDRAW)) {
-			RECT32 rc1;
-			RECT32 rc;
-			GetClientRect32(wnd->hwndSelf, &rc1);
-			IntersectRect32(&rc, &rc1, &es->format_rect);
-			ScrollWindowEx32(wnd->hwndSelf, -dx, dy,
-					NULL, &rc, (HRGN32)NULL, NULL, SW_INVALIDATE);
-		}
+		RECT32 rc1;
+		RECT32 rc;
+		GetClientRect32(wnd->hwndSelf, &rc1);
+		IntersectRect32(&rc, &rc1, &es->format_rect);
+		ScrollWindowEx32(wnd->hwndSelf, -dx, dy,
+				NULL, &rc, (HRGN32)NULL, NULL, SW_INVALIDATE);
 		es->y_offset = nyoff;
 		es->x_offset += dx;
 	}
@@ -2440,8 +2446,7 @@
 	EDIT_EM_ScrollCaret(wnd, es);
 
 	/* FIXME: really inefficient */
-	if (!(wnd->flags & WIN_NO_REDRAW))
-		InvalidateRect32(wnd->hwndSelf, NULL, TRUE);
+	InvalidateRect32(wnd->hwndSelf, NULL, TRUE);
 }
 
 
@@ -2525,8 +2530,7 @@
 	es->flags &= ~EF_MODIFIED;
 	es->flags &= ~EF_UPDATE;
 	EDIT_BuildLineDefs_ML(wnd, es);
-	if (!(wnd->flags & WIN_NO_REDRAW))
-		InvalidateRect32(wnd->hwndSelf, NULL, TRUE);
+	InvalidateRect32(wnd->hwndSelf, NULL, TRUE);
 	EDIT_EM_ScrollCaret(wnd, es);
 }
 
@@ -2569,8 +2573,7 @@
 	es->flags &= ~EF_MODIFIED;
 	es->flags &= ~EF_UPDATE;
 	EDIT_BuildLineDefs_ML(wnd, es);
-	if (!(wnd->flags & WIN_NO_REDRAW))
-		InvalidateRect32(wnd->hwndSelf, NULL, TRUE);
+	InvalidateRect32(wnd->hwndSelf, NULL, TRUE);
 	EDIT_EM_ScrollCaret(wnd, es);
 }
 
@@ -2612,16 +2615,16 @@
 			 *	FIXME: do some GetABCCharWidth, or so
 			 *		This is just preliminary
 			 */
-			es->left_margin = es->right_margin = es->char_width;
+			es->left_margin = es->right_margin = es->char_width/4;
 		} else
-			es->left_margin = es->right_margin = es->char_width;
-		return;
+			es->left_margin = es->right_margin = es->char_width/4;
 	} else {
 		if (action & EC_LEFTMARGIN)
 			es->left_margin = left;
 		if (action & EC_RIGHTMARGIN)
 			es->right_margin = right;
 	}
+	dprintf_edit(stddeb, "EDIT_EM_SetMargins: left=%d, right=%d\n", es->left_margin, es->right_margin);
 }
 
 
@@ -2678,24 +2681,36 @@
 		es->flags |= EF_AFTER_WRAP;
 	else
 		es->flags &= ~EF_AFTER_WRAP;
-	if (!(wnd->flags & WIN_NO_REDRAW)) {
-		if (es->flags & EF_FOCUSED) {
-			LRESULT pos = EDIT_EM_PosFromChar(wnd, es, end, after_wrap);
-			SetCaretPos32(SLOWORD(pos), SHIWORD(pos));
-		}
-		/* FIXME: little efficiency, could be better */
-		ORDER_UINT32(start, end);
-		ORDER_UINT32(start, old_start);
-		ORDER_UINT32(start, old_end);
-		ORDER_UINT32(end, old_start);
-		ORDER_UINT32(end, old_end);
-		ORDER_UINT32(old_start, old_end);
-		if (end != old_start) {
-			EDIT_InvalidateText(wnd, es, start, end);
-			EDIT_InvalidateText(wnd, es, old_start, old_end);
-		} else
-			EDIT_InvalidateText(wnd, es, start, old_end);
+	if (es->flags & EF_FOCUSED) {
+		LRESULT pos = EDIT_EM_PosFromChar(wnd, es, end, after_wrap);
+		SetCaretPos32(SLOWORD(pos), SHIWORD(pos));
 	}
+/* This is little  bit more efficient than before, not sure if it can be improved. FIXME? */
+        ORDER_UINT32(start, end);
+        ORDER_UINT32(end, old_end);
+        ORDER_UINT32(start, old_start);
+        ORDER_UINT32(old_start, old_end);
+	if (end != old_start)
+        {
+/*
+ * One can also do 
+ *          ORDER_UINT32(end, old_start);
+ *          EDIT_InvalidateText(wnd, es, start, end);
+ *          EDIT_InvalidateText(wnd, es, old_start, old_end);
+ * in place of the following if statement.                          
+ */
+            if (old_start > end )
+            {
+                EDIT_InvalidateText(wnd, es, start, end);
+                EDIT_InvalidateText(wnd, es, old_start, old_end);
+            }
+            else
+            {
+                EDIT_InvalidateText(wnd, es, start, old_start);
+                EDIT_InvalidateText(wnd, es, end, old_end);
+            }
+	}
+        else EDIT_InvalidateText(wnd, es, start, old_end);
 }
 
 
@@ -3479,6 +3494,7 @@
 	e = EDIT_CharFromPos(wnd, es, x, y, &after_wrap);
 	EDIT_EM_SetSel(wnd, es, (keys & MK_SHIFT) ? es->selection_start : e, e, after_wrap);
 	EDIT_EM_ScrollCaret(wnd, es);
+	es->region_posx = es->region_posx = 0;
 	SetTimer32(wnd->hwndSelf, 0, 100, NULL);
 	return 0;
 }
@@ -3508,6 +3524,7 @@
 {
 	INT32 e;
 	BOOL32 after_wrap;
+	INT32 prex, prey;
 
 	if (GetCapture32() != wnd->hwndSelf)
 		return 0;
@@ -3516,7 +3533,10 @@
 	 *	FIXME: gotta do some scrolling if outside client
 	 *		area.  Maybe reset the timer ?
 	 */
+	prex = x; prey = y;
 	EDIT_ConfinePoint(wnd, es, &x, &y);
+	es->region_posx = (prex < x) ? -1 : ((prex > x) ? 1 : 0);
+	es->region_posy = (prey < y) ? -1 : ((prey > y) ? 1 : 0);
 	e = EDIT_CharFromPos(wnd, es, x, y, &after_wrap);
 	EDIT_EM_SetSel(wnd, es, es->selection_start, e, after_wrap);
 	return 0;
@@ -3677,7 +3697,7 @@
 		EDIT_EM_SetMargins(wnd, es, EC_USEFONTINFO, 0, 0);
 	if (es->style & ES_MULTILINE)
 		EDIT_BuildLineDefs_ML(wnd, es);
-	if (redraw && !(wnd->flags & WIN_NO_REDRAW))
+	if (redraw)
 		InvalidateRect32(wnd->hwndSelf, NULL, TRUE);
 	if (es->flags & EF_FOCUSED) {
 		LRESULT pos;
@@ -3701,6 +3721,7 @@
 	if (text) {
 		dprintf_edit(stddeb, "\t'%s'\n", text);
 		EDIT_EM_ReplaceSel(wnd, es, FALSE, text);
+		es->x_offset = 0;
 	}
 	es->flags |= EF_MODIFIED;
 	es->flags |= EF_UPDATE;
@@ -3749,8 +3770,13 @@
  */
 static void EDIT_WM_Timer(WND *wnd, EDITSTATE *es, INT32 id, TIMERPROC32 timer_proc)
 {
+	if (es->region_posx < 0) {
+		EDIT_MoveBackward(wnd, es, TRUE);
+	} else if (es->region_posx > 0) {
+		EDIT_MoveForward(wnd, es, TRUE);
+	}
 /*
- *	FIXME: gotta do some scrolling here, like
+ *	FIXME: gotta do some vertical scrolling here, like
  *		EDIT_EM_LineScroll(wnd, 0, 1);
  */
 }
diff --git a/controls/status.c b/controls/status.c
index d05aa6d..395ebce 100644
--- a/controls/status.c
+++ b/controls/status.c
@@ -118,13 +118,11 @@
     part_num = ((INT32) wParam) & 0x00ff;
     style = ((INT32) wParam) & 0xff00;
 
-    if (part_num >= 255)
-	return FALSE;
-
-    if ((self->simple) || (part_num==255))
+    if ((self->simple) || (self->parts==NULL) || (part_num==255))
 	part = &self->part0;
     else
 	part = &self->parts[part_num];
+    if (!part) return FALSE;
     part->style = style;
     if (style == SBT_OWNERDRAW) {
 	part->text = text;
diff --git a/debugger/break.c b/debugger/break.c
index 19d3386..d842f50 100644
--- a/debugger/break.c
+++ b/debugger/break.c
@@ -347,19 +347,18 @@
 
         if (pModule->flags & NE_FFLAGS_WIN32)  /* PE module */
         {
-            PE_MODULE *pe = pModule->pe_module;
             PE_MODREF *pem;
             if (!pCurrentProcess) continue;
             pem = pCurrentProcess->modref_list;
             while (pem)
             {
-		if (pem->pe_module == pe) break;
+		if (pem->module == pModule->module32) break;
 		pem = pem->next;
             }
             if (!pem) continue;
             addr.seg = 0;
-            addr.off = pem->load_addr +
-                      (DWORD)pe->pe_header->OptionalHeader.AddressOfEntryPoint;
+            addr.off = (DWORD)RVA_PTR( pem->module,
+                                       OptionalHeader.AddressOfEntryPoint );
             fprintf( stderr, "Win32 task '%s': ", entry.szModule );
             DEBUG_AddBreakpoint( &addr );
         }
diff --git a/debugger/expr.c b/debugger/expr.c
index e8a7d6d..f097f7d 100644
--- a/debugger/expr.c
+++ b/debugger/expr.c
@@ -418,13 +418,10 @@
       exp->un.rgister.result = DEBUG_GetRegister(exp->un.rgister.reg);
       rtn.off = (unsigned int) &exp->un.rgister.result;
       if( exp->un.rgister.reg == REG_EIP )
-	{
 	  rtn.seg = CS_reg(&DEBUG_context);
-	}
       else
-	{
 	  rtn.seg = DS_reg(&DEBUG_context);
-	}
+      DBG_FIX_ADDR_SEG( &rtn, 0 );
       break;
     case EXPR_TYPE_BINOP:
       exp1 = DEBUG_EvalExpr(exp->un.binop.exp1);
diff --git a/debugger/hash.c b/debugger/hash.c
index 815715a..acf281f 100644
--- a/debugger/hash.c
+++ b/debugger/hash.c
@@ -789,24 +789,23 @@
  *
  * Load the entry points of a Win32 module into the hash table.
  */
-static void DEBUG_LoadEntryPoints32( PE_MODULE *pe, const char *name )
+static void DEBUG_LoadEntryPoints32( HMODULE32 hModule, const char *name )
 {
-#define RVA(x) (load_addr+(DWORD)(x))
+#define RVA(x) (hModule+(DWORD)(x))
 
     DBG_ADDR addr;
     char buffer[256];
     int i, j;
+    IMAGE_SECTION_HEADER *pe_seg;
     IMAGE_EXPORT_DIRECTORY *exports;
     IMAGE_DATA_DIRECTORY *debug_dir;
-    DWORD load_addr;
     WORD *ordinals;
     void **functions;
     const char **names;
 
     PE_MODREF *pem = pCurrentProcess->modref_list;
-    while (pem && (pem->pe_module != pe)) pem = pem->next;
+    while (pem && (pem->module != hModule)) pem = pem->next;
     if (!pem) return;
-    load_addr = pem->load_addr;
     exports = pem->pe_export;
 
     addr.seg = 0;
@@ -814,22 +813,24 @@
 
     /* Add start of DLL */
 
-    addr.off = load_addr;
+    addr.off = hModule;
     DEBUG_AddSymbol( name, &addr, NULL, SYM_WIN32 | SYM_FUNC );
 
     /* Add entry point */
 
     sprintf( buffer, "%s.EntryPoint", name );
-    addr.off = RVA( pe->pe_header->OptionalHeader.AddressOfEntryPoint );
+    addr.off = (DWORD)RVA_PTR( hModule, OptionalHeader.AddressOfEntryPoint );
     DEBUG_AddSymbol( buffer, &addr, NULL, SYM_WIN32 | SYM_FUNC );
 
     /* Add start of sections */
 
-    for (i = 0; i < pe->pe_header->FileHeader.NumberOfSections; i++)
+    pe_seg = PE_SECTIONS(hModule);
+    for (i = 0; i < PE_HEADER(hModule)->FileHeader.NumberOfSections; i++)
     {
-        sprintf( buffer, "%s.%s", name, pe->pe_seg[i].Name );
-        addr.off = RVA( pe->pe_seg[i].VirtualAddress );
+        sprintf( buffer, "%s.%s", name, pe_seg->Name );
+        addr.off = RVA(pe_seg->VirtualAddress );
         DEBUG_AddSymbol( buffer, &addr, NULL, SYM_WIN32 | SYM_FUNC );
+        pe_seg++;
     }
 
     /* Add exported functions */
@@ -859,9 +860,9 @@
         DEBUG_AddSymbol( buffer, &addr, NULL, SYM_WIN32 | SYM_FUNC );
     }
 
-    debug_dir = &pe->pe_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG];
+    debug_dir = &PE_HEADER(hModule)->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG];
     if (debug_dir->Size)
-        DEBUG_RegisterDebugInfo( pe, load_addr, name,
+        DEBUG_RegisterDebugInfo( hModule, name,
                                  debug_dir->VirtualAddress, debug_dir->Size );
 #undef RVA
 }
@@ -884,10 +885,7 @@
         fprintf( stderr, " %s", entry.szModule );
 
         if (pModule->flags & NE_FFLAGS_WIN32)  /* PE module */
-        {
-            if (pModule->flags & NE_FFLAGS_BUILTIN) continue;
-            DEBUG_LoadEntryPoints32( pModule->pe_module, entry.szModule );
-        }
+            DEBUG_LoadEntryPoints32( pModule->module32, entry.szModule );
         else  /* NE module */
             DEBUG_LoadEntryPoints16( entry.hModule, pModule, entry.szModule );
     }
diff --git a/debugger/msc.c b/debugger/msc.c
index 8094d86..3be941d 100644
--- a/debugger/msc.c
+++ b/debugger/msc.c
@@ -509,8 +509,8 @@
 	char				* module_name;
 	char				* dbg_info;
 	int				  dbg_size;
+        HMODULE32                         module;
 	LPIMAGE_DEBUG_DIRECTORY           dbgdir;
-	struct pe_data			* pe;
         LPIMAGE_SECTION_HEADER	          sectp;
 	int				  nsect;
 	short int			  dbg_index;			
@@ -881,8 +881,8 @@
  * We don't fully process it here for performance reasons.
  */
 int
-DEBUG_RegisterDebugInfo(struct pe_data * pe,int load_addr,
-                        const char *module_name, u_long v_addr, u_long size)
+DEBUG_RegisterDebugInfo( HMODULE32 hModule, const char *module_name,
+                         u_long v_addr, u_long size)
 {
   int			  has_codeview = FALSE;
   int			  rtn = FALSE;
@@ -891,7 +891,7 @@
   struct deferred_debug_info * deefer;
 
   orig_size = size;
-  dbgptr = (LPIMAGE_DEBUG_DIRECTORY) (load_addr + v_addr);
+  dbgptr = (LPIMAGE_DEBUG_DIRECTORY) (hModule + v_addr);
   for(; size >= sizeof(*dbgptr); size -= sizeof(*dbgptr), dbgptr++ )
     {
       switch(dbgptr->Type)
@@ -904,7 +904,7 @@
     }
 
   size = orig_size;
-  dbgptr = (LPIMAGE_DEBUG_DIRECTORY) (load_addr + v_addr);
+  dbgptr = (LPIMAGE_DEBUG_DIRECTORY) (hModule + v_addr);
   for(; size >= sizeof(*dbgptr); size -= sizeof(*dbgptr), dbgptr++ )
     {
       switch(dbgptr->Type)
@@ -935,16 +935,16 @@
 	   * it just points to itself, and we can ignore this.
 	   */
 	  if(    (dbgptr->Type == IMAGE_DEBUG_TYPE_MISC)
-	      && (pe->pe_header->FileHeader.Characteristics & IMAGE_FILE_DEBUG_STRIPPED) == 0 )
+	      && (PE_HEADER(hModule)->FileHeader.Characteristics & IMAGE_FILE_DEBUG_STRIPPED) == 0 )
 	    {
 	      break;
 	    }
 
 	  deefer = (struct deferred_debug_info *) xmalloc(sizeof(*deefer));
-	  deefer->pe = pe;
-
-	  deefer->dbg_info = NULL;
-	  deefer->dbg_size = 0;
+	  deefer->module    = hModule;
+	  deefer->load_addr = (char *)hModule;
+	  deefer->dbg_info  = NULL;
+	  deefer->dbg_size  = 0;
 
 	  /*
 	   * Read the important bits.  What we do after this depends
@@ -952,16 +952,15 @@
 	   * to proceed if we know what we need to do next.
 	   */
 	  deefer->dbg_size = dbgptr->SizeOfData;
-	  deefer->dbg_info = (char *)(pe->mappeddll+dbgptr->PointerToRawData);
-	  deefer->load_addr = (char *) load_addr;
+	  deefer->dbg_info = (char *)(hModule + dbgptr->PointerToRawData);
 	  deefer->dbgdir = dbgptr;
 	  deefer->next = dbglist;
 	  deefer->loaded = FALSE;
 	  deefer->dbg_index = DEBUG_next_index;
 	  deefer->module_name = xstrdup(module_name);
 
-	  deefer->sectp = pe->pe_seg;
-	  deefer->nsect = pe->pe_header->FileHeader.NumberOfSections;
+	  deefer->sectp = PE_SECTIONS(hModule);
+	  deefer->nsect = PE_HEADER(hModule)->FileHeader.NumberOfSections;
 
 	  dbglist = deefer;
 	  break;
@@ -985,7 +984,7 @@
   struct deferred_debug_info * deefer;
 
   deefer = (struct deferred_debug_info *) xmalloc(sizeof(*deefer));
-  deefer->pe = NULL;
+  deefer->module = 0;
   
   /*
    * Read the important bits.  What we do after this depends
@@ -2401,19 +2400,9 @@
   fprintf(stderr,"Address\t\tModule\tName\n");
 
   for(deefer = dbglist; deefer; deefer = deefer->next)
-    {
-      if( deefer->pe == NULL )
-	{
-	  fprintf(stderr,"0x%8.8x\t(ELF)\t%s\n", 
-		  (unsigned int) deefer->load_addr,
-		  deefer->module_name);
-	}
-      else
-	{
-	  fprintf(stderr,"0x%8.8x\t(Win32)\t%s\n", 
-		  (unsigned int) deefer->load_addr,
-		  deefer->module_name);
-	}
-    }
+  {
+      fprintf(stderr,"0x%8.8x\t(%s)\t%s\n", (unsigned int) deefer->load_addr,
+              deefer->module ? "Win32" : "ELF", deefer->module_name);
+  }
 }
 
diff --git a/files/directory.c b/files/directory.c
index b4ddb7e..f740f3e 100644
--- a/files/directory.c
+++ b/files/directory.c
@@ -161,7 +161,7 @@
     dprintf_dosfs( stddeb, "TempDir    = %s\nCwd        = %c:\\%s\n",
                    DIR_TempDosDir, 'A' + drive, DRIVE_GetDosCwd( drive ) );
 
-    /* Put the temp and Windows directories into the environment */
+    /* Put the temp and Windows and system directories into the environment */
 
     env_p = HEAP_xalloc( SystemHeap, 0, strlen(DIR_TempDosDir) + 6 );
     strcpy( env_p, "TEMP=" );
@@ -171,6 +171,10 @@
     strcpy( env_p, "windir=" );
     strcpy( env_p + 7, DIR_WindowsDosDir );
     putenv( env_p );
+    env_p = HEAP_xalloc( SystemHeap, 0, strlen(DIR_SystemDosDir) + 11 );
+    strcpy( env_p, "winsysdir=" );
+    strcpy( env_p + 10, DIR_SystemDosDir );
+    putenv( env_p );
 
     return 1;
 }
diff --git a/files/dos_fs.c b/files/dos_fs.c
index 74f6cf2..2ace4e0 100644
--- a/files/dos_fs.c
+++ b/files/dos_fs.c
@@ -798,6 +798,42 @@
 
 
 /***********************************************************************
+ *           GetLongPathName32A   (KERNEL32.xxx)
+ */
+DWORD WINAPI GetLongPathName32A( LPCSTR shortpath, LPSTR longpath,
+                                  DWORD longlen )
+{
+    DOS_FULL_NAME full_name;
+
+    /* FIXME: is it correct to always return a fully qualified short path? */
+    if (!DOSFS_GetFullName( shortpath, TRUE, &full_name )) return 0;
+    lstrcpyn32A( longpath, full_name.long_name, longlen );
+    return strlen( full_name.long_name );
+}
+
+
+/***********************************************************************
+ *           GetLongPathName32W   (KERNEL32.269)
+ */
+DWORD WINAPI GetLongPathName32W( LPCWSTR shortpath, LPWSTR longpath,
+                                  DWORD longlen )
+{
+    DOS_FULL_NAME full_name;
+    DWORD ret = 0;
+    LPSTR shortpathA = HEAP_strdupWtoA( GetProcessHeap(), 0, shortpath );
+
+    /* FIXME: is it correct to always return a fully qualified short path? */
+    if (DOSFS_GetFullName( shortpathA, TRUE, &full_name ))
+    {
+        ret = strlen( full_name.short_name );
+        lstrcpynAtoW( longpath, full_name.long_name, longlen );
+    }
+    HeapFree( GetProcessHeap(), 0, shortpathA );
+    return ret;
+}
+
+
+/***********************************************************************
  *           DOSFS_DoGetFullPathName
  *
  * Implementation of GetFullPathName32A/W.
diff --git a/files/file.c b/files/file.c
index f60a115..cdbbe55 100644
--- a/files/file.c
+++ b/files/file.c
@@ -146,7 +146,8 @@
 {
     int save_errno = errno; /* errno gets overwritten by printf */
 
-    dprintf_file(stddeb, "FILE_SetDosError: errno = %d\n", errno );
+    dprintf_file(stddeb, "FILE_SetDosError: errno = %d %s\n", errno,
+		 sys_errlist[errno] );
     switch (save_errno)
     {
     case EAGAIN:
@@ -179,6 +180,12 @@
     case EEXIST:
         DOS_ERROR( ER_FileExists, EC_Exists, SA_Abort, EL_Disk );
         break;
+    case EINVAL:
+        DOS_ERROR( ER_SeekError, EC_NotFound, SA_Ignore, EL_Disk );
+        break;
+    case ENOTEMPTY:
+        DOS_ERROR( ERROR_DIR_NOT_EMPTY, EC_Exists, SA_Ignore, EL_Disk );
+        break;
     default:
         perror( "int21: unknown errno" );
         DOS_ERROR( ER_GeneralFailure, EC_SystemFailure, SA_Abort, EL_Unknown );
@@ -523,6 +530,9 @@
 {
     char temppath[144];
 
+    if (!(drive & ~TF_FORCEDRIVE)) /* drive 0 means current default drive */
+        drive |= DRIVE_GetCurrentDrive();
+
     if ((drive & TF_FORCEDRIVE) &&
         !DRIVE_IsValid( toupper(drive & ~TF_FORCEDRIVE) - 'A' ))
     {
@@ -1185,7 +1195,7 @@
 BOOL32 WINAPI DeleteFile32W( LPCWSTR path )
 {
     LPSTR xpath = HEAP_strdupWtoA( GetProcessHeap(), 0, path );
-    BOOL32 ret = RemoveDirectory32A( xpath );
+    BOOL32 ret = DeleteFile32A( xpath );
     HeapFree( GetProcessHeap(), 0, xpath );
     return ret;
 }
diff --git a/graphics/escape.c b/graphics/escape.c
index 83e006a..cd3873c 100644
--- a/graphics/escape.c
+++ b/graphics/escape.c
@@ -92,6 +92,7 @@
         LPSTR x=PTR_SEG_TO_LIN(segout);
         lstrcpy32A(lpvOutData,x);
         SEGPTR_FREE(x);
+	break;
     }
     case ENABLEPAIRKERNING: {
         LPINT16 enab = (LPINT16)PTR_SEG_TO_LIN(segout);
@@ -99,6 +100,7 @@
         *(LPINT32)lpvOutData = *enab;
         SEGPTR_FREE(enab);
         SEGPTR_FREE(PTR_SEG_TO_LIN(segin));
+	break;
     }
     case GETFACENAME: {
         LPSTR x = (LPSTR)PTR_SEG_TO_LIN(segout);
diff --git a/graphics/x11drv/bitblt.c b/graphics/x11drv/bitblt.c
index 4436913..f2f89fd 100644
--- a/graphics/x11drv/bitblt.c
+++ b/graphics/x11drv/bitblt.c
@@ -975,6 +975,7 @@
                 XPutPixel( image, x, y,
                            COLOR_PixelToPalette[XGetPixel( image, x, y )]);
         XPutImage( display, pixmap, gc, image, 0, 0, 0, 0, width, height );
+	XDestroyImage( image );
     }
 }
 
diff --git a/if1632/Makefile.in b/if1632/Makefile.in
index 2469274..63fb303 100644
--- a/if1632/Makefile.in
+++ b/if1632/Makefile.in
@@ -31,7 +31,9 @@
 	ole2prox.spec \
 	ole32.spec \
 	olecli.spec \
+	olecli32.spec \
 	olesvr.spec \
+	olesvr32.spec \
 	shell.spec \
 	shell32.spec \
 	sound.spec \
@@ -43,7 +45,9 @@
 	user32.spec \
 	ver.spec \
 	version.spec \
+	w32skrnl.spec \
 	w32sys.spec \
+	win32s16.spec \
 	win87em.spec \
 	winaspi.spec \
 	wing.spec \
diff --git a/if1632/advapi32.spec b/if1632/advapi32.spec
index d72abaa..a53a955 100644
--- a/if1632/advapi32.spec
+++ b/if1632/advapi32.spec
@@ -87,8 +87,8 @@
 0083 stub LogonUserW
 0084 stub LookupAccountNameA
 0085 stub LookupAccountNameW
-0086 stub LookupAccountSidA
-0087 stub LookupAccountSidW
+0086 stdcall LookupAccountSidA(ptr ptr ptr ptr ptr ptr ptr) LookupAccountSid32A
+0087 stdcall LookupAccountSidW(ptr ptr ptr ptr ptr ptr ptr) LookupAccountSid32W
 0088 stub LookupPrivilegeDisplayNameA
 0089 stub LookupPrivilegeDisplayNameW
 0090 stub LookupPrivilegeNameA
diff --git a/if1632/builtin.c b/if1632/builtin.c
index d21f294..f514004 100644
--- a/if1632/builtin.c
+++ b/if1632/builtin.c
@@ -16,6 +16,7 @@
 #include "neexe.h"
 #include "stackframe.h"
 #include "user.h"
+#include "process.h"
 #include "stddebug.h"
 #include "debug.h"
 
@@ -101,6 +102,7 @@
 extern const DLL_DESCRIPTOR LZEXPAND_Descriptor;
 extern const DLL_DESCRIPTOR VER_Descriptor;
 extern const DLL_DESCRIPTOR W32SYS_Descriptor;
+extern const DLL_DESCRIPTOR WIN32S16_Descriptor;
 extern const DLL_DESCRIPTOR WING_Descriptor;
 extern const DLL_DESCRIPTOR WINASPI_Descriptor;
 
@@ -110,15 +112,18 @@
 extern const DLL_DESCRIPTOR COMCTL32_Descriptor;
 extern const DLL_DESCRIPTOR COMDLG32_Descriptor;
 extern const DLL_DESCRIPTOR CRTDLL_Descriptor;
-extern const DLL_DESCRIPTOR OLE32_Descriptor;
 extern const DLL_DESCRIPTOR GDI32_Descriptor;
 extern const DLL_DESCRIPTOR KERNEL32_Descriptor;
 extern const DLL_DESCRIPTOR LZ32_Descriptor;
 extern const DLL_DESCRIPTOR MPR_Descriptor;
 extern const DLL_DESCRIPTOR NTDLL_Descriptor;
+extern const DLL_DESCRIPTOR OLE32_Descriptor;
+extern const DLL_DESCRIPTOR OLECLI32_Descriptor;
+extern const DLL_DESCRIPTOR OLESVR32_Descriptor;
 extern const DLL_DESCRIPTOR SHELL32_Descriptor;
 extern const DLL_DESCRIPTOR USER32_Descriptor;
 extern const DLL_DESCRIPTOR VERSION_Descriptor;
+extern const DLL_DESCRIPTOR W32SKRNL_Descriptor;
 extern const DLL_DESCRIPTOR WINMM_Descriptor;
 extern const DLL_DESCRIPTOR WINSPOOL_Descriptor;
 extern const DLL_DESCRIPTOR WSOCK32_Descriptor;
@@ -156,6 +161,7 @@
     { &LZEXPAND_Descriptor, NULL, 0 },
     { &VER_Descriptor,      NULL, 0 },
     { &W32SYS_Descriptor,   NULL, 0 },
+    { &WIN32S16_Descriptor, NULL, 0 },
     { &WING_Descriptor,     NULL, 0 },
     { &WINASPI_Descriptor,  NULL, 0 },
     /* Win32 DLLs */
@@ -163,15 +169,18 @@
     { &COMCTL32_Descriptor, NULL, DLL_FLAG_WIN32 | DLL_FLAG_NOT_USED },
     { &COMDLG32_Descriptor, NULL, DLL_FLAG_WIN32 },
     { &CRTDLL_Descriptor,   NULL, DLL_FLAG_WIN32 },
-    { &OLE32_Descriptor,    NULL, DLL_FLAG_WIN32 | DLL_FLAG_NOT_USED },
     { &GDI32_Descriptor,    NULL, DLL_FLAG_WIN32 },
-    { &KERNEL32_Descriptor, NULL, DLL_FLAG_WIN32 | DLL_FLAG_ALWAYS_USED },
+    { &KERNEL32_Descriptor, NULL, DLL_FLAG_WIN32 },
     { &LZ32_Descriptor,     NULL, DLL_FLAG_WIN32 },
-    { &MPR_Descriptor,      NULL, DLL_FLAG_WIN32 | DLL_FLAG_NOT_USED },
+    { &MPR_Descriptor,      NULL, DLL_FLAG_WIN32 },
     { &NTDLL_Descriptor,    NULL, DLL_FLAG_WIN32 },
+    { &OLE32_Descriptor,    NULL, DLL_FLAG_WIN32 | DLL_FLAG_NOT_USED },
+    { &OLECLI32_Descriptor, NULL, DLL_FLAG_WIN32 | DLL_FLAG_NOT_USED },
+    { &OLESVR32_Descriptor, NULL, DLL_FLAG_WIN32 | DLL_FLAG_NOT_USED },
     { &SHELL32_Descriptor,  NULL, DLL_FLAG_WIN32 },
     { &USER32_Descriptor,   NULL, DLL_FLAG_WIN32 },
     { &VERSION_Descriptor,  NULL, DLL_FLAG_WIN32 },
+    { &W32SKRNL_Descriptor, NULL, DLL_FLAG_WIN32 },
     { &WINMM_Descriptor,    NULL, DLL_FLAG_WIN32 },
     { &WINSPOOL_Descriptor, NULL, DLL_FLAG_WIN32 },
     { &WSOCK32_Descriptor,  NULL, DLL_FLAG_WIN32 },
@@ -182,46 +191,6 @@
   /* Ordinal number for interrupt 0 handler in WPROCS.DLL */
 #define FIRST_INTERRUPT_ORDINAL 100
 
-/***********************************************************************
- *           BUILTIN_BuildDebugEntryPoints
- *
- * Build the table of relay-debugging entry points for a Win32 DLL.
- */
-static void BUILTIN_BuildDebugEntryPoints( BUILTIN_DLL *dll )
-{
-    int i;
-    DEBUG_ENTRY_POINT *entry;
-    extern void RELAY_CallFrom32();
-
-    assert( !dll->dbg_funcs );
-    assert( dll->flags & DLL_FLAG_WIN32 );
-    dll->dbg_funcs = HeapAlloc( SystemHeap, 0,
-                      dll->descr->win32.nb_funcs * sizeof(DEBUG_ENTRY_POINT) );
-    entry = dll->dbg_funcs;
-    for (i = 0; i < dll->descr->win32.nb_funcs; i++, entry++)
-    {
-        BYTE args = dll->descr->win32.args[i];
-        entry->call = 0xe8;  /* call */
-        switch(args)
-        {
-        case 0xfe:  /* register func */
-            entry->callfrom32 = (DWORD)dll->descr->win32.functions[i] -
-                                (DWORD)&entry->ret;
-            entry->ret        = 0x90;  /* nop */
-            entry->args       = 0;
-            break;
-        case 0xff:  /* stub */
-            entry->args = 0xffff;
-            break;
-        default:  /* normal function (stdcall or cdecl) */
-            entry->callfrom32 = (DWORD)RELAY_CallFrom32 - (DWORD)&entry->ret;
-            entry->ret        = (args & 0x80) ? 0xc3 : 0xc2; /* ret / ret $n */
-            entry->args       = (args & 0x7f) * sizeof(int);
-            break;
-        }
-    }
-}
-
 
 /***********************************************************************
  *           BUILTIN_DoLoadModule16
@@ -279,20 +248,179 @@
  * Load a built-in Win32 module. Helper function for BUILTIN_LoadModule
  * and BUILTIN_Init.
  */
-static HMODULE16 BUILTIN_DoLoadModule32( BUILTIN_DLL *table )
+static HMODULE32 BUILTIN_DoLoadModule32( BUILTIN_DLL *dll )
 {
+    extern void RELAY_CallFrom32();
+
     HMODULE16 hModule;
     NE_MODULE *pModule;
     OFSTRUCT ofs;
+    IMAGE_DATA_DIRECTORY *dir;
+    IMAGE_DOS_HEADER *dos;
+    IMAGE_NT_HEADERS *nt;
+    IMAGE_SECTION_HEADER *sec;
+    IMAGE_EXPORT_DIRECTORY *exp;
+    LPVOID *funcs;
+    LPSTR *names;
+    DEBUG_ENTRY_POINT *entry;
+    PE_MODREF *pem;
+    INT32 i, size;
+    BYTE *addr;
 
-    sprintf( ofs.szPathName, "%s.DLL", table->descr->name );
+    /* Allocate the module */
+
+    size = (sizeof(IMAGE_DOS_HEADER)
+            + sizeof(IMAGE_NT_HEADERS)
+            + 2 * sizeof(IMAGE_SECTION_HEADER)
+            + sizeof(IMAGE_EXPORT_DIRECTORY)
+            + dll->descr->win32.nb_funcs * sizeof(LPVOID)
+            + dll->descr->win32.nb_names * sizeof(LPSTR));
+    if (debugging_relay)
+        size += dll->descr->win32.nb_funcs * sizeof(DEBUG_ENTRY_POINT);
+    addr  = VirtualAlloc( NULL, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE );
+    if (!addr) return 0;
+    dos   = (IMAGE_DOS_HEADER *)addr;
+    nt    = (IMAGE_NT_HEADERS *)(dos + 1);
+    sec   = (IMAGE_SECTION_HEADER *)(nt + 1);
+    exp   = (IMAGE_EXPORT_DIRECTORY *)(sec + 2);
+    funcs = (LPVOID *)(exp + 1);
+    names = (LPSTR *)(funcs + dll->descr->win32.nb_funcs);
+    entry = (DEBUG_ENTRY_POINT *)(names + dll->descr->win32.nb_names);
+
+    /* Build the DOS and NT headers */
+
+    dos->e_magic  = IMAGE_DOS_SIGNATURE;
+    dos->e_lfanew = sizeof(*dos);
+
+    nt->Signature                       = IMAGE_NT_SIGNATURE;
+    nt->FileHeader.Machine              = IMAGE_FILE_MACHINE_I386;
+    nt->FileHeader.NumberOfSections     = 2;  /* exports + code */
+    nt->FileHeader.SizeOfOptionalHeader = sizeof(nt->OptionalHeader);
+    nt->FileHeader.Characteristics      = IMAGE_FILE_DLL;
+
+    nt->OptionalHeader.Magic = IMAGE_NT_OPTIONAL_HDR_MAGIC;
+    nt->OptionalHeader.SizeOfCode                  = 0x1000;
+    nt->OptionalHeader.SizeOfInitializedData       = 0;
+    nt->OptionalHeader.SizeOfUninitializedData     = 0;
+    nt->OptionalHeader.ImageBase                   = (DWORD)addr;
+    nt->OptionalHeader.SectionAlignment            = 0x1000;
+    nt->OptionalHeader.FileAlignment               = 0x1000;
+    nt->OptionalHeader.MajorOperatingSystemVersion = 1;
+    nt->OptionalHeader.MinorOperatingSystemVersion = 0;
+    nt->OptionalHeader.MajorSubsystemVersion       = 4;
+    nt->OptionalHeader.MinorSubsystemVersion       = 0;
+    nt->OptionalHeader.SizeOfImage                 = size;
+    nt->OptionalHeader.SizeOfHeaders               = (BYTE *)exp - addr;
+    nt->OptionalHeader.NumberOfRvaAndSizes = IMAGE_NUMBEROF_DIRECTORY_ENTRIES;
+
+    /* Build the export directory */
+
+    dir = &nt->OptionalHeader.DataDirectory[IMAGE_FILE_EXPORT_DIRECTORY];
+    dir->VirtualAddress = (BYTE *)exp - addr;
+    dir->Size = sizeof(*exp)
+                + dll->descr->win32.nb_funcs * sizeof(LPVOID)
+                + dll->descr->win32.nb_names * sizeof(LPSTR);
+
+    /* Build the exports section */
+
+    strcpy( sec->Name, ".edata" );
+    sec->Misc.VirtualSize = dir->Size;
+    sec->VirtualAddress   = (BYTE *)exp - addr;
+    sec->SizeOfRawData    = dir->Size;
+    sec->PointerToRawData = (BYTE *)exp - addr;
+    sec->Characteristics  = (IMAGE_SCN_CNT_INITIALIZED_DATA |
+                             IMAGE_SCN_MEM_EXECUTE | IMAGE_SCN_MEM_READ |
+                             IMAGE_SCN_MEM_WRITE);
+
+    /* Build the code section */
+
+    sec++;
+    strcpy( sec->Name, ".code" );
+    if (debugging_relay)
+        sec->SizeOfRawData = dll->descr->win32.nb_funcs * sizeof(DEBUG_ENTRY_POINT);
+    else
+        sec->SizeOfRawData = 1;
+    sec->Misc.VirtualSize = sec->SizeOfRawData;
+    sec->VirtualAddress   = (BYTE *)entry - addr;
+    sec->PointerToRawData = (BYTE *)entry - addr;
+    sec->Characteristics  = (IMAGE_SCN_CNT_INITIALIZED_DATA |
+                             IMAGE_SCN_MEM_EXECUTE | IMAGE_SCN_MEM_READ);
+
+    /* Build the exports section data */
+
+    exp->Name                  = (BYTE *)dll->descr->name - addr;  /*??*/
+    exp->Base                  = dll->descr->win32.base;
+    exp->NumberOfFunctions     = dll->descr->win32.nb_funcs;
+    exp->NumberOfNames         = dll->descr->win32.nb_names;
+    exp->AddressOfFunctions    = (LPDWORD *)((BYTE *)funcs - addr);
+    exp->AddressOfNames        = (LPDWORD *)((BYTE *)names - addr);
+    exp->AddressOfNameOrdinals = (LPWORD *)((BYTE *)dll->descr->win32.ordinals - addr);
+
+    /* Build the funcs table */
+
+    if (debugging_relay)
+    {
+        dll->dbg_funcs = entry;
+        for (i = 0; i < dll->descr->win32.nb_funcs; i++, funcs++, entry++)
+        {
+            BYTE args = dll->descr->win32.args[i];
+            entry->call = 0xe8;  /* call */
+            switch(args)
+            {
+            case 0xfe:  /* register func */
+                entry->callfrom32 = (DWORD)dll->descr->win32.functions[i] -
+                                    (DWORD)&entry->ret;
+                entry->ret        = 0x90;  /* nop */
+                entry->args       = 0;
+                *funcs = (LPVOID)((BYTE *)entry - addr);
+                break;
+            case 0xff:  /* stub or extern */
+                if (dll->descr->win32.functions[i])
+                    *funcs = (LPVOID)((BYTE *)dll->descr->win32.functions[i]
+                                              - addr);
+                break;
+            default:  /* normal function (stdcall or cdecl) */
+                entry->callfrom32 = (DWORD)RELAY_CallFrom32 -
+                                    (DWORD)&entry->ret;
+                entry->ret        = (args & 0x80) ? 0xc3 : 0xc2; /*ret/ret $n*/
+                entry->args       = (args & 0x7f) * sizeof(int);
+                *funcs = (LPVOID)((BYTE *)entry - addr);
+                break;
+            }
+        }
+    }
+    else
+    {
+        for (i = 0; i < dll->descr->win32.nb_funcs; i++, funcs++)
+            if (dll->descr->win32.functions[i])
+                *funcs = (LPVOID)((BYTE *)dll->descr->win32.functions[i]
+                                           - addr);
+    }
+
+    /* Build the names table */
+
+    for (i = 0; i < exp->NumberOfNames; i++, names++)
+        if (dll->descr->win32.names[i])
+            *names = (LPSTR)((BYTE *)dll->descr->win32.names[i] - addr);
+
+    /* Create a modref */
+
+    pem = (PE_MODREF *)HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
+                                  sizeof(*pem) );
+    pem->module = (HMODULE32)addr;
+    pem->pe_export = exp;
+    pem->next = pCurrentProcess->modref_list;
+    pCurrentProcess->modref_list = pem;
+
+    /* Create a Win16 dummy module */
+
+    sprintf( ofs.szPathName, "%s.DLL", dll->descr->name );
     hModule = MODULE_CreateDummyModule( &ofs );
     pModule = (NE_MODULE *)GlobalLock16( hModule );
-    pModule->pe_module = (PE_MODULE *)table;
     pModule->flags = NE_FFLAGS_SINGLEDATA | NE_FFLAGS_BUILTIN |
-        NE_FFLAGS_LIBMODULE | NE_FFLAGS_WIN32;
-    if (debugging_relay) BUILTIN_BuildDebugEntryPoints( table );
-    return hModule;
+                     NE_FFLAGS_LIBMODULE | NE_FFLAGS_WIN32;
+    pModule->module32 = (HMODULE32)addr;
+    return pModule->module32;
 }
 
 
@@ -358,7 +486,7 @@
  * Load a built-in module. If the 'force' parameter is FALSE, we only
  * load the module if it has not been disabled via the -dll option.
  */
-HMODULE16 BUILTIN_LoadModule( LPCSTR name, BOOL32 force )
+HMODULE32 BUILTIN_LoadModule( LPCSTR name, BOOL32 force )
 {
     BUILTIN_DLL *table;
     char dllname[16], *p;
@@ -484,56 +612,14 @@
     /* Now find the function */
 
     ordinal = ((DWORD)relay-(DWORD)dll->dbg_funcs) / sizeof(DEBUG_ENTRY_POINT);
-    ordinal += descr->base;
     for (i = 0; i < descr->nb_names; i++)
         if (descr->ordinals[i] == ordinal) break;
     assert( i < descr->nb_names );
 
-    sprintf( buffer, "%s.%d: %s", descr->name, ordinal, descr->names[i] );
-    *typemask = descr->argtypes[ordinal - descr->base];
-    return (FARPROC32)descr->functions[ordinal - descr->base];
-}
-
-
-/***********************************************************************
- *           BUILTIN_GetProcAddress32
- *
- * Implementation of GetProcAddress() for built-in Win32 modules.
- * FIXME: this should be unified with the real GetProcAddress32().
- */
-FARPROC32 BUILTIN_GetProcAddress32( NE_MODULE *pModule, LPCSTR function )
-{
-    BUILTIN_DLL *dll = (BUILTIN_DLL *)pModule->pe_module;
-    const WIN32_DESCRIPTOR *info = &dll->descr->win32;
-    WORD ordinal = 0;
-
-    if (!dll) return NULL;
-
-    if (HIWORD(function))  /* Find function by name */
-    {
-        int i;
-
-        dprintf_module( stddeb, "Looking for function %s in %s\n",
-                        function, dll->descr->name );
-        for (i = 0; i < info->nb_names; i++)
-            if (!strcmp( function, info->names[i] ))
-            {
-                ordinal = info->ordinals[i];
-                break;
-            }
-        if (i >= info->nb_names) return NULL;  /* not found */
-    }
-    else  /* Find function by ordinal */
-    {
-        ordinal = LOWORD(function);
-        dprintf_module( stddeb, "Looking for ordinal %d in %s\n",
-                        ordinal, dll->descr->name );
-        if ((ordinal < info->base) || (ordinal >= info->base + info->nb_funcs))
-            return NULL;  /* not found */
-    }
-    if (dll->dbg_funcs && (dll->dbg_funcs[ordinal-info->base].args != 0xffff))
-        return (FARPROC32)&dll->dbg_funcs[ordinal - info->base];
-    return (FARPROC32)info->functions[ordinal - info->base];
+    sprintf( buffer, "%s.%d: %s", descr->name, ordinal + descr->base,
+             descr->names[i] );
+    *typemask = descr->argtypes[ordinal];
+    return (FARPROC32)descr->functions[ordinal];
 }
 
 
diff --git a/if1632/crtdll.spec b/if1632/crtdll.spec
index c0b8f3c..91b4e2d 100644
--- a/if1632/crtdll.spec
+++ b/if1632/crtdll.spec
@@ -37,7 +37,7 @@
  33 stub __threadhandle
  34 stub __threadid
  35 stub __toascii
- 36 stub _abnormal_termination
+ 36 cdecl _abnormal_termination() CRTDLL__abnormal_termination
  37 stub _access
  38 extern _acmdln_dll CRTDLL_acmdln_dll
  39 stub _aexit_rtn_dll
@@ -260,7 +260,7 @@
 256 stub _read
 257 stub _rmdir
 258 stub _rmtmp
-259 stub _rotl
+259 cdecl _rotl (long long) CRTDLL__rotl
 260 stub _rotr
 261 stub _scalb
 262 stub _searchenv
@@ -280,7 +280,7 @@
 276 stub _spawnve
 277 stub _spawnvp
 278 stub _spawnvpe
-279 stub _splitpath
+279 cdecl _splitpath (ptr ptr ptr ptr ptr) CRTDLL__splitpath
 280 cdecl _stat (ptr ptr) CRTDLL__stat
 281 stub _statusfp
 282 cdecl _strcmpi(ptr ptr) CRTDLL__strcmpi
diff --git a/if1632/gdi.spec b/if1632/gdi.spec
index 07848fc..f792059 100644
--- a/if1632/gdi.spec
+++ b/if1632/gdi.spec
@@ -385,7 +385,7 @@
 613 pascal16 EnumFontFamiliesEx(word ptr segptr long long) THUNK_EnumFontFamiliesEx16
 614 stub AddLpkToGDI
 615 stub GetCharacterPlacement
-616 stub GetFontLanguageInfo
+616 pascal GetFontLanguageInfo(word) GetFontLanguageInfo16
 650 stub BuildInverseTableDIB
 701 stub GDITHKCONNECTIONDATALS
 702 stub FT_GDIFTHKTHKCONNECTIONDATA
diff --git a/if1632/gdi32.spec b/if1632/gdi32.spec
index e339598..686cfcf 100644
--- a/if1632/gdi32.spec
+++ b/if1632/gdi32.spec
@@ -173,7 +173,7 @@
 166 stub GetCurrentObject
 167 stdcall GetCurrentPositionEx(long ptr) GetCurrentPositionEx32
 168 stdcall GetDCOrgEx(long ptr) GetDCOrgEx
-169 stub GetDIBColorTable
+169 stdcall GetDIBColorTable(long long long ptr) GetDIBColorTable32
 170 stdcall GetDIBits(long long long long ptr ptr long) GetDIBits32
 171 stdcall GetDeviceCaps(long long) GetDeviceCaps32
 172 stub GetDeviceGammaRamp
@@ -186,7 +186,7 @@
 179 stub GetEnhMetaFilePaletteEntries
 180 stub GetEnhMetaFileW
 181 stub GetFontData
-182 stub GetFontLanguageInfo
+182 stdcall GetFontLanguageInfo(long) GetFontLanguageInfo32
 183 stub GetFontResourceInfo
 184 stub GetFontResourceInfoW
 185 stub GetGlyphOutline
@@ -315,7 +315,7 @@
 308 stdcall SetBrushOrgEx(long long long ptr) SetBrushOrgEx
 309 stub SetColorAdjustment
 310 stub SetColorSpace
-311 stub SetDIBColorTable
+311 stdcall SetDIBColorTable(long long long ptr) SetDIBColorTable32
 312 stdcall SetDIBits(long long long long ptr ptr long) SetDIBits32
 313 stdcall SetDIBitsToDevice(long long long long long long long long long
                                ptr ptr long) SetDIBitsToDevice32
@@ -389,7 +389,7 @@
 378 stub GdiWinWatchGetClipList
 379 stub GdiWinWatchOpen
 380 stub GetGlyphOutlineWow
-381 stub GetTextCharsetInfo
+381 stdcall GetTextCharsetInfo(long ptr long) GetTextCharsetInfo
 382 stdcall TranslateCharsetInfo(ptr ptr long) TranslateCharSetInfo
 383 stub UpdateICMRegKeyA
 384 stub UpdateICMRegKeyW
diff --git a/if1632/kernel.spec b/if1632/kernel.spec
index 98f1934..c7fa8da 100644
--- a/if1632/kernel.spec
+++ b/if1632/kernel.spec
@@ -30,7 +30,7 @@
 26  pascal16 GlobalFreeAll(word) GlobalFreeAll
 27  pascal16 GetModuleName(word ptr word) GetModuleName
 28  stub GlobalMasterHandle
-29  pascal16 Yield() Yield
+29  pascal16 Yield() Yield16
 30  pascal16 WaitEvent(word) WaitEvent
 31  pascal16 PostEvent(word) PostEvent
 32  pascal16 SetPriority(word s_word) SetPriority
@@ -91,7 +91,7 @@
 91  register InitTask() InitTask
 92  pascal   GetTempDrive(word) WIN16_GetTempDrive
 93  pascal16 GetCodeHandle(segptr) GetCodeHandle
-94  stub DefineHandleTable
+94  pascal16 DefineHandleTable(word) DefineHandleTable16
 95  pascal16 LoadLibrary(str) LoadLibrary16
 96  pascal16 FreeLibrary(word) FreeLibrary16
 97  pascal16 GetTempFileName(word str word ptr) GetTempFileName16
@@ -103,7 +103,7 @@
 103 register NetBIOSCall() NetBIOSCall
 104 stub GetCodeInfo
 105 pascal16 GetExeVersion() GetExeVersion
-106 pascal SetSwapAreaSize(word) SetSwapAreaSize
+106 pascal SetSwapAreaSize(word) SetSwapAreaSize16
 107 pascal16 SetErrorMode(word) SetErrorMode16
 108 pascal16 SwitchStackTo(word word word) SwitchStackTo
 109 register SwitchStackBack(word word word) SwitchStackBack
@@ -232,6 +232,7 @@
 233 stub RegUnloadKey
 234 stub RegSaveKey
 235 stub InvalidateNlsCache
+236 stub GetProductName
 237 stub KERNEL_237
 262 stub KERNEL_262
 263 stub KERNEL_263
@@ -280,6 +281,7 @@
 359 pascal KERNEL_359(long) _KERNEL_359
 360 stub OpenFileEx
 #361 PIGLET_361
+365 stub KERNEL_365
 403 pascal16 FarSetOwner(word word) FarSetOwner
 404 pascal16 FarGetOwner(word) FarGetOwner
 406 stub WritePrivateProfileStruct
@@ -312,6 +314,7 @@
 471 stub KERNEL_471
 472 register KERNEL_472() _KERNEL_472
 473 stub KERNEL_473
+475 stub KERNEL_475
 482 stub KERNEL_482
 485 stub KERNEL_485
 491 stub RegisterServiceProcess
@@ -327,11 +330,21 @@
 518 stub CallProcEx32W
 519 stub KERNEL_519
 522 stub KERNEL_522
+523 stub KERNEL_523
 525 stub KERNEL_525
+531 stub KERNEL_531
+532 stub KERNEL_532
+540 stub KERNEL_540
+541 stub KERNEL_541
+544 stub KERNEL_544
 600 stub KERNEL_600
 601 stub KERNEL_601
 604 stub KERNEL_604
 605 stub KERNEL_605
+606 stub KERNEL_606
+607 stub KERNEL_607
+608 stub KERNEL_608
+611 stub KERNEL_611
 612 stub KERNEL_612
 613 stub KERNEL_613
 614 stub KERNEL_614
@@ -339,6 +352,6 @@
 621 stub KERNEL_621
 627 stub IsBadFlatReadWritePtr
 630 stub KERNEL_630
-631 pascal FUNC004(word word long) FUNC004	# shell hook
-651 stub KERNEL_651
+631 pascal FUNC004(word word long) FUNC004	#C16ThkSl01?
+651 stub KERNEL_651				#ThunkConnect16?
 700 pascal KERNEL_700() stub_KERNEL_700
diff --git a/if1632/kernel32.spec b/if1632/kernel32.spec
index c0b0b1c..4de6ca3 100644
--- a/if1632/kernel32.spec
+++ b/if1632/kernel32.spec
@@ -160,7 +160,7 @@
 169 stub CreateNamedPipeW
 170 stub CreatePipe
 171 stdcall CreateProcessA(str str ptr ptr long long ptr str ptr ptr) CreateProcess32A
-172 stub CreateProcessW
+172 stdcall CreateProcessW(wstr wstr ptr ptr long long ptr wstr ptr ptr) CreateProcess32W
 173 stub CreateRemoteThread
 174 stdcall CreateSemaphoreA(ptr long long str) CreateSemaphore32A
 175 stdcall CreateSemaphoreW(ptr long long wstr) CreateSemaphore32W
@@ -176,7 +176,7 @@
 185 stdcall DeleteCriticalSection(ptr)	DeleteCriticalSection
 186 stdcall DeleteFileA(str) DeleteFile32A
 187 stdcall DeleteFileW(wstr) DeleteFile32W
-188 stub DeviceIoControl
+188 stdcall DeviceIoControl(long long ptr long ptr long ptr ptr) DeviceIoControl
 189 stdcall DisableThreadLibraryCalls(long) DisableThreadLibraryCalls
 190 stub DisconnectNamedPipe
 191 stdcall DosDateTimeToFileTime(long long ptr) DosDateTimeToFileTime
@@ -250,7 +250,7 @@
 259 stdcall FlushConsoleInputBuffer(long) FlushConsoleInputBuffer
 260 stdcall FlushFileBuffers(long) FlushFileBuffers
 261 stub FlushInstructionCache
-262 stub FlushViewOfFile
+262 stdcall FlushViewOfFile(ptr long) FlushViewOfFile
 263 stub FoldStringA
 264 stub FoldStringW
 265 stdcall FormatMessageA(long ptr long long ptr long ptr) FormatMessage32A
@@ -362,7 +362,7 @@
 371 stub GetPrivateProfileStructW
 372 stdcall GetProcAddress(long str) GetProcAddress32
 373 stdcall GetProcessAffinityMask(long ptr ptr) GetProcessAffinityMask
-374 stub GetProcessFlags
+374 stdcall GetProcessFlags(long) GetProcessFlags
 375 stdcall GetProcessHeap() GetProcessHeap
 376 stub GetProcessHeaps
 377 stub GetProcessShutdownParameters
@@ -531,7 +531,7 @@
 540 stdcall OpenFileMappingW(long long wstr) OpenFileMapping32W
 541 stdcall OpenMutexA(long long str) OpenMutex32A
 542 stdcall OpenMutexW(long long wstr) OpenMutex32W
-543 stub OpenProcess
+543 stdcall OpenProcess(long long long) OpenProcess32
 544 stub OpenProfileUserMapping
 545 stdcall OpenSemaphoreA(long long str) OpenSemaphore32A
 546 stdcall OpenSemaphoreW(long long wstr) OpenSemaphore32W
@@ -553,7 +553,7 @@
 562 stub QueryNumberOfEventLogRecords
 563 stub QueryOldestEventLogRecord
 564 stdcall QueryPerformanceCounter(ptr) QueryPerformanceCounter
-565 stub QueryPerformanceFrequency
+565 stdcall QueryPerformanceFrequency(ptr) QueryPerformanceFrequency
 566 stub QueueUserAPC
 567 register RaiseException() EXC_RaiseException
 568 stdcall ReadConsoleA(long ptr long ptr ptr) ReadConsole32A
@@ -843,3 +843,56 @@
 853 stub VirtualBufferExceptionHandler
 854 stub WriteConsoleInputVDMA
 855 stub WriteConsoleInputVDMW
+
+# NT 4.0 additions
+856 stub CancelIo
+857 stub CancelWaitableTimer
+858 stub CopyFileExA
+859 stub CopyFileExW
+860 stub CreateFiber
+861 stub CreateWaitableTimerA
+862 stub CreateWaitableTimerW
+863 stub DeleteFiber
+864 stub DuplicateConsoleHandle
+865 stub FindFirstFileExA
+866 stub FindFirstFileExW
+867 stub GetConsoleInputExeNameA
+868 stub GetConsoleInputExeNameW
+869 stub GetConsoleKeyboardLayoutNameA
+870 stub GetConsoleKeyboardLayoutNameW
+871 stub GetDiskFreeSpaceExA
+873 stub GetDiskFreeSpaceExW
+874 stub GetFileAttributesExA
+875 stub GetFileAttributesExW
+876 stub GetProcessPriorityBoost
+877 stub GetThreadPriorityBoost
+878 stub InterlockedCompareExchange
+879 stub InterlockedExchangeAdd
+880 stub IsProcessorFeaturePresent
+881 stub OpenWaitableTimerA
+882 stub OpenWaitableTimerW
+883 stub ReadConsoleInputExA
+884 stub ReadConsoleInputExW
+885 stub ReadDirectoryChangesW
+886 stub ReadFileScatter
+887 stub SetConsoleIcon
+888 stub SetConsoleInputExeNameA
+889 stub SetConsoleInputExeNameW
+890 stub SetProcessAffinityMask
+891 stub SetProcessPriorityBoost
+892 stub SetThreadIdealProcessor
+893 stub SetThreadPriorityBoost
+894 stub SetWaitableTimer
+895 stub SignalObjectAndWait
+896 stub SwitchToFiber
+897 stub SwitchToThread
+898 stub TryEnterCriticalSection
+899 stub VirtualAllocEx
+900 stub VirtualFreeEx
+901 stub WriteFileGather
+
+1346 stdcall PrivateLoadLibrary(str) PrivateLoadLibrary
+1545 stdcall PrivateFreeLibrary(long) PrivateFreeLibrary
+
+#1599 wrong ordinal (249 in Win32s's W32SCOMB.DLL) !
+1599 stdcall Get16DLLAddress(long str) Get16DLLAddress
diff --git a/if1632/mpr.spec b/if1632/mpr.spec
index ade7cba..c1977b4 100644
--- a/if1632/mpr.spec
+++ b/if1632/mpr.spec
@@ -58,7 +58,7 @@
 0077 stub WNetGetNetworkInformationW
 0078 stub WNetGetProviderNameA
 0079 stub WNetGetProviderNameW
-0080 stub WNetGetResourceInformationA
+0080 stdcall WNetGetResourceInformationA(ptr ptr ptr ptr) WNetGetResourceInformation32A
 0081 stub WNetGetResourceInformationW
 0082 stub WNetGetResourceParentA
 0083 stub WNetGetResourceParentW
@@ -70,7 +70,7 @@
 0089 stub WNetLogoffW
 0090 stub WNetLogonA
 0091 stub WNetLogonW
-0092 stub WNetOpenEnumA
+0092 stdcall WNetOpenEnumA(long long ptr ptr) WNetOpenEnum32A
 0093 stub WNetOpenEnumW
 0094 stub WNetRemoveCachedPassword
 0095 stub WNetRestoreConnectionA
diff --git a/if1632/ntdll.spec b/if1632/ntdll.spec
index b8fd7f5..4295ecc 100644
--- a/if1632/ntdll.spec
+++ b/if1632/ntdll.spec
@@ -951,3 +951,23 @@
 948 stub wcstol
 949 cdecl wcstombs(ptr ptr long) CRTDLL_wcstombs
 950 stub wcstoul
+
+# NT 4 additions
+951 stub NtAddAtom
+952 stub NtDeleteAtom
+953 stub NtFindAtom
+954 stub NtQueryFullAttributesFile
+955 stub NtQueueApcThread
+956 stub NtReadFileScatter
+957 stub NtSignalAndWaitForSingleObject
+958 stub NtWriteFileGather
+959 stub NtYieldExecution
+960 stub RtlAddAtomToAtomTable
+961 stub RtlAllocateHandle
+962 stub RtlCreateAtomTable
+963 stub RtlDeleteAtomFromAtomTable
+964 stub RtlFreeHandle
+965 stub RtlInitializeHandleTable
+966 stub RtlIsValidHandle
+967 stub RtlLookupAtomInAtomTable
+968 stub RtlQueryAtomInAtomTable
diff --git a/if1632/ole32.spec b/if1632/ole32.spec
index 300d3ee..18cec80 100644
--- a/if1632/ole32.spec
+++ b/if1632/ole32.spec
@@ -38,7 +38,7 @@
  35 stub CoQueryReleaseObject
  36 stub CoRegisterClassObject
  37 stub CoRegisterMallocSpy
- 38 stub CoRegisterMessageFilter
+ 38 stdcall CoRegisterMessageFilter(ptr ptr) CoRegisterMessageFilter
  39 stub CoReleaseMarshalData
  40 stub CoRevokeClassObject
  41 stub CoRevokeMallocSpy
diff --git a/if1632/olecli.spec b/if1632/olecli.spec
index 291db7f..65c77a4 100644
--- a/if1632/olecli.spec
+++ b/if1632/olecli.spec
@@ -40,9 +40,9 @@
 38 stub OLECREATEFROMFILE
 39 stub OLECREATELINKFROMFILE
 40 stub OLERELEASE
-41  pascal OleRegisterClientDoc(ptr ptr long ptr) OleRegisterClientDoc
-42  pascal OleRevokeClientDoc(long) OleRevokeClientDoc
-43  pascal OleRenameClientDoc(long ptr) OleRenameClientDoc
+41  pascal OleRegisterClientDoc(ptr ptr long ptr) OleRegisterClientDoc16
+42  pascal OleRevokeClientDoc(long) OleRevokeClientDoc16
+43  pascal OleRenameClientDoc(long ptr) OleRenameClientDoc16
 44 stub OLEREVERTCLIENTDOC
 45 stub OLESAVEDCLIENTDOC
 46 stub OLERENAME
diff --git a/if1632/olecli32.spec b/if1632/olecli32.spec
new file mode 100644
index 0000000..2034bba
--- /dev/null
+++ b/if1632/olecli32.spec
@@ -0,0 +1,59 @@
+name olecli32
+type win32
+
+   1 stub WEP
+   2 stub OleDelete
+   3 stub OleSaveToStream
+   4 stub OleLoadFromStream
+   6 stub OleClone
+   7 stub OleCopyFromLink
+   8 stub OleEqual
+   9 stdcall OleQueryLinkFromClip(str long long) OleQueryLinkFromClip32
+  10 stdcall OleQueryCreateFromClip(str long long) OleQueryCreateFromClip32
+  11 stdcall OleCreateLinkFromClip(str long ptr str long long) OleCreateLinkFromClip32
+  12 stdcall OleCreateFromClip(str ptr long str ptr long long) OleCreateFromClip32
+  13 stub OleCopyToClipboard
+  14 stdcall OleQueryType(ptr ptr) OleQueryType32
+  15 stdcall OleSetHostNames(ptr str str) OleSetHostNames32
+  16 stub OleSetTargetDevice
+  17 stub OleSetBounds
+  18 stub OleQueryBounds
+  19 stub OleDraw
+  20 stub OleQueryOpen
+  21 stub OleActivate
+  22 stub OleUpdate
+  23 stub OleReconnect
+  24 stub OleGetLinkUpdateOptions
+  25 stub OleSetLinkUpdateOptions
+  26 stub OleEnumFormats
+  27 stub OleClose
+  28 stub OleGetData
+  29 stub OleSetData
+  30 stub OleQueryProtocol
+  31 stub OleQueryOutOfDate
+  32 stub OleObjectConvert
+  33 stub OleCreateFromTemplate
+  34 stub OleCreate
+  35 stub OleQueryReleaseStatus
+  36 stub OleQueryReleaseError
+  37 stub OleQueryReleaseMethod
+  38 stub OleCreateFromFile
+  39 stub OleCreateLinkFromFile
+  40 stub OleRelease
+  41 stdcall OleRegisterClientDoc(str str long ptr) OleRegisterClientDoc32
+  42 stdcall OleRevokeClientDoc(long) OleRevokeClientDoc32
+  43 stdcall OleRenameClientDoc(long str) OleRenameClientDoc32
+  44 stub OleRevertClientDoc
+  45 stub OleSavedClientDoc
+  46 stub OleRename
+  47 stub OleEnumObjects
+  48 stub OleQueryName
+  49 stub OleSetColorScheme
+  50 stub OleRequestData
+  54 stub OleLockServer
+  55 stub OleUnlockServer
+  56 stub OleQuerySize
+  57 stub OleExecute
+  58 stub OleCreateInvisible
+  59 stub OleQueryClientVersion
+  60 stub OleIsDcMeta
diff --git a/if1632/olesvr.spec b/if1632/olesvr.spec
index 3eac977..074c538 100644
--- a/if1632/olesvr.spec
+++ b/if1632/olesvr.spec
@@ -2,12 +2,12 @@
 type	win16
 
 #1 WEP
-2  pascal OleRegisterServer(str ptr ptr word word) OleRegisterServer
+2  pascal OleRegisterServer(str ptr ptr word word) OleRegisterServer16
 3  pascal OleRevokeServer(long) OleRevokeServer
-4  pascal OleBlockServer(long) OleBlockServer
-5  pascal OleUnblockServer(long ptr) OleUnblockServer
-6  pascal OleRegisterServerDoc(long str ptr ptr) OleRegisterServerDoc
-7  pascal OleRevokeServerDoc(long) OleRevokeServerDoc
+4  pascal OleBlockServer(long) OleBlockServer16
+5  pascal OleUnblockServer(long ptr) OleUnblockServer16
+6  pascal OleRegisterServerDoc(long str ptr ptr) OleRegisterServerDoc16
+7  pascal OleRevokeServerDoc(long) OleRevokeServerDoc16
 8 stub OLERENAMESERVERDOC
 9 stub OLEREVERTSERVERDOC
 10 stub OLESAVEDSERVERDOC
diff --git a/if1632/olesvr32.spec b/if1632/olesvr32.spec
new file mode 100644
index 0000000..99726dd
--- /dev/null
+++ b/if1632/olesvr32.spec
@@ -0,0 +1,15 @@
+name	olesvr32
+type	win32
+
+ 1 stub WEP
+ 2 stdcall OleRegisterServer(str ptr ptr long long) OleRegisterServer32
+ 3 stub OleRevokeServer
+ 4 stdcall OleBlockServer(long) OleBlockServer32
+ 5 stdcall OleUnblockServer(long ptr) OleUnblockServer32
+ 6 stdcall OleRegisterServerDoc(ptr str ptr ptr) OleRegisterServerDoc32
+ 7 stdcall OleRevokeServerDoc(long) OleRevokeServerDoc32
+ 8 stdcall OleRenameServerDoc(long str) OleRenameServerDoc32
+ 9 stub OleRevertServerDoc
+10 stub OleSavedServerDoc
+11 stub OleRevokeObject
+12 stub OleQueryServerVersion
diff --git a/if1632/shell.spec b/if1632/shell.spec
index 00ec20e..2d9b130 100644
--- a/if1632/shell.spec
+++ b/if1632/shell.spec
@@ -17,7 +17,7 @@
  22 pascal16 ShellAbout(word ptr ptr word) ShellAbout16
  33 pascal16 AboutDlgProc(word word word long) AboutDlgProc16
  34 pascal16 ExtractIcon(word str s_word) ExtractIcon16
- 36 pascal16 ExtractAssociatedIcon(word ptr ptr) ExtractAssociatedIcon
+ 36 pascal16 ExtractAssociatedIcon(word ptr ptr) ExtractAssociatedIcon16
  37 pascal   DoEnvironmentSubst(ptr word) DoEnvironmentSubst
  38 pascal   FindEnvironmentString(ptr) FindEnvironmentString
  39 pascal16 InternalExtractIcon(word ptr s_word word) InternalExtractIcon
diff --git a/if1632/shell32.spec b/if1632/shell32.spec
index 04d1ab7..9867e60 100644
--- a/if1632/shell32.spec
+++ b/if1632/shell32.spec
@@ -7,51 +7,182 @@
 
    2 stub SHELL32_2
    3 stub CheckEscapesA
+   4 stub SHELL32_4
+   5 stub SHELL32_5
    6 stub CheckEscapesW
    7 stdcall CommandLineToArgvW(ptr ptr) CommandLineToArgvW
    8 stub Control_FillCache_RunDLL
   12 stdcall Control_RunDLL(long long long long) Control_RunDLL
   14 stdcall DllGetClassObject(long long ptr) SHELL32_DllGetClassObject
+  15 stub SHELL32_15
+  16 stdcall SHELL32_16(ptr) SHELL32_16
+  17 stub SHELL32_17
+  18 stdcall SHELL32_18(ptr) SHELL32_18
+  19 stub SHELL32_19
+  20 stub SHELL32_20
+  21 stub SHELL32_21
   22 stub DoEnvironmentSubstA
+  23 stub SHELL32_23
+  24 stub SHELL32_24
+  25 stdcall SHELL32_25(ptr ptr) SHELL32_25
+  26 stub SHELL32_26
+  27 stub SHELL32_27
+  28 stub SHELL32_28
+  29 stdcall SHELL32_29(str) SHELL32_29
+  30 stub SHELL32_30
+  31 stub SHELL32_31
+  32 stdcall SHELL32_32(str) SHELL32_32
   33 stub SHELL32_33
-  34 stub SHELL32_34
-  35 stub SHELL32_35
+  34 stdcall SHELL32_34(str) SHELL32_34
+  35 stdcall SHELL32_35(str) SHELL32_35
+  36 stdcall SHELL32_36(str str) SHELL32_36
+  37 stdcall SHELL32_37(ptr str str) SHELL32_37
   38 stub DoEnvironmentSubstW
+  39 stub SHELL32_39
+  40 stub SHELL32_40
   41 stdcall DragAcceptFiles(long long) DragAcceptFiles
   42 stub DragFinish
+  43 stub SHELL32_43
   44 stub DragQueryFile
+  45 stdcall SHELL32_45(str) SHELL32_45
   46 stub SHELL32_46
   47 stub SHELL32_47
   48 stub SHELL32_48
   49 stub SHELL32_49
   50 stub DragQueryFileA
+  51 stub SHELL32_51
+  52 stdcall SHELL32_52(str) SHELL32_52
   53 stub DragQueryFileAorW
   54 stub DragQueryFileW
+  55 stub SHELL32_55
   56 stub SHELL32_56
   57 stub SHELL32_57
   58 stub SHELL32_58
-  62 stub SHELL32_62
+  59 stub SHELL32_59
+  60 stub SHELL32_60
+  61 stub SHELL32_61
+  62 stdcall SHELL32_62(long long long long) SHELL32_62
   63 stub SHELL32_63
   64 stub SHELL32_64
   65 stub SHELL32_65
+  66 stub SHELL32_66
+  67 stub SHELL32_67
+  68 stub SHELL32_68
+  69 stub SHELL32_69
+  70 stub SHELL32_70
+  71 stdcall SHELL32_71(ptr ptr) SHELL32_71
+  72 stdcall SHELL32_72(ptr ptr long) SHELL32_72
+  73 stub SHELL32_73
+  74 stub SHELL32_74
+  75 stub SHELL32_75
   76 stub DragQueryPoint
+  77 stdcall SHELL32_77(long long long) SHELL32_77
+  78 stub SHELL32_78
+  79 stdcall SHELL32_79(str ptr) SHELL32_79
   80 stub DuplicateIcon
+  81 stub SHELL32_81
   82 stub ExtractAssociatedIconA
+  83 stub SHELL32_83
+  84 stub SHELL32_84
+  85 stub SHELL32_85
+  86 stub SHELL32_86
+  87 stub SHELL32_87
+  88 stub SHELL32_88
+  89 stub SHELL32_89
+  90 stub SHELL32_90
+  91 stub SHELL32_91
+  92 stub SHELL32_92
+  93 stub SHELL32_93
+  94 stub SHELL32_94
+  95 stub SHELL32_95
+  96 stub SHELL32_96
+  97 stub SHELL32_97
+  98 stub SHELL32_98
+  99 stub SHELL32_99
+ 100 stdcall SHELL32_100(long) SHELL32_100
  101 stub ExtractAssociatedIconExA
+ 102 stdcall SHELL32_102(ptr ptr long ptr ptr) SHELL32_102
+ 103 stub SHELL32_103
+ 104 stub SHELL32_104
+ 105 stub SHELL32_105
+ 106 stub SHELL32_106
+ 107 stub SHELL32_107
+ 108 stub SHELL32_108
+ 109 stub SHELL32_109
+ 110 stub SHELL32_110
+ 111 stub SHELL32_111
+ 112 stub SHELL32_112
+ 113 stub SHELL32_113
+ 114 stub SHELL32_114
+ 115 stub SHELL32_115
+ 116 stub SHELL32_116
+ 117 stub SHELL32_117
+ 118 stub SHELL32_118
+ 119 stdcall SHELL32_119(ptr) SHELL32_119
+ 120 stub SHELL32_120
+ 121 stub SHELL32_121
+ 122 stub SHELL32_122
+ 123 stub SHELL32_123
  124 stub ExtractAssociatedIconExW
  125 stub ExtractAssociatedIconW
- 133 stdcall ExtractIconA(long ptr long) ExtractIcon32A
+ 126 stub SHELL32_126
+ 127 stub SHELL32_127
+ 128 stdcall DllGetClassObject(long long ptr) SHELL32_DllGetClassObject
+ 129 stub SHELL32_129
+ 130 stub SHELL32_130
+ 131 stub SHELL32_131
+ 132 stub SHELL32_132
+ 133 stdcall ExtractIconA(long str long) ExtractIcon32A
+ 134 stub SHELL32_134
  135 stub ExtractIconEx
+ 136 stub SHELL32_136
+ 137 stub SHELL32_137
  138 stub ExtractIconExA
+ 139 stub SHELL32_139
+ 140 stub SHELL32_140
+ 141 stub SHELL32_141
+ 142 stub SHELL32_142
+ 143 stub SHELL32_143
+ 144 stub SHELL32_144
+ 145 stub SHELL32_145
+ 146 stub SHELL32_146
+ 147 stub SHELL32_147
  148 stub ExtractIconResInfoA
+ 149 stub SHELL32_149
  150 stub ExtractIconResInfoW
+ 151 stub SHELL32_151
+ 152 stdcall SHELL32_152(ptr) SHELL32_152
+ 153 stub SHELL32_153
+ 154 stub SHELL32_154
+ 155 stdcall SHELL32_155(ptr) SHELL32_155
  156 stub SHELL32_156
  157 stub SHELL32_157
  158 stub SHELL32_158
  159 stub SHELL32_159
  160 stub SHELL32_160
- 180 stub ExtractIconW
+ 161 stub SHELL32_161
+ 162 stub SHELL32_162
+ 163 stub SHELL32_163
+ 164 stub SHELL32_164
+ 165 stdcall SHELL32_165(long long) SHELL32_165
+ 166 stub SHELL32_166
+ 167 stub SHELL32_167
+ 168 stub SHELL32_168
+ 169 stub SHELL32_169
+ 170 stub SHELL32_170
+ 171 stub SHELL32_171
+ 172 stub SHELL32_172
+ 173 stub SHELL32_173
+ 174 stub SHELL32_174
+ 175 stdcall SHELL32_175(long long long long) SHELL32_175
+ 176 stub SHELL32_176
+ 177 stub SHELL32_177
+ 178 stub SHELL32_178
+ 179 stub SHELL32_179
+ 180 stdcall ExtractIconW(long wstr long) ExtractIcon32W
+ 181 stdcall SHELL32_181(long long) SHELL32_181
  182 stub ExtractVersionResource16W
+ 183 cdecl SHELL32_183(long long long long long long) SHELL32_183
  184 stub SHELL32_184
  185 stub SHELL32_185
  186 stdcall FindExecutableA(ptr ptr ptr) FindExecutable32A
@@ -63,11 +194,19 @@
  192 stub PrintersGetCommand_RunDLL
  193 stub RealShellExecuteA
  194 stub RealShellExecuteExA
+ 195 stdcall SHELL32_195(ptr) SHELL32_195
+ 196 stdcall SHELL32_196(long) SHELL32_196
+ 197 stub SHELL32_197
+ 198 stub SHELL32_198
+ 199 stub SHELL32_199
+ 200 stub SHELL32_200
+ 201 stub SHELL32_201
+ 202 stub SHELL32_202
  203 stub RealShellExecuteExW
  204 stub RealShellExecuteW
  205 stub RegenerateUserEnvironment
  206 stub SHAddToRecentDocs
- 207 stub SHAppBarMessage
+ 207 stdcall SHAppBarMessage(long ptr) SHAppBarMessage32
  208 stub SHBrowseForFolder
  209 stub SHBrowseForFolderA
  210 stub SHChangeNotify
@@ -76,7 +215,7 @@
  213 stub SHFormatDrive
  214 stub SHFreeNameMappings
  215 stub SHGetDataFromIDListA
- 216 stub SHGetDesktopFolder
+ 216 stdcall SHGetDesktopFolder(ptr) SHGetDesktopFolder
  217 stdcall SHGetFileInfo(ptr long ptr long long) SHGetFileInfo32A
  218 stdcall SHGetFileInfoA(ptr long ptr long long) SHGetFileInfo32A
  219 stub SHGetInstanceExplorer
@@ -113,6 +252,10 @@
  250 stub Shell_NotifyIconA
  251 stub Shl1632_ThunkData32
  252 stub Shl3216_ThunkData32
+ 505 stub SHELL32_505
+ 507 stub SHELL32_507
+ 510 stub SHELL32_510
+ 511 stub SHELL32_511
 1025 stub ExtractIconExW # proper ordinal unknown
 1030 stub FindExeDlgProc # proper ordinal unknown
 1043 stub RegisterShellHook # proper ordinal unknown
diff --git a/if1632/user.spec b/if1632/user.spec
index 521deb9..fef3bfc 100644
--- a/if1632/user.spec
+++ b/if1632/user.spec
@@ -52,7 +52,7 @@
 48  pascal16 IsChild(word word) IsChild16
 49  pascal16 IsWindowVisible(word) IsWindowVisible16
 50  pascal16 FindWindow(segstr str) FindWindow16
-#51 BEAR51
+51  stub BEAR51 # IsTwoByteCharPrefix
 52  pascal16 AnyPopup() AnyPopup16
 53  pascal16 DestroyWindow(word) DestroyWindow16
 54  pascal16 EnumWindows(segptr long) THUNK_EnumWindows16
@@ -87,6 +87,7 @@
 83  pascal16 FrameRect(word ptr word) FrameRect16
 84  pascal16 DrawIcon(word s_word s_word word) DrawIcon16
 85  pascal16 DrawText(word str s_word ptr word) DrawText16
+86  stub BEAR86 # IconSize
 87  pascal16 DialogBox(word segstr word segptr) DialogBox16
 88  pascal16 EndDialog(word s_word) EndDialog16
 89  pascal16 CreateDialog(word segstr word segptr) CreateDialog16
@@ -217,7 +218,7 @@
 213 pascal16 BuildCommDCB(ptr ptr) BuildCommDCB16
 214 pascal   EscapeCommFunction(word word) EscapeCommFunction16
 215 pascal16 FlushComm(word word) FlushComm
-#216 USERSEEUSERDO
+216 stub USERSEEUSERDO
 217 pascal16 LookupMenuHandle(word s_word) LookupMenuHandle
 218 pascal16 DialogBoxIndirect(word word word segptr) DialogBoxIndirect16
 219 pascal16 CreateDialogIndirect(word ptr word segptr) CreateDialogIndirect16
@@ -431,6 +432,7 @@
 492 pascal16 USER_492() stub_USER_492
 496 pascal16 USER_496() stub_USER_496
 499 pascal16 WNetErrorText(word ptr word) WNetErrorText
+500 stub FARCALLNETDRIVER 			# Undocumented Windows
 501 pascal16 WNetOpenJob(ptr ptr word ptr)  WNetOpenJob
 502 pascal16 WNetCloseJob(word ptr ptr) WNetCloseJob
 503 pascal16 WNetAbortJob(ptr word) WNetAbortJob
@@ -534,3 +536,4 @@
 920 pascal16 USER_920() stub_USER_920
 922 pascal16 USER_922() stub_USER_922
 923 pascal16 USER_923() stub_USER_923
+924 stub UsrMpr_ThunkData16
diff --git a/if1632/user32.spec b/if1632/user32.spec
index 91782b6..f0f98be 100644
--- a/if1632/user32.spec
+++ b/if1632/user32.spec
@@ -12,7 +12,7 @@
   9 stdcall BeginDeferWindowPos(long) BeginDeferWindowPos32
  10 stdcall BeginPaint(long ptr) BeginPaint32
  11 stdcall BringWindowToTop(long) BringWindowToTop32
- 12 stub BroadcastSystemMessage
+ 12 stdcall BroadcastSystemMessage(long ptr long long long) BroadcastSystemMessage
  13 stub CalcChildScroll
  14 stub CallMsgFilter
  15 stdcall CallMsgFilterA(ptr long) CallMsgFilter32A
@@ -285,7 +285,7 @@
 280 stub GetProcessWindowStation
 281 stdcall GetPropA(long ptr) GetProp32A
 282 stdcall GetPropW(long ptr) GetProp32W
-283 stub GetQueueStatus
+283 stdcall GetQueueStatus(long) GetQueueStatus32
 284 stdcall GetScrollInfo(long long ptr) GetScrollInfo32
 285 stdcall GetScrollPos(long long) GetScrollPos32
 286 stdcall GetScrollRange(long long ptr ptr) GetScrollRange32
@@ -381,7 +381,7 @@
 376 stdcall LoadStringW(long long ptr long) LoadString32W
 377 stub LockWindowStation
 378 stdcall LockWindowUpdate(long) LockWindowUpdate32
-379 stdcall LookupIconIdFromDirectory(ptr long) LookupIconIdFromDirectory
+379 stdcall LookupIconIdFromDirectory(ptr long) LookupIconIdFromDirectory32
 380 stdcall LookupIconIdFromDirectoryEx(ptr long long long long) LookupIconIdFromDirectoryEx32
 381 stub MBToWCSEx
 382 stdcall MapDialogRect(long ptr) MapDialogRect32
@@ -435,7 +435,7 @@
 430 stdcall RegisterClassW(ptr) RegisterClass32W
 431 stdcall RegisterClipboardFormatA(str) RegisterClipboardFormat32A
 432 stdcall RegisterClipboardFormatW(wstr) RegisterClipboardFormat32W
-433 stub RegisterHotKey
+433 stdcall RegisterHotKey(long long long long) RegisterHotKey
 434 stub RegisterLogonProcess
 435 stub RegisterSystemThread
 436 stub RegisterTasklist
@@ -506,7 +506,7 @@
 501 stdcall SetScrollInfo(long long ptr long) SetScrollInfo32
 502 stdcall SetScrollPos(long long long long) SetScrollPos32
 503 stdcall SetScrollRange(long long long long long) SetScrollRange32
-504 stub SetShellWindow
+504 stdcall SetShellWindow(long) SetShellWindow32
 505 stdcall SetSysColors(long ptr ptr) SetSysColors32
 506 stub SetSysColorsTemp
 507 stub SetSystemCursor
@@ -567,7 +567,7 @@
 562 stub UnpackDDElParam
 563 stdcall UnregisterClassA(str long) UnregisterClass32A
 564 stdcall UnregisterClassW(wstr long) UnregisterClass32W
-565 stub UnregisterHotKey
+565 stdcall UnregisterHotKey(long long) UnregisterHotKey
 566 stub UpdatePerUserSystemParameters
 567 stdcall UpdateWindow(long) UpdateWindow32
 568 stub UserClientDllInitialize
@@ -602,6 +602,10 @@
 596 stub RegisterServicesProcess
 597 stub SetWindowRgn
 598 stub ToUnicodeEx
-599 stub DrawCaptionTempA
+599 stdcall DrawCaptionTempA(long long ptr long long str long) DrawCaptionTemp32A
 600 stub RegisterNetworkCapabilities
 601 stub WNDPROC_CALLBACK
+602 stub DrawCaptionTempW
+603 stub IsHungAppWindow
+604 stub ChangeDisplaySettingsA
+605 stub ChangeDisplaySettingsW
diff --git a/if1632/w32skrnl.spec b/if1632/w32skrnl.spec
new file mode 100644
index 0000000..fd02cde
--- /dev/null
+++ b/if1632/w32skrnl.spec
@@ -0,0 +1,139 @@
+name	w32skrnl
+type	win32
+
+1 stub _kSetEnvironmentVariable@8
+2 stub _SzFromImte@4
+3 stdcall GetCurrentTask32() GetCurrentTask
+4 stub _DebugPrintf
+5 stub _NtCloseSection@8
+6 stub _AllocKernelHeap@8
+7 stub _SelToFlat
+8 stub _kGetExeVersion@4
+9 stub _ResizeKernelHeap@12
+10 stub _DbgBackTo32
+11 stub _kGethInstance@0
+12 stub SelOffsetToLinear
+13 stub DebugPrintf
+14 stdcall _kGetWin32sDirectory@0() GetWin32sDirectory
+15 stub _sprintf
+16 stub _KIsDBCSLeadByte@4
+17 stub W32S_BackTo32
+18 stub _KGetDbgFlags32
+19 stub SelToFlat
+20 stub _FreeKernelHeap@4
+21 stub WIN32SYSDLL
+#22
+23 stub _KSilentException@4
+24 stub _NtCreateSection@28
+#25 stub _W32sError32@12
+26 stub _NtOpenSection@12
+27 stub _NtDupSection@4
+28 stub _GetSelModName@20
+29 stub _FGetDscr@8
+30 stdcall _RtlNtStatusToDosError@4(long) RtlNtStatusToDosError #FIXME: not sure
+31 stub _NtFlushVirtualMemory@16
+32 stub _snprintf
+33 stub _NtUnmapViewOfSection@8
+
+#34-149
+
+153 stub _PvAllocVirtMem@16
+154 stub SetVirtMemProcess
+155 stub _FFreeVirtMem@12
+156 stub _FSetVirtProtect@16
+157 stub _QueryVirtMem@8
+158 stub _FLockVirtMem@8
+159 stub _FUnlockVirtMem@8
+
+#160-170
+
+171 stub _HHeapCreateHeap@12
+#172
+173 stub _FHeapDestroy@4
+174 stub _PvAllocHeapMem@12
+175 stub _PvResizeHeapMem@16
+176 stub _FFreeHeapMem@8
+
+#177-196
+
+197 stub _PpdbGetProcess@0
+198 stub _ErcGetError@0
+199 stub _SetError@4
+
+#200-223
+
+224 stub _CbSearchPath@24
+225 stub _CbSearchBinPath@16
+
+#226-230
+
+231 stub _FFindEnvVar@8
+
+#232-251
+
+252 stub _SzFileFromImte@4
+253 stub _ImteFromFileSz@4
+254 stub _ImteFromSz@4
+255 stub _FGetProcAddr@12
+256 stub _KLoadLibrary@8
+257 stub _KFreeLibrary@4
+
+#258-271
+
+272 stub _lmaUserBase
+
+#273-325
+
+326 stub _KrnOutputDebugString@4
+
+#327-359
+
+360 stub _RtlRaiseException
+361 stub _RtlUnwind
+362 stub _RtlUnwind4
+
+#363-401
+
+402 stub _DfhCreateFile@12
+403 stub _FCloseFile@4
+404 stub _CbWriteFile@12
+405 stub _LfoSetFilePos@12
+406 stub _CbReadFile@12
+
+#407-499
+
+500 stub _SelOffsetToLinear@4
+501 stub _ImteFromHModule@4
+502 stub _HModuleFromImte@4
+503 stub _ExitPEApp
+#504 stdcall _GetThunkBuff@0() _GetThunkBuff
+505 stub _Dos3Call@0
+506 stub _GetPEInstanceData@0
+507 stub _GetThreadTask@4
+508 stub _BaseAddrFromImte@4
+509 stub _GetTaskId@12
+510 stub _KGetProcessDebugPort@4
+511 stub _W32S_BackTo32
+512 stub _KReadProcessMemory32@20
+513 stub _KWriteProcessMemory32@20
+514 stub _KGetThreadContext32@8
+515 stub _KSetThreadContext32@8
+516 stub _KQueryPerformanceCounter@8
+#517
+518 stub _KGetExitCodeThread32@8
+519 stub _KGetExitCodeProcess32@8
+520 stub _KGetTaskPpdb32@4
+521 stub _KGetThreadPtdb32@4
+
+#522-599
+
+600 stub _GetCurProcFIOData@0
+601 stub _KUseObject32@4
+602 stub _KUnuseObject32@4
+603 stub _KErcGetError32@0
+604 stub _KCreateProcessHeap@4
+605 stub _KGetSystemInfo@8
+606 stub _KGlobalMemStat@4
+607 stub _GetHandleFromAddr@4
+608 stub _TlsNullSlot@4
+609 stub _FWorkingSetSize@8
diff --git a/if1632/win32s16.spec b/if1632/win32s16.spec
new file mode 100644
index 0000000..2457c88
--- /dev/null
+++ b/if1632/win32s16.spec
@@ -0,0 +1,58 @@
+name	win32s16
+type	win16
+
+1 stub WEP
+2 stub BOOTTASK
+3 stub CREATEPROCESS
+4 stub WAITFORDEBUGEVENT
+5 pascal CONTINUEDEBUGEVENT(long long long) ContinueDebugEvent
+6 pascal READPROCESSMEMORY(long ptr ptr long ptr) ReadProcessMemory
+7 stub WRITEPROCESSMEMORY
+8 stub GETTHREADCONTEXT
+9 stub SETTHREADCONTEXT
+10 pascal GETLASTERROR() GetLastError
+11 pascal CLOSEHANDLE(long) CloseHandle
+12 stub ALLOCCLBKTO32BDLL
+13 pascal GETEXITCODETHREAD(long ptr) GetExitCodeThread
+14 stub GETEXITCODEPROCESS
+15 stub OPENPROCESS
+16 stub OPENTHREAD
+17 stub GETTHREADSELECTORENTRY
+18 pascal VIRTUALQUERYEX(long ptr ptr long) VirtualQueryEx
+19 pascal VIRTUALPROTECTEX(long ptr long long ptr) VirtualProtectEx
+20 stub KGETTASKPPDB
+21 stub KGETTHREADPTDB
+22 stub FREECALLBACK
+23 stub RELEASECSALIAS
+24 stub EXCHANGEPFN32INSTUB
+25 stub SELCBCS
+26 stub DESTROYPEHEADER
+27 stub SELCBDS
+28 stub GETCSALIAS
+29 stub SELFLATCODE
+30 stub HUNITOANSIDBCS
+31 stub ALLOCUTPROC32
+32 stub FLATDATA
+33 stub CODEDATA
+34 stub MYGLOBALFREE
+35 stub FREE32BDLLCBENTRIES
+36 stub SETFS
+37 stub PELOADRESOURCEHANDLER
+38 stub CHECKDEBUG
+39 stub REMOVEH32FROMWIN32S
+40 stub RMEMCPY
+41 stub INITRESLOADER
+42 stub FREESELECTOROFFSET
+43 stub STACKLINEARTOSEGMENTED
+44 stub GETMODULEFILENAME32S
+45 stub FAPILOG16
+46 stub ALLOCCALLBACK
+47 stub LINEARTOHUGESELECTOROFFSET
+48 stub UTSELECTOROFFSETTOLINEAR
+49 stub UTLINEARTOSELECTOROFFSET
+50 stub SELFOREIGNTIB
+51 stub MYGLOBALREALLOC
+52 stub CREATEPEHEADER
+53 stub FINDGLOBALHANDLE
+
+#54-289 exist, but function names blanked out
diff --git a/if1632/winspool.spec b/if1632/winspool.spec
index cafda74..f5bd31a 100644
--- a/if1632/winspool.spec
+++ b/if1632/winspool.spec
@@ -74,7 +74,7 @@
 171 stub EnumPrintProcessorsW
 172 stub EnumPrinterDriversA
 173 stub EnumPrinterDriversW
-174 stub EnumPrintersA
+174 stdcall EnumPrintersA(long ptr long ptr long ptr ptr) EnumPrinters32A
 175 stub EnumPrintersW
 176 stub ExtDeviceMode
 177 stub FindClosePrinterChangeNotification
diff --git a/if1632/wprocs.spec b/if1632/wprocs.spec
index f73a118..61ce5f3 100644
--- a/if1632/wprocs.spec
+++ b/if1632/wprocs.spec
@@ -78,7 +78,7 @@
 158 register INT_Int3aHandler(word) BUILTIN_DefaultIntHandler
 159 register INT_Int3bHandler(word) BUILTIN_DefaultIntHandler
 160 register INT_Int3cHandler(word) BUILTIN_DefaultIntHandler
-161 register INT_Int3dHandler(word) BUILTIN_DefaultIntHandler
+161 register INT_Int3dHandler(word) INT_Int3dHandler
 162 register INT_Int3eHandler(word) BUILTIN_DefaultIntHandler
 163 register INT_Int3fHandler(word) BUILTIN_DefaultIntHandler
 164 register INT_Int40Handler(word) BUILTIN_DefaultIntHandler
diff --git a/include/aspi.h b/include/aspi.h
index 901aa9e..9ceafd9 100644
--- a/include/aspi.h
+++ b/include/aspi.h
@@ -56,92 +56,92 @@
 typedef struct SRB_HaInquiry16 SRB_HaInquiry16;
 
 struct SRB_ExecSCSICmd16 {
-  BYTE        SRB_Cmd;                // ASPI command code		(W)
-  BYTE        SRB_Status;             // ASPI command status byte	(R)
-  BYTE        SRB_HaId;               // ASPI host adapter number	(W)
-  BYTE        SRB_Flags;              // ASPI request flags		(W)
-  DWORD       SRB_Hdr_Rsvd;           // Reserved, MUST = 0		(-)
-  BYTE        SRB_Target;             // Target's SCSI ID		(W)
-  BYTE        SRB_Lun;                // Target's LUN number		(W)
-  DWORD       SRB_BufLen;             // Data Allocation LengthPG	(W/R)
-  BYTE        SRB_SenseLen;           // Sense Allocation Length	(W)
-  SEGPTR      SRB_BufPointer;         // Data Buffer Pointer		(W)
-  DWORD       SRB_Rsvd1;              // Reserved, MUST = 0		(-/W)
-  BYTE        SRB_CDBLen;             // CDB Length = 6			(W)
-  BYTE        SRB_HaStat;             // Host Adapter Status		(R)
-  BYTE        SRB_TargStat;           // Target Status			(R)
-  FARPROC16   SRB_PostProc;	      // Post routine			(W)
-  BYTE        SRB_Rsvd2[34];          // Reserved, MUST = 0
-  BYTE		CDBByte[0];	      // SCSI CBD - variable length	(W)
+  BYTE        SRB_Cmd;                /* ASPI command code	      (W)  */
+  BYTE        SRB_Status;             /* ASPI command status byte     (R)  */
+  BYTE        SRB_HaId;               /* ASPI host adapter number     (W)  */
+  BYTE        SRB_Flags;              /* ASPI request flags	      (W)  */
+  DWORD       SRB_Hdr_Rsvd;           /* Reserved, MUST = 0	      (-)  */
+  BYTE        SRB_Target;             /* Target's SCSI ID	      (W)  */
+  BYTE        SRB_Lun;                /* Target's LUN number	      (W)  */
+  DWORD       SRB_BufLen;             /* Data Allocation LengthPG     (W/R)*/
+  BYTE        SRB_SenseLen;           /* Sense Allocation Length      (W)  */
+  SEGPTR      SRB_BufPointer;         /* Data Buffer Pointer	      (W)  */
+  DWORD       SRB_Rsvd1;              /* Reserved, MUST = 0	      (-/W)*/
+  BYTE        SRB_CDBLen;             /* CDB Length = 6		      (W)  */
+  BYTE        SRB_HaStat;             /* Host Adapter Status	      (R)  */
+  BYTE        SRB_TargStat;           /* Target Status		      (R)  */
+  FARPROC16   SRB_PostProc;	      /* Post routine		      (W)  */
+  BYTE        SRB_Rsvd2[34];          /* Reserved, MUST = 0                */
+  BYTE		CDBByte[0];	      /* SCSI CBD - variable length   (W)  */
   /* variable example for 6 byte cbd
-   * BYTE        CDBByte[6];             // SCSI CDB			(W)
-   * BYTE        SenseArea6[SENSE_LEN];  // Request Sense buffer 	(R)
+   * BYTE        CDBByte[6];             * SCSI CDB                    (W) *
+   * BYTE        SenseArea6[SENSE_LEN];  * Request Sense buffer 	(R) *
    */
 } WINE_PACKED ;
 
 typedef struct SRB_ExecSCSICmd16 SRB_ExecSCSICmd16;
 
 struct SRB_ExecSCSICmd32 {
-  BYTE        SRB_Cmd;            // ASPI command code = SC_EXEC_SCSI_CMD
-  BYTE        SRB_Status;         // ASPI command status byte
-  BYTE        SRB_HaId;           // ASPI host adapter number
-  BYTE        SRB_Flags;          // ASPI request flags
-  DWORD       SRB_Hdr_Rsvd;       // Reserved
-  BYTE        SRB_Target;         // Target's SCSI ID
-  BYTE        SRB_Lun;            // Target's LUN number
-  WORD        SRB_Rsvd1;          // Reserved for Alignment
-  DWORD       SRB_BufLen;         // Data Allocation Length
-  BYTE        *SRB_BufPointer;    // Data Buffer Point
-  BYTE        SRB_SenseLen;       // Sense Allocation Length
-  BYTE        SRB_CDBLen;         // CDB Length
-  BYTE        SRB_HaStat;         // Host Adapter Status
-  BYTE        SRB_TargStat;       // Target Status
-  void        (*SRB_PostProc)();  // Post routine
-  void        *SRB_Rsvd2;         // Reserved
-  BYTE        SRB_Rsvd3[16];      // Reserved for expansion
-  BYTE        CDBByte[16];        // SCSI CDB
-  BYTE        SenseArea[0];       // Request sense buffer - var length
+  BYTE        SRB_Cmd;            /* ASPI command code = SC_EXEC_SCSI_CMD */
+  BYTE        SRB_Status;         /* ASPI command status byte */
+  BYTE        SRB_HaId;           /* ASPI host adapter number */
+  BYTE        SRB_Flags;          /* ASPI request flags */
+  DWORD       SRB_Hdr_Rsvd;       /* Reserved */
+  BYTE        SRB_Target;         /* Target's SCSI ID */
+  BYTE        SRB_Lun;            /* Target's LUN number */
+  WORD        SRB_Rsvd1;          /* Reserved for Alignment */
+  DWORD       SRB_BufLen;         /* Data Allocation Length */
+  BYTE        *SRB_BufPointer;    /* Data Buffer Point */
+  BYTE        SRB_SenseLen;       /* Sense Allocation Length */
+  BYTE        SRB_CDBLen;         /* CDB Length */
+  BYTE        SRB_HaStat;         /* Host Adapter Status */
+  BYTE        SRB_TargStat;       /* Target Status */
+  void        (*SRB_PostProc)();  /* Post routine */
+  void        *SRB_Rsvd2;         /* Reserved */
+  BYTE        SRB_Rsvd3[16];      /* Reserved for expansion */
+  BYTE        CDBByte[16];        /* SCSI CDB */
+  BYTE        SenseArea[0];       /* Request sense buffer - var length */
 };
 
 typedef struct SRB_ExecSCSICmd32 SRB_ExecSCSICmd32;
 
 struct SRB_Abort16 {
-  BYTE        SRB_Cmd;            // ASPI command code = SC_ABORT_SRB
-  BYTE        SRB_Status;         // ASPI command status byte
-  BYTE        SRB_HaId;           // ASPI host adapter number
-  BYTE        SRB_Flags;          // ASPI request flags
-  DWORD       SRB_Hdr_Rsvd;       // Reserved, MUST = 0
-  LPSRB16     SRB_ToAbort;        // Pointer to SRB to abort
+  BYTE        SRB_Cmd;            /* ASPI command code = SC_ABORT_SRB */
+  BYTE        SRB_Status;         /* ASPI command status byte */
+  BYTE        SRB_HaId;           /* ASPI host adapter number */
+  BYTE        SRB_Flags;          /* ASPI request flags */
+  DWORD       SRB_Hdr_Rsvd;       /* Reserved, MUST = 0 */
+  LPSRB16     SRB_ToAbort;        /* Pointer to SRB to abort */
 } WINE_PACKED;
 
 typedef struct SRB_Abort16 SRB_Abort16;
 
 struct SRB_BusDeviceReset16 {
-  BYTE        SRB_Cmd;            // ASPI command code = SC_RESET_DEV
-  BYTE        SRB_Status;         // ASPI command status byte
-  BYTE        SRB_HaId;           // ASPI host adapter number
-  BYTE        SRB_Flags;          // ASPI request flags
-  DWORD       SRB_Hdr_Rsvd;       // Reserved, MUST = 0
-  BYTE        SRB_Target;         // Target's SCSI ID
-  BYTE        SRB_Lun;            // Target's LUN number
-  BYTE        SRB_ResetRsvd1[14]; // Reserved, MUST = 0
-  BYTE        SRB_HaStat;         // Host Adapter Status
-  BYTE        SRB_TargStat;       // Target Status
-  SEGPTR      SRB_PostProc;           // Post routine
-  BYTE        SRB_ResetRsvd2[34]; // Reserved, MUST = 0
+  BYTE        SRB_Cmd;            /* ASPI command code = SC_RESET_DEV */
+  BYTE        SRB_Status;         /* ASPI command status byte */
+  BYTE        SRB_HaId;           /* ASPI host adapter number */
+  BYTE        SRB_Flags;          /* ASPI request flags */
+  DWORD       SRB_Hdr_Rsvd;       /* Reserved, MUST = 0 */
+  BYTE        SRB_Target;         /* Target's SCSI ID */
+  BYTE        SRB_Lun;            /* Target's LUN number */
+  BYTE        SRB_ResetRsvd1[14]; /* Reserved, MUST = 0 */
+  BYTE        SRB_HaStat;         /* Host Adapter Status */
+  BYTE        SRB_TargStat;       /* Target Status */
+  SEGPTR      SRB_PostProc;       /* Post routine */
+  BYTE        SRB_ResetRsvd2[34]; /* Reserved, MUST = 0 */
 } WINE_PACKED;
 
 typedef struct SRB_BusDeviceReset16 SRB_BusDeviceReset16;
 
 struct SRB_GDEVBlock16 {
-  BYTE        SRB_Cmd;            // ASPI command code = SC_GET_DEV_TYPE
-  BYTE        SRB_Status;         // ASPI command status byte
-  BYTE        SRB_HaId;           // ASPI host adapter number
-  BYTE        SRB_Flags;          // ASPI request flags
-  DWORD       SRB_Hdr_Rsvd;       // Reserved, MUST = 0
-  BYTE        SRB_Target;         // Target's SCSI ID
-  BYTE        SRB_Lun;            // Target's LUN number
-  BYTE        SRB_DeviceType;     // Target's peripheral device type
+  BYTE        SRB_Cmd;            /* ASPI command code = SC_GET_DEV_TYPE */
+  BYTE        SRB_Status;         /* ASPI command status byte */
+  BYTE        SRB_HaId;           /* ASPI host adapter number */
+  BYTE        SRB_Flags;          /* ASPI request flags */
+  DWORD       SRB_Hdr_Rsvd;       /* Reserved, MUST = 0 */
+  BYTE        SRB_Target;         /* Target's SCSI ID */
+  BYTE        SRB_Lun;            /* Target's LUN number */
+  BYTE        SRB_DeviceType;     /* Target's peripheral device type */
 } WINE_PACKED;
 
 typedef struct SRB_GDEVBlock16 SRB_GDEVBlock16;
diff --git a/include/combo.h b/include/combo.h
index a4a861e..aa808dc 100644
--- a/include/combo.h
+++ b/include/combo.h
@@ -19,6 +19,7 @@
 #define CBF_EDIT                0x0040
 #define CBF_NORESIZE		0x0080
 #define CBF_NOTIFY		0x0100
+#define CBF_NOREDRAW            0x0200
 #define CBF_EUI                 0x8000
 
 /* Combo state struct */
diff --git a/include/commdlg.h b/include/commdlg.h
index 2cac612..4f6e78e 100644
--- a/include/commdlg.h
+++ b/include/commdlg.h
@@ -11,20 +11,6 @@
 
 #include "wintypes.h"		/* needed for CHOOSEFONT structure */
 
-#define RT_CURSOR           MAKEINTRESOURCE(1)
-#define RT_BITMAP           MAKEINTRESOURCE(2)
-#define RT_ICON             MAKEINTRESOURCE(3)
-#define RT_MENU             MAKEINTRESOURCE(4)
-#define RT_DIALOG           MAKEINTRESOURCE(5)
-#define RT_STRING           MAKEINTRESOURCE(6)
-#define RT_FONTDIR          MAKEINTRESOURCE(7)
-#define RT_FONT             MAKEINTRESOURCE(8)
-#define RT_ACCELERATOR      MAKEINTRESOURCE(9)
-#define RT_RCDATA           MAKEINTRESOURCE(10)
-
-#define RT_GROUP_CURSOR     MAKEINTRESOURCE(12)
-#define RT_GROUP_ICON       MAKEINTRESOURCE(14)
-
 #define OFN_READONLY                 0x00000001
 #define OFN_OVERWRITEPROMPT          0x00000002
 #define OFN_HIDEREADONLY             0x00000004
diff --git a/include/compobj.h b/include/compobj.h
index 09fa2fc..9aca771 100644
--- a/include/compobj.h
+++ b/include/compobj.h
@@ -1,6 +1,8 @@
 #if !defined(COMPOBJ_H)
 #define COMPOBJ_H
 
+#include "ole.h"
+
 struct tagGUID
 {
     DWORD Data1;
@@ -10,9 +12,24 @@
 };
 
 typedef struct tagGUID	GUID;
-typedef struct tagGUID	CLSID;
+typedef struct tagGUID	CLSID,*LPCLSID,*REFCLSID;
+typedef struct tagGUID	IID,*REFIID,*LPIID;
 
 OLESTATUS WINAPI StringFromCLSID(const CLSID *id, LPSTR);
 OLESTATUS WINAPI CLSIDFromString(const LPCSTR, CLSID *);
 
+
+#ifdef INITGUID
+#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
+        const GUID name =\
+	{ l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } }
+#else
+#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
+    extern const GUID name
+#endif
+
+#define DEFINE_OLEGUID(name, l, w1, w2) \
+	DEFINE_GUID(name, l, w1, w2, 0xC0,0,0,0,0,0,0,0x46)
+
+#define DEFINE_SHLGUID(name, l, w1, w2) DEFINE_OLEGUID(name,l,w1,w2)
 #endif
diff --git a/include/debugger.h b/include/debugger.h
index b872b3c..94d71aa 100644
--- a/include/debugger.h
+++ b/include/debugger.h
@@ -266,8 +266,8 @@
 extern int DEBUG_ReadExecutableDbgInfo(void);
 
   /* debugger/msc.c */
-extern int DEBUG_RegisterDebugInfo(struct pe_data *pe, int, const char *,
-				   unsigned long, unsigned long);
+extern int DEBUG_RegisterDebugInfo( HMODULE32, const char *,
+                                    unsigned long, unsigned long);
 extern int DEBUG_ProcessDeferredDebug(void);
 extern int DEBUG_RegisterELFDebugInfo(int load_addr, u_long size, char * name);
 extern void DEBUG_InfoShare(void);
diff --git a/include/interfaces.h b/include/interfaces.h
new file mode 100644
index 0000000..5e912da
--- /dev/null
+++ b/include/interfaces.h
@@ -0,0 +1,45 @@
+#ifndef _WINE_INTERFACES_H
+#define _WINE_INTERFACES_H
+
+#include "ole.h"
+#include "ole2.h"
+#include "compobj.h"
+
+DEFINE_OLEGUID(IID_IUnknown,0,0,0);
+DEFINE_OLEGUID(IID_IClassFactory,1,0,0);
+DEFINE_OLEGUID(IID_IMalloc,2,0,0);
+DEFINE_OLEGUID(IID_IMarshal,3,0,0);
+DEFINE_OLEGUID(IID_IStorage,0xb,0,0);
+DEFINE_OLEGUID(IID_IStream,0xc,0,0);
+DEFINE_OLEGUID(IID_IBindCtx,0xe,0,0);
+DEFINE_OLEGUID(IID_IMoniker,0xf,0,0);
+DEFINE_OLEGUID(IID_IRunningObject,0x10,0,0);
+DEFINE_OLEGUID(IID_IRootStorage,0x12,0,0);
+DEFINE_OLEGUID(IID_IMessageFilter,0x16,0,0);
+DEFINE_OLEGUID(IID_IStdMarshalInfo,0x18,0,0);
+
+typedef struct tagUNKNOWN *LPUNKNOWN,IUnknown;
+typedef struct {
+	HRESULT	(CALLBACK *fnQueryInterface)(LPUNKNOWN this,REFIID refiid,LPVOID *obj);
+	HRESULT	(CALLBACK *fnAddRef)(LPUNKNOWN this);
+	HRESULT	(CALLBACK *fnRelease)(LPUNKNOWN this);
+} *LPUNKNOWN_VTABLE;
+
+struct tagUNKNOWN {
+	LPUNKNOWN_VTABLE	lpvtbl;
+	/* internal stuff. Not needed until we actually implement IUnknown */
+};
+
+typedef struct tagCLASSFACTORY *LPCLASSFACTORY,IClassFactory;
+typedef struct {
+	HRESULT	(CALLBACK *fnQueryInterface)(LPCLASSFACTORY this,REFIID refiid,LPVOID *obj);
+	HRESULT	(CALLBACK *fnAddRef)(LPCLASSFACTORY this);
+	HRESULT	(CALLBACK *fnRelease)(LPCLASSFACTORY this);
+	HRESULT (CALLBACK *fnCreateInstance)(LPCLASSFACTORY this,LPUNKNOWN pUnkOuter,REFIID riid,LPVOID * ppvObject);
+} *LPCLASSFACTORY_VTABLE;
+
+struct tagCLASSFACTORY {
+	LPCLASSFACTORY_VTABLE lpvtbl;
+	/*internal stuff. Not needed until we actually implement IClassFactory*/
+};
+#endif /*_WINE_INTERFACES_H*/
diff --git a/include/module.h b/include/module.h
index 4abfc61..2737501 100644
--- a/include/module.h
+++ b/include/module.h
@@ -46,7 +46,7 @@
     WORD    min_swap_area;    /* 3c Min. swap area size */
     WORD    expected_version; /* 3e Expected Windows version */
     /* From here, these are extra fields not present in normal Windows */
-    PE_MODULE *pe_module;     /* 40 PE module handle for Win32 modules */
+    HMODULE32  module32;      /* 40 PE module handle for Win32 modules */
     HMODULE16  self;          /* 44 Handle for this module */
     WORD    self_loading_sel; /* 46 Selector used for self-loading apps. */
 } NE_MODULE;
@@ -107,8 +107,8 @@
     (((OFSTRUCT *)((char*)(pModule) + (pModule)->fileinfo))->szPathName)
 
 #define NE_WIN32_MODULE(pModule) \
-    ((struct pe_data *)(((pModule)->flags & NE_FFLAGS_WIN32) ? \
-                    ((NE_WIN32_EXTRAINFO *)((pModule) + 1))->pe_module : 0))
+    ((((pModule)->flags & NE_FFLAGS_WIN32) ? \
+                    ((NE_WIN32_EXTRAINFO *)((pModule) + 1))->module32 : 0))
 
 /* module.c */
 extern NE_MODULE *MODULE_GetPtr( HMODULE32 hModule );
@@ -133,11 +133,10 @@
 
 /* builtin.c */
 extern BOOL32 BUILTIN_Init(void);
-extern HMODULE16 BUILTIN_LoadModule( LPCSTR name, BOOL32 force );
+extern HMODULE32 BUILTIN_LoadModule( LPCSTR name, BOOL32 force );
 extern LPCSTR BUILTIN_GetEntryPoint16( WORD cs, WORD ip, WORD *pOrd );
 extern FARPROC32 BUILTIN_GetEntryPoint32( char *buffer, void *relay,
                                           DWORD *typemask );
-extern FARPROC32 BUILTIN_GetProcAddress32(NE_MODULE *pModule, LPCSTR function);
 extern BOOL32 BUILTIN_ParseDLLOptions( const char *str );
 extern void BUILTIN_PrintDLLs(void);
 
diff --git a/include/ntdll.h b/include/ntdll.h
index 820425e..2f1bf8b 100644
--- a/include/ntdll.h
+++ b/include/ntdll.h
@@ -17,14 +17,14 @@
 
 typedef struct {
 	BYTE	Value[6];
-} SID_IDENTIFIER_AUTHORITY,*LPSID_IDENTIFIER_AUTHORITY;
+} SID_IDENTIFIER_AUTHORITY,*PSID_IDENTIFIER_AUTHORITY,*LPSID_IDENTIFIER_AUTHORITY;
 
 typedef struct _SID {
 	BYTE	Revision;
 	BYTE	SubAuthorityCount;
 	SID_IDENTIFIER_AUTHORITY	IdentifierAuthority;
 	DWORD	SubAuthority[1];	/* more than one */
-} SID,*LPSID;
+} SID,*PSID,*LPSID;
 
 #define	SID_REVISION			(1)	/* Current revision */
 #define	SID_MAX_SUB_AUTHORITIES		(15)	/* current max subauths */
@@ -121,7 +121,18 @@
 	LPSID	Group;
 	LPACL	Sacl;
 	LPACL	Dacl;
-} SECURITY_DESCRIPTOR,*LPSECURITY_DESCRIPTOR;
+} SECURITY_DESCRIPTOR,*PSECURITY_DESCRIPTOR,*LPSECURITY_DESCRIPTOR;
+
+typedef enum tagSID_NAME_USE {
+	SidTypeUser = 1,
+	SidTypeGroup,
+	SidTypeDomain,
+	SidTypeAlias,
+	SidTypeWellKnownGroup,
+	SidTypeDeletedAccount,
+	SidTypeInvalid,
+	SidTypeUnknown
+} SID_NAME_USE,*PSID_NAME_USE,*LPSID_NAME_USE;
 
 /* NT lowlevel Strings (handled by Rtl* functions in NTDLL)
  * If they are zero terminated, Length does not include the terminating 0.
diff --git a/include/ole.h b/include/ole.h
index 7e08b9d..0d90960 100644
--- a/include/ole.h
+++ b/include/ole.h
@@ -7,8 +7,9 @@
 
 #include "windows.h"
 
-typedef	LPVOID	LPUNKNOWN;
 typedef LPCSTR	OLE_LPCSTR;
+typedef LPSTR	LPOLESTR;
+typedef LPCSTR	LPCOLESTR;
 
 /* object types */
 #define OT_LINK		1
diff --git a/include/ole2.h b/include/ole2.h
index d3856d7..391843f 100644
--- a/include/ole2.h
+++ b/include/ole2.h
@@ -7,6 +7,8 @@
 
 typedef LONG HRESULT;
 
+typedef LPVOID LPMESSAGEFILTER;
+
 #define S_OK	0
 #define S_FALSE	1
 
diff --git a/include/pe_image.h b/include/pe_image.h
index 482c0f3..b432c83 100644
--- a/include/pe_image.h
+++ b/include/pe_image.h
@@ -6,22 +6,12 @@
 #include "winnt.h"
 #include "peexe.h"
 
-/* This struct is used for loaded PE .dlls */
-struct pe_data {
-	LPIMAGE_NT_HEADERS	pe_header;
-	LPIMAGE_SECTION_HEADER	pe_seg;
-	HMODULE32		mappeddll;
-};
-
-typedef struct pe_data PE_MODULE;
-
 /* modreference used for attached processes
  * all section are calculated here, relocations etc.
  */
 struct pe_modref {
 	struct pe_modref		*next;
-	PE_MODULE			*pe_module;
-	unsigned long int		load_addr;
+        HMODULE32                       module;
 	LPIMAGE_IMPORT_DESCRIPTOR	pe_import;
 	LPIMAGE_EXPORT_DIRECTORY	pe_export;
 	LPIMAGE_RESOURCE_DIRECTORY	pe_resource;
@@ -35,7 +25,7 @@
 typedef struct pe_modref PE_MODREF;
 
 extern int PE_unloadImage(HMODULE32 hModule);
-extern FARPROC32 PE_FindExportedFunction(struct pe_data *pe, LPCSTR funcName);
+extern FARPROC32 PE_FindExportedFunction(HMODULE32 hModule, LPCSTR funcName);
 extern void my_wcstombs(char * result, u_short * source, int len);
 extern BOOL32 PE_EnumResourceTypes32A(HMODULE32,ENUMRESTYPEPROC32A,LONG);
 extern BOOL32 PE_EnumResourceTypes32W(HMODULE32,ENUMRESTYPEPROC32W,LONG);
@@ -51,4 +41,6 @@
 struct _PDB32; /* forward definition */
 extern void PE_InitializeDLLs(struct _PDB32*,DWORD,LPVOID);
 
+extern LPIMAGE_RESOURCE_DIRECTORY GetResDirEntryW(LPIMAGE_RESOURCE_DIRECTORY,LPCWSTR,DWORD);
+
 #endif /* __WINE_PE_IMAGE_H */
diff --git a/include/peexe.h b/include/peexe.h
index 364e44d..78adf3b 100644
--- a/include/peexe.h
+++ b/include/peexe.h
@@ -145,6 +145,17 @@
 	IMAGE_OPTIONAL_HEADER	OptionalHeader;
 } IMAGE_NT_HEADERS,*LPIMAGE_NT_HEADERS;
 
+
+#define PE_HEADER(module) \
+    ((IMAGE_NT_HEADERS*)((LPBYTE)(module) + \
+                         (((IMAGE_DOS_HEADER*)(module))->e_lfanew)))
+
+#define PE_SECTIONS(module) \
+    ((IMAGE_SECTION_HEADER*)((LPBYTE)&PE_HEADER(module)->OptionalHeader + \
+                           PE_HEADER(module)->FileHeader.SizeOfOptionalHeader))
+
+#define RVA_PTR(module,field) ((LPBYTE)(module) + PE_HEADER(module)->field)
+
 /* Section header format */
 
 #define	IMAGE_SIZEOF_SHORT_NAME	8
diff --git a/include/shell.h b/include/shell.h
index 947ec4d..2ddf3a3 100644
--- a/include/shell.h
+++ b/include/shell.h
@@ -50,6 +50,17 @@
 
 DECL_WINELIB_TYPE_AW(SHFILEINFO);
 
+typedef struct _AppBarData {
+	DWORD	cbSize;
+	HWND32	hWnd;
+	UINT32	uCallbackMessage;
+	UINT32	uEdge;
+	RECT32	rc;
+	LPARAM	lParam;
+} APPBARDATA, *PAPPBARDATA;
+
+DECL_WINELIB_TYPE(APPBARDATA);
+
 #define SHGFI_ICON              0x000000100     /* get icon */
 #define SHGFI_DISPLAYNAME       0x000000200     /* get display name */
 #define SHGFI_TYPENAME          0x000000400     /* get type name */
diff --git a/include/shlobj.h b/include/shlobj.h
new file mode 100644
index 0000000..bb06efe
--- /dev/null
+++ b/include/shlobj.h
@@ -0,0 +1,65 @@
+#ifndef _WINE_SHLOBJ_H
+#define _WINE_SHLOBJ_H
+
+#include "ole.h"
+#include "ole2.h"
+#include "compobj.h"
+
+typedef LPVOID	LPBC; /* *IBindCtx really */
+typedef LPVOID	LPSTRRET,LPENUMIDLIST;
+
+/*
+ * shell32 classids
+ */
+DEFINE_SHLGUID(CLSID_ShellDesktop,      0x00021400L, 0, 0);
+DEFINE_SHLGUID(CLSID_ShellLink,         0x00021401L, 0, 0);
+
+/*
+ * shell32 Interface ids
+ */
+DEFINE_SHLGUID(IID_IContextMenu,        0x000214E4L, 0, 0);
+DEFINE_SHLGUID(IID_IShellFolder,        0x000214E6L, 0, 0);
+DEFINE_SHLGUID(IID_IShellExtInit,       0x000214E8L, 0, 0);
+DEFINE_SHLGUID(IID_IShellPropSheetExt,  0x000214E9L, 0, 0);
+DEFINE_SHLGUID(IID_IExtractIcon,        0x000214EBL, 0, 0);
+DEFINE_SHLGUID(IID_IShellLink,          0x000214EEL, 0, 0);
+DEFINE_SHLGUID(IID_IShellCopyHook,      0x000214EFL, 0, 0);
+DEFINE_SHLGUID(IID_IFileViewer,         0x000214F0L, 0, 0);
+DEFINE_SHLGUID(IID_IEnumIDList,         0x000214F2L, 0, 0);
+DEFINE_SHLGUID(IID_IFileViewerSite,     0x000214F3L, 0, 0);
+
+typedef struct {
+	WORD		cb;	/* nr of bytes in this item */
+	BYTE		abID[1];/* first byte in this item */
+} SHITEMID,*LPSHITEMID;
+
+typedef struct {
+	SHITEMID	mkid; /* first itemid in list */
+} ITEMIDLIST,*LPITEMIDLIST,*LPCITEMIDLIST;
+
+/* The IShellFolder interface ... the basic interface for a lot of stuff */
+
+typedef struct tagSHELLFOLDER *LPSHELLFOLDER,IShellFolder;
+typedef struct {
+	HRESULT	(CALLBACK *fnQueryInterface)(LPSHELLFOLDER this,REFIID refiid,LPVOID *obj);
+	HRESULT	(CALLBACK *fnAddRef)(LPSHELLFOLDER this);
+	HRESULT	(CALLBACK *fnRelease)(LPSHELLFOLDER this);
+	/* IShellFolder methods */
+
+	HRESULT (CALLBACK *fnParseDisplayName) (LPSHELLFOLDER this,HWND32 hwndOwner,LPBC pbcReserved,LPOLESTR lpszDisplayName,DWORD * pchEaten,LPITEMIDLIST * ppidl, DWORD *pdwAttributes) ;
+
+	HRESULT (CALLBACK *fnEnumObjects)( LPSHELLFOLDER this,HWND32 hwndOwner, DWORD grfFlags, LPENUMIDLIST* ppenumIDList);
+	HRESULT (CALLBACK *fnBindToObject)(LPSHELLFOLDER this, LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut);
+	HRESULT (CALLBACK *fnBindToStorage)(LPSHELLFOLDER this, LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvObj);
+    	HRESULT (CALLBACK *fnCompareIDs) (LPSHELLFOLDER this, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2);
+	HRESULT (CALLBACK *fnCreateViewObject) (LPSHELLFOLDER this, HWND32 hwndOwner, REFIID riid, LPVOID * ppvOut);
+	HRESULT (CALLBACK *fnGetAttributesOf)  (LPSHELLFOLDER this, UINT32 cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut);
+	HRESULT (CALLBACK *fnGetUIObjectOf)    (LPSHELLFOLDER this, HWND32 hwndOwner, UINT32 cidl, LPCITEMIDLIST * apidl, REFIID riid, UINT32 * prgfInOut, LPVOID * ppvOut);
+	HRESULT (CALLBACK *fnGetDisplayNameOf) (LPSHELLFOLDER this, LPCITEMIDLIST pidl, DWORD uFlags, LPSTRRET lpName);
+	HRESULT (CALLBACK *fnSetNameOf)        (LPSHELLFOLDER this, HWND32 hwndOwner, LPCITEMIDLIST pidl, LPCOLESTR lpszName, DWORD uFlags, LPITEMIDLIST * ppidlOut);
+} *LPSHELLFOLDER_VTABLE;
+
+struct tagSHELLFOLDER {
+	LPSHELLFOLDER_VTABLE	*lpvtbl;
+};
+#endif /*_WINE_SHLOBJ_H*/
diff --git a/include/string32.h b/include/string32.h
deleted file mode 100644
index 6c644a2..0000000
--- a/include/string32.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * Unicode string management
- *
- * Copyright 1995 Martin von Loewis
- *
- */
-
-#ifndef __WINE_STRING32_H
-#define __WINE_STRING32_H
-
-#include "wintypes.h"
-
-LPWSTR	STRING32_DupAnsiToUni(LPCSTR src);
-LPWSTR	STRING32_strdupW(LPCWSTR);
-
-#endif  /* __WINE_STRING32_H */
diff --git a/include/version.h b/include/version.h
index 0bf94c8..b0cfc85 100644
--- a/include/version.h
+++ b/include/version.h
@@ -1 +1 @@
-#define WINE_RELEASE_INFO "Wine release 971116"
+#define WINE_RELEASE_INFO "Wine release 971130"
diff --git a/include/win.h b/include/win.h
index 07dd3b2..5a57b43 100644
--- a/include/win.h
+++ b/include/win.h
@@ -97,7 +97,7 @@
 #define WIN_NEEDS_NCPAINT      0x0004 /* WM_NCPAINT must be sent to window */
 #define WIN_RESTORE_MAX        0x0008 /* Maximize when restoring */
 #define WIN_INTERNAL_PAINT     0x0010 /* Internal WM_PAINT message pending */
-#define WIN_NO_REDRAW          0x0020 /* WM_SETREDRAW called for this window */
+/* Used to have WIN_NO_REDRAW  0x0020 here */
 #define WIN_NEED_SIZE          0x0040 /* Internal WM_SIZE is needed */
 #define WIN_NCACTIVATED        0x0080 /* last WM_NCACTIVATE was positive */
 #define WIN_MANAGED            0x0100 /* Window managed by the X wm */
diff --git a/include/windows.h b/include/windows.h
index e93a7dd..997208a 100644
--- a/include/windows.h
+++ b/include/windows.h
@@ -1973,6 +1973,15 @@
 DECL_WINELIB_TYPE(ACCEL);
 DECL_WINELIB_TYPE(LPACCEL);
 
+/* modifiers for RegisterHotKey */
+#define	MOD_ALT		0x0001
+#define	MOD_CONTROL	0x0002
+#define	MOD_SHIFT	0x0004
+#define	MOD_WIN		0x0008
+
+/* ids for RegisterHotKey */
+#define	IDHOT_SNAPWINDOW	(-1)    /* SHIFT-PRINTSCRN  */
+#define	IDHOT_SNAPDESKTOP	(-2)    /* PRINTSCRN        */
 
 /* Flags for DrawIconEx.  */
 #define DI_MASK                 1
@@ -5461,7 +5470,6 @@
 FARPROC16   WINAPI SetResourceHandler(HINSTANCE16,SEGPTR,FARPROC16);
 WORD        WINAPI SetSelectorBase(WORD,DWORD);
 WORD        WINAPI SetSelectorLimit(WORD,DWORD);
-LONG        WINAPI SetSwapAreaSize(WORD);
 HQUEUE16    WINAPI SetTaskQueue(HTASK16,HQUEUE16);
 FARPROC16   WINAPI SetTaskSignalProc(HTASK16,FARPROC16);
 DWORD       WINAPI SetViewportExt(HDC16,INT16,INT16);
@@ -5478,7 +5486,6 @@
 INT16       WINAPI WriteComm(INT16,LPSTR,INT16);
 VOID        WINAPI WriteOutProfiles(VOID);
 VOID        WINAPI hmemcpy(LPVOID,LPCVOID,LONG);
-VOID        WINAPI Yield(void);
 
 
 /* Declarations for functions that exist only in Win32 */
@@ -6160,6 +6167,9 @@
 LRESULT     WINAPI DefWindowProc32A(HWND32,UINT32,WPARAM32,LPARAM);
 LRESULT     WINAPI DefWindowProc32W(HWND32,UINT32,WPARAM32,LPARAM);
 #define     DefWindowProc WINELIB_NAME_AW(DefWindowProc)
+BOOL16      WINAPI DefineHandleTable16(WORD);
+#define     DefineHandleTable32(w) ((w),TRUE)
+#define     DefineHandleTable WINELIB_NAME(DefineHandleTable)
 ATOM        WINAPI DeleteAtom16(ATOM);
 ATOM        WINAPI DeleteAtom32(ATOM);
 #define     DeleteAtom WINELIB_NAME(DeleteAtom)
@@ -6357,6 +6367,10 @@
 HICON32     WINAPI ExtractIcon32A(HINSTANCE32,LPCSTR,UINT32);
 HICON32     WINAPI ExtractIcon32W(HINSTANCE32,LPCWSTR,UINT32);
 #define     ExtractIcon WINELIB_NAME_AW(ExtractIcon)
+HICON16     WINAPI ExtractAssociatedIcon16(HINSTANCE16,LPSTR,LPWORD);
+HICON32     WINAPI ExtractAssociatedIcon32A(HINSTANCE32,LPSTR,LPWORD);
+HICON32     WINAPI ExtractAssociatedIcon32W(HINSTANCE32,LPWSTR,LPWORD);
+#define     ExtractAssociatedIcon WINELIB_NAME_AW(ExtractAssociatedIcon)
 BOOL16      WINAPI ExtTextOut16(HDC16,INT16,INT16,UINT16,const RECT16*,
                                 LPCSTR,UINT16,const INT16*);
 BOOL32      WINAPI ExtTextOut32A(HDC32,INT32,INT32,UINT32,const RECT32*,
@@ -7173,6 +7187,12 @@
 BOOL16      WINAPI LockWindowUpdate16(HWND16);
 BOOL32      WINAPI LockWindowUpdate32(HWND32);
 #define     LockWindowUpdate WINELIB_NAME(LockWindowUpdate)
+INT16       WINAPI LookupIconIdFromDirectory16(LPBYTE,BOOL16);
+INT32       WINAPI LookupIconIdFromDirectory32(LPBYTE,BOOL32);
+#define     LookupIconIdFromDirectory WINELIB_NAME(LookupIconIdFromDirectory)
+INT16       WINAPI LookupIconIdFromDirectoryEx16(LPBYTE,BOOL16,INT16,INT16,UINT16);
+INT32       WINAPI LookupIconIdFromDirectoryEx32(LPBYTE,BOOL32,INT32,INT32,UINT32);
+#define     LookupIconIdFromDirectoryEx WINELIB_NAME(LookupIconIdFromDirectoryEx)
 BOOL16      WINAPI LPtoDP16(HDC16,LPPOINT16,INT16);
 BOOL32      WINAPI LPtoDP32(HDC32,LPPOINT32,INT32);
 #define     LPtoDP WINELIB_NAME(LPtoDP)
@@ -7620,6 +7640,9 @@
 INT16       WINAPI SetStretchBltMode16(HDC16,INT16);
 INT32       WINAPI SetStretchBltMode32(HDC32,INT32);
 #define     SetStretchBltMode WINELIB_NAME(SetStretchBltMode)
+LONG        WINAPI SetSwapAreaSize16(WORD);
+#define     SetSwapAreaSize32(w) (w)
+#define     SetSwapAreaSize WINELIB_NAME(SetSwapAreaSize)
 VOID        WINAPI SetSysColors16(INT16,const INT16*,const COLORREF*);
 BOOL32      WINAPI SetSysColors32(INT32,const INT32*,const COLORREF*);
 #define     SetSysColors WINELIB_NAME(SetSysColors)
@@ -7861,6 +7884,9 @@
 BOOL32      WINAPI WriteProfileString32A(LPCSTR,LPCSTR,LPCSTR);
 BOOL32      WINAPI WriteProfileString32W(LPCWSTR,LPCWSTR,LPCWSTR);
 #define     WriteProfileString WINELIB_NAME_AW(WriteProfileString)
+VOID        WINAPI Yield16(void);
+#define     Yield32()
+#define     Yield WINELIB_NAME(Yield)
 SEGPTR      WINAPI lstrcat16(SEGPTR,LPCSTR);
 LPSTR       WINAPI lstrcat32A(LPSTR,LPCSTR);
 LPWSTR      WINAPI lstrcat32W(LPWSTR,LPCWSTR);
diff --git a/include/winerror.h b/include/winerror.h
index f8d7738..ce1a3fe 100644
--- a/include/winerror.h
+++ b/include/winerror.h
@@ -38,5 +38,6 @@
 #define ERROR_IO_DEVICE             1117
 #define ERROR_POSSIBLE_DEADLOCK     1131
 #define ERROR_BAD_DEVICE            1200
+#define ERROR_NO_NETWORK            1222
 
 #endif  /* __WINE_WINERROR_H */
diff --git a/include/wintypes.h b/include/wintypes.h
index c54a42f..5092157 100644
--- a/include/wintypes.h
+++ b/include/wintypes.h
@@ -145,7 +145,7 @@
 
 /* Handle types that exist both in Win16 and Win32. */
 
-#define DECLARE_HANDLE(a)  typedef HANDLE16 a##16; typedef HANDLE32 a##32;
+#define DECLARE_HANDLE(a)  typedef HANDLE16 a##16; typedef HANDLE32 a##32
 DECLARE_HANDLE(HACCEL);
 DECLARE_HANDLE(HBITMAP);
 DECLARE_HANDLE(HBRUSH);
diff --git a/library/winestub.c b/library/winestub.c
index ac18da2..789c7bf 100644
--- a/library/winestub.c
+++ b/library/winestub.c
@@ -4,9 +4,8 @@
 #include "windows.h"
 #include "xmalloc.h"
 
-/* Stubs needed for linking with Winelib */
+/* Stub needed for linking with Winelib */
 /* FIXME: this should not be necessary */
-FARPROC32 BUILTIN_GetProcAddress32( void *mod, LPCSTR func ) { return 0; }
 HMODULE32 BUILTIN_LoadModule( LPCSTR name, BOOL32 force ) { return 0; }
 
 
diff --git a/loader/module.c b/loader/module.c
index 202f189..f35bae4 100644
--- a/loader/module.c
+++ b/loader/module.c
@@ -53,18 +53,16 @@
 MODULE_HANDLEtoHMODULE16(HANDLE32 handle) {
     NE_MODULE	*pModule;
 
-    if (HIWORD(handle)) {
-	/* this is a HMODULE32 aka pe->mappeddll */
+    if (HIWORD(handle))
+    {
+	/* this is a HMODULE32 */
 
         /* walk the list looking for the correct startaddress */
     	pModule = (NE_MODULE *)GlobalLock16( hFirstModule );
-	while (pModule) { 
-		if (	((pModule->flags&(NE_FFLAGS_BUILTIN|NE_FFLAGS_WIN32))==NE_FFLAGS_WIN32) &&
-			pModule->pe_module &&
-			((HMODULE32)pModule->pe_module->mappeddll == handle)
-		)
-			return pModule->self;
-		pModule=(NE_MODULE*)GlobalLock16(pModule->next);
+	while (pModule)
+        {
+            if (pModule->module32 == handle) return pModule->self;
+            pModule = (NE_MODULE*)GlobalLock16(pModule->next);
 	}
 	return 0;
     }
@@ -89,10 +87,7 @@
 	if (!pModule)
 	    return 0;
 	
-	if (	((pModule->flags&(NE_FFLAGS_BUILTIN|NE_FFLAGS_WIN32))==NE_FFLAGS_WIN32) &&
-		pModule->pe_module
-	)
-		return (HMODULE32)pModule->pe_module->mappeddll;
+	if (pModule->module32) return pModule->module32;
 	return handle;
     }
 }
@@ -127,7 +122,7 @@
             pModule->os_flags, pModule->min_swap_area,
             pModule->expected_version );
     if (pModule->flags & NE_FFLAGS_WIN32)
-        printf( "PE module=%08x\n", (unsigned int)pModule->pe_module );
+        printf( "PE module=%08x\n", pModule->module32 );
 
       /* Dump the file info */
 
@@ -557,7 +552,7 @@
     pModule = (NE_MODULE *)GlobalLock16( hModule );
     memcpy( pModule, &ne_header, sizeof(ne_header) );
     pModule->count = 0;
-    pModule->pe_module = NULL;
+    pModule->module32 = 0;
     pModule->self = hModule;
     pModule->self_loading_sel = 0;
     pData = (BYTE *)(pModule + 1);
@@ -1139,7 +1134,7 @@
  */
 HINSTANCE16 MODULE_Load( LPCSTR name, LPVOID paramBlock, UINT16 uFlags)
 {
-    HMODULE16 hModule;
+    HMODULE32 hModule;
     HINSTANCE16 hInstance, hPrevInstance;
     NE_MODULE *pModule;
     LOADPARAMS *params = (LOADPARAMS *)paramBlock;
@@ -1161,7 +1156,8 @@
         if (!hModule)  /* We have to load the module */
         {
             /* Try to load the built-in first if not disabled */
-            if ((hModule = BUILTIN_LoadModule( name, FALSE ))) return hModule;
+            if ((hModule = BUILTIN_LoadModule( name, FALSE )))
+                return MODULE_HANDLEtoHMODULE16( hModule );
             
             if ((hFile = OpenFile32( name, &ofs, OF_READ )) == HFILE_ERROR32)
             {
@@ -1169,7 +1165,7 @@
                 if ((hModule = BUILTIN_LoadModule( name, TRUE )))
                 {
                     fprintf( stderr, "Warning: could not load Windows DLL '%s', using built-in module.\n", name );
-                    return hModule;
+                    return MODULE_HANDLEtoHMODULE16( hModule );
                 }
                 return 2;  /* File not found */
             }
@@ -1254,7 +1250,7 @@
                                 (LPSTR)PTR_SEG_TO_LIN( params->cmdLine ),
                                  showcmd );
 
-	if( hTask && TASK_GetNextTask(hTask)) Yield();
+	if( hTask && TASK_GetNextTask(hTask)) Yield16();
     }
 
     return hInstance;
@@ -1508,6 +1504,17 @@
 
 
 /***********************************************************************
+ *           PrivateLoadLibrary       (KERNEL32)
+ *
+ * FIXME: rough guesswork, don't know what "Private" means
+ */
+HMODULE32 WINAPI PrivateLoadLibrary(LPCSTR libname)
+{
+        return LoadLibrary16(libname);
+}
+
+
+/***********************************************************************
  *           FreeLibrary16   (KERNEL.96)
  */
 void WINAPI FreeLibrary16( HINSTANCE16 handle )
@@ -1518,6 +1525,17 @@
 
 
 /***********************************************************************
+ *           PrivateFreeLibrary       (KERNEL32)
+ *
+ * FIXME: rough guesswork, don't know what "Private" means
+ */
+void WINAPI PrivateFreeLibrary(HMODULE32 handle)
+{
+	FreeLibrary16(handle);
+}
+
+
+/***********************************************************************
  *           WinExec16   (KERNEL.166)
  */
 HINSTANCE16 WINAPI WinExec16( LPCSTR lpCmdLine, UINT16 nCmdShow )
@@ -1773,15 +1791,14 @@
 	dprintf_win32(stddeb,"GetProcAddress32(%08lx,%p)\n",(DWORD)hModule,function);
     if (!(pModule = MODULE_GetPtr( hModule )))
         return (FARPROC32)0;
-    if (pModule->flags & NE_FFLAGS_BUILTIN)
-        return BUILTIN_GetProcAddress32( pModule, function );
-    if (!pModule->pe_module) {
-    	fprintf(stderr,"Oops, Module 0x%08lx has got no pe_module?\n",
+    if (!pModule->module32)
+    {
+    	fprintf(stderr,"Oops, Module 0x%08lx has got no module32?\n",
 		(DWORD)MODULE_HANDLEtoHMODULE32(hModule)
 	);
 	return (FARPROC32)0;
     }
-    return PE_FindExportedFunction( pModule->pe_module, function );
+    return PE_FindExportedFunction( pModule->module32, function );
 }
 
 /***********************************************************************
@@ -1798,11 +1815,9 @@
 
     if (!(pModule = MODULE_GetPtr( hModule )))
         return (LPIMAGE_NT_HEADERS)0;
-    if (!(pModule->flags & NE_FFLAGS_WIN32) || !pModule->pe_module)
+    if (!(pModule->flags & NE_FFLAGS_WIN32) || !pModule->module32)
         return (LPIMAGE_NT_HEADERS)0;
-    if (pModule->flags & NE_FFLAGS_BUILTIN)
-        return (LPIMAGE_NT_HEADERS)0;
-    return pModule->pe_module->pe_header;
+    return PE_HEADER(pModule->module32);
 }
 
 
diff --git a/loader/pe_image.c b/loader/pe_image.c
index 17bd230..1485cb6 100644
--- a/loader/pe_image.c
+++ b/loader/pe_image.c
@@ -40,13 +40,20 @@
 /* convert PE image VirtualAddress to Real Address */
 #define RVA(x) ((unsigned int)load_addr+(unsigned int)(x))
 
-void dump_exports(IMAGE_EXPORT_DIRECTORY * pe_exports, unsigned int load_addr)
+void dump_exports( HMODULE32 hModule )
 { 
   char		*Module;
   int		i, j;
   u_short	*ordinal;
   u_long	*function,*functions;
   u_char	**name;
+  unsigned int load_addr = hModule;
+
+  DWORD rva_start = PE_HEADER(hModule)->OptionalHeader
+                   .DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress;
+  DWORD rva_end = rva_start + PE_HEADER(hModule)->OptionalHeader
+                   .DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].Size;
+  IMAGE_EXPORT_DIRECTORY *pe_exports = (IMAGE_EXPORT_DIRECTORY*)RVA(rva_start);
 
   Module = (char*)RVA(pe_exports->Name);
   dprintf_win32(stddeb,"\n*******EXPORT DATA*******\nModule name is %s, %ld functions, %ld names\n", 
@@ -58,15 +65,18 @@
   functions=function=(u_long*) RVA(pe_exports->AddressOfFunctions);
   name=(u_char**) RVA(pe_exports->AddressOfNames);
 
-  dprintf_win32(stddeb," Ord  Virt Addr  Name\n" );
+  dprintf_win32(stddeb," Ord    RVA     Addr   Name\n" );
   for (i=0;i<pe_exports->NumberOfFunctions;i++, function++)
   {
       if (!*function) continue;  /* No such function */
-      dprintf_win32( stddeb,"%4ld  %08lx", i + pe_exports->Base, *function );
+      dprintf_win32( stddeb,"%4ld %08lx %08x",
+                     i + pe_exports->Base, *function, RVA(*function) );
       /* Check if we have a name for it */
       for (j = 0; j < pe_exports->NumberOfNames; j++)
           if (ordinal[j] == i)
               dprintf_win32( stddeb, "  %s", (char*)RVA(name[j]) );
+      if ((*function >= rva_start) && (*function <= rva_end))
+	  dprintf_win32(stddeb, " (forwarded -> %s)", (char *)RVA(*function));
       dprintf_win32( stddeb,"\n" );
   }
 }
@@ -79,7 +89,7 @@
  * If it is a ordinal:
  *	- use ordinal-pe_export->Base as offset into the functionlist
  */
-FARPROC32 PE_FindExportedFunction(struct pe_data *pe, LPCSTR funcName)
+FARPROC32 PE_FindExportedFunction( HMODULE32 hModule, LPCSTR funcName)
 {
 	IMAGE_EXPORT_DIRECTORY 		*exports;
 	unsigned			load_addr;
@@ -89,34 +99,47 @@
 	int				i;
 	PDB32				*process=(PDB32*)GetCurrentProcessId();
 	PE_MODREF			*pem;
+	u_long				rva_start, rva_end, addr;
+	char				* forward;
 
 	pem = process->modref_list;
-	while (pem && (pem->pe_module != pe))
+	while (pem && (pem->module != hModule))
 		pem=pem->next;
 	if (!pem) {
-		fprintf(stderr,"No MODREF found for PE_MODULE %p in process %p\n",pe,process);
+		fprintf(stderr,"No MODREF found for PE_MODULE %08x in process %p\n",hModule,process);
 		return NULL;
 	}
-	load_addr	= pem->load_addr;
-	exports		= pem->pe_export;
+	load_addr = hModule;
+	exports   = pem->pe_export;
 
 	if (HIWORD(funcName))
 		dprintf_win32(stddeb,"PE_FindExportedFunction(%s)\n",funcName);
 	else
 		dprintf_win32(stddeb,"PE_FindExportedFunction(%d)\n",(int)funcName);
 	if (!exports) {
-		fprintf(stderr,"Module %p/MODREF %p doesn't have a exports table.\n",pe,pem);
+		fprintf(stderr,"Module %08x/MODREF %p doesn't have a exports table.\n",hModule,pem);
 		return NULL;
 	}
 	ordinal	= (u_short*)  RVA(exports->AddressOfNameOrdinals);
 	function= (u_long*)   RVA(exports->AddressOfFunctions);
 	name	= (u_char **) RVA(exports->AddressOfNames);
+	forward = NULL;
+	rva_start = PE_HEADER(hModule)->OptionalHeader
+		.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress;
+	rva_end = rva_start + PE_HEADER(hModule)->OptionalHeader
+		.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].Size;
 
 	if (HIWORD(funcName)) {
 		for(i=0; i<exports->NumberOfNames; i++) {
 			ename=(char*)RVA(*name);
 			if(!strcmp(ename,funcName))
-				return (FARPROC32) RVA(function[*ordinal]);
+                        {
+                            addr = function[*ordinal];
+                            if ((addr < rva_start) || (addr >= rva_end))
+                                return (FARPROC32)RVA(addr);
+                            forward = (char *)RVA(addr);
+                            break;
+			}
 			ordinal++;
 			name++;
 		}
@@ -126,7 +149,19 @@
                                       LOWORD(funcName));
 			return NULL;
 		}
-		return (FARPROC32) RVA(function[(int)funcName-exports->Base]);
+		addr = function[(int)funcName-exports->Base];
+		if ((addr < rva_start) || (addr >= rva_end))
+			return (FARPROC32)RVA(addr);
+		forward = (char *)RVA(addr);
+	}
+	if (forward)
+        {
+		char module[256];
+		char *end = strchr(forward, '.');
+		if (!end) return NULL;
+		strncpy(module, forward, (end - forward));
+		module[end-forward] = 0;
+		return GetProcAddress32(MODULE_FindModule(module), end + 1);
 	}
 	return NULL;
 }
@@ -134,10 +169,9 @@
 void 
 fixup_imports (PDB32 *process,PE_MODREF *pem)
 {
-    PE_MODULE			*pe = pem->pe_module;
     IMAGE_IMPORT_DESCRIPTOR	*pe_imp;
     int	fixup_failed		= 0;
-    unsigned int load_addr	= pem->load_addr;
+    unsigned int load_addr	= pem->module;
     int				i;
     char			*modname;
     
@@ -176,7 +210,7 @@
 	    char *p, buffer[256];
 
 	    /* Try with prepending the path of the current module */
-	    GetModuleFileName32A (pe->mappeddll, buffer, sizeof (buffer));
+	    GetModuleFileName32A( pem->module, buffer, sizeof (buffer));
 	    if (!(p = strrchr (buffer, '\\')))
 		p = buffer;
 	    strcpy (p + 1, name);
@@ -189,7 +223,7 @@
 	res = MODULE_HANDLEtoHMODULE32(res);
 	xpem = pem->next;
 	while (xpem) {
-		if (xpem->pe_module->mappeddll == res)
+		if (xpem->module == res)
 			break;
 		xpem = xpem->next;
 	}
@@ -297,37 +331,36 @@
     if (fixup_failed) exit(1);
 }
 
-static int calc_vma_size(struct pe_data *pe)
+static int calc_vma_size( HMODULE32 hModule )
 {
-  int i,vma_size = 0;
+    int i,vma_size = 0;
+    IMAGE_SECTION_HEADER *pe_seg = PE_SECTIONS(hModule);
 
-  dprintf_win32(stddeb, "Dump of segment table\n");
-  dprintf_win32(stddeb, "   Name    VSz  Vaddr     SzRaw   Fileadr  *Reloc *Lineum #Reloc #Linum Char\n");
-  for(i=0; i< pe->pe_header->FileHeader.NumberOfSections; i++)
+    dprintf_win32(stddeb, "Dump of segment table\n");
+    dprintf_win32(stddeb, "   Name    VSz  Vaddr     SzRaw   Fileadr  *Reloc *Lineum #Reloc #Linum Char\n");
+    for (i = 0; i< PE_HEADER(hModule)->FileHeader.NumberOfSections; i++)
     {
-      dprintf_win32(stddeb, "%8s: %4.4lx %8.8lx %8.8lx %8.8lx %8.8lx %8.8lx %4.4x %4.4x %8.8lx\n", 
-	     pe->pe_seg[i].Name, 
-	     pe->pe_seg[i].Misc.VirtualSize,
-	     pe->pe_seg[i].VirtualAddress,
-	     pe->pe_seg[i].SizeOfRawData,
-	     pe->pe_seg[i].PointerToRawData,
-	     pe->pe_seg[i].PointerToRelocations,
-	     pe->pe_seg[i].PointerToLinenumbers,
-	     pe->pe_seg[i].NumberOfRelocations,
-	     pe->pe_seg[i].NumberOfLinenumbers,
-	     pe->pe_seg[i].Characteristics);
-	  vma_size = MAX(vma_size,
-	  		pe->pe_seg[i].VirtualAddress + 
-			pe->pe_seg[i].SizeOfRawData);
+        dprintf_win32(stddeb, "%8s: %4.4lx %8.8lx %8.8lx %8.8lx %8.8lx %8.8lx %4.4x %4.4x %8.8lx\n", 
+                      pe_seg->Name, 
+                      pe_seg->Misc.VirtualSize,
+                      pe_seg->VirtualAddress,
+                      pe_seg->SizeOfRawData,
+                      pe_seg->PointerToRawData,
+                      pe_seg->PointerToRelocations,
+                      pe_seg->PointerToLinenumbers,
+                      pe_seg->NumberOfRelocations,
+                      pe_seg->NumberOfLinenumbers,
+                      pe_seg->Characteristics);
+        vma_size = MAX(vma_size, pe_seg->VirtualAddress+pe_seg->SizeOfRawData);
+        pe_seg++;
     }
     return vma_size;
 }
 
 static void do_relocations(PE_MODREF *pem)
 {
-	int delta = pem->load_addr - pem->pe_module->pe_header->OptionalHeader.ImageBase;
-
-	unsigned int			load_addr= pem->load_addr;
+    int delta = pem->module - PE_HEADER(pem->module)->OptionalHeader.ImageBase;
+    unsigned int load_addr= pem->module;
 	IMAGE_BASE_RELOCATION		*r = pem->pe_reloc;
 	int				hdelta = (delta >> 16) & 0xFFFF;
 	int				ldelta = delta & 0xFFFF;
@@ -398,9 +431,8 @@
  * BUT we have to map the whole image anyway, for Win32 programs sometimes
  * want to access them. (HMODULE32 point to the start of it)
  */
-static PE_MODULE *PE_LoadImage( HFILE32 hFile )
+static HMODULE32 PE_LoadImage( HFILE32 hFile )
 {
-    struct pe_data *pe;
     HMODULE32 hModule;
     HANDLE32 mapping;
 
@@ -411,7 +443,7 @@
     {
         fprintf( stderr, "PE_LoadImage: CreateFileMapping error %ld\n",
                  GetLastError() );
-        return NULL;
+        return 0;
     }
     hModule = (HMODULE32)MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 0 );
     CloseHandle( mapping );
@@ -419,126 +451,128 @@
     {
         fprintf( stderr, "PE_LoadImage: MapViewOfFile error %ld\n",
                  GetLastError() );
-        return NULL;
+        return 0;
     }
 
-    /* build PE header */
-    pe = xmalloc(sizeof(struct pe_data));
-    pe->mappeddll = hModule;
-    pe->pe_header = (IMAGE_NT_HEADERS*)(pe->mappeddll+(((IMAGE_DOS_HEADER*)pe->mappeddll)->e_lfanew));
-    if (pe->pe_header->Signature!=IMAGE_NT_SIGNATURE)
+    if (PE_HEADER(hModule)->Signature != IMAGE_NT_SIGNATURE)
     {
         fprintf(stderr,"image doesn't have PE signature, but 0x%08lx\n",
-                pe->pe_header->Signature );
-        free(pe);
-        return NULL;
+                PE_HEADER(hModule)->Signature );
+        goto error;
     }
 
-	if (pe->pe_header->FileHeader.Machine != IMAGE_FILE_MACHINE_I386) {
-		fprintf(stderr,"trying to load PE image for unsupported architecture (");
-		switch (pe->pe_header->FileHeader.Machine) {
-		case IMAGE_FILE_MACHINE_UNKNOWN:
-			fprintf(stderr,"Unknown");break;
-		case IMAGE_FILE_MACHINE_I860:
-			fprintf(stderr,"I860");break;
-		case IMAGE_FILE_MACHINE_R3000:
-			fprintf(stderr,"R3000");break;
-		case IMAGE_FILE_MACHINE_R4000:
-			fprintf(stderr,"R4000");break;
-		case IMAGE_FILE_MACHINE_R10000:
-			fprintf(stderr,"R10000");break;
-		case IMAGE_FILE_MACHINE_ALPHA:
-			fprintf(stderr,"Alpha");break;
-		case IMAGE_FILE_MACHINE_POWERPC:
-			fprintf(stderr,"PowerPC");break;
-		default:
-			fprintf(stderr,"Unknown-%04x",pe->pe_header->FileHeader.Machine);break;
-		}
-		fprintf(stderr,")\n");
-		return NULL;
-	}
-	pe->pe_seg = (IMAGE_SECTION_HEADER*)(((LPBYTE)(pe->pe_header+1))-
-		 (16 - pe->pe_header->OptionalHeader.NumberOfRvaAndSizes) * sizeof(IMAGE_DATA_DIRECTORY));
+    if (PE_HEADER(hModule)->FileHeader.Machine != IMAGE_FILE_MACHINE_I386)
+    {
+        fprintf(stderr,"trying to load PE image for unsupported architecture (");
+        switch (PE_HEADER(hModule)->FileHeader.Machine)
+        {
+        case IMAGE_FILE_MACHINE_UNKNOWN: fprintf(stderr,"Unknown"); break;
+        case IMAGE_FILE_MACHINE_I860:    fprintf(stderr,"I860"); break;
+        case IMAGE_FILE_MACHINE_R3000:   fprintf(stderr,"R3000"); break;
+        case IMAGE_FILE_MACHINE_R4000:   fprintf(stderr,"R4000"); break;
+        case IMAGE_FILE_MACHINE_R10000:  fprintf(stderr,"R10000"); break;
+        case IMAGE_FILE_MACHINE_ALPHA:   fprintf(stderr,"Alpha"); break;
+        case IMAGE_FILE_MACHINE_POWERPC: fprintf(stderr,"PowerPC"); break;
+        default: fprintf(stderr,"Unknown-%04x",
+                         PE_HEADER(hModule)->FileHeader.Machine); break;
+        }
+        fprintf(stderr,")\n");
+        goto error;
+    }
+    return hModule;
 
-/* FIXME: the (16-...) is a *horrible* hack to make COMDLG32.DLL load OK. The
- * problem needs to be fixed properly at some stage.
- */
- 	return pe;
+error:
+    UnmapViewOfFile( (LPVOID)hModule );
+    return 0;
 }
 
 /**********************************************************************
  * This maps a loaded PE dll into the address space of the specified process.
  */
-void
-PE_MapImage(PE_MODULE *pe,PDB32 *process, OFSTRUCT *ofs, DWORD flags) {
+static HMODULE32 PE_MapImage( HMODULE32 hModule, PDB32 *process,
+                              OFSTRUCT *ofs, DWORD flags )
+{
 	PE_MODREF		*pem;
 	int			i, result;
-	int			load_addr;
+	DWORD			load_addr;
 	IMAGE_DATA_DIRECTORY	dir;
 	char			*modname;
 	int			vma_size;
+
+        IMAGE_SECTION_HEADER *pe_seg;
+        IMAGE_DOS_HEADER *dos_header = (IMAGE_DOS_HEADER *)hModule;
+        IMAGE_NT_HEADERS *nt_header = PE_HEADER(hModule);
 	
-	pem		= (PE_MODREF*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(*pem));
+	pem = (PE_MODREF*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,
+                                    sizeof(*pem));
 	/* NOTE: fixup_imports takes care of the correct order */
 	pem->next	= process->modref_list;
 	process->modref_list = pem;
 
-	pem->pe_module	= pe;
-	if (!(pe->pe_header->FileHeader.Characteristics & IMAGE_FILE_DLL)) {
+	if (!(nt_header->FileHeader.Characteristics & IMAGE_FILE_DLL))
+        {
 		if (process->exe_modref)
 			fprintf(stderr,"overwriting old exe_modref... arrgh\n");
 		process->exe_modref = pem;
 	}
 
-	load_addr 	= pe->pe_header->OptionalHeader.ImageBase;
-	dprintf_win32(stddeb, "Load addr is %x\n",load_addr);
-	vma_size = calc_vma_size(pe);
-	load_addr 	= (int) VirtualAlloc( (void*)load_addr, vma_size, MEM_RESERVE|MEM_COMMIT, PAGE_EXECUTE_READWRITE );
-        pem->load_addr	= load_addr;
+	load_addr = nt_header->OptionalHeader.ImageBase;
+	vma_size = calc_vma_size( hModule );
+	dprintf_win32(stddeb, "Load addr is %lx\n",load_addr);
+	load_addr = (DWORD)VirtualAlloc( (void*)load_addr, vma_size,
+                                         MEM_RESERVE | MEM_COMMIT,
+                                         PAGE_EXECUTE_READWRITE );
+	pem->module = (HMODULE32)load_addr;
 
 	dprintf_win32(stddeb, "Load addr is really %lx, range %x\n",
-		pem->load_addr, vma_size);
+                      load_addr, vma_size);
 	
+        /* Store the NT header at the load addr
+         * (FIXME: should really use mmap)
+         */
+        *(IMAGE_DOS_HEADER *)load_addr = *dos_header;
+        *(IMAGE_NT_HEADERS *)(load_addr + dos_header->e_lfanew) = *nt_header;
 
-	for(i=0; i < pe->pe_header->FileHeader.NumberOfSections; i++)
+        pe_seg = PE_SECTIONS(hModule);
+	for (i = 0; i < nt_header->FileHeader.NumberOfSections; i++, pe_seg++)
 	{
 		/* memcpy only non-BSS segments */
 		/* FIXME: this should be done by mmap(..MAP_PRIVATE|MAP_FIXED..)
 		 * but it is not possible for (at least) Linux needs
 		 * a page-aligned offset.
 		 */
-		if(!(pe->pe_seg[i].Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA))
-		    memcpy((char*)RVA(pe->pe_seg[i].VirtualAddress),
-		    	(char*)(pe->mappeddll+pe->pe_seg[i].PointerToRawData),
-			pe->pe_seg[i].SizeOfRawData
+		if(!(pe_seg->Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA))
+		    memcpy((char*)RVA(pe_seg->VirtualAddress),
+		    	(char*)(hModule + pe_seg->PointerToRawData),
+			pe_seg->SizeOfRawData
 		    );
 
-		result = RVA (pe->pe_seg[i].VirtualAddress);
+		result = RVA (pe_seg->VirtualAddress);
 #if 1
 		/* not needed, memory is zero */
-		if(strcmp(pe->pe_seg[i].Name, ".bss") == 0)
+		if(strcmp(pe_seg->Name, ".bss") == 0)
 		    memset((void *)result, 0, 
-			   pe->pe_seg[i].Misc.VirtualSize ?
-			   pe->pe_seg[i].Misc.VirtualSize :
-			   pe->pe_seg[i].SizeOfRawData);
+			   pe_seg->Misc.VirtualSize ?
+			   pe_seg->Misc.VirtualSize :
+			   pe_seg->SizeOfRawData);
 #endif
 
-		if(strcmp(pe->pe_seg[i].Name, ".idata") == 0)
+		if(strcmp(pe_seg->Name, ".idata") == 0)
 			pem->pe_import = (LPIMAGE_IMPORT_DESCRIPTOR) result;
 
-		if(strcmp(pe->pe_seg[i].Name, ".edata") == 0)
+		if(strcmp(pe_seg->Name, ".edata") == 0)
 			pem->pe_export = (LPIMAGE_EXPORT_DIRECTORY) result;
 
-		if(strcmp(pe->pe_seg[i].Name, ".rsrc") == 0)
+		if(strcmp(pe_seg->Name, ".rsrc") == 0)
 			pem->pe_resource = (LPIMAGE_RESOURCE_DIRECTORY) result;
 
-		if(strcmp(pe->pe_seg[i].Name, ".reloc") == 0)
+		if(strcmp(pe_seg->Name, ".reloc") == 0)
 			pem->pe_reloc = (LPIMAGE_BASE_RELOCATION) result;
 	}
 
 	/* There is word that the actual loader does not care about the
 	   section names, and only goes for the DataDirectory */
-	dir=pe->pe_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT];
+	dir=nt_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT];
 	if(dir.Size)
 	{
 		if(pem->pe_export && (int)pem->pe_export!=RVA(dir.VirtualAddress))
@@ -547,7 +581,7 @@
 		pem->pe_export = (LPIMAGE_EXPORT_DIRECTORY) RVA(dir.VirtualAddress);
 	}
 
-	dir=pe->pe_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT];
+	dir=nt_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT];
 	if(dir.Size)
 	{
 		/* 
@@ -557,7 +591,7 @@
 		pem->pe_import = (LPIMAGE_IMPORT_DESCRIPTOR) RVA(dir.VirtualAddress);
 	}
 
-	dir=pe->pe_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE];
+	dir=nt_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE];
 	if(dir.Size)
 	{
 		if(pem->pe_resource && (int)pem->pe_resource!=RVA(dir.VirtualAddress))
@@ -565,15 +599,15 @@
 		pem->pe_resource = (LPIMAGE_RESOURCE_DIRECTORY) RVA(dir.VirtualAddress);
 	}
 
-	if(pe->pe_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXCEPTION].Size)
+	if(nt_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXCEPTION].Size)
 		dprintf_win32(stdnimp,"Exception directory ignored\n");
 
-	if(pe->pe_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_SECURITY].Size)
+	if(nt_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_SECURITY].Size)
 		dprintf_win32(stdnimp,"Security directory ignored\n");
 
 
 
-	dir=pe->pe_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC];
+	dir=nt_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC];
 	if(dir.Size)
 	{
 		if(pem->pe_reloc && (int)pem->pe_reloc!= RVA(dir.VirtualAddress))
@@ -581,38 +615,38 @@
 		pem->pe_reloc = (void *) RVA(dir.VirtualAddress);
 	}
 
-	if(pe->pe_header->OptionalHeader.DataDirectory
+	if(nt_header->OptionalHeader.DataDirectory
 		[IMAGE_DIRECTORY_ENTRY_COPYRIGHT].Size)
 		dprintf_win32(stdnimp,"Copyright string ignored\n");
 
-	if(pe->pe_header->OptionalHeader.DataDirectory
+	if(nt_header->OptionalHeader.DataDirectory
 		[IMAGE_DIRECTORY_ENTRY_GLOBALPTR].Size)
 		dprintf_win32(stdnimp,"Global Pointer (MIPS) ignored\n");
 
-	if(pe->pe_header->OptionalHeader.DataDirectory
+	if(nt_header->OptionalHeader.DataDirectory
 		[IMAGE_DIRECTORY_ENTRY_TLS].Size)
 		 fprintf(stdnimp,"Thread local storage ignored\n");
 
-	if(pe->pe_header->OptionalHeader.DataDirectory
+	if(nt_header->OptionalHeader.DataDirectory
 		[IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG].Size)
 		dprintf_win32(stdnimp,"Load Configuration directory ignored\n");
 
-	if(pe->pe_header->OptionalHeader.DataDirectory
+	if(nt_header->OptionalHeader.DataDirectory
 		[IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT].Size)
 		dprintf_win32(stdnimp,"Bound Import directory ignored\n");
 
-	if(pe->pe_header->OptionalHeader.DataDirectory
+	if(nt_header->OptionalHeader.DataDirectory
 		[IMAGE_DIRECTORY_ENTRY_IAT].Size)
 		dprintf_win32(stdnimp,"Import Address Table directory ignored\n");
-	if(pe->pe_header->OptionalHeader.DataDirectory[13].Size)
+	if(nt_header->OptionalHeader.DataDirectory[13].Size)
 		dprintf_win32(stdnimp,"Unknown directory 13 ignored\n");
-	if(pe->pe_header->OptionalHeader.DataDirectory[14].Size)
+	if(nt_header->OptionalHeader.DataDirectory[14].Size)
 		dprintf_win32(stdnimp,"Unknown directory 14 ignored\n");
-	if(pe->pe_header->OptionalHeader.DataDirectory[15].Size)
+	if(nt_header->OptionalHeader.DataDirectory[15].Size)
 		dprintf_win32(stdnimp,"Unknown directory 15 ignored\n");
 
 	if(pem->pe_reloc)	do_relocations(pem);
-	if(pem->pe_export)	dump_exports(pem->pe_export,load_addr);
+	if(pem->pe_export)	dump_exports(pem->module);
 	if(pem->pe_import)	fixup_imports(process,pem);
   		
 	if (pem->pe_export)
@@ -625,6 +659,11 @@
 		if ((s=strchr(modname,'.')))
 			*s='\0';
 	}
+
+        /* Now that we got everything at the right address,
+         * we can unmap the previous module */
+        UnmapViewOfFile( (LPVOID)hModule );
+        return (HMODULE32)load_addr;
 }
 
 HINSTANCE16 MODULE_CreateInstance(HMODULE16 hModule,LOADPARAMS *params);
@@ -647,8 +686,7 @@
 		/* check if this module is already mapped */
 		pem 	= ((PDB32*)GetCurrentProcessId())->modref_list;
 		while (pem) {
-			if (pem->pe_module->mappeddll == hModule)
-				return hModule;
+			if (pem->module == hModule) return hModule;
 			pem = pem->next;
 		}
 		pModule = MODULE_GetPtr(hModule);
@@ -656,14 +694,14 @@
 
 		/* try to load builtin, enabled modules first */
 		if ((hModule = BUILTIN_LoadModule( name, FALSE )))
-			return hModule;
+                    return MODULE_HANDLEtoHMODULE32( hModule );
 
 		/* try to open the specified file */
 		if (HFILE_ERROR32==(hFile=OpenFile32(name,&ofs,OF_READ))) {
 			/* Now try the built-in even if disabled */
 			if ((hModule = BUILTIN_LoadModule( name, TRUE ))) {
 				fprintf( stderr, "Warning: could not load Windows DLL '%s', using built-in module.\n", name );
-				return hModule;
+                                return MODULE_HANDLEtoHMODULE32( hModule );
 			}
 			return 1;
 		}
@@ -673,14 +711,15 @@
 		}
 		pModule		= (NE_MODULE *)GlobalLock16( hModule );
 		pModule->flags	= NE_FFLAGS_WIN32;
-		pModule->pe_module = PE_LoadImage( hFile );
+		pModule->module32 = PE_LoadImage( hFile );
 		CloseHandle( hFile );
-		if (!pModule->pe_module)
-			return 21;
+		if (pModule->module32 < 32) return 21;
 	}
 	/* recurse */
-	PE_MapImage(pModule->pe_module,(PDB32*)GetCurrentProcessId(),&ofs,flags);
-	return pModule->pe_module->mappeddll;
+	pModule->module32 = PE_MapImage( pModule->module32,
+                                         (PDB32*)GetCurrentProcessId(),
+                                         &ofs,flags);
+	return pModule->module32;
 }
 
 /*****************************************************************************
@@ -690,28 +729,29 @@
  */
 HINSTANCE16 PE_LoadModule( HFILE32 hFile, OFSTRUCT *ofs, LOADPARAMS* params )
 {
-    HMODULE16 hModule;
+    HMODULE16 hModule16;
+    HMODULE32 hModule32;
     HINSTANCE16 hInstance;
     NE_MODULE *pModule;
 
-    if ((hModule = MODULE_CreateDummyModule( ofs )) < 32) return hModule;
-    pModule = (NE_MODULE *)GlobalLock16( hModule );
+    if ((hModule16 = MODULE_CreateDummyModule( ofs )) < 32) return hModule16;
+    pModule = (NE_MODULE *)GlobalLock16( hModule16 );
     pModule->flags = NE_FFLAGS_WIN32;
 
-    pModule->pe_module = PE_LoadImage( hFile );
+    pModule->module32 = hModule32 = PE_LoadImage( hFile );
     CloseHandle( hFile );
-    if (!pModule->pe_module)
-    	return 21;
+    if (hModule32 < 32) return 21;
 
-    hInstance = MODULE_CreateInstance( hModule, params );
-    if (!(pModule->pe_module->pe_header->FileHeader.Characteristics & IMAGE_FILE_DLL))
+    hInstance = MODULE_CreateInstance( hModule16, params );
+    if (!(PE_HEADER(hModule32)->FileHeader.Characteristics & IMAGE_FILE_DLL))
     {
-        TASK_CreateTask( hModule, hInstance, 0,
+        TASK_CreateTask( hModule16, hInstance, 0,
                          params->hEnvironment,
                          (LPSTR)PTR_SEG_TO_LIN( params->cmdLine ),
                          *((WORD*)PTR_SEG_TO_LIN(params->showCmd) + 1) );
     }
-    PE_MapImage(pModule->pe_module,(PDB32*)GetCurrentProcessId(),ofs,0);
+    pModule->module32 = PE_MapImage( hModule32, (PDB32*)GetCurrentProcessId(),
+                                     ofs, 0 );
     return hInstance;
 }
 
@@ -729,9 +769,6 @@
  */
 static void PE_InitDLL(PE_MODREF *pem, DWORD type,LPVOID lpReserved)
 {
-    PE_MODULE		*pe = pem->pe_module;
-    unsigned int	load_addr = pem->load_addr;
-
     if (type==DLL_PROCESS_ATTACH)
 	pem->flags |= PE_MODREF_PROCESS_ATTACHED;
 
@@ -743,13 +780,14 @@
      */
         
     /* Is this a library? And has it got an entrypoint? */
-    if (	(pe->pe_header->FileHeader.Characteristics & IMAGE_FILE_DLL) &&
-		(pe->pe_header->OptionalHeader.AddressOfEntryPoint)
+    if ((PE_HEADER(pem->module)->FileHeader.Characteristics & IMAGE_FILE_DLL) &&
+        (PE_HEADER(pem->module)->OptionalHeader.AddressOfEntryPoint)
     ) {
-        FARPROC32 entry = (FARPROC32)RVA(pe->pe_header->OptionalHeader.AddressOfEntryPoint);
+        FARPROC32 entry = (FARPROC32)RVA_PTR( pem->module,
+                                          OptionalHeader.AddressOfEntryPoint );
         dprintf_relay( stddeb, "CallTo32(entryproc=%p,module=%d,type=%ld,res=%p)\n",
-                       entry, pe->mappeddll, type, lpReserved );
-        entry( pe->mappeddll, type, lpReserved );
+                       entry, pem->module, type, lpReserved );
+        entry( pem->module, type, lpReserved );
     }
 }
 
@@ -788,12 +826,12 @@
 
 	pem = pdb->modref_list;
 	while (pem) {
-		peh = pem->pe_module->pe_header;
+		peh = PE_HEADER(pem->module);
 		if (!peh->OptionalHeader.DataDirectory[IMAGE_FILE_THREAD_LOCAL_STORAGE].VirtualAddress) {
 			pem = pem->next;
 			continue;
 		}
-		pdir = (LPVOID)(pem->load_addr + peh->OptionalHeader.
+		pdir = (LPVOID)(pem->module + peh->OptionalHeader.
 			DataDirectory[IMAGE_FILE_THREAD_LOCAL_STORAGE].VirtualAddress);
 		index	= TlsAlloc();
 		datasize= pdir->EndAddressOfRawData-pdir->StartAddressOfRawData;
@@ -816,7 +854,7 @@
 	PE_MODREF	*pem = process->modref_list;
 
 	while (pem) {
-		if (pem->pe_module->mappeddll == hModule)
+		if (pem->module == hModule)
 			pem->flags|=PE_MODREF_NO_DLL_CALLS;
 		pem = pem->next;
 	}
diff --git a/loader/pe_resource.c b/loader/pe_resource.c
index 11ee003..4ba09dd 100644
--- a/loader/pe_resource.c
+++ b/loader/pe_resource.c
@@ -41,7 +41,7 @@
 	if (!hmod) return NULL;
 	if (!(pModule = MODULE_GetPtr( hmod ))) return 0;
 	pem = pdb->modref_list;
-	while (pem && pem->pe_module->mappeddll != hmod)
+	while (pem && pem->module != hmod)
 		pem=pem->next;
 	return pem;
 }
@@ -141,7 +141,7 @@
     	return 0;
     if (!hRsrc)
    	 return 0;
-    return (HANDLE32) (pem->load_addr+((LPIMAGE_RESOURCE_DATA_ENTRY)hRsrc)->OffsetToData);
+    return (HANDLE32) (pem->module + ((LPIMAGE_RESOURCE_DATA_ENTRY)hRsrc)->OffsetToData);
 }
 
 
diff --git a/loader/resource.c b/loader/resource.c
index 0017fa7..5e98fb5 100644
--- a/loader/resource.c
+++ b/loader/resource.c
@@ -45,19 +45,27 @@
     NE_MODULE *pModule;
 
     hModule = MODULE_HANDLEtoHMODULE16( hModule ); 
-    dprintf_resource(stddeb, "FindResource16: module=%04x type=", hModule );
-    PrintId( type );
+    dprintf_resource(stddeb, "FindResource16: module=%04x", hModule );
 
     if (HIWORD(name))  /* Check for '#xxx' name */
     {
 	char *ptr = PTR_SEG_TO_LIN( name );
-	if (ptr[0] == '#') {
+	if (ptr[0] == '#')
 	    if (!(name = (SEGPTR)atoi( ptr + 1 ))) return 0;
-	}
     }
 
     dprintf_resource( stddeb, " name=" );
     PrintId( name );
+
+    if (HIWORD(type))  /* Check for '#xxx' type */
+    {
+	char *ptr = PTR_SEG_TO_LIN( type );
+	if (ptr[0] == '#')
+	    if (!(type = (SEGPTR)atoi( ptr + 1 ))) return 0;
+    }
+
+    dprintf_resource( stddeb, " type=" );
+    PrintId( type );
     dprintf_resource( stddeb, "\n" );
 
     if ((pModule = MODULE_GetPtr( hModule )))
@@ -547,7 +555,7 @@
  *	LoadString32W		(USER32.375)
  */
 INT32 WINAPI LoadString32W( HINSTANCE32 instance, UINT32 resource_id,
-                            LPWSTR buffer, int buflen )
+                            LPWSTR buffer, INT32 buflen )
 {
     HGLOBAL32 hmem;
     HRSRC32 hrsrc;
@@ -599,16 +607,20 @@
  *	LoadString32A	(USER32.374)
  */
 INT32 WINAPI LoadString32A( HINSTANCE32 instance, UINT32 resource_id,
-                            LPSTR buffer,int buflen )
+                            LPSTR buffer, INT32 buflen )
 {
     INT32 retval;
     LPWSTR buffer2 = NULL;
-    if (buffer) buffer2 = HeapAlloc( GetProcessHeap(), 0, buflen * 2 );
+    if (buffer && buflen)
+	buffer2 = HeapAlloc( GetProcessHeap(), 0, buflen * 2 );
     retval = LoadString32W(instance,resource_id,buffer2,buflen);
 
     if (buffer2)
     {
-        lstrcpynWtoA( buffer, buffer2, buflen );
+	if (retval) {
+	    lstrcpynWtoA( buffer, buffer2, buflen );
+	    retval = lstrlen32A( buffer );
+	}
 	HeapFree( GetProcessHeap(), 0, buffer2 );
     }
     return retval;
@@ -640,7 +652,7 @@
  *	LoadMessage32A		(internal)
  */
 INT32 LoadMessage32A( HINSTANCE32 instance, UINT32 id, WORD lang,
-                      LPSTR buffer, int buflen )
+                      LPSTR buffer, INT32 buflen )
 {
     HGLOBAL32	hmem;
     HRSRC32	hrsrc;
@@ -708,15 +720,19 @@
  *	LoadMessage32W	(internal)
  */
 INT32 LoadMessage32W( HINSTANCE32 instance, UINT32 id, WORD lang,
-                      LPWSTR buffer, int buflen )
+                      LPWSTR buffer, INT32 buflen )
 {
     INT32 retval;
     LPSTR buffer2 = NULL;
-    if (buffer) buffer2 = HeapAlloc( GetProcessHeap(), 0, buflen );
+    if (buffer && buflen)
+	buffer2 = HeapAlloc( GetProcessHeap(), 0, buflen );
     retval = LoadMessage32A(instance,id,lang,buffer2,buflen);
     if (buffer)
     {
-        lstrcpynAtoW( buffer, buffer2, buflen );
+	if (retval) {
+	    lstrcpynAtoW( buffer, buffer2, buflen );
+	    retval = lstrlen32W( buffer );
+	}
 	HeapFree( GetProcessHeap(), 0, buffer2 );
     }
     return retval;
diff --git a/loader/task.c b/loader/task.c
index 4c5d51f..cf981d4 100644
--- a/loader/task.c
+++ b/loader/task.c
@@ -340,18 +340,17 @@
     SEGTABLEENTRY *pSegTable = NE_SEG_TABLE( pModule );
 
     IF1632_Saved16_ss_sp = pTask->ss_sp;
+    SET_FS( pCurrentThread->teb_sel );
     if (pModule->flags & NE_FFLAGS_WIN32)
     {
         /* FIXME: all this is an ugly hack */
 
         extern void InitTask( CONTEXT *context );
 
-        FARPROC32 entry = (FARPROC32)(pCurrentProcess->exe_modref->load_addr + 
-                 pCurrentProcess->exe_modref->pe_module->pe_header->OptionalHeader.AddressOfEntryPoint);
+        FARPROC32 entry = (FARPROC32)RVA_PTR( pCurrentProcess->exe_modref->module, OptionalHeader.AddressOfEntryPoint );
 
         InitTask( NULL );
         InitApp( pTask->hModule );
-        SET_FS( pCurrentThread->teb_sel );
         PE_InitializeDLLs( pCurrentProcess, DLL_PROCESS_ATTACH, (LPVOID)-1 );
         dprintf_relay( stddeb, "CallTo32(entryproc=%p)\n", entry );
         exit_code = entry();
@@ -526,7 +525,8 @@
 	    	pCurrentProcess->exe_modref->load_addr +
 		pCurrentProcess->exe_modref->pe_module->pe_header->OptionalHeader.AddressOfEntryPoint);
      */
-        pTask->thdb = THREAD_Create( pdb32, 0, 0 );
+        pTask->thdb = THREAD_Create( pdb32,
+          PE_HEADER(pModule->module32)->OptionalHeader.SizeOfStackReserve, 0 );
         /* FIXME: should not be done here */
         pCurrentThread = pTask->thdb;
         PE_InitTls( pdb32 );
@@ -1005,9 +1005,9 @@
 
 
 /***********************************************************************
- *           Yield  (KERNEL.29)
+ *           Yield16  (KERNEL.29)
  */
-void WINAPI Yield(void)
+void WINAPI Yield16(void)
 {
     TDB *pCurTask = (TDB *)GlobalLock16( hCurrentTask );
     if (pCurTask) pCurTask->hYieldTo = 0;
@@ -1021,16 +1021,24 @@
  */
 FARPROC16 WINAPI MakeProcInstance16( FARPROC16 func, HANDLE16 hInstance )
 {
-    BYTE *thunk;
+    BYTE *thunk,*lfunc;
     SEGPTR thunkaddr;
     
     if (__winelib) return func; /* func can be called directly in Winelib */
     thunkaddr = TASK_AllocThunk( hCurrentTask );
     if (!thunkaddr) return (FARPROC16)0;
     thunk = PTR_SEG_TO_LIN( thunkaddr );
+    lfunc = PTR_SEG_TO_LIN( func );
 
     dprintf_task( stddeb, "MakeProcInstance(%08lx,%04x): got thunk %08lx\n",
                   (DWORD)func, hInstance, (DWORD)thunkaddr );
+    if (((lfunc[0]==0x8c) && (lfunc[1]==0xd8)) ||
+    	((lfunc[0]==0x1e) && (lfunc[1]==0x58))
+    ) {
+    	fprintf(stderr,"FIXME: MakeProcInstance16 thunk would be useless for %p, overwriting with nop;nop;\n", func );
+	lfunc[0]=0x90; /* nop */
+	lfunc[1]=0x90; /* nop */
+    }
     
     *thunk++ = 0xb8;    /* movw instance, %ax */
     *thunk++ = (BYTE)(hInstance & 0xff);
@@ -1074,6 +1082,15 @@
 }
 
 
+/**********************************************************************
+ *          DefineHandleTable16    (KERNEL.94)
+ */
+BOOL16 WINAPI DefineHandleTable16( WORD wOffset )
+{
+    return TRUE;  /* FIXME */
+}
+
+
 /***********************************************************************
  *           SetTaskQueue  (KERNEL.34)
  */
diff --git a/memory/global.c b/memory/global.c
index b4b53cd..4490b8a 100644
--- a/memory/global.c
+++ b/memory/global.c
@@ -567,9 +567,9 @@
 
 
 /***********************************************************************
- *           SetSwapAreaSize   (KERNEL.106)
+ *           SetSwapAreaSize16   (KERNEL.106)
  */
-LONG WINAPI SetSwapAreaSize( WORD size )
+LONG WINAPI SetSwapAreaSize16( WORD size )
 {
     dprintf_global(stdnimp, "STUB: SetSwapAreaSize(%d)\n", size );
     return MAKELONG( size, 0xffff );
diff --git a/memory/virtual.c b/memory/virtual.c
index 8bc92ce..7ae69be 100644
--- a/memory/virtual.c
+++ b/memory/virtual.c
@@ -1081,6 +1081,28 @@
 
 
 /***********************************************************************
+ *             FlushViewOfFile   (KERNEL32.262)
+ */
+BOOL32 WINAPI FlushViewOfFile( LPCVOID base, DWORD cbFlush )
+{
+    FILE_VIEW *view;
+    UINT32 addr = ROUND_ADDR( base );
+
+    dprintf_virtual( stddeb, "FlushViewOfFile at %p for %ld bytes\n",
+                     base, cbFlush );
+
+    if (!(view = VIRTUAL_FindView( addr )))
+    {
+        SetLastError( ERROR_INVALID_PARAMETER );
+        return FALSE;
+    }
+    if (!cbFlush) cbFlush = view->size;
+    if (!msync( addr, cbFlush, MS_SYNC )) return TRUE;
+    SetLastError( ERROR_INVALID_PARAMETER );
+    return FALSE;
+
+}
+/***********************************************************************
  *             UnmapViewOfFile   (KERNEL32.540)
  */
 BOOL32 WINAPI UnmapViewOfFile( LPVOID addr )
diff --git a/misc/Makefile.in b/misc/Makefile.in
index 9a5b752..4bbbe90 100644
--- a/misc/Makefile.in
+++ b/misc/Makefile.in
@@ -10,7 +10,6 @@
 	callback.c \
 	comm.c \
 	commdlg.c \
-	compobj.c \
 	crtdll.c \
 	cpu.c \
 	ddeml.c \
@@ -22,15 +21,11 @@
 	mpr.c \
 	network.c \
 	ntdll.c \
-	ole2.c \
-	ole2disp.c \
-	ole2nls.c \
-	olecli.c \
-	olesvr.c \
 	port.c \
 	printdrv.c \
 	registry.c \
 	shell.c \
+	shellord.c \
 	sound.c \
 	spy.c \
 	stress.c \
@@ -39,6 +34,8 @@
 	tweak.c \
 	ver.c \
 	version.c \
+	w32scomb.c \
+	w32skrnl.c \
 	w32sys.c \
 	winsock.c \
 	winsock_dns.c \
diff --git a/misc/commdlg.c b/misc/commdlg.c
index 4c3668d..83fa922 100644
--- a/misc/commdlg.c
+++ b/misc/commdlg.c
@@ -124,6 +124,7 @@
     }
 
     hInst = WIN_GetWindowInstance( lpofn->hwndOwner );
+    /* FIXME: doesn't handle win32 format correctly yet */
     hwndDialog = DIALOG_CreateIndirect( hInst, template, win32Format,
                                         lpofn->hwndOwner,
                                         (DLGPROC16)MODULE_GetWndProcEntry16("FileOpenDlgProc"),
diff --git a/misc/crtdll.c b/misc/crtdll.c
index d5be371..7ffa01a 100644
--- a/misc/crtdll.c
+++ b/misc/crtdll.c
@@ -475,6 +475,16 @@
 
 
 /*********************************************************************
+ *                  _abnormal_termination          (CRTDLL.36 )
+ */
+INT32 __cdecl CRTDLL__abnormal_termination(void)
+{
+        dprintf_crtdll(stddeb,"CRTDLL__abnormal_termination\n");
+	return 0;
+}
+
+
+/*********************************************************************
  *                  fflush        (CRTDLL.365)
  */
 INT32 __cdecl CRTDLL_fflush(LPVOID stream)
@@ -583,6 +593,19 @@
 }
 
 /*********************************************************************
+ *                  _rotl          (CRTDLL.259)
+ */
+UINT32 __cdecl CRTDLL__rotl(UINT32 x,INT32 shift)
+{
+   unsigned int ret = (x >> shift)|( x >>((sizeof(x))-shift));
+
+   dprintf_crtdll(stddeb,
+		  "CRTDLL_rotl got 0x%08x rot %d ret 0x%08x\n",
+		  x,shift,ret);
+   return ret;
+    
+}
+/*********************************************************************
  *                  _lrotl          (CRTDLL.176)
  */
 DWORD __cdecl CRTDLL__lrotl(DWORD x,INT32 shift)
@@ -1430,6 +1453,66 @@
 }
 
 /*********************************************************************
+ *                  _splitpath           (CRTDLL.279)
+ */
+VOID __cdecl CRTDLL__splitpath(LPCSTR path, LPSTR drive, LPSTR directory, LPSTR filename, LPSTR extension )
+{
+  /* drive includes :
+     directory includes leading and trailing (forward and backward slashes)
+     filename without dot and slashes
+     extension with leading dot
+     */
+  char * drivechar,*dirchar,*namechar;
+
+  dprintf_crtdll(stddeb,"CRTDLL__splitpath got %s\n",path);
+
+  drivechar  = strchr(path,':');
+  dirchar    = strrchr(path,'/');
+  namechar   = strrchr(path,'\\');
+  dirchar = MAX(dirchar,namechar);
+  if (dirchar)
+    namechar   = strrchr(dirchar,'.');
+  else
+    namechar   = strrchr(path,'.');
+  
+  
+  if (drive) 
+    {
+      *drive = NULL;
+      if (drivechar) 
+	{
+	  strncat(drive,path,drivechar-path+1);
+	  path = drivechar+1;
+	}
+    }
+  if (directory) 
+    {
+      *directory = NULL;
+      if (dirchar)
+	{
+	  strncat(directory,path,dirchar-path+1);
+	  path = dirchar+1;
+	}
+    }
+  if (filename)
+    {
+      *filename = NULL;
+      if (namechar)
+	{
+	  strncat(filename,path,namechar-path);
+	  if (extension) 
+	    {
+	      *extension = NULL;
+	      strcat(extension,namechar);
+	    }
+	}
+    }
+
+  dprintf_crtdll(stddeb,"CRTDLL__splitpath found %s %s %s %s\n",drive,directory,filename,extension);
+  
+}
+
+/*********************************************************************
  *                  _getcwd           (CRTDLL.120)
  */
 CHAR* __cdecl CRTDLL__getcwd(LPSTR buf, INT32 size)
diff --git a/misc/lzexpand.c b/misc/lzexpand.c
index 9f37072..90c2323 100644
--- a/misc/lzexpand.c
+++ b/misc/lzexpand.c
@@ -168,7 +168,7 @@
 		_llseek32(hfSrc,0,SEEK_SET);
 		return ret?ret:hfSrc;
 	}
-	lzstates = HeapReAlloc( GetProcessHeap(), 0, lzstates,
+	lzstates = HeapReAlloc( SystemHeap, 0, lzstates,
                                 (++nroflzstates)*sizeof(struct lzstate) );
 	lzs		= lzstates+(nroflzstates-1);
 
@@ -618,7 +618,7 @@
 	memmove(lzstates+i,lzstates+i+1,
                 sizeof(struct lzstate)*(nroflzstates-i-1));
 	nroflzstates--;
-	lzstates = HeapReAlloc( GetProcessHeap(), 0, lzstates,
+	lzstates = HeapReAlloc( SystemHeap, 0, lzstates,
                                 sizeof(struct lzstate)*nroflzstates );
 }
 
diff --git a/misc/main.c b/misc/main.c
index 1404905..02984ae 100644
--- a/misc/main.c
+++ b/misc/main.c
@@ -118,7 +118,7 @@
 #define NB_OPTIONS  (sizeof(optionsTable) / sizeof(optionsTable[0]))
 
 #define USAGE \
-  "Usage:  %s [options] program_name [arguments]\n" \
+  "Usage:  %s [options] \"program_name [arguments]\"\n" \
   "\n" \
   "Options:\n" \
   "    -backingstore   Turn on backing store\n" \
@@ -613,7 +613,7 @@
  */
 BOOL32 WINAPI MessageBeep32( UINT32 i )
 {
-    XBell( display, 100 );
+    XBell( display, 0 );
     return TRUE;
 }
 
@@ -624,7 +624,7 @@
 BOOL32 WINAPI Beep( DWORD dwFreq, DWORD dwDur )
 {
     /* dwFreq and dwDur are ignored by Win95 */
-    XBell(display, 100);
+    XBell(display, 0);
     return TRUE;
 }
 
diff --git a/misc/network.c b/misc/network.c
index 4ebd1ff..12ed9fa 100644
--- a/misc/network.c
+++ b/misc/network.c
@@ -6,6 +6,7 @@
 #include <stdio.h>
 
 #include "windows.h"
+#include "winerror.h"
 #include "drive.h"
 
 #define WN_SUCCESS       			0x0000
@@ -29,8 +30,10 @@
 #define WN_ALREADY_CONNECTED		0x0034
 #define WN_DEVICE_ERROR     		0x0035
 #define WN_CONNECTION_CLOSED		0x0036
+#define WN_NO_NETWORK				ERROR_NO_NETWORK
 
-typedef LPSTR 	LPNETRESOURCE;
+
+typedef LPVOID	LPNETRESOURCE16;
 
 /**************************************************************************
  *              WNetErrorText       [USER.499]
@@ -170,8 +173,12 @@
         case DRIVE_FIXED:
             return WN_NOT_CONNECTED;
         case DRIVE_REMOTE:
-            path = DRIVE_GetDosCwd(drive);
-            if (strlen(path) + 1 > *cbRemoteName) return WN_MORE_DATA;
+            path = DRIVE_GetLabel(drive);
+            if (strlen(path) + 1 > *cbRemoteName)
+            {
+                *cbRemoteName = strlen(path) + 1;
+                return WN_MORE_DATA;
+            }
             strcpy( lpRemoteName, path );
             *cbRemoteName = strlen(lpRemoteName) + 1;
             return WN_SUCCESS;
@@ -194,7 +201,7 @@
 int WINAPI WNetDeviceMode(HWND16 hWndOwner)
 {
 	printf("EMPTY STUB !!! WNetDeviceMode(%04x)\n",hWndOwner);
-	return WN_NET_ERROR;
+	return WN_NO_NETWORK;
 }
 
 /**************************************************************************
@@ -204,7 +211,7 @@
 {
 	printf("EMPTY STUB !!! WNetBrowseDialog(%04x,%x,'%s')\n",
 		hParent,nType,szPath);
-	return WN_NET_ERROR;
+	return WN_NO_NETWORK;
 }
 
 /**************************************************************************
@@ -214,7 +221,7 @@
 {
 	printf("EMPTY STUB !!! WNetGetUser(%p, %p, %p);\n", 
 							lpLocalName, lpUserName, lpSize);
-	return WN_NET_ERROR;
+	return WN_NO_NETWORK;
 }
 
 /**************************************************************************
@@ -225,7 +232,7 @@
 {
 	printf("EMPTY STUB !!! WNetAddConnection('%s', %p, '%s');\n",
 							lpNetPath, lpPassWord, lpLocalName);
-	return WN_NET_ERROR;
+	return WN_NO_NETWORK;
 }
 
 
@@ -236,7 +243,7 @@
 {
     printf("EMPTY STUB !!! WNetCancelConnection('%s', %04X);\n",
            lpName, bForce);
-    return WN_NET_ERROR;
+    return WN_NO_NETWORK;
 }
 
 /**************************************************************************
@@ -245,7 +252,7 @@
 int WINAPI WNetGetError(LPWORD nError)
 {
 	printf("EMPTY STUB !!! WNetGetError(%p)\n",nError);
-	return WN_NET_ERROR;
+	return WN_NO_NETWORK;
 }
 
 /**************************************************************************
@@ -265,7 +272,7 @@
 {
 	printf("EMPTY STUB !!! WNetRestoreConnection(%04x,'%s')\n",
 		hwndOwner,lpszDevice);
-	return WN_NET_ERROR;
+	return WN_NO_NETWORK;
 }
 
 /**************************************************************************
@@ -275,7 +282,7 @@
 {
 	printf("EMPTY STUB !!! WNetWriteJob(%04x,%p,%p)\n",
 		hJob,lpData,lpcbData);
-	return WN_NET_ERROR;
+	return WN_NO_NETWORK;
 }
 
 /**************************************************************************
@@ -294,7 +301,7 @@
 {
 	printf("EMPTY STUB !!! WNetDisconnectDialog(%04x,%x)\n",
 		hwndOwner,iType);
-	return WN_NET_ERROR;
+	return WN_NO_NETWORK;
 }
 
 /**************************************************************************
@@ -314,7 +321,7 @@
 {
 	printf("EMPTY STUB !!! WNetViewQueueDialog(%04x,'%s')\n",
 		hwndOwner,lpszQueue);
-	return WN_NET_ERROR;
+	return WN_NO_NETWORK;
 }
 
 /**************************************************************************
@@ -325,7 +332,7 @@
 {
 	printf("EMPTY STUB !!! WNetPropertyDialog(%04x,%x,%x,'%s',%x)\n",
 		hwndParent,iButton,nPropSel,lpszName,nType);
-	return WN_NET_ERROR;
+	return WN_NO_NETWORK;
 }
 
 /**************************************************************************
@@ -335,7 +342,7 @@
 {
 	printf("EMPTY STUB !!! WNetGetDirectoryType('%s',%p)\n",
 		lpName,lpType);
-	return WN_NET_ERROR;
+	return WN_NO_NETWORK;
 }
 
 /**************************************************************************
@@ -345,7 +352,7 @@
 {
 	printf("EMPTY STUB !!! WNetDirectoryNotify(%04x,%p,%x)\n",
 		hwndOwner,lpDir,wOper);
-	return WN_NET_ERROR;
+	return WN_NO_NETWORK;
 }
 
 /**************************************************************************
@@ -356,7 +363,7 @@
 {
 	printf("EMPTY STUB !!! WNetGetPropertyText(%04x,%x,%x,'%s',%x)\n",
 		hwndParent,iButton,nPropSel,lpszName,nType);
-	return WN_NET_ERROR;
+	return WN_NO_NETWORK;
 }
 
 /**************************************************************************
@@ -367,7 +374,7 @@
 {
 	printf("EMPTY STUB !!! WNetAddConnection2('%s', %p, '%s', '%s');\n",
 					lpNetPath, lpPassWord, lpLocalName, lpUserName);
-	return WN_NET_ERROR;
+	return WN_NO_NETWORK;
 }
 
 /**************************************************************************
@@ -376,7 +383,7 @@
 UINT16 WINAPI WNetCloseEnum(HANDLE16 hEnum)
 {
 	printf("EMPTY STUB !!! WNetCloseEnum(%04x);\n", hEnum);
-	return WN_NET_ERROR;
+	return WN_NO_NETWORK;
 }
 
 /**************************************************************************
@@ -387,22 +394,35 @@
 {
 	printf("EMPTY STUB !!! WNetEnumResource(%04x, %08lX, %p, %p);\n", 
 							hEnum, cRequ, lpCount, lpBuf);
-	return WN_NET_ERROR;
+	return WN_NO_NETWORK;
 }
 
 /**************************************************************************
  *				WNetOpenEnum		[USER.???]
  */
-UINT16 WINAPI WNetOpenEnum(DWORD dwScope, DWORD dwType, 
-                           LPNETRESOURCE lpNet, HANDLE16 *lphEnum)
+UINT16 WINAPI WNetOpenEnum16(DWORD dwScope, DWORD dwType, 
+                             LPNETRESOURCE16 lpNet, HANDLE16 *lphEnum)
 {
 	printf("EMPTY STUB !!! WNetOpenEnum(%08lX, %08lX, %p, %p);\n",
                dwScope, dwType, lpNet, lphEnum);
-	return WN_NET_ERROR;
+	return WN_NO_NETWORK;
 }
 
+/**************************************************************************
+ *				WNetOpenEnumA		[MPR.92]
+ */
+UINT32 WINAPI WNetOpenEnum32A(DWORD dwScope, DWORD dwType, 
+                              LPNETRESOURCE32A lpNet, HANDLE32 *lphEnum)
+{
+	printf("EMPTY STUB !!! WNetOpenEnumA(%08lX, %08lX, %p, %p);\n",
+               dwScope, dwType, lpNet, lphEnum);
+	return WN_NO_NETWORK;
+}
 
-DWORD
+/**************************************************************************
+ *				WNetGetConnectionA	[MPR.92]
+ */
+DWORD WINAPI
 WNetGetConnection32A(LPCSTR localname,LPSTR remotename,LPDWORD buflen)
 {
 	UINT16	x;
@@ -410,3 +430,13 @@
 	*buflen = x;
 	return ret;
 }
+
+DWORD WINAPI 
+WNetGetResourceInformation32A(
+	LPNETRESOURCE32A netres,LPVOID buf,LPDWORD buflen,LPSTR systemstr
+) {
+	fprintf(stderr,"WNetGetResourceInformationA(%p,%p,%p,%p),stub!\n",
+		netres,buf,buflen,systemstr
+	);
+	return WN_NO_NETWORK;
+}
diff --git a/misc/olecli.c b/misc/olecli.c
deleted file mode 100644
index bdc2aae..0000000
--- a/misc/olecli.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- *	OLECLI library
- *
- *	Copyright 1995	Martin von Loewis
- */
-
-/*	At the moment, these are only empty stubs.
- */
-
-#include "windows.h"
-#include "ole.h"
-#include "gdi.h"
-#include "stddebug.h"
-#include "debug.h"
-
-extern LONG	OLE_current_handle;
-
-/***********************************************************************
- *           OleRegisterClientDoc
- */
-OLESTATUS WINAPI OleRegisterClientDoc(	LPCSTR classname, LPCSTR docname,
-                                        LONG reserved, LHCLIENTDOC *hRet )
-{
-    dprintf_ole(stdnimp,"OleRegisterClientDoc:%s %s\n",classname,docname);
-    *hRet=++OLE_current_handle;
-    return OLE_OK;
-}
-
-/***********************************************************************
- *           OleRenameClientDoc
- */
-OLESTATUS WINAPI OleRenameClientDoc(LHCLIENTDOC hDoc, LPCSTR newName)
-{
-    dprintf_ole(stdnimp,"OleRenameClientDoc: %ld %s\n",hDoc, newName);
-    return OLE_OK;
-}
-
-/***********************************************************************
- *           OleRevokeClientDoc
- */
-OLESTATUS WINAPI OleRevokeClientDoc(LHCLIENTDOC hServerDoc)
-{
-    dprintf_ole(stdnimp,"OleRevokeClientDoc:%ld\n",hServerDoc);
-    return OLE_OK;
-}
-
-/***********************************************************************
- *           OleIsDcMeta
- */
-BOOL16 WINAPI OleIsDcMeta(HDC16 hdc)
-{
-	dprintf_ole(stddeb,"OleIsDCMeta(%04x)\n",hdc);
-	return GDI_GetObjPtr( hdc, METAFILE_DC_MAGIC ) != 0;
-}
diff --git a/misc/olesvr.c b/misc/olesvr.c
deleted file mode 100644
index 0ebc3e2..0000000
--- a/misc/olesvr.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- *	OLESVR library
- *
- *	Copyright 1995	Martin von Loewis
- */
-
-/*	At the moment, these are only empty stubs.
- */
-
-#include "windows.h"
-#include "ole.h"
-#include "stddebug.h"
-#include "debug.h"
-
-LONG	OLE_current_handle;
-
-/***********************************************************************
- *           OleRegisterServer
- */
-OLESTATUS WINAPI OleRegisterServer( LPCSTR name, LPOLESERVER serverStruct,
-                                    LHSERVER *hRet, HINSTANCE16 hServer,
-                                    OLE_SERVER_USE use )
-{
-    dprintf_ole(stdnimp,"OleRegisterServer:%s\n",name);
-    *hRet=++OLE_current_handle;
-    /* return OLE_ERROR_MEMORY, OLE_ERROR_PROTECT_ONLY if you want it fail*/
-    return OLE_OK;
-}
-
-/***********************************************************************
- *           OleBlockServer
- */
-OLESTATUS WINAPI OleBlockServer(LHSERVER hServer)
-{
-    fprintf(stdnimp,"OleBlockServer:%ld\n",hServer);
-    return OLE_OK;
-}
-
-/***********************************************************************
- *           OleUnblockServer
- */
-OLESTATUS WINAPI OleUnblockServer(LHSERVER hServer, BOOL16 *block)
-{
-    fprintf(stdnimp,"OleUnblockServer:%ld\n",hServer);
-    /* no more blocked messages :) */
-    *block=FALSE;
-    return OLE_OK;
-}
-
-/***********************************************************************
- *           OleRegisterServerDoc
- */
-OLESTATUS WINAPI OleRegisterServerDoc( LHSERVER hServer, LPCSTR docname,
-                                       LPOLESERVERDOC document,
-                                       LHSERVERDOC *hRet)
-{
-    dprintf_ole(stdnimp,"OleRegisterServerDoc:%ld,%s\n", hServer, docname);
-    *hRet=++OLE_current_handle;
-    return OLE_OK;
-}
-
-/***********************************************************************
- *           OleRevokeServerDoc
- */
-OLESTATUS WINAPI OleRevokeServerDoc(LHSERVERDOC hServerDoc)
-{
-    dprintf_ole(stdnimp,"OleRevokeServerDoc:%ld\n",hServerDoc);
-    return OLE_OK;
-}
-
-/***********************************************************************
- *           OleRevokeServer
- */
-OLESTATUS WINAPI OleRevokeServer(LHSERVER hServer)
-{
-    dprintf_ole(stdnimp,"OleRevokeServer:%ld\n",hServer);
-    return OLE_OK;
-}
diff --git a/misc/printdrv.c b/misc/printdrv.c
index 1ad9e09..94ca696 100644
--- a/misc/printdrv.c
+++ b/misc/printdrv.c
@@ -89,3 +89,12 @@
     return 1;
 }
 
+BOOL32  WINAPI EnumPrinters32A(DWORD dwType, LPSTR lpszName,
+			       DWORD dwLevel, LPBYTE lpbPrinters,
+			       DWORD cbBuf, LPDWORD lpdwNeeded,
+			       LPDWORD lpdwReturned)
+{
+    fprintf(stderr,"EnumPrinters32A nearly empty stub\n");
+    *lpdwReturned=0;
+    return TRUE;
+}
diff --git a/misc/registry.c b/misc/registry.c
index 3cddd69..fa63c80 100644
--- a/misc/registry.c
+++ b/misc/registry.c
@@ -20,7 +20,6 @@
 #include "winerror.h"
 #include "file.h"
 #include "heap.h"
-#include "string32.h"	
 #include "stddebug.h"
 #include "debug.h"
 #include "xmalloc.h"
@@ -78,9 +77,25 @@
 /* what valuetypes do we need to convert? */
 #define UNICONVMASK	((1<<REG_SZ)|(1<<REG_MULTI_SZ)|(1<<REG_EXPAND_SZ))
 
-#define strdupA2W(x)	STRING32_DupAnsiToUni(x)
-#define strdupW(x)	STRING32_strdupW(x)
-#define strchrW(a,c)	STRING32_lstrchrW(a,c)
+extern LPWSTR __cdecl CRTDLL_wcschr(LPWSTR a,WCHAR c);
+
+static LPWSTR strdupA2W(LPCSTR src)
+{
+	LPWSTR dest=xmalloc(2*strlen(src)+2);
+	lstrcpyAtoW(dest,src);
+	return dest;
+}
+
+static LPWSTR strdupW(LPCWSTR a) {
+	LPWSTR	b;
+	int	len;
+
+	len=sizeof(WCHAR)*(lstrlen32W(a)+1);
+	b=(LPWSTR)xmalloc(len);
+	memcpy(b,a,len);
+	return b;
+}
+
 
 static struct openhandle {
 	LPKEYSTRUCT	lpkey;
@@ -1454,7 +1469,7 @@
 				idx=dir->sibling_idx;
 				continue;
 			}
-			name=STRING32_DupAnsiToUni(tail);
+			name=strdupA2W(tail);
 
 			xlpkey=_find_or_add_key(lpkey,name);
 
@@ -1464,7 +1479,7 @@
 					val=(struct _w31_valent*)&tab[dir->value_idx];
 					memcpy(tail,&txt[val->string_off],val->length);
 					tail[val->length]='\0';
-					value=STRING32_DupAnsiToUni(tail);
+					value=strdupA2W(tail);
 					_find_or_add_value(xlpkey,NULL,REG_SZ,(LPBYTE)value,lstrlen32W(value)*2+2,lastmodified);
 				}
 			}
diff --git a/misc/shell.c b/misc/shell.c
index a824ab0..66a94ce 100644
--- a/misc/shell.c
+++ b/misc/shell.c
@@ -1,6 +1,7 @@
 /*
  * 				Shell Library Functions
  */
+#include <assert.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -17,8 +18,12 @@
 #include "win.h"
 #include "graphics.h"
 #include "cursoricon.h"
+#include "interfaces.h"
+#include "sysmetrics.h"
+#include "shlobj.h"
 #include "stddebug.h"
 #include "debug.h"
+#include "debugstr.h"
 #include "winreg.h"
 
 static const char * const SHELL_People[] =
@@ -29,6 +34,7 @@
     "Peter Bajusz",
     "Georg Beyerle",
     "Ross Biro",
+    "Martin Boehme",
     "Uwe Bonnes",
     "Erik Bos",
     "Fons Botman",
@@ -36,12 +42,14 @@
     "Andrew Bulhak",
     "John Burton",
     "Niels de Carpentier",
+    "Gordon Chaffee",
     "Jimen Ching",
     "David A. Cuthbert",
     "Huw D. M. Davies",
     "Roman Dolejsi",
     "Frans van Dorsselaer",
     "Chris Faherty",
+    "Carsten Fallesen",
     "Paul Falstad",
     "David Faure",
     "Claus Fischer",
@@ -89,6 +97,7 @@
     "Andreas Mohr",
     "Philippe De Muyter",
     "Itai Nahshon",
+    "Kristian Nielsen",
     "Henrik Olsen",
     "Michael Patra",
     "Dimitrie O. Paun",
@@ -132,12 +141,14 @@
     "Eric Warnke",
     "Manfred Weichel",
     "Morten Welinder",
+    "Len White",
     "Lawson Whitney",
     "Jan Willamowius",
     "Carl Williams",
     "Karl Guenter Wuensch",
     "Eric Youngdale",
     "James Youngman",
+    "Nikita V. Youshchenko",
     "Mikolaj Zalewski",
     "John Zero",
     NULL
@@ -746,48 +757,52 @@
 
 /*************************************************************************
  *				SHELL_GetResourceTable
- *
- * FIXME: Implement GetPEResourceTable in w32sys.c and call it here.
  */
-static BYTE* SHELL_GetResourceTable(HFILE32 hFile)
+static DWORD SHELL_GetResourceTable(HFILE32 hFile,LPBYTE *retptr)
 {
-  BYTE*              pTypeInfo = NULL;
   IMAGE_DOS_HEADER	mz_header;
-  IMAGE_OS2_HEADER	ne_header;
-  int		     size;
+  char			magic[4];
+  int			size;
   
+  *retptr = NULL;
   _llseek32( hFile, 0, SEEK_SET );
-  if ((_lread32(hFile,&mz_header,sizeof(mz_header)) != sizeof(mz_header)) ||
-      (mz_header.e_magic != IMAGE_DOS_SIGNATURE)) return (BYTE*)-1;
+  if (	(_lread32(hFile,&mz_header,sizeof(mz_header)) != sizeof(mz_header)) ||
+  	(mz_header.e_magic != IMAGE_DOS_SIGNATURE)
+  )
+  	return 0;
 
   _llseek32( hFile, mz_header.e_lfanew, SEEK_SET );
-  if (_lread32( hFile, &ne_header, sizeof(ne_header) ) != sizeof(ne_header))
-      return NULL;
+  if (_lread32( hFile, magic, sizeof(magic) ) != sizeof(magic))
+	return 0;
+  _llseek32( hFile, mz_header.e_lfanew, SEEK_SET);
 
-  if (ne_header.ne_magic == IMAGE_NT_SIGNATURE) 
-     { fprintf(stdnimp,"Win32s FIXME: file %s line %i\n", __FILE__, __LINE__ );
-       return NULL; }
+  if (*(DWORD*)magic  == IMAGE_NT_SIGNATURE)
+	return IMAGE_NT_SIGNATURE;
+  if (*(WORD*)magic == IMAGE_OS2_SIGNATURE) {
+  	IMAGE_OS2_HEADER	ne_header;
+  	LPBYTE			pTypeInfo = NULL;
 
-  if (ne_header.ne_magic != IMAGE_OS2_SIGNATURE) return NULL;
+  	if (_lread32(hFile,&ne_header,sizeof(ne_header))!=sizeof(ne_header))
+		return 0;
 
-  size = ne_header.rname_tab_offset - ne_header.resource_tab_offset;
+	if (ne_header.ne_magic != IMAGE_OS2_SIGNATURE) return 0;
+	size = ne_header.rname_tab_offset - ne_header.resource_tab_offset;
+	if( size > sizeof(NE_TYPEINFO) )
+	{
+	    pTypeInfo = (BYTE*)HeapAlloc( GetProcessHeap(), 0, size);
+	    if( pTypeInfo ) {
+		_llseek32(hFile, mz_header.e_lfanew+ne_header.resource_tab_offset, SEEK_SET);
+		if( _lread32( hFile, (char*)pTypeInfo, size) != size ) { 
+		    HeapFree( GetProcessHeap(), 0, pTypeInfo); 
+		    pTypeInfo = NULL;
+		}
+	    }
+	}
+  	*retptr = pTypeInfo;
+  } else
+  	*retptr = (LPBYTE)-1;
+  return IMAGE_OS2_SIGNATURE; /* handles .ICO too */
 
-  if( size > sizeof(NE_TYPEINFO) )
-  {
-      pTypeInfo = (BYTE*)HeapAlloc( GetProcessHeap(), 0, size);
-      if( pTypeInfo ) 
-      {
-          _llseek32(hFile, mz_header.e_lfanew+ne_header.resource_tab_offset, SEEK_SET);
-          if( _lread32( hFile, (char*)pTypeInfo, size) != size )
-          { 
-	      HeapFree( GetProcessHeap(), 0, pTypeInfo); 
-	      pTypeInfo = NULL;
-          }
-      }
-  }
-  /* no resources */
-
-  return pTypeInfo;
 }
 
 /*************************************************************************
@@ -886,11 +901,13 @@
 {
   HGLOBAL16 	hRet = 0;
   HGLOBAL16*	RetPtr = NULL;
-  BYTE*  	pData;
+  LPBYTE  	pData;
   OFSTRUCT 	ofs;
+  DWORD		sig;
   HFILE32 	hFile = OpenFile32( lpszExeFileName, &ofs, OF_READ );
+  UINT16	iconDirCount = 0,iconCount = 0;
   
-  dprintf_reg(stddeb, "InternalExtractIcon(%04x, file '%s', start from %d, extract %d\n", 
+  dprintf_reg(stddeb,"InternalExtractIcon(%04x,file %s,start %d,extract %d\n", 
 		       hInstance, lpszExeFileName, nIconIndex, n);
 
   if( hFile == HFILE_ERROR32 || !n ) return 0;
@@ -898,13 +915,13 @@
   hRet = GlobalAlloc16( GMEM_FIXED | GMEM_ZEROINIT, sizeof(HICON16)*n);
   RetPtr = (HICON16*)GlobalLock16(hRet);
 
- *RetPtr = (n == 0xFFFF)? 0: 1;				/* error return values */
+  *RetPtr = (n == 0xFFFF)? 0: 1;	/* error return values */
 
-  if( (pData = SHELL_GetResourceTable(hFile)) )
+  sig = SHELL_GetResourceTable(hFile,&pData);
+
+  if(sig == IMAGE_OS2_SIGNATURE)
   {
     HICON16	 hIcon = 0;
-    UINT16       iconDirCount = 0;
-    UINT16       iconCount = 0;
     NE_TYPEINFO* pTInfo = (NE_TYPEINFO*)(pData + 2);
     NE_NAMEINFO* pIconStorage = NULL;
     NE_NAMEINFO* pIconDir = NULL;
@@ -980,30 +997,181 @@
     if( lpiID ) HeapFree( GetProcessHeap(), 0, lpiID);
     else HeapFree( GetProcessHeap(), 0, pData);
   } 
- _lclose32( hFile );
- 
-  /* return array with icon handles */
+  if( sig == IMAGE_NT_SIGNATURE)
+  {
+  	LPBYTE			peimage,idata,igdata;
+	LPIMAGE_DOS_HEADER	dheader;
+	LPIMAGE_NT_HEADERS	pe_header;
+	LPIMAGE_SECTION_HEADER	pe_sections;
+	LPIMAGE_RESOURCE_DIRECTORY	rootresdir,iconresdir,icongroupresdir;
+	LPIMAGE_RESOURCE_DATA_ENTRY	idataent,igdataent;
+	HANDLE32		fmapping;
+	int			i,j;
+	LPIMAGE_RESOURCE_DIRECTORY_ENTRY	xresent;
+	CURSORICONDIR		**cids;
+	
+	fmapping = CreateFileMapping32A(hFile,NULL,PAGE_READONLY|SEC_COMMIT,0,0,NULL);
+	if (fmapping == 0) { /* FIXME, INVALID_HANDLE_VALUE? */
+		fprintf(stderr,"InternalExtractIcon:failed to create filemap.\n");
+		_lclose32( hFile);
+		return 0;
+	}
+	peimage = MapViewOfFile(fmapping,FILE_MAP_READ,0,0,0);
+	if (!peimage) {
+		fprintf(stderr,"InternalExtractIcon:failed to mmap filemap.\n");
+		CloseHandle(fmapping);
+		_lclose32( hFile);
+		return 0;
+	}
+	dheader = (LPIMAGE_DOS_HEADER)peimage;
+	/* it is a pe header, SHELL_GetResourceTable checked that */
+	pe_header = (LPIMAGE_NT_HEADERS)(peimage+dheader->e_lfanew);
+	/* probably makes problems with short PE headers... but I haven't seen 
+	 * one yet... 
+	 */
+	pe_sections = (LPIMAGE_SECTION_HEADER)(((char*)pe_header)+sizeof(*pe_header));
+	rootresdir = NULL;
+	for (i=0;i<pe_header->FileHeader.NumberOfSections;i++) {
+		if (pe_sections[i].Characteristics & IMAGE_SCN_CNT_UNINITIALIZED_DATA)
+			continue;
+		/* FIXME: doesn't work when the resources are not in a seperate section */
+		if (pe_sections[i].VirtualAddress == pe_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress) {
+			rootresdir = (LPIMAGE_RESOURCE_DIRECTORY)((char*)peimage+pe_sections[i].PointerToRawData);
+			break;
+		}
+	}
 
+	if (!rootresdir) {
+		fprintf(stderr,"InternalExtractIcon: haven't found section for resource directory.\n");
+		UnmapViewOfFile(peimage);
+		CloseHandle(fmapping);
+		_lclose32( hFile);
+		return 0;
+	}
+	icongroupresdir = GetResDirEntryW(rootresdir,(LPWSTR)RT_GROUP_ICON,(DWORD)rootresdir);
+	if (!icongroupresdir) {
+		fprintf(stderr,"InternalExtractIcon: No Icongroupresourcedirectory!\n");
+		UnmapViewOfFile(peimage);
+		CloseHandle(fmapping);
+		_lclose32( hFile);
+		return 0;
+	}
+
+	iconDirCount = icongroupresdir->NumberOfNamedEntries+icongroupresdir->NumberOfIdEntries;
+	if( nIconIndex == (UINT16)-1 ) {
+		RetPtr[0] = iconDirCount;
+		UnmapViewOfFile(peimage);
+		CloseHandle(fmapping);
+		_lclose32( hFile);
+		return hRet;
+	}
+
+	if (nIconIndex >= iconDirCount) {
+		fprintf(stderr,"nIconIndex %d is larger than iconDirCount %d\n",
+			nIconIndex,iconDirCount
+		);
+		UnmapViewOfFile(peimage);
+		CloseHandle(fmapping);
+		_lclose32( hFile);
+		GlobalFree16(hRet);
+		return 0;
+	}
+	cids = (CURSORICONDIR**)HeapAlloc(GetProcessHeap(),0,n*sizeof(CURSORICONDIR*));
+		
+	/* caller just wanted the number of entries */
+
+	xresent = (LPIMAGE_RESOURCE_DIRECTORY_ENTRY)(icongroupresdir+1);
+	/* assure we don't get too much ... */
+	if( n > iconDirCount - nIconIndex ) n = iconDirCount - nIconIndex;
+
+	/* starting from specified index ... */
+	xresent = xresent+nIconIndex;
+
+	for (i=0;i<n;i++,xresent++) {
+		CURSORICONDIR	*cid;
+		LPIMAGE_RESOURCE_DIRECTORY	resdir;
+
+		/* go down this resource entry, name */
+		resdir = (LPIMAGE_RESOURCE_DIRECTORY)((DWORD)rootresdir+(xresent->u2.s.OffsetToDirectory));
+		/* default language (0) */
+		resdir = GetResDirEntryW(resdir,(LPWSTR)0,(DWORD)rootresdir);
+		igdataent = (LPIMAGE_RESOURCE_DATA_ENTRY)resdir;
+
+		/* lookup address in mapped image for virtual address */
+		igdata = NULL;
+		for (j=0;j<pe_header->FileHeader.NumberOfSections;j++) {
+			if (igdataent->OffsetToData < pe_sections[j].VirtualAddress)
+				continue;
+			if (igdataent->OffsetToData+igdataent->Size > pe_sections[j].VirtualAddress+pe_sections[j].SizeOfRawData)
+				continue;
+			igdata = peimage+(igdataent->OffsetToData-pe_sections[j].VirtualAddress+pe_sections[j].PointerToRawData);
+		}
+		if (!igdata) {
+			fprintf(stderr,"InternalExtractIcon: no matching real address found for icongroup!\n");
+			UnmapViewOfFile(peimage);
+			CloseHandle(fmapping);
+			_lclose32( hFile);
+			return 0;
+		}
+		/* found */
+		cid = (CURSORICONDIR*)igdata;
+		cids[i] = cid;
+		fprintf(stderr,"cursoricondir %d: idType %d, idCount %d\n",
+			i,cid->idType,cid->idCount
+		);
+		RetPtr[i] = LookupIconIdFromDirectoryEx32(igdata,TRUE,SYSMETRICS_CXICON,SYSMETRICS_CYICON,0);
+		fprintf(stderr,"-> best match is %08x\n",RetPtr[i]);
+	}
+	iconresdir=GetResDirEntryW(rootresdir,(LPWSTR)RT_ICON,(DWORD)rootresdir);
+	if (!iconresdir) {
+	    fprintf(stderr,"InternalExtractIcon: No Iconresourcedirectory!\n");
+	    UnmapViewOfFile(peimage);
+	    CloseHandle(fmapping);
+	    _lclose32( hFile);
+	    return 0;
+	}
+	for (i=0;i<n;i++) {
+	    LPIMAGE_RESOURCE_DIRECTORY	xresdir;
+
+	    xresdir = GetResDirEntryW(iconresdir,(LPWSTR)RetPtr[i],(DWORD)rootresdir);
+	    xresdir = GetResDirEntryW(xresdir,(LPWSTR)0,(DWORD)rootresdir);
+
+	    idataent = (LPIMAGE_RESOURCE_DATA_ENTRY)xresdir;
+
+	    idata = NULL;
+	    /* map virtual to address in image */
+	    for (j=0;j<pe_header->FileHeader.NumberOfSections;j++) {
+		if (idataent->OffsetToData < pe_sections[j].VirtualAddress)
+		    continue;
+		if (idataent->OffsetToData+idataent->Size > pe_sections[j].VirtualAddress+pe_sections[j].SizeOfRawData)
+		    continue;
+		idata = peimage+(idataent->OffsetToData-pe_sections[j].VirtualAddress+pe_sections[j].PointerToRawData);
+	    }
+	    if (!idata) {
+		fprintf(stderr,"InternalExtractIcon: no matching real address found for icondata!\n");
+		RetPtr[i]=0;
+		continue;
+	    }
+	    RetPtr[i] = CreateIconFromResourceEx32(idata,idataent->Size,TRUE,0x00030000,SYSMETRICS_CXICON,SYSMETRICS_CYICON,0);
+	}
+	UnmapViewOfFile(peimage);
+	CloseHandle(fmapping);
+	_lclose32( hFile);
+	return hRet;
+  }
+  _lclose32( hFile );
+  /* return array with icon handles */
   return hRet;
+
 }
 
 /*************************************************************************
  *             ExtractIcon16   (SHELL.34)
  */
 HICON16 WINAPI ExtractIcon16( HINSTANCE16 hInstance, LPCSTR lpszExeFileName,
-                              UINT16 nIconIndex )
+	UINT16 nIconIndex )
 {
-  HGLOBAL16 handle = InternalExtractIcon(hInstance,lpszExeFileName,nIconIndex, 1);
-
-  if( handle )
-    {
-      HICON16* ptr = (HICON16*)GlobalLock16(handle);
-      HICON16  hIcon = *ptr;
-
-      GlobalFree16(handle);
-      return hIcon;
-    }
-  return 0;
+    return ExtractIcon32A( hInstance, lpszExeFileName, nIconIndex );
 }
 
 
@@ -1011,10 +1179,32 @@
  *             ExtractIcon32A   (SHELL32.133)
  */
 HICON32 WINAPI ExtractIcon32A( HINSTANCE32 hInstance, LPCSTR lpszExeFileName,
-                               UINT32 nIconIndex )
+	UINT32 nIconIndex )
 {
-    /* FIXME */
-    return ExtractIcon16( hInstance, lpszExeFileName, nIconIndex );
+    HGLOBAL16 handle = InternalExtractIcon(hInstance,lpszExeFileName,nIconIndex, 1);
+
+    if( handle )
+    {
+	HICON16* ptr = (HICON16*)GlobalLock16(handle);
+	HICON16  hIcon = *ptr;
+
+	GlobalFree16(handle);
+	return hIcon;
+    }
+    return 0;
+}
+
+/*************************************************************************
+ *             ExtractIcon32W   (SHELL32.180)
+ */
+HICON32 WINAPI ExtractIcon32W( HINSTANCE32 hInstance, LPCWSTR lpszExeFileName,
+	UINT32 nIconIndex )
+{
+	LPSTR	exefn = HEAP_strdupWtoA(GetProcessHeap(),0,lpszExeFileName);
+	HICON32	ret = ExtractIcon32A(hInstance,exefn,nIconIndex);
+
+	HeapFree(GetProcessHeap(),0,exefn);
+	return ret;
 }
 
 
@@ -1024,37 +1214,37 @@
  * Return icon for given file (either from file itself or from associated
  * executable) and patch parameters if needed.
  */
-HICON16 WINAPI ExtractAssociatedIcon(HINSTANCE16 hInst,LPSTR lpIconPath,
-                                     LPWORD lpiIcon)
+HICON16 WINAPI ExtractAssociatedIcon16(HINSTANCE16 hInst,LPSTR lpIconPath,
+	LPWORD lpiIcon)
 {
     HICON16 hIcon = ExtractIcon16(hInst, lpIconPath, *lpiIcon);
 
     if( hIcon < 2 )
-      {
+    {
 
 	if( hIcon == 1 ) /* no icons found in given file */
-	  {
+	{
 	    char  tempPath[0x80];
 	    UINT16  uRet = FindExecutable16(lpIconPath,NULL,tempPath);
 
 	    if( uRet > 32 && tempPath[0] )
-	      {
+	    {
 		strcpy(lpIconPath,tempPath);
-	        hIcon = ExtractIcon16(hInst, lpIconPath, *lpiIcon);
+		hIcon = ExtractIcon16(hInst, lpIconPath, *lpiIcon);
 
 		if( hIcon > 2 ) return hIcon;
-	      }
+	    }
 	    else hIcon = 0;
-	  }
-	
-	if( hIcon == 1 ) 
-	  *lpiIcon = 2;   /* MSDOS icon - we found .exe but no icons in it */
-	else
-	  *lpiIcon = 6;   /* generic icon - found nothing */
+	}
 
-        GetModuleFileName16(hInst, lpIconPath, 0x80);
+	if( hIcon == 1 ) 
+	    *lpiIcon = 2;   /* MSDOS icon - we found .exe but no icons in it */
+	else
+	    *lpiIcon = 6;   /* generic icon - found nothing */
+
+	GetModuleFileName16(hInst, lpIconPath, 0x80);
 	hIcon = LoadIcon16( hInst, MAKEINTRESOURCE(*lpiIcon));
-      }
+    }
 
     return hIcon;
 }
@@ -1066,30 +1256,30 @@
  */
 LPSTR SHELL_FindString(LPSTR lpEnv, LPCSTR entry)
 {
-  UINT16 	l = strlen(entry); 
-  for( ; *lpEnv ; lpEnv+=strlen(lpEnv)+1 )
-     {
-       if( lstrncmpi32A(lpEnv, entry, l) ) continue;
-       
-       if( !*(lpEnv+l) )
-         return (lpEnv + l); 		/* empty entry */
-       else if ( *(lpEnv+l)== '=' )
-	 return (lpEnv + l + 1);
-     }
-  return NULL;
+    UINT16 	l = strlen(entry); 
+    for( ; *lpEnv ; lpEnv+=strlen(lpEnv)+1 )
+    {
+	if( lstrncmpi32A(lpEnv, entry, l) ) continue;
+
+	if( !*(lpEnv+l) )
+	    return (lpEnv + l); 		/* empty entry */
+	else if ( *(lpEnv+l)== '=' )
+	    return (lpEnv + l + 1);
+    }
+    return NULL;
 }
 
 SEGPTR WINAPI FindEnvironmentString(LPSTR str)
 {
- SEGPTR  spEnv = GetDOSEnvironment();
- LPSTR  lpEnv = (LPSTR)PTR_SEG_TO_LIN(spEnv);
- 
- LPSTR  lpString = (spEnv)?SHELL_FindString(lpEnv, str):NULL; 
+    SEGPTR  spEnv = GetDOSEnvironment();
+    LPSTR  lpEnv = (LPSTR)PTR_SEG_TO_LIN(spEnv);
 
- if( lpString )		/*  offset should be small enough */
-     return spEnv + (lpString - lpEnv);
+    LPSTR  lpString = (spEnv)?SHELL_FindString(lpEnv, str):NULL; 
 
- return (SEGPTR)NULL;
+    if( lpString )		/*  offset should be small enough */
+	return spEnv + (lpString - lpEnv);
+
+    return (SEGPTR)NULL;
 }
 
 /*************************************************************************
@@ -1250,6 +1440,30 @@
 }
 
 /*************************************************************************
+ *				SHAppBarMessage32	[SHELL32.207]
+ */
+UINT32 WINAPI SHAppBarMessage32(DWORD msg, PAPPBARDATA data)
+{
+    fprintf(stdnimp,"SHAppBarMessage32(0x%08lx,%p)\n", msg, data);
+#if 0
+    switch (msg) {
+        case ABM_ACTIVATE:
+        case ABM_GETAUTOHIDEBAR:
+        case ABM_GETSTATE:
+        case ABM_GETTASKBARPOS:
+        case ABM_NEW:
+        case ABM_QUERYPOS:
+        case ABM_REMOVE:
+        case ABM_SETAUTOHIDEBAR:
+        case ABM_SETPOS:
+        case ABM_WINDOWPOSCHANGED:
+	    ;
+    }
+#endif
+    return 0;
+}
+
+/*************************************************************************
  *				CommandLineToArgvW	[SHELL32.7]
  */
 LPWSTR* WINAPI CommandLineToArgvW(LPWSTR cmdline,LPDWORD numargs)
@@ -1329,9 +1543,7 @@
  */
 
 /* This is the wrong place, but where is the right one?  */
-typedef UINT32 REFCLSID32;
-typedef UINT32 REFIID32;
-typedef UINT32 HRESULT32;
+#if 0
 #define E_OUTOFMEMORY 0x8007000EL
 
 HRESULT32 WINAPI SHELL32_DllGetClassObject (REFCLSID32 clsid,
@@ -1346,3 +1558,9 @@
 
   return hres;
 }
+#endif
+
+DWORD WINAPI SHGetDesktopFolder(LPSHELLFOLDER *shellfolder) {
+	*shellfolder = NULL;
+	return 0;
+}
diff --git a/misc/shellord.c b/misc/shellord.c
new file mode 100644
index 0000000..f3a1191
--- /dev/null
+++ b/misc/shellord.c
@@ -0,0 +1,525 @@
+/*
+ * 				Shell Ordinal Functions
+ *
+ * These are completely undocumented. The meaning of the functions changes
+ * between different OS versions (NT uses Unicode strings, 95 uses ASCII
+ * strings, etc. etc.)
+ * 
+ * They are just here so that explorer.exe and iexplore.exe can be tested.
+ *
+ * Copyright 1997 Marcus Meissner
+ */
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <ctype.h>
+#include "windows.h"
+#include "file.h"
+#include "shell.h"
+#include "heap.h"
+#include "module.h"
+#include "neexe.h"
+#include "resource.h"
+#include "dlgs.h"
+#include "win.h"
+#include "graphics.h"
+#include "cursoricon.h"
+#include "interfaces.h"
+#include "shlobj.h"
+#include "stddebug.h"
+#include "debug.h"
+#include "winreg.h"
+
+/*************************************************************************
+ *				SHELL32_32	[SHELL32.32]
+ * append \ if there is none
+ */
+LPSTR WINAPI SHELL32_32(LPSTR path) {
+    int len;
+
+    len = lstrlen32A(path);
+    if (len && path[len-1]!='\\') {
+    	path[len+0]='\\';
+	path[len+1]='\0';
+	return path+len+1;
+    } else
+    	return path+len;
+}
+
+/*************************************************************************
+ *				SHELL32_34	[SHELL32.34]
+ * basename(char *fn);
+ */
+LPSTR WINAPI SHELL32_34(LPSTR fn) {
+    LPSTR basefn;
+
+    basefn = fn;
+    while (fn[0]) {
+    	if (((fn[0]=='\\') || (fn[0]==':')) && fn[1] && fn[1]!='\\')
+	    basefn = fn+1;
+	fn++;
+    }
+    return basefn;
+}
+
+/*************************************************************************
+ *	 		 SHELL32_35   			[SHELL32.35]
+ * bool getpath(char *pathname); truncates passed argument to a valid path
+ * returns if the string was modified or not.
+ * "\foo\xx\foo"-> "\foo\xx"
+ * "\"		-> "\"
+ * "a:\foo"	-> "a:\"
+ */
+DWORD WINAPI SHELL32_35(LPSTR fn) {
+	LPSTR	x,cutplace;
+
+	if (!fn[0])
+		return 0;
+	x=fn;
+	cutplace = fn;
+	while (*x) {
+		if (*x=='\\') {
+			cutplace=x++;
+			continue;
+		}
+		if (*x==':') {
+			x++;
+			if (*x=='\\')
+				cutplace=++x;
+			continue; /* already x++ed */
+		}
+		x++;
+	}
+	if (!*cutplace)
+		return 0;
+	if (cutplace==fn) {
+		if (fn[0]=='\\') {
+			if (!fn[1])
+				return 0;
+			fn[0]='\0';
+			return 1;
+		}
+	}
+	*cutplace='\0';
+	return 1;
+}
+
+/*************************************************************************
+ *				SHELL32_37	[SHELL32.37]
+ * concat_paths(char*target,const char*add);
+ * concats "target\\add" and writes them to target
+ */
+LPSTR WINAPI SHELL32_37(LPSTR target,LPSTR x1,LPSTR x2) {
+	char	buf[260];
+
+	if (!x2 || !x2[0]) {
+		lstrcpy32A(target,x1);
+		return target;
+	}
+	lstrcpy32A(buf,x1);
+	SHELL32_32(buf); /* append \ if not there */
+	lstrcat32A(buf,x2);
+	lstrcpy32A(target,buf);
+	return target;
+}
+
+/*************************************************************************
+ *				SHELL32_36	[SHELL32.36]
+ * concat_paths(char*target,const char*add);
+ * concats "target\\add" and writes them to target
+ */
+LPSTR WINAPI SHELL32_36(LPSTR x1,LPSTR x2) {
+	while (x2[0]=='\\') x2++;
+	return SHELL32_37(x1,x1,x2);
+}
+
+/*************************************************************************
+ *				SHELL32_52	[SHELL32.52]
+ * look for next arg in string. handle "quoted" strings
+ * returns pointer to argument *AFTER* the space. Or to the \0.
+ */
+LPSTR WINAPI SHELL32_52(LPSTR cmdline) {
+    BOOL32	qflag = FALSE;
+
+    while (*cmdline) {
+    	if ((*cmdline==' ') && !qflag)
+		return cmdline+1;
+	if (*cmdline=='"')
+		qflag=!qflag;
+	cmdline++;
+    }
+    return cmdline;
+}
+
+/*************************************************************************
+ *				SHELL32_45	[SHELL32.45]
+ * file_exists(char *fn);
+ */
+BOOL32 WINAPI SHELL32_45(LPSTR fn) {
+    if (GetFileAttributes32A(fn)==-1)
+    	return FALSE;
+    else
+    	return TRUE;
+}
+
+/*************************************************************************
+ *				SHELL32_175	[SHELL32.175]
+ * unknown
+ */
+void WINAPI SHELL32_175(DWORD x1,DWORD x2,DWORD x3,DWORD x4) {
+    fprintf(stdnimp,"SHELL32_175(0x%08lx,0x%08lx,0x%08lx,0x%08lx),stub\n",
+    	x1,x2,x3,x4
+    );
+}
+
+/*************************************************************************
+ *				SHELL32_181	[SHELL32.181]
+ * unknown
+ */
+void WINAPI SHELL32_181(DWORD x,DWORD y) {
+    fprintf(stderr,"SHELL32_181(0x%08lx,0x%08lx)\n",x,y);
+}
+
+/*************************************************************************
+ *				SHELL32_119	[SHELL32.119]
+ * unknown
+ */
+void WINAPI SHELL32_119(LPVOID x) {
+    fprintf(stderr,"SHELL32_119(%p),stub\n",x);
+}
+
+/*************************************************************************
+ *				SHELL32_75	[SHELL32.75]
+ * unknown
+ */
+BOOL32 WINAPI SHELL32_75(LPDWORD x,LPDWORD y) {
+    fprintf(stderr,"SHELL32_75(%p,%p),stub\n",x,y);
+    return TRUE;
+}
+
+DWORD WINAPI
+SHELL32_DllGetClassObject(REFCLSID *clsid,REFIID *iid,LPVOID *x) {
+	char	xclsid[50],xiid[50];
+
+	StringFromCLSID((LPCLSID)clsid,xclsid);
+	StringFromCLSID((LPCLSID)iid,xiid);
+	fprintf(stderr,"SHELL32_DllGetClassObject(%s,%s,%p), STUB\n",xclsid,xiid,x);
+	return 0;
+}
+
+static FARPROC32 _find_moduleproc(LPSTR dllname,HMODULE32 *xhmod,LPSTR name) {
+	HMODULE32	hmod;
+	FARPROC32	dllunload,nameproc;
+
+	if (xhmod) *xhmod = 0;
+	if (!lstrcmpi32A(SHELL32_34(dllname),"shell32.dll"))
+		return (FARPROC32)SHELL32_DllGetClassObject;
+
+	hmod = LoadLibraryEx32A(dllname,0,LOAD_WITH_ALTERED_SEARCH_PATH);
+	if (!hmod)
+		return NULL;
+	dllunload = GetProcAddress32(hmod,"DllCanUnloadNow");
+	if (!dllunload)
+		if (xhmod) *xhmod = hmod;
+	nameproc = GetProcAddress32(hmod,name);
+	if (!nameproc) {
+		FreeLibrary32(hmod);
+		return NULL;
+	}
+	/* register unloadable dll with unloadproc ... */
+	return nameproc;
+}
+
+static DWORD _get_instance(REFCLSID clsid,LPSTR dllname,
+	LPVOID	unknownouter,REFIID refiid,LPVOID inst
+) {
+	DWORD	WINAPI	(*dllgetclassob)(REFCLSID,REFIID,LPVOID);
+	DWORD		hres;
+	LPCLASSFACTORY	classfac;
+
+	dllgetclassob = (DWORD(*)(REFCLSID,REFIID,LPVOID))_find_moduleproc(dllname,NULL,"DllGetClassObject");
+	if (!dllgetclassob)
+		return 0x80070000|GetLastError();
+
+	hres = (*dllgetclassob)(clsid,(REFIID)&IID_IClassFactory,&classfac);
+	if (hres<0)
+		return hres;
+
+	classfac->lpvtbl->fnCreateInstance(classfac,unknownouter,refiid,inst);
+	classfac->lpvtbl->fnRelease(classfac);
+	return 0;
+}
+/*************************************************************************
+ *				SHELL32_102	[SHELL32.102]
+ * unknown
+ */
+LRESULT WINAPI SHELL32_102(
+	LPSTR aclsid,CLSID *clsid,LPUNKNOWN unknownouter,REFIID refiid,LPVOID inst
+) {
+	char	buffer[256],xclsid[48],xiid[48],path[260],tmodel[100];
+	HKEY	inprockey;
+	DWORD	pathlen,type,tmodellen;
+	DWORD	hres;
+	
+	StringFromCLSID(refiid,xiid);
+
+	if (clsid)
+		StringFromCLSID(clsid,xclsid);
+	else {
+		if (!aclsid)
+		    return 0x80040154;
+		strcpy(xclsid,aclsid);
+	}
+	fprintf(stderr,"SHELL32_102(%p,%s,%p,%s,%p)\n",
+		aclsid,xclsid,unknownouter,xiid,inst
+	);
+
+	sprintf(buffer,"CLSID\\%s\\InProcServer32",xclsid);
+	if (RegOpenKeyEx32A(HKEY_CLASSES_ROOT,buffer,0,0x02000000,&inprockey))
+		return _get_instance(clsid,"shell32.dll",unknownouter,refiid,inst);
+	pathlen=sizeof(path);
+	if (RegQueryValue32A(inprockey,NULL,path,&pathlen)) {
+		RegCloseKey(inprockey);
+		return _get_instance(clsid,"shell32.dll",unknownouter,refiid,inst);
+	}
+	fprintf(stderr,"	-> server dll is %s\n",path);
+	tmodellen=sizeof(tmodel);
+	type=REG_SZ;
+	if (RegQueryValueEx32A(inprockey,"ThreadingModel",NULL,&type,tmodel,&tmodellen)) {
+		RegCloseKey(inprockey);
+		return _get_instance(clsid,"shell32.dll",unknownouter,refiid,inst);
+	}
+	fprintf(stderr,"	-> threading model is %s\n",tmodel);
+	hres=_get_instance(clsid,path,unknownouter,refiid,inst);
+	if (hres<0)
+		hres=_get_instance(clsid,"shell32.dll",unknownouter,refiid,inst);
+	RegCloseKey(inprockey);
+	return hres;
+}
+
+
+/*************************************************************************
+ *			 SHELL32_183   			[SHELL32.183]
+ * Format and output errormessage.
+ */
+void __cdecl SHELL32_183(HMODULE32 hmod,HWND32 hwnd,DWORD id,DWORD x,DWORD type,LPVOID arglist) {
+	char	buf[100],buf2[100],*buf3;
+	LPVOID	args = &arglist;
+
+	if (!LoadString32A(hmod,x,buf,100))
+		strcpy(buf,"Desktop");
+	LoadString32A(hmod,id,buf2,100);
+	/* FIXME: the varargs handling doesn't. */
+	FormatMessage32A(0x500,buf2,0,0,&buf3,256,&args);
+
+	fprintf(stderr,"SHELL32_183(%08lx,%08lx,%08lx(%s),%08lx(%s),%08lx,%p),stub!\n",
+		(DWORD)hmod,(DWORD)hwnd,id,buf2,x,buf,type,arglist
+	);
+	MessageBox32A(hwnd,buf3,buf,id|0x10000);
+}
+
+
+/*************************************************************************
+ *			 SHELL32_71   			[SHELL32.71]
+ * returns internal shell values in the passed pointers
+ */
+BOOL32 WINAPI SHELL32_71(LPDWORD x,LPDWORD y) {
+
+	fprintf(stderr,"SHELL32_71(%p,%p),stub!\n",x,y);
+	return TRUE;
+}
+
+/*************************************************************************
+ *			 SHELL32_72   			[SHELL32.72]
+ * dunno. something with icons
+ */
+void WINAPI SHELL32_72(LPSTR x,DWORD y,DWORD z) {
+	fprintf(stderr,"SHELL32_72(%s,%08lx,%08lx),stub!\n",x,y,z);
+}
+
+/*************************************************************************
+ *			 SHELL32_100   			[SHELL32.100]
+ * walks through policy table, queries <app> key, <type> value, returns 
+ * queried (DWORD) value.
+ * {0x00001,Explorer,NoRun}
+ * {0x00002,Explorer,NoClose}
+ * {0x00004,Explorer,NoSaveSettings}
+ * {0x00008,Explorer,NoFileMenu}
+ * {0x00010,Explorer,NoSetFolders}
+ * {0x00020,Explorer,NoSetTaskbar}
+ * {0x00040,Explorer,NoDesktop}
+ * {0x00080,Explorer,NoFind}
+ * {0x00100,Explorer,NoDrives}
+ * {0x00200,Explorer,NoDriveAutoRun}
+ * {0x00400,Explorer,NoDriveTypeAutoRun}
+ * {0x00800,Explorer,NoNetHood}
+ * {0x01000,Explorer,NoStartBanner}
+ * {0x02000,Explorer,RestrictRun}
+ * {0x04000,Explorer,NoPrinterTabs}
+ * {0x08000,Explorer,NoDeletePrinter}
+ * {0x10000,Explorer,NoAddPrinter}
+ * {0x20000,Explorer,NoStartMenuSubFolders}
+ * {0x40000,Explorer,MyDocsOnNet}
+ * {0x80000,WinOldApp,NoRealMode}
+ */
+DWORD WINAPI SHELL32_100(DWORD pol) {
+	HKEY	xhkey;
+
+	fprintf(stderr,"SHELL32_100(%08lx),stub!\n",pol);
+	if (RegOpenKey32A(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies",&xhkey))
+		return 0;
+	/* FIXME: do nothing for now, just return 0 (== "allowed") */
+	RegCloseKey(xhkey);
+	return 0;
+	
+}
+
+DWORD WINAPI SHELL32_77(DWORD x,DWORD y,DWORD z) {
+	fprintf(stderr,"SHELL32_77(%08lx,%08lx,%08lx),stub!\n",x,y,z);
+	return 0;
+}
+
+/*************************************************************************
+ *	 		 SHELL32_79   			[SHELL32.79]
+ * create_directory_and_notify(...)
+ */
+DWORD WINAPI SHELL32_79(LPCSTR dir,LPVOID xvoid) {
+	fprintf(stderr,"mkdir %s,%p\n",dir,xvoid);
+	if (!CreateDirectory32A(dir,xvoid))
+		return FALSE;
+	/* SHChangeNotify(8,1,dir,0); */
+	return TRUE;
+}
+
+/*************************************************************************
+ *	 		 SHELL32_165   			[SHELL32.165]
+ * create_path_and_notify(...)
+ */
+DWORD WINAPI SHELL32_165(DWORD x,LPCSTR path) {
+	if (SHELL32_79(path,(LPVOID)x))
+		return 0;
+	fprintf(stderr,"SHELL32_165(%08lx,%s),stub!\n",x,path);
+	return 0;
+}
+
+/*************************************************************************
+ *	 		 SHELL32_29   			[SHELL32.29]
+ * is_rootdir(const char*path)
+ */
+BOOL32 WINAPI SHELL32_29(LPCSTR x) {
+	if (!lstrcmp32A(x+1,":\\"))		/* "X:\" */
+		return 1;
+	if (!lstrcmp32A(x,"\\"))		/* "\" */
+		return 1;
+	if (x[0]=='\\' && x[1]=='\\') {		/* UNC "\\<xx>\" */
+		int	foundbackslash = 0;
+		x=x+2;
+		while (*x) {
+			if (*x++=='\\')
+				foundbackslash++;
+		}
+		if (foundbackslash<=1)	/* max 1 \ more ... */
+			return 1;
+	}
+	return 0;
+}
+
+/*************************************************************************
+ *	 		 SHELL32_152   			[SHELL32.152]
+ * itemlist_length
+ */
+DWORD WINAPI SHELL32_152(LPITEMIDLIST iil) {
+	LPSHITEMID	si;
+	DWORD		len;
+
+	si = &(iil->mkid);
+	len = 2;
+	while (si->cb) {
+		len	+= si->cb;
+		si	 = (LPSHITEMID)(((char*)si)+si->cb);
+	}
+	return len;
+}
+
+/*************************************************************************
+ *	 		 SHELL32_196   			[SHELL32.196]
+ * void *task_alloc(DWORD len), uses SHMalloc allocator
+ */
+LPVOID WINAPI SHELL32_196(DWORD len) {
+	return (LPVOID)LocalAlloc32(len,LMEM_ZEROINIT); /* FIXME */
+}
+
+/*************************************************************************
+ *	 		 SHELL32_18   			[SHELL32.18]
+ * copy_itemidlist()
+ */
+LPITEMIDLIST WINAPI SHELL32_18(LPITEMIDLIST iil) {
+	DWORD		len;
+	LPITEMIDLIST	newiil;
+
+	len = SHELL32_152(iil);
+	newiil = (LPITEMIDLIST)SHELL32_196(len);
+	memcpy(newiil,iil,len);
+	return newiil;
+}
+
+/*************************************************************************
+ *	 		 SHELL32_25   			[SHELL32.25]
+ * merge_itemidlist()
+ */
+LPITEMIDLIST WINAPI SHELL32_25(LPITEMIDLIST iil1,LPITEMIDLIST iil2) {
+	DWORD		len1,len2;
+	LPITEMIDLIST	newiil;
+
+	len1 	= SHELL32_152(iil1)-2;
+	len2	= SHELL32_152(iil2);
+	newiil	= SHELL32_196(len1+len2);
+	memcpy(newiil,iil1,len1);
+	memcpy(((char*)newiil)+len1,iil2,len2);
+	return newiil;
+}
+
+/*************************************************************************
+ *	 		 SHELL32_16   			[SHELL32.16]
+ * find_lastitem_in_itemidlist()
+ */
+LPSHITEMID WINAPI SHELL32_16(LPITEMIDLIST iil) {
+	LPSHITEMID	lastsii,sii;
+
+	if (!iil)
+		return NULL;
+	sii = &(iil->mkid);
+	lastsii = sii;
+	while (sii->cb) {
+		lastsii = sii;
+		sii = (LPSHITEMID)(((char*)sii)+sii->cb);
+	}
+	return lastsii;
+}
+
+/*************************************************************************
+ *	 		 SHELL32_195   			[SHELL32.195]
+ * free_ptr() - frees memory using IMalloc
+ */
+DWORD WINAPI SHELL32_195(LPVOID x) {
+	return LocalFree32((HANDLE32)x);
+}
+
+/*************************************************************************
+ *	 		 SHELL32_155   			[SHELL32.155]
+ * free_check_ptr - frees memory (if not NULL) allocated by SHMalloc allocator
+ */
+DWORD WINAPI SHELL32_155(LPVOID x) {
+	if (!x)
+		return 0;
+	return SHELL32_195(x);
+}
+
+/*************************************************************************
+ *	 		 SHELL32_62   			[SHELL32.62]
+ */
+DWORD WINAPI SHELL32_62(DWORD x,DWORD y,DWORD z,DWORD a) {
+	fprintf(stderr,"SHELL32_62(%08lx,%08lx,%08lx,%08lx),stub!\n",x,y,z,a);
+	return 0xffffffff;
+}
diff --git a/misc/version.c b/misc/version.c
index 5e0d7bb..dafa443 100644
--- a/misc/version.c
+++ b/misc/version.c
@@ -117,8 +117,14 @@
     if (!pCurrentProcess) /* at startuptime probably */
         return defaultVersion;
     if (!pCurrentProcess->exe_modref)
+    {
+        /* HACK: if we have loaded a PE image into this address space,
+         * we are probably using thunks, so Win95 is our best bet
+         */
+        if (pCurrentProcess->modref_list) return WIN95;
         return WIN31; /* FIXME: hmm, look at DDB.version ? */
-    peheader = pCurrentProcess->exe_modref->pe_module->pe_header;
+    }
+    peheader = PE_HEADER(pCurrentProcess->exe_modref->module);
     if (peheader->OptionalHeader.MajorSubsystemVersion == 4)
         /* FIXME: NT4 has the same majorversion; add a check here for it. */
         return WIN95;
diff --git a/misc/w32scomb.c b/misc/w32scomb.c
new file mode 100644
index 0000000..54d1d5c
--- /dev/null
+++ b/misc/w32scomb.c
@@ -0,0 +1,22 @@
+/*
+ * W32SCOMB
+ * DLL for Win32s
+ *
+ * Copyright (c) 1997 Andreas Mohr
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "windows.h"
+#include "module.h"
+
+/***********************************************************************
+ *           Get16DLLAddress       (KERNEL32)
+ *
+ * rough guesswork, but seems to work
+ */
+FARPROC16 Get16DLLAddress(HMODULE32 handle, LPSTR name) {
+        if (!handle) handle=GetModuleHandle16("WIN32S16");
+        return (FARPROC16)WIN32_GetProcAddress16(handle, name);
+}
diff --git a/misc/w32skrnl.c b/misc/w32skrnl.c
new file mode 100644
index 0000000..af8dae5
--- /dev/null
+++ b/misc/w32skrnl.c
@@ -0,0 +1,30 @@
+/*
+ * W32SKRNL
+ * DLL for Win32s
+ *
+ * Copyright (c) 1997 Andreas Mohr
+ */
+
+#include "windows.h"
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+LPSTR WINAPI GetWin32sDirectory()
+{
+    static char *sysdir;
+    LPSTR text;
+
+    sysdir = getenv("winsysdir");
+    if (!sysdir) return NULL;
+    strcat(sysdir, "\\WIN32S");
+    text = HeapAlloc(GetProcessHeap(), 0, strlen(sysdir)+1);
+    strcpy(text, sysdir);
+    return text; 
+}
+
+/* FIXME */
+SEGPTR WINAPI _GetThunkBuff()
+{
+	return (SEGPTR)NULL;
+}
diff --git a/misc/wsprintf.c b/misc/wsprintf.c
index da2d15f..7d57209 100644
--- a/misc/wsprintf.c
+++ b/misc/wsprintf.c
@@ -149,6 +149,7 @@
     }
     if (*p == 'l') { res->flags |= WPRINTF_LONG; p++; }
     else if (*p == 'h') { res->flags |= WPRINTF_SHORT; p++; }
+    else if (*p == 'w') { res->flags |= WPRINTF_WIDE; p++; }
     switch((CHAR)*p)
     {
     case 'c':
@@ -162,10 +163,10 @@
         res->type = WPR_SIGNED;
         break;
     case 's':
-        res->type = (res->flags & WPRINTF_SHORT) ? WPR_STRING : WPR_WSTRING;
+        res->type = ((res->flags & WPRINTF_SHORT) && !(res->flags & WPRINTF_WIDE)) ? WPR_STRING : WPR_WSTRING;
         break;
     case 'S':
-        res->type = (res->flags & WPRINTF_LONG) ? WPR_WSTRING : WPR_STRING;
+        res->type = (res->flags & (WPRINTF_LONG|WPRINTF_WIDE)) ? WPR_WSTRING : WPR_STRING;
         break;
     case 'u':
         res->type = WPR_UNSIGNED;
diff --git a/miscemu/main.c b/miscemu/main.c
index 98dc871..6ac2cc8 100644
--- a/miscemu/main.c
+++ b/miscemu/main.c
@@ -114,7 +114,7 @@
 
     if (Options.debug) DEBUG_AddModuleBreakpoints();
 
-    Yield();  /* Start the first task */
+    Yield16();  /* Start the first task */
     fprintf( stderr, "WinMain: Should never happen: returned from Yield()\n" );
     return 0;
 }
diff --git a/msdos/Makefile.in b/msdos/Makefile.in
index 31be80e..398fb34 100644
--- a/msdos/Makefile.in
+++ b/msdos/Makefile.in
@@ -19,6 +19,7 @@
 	int26.c \
 	int2a.c \
 	int2f.c \
+	int3d.c \
 	int4b.c \
 	int5c.c \
 	interrupts.c \
diff --git a/msdos/int3d.c b/msdos/int3d.c
new file mode 100644
index 0000000..8e517d4
--- /dev/null
+++ b/msdos/int3d.c
@@ -0,0 +1,38 @@
+/*
+ * DOS interrupt 3d handler.
+ * Copyright 1997 Len White
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "msdos.h"
+#include "miscemu.h"
+#include "stddebug.h"
+/* #define DEBUG_INT */
+#include "debug.h"
+
+/**********************************************************************
+ *          INT_Int3dHandler
+ *
+ * Handler for int 3d (FLOATING POINT EMULATION - STANDALONE FWAIT).
+ */
+void WINAPI INT_Int3dHandler(CONTEXT *context)
+{
+    switch(AH_reg(context))
+    {
+    case 0x00:
+        break;
+
+    case 0x02:
+    case 0x03:
+    case 0x04:
+    case 0x05:
+    case 0xb:
+        AH_reg(context) = 0;
+        break;
+
+    default:
+        INT_BARF( context, 0x3d );
+    }
+}
+
diff --git a/objects/cursoricon.c b/objects/cursoricon.c
index 569b6ab..a9a7a06 100644
--- a/objects/cursoricon.c
+++ b/objects/cursoricon.c
@@ -1258,9 +1258,10 @@
  *
  * FIXME: exact parameter sizes
  */
-UINT16 WINAPI LookupIconIdFromDirectoryEx16( CURSORICONDIR *dir, BOOL16 bIcon,
+INT16 WINAPI LookupIconIdFromDirectoryEx16( LPBYTE xdir, BOOL16 bIcon,
 	     INT16 width, INT16 height, UINT16 cFlag )
 {
+    CURSORICONDIR	*dir = (CURSORICONDIR*)xdir;
     UINT16 retVal = 0;
     if( dir && !dir->idReserved && (dir->idType & 3) )
     {
@@ -1285,16 +1286,16 @@
 /**********************************************************************
  *          LookupIconIdFromDirectoryEx32       (USER32.379)
  */
-INT32 WINAPI LookupIconIdFromDirectoryEx32( CURSORICONDIR *dir, BOOL32 bIcon,
+INT32 WINAPI LookupIconIdFromDirectoryEx32( LPBYTE dir, BOOL32 bIcon,
              INT32 width, INT32 height, UINT32 cFlag )
 {
     return LookupIconIdFromDirectoryEx16( dir, bIcon, width, height, cFlag );
 }
 
 /**********************************************************************
- *          LookupIconIdFromDirectory		(USER32.378)
+ *          LookupIconIdFromDirectory		(USER.???)
  */
-INT32 WINAPI LookupIconIdFromDirectory( CURSORICONDIR *dir, BOOL32 bIcon )
+INT16 WINAPI LookupIconIdFromDirectory16( LPBYTE dir, BOOL16 bIcon )
 {
     return LookupIconIdFromDirectoryEx16( dir, bIcon, 
 	   bIcon ? SYSMETRICS_CXICON : SYSMETRICS_CXCURSOR,
@@ -1302,14 +1303,24 @@
 }
 
 /**********************************************************************
+ *          LookupIconIdFromDirectory		(USER32.378)
+ */
+INT32 WINAPI LookupIconIdFromDirectory32( LPBYTE dir, BOOL32 bIcon )
+{
+    return LookupIconIdFromDirectoryEx32( dir, bIcon, 
+	   bIcon ? SYSMETRICS_CXICON : SYSMETRICS_CXCURSOR,
+	   bIcon ? SYSMETRICS_CYICON : SYSMETRICS_CYCURSOR, bIcon ? 0 : LR_MONOCHROME );
+}
+
+/**********************************************************************
  *	    GetIconID    (USER.455)
  */
 WORD WINAPI GetIconID( HGLOBAL16 hResource, DWORD resType )
 {
-    CURSORICONDIR *lpDir = (CURSORICONDIR *)GlobalLock16(hResource);
+    LPBYTE lpDir = (LPBYTE)GlobalLock16(hResource);
 
     dprintf_cursor( stddeb, "GetIconID: hRes=%04x, entries=%i\n",
-                    hResource, lpDir ? lpDir->idCount : 0);
+                    hResource, lpDir ? ((CURSORICONDIR*)lpDir)->idCount : 0);
 
     switch(resType)
     {
diff --git a/objects/dib.c b/objects/dib.c
index 88cb033..3c1be2e 100644
--- a/objects/dib.c
+++ b/objects/dib.c
@@ -27,7 +27,7 @@
 {
     DC               *dc;
     LPCVOID           bits;
-    DWORD             lines;
+    int               lines;
     DWORD             infoWidth;
     WORD              depth;
     WORD              infoBpp;
@@ -145,7 +145,7 @@
  * Return 1 for INFOHEADER, 0 for COREHEADER, -1 for error.
  */
 static int DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, DWORD *width,
-                              DWORD *height, WORD *bpp )
+                              int *height, WORD *bpp )
 {
     if (header->biSize == sizeof(BITMAPINFOHEADER))
     {
@@ -235,50 +235,66 @@
     return colorMapping;
 }
 
+/***********************************************************************
+ *           DIB_SetImageBits_1_Line
+ *
+ * Handles a single line of 1 bit data.
+ */
+static void DIB_SetImageBits_1_Line(DWORD dstwidth, int *colors,
+				    XImage *bmpImage, int h, const BYTE *bits)
+{
+    BYTE pix;
+    DWORD i, x;
+
+    for (i = dstwidth/8, x = 0; (i > 0); i--)
+    {
+	pix = *bits++;
+	XPutPixel( bmpImage, x++, h, colors[pix >> 7] );
+	XPutPixel( bmpImage, x++, h, colors[(pix >> 6) & 1] );
+	XPutPixel( bmpImage, x++, h, colors[(pix >> 5) & 1] );
+	XPutPixel( bmpImage, x++, h, colors[(pix >> 4) & 1] );
+	XPutPixel( bmpImage, x++, h, colors[(pix >> 3) & 1] );
+	XPutPixel( bmpImage, x++, h, colors[(pix >> 2) & 1] );
+	XPutPixel( bmpImage, x++, h, colors[(pix >> 1) & 1] );
+	XPutPixel( bmpImage, x++, h, colors[pix & 1] );
+    }
+    pix = *bits;
+    switch(dstwidth & 7)
+    {
+    case 7: XPutPixel( bmpImage, x++, h, colors[pix >> 7] ); pix <<= 1;
+    case 6: XPutPixel( bmpImage, x++, h, colors[pix >> 7] ); pix <<= 1;
+    case 5: XPutPixel( bmpImage, x++, h, colors[pix >> 7] ); pix <<= 1;
+    case 4: XPutPixel( bmpImage, x++, h, colors[pix >> 7] ); pix <<= 1;
+    case 3: XPutPixel( bmpImage, x++, h, colors[pix >> 7] ); pix <<= 1;
+    case 2: XPutPixel( bmpImage, x++, h, colors[pix >> 7] ); pix <<= 1;
+    case 1: XPutPixel( bmpImage, x++, h, colors[pix >> 7] );
+    }
+}
 
 /***********************************************************************
  *           DIB_SetImageBits_1
  *
  * SetDIBits for a 1-bit deep DIB.
  */
-static void DIB_SetImageBits_1( DWORD lines, const BYTE *srcbits,
+static void DIB_SetImageBits_1( int lines, const BYTE *srcbits,
                                 DWORD srcwidth, DWORD dstwidth,
                                 int *colors, XImage *bmpImage )
 {
-    DWORD i, x;
-    BYTE pix;
-    const BYTE *bits = srcbits;
+    int h;
 
     /* 32 bit aligned */
     DWORD linebytes = ((srcwidth + 31) & ~31) / 8;
 
-    while (lines--)
-    {
-	for (i = dstwidth/8, x = 0; (i > 0); i--)
-	{
-	    pix = *bits++;
-	    XPutPixel( bmpImage, x++, lines, colors[pix >> 7] );
-	    XPutPixel( bmpImage, x++, lines, colors[(pix >> 6) & 1] );
-	    XPutPixel( bmpImage, x++, lines, colors[(pix >> 5) & 1] );
-	    XPutPixel( bmpImage, x++, lines, colors[(pix >> 4) & 1] );
-	    XPutPixel( bmpImage, x++, lines, colors[(pix >> 3) & 1] );
-	    XPutPixel( bmpImage, x++, lines, colors[(pix >> 2) & 1] );
-	    XPutPixel( bmpImage, x++, lines, colors[(pix >> 1) & 1] );
-	    XPutPixel( bmpImage, x++, lines, colors[pix & 1] );
+    if (lines > 0) {
+	for (h = lines-1; h >=0; h--) {
+	    DIB_SetImageBits_1_Line(dstwidth, colors, bmpImage, h, srcbits);
+	    srcbits += linebytes;
 	}
-	pix = *bits;
-	switch(dstwidth & 7)
-	{
-	case 7: XPutPixel( bmpImage, x++, lines, colors[pix >> 7] ); pix <<= 1;
-	case 6: XPutPixel( bmpImage, x++, lines, colors[pix >> 7] ); pix <<= 1;
-	case 5: XPutPixel( bmpImage, x++, lines, colors[pix >> 7] ); pix <<= 1;
-	case 4: XPutPixel( bmpImage, x++, lines, colors[pix >> 7] ); pix <<= 1;
-	case 3: XPutPixel( bmpImage, x++, lines, colors[pix >> 7] ); pix <<= 1;
-	case 2: XPutPixel( bmpImage, x++, lines, colors[pix >> 7] ); pix <<= 1;
-	case 1: XPutPixel( bmpImage, x++, lines, colors[pix >> 7] );
+    } else {
+	for (h = 0; h < lines; h++) {
+	    DIB_SetImageBits_1_Line(dstwidth, colors, bmpImage, h, srcbits);
+	    srcbits += linebytes;
 	}
-	srcbits += linebytes;
-	bits	 = srcbits;
     }
 }
 
@@ -288,27 +304,39 @@
  *
  * SetDIBits for a 4-bit deep DIB.
  */
-static void DIB_SetImageBits_4( DWORD lines, const BYTE *srcbits,
+static void DIB_SetImageBits_4( int lines, const BYTE *srcbits,
                                 DWORD srcwidth, DWORD dstwidth,
                                 int *colors, XImage *bmpImage )
 {
     DWORD i, x;
+    int h;
     const BYTE *bits = srcbits;
   
     /* 32 bit aligned */
     DWORD linebytes = ((srcwidth+7)&~7)/2;
 
-    while (lines--)
-    {
-	for (i = dstwidth/2, x = 0; i > 0; i--)
-	{
-	    BYTE pix = *bits++;
-	    XPutPixel( bmpImage, x++, lines, colors[pix >> 4] );
-	    XPutPixel( bmpImage, x++, lines, colors[pix & 0x0f] );
+    if (lines > 0) {
+	for (h = lines-1; h >= 0; h--) {
+	    for (i = dstwidth/2, x = 0; i > 0; i--) {
+		BYTE pix = *bits++;
+		XPutPixel( bmpImage, x++, h, colors[pix >> 4] );
+		XPutPixel( bmpImage, x++, h, colors[pix & 0x0f] );
+	    }
+	    if (dstwidth & 1) XPutPixel( bmpImage, x, h, colors[*bits >> 4] );
+	    srcbits += linebytes;
+	    bits	 = srcbits;
 	}
-        if (dstwidth & 1) XPutPixel( bmpImage, x, lines, colors[*bits >> 4] );
-        srcbits += linebytes;
-        bits	 = srcbits;
+    } else {
+	for (h = 0; h < lines; h++) {
+	    for (i = dstwidth/2, x = 0; i > 0; i--) {
+		BYTE pix = *bits++;
+		XPutPixel( bmpImage, x++, h, colors[pix >> 4] );
+		XPutPixel( bmpImage, x++, h, colors[pix & 0x0f] );
+	    }
+	    if (dstwidth & 1) XPutPixel( bmpImage, x, h, colors[*bits >> 4] );
+	    srcbits += linebytes;
+	    bits	 = srcbits;
+	}
     }
 }
 
@@ -324,7 +352,7 @@
  *
  * SetDIBits for a 4-bit deep compressed DIB.
  */
-static void DIB_SetImageBits_RLE4( DWORD lines, const BYTE *bits, DWORD width,
+static void DIB_SetImageBits_RLE4( int lines, const BYTE *bits, DWORD width,
                                 DWORD dstwidth, int *colors, XImage *bmpImage )
 {
 	int x = 0, c, length;
@@ -384,22 +412,32 @@
  *
  * SetDIBits for an 8-bit deep DIB.
  */
-static void DIB_SetImageBits_8( DWORD lines, const BYTE *srcbits,
-                                DWORD srcwidth, DWORD dstwidth,
+static void DIB_SetImageBits_8( int lines, const BYTE *srcbits,
+				DWORD srcwidth, DWORD dstwidth,
                                 int *colors, XImage *bmpImage )
 {
     DWORD x;
+    int h;
     const BYTE *bits = srcbits;
 
     /* align to 32 bit */
     DWORD linebytes = (srcwidth + 3) & ~3;
 
-    while (lines--)
-    {
-	for (x = 0; x < dstwidth; x++)
-	    XPutPixel( bmpImage, x, lines, colors[*bits++] );
-        srcbits += linebytes;
-        bits     = srcbits;
+    if (lines > 0) {
+	for (h = lines - 1; h >= 0; h--) {
+	    for (x = 0; x < dstwidth; x++, bits++) {
+		XPutPixel( bmpImage, x, h, colors[*bits] );
+	    }
+	    bits = (srcbits += linebytes);
+	}
+    } else {
+	lines = -lines;
+	for (h = 0; h < lines; h++) {
+	    for (x = 0; x < dstwidth; x++, bits++) {
+		XPutPixel( bmpImage, x, h, colors[*bits] );
+	    }
+	    bits = (srcbits += linebytes);
+	}
     }
 }
 
@@ -434,7 +472,7 @@
   RleDelta	= 2		/* Delta */
 };
   
-static void DIB_SetImageBits_RLE8( DWORD lines, const BYTE *bits, DWORD width,
+static void DIB_SetImageBits_RLE8( int lines, const BYTE *bits, DWORD width,
                                 DWORD dstwidth, int *colors, XImage *bmpImage )
 {
     int x;			/* X-positon on each line.  Increases. */
@@ -583,29 +621,123 @@
 
 
 /***********************************************************************
+ *           DIB_SetImageBits_16
+ *
+ * SetDIBits for a 16-bit deep DIB.
+ */
+static void DIB_SetImageBits_16( int lines, const BYTE *srcbits,
+                                 DWORD srcwidth, DWORD dstwidth,
+				 DC *dc, XImage *bmpImage )
+{
+    DWORD x;
+    LPWORD ptr;
+    WORD val;
+    int h;
+    BYTE r, g, b;
+  
+    /* align to 32 bit */
+    DWORD linebytes = (srcwidth * 2 + 3) & ~3;
+
+    ptr = (LPWORD) srcbits;
+    if (lines > 0) {
+	for (h = lines - 1; h >= 0; h--) {
+	    for (x = 0; x < dstwidth; x++, ptr++) {
+		val = *ptr;
+		r = (BYTE) ((val & 0x7c00) >> 7);
+		g = (BYTE) ((val & 0x03e0) >> 2);
+		b = (BYTE) ((val & 0x001f) << 3);
+		XPutPixel( bmpImage, x, h,
+			   COLOR_ToPhysical(dc, RGB(r,g,b)) );
+	    }
+	    ptr = (LPWORD) (srcbits += linebytes);
+	}
+    } else {
+	lines = -lines;
+	for (h = 0; h < lines; h++) {
+	    for (x = 0; x < dstwidth; x++, ptr++) {
+		val = *ptr;
+		r = (BYTE) ((val & 0x7c00) >> 7);
+		g = (BYTE) ((val & 0x03e0) >> 2);
+		b = (BYTE) ((val & 0x001f) << 3);
+		XPutPixel( bmpImage, x, h,
+			   COLOR_ToPhysical(dc, RGB(r,g,b)) );
+	    }
+	    ptr = (LPWORD) (srcbits += linebytes);
+	}
+    }
+}
+
+
+/***********************************************************************
  *           DIB_SetImageBits_24
  *
  * SetDIBits for a 24-bit deep DIB.
  */
-static void DIB_SetImageBits_24( DWORD lines, const BYTE *srcbits,
+static void DIB_SetImageBits_24( int lines, const BYTE *srcbits,
                                  DWORD srcwidth, DWORD dstwidth,
 				 DC *dc, XImage *bmpImage )
 {
     DWORD x;
     const BYTE *bits = srcbits;
+    int h;
   
     /* align to 32 bit */
     DWORD linebytes = (srcwidth * 3 + 3) & ~3;
 
     /* "bits" order is reversed for some reason */
 
-    while (lines--)
-    {
-	for (x = 0; x < dstwidth; x++, bits += 3)
-	    XPutPixel( bmpImage, x, lines, 
-		       COLOR_ToPhysical(dc, RGB(bits[2],bits[1],bits[0])) );
+    if (lines > 0) {
+	for (h = lines - 1; h >= 0; h--) {
+	    for (x = 0; x < dstwidth; x++, bits += 3) {
+		XPutPixel( bmpImage, x, h, 
+			   COLOR_ToPhysical(dc, RGB(bits[2],bits[1],bits[0])));
+	    }
+	    bits = (srcbits += linebytes);
+	}
+    } else {
+	lines = -lines;
+	for (h = 0; h < lines; h++) {
+	    for (x = 0; x < dstwidth; x++, bits += 3) {
+		XPutPixel( bmpImage, x, h,
+			   COLOR_ToPhysical(dc, RGB(bits[2],bits[1],bits[0])));
+	    }
+	    bits = (srcbits += linebytes);
+	}
+    }
+}
 
-        bits = (srcbits += linebytes);
+
+/***********************************************************************
+ *           DIB_SetImageBits_32
+ *
+ * SetDIBits for a 32-bit deep DIB.
+ */
+static void DIB_SetImageBits_32( int lines, const BYTE *srcbits,
+                                 DWORD srcwidth, DWORD dstwidth,
+				 DC *dc, XImage *bmpImage )
+{
+    DWORD x;
+    const BYTE *bits = srcbits;
+    int h;
+  
+    DWORD linebytes = (srcwidth * 4);
+
+    if (lines > 0) {
+	for (h = lines - 1; h >= 0; h--) {
+	    for (x = 0; x < dstwidth; x++, bits += 4) {
+		XPutPixel( bmpImage, x, h, 
+			   COLOR_ToPhysical(dc, RGB(bits[2],bits[1],bits[0])));
+	    }
+	    bits = (srcbits += linebytes);
+	}
+    } else {
+	for (h = 0; h < lines; h++) {
+	    for (x = 0; x < dstwidth; x++, bits += 4) {
+		XPutPixel( bmpImage, x, h,
+			   COLOR_ToPhysical(dc, RGB(bits[2],bits[1],bits[0])));
+	    }
+	    bits = (srcbits += linebytes);
+	}
     }
 }
 
@@ -621,6 +753,7 @@
     int *colorMapping;
     XImage *bmpImage;
     DWORD compression = 0;
+    int lines;
 
     if (descr->info->bmiHeader.biSize == sizeof(BITMAPINFOHEADER))
         compression = descr->info->bmiHeader.biCompression;
@@ -635,7 +768,9 @@
     if( descr->dc->w.flags & DC_DIRTY ) CLIPPING_UpdateGCRegion(descr->dc);
 
       /* Transfer the pixels */
-    XCREATEIMAGE(bmpImage, descr->infoWidth, descr->lines, descr->depth );
+    lines = descr->lines;
+    if (lines < 0) lines = -lines;
+    XCREATEIMAGE(bmpImage, descr->infoWidth, lines, descr->depth );
 
     switch(descr->infoBpp)
     {
@@ -657,10 +792,19 @@
 	else DIB_SetImageBits_8( descr->lines, descr->bits, descr->infoWidth,
                                  descr->width, colorMapping, bmpImage );
 	break;
+    case 15:
+    case 16:
+	DIB_SetImageBits_16( descr->lines, descr->bits, descr->infoWidth,
+			     descr->width, descr->dc, bmpImage);
+	break;
     case 24:
 	DIB_SetImageBits_24( descr->lines, descr->bits, descr->infoWidth,
                              descr->width, descr->dc, bmpImage );
 	break;
+    case 32:
+	DIB_SetImageBits_32( descr->lines, descr->bits, descr->infoWidth,
+                             descr->width, descr->dc, bmpImage);
+	break;
     default:
         fprintf( stderr, "Invalid depth %d for SetDIBits!\n", descr->infoBpp );
         break;
@@ -670,7 +814,7 @@
                descr->xSrc, descr->ySrc, descr->xDest, descr->yDest,
                descr->width, descr->height );
     XDestroyImage( bmpImage );
-    return descr->lines;
+    return lines;
 }
 
 
@@ -732,7 +876,7 @@
 {
     DIB_SETIMAGEBITS_DESCR descr;
     BITMAPOBJ * bmp;
-    DWORD height;
+    int height, tmpheight;
     INT32 result;
 
       /* Check parameters */
@@ -755,6 +899,8 @@
         GDI_HEAP_UNLOCK( hdc );
         return 0;
     }
+    tmpheight = height;
+    if (height < 0) height = -height;
     if (!lines || (startscan >= height))
     {
         GDI_HEAP_UNLOCK( hbitmap );
@@ -764,7 +910,7 @@
     if (startscan + lines > height) lines = height - startscan;
 
     descr.bits      = bits;
-    descr.lines     = lines;
+    descr.lines     = tmpheight >= 0 ? lines : -lines;
     descr.depth     = bmp->bitmap.bmBitsPixel;
     descr.info      = info;
     descr.coloruse  = coloruse;
@@ -807,7 +953,8 @@
 {
     DIB_SETIMAGEBITS_DESCR descr;
     DC * dc;
-    DWORD width, height;
+    DWORD width;
+    int height, tmpheight;
 
       /* Check parameters */
 
@@ -820,6 +967,8 @@
     if (DIB_GetBitmapInfo( &info->bmiHeader, &width,
                            &height, &descr.infoBpp ) == -1)
         return 0;
+    tmpheight = height;
+    if (height < 0) height = -height;
     if (!lines || (startscan >= height)) return 0;
     if (startscan + lines > height) lines = height - startscan;
     if (ySrc < startscan) ySrc = startscan;
@@ -834,7 +983,7 @@
 
     descr.dc        = dc;
     descr.bits      = bits;
-    descr.lines     = lines;
+    descr.lines     = tmpheight >= 0 ? lines : -lines;
     descr.infoWidth = width;
     descr.depth     = dc->w.bitsPerPixel;
     descr.info      = info;
@@ -851,7 +1000,92 @@
     return CALL_LARGE_STACK( DIB_SetImageBits, &descr );
 }
 
+/***********************************************************************
+ *           SetDIBColorTable32    (GDI32.311)
+ */
+UINT32 WINAPI SetDIBColorTable32( HDC32 hdc, UINT32 startpos, UINT32 entries,
+				  RGBQUAD *colors )
+{
+    DC * dc;
+    PALETTEENTRY * palEntry;
+    PALETTEOBJ * palette;
+    RGBQUAD *end;
 
+    dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
+    if (!dc) 
+    {
+	dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC);
+	if (!dc) return 0;
+    }
+
+    if (!(palette = (PALETTEOBJ*)GDI_GetObjPtr( dc->w.hPalette, PALETTE_MAGIC )))
+    {
+        return 0;
+    }
+
+    /* Transfer color info */
+    
+    if (dc->w.bitsPerPixel <= 8) {
+	palEntry = palette->logpalette.palPalEntry + startpos;
+	if (startpos + entries > (1 << dc->w.bitsPerPixel)) {
+	    entries = (1 << dc->w.bitsPerPixel) - startpos;
+	}
+	for (end = colors + entries; colors < end; palEntry++, colors++)
+	{
+	    palEntry->peRed   = colors->rgbRed;
+	    palEntry->peGreen = colors->rgbGreen;
+	    palEntry->peBlue  = colors->rgbBlue;
+	}
+    } else {
+	entries = 0;
+    }
+    GDI_HEAP_UNLOCK( dc->w.hPalette );
+    return entries;
+}
+
+/***********************************************************************
+ *           GetDIBColorTable32    (GDI32.169)
+ */
+UINT32 WINAPI GetDIBColorTable32( HDC32 hdc, UINT32 startpos, UINT32 entries,
+				  RGBQUAD *colors )
+{
+    DC * dc;
+    PALETTEENTRY * palEntry;
+    PALETTEOBJ * palette;
+    RGBQUAD *end;
+
+    dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
+    if (!dc) 
+    {
+	dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC);
+	if (!dc) return 0;
+    }
+
+    if (!(palette = (PALETTEOBJ*)GDI_GetObjPtr( dc->w.hPalette, PALETTE_MAGIC )))
+    {
+        return 0;
+    }
+
+    /* Transfer color info */
+    
+    if (dc->w.bitsPerPixel <= 8) {
+	palEntry = palette->logpalette.palPalEntry + startpos;
+	if (startpos + entries > (1 << dc->w.bitsPerPixel)) {
+	    entries = (1 << dc->w.bitsPerPixel) - startpos;
+	}
+	for (end = colors + entries; colors < end; palEntry++, colors++)
+	{
+	    colors->rgbRed      = palEntry->peRed;
+	    colors->rgbGreen    = palEntry->peGreen;
+	    colors->rgbBlue     = palEntry->peBlue;
+	    colors->rgbReserved = 0;
+	}
+    } else {
+	entries = 0;
+    }
+    GDI_HEAP_UNLOCK( dc->w.hPalette );
+    return entries;
+}
 
 /***********************************************************************
  *           GetDIBits16    (GDI.441)
@@ -1018,6 +1252,18 @@
 		   bbits += pad;
 		}
 		break;
+	   case 32:
+		for( y = yend - 1; (int)y >= (int)startscan; y-- )
+		{
+		   *bbits = 0;
+		   for( x = 0; x < xend; x++ ) {
+		   	unsigned long pixel=XGetPixel( bmpImage, x, y);
+			*bbits++ = (pixel >>16) & 0xff;
+			*bbits++ = (pixel >> 8) & 0xff;
+			*bbits++ =  pixel       & 0xff;
+		   }
+		}
+		break;
 	   default:
 	   	fprintf(stderr,"GetDIBits*: unsupported depth %d\n",
 			info->bmiHeader.biBitCount
@@ -1069,10 +1315,12 @@
 {
     HBITMAP32 handle;
     BOOL32 fColor;
-    DWORD width, height;
+    DWORD width;
+    int height;
     WORD bpp;
 
     if (DIB_GetBitmapInfo( header, &width, &height, &bpp ) == -1) return 0;
+    if (height < 0) height = -height;
 
     /* Check if we should create a monochrome or color bitmap. */
     /* We create a monochrome bitmap only if it has exactly 2  */
diff --git a/objects/font.c b/objects/font.c
index f65f016..124663e 100644
--- a/objects/font.c
+++ b/objects/font.c
@@ -1189,3 +1189,21 @@
     return TRUE;
 }
 
+
+/*************************************************************************
+ *             GetFontLanguageInfo   (GDI32.182)
+ */
+DWORD WINAPI GetFontLanguageInfo32(HDC32 hdc) {
+	/* return value 0 is correct for most cases anyway */
+	fprintf(stderr,"GetFontLanguageInfo:stub!\n");
+	return 0;
+}
+
+/*************************************************************************
+ *             GetFontLanguageInfo   (GDI.616)
+ */
+DWORD WINAPI GetFontLanguageInfo16(HDC16 hdc) {
+	/* return value 0 is correct for most cases anyway */
+	fprintf(stderr,"GetFontLanguageInfo:stub!\n");
+	return 0;
+}
diff --git a/objects/text.c b/objects/text.c
index 7844d8a..04f8f8b 100644
--- a/objects/text.c
+++ b/objects/text.c
@@ -636,7 +636,7 @@
 }
 
 /***********************************************************************
- *           GetTextCharset    (USER32.226) (USER.612)
+ *           GetTextCharset    (GDI32.226) (GDI.612)
  */
 INT32 WINAPI GetTextCharset32(HDC32 hdc)
 {
@@ -648,3 +648,15 @@
 {
     return GetTextCharset32(hdc);
 }
+
+/***********************************************************************
+ *           GetTextCharsetInfo    (GDI32.381)
+ */
+INT32 WINAPI GetTextCharsetInfo(HDC32 hdc,LPCHARSETINFO csi,DWORD flags)
+{
+    fprintf(stdnimp,"GetTextCharsetInfo(0x%x,%p,%08lx), stub!\n",hdc,csi,flags);
+    csi->ciCharset = DEFAULT_CHARSET;
+    csi->ciACP = GetACP();
+    /* ... fill fontstruct too ... */
+    return DEFAULT_CHARSET;
+}
diff --git a/ole/Makefile.in b/ole/Makefile.in
new file mode 100644
index 0000000..feeca6c
--- /dev/null
+++ b/ole/Makefile.in
@@ -0,0 +1,21 @@
+DEFS      = @DLLFLAGS@ -D__WINE__
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ..
+SRCDIR    = @srcdir@
+VPATH     = @srcdir@
+MODULE    = ole
+
+C_SRCS = \
+	compobj.c \
+	ole2.c \
+	ole2disp.c \
+	ole2nls.c \
+	olecli.c \
+	olesvr.c
+
+all: $(MODULE).o
+
+@MAKE_RULES@
+
+### Dependencies:
+
diff --git a/misc/compobj.c b/ole/compobj.c
similarity index 96%
rename from misc/compobj.c
rename to ole/compobj.c
index 40c9444..7287bfe 100644
--- a/misc/compobj.c
+++ b/ole/compobj.c
@@ -6,6 +6,7 @@
 
 /*	At the moment, these are only empty stubs.
  */
+#define INITGUID
 
 #include <ctype.h>
 #include <stdlib.h>
@@ -15,6 +16,8 @@
 #include "stddebug.h"
 #include "debug.h"
 #include "compobj.h"
+#include "interfaces.h"
+#include "shlobj.h"
 
 DWORD currentMalloc=0;
 
@@ -159,7 +162,7 @@
   char *s;
   int	i;
 
-  sprintf(idstr, "{%08lx-%04x-%04x-%2x%2x-",
+  sprintf(idstr, "{%08lx-%04x-%04x-%02x%02x-",
 	  id->Data1, id->Data2, id->Data3,
 	  id->Data4[0], id->Data4[1]);
   s = &idstr[25];
diff --git a/misc/ole2.c b/ole/ole2.c
similarity index 69%
rename from misc/ole2.c
rename to ole/ole2.c
index d51e275..fce01ad 100644
--- a/misc/ole2.c
+++ b/ole/ole2.c
@@ -46,3 +46,16 @@
     return S_OK;
 }
 
+/***********************************************************************
+ *           CoRegisterMessageFilter   [OLE32.38]
+ */
+HRESULT CoRegisterMessageFilter(
+    LPMESSAGEFILTER lpMessageFilter,	/* Pointer to interface */
+    LPMESSAGEFILTER *lplpMessageFilter	/* Indirect pointer to prior instance if non-NULL */
+) {
+    dprintf_ole(stdnimp,"CoRegisterMessageFilter()\n");
+    if (lplpMessageFilter) {
+	*lplpMessageFilter = NULL;
+    }
+    return S_OK;
+}
diff --git a/misc/ole2disp.c b/ole/ole2disp.c
similarity index 100%
rename from misc/ole2disp.c
rename to ole/ole2disp.c
diff --git a/misc/ole2nls.c b/ole/ole2nls.c
similarity index 100%
rename from misc/ole2nls.c
rename to ole/ole2nls.c
diff --git a/ole/olecli.c b/ole/olecli.c
new file mode 100644
index 0000000..a218213
--- /dev/null
+++ b/ole/olecli.c
@@ -0,0 +1,151 @@
+/*
+ *	OLECLI library
+ *
+ *	Copyright 1995	Martin von Loewis
+ */
+
+/*	At the moment, these are only empty stubs.
+ */
+
+#include "windows.h"
+#include "ole.h"
+#include "gdi.h"
+#include "stddebug.h"
+#include "debug.h"
+
+extern LONG	OLE_current_handle;
+
+/***********************************************************************
+ *           OleRegisterClientDoc
+ */
+OLESTATUS WINAPI OleRegisterClientDoc16(LPCSTR classname, LPCSTR docname,
+                                        LONG reserved, LHCLIENTDOC *hRet )
+{
+    fprintf(stdnimp,"OleRegisterClientDoc:%s %s\n",classname,docname);
+    *hRet=++OLE_current_handle;
+    return OLE_OK;
+}
+
+/***********************************************************************
+ *           OleRegisterClientDoc
+ */
+OLESTATUS WINAPI OleRegisterClientDoc32(LPCSTR classname, LPCSTR docname,
+                                        LONG reserved, LHCLIENTDOC *hRet )
+{
+    fprintf(stdnimp,"OleRegisterClientDoc:%s %s\n",classname,docname);
+    *hRet=++OLE_current_handle;
+    return OLE_OK;
+}
+
+/***********************************************************************
+ *           OleRenameClientDoc
+ */
+OLESTATUS WINAPI OleRenameClientDoc16(LHCLIENTDOC hDoc, LPCSTR newName)
+{
+    fprintf(stdnimp,"OleRenameClientDoc: %ld %s\n",hDoc, newName);
+    return OLE_OK;
+}
+
+/***********************************************************************
+ *           OleRenameClientDoc
+ */
+OLESTATUS WINAPI OleRenameClientDoc32(LHCLIENTDOC hDoc, LPCSTR newName)
+{
+    fprintf(stdnimp,"OleRenameClientDoc: %ld %s\n",hDoc, newName);
+    return OLE_OK;
+}
+
+/***********************************************************************
+ *           OleRevokeClientDoc
+ */
+OLESTATUS WINAPI OleRevokeClientDoc16(LHCLIENTDOC hServerDoc)
+{
+    fprintf(stdnimp,"OleRevokeClientDoc:%ld\n",hServerDoc);
+    return OLE_OK;
+}
+
+/***********************************************************************
+ *           OleRevokeClientDoc
+ */
+OLESTATUS WINAPI OleRevokeClientDoc32(LHCLIENTDOC hServerDoc)
+{
+    fprintf(stdnimp,"OleRevokeClientDoc:%ld\n",hServerDoc);
+    return OLE_OK;
+}
+
+/***********************************************************************
+ *           OleCreateLinkFromClip32
+ */
+OLESTATUS WINAPI OleCreateLinkFromClip32( 
+	LPCSTR name,LPOLECLIENT olecli,LHCLIENTDOC hclientdoc,LPCSTR xname,
+	LPOLEOBJECT *lpoleob,OLEOPT_RENDER render,OLECLIPFORMAT clipformat
+) {
+	fprintf(stdnimp,"OleCreateLinkFromClip(%s,%p,%08lx,%s,%p,%d,%ld),stub!\n",
+		name,olecli,hclientdoc,xname,lpoleob,render,clipformat
+	);
+	return OLE_OK;
+}
+
+/***********************************************************************
+ *           OleQueryLinkFromClip32
+ */
+OLESTATUS WINAPI OleQueryLinkFromClip32(LPCSTR name,OLEOPT_RENDER render,OLECLIPFORMAT clipformat) {
+	fprintf(stdnimp,"OleQueryLinkFromClip(%s,%d,%ld),stub!\n",
+		name,render,clipformat
+	);
+	return OLE_OK;
+}
+/***********************************************************************
+ *           OleQueryCreateFromClip32
+ */
+OLESTATUS WINAPI OleQueryCreateFromClip32(LPCSTR name,OLEOPT_RENDER render,OLECLIPFORMAT clipformat) {
+	fprintf(stdnimp,"OleQueryCreateFromClip(%s,%d,%ld),stub!\n",
+		name,render,clipformat
+	);
+	return OLE_OK;
+}
+
+
+/***********************************************************************
+ *           OleIsDcMeta
+ */
+BOOL16 WINAPI OleIsDcMeta(HDC16 hdc)
+{
+	dprintf_ole(stddeb,"OleIsDCMeta(%04x)\n",hdc);
+	return GDI_GetObjPtr( hdc, METAFILE_DC_MAGIC ) != 0;
+}
+
+/***********************************************************************
+ *           OleSetHostNames
+ */
+OLESTATUS WINAPI OleSetHostNames32(LPOLEOBJECT oleob,LPCSTR name1,LPCSTR name2) {
+	fprintf(stdnimp,"OleSetHostNames(%p,%s,%s),stub\n",oleob,name1,name2);
+	return OLE_OK;
+}
+
+/***********************************************************************
+ *           OleQueryType32
+ */
+OLESTATUS WINAPI OleQueryType32(LPOLEOBJECT oleob,LONG*xlong) {
+	fprintf(stdnimp,"OleQueryType(%p,%p),stub!\n",oleob,xlong);
+	if (!oleob)
+		return 0x10;
+	fprintf(stddeb,"Calling OLEOBJECT.QueryType (%p) (%p,%p)\n",
+		oleob->lpvtbl->QueryType,oleob,xlong
+	);
+	return oleob->lpvtbl->QueryType(oleob,xlong);
+}
+
+/***********************************************************************
+ *           OleCreateFromClip
+ */
+OLESTATUS WINAPI OleCreateFromClip32(
+	LPCSTR name,LPOLECLIENT olecli,LHCLIENTDOC hclientdoc,LPCSTR xname,
+	LPOLEOBJECT *lpoleob,OLEOPT_RENDER render, OLECLIPFORMAT clipformat
+) {
+	fprintf(stdnimp,"OleCreateLinkFromClip(%s,%p,%08lx,%s,%p,%d,%ld),stub!\n",
+		name,olecli,hclientdoc,xname,lpoleob,render,clipformat
+	);
+	/* clipb type, object kreieren entsprechend etc. */
+	return OLE_OK;
+}
diff --git a/ole/olesvr.c b/ole/olesvr.c
new file mode 100644
index 0000000..ad68eb1
--- /dev/null
+++ b/ole/olesvr.c
@@ -0,0 +1,134 @@
+/*
+ *	OLESVR library
+ *
+ *	Copyright 1995	Martin von Loewis
+ */
+
+/*	At the moment, these are only empty stubs.
+ */
+
+#include "windows.h"
+#include "ole.h"
+#include "stddebug.h"
+#include "debug.h"
+
+LONG	OLE_current_handle;
+
+/***********************************************************************
+ *           OleRegisterServer
+ */
+OLESTATUS WINAPI OleRegisterServer16( LPCSTR name, LPOLESERVER serverStruct,
+                                      LHSERVER *hRet, HINSTANCE16 hServer,
+                                      OLE_SERVER_USE use )
+{
+    dprintf_ole(stdnimp,"OleRegisterServer:%s\n",name);
+    *hRet=++OLE_current_handle;
+    /* return OLE_ERROR_MEMORY, OLE_ERROR_PROTECT_ONLY if you want it fail*/
+    return OLE_OK;
+}
+
+/***********************************************************************
+ *           OleBlockServer
+ */
+OLESTATUS WINAPI OleBlockServer16(LHSERVER hServer)
+{
+    fprintf(stdnimp,"OleBlockServer:%ld\n",hServer);
+    return OLE_OK;
+}
+
+/***********************************************************************
+ *           OleBlockServer
+ */
+OLESTATUS WINAPI OleBlockServer32(LHSERVER hServer)
+{
+    fprintf(stdnimp,"OleBlockServer:%ld\n",hServer);
+    return OLE_OK;
+}
+
+/***********************************************************************
+ *           OleUnblockServer
+ */
+OLESTATUS WINAPI OleUnblockServer16(LHSERVER hServer, BOOL16 *block)
+{
+    fprintf(stdnimp,"OleUnblockServer:%ld\n",hServer);
+    /* no more blocked messages :) */
+    *block=FALSE;
+    return OLE_OK;
+}
+
+/***********************************************************************
+ *           OleUnblockServer
+ */
+OLESTATUS WINAPI OleUnblockServer32(LHSERVER hServer, BOOL32 *block)
+{
+    fprintf(stdnimp,"OleUnblockServer:%ld\n",hServer);
+    /* no more blocked messages :) */
+    *block=FALSE;
+    return OLE_OK;
+}
+
+/***********************************************************************
+ *           OleRegisterServerDoc
+ */
+OLESTATUS WINAPI OleRegisterServerDoc16( LHSERVER hServer, LPCSTR docname,
+                                         LPOLESERVERDOC document,
+                                         LHSERVERDOC *hRet)
+{
+    dprintf_ole(stdnimp,"OleRegisterServerDoc:%ld,%s\n", hServer, docname);
+    *hRet=++OLE_current_handle;
+    return OLE_OK;
+}
+
+/***********************************************************************
+ *           OleRevokeServerDoc
+ */
+OLESTATUS WINAPI OleRevokeServerDoc16(LHSERVERDOC hServerDoc)
+{
+    dprintf_ole(stdnimp,"OleRevokeServerDoc:%ld\n",hServerDoc);
+    return OLE_OK;
+}
+
+/***********************************************************************
+ *           OleRevokeServerDoc
+ */
+OLESTATUS WINAPI OleRevokeServerDoc32(LHSERVERDOC hServerDoc)
+{
+    fprintf(stdnimp,"OleRevokeServerDoc:%ld\n",hServerDoc);
+    return OLE_OK;
+}
+
+/***********************************************************************
+ *           OleRevokeServer
+ */
+OLESTATUS WINAPI OleRevokeServer(LHSERVER hServer)
+{
+    dprintf_ole(stdnimp,"OleRevokeServer:%ld\n",hServer);
+    return OLE_OK;
+}
+
+OLESTATUS WINAPI OleRegisterServer32(LPCSTR svrname,LPOLESERVER olesvr,LHSERVER* hRet,HINSTANCE32 hinst,OLE_SERVER_USE osu) {
+	fprintf(stderr,"OleRegisterServer(%s,%p,%p,%08x,%d),stub!\n",
+		svrname,olesvr,hRet,hinst,osu
+	);
+    	*hRet=++OLE_current_handle;
+	return OLE_OK;
+}
+
+OLESTATUS WINAPI OleRegisterServerDoc32( LHSERVER hServer, LPCSTR docname,
+                                         LPOLESERVERDOC document,
+                                         LHSERVERDOC *hRet)
+{
+    fprintf(stdnimp,"OleRegisterServerDoc:%ld,%s\n", hServer, docname);
+    *hRet=++OLE_current_handle;
+    return OLE_OK;
+}
+
+/***********************************************************************
+ *           OleRenameServerDoc32
+ *
+ */
+OLESTATUS WINAPI OleRenameServerDoc32(LHSERVERDOC hDoc, LPCSTR newName)
+{
+    fprintf(stderr,"OleRenameServerDoc: %ld %s; stub.\n",hDoc, newName);
+    return OLE_OK;
+}
diff --git a/programs/Makefile.in b/programs/Makefile.in
index ad54a38..0118d6d 100644
--- a/programs/Makefile.in
+++ b/programs/Makefile.in
@@ -1,4 +1,4 @@
-SUBDIRS = progman winhelp
+SUBDIRS = progman winhelp winver
 
 all: $(SUBDIRS)
 
diff --git a/programs/progman/Makefile.in b/programs/progman/Makefile.in
index c1948d6..39e72fd 100644
--- a/programs/progman/Makefile.in
+++ b/programs/progman/Makefile.in
@@ -11,19 +11,6 @@
 LANGUAGES   = En Da De Fr Fi Ko Hu It Va
 LICENSELANG = En
 
-# Installation infos
-
-INSTALL         = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_DATA    = @INSTALL_DATA@
-prefix          = @prefix@
-exec_prefix     = @exec_prefix@
-bindir          = @bindir@
-libdir          = @libdir@
-sysconfdir      = @sysconfdir@
-mandir          = @mandir@/man1
-manext          = .1
-
 MOSTSRCS = \
 	dialog.c \
 	group.c \
diff --git a/programs/winhelp/Makefile.in b/programs/winhelp/Makefile.in
index 322bb0b..612a362 100644
--- a/programs/winhelp/Makefile.in
+++ b/programs/winhelp/Makefile.in
@@ -10,19 +10,6 @@
 
 LANGUAGES   = En Da De Fr Fi Ko Hu It Va
 
-# Installation infos
-
-INSTALL         = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_DATA    = @INSTALL_DATA@
-prefix          = @prefix@
-exec_prefix     = @exec_prefix@
-bindir          = @bindir@
-libdir          = @libdir@
-sysconfdir      = @sysconfdir@
-mandir          = @mandir@/man1
-manext          = .1
-
 MOSTSRCS = \
 	winhelp.c \
 	hlpfile.c \
diff --git a/programs/winver/ChangeLog b/programs/winver/ChangeLog
new file mode 100644
index 0000000..5fb731e
--- /dev/null
+++ b/programs/winver/ChangeLog
@@ -0,0 +1,5 @@
+Sun Nov 23 22:58:05 1997  Marcel Baur <mbaur@g26.ethz.ch>
+
+	* [winver.c] (new)
+         Original by Marcel Baur <mbaur@g26.ethz.ch>
+
diff --git a/programs/winver/Makefile.in b/programs/winver/Makefile.in
new file mode 100644
index 0000000..208ca04
--- /dev/null
+++ b/programs/winver/Makefile.in
@@ -0,0 +1,25 @@
+DEFS      = -DWINELIB
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../..
+SRCDIR    = @srcdir@
+VPATH     = @srcdir@
+MODULE    = none
+PROGRAMS  = winver
+ALL_LIBS  = $(WINELIB) $(X_LIBS) $(XPM_LIB) $(XLIB) $(LDLIBS)
+RCFLAGS   = -w32 -h
+
+C_SRCS = winver.c
+
+all: check_winerc $(PROGRAMS)
+
+@MAKE_RULES@
+
+winver: $(OBJS)
+	$(CC) -o winver $(OBJS) $(LDOPTIONS) $(ALL_LIBS)
+
+install: dummy
+	$(INSTALL_PROGRAM) winver $(bindir)/program
+
+dummy:
+
+### Dependencies:
diff --git a/programs/winver/winver.c b/programs/winver/winver.c
new file mode 100644
index 0000000..fde3992
--- /dev/null
+++ b/programs/winver/winver.c
@@ -0,0 +1,18 @@
+/*
+ * Windows Version Program
+ *
+ * Copyright 1997 by Marcel Baur (mbaur@g26.ethz.ch)
+ *
+*/
+
+#include "windows.h"
+#include "version.h"
+
+int PASCAL WinMain (HANDLE inst, HANDLE prev, LPSTR cmdline, int show)
+{
+   return ShellAbout((HWND)0, "WINE", WINE_RELEASE_INFO, 0);
+}
+
+/* Local Variables:     */
+/* c-files style: "GNU" */
+/* End:                 */
diff --git a/scheduler/process.c b/scheduler/process.c
index 4600e4d..e3bd71b 100644
--- a/scheduler/process.c
+++ b/scheduler/process.c
@@ -16,6 +16,7 @@
 #include "ldt.h"
 #include "thread.h"
 #include "winerror.h"
+#include "pe_image.h"
 
 PDB32 *pCurrentProcess = NULL;
 
@@ -306,7 +307,12 @@
 PDB32 *PROCESS_Create( TDB *pTask, LPCSTR cmd_line )
 {
     PDB32 *pdb = HeapAlloc( SystemHeap, HEAP_ZERO_MEMORY, sizeof(PDB32) );
+    DWORD size, commit;
+    NE_MODULE *pModule;
+
     if (!pdb) return NULL;
+    if (!(pModule = MODULE_GetPtr( pTask->hModule ))) return 0;
+
     pdb->header.type     = K32OBJ_PROCESS;
     pdb->header.refcount = 1;
     pdb->exit_code       = 0x103; /* STILL_ACTIVE */
@@ -318,8 +324,23 @@
     pdb->group           = pdb;
     pdb->priority        = 8;  /* Normal */
     pdb->heap_list       = pdb->heap;
+
     InitializeCriticalSection( &pdb->crit_section );
-    if (!(pdb->heap = HeapCreate( HEAP_GROWABLE, 0x10000, 0 ))) goto error;
+
+    /* Create the heap */
+
+    if (pModule->module32)
+    {
+	size  = PE_HEADER(pModule->module32)->OptionalHeader.SizeOfHeapReserve;
+	commit = PE_HEADER(pModule->module32)->OptionalHeader.SizeOfHeapCommit;
+    }
+    else
+    {
+	size = 0x10000;
+	commit = 0;
+    }
+    if (!(pdb->heap = HeapCreate( HEAP_GROWABLE, size, commit ))) goto error;
+
     if (!(pdb->env_db = HeapAlloc(pdb->heap, HEAP_ZERO_MEMORY, sizeof(ENVDB))))
         goto error;
     if (!(pdb->handle_table = PROCESS_AllocHandleTable( pdb ))) goto error;
@@ -379,6 +400,21 @@
 }
 
 
+/*********************************************************************
+ *	OpenProcess				[KERNEL32.543]
+ *
+ */
+HANDLE32 WINAPI OpenProcess32(DWORD fdwAccess,BOOL32 bInherit,DWORD IDProcess)
+{
+	if (IDProcess != (DWORD)pCurrentProcess) {
+		fprintf(stderr,"OpenProcess32(%ld,%d,%ld)\n",fdwAccess,bInherit,IDProcess);
+		/* XXX: might not be the correct error value */
+		SetLastError( ERROR_INVALID_HANDLE );
+		return 0;
+	}
+	return GetCurrentProcess();
+}			      
+
 /***********************************************************************
  *           GetCurrentProcessId   (KERNEL32.199)
  */
@@ -475,7 +511,13 @@
     }
     if (!*p) goto not_found;
     if (value) lstrcpyn32A( value, p + len + 1, size );
-    return strlen(p);
+    len = strlen(p);
+    /* According to the Win32 docs, if there is not enough room, return
+     * the size required to hold the string plus the terminating null
+     */
+    if (size <= len) len++;
+    return len;
+	
 not_found:
     return 0;  /* FIXME: SetLastError */
 }
@@ -527,13 +569,20 @@
     len = value ? strlen(name) + strlen(value) + 2 : 0;
     if (!res) len -= strlen(p) + 1;  /* The name already exists */
     size = pCurrentProcess->env_db->env_size + len;
+    if (len < 0)
+    {
+        LPSTR next = p + strlen(p) + 1;
+        memmove( next + len, next,
+                 pCurrentProcess->env_db->env_size - (next - env) );
+    }
     if (!(new_env = HeapReAlloc( GetProcessHeap(), 0, env, size )))
         return FALSE;
     p = new_env + (p - env);
+    if (len > 0)
+        memmove( p + len, p, pCurrentProcess->env_db->env_size - (p-new_env) );
 
     /* Set the new string */
 
-    memmove( p + len, p, pCurrentProcess->env_db->env_size - (p-new_env) );
     if (value)
     {
         strcpy( p, name );
@@ -597,8 +646,8 @@
 				LPSTR	x = HeapAlloc(heap,0,end-s+1);
 				char	buf[2];
 
-				lstrcpyn32A(x,s+1,end-s-1);
-				x[end-s-1]=0;
+				lstrcpyn32A(x,s+1,end-s);
+				x[end-s]=0;
 
 				/* put expanded variable directly into 
 				 * destination string, so we don't have
@@ -606,7 +655,7 @@
 				 */
 				ret = GetEnvironmentVariable32A(x,buf,2);
 				CHECK_FREE(ret+2);
-				ret = GetEnvironmentVariable32A(x,d,d-xdst);
+				ret = GetEnvironmentVariable32A(x,d,cursize-(d-xdst));
 				if (ret) {
 					d+=strlen(d);
 				} else {
@@ -826,6 +875,21 @@
 }
 
 /***********************************************************************
+ *           GetProcessFlags    (KERNEL32)
+ */
+DWORD WINAPI GetProcessFlags(DWORD processid)
+{
+	PDB32	*process;
+
+	if (!processid) {
+		process=pCurrentProcess;
+		/* check if valid process */
+	} else
+		process=(PDB32*)pCurrentProcess; /* decrypt too, if needed */
+	return process->flags;
+}
+
+/***********************************************************************
  *           SetProcessWorkingSetSize    (KERNEL32)
  */
 BOOL32 WINAPI SetProcessWorkingSetSize(HANDLE32 hProcess,DWORD minset,
diff --git a/tools/build.c b/tools/build.c
index 952bb9f..3f39bda 100644
--- a/tools/build.c
+++ b/tools/build.c
@@ -68,7 +68,7 @@
     "extern"        /* TYPE_EXTERN */
 };
 
-#define MAX_ORDINALS	1299
+#define MAX_ORDINALS	2048
 
   /* Callback function used for stub functions */
 #define STUB_CALLBACK \
@@ -826,7 +826,7 @@
     pModule->nrname_handle = 0;
     pModule->min_swap_area = 0;
     pModule->expected_version = 0x030a;
-    pModule->pe_module = NULL;
+    pModule->module32 = 0;
     pModule->self = 0;
     pModule->self_loading_sel = 0;
 
@@ -1097,7 +1097,8 @@
         if (odp->type == TYPE_INVALID) continue;
         nb_names++;
         /* Some assemblers do not have .word */
-        fprintf( outfile, "\t.byte %d,%d\n", LOBYTE(i), HIBYTE(i) );
+        fprintf( outfile, "\t.byte %d,%d\n",
+                 LOBYTE(i - Base), HIBYTE(i - Base) );
     }
 
     /* Output the DLL names */
diff --git a/win32/Makefile.in b/win32/Makefile.in
index fb594a8..d42613d 100644
--- a/win32/Makefile.in
+++ b/win32/Makefile.in
@@ -19,7 +19,6 @@
 	ordinals.c \
 	process.c \
 	security.c \
-	string32.c \
 	struct32.c \
 	thread.c \
 	time.c \
diff --git a/win32/advapi.c b/win32/advapi.c
index 33b4720..5404f41 100644
--- a/win32/advapi.c
+++ b/win32/advapi.c
@@ -76,6 +76,10 @@
 	);
 	return TRUE;
 }
+
+/***********************************************************************
+ *           AdjustTokenPrivileges   [ADVAPI32.10]
+ */
 BOOL32 WINAPI AdjustTokenPrivileges(HANDLE32 TokenHandle,BOOL32 DisableAllPrivileges,
 	LPVOID NewState,DWORD BufferLength,LPVOID PreviousState,
 	LPDWORD ReturnLength )
diff --git a/win32/newfns.c b/win32/newfns.c
index 7954e72..3192451 100644
--- a/win32/newfns.c
+++ b/win32/newfns.c
@@ -38,12 +38,42 @@
 }
 
 /****************************************************************************
- *		QueryPerformanceCounter (KERNEL32.415)
+ *		QueryPerformanceCounter (KERNEL32.564)
  */
 BOOL32 WINAPI QueryPerformanceCounter(LPLARGE_INTEGER counter)
 {
 	/* FIXME: don't know what are good values */
-	counter->LowPart	= 1;
+	counter->LowPart	= 0;
 	counter->HighPart	= 0;
-	return TRUE;
+	/* FIXME: Set appropriate error */
+	return FALSE;
+}
+
+
+/****************************************************************************
+ *		QueryPerformanceFrequency (KERNEL32.565)
+ */
+BOOL32 WINAPI QueryPerformanceFrequency(LPLARGE_INTEGER frequency)
+{
+	/* FIXME: don't know what are good values */
+	frequency->LowPart	= 0;
+	frequency->HighPart	= 0;
+	/* FIXME: Set appropriate error */
+	return FALSE;
+}
+
+/****************************************************************************
+ *		DeviceIoControl (KERNEL32.188)
+ */
+BOOL32 WINAPI DeviceIoControl(HANDLE32 hDevice, DWORD dwIoControlCode, 
+			      LPVOID lpvlnBuffer, DWORD cblnBuffer,
+			      LPVOID lpvOutBuffer, DWORD cbOutBuffer,
+			      LPDWORD lpcbBytesReturned,
+			      LPOVERLAPPED lpoPverlapped)
+{
+
+        fprintf(stdnimp, "DeviceIoControl Stub called!\n");
+	/* FIXME: Set appropriate error */
+	return FALSE;
+
 }
diff --git a/win32/process.c b/win32/process.c
index 5b26a52..fd7d102 100644
--- a/win32/process.c
+++ b/win32/process.c
@@ -417,7 +417,7 @@
 	DWORD creationflags,LPVOID env,LPCSTR curdir,
 	LPSTARTUPINFO32A startupinfo,LPPROCESS_INFORMATION processinfo
 ) {
-	fprintf(stderr,"CreateProcess(%s,%s,%p,%p,%d,%08lx,%p,%s,%p,%p)\n",
+	fprintf(stderr,"CreateProcessA(%s,%s,%p,%p,%d,%08lx,%p,%s,%p,%p), stub\n",
 		appname,cmdline,processattributes,threadattributes,
 		inherithandles,creationflags,env,curdir,startupinfo,processinfo
 	);
@@ -426,8 +426,22 @@
 	return FALSE;
 }
 
+BOOL32 WINAPI CreateProcess32W(
+	LPCWSTR appname,LPWSTR cmdline,LPSECURITY_ATTRIBUTES processattributes,
+        LPSECURITY_ATTRIBUTES threadattributes,BOOL32 inherithandles,
+	DWORD creationflags,LPVOID env,LPCWSTR curdir,
+	LPSTARTUPINFO32W startupinfo,LPPROCESS_INFORMATION processinfo)
+{
+    fprintf(stderr,"CreateProcessW(%p,%p,%p,%p,%d,%08lx,%p,%p,%p,%p) stub\n",
+            appname,cmdline,processattributes,threadattributes,
+            inherithandles,creationflags,env,curdir,startupinfo,processinfo );
+    /* make from lcc uses system as fallback if CreateProcess returns
+       FALSE, so return false */
+    return FALSE;
+}
+
 BOOL32 WINAPI ContinueDebugEvent(DWORD pid,DWORD tid,DWORD contstatus) {
-	fprintf(stderr,"ContinueDebugEvent(%ld,%ld,%ld), stub\n",pid,tid,contstatus);
+	fprintf(stderr,"ContinueDebugEvent(%ld,%ld,%ld) stub\n",pid,tid,contstatus);
 	return TRUE;
 }
 
diff --git a/win32/security.c b/win32/security.c
index d808cd7..6516eb7 100644
--- a/win32/security.c
+++ b/win32/security.c
@@ -3,6 +3,7 @@
 #include <string.h>
 
 #include "windows.h"
+#include "winerror.h"
 #include "ntdll.h"
 #include "stddebug.h"
 #include "debug.h"
@@ -199,3 +200,32 @@
 
     return TRUE;
 }
+
+/***********************************************************************
+ *           LookupAccountSidA   [ADVAPI32.86]
+ */
+BOOL32 WINAPI LookupAccountSid32A(LPCSTR system,PSID sid,
+				  LPCSTR account,LPDWORD accountSize,
+				  LPCSTR domain, LPDWORD domainSize,
+				  PSID_NAME_USE name_use)
+{
+	fprintf(stdnimp,"LookupAccountSid32A(%s,%p,%p,%p,%p,%p,%p),stub\n",
+		system,sid,account,accountSize,domain,domainSize,name_use);
+	SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+	return FALSE;
+}
+
+/***********************************************************************
+ *           LookupAccountSidW   [ADVAPI32.86]
+ */
+BOOL32 WINAPI LookupAccountSid32W(LPCWSTR system,PSID sid,
+				  LPCWSTR account,LPDWORD accountSize,
+				  LPCWSTR domain, LPDWORD domainSize,
+				  PSID_NAME_USE name_use)
+{
+	fprintf(stdnimp,"LookupAccountSid32W(%p,%p,%p,%p,%p,%p,%p),stub\n",
+		system,sid,account,accountSize,domain,domainSize,name_use);
+	SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+	return FALSE;
+}
+
diff --git a/win32/string32.c b/win32/string32.c
deleted file mode 100644
index 253ab60..0000000
--- a/win32/string32.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Unicode string management
- *
- * Copyright 1996 Martin von Loewis
- *
- * Conversion between Unicode and ISO-8859-1 is inherently lossy,
- * so the conversion code should be called only if it does not matter
- * 
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include "windows.h"
-#include "string32.h"
-#include "xmalloc.h"
-
-LPWSTR STRING32_DupAnsiToUni(LPCSTR src)
-{
-	LPWSTR dest=xmalloc(2*strlen(src)+2);
-	lstrcpyAtoW(dest,src);
-	return dest;
-}
-
-LPWSTR
-STRING32_lstrchrW(LPCWSTR a,WCHAR c) {
-	while(*a) {
-		if (*a==c)
-			return a;
-		a++;
-	}
-	return NULL;
-}
-
-LPWSTR
-STRING32_strdupW(LPCWSTR a) {
-	LPWSTR	b;
-	int	len;
-
-	len=sizeof(WCHAR)*(lstrlen32W(a)+1);
-	b=(LPWSTR)xmalloc(len);
-	memcpy(b,a,len);
-	return b;
-}
diff --git a/windows/dce.c b/windows/dce.c
index df98a11..2d3b506 100644
--- a/windows/dce.c
+++ b/windows/dce.c
@@ -309,7 +309,7 @@
 {
     *lprect = clientArea ? wndPtr->rectClient : wndPtr->rectWindow;
 
-    if ((wndPtr->dwStyle & WS_VISIBLE) && !(wndPtr->flags & WIN_NO_REDRAW))
+    if (wndPtr->dwStyle & WS_VISIBLE)
     {
 	INT32 xoffset = lprect->left;
 	INT32 yoffset = lprect->top;
@@ -318,8 +318,7 @@
 	{
 	    wndPtr = wndPtr->parent;
 
-	    if ((wndPtr->flags & WIN_NO_REDRAW) ||
-		(wndPtr->dwStyle & (WS_ICONIC | WS_VISIBLE)) != WS_VISIBLE )
+	    if ( (wndPtr->dwStyle & (WS_ICONIC | WS_VISIBLE)) != WS_VISIBLE )
 		goto fail;
 
 	    xoffset += wndPtr->rectClient.left;
diff --git a/windows/defwnd.c b/windows/defwnd.c
index 80a8d92..e50d00b 100644
--- a/windows/defwnd.c
+++ b/windows/defwnd.c
@@ -167,16 +167,14 @@
 	}
 
     case WM_SETREDRAW:
-        if (!wParam)
-        {
-            ValidateRect32( wndPtr->hwndSelf, NULL );
-            wndPtr->flags |= WIN_NO_REDRAW;
-        }
+        if(wParam)
+            SetWindowPos32( wndPtr->hwndSelf, NULL, 0, 0, 0, 0,
+                SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
+                SWP_NOACTIVATE | SWP_NOREDRAW );
         else
-        {
-            wndPtr->flags &= ~WIN_NO_REDRAW;
-            ShowWindow32( wndPtr->hwndSelf, SW_SHOW );
-        }
+            SetWindowPos32( wndPtr->hwndSelf, NULL, 0, 0, 0, 0,
+                SWP_HIDEWINDOW | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
+                SWP_NOACTIVATE | SWP_NOREDRAW );
         return 0;
 
     case WM_CLOSE:
diff --git a/windows/keyboard.c b/windows/keyboard.c
index 8301094..75a8438 100644
--- a/windows/keyboard.c
+++ b/windows/keyboard.c
@@ -1227,3 +1227,21 @@
 	return 1;
 }
 
+
+/***********************************************************************
+ *           RegisterHotKey			(USER32.433)
+ */
+BOOL32 WINAPI RegisterHotKey(HWND32 hwnd,INT32 id,UINT32 modifiers,UINT32 vk) {
+	fprintf(stderr,"RegisterHotKey(%08x,%d,%08x,%d), STUB!\n",
+		hwnd,id,modifiers,vk
+	);
+	return TRUE;
+}
+
+/***********************************************************************
+ *           UnregisterHotKey			(USER32.565)
+ */
+BOOL32 WINAPI UnregisterHotKey(HWND32 hwnd,INT32 id) {
+	fprintf(stderr,"UnregisterHotKey(%08x,%d),stub!\n",hwnd,id);
+	return TRUE;
+}
diff --git a/windows/message.c b/windows/message.c
index 9470710..01e0c070 100644
--- a/windows/message.c
+++ b/windows/message.c
@@ -1658,3 +1658,16 @@
         return 0;
     return (BOOL32)queue->InSendMessageHandle;
 }
+
+/***********************************************************************
+ *           BroadcastSystemMessage    (USER32.12)
+ */
+LONG WINAPI BroadcastSystemMessage(
+	DWORD dwFlags,LPDWORD recipients,UINT32 uMessage,WPARAM32 wParam,
+	LPARAM lParam
+) {
+	fprintf(stdnimp,"BroadcastSystemMessage(%08lx,%08lx,%08x,%08x,%08lx),stub!\n",
+		dwFlags,*recipients,uMessage,wParam,lParam
+	);
+	return 0;
+}
diff --git a/windows/nonclient.c b/windows/nonclient.c
index 9235836..e9b2489 100644
--- a/windows/nonclient.c
+++ b/windows/nonclient.c
@@ -161,6 +161,17 @@
 }
 
 
+/***********************************************************************
+ *           DrawCaptionTempA    (USER32.)
+ */
+DWORD
+DrawCaptionTemp32A(HWND32 hwnd,HDC32 hdc,LPRECT32 rect,HFONT32 hfont,DWORD x1,LPCSTR str,DWORD x2) {
+	fprintf(stderr,"DrawCaptionTempA(%08x,%08x,%p,%08x,%08lx,\"%s\",%08lx),tub!\n",
+		hwnd,hdc,rect,hfont,x1,str,x2
+	);
+	return 0;
+}
+
 
 /***********************************************************************
  *           AdjustWindowRect16    (USER.102)
diff --git a/windows/painting.c b/windows/painting.c
index 8699c2e..9ab73d4 100644
--- a/windows/painting.c
+++ b/windows/painting.c
@@ -121,13 +121,19 @@
      */
 
     if (wndPtr->class->style & CS_PARENTDC)
+    {
         /* Don't clip the output to the update region for CS_PARENTDC window */
+	if(hrgnUpdate > 1)
+	    DeleteObject32(hrgnUpdate);
         lps->hdc = GetDCEx16( hwnd, 0, DCX_WINDOWPAINT | DCX_USESTYLE |
                               (bIcon ? DCX_WINDOW : 0) );
+    }
     else
+    {
         lps->hdc = GetDCEx16(hwnd, hrgnUpdate, DCX_INTERSECTRGN |
                              DCX_WINDOWPAINT | DCX_USESTYLE |
                              (bIcon ? DCX_WINDOW : 0) );
+    }
 
     dprintf_win(stddeb,"hdc = %04x\n", lps->hdc);
 
@@ -283,8 +289,8 @@
 
     if (!hwnd) hwnd = GetDesktopWindow32();
     if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE;
-    if (!WIN_IsWindowDrawable( wndPtr, !(flags & RDW_FRAME) ) 
-	|| (wndPtr->flags & WIN_NO_REDRAW)) return TRUE;  /* No redraw needed */
+    if (!WIN_IsWindowDrawable( wndPtr, !(flags & RDW_FRAME) ) )
+        return TRUE;  /* No redraw needed */
 
     bIcon = (wndPtr->dwStyle & WS_MINIMIZE && wndPtr->class->hIcon);
     if (rectUpdate)
diff --git a/windows/queue.c b/windows/queue.c
index ecc6f30..6c6cf30 100644
--- a/windows/queue.c
+++ b/windows/queue.c
@@ -794,6 +794,20 @@
     return ret & MAKELONG( flags, flags );
 }
 
+/***********************************************************************
+ *           GetQueueStatus32   (USER32.283)
+ */
+DWORD WINAPI GetQueueStatus32( UINT32 flags )
+{
+    MESSAGEQUEUE *queue;
+    DWORD ret;
+
+    if (!(queue = (MESSAGEQUEUE *)GlobalLock16( GetTaskQueue(0) ))) return 0;
+    ret = MAKELONG( queue->changeBits, queue->wakeBits );
+    queue->changeBits = 0;
+    return ret & MAKELONG( flags, flags );
+}
+
 
 /***********************************************************************
  *           GetInputState16   (USER.335)
diff --git a/windows/win.c b/windows/win.c
index 11c45b8..5f6fbc0 100644
--- a/windows/win.c
+++ b/windows/win.c
@@ -239,7 +239,7 @@
 
     for ( ; pWnd ; pWnd = pWnd->next )
     {
-        if (!(pWnd->dwStyle & WS_VISIBLE) || (pWnd->flags & WIN_NO_REDRAW))
+        if (!(pWnd->dwStyle & WS_VISIBLE))
         {
             dprintf_win( stddeb, "FindWinToRepaint: skipping window %04x\n",
                          pWnd->hwndSelf );
@@ -1783,14 +1783,23 @@
 
     WND *wndPtr = WIN_FindWndPtr( hwndChild );
     WND *pWndParent = WIN_FindWndPtr( hwndNewParent );
-    if (!wndPtr || !pWndParent || !(wndPtr->dwStyle & WS_CHILD)) return 0;
 
+    if (!wndPtr || !pWndParent) return 0;
     oldParent = wndPtr->parent->hwndSelf;
 
+    if (!(wndPtr->dwStyle & WS_CHILD)) {
+	if (wndPtr->window) {
+	    /* Toplevel window needs to be reparented.  Used by Tk 8.0 */
+	    XDestroyWindow( display, wndPtr->window );
+	    wndPtr->window = None;
+	}
+	wndPtr->dwStyle |= WS_CHILD;
+    }
+
     WIN_UnlinkWindow(hwndChild);
     if (hwndNewParent) wndPtr->parent = pWndParent;
     WIN_LinkWindow(hwndChild, HWND_BOTTOM);
-    
+
     if (IsWindowVisible32(hwndChild)) UpdateWindow32(hwndChild);
     
     return oldParent;
diff --git a/windows/winhelp.c b/windows/winhelp.c
index 89be98b..3b0576f 100644
--- a/windows/winhelp.c
+++ b/windows/winhelp.c
@@ -37,7 +37,7 @@
             if(WinExec32("winhelp.exe -x",SW_SHOWNORMAL)<=32)
 		return FALSE;
 	/* FIXME: Should be directed yield, to let winhelp open the window */
-	Yield();
+	Yield16();
 	if(!WM_WINHELP) {
 		WM_WINHELP=RegisterWindowMessage32A("WM_WINHELP");
 		if(!WM_WINHELP)
diff --git a/windows/winpos.c b/windows/winpos.c
index 1f28f5f..8b51066 100644
--- a/windows/winpos.c
+++ b/windows/winpos.c
@@ -669,6 +669,15 @@
     return GetShellWindow32();
 }
 
+/*******************************************************************
+ *         SetShellWindow32    (USER32.287)
+ */
+HWND32 WINAPI SetShellWindow32(HWND32 hwndshell)
+{
+    fprintf( stdnimp, "SetShellWindow(%08x): empty stub\n",hwndshell );
+    return 0;
+}
+
 
 /*******************************************************************
  *         GetShellWindow32    (USER32.287)
@@ -2054,10 +2063,7 @@
     if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE;
 
     if(wndPtr->dwStyle & WS_VISIBLE)
-    {
-        if(!(wndPtr->flags & WIN_NO_REDRAW))
-            flags &= ~SWP_SHOWWINDOW;
-    }
+        flags &= ~SWP_SHOWWINDOW;
     else
     {
 	uFlags |= SMC_NOPARENTERASE; 
@@ -2065,9 +2071,6 @@
 	if (!(flags & SWP_SHOWWINDOW)) flags |= SWP_NOREDRAW;
     }
 
-    if(flags & SWP_SHOWWINDOW)
-       wndPtr->flags&=~WIN_NO_REDRAW;
-
 /*     Check for windows that may not be resized 
        FIXME: this should be done only for Windows 3.0 programs 
        if (flags & (SWP_SHOWWINDOW | SWP_HIDEWINDOW ) )
@@ -2313,12 +2316,25 @@
 	wndPtr->dwStyle |= WS_VISIBLE;
         if (wndPtr->window)
         {
+	    HWND32 focus, curr;
+
 	    if( uFlags & SMC_SETXPOS )
 	    {
               WINPOS_SetXWindowPos( &winpos );
               winpos.hwndInsertAfter = tempInsertAfter;
 	    }
             XMapWindow( display, wndPtr->window );
+
+	    /* If focus was set to an unmapped window, reset X focus now */
+	    focus = curr = GetFocus32();
+	    while (curr != NULL) {
+		if (curr == hwnd) {
+		    SetFocus32( NULL );
+		    SetFocus32( focus );
+		    break;
+		}
+		curr = GetParent32(curr);
+	    }
         }
         else
         {