Rev 145 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 145 | Rev 215 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | format ELF |
1 | format ELF |
2 | section '.text' executable |
2 | section '.text' executable |
3 | public start |
3 | public start |
4 | extrn mf_init |
4 | extrn mf_init |
5 | extrn main |
5 | extrn main |
- | 6 | ||
6 | ;include 'debug2.inc' |
7 | __DEBUG__ equ 1 |
7 | __DEBUG__=0 |
8 | __DEBUG_LEVEL__ equ 1 |
- | 9 | ||
- | 10 | include 'DEBUG-FDO.INC' |
|
- | 11 | ||
8 | virtual at 0 |
12 | virtual at 0 |
9 | db 'MENUET01' ; 1. Magic number (8 bytes) |
13 | db 'MENUET01' ; 1. Magic number (8 bytes) |
10 | dd 0x01 ; 2. Version of executable file |
14 | dd 0x01 ; 2. Version of executable file |
11 | dd 0x0 ; 3. Start address |
15 | dd 0x0 ; 3. Start address |
12 | dd 0x0 ; 4. Size of image |
16 | dd 0x0 ; 4. Size of image |
Line 14... | Line 18... | ||
14 | dd 0x100000 ; 6. Pointer to stack |
18 | dd 0x100000 ; 6. Pointer to stack |
15 | hparams dd 0x0 ; 7. Pointer to program arguments |
19 | hparams dd 0x0 ; 7. Pointer to program arguments |
16 | hpath dd 0x0 ; 8. Pointer to program path |
20 | hpath dd 0x0 ; 8. Pointer to program path |
17 | end virtual |
21 | end virtual |
18 | start: |
22 | start: |
19 | ;DEBUGF 'Start programm\n' |
23 | DEBUGF 1,'Start programm\n' |
20 | xor eax,eax |
24 | xor eax,eax |
21 | call mf_init |
25 | call mf_init |
22 | ;DEBUGF ' path "%s"\n params "%s"\n', .path, .params |
26 | DEBUGF 1,' path "%s"\n params "%s"\n', path, params |
23 | ; check for overflow |
27 | ; check for overflow |
24 | mov al, [path+buf_len-1] |
28 | mov al, [path+buf_len-1] |
25 | or al, [params+buf_len-1] |
29 | or al, [params+buf_len-1] |
26 | jnz .crash |
30 | jnz .crash |
27 | ; check if path written by OS |
31 | ; check if path written by OS |
Line 76... | Line 80... | ||
76 | mov [ebx], ch |
80 | mov [ebx], ch |
77 | mov dl, ch |
81 | mov dl, ch |
78 | jmp .parse |
82 | jmp .parse |
Line 79... | Line 83... | ||
79 | 83 | ||
80 | .run: |
84 | .run: |
81 | ;DEBUGF 'call main(%x, %x) with params:\n', [argc], argv |
85 | DEBUGF 1,'call main(%x, %x) with params:\n', [argc], argv |
82 | if __DEBUG__ = 1 |
86 | if __DEBUG__ = 1 |
83 | mov ecx, [argc] |
87 | mov ecx, [argc] |
84 | @@: |
88 | @@: |
85 | lea esi, [ecx * 4 + argv-4] |
89 | lea esi, [ecx * 4 + argv-4] |
86 | DEBUGF '0x%x) "%s"\n', cx, [esi] |
90 | DEBUGF 1,'%d) "%s"\n', cx, [esi] |
87 | loop @b |
91 | loop @b |
88 | end if |
- | |
89 | push [argc] |
92 | end if |
- | 93 | push argv |
|
90 | push argv |
94 | push [argc] |
91 | call main |
95 | call main |
92 | .exit: |
96 | .exit: |
93 | ;DEBUGF 'Exit from prog\n'; |
97 | DEBUGF 1,'Exit from prog with code: %x\n', eax; |
94 | xor eax,eax |
98 | xor eax,eax |
95 | dec eax |
99 | dec eax |
96 | int 0x40 |
100 | int 0x40 |
97 | dd -1 |
101 | dd -1 |
98 | .crash: |
102 | .crash: |
99 | ;DEBUGF 'E:buffer overflowed\n' |
103 | DEBUGF 1,'E:buffer overflowed\n' |
100 | jmp .exit |
104 | jmp .exit |
101 | ;============================ |
105 | ;============================ |
102 | push_param: |
106 | push_param: |
103 | ;============================ |
107 | ;============================ |
Line 124... | Line 128... | ||
124 | argc rd 1 |
128 | argc rd 1 |
125 | argv rd max_parameters |
129 | argv rd max_parameters |
126 | path rb buf_len |
130 | path rb buf_len |
127 | params rb buf_len |
131 | params rb buf_len |
Line 128... | Line -... | ||
128 | - | ||
129 | ;section '.data' |
- | |
130 | ;include_debug_strings ; ALWAYS present in data section |
132 | |
- | 133 | section '.data' |
|
- | 134 | include_debug_strings ; ALWAYS present in data section |
|
131 | 135 |