Rev 4635 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4635 | Rev 6699 | ||
---|---|---|---|
Line 1... | Line -... | ||
1 | include 'proc32.inc' |
- | |
- | 1 | format PE console 0.8 |
|
2 | 2 | include 'proc32.inc' |
|
3 | DLL_ENTRY equ 1 |
- | |
4 | DLL_EXIT equ -1 |
- | |
5 | REQ_DLL_VER equ 2 |
- | |
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 (show color strings in this case). |
- | |
31 | - | ||
32 | push caption |
5 | start: |
33 | push -1 |
- | |
34 | push -1 |
- | |
35 | push -1 |
- | |
36 | push -1 |
- | |
37 | call [con_init] |
- | |
38 | ; C-equivalent of the following code: |
6 | invoke con_set_title, caption |
39 | ; for (ebx=0;ebx<0x100;ebx++) |
7 | ; C-equivalent of the following code: |
40 | ; { |
8 | ; for (ebx=0;ebx<0x100;ebx++) |
41 | ; con_printf(t1,ebx); |
9 | ; { |
42 | ; eax = con_set_flags(ebx); |
10 | ; con_printf(t1,ebx); |
Line 65... | Line 33... | ||
65 | call [con_write_asciiz] |
33 | push text2 |
66 | push 0 |
34 | call [con_write_asciiz] |
67 | call [con_exit] |
35 | push 0 |
68 | exit: |
36 | call [con_exit] |
69 | or eax, -1 |
37 | exit: |
70 | int 0x40 |
- | |
71 | - | ||
72 | proc load_dll_and_import stdcall, _dllname:dword, _imports:dword |
- | |
73 | pushad |
- | |
74 | ; load DLL |
- | |
75 | push 68 |
- | |
76 | pop eax |
- | |
77 | push 19 |
- | |
78 | pop ebx |
- | |
79 | mov ecx, [_dllname] |
- | |
80 | int 0x40 |
- | |
81 | test eax, eax |
- | |
82 | jz import_fail |
- | |
83 | - | ||
84 | ; initialize import |
- | |
85 | mov edi, eax |
- | |
86 | mov esi, [_imports] |
- | |
87 | import_loop: |
- | |
88 | lodsd |
- | |
89 | test eax, eax |
- | |
90 | jz import_done |
- | |
91 | mov edx, edi |
- | |
92 | import_find: |
- | |
93 | mov ebx, [edx] |
- | |
94 | test ebx, ebx |
- | |
95 | jz import_not_found |
- | |
96 | push eax |
- | |
97 | @@: |
- | |
98 | mov cl, [eax] |
- | |
99 | cmp cl, [ebx] |
- | |
100 | jnz import_find_next |
- | |
101 | test cl, cl |
- | |
102 | jz import_found |
- | |
103 | inc eax |
- | |
104 | inc ebx |
- | |
105 | jmp @b |
- | |
106 | import_find_next: |
- | |
107 | pop eax |
- | |
108 | add edx, 8 |
- | |
109 | jmp import_find |
- | |
110 | import_found: |
- | |
111 | pop eax |
- | |
112 | mov eax, [edx+4] |
- | |
113 | mov [esi-4], eax |
- | |
114 | jmp import_loop |
- | |
115 | import_not_found: |
- | |
116 | import_fail: |
- | |
117 | popad |
- | |
118 | xor eax, eax |
- | |
119 | ret |
- | |
120 | import_done: |
- | |
121 | popad |
- | |
122 | xor eax, eax |
- | |
123 | inc eax |
38 | xor eax, eax |
124 | ret |
- | |
125 | endp |
39 | ret |
126 | - | ||
Line 127... | Line 40... | ||
127 | align 4 |
40 | |
128 | - | ||
129 | imports: |
41 | align 4 |
130 | dll_start dd szStart |
- | |
131 | dll_ver dd szVersion |
42 | data import |
132 | con_init dd szcon_init |
- | |
133 | con_write_asciiz dd szcon_write_asciiz |
- | |
134 | con_printf dd szcon_printf |
- | |
135 | con_set_flags dd szcon_set_flags |
- | |
136 | con_exit dd szcon_exit |
- | |
137 | dd 0 |
43 | library console, 'console.dll' |
138 | - | ||
139 | szStart db 'START',0 |
- | |
140 | szVersion db 'version',0 |
- | |
141 | szcon_init db 'con_init',0 |
44 | import console, \ |
142 | szcon_write_asciiz db 'con_write_asciiz',0 |
45 | con_set_title, 'con_set_title', \ |
143 | szcon_printf db 'con_printf',0 |
46 | con_write_asciiz, 'con_write_asciiz', \ |
144 | szcon_set_flags db 'con_set_flags',0 |
47 | con_printf, 'con_printf', \ |
145 | szcon_exit db 'con_exit',0 |
48 | con_set_flags, 'con_set_flags', \ |
146 | 49 | con_exit, 'con_exit' |
|
147 | dllname db '/sys/lib/console.obj',0 |
- | |
Line 148... | Line 50... | ||
148 | 50 | end data |
|
149 | caption db 'Console test - colors',0 |
51 | |
150 | t1 db '¢¥â 0x%02X: ',0 |
52 | caption db 'Console test - colors',0 |
151 | text db '®â ¯à¨¬¥à ⥪áâ .',10,0 |
53 | t1 db '¢¥â 0x%02X: ',0 |
152 | text2 db 27,'[7m íâ® ¯à¨¬¥à ¨á¯®«ì§®¢ ¨ï ' |
54 | text db '®â ¯à¨¬¥à ⥪áâ .',10,0 |
153 | db 27,'[1;36;41mEsc' |
55 | text2 db 27,'[7m íâ® ¯à¨¬¥à ¨á¯®«ì§®¢ ¨ï ' |
154 | db 27,'[7m-¯®á«¥¤®¢ ⥫ì®á⥩.',10,0 |
- | |
155 | - | ||
156 | i_end: |
- | |
157 | - | ||
158 | align 4 |
- | |
159 | rb 2048 ; stack |
- |