[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wine-devel
Subject:    Correct DPMI Allocate memory block on special case
From:       Uwe Bonnes <bon () elektron ! ikp ! physik ! tu-darmstadt ! de>
Date:       2000-02-27 22:54:29
[Download RAW message or body]

Hallo,

some DPMI programs set a selector base of NULL. Wine doesn't allow
that and corrects the Base to DOSMEM_MapDosToLinear(0). If the DPMI
client then later uses function 0x0501:  /* Allocate memory block */
with this selector, things go wrong, as the access happens at 
*(DOSMEM_MapDosToLinear(0) +memory). While DPMI is working on such a
coorected selector base, appended patch corrects the linear adress
that func 0501 returns.
This may go wrong in some situations, so the WARN message, but helps
me for some file.

Is this patch acceptable?

Bye

Uwe Bonnes                bon@elektron.ikp.physik.tu-darmstadt.de

Free Software: If you contribute nothing, expect nothing
--

Index: wine/msdos/dpmi.c
===================================================================
RCS file: /home/wine/wine/msdos/dpmi.c,v
retrieving revision 1.32
diff -u -r1.32 dpmi.c
--- wine/msdos/dpmi.c	2000/02/26 16:51:14	1.32
+++ wine/msdos/dpmi.c	2000/02/27 15:50:07
@@ -29,6 +29,7 @@
 void CreateBPB(int drive, BYTE *data, BOOL16 limited);  /* defined in int21.c */
 
 static void* lastvalloced = NULL;
+static int fullrange=0;
 
 /* Structure for real-mode callbacks */
 typedef struct
@@ -874,6 +875,11 @@
 	    dw = DOS_APPTOWINE(dw, base);
         }
 #endif
+	if (!dw)
+	  /* SetSelectorBase will set the base to DOSMEM_MapDosToLinear(0)*/
+	  fullrange=1;
+	else
+	  fullrange=0;
         SetSelectorBase(BX_reg(context), dw);
         break;
 
@@ -917,6 +923,7 @@
             AX_reg(context) = 0x8011;  /* descriptor unavailable */
             SET_CFLAG(context);
         }
+	EDI_reg(context) = 0;
         break;
 
     case 0x000b:  /* Get descriptor */
@@ -1093,7 +1100,16 @@
         } else {
             BX_reg(context) = SI_reg(context) = HIWORD(W32S_WINE2APP(ptr, offset));
             CX_reg(context) = DI_reg(context) = LOWORD(W32S_WINE2APP(ptr, offset));
+	    if (fullrange)
+	      /* Try to correct while there is a selector with base 0 */
+	      {
+		WARN("Correcting Linear Adress. Things may crash\n");
+		BX_reg(context) = HIWORD((ptr)-(DWORD)DOSMEM_MapDosToLinear(0));
+		CX_reg(context) = LOWORD((ptr)-(DWORD)DOSMEM_MapDosToLinear(0));
+	      }
+
         }
+	TRACE("ptr %08x\n",ptr);
         break;
 
     case 0x0502:  /* Free memory block */

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic