2014-03-02 21:47:45 +04:00
|
|
|
;-----------------------------------------------------------------------------
|
2006-01-03 12:43:31 +03:00
|
|
|
;
|
2014-03-02 21:47:45 +04:00
|
|
|
; LAUNCHER - startup of programs
|
2006-01-03 12:43:31 +03:00
|
|
|
;
|
2014-03-02 21:47:45 +04:00
|
|
|
; Compile with FASM 1.52 or newer
|
2006-01-03 12:43:31 +03:00
|
|
|
;
|
2014-03-02 21:47:45 +04:00
|
|
|
;-----------------------------------------------------------------------------
|
2014-03-06 03:37:48 +04:00
|
|
|
; last update: 06/03/2014
|
|
|
|
; changed by: Marat Zakiyanov aka Mario79, aka Mario
|
|
|
|
; changes: Dynamic memory allocation for AUTORUN.DAT.
|
|
|
|
; Added additional diagnostic messages for BOARD.
|
|
|
|
;-----------------------------------------------------------------------------
|
2014-03-02 21:47:45 +04:00
|
|
|
; last update: 02/03/2014
|
|
|
|
; changed by: Marat Zakiyanov aka Mario79, aka Mario
|
|
|
|
; changes: Reducing the consumption of RAM, 4 KB instead of 32 KB.
|
|
|
|
; Output to BOARD information about running applications.
|
|
|
|
; Cleaning of the source code.
|
|
|
|
; notice: Only 2 KB of memory for AUTORUN.DAT - be careful!
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
use32
|
|
|
|
org 0x0
|
|
|
|
db 'MENUET01' ; 8 byte id
|
|
|
|
dd 0x01 ; header version
|
|
|
|
dd START ; start of code
|
|
|
|
dd IM_END ; size of image
|
|
|
|
dd I_END ; memory for app
|
|
|
|
dd stack_top ; esp
|
|
|
|
dd 0x0 ; I_Param
|
|
|
|
dd 0x0 ; I_Icon
|
|
|
|
;-----------------------------------------------------------------------------
|
2011-01-18 14:56:31 +03:00
|
|
|
include "../../../macros.inc"
|
2006-01-03 12:43:31 +03:00
|
|
|
|
2014-03-02 21:47:45 +04:00
|
|
|
define __DEBUG__ 1
|
|
|
|
define __DEBUG_LEVEL__ 1
|
|
|
|
include "../../../debug-fdo.inc"
|
|
|
|
;-----------------------------------------------------------------------------
|
2006-01-03 12:43:31 +03:00
|
|
|
START: ; start of execution
|
2014-03-06 03:37:48 +04:00
|
|
|
mcall 68,11
|
|
|
|
mcall 70,autorun_dat_info ;get information AUTORUN.DAT
|
|
|
|
test eax,eax
|
|
|
|
jnz .read_error
|
|
|
|
|
|
|
|
mov ecx,[processinfo+32]
|
|
|
|
test ecx,ecx
|
|
|
|
jnz @f
|
|
|
|
|
|
|
|
inc ecx ; if file size zero
|
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
|
|
|
mov [autorun_dat_info.size],ecx
|
|
|
|
mcall 68,12
|
|
|
|
mov [autorun_dat_info.address],eax
|
|
|
|
mov ebp,eax
|
|
|
|
mov [autorun_dat_info.mode],dword 0
|
|
|
|
mcall 70,autorun_dat_info ;load AUTORUN.DAT
|
|
|
|
test eax,eax
|
|
|
|
jz @f
|
|
|
|
.read_error:
|
|
|
|
DEBUGF 1, "L: AUTORUN.DAT read error\n"
|
|
|
|
jmp exit
|
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
|
|
|
add ebx,ebp
|
2014-03-02 21:47:45 +04:00
|
|
|
mov [fileend],ebx
|
|
|
|
;-----------------------------------------------------------------------------
|
2009-01-30 03:09:58 +03:00
|
|
|
; this cycle does not contain an obvious exit condition,
|
|
|
|
; but auxiliary procedures (like "get_string") will exit
|
|
|
|
; at EOF
|
2014-03-02 21:47:45 +04:00
|
|
|
start_program:
|
|
|
|
call skip_spaces
|
|
|
|
cmp al,byte '#'
|
|
|
|
jz skip_this_string
|
|
|
|
call clear_strings
|
|
|
|
mov edi,program
|
|
|
|
call get_string
|
|
|
|
mov edi,parameters
|
|
|
|
call get_string
|
|
|
|
call get_number
|
|
|
|
call run_program
|
|
|
|
;--------------------------------------
|
|
|
|
skip_this_string:
|
|
|
|
call next_line
|
|
|
|
jmp start_program
|
|
|
|
;-----------------------------------------------------------------------------
|
2014-03-06 03:37:48 +04:00
|
|
|
exit_1:
|
|
|
|
DEBUGF 1, "L: AUTORUN.DAT processed\n"
|
2014-03-02 21:47:45 +04:00
|
|
|
exit:
|
|
|
|
or eax,-1
|
|
|
|
mcall
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
run_program: ; time to delay in eax
|
2014-03-06 03:37:48 +04:00
|
|
|
DEBUGF 1, "L: %s Param: %s\n",program,parameters
|
2014-03-02 21:47:45 +04:00
|
|
|
push eax
|
|
|
|
mcall 70,start_info
|
|
|
|
pop ebx
|
2009-01-30 03:09:58 +03:00
|
|
|
; if delay is negative, wait for termination
|
|
|
|
; of the spawned process
|
2014-03-02 21:47:45 +04:00
|
|
|
test ebx,ebx
|
|
|
|
js must_wait_for_termination
|
2009-01-30 03:09:58 +03:00
|
|
|
; otherwise, simply wait
|
2014-03-02 21:47:45 +04:00
|
|
|
mcall 5
|
|
|
|
ret
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
must_wait_for_termination:
|
|
|
|
mov esi,eax ; save slot for the future
|
2009-01-30 03:09:58 +03:00
|
|
|
; get process slot
|
2014-03-02 21:47:45 +04:00
|
|
|
mov ecx,eax
|
|
|
|
mcall 18,21
|
2009-01-30 03:09:58 +03:00
|
|
|
; if an error has occured, exit
|
2014-03-02 21:47:45 +04:00
|
|
|
test eax,eax
|
|
|
|
jz child_exited
|
|
|
|
|
|
|
|
mov ecx,eax
|
|
|
|
;--------------------------------------
|
|
|
|
wait_for_termination:
|
|
|
|
mcall 5,1
|
|
|
|
mov ebx, processinfo
|
|
|
|
mcall 9
|
|
|
|
cmp [ebx+50],word 9 ; the slot was freed?
|
|
|
|
jz child_exited
|
|
|
|
|
|
|
|
cmp [ebx+30],dword esi ; the slot is still occupied by our child?
|
|
|
|
jz wait_for_termination
|
|
|
|
;--------------------------------------
|
|
|
|
child_exited:
|
|
|
|
ret
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
clear_strings: ; clears buffers
|
|
|
|
pushad
|
|
|
|
mov ecx,60+1
|
|
|
|
mov edi,program
|
|
|
|
xor al,al
|
|
|
|
rep stosb
|
|
|
|
mov ecx,60+1
|
|
|
|
mov edi,parameters
|
|
|
|
rep stosb
|
|
|
|
popad
|
|
|
|
ret
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
get_string: ; pointer to destination buffer in edi
|
|
|
|
pushad
|
|
|
|
call skip_spaces
|
|
|
|
mov esi,[position]
|
2014-03-06 03:37:48 +04:00
|
|
|
add esi,ebp
|
2014-03-02 21:47:45 +04:00
|
|
|
cmp [esi],byte '"'
|
|
|
|
jz .quoted
|
|
|
|
;--------------------------------------
|
|
|
|
.start:
|
|
|
|
cmp esi,[fileend]
|
|
|
|
jae exit
|
|
|
|
|
|
|
|
lodsb
|
|
|
|
cmp al,byte ' '
|
|
|
|
jbe .finish
|
|
|
|
|
|
|
|
stosb
|
|
|
|
inc dword [position]
|
|
|
|
jmp .start
|
|
|
|
;--------------------------------------
|
|
|
|
.finish:
|
|
|
|
popad
|
|
|
|
ret
|
|
|
|
;--------------------------------------
|
|
|
|
.quoted:
|
|
|
|
inc esi
|
|
|
|
inc dword [position]
|
|
|
|
;--------------------------------------
|
|
|
|
.quoted.start:
|
|
|
|
cmp esi,[fileend]
|
|
|
|
jae exit
|
|
|
|
|
|
|
|
lodsb
|
|
|
|
inc dword [position]
|
|
|
|
cmp al,byte '"'
|
|
|
|
je .finish
|
|
|
|
|
|
|
|
stosb
|
|
|
|
jmp .quoted.start
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
get_number:
|
|
|
|
push ebx esi
|
|
|
|
call skip_spaces
|
|
|
|
mov esi,[position]
|
2014-03-06 03:37:48 +04:00
|
|
|
add esi,ebp
|
2014-03-02 21:47:45 +04:00
|
|
|
xor eax,eax
|
|
|
|
cmp [esi],byte '-'
|
|
|
|
jnz @f
|
|
|
|
|
|
|
|
inc eax
|
|
|
|
inc esi
|
|
|
|
inc dword [position]
|
|
|
|
;--------------------------------------
|
2009-01-30 03:09:58 +03:00
|
|
|
@@:
|
2014-03-02 21:47:45 +04:00
|
|
|
push eax
|
|
|
|
xor eax,eax
|
|
|
|
xor ebx,ebx
|
|
|
|
;--------------------------------------
|
|
|
|
.start:
|
|
|
|
cmp esi,[fileend]
|
|
|
|
jae .finish
|
|
|
|
|
|
|
|
lodsb
|
|
|
|
sub al,byte '0'
|
|
|
|
cmp al,9
|
|
|
|
ja .finish
|
|
|
|
|
|
|
|
lea ebx,[ebx*4+ebx]
|
|
|
|
lea ebx,[ebx*2+eax]
|
|
|
|
inc dword [position]
|
|
|
|
jmp .start
|
|
|
|
;--------------------------------------
|
|
|
|
.finish:
|
|
|
|
pop eax
|
|
|
|
dec eax
|
|
|
|
jnz @f
|
|
|
|
|
|
|
|
neg ebx
|
|
|
|
;--------------------------------------
|
2009-01-30 03:09:58 +03:00
|
|
|
@@:
|
2014-03-02 21:47:45 +04:00
|
|
|
mov eax,ebx
|
|
|
|
pop esi ebx
|
|
|
|
ret
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
skip_spaces:
|
|
|
|
push esi
|
|
|
|
xor eax,eax
|
|
|
|
mov esi,[position]
|
2014-03-06 03:37:48 +04:00
|
|
|
add esi,ebp
|
2014-03-02 21:47:45 +04:00
|
|
|
;--------------------------------------
|
|
|
|
.start:
|
|
|
|
cmp esi,[fileend]
|
|
|
|
jae .finish
|
|
|
|
|
|
|
|
lodsb
|
|
|
|
cmp al,byte ' '
|
|
|
|
ja .finish
|
|
|
|
|
|
|
|
inc dword [position]
|
|
|
|
jmp .start
|
|
|
|
;--------------------------------------
|
|
|
|
.finish:
|
|
|
|
pop esi
|
|
|
|
ret
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
next_line:
|
|
|
|
mov esi,[position]
|
2014-03-06 03:37:48 +04:00
|
|
|
add esi,ebp
|
2014-03-02 21:47:45 +04:00
|
|
|
;--------------------------------------
|
|
|
|
.start:
|
|
|
|
cmp esi,[fileend]
|
2014-03-06 03:37:48 +04:00
|
|
|
jae exit_1
|
2014-03-02 21:47:45 +04:00
|
|
|
|
|
|
|
lodsb
|
|
|
|
cmp al,13
|
|
|
|
je .finish
|
|
|
|
|
|
|
|
cmp al,10
|
|
|
|
je .finish
|
|
|
|
|
|
|
|
inc dword [position]
|
|
|
|
jmp .start
|
|
|
|
;--------------------------------------
|
|
|
|
.finish:
|
|
|
|
inc dword [position]
|
|
|
|
cmp esi,[fileend]
|
2014-03-06 03:37:48 +04:00
|
|
|
jae exit_1
|
2014-03-02 21:47:45 +04:00
|
|
|
|
|
|
|
lodsb
|
|
|
|
cmp al,13
|
|
|
|
je .finish
|
|
|
|
|
|
|
|
cmp al,10
|
|
|
|
je .finish
|
|
|
|
|
|
|
|
ret
|
|
|
|
;-----------------------------------------------------------------------------
|
2006-01-03 12:43:31 +03:00
|
|
|
; DATA:
|
2014-03-02 21:47:45 +04:00
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
include_debug_strings
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
autorun_dat_info: ; AUTORUN.DAT
|
2014-03-06 03:37:48 +04:00
|
|
|
.mode dd 5 ; get information or read file
|
|
|
|
.start dd 0
|
|
|
|
.params dd 0
|
|
|
|
.size dd 0
|
|
|
|
.address dd processinfo
|
2014-03-02 21:47:45 +04:00
|
|
|
db "/SYS/SETTINGS/AUTORUN.DAT",0
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
start_info:
|
|
|
|
.mode dd 7
|
2014-03-06 03:37:48 +04:00
|
|
|
.flags dd 0
|
2014-03-02 21:47:45 +04:00
|
|
|
.params dd parameters
|
|
|
|
dd 0
|
|
|
|
dd 0
|
2014-03-06 03:37:48 +04:00
|
|
|
db 0
|
|
|
|
.path dd program
|
2014-03-02 21:47:45 +04:00
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
IM_END:
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
align 4
|
|
|
|
processinfo:
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
program:
|
|
|
|
rb 61 ; 60 + [0] char
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
parameters:
|
|
|
|
rb 61
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
rb 1024-61*2
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
position:
|
|
|
|
rd 1 ; position in file
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
fileend:
|
|
|
|
rd 1
|
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
align 4
|
|
|
|
rb 256
|
|
|
|
stack_top:
|
|
|
|
;-----------------------------------------------------------------------------
|
2006-01-03 12:43:31 +03:00
|
|
|
I_END:
|
2014-03-02 21:47:45 +04:00
|
|
|
;-----------------------------------------------------------------------------
|