Rev 1145 | 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 | ; for (;;) |
||
41 | ; { |
||
42 | ; con_write_asciiz("Enter string (empty for exit): "); |
||
43 | ; if (!con_gets(s,256)) break; |
||
1145 | diamond | 44 | ; if (s[0] == '\n') break; |
836 | diamond | 45 | ; con_write_asciiz("You entered: "); |
46 | ; con_write_asciiz(s); |
||
47 | ; } |
||
48 | mainloop: |
||
49 | push str1 |
||
50 | call [con_write_asciiz] |
||
51 | push 256 |
||
52 | push s |
||
53 | call [con_gets] |
||
54 | test eax, eax |
||
1145 | diamond | 55 | jz done |
56 | cmp [s], 10 |
||
836 | diamond | 57 | jz done |
58 | push str2 |
||
59 | call [con_write_asciiz] |
||
60 | push s |
||
61 | call [con_write_asciiz] |
||
62 | jmp mainloop |
||
63 | done: |
||
64 | push 1 |
||
65 | call [con_exit] |
||
66 | exit: |
||
67 | or eax, -1 |
||
68 | int 0x40 |
||
69 | |||
70 | |||
71 | pushad |
||
72 | ; load DLL |
||
73 | push 68 |
||
74 | pop eax |
||
75 | push 19 |
||
76 | pop ebx |
||
77 | mov ecx, [_dllname] |
||
78 | int 0x40 |
||
79 | test eax, eax |
||
80 | jz import_fail |
||
81 | |||
82 | |||
83 | mov edi, eax |
||
84 | mov esi, [_imports] |
||
85 | import_loop: |
||
86 | lodsd |
||
87 | test eax, eax |
||
88 | jz import_done |
||
89 | mov edx, edi |
||
90 | import_find: |
||
91 | mov ebx, [edx] |
||
92 | test ebx, ebx |
||
93 | jz import_not_found |
||
94 | push eax |
||
95 | @@: |
||
96 | mov cl, [eax] |
||
97 | cmp cl, [ebx] |
||
98 | jnz import_find_next |
||
99 | test cl, cl |
||
100 | jz import_found |
||
101 | inc eax |
||
102 | inc ebx |
||
103 | jmp @b |
||
104 | import_find_next: |
||
105 | pop eax |
||
106 | add edx, 8 |
||
107 | jmp import_find |
||
108 | import_found: |
||
109 | pop eax |
||
110 | mov eax, [edx+4] |
||
111 | mov [esi-4], eax |
||
112 | jmp import_loop |
||
113 | import_not_found: |
||
114 | import_fail: |
||
115 | popad |
||
116 | xor eax, eax |
||
117 | ret |
||
118 | import_done: |
||
119 | popad |
||
120 | xor eax, eax |
||
121 | inc eax |
||
122 | ret |
||
123 | endp |
||
124 | |||
125 | |||
126 | |||
127 | |||
128 | dll_start dd szStart |
||
129 | dll_ver dd szVersion |
||
130 | con_init dd szcon_init |
||
131 | con_write_asciiz dd szcon_write_asciiz |
||
132 | con_exit dd szcon_exit |
||
133 | con_gets dd szcon_gets |
||
134 | dd 0 |
||
135 | |||
136 | |||
137 | szVersion db 'version',0 |
||
138 | szcon_init db 'con_init',0 |
||
139 | szcon_write_asciiz db 'con_write_asciiz',0 |
||
140 | szcon_exit db 'con_exit',0 |
||
141 | szcon_gets db 'con_gets',0 |
||
142 | |||
143 | |||
144 | |||
145 | |||
146 | str1 db 'Enter string (empty for exit): ',0 |
||
147 | str2 db 'You entered: ',0 |
||
148 | |||
149 | |||
150 | |||
151 | |||
152 | |||
153 | |||
154 | rb 2048 ; stack |
||
155 | mem: |
||
156 |