winedos/kernel: move dos file handling to winedos

Markus Amsler markus.amsler at oribi.org
Tue Oct 12 12:25:32 CDT 2004


This patch prepares kernel/winedos for job file table (JFT) 
implementation (comming soon). It also makes winedos independant from 
non-nt functions _lclose16, Win32HandleToDosFileHandle and 
DosFileHandleToWin32Handle.

I also removed the _lclose16 export from kernel32.spec, because winedos 
was the only user of that.

I tested the win16 file functions wath a modified version of 
kernel/test/file.c, so it compiles in openwatcom win16. Source and win16 
executable can be downloaded from [1]

[1] http://oribi.org/linux/wine/win16tests/

Changelog:
* Move dos file handling to winedos.

-------------- next part --------------
--- /dev/null	2004-09-20 14:26:34.000000000 +0200
+++ dlls/winedos/file.c	2004-10-12 17:28:38.000000000 +0200
@@ -0,0 +1,170 @@
+/*
+ * DOS file handle management
+ *
+ * Copyright 1993 John Burton
+ * Copyright 1996, 2004 Alexandre Julliard
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+/* FIXME: move some of the int21 code in here */
+
+#include <stdarg.h>
+#include <stdio.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "dosexe.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(file);
+
+/* some kind of a system file table */
+HANDLE sft_handles[SFT_TABLE_SIZE];
+
+/***********************************************************************
+ *           FILE_InitProcessDosHandles
+ *
+ * Allocates the default DOS handles for a process. Called either by
+ * Win32HandleToDosFileHandle below or by the DOSVM stuff.
+ */
+static void FILE_InitProcessDosHandles( void )
+{
+    static BOOL init_done /* = FALSE */;
+    HANDLE cp = GetCurrentProcess();
+    if (init_done) return;
+    init_done = TRUE;
+    DuplicateHandle(cp, GetStdHandle(STD_INPUT_HANDLE), cp, &sft_handles[0],
+                    0, TRUE, DUPLICATE_SAME_ACCESS);
+    DuplicateHandle(cp, GetStdHandle(STD_OUTPUT_HANDLE), cp, &sft_handles[1],
+                    0, TRUE, DUPLICATE_SAME_ACCESS);
+    DuplicateHandle(cp, GetStdHandle(STD_ERROR_HANDLE), cp, &sft_handles[2],
+                    0, TRUE, DUPLICATE_SAME_ACCESS);
+    DuplicateHandle(cp, GetStdHandle(STD_ERROR_HANDLE), cp, &sft_handles[3],
+                    0, TRUE, DUPLICATE_SAME_ACCESS);
+    DuplicateHandle(cp, GetStdHandle(STD_ERROR_HANDLE), cp, &sft_handles[4],
+                    0, TRUE, DUPLICATE_SAME_ACCESS);
+}
+
+
+/***********************************************************************
+ *           FILE_HandleWin32ToDos   (WINEDOS.@)
+ *
+ * Allocate a DOS handle for a Win32 handle. The Win32 handle is no
+ * longer valid after this function (even on failure).
+ *
+ * Note: Same behaviour as KERNEL32.Win32HandleToDosFileHandle.
+ *       this is not exactly right, since on Win95 the Win32 handles
+ *       are on top of DOS handles and we do it the other way
+ *       around. Should be good enough though.
+ */
+HFILE WINAPI FILE_HandleWin32ToDos( HANDLE handle )
+{
+    int i;
+
+    if (!handle || (handle == INVALID_HANDLE_VALUE))
+        return HFILE_ERROR;
+
+    FILE_InitProcessDosHandles();
+    for (i = 0; i < SFT_TABLE_SIZE; i++)
+        if (!sft_handles[i])
+        {
+            sft_handles[i] = handle;
+            TRACE("Got %d for h32 %p\n", i, handle );
+            return (HFILE)i;
+        }
+    CloseHandle( handle );
+    SetLastError( ERROR_TOO_MANY_OPEN_FILES );
+    return HFILE_ERROR;
+}
+
+
+/***********************************************************************
+ *           FILE_HandleDosToWin32   (WINEDEOS.@)
+ *
+ * Return the Win32 handle for a DOS handle.
+ *
+ * Note: Same behaviour as KERNEL32.DosFileHandleToWin32Handle.
+ *       This is not exactly right, since on Win95 the Win32 handles
+ *       are on top of DOS handles and we do it the other way
+ *       around. Should be good enough though.
+ */
+HANDLE WINAPI FILE_HandleDosToWin32( HFILE handle )
+{
+    HFILE hfile = handle;
+    
+    if (hfile < 5) FILE_InitProcessDosHandles();
+    if ((hfile >= SFT_TABLE_SIZE) || !sft_handles[hfile])
+    {
+        SetLastError( ERROR_INVALID_HANDLE );
+        return INVALID_HANDLE_VALUE;
+    }
+    return sft_handles[hfile];
+}
+
+
+/*************************************************************************
+ *           FILE_SetHandleCount   (WINEDOS.@)
+ *
+ * Note: Same behaviour as KERNEL32.DosSetHandleCount.
+ */
+UINT WINAPI FILE_SetHandleCount( UINT count )
+{
+    return min( 256, count );
+}
+
+
+/***********************************************************************
+ *           FILE_DisposeLZ32Handle   (WINEDOS.@)
+ *
+ * Note: Same behaviour as KERNEL32.DisposeLZ32Handle.
+ *       this is not entirely correct, we should only close the
+ *       32-bit handle and not the 16-bit one, but we cannot do
+ *       this because of the way our DOS handles are implemented.
+ *       It shouldn't break anything though.
+ */
+void WINAPI FILE_DisposeLZ32Handle( HANDLE handle )
+{
+    int i;
+
+    if (!handle || (handle == INVALID_HANDLE_VALUE)) return;
+
+    for (i = 5; i < SFT_TABLE_SIZE; i++)
+        if (sft_handles[i] == handle)
+        {
+            sft_handles[i] = 0;
+            CloseHandle( handle );
+            break;
+        }
+}
+
+
+/***********************************************************************
+ *           FILE_Close   (WINEDOS.@)
+ *
+ * Closes a dos handle.
+ */
+HFILE WINAPI FILE_Close( HFILE hFile )
+{
+    if ((hFile >= SFT_TABLE_SIZE) || !sft_handles[hFile])
+    {
+        SetLastError( ERROR_INVALID_HANDLE );
+        return HFILE_ERROR16;
+    }
+    TRACE("%d (handle32=%p)\n", hFile, sft_handles[hFile] );
+    CloseHandle( sft_handles[hFile] );
+    sft_handles[hFile] = 0;
+    return 0;
+}
? dlls/kernel/winedos.h
Index: dlls/kernel/file.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/file.c,v
retrieving revision 1.27
diff -u -r1.27 file.c
--- dlls/kernel/file.c	11 Oct 2004 19:53:13 -0000	1.27
+++ dlls/kernel/file.c	12 Oct 2004 15:34:12 -0000
@@ -47,8 +47,6 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(file);
 
-HANDLE dos_handles[DOS_TABLE_SIZE];
-
 /* info structure for FindFirstFile handle */
 typedef struct
 {
@@ -266,32 +264,6 @@
  *                      Operations on file handles                        *
  **************************************************************************/
 
-/***********************************************************************
- *           FILE_InitProcessDosHandles
- *
- * Allocates the default DOS handles for a process. Called either by
- * Win32HandleToDosFileHandle below or by the DOSVM stuff.
- */
-static void FILE_InitProcessDosHandles( void )
-{
-    static BOOL init_done /* = FALSE */;
-    HANDLE cp = GetCurrentProcess();
-
-    if (init_done) return;
-    init_done = TRUE;
-    DuplicateHandle(cp, GetStdHandle(STD_INPUT_HANDLE), cp, &dos_handles[0],
-                    0, TRUE, DUPLICATE_SAME_ACCESS);
-    DuplicateHandle(cp, GetStdHandle(STD_OUTPUT_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);
-}
-
-
 /******************************************************************
  *		FILE_ReadWriteApc (internal)
  */
@@ -1079,22 +1051,10 @@
  */
 HFILE WINAPI Win32HandleToDosFileHandle( HANDLE handle )
 {
-    int i;
-
-    if (!handle || (handle == INVALID_HANDLE_VALUE))
-        return HFILE_ERROR;
-
-    FILE_InitProcessDosHandles();
-    for (i = 0; i < DOS_TABLE_SIZE; i++)
-        if (!dos_handles[i])
-        {
-            dos_handles[i] = handle;
-            TRACE("Got %d for h32 %p\n", i, handle );
-            return (HFILE)i;
-        }
-    CloseHandle( handle );
-    SetLastError( ERROR_TOO_MANY_OPEN_FILES );
-    return HFILE_ERROR;
+    HFILE h = HFILE_ERROR;
+    if (!DOS_HandleWin32ToDos) init_winedos();
+    if (DOS_HandleWin32ToDos) h = DOS_HandleWin32ToDos( handle );
+    return h;
 }
 
 
@@ -1109,14 +1069,10 @@
  */
 HANDLE WINAPI DosFileHandleToWin32Handle( HFILE handle )
 {
-    HFILE16 hfile = (HFILE16)handle;
-    if (hfile < 5) FILE_InitProcessDosHandles();
-    if ((hfile >= DOS_TABLE_SIZE) || !dos_handles[hfile])
-    {
-        SetLastError( ERROR_INVALID_HANDLE );
-        return INVALID_HANDLE_VALUE;
-    }
-    return dos_handles[hfile];
+    HANDLE h = INVALID_HANDLE_VALUE;
+    if (!DOS_HandleDosToWin32) init_winedos();
+    if (DOS_HandleDosToWin32) h = DOS_HandleDosToWin32( handle );
+    return h;
 }
 
 
@@ -1125,7 +1081,10 @@
  */
 UINT WINAPI SetHandleCount( UINT count )
 {
-    return min( 256, count );
+    UINT ret=count;
+    if (!DOS_SetHandleCount) init_winedos();
+    if (DOS_SetHandleCount) ret = DOS_SetHandleCount( count );
+    return ret;
 }
 
 
@@ -1139,17 +1098,8 @@
  */
 void WINAPI DisposeLZ32Handle( HANDLE handle )
 {
-    int i;
-
-    if (!handle || (handle == INVALID_HANDLE_VALUE)) return;
-
-    for (i = 5; i < DOS_TABLE_SIZE; i++)
-        if (dos_handles[i] == handle)
-        {
-            dos_handles[i] = 0;
-            CloseHandle( handle );
-            break;
-        }
+    if (!DOS_DisposeLZ32Handle) init_winedos();
+    if (DOS_DisposeLZ32Handle) DOS_DisposeLZ32Handle( handle );
 }
 
 /**************************************************************************
Index: dlls/kernel/file16.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/file16.c,v
retrieving revision 1.12
diff -u -r1.12 file16.c
--- dlls/kernel/file16.c	1 May 2004 05:25:08 -0000	1.12
+++ dlls/kernel/file16.c	12 Oct 2004 15:34:13 -0000
@@ -253,15 +253,10 @@
  */
 HFILE16 WINAPI _lclose16( HFILE16 hFile )
 {
-    if ((hFile >= DOS_TABLE_SIZE) || !dos_handles[hFile])
-    {
-        SetLastError( ERROR_INVALID_HANDLE );
-        return HFILE_ERROR16;
-    }
-    TRACE("%d (handle32=%p)\n", hFile, dos_handles[hFile] );
-    CloseHandle( dos_handles[hFile] );
-    dos_handles[hFile] = 0;
-    return 0;
+    HFILE16 h = HFILE_ERROR16;
+    if (!DOS_Close) init_winedos();
+    if (DOS_Close) h = DOS_Close( hFile );
+    return h;
 }
 
 /***********************************************************************
Index: dlls/kernel/instr.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/instr.c,v
retrieving revision 1.15
diff -u -r1.15 instr.c
--- dlls/kernel/instr.c	14 Jun 2004 17:04:35 -0000	1.15
+++ dlls/kernel/instr.c	12 Oct 2004 15:34:17 -0000
@@ -68,13 +68,17 @@
 }
 
 
-static void (WINAPI *DOS_EmulateInterruptPM)( CONTEXT86 *context, BYTE intnum );
-static void (WINAPI *DOS_CallBuiltinHandler)( CONTEXT86 *context, BYTE intnum );
-static DWORD (WINAPI *DOS_inport)( int port, int size );
-static void (WINAPI *DOS_outport)( int port, int size, DWORD val );
+void (WINAPI *DOS_EmulateInterruptPM)( CONTEXT86 *context, BYTE intnum );
+void (WINAPI *DOS_CallBuiltinHandler)( CONTEXT86 *context, BYTE intnum );
+DWORD (WINAPI *DOS_inport)( int port, int size );
+void (WINAPI *DOS_outport)( int port, int size, DWORD val );
+HFILE (WINAPI *DOS_HandleWin32ToDos)( HANDLE handle );
+HANDLE (WINAPI *DOS_HandleDosToWin32)( HFILE handle );
+UINT (WINAPI *DOS_SetHandleCount)( UINT count );
+void (WINAPI *DOS_DisposeLZ32Handle)( HANDLE handle );
+HFILE (WINAPI *DOS_Close)( HFILE hFile );
 
-
-static void init_winedos(void)
+void init_winedos(void)
 {
     static HMODULE module;
 
@@ -91,6 +95,11 @@
     GET_ADDR(outport);
     GET_ADDR(EmulateInterruptPM);
     GET_ADDR(CallBuiltinHandler);
+    GET_ADDR(HandleWin32ToDos);
+    GET_ADDR(HandleDosToWin32);
+    GET_ADDR(SetHandleCount);
+    GET_ADDR(DisposeLZ32Handle);
+    GET_ADDR(Close);
 #undef GET_ADDR
 }
 
Index: dlls/kernel/kernel32.spec
===================================================================
RCS file: /home/wine/wine/dlls/kernel/kernel32.spec,v
retrieving revision 1.138
diff -u -r1.138 kernel32.spec
--- dlls/kernel/kernel32.spec	24 Aug 2004 18:46:05 -0000	1.138
+++ dlls/kernel/kernel32.spec	12 Oct 2004 15:34:19 -0000
@@ -1100,7 +1100,6 @@
 ################################################################
 # Wine extensions: Win16 functions that are needed by other dlls
 #
-@ stdcall _lclose16(long)
 @ stdcall AllocCStoDSAlias16(long)
 @ stdcall AllocSelectorArray16(long)
 @ stdcall ConvertDialog32To16(ptr long ptr)
Index: dlls/kernel/kernel_private.h
===================================================================
RCS file: /home/wine/wine/dlls/kernel/kernel_private.h,v
retrieving revision 1.20
diff -u -r1.20 kernel_private.h
--- dlls/kernel/kernel_private.h	14 May 2004 21:43:18 -0000	1.20
+++ dlls/kernel/kernel_private.h	12 Oct 2004 15:34:19 -0000
@@ -46,10 +46,6 @@
 
 extern HMODULE kernel32_handle;
 
-/* Size of per-process table of DOS handles */
-#define DOS_TABLE_SIZE 256
-extern HANDLE dos_handles[DOS_TABLE_SIZE];
-
 extern const WCHAR *DIR_Windows;
 extern const WCHAR *DIR_System;
 
@@ -76,6 +72,17 @@
    (wine_ldt_is_system(sel) || (wine_ldt_copy.flags[LOWORD(sel) >> 3] & WINE_LDT_FLAGS_32BIT))
 
 extern HANDLE VXD_Open( LPCWSTR filename, DWORD access, LPSECURITY_ATTRIBUTES sa );
+
+extern void init_winedos(void);
+extern void (WINAPI *DOS_EmulateInterruptPM)( CONTEXT86 *context, BYTE intnum );
+extern void (WINAPI *DOS_CallBuiltinHandler)( CONTEXT86 *context, BYTE intnum );
+extern DWORD (WINAPI *DOS_inport)( int port, int size );
+extern void (WINAPI *DOS_outport)( int port, int size, DWORD val );
+extern HFILE (WINAPI *DOS_HandleWin32ToDos)( HANDLE handle );
+extern HANDLE (WINAPI *DOS_HandleDosToWin32)( HFILE handle );
+extern UINT (WINAPI *DOS_SetHandleCount)( UINT count );
+extern void (WINAPI *DOS_DisposeLZ32Handle)( HANDLE handle );
+extern HFILE (WINAPI *DOS_Close)( HFILE hFile );
 
 /* this structure is always located at offset 0 of the DGROUP segment */
 #include "pshpack1.h"
? dlls/winedos/file.c
? dlls/winedos/memory.c
Index: dlls/winedos/Makefile.in
===================================================================
RCS file: /home/wine/wine/dlls/winedos/Makefile.in,v
retrieving revision 1.28
diff -u -r1.28 Makefile.in
--- dlls/winedos/Makefile.in	11 Aug 2004 23:59:07 -0000	1.28
+++ dlls/winedos/Makefile.in	12 Oct 2004 15:37:09 -0000
@@ -14,6 +14,7 @@
 	dosaspi.c \
 	dosconf.c \
 	dosvm.c \
+	file.c \
 	fpu.c \
 	himem.c \
 	int09.c \
Index: dlls/winedos/dosexe.h
===================================================================
RCS file: /home/wine/wine/dlls/winedos/dosexe.h,v
retrieving revision 1.34
diff -u -r1.34 dosexe.h
--- dlls/winedos/dosexe.h	15 Nov 2003 00:13:21 -0000	1.34
+++ dlls/winedos/dosexe.h	12 Oct 2004 15:37:20 -0000
@@ -31,6 +31,8 @@
 #include "miscemu.h"
 
 #define MAX_DOS_DRIVES  26
+/* Size of the system file table */
+#define SFT_TABLE_SIZE 256
 
 struct _DOSEVENT;
 
@@ -88,6 +90,7 @@
 extern WORD DOSVM_psp;     /* psp of current DOS task */
 extern WORD DOSVM_retval;  /* return value of previous DOS task */
 extern struct DPMI_segments *DOSVM_dpmi_segments;
+extern HANDLE sft_handles[SFT_TABLE_SIZE];  /* some kind of a system file table */
 
 #if defined(linux) && defined(__i386__) && defined(HAVE_SYS_VM86_H)
 # define MZ_SUPPORTED
@@ -220,6 +223,13 @@
 
 /* dosconf.c */
 DOSCONF *DOSCONF_GetConfig( void );
+
+/* file.c */
+extern HFILE WINAPI FILE_HandleWin32ToDos( HANDLE handle );
+extern HANDLE WINAPI FILE_HandleDosToWin32( HFILE handle );
+extern UINT WINAPI FILE_SetHandleCount( UINT count );
+extern void WINAPI FILE_DisposeLZ32Handle( HANDLE handle );
+extern HFILE WINAPI FILE_Close( HFILE hFile );
 
 /* fpu.c */
 extern void WINAPI DOSVM_Int34Handler(CONTEXT86*);
Index: dlls/winedos/int21.c
===================================================================
RCS file: /home/wine/wine/dlls/winedos/int21.c,v
retrieving revision 1.72
diff -u -r1.72 int21.c
--- dlls/winedos/int21.c	22 Sep 2004 02:46:39 -0000	1.72
+++ dlls/winedos/int21.c	12 Oct 2004 15:37:43 -0000
@@ -1123,7 +1123,7 @@
     /*
      * Return DOS file handle and DOS status.
      */
-    SET_AX( context, Win32HandleToDosFileHandle(winHandle) );
+    SET_AX( context, FILE_HandleWin32ToDos(winHandle) );
 
     if (returnStatus)
         SET_CX( context, dosStatus );
@@ -1266,20 +1266,20 @@
             TRACE("_lopen(\"%s\") failed: INVALID_HANDLE_VALUE\n", file_path);
             AL_result = 0xff; /* failed */
         } else {
-            hfile16 = Win32HandleToDosFileHandle(handle);
+            hfile16 = FILE_HandleWin32ToDos(handle);
             if (hfile16 == HFILE_ERROR16) {
-                TRACE("Win32HandleToDosFileHandle(%p) failed: HFILE_ERROR\n", handle);
+                TRACE("FILE_HandleWin32ToDos(%p) failed: HFILE_ERROR\n", handle);
                 CloseHandle(handle);
                 AL_result = 0xff; /* failed */
             } else if (hfile16 > 255) {
                 TRACE("hfile16 (=%d) larger than 255 for \"%s\"\n", hfile16, file_path);
-                _lclose16(hfile16);
+                FILE_Close(hfile16);
                 AL_result = 0xff; /* failed */
             } else {
                 if (!GetFileInformationByHandle(handle, &info)) {
                     TRACE("GetFileInformationByHandle(%d, %p) for \"%s\" failed\n",
                           hfile16, handle, file_path);
-                    _lclose16(hfile16);
+                    FILE_Close(hfile16);
                     AL_result = 0xff; /* failed */
                 } else {
                     fcb->drive_number = file_path[0] - 'A' + 1;
@@ -1337,8 +1337,8 @@
         fcb = (struct FCB *) xfcb->fcb;
     } /* if */
 
-    if (_lclose16((HFILE16) fcb->file_number) != 0) {
-        TRACE("_lclose16(%d) failed\n", fcb->file_number);
+    if (FILE_Close((HFILE16) fcb->file_number) != 0) {
+        TRACE("FILE_Close(%d) failed\n", fcb->file_number);
         AL_result = 0xff; /* failed */
     } else {
         TRACE("successful closed file %d\n", fcb->file_number);
@@ -1387,9 +1387,9 @@
         fcb = (struct FCB *) xfcb->fcb;
     } /* if */
 
-    handle = DosFileHandleToWin32Handle((HFILE16) fcb->file_number);
+    handle = FILE_HandleDosToWin32((HFILE16) fcb->file_number);
     if (handle == INVALID_HANDLE_VALUE) {
-        TRACE("DosFileHandleToWin32Handle(%d) failed: INVALID_HANDLE_VALUE\n",
+        TRACE("FILE_HandleDosToWin32(%d) failed: INVALID_HANDLE_VALUE\n",
             fcb->file_number);
         AL_result = 0x01; /* end of file, no data read */
     } else {
@@ -1467,9 +1467,9 @@
         fcb = (struct FCB *) xfcb->fcb;
     } /* if */
 
-    handle = DosFileHandleToWin32Handle((HFILE16) fcb->file_number);
+    handle = FILE_HandleDosToWin32((HFILE16) fcb->file_number);
     if (handle == INVALID_HANDLE_VALUE) {
-        TRACE("DosFileHandleToWin32Handle(%d) failed: INVALID_HANDLE_VALUE\n",
+        TRACE("FILE_HandleDosToWin32(%d) failed: INVALID_HANDLE_VALUE\n",
             fcb->file_number);
         AL_result = 0x01; /* disk full */
     } else {
@@ -1544,9 +1544,9 @@
     } /* if */
 
     memcpy(&record_number, fcb->random_access_record_number, 4);
-    handle = DosFileHandleToWin32Handle((HFILE16) fcb->file_number);
+    handle = FILE_HandleDosToWin32((HFILE16) fcb->file_number);
     if (handle == INVALID_HANDLE_VALUE) {
-        TRACE("DosFileHandleToWin32Handle(%d) failed: INVALID_HANDLE_VALUE\n",
+        TRACE("FILE_HandleDosToWin32(%d) failed: INVALID_HANDLE_VALUE\n",
             fcb->file_number);
         AL_result = 0x01; /* end of file, no data read */
     } else {
@@ -1617,9 +1617,9 @@
     } /* if */
 
     memcpy(&record_number, fcb->random_access_record_number, 4);
-    handle = DosFileHandleToWin32Handle((HFILE16) fcb->file_number);
+    handle = FILE_HandleDosToWin32((HFILE16) fcb->file_number);
     if (handle == INVALID_HANDLE_VALUE) {
-        TRACE("DosFileHandleToWin32Handle(%d) failed: INVALID_HANDLE_VALUE\n",
+        TRACE("FILE_HandleDosToWin32(%d) failed: INVALID_HANDLE_VALUE\n",
             fcb->file_number);
         AL_result = 0x01; /* disk full */
     } else {
@@ -1695,9 +1695,9 @@
     } /* if */
 
     memcpy(&record_number, fcb->random_access_record_number, 4);
-    handle = DosFileHandleToWin32Handle((HFILE16) fcb->file_number);
+    handle = FILE_HandleDosToWin32((HFILE16) fcb->file_number);
     if (handle == INVALID_HANDLE_VALUE) {
-        TRACE("DosFileHandleToWin32Handle(%d) failed: INVALID_HANDLE_VALUE\n",
+        TRACE("FILE_HandleDosToWin32(%d) failed: INVALID_HANDLE_VALUE\n",
             fcb->file_number);
         records_read = 0;
         AL_result = 0x01; /* end of file, no data read */
@@ -1786,9 +1786,9 @@
     } /* if */
 
     memcpy(&record_number, fcb->random_access_record_number, 4);
-    handle = DosFileHandleToWin32Handle((HFILE16) fcb->file_number);
+    handle = FILE_HandleDosToWin32((HFILE16) fcb->file_number);
     if (handle == INVALID_HANDLE_VALUE) {
-        TRACE("DosFileHandleToWin32Handle(%d) failed: INVALID_HANDLE_VALUE\n",
+        TRACE("FILE_HandleDosToWin32(%d) failed: INVALID_HANDLE_VALUE\n",
             fcb->file_number);
         records_written = 0;
         AL_result = 0x01; /* disk full */
@@ -2254,7 +2254,7 @@
  */
 static BOOL INT21_FileDateTime( CONTEXT86 *context )
 {
-    HANDLE   handle = DosFileHandleToWin32Handle(BX_reg(context));
+    HANDLE   handle = FILE_HandleDosToWin32(BX_reg(context));
     FILETIME filetime;
     WORD     date, time;
 
@@ -2731,7 +2731,7 @@
 {
     struct stat st;
     int status, i, fd;
-    HANDLE handle = DosFileHandleToWin32Handle(BX_reg(context));
+    HANDLE handle = FILE_HandleDosToWin32(BX_reg(context));
 
     status = wine_server_handle_to_fd( handle, 0, &fd, NULL );
     if (status)
@@ -3264,7 +3264,7 @@
           
     case 0xa6: /* LONG FILENAME - GET FILE INFO BY HANDLE */
         {
-            HANDLE handle = DosFileHandleToWin32Handle(BX_reg(context));
+            HANDLE handle = FILE_HandleDosToWin32(BX_reg(context));
             BY_HANDLE_FILE_INFORMATION *info =
                 CTX_SEG_OFF_TO_LIN(context, context->SegDs, context->Edx);
             
@@ -3633,7 +3633,7 @@
         counter = (counter + 1) % 1000;
 
         SET_AX( context, 
-                Win32HandleToDosFileHandle( 
+                FILE_HandleWin32ToDos( 
                     CreateFileA( name, GENERIC_READ | GENERIC_WRITE,
                                  FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
                                  CREATE_NEW, 0, 0 ) ) );
@@ -4059,11 +4059,11 @@
     DWORD       map[DOS_TABLE_SIZE / 32];
     int         i;
 
-    handle = DosFileHandleToWin32Handle(hFile1);
+    handle = FILE_HandleDosToWin32(hFile1);
     if (handle == INVALID_HANDLE_VALUE)
         return FALSE;
 
-    _lclose16(hFile2);
+    FILE_Close(hFile2);
     /* now loop to allocate the same one... */
     memset(map, 0, sizeof(map));
     for (i = 0; i < DOS_TABLE_SIZE; i++)
@@ -4075,7 +4075,7 @@
             res = HFILE_ERROR16;
             break;
         }
-        res = Win32HandleToDosFileHandle(new_handle);
+        res = FILE_HandleWin32ToDos(new_handle);
         if (res == HFILE_ERROR16 || res == hFile2) break;
         map[res / 32] |= 1 << (res % 32);
     }
@@ -4083,7 +4083,7 @@
     for (i = 0; i < DOS_TABLE_SIZE; i++)
     {
         if (map[i / 32] & (1 << (i % 32)))
-            _lclose16((HFILE16)i);
+            FILE_Close((HFILE16)i);
     }
     return res == hFile2;
 }
@@ -4217,7 +4217,7 @@
             while (*p != '$') p++;
 
             if (DOSVM_IsWin16())
-                WriteFile( DosFileHandleToWin32Handle(1), 
+                WriteFile( FILE_HandleDosToWin32(1), 
                            data, p - data, 0, 0 );
             else
                 for(; data != p; data++)
@@ -4714,7 +4714,7 @@
 
     case 0x3e: /* "CLOSE" - CLOSE FILE */
         TRACE( "CLOSE handle %d\n", BX_reg(context) );
-        if (_lclose16( BX_reg(context) ) == HFILE_ERROR16)
+        if (FILE_Close( BX_reg(context) ) == HFILE_ERROR16)
             bSetDOSExtendedError = TRUE;
         else
             RESET_CFLAG(context);
@@ -4753,7 +4753,7 @@
                 result = INT21_BufferedInput( context, buffer, count );
                 SET_AX( context, (WORD)result );
             }
-            else if (ReadFile( DosFileHandleToWin32Handle(BX_reg(context)),
+            else if (ReadFile( FILE_HandleDosToWin32(BX_reg(context)),
                                buffer, count, &result, NULL ))
                 SET_AX( context, (WORD)result );
             else
@@ -4779,7 +4779,7 @@
             }
             else
             {
-                HFILE handle = (HFILE)DosFileHandleToWin32Handle(BX_reg(context));
+                HFILE handle = (HFILE)FILE_HandleDosToWin32(BX_reg(context));
                 LONG result = _hwrite( handle, ptr, CX_reg(context) );
                 if (result == HFILE_ERROR)
                     bSetDOSExtendedError = TRUE;
@@ -4817,7 +4817,7 @@
                "start of file" : ((AL_reg(context) == 1) ? 
                                   "current file position" : "end of file") );
         {
-            HANDLE handle = DosFileHandleToWin32Handle(BX_reg(context));
+            HANDLE handle = FILE_HandleDosToWin32(BX_reg(context));
             LONG   offset = MAKELONG( DX_reg(context), CX_reg(context) );
             DWORD  status = SetFilePointer( handle, offset, 
                                             NULL, AL_reg(context) );
@@ -4850,11 +4850,11 @@
             HFILE  handle16 = HFILE_ERROR;
 
             if (DuplicateHandle( GetCurrentProcess(),
-                                 DosFileHandleToWin32Handle(BX_reg(context)),
+                                 FILE_HandleDosToWin32(BX_reg(context)),
                                  GetCurrentProcess(), 
                                  &handle32,
                                  0, TRUE, DUPLICATE_SAME_ACCESS ))
-                handle16 = Win32HandleToDosFileHandle(handle32);
+                handle16 = FILE_HandleWin32ToDos(handle32);
 
             if (handle16 == HFILE_ERROR)
                 bSetDOSExtendedError = TRUE;
@@ -5116,7 +5116,7 @@
         {
             DWORD  offset = MAKELONG(DX_reg(context), CX_reg(context));
             DWORD  length = MAKELONG(DI_reg(context), SI_reg(context));
-            HANDLE handle = DosFileHandleToWin32Handle(BX_reg(context));
+            HANDLE handle = FILE_HandleDosToWin32(BX_reg(context));
 
             RESET_CFLAG(context);
             switch (AL_reg(context))
@@ -5227,13 +5227,13 @@
 
     case 0x67: /* SET HANDLE COUNT */
         TRACE( "SET HANDLE COUNT to %d\n", BX_reg(context) );
-        if (SetHandleCount( BX_reg(context) ) < BX_reg(context) )
+        if (FILE_SetHandleCount( BX_reg(context) ) < BX_reg(context) )
             bSetDOSExtendedError = TRUE;
         break;
 
     case 0x68: /* "FFLUSH" - COMMIT FILE */
         TRACE( "FFLUSH - handle %d\n", BX_reg(context) );
-        if (!FlushFileBuffers( DosFileHandleToWin32Handle(BX_reg(context)) ))
+        if (!FlushFileBuffers( FILE_HandleDosToWin32(BX_reg(context)) ))
             bSetDOSExtendedError = TRUE;
         break;
 
@@ -5258,7 +5258,7 @@
 
     case 0x6a: /* COMMIT FILE */
         TRACE( "COMMIT FILE - handle %d\n", BX_reg(context) );
-        if (!FlushFileBuffers( DosFileHandleToWin32Handle(BX_reg(context)) ))
+        if (!FlushFileBuffers( FILE_HandleDosToWin32(BX_reg(context)) ))
             bSetDOSExtendedError = TRUE;
         break;
 
Index: dlls/winedos/vxd.c
===================================================================
RCS file: /home/wine/wine/dlls/winedos/vxd.c,v
retrieving revision 1.7
diff -u -r1.7 vxd.c
--- dlls/winedos/vxd.c	22 Sep 2004 02:46:39 -0000	1.7
+++ dlls/winedos/vxd.c	12 Oct 2004 15:38:04 -0000
@@ -1111,7 +1111,7 @@
         LARGE_INTEGER *size = (LARGE_INTEGER *)W32S_APP2WINE(stack[3]);
         DWORD  protect  = stack[4];
         DWORD  flags2   = stack[5];
-        HANDLE hFile    = DosFileHandleToWin32Handle(stack[6]);
+        HANDLE hFile    = FILE_HandleDosToWin32(stack[6]);
         DWORD  psp      = stack[7];
 
         HANDLE result = INVALID_HANDLE_VALUE;
Index: dlls/winedos/winedos.spec
===================================================================
RCS file: /home/wine/wine/dlls/winedos/winedos.spec,v
retrieving revision 1.17
diff -u -r1.17 winedos.spec
--- dlls/winedos/winedos.spec	17 Sep 2003 22:45:46 -0000	1.17
+++ dlls/winedos/winedos.spec	12 Oct 2004 15:38:04 -0000
@@ -6,3 +6,10 @@
 # I/O functions
 @ stdcall inport(long long) DOSVM_inport
 @ stdcall outport(long long long) DOSVM_outport
+
+# DOS File Functions
+@ stdcall HandleWin32ToDos(ptr) FILE_HandleWin32ToDos
+@ stdcall HandleDosToWin32(long) FILE_HandleDosToWin32
+@ stdcall SetHandleCount(long) FILE_SetHandleCount
+@ stdcall DisposeLZ32Handle(ptr) FILE_DisposeLZ32Handle
+@ stdcall Close(long) FILE_Close


More information about the wine-patches mailing list