Index: trunk/src/kernel32/Fileio.cpp
===================================================================
--- trunk/src/kernel32/Fileio.cpp	(revision 74)
+++ trunk/src/kernel32/Fileio.cpp	(revision 75)
@@ -29,10 +29,10 @@
 {
   HANDLE rc;
-  int    slen = 0;
+  HANDLE hFile;
 
   if(lpszName == NULL)
     return(NULL);
 
-  dprintf(("KERNEL32:  CreateFile %s\n", lpszName));
+  dprintf(("KERNEL32: CreateFile %s\n", lpszName));
 
   if(strncmp(lpszName,
@@ -45,10 +45,12 @@
   }
 
-  dprintf(("KERNEL32:  CreateFile %s %X %X %X %X \n",
+  dprintf(("KERNEL32: CreateFileA(%s,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh)\n",
            lpszName,
            fdwAccess,
            fdwShareMode,
+           lpsa,
            fdwCreate,
-           fdwAttrsAndFlags));
+           fdwAttrsAndFlags,
+           hTemplateFile));
 
   rc = O32_CreateFile(lpszName,
@@ -70,7 +72,10 @@
                       hTemplateFile);
 
-  //@@@PH translate handle
-
-  dprintf(("KERNEL32:  CreateFile returned %d\n",
+  /* @@@PH experimental Handlemanager support */
+  if (HMHandleAllocate(&hFile,
+                       rc) == NO_ERROR)
+    rc = hFile;
+
+  dprintf(("KERNEL32:  CreateFile returned %08xh\n",
            rc));
 
@@ -112,5 +117,5 @@
 
     dprintf(("KERNEL32: FindFirstFileW: not implemented!!"));
-    dprintf(("KERNEL32:  FindFirstFileW\n"));
+
     astring = UnicodeToAsciiString((LPWSTR)arg1);
 //    rc = O32_FindFirstFile(astring, arg2);
@@ -146,5 +151,6 @@
 DWORD WIN32API GetFileType(HANDLE file)
 {
- DWORD rc;
+  DWORD rc;
+  HFILE hFile;
 
   /* @@@PH 1998/02/12 Handle Manager support */
@@ -152,10 +158,22 @@
     return (HMGetFileType(file));
 
-  dprintf(("KERNEL32:  GetFileType %d\n", file));
+  /* @@@PH experimental Handlemanager support */
+  if (HMHandleTranslateToOS2(file,
+                       &hFile) == NO_ERROR)
+    file = hFile;
+
+  dprintf(("KERNEL32:  GetFileType %08xh\n",
+           file));
+
   rc = O32_GetFileType(file);
-  if(rc == 0) {//bugfix
-        rc = 1;
+  if(rc == 0)
+  {
+    //bugfix
+    rc = 1;
   }
-  dprintf(("KERNEL32:  GetFileType returned %d\n", rc));
+
+  dprintf(("KERNEL32:  GetFileType returned %08xh\n",
+           rc));
+
   return(rc);
 }
@@ -165,17 +183,31 @@
                                           BY_HANDLE_FILE_INFORMATION *arg2)
 {
- DWORD rc;
-
+  DWORD rc;
+  HFILE hFile;
+
+   /* @@@PH experimental Handlemanager support */
+  if (HMHandleTranslateToOS2(arg1,
+                       &hFile) == NO_ERROR)
+    arg1 = hFile;
+
+
+  rc = O32_GetFileInformationByHandle(arg1,
+                                      arg2);
+
+  dprintf(("KERNEL32:  GetFileInformationByHandle (%08xh) returned %08xh\n",
+           arg1,
+           rc));
+
+  /* @@@PH irrelevant
+  if(rc == 0)
+  {
+    //might be converted _lopen handle, so go get it
+    //      arg1 = ConvertHandle(arg1);
     rc = O32_GetFileInformationByHandle(arg1, arg2);
     dprintf(("KERNEL32:  GetFileInformationByHandle (%X) returned %d\n", arg1, rc));
-
-    if(rc == 0) {//might be converted _lopen handle, so go get it
-        //      arg1 = ConvertHandle(arg1);
-        //@@@PH translate handle
-        rc = O32_GetFileInformationByHandle(arg1, arg2);
-        dprintf(("KERNEL32:  GetFileInformationByHandle (%X) returned %d\n", arg1, rc));
-    }
-
-    return(rc);
+  }
+  */
+
+  return(rc);
 }
 //******************************************************************************
@@ -183,13 +215,40 @@
 BOOL WIN32API SetEndOfFile( HANDLE arg1)
 {
-    dprintf(("KERNEL32:  SetEndOfFile\n"));
-    return O32_SetEndOfFile(arg1);
-}
-//******************************************************************************
-//******************************************************************************
-BOOL WIN32API SetFileTime( HANDLE arg1, const FILETIME * arg2, const FILETIME * arg3, const FILETIME *  arg4)
-{
-    dprintf(("KERNEL32:  SetFileTime\n"));
-    return O32_SetFileTime(arg1, arg2, arg3, arg4);
+  HFILE hFile;
+
+  /* @@@PH experimental Handlemanager support */
+  if (HMHandleTranslateToOS2(arg1,
+                       &hFile) == NO_ERROR)
+    arg1 = hFile;
+
+  dprintf(("KERNEL32: SetEndOfFile(%08xh)\n",
+           arg1));
+
+  return O32_SetEndOfFile(arg1);
+}
+//******************************************************************************
+//******************************************************************************
+BOOL WIN32API SetFileTime(HANDLE          arg1,
+                          const FILETIME *arg2,
+                          const FILETIME *arg3,
+                          const FILETIME *arg4)
+{
+  HFILE hFile;
+
+  /* @@@PH experimental Handlemanager support */
+  if (HMHandleTranslateToOS2(arg1,
+                       &hFile) == NO_ERROR)
+    arg1 = hFile;
+
+  dprintf(("KERNEL32: SetFileTime(%08xh,%08xh,%08xh,%08xh)\n",
+           arg1,
+           arg2,
+           arg3,
+           arg4));
+
+  return O32_SetFileTime(arg1,
+                         arg2,
+                         arg3,
+                         arg4);
 }
 //******************************************************************************
@@ -227,6 +286,17 @@
 DWORD WIN32API GetFileSize( HANDLE arg1, PDWORD  arg2)
 {
-    dprintf(("KERNEL32:  GetFileSize\n"));
-    return O32_GetFileSize(arg1, arg2);
+  HFILE hFile;
+
+  /* @@@PH experimental Handlemanager support */
+  if (HMHandleTranslateToOS2(arg1,
+                       &hFile) == NO_ERROR)
+    arg1 = hFile;
+
+  dprintf(("KERNEL32: GetFileSize (%08xh, %08xh)\n",
+           arg1,
+           arg2));
+
+  return O32_GetFileSize(arg1,
+                         arg2);
 }
 //******************************************************************************
@@ -298,7 +368,12 @@
 //******************************************************************************
 //******************************************************************************
-BOOL WIN32API ReadFile( HANDLE arg1, PVOID arg2, DWORD arg3, PDWORD arg4, LPOVERLAPPED  arg5)
-{
- BOOL rc;
+BOOL WIN32API ReadFile(HANDLE arg1,
+                       PVOID  arg2,
+                       DWORD  arg3,
+                       PDWORD arg4,
+                       LPOVERLAPPED  arg5)
+{
+  BOOL rc;
+  HFILE hFile;
 
   /* @@@PH 1998/02/12 Handle Manager support */
@@ -306,6 +381,22 @@
     return (HMReadFile(arg1, arg2, arg3, arg4, arg5));
 
-  rc = O32_ReadFile(arg1, arg2, arg3, arg4, arg5);
-  dprintf(("KERNEL32:  ReadFile %X %d bytes returned %d\n", arg1, arg3, rc));
+  /* @@@PH 1999/06/09 Handle Manager support */
+
+  /* @@@PH experimental Handlemanager support */
+  if (HMHandleTranslateToOS2(arg1,
+                       &hFile) == NO_ERROR)
+    arg1 = hFile;
+
+  rc = O32_ReadFile(arg1,
+                    arg2,
+                    arg3,
+                    arg4,
+                    arg5);
+
+  dprintf(("KERNEL32:  ReadFile %X %d bytes returned %d\n",
+           arg1,
+           arg3,
+           rc));
+
   return(rc);
 }
@@ -317,13 +408,17 @@
                               DWORD  dwMoveMethod)
 {
-////  dprintf(("KERNEL32:  SetFilePointer\n"));
-
-  //@@@PH translate handle
-
+  HANDLE hFile2;
+
+//  dprintf(("KERNEL32:  SetFilePointer\n"));
+
+  /* @@@PH experimental Handlemanager support */
+  if (HMHandleTranslateToOS2(hFile,
+                       &hFile2) == NO_ERROR)
+    hFile = hFile2;
 
   return(O32_SetFilePointer(hFile,
-                        lDistanceToMove,
-                        lpDistanceToMoveHigh,
-                        dwMoveMethod));
+                            lDistanceToMove,
+                            lpDistanceToMoveHigh,
+                            dwMoveMethod));
 }
 //******************************************************************************
@@ -335,5 +430,6 @@
                            LPOVERLAPPED lpOverlapped)
 {
-  BOOL rc;
+  BOOL   rc;
+  HANDLE hFile2;
 
   //@@@PH translate handle
@@ -352,4 +448,10 @@
                         nrbyteswritten,
                         lpOverlapped));
+
+  /* @@@PH experimental Handlemanager support */
+  if (HMHandleTranslateToOS2(hFile,
+                       &hFile2) == NO_ERROR)
+    hFile = hFile2;
+
 
   rc = O32_WriteFile(hFile, buffer, nrbytes, nrbyteswritten, (LPOVERLAPPED)lpOverlapped);
@@ -476,8 +578,29 @@
 //******************************************************************************
 //******************************************************************************
-BOOL WIN32API LockFile( HANDLE arg1, DWORD arg2, DWORD arg3, DWORD arg4, DWORD  arg5)
-{
-    dprintf(("KERNEL32:  LockFile\n"));
-    return O32_LockFile(arg1, arg2, arg3, arg4, arg5);
+BOOL WIN32API LockFile(HANDLE arg1,
+                       DWORD  arg2,
+                       DWORD  arg3,
+                       DWORD  arg4,
+                       DWORD  arg5)
+{
+  HFILE hFile;
+
+  /* @@@PH experimental Handlemanager support */
+  if (HMHandleTranslateToOS2(arg1,
+                       &hFile) == NO_ERROR)
+    arg1 = hFile;
+
+  dprintf(("KERNEL32: LockFile (%08xh,%08xh,%08xh,%08xh,%08xh)\n",
+           arg1,
+           arg2,
+           arg3,
+           arg4,
+           arg5));
+
+  return O32_LockFile(arg1,
+                      arg2,
+                      arg3,
+                      arg4,
+                      arg5);
 }
 
@@ -501,10 +624,17 @@
 
 BOOL WIN32API LockFileEx(HANDLE       hFile,
-                            DWORD        dwFlags,
-                            DWORD        dwReserved,
-                            DWORD        nNumberOfBytesToLockLow,
-                            DWORD        nNumberOfBytesToLockHigh,
-                            LPOVERLAPPED LPOVERLAPPED)
-{
+                         DWORD        dwFlags,
+                         DWORD        dwReserved,
+                         DWORD        nNumberOfBytesToLockLow,
+                         DWORD        nNumberOfBytesToLockHigh,
+                         LPOVERLAPPED LPOVERLAPPED)
+{
+  HFILE hFile2;
+
+  /* @@@PH experimental Handlemanager support */
+  if (HMHandleTranslateToOS2(hFile,
+                       &hFile2) == NO_ERROR)
+    hFile = hFile2;
+
   dprintf(("Kernel32: LockFileEx(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh)\n",
            hFile,
@@ -593,4 +723,6 @@
                    arg2,
                    arg3);
+
+  /* @@@PH 1999/06/09 HandleManager support temporarily disabled */
   if (hFile != 0)                                /* check if handle is valid */
   {
@@ -598,16 +730,35 @@
                          hFile) == NO_ERROR)
       return (ulWindowsHandle);
-    else
-      return (0);
   }
-  else
-    return (0);
-}
-//******************************************************************************
-//******************************************************************************
-BOOL WIN32API UnlockFile( HANDLE arg1, DWORD arg2, DWORD arg3, DWORD arg4, DWORD  arg5)
-{
-    dprintf(("KERNEL32:  UnlockFile\n"));
-    return O32_UnlockFile(arg1, arg2, arg3, arg4, arg5);
+
+  return (hFile);
+}
+//******************************************************************************
+//******************************************************************************
+BOOL WIN32API UnlockFile(HANDLE arg1,
+                         DWORD  arg2,
+                         DWORD  arg3,
+                         DWORD  arg4,
+                         DWORD  arg5)
+{
+  HFILE hFile2;
+
+  /* @@@PH experimental Handlemanager support */
+  if (HMHandleTranslateToOS2(arg1,
+                       &hFile2) == NO_ERROR)
+    arg1 = hFile2;
+
+  dprintf(("KERNEL32: UnlockFile(%08xh,%08xh,%08xh,%08xh,%08xh)\n",
+           arg1,
+           arg2,
+           arg3,
+           arg4,
+           arg5));
+
+  return O32_UnlockFile(arg1,
+                        arg2,
+                        arg3,
+                        arg4,
+                        arg5);
 }
 
@@ -630,9 +781,16 @@
 
 BOOL WIN32API UnlockFileEx(HANDLE       hFile,
-                              DWORD        dwReserved,
-                              DWORD        nNumberOfBytesToLockLow,
-                              DWORD        nNumberOfBytesToLockHigh,
-                              LPOVERLAPPED LPOVERLAPPED)
-{
+                           DWORD        dwReserved,
+                           DWORD        nNumberOfBytesToLockLow,
+                           DWORD        nNumberOfBytesToLockHigh,
+                           LPOVERLAPPED LPOVERLAPPED)
+{
+  HFILE hFile2;
+
+  /* @@@PH experimental Handlemanager support */
+  if (HMHandleTranslateToOS2(hFile,
+                       &hFile2) == NO_ERROR)
+    hFile = hFile2;
+
   dprintf(("Kernel32: UnlockFileEx(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh)\n",
            hFile,
@@ -692,5 +850,7 @@
 BOOL WIN32API FindNextChangeNotification(HANDLE hChange)
 {
-  dprintf(("KERNEL32:  FindNextChangeNotification, Not implemented\n"));
+  dprintf(("KERNEL32: FindNextChangeNotification (%08xh), Not implemented\n",
+           hChange));
+
   return(0);
 }
@@ -718,5 +878,5 @@
 
 DWORD WIN32API GetCompressedFileSizeA(LPCTSTR  lpFileName,
-                                         LPDWORD  lpFileSizeHigh)
+                                      LPDWORD  lpFileSizeHigh)
 {
   dprintf(("KERNEL32: GetCompressedFileSizeA (%s, %08xh) not implemented.\n",
