3,8 → 3,12 |
public start |
extrn mf_init |
extrn main |
;include 'debug2.inc' |
__DEBUG__=0 |
|
__DEBUG__ equ 1 |
__DEBUG_LEVEL__ equ 1 |
|
include 'DEBUG-FDO.INC' |
|
virtual at 0 |
db 'MENUET01' ; 1. Magic number (8 bytes) |
dd 0x01 ; 2. Version of executable file |
16,10 → 20,10 |
hpath dd 0x0 ; 8. Pointer to program path |
end virtual |
start: |
;DEBUGF 'Start programm\n' |
DEBUGF 1,'Start programm\n' |
xor eax,eax |
call mf_init |
;DEBUGF ' path "%s"\n params "%s"\n', .path, .params |
DEBUGF 1,' path "%s"\n params "%s"\n', path, params |
; check for overflow |
mov al, [path+buf_len-1] |
or al, [params+buf_len-1] |
78,25 → 82,25 |
jmp .parse |
|
.run: |
;DEBUGF 'call main(%x, %x) with params:\n', [argc], argv |
DEBUGF 1,'call main(%x, %x) with params:\n', [argc], argv |
if __DEBUG__ = 1 |
mov ecx, [argc] |
@@: |
lea esi, [ecx * 4 + argv-4] |
DEBUGF '0x%x) "%s"\n', cx, [esi] |
DEBUGF 1,'%d) "%s"\n', cx, [esi] |
loop @b |
end if |
push argv |
push [argc] |
push argv |
call main |
.exit: |
;DEBUGF 'Exit from prog\n'; |
DEBUGF 1,'Exit from prog with code: %x\n', eax; |
xor eax,eax |
dec eax |
int 0x40 |
dd -1 |
.crash: |
;DEBUGF 'E:buffer overflowed\n' |
DEBUGF 1,'E:buffer overflowed\n' |
jmp .exit |
;============================ |
push_param: |
126,5 → 130,5 |
path rb buf_len |
params rb buf_len |
|
;section '.data' |
;include_debug_strings ; ALWAYS present in data section |
section '.data' |
include_debug_strings ; ALWAYS present in data section |