Release 970415

Mon Apr 14 11:22:54 1997  John Harvey <john@division.co.uk>

	* [graphics/win16drv/init.c]
	Minor changes to help debug problems.

	* [if1632/dummy.c] [if1632/gdi.spec]
	Dummy routines for StartPage, EndPage, SetAbortProc, AbortProc.

	* [misc/printdrv.c] [if1632/gdi.spec] [include/windows.h]
	StartDoc16, EndDoc16 new functions.

Sun Apr 13 11:18:35 1997  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [memory/virtual.c]
	Implemented MapViewOfFile.

	* [debugger/dbg.y]
	Added 'info maps' command.

Fri Apr 11 16:34:08 1997  Frans van Dorsselaer <devel@rulhmpc58.LeidenUniv.nl>

	* [controls/edit.c] [controls/EDIT.TODO]
	Started restructuring.  Performance improvements.
	Fixed:	wordwrap, scrollbar handling, scrolling, painting,
		EditWndProc() is now reentrant, wordbreak procs,
		better compliance to specs.
	New:	margins, format rectangle.

	* [controls/widgets.c]
	Changed the cursor for the edit control class to an I-beam.

	* [include/callback.h]
	Added 32 bit wordbreak callback.

Mon Apr  7 20:53:28 1997  Albrecht Kleine  <kleine@ak.sax.de>

	* [objects/metafile.c]
	Added handling of some more metafile records: 
	META_CREATEREGION, META_INVERTREGION etc.

Sat Apr  5 09:23:02 MET DST 1997 Sven Verdoolaege <skimo@breughel.ufsia.ac.be>

	* [loader/signal.c]
	Define kernel sigaction ourselves instead of getting it
	from the kernel source.

Wed Apr  2 21:05:00 1997  Uwe Bonnes <bon@elektron.ikp.physik.th-darmstadt.de>

	* [control/menu.c]
	Fix return value range for GetMenuState.

	* [files/file.c]
	Always fill out ofs->szPathName in FILE_DoOpenFile.

	* [memory/string.c]
	Add debug option string.

	* [objects/cursoricon.c]
	Fix return value for DestroyIcon32.

Mon Mar 31 17:16:12 1997  Alex Korobka <alex@trantor.pharm.sunysb.edu>

	* [DEVELOPERS-HINTS] [misc/*] [windows/*] [graphics/*]
	Added description of the source tree. Moved several
	files to fit it.

	* [misc/shell.c]
	Use Win32 heap functions.
diff --git a/loader/module.c b/loader/module.c
index b247489..d7df2fe 100644
--- a/loader/module.c
+++ b/loader/module.c
@@ -1054,11 +1054,11 @@
         hModule = MODULE_LoadExeHeader( hFile, &ofs );
         if (hModule < 32)
         {
-            /* FIXME: Hack because PE_LoadModule is recursive */
-            int fd = dup( FILE_GetUnixHandle(hFile) );
-            _lclose32( hFile );
-            if (hModule == 21) hModule = PE_LoadModule( fd, &ofs, paramBlock );
-            close( fd );
+            /* Note: PE_LoadModule closes the file */
+            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 );
diff --git a/loader/ne_image.c b/loader/ne_image.c
index 0887a53..ec82673 100644
--- a/loader/ne_image.c
+++ b/loader/ne_image.c
@@ -527,7 +527,6 @@
         for (pDLL = (HMODULE16 *)GlobalLock16( to_init ); *pDLL; pDLL++)
         {
             NE_InitializeDLLs( *pDLL );
-            NE_InitDLL( *pDLL );
         }
         GlobalFree16( to_init );
     }
diff --git a/loader/pe_image.c b/loader/pe_image.c
index efcda7f..1e74f48 100644
--- a/loader/pe_image.c
+++ b/loader/pe_image.c
@@ -420,15 +420,17 @@
 	for(i=0; i < pe->pe_header->FileHeader.NumberOfSections; i++)
 	{
 		/* load only non-BSS segments */
-		if(pe->pe_seg[i].Characteristics & 
-			~ IMAGE_SCN_CNT_UNINITIALIZED_DATA)
-		if(lseek(fd,pe->pe_seg[i].PointerToRawData,SEEK_SET) == -1
-		|| read(fd,(char*)RVA(pe->pe_seg[i].VirtualAddress),
-			   pe->pe_seg[i].SizeOfRawData) != pe->pe_seg[i].SizeOfRawData)
-		{
+		if(!(pe->pe_seg[i].Characteristics & 
+			IMAGE_SCN_CNT_UNINITIALIZED_DATA))
+                {
+                    if(lseek(fd,pe->pe_seg[i].PointerToRawData,SEEK_SET) == -1
+                       || read(fd,(char*)RVA(pe->pe_seg[i].VirtualAddress),
+                               pe->pe_seg[i].SizeOfRawData) != pe->pe_seg[i].SizeOfRawData)
+                    {
 			fprintf(stderr,"Failed to load section %x\n", i);
 			exit(0);
-		}
+                    }
+                }
 		result = RVA (pe->pe_seg[i].VirtualAddress);
 #if 1
 		/* not needed, memory is zero */
@@ -568,21 +570,26 @@
 
 HINSTANCE16 MODULE_CreateInstance(HMODULE16 hModule,LOADPARAMS *params);
 
-HINSTANCE16 PE_LoadModule( int fd, OFSTRUCT *ofs, LOADPARAMS* params )
+HINSTANCE16 PE_LoadModule( HFILE32 hFile, OFSTRUCT *ofs, LOADPARAMS* params )
 {
     HMODULE16 hModule;
     HINSTANCE16 hInstance;
     NE_MODULE *pModule;
     struct mz_header_s mz_header;
+    int fd;
 
     if ((hModule = MODULE_CreateDummyModule( ofs )) < 32) return hModule;
     pModule = (NE_MODULE *)GlobalLock16( hModule );
     pModule->flags = NE_FFLAGS_WIN32;
 
+    /* FIXME: Hack because PE_LoadModule is recursive */
+    fd = dup( FILE_GetUnixHandle(hFile) );
+    _lclose32( hFile );
     lseek( fd, 0, SEEK_SET );
     read( fd, &mz_header, sizeof(mz_header) );
 
     pModule->pe_module = PE_LoadImage( fd, hModule, mz_header.ne_offset );
+    close( fd );
 
     hInstance = MODULE_CreateInstance( hModule, params );
 
@@ -653,8 +660,7 @@
 	
 		for (pDLL = (HMODULE16 *)GlobalLock16( to_init ); *pDLL; pDLL++)
 		{
-			PE_InitializeDLLs( *pDLL, type, lpReserved);
-			PE_InitDLL( *pDLL, type, lpReserved );
+                    PE_InitializeDLLs( *pDLL, type, lpReserved);
 		}
 		GlobalFree16( to_init );
 	}
diff --git a/loader/signal.c b/loader/signal.c
index fd2203f..96281bf 100644
--- a/loader/signal.c
+++ b/loader/signal.c
@@ -1,11 +1,7 @@
 #ifndef WINELIB
 #include <stdio.h>
 #include <stdlib.h>
-#ifdef __GLIBC__
-#include <linux/signal.h>
-#else
 #include <signal.h>
-#endif
 #include <string.h>
 #include <errno.h>
 #include <time.h>
@@ -39,11 +35,21 @@
 extern void ___sig_restore();
 extern void ___masksig_restore();
 
+/* This is the sigaction structure from the Linux 2.1.20 kernel.  */
+
+struct kernel_sigaction {
+	__sighandler_t sa_handler;
+	unsigned long sa_mask;
+	unsigned long sa_flags;
+	void (*sa_restorer) __P ((void));
+};
+
 /* Similar to the sigaction function in libc, except it leaves alone the
    restorer field */
 
 static int
-wine_sigaction(int sig,struct sigaction * new, struct sigaction * old)
+wine_sigaction(int sig,struct kernel_sigaction * new, 
+               struct kernel_sigaction * old)
 {
 	__asm__("int $0x80":"=a" (sig)
 		:"0" (SYS_sigaction),"b" (sig),"c" (new),"d" (old));
@@ -166,9 +172,9 @@
 static void SIGNAL_SetHandler( int sig, void (*func)(), int flags )
 {
     int ret;
-    struct sigaction sig_act;
 
 #ifdef linux
+    struct kernel_sigaction sig_act;
     sig_act.sa_handler = func;
     sig_act.sa_flags = SA_RESTART | (flags) ? SA_NOMASK : 0;
     /* Point to the top of the stack, minus 4 just in case, and make
@@ -179,6 +185,7 @@
 #endif  /* linux */
 
 #if defined(__NetBSD__) || defined(__FreeBSD__)
+    struct sigaction sig_act;
     sigset_t sig_mask;
     sigemptyset(&sig_mask);
     sig_act.sa_handler = func;
@@ -188,6 +195,7 @@
 #endif  /* __FreeBSD__ || __NetBSD__ */
 
 #if defined (__svr4__) || defined(_SCO_DS)
+    struct sigaction sig_act;
     sigset_t sig_mask;
     sigemptyset(&sig_mask);
     sig_act.sa_handler = func;
@@ -197,6 +205,7 @@
 #endif  /* __svr4__ || _SCO_DS */
 
 #if defined(__EMX__)
+    struct sigaction sig_act;
     sigset_t sig_mask;
     sigemptyset(&sig_mask);
     sig_act.sa_handler = func;
diff --git a/loader/task.c b/loader/task.c
index 9895f93..97cf296 100644
--- a/loader/task.c
+++ b/loader/task.c
@@ -679,10 +679,10 @@
  */
 void TASK_KillCurrentTask( INT16 exitCode )
 {
-    extern void EXEC_ExitWindows(void);
+    extern void USER_ExitWindows(void);
 
     TDB* pTask = (TDB*) GlobalLock16( hCurrentTask );
-    if (!pTask) EXEC_ExitWindows();  /* No current task yet */
+    if (!pTask) USER_ExitWindows();  /* No current task yet */
 
     /* Perform USER cleanup */
 
@@ -698,7 +698,7 @@
     if (nTaskCount <= 1)
     {
         dprintf_task( stddeb, "Killing the last task, exiting\n" );
-        EXEC_ExitWindows();
+        USER_ExitWindows();
     }
 
     /* Remove the task from the list to be sure we never switch back to it */