Subversion Repositories SvarDOS

Rev

Rev 987 | Rev 1593 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 987 Rev 1178
Line 34... Line 34...
34
STACKBUF db "XXX  SVARCOM RMOD BY MATEUSZ VISTE  XXXXXXXXXXXXXXXXXXXXXXXXXXXX"
34
STACKBUF db "XXX  SVARCOM RMOD BY MATEUSZ VISTE  XXXXXXXXXXXXXXXXXXXXXXXXXXXX"
35
STACKPTR dw 0
35
STACKPTR dw 0
36
 
36
 
37
; offset of the COMSPEC variable in the environment block, 0 means "use
37
; offset of the COMSPEC variable in the environment block, 0 means "use
38
; boot drive". this value is patched by the transient part of COMMAND.COM
38
; boot drive". this value is patched by the transient part of COMMAND.COM
39
COMSPECPTR dw 0  ; +4Ah
39
COMSPECPTR dw 0  ; +CEh
40
 
40
 
41
; fallback COMSPEC string used if no COMPSEC is present in the environment
41
; fallback COMSPEC string used if no COMPSEC is present in the environment
42
; drive. drive is patched by the transient part of COMMAND.COM
42
; drive. drive is patched by the transient part of COMMAND.COM
43
COMSPECBOOT db "@:\COMMAND.COM", 0 ; +4Ch
43
COMSPECBOOT db "@:\COMMAND.COM", 0 ; +D0h
44
 
44
 
45
; exit code of last application
45
; exit code of last application
46
LEXCODE  db 0    ; +5Bh
46
LEXCODE  db 0    ; +DFh
47
 
47
 
48
; ExecParamRec used by INT 21h, AX=4b00 (load and execute program), 14 bytes:
48
; ExecParamRec used by INT 21h, AX=4b00 (load and execute program), 14 bytes:
49
;  offset  size  content
49
;  offset  size  content
50
;     +0     2   segment of environment for child (0 = current)
50
;     +0     2   segment of environment for child (0 = current)
51
;     +2     4   address of command line to place at PSP:0080
51
;     +2     4   address of command line to place at PSP:0080
52
;     +6     4   address of an FCB to be placed at PSP:005c
52
;     +6     4   address of an FCB to be placed at PSP:005c
53
;    +0Ah    4   address of an FCB to be placed at PSP:006c
53
;    +0Ah    4   address of an FCB to be placed at PSP:006c
54
EXEC_PARAM_REC db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0   ; +5Ch
54
EXEC_PARAM_REC db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0   ; +E0h
55
 
55
 
56
; Program to execute, preset by SvarCOM (128 bytes, ASCIIZ)
56
; Program to execute, preset by SvarCOM (128 bytes, ASCIIZ)
57
EXECPROG: times 128 db 0                                     ; +6Ah
57
EXECPROG: times 128 db 0                                     ; +EEh
58
 
58
 
59
; File where stdin and stdout should be redirected (0 = no redirection)
59
; File where stdin and stdout should be redirected (0 = no redirection)
60
REDIR_INFIL:     times 128 db 0     ; +EAh
60
REDIR_INFIL:     times 128 db 0     ; +16Eh
61
REDIR_OUTFIL:    times 128 db 0     ; +16Ah
61
REDIR_OUTFIL:    times 128 db 0     ; +1EEh
62
REDIR_OUTAPPEND: dw 0               ; +1EAh
62
REDIR_OUTAPPEND: dw 0               ; +26Eh
63
REDIR_DEL_STDIN: db 0               ; +1ECh  indicates that the stdin file
63
REDIR_DEL_STDIN: db 0               ; +270h  indicates that the stdin file
64
                                    ;        should be deleted (pipes). This
64
                                    ;        should be deleted (pipes). This
65
                                    ;        MUST contain the 1st char of
65
                                    ;        MUST contain the 1st char of
66
                                    ;        REDIR_INFIL!
66
                                    ;        REDIR_INFIL!
67
 
67
 
68
; CTRL+BREAK (int 23h) handler
68
; CTRL+BREAK (int 23h) handler
69
; According to the TechHelp! Manual: "If you want to abort (exit to the parent
69
; According to the TechHelp! Manual: "If you want to abort (exit to the parent
70
; process), then set the carry flag and return via a FAR RET. This causes DOS
70
; process), then set the carry flag and return via a FAR RET. This causes DOS
71
; to perform normal cleanup and exit to the parent." (otherwise use iret)
71
; to perform normal cleanup and exit to the parent." (otherwise use iret)
72
BREAK_HANDLER:            ; +1EDh
72
BREAK_HANDLER:            ; +271h
73
stc
73
stc
74
retf
74
retf
75
 
75
 
-
 
76
; INT 0x2E handler
-
 
77
INT2E:
-
 
78
xor ax, ax
-
 
79
iret
76
 
80
 
77
skipsig:                  ; +1EFh
81
skipsig:                  ; +276h
78
 
82
 
79
; set up CS=DS=SS and point SP to my private stack buffer
83
; set up CS=DS=SS and point SP to my private stack buffer
80
mov ax, cs
84
mov ax, cs
81
mov ds, ax
85
mov ds, ax
82
mov es, ax
86
mov es, ax
83
mov ss, ax
87
mov ss, ax
84
mov sp, STACKPTR
88
mov sp, STACKPTR
85
 
89
 
86
; set up myself as break handler
90
; set up myself as break handler (int 0x23)
87
mov ax, 0x2523  ; set int vector 23h
91
mov ax, 0x2523  ; set int vector 23h
88
mov dx, BREAK_HANDLER
92
mov dx, BREAK_HANDLER
89
int 0x21
93
int 0x21
90
 
94
 
-
 
95
; set up myself as int 0x2E handler ("pass command to shell")
-
 
96
mov ax, 0x252E
-
 
97
mov dx, INT2E ; TODO do something meaningful instead of a no-op
-
 
98
int 0x21
-
 
99
 
91
; revert stdin/stdout redirections (if any) to their initial state
100
; revert stdin/stdout redirections (if any) to their initial state
92
call REVERT_REDIR_IF_ANY
101
call REVERT_REDIR_IF_ANY
93
 
102
 
94
; redirect stdin and/or stdout if required
103
; redirect stdin and/or stdout if required
95
call REDIR_INOUTFILE_IF_REQUIRED
104
call REDIR_INOUTFILE_IF_REQUIRED