Index: trunk/src/gdi32/region.cpp
===================================================================
--- trunk/src/gdi32/region.cpp	(revision 3713)
+++ trunk/src/gdi32/region.cpp	(revision 3714)
@@ -1,3 +1,3 @@
-/* $Id: region.cpp,v 1.7 2000-06-14 14:26:59 sandervl Exp $ */
+/* $Id: region.cpp,v 1.8 2000-06-16 00:05:49 phaller Exp $ */
 
 /*
@@ -70,6 +70,8 @@
     if(hwnd == 0 && pHps != 0)
         hwnd = pHps->hwnd;
-
-    if(hwnd != 0 || pHps == 0)
+  
+    // @@@pH Note: hwnd == 0 == HWND_DESKTOP !
+    // if(hwnd != 0 || pHps == 0)
+    if (pHps == 0)
     {
         RECT rect;
@@ -115,6 +117,8 @@
     if(hwnd == 0 && pHps != 0)
         hwnd = pHps->hwnd;
-
-    if(hwnd != 0 || pHps == 0)
+  
+    // @@@pH Note: hwnd == 0 == HWND_DESKTOP !
+    // if(hwnd != 0 || pHps == 0)
+    if (pHps == 0)
     {
         RECT rect;
@@ -134,5 +138,6 @@
         return x;
    }
-   else DebugInt3();
+   else
+     DebugInt3();
    return 0;
 }
Index: trunk/src/kernel32/hmfile.cpp
===================================================================
--- trunk/src/kernel32/hmfile.cpp	(revision 3713)
+++ trunk/src/kernel32/hmfile.cpp	(revision 3714)
@@ -1,3 +1,3 @@
-/* $Id: hmfile.cpp,v 1.2 2000-06-08 18:08:56 sandervl Exp $ */
+/* $Id: hmfile.cpp,v 1.3 2000-06-16 00:04:29 phaller Exp $ */
 
 /*
@@ -269,38 +269,63 @@
  * Author    : SvL
  *****************************************************************************/
-BOOL HMDeviceFileClass::DuplicateHandle(PHMHANDLEDATA pHMHandleData, HANDLE  srcprocess,
-                               PHMHANDLEDATA pHMSrcHandle,
-                               HANDLE  destprocess,
-                               PHANDLE desthandle,
-                       	       DWORD   fdwAccess,
-                       	       BOOL    fInherit,
-                               DWORD   fdwOptions)
+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;
+ DWORD rc;
 
   dprintf(("KERNEL32:HMDeviceFileClass::DuplicateHandle (%08x,%08x,%08x,%08x,%08x)",
            pHMHandleData,
-           srcprocess, pHMSrcHandle->hHMHandle, destprocess, desthandle));
+           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;
+  if(destprocess != srcprocess) 
+  {
+    //TODO:!!!!
+    dprintf(("ERROR: DuplicateHandle; different processes not yet supported!!"));
+    return FALSE;
+  }
+
+  if(srcfileinfo)
+  {
+#if 0
+    // @@@PH Why createfile here? Why not OSLibDupHandle() ?
+    if(CreateFile(srcfileinfo->lpszFileName, pHMHandleData,
+                  srcfileinfo->lpSecurityAttributes, NULL) == NO_ERROR) 
+    {
+      return TRUE;
+    }
+    dprintf(("ERROR: DuplicateHandle; CreateFile %s failed!", 
+             srcfileinfo->lpszFileName));
+    return FALSE;
+#endif
+
+    rc = OSLibDosDupHandle(pHMSrcHandle->hHMHandle,
+                           desthandle);
+    if (rc)
+    {
+      dprintf(("ERROR: DulicateHandle: OSLibDosDupHandle(%s) failed = %u\n",
+               rc,
+               srcfileinfo->lpszFileName));
+      SetLastError(rc);
+      return FALSE;   // ERROR
+    }
+    else
+      return TRUE;    // OK
+  }
+  else
+  {
+    SetLastError(ERROR_INVALID_PARAMETER);
+    return FALSE;
   }
 }
Index: trunk/src/kernel32/lfile.cpp
===================================================================
--- trunk/src/kernel32/lfile.cpp	(revision 3713)
+++ trunk/src/kernel32/lfile.cpp	(revision 3714)
@@ -1,3 +1,3 @@
-/* $Id: lfile.cpp,v 1.6 2000-02-16 14:25:41 sandervl Exp $ */
+/* $Id: lfile.cpp,v 1.7 2000-06-16 00:04:30 phaller Exp $ */
 
 /*
@@ -226,9 +226,10 @@
       return -1;
    }
-
+  
    rc = SetFilePointer(arg1,
                        arg2,
                        NULL,
-                       arg3);   //returns -1 on error (-1 == 0xffffffff)
+                       arg3);   
+  //returns -1 on error (-1 == 0xffffffff)
 
    dprintf(("KERNEL32: _llseek returns %08xh", rc));
Index: trunk/src/kernel32/oslibdos.cpp
===================================================================
--- trunk/src/kernel32/oslibdos.cpp	(revision 3713)
+++ trunk/src/kernel32/oslibdos.cpp	(revision 3714)
@@ -1,3 +1,3 @@
-/* $Id: oslibdos.cpp,v 1.30 2000-06-01 14:01:43 sandervl Exp $ */
+/* $Id: oslibdos.cpp,v 1.31 2000-06-16 00:04:30 phaller Exp $ */
 /*
  * Wrappers for OS/2 Dos* API
@@ -522,20 +522,24 @@
  APIRET rc;
 
-  switch(method) {
-  case OSLIB_SETPTR_FILE_CURRENT:
-        os2method = FILE_CURRENT;
-        break;
-  case OSLIB_SETPTR_FILE_BEGIN:
-        os2method = FILE_BEGIN  ;
-        break;
-  case OSLIB_SETPTR_FILE_END:
-        os2method = FILE_END;
-        break;
-  default:
-        return OSLIB_ERROR_INVALID_PARAMETER;
-  }
+  switch(method) 
+  {
+    case OSLIB_SETPTR_FILE_CURRENT:
+      os2method = FILE_CURRENT;
+      break;
+    case OSLIB_SETPTR_FILE_BEGIN:
+      os2method = FILE_BEGIN  ;
+      break;
+    case OSLIB_SETPTR_FILE_END:
+      os2method = FILE_END;
+      break;
+    default:
+      return OSLIB_ERROR_INVALID_PARAMETER;
+  }
+  
   rc = DosSetFilePtr(hFile, offset, os2method, &newoffset);
-  if(rc) {
-        return -1;
+  if(rc) 
+  {
+    SetLastError(error2WinError(rc));
+    return -1;
   }
   else  return newoffset;
@@ -1021,23 +1025,28 @@
 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) {
+  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;
+  }
+  
+  // PH Note: for a negative 32-bit seek, the OS/2 64-bit version
+  // needs to be skipped.
+  if( (f64BitIO) && (OffsetHigh) )
+  {
 	offsetL.ulLo = OffsetLow;
 	offsetL.ulHi = (OffsetHigh) ? *OffsetHigh : 0;
@@ -1048,11 +1057,14 @@
 	newoffset = newoffsetL.ulLo;
    }
-   else	rc = DosSetFilePtr(hFile, OffsetLow, method, &newoffset);
-   if(rc) {
-   	SetLastError(error2WinError(rc));
-   	return -1;
-   }
-   SetLastError(ERROR_SUCCESS_W);
-   return newoffset;
+  else 
+    rc = DosSetFilePtr(hFile, OffsetLow, method, &newoffset);
+  
+  if(rc) 
+  {
+    SetLastError(error2WinError(rc));
+    return -1;
+  }
+  SetLastError(ERROR_SUCCESS_W);
+  return newoffset;
 }
 //******************************************************************************
Index: trunk/src/kernel32/oslibdos.h
===================================================================
--- trunk/src/kernel32/oslibdos.h	(revision 3713)
+++ trunk/src/kernel32/oslibdos.h	(revision 3714)
@@ -1,3 +1,3 @@
-/* $Id: oslibdos.h,v 1.17 2000-06-01 14:01:44 sandervl Exp $ */
+/* $Id: oslibdos.h,v 1.18 2000-06-16 00:04:31 phaller Exp $ */
 
 /*
@@ -72,7 +72,7 @@
 BOOL OSLibDosDelete(char *lpszFileName);
 
-#define OSLIB_SETPTR_FILE_CURRENT       1
-#define OSLIB_SETPTR_FILE_BEGIN         2
-#define OSLIB_SETPTR_FILE_END           3
+#define OSLIB_SETPTR_FILE_CURRENT       0
+#define OSLIB_SETPTR_FILE_BEGIN         1
+#define OSLIB_SETPTR_FILE_END           2
 
 DWORD OSLibDosSetFilePtr(DWORD hFile, DWORD offset, DWORD method);
