Release 970824

Sat Aug 23 00:05:23 1997  Andreas Mohr <100.30936@germany.net>

	* [if1632/kernel.spec] [if1632/mmsystem.spec]
	Added some stubs.

	* [include/neexe.h] [loader/module.c]
	Added warning for OS/2 executables.

	* [multimedia/midi.c]
	Shortened MIDIOUT driver version string to be less than 31 chars.

	* [objects/gdiobj.c]
	Fixed DeleteObject32() to react properly when called with stock object.

Fri Aug 22 18:03:26 1997  Dimitrie O. Paun <dimi@cs.toronto.edu>

	* [controls/updown.c] [include/updown.h]
	First attempt at implementiong the UpDown class.

	* [controls/widgets.c]
	Added the UpDown class to be initialized by InitCommonControls().

Wed Aug 20 18:01:33 1997  Doug Ridgway <ridgway@routh.UCSD.EDU>

	* [graphics/*] [objects/*] [include/gdi.h]
	Made all GDI objects (except DCs) moveable.

Mon Aug 18 03:25:30 1997  Alex Korobka <alex@trantor.pharm.sunysb.edu>

	* [windows/event.c] [misc/winsock.c] [misc/winsock_dns.c]
	Removed IPC communication to speed up winsock services
	(tested only with 16-bit netscape 3.03).

	* [graphics/x11drv/xfont.c] [documentation/fonts]
	Miscellaneous improvements. Updated docs.

Sun Aug 17 20:39:55 1997  Ingo Schneider <schneidi@informatik.tu-muenchen.de>

	* [misc/comm.c]
	A couple of bug fixes.

Sun Aug 17 19:29:22 1997  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [debugger/dbg.y]
	Display next instruction after stepi/nexti.

	* [if1632/relay.c] [include/callback.h] [tools/build.c]
	Replaced CallTo32_LargeStack with the CALL_LARGE_STACK macro for
	better Winelib support.

	* [include/sigcontext.h]
	Renamed to sig_context.h to avoid conflicts with libc.

	* [*/*]
	All API functions are now prefixed with WINAPI in prevision of
	future Winelib integration.

	* [loader/signal.c] [memory/ldt.c]
	Fixed assembly code to be -fPIC compatible.

Thu Aug 14 14:38:15 1997  Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>

	* [if1632/crtdll.spec][win32/except.c]
	_global_unwind, _local_unwind stub added.

	* [objects/dib.c]	
	Don't read memory you don't even need for the target bitmap (fixes
	one 'lazy' program).

	* [if1632/relay.c][if1632/thunk.c][if1632/kernel32.spec]
	  [win32/ordinals.c][memory/selector.c][memory/global.c]
	  [include/callback.h]
	Added/moved some more win95 ordinal stuff. Implemented QT_Thunk
	(not 100% correct yet) and some friends.

	* [loader/pe_image.c]
	Add possibility to break at the DLL entrypoint.

	* [controls/static.c][misc/commdlg.c][scheduler/thread.c]
	Misc bugfixes and additions.

	* [misc/registry.c]
	The registry seems to be case-preserving but case-insensitive.

	* [memory/global.c]	
	Adapted to new /proc/meminfo format.

	* [objects/font.c][graphics/x11drv/xfont.c]
	FONT_SelectObject and GetTextMetrics* get passed ranges in logical
 	and not device points (thanks to Marion Reyzl for pointing this
 	out).

	* [windows/caret.c]
	Use the windows own DC if present (The caret coordinates are
	logical coordinates based on it). Fixes another AMIPRO problem.

Wed Aug  6 18:22:22 1997  Morten Welinder  <terra@diku.dk>

	* [controls/menu.c]
	General clean-up and Win32 work: split item_flags into fType and
	fState; split item_id into wID and hSubMenu.  Improved
	debug-printing.  Implemented InsertMenuItem32[AW],
	SetMenuDefaultItem32, and SetMenuItemInfo32[AW].  Fixed
	GetMenuItemInfo32[AW].

	* [if1632/user32.spec]
	Define above new functions.

	* [include/windows.h]
	Define MF_DEFAULT and MF_RIGHTJUSTIFY.  Prototype above functions.

	* [include/menu.h]
	Don't prototype now-static MENU_InitSysMenuPopup.

	* [include/comm.h]
	Reduce MAX_PORTS to 9 (which the profile code can handle).

Tue Aug  5 20:16:22 1997  Victor Schneider <vischne@ibm.net>

	* [library/winestub.c] [libtest/expand.c]
	These patches let people porting Windows apps compile them using
	the same conventions regarding global _argc and _argv as those on
	Windows C/C++ compilers.
diff --git a/memory/selector.c b/memory/selector.c
index 06ed3ef..421cd99 100644
--- a/memory/selector.c
+++ b/memory/selector.c
@@ -20,7 +20,7 @@
 /***********************************************************************
  *           AllocSelectorArray   (KERNEL.206)
  */
-WORD AllocSelectorArray( WORD count )
+WORD WINAPI AllocSelectorArray( WORD count )
 {
     WORD i, size = 0;
 
@@ -40,7 +40,7 @@
 /***********************************************************************
  *           AllocSelector   (KERNEL.175)
  */
-WORD AllocSelector( WORD sel )
+WORD WINAPI AllocSelector( WORD sel )
 {
     WORD newsel, count, i;
 
@@ -63,7 +63,7 @@
 /***********************************************************************
  *           FreeSelector   (KERNEL.176)
  */
-WORD FreeSelector( WORD sel )
+WORD WINAPI FreeSelector( WORD sel )
 {
     if (IS_SELECTOR_FREE(sel)) return sel;  /* error */
     SELECTOR_FreeBlock( sel, 1 );
@@ -202,7 +202,7 @@
 /***********************************************************************
  *           PrestoChangoSelector   (KERNEL.177)
  */
-WORD PrestoChangoSelector( WORD selSrc, WORD selDst )
+WORD WINAPI PrestoChangoSelector( WORD selSrc, WORD selDst )
 {
     ldt_entry entry;
     LDT_GetEntry( SELECTOR_TO_ENTRY( selSrc ), &entry );
@@ -215,7 +215,7 @@
 /***********************************************************************
  *           AllocCStoDSAlias   (KERNEL.170)
  */
-WORD AllocCStoDSAlias( WORD sel )
+WORD WINAPI AllocCStoDSAlias( WORD sel )
 {
     WORD newsel;
     ldt_entry entry;
@@ -234,7 +234,7 @@
 /***********************************************************************
  *           AllocDStoCSAlias   (KERNEL.171)
  */
-WORD AllocDStoCSAlias( WORD sel )
+WORD WINAPI AllocDStoCSAlias( WORD sel )
 {
     WORD newsel;
     ldt_entry entry;
@@ -253,7 +253,7 @@
 /***********************************************************************
  *           LongPtrAdd   (KERNEL.180)
  */
-void LongPtrAdd( DWORD ptr, DWORD add )
+void WINAPI LongPtrAdd( DWORD ptr, DWORD add )
 {
     ldt_entry entry;
     LDT_GetEntry( SELECTOR_TO_ENTRY(SELECTOROF(ptr)), &entry );
@@ -265,7 +265,7 @@
 /***********************************************************************
  *           GetSelectorBase   (KERNEL.186)
  */
-DWORD GetSelectorBase( WORD sel )
+DWORD WINAPI GetSelectorBase( WORD sel )
 {
     DWORD base = GET_SEL_BASE(sel);
 
@@ -279,7 +279,7 @@
 /***********************************************************************
  *           SetSelectorBase   (KERNEL.187)
  */
-WORD SetSelectorBase( WORD sel, DWORD base )
+WORD WINAPI SetSelectorBase( WORD sel, DWORD base )
 {
     ldt_entry entry;
 
@@ -295,7 +295,7 @@
 /***********************************************************************
  *           GetSelectorLimit   (KERNEL.188)
  */
-DWORD GetSelectorLimit( WORD sel )
+DWORD WINAPI GetSelectorLimit( WORD sel )
 {
     return GET_SEL_LIMIT(sel);
 }
@@ -304,7 +304,7 @@
 /***********************************************************************
  *           SetSelectorLimit   (KERNEL.189)
  */
-WORD SetSelectorLimit( WORD sel, DWORD limit )
+WORD WINAPI SetSelectorLimit( WORD sel, DWORD limit )
 {
     ldt_entry entry;
     LDT_GetEntry( SELECTOR_TO_ENTRY(sel), &entry );
@@ -319,7 +319,7 @@
 /***********************************************************************
  *           SelectorAccessRights   (KERNEL.196)
  */
-WORD SelectorAccessRights( WORD sel, WORD op, WORD val )
+WORD WINAPI SelectorAccessRights( WORD sel, WORD op, WORD val )
 {
     ldt_entry entry;
     LDT_GetEntry( SELECTOR_TO_ENTRY(sel), &entry );
@@ -349,7 +349,7 @@
 /***********************************************************************
  *           IsBadCodePtr16   (KERNEL.336)
  */
-BOOL16 IsBadCodePtr16( SEGPTR lpfn )
+BOOL16 WINAPI IsBadCodePtr16( SEGPTR lpfn )
 {
     WORD sel;
     ldt_entry entry;
@@ -367,7 +367,7 @@
 /***********************************************************************
  *           IsBadStringPtr16   (KERNEL.337)
  */
-BOOL16 IsBadStringPtr16( SEGPTR ptr, UINT16 size )
+BOOL16 WINAPI IsBadStringPtr16( SEGPTR ptr, UINT16 size )
 {
     WORD sel;
     ldt_entry entry;
@@ -386,7 +386,7 @@
 /***********************************************************************
  *           IsBadHugeReadPtr16   (KERNEL.346)
  */
-BOOL16 IsBadHugeReadPtr16( SEGPTR ptr, DWORD size )
+BOOL16 WINAPI IsBadHugeReadPtr16( SEGPTR ptr, DWORD size )
 {
     WORD sel;
     ldt_entry entry;
@@ -404,7 +404,7 @@
 /***********************************************************************
  *           IsBadHugeWritePtr16   (KERNEL.347)
  */
-BOOL16 IsBadHugeWritePtr16( SEGPTR ptr, DWORD size )
+BOOL16 WINAPI IsBadHugeWritePtr16( SEGPTR ptr, DWORD size )
 {
     WORD sel;
     ldt_entry entry;
@@ -421,7 +421,7 @@
 /***********************************************************************
  *           IsBadReadPtr16   (KERNEL.334)
  */
-BOOL16 IsBadReadPtr16( SEGPTR ptr, UINT16 size )
+BOOL16 WINAPI IsBadReadPtr16( SEGPTR ptr, UINT16 size )
 {
     return IsBadHugeReadPtr16( ptr, size );
 }
@@ -430,7 +430,7 @@
 /***********************************************************************
  *           IsBadWritePtr16   (KERNEL.335)
  */
-BOOL16 IsBadWritePtr16( SEGPTR ptr, UINT16 size )
+BOOL16 WINAPI IsBadWritePtr16( SEGPTR ptr, UINT16 size )
 {
     return IsBadHugeWritePtr16( ptr, size );
 }
@@ -439,7 +439,7 @@
 /***********************************************************************
  *           MemoryRead   (TOOLHELP.78)
  */
-DWORD MemoryRead( WORD sel, DWORD offset, void *buffer, DWORD count )
+DWORD WINAPI MemoryRead( WORD sel, DWORD offset, void *buffer, DWORD count )
 {
     if (IS_SELECTOR_FREE(sel)) return 0;
     if (offset > GET_SEL_LIMIT(sel)) return 0;
@@ -453,7 +453,7 @@
 /***********************************************************************
  *           MemoryWrite   (TOOLHELP.79)
  */
-DWORD MemoryWrite( WORD sel, DWORD offset, void *buffer, DWORD count )
+DWORD WINAPI MemoryWrite( WORD sel, DWORD offset, void *buffer, DWORD count )
 {
     if (IS_SELECTOR_FREE(sel)) return 0;
     if (offset > GET_SEL_LIMIT(sel)) return 0;
@@ -475,7 +475,7 @@
  *
  * Maps fixed segmented pointer to linear.
  */
-LPVOID MapSL( SEGPTR sptr )
+LPVOID WINAPI MapSL( SEGPTR sptr )
 {
     return (LPVOID)PTR_SEG_TO_LIN(sptr);
 }
@@ -486,7 +486,7 @@
  *
  * Maps linear pointer to segmented.
  */
-SEGPTR MapLS( LPVOID ptr )
+SEGPTR WINAPI MapLS( LPVOID ptr )
 {
     WORD sel = SELECTOR_AllocBlock( ptr, 0x10000, SEGMENT_DATA, FALSE, FALSE );
     return PTR_SEG_OFF_TO_SEGPTR( sel, 0 );
@@ -498,7 +498,120 @@
  *
  * Free mapped selector.
  */
-void UnMapLS( SEGPTR sptr )
+void WINAPI UnMapLS( SEGPTR sptr )
 {
     if (!__winelib) SELECTOR_FreeBlock( SELECTOROF(sptr), 1 );
 }
+
+/***********************************************************************
+ *           GetThreadSelectorEntry   (KERNEL32)
+ * FIXME: add #ifdef i386 for non x86
+ */
+BOOL32 WINAPI GetThreadSelectorEntry( HANDLE32 hthread, DWORD sel,
+                                      LPLDT_ENTRY ldtent)
+{
+    ldt_entry	ldtentry;
+
+    LDT_GetEntry(SELECTOR_TO_ENTRY(sel),&ldtentry);
+    ldtent->BaseLow = ldtentry.base & 0x0000ffff;
+    ldtent->HighWord.Bits.BaseMid = (ldtentry.base & 0x00ff0000) >> 16;
+    ldtent->HighWord.Bits.BaseHi = (ldtentry.base & 0xff000000) >> 24;
+    ldtent->LimitLow = ldtentry.limit & 0x0000ffff;
+    ldtent->HighWord.Bits.LimitHi = (ldtentry.limit & 0x00ff0000) >> 16;
+    ldtent->HighWord.Bits.Dpl = 3;
+    ldtent->HighWord.Bits.Sys = 0;
+    ldtent->HighWord.Bits.Pres = 1;
+    ldtent->HighWord.Bits.Type = 0x10|(ldtentry.type << 2);
+    if (ldtentry.read_only)
+    	ldtent->HighWord.Bits.Type|=0x2;
+    ldtent->HighWord.Bits.Granularity = ldtentry.limit_in_pages;
+    ldtent->HighWord.Bits.Default_Big = ldtentry.seg_32bit;
+    return TRUE;
+}
+
+
+/**********************************************************************
+ * 		SMapLS*		(KERNEL32)
+ * These functions map linear pointers at [EBP+xxx] to segmented pointers
+ * and return them.
+ * Win95 uses some kind of alias structs, which it stores in [EBP+x] to
+ * unravel them at SUnMapLS. We just store the segmented pointer there.
+ */
+static void
+x_SMapLS_IP_EBP_x(CONTEXT *context,int argoff) {
+    DWORD	val,ptr; 
+
+    val =*(DWORD*)(EBP_reg(context)+argoff);
+    if (val<0x10000) {
+	ptr=val;
+	*(DWORD*)(EBP_reg(context)+argoff) = 0;
+    } else {
+    	ptr = MapLS((LPVOID)val);
+	*(DWORD*)(EBP_reg(context)+argoff) = ptr;
+    }
+    fprintf(stderr,"[EBP+%d] %08lx => %08lx\n",argoff,val,ptr);
+    EAX_reg(context) = ptr;
+}
+
+void WINAPI SMapLS_IP_EBP_8(CONTEXT *context)  {x_SMapLS_IP_EBP_x(context,8);}
+void WINAPI SMapLS_IP_EBP_12(CONTEXT *context) {x_SMapLS_IP_EBP_x(context,12);}
+void WINAPI SMapLS_IP_EBP_16(CONTEXT *context) {x_SMapLS_IP_EBP_x(context,16);}
+void WINAPI SMapLS_IP_EBP_20(CONTEXT *context) {x_SMapLS_IP_EBP_x(context,20);}
+void WINAPI SMapLS_IP_EBP_24(CONTEXT *context) {x_SMapLS_IP_EBP_x(context,24);}
+void WINAPI SMapLS_IP_EBP_28(CONTEXT *context) {x_SMapLS_IP_EBP_x(context,28);}
+void WINAPI SMapLS_IP_EBP_32(CONTEXT *context) {x_SMapLS_IP_EBP_x(context,32);}
+void WINAPI SMapLS_IP_EBP_36(CONTEXT *context) {x_SMapLS_IP_EBP_x(context,36);}
+void WINAPI SMapLS_IP_EBP_40(CONTEXT *context) {x_SMapLS_IP_EBP_x(context,40);}
+
+void WINAPI SMapLS(CONTEXT *context,int argoff)
+{
+    if (EAX_reg(context)>=0x10000) {
+	EAX_reg(context) = MapLS((LPVOID)EAX_reg(context));
+	EDX_reg(context) = EAX_reg(context);
+    } else {
+	EDX_reg(context) = 0;
+    }
+}
+
+/**********************************************************************
+ *           WOWGetVDMPointer	(KERNEL32.55)
+ * Get linear from segmented pointer. (MSDN lib)
+ */
+LPVOID WINAPI WOWGetVDMPointer(DWORD vp,DWORD nrofbytes,BOOL32 protected)
+{
+    /* FIXME: add size check too */
+    fprintf(stdnimp,"WOWGetVDMPointer(%08lx,%ld,%d)\n",vp,nrofbytes,protected);
+    if (protected)
+	return PTR_SEG_TO_LIN(vp);
+    else
+	return DOSMEM_MapRealToLinear(vp);
+}
+
+/**********************************************************************
+ *           GetVDMPointer32W   (KERNEL.516)
+ */
+LPVOID WINAPI GetVDMPointer32W(DWORD vp,DWORD mode)
+{
+    return WOWGetVDMPointer(vp,0,mode);
+}
+
+/**********************************************************************
+ *           WOWGetVDMPointerFix (KERNEL32.55)
+ * Dito, but fix heapsegment (MSDN lib)
+ */
+LPVOID WINAPI WOWGetVDMPointerFix(DWORD vp,DWORD nrofbytes,BOOL32 protected)
+{
+    /* FIXME: fix heapsegment */
+    fprintf(stdnimp,"WOWGetVDMPointerFix(%08lx,%ld,%d)\n",vp,nrofbytes,protected);
+    return WOWGetVDMPointer(vp,nrofbytes,protected);
+}
+
+/**********************************************************************
+ *           WOWGetVDMPointerUnFix (KERNEL32.56)
+ */
+void WINAPI WOWGetVDMPointerUnfix(DWORD vp)
+{
+    fprintf(stdnimp,"WOWGetVDMPointerUnfix(%08lx), STUB\n",vp);
+    /* FIXME: unfix heapsegment */
+}
+