Release 950522

Sun May 21 12:30:30 1995  Alexandre Julliard  (julliard@sunsite.unc.edu)

	* [debugger/hash.c] [debugger/info.c]
	Added support for symbolic segmented addresses. Add symbols for all
	built-in API entry points.

	* [if1632/relay.c] [include/dlls.h]
	Removed dll_table structure, as we now use the built-in module
	structures.

	* [if1632/relay.c] [loader/main.c]
	Removed winestat option, as it was no longer very meaningful.

	* [include/stackframe.h]
	New macro MAKE_SEGPTR that creates a segmented pointer to a local
	variable on the 32-bit stack.

	* [loader/module.c]
	Added support for multiple instances of an application.
	Implemented LoadModule() and FreeModule().

	* [loader/ne_image.c] [loader/task.c]
	Moved initialisation of built-in DLLs to InitTask().

	* [memory/global.c]
	Implemented discardable blocks.

	* [misc/file.c]
	Search path of current executable in OpenFile().
	Fixed bug with searching in Windows path.

	* [misc/lstr.c]
	Hard-coded translation tables for Ansi<->Oem.

	* [misc/user.c]
	Moved some global initializations to InitApp(), because they need
	a task context to be performed.

	* [objects/dc.c]
	Handle R2_BLACK and R2_WHITE specially so that they work correctly
	with palette displays.

	* [tools/build.c]
	Suppressed generation of the C file for DLL specs, because it's no
	longer needed. Output all the assembly code directly to stdout.
	Some changes to integrate Win32 support from Martin von	Loewis. 

	* [windows/msgbox.c]
	Moved message box code from misc/ to windows/.

Mon May 15 23:40:04 1995  Martin Ayotte (wine@trgcorp.mksinfo.qc.ca)

	* [misc/audio.c] [misc/mcicda.c] [misc/mcianim.c] [misc/midi.c]
	  [misc/mmaux.c] [misc/mmsystem.c]
	Modify code & use pointers conversion macros.
	Make cdaudio & wave devices work again (only using some applets).

	* [misc/profile.c]
	Change getc() to fgetc() where needed.

Mon May 15 22:10:56 1995  Martin von Loewis  <loewis@informatik.hu-berlin.de>

	* [if1632/Imakefile]
	added entries for the new files gdi32.spec, kernel32.spec,
	user32.spec, shell32.spec and winprocs32.spec.

	* [if1632/commdlg.spec][if1632/kernel.spec][if1632/shell.spec]
	  [if1632/storage.spec][if1632/system.spec][if1632/user.spec]
	ChooseFont, RESERVED5, InternalExtractIcon: Marked as stubs
	ExtractAssociatedIcon, DoEnvironmentSubst, DumpIcon:
		stub implementations provided 
	marked storage.dll,storege.sys functions as stubs

	* [include/pe_image.h]
	Added structures WIN32_builtin and  WIN32_function

	* [include/peexe.h]
	PE_Import_Directory: renamed reserved fields to 
		TimeDate, Forwarder, Thunk_List

	* [include/winerror.h]
	New file.

	* [loader/main.c]
	called RELAY32_Init

	* [loader/pe_image.c]
	xmmap: map BSS anonymous
	dump_imports: renamed to fixup_imports, do the fixup of imported
	              symbols
	PE_LoadImage: pass raw data size to xmmap

	* [loader/resource.c]
	DumpIcon: new function

	* [misc/kernel32.c]
	New file.

	* [misc/main.c]
	make stdout and stderr unbuffered

	* [misc/shell.c]
	DoEnvironmentSubst: new function

	* [objects/font.c]
	FONT_MatchFont: try oblique if there is no italic

	* [rc/Imakefile][rc/parser.l]
	yywrap: new function
	Don't link with libfl.a on Linux

	* [tools/build.c]
	Added keywords stdcall, subsystem, base
	GenerateForWin32: new function
	BuildSpecFiles: call GenerateForWin32 if subsystem is win32

Mon May 15 10:38:14 1995   Bernd Schmidt <crux@pool.informatik.rwth-aachen.de>
        
        * [controls/listbox.c] [controls/combo.c] [windows/defwnd.c]
	Minor fixes.
	
	* [misc/message.c] [misc/main.c] [rc/sysres*.rc] [include/texts.h]
	Rewrote message box handling.
	
	* [windows/dialog.c]
	Dialogs should be invisible until after WM_INITDIALOG is seent.
	Don't switch to invisible dialog items on a TAB keypress.
	
	* [windows/mdi.c]
	Send WM_NCPAINT message in MDIRestoreChild().
	
	* [windows/painting.c]
	Fixed typo (&& -> &).
	
	* [windows/message.c] [if1632/user.spec]
	Implemented PostAppMessage().
	
	* [windows/event.c]
	SetCapture(0) should act like ReleaseCapture().

Tue May  9 11:55:52 1995     Eddie C. Dost             (ecd@dressler.de)

	* [Imakefile]
	Changed CDEBUGFLAGS for systems running __ELF__ (temporarily)
	Added ASFLAGS to exported variables.

	* [debugger/readline/Imakefile]
	Moved defines for libreadline from DEFINES to EXTRA_DEFINES

	* [memory/local.c] [miscemu/int21.c]
	Added some more debugging outputs.

Mon May  8 00:55:27 MET DST 1995	  Dag Asheim (dash@ifi.uio.no)

	* [misc/message.c]
	Fixed a "FIXME" concerning norwegian translation.

Sun May  7 23:25:23 1995   Bernd Schmidt <crux@pool.informatik.rwth-aachen.de>
        
	* [*/*]
        Removed warnings in a couple of files and deleted some obsolete code.

        * [controls/listbox.c]
        Cleanup, speed improvements & lots of bug fixes.

        * [controls/combo.c]
	Mostly rewritten. This is still very buggy, but not quite as bad as 
	before.

        * [include/commdlg.h] [misc/commdlg.c]
        Removed the need for sysres.dll. Small bug fixes.
	
        * [objects/oembitmap.c] [include/bitmaps/<many>] [include/windows.h]
          [loader/library.c] [loader/main.c] [rc/sysres*.rc]
        Removed sysres.dll and replaced the remaining bitmaps/icons with
        XPM equivalents.

        * [misc/message.c] [windows/nonclient.c] [misc/main.c]
          [if1632/winprocs.spec]
        "About Wine..." now brings up a standard ShellAbout() window with
        the Wine icon and the list of contributors.
	
	* [misc/shell.c]
	Fixed ShellAbout()/AboutDialogProc() to show the right icon.

	* [windows/event.c]
	Small hack for non-alphanumeric keys: Dont't send the ascii value in
	the WM_KEYDOWN message, but some unused code instead. Should be done
	properly by sending different codes for each key. The edit control
	used to get a VK_DELETE message each time the user typed '.'.

	* [windows/class.c]
	Removed a check for CS_GLOBALCLASS in CLASS_FindClassByName().
	This used to be no problem, but breaks Resource Workshop in 950403.
	
	* [objects/dib.c]
	New diagnostic for a bug I've been encountering. If it shows up,
	please report it.

Sun May  7 23:11:18 EDT 1995  William Magro (wmagro@tc.cornell.edu)

	* [objects/color.c]
	Handle situation when 'dc' exists, but palette mapping
	does not.  (Fixes kidpix2 demo.)

Sun May  7 03:32:00 1995  Charles M. Hannum  (mycroft@mit.edu)

	* [loader/ldt.c]
	LDT_Print: Only show the number of entries that the kernel
	returned. Make this work for NetBSD.

Fri May  5 02:53:26 1995  Charles M. Hannum  (mycroft@mit.edu)

	* [debugger/dbg.y] [include/wine.h] [loader/signal.c]
	Modify cs and ds selector values for NetBSD-current.

	* [debugger/debug.l]
	$sp, $esp: Use RN_ESP_AT_SIGNAL rather than RN_ESP.

	* [debugger/regpos.h]
	Modify sigcontext format for NetBSD-current.
	SC_ESP: Use RN_ESP_AT_SIGNAL rather than RN_ESP.

	* [include/ldt.h]
	SELECTOR_TO_ENTRY: Explicitly clear the top half of the selector
	value, since only 16 bits of it may have been saved.

	* [misc/winsocket.c]
	Set structure packing with `#pragma pack' to accomodate
	other/older compilers.

Tue May  2 18:15:01 1995 Paal Beyer (beyer@idt.unit.no)
	
	* [misc/commdlg.c]
	Fixed path-names so when changing directory the listboxes
	changes too.
	
	* [debugger/dbg.y debugger/debug.l wine.ini]
	Added SymbolTableFile to wine.ini so symbols can be read
	without standing in the directory containing wine.sym.
	Added the possibility to specify full name of wine.sym from
	the debugger prompt.
diff --git a/misc/Imakefile b/misc/Imakefile
index 5c32ba5..36b097a 100644
--- a/misc/Imakefile
+++ b/misc/Imakefile
@@ -14,12 +14,12 @@
 	escape.c \
 	file.c \
 	keyboard.c \
+	kernel32.c \
 	lstr.c \
 	main.c \
 	ole2nls.c \
 	olecli.c \
 	olesvr.c \
-	message.c \
 	network.c \
 	profile.c \
 	rect.c \
diff --git a/misc/commdlg.c b/misc/commdlg.c
index 356835f..d9a0f31 100644
--- a/misc/commdlg.c
+++ b/misc/commdlg.c
@@ -11,10 +11,10 @@
 #include "win.h"
 #include "user.h"
 #include "message.h"
-#include "library.h"
 #include "commdlg.h"
 #include "dlgs.h"
 #include "selectors.h"
+#include "../rc/sysres.h"
 
 #define OPENFILEDLG2			11
 #define SAVEFILEDLG2			12
@@ -57,11 +57,11 @@
  */
 static BOOL FileDlg_Init()
 {
-  if (!hFolder) hFolder = LoadBitmap(hSysRes, MAKEINTRESOURCE(OBM_FOLDER));
-  if (!hFolder2) hFolder2 = LoadBitmap(hSysRes, MAKEINTRESOURCE(OBM_FOLDER2));
-  if (!hFloppy) hFloppy = LoadBitmap(hSysRes, MAKEINTRESOURCE(OBM_FLOPPY));
-  if (!hHDisk) hHDisk = LoadBitmap(hSysRes, MAKEINTRESOURCE(OBM_HDISK));
-  if (!hCDRom) hCDRom = LoadBitmap(hSysRes, MAKEINTRESOURCE(OBM_CDROM));
+  if (!hFolder) hFolder = LoadBitmap(0, MAKEINTRESOURCE(OBM_FOLDER));
+  if (!hFolder2) hFolder2 = LoadBitmap(0, MAKEINTRESOURCE(OBM_FOLDER2));
+  if (!hFloppy) hFloppy = LoadBitmap(0, MAKEINTRESOURCE(OBM_FLOPPY));
+  if (!hHDisk) hHDisk = LoadBitmap(0, MAKEINTRESOURCE(OBM_HDISK));
+  if (!hCDRom) hCDRom = LoadBitmap(0, MAKEINTRESOURCE(OBM_CDROM));
   if (hFolder == 0 || hFolder2 == 0 || hFloppy == 0 || 
       hHDisk == 0 || hCDRom == 0)
   fprintf(stderr, "FileDlg_Init // Error loading bitmaps !");
@@ -69,6 +69,36 @@
 }
 
 /***********************************************************************
+ *                              OpenDlg_FixDirName              [internal]
+ */
+void OpenDlg_FixDirName(LPSTR dirname)
+{
+  char temp[512];
+  char* strp1;
+  char* strp2;
+
+  strp1=dirname;
+  if( dirname[1] != ':'){
+    temp[0]=(char)((char)DOS_GetDefaultDrive()+'A');
+    temp[1]=':';
+    temp[2]='\\';
+    temp[3]= '\0';
+    strcat(temp, DOS_GetCurrentDir(DOS_GetDefaultDrive()));
+    if(dirname[0]=='.' && dirname[1]=='.') {
+      strp2 = strrchr(temp, '\\');
+      if (strp2 != NULL){
+	*strp2='\0';
+	strp1+=2;
+      }
+    }
+    strcat(temp, "\\");
+    strcat(temp, strp1);
+    strcpy(dirname, temp);
+  } 
+}
+  
+
+/***********************************************************************
  * 				OpenDlg_ScanDir			[internal]
  */
 static BOOL OpenDlg_ScanDir(HWND hWnd, LPSTR newPath)
@@ -77,13 +107,14 @@
   static LPSTR  str  = NULL;
   static SEGPTR str16 = 0;
   LPSTR strp;
-  
+
+  OpenDlg_FixDirName(newPath);
   if (str == NULL)  {
     hStr = GlobalAlloc(0,512);
     str = GlobalLock(hStr);
     str16 = WIN16_GlobalLock(hStr);
   }
-  
+
   strcpy(str,newPath);
   DlgDirList(hWnd, str, lst1, 0, 0x0000);
   strp = strrchr(str,'\\');
@@ -96,37 +127,27 @@
   } else strp++;
   strcpy(str,strp);
   SendDlgItemMessage(hWnd,edt1,WM_SETTEXT, 0, str16);
-  strcpy(str,newPath);
-  *strp = 0;
-  strcat(str,"*.*");
+  strcpy(str,"*.*");
   DlgDirList(hWnd, str, lst2, stc1, 0x8010);
   
   return TRUE;
 }
 
-
-
 /***********************************************************************
  * 				OpenDlg_GetFileType		[internal]
  */
-LPSTR OpenDlg_GetFileType(LPCSTR types, WORD index)
+static LPSTR OpenDlg_GetFileType(LPCSTR types, WORD index)
 {
 	int		n;
 	int		i = 1;
 	LPSTR 	ptr = (LPSTR) types;
 	if	(ptr == NULL) return NULL;
 	while((n = strlen(ptr)) != 0) {
-#ifdef DEBUG_OPENDLG
-		printf("OpenDlg_GetFileType // file type '%s' !\n", ptr);
-#endif
 		ptr += ++n;
-#ifdef DEBUG_OPENDLG
-		printf("OpenDlg_GetFileType // file spec '%s' !\n", ptr);
-#endif
 		if (i++ == index) return ptr;
 		n = strlen(ptr);
 		ptr += ++n;
-		}
+	}
 	return NULL;
 }
 
@@ -135,45 +156,45 @@
  */
 BOOL GetOpenFileName(LPOPENFILENAME lpofn)
 {
-	HANDLE		hDlgTmpl;
-	HANDLE		hResInfo;
-	HINSTANCE	hInst;
-	WND 		*wndPtr;
-	BOOL		bRet;
-
-        if (lpofn == NULL) return FALSE;
-	if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE) {
-		hDlgTmpl = lpofn->hInstance;
-	} else {
-		if (lpofn->Flags & OFN_ENABLETEMPLATE) {
-			hInst = lpofn->hInstance;
-			hResInfo = FindResource(hInst,
-				lpofn->lpTemplateName, RT_DIALOG);
-		} else {
-			hInst = hSysRes;
-			hResInfo = FindResource(hInst, MAKEINTRESOURCE(OPENFILEDLG2), RT_DIALOG);
-		}
-		if (hResInfo == 0) {
-			CommDlgLastError = CDERR_FINDRESFAILURE;
-			return FALSE;
-		}
-		printf("GetOpenFileName // apres FindResource hResInfo=%04X!\n", hResInfo);
-		hDlgTmpl = LoadResource(hInst, hResInfo);
-       	}
-	if (hDlgTmpl == 0) {
-		CommDlgLastError = CDERR_LOADRESFAILURE;
-		return FALSE;
-	}
-	printf("GetOpenFileName // apres LoadResource hDlgTmpl=%04X!\n", hDlgTmpl);
-        wndPtr = WIN_FindWndPtr(lpofn->hwndOwner);
-	bRet = DialogBoxIndirectParam(wndPtr->hInstance, hDlgTmpl,
-                                      lpofn->hwndOwner,
-                                      GetWndProcEntry16("FileOpenDlgProc"),
-                                      (DWORD)lpofn); 
-
-	printf("GetOpenFileName // return lpstrFile='%s' !\n", 
-	       (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrFile));
-	return bRet;
+  HANDLE    hDlgTmpl;
+  HANDLE    hResInfo;
+  HINSTANCE hInst;
+  BOOL 	    bRet;
+  LPCSTR    dlgTemplate;
+  
+  if (lpofn == NULL) return FALSE;
+  if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE) {
+    dlgTemplate = GlobalLock(lpofn->hInstance);
+    if (!dlgTemplate) {
+      CommDlgLastError = CDERR_LOADRESFAILURE;
+      return FALSE;
+    }
+  } else {
+    if (lpofn->Flags & OFN_ENABLETEMPLATE) {
+      hInst = lpofn->hInstance;
+      hResInfo = FindResource(hInst, lpofn->lpTemplateName, RT_DIALOG);
+      if (hResInfo == 0) {
+	CommDlgLastError = CDERR_FINDRESFAILURE;
+	return FALSE;
+      }
+      hDlgTmpl = LoadResource(hInst, hResInfo);
+      if (hDlgTmpl == 0) {
+	CommDlgLastError = CDERR_LOADRESFAILURE;
+	return FALSE;
+      }
+      dlgTemplate = GlobalLock(hDlgTmpl);
+    } else {
+      dlgTemplate = sysres_DIALOG_3;
+    }
+  }
+  hInst = GetWindowWord(lpofn->hwndOwner, GWW_HINSTANCE);
+  bRet = DialogBoxIndirectParamPtr(hInst, dlgTemplate, lpofn->hwndOwner,
+				   GetWndProcEntry16("FileOpenDlgProc"),
+				   (DWORD)lpofn); 
+  
+  printf("GetOpenFileName // return lpstrFile='%s' !\n", 
+	 (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrFile));
+  return bRet;
 }
 
 
@@ -182,42 +203,44 @@
  */
 BOOL GetSaveFileName(LPOPENFILENAME lpofn)
 {
-        HANDLE	        hDlgTmpl;
-        HANDLE	        hResInfo;
-        HINSTANCE       hInst;
-        WND 	        *wndPtr;
-        BOOL	        bRet;
-
-        if (lpofn == NULL) return FALSE;
-	if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE) {
-		hDlgTmpl = lpofn->hInstance;
-	} else {
-		if (lpofn->Flags & OFN_ENABLETEMPLATE) {
-			hInst = lpofn->hInstance;
-                        hResInfo = FindResource(hInst, lpofn->lpTemplateName,
-						RT_DIALOG);
-		} else {
-			hInst = hSysRes;
-			hResInfo = FindResource(hInst, MAKEINTRESOURCE(SAVEFILEDLG2), RT_DIALOG);
-		}
-		if (hResInfo == 0) {
-			CommDlgLastError = CDERR_FINDRESFAILURE;
-			return FALSE;
-		}
-		hDlgTmpl = LoadResource(hInst, hResInfo);
-	}
-	if (hDlgTmpl == 0) {
-		CommDlgLastError = CDERR_LOADRESFAILURE;
-		return FALSE;
-	}
-        wndPtr = WIN_FindWndPtr(lpofn->hwndOwner);
-	bRet = DialogBoxIndirectParam(wndPtr->hInstance, hDlgTmpl, 
-                                      lpofn->hwndOwner,
-                                      GetWndProcEntry16("FileSaveDlgProc"),
-                                      (DWORD)lpofn );
-	printf("GetSaveFileName // return lpstrFile='%s' !\n", 
-	       (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrFile));
-	return bRet;
+  HANDLE    hDlgTmpl;
+  HANDLE    hResInfo;
+  HINSTANCE hInst;
+  BOOL	    bRet;
+  LPCSTR    dlgTemplate;
+  
+  if (lpofn == NULL) return FALSE;
+  if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE) {
+    dlgTemplate = GlobalLock(lpofn->hInstance);
+    if (!dlgTemplate) {
+      CommDlgLastError = CDERR_LOADRESFAILURE;
+      return FALSE;
+    }
+  } else {
+    if (lpofn->Flags & OFN_ENABLETEMPLATE) {
+      hInst = lpofn->hInstance;
+      hResInfo = FindResource(hInst, lpofn->lpTemplateName, RT_DIALOG);
+      if (hResInfo == 0) {
+	CommDlgLastError = CDERR_FINDRESFAILURE;
+	return FALSE;
+      }
+      hDlgTmpl = LoadResource(hInst, hResInfo);
+      if (hDlgTmpl == 0) {
+	CommDlgLastError = CDERR_LOADRESFAILURE;
+	return FALSE;
+      }
+      dlgTemplate = GlobalLock(hDlgTmpl);
+    } else {
+      dlgTemplate = sysres_DIALOG_4; /* SAVEFILEDIALOG */
+    }
+  }
+  hInst = GetWindowWord(lpofn->hwndOwner, GWW_HINSTANCE);
+  bRet = DialogBoxIndirectParamPtr(hInst, dlgTemplate, lpofn->hwndOwner,
+				   GetWndProcEntry16("FileSaveDlgProc"),
+				   (DWORD)lpofn); 
+  printf("GetSaveFileName // return lpstrFile='%s' !\n", 
+	 (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrFile));
+  return bRet;
 }
 
 
@@ -228,13 +251,10 @@
 {
         WND     *wndPtr;
 	BOOL	bRet;
-
         wndPtr = WIN_FindWndPtr(lpChCol->hwndOwner);
-	bRet = DialogBoxParam( wndPtr->hInstance,
-                               MAKEINTRESOURCE(COLORDLG), 
-                               lpChCol->hwndOwner,
-                               GetWndProcEntry16("ColorDlgProc"), 
-                               (DWORD)lpChCol);
+	bRet = DialogBoxIndirectParamPtr(wndPtr->hInstance, sysres_DIALOG_8,
+		lpChCol->hwndOwner, GetWndProcEntry16("ColorDlgProc"), 
+		(DWORD)lpChCol);
 	return bRet;
 }
 
@@ -459,13 +479,11 @@
 #endif
       break;
      case IDOK:
-      SendDlgItemMessage(hWnd, edt1, WM_GETTEXT, 0, str16);
-      printf("OK: str %s\n",str);
+      SendDlgItemMessage(hWnd, edt1, WM_GETTEXT, 511, str16);
       if (COMMDLG_IsPathName(str)) {
 	OpenDlg_ScanDir(hWnd, str);
       } else  {	
 	ShowWindow(hWnd, SW_HIDE); 
-	printf("FileOpenDlgProc // IDOK str='%s'\n", str);
 	strcpy(PTR_SEG_TO_LIN(lpofn->lpstrFile), str);
 	lpofn->nFileOffset = 0;
 	lpofn->nFileExtension = strlen(PTR_SEG_TO_LIN(lpofn->lpstrFile)) - 3;
@@ -723,7 +741,7 @@
 #endif
       break;
      case IDOK:
-      SendDlgItemMessage(hWnd, edt1, WM_GETTEXT, 0, str16);
+      SendDlgItemMessage(hWnd, edt1, WM_GETTEXT, 511, str16);
       if (COMMDLG_IsPathName(str)) {
 	OpenDlg_ScanDir(hWnd, str);
       } else  {	
@@ -797,26 +815,16 @@
  */
 BOOL FindText(LPFINDREPLACE lpFind)
 {
-	HANDLE	hDlgTmpl;
-	HANDLE	hResInfo;
-    WND 	*wndPtr;
-	BOOL	bRet;
-	hResInfo = FindResource(hSysRes, MAKEINTRESOURCE(FINDDLG), RT_DIALOG);
-	if (hResInfo == 0) {
-		CommDlgLastError = CDERR_FINDRESFAILURE;
-		return FALSE;
-		}
-	hDlgTmpl = LoadResource(hSysRes, hResInfo);
-	if (hDlgTmpl == 0) {
-		CommDlgLastError = CDERR_LOADRESFAILURE;
-		return FALSE;
-		}
-    wndPtr = WIN_FindWndPtr(lpFind->hwndOwner);
-	bRet = DialogBoxIndirectParam(wndPtr->hInstance, hDlgTmpl,
-                                      lpFind->hwndOwner,
-                                      GetWndProcEntry16("FindTextDlgProc"),
-                                      (DWORD)lpFind);
-	return bRet;
+  WND    *wndPtr;
+  BOOL   bRet;
+  LPCSTR lpTemplate;
+  
+  lpTemplate = sysres_DIALOG_9;
+  wndPtr = WIN_FindWndPtr(lpFind->hwndOwner);
+  bRet = DialogBoxIndirectParamPtr(wndPtr->hInstance, lpTemplate,
+				lpFind->hwndOwner, GetWndProcEntry16("FindTextDlgProc"),
+				(DWORD)lpFind);
+  return bRet;
 }
 
 
@@ -825,26 +833,16 @@
  */
 BOOL ReplaceText(LPFINDREPLACE lpFind)
 {
-	HANDLE	hDlgTmpl;
-	HANDLE	hResInfo;
-    WND 	*wndPtr;
-	BOOL	bRet;
-	hResInfo = FindResource(hSysRes, MAKEINTRESOURCE(REPLACEDLG), RT_DIALOG);
-	if (hResInfo == 0) {
-		CommDlgLastError = CDERR_FINDRESFAILURE;
-		return FALSE;
-		}
-	hDlgTmpl = LoadResource(hSysRes, hResInfo);
-	if (hDlgTmpl == 0) {
-		CommDlgLastError = CDERR_LOADRESFAILURE;
-		return FALSE;
-		}
-    wndPtr = WIN_FindWndPtr(lpFind->hwndOwner);
-	bRet = DialogBoxIndirectParam(wndPtr->hInstance, hDlgTmpl,
-                                      lpFind->hwndOwner,
-                                      GetWndProcEntry16("ReplaceTextDlgProc"),
-                                      (DWORD)lpFind);
-	return bRet;
+  WND    *wndPtr;
+  BOOL   bRet;
+  LPCSTR lpTemplate;
+
+  lpTemplate = sysres_DIALOG_10;
+  wndPtr = WIN_FindWndPtr(lpFind->hwndOwner);
+  bRet = DialogBoxIndirectParamPtr(wndPtr->hInstance, lpTemplate,
+				   lpFind->hwndOwner, GetWndProcEntry16("ReplaceTextDlgProc"),
+				   (DWORD)lpFind);
+  return bRet;
 }
 
 
@@ -853,24 +851,24 @@
  */
 BOOL FindTextDlgProc(HWND hWnd, WORD wMsg, WORD wParam, LONG lParam)
 {
-	switch (wMsg) {
-		case WM_INITDIALOG:
-			printf("FindTextDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam);
-			ShowWindow(hWnd, SW_SHOWNORMAL);
-			return (TRUE);
-
-		case WM_COMMAND:
-			switch (wParam) {
-				case IDOK:
-					EndDialog(hWnd, TRUE);
-					return(TRUE);
-				case IDCANCEL:
-					EndDialog(hWnd, FALSE);
-					return(TRUE);
-				}
-			return(FALSE);
-		}
-	return FALSE;
+  switch (wMsg) {
+   case WM_INITDIALOG:
+    printf("FindTextDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam);
+    ShowWindow(hWnd, SW_SHOWNORMAL);
+    return (TRUE);
+    
+   case WM_COMMAND:
+    switch (wParam) {
+     case IDOK:
+      EndDialog(hWnd, TRUE);
+      return(TRUE);
+     case IDCANCEL:
+      EndDialog(hWnd, FALSE);
+      return(TRUE);
+    }
+    return(FALSE);
+  }
+  return FALSE;
 }
 
 
@@ -879,24 +877,24 @@
  */
 BOOL ReplaceTextDlgProc(HWND hWnd, WORD wMsg, WORD wParam, LONG lParam)
 {
-	switch (wMsg) {
-		case WM_INITDIALOG:
-			printf("ReplaceTextDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam);
-			ShowWindow(hWnd, SW_SHOWNORMAL);
-			return (TRUE);
-
-		case WM_COMMAND:
-			switch (wParam) {
-				case IDOK:
-					EndDialog(hWnd, TRUE);
-					return(TRUE);
-				case IDCANCEL:
-					EndDialog(hWnd, FALSE);
-					return(TRUE);
-				}
-			return(FALSE);
-		}
-	return FALSE;
+  switch (wMsg) {
+   case WM_INITDIALOG:
+    printf("ReplaceTextDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam);
+    ShowWindow(hWnd, SW_SHOWNORMAL);
+    return (TRUE);
+    
+   case WM_COMMAND:
+    switch (wParam) {
+     case IDOK:
+      EndDialog(hWnd, TRUE);
+      return(TRUE);
+     case IDCANCEL:
+      EndDialog(hWnd, FALSE);
+      return(TRUE);
+    }
+    return(FALSE);
+  }
+  return FALSE;
 }
 
 
@@ -905,36 +903,26 @@
  */
 BOOL PrintDlg(LPPRINTDLG lpPrint)
 {
-	HANDLE	hDlgTmpl;
-	HANDLE	hResInfo;
-    WND 	*wndPtr;
-	BOOL	bRet;
-	printf("PrintDlg(%p) // Flags=%08lX\n", lpPrint, lpPrint->Flags);
-	if (lpPrint->Flags & PD_PRINTSETUP)
-		hResInfo = FindResource(hSysRes, MAKEINTRESOURCE(PRINTSETUPDLG), RT_DIALOG);
-	else
-		hResInfo = FindResource(hSysRes, MAKEINTRESOURCE(PRINTDLG), RT_DIALOG);
-	if (hResInfo == 0) {
-		CommDlgLastError = CDERR_FINDRESFAILURE;
-		return FALSE;
-		}
-	hDlgTmpl = LoadResource(hSysRes, hResInfo);
-	if (hDlgTmpl == 0) {
-		CommDlgLastError = CDERR_LOADRESFAILURE;
-		return FALSE;
-		}
-    wndPtr = WIN_FindWndPtr(lpPrint->hwndOwner);
-	if (lpPrint->Flags & PD_PRINTSETUP)
-            bRet = DialogBoxIndirectParam(wndPtr->hInstance, hDlgTmpl,
-                                          lpPrint->hwndOwner,
-                                          GetWndProcEntry16("PrintSetupDlgProc"),
-                                          (DWORD)lpPrint);
-	else
-            bRet = DialogBoxIndirectParam(wndPtr->hInstance, hDlgTmpl,
-                                          lpPrint->hwndOwner,
-                                          GetWndProcEntry16("PrintDlgProc"),
-                                          (DWORD)lpPrint);
-	return bRet;
+  WND    *wndPtr;
+  BOOL   bRet;
+  LPCSTR lpTemplate;
+  
+  printf("PrintDlg(%p) // Flags=%08lX\n", lpPrint, lpPrint->Flags);
+  if (lpPrint->Flags & PD_PRINTSETUP)  {
+    lpTemplate = sysres_DIALOG_6;
+  } else  {
+    lpTemplate = sysres_DIALOG_5;
+  }
+  wndPtr = WIN_FindWndPtr(lpPrint->hwndOwner);
+  if (lpPrint->Flags & PD_PRINTSETUP)
+  bRet = DialogBoxIndirectParamPtr(wndPtr->hInstance, lpTemplate,
+				   lpPrint->hwndOwner, GetWndProcEntry16("PrintSetupDlgProc"),
+				   (DWORD)lpPrint);
+  else
+  bRet = DialogBoxIndirectParamPtr(wndPtr->hInstance, lpTemplate,
+				   lpPrint->hwndOwner, GetWndProcEntry16("PrintDlgProc"),
+				   (DWORD)lpPrint);
+  return bRet;
 }
 
 
@@ -943,24 +931,24 @@
  */
 BOOL PrintDlgProc(HWND hWnd, WORD wMsg, WORD wParam, LONG lParam)
 {
-	switch (wMsg) {
-		case WM_INITDIALOG:
-			printf("PrintDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam);
-			ShowWindow(hWnd, SW_SHOWNORMAL);
-			return (TRUE);
-
-		case WM_COMMAND:
-			switch (wParam) {
-				case IDOK:
-					EndDialog(hWnd, TRUE);
-					return(TRUE);
-				case IDCANCEL:
-					EndDialog(hWnd, FALSE);
-					return(TRUE);
-				}
-			return(FALSE);
-		}
-	return FALSE;
+  switch (wMsg) {
+   case WM_INITDIALOG:
+    printf("PrintDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam);
+    ShowWindow(hWnd, SW_SHOWNORMAL);
+    return (TRUE);
+    
+   case WM_COMMAND:
+    switch (wParam) {
+     case IDOK:
+      EndDialog(hWnd, TRUE);
+      return(TRUE);
+     case IDCANCEL:
+      EndDialog(hWnd, FALSE);
+      return(TRUE);
+    }
+    return(FALSE);
+  }
+  return FALSE;
 }
 
 
@@ -969,24 +957,24 @@
  */
 BOOL PrintSetupDlgProc(HWND hWnd, WORD wMsg, WORD wParam, LONG lParam)
 {
-	switch (wMsg) {
-		case WM_INITDIALOG:
-			printf("PrintSetupDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam);
-			ShowWindow(hWnd, SW_SHOWNORMAL);
-			return (TRUE);
-
-		case WM_COMMAND:
-			switch (wParam) {
-				case IDOK:
-					EndDialog(hWnd, TRUE);
-					return(TRUE);
-				case IDCANCEL:
-					EndDialog(hWnd, FALSE);
-					return(TRUE);
-				}
-			return(FALSE);
-		}
-	return FALSE;
+  switch (wMsg) {
+   case WM_INITDIALOG:
+    printf("PrintSetupDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam);
+    ShowWindow(hWnd, SW_SHOWNORMAL);
+    return (TRUE);
+    
+   case WM_COMMAND:
+    switch (wParam) {
+     case IDOK:
+      EndDialog(hWnd, TRUE);
+      return(TRUE);
+     case IDCANCEL:
+      EndDialog(hWnd, FALSE);
+      return(TRUE);
+    }
+    return(FALSE);
+  }
+  return FALSE;
 }
 
 
@@ -1004,7 +992,7 @@
  */
 int GetFileTitle(LPCSTR lpFile, LPSTR lpTitle, UINT cbBuf)
 {
-	int		i, len;
+	int    	i, len;
 	printf("GetFileTitle(%p %p %d); \n", lpFile, lpTitle, cbBuf);
 	if (lpFile == NULL || lpTitle == NULL) return -1;
 	len = strlen(lpFile);
@@ -1015,13 +1003,11 @@
 	len--;
 	if (lpFile[len] == '/' || lpFile[len] == '\\' || lpFile[len] == ':') return -1;
 	for (i = len; i >= 0; i--) {
-		if (lpFile[i] == '/' || 
-			lpFile[i] == '\\' || 
-			lpFile[i] == ':') {
-			i++;
-			break;
-			}
-		}
+	  if (lpFile[i] == '/' ||  lpFile[i] == '\\' ||  lpFile[i] == ':') {
+	    i++;
+	    break;
+	  }
+	}
 	printf("\n---> '%s' ", &lpFile[i]);
 	len = min(cbBuf, strlen(&lpFile[i]) + 1);
 	strncpy(lpTitle, &lpFile[i], len + 1);
diff --git a/misc/exec.c b/misc/exec.c
index e10cb21..ad55c1c 100644
--- a/misc/exec.c
+++ b/misc/exec.c
@@ -11,10 +11,7 @@
 #include "prototypes.h"
 #include "dlls.h"
 #include "windows.h"
-#include "if1632.h"
 #include "callback.h"
-#include "library.h"
-#include "ne_image.h"
 #include "stddebug.h"
 #include "debug.h"
 
@@ -33,88 +30,6 @@
 #define HELP_MULTIKEY     0x0201
 #define HELP_SETWINPOS    0x0203
 
-typedef struct {
-	WORD	wEnvSeg;
-	LPSTR	lpCmdLine;
-	LPVOID	lpCmdShow;
-	DWORD	dwReserved;
-	} PARAMBLOCK;
-
-typedef BOOL (CALLBACK * LPFNWINMAIN)(HANDLE, HANDLE, LPSTR, int);
-
-
-/**********************************************************************
- *				LoadModule	[KERNEL.45]
- */
-HANDLE LoadModule(LPSTR modulefile, LPVOID lpParamBlk)
-{
-	PARAMBLOCK  *pblk = lpParamBlk;
-	WORD 	*lpCmdShow;
-    	dprintf_exec(stddeb,"LoadModule '%s' %p\n", modulefile, lpParamBlk);
-	if (lpParamBlk == NULL) return 0;
-	lpCmdShow = (WORD *)pblk->lpCmdShow;
-	return WinExec(pblk->lpCmdLine, lpCmdShow[1]);
-}
-
-
-/**********************************************************************
- *				WinExec		[KERNEL.166]
- */
-WORD WinExec(LPSTR lpCmdLine, WORD nCmdShow)
-{
-	int 		c = 0;
-	int 		x, x2;
-	char 		*ArgV[20];
-	HINSTANCE	hInst = 0;
-	HANDLE		hTask = 0;
-    	dprintf_exec(stddeb,"WinExec('%s', %04X)\n", lpCmdLine, nCmdShow);
-/*	ArgV[0] = "wine";
-	c = 1; */
-	for (x = x2 = 0; x < strlen(lpCmdLine) + 1; x++) {
-		if ((lpCmdLine[x] == ' ') || (lpCmdLine[x] == '\0')) {
-			ArgV[c] = (char *)malloc(x - x2 + 1);
-			strncpy(ArgV[c], &lpCmdLine[x2], x - x2);
-			ArgV[c][x - x2] = '\0';
-			c++;   x2 = x + 1;
-			}							  
-		}  
-	ArgV[c] = NULL;
-    for (c = 0; ArgV[c] != NULL; c++) 
-	dprintf_exec(stddeb,"--> '%s' \n", ArgV[c]);
-
-        if ((hInst = LoadImage(ArgV[0], EXE, 1)) == (HINSTANCE) NULL ) {
-            fprintf(stderr, "wine: can't find %s!.\n", ArgV[0]);
-        }
-#if 0
-	switch(fork()) {
-		case -1:
-            fprintf(stderr,"Can't 'fork' process !\n");
-			break;
-		case 0:
-			if ((hInst = LoadImage(ArgV[0], EXE, 1)) == (HINSTANCE) NULL ) {
-				fprintf(stderr, "wine: can't find %s!.\n", ArgV[0]);
-                		fprintf(stderr,"Child process died !\n");
-				exit(1);
-				}
-			StartNewTask(hInst); 
-/*			hTask = CreateNewTask(0);
-            		dprintf_exec(stddeb,
-				"WinExec // New Task hTask=%04X !\n", hTask);
-			execvp(ArgV[0], ArgV); */
-
-            		fprintf(stderr,"Child process died !\n");
-			exit(1);
-		default:
-            		dprintf_exec(stddeb,
-			"WinExec (Main process stay alive) hTask=%04X !\n", 
-			hTask);
-			break;         
-		}
-#endif
-	for (c = 0; ArgV[c] != NULL; c++) 	free(ArgV[c]);
-	return hTask;
-}
-
 
 /**********************************************************************
  *				ExitWindows		[USER.7]
diff --git a/misc/file.c b/misc/file.c
index c71673a..31c2cfc 100644
--- a/misc/file.c
+++ b/misc/file.c
@@ -42,13 +42,19 @@
 {
   int  handle;
   char *UnixFileName;
+  int mode = 0;
 
   dprintf_file(stddeb, "_lopen: open('%s', %X);\n", lpPathName, iReadWrite);
   if ((UnixFileName = DOS_GetUnixFileName(lpPathName)) == NULL)
   	return HFILE_ERROR;
-  iReadWrite &= 0x000F;
-  handle =  open (UnixFileName, iReadWrite);
-  if( ( handle == -1 ) && Options.allowReadOnly )
+  switch(iReadWrite & 3)
+  {
+  case OF_READ:      mode = O_RDONLY; break;
+  case OF_WRITE:     mode = O_WRONLY; break;
+  case OF_READWRITE: mode = O_RDWR; break;
+  }
+  handle = open( UnixFileName, mode );
+  if (( handle == -1 ) && Options.allowReadOnly)
     handle = open( UnixFileName, O_RDONLY );
 
   dprintf_file(stddeb, "_lopen: open: %s (handle %d)\n", UnixFileName, handle);
@@ -112,17 +118,14 @@
  **************************************************************************/
 INT OpenFile (LPSTR lpFileName, LPOFSTRUCT ofs, WORD wStyle)
 {
-#ifdef WINELIB
-    dprintf_file(stdnimp, "OpenFile: not implemented\n");
-#else
-    char                      filename[MAX_PATH+1];
-    int                       action;
-    struct stat               s;
-    struct tm                 *now;
-    int                       res;
-    int                       verify_time;
+    char         filename[MAX_PATH+1];
+    int          action;
+    struct stat  s;
+    struct tm   *now;
+    int          res, handle;
+    int          verify_time;
   
-    dprintf_file(stddeb,"Openfile(%s,<struct>,%d) ",lpFileName,wStyle);
+    dprintf_file(stddeb,"Openfile(%s,<struct>,%d)\n",lpFileName,wStyle);
   
     action = wStyle & 0xff00;
   
@@ -131,31 +134,29 @@
        handle it first */
 
     if (action & OF_CREATE)
-      {
-      int handle;
-      char *unixfilename;
+    {
+        char *unixfilename;
 
-      if (!(action & OF_REOPEN))
-        strcpy(ofs->szPathName, lpFileName);
-      ofs->cBytes = sizeof(OFSTRUCT);
-      ofs->fFixedDisk = FALSE;
-      ofs->nErrCode = 0;
-      *((int*)ofs->reserved) = 0;
+        if (!(action & OF_REOPEN)) strcpy(ofs->szPathName, lpFileName);
+        ofs->cBytes = sizeof(OFSTRUCT);
+        ofs->fFixedDisk = FALSE;
+        ofs->nErrCode = 0;
+        *((int*)ofs->reserved) = 0;
 
-      if ((unixfilename = DOS_GetUnixFileName (ofs->szPathName)) == NULL)
-      {
-        errno_to_doserr();
-	ofs->nErrCode = ExtendedError;
-        return -1;
-      }
-      handle = open (unixfilename, (wStyle & 0x0003) | O_CREAT, 0x666);
-      if (handle == -1)
-      {
-	errno_to_doserr();
-	ofs->nErrCode = ExtendedError;
-      }   
-      return handle;
-      }
+        if ((unixfilename = DOS_GetUnixFileName (ofs->szPathName)) == NULL)
+        {
+            errno_to_doserr();
+            ofs->nErrCode = ExtendedError;
+            return -1;
+        }
+        handle = open (unixfilename, (wStyle & 0x0003) | O_CREAT, 0x666);
+        if (handle == -1)
+        {
+            errno_to_doserr();
+            ofs->nErrCode = ExtendedError;
+        }   
+        return handle;
+    }
 
 
     /* If path isn't given, try to find the file. */
@@ -166,27 +167,53 @@
 	      index(lpFileName,':')))
 	while(1)
 	{
-	  char temp[MAX_PATH+1];
+          char temp[MAX_PATH+1];
+          /* Try current directory */
 	  strcpy (filename, lpFileName);
 	  if ( (!stat(DOS_GetUnixFileName(filename), &s)) && (S_ISREG(s.st_mode)) )
 	    break;
+
+          /* Try Windows directory */
+
 	  GetWindowsDirectory (filename,MAX_PATH);
 	  if ((!filename[0])||(filename[strlen(filename)-1]!='\\'))
             strcat(filename, "\\");
 	  strcat (filename, lpFileName);
 	  if ( (!stat(DOS_GetUnixFileName(filename), &s)) && (S_ISREG(s.st_mode)) )
 	    break;
+
+          /* Try Windows system directory */
+
 	  GetSystemDirectory (filename,MAX_PATH);
 	  if ((!filename[0])||(filename[strlen(filename)-1]!='\\'))
  	    strcat(filename, "\\");
 	  strcat (filename, lpFileName);
 	  if ( (!stat(DOS_GetUnixFileName(filename), &s)) && (S_ISREG(s.st_mode)) )
 	    break;
-	  if (!DOS_FindFile(temp,MAX_PATH,lpFileName,NULL,WindowsPath))
-	    {
+
+          /* Try the path of the current executable */
+
+          if (GetCurrentTask())
+          {
+              char *p;
+              GetModuleFileName( GetCurrentTask(), filename, MAX_PATH );
+              if ((p = strrchr( filename, '\\' )))
+              {
+                  p[1] = '\0';
+                  strcat( filename, lpFileName );
+                  if ((!stat(DOS_GetUnixFileName(filename), &s)) &&
+                      (S_ISREG(s.st_mode)) )
+                      break;
+              }
+          }
+
+          /* Try all directories in path */
+
+	  if (DOS_FindFile(temp,MAX_PATH,lpFileName,NULL,WindowsPath))
+          {
 	      strcpy(filename, DOS_GetDosFileName(temp));
 	      break;
-	    }
+          }
 	  strcpy (filename, lpFileName);
 	  break;
 	}
@@ -235,47 +262,15 @@
     if (action & OF_EXIST)
       return 0;
     
-   /* Now we are actually going to open the file. According to Microsoft's
-       Knowledge Basis, this is done by calling int 21h, ax=3dh. */    
-
-#if 0
-    AX = 0x3d00;
-    AL = (AL & 0x0f) | (wStyle & 0x70); /* Handle OF_SHARE_xxx etc. */
-    AL = (AL & 0xf0) | (wStyle & 0x03); /* Handle OF_READ etc. */
-    DS = SELECTOROF(ofs->szPathName);
-    DX = OFFSETOF(ofs->szPathName);
-  
-    OpenExistingFile (context);
-
-    if (EFL & 0x00000001)     /* Cflag */
+    if ((handle = _lopen( ofs->szPathName, wStyle )) == -1)
     {
-      ofs->nErrCode = AL;
-      return -1;
-      }
-
-    return AX;
-#endif
-      /* FIXME: Quick hack to get it to work without calling DOS  --AJ */
-    {
-        int mode, handle;
-        switch(wStyle & 3)
-        {
-            case 0: mode = O_RDONLY; break;
-            case 1: mode = O_WRONLY; break;
-            default: mode = O_RDWR; break;
-        }
-        if ((handle = open(DOS_GetUnixFileName(ofs->szPathName), mode)) == -1)
-        {
-            ofs->nErrCode = 2;  /* not found */
-            return -1;
-        }
-          /* don't bother with locking for now */
-
-        return handle;
+        ofs->nErrCode = 2;  /* not found */
+        return -1;
     }
-#endif /*WINELIB*/
+    return handle;
 }
 
+
 /**************************************************************************
  SetHandleCount
 
@@ -358,7 +353,8 @@
 BYTE GetTempDrive(BYTE chDriveLetter)
 {
     dprintf_file(stddeb,"GetTempDrive (%d)\n",chDriveLetter);
-	return('C');
+    if (TempDirectory[1] == ':') return TempDirectory[0];
+    else return 'C';
 }
 
 /***************************************************************************
@@ -437,14 +433,14 @@
 /***************************************************************************
  _hread
  ***************************************************************************/
-long _hread(int hf, void FAR *hpvBuffer, long cbBuffer)
+LONG _hread(INT hf, LPSTR hpvBuffer, LONG cbBuffer)
 {
 	return read(hf, hpvBuffer, cbBuffer);
 }
 /***************************************************************************
  _hwrite
  ***************************************************************************/
-long _hwrite(int hf, const void FAR *hpvBuffer, long cbBuffer)
+LONG _hwrite(INT hf, const LPSTR hpvBuffer, LONG cbBuffer)
 {
 	return write(hf, hpvBuffer, cbBuffer);
 }
diff --git a/misc/kernel32.c b/misc/kernel32.c
new file mode 100644
index 0000000..0be2b09
--- /dev/null
+++ b/misc/kernel32.c
@@ -0,0 +1,61 @@
+/*
+ * Win32 kernel functions
+ *
+ * Copyright 1995 Martin von Loewis
+ */
+
+/* This file contains only wrappers to existing Wine functions or trivial
+   stubs. 'Real' implementations go into context specific files */
+
+#include "windows.h"
+#include "winerror.h"
+
+int WIN32_LastError;
+
+/***********************************************************************
+ *           GetCommandLineA      (KERNEL32.161)
+ */
+LPSTR GetCommandLineA(void)
+{
+	return 0;
+}
+
+/***********************************************************************
+ *           GetCurrentThreadId   (KERNEL32.200)
+ */
+
+int GetCurrentThreadId(void)
+{
+	return getpid();
+}
+
+
+/***********************************************************************
+ *           GetEnvironmentStrings    (KERNEL32.210)
+ */
+LPSTR GetEnvironmentStrings(void)
+{
+	return 0;
+}
+
+/***********************************************************************
+ *           GetStdHandle             (KERNEL32.276)
+ */
+HANDLE GetStdHandle(DWORD nStdHandle)
+{
+	switch(nStdHandle)
+	{
+		case -10/*STD_INPUT_HANDLE*/:return 0;
+		case -11/*STD_OUTPUT_HANDLE*/:return 1;
+		case -12/*STD_ERROR_HANDLE*/:return 2;
+	}
+	return -1;
+}
+
+/***********************************************************************
+ *           GetThreadContext         (KERNEL32.294)
+ */
+BOOL GetThreadContext(HANDLE hThread, void *lpContext)
+{
+	return FALSE;
+}
diff --git a/misc/lstr.c b/misc/lstr.c
index 9d7be42..7ba113e 100644
--- a/misc/lstr.c
+++ b/misc/lstr.c
@@ -1,13 +1,13 @@
 /*
-static char Copyright[] = "Copyright  Yngvi Sigurjonsson (yngvi@hafro.is), 1993";
-*/
+ * String functions
+ *
+ * Copyright 1993 Yngvi Sigurjonsson (yngvi@hafro.is)
+ */
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <unistd.h>
 
 #include "ldt.h"
 #include "windows.h"
@@ -17,6 +17,44 @@
 #define ToUpper(c)	toupper(c)
 #define ToLower(c)	tolower(c)
 
+
+static const BYTE Oem2Ansi[256] =
+"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\244"
+"\020\021\022\023\266\247\026\027\030\031\032\033\034\035\036\037"
+"\040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057"
+"\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077"
+"\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117"
+"\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137"
+"\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157"
+"\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177"
+"\307\374\351\342\344\340\345\347\352\353\350\357\356\354\304\305"
+"\311\346\306\364\366\362\373\371\377\326\334\242\243\245\120\203"
+"\341\355\363\372\361\321\252\272\277\137\254\275\274\241\253\273"
+"\137\137\137\246\246\246\246\053\053\246\246\053\053\053\053\053"
+"\053\055\055\053\055\053\246\246\053\053\055\055\246\055\053\055"
+"\055\055\055\053\053\053\053\053\053\053\053\137\137\246\137\137"
+"\137\337\137\266\137\137\265\137\137\137\137\137\137\137\137\137"
+"\137\261\137\137\137\137\367\137\260\225\267\137\156\262\137\137";
+
+static const BYTE Ansi2Oem[256] =
+"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017"
+"\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
+"\040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057"
+"\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077"
+"\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117"
+"\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137"
+"\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157"
+"\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177"
+"\200\201\054\237\054\137\375\374\210\045\123\074\117\215\216\217"
+"\220\140\047\042\042\371\055\137\230\231\163\076\157\235\236\131"
+"\040\255\233\234\017\235\335\025\042\143\246\256\252\055\162\137"
+"\370\361\375\063\047\346\024\372\054\061\247\257\254\253\137\250"
+"\101\101\101\101\216\217\222\200\105\220\105\105\111\111\111\111"
+"\104\245\117\117\117\117\231\170\117\125\125\125\232\131\137\341"
+"\205\240\203\141\204\206\221\207\212\202\210\211\215\241\214\213"
+"\144\244\225\242\223\157\224\366\157\227\243\226\201\171\137\230";
+
+
 /* Funny to divide them between user and kernel. */
 
 /* KERNEL.89 */
@@ -191,36 +229,10 @@
     return (current==start)?start:current-1;
 }
 
-BYTE Oem2Ansi[256], Ansi2Oem[256];
-
-void InitOemAnsiTranslations(void)
-{
-  static int inited=0; /* should called called in some init function*/
-  int transfile,i;
-  if(inited) return;
-  if((transfile=open("oem2ansi.trl",O_RDONLY))){
-    read(transfile,Oem2Ansi,256);
-    close(transfile);
-  }
-  else {  /* sets up passive translations if it does not find the file */
-    for(i=0;i<256;i++)  /* Needs some fixing */
-      Oem2Ansi[i]=i;  
-  }
-  if((transfile=open("ansi2oem.trl",O_RDONLY))){
-    read(transfile,Ansi2Oem,256);
-    close(transfile);
-  }
-  else {  /* sets up passive translations if it does not find the file */
-    for(i=0;i<256;i++)  /* Needs some fixing */
-      Ansi2Oem[i]=i;  
-  }
-  inited=1;
-}
 
 /* AnsiToOem Keyboard.5 */
 INT AnsiToOem(LPSTR lpAnsiStr, LPSTR lpOemStr)   /* why is this int ??? */
 {
-  InitOemAnsiTranslations(); /* should called called in some init function*/
   while(*lpAnsiStr){
     *lpOemStr++=Ansi2Oem[(unsigned char)(*lpAnsiStr++)];
   }
@@ -231,7 +243,6 @@
 /* OemToAnsi Keyboard.6 */
 BOOL OemToAnsi(LPSTR lpOemStr, LPSTR lpAnsiStr)   /* why is this BOOL ???? */
 {
-  InitOemAnsiTranslations(); /* should called called in some init function*/
   while(*lpOemStr){
     *lpAnsiStr++=Oem2Ansi[(unsigned char)(*lpOemStr++)];
   }
@@ -243,7 +254,6 @@
 void AnsiToOemBuff(LPSTR lpAnsiStr, LPSTR lpOemStr, INT nLength)
 {
   int i;
-  InitOemAnsiTranslations(); /* should called called in some init function*/
   for(i=0;i<nLength;i++)
     lpOemStr[i]=Ansi2Oem[(unsigned char)(lpAnsiStr[i])];
 }
@@ -252,7 +262,6 @@
 void OemToAnsiBuff(LPSTR lpOemStr, LPSTR lpAnsiStr, INT nLength)
 {
   int i;
-  InitOemAnsiTranslations(); /* should called called in some init function*/
   for(i=0;i<nLength;i++)
     lpAnsiStr[i]=Oem2Ansi[(unsigned char)(lpOemStr[i])];
 }
diff --git a/misc/main.c b/misc/main.c
index 0d2dc23..c174132 100644
--- a/misc/main.c
+++ b/misc/main.c
@@ -25,17 +25,12 @@
 #include "options.h"
 #include "desktop.h"
 #include "prototypes.h"
-#include "texts.h"
-#include "library.h"
 #include "dlls.h"
-#include "if1632.h"
 #define DEBUG_DEFINE_VARIABLES
 #include "stddebug.h"
 #include "debug.h"
 
-extern ButtonTexts ButtonText;
-
-static const char people[] = "Wine is available thanks to the work of "\
+const char people[] = "Wine is available thanks to the work of "\
 "Bob Amstadt, Dag Asheim, Martin Ayotte, Ross Biro, Erik Bos, Fons Botman, "\
 "John Brezak, Andrew Bulhak, John Burton, Paul Falstad, Olaf Flebbe, "\
 "Peter Galbavy, Cameron Heide, Jeffrey Hsu, Miguel de Icaza, "\
@@ -50,13 +45,12 @@
 #define WINE_CLASS    "Wine"    /* Class name for resources */
 
 typedef struct tagENVENTRY {
-	LPSTR				Name;
-	LPSTR				Value;
-	WORD				wSize;
-	struct tagENVENTRY	*Prev;
-	struct tagENVENTRY	*Next;
-	} ENVENTRY;
-typedef ENVENTRY *LPENVENTRY;
+  LPSTR	       	        Name;
+  LPSTR	       	        Value;
+  WORD	       	        wSize;
+  struct tagENVENTRY    *Prev;
+  struct tagENVENTRY    *Next;
+} ENVENTRY, *LPENVENTRY;
 
 LPENVENTRY	lpEnvList = NULL;
 
@@ -77,7 +71,8 @@
     FALSE,          /* backing store */
     SW_SHOWNORMAL,  /* cmdShow */
     FALSE,
-    FALSE           /* AllowReadOnly */
+    FALSE,          /* AllowReadOnly */
+    FALSE           /* Enhanced mode */
 };
 
 
@@ -95,7 +90,8 @@
     { "-debug",         ".debug",           XrmoptionNoArg,  (caddr_t)"on" },
     { "-debugmsg",      ".debugmsg",        XrmoptionSepArg, (caddr_t)NULL },
     { "-dll",           ".dll",             XrmoptionSepArg, (caddr_t)NULL },
-    { "-allowreadonly", ".allowreadonly",   XrmoptionNoArg,  (caddr_t)"on" }
+    { "-allowreadonly", ".allowreadonly",   XrmoptionNoArg,  (caddr_t)"on" },
+    { "-enhanced",      ".enhanced",        XrmoptionNoArg,  (caddr_t)"off"}
 };
 
 #define NB_OPTIONS  (sizeof(optionsTable) / sizeof(optionsTable[0]))
@@ -114,10 +110,10 @@
   "    -synchronous    Turn on synchronous display mode\n" \
   "    -backingstore   Turn on backing store\n" \
   "    -spy file       Turn on message spying to the specified file\n" \
-  "    -relaydbg       Obsolete. Use -debugmsg +relay instead\n" \
   "    -debugmsg name  Turn debugging-messages on or off\n" \
   "    -dll name       Enable or disable built-in DLLs\n" \
-  "    -allowreadonly  Read only files may be opened in write mode\n"
+  "    -allowreadonly  Read only files may be opened in write mode\n" \
+  "    -enhanced       Start wine in enhanced mode\n"
 
 
 
@@ -179,53 +175,6 @@
 
 
 /***********************************************************************
- *           MAIN_GetButtonText
- *
- * Fetch the value of resource 'name' using the correct instance name.
- * 'name' must begin with '.' or '*'
- *
- * The address of the string got from the XResoure is stored in Button.Label.
- * The corresponding hotkey is taken from this string.
- */
-
-static void MAIN_GetButtonText( XrmDatabase db, char *name, ButtonDesc *Button)
-{
-    XrmValue value;
-    char *i;
-
-    if (MAIN_GetResource( db, name, &value))
-      {
-       Button->Label = value.addr;
-       i = strchr(Button->Label,'&');
-       if ( i == NULL )
-         Button->Hotkey = '\0';
-       else if ( i++ == '\0' )
-         Button->Hotkey = '\0';
-       else
-         Button->Hotkey = *i;
-      }
-    Button->Hotkey = toupper(Button->Hotkey);
-}
-
-/***********************************************************************
- *           MAIN_GetAllButtonTexts
- *
- * Read all Button-labels from X11-resources if they exist.
- */
-
-static void MAIN_GetAllButtonTexts(XrmDatabase db)
-{
-  MAIN_GetButtonText(db, ".YesLabel",    &ButtonText.Yes);
-  MAIN_GetButtonText(db, ".NoLabel",     &ButtonText.No);
-  MAIN_GetButtonText(db, ".OkLabel",     &ButtonText.Ok);
-  MAIN_GetButtonText(db, ".CancelLabel", &ButtonText.Cancel);
-  MAIN_GetButtonText(db, ".AbortLabel",  &ButtonText.Abort);
-  MAIN_GetButtonText(db, ".RetryLabel",  &ButtonText.Retry);
-  MAIN_GetButtonText(db, ".IgnoreLabel", &ButtonText.Ignore);
-  MAIN_GetButtonText(db, ".CancelLabel", &ButtonText.Cancel);
-}
-
-/***********************************************************************
  *                    ParseDebugOptions
  *
  *  Turns specific debug messages on or off, according to "options".
@@ -294,9 +243,9 @@
       l=strchr(options,',')-options;
     else l=strlen(options);
     for (i=0;i<N_BUILTINS;i++)
-         if (!strncasecmp(options+1,dll_builtin_table[i].dll_name,l-1))
+         if (!strncasecmp(options+1,dll_builtin_table[i].name,l-1))
            {
-             dll_builtin_table[i].dll_is_used=(*options=='+');
+             dll_builtin_table[i].used = (*options=='+');
              break;
            }
     if (i==N_BUILTINS)
@@ -360,6 +309,8 @@
 	Options.debug = TRUE;
     if (MAIN_GetResource( db, ".allowreadonly", &value ))
         Options.allowReadOnly = TRUE;
+    if (MAIN_GetResource( db, ".enhanced", &value ))
+        Options.enhanced = TRUE;
     if (MAIN_GetResource( db, ".spy", &value))
 	Options.spyFilename = value.addr;
     if (MAIN_GetResource( db, ".depth", &value))
@@ -403,14 +354,11 @@
          fprintf(stderr,"Example: -dll -ole2    Do not use emulated OLE2.DLL\n");
          fprintf(stderr,"Available DLLs\n");
          for(i=0;i<N_BUILTINS;i++)
-               fprintf(stderr,"%-9s%c",dll_builtin_table[i].dll_name,
+               fprintf(stderr,"%-9s%c",dll_builtin_table[i].name,
                        (((i+2)%8==0)?'\n':' '));
          fprintf(stderr,"\n\n");
          exit(1);
        }
-
-/*    MAIN_GetAllButtonTexts(db); */
- 
 }
 
 
@@ -531,6 +479,9 @@
     int depth_count, i;
     int *depth_list;
 
+	setbuf(stdout,NULL);
+	setbuf(stderr,NULL);
+
     setlocale(LC_CTYPE,"");
 
     XrmInitialize();
@@ -607,7 +558,10 @@
  */
 LONG GetWinFlags(void)
 {
-	return (WF_STANDARD | WF_CPU286 | WF_PMODE | WF_80x87);
+  if (Options.enhanced)
+    return (WF_STANDARD | WF_ENHANCED | WF_CPU286 | WF_PMODE | WF_80x87);
+  else
+    return (WF_STANDARD | WF_CPU286 | WF_PMODE | WF_80x87);
 }
 
 /***********************************************************************
diff --git a/misc/message.c b/misc/message.c
deleted file mode 100644
index 7d23f7e..0000000
--- a/misc/message.c
+++ /dev/null
@@ -1,476 +0,0 @@
-/*
- * 'Wine' MessageBox function handling
- *
- * Copyright 1993 Martin Ayotte
- *
-static char Copyright[] = "Copyright Martin Ayotte, 1993";
-*/
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <windows.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <ctype.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include "library.h"
-#include "win.h"
-#include "texts.h"
-#include "user.h"
-#include "selectors.h"
-#include "stddebug.h"
-/* #define DEBUG_MSGBOX */
-#include "debug.h"
-
-
-/*
- * Defaults for button-texts
- */
-
-ButtonTexts ButtonText = {    /* FIXME: Norwegian Translation missing */
-#if #LANG(De)
-  { "&Ja",     'J' },
-  { "&Nein",   'N' },
-  { "&Ok",     'O' },
-  { "&Abbruch",'A' },
-  { "&Abbruch",'A' },
-  { "&Wiederholen", 'W' },
-  { "&Ignorieren", 'I' }
-#else
-  { "&Yes",    'Y' },
-  { "&No",     'N' },
-  { "&Ok",     'O' },
-  { "&Cancel", 'C' },
-  { "&Abort",  'A' },
-  { "&Retry",  'R' },
-  { "&Ignore", 'I' }
-#endif
-};
-
-extern HBITMAP hUpArrow;
-
-typedef struct tagMSGBOX {
-    LPSTR	Title;
-    LPSTR	Str;
-    WORD	wType;
-    WORD	wRetVal;
-    BOOL	ActiveFlg;
-    HWND	hWndYes;
-    HWND	hWndNo;
-    HWND	hWndCancel;
-    HICON	hIcon;
-    RECT	rectIcon;
-    RECT	rectStr;
-} MSGBOX;
-typedef MSGBOX FAR* LPMSGBOX;
-
-LONG SystemMessageBoxProc(HWND hwnd, WORD message, WORD wParam, LONG lParam);
-
-/**************************************************************************
- *			MessageBox  [USER.1]
- */
-
-int MessageBox(HWND hWnd, LPSTR str, LPSTR title, WORD type)
-{
-	HWND    	hDlg, hWndOld;
-	WND	    	*wndPtr;
-	WNDCLASS  	wndClass;
-	MSG*	    	msg;
-        LPMSGBOX 	lpmb;
-        HANDLE          hClassName, hMsg;
-	DWORD		dwStyle;
-	HINSTANCE	hInst;
-	int			nRet;
-
-        if (title == NULL)
-		title = "Error";
-	wndPtr = WIN_FindWndPtr(hWnd);
-	if (wndPtr == NULL) {
-		hInst = hSysRes;
-		dprintf_msgbox(stddeb,"MessageBox(NULL, str='%s', title='%s', %04X)\n", 
-			str, title, type);
-		}
-	else {
-		hInst = wndPtr->hInstance;
-		dprintf_msgbox(stddeb,"MessageBox(%04X, str='%s', title='%s', %04X)\n", 
-			hWnd, str, title, type);
-		}
-    lpmb = (LPMSGBOX) malloc(sizeof(MSGBOX));
-	memset(lpmb, 0, sizeof(MSGBOX));
-/*	lpmb->Title = title;*/
-	lpmb->Title = (LPSTR) malloc(strlen(title) + 1);
-	strcpy(lpmb->Title, title);
-/*	lpmb->Str = str;*/
-	if (str && *str)
-	{
-		lpmb->Str = (LPSTR) malloc(strlen(str) + 1);
-		strcpy(lpmb->Str, str);
-	}
-	else
-	{
-		lpmb->Str = (LPSTR) malloc(8);
-		strcpy(lpmb->Str, "Message");
-	}
-	lpmb->wType = type;
-	lpmb->ActiveFlg = TRUE;
-	wndClass.style           = CS_HREDRAW | CS_VREDRAW ;
-	wndClass.lpfnWndProc     = GetWndProcEntry16("SystemMessageBoxProc");
-	wndClass.cbClsExtra      = 0;
-	wndClass.cbWndExtra      = 4;
-	wndClass.hInstance       = hInst;
-	wndClass.hIcon           = (HICON)NULL;
-	wndClass.hCursor         = LoadCursor((HANDLE)NULL, IDC_ARROW); 
-	wndClass.hbrBackground   = GetStockObject(WHITE_BRUSH);
-	wndClass.lpszMenuName    = NULL;
-        hClassName = USER_HEAP_ALLOC( 20 );
-        strcpy( USER_HEAP_LIN_ADDR( hClassName ), "MESSAGEBOX" );
-        hMsg = USER_HEAP_ALLOC( sizeof(MSG) );
-        msg = (MSG *) USER_HEAP_LIN_ADDR( hMsg );
-	wndClass.lpszClassName = (LPSTR)USER_HEAP_SEG_ADDR( hClassName );
-	dprintf_msgbox(stddeb, "MessageBox // before RegisterClass, '%s' '%s' !\n", str, title);
-	if (!RegisterClass(&wndClass)) {
-		printf("Unable to Register class 'MESSAGEBOX' !\n");
-		if (lpmb != NULL) free(lpmb);
-		return 0;
-		}
-        USER_HEAP_FREE( hClassName );
-	dwStyle = WS_POPUP | WS_DLGFRAME | WS_VISIBLE;
-	if ((type & (MB_SYSTEMMODAL | MB_TASKMODAL)) == 0) dwStyle |= WS_CAPTION;
-	hWndOld = GetFocus();
-	hDlg = CreateWindow("MESSAGEBOX", lpmb->Title, dwStyle, 100, 150, 400, 160,
-				(HWND)NULL, (HMENU)NULL, hInst, (SEGPTR)lpmb);
-	if (hDlg == 0) {
-		printf("Unable to create 'MESSAGEBOX' window !\n");
-		if (lpmb != NULL) free(lpmb);
-		return 0;
-		}
-	dprintf_msgbox(stddeb, "MessageBox // before Msg Loop !\n");
-	while(TRUE) {
-		if (!lpmb->ActiveFlg) break;
-		if (!GetMessage( USER_HEAP_SEG_ADDR(hMsg),
-                                 (HWND)NULL, 0, 0)) break;
-		TranslateMessage(msg);
-		if ((type & (MB_SYSTEMMODAL | MB_TASKMODAL)) != 0 &&
-			msg->hwnd != hDlg) {
-			switch(msg->message) {
-				case WM_KEYDOWN:
-				case WM_LBUTTONDOWN:
-				case WM_MBUTTONDOWN:
-				case WM_RBUTTONDOWN:
-					MessageBeep(0);
-					break;
-				}
-			}
-		DispatchMessage(msg);
-		}
-        USER_HEAP_FREE(hMsg);
-	SetFocus(hWndOld);
-	nRet = lpmb->wRetVal;
-	if (lpmb != NULL) free(lpmb);
-	if (!UnregisterClass("MESSAGEBOX", hInst)) return 0;
-	dprintf_msgbox(stddeb, "MessageBox return %04X !\n", nRet);
-	return(nRet);
-}
-
-
-LPMSGBOX MsgBoxGetStorageHeader(HWND hwnd)
-{
-    WND  *wndPtr;
-    LPMSGBOX lpmb;
-    wndPtr = WIN_FindWndPtr(hwnd);
-    if (wndPtr == 0) {
-    	printf("Bad Window handle on MessageBox !\n");
-    	return 0;
-    	}
-    lpmb = *((LPMSGBOX *)wndPtr->wExtra);
-    return lpmb;
-}
-
-
-
-
-LONG SystemMessageBoxProc(HWND hWnd, WORD message, WORD wParam, LONG lParam)
-{
-	WND	    	*wndPtr;
-	CREATESTRUCT *createStruct;
-	PAINTSTRUCT	ps;
-	HDC			hDC;
-	DWORD		OldTextColor;
-	RECT		rect;
-	LPMSGBOX	lpmb;
-
-	switch(message) {
-	case WM_CREATE:
-		dprintf_msgbox(stddeb, "MessageBox WM_CREATE hWnd=%04X !\n", hWnd);
-		wndPtr = WIN_FindWndPtr(hWnd);
-		createStruct = (CREATESTRUCT *)PTR_SEG_TO_LIN(lParam);
-		lpmb = (LPMSGBOX)createStruct->lpCreateParams;
-		if (lpmb == NULL) break;
-		*((LPMSGBOX *)wndPtr->wExtra) = lpmb;
-		dprintf_msgbox(stddeb, "MessageBox WM_CREATE title='%s' str='%s' !\n", 
-									lpmb->Title, lpmb->Str);
-		GetClientRect(hWnd, &rect);
-		CopyRect(&lpmb->rectStr, &rect);
-		lpmb->rectStr.bottom -= 32;
-		switch(lpmb->wType & MB_TYPEMASK) {
-		case MB_OK :
-		        lpmb->hWndYes = CreateWindow("BUTTON", ButtonText.Ok.Label,
-				WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
-				rect.right / 2 - 30, rect.bottom - 25, 
-				60, 18, hWnd, IDOK, wndPtr->hInstance, 0L);
-			break;
-		case MB_OKCANCEL :
-			lpmb->hWndYes = CreateWindow("BUTTON", ButtonText.Ok.Label,
-				WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
-				rect.right / 2 - 65, rect.bottom - 25, 
-				60, 18, hWnd, IDOK, wndPtr->hInstance, 0L);
-			lpmb->hWndCancel = CreateWindow("BUTTON", ButtonText.Cancel.Label,
-				WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
-				rect.right / 2 + 5, rect.bottom - 25, 
-				60, 18, hWnd, IDCANCEL, wndPtr->hInstance, 0L);
-			break;
-		case MB_ABORTRETRYIGNORE :
-			lpmb->hWndYes = CreateWindow("BUTTON", ButtonText.Retry.Label,
-				WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
-				rect.right / 2 - 100, rect.bottom - 25, 
-				60, 18, hWnd, IDRETRY, wndPtr->hInstance, 0L);
-			lpmb->hWndNo = CreateWindow("BUTTON", ButtonText.Ignore.Label,
-				WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
-				rect.right / 2 - 30, rect.bottom - 25, 
-				60, 18, hWnd, IDIGNORE, wndPtr->hInstance, 0L);
-			lpmb->hWndCancel = CreateWindow("BUTTON", ButtonText.Abort.Label,
-				WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
-				rect.right / 2 + 40, rect.bottom - 25, 
-				60, 18, hWnd, IDABORT, wndPtr->hInstance, 0L);
-			break;
-		case MB_YESNO :
-			lpmb->hWndYes = CreateWindow("BUTTON", ButtonText.Yes.Label,
-				WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
-				rect.right / 2 - 65, rect.bottom - 25, 
-				60, 18, hWnd, IDYES, wndPtr->hInstance, 0L);
-			lpmb->hWndNo = CreateWindow("BUTTON", ButtonText.No.Label,
-				WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
-				rect.right / 2 + 5, rect.bottom - 25, 
-				60, 18, hWnd, IDNO, wndPtr->hInstance, 0L);
-			break;
-		case MB_YESNOCANCEL :
-			lpmb->hWndYes = CreateWindow("BUTTON", ButtonText.Yes.Label,
-				WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
-				rect.right / 2 - 100, rect.bottom - 25, 
-				60, 18, hWnd, IDYES, wndPtr->hInstance, 0L);
-			lpmb->hWndNo = CreateWindow("BUTTON", ButtonText.No.Label,
-				WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
-				rect.right / 2 - 30, rect.bottom - 25, 
-				60, 18, hWnd, IDNO, wndPtr->hInstance, 0L);
-			lpmb->hWndCancel = CreateWindow("BUTTON", ButtonText.Cancel.Label,
-				WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | BS_PUSHBUTTON,
-				rect.right / 2 + 40, rect.bottom - 25, 
-				60, 18, hWnd, IDCANCEL, wndPtr->hInstance, 0L);
-			break;
-		}
-	    switch(lpmb->wType & MB_ICONMASK) {
-		case MB_ICONEXCLAMATION:
-			printf("MsgBox LoadIcon Exclamation !\n");
-			lpmb->hIcon = LoadIcon((HINSTANCE)NULL, IDI_EXCLAMATION);
-			break;
-		case MB_ICONQUESTION:
-			printf("MsgBox LoadIcon Question !\n");
-			lpmb->hIcon = LoadIcon((HINSTANCE)NULL, IDI_QUESTION);
-			break;
-		case MB_ICONASTERISK:
-			printf("MsgBox LoadIcon Asterisk !\n");
-			lpmb->hIcon = LoadIcon((HINSTANCE)NULL, IDI_ASTERISK);
-			break;
-		case MB_ICONHAND:
-			printf("MsgBox LoadIcon Hand !\n");
-			lpmb->hIcon = LoadIcon((HINSTANCE)NULL, IDI_HAND);
-			break;
-			}
-	    if (lpmb->hIcon != (HICON)NULL) {
-			SetRect(&lpmb->rectIcon, 16,
-			lpmb->rectStr.bottom / 2 - 16, 48,
-			lpmb->rectStr.bottom / 2 + 16);
-			lpmb->rectStr.left += 64;
-			}
-	    break;
-	case WM_SHOWWINDOW:
-		dprintf_msgbox(stddeb, "MessageBox WM_SHOWWINDOW hWnd=%04X !\n", hWnd);
-		if (!(wParam == 0 && lParam == 0L)) {
-			InvalidateRect(hWnd, NULL, TRUE);
-			}
-	    break;
-	case WM_PAINT:
-		dprintf_msgbox(stddeb, "MessageBox WM_PAINT hWnd=%04X !\n", hWnd);
-		lpmb = MsgBoxGetStorageHeader(hWnd);
-		if (lpmb == NULL) break;
-		if (!lpmb->ActiveFlg) break;
-		hDC = BeginPaint(hWnd, &ps);
-		if (hDC == 0) {
-			printf("MessageBox WM_PAINT // BeginPaint returned BAD hDC !\n");
-			break;
-			}
-		GetClientRect(hWnd, &rect);
-		FillRect(hDC, &rect, GetStockObject(WHITE_BRUSH));
-		CopyRect(&rect, &lpmb->rectStr);
-		OldTextColor = SetTextColor(hDC, 0x00000000);
-		if (lpmb->hIcon) 
-			DrawIcon(hDC, lpmb->rectIcon.left,
-				lpmb->rectIcon.top, lpmb->hIcon);
-		DrawText(hDC, lpmb->Str, -1, &rect, 
-			DT_CALCRECT | DT_LEFT | DT_VCENTER | DT_WORDBREAK);
-		rect.top = lpmb->rectStr.bottom / 2 - rect.bottom / 2;
-		rect.bottom = lpmb->rectStr.bottom / 2 + rect.bottom / 2;
-		DrawText(hDC, lpmb->Str, -1, &rect, DT_LEFT | DT_VCENTER | DT_WORDBREAK);
-		SetTextColor(hDC, OldTextColor);
-		EndPaint(hWnd, &ps);
-		dprintf_msgbox(stddeb, "MessageBox End of WM_PAINT !\n");
-		break;
-	case WM_DESTROY:
-	    dprintf_msgbox(stddeb, "MessageBox WM_DESTROY !\n");
-	    ReleaseCapture();
-	    lpmb = MsgBoxGetStorageHeader(hWnd);
-		if (lpmb == NULL) break;
-	    if (lpmb->hIcon) DestroyIcon(lpmb->hIcon);
-	    if (lpmb->hWndYes) DestroyWindow(lpmb->hWndYes);
-	    if (lpmb->hWndNo) DestroyWindow(lpmb->hWndNo);
-	    if (lpmb->hWndCancel) DestroyWindow(lpmb->hWndCancel);
-	    dprintf_msgbox(stddeb, "MessageBox WM_DESTROY end !\n");
-	    lpmb->ActiveFlg = FALSE;
-	    break;
-	case WM_COMMAND:
-	    lpmb = MsgBoxGetStorageHeader(hWnd);
-		if (lpmb == NULL) break;
-	    if (wParam < IDOK || wParam > IDNO) return(0);
-	    lpmb->wRetVal = wParam;
-	    dprintf_msgbox(stddeb, "MessageBox sending WM_CLOSE !\n");
-	    PostMessage(hWnd, WM_CLOSE, 0, 0L);
-	    break;
-	case WM_CHAR:
-	    lpmb = MsgBoxGetStorageHeader(hWnd);
-/*          if (wParam >= 'a' || wParam <= 'z') wParam -= 'a' - 'A'; */
-		wParam = toupper(wParam);
-	    if (wParam == ButtonText.Yes.Hotkey)
-                lpmb->wRetVal = IDYES;
-            else if (wParam == ButtonText.Ok.Hotkey)
-                lpmb->wRetVal = IDOK;
-            else if (wParam == ButtonText.Retry.Hotkey)
-                lpmb->wRetVal = IDRETRY;
-            else if (wParam == ButtonText.Abort.Hotkey)
-                lpmb->wRetVal = IDABORT;
-            else if (wParam == ButtonText.No.Hotkey)
-                lpmb->wRetVal = IDNO;
-            else if (wParam == ButtonText.Ignore.Hotkey)
-                 lpmb->wRetVal = IDIGNORE;
-            else if ((wParam == ButtonText.Ok.Hotkey) || (wParam == VK_ESCAPE))
-                lpmb->wRetVal = IDCANCEL;
-	    else
-		return 0;
-		if (lpmb == NULL) break;
-		ShowWindow(hWnd, SW_HIDE);
-		PostMessage(hWnd, WM_CLOSE, 0, 0L);
-		break;
-	default:
-	    return DefWindowProc(hWnd, message, wParam, lParam );
-    }
-return(0);
-}
-
-
-
-/*************************************************************************
- *			"About Wine..." Dialog Box
- */
-BOOL FAR PASCAL AboutWine_Proc(HWND hDlg, WORD msg, WORD wParam, LONG lParam)
-{
-    HDC  	hDC;
-    HDC		hMemDC;
-    PAINTSTRUCT ps;
-    RECT 	rect;
-    BITMAP	bm;
-    OFSTRUCT	ofstruct;
-    HBITMAP     hbmpOld;
-    static LPSTR	ptr;
-    static char 	str[256];
-    static HBITMAP	hBitMap = 0;
-    static BOOL		CreditMode;
-    static HANDLE	hFile = 0;
-    switch (msg) {
-    case WM_INITDIALOG:
-	CreditMode = FALSE;
-	strcpy(str, "WINELOGO");
-	hBitMap = LoadBitmap((HINSTANCE)NULL, (LPSTR)str);
-
-	strcpy(str, "LICENSE");
-	printf("str = '%s'\n", str);
-	hFile = OpenFile((LPSTR)str, &ofstruct, OF_READ);
-	ptr = (LPSTR)malloc(2048);
-	lseek(hFile, 0L, SEEK_SET);
-	_lread(hFile, ptr, 2000L);
-	close(hFile);
-	return TRUE;
-    case WM_PAINT:
-	hDC = BeginPaint(hDlg, &ps);
-	GetClientRect(hDlg, &rect);
-	if (CreditMode) {
-	    FillRect(hDC, &rect, GetStockObject(WHITE_BRUSH));
-	    InflateRect(&rect, -8, -8);
-	    DrawText(hDC, ptr, -1, &rect, DT_LEFT | DT_WORDBREAK);
-	    EndPaint(hDlg, &ps);
-	    return TRUE;
-	    }
-	FillRect(hDC, &rect, GetStockObject(GRAY_BRUSH));
-	InflateRect(&rect, -3, -3);
-	FrameRect(hDC, &rect, GetStockObject(BLACK_BRUSH));
-	InflateRect(&rect, -10, -10);
-	hMemDC = CreateCompatibleDC(hDC);
-	hbmpOld = SelectObject(hMemDC, hBitMap);
-	GetObject(hBitMap, sizeof(BITMAP), (LPSTR)&bm);
-	BitBlt(hDC, rect.left, rect.top, bm.bmWidth, bm.bmHeight, 
-					hMemDC, 0, 0, SRCCOPY);
-        SelectObject( hMemDC, hbmpOld );
-	DeleteDC(hMemDC);
-	EndPaint(hDlg, &ps);
-	return TRUE;
-    case WM_COMMAND:
-	switch (wParam)
-	    {
-	    case IDYES:
-		if (!CreditMode) {
-		    SetWindowPos(hDlg, (HWND)NULL, 0, 0, 640, 480, 
-				SWP_NOMOVE | SWP_NOZORDER);
-		    }
-		else {
-		    SetWindowPos(hDlg, (HWND)NULL, 0, 0, 320, 250, 
-				SWP_NOMOVE | SWP_NOZORDER);
-		    }
-		CreditMode = !CreditMode;
-		ShowWindow(GetDlgItem(hDlg, IDYES), CreditMode ? SW_HIDE : SW_SHOW);
-		ShowWindow(GetDlgItem(hDlg, IDOK), CreditMode ? SW_HIDE : SW_SHOW);
-		InvalidateRect(hDlg, (LPRECT)NULL, TRUE);
-		UpdateWindow(hDlg);
-		return TRUE;
-	    case IDCANCEL:
-	    case IDOK:
-                if (hBitMap != 0 ) DeleteObject(hBitMap);
-		if (ptr != NULL) free(ptr);
-		EndDialog(hDlg, TRUE);
-		return TRUE;
-	    default:
-		return TRUE;
-	    }
-    }
-return FALSE;
-}
-
-
-/**************************************************************************
- *			FatalAppExit  [USER.137]
- */
-
-void FatalAppExit(WORD wAction, LPSTR str)
-{
-MessageBox((HWND)NULL, str, NULL, MB_SYSTEMMODAL | MB_OK);
-exit(1);
-}
diff --git a/misc/profile.c b/misc/profile.c
index 9796d49..a1bce12 100644
--- a/misc/profile.c
+++ b/misc/profile.c
@@ -106,7 +106,7 @@
 
 
     state = FirstBrace;
-    while ((c = getc (f)) != EOF){
+    while ((c = fgetc (f)) != EOF){
 	if (c == '\r')		/* Ignore Carriage Return */
 	    continue;
 	
@@ -188,7 +188,7 @@
 	    
 	} /* switch */
 	
-    } /* while ((c = getc (f)) != EOF) */
+    } /* while ((c = fgetc (f)) != EOF) */
     return SecHeader;
 }
 
diff --git a/misc/shell.c b/misc/shell.c
index f6a8db6..bab7b02 100644
--- a/misc/shell.c
+++ b/misc/shell.c
@@ -6,11 +6,12 @@
 #include <string.h>
 #include <unistd.h>
 #include "windows.h"
-#include "library.h"
 #include "shell.h"
 #include "neexe.h"
 #include "selectors.h"
 #include "../rc/sysres.h"
+#include "dlgs.h"
+#include "dialog.h"
 #include "stddebug.h"
 /* #define DEBUG_REG */
 #include "debug.h"
@@ -312,7 +313,7 @@
  */
 void DragAcceptFiles(HWND hWnd, BOOL b)
 {
-	dprintf_reg(stdnimp, "DragAcceptFiles : Empty Stub !!!\n");
+	fprintf(stdnimp, "DragAcceptFiles : Empty Stub !!!\n");
 }
 
 
@@ -321,7 +322,7 @@
  */
 void DragQueryFile(HDROP h, UINT u, LPSTR u2, UINT u3)
 {
-	dprintf_reg(stdnimp, "DragQueryFile : Empty Stub !!!\n");
+	fprintf(stdnimp, "DragQueryFile : Empty Stub !!!\n");
 
 }
 
@@ -331,8 +332,7 @@
  */
 void DragFinish(HDROP h)
 {
-	dprintf_reg(stdnimp, "DragFinish : Empty Stub !!!\n");
-
+	fprintf(stdnimp, "DragFinish : Empty Stub !!!\n");
 }
 
 
@@ -341,7 +341,7 @@
  */
 BOOL DragQueryPoint(HDROP h, POINT FAR *p)
 {
-	dprintf_reg(stdnimp, "DragQueryPoinyt : Empty Stub !!!\n");
+	fprintf(stdnimp, "DragQueryPoint : Empty Stub !!!\n");
         return FALSE;
 }
 
@@ -351,12 +351,14 @@
  */
 HINSTANCE ShellExecute(HWND hWnd, LPCSTR lpOperation, LPCSTR lpFile, LPCSTR lpParameters, LPCSTR lpDirectory, int iShowCmd)
 {
-	dprintf_reg(stdnimp, "ShellExecute // hWnd=%04X\n", hWnd);
-	dprintf_reg(stdnimp, "ShellExecute // lpOperation='%s'\n", lpOperation);
-	dprintf_reg(stdnimp, "ShellExecute // lpFile='%s'\n", lpFile);
-	dprintf_reg(stdnimp, "ShellExecute // lpParameters='%s'\n", lpParameters);
-	dprintf_reg(stdnimp, "ShellExecute // lpDirectory='%s'\n", lpDirectory);
-	dprintf_reg(stdnimp, "ShellExecute // iShowCmd=%04X\n", iShowCmd);
+        fprintf(stdnimp, "ShellExecute: empty stub\n");
+        return 2;
+	fprintf(stdnimp, "ShellExecute // hWnd=%04X\n", hWnd);  
+	fprintf(stdnimp, "ShellExecute // lpOperation='%s'\n", lpOperation);
+	fprintf(stdnimp, "ShellExecute // lpFile='%s'\n", lpFile);
+	fprintf(stdnimp, "ShellExecute // lpParameters='%s'\n", lpParameters);
+	fprintf(stdnimp, "ShellExecute // lpDirectory='%s'\n", lpDirectory);
+	fprintf(stdnimp, "ShellExecute // iShowCmd=%04X\n", iShowCmd);
 	return 2; /* file not found */
 }
 
@@ -366,58 +368,57 @@
  */
 HINSTANCE FindExecutable(LPCSTR lpFile, LPCSTR lpDirectory, LPSTR lpResult)
 {
-	dprintf_reg(stdnimp, "FindExecutable : Empty Stub !!!\n");
+	fprintf(stdnimp, "FindExecutable : Empty Stub !!!\n");
         return 0;
 }
 
-char AppName[256], AppMisc[256];
-INT AboutDlgProc(HWND hWnd, WORD msg, WORD wParam, LONG lParam);
-
-/*************************************************************************
- *				ShellAbout		[SHELL.22]
- */
-INT ShellAbout(HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff, HICON hIcon)
-{
-/*	fprintf(stderr, "ShellAbout ! (%s, %s)\n", szApp, szOtherStuff);*/
-
-	if (szApp)
-		strcpy(AppName, szApp);
-	else
-		*AppName = 0;
-
-	if (szOtherStuff)
-		strcpy(AppMisc, szOtherStuff);
-	else
-		*AppMisc = 0;
-
-	return DialogBoxIndirectPtr( GetWindowWord(hWnd, GWW_HINSTANCE),
-                                     sysres_DIALOG_SHELL_ABOUT_MSGBOX,
-                                     hWnd, GetWndProcEntry16("AboutDlgProc"));
-}
-
+static char AppName[512], AppMisc[512];
 
 /*************************************************************************
  *				AboutDlgProc		[SHELL.33]
  */
 INT AboutDlgProc(HWND hWnd, WORD msg, WORD wParam, LONG lParam)
 {
-	char temp[256];
+  switch(msg) {
+   case WM_INITDIALOG:
+    SendDlgItemMessage(hWnd,stc1,STM_SETICON,LOWORD(lParam),0);
+    SetWindowText(hWnd, AppName);
+    SetWindowText(GetDlgItem(hWnd,100), AppMisc);
+    return 1;
+    
+   case WM_COMMAND:
+    switch (wParam) {
+     case IDOK:
+      EndDialog(hWnd, TRUE);
+      return TRUE;
+    }
+    break;
+  }
+  return FALSE;
+}
 
-	switch(msg) {
-        case WM_INITDIALOG:
-		sprintf(temp, "About %s", AppName);
-		SetWindowText(hWnd, temp);
-                SetWindowText(GetDlgItem(hWnd,100), AppMisc );
-		break;
-
-        case WM_COMMAND:
-		switch (wParam) {
-		case IDOK:
-			EndDialog(hWnd, TRUE);
-			return TRUE;
-		}
-	}
-	return FALSE;
+/*************************************************************************
+ *				ShellAbout		[SHELL.22]
+ */
+INT ShellAbout(HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff, HICON hIcon)
+{
+  if (szApp) {
+    sprintf(AppName, "About %s", szApp);
+  } else  {
+    *AppName = 0;
+  }
+  if (szOtherStuff) {
+    strcpy(AppMisc, szOtherStuff);
+  } else {
+    *AppMisc = 0;
+  }
+  if (!hIcon) {
+    hIcon = LoadIcon(0,MAKEINTRESOURCE(OIC_WINEICON));
+  }
+  return DialogBoxIndirectParamPtr(GetWindowWord(hWnd, GWW_HINSTANCE),
+				   sysres_DIALOG_SHELL_ABOUT_MSGBOX,
+				   hWnd, GetWndProcEntry16("AboutDlgProc"),
+				   hIcon);
 }
 
 /*************************************************************************
@@ -425,24 +426,23 @@
  */
 HICON ExtractIcon(HINSTANCE hInst, LPCSTR lpszExeFileName, UINT nIconIndex)
 {
-	int		count;
 	HICON	hIcon = 0;
 	HINSTANCE hInst2 = hInst;
 	dprintf_reg(stddeb, "ExtractIcon(%04X, '%s', %d\n", 
 			hInst, lpszExeFileName, nIconIndex);
 	if (lpszExeFileName != NULL) {
 		hInst2 = LoadLibrary(lpszExeFileName);
-		}
+	}
 	if (hInst2 != 0 && nIconIndex == (UINT)-1) {
 #if 0
 		count = GetRsrcCount(hInst2, NE_RSCTYPE_GROUP_ICON);
 		dprintf_reg(stddeb, "ExtractIcon // '%s' has %d icons !\n", lpszExeFileName, count);
 		return (HICON)count;
 #endif
-		}
+	}
 	if (hInst2 != hInst && hInst2 != 0) {
 		FreeLibrary(hInst2);
-		}
+	}
 	return hIcon;
 }
 
@@ -452,8 +452,20 @@
  */
 HICON ExtractAssociatedIcon(HINSTANCE hInst,LPSTR lpIconPath, LPWORD lpiIcon)
 {
-	dprintf_reg(stdnimp, "ExtractAssociatedIcon : Empty Stub !!!\n");
-        return 0;
+    dprintf_reg(stdnimp, "ExtractAssociatedIcon : Empty Stub !!!\n");
+    return 0;
+}
+
+/*************************************************************************
+ *              DoEnvironmentSubst      [SHELL.37]
+ * I couldn't find any reference, so even the number of bytes on the
+ * stack might be wrong
+ */
+WORD DoEnvironmentSubst(LPSTR a,WORD b,WORD c)
+{
+    printf(stderr, "DoEnvironmentSubst: Unknown argument count\n");
+    dprintf_reg(stdnimp, "DoEnvironmentSubst %x %x %x\n",a,b,c);
+    return 0;
 }
 
 /*************************************************************************
diff --git a/misc/spy.c b/misc/spy.c
index f121b18..524392c 100644
--- a/misc/spy.c
+++ b/misc/spy.c
@@ -156,10 +156,12 @@
     "WM_INITMENU",              /* 0x0116 */
     "WM_INITMENUPOPUP",         /* 0x0117 */
     "WM_SYSTIMER",		/* 0x0118 */
-    NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+    NULL, NULL, NULL, NULL, NULL, NULL,
+    "WM_MENUSELECT",            /* 0x011f */
 
-    /* 0x0120 */
-    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+    "WM_MENUCHAR",              /* 0x0120 */
+    "WM_ENTERIDLE",             /* 0x0121 */
+    NULL, NULL, NULL, NULL, NULL, NULL,
     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 
     /* 0x0130 */
@@ -227,16 +229,23 @@
     NULL, NULL, NULL, NULL, NULL, NULL,
 
     "WM_PARENTNOTIFY",		/* 0x0210 */
-
-    NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+    "WM_ENTERMENULOOP",         /* 0x0211 */
+    "WM_EXITMENULOOP",          /* 0x0212 */
+    NULL, NULL, NULL, NULL, NULL,
     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 
-    /* 0x0220 */
-    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+    "WM_MDICREATE",             /* 0x0220 */
+    "WM_MDIDESTROY",            /* 0x0221 */
+    "WM_MDIACTIVATE",           /* 0x0222 */
+    "WM_MDIRESTORE",            /* 0x0223 */
+    "WM_MDINEXT",               /* 0x0224 */
+    "WM_MDIMAXIMIZE",           /* 0x0225 */
+    "WM_MDITILE",               /* 0x0226 */
+    "WM_MDICASCADE",            /* 0x0227 */
+    "WM_MDIICONARRANGE",        /* 0x0228 */
+    "WM_MDIGETACTIVE",          /* 0x0229 */
 
-    
-    NULL,			/* 0x0230 */
+    "WM_MDISETMENU",            /* 0x0230 */
     "WM_ENTERSIZEMOVE",		/* 0x0231 */
     "WM_EXITSIZEMOVE"		/* 0x0232 */
 };
diff --git a/misc/user.c b/misc/user.c
index e68f443..d9bf1d8 100644
--- a/misc/user.c
+++ b/misc/user.c
@@ -92,16 +92,27 @@
  */
 int USER_InitApp(int hInstance)
 {
+    extern BOOL WIDGETS_Init(void);
+
+    static int firstTask = 1;
     int queueSize;
 
+    if (firstTask)
+    {
+        /* Perform global initialisations that need a task context */
+
+          /* Initialize built-in window classes */
+        if (!WIDGETS_Init()) return 0;
+
+          /* Create desktop window */
+        if (!WIN_CreateDesktopWindow()) return 0;
+
+        firstTask = 0;
+    }
+
       /* Create task message queue */
     queueSize = GetProfileInt( "windows", "DefaultQueueSize", 8 );
     if (!SetMessageQueue( queueSize )) return 0;
 
-#ifndef WINELIB
-    /* Initialize DLLs */
-    InitializeLoadedDLLs(NULL);
-#endif
-        
     return 1;
 }
diff --git a/misc/winsocket.c b/misc/winsocket.c
index 551ac41..ee95375 100644
--- a/misc/winsocket.c
+++ b/misc/winsocket.c
@@ -36,6 +36,9 @@
 	WORD	wMsg;
 	LONG	lParam;
 };
+
+#pragma pack(1)
+
 #define IPC_PACKET_SIZE (sizeof(struct ipc_packet) - sizeof(long))
 #define MTYPE 0xb0b0eb05
 #define WINE_PACKED __attribute__ ((packed))
@@ -82,6 +85,8 @@
 };
 static struct WinSockHeap *heap;
 
+#pragma pack(4)
+
 #define dump_sockaddr(a) \
 	fprintf(stderr, "sockaddr_in: family %d, address %s, port %d\n", \
 			((struct sockaddr_in *)a)->sin_family, \