⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 woarlm.asm

📁 Dos6.0
💻 ASM
📖 第 1 页 / 共 5 页
字号:
	shr     bx,1                                          ;restore index

; if the node is for the current app, save the logical node number.

	mov     ax,es:[si.Program_Id]   ;get the program ID
	cmp     ax,WoahApp              ;is it the current node ?
	jnz     PAHKL_Next              ;no.
	mov     AppsLogicalNodeNum,dh   ;save node number

PAHKL_Next:

; move onto the next node

	add     bx,SIZE ScanCodeStruc   ;next index
	xor     ah,ah                   ;zero out
	mov     al,es:[si].Next_In_List ;get the next entry
	cmp     al,es:[di].First_In_List;done ?
	jz      PAHKL_Done              ;yes
	mul     dl                      ;ax has the offset from the start
	lea     si,[di].Program_List    ;es:si points to the first program entry
	add     si,ax                   ;point to the right node.
	inc     dh                      ;one more fresh entry obtained
	loop    PAHKL_Loop              ;continue

PAHKL_Done:

	pop     es                      ;restore
	ret

PrepareAppHotKeyList endp
;----------------------------------------------------------------------------;
; Int15ISR:                                                                  ;
;                                                                            ;
; Hooks the AH=88H INT 15 function and if WoaInt15UsershApp is 0, returns    ;
; OriginalInt15MemSize in AX else returns 0.                                 ;
;                                                                            ;
; This code also watches for the INT 15/C207H call to set a mouse handler on ;
; PS/2 machines. If the callback CS is >= the Switcher's CS a flag is set.   ;
;----------------------------------------------------------------------------;

Int15ISR proc far

	assumes ds,nothing

	cmp     ah,88h                  ;function we want to trap ?
	jnz     CheckOther15Traps       ;no, check for other trap codes
	mov     OurInt15OffChain,0      ;we are still in chain.
	mov     ax,OriginalInt15MemSize ;get the original size
	cmp     WoaInt15UsershApp,0     ;is there an INT 15 user
	jz      @f                      ;no, return original size
	xor     ax,ax                   ;return no memory available
@@:
	iret

CheckOther15Traps:

	cmp     ax,0c207h               ;set mouse call back ?
	jnz     LetGoInt15              ;no, chain it on.
	mov     cs:[LocalInt15MouseHandler],0
	pushem  ax,bx                   ;save
	mov     ax,es                   ;call back segment
	mov     bx,cs                   ;Switcher code segment
	cmp     ax,bx                   ;address in global area ?
	popem   ax,bx                   ;restore
	jb      LetGoInt15              ;yes, address in global area
	mov     cs:[LocalInt15MouseHandler],0ffh

; fall through.

LetGoInt15:

	jmp     cs:[ActualInt15]        ;chain down

Int15ISR endp
;----------------------------------------------------------------------------;
;Int16ISR:                                                                   ;
;                                                                            ;
; Hooks the INT 16 Interrupt vector. It would do the context switch if the   ;
; appropriate hot key is set and we are not inside dos or the critical error ;
; handler.                                                                   ;
;----------------------------------------------------------------------------;

Int16ISR proc far

	assumes ds,nothing

; if we have reached our INT 16 handler we should set a flag byte to 0 so
; that the Pasting code will detect that pasting can occur.

	push    ax                      ;save
	xor     al,al                   ;want to reset the flag
	xchg    cs:[TestWoaInt16InChain],al
	cmp     al,0ffh                 ;was it just to test if on chain or not?
	pop     ax                      ;restore
	jz      ChainInt16              ;yes, bypass action on this call

; do a contextswitch if appropriate.

	call    SwitchIfPossible        ;ContextSwitch if possible

; if this is INT 16 was originated by our own code, pass it on to BIOS

	cmp     cs:[WOAsInt16],0ffh     ;call from own code ?
	jz      ChainInt16              ;yes, chain it on.

	cmp     ah,10h                  ;enhanced read key ?
	jz      Int16BlockRead          ;yes
	cmp     ah,0                    ;is it a 'READ KEY' call
	jnz     ChainInt16              ;no

Int16BlockRead:

; we have a read key call, wait till the key is pressed

	call    WaitForKeyFromInt16     ;wait for key to be pressed

ChainInt16:

	jmp     cs:[ActualInt16]        ;go back to original int 16 code

Int16ISR endp
;----------------------------------------------------------------------------;
; Int21ISR:                                                                  ;
;                                                                            ;
; Hooks the INT 21 vector. The code maintains a list of functions that WOA   ;
; traps and the corresponding handler routine addresses.                     ;
;----------------------------------------------------------------------------;

Int21ISR  proc near
  
; at this point we check to see if it is possible to do a context switch. If
; apprpriate flags are set and this is not a nested INT 21 call or call from
; within a critical error handler, we can do the switch

	call    SwitchIfPossible        ;switch out if possible

	push    bp                      ;save before trashing
	push    ds                      ;save ds
	mov     cs:[DosDefaultCode],ah  ;jam current code in
	mov     bp,StubSegOFFSET DosTraps
	sub     bp,3                    ;each entry of 3 bytes

; search for the address of the function which handles the call

@@:

	add     bp,3                    ;look at next entry
	cmp     ah,cs:[bp]              ;matches code ?
	jnz     @b                      ;continue searching

;  jump off to the function, BP is pushed on stack

	
	push    wptr cs:[bp+1]          ;save jump address
	mov     bp,sp                   ;will access stack with it
	add     bp,4                    ;ss:[bp] has original bp
	;sti                             ;enable interrupts
	near_ret                        ;jump to the handler

Int21ISR endp


	;----------------------------------------------------------;
	; DOS function handler top level routines are defined next ;
	;----------------------------------------------------------;


	;----------------------------------------------------------;
	; This one handles all calls that are not trapped by WOA   ;
	;----------------------------------------------------------;

DosDefaultFunc:

	pop     ds                      ;restore ds
	pop     bp                      ;restore bp
	cli                             ;shut of interrupts
	jmp     cs:[ActualInt21]        ;invoke actual handler

	;----------------------------------------------------------;
	; This one is used to return back to caller                ;
	;----------------------------------------------------------;

DosRet:

	pop     ds                      ;restore ds
	pop     bp                      ;retore bp
	iret                            ;return to user

	;----------------------------------------------------------;
	; This one just calls off to the original dos handler and  ;
	; retuns back. It is used for our internal calls.          ;
	;----------------------------------------------------------;

DosCall proc near

	pushf                           ;part of call-iret protocal
	cli                             ;part of calling protocal
	call    cs:[ActualInt21]        ;call off to dos
	ret                             ;return to caller

DosCall endp

	;----------------------------------------------------------;
	; This one handles all readkey board functions which wait  ;
	; for the key to be hit, like function numbers:            ;
	;       01 -- console input with excho.                    ;
	;       07 -- unfiltered char input with echo              ;
	;       08 -- character input without echo                 ;
	;----------------------------------------------------------;

DosFuncGetKey:

; wait till a character is ready and do a dos call to get the status to 
; take care of redirection.

	sti                             ;enable interrupts
	call    WaitForKeyFromDosCalls  ;wait for a key to be ready
	jmp     DosDefaultFunc          ;execute the function


	;----------------------------------------------------------;
	; This one handles Function 0A (BufferedKeyboardInput)     ;
	;----------------------------------------------------------;

DosFunc0A:

	sti                             ;enable interrupts
	call    SaveRegisters           ;save all resgisters
	mov     es,USER_DS              ;get users DS
	mov     di,USER_DX              ;es:di has users buffer
	mov     cx,[di]                 ;get the buffer length,template length
	smov    ds,cs                   ;load stubseg in ds
	add     dx,2                    ;es:dx points to proper buffer
	push    bp                      ;bp will be thrashed 
	mov     RCB_FileHandle,1        ;handle for STDOUT
	mov     b3fRCB,0                ;not a 3FH call
	call    ReadConsoleBuffer       ;handle the call
	pop     bp                      ;restore bp
	mov     ds,USER_DS              ;get back users ds
	mov     di,USER_DX              ;get back start of buffer
	or      al,al                   ;was the count zero
	jz      @f                      ;yes
	dec     al                      ;return 1 less for CR
@@:
	mov     [di+1],al               ;fill in new template length
	call    RestoreRegisters        ;restore all registers including BP
	iret                            ;get back to caller

	;----------------------------------------------------------;
	; This one handles Function 0C - Flush Buffer and read key ;
	; board, it first flushes the keyboard buffer and then dis-;
	; -patches any of the other calls if there is one.         ;
	;----------------------------------------------------------;

DosFunc0C:

	sti                             ;enable interrupts
	push    ax                      ;save calling code
	xor     al,al                   ;want to just flush the keyboard
	call    DosCall                 ;key board flushed
	pop     ax                      ;get back function
	xchg    ah,al                   ;get the function key in ah
	cmp     ah,0ah                  ;read console buffer call ?
	jz      DosFunc0A               ;yes, dispatch it
	cmp     ah,01h                  ;conin with echo call ?
	jz      DosFuncGetKey           ;yes,dispatch it
	cmp     ah,07h                  ;unfiltered input call ?
	jz      DosFuncGetKey           ;yes,dispatch it
	cmp     ah,08h                  ;con in without echo call ?
	jz      DosFuncGetKey           ;yes, dispatch it

; we don't want to handle the 'al=6' case as it does not wait for any key.

	cmp     ah,06h                  ;direct console i/o ?
	jz      DosDefaultFunc          ;let dos handle it.

; keyborad is flushed and AL does not have a valid function code, so we 
; get back to the user.

	jmp     short DosRet            ;go back, bypassing DOS

	;----------------------------------------------------------;
	; This one handles the terminate and stay resident call.   ;
	; A flag is set to indicate that a TSR has been run.       ;
	;----------------------------------------------------------;

DosFunc31:

	mov     cs:[TsrActive],0ffh     ;a TSR call done
	jmp     DosDefaultFunc          ;let the call go

	;----------------------------------------------------------;
	; This one handles function 3fh - Read From File Or Device.;
	; It would trap the call if the handle specified a console ;
	; device, else will pass it on to the actual handler.      ;
	;----------------------------------------------------------;

DosFunc3f:

	sti                             ;enable interrupts
	call    IsFileConsole?          ;check if the file is CON:
	njnz     DosDefaultFunc          ;no,excute actual ISR
	call    SaveRegisters           ;save all the users registers
	mov     es,USER_DS              ;load users ds
	smov    ds,cs                   ;ds has StubSeg segment
	push    bp                      ;may get thrashed
	mov     RCB_FileHandle,bx       ;save file handle
	mov     b3fRCB,-1               ;3F call
	call    XenixRead               ;trap and execute the call
	pop     bp                      ;restore
	mov     USER_AX,ax              ;save the return value
	call    RestoreRegisters        ;restore all the registers
	iret                            ;go back to user

	;------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -