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/task.c b/loader/task.c
index b0c44ca..4c5d51f 100644
--- a/loader/task.c
+++ b/loader/task.c
@@ -65,9 +65,7 @@
     if (!(hDOSEnvironment = TASK_CreateDOSEnvironment()))
         fprintf( stderr, "Not enough memory for DOS Environment\n" );
     TASK_SystemTHDB.teb_sel = SELECTOR_AllocBlock( &TASK_SystemTHDB, 0x1000, SEGMENT_DATA, TRUE, FALSE );
-#ifdef __i386__
-    __asm__ __volatile__("movw %w0,%%fs"::"r"(TASK_SystemTHDB.teb_sel));
-#endif
+    SET_FS( TASK_SystemTHDB.teb_sel );
     return (hDOSEnvironment != 0);
 }
 
@@ -334,7 +332,6 @@
  * 32-bit entry point for a new task. This function is responsible for
  * setting up the registers and jumping to the 16-bit entry point.
  */
-#ifndef WINELIB
 static void TASK_CallToStart(void)
 {
     int exit_code = 1;
@@ -354,9 +351,7 @@
 
         InitTask( NULL );
         InitApp( pTask->hModule );
-#ifdef __i386__
-        __asm__ __volatile__("movw %w0,%%fs"::"r" (pCurrentThread->teb_sel));
-#endif
+        SET_FS( pCurrentThread->teb_sel );
         PE_InitializeDLLs( pCurrentProcess, DLL_PROCESS_ATTACH, (LPVOID)-1 );
         dprintf_relay( stddeb, "CallTo32(entryproc=%p)\n", entry );
         exit_code = entry();
@@ -398,7 +393,6 @@
         TASK_KillCurrentTask( 1 );
     }
 }
-#endif
 
 
 /***********************************************************************
@@ -415,13 +409,10 @@
     NE_MODULE *pModule;
     SEGTABLEENTRY *pSegTable;
     LPSTR name;
+    WORD sp;
     char *stack32Top;
     STACK16FRAME *frame16;
     STACK32FRAME *frame32;
-#ifndef WINELIB
-    extern DWORD CALLTO16_RetAddr_regs;
-    extern void CALLTO16_Restore();
-#endif
     
     if (!(pModule = MODULE_GetPtr( hModule ))) return 0;
     pSegTable = NE_SEG_TABLE( pModule );
@@ -489,10 +480,8 @@
 
     pTask->pdb.int20 = 0x20cd;
     pTask->pdb.dispatcher[0] = 0x9a;  /* ljmp */
-#ifndef WINELIB
-    *(FARPROC16 *)&pTask->pdb.dispatcher[1] = MODULE_GetEntryPoint(
-            GetModuleHandle16("KERNEL"), 102 );  /* KERNEL.102 is DOS3Call() */
-#endif
+    PUT_DWORD(&pTask->pdb.dispatcher[1], (DWORD)MODULE_GetEntryPoint(
+           GetModuleHandle16("KERNEL"), 102 ));  /* KERNEL.102 is DOS3Call() */
     pTask->pdb.savedint22 = INT_GetHandler( 0x22 );
     pTask->pdb.savedint23 = INT_GetHandler( 0x23 );
     pTask->pdb.savedint24 = INT_GetHandler( 0x24 );
@@ -538,11 +527,9 @@
 		pCurrentProcess->exe_modref->pe_module->pe_header->OptionalHeader.AddressOfEntryPoint);
      */
         pTask->thdb = THREAD_Create( pdb32, 0, 0 );
-#ifndef WINELIB
         /* FIXME: should not be done here */
         pCurrentThread = pTask->thdb;
         PE_InitTls( pdb32 );
-#endif
     }
     else
         pTask->thdb = THREAD_Create( pdb32, 0, NULL );
@@ -558,32 +545,26 @@
     frame32->edx = 0;
     frame32->ecx = 0;
     frame32->ebx = 0;
-    frame32->ebp = 0;
-#ifndef WINELIB
-    frame32->restore_addr = (DWORD)CALLTO16_Restore;
     frame32->retaddr = (DWORD)TASK_CallToStart;
-    frame32->codeselector = WINE_CODE_SELECTOR;
-#endif
+    /* The remaining fields will be initialized in TASK_Reschedule */
 
     /* Create the 16-bit stack frame */
 
-    pTask->ss_sp = PTR_SEG_OFF_TO_SEGPTR( hInstance,
-                        ((pModule->sp != 0) ? pModule->sp :
-                pSegTable[pModule->ss-1].minsize + pModule->stack_size) & ~1 );
-    pTask->ss_sp -= sizeof(STACK16FRAME) - sizeof(DWORD) /* for saved %esp */;
+    if (!(sp = pModule->sp))
+        sp = pSegTable[pModule->ss-1].minsize + pModule->stack_size;
+    sp &= ~1;
+    pTask->ss_sp = PTR_SEG_OFF_TO_SEGPTR( hInstance, sp );
+    pTask->ss_sp -= sizeof(STACK16FRAME) + sizeof(DWORD) /* for saved %esp */;
     frame16 = (STACK16FRAME *)PTR_SEG_TO_LIN( pTask->ss_sp );
     frame16->saved_ss_sp = 0;
-    frame16->ebp = 0;
+    frame16->ebp = sp + (int)&((STACK16FRAME *)0)->bp;
+    frame16->bp = LOWORD(frame16->ebp);
     frame16->ds = frame16->es = pTask->hInstance;
     frame16->entry_point = 0;
-    frame16->entry_ip = 0;
     frame16->entry_cs = 0;
-    frame16->bp = 0;
+    /* The remaining fields will be initialized in TASK_Reschedule */
+
     *(STACK32FRAME **)(frame16 + 1) = frame32; /* Store the 32-bit %esp */
-#ifndef WINELIB
-    frame16->ip = LOWORD( CALLTO16_RetAddr_regs );
-    frame16->cs = HIWORD( CALLTO16_RetAddr_regs );
-#endif  /* WINELIB */
 
       /* If there's no 16-bit stack yet, use a part of the new task stack */
       /* This is only needed to have a stack to switch from on the first  */
@@ -717,6 +698,7 @@
 {
     TDB *pOldTask = NULL, *pNewTask;
     HTASK16 hTask = 0;
+    STACK16FRAME *newframe16;
 
 #ifdef CONFIG_IPC
     dde_reschedule();
@@ -788,6 +770,23 @@
     TASK_LinkTask( hTask );
     pNewTask->priority--;
 
+    /* Finish initializing the new task stack if necessary */
+
+    newframe16 = (STACK16FRAME *)PTR_SEG_TO_LIN( pNewTask->ss_sp );
+    if (!newframe16->entry_cs)
+    {
+        STACK16FRAME *oldframe16 = CURRENT_STACK16;
+        STACK32FRAME *oldframe32 = *(STACK32FRAME **)(oldframe16 + 1);
+        STACK32FRAME *newframe32 = *(STACK32FRAME **)(newframe16 + 1);
+        newframe16->entry_ip     = oldframe16->entry_ip;
+        newframe16->entry_cs     = oldframe16->entry_cs;
+        newframe16->ip           = oldframe16->ip;
+        newframe16->cs           = oldframe16->cs;
+        newframe32->ebp          = oldframe32->ebp;
+        newframe32->restore_addr = oldframe32->restore_addr;
+        newframe32->codeselector = oldframe32->codeselector;
+    }
+    
     /* Switch to the new stack */
 
     hCurrentTask = hTask;