Release 960131

Wed Jan 31 10:58:00 1996  Alexandre Julliard  <julliard@sunsite.unc.edu>

	* [configure.in]
	Added --with-dll option to build libwine.so.

	* [controls/listbox.c]
	Fixed ListBoxDirectory(), DlgDirSelect() and
	DlgDirList(). Hopefully their behavior is correct now.

	* [controls/menu.c]
	Use SEGPTRs in ChangeMenu(), InsertMenu(), AppendMenu() and
 	ModifyMenu() for the item data, to avoid corrupting the pointer
 	for owner-drawn items.

	* [controls/static.c]
	Attempt to load OEM icons for SS_ICON controls. Probably not
	entirely correct.
	Don't clip the text output.

	* [files/directory.c]
	Add temp dir and Windows dir to environment.

	* [files/dos_fs.c]
	Fixed a few path handling bugs in DOSFS_GetUnixFileName().
	Cache last used directory in DOSFS_FindNext() to avoid quadratic
	search time.

	* [files/drive.c]
	New format for drives configuration in wine.conf; allows
	specifying the type, label and serial number of a drive.

	* [files/file.c]
	New function FILE_OpenUnixFile to make sure we don't open a
	directory instead of a file.
	Fixed DOSFS_GetUnixFileName() check_last flag in FILE_MakeDir().

	* [files/profile.c]
	Rewrote profile handling. Should be closer to Windows behavior now.
	New function PROFILE_GetWineIniString() to get a string from wine.conf.
	Support environment variables in wine.conf.

	* [loader/task.c]
	Fixed the order of deletion in TASK_DeleteTask() to avoid memory
	corruption.

	* [memory/global.c]
	Create a discarded block on GlobalAlloc() if the size is 0; thanks
	to John Harvey for noticing this.

	* [memory/local.c]
	LOCAL_GetHeap: make sure the pointer is valid before checking
	magic number.

	* [misc/main.c]
	Moved profile and registry saving to ExitWindows(), so we don't
	try to save them in case of a crash.

	* [miscemu/int21.c]
	INT21_GetFreeDiskSpace: try to compute the cluster size from the
	filesystem size instead of hard-coding it to 64.
	Fixed functions 0x3f and 0x40 to use _hread and _hwrite to allow
	reading or writing 65535 bytes (thanks to Bruce Milner for this	one).

	* [windows/message.c]
	Fixed bug in linked-list handling in MSG_DeleteQueue().
	Simplified SetMessageQueue().

	* [wine.ini] [wine.man]
	Updated for new drives configuration format.

Tue Jan 30 11:24:46 1996  William Magro  <wmagro@tc.cornell.edu>

	* [controls/edit.c]
	Implemented ES_PASSWORD style, EM_SETPASSWORDCHAR and
 	EM_GETPASSWORDCHAR messages.

	* [controls/widgets.c]
	Adjusted class creation flags to better match values Windows uses.

	* [include/windows.h]
	Fixed ES_NOHIDESEL typo.

	* [loader/ne_image.c]
	Added detection for zero offset in RADDR fixups. Quicken
	was in an infinite loop here.

Mon Jan 29 20:12:22 1996  Albrecht Kleine  <kleine@ak.sax.de>

	* [files/dos_fs.c]
	Bugfix: range error in month value (0..11 set to 1..12).

	* [windows/caret.c]
	Changed ROP2-mode to R2_NOTXORPEN in CARET_Callback for pulsed
 	appearance of the caret.

	* [windows/mdi.c] [include/mdi.h]
	Changed MDITile(): added a new parameter WORD wParam for
 	WM_MDITILE second tiling method (MDITILE_HORIZONTAL in wParam) as
 	used in Win3.1

Sun Jan 28 14:20:00 1996  Cameron Heide  <heide@ee.ualberta.ca>

	* [miscemu/int2f.c]
	Added a small bit of MSCDEX emulation.

	* [windows/alias.c]
	ALIAS_RegisterAlias was returning the hash value when it should
 	have been returning the record number.
	
Sat Jan 27 10:53:51 1996  Jim Peterson <jspeter@birch.ee.vt.edu>

	* [include/shell.h] [include/wintypes.h]
	Moved definition of HKEY and LPHKEY types to include/wintypes.h.
	Declared FONTENUMPROC in wintypes.h.

	* [include/windows.h]
	Added definition of KERNINGPAIR and LPKERNINGPAIR types.  Added
	declarations for CopyCursor(), CopyIcon(), EnumFontFamilies(),
	ExtractIcon(), FatalAppExit(), FindExecutable(), GetClipCursor(),
	GetKerningPairs(), GetQueueStatus(), GetRasterizerCaps(),
	IsGDIObject(), IsMenu(), IsTask(), RegCloseKey(), RegCreateKey(),
	RegDeleteKey(), RegEnumKey(), RegOpenKey(), RegQueryValue(),
	RegSetValue(), ResetDC(), ShellExecute(), SystemParametersInfo(),
	and wsprintf().

	* [tools/makehtml.pl] [documentation/apiw.index]
	New files that scan windows.h, commdlg.h, and toolhelp.h and output
	an HTML sorted list with optional links to www.willows.com and a
	tally of unimplemented APIW functions.

	* [objects/cursoricon.c]
	Added Win32 versions of CopyIcon() and CopyCursor() for use in
	libwine.

	* [win32/resource.c] [win32/winprocs.c]
	Added '#include "libres.h"' and explicit declarations of windows
	procs in order to avoid warnings.

	* [windows/utility.c]
	Added Win32 version of MulDiv() for libwine.

	* [*/*] [include/windows.h]
	Changed several function declarations to comply more strictly to
	the windows API (without, hopefully, altering their functionality).

	* [controls/menu.c]
	Made the return value of CheckMenuItem be the previous state of
 	the menu item if it was found, otherwise -1 as specified in the
 	SDK. This conflicts with the APIW specification, which says it
 	should return TRUE if successful, otherwise FALSE.

	* [include/windows.h]
	Added obsolete WM_SIZE message wParam names for compatibility.
  	Added WinHelp() command constants, even though they are not yet
 	supported.

	* [rc/winerc.c]
	Tidied up transform_binary_file().  In argument checking, flattened
	any invalid characters specified with the prefix argument.

	* [library/libres.c]
	Made FindResource() case-insensitive when parameter 'name' is a string.

Sat Jan 27 02:30 1996  Uwe Bonnes <bon@elektron.ikp.physik.th-darmstadt.de

	* [files/drive.c]
	If root "/" is given in wine.conf, use it as last resort.

	* [files/file.c]
	Report ER_AccessDenied it disk ist not writable
	More Debug Output

	* [miscemu/int21.c]
	Squeezed some bugs in ExtendedOpenCreateFile
	
	* [windows/winpos.c]
	Some windows may not be moved or resized. We are missing some
	structures to be exact, but the approach should help in some cases
	and make things worse in much fewer.

Fri Jan 26 10:24:00 1996  Thomas Sandford <t.d.g.sandford@prds-grn.demon.co.uk>

	* [loader/pe_image.c]
	fixup_imports: Find builtins for Borland style entries, too

Fri Jan 26 10:24:00 1996  Martin von Loewis <loewis@informatik.hu-berlin.de>

	* [controls/menu.c]
	LoadMenu: branch to Win32 for PE modules

	* [if1632/gdi.spec][if1632/kernel32.spec][if1632/user32.spec]
	DeleteObject, GetPixel, SetPixel,WritePrivateProfileStringA,
	WriteProfileStringA, EmptyClipboard, EnableMenuItem, EnableScrollBar,
	EnableWindow, InvalidateRect, SetWindowTextA, WinHelpA: new relays
	DrawTextA, MoveToEx, GetClientRect, InvalidateRect, LoadBitmapA/W,
	LoadAcceleratorsA/W, LoadMenu[Indirect]A/W, LoadStringA/W: changed
	to convert parameters or naming convention

	* [include/kernel32.h][include/wintypes.h]
	moved WCHAR, defined LPWSTR

	* [include/string32.h][win32/string32.c][include/struct32.h]
	New files

	* [loader/module.h]
	LoadModule: exit after returning from PE_LoadModule

	* [loader/pe_image.c]
	my_wcstombs: isascii does not work on Linux for Unicode
	PE_LoadImage: Handle directories

	* [misc/user32.c]
	USER32_RECT32to16, USER32_RECT16to32: new functions
	implemented new user32 relays

	* [misc/newfns.c]
	WIN32_WinHelpA: new function

	* [win32/param32.c]
	New file

	* [win32/resource.c]
	GetResDirEntry: added support for named entries
	WIN32_LoadAcceleratorsW: invoke *32 resource functions
	WIN32_LoadBitmapA: convert name to unicode if appropriate
	WIN32_ParseMenu: new function
	implemented new resource functions from user32.spec

Wed Jan 24 18:09:00 1996 Alex Korobka <alex@phm30.pharm.sunysb.edu>

	* [objects/cursoricon.c]
	GetIconId() and LoadIconHandler() functions.

	* [windows/mdi.c]
	Better maximization support, TranslateMDISysAccel() function, 
	misc improvements.

	* [windows/defwnd.c]
	Fix for WM_WINDOWPOSCHANGED message handler.

	* [windows/winpos.c]
	Rewrote WindowFromPoint() function.

Sun Jan 21 1996 17:05:09  Marcus Meissner <msmeissn@faui01.informatik.uni-erlangen.de>

	* [include/toolhelp.h] [misc/toolhelp.c]
	Added Notify(Un)Register, but no callbacks yet.

Fri Jan 19 01:43:37 1996 Victor Schneider <root@tailor.roman.org>

	* [Makefile.in]
	Added target for libwine.so.1.0.

	* [library/winmain.c]
	For WINELIBDLL, _WinMain just returns hInstance instead of calling
	WinMain().

	* [misc/main.c]
	For WINELIBDLL, renamed main() to _wine_main() for calling from the
	stub main function.

	* [library/winestub.c] (new file)
	Provides a stub main() function for using libwine.so.

Tue Jan 16 11:04:34 1996  Anand Kumria <akumria@ozemail.com.au>

	* [winsocket.c]
	Fix EPERM problem.

	* [global.c]
	Attempt to do some sanity checking in MemManInfo().

	* [Changelog]
	Fix changelog oversight for previous entry.
diff --git a/misc/Makefile.in b/misc/Makefile.in
index 7d0a546..b9939f3 100644
--- a/misc/Makefile.in
+++ b/misc/Makefile.in
@@ -6,7 +6,6 @@
 	comm.c \
 	commdlg.c \
 	compobj.c \
-	dos_fs.c \
 	driver.c \
 	exec.c \
 	escape.c \
@@ -20,14 +19,13 @@
 	olecli.c \
 	olesvr.c \
 	port.c \
-	profile.c \
 	rect.c \
 	shell.c \
 	sound.c \
 	spy.c \
 	stress.c \
+	toolhelp.c \
 	user.c \
-	user32.c \
 	winsocket.c \
 	xmalloc.c
 
diff --git a/misc/clipboard.c b/misc/clipboard.c
index 68f5fe7..41bab82 100644
--- a/misc/clipboard.c
+++ b/misc/clipboard.c
@@ -165,7 +165,7 @@
 /**************************************************************************
  *			CountClipboardFormats	[USER.143]
  */
-int CountClipboardFormats()
+INT CountClipboardFormats()
 {
     int FormatCount = 0;
     LPCLIPFORMAT lpFormat = ClipFormats; 
diff --git a/misc/comm.c b/misc/comm.c
index 107ec99..467912d 100644
--- a/misc/comm.c
+++ b/misc/comm.c
@@ -16,9 +16,9 @@
 #endif
 #include <unistd.h>
 
-#include "wine.h"
 #include "windows.h"
 #include "comm.h"
+#include "options.h"
 #include "stddebug.h"
 /* #define DEBUG_COMM */
 /* #undef  DEBUG_COMM */
@@ -40,11 +40,12 @@
 		option[3] = '1' + x;
 		option[4] = '\0';
 
-		GetPrivateProfileString("serialports", option, "*", temp, sizeof(temp), WINE_INI);
+		PROFILE_GetWineIniString( "serialports", option, "*",
+                                          temp, sizeof(temp) );
 		if (!strcmp(temp, "*") || *temp == '\0') 
 			COM[x].devicename = NULL;
 		else {
-		  	btemp = index(temp,',');
+		  	btemp = strchr(temp,',');
 			if (btemp != NULL) {
 			  	*btemp++ = '\0';
 				COM[x].baudrate = atoi(btemp);
@@ -69,7 +70,8 @@
 		option[3] = '1' + x;
 		option[4] = '\0';
 
-		GetPrivateProfileString("parallelports", option, "*", temp, sizeof(temp), WINE_INI);
+		PROFILE_GetWineIniString( "parallelports", option, "*",
+                                          temp, sizeof(temp) );
 		if (!strcmp(temp, "*") || *temp == '\0')
 			LPT[x].devicename = NULL;
 		else {
@@ -124,7 +126,7 @@
 		}
 }
 
-int BuildCommDCB(LPSTR device, DCB FAR *lpdcb)
+BOOL BuildCommDCB(LPCSTR device, LPDCB lpdcb)
 {
 	/* "COM1:9600,n,8,1"	*/
 	/*  012345		*/
@@ -219,7 +221,7 @@
 	return 0;
 }
 
-int OpenComm(LPSTR device, UINT cbInQueue, UINT cbOutQueue)
+int OpenComm(LPCSTR device, UINT cbInQueue, UINT cbOutQueue)
 {
 	int port, fd;
 
diff --git a/misc/dos_fs.c b/misc/dos_fs.c
deleted file mode 100644
index b01f6b0..0000000
--- a/misc/dos_fs.c
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * DOS-FS
- * NOV 1993 Erik Bos <erik@xs4all.nl>
- *
- * FindFile by Bob, hacked for dos & unixpaths by Erik.
- *
- * Bugfix by dash@ifi.uio.no: ToUnix() was called to often
- */
-
-#include <ctype.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <pwd.h>
-#include <dirent.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#if defined(__linux__) || defined(sun)
-#include <sys/vfs.h>
-#endif
-#if defined(__NetBSD__) || defined(__FreeBSD__)
-#include <sys/param.h>
-#include <sys/mount.h>
-#include <sys/errno.h>
-#endif
-#ifdef __svr4__
-#include <sys/statfs.h>
-#endif
-#include "wine.h"
-#include "windows.h"
-#include "msdos.h"
-#include "dos_fs.h"
-#include "comm.h"
-#include "task.h"
-#include "stddebug.h"
-#include "debug.h"
-#include "xmalloc.h"
-
-#define WINE_INI_USER "~/.winerc"
-
-
-static void ExpandTildeString(char *s)
-{
-    struct passwd *entry;
-    char temp[1024], *ptr = temp;
-	
-    strcpy(temp, s);
-
-    while (*ptr)
-    {
-	if (*ptr != '~') 
-	{ 
-	    *s++ = *ptr++;
-	    continue;
-	}
-
-	ptr++;
-
-	if ( (entry = getpwuid(getuid())) == NULL) 
-	{
-	    continue;
-	}
-
-	strcpy(s, entry->pw_dir);
-	s += strlen(entry->pw_dir);
-    }
-    *s = 0;
-}
-
-
-
-int DOS_GetFreeSpace(int drive, long *size, long *available)
-{
-    struct statfs info;
-    const char *root;
-
-    if (!DRIVE_IsValid(drive)) return 0;
-    root = DRIVE_GetRoot(drive);
-
-#ifdef __svr4__
-	if (statfs( root, &info, 0, 0) < 0) {
-#else
-	if (statfs( root, &info) < 0) {
-#endif
-		fprintf(stderr,"dosfs: cannot do statfs(%s)\n", root );
-		return 0;
-	}
-
-	*size = info.f_bsize * info.f_blocks;
-#ifdef __svr4__
-	*available = info.f_bfree * info.f_bsize;
-#else
-	*available = info.f_bavail * info.f_bsize;
-#endif
-	return 1;
-}
-
-/**********************************************************************
- *		WineIniFileName
- */
-char *WineIniFileName(void)
-{
-	int fd;
-	static char *filename = NULL;
-	static char name[256];
-
-	if (filename)
-		return filename;
-
-	strcpy(name, WINE_INI_USER);
-	ExpandTildeString(name);
-	if ((fd = open(name, O_RDONLY)) != -1) {
-		close(fd);
-		filename = name;
-		return filename;
-	}
-	if ((fd = open(WINE_INI_GLOBAL, O_RDONLY)) != -1) {
-		close(fd);
-		filename = WINE_INI_GLOBAL;
-		return filename;
-	}
-	fprintf(stderr,"wine: can't open configuration file %s or %s !\n",
-		WINE_INI_GLOBAL, WINE_INI_USER);
-	exit(1);
-}
-
diff --git a/misc/exec.c b/misc/exec.c
index 1235661..5c49487 100644
--- a/misc/exec.c
+++ b/misc/exec.c
@@ -9,6 +9,7 @@
 #include <unistd.h>
 #include "neexe.h"
 #include "dlls.h"
+#include "shell.h"
 #include "windows.h"
 #include "callback.h"
 #include "stddebug.h"
@@ -41,6 +42,11 @@
     dprintf_exec( stdnimp,"PARTIAL STUB ExitWindows(%08lX, %04X)\n", 
                   dwReturnCode, wReserved);
 
+    /* Do the clean-up stuff */
+
+    WriteOutProfiles();
+    SHELL_SaveRegistry();
+
     exit( LOWORD(dwReturnCode) );
 }
 
diff --git a/misc/lstr.c b/misc/lstr.c
index 5f7c90a..5bc9032 100644
--- a/misc/lstr.c
+++ b/misc/lstr.c
@@ -106,7 +106,7 @@
 }
 
 /* KERNEL.353 32-bit version*/
-char *lstrcpyn( char *dst, const char *src, int n )
+LPSTR lstrcpyn( LPSTR dst, LPCSTR src, int n )
 {
     char *tmp = dst;
     while(n-- > 1 && *src)
@@ -293,7 +293,7 @@
 }
 
 /* AnsiToOemBuff Keyboard.134 */
-void AnsiToOemBuff(LPSTR lpAnsiStr, LPSTR lpOemStr, INT nLength)
+void AnsiToOemBuff(LPCSTR lpAnsiStr, LPSTR lpOemStr, UINT nLength)
 {
   int i;
   for(i=0;i<nLength;i++)
diff --git a/misc/main.c b/misc/main.c
index 0d9e948..b445865 100644
--- a/misc/main.c
+++ b/misc/main.c
@@ -524,29 +524,20 @@
 }
 
 
-#ifdef MALLOC_DEBUGGING
-static void malloc_error()
-{
-       fprintf(stderr,"malloc is not feeling well. Good bye\n");
-       exit(1);
-}
-#endif  /* MALLOC_DEBUGGING */
-
-
 static void called_at_exit(void)
 {
-    extern void sync_profiles(void);
-
-    sync_profiles();
     MAIN_RestoreSetup();
     WSACleanup();
-    SHELL_SaveRegistry();
 }
 
 /***********************************************************************
  *           main
  */
+#if defined(WINELIB) && defined(WINELIBDLL)
+int _wine_main (int argc, char *argv[])
+#else
 int main( int argc, char *argv[] )
+#endif
 {    
     int ret_val;
     int depth_count, i;
@@ -555,6 +546,21 @@
 
     extern int _WinMain(int argc, char **argv);
 
+#ifdef MALLOC_DEBUGGING
+    char *trace;
+
+    mcheck(NULL);
+    if (!(trace = getenv("MALLOC_TRACE")))
+    {       
+        fprintf( stderr, "MALLOC_TRACE not set. No trace generated\n" );
+    }
+    else
+    {
+        fprintf( stderr, "malloc trace goes to %s\n", trace );
+        mtrace();
+    }
+#endif
+
     setbuf(stdout,NULL);
     setbuf(stderr,NULL);
 
@@ -566,22 +572,6 @@
     
     MAIN_ParseOptions( &argc, argv );
 
-#ifdef MALLOC_DEBUGGING
-    if(debugging_malloc)
-    {
-       char *trace=getenv("MALLOC_TRACE");
-       if(!trace)
-       {       
-       	dprintf_malloc(stddeb,"MALLOC_TRACE not set. No trace generated\n");
-       }else
-       {
-               dprintf_malloc(stddeb,"malloc trace goes to %s\n",trace);
-               mtrace();
-       }
-      mcheck(malloc_error);
-    }
-#endif
-
     SHELL_Init();
     SHELL_LoadRegistry();
 
@@ -816,7 +806,7 @@
 /***********************************************************************
  *	SystemParametersInfo (USER.483)
  */
-BOOL SystemParametersInfo (UINT uAction, UINT uParam, void FAR *lpvParam, UINT fuWinIni)
+BOOL SystemParametersInfo (UINT uAction, UINT uParam, LPVOID lpvParam, UINT fuWinIni)
 {
 	int timeout, temp;
 	char buffer[256];
@@ -957,7 +947,7 @@
 /***********************************************************************
 *	HMEMCPY (KERNEL.348)
 */
-void hmemcpy(void FAR *hpvDest, const void FAR *hpvSource, long cbCopy)
+void hmemcpy(LPVOID hpvDest, LPCVOID hpvSource, LONG cbCopy)
 {
 	memcpy(hpvDest,	hpvSource, cbCopy);
 }
diff --git a/misc/port.c b/misc/port.c
index 52ac9d9..751750c 100644
--- a/misc/port.c
+++ b/misc/port.c
@@ -1,5 +1,3 @@
-#include <unistd.h>
-#include <sys/types.h>
 #include <sys/time.h>
 
 #ifndef HAVE_USLEEP
diff --git a/misc/profile.c b/misc/profile.c
deleted file mode 100644
index 4790c01..0000000
--- a/misc/profile.c
+++ /dev/null
@@ -1,496 +0,0 @@
-/*
- * Initialization-File Functions.
- *
- * Copyright (c) 1993 Miguel de Icaza
- *
- * 1/Dec o Corrected return values for Get*ProfileString
- *
- *       o Now, if AppName == NULL in Get*ProfileString it returns a list
- *            of the KeyNames (as documented in the MS-SDK).
- *
- *       o if KeyValue == NULL now clears the value in Get*ProfileString
- *
- * 20/Apr  SL - I'm not sure where these definitions came from, but my SDK
- *         has a NULL KeyValue returning a list of KeyNames, and a NULL
- *         AppName undefined.  I changed GetSetProfile to match.  This makes
- *         PROGMAN.EXE do the right thing.
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
-#include "wine.h"
-#include "windows.h"
-#include "dos_fs.h"
-#include "toolhelp.h"
-#include "stddebug.h"
-#include "debug.h"
-#include "xmalloc.h"
-
-#define STRSIZE 255
-
-typedef struct TKeys {
-    char *KeyName;
-    char *Value;
-    struct TKeys *link;
-} TKeys;
-
-typedef struct TSecHeader {
-    char *AppName;
-    TKeys *Keys;
-    struct TSecHeader *link;
-} TSecHeader;
-    
-typedef struct TProfile {
-    char *FileName;
-    char *FullName;
-    TSecHeader *Section;
-    struct TProfile *link;
-    int changed;
-} TProfile;
-
-TProfile *Current = 0;
-TProfile *Base = 0;
-
-static TSecHeader *is_loaded (char *FileName)
-{
-    TProfile *p = Base;
-    
-    while (p){
-	if (!lstrcmpi( FileName, p->FileName)){
-	    Current = p;
-	    return p->Section;
-	}
-	p = p->link;
-    }
-    return 0;
-}
-
-#define WIN_INI WinIniFileName()
-
-static char *WinIniFileName(void)
-{
-    static char *name = NULL;
-    int len;
-    const char *unixName;
-
-    if (name) return name;
-
-    len = GetWindowsDirectory( NULL, 0 ) + 9;
-    name = xmalloc( len );
-    GetWindowsDirectory( name, len );
-    strcat( name, "/win.ini" );
-    if (!(unixName = DOSFS_GetUnixFileName( name, TRUE ))) return NULL;
-    free( name );
-    name = strdup( unixName );
-    return name;
-}
-
-static char *GetIniFileName(char *name, char *dir)
-{
-	char temp[256];
-
-	if (strchr(name, '/'))
-		return name;
-
-        if (strlen(dir)) {
-        strcpy(temp, dir);
-        strcat(temp, "\\");
-	strcat(temp, name);
-	}
-	else
-	  strcpy(temp, name);
-	return DOSFS_GetUnixFileName(temp,TRUE);
-}
-
-static TSecHeader *load (char *filename, char **pfullname)
-{
-    FILE *f;
-    TSecHeader *SecHeader = 0;
-    char CharBuffer [STRSIZE];
-    char *bufptr;
-    char *lastnonspc;
-    int bufsize;
-    char *file, *purefilename;
-    int c;
-    char path[MAX_PATH+1];
-    BOOL firstbrace;
-    
-    *pfullname = NULL;
-
-    dprintf_profile(stddeb,"Trying to load file %s \n", filename);
-
-    /* First try it as is */
-    file = GetIniFileName(filename, "");
-    if (!file || !(f = fopen(file, "r")))
-    {
-      if  ((purefilename = strrchr( filename, '\\' )))
-	purefilename++; 
-      else if  ((purefilename = strrchr( filename, '/' ))) 
-	purefilename++; 
-      else
-	purefilename = filename;
-
-      /* Now try the Windows directory */
-      GetWindowsDirectory(path, sizeof(path));
-      if ((file = GetIniFileName(purefilename, path)))
-      {
-          dprintf_profile(stddeb,"Trying to load  in windows directory file %s\n",
-                          file);
-          f = fopen(file, "r");
-      }
-      else f = NULL;
-
-      if (f == NULL)
-      { 	/* Try the path of the current executable */
-    
-	if (GetCurrentTask())
-	{
-	    char *p;
-	    GetModuleFileName( GetCurrentTask(), path, MAX_PATH );
-	    if ((p = strrchr( path, '\\' )))
-	    {
-		p[0] = '\0'; /* Remove trailing slash */
-		if ((file = GetIniFileName(purefilename, path)))
-                {
-                    dprintf_profile(stddeb,
-                                    "Trying to load in current directory%s\n",
-                                    file);
-                    f = fopen(file, "r");
-                }
-	    }
-	}
-    }
-      if (f == NULL) { 	/* And now in $HOME/.wine */
-	
-	strcpy(path,getenv("HOME"));
-	strcat(path, "/.wine/");
-	strcat(path, purefilename);
-	dprintf_profile(stddeb,"Trying to load in user-directory %s\n", path);
-        file = path;
-	f = fopen(file, "r");
-      }
-      
-      if (f == NULL) {
-	/* FIXED: we ought to create it now (in which directory?) */
-	/* lets do it in ~/.wine */
-	strcpy(path,getenv("HOME"));
-	strcat(path, "/.wine/");
-	strcat(path, purefilename);
-	dprintf_profile(stddeb,"Creating %s\n", path);
-        file = path;
-	f = fopen(file, "w+");
-    if (f == NULL) {
-	fprintf(stderr, "profile.c: load() can't find file %s\n", filename);
-	return NULL;
-	}
-      }
-    }
-    
-    *pfullname = xstrdup(file);
-    dprintf_profile(stddeb,"Loading %s\n", file);
-
-    firstbrace = TRUE;
-    for(;;) {	
-	c = fgetc(f);
-	if (c == EOF) goto finished;
-	
-	if (isspace(c))
-	    continue;
-	if (c == ';') {
-	    do {
-		c = fgetc(f);
-	    } while (!(c == EOF || c == '\n'));
-	    if (c == EOF) goto finished;
-	}
-	if (c == '[') {
-	    TSecHeader *temp = SecHeader;
-	    
-	    SecHeader = (TSecHeader *) xmalloc (sizeof (TSecHeader));
-	    SecHeader->link = temp;
-	    SecHeader->Keys = NULL;
-	    do {
-		c = fgetc(f);
-		if (c == EOF) goto bad_file;
-	    } while (isspace(c));
-	    bufptr = lastnonspc = CharBuffer;
-	    bufsize = 0;
-	    do {
-		if (c != ']') {
-		    bufsize++;
-		    *bufptr++ = c;
-		    if (!isspace(c))
-		    	lastnonspc = bufptr;
-		} else
-		    break;
-		c = fgetc(f);
-		if (c == EOF) goto bad_file;
-	    } while(bufsize < STRSIZE-1);
-	    *lastnonspc = 0;
-	    if (!strlen(CharBuffer))
-	    	fprintf(stderr, "warning: empty section name in ini file\n");
-	    SecHeader->AppName = xstrdup (CharBuffer);
-	    dprintf_profile(stddeb,"%s: section %s\n", file, CharBuffer);
-	    firstbrace = FALSE;
-	} else if (SecHeader) {
-	    TKeys *temp = SecHeader->Keys;
-	    BOOL skipspc;
-	    
-	    if (firstbrace)
-	    	goto bad_file;
-	    bufptr = lastnonspc = CharBuffer;
-	    bufsize = 0;
-	    do {
-		if (c != '=') {
-		    bufsize++;
-		    *bufptr++ = c;
-		    if (!isspace(c))
-		    	lastnonspc = bufptr;
-		} else
-		    break;
-		c = fgetc(f);
-		if (c == EOF) goto bad_file;
-	    } while(bufsize < STRSIZE-1);
-	    *lastnonspc = 0;
-	    if (!strlen(CharBuffer))
-	    	fprintf(stderr, "warning: empty key name in ini file\n");
-	    SecHeader->Keys = (TKeys *) xmalloc (sizeof (TKeys));
-	    SecHeader->Keys->link = temp;
-	    SecHeader->Keys->KeyName = xstrdup (CharBuffer);
-
-	    dprintf_profile(stddeb,"%s:   key %s\n", file, CharBuffer);
-	    
-	    bufptr = lastnonspc = CharBuffer;
-	    bufsize = 0;
-	    skipspc = TRUE;
-	    do {
-		c = fgetc(f);
-		if (c == EOF || c == '\n') break;
-		if (!isspace(c) || !skipspc) {
-		    skipspc = FALSE;
-		    bufsize++;
-		    *bufptr++ = c;
-		    if (!isspace(c))
-		    	lastnonspc = bufptr;
-		}
-	    } while(bufsize < STRSIZE-1);
-	    *lastnonspc = 0;
-	    SecHeader->Keys->Value = xstrdup (CharBuffer);
-	    dprintf_profile (stddeb, "[%s] (%s)=%s\n", SecHeader->AppName,
-			     SecHeader->Keys->KeyName, SecHeader->Keys->Value);
-	    if (c == ';') {
-		do {
-		    c = fgetc(f);
-		} while (!(c == EOF || c == '\n'));
-		if (c == EOF)
-		    goto finished;
-	    }
-	}
-
-    }
-bad_file:
-    fprintf(stderr, "warning: bad ini file\n");
-finished:
-    return SecHeader;
-}
-
-static void new_key (TSecHeader *section, char *KeyName, char *Value)
-{
-    TKeys *key;
-    
-    key = (TKeys *) xmalloc (sizeof (TKeys));
-    key->KeyName = xstrdup (KeyName);
-    key->Value   = xstrdup (Value);
-    key->link = section->Keys;
-    section->Keys = key;
-}
-
-static short GetSetProfile (int set, LPSTR AppName, LPSTR KeyName,
-		     LPSTR Default, LPSTR ReturnedString, short Size,
-		     LPSTR FileName)
-
-{
-    TProfile   *New;
-    TSecHeader *section;
-    TKeys      *key;
-    
-    /* Supposedly Default should NEVER be NULL.  But sometimes it is.  */
-    if (Default == NULL)
-	Default = "";
-
-    if (!(section = is_loaded (FileName))){
-	New = (TProfile *) xmalloc (sizeof (TProfile));
-	New->link = Base;
-	New->FileName = xstrdup (FileName);
-	New->Section = load (FileName, &New->FullName);
-	New->changed = FALSE;
-	Base = New;
-	section = New->Section;
-	Current = New;
-    }
-
-    /* Start search */
-    for (; section; section = section->link){
-	if (lstrcmpi(section->AppName, AppName))
-	    continue;
-
-	/* If no key value given, then list all the keys */
-	if ((!KeyName) && (!set)){
-	    char *p = ReturnedString;
-	    int left = Size - 2;
-	    int slen;
-
-	    dprintf_profile(stddeb,"GetSetProfile // KeyName == NULL, Enumeration !\n");
-	    for (key = section->Keys; key; key = key->link){
-		if (left < 1) {
-		    dprintf_profile(stddeb,"GetSetProfile // No more storage for enum !\n");
-		    return Size - 2;
-		}
-		slen = MIN(strlen(key->KeyName) + 1, left);
-		lstrcpyn(p, key->KeyName, slen);
-		dprintf_profile(stddeb,"GetSetProfile // enum '%s' !\n", p);
-		left -= slen;
-		p += slen;
-	    }
-	    *p = '\0';
-	    return Size - 2 - left;
-	}
-	for (key = section->Keys; key; key = key->link){
-	    int slen;
-	    if (lstrcmpi(key->KeyName, KeyName))
-		continue;
-	    if (set){
-		free (key->Value);
-		key->Value = xstrdup (Default ? Default : "");
-		Current->changed=TRUE;
-		return 1;
-	    }
-	    slen = MIN(strlen(key->Value)+1, Size);
-	    lstrcpyn(ReturnedString, key->Value, slen);
-	    dprintf_profile(stddeb,"GetSetProfile // Return ``%s''\n", ReturnedString);
-	    return 1; 
-	}
-	/* If Getting the information, then don't write the information
-	   to the INI file, need to run a couple of tests with windog */
-	/* No key found */
-	if (set) {
-	    new_key (section, KeyName, Default);
-        } else {
-	    int slen = MIN(strlen(Default)+1, Size);
-            lstrcpyn(ReturnedString, Default, slen);
-	    dprintf_profile(stddeb,"GetSetProfile // Key not found\n");
-	}
-	return 1;
-    }
-
-    /* Non existent section */
-    if (set){
-	section = (TSecHeader *) xmalloc (sizeof (TSecHeader));
-	section->AppName = xstrdup (AppName);
-	section->Keys = 0;
-	new_key (section, KeyName, Default);
-	section->link = Current->Section;
-	Current->Section = section;
-	Current->changed = TRUE;
-    } else {
-	int slen = MIN(strlen(Default)+1, Size);
-	lstrcpyn(ReturnedString, Default, slen);
-	dprintf_profile(stddeb,"GetSetProfile // Section not found\n");
-    }
-    return 1;
-}
-
-short GetPrivateProfileString (LPCSTR AppName, LPCSTR KeyName,
-			       LPCSTR Default, LPSTR ReturnedString,
-			       short Size, LPCSTR FileName)
-{
-    int v;
-
-    dprintf_profile(stddeb,"GetPrivateProfileString ('%s', '%s', '%s', %p, %d, %s\n", 
-			AppName, KeyName, Default, ReturnedString, Size, FileName);
-    v = GetSetProfile (0,AppName,KeyName,Default,ReturnedString,Size,FileName);
-    if (AppName)
-	return strlen (ReturnedString);
-    else
-	return Size - v;
-}
-
-int GetProfileString (LPCSTR AppName, LPCSTR KeyName, LPCSTR Default, 
-		      LPSTR ReturnedString, int Size)
-{
-    return GetPrivateProfileString (AppName, KeyName, Default,
-				    ReturnedString, Size, WIN_INI );
-}
-
-WORD GetPrivateProfileInt (LPCSTR AppName, LPCSTR KeyName, short Default,
-			   LPCSTR File)
-{
-    static char IntBuf[10];
-    static char buf[10];
-
-    sprintf (buf, "%d", Default);
-    
-    /* Check the exact semantic with the SDK */
-    GetPrivateProfileString (AppName, KeyName, buf, IntBuf, 10, File);
-    if (!lstrcmpi(IntBuf, "true"))
-	return 1;
-    if (!lstrcmpi(IntBuf, "yes"))
-	return 1;
-    return strtoul( IntBuf, NULL, 0 );
-}
-
-WORD GetProfileInt (LPCSTR AppName, LPCSTR KeyName, int Default)
-{
-    return GetPrivateProfileInt (AppName, KeyName, Default, WIN_INI);
-}
-
-BOOL WritePrivateProfileString (LPSTR AppName, LPSTR KeyName, LPSTR String,
-				LPSTR FileName)
-{
-    if (!AppName || !KeyName || !String)  /* Flush file to disk */
-        return TRUE;
-    return GetSetProfile (1, AppName, KeyName, String, "", 0, FileName);
-}
-
-BOOL WriteProfileString (LPSTR AppName, LPSTR KeyName, LPSTR String)
-{
-    return (WritePrivateProfileString (AppName, KeyName, String, WIN_INI));
-}
-
-static void dump_keys (FILE *profile, TKeys *p)
-{
-    if (!p)
-	return;
-    dump_keys (profile, p->link);
-    fprintf (profile, "%s=%s\r\n", p->KeyName, p->Value);
-}
-
-static void dump_sections (FILE *profile, TSecHeader *p)
-{
-    if (!p)
-	return;
-    dump_sections (profile, p->link);
-    fprintf (profile, "\r\n[%s]\r\n", p->AppName);
-    dump_keys (profile, p->Keys);
-}
-
-static void dump_profile (TProfile *p)
-{
-    FILE *profile;
-    
-    if (!p)
-	return;
-    dump_profile (p->link);
-    if(!p->changed)
-	return;
-    if (p->FullName && (profile = fopen (p->FullName, "w")) != NULL){
-	dump_sections (profile, p->Section);
-	fclose (profile);
-    }
-}
-
-void sync_profiles (void)
-{
-    dump_profile (Base);
-}
diff --git a/misc/rect.c b/misc/rect.c
index c5d7985..0ae8b0c 100644
--- a/misc/rect.c
+++ b/misc/rect.c
@@ -33,9 +33,10 @@
 /***********************************************************************
  *           CopyRect    (USER.74)
  */
-void CopyRect( LPRECT dest, LPRECT src )
+BOOL CopyRect( LPRECT dest, LPRECT src )
 {
     *dest = *src;
+    return TRUE;
 }
 
 
diff --git a/misc/shell.c b/misc/shell.c
index 0d48698..802ee7b 100644
--- a/misc/shell.c
+++ b/misc/shell.c
@@ -215,7 +215,7 @@
 /*************************************************************************
  *				RegOpenKey		[SHELL.1]
  */
-LONG RegOpenKey(HKEY hKey, LPCSTR lpSubKey, HKEY FAR *lphKey)
+LONG RegOpenKey(HKEY hKey, LPCSTR lpSubKey, LPHKEY lphKey)
 {
 	LPKEYSTRUCT	lpKey,lpNextKey;
 	LPCSTR		ptr;
@@ -264,7 +264,7 @@
 /*************************************************************************
  *				RegCreateKey		[SHELL.2]
  */
-LONG RegCreateKey(HKEY hKey, LPCSTR lpSubKey, HKEY FAR *lphKey)
+LONG RegCreateKey(HKEY hKey, LPCSTR lpSubKey, LPHKEY lphKey)
 {
 	HKEY		hNewKey;
 	LPKEYSTRUCT	lpNewKey;
@@ -391,7 +391,7 @@
 /*************************************************************************
  *				RegQueryValue		[SHELL.6]
  */
-LONG RegQueryValue(HKEY hKey, LPCSTR lpSubKey, LPSTR lpVal, LONG FAR *lpcb)
+LONG RegQueryValue(HKEY hKey, LPCSTR lpSubKey, LPSTR lpVal, LPLONG lpcb)
 {
 	HKEY		hRetKey;
 	LPKEYSTRUCT	lpKey;
@@ -552,7 +552,7 @@
 /*************************************************************************
  *				ShellExecute		[SHELL.20]
  */
-HINSTANCE ShellExecute(HWND hWnd, LPCSTR lpOperation, LPCSTR lpFile, LPCSTR lpParameters, LPCSTR lpDirectory, int iShowCmd)
+HINSTANCE ShellExecute(HWND hWnd, LPCSTR lpOperation, LPCSTR lpFile, LPSTR lpParameters, LPCSTR lpDirectory, INT iShowCmd)
 {
     char cmd[400];
     char *p,*x;
diff --git a/misc/sound.c b/misc/sound.c
index 8b8696d..990bb72 100644
--- a/misc/sound.c
+++ b/misc/sound.c
@@ -77,7 +77,7 @@
         return 0;
 }
 
-int CountVoiceNotes(int x)
+INT CountVoiceNotes(INT x)
 {
 	fprintf(stderr, "CountVoiceNotes(%d)\n", x);
         return 0;
diff --git a/misc/spy.c b/misc/spy.c
index 3a92d62..81f2852 100644
--- a/misc/spy.c
+++ b/misc/spy.c
@@ -10,7 +10,6 @@
 #include <X11/Xresource.h>
 #include <string.h>
 #include "windows.h"
-#include "wine.h"
 #include "options.h"
 #include "stddebug.h"
 #include "debug.h"
@@ -529,7 +528,8 @@
 
     for(i=0; i <= SPY_MAX_MSGNUM; i++) SpyFilters[i] = SpyIncludes[i] = FALSE;
 
-    GetPrivateProfileString("spy", "Exclude", "",lpstrBuffer ,511 , WINE_INI);
+    PROFILE_GetWineIniString( "spy", "Exclude", "",
+                              lpstrBuffer, sizeof(lpstrBuffer) );
     dprintf_message(stddeb,"SpyInit: Exclude=%s\n",lpstrBuffer);
     if( *lpstrBuffer != 0 )
       if(strstr(lpstrBuffer,"EXCLUDEALL"))
@@ -539,7 +539,8 @@
 	    if(MessageTypeNames[i])
 	       if(strstr(lpstrBuffer,MessageTypeNames[i])) SpyFilters[i] = TRUE; 
 
-    GetPrivateProfileString("spy", "Include", "INCLUDEALL",lpstrBuffer ,511 , WINE_INI);
+    PROFILE_GetWineIniString( "spy", "Include", "INCLUDEALL",
+                              lpstrBuffer, sizeof(lpstrBuffer) );
     dprintf_message(stddeb,"SpyInit: Include=%s\n",lpstrBuffer);
     if( *lpstrBuffer != 0 )
       if(strstr(lpstrBuffer,"INCLUDEALL"))
diff --git a/misc/toolhelp.c b/misc/toolhelp.c
new file mode 100644
index 0000000..ccde79a
--- /dev/null
+++ b/misc/toolhelp.c
@@ -0,0 +1,70 @@
+/*
+ * Misc Toolhelp functions
+ *
+ * Copyright 1996 Marcus Meissner
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <ctype.h>
+#include "windows.h"
+#include "win.h"
+#include "toolhelp.h"
+#include "stddebug.h"
+#include "debug.h"
+#include "xmalloc.h"
+
+/* FIXME: to make this working, we have to callback all these registered 
+ * functions from all over the WINE code. Someone with more knowledge than
+ * me please do that. -Marcus
+ */
+static struct notify
+{
+    HTASK    htask;
+    FARPROC  lpfnCallback;
+    WORD     wFlags;
+} *notifys = NULL;
+
+static int nrofnotifys = 0;
+
+BOOL
+NotifyRegister(HTASK htask,FARPROC lpfnCallback,WORD wFlags)
+{
+    int	i;
+
+    dprintf_toolhelp( stddeb, "NotifyRegister(%x,%lx,%x) called.\n",
+                      htask, (DWORD)lpfnCallback, wFlags );
+    for (i=0;i<nrofnotifys;i++)
+        if (notifys[i].htask==htask)
+            break;
+    if (i==nrofnotifys) {
+        if (notifys==NULL)
+            notifys=(struct notify*)xmalloc(sizeof(struct notify));
+        else
+            notifys=(struct notify*)xrealloc(notifys,sizeof(struct notify)*(nrofnotifys+1));
+        nrofnotifys++;
+    }
+    notifys[i].htask=htask;
+    notifys[i].lpfnCallback=lpfnCallback;
+    notifys[i].wFlags=wFlags;
+    return TRUE;
+}
+
+BOOL
+NotifyUnregister(HTASK htask)
+{
+    int	i;
+    
+    dprintf_toolhelp( stddeb, "NotifyUnregister(%x) called.\n", htask );
+    for (i=nrofnotifys;i--;)
+        if (notifys[i].htask==htask)
+            break;
+    if (i==-1)
+        return FALSE;
+    memcpy(notifys+i,notifys+(i+1),sizeof(struct notify)*(nrofnotifys-i-1));
+    notifys=(struct notify*)realloc(notifys,(nrofnotifys-1)*sizeof(struct notify));
+    nrofnotifys--;
+    return TRUE;
+}
diff --git a/misc/user.c b/misc/user.c
index 27bd40c..4fe51e8 100644
--- a/misc/user.c
+++ b/misc/user.c
@@ -4,20 +4,10 @@
 */
 #include <stdio.h>
 #include <stdlib.h>
-#include "atom.h"
-#include "comm.h"
-#include "gdi.h"
-#include "desktop.h"
-#include "dlls.h"
-#include "dos_fs.h"
-#include "sysmetrics.h"
-#include "menu.h"
-#include "dce.h"
-#include "dialog.h"
-#include "syscolor.h"
-#include "win.h"
 #include "windows.h"
+#include "gdi.h"
 #include "user.h"
+#include "win.h"
 #include "message.h"
 #include "toolhelp.h"
 
diff --git a/misc/user32.c b/misc/user32.c
deleted file mode 100644
index 5097b8c..0000000
--- a/misc/user32.c
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Win32 user 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 <unistd.h>
-#include "windows.h"
-#include "winerror.h"
-#include "relay32.h"
-#include "alias.h"
-#include "stackframe.h"
-#include "xmalloc.h"
-
-/* Structure copy functions */
-static void MSG16to32(MSG *msg16,struct WIN32_MSG *msg32)
-{
-	msg32->hwnd=(DWORD)msg16->hwnd;
-	msg32->message=msg16->message;
-	msg32->wParam=msg16->wParam;
-	msg32->lParam=msg16->lParam;
-	msg32->time=msg16->time;
-	msg32->pt.x=msg16->pt.x;
-	msg32->pt.y=msg16->pt.y;
-}
-
-static void MSG32to16(struct WIN32_MSG *msg32,MSG *msg16)
-{
-	msg16->hwnd=(HWND)msg32->hwnd;
-	msg16->message=msg32->message;
-	msg16->wParam=msg32->wParam;
-	msg16->lParam=msg32->lParam;
-	msg16->time=msg32->time;
-	msg16->pt.x=msg32->pt.x;
-	msg16->pt.y=msg32->pt.y;
-}
-
-/***********************************************************************
- *           RegisterClassA      (USER32.426)
- */
-ATOM USER32_RegisterClassA(WNDCLASSA* wndclass)
-{
-	WNDCLASS copy;
-	HANDLE classh = 0, menuh = 0;
-	SEGPTR classsegp, menusegp;
-	char *classbuf, *menubuf;
-
-	ATOM retval;
-	copy.style=wndclass->style;
-	ALIAS_RegisterAlias(0,0,(DWORD)wndclass->lpfnWndProc);
-	copy.lpfnWndProc=wndclass->lpfnWndProc;
-	copy.cbClsExtra=wndclass->cbClsExtra;
-	copy.cbWndExtra=wndclass->cbWndExtra;
-	copy.hInstance=(HINSTANCE)wndclass->hInstance;
-	copy.hIcon=(HICON)wndclass->hIcon;
-	copy.hCursor=(HCURSOR)wndclass->hCursor;
-	copy.hbrBackground=(HBRUSH)wndclass->hbrBackground;
-
-	/* FIXME: There has to be a better way of doing this - but neither
-	malloc nor alloca will work */
-
-	if(wndclass->lpszMenuName)
-	{
-		menuh = GlobalAlloc(0, strlen(wndclass->lpszMenuName)+1);
-		menusegp = WIN16_GlobalLock(menuh);
-		menubuf = PTR_SEG_TO_LIN(menusegp);
-		strcpy( menubuf, wndclass->lpszMenuName);
-		copy.lpszMenuName=menusegp;
-	}else
-		copy.lpszMenuName=0;
-	if(wndclass->lpszClassName)
-	{
-		classh = GlobalAlloc(0, strlen(wndclass->lpszClassName)+1);
-		classsegp = WIN16_GlobalLock(classh);
-		classbuf = PTR_SEG_TO_LIN(classsegp);
-		strcpy( classbuf, wndclass->lpszClassName);
-		copy.lpszClassName=classsegp;
-	}
-	retval = RegisterClass(&copy);
-	GlobalFree(menuh);
-	GlobalFree(classh);
-	return retval;
-}
-
-/***********************************************************************
- *          GetMessageA          (USER32.269)
- */
-BOOL USER32_GetMessageA(struct WIN32_MSG* lpmsg,DWORD hwnd,DWORD min,DWORD max)
-{
-	BOOL ret;
-	MSG msg;
-	ret=GetMessage(MAKE_SEGPTR(&msg),(HWND)hwnd,min,max);
-	MSG16to32(&msg,lpmsg);
-	return ret;
-}
-
-/***********************************************************************
- *          BeginPaint           (USER32.9)
- */
-HDC USER32_BeginPaint(DWORD hwnd,struct WIN32_PAINTSTRUCT *lpps)
-{
-	PAINTSTRUCT ps;
-	HDC ret;
-	ret=BeginPaint((HWND)hwnd,&ps);
-	lpps->hdc=(DWORD)ps.hdc;
-	lpps->fErase=ps.fErase;
-	lpps->rcPaint.top=ps.rcPaint.top;
-	lpps->rcPaint.left=ps.rcPaint.left;
-	lpps->rcPaint.right=ps.rcPaint.right;
-	lpps->rcPaint.bottom=ps.rcPaint.bottom;
-	lpps->fRestore=ps.fRestore;
-	lpps->fIncUpdate=ps.fIncUpdate;
-	return ret;
-}
-
-/***********************************************************************
- *          EndPaint             (USER32.175)
- */
-BOOL USER32_EndPaint(DWORD hwnd,struct WIN32_PAINTSTRUCT *lpps)
-{
-	PAINTSTRUCT ps;
-	ps.hdc=(HDC)lpps->hdc;
-	ps.fErase=lpps->fErase;
-	ps.rcPaint.top=lpps->rcPaint.top;
-	ps.rcPaint.left=lpps->rcPaint.left;
-	ps.rcPaint.right=lpps->rcPaint.right;
-	ps.rcPaint.bottom=lpps->rcPaint.bottom;
-	ps.fRestore=lpps->fRestore;
-	ps.fIncUpdate=lpps->fIncUpdate;
-	EndPaint((HWND)hwnd,&ps);
-	return TRUE;
-}
-
-/***********************************************************************
- *         DispatchMessageA       (USER32.140)
- */
-LONG USER32_DispatchMessageA(struct WIN32_MSG* lpmsg)
-{
-	MSG msg;
-	LONG ret;
-	MSG32to16(lpmsg,&msg);
-	ret=DispatchMessage(&msg);
-	MSG16to32(&msg,lpmsg);
-	return ret;
-}
-
-/***********************************************************************
- *         TranslateMessage       (USER32.555)
- */
-BOOL USER32_TranslateMessage(struct WIN32_MSG* lpmsg)
-{
-	MSG msg;
-	MSG32to16(lpmsg,&msg);
-	return TranslateMessage(&msg);
-}
-
-/***********************************************************************
- *         CreateWindowExA        (USER32.82)
- */
-DWORD USER32_CreateWindowExA(long flags,char* class,char *title,
-	long style,int x,int y,int width,int height,DWORD parent,DWORD menu,
-	DWORD instance,DWORD param)
-{
-    DWORD retval;
-    HANDLE classh, titleh;
-    SEGPTR classsegp, titlesegp;
-    char *classbuf, *titlebuf;
-
-    /*Have to translate CW_USEDEFAULT */
-    if(x==0x80000000)x=CW_USEDEFAULT;
-    if(y==0x80000000)y=CW_USEDEFAULT;
-    if(width==0x80000000)width=CW_USEDEFAULT;
-    if(height==0x80000000)height=CW_USEDEFAULT;
-
-    /* FIXME: There has to be a better way of doing this - but neither
-    malloc nor alloca will work */
-
-    classh = GlobalAlloc(0, strlen(class)+1);
-    titleh = GlobalAlloc(0, strlen(title)+1);
-    classsegp = WIN16_GlobalLock(classh);
-    titlesegp = WIN16_GlobalLock(titleh);
-    classbuf = PTR_SEG_TO_LIN(classsegp);
-    titlebuf = PTR_SEG_TO_LIN(titlesegp);
-    strcpy( classbuf, class );
-    strcpy( titlebuf, title );
-    
-    retval = (DWORD) CreateWindowEx(flags,classsegp,
-				  titlesegp,style,x,y,width,height,
-				  (HWND)parent,(HMENU)menu,(HINSTANCE)instance,
-				  (LPVOID)param);
-    GlobalFree(classh);
-    GlobalFree(titleh);
-    return retval;
-}
diff --git a/misc/winsocket.c b/misc/winsocket.c
index 0586e52..05e1ecf 100644
--- a/misc/winsocket.c
+++ b/misc/winsocket.c
@@ -652,7 +652,16 @@
     dprintf_winsock(stddeb, "WSA_socket: af=%d type=%d protocol=%d\n", af, type, protocol);
 
     if ((sock = socket(af, type, protocol)) < 0) {
+        if (errno != EPERM) {
             errno_to_wsaerrno();
+        } else {
+             /* NOTE: EPERM does not always map to WSAESOCKTNOSUPPORT
+              * so this is done as a special case
+              */
+             /* non super-user wants a raw socket */
+             dprintf_winsock(stderr, "WSA_socket: not enough privileges\n");
+             WSASetLastError(WSAESOCKTNOSUPPORT);
+        }
             dprintf_winsock(stddeb, "WSA_socket: failed !\n");
             return INVALID_SOCKET;
     }
@@ -1177,7 +1186,7 @@
 	return WSASYSNOTREADY;
 
     Heap = (struct WinSockHeap *) GlobalLock(HeapHandle);
-    bcopy(&WINSOCK_data, lpWSAData, sizeof(WINSOCK_data));
+    memcpy(lpWSAData, &WINSOCK_data, sizeof(WINSOCK_data));
 
     /* ipc stuff */