Rev 1145 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1145 | Rev 6699 | ||
---|---|---|---|
Line 1... | Line -... | ||
1 | include 'proc32.inc' |
- | |
- | 1 | format PE GUI 0.8 ; initialize console ourselves |
|
2 | 2 | include 'proc32.inc' |
|
3 | DLL_ENTRY equ 1 |
- | |
4 | DLL_EXIT equ -1 |
- | |
5 | REQ_DLL_VER equ 4 |
- | |
6 | - | ||
7 | use32 |
- | |
8 | db 'MENUET01' |
- | |
9 | dd 1 |
3 | include '../../../../import.inc' |
10 | dd start |
- | |
11 | dd i_end |
- | |
12 | dd mem |
- | |
13 | dd mem |
- | |
14 | dd 0 |
- | |
15 | dd 0 |
- | |
16 | - | ||
Line 17... | Line 4... | ||
17 | start: |
4 | |
18 | stdcall load_dll_and_import, dllname, imports |
- | |
19 | test eax, eax |
- | |
20 | jz exit |
- | |
21 | - | ||
22 | ; check version |
- | |
23 | cmp word [dll_ver], REQ_DLL_VER |
- | |
24 | jb exit |
- | |
25 | cmp word [dll_ver+2], REQ_DLL_VER |
- | |
26 | ja exit |
- | |
27 | push DLL_ENTRY |
- | |
28 | call [dll_start] |
- | |
29 | - | ||
30 | ; yes! Now do some work (gets2() demo in this case). |
- | |
31 | - | ||
32 | push caption |
5 | start: |
33 | push 25 |
6 | push caption |
34 | push 80 |
7 | push 25 |
35 | push 25 |
8 | push 80 |
36 | push 80 |
9 | push 25 |
Line 64... | Line 37... | ||
64 | done: |
37 | jmp mainloop |
65 | push 1 |
38 | done: |
66 | call [con_exit] |
39 | push 1 |
67 | exit: |
40 | call [con_exit] |
68 | or eax, -1 |
41 | exit: |
69 | int 0x40 |
42 | xor eax, eax |
70 | 43 | ret |
|
Line 71... | Line 44... | ||
71 | proc mycallback stdcall, keycode:dword, pstr:dword, pn:dword, ppos:dword |
44 | |
72 | mov eax, [keycode] |
45 | proc mycallback stdcall, keycode:dword, pstr:dword, pn:dword, ppos:dword |
73 | cmp al, 0x0F |
46 | mov eax, [keycode] |
74 | jz .tab |
47 | cmp al, 0x0F |
Line 158... | Line 131... | ||
158 | inc eax |
131 | pop edi esi |
159 | ret |
132 | inc eax |
160 | endp |
133 | ret |
161 | 134 | endp |
|
Line 162... | Line -... | ||
162 | proc load_dll_and_import stdcall, _dllname:dword, _imports:dword |
- | |
163 | pushad |
- | |
164 | ; load DLL |
- | |
165 | push 68 |
- | |
166 | pop eax |
- | |
167 | push 19 |
- | |
168 | pop ebx |
- | |
169 | mov ecx, [_dllname] |
- | |
170 | int 0x40 |
- | |
171 | test eax, eax |
- | |
172 | jz import_fail |
- | |
173 | - | ||
174 | ; initialize import |
- | |
175 | mov edi, eax |
- | |
176 | mov esi, [_imports] |
- | |
177 | import_loop: |
- | |
178 | lodsd |
- | |
179 | test eax, eax |
- | |
180 | jz import_done |
- | |
181 | mov edx, edi |
- | |
182 | import_find: |
- | |
183 | mov ebx, [edx] |
- | |
184 | test ebx, ebx |
- | |
185 | jz import_not_found |
- | |
186 | push eax |
- | |
187 | @@: |
- | |
188 | mov cl, [eax] |
- | |
189 | cmp cl, [ebx] |
- | |
190 | jnz import_find_next |
- | |
191 | test cl, cl |
- | |
192 | jz import_found |
- | |
193 | inc eax |
- | |
194 | inc ebx |
- | |
195 | jmp @b |
- | |
196 | import_find_next: |
- | |
197 | pop eax |
- | |
198 | add edx, 8 |
- | |
199 | jmp import_find |
- | |
200 | import_found: |
- | |
201 | pop eax |
- | |
202 | mov eax, [edx+4] |
- | |
203 | mov [esi-4], eax |
- | |
204 | jmp import_loop |
- | |
205 | import_not_found: |
- | |
206 | import_fail: |
- | |
207 | popad |
- | |
208 | xor eax, eax |
- | |
209 | ret |
- | |
210 | import_done: |
- | |
211 | popad |
- | |
212 | xor eax, eax |
- | |
213 | inc eax |
- | |
214 | ret |
- | |
215 | endp |
- | |
Line 216... | Line 135... | ||
216 | 135 | ||
217 | align 4 |
- | |
218 | 136 | ||
219 | imports: |
- | |
220 | dll_start dd szStart |
137 | align 4 |
221 | dll_ver dd szVersion |
- | |
222 | con_init dd szcon_init |
- | |
223 | con_write_asciiz dd szcon_write_asciiz |
- | |
224 | con_exit dd szcon_exit |
- | |
225 | con_gets2 dd szcon_gets2 |
138 | data import |
226 | dd 0 |
- | |
227 | - | ||
228 | szStart db 'START',0 |
- | |
229 | szVersion db 'version',0 |
139 | library console, 'console.dll' |
230 | szcon_init db 'con_init',0 |
140 | import console, \ |
231 | szcon_write_asciiz db 'con_write_asciiz',0 |
141 | con_init, 'con_init', \ |
232 | szcon_exit db 'con_exit',0 |
142 | con_write_asciiz, 'con_write_asciiz', \ |
233 | szcon_gets2 db 'con_gets2',0 |
143 | con_exit, 'con_exit', \ |
234 | - | ||
Line 235... | Line 144... | ||
235 | dllname db '/sys/lib/console.obj',0 |
144 | con_gets2, 'con_gets2' |
236 | 145 | end data |
|
237 | caption db 'Console test - gets2()',0 |
146 | |
238 | str1 db 'Enter string (empty for exit): ',0 |
147 | caption db 'Console test - gets2()',0 |
Line 244... | Line 153... | ||
244 | str5.len = $ - str5 |
153 | str5 db 'previous line in the history' |
245 | str6 db 'next line in the history' |
154 | str5.len = $ - str5 |
246 | str6.len = $ - str6 |
155 | str6 db 'next line in the history' |
247 | 156 | str6.len = $ - str6 |
|
Line 248... | Line -... | ||
248 | i_end: |
- | |
249 | - | ||
250 | s rb 256 |
157 | |
251 | - | ||
252 | align 4 |
- | |
253 | rb 2048 ; stack |
- | |
254 | mem: |
- |