Rev 741 | Rev 747 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
659 | serge | 1 | |
740 | serge | 2 | |
3 | |||
659 | serge | 4 | |
5 | |||
6 | locals |
||
7 | image dd ? |
||
8 | entry dd ? |
||
740 | serge | 9 | base dd ? |
10 | endl |
||
659 | serge | 11 | |
12 | |||
13 | test eax, eax |
||
14 | jz .fail |
||
15 | |||
16 | |||
17 | |||
18 | |||
19 | |||
20 | |||
21 | test eax, eax |
||
22 | jz .cleanup |
||
23 | |||
24 | |||
740 | serge | 25 | |
26 | |||
659 | serge | 27 | |
740 | serge | 28 | |
29 | test eax, eax |
||
30 | jnz .cleanup |
||
31 | |||
32 | |||
33 | .cleanup: |
||
34 | stdcall kernel_free, [image] |
||
35 | mov eax, [entry] |
||
36 | ret |
||
659 | serge | 37 | .fail: |
38 | xor eax, eax |
||
39 | ret |
||
40 | endp |
||
41 | |||
42 | |||
740 | serge | 43 | PTR equ |
44 | |||
659 | serge | 45 | |
46 | map_PE: ;stdcall base:dword, image:dword |
||
662 | serge | 47 | cld |
659 | serge | 48 | push ebp |
740 | serge | 49 | push edi |
50 | push esi |
||
51 | push ebx |
||
52 | sub esp, 60 |
||
53 | mov ebx, DWORD PTR [esp+84] |
||
54 | mov ebp, DWORD PTR [esp+80] |
||
55 | mov edx, ebx |
||
56 | mov esi, ebx |
||
57 | add edx, DWORD PTR [ebx+60] |
||
58 | mov edi, ebp |
||
59 | mov DWORD PTR [esp+32], edx |
||
60 | mov ecx, DWORD PTR [edx+84] |
||
61 | |||
659 | serge | 62 | |
740 | serge | 63 | rep movsd |
64 | |||
668 | serge | 65 | |
740 | serge | 66 | mov DWORD PTR [esp+36], 0 |
67 | mov DWORD PTR [esp+16], eax |
||
68 | jmp L2 |
||
69 | L3: |
||
70 | mov eax, DWORD PTR [edx+264] |
||
71 | test eax, eax |
||
72 | je L4 |
||
73 | mov esi, ebx |
||
74 | mov edi, ebp |
||
75 | add esi, DWORD PTR [edx+268] |
||
76 | mov ecx, eax |
||
77 | add edi, DWORD PTR [edx+260] |
||
78 | |||
668 | serge | 79 | |
740 | serge | 80 | rep movsd |
81 | |||
668 | serge | 82 | |
740 | serge | 83 | mov ecx, DWORD PTR [edx+256] |
84 | add ecx, 4095 |
||
85 | and ecx, -4096 |
||
86 | cmp ecx, eax |
||
87 | jbe L6 |
||
88 | sub ecx, eax |
||
89 | add eax, DWORD PTR [edx+260] |
||
90 | lea edi, [eax+ebp] |
||
91 | |||
659 | serge | 92 | |
740 | serge | 93 | rep stosb |
94 | |||
668 | serge | 95 | |
740 | serge | 96 | inc DWORD PTR [esp+36] |
97 | add edx, 40 |
||
98 | L2: |
||
99 | mov esi, DWORD PTR [esp+16] |
||
100 | cmp DWORD PTR [esp+36], esi |
||
101 | jne L3 |
||
102 | mov edi, DWORD PTR [esp+32] |
||
103 | cmp DWORD PTR [edi+164], 0 |
||
104 | je L9 |
||
105 | mov esi, ebp |
||
106 | mov ecx, ebp |
||
107 | sub esi, DWORD PTR [edi+52] |
||
108 | add ecx, DWORD PTR [edi+160] |
||
109 | mov eax, esi |
||
110 | shr eax, 16 |
||
111 | mov DWORD PTR [esp+12], eax |
||
112 | jmp L11 |
||
113 | L12: |
||
114 | lea ebx, [eax-8] |
||
115 | xor edi, edi |
||
116 | shr ebx,1 |
||
117 | jmp L13 |
||
118 | L14: |
||
119 | movzx eax, WORD PTR [ecx+8+edi*2] |
||
120 | mov edx, eax |
||
121 | shr eax, 12 |
||
122 | and edx, 4095 |
||
123 | add edx, DWORD PTR [ecx] |
||
124 | cmp ax, 2 |
||
125 | je L17 |
||
126 | cmp ax, 3 |
||
127 | je L18 |
||
128 | dec ax |
||
129 | jne L15 |
||
130 | mov eax, DWORD PTR [esp+12] |
||
131 | add WORD PTR [edx+ebp], ax |
||
132 | L17: |
||
133 | add WORD PTR [edx+ebp], si |
||
134 | L18: |
||
135 | add DWORD PTR [edx+ebp], esi |
||
136 | L15: |
||
137 | inc edi |
||
138 | L13: |
||
139 | cmp edi, ebx |
||
140 | jne L14 |
||
141 | add ecx, DWORD PTR [ecx+4] |
||
142 | L11: |
||
143 | mov eax, DWORD PTR [ecx+4] |
||
144 | test eax, eax |
||
145 | jne L12 |
||
146 | L9: |
||
147 | mov edx, DWORD PTR [esp+32] |
||
148 | cmp DWORD PTR [edx+132], 0 |
||
149 | je L20 |
||
150 | mov eax, ebp |
||
151 | add eax, DWORD PTR [edx+128] |
||
152 | mov DWORD PTR [esp+40], 0 |
||
153 | add eax, 20 |
||
154 | mov DWORD PTR [esp+56], eax |
||
155 | L22: |
||
156 | mov ecx, DWORD PTR [esp+56] |
||
157 | cmp DWORD PTR [ecx-16], 0 |
||
158 | jne L23 |
||
159 | cmp DWORD PTR [ecx-8], 0 |
||
160 | je L25 |
||
161 | L23: |
||
162 | mov edi, DWORD PTR [__exports+32] |
||
163 | mov esi, DWORD PTR [__exports+28] |
||
164 | mov eax, DWORD PTR [esp+56] |
||
165 | mov DWORD PTR [esp+20], edi |
||
166 | sub edi, -2147483648 |
||
167 | sub esi, -2147483648 |
||
168 | mov DWORD PTR [esp+44], esi |
||
169 | mov ecx, DWORD PTR [eax-4] |
||
170 | mov DWORD PTR [esp+48], edi |
||
171 | mov edx, DWORD PTR [eax-20] |
||
172 | mov DWORD PTR [esp+52], 0 |
||
173 | add ecx, ebp |
||
174 | add edx, ebp |
||
175 | mov DWORD PTR [esp+24], edx |
||
176 | mov DWORD PTR [esp+28], ecx |
||
177 | L26: |
||
178 | mov esi, DWORD PTR [esp+52] |
||
179 | mov edi, DWORD PTR [esp+24] |
||
180 | mov eax, DWORD PTR [edi+esi*4] |
||
181 | test eax, eax |
||
182 | je L27 |
||
183 | test eax, eax |
||
184 | js L27 |
||
185 | lea edi, [ebp+eax] |
||
186 | mov eax, DWORD PTR [esp+28] |
||
187 | mov DWORD PTR [eax+esi*4], 0 |
||
188 | lea esi, [edi+2] |
||
189 | push eax |
||
190 | push 32 |
||
191 | movzx eax, WORD PTR [edi] |
||
192 | mov edx, DWORD PTR [esp+56] |
||
193 | mov eax, DWORD PTR [edx+eax*4] |
||
194 | sub eax, -2147483648 |
||
195 | push eax |
||
196 | push esi |
||
197 | call strncmp |
||
198 | pop ebx |
||
199 | xor ebx, ebx |
||
200 | test eax, eax |
||
201 | jne L32 |
||
202 | jmp L30 |
||
203 | L33: |
||
204 | push ecx |
||
205 | push 32 |
||
206 | mov ecx, DWORD PTR [esp+28] |
||
207 | mov eax, DWORD PTR [ecx-2147483648+ebx*4] |
||
208 | sub eax, -2147483648 |
||
209 | push eax |
||
210 | push esi |
||
211 | call strncmp |
||
212 | pop edx |
||
213 | test eax, eax |
||
214 | jne L34 |
||
215 | mov esi, DWORD PTR [esp+44] |
||
216 | mov edx, DWORD PTR [esp+52] |
||
217 | mov ecx, DWORD PTR [esp+28] |
||
218 | mov eax, DWORD PTR [esi+ebx*4] |
||
219 | sub eax, -2147483648 |
||
220 | mov DWORD PTR [ecx+edx*4], eax |
||
221 | jmp L36 |
||
222 | L34: |
||
223 | inc ebx |
||
224 | L32: |
||
225 | cmp ebx, DWORD PTR [__exports+24] |
||
226 | jb L33 |
||
227 | L36: |
||
228 | cmp ebx, DWORD PTR [__exports+24] |
||
229 | jne L37 |
||
230 | |||
659 | serge | 231 | |
740 | serge | 232 | call sys_msg_board_str |
233 | lea esi, [edi+2] |
||
234 | call sys_msg_board_str |
||
235 | mov esi, msg_CR |
||
236 | call sys_msg_board_str |
||
237 | |||
659 | serge | 238 | |
740 | serge | 239 | jmp L37 |
240 | L30: |
||
241 | movzx eax, WORD PTR [edi] |
||
242 | mov esi, DWORD PTR [esp+44] |
||
243 | mov edi, DWORD PTR [esp+52] |
||
244 | mov edx, DWORD PTR [esp+28] |
||
245 | mov eax, DWORD PTR [esi+eax*4] |
||
246 | sub eax, -2147483648 |
||
247 | mov DWORD PTR [edx+edi*4], eax |
||
248 | L37: |
||
249 | inc DWORD PTR [esp+52] |
||
250 | jmp L26 |
||
251 | L27: |
||
252 | add DWORD PTR [esp+56], 20 |
||
253 | jmp L22 |
||
254 | L25: |
||
255 | xor eax, eax |
||
256 | cmp DWORD PTR [esp+40], 0 |
||
257 | jne L40 |
||
258 | L20: |
||
259 | mov ecx, DWORD PTR [esp+32] |
||
260 | mov eax, ebp |
||
261 | add eax, DWORD PTR [ecx+40] |
||
262 | L40: |
||
263 | add esp, 60 |
||
264 | pop ebx |
||
265 | pop esi |
||
266 | pop edi |
||
267 | pop ebp |
||
268 | ret 8 |
||
269 | |||
659 | serge | 270 | |
740 | serge | 271 | __exports: |
272 | export 'KERNEL', \ |
||
273 | alloc_kernel_space, 'AllocKernelSpace', \ ; stdcall |
||
274 | free_kernel_space, 'FreeKernelSpace', \ ; stdcall |
||
275 | kernel_alloc, 'KernelAlloc', \ ; stdcall |
||
276 | kernel_free, 'KernelFree', \ ; stdcall |
||
277 | map_io_mem, 'MapIoMem', \ ; stdcall |
||
741 | serge | 278 | pci_api, 'PciApi', \ |
740 | serge | 279 | pci_read32, 'PciRead32', \ ; stdcall |
280 | pci_write32, 'PciWrite32', \ ; stdcall |
||
745 | serge | 281 | reg_service, 'RegService', \ |
740 | serge | 282 | user_alloc, 'UserAlloc', \ ; stdcall |
283 | user_free, 'UserFree', \ ; stdcall |
||
284 | sys_msg_board_str, 'SysMsgBoardStr' |
||
285 |