diff -ur wine971116-clean/Makefile.in wine971116/Makefile.in
--- wine971116-clean/Makefile.in	Sun Nov 16 09:31:35 1997
+++ wine971116/Makefile.in	Mon Nov 24 19:57:55 1997
@@ -96,18 +96,24 @@
 
 install:: install_$(MAIN_TARGET)
 
-emu: wine
+emu: wine.dummy
 
 lib: $(LIB_TARGET)
 
-wine wine.sym: $(LIB_TARGET) $(EMUSUBDIRS) dummy
+wine.dummy: $(LIB_TARGET).dummy $(EMUSUBDIRS) dummy wine
+
+wine wine.sym: $(LIB_TARGET) $(EMUOBJS)
 	$(CC) -o wine $(EMUOBJS) $(LIB_TARGET) $(LDOPTIONS) $(X_LIBS) $(XPM_LIB) $(XLIB) $(LDLIBS)
 	nm -n wine | grep -v _compiled >wine.sym
 
-libwine.a: $(LIBSUBDIRS) dummy
+libwine.a.dummy: $(LIBSUBDIRS) dummy libwine.a
+
+libwine.a: $(LIBOBJS)
 	$(RM) $@
 	$(AR) $@ $(LIBOBJS)
 	$(RANLIB) $@
+
+libwine.so.1.0.dummy: libwine.so.1.0
 
 libwine.so.1.0: $(LIBSUBDIRS) dummy
 	$(CC) -shared -Wl,-soname,libwine.so -o$@ $(LIBOBJS) $(LDOPTIONS) $(X_LIBS) $(XPM_LIB) $(XLIB) $(LDLIBS)
diff -ur wine971116-clean/controls/edit.c wine971116/controls/edit.c
--- wine971116-clean/controls/edit.c	Sun Nov 16 09:31:37 1997
+++ wine971116/controls/edit.c	Mon Nov 24 19:57:55 1997
@@ -84,6 +84,8 @@
 	INT32 left_margin;		/* in pixels */
 	INT32 right_margin;		/* in pixels */
 	RECT32 format_rect;
+	INT32 region_posx;		/* Position of cursor relative to region: */
+	INT32 region_posy;		/* -1: to left, 0: within, 1: to right */
 	EDITWORDBREAKPROC16 word_break_proc16;
 	EDITWORDBREAKPROC32A word_break_proc32A;
 	INT32 line_count;		/* number of lines */
@@ -2612,16 +2614,16 @@
 			 *	FIXME: do some GetABCCharWidth, or so
 			 *		This is just preliminary
 			 */
-			es->left_margin = es->right_margin = es->char_width;
+			es->left_margin = es->right_margin = es->char_width/4;
 		} else
-			es->left_margin = es->right_margin = es->char_width;
-		return;
+			es->left_margin = es->right_margin = es->char_width/4;
 	} else {
 		if (action & EC_LEFTMARGIN)
 			es->left_margin = left;
 		if (action & EC_RIGHTMARGIN)
 			es->right_margin = right;
 	}
+	dprintf_edit(stddeb, "EDIT_EM_SetMargins: left=%d, right=%d\n", es->left_margin, es->right_margin);
 }
 
 
@@ -2665,6 +2667,8 @@
 	UINT32 old_end = es->selection_end;
 	UINT32 len = lstrlen32A(es->text);
 
+	dprintf_edit(stddeb, "EDIT_EM_SetSel(%p,%p,%d,%d,%d\n",
+		     wnd,es,start,end,after_wrap);
 	if (start == -1) {
 		start = es->selection_end;
 		end = es->selection_end;
@@ -3479,6 +3483,7 @@
 	e = EDIT_CharFromPos(wnd, es, x, y, &after_wrap);
 	EDIT_EM_SetSel(wnd, es, (keys & MK_SHIFT) ? es->selection_start : e, e, after_wrap);
 	EDIT_EM_ScrollCaret(wnd, es);
+	es->region_posx = es->region_posy = 0;
 	SetTimer32(wnd->hwndSelf, 0, 100, NULL);
 	return 0;
 }
@@ -3508,6 +3513,7 @@
 {
 	INT32 e;
 	BOOL32 after_wrap;
+	INT32 prex, prey;
 
 	if (GetCapture32() != wnd->hwndSelf)
 		return 0;
@@ -3516,7 +3522,10 @@
 	 *	FIXME: gotta do some scrolling if outside client
 	 *		area.  Maybe reset the timer ?
 	 */
+	prex = x; prey = y;
 	EDIT_ConfinePoint(wnd, es, &x, &y);
+	es->region_posx = (prex < x) ? -1 : ((prex > x) ? 1 : 0);
+	es->region_posy = (prey < y) ? -1 : ((prey > y) ? 1 : 0);
 	e = EDIT_CharFromPos(wnd, es, x, y, &after_wrap);
 	EDIT_EM_SetSel(wnd, es, es->selection_start, e, after_wrap);
 	return 0;
@@ -3701,6 +3710,7 @@
 	if (text) {
 		dprintf_edit(stddeb, "\t'%s'\n", text);
 		EDIT_EM_ReplaceSel(wnd, es, FALSE, text);
+		es->x_offset = 0;
 	}
 	es->flags |= EF_MODIFIED;
 	es->flags |= EF_UPDATE;
@@ -3749,8 +3759,13 @@
  */
 static void EDIT_WM_Timer(WND *wnd, EDITSTATE *es, INT32 id, TIMERPROC32 timer_proc)
 {
+	if (es->region_posx < 0) {
+		EDIT_MoveBackward(wnd, es, TRUE);
+	} else if (es->region_posx > 0) {
+		EDIT_MoveForward(wnd, es, TRUE);
+	}
 /*
- *	FIXME: gotta do some scrolling here, like
+ *	FIXME: gotta do some vertical scrolling here, like
  *		EDIT_EM_LineScroll(wnd, 0, 1);
  */
 }
diff -ur wine971116-clean/debugger/expr.c wine971116/debugger/expr.c
--- wine971116-clean/debugger/expr.c	Sun Oct 12 09:16:00 1997
+++ wine971116/debugger/expr.c	Mon Nov 24 19:57:56 1997
@@ -417,6 +417,7 @@
       rtn.type = DEBUG_TypeIntConst;
       exp->un.rgister.result = DEBUG_GetRegister(exp->un.rgister.reg);
       rtn.off = (unsigned int) &exp->un.rgister.result;
+#if 0 /* I think this is broken for displaying registers in 32 bit mode: GCC */
       if( exp->un.rgister.reg == REG_EIP )
 	{
 	  rtn.seg = CS_reg(&DEBUG_context);
@@ -425,6 +426,9 @@
 	{
 	  rtn.seg = DS_reg(&DEBUG_context);
 	}
+#else
+      rtn.seg = 0;
+#endif
       break;
     case EXPR_TYPE_BINOP:
       exp1 = DEBUG_EvalExpr(exp->un.binop.exp1);
diff -ur wine971116-clean/files/dos_fs.c wine971116/files/dos_fs.c
--- wine971116-clean/files/dos_fs.c	Sun Aug 24 08:48:33 1997
+++ wine971116/files/dos_fs.c	Mon Nov 24 19:57:56 1997
@@ -373,15 +373,15 @@
 #ifdef VFAT_IOCTL_READDIR_BOTH
     if (dir->fd != -1)
     {
-        if (ioctl( dir->fd, VFAT_IOCTL_READDIR_BOTH, (long)dir->dirent ) == -1)
-            return FALSE;
-        if (!dir->dirent[0].d_reclen) return FALSE;
-        if (!DOSFS_ToDosFCBFormat( dir->dirent[0].d_name, dir->short_name ))
-            dir->short_name[0] = '\0';
-        *short_name = dir->short_name;
-        if (dir->dirent[1].d_name[0]) *long_name = dir->dirent[1].d_name;
-        else *long_name = dir->dirent[0].d_name;
-        return TRUE;
+        if (ioctl( dir->fd, VFAT_IOCTL_READDIR_BOTH, (long)dir->dirent ) != -1) {
+	    if (!dir->dirent[0].d_reclen) return FALSE;
+	    if (!DOSFS_ToDosFCBFormat( dir->dirent[0].d_name, dir->short_name ))
+		dir->short_name[0] = '\0';
+	    *short_name = dir->short_name;
+	    if (dir->dirent[1].d_name[0]) *long_name = dir->dirent[1].d_name;
+	    else *long_name = dir->dirent[0].d_name;
+	    return TRUE;
+	}
     }
 #endif  /* VFAT_IOCTL_READDIR_BOTH */
 
@@ -518,8 +518,8 @@
 
     if (!(dir = DOSFS_OpenDir( path )))
     {
-        dprintf_dosfs( stddeb, "DOSFS_FindUnixName(%s,%s): can't open dir\n",
-                       path, name );
+        dprintf_dosfs( stddeb, "DOSFS_FindUnixName(%s,%s): can't open dir: %s\n",
+                       path, name, strerror(errno) );
         return FALSE;
     }
 
diff -ur wine971116-clean/files/profile.c wine971116/files/profile.c
--- wine971116-clean/files/profile.c	Sun Oct 12 09:16:00 1997
+++ wine971116/files/profile.c	Mon Nov 24 19:57:56 1997
@@ -1021,6 +1021,27 @@
     return res;
 }
 
+/***********************************************************************
+ *           WritePrivateProfileSection32A   (KERNEL32)
+ */
+BOOL32 WINAPI WritePrivateProfileSection32A( LPCSTR section, 
+                                            LPCSTR string, LPCSTR filename )
+{
+    char *p =(char*)string;
+
+    fprintf( stdnimp,"WritePrivateProfileSection32A empty stup\n");
+    if (debugging_profile) {
+      fprintf(stddeb,"file(%s) => [%s]\n", filename,section);
+      while (*(p+1)) {
+	fprintf(stddeb,"%s\n",p);
+        p += strlen(p);
+	p += 1;
+      }
+    }
+    
+    return FALSE;
+}
+
 
 /***********************************************************************
  *           WriteOutProfiles   (KERNEL.315)
diff -ur wine971116-clean/graphics/x11drv/pen.c wine971116/graphics/x11drv/pen.c
--- wine971116-clean/graphics/x11drv/pen.c	Sun Feb  2 10:57:47 1997
+++ wine971116/graphics/x11drv/pen.c	Mon Nov 24 19:57:56 1997
@@ -13,6 +13,7 @@
 static const char PEN_dot[]        = { 1,1 };      /* --  --  --  --  --  -- */
 static const char PEN_dashdot[]    = { 4,3,2,3 };  /* ----   --   ----   --  */
 static const char PEN_dashdotdot[] = { 4,2,2,2,2,2 }; /* ----  --  --  ----  */
+static const char PEN_alternate[]  = { 1,1 };      /* FIXME */
 
 /***********************************************************************
  *           PEN_SelectObject
@@ -22,12 +23,15 @@
     HPEN32 prevHandle = dc->w.hPen;
 
     dc->w.hPen = hpen;
-    dc->u.x.pen.style = pen->logpen.lopnStyle;
+    dc->u.x.pen.style = pen->logpen.lopnStyle & PS_ALL_STYLES;
+    dc->u.x.pen.endcap = pen->logpen.lopnStyle & PS_ALL_ENDCAPS;
+    dc->u.x.pen.linejoin = pen->logpen.lopnStyle & PS_ALL_LINEJOINS;
+
     dc->u.x.pen.width = pen->logpen.lopnWidth.x * dc->vportExtX / dc->wndExtX;
     if (dc->u.x.pen.width < 0) dc->u.x.pen.width = -dc->u.x.pen.width;
     if (dc->u.x.pen.width == 1) dc->u.x.pen.width = 0;  /* Faster */
     dc->u.x.pen.pixel = COLOR_ToPhysical( dc, pen->logpen.lopnColor );    
-    switch(pen->logpen.lopnStyle)
+    switch(pen->logpen.lopnStyle & PS_ALL_STYLES)
     {
       case PS_DASH:
 	dc->u.x.pen.dashes = (char *)PEN_dash;
@@ -44,6 +48,14 @@
       case PS_DASHDOTDOT:
 	dc->u.x.pen.dashes = (char *)PEN_dashdotdot;
 	dc->u.x.pen.dash_len = 6;
+	break;
+      case PS_ALTERNATE:
+	/* FIXME: should be alternating _pixels_ that are set */
+	dc->u.x.pen.dashes = (char *)PEN_alternate;
+	dc->u.x.pen.dash_len = 2;
+	break;
+      case PS_USERSTYLE:
+	/* FIXME */
 	break;
     }
     
diff -ur wine971116-clean/if1632/advapi32.spec wine971116/if1632/advapi32.spec
--- wine971116-clean/if1632/advapi32.spec	Sat Nov  1 11:06:20 1997
+++ wine971116/if1632/advapi32.spec	Mon Nov 24 19:57:56 1997
@@ -87,8 +87,8 @@
 0083 stub LogonUserW
 0084 stub LookupAccountNameA
 0085 stub LookupAccountNameW
-0086 stub LookupAccountSidA
-0087 stub LookupAccountSidW
+0086 stdcall LookupAccountSidA(ptr ptr ptr ptr ptr ptr ptr) LookupAccountSid32A
+0087 stdcall LookupAccountSidW(ptr ptr ptr ptr ptr ptr ptr) LookupAccountSid32W
 0088 stub LookupPrivilegeDisplayNameA
 0089 stub LookupPrivilegeDisplayNameW
 0090 stub LookupPrivilegeNameA
diff -ur wine971116-clean/if1632/gdi32.spec wine971116/if1632/gdi32.spec
--- wine971116-clean/if1632/gdi32.spec	Sun Nov 16 09:31:47 1997
+++ wine971116/if1632/gdi32.spec	Mon Nov 24 19:57:56 1997
@@ -97,7 +97,7 @@
  90 stdcall EqualRgn(long long) EqualRgn32
  91 stdcall Escape(long long long ptr ptr) Escape32
  92 stdcall ExcludeClipRect(long long long long long) ExcludeClipRect32
- 93 stub ExtCreatePen
+ 93 stdcall ExtCreatePen(long long ptr long ptr) ExtCreatePen32
  94 stub ExtCreateRegion
  95 stdcall ExtEscape(long long long ptr long ptr) ExtEscape32
  96 stdcall ExtFloodFill(long long long long long) ExtFloodFill32
@@ -173,7 +173,7 @@
 166 stub GetCurrentObject
 167 stdcall GetCurrentPositionEx(long ptr) GetCurrentPositionEx32
 168 stdcall GetDCOrgEx(long ptr) GetDCOrgEx
-169 stub GetDIBColorTable
+169 stdcall GetDIBColorTable(long long long ptr) GetDIBColorTable32
 170 stdcall GetDIBits(long long long long ptr ptr long) GetDIBits32
 171 stdcall GetDeviceCaps(long long) GetDeviceCaps32
 172 stub GetDeviceGammaRamp
@@ -315,7 +315,7 @@
 308 stdcall SetBrushOrgEx(long long long ptr) SetBrushOrgEx
 309 stub SetColorAdjustment
 310 stub SetColorSpace
-311 stub SetDIBColorTable
+311 stdcall SetDIBColorTable(long long long ptr) SetDIBColorTable32
 312 stdcall SetDIBits(long long long long ptr ptr long) SetDIBits32
 313 stdcall SetDIBitsToDevice(long long long long long long long long long
                                ptr ptr long) SetDIBitsToDevice32
diff -ur wine971116-clean/if1632/kernel32.spec wine971116/if1632/kernel32.spec
--- wine971116-clean/if1632/kernel32.spec	Sat Nov  1 11:06:21 1997
+++ wine971116/if1632/kernel32.spec	Mon Nov 24 19:57:56 1997
@@ -160,7 +160,7 @@
 169 stub CreateNamedPipeW
 170 stub CreatePipe
 171 stdcall CreateProcessA(str str ptr ptr long long ptr str ptr ptr) CreateProcess32A
-172 stub CreateProcessW
+172 stdcall CreateProcessW(str str ptr ptr long long ptr str ptr ptr) CreateProcess32W
 173 stub CreateRemoteThread
 174 stdcall CreateSemaphoreA(ptr long long str) CreateSemaphore32A
 175 stdcall CreateSemaphoreW(ptr long long wstr) CreateSemaphore32W
@@ -531,7 +531,7 @@
 540 stdcall OpenFileMappingW(long long wstr) OpenFileMapping32W
 541 stdcall OpenMutexA(long long str) OpenMutex32A
 542 stdcall OpenMutexW(long long wstr) OpenMutex32W
-543 stub OpenProcess
+543 stdcall OpenProcess(long long long) OpenProcess32
 544 stub OpenProfileUserMapping
 545 stdcall OpenSemaphoreA(long long str) OpenSemaphore32A
 546 stdcall OpenSemaphoreW(long long wstr) OpenSemaphore32W
@@ -728,7 +728,7 @@
 737 stdcall WriteConsoleW(long ptr long ptr ptr) WriteConsole32W
 738 stdcall WriteFile(long ptr long ptr ptr) WriteFile
 739 stub WriteFileEx
-740 stub WritePrivateProfileSectionA
+740 stdcall WritePrivateProfileSectionA(str str str) WritePrivateProfileSection32A
 741 stub WritePrivateProfileSectionW
 742 stdcall WritePrivateProfileStringA(str str str str) WritePrivateProfileString32A
 743 stdcall WritePrivateProfileStringW(wstr wstr wstr wstr) WritePrivateProfileString32W
diff -ur wine971116-clean/if1632/ole32.spec wine971116/if1632/ole32.spec
--- wine971116-clean/if1632/ole32.spec	Sun Oct 12 09:16:05 1997
+++ wine971116/if1632/ole32.spec	Mon Nov 24 19:57:56 1997
@@ -38,7 +38,7 @@
  35 stub CoQueryReleaseObject
  36 stub CoRegisterClassObject
  37 stub CoRegisterMallocSpy
- 38 stub CoRegisterMessageFilter
+ 38 stdcall CoRegisterMessageFilter(ptr ptr) CoRegisterMessageFilter
  39 stub CoReleaseMarshalData
  40 stub CoRevokeClassObject
  41 stub CoRevokeMallocSpy
diff -ur wine971116-clean/if1632/shell32.spec wine971116/if1632/shell32.spec
--- wine971116-clean/if1632/shell32.spec	Sun Nov 16 09:31:47 1997
+++ wine971116/if1632/shell32.spec	Mon Nov 24 19:57:56 1997
@@ -67,7 +67,7 @@
  204 stub RealShellExecuteW
  205 stub RegenerateUserEnvironment
  206 stub SHAddToRecentDocs
- 207 stub SHAppBarMessage
+ 207 stdcall SHAppBarMessage(long ptr) SHAppBarMessage32
  208 stub SHBrowseForFolder
  209 stub SHBrowseForFolderA
  210 stub SHChangeNotify
diff -ur wine971116-clean/include/debugger.h wine971116/include/debugger.h
--- wine971116-clean/include/debugger.h	Sun Nov 16 09:31:50 1997
+++ wine971116/include/debugger.h	Mon Nov 24 19:57:56 1997
@@ -96,13 +96,13 @@
 
 #define DBG_CHECK_READ_PTR(addr,len) \
     (!DEBUG_IsBadReadPtr((addr),(len)) || \
-     (fprintf(stderr,"*** Invalid address "), \
+     (fprintf(stderr,"*** Invalid read address (%s:%d) ", __FILE__, __LINE__), \
       DEBUG_PrintAddress((addr),dbg_mode, FALSE), \
       fprintf(stderr,"\n"),0))
 
 #define DBG_CHECK_WRITE_PTR(addr,len) \
     (!DEBUG_IsBadWritePtr((addr),(len)) || \
-     (fprintf(stderr,"*** Invalid address "), \
+     (fprintf(stderr,"*** Invalid write address (%s:%d) ", __FILE__, __LINE__), \
       DEBUG_PrintAddress(addr,dbg_mode, FALSE), \
       fprintf(stderr,"\n"),0))
 
diff -ur wine971116-clean/include/ntdll.h wine971116/include/ntdll.h
--- wine971116-clean/include/ntdll.h	Sat Feb 15 06:25:44 1997
+++ wine971116/include/ntdll.h	Mon Nov 24 19:57:56 1997
@@ -17,14 +17,14 @@
 
 typedef struct {
 	BYTE	Value[6];
-} SID_IDENTIFIER_AUTHORITY,*LPSID_IDENTIFIER_AUTHORITY;
+} SID_IDENTIFIER_AUTHORITY,*PSID_IDENTIFIER_AUTHORITY,*LPSID_IDENTIFIER_AUTHORITY;
 
 typedef struct _SID {
 	BYTE	Revision;
 	BYTE	SubAuthorityCount;
 	SID_IDENTIFIER_AUTHORITY	IdentifierAuthority;
 	DWORD	SubAuthority[1];	/* more than one */
-} SID,*LPSID;
+} SID,*PSID,*LPSID;
 
 #define	SID_REVISION			(1)	/* Current revision */
 #define	SID_MAX_SUB_AUTHORITIES		(15)	/* current max subauths */
@@ -121,7 +121,18 @@
 	LPSID	Group;
 	LPACL	Sacl;
 	LPACL	Dacl;
-} SECURITY_DESCRIPTOR,*LPSECURITY_DESCRIPTOR;
+} SECURITY_DESCRIPTOR,*PSECURITY_DESCRIPTOR,*LPSECURITY_DESCRIPTOR;
+
+typedef enum tagSID_NAME_USE {
+	SidTypeUser = 1,
+	SidTypeGroup,
+	SidTypeDomain,
+	SidTypeAlias,
+	SidTypeWellKnownGroup,
+	SidTypeDeletedAccount,
+	SidTypeInvalid,
+	SidTypeUnknown
+} SID_NAME_USE,*PSID_NAME_USE,*LPSID_NAME_USE;
 
 /* NT lowlevel Strings (handled by Rtl* functions in NTDLL)
  * If they are zero terminated, Length does not include the terminating 0.
diff -ur wine971116-clean/include/ole2.h wine971116/include/ole2.h
--- wine971116-clean/include/ole2.h	Sun Jan 12 10:28:00 1997
+++ wine971116/include/ole2.h	Mon Nov 24 19:57:56 1997
@@ -7,6 +7,8 @@
 
 typedef LONG HRESULT;
 
+typedef LPVOID LPMESSAGEFILTER;
+
 #define S_OK	0
 #define S_FALSE	1
 
diff -ur wine971116-clean/include/pen.h wine971116/include/pen.h
--- wine971116-clean/include/pen.h	Sun Feb  2 10:57:50 1997
+++ wine971116/include/pen.h	Mon Nov 24 19:57:56 1997
@@ -9,6 +9,13 @@
 
 #include "gdi.h"
 
+#define PS_ALL_TYPES     (PS_GEOMETRIC|PS_COSMETIC)
+#define PS_ALL_STYLES    (PS_ALTERNATE|PS_SOLID|PS_DASH|PS_DOT|\
+			  PS_DASHDOT|PS_DASHDOTDOT|PS_NULL|PS_USERSTYLE|\
+			  PS_INSIDEFRAME)
+#define PS_ALL_ENDCAPS   (PS_ENDCAP_ROUND|PS_ENDCAP_SQUARE|PS_ENDCAP_FLAT)
+#define PS_ALL_LINEJOINS (PS_JOIN_BEVEL|PS_JOIN_MITER|PS_JOIN_ROUND)
+
   /* GDI logical pen object */
 typedef struct
 {
diff -ur wine971116-clean/include/process.h wine971116/include/process.h
--- wine971116-clean/include/process.h	Sun Sep 14 10:07:35 1997
+++ wine971116/include/process.h	Mon Nov 24 19:57:56 1997
@@ -102,7 +102,7 @@
 extern K32OBJ *PROCESS_GetObjPtr( HANDLE32 handle, K32OBJ_TYPE type );
 extern BOOL32 PROCESS_SetObjPtr( HANDLE32 handle, K32OBJ *ptr, DWORD flags );
 
-extern PDB32 *PROCESS_Create( TDB *pTask, LPCSTR cmd_line );
+extern PDB32 *PROCESS_Create( HMODULE16 hModule, TDB *pTask, LPCSTR cmd_line );
 extern void PROCESS_Destroy( K32OBJ *ptr );
 
 extern PDB32 *pCurrentProcess;
diff -ur wine971116-clean/include/shell.h wine971116/include/shell.h
--- wine971116-clean/include/shell.h	Sun Aug 24 08:48:45 1997
+++ wine971116/include/shell.h	Mon Nov 24 19:57:56 1997
@@ -50,6 +50,17 @@
 
 DECL_WINELIB_TYPE_AW(SHFILEINFO);
 
+typedef struct _AppBarData {
+	DWORD	cbSize;
+	HWND32	hWnd;
+	UINT32	uCallbackMessage;
+	UINT32	uEdge;
+	RECT32	rc;
+	LPARAM	lParam;
+} APPBARDATA, *PAPPBARDATA;
+
+DECL_WINELIB_TYPE(APPBARDATA);
+
 #define SHGFI_ICON              0x000000100     /* get icon */
 #define SHGFI_DISPLAYNAME       0x000000200     /* get display name */
 #define SHGFI_TYPENAME          0x000000400     /* get type name */
diff -ur wine971116-clean/include/windows.h wine971116/include/windows.h
--- wine971116-clean/include/windows.h	Sun Nov 16 09:31:55 1997
+++ wine971116/include/windows.h	Mon Nov 24 19:57:56 1997
@@ -1591,13 +1591,26 @@
 DECL_WINELIB_TYPE(LOGPEN);
 DECL_WINELIB_TYPE(LPLOGPEN);
 
-#define PS_SOLID	  0
-#define PS_DASH           1
-#define PS_DOT            2
-#define PS_DASHDOT        3
-#define PS_DASHDOTDOT     4
-#define PS_NULL 	  5
-#define PS_INSIDEFRAME 	  6
+#define PS_COSMETIC       0x00000000
+#define PS_GEOMETRIC      0x00010000
+
+#define PS_SOLID	  0x00000000
+#define PS_DASH           0x00000001
+#define PS_DOT            0x00000002
+#define PS_DASHDOT        0x00000003
+#define PS_DASHDOTDOT     0x00000004
+#define PS_NULL 	  0x00000005
+#define PS_INSIDEFRAME 	  0x00000006
+#define PS_USERSTYLE      0x00000007
+#define PS_ALTERNATE      0x00000008
+
+#define PS_ENDCAP_ROUND   0x00000000
+#define PS_ENDCAP_SQUARE  0x00000100
+#define PS_ENDCAP_FLAT    0x00000200
+
+#define PS_JOIN_ROUND     0x00000000
+#define PS_JOIN_BEVEL     0x00001000
+#define PS_JOIN_MITER     0x00002000
 
   /* Regions */
 
@@ -6350,6 +6363,8 @@
 BOOL16      WINAPI ExitWindows16(DWORD,UINT16);
 #define     ExitWindows32(a,b) ExitWindowsEx(EWX_LOGOFF,0xffffffff)
 #define     ExitWindows WINELIB_NAME(ExitWindows)
+HPEN32      WINAPI ExtCreatePen32(DWORD,DWORD,const LOGBRUSH32 *,DWORD,LPDWORD);
+#define     ExtCreatePen WINELIB_NAME(ExtCreatePen)
 BOOL16      WINAPI ExtFloodFill16(HDC16,INT16,INT16,COLORREF,UINT16);
 BOOL32      WINAPI ExtFloodFill32(HDC32,INT32,INT32,COLORREF,UINT32);
 #define     ExtFloodFill WINELIB_NAME(ExtFloodFill)
@@ -6549,6 +6564,8 @@
 INT16       WINAPI GetDeviceCaps16(HDC16,INT16);
 INT32       WINAPI GetDeviceCaps32(HDC32,INT32);
 #define     GetDeviceCaps WINELIB_NAME(GetDeviceCaps)
+UINT32      WINAPI GetDIBColorTable32(HDC32,UINT32,UINT32,RGBQUAD *);
+#define     GetDIBColorTable WINELIB_NAME(GetDIBColorTable)
 INT16       WINAPI GetDIBits16(HDC16,HBITMAP16,UINT16,UINT16,LPSTR,LPBITMAPINFO,UINT16);
 INT32       WINAPI GetDIBits32(HDC32,HBITMAP32,UINT32,UINT32,LPSTR,LPBITMAPINFO,UINT32);
 #define     GetDIBits WINELIB_NAME(GetDIBits)
@@ -7522,6 +7539,8 @@
 BOOL16      WINAPI SetDeskWallPaper16(LPCSTR);
 BOOL32      WINAPI SetDeskWallPaper32(LPCSTR);
 #define     SetDeskWallPaper WINELIB_NAME(SetDeskWallPaper)
+UINT32      WINAPI SetDIBColorTable32(HDC32,UINT32,UINT32,RGBQUAD *);
+#define     SetDIBColorTable WINELIB_NAME(SetDIBColorTable)
 INT16       WINAPI SetDIBits16(HDC16,HBITMAP16,UINT16,UINT16,LPCVOID,const BITMAPINFO*,UINT16);
 INT32       WINAPI SetDIBits32(HDC32,HBITMAP32,UINT32,UINT32,LPCVOID,const BITMAPINFO*,UINT32);
 #define     SetDIBits WINELIB_NAME(SetDIBits)
diff -ur wine971116-clean/include/winerror.h wine971116/include/winerror.h
--- wine971116-clean/include/winerror.h	Sun Jul 20 09:09:25 1997
+++ wine971116/include/winerror.h	Mon Nov 24 19:57:56 1997
@@ -35,6 +35,7 @@
 #define ERROR_FILENAME_EXCED_RANGE  206
 #define ERROR_MORE_DATA             234
 #define ERROR_NO_MORE_ITEMS         259
+#define ERROR_INVALID_ADDRESS       487
 #define ERROR_IO_DEVICE             1117
 #define ERROR_POSSIBLE_DEADLOCK     1131
 #define ERROR_BAD_DEVICE            1200
diff -ur wine971116-clean/include/x11drv.h wine971116/include/x11drv.h
--- wine971116-clean/include/x11drv.h	Mon Jun 16 10:36:02 1997
+++ wine971116/include/x11drv.h	Mon Nov 24 19:57:56 1997
@@ -14,6 +14,8 @@
 typedef struct
 {
     int          style;
+    int          endcap;
+    int          linejoin;
     int          pixel;
     int          width;
     char *       dashes;
diff -ur wine971116-clean/loader/pe_image.c wine971116/loader/pe_image.c
--- wine971116-clean/loader/pe_image.c	Sun Nov 16 09:31:57 1997
+++ wine971116/loader/pe_image.c	Mon Nov 24 20:18:29 1997
@@ -40,13 +40,20 @@
 /* convert PE image VirtualAddress to Real Address */
 #define RVA(x) ((unsigned int)load_addr+(unsigned int)(x))
 
-void dump_exports(IMAGE_EXPORT_DIRECTORY * pe_exports, unsigned int load_addr)
+void dump_exports(PE_MODULE * pe, IMAGE_EXPORT_DIRECTORY * pe_exports,
+		  unsigned int load_addr)
 { 
   char		*Module;
   int		i, j;
   u_short	*ordinal;
   u_long	*function,*functions;
   u_char	**name;
+  u_long	rva_start, rva_end;
+
+  rva_start = pe->pe_header->OptionalHeader
+      .DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress;
+  rva_end = rva_start + pe->pe_header->OptionalHeader
+      .DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].Size;
 
   Module = (char*)RVA(pe_exports->Name);
   dprintf_win32(stddeb,"\n*******EXPORT DATA*******\nModule name is %s, %ld functions, %ld names\n", 
@@ -67,6 +74,11 @@
       for (j = 0; j < pe_exports->NumberOfNames; j++)
           if (ordinal[j] == i)
               dprintf_win32( stddeb, "  %s", (char*)RVA(name[j]) );
+      if ((*function >= rva_start) && (*function <= rva_end)) {
+	  dprintf_win32(stddeb, " (forwarded -> %s)",
+			(char *) (RVA(*function)));
+      }
+
       dprintf_win32( stddeb,"\n" );
   }
 }
@@ -89,6 +101,9 @@
 	int				i;
 	PDB32				*process=(PDB32*)GetCurrentProcessId();
 	PE_MODREF			*pem;
+	u_long				rva_start, rva_end;
+	u_long				addr;
+	char				* forward, * end;
 
 	pem = process->modref_list;
 	while (pem && (pem->pe_module != pe))
@@ -112,11 +127,23 @@
 	function= (u_long*)   RVA(exports->AddressOfFunctions);
 	name	= (u_char **) RVA(exports->AddressOfNames);
 
+	rva_start = pe->pe_header->OptionalHeader
+		.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress;
+	rva_end = rva_start + pe->pe_header->OptionalHeader
+		.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].Size;
+
+	forward = NULL;
 	if (HIWORD(funcName)) {
 		for(i=0; i<exports->NumberOfNames; i++) {
 			ename=(char*)RVA(*name);
-			if(!strcmp(ename,funcName))
-				return (FARPROC32) RVA(function[*ordinal]);
+			if(!strcmp(ename,funcName)) {
+				addr = function[*ordinal];
+				if ((addr < rva_start) || (addr >= rva_end)) {
+					return (FARPROC32) RVA(addr);
+				}
+				forward = (char *) RVA(addr);
+				break;
+			}
 			ordinal++;
 			name++;
 		}
@@ -126,7 +153,23 @@
                                       LOWORD(funcName));
 			return NULL;
 		}
-		return (FARPROC32) RVA(function[(int)funcName-exports->Base]);
+		addr = function[(int)funcName-exports->Base];
+		if ((addr < rva_start) || (addr >= rva_end)) {
+			return (FARPROC32) RVA(addr);
+		}
+		forward = (char *) RVA(addr);
+	}
+	if (forward) {
+		char	module[256];
+		char	function[1024];
+		end = strchr(forward, '.');
+		if (! end)
+			return NULL;
+		strncpy(module, forward, (end - forward));
+		module[end-forward] = 0;
+		strcpy(function, end+1);
+		return GetProcAddress32(MODULE_FindModule(module), function);
+			
 	}
 	return NULL;
 }
@@ -494,6 +537,9 @@
 	dprintf_win32(stddeb, "Load addr is %x\n",load_addr);
 	vma_size = calc_vma_size(pe);
 	load_addr 	= (int) VirtualAlloc( (void*)load_addr, vma_size, MEM_RESERVE|MEM_COMMIT, PAGE_EXECUTE_READWRITE );
+	if (load_addr == 0) {
+		load_addr = (int) VirtualAlloc( NULL, vma_size, MEM_RESERVE|MEM_COMMIT, PAGE_EXECUTE_READWRITE );
+	}
         pem->load_addr	= load_addr;
 
 	dprintf_win32(stddeb, "Load addr is really %lx, range %x\n",
@@ -612,7 +658,7 @@
 		dprintf_win32(stdnimp,"Unknown directory 15 ignored\n");
 
 	if(pem->pe_reloc)	do_relocations(pem);
-	if(pem->pe_export)	dump_exports(pem->pe_export,load_addr);
+	if(pem->pe_export)	dump_exports(pe, pem->pe_export,load_addr);
 	if(pem->pe_import)	fixup_imports(process,pem);
   		
 	if (pem->pe_export)
diff -ur wine971116-clean/loader/resource.c wine971116/loader/resource.c
--- wine971116-clean/loader/resource.c	Sun Nov 16 09:31:58 1997
+++ wine971116/loader/resource.c	Mon Nov 24 19:57:56 1997
@@ -603,12 +603,16 @@
 {
     INT32 retval;
     LPWSTR buffer2 = NULL;
-    if (buffer) buffer2 = HeapAlloc( GetProcessHeap(), 0, buflen * 2 );
+    if (buffer && buflen)
+	buffer2 = HeapAlloc( GetProcessHeap(), 0, buflen * 2 );
     retval = LoadString32W(instance,resource_id,buffer2,buflen);
 
     if (buffer2)
     {
-        lstrcpynWtoA( buffer, buffer2, buflen );
+	if (retval) {
+	    lstrcpynWtoA( buffer, buffer2, buflen );
+	    retval = lstrlen32A( buffer );
+	}
 	HeapFree( GetProcessHeap(), 0, buffer2 );
     }
     return retval;
@@ -712,11 +716,15 @@
 {
     INT32 retval;
     LPSTR buffer2 = NULL;
-    if (buffer) buffer2 = HeapAlloc( GetProcessHeap(), 0, buflen );
+    if (buffer && buflen)
+	buffer2 = HeapAlloc( GetProcessHeap(), 0, buflen );
     retval = LoadMessage32A(instance,id,lang,buffer2,buflen);
     if (buffer)
     {
-        lstrcpynAtoW( buffer, buffer2, buflen );
+	if (retval) {
+	    lstrcpynAtoW( buffer, buffer2, buflen );
+	    retval = lstrlen32W( buffer );
+	}
 	HeapFree( GetProcessHeap(), 0, buffer2 );
     }
     return retval;
diff -ur wine971116-clean/loader/task.c wine971116/loader/task.c
--- wine971116-clean/loader/task.c	Sun Nov 16 09:31:58 1997
+++ wine971116/loader/task.c	Mon Nov 24 19:57:56 1997
@@ -515,7 +515,7 @@
 
     /* Create the Win32 part of the task */
 
-    pCurrentProcess = pdb32 = PROCESS_Create( pTask, cmdLine );
+    pCurrentProcess = pdb32 = PROCESS_Create( hModule, pTask, cmdLine );
     /* FIXME: check for pdb32 == NULL.  */
     pdb32->task = hTask;
     if (pModule->flags & NE_FFLAGS_WIN32)
diff -ur wine971116-clean/memory/virtual.c wine971116/memory/virtual.c
--- wine971116-clean/memory/virtual.c	Sat Nov  1 11:06:29 1997
+++ wine971116/memory/virtual.c	Mon Nov 24 19:57:56 1997
@@ -190,7 +190,9 @@
 
     /* Create the view structure */
 
-    size >>= page_shift;
+    if (size == 0) return NULL;
+    size = 1 + ((base + size - 1) >> page_shift) - (base >> page_shift);
+
     if (!(view = (FILE_VIEW *)malloc( sizeof(*view) + size - 1 ))) return NULL;
     view->base    = base;
     view->size    = size << page_shift;
@@ -475,6 +477,11 @@
             SetLastError( ERROR_OUTOFMEMORY );
             return NULL;
         }
+	if (base && ptr != base) {
+	    FILE_munmap( (LPVOID)ptr, 0, view_size );
+	    SetLastError( ERROR_INVALID_ADDRESS );
+	    return NULL;
+	}
         if (!base)
         {
             /* Release the extra memory while keeping the range */
diff -ur wine971116-clean/misc/ole2.c wine971116/misc/ole2.c
--- wine971116-clean/misc/ole2.c	Sun Oct 12 09:16:11 1997
+++ wine971116/misc/ole2.c	Mon Nov 24 19:57:56 1997
@@ -46,3 +46,16 @@
     return S_OK;
 }
 
+/***********************************************************************
+ *           CoRegisterMessageFilter   [OLE32.38]
+ */
+HRESULT CoRegisterMessageFilter(
+    LPMESSAGEFILTER lpMessageFilter,	/* Pointer to interface */
+    LPMESSAGEFILTER *lplpMessageFilter	/* Indirect pointer to prior instance if non-NULL */
+) {
+    dprintf_ole(stdnimp,"CoRegisterMessageFilter()\n");
+    if (lplpMessageFilter) {
+	*lplpMessageFilter = NULL;
+    }
+    return S_OK;
+}
diff -ur wine971116-clean/misc/shell.c wine971116/misc/shell.c
--- wine971116-clean/misc/shell.c	Sun Nov 16 09:32:01 1997
+++ wine971116/misc/shell.c	Mon Nov 24 19:57:56 1997
@@ -1250,6 +1250,30 @@
 }
 
 /*************************************************************************
+ *				SHAppBarMeesage32	[SHELL32.207]
+ */
+UINT32 WINAPI SHAppBarMessage32(DWORD msg, PAPPBARDATA data)
+{
+    fprintf(stdnimp,"SHAppBarMessage32(0x%08lx,%p)\n", msg, data);
+#if 0
+    switch (msg) {
+        case ABM_ACTIVATE:
+        case ABM_GETAUTOHIDEBAR:
+        case ABM_GETSTATE:
+        case ABM_GETTASKBARPOS:
+        case ABM_NEW:
+        case ABM_QUERYPOS:
+        case ABM_REMOVE:
+        case ABM_SETAUTOHIDEBAR:
+        case ABM_SETPOS:
+        case ABM_WINDOWPOSCHANGED:
+	    ;
+    }
+#endif
+    return 0;
+}
+
+/*************************************************************************
  *				CommandLineToArgvW	[SHELL32.7]
  */
 LPWSTR* WINAPI CommandLineToArgvW(LPWSTR cmdline,LPDWORD numargs)
diff -ur wine971116-clean/objects/dc.c wine971116/objects/dc.c
--- wine971116-clean/objects/dc.c	Sat Nov  1 11:06:36 1997
+++ wine971116/objects/dc.c	Mon Nov 24 19:57:56 1997
@@ -349,8 +349,32 @@
     }
     else val.line_style = LineSolid;
     val.line_width = dc->u.x.pen.width;
-    val.cap_style  = (val.line_width <= 1) ? CapNotLast : CapRound;
-    val.join_style = JoinMiter;
+    if (val.line_width <= 1) {
+	val.cap_style = CapNotLast;
+    } else {
+	switch (dc->u.x.pen.endcap)
+	{
+	case PS_ENDCAP_SQUARE:
+	    val.cap_style = CapProjecting;
+	    break;
+	case PS_ENDCAP_FLAT:
+	    val.cap_style = CapButt;
+	    break;
+	case PS_ENDCAP_ROUND:
+	default:
+	    val.cap_style = CapRound;
+	}
+    }
+    switch (dc->u.x.pen.linejoin)
+    {
+    case PS_JOIN_BEVEL:
+	val.join_style = JoinBevel;
+    case PS_JOIN_MITER:
+	val.join_style = JoinMiter;
+    case PS_JOIN_ROUND:
+    default:
+	val.join_style = JoinRound;
+    }
     XChangeGC( display, dc->u.x.gc, 
 	       GCFunction | GCForeground | GCBackground | GCLineWidth |
 	       GCLineStyle | GCCapStyle | GCJoinStyle | GCFillStyle, &val );
diff -ur wine971116-clean/objects/dib.c wine971116/objects/dib.c
--- wine971116-clean/objects/dib.c	Sun Nov 16 09:32:04 1997
+++ wine971116/objects/dib.c	Mon Nov 24 19:57:57 1997
@@ -27,7 +27,7 @@
 {
     DC               *dc;
     LPCVOID           bits;
-    DWORD             lines;
+    int               lines;
     DWORD             infoWidth;
     WORD              depth;
     WORD              infoBpp;
@@ -145,7 +145,7 @@
  * Return 1 for INFOHEADER, 0 for COREHEADER, -1 for error.
  */
 static int DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, DWORD *width,
-                              DWORD *height, WORD *bpp )
+                              int *height, WORD *bpp )
 {
     if (header->biSize == sizeof(BITMAPINFOHEADER))
     {
@@ -235,50 +235,67 @@
     return colorMapping;
 }
 
+/***********************************************************************
+ *           DIB_SetImageBits_1_Line
+ *
+ * Handles a single line of 1 bit data.
+ */
+static void DIB_SetImageBits_1_Line(DWORD dstwidth, int *colors,
+				    XImage *bmpImage, int h, const BYTE *bits)
+{
+    BYTE pix;
+    DWORD i, x;
+
+    for (i = dstwidth/8, x = 0; (i > 0); i--)
+    {
+	pix = *bits++;
+	XPutPixel( bmpImage, x++, h, colors[pix >> 7] );
+	XPutPixel( bmpImage, x++, h, colors[(pix >> 6) & 1] );
+	XPutPixel( bmpImage, x++, h, colors[(pix >> 5) & 1] );
+	XPutPixel( bmpImage, x++, h, colors[(pix >> 4) & 1] );
+	XPutPixel( bmpImage, x++, h, colors[(pix >> 3) & 1] );
+	XPutPixel( bmpImage, x++, h, colors[(pix >> 2) & 1] );
+	XPutPixel( bmpImage, x++, h, colors[(pix >> 1) & 1] );
+	XPutPixel( bmpImage, x++, h, colors[pix & 1] );
+    }
+    pix = *bits;
+    switch(dstwidth & 7)
+    {
+    case 7: XPutPixel( bmpImage, x++, h, colors[pix >> 7] ); pix <<= 1;
+    case 6: XPutPixel( bmpImage, x++, h, colors[pix >> 7] ); pix <<= 1;
+    case 5: XPutPixel( bmpImage, x++, h, colors[pix >> 7] ); pix <<= 1;
+    case 4: XPutPixel( bmpImage, x++, h, colors[pix >> 7] ); pix <<= 1;
+    case 3: XPutPixel( bmpImage, x++, h, colors[pix >> 7] ); pix <<= 1;
+    case 2: XPutPixel( bmpImage, x++, h, colors[pix >> 7] ); pix <<= 1;
+    case 1: XPutPixel( bmpImage, x++, h, colors[pix >> 7] );
+    }
+}
 
 /***********************************************************************
  *           DIB_SetImageBits_1
  *
  * SetDIBits for a 1-bit deep DIB.
  */
-static void DIB_SetImageBits_1( DWORD lines, const BYTE *srcbits,
+static void DIB_SetImageBits_1( int lines, const BYTE *srcbits,
                                 DWORD srcwidth, DWORD dstwidth,
                                 int *colors, XImage *bmpImage )
 {
-    DWORD i, x;
-    BYTE pix;
-    const BYTE *bits = srcbits;
+    int h;
 
     /* 32 bit aligned */
     DWORD linebytes = ((srcwidth + 31) & ~31) / 8;
 
-    while (lines--)
-    {
-	for (i = dstwidth/8, x = 0; (i > 0); i--)
-	{
-	    pix = *bits++;
-	    XPutPixel( bmpImage, x++, lines, colors[pix >> 7] );
-	    XPutPixel( bmpImage, x++, lines, colors[(pix >> 6) & 1] );
-	    XPutPixel( bmpImage, x++, lines, colors[(pix >> 5) & 1] );
-	    XPutPixel( bmpImage, x++, lines, colors[(pix >> 4) & 1] );
-	    XPutPixel( bmpImage, x++, lines, colors[(pix >> 3) & 1] );
-	    XPutPixel( bmpImage, x++, lines, colors[(pix >> 2) & 1] );
-	    XPutPixel( bmpImage, x++, lines, colors[(pix >> 1) & 1] );
-	    XPutPixel( bmpImage, x++, lines, colors[pix & 1] );
+    if (lines > 0) {
+	for (h = lines-1; h >=0; h--) {
+	    DIB_SetImageBits_1_Line(dstwidth, colors, bmpImage, h, srcbits);
+	    srcbits += linebytes;
 	}
-	pix = *bits;
-	switch(dstwidth & 7)
-	{
-	case 7: XPutPixel( bmpImage, x++, lines, colors[pix >> 7] ); pix <<= 1;
-	case 6: XPutPixel( bmpImage, x++, lines, colors[pix >> 7] ); pix <<= 1;
-	case 5: XPutPixel( bmpImage, x++, lines, colors[pix >> 7] ); pix <<= 1;
-	case 4: XPutPixel( bmpImage, x++, lines, colors[pix >> 7] ); pix <<= 1;
-	case 3: XPutPixel( bmpImage, x++, lines, colors[pix >> 7] ); pix <<= 1;
-	case 2: XPutPixel( bmpImage, x++, lines, colors[pix >> 7] ); pix <<= 1;
-	case 1: XPutPixel( bmpImage, x++, lines, colors[pix >> 7] );
+    } else {
+	lines = -lines;
+	for (h = 0; h < lines; h++) {
+	    DIB_SetImageBits_1_Line(dstwidth, colors, bmpImage, h, srcbits);
+	    srcbits += linebytes;
 	}
-	srcbits += linebytes;
-	bits	 = srcbits;
     }
 }
 
@@ -288,27 +305,40 @@
  *
  * SetDIBits for a 4-bit deep DIB.
  */
-static void DIB_SetImageBits_4( DWORD lines, const BYTE *srcbits,
+static void DIB_SetImageBits_4( int lines, const BYTE *srcbits,
                                 DWORD srcwidth, DWORD dstwidth,
                                 int *colors, XImage *bmpImage )
 {
     DWORD i, x;
+    int h;
     const BYTE *bits = srcbits;
   
     /* 32 bit aligned */
     DWORD linebytes = ((srcwidth+7)&~7)/2;
 
-    while (lines--)
-    {
-	for (i = dstwidth/2, x = 0; i > 0; i--)
-	{
-	    BYTE pix = *bits++;
-	    XPutPixel( bmpImage, x++, lines, colors[pix >> 4] );
-	    XPutPixel( bmpImage, x++, lines, colors[pix & 0x0f] );
-	}
-        if (dstwidth & 1) XPutPixel( bmpImage, x, lines, colors[*bits >> 4] );
-        srcbits += linebytes;
-        bits	 = srcbits;
+    if (lines > 0) {
+	for (h = lines-1; h >= 0; h--) {
+	    for (i = dstwidth/2, x = 0; i > 0; i--) {
+		BYTE pix = *bits++;
+		XPutPixel( bmpImage, x++, h, colors[pix >> 4] );
+		XPutPixel( bmpImage, x++, h, colors[pix & 0x0f] );
+	    }
+	    if (dstwidth & 1) XPutPixel( bmpImage, x, h, colors[*bits >> 4] );
+	    srcbits += linebytes;
+	    bits	 = srcbits;
+	}
+    } else {
+	lines = -lines;
+	for (h = 0; h < lines; h++) {
+	    for (i = dstwidth/2, x = 0; i > 0; i--) {
+		BYTE pix = *bits++;
+		XPutPixel( bmpImage, x++, h, colors[pix >> 4] );
+		XPutPixel( bmpImage, x++, h, colors[pix & 0x0f] );
+	    }
+	    if (dstwidth & 1) XPutPixel( bmpImage, x, h, colors[*bits >> 4] );
+	    srcbits += linebytes;
+	    bits	 = srcbits;
+	}
     }
 }
 
@@ -324,7 +354,7 @@
  *
  * SetDIBits for a 4-bit deep compressed DIB.
  */
-static void DIB_SetImageBits_RLE4( DWORD lines, const BYTE *bits, DWORD width,
+static void DIB_SetImageBits_RLE4( int lines, const BYTE *bits, DWORD width,
                                 DWORD dstwidth, int *colors, XImage *bmpImage )
 {
 	int x = 0, c, length;
@@ -384,22 +414,32 @@
  *
  * SetDIBits for an 8-bit deep DIB.
  */
-static void DIB_SetImageBits_8( DWORD lines, const BYTE *srcbits,
-                                DWORD srcwidth, DWORD dstwidth,
+static void DIB_SetImageBits_8( int lines, const BYTE *srcbits,
+				DWORD srcwidth, DWORD dstwidth,
                                 int *colors, XImage *bmpImage )
 {
     DWORD x;
+    int h;
     const BYTE *bits = srcbits;
 
     /* align to 32 bit */
     DWORD linebytes = (srcwidth + 3) & ~3;
 
-    while (lines--)
-    {
-	for (x = 0; x < dstwidth; x++)
-	    XPutPixel( bmpImage, x, lines, colors[*bits++] );
-        srcbits += linebytes;
-        bits     = srcbits;
+    if (lines > 0) {
+	for (h = lines - 1; h >= 0; h--) {
+	    for (x = 0; x < dstwidth; x++, bits++) {
+		XPutPixel( bmpImage, x, h, colors[*bits] );
+	    }
+	    bits = (srcbits += linebytes);
+	}
+    } else {
+	lines = -lines;
+	for (h = 0; h < lines; h++) {
+	    for (x = 0; x < dstwidth; x++, bits++) {
+		XPutPixel( bmpImage, x, h, colors[*bits] );
+	    }
+	    bits = (srcbits += linebytes);
+	}
     }
 }
 
@@ -434,7 +474,7 @@
   RleDelta	= 2		/* Delta */
 };
   
-static void DIB_SetImageBits_RLE8( DWORD lines, const BYTE *bits, DWORD width,
+static void DIB_SetImageBits_RLE8( int lines, const BYTE *bits, DWORD width,
                                 DWORD dstwidth, int *colors, XImage *bmpImage )
 {
     int x;			/* X-positon on each line.  Increases. */
@@ -583,29 +623,124 @@
 
 
 /***********************************************************************
+ *           DIB_SetImageBits_16
+ *
+ * SetDIBits for a 16-bit deep DIB.
+ */
+static void DIB_SetImageBits_16( int lines, const BYTE *srcbits,
+                                 DWORD srcwidth, DWORD dstwidth,
+				 DC *dc, XImage *bmpImage )
+{
+    DWORD x;
+    LPWORD ptr;
+    WORD val;
+    int h;
+    BYTE r, g, b;
+  
+    /* align to 32 bit */
+    DWORD linebytes = (srcwidth * 2 + 3) & ~3;
+
+    ptr = (LPWORD) srcbits;
+    if (lines > 0) {
+	for (h = lines - 1; h >= 0; h--) {
+	    for (x = 0; x < dstwidth; x++, ptr++) {
+		val = *ptr;
+		r = (BYTE) ((val & 0x7c00) >> 7);
+		g = (BYTE) ((val & 0x03e0) >> 2);
+		b = (BYTE) ((val & 0x001f) << 3);
+		XPutPixel( bmpImage, x, h,
+			   COLOR_ToPhysical(dc, RGB(r,g,b)) );
+	    }
+	    ptr = (LPWORD) (srcbits += linebytes);
+	}
+    } else {
+	lines = -lines;
+	for (h = 0; h < lines; h++) {
+	    for (x = 0; x < dstwidth; x++, ptr++) {
+		val = *ptr;
+		r = (BYTE) ((val & 0x7c00) >> 7);
+		g = (BYTE) ((val & 0x03e0) >> 2);
+		b = (BYTE) ((val & 0x001f) << 3);
+		XPutPixel( bmpImage, x, h,
+			   COLOR_ToPhysical(dc, RGB(r,g,b)) );
+	    }
+	    ptr = (LPWORD) (srcbits += linebytes);
+	}
+    }
+}
+
+
+/***********************************************************************
  *           DIB_SetImageBits_24
  *
  * SetDIBits for a 24-bit deep DIB.
  */
-static void DIB_SetImageBits_24( DWORD lines, const BYTE *srcbits,
+static void DIB_SetImageBits_24( int lines, const BYTE *srcbits,
                                  DWORD srcwidth, DWORD dstwidth,
 				 DC *dc, XImage *bmpImage )
 {
     DWORD x;
     const BYTE *bits = srcbits;
+    int h;
   
     /* align to 32 bit */
     DWORD linebytes = (srcwidth * 3 + 3) & ~3;
 
     /* "bits" order is reversed for some reason */
 
-    while (lines--)
-    {
-	for (x = 0; x < dstwidth; x++, bits += 3)
-	    XPutPixel( bmpImage, x, lines, 
-		       COLOR_ToPhysical(dc, RGB(bits[2],bits[1],bits[0])) );
+    if (lines > 0) {
+	for (h = lines - 1; h >= 0; h--) {
+	    for (x = 0; x < dstwidth; x++, bits += 3) {
+		XPutPixel( bmpImage, x, h, 
+			   COLOR_ToPhysical(dc, RGB(bits[2],bits[1],bits[0])));
+	    }
+	    bits = (srcbits += linebytes);
+	}
+    } else {
+	lines = -lines;
+	for (h = 0; h < lines; h++) {
+	    for (x = 0; x < dstwidth; x++, bits += 3) {
+		XPutPixel( bmpImage, x, h,
+			   COLOR_ToPhysical(dc, RGB(bits[2],bits[1],bits[0])));
+	    }
+	    bits = (srcbits += linebytes);
+	}
+    }
+}
+
 
-        bits = (srcbits += linebytes);
+/***********************************************************************
+ *           DIB_SetImageBits_32
+ *
+ * SetDIBits for a 32-bit deep DIB.
+ */
+static void DIB_SetImageBits_32( int lines, const BYTE *srcbits,
+                                 DWORD srcwidth, DWORD dstwidth,
+				 DC *dc, XImage *bmpImage )
+{
+    DWORD x;
+    const BYTE *bits = srcbits;
+    int h;
+  
+    DWORD linebytes = (srcwidth * 4);
+
+    if (lines > 0) {
+	for (h = lines - 1; h >= 0; h--) {
+	    for (x = 0; x < dstwidth; x++, bits += 4) {
+		XPutPixel( bmpImage, x, h, 
+			   COLOR_ToPhysical(dc, RGB(bits[2],bits[1],bits[0])));
+	    }
+	    bits = (srcbits += linebytes);
+	}
+    } else {
+	lines = -lines;
+	for (h = 0; h < lines; h++) {
+	    for (x = 0; x < dstwidth; x++, bits += 4) {
+		XPutPixel( bmpImage, x, h,
+			   COLOR_ToPhysical(dc, RGB(bits[2],bits[1],bits[0])));
+	    }
+	    bits = (srcbits += linebytes);
+	}
     }
 }
 
@@ -621,6 +756,7 @@
     int *colorMapping;
     XImage *bmpImage;
     DWORD compression = 0;
+    int lines;
 
     if (descr->info->bmiHeader.biSize == sizeof(BITMAPINFOHEADER))
         compression = descr->info->bmiHeader.biCompression;
@@ -635,7 +771,9 @@
     if( descr->dc->w.flags & DC_DIRTY ) CLIPPING_UpdateGCRegion(descr->dc);
 
       /* Transfer the pixels */
-    XCREATEIMAGE(bmpImage, descr->infoWidth, descr->lines, descr->depth );
+    lines = descr->lines;
+    if (lines < 0) lines = -lines;
+    XCREATEIMAGE(bmpImage, descr->infoWidth, lines, descr->depth );
 
     switch(descr->infoBpp)
     {
@@ -657,10 +795,19 @@
 	else DIB_SetImageBits_8( descr->lines, descr->bits, descr->infoWidth,
                                  descr->width, colorMapping, bmpImage );
 	break;
+    case 15:
+    case 16:
+	DIB_SetImageBits_16( descr->lines, descr->bits, descr->infoWidth,
+			     descr->width, descr->dc, bmpImage);
+	break;
     case 24:
 	DIB_SetImageBits_24( descr->lines, descr->bits, descr->infoWidth,
                              descr->width, descr->dc, bmpImage );
 	break;
+    case 32:
+	DIB_SetImageBits_32( descr->lines, descr->bits, descr->infoWidth,
+                             descr->width, descr->dc, bmpImage);
+	break;
     default:
         fprintf( stderr, "Invalid depth %d for SetDIBits!\n", descr->infoBpp );
         break;
@@ -670,7 +817,7 @@
                descr->xSrc, descr->ySrc, descr->xDest, descr->yDest,
                descr->width, descr->height );
     XDestroyImage( bmpImage );
-    return descr->lines;
+    return lines;
 }
 
 
@@ -732,7 +879,7 @@
 {
     DIB_SETIMAGEBITS_DESCR descr;
     BITMAPOBJ * bmp;
-    DWORD height;
+    int height, tmpheight;
     INT32 result;
 
       /* Check parameters */
@@ -755,6 +902,8 @@
         GDI_HEAP_UNLOCK( hdc );
         return 0;
     }
+    tmpheight = height;
+    if (height < 0) height = -height;
     if (!lines || (startscan >= height))
     {
         GDI_HEAP_UNLOCK( hbitmap );
@@ -764,7 +913,7 @@
     if (startscan + lines > height) lines = height - startscan;
 
     descr.bits      = bits;
-    descr.lines     = lines;
+    descr.lines     = tmpheight >= 0 ? lines : -lines;
     descr.depth     = bmp->bitmap.bmBitsPixel;
     descr.info      = info;
     descr.coloruse  = coloruse;
@@ -807,7 +956,8 @@
 {
     DIB_SETIMAGEBITS_DESCR descr;
     DC * dc;
-    DWORD width, height;
+    DWORD width;
+    int height, tmpheight;
 
       /* Check parameters */
 
@@ -820,6 +970,8 @@
     if (DIB_GetBitmapInfo( &info->bmiHeader, &width,
                            &height, &descr.infoBpp ) == -1)
         return 0;
+    tmpheight = height;
+    if (height < 0) height = -height;
     if (!lines || (startscan >= height)) return 0;
     if (startscan + lines > height) lines = height - startscan;
     if (ySrc < startscan) ySrc = startscan;
@@ -834,7 +986,7 @@
 
     descr.dc        = dc;
     descr.bits      = bits;
-    descr.lines     = lines;
+    descr.lines     = tmpheight >= 0 ? lines : -lines;
     descr.infoWidth = width;
     descr.depth     = dc->w.bitsPerPixel;
     descr.info      = info;
@@ -851,6 +1003,92 @@
     return CALL_LARGE_STACK( DIB_SetImageBits, &descr );
 }
 
+/***********************************************************************
+ *           SetDIBColorTable32    (GDI32.311)
+ */
+UINT32 WINAPI SetDIBColorTable32( HDC32 hdc, UINT32 startpos, UINT32 entries,
+				  RGBQUAD *colors )
+{
+    DC * dc;
+    PALETTEENTRY * palEntry;
+    PALETTEOBJ * palette;
+    RGBQUAD *end;
+
+    dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
+    if (!dc) 
+    {
+	dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC);
+	if (!dc) return 0;
+    }
+
+    if (!(palette = (PALETTEOBJ*)GDI_GetObjPtr( dc->w.hPalette, PALETTE_MAGIC )))
+    {
+        return 0;
+    }
+
+    /* Transfer color info */
+    
+    if (dc->w.bitsPerPixel <= 8) {
+	palEntry = palette->logpalette.palPalEntry + startpos;
+	if (startpos + entries > (1 << dc->w.bitsPerPixel)) {
+	    entries = (1 << dc->w.bitsPerPixel) - startpos;
+	}
+	for (end = colors + entries; colors < end; palEntry++, colors++)
+	{
+	    palEntry->peRed   = colors->rgbRed;
+	    palEntry->peGreen = colors->rgbGreen;
+	    palEntry->peBlue  = colors->rgbBlue;
+	}
+    } else {
+	entries = 0;
+    }
+    GDI_HEAP_UNLOCK( dc->w.hPalette );
+    return entries;
+}
+
+/***********************************************************************
+ *           GetDIBColorTable32    (GDI32.169)
+ */
+UINT32 WINAPI GetDIBColorTable32( HDC32 hdc, UINT32 startpos, UINT32 entries,
+				  RGBQUAD *colors )
+{
+    DC * dc;
+    PALETTEENTRY * palEntry;
+    PALETTEOBJ * palette;
+    RGBQUAD *end;
+
+    dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
+    if (!dc) 
+    {
+	dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC);
+	if (!dc) return 0;
+    }
+
+    if (!(palette = (PALETTEOBJ*)GDI_GetObjPtr( dc->w.hPalette, PALETTE_MAGIC )))
+    {
+        return 0;
+    }
+
+    /* Transfer color info */
+    
+    if (dc->w.bitsPerPixel <= 8) {
+	palEntry = palette->logpalette.palPalEntry + startpos;
+	if (startpos + entries > (1 << dc->w.bitsPerPixel)) {
+	    entries = (1 << dc->w.bitsPerPixel) - startpos;
+	}
+	for (end = colors + entries; colors < end; palEntry++, colors++)
+	{
+	    colors->rgbRed      = palEntry->peRed;
+	    colors->rgbGreen    = palEntry->peGreen;
+	    colors->rgbBlue     = palEntry->peBlue;
+	    colors->rgbReserved = 0;
+	}
+    } else {
+	entries = 0;
+    }
+    GDI_HEAP_UNLOCK( dc->w.hPalette );
+    return entries;
+}
 
 
 /***********************************************************************
@@ -1018,6 +1256,18 @@
 		   bbits += pad;
 		}
 		break;
+	   case 32:
+		for( y = yend - 1; (int)y >= (int)startscan; y-- )
+		{
+		   *bbits = 0;
+		   for( x = 0; x < xend; x++ ) {
+		   	unsigned long pixel=XGetPixel( bmpImage, x, y);
+			*bbits++ = (pixel >>16) & 0xff;
+			*bbits++ = (pixel >> 8) & 0xff;
+			*bbits++ =  pixel       & 0xff;
+		   }
+		}
+		break;
 	   default:
 	   	fprintf(stderr,"GetDIBits*: unsupported depth %d\n",
 			info->bmiHeader.biBitCount
@@ -1069,10 +1319,12 @@
 {
     HBITMAP32 handle;
     BOOL32 fColor;
-    DWORD width, height;
+    DWORD width;
+    int height;
     WORD bpp;
 
     if (DIB_GetBitmapInfo( header, &width, &height, &bpp ) == -1) return 0;
+    if (height < 0) height = -height;
 
     /* Check if we should create a monochrome or color bitmap. */
     /* We create a monochrome bitmap only if it has exactly 2  */
diff -ur wine971116-clean/objects/gdiobj.c wine971116/objects/gdiobj.c
--- wine971116-clean/objects/gdiobj.c	Sun Nov 16 09:32:05 1997
+++ wine971116/objects/gdiobj.c	Mon Nov 24 19:57:57 1997
@@ -442,6 +442,7 @@
 	  result = FONT_GetObject32A( (FONTOBJ *)ptr, count, buffer );
 	  break;
       case PALETTE_MAGIC:
+      default:
           fprintf( stderr, "GetObject32: magic %04x not implemented\n",
                    ptr->wMagic );
           break;
diff -ur wine971116-clean/objects/metafile.c wine971116/objects/metafile.c
--- wine971116-clean/objects/metafile.c	Sat Nov  1 11:06:37 1997
+++ wine971116/objects/metafile.c	Mon Nov 24 19:57:57 1997
@@ -650,6 +650,8 @@
             dxx = (LPINT16)(sot+(((s1+1)>>1)*2));	   
           else 
 	  {
+	   dprintf_metafile(stddeb,"EXTTEXTOUT: %s  len: %ld\n",
+             sot,mr->rdSize);
            fprintf(stderr,
 	     "Please report: PlayMetaFile/ExtTextOut len=%ld slen=%d rdSize=%ld opt=%04x\n",
 		   len,s1,mr->rdSize,mr->rdParam[3]);
diff -ur wine971116-clean/objects/pen.c wine971116/objects/pen.c
--- wine971116-clean/objects/pen.c	Sun Aug 24 08:49:06 1997
+++ wine971116/objects/pen.c	Mon Nov 24 19:57:57 1997
@@ -73,6 +73,32 @@
     return hpen;
 }
 
+/***********************************************************************
+ *           ExtCreatePen    (GDI32.93)
+ *
+ * FIXME: PS_USERSTYLE not handled
+ */
+
+HPEN32 WINAPI ExtCreatePen32( DWORD style, DWORD width,
+			      const LOGBRUSH32 * brush, DWORD style_count,
+			      LPDWORD style_bits )
+{
+    LOGPEN32 logpen;
+
+    if ((style & PS_ALL_STYLES) == PS_USERSTYLE) {
+	fprintf(stderr, "ExtCreatePen32: PS_USERSTYLE not handled\n");
+    }
+    if ((style & PS_ALL_TYPES) == PS_GEOMETRIC) {
+	if (brush->lbHatch) {
+	    fprintf(stderr, "ExtCreatePen32: Hatches not implemented\n");
+	}
+    }
+    logpen.lopnStyle = style &~ (PS_ALL_TYPES);
+    logpen.lopnWidth.x = (style & PS_GEOMETRIC) ? width : 1;
+    logpen.lopnWidth.y = 0;
+    logpen.lopnColor = brush->lbColor;
+    return CreatePenIndirect32( &logpen );
+}
 
 /***********************************************************************
  *           PEN_GetObject16
diff -ur wine971116-clean/scheduler/process.c wine971116/scheduler/process.c
--- wine971116-clean/scheduler/process.c	Sun Oct 12 09:16:13 1997
+++ wine971116/scheduler/process.c	Mon Nov 24 19:57:57 1997
@@ -16,6 +16,9 @@
 #include "ldt.h"
 #include "thread.h"
 #include "winerror.h"
+#include "neexe.h"
+#include "peexe.h"
+#include "pe_image.h"
 
 PDB32 *pCurrentProcess = NULL;
 
@@ -303,10 +306,14 @@
 /***********************************************************************
  *           PROCESS_Create
  */
-PDB32 *PROCESS_Create( TDB *pTask, LPCSTR cmd_line )
+PDB32 *PROCESS_Create( HMODULE16 hModule, TDB *pTask, LPCSTR cmd_line )
 {
     PDB32 *pdb = HeapAlloc( SystemHeap, HEAP_ZERO_MEMORY, sizeof(PDB32) );
+    DWORD size, commit;
+    NE_MODULE *pModule;
+
     if (!pdb) return NULL;
+    if (!(pModule = MODULE_GetPtr( hModule ))) return 0;
     pdb->header.type     = K32OBJ_PROCESS;
     pdb->header.refcount = 1;
     pdb->exit_code       = 0x103; /* STILL_ACTIVE */
@@ -318,8 +325,17 @@
     pdb->group           = pdb;
     pdb->priority        = 8;  /* Normal */
     pdb->heap_list       = pdb->heap;
+
+    if (pModule->pe_module) {
+	size = pModule->pe_module->pe_header->OptionalHeader.SizeOfHeapReserve;
+	commit= pModule->pe_module->pe_header->OptionalHeader.SizeOfHeapCommit;
+    } else {
+	size = 0x10000;
+	commit = 0;
+    }
+    
     InitializeCriticalSection( &pdb->crit_section );
-    if (!(pdb->heap = HeapCreate( HEAP_GROWABLE, 0x10000, 0 ))) goto error;
+    if (!(pdb->heap = HeapCreate( HEAP_GROWABLE, size, commit ))) goto error;
     if (!(pdb->env_db = HeapAlloc(pdb->heap, HEAP_ZERO_MEMORY, sizeof(ENVDB))))
         goto error;
     if (!(pdb->handle_table = PROCESS_AllocHandleTable( pdb ))) goto error;
@@ -379,6 +395,21 @@
 }
 
 
+/*********************************************************************
+ *	OpenProcess				[KERNEL32.543]
+ *
+ */
+HANDLE32 WINAPI OpenProcess32(DWORD fdwAccess,BOOL32 bInherit,DWORD IDProcess)
+{
+	if (IDProcess != (DWORD)pCurrentProcess) {
+		fprintf(stderr,"OpenProcess32(%ld,%d,%ld)\n",fdwAccess,bInherit,IDProcess);
+		/* XXX: might not be the correct error value */
+		SetLastError( ERROR_INVALID_HANDLE );
+		return NULL;
+	}
+	return GetCurrentProcess();
+}			      
+
 /***********************************************************************
  *           GetCurrentProcessId   (KERNEL32.199)
  */
@@ -475,7 +506,13 @@
     }
     if (!*p) goto not_found;
     if (value) lstrcpyn32A( value, p + len + 1, size );
-    return strlen(p);
+    len = strlen(p);
+    /* According to the Win32 docs, if there is not enough room, return
+     * the size required to hold the string plus the terminating null
+     */
+    if (size <= len) len++;
+    return len;
+	
 not_found:
     return 0;  /* FIXME: SetLastError */
 }
@@ -597,8 +634,8 @@
 				LPSTR	x = HeapAlloc(heap,0,end-s+1);
 				char	buf[2];
 
-				lstrcpyn32A(x,s+1,end-s-1);
-				x[end-s-1]=0;
+				lstrcpyn32A(x,s+1,end-s);
+				x[end-s]=0;
 
 				/* put expanded variable directly into 
 				 * destination string, so we don't have
@@ -606,9 +643,10 @@
 				 */
 				ret = GetEnvironmentVariable32A(x,buf,2);
 				CHECK_FREE(ret+2);
-				ret = GetEnvironmentVariable32A(x,d,d-xdst);
+				ret = GetEnvironmentVariable32A(x,d,cursize-(d-xdst));
 				if (ret) {
 					d+=strlen(d);
+					s=end;
 				} else {
 					CHECK_FREE(strlen(x)+2);
 					*d++='%';
@@ -618,9 +656,9 @@
 				}
 				HeapFree(heap,0,x);
 			} else
-				*d=*s;
+				*d++=*s;
 
-			s++;d++;
+			s++;
 		} else {
 			CHECK_FREE(1);
 			*d++=*s++;
diff -ur wine971116-clean/win32/advapi.c wine971116/win32/advapi.c
--- wine971116-clean/win32/advapi.c	Sun Oct 12 09:16:15 1997
+++ wine971116/win32/advapi.c	Mon Nov 24 19:57:57 1997
@@ -76,6 +76,10 @@
 	);
 	return TRUE;
 }
+
+/***********************************************************************
+ *           AdjustTokenPrivileges   [ADVAPI32.10]
+ */
 BOOL32 WINAPI AdjustTokenPrivileges(HANDLE32 TokenHandle,BOOL32 DisableAllPrivileges,
 	LPVOID NewState,DWORD BufferLength,LPVOID PreviousState,
 	LPDWORD ReturnLength )
diff -ur wine971116-clean/win32/environment.c wine971116/win32/environment.c
--- wine971116-clean/win32/environment.c	Sun Oct 12 09:16:15 1997
+++ wine971116/win32/environment.c	Mon Nov 24 19:57:57 1997
@@ -29,9 +29,9 @@
  */
 LPCWSTR WINAPI GetCommandLine32W(void)
 {
-    static WCHAR buffer[256];
+    static WCHAR buffer[1024];
 
-    lstrcpynAtoW(buffer,GetCommandLine32A(),256);
+    lstrcpynAtoW(buffer,GetCommandLine32A(),1024);
     return buffer;
 }
 
diff -ur wine971116-clean/win32/process.c wine971116/win32/process.c
--- wine971116-clean/win32/process.c	Sun Sep 28 10:33:16 1997
+++ wine971116/win32/process.c	Mon Nov 24 19:57:57 1997
@@ -417,7 +417,22 @@
 	DWORD creationflags,LPVOID env,LPCSTR curdir,
 	LPSTARTUPINFO32A startupinfo,LPPROCESS_INFORMATION processinfo
 ) {
-	fprintf(stderr,"CreateProcess(%s,%s,%p,%p,%d,%08lx,%p,%s,%p,%p)\n",
+	fprintf(stderr,"CreateProcessA(%s,%s,%p,%p,%d,%08lx,%p,%s,%p,%p), stub\n",
+		appname,cmdline,processattributes,threadattributes,
+		inherithandles,creationflags,env,curdir,startupinfo,processinfo
+	);
+	/* make from lcc uses system as fallback if CreateProcess returns
+	   FALSE, so return false */
+	return FALSE;
+}
+
+BOOL32 WINAPI CreateProcess32W(
+	LPCWSTR appname,LPWSTR cmdline,LPSECURITY_ATTRIBUTES processattributes,
+        LPSECURITY_ATTRIBUTES threadattributes,BOOL32 inherithandles,
+	DWORD creationflags,LPVOID env,LPCWSTR curdir,
+	LPSTARTUPINFO32W startupinfo,LPPROCESS_INFORMATION processinfo
+) {
+	printf(stderr,"CreateProcessW(%p,%p,%p,%p,%d,%08lx,%p,%p,%p,%p) stub\n",
 		appname,cmdline,processattributes,threadattributes,
 		inherithandles,creationflags,env,curdir,startupinfo,processinfo
 	);
@@ -427,7 +442,7 @@
 }
 
 BOOL32 WINAPI ContinueDebugEvent(DWORD pid,DWORD tid,DWORD contstatus) {
-	fprintf(stderr,"ContinueDebugEvent(%ld,%ld,%ld), stub\n",pid,tid,contstatus);
+	fprintf(stderr,"ContinueDebugEvent(%ld,%ld,%ld) stub\n",pid,tid,contstatus);
 	return TRUE;
 }
 
@@ -447,4 +462,3 @@
 	DOSFS_UnixTimeToFileTime(tms.tms_stime,lpKernelTime,0);
 	return TRUE;
 }
-
diff -ur wine971116-clean/win32/security.c wine971116/win32/security.c
--- wine971116-clean/win32/security.c	Sat Nov  1 11:06:38 1997
+++ wine971116/win32/security.c	Mon Nov 24 19:57:57 1997
@@ -3,6 +3,7 @@
 #include <string.h>
 
 #include "windows.h"
+#include "winerror.h"
 #include "ntdll.h"
 #include "stddebug.h"
 #include "debug.h"
@@ -199,3 +200,32 @@
 
     return TRUE;
 }
+
+/***********************************************************************
+ *           LookupAccountSidA   [ADVAPI32.86]
+ */
+BOOL32 WINAPI LookupAccountSid32A(LPCSTR system,PSID sid,
+				  LPCSTR account,LPDWORD accountSize,
+				  LPCSTR domain, LPDWORD domainSize,
+				  PSID_NAME_USE name_use)
+{
+	fprintf(stdnimp,"LookupAccountSid32A(%s,%p,%p,%p,%p,%p,%p),stub\n",
+		system,sid,account,accountSize,domain,domainSize,name_use);
+	SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+	return FALSE;
+}
+
+/***********************************************************************
+ *           LookupAccountSidW   [ADVAPI32.86]
+ */
+BOOL32 WINAPI LookupAccountSid32W(LPCWSTR system,PSID sid,
+				  LPCWSTR account,LPDWORD accountSize,
+				  LPCWSTR domain, LPDWORD domainSize,
+				  PSID_NAME_USE name_use)
+{
+	fprintf(stdnimp,"LookupAccountSid32W(%p,%p,%p,%p,%p,%p,%p),stub\n",
+		system,sid,account,accountSize,domain,domainSize,name_use);
+	SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+	return FALSE;
+}
+
diff -ur wine971116-clean/windows/message.c wine971116/windows/message.c
--- wine971116-clean/windows/message.c	Sun Sep 14 10:07:53 1997
+++ wine971116/windows/message.c	Mon Nov 24 19:57:57 1997
@@ -1136,7 +1136,7 @@
     WND **list, **ppWnd;
     LRESULT ret;
 
-    if (hwnd == HWND_BROADCAST)
+    if (hwnd == HWND_BROADCAST || hwnd == HWND_TOPMOST)
     {
         if (!(list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL )))
             return TRUE;
@@ -1187,7 +1187,7 @@
     WND **list, **ppWnd;
     LRESULT ret;
 
-    if (hwnd == HWND_BROADCAST)
+    if (hwnd == HWND_BROADCAST || hwnd == HWND_TOPMOST)
     {
         if (!(list = WIN_BuildWinArray( WIN_GetDesktop(), 0, NULL )))
             return TRUE;
diff -ur wine971116-clean/windows/win.c wine971116/windows/win.c
--- wine971116-clean/windows/win.c	Sun Nov 16 09:32:17 1997
+++ wine971116/windows/win.c	Mon Nov 24 19:57:57 1997
@@ -1783,14 +1783,23 @@
 
     WND *wndPtr = WIN_FindWndPtr( hwndChild );
     WND *pWndParent = WIN_FindWndPtr( hwndNewParent );
-    if (!wndPtr || !pWndParent || !(wndPtr->dwStyle & WS_CHILD)) return 0;
 
+    if (!wndPtr || !pWndParent) return 0;
     oldParent = wndPtr->parent->hwndSelf;
 
+    if (!(wndPtr->dwStyle & WS_CHILD)) {
+	if (wndPtr->window) {
+	    /* Toplevel window needs to be reparented.  Used by Tk 8.0 */
+	    XDestroyWindow( display, wndPtr->window );
+	    wndPtr->window = None;
+	}
+	wndPtr->dwStyle |= WS_CHILD;
+    }
+
     WIN_UnlinkWindow(hwndChild);
     if (hwndNewParent) wndPtr->parent = pWndParent;
     WIN_LinkWindow(hwndChild, HWND_BOTTOM);
-    
+
     if (IsWindowVisible32(hwndChild)) UpdateWindow32(hwndChild);
     
     return oldParent;
diff -ur wine971116-clean/windows/winpos.c wine971116/windows/winpos.c
--- wine971116-clean/windows/winpos.c	Sun Nov 16 09:32:18 1997
+++ wine971116/windows/winpos.c	Mon Nov 24 19:57:57 1997
@@ -2313,12 +2313,25 @@
 	wndPtr->dwStyle |= WS_VISIBLE;
         if (wndPtr->window)
         {
+	    HWND32 focus, curr;
+
 	    if( uFlags & SMC_SETXPOS )
 	    {
               WINPOS_SetXWindowPos( &winpos );
               winpos.hwndInsertAfter = tempInsertAfter;
 	    }
             XMapWindow( display, wndPtr->window );
+
+	    /* If focus was set to an unmapped window, reset X focus now */
+	    focus = curr = GetFocus32();
+	    while (curr != NULL) {
+		if (curr == hwnd) {
+		    SetFocus32( NULL );
+		    SetFocus32( focus );
+		    break;
+		}
+		curr = GetParent32(curr);
+	    }
         }
         else
         {
