Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Execute .exe file out of a TSR?

huhn_mhuhn_m Member Posts: 2
Is there any possibility to execute something out
of a TSR? I tried it with INT21/4Bh but It looks up
the computer. Can someone give me an example?

Comments

  • blipblip Member Posts: 756
    INT 21h/4Bh should work if you put in the correct parameters. Maybe you called INT 21h when the main program was using it, I think it's called re-entry.
  • huhn_mhuhn_m Member Posts: 2
    [b][red]This message was edited by huhn_m at 2003-2-16 23:31:58[/red][/b][hr]
    I use the folowing TASM code:

    It should install on int 10h.
    Whenever the sign # is outputed via this fkt. it should turn on.
    As soon as you print a 5 (after you installed it) it should execute
    the Program ebasic.exe. The turn on works fine but after printing the
    5 it crashes. It must be compatible to a 286 because it is executed
    on a 286 compatible V30MX (NEC) processor. Is it maybe (and I think thats
    the mistake) impossible to resize an interrupt routine???



    .286
    .MODEL Tiny
    .STACK 512h
    .CONST

    include cmm.h

    .CODE
    MSG1 db 'Press [EXE] to',13,10
    MSG2 db 'Install EBasic Driver',13,10,'$'
    oldint dw 2 dup (?) ;Points to old interrupt handler
    handler_enabled db 0
    prgname db 'Q:EBASIC.EXE',0 ;The Filename
    prgpara db 'NONE',0 ;Parameters


    ;The proc to execute the program
    exec proc far
    MOV AX,@CODE
    MOV DS,AX

    call setfree

    MOV DX,offset prgname
    MOV SI,offset prgpara

    call exeprg
    ret
    exec endp

    setfree proc near
    MOV BX,SS
    MOV AX,ES
    SUB BX,AX

    MOV AX,SP
    MOV CL,4
    SHR AX,CL
    ADD BX,AX
    INC BX

    MOV AH,4Ah
    INT 21h

    ret
    setfree endp

    exeprg proc near
    PUSH BX
    PUSH CX
    PUSH DX
    PUSH DI
    PUSH SI
    PUSH BP
    PUSH DS
    PUSH ES

    MOV AX,@CODE
    MOV DS,AX
    MOV DI,offset comline+1
    PUSH CS
    POP ES
    XOR BL,BL
    @copypara:
    lodsb
    OR AL,AL
    @copyend
    stosb
    INC bl
    CMP BL,126
    @copypara
    @copyend:
    MOV cs:comline,bl
    MOV byte ptr es:[di],13

    MOV cs:merkss,ss
    MOV cs:merksp,sp

    MOV BX,offset parblock
    MOV AX,4B00h
    INT 21h

    CLI

    MOV ss,cs:merkss
    MOV sp,cs:merksp

    sti

    POP ES
    POP DS
    POP BP
    POP SI
    POP DI
    POP DX
    POP CX
    POP BX

    @exeend

    MOV AH,4Dh
    INT 21h
    @exeend:
    ret
    merkss dw 0
    merksp dw 0
    parblock equ this word
    dw 0
    dw offset comline
    dw seg @CODE
    dw 0
    dw 0
    dw 0
    dw 0
    comline db 128 dup (?)
    exeprg endp

    ;The handler itsself
    tsr_exbasic proc far
    PUSH AX
    PUSH DX
    PUSH CX
    PUSH BX
    PUSH SI
    PUSH DS
    PUSH ES
    PUSH DI
    PUSHF

    CMP AH,09h
    @DONE

    CMP AL,'#' ;turn on ?
    @DONe_q ;if not next
    MOV handler_enabled,1
    @DONE ;and exit
    @DONe_q:
    CMP AL,'~' ;turn off
    @DONe_r ;if not next
    MOV handler_enabled,0
    @DONE ;exit
    @DONe_r:
    CMP handler_enabled,1 ;Is enabled??
    @DONE ;not -> exit
    CMP AL,'5' ;else is AL=5?
    JNE test_next_1 ;not -> next

    MOV AX,@STACK ;Install Stack
    MOV SS,AX

    ;Execute E-Basic

    call exec ;run execute

    test_next_1:


    @DONE: ;execute olt interrupt
    POPF
    POP DI
    POP ES
    POP DS
    POP SI
    POP BX
    POP CX
    POP DX
    POP AX

    pushf
    call dword ptr cs:[oldint]
    iret
    tsr_exbasic endp end

    ;Interrupt loader
    start:
    MOV AX,@CODE
    MOV DS,AX

    MOV DX,offset MSG1
    MOV AH,09h
    INT 21h

    XOR AH,AH
    INT 16h
    CMP AH,28
    JNE ende_setup

    MOV AX,3510h ;Get INT 21h offset
    INT 21h
    MOV oldint,BX ;Offset
    mov oldint[2],ES ;Segment

    MOV AX,2510h
    MOV DX,offset tsr_exbasic
    INT 21h

    MOV AH,62h
    INT 21h

    MOV DS,BX
    MOV ES,word ptr ds:2ch
    MOV AH,49h
    INT 21h

    MOV DX,offset start
    ADD DX,10Fh
    MOV CL,4
    SHR DX,CL

    MOV AX,3100h ;Terminate & resident
    INT 21h
    ende_setup:
    MOV AH,4Ch
    INT 21h

    end start
Sign In or Register to comment.