the algorithm, sketched for review. Nitpicks ? (Miscellaneous)
After the great collective brain storming, here's for review a rough sketch of the algorithm I settled for finding the Magic Test Instruction & installing the fix. I think it's not far from the ideal, viz produces the correct result using the least amount of effort.
Pre-assertions :
- the code is running as part of the driver's initialisation routine.
- Win95/DOS 7 (any version). The DOS8 case is merged somewhere along the path below, and is only simpler because so much is hardcoded.
Finding and fixing the Magic Test Instruction, step by step; being programmers, our first step has to be step zero, right ?
-0. Check SHARE not installed (should not really be needed since SHARE.EXE can't be installed before driver initialisations, but this step is to please CM and guard against his hypothetical mad hacker trying to DEVLOAD FIXWRAP after loading a version of SHARE.EXE) :
Use Int 2F/1000. -> AX=0 or 1, OK for us to continue; else bail out.
-1. Get CS:IP of int 27 in DOS Kernel :
CS from IOSYS share hooks (DATA:0092),
IP from MSDOS Data:0F90
IF this routine entry is NOT in the HMA, GOTO step 3 below.
-2. Else MS-DOS is "high" using the HMA, ergo XMS must be present :
-2a. check int 2F/4300 -> AL=80h. Else (incoherent! output dbg msg and bail out)
-2b. int 2F/43.10 -> get the far entry point to XMM functions,
-2c. Call with AH=5, the LOCAL Open HMA function. -> AX=0001 OK (else incoherence, dbg msg, undo work, bail out)
-3. Locate the Magic Test instruction :
We start by checking for the MTI straight at (int27_entry - 0Eh).
This is justified by my tests always finding the same layout of the code around this point in samples of MS-DOS 7.0, 7.1 (also 8). PLEASE everybody who can have a look, can we assert the MTI is always exactly fourteen bytes ahead of the int 27 entry in MSDOS code in all your versions, including national variations of Win 9x/ME ?
Of course we needn't rely on the offset of MTI with respect to Int27 being fixed. If the MTI was not found in its expected location, we may start searching for it (in the vicinity only??? Warn, for debugging purposes. TBD)
If NO magic instruction was found, error! mesg, undo work, bail out...
-4. TEST and SET Ninho's bit in the MTI. This establishes the fix proper (and could be applied permanently to the IO.SYS file, if desired). If the bit was set already, put a message (notice, rather than an error).
IFF we had opened the HMA in step 2c, now close it (locally!) using
XMS function 6.
-5. Finally, switch the fix ON, i.e. prevent DOS 21/31 from checking the TSRs, by setting Ninho's bit in DOSDATA offset F5B. Yell : Cocorico !!!!
(If the bit was found to be SET already, user may be loading FIXWRAP multiple times. No harm done, Warn only)
The rest is routine work : clean up, fill in exit values to caller, RETf to DOS Sysinit.
_______________________________________________________________________
Compared to the sweat of installation, the later undoing of the fix will be trivial and does not need much more than, switch Ninho's bit off at DATA:F5B
[Dec 17 : Typo corrected, thanks CM]
---
Ninho
Complete thread:
- new HACKWRAP fix for MS-DOS7+, aka smashing the bug - Ninho, 11.12.2009, 00:17 (Miscellaneous)
- new HACKWRAP fix for MS-DOS7+, aka smashing the bug - ecm, 11.12.2009, 15:02
- new *FIXWRAP* for MS-DOS7+, aka smashing the bug - Ninho, 12.12.2009, 01:12
- FIXWRAP technical thread. News - Ninho, 12.12.2009, 16:05
- CM's questions, answered - Ninho, 12.12.2009, 18:22
- CM's questions, answered - ecm, 12.12.2009, 22:40
- CM's questions, answered - Ninho, 13.12.2009, 00:10
- CM's questions, answered - ecm, 13.12.2009, 00:51
- CM's questions, answered - Ninho, 13.12.2009, 10:32
- CM's questions, answered - ecm, 13.12.2009, 00:51
- CM's questions, answered - Ninho, 13.12.2009, 00:10
- CM's questions, answered - geoffchappell, 14.12.2009, 10:42
- CM's questions, answered - Ninho, 14.12.2009, 12:19
- CM's questions, answered - ecm, 12.12.2009, 22:40
- CM's questions, answered - Ninho, 12.12.2009, 18:22
- new HACKWRAP fix for MS-DOS7+, aka smashing the bug - geoffchappell, 14.12.2009, 10:41
- new HACKWRAP fix for MS-DOS7+, aka smashing the bug - Ninho, 14.12.2009, 11:49
- new HACKWRAP fix for MS-DOS7+, aka smashing the bug - geoffchappell, 15.12.2009, 16:55
- new HACKWRAP fix for MS-DOS7+, aka smashing the bug - Ninho, 15.12.2009, 19:08
- new HACKWRAP fix for MS-DOS7+, aka smashing the bug - Ninho, 17.12.2009, 16:35
- new HACKWRAP fix for MS-DOS7+, aka smashing the bug - geoffchappell, 15.12.2009, 16:55
- new HACKWRAP fix for MS-DOS7+, aka smashing the bug - Ninho, 14.12.2009, 11:49
- the DOS code segment hunt, results/questions - Ninho, 14.12.2009, 20:37
- the DOS code segment hunt, results/questions - ecm, 14.12.2009, 23:30
- the DOS code segment hunt, results/questions - Ninho, 15.12.2009, 00:59
- Aha! Share was a *red herring* ! Hunt over !!! - Ninho, 15.12.2009, 10:32
- Aha! Share was a *red herring* ! Hunt over !!! - ecm, 15.12.2009, 21:13
- Aha! Share was a *red herring* ! Hunt over !!! - Ninho, 15.12.2009, 22:32
- Aha! Share was a *red herring* ! Hunt over !!! - ecm, 15.12.2009, 23:05
- Aha! Share was a *red herring* ! Hunt over !!! - Ninho, 15.12.2009, 22:32
- Aha! Share was a *red herring* ! Hunt over !!! - ecm, 15.12.2009, 21:13
- the DOS code segment hunt, results/questions - geoffchappell, 15.12.2009, 16:56
- the DOS code segment hunt, results/questions - ecm, 15.12.2009, 21:19
- the DOS code segment hunt, results/questions - Ninho, 15.12.2009, 22:38
- the DOS code segment hunt, results/questions - ecm, 15.12.2009, 23:06
- the DOS code segment hunt, results/questions - Ninho, 16.12.2009, 09:22
- the DOS code segment hunt, results/questions - ecm, 15.12.2009, 23:06
- the DOS code segment hunt, results/questions - Ninho, 15.12.2009, 22:38
- the DOS code segment hunt, results/questions - Ninho, 16.12.2009, 20:24
- the DOS code segment hunt, results/questions - Ninho, 30.12.2009, 10:50
- the DOS code segment hunt, results/questions - ecm, 15.12.2009, 21:19
- the algorithm, sketched for review. Nitpicks ? - Ninho, 16.12.2009, 19:51
- the algorithm, sketched for review. Nitpicks ? - ecm, 17.12.2009, 16:19
- the algorithm, sketched for review. Nitpicks ? - Ninho, 17.12.2009, 17:14
- the algorithm, sketched for review. Nitpicks ? - ecm, 17.12.2009, 20:32
- the algorithm, sketched for review. Nitpicks ? - Ninho, 17.12.2009, 21:05
- the algorithm, sketched for review. Nitpicks ? - ecm, 17.12.2009, 21:13
- the algorithm, sketched for review. Nitpicks ? - Ninho, 17.12.2009, 23:16
- digression : MSDOS 7 and SHARE.EXE revisited - Ninho, 18.12.2009, 13:04
- digression : MSDOS 7 and SHARE.EXE revisited - ecm, 18.12.2009, 14:31
- digression : MSDOS 7 and SHARE.EXE revisited - Ninho, 18.12.2009, 17:19
- digression : MSDOS 7 and SHARE.EXE revisited - ecm, 18.12.2009, 18:19
- digression : MSDOS 7 and SHARE.EXE revisited - Ninho, 18.12.2009, 18:55
- digression : MSDOS 7 and SHARE.EXE revisited - ecm, 18.12.2009, 18:19
- digression : MSDOS 7 and SHARE.EXE revisited - Ninho, 18.12.2009, 17:19
- digression : MSDOS 7 and SHARE.EXE revisited - ecm, 18.12.2009, 14:31
- the algorithm, sketched for review. Nitpicks ? - ecm, 17.12.2009, 21:13
- the algorithm, sketched for review. Nitpicks ? - Ninho, 17.12.2009, 21:05
- the algorithm, sketched for review. Nitpicks ? - ecm, 17.12.2009, 20:32
- the algorithm, sketched for review. Nitpicks ? - Ninho, 17.12.2009, 17:14
- the algorithm, sketched for review. Nitpicks ? - ecm, 17.12.2009, 16:19
- the DOS code segment hunt, results/questions - ecm, 14.12.2009, 23:30
- HACKWRAP.SYS news, testing - Ninho, 20.12.2009, 02:44
- FIXWRAP.SYS 0.5 beta - released - please try it ! - Ninho, 23.12.2009, 00:07
- new HACKWRAP fix for MS-DOS7+, aka smashing the bug - ecm, 11.12.2009, 15:02