Release 971116

Sun Nov 16 07:42:44 1997  Alex Korobka <alex@trantor.pharm.sunysb.edu>

	* [windows/dce.c] [windows/clipboard.c] [windows/nonclient.c]
	Bug fixes.

	* [misc/shell.c] [resources/*]
	New "About" dialog.

Sat Nov 15 17:30:18 1997  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [configure.in] [Makefile.in]
	Replaced --with-library option by --disable-emulator. The default
 	is now to build both the library and the emulator.
	Renamed --with options to --enable to follow autoconf guidelines.

	* [loader/main.c] [miscemu/main.c] (New file)
	Split initialization in WinelibInit/EmulatorInit.

	* [loader/*.c]
	Removed all remaining #ifdef's WINELIB.

	* [controls/widgets.c] [windows/mdi.c]
	Converted MDIClientWndProc to 32-bit.

	* [debugger/break.c] [if1632/signal.c] [include/selectors.h]
	  [scheduler/thread.c]
	Code and data selector values are now computed at run-time.

	* [library/libres.c]
	Moved to loader/ directory.

	* [misc/main.c] [misc/version.c] (New file)
	Moved all version stuff to version.c. Cleaned up a bit.

	* [msdos/dpmi.c]
	Update the REALMODECALL structure on return from real-mode
	interrupt.

	* [windows/event.c] [windows/keyboard.c]
	Changed the way event coordinates are determined. Don't rely on
	the ConfigureNotify event values. This should fix all problems
	with cursor position in -desktop and -managed modes.

Sat Nov 15 16:09:36 1997  Slaven Rezic  <eserte@cs.tu-berlin.de>

	* [controls/button.c]
	(BUTTON_CheckAutoRadioButton): Prevent possible endless loop.

Wed Nov 12 03:42:45 1997  Chris Faherty <chrisf@america.com>

	* [misc/ver.c]
	Changed VerInstall32A to assume srcdir as destination if destdir
	is blank.  This was causing alot of DLL installation into SYSTEM
	directory to fail.

	* [loader/ne_image.c]
	NE_LoadSegment buffer[100] was too small and getting overruns.
	Changed it to buffer[200].

Sat Nov  8 06:09:57 1997  Len White <phreak@cgocable.net>

	* [misc/ddeml.c] [include/ddeml.h] [if1632/ddeml.spec]
	Added stub functions DdeConnectList(), DdeQueryNextServer(),
	DdeDisconnectList(), DdeSetUserHandle(), DdeAbandonTransaction(),
	DdePostAdvise(), DdeCreateDataHandle(), DdeAddData(), DdeGetData(),
	DdeAccessData(), DdeUnaccessData(), DdeEnableCallback(),
	DdeCmpStringHandles().

Fri Nov  7 19:44:26 1997  Olaf Flebbe  <o.flebbe@science-computing.de>

	* [files/directory.c]
	Fix typo in directory.c [broke loading of cdplayer on nt40]

	* [misc/main.c]
	Implemented -winver nt40.

	* [loader/resource.c] [user32.spec]
	Stubs for CopyAcceleratorTable, Destroy AcceleratorTable.

Thu Nov  6 22:37:04 1997  Morten Welinder  <welinder@rentec.com>

	* [files/drive.c]
	(GetDiskFreeSpace32A): Cap at 2GB.

	* [include/windows.h]
	Prototype DrawIconEx and CreateDIBSection32.
	Define OBM_RADIOCHECK.
	Add DI_* macros.

	* [objects/dib.c] [if1632/gdi.spec]
	CreateDIBSection is a WINAPI.  Renamed to CreateDIBSection32.
	Implement CreateDIBSection16.

	* [if1632/user.spec] [if1632/user32.spec]
	Add DrawIconEx.

	* [objects/cursoricon.c]
	(CopyIcon32): Fix bogus implementation.

	* [objects/bitmap.c]
	(CopyBitmap32): New function.
	(CopyImage32): Do bitmaps.

	* [graphics/x11drv/text.c]
	(X11DRV_ExtTextOut): Change ascent and descent default to avoid
	zero-thinkness overstrike line.

	* [include/debugstr.h] [misc/debugstr.c]
	New files.

	* [msdos/dpmi.c]
	Don't prototype do_mscdex. In INT_Int31Handler, handle real-mode
	int 0x21, ah=0x52.

	* [msdos/int2f.c]
	Add dummys for 0x1681 and 0x1682.

	* [misc/registry.c]
	Fix memory leaks in RegDeleteKey32W.

	* [objects/text.c]
	In TEXT_NextLine, fix another off-by-one bug.

	* [include/bitmaps/obm_radiocheck]
	New file.  (It a small circle used to radio-button menu items
	when selected.)
	
	* [objects/oembitmap.c]
	Add obm_radiocheck.

	* [include/windows.h] [if1632/user32.spec] [controls/menu.c]
	  [if1632/user.spec]
	Define CheckMenuRadioItem{16,32}.  Define GetMenuItemRect{16,32}.

Wed Nov  5 11:30:14 1997  Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>
	* [misc/main.c]
	Auto adjust versions depending on binary.

Tue Nov  4 15:21:00 1997  Kristian Nielsen  <kristian.nielsen@risoe.dk>

	* [controls/listbox.c]
	Paint full background in listbox items with tab stops enabled.

	* [if1632/thunk.c]
	Copy some more message parameter structures (DRAWITEMSTRUCT16,
	COMPAREITEMSTRUCT16) to the stack segment to fix broken programs
	that need this.

	* [windows/dce.c]
	Only clip sibling windows when the parent has the WS_CLIPSIBLINGS
	style set.

	* [windows/focus.c]
	Make order of events in FOCUS_SwitchFocus() reflect API docs.

	* [windows/defdlg.c]
	Fix problem with loss of focus in some dialogs.

	* [win32/code_page.c]
	Fix return value for MultiByteToWideChar().

	* [BUGS]
	BCW now works.
diff --git a/loader/module.c b/loader/module.c
index c1d3047..202f189 100644
--- a/loader/module.c
+++ b/loader/module.c
@@ -4,6 +4,7 @@
  * Copyright 1995 Alexandre Julliard
  */
 
+#include <assert.h>
 #include <fcntl.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -918,20 +919,54 @@
  *
  * Return an entry point from the WPROCS dll.
  */
-#ifndef WINELIB
-FARPROC16 MODULE_GetWndProcEntry16( const char *name )
+FARPROC16 MODULE_GetWndProcEntry16( LPCSTR name )
 {
-    WORD ordinal;
-    FARPROC16 ret;
-    static HMODULE32 hModule = 0;
+    FARPROC16 ret = NULL;
 
-    if (!hModule) hModule = GetModuleHandle16( "WPROCS" );
-    ordinal = MODULE_GetOrdinal( hModule, name );
-    if (!(ret = MODULE_GetEntryPoint( hModule, ordinal )))
-        fprintf( stderr, "GetWndProc16: %s not found, please report\n", name );
+    if (__winelib)
+    {
+        /* FIXME: hack for Winelib */
+        extern LRESULT ColorDlgProc(HWND16,UINT16,WPARAM16,LPARAM);
+        extern LRESULT FileOpenDlgProc(HWND16,UINT16,WPARAM16,LPARAM);
+        extern LRESULT FileSaveDlgProc(HWND16,UINT16,WPARAM16,LPARAM);
+        extern LRESULT FindTextDlgProc(HWND16,UINT16,WPARAM16,LPARAM);
+        extern LRESULT PrintDlgProc(HWND16,UINT16,WPARAM16,LPARAM);
+        extern LRESULT PrintSetupDlgProc(HWND16,UINT16,WPARAM16,LPARAM);
+        extern LRESULT ReplaceTextDlgProc(HWND16,UINT16,WPARAM16,LPARAM);
+
+        if (!strcmp(name,"ColorDlgProc"))
+            return (FARPROC16)ColorDlgProc;
+        if (!strcmp(name,"FileOpenDlgProc"))
+            return (FARPROC16)FileOpenDlgProc;
+        if (!strcmp(name,"FileSaveDlgProc"))
+            return (FARPROC16)FileSaveDlgProc;
+        if (!strcmp(name,"FindTextDlgProc"))
+            return (FARPROC16)FindTextDlgProc;
+        if (!strcmp(name,"PrintDlgProc"))
+            return (FARPROC16)PrintDlgProc;
+        if (!strcmp(name,"PrintSetupDlgProc"))
+            return (FARPROC16)PrintSetupDlgProc;
+        if (!strcmp(name,"ReplaceTextDlgProc"))
+            return (FARPROC16)ReplaceTextDlgProc;
+        fprintf(stderr,"warning: No mapping for %s(), add one in library/miscstubs.c\n",name);
+        assert( FALSE );
+        return NULL;
+    }
+    else
+    {
+        WORD ordinal;
+        static HMODULE32 hModule = 0;
+
+        if (!hModule) hModule = GetModuleHandle16( "WPROCS" );
+        ordinal = MODULE_GetOrdinal( hModule, name );
+        if (!(ret = MODULE_GetEntryPoint( hModule, ordinal )))
+        {            
+            fprintf( stderr, "GetWndProc16: %s not found\n", name );
+            assert( FALSE );
+        }
+    }
     return ret;
 }
-#endif
 
 
 /***********************************************************************
@@ -1109,203 +1144,97 @@
     NE_MODULE *pModule;
     LOADPARAMS *params = (LOADPARAMS *)paramBlock;
     OFSTRUCT ofs;
-#ifndef WINELIB
-    WORD *pModRef, *pDLLs;
     HFILE32 hFile;
-    int i;
-    extern const char * DEBUG_curr_module;
 
-    hModule = MODULE_FindModule( name );
-
-    if (!hModule)  /* We have to load the module */
+    if (__winelib)
     {
-        /* Try to load the built-in first if not disabled */
-        if ((hModule = BUILTIN_LoadModule( name, FALSE ))) return hModule;
+        lstrcpyn32A( ofs.szPathName, name, sizeof(ofs.szPathName) );
+        if ((hModule = MODULE_CreateDummyModule( &ofs )) < 32) return hModule;
+        pModule = (NE_MODULE *)GlobalLock16( hModule );
+        hPrevInstance = 0;
+        hInstance = MODULE_CreateInstance( hModule, params );
+    }
+    else
+    {
+        hModule = MODULE_FindModule( name );
 
-        if ((hFile = OpenFile32( name, &ofs, OF_READ )) == HFILE_ERROR32)
+        if (!hModule)  /* We have to load the module */
         {
-            /* Now try the built-in even if disabled */
-            if ((hModule = BUILTIN_LoadModule( name, TRUE )))
+            /* Try to load the built-in first if not disabled */
+            if ((hModule = BUILTIN_LoadModule( name, FALSE ))) return hModule;
+            
+            if ((hFile = OpenFile32( name, &ofs, OF_READ )) == HFILE_ERROR32)
             {
-                fprintf( stderr, "Warning: could not load Windows DLL '%s', using built-in module.\n", name );
+                /* Now try the built-in even if disabled */
+                if ((hModule = BUILTIN_LoadModule( name, TRUE )))
+                {
+                    fprintf( stderr, "Warning: could not load Windows DLL '%s', using built-in module.\n", name );
+                    return hModule;
+                }
+                return 2;  /* File not found */
+            }
+
+            /* Create the module structure */
+
+            hModule = MODULE_LoadExeHeader( hFile, &ofs );
+            if (hModule < 32)
+            {
+                if (hModule == 21)
+                    hModule = PE_LoadModule( hFile, &ofs, paramBlock );
+                else _lclose32( hFile );
+
+                if (hModule < 32)
+                    fprintf( stderr, "LoadModule: can't load '%s', error=%d\n",
+                             name, hModule );
                 return hModule;
             }
-            return 2;  /* File not found */
+            _lclose32( hFile );
+            pModule = MODULE_GetPtr( hModule );
+            pModule->flags |= uFlags; /* stamp implicitly loaded modules */
+
+            /* Allocate the segments for this module */
+
+            MODULE_CreateSegments( hModule );
+            hPrevInstance = 0;
+            hInstance = MODULE_CreateInstance(hModule,(LOADPARAMS*)paramBlock);
+
+            /* Load the referenced DLLs */
+
+            if (!NE_LoadDLLs( pModule )) return 2;  /* File not found */
+
+            /* Load the segments */
+
+            NE_LoadAllSegments( pModule );
+
+            /* Fixup the functions prologs */
+
+            NE_FixupPrologs( pModule );
+
+            /* Make sure the usage count is 1 on the first loading of  */
+            /* the module, even if it contains circular DLL references */
+
+            pModule->count = 1;
+
+            /* Call initialization rountines for all loaded DLLs. Note that
+             * when we load implicitly linked DLLs this will be done by InitTask().
+             */
+
+            if ((pModule->flags & (NE_FFLAGS_LIBMODULE | NE_FFLAGS_IMPLICIT)) ==
+                                       NE_FFLAGS_LIBMODULE )
+                NE_InitializeDLLs( hModule );
         }
-
-	/*
-	 * Record this so that the internal debugger gets some
-	 * record of what it is that we are working with.
-	 */
-	DEBUG_curr_module = name;
-
-          /* Create the module structure */
-
-        hModule = MODULE_LoadExeHeader( hFile, &ofs );
-        if (hModule < 32)
+        else /* module is already loaded, just create a new data segment if it's a task */
         {
-            if (hModule == 21)
-                hModule = PE_LoadModule( hFile, &ofs, paramBlock );
-	    else _lclose32( hFile );
-
-            if (hModule < 32)
-                fprintf( stderr, "LoadModule: can't load '%s', error=%d\n",
-                         name, hModule );
-            return hModule;
+            pModule = MODULE_GetPtr( hModule );
+            hPrevInstance = MODULE_GetInstance( hModule );
+            hInstance = MODULE_CreateInstance( hModule, params );
+            if (hInstance != hPrevInstance)  /* not a library */
+                NE_LoadSegment( pModule, pModule->dgroup );
+            pModule->count++;
         }
-        _lclose32( hFile );
-        pModule = MODULE_GetPtr( hModule );
-	pModule->flags |= uFlags; /* stamp implicitly loaded modules */
+    } /* !winelib */
 
-          /* Allocate the segments for this module */
-
-        MODULE_CreateSegments( hModule );
-
-        hPrevInstance = 0;
-        hInstance = MODULE_CreateInstance( hModule, (LOADPARAMS*)paramBlock );
-
-          /* Load the referenced DLLs */
-
-        pModRef = (WORD *)((char *)pModule + pModule->modref_table);
-        pDLLs = (WORD *)GlobalLock16( pModule->dlls_to_init );
-        for (i = 0; i < pModule->modref_count; i++, pModRef++)
-        {
-            char buffer[256];
-            BYTE *pstr = (BYTE *)pModule + pModule->import_table + *pModRef;
-            memcpy( buffer, pstr + 1, *pstr );
-            strcpy( buffer + *pstr, ".dll" );
-            dprintf_module( stddeb, "Loading '%s'\n", buffer );
-            if (!(*pModRef = MODULE_FindModule( buffer )))
-            {
-                /* If the DLL is not loaded yet, load it and store */
-                /* its handle in the list of DLLs to initialize.   */
-                HMODULE16 hDLL;
-
-                if ((hDLL = MODULE_Load( buffer, (LPVOID)-1, NE_FFLAGS_IMPLICIT )) == 2)
-                {
-                    /* file not found */
-                    char *p;
-
-                    /* Try with prepending the path of the current module */
-                    GetModuleFileName16( hModule, buffer, sizeof(buffer) );
-                    if (!(p = strrchr( buffer, '\\' ))) p = buffer;
-                    memcpy( p + 1, pstr + 1, *pstr );
-                    strcpy( p + 1 + *pstr, ".dll" );
-                    hDLL = MODULE_Load( buffer, (LPVOID)-1, NE_FFLAGS_IMPLICIT );
-                }
-                if (hDLL < 32)
-                {
-		    /* FIXME: cleanup what was done */
-
-                    fprintf( stderr, "Could not load '%s' required by '%s', error = %d\n",
-                             buffer, name, hDLL );
-                    return 2;  /* file not found */
-                }
-                *pModRef = MODULE_HANDLEtoHMODULE16( hDLL );
-                *pDLLs++ = *pModRef;
-            }
-            else  /* Increment the reference count of the DLL */
-            {
-                NE_MODULE *pOldDLL = MODULE_GetPtr( *pModRef );
-                if (pOldDLL) pOldDLL->count++;
-            }
-        }
-
-          /* Load the segments */
-
-	if (pModule->flags & NE_FFLAGS_SELFLOAD)
-	{
-                HFILE32 hf;
-		/* Handle self loading modules */
-		SEGTABLEENTRY * pSegTable = (SEGTABLEENTRY *) NE_SEG_TABLE(pModule);
-		SELFLOADHEADER *selfloadheader;
-                STACK16FRAME *stack16Top;
-		HMODULE16 hselfload = GetModuleHandle16("WPROCS");
-                DWORD oldstack;
-		WORD saved_dgroup = pSegTable[pModule->dgroup - 1].selector;
-
-		dprintf_module(stddeb, "MODULE_Load: %*.*s is a self-loading module!\n",
-					*((BYTE*)pModule + pModule->name_table),
-					*((BYTE*)pModule + pModule->name_table),
-					 (char *)pModule + pModule->name_table + 1);
-
-		NE_LoadSegment( hModule, 1 );
-		selfloadheader = (SELFLOADHEADER *)
-			PTR_SEG_OFF_TO_LIN(pSegTable->selector, 0);
-		selfloadheader->EntryAddrProc = 
-                                           MODULE_GetEntryPoint(hselfload,27);
-		selfloadheader->MyAlloc  = MODULE_GetEntryPoint(hselfload,28);
-		selfloadheader->SetOwner = MODULE_GetEntryPoint(GetModuleHandle16("KERNEL"),403);
-		pModule->self_loading_sel = GlobalHandleToSel(
-					GLOBAL_Alloc (GMEM_ZEROINIT,
-					0xFF00, hModule, FALSE, FALSE, FALSE)
-					);
-		oldstack = IF1632_Saved16_ss_sp;
-		IF1632_Saved16_ss_sp =
-                    PTR_SEG_OFF_TO_SEGPTR( pModule->self_loading_sel,
-                                           0xff00 - sizeof(*stack16Top) );
-                stack16Top = CURRENT_STACK16;
-                stack16Top->saved_ss_sp = 0;
-                stack16Top->ebp = 0;
-                stack16Top->ds = stack16Top->es = pModule->self_loading_sel;
-                stack16Top->entry_point = 0;
-                stack16Top->entry_ip = 0;
-                stack16Top->entry_cs = 0;
-                stack16Top->bp = 0;
-                stack16Top->ip = 0;
-                stack16Top->cs = 0;
-
-                hf = FILE_DupUnixHandle( MODULE_OpenFile( hModule ) );
-                Callbacks->CallBootAppProc( selfloadheader->BootApp,
-                                            hModule, hf );
-                _lclose32(hf);
-		/* some BootApp procs overwrite the selector of dgroup */
-		pSegTable[pModule->dgroup - 1].selector = saved_dgroup;
-		IF1632_Saved16_ss_sp = oldstack;
-		for (i = 2; i <= pModule->seg_count; i++)
-                    NE_LoadSegment( hModule, i );
-	} 
-	else
-        {
-            for (i = 1; i <= pModule->seg_count; i++)
-                NE_LoadSegment( hModule, i );
-        }
-
-          /* Fixup the functions prologs */
-
-        NE_FixupPrologs( pModule );
-
-          /* Make sure the usage count is 1 on the first loading of  */
-          /* the module, even if it contains circular DLL references */
-
-        pModule->count = 1;
-
-	  /* Call initialization rountines for all loaded DLLs. Note that
-	   * when we load implicitly linked DLLs this will be done by the InitTask().
-	   */
-
-        if ((pModule->flags & (NE_FFLAGS_LIBMODULE | NE_FFLAGS_IMPLICIT)) ==
-			       NE_FFLAGS_LIBMODULE ) NE_InitializeDLLs( hModule );
-    }
-    else /* module is already loaded, just create a new data segment if it's a task */
-    {
-        pModule = MODULE_GetPtr( hModule );
-        hPrevInstance = MODULE_GetInstance( hModule );
-        hInstance = MODULE_CreateInstance( hModule, params );
-        if (hInstance != hPrevInstance)  /* not a library */
-            NE_LoadSegment( hModule, pModule->dgroup );
-        pModule->count++;
-    }
-
-#else
-    lstrcpyn32A( ofs.szPathName, name, sizeof(ofs.szPathName) );
-    if ((hModule = MODULE_CreateDummyModule( &ofs )) < 32) return hModule;
-    pModule = (NE_MODULE *)GlobalLock16( hModule );
-    hPrevInstance = 0;
-    hInstance = MODULE_CreateInstance( hModule, params );
-#endif /* WINELIB */
-
-      /* Create a task for this instance */
+    /* Create a task for this instance */
 
     if (!(pModule->flags & NE_FFLAGS_LIBMODULE) && (paramBlock != (LPVOID)-1))
     {
@@ -1675,13 +1604,9 @@
 
 	if (use_load_module)
 	{
-#ifdef WINELIB
-	    /* WINELIB: Use LoadModule() only for the program itself */
-	    use_load_module = 0;
-	    params.hEnvironment = (HGLOBAL16)GetDOSEnvironment();
-#else
+	    /* Winelib: Use LoadModule() only for the program itself */
+	    if (__winelib) use_load_module = 0;
 	    params.hEnvironment = (HGLOBAL16)SELECTOROF( GetDOSEnvironment() );
-#endif  /* WINELIB */
 	    params.cmdLine  = (SEGPTR)WIN16_GlobalLock16( cmdLineHandle );
 	    params.showCmd  = (SEGPTR)WIN16_GlobalLock16( cmdShowHandle );
 	    params.reserved = 0;
@@ -1840,7 +1765,6 @@
  */
 FARPROC32 WINAPI GetProcAddress32( HMODULE32 hModule, LPCSTR function )
 {
-#ifndef WINELIB
     NE_MODULE *pModule;
 
     if (HIWORD(function))
@@ -1858,9 +1782,6 @@
 	return (FARPROC32)0;
     }
     return PE_FindExportedFunction( pModule->pe_module, function );
-#else
-    return NULL;
-#endif
 }
 
 /***********************************************************************