delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/08/14/05:54:01

From: pavenis AT lanet DOT lv
To: "Andrew Cottrell" <acottrel AT ihug DOT com DOT au>, <pavenis AT lanet DOT lv>,
<sandmann AT clio DOT rice DOT edu>, <djgpp-workers AT delorie DOT com>
Date: Tue, 14 Aug 2001 12:53:58 +0300
MIME-Version: 1.0
Subject: Re: Selector Exhaustion
Message-ID: <3B791F66.22654.6DAEEC@localhost>
In-reply-to: <026201c12403$e0d609f0$0a02a8c0@acceleron>
X-mailer: Pegasus Mail for Win32 (v3.12c)
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On 14 Aug 2001, at 0:26, Andrew Cottrell wrote:

> 
> The issue I had was that Charles patch was for Win 2K and Andris patch was
> for Win 98. I wanted to have the same source and executables for both Win 98
> and 2K.  Between the patch from Charles that was for Win 2K issues and
> Andris and your comments about this last week I thought it best to only
> enable the code in Charles's patch on my Win 2K box and don't enable the
> function calls when running on my Win 98 box. I thought it was better safe
> than sorry.
> 

Here is patch that seems to work both under Win98SE and 
WinNT 4.0+SP6 (with my test program). I added wrapper procedure
around original direct_exec_tail() as I think it's easier to debug if 
needed.

Cannot test on Win2k though.

Andris

*** djgpp/src/libc/dos/process/dosexec.c~1	Mon Jul 30 14:35:52 2001
--- djgpp/src/libc/dos/process/dosexec.c	Tue Aug 14 12:42:24 2001
*************** size_t __cmdline_str_len = sizeof(__cmdl
*** 157,163 ****
     if LFN is 2, there is a possiblity that the contents of the
     transfer buffer will be overrun!  */
  static int
! direct_exec_tail(const char *program, const char *args,
  		 char * const envp[], const char *proxy, int lfn,
  		 const char *cmdline_var)
  {
--- 157,163 ----
     if LFN is 2, there is a possiblity that the contents of the
     transfer buffer will be overrun!  */
  static int
! direct_exec_tail_1 (const char *program, const char *args,
  		 char * const envp[], const char *proxy, int lfn,
  		 const char *cmdline_var)
  {
*************** direct_exec_tail(const char *program, co
*** 413,418 ****
--- 413,469 ----
    return r.h.al;	/* AL holds the child exit code */
  }
  
+ 
+ 
+ static int direct_exec_tail (const char *program, const char *args,
+ 		 char * const envp[], const char *proxy, int lfn,
+ 		 const char *cmdline_var)
+ {
+   int   i, ret;
+   int   sel1=0, sel2=0;
+   char  desc_map[8192];
+   int is_nt = (_osmajor==5 && _osminor==0 && _get_dos_version(1)==0x0532) ?
+                            1 : 0;
+   if (is_nt)
+   {
+      sel1 = __dpmi_allocate_ldt_descriptors (1);
+   }
+   else
+   {
+      char * map = desc_map;
+      for (i=0x0000007; i<0x00010000; i+=8)
+      {  /* FIXME: Use __dpmi_get_selector_increment_value() instead of 8 ?  */
+         *map++ = (__dpmi_get_descriptor_access_rights(i) & 0x80) ? 0 : 1;
+      }
+   }
+ 
+   ret = direct_exec_tail_1 ( program, args, envp, proxy, lfn, cmdline_var );
+ 
+   if (is_nt)
+   {
+      sel2 = __dpmi_allocate_ldt_descriptors (1);
+      if (sel1>_dos_ds && sel2>_dos_ds)
+      {
+         for (i=sel2; i>=sel1; i-=8)
+            __dpmi_free_ldt_descriptor (i);
+      }
+   }
+   else
+   {
+      char * map = desc_map;
+      for (i=0x0000007; i<0x00010000; i+=8)
+      {
+         if (*map++)
+         {
+             if (__dpmi_get_descriptor_access_rights(i) & 0x80)
+                 __dpmi_free_ldt_descriptor (i);
+         }
+      }
+   }
+   return ret;
+ }
+ 
+ 
  int
  _dos_exec(const char *program, const char *args, char * const envp[],
  	  const char *cmdline_var)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019