fix for closing stdio/out/err dos handles

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



reference: http://www.winehq.com/hypermail/wine-devel/2002/07/0491.html

License: X11,LGPL
Name: dos_stdio_close_fix
ChangeLog: Changed dos_handles to store dups of stdio/out/err as per Ove Kaaven's suggestion.
GenDate: 2002/07/31 10:59:00 UTC
ModifiedFiles: files/file.c
AddedFiles: 
===================================================================
RCS file: /home/wine/wine/files/file.c,v
retrieving revision 1.149
diff -u -r1.149 file.c
--- files/file.c	5 Jun 2002 00:47:38 -0000	1.149
+++ files/file.c	31 Jul 2002 10:59:05 -0000
@@ -1230,11 +1230,12 @@
  */
 static void FILE_InitProcessDosHandles( void )
 {
-    dos_handles[0] = GetStdHandle(STD_INPUT_HANDLE);
-    dos_handles[1] = GetStdHandle(STD_OUTPUT_HANDLE);
-    dos_handles[2] = GetStdHandle(STD_ERROR_HANDLE);
-    dos_handles[3] = GetStdHandle(STD_ERROR_HANDLE);
-    dos_handles[4] = GetStdHandle(STD_ERROR_HANDLE);
+    HANDLE cp = GetCurrentProcess();
+    DuplicateHandle(cp, GetStdHandle(STD_INPUT_HANDLE), cp, &dos_handles[0], 0, TRUE, DUPLICATE_SAME_ACCESS);
+    DuplicateHandle(cp, GetStdHandle(STD_INPUT_HANDLE), cp, &dos_handles[1], 0, TRUE, DUPLICATE_SAME_ACCESS);
+    DuplicateHandle(cp, GetStdHandle(STD_ERROR_HANDLE), cp, &dos_handles[2], 0, TRUE, DUPLICATE_SAME_ACCESS);
+    DuplicateHandle(cp, GetStdHandle(STD_ERROR_HANDLE), cp, &dos_handles[3], 0, TRUE, DUPLICATE_SAME_ACCESS);
+    DuplicateHandle(cp, GetStdHandle(STD_ERROR_HANDLE), cp, &dos_handles[4], 0, TRUE, DUPLICATE_SAME_ACCESS);
 }
 
 /***********************************************************************
@@ -1329,12 +1330,6 @@
         SetLastError( ERROR_INVALID_HANDLE );
         return HFILE_ERROR16;
     }
-    if (hFile2 < 5)
-    {
-        FIXME("stdio handle closed, need proper conversion\n" );
-        SetLastError( ERROR_INVALID_HANDLE );
-        return HFILE_ERROR16;
-    }
     if (!DuplicateHandle( GetCurrentProcess(), dos_handles[hFile1],
                           GetCurrentProcess(), &new_handle,
                           0, FALSE, DUPLICATE_SAME_ACCESS ))
@@ -1350,12 +1345,6 @@
  */
 HFILE16 WINAPI _lclose16( HFILE16 hFile )
 {
-    if (hFile < 5)
-    {
-        FIXME("stdio handle closed, need proper conversion\n" );
-        SetLastError( ERROR_INVALID_HANDLE );
-        return HFILE_ERROR16;
-    }
     if ((hFile >= DOS_TABLE_SIZE) || !dos_handles[hFile])
     {
         SetLastError( ERROR_INVALID_HANDLE );

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux