Rev 836 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
836 | diamond | 1 | |
2 | |||
3 | |||
4 | DLL_EXIT equ -1 |
||
5 | REQ_DLL_VER equ 3 |
||
6 | |||
7 | |||
8 | db 'MENUET01' |
||
9 | dd 1 |
||
10 | dd start |
||
11 | dd i_end |
||
12 | dd mem |
||
13 | dd mem |
||
14 | dd 0 |
||
15 | dd 0 |
||
16 | |||
17 | |||
18 | stdcall load_dll_and_import, dllname, imports |
||
19 | test eax, eax |
||
20 | jz exit |
||
21 | |||
22 | |||
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 | |||
31 | |||
32 | |||
33 | push -1 |
||
34 | push -1 |
||
35 | push -1 |
||
36 | push -1 |
||
37 | call [con_init] |
||
38 | |||
39 | |||
40 | ; con_printf(start_string); |
||
41 | ; int c; |
||
42 | ; while ((c=con_getch())!=27) // Esc=exit |
||
43 | ; { |
||
44 | ; if (c) |
||
45 | ; con_printf("normal character with code %d=0x%02X\n",c,c); |
||
46 | ; else |
||
47 | ; { |
||
48 | ; c=con_getch(); |
||
49 | ; con_printf("extended character with code %d=0x%02X\n",c,c); |
||
50 | ; } |
||
51 | ; } |
||
52 | push start_string |
||
53 | call [con_printf] |
||
54 | pop ecx |
||
55 | mainloop: |
||
56 | call [con_getch] |
||
57 | cmp al, 27 |
||
58 | jz done |
||
59 | test eax, eax |
||
60 | jz extended |
||
61 | push eax |
||
62 | push eax |
||
63 | push string_normal |
||
64 | @@: |
||
65 | call [con_printf] |
||
66 | add esp, 12 |
||
67 | jmp mainloop |
||
68 | extended: |
||
69 | call [con_getch] |
||
70 | test eax, eax |
||
1145 | diamond | 71 | jz done |
72 | push eax |
||
836 | diamond | 73 | push eax |
74 | push string_extended |
||
75 | jmp @b |
||
76 | done: |
||
77 | push 1 |
||
78 | call [con_exit] |
||
79 | exit: |
||
80 | or eax, -1 |
||
81 | int 0x40 |
||
82 | |||
83 | |||
84 | pushad |
||
85 | ; load DLL |
||
86 | push 68 |
||
87 | pop eax |
||
88 | push 19 |
||
89 | pop ebx |
||
90 | mov ecx, [_dllname] |
||
91 | int 0x40 |
||
92 | test eax, eax |
||
93 | jz import_fail |
||
94 | |||
95 | |||
96 | mov edi, eax |
||
97 | mov esi, [_imports] |
||
98 | import_loop: |
||
99 | lodsd |
||
100 | test eax, eax |
||
101 | jz import_done |
||
102 | mov edx, edi |
||
103 | import_find: |
||
104 | mov ebx, [edx] |
||
105 | test ebx, ebx |
||
106 | jz import_not_found |
||
107 | push eax |
||
108 | @@: |
||
109 | mov cl, [eax] |
||
110 | cmp cl, [ebx] |
||
111 | jnz import_find_next |
||
112 | test cl, cl |
||
113 | jz import_found |
||
114 | inc eax |
||
115 | inc ebx |
||
116 | jmp @b |
||
117 | import_find_next: |
||
118 | pop eax |
||
119 | add edx, 8 |
||
120 | jmp import_find |
||
121 | import_found: |
||
122 | pop eax |
||
123 | mov eax, [edx+4] |
||
124 | mov [esi-4], eax |
||
125 | jmp import_loop |
||
126 | import_not_found: |
||
127 | import_fail: |
||
128 | popad |
||
129 | xor eax, eax |
||
130 | ret |
||
131 | import_done: |
||
132 | popad |
||
133 | xor eax, eax |
||
134 | inc eax |
||
135 | ret |
||
136 | endp |
||
137 | |||
138 | |||
139 | |||
140 | |||
141 | dll_start dd szStart |
||
142 | dll_ver dd szVersion |
||
143 | con_init dd szcon_init |
||
144 | con_printf dd szcon_printf |
||
145 | con_exit dd szcon_exit |
||
146 | con_getch dd szcon_getch |
||
147 | dd 0 |
||
148 | |||
149 | |||
150 | szVersion db 'version',0 |
||
151 | szcon_init db 'con_init',0 |
||
152 | szcon_printf db 'con_printf',0 |
||
153 | szcon_exit db 'con_exit',0 |
||
154 | szcon_getch db 'con_getch',0 |
||
155 | |||
156 | |||
157 | |||
158 | |||
159 | start_string db 'Press any key to see its code, or Esc to exit',10,0 |
||
160 | string_normal db 'normal character with code %d=0x%02X',10,0 |
||
161 | string_extended db 'extended character with code %d=0x%02X',10,0 |
||
162 | |||
163 | |||
164 | |||
165 | |||
166 | rb 2048 ; stack |
||
167 | mem: |
||
168 |