On at 2023-09-03 20:31 +0200, C. Masloch via Freedos-user wrote:
On at 2023-08-26 16:30 +0200, C. Masloch via Freedos-user wrote:
Hello list,
I finished release 6 of lDebug (with a small L) today. This is my
advanced 86-DOS debugger project based on FreeDOS Debug/X (in turn
based on MS-DOS Debug), with some ideas from DR-DOS Debug. The
duration since the prior release 5 is back to less than 6 months as
opposed to the year between releases 4 and 5. Apart from the usual
amount of bugfixes, there are some new features.
I just found a bug in the release 6 revision of lDebug. It makes the DIL
command (Dump Interrupt chains with discovery of hidden chains through
AMIS Interrupt Lists) not work properly. Depending on the prior use of
(and left-over contents in) the auxiliary buffer, it could either seem
to appear to work, it could display an error immediately on any hidden
chain being detected (very common), or it could overflow the auxiliary
buffer (only possible if hundreds and hundreds of interrupt entrypoints
are found for one particular interrupt number).
It is unfortunate that this bug slipped by me into the release. I am
considering whether to make a "minor" release about it. As a halfway
remedy for now, I created a Script for lDebug that can patch an
uncompressed executable (ldebugu.com, ldebugxu.com, lcdebugu.com, etc)
to work around the bug. I have tested this patch on several different
files. It is described some on my blog [1]. A copy of the patch itself
is also hosted on our server [2]. The files that can be patched in the
FreeDOS package are found in the package's directory tree at these
positions:
Today I figured I could make an online patch in which the debugger that
needs to be patched can, itself, run a Script for lDebug file to patch
its own code. The patch result is the same as for the offline patch,
however the online method works on any executable, including the
compressed executables.
With the insight into the exact location of the code section (read from
the read-only variables DCODE1SEG and DCODE1LEN), the online patch is
even more reliable than the offline one. However, the detection of the
correct offset used by the instructions to replace is a bit different
as, at script run time, the init section is no longer accessible.
Because the online debugger is already loaded, the patch can also patch
in the exact allowable size of the auxiliary buffer (calculated as
DAUXBUFLEN - #24 if this variable is available), as at this point this
size cannot change after the control flow has left init behind. (The /A
switch to init can be used to enlarge the buffer, which is also the
cause of this bug to begin with.)
As an addition, this script will end in one of five different paths:
Success, patch not needed (source patch already applied), patch not
needed (binary patch is already applied or auxiliary buffer size is
hardcoded as before introduction of the /A switch), attempt to run the
script in Protected Mode (which is not supported), and other error.
Here is the full script:
=== snip patchl6.sld
if (dif & 800) then goto :nopm
; 205 <1> protectedmode equ 800h ; in
(DPMI) protected mode
s dcode1seg:0 l dcode1len 88 65 04 80 65 05 FD 89 4D 06
; 2491 00001C74 886504 <1> mov byte [di + 4], ah ; store
the multiplex number
; 2492 00001C77 806505FD <1> clropt [di + 4], 200h ;
indicate it is claimed
; 2493 00001C7B 894D06 <1> mov word [di + 6], cx ; = how
many list entries before ours,
; 2494 <1> ; or
= -1 if not from a list
; 2495 00001C7E E9B900 <1> jmp .done
; 2496 <1>
; 2497 <1> @@:
; 2498 <1> ; ds:di -> second terminator
(will be overwritten)
; 2499 <1> %if _AUXBUFFSIZE == _AUXBUFFMAXSIZE
; 2500 <1> cmp di, _AUXBUFFSIZE - 8 * 3 ;
enough for 1 entry + 2 terminators ?
; 2501 <1> %else
; 2502 00001C81 3B3E[540A] <1> cmp di, word
[auxbuff_current_size_minus_24]
; 2503 <1> %endif
if (src != 1) then goto :error
r v0 := 2
if (byte [srs:sro + count] == EB) then goto :short
r v0 += 1
if (byte [srs:sro + count] != E9) then goto :error
:short
if (byte [srs:sro + count + v0] == 36) then goto :notneedednew
if (word [srs:sro + count + v0] == FF81) then goto :notneededold
if (word [srs:sro + count + v0] != 3E3B) then goto :error
r word [srs:sro + count + v0 + 2] .
s dcode1seg:0 l dcode1len range srs:sro + count + v0 l 4
if (src != 3) then goto :error
r v1 := 8 * #1024 + #16 - #24
if exists r dauxbuflen then r v1 := dauxbuflen - #24
a srs:sro0
cmp di, (v1)
.
a srs:sro1
cmp di, (v1)
.
a srs:sro2
cmp di, (v1)
.
@goto :eof
:nopm
; Cannot operate in PM
@goto :eof
:notneededold
; Patch not needed, auxiliary buffer has fixed size (or already patched)
@goto :eof
:notneedednew
; Patch not needed, comparison uses ss: segment override
@goto :eof
:error
; Error detected
=== snip
It can also be downloaded from our server [1].
The patch is applied by simply running a command like "y patchl6.sld" in
the affected debugger. It will write the SRC (Search Result Count), SRS
(Search Result Segment), SRO (Search Result Offsets), COUNT (search
pattern length), AAS (Address Assembly Segment), AAO (Address Assembly
Offset), and V0 and V1 variables.
Regards,
ecm
[1]: https://pushbx.org/ecm/test/20230904/patchl6.sld
_______________________________________________
Freedos-user mailing list
Freedos-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-user