Category : Word Processors
Archive   : HP22D5.ZIP
Filename : FIXENV.ASM

 
Output of file : FIXENV.ASM contained in archive : HP22D5.ZIP
; ---------------------------------------------------------------------------
; FIXENV.ASM
;
; This program sets HyperPAD's environment to the original environment used
; by COMMAND.COM. Also, the environment that HyperPAD passes to other programs
; when they are run is the actual environment of COMMAND.COM.
;
; It performs the following steps:
;
; 1. get the address of the first memory block
; 2. it assumes the second memory block is COMMAND.COM. It finds the
; next memory block owned by this memory block
; 3. this memory block is inserted into the HyperPAD shared data
; area as the new environment
; 4. the size of the memory block is calculated and inserted into the
; appropriate field in the shared data area
;
; ---------------------------------------------------------------------------
DOSSEG
.MODEL LARGE

include extern.inc

.DATA

FixEnvName db 'STARTUP',0

Pool PoolStruct
PoolStruct <> ;END

.CODE

WhenLoaded:
WhenUnLoaded: retf

EXTRN GetSharedArea:FAR
FixEnv proc far

push es
push si
push di

mov ah,52h ;undocumented DOS interrupt
int 21h

dec bx ;ES:[BX-2] = first memory block
dec bx

mov si,3 ;memory block offset of size
mov di,1 ;memory block offset of owner

mov ax,es:[bx] ;AX = seg of first memory block
mov es,ax
mov bx,es:[si] ;BX = size of first memory block
inc bx
add ax,bx ;AX = seg of second memory block
mov es,ax
mov dx,es:[di] ;DX = owner of second mem block (COMMAND.COM)
loop1:
mov bx,es:[si] ;BX = size of block
mov cx,bx ;CX = block size (save for later)
inc bx
add ax,bx ;AX = segment of next block
mov es,ax
cmp dx,es:[di] ;check owner
jnz loop1 ;not this block ... find next one

inc ax
mov si,ax ;SI = segment first COMMAND.COM environment
mov di,cx ;DI = size of block

call GetSharedArea ;DX:AX far pointer to shared data area
mov es,dx
mov bx,ax ;ES:BX = pointer to shared data area

mov es:[bx+618],si ;EnvSeg = segment of COMMAND.COM's environment
mov cl,4
shl di,cl ;convert paragraphs to bytes
mov es:[bx+624],di ;EnvSegSz = size fo environment block

mov ax,PASS ;pass the startup message on

pop di
pop si
pop es

ret
FixEnv endp

END




  3 Responses to “Category : Word Processors
Archive   : HP22D5.ZIP
Filename : FIXENV.ASM

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/