Index: trunk/src/kernel32/conbuffervio.cpp
===================================================================
--- trunk/src/kernel32/conbuffervio.cpp	(revision 4522)
+++ trunk/src/kernel32/conbuffervio.cpp	(revision 4523)
@@ -1,3 +1,3 @@
-/* $Id: conbuffervio.cpp,v 1.1 2000-10-20 11:46:45 sandervl Exp $ */
+/* $Id: conbuffervio.cpp,v 1.2 2000-10-23 13:42:40 sandervl Exp $ */
 
 /*
@@ -100,5 +100,5 @@
   PCONSOLEBUFFER pConsoleBuffer = (PCONSOLEBUFFER)pHMHandleData->lpHandlerData;
            ULONG ulCounter;                 /* counter for the byte transfer */
-           PSZ   pszBuffer = (PSZ)lpBuffer;
+           PSZ   pszBuffer;
            char  filler[4] = {' ', 0x07, ' ', 0x07};
   register UCHAR ucChar;
@@ -125,4 +125,30 @@
 
   dprintf(("Current cursor position (%d,%d)", pConsoleBuffer->coordCursorPosition.X, pConsoleBuffer->coordCursorPosition.Y));
+
+  if(nNumberOfBytesToWrite > 1024)
+  {
+    int  tmp = 0;
+    BOOL retcode;
+
+    while(nNumberOfBytesToWrite) {
+        *lpNumberOfBytesWritten = 0;
+        retcode = WriteFile(pHMHandleData, lpBuffer,
+                            min(nNumberOfBytesToWrite, 512), lpNumberOfBytesWritten,
+                            lpOverlapped);
+        if(retcode != TRUE)     break;
+
+        tmp                   += *lpNumberOfBytesWritten;
+        nNumberOfBytesToWrite -= *lpNumberOfBytesWritten;
+        lpBuffer               = (LPCVOID)((char *)lpBuffer + *lpNumberOfBytesWritten);
+    }
+    *lpNumberOfBytesWritten = tmp;
+    return retcode;
+  }
+  pszBuffer = (PSZ)alloca(nNumberOfBytesToWrite);
+  if(pszBuffer == NULL) {
+    DebugInt3();
+    return FALSE;
+  }
+  memcpy(pszBuffer, lpBuffer, nNumberOfBytesToWrite);
 
   ulCounter = 0;
Index: trunk/src/kernel32/windllbase.cpp
===================================================================
--- trunk/src/kernel32/windllbase.cpp	(revision 4522)
+++ trunk/src/kernel32/windllbase.cpp	(revision 4523)
@@ -1,8 +1,8 @@
-/* $Id: windllbase.cpp,v 1.18 2000-10-10 17:14:06 sandervl Exp $ */
+/* $Id: windllbase.cpp,v 1.19 2000-10-23 13:42:42 sandervl Exp $ */
 
 /*
  * Win32 Dll base class
  *
- * Copyright 1998-1999 Sander van Leeuwen (sandervl@xs4all.nl)
+ * Copyright 1998-2000 Sander van Leeuwen (sandervl@xs4all.nl)
  *
  * Unloading of a dll always happens in order of dependency (taking nr of
@@ -10,5 +10,5 @@
  * Unloading of dynamically loaded dll (with LoadLibrary) in deleteAll
  * is done in LIFO order (NT exhibits the same behaviour)
- *           
+ *
  * RemoveCircularDependency: TODO: Send process detach message here??
  *
@@ -22,5 +22,5 @@
 #define INCL_DOSMISC             /* DOS Miscellanous values  */
 #define INCL_WIN
-#include <os2wrap.h>	//Odin32 OS/2 api wrappers
+#include <os2wrap.h>    //Odin32 OS/2 api wrappers
 #include <stdio.h>
 #include <string.h>
@@ -41,5 +41,5 @@
 #include "profile.h"
 
-#define DBG_LOCALLOG	DBG_windllbase
+#define DBG_LOCALLOG    DBG_windllbase
 #include "dbglocal.h"
 
@@ -48,16 +48,16 @@
 //******************************************************************************
 //******************************************************************************
-Win32DllBase::Win32DllBase(HINSTANCE hinstance, WIN32DLLENTRY DllEntryPoint, 
+Win32DllBase::Win32DllBase(HINSTANCE hinstance, WIN32DLLENTRY DllEntryPoint,
                            Win32ImageBase *parent)
                  : Win32ImageBase(hinstance),
-  	           referenced(0), fSkipThreadEntryCalls(FALSE), next(NULL), fInserted(FALSE),
-                   fAttachedToProcess(FALSE), fUnloaded(FALSE), 
-                   nrDynamicLibRef(0), fDisableUnload(FALSE), fSkipEntryCalls(FALSE)
-{
-  dllEntryPoint = DllEntryPoint;
-
-  setUnloadOrder(parent);
-  
-  dprintf(("Win32DllBase::Win32DllBase %x %s", hinstance, szModule));
+                    referenced(0), fSkipThreadEntryCalls(FALSE), next(NULL), fInserted(FALSE),
+                    fAttachedToProcess(FALSE), fUnloaded(FALSE),
+                    nrDynamicLibRef(0), fDisableUnload(FALSE), fSkipEntryCalls(FALSE)
+{
+    dllEntryPoint = DllEntryPoint;
+
+    setUnloadOrder(parent);
+
+    dprintf(("Win32DllBase::Win32DllBase %x %s", hinstance, szModule));
 }
 //******************************************************************************
@@ -65,34 +65,34 @@
 Win32DllBase::~Win32DllBase()
 {
-  dprintf(("Win32DllBase::~Win32DllBase %s", szModule));
-
-  if(errorState == NO_ERROR && !fUnloaded)
-  {
-	detachProcess();
-  }
-
-  dlllistmutex.enter();
-  if(head == this) {
-	head = next;
-  }
-  else {
+    dprintf(("Win32DllBase::~Win32DllBase %s", szModule));
+
+    if(errorState == NO_ERROR && !fUnloaded)
+    {
+        detachProcess();
+    }
+
+    dlllistmutex.enter();
+    if(head == this) {
+        head = next;
+    }
+    else {
         Win32DllBase *dll = head;
-	while(dll && dll->next != this) {
-		dll = dll->next;
-        }
-	if(dll == NULL) {
-		dprintf(("~Win32DllBase: Can't find dll!\n"));
-		dlllistmutex.leave();
-		return;
-	}
-	dll->next = next;
-  }
-  dlllistmutex.leave();
+        while(dll && dll->next != this) {
+            dll = dll->next;
+        }
+        if(dll == NULL) {
+            dprintf(("~Win32DllBase: Can't find dll!\n"));
+            dlllistmutex.leave();
+            return;
+        }
+        dll->next = next;
+    }
+    dlllistmutex.leave();
 }
 //******************************************************************************
 //******************************************************************************
 void Win32DllBase::incDynamicLib()
-{ 
-  if(nrDynamicLibRef == 0) {
+{
+    if(nrDynamicLibRef == 0) {
         //NOTE:
         //Must be called *after* attachprocess, since attachprocess may also
@@ -103,26 +103,25 @@
         //     this means that in ExitProcess, PNRS3260 needs to be removed
         //     first since RPAP3260 depends on it
-
-  	dlllistmutex.enter();
-	loadLibDlls.Push((ULONG)this);
-	dlllistmutex.leave();
-  }
-  nrDynamicLibRef++; 
+        dlllistmutex.enter();
+        loadLibDlls.Push((ULONG)this);
+        dlllistmutex.leave();
+    }
+    nrDynamicLibRef++;
 }
 //******************************************************************************
 //******************************************************************************
 void Win32DllBase::decDynamicLib()
-{ 
-  nrDynamicLibRef--; 
-  if(nrDynamicLibRef == 0) {
-  	dlllistmutex.enter();
-	loadLibDlls.Remove((ULONG)this);
-	dlllistmutex.leave();
-  }
+{
+    nrDynamicLibRef--;
+    if(nrDynamicLibRef == 0) {
+        dlllistmutex.enter();
+        loadLibDlls.Remove((ULONG)this);
+        dlllistmutex.leave();
+    }
 }
 //******************************************************************************
 //unload of dlls needs to be done in reverse order of dependencies
-//Note: Only necessary for pe loader; the OS/2 loader takes care of this 
-//for win32k/pe2lx 
+//Note: Only necessary for pe loader; the OS/2 loader takes care of this
+//for win32k/pe2lx
 //******************************************************************************
 void Win32DllBase::setUnloadOrder(Win32ImageBase *parent)
@@ -131,74 +130,72 @@
  Win32DllBase *parentdll = NULL;
 
-  dlllistmutex.enter();
-  if(parent) {
-  	dll = head;
-	while(dll) {
-		if(dll->getInstanceHandle() == parent->getInstanceHandle()) {
-			parentdll = dll;
-			break;
-		}
-		dll = dll->next;
-	}
-  }
-
-  //first check if this dll is already at a lower position (further down the list)
-  //than the parent
-  if(parentdll && fInserted) {//already in the list?
-  	dll = parentdll->next;
-  	while(dll) {
-		if(dll->getInstanceHandle() == getInstanceHandle()) {
-  			dlllistmutex.leave();
-			return; //it's at a lower position, so no need to change anything
-		}
-		dll = dll->next;
-  	}
-
-	//it's already in the list but not at the right position; remove it now
-	if(head == this) {
-		head = next;
-	}
-	else {
-		dll = head;
-		while(dll->next) {
-			if(dll->next == this) {
-				dll->next = next;
-				break;
-			}
-			dll = dll->next;
-		}
-	}
-  }
-  else 
-  if(fInserted) {//already in the list?
-  	dlllistmutex.leave();
-	return;
-  }
-  //(re)insert it in the list after it's parent
-  if(parentdll) {
-	next = parentdll->next;
-	parentdll->next = this;
-  }
-  else {//no parent or exe, just add it at the start of the list
-  	next = head;
-  	head = this;
-  }
-  fInserted = TRUE;
-
-  //Now do the same thing for the child dependencies
-  QueueItem *item;
-
-  item = loadedDlls.Head();
-  while(item) {
-	dll = (Win32DllBase *)loadedDlls.getItem(item);
-	//Check for circular dependencies (i.e. in Lotus Notes)
-	if(dll != parentdll) {
-  		dll->setUnloadOrder(this);
-	}
-
-	item  = loadedDlls.getNext(item);
-  }
-
-  dlllistmutex.leave();
+    dlllistmutex.enter();
+    if(parent) {
+        dll = head;
+        while(dll) {
+            if(dll->getInstanceHandle() == parent->getInstanceHandle()) {
+                parentdll = dll;
+                break;
+            }
+            dll = dll->next;
+        }
+    }
+
+    //first check if this dll is already at a lower position (further down the list)
+    //than the parent
+    if(parentdll && fInserted) {//already in the list?
+        dll = parentdll->next;
+        while(dll) {
+            if(dll->getInstanceHandle() == getInstanceHandle()) {
+                dlllistmutex.leave();
+                return; //it's at a lower position, so no need to change anything
+            }
+            dll = dll->next;
+        }
+
+        //it's already in the list but not at the right position; remove it now
+        if(head == this) {
+            head = next;
+        }
+        else {
+        dll = head;
+            while(dll->next) {
+                if(dll->next == this) {
+                    dll->next = next;
+                    break;
+                }
+                dll = dll->next;
+            }
+        }
+    }
+    else
+    if(fInserted) {//already in the list?
+        dlllistmutex.leave();
+        return;
+    }
+    //(re)insert it in the list after it's parent
+    if(parentdll) {
+        next = parentdll->next;
+        parentdll->next = this;
+    }
+    else {//no parent or exe, just add it at the start of the list
+        next = head;
+        head = this;
+    }
+    fInserted = TRUE;
+
+    //Now do the same thing for the child dependencies
+    QueueItem *item;
+
+    item = loadedDlls.Head();
+    while(item) {
+        dll = (Win32DllBase *)loadedDlls.getItem(item);
+        //Check for circular dependencies (i.e. in Lotus Notes)
+        if(dll != parentdll) {
+            dll->setUnloadOrder(this);
+        }
+        item  = loadedDlls.getNext(item);
+    }
+    dlllistmutex.leave();
 }
 //******************************************************************************
@@ -209,19 +206,18 @@
 ULONG Win32DllBase::AddRef()
 #endif
-{ 
+{
  Win32DllBase *dll;
 
-  dprintf(("Win32DllBase::AddRef %s->%s %d", parentname, getModuleName(), referenced+1));
-  ++referenced;
+    dprintf(("Win32DllBase::AddRef %s->%s %d", parentname, getModuleName(), referenced+1));
+    ++referenced;
 #ifdef DEBUG
-  if(referenced == 1) {
+    if(referenced == 1) {
 #ifdef DEBUG_ENABLELOG_LEVEL2
-	printListOfDlls();
+        printListOfDlls();
 #endif
-	//printDependencies(NULL);
-  }
+        //printDependencies(NULL);
+    }
 #endif
-
-  return referenced; 
+    return referenced;
 }
 //******************************************************************************
@@ -234,45 +230,45 @@
  LONG          ret;
 
-  dprintf(("Win32DllBase::Release %s %d", getModuleName(), referenced-1));
-
-  ret = --referenced;
-  if(ret <= 0) {
-	//make copy of linked list of dependencies
-	queue = loadedDlls;
-
-	//remove any circular dependencies on this dll that might be present
-  	item = queue.Head();
-  	while(item) {
-		dll = (Win32DllBase *)queue.getItem(item);
-		if(dll == NULL) {
-			dprintf(("ERROR: Win32DllBase::Release: dll item == NULL!!"));
-			DebugInt3();
-			return -1;
-		}
-		dll->RemoveCircularDependency(this);
-		item = queue.getNext(item);
-	}
+    dprintf(("Win32DllBase::Release %s %d", getModuleName(), referenced-1));
+
+    ret = --referenced;
+    if(ret <= 0) {
+        //make copy of linked list of dependencies
+        queue = loadedDlls;
+
+        //remove any circular dependencies on this dll that might be present
+        item = queue.Head();
+        while(item) {
+            dll = (Win32DllBase *)queue.getItem(item);
+            if(dll == NULL) {
+                dprintf(("ERROR: Win32DllBase::Release: dll item == NULL!!"));
+                DebugInt3();
+                return -1;
+            }
+            dll->RemoveCircularDependency(this);
+            item = queue.getNext(item);
+        }
 #ifdef DEBUG
-	//printDependencies(NULL);
+        //printDependencies(NULL);
 #endif
-	dprintf(("Win32DllBase::Release %s referenced == 0", getModuleName()));
-
-	//delete dll object
-	delete this;
-
-	//unreference all of it's dependencies
-  	item = queue.Head();
-  	while(item) {
-		dll = (Win32DllBase *)queue.getItem(item);
-		if(dll == NULL) {
-			dprintf(("ERROR: Win32DllBase::Release: dll item == NULL!!"));
-			DebugInt3();
-			return -1;
-		}
-		dll->Release();
-		item = queue.getNext(item);
-	}
-  }
-  return(ret);
+        dprintf(("Win32DllBase::Release %s referenced == 0", getModuleName()));
+
+        //delete dll object
+        delete this;
+
+        //unreference all of it's dependencies
+        item = queue.Head();
+        while(item) {
+            dll = (Win32DllBase *)queue.getItem(item);
+            if(dll == NULL) {
+                dprintf(("ERROR: Win32DllBase::Release: dll item == NULL!!"));
+                DebugInt3();
+                return -1;
+            }
+            dll->Release();
+            item = queue.getNext(item);
+        }
+    }
+    return(ret);
 }
 //******************************************************************************
@@ -286,27 +282,27 @@
  BOOL          ret = FALSE;
 
-  //remove any circular dependencies on this dll that might be present
-  item = loadedDlls.Head();
-  while(item) {
-	dll = (Win32DllBase *)loadedDlls.getItem(item);
-	if(dll == NULL) {
-		dprintf(("ERROR: Win32DllBase::Release: dll item == NULL!!"));
-		DebugInt3();
-		return FALSE;
-	}
-	tmp = loadedDlls.getNext(item);
-	if(dll == parent) {
-		dprintf(("Removing CIRCULAR dependency %s->%s", parent->getModuleName(), dll->getModuleName()));
-		loadedDlls.Remove(item);
-		ret = TRUE;
-	}
-////	else	ret |= dll->RemoveCircularDependency(parent);
-	item = tmp;
-  }
-  //TODO: Send process detach message here??
-  return ret;
-}
-//******************************************************************************
-//There's a slight problem with our dependency procedure. 
+    //remove any circular dependencies on this dll that might be present
+    item = loadedDlls.Head();
+    while(item) {
+        dll = (Win32DllBase *)loadedDlls.getItem(item);
+        if(dll == NULL) {
+            dprintf(("ERROR: Win32DllBase::Release: dll item == NULL!!"));
+            DebugInt3();
+            return FALSE;
+        }
+        tmp = loadedDlls.getNext(item);
+        if(dll == parent) {
+            dprintf(("Removing CIRCULAR dependency %s->%s", parent->getModuleName(), dll->getModuleName()));
+            loadedDlls.Remove(item);
+            ret = TRUE;
+        }
+////    else    ret |= dll->RemoveCircularDependency(parent);
+        item = tmp;
+    }
+    //TODO: Send process detach message here??
+    return ret;
+}
+//******************************************************************************
+//There's a slight problem with our dependency procedure.
 //example: gdi32 is loaded -> depends on kernel32 (which is already loaded)
 //         kernel32's reference count isn't updated
@@ -321,31 +317,30 @@
  Win32DllBase *dll, *depdll;
  ULONG         refcount;
- 
-  dlllistmutex.enter();
-  item = loadedDlls.Head();
-  while(item) {
-	depdll   = (Win32DllBase *)loadedDlls.getItem(item);
-	if(depdll == NULL) {
-		dprintf(("updateDependencies: depdll == NULL!!"));
-		DebugInt3();	
-		return;
-	}
-	refcount = 0;
-  	dll      = head;
-
-  	while(dll) {
-		if(dll->dependsOn(depdll)) {
-			refcount++;
-		}
-		dll = dll->getNext();
-	}
-	if(refcount > depdll->referenced) {
-		dprintf(("Win32DllBase::updateDependencies changing refcount of %s to %d (old=%d)", depdll->getModuleName(), refcount, depdll->referenced));
-		depdll->referenced = refcount;
-	}
-
-	item = loadedDlls.getNext(item);
-  }
-  dlllistmutex.leave();
+
+    dlllistmutex.enter();
+    item = loadedDlls.Head();
+    while(item) {
+        depdll   = (Win32DllBase *)loadedDlls.getItem(item);
+        if(depdll == NULL) {
+            dprintf(("updateDependencies: depdll == NULL!!"));
+            DebugInt3();
+            return;
+        }
+        refcount = 0;
+        dll      = head;
+
+        while(dll) {
+            if(dll->dependsOn(depdll)) {
+                refcount++;
+            }
+            dll = dll->getNext();
+        }
+        if(refcount > depdll->referenced) {
+            dprintf(("Win32DllBase::updateDependencies changing refcount of %s to %d (old=%d)", depdll->getModuleName(), refcount, depdll->referenced));
+            depdll->referenced = refcount;
+        }
+        item = loadedDlls.getNext(item);
+    }
+    dlllistmutex.leave();
 }
 //******************************************************************************
@@ -358,14 +353,14 @@
  ULONG         ret;
 
-  dprintf(("Dependency list: %s->%s %d", parent, getModuleName(), referenced));
-  item = loadedDlls.Head();
-  while(item) {
-	dll = (Win32DllBase *)loadedDlls.getItem(item);
-	if(dll == NULL) {
-		return;
-	}
-	dll->printDependencies(getModuleName());
-	item = loadedDlls.getNext(item);
-  }
+    dprintf(("Dependency list: %s->%s %d", parent, getModuleName(), referenced));
+    item = loadedDlls.Head();
+    while(item) {
+        dll = (Win32DllBase *)loadedDlls.getItem(item);
+        if(dll == NULL) {
+            return;
+        }
+        dll->printDependencies(getModuleName());
+        item = loadedDlls.getNext(item);
+    }
 }
 //******************************************************************************
@@ -376,11 +371,11 @@
  Win32DllBase *dll;
 
-  dll = head;
-
-  dprintf2(("Win32DllBase::Win32DllBase: List of loaded dlls:"));
-  while(dll) {
-	dprintf2(("DLL %s %d", dll->szModule, dll->referenced));
-	dll = dll->next;
-  }
+    dll = head;
+
+    dprintf2(("Win32DllBase::Win32DllBase: List of loaded dlls:"));
+    while(dll) {
+        dprintf2(("DLL %s %d", dll->szModule, dll->referenced));
+        dll = dll->next;
+    }
 }
 #endif
@@ -395,61 +390,61 @@
  BOOL rc, fSetExceptionHandler;
 
-  if(fAttachedToProcess || fSkipEntryCalls)
-	return TRUE;
-
-  fAttachedToProcess = TRUE;
-
-  thdb = GetThreadTHDB();
-  fSetExceptionHandler = (!thdb || thdb->teb_sel != GetFS());
-
-  //Note: The Win32 exception structure references by FS:[0] is the same
-  //      in OS/2
-  if(fSetExceptionHandler) {
-  	OS2SetExceptionHandler((void *)&exceptFrame);
-  	sel = SetWin32TIB();
-  }
-
-  //Allocate TLS index for this module
-  tlsAlloc();
-  tlsAttachThread();	//setup TLS (main thread)
-
-  if(dllEntryPoint == NULL) {
+    if(fAttachedToProcess || fSkipEntryCalls)
+        return TRUE;
+
+    fAttachedToProcess = TRUE;
+
+    thdb = GetThreadTHDB();
+    fSetExceptionHandler = (!thdb || thdb->teb_sel != GetFS());
+
+    //Note: The Win32 exception structure references by FS:[0] is the same
+    //      in OS/2
+    if(fSetExceptionHandler) {
+        OS2SetExceptionHandler((void *)&exceptFrame);
+        sel = SetWin32TIB();
+    }
+
+    //Allocate TLS index for this module
+    tlsAlloc();
+    tlsAttachThread();    //setup TLS (main thread)
+
+    if(dllEntryPoint == NULL) {
         dprintf(("attachProcess not required for dll %s", szModule));
-  	if(fSetExceptionHandler) {
-  		SetFS(sel);
-		OS2UnsetExceptionHandler((void *)&exceptFrame);
-	}
-	return(TRUE);
-  }
-
-  dprintf(("attachProcess to dll %s", szModule));
-  
-  // @@@PH 2000/06/13 lpvReserved, Starcraft STORM.DLL
-  // if DLL_PROCESS_ATTACH, lpvReserved is NULL for dynamic loads
-  //   and non-NULL for static loads.
-  // same goes for process termination
-  LPVOID lpvReserved;
-  
-  if (isDynamicLib())
-    lpvReserved = NULL;
-  else
-    lpvReserved = (LPVOID)0xdeadface; // some arbitrary value
-  
-  rc = dllEntryPoint(hinstance, DLL_PROCESS_ATTACH, lpvReserved);
-
-  dprintf(("attachProcess to dll %s DONE", szModule));
-
-  if(fSetExceptionHandler) {
-  	SetFS(sel);
-  	OS2UnsetExceptionHandler((void *)&exceptFrame);
-  }
-  else 
-  if(thdb) {
-	if(thdb->teb_sel != GetFS()) {
-		dprintf(("Win32DllBase::attachProcess: FS was changed by dll entrypoint!!!!"));
-		DebugInt3();
-	}
-  }
-  return rc;
+        if(fSetExceptionHandler) {
+            SetFS(sel);
+            OS2UnsetExceptionHandler((void *)&exceptFrame);
+        }
+        return(TRUE);
+    }
+
+    dprintf(("attachProcess to dll %s", szModule));
+
+    // @@@PH 2000/06/13 lpvReserved, Starcraft STORM.DLL
+    // if DLL_PROCESS_ATTACH, lpvReserved is NULL for dynamic loads
+    //   and non-NULL for static loads.
+    // same goes for process termination
+    LPVOID lpvReserved;
+
+    if (isDynamicLib())
+        lpvReserved = NULL;
+    else
+        lpvReserved = (LPVOID)0xdeadface; // some arbitrary value
+
+    rc = dllEntryPoint(hinstance, DLL_PROCESS_ATTACH, lpvReserved);
+
+    dprintf(("attachProcess to dll %s DONE", szModule));
+
+    if(fSetExceptionHandler) {
+        SetFS(sel);
+        OS2UnsetExceptionHandler((void *)&exceptFrame);
+    }
+    else
+    if(thdb) {
+        if(thdb->teb_sel != GetFS()) {
+            dprintf(("Win32DllBase::attachProcess: FS was changed by dll entrypoint!!!!"));
+            DebugInt3();
+        }
+    }
+    return rc;
 }
 //******************************************************************************
@@ -461,44 +456,44 @@
  BOOL rc;
 
-  if(fSkipEntryCalls) {
-	fUnloaded = TRUE;
-	return TRUE;
-  }
-
-  if(dllEntryPoint == NULL) {
-        tlsDetachThread();	//destroy TLS (main thread)
-	fUnloaded = TRUE;
-	return(TRUE);
-  }
-
-  dprintf(("detachProcess from dll %s", szModule));
-
-  //Note: The Win32 exception structure references by FS:[0] is the same
-  //      in OS/2
-  OS2SetExceptionHandler((void *)&exceptFrame);
-
-  fUnloaded = TRUE;
-  sel = SetWin32TIB();
-  
-  // @@@PH 2000/06/13 lpvReserved, Starcraft STORM.DLL
-  // if DLL_PROCESS_ATTACH, lpvReserved is NULL for dynamic loads
-  //   and non-NULL for static loads.
-  // same goes for process termination
-  LPVOID lpvReserved;
-  
-  if (isDynamicLib())
-    lpvReserved = NULL;
-  else
-    lpvReserved = (LPVOID)0xdeadface; // some arbitrary value
-  
-  rc = dllEntryPoint(hinstance, DLL_PROCESS_DETACH, lpvReserved);
-  
-  SetFS(sel);
-  tlsDetachThread();	//destroy TLS (main thread)
-  tlsDelete();
-
-  OS2UnsetExceptionHandler((void *)&exceptFrame);
-
-  return rc;
+    if(fSkipEntryCalls) {
+        fUnloaded = TRUE;
+        return TRUE;
+    }
+
+    if(dllEntryPoint == NULL) {
+        tlsDetachThread();  //destroy TLS (main thread)
+        fUnloaded = TRUE;
+        return(TRUE);
+    }
+
+    dprintf(("detachProcess from dll %s", szModule));
+
+    //Note: The Win32 exception structure references by FS:[0] is the same
+    //      in OS/2
+    OS2SetExceptionHandler((void *)&exceptFrame);
+
+    fUnloaded = TRUE;
+    sel = SetWin32TIB();
+
+    // @@@PH 2000/06/13 lpvReserved, Starcraft STORM.DLL
+    // if DLL_PROCESS_ATTACH, lpvReserved is NULL for dynamic loads
+    //   and non-NULL for static loads.
+    // same goes for process termination
+    LPVOID lpvReserved;
+
+    if (isDynamicLib())
+        lpvReserved = NULL;
+    else
+        lpvReserved = (LPVOID)0xdeadface; // some arbitrary value
+
+    rc = dllEntryPoint(hinstance, DLL_PROCESS_DETACH, lpvReserved);
+
+    SetFS(sel);
+    tlsDetachThread();    //destroy TLS (main thread)
+    tlsDelete();
+
+    OS2UnsetExceptionHandler((void *)&exceptFrame);
+
+    return rc;
 }
 //******************************************************************************
@@ -509,14 +504,14 @@
  BOOL               rc;
 
-  if(fSkipThreadEntryCalls || dllEntryPoint == NULL)
-	return(TRUE);
-
-  dprintf(("attachThread to dll %s", szModule));
-  
-  rc = dllEntryPoint(hinstance, DLL_THREAD_ATTACH, 0);
-
-  dprintf(("attachThread to dll %s DONE", szModule));
-
-  return rc;
+    if(fSkipThreadEntryCalls || dllEntryPoint == NULL)
+        return(TRUE);
+
+    dprintf(("attachThread to dll %s", szModule));
+
+    rc = dllEntryPoint(hinstance, DLL_THREAD_ATTACH, 0);
+
+    dprintf(("attachThread to dll %s DONE", szModule));
+
+    return rc;
 }
 //******************************************************************************
@@ -527,11 +522,11 @@
  BOOL               rc;
 
-  if(fSkipThreadEntryCalls || dllEntryPoint == NULL)
-	return(TRUE);
-
-  dprintf(("detachThread from dll %s", szModule));
-  
-  rc =  dllEntryPoint(hinstance, DLL_THREAD_DETACH, 0);
-  return rc;
+    if(fSkipThreadEntryCalls || dllEntryPoint == NULL)
+        return(TRUE);
+
+    dprintf(("detachThread from dll %s", szModule));
+
+    rc = dllEntryPoint(hinstance, DLL_THREAD_DETACH, 0);
+    return rc;
 }
 //******************************************************************************
@@ -540,37 +535,37 @@
 void Win32DllBase::attachThreadToAllDlls()
 {
-  dlllistmutex.enter();
-  Win32DllBase *dll = Win32DllBase::head;
-  while(dll) {
-	dll->attachThread();
-	dll = dll->getNext();
-  }
+    dlllistmutex.enter();
+    Win32DllBase *dll = Win32DllBase::head;
+    while(dll) {
+        dll->attachThread();
+        dll = dll->getNext();
+    }
+    dlllistmutex.leave();
+}
+//******************************************************************************
+//Send DLL_THREAD_DETACH message to all dlls for thread that's about to die
+//******************************************************************************
+void Win32DllBase::detachThreadFromAllDlls()
+{
+    dlllistmutex.enter();
+    Win32DllBase *dll = Win32DllBase::head;
+    while(dll) {
+        dll->detachThread();
+        dll = dll->getNext();
+    }
   dlllistmutex.leave();
 }
 //******************************************************************************
-//Send DLL_THREAD_DETACH message to all dlls for thread that's about to die
-//******************************************************************************
-void Win32DllBase::detachThreadFromAllDlls()
-{
-  dlllistmutex.enter();
-  Win32DllBase *dll = Win32DllBase::head;
-  while(dll) {
-	dll->detachThread();
-	dll = dll->getNext();
-  }
-  dlllistmutex.leave();
-}
-//******************************************************************************
 //Setup TLS structure for all dlls for a new thread
 //******************************************************************************
 void Win32DllBase::tlsAttachThreadToAllDlls()
 {
-  dlllistmutex.enter();
-  Win32DllBase *dll = Win32DllBase::head;
-  while(dll) {
-	dll->tlsAttachThread();
-	dll = dll->getNext();
-  }
-  dlllistmutex.leave();
+    dlllistmutex.enter();
+    Win32DllBase *dll = Win32DllBase::head;
+    while(dll) {
+        dll->tlsAttachThread();
+        dll = dll->getNext();
+    }
+    dlllistmutex.leave();
 }
 //******************************************************************************
@@ -579,11 +574,11 @@
 void Win32DllBase::tlsDetachThreadFromAllDlls()
 {
-  dlllistmutex.enter();
-  Win32DllBase *dll = Win32DllBase::head;
-  while(dll) {
-	dll->tlsDetachThread();
-	dll = dll->getNext();
-  }
-  dlllistmutex.leave();
+    dlllistmutex.enter();
+    Win32DllBase *dll = Win32DllBase::head;
+    while(dll) {
+        dll->tlsDetachThread();
+        dll = dll->getNext();
+    }
+    dlllistmutex.leave();
 }
 //******************************************************************************
@@ -593,17 +588,17 @@
  Win32DllBase *dll = Win32DllBase::head;
 
-  dprintf(("Win32DllBase::deleteAll"));
+    dprintf(("Win32DllBase::deleteAll"));
 
 #ifdef DEBUG_ENABLELOG_LEVEL2
-  if(dll) dll->printListOfDlls();
+    if(dll) dll->printListOfDlls();
 #endif
 
-  dlllistmutex.enter();
-  while(dll) {
-	dll->Release();
-	dll = Win32DllBase::head;
-  }
-  dlllistmutex.leave();
-  dprintf(("Win32DllBase::deleteAll Done!"));
+    dlllistmutex.enter();
+    while(dll) {
+        dll->Release();
+        dll = Win32DllBase::head;
+    }
+    dlllistmutex.leave();
+    dprintf(("Win32DllBase::deleteAll Done!"));
 }
 //******************************************************************************
@@ -615,28 +610,28 @@
  QueueItem    *item;
 
-  dprintf(("Win32DllBase::deleteDynamicLibs"));
+    dprintf(("Win32DllBase::deleteDynamicLibs"));
 #ifdef DEBUG_ENABLELOG_LEVEL2
-  if(dll) dll->printListOfDlls();
+    if(dll) dll->printListOfDlls();
 #endif
 
-  dlllistmutex.enter();
-
-  item = loadLibDlls.Head();
-  while(item) {
-	dll = (Win32DllBase *)loadLibDlls.getItem(item);
-	int dynref = dll->nrDynamicLibRef;
-	if(dynref) {
-  		while(dynref) {
-			dynref--;
-        		dll->decDynamicLib();
-			dll->Release();
-		}
-	}
-	else	DebugInt3();
-  	item = loadLibDlls.Head(); //queue could have been changed, so start from the beginning
-  }
-
-  dlllistmutex.leave();
-  dprintf(("Win32DllBase::deleteDynamicLibs end"));
+    dlllistmutex.enter();
+
+    item = loadLibDlls.Head();
+    while(item) {
+        dll = (Win32DllBase *)loadLibDlls.getItem(item);
+        int dynref = dll->nrDynamicLibRef;
+        if(dynref) {
+            while(dynref) {
+                dynref--;
+                dll->decDynamicLib();
+                dll->Release();
+            }
+        }
+        else    DebugInt3();
+        item = loadLibDlls.Head(); //queue could have been changed, so start from the beginning
+    }
+
+    dlllistmutex.leave();
+    dprintf(("Win32DllBase::deleteDynamicLibs end"));
 }
 //******************************************************************************
@@ -644,5 +639,5 @@
 Win32DllBase *Win32DllBase::getFirst()
 {
-  return head;
+    return head;
 }
 //******************************************************************************
@@ -654,22 +649,22 @@
  char renameddll[CCHMAXPATH];
 
-  if(PROFILE_GetOdinIniString(DLLRENAMEWIN_SECTION, "OLE32", "", renameddll, 
-                                   sizeof(renameddll)-1) <= 1) 
-  {
-	PROFILE_SetOdinIniString(DLLRENAMEWIN_SECTION, "OLE32", "OLE32OS2");
-	PROFILE_SetOdinIniString(DLLRENAMEOS2_SECTION, "OLE32OS2", "OLE32");
-  }
-  if(PROFILE_GetOdinIniString(DLLRENAMEWIN_SECTION, "OLEAUT32", "", renameddll, 
-                                   sizeof(renameddll)-1) <= 1) 
-  {
-	PROFILE_SetOdinIniString(DLLRENAMEWIN_SECTION, "OLEAUT32", "OLAUTOS2");
-	PROFILE_SetOdinIniString(DLLRENAMEOS2_SECTION, "OLAUTOS2", "OLEAUT32");
-  }
-  if(PROFILE_GetOdinIniString(DLLRENAMEWIN_SECTION, "NETAPI32", "", renameddll, 
-                                   sizeof(renameddll)-1) <= 1) 
-  {
-	PROFILE_SetOdinIniString(DLLRENAMEWIN_SECTION, "NETAPI32", "WNETAP32");
-	PROFILE_SetOdinIniString(DLLRENAMEOS2_SECTION, "WNETAP32", "NETAPI32");
-  }
+    if(PROFILE_GetOdinIniString(DLLRENAMEWIN_SECTION, "OLE32", "", renameddll,
+                                sizeof(renameddll)-1) <= 1)
+    {
+        PROFILE_SetOdinIniString(DLLRENAMEWIN_SECTION, "OLE32", "OLE32OS2");
+        PROFILE_SetOdinIniString(DLLRENAMEOS2_SECTION, "OLE32OS2", "OLE32");
+    }
+    if(PROFILE_GetOdinIniString(DLLRENAMEWIN_SECTION, "OLEAUT32", "", renameddll,
+                                sizeof(renameddll)-1) <= 1)
+    {
+        PROFILE_SetOdinIniString(DLLRENAMEWIN_SECTION, "OLEAUT32", "OLAUTOS2");
+        PROFILE_SetOdinIniString(DLLRENAMEOS2_SECTION, "OLAUTOS2", "OLEAUT32");
+    }
+    if(PROFILE_GetOdinIniString(DLLRENAMEWIN_SECTION, "NETAPI32", "", renameddll,
+                                sizeof(renameddll)-1) <= 1)
+    {
+        PROFILE_SetOdinIniString(DLLRENAMEWIN_SECTION, "NETAPI32", "WNETAP32");
+        PROFILE_SetOdinIniString(DLLRENAMEOS2_SECTION, "WNETAP32", "NETAPI32");
+    }
 }
 //******************************************************************************
@@ -686,29 +681,32 @@
  char *sectionname;
 
-  if(fWinToOS2) {
-	sectionname = DLLRENAMEWIN_SECTION;
-  }
-  else {
-	sectionname = DLLRENAMEOS2_SECTION;
-  }
-  namestart = OSLibStripPath(dllname);
-  strcpy(modname, namestart);
-  char *dot = strrchr(modname, '.');
-  if(dot)
-	*dot = 0;
-  strupr(modname);
-  if(PROFILE_GetOdinIniString(sectionname, modname, "", renameddll, 
-                                   sizeof(renameddll)-1) > 1) 
-  {
-	if(namestart == dllname) {
-		strcpy(dllname, renameddll);
-	}
-	else {
-		*namestart = 0;
-		strcat(dllname, renameddll);
-	}
-	strcat(dllname, ".dll");
-  }
-  return;
+    if(fWinToOS2) {
+        sectionname = DLLRENAMEWIN_SECTION;
+    }
+    else {
+        sectionname = DLLRENAMEOS2_SECTION;
+    }
+    namestart = OSLibStripPath(dllname);
+    strcpy(modname, namestart);
+    char *dot = strrchr(modname, '.');
+    if(dot)
+        *dot = 0;
+    strupr(modname);
+    if(PROFILE_GetOdinIniString(sectionname, modname, "", renameddll,
+                                   sizeof(renameddll)-1) > 1)
+    {
+        if(namestart == dllname) {
+            strcpy(dllname, renameddll);
+        }
+        else {
+            *namestart = 0;
+            strcat(dllname, renameddll);
+        }
+        if(!strchr(dllname, '.')) {
+            strcat(dllname, DLL_EXTENSION);
+        }
+        strupr(dllname);
+    }
+    return;
 }
 //******************************************************************************
@@ -722,27 +720,22 @@
 ////  dprintf2(("findModule %s", dllname));
 
-  strcpy(szDllName, OSLibStripPath(dllname));
-  strupr(szDllName);
-
-  if(fRenameFirst) {
-	renameDll(szDllName, FALSE);
-  }
-
-  dot = strstr(szDllName, ".");
-  if(dot)
-	*dot = 0;
-
-  dlllistmutex.enter();
-  dll = head;
-  while(dll) {
-	if(strcmpi(szDllName, dll->szModule) == 0) {
-		dlllistmutex.leave();
-		return(dll);
-        }
-
-	dll = dll->next;
-  }
-  dlllistmutex.leave();
-  return(NULL);
+    strcpy(szDllName, OSLibStripPath(dllname));
+    strupr(szDllName);
+
+    if(fRenameFirst) {
+        renameDll(szDllName, FALSE);
+    }
+
+    dlllistmutex.enter();
+    dll = head;
+    while(dll) {
+        if(strcmpi(szDllName, dll->szModule) == 0) {
+            dlllistmutex.leave();
+            return(dll);
+        }
+        dll = dll->next;
+    }
+    dlllistmutex.leave();
+    return(NULL);
 }
 //******************************************************************************
@@ -750,18 +743,18 @@
 Win32DllBase *Win32DllBase::findModule(WIN32DLLENTRY DllEntryPoint)
 {
-   dprintf2(("findModule %X", DllEntryPoint));
-
-   dlllistmutex.enter();
-   Win32DllBase *mod = Win32DllBase::head;
-   while(mod != NULL) {
-	dbgCheckObj(mod);
-	if(mod->dllEntryPoint == DllEntryPoint) {
-		dlllistmutex.leave();
-		return(mod);
-        }
-	mod = mod->next;
-   }
-   dlllistmutex.leave();
-   return(NULL);
+    dprintf2(("findModule %X", DllEntryPoint));
+
+    dlllistmutex.enter();
+    Win32DllBase *mod = Win32DllBase::head;
+    while(mod != NULL) {
+        dbgCheckObj(mod);
+        if(mod->dllEntryPoint == DllEntryPoint) {
+            dlllistmutex.leave();
+            return(mod);
+        }
+        mod = mod->next;
+    }
+    dlllistmutex.leave();
+    return(NULL);
 }
 //******************************************************************************
@@ -769,17 +762,17 @@
 Win32DllBase *Win32DllBase::findModule(HINSTANCE hinstance)
 {
-   dlllistmutex.enter();
-
-   Win32DllBase *mod = Win32DllBase::head;
-   while(mod != NULL) {
-	dbgCheckObj(mod);
-	if(mod->hinstance == hinstance) {
-		dlllistmutex.leave();
-		return(mod);
-        }
-	mod = mod->next;
-   }
-   dlllistmutex.leave();
-   return(NULL);
+    dlllistmutex.enter();
+
+    Win32DllBase *mod = Win32DllBase::head;
+    while(mod != NULL) {
+        dbgCheckObj(mod);
+        if(mod->hinstance == hinstance) {
+            dlllistmutex.leave();
+            return(mod);
+        }
+        mod = mod->next;
+    }
+    dlllistmutex.leave();
+    return(NULL);
 }
 //******************************************************************************
@@ -787,17 +780,17 @@
 Win32DllBase *Win32DllBase::findModuleByAddr(ULONG address)
 {
-   dlllistmutex.enter();
-
-   Win32DllBase *mod = Win32DllBase::head;
-   while(mod != NULL) {
-	dbgCheckObj(mod);
-	if(mod->insideModule(address)) {
-		dlllistmutex.leave();
-		return(mod);
-        }
-	mod = mod->next;
-   }
-   dlllistmutex.leave();
-   return(NULL);
+    dlllistmutex.enter();
+
+    Win32DllBase *mod = Win32DllBase::head;
+    while(mod != NULL) {
+        dbgCheckObj(mod);
+        if(mod->insideModule(address)) {
+            dlllistmutex.leave();
+            return(mod);
+        }
+        mod = mod->next;
+    }
+    dlllistmutex.leave();
+    return(NULL);
 }
 //******************************************************************************
@@ -805,5 +798,5 @@
 BOOL Win32DllBase::isDll()
 {
-  return TRUE;
+    return TRUE;
 }
 //******************************************************************************
Index: trunk/src/kernel32/windllbase.h
===================================================================
--- trunk/src/kernel32/windllbase.h	(revision 4522)
+++ trunk/src/kernel32/windllbase.h	(revision 4523)
@@ -1,3 +1,3 @@
-/* $Id: windllbase.h,v 1.6 2000-10-10 17:14:06 sandervl Exp $ */
+/* $Id: windllbase.h,v 1.7 2000-10-23 13:42:43 sandervl Exp $ */
 
 /*
@@ -29,4 +29,6 @@
 #define LOAD_LIBRARY_AS_DATAFILE        0x00000002
 #define LOAD_WITH_ALTERED_SEARCH_PATH   0x00000008
+
+#define DLL_EXTENSION 		".DLL"
 
 //odin.ini section names to lookup renamed dlls
Index: trunk/src/kernel32/windllpeldr.cpp
===================================================================
--- trunk/src/kernel32/windllpeldr.cpp	(revision 4522)
+++ trunk/src/kernel32/windllpeldr.cpp	(revision 4523)
@@ -1,3 +1,3 @@
-/* $Id: windllpeldr.cpp,v 1.7 2000-05-27 11:30:35 sandervl Exp $ */
+/* $Id: windllpeldr.cpp,v 1.8 2000-10-23 13:42:44 sandervl Exp $ */
 
 /*
@@ -63,5 +63,5 @@
   strupr(szFileName);
   if(!strchr(szFileName, (int)'.')) {
- 	strcat(szFileName,".DLL");
+ 	strcat(szFileName, DLL_EXTENSION);
   }
   dllfile = OSLibDosOpen(szFileName, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
Index: trunk/src/kernel32/winimagebase.cpp
===================================================================
--- trunk/src/kernel32/winimagebase.cpp	(revision 4522)
+++ trunk/src/kernel32/winimagebase.cpp	(revision 4523)
@@ -1,3 +1,3 @@
-/* $Id: winimagebase.cpp,v 1.29 2000-10-10 17:14:07 sandervl Exp $ */
+/* $Id: winimagebase.cpp,v 1.30 2000-10-23 13:42:44 sandervl Exp $ */
 
 /*
@@ -64,8 +64,4 @@
     name = strrchr(szFileName, '\\')+1;
     strcpy(szModule, name);
-
-    char *dot = strrchr(szModule, '.');
-    if(dot)
-        *dot = 0;
   }
   else {
@@ -154,49 +150,52 @@
  char  *imagepath;
 
-  strcpy(szFullName, szFileName);
-  strupr(szFullName);
-  if(!strchr(szFullName, (int)'.')) {
-        strcat(szFullName,".DLL");
-  }
-
-  //search order:
-  //1) exe dir
-  //2) current dir
-  //3) windows system dir (kernel32 path)
-  //4) windows dir
-  //5) path
-  if(WinExe) {
-    strcpy(modname, WinExe->getFullPath());
-    //remove file name from full path
-    imagepath = modname + strlen(modname) - 1;
-    while(*imagepath != '\\') imagepath--;
-    imagepath[1] = 0;
-    strcat(modname, szFullName);
-    dllfile = OSLibDosOpen(modname, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
-  }
-  if(dllfile == NULL) {
-    strcpy(modname, szFullName);
-    dllfile = OSLibDosOpen(szFullName, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
-    if(dllfile == NULL) {
+    strcpy(szFullName, szFileName);
+    strupr(szFullName);
+    if(!strchr(szFullName, (int)'.')) {
+        strcat(szFullName, DLL_EXTENSION);
+    }
+
+    //search order:
+    //1) exe dir
+    //2) current dir
+    //3) windows system dir (kernel32 path)
+    //4) windows dir
+    //5) path
+    if(WinExe) {
+        strcpy(modname, WinExe->getFullPath());
+        //remove file name from full path
+        imagepath = modname + strlen(modname) - 1;
+        while(*imagepath != '\\')
+            imagepath--;
+        imagepath[1] = 0;
+        strcat(modname, szFullName);
+        dllfile = OSLibDosOpen(modname, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
+    }
+    if(dllfile == NULL)
+    {
+        strcpy(modname, szFullName);
+        dllfile = OSLibDosOpen(szFullName, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
+        if(dllfile == NULL)
+        {
             strcpy(modname, InternalGetSystemDirectoryA());
-        strcat(modname, "\\");
+            strcat(modname, "\\");
             strcat(modname, szFullName);
-        dllfile = OSLibDosOpen(modname, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
-        if(dllfile == NULL) {
-            strcpy(modname, InternalGetWindowsDirectoryA());
-            strcat(modname, "\\");
+            dllfile = OSLibDosOpen(modname, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
+            if(dllfile == NULL)
+            {
+                strcpy(modname, InternalGetWindowsDirectoryA());
+                strcat(modname, "\\");
                 strcat(modname, szFullName);
-            dllfile = OSLibDosOpen(modname, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
-            if(dllfile == NULL) {
-                if(OSLibDosSearchPath(OSLIB_SEARCHENV, "PATH", szFullName, modname, sizeof(modname)) == 0) {
-                    return FALSE;
+                dllfile = OSLibDosOpen(modname, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
+                if(dllfile == NULL) {
+                    if(OSLibDosSearchPath(OSLIB_SEARCHENV, "PATH", szFullName, modname, sizeof(modname)) == 0)
+                        return FALSE;
                 }
             }
         }
     }
-  }
-  strcpy(szFullName, modname);
-  if(dllfile) OSLibDosClose(dllfile);
-  return TRUE;
+    strcpy(szFullName, modname);
+    if(dllfile) OSLibDosClose(dllfile);
+    return TRUE;
 }
 
@@ -254,10 +253,10 @@
   rc = DosRead(win32handle, pdoshdr, sizeof(IMAGE_DOS_HEADER), &ulRead);
   if(rc != NO_ERROR || ulRead != sizeof(IMAGE_DOS_HEADER)) {
-    free(pdoshdr);
+        free(pdoshdr);
         DosClose(win32handle);                /* Close the file */
         return ERROR_INVALID_EXE_SIGNATURE_W;
   }
   if(pdoshdr->e_magic != IMAGE_DOS_SIGNATURE) {
-    free(pdoshdr);
+        free(pdoshdr);
         DosClose(win32handle);                /* Close the file */
         return ERROR_INVALID_EXE_SIGNATURE_W;
@@ -294,5 +293,5 @@
   }
   if(Characteristics) {
-	*Characteristics = fh.Characteristics;
+        *Characteristics = fh.Characteristics;
   }
   DosClose(win32handle);
@@ -346,5 +345,5 @@
  * @remark      Just a clarification:
  *              A module name is the filename of a executable image without
- *              path and without extention.
+ *              path, but *with* extention.
  */
 BOOL Win32ImageBase::matchModName(const char *pszFilename) const
@@ -365,15 +364,11 @@
            )
     {
-        if (ch == '.' && pszModNameEnd == NULL)
-            pszModNameEnd = pszModName;
         pszModName--;
     }
     pszModName++;
-   
+
     /** @sketch
      * Compare the names caseinsensitivly.
      */
-    if (pszModNameEnd)
-        return strnicmp(pszModName, szModule, pszModNameEnd - pszModName) == 0;
     return stricmp(pszModName, szModule) == 0;
 }
Index: trunk/src/kernel32/winimagepeldr.cpp
===================================================================
--- trunk/src/kernel32/winimagepeldr.cpp	(revision 4522)
+++ trunk/src/kernel32/winimagepeldr.cpp	(revision 4523)
@@ -1,3 +1,3 @@
-/* $Id: winimagepeldr.cpp,v 1.62 2000-10-16 19:15:16 sandervl Exp $ */
+/* $Id: winimagepeldr.cpp,v 1.63 2000-10-23 13:42:45 sandervl Exp $ */
 
 /*
@@ -111,36 +111,28 @@
  HFILE  dllfile;
 
-  strcpy(szFileName, pszFileName);
-  strupr(szFileName);
-  if(isExe) {
-    if(!strchr(szFileName, '.')) {
-        strcat(szFileName,".EXE");
-    }
-    dllfile = OSLibDosOpen(szFileName, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
-    if(dllfile == NULL) {
-        if(!strstr(szFileName, ".EXE")) {
+    strcpy(szFileName, pszFileName);
+    strupr(szFileName);
+    if(isExe) {
+        if(!strchr(szFileName, '.')) {
             strcat(szFileName,".EXE");
         }
         dllfile = OSLibDosOpen(szFileName, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
         if(dllfile == NULL) {
-            OSLibDosSearchPath(OSLIB_SEARCHENV, "PATH", szFileName, szFileName, sizeof(szFileName));
-        }
-    }
-    else    OSLibDosClose(dllfile);
-  }
-  else {
-    findDll(szFileName, szModule, sizeof(szModule));
-    strcpy(szFileName, szModule);
-  }
-  strcpy(szModule, OSLibStripPath(szFileName));
-  strupr(szModule);
-  char *dot = strstr(szModule, ".");
-  while(dot) {
-    char *newdot = strstr(dot+1, ".");
-    if(newdot == NULL)  break;
-    dot = newdot;
-  }
-  if(dot)
-    *dot = 0;
+            if(!strstr(szFileName, ".EXE")) {
+                strcat(szFileName,".EXE");
+            }
+            dllfile = OSLibDosOpen(szFileName, OSLIB_ACCESS_READONLY|OSLIB_ACCESS_SHAREDENYNONE);
+            if(dllfile == NULL) {
+                OSLibDosSearchPath(OSLIB_SEARCHENV, "PATH", szFileName, szFileName, sizeof(szFileName));
+            }
+        }
+        else    OSLibDosClose(dllfile);
+    }
+    else {
+        findDll(szFileName, szModule, sizeof(szModule));
+        strcpy(szFileName, szModule);
+    }
+    strcpy(szModule, OSLibStripPath(szFileName));
+    strupr(szModule);
 }
 //******************************************************************************
@@ -1325,44 +1317,44 @@
  int           forwardord;
 
-  forwarddll = strdup(forward);
-  if(forwarddll == NULL) {
-    return FALSE;
-  }
-  forwardapi = strchr(forwarddll, '.');
-  if(forwardapi == NULL) {
-    goto fail;
-  }
-  *forwardapi++ = 0;
-  if(strlen(forwarddll) == 0 || strlen(forwardapi) == 0) {
-    goto fail;
-  }
-  WinDll = Win32DllBase::findModule(forwarddll);
-  if(WinDll == NULL) {
-    WinDll = loadDll(forwarddll);
+    forwarddll = strdup(forward);
+    if(forwarddll == NULL) {
+        return FALSE;
+    }
+    forwardapi = strchr(forwarddll, '.');
+    if(forwardapi == NULL) {
+        goto fail;
+    }
+    *forwardapi++ = 0;
+    if(strlen(forwarddll) == 0 || strlen(forwardapi) == 0) {
+        goto fail;
+    }
+    WinDll = Win32DllBase::findModule(forwarddll);
     if(WinDll == NULL) {
-        dprintf((LOG, "ERROR: couldn't find forwarder %s.%s", forwarddll, forwardapi));
-        goto fail;
-    }
-  }
-  //check if name or ordinal forwarder
-  forwardord = 0;
-  if(*forwardapi >= '0' && *forwardapi <= '9') {
-    forwardord = atoi(forwardapi);
-  }
-  if(forwardord != 0 || (strlen(forwardapi) == 1 && *forwardapi == '0')) {
-    exportaddr = WinDll->getApi(forwardord);
-  }
-  else  exportaddr = WinDll->getApi(forwardapi);
-
-  if(apiname) {
+        WinDll = loadDll(forwarddll);
+        if(WinDll == NULL) {
+            dprintf((LOG, "ERROR: couldn't find forwarder %s.%s", forwarddll, forwardapi));
+            goto fail;
+        }
+    }
+    //check if name or ordinal forwarder
+    forwardord = 0;
+    if(*forwardapi >= '0' && *forwardapi <= '9') {
+        forwardord = atoi(forwardapi);
+    }
+    if(forwardord != 0 || (strlen(forwardapi) == 1 && *forwardapi == '0')) {
+        exportaddr = WinDll->getApi(forwardord);
+    }
+    else  exportaddr = WinDll->getApi(forwardapi);
+
+    if(apiname) {
         dprintf((LOG, "address 0x%x %s @%d (0x%08x) forwarder %s.%s", virtaddr - oh.ImageBase, apiname, ordinal, virtaddr, forwarddll, forwardapi));
-    AddNameExport(exportaddr, apiname, ordinal, TRUE);
-  }
-  else {
+        AddNameExport(exportaddr, apiname, ordinal, TRUE);
+    }
+    else {
         dprintf((LOG, "address 0x%x @%d (0x%08x) forwarder %s.%s", virtaddr - oh.ImageBase, ordinal, virtaddr, forwarddll, forwardapi));
-        AddOrdExport(exportaddr, ordinal, TRUE);
-  }
-  free(forwarddll);
-  return TRUE;
+         AddOrdExport(exportaddr, ordinal, TRUE);
+    }
+    free(forwarddll);
+    return TRUE;
 
 fail:
@@ -1378,6 +1370,17 @@
 
     strcpy(modname, pszCurModule);
+
     //rename dll if necessary (i.e. OLE32 -> OLE32OS2)
     Win32DllBase::renameDll(modname);
+
+    char szModName2[CCHMAXPATH];
+    strcpy(szModName2, modname);
+    if (!Win32ImageBase::findDll(szModName2, modname, sizeof(modname)))
+    {
+            dprintf((LOG, "Module %s not found!", modname));
+            sprintf(szErrorModule, "%s", modname);
+            errorState = 2;
+            return NULL;
+    }
 
     if(isPEImage(modname) != ERROR_SUCCESS_W)
@@ -1386,15 +1389,14 @@
         char   szModuleFailure[CCHMAXPATH] = "";
         ULONG  hInstanceNewDll;
-                Win32LxDll *lxdll;
+        Win32LxDll *lxdll;
 
         char *dot = strchr(modname, '.');
-        if(dot) {
-            *dot = 0;
-        }
-        strcat(modname, ".DLL");
+        if(dot == NULL) {
+            strcat(modname, DLL_EXTENSION);
+        }
         rc = DosLoadModule(szModuleFailure, sizeof(szModuleFailure), modname, (HMODULE *)&hInstanceNewDll);
         if(rc) {
-            dprintf((LOG, "DosLoadModule returned %X for %s\n", rc, szModuleFailure));
-            sprintf(szErrorModule, "%s.DLL", szModuleFailure);
+            dprintf((LOG, "DosLoadModule returned %X for %s", rc, szModuleFailure));
+            sprintf(szErrorModule, "%s", szModuleFailure);
             errorState = rc;
             return NULL;
@@ -1413,5 +1415,5 @@
             return NULL;
         }
-                WinDll = (Win32DllBase*)lxdll;
+        WinDll = (Win32DllBase*)lxdll;
     }
     else {
@@ -1423,5 +1425,5 @@
                 WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, szMemErrorMsg, szErrorTitle, 0, MB_OK | MB_ERROR | MB_MOVEABLE);
                 errorState = ERROR_INTERNAL;
-            return NULL;
+                return NULL;
             }
             dprintf((LOG, "**********************************************************************" ));
@@ -1430,6 +1432,6 @@
             if(pedll->init(0) == FALSE) {
                 dprintf((LOG, "Internal WinDll error ", pedll->getError() ));
-            delete pedll;
-            return NULL;
+                delete pedll;
+                return NULL;
             }
 #ifdef DEBUG
@@ -1440,7 +1442,7 @@
             if(pedll->attachProcess() == FALSE) {
                 dprintf((LOG, "attachProcess failed!" ));
-            delete pedll;
+                delete pedll;
                 errorState = ERROR_INTERNAL;
-            return NULL;
+                return NULL;
             }
         WinDll = (Win32DllBase*)pedll;
@@ -1449,5 +1451,5 @@
     dprintf((LOG, "**********************************************************************" ));
     dprintf((LOG, "**********************  Finished Loading Module %s ", modname ));
-        dprintf((LOG, "**********************************************************************" ));
+    dprintf((LOG, "**********************************************************************" ));
 
     return WinDll;
@@ -1600,13 +1602,12 @@
     if(WinDll == NULL)
     {  //not found, so load it
-    WinDll = loadDll(pszCurModule);
-    if(WinDll == NULL) {
-        return FALSE;
-    }
+        WinDll = loadDll(pszCurModule);
+        if(WinDll == NULL) {
+            return FALSE;
+        }
     }
     else {
-    WinDll->AddRef();
-
-    dprintf((LOG, "Already found ", pszCurModule));
+        WinDll->AddRef();
+        dprintf((LOG, "Already found ", pszCurModule));
     }
     //add the dll we just loaded to dependency list for this image
Index: trunk/src/kernel32/wprocess.cpp
===================================================================
--- trunk/src/kernel32/wprocess.cpp	(revision 4522)
+++ trunk/src/kernel32/wprocess.cpp	(revision 4523)
@@ -1,3 +1,3 @@
-/* $Id: wprocess.cpp,v 1.105 2000-10-18 17:09:34 sandervl Exp $ */
+/* $Id: wprocess.cpp,v 1.106 2000-10-23 13:42:47 sandervl Exp $ */
 
 /*
@@ -679,5 +679,5 @@
     ULONG           fPE;                /* isPEImage return value. */
     DWORD           Characteristics;    //file header's Characteristics
-    BOOL            fDllModule;         //file type
+    char           *dot;
 
     /** @sketch
@@ -709,5 +709,5 @@
     /** @sketch
      *  First we'll see if the module is allready loaded - either as the EXE or as DLL.
-     *  IF NOT dll AND Executable present AND libfile matches the modname of the executable THEN
+     *  IF Executable present AND libfile matches the modname of the executable THEN
      *      RETURN instance handle of executable.
      *  Endif
@@ -721,21 +721,22 @@
      *  Endif
      */
-    if(strstr(lpszLibFile, ".DLL")) {
-        fDllModule = TRUE;
+    strcpy(szModname, lpszLibFile);
+    strupr(szModname);
+    dot = strchr(szModname, '.');
+    if(dot == NULL) {
+        //if there's no extension or trainling dot, we
+        //assume it's a dll (see Win32 SDK docs)
+        strcat(szModname, DLL_EXTENSION);
     }
     else {
-        if(!strstr(lpszLibFile, ".")) {
-            //if there's no extension or trainling dot, we
-            //assume it's a dll (see Win32 SDK docs)
-            fDllModule = TRUE;
-        }
-    }
-
-    //todo: the entire exe name probably needs to be identical (path + extension)
-    //      -> check in NT
-    if (!fDllModule && WinExe != NULL && WinExe->matchModName(lpszLibFile))
+        if(dot[1] == 0) {
+            //a trailing dot means the module has no extension (SDK docs)
+            *dot = 0;
+        }
+    }
+    if (WinExe != NULL && WinExe->matchModName(szModname))
         return WinExe->getInstanceHandle();
 
-    pModule = Win32DllBase::findModule((LPSTR)lpszLibFile);
+    pModule = Win32DllBase::findModule((LPSTR)szModname);
     if (pModule)
     {
@@ -743,5 +744,5 @@
         pModule->AddRef();
         dprintf(("KERNEL32: LoadLibraryExA(%s, 0x%x, 0x%x): returns 0x%x. Dll found %s",
-                 lpszLibFile, hFile, dwFlags, pModule->getInstanceHandle(), pModule->getFullPath()));
+                 szModname, hFile, dwFlags, pModule->getInstanceHandle(), pModule->getFullPath()));
         return pModule->getInstanceHandle();
     }
@@ -758,12 +759,10 @@
      *  Endif
      */
-    fPath = strchr(lpszLibFile, '\\') || strchr(lpszLibFile, '/');
-    strcpy(szModname, lpszLibFile);
+    fPath = strchr(szModname, '\\') || strchr(szModname, '/');
     Win32DllBase::renameDll(szModname);
-    strupr(szModname);
 
     if (!fPath)
     {
-        char    szModName2[CCHMAXPATH];
+        char szModName2[CCHMAXPATH];
         strcpy(szModName2, szModname);
         if (!Win32ImageBase::findDll(szModName2, szModname, sizeof(szModname)))
@@ -1125,5 +1124,5 @@
             return ERROR_NOT_ENOUGH_MEMORY;
         }
-    strcpy((char *)pszCmdLineA, pszPeExe);
+        strcpy((char *)pszCmdLineA, pszPeExe);
 
         rc = NO_ERROR;
@@ -1464,4 +1463,14 @@
 //NOTE: GetModuleHandleA does NOT support files with multiple dots (i.e.
 //      very.weird.exe)
+//
+//  	hinst = LoadLibrary("WINSPOOL.DRV");      -> succeeds
+//	    hinst2 = GetModuleHandle("WINSPOOL.DRV"); -> succeeds
+//      hinst3 = GetModuleHandle("WINSPOOL.");    -> fails
+//      hinst4 = GetModuleHandle("WINSPOOL");     -> fails
+//  	hinst = LoadLibrary("KERNEL32.DLL");      -> succeeds
+//	    hinst2 = GetModuleHandle("KERNEL32.DLL"); -> succeeds
+//      hinst3 = GetModuleHandle("KERNEL32.");    -> fails
+//      hinst4 = GetModuleHandle("KERNEL32");     -> succeeds
+//      Same behaviour as observed in NT4, SP6
 //******************************************************************************
 HANDLE WIN32API GetModuleHandleA(LPCTSTR lpszModule)
@@ -1470,42 +1479,39 @@
  Win32DllBase *windll;
  char      szModule[CCHMAXPATH];
- BOOL      fDllModule = FALSE;
-
-  if(lpszModule == NULL) {
-    if(WinExe)
+ char     *dot;
+
+    if(lpszModule == NULL)
+    {
+        if(WinExe)
+                hMod = WinExe->getInstanceHandle();
+        else    hMod = -1;
+    }
+    else
+    {
+        strcpy(szModule, OSLibStripPath((char *)lpszModule));
+        strupr(szModule);
+        dot = strchr(szModule, '.');
+        if(dot == NULL) {
+            //if no extension -> add .DLL (see SDK docs)
+            strcat(szModule, DLL_EXTENSION);
+        }
+        else {
+            if(dot[1] == 0) {
+                //a trailing dot means the module has no extension (SDK docs)
+                *dot = 0;
+            }
+        }
+        if(WinExe && WinExe->matchModName(szModule)) {
             hMod = WinExe->getInstanceHandle();
-    else    hMod = -1;
-  }
-  else
-  {
-    strcpy(szModule, OSLibStripPath((char *)lpszModule));
-    strupr(szModule);
-    if(strstr(szModule, ".DLL")) {
-        fDllModule = TRUE;
-    }
-    else {
-        if(!strstr(szModule, ".")) {
-            //if there's no extension or trainling dot, we
-            //assume it's a dll (see Win32 SDK docs)
-            fDllModule = TRUE;
-        }
-    }
-    char *dot = strstr(szModule, ".");
-    if(dot)
-        *dot = 0;
-
-    if(!fDllModule && WinExe && WinExe->matchModName(szModule)) {
-        hMod = WinExe->getInstanceHandle();
-    }
-    else {
-        windll = Win32DllBase::findModule(szModule);
-        if(windll) {
-              hMod = windll->getInstanceHandle();
-        }
-    }
-  }
-
-  dprintf(("KERNEL32:  GetModuleHandle %s returned %X\n", lpszModule, hMod));
-  return(hMod);
+        }
+        else {
+            windll = Win32DllBase::findModule(szModule);
+            if(windll) {
+                  hMod = windll->getInstanceHandle();
+            }
+        }
+    }
+    dprintf(("KERNEL32:  GetModuleHandle %s returned %X\n", lpszModule, hMod));
+    return(hMod);
 }
 //******************************************************************************
@@ -1605,12 +1611,12 @@
     }
     if(szAppName[0] == '"') {
-     exename = &szAppName[1];
+        exename = &szAppName[1];
     }
     else exename = szAppName;
 
     if(GetFileAttributesA(exename) == -1) {
-    dprintf(("CreateProcess: can't find executable!"));
-    SetLastError(ERROR_FILE_NOT_FOUND);
-    return FALSE;
+        dprintf(("CreateProcess: can't find executable!"));
+        SetLastError(ERROR_FILE_NOT_FOUND);
+        return FALSE;
     }
     dprintf(("KERNEL32:  CreateProcess %s\n", cmdline));
@@ -1619,18 +1625,18 @@
     //     lpCurrentDirectory ourselves. (Open32 ignores it!)
     if(lpCurrentDirectory) {
-    char *newcmdline;
-
-    newcmdline = (char *)malloc(strlen(lpCurrentDirectory) + strlen(cmdline) + 32);
-    sprintf(newcmdline, "PE.EXE /OPT:[CURDIR=%s] %s", lpCurrentDirectory, cmdline);
-    free(cmdline);
-    cmdline = newcmdline;
+        char *newcmdline;
+
+        newcmdline = (char *)malloc(strlen(lpCurrentDirectory) + strlen(cmdline) + 32);
+        sprintf(newcmdline, "PE.EXE /OPT:[CURDIR=%s] %s", lpCurrentDirectory, cmdline);
+        free(cmdline);
+        cmdline = newcmdline;
     }
     else {
-    char *newcmdline;
-
-    newcmdline = (char *)malloc(strlen(cmdline) + 16);
-    sprintf(newcmdline, "PE.EXE %s", cmdline);
-    free(cmdline);
-    cmdline = newcmdline;
+        char *newcmdline;
+
+        newcmdline = (char *)malloc(strlen(cmdline) + 16);
+        sprintf(newcmdline, "PE.EXE %s", cmdline);
+        free(cmdline);
+        cmdline = newcmdline;
     }
     rc = O32_CreateProcess("PE.EXE", (LPCSTR)cmdline,lpProcessAttributes,
@@ -1828,57 +1834,29 @@
  Win32ImageBase *winimage;
  HINSTANCE hDll;
-
-  dprintf(("GetVersionStruct of module %s %x %d", lpszModName, verstruct, bufLength));
-  if(verstruct == NULL) {
-    SetLastError(ERROR_INVALID_PARAMETER);
-    return FALSE;
-  }
-  if(WinExe && !stricmp(WinExe->getFullPath(), lpszModName))
-  {
-        winimage = (Win32ImageBase *)WinExe;
-  }
-  else
-  {
-        winimage = (Win32ImageBase *)Win32DllBase::findModule(lpszModName);
-        if(winimage == NULL)
-        {
-          char modname[CCHMAXPATH];
-
-          strcpy(modname, lpszModName);
-          //rename dll if necessary (i.e. OLE32 -> OLE32OS2)
-          Win32DllBase::renameDll(modname);
-
-          if(Win32ImageBase::isPEImage(modname) != ERROR_SUCCESS)
-          {
-            HINSTANCE hInstance;
-
-              //must be an LX dll, just load it (app will probably load it anyway)
-              hInstance = LoadLibraryA(modname);
-              if(hInstance == 0)
-                  return 0;
-
-              winimage = (Win32ImageBase *)Win32DllBase::findModule(hInstance);
-              if(winimage) {
-                   return winimage->getVersionStruct(verstruct, bufLength);
-              }
-          dprintf(("GetVersionStruct; just loaded dll %s, but can't find it now!", modname));
-              return 0;
-          }
-          BOOL rc = FALSE;
-
-          hDll = LoadLibraryExA(lpszModName, 0, LOAD_LIBRARY_AS_DATAFILE);
-          if(hDll == 0)
-              return 0;
-
-          winimage = (Win32ImageBase *)Win32DllBase::findModule(lpszModName);
-          if(winimage != NULL) {
-            rc = winimage->getVersionStruct(verstruct, bufLength);
-      }
-          else  dprintf(("GetVersionSize; just loaded dll %s, but can't find it now!", lpszModName));
-      FreeLibrary(hDll);
-          return rc;
-        }
-  }
-  return winimage->getVersionStruct(verstruct, bufLength);
+ BOOL rc = FALSE;
+
+    dprintf(("GetVersionStruct of module %s %x %d", lpszModName, verstruct, bufLength));
+    if(verstruct == NULL) {
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return FALSE;
+    }
+    if (WinExe != NULL && WinExe->matchModName(lpszModName)) {
+        return WinExe->getVersionStruct(verstruct, bufLength);
+    }
+    hDll = LoadLibraryExA(lpszModName, 0, LOAD_LIBRARY_AS_DATAFILE);
+    if(hDll == 0) {
+        dprintf(("ERROR: GetVersionStruct: Unable to load module!!"));
+        return 0;
+    }
+    winimage = (Win32ImageBase *)Win32DllBase::findModule(hDll);
+    if(winimage != NULL) {
+        rc = winimage->getVersionStruct(verstruct, bufLength);
+    }
+    else {
+        dprintf(("GetVersionStruct; just loaded dll %s, but can't find it now!", lpszModName));
+        DebugInt3();
+    }
+    FreeLibrary(hDll);
+    return rc;
 }
 //******************************************************************************
@@ -1888,52 +1866,26 @@
  Win32ImageBase *winimage;
  HINSTANCE hDll;
-
-  dprintf(("GetVersionSize of %s\n", lpszModName));
-
-  if(WinExe && !stricmp(WinExe->getFullPath(), lpszModName)) {
-        winimage = (Win32ImageBase *)WinExe;
-  }
-  else {
-        winimage = (Win32ImageBase *)Win32DllBase::findModule(lpszModName);
-        if(winimage == NULL)
-        {
-          char modname[CCHMAXPATH];
-
-          strcpy(modname, lpszModName);
-          //rename dll if necessary (i.e. OLE32 -> OLE32OS2)
-          Win32DllBase::renameDll(modname);
-
-          if(Win32ImageBase::isPEImage(modname) != ERROR_SUCCESS)
-          {
-            HINSTANCE hInstance;
-
-            //must be an LX dll, just load it (app will probably load it anyway)
-            hInstance = LoadLibraryA(modname);
-            if(hInstance == 0)
-                return 0;
-
-            winimage = (Win32ImageBase *)Win32DllBase::findModule(hInstance);
-            if(winimage) {
-                return winimage->getVersionSize();
-            }
-        dprintf(("GetVersionSize; just loaded dll %s, but can't find it now!", modname));
-            return 0;
-        }
-        int size = 0;
-
-        hDll = LoadLibraryExA(lpszModName, 0, LOAD_LIBRARY_AS_DATAFILE);
-        if(hDll == 0)
-            return 0;
-
-        winimage = (Win32ImageBase *)Win32DllBase::findModule(lpszModName);
-        if(winimage != NULL) {
-            size = winimage->getVersionSize();
-    }
-        else    dprintf(("GetVersionSize; just loaded dll %s, but can't find it now!", lpszModName));
+ ULONG size = 0;
+
+    dprintf(("GetVersionSize of %s", lpszModName));
+    if (WinExe != NULL && WinExe->matchModName(lpszModName)) {
+        return WinExe->getVersionSize();
+    }
+
+    hDll = LoadLibraryExA(lpszModName, 0, LOAD_LIBRARY_AS_DATAFILE);
+    if(hDll == 0) {
+        dprintf(("ERROR: GetVersionStruct: Unable to load module!!"));
+        return 0;
+    }
+    winimage = (Win32ImageBase *)Win32DllBase::findModule(hDll);
+    if(winimage != NULL) {
+        size = winimage->getVersionSize();
+    }
+    else {
+        dprintf(("GetVersionSize; just loaded dll %s, but can't find it now!", lpszModName));
+        DebugInt3();
+    }
     FreeLibrary(hDll);
-        return size;
-      }
-  }
-  return winimage->getVersionSize();
+    return size;
 }
 //******************************************************************************
