Index: trunk/src/kernel32/Fileio.cpp
===================================================================
--- trunk/src/kernel32/Fileio.cpp	(revision 3641)
+++ trunk/src/kernel32/Fileio.cpp	(revision 3642)
@@ -1,3 +1,3 @@
-/* $Id: Fileio.cpp,v 1.33 2000-05-22 19:07:53 sandervl Exp $ */
+/* $Id: Fileio.cpp,v 1.34 2000-06-01 11:28:45 sandervl Exp $ */
 
 /*
@@ -234,8 +234,25 @@
 //******************************************************************************
 ODINFUNCTION2(INT, CompareFileTime,
-              FILETIME *, arg1,
-              FILETIME *, arg2)
-{
-  return O32_CompareFileTime(arg1, arg2);
+              FILETIME *, lpft1,
+              FILETIME *, lpft2)
+{
+   if (lpft1 == NULL || lpft2 == NULL) {
+	SetLastError(ERROR_INVALID_PARAMETER);
+	return -1;
+   }     
+
+   if(lpft1->dwHighDateTime > lpft2->dwHighDateTime)
+	return 1;
+
+   if(lpft1->dwHighDateTime < lpft2->dwHighDateTime)
+	return -1;
+
+   if(lpft1->dwLowDateTime > lpft2->dwLowDateTime)
+ 	return 1;
+
+   if(lpft1->dwLowDateTime < lpft2->dwLowDateTime)
+	return -1;
+
+   return 0; //equal
 }
 //******************************************************************************
@@ -288,5 +305,8 @@
  BOOL rc;
 
-  rc = O32_DeleteFile(lpszFile);
+#if 0
+  return 1;
+#else
+  rc = OSLibDosDelete((LPSTR)lpszFile);
   if(!rc) {
   	dprintf(("DeleteFileA %s returned FALSE; last error %x", lpszFile, GetLastError()));
@@ -298,4 +318,5 @@
 
   return rc;
+#endif
 }
 //******************************************************************************
@@ -382,20 +403,15 @@
 //******************************************************************************
 //******************************************************************************
-ODINFUNCTION4(DWORD, SetFilePointer,
-              HANDLE, hFile,
-              LONG, lDistanceToMove,
-              PLONG, lpDistanceToMoveHigh,
-              DWORD, dwMoveMethod)
-{
-  dprintf(("KERNEL32: SetFilePointer(%08xh,%08xh,%08xh,%08xh)\n",
-           hFile,
-           lDistanceToMove,
-           lpDistanceToMoveHigh,
-           dwMoveMethod));
-
-  return(HMSetFilePointer(hFile,
-                         lDistanceToMove,
-                         lpDistanceToMoveHigh,
-                         dwMoveMethod));
+ODINFUNCTION5(BOOL,         ReadFileEx, 
+              HANDLE,       hFile,
+              LPVOID,       lpBuffer,
+              DWORD,        nNumberOfBytesToRead,
+              LPOVERLAPPED, lpOverlapped,
+              LPOVERLAPPED_COMPLETION_ROUTINE,  lpCompletionRoutine)
+{
+  return (HMReadFileEx(hFile,
+                       lpBuffer,
+                       nNumberOfBytesToRead,
+                       lpOverlapped, lpCompletionRoutine));
 }
 //******************************************************************************
@@ -408,11 +424,4 @@
               LPOVERLAPPED, lpOverlapped)
 {
-  dprintf(("KERNEL32: WriteFile(%08xh,%08xh,%08xh,%08xh,%08xh)\n",
-           hFile,
-           buffer,
-           nrbytes,
-           nrbyteswritten,
-           lpOverlapped));
-
   return (HMWriteFile(hFile,
                       buffer,
@@ -420,4 +429,56 @@
                       nrbyteswritten,
                       lpOverlapped));
+}
+/*****************************************************************************
+ * Name      : BOOL WriteFileEx
+ * Purpose   : The WriteFileEx function writes data to a file. It is designed
+ *             solely for asynchronous operation, unlike WriteFile, which is
+ *             designed for both synchronous and asynchronous operation.
+ *             WriteFileEx reports its completion status asynchronously,
+ *             calling a specified completion routine when writing is completed
+ *             and the calling thread is in an alertable wait state.
+ * Parameters: HANDLE       hFile                handle of file to write
+ *             LPVOID       lpBuffer             address of buffer
+ *             DWORD        nNumberOfBytesToRead number of bytes to write
+ *             LPOVERLAPPED lpOverlapped         address of offset
+ *             LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine address of completion routine
+ * Variables :
+ * Result    : TRUE / FALSE
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Mon, 1998/06/15 08:00]
+ *****************************************************************************/
+
+ODINFUNCTION5(BOOL,         WriteFileEx, 
+              HANDLE,       hFile,
+              LPVOID,       lpBuffer,
+              DWORD,        nNumberOfBytesToWrite,
+              LPOVERLAPPED, lpOverlapped,
+              LPOVERLAPPED_COMPLETION_ROUTINE,  lpCompletionRoutine)
+{
+  return (HMWriteFileEx(hFile,
+                        lpBuffer,
+                        nNumberOfBytesToWrite,
+                        lpOverlapped, lpCompletionRoutine));
+}
+//******************************************************************************
+//******************************************************************************
+ODINFUNCTION4(DWORD, SetFilePointer,
+              HANDLE, hFile,
+              LONG, lDistanceToMove,
+              PLONG, lpDistanceToMoveHigh,
+              DWORD, dwMoveMethod)
+{
+  dprintf(("KERNEL32: SetFilePointer(%08xh,%08xh,%08xh,%08xh)\n",
+           hFile,
+           lDistanceToMove,
+           lpDistanceToMoveHigh,
+           dwMoveMethod));
+
+  return(HMSetFilePointer(hFile,
+                         lDistanceToMove,
+                         lpDistanceToMoveHigh,
+                         dwMoveMethod));
 }
 //******************************************************************************
@@ -751,9 +812,8 @@
            lpOverlapped));
 
-  return(HMUnlockFile(hFile,
-                      lpOverlapped->Offset,
-                      lpOverlapped->OffsetHigh,
-                      nNumberOfBytesToLockLow,
-                      nNumberOfBytesToLockHigh));
+  return(HMUnlockFileEx(hFile, dwReserved,
+                        nNumberOfBytesToLockLow,
+                        nNumberOfBytesToLockHigh,
+                        lpOverlapped));
 }
 //******************************************************************************
Index: trunk/src/kernel32/HandleManager.cpp
===================================================================
--- trunk/src/kernel32/HandleManager.cpp	(revision 3641)
+++ trunk/src/kernel32/HandleManager.cpp	(revision 3642)
@@ -1,3 +1,3 @@
-/* $Id: HandleManager.cpp,v 1.39 2000-05-22 19:07:52 sandervl Exp $ */
+/* $Id: HandleManager.cpp,v 1.40 2000-06-01 11:28:42 sandervl Exp $ */
 
 /*
@@ -52,4 +52,5 @@
 #include "HMOpen32.h"
 #include "HMEvent.h"
+#include "HMFile.h"
 #include "HMMutex.h"
 #include "HMSemaphore.h"
@@ -125,4 +126,5 @@
   HMDeviceHandler        *pHMOpen32;      /* default handle manager instance */
   HMDeviceHandler        *pHMEvent;        /* static instances of subsystems */
+  HMDeviceHandler        *pHMFile;
   HMDeviceHandler        *pHMMutex;
   HMDeviceHandler        *pHMSemaphore;
@@ -354,4 +356,5 @@
     HMGlobals.pHMOpen32     = new HMDeviceOpen32Class("\\\\.\\");
     HMGlobals.pHMEvent      = new HMDeviceEventClass("\\\\EVENT\\");
+    HMGlobals.pHMFile       = new HMDeviceFileClass("\\\\FILE\\");
     HMGlobals.pHMMutex      = new HMDeviceMutexClass("\\\\MUTEX\\");
     HMGlobals.pHMSemaphore  = new HMDeviceSemaphoreClass("\\\\SEM\\");
@@ -383,4 +386,5 @@
   delete HMGlobals.pHMOpen32;
   delete HMGlobals.pHMEvent;
+  delete HMGlobals.pHMFile;
   delete HMGlobals.pHMMutex;
   delete HMGlobals.pHMSemaphore;
@@ -706,5 +710,5 @@
   HMDeviceHandler *pDeviceHandler;         /* device handler for this handle */
   PHMHANDLEDATA   pHMHandleData;
-  DWORD           rc;                                     /* API return code */
+  BOOL            rc;                                     /* API return code */
 
   if(HMHandleValidate(srchandle) != NO_ERROR)
@@ -758,8 +762,7 @@
     HMCloseHandle(srchandle);
 
-  if (rc != NO_ERROR)     /* oops, creation failed within the device handler */
+  if(rc == FALSE)     /* oops, creation failed within the device handler */
   {
     TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = INVALID_HANDLE_VALUE;
-    SetLastError(rc);          /* Hehe, OS/2 and NT are pretty compatible :) */
     return FALSE;                           /* signal error */
   }
@@ -827,4 +830,8 @@
     else
       pHMHandleData  = NULL;
+
+    if(pDeviceHandler == HMGlobals.pHMOpen32) {
+	pDeviceHandler = HMGlobals.pHMFile;
+    }
   }
 
@@ -962,4 +969,7 @@
     pHMHandleData  = NULL;
 
+  if(pDeviceHandler == HMGlobals.pHMOpen32) {
+    pDeviceHandler = HMGlobals.pHMFile;
+  }
 
   iIndexNew = _HMHandleGetFree();                         /* get free handle */
@@ -1003,12 +1013,25 @@
 #endif
 
-  if (rc != NO_ERROR)     /* oops, creation failed within the device handler */
-  {
-    TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = INVALID_HANDLE_VALUE;
-    SetLastError(rc);          /* Hehe, OS/2 and NT are pretty compatible :) */
-    return (INVALID_HANDLE_VALUE);                           /* signal error */
-  }
-  else
-    SetLastError(ERROR_SUCCESS); //@@@PH 1999/10/27 rc5desg requires this?
+  if(rc != NO_ERROR)     /* oops, creation failed within the device handler */
+  {
+    	TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = INVALID_HANDLE_VALUE;
+    	SetLastError(rc);          /* Hehe, OS/2 and NT are pretty compatible :) */
+    	return (INVALID_HANDLE_VALUE);                           /* signal error */
+  }
+  else {
+  	if(fuMode & (OF_DELETE|OF_EXIST)) {
+		//file handle already closed
+    		TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = INVALID_HANDLE_VALUE;
+		return TRUE; //TODO: correct?
+	}
+	if(fuMode & OF_PARSE) {
+    		TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = INVALID_HANDLE_VALUE;
+		return 0;
+	}
+	if(fuMode & OF_VERIFY) {
+    		TabWin32Handles[iIndexNew].hmHandleData.hHMHandle = INVALID_HANDLE_VALUE;
+		return 1; //TODO: correct?
+	}
+  }
 
 #ifdef DEBUG_LOCAL
@@ -1119,5 +1142,42 @@
   return (fResult);                                   /* deliver return code */
 }
-
+/*****************************************************************************
+ * Name      : HANDLE  HMReadFileEx
+ * Purpose   : Wrapper for the ReadFileEx() API
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    :
+ *
+ * Author    : SvL
+ *****************************************************************************/
+BOOL HMReadFileEx(HANDLE                     hFile,
+                  LPVOID                     lpBuffer,
+                  DWORD                      nNumberOfBytesToRead,
+                  LPOVERLAPPED               lpOverlapped,
+                  LPOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine)
+{
+  int       iIndex;                           /* index into the handle table */
+  BOOL      fResult;       /* result from the device handler's CloseHandle() */
+  PHMHANDLE pHMHandle;       /* pointer to the handle structure in the table */
+
+                                                          /* validate handle */
+  iIndex = _HMHandleQuery(hFile);                           /* get the index */
+  if (-1 == iIndex)                                               /* error ? */
+  {
+    SetLastError(ERROR_INVALID_HANDLE);       /* set win32 error information */
+    return (FALSE);                                        /* signal failure */
+  }
+
+  pHMHandle = &TabWin32Handles[iIndex];               /* call device handler */
+  fResult = pHMHandle->pDeviceHandler->ReadFileEx(&pHMHandle->hmHandleData,
+                                                  lpBuffer,
+                                                  nNumberOfBytesToRead,
+                                                  lpOverlapped,
+                                                  lpCompletionRoutine);
+
+  return (fResult);                                   /* deliver return code */
+}
 
 /*****************************************************************************
@@ -1134,8 +1194,8 @@
 
 BOOL HMWriteFile(HANDLE       hFile,
-                        LPCVOID      lpBuffer,
-                        DWORD        nNumberOfBytesToWrite,
-                        LPDWORD      lpNumberOfBytesWritten,
-                        LPOVERLAPPED lpOverlapped)
+                 LPCVOID      lpBuffer,
+                 DWORD        nNumberOfBytesToWrite,
+                 LPDWORD      lpNumberOfBytesWritten,
+                 LPOVERLAPPED lpOverlapped)
 {
   int       iIndex;                           /* index into the handle table */
@@ -1157,4 +1217,43 @@
                                                  lpNumberOfBytesWritten,
                                                  lpOverlapped);
+
+  return (fResult);                                   /* deliver return code */
+}
+
+/*****************************************************************************
+ * Name      : HANDLE  HMWriteFileEx
+ * Purpose   : Wrapper for the WriteFileEx() API
+ * Parameters:
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    :
+ *
+ * Author    : SvL
+ *****************************************************************************/
+BOOL HMWriteFileEx(HANDLE                     hFile,
+                   LPVOID                     lpBuffer,
+                   DWORD                      nNumberOfBytesToWrite,
+                   LPOVERLAPPED               lpOverlapped,
+                   LPOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine)
+{
+  int       iIndex;                           /* index into the handle table */
+  BOOL      fResult;       /* result from the device handler's CloseHandle() */
+  PHMHANDLE pHMHandle;       /* pointer to the handle structure in the table */
+
+                                                          /* validate handle */
+  iIndex = _HMHandleQuery(hFile);                           /* get the index */
+  if (-1 == iIndex)                                               /* error ? */
+  {
+    SetLastError(ERROR_INVALID_HANDLE);       /* set win32 error information */
+    return (FALSE);                                        /* signal failure */
+  }
+
+  pHMHandle = &TabWin32Handles[iIndex];               /* call device handler */
+  fResult = pHMHandle->pDeviceHandler->WriteFileEx(&pHMHandle->hmHandleData,
+                                                   lpBuffer,
+                                                   nNumberOfBytesToWrite,
+                                                   lpOverlapped,
+                                                   lpCompletionRoutine);
 
   return (fResult);                                   /* deliver return code */
@@ -1598,5 +1697,4 @@
 
 BOOL HMUnlockFileEx(HANDLE        hFile,
-                    DWORD         dwFlags,
                     DWORD         dwReserved,
                     DWORD         nNumberOfBytesToLockLow,
@@ -1618,5 +1716,4 @@
   pHMHandle = &TabWin32Handles[iIndex];               /* call device handler */
   dwResult = pHMHandle->pDeviceHandler->UnlockFileEx(&pHMHandle->hmHandleData,
-                                                     dwFlags,
                                                      dwReserved,
                                                      nNumberOfBytesToLockLow,
Index: trunk/src/kernel32/async.cpp
===================================================================
--- trunk/src/kernel32/async.cpp	(revision 3641)
+++ trunk/src/kernel32/async.cpp	(revision 3642)
@@ -1,3 +1,3 @@
-/* $Id: async.cpp,v 1.7 2000-02-16 14:25:30 sandervl Exp $ */
+/* $Id: async.cpp,v 1.8 2000-06-01 11:28:44 sandervl Exp $ */
 
 /*
@@ -114,86 +114,3 @@
 }
 
-
-/*****************************************************************************
- * Name      : BOOL ReadFileEx
- * Purpose   : The ReadFileEx function reads data from a file asynchronously.
- *             It is designed solely for asynchronous operation, unlike the
- *             ReadFile function, which is designed for both synchronous and
- *             asynchronous operation. ReadFileEx lets an application perform
- *             other processing during a file read operation.
- *             The ReadFileEx function reports its completion status asynchronously,
- *             calling a specified completion routine when reading is completed
- *             and the calling thread is in an alertable wait state.
- * Parameters: HANDLE       hFile                handle of file to read
- *             LPVOID       lpBuffer             address of buffer
- *             DWORD        nNumberOfBytesToRead number of bytes to read
- *             LPOVERLAPPED lpOverlapped         address of offset
- *             LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine address of completion routine
- * Variables :
- * Result    : TRUE / FALSE
- * Remark    :
- * Status    : UNTESTED STUB
- *
- * Author    : Patrick Haller [Mon, 1998/06/15 08:00]
- *****************************************************************************/
-
-#define LPOVERLAPPED_COMPLETION_ROUTINE LPVOID
-
-DWORD WIN32API ReadFileEx(HANDLE       hFile,
-                             LPVOID       lpBuffer,
-                             DWORD        nNumberOfBytesToRead,
-                             LPOVERLAPPED lpOverlapped,
-                             LPOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine)
-{
-  dprintf(("Kernel32: ReadFileEx(%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
-           hFile,
-           lpBuffer,
-           nNumberOfBytesToRead,
-           lpOverlapped,
-           lpCompletionRoutine));
-
-
-  return (FALSE);
-}
-
-
-/*****************************************************************************
- * Name      : BOOL WriteFileEx
- * Purpose   : The WriteFileEx function writes data to a file. It is designed
- *             solely for asynchronous operation, unlike WriteFile, which is
- *             designed for both synchronous and asynchronous operation.
- *             WriteFileEx reports its completion status asynchronously,
- *             calling a specified completion routine when writing is completed
- *             and the calling thread is in an alertable wait state.
- * Parameters: HANDLE       hFile                handle of file to write
- *             LPVOID       lpBuffer             address of buffer
- *             DWORD        nNumberOfBytesToRead number of bytes to write
- *             LPOVERLAPPED lpOverlapped         address of offset
- *             LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine address of completion routine
- * Variables :
- * Result    : TRUE / FALSE
- * Remark    :
- * Status    : UNTESTED STUB
- *
- * Author    : Patrick Haller [Mon, 1998/06/15 08:00]
- *****************************************************************************/
-
-DWORD WIN32API WriteFileEx(HANDLE       hFile,
-                              LPVOID       lpBuffer,
-                              DWORD        nNumberOfBytesToWrite,
-                              LPOVERLAPPED lpOverlapped,
-                              LPOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine)
-{
-  dprintf(("Kernel32: WriteFileEx(%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
-           hFile,
-           lpBuffer,
-           nNumberOfBytesToWrite,
-           lpOverlapped,
-           lpCompletionRoutine));
-
-
-  return (FALSE);
-}
-
-
 #endif /* _ASYNCIOSUBSYSTEM_H_ */
Index: trunk/src/kernel32/dbglocal.cpp
===================================================================
--- trunk/src/kernel32/dbglocal.cpp	(revision 3641)
+++ trunk/src/kernel32/dbglocal.cpp	(revision 3642)
@@ -1,3 +1,3 @@
-/* $Id: dbglocal.cpp,v 1.7 2000-05-02 20:53:11 sandervl Exp $ */
+/* $Id: dbglocal.cpp,v 1.8 2000-06-01 11:28:44 sandervl Exp $ */
 
 /*
@@ -118,5 +118,6 @@
 "hmprocess",
 "vsemaphore",
-"exceptstackdump"
+"exceptstackdump",
+"hmfile"
 };
 //******************************************************************************
Index: trunk/src/kernel32/dbglocal.h
===================================================================
--- trunk/src/kernel32/dbglocal.h	(revision 3641)
+++ trunk/src/kernel32/dbglocal.h	(revision 3642)
@@ -1,3 +1,3 @@
-/* $Id: dbglocal.h,v 1.7 2000-05-02 20:53:12 sandervl Exp $ */
+/* $Id: dbglocal.h,v 1.8 2000-06-01 11:28:44 sandervl Exp $ */
 
 /*
@@ -118,5 +118,6 @@
 #define DBG_VSemaphore     96
 #define DBG_exceptstackdump 97
-#define DBG_MAXFILES       98
+#define DBG_hmfile         98
+#define DBG_MAXFILES       99
 
 extern USHORT DbgEnabled[DBG_MAXFILES];
Index: trunk/src/kernel32/directory.cpp
===================================================================
--- trunk/src/kernel32/directory.cpp	(revision 3641)
+++ trunk/src/kernel32/directory.cpp	(revision 3642)
@@ -1,3 +1,3 @@
-/* $Id: directory.cpp,v 1.22 2000-05-28 16:45:12 sandervl Exp $ */
+/* $Id: directory.cpp,v 1.23 2000-06-01 11:28:44 sandervl Exp $ */
 
 /*
@@ -159,6 +159,9 @@
 
   strcpy(tmp, lpPathName);
-  //SvL: Don't remove terminating backslash if it wants to chdir to root dir
-  if(tmp[len -1] == '\\' && len != 1)
+  if(tmp[len - 1] == '/') {
+	tmp[len-1] = '\\';
+  }
+  //SvL: Don't remove trailing backslash if it wants to chdir to root dir
+  if((tmp[len - 1] == '\\')  && len != 1)
     tmp[len -1] = 0;
 
Index: trunk/src/kernel32/hmdevice.cpp
===================================================================
--- trunk/src/kernel32/hmdevice.cpp	(revision 3641)
+++ trunk/src/kernel32/hmdevice.cpp	(revision 3642)
@@ -1,3 +1,3 @@
-/* $Id: hmdevice.cpp,v 1.19 2000-05-22 19:07:54 sandervl Exp $ */
+/* $Id: hmdevice.cpp,v 1.20 2000-06-01 11:28:45 sandervl Exp $ */
 
 /*
@@ -126,5 +126,5 @@
            srcprocess, pHMSrcHandle, destprocess, desthandle));
 
-  return(ERROR_INVALID_FUNCTION);
+  return FALSE;
 }
 
@@ -208,5 +208,5 @@
   dprintf(("KERNEL32:HandleManager::ReadFile %s(%08x,%08x,%08x,%08x,%08x) - stub?\n",
            lpHMDeviceName,
-           pHMHandleData,
+           pHMHandleData->hHMHandle,
            lpBuffer,
            nNumberOfBytesToRead,
@@ -218,4 +218,43 @@
 }
 
+/*****************************************************************************
+ * Name      : BOOL ReadFileEx
+ * Purpose   : The ReadFileEx function reads data from a file asynchronously.
+ *             It is designed solely for asynchronous operation, unlike the
+ *             ReadFile function, which is designed for both synchronous and
+ *             asynchronous operation. ReadFileEx lets an application perform
+ *             other processing during a file read operation.
+ *             The ReadFileEx function reports its completion status asynchronously,
+ *             calling a specified completion routine when reading is completed
+ *             and the calling thread is in an alertable wait state.
+ * Parameters: HANDLE       hFile                handle of file to read
+ *             LPVOID       lpBuffer             address of buffer
+ *             DWORD        nNumberOfBytesToRead number of bytes to read
+ *             LPOVERLAPPED lpOverlapped         address of offset
+ *             LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine address of completion routine
+ * Variables :
+ * Result    : TRUE / FALSE
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Mon, 1998/06/15 08:00]
+ *****************************************************************************/
+BOOL HMDeviceHandler::ReadFileEx(PHMHANDLEDATA pHMHandleData,
+                           LPVOID       lpBuffer,
+                           DWORD        nNumberOfBytesToRead,
+                           LPOVERLAPPED lpOverlapped,
+                           LPOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine)
+{
+  dprintf(("ERROR: ReadFileEx %s (%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
+           lpHMDeviceName,
+           pHMHandleData->hHMHandle,
+           lpBuffer,
+           nNumberOfBytesToRead,
+           lpOverlapped,
+           lpCompletionRoutine));
+
+  SetLastError(ERROR_INVALID_FUNCTION);
+  return FALSE;
+}
 
 /*****************************************************************************
@@ -243,5 +282,5 @@
   dprintf(("KERNEL32:HandleManager::WriteFile %s(%08x,%08x,%08x,%08x,%08x) - stub?\n",
            lpHMDeviceName,
-           pHMHandleData,
+           pHMHandleData->hHMHandle,
            lpBuffer,
            nNumberOfBytesToWrite,
@@ -253,4 +292,43 @@
 }
 
+
+/*****************************************************************************
+ * Name      : BOOL WriteFileEx
+ * Purpose   : The WriteFileEx function writes data to a file. It is designed
+ *             solely for asynchronous operation, unlike WriteFile, which is
+ *             designed for both synchronous and asynchronous operation.
+ *             WriteFileEx reports its completion status asynchronously,
+ *             calling a specified completion routine when writing is completed
+ *             and the calling thread is in an alertable wait state.
+ * Parameters: HANDLE       hFile                handle of file to write
+ *             LPVOID       lpBuffer             address of buffer
+ *             DWORD        nNumberOfBytesToRead number of bytes to write
+ *             LPOVERLAPPED lpOverlapped         address of offset
+ *             LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine address of completion routine
+ * Variables :
+ * Result    : TRUE / FALSE
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Mon, 1998/06/15 08:00]
+ *****************************************************************************/
+
+BOOL HMDeviceHandler::WriteFileEx(PHMHANDLEDATA pHMHandleData,
+                           LPVOID       lpBuffer,
+                           DWORD        nNumberOfBytesToWrite,
+                           LPOVERLAPPED lpOverlapped,
+                           LPOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine)
+{
+  dprintf(("ERROR: WriteFileEx %s (%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
+           lpHMDeviceName,
+           pHMHandleData->hHMHandle,
+           lpBuffer,
+           nNumberOfBytesToWrite,
+           lpOverlapped,
+           lpCompletionRoutine));
+
+  SetLastError(ERROR_INVALID_FUNCTION);
+  return FALSE;
+}
 
 /*****************************************************************************
@@ -579,5 +657,4 @@
  * Purpose   : file locking
  * Parameters: PHMHANDLEDATA pHMHandleData
- *             DWORD dwFlags
  *             DWORD dwReserved
  *             DWORD nNumberOfBytesToLockLow
@@ -593,5 +670,4 @@
 
 DWORD HMDeviceHandler::UnlockFileEx(PHMHANDLEDATA pHMHandleData,
-                                        DWORD         dwFlags,
                                         DWORD         dwReserved,
                                         DWORD         nNumberOfBytesToLockLow,
@@ -599,8 +675,7 @@
                                         LPOVERLAPPED  lpOverlapped)
 {
-  dprintf(("KERNEL32: HandleManager::DeviceHandler::UnlockFileEx %s(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh)\n",
-           lpHMDeviceName,
-           pHMHandleData,
-           dwFlags,
+  dprintf(("KERNEL32: HandleManager::DeviceHandler::UnlockFileEx %s,%08xh,%08xh,%08xh,%08xh,%08xh)\n",
+           lpHMDeviceName,
+           pHMHandleData,
            dwReserved,
            nNumberOfBytesToLockLow,
Index: trunk/src/kernel32/hmdevice.h
===================================================================
--- trunk/src/kernel32/hmdevice.h	(revision 3641)
+++ trunk/src/kernel32/hmdevice.h	(revision 3642)
@@ -1,3 +1,3 @@
-/* $Id: hmdevice.h,v 1.18 2000-05-22 19:07:55 sandervl Exp $ */
+/* $Id: hmdevice.h,v 1.19 2000-06-01 11:28:46 sandervl Exp $ */
 
 /*
@@ -112,4 +112,11 @@
                              LPOVERLAPPED  lpOverlapped);
 
+                        /* this is a handler method for calls to ReadFileEx() */
+  virtual BOOL  ReadFileEx(PHMHANDLEDATA pHMHandleData,
+                           LPVOID       lpBuffer,
+                           DWORD        nNumberOfBytesToRead,
+                           LPOVERLAPPED lpOverlapped,
+                           LPOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine);
+
                         /* this is a handler method for calls to WriteFile() */
   virtual BOOL   WriteFile  (PHMHANDLEDATA pHMHandleData,
@@ -118,4 +125,11 @@
                              LPDWORD       lpNumberOfBytesWritten,
                              LPOVERLAPPED  lpOverlapped);
+
+                        /* this is a handler method for calls to WriteFileEx() */
+  virtual BOOL  WriteFileEx(PHMHANDLEDATA pHMHandleData,
+                            LPVOID       lpBuffer,
+                            DWORD        nNumberOfBytesToWrite,
+                            LPOVERLAPPED lpOverlapped,
+                            LPOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine);
 
                       /* this is a handler method for calls to GetFileType() */
@@ -185,5 +199,4 @@
                      /* this is a handler method for calls to UnlockFileEx() */
   virtual DWORD UnlockFileEx(PHMHANDLEDATA pHMHandleData,
-                             DWORD         dwFlags,
                              DWORD         dwReserved,
                              DWORD         nNumberOfBytesToLockLow,
Index: trunk/src/kernel32/hmfile.cpp
===================================================================
--- trunk/src/kernel32/hmfile.cpp	(revision 3642)
+++ trunk/src/kernel32/hmfile.cpp	(revision 3642)
@@ -0,0 +1,1047 @@
+/* $Id: hmfile.cpp,v 1.1 2000-06-01 11:28:46 sandervl Exp $ */
+
+/*
+ * File IO win32 apis
+ *
+ * Copyright 1999-2000 Sander van Leeuwen
+ *
+ * Project Odin Software License can be found in LICENSE.TXT
+ *
+ */
+
+/*****************************************************************************
+ * Remark                                                                    *
+ *****************************************************************************
+ */
+
+//#define DEBUG_LOCAL
+
+#ifdef DEBUG_LOCAL
+#  define dprintfl(a) dprintf(a)
+#else
+inline void ignore_dprintf(...){}
+#  define dprintfl(a) ignore_dprintf(a)
+#endif
+
+/*****************************************************************************
+ * Includes                                                                  *
+ *****************************************************************************/
+
+#include <os2win.h>
+#include <string.h>
+#include "HandleManager.h"
+#include "HMFile.h"
+#include "mmap.h"
+#include "oslibdos.h"
+
+#define DBG_LOCALLOG	DBG_hmfile
+#include "dbglocal.h"
+
+/*****************************************************************************
+ * Name      : DWORD HMDeviceFileClass::CreateFile
+ * Purpose   : this is called from the handle manager if a CreateFile() is
+ *             performed on a handle
+ * Parameters: LPCSTR        lpFileName            name of the file / device
+ *             PHMHANDLEDATA pHMHandleData         data of the NEW handle
+ *             PVOID         lpSecurityAttributes  ignored
+ *             PHMHANDLEDATA pHMHandleDataTemplate data of the template handle
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : NO_ERROR - API succeeded
+ *             other    - what is to be set in SetLastError
+ *
+ * Author    : Patrick Haller [Wed, 1998/02/11 20:44]
+ *****************************************************************************/
+
+DWORD HMDeviceFileClass::CreateFile (LPCSTR        lpFileName,
+                                     PHMHANDLEDATA pHMHandleData,
+                                     PVOID         lpSecurityAttributes,
+                                     PHMHANDLEDATA pHMHandleDataTemplate)
+{
+  HFILE hFile;
+  HFILE hTemplate;
+
+  dprintfl(("KERNEL32: HMDeviceFileClass::CreateFile %s(%s,%08x,%08x,%08x)\n",
+           lpHMDeviceName,
+           lpFileName,
+           pHMHandleData,
+           lpSecurityAttributes,
+           pHMHandleDataTemplate));
+
+  if (strncmp(lpFileName,       // "support" for local unc names
+              "\\\\.\\",
+              4) == 0) 
+  {
+  	lpFileName+=4;
+  }
+
+  // create from template
+  if (pHMHandleDataTemplate != NULL)
+     hTemplate = pHMHandleDataTemplate->hHMHandle;
+  else
+     hTemplate = 0;
+
+  //SvL: Open32 doesn't like this flag
+  if(pHMHandleData->dwShare & FILE_SHARE_DELETE) {
+	pHMHandleData->dwShare &= ~FILE_SHARE_DELETE;
+  }
+
+  hFile = OSLibDosCreateFile((LPSTR)lpFileName,
+                             pHMHandleData->dwAccess,
+                             pHMHandleData->dwShare,
+                             (LPSECURITY_ATTRIBUTES)lpSecurityAttributes,
+                             pHMHandleData->dwCreation,
+                             pHMHandleData->dwFlags,
+                             hTemplate);
+  if (hFile != INVALID_HANDLE_ERROR)
+  {
+	pHMHandleData->dwUserData = (DWORD) new HMFileInfo((LPSTR)lpFileName, lpSecurityAttributes);
+     	pHMHandleData->hHMHandle  = hFile;
+     	return (NO_ERROR);
+  }
+  else {
+	dprintf(("CreateFile failed; error %d", GetLastError()));
+    	return(GetLastError());
+  }
+}
+
+/*****************************************************************************
+ * Name      : DWORD HMDeviceFileClass::OpenFile
+ * Purpose   : this is called from the handle manager if a OpenFile() is
+ *             performed on a handle
+ * Parameters: LPCSTR        lpFileName            name of the file / device
+ *             PHMHANDLEDATA pHMHandleData         data of the NEW handle
+ *             PVOID         lpSecurityAttributes  ignored
+ *             PHMHANDLEDATA pHMHandleDataTemplate data of the template handle
+ * Variables :
+ * Result    :
+ * Remark    : TODO: Check if this implementation is complete and 100% correct
+ * Status    : NO_ERROR - API succeeded
+ *             other    - what is to be set in SetLastError
+ *
+ * Author    : Patrick Haller [Wed, 1998/02/11 20:44]
+ *****************************************************************************/
+
+DWORD HMDeviceFileClass::OpenFile (LPCSTR        lpszFileName,
+                                   PHMHANDLEDATA pHMHandleData,
+                                   OFSTRUCT      *pOFStruct,
+                                   UINT          fuMode)
+{
+  HFILE hFile;
+  FILETIME filetime;
+  WORD filedatetime[2];
+  char filepath[260];
+  LPSTR lpFileName = (LPSTR)lpszFileName;
+
+  SetLastError(ERROR_SUCCESS);
+
+  dprintf(("KERNEL32: HMDeviceFileClass::OpenFile %s(%s,%08x,%08x,%08x) - stub?\n",
+           lpHMDeviceName,
+           lpFileName,
+           pHMHandleData,
+           pOFStruct,
+           fuMode));
+
+  //Re-open using name in OFSTRUCT
+  if(fuMode & OF_REOPEN) lpFileName = (LPSTR)pOFStruct->szPathName;
+
+  if(strcmp(lpFileName,       // "support" for local unc names
+             "\\\\.\\") == 0)
+  {
+    	lpFileName+=4;
+  }
+  else 
+  if(!strchr(lpFileName, ':') && !strchr(lpFileName, '\\')) 
+  {
+	//filename only; search for file in following order
+	//1: dir from which the app loaded
+	//2: current dir
+	//3: windows system dir
+	//4: windows dir
+	//5: dirs in path path environment variable
+	//SearchPath does exactly that
+	LPSTR filenameinpath;
+
+	if(SearchPathA(NULL, lpFileName, NULL, sizeof(filepath), filepath, &filenameinpath) == 0
+           && !(fuMode & OF_CREATE) ) {
+		SetLastError(ERROR_FILE_NOT_FOUND);
+		return HFILE_ERROR;
+	}
+	lpFileName = filepath;
+  }
+  // filling OFSTRUCT
+  memset(pOFStruct, 0, sizeof(OFSTRUCT));
+  pOFStruct->cBytes = sizeof(OFSTRUCT);
+  pOFStruct->nErrCode = 0;
+  strncpy((char *)pOFStruct->szPathName, lpFileName, OFS_MAXPATHNAME - 1);
+
+  hFile = OSLibDosOpenFile((LPSTR)lpFileName, fuMode);
+
+  if(hFile != INVALID_HANDLE_ERROR)
+  {
+    	GetFileTime(pHMHandleData,
+                    NULL,
+                    NULL,
+                    &filetime );
+    	FileTimeToDosDateTime(&filetime,
+                              &filedatetime[0],
+                              &filedatetime[1] );
+    	memcpy(pOFStruct->reserved, filedatetime, sizeof(pOFStruct->reserved));
+
+  	if(fuMode & OF_DELETE)
+  	{
+       		OSLibDosClose(hFile);
+	        OSLibDosDelete((LPSTR)lpFileName);
+  	}
+  	else 
+	if(fuMode & OF_EXIST)
+  	{
+       		OSLibDosClose(hFile);
+		hFile = HFILE_ERROR;
+  	}
+   	if(fuMode & OF_PARSE) 
+	{
+	  CHAR drive[4];
+
+		drive[0] = pOFStruct->szPathName[0];
+		drive[1] = pOFStruct->szPathName[1];
+		drive[2] = pOFStruct->szPathName[2];
+		drive[3] = 0;
+
+        	pOFStruct->fFixedDisk = (GetDriveTypeA(drive) != DRIVE_REMOVABLE);
+		
+      		OSLibDosClose(hFile);
+		hFile = HFILE_ERROR;
+   	}
+
+       	if((fuMode & OF_VERIFY))
+       	{
+        	if(memcmp(pOFStruct->reserved, filedatetime, sizeof(pOFStruct->reserved)))
+        	{
+            		OSLibDosClose(hFile);
+            		SetLastError(ERROR_FILE_NOT_FOUND);
+        	}
+		hFile = HFILE_ERROR;
+    	}
+
+  	pOFStruct->nErrCode = GetLastError();
+    	pHMHandleData->hHMHandle = hFile;
+
+        if(hFile != HFILE_ERROR) {
+		pHMHandleData->dwUserData = (DWORD) new HMFileInfo((LPSTR)lpFileName, NULL);
+	}
+    	return (NO_ERROR);
+  }
+  else {
+	DWORD rc = GetLastError();
+
+       	if(fuMode & OF_EXIST)
+       	{
+          	if(rc == ERROR_OPEN_FAILED) {
+			SetLastError(ERROR_FILE_NOT_FOUND);
+		}
+	}
+	//todo: OF_PROMPT handling (pop up message box)
+  }
+  // error branch
+  pOFStruct->nErrCode = GetLastError();
+  dprintf(("KERNEL32: HMDeviceFileClass::OpenFile Error %08xh\n",
+            pOFStruct->nErrCode));
+
+  // return != NO_ERROR => error code
+  return(hFile);
+}
+
+/*****************************************************************************
+ * Name      : HMDeviceFileClass::DuplicateHandle
+ * Purpose   : 
+ * Parameters: 
+ *             various parameters as required
+ * Variables :
+ * Result    :
+ * Remark    : DUPLICATE_CLOSE_SOURCE flag handled in HMDuplicateHandle
+ *             
+ * Status    : partially implemented
+ *
+ * Author    : SvL
+ *****************************************************************************/
+BOOL HMDeviceFileClass::DuplicateHandle(PHMHANDLEDATA pHMHandleData, HANDLE  srcprocess,
+                               PHMHANDLEDATA pHMSrcHandle,
+                               HANDLE  destprocess,
+                               PHANDLE desthandle,
+                       	       DWORD   fdwAccess,
+                       	       BOOL    fInherit,
+                               DWORD   fdwOptions)
+{
+ HMFileInfo *srcfileinfo = (HMFileInfo *)pHMSrcHandle->dwUserData;
+ BOOL rc;
+
+  dprintf(("KERNEL32:HMDeviceFileClass::DuplicateHandle (%08x,%08x,%08x,%08x,%08x)",
+           pHMHandleData,
+           srcprocess, pHMSrcHandle->hHMHandle, destprocess, desthandle));
+
+  //TODO: Inheritance of file handles won't work!
+
+  if(destprocess != srcprocess) {
+	//TODO:!!!!
+	dprintf(("ERROR: DuplicateHandle; different processes not yet supported!!"));
+	return FALSE;
+  }
+
+  if(srcfileinfo) {
+	if(CreateFile(srcfileinfo->lpszFileName, pHMHandleData,
+                      srcfileinfo->lpSecurityAttributes, NULL) == NO_ERROR) {
+		return TRUE;
+	}
+	dprintf(("ERROR: DuplicateHandle; CreateFile %s failed!", srcfileinfo->lpszFileName));
+	return FALSE;
+  }
+  else {
+	SetLastError(ERROR_INVALID_PARAMETER);
+	return FALSE;
+  }
+}
+
+/*****************************************************************************
+ * Name      : DWORD HMDeviceFileClass::CloseHandle
+ * Purpose   : close the handle
+ * Parameters: PHMHANDLEDATA pHMHandleData
+ * Variables :
+ * Result    : API returncode
+ * Remark    :
+ * Status    :
+ *
+ * Author    : Patrick Haller [Wed, 1998/02/11 20:44]
+ *****************************************************************************/
+
+DWORD HMDeviceFileClass::CloseHandle(PHMHANDLEDATA pHMHandleData)
+{
+  HMFileInfo *fileInfo = (HMFileInfo *)pHMHandleData->dwUserData;
+  BOOL        bRC;
+
+  dprintfl(("KERNEL32: HMDeviceFileClass::CloseHandle(%08x)\n",
+           pHMHandleData->hHMHandle));
+
+  bRC = OSLibDosClose(pHMHandleData->hHMHandle);
+
+  if(pHMHandleData->dwFlags & FILE_FLAG_DELETE_ON_CLOSE) {
+	//TODO: should only do this after all handles have been closed
+	if(fileInfo) {
+		DeleteFileA(fileInfo->lpszFileName);
+	}        
+  }
+  if(fileInfo) {
+	delete fileInfo;
+  }
+  dprintf(("KERNEL32: HMDeviceFileClass::CloseHandle returned %08xh\n",
+           bRC));
+
+  return (DWORD)bRC;
+}
+
+
+/*****************************************************************************
+ * Name      : BOOL HMDeviceFileClass::ReadFile
+ * Purpose   : read data from handle / device
+ * Parameters: PHMHANDLEDATA pHMHandleData,
+ *             LPCVOID       lpBuffer,
+ *             DWORD         nNumberOfBytesToRead,
+ *             LPDWORD       lpNumberOfBytesRead,
+ *             LPOVERLAPPED  lpOverlapped
+ * Variables :
+ * Result    : Boolean
+ * Remark    :
+ * Status    :
+ *
+ * Author    : Patrick Haller [Wed, 1998/02/11 20:44]
+ *****************************************************************************/
+
+BOOL HMDeviceFileClass::ReadFile(PHMHANDLEDATA pHMHandleData,
+                                 LPCVOID       lpBuffer,
+                                 DWORD         nNumberOfBytesToRead,
+                                 LPDWORD       lpNumberOfBytesRead,
+                                 LPOVERLAPPED  lpOverlapped)
+{
+  LPVOID       lpRealBuf;
+  Win32MemMap *map;
+  DWORD        offset;
+  BOOL         bRC;
+
+  dprintfl(("KERNEL32: HMDeviceFileClass::ReadFile %s(%08x,%08x,%08x,%08x,%08x) - stub?\n",
+           lpHMDeviceName,
+           pHMHandleData,
+           lpBuffer,
+           nNumberOfBytesToRead,
+           lpNumberOfBytesRead,
+           lpOverlapped));
+
+  if((pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) && !lpOverlapped) {
+	dprintf(("FILE_FLAG_OVERLAPPED flag set, but lpOverlapped NULL!!"));
+	SetLastError(ERROR_INVALID_PARAMETER);
+	return FALSE;
+  }
+  if(!(pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) && lpOverlapped) {
+	dprintf(("Warning: lpOverlapped != NULL & !FILE_FLAG_OVERLAPPED; sync operation"));
+  }
+
+  //SvL: DosRead doesn't like writing to memory addresses returned by 
+  //     DosAliasMem -> search for original memory mapped pointer and use 
+  //     that one
+  map = Win32MemMapView::findMapByView((ULONG)lpBuffer, &offset, MEMMAP_ACCESS_READ);
+  if(map) {
+	lpRealBuf = (LPVOID)((ULONG)map->getMappingAddr() + offset);
+	DWORD nrpages = nNumberOfBytesToRead/4096;
+	if(offset & 0xfff) 
+		nrpages++;
+	else
+	if(nNumberOfBytesToRead & 0xfff) 
+		nrpages++;
+
+	map->commitPage(offset & ~0xfff, TRUE, nrpages);
+  }
+  else  lpRealBuf = (LPVOID)lpBuffer;
+
+  if(pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) {
+	dprintf(("ERROR: Overlapped IO not yet implememented!!"));
+  }
+//  else {
+  	bRC = OSLibDosRead(pHMHandleData->hHMHandle,
+                           (PVOID)lpRealBuf,
+                           nNumberOfBytesToRead,
+                           lpNumberOfBytesRead);
+//  }
+
+  if(bRC == 0) {
+     	dprintf(("KERNEL32: HMDeviceFileClass::ReadFile returned %08xh %x\n",
+                  bRC, GetLastError()));
+	dprintf(("%x -> %d", lpBuffer, IsBadWritePtr((LPVOID)lpBuffer, nNumberOfBytesToRead)));
+  }
+
+  return bRC;
+}
+
+/*****************************************************************************
+ * Name      : BOOL ReadFileEx
+ * Purpose   : The ReadFileEx function reads data from a file asynchronously.
+ *             It is designed solely for asynchronous operation, unlike the
+ *             ReadFile function, which is designed for both synchronous and
+ *             asynchronous operation. ReadFileEx lets an application perform
+ *             other processing during a file read operation.
+ *             The ReadFileEx function reports its completion status asynchronously,
+ *             calling a specified completion routine when reading is completed
+ *             and the calling thread is in an alertable wait state.
+ * Parameters: HANDLE       hFile                handle of file to read
+ *             LPVOID       lpBuffer             address of buffer
+ *             DWORD        nNumberOfBytesToRead number of bytes to read
+ *             LPOVERLAPPED lpOverlapped         address of offset
+ *             LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine address of completion routine
+ * Variables :
+ * Result    : TRUE / FALSE
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Mon, 1998/06/15 08:00]
+ *****************************************************************************/
+BOOL HMDeviceFileClass::ReadFileEx(PHMHANDLEDATA pHMHandleData,
+                           LPVOID       lpBuffer,
+                           DWORD        nNumberOfBytesToRead,
+                           LPOVERLAPPED lpOverlapped,
+                           LPOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine)
+{
+  dprintf(("ERROR: ReadFileEx(%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
+           pHMHandleData->hHMHandle,
+           lpBuffer,
+           nNumberOfBytesToRead,
+           lpOverlapped,
+           lpCompletionRoutine));
+  return FALSE;
+}
+
+
+/*****************************************************************************
+ * Name      : BOOL HMDeviceFileClass::WriteFile
+ * Purpose   : write data to handle / device
+ * Parameters: PHMHANDLEDATA pHMHandleData,
+ *             LPCVOID       lpBuffer,
+ *             DWORD         nNumberOfBytesToWrite,
+ *             LPDWORD       lpNumberOfBytesWritten,
+ *             LPOVERLAPPED  lpOverlapped
+ * Variables :
+ * Result    : Boolean
+ * Remark    :
+ * Status    :
+ *
+ * Author    : Patrick Haller [Wed, 1998/02/11 20:44]
+ *****************************************************************************/
+
+BOOL HMDeviceFileClass::WriteFile(PHMHANDLEDATA pHMHandleData,
+                                    LPCVOID       lpBuffer,
+                                    DWORD         nNumberOfBytesToWrite,
+                                    LPDWORD       lpNumberOfBytesWritten,
+                                    LPOVERLAPPED  lpOverlapped)
+{
+  BOOL bRC;
+
+  dprintfl(("KERNEL32: HMDeviceFileClass::WriteFile %s(%08x,%08x,%08x,%08x,%08x) - stub?\n",
+           lpHMDeviceName,
+           pHMHandleData,
+           lpBuffer,
+           nNumberOfBytesToWrite,
+           lpNumberOfBytesWritten,
+           lpOverlapped));
+
+  if((pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) && !lpOverlapped) {
+	dprintf(("FILE_FLAG_OVERLAPPED flag set, but lpOverlapped NULL!!"));
+	SetLastError(ERROR_INVALID_PARAMETER);
+	return FALSE;
+  }
+  if(!(pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) && lpOverlapped) {
+	dprintf(("Warning: lpOverlapped != NULL & !FILE_FLAG_OVERLAPPED; sync operation"));
+  }
+
+  if(pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) {
+	dprintf(("ERROR: Overlapped IO not yet implememented!!"));
+  }
+//  else {
+  	bRC = OSLibDosWrite(pHMHandleData->hHMHandle,
+                            (PVOID)lpBuffer,
+                            nNumberOfBytesToWrite,
+                            lpNumberOfBytesWritten);
+//  }
+
+  dprintf(("KERNEL32: HMDeviceFileClass::WriteFile returned %08xh\n",
+           bRC));
+
+  return bRC;
+}
+
+/*****************************************************************************
+ * Name      : BOOL WriteFileEx
+ * Purpose   : The WriteFileEx function writes data to a file. It is designed
+ *             solely for asynchronous operation, unlike WriteFile, which is
+ *             designed for both synchronous and asynchronous operation.
+ *             WriteFileEx reports its completion status asynchronously,
+ *             calling a specified completion routine when writing is completed
+ *             and the calling thread is in an alertable wait state.
+ * Parameters: HANDLE       hFile                handle of file to write
+ *             LPVOID       lpBuffer             address of buffer
+ *             DWORD        nNumberOfBytesToRead number of bytes to write
+ *             LPOVERLAPPED lpOverlapped         address of offset
+ *             LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine address of completion routine
+ * Variables :
+ * Result    : TRUE / FALSE
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Mon, 1998/06/15 08:00]
+ *****************************************************************************/
+
+BOOL HMDeviceFileClass::WriteFileEx(PHMHANDLEDATA pHMHandleData,
+                           LPVOID       lpBuffer,
+                           DWORD        nNumberOfBytesToWrite,
+                           LPOVERLAPPED lpOverlapped,
+                           LPOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine)
+{
+  dprintf(("ERROR: WriteFileEx(%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
+           pHMHandleData->hHMHandle,
+           lpBuffer,
+           nNumberOfBytesToWrite,
+           lpOverlapped,
+           lpCompletionRoutine));
+  return FALSE;
+}
+
+/*****************************************************************************
+ * Name      : DWORD HMDeviceFileClass::GetFileType
+ * Purpose   : determine the handle type
+ * Parameters: PHMHANDLEDATA pHMHandleData
+ * Variables :
+ * Result    : API returncode
+ * Remark    :
+ * Status    :
+ *
+ * Author    : Patrick Haller [Wed, 1998/02/11 20:44]
+ *****************************************************************************/
+
+DWORD HMDeviceFileClass::GetFileType(PHMHANDLEDATA pHMHandleData)
+{
+  dprintfl(("KERNEL32: HMDeviceFileClass::GetFileType %s(%08x)\n",
+           lpHMDeviceName,
+           pHMHandleData));
+
+  return FILE_TYPE_DISK;
+}
+
+
+/*****************************************************************************
+ * Name      : DWORD HMDeviceFileClass::GetFileInformationByHandle
+ * Purpose   : determine the handle type
+ * Parameters: PHMHANDLEDATA               pHMHandleData
+ *             BY_HANDLE_FILE_INFORMATION* pHFI
+ * Variables :
+ * Result    : API returncode
+ * Remark    :
+ * Status    :
+ *
+ * Author    : Patrick Haller [Wed, 1999/06/17 20:44]
+ *****************************************************************************/
+
+DWORD HMDeviceFileClass::GetFileInformationByHandle(PHMHANDLEDATA               pHMHandleData,
+                                                    BY_HANDLE_FILE_INFORMATION* pHFI)
+{
+  dprintfl(("KERNEL32: HMDeviceFileClass::GetFileInformationByHandle %s(%08xh,%08xh)\n",
+           lpHMDeviceName,
+           pHMHandleData,
+           pHFI));
+
+  if(OSLibDosGetFileInformationByHandle(pHMHandleData->hHMHandle,
+                                        pHFI))
+  {
+	return TRUE;
+  }
+  dprintf(("GetFileInformationByHandle failed with error %d", GetLastError()));
+  return FALSE;
+
+}
+
+
+/*****************************************************************************
+ * Name      : BOOL HMDeviceFileClass::SetEndOfFile
+ * Purpose   : set end of file marker
+ * Parameters: PHMHANDLEDATA              pHMHandleData
+ * Variables :
+ * Result    : API returncode
+ * Remark    :
+ * Status    :
+ *
+ * Author    : Patrick Haller [Wed, 1999/06/17 20:44]
+ *****************************************************************************/
+
+BOOL HMDeviceFileClass::SetEndOfFile(PHMHANDLEDATA pHMHandleData)
+{
+  dprintfl(("KERNEL32: HMDeviceFileClass::SetEndOfFile %s(%08xh)\n",
+           lpHMDeviceName,
+           pHMHandleData));
+
+  if(OSLibDosSetEndOfFile(pHMHandleData->hHMHandle)) {
+	return TRUE;
+  }
+  dprintf(("SetEndOfFile failed with error %d", GetLastError()));
+  return FALSE;
+}
+
+
+/*****************************************************************************
+ * Name      : BOOL HMDeviceFileClass::SetFileTime
+ * Purpose   : set file time
+ * Parameters: PHMHANDLEDATA pHMHandleData
+ *             PFILETIME     pFT1
+ *             PFILETIME     pFT2
+ *             PFILETIME     pFT3
+ * Variables :
+ * Result    : API returncode
+ * Remark    :
+ * Status    :
+ *
+ * Author    : Patrick Haller [Wed, 1999/06/17 20:44]
+ *****************************************************************************/
+
+BOOL HMDeviceFileClass::SetFileTime(PHMHANDLEDATA pHMHandleData,
+                                    LPFILETIME pFT1,
+                                    LPFILETIME pFT2,
+                                    LPFILETIME pFT3)
+{
+ WORD creationdate = 0, creationtime = 0;
+ WORD lastaccessdate = 0, lastaccesstime = 0;
+ WORD lastwritedate = 0, lastwritetime = 0;
+
+  dprintfl(("KERNEL32: HMDeviceFileClass::SetFileTime %s(%08xh,%08xh,%08xh,%08xh)\n",
+           lpHMDeviceName,
+           pHMHandleData,
+           pFT1,
+           pFT2,
+           pFT3));
+
+  if(pFT1 && pFT1->dwLowDateTime && pFT1->dwHighDateTime) {
+  	FileTimeToDosDateTime(pFT1, &creationdate, &creationtime);
+  }
+
+  if(pFT2 && pFT2->dwLowDateTime && pFT2->dwHighDateTime) {
+  	FileTimeToDosDateTime(pFT2, &lastaccessdate, &lastaccesstime);
+  }
+
+  if(pFT3 && pFT3->dwLowDateTime && pFT3->dwHighDateTime) {
+  	FileTimeToDosDateTime(pFT3, &lastwritedate, &lastwritetime);
+  }
+
+  if(OSLibDosSetFileTime(pHMHandleData->hHMHandle,
+                             creationdate, creationtime, 
+                             lastaccessdate, lastaccesstime, 
+                             lastwritedate, lastwritetime)) 
+  {
+	return TRUE;
+  }
+  dprintf(("SetFileTime failed with error %d", GetLastError()));
+  return FALSE;
+}
+
+/*****************************************************************************
+ * Name      : BOOL HMDeviceFileClass::GetFileTime
+ * Purpose   : get file time
+ * Parameters: PHMHANDLEDATA pHMHandleData
+ *             PFILETIME     pFT1
+ *             PFILETIME     pFT2
+ *             PFILETIME     pFT3
+ * Variables :
+ * Result    : API returncode
+ * Remark    :
+ * Status    :
+ *
+ * Author    : SvL
+ *****************************************************************************/
+
+BOOL HMDeviceFileClass::GetFileTime(PHMHANDLEDATA pHMHandleData,
+                                    LPFILETIME pFT1,
+                                    LPFILETIME pFT2,
+                                    LPFILETIME pFT3)
+{
+ WORD creationdate, creationtime;
+ WORD lastaccessdate, lastaccesstime;
+ WORD lastwritedate, lastwritetime;
+ BOOL rc;
+
+  if(!pFT1 && !pFT2 && !pFT3) {//TODO: does NT do this?
+	SetLastError(ERROR_INVALID_PARAMETER);
+	return FALSE;
+  }
+
+  if(OSLibDosGetFileTime(pHMHandleData->hHMHandle,
+                         &creationdate, &creationtime, 
+                         &lastaccessdate, &lastaccesstime, 
+                         &lastwritedate, &lastwritetime))
+  {
+	if(pFT1) {
+		DosDateTimeToFileTime(creationdate, creationtime, pFT1);
+	}
+	if(pFT2) {
+		DosDateTimeToFileTime(lastaccessdate, lastaccesstime, pFT2);
+	}
+	if(pFT3) {
+		DosDateTimeToFileTime(lastwritedate, lastwritetime, pFT3);
+	}
+	return TRUE;
+  }
+  dprintf(("GetFileTime failed with error %d", GetLastError()));
+  return FALSE;
+}
+
+/*****************************************************************************
+ * Name      : DWORD HMDeviceFileClass::GetFileSize
+ * Purpose   : set file time
+ * Parameters: PHMHANDLEDATA pHMHandleData
+ *             PDWORD        pSize
+ * Variables :
+ * Result    : API returncode
+ * Remark    :
+ * Status    :
+ *
+ * Author    : Patrick Haller [Wed, 1999/06/17 20:44]
+ *****************************************************************************/
+
+DWORD HMDeviceFileClass::GetFileSize(PHMHANDLEDATA pHMHandleData,
+                                     PDWORD        lpdwFileSizeHigh)
+{
+  dprintfl(("KERNEL32: HMDeviceFileClass::GetFileSize %s(%08xh,%08xh)\n",
+           lpHMDeviceName,
+           pHMHandleData,
+           lpdwFileSizeHigh));
+
+  if(lpdwFileSizeHigh)
+    *lpdwFileSizeHigh = 0;
+
+  return OSLibDosGetFileSize(pHMHandleData->hHMHandle, lpdwFileSizeHigh);
+}
+
+/*****************************************************************************
+ * Name      : DWORD HMDeviceFileClass::SetFilePointer
+ * Purpose   : set file pointer
+ * Parameters: PHMHANDLEDATA pHMHandleData
+ *             LONG          lDistanceToMove
+ *             PLONG         lpDistanceToMoveHigh
+ *             DWORD         dwMoveMethod
+ * Variables :
+ * Result    : API returncode
+ * Remark    :
+ * Status    :
+ *
+ * Author    : Patrick Haller [Wed, 1999/06/17 20:44]
+ *****************************************************************************/
+
+DWORD HMDeviceFileClass::SetFilePointer(PHMHANDLEDATA pHMHandleData,
+                                        LONG          lDistanceToMove,
+                                        PLONG         lpDistanceToMoveHigh,
+                                        DWORD         dwMoveMethod)
+{
+  DWORD ret;
+
+  dprintfl(("KERNEL32: HMDeviceFileClass::SetFilePointer %s(%08xh,%08xh,%08xh,%08xh)\n",
+           lpHMDeviceName,
+           pHMHandleData,
+           lDistanceToMove,
+           lpDistanceToMoveHigh,
+           dwMoveMethod));
+
+  ret = OSLibDosSetFilePointer(pHMHandleData->hHMHandle,
+                               lDistanceToMove,
+                               (DWORD *)lpDistanceToMoveHigh,
+                               dwMoveMethod);
+
+  if(ret == -1) {
+	dprintf(("SetFilePointer failed (error = %d)", GetLastError()));
+  }
+  return ret;
+}
+
+
+/*****************************************************************************
+ * Name      : DWORD HMDeviceFileClass::LockFile
+ * Purpose   : file locking
+ * Parameters: PHMHANDLEDATA pHMHandleData
+ *             DWORD arg2
+ *             DWORD arg3
+ *             DWORD arg4
+ *             DWORD arg5
+ * Variables :
+ * Result    : API returncode
+ * Remark    :
+ * Status    :
+ *
+ * Author    : Patrick Haller [Wed, 1999/06/17 20:44]
+ *****************************************************************************/
+
+DWORD HMDeviceFileClass::LockFile(PHMHANDLEDATA pHMHandleData,
+                                  DWORD         dwFileOffsetLow,
+                                  DWORD         dwFileOffsetHigh,
+                                  DWORD         cbLockLow,
+                                  DWORD         cbLockHigh)
+{
+  dprintfl(("KERNEL32: HMDeviceFileClass::LockFile %s(%08xh,%08xh,%08xh,%08xh,%08xh)\n",
+           lpHMDeviceName,
+           pHMHandleData,
+           dwFileOffsetLow,
+           dwFileOffsetHigh,
+           cbLockLow,
+           cbLockHigh));
+
+  return OSLibDosLockFile(pHMHandleData->hHMHandle,
+                          LOCKFILE_EXCLUSIVE_LOCK,
+                          dwFileOffsetLow,
+                          dwFileOffsetHigh,
+                          cbLockLow,
+                          cbLockHigh,
+                          NULL);
+}
+
+/*****************************************************************************
+ * Name      : DWORD HMDeviceFileClass::LockFileEx
+ * Purpose   : file locking
+ * Parameters: PHMHANDLEDATA pHMHandleData
+ *             DWORD dwFlags
+ *             DWORD dwReserved
+ *             DWORD nNumberOfBytesToLockLow
+ *             DWORD nNumberOfBytesToLockHigh
+ *             LPOVERLAPPED lpOverlapped
+ * Variables :
+ * Result    : API returncode
+ * Remark    :
+ * Status    :
+ *
+ * Author    : Patrick Haller [Wed, 1999/06/17 20:44]
+ *****************************************************************************/
+
+DWORD HMDeviceFileClass::LockFileEx(PHMHANDLEDATA pHMHandleData,
+                                    DWORD         dwFlags,
+                                    DWORD         dwReserved,
+                                    DWORD         nNumberOfBytesToLockLow,
+                                    DWORD         nNumberOfBytesToLockHigh,
+                                    LPOVERLAPPED  lpOverlapped)
+{
+
+  dprintfl(("KERNEL32: HMDeviceFileClass::LockFileEx %s(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh) not completely implemented!",
+           lpHMDeviceName,
+           pHMHandleData,
+           dwFlags,
+           dwReserved,
+           nNumberOfBytesToLockLow,
+           nNumberOfBytesToLockHigh,
+           lpOverlapped));
+
+
+  return(OSLibDosLockFile(pHMHandleData->hHMHandle,
+                          dwFlags,
+                          lpOverlapped->Offset,
+                          lpOverlapped->OffsetHigh,
+                          nNumberOfBytesToLockLow,
+                          nNumberOfBytesToLockHigh,
+                          lpOverlapped));
+}
+
+
+/*****************************************************************************
+ * Name      : DWORD HMDeviceFileClass::UnlockFile
+ * Purpose   : file locking
+ * Parameters: PHMHANDLEDATA pHMHandleData
+ *             DWORD arg2
+ *             DWORD arg3
+ *             DWORD arg4
+ *             DWORD arg5
+ * Variables :
+ * Result    : API returncode
+ * Remark    :
+ * Status    :
+ *
+ * Author    : Patrick Haller [Wed, 1999/06/17 20:44]
+ *****************************************************************************/
+
+DWORD HMDeviceFileClass::UnlockFile(PHMHANDLEDATA pHMHandleData,
+                                    DWORD         dwFileOffsetLow,
+                                    DWORD         dwFileOffsetHigh,
+                                    DWORD         cbLockLow,
+                                    DWORD         cbLockHigh)
+{
+  dprintfl(("KERNEL32: HMDeviceFileClass::UnlockFile %s(%08xh,%08xh,%08xh,%08xh,%08xh)\n",
+           lpHMDeviceName,
+           pHMHandleData,
+           dwFileOffsetLow,
+           dwFileOffsetHigh,
+           cbLockLow,
+           cbLockHigh));
+
+  return OSLibDosUnlockFile(pHMHandleData->hHMHandle,
+                            dwFileOffsetLow,
+                            dwFileOffsetHigh,
+                            cbLockLow,
+                            cbLockHigh,
+                            NULL);
+}
+
+
+
+/*****************************************************************************
+ * Name      : DWORD HMDeviceFileClass::UnlockFileEx
+ * Purpose   : file locking
+ * Parameters: PHMHANDLEDATA pHMHandleData
+ *             DWORD dwFlags
+ *             DWORD dwReserved
+ *             DWORD nNumberOfBytesToLockLow
+ *             DWORD nNumberOfBytesToLockHigh
+ *             LPOVERLAPPED lpOverlapped
+ * Variables :
+ * Result    : API returncode
+ * Remark    :
+ * Status    :
+ *
+ * Author    : Patrick Haller [Wed, 1999/06/17 20:44]
+ *****************************************************************************/
+
+DWORD HMDeviceFileClass::UnlockFileEx(PHMHANDLEDATA pHMHandleData,
+                                      DWORD         dwReserved,
+                                      DWORD         nNumberOfBytesToLockLow,
+                                      DWORD         nNumberOfBytesToLockHigh,
+                                      LPOVERLAPPED  lpOverlapped)
+{
+
+  dprintfl(("KERNEL32: HMDeviceFileClass::UnlockFileEx %s(%08xh,%08xh,%08xh,%08xh,%08xh) not completely implemented!",
+           lpHMDeviceName,
+           pHMHandleData,
+           dwReserved,
+           nNumberOfBytesToLockLow,
+           nNumberOfBytesToLockHigh,
+           lpOverlapped));
+
+
+  return(OSLibDosUnlockFile(pHMHandleData->hHMHandle,
+                            lpOverlapped->Offset,
+                            lpOverlapped->OffsetHigh,
+                            nNumberOfBytesToLockLow,
+                            nNumberOfBytesToLockHigh,
+                            lpOverlapped));
+}
+
+
+/*****************************************************************************
+ * Name      : DWORD HMDeviceFileClass::FlushFileBuffers
+ * Purpose   : flush the buffers of a file
+ * Parameters: PHMHANDLEDATA pHMHandleData
+ * Variables :
+ * Result    : API returncode
+ * Remark    :
+ * Status    :
+ *
+ * Author    : Patrick Haller [Wed, 1999/06/17 20:44]
+ *****************************************************************************/
+
+BOOL HMDeviceFileClass::FlushFileBuffers(PHMHANDLEDATA pHMHandleData)
+{
+  dprintfl(("KERNEL32: HMDeviceFileClass:FlushFileBuffers(%08xh)\n",
+            pHMHandleData->hHMHandle));
+
+  return(OSLibDosFlushFileBuffers(pHMHandleData->hHMHandle));
+}
+
+
+/*****************************************************************************
+ * Name      : DWORD HMDeviceFileClass::GetOverlappedResult
+ * Purpose   : asynchronus I/O
+ * Parameters: PHMHANDLEDATA pHMHandleData
+ *             LPOVERLAPPED  arg2
+ *             LPDWORD       arg3
+ *             BOOL          arg4
+ * Variables :
+ * Result    : API returncode
+ * Remark    :
+ * Status    :
+ *
+ * Author    : Patrick Haller [Wed, 1999/06/17 20:44]
+ *****************************************************************************/
+
+BOOL HMDeviceFileClass::GetOverlappedResult(PHMHANDLEDATA pHMHandleData,
+                                              LPOVERLAPPED  arg2,
+                                              LPDWORD       arg3,
+                                              BOOL          arg4)
+{
+  dprintfl(("KERNEL32-WARNING: HMDeviceFileClass::GetOverlappedResult(%08xh,%08xh,%08xh,%08xh) STUB!!",
+            pHMHandleData->hHMHandle,
+            arg2,
+            arg3,
+            arg4));
+
+  return FALSE;
+//  return(O32_GetOverlappedResult(pHMHandleData->hHMHandle,
+//                                 arg2,
+//                                 arg3,
+//                                 arg4));
+}
+//******************************************************************************
+//******************************************************************************
+HMFileInfo::HMFileInfo(LPSTR lpszFileName, PVOID lpSecurityAttributes)
+{
+  this->lpszFileName = (LPSTR)malloc(strlen(lpszFileName)+1);
+  if(!this->lpszFileName) {
+	DebugInt3();
+  }
+  strcpy(this->lpszFileName, lpszFileName);
+  this->lpSecurityAttributes = lpSecurityAttributes;
+}
+//******************************************************************************
+//******************************************************************************
+HMFileInfo::~HMFileInfo()
+{
+  if(lpszFileName) {
+	free(lpszFileName);
+	lpszFileName = NULL;
+  }
+}
+//******************************************************************************
+//******************************************************************************
Index: trunk/src/kernel32/hmfile.h
===================================================================
--- trunk/src/kernel32/hmfile.h	(revision 3642)
+++ trunk/src/kernel32/hmfile.h	(revision 3642)
@@ -0,0 +1,171 @@
+/* $Id: hmfile.h,v 1.1 2000-06-01 11:28:47 sandervl Exp $ */
+
+/*
+ * Project Odin Software License can be found in LICENSE.TXT
+ * Win32 Unified Handle Manager for OS/2
+ * 1999/06/17 PH Patrick Haller (phaller@gmx.net)
+ */
+
+#ifndef __HMFILE_H__
+#define __HMFILE_H__
+
+
+/*****************************************************************************
+ * Remark                                                                    *
+ *****************************************************************************
+ */
+
+
+/*****************************************************************************
+ * Includes                                                                  *
+ *****************************************************************************/
+
+#include "HMDevice.h"
+#include "HMOpen32.h"
+
+
+class HMFileInfo
+{
+public:
+  HMFileInfo(LPSTR lpszFileName, PVOID lpSecurityAttributes);
+ ~HMFileInfo();
+
+  char *lpszFileName;
+  PVOID lpSecurityAttributes;
+};
+
+/*****************************************************************************
+ * Structures                                                                *
+ *****************************************************************************/
+
+class HMDeviceFileClass : public HMDeviceHandler
+{
+public:
+  HMDeviceFileClass(LPCSTR lpDeviceName) : HMDeviceHandler(lpDeviceName) {}
+
+                       /* this is a handler method for calls to CreateFile() */
+  virtual DWORD  CreateFile (LPCSTR        lpFileName,
+                             PHMHANDLEDATA pHMHandleData,
+                             PVOID         lpSecurityAttributes,
+                             PHMHANDLEDATA pHMHandleDataTemplate);
+
+                       /* this is a handler method for calls to   OpenFile() */
+  virtual DWORD  OpenFile   (LPCSTR        lpFileName,
+                             PHMHANDLEDATA pHMHandleData,
+                             OFSTRUCT*     pOFStruct,
+                             UINT          fuMode);
+
+  virtual BOOL DuplicateHandle(PHMHANDLEDATA pHMHandleData, HANDLE  srcprocess,
+                               PHMHANDLEDATA pHMSrcHandle,
+                               HANDLE  destprocess,
+                               PHANDLE desthandle,
+                               DWORD   fdwAccess,
+                               BOOL    fInherit,
+                               DWORD   fdwOptions);
+
+                      /* this is a handler method for calls to CloseHandle() */
+  virtual DWORD  CloseHandle(PHMHANDLEDATA pHMHandleData);
+
+                           /* this is a handler method for calls to ReadFile() */
+  virtual BOOL   ReadFile   (PHMHANDLEDATA pHMHandleData,
+                             LPCVOID       lpBuffer,
+                             DWORD         nNumberOfBytesToRead,
+                             LPDWORD       lpNumberOfBytesRead,
+                             LPOVERLAPPED  lpOverlapped);
+
+                        /* this is a handler method for calls to ReadFileEx() */
+  virtual BOOL  ReadFileEx(PHMHANDLEDATA pHMHandleData,
+                           LPVOID       lpBuffer,
+                           DWORD        nNumberOfBytesToRead,
+                           LPOVERLAPPED lpOverlapped,
+                           LPOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine);
+
+                        /* this is a handler method for calls to WriteFile() */
+  virtual BOOL   WriteFile  (PHMHANDLEDATA pHMHandleData,
+                             LPCVOID       lpBuffer,
+                             DWORD         nNumberOfBytesToWrite,
+                             LPDWORD       lpNumberOfBytesWritten,
+                             LPOVERLAPPED  lpOverlapped);
+
+                        /* this is a handler method for calls to WriteFileEx() */
+  virtual BOOL  WriteFileEx(PHMHANDLEDATA pHMHandleData,
+                            LPVOID       lpBuffer,
+                            DWORD        nNumberOfBytesToWrite,
+                            LPOVERLAPPED lpOverlapped,
+                            LPOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine);
+
+                      /* this is a handler method for calls to GetFileType() */
+  virtual DWORD GetFileType (PHMHANDLEDATA pHMHandleData);
+
+       /* this is a handler method for calls to GetFileInformationByHandle() */
+  virtual DWORD GetFileInformationByHandle(PHMHANDLEDATA pHMHandleData,
+                                           BY_HANDLE_FILE_INFORMATION* pHFI);
+
+                     /* this is a handler method for calls to SetEndOfFile() */
+  virtual BOOL  SetEndOfFile(PHMHANDLEDATA pHMHandleData);
+
+                      /* this is a handler method for calls to SetFileTime() */
+  virtual BOOL  SetFileTime (PHMHANDLEDATA pHMHandleData,
+                             LPFILETIME    pFT1,
+                             LPFILETIME    pFT2,
+                             LPFILETIME    pFT3);
+
+                      /* this is a handler method for calls to GetFileTime() */
+  virtual BOOL  GetFileTime (PHMHANDLEDATA pHMHandleData,
+                             LPFILETIME    pFT1,
+                             LPFILETIME    pFT2,
+                             LPFILETIME    pFT3);
+
+                      /* this is a handler method for calls to GetFileSize() */
+  virtual DWORD GetFileSize(PHMHANDLEDATA pHMHandleData,
+                            PDWORD        pSizeHigh);
+
+                   /* this is a handler method for calls to SetFilePointer() */
+  virtual DWORD SetFilePointer(PHMHANDLEDATA pHMHandleData,
+                               LONG          lDistanceToMove,
+                               PLONG         lpDistanceToMoveHigh,
+                               DWORD         dwMoveMethod);
+
+                         /* this is a handler method for calls to LockFile() */
+  virtual DWORD LockFile(PHMHANDLEDATA pHMHandleData,
+                         DWORD         arg2,
+                         DWORD         arg3,
+                         DWORD         arg4,
+                         DWORD         arg5);
+
+                       /* this is a handler method for calls to LockFileEx() */
+  virtual DWORD LockFileEx(PHMHANDLEDATA pHMHandleData,
+                           DWORD         dwFlags,
+                           DWORD         dwReserved,
+                           DWORD         nNumberOfBytesToLockLow,
+                           DWORD         nNumberOfBytesToLockHigh,
+                           LPOVERLAPPED  lpOverlapped);
+
+                       /* this is a handler method for calls to UnlockFile() */
+  virtual DWORD UnlockFile(PHMHANDLEDATA pHMHandleData,
+                           DWORD         arg2,
+                           DWORD         arg3,
+                           DWORD         arg4,
+                           DWORD         arg5);
+
+                     /* this is a handler method for calls to UnlockFileEx() */
+  virtual DWORD UnlockFileEx(PHMHANDLEDATA pHMHandleData,
+                             DWORD         dwReserved,
+                             DWORD         nNumberOfBytesToLockLow,
+                             DWORD         nNumberOfBytesToLockHigh,
+                             LPOVERLAPPED  lpOverlapped);
+
+                   /* this is a handler method for calls to FlushFileBuffers */
+  virtual BOOL FlushFileBuffers(PHMHANDLEDATA pHMHandleData);
+
+                /* this is a handler method for calls to GetOverlappedResult */
+  virtual BOOL GetOverlappedResult(PHMHANDLEDATA pHMHandleData,
+                                   LPOVERLAPPED  arg2,
+                                   LPDWORD       arg3,
+                                   BOOL          arg4);
+
+};
+
+
+#endif /* __HMFILE_H__ */
+
Index: trunk/src/kernel32/hmopen32.cpp
===================================================================
--- trunk/src/kernel32/hmopen32.cpp	(revision 3641)
+++ trunk/src/kernel32/hmopen32.cpp	(revision 3642)
@@ -1,3 +1,3 @@
-/* $Id: hmopen32.cpp,v 1.23 2000-05-23 18:45:12 sandervl Exp $ */
+/* $Id: hmopen32.cpp,v 1.24 2000-06-01 11:28:47 sandervl Exp $ */
 
 /*
@@ -71,4 +71,30 @@
 }
 
+/*****************************************************************************
+ * Name      : DWORD HMDeviceOpen32Class::CloseHandle
+ * Purpose   : close the handle
+ * Parameters: PHMHANDLEDATA pHMHandleData
+ * Variables :
+ * Result    : API returncode
+ * Remark    :
+ * Status    :
+ *
+ * Author    : Patrick Haller [Wed, 1998/02/11 20:44]
+ *****************************************************************************/
+
+DWORD HMDeviceOpen32Class::CloseHandle(PHMHANDLEDATA pHMHandleData)
+{
+  BOOL bRC;
+
+  dprintfl(("KERNEL32: HandleManager::Open32::CloseHandle(%08x)\n",
+           pHMHandleData->hHMHandle));
+
+  bRC = O32_CloseHandle(pHMHandleData->hHMHandle);
+
+  dprintfl(("KERNEL32: HandleManager::Open32::CloseHandle returned %08xh\n",
+           bRC));
+
+  return (DWORD)bRC;
+}
 
 /*****************************************************************************
@@ -100,313 +126,12 @@
            srcprocess, pHMSrcHandle->hHMHandle, destprocess, desthandle));
 
-#if 1
   rc = O32_DuplicateHandle(srcprocess, pHMSrcHandle->hHMHandle, destprocess, desthandle, fdwAccess, fInherit, fdwOptions);
 
   if(rc == TRUE) {
      	pHMHandleData->hHMHandle = *desthandle;
-     	return (NO_ERROR);
+     	return TRUE;
   }
-  else  return(O32_GetLastError());
-#else
-  rc = OSLibDosDupHandle(pHMSrcHandle->hHMHandle, desthandle);
-  if(rc == NO_ERROR)
-  {
-    pHMHandleData->hHMHandle = *desthandle;
-    return (NO_ERROR);
-  }
-  else
-  {
-    dprintfl(("KERNEL32: HandleManager::Open32::DuplicateHandle Error %d\n",rc));
-    O32_SetLastError(rc);
-    return(rc);
-  }
-#endif
-}
-
-/*****************************************************************************
- * Name      : DWORD HMDeviceOpen32Class::CreateFile
- * Purpose   : this is called from the handle manager if a CreateFile() is
- *             performed on a handle
- * Parameters: LPCSTR        lpFileName            name of the file / device
- *             PHMHANDLEDATA pHMHandleData         data of the NEW handle
- *             PVOID         lpSecurityAttributes  ignored
- *             PHMHANDLEDATA pHMHandleDataTemplate data of the template handle
- * Variables :
- * Result    :
- * Remark    :
- * Status    : NO_ERROR - API succeeded
- *             other    - what is to be set in SetLastError
- *
- * Author    : Patrick Haller [Wed, 1998/02/11 20:44]
- *****************************************************************************/
-
-DWORD HMDeviceOpen32Class::CreateFile (LPCSTR        lpFileName,
-                                       PHMHANDLEDATA pHMHandleData,
-                                       PVOID         lpSecurityAttributes,
-                                       PHMHANDLEDATA pHMHandleDataTemplate)
-{
-  HFILE hFile;
-  HFILE hTemplate;
-
-  dprintfl(("KERNEL32: HandleManager::Open32::CreateFile %s(%s,%08x,%08x,%08x) - stub?\n",
-           lpHMDeviceName,
-           lpFileName,
-           pHMHandleData,
-           lpSecurityAttributes,
-           pHMHandleDataTemplate));
-
-  if (strncmp(lpFileName,       // "support" for local unc names
-              "\\\\.\\",
-              4) == 0) 
-  {
-  	lpFileName+=4;
-  }
-
-  // create from template
-  if (pHMHandleDataTemplate != NULL)
-     hTemplate = pHMHandleDataTemplate->hHMHandle;
-  else
-     hTemplate = 0;
-
-#if 1
-  //SvL: Open32 doesn't like this flag
-  if(pHMHandleData->dwShare & FILE_SHARE_DELETE) {
-	pHMHandleData->dwShare &= ~FILE_SHARE_DELETE;
-  }
-
-  hFile = O32_CreateFile(lpFileName,
-                         pHMHandleData->dwAccess,
-                         pHMHandleData->dwShare,
-                         //(LPSECURITY_ATTRIBUTES)lpSecurityAttributes,
-                         NULL,
-                         pHMHandleData->dwCreation,
-                         pHMHandleData->dwFlags,
-                         hTemplate);
-  if (hFile != INVALID_HANDLE_ERROR)
-  {
-     	pHMHandleData->hHMHandle = hFile;
-     	return (NO_ERROR);
-  }
-  else {
-	dprintf(("CreateFile failed; error %x", O32_GetLastError()));
-    	return(O32_GetLastError());
-  }
-#else
-
-  rc = OSLibDosCreate((char *)lpFileName,
-                       pHMHandleData->dwAccess,
-                       pHMHandleData->dwShare,
-                       //(LPSECURITY_ATTRIBUTES)lpSecurityAttributes,
-                       NULL,
-                       pHMHandleData->dwCreation,
-                       pHMHandleData->dwFlags,
-                       hTemplate, &hFile);
-  if(rc)
-  {
-    dprintfl(("KERNEL32: HandleManager::Open32::CreateFile Error %d\n",rc));
-    O32_SetLastError(rc);
-    return(rc);
-  }
-  else
-  {
-    pHMHandleData->hHMHandle = hFile;
-    return (NO_ERROR);
-  }
-#endif
-}
-
-
-/*****************************************************************************
- * Name      : DWORD HMDeviceOpen32Class::CloseHandle
- * Purpose   : close the handle
- * Parameters: PHMHANDLEDATA pHMHandleData
- * Variables :
- * Result    : API returncode
- * Remark    :
- * Status    :
- *
- * Author    : Patrick Haller [Wed, 1998/02/11 20:44]
- *****************************************************************************/
-
-DWORD HMDeviceOpen32Class::CloseHandle(PHMHANDLEDATA pHMHandleData)
-{
-  BOOL bRC;
-
-  dprintfl(("KERNEL32: HandleManager::Open32::CloseHandle(%08x)\n",
-           pHMHandleData->hHMHandle));
-
-#if 1
-  bRC = O32_CloseHandle(pHMHandleData->hHMHandle);
-
-  dprintfl(("KERNEL32: HandleManager::Open32::CloseHandle returned %08xh\n",
-           bRC));
-
-  return (DWORD)bRC;
-#else
-  bRC = OSLibDosClose(pHMHandleData->hHMHandle);
-  if(bRC)
-  {
-    dprintfl(("KERNEL32: HandleManager::Open32::CloseHandle Error %d\n",bRC));
-    O32_SetLastError(bRC);
-    return TRUE;      // MUTEX Problem
-    return FALSE;
-  }
-  else
-  {
-    return TRUE;
-  }
-#endif
-}
-
-
-/*****************************************************************************
- * Name      : BOOL HMDeviceOpen32Class::ReadFile
- * Purpose   : read data from handle / device
- * Parameters: PHMHANDLEDATA pHMHandleData,
- *             LPCVOID       lpBuffer,
- *             DWORD         nNumberOfBytesToRead,
- *             LPDWORD       lpNumberOfBytesRead,
- *             LPOVERLAPPED  lpOverlapped
- * Variables :
- * Result    : Boolean
- * Remark    :
- * Status    :
- *
- * Author    : Patrick Haller [Wed, 1998/02/11 20:44]
- *****************************************************************************/
-
-BOOL HMDeviceOpen32Class::ReadFile(PHMHANDLEDATA pHMHandleData,
-                                   LPCVOID       lpBuffer,
-                                   DWORD         nNumberOfBytesToRead,
-                                   LPDWORD       lpNumberOfBytesRead,
-                                   LPOVERLAPPED  lpOverlapped)
-{
-  BOOL bRC;
-  LPVOID lpRealBuf;
-
-  dprintfl(("KERNEL32: HandleManager::Open32::ReadFile %s(%08x,%08x,%08x,%08x,%08x) - stub?\n",
-           lpHMDeviceName,
-           pHMHandleData,
-           lpBuffer,
-           nNumberOfBytesToRead,
-           lpNumberOfBytesRead,
-           lpOverlapped));
-
-#if 1
-  Win32MemMap *map;
-  DWORD offset;
-
-  //SvL: DosRead doesn't like writing to memory addresses returned by 
-  //     DosAliasMem -> search for original memory mapped pointer and use 
-  //     that one
-  map = Win32MemMapView::findMapByView((ULONG)lpBuffer, &offset, MEMMAP_ACCESS_READ);
-  if(map) {
-	lpRealBuf = (LPVOID)((ULONG)map->getMappingAddr() + offset);
-	DWORD nrpages = nNumberOfBytesToRead/4096;
-	if(offset & 0xfff) 
-		nrpages++;
-	else
-	if(nNumberOfBytesToRead & 0xfff) 
-		nrpages++;
-
-	map->commitPage(offset & ~0xfff, TRUE, nrpages);
-  }
-  else  lpRealBuf = (LPVOID)lpBuffer;
-  
-  bRC = O32_ReadFile(pHMHandleData->hHMHandle,
-                     (PVOID)lpRealBuf,
-                     nNumberOfBytesToRead,
-                     lpNumberOfBytesRead,
-                     lpOverlapped);
-
-  if(bRC == 0) {
-     	dprintf(("KERNEL32: HandleManager::Open32::ReadFile returned %08xh %x\n",
-                  bRC, GetLastError()));
-	dprintf(("%x -> %d", lpBuffer, IsBadWritePtr((LPVOID)lpBuffer, nNumberOfBytesToRead)));
-  }
-  else 	dprintfl(("KERNEL32: HandleManager::Open32::ReadFile returned %08xh\n",
-                   bRC));
-
-  return bRC;
-#else
-  rc = OSLibDosRead(pHMHandleData->hHMHandle,
-                    (PVOID) lpBuffer,
-                    nNumberOfBytesToRead,
-                    lpNumberOfBytesRead);
-  if(rc)
-  {
-    dprintfl(("KERNEL32: HandleManager::Open32::ReadFile Error %d\n",rc));
-    O32_SetLastError(rc);
-    return FALSE;
-  }
-  else
-  {
-    return TRUE;
-  }
-#endif
-}
-
-
-/*****************************************************************************
- * Name      : BOOL HMDeviceOpen32Class::WriteFile
- * Purpose   : write data to handle / device
- * Parameters: PHMHANDLEDATA pHMHandleData,
- *             LPCVOID       lpBuffer,
- *             DWORD         nNumberOfBytesToWrite,
- *             LPDWORD       lpNumberOfBytesWritten,
- *             LPOVERLAPPED  lpOverlapped
- * Variables :
- * Result    : Boolean
- * Remark    :
- * Status    :
- *
- * Author    : Patrick Haller [Wed, 1998/02/11 20:44]
- *****************************************************************************/
-
-BOOL HMDeviceOpen32Class::WriteFile(PHMHANDLEDATA pHMHandleData,
-                                    LPCVOID       lpBuffer,
-                                    DWORD         nNumberOfBytesToWrite,
-                                    LPDWORD       lpNumberOfBytesWritten,
-                                    LPOVERLAPPED  lpOverlapped)
-{
-  BOOL bRC;
-
-  dprintfl(("KERNEL32: HandleManager::Open32::WriteFile %s(%08x,%08x,%08x,%08x,%08x) - stub?\n",
-           lpHMDeviceName,
-           pHMHandleData,
-           lpBuffer,
-           nNumberOfBytesToWrite,
-           lpNumberOfBytesWritten,
-           lpOverlapped));
-
-#if 1
-  bRC = O32_WriteFile(pHMHandleData->hHMHandle,
-                      lpBuffer,
-                      nNumberOfBytesToWrite,
-                      lpNumberOfBytesWritten,
-                      lpOverlapped);
-
-  dprintfl(("KERNEL32: HandleManager::Open32::WriteFile returned %08xh\n",
-           bRC));
-
-  return bRC;
-#else
-  rc = OSLibDosWrite(pHMHandleData->hHMHandle,
-                     (PVOID) lpBuffer,
-                     nNumberOfBytesToWrite,
-                     lpNumberOfBytesWritten);
-  if(rc)
-  {
-    dprintfl(("KERNEL32: HandleManager::Open32::WriteFile Error %d\n",rc));
-    O32_SetLastError(rc);
-    return FALSE;
-  }
-  else
-  {
-    return TRUE;
-  }
-#endif
-}
-
+  else  return FALSE;
+}
 
 /*****************************************************************************
@@ -428,10 +153,6 @@
            pHMHandleData));
 
-#if 1
+  //TODO: return FILE_TYPE_UNKNOWN for standard in/out handles; correct??
   return O32_GetFileType(pHMHandleData->hHMHandle);
-#else
-  // TODO: FILE_TYPE_DISK
-  return FILE_TYPE_CHAR;
-#endif
 }
 
@@ -461,433 +182,4 @@
                                         pHFI);
 }
-
-
-/*****************************************************************************
- * Name      : BOOL HMDeviceOpen32Class::SetEndOfFile
- * Purpose   : set end of file marker
- * Parameters: PHMHANDLEDATA              pHMHandleData
- * Variables :
- * Result    : API returncode
- * Remark    :
- * Status    :
- *
- * Author    : Patrick Haller [Wed, 1999/06/17 20:44]
- *****************************************************************************/
-
-BOOL HMDeviceOpen32Class::SetEndOfFile(PHMHANDLEDATA pHMHandleData)
-{
-  dprintfl(("KERNEL32: HandleManager::Open32::SetEndOfFile %s(%08xh)\n",
-           lpHMDeviceName,
-           pHMHandleData));
-
-  return O32_SetEndOfFile(pHMHandleData->hHMHandle);
-}
-
-
-/*****************************************************************************
- * Name      : BOOL HMDeviceOpen32Class::SetFileTime
- * Purpose   : set file time
- * Parameters: PHMHANDLEDATA pHMHandleData
- *             PFILETIME     pFT1
- *             PFILETIME     pFT2
- *             PFILETIME     pFT3
- * Variables :
- * Result    : API returncode
- * Remark    :
- * Status    :
- *
- * Author    : Patrick Haller [Wed, 1999/06/17 20:44]
- *****************************************************************************/
-
-BOOL HMDeviceOpen32Class::SetFileTime(PHMHANDLEDATA pHMHandleData,
-                                      LPFILETIME pFT1,
-                                      LPFILETIME pFT2,
-                                      LPFILETIME pFT3)
-{
-  dprintfl(("KERNEL32: HandleManager::Open32::SetFileTime %s(%08xh,%08xh,%08xh,%08xh)\n",
-           lpHMDeviceName,
-           pHMHandleData,
-           pFT1,
-           pFT2,
-           pFT3));
-
-  return O32_SetFileTime(pHMHandleData->hHMHandle,
-                         pFT1,
-                         pFT2,
-                         pFT3);
-}
-
-/*****************************************************************************
- * Name      : BOOL HMDeviceOpen32Class::GetFileTime
- * Purpose   : get file time
- * Parameters: PHMHANDLEDATA pHMHandleData
- *             PFILETIME     pFT1
- *             PFILETIME     pFT2
- *             PFILETIME     pFT3
- * Variables :
- * Result    : API returncode
- * Remark    :
- * Status    :
- *
- * Author    : SvL
- *****************************************************************************/
-
-BOOL HMDeviceOpen32Class::GetFileTime(PHMHANDLEDATA pHMHandleData,
-                                      LPFILETIME pFT1,
-                                      LPFILETIME pFT2,
-                                      LPFILETIME pFT3)
-{
-  return O32_GetFileTime(pHMHandleData->hHMHandle,
-                         pFT1,
-                         pFT2,
-                         pFT3);
-}
-
-
-/*****************************************************************************
- * Name      : DWORD HMDeviceOpen32Class::GetFileSize
- * Purpose   : set file time
- * Parameters: PHMHANDLEDATA pHMHandleData
- *             PDWORD        pSize
- * Variables :
- * Result    : API returncode
- * Remark    :
- * Status    :
- *
- * Author    : Patrick Haller [Wed, 1999/06/17 20:44]
- *****************************************************************************/
-
-DWORD HMDeviceOpen32Class::GetFileSize(PHMHANDLEDATA pHMHandleData,
-                                       PDWORD        lpdwFileSizeHigh)
-{
-  dprintfl(("KERNEL32: HandleManager::Open32::GetFileSize %s(%08xh,%08xh)\n",
-           lpHMDeviceName,
-           pHMHandleData,
-           lpdwFileSizeHigh));
-
-#if 1
-  if(lpdwFileSizeHigh)
-    *lpdwFileSizeHigh = 0;
-
-  return O32_GetFileSize(pHMHandleData->hHMHandle,
-                         lpdwFileSizeHigh);
-#else
-  size = OSLibDosGetFileSize(pHMHandleData->hHMHandle);
-  if(pSize)
-    *pSize = 0;
-  return size;
-#endif
-}
-
-
-/*****************************************************************************
- * Name      : DWORD HMDeviceOpen32Class::SetFilePointer
- * Purpose   : set file pointer
- * Parameters: PHMHANDLEDATA pHMHandleData
- *             LONG          lDistanceToMove
- *             PLONG         lpDistanceToMoveHigh
- *             DWORD         dwMoveMethod
- * Variables :
- * Result    : API returncode
- * Remark    :
- * Status    :
- *
- * Author    : Patrick Haller [Wed, 1999/06/17 20:44]
- *****************************************************************************/
-
-DWORD HMDeviceOpen32Class::SetFilePointer(PHMHANDLEDATA pHMHandleData,
-                                          LONG          lDistanceToMove,
-                                          PLONG         lpDistanceToMoveHigh,
-                                          DWORD         dwMoveMethod)
-{
-  dprintfl(("KERNEL32: HandleManager::Open32::SetFilePointer %s(%08xh,%08xh,%08xh,%08xh)\n",
-           lpHMDeviceName,
-           pHMHandleData,
-           lDistanceToMove,
-           lpDistanceToMoveHigh,
-           dwMoveMethod));
-
-#if 1
-  DWORD ret;
-
-  if(lpDistanceToMoveHigh)
-    *lpDistanceToMoveHigh = 0;
-
-  ret = O32_SetFilePointer(pHMHandleData->hHMHandle,
-                           lDistanceToMove,
-                           lpDistanceToMoveHigh,
-                           dwMoveMethod);
-
-//  if(ret == -1) {
-//	dprintf(("current position %x (error = %x)", O32_SetFilePointer(pHMHandleData->hHMHandle,0, 0, 1), GetLastError()));
-//  }
-  return ret;
-#else
-
-  if(lpDistanceToMoveHigh)
-    *lpDistanceToMoveHigh = 0;
-  pos = OSLibDosSetFilePtr2(pHMHandleData->hHMHandle, lDistanceToMove, dwMoveMethod);
-  return pos;
-#endif
-}
-
-
-/*****************************************************************************
- * Name      : DWORD HMDeviceOpen32Class::LockFile
- * Purpose   : file locking
- * Parameters: PHMHANDLEDATA pHMHandleData
- *             DWORD arg2
- *             DWORD arg3
- *             DWORD arg4
- *             DWORD arg5
- * Variables :
- * Result    : API returncode
- * Remark    :
- * Status    :
- *
- * Author    : Patrick Haller [Wed, 1999/06/17 20:44]
- *****************************************************************************/
-
-DWORD HMDeviceOpen32Class::LockFile(PHMHANDLEDATA pHMHandleData,
-                                    DWORD         arg2,
-                                    DWORD         arg3,
-                                    DWORD         arg4,
-                                    DWORD         arg5)
-{
-  dprintfl(("KERNEL32: HandleManager::Open32::LockFile %s(%08xh,%08xh,%08xh,%08xh,%08xh)\n",
-           lpHMDeviceName,
-           pHMHandleData,
-           arg2,
-           arg3,
-           arg4,
-           arg5));
-
-  return O32_LockFile(pHMHandleData->hHMHandle,
-                      arg2,
-                      arg3,
-                      arg4,
-                      arg5);
-}
-
-
-
-/*****************************************************************************
- * Name      : DWORD HMDeviceOpen32Class::LockFileEx
- * Purpose   : file locking
- * Parameters: PHMHANDLEDATA pHMHandleData
- *             DWORD dwFlags
- *             DWORD dwReserved
- *             DWORD nNumberOfBytesToLockLow
- *             DWORD nNumberOfBytesToLockHigh
- *             LPOVERLAPPED lpOverlapped
- * Variables :
- * Result    : API returncode
- * Remark    :
- * Status    :
- *
- * Author    : Patrick Haller [Wed, 1999/06/17 20:44]
- *****************************************************************************/
-
-DWORD HMDeviceOpen32Class::LockFileEx(PHMHANDLEDATA pHMHandleData,
-                                      DWORD         dwFlags,
-                                      DWORD         dwReserved,
-                                      DWORD         nNumberOfBytesToLockLow,
-                                      DWORD         nNumberOfBytesToLockHigh,
-                                      LPOVERLAPPED  lpOverlapped)
-{
-
-  dprintfl(("KERNEL32: HandleManager::Open32::LockFileEx %s(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh)\n",
-           lpHMDeviceName,
-           pHMHandleData,
-           dwFlags,
-           dwReserved,
-           nNumberOfBytesToLockLow,
-           nNumberOfBytesToLockHigh,
-           lpOverlapped));
-
-
-  return(O32_LockFile(pHMHandleData->hHMHandle,
-                      lpOverlapped->Offset,
-                      lpOverlapped->OffsetHigh,
-                      nNumberOfBytesToLockLow,
-                      nNumberOfBytesToLockHigh));
-}
-
-
-/*****************************************************************************
- * Name      : DWORD HMDeviceOpen32Class::OpenFile
- * Purpose   : this is called from the handle manager if a OpenFile() is
- *             performed on a handle
- * Parameters: LPCSTR        lpFileName            name of the file / device
- *             PHMHANDLEDATA pHMHandleData         data of the NEW handle
- *             PVOID         lpSecurityAttributes  ignored
- *             PHMHANDLEDATA pHMHandleDataTemplate data of the template handle
- * Variables :
- * Result    :
- * Remark    :
- * Status    : NO_ERROR - API succeeded
- *             other    - what is to be set in SetLastError
- *
- * Author    : Patrick Haller [Wed, 1998/02/11 20:44]
- *****************************************************************************/
-
-DWORD HMDeviceOpen32Class::OpenFile (LPCSTR        lpFileName,
-                                     PHMHANDLEDATA pHMHandleData,
-                                     OFSTRUCT      *pOFStruct,
-                                     UINT          fuMode)
-{
-  HFILE hFile;
-  FILETIME filetime;
-  WORD filedatetime[2];
-  char filepath[260];
-
-  dprintfl(("KERNEL32: HandleManager::Open32::OpenFile %s(%s,%08x,%08x,%08x) - stub?\n",
-           lpHMDeviceName,
-           lpFileName,
-           pHMHandleData,
-           pOFStruct,
-           fuMode));
-
-  if(strcmp(lpFileName,       // "support" for local unc names
-             "\\\\.\\") == 0)
-  {
-    lpFileName+=4;
-  }
-  else 
-  if(!strchr(lpFileName, ':') && !strchr(lpFileName, '\\')) 
-  {
-	//filename only; search for file in following order
-	//1: dir from which the app loaded
-	//2: current dir
-	//3: windows system dir
-	//4: windows dir
-	//5: dirs in path path environment variable
-	//SearchPath does exactly that
-	LPSTR filenameinpath;
-
-	if(SearchPathA(NULL, lpFileName, NULL, sizeof(filepath), filepath, &filenameinpath) == 0
-           && !(fuMode & OF_CREATE) ) {
-		SetLastError(ERROR_FILE_NOT_FOUND);
-		return HFILE_ERROR;
-	}
-	lpFileName = filepath;
-  }
-  // filling OFSTRUCT
-  memset(pOFStruct, 0, sizeof(OFSTRUCT));
-  pOFStruct->cBytes = sizeof(OFSTRUCT);
-  pOFStruct->nErrCode = 0;
-  strncpy((char *)pOFStruct->szPathName, lpFileName, OFS_MAXPATHNAME - 1);
-
-  hFile = O32_OpenFile(lpFileName,
-                       pOFStruct,
-                       fuMode);
-  if (hFile != INVALID_HANDLE_ERROR)
-  {
-    pHMHandleData->hHMHandle = hFile;
-
-    GetFileTime(pHMHandleData,
-                NULL,
-                NULL,
-                &filetime );
-    FileTimeToDosDateTime(&filetime,
-                          &filedatetime[0],
-                          &filedatetime[1] );
-    memcpy(pOFStruct->reserved,
-           filedatetime,
-           sizeof(pOFStruct->reserved) );
-
-    return (NO_ERROR);
-  }
-
-  // error branch
-  pOFStruct->nErrCode = O32_GetLastError();
-  dprintf(("KERNEL32: HandleManager::Open32::OpenFile Error %08xh\n",
-            pOFStruct->nErrCode));
-
-  // return != NO_ERROR => error code
-  return(hFile);
-}
-
-
-/*****************************************************************************
- * Name      : DWORD HMDeviceOpen32Class::UnlockFile
- * Purpose   : file locking
- * Parameters: PHMHANDLEDATA pHMHandleData
- *             DWORD arg2
- *             DWORD arg3
- *             DWORD arg4
- *             DWORD arg5
- * Variables :
- * Result    : API returncode
- * Remark    :
- * Status    :
- *
- * Author    : Patrick Haller [Wed, 1999/06/17 20:44]
- *****************************************************************************/
-
-DWORD HMDeviceOpen32Class::UnlockFile(PHMHANDLEDATA pHMHandleData,
-                                      DWORD         arg2,
-                                      DWORD         arg3,
-                                      DWORD         arg4,
-                                      DWORD         arg5)
-{
-  dprintfl(("KERNEL32: HandleManager::Open32::UnlockFile %s(%08xh,%08xh,%08xh,%08xh,%08xh)\n",
-           lpHMDeviceName,
-           pHMHandleData,
-           arg2,
-           arg3,
-           arg4,
-           arg5));
-
-  return O32_UnlockFile(pHMHandleData->hHMHandle,
-                        arg2,
-                        arg3,
-                        arg4,
-                        arg5);
-}
-
-
-
-/*****************************************************************************
- * Name      : DWORD HMDeviceOpen32Class::UnlockFileEx
- * Purpose   : file locking
- * Parameters: PHMHANDLEDATA pHMHandleData
- *             DWORD dwFlags
- *             DWORD dwReserved
- *             DWORD nNumberOfBytesToLockLow
- *             DWORD nNumberOfBytesToLockHigh
- *             LPOVERLAPPED lpOverlapped
- * Variables :
- * Result    : API returncode
- * Remark    :
- * Status    :
- *
- * Author    : Patrick Haller [Wed, 1999/06/17 20:44]
- *****************************************************************************/
-
-DWORD HMDeviceOpen32Class::UnlockFileEx(PHMHANDLEDATA pHMHandleData,
-                                        DWORD         dwFlags,
-                                        DWORD         dwReserved,
-                                        DWORD         nNumberOfBytesToLockLow,
-                                        DWORD         nNumberOfBytesToLockHigh,
-                                        LPOVERLAPPED  lpOverlapped)
-{
-
-  dprintfl(("KERNEL32: HandleManager::Open32::UnlockFileEx %s(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh)\n",
-           lpHMDeviceName,
-           pHMHandleData,
-           dwFlags,
-           dwReserved,
-           nNumberOfBytesToLockLow,
-           nNumberOfBytesToLockHigh,
-           lpOverlapped));
-
-  return(O32_UnlockFile(pHMHandleData->hHMHandle,
-                   lpOverlapped->Offset,
-                   lpOverlapped->OffsetHigh,
-                   nNumberOfBytesToLockLow,
-                   nNumberOfBytesToLockHigh));
-}
-
 
 /*****************************************************************************
@@ -955,56 +247,2 @@
 }
 
-
-/*****************************************************************************
- * Name      : DWORD HMDeviceOpen32Class::FlushFileBuffers
- * Purpose   : flush the buffers of a file
- * Parameters: PHMHANDLEDATA pHMHandleData
- * Variables :
- * Result    : API returncode
- * Remark    :
- * Status    :
- *
- * Author    : Patrick Haller [Wed, 1999/06/17 20:44]
- *****************************************************************************/
-
-BOOL HMDeviceOpen32Class::FlushFileBuffers(PHMHANDLEDATA pHMHandleData)
-{
-  dprintfl(("KERNEL32: HandleManager::Open32:FlushFileBuffers(%08xh)\n",
-            pHMHandleData->hHMHandle));
-
-  return(O32_FlushFileBuffers(pHMHandleData->hHMHandle));
-}
-
-
-/*****************************************************************************
- * Name      : DWORD HMDeviceOpen32Class::GetOverlappedResult
- * Purpose   : asynchronus I/O
- * Parameters: PHMHANDLEDATA pHMHandleData
- *             LPOVERLAPPED  arg2
- *             LPDWORD       arg3
- *             BOOL          arg4
- * Variables :
- * Result    : API returncode
- * Remark    :
- * Status    :
- *
- * Author    : Patrick Haller [Wed, 1999/06/17 20:44]
- *****************************************************************************/
-
-BOOL HMDeviceOpen32Class::GetOverlappedResult(PHMHANDLEDATA pHMHandleData,
-                                              LPOVERLAPPED  arg2,
-                                              LPDWORD       arg3,
-                                              BOOL          arg4)
-{
-  dprintfl(("KERNEL32: HandleManager::Open32::GetOverlappedResult(%08xh,%08xh,%08xh,%08xh)\n",
-            pHMHandleData->hHMHandle,
-            arg2,
-            arg3,
-            arg4));
-
-  return(O32_GetOverlappedResult(pHMHandleData->hHMHandle,
-                                 arg2,
-                                 arg3,
-                                 arg4));
-}
-
Index: trunk/src/kernel32/hmopen32.h
===================================================================
--- trunk/src/kernel32/hmopen32.h	(revision 3641)
+++ trunk/src/kernel32/hmopen32.h	(revision 3642)
@@ -1,3 +1,3 @@
-/* $Id: hmopen32.h,v 1.5 2000-05-22 19:07:56 sandervl Exp $ */
+/* $Id: hmopen32.h,v 1.6 2000-06-01 11:28:47 sandervl Exp $ */
 
 /*
@@ -50,32 +50,6 @@
                                DWORD   fdwOptions);
 
-                       /* this is a handler method for calls to CreateFile() */
-  virtual DWORD  CreateFile (LPCSTR        lpFileName,
-                             PHMHANDLEDATA pHMHandleData,
-                             PVOID         lpSecurityAttributes,
-                             PHMHANDLEDATA pHMHandleDataTemplate);
-
-                       /* this is a handler method for calls to   OpenFile() */
-  virtual DWORD  OpenFile   (LPCSTR        lpFileName,
-                             PHMHANDLEDATA pHMHandleData,
-                             OFSTRUCT*     pOFStruct,
-                             UINT          fuMode);
-
                       /* this is a handler method for calls to CloseHandle() */
   virtual DWORD  CloseHandle(PHMHANDLEDATA pHMHandleData);
-
-                           /* this is a handler method for calls to ReadFile() */
-  virtual BOOL   ReadFile   (PHMHANDLEDATA pHMHandleData,
-                             LPCVOID       lpBuffer,
-                             DWORD         nNumberOfBytesToRead,
-                             LPDWORD       lpNumberOfBytesRead,
-                             LPOVERLAPPED  lpOverlapped);
-
-                        /* this is a handler method for calls to WriteFile() */
-  virtual BOOL   WriteFile  (PHMHANDLEDATA pHMHandleData,
-                             LPCVOID       lpBuffer,
-                             DWORD         nNumberOfBytesToWrite,
-                             LPDWORD       lpNumberOfBytesWritten,
-                             LPOVERLAPPED  lpOverlapped);
 
                       /* this is a handler method for calls to GetFileType() */
@@ -85,59 +59,4 @@
   virtual DWORD GetFileInformationByHandle(PHMHANDLEDATA pHMHandleData,
                                            BY_HANDLE_FILE_INFORMATION* pHFI);
-
-                     /* this is a handler method for calls to SetEndOfFile() */
-  virtual BOOL  SetEndOfFile(PHMHANDLEDATA pHMHandleData);
-
-                      /* this is a handler method for calls to SetFileTime() */
-  virtual BOOL  SetFileTime (PHMHANDLEDATA pHMHandleData,
-                             LPFILETIME    pFT1,
-                             LPFILETIME    pFT2,
-                             LPFILETIME    pFT3);
-
-                      /* this is a handler method for calls to GetFileTime() */
-  virtual BOOL  GetFileTime (PHMHANDLEDATA pHMHandleData,
-                             LPFILETIME    pFT1,
-                             LPFILETIME    pFT2,
-                             LPFILETIME    pFT3);
-
-                      /* this is a handler method for calls to GetFileSize() */
-  virtual DWORD GetFileSize(PHMHANDLEDATA pHMHandleData,
-                            PDWORD        pSizeHigh);
-
-                   /* this is a handler method for calls to SetFilePointer() */
-  virtual DWORD SetFilePointer(PHMHANDLEDATA pHMHandleData,
-                               LONG          lDistanceToMove,
-                               PLONG         lpDistanceToMoveHigh,
-                               DWORD         dwMoveMethod);
-
-                         /* this is a handler method for calls to LockFile() */
-  virtual DWORD LockFile(PHMHANDLEDATA pHMHandleData,
-                         DWORD         arg2,
-                         DWORD         arg3,
-                         DWORD         arg4,
-                         DWORD         arg5);
-
-                       /* this is a handler method for calls to LockFileEx() */
-  virtual DWORD LockFileEx(PHMHANDLEDATA pHMHandleData,
-                           DWORD         dwFlags,
-                           DWORD         dwReserved,
-                           DWORD         nNumberOfBytesToLockLow,
-                           DWORD         nNumberOfBytesToLockHigh,
-                           LPOVERLAPPED  lpOverlapped);
-
-                       /* this is a handler method for calls to UnlockFile() */
-  virtual DWORD UnlockFile(PHMHANDLEDATA pHMHandleData,
-                           DWORD         arg2,
-                           DWORD         arg3,
-                           DWORD         arg4,
-                           DWORD         arg5);
-
-                     /* this is a handler method for calls to UnlockFileEx() */
-  virtual DWORD UnlockFileEx(PHMHANDLEDATA pHMHandleData,
-                             DWORD         dwFlags,
-                             DWORD         dwReserved,
-                             DWORD         nNumberOfBytesToLockLow,
-                             DWORD         nNumberOfBytesToLockHigh,
-                             LPOVERLAPPED  lpOverlapped);
 
                 /* this is a handler method for calls to WaitForSingleObject */
@@ -149,13 +68,4 @@
                                       DWORD  dwTimeout,
                                       BOOL   fAlertable);
-
-                   /* this is a handler method for calls to FlushFileBuffers */
-  virtual BOOL FlushFileBuffers(PHMHANDLEDATA pHMHandleData);
-
-                /* this is a handler method for calls to GetOverlappedResult */
-  virtual BOOL GetOverlappedResult(PHMHANDLEDATA pHMHandleData,
-                                   LPOVERLAPPED  arg2,
-                                   LPDWORD       arg3,
-                                   BOOL          arg4);
 };
 
Index: trunk/src/kernel32/initterm.cpp
===================================================================
--- trunk/src/kernel32/initterm.cpp	(revision 3641)
+++ trunk/src/kernel32/initterm.cpp	(revision 3642)
@@ -1,3 +1,3 @@
-/* $Id: initterm.cpp,v 1.41 2000-04-29 18:26:59 sandervl Exp $ */
+/* $Id: initterm.cpp,v 1.42 2000-06-01 11:28:47 sandervl Exp $ */
 
 /*
@@ -154,4 +154,5 @@
                 flAllocMem = PAG_ANY;      // high memory support. Let's use it!
                 ulMaxAddr = ulSysinfo * (1024*1024);
+		OSLibInitWSeBFileIO();
             }
             else
Index: trunk/src/kernel32/makefile
===================================================================
--- trunk/src/kernel32/makefile	(revision 3641)
+++ trunk/src/kernel32/makefile	(revision 3642)
@@ -1,3 +1,3 @@
-# $Id: makefile,v 1.94 2000-05-02 20:53:13 sandervl Exp $
+# $Id: makefile,v 1.95 2000-06-01 11:28:47 sandervl Exp $
 
 #
@@ -72,4 +72,5 @@
 $(OBJDIR)\hmobjects.obj \
 $(OBJDIR)\hmevent.obj \
+$(OBJDIR)\hmfile.obj \
 $(OBJDIR)\hmmutex.obj \
 $(OBJDIR)\hmcomm.obj \
Index: trunk/src/kernel32/oslibdos.cpp
===================================================================
--- trunk/src/kernel32/oslibdos.cpp	(revision 3641)
+++ trunk/src/kernel32/oslibdos.cpp	(revision 3642)
@@ -1,3 +1,3 @@
-/* $Id: oslibdos.cpp,v 1.28 2000-05-23 18:45:12 sandervl Exp $ */
+/* $Id: oslibdos.cpp,v 1.29 2000-06-01 11:28:47 sandervl Exp $ */
 /*
  * Wrappers for OS/2 Dos* API
@@ -33,4 +33,65 @@
 #include "dbglocal.h"
 
+static PROC_DosSetFileSizeL  DosSetFileSizeLProc = 0;
+static PROC_DosSetFilePtrL   DosSetFilePtrLProc   = 0;
+static PROC_DosSetFileLocksL DosSetFileLocksLProc = 0;
+static BOOL f64BitIO = FALSE;
+//******************************************************************************
+//******************************************************************************
+void OSLibInitWSeBFileIO()
+{ 
+ HMODULE hDoscalls;
+
+  if(DosQueryModuleHandle("DOSCALLS", &hDoscalls) != NO_ERROR) {
+	return;
+  }
+  if(DosQueryProcAddr(hDoscalls, 989, NULL, (PFN *)&DosSetFileSizeLProc) != NO_ERROR) {
+	return;
+  }
+  if(DosQueryProcAddr(hDoscalls, 988, NULL, (PFN *)&DosSetFilePtrLProc) != NO_ERROR) {
+	return;
+  }
+  if(DosQueryProcAddr(hDoscalls, 986, NULL, (PFN *)&DosSetFileLocksLProc) != NO_ERROR) {
+	return;
+  }
+  f64BitIO = TRUE;
+}
+//******************************************************************************
+//******************************************************************************
+APIRET OdinDosSetFileSizeL(HFILE hFile, LONGLONG cbSize)
+{
+ APIRET yyrc;
+ USHORT sel = RestoreOS2FS();
+
+    yyrc = DosSetFileSizeLProc(hFile, cbSize);
+    SetFS(sel);
+
+    return yyrc;
+}
+//******************************************************************************
+//******************************************************************************
+APIRET OdinDosSetFilePtrL(HFILE hFile, LONGLONG ib, ULONG method, PLONGLONG ibActual)
+{
+ APIRET yyrc;
+ USHORT sel = RestoreOS2FS();
+
+    yyrc = DosSetFilePtrLProc(hFile, ib, method, ibActual);
+    SetFS(sel);
+
+    return yyrc;
+}
+//******************************************************************************
+//******************************************************************************
+APIRET OdinDosSetFileLocksL(HFILE hFile, PFILELOCKL pflUnlock, PFILELOCKL pflLock,
+                            ULONG timeout, ULONG flags)
+{
+ APIRET yyrc;
+ USHORT sel = RestoreOS2FS();
+
+    yyrc = DosSetFileLocksLProc(hFile, pflUnlock, pflLock, timeout, flags);
+    SetFS(sel);
+
+    return yyrc;
+}
 //******************************************************************************
 // translate OS/2 error codes to Windows codes
@@ -42,86 +103,135 @@
   {
     case NO_ERROR: //0
-      return ERROR_SUCCESS_W;
+      	return ERROR_SUCCESS_W;
+
+    case ERROR_INVALID_FUNCTION: //1
+        return ERROR_INVALID_FUNCTION_W;
 
     case ERROR_FILE_NOT_FOUND: //2
-      return ERROR_FILE_NOT_FOUND_W;
+      	return ERROR_FILE_NOT_FOUND_W;
 
     case ERROR_PATH_NOT_FOUND: //3
-      return ERROR_PATH_NOT_FOUND_W;
+      	return ERROR_PATH_NOT_FOUND_W;
+
+    case ERROR_TOO_MANY_OPEN_FILES: //4
+      	return ERROR_TOO_MANY_OPEN_FILES_W;
 
     case ERROR_ACCESS_DENIED: //5
-      return ERROR_ACCESS_DENIED_W;
+      	return ERROR_ACCESS_DENIED_W;
 
     case ERROR_INVALID_HANDLE: //6
-      return ERROR_INVALID_HANDLE_W;
+      	return ERROR_INVALID_HANDLE_W;
 
     case ERROR_NOT_ENOUGH_MEMORY: //8
-      return ERROR_NOT_ENOUGH_MEMORY_W;
+      	return ERROR_NOT_ENOUGH_MEMORY_W;
 
     case ERROR_BAD_FORMAT: //11
-      return ERROR_BAD_FORMAT_W;
+      	return ERROR_BAD_FORMAT_W;
+ 
+    case ERROR_INVALID_ACCESS: //12
+     	return ERROR_INVALID_ACCESS_W;
 
     case ERROR_NO_MORE_FILES: //18
-      return ERROR_NO_MORE_FILES_W;
+      	return ERROR_NO_MORE_FILES_W;
+
+    case ERROR_WRITE_PROTECT: //19
+        return ERROR_WRITE_PROTECT_W;
 
     case ERROR_NOT_DOS_DISK: //26
-      return ERROR_NOT_DOS_DISK_W;
+      	return ERROR_NOT_DOS_DISK_W;
+
+    case ERROR_WRITE_FAULT: //29
+        return ERROR_WRITE_FAULT_W;
+
+    case ERROR_SHARING_VIOLATION: //32
+       	return ERROR_SHARING_VIOLATION_W;
+
+    case ERROR_LOCK_VIOLATION: //32
+       	return ERROR_LOCK_VIOLATION_W;
+
+    case ERROR_SHARING_BUFFER_EXCEEDED: //36
+       	return ERROR_SHARING_BUFFER_EXCEEDED_W;
+
+    case ERROR_CANNOT_MAKE: //82
+        return ERROR_CANNOT_MAKE_W;
 
     case ERROR_OUT_OF_STRUCTURES: //84
-      return ERROR_OUT_OF_STRUCTURES_W;
+      	return ERROR_OUT_OF_STRUCTURES_W;
 
     case ERROR_INVALID_PARAMETER: //87
-      return ERROR_INVALID_PARAMETER_W;
+      	return ERROR_INVALID_PARAMETER_W;
 
     case ERROR_INTERRUPT: //95
-      return ERROR_INVALID_AT_INTERRUPT_TIME_W; //CB: right???
+      	return ERROR_INVALID_AT_INTERRUPT_TIME_W; //CB: right???
+
+    case ERROR_DEVICE_IN_USE: //99
+	return ERROR_DEVICE_IN_USE_W;
 
     case ERROR_DRIVE_LOCKED: //108
-      return ERROR_DRIVE_LOCKED_W;
+      	return ERROR_DRIVE_LOCKED_W;
 
     case ERROR_BROKEN_PIPE: //109
-      return ERROR_BROKEN_PIPE_W;
+      	return ERROR_BROKEN_PIPE_W;
+
+    case ERROR_OPEN_FAILED: //110
+	return ERROR_OPEN_FAILED_W;
 
     case ERROR_BUFFER_OVERFLOW: //111
-      return ERROR_BUFFER_OVERFLOW_W;
+      	return ERROR_BUFFER_OVERFLOW_W;
+
+    case ERROR_DISK_FULL: //112
+	return ERROR_DISK_FULL_W;
 
     case ERROR_NO_MORE_SEARCH_HANDLES: //113
-      return ERROR_NO_MORE_SEARCH_HANDLES_W;
+      	return ERROR_NO_MORE_SEARCH_HANDLES_W;
 
     case ERROR_SEM_TIMEOUT: //121
-      return ERROR_SEM_TIMEOUT_W;
+      	return ERROR_SEM_TIMEOUT_W;
+
+    case ERROR_DIRECT_ACCESS_HANDLE: //130
+        return ERROR_DIRECT_ACCESS_HANDLE_W;
+
+    case ERROR_NEGATIVE_SEEK: //131
+        return ERROR_NEGATIVE_SEEK;
+
+    case ERROR_SEEK_ON_DEVICE: //132
+        return ERROR_SEEK_ON_DEVICE_W;
 
     case ERROR_DISCARDED: //157
-      return ERROR_DISCARDED_W;
+      	return ERROR_DISCARDED_W;
 
     case ERROR_FILENAME_EXCED_RANGE: //206
-      return ERROR_FILENAME_EXCED_RANGE_W;
+      	return ERROR_FILENAME_EXCED_RANGE_W;
 
     case ERROR_META_EXPANSION_TOO_LONG: //208
-      return ERROR_META_EXPANSION_TOO_LONG_W;
+      	return ERROR_META_EXPANSION_TOO_LONG_W;
 
     case ERROR_BAD_PIPE: //230
-      return ERROR_BAD_PIPE_W;
+      	return ERROR_BAD_PIPE_W;
 
     case ERROR_PIPE_BUSY: //231
-      return ERROR_PIPE_BUSY_W;
+      	return ERROR_PIPE_BUSY_W;
+
+    case ERROR_NO_DATA: //232
+      	return ERROR_NO_DATA_W;
 
     case ERROR_PIPE_NOT_CONNECTED: //233
-      return ERROR_PIPE_NOT_CONNECTED_W;
+      	return ERROR_PIPE_NOT_CONNECTED_W;
 
     case ERROR_MORE_DATA: //234
-      return ERROR_MORE_DATA_W;
+      	return ERROR_MORE_DATA_W;
 
     case ERROR_INVALID_EA_NAME: //254
-      return ERROR_INVALID_EA_NAME_W;
+      	return ERROR_INVALID_EA_NAME_W;
 
     case ERROR_EA_LIST_INCONSISTENT: //255
-      return ERROR_EA_LIST_INCONSISTENT_W;
+      	return ERROR_EA_LIST_INCONSISTENT_W;
 
     case ERROR_EAS_DIDNT_FIT: //275
-      return ERROR_EAS_DIDNT_FIT;
+      	return ERROR_EAS_DIDNT_FIT;
 
     default:
-      return defaultCode;
+    	dprintf(("WARNING: error2WinError: error %d not included!!!!", rc));
+      	return defaultCode;
   }
 }
@@ -382,13 +492,21 @@
 //******************************************************************************
 //******************************************************************************
-DWORD OSLibDosRead(DWORD hFile, LPVOID lpBuffer, DWORD size, DWORD *nrBytesRead)
-{
-  return DosRead(hFile, lpBuffer, size, nrBytesRead);
-}
-//******************************************************************************
-//******************************************************************************
-DWORD OSLibDosWrite(DWORD hFile, LPVOID lpBuffer, DWORD size, DWORD *nrBytesWritten)
-{
-  return DosWrite(hFile, lpBuffer, size, nrBytesWritten);
+BOOL OSLibDosRead(DWORD hFile, LPVOID lpBuffer, DWORD size, DWORD *nrBytesRead)
+{
+ APIRET rc;
+
+  rc = DosRead(hFile, lpBuffer, size, nrBytesRead);
+  SetLastError(error2WinError(rc));
+  return (rc == NO_ERROR);
+}
+//******************************************************************************
+//******************************************************************************
+BOOL OSLibDosWrite(DWORD hFile, LPVOID lpBuffer, DWORD size, DWORD *nrBytesWritten)
+{
+ APIRET rc;
+
+  rc = DosWrite(hFile, lpBuffer, size, nrBytesWritten);
+  SetLastError(error2WinError(rc));
+  return (rc == NO_ERROR);
 }
 //******************************************************************************
@@ -421,7 +539,14 @@
 //******************************************************************************
 //******************************************************************************
-DWORD OSLibDosDelete(char *lpszFileName)
-{
-  return DosDelete(lpszFileName);
+BOOL OSLibDosDelete(char *lpszFileName)
+{
+ APIRET rc;
+
+  rc = DosDelete(lpszFileName);
+  if(rc) {
+	SetLastError(error2WinError(rc));	
+	return FALSE;
+  }
+  return TRUE;
 }
 //******************************************************************************
@@ -552,105 +677,569 @@
 //******************************************************************************
 //******************************************************************************
-DWORD OSLibDosCreate(CHAR *lpFileName,
-                     DWORD dwAccess,
-                     DWORD dwShare,
-                     LPSECURITY_ATTRIBUTES lpSecurityAttributes,
-                     DWORD dwCreation,
-                     DWORD dwFlags,
-                     HANDLE hTemplate,
-                     DWORD *dwFile)
-{
-   APIRET rc;
-   HFILE  hFile;
-   ULONG  ulAction=0;
-   DWORD  os2Attrib=0;
-   DWORD  os2Flags = 0; //OPEN_FLAGS_NOINHERIT;
-   DWORD  os2Open=0;
-
-    if(dwAccess == (GENERIC_READ_W | GENERIC_WRITE_W))
-      os2Flags |= OPEN_ACCESS_READWRITE;
-    else if(dwAccess & GENERIC_WRITE_W)
-      os2Flags |= OPEN_ACCESS_WRITEONLY;
-    else if(dwAccess & GENERIC_READ_W)
-      os2Flags |= OPEN_ACCESS_READONLY;
-
-    if(dwShare == 0)
-      os2Flags |= OPEN_SHARE_DENYREADWRITE;
-    else if(dwShare == (FILE_SHARE_READ_W | FILE_SHARE_WRITE_W))
-      os2Flags |= OPEN_SHARE_DENYNONE;
-    else if(dwShare & FILE_SHARE_READ_W)
-      os2Flags |= OPEN_SHARE_DENYWRITE;
-    else if(dwShare & FILE_SHARE_WRITE_W)
-      os2Flags |= OPEN_SHARE_DENYREAD;
-
-    if(dwCreation == CREATE_NEW_W)
-      os2Open = OPEN_ACTION_FAIL_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW;
-    else if(dwCreation == CREATE_ALWAYS_W)
-      os2Open = OPEN_ACTION_REPLACE_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW;
-    else if(dwCreation == OPEN_EXISTING_W)
-      os2Open = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW;
-    else if(dwCreation == OPEN_ALWAYS_W)
-      os2Open = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW;
-    else if(dwCreation == TRUNCATE_EXISTING_W)
-      os2Open = OPEN_ACTION_REPLACE_IF_EXISTS;// |OPEN_ACTION_FAIL_IF_NEW;
-
-    if(dwFlags & FILE_ATTRIBUTE_READONLY_W)
-      os2Attrib |= FILE_READONLY;
-    if(dwFlags & FILE_ATTRIBUTE_HIDDEN_W)
-      os2Attrib |= FILE_HIDDEN;
-    if(dwFlags & FILE_ATTRIBUTE_SYSTEM_W)
-      os2Attrib |= FILE_SYSTEM;
-    if(dwFlags & FILE_ATTRIBUTE_DIRECTORY_W)
-      os2Attrib |= FILE_DIRECTORY;
-    if(dwFlags & FILE_ATTRIBUTE_ARCHIVE_W)
-      os2Attrib |= FILE_ARCHIVED;
-    if(dwFlags & FILE_ATTRIBUTE_NORMAL_W)
-      os2Attrib |= FILE_NORMAL;
-
-    if(dwFlags & FILE_FLAG_WRITE_THROUGH_W)
-      os2Flags |= OPEN_FLAGS_WRITE_THROUGH;
-    if(dwFlags & FILE_FLAG_NO_BUFFERING_W)
-      os2Flags |= OPEN_FLAGS_NO_CACHE;
-    if(dwFlags & FILE_FLAG_RANDOM_ACCESS_W)
-      os2Flags |= OPEN_FLAGS_RANDOM;
-    if(dwFlags & FILE_FLAG_SEQUENTIAL_SCAN_W)
-      os2Flags |= OPEN_FLAGS_SEQUENTIAL;
-
-    // TODO:
-    // if(dwFlags & FILE_FLAG_OVERLAPPED_W)
-    // if(dwFlags & FILE_FLAG_DELETE_ON_CLOSE_W
-
-    rc = DosOpen(lpFileName, &hFile, &ulAction, 0,
-                 os2Attrib, os2Open, os2Flags, 0);
-
-    if(rc)
-    {
-      // TODO: TEST TEST
-      dprintf(("DosOpen Error rc:%d, try without GENERIC_WRITE_W", rc));
-      if(dwAccess & GENERIC_WRITE_W)
-        os2Flags &= ~(OPEN_ACCESS_READWRITE | OPEN_ACCESS_WRITEONLY);
-      rc = DosOpen(lpFileName, &hFile, &ulAction, 0,
-                   os2Attrib, os2Open, os2Flags, 0);
-      if(rc)
-      {
-        dprintf(("DosOpen Error rc:%d os2Attrib:%X os2Open:%X os2Flags:%X",
-                 rc, os2Attrib, os2Open, os2Flags));
-        hFile = -1;
-      }
-    }
-
-    *dwFile = hFile;
-    return rc;
-}
-//******************************************************************************
-//(without changing file pointer)
-//******************************************************************************
-DWORD OSLibDosGetFileSize(DWORD hFile)
-{
-  FILESTATUS3  fsts3ConfigInfo = {{0}};
-  ULONG        ulBufSize     = sizeof(FILESTATUS3);
-
-  DosQueryFileInfo(hFile, FIL_STANDARD, &fsts3ConfigInfo, ulBufSize);
-  return fsts3ConfigInfo.cbFile;
+APIRET OSLibDosQueryPathInfo(PSZ   pszPathName,
+                             ULONG ulInfoLevel,
+                             PVOID pInfoBuf,
+                             ULONG cbInfoBuf)
+{
+   APIRET rc = DosQueryPathInfo( pszPathName, ulInfoLevel,
+                                 pInfoBuf, cbInfoBuf );
+
+   if(rc == ERROR_TOO_MANY_OPEN_FILES)
+   {
+      	LONG  reqCount = 2;
+      	ULONG maxFiles;
+
+      	if(DosSetRelMaxFH(&reqCount, &maxFiles) == NO_ERROR)
+         	rc = DosQueryPathInfo(pszPathName, ulInfoLevel,
+                                      pInfoBuf, cbInfoBuf );
+   }
+   return rc;
+}
+//******************************************************************************
+//******************************************************************************
+DWORD OSLibDosCreateFile(CHAR *lpszFile,
+                         DWORD fuAccess,
+                         DWORD fuShare,
+                         LPSECURITY_ATTRIBUTES lpSecurityAttributes,
+                         DWORD fuCreate,
+                         DWORD fuAttrFlags,
+                         HANDLE hTemplateFile)
+{
+   HFILE   hFile;
+   ULONG   actionTaken = 0;
+   ULONG   fileSize = 0;
+   ULONG   fileAttr = FILE_NORMAL;
+   ULONG   openFlag = 0;
+   ULONG   openMode = 0;
+   APIRET  rc = ERROR_NOT_ENOUGH_MEMORY;;
+
+   //TODO: lpSecurityAttributes (inheritance)
+
+   if(fuAttrFlags & FILE_ATTRIBUTE_ARCHIVE_W)
+      	fileAttr |= FILE_ARCHIVED;
+   if(fuAttrFlags & FILE_ATTRIBUTE_HIDDEN_W)
+        fileAttr |= FILE_HIDDEN;
+   if(fuAttrFlags & FILE_ATTRIBUTE_SYSTEM_W)
+        fileAttr |= FILE_SYSTEM;
+   if(fuAttrFlags & FILE_ATTRIBUTE_READONLY_W)
+        fileAttr |= FILE_READONLY;
+   // TODO: FILE_ATTRIBUTE_TEMPORARY_W
+
+   switch(fuCreate)
+   {
+   case CREATE_NEW_W:
+	openFlag |= OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_FAIL_IF_EXISTS;
+        break;
+   case CREATE_ALWAYS_W:
+        openFlag |= OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS;
+        break;
+   case OPEN_EXISTING_W:
+        openFlag |= OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS;
+        break;
+   case OPEN_ALWAYS_W:
+        openFlag |= OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS;
+        break;
+   case TRUNCATE_EXISTING_W:
+        openFlag |= OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS;
+        break;
+   }
+
+   if(fuAttrFlags & FILE_FLAG_WRITE_THROUGH_W)   openMode |= OPEN_FLAGS_WRITE_THROUGH;
+   if(fuAttrFlags & FILE_FLAG_NO_BUFFERING_W)    openMode |= OPEN_FLAGS_NO_CACHE;
+   if(fuAttrFlags & FILE_FLAG_RANDOM_ACCESS_W)   openMode |= OPEN_FLAGS_RANDOM;
+   if(fuAttrFlags & FILE_FLAG_SEQUENTIAL_SCAN_W) openMode |= OPEN_FLAGS_SEQUENTIAL;
+   // TODO: FILE_FLAG_BACKUP_SEMANTICS_W
+   //       FILE_FLAG_POSIX_SEMANTICS_W are not supported
+
+   if(fuShare == 0)
+	openMode |= OPEN_SHARE_DENYREADWRITE;
+   else 
+   if(fuShare == (FILE_SHARE_READ_W | FILE_SHARE_WRITE_W))
+      	openMode |= OPEN_SHARE_DENYNONE;
+   else 
+   if(fuShare & FILE_SHARE_READ_W)          
+        openMode |= OPEN_SHARE_DENYWRITE;
+   else 
+   if(fuShare & FILE_SHARE_WRITE_W)
+ 	openMode |= OPEN_SHARE_DENYREAD;
+
+   if(fuAccess == (GENERIC_READ_W | GENERIC_WRITE_W))
+	openMode |= OPEN_ACCESS_READWRITE;
+   else 
+   if(fuAccess & GENERIC_READ_W)            
+	openMode |= OPEN_ACCESS_READONLY;
+   else
+   if(fuAccess & GENERIC_WRITE_W)
+       	openMode |= OPEN_ACCESS_WRITEONLY;
+
+   int retry = 0;
+   while(retry < 2) 
+   {
+        rc = DosOpen((PSZ)lpszFile,
+                      &hFile,
+                      &actionTaken,
+                      fileSize,
+                      fileAttr,
+                      openFlag,
+                      openMode,
+                      NULL);
+  	if(rc == ERROR_TOO_MANY_OPEN_FILES) 
+        {
+   	  ULONG CurMaxFH;
+   	  LONG  ReqCount = 32;
+
+		rc = DosSetRelMaxFH(&ReqCount, &CurMaxFH);
+		if(rc) {
+			dprintf(("DosSetRelMaxFH returned %d", rc));
+			SetLastError(ERROR_TOO_MANY_OPEN_FILES_W);
+			return INVALID_HANDLE_VALUE_W;
+		}
+		dprintf(("DosOpen failed -> increased nr open files to %d", CurMaxFH));
+  	}
+	else	break;
+	retry++;
+   }
+
+   if(rc)
+   {
+      SetLastError(error2WinError(rc));
+      return INVALID_HANDLE_VALUE_W;
+   }
+   SetLastError(ERROR_SUCCESS_W);
+   return hFile;
+}
+//******************************************************************************
+//******************************************************************************
+DWORD OSLibDosOpenFile(CHAR *lpszFile, UINT fuMode)
+{
+   ULONG   actionTaken = 0;
+   ULONG   fileSize = 0;
+   ULONG   fileAttr = FILE_NORMAL;
+   ULONG   openFlag = 0;
+   ULONG   openMode = 0;
+   APIRET  rc = ERROR_NOT_ENOUGH_MEMORY;
+   HFILE   hFile;
+
+   if(!(fuMode & (OF_CREATE_W | OF_READWRITE_W | OF_WRITE_W)))
+   {
+      	openMode |= OPEN_ACCESS_READONLY;
+      	openFlag |= OPEN_ACTION_OPEN_IF_EXISTS;
+   }
+   else
+   {
+       	if(fuMode & OF_CREATE_W) {
+          	openFlag |= OPEN_ACTION_CREATE_IF_NEW |
+                            OPEN_ACTION_REPLACE_IF_EXISTS;
+	}
+       	else    openFlag |= OPEN_ACTION_OPEN_IF_EXISTS;                                //180575
+
+       	if(fuMode & OF_READWRITE_W)
+          	openMode |= OPEN_ACCESS_READWRITE;
+       	else 
+	if(fuMode & OF_WRITE_W)
+          	openMode |= OPEN_ACCESS_WRITEONLY;
+       	else 
+	if(fuMode & OF_CREATE_W)
+          	openMode |= OPEN_ACCESS_READWRITE;
+   }
+
+   if((fuMode & OF_SHARE_DENY_WRITE_W) ||
+      !(fuMode & (OF_SHARE_DENY_READ_W | OF_SHARE_DENY_NONE_W | OF_SHARE_EXCLUSIVE_W)))
+      	openMode |= OPEN_SHARE_DENYWRITE;
+   else 
+   if (fuMode & OF_SHARE_DENY_NONE_W)
+      	openMode |= OPEN_SHARE_DENYNONE;
+   else 
+   if (fuMode & OF_SHARE_DENY_READ_W)
+      	openMode |= OPEN_SHARE_DENYREAD;
+   else 
+   if (fuMode & OF_SHARE_EXCLUSIVE_W)
+      	openMode |= OPEN_SHARE_DENYREADWRITE;
+
+   rc = DosOpen((PSZ)lpszFile,
+                &hFile,
+                &actionTaken,
+                fileSize,
+                fileAttr,
+                openFlag,
+                openMode,
+                NULL);
+
+   if(rc != NO_ERROR)
+   {
+       	if(fuMode & OF_EXIST_W)
+       	{
+          	if(rc == ERROR_OPEN_FAILED || rc == ERROR_FILE_NOT_FOUND)
+          	{
+             		SetLastError(ERROR_FILE_NOT_FOUND_W);
+             		return HFILE_ERROR_W;
+          	}
+       	}
+      	if((rc == ERROR_OPEN_FAILED) && (openFlag & OPEN_ACTION_OPEN_IF_EXISTS))
+      	{
+          	SetLastError(ERROR_FILE_NOT_FOUND_W);
+      	} 
+      	else    SetLastError(error2WinError(rc));
+
+      	return HFILE_ERROR_W;
+   }
+   SetLastError(ERROR_SUCCESS_W);
+   return hFile;
+}
+//******************************************************************************
+//******************************************************************************
+BOOL OSLibDosLockFile(DWORD hFile, DWORD dwFlags,
+                      DWORD OffsetLow, DWORD OffsetHigh,
+                      DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh,
+                      LPOVERLAPPED lpOverlapped)
+{
+  APIRET   rc;
+
+   // Set 5 secs timeout for locking file and no other can access this
+   // file region
+
+   if(lpOverlapped) {//TODO:
+	dprintf(("OSLibDosLockFile: overlapped lock not yet implemented!!"));
+   }
+   //TODO: Locking region crossing end of file is permitted. Works in OS/2??
+   if(f64BitIO) 
+   {
+    FILELOCKL lockRangeL;
+
+ 	lockRangeL.lOffset.ulLo = OffsetLow;
+ 	lockRangeL.lOffset.ulHi = OffsetHigh;
+ 	lockRangeL.lRange.ulLo  = nNumberOfBytesToLockLow;
+ 	lockRangeL.lRange.ulHi  = nNumberOfBytesToLockHigh;
+
+   	rc = OdinDosSetFileLocksL(hFile, NULL, &lockRangeL, 
+                                  (dwFlags & LOCKFILE_FAIL_IMMEDIATELY_W) ? 0 : 5000, 0);
+   }
+   else 
+   {
+    FILELOCK lockRange = { OffsetLow, nNumberOfBytesToLockLow };
+
+   	rc = DosSetFileLocks(hFile, NULL, &lockRange, 
+                             (dwFlags & LOCKFILE_FAIL_IMMEDIATELY_W) ? 0 : 5000, 0);
+   }
+   if(rc) {
+   	SetLastError(error2WinError(rc));
+	return FALSE;
+   }
+   SetLastError(ERROR_SUCCESS_W);
+   return TRUE;
+}
+//******************************************************************************
+//******************************************************************************
+BOOL OSLibDosUnlockFile(DWORD hFile, DWORD OffsetLow, DWORD OffsetHigh,
+                        DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh,
+                        LPOVERLAPPED lpOverlapped)
+{
+  APIRET   rc;
+
+   // Set 5 secs timeout for unlocking file and no other can access this
+   // file region
+
+   if(lpOverlapped) {//TODO:
+	dprintf(("OSLibDosUnlockFile: overlapped unlock not yet implemented!!"));
+   }
+   if(f64BitIO) 
+   {
+    FILELOCKL unlockRangeL;
+
+ 	unlockRangeL.lOffset.ulLo = OffsetLow;
+ 	unlockRangeL.lOffset.ulHi = OffsetHigh;
+ 	unlockRangeL.lRange.ulLo  = nNumberOfBytesToLockLow;
+ 	unlockRangeL.lRange.ulHi  = nNumberOfBytesToLockHigh;
+
+   	rc = OdinDosSetFileLocksL(hFile, &unlockRangeL, NULL, 5000, 0);
+   }
+   else 
+   {
+    FILELOCK unlockRange = { OffsetLow, nNumberOfBytesToLockLow };
+
+        rc = DosSetFileLocks(hFile, &unlockRange, NULL,  5000, 0);
+   }
+   if(rc) {
+   	SetLastError(error2WinError(rc));
+	return FALSE;
+   }
+   SetLastError(ERROR_SUCCESS_W);
+   return TRUE;
+}
+//******************************************************************************
+//******************************************************************************
+BOOL OSLibDosFlushFileBuffers(DWORD hFile)
+{
+  APIRET   rc;
+  
+   rc = DosResetBuffer(hFile);
+   SetLastError(error2WinError(rc));
+   return (rc == NO_ERROR);
+}
+//******************************************************************************
+//******************************************************************************
+DWORD OSLibDosGetFileSize(DWORD hFile, LPDWORD lpdwFileSizeHigh)
+{
+ APIRET rc;
+ ULONG  sizeLow;
+  
+   if(f64BitIO) 
+   {
+     FILESTATUS3L fsts3ConfigInfoL = {{0}};
+     ULONG        ulBufSize       = sizeof(FILESTATUS3L);
+
+   	rc = DosQueryFileInfo(hFile, FIL_STANDARDL, &fsts3ConfigInfoL, ulBufSize);
+   	if(lpdwFileSizeHigh) {
+  		*lpdwFileSizeHigh = fsts3ConfigInfoL.cbFile.ulHi;
+	}
+	sizeLow = fsts3ConfigInfoL.cbFile.ulLo;
+   }
+   else 
+   {
+     FILESTATUS3 fsts3ConfigInfo = {{0}};
+     ULONG       ulBufSize       = sizeof(FILESTATUS3);
+
+   	if(lpdwFileSizeHigh) {
+  		*lpdwFileSizeHigh = 0;
+	}
+   	rc = DosQueryFileInfo(hFile, FIL_STANDARD, &fsts3ConfigInfo, ulBufSize);
+	sizeLow = fsts3ConfigInfo.cbFile;
+   }
+   if(rc) {
+   	SetLastError(error2WinError(rc));
+   	return -1;
+   }
+   SetLastError(ERROR_SUCCESS_W);
+   return sizeLow;
+}
+//******************************************************************************
+//******************************************************************************
+DWORD OSLibDosSetFilePointer(DWORD hFile, DWORD OffsetLow, DWORD *OffsetHigh, DWORD method)
+{
+ LONGLONG offsetL;
+ LONGLONG newoffsetL;
+ APIRET   rc;
+ DWORD    newoffset;
+
+   switch(method) {
+   case FILE_BEGIN_W:
+	method = FILE_BEGIN;
+	break;
+
+   case FILE_CURRENT_W:
+	method = FILE_CURRENT;
+	break;
+
+   case FILE_END_W:
+     	method = FILE_END;
+	break;
+   }
+   if(f64BitIO) {
+	offsetL.ulLo = OffsetLow;
+	offsetL.ulHi = (OffsetHigh) ? *OffsetHigh : 0;
+	rc = OdinDosSetFilePtrL(hFile, offsetL, method, &newoffsetL);
+	if(OffsetHigh) {
+		*OffsetHigh = newoffsetL.ulHi;
+	}
+	newoffset = newoffsetL.ulLo;
+   }
+   else	rc = DosSetFilePtr(hFile, OffsetLow, method, &newoffset);
+   if(rc) {
+   	SetLastError(error2WinError(rc));
+   	return -1;
+   }
+   SetLastError(ERROR_SUCCESS_W);
+   return newoffset;
+}
+//******************************************************************************
+//******************************************************************************
+BOOL OSLibDosSetEndOfFile(DWORD hFile)
+{
+ ULONG    newFilePos;
+ LONGLONG FilePosL = {0,0};
+ LONGLONG newFilePosL;
+ APIRET   rc;
+ 
+   if(f64BitIO) {
+	rc = OdinDosSetFilePtrL(hFile, FilePosL, FILE_CURRENT, &newFilePosL);
+	if(rc == 0) {
+        	rc = OdinDosSetFileSizeL(hFile, newFilePosL);
+	}
+   }
+   else {
+   	rc = DosSetFilePtr(hFile, 0, FILE_CURRENT, &newFilePos);
+	if(rc == 0) {
+        	rc = DosSetFileSize(hFile, newFilePos);
+	}
+   }
+   if(rc) {
+   	SetLastError(error2WinError(rc));
+   	return FALSE;
+   }
+   SetLastError(ERROR_SUCCESS_W);
+   return TRUE;
+}
+//******************************************************************************
+//******************************************************************************
+BOOL OSLibDosGetFileInformationByHandle(DWORD hFile, BY_HANDLE_FILE_INFORMATION* pInfo)
+{
+ APIRET       rc;
+ 
+   if(f64BitIO) 
+   {
+     FILESTATUS4L statusL = { 0 };
+
+   	rc = DosQueryFileInfo(hFile,
+        	              FIL_QUERYEASIZEL,
+                	      &statusL,
+                              sizeof(statusL));
+   	if(rc == NO_ERROR) 
+   	{
+	  	pInfo->dwFileAttributes = 0;
+		if(!(statusL.attrFile & NOT_NORMAL))
+		  	pInfo->dwFileAttributes |= FILE_ATTRIBUTE_NORMAL_W;
+		if(statusL.attrFile & FILE_READONLY)
+		        pInfo->dwFileAttributes |= FILE_ATTRIBUTE_READONLY_W;
+		if(statusL.attrFile & FILE_HIDDEN)
+		        pInfo->dwFileAttributes |= FILE_ATTRIBUTE_HIDDEN_W;
+		if(statusL.attrFile & FILE_SYSTEM)
+		        pInfo->dwFileAttributes |= FILE_ATTRIBUTE_SYSTEM_W;
+		if(statusL.attrFile & FILE_DIRECTORY)
+		        pInfo->dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY_W;
+		if(statusL.attrFile & FILE_ARCHIVED)
+		        pInfo->dwFileAttributes |= FILE_ATTRIBUTE_ARCHIVE_W;
+			
+		pmDateTimeToFileTime(&statusL.fdateCreation,
+	                             &statusL.ftimeCreation,
+	                             &pInfo->ftCreationTime);
+		pmDateTimeToFileTime(&statusL.fdateLastAccess,
+	                             &statusL.ftimeLastAccess,
+	                             &pInfo->ftLastAccessTime);
+		pmDateTimeToFileTime(&statusL.fdateLastWrite,
+	                             &statusL.ftimeLastWrite,
+	                             &pInfo->ftLastWriteTime);
+	
+		pInfo->nFileSizeHigh = statusL.cbFile.ulHi;
+		pInfo->nFileSizeLow  = statusL.cbFile.ulLo;
+		pInfo->dwVolumeSerialNumber = 0; //todo
+		pInfo->nNumberOfLinks = 1;
+		pInfo->nFileIndexHigh = 0;
+		pInfo->nFileIndexLow  = 0;
+	   }
+   }
+   else 
+   {
+     FILESTATUS4  status  = { 0 };
+
+   	rc = DosQueryFileInfo(hFile,
+        	              FIL_QUERYEASIZE,
+                	      &status,
+                              sizeof(status));
+   	if(rc == NO_ERROR) 
+   	{
+	  	pInfo->dwFileAttributes = 0;
+		if(!(status.attrFile & NOT_NORMAL))
+		  	pInfo->dwFileAttributes |= FILE_ATTRIBUTE_NORMAL_W;
+		if(status.attrFile & FILE_READONLY)
+		        pInfo->dwFileAttributes |= FILE_ATTRIBUTE_READONLY_W;
+		if(status.attrFile & FILE_HIDDEN)
+		        pInfo->dwFileAttributes |= FILE_ATTRIBUTE_HIDDEN_W;
+		if(status.attrFile & FILE_SYSTEM)
+		        pInfo->dwFileAttributes |= FILE_ATTRIBUTE_SYSTEM_W;
+		if(status.attrFile & FILE_DIRECTORY)
+		        pInfo->dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY_W;
+		if(status.attrFile & FILE_ARCHIVED)
+		        pInfo->dwFileAttributes |= FILE_ATTRIBUTE_ARCHIVE_W;
+			
+		pmDateTimeToFileTime(&status.fdateCreation,
+	                             &status.ftimeCreation,
+	                             &pInfo->ftCreationTime);
+		pmDateTimeToFileTime(&status.fdateLastAccess,
+	                             &status.ftimeLastAccess,
+	                             &pInfo->ftLastAccessTime);
+		pmDateTimeToFileTime(&status.fdateLastWrite,
+	                             &status.ftimeLastWrite,
+	                             &pInfo->ftLastWriteTime);
+	
+		pInfo->nFileSizeHigh = 0;
+		pInfo->nFileSizeLow = status.cbFile;
+		pInfo->dwVolumeSerialNumber = 0; //todo
+		pInfo->nNumberOfLinks = 1;
+		pInfo->nFileIndexHigh = 0;
+		pInfo->nFileIndexLow = 0;
+	   }
+   }
+   if(rc) {
+      	SetLastError(error2WinError(rc));
+   	return FALSE;
+   }
+   SetLastError(ERROR_SUCCESS_W);
+   return TRUE;
+}
+//******************************************************************************
+//******************************************************************************
+BOOL OSLibDosSetFileTime(DWORD hFile, WORD creationdate, WORD creationtime, 
+                         WORD lastaccessdate, WORD lastaccesstime, 
+                         WORD lastwritedate, WORD lastwritetime)
+{
+  FILESTATUS3 fileInfo;
+  APIRET      rc;
+
+  rc = DosQueryFileInfo(hFile, FIL_STANDARD, &fileInfo, sizeof(fileInfo));
+
+  if(rc == NO_ERROR)
+  {
+	if(creationdate && creationtime) {
+		fileInfo.fdateCreation   = *(FDATE *)&creationdate;
+        	fileInfo.ftimeCreation   = *(FTIME *)&creationtime;
+	}
+	if(lastaccessdate && lastaccesstime) {
+		fileInfo.fdateLastAccess = *(FDATE *)&lastaccessdate;
+        	fileInfo.ftimeLastAccess = *(FTIME *)&lastaccesstime;
+	}
+	if(lastwritedate && lastwritetime) {
+		fileInfo.fdateLastWrite  = *(FDATE *)&lastwritedate;
+        	fileInfo.ftimeLastWrite  = *(FTIME *)&lastwritetime;
+	}
+
+ 	rc = DosSetFileInfo(hFile, FIL_STANDARD, &fileInfo, sizeof(fileInfo));
+  }
+
+  if(rc)
+  {
+      	SetLastError(error2WinError(rc));
+     	return FALSE;
+  }
+  SetLastError(ERROR_SUCCESS_W);
+  return TRUE;
+}
+//******************************************************************************
+//******************************************************************************
+BOOL OSLibDosGetFileTime(DWORD hFile, WORD *creationdate, WORD *creationtime, 
+                         WORD *lastaccessdate, WORD *lastaccesstime, 
+                         WORD *lastwritedate, WORD *lastwritetime)
+{
+  FILESTATUS3 fileInfo;
+  APIRET      rc;
+
+  rc = DosQueryFileInfo(hFile, FIL_STANDARD, &fileInfo, sizeof(fileInfo));
+
+  if(rc == NO_ERROR)
+  {
+	*creationdate   = *(WORD *)&fileInfo.fdateCreation;
+        *creationtime   = *(WORD *)&fileInfo.ftimeCreation;
+	*lastaccessdate = *(WORD *)&fileInfo.fdateLastAccess;
+        *lastaccesstime = *(WORD *)&fileInfo.ftimeLastAccess;
+	*lastwritedate  = *(WORD *)&fileInfo.fdateLastWrite;
+        *lastwritetime  = *(WORD *)&fileInfo.ftimeLastWrite;
+  }
+
+  if(rc)
+  {
+      	SetLastError(error2WinError(rc));
+     	return FALSE;
+  }
+  SetLastError(ERROR_SUCCESS_W);
+  return TRUE;
 }
 //******************************************************************************
@@ -662,17 +1251,10 @@
 
 
-  rc = DosSetFilePtr(hFile, offset, method, &newoffset);
-  if(rc) {
-    dprintf(("DosSetFilePtr Error rc:%d", rc));
-    return -1;
-  }
-  else  return newoffset;
-}
-//******************************************************************************
-//(FlushBuffer)
-//******************************************************************************
-DWORD OSLibDosResetBuffer(DWORD hFile)
-{
-  return DosResetBuffer(hFile);
+   rc = DosSetFilePtr(hFile, offset, method, &newoffset);
+   if(rc) {
+    	dprintf(("DosSetFilePtr Error rc:%d", rc));
+    	return -1;
+   }
+   else  return newoffset;
 }
 //******************************************************************************
@@ -680,6 +1262,6 @@
 DWORD OSLibDosDupHandle(DWORD hFile, DWORD *hNew)
 {
-  *hNew = -1;
-  return DosDupHandle(hFile, hNew);
+   *hNew = -1;
+   return DosDupHandle(hFile, hNew);
 }
 //******************************************************************************
@@ -687,5 +1269,5 @@
 void OSLibDosDisableHardError(BOOL fTurnOff)
 {
-  DosError((fTurnOff) ? FERR_DISABLEHARDERR : FERR_ENABLEHARDERR);
+   DosError((fTurnOff) ? FERR_DISABLEHARDERR : FERR_ENABLEHARDERR);
 }
 //******************************************************************************
Index: trunk/src/kernel32/oslibdos.h
===================================================================
--- trunk/src/kernel32/oslibdos.h	(revision 3641)
+++ trunk/src/kernel32/oslibdos.h	(revision 3642)
@@ -1,3 +1,3 @@
-/* $Id: oslibdos.h,v 1.15 2000-05-23 18:45:13 sandervl Exp $ */
+/* $Id: oslibdos.h,v 1.16 2000-06-01 11:28:48 sandervl Exp $ */
 
 /*
@@ -13,4 +13,6 @@
 #define __OSLIBDOS_H__
 
+
+void  OSLibInitWSeBFileIO();
 
 DWORD OSLibDosAliasMem(LPVOID pb, ULONG cb, LPVOID *ppbAlias, ULONG fl);
@@ -68,8 +70,5 @@
 DWORD OSLibDosOpen(char *lpszFileName, DWORD flags);
 DWORD OSLibDosClose(DWORD hFile);
-DWORD OSLibDosGetFileSize(DWORD hFile);
-DWORD OSLibDosRead(DWORD hFile, LPVOID lpBuffer, DWORD size, DWORD *nrBytesRead);
-DWORD OSLibDosWrite(DWORD hFile, LPVOID lpBuffer, DWORD size, DWORD *nrBytesWritten);
-DWORD OSLibDosDelete(char *lpszFileName);
+BOOL OSLibDosDelete(char *lpszFileName);
 
 #define OSLIB_SETPTR_FILE_CURRENT       1
@@ -86,15 +85,38 @@
 DWORD OSLibDosSearchPath(DWORD cmd, char *path, char *name, char *full_name, DWORD length_fullname);
 
-
-DWORD OSLibDosCreate(CHAR *lpFileName,
-                     DWORD dwAccess,
-                     DWORD dwShare,
-                     LPSECURITY_ATTRIBUTES lpSecurityAttributes,
-                     DWORD dwCreation,
-                     DWORD dwFlags,
-                     HANDLE hTemplate,
-                     DWORD *dwFile);
-
-DWORD OSLibDosResetBuffer(DWORD hFile);
+DWORD OSLibDosCreateFile(CHAR *lpFileName, DWORD dwAccess,
+                         DWORD dwShare, LPSECURITY_ATTRIBUTES lpSecurityAttributes,
+                         DWORD dwCreation, DWORD dwFlags, HANDLE hTemplate);
+
+DWORD OSLibDosOpenFile(CHAR *lpszFile, UINT fuMode);
+
+BOOL  OSLibDosLockFile(DWORD hFile, DWORD dwFlags,
+                       DWORD OffsetLow, DWORD OffsetHigh,
+                       DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh,
+                       LPOVERLAPPED lpOverlapped);
+
+BOOL  OSLibDosUnlockFile(DWORD hFile, DWORD OffsetLow, DWORD OffsetHigh,
+                         DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh,
+                         LPOVERLAPPED lpOverlapped);
+
+BOOL  OSLibDosFlushFileBuffers(DWORD hFile);
+BOOL  OSLibDosSetEndOfFile(DWORD hFile);
+
+DWORD OSLibDosGetFileSize(DWORD hFile, LPDWORD lpdwFileSizeHigh);
+BOOL  OSLibDosRead(DWORD hFile, LPVOID lpBuffer, DWORD size, DWORD *nrBytesRead);
+BOOL  OSLibDosWrite(DWORD hFile, LPVOID lpBuffer, DWORD size, DWORD *nrBytesWritten);
+
+BOOL  OSLibDosGetFileInformationByHandle(DWORD hFile, BY_HANDLE_FILE_INFORMATION* pHFI);
+
+BOOL  OSLibDosSetFileTime(DWORD hFile, WORD creationdate, WORD creationtime, 
+                          WORD lastaccessdate, WORD lastaccesstime, 
+                          WORD lastwritedate, WORD lastwritetime);
+
+BOOL  OSLibDosGetFileTime(DWORD hFile, WORD *creationdate, WORD *creationtime, 
+                          WORD *lastaccessdate, WORD *lastaccesstime, 
+                          WORD *lastwritedate, WORD *lastwritetime);
+
+DWORD OSLibDosSetFilePointer(DWORD hFile, DWORD OffsetLow, DWORD *OffsetHigh, DWORD method);
+
 DWORD OSLibDosDupHandle(DWORD hFile, DWORD *hNew);
 DWORD OSLibDosSetFilePtr2(DWORD hFile, DWORD offset, DWORD method);
@@ -156,3 +178,78 @@
 
 
-#endif
+#ifdef OS2DEF_INCLUDED
+#ifndef FIL_STANDARDL
+    typedef struct _LONGLONG {  /* LONGLONG */
+        ULONG ulLo;
+        LONG ulHi;
+    } LONGLONG;
+    typedef LONGLONG *PLONGLONG;
+
+    typedef struct _ULONGLONG {  /* ULONGLONG */
+        ULONG ulLo;
+        ULONG ulHi;
+    } ULONGLONG;
+    typedef ULONGLONG *PULONGLONG;
+
+   #define FIL_STANDARDL         11     /* LFS - Info level 11, standard file info for large files*/
+   #define FIL_QUERYEASIZEL      12     /* LFS - Level 12, return Full EA size for large files */
+   #define FIL_QUERYEASFROMLISTL 13     /* LFS - Level 13, return requested EA's */
+
+   typedef struct _FILESTATUS3L     /* fsts3L */
+   {
+      FDATE    fdateCreation;
+      FTIME    ftimeCreation;
+      FDATE    fdateLastAccess;
+      FTIME    ftimeLastAccess;
+      FDATE    fdateLastWrite;
+      FTIME    ftimeLastWrite;
+      LONGLONG cbFile;
+      LONGLONG cbFileAlloc;
+      ULONG    attrFile;
+   } FILESTATUS3L;
+   typedef FILESTATUS3L *PFILESTATUS3L;
+
+   /* Large File Support >2GB */
+   typedef struct _FILESTATUS4L      /* fsts4L */
+   {
+      FDATE    fdateCreation;
+      FTIME    ftimeCreation;
+      FDATE    fdateLastAccess;
+      FTIME    ftimeLastAccess;
+      FDATE    fdateLastWrite;
+      FTIME    ftimeLastWrite;
+      LONGLONG cbFile;
+      LONGLONG cbFileAlloc;
+      ULONG    attrFile;
+      ULONG    cbList;
+   } FILESTATUS4L;
+   typedef FILESTATUS4L  *PFILESTATUS4L;
+
+   typedef struct _FILELOCKL     /* flock */
+   {
+      LONGLONG lOffset;
+      LONGLONG lRange;
+   } FILELOCKL;
+   typedef FILELOCKL  *PFILELOCKL;
+#endif
+
+
+   typedef APIRET (* APIENTRY PROC_DosSetFileSizeL)(HFILE hFile, LONGLONG cbSize);
+   APIRET OdinDosSetFileSize(HFILE hFile,
+                             LONGLONG cbSize);
+
+   typedef APIRET (* APIENTRY PROC_DosSetFilePtrL)(HFILE hFile, LONGLONG ib, ULONG method, PLONGLONG ibActual);
+   APIRET OdinDosSetFilePtr(HFILE hFile,
+                            LONGLONG ib,
+                            ULONG method,
+                            PLONGLONG ibActual);
+
+   typedef APIRET (* APIENTRY PROC_DosSetFileLocksL)(HFILE hFile, PFILELOCKL pflUnlock, PFILELOCKL pflLock, ULONG timeout, ULONG flags);
+   APIRET OdinDosSetFileLocks(HFILE hFile,
+                              PFILELOCKL pflUnlock,
+                              PFILELOCKL pflLock,
+                              ULONG timeout,
+                              ULONG flags);
+#endif
+
+#endif
Index: trunk/src/kernel32/winimagepeldr.cpp
===================================================================
--- trunk/src/kernel32/winimagepeldr.cpp	(revision 3641)
+++ trunk/src/kernel32/winimagepeldr.cpp	(revision 3642)
@@ -1,3 +1,3 @@
-/* $Id: winimagepeldr.cpp,v 1.45 2000-05-29 22:32:09 sandervl Exp $ */
+/* $Id: winimagepeldr.cpp,v 1.46 2000-06-01 11:28:48 sandervl Exp $ */
 
 /*
@@ -212,5 +212,5 @@
 
   if(oh.SizeOfImage == 0) {//just in case
-	oh.SizeOfImage = OSLibDosGetFileSize(hFile);
+	oh.SizeOfImage = OSLibDosGetFileSize(hFile, NULL);
   }
 
