[WINEDOS] FIX GET DEVICE INFORMATION for STDIO

markus.amsler at oribi.org markus.amsler at oribi.org
Fri Jun 4 09:16:37 CDT 2004


Hi,

QuickBasic compiled console apps, check the stdinput, stdoutput capabilities
through int21: GET DEVICE INFORMATION. If the check fails, they fallback into a
limited file read/write mode. If the check succeeds, they use direct BIOS memory
output.
This patch makes the test succeeding.

Changelog:
	Markus Amsler <markus.amsler att oribi.org>
	make int21: GET DEVICE IFORMATION for STDIO handles succeeding.

Markus

Index: dlls/winedos/int21.c
===================================================================
RCS file: /home/wine/wine/dlls/winedos/int21.c,v
retrieving revision 1.62
diff -u -r1.62 int21.c
--- dlls/winedos/int21.c	3 Jun 2004 23:20:35 -0000	1.62
+++ dlls/winedos/int21.c	4 Jun 2004 11:37:19 -0000
@@ -246,6 +246,12 @@
 #define EL_Serial            0x04
 #define EL_Memory            0x05

+/* STDIO device handles */
+#define STDIO_Input          0x00
+#define STDIO_Output         0x01
+#define STDIO_Error          0x02
+
+#define IS_STDIO(h)          ((h)==STDIO_Input || (h)==STDIO_Output ||
(h)==STDIO_Error)

 struct magic_device
 {
@@ -2659,27 +2665,52 @@
 {
     struct stat st;
     int status, i, fd;
-    HANDLE handle = DosFileHandleToWin32Handle(BX_reg(context));
+    int dos_handle;
+    HANDLE handle;
+    WORD ret;

-    status = wine_server_handle_to_fd( handle, 0, &fd, NULL, NULL );
-    if (status)
-    {
-        SET_AX( context, RtlNtStatusToDosError(status) );
-        SET_CFLAG( context );
-        return;
-    }
-    fstat( fd, &st );
-    wine_server_release_fd( handle, fd );
+    dos_handle = BX_reg(context);
+    ret = 0;

-    for (i = 0; i < NB_MAGIC_DEVICES; i++)
+    if (IS_STDIO(dos_handle)){
+        /*
+         * STDIO Device are always open, and are character devices
+         *
+         * FIXME: this is just a workaround, so STDIO Devices
+         *        won't return an invalid handle error
+         */
+        st.st_mode = S_IFCHR;
+        /*
+         * Windows 2000 Console returns 0x80d3 for STDIO_Output
+         * so it flags an output device as an input ??
+         */
+        ret = 0x0013;
+    }
+    else
     {
-        if (!magic_devices[i].handle) continue;
-        if (magic_devices[i].dev == st.st_dev && magic_devices[i].ino ==
st.st_ino)
+        handle = DosFileHandleToWin32Handle(dos_handle);
+
+        status = wine_server_handle_to_fd( handle, 0, &fd, NULL, NULL );
+        if (status)
         {
-            /* found it */
-            magic_devices[i].ioctl_handler( context );
+            SET_AX( context, RtlNtStatusToDosError(status) );
+            SET_CFLAG( context );
             return;
         }
+        fstat( fd, &st );
+        wine_server_release_fd( handle, fd );
+
+        for (i = 0; i < NB_MAGIC_DEVICES; i++)
+        {
+            if (!magic_devices[i].handle) continue;
+            if (magic_devices[i].dev == st.st_dev && magic_devices[i].ino ==
st.st_ino)
+            {
+                /* found it */
+                magic_devices[i].ioctl_handler( context );
+                return;
+            }
+        }
     }

     /* no magic device found, do default handling */
@@ -4693,8 +4725,7 @@
         {
             BYTE *ptr = CTX_SEG_OFF_TO_LIN(context, context->SegDs,
context->Edx);

-            if (!DOSVM_IsWin16() &&
-                (BX_reg(context) == 1 || BX_reg(context) == 2))
+            if (!DOSVM_IsWin16() && IS_STDIO(BX_reg(context)))
             {
                 int i;
                 for(i=0; i<CX_reg(context); i++)



More information about the wine-patches mailing list