Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

A LISP programmer knows the value of everything, but the cost of nothing. -- Alan Perlis


devel / comp.os.msdos.djgpp / [PING][PATCH v2] stub: ignore host exit status

SubjectAuthor
* [PING][PATCH v2] stub: ignore host exit statusJ.W. Jagersma (jwjagersma@gmail.com) [via djgpp@delorie.com]
+- Re: [PATCH] stub: ignore host exit statusJ.W. Jagersma (jwjagersma@gmail.com) [via djgpp@delorie.com]
`- Re: [PING][PATCH v2] stub: ignore host exit statusOzkan Sezer (sezeroz@gmail.com) [via djgpp@delorie.com]

1
[PING][PATCH v2] stub: ignore host exit status

<5de28b44-10f2-c824-def1-d451035ecaad@gmail.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=232&group=comp.os.msdos.djgpp#232

  copy link   Newsgroups: comp.os.msdos.djgpp
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Tue, 24 Jan 2023 21:54:56 +0000
X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp@delorie.com
X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20210112;
h=content-transfer-encoding:in-reply-to:content-language:references
:to:from:subject:user-agent:mime-version:date:message-id:from:to:cc
:subject:date:message-id:reply-to;
bh=4zGNpDcOsODzpURnLHYFVozYOKJdppS+5OLLaApUr18=;
b=kLQinljZOh3YsU1rRztQJNo3mhOy87oeqOegL4HZMyVLEzNU2rFQVg9a/XT/vo6MRw
g1j7oDGJq2avIJ/AufXortpua0q7yjDAyNN+tGONtCIoNQNtBJXFXnClEd24TnuFA4dZ
QQVFtLYViKWi7HaZz6vGkoYuoztRRUaH8paRekIwAi1Nd/EhWu+6MoMnD7DltZzOcS0f
K9V5EIFR5EsQtpMt4jVcPRRVr3tnYCQb5h/Y6tEmCexcKgSZ5vFyt6zLrd/RIwyEq51m
OvnoeU3HefVnCmxjdb1L2I1vjIMoZu2sMHcFrAaNeqtgCzQ1n+awfWENdfWmuDr2/uGu
NwgQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=content-transfer-encoding:in-reply-to:content-language:references
:to:from:subject:user-agent:mime-version:date:message-id
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=4zGNpDcOsODzpURnLHYFVozYOKJdppS+5OLLaApUr18=;
b=VLryqdV+fS3t2u16I5PVMJvS4rri971lekxleNxf604VLK07Pig1FhlfGY3APyzkOW
RSm+Plh52+9YnEBgbhVl09elfOBAIMk4VLT6gKVfvjMVRJ+WZNhtcoRzwA77cUvRSu5F
bLD2y6k/5TKazT+8ArlqUa5CqvjpTHsUB4Am9NGilBRsZcvmsSjGy6JUvSec/Yf3FqiE
VhtJ9SjudQRXqhncSt+vJzacT2t41bpXaoL46wrjCRfrOjxkIHF0ON5JUSOa2Bt3UB1n
1jOiFovM9k++AbDItYKETP/QwlELOJvS/79DwC0yUsmelRCuW2lq2AhXG8tTw/15TwWV
/23w==
X-Gm-Message-State: AFqh2krFdu3bOIZNVE51FiLwiJATl/7Dgo6LNUVWTfCFbJaRMTdyhab7
J5QgBg+0yxccdLuu4UCUHQLEBAn07zA/LQ==
X-Google-Smtp-Source: AMrXdXsHDEKTB55OCmOyIEozkYM1tb5awHkq7TwDzPoNIRo+M0sXoz7Y5sekTwsMbvDL67pu6Aafqw==
X-Received: by 2002:a17:906:80d:b0:870:d15a:c2e0 with SMTP id e13-20020a170906080d00b00870d15ac2e0mr30903206ejd.51.1674583822255;
Tue, 24 Jan 2023 10:10:22 -0800 (PST)
Message-ID: <5de28b44-10f2-c824-def1-d451035ecaad@gmail.com>
Date: Tue, 24 Jan 2023 19:10:21 +0100
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Subject: [PING][PATCH v2] stub: ignore host exit status
From: djg...@delorie.com (J.W. Jagersma (jwjagersma@gmail.com) [via djgpp@delorie.com])
To: djgpp@delorie.com
References: <744f054f-9682-4a05-91ad-684b18c0122b@gmail.com>
<21e1aa0b-1511-0071-84c0-b20c6a3d1dae@gmail.com>
Content-Language: en-US
In-Reply-To: <21e1aa0b-1511-0071-84c0-b20c6a3d1dae@gmail.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Reply-To: djgpp@delorie.com
Errors-To: nobody@delorie.com
X-Mailing-List: djgpp@delorie.com
X-Unsubscribes-To: listserv@delorie.com
Precedence: bulk
Newsgroups: comp.os.msdos.djgpp
Organization: None provided
DJ-Gateway: from mailing list djgpp@delorie.com
Lines: 208
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-49otSWj9IIMqCnjK+i+vkVvS7fAdYJe9JzypPJZWSEnpX/vaI0XzHJnxdit/lQ92+twf2xDSsrVHBQM!9js7OTZvGBYrjH/pzMjPEcz0942pjUgDFENXJIa6+7bjOK+Wy6qsQiZrJIC+Q6kU2iGQe4ZmQjBJ
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: J.W. Jagersma (jwjag - Tue, 24 Jan 2023 18:10 UTC

Would appreciate any feedback on this. I know there's a small mistake in one
comment, but the code works.

On 2022-11-25 00:26, J.W. Jagersma wrote:
> On 2022-11-23 20:47, J.W. Jagersma wrote:
>> Hi all,
>>
>> If you've ever tried using hdpmi32 with a djgpp program, you may have
>> noticed some strange behavior. The program first fails to run with
>> "Load error: no DPMI", but on the second try, it suddenly works. Then
>> a third invocation fails again, the fourth runs fine, etc.
>>
>> When you rename 'hdpmi32.exe' to 'cwsdpmi.exe', your program seems to
>> run consistently. But this is only because there is a second (real)
>> cwsdpmi in your PATH somewhere. What really happens, is that your
>> program alternates between running under hdpmi and cwsdpmi.
>>
>> I finally figured out why this happens, and it's very simple: hdpmi uses
>> the exit status to indicate if it was loaded via xms, vcpi, or int15.
>> And the djgpp stub considers any non-zero exit status to be a failure,
>> so it keeps searching PATH until cwsdpmi is found, which always returns
>> zero.
>>
>> For a possible solution, I would suggest to ignore the return status
>> from the host, and just check int 2f/1687 after every exec. As an added
>> bonus, this saves 13 bytes of stub space.
>
> Amended patch follows - it no longer skips the last iteration (exec
> with no path).
>
> It's a bit larger, but still saves 6 bytes in total.
>
> --- a/src/stub/stub.asm
> +++ b/src/stub/stub.asm
> @@ -199,38 +199,49 @@ not_path:
> ;-----------------------------------------------------------------------------
> ; Get DPMI information before doing anything 386-specific
>
> - push es
> push di
> - xor cx, cx ; flag for load attempt set cx = 0
> - jz @f2 ; We always jump, shorter than jmp
> + ; Set up loadname in case of no DPMI.
> + ; First try current dir.
> + xor ah, ah ; Copy until this character (=0)
> + call store_env_string ; copy stub image to "loadname"
> + mov si, bx ; remove name so we can add DPMI name
> + mov di, [path_off] ; Pointer to path contents (next try)
> @b1:
> + xor cx, cx ; flag to signal end of loop
> +@b2:
> + call check_dpmi ; int 2f, ax=1687
> + jz @f3
> + call do_exec ; copy our name to string and try load
> + jcxz @f1 ; cx=0 while we have more paths to try
> + call check_dpmi ; last chance...
> + jz @f3
> mov al, 110
> mov dx, msg_no_dpmi
> jmpl error
> -@b2:
> - or cx, cx
> - jnz @b1 ; we already tried load once before
> - inc cx
> - call load_dpmi
> - jc @b1
> +@f1:
> + ; Set up loadname for next attempt.
> + mov ah, ';' ; Copy until this character
> + call store_env_string ; to "loadname"
> + or al, al ; Check terminating character
> + jne @f2 ; If ';', continue
> + dec di ; else point at null for next pass.
> @f2:
> - mov ax, 0x1687 ; get DPMI entry point
> - int 0x2f
> - or ax, ax
> - jnz @b2 ; if 0 then it's there
> - and bl, 1 ; 32 bit capable?
> - jz @b2
> + inc cx
> + cmp si, loadname ; anything there?
> + je @b2 ; final try (no path)
> + mov al, [si-1]
> + call test_delim ; is final character a path delimiter
> + je @b1
> + movb [si], '\\' ; no, add separator between path & name
> + inc si
> + jmp @b1
> @f3:
> - mov [modesw], di ; store the DPMI entry point
> - mov [modesw+2], es
> - mov [modesw_mem], si
> pop di
> - pop es
>
> ;-----------------------------------------------------------------------------
> ; Now, find the name of the program file we are supposed to load.
>
> -; xor ah, ah ; termination character (set above!)
> +; xor ah, ah ; termination char (set by check_dpmi)
> call store_env_string ; copy it to loadname, set bx
>
> mov [stubinfo_env_size], di
> @@ -700,36 +711,29 @@ pm_dos:
> ret
>
> ;-----------------------------------------------------------------------------
> -; load DPMI server if not present
> -; First check directory from which stub is loaded, then path, then default
> -; On entry di points to image name
> +; Check for presence of a DPMI host, and save the mode switch address.
> +; Zero flag is clear on success. Clobbers ax/bx/dx.
>
> -path_off:
> - .dw 0 ; If stays zero, no path
> -
> -load_dpmi:
> - xor ah, ah ; Copy until this character (=0)
> - call store_env_string ; copy stub image to "loadname"
> - mov si, bx ; remove name so we can add DPMI name
> - mov di, [path_off] ; Pointer to path contents (next try)
> - jmp @f2
> -loadloop:
> - mov ah, ';' ; Copy until this character
> - call store_env_string ; to "loadname"
> - or al,al ; Check terminating character
> - jne @f1 ; If ';', continue
> - dec di ; else point at null for next pass.
> -@f1:
> - cmp si, loadname ; anything there?
> - je do_exec ; final try (no path) let it return
> - mov al, [si-1]
> - call test_delim ; is final character a path delimiter
> - je @f2
> - movb [si], '\\' ; no, add separator between path & name
> - inc si
> -@f2:
> - call do_exec ; copy our name to string and try load
> - jc loadloop
> +check_dpmi:
> + push es
> + push cx
> + push di
> + push si
> + mov ax, 0x1687 ; get DPMI entry point
> + int 0x2f
> + mov dx, bx
> + or dl, 1 ; bx bit 0: 32-bit capable
> + xor bx, dx
> + or ax, bx ; DPMI present if ax = 0
> + jnz @f1
> + mov [modesw], di ; store the DPMI entry point
> + mov [modesw+2], es
> + mov [modesw_mem], si
> +@f1:
> + pop si
> + pop di
> + pop cx
> + pop es
> ret
>
> ;-----------------------------------------------------------------------------
> @@ -766,13 +770,6 @@ do_exec:
> int 0x21
> pop di
> pop es
> - jc @f1 ;carry set if exec failed
> -
> - mov ah, 0x4d ;get return code
> - int 0x21
> - sub ax, 0x300 ;ah=3 TSR, al=code (success)
> - neg ax ;CY, if not originally 0x300
> -@f1:
> jmp restore_umb ;called func. return for us.
>
> ;-----------------------------------------------------------------------------
> @@ -796,10 +793,9 @@ include_umb:
> @f1:
> ret
>
> -; Restore upper memory status. All registers and flags preserved.
> +; Restore upper memory status. All registers preserved.
>
> restore_umb:
> - pushf
> cmpb [dos_major], 5 ; Won't work before dos 5
> jb @f1
> push ax
> @@ -815,7 +811,6 @@ restore_umb:
> pop bx
> pop ax
> @f1:
> - popf
> ret
>
> ;-----------------------------------------------------------------------------
> @@ -840,6 +835,8 @@ msg_no_selectors:
> .db "no DPMI selectors$"
> msg_no_dpmi_memory:
> .db "no DPMI memory$"
> +path_off:
> + .dw 0 ; Points to PATH, stays zero if none.
>
> ;-----------------------------------------------------------------------------
> ; Unstored Data, available during and after mode switch
>

Re: [PATCH] stub: ignore host exit status

<ba7e4d79-1a5b-7fbe-310e-dd192b576722@gmail.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=236&group=comp.os.msdos.djgpp#236

  copy link   Newsgroups: comp.os.msdos.djgpp
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!69.80.99.23.MISMATCH!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Wed, 25 Jan 2023 21:13:48 +0000
X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp@delorie.com
X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=6W0qy4+ujq7G37kDc1B5RsNpqsv4dtxEvJHVNsySAQk=; b=PZ+To1+g7qP5dbrYXFhIcBh56Ih8jjz1BJWOnNt7K0RZO2bQFXc0rp9q+pVpuPBVTF 7yQ25UE/zRoCkL6saK+nxdVbdbFxiT0IVQMonyu05sUls78k9EKTmiWWyvyZ6/mPXCrf bUKPxJSkBV5qAFKzmGtCaKRIWgoL0lSsWioEKnjXt9+gjnqTOlV/obz8FM6sKmpGbAeR j/Qgm+iel18SmXoDcZ2bTEeT7j4TEuEa2QsE4eXuNXZSxCzYwgmuh4DZjutfZbo9nuF7 O/bVTJGbEiXbv9DDPCdVPpqaVsbwVLEPvgqoDrTNy6eATy6+Y40zF8UrfporbEvqtamF ALRQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6W0qy4+ujq7G37kDc1B5RsNpqsv4dtxEvJHVNsySAQk=; b=HlQzlLYtPw75ALLB6xnwJX58maeRFzjZUa7c79WDZxbAaopmpbqZUQ5FkqPLf08IlM K8ajSYbCxGUykM7S8cUjttSsxHHeqSz8D8szGinugXC0mh45r7805vBcO7heYXeDcGkp 03HyMsf1WmG0SOY4IPQbbDYOx1HzqbpBoAKRHUNMZggw13ZKnTEUAcVtvErxtZb26Cbu LQxN8risR6rteRF0m+JAe2COEE3lqO7edNV6Ttf2VHosorz0VX5OKoOwhSrEWzew1cwc TedRCSE+zgyFGdthhIGNEd9XjIvsy572QvMlWbrrVOsd9il2bj2UnaAEkzHUiUEN9/pX XM5w==
X-Gm-Message-State: AFqh2kpaZhjx3fQYkVN2BLWoVAWk8FFJ815vjHUNDP8Qi0oqhTUs3Rj/ lku/vImabECm45jM6/M7vcXZazCdQ/TOsw==
X-Google-Smtp-Source: AMrXdXunIfXooopEekyWI8s4VAJvIfHcY/HZR35duYIMz0S6/aOV7auouhN9MEMxoFqGDMk21Jd7LA==
X-Received: by 2002:a17:907:cbc5:b0:7ad:9455:d57d with SMTP id vk5-20020a170907cbc500b007ad9455d57dmr36998168ejc.74.1674681028808; Wed, 25 Jan 2023 13:10:28 -0800 (PST)
Message-ID: <ba7e4d79-1a5b-7fbe-310e-dd192b576722@gmail.com>
Date: Wed, 25 Jan 2023 22:10:28 +0100
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1
Subject: Re: [PATCH] stub: ignore host exit status
Content-Language: en-US
To: djgpp@delorie.com
References: <744f054f-9682-4a05-91ad-684b18c0122b@gmail.com> <21e1aa0b-1511-0071-84c0-b20c6a3d1dae@gmail.com> <5de28b44-10f2-c824-def1-d451035ecaad@gmail.com> <CACuL_+D9jQtMvFx4-thuLjrjbO+etmdipOdwJJJXCiWB3s6t2w@mail.gmail.com>
From: djg...@delorie.com (J.W. Jagersma (jwjagersma@gmail.com) [via djgpp@delorie.com])
In-Reply-To: <CACuL_+D9jQtMvFx4-thuLjrjbO+etmdipOdwJJJXCiWB3s6t2w@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Reply-To: djgpp@delorie.com
Errors-To: nobody@delorie.com
X-Mailing-List: djgpp@delorie.com
X-Unsubscribes-To: listserv@delorie.com
Precedence: bulk
Newsgroups: comp.os.msdos.djgpp
Organization: None provided
DJ-Gateway: from mailing list djgpp@delorie.com
Lines: 15
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-DmSFBW+bTpdxROWkEuL0NNpuGt0yszy7CZ3GIubtOTNJ+qu+uyCFm0KTq6x3nnIFjvmo9jXv8LPa303!Ewg3xoxopK/hD9e06+4kdX+Z0Mqka7CZLqqZ0ccdcbK5EBUf/U1hez8Ye5Z85P4jyCEelCvCTvxW
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Received-Bytes: 4677
 by: J.W. Jagersma (jwjag - Wed, 25 Jan 2023 21:10 UTC

On 2023-01-25 00:36, Frank H. Sapone (emoaddict15@gmail.com) [via djgpp@delorie.com] wrote:
> I know you're looking for feedback but I dont use hdpmi32 and don't know of too many others that do except to run some windows console apps under dos.  Cwsdpmi works just fine for djgpp.
>
> In any case, someone who knows what they're looking at can hopefully chime in.  Just wanted to let you know we're receiving your messages. :)

Thanks for the message! I think this is an important patch, hopefully someone
can review it at some point. Although I suppose this should be fixed on the
hdpmi32 side too, so newer hdpmi versions are compatible with old djgpp
programs, and new djgpp programs can work with older hdpmi versions.

As for why someone might want to use hdpmi instead of cwsdpmi, the simple
answer is speed - on the few functions I benchmarked, it's over 20 times
faster. That can add up on things like allocating memory or PM-RM switches.
Plus it implements more (almost all) DPMI 1.0 functions.

Re: [PING][PATCH v2] stub: ignore host exit status

<CAA2C=vCkG-QbD3VRpsotWXXizxWwK+LRScTb+XrocR3G9n-hZw@mail.gmail.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=478&group=comp.os.msdos.djgpp#478

  copy link   Newsgroups: comp.os.msdos.djgpp
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!border-2.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Tue, 27 Feb 2024 17:35:45 +0000
X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp@delorie.com
X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1709055341; x=1709660141; darn=delorie.com;
h=content-transfer-encoding:to:subject:message-id:date:from
:in-reply-to:references:mime-version:from:to:cc:subject:date
:message-id:reply-to;
bh=zUnc5HlP+8ICf4po0SxcW/ZK6ctKUwopyXM1QfoLx2U=;
b=AXVQQ3ZFDO5V3f099fxAgby17Kot2PBEo4OQX16iFPt1lh5tff8HY/PU5JaJY0GCUo
VaMhkoQttsIXzr5b7jD0dccS9Ydq00NQs4qbw1oK74IqQWutbRytxFymZqEyN/VnkS1j
dQ+JIEBa/IZWx9u2FnF0hDmKMuBKPYlL8Oq6gzKV40RkwjBy4X2oyBGWJawz+ZxoGYzj
SKj43aZQ049i1Pf/Qr8WP/XwfD7efkV5HuX7xHLDFUlOTybN54S+Tz6xNHHYEAqPzvOB
ERwI0c7RlqIHqrgV1Xa2HaK4AQ4GaCn7xbLMBq499minhxGgDoH8HI7rZx8mVvrsLQe/
6sDw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1709055341; x=1709660141;
h=content-transfer-encoding:to:subject:message-id:date:from
:in-reply-to:references:mime-version:x-gm-message-state:from:to:cc
:subject:date:message-id:reply-to;
bh=zUnc5HlP+8ICf4po0SxcW/ZK6ctKUwopyXM1QfoLx2U=;
b=f/QQCBnn7UzeQ+/ywLCLYqdvQzbLKOdlFM5XZkAwuMMk5BtANlq8S4BGIdR5NKhCLF
haotK1UxGV+hZIVR5natkjaoZ/tVwb+enL+lEiCxGRSBwBf1t4eE0cEP3XB0D24+UnyJ
ztU4xQONpe1XW0xvOdB0zfpexUq2uaagLTY9+bKdFaRosDbuuI1rOK4I8jio5OCcLgr/
vBgmimH5kZGmv2YXxB7hDyWZQXNq57D1PY9uyS/bjmGPAq1rLCOGAtlS6qWoJI6gmMQM
/7Rav16sMtFp05zyrHkrIrF4b4oCqdzXAfGwRsHw9h1NxnO2W9D0OsPD8Ltd/N3LylM4
ITXg==
X-Gm-Message-State: AOJu0YxvAoEueWOgyqI4KcTmK1I7S8PCZ9qyxS1PrlHVSHJO4314TW3/
uKB7S/oQqJRg8Lr6Pm/A5ofIru71ThDzD/2V02+Sm+g2znpokHTnbKZ6UcZbzpTgqseeIbeY3sR
s3tfI9SoEMxiZD6tIFUpbsmJTI97Ycj2W
X-Google-Smtp-Source: AGHT+IETpRYCO+XUGflVBvGQ+AzT0ZPZhyIZQ7Bpk90qzP0D7Wm3CDkVUltKLYHRGW8dUqSMEbohJl4VvY3G+pxG0MI=
X-Received: by 2002:a05:6000:12d0:b0:33d:6554:fe81 with SMTP id
l16-20020a05600012d000b0033d6554fe81mr6907699wrx.64.1709055340960; Tue, 27
Feb 2024 09:35:40 -0800 (PST)
MIME-Version: 1.0
References: <744f054f-9682-4a05-91ad-684b18c0122b@gmail.com>
<21e1aa0b-1511-0071-84c0-b20c6a3d1dae@gmail.com> <5de28b44-10f2-c824-def1-d451035ecaad@gmail.com>
In-Reply-To: <5de28b44-10f2-c824-def1-d451035ecaad@gmail.com>
From: djg...@delorie.com (Ozkan Sezer (sezeroz@gmail.com) [via djgpp@delorie.com])
Date: Tue, 27 Feb 2024 20:35:29 +0300
Message-ID: <CAA2C=vCkG-QbD3VRpsotWXXizxWwK+LRScTb+XrocR3G9n-hZw@mail.gmail.com>
Subject: Re: [PING][PATCH v2] stub: ignore host exit status
To: djgpp@delorie.com
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id 41RHZgGl1028179
Reply-To: djgpp@delorie.com
Errors-To: nobody@delorie.com
X-Mailing-List: djgpp@delorie.com
X-Unsubscribes-To: listserv@delorie.com
Precedence: bulk
Newsgroups: comp.os.msdos.djgpp
Organization: None provided
DJ-Gateway: from mailing list djgpp@delorie.com
Lines: 214
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-P0caATqNL+4PHcdWtvuCSlp3xGuVTlZzIg2DsCaFXuZbODgGqTr8sqeNS/ymBg83kkjIE7I+n4phyVT!WiDV2dCJoEf7W7pdBZ5CBFR9CnQoF/pbUDn7FlzsA3uxuuvx/HcO2uncEBoq4HROqmGMLoQa4xBl!WejGI/YAn3UGNawk48wgHSeEtZM=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: Ozkan Sezer (sezeroz - Tue, 27 Feb 2024 17:35 UTC

On Wed, Jan 25, 2023 at 12:56 AM J.W. Jagersma (jwjagersma@gmail.com)
[via djgpp@delorie.com] <djgpp@delorie.com> wrote:
>
> Would appreciate any feedback on this. I know there's a small mistake in one
> comment, but the code works.
>
> On 2022-11-25 00:26, J.W. Jagersma wrote:
> > On 2022-11-23 20:47, J.W. Jagersma wrote:
> >> Hi all,
> >>
> >> If you've ever tried using hdpmi32 with a djgpp program, you may have
> >> noticed some strange behavior. The program first fails to run with
> >> "Load error: no DPMI", but on the second try, it suddenly works. Then
> >> a third invocation fails again, the fourth runs fine, etc.
> >>
> >> When you rename 'hdpmi32.exe' to 'cwsdpmi.exe', your program seems to
> >> run consistently. But this is only because there is a second (real)
> >> cwsdpmi in your PATH somewhere. What really happens, is that your
> >> program alternates between running under hdpmi and cwsdpmi.
> >>
> >> I finally figured out why this happens, and it's very simple: hdpmi uses
> >> the exit status to indicate if it was loaded via xms, vcpi, or int15.
> >> And the djgpp stub considers any non-zero exit status to be a failure,
> >> so it keeps searching PATH until cwsdpmi is found, which always returns
> >> zero.
> >>
> >> For a possible solution, I would suggest to ignore the return status
> >> from the host, and just check int 2f/1687 after every exec. As an added
> >> bonus, this saves 13 bytes of stub space.
> >
> > Amended patch follows - it no longer skips the last iteration (exec
> > with no path).
> >
> > It's a bit larger, but still saves 6 bytes in total.
> >
> > --- a/src/stub/stub.asm
> > +++ b/src/stub/stub.asm
> > @@ -199,38 +199,49 @@ not_path:
> > ;-----------------------------------------------------------------------------
> > ; Get DPMI information before doing anything 386-specific
> >
> > - push es
> > push di
> > - xor cx, cx ; flag for load attempt set cx = 0
> > - jz @f2 ; We always jump, shorter than jmp
> > + ; Set up loadname in case of no DPMI.
> > + ; First try current dir.
> > + xor ah, ah ; Copy until this character (=0)
> > + call store_env_string ; copy stub image to "loadname"
> > + mov si, bx ; remove name so we can add DPMI name
> > + mov di, [path_off] ; Pointer to path contents (next try)
> > @b1:
> > + xor cx, cx ; flag to signal end of loop
> > +@b2:
> > + call check_dpmi ; int 2f, ax=1687
> > + jz @f3
> > + call do_exec ; copy our name to string and try load
> > + jcxz @f1 ; cx=0 while we have more paths to try
> > + call check_dpmi ; last chance...
> > + jz @f3
> > mov al, 110
> > mov dx, msg_no_dpmi
> > jmpl error
> > -@b2:
> > - or cx, cx
> > - jnz @b1 ; we already tried load once before
> > - inc cx
> > - call load_dpmi
> > - jc @b1
> > +@f1:
> > + ; Set up loadname for next attempt.
> > + mov ah, ';' ; Copy until this character
> > + call store_env_string ; to "loadname"
> > + or al, al ; Check terminating character
> > + jne @f2 ; If ';', continue
> > + dec di ; else point at null for next pass.
> > @f2:
> > - mov ax, 0x1687 ; get DPMI entry point
> > - int 0x2f
> > - or ax, ax
> > - jnz @b2 ; if 0 then it's there
> > - and bl, 1 ; 32 bit capable?
> > - jz @b2
> > + inc cx
> > + cmp si, loadname ; anything there?
> > + je @b2 ; final try (no path)
> > + mov al, [si-1]
> > + call test_delim ; is final character a path delimiter
> > + je @b1
> > + movb [si], '\\' ; no, add separator between path & name
> > + inc si
> > + jmp @b1
> > @f3:
> > - mov [modesw], di ; store the DPMI entry point
> > - mov [modesw+2], es
> > - mov [modesw_mem], si
> > pop di
> > - pop es
> >
> > ;-----------------------------------------------------------------------------
> > ; Now, find the name of the program file we are supposed to load.
> >
> > -; xor ah, ah ; termination character (set above!)
> > +; xor ah, ah ; termination char (set by check_dpmi)
> > call store_env_string ; copy it to loadname, set bx
> >
> > mov [stubinfo_env_size], di
> > @@ -700,36 +711,29 @@ pm_dos:
> > ret
> >
> > ;-----------------------------------------------------------------------------
> > -; load DPMI server if not present
> > -; First check directory from which stub is loaded, then path, then default
> > -; On entry di points to image name
> > +; Check for presence of a DPMI host, and save the mode switch address.
> > +; Zero flag is clear on success. Clobbers ax/bx/dx.
> >
> > -path_off:
> > - .dw 0 ; If stays zero, no path
> > -
> > -load_dpmi:
> > - xor ah, ah ; Copy until this character (=0)
> > - call store_env_string ; copy stub image to "loadname"
> > - mov si, bx ; remove name so we can add DPMI name
> > - mov di, [path_off] ; Pointer to path contents (next try)
> > - jmp @f2
> > -loadloop:
> > - mov ah, ';' ; Copy until this character
> > - call store_env_string ; to "loadname"
> > - or al,al ; Check terminating character
> > - jne @f1 ; If ';', continue
> > - dec di ; else point at null for next pass.
> > -@f1:
> > - cmp si, loadname ; anything there?
> > - je do_exec ; final try (no path) let it return
> > - mov al, [si-1]
> > - call test_delim ; is final character a path delimiter
> > - je @f2
> > - movb [si], '\\' ; no, add separator between path & name
> > - inc si
> > -@f2:
> > - call do_exec ; copy our name to string and try load
> > - jc loadloop
> > +check_dpmi:
> > + push es
> > + push cx
> > + push di
> > + push si
> > + mov ax, 0x1687 ; get DPMI entry point
> > + int 0x2f
> > + mov dx, bx
> > + or dl, 1 ; bx bit 0: 32-bit capable
> > + xor bx, dx
> > + or ax, bx ; DPMI present if ax = 0
> > + jnz @f1
> > + mov [modesw], di ; store the DPMI entry point
> > + mov [modesw+2], es
> > + mov [modesw_mem], si
> > +@f1:
> > + pop si
> > + pop di
> > + pop cx
> > + pop es
> > ret
> >
> > ;-----------------------------------------------------------------------------
> > @@ -766,13 +770,6 @@ do_exec:
> > int 0x21
> > pop di
> > pop es
> > - jc @f1 ;carry set if exec failed
> > -
> > - mov ah, 0x4d ;get return code
> > - int 0x21
> > - sub ax, 0x300 ;ah=3 TSR, al=code (success)
> > - neg ax ;CY, if not originally 0x300
> > -@f1:
> > jmp restore_umb ;called func. return for us.
> >
> > ;-----------------------------------------------------------------------------
> > @@ -796,10 +793,9 @@ include_umb:
> > @f1:
> > ret
> >
> > -; Restore upper memory status. All registers and flags preserved.
> > +; Restore upper memory status. All registers preserved.
> >
> > restore_umb:
> > - pushf
> > cmpb [dos_major], 5 ; Won't work before dos 5
> > jb @f1
> > push ax
> > @@ -815,7 +811,6 @@ restore_umb:
> > pop bx
> > pop ax
> > @f1:
> > - popf
> > ret
> >
> > ;-----------------------------------------------------------------------------
> > @@ -840,6 +835,8 @@ msg_no_selectors:
> > .db "no DPMI selectors$"
> > msg_no_dpmi_memory:
> > .db "no DPMI memory$"
> > +path_off:
> > + .dw 0 ; Points to PATH, stays zero if none.
> >
> > ;-----------------------------------------------------------------------------
> > ; Unstored Data, available during and after mode switch
> >
>


Click here to read the complete article
1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor