Release 951003

Sun Oct  1 15:48:34 1995  Alexandre Julliard  <julliard@sunsite.unc>

	* [controls/menu.c]
	Fixed GetMenuString() for non-string items.

	* [debugger/*.c]
	First attempt to check validity of pointers before memory
	accesses. For now only segmented pointers are checked.

	* [debugger/dbg.y] [memory/ldt.c]
	Added possibility to dump only one segment with 'info segment'.

	* [include/bitmaps/ocr_*]
	Added all OEM cursors as XPM bitmaps.

	* [include/cursoricon.h] [objects/cursoricon.c]
	Rewrote all cursor and icon management to use the same memory
 	layout as Windows, and to factor common code between icons and
	cursors. Implemented icon directory lookup to find the best
	matching icon (i.e. the color one).
  	Implemented CopyCursor() and DumpIcon().

	* [loader/module.c]
	For disabled built-in modules, we now try to load the Windows DLL
	first, and if this fails we fall back to using the built-in module
	anyway.

	* [memory/global.c]
	Fixed GlobalHandle() to return the correct selector in the high
	word even if we are passed a handle in the first place.

	* [miscemu/instr.c]
	Take into account the size of the operand and of the stack segment
	when incrementing the stack pointer.
	Avoid referencing FS_reg and GS_reg on *BSD.

	* [objects/dib.c]
	All DIB functions now accept a BITMAPCOREHEADER format bitmap.
	Monochrome DIBs are created as monochrome bitmap iff they are
	black and white.

	* [objects/oembitmap.c]
	Added support for OEM cursors, changed OBM_LoadIcon to use the new
	icon memory layout.

	* [rc/sysres_Fr.rc]
	Added French [Fr] language support.

	* [win32/environment.c]
	Fixed GetCommandLineA() to use current PDB.

	* [windows/event.c] [windows/winpos.c]
	Simulate a mouse motion event upon SetWindowPos() to force the
	cursor to be set correctly.

Sat Sep 30 17:49:32  Cameron Heide  (heide@ee.ualberta.ca)

	* [win32/*]
        New Win32 kernel functions: GetACP, GetCPInfo,
 	GetEnvironmentVariableA, GetFileType, GetLastError, GetOEMCP,
 	GetStartupInfoA, GetTimeZoneInformation, SetEnvironmentVariable,
 	SetFilePointer, SetLastError, VirtualAlloc, VirtualFree,
 	WriteFile.  Completed implementations of GetCommandLineA.

	* [include/kernel32.h]
        New file.

	* [loader/main.c]
        Call initialization function for Win32 data (doesn't currently do
 	anything).

	* [misc/main.c]
	Implemented GetEnvironmentVariableA, SetEnvironmentVariableA.

Sat Sep 30 00:26:56 1995  Niels de Carpentier  <niels@cindy.et.tudelft.nl>

	* [windows/winpos.c][miscemu/emulate.c][loader/module.c]
	  [misc/commdlg.c]
	Misc. bug fixes

Fri Sep 29 16:16:13 1995  Jim Peterson <jspeter@birch.ee.vt.edu>

	* [*/*]
	For Winelib, explicit casts have been placed where warnings were
 	usually generated.
	printf formats which give the format for printing a handle as
 	"%04x" or something similar have been changed to use the NPFMT
 	macro defined in include/wintypes.h.  Some times, explicit casts
 	were also necessary.
     	Parameter, field, and variable declarations have been made more
 	exact, such as converting 'WORD wParam' to 'WPARAM wParam' or
 	'WORD hFont' to 'HFONT hFont'.
     	Any call of the form GetWindowWord(hwnd,GWW_HINSTANCE) has been
 	replaced with a call to WIN_GetWindowInstance(hwnd).

	* [controls/combo.c]
	Added WINELIB32 support in CLBoxGetCombo().

	* [include/dialog.h]
	Commented out the '#ifndef WINELIB' around the '#pragma pack(1)'.
	winelib needs the packing as well (e.g. when accessing resources
	like sysres_DIALOG_SHELL_ABOUT_MSGBOX).

	* [include/windows.h]
	Got rid of the F[a-k] macros, which were cluttering up the global
	namespace.

	* [include/windows.h] [windows/defwnd.c]
	Added Win32 messages WM_CTLCOLOR*.

	* [include/wintypes.h]
	Put in preprocessor '#define WINELIB32' if appropriate and changed
	the types of some typedefs (WPARAM, HANDLE) based on this.
	
	* [loader/module.c] [toolkit/miscstubs.c]
	Added #ifdef'd portion in LoadModule to handle loading a WINElib
	module (already loaded, just init values).  '#ifdef'ed out the
	definition for GetWndProcEntry16 and added a new version to
	toolkit/miscstubs.c.

	* [misc/shell.c]
	Adjusted the lengths of AppName and AppMisc from 512,512 to 128,906.
	Same amount of total storage, but much more reasonable.  Also, changed
	calls to strcpy() in ShellAbout() to calls to strncpy() instead.
	This was a difficult bug to track down, but the AppMisc field was
	being initialized with the contributers text, which was much larger
	than 512 characters.

	* [toolkit/atom.c]
	New file for atom-handling functions.  Copied from memory/atom.c and
	then heavily modified.  Right now, it's just a linked list of atoms.
	Consider it as a hash table with just one entry.  It's easily changed
	later.

	* [toolkit/heap.c]
	Commented out the heap functions with a "#ifdef WINELIB16" and put in
	a Win32 version (which is basically a modified copy).

	* [toolkit/sup.c] [toolkit/miscstubs.c]
	Moved the stuff I put in toolkit/sup.c into toolkit/miscstubs.c and
	added quite a few more stubs.

	* [toolkit/winmain.c]
	Rearranged startup code in _WinMain.  I think this will work.

	* [toolkit/Makefile.in]
	Added targets for 'hello' and 'hello2' in case anyone cares to try
	out the sample programs.

Wed Sep 27 23:13:43 1995  Anand Kumria <akumria@ozemail.com.au>
	
	* [miscemu/int2f.c] [miscemu/vxd.c] [if1632/winprocs.spec]
	First attempt at support for some VxDs. Comm, Shell and Pagefile.

Tue Sep 26 21:34:45 1995  Hans de Graaff  <graaff@twi72.twi.tudelft.nl>

	* [misc/dos_fs.c]
	DOS_SimplifyPath: Also remove "/./" from path. (Happens when
 	starting applications like 'wine ./excel.exe')

Sat Sep 23 23:32:40 1995  Morten Welinder  <terra@diku.dk>

	* [configure.in]
	Avoid relative path for wine.ini.

	* [rc/sysres_Da.rc]
	Support for Danish [Da] language.

	* [misc/main.c] [miscemu/cpu.c]
	Return the processor we're running on correctly.

	* [miscemu/int2f.c]
	Minor stuff in int 0x2f, function 0x16.

Sat Sep 23 1995 17:58:04  Marcus Meissner  <msmeissn@faui01.informatik.uni-erlangen.de>

	* [misc/shell.c] [misc/main.c]
	Implement saving and loading of the registry database (needed for
	OLE). Very experimental. Fixed ShellExecute().
	
	* [miscemu/int21.c]
	EEXIST is not a critical error condition for mkdir().

Fri Sep 22 01:33:34 1995  Alex Korobka  <alex@phm6.pharm.sunysb.edu>

	* [include/shell.h] [misc/shell.c]
	Implemented 4 drag/drop functions with documented functionality.

        * [multimedia/time.c]
        "Fixed" MMSysTimeCallback kludge so Excel5 loads up without crashing.

	* [*/*] 
        Added new files, more message definitions, structures, debug info,
 	etc.  Rewrote message logging functions to produce output similar
 	to WinSight.  Check out -debugmsg +message option.

	* [misc/file.c]
        Fixed GetDriveType return value.  

        * [windows/message.c] 
        Hooks are invoked in normal order.

        * [miscemu/*]
        Added some functions and interrupts.

        * [misc/shell.c]
        Implemented Drag... functions.

Thu Sep 21 23:50:12 1995  Jukka Iivonen <iivonen@cc.helsinki.fi>

	* [rc/sysres_Fi.rc] [rc/sysres.rc]
	First attempt at Finnish [Fi] language support.
diff --git a/loader/module.c b/loader/module.c
index 928b647..e48ed03 100644
--- a/loader/module.c
+++ b/loader/module.c
@@ -30,62 +30,89 @@
 
 
 /***********************************************************************
+ *           MODULE_LoadBuiltin
+ *
+ * Load a built-in module. If the 'force' parameter is FALSE, we only
+ * load the module if it has not been disabled via the -dll option.
+ */
+static HMODULE MODULE_LoadBuiltin( LPCSTR name, BOOL force )
+{
+#ifndef WINELIB /* JBP: Not really allowed in libwine.a (FIXME:?) */
+    HMODULE hModule;
+    NE_MODULE *pModule;
+    SEGTABLEENTRY *pSegTable;
+    struct dll_table_s *table;
+    int i;
+    char dllname[16], *p;
+
+    /* Fix the name in case we have a full path and extension */
+
+    if ((p = strrchr( name, '\\' ))) name = p + 1;
+    strncpy( dllname, name, 15 );
+    dllname[15] = '\0';
+    if ((p = strrchr( dllname, '.' ))) *p = '\0';
+
+    for (i = 0, table = dll_builtin_table; i < N_BUILTINS; i++, table++)
+        if (!strcasecmp( table->name, dllname )) break;
+    if (i >= N_BUILTINS) return 0;
+    if (!table->used && !force) return 0;
+
+    hModule = GLOBAL_CreateBlock( GMEM_MOVEABLE, table->module_start,
+                                  table->module_end - table->module_start,
+                                  0, FALSE, FALSE, FALSE, NULL );
+    if (!hModule) return 0;
+    FarSetOwner( hModule, hModule );
+
+    table->hModule = hModule;
+
+    dprintf_module( stddeb, "Built-in %s: hmodule=%04x\n",
+                    table->name, hModule );
+
+    /* Allocate the code segment */
+
+    pModule = (NE_MODULE *)GlobalLock( hModule );
+    pSegTable = NE_SEG_TABLE( pModule );
+
+    pSegTable->selector = GLOBAL_CreateBlock( GMEM_FIXED, table->code_start,
+                                              pSegTable->minsize, hModule,
+                                              TRUE, TRUE, FALSE, NULL );
+    if (!pSegTable->selector) return 0;
+    pSegTable++;
+
+    /* Allocate the data segment */
+
+    pSegTable->selector = GLOBAL_Alloc( GMEM_FIXED, pSegTable->minsize,
+                                        hModule, FALSE, FALSE, FALSE );
+    if (!pSegTable->selector) return 0;
+    memcpy( GlobalLock( pSegTable->selector ),
+            table->data_start, pSegTable->minsize );
+
+    pModule->next = hFirstModule;
+    hFirstModule = hModule;
+    return hModule;
+}
+
+
+/***********************************************************************
  *           MODULE_Init
  *
  * Create the built-in modules.
  */
 BOOL MODULE_Init(void)
 {
-    HMODULE hModule;
-    NE_MODULE *pModule;
-    SEGTABLEENTRY *pSegTable;
-    struct dll_table_s *table;
-    int i;
+    /* For these, built-in modules are always used */
 
-      /* Create the built-in modules */
+    if (!MODULE_LoadBuiltin( "KERNEL", TRUE ) ||
+        !MODULE_LoadBuiltin( "GDI", TRUE ) ||
+        !MODULE_LoadBuiltin( "USER", TRUE ) ||
+        !MODULE_LoadBuiltin( "WINPROCS", TRUE )) return FALSE;
 
-    for (i = 0, table = dll_builtin_table; i < N_BUILTINS; i++, table++)
-    {
-        if (!table->used) continue;
-
-        hModule = GLOBAL_CreateBlock( GMEM_MOVEABLE, table->module_start,
-                                      table->module_end - table->module_start,
-                                      0, FALSE, FALSE, FALSE, NULL );
-        if (!hModule) return FALSE;
-        FarSetOwner( hModule, hModule );
-
-        table->hModule = hModule;
-
-        dprintf_module( stddeb, "Built-in %s: hmodule=%04x\n",
-                        table->name, hModule );
-
-          /* Allocate the code segment */
-
-        pModule = (NE_MODULE *)GlobalLock( hModule );
-        pSegTable = NE_SEG_TABLE( pModule );
-
-        pSegTable->selector = GLOBAL_CreateBlock(GMEM_FIXED, table->code_start,
-                                                 pSegTable->minsize, hModule,
-                                                 TRUE, TRUE, FALSE, NULL );
-        if (!pSegTable->selector) return FALSE;
-        pSegTable++;
-
-          /* Allocate the data segment */
-
-        pSegTable->selector = GLOBAL_Alloc( GMEM_FIXED, pSegTable->minsize,
-                                            hModule, FALSE, FALSE, FALSE );
-        if (!pSegTable->selector) return FALSE;
-        memcpy( GlobalLock( pSegTable->selector ), table->data_start,
-                pSegTable->minsize );
-
-        pModule->next = hFirstModule;
-        hFirstModule = hModule;
-    }
-
+#else
+    fprintf(stderr, "JBP: MODULE_Init() ignored.\n");
+#endif
     /* Initialize KERNEL.178 (__WINFLAGS) with the correct flags value */
 
     MODULE_SetEntryPoint( GetModuleHandle( "KERNEL" ), 178, GetWinFlags() );
-
     return TRUE;
 }
 
@@ -103,7 +130,7 @@
 
       /* Dump the module info */
 
-    printf( "Module %04x:\n", hmodule );
+    printf( "Module "NPFMT":\n", hmodule );
     printf( "count=%d flags=%04x heap=%d stack=%d\n",
             pModule->count, pModule->flags,
             pModule->heap_size, pModule->stack_size );
@@ -124,7 +151,7 @@
     printf( "\nSegment table:\n" );
     pSeg = NE_SEG_TABLE( pModule );
     for (i = 0; i < pModule->seg_count; i++, pSeg++)
-        printf( "%02x: pos=%d size=%d flags=%04x minsize=%d sel=%04x\n",
+        printf( "%02x: pos=%d size=%d flags=%04x minsize=%d sel="NPFMT"\n",
                 i + 1, pSeg->filepos, pSeg->size, pSeg->flags,
                 pSeg->minsize, pSeg->selector );
 
@@ -233,7 +260,7 @@
     static int cachedfd = -1;
 
     hModule = GetExePtr( hModule );  /* In case we were passed an hInstance */
-    dprintf_module( stddeb, "MODULE_OpenFile(%04x) cache: mod=%04x fd=%d\n",
+    dprintf_module( stddeb, "MODULE_OpenFile("NPFMT") cache: mod="NPFMT" fd=%d\n",
                     hModule, hCachedModule, cachedfd );
     if (!(pModule = (NE_MODULE *)GlobalLock( hModule ))) return -1;
     if (hCachedModule == hModule) return cachedfd;
@@ -278,9 +305,13 @@
 DWORD MODULE_AllocateSegment(WORD wFlags, WORD wSize, WORD wElem)
 {
     WORD size = wSize << wElem;
-    WORD hMem = GlobalAlloc( MODULE_Ne2MemFlags(wFlags), size);
+    HANDLE hMem = GlobalAlloc( MODULE_Ne2MemFlags(wFlags), size);
+#ifdef WINELIB32
+    return (DWORD)GlobalLock(hMem);
+#else
     WORD selector = HIWORD(GlobalLock(hMem));
     return MAKELONG(hMem, selector);
+#endif
 }
 
 /***********************************************************************
@@ -389,14 +420,14 @@
 
     lseek( fd, 0, SEEK_SET );
     if ((read( fd, &mz_header, sizeof(mz_header) ) != sizeof(mz_header)) ||
-        (mz_header.mz_magic != MZ_SIGNATURE)) return 11;  /* invalid exe */
+        (mz_header.mz_magic != MZ_SIGNATURE)) return (HMODULE)11;  /* invalid exe */
 
     lseek( fd, mz_header.ne_offset, SEEK_SET );
     if (read( fd, &ne_header, sizeof(ne_header) ) != sizeof(ne_header))
-        return 11;  /* invalid exe */
+        return (HMODULE)11;  /* invalid exe */
 
-    if (ne_header.ne_magic == PE_SIGNATURE) return 21;  /* win32 exe */
-    if (ne_header.ne_magic != NE_SIGNATURE) return 11;  /* invalid exe */
+    if (ne_header.ne_magic == PE_SIGNATURE) return (HMODULE)21;  /* win32 exe */
+    if (ne_header.ne_magic != NE_SIGNATURE) return (HMODULE)11;  /* invalid exe */
 
     /* We now have a valid NE header */
 
@@ -417,7 +448,7 @@
            ne_header.entry_tab_length;
 
     hModule = GlobalAlloc( GMEM_MOVEABLE | GMEM_ZEROINIT, size );
-    if (!hModule) return 11;  /* invalid exe */
+    if (!hModule) return (HMODULE)11;  /* invalid exe */
     FarSetOwner( hModule, hModule );
     pModule = (NE_MODULE *)GlobalLock( hModule );
     memcpy( pModule, &ne_header, sizeof(NE_MODULE) );
@@ -465,7 +496,7 @@
 
         if (!READ( ne_header.segment_tab_offset,
              ne_header.n_segment_tab * sizeof(struct ne_segment_table_entry_s),
-             buffer )) return 11;  /* invalid exe */
+             buffer )) return (HMODULE)11;  /* invalid exe */
         pSeg = (struct ne_segment_table_entry_s *)buffer;
         for (i = ne_header.n_segment_tab; i > 0; i--, pSeg++)
         {
@@ -474,7 +505,7 @@
         }
         free( buffer );
     }
-    else return 11;  /* invalid exe */
+    else return (HMODULE)11;  /* invalid exe */
 
     /* Get the resource table */
 
@@ -483,7 +514,7 @@
         pModule->res_table = (int)pData - (int)pModule;
         if (!READ(ne_header.resource_tab_offset,
                   ne_header.rname_tab_offset - ne_header.resource_tab_offset,
-                  pData )) return 11;  /* invalid exe */
+                  pData )) return (HMODULE)11;  /* invalid exe */
         pData += ne_header.rname_tab_offset - ne_header.resource_tab_offset;
     }
     else pModule->res_table = 0;  /* No resource table */
@@ -493,7 +524,7 @@
     pModule->name_table = (int)pData - (int)pModule;
     if (!READ( ne_header.rname_tab_offset,
                ne_header.moduleref_tab_offset - ne_header.rname_tab_offset,
-               pData )) return 11;  /* invalid exe */
+               pData )) return (HMODULE)11;  /* invalid exe */
     pData += ne_header.moduleref_tab_offset - ne_header.rname_tab_offset;
 
     /* Get the module references table */
@@ -503,7 +534,7 @@
         pModule->modref_table = (int)pData - (int)pModule;
         if (!READ( ne_header.moduleref_tab_offset,
                   ne_header.n_mod_ref_tab * sizeof(WORD),
-                  pData )) return 11;  /* invalid exe */
+                  pData )) return (HMODULE)11;  /* invalid exe */
         pData += ne_header.n_mod_ref_tab * sizeof(WORD);
     }
     else pModule->modref_table = 0;  /* No module references */
@@ -513,7 +544,7 @@
     pModule->import_table = (int)pData - (int)pModule;
     if (!READ( ne_header.iname_tab_offset, 
                ne_header.entry_tab_offset - ne_header.iname_tab_offset,
-               pData )) return 11;  /* invalid exe */
+               pData )) return (HMODULE)11;  /* invalid exe */
     pData += ne_header.entry_tab_offset - ne_header.iname_tab_offset;
 
     /* Get the entry table */
@@ -521,7 +552,7 @@
     pModule->entry_table = (int)pData - (int)pModule;
     if (!READ( ne_header.entry_tab_offset,
                ne_header.entry_tab_length,
-               pData )) return 11;  /* invalid exe */
+               pData )) return (HMODULE)11;  /* invalid exe */
     pData += ne_header.entry_tab_length;
 
     /* Get the non-resident names table */
@@ -530,11 +561,11 @@
     {
         pModule->nrname_handle = GLOBAL_Alloc( 0, ne_header.nrname_tab_length,
                                                hModule, FALSE, FALSE, FALSE );
-        if (!pModule->nrname_handle) return 11;  /* invalid exe */
+        if (!pModule->nrname_handle) return (HMODULE)11;  /* invalid exe */
         buffer = GlobalLock( pModule->nrname_handle );
         lseek( fd, ne_header.nrname_tab_offset, SEEK_SET );
         if (read( fd, buffer, ne_header.nrname_tab_length )
-              != ne_header.nrname_tab_length) return 11;  /* invalid exe */
+              != ne_header.nrname_tab_length) return (HMODULE)11;  /* invalid exe */
     }
     else pModule->nrname_handle = 0;
 
@@ -545,7 +576,7 @@
         pModule->dlls_to_init = GLOBAL_Alloc(GMEM_ZEROINIT,
                                     (pModule->modref_count+1)*sizeof(HMODULE),
                                     hModule, FALSE, FALSE, FALSE );
-        if (!pModule->dlls_to_init) return 11;  /* invalid exe */
+        if (!pModule->dlls_to_init) return (HMODULE)11;  /* invalid exe */
     }
     else pModule->dlls_to_init = 0;
 
@@ -569,7 +600,7 @@
 
     if (!(pModule = (NE_MODULE *)GlobalLock( hModule ))) return 0;
 
-    dprintf_module( stddeb, "MODULE_GetOrdinal(%04x,'%s')\n",
+    dprintf_module( stddeb, "MODULE_GetOrdinal("NPFMT",'%s')\n",
                     hModule, name );
 
       /* First handle names of the form '#xxxx' */
@@ -817,10 +848,12 @@
     HMODULE *hPrevModule;
     NE_MODULE *pModule;
     SEGTABLEENTRY *pSegment;
-    WORD *pModRef;
+    HMODULE *pModRef;
     int i;
 
     if (!(pModule = (NE_MODULE *)GlobalLock( hModule ))) return;
+    if (pModule->flags & NE_FFLAGS_BUILTIN)
+        return;  /* Can't free built-in module */
 
     /* FIXME: should call the exit code for the library here */
 
@@ -861,6 +894,8 @@
 }
 
 
+HINSTANCE PE_LoadModule(int fd, OFSTRUCT *ofs, LOADPARAMS* params);
+
 /**********************************************************************
  *	    LoadModule    (KERNEL.45)
  */
@@ -870,16 +905,30 @@
     HANDLE hInstance, hPrevInstance;
     NE_MODULE *pModule;
     LOADPARAMS *params = (LOADPARAMS *)paramBlock;
+#ifndef WINELIB /* JBP: Disabled for now in winelib.a */
     WORD *pModRef, *pDLLs;
     int i, fd;
 
     hModule = MODULE_FindModule( name );
+
     if (!hModule)  /* We have to load the module */
     {
         OFSTRUCT ofs;
+
+        /* Try to load the built-in first if not disabled */
+        if ((hModule = MODULE_LoadBuiltin( name, FALSE ))) return hModule;
+
         if (strchr( name, '/' )) name = DOS_GetDosFileName( name );
         if ((fd = OpenFile( name, &ofs, OF_READ )) == -1)
+        {
+            /* Now try the built-in even if disabled */
+            if ((hModule = MODULE_LoadBuiltin( name, TRUE )))
+            {
+                fprintf( stderr, "Warning: could not load Windows DLL '%s', using built-in module.\n", name );
+                return hModule;
+            }
             return 2;  /* File not found */
+        }
 
           /* Create the module structure */
 
@@ -996,6 +1045,10 @@
           /* the module, even if it contains circular DLL references */
 
         pModule->count = 1;
+
+          /* Clear built-in flag in case it was set in the EXE file */
+
+        pModule->flags &= ~NE_FFLAGS_BUILTIN;
     }
     else
     {
@@ -1006,6 +1059,14 @@
             NE_LoadSegment( hModule, pModule->dgroup );
         pModule->count++;
     }
+#else
+    hModule = GlobalAlloc( GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(NE_MODULE) );
+    pModule = (NE_MODULE *)GlobalLock( hModule );
+    pModule->count = 1;
+    pModule->magic = 0x454e;
+    hPrevInstance = 0;
+    hInstance = MODULE_CreateInstance( hModule, (LOADPARAMS*)paramBlock );
+#endif /* WINELIB */
 
       /* Create a task for this instance */
 
@@ -1043,7 +1104,11 @@
  */
 HMODULE WIN16_GetModuleHandle( SEGPTR name )
 {
+#ifdef WINELIB32
+    if (HIWORD(name) == 0) return GetExePtr( name );
+#else
     if (HIWORD(name) == 0) return GetExePtr( LOWORD(name) );
+#endif
     return MODULE_FindModule( PTR_SEG_TO_LIN(name) );
 }
 
@@ -1062,7 +1127,7 @@
 
     hModule = GetExePtr( hModule );  /* In case we were passed an hInstance */
     if (!(pModule = (NE_MODULE *)GlobalLock( hModule ))) return 0;
-    dprintf_module( stddeb, "GetModuleUsage(%04x): returning %d\n",
+    dprintf_module( stddeb, "GetModuleUsage("NPFMT"): returning %d\n",
                     hModule, pModule->count );
     return pModule->count;
 }
@@ -1099,14 +1164,14 @@
     if ((handle = MODULE_FindModule( libname )) != 0) return handle;
      */
     handle = LoadModule( libname, (LPVOID)-1 );
-    if (handle == 2)  /* file not found */
+    if (handle == (HANDLE)2)  /* file not found */
     {
         char buffer[256];
         strcpy( buffer, libname );
         strcat( buffer, ".dll" );
         handle = LoadModule( buffer, (LPVOID)-1 );
     }
-    if (handle >= 32) NE_InitializeDLLs( GetExePtr(handle) );
+    if (handle >= (HANDLE)32) NE_InitializeDLLs( GetExePtr(handle) );
     return handle;
 }
 
@@ -1116,7 +1181,7 @@
  */
 void FreeLibrary( HANDLE handle )
 {
-    dprintf_module( stddeb,"FreeLibrary: %04x\n", handle );
+    dprintf_module( stddeb,"FreeLibrary: "NPFMT"\n", handle );
     FreeModule( handle );
 }
 
@@ -1157,12 +1222,12 @@
 
       /* Now load the executable file */
 
-    params.hEnvironment = SELECTOROF( GetDOSEnvironment() );
-    params.cmdLine  = WIN16_GlobalLock( cmdLineHandle );
-    params.showCmd  = WIN16_GlobalLock( cmdShowHandle );
+    params.hEnvironment = (HANDLE)SELECTOROF( GetDOSEnvironment() );
+    params.cmdLine  = (SEGPTR)WIN16_GlobalLock( cmdLineHandle );
+    params.showCmd  = (SEGPTR)WIN16_GlobalLock( cmdShowHandle );
     params.reserved = 0;
     handle = LoadModule( filename, &params );
-    if (handle == 2)  /* file not found */
+    if (handle == (HANDLE)2)  /* file not found */
     {
         strcat( filename, ".exe" );
         handle = LoadModule( filename, &params );
@@ -1170,6 +1235,7 @@
 
     GlobalFree( cmdShowHandle );
     GlobalFree( cmdLineHandle );
+    Yield();	/* program is executed immediatly ....needed for word */
     return handle;
 }
 
@@ -1188,13 +1254,13 @@
     if (HIWORD(name) != 0)
     {
         ordinal = MODULE_GetOrdinal( hModule, (LPSTR)PTR_SEG_TO_LIN(name) );
-        dprintf_module( stddeb, "GetProcAddress: %04x '%s'\n",
+        dprintf_module( stddeb, "GetProcAddress: "NPFMT" '%s'\n",
                         hModule, (LPSTR)PTR_SEG_TO_LIN(name) );
     }
     else
     {
         ordinal = LOWORD(name);
-        dprintf_module( stddeb, "GetProcAddress: %04x %04x\n",
+        dprintf_module( stddeb, "GetProcAddress: "NPFMT" %04x\n",
                         hModule, ordinal );
     }
     if (!ordinal) return (FARPROC)0;
@@ -1206,6 +1272,7 @@
 }
 
 
+#ifndef WINELIB
 /***********************************************************************
  *           GetWndProcEntry16 (not a Windows API function)
  *
@@ -1220,6 +1287,7 @@
     ordinal = MODULE_GetOrdinal( hModule, name );
     return MODULE_GetEntryPoint( hModule, ordinal );
 }
+#endif
 
 
 /**********************************************************************