Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2292 | leency | 1 | ; Cb-n#%li.-# @l$i Lkbnbe |
2 | format PE GUI 4.0 at 400000h |
||
3 | section '.text' code readable executable |
||
4 | entry start |
||
5 | i40_nt: |
||
6 | jmp i40_9x |
||
7 | start: |
||
8 | xor ebx, ebx |
||
9 | call [GetVersion] |
||
10 | shr eax, 31 |
||
11 | mov [bIs9x], al |
||
12 | ; get default heap |
||
13 | call [GetProcessHeap] |
||
14 | mov [hHeap], eax |
||
15 | push 261 |
||
16 | push startcurdir |
||
17 | push ebx |
||
18 | call [GetModuleFileNameA] |
||
19 | xchg ecx, eax |
||
20 | inc ecx |
||
21 | inc ecx |
||
22 | lea edi, [ecx+startcurdir-1] |
||
23 | mov al, '\' |
||
24 | std |
||
25 | repnz scasb |
||
26 | cld |
||
27 | mov byte [edi+2], bl |
||
28 | mov esi, startcurdir |
||
29 | mov edi, esi |
||
30 | xor ecx, ecx |
||
31 | dec ecx |
||
32 | mov al, 0 |
||
33 | repnz scasb |
||
34 | not ecx |
||
35 | dec ecx |
||
36 | mov edi, win32_path |
||
37 | push edi |
||
38 | rep movsb |
||
39 | mov al, '\' |
||
40 | cmp byte [edi-1], al |
||
41 | jz @f |
||
42 | stosb |
||
43 | @@: mov esi, inifilename |
||
44 | mov ecx, inifilenamesize |
||
45 | rep movsb |
||
46 | ; parse command line |
||
47 | call [GetCommandLineA] |
||
48 | xchg eax, esi |
||
49 | mov edi, inname |
||
50 | call getfilename |
||
51 | mov edi, inname |
||
52 | call getfilename |
||
53 | jc no_file_given |
||
54 | cmp byte [esi], bl |
||
55 | jz file_known |
||
56 | mov [parameters], esi |
||
57 | jmp file_known |
||
58 | no_file_given: |
||
59 | mov [inname], bl |
||
60 | push comdlg32_name |
||
61 | call [LoadLibraryA] |
||
62 | test eax, eax |
||
63 | jz @f |
||
64 | push eax |
||
65 | push aGetOpenFileNameA |
||
66 | push eax |
||
67 | call [GetProcAddress] |
||
68 | test eax, eax |
||
69 | jz @f |
||
70 | push ofn |
||
71 | call eax |
||
72 | test eax, eax |
||
73 | jz @f |
||
74 | call [FreeLibrary] |
||
75 | jmp file_known |
||
76 | @@: |
||
77 | push ebx |
||
78 | call [ExitProcess] |
||
79 | file_known: |
||
80 | ; TLS data |
||
81 | mov eax, [tls_index] |
||
82 | mov ecx, [fs:2Ch] |
||
83 | mov ebp, [ecx+eax*4] |
||
84 | ; save registers |
||
85 | mov [ebp+tls._cs], cs |
||
86 | mov [ebp+tls._ds], ds |
||
87 | mov [ebp+tls._fs], fs |
||
88 | mov [ebp+tls._esp], esp |
||
89 | mov [ebp+tls._eip], exception |
||
90 | mov eax, 1000h |
||
91 | call malloc_big |
||
92 | mov edi, eax |
||
93 | ; test for server |
||
94 | push seh |
||
95 | push dword [fs:ebx] |
||
96 | mov [fs:ebx], esp |
||
97 | xor eax, eax |
||
98 | server_test: |
||
99 | div edx |
||
100 | pop dword [fs:ebx] |
||
101 | pop esi |
||
102 | test eax, eax |
||
103 | jz server |
||
104 | mov [ebp+tls.cur_slot], eax |
||
105 | mov [hSharedData], ecx |
||
106 | mov [hSharedMutex], edx |
||
107 | push edi |
||
108 | push user32_thunks |
||
109 | push user32_name |
||
110 | call init_dll |
||
111 | push gdi32_thunks |
||
112 | push gdi32_name |
||
113 | call init_dll |
||
114 | pop edi |
||
115 | push edi |
||
116 | call [lstrlenA] |
||
117 | inc eax |
||
118 | push eax |
||
119 | push eax |
||
120 | call malloc |
||
121 | pop ecx |
||
122 | mov [ebp+tls.cur_dir], eax |
||
123 | push edi |
||
124 | xchg eax, edi |
||
125 | xchg eax, esi |
||
126 | rep movsb |
||
127 | call free_big |
||
128 | call map_shared_data |
||
129 | push bgr_mutex_name |
||
130 | push ebx |
||
131 | push ebx |
||
132 | call [CreateMutexA] |
||
133 | mov [hBgrMutex], eax |
||
134 | push ebx |
||
135 | push ebx |
||
136 | push 3 ; OPEN_EXISTING |
||
137 | push ebx |
||
138 | push 1 ; FILE_SHARE_READ |
||
139 | push 80000000h ; GENERIC_READ |
||
140 | push inname |
||
141 | call [CreateFileA] |
||
142 | inc eax |
||
143 | jnz infileopened |
||
144 | mov esi, fileopenerr |
||
145 | fail: |
||
146 | push 10h |
||
147 | push ebx |
||
148 | fail2: |
||
149 | push esi |
||
150 | push ebx |
||
151 | cmp [bInitialized], 0 |
||
152 | jnz @f |
||
153 | mov eax, [esi-4] |
||
154 | loadfailed: |
||
155 | div edx |
||
156 | @@: |
||
157 | call [MessageBoxA] |
||
158 | call free_ldt |
||
159 | push ebx |
||
160 | call [ExitProcess] |
||
161 | infileopened: |
||
162 | dec eax |
||
163 | xchg eax, edi |
||
164 | push eax |
||
165 | mov eax, esp |
||
166 | push ebx |
||
167 | push eax |
||
168 | push 36 |
||
169 | push header |
||
170 | push edi |
||
171 | call [ReadFile] |
||
172 | test eax, eax |
||
173 | pop eax |
||
174 | mov esi, filereaderr |
||
175 | jz fail |
||
176 | cmp eax, 36 |
||
177 | jnz fail |
||
178 | cmp [header], 'KPCK' |
||
179 | jnz .program_not_packed |
||
180 | mov eax, [header+4] |
||
181 | call malloc_big |
||
182 | test eax, eax |
||
183 | mov esi, memerr |
||
184 | jz fail |
||
185 | push eax |
||
186 | push eax |
||
187 | push ebx |
||
188 | push edi |
||
189 | call [GetFileSize] |
||
190 | mov [limit], eax |
||
191 | call malloc_big |
||
192 | test eax, eax |
||
193 | jz fail |
||
194 | push eax |
||
195 | push ebx |
||
196 | push ebx |
||
197 | push ebx |
||
198 | push edi |
||
199 | call [SetFilePointer] |
||
200 | push eax |
||
201 | mov eax, esp |
||
202 | push ebx |
||
203 | push eax |
||
204 | push [limit] |
||
205 | push dword [esp+16] |
||
206 | push edi |
||
207 | call [ReadFile] |
||
208 | test eax, eax |
||
209 | pop eax |
||
210 | mov esi, filereaderr |
||
211 | jz fail |
||
212 | cmp eax, [limit] |
||
213 | jnz fail |
||
214 | pop esi |
||
215 | push esi |
||
216 | mov eax, [esi+4] |
||
217 | mov [limit], eax |
||
218 | call unpack |
||
219 | push esi |
||
220 | call free_big |
||
221 | pop edx |
||
222 | mov esi, notexe |
||
223 | cmp dword [edx], 'MENU' |
||
224 | jnz fail |
||
225 | cmp word [edx+4], 'ET' |
||
226 | jnz fail |
||
227 | mov ax, word [edx+6] |
||
228 | sub ax, '00' |
||
229 | xchg al, ah |
||
230 | cmp ax, 1 |
||
231 | ja fail |
||
232 | push edi |
||
233 | mov esi, edx |
||
234 | mov edi, header |
||
235 | mov ecx, 9 |
||
236 | rep movsd |
||
237 | jz @f |
||
238 | mov eax, [edx+18h] |
||
239 | mov [header+1Ch], eax |
||
240 | mov eax, [edx+14h] |
||
241 | shr eax, 1 |
||
242 | sub eax, 10h |
||
243 | mov [header+18h], eax |
||
244 | mov [header+20h], ebx |
||
245 | @@: |
||
246 | push edx |
||
247 | push 40h ; PAGE_EXECUTE_READWRITE |
||
248 | push 1000h ; MEM_COMMIT |
||
249 | push dword [edx+14h] |
||
250 | push ebx |
||
251 | call [VirtualAlloc] |
||
252 | pop edx |
||
253 | test eax, eax |
||
254 | mov esi, memerr |
||
255 | jz fail |
||
256 | mov [base], eax |
||
257 | mov edi, eax |
||
258 | mov esi, edx |
||
259 | mov ecx, [limit] |
||
260 | mov eax, ecx |
||
261 | shr ecx, 2 |
||
262 | rep movsd |
||
263 | mov ecx, eax |
||
264 | and ecx, 3 |
||
265 | rep movsb |
||
266 | jmp .program_packed_common |
||
267 | .program_not_packed: |
||
268 | mov esi, notexe |
||
269 | cmp [header], 'MENU' |
||
270 | jnz fail |
||
271 | cmp word [header+4], 'ET' |
||
272 | jnz fail |
||
273 | mov ax, word [header+6] |
||
274 | sub ax, '00' |
||
275 | xchg al, ah |
||
276 | cmp ax, 1 |
||
277 | ja fail |
||
278 | jz @f |
||
279 | mov eax, [header+18h] |
||
280 | mov [header+1Ch], eax |
||
281 | mov eax, [header+14h] |
||
282 | shr eax, 1 |
||
283 | sub eax, 10h |
||
284 | mov [header+18h], eax |
||
285 | mov [header+20h], ebx |
||
286 | @@: |
||
287 | ; hmm... Menuet/Kolibri seems to ignore app_i_end field in case of running from ramdisk (fn 19) |
||
288 | ; but depend on app_i_end in case of running from fn 58 |
||
289 | |||
290 | ; so force read all file |
||
291 | push ebx |
||
292 | push edi |
||
293 | call [GetFileSize] |
||
294 | mov [header+10h], eax |
||
295 | mov eax, [header+14h] |
||
296 | cmp eax, [header+10h] |
||
297 | jb fail |
||
298 | push 40h ; PAGE_EXECUTE_READWRITE |
||
299 | push 1000h ; MEM_COMMIT |
||
300 | push eax |
||
301 | push ebx |
||
302 | call [VirtualAlloc] |
||
303 | test eax, eax |
||
304 | mov esi, memerr |
||
305 | jz fail |
||
306 | mov [base], eax |
||
307 | push ebx |
||
308 | push ebx |
||
309 | push ebx |
||
310 | push edi |
||
311 | call [SetFilePointer] |
||
312 | push eax |
||
313 | mov eax, esp |
||
314 | push ebx |
||
315 | push eax |
||
316 | push [header+10h] |
||
317 | push [base] |
||
318 | push edi |
||
319 | call [ReadFile] |
||
320 | test eax, eax |
||
321 | pop eax |
||
322 | mov esi, filereaderr |
||
323 | jz fail |
||
324 | push edi |
||
325 | .program_packed_common: |
||
326 | call [CloseHandle] |
||
327 | mov esi, [parameters] |
||
328 | mov edi, esi |
||
329 | test esi, esi |
||
330 | jz no_params |
||
331 | mov eax, [header+1Ch] |
||
332 | test eax, eax |
||
333 | jz no_params |
||
334 | mov edx, eax |
||
335 | add eax, 256 |
||
336 | cmp eax, [header+14h] |
||
337 | mov esi, params_err |
||
338 | ja fail |
||
339 | mov esi, edi |
||
340 | mov ecx, 256 |
||
341 | xor eax, eax |
||
342 | repnz scasb |
||
343 | neg cl |
||
344 | mov edi, edx |
||
345 | add edi, [base] |
||
346 | rep movsb |
||
347 | no_params: |
||
348 | ; read ini file client settings |
||
349 | ; disks |
||
350 | push 512 |
||
351 | push ramdisk_path |
||
352 | push default_ramdisk |
||
353 | push ramdisk_keyname |
||
354 | push aDisk |
||
355 | call [GetPrivateProfileStringA] |
||
356 | mov edi, hd_partitions_num |
||
357 | hdloop: |
||
358 | push win32_path |
||
359 | push ebx |
||
360 | push hdxn |
||
361 | push aDisk |
||
362 | call [GetPrivateProfileIntA] |
||
363 | stosd |
||
364 | test eax, eax |
||
365 | jz .cont |
||
366 | push eax |
||
367 | shl eax, 9 ; *512 |
||
368 | push eax |
||
369 | call malloc |
||
370 | mov [edi-4+hd_partitions_array-hd_partitions_num], eax |
||
371 | pop ecx |
||
372 | xchg esi, eax |
||
373 | xor eax, eax |
||
374 | inc eax |
||
375 | .partitions: |
||
376 | push eax ecx |
||
377 | push eax |
||
378 | push hdpart |
||
379 | push converted_path |
||
380 | call [wsprintfA] |
||
381 | add esp, 12 |
||
382 | mov byte [esi+511], 0 |
||
383 | push win32_path |
||
384 | push 511 |
||
385 | push esi |
||
386 | push null_string |
||
387 | push converted_path |
||
388 | push aDisk |
||
389 | call [GetPrivateProfileStringA] |
||
390 | test eax, eax |
||
391 | jnz @f |
||
392 | push 10h |
||
393 | push converted_path |
||
394 | mov esi, no_partition |
||
395 | jmp fail2 |
||
396 | @@: |
||
397 | push esi |
||
398 | call [lstrlenA] |
||
399 | cmp eax, 10 |
||
400 | jbe @f |
||
401 | lea eax, [eax+esi-9] |
||
402 | cmp byte [eax], ',' |
||
403 | jnz @f |
||
404 | cmp dword [eax+1], 'read' |
||
405 | jnz @f |
||
406 | cmp dword [eax+5], 'only' |
||
407 | jnz @f |
||
408 | mov byte [eax], 0 |
||
409 | mov byte [esi+511], 1 |
||
410 | @@: |
||
411 | add esi, 512 |
||
412 | pop ecx eax |
||
413 | inc eax |
||
414 | dec ecx |
||
415 | jnz .partitions |
||
416 | .cont: |
||
417 | inc [hdxn+2] |
||
418 | inc [hdpart+2] |
||
419 | cmp edi, hd_partitions_num+4*4 |
||
420 | jnz hdloop |
||
421 | mov esi, converted_path |
||
422 | ; read fonts |
||
423 | push win32_path |
||
424 | push 512 |
||
425 | push esi |
||
426 | push null_string |
||
427 | push aFont1 |
||
428 | push aMain |
||
429 | call [GetPrivateProfileStringA] |
||
430 | call getfilemap |
||
431 | mov [char_mt], eax |
||
432 | push win32_path |
||
433 | push 512 |
||
434 | push esi |
||
435 | push null_string |
||
436 | push aFont2 |
||
437 | push aMain |
||
438 | call [GetPrivateProfileStringA] |
||
439 | call getfilemap |
||
440 | mov [char2_mt], eax |
||
441 | push win32_path |
||
442 | push ebx |
||
443 | push aSetBgr |
||
444 | push aQuestions |
||
445 | call [GetPrivateProfileIntA] |
||
446 | mov [SetBgrQuestion], eax |
||
447 | ; read skin |
||
448 | push win32_path |
||
449 | push 512 |
||
450 | push esi |
||
451 | push null_string |
||
452 | push aSkin |
||
453 | push aMain |
||
454 | call [GetPrivateProfileStringA] |
||
455 | call getfilemap |
||
456 | xchg eax, edi |
||
457 | cmp dword [edi], 'KPCK' |
||
458 | jnz @f |
||
459 | mov eax, [edi+4] |
||
460 | call malloc_big |
||
461 | mov esi, memerr |
||
462 | test eax, eax |
||
463 | jz fail |
||
464 | push eax |
||
465 | push eax |
||
466 | push edi |
||
467 | call unpack |
||
468 | push edi |
||
469 | call [UnmapViewOfFile] |
||
470 | pop edi |
||
471 | inc ebx |
||
472 | @@: |
||
473 | cmp dword [edi], 'SKIN' ; ident |
||
474 | mov esi, skinfileerr |
||
475 | jnz fail |
||
476 | cmp dword [edi+4], 1 ; version |
||
477 | jnz fail |
||
478 | ; skin parameters |
||
479 | mov esi, edi |
||
480 | add esi, [esi+8] ; parameters offset |
||
481 | mov ecx, 9 |
||
482 | push edi |
||
483 | mov edi, _skinh |
||
484 | rep movsd |
||
485 | pop edi |
||
486 | mov ecx, common_colors |
||
487 | mov edx, 127 |
||
488 | call get_wnd_colors |
||
489 | test al, al |
||
490 | jnz @f |
||
491 | lodsd |
||
492 | and eax, edx |
||
493 | push eax |
||
494 | xchg eax, ecx |
||
495 | push edi |
||
496 | mov edi, common_colors |
||
497 | push edi |
||
498 | rep movsb |
||
499 | pop ecx |
||
500 | pop edi |
||
501 | pop edx |
||
502 | call set_wnd_colors |
||
503 | @@: |
||
504 | ; skin bitmaps |
||
505 | mov esi, edi |
||
506 | add esi, [esi+16] |
||
507 | skinbmploop: |
||
508 | cmp dword [esi], 0 |
||
509 | jz skinbmploopend |
||
510 | movzx eax, word [esi] |
||
511 | movzx ecx, word [esi+2] |
||
512 | mov edx, [esi+4] |
||
513 | add esi, 8 |
||
514 | add edx, edi |
||
515 | lea eax, [eax*2+ecx-1] |
||
516 | ; convert bmp data to Win32 DIB |
||
517 | push eax edx |
||
518 | mov eax, [edx] |
||
519 | add eax, 3 |
||
520 | and al, not 3 |
||
521 | mul dword [edx+4] |
||
522 | imul eax, 3 |
||
523 | add eax, 40 |
||
524 | push eax |
||
525 | push 8 ; HEAP_ZERO_MEMORY |
||
526 | push [hHeap] |
||
527 | call [HeapAlloc] |
||
528 | pop edx |
||
529 | mov dword [eax], 40 ; biSize |
||
530 | mov ecx, [edx] |
||
531 | mov [eax+4], ecx ; biWidth |
||
532 | mov ecx, [edx+4] |
||
533 | mov [eax+8], ecx ; biHeight |
||
534 | mov dword [eax+12], 180001h ; biPlanes, biBitCount |
||
535 | push esi edi |
||
536 | lea edi, [eax+40] |
||
537 | lea esi, [edx+8] |
||
538 | mov ecx, [edx+4] |
||
539 | push eax |
||
540 | mov eax, [edx] |
||
541 | imul eax, ecx |
||
542 | add esi, eax |
||
543 | add esi, eax |
||
544 | add esi, eax |
||
545 | .x1: |
||
546 | push ecx |
||
547 | mov ecx, [edx] |
||
548 | add ecx, ecx |
||
549 | add ecx, [edx] |
||
550 | sub esi, ecx |
||
551 | push esi |
||
552 | rep movsb |
||
553 | add edi, 3 |
||
554 | and edi, not 3 |
||
555 | pop esi |
||
556 | pop ecx |
||
557 | loop .x1 |
||
558 | pop edx |
||
559 | pop edi esi |
||
560 | pop eax |
||
561 | dec eax |
||
562 | jnz @f |
||
563 | ; inactive left |
||
564 | mov [left1_bmp], edx |
||
565 | jmp skinbmploop |
||
566 | @@: |
||
567 | dec eax |
||
568 | jnz @f |
||
569 | ; active left |
||
570 | mov [left_bmp], edx |
||
571 | jmp skinbmploop |
||
572 | @@: |
||
573 | dec eax |
||
574 | jnz @f |
||
575 | ; inactive oper |
||
576 | mov [oper1_bmp], edx |
||
577 | jmp skinbmploop |
||
578 | @@: |
||
579 | dec eax |
||
580 | jnz @f |
||
581 | ; active oper |
||
582 | mov [oper_bmp], edx |
||
583 | jmp skinbmploop |
||
584 | @@: |
||
585 | dec eax |
||
586 | jnz @f |
||
587 | ; inactive base |
||
588 | mov [base1_bmp], edx |
||
589 | jmp skinbmploop |
||
590 | @@: |
||
591 | dec eax |
||
592 | jnz skinbmploop |
||
593 | ; active base |
||
594 | mov [base_bmp], edx |
||
595 | jmp skinbmploop |
||
596 | skinbmploopend: |
||
597 | ; skin buttons |
||
598 | mov esi, edi |
||
599 | add esi, [esi+12] |
||
600 | skinbuttonsloop: |
||
601 | lodsd |
||
602 | test eax, eax |
||
603 | jz skinbuttonsloopend |
||
604 | mov edx, skin_btn_close |
||
605 | dec eax |
||
606 | jz .button |
||
607 | mov edx, skin_btn_minimize |
||
608 | dec eax |
||
609 | jz .button |
||
610 | lodsd |
||
611 | lodsd |
||
612 | jmp skinbuttonsloop |
||
613 | .button: |
||
614 | mov ecx, 4 |
||
615 | @@: |
||
616 | lodsw |
||
617 | cwde |
||
618 | mov [edx], eax |
||
619 | add edx, 4 |
||
620 | loop @b |
||
621 | jmp skinbuttonsloop |
||
622 | skinbuttonsloopend: |
||
623 | dec ebx |
||
624 | jz .mem |
||
625 | xor ebx, ebx |
||
626 | push edi |
||
627 | call [UnmapViewOfFile] |
||
628 | jmp @f |
||
629 | .mem: |
||
630 | push edi |
||
631 | call free_big |
||
632 | @@: |
||
633 | ; sound volume |
||
634 | push win32_path |
||
635 | push 10 |
||
636 | push aSoundVol |
||
637 | push aSetup |
||
638 | call [GetPrivateProfileIntA] |
||
639 | and al, 0x7F |
||
640 | mov [sound_vol], al |
||
641 | ; direct screen access parameters |
||
642 | push win32_path |
||
643 | push 32 |
||
644 | push aColorDepth |
||
645 | push aDirectScreenAccess |
||
646 | call [GetPrivateProfileIntA] |
||
647 | test eax, eax |
||
648 | jz @f |
||
649 | cmp eax, 24 |
||
650 | jz @f |
||
651 | cmp eax, 32 |
||
652 | jz @f |
||
653 | mov esi, aInvalidColorDepth |
||
654 | jmp fail |
||
655 | @@: |
||
656 | mov [ColorDepth], eax |
||
657 | push win32_path |
||
658 | push 200 |
||
659 | push aInvalidateTime |
||
660 | push aDirectScreenAccess |
||
661 | call [GetPrivateProfileIntA] |
||
662 | mov [InvalidateTime], eax |
||
663 | mov [DSA], ebx |
||
664 | push DSACritSect |
||
665 | call [InitializeCriticalSection] |
||
666 | cmp [ColorDepth], ebx |
||
667 | jz @f |
||
668 | push 4 ; PAGE_READWRITE |
||
669 | push 2000h ; MEM_RESERVE |
||
670 | push 1000000h |
||
671 | push ebx |
||
672 | call [VirtualAlloc] |
||
673 | mov esi, memerr |
||
674 | test eax, eax |
||
675 | jz fail |
||
676 | mov [DSA], eax |
||
677 | @@: |
||
678 | ; parse path |
||
679 | mov eax, [header+20h] |
||
680 | test eax, eax |
||
681 | jz path_done |
||
682 | cmp eax, [header+14h] |
||
683 | jae path_done |
||
684 | ; jb @f |
||
685 | ; push 30h |
||
686 | ; push aWarning |
||
687 | ; push aPathInvalid |
||
688 | ; push 0 |
||
689 | ; call [MessageBoxA] |
||
690 | ; jmp path_done |
||
691 | ;@@: |
||
692 | push 0 |
||
693 | push startcurdir |
||
694 | push 261 |
||
695 | push inname |
||
696 | call [GetFullPathNameA] |
||
697 | ; test for /rd/1 |
||
698 | push ramdisk_path |
||
699 | call [lstrlenA] |
||
700 | push eax |
||
701 | push eax |
||
702 | push ramdisk_path |
||
703 | push eax |
||
704 | push startcurdir |
||
705 | push 1 |
||
706 | push 800h |
||
707 | call [CompareStringA] |
||
708 | cmp eax, 2 |
||
709 | pop eax |
||
710 | jz .ramdisk |
||
711 | ; test for /hdx/y |
||
712 | xor ecx, ecx |
||
713 | .hdxloop: |
||
714 | push ecx |
||
715 | mov esi, [hd_partitions_array+ecx*4] |
||
716 | mov edi, [hd_partitions_num+ecx*4] |
||
717 | test edi, edi |
||
718 | jz .hdxcont |
||
719 | .hdyloop: |
||
720 | push esi |
||
721 | call [lstrlenA] |
||
722 | push eax |
||
723 | push eax |
||
724 | push esi |
||
725 | push eax |
||
726 | push startcurdir |
||
727 | push 1 |
||
728 | push 800h |
||
729 | call [CompareStringA] |
||
730 | cmp eax, 2 |
||
731 | pop eax |
||
732 | jz .hdxy |
||
733 | add esi, 512 |
||
734 | dec edi |
||
735 | jnz .hdyloop |
||
736 | .hdxcont: |
||
737 | pop ecx |
||
738 | inc ecx |
||
739 | cmp ecx, 4 |
||
740 | jb .hdxloop |
||
741 | mov esi, aPathUnknown |
||
742 | jmp fail |
||
743 | .ramdisk: |
||
744 | push eax |
||
745 | mov edi, [header+20h] |
||
746 | add edi, [base] |
||
747 | mov eax, '/RD/' |
||
748 | stosd |
||
749 | mov ax, '1/' |
||
750 | stosw |
||
751 | jmp .common |
||
752 | .hdxy: |
||
753 | pop ecx |
||
754 | sub esi, [hd_partitions_array+ecx*4] |
||
755 | shr esi, 9 |
||
756 | inc esi |
||
757 | push eax |
||
758 | mov edi, [header+20h] |
||
759 | add edi, [base] |
||
760 | push esi |
||
761 | push ecx |
||
762 | push hdxy_str |
||
763 | push edi |
||
764 | call [wsprintfA] |
||
765 | add esp, 10h |
||
766 | add edi, eax |
||
767 | .common: |
||
768 | pop eax |
||
769 | lea esi, [startcurdir+eax] |
||
770 | .l: |
||
771 | lodsb |
||
772 | cmp al, '\' |
||
773 | jnz @f |
||
774 | mov al, '/' |
||
775 | @@: |
||
776 | stosb |
||
777 | test al, al |
||
778 | jnz .l |
||
779 | mov eax, [header+20h] |
||
780 | add eax, [base] |
||
781 | push eax |
||
782 | push eax |
||
783 | call [CharToOemA] |
||
784 | path_done: |
||
785 | ; create window |
||
786 | ; push 0 |
||
787 | ; push 16 |
||
788 | ; push 16 |
||
789 | ; push 1 |
||
790 | ; push 1 |
||
791 | ; push 400000h |
||
792 | ; call [LoadImageA] |
||
793 | ; push eax ; hIconSm |
||
794 | push ebx ; hIconSm |
||
795 | push classname ; lpszClassName |
||
796 | push ebx ; lpszMenuName |
||
797 | push ebx ; hbrBackground |
||
798 | push 32512 |
||
799 | push ebx |
||
800 | call [LoadCursorA] |
||
801 | mov [hArrow], eax |
||
802 | push eax ; hCursor |
||
803 | ; push ebx ; hIcon |
||
804 | push 1 |
||
805 | push 400000h |
||
806 | call [LoadIconA] |
||
807 | push eax ; hIcon |
||
808 | push 400000h ; hInstance |
||
809 | push ebx ; cbWndExtra |
||
810 | push ebx ; cbClsExtra |
||
811 | push wndproc ; lpfnWndProc |
||
812 | push 3 ; style = CS_HREDRAW or CS_VREDRAW |
||
813 | push 48 ; cbSize |
||
814 | push esp |
||
815 | call [RegisterClassExA] |
||
816 | add esp, 48 |
||
817 | push ebx ; lpParam |
||
818 | push 400000h ; hInstance |
||
819 | push ebx ; hMenu |
||
820 | push ebx ; hWndParent |
||
821 | mov eax, 80000000h ; CW_USEDEFAULT |
||
822 | push eax ; nHeight |
||
823 | push eax ; nWidth |
||
824 | push eax ; y |
||
825 | push eax ; x |
||
826 | push eax ; dwStyle = WS_POPUP |
||
827 | ; push ebx ; lpWindowName |
||
828 | mov esi, inname |
||
829 | mov edx, esi |
||
830 | @@: |
||
831 | lodsb |
||
832 | cmp al, 0 |
||
833 | jz .done |
||
834 | cmp al, '\' |
||
835 | jz .x |
||
836 | cmp al, '/' |
||
837 | jz .x |
||
838 | cmp al, ':' |
||
839 | jnz @b |
||
840 | .x: mov edx, esi |
||
841 | jmp @b |
||
842 | .done: |
||
843 | dec esi |
||
844 | cmp byte [esi-1], '.' |
||
845 | jnz @f |
||
846 | dec esi |
||
847 | mov byte [esi], 0 |
||
848 | @@: |
||
849 | push edx |
||
850 | mov [process_name], edx |
||
851 | push classname ; lpClassName |
||
852 | push ebx ; dwExStyle |
||
853 | call [CreateWindowExA] |
||
854 | mov [ebp+tls.hWnd], eax |
||
855 | mov [ebp+tls.bActive], 1 |
||
856 | mov [ebp+tls.bFirstMouseMove], 1 |
||
857 | test eax, eax |
||
858 | mov esi, createwnderr |
||
859 | jz fail |
||
860 | call get_cur_slot_ptr |
||
861 | mov [edi+shared_data_struc.hWnd-shared_data_struc.threads], eax |
||
862 | cmp [edi+shared_data_struc.thread_id-shared_data_struc.threads], 2 |
||
863 | jnz .notfirst |
||
864 | mov esi, [shared_data] |
||
865 | cmp [esi+shared_data_struc.vk], 0 |
||
866 | jnz .workarea_vk |
||
867 | push ebx |
||
868 | lea eax, [esi+shared_data_struc.workarea_left] |
||
869 | push eax |
||
870 | push ebx |
||
871 | push 30h ; SPI_GETWORKAREA |
||
872 | call [SystemParametersInfoA] |
||
873 | dec [esi+shared_data_struc.workarea_right] |
||
874 | dec [esi+shared_data_struc.workarea_bottom] |
||
875 | jmp .workarea_set |
||
876 | .workarea_vk: |
||
877 | push esi |
||
878 | call get_screen_size |
||
879 | pop esi |
||
880 | inc ebx |
||
881 | mov word [esi+shared_data_struc.workarea_bottom], bx |
||
882 | shr ebx, 10h |
||
883 | inc ebx |
||
884 | mov [esi+shared_data_struc.workarea_right], ebx |
||
885 | xor ebx, ebx |
||
886 | .workarea_set: |
||
887 | .notfirst: |
||
888 | push newprg_section_name |
||
889 | push 1000h |
||
890 | push ebx |
||
891 | push 4 |
||
892 | push ebx |
||
893 | push -1 |
||
894 | call [CreateFileMappingA] |
||
895 | push eax |
||
896 | mov esi, shared_section_create_err |
||
897 | test eax, eax |
||
898 | jz fail |
||
899 | push ebx |
||
900 | push ebx |
||
901 | push ebx |
||
902 | push 2 |
||
903 | push eax |
||
904 | call [MapViewOfFile] |
||
905 | pop ecx |
||
906 | push eax |
||
907 | push ecx |
||
908 | call [CloseHandle] |
||
909 | pop eax |
||
910 | push eax |
||
911 | cmp word [eax], 0x201 |
||
912 | jnz @f |
||
913 | mov ecx, [ebp+tls.hWnd] |
||
914 | mov [eax+2], ecx |
||
915 | mov byte [eax+1], 3 |
||
916 | @@: |
||
917 | call [UnmapViewOfFile] |
||
918 | ; allocate LDT selectors |
||
919 | ; data segment |
||
920 | mov esi, selector_data |
||
921 | mov eax, [base] |
||
922 | mov [esi+2], ax |
||
923 | shr eax, 10h |
||
924 | mov [esi+4], al |
||
925 | mov [esi+7], ah |
||
926 | mov eax, [header+14h] |
||
927 | dec eax |
||
928 | mov [limit], eax |
||
929 | mov [fn9limit], eax |
||
930 | call get_cur_slot_ptr |
||
931 | mov [edi+24], eax |
||
932 | shr eax, 0Ch |
||
933 | mov [esi], ax |
||
934 | shr eax, 10h |
||
935 | or al, 11000000b |
||
936 | mov [esi+6], al |
||
937 | mov byte [esi+5], 11110010b |
||
938 | lea edi, [esi+8] |
||
939 | ; code segment |
||
940 | movsd |
||
941 | movsd |
||
942 | mov byte [esi+5], 11111010b |
||
943 | cmp [bIs9x], 0 |
||
944 | jnz alloc_ldt_9x |
||
945 | push ntdll_name |
||
946 | call [GetModuleHandleA] |
||
947 | push aNtSetLdtEntries |
||
948 | push eax |
||
949 | call [GetProcAddress] |
||
950 | mov [NtSetLdtEntries], eax |
||
951 | push dword [esi-4] |
||
952 | push dword [esi-8] |
||
953 | push 17h |
||
954 | push dword [esi+4] |
||
955 | push dword [esi] |
||
956 | push 0Fh |
||
957 | call eax |
||
958 | mov esi, ldterr |
||
959 | test eax, eax |
||
960 | js fail |
||
961 | mov eax, [DSA] |
||
962 | test eax, eax |
||
963 | jz @f |
||
964 | push ebx |
||
965 | push ebx |
||
966 | push ebx |
||
967 | mov edx, eax |
||
968 | mov dx, (11000000b shl 8) + 11110010b |
||
969 | ror edx, 16 |
||
970 | xchg dl, dh |
||
971 | ror edx, 8 |
||
972 | push edx |
||
973 | shl eax, 16 |
||
974 | mov ax, 0FFFh |
||
975 | push eax |
||
976 | push 1Fh |
||
977 | call [NtSetLdtEntries] |
||
978 | test eax, eax |
||
979 | js fail |
||
980 | mov [_gs], 1Fh |
||
981 | @@: |
||
982 | dorunklbr: |
||
983 | ; jump to program code |
||
984 | mov eax, [header+18h] |
||
985 | mov [ebp+tls._esp], eax |
||
986 | mov eax, [header+0Ch] |
||
987 | mov [ebp+tls._eip], eax |
||
988 | push 3200h ; eflags |
||
989 | xor eax, eax |
||
990 | push eax |
||
991 | push eax |
||
992 | push eax |
||
993 | push eax |
||
994 | push eax |
||
995 | push eax |
||
996 | push eax |
||
997 | push eax |
||
998 | ; Kolibri process was successfully created, notify parent |
||
999 | call get_cur_slot_ptr |
||
1000 | mov [edi+shared_data_struc.win32_stack-shared_data_struc.threads], esp |
||
1001 | mov [bInitialized], 1 |
||
1002 | notify_parent: |
||
1003 | div edx |
||
1004 | jmp i40_done |
||
1005 | |||
1006 | alloc_ldt_9x: |
||
1007 | mov eax, r0p |
||
1008 | call CallRing0 |
||
1009 | ; patch int40 |
||
1010 | add edi, (40h-9)*8 |
||
1011 | mov eax, i40_9x |
||
1012 | mov [edi], ax |
||
1013 | mov word [edi+2], cs |
||
1014 | shr eax, 16 |
||
1015 | mov [edi+6], ax |
||
1016 | mov word [edi+4], 1110111100000000b |
||
1017 | xor ebx, ebx |
||
1018 | jmp dorunklbr |
||
1019 | free_ldt: |
||
1020 | cmp [bIs9x], 0 |
||
1021 | jnz @f |
||
1022 | .ret: ret |
||
1023 | @@: |
||
1024 | cmp [temp_cs], 0 |
||
1025 | jz .ret |
||
1026 | mov eax, fl0p |
||
1027 | |||
1028 | CallRing0: |
||
1029 | call acquire_shared ; int 9 is global resource |
||
1030 | sidt [idtr] |
||
1031 | mov edi, dword [idtr+2] |
||
1032 | add edi, 8*9 |
||
1033 | push dword [edi] |
||
1034 | push dword [edi+4] |
||
1035 | mov [edi], ax |
||
1036 | mov word [edi+2], 28h |
||
1037 | ; mov word [edi+4], 0xEE00 |
||
1038 | ; shr eax, 16 |
||
1039 | ; mov [edi+6], ax |
||
1040 | mov [edi+4], eax |
||
1041 | mov word [edi+4], 0xEE00 |
||
1042 | int 9 |
||
1043 | pop dword [edi+4] |
||
1044 | pop dword [edi] |
||
1045 | call release_shared |
||
1046 | ret |
||
1047 | |||
1048 | r0p: |
||
1049 | int 20h ; VMMCall Get_Cur_VM_Handle |
||
1050 | dw 1 |
||
1051 | dw 1 |
||
1052 | push 0 |
||
1053 | push 1 |
||
1054 | push dword [esi] |
||
1055 | push dword [esi+4] |
||
1056 | push ebx |
||
1057 | int 20h ; VMMCall _Allocate_LDT_Selector |
||
1058 | dw 78h |
||
1059 | dw 1 |
||
1060 | add esp, 14h |
||
1061 | mov [klbr_cs], ax |
||
1062 | push 0 |
||
1063 | push 1 |
||
1064 | push dword [esi-8] |
||
1065 | push dword [esi-4] |
||
1066 | push ebx |
||
1067 | int 20h ; VMMCall _Allocate_LDT_Selector |
||
1068 | dw 78h |
||
1069 | dw 1 |
||
1070 | add esp, 14h |
||
1071 | mov [klbr_ds], ax |
||
1072 | mov eax, [DSA] |
||
1073 | test eax, eax |
||
1074 | jz @f |
||
1075 | push 0 |
||
1076 | push 1 |
||
1077 | mov edx, eax |
||
1078 | mov dx, (11000000b shl 8) + 11110010b |
||
1079 | ror edx, 16 |
||
1080 | xchg dl, dh |
||
1081 | ror edx, 8 |
||
1082 | shl eax, 16 |
||
1083 | mov ax, 0FFFh |
||
1084 | push eax |
||
1085 | push edx |
||
1086 | push ebx |
||
1087 | int 20h ; VMMCall _Allocate_LDT_Selector |
||
1088 | dw 78h |
||
1089 | dw 1 |
||
1090 | add esp, 14h |
||
1091 | mov [_gs], ax |
||
1092 | @@: |
||
1093 | push 0 |
||
1094 | push 1 |
||
1095 | mov eax, temp_code |
||
1096 | mov ecx, eax |
||
1097 | shl eax, 16 |
||
1098 | add eax, temp_code_size-1 |
||
1099 | push eax |
||
1100 | mov eax, ecx |
||
1101 | and eax, 0xFF000000 |
||
1102 | add eax, 0000000011111011b shl 8 |
||
1103 | shr ecx, 16 |
||
1104 | mov al, cl |
||
1105 | push eax |
||
1106 | push ebx |
||
1107 | int 20h ; VMMCall _Allocate_LDT_Selector |
||
1108 | dw 78h |
||
1109 | dw 1 |
||
1110 | add esp, 14h |
||
1111 | mov [temp_cs], ax |
||
1112 | mov [temp_cs2], ax |
||
1113 | push 0 |
||
1114 | push 1 |
||
1115 | mov eax, temp_stack |
||
1116 | mov ecx, eax |
||
1117 | shl eax, 16 |
||
1118 | add eax, temp_stack_size-1 |
||
1119 | push eax |
||
1120 | mov eax, ecx |
||
1121 | and eax, 0xFF000000 |
||
1122 | add eax, 0000000011110011b shl 8 |
||
1123 | shr ecx, 16 |
||
1124 | mov al, cl |
||
1125 | push eax |
||
1126 | push ebx |
||
1127 | int 20h ; VMMCall _Allocate_LDT_Selector |
||
1128 | dw 78h |
||
1129 | dw 1 |
||
1130 | add esp, 14h |
||
1131 | mov [temp_ss], ax |
||
1132 | ; mov eax, 40h |
||
1133 | ; mov cx, [_cs] |
||
1134 | ; mov edx, i40_9x |
||
1135 | ; int 20h ; VMMCall Set_PM_Int_Vector |
||
1136 | ; dw 45h |
||
1137 | ; dw 1 |
||
1138 | ; xor ecx, ecx |
||
1139 | ; xor edx, edx |
||
1140 | ; int 20h ; VMMCall Get_PM_Int_Vector |
||
1141 | ; dw 44h |
||
1142 | ; dw 1 |
||
1143 | iret |
||
1144 | fl0p: |
||
1145 | int 20h ; VMMCall Get_Cur_VM_Handle |
||
1146 | dw 1 |
||
1147 | dw 1 |
||
1148 | movzx eax, [klbr_cs] |
||
1149 | call free_selector |
||
1150 | movzx eax, [klbr_ds] |
||
1151 | call free_selector |
||
1152 | movzx eax, [temp_cs] |
||
1153 | call free_selector |
||
1154 | movzx eax, [temp_ss] |
||
1155 | call free_selector |
||
1156 | xor ebx, ebx |
||
1157 | iret |
||
1158 | sl0p: |
||
1159 | int 20h ; VMMCall Get_Cur_VM_Handle |
||
1160 | dw 1 |
||
1161 | dw 1 |
||
1162 | push 0 |
||
1163 | push dword [esi] |
||
1164 | push dword [esi+4] |
||
1165 | push ebx |
||
1166 | movzx eax, [klbr_cs] |
||
1167 | push eax |
||
1168 | int 20h ; VMMCall _SetDescriptor |
||
1169 | dw 7Ch |
||
1170 | dw 1 |
||
1171 | push 0 |
||
1172 | push dword [esi-8] |
||
1173 | push dword [esi-4] |
||
1174 | push ebx |
||
1175 | movzx eax, [klbr_ds] |
||
1176 | push eax |
||
1177 | int 20h ; VMMCall _SetDescriptor |
||
1178 | dw 7Ch |
||
1179 | dw 1 |
||
1180 | add esp, 40 |
||
1181 | iret |
||
1182 | rdmsrp: |
||
1183 | ; rdmsr may throw exception |
||
1184 | mov esi, .exception_struc |
||
1185 | int 20h ; VMMCall Install_Exception_Handler |
||
1186 | dw 0EFh |
||
1187 | dw 1 |
||
1188 | xor ebx, ebx ; assume OK |
||
1189 | .start_eip: |
||
1190 | rdmsr |
||
1191 | .end_eip: |
||
1192 | mov esi, .exception_struc |
||
1193 | int 20h ; VMMCall Remove_Exception_Handler |
||
1194 | dw 0F0h |
||
1195 | dw 1 |
||
1196 | iret |
||
1197 | .exception_struc: |
||
1198 | dd 0 |
||
1199 | dd .start_eip |
||
1200 | dd .end_eip |
||
1201 | dd .exception_handler |
||
1202 | .exception_handler: |
||
1203 | inc ebx |
||
1204 | jmp .end_eip |
||
1205 | |||
1206 | free_selector: |
||
1207 | push 0 |
||
1208 | push eax |
||
1209 | push ebx |
||
1210 | int 20h ; VMMCall _Free_LDT_Selector |
||
1211 | dw 79h |
||
1212 | dw 1 |
||
1213 | add esp, 12 |
||
1214 | ret |
||
1215 | |||
1216 | seh: |
||
1217 | mov eax, [esp+12] |
||
1218 | add dword [eax+0xB8], 2 |
||
1219 | xor eax, eax |
||
1220 | ret |
||
1221 | |||
1222 | ofn_hook: |
||
1223 | cmp dword [esp+8], 2 ; WM_DESTROY |
||
1224 | jnz @f |
||
1225 | push 260 |
||
1226 | mov eax, converted_path |
||
1227 | mov [parameters], eax |
||
1228 | push eax |
||
1229 | push 23 |
||
1230 | push dword [esp+12+4] |
||
1231 | push user32_name |
||
1232 | call [GetModuleHandleA] |
||
1233 | push GetDlgItemTextA_thunk+2 |
||
1234 | push eax |
||
1235 | call [GetProcAddress] |
||
1236 | call eax |
||
1237 | @@: |
||
1238 | xor eax, eax |
||
1239 | ret 10h |
||
1240 | |||
1241 | getfilename: |
||
1242 | @@: |
||
1243 | lodsb |
||
1244 | cmp al, 0 |
||
1245 | jz .not |
||
1246 | cmp al, ' ' |
||
1247 | jbe @b |
||
1248 | cmp al, '"' |
||
1249 | setz dl |
||
1250 | jz .loo |
||
1251 | dec esi |
||
1252 | .loo: |
||
1253 | lodsb |
||
1254 | cmp al, 0 |
||
1255 | jz .end |
||
1256 | cmp al, ' ' |
||
1257 | ja @f |
||
1258 | test dl, 1 |
||
1259 | jz .end |
||
1260 | @@: cmp al, '"' |
||
1261 | jnz @f |
||
1262 | test dl, 1 |
||
1263 | jnz .end_quote |
||
1264 | @@: stosb |
||
1265 | jmp .loo |
||
1266 | .end_quote: |
||
1267 | lodsb |
||
1268 | .end: |
||
1269 | or al, al |
||
1270 | jnz @f |
||
1271 | dec esi |
||
1272 | @@: mov al, 0 |
||
1273 | stosb |
||
1274 | clc |
||
1275 | ret |
||
1276 | .not: |
||
1277 | stc |
||
1278 | ret |
||
1279 | |||
1280 | map_shared_data: |
||
1281 | push 0 |
||
1282 | push 0 |
||
1283 | push 0 |
||
1284 | push 2 |
||
1285 | push [hSharedData] |
||
1286 | call [MapViewOfFile] |
||
1287 | mov [shared_data], eax |
||
1288 | ret |
||
1289 | |||
1290 | acquire_shared: |
||
1291 | pushad |
||
1292 | push -1 |
||
1293 | push [hSharedMutex] |
||
1294 | call [WaitForSingleObject] |
||
1295 | popad |
||
1296 | ret |
||
1297 | release_shared: |
||
1298 | pushad |
||
1299 | push [hSharedMutex] |
||
1300 | call [ReleaseMutex] |
||
1301 | popad |
||
1302 | ret |
||
1303 | |||
1304 | get_cur_slot_ptr_server: |
||
1305 | push eax |
||
1306 | mov eax, [cur_slot] |
||
1307 | @@: |
||
1308 | call get_slot_ptr |
||
1309 | pop eax |
||
1310 | ret |
||
1311 | get_cur_slot_ptr: |
||
1312 | push eax |
||
1313 | mov eax, [ebp+tls.cur_slot] |
||
1314 | jmp @b |
||
1315 | get_slot_ptr: |
||
1316 | mov edi, [shared_data] |
||
1317 | shl eax, 6 |
||
1318 | lea edi, [eax+edi+shared_data_struc.threads] |
||
1319 | ret |
||
1320 | |||
1321 | read_color: |
||
1322 | push esi |
||
1323 | mov ecx, 6 |
||
1324 | xor edx, edx |
||
1325 | .l: |
||
1326 | lodsb |
||
1327 | cmp al, 0 |
||
1328 | jz .d |
||
1329 | or al, 20h |
||
1330 | sub al, '0' |
||
1331 | cmp al, 10 |
||
1332 | jb @f |
||
1333 | sub al, 'a'-10-'0' |
||
1334 | @@: |
||
1335 | shl edx, 4 |
||
1336 | or dl, al |
||
1337 | loop .l |
||
1338 | .d: |
||
1339 | pop esi |
||
1340 | xchg eax, edx |
||
1341 | ret |
||
1342 | |||
1343 | i40_9x: |
||
1344 | ; set Win32 context |
||
1345 | push eax ecx |
||
1346 | mov eax, [cs:tls_index] |
||
1347 | shl eax, 2 |
||
1348 | add eax, [fs:2Ch] |
||
1349 | mov eax, [cs:eax] |
||
1350 | mov ds, [cs:eax+tls._ds] |
||
1351 | mov es, [eax+tls._ds] |
||
1352 | ; mov fs, [_fs] |
||
1353 | mov ecx, [esp+8] ; eip |
||
1354 | dec ecx |
||
1355 | dec ecx |
||
1356 | mov [eax+tls._eip], ecx |
||
1357 | mov ecx, [esp+16] ; eflags |
||
1358 | mov ss, [eax+tls._ds] |
||
1359 | xchg esp, [eax+tls._esp] |
||
1360 | push ecx |
||
1361 | add [eax+tls._esp], 20 |
||
1362 | mov eax, [eax+tls._esp] |
||
1363 | add eax, [base] |
||
1364 | mov ecx, [eax-20] |
||
1365 | mov eax, [eax-16] |
||
1366 | popfd |
||
1367 | |||
1368 | exception: |
||
1369 | pushfd |
||
1370 | cld |
||
1371 | ; test for page fault in direct screen area |
||
1372 | push ebp eax |
||
1373 | mov eax, [tls_index] |
||
1374 | mov ebp, [fs:2Ch] |
||
1375 | mov ebp, [ebp+eax*4] |
||
1376 | mov eax, [ebp+tls.saved_fs0] |
||
1377 | mov [fs:0], eax |
||
1378 | mov eax, [ebp+tls.saved_fs4] |
||
1379 | mov [fs:4], eax |
||
1380 | cmp [ebp+tls.exc_code], 0C0000005h |
||
1381 | jnz noaccvio |
||
1382 | mov eax, [ebp+tls.exc_data] |
||
1383 | sub eax, [DSA] |
||
1384 | cmp eax, 0FFFFFFh |
||
1385 | ja noaccvio |
||
1386 | ; handle page fault in direct screen area |
||
1387 | pop eax ebp |
||
1388 | pushad |
||
1389 | mov ebp, [tls_index] |
||
1390 | shl ebp, 2 |
||
1391 | add ebp, [fs:2Ch] |
||
1392 | mov ebp, [ebp] |
||
1393 | push DSACritSect |
||
1394 | call [EnterCriticalSection] |
||
1395 | cmp [bHaveDSA], 0 |
||
1396 | jnz dsafail |
||
1397 | call get_screen_size |
||
1398 | mov eax, ebx |
||
1399 | shr eax, 16 |
||
1400 | movzx ebx, bx |
||
1401 | inc eax |
||
1402 | inc ebx |
||
1403 | mov edi, eax |
||
1404 | mul ebx |
||
1405 | mul [ColorDepth] |
||
1406 | shr eax, 3 |
||
1407 | add eax, 0xFFF |
||
1408 | and eax, not 0xFFF |
||
1409 | mov ecx, [ebp+tls.exc_data] |
||
1410 | sub ecx, [DSA] |
||
1411 | cmp ecx, eax |
||
1412 | jb @f |
||
1413 | dsafail: |
||
1414 | push DSACritSect |
||
1415 | call [LeaveCriticalSection] |
||
1416 | push 40h |
||
1417 | push 0 |
||
1418 | push DSAErr |
||
1419 | push 0 |
||
1420 | mbni: |
||
1421 | call [MessageBoxA] |
||
1422 | popad |
||
1423 | push ebp eax |
||
1424 | mov ebp, [tls_index] |
||
1425 | shl ebp, 2 |
||
1426 | add ebp, [fs:2Ch] |
||
1427 | mov ebp, [ebp] |
||
1428 | jmp notint40 |
||
1429 | @@: |
||
1430 | push 4 |
||
1431 | push 1000h |
||
1432 | push eax |
||
1433 | push [DSA] |
||
1434 | call [VirtualAlloc] |
||
1435 | ; get screen data |
||
1436 | push ebp |
||
1437 | push 0 |
||
1438 | call [GetDC] |
||
1439 | push eax |
||
1440 | xchg eax, ebp |
||
1441 | call [CreateCompatibleDC] |
||
1442 | xchg eax, esi |
||
1443 | push ebx |
||
1444 | push edi |
||
1445 | push ebp |
||
1446 | call [CreateCompatibleBitmap] |
||
1447 | push eax |
||
1448 | push esi |
||
1449 | call [SelectObject] |
||
1450 | push eax |
||
1451 | xor eax, eax |
||
1452 | push 0xCC0020 |
||
1453 | push eax |
||
1454 | push eax |
||
1455 | push ebp |
||
1456 | push ebx |
||
1457 | push edi |
||
1458 | push eax |
||
1459 | push eax |
||
1460 | push esi |
||
1461 | call [BitBlt] |
||
1462 | push esi |
||
1463 | call [SelectObject] |
||
1464 | push ebp |
||
1465 | xchg eax, ebp |
||
1466 | xor eax, eax |
||
1467 | ; now esi=hDC, ebp=hBitmap |
||
1468 | push eax ; biClrImportant |
||
1469 | push eax ; biClrUsed |
||
1470 | push eax ; biYPelsPerMeter |
||
1471 | push eax ; biXPelsPerMeter |
||
1472 | push eax ; biSizeImage |
||
1473 | push eax ; biCompression |
||
1474 | push 1 ; biPlanes |
||
1475 | mov ecx, [ColorDepth] |
||
1476 | mov [esp+2], cx ; biBitColor |
||
1477 | neg ebx |
||
1478 | push ebx ; biHeight |
||
1479 | neg ebx |
||
1480 | push edi ; biWidth |
||
1481 | push 40 ; biSize |
||
1482 | mov ecx, esp |
||
1483 | push eax |
||
1484 | push ecx |
||
1485 | push [DSA] |
||
1486 | push ebx |
||
1487 | push eax |
||
1488 | push ebp |
||
1489 | push esi |
||
1490 | call [GetDIBits] |
||
1491 | add esp, 40 |
||
1492 | push ebp |
||
1493 | call [DeleteObject] |
||
1494 | push esi |
||
1495 | call [DeleteDC] |
||
1496 | push 0 |
||
1497 | call [ReleaseDC] |
||
1498 | mov [bHaveDSA], 1 |
||
1499 | push eax |
||
1500 | push esp |
||
1501 | push 0 |
||
1502 | push 0 |
||
1503 | push DSAFreeThread |
||
1504 | push 10000h |
||
1505 | push 0 |
||
1506 | call [CreateThread] |
||
1507 | pop eax |
||
1508 | push DSACritSect |
||
1509 | call [LeaveCriticalSection] |
||
1510 | pop ebp |
||
1511 | mov ebp, [tls_index] |
||
1512 | shl ebp, 2 |
||
1513 | add ebp, [fs:2Ch] |
||
1514 | mov ebp, [ebp] |
||
1515 | jmp i40_done |
||
1516 | noaccvio: |
||
1517 | ; test for int40 |
||
1518 | mov eax, [ebp+tls._eip] |
||
1519 | cmp eax, [limit] |
||
1520 | jae notint40 |
||
1521 | add eax, [base] |
||
1522 | cmp word [eax], 0x40CD |
||
1523 | jz int40 |
||
1524 | notint40: |
||
1525 | |||
1526 | pop eax |
||
1527 | push esi |
||
1528 | sub esp, 400h |
||
1529 | mov esi, esp |
||
1530 | push dword [esi+408h] |
||
1531 | push [ebp+tls._eip] |
||
1532 | push dword [esi+404h] |
||
1533 | push [ebp+tls._esp] |
||
1534 | push edi |
||
1535 | push dword [esi+400h] |
||
1536 | push edx |
||
1537 | push ecx |
||
1538 | push ebx |
||
1539 | push eax |
||
1540 | push excstr |
||
1541 | push esi |
||
1542 | call [wsprintfA] |
||
1543 | push 0 |
||
1544 | push exceptionstr |
||
1545 | push esi |
||
1546 | push 0 |
||
1547 | call [MessageBoxA] |
||
1548 | lock dec [NumThreads] |
||
1549 | jnz .et |
||
1550 | call free_ldt |
||
1551 | push 0 |
||
1552 | call [ExitProcess] |
||
1553 | .et: |
||
1554 | push 0 |
||
1555 | call [ExitThread] |
||
1556 | |||
1557 | int40: |
||
1558 | add [ebp+tls._eip], 2 |
||
1559 | pop eax ebp |
||
1560 | pushad |
||
1561 | safe_to_suspend: |
||
1562 | mov ebp, [tls_index] |
||
1563 | shl ebp, 2 |
||
1564 | add ebp, [fs:2Ch] |
||
1565 | mov ebp, [ebp] |
||
1566 | inc eax |
||
1567 | cmp eax, num_i40_fns |
||
1568 | push eax ; emulate ret addr for not_supported_i40_fn |
||
1569 | jae not_supported_i40_fn |
||
1570 | pop eax |
||
1571 | call [i40fns + eax*4] |
||
1572 | i40_done: |
||
1573 | cmp [NumThreads], 1 |
||
1574 | jnz i40_done_mt |
||
1575 | mov eax, [ebp+tls._esp] |
||
1576 | mov [klbr_esp], eax |
||
1577 | mov eax, [ebp+tls._eip] |
||
1578 | mov [jmp_klbr_eip], eax |
||
1579 | lea eax, [esp+24h] |
||
1580 | mov [ebp+tls._esp], eax |
||
1581 | mov [ebp+tls._eip], exception |
||
1582 | mov eax, [fs:0] |
||
1583 | mov [ebp+tls.saved_fs0], eax |
||
1584 | mov eax, [fs:4] |
||
1585 | mov [ebp+tls.saved_fs4], eax |
||
1586 | popad |
||
1587 | popfd |
||
1588 | mov ss, [klbr_ds] |
||
1589 | mov esp, [klbr_esp] |
||
1590 | mov es, [klbr_ds] |
||
1591 | ; mov fs, [klbr_null] |
||
1592 | ; mov gs, [klbr_null] |
||
1593 | mov gs, [_gs] |
||
1594 | mov ds, [klbr_ds] |
||
1595 | i40_done_jmp1: |
||
1596 | jmp [cs:jmp_klbr] |
||
1597 | i40_done_mt: |
||
1598 | mov eax, [ebp+tls._esp] |
||
1599 | mov [esp+12], eax |
||
1600 | mov ecx, [ebp+tls._eip] |
||
1601 | xchg [fs:0], ecx |
||
1602 | mov [ebp+tls.saved_fs0], ecx |
||
1603 | movzx ecx, [klbr_cs] |
||
1604 | xchg [fs:4], ecx |
||
1605 | mov [ebp+tls.saved_fs4], ecx |
||
1606 | lea eax, [esp+24h] |
||
1607 | mov [ebp+tls._esp], eax |
||
1608 | mov [ebp+tls._eip], exception |
||
1609 | popad |
||
1610 | popfd |
||
1611 | mov ss, [klbr_ds] |
||
1612 | mov esp, [ds:esp-24h+12] |
||
1613 | mov es, [klbr_ds] |
||
1614 | ; mov fs, [klbr_null] |
||
1615 | ; mov gs, [klbr_null] |
||
1616 | mov gs, [_gs] |
||
1617 | mov ds, [klbr_ds] |
||
1618 | i40_done_jmp2: |
||
1619 | jmp fword [fs:0] |
||
1620 | |||
1621 | not_supported_i40_fn: |
||
1622 | sub esp, 200h-4 |
||
1623 | mov esi, esp |
||
1624 | push dword [esi+200h+20h] |
||
1625 | push [ebp+tls._eip] |
||
1626 | push dword [esi+200h+8] |
||
1627 | push [ebp+tls._esp] |
||
1628 | push dword [esi+200h] |
||
1629 | push dword [esi+200h+4] |
||
1630 | push dword [esi+200h+14h] |
||
1631 | push dword [esi+200h+18h] |
||
1632 | push dword [esi+200h+10h] |
||
1633 | push dword [esi+200h+1Ch] |
||
1634 | push notsupportedmsg |
||
1635 | push esi |
||
1636 | call [wsprintfA] |
||
1637 | push 0 |
||
1638 | push nsm |
||
1639 | push esi |
||
1640 | push 0 |
||
1641 | call [MessageBoxA] |
||
1642 | i40_terminate: |
||
1643 | lock dec [NumThreads] |
||
1644 | jnz .thread |
||
1645 | call free_ldt |
||
1646 | push 0 |
||
1647 | call [ExitProcess] |
||
1648 | .thread: |
||
1649 | push 0 |
||
1650 | call [ExitThread] |
||
1651 | |||
1652 | align 4 |
||
1653 | i40fns dd i40_terminate ; -1 |
||
1654 | dd i40_draw_window ; 0 |
||
1655 | dd i40_put_pixel ; 1 |
||
1656 | dd i40_getkey ; 2 |
||
1657 | dd i40_get_sys_time ; 3 |
||
1658 | dd i40_writetext ; 4 |
||
1659 | dd i40_delay ; 5 |
||
1660 | dd i40_read_floppy_file ; 6 |
||
1661 | dd i40_putimage ; 7 |
||
1662 | dd i40_define_button ; 8 |
||
1663 | dd i40_get_process_info ; 9 |
||
1664 | dd i40_wait_event ; 10 |
||
1665 | dd i40_check_event ; 11 |
||
1666 | dd i40_redraw_status ; 12 |
||
1667 | dd i40_drawrect ; 13 |
||
1668 | dd i40_get_screen_size ; 14 |
||
1669 | dd i40_set_background ; 15 |
||
1670 | dd not_supported_i40_fn ; 16 |
||
1671 | dd i40_getbutton ; 17 |
||
1672 | dd i40_sys_service ; 18 |
||
1673 | dd not_supported_i40_fn ; 19 |
||
1674 | dd not_supported_i40_fn ; 20 |
||
1675 | dd i40_sys_setup ; 21 |
||
1676 | dd not_supported_i40_fn ; 22 |
||
1677 | dd i40_wait_event_timeout ; 23 |
||
1678 | dd not_supported_i40_fn ; 24 |
||
1679 | dd not_supported_i40_fn ; 25 |
||
1680 | dd i40_getsetup ; 26 |
||
1681 | dd not_supported_i40_fn ; 27 |
||
1682 | dd not_supported_i40_fn ; 28 |
||
1683 | dd i40_get_sys_date ; 29 |
||
1684 | dd i40_current_folder ; 30 |
||
1685 | dd not_supported_i40_fn ; 31 |
||
1686 | dd i40_delete_ramdisk_file ; 32 |
||
1687 | dd i40_write_ramdisk_file ; 33 |
||
1688 | dd not_supported_i40_fn ; 34 |
||
1689 | dd i40_screen_getpixel ; 35 |
||
1690 | dd i40_screen_getarea ; 36 |
||
1691 | dd i40_read_mouse_pos ; 37 |
||
1692 | dd i40_draw_line ; 38 |
||
1693 | dd i40_get_background ; 39 |
||
1694 | dd i40_set_event_mask ; 40 |
||
1695 | dd not_supported_i40_fn ; 41 |
||
1696 | dd not_supported_i40_fn ; 42 |
||
1697 | dd not_supported_i40_fn ; 43 |
||
1698 | dd not_supported_i40_fn ; 44 |
||
1699 | dd not_supported_i40_fn ; 45 |
||
1700 | dd i40_reserve_free_ports ; 46 |
||
1701 | dd i40_display_number ; 47 |
||
1702 | dd i40_display_settings ; 48 |
||
1703 | dd not_supported_i40_fn ; 49 |
||
1704 | dd i40_set_window_shape ; 50 |
||
1705 | dd i40_create_thread ; 51 |
||
1706 | dd not_supported_i40_fn ; 52 |
||
1707 | dd not_supported_i40_fn ; 53 |
||
1708 | dd not_supported_i40_fn ; 54 |
||
1709 | dd i40_sound_interface ; 55 |
||
1710 | dd not_supported_i40_fn ; 56 |
||
1711 | dd not_supported_i40_fn ; 57 |
||
1712 | dd i40_file_system ; 58 |
||
1713 | dd not_supported_i40_fn ; 59 |
||
1714 | dd i40_ipc ; 60 |
||
1715 | dd i40_direct_scr_access ; 61 |
||
1716 | dd i40_pci ; 62 |
||
1717 | dd i40_debug_board ; 63 |
||
1718 | dd i40_resize_app_memory ; 64 |
||
1719 | dd i40_putimage_palette ; 65 |
||
1720 | dd i40_process_def ; 66 |
||
1721 | dd i40_move_resize ; 67 |
||
1722 | dd i40_sys_services ; 68 |
||
1723 | dd i40_debug_services ; 69 |
||
1724 | dd i40_file_system_lfn ; 70 |
||
1725 | dd i40_window_settings ; 71 |
||
1726 | num_i40_fns = ($ - i40fns)/4 |
||
1727 | |||
1728 | getfilemap: |
||
1729 | ; in: esi->filename |
||
1730 | ; out: eax->mapped file |
||
1731 | push esi |
||
1732 | sub esp, 200h |
||
1733 | cmp word [esi+1], ':\' |
||
1734 | jz .fullpath |
||
1735 | mov edi, esp |
||
1736 | push esi |
||
1737 | mov esi, startcurdir |
||
1738 | @@: |
||
1739 | lodsb |
||
1740 | stosb |
||
1741 | test al, al |
||
1742 | jnz @b |
||
1743 | pop esi |
||
1744 | dec edi |
||
1745 | mov al, '\' |
||
1746 | cmp byte [edi-1], al |
||
1747 | jz @f |
||
1748 | stosb |
||
1749 | @@: |
||
1750 | lodsb |
||
1751 | stosb |
||
1752 | test al, al |
||
1753 | jnz @b |
||
1754 | mov esi, esp |
||
1755 | .fullpath: |
||
1756 | push ebx |
||
1757 | push ebx |
||
1758 | push 3 ; OPEN_EXISTING |
||
1759 | push ebx |
||
1760 | push 1 ; FILE_SHARE_READ |
||
1761 | push 80000000h ; GENERIC_READ |
||
1762 | push esi |
||
1763 | call [CreateFileA] |
||
1764 | add esp, 200h |
||
1765 | pop esi |
||
1766 | inc eax |
||
1767 | jz .failed |
||
1768 | dec eax |
||
1769 | xchg eax, edi |
||
1770 | push ebx |
||
1771 | push ebx |
||
1772 | push ebx |
||
1773 | push 2 ; PAGE_READONLY |
||
1774 | push ebx |
||
1775 | push edi |
||
1776 | call [CreateFileMappingA] |
||
1777 | test eax, eax |
||
1778 | jz .failed |
||
1779 | push edi |
||
1780 | xchg eax, edi |
||
1781 | call [CloseHandle] |
||
1782 | push ebx |
||
1783 | push ebx |
||
1784 | push ebx |
||
1785 | push 4 ; FILE_MAP_READ |
||
1786 | push edi |
||
1787 | call [MapViewOfFile] |
||
1788 | test eax, eax |
||
1789 | jz .failed |
||
1790 | push eax |
||
1791 | push edi |
||
1792 | call [CloseHandle] |
||
1793 | pop eax |
||
1794 | ret |
||
1795 | .failed: |
||
1796 | push ebx |
||
1797 | push filereaderr |
||
1798 | jmp fail2 |
||
1799 | |||
1800 | DSAFreeThread: |
||
1801 | push [InvalidateTime] |
||
1802 | call [Sleep] |
||
1803 | push DSACritSect |
||
1804 | call [EnterCriticalSection] |
||
1805 | push 4000h |
||
1806 | push 0 |
||
1807 | push [DSA] |
||
1808 | call [VirtualFree] |
||
1809 | mov [bHaveDSA], 0 |
||
1810 | push DSACritSect |
||
1811 | call [LeaveCriticalSection] |
||
1812 | ret |
||
1813 | |||
1814 | virtual at 0 |
||
1815 | button_desc: |
||
1816 | .next dd ? ; must be 1st dword |
||
1817 | .id dd ? |
||
1818 | .xsize dw ? |
||
1819 | .xstart dw ? |
||
1820 | .ysize dw ? |
||
1821 | .ystart dw ? |
||
1822 | .color dd ? |
||
1823 | .size = $ |
||
1824 | end virtual |
||
1825 | |||
1826 | test_maximized: |
||
1827 | sub esp, 40 |
||
1828 | push 44 |
||
1829 | push esp |
||
1830 | push [ebp+tls.hWnd] |
||
1831 | call [GetWindowPlacement] |
||
1832 | mov eax, [esp+8] ; showCmd |
||
1833 | add esp, 44 |
||
1834 | cmp eax, 3 ; SW_SHOWMAXIMIZED |
||
1835 | ret |
||
1836 | |||
1837 | wndproc: |
||
1838 | ; LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) |
||
1839 | push ebp |
||
1840 | mov ebp, [tls_index] |
||
1841 | mov eax, [fs:2Ch] |
||
1842 | mov ebp, [eax+ebp*4] |
||
1843 | mov eax, [esp+8+4] |
||
1844 | cmp eax, 0xF ; WM_PAINT |
||
1845 | jz wmpaint |
||
1846 | dec eax |
||
1847 | ; jz wmcreate |
||
1848 | dec eax |
||
1849 | jz wmdestroy |
||
1850 | dec eax |
||
1851 | jz wmmove |
||
1852 | dec eax |
||
1853 | dec eax |
||
1854 | jz wmsize |
||
1855 | dec eax |
||
1856 | jz wmactivate |
||
1857 | cmp eax, 0x1A-6 |
||
1858 | jz wmsettingchange |
||
1859 | cmp eax, 0x20-6 |
||
1860 | jz wmsetcursor |
||
1861 | cmp eax, 0x24-6 |
||
1862 | jz wmgetminmaxinfo |
||
1863 | sub eax, 0x84-6 |
||
1864 | jz wmnchittest |
||
1865 | cmp eax, 0xA1-0x84 |
||
1866 | jz wmnclbuttondown |
||
1867 | cmp eax, 0xA3-0x84 |
||
1868 | jz wmnclbuttondblclk |
||
1869 | sub eax, 0x100-0x84 ; WM_KEYDOWN |
||
1870 | jz wmkeydown |
||
1871 | dec eax |
||
1872 | jz wmkeyup |
||
1873 | dec eax |
||
1874 | jz wmchar |
||
1875 | dec eax |
||
1876 | dec eax |
||
1877 | jz wmsyskeydown |
||
1878 | dec eax |
||
1879 | jz wmsyskeyup |
||
1880 | sub eax, 0x200-0x105 ; WM_MOUSEMOVE |
||
1881 | jz wmmousemove |
||
1882 | dec eax |
||
1883 | jz wmlbuttondown |
||
1884 | dec eax |
||
1885 | jz wmlbuttonup |
||
1886 | dec eax |
||
1887 | dec eax |
||
1888 | jz wmrbuttondown |
||
1889 | dec eax |
||
1890 | jz wmrbuttonup |
||
1891 | cmp eax, 0x20A-0x205 |
||
1892 | jz wmmousewheel |
||
1893 | cmp eax, 0x214-0x205 |
||
1894 | jz wmsizing |
||
1895 | sub eax, 0x400-0x205 ; WM_USER |
||
1896 | jz wm_ipc |
||
1897 | cmp eax, 0xC000-0x400 |
||
1898 | jz vk_mouse |
||
1899 | dec eax |
||
1900 | jz wm_debug1 |
||
1901 | dec eax |
||
1902 | jz wm_debug2 |
||
1903 | wmdef: |
||
1904 | pop ebp |
||
1905 | jmp [DefWindowProcA] |
||
1906 | wmsettingchange: |
||
1907 | call del_background |
||
1908 | @@: |
||
1909 | test [ebp+tls.message_mask], 10h |
||
1910 | jz wmdef |
||
1911 | mov [ebp+tls.translated_msg_code], 5 |
||
1912 | push 0 |
||
1913 | push 0 |
||
1914 | push 0 |
||
1915 | push dword [esp+20] |
||
1916 | call [PostMessageA] |
||
1917 | jmp wmdef |
||
1918 | wmactivate: |
||
1919 | mov eax, [shared_data] |
||
1920 | mov ecx, [ebp+tls.cur_slot] |
||
1921 | inc ecx |
||
1922 | cmp word [esp+12+4], 0 |
||
1923 | jz .inact1 |
||
1924 | mov [eax+shared_data_struc.active_process], ecx |
||
1925 | jmp .cmn1 |
||
1926 | .inact1: |
||
1927 | call acquire_shared |
||
1928 | cmp [eax+shared_data_struc.active_process], ecx |
||
1929 | jnz @f |
||
1930 | mov [eax+shared_data_struc.active_process], 1 |
||
1931 | @@: call release_shared |
||
1932 | .cmn1: |
||
1933 | mov al, byte [ebp+tls.color_main+3] |
||
1934 | and al, 0Fh |
||
1935 | cmp al, 3 |
||
1936 | jz .setactive |
||
1937 | cmp al, 4 |
||
1938 | jnz wmdef |
||
1939 | .setactive: |
||
1940 | mov al, [esp+12+4] |
||
1941 | mov [ebp+tls.bActive], al ; 0/1/2 |
||
1942 | wndproc_update_wnd: |
||
1943 | mov [ebp+tls.curdraw], 0 |
||
1944 | push 0 |
||
1945 | push 0 |
||
1946 | push [ebp+tls.hWnd] |
||
1947 | call [InvalidateRect] |
||
1948 | jmp wmdef |
||
1949 | wmpaint: |
||
1950 | push esi |
||
1951 | push edi |
||
1952 | sub esp, 0x40 |
||
1953 | push esp |
||
1954 | push [ebp+tls.hWnd] |
||
1955 | call [BeginPaint] |
||
1956 | ; test [ebp+tls.message_mask], 1 |
||
1957 | ; jz @f |
||
1958 | ; mov [ebp+tls.translated_msg_code], 1 |
||
1959 | @@: xchg eax, edi |
||
1960 | cmp [ebp+tls.curdraw], 0 |
||
1961 | mov [ebp+tls.curdraw], 1 |
||
1962 | jz .nopaint |
||
1963 | call draw_window_base |
||
1964 | .nopaint: |
||
1965 | push esp |
||
1966 | push [ebp+tls.hWnd] |
||
1967 | call [EndPaint] |
||
1968 | add esp, 40h |
||
1969 | pop edi |
||
1970 | pop esi |
||
1971 | pop ebp |
||
1972 | xor eax, eax |
||
1973 | ret 10h |
||
1974 | wmdestroy: |
||
1975 | push 0 |
||
1976 | call [PostQuitMessage] |
||
1977 | @@: |
||
1978 | xor eax, eax |
||
1979 | pop ebp |
||
1980 | ret 10h |
||
1981 | wmnclbuttondown: |
||
1982 | call test_maximized |
||
1983 | jnz wmdef |
||
1984 | push [ebp+tls.hWnd] |
||
1985 | call [SetForegroundWindow] |
||
1986 | jmp @b |
||
1987 | ;wmwindowposchanging: |
||
1988 | ; call test_maximized |
||
1989 | ; jnz @b |
||
1990 | ; mov eax, [esp+0x10+4] |
||
1991 | ; or byte [eax+18h], 2 ; SWP_NOMOVE |
||
1992 | ; jmp @b |
||
1993 | wmnchittest: |
||
1994 | ; for window type 1 always return HTCLIENT |
||
1995 | mov cl, byte [ebp+tls.color_main+3] |
||
1996 | and cl, 0x0F |
||
1997 | cmp cl, 0x01 |
||
1998 | jz .client |
||
1999 | mov ax, [esp+0x10+4] ; x |
||
2000 | sub ax, [ebp+tls.x_start] |
||
2001 | mov dx, [esp+0x12+4] ; y |
||
2002 | sub dx, [ebp+tls.y_start] |
||
2003 | ; test for caption |
||
2004 | push eax |
||
2005 | mov eax, [_skinh] |
||
2006 | cmp cl, 0x03 |
||
2007 | jz @f |
||
2008 | mov al, 21 |
||
2009 | @@: |
||
2010 | cmp dx, ax |
||
2011 | pop eax |
||
2012 | jae .nocaption |
||
2013 | ; check for buttons |
||
2014 | push esi |
||
2015 | call find_button |
||
2016 | test esi, esi |
||
2017 | pop esi |
||
2018 | jnz .button |
||
2019 | .caption: |
||
2020 | push 2 ; HTCAPTION |
||
2021 | pop eax |
||
2022 | pop ebp |
||
2023 | ret 10h |
||
2024 | .button: |
||
2025 | .client: |
||
2026 | push 1 ; HTCLIENT |
||
2027 | jmp .ret |
||
2028 | .nocaption: |
||
2029 | ; do not resize window with type 0 |
||
2030 | jecxz .client |
||
2031 | ; do not resize window with type 4 |
||
2032 | cmp ecx, 0x04000000 |
||
2033 | jz .client |
||
2034 | ; do not resize maximized window |
||
2035 | push eax edx |
||
2036 | call test_maximized |
||
2037 | pop edx eax |
||
2038 | jz .client |
||
2039 | sub dx, [ebp+tls.y_size] |
||
2040 | neg dx |
||
2041 | cmp dx, 7 |
||
2042 | jbe .bottomall |
||
2043 | cmp ax, 7 |
||
2044 | jbe .left |
||
2045 | sub ax, [ebp+tls.x_size] |
||
2046 | neg ax |
||
2047 | cmp ax, 7 |
||
2048 | ja .client |
||
2049 | push 11 ; HTRIGHT |
||
2050 | jmp .ret |
||
2051 | .left: |
||
2052 | push 10 ; HTLEFT |
||
2053 | .ret: |
||
2054 | pop eax |
||
2055 | pop ebp |
||
2056 | ret 10h |
||
2057 | .bottomall: |
||
2058 | cmp ax, 7 |
||
2059 | jbe .bottomleft |
||
2060 | sub ax, [ebp+tls.x_size] |
||
2061 | neg ax |
||
2062 | cmp ax, 7 |
||
2063 | ja .bottom |
||
2064 | push 17 ; HTBOTTOMRIGHT |
||
2065 | jmp .ret |
||
2066 | .bottomleft: |
||
2067 | push 16 ; HTBOTTOMLEFT |
||
2068 | jmp .ret |
||
2069 | .bottom: |
||
2070 | push 15 ; HTBOTTOM |
||
2071 | jmp .ret |
||
2072 | wmsetcursor: |
||
2073 | cmp [ebp+tls.hCursor], 0 |
||
2074 | jz wmdef |
||
2075 | push [ebp+tls.hCursor] |
||
2076 | call [SetCursor] |
||
2077 | push 1 |
||
2078 | pop eax |
||
2079 | pop ebp |
||
2080 | ret 10h |
||
2081 | wmnclbuttondblclk: |
||
2082 | mov al, byte [ebp+tls.color_main+3] |
||
2083 | and al, 0xF |
||
2084 | jz .nomaximize |
||
2085 | cmp al, 1 |
||
2086 | jz .nomaximize |
||
2087 | cmp al, 4 |
||
2088 | jz .nomaximize |
||
2089 | call test_maximized |
||
2090 | mov eax, 3 ; SW_MAXIMIZED |
||
2091 | jnz @f |
||
2092 | mov al, 1 ; SW_SHOWNORMAL |
||
2093 | @@: |
||
2094 | push eax |
||
2095 | push [ebp+tls.hWnd] |
||
2096 | call [ShowWindow] |
||
2097 | push 1 |
||
2098 | push 0 |
||
2099 | push [ebp+tls.hWnd] |
||
2100 | call [InvalidateRect] |
||
2101 | .nomaximize: |
||
2102 | xor eax, eax |
||
2103 | pop ebp |
||
2104 | ret 10h |
||
2105 | wmmove: |
||
2106 | mov ax, [esp+0x10+4] |
||
2107 | mov [ebp+tls.x_start], ax |
||
2108 | mov ax, [esp+0x12+4] |
||
2109 | mov [ebp+tls.y_start], ax |
||
2110 | ; jmp wndproc_update_wnd |
||
2111 | xor eax, eax |
||
2112 | pop ebp |
||
2113 | ret 10h |
||
2114 | wmsize: |
||
2115 | mov ax, [esp+0x10+4] |
||
2116 | mov [ebp+tls.x_size], ax |
||
2117 | mov ax, [esp+0x12+4] |
||
2118 | mov [ebp+tls.y_size], ax |
||
2119 | ; jmp wndproc_update_wnd |
||
2120 | xor eax, eax |
||
2121 | pop ebp |
||
2122 | ret 10h |
||
2123 | wmsizing: |
||
2124 | mov eax, [esp+0x14] |
||
2125 | mov ecx, [eax] |
||
2126 | mov [ebp+tls.x_start], cx |
||
2127 | mov ecx, [eax+4] |
||
2128 | mov [ebp+tls.y_start], cx |
||
2129 | mov ecx, [eax+8] |
||
2130 | sub ecx, [eax] |
||
2131 | mov [ebp+tls.x_size], cx |
||
2132 | mov ecx, [eax+12] |
||
2133 | sub ecx, [eax+4] |
||
2134 | mov [ebp+tls.y_size], cx |
||
2135 | ; push 0 |
||
2136 | ; push 0 |
||
2137 | ; push [ebp+tls.hWnd] |
||
2138 | ; call [InvalidateRect] |
||
2139 | xor eax, eax |
||
2140 | inc eax |
||
2141 | pop ebp |
||
2142 | ret 10h |
||
2143 | wmsyskeydown: |
||
2144 | ; test byte [esp+16+3+4], 20h ; Alt pressed? |
||
2145 | ; jnz wmdef |
||
2146 | cmp byte [esp+16+2+4], 3Eh ; Alt+F4? |
||
2147 | jz wmdestroy |
||
2148 | wmkeydown: |
||
2149 | movzx eax, byte [esp+16+2+4] |
||
2150 | test eax, eax |
||
2151 | jnz @f |
||
2152 | mov al, 1Ch ; |
||
2153 | @@: |
||
2154 | cmp [ebp+tls.usescancode], 0 |
||
2155 | jnz .putkeycode |
||
2156 | ; ignore keys-modifiers |
||
2157 | cmp al, 2Ah |
||
2158 | jz .ret |
||
2159 | cmp al, 36h |
||
2160 | jz .ret |
||
2161 | cmp al, 38h |
||
2162 | jz .ret |
||
2163 | cmp al, 1Dh |
||
2164 | jz .ret |
||
2165 | cmp al, 3Ah |
||
2166 | jz .ret |
||
2167 | cmp al, 45h |
||
2168 | jz .ret |
||
2169 | cmp al, 46h |
||
2170 | jz .ret |
||
2171 | ; translate NumPad keys |
||
2172 | test byte [esp+14h+3], 1 |
||
2173 | jnz .nonumpad |
||
2174 | mov cl, '*' |
||
2175 | cmp al, 55 |
||
2176 | jz @f |
||
2177 | cmp al, 71 |
||
2178 | jb .nonumpad |
||
2179 | cmp al, 83 |
||
2180 | ja .nonumpad |
||
2181 | mov cl, [numlock_map+eax-71] |
||
2182 | @@: |
||
2183 | push eax |
||
2184 | push ecx |
||
2185 | sub esp, 100h |
||
2186 | push esp |
||
2187 | call [GetKeyboardState] |
||
2188 | mov al, [esp+0x90] ; VK_NUMLOCK |
||
2189 | add esp, 100h |
||
2190 | test al, 1 |
||
2191 | pop ecx |
||
2192 | pop eax |
||
2193 | jnz .put_cl |
||
2194 | .nonumpad: |
||
2195 | mov cl, [keymap+eax] |
||
2196 | push eax |
||
2197 | push ecx |
||
2198 | push 0x11 ; VK_CONTROL |
||
2199 | call [GetAsyncKeyState] |
||
2200 | test ax, ax |
||
2201 | jns @f |
||
2202 | sub byte [esp], 60h |
||
2203 | @@: |
||
2204 | push 0x10 ; VK_SHIFT |
||
2205 | call [GetAsyncKeyState] |
||
2206 | test ax, ax |
||
2207 | jns @f |
||
2208 | pop ecx |
||
2209 | pop eax |
||
2210 | mov cl, [keymap_shift+eax] |
||
2211 | push eax |
||
2212 | push ecx |
||
2213 | @@: |
||
2214 | push 0x12 ; VK_MENU |
||
2215 | call [GetAsyncKeyState] |
||
2216 | test ax, ax |
||
2217 | pop ecx |
||
2218 | pop eax |
||
2219 | jns @f |
||
2220 | mov cl, [keymap_alt+eax] |
||
2221 | @@: |
||
2222 | .put_cl: |
||
2223 | xchg eax, ecx |
||
2224 | .putkeycode: |
||
2225 | movzx ecx, [ebp+tls.keybuflen] |
||
2226 | inc cl |
||
2227 | jz .ret |
||
2228 | ; test for extended key (0xE0 prefix) |
||
2229 | test byte [esp+14h+3], 1 ; lParam+3 |
||
2230 | jz .noext |
||
2231 | cmp [ebp+tls.usescancode], 0 |
||
2232 | jz .noext |
||
2233 | mov [ebp+tls.keybuflen], cl |
||
2234 | mov [ebp+tls.keybuffer+ecx-1], 0xE0 |
||
2235 | inc cl |
||
2236 | jz .ret |
||
2237 | .noext: |
||
2238 | mov [ebp+tls.keybuflen], cl |
||
2239 | mov [ebp+tls.keybuffer+ecx-1], al |
||
2240 | test [ebp+tls.message_mask], 2 |
||
2241 | jz @f |
||
2242 | mov [ebp+tls.translated_msg_code], 2 |
||
2243 | @@: |
||
2244 | .ret: |
||
2245 | wmchar: |
||
2246 | xor eax, eax |
||
2247 | pop ebp |
||
2248 | ret 10h |
||
2249 | wmkeyup: |
||
2250 | wmsyskeyup: |
||
2251 | cmp [ebp+tls.usescancode], 0 |
||
2252 | jz wmkeydown.ret |
||
2253 | mov al, [esp+16+2+4] |
||
2254 | or al, 80h |
||
2255 | jmp wmkeydown.putkeycode |
||
2256 | ;wmchar: |
||
2257 | ; cmp [usescancode], 0 |
||
2258 | ; jnz wmkeydown.ret |
||
2259 | ; mov al, [esp+12] |
||
2260 | ; jmp wmkeydown.putkeycode |
||
2261 | wmlbuttondown: |
||
2262 | push esi |
||
2263 | push 1 |
||
2264 | jmp @f |
||
2265 | wmrbuttondown: |
||
2266 | push esi |
||
2267 | push 2 |
||
2268 | @@: |
||
2269 | call capture1 |
||
2270 | mov ax, [esp+0x10+12] ; x |
||
2271 | mov dx, [esp+0x12+12] ; y |
||
2272 | call find_button |
||
2273 | pop eax |
||
2274 | test esi, esi |
||
2275 | jnz .onbutton |
||
2276 | test [ebp+tls.message_mask], 20h |
||
2277 | jz @f |
||
2278 | mov [ebp+tls.translated_msg_code], 6 |
||
2279 | @@: |
||
2280 | .done: |
||
2281 | pop esi |
||
2282 | pop ebp |
||
2283 | xor eax, eax |
||
2284 | ret 10h |
||
2285 | .onbutton: |
||
2286 | or [ebp+tls.current_buttons], al |
||
2287 | cmp [ebp+tls.original_buttons], 0 |
||
2288 | jnz @f |
||
2289 | mov [ebp+tls.original_buttons], al |
||
2290 | @@: |
||
2291 | mov [ebp+tls.active_button], esi |
||
2292 | ; don't highlight button if bit 29 is set |
||
2293 | test [esi+button_desc.id], 20000000h |
||
2294 | jnz .done |
||
2295 | ; highlight - negate border |
||
2296 | call negate_button_border |
||
2297 | jmp .done |
||
2298 | wmrbuttonup: |
||
2299 | push -3 |
||
2300 | jmp @f |
||
2301 | wmlbuttonup: |
||
2302 | push -2 |
||
2303 | @@: |
||
2304 | call capture2 |
||
2305 | pop eax |
||
2306 | cmp [ebp+tls.active_button], 0 |
||
2307 | jz wmrbuttondown.nobutton |
||
2308 | and [ebp+tls.current_buttons], al |
||
2309 | jnz wmrbuttondown.nobutton |
||
2310 | push esi |
||
2311 | xor esi, esi |
||
2312 | xchg esi, [ebp+tls.active_button] |
||
2313 | test byte [esi+button_desc.id+3], 20h |
||
2314 | jnz @f |
||
2315 | call negate_button_border |
||
2316 | @@: |
||
2317 | ; minimize button - special handler (see event.inc) |
||
2318 | cmp word [esi+button_desc.id], 0FFFFh |
||
2319 | jz .minimize |
||
2320 | test [ebp+tls.message_mask], 4 |
||
2321 | jz @f |
||
2322 | mov [ebp+tls.translated_msg_code], 3 |
||
2323 | @@: |
||
2324 | test [ebp+tls.message_mask], 20h |
||
2325 | jz @f |
||
2326 | mov [ebp+tls.translated_msg_code], 86h |
||
2327 | @@: |
||
2328 | mov [ebp+tls.bFirstMouseMove], 1 |
||
2329 | movzx ecx, [ebp+tls.butbuflen] |
||
2330 | inc cl |
||
2331 | jz @f |
||
2332 | mov [ebp+tls.butbuflen], cl |
||
2333 | mov eax, [esi+button_desc.id] |
||
2334 | shl eax, 8 |
||
2335 | mov al, [ebp+tls.original_buttons] |
||
2336 | mov [ebp+tls.butbuffer+ecx*4-4], eax |
||
2337 | @@: |
||
2338 | mov [ebp+tls.original_buttons], 0 |
||
2339 | .done: |
||
2340 | pop esi |
||
2341 | .ret: |
||
2342 | xor eax, eax |
||
2343 | pop ebp |
||
2344 | ret 10h |
||
2345 | .minimize: |
||
2346 | call minimize_window |
||
2347 | jmp .done |
||
2348 | wmrbuttondown.nobutton: |
||
2349 | wmmousemove: |
||
2350 | cmp [ebp+tls.bFirstMouseMove], 0 |
||
2351 | mov [ebp+tls.bFirstMouseMove], 0 |
||
2352 | jnz wmdef |
||
2353 | vk_mouse: |
||
2354 | ; N.B. Due of current implementation of buttons in the kernel |
||
2355 | ; mouse events are NOT processed when any button is active! |
||
2356 | cmp [ebp+tls.active_button], 0 |
||
2357 | jnz wmlbuttonup.ret |
||
2358 | test [ebp+tls.message_mask], 20h |
||
2359 | jz wmlbuttonup.ret |
||
2360 | mov [ebp+tls.translated_msg_code], 6 |
||
2361 | jmp wmlbuttonup.ret |
||
2362 | wmmousewheel: |
||
2363 | movsx eax, word [esp+0xE+4] |
||
2364 | sub [ebp+tls.scroll], eax |
||
2365 | jmp vk_mouse |
||
2366 | wm_ipc: |
||
2367 | test [ebp+tls.message_mask], 40h |
||
2368 | jz wmlbuttonup.ret |
||
2369 | mov [ebp+tls.translated_msg_code], 7 |
||
2370 | jmp wmlbuttonup.ret |
||
2371 | wm_debug1: |
||
2372 | test byte [ebp+tls.message_mask+1], 1 |
||
2373 | jz .failed2 |
||
2374 | push edi |
||
2375 | call get_cur_slot_ptr |
||
2376 | mov edi, [edi+shared_data_struc.debugger_mem-shared_data_struc.threads] |
||
2377 | test edi, edi |
||
2378 | jz .failed |
||
2379 | add edi, [base] |
||
2380 | mov eax, [edi] |
||
2381 | mov ecx, [edi+4] |
||
2382 | sub eax, ecx |
||
2383 | cmp eax, 12 |
||
2384 | jl .failed |
||
2385 | add dword [edi+4], 12 |
||
2386 | lea edi, [edi+ecx+8] |
||
2387 | xor eax, eax |
||
2388 | inc eax |
||
2389 | stosd |
||
2390 | push edi |
||
2391 | mov eax, [esp+0xC+12] |
||
2392 | call get_slot_ptr |
||
2393 | mov eax, [edi] |
||
2394 | pop edi |
||
2395 | stosd |
||
2396 | mov eax, [esp+0x10+8] |
||
2397 | ; translate Win32 exception code to x86 exception vector |
||
2398 | cmp eax, 0x80000004 |
||
2399 | jz .singlestep |
||
2400 | xor ecx, ecx |
||
2401 | push edi |
||
2402 | mov edi, exccode2number-5 |
||
2403 | .1: |
||
2404 | add edi, 5 |
||
2405 | cmp eax, [edi] |
||
2406 | jnz .2 |
||
2407 | mov cl, [edi+4] |
||
2408 | jmp .3 |
||
2409 | .2: |
||
2410 | cmp dword [edi], ecx |
||
2411 | jnz .1 |
||
2412 | mov cl, 0xD ; translate unrecognized codes to #GP |
||
2413 | .3: |
||
2414 | pop edi |
||
2415 | jmp .4 |
||
2416 | .singlestep: |
||
2417 | push ebx |
||
2418 | mov ecx, [edi-4] |
||
2419 | call find_debuggee |
||
2420 | mov ecx, ebx |
||
2421 | pop ebx |
||
2422 | jecxz .failed |
||
2423 | sub esp, 0xB2*4 |
||
2424 | push 1001Fh |
||
2425 | push esp |
||
2426 | push dword [ecx+12] |
||
2427 | call [GetThreadContext] |
||
2428 | mov ecx, [esp+0x14] ; DR6 |
||
2429 | mov byte [edi-8], 3 ; signal #DB |
||
2430 | add esp, 0xB3*4 |
||
2431 | .4: |
||
2432 | mov [edi], ecx |
||
2433 | .written: |
||
2434 | pop edi |
||
2435 | mov [ebp+tls.translated_msg_code], 9 |
||
2436 | jmp wmlbuttonup.ret |
||
2437 | .failed: |
||
2438 | pop edi |
||
2439 | .failed2: |
||
2440 | push 40h |
||
2441 | push 0 |
||
2442 | push aFailedToDeliverDebugMessage |
||
2443 | push [ebp+tls.hWnd] |
||
2444 | call [MessageBoxA] |
||
2445 | jmp wmlbuttonup.ret |
||
2446 | wm_debug2: |
||
2447 | test byte [ebp+tls.message_mask+1], 1 |
||
2448 | jz wm_debug1.failed2 |
||
2449 | push edi |
||
2450 | call get_cur_slot_ptr |
||
2451 | mov edi, [edi+shared_data_struc.debugger_mem-shared_data_struc.threads] |
||
2452 | test edi, edi |
||
2453 | jz wm_debug1.failed |
||
2454 | add edi, [base] |
||
2455 | mov eax, [edi] |
||
2456 | mov ecx, [edi+4] |
||
2457 | sub eax, ecx |
||
2458 | cmp eax, 8 |
||
2459 | jl wm_debug1.failed |
||
2460 | add dword [edi+4], 8 |
||
2461 | lea edi, [edi+ecx+8] |
||
2462 | push 2 |
||
2463 | pop eax |
||
2464 | stosd |
||
2465 | push edi |
||
2466 | mov eax, [esp+0xC+12] |
||
2467 | call get_slot_ptr |
||
2468 | mov eax, [edi] |
||
2469 | pop edi |
||
2470 | stosd |
||
2471 | ; delete this item from debuggees list |
||
2472 | lea ecx, [ebp+tls.debuggees] |
||
2473 | @@: |
||
2474 | mov edx, [ecx] |
||
2475 | test edx, edx |
||
2476 | jz wm_debug1.written |
||
2477 | cmp dword [edx+4], eax |
||
2478 | jz .found |
||
2479 | mov ecx, edx |
||
2480 | jmp @b |
||
2481 | .found: |
||
2482 | push dword [edx] |
||
2483 | push ecx |
||
2484 | push edx |
||
2485 | call free |
||
2486 | pop ecx |
||
2487 | pop dword [ecx] |
||
2488 | jmp wm_debug1.written |
||
2489 | |||
2490 | wmgetminmaxinfo: |
||
2491 | mov ecx, [shared_data] |
||
2492 | cmp [ecx+shared_data_struc.vk], 0 |
||
2493 | jnz @f |
||
2494 | sub esp, 10h |
||
2495 | mov eax, esp |
||
2496 | push 0 |
||
2497 | push eax |
||
2498 | push 0 |
||
2499 | push 30h ; SPI_GETWORKAREA |
||
2500 | call [SystemParametersInfoA] |
||
2501 | mov eax, [esp+20+10h] ; lParam |
||
2502 | mov ecx, esp |
||
2503 | mov edx, [ecx] |
||
2504 | mov [eax+10h], edx |
||
2505 | mov edx, [ecx+4] |
||
2506 | mov [eax+14h], edx |
||
2507 | mov edx, [ecx+8] |
||
2508 | sub edx, [ecx] |
||
2509 | mov [eax+8], edx |
||
2510 | mov edx, [ecx+12] |
||
2511 | sub edx, [ecx+4] |
||
2512 | mov [eax+0Ch], edx |
||
2513 | add esp, 10h |
||
2514 | jmp .ret |
||
2515 | @@: |
||
2516 | call acquire_shared |
||
2517 | mov eax, [esp+20] ; lParam |
||
2518 | mov edx, [ecx+shared_data_struc.workarea_left] |
||
2519 | mov [eax+10h], edx |
||
2520 | mov edx, [ecx+shared_data_struc.workarea_top] |
||
2521 | mov [eax+14h], edx |
||
2522 | mov edx, [ecx+shared_data_struc.workarea_right] |
||
2523 | sub edx, [ecx+shared_data_struc.workarea_left] |
||
2524 | mov [eax+8], edx |
||
2525 | mov edx, [ecx+shared_data_struc.workarea_bottom] |
||
2526 | sub edx, [ecx+shared_data_struc.workarea_top] |
||
2527 | mov [eax+0Ch], edx |
||
2528 | call release_shared |
||
2529 | .ret: |
||
2530 | xor eax, eax |
||
2531 | pop ebp |
||
2532 | ret 10h |
||
2533 | |||
2534 | find_button: |
||
2535 | mov esi, [ebp+tls.buttons] |
||
2536 | .loop: |
||
2537 | test esi, esi |
||
2538 | jz .done |
||
2539 | push eax |
||
2540 | sub ax, [esi+button_desc.xstart] |
||
2541 | cmp ax, [esi+button_desc.xsize] |
||
2542 | pop eax |
||
2543 | jae .cont |
||
2544 | push edx |
||
2545 | sub dx, [esi+button_desc.ystart] |
||
2546 | cmp dx, [esi+button_desc.ysize] |
||
2547 | pop edx |
||
2548 | jb .done |
||
2549 | .cont: |
||
2550 | mov esi, [esi] |
||
2551 | jmp .loop |
||
2552 | .done: |
||
2553 | ret |
||
2554 | |||
2555 | negate_button_border: |
||
2556 | push edi |
||
2557 | push [ebp+tls.hWnd] |
||
2558 | call [GetDC] |
||
2559 | xchg eax, edi |
||
2560 | push 6 ; R2_NOT |
||
2561 | push edi |
||
2562 | call [SetROP2] |
||
2563 | push eax |
||
2564 | movzx eax, [esi+button_desc.xstart] |
||
2565 | movzx edx, [esi+button_desc.ystart] |
||
2566 | ; point 4 |
||
2567 | push edx |
||
2568 | push eax |
||
2569 | ; point 3 |
||
2570 | mov ecx, edx |
||
2571 | add cx, [esi+button_desc.ysize] |
||
2572 | push ecx |
||
2573 | push eax |
||
2574 | ; point 2 |
||
2575 | push ecx |
||
2576 | mov ecx, eax |
||
2577 | add cx, [esi+button_desc.xsize] |
||
2578 | push ecx |
||
2579 | ; point 1 |
||
2580 | push edx |
||
2581 | push ecx |
||
2582 | ; point 0 |
||
2583 | push edx |
||
2584 | push eax |
||
2585 | ; Polyline |
||
2586 | mov eax, esp |
||
2587 | push 5 |
||
2588 | push eax |
||
2589 | push edi |
||
2590 | call [Polyline] |
||
2591 | add esp, 5*8 |
||
2592 | push edi |
||
2593 | call [SetROP2] |
||
2594 | push edi |
||
2595 | push [ebp+tls.hWnd] |
||
2596 | call [ReleaseDC] |
||
2597 | pop edi |
||
2598 | ret |
||
2599 | |||
2600 | draw_border: |
||
2601 | mov eax, [ebp+tls.color_border] |
||
2602 | shr eax, 1 |
||
2603 | and eax, 0x007F7F7F |
||
2604 | cmp byte [esp+4], 0 |
||
2605 | jz @f |
||
2606 | mov eax, [skin_active_outer] |
||
2607 | cmp [ebp+tls.bActive], 0 |
||
2608 | jnz @f |
||
2609 | mov eax, [skin_passive_outer] |
||
2610 | @@: |
||
2611 | call create_select_pen |
||
2612 | push eax |
||
2613 | xor esi, esi |
||
2614 | call rect_wnd |
||
2615 | call select_delete |
||
2616 | mov eax, [ebp+tls.color_border] |
||
2617 | cmp byte [esp+4], 0 |
||
2618 | jz @f |
||
2619 | mov eax, [skin_active_frame] |
||
2620 | cmp [ebp+tls.bActive], 0 |
||
2621 | jnz @f |
||
2622 | mov eax, [skin_passive_frame] |
||
2623 | @@: |
||
2624 | call create_select_pen |
||
2625 | push eax |
||
2626 | @@: |
||
2627 | inc esi |
||
2628 | call rect_wnd |
||
2629 | cmp esi, 3 |
||
2630 | jnz @b |
||
2631 | call select_delete |
||
2632 | mov eax, [ebp+tls.color_border] |
||
2633 | shr eax, 1 |
||
2634 | and eax, 0x007F7F7F |
||
2635 | cmp byte [esp+4], 0 |
||
2636 | jz @f |
||
2637 | mov eax, [skin_active_inner] |
||
2638 | cmp [ebp+tls.bActive], 0 |
||
2639 | jnz @f |
||
2640 | mov eax, [skin_passive_inner] |
||
2641 | @@: |
||
2642 | call create_select_pen |
||
2643 | push eax |
||
2644 | inc esi |
||
2645 | call rect_wnd |
||
2646 | call select_delete |
||
2647 | ret 4 |
||
2648 | |||
2649 | rect_wnd: |
||
2650 | movzx ecx, [ebp+tls.y_size] |
||
2651 | dec ecx |
||
2652 | sub ecx, esi |
||
2653 | movzx edx, [ebp+tls.x_size] |
||
2654 | dec edx |
||
2655 | sub edx, esi |
||
2656 | ; point 5 |
||
2657 | push esi |
||
2658 | push esi |
||
2659 | ; point 4 |
||
2660 | push esi |
||
2661 | push edx |
||
2662 | ; point 3 |
||
2663 | push ecx |
||
2664 | push edx |
||
2665 | ; point 2 |
||
2666 | push ecx |
||
2667 | push esi |
||
2668 | ; point 1 |
||
2669 | push esi |
||
2670 | push esi |
||
2671 | mov eax, esp |
||
2672 | push 5 |
||
2673 | push eax |
||
2674 | push edi |
||
2675 | call [Polyline] |
||
2676 | add esp, 40 |
||
2677 | ret |
||
2678 | |||
2679 | rectangle_gradient: |
||
2680 | ; in: edi=hDC |
||
2681 | ; stack: |
||
2682 | ; [esp+4] = xstart |
||
2683 | ; [esp+8] = ystart |
||
2684 | ; [esp+12] = xend |
||
2685 | ; [esp+16] = yend (end is excluded) |
||
2686 | ; [esp+20] = color |
||
2687 | ; [esp+24] = color_delta (if gradient specified) |
||
2688 | test byte [esp+20+3], 80h |
||
2689 | jnz .dograd |
||
2690 | ; no gradient |
||
2691 | mov eax, [esp+20] |
||
2692 | call convert_color |
||
2693 | push eax |
||
2694 | call [CreateSolidBrush] |
||
2695 | push eax |
||
2696 | push dword [esp+4+16] |
||
2697 | push dword [esp+8+12] |
||
2698 | push dword [esp+12+8] |
||
2699 | push dword [esp+16+4] |
||
2700 | mov ecx, esp |
||
2701 | push eax |
||
2702 | push ecx |
||
2703 | push edi |
||
2704 | call [FillRect] |
||
2705 | add esp, 10h |
||
2706 | call [DeleteObject] |
||
2707 | .done: |
||
2708 | ret 24 |
||
2709 | .dograd: |
||
2710 | ; gradient |
||
2711 | mov esi, [esp+8] |
||
2712 | .gradloop: |
||
2713 | cmp esi, [esp+16] |
||
2714 | jae .done |
||
2715 | mov eax, [esp+20] |
||
2716 | call create_select_pen |
||
2717 | push eax |
||
2718 | push 0 |
||
2719 | push esi |
||
2720 | push dword [esp+12+4] |
||
2721 | push edi |
||
2722 | call [MoveToEx] |
||
2723 | push esi |
||
2724 | push dword [esp+8+12] |
||
2725 | push edi |
||
2726 | call [LineTo] |
||
2727 | call select_delete |
||
2728 | inc esi |
||
2729 | ; mov eax, [esp+24] |
||
2730 | ; sub [esp+20], eax |
||
2731 | test byte [esp+27], 80h |
||
2732 | jnz .signed |
||
2733 | mov al, [esp+24] |
||
2734 | sub [esp+20], al |
||
2735 | jnb @f |
||
2736 | add [esp+20], al |
||
2737 | @@: mov al, [esp+25] |
||
2738 | sub [esp+21], al |
||
2739 | jnb @f |
||
2740 | add [esp+21], al |
||
2741 | @@: mov al, [esp+26] |
||
2742 | sub [esp+22], al |
||
2743 | jnb @f |
||
2744 | add [esp+22], al |
||
2745 | @@: jmp .gradloop |
||
2746 | .signed: |
||
2747 | mov al, [esp+24] |
||
2748 | add [esp+20], al |
||
2749 | jnb @f |
||
2750 | sub [esp+20], al |
||
2751 | @@: mov al, [esp+25] |
||
2752 | add [esp+21], al |
||
2753 | jnb @f |
||
2754 | sub [esp+21], al |
||
2755 | @@: mov al, [esp+26] |
||
2756 | add [esp+22], al |
||
2757 | jnb @f |
||
2758 | sub [esp+22], al |
||
2759 | @@: jmp .gradloop |
||
2760 | |||
2761 | create_select_pen: |
||
2762 | call convert_color |
||
2763 | push eax |
||
2764 | push 1 |
||
2765 | push 0 |
||
2766 | call [CreatePen] |
||
2767 | push eax |
||
2768 | push edi |
||
2769 | call [SelectObject] |
||
2770 | ret |
||
2771 | select_delete: |
||
2772 | push dword [esp+4] |
||
2773 | push edi |
||
2774 | call [SelectObject] |
||
2775 | push eax |
||
2776 | call [DeleteObject] |
||
2777 | ret 4 |
||
2778 | |||
2779 | malloc: |
||
2780 | push dword [esp+4] |
||
2781 | push 0 |
||
2782 | push [hHeap] |
||
2783 | call [HeapAlloc] |
||
2784 | ret 4 |
||
2785 | free: |
||
2786 | push dword [esp+4] |
||
2787 | push 0 |
||
2788 | push [hHeap] |
||
2789 | call [HeapFree] |
||
2790 | ret 4 |
||
2791 | malloc_big: |
||
2792 | push 4 ; PAGE_READWRITE |
||
2793 | push 1000h ; MEM_COMMIT |
||
2794 | push eax |
||
2795 | push 0 |
||
2796 | call [VirtualAlloc] |
||
2797 | ret |
||
2798 | free_big: |
||
2799 | push 8000h ; MEM_RELEASE |
||
2800 | push 0 |
||
2801 | push dword [esp+12] |
||
2802 | call [VirtualFree] |
||
2803 | ret 4 |
||
2804 | |||
2805 | capture1: |
||
2806 | inc [bCaptured] |
||
2807 | cmp [bCaptured], 1 |
||
2808 | jnz @f |
||
2809 | push [ebp+tls.hWnd] |
||
2810 | call [SetCapture] |
||
2811 | @@: ret |
||
2812 | capture2: |
||
2813 | cmp [bCaptured], 0 |
||
2814 | jz @f |
||
2815 | dec [bCaptured] |
||
2816 | jnz @f |
||
2817 | call [ReleaseCapture] |
||
2818 | @@: ret |
||
2819 | |||
2820 | server_fail: |
||
2821 | push 10h |
||
2822 | push 0 |
||
2823 | push esi |
||
2824 | push 0 |
||
2825 | call init_MessageBox |
||
2826 | call [MessageBoxA] |
||
2827 | push 0 |
||
2828 | call [ExitProcess] |
||
2829 | |||
2830 | server_exists: |
||
2831 | mov esi, vkerr |
||
2832 | cmp [vk], 0 |
||
2833 | jnz server_fail |
||
2834 | mov al, 1 |
||
2835 | mov edx, [newprg_section] |
||
2836 | lock xchg [edx], al |
||
2837 | test al, al |
||
2838 | jz @f |
||
2839 | push edx |
||
2840 | push 200 |
||
2841 | call [Sleep] |
||
2842 | pop edx |
||
2843 | dec edi |
||
2844 | jnz server_exists |
||
2845 | @@: |
||
2846 | mov esi, inname |
||
2847 | lea edi, [edx+8] |
||
2848 | mov ecx, 108h/4 |
||
2849 | rep movsd |
||
2850 | mov esi, [parameters] |
||
2851 | test esi, esi |
||
2852 | jnz @f |
||
2853 | mov esi, converted_path |
||
2854 | @@: mov ecx, 100h/4 |
||
2855 | rep movsd |
||
2856 | mov byte [edx+1], 1 |
||
2857 | mov esi, edx |
||
2858 | push 50 |
||
2859 | pop edi |
||
2860 | @@: |
||
2861 | push 200 |
||
2862 | call [Sleep] |
||
2863 | cmp byte [esi+1], 3 |
||
2864 | jz @f |
||
2865 | dec edi |
||
2866 | jnz @b |
||
2867 | push ebx |
||
2868 | call [ExitProcess] |
||
2869 | @@: |
||
2870 | push esi |
||
2871 | push user32_thunks |
||
2872 | push user32_name |
||
2873 | call init_dll |
||
2874 | pop esi |
||
2875 | push dword [esi+2] |
||
2876 | call [SetForegroundWindow] |
||
2877 | mov word [esi], bx |
||
2878 | push ebx |
||
2879 | call [ExitProcess] |
||
2880 | |||
2881 | newprg_request: |
||
2882 | lea edi, [eax+8] |
||
2883 | lea esi, [eax+110h] |
||
2884 | call acquire_shared |
||
2885 | call new_kolibri_process_with_default_curdir |
||
2886 | call release_shared |
||
2887 | mov eax, [newprg_section] |
||
2888 | mov byte [eax+1], 2 |
||
2889 | jmp debugloop |
||
2890 | |||
2891 | server: |
||
2892 | push edi |
||
2893 | call free_big |
||
2894 | sub esp, 44h |
||
2895 | push esp |
||
2896 | call [GetStartupInfoA] |
||
2897 | mov eax, [esp+8] |
||
2898 | test eax, eax |
||
2899 | jz @f |
||
2900 | cmp dword [eax], 'Koli' |
||
2901 | jnz @f |
||
2902 | cmp dword [eax+4], 'briD' |
||
2903 | jnz @f |
||
2904 | mov [vk], 1 |
||
2905 | @@: |
||
2906 | push newprg_section_name |
||
2907 | push 1000h |
||
2908 | push ebx |
||
2909 | push 4 |
||
2910 | push ebx |
||
2911 | push -1 |
||
2912 | call [CreateFileMappingA] |
||
2913 | mov esi, shared_section_create_err |
||
2914 | test eax, eax |
||
2915 | jz server_fail |
||
2916 | xchg eax, edi |
||
2917 | call [GetLastError] |
||
2918 | push eax |
||
2919 | push ebx |
||
2920 | push ebx |
||
2921 | push ebx |
||
2922 | push 2 |
||
2923 | push edi |
||
2924 | call [MapViewOfFile] |
||
2925 | mov [newprg_section], eax |
||
2926 | test eax, eax |
||
2927 | jz server_fail |
||
2928 | ; push edi |
||
2929 | ; call [CloseHandle] |
||
2930 | pop eax |
||
2931 | cmp eax, 183 |
||
2932 | jz server_exists |
||
2933 | mov ecx, [esp+2Ch] |
||
2934 | add esp, 44h |
||
2935 | test cl, cl |
||
2936 | js @f |
||
2937 | cmp [vk], 0 |
||
2938 | jnz @f |
||
2939 | ; We were created without STARTF_FORCEOFFFEEDBACK flag. |
||
2940 | ; Rerun self. This has two goals: first, this avoids "hour glass" cursor, |
||
2941 | ; second, if GetOpenFileNameA was used, it didn't cleanup all resources, |
||
2942 | ; but new process will run in clean environment. |
||
2943 | push [newprg_section] |
||
2944 | call [UnmapViewOfFile] |
||
2945 | push edi |
||
2946 | call [CloseHandle] |
||
2947 | mov [bDontDebug], 1 |
||
2948 | call create_child |
||
2949 | push ebx |
||
2950 | call [ExitProcess] |
||
2951 | @@: |
||
2952 | if 0 |
||
2953 | push ebx |
||
2954 | push ebx |
||
2955 | push ebx |
||
2956 | call [GetCurrentThreadId] |
||
2957 | push eax |
||
2958 | call [PostThreadMessageA] |
||
2959 | sub esp, 40h |
||
2960 | mov eax, esp |
||
2961 | push ebx |
||
2962 | push ebx |
||
2963 | push ebx |
||
2964 | push eax |
||
2965 | call [GetMessageA] |
||
2966 | add esp, 40h |
||
2967 | end if |
||
2968 | ; create shared data |
||
2969 | push ebx |
||
2970 | push shared_section_size |
||
2971 | push ebx |
||
2972 | push 4 |
||
2973 | push ebx |
||
2974 | push -1 |
||
2975 | call [CreateFileMappingA] |
||
2976 | test eax, eax |
||
2977 | jz server_fail |
||
2978 | mov [hSharedData], eax |
||
2979 | push ebx |
||
2980 | push ebx |
||
2981 | push ebx |
||
2982 | call [CreateMutexA] |
||
2983 | mov esi, shared_mutex_create_err |
||
2984 | test eax, eax |
||
2985 | jz server_fail |
||
2986 | mov [hSharedMutex], eax |
||
2987 | call map_shared_data |
||
2988 | xor ecx, ecx |
||
2989 | inc ecx |
||
2990 | mov dword [eax], ecx ; 1 process (OS/IDLE) |
||
2991 | mov dword [eax+4], ecx ; 1 process |
||
2992 | mov [eax+shared_data_struc.active_process], ecx |
||
2993 | mov [eax+shared_data_struc.thread_id], ecx ; PID=1 |
||
2994 | mov [eax+shared_data_struc.sound_dma], ecx |
||
2995 | mov [eax+shared_data_struc.fat32part], ecx |
||
2996 | mov [eax+shared_data_struc.hd_base], cl |
||
2997 | mov [eax+shared_data_struc.mouse_delay], 10 |
||
2998 | mov [eax+shared_data_struc.mouse_speed_factor], 3 |
||
2999 | xchg eax, esi |
||
3000 | mov al, [vk] |
||
3001 | or [esi+shared_data_struc.vk], al |
||
3002 | mov [esi+shared_data_struc.pci_data_init], bl |
||
3003 | ; read ini file server settings |
||
3004 | mov edi, aSetup |
||
3005 | push win32_path |
||
3006 | push ebx |
||
3007 | push aSoundFlag |
||
3008 | push edi |
||
3009 | call [GetPrivateProfileIntA] |
||
3010 | mov [esi+shared_data_struc.sound_flag], al |
||
3011 | push win32_path |
||
3012 | push 1 |
||
3013 | push aSysLang |
||
3014 | push edi |
||
3015 | call [GetPrivateProfileIntA] |
||
3016 | mov [esi+shared_data_struc.syslang], eax |
||
3017 | push win32_path |
||
3018 | push 1 |
||
3019 | push aKeyboard |
||
3020 | push edi |
||
3021 | call [GetPrivateProfileIntA] |
||
3022 | mov [esi+shared_data_struc.keyboard], ax |
||
3023 | mov ebp, esi |
||
3024 | mov ecx, 1028 |
||
3025 | sub esp, ecx |
||
3026 | mov esi, esp |
||
3027 | mov edi, aMain |
||
3028 | push win32_path |
||
3029 | push ecx |
||
3030 | push esi |
||
3031 | push null_string |
||
3032 | push aAllowReadMSR |
||
3033 | push edi |
||
3034 | call [GetPrivateProfileStringA] |
||
3035 | cmp byte [esi], 't' |
||
3036 | setz [ebp+shared_data_struc.bAllowReadMSR] |
||
3037 | push win32_path |
||
3038 | push 1028 |
||
3039 | push esi |
||
3040 | push null_string |
||
3041 | push aAllowReadPCI |
||
3042 | push edi |
||
3043 | call [GetPrivateProfileStringA] |
||
3044 | cmp byte [esi], 't' |
||
3045 | setz [ebp+shared_data_struc.bAllowReadPCI] |
||
3046 | setz byte [ebp+shared_data_struc.pci_access_enabled] |
||
3047 | push win32_path |
||
3048 | push 1028 |
||
3049 | push esi |
||
3050 | push null_string |
||
3051 | push aKeepLoadedDriver |
||
3052 | push edi |
||
3053 | call [GetPrivateProfileStringA] |
||
3054 | cmp byte [esi], 't' |
||
3055 | setz [keep_loaded_driver] |
||
3056 | push win32_path |
||
3057 | push 1028 |
||
3058 | push esi |
||
3059 | push null_string |
||
3060 | push aEnablePorts |
||
3061 | push edi |
||
3062 | call [GetPrivateProfileStringA] |
||
3063 | ; parse EnablePorts parameter |
||
3064 | or eax, -1 |
||
3065 | lea edi, [ebp+shared_data_struc.DisabledPorts] |
||
3066 | mov ecx, 1000h |
||
3067 | rep stosd |
||
3068 | ParseEnablePorts: |
||
3069 | lodsb |
||
3070 | test al, al |
||
3071 | jz .done |
||
3072 | cmp al, 0x20 |
||
3073 | jbe ParseEnablePorts |
||
3074 | call read_hex |
||
3075 | cmp al, '-' |
||
3076 | jz .minus |
||
3077 | mov edx, ecx |
||
3078 | shr ecx, 3 |
||
3079 | and edx, 7 |
||
3080 | btr dword [ebp+shared_data_struc.DisabledPorts+ecx], edx |
||
3081 | .x1: test al, al |
||
3082 | jz .done |
||
3083 | cmp al, 0x20 |
||
3084 | jbe ParseEnablePorts |
||
3085 | .err: |
||
3086 | mov esi, EnablePortsSyntaxErr |
||
3087 | jmp server_fail |
||
3088 | .minus: |
||
3089 | push ecx |
||
3090 | lodsb |
||
3091 | call read_hex |
||
3092 | cmp ecx, [esp] |
||
3093 | jb .err |
||
3094 | push eax |
||
3095 | @@: |
||
3096 | mov eax, ecx |
||
3097 | shr ecx, 3 |
||
3098 | mov edx, eax |
||
3099 | and edx, 7 |
||
3100 | btr dword [ebp+shared_data_struc.DisabledPorts+ecx], edx |
||
3101 | test eax, eax |
||
3102 | jz @f |
||
3103 | lea ecx, [eax-1] |
||
3104 | cmp ecx, [esp+4] |
||
3105 | jae @b |
||
3106 | @@: |
||
3107 | pop eax |
||
3108 | pop ecx |
||
3109 | jmp .x1 |
||
3110 | .done: |
||
3111 | add esp, 1028 |
||
3112 | xor eax, eax |
||
3113 | cmp [bIs9x], al |
||
3114 | jnz .skipload |
||
3115 | cmp [ebp+shared_data_struc.bAllowReadMSR], bl |
||
3116 | jnz .load |
||
3117 | cmp [ebp+shared_data_struc.bAllowReadPCI], bl |
||
3118 | jnz .load |
||
3119 | mov ecx, 2000h |
||
3120 | lea edi, [ebp+shared_data_struc.DisabledPorts] |
||
3121 | mov al, -1 |
||
3122 | repz scasb |
||
3123 | jz .skipload |
||
3124 | .load: |
||
3125 | ; load driver kiw0.sys |
||
3126 | ; note that this must execute after all work with ini-file |
||
3127 | ; because win32_path is overwritten |
||
3128 | call load_kiw0 |
||
3129 | .skipload: |
||
3130 | call create_child |
||
3131 | debugloop: |
||
3132 | mov eax, [newprg_section] |
||
3133 | cmp byte [eax+1], 1 |
||
3134 | jz newprg_request |
||
3135 | push 500 ; wait a half of second |
||
3136 | push debugevent |
||
3137 | call [WaitForDebugEvent] |
||
3138 | test eax, eax |
||
3139 | jz debugloop |
||
3140 | ; get hProcess |
||
3141 | mov eax, [debugevent+4] |
||
3142 | mov ecx, [pids] |
||
3143 | @@: cmp [ecx+4], eax |
||
3144 | jz @f |
||
3145 | mov ecx, [ecx] |
||
3146 | jmp @b |
||
3147 | @@: mov eax, [ecx+8] |
||
3148 | mov [hProcess], eax |
||
3149 | ; parse debug event |
||
3150 | mov eax, [debugevent] ; dwDebugEventCode |
||
3151 | dec eax ; EXCEPTION_DEBUG_EVENT = 1 |
||
3152 | jz exceptionevent |
||
3153 | dec eax ; CREATE_THREAD_DEBUG_EVENT = 2 |
||
3154 | jz threadcreated |
||
3155 | dec eax ; CREATE_PROCESS_DEBUG_EVENT = 3 |
||
3156 | jz processcreated |
||
3157 | dec eax ; EXIT_THREAD_DEBUG_EVENT = 4 |
||
3158 | jz threadexited |
||
3159 | dec eax ; EXIT_PROCESS_DEBUG_EVENT = 5 |
||
3160 | jz exited |
||
3161 | debugcont: |
||
3162 | push 10002h ; DBG_CONTINUE |
||
3163 | dodebugcont: |
||
3164 | push [debugevent+8] |
||
3165 | push [debugevent+4] |
||
3166 | call [ContinueDebugEvent] |
||
3167 | jmp debugloop |
||
3168 | exited: |
||
3169 | ; delete Win32 pid and tid |
||
3170 | mov eax, [debugevent+4] |
||
3171 | mov ecx, pids |
||
3172 | call delete_id |
||
3173 | call find_tid |
||
3174 | jecxz @f |
||
3175 | call on_thread_exited |
||
3176 | mov eax, [debugevent+8] |
||
3177 | mov ecx, tids |
||
3178 | call delete_id |
||
3179 | @@: |
||
3180 | ; if all processes are done, exit |
||
3181 | dec [num_kolibri_proc] |
||
3182 | jnz debugcont |
||
3183 | jmp server_done |
||
3184 | threadcreated: |
||
3185 | mov eax, [debugevent+12] |
||
3186 | mov [hThread], eax |
||
3187 | mov eax, [debugevent+8] |
||
3188 | mov [dwThreadId], eax |
||
3189 | call alloc_thread |
||
3190 | mov eax, [debugevent+16] |
||
3191 | mov ecx, [cur_tid_ptr] |
||
3192 | mov [ecx+16], eax |
||
3193 | mov [ecx+20], ebx |
||
3194 | jmp debugcont |
||
3195 | processcreated: |
||
3196 | call find_tid |
||
3197 | test ecx, ecx |
||
3198 | jz debugcont |
||
3199 | push [debugevent+12] |
||
3200 | call [CloseHandle] |
||
3201 | mov eax, [debugevent+24h] |
||
3202 | mov ecx, [cur_tid_ptr] |
||
3203 | mov [ecx+16], eax |
||
3204 | jmp debugcont |
||
3205 | threadexited: |
||
3206 | call find_tid |
||
3207 | test ecx, ecx |
||
3208 | jz debugcont |
||
3209 | cmp [cur_slot], -1 |
||
3210 | jz @f |
||
3211 | call on_thread_exited |
||
3212 | @@: |
||
3213 | mov eax, [debugevent+8] |
||
3214 | mov ecx, tids |
||
3215 | call delete_id |
||
3216 | jmp debugcont |
||
3217 | exceptionevent: |
||
3218 | call find_tid |
||
3219 | test eax, eax |
||
3220 | jz debugcont |
||
3221 | ; special handling of #PF exceptions in shared memory areas |
||
3222 | cmp [debugevent+12], 0xC0000005 |
||
3223 | jnz .nopf |
||
3224 | mov ecx, [debugevent+36] |
||
3225 | call get_cur_slot_ptr_server |
||
3226 | mov edi, [edi+shared_data_struc.shmem_list-shared_data_struc.threads] |
||
3227 | .scanaddr: |
||
3228 | test edi, edi |
||
3229 | jz .nopf |
||
3230 | cmp ecx, [edi+shmem_proc_descr.ptr] |
||
3231 | jb @f |
||
3232 | cmp ecx, [edi+shmem_proc_descr.end] |
||
3233 | jb .pfshared |
||
3234 | @@: |
||
3235 | mov edi, [edi+shmem_proc_descr.next] |
||
3236 | jmp .scanaddr |
||
3237 | .pfshared: |
||
3238 | ; this is really exception in shared area |
||
3239 | mov esi, [edi+shmem_proc_descr.item] |
||
3240 | mov eax, [esi+shmem_item.pOwner] |
||
3241 | cmp eax, ebx |
||
3242 | jz .pfsh_noowner |
||
3243 | call shmem_load |
||
3244 | .pfsh_noowner: |
||
3245 | mov edx, [edi+shmem_proc_descr.end] |
||
3246 | mov ecx, [edi+shmem_proc_descr.ptr] |
||
3247 | sub edx, ecx |
||
3248 | push ecx edx |
||
3249 | push eax |
||
3250 | push esp |
||
3251 | push 4 ; PAGE_READWRITE |
||
3252 | push edx |
||
3253 | push ecx |
||
3254 | push [hProcess] |
||
3255 | call [VirtualProtectEx] |
||
3256 | pop eax |
||
3257 | pop edx ecx |
||
3258 | push ecx edx |
||
3259 | push ebx |
||
3260 | push edx |
||
3261 | push [esi+shmem_item.ptr] |
||
3262 | push ecx |
||
3263 | push [hProcess] |
||
3264 | call [WriteProcessMemory] |
||
3265 | pop edx ecx |
||
3266 | cmp dword [debugevent+32], ebx |
||
3267 | jz .pfsh_read |
||
3268 | cmp [edi+shmem_proc_descr.access], ebx |
||
3269 | jz .nopf |
||
3270 | mov [esi+shmem_item.pOwner], edi |
||
3271 | mov eax, [hProcess] |
||
3272 | mov [esi+shmem_item.hOwner], eax |
||
3273 | jmp debugcont |
||
3274 | .pfsh_read: |
||
3275 | push eax |
||
3276 | push esp |
||
3277 | push 2 ; PAGE_READONLY |
||
3278 | push edx |
||
3279 | push ecx |
||
3280 | push [hProcess] |
||
3281 | call [VirtualProtectEx] |
||
3282 | pop eax |
||
3283 | jmp debugcont |
||
3284 | .nopf: |
||
3285 | ; first exception is int3 in loader code |
||
3286 | ; ignore all exceptions before executing our code |
||
3287 | ; (there is one exception, debugging int3, in ntdll loader code, |
||
3288 | ; this exception must be continued as handled) |
||
3289 | mov edi, context |
||
3290 | push edi |
||
3291 | push [hThread] |
||
3292 | mov dword [edi], 1000Fh |
||
3293 | call [GetThreadContext] |
||
3294 | add edi, 0xB8 |
||
3295 | ; breakpoints int3 (0xCC): decrement EIP (incremented by Windows) |
||
3296 | cmp [debugevent+12], 0x80000003 |
||
3297 | jnz @f |
||
3298 | dec dword [edi] |
||
3299 | @@: |
||
3300 | ; single-step exceptions: restore TF flag (cleared by Windows) |
||
3301 | mov dx, cs |
||
3302 | mov eax, [edi] |
||
3303 | mov ecx, [cur_tid_ptr] |
||
3304 | cmp [debugevent+12], 0x80000004 |
||
3305 | jnz .noss |
||
3306 | cmp word [edi+4], dx |
||
3307 | jnz .set_tf |
||
3308 | cmp eax, exception+1 |
||
3309 | jz @f |
||
3310 | .set_tf: |
||
3311 | or byte [edi+8+1], 1 |
||
3312 | @@: |
||
3313 | cmp [ecx+52], ebx |
||
3314 | mov [ecx+52], ebx |
||
3315 | jnz x |
||
3316 | cmp word [edi+4], dx |
||
3317 | jnz .noss |
||
3318 | cmp eax, i40_done_jmp1 |
||
3319 | jz .skipnext |
||
3320 | cmp eax, i40_done_jmp2 |
||
3321 | jnz @f |
||
3322 | .skipnext: |
||
3323 | inc dword [ecx+52] |
||
3324 | @@: |
||
3325 | cmp eax, exception+1 |
||
3326 | jz x |
||
3327 | cmp eax, i40_done |
||
3328 | jb .noss |
||
3329 | cmp eax, not_supported_i40_fn |
||
3330 | jb x |
||
3331 | .noss: |
||
3332 | mov [ecx+52], ebx |
||
3333 | mov esi, tls_index |
||
3334 | push eax |
||
3335 | push esp |
||
3336 | push 4 |
||
3337 | push esi |
||
3338 | push esi |
||
3339 | push [hProcess] |
||
3340 | call [ReadProcessMemory] |
||
3341 | mov eax, [cur_tid_ptr] |
||
3342 | mov eax, [eax+16] |
||
3343 | add eax, 2Ch |
||
3344 | mov ecx, esp |
||
3345 | push ebx |
||
3346 | push ecx |
||
3347 | sub ecx, 4 |
||
3348 | push 4 |
||
3349 | push ecx |
||
3350 | push eax |
||
3351 | push [hProcess] |
||
3352 | call [ReadProcessMemory] |
||
3353 | pop eax |
||
3354 | pop ecx |
||
3355 | test eax, eax |
||
3356 | jz debugcont |
||
3357 | mov ecx, [esi] |
||
3358 | cmp ecx, -1 |
||
3359 | jz debugcont |
||
3360 | lea eax, [eax+ecx*4] |
||
3361 | push eax |
||
3362 | mov ecx, esp |
||
3363 | push ebx |
||
3364 | push ecx |
||
3365 | sub ecx, 4 |
||
3366 | push 4 |
||
3367 | push ecx |
||
3368 | push eax |
||
3369 | push [hProcess] |
||
3370 | call [ReadProcessMemory] |
||
3371 | pop eax |
||
3372 | pop ecx |
||
3373 | ; now eax -> TLS data |
||
3374 | xchg eax, esi |
||
3375 | push eax |
||
3376 | push esp |
||
3377 | push 24 |
||
3378 | push _cs |
||
3379 | push esi |
||
3380 | push [hProcess] |
||
3381 | call [ReadProcessMemory] |
||
3382 | pop eax |
||
3383 | mov ax, [_cs] |
||
3384 | test ax, ax |
||
3385 | jz debugcont |
||
3386 | ; test for exceptions in Kolibri code |
||
3387 | cmp word [context+0xBC], ax |
||
3388 | jz process_exception |
||
3389 | ; debugged process? |
||
3390 | mov edx, [cur_tid_ptr] |
||
3391 | mov edi, [edx+20] |
||
3392 | test edi, edi |
||
3393 | jz .nodebuggee |
||
3394 | ; yes |
||
3395 | ; int40? |
||
3396 | cmp [debugevent+12], 0xC0000005 |
||
3397 | jnz .exception2dbg |
||
3398 | push edx edi |
||
3399 | push ebx |
||
3400 | mov ecx, esp |
||
3401 | push ebx |
||
3402 | push esp |
||
3403 | push 4 |
||
3404 | push ecx |
||
3405 | push base |
||
3406 | call get_cur_slot_ptr_server |
||
3407 | push [edi+shared_data_struc.win32_hBaseProcess-shared_data_struc.threads] |
||
3408 | call [ReadProcessMemory] |
||
3409 | lea ecx, [esp+4] |
||
3410 | push esp |
||
3411 | mov eax, [ecx] |
||
3412 | push 2 |
||
3413 | add eax, [context+0xB8] |
||
3414 | push ecx |
||
3415 | push eax |
||
3416 | push [edi+shared_data_struc.win32_hBaseProcess-shared_data_struc.threads] |
||
3417 | call [ReadProcessMemory] |
||
3418 | pop eax |
||
3419 | pop ecx |
||
3420 | pop edi edx |
||
3421 | cmp al, 2 |
||
3422 | jnz .exception2dbg |
||
3423 | cmp cx, 0x40CD |
||
3424 | jz .nodebuggee |
||
3425 | ; suspend current thread and notify debugger |
||
3426 | .exception2dbg: |
||
3427 | push dword [edx+8] |
||
3428 | call [SuspendThread] |
||
3429 | push context |
||
3430 | push [hThread] |
||
3431 | call [SetThreadContext] |
||
3432 | mov eax, [edi+12] |
||
3433 | call get_slot_ptr |
||
3434 | push [debugevent+12] |
||
3435 | push [cur_slot] |
||
3436 | push 401h |
||
3437 | push [edi+shared_data_struc.hWnd-shared_data_struc.threads] |
||
3438 | call init_MessageBox |
||
3439 | call [PostMessageA] |
||
3440 | jmp debugcont |
||
3441 | .nodebuggee: |
||
3442 | ; set Win32 context |
||
3443 | mov word [context+0xBC], ax |
||
3444 | mov ax, [_ds] |
||
3445 | mov word [context+0x98], ax |
||
3446 | mov word [context+0x94], ax |
||
3447 | mov word [context+0xC8], ax |
||
3448 | mov ax, [_fs] |
||
3449 | mov word [context+0x90], ax |
||
3450 | ; mov word [context+0x8C], 0 |
||
3451 | mov eax, [_eip] |
||
3452 | xchg eax, [context+0xB8] |
||
3453 | mov [_eip], eax |
||
3454 | mov eax, [_esp] |
||
3455 | xchg eax, [context+0xC4] |
||
3456 | mov [_esp], eax |
||
3457 | mov eax, [debugevent+12] |
||
3458 | mov [exc_code], eax |
||
3459 | mov eax, [debugevent+36] |
||
3460 | mov [exc_data], eax |
||
3461 | push eax |
||
3462 | push esp |
||
3463 | push 24 |
||
3464 | push _cs |
||
3465 | push esi |
||
3466 | push [hProcess] |
||
3467 | call [WriteProcessMemory] |
||
3468 | pop eax |
||
3469 | x: |
||
3470 | push context |
||
3471 | push [hThread] |
||
3472 | call [SetThreadContext] |
||
3473 | jmp debugcont |
||
3474 | process_exception: |
||
3475 | mov eax, [context+0xB8] |
||
3476 | cmp eax, server_test |
||
3477 | jnz .no_server_test |
||
3478 | mov eax, [debugevent+4] |
||
3479 | mov ecx, [pids] |
||
3480 | @@: cmp [ecx+4], eax |
||
3481 | jz @f |
||
3482 | mov ecx, [ecx] |
||
3483 | jmp @b |
||
3484 | @@: |
||
3485 | mov edi, [ecx+12] |
||
3486 | push ebx |
||
3487 | push 1000h |
||
3488 | push edi |
||
3489 | push [context+0x9C] |
||
3490 | push [hProcess] |
||
3491 | call [WriteProcessMemory] |
||
3492 | push edi |
||
3493 | call free_big |
||
3494 | mov eax, [cur_slot] |
||
3495 | mov [context+0xB0], eax |
||
3496 | mov eax, context+0xAC ; ecx |
||
3497 | mov ecx, [hSharedData] |
||
3498 | call DuplicateMyHandle |
||
3499 | mov eax, context+0xA8 ; edx |
||
3500 | mov ecx, [hSharedMutex] |
||
3501 | call DuplicateMyHandle |
||
3502 | jmp add2 |
||
3503 | .no_server_test: |
||
3504 | cmp eax, server_new_thread |
||
3505 | jnz @f |
||
3506 | mov eax, [debugevent+8] |
||
3507 | mov [dwThreadId], eax |
||
3508 | call new_kolibri_thread |
||
3509 | mov eax, [cur_slot] |
||
3510 | mov [context+0xAC], eax |
||
3511 | jmp add2 |
||
3512 | @@: |
||
3513 | cmp eax, server_run_prg |
||
3514 | jnz @f |
||
3515 | ; create new process |
||
3516 | push ebx |
||
3517 | push 4096 |
||
3518 | push process_curdir |
||
3519 | push process_curdir |
||
3520 | push [hProcess] |
||
3521 | call [ReadProcessMemory] |
||
3522 | mov eax, [context+0x9C] |
||
3523 | mov edx, converted_path |
||
3524 | mov edi, edx ; edi=name |
||
3525 | call read_asciz |
||
3526 | mov eax, [context+0xA0] |
||
3527 | xor esi, esi ; esi=params |
||
3528 | test eax, eax |
||
3529 | jz .x |
||
3530 | mov edx, win32_path |
||
3531 | mov esi, edx |
||
3532 | call read_asciz |
||
3533 | .x: |
||
3534 | mov eax, [cur_tid_ptr] |
||
3535 | mov [parent_tid_ptr], eax |
||
3536 | push 2 ; dwOptions = DUPLICATE_SAME_ACCESS |
||
3537 | push ebx ; bInheritHandle |
||
3538 | push ebx ; dwDesiredAccess |
||
3539 | push context+0xAC ; lpTargetHandle |
||
3540 | push [hProcess] |
||
3541 | push eax |
||
3542 | call new_kolibri_process |
||
3543 | pop ecx |
||
3544 | mov edx, [context+0xB0] ; flags for 70.7 |
||
3545 | mov [ecx+32], edx |
||
3546 | mov [ecx+36], ebx |
||
3547 | mov [ecx+40], ebx |
||
3548 | ; mov [context+0xB0], eax |
||
3549 | mov [ecx+28], eax |
||
3550 | push dword [ecx+24] |
||
3551 | call [GetCurrentProcess] |
||
3552 | push eax |
||
3553 | call [DuplicateHandle] |
||
3554 | jmp add2 |
||
3555 | @@: |
||
3556 | cmp eax, server_get_run_result |
||
3557 | jnz @f |
||
3558 | mov esi, [cur_tid_ptr] |
||
3559 | push dword [esi+24] |
||
3560 | call [CloseHandle] |
||
3561 | mov eax, [esi+28] |
||
3562 | mov [context+0xB0], eax |
||
3563 | mov eax, context+0xAC |
||
3564 | mov ecx, [esi+36] |
||
3565 | call DuplicateMyHandle |
||
3566 | mov eax, context+0xA8 |
||
3567 | mov ecx, [esi+40] |
||
3568 | call DuplicateMyHandle |
||
3569 | mov eax, [esi+44] |
||
3570 | mov [context+0xA0], eax |
||
3571 | mov eax, [esi+48] |
||
3572 | mov [context+0x9C], eax |
||
3573 | jmp add2 |
||
3574 | @@: |
||
3575 | cmp eax, set_wnd_colors |
||
3576 | jnz @f |
||
3577 | mov ecx, [context+0xA8] |
||
3578 | and ecx, 7Fh |
||
3579 | push ebx |
||
3580 | push ecx |
||
3581 | push common_colors |
||
3582 | push [context+0xAC] |
||
3583 | push [hProcess] |
||
3584 | call [ReadProcessMemory] |
||
3585 | mov [bCommonColorsSet], 1 |
||
3586 | add2: |
||
3587 | add [context+0xB8], 2 |
||
3588 | jmp x |
||
3589 | @@: |
||
3590 | cmp eax, notify_parent |
||
3591 | jnz nonotifyparent |
||
3592 | mov eax, [cur_tid_ptr] |
||
3593 | mov edi, [eax+20] |
||
3594 | test edi, edi |
||
3595 | jz add2 |
||
3596 | test byte [edi+32], 1 |
||
3597 | jz @f |
||
3598 | push [hThread] |
||
3599 | call [SuspendThread] |
||
3600 | mov eax, [hProcess] |
||
3601 | mov [edi+36], eax |
||
3602 | mov eax, [hThread] |
||
3603 | mov [edi+40], eax |
||
3604 | mov eax, [context+0xB4] |
||
3605 | mov [edi+44], eax |
||
3606 | mov eax, [context+0xC4] |
||
3607 | mov [edi+48], eax |
||
3608 | jmp setparev |
||
3609 | @@: |
||
3610 | mov dword [eax+20], ebx |
||
3611 | setparev: |
||
3612 | push dword [edi+24] |
||
3613 | call [SetEvent] |
||
3614 | jmp add2 |
||
3615 | nonotifyparent: |
||
3616 | cmp eax, loadfailed |
||
3617 | jnz @f |
||
3618 | mov ecx, [context+0xB0] |
||
3619 | mov eax, [cur_tid_ptr] |
||
3620 | mov edi, [eax+20] |
||
3621 | test edi, edi |
||
3622 | jz add2 |
||
3623 | mov [edi+28], ecx |
||
3624 | jmp @b |
||
3625 | @@: |
||
3626 | cmp eax, get_wnd_colors |
||
3627 | jnz @f |
||
3628 | mov ecx, [context+0xA8] |
||
3629 | and ecx, 7Fh |
||
3630 | push ebx |
||
3631 | push ecx |
||
3632 | push common_colors |
||
3633 | push [context+0xAC] |
||
3634 | push [hProcess] |
||
3635 | call [WriteProcessMemory] |
||
3636 | mov al, [bCommonColorsSet] |
||
3637 | mov byte [context+0xB0], al |
||
3638 | jmp add2 |
||
3639 | @@: |
||
3640 | cmp eax, set_button_style |
||
3641 | jnz @f |
||
3642 | mov ecx, [context+0xAC] |
||
3643 | cmp cl, [buttontype] |
||
3644 | jz add2 |
||
3645 | mov [buttontype], cl |
||
3646 | call update_buttontype |
||
3647 | jmp add2 |
||
3648 | @@: |
||
3649 | cmp eax, server_send_ipc |
||
3650 | jnz no_server_send_ipc |
||
3651 | ; find target slot |
||
3652 | mov eax, [context+0xAC] ; ecx |
||
3653 | mov esi, [shared_data] |
||
3654 | mov ecx, [esi] |
||
3655 | add esi, shared_data_struc.threads |
||
3656 | @@: |
||
3657 | cmp [esi], eax |
||
3658 | jz @f |
||
3659 | add esi, 64 |
||
3660 | loop @b |
||
3661 | mov [context+0xB0], 4 ; no such PID |
||
3662 | jmp .done |
||
3663 | @@: |
||
3664 | mov eax, [esi+4] |
||
3665 | test eax, eax |
||
3666 | jnz @f |
||
3667 | mov [context+0xB0], 1 ; no IPC memory |
||
3668 | jmp .done |
||
3669 | @@: |
||
3670 | push -1 |
||
3671 | mov ecx, esp |
||
3672 | push ebx |
||
3673 | push 4 |
||
3674 | push ecx |
||
3675 | push eax |
||
3676 | push dword [esi+12] |
||
3677 | call [ReadProcessMemory] |
||
3678 | pop ecx |
||
3679 | jecxz @f |
||
3680 | mov [context+0xB0], 2 ; IPC blocked |
||
3681 | jmp .done |
||
3682 | @@: |
||
3683 | push ebx |
||
3684 | mov eax, esp |
||
3685 | push ebx |
||
3686 | push 4 |
||
3687 | push eax |
||
3688 | mov eax, [esi+4] |
||
3689 | add eax, 4 |
||
3690 | push eax |
||
3691 | push dword [esi+12] |
||
3692 | call [ReadProcessMemory] |
||
3693 | pop eax |
||
3694 | mov ecx, [esi+8] |
||
3695 | sub ecx, 8 |
||
3696 | sub ecx, eax |
||
3697 | sub ecx, [context+0xA0] ; esi = message length |
||
3698 | jns @f |
||
3699 | mov [context+0xB0], 3 ; buffer overflow |
||
3700 | jmp .done |
||
3701 | @@: |
||
3702 | mov edi, eax |
||
3703 | add eax, 8 |
||
3704 | add eax, [context+0xA0] |
||
3705 | push eax |
||
3706 | mov eax, esp |
||
3707 | push ebx |
||
3708 | push 4 |
||
3709 | push eax |
||
3710 | mov eax, [esi+4] |
||
3711 | add eax, 4 |
||
3712 | push eax |
||
3713 | push dword [esi+12] |
||
3714 | call [WriteProcessMemory] |
||
3715 | pop eax |
||
3716 | add edi, [esi+4] ; edi = pointer to place for our message |
||
3717 | ; message header: dd source_pid, dd size |
||
3718 | push [context+0xA0] |
||
3719 | push edi |
||
3720 | call get_cur_slot_ptr_server |
||
3721 | mov eax, [edi] |
||
3722 | pop edi |
||
3723 | push eax |
||
3724 | mov eax, esp |
||
3725 | push ebx |
||
3726 | push 8 |
||
3727 | push eax |
||
3728 | push edi |
||
3729 | push dword [esi+12] |
||
3730 | call [WriteProcessMemory] |
||
3731 | pop eax |
||
3732 | pop eax |
||
3733 | ; now read message from source process and write it to target |
||
3734 | push eax |
||
3735 | call malloc |
||
3736 | xchg eax, ebp |
||
3737 | push ebx |
||
3738 | push [context+0xA0] |
||
3739 | push ebp |
||
3740 | push [context+0xA8] |
||
3741 | push [hProcess] |
||
3742 | call [ReadProcessMemory] |
||
3743 | add edi, 8 |
||
3744 | push ebx |
||
3745 | push [context+0xA0] |
||
3746 | push ebp |
||
3747 | push edi |
||
3748 | push dword [esi+12] |
||
3749 | call [WriteProcessMemory] |
||
3750 | push ebp |
||
3751 | call free |
||
3752 | mov [context+0xB0], ebx ; success |
||
3753 | ; now notify window of target handle |
||
3754 | ; push 0 |
||
3755 | ; push 0 |
||
3756 | ; push 400h ; WM_USER |
||
3757 | ; push dword [esi+20] |
||
3758 | ; call [PostMessageA] |
||
3759 | ; let source thread to notify target window |
||
3760 | mov eax, [esi+20] |
||
3761 | mov [context+0xAC], eax |
||
3762 | .done: |
||
3763 | jmp add2 |
||
3764 | no_server_send_ipc: |
||
3765 | cmp eax, server_convert |
||
3766 | jnz no_server_convert |
||
3767 | mov eax, context+0xB0 ; eax |
||
3768 | mov ecx, [eax] |
||
3769 | call DuplicateMyHandle |
||
3770 | jmp add2 |
||
3771 | no_server_convert: |
||
3772 | cmp eax, ..server_create_shmem |
||
3773 | jnz no_server_create_shmem |
||
3774 | sub esp, 32 |
||
3775 | mov eax, esp |
||
3776 | push ebx |
||
3777 | push 32 |
||
3778 | push eax |
||
3779 | push dword [context+0xAC] ; ecx |
||
3780 | push [hProcess] |
||
3781 | call [ReadProcessMemory] |
||
3782 | test eax, eax |
||
3783 | jnz @f |
||
3784 | .invparam: |
||
3785 | push 33 ; E_PARAM |
||
3786 | pop edx |
||
3787 | .ret: |
||
3788 | add esp, 32 |
||
3789 | mov dword [context+0xB0], edx ; eax |
||
3790 | jmp add2 |
||
3791 | @@: |
||
3792 | ; scan for shared memory area with requested name |
||
3793 | mov edx, [shmem_list] |
||
3794 | .scan: |
||
3795 | mov esi, esp |
||
3796 | cmp edx, shmem_list - shmem_item.next |
||
3797 | jz .new |
||
3798 | mov edi, edx |
||
3799 | push 32 |
||
3800 | pop ecx |
||
3801 | @@: |
||
3802 | lodsb |
||
3803 | scasb |
||
3804 | jnz @f |
||
3805 | test al, al |
||
3806 | loopnz @b |
||
3807 | @@: |
||
3808 | jz .found |
||
3809 | mov edx, [edx+shmem_item.next] |
||
3810 | jmp .scan |
||
3811 | .new: |
||
3812 | ; requested section was not found, create new if needed |
||
3813 | push 5 ; E_NOTFOUND |
||
3814 | pop edx |
||
3815 | mov al, byte [context+0xA0] ; esi |
||
3816 | and al, 0xC |
||
3817 | jz .ret |
||
3818 | jp .invparam |
||
3819 | ; create |
||
3820 | mov eax, [context+0xA8] ; edx |
||
3821 | test eax, eax |
||
3822 | jz .invparam |
||
3823 | call malloc_big |
||
3824 | push 30 ; E_NOMEM |
||
3825 | pop edx |
||
3826 | test eax, eax |
||
3827 | jz .ret |
||
3828 | push eax |
||
3829 | push shmem_item.sizeof |
||
3830 | call malloc |
||
3831 | test eax, eax |
||
3832 | jnz @f |
||
3833 | call free_big |
||
3834 | push 30 |
||
3835 | pop edx |
||
3836 | jmp .ret |
||
3837 | @@: |
||
3838 | mov edi, eax |
||
3839 | push 32/4 |
||
3840 | pop ecx |
||
3841 | rep movsd |
||
3842 | mov ecx, [shmem_list] |
||
3843 | mov [eax+shmem_item.next], ecx |
||
3844 | mov [ecx+shmem_item.prev], eax |
||
3845 | mov [eax+shmem_item.prev], shmem_list - shmem_item.next |
||
3846 | mov [shmem_list], eax |
||
3847 | mov [eax+shmem_item.refs], ebx |
||
3848 | pop [eax+shmem_item.ptr] |
||
3849 | push [context+0xA8] |
||
3850 | pop [eax+shmem_item.size] |
||
3851 | mov [eax+shmem_item.hOwner], ebx |
||
3852 | mov [eax+shmem_item.pOwner], ebx |
||
3853 | mov esi, eax |
||
3854 | mov eax, [context+0xA0] ; esi |
||
3855 | and eax, 1 |
||
3856 | mov [esi+shmem_item.access], eax |
||
3857 | jmp .created |
||
3858 | .found: |
||
3859 | mov esi, edx |
||
3860 | push 10 ; E_ACCESS |
||
3861 | pop edx |
||
3862 | mov al, byte [context+0xA0] ; esi |
||
3863 | and al, 0xC |
||
3864 | jz @f |
||
3865 | jp .invparam |
||
3866 | cmp al, 8 |
||
3867 | jz .ret |
||
3868 | @@: |
||
3869 | test byte [context+0xA0], 1 |
||
3870 | jz .created |
||
3871 | cmp [esi+shmem_item.access], ebx |
||
3872 | jz .ret |
||
3873 | .created: |
||
3874 | inc [esi+shmem_item.refs] |
||
3875 | ; section ok, now create descriptor for address space in target process |
||
3876 | push shmem_proc_descr.sizeof |
||
3877 | call malloc |
||
3878 | test eax, eax |
||
3879 | jnz @f |
||
3880 | push [esi+shmem_item.next] |
||
3881 | pop [shmem_list] |
||
3882 | push esi |
||
3883 | push [esi+shmem_item.ptr] |
||
3884 | call free_big |
||
3885 | call free |
||
3886 | push 30 |
||
3887 | pop edx |
||
3888 | jmp .ret |
||
3889 | @@: |
||
3890 | mov [eax+shmem_proc_descr.item], esi |
||
3891 | mov [eax+shmem_proc_descr.ptr], ebx |
||
3892 | mov [eax+shmem_proc_descr.end], ebx |
||
3893 | xor edx, edx |
||
3894 | test byte [context+0xA0], 1 |
||
3895 | jz @f |
||
3896 | inc edx |
||
3897 | @@: |
||
3898 | cmp [esi+shmem_item.refs], 1 |
||
3899 | jnz @f |
||
3900 | mov dl, 1 |
||
3901 | @@: |
||
3902 | mov [eax+shmem_proc_descr.access], edx |
||
3903 | ; no need to synchronize - only server uses this list |
||
3904 | call get_cur_slot_ptr_server |
||
3905 | push [edi+shared_data_struc.shmem_list-shared_data_struc.threads] |
||
3906 | pop [eax+shmem_proc_descr.next] |
||
3907 | mov [edi+shared_data_struc.shmem_list-shared_data_struc.threads], eax |
||
3908 | ; all is OK, return to caller |
||
3909 | mov [context+0xB0], ebx ; eax |
||
3910 | mov eax, [esi+shmem_item.size] |
||
3911 | mov [context+0xAC], eax ; ecx |
||
3912 | add eax, 0xFFF |
||
3913 | and eax, not 0xFFF |
||
3914 | cmp [esi+shmem_item.refs], 1 |
||
3915 | jnz @f |
||
3916 | xor eax, eax |
||
3917 | @@: |
||
3918 | mov [context+0xA8], eax ; edx |
||
3919 | add esp, 32 |
||
3920 | jmp add2 |
||
3921 | no_server_create_shmem: |
||
3922 | cmp eax, ..server_notify_shmem |
||
3923 | jnz no_server_notify_shmem |
||
3924 | call get_cur_slot_ptr_server |
||
3925 | mov edi, [edi+shared_data_struc.shmem_list-shared_data_struc.threads] |
||
3926 | push [context+0xB0] ; eax |
||
3927 | pop [edi+shmem_proc_descr.ptr] |
||
3928 | mov eax, [edi+shmem_proc_descr.item] |
||
3929 | mov eax, [eax+shmem_item.size] |
||
3930 | add eax, 0xFFF |
||
3931 | and eax, not 0xFFF |
||
3932 | add eax, [edi+shmem_proc_descr.ptr] |
||
3933 | mov [edi+shmem_proc_descr.end], eax |
||
3934 | jmp add2 |
||
3935 | no_server_notify_shmem: |
||
3936 | cmp eax, ..server_destroy_shmem |
||
3937 | jnz no_server_destroy_shmem |
||
3938 | sub esp, 32 |
||
3939 | mov eax, esp |
||
3940 | push ebx |
||
3941 | push 32 |
||
3942 | push eax |
||
3943 | push dword [context+0xAC] ; ecx |
||
3944 | push [hProcess] |
||
3945 | call [ReadProcessMemory] |
||
3946 | mov [context+0xAC], ebx |
||
3947 | test eax, eax |
||
3948 | jz .ret |
||
3949 | call get_cur_slot_ptr_server |
||
3950 | lea ebp, [edi+shared_data_struc.shmem_list-shared_data_struc.threads - shmem_proc_descr.next] |
||
3951 | .scan: |
||
3952 | mov edx, [ebp+shmem_proc_descr.next] |
||
3953 | test edx, edx |
||
3954 | jz .ret |
||
3955 | mov esi, [edx+shmem_proc_descr.item] |
||
3956 | mov edi, esp |
||
3957 | push 32 |
||
3958 | pop ecx |
||
3959 | @@: |
||
3960 | lodsb |
||
3961 | scasb |
||
3962 | jnz @f |
||
3963 | test al, al |
||
3964 | loopnz @b |
||
3965 | @@: |
||
3966 | jz .found |
||
3967 | mov ebp, edx |
||
3968 | jmp .scan |
||
3969 | .found: |
||
3970 | push [edx+shmem_proc_descr.next] |
||
3971 | pop [ebp+shmem_proc_descr.next] |
||
3972 | push [edx+shmem_proc_descr.ptr] |
||
3973 | pop [context+0xAC] ; ecx |
||
3974 | mov esi, [edx+shmem_proc_descr.item] |
||
3975 | push edx |
||
3976 | call free |
||
3977 | dec [esi+shmem_item.refs] |
||
3978 | jnz .ret |
||
3979 | call shmem_free_item |
||
3980 | .ret: |
||
3981 | add esp, 32 |
||
3982 | jmp add2 |
||
3983 | no_server_destroy_shmem: |
||
3984 | cmp eax, i40_sys_service.server_terminate |
||
3985 | jz server_done |
||
3986 | no_server_terminate: |
||
3987 | if idletime_via_ring0 |
||
3988 | cmp eax, i40_sys_service.idlecount_init |
||
3989 | jnz @f |
||
3990 | push eax |
||
3991 | push esp |
||
3992 | push ebx |
||
3993 | push [cur_slot] |
||
3994 | push idlecount_thread |
||
3995 | push 2000h |
||
3996 | push ebx |
||
3997 | call [CreateThread] |
||
3998 | pop eax |
||
3999 | mov eax, [shared_data] |
||
4000 | mov [eax+shared_data_struc.idlecount], 1000 |
||
4001 | mov [eax+shared_data_struc.b9xPerfInited], 1 |
||
4002 | jmp add2 |
||
4003 | @@: |
||
4004 | end if |
||
4005 | cont_nh: |
||
4006 | ; ignore int3 breaks (continue as handled) |
||
4007 | cmp [debugevent+12], 80000003h ; EXCEPTION_BREAKPOINT |
||
4008 | jz debugcont |
||
4009 | if 1 |
||
4010 | ; ignore first-chance exceptions (continue as not handled) |
||
4011 | cmp dword [debugevent+0x5C], ebx |
||
4012 | jnz .first_chance |
||
4013 | mov eax, context |
||
4014 | int3 |
||
4015 | mov eax, [context+0xB8] |
||
4016 | mov edi, eeeeip+7 |
||
4017 | std |
||
4018 | mov ecx, 8 |
||
4019 | @@: |
||
4020 | mov edx, eax |
||
4021 | and al, 0xF |
||
4022 | cmp al, 10 |
||
4023 | sbb al, 69h |
||
4024 | das |
||
4025 | stosb |
||
4026 | mov eax, edx |
||
4027 | shr eax, 4 |
||
4028 | loop @b |
||
4029 | cld |
||
4030 | call init_MessageBox |
||
4031 | push ebx |
||
4032 | push ebx |
||
4033 | push eee |
||
4034 | push ebx |
||
4035 | call [MessageBoxA] |
||
4036 | .first_chance: |
||
4037 | end if |
||
4038 | push 80010001h ; DBG_EXCEPTION_NOT_HANDLED |
||
4039 | jmp dodebugcont |
||
4040 | |||
4041 | find_tid: |
||
4042 | ; get hThread |
||
4043 | mov [hThread], ebx |
||
4044 | mov [cur_slot], ebx |
||
4045 | mov eax, [debugevent+8] |
||
4046 | mov ecx, [tids] |
||
4047 | @@: jecxz .ret |
||
4048 | cmp [ecx+4], eax |
||
4049 | jz @f |
||
4050 | mov ecx, [ecx] |
||
4051 | jmp @b |
||
4052 | @@: mov eax, [ecx+12] |
||
4053 | mov [cur_slot], eax |
||
4054 | mov eax, [ecx+8] |
||
4055 | mov [hThread], eax |
||
4056 | mov [cur_tid_ptr], ecx |
||
4057 | .ret: |
||
4058 | ret |
||
4059 | |||
4060 | read_asciz: |
||
4061 | ; in: eax=client pointer, edx->buffer |
||
4062 | push eax |
||
4063 | push edx |
||
4064 | push eax |
||
4065 | push esp |
||
4066 | push 260 |
||
4067 | push edx |
||
4068 | push eax |
||
4069 | push [hProcess] |
||
4070 | call [ReadProcessMemory] |
||
4071 | test eax, eax |
||
4072 | pop ecx |
||
4073 | pop edx |
||
4074 | pop eax |
||
4075 | jnz @f |
||
4076 | xor ecx, ecx |
||
4077 | @@: mov byte [edx+ecx], bl |
||
4078 | ret |
||
4079 | |||
4080 | create_child: |
||
4081 | mov edi, inname |
||
4082 | mov esi, [parameters] |
||
4083 | |||
4084 | new_kolibri_process_with_default_curdir: |
||
4085 | mov dword [process_curdir], '/rd/' |
||
4086 | mov word [process_curdir+4], '1' |
||
4087 | mov [parent_tid_ptr], ebx |
||
4088 | |||
4089 | new_kolibri_process: |
||
4090 | ; in: edi=pointer to process name, esi=pointer to parameters |
||
4091 | ; create command line |
||
4092 | mov [process_name], edi |
||
4093 | push esi |
||
4094 | push edi |
||
4095 | mov edi, cmdline |
||
4096 | mov al, '"' |
||
4097 | stosb |
||
4098 | push 2000 |
||
4099 | push edi |
||
4100 | push ebx |
||
4101 | call [GetModuleFileNameA] |
||
4102 | add edi, eax |
||
4103 | mov ax, '" ' |
||
4104 | stosw |
||
4105 | mov al, '"' |
||
4106 | stosb |
||
4107 | pop esi |
||
4108 | push esi |
||
4109 | call [lstrlenA] |
||
4110 | xchg eax, ecx |
||
4111 | rep movsb |
||
4112 | mov al, '"' |
||
4113 | stosb |
||
4114 | mov al, ' ' |
||
4115 | stosb |
||
4116 | pop esi |
||
4117 | test esi, esi |
||
4118 | jz @f |
||
4119 | push esi |
||
4120 | call [lstrlenA] |
||
4121 | xchg eax, ecx |
||
4122 | rep movsb |
||
4123 | @@: |
||
4124 | xor eax, eax |
||
4125 | stosb |
||
4126 | ; create process |
||
4127 | push [hThread] |
||
4128 | push pinfo |
||
4129 | push sinfo |
||
4130 | push ebx |
||
4131 | push ebx |
||
4132 | push ebx |
||
4133 | cmp [bDontDebug], bl |
||
4134 | jnz @f |
||
4135 | pop ebx |
||
4136 | push 2 ; DEBUG_ONLY_THIS_PROCESS |
||
4137 | @@: |
||
4138 | push ebx |
||
4139 | push ebx |
||
4140 | push ebx |
||
4141 | push cmdline |
||
4142 | push ebx |
||
4143 | call [CreateProcessA] |
||
4144 | test eax, eax |
||
4145 | jnz @f |
||
4146 | call init_MessageBox |
||
4147 | push ebx |
||
4148 | push ebx |
||
4149 | push cpe |
||
4150 | push ebx |
||
4151 | call [MessageBoxA] |
||
4152 | pop eax |
||
4153 | xor eax, eax |
||
4154 | dec eax |
||
4155 | ret |
||
4156 | @@: |
||
4157 | cmp [bDontDebug], bl |
||
4158 | jz @f |
||
4159 | pop eax |
||
4160 | ret |
||
4161 | @@: |
||
4162 | mov eax, pids |
||
4163 | @@: mov ecx, [eax] |
||
4164 | jecxz @f |
||
4165 | xchg eax, ecx |
||
4166 | jmp @b |
||
4167 | @@: push eax |
||
4168 | push 16 |
||
4169 | call malloc |
||
4170 | pop ecx |
||
4171 | mov [ecx], eax |
||
4172 | mov [eax], ebx |
||
4173 | mov ecx, [dwProcessId] |
||
4174 | mov [eax+4], ecx |
||
4175 | mov ecx, [hProcess] |
||
4176 | mov [eax+8], ecx |
||
4177 | push eax |
||
4178 | mov eax, 1000h |
||
4179 | call malloc_big |
||
4180 | pop ecx |
||
4181 | mov [ecx+12], eax |
||
4182 | mov edi, eax |
||
4183 | mov esi, process_curdir |
||
4184 | mov ecx, 1000h/4 |
||
4185 | rep movsd |
||
4186 | call alloc_thread |
||
4187 | call new_kolibri_thread |
||
4188 | push eax |
||
4189 | add edi, 8 |
||
4190 | mov esi, [process_name] |
||
4191 | mov edx, esi |
||
4192 | .1: |
||
4193 | lodsb |
||
4194 | cmp al, '\' |
||
4195 | jnz @f |
||
4196 | mov edx, esi |
||
4197 | @@: cmp al, 0 |
||
4198 | jnz .1 |
||
4199 | mov esi, edx |
||
4200 | mov ecx, 11 |
||
4201 | push ecx edi |
||
4202 | mov al, ' ' |
||
4203 | rep stosb |
||
4204 | pop edi ecx |
||
4205 | push edi |
||
4206 | .s: |
||
4207 | lodsb |
||
4208 | test al, al |
||
4209 | jz .d |
||
4210 | cmp al, '.' |
||
4211 | jnz @f |
||
4212 | mov edi, [esp] |
||
4213 | add edi, 8 |
||
4214 | mov cl, 3 |
||
4215 | jmp .s |
||
4216 | @@: |
||
4217 | cmp al, 'a' |
||
4218 | jb @f |
||
4219 | cmp al, 'z' |
||
4220 | ja @f |
||
4221 | and al, not 20h |
||
4222 | @@: stosb |
||
4223 | loop .s |
||
4224 | .d: |
||
4225 | pop edi |
||
4226 | add edi, 11 |
||
4227 | mov byte [edi], 0 |
||
4228 | pop eax |
||
4229 | pop [hThread] |
||
4230 | inc [num_kolibri_proc] |
||
4231 | ret |
||
4232 | alloc_thread: |
||
4233 | mov eax, tids |
||
4234 | @@: mov ecx, [eax] |
||
4235 | jecxz @f |
||
4236 | xchg eax, ecx |
||
4237 | jmp @b |
||
4238 | @@: push eax |
||
4239 | push 56 |
||
4240 | call malloc |
||
4241 | pop ecx |
||
4242 | mov [ecx], eax |
||
4243 | mov [eax], ebx |
||
4244 | mov ecx, [dwThreadId] |
||
4245 | mov [eax+4], ecx |
||
4246 | mov ecx, [hThread] |
||
4247 | mov [eax+8], ecx |
||
4248 | or dword [eax+12], -1 |
||
4249 | mov ecx, [parent_tid_ptr] |
||
4250 | mov [eax+20], ecx |
||
4251 | mov [eax+52], ebx |
||
4252 | mov [cur_tid_ptr], eax |
||
4253 | push ecx |
||
4254 | push ebx ; lpName |
||
4255 | push ebx ; bInitialState |
||
4256 | push ebx ; bManualReset |
||
4257 | push ebx ; lpEventAttributes |
||
4258 | call [CreateEventA] |
||
4259 | pop ecx |
||
4260 | jecxz @f |
||
4261 | mov [ecx+24], eax |
||
4262 | @@: |
||
4263 | ret |
||
4264 | new_kolibri_thread: |
||
4265 | ; find free slot |
||
4266 | mov edi, [shared_data] |
||
4267 | inc dword [edi+4] |
||
4268 | mov ecx, [edi] |
||
4269 | add edi, shared_data_struc.threads |
||
4270 | xor edx, edx |
||
4271 | @@: |
||
4272 | cmp dword [edi], 0 |
||
4273 | jz @f |
||
4274 | inc edx |
||
4275 | add edi, 64 |
||
4276 | loop @b |
||
4277 | mov ecx, [shared_data] |
||
4278 | inc dword [ecx] |
||
4279 | @@: |
||
4280 | mov eax, [cur_tid_ptr] |
||
4281 | mov [eax+12], edx |
||
4282 | mov [cur_slot], edx |
||
4283 | mov eax, [max_pid] |
||
4284 | inc eax |
||
4285 | mov [max_pid], eax |
||
4286 | stosd |
||
4287 | push eax |
||
4288 | xor eax, eax |
||
4289 | stosd |
||
4290 | stosd |
||
4291 | mov eax, [hProcess] |
||
4292 | stosd |
||
4293 | mov eax, [dwThreadId] |
||
4294 | stosd |
||
4295 | push edi |
||
4296 | add edi, 20 |
||
4297 | mov eax, [hThread] |
||
4298 | stosd |
||
4299 | xor eax, eax |
||
4300 | stosd |
||
4301 | stosd |
||
4302 | stosd |
||
4303 | stosd |
||
4304 | stosd |
||
4305 | pop edi |
||
4306 | pop eax |
||
4307 | ret |
||
4308 | |||
4309 | delete_id: |
||
4310 | @@: mov edx, [ecx] |
||
4311 | cmp [edx+4], eax |
||
4312 | jz @f |
||
4313 | mov ecx, edx |
||
4314 | jmp @b |
||
4315 | @@: |
||
4316 | push dword [edx] |
||
4317 | push ecx |
||
4318 | push edx |
||
4319 | push ebx |
||
4320 | push [hHeap] |
||
4321 | ; push dword [edx+8] |
||
4322 | ; call [CloseHandle] |
||
4323 | call [HeapFree] |
||
4324 | pop ecx |
||
4325 | pop dword [ecx] |
||
4326 | .ret: |
||
4327 | ret |
||
4328 | |||
4329 | on_thread_exited: |
||
4330 | mov ecx, [cur_tid_ptr] |
||
4331 | ; send notification message to debugger, if it is present |
||
4332 | mov edi, [ecx+20] |
||
4333 | test edi, edi |
||
4334 | jz @f |
||
4335 | push ecx |
||
4336 | mov eax, [edi+12] |
||
4337 | call get_slot_ptr |
||
4338 | push ebx |
||
4339 | push [cur_slot] |
||
4340 | push 402h |
||
4341 | push [edi+shared_data_struc.hWnd-shared_data_struc.threads] |
||
4342 | call init_MessageBox |
||
4343 | call [PostMessageA] |
||
4344 | pop ecx |
||
4345 | @@: |
||
4346 | ; terminate all debuggees, if are |
||
4347 | mov esi, tids |
||
4348 | @@: |
||
4349 | mov esi, [esi] |
||
4350 | test esi, esi |
||
4351 | jz @f |
||
4352 | cmp [esi+20], ecx |
||
4353 | jnz @b |
||
4354 | push ecx |
||
4355 | push ebx |
||
4356 | push dword [esi+8] |
||
4357 | call [TerminateThread] |
||
4358 | pop ecx |
||
4359 | jmp @b |
||
4360 | @@: |
||
4361 | ; free all shared memory |
||
4362 | call get_cur_slot_ptr_server |
||
4363 | mov edi, [edi+shared_data_struc.shmem_list-shared_data_struc.threads] |
||
4364 | .freeshared: |
||
4365 | test edi, edi |
||
4366 | jz .doneshared |
||
4367 | push [edi+shmem_proc_descr.next] |
||
4368 | mov esi, [edi+shmem_proc_descr.item] |
||
4369 | dec [esi+shmem_item.refs] |
||
4370 | jz .freephys |
||
4371 | cmp [esi+shmem_item.pOwner], edi |
||
4372 | jnz .nextshared |
||
4373 | call shmem_load |
||
4374 | jmp .nextshared |
||
4375 | .freephys: |
||
4376 | call shmem_free_item |
||
4377 | .nextshared: |
||
4378 | push edi |
||
4379 | call free |
||
4380 | pop edi |
||
4381 | jmp .freeshared |
||
4382 | .doneshared: |
||
4383 | ; create thread to do rest of job (part which must be done with SharedDataMutex acquired) |
||
4384 | ; it is not safe to acquire_shared right here, because of possible deadlock |
||
4385 | push eax |
||
4386 | push esp |
||
4387 | push ebx |
||
4388 | push [cur_slot] |
||
4389 | push on_thread_exited_thread |
||
4390 | push 10000h |
||
4391 | push ebx |
||
4392 | call [CreateThread] |
||
4393 | pop eax |
||
4394 | ret |
||
4395 | |||
4396 | on_thread_exited_thread: |
||
4397 | call acquire_shared |
||
4398 | mov eax, [shared_data] |
||
4399 | dec dword [eax+4] |
||
4400 | mov eax, [esp+4] |
||
4401 | call get_slot_ptr |
||
4402 | and dword [edi], 0 |
||
4403 | ; avoid problems with @panel |
||
4404 | mov eax, ' ' |
||
4405 | add edi, 28 |
||
4406 | stosd |
||
4407 | stosd |
||
4408 | stosd |
||
4409 | call release_shared |
||
4410 | push 0 |
||
4411 | call [ExitThread] |
||
4412 | |||
4413 | if idletime_via_ring0 |
||
4414 | idlecount_thread: |
||
4415 | mov eax, .count |
||
4416 | call CallRing0 |
||
4417 | .workloop: |
||
4418 | mov esi, eax |
||
4419 | push 1000 |
||
4420 | call [Sleep] |
||
4421 | mov eax, .count |
||
4422 | call CallRing0 |
||
4423 | sub esi, eax |
||
4424 | ; add esi, 1000 |
||
4425 | ; jc @f |
||
4426 | ; mov esi, 1000 |
||
4427 | ;@@: |
||
4428 | neg esi |
||
4429 | cmp esi, 1000 |
||
4430 | jb @f |
||
4431 | mov esi, 1000 |
||
4432 | @@: |
||
4433 | mov ecx, [shared_data] |
||
4434 | mov [ecx+shared_data_struc.idlecount], esi |
||
4435 | jmp .workloop |
||
4436 | .count: |
||
4437 | push edi |
||
4438 | ; xor edx, edx |
||
4439 | int 0x20 ; VMMCall Get_Sys_Thread_Handle |
||
4440 | dw 10Ah |
||
4441 | dw 1 |
||
4442 | push edi |
||
4443 | int 0x20 ; VMMCall _GetThreadExecTime |
||
4444 | dw 106h |
||
4445 | dw 1 |
||
4446 | pop edi |
||
4447 | ; int 0x20 ; VMMCall Get_Sys_Thread_Handle |
||
4448 | ; dw 10Ah |
||
4449 | ; dw 1 |
||
4450 | ;@@: |
||
4451 | ; int 0x20 ; VMMCall Get_Next_Thread_Handle |
||
4452 | ; dw 113h |
||
4453 | ; dw 1 |
||
4454 | ; int 0x20 ; VMMCall Test_Sys_Thread_Handle |
||
4455 | ; dw 10Bh |
||
4456 | ; dw 1 |
||
4457 | ; jz @f |
||
4458 | ; push edi |
||
4459 | ; int 0x20 ; VMMCall _GetThreadExecTime |
||
4460 | ; dw 106h |
||
4461 | ; dw 1 |
||
4462 | ; add edx, eax |
||
4463 | ; pop eax |
||
4464 | ; jmp @b |
||
4465 | ;@@: |
||
4466 | ; mov eax, edx |
||
4467 | pop edi |
||
4468 | iret |
||
4469 | end if |
||
4470 | |||
4471 | update_buttontype: |
||
4472 | mov esi, [pids] |
||
4473 | @@: |
||
4474 | test esi, esi |
||
4475 | jz .done |
||
4476 | push 0 |
||
4477 | push 1 |
||
4478 | push buttontype |
||
4479 | push buttontype |
||
4480 | push dword [esi+8] |
||
4481 | call [WriteProcessMemory] |
||
4482 | mov esi, [esi] |
||
4483 | jmp @b |
||
4484 | .done: |
||
4485 | ret |
||
4486 | |||
4487 | init_background: |
||
4488 | push -1 |
||
4489 | push [hBgrMutex] |
||
4490 | call [WaitForSingleObject] |
||
4491 | cmp [bgr_section], 0 |
||
4492 | jnz .ret |
||
4493 | push ebx |
||
4494 | call get_screen_size |
||
4495 | movzx eax, bx |
||
4496 | shr ebx, 16 |
||
4497 | inc eax |
||
4498 | inc ebx |
||
4499 | mul ebx |
||
4500 | imul eax, 3 |
||
4501 | pop ebx |
||
4502 | add eax, 20h |
||
4503 | push bgr_section_name |
||
4504 | ; push 0 |
||
4505 | push eax |
||
4506 | push 0 |
||
4507 | push 4 |
||
4508 | push 0 |
||
4509 | push -1 |
||
4510 | call [CreateFileMappingA] |
||
4511 | test eax, eax |
||
4512 | jz .ret |
||
4513 | xchg eax, esi |
||
4514 | call [GetLastError] |
||
4515 | push eax |
||
4516 | push 0 |
||
4517 | push 0 |
||
4518 | push 0 |
||
4519 | push 2 |
||
4520 | push esi |
||
4521 | call [MapViewOfFile] |
||
4522 | push eax |
||
4523 | ; push esi |
||
4524 | ; call [CloseHandle] |
||
4525 | pop eax |
||
4526 | mov [bgr_section], eax |
||
4527 | test eax, eax |
||
4528 | xchg eax, edi |
||
4529 | pop eax |
||
4530 | jz .ret |
||
4531 | cmp eax, 183 |
||
4532 | jz .ret |
||
4533 | ; init background data |
||
4534 | call get_screen_size |
||
4535 | xor eax, eax |
||
4536 | shld eax, ebx, 16 |
||
4537 | inc eax |
||
4538 | stosd |
||
4539 | mov ax, bx |
||
4540 | inc eax |
||
4541 | stosd |
||
4542 | mov byte [edi], 2 |
||
4543 | add edi, 8 |
||
4544 | xor ebx, ebx |
||
4545 | ; cmp byte [esp+4], 0 |
||
4546 | ; jz read_bgr |
||
4547 | jmp read_bgr |
||
4548 | .ret: |
||
4549 | push [hBgrMutex] |
||
4550 | call [ReleaseMutex] |
||
4551 | ret 4 |
||
4552 | |||
4553 | read_bgr: |
||
4554 | ; read and parse desktop background to edi (=[bgr_section]+10h) |
||
4555 | ; call [GetDesktopWindow] |
||
4556 | xor eax, eax |
||
4557 | push eax |
||
4558 | push eax |
||
4559 | call [GetDC] |
||
4560 | push eax |
||
4561 | push eax |
||
4562 | call [CreateCompatibleDC] |
||
4563 | xchg eax, esi |
||
4564 | push dword [edi-0Ch] |
||
4565 | push dword [edi-10h] |
||
4566 | push dword [esp+8] |
||
4567 | call [CreateCompatibleBitmap] |
||
4568 | push eax |
||
4569 | push esi |
||
4570 | call [SelectObject] |
||
4571 | push eax |
||
4572 | push 0xCC0020 |
||
4573 | push ebx |
||
4574 | push ebx |
||
4575 | push dword [esp+16] |
||
4576 | push dword [edi-0Ch] |
||
4577 | push dword [edi-10h] |
||
4578 | push ebx |
||
4579 | push ebx |
||
4580 | push esi |
||
4581 | call [BitBlt] |
||
4582 | push dword [esp+4] |
||
4583 | call [PaintDesktop] |
||
4584 | push 0x660046 |
||
4585 | push ebx |
||
4586 | push ebx |
||
4587 | push dword [esp+16] |
||
4588 | push dword [edi-0Ch] |
||
4589 | push dword [edi-10h] |
||
4590 | push ebx |
||
4591 | push ebx |
||
4592 | push esi |
||
4593 | call [BitBlt] |
||
4594 | push 0x660046 |
||
4595 | push ebx |
||
4596 | push ebx |
||
4597 | push esi |
||
4598 | push dword [edi-0Ch] |
||
4599 | push dword [edi-10h] |
||
4600 | push ebx |
||
4601 | push ebx |
||
4602 | push dword [esp+36] |
||
4603 | call [BitBlt] |
||
4604 | push 0x660046 |
||
4605 | push ebx |
||
4606 | push ebx |
||
4607 | push dword [esp+16] |
||
4608 | push dword [edi-0Ch] |
||
4609 | push dword [edi-10h] |
||
4610 | push ebx |
||
4611 | push ebx |
||
4612 | push esi |
||
4613 | call [BitBlt] |
||
4614 | push esi |
||
4615 | call [SelectObject] |
||
4616 | push ebp |
||
4617 | xchg eax, ebp |
||
4618 | ; now esi=hDC, ebp=hBitmap |
||
4619 | push ebx ; biClrImportant |
||
4620 | push ebx ; biClrUsed |
||
4621 | push ebx ; biYPelsPerMeter |
||
4622 | push ebx ; biXPelsPerMeter |
||
4623 | push ebx ; biSizeImage |
||
4624 | push ebx ; biCompression |
||
4625 | push 200001h ; biBitCount, biPlanes |
||
4626 | push dword [edi-0Ch] ; biHeight |
||
4627 | push dword [edi-10h] ; biWidth |
||
4628 | push 40 ; biSize |
||
4629 | mov ecx, esp |
||
4630 | push ebx |
||
4631 | push ecx |
||
4632 | mov eax, [edi-0Ch] |
||
4633 | mul dword [edi-10h] |
||
4634 | shl eax, 2 |
||
4635 | call malloc_big |
||
4636 | push eax |
||
4637 | push dword [edi-0Ch] |
||
4638 | push ebx |
||
4639 | push ebp |
||
4640 | push esi |
||
4641 | xchg eax, edi |
||
4642 | call [GetDIBits] |
||
4643 | add esp, 40 |
||
4644 | push ebp |
||
4645 | call [DeleteObject] |
||
4646 | pop ebp |
||
4647 | push esi |
||
4648 | call [DeleteDC] |
||
4649 | pop eax |
||
4650 | pop ecx |
||
4651 | push eax |
||
4652 | push ecx |
||
4653 | call [ReleaseDC] |
||
4654 | mov esi, [bgr_section] |
||
4655 | mov eax, [esi] ; width |
||
4656 | mov ecx, [esi+4] ; height |
||
4657 | add esi, 10h |
||
4658 | xchg esi, edi |
||
4659 | ; esi=source, edi=destination |
||
4660 | push eax |
||
4661 | mul ecx |
||
4662 | shl eax, 2 |
||
4663 | add esi, eax |
||
4664 | pop edx |
||
4665 | .1: |
||
4666 | push ecx |
||
4667 | mov ecx, edx |
||
4668 | neg ecx |
||
4669 | lea esi, [esi+ecx*4] |
||
4670 | neg ecx |
||
4671 | push esi |
||
4672 | .2: |
||
4673 | lodsd |
||
4674 | ; call convert_color |
||
4675 | stosd |
||
4676 | dec edi |
||
4677 | loop .2 |
||
4678 | pop esi |
||
4679 | pop ecx |
||
4680 | loop .1 |
||
4681 | push esi |
||
4682 | call free_big |
||
4683 | push [hBgrMutex] |
||
4684 | call [ReleaseMutex] |
||
4685 | ret 4 |
||
4686 | |||
4687 | del_background: |
||
4688 | call [GetTickCount] |
||
4689 | mov ecx, [shared_data] |
||
4690 | cmp eax, [ecx+shared_data_struc.dwNewBgrTime] |
||
4691 | jb .ret |
||
4692 | add eax, 3000 |
||
4693 | mov [ecx+shared_data_struc.dwNewBgrTime], eax |
||
4694 | xor eax, eax |
||
4695 | lock xchg eax, [bgr_section] |
||
4696 | test eax, eax |
||
4697 | jz .ret |
||
4698 | push eax |
||
4699 | call [UnmapViewOfFile] |
||
4700 | .ret: |
||
4701 | ret |
||
4702 | |||
4703 | read_hex: |
||
4704 | xor ecx, ecx |
||
4705 | .l: |
||
4706 | cmp al, '0' |
||
4707 | jb .done |
||
4708 | cmp al, '9' |
||
4709 | jbe .digit |
||
4710 | cmp al, 'A' |
||
4711 | jb .done |
||
4712 | cmp al, 'F' |
||
4713 | jbe .digit2 |
||
4714 | cmp al, 'a' |
||
4715 | jb .done |
||
4716 | cmp al, 'f' |
||
4717 | jbe .digit3 |
||
4718 | .done: |
||
4719 | ret |
||
4720 | .digit3: |
||
4721 | sub al, 0x20 |
||
4722 | .digit2: |
||
4723 | sub al, 'A'-'0'-10 |
||
4724 | .digit: |
||
4725 | sub al, '0' |
||
4726 | movzx eax, al |
||
4727 | shl ecx, 4 |
||
4728 | add ecx, eax |
||
4729 | cmp ecx, 0x10000 |
||
4730 | jae ParseEnablePorts.err |
||
4731 | lodsb |
||
4732 | jmp .l |
||
4733 | |||
4734 | send_driver_request: |
||
4735 | xor ebx, ebx |
||
4736 | push ebx |
||
4737 | push ebx |
||
4738 | push 3 |
||
4739 | push ebx |
||
4740 | push ebx |
||
4741 | push 0xC0000000 |
||
4742 | push kiw0 |
||
4743 | call [CreateFileA] |
||
4744 | inc eax |
||
4745 | jz .ret |
||
4746 | dec eax |
||
4747 | push eax |
||
4748 | push eax |
||
4749 | mov ecx, esp |
||
4750 | push ebx ; lpOverlapped |
||
4751 | push ecx ; lpBytesReturned |
||
4752 | push dword [ecx+8+20] ; nOutBufferSize |
||
4753 | push dword [ecx+8+16] ; lpOutBuffer |
||
4754 | push dword [ecx+8+12] ; nInBufferSize |
||
4755 | push dword [ecx+8+8] ; lpInBuffer |
||
4756 | push dword [ecx+8+4] ; dwIoControlCode |
||
4757 | push eax |
||
4758 | call [DeviceIoControl] |
||
4759 | pop ecx |
||
4760 | pop ecx |
||
4761 | push eax |
||
4762 | push ecx |
||
4763 | call [CloseHandle] |
||
4764 | pop eax |
||
4765 | .ret: |
||
4766 | ret 20 |
||
4767 | |||
4768 | driver_via_scm = 0 |
||
4769 | REQUIRED_DRIVER_VERSION = 1 |
||
4770 | |||
4771 | load_kiw0: |
||
4772 | ; check whether driver with required version is already loaded |
||
4773 | push eax |
||
4774 | mov eax, esp |
||
4775 | push 4 |
||
4776 | push eax |
||
4777 | push ebx |
||
4778 | push ebx |
||
4779 | push 0x222008 |
||
4780 | call send_driver_request |
||
4781 | test eax, eax |
||
4782 | pop edi |
||
4783 | jz .load |
||
4784 | if driver_via_scm |
||
4785 | push 3 ; dwDesiredAccess = SC_MANAGER_CONNECT+SC_MANAGER_CREATE_SERVICE |
||
4786 | cmp edi, REQUIRED_DRIVER_VERSION |
||
4787 | jnz .open |
||
4788 | pop eax |
||
4789 | cmp [keep_loaded_driver], 0 |
||
4790 | jnz .noopen |
||
4791 | push 1 ; dwDesiredAccess = SC_MANAGER_CONNECT |
||
4792 | .open: |
||
4793 | mov esi, DrvLoadErr |
||
4794 | push ebx ; lpDatabaseName |
||
4795 | push ebx ; lpMachineName |
||
4796 | call [OpenSCManagerA] |
||
4797 | test eax, eax |
||
4798 | jz server_fail |
||
4799 | mov [hSCManager], eax |
||
4800 | push 10030h |
||
4801 | push kiw0_drivername |
||
4802 | push [hSCManager] |
||
4803 | call [OpenServiceA] |
||
4804 | test eax, eax |
||
4805 | jz server_fail |
||
4806 | mov [hService], eax |
||
4807 | .noopen: |
||
4808 | cmp edi, REQUIRED_DRIVER_VERSION |
||
4809 | jz .driverok |
||
4810 | ; driver is loaded, but has incorrect version |
||
4811 | ; try to unload and load new driver |
||
4812 | call unload_kiw0 |
||
4813 | jmp @f |
||
4814 | |||
4815 | .load: |
||
4816 | mov esi, DrvLoadErr |
||
4817 | push 2 ; dwDesiredAccess = SC_MANAGER_CREATE_SERVICE |
||
4818 | push ebx ; lpDatabaseName |
||
4819 | push ebx ; lpMachineName |
||
4820 | call [OpenSCManagerA] |
||
4821 | test eax, eax |
||
4822 | jz server_fail |
||
4823 | mov [hSCManager], eax |
||
4824 | @@: |
||
4825 | mov edi, win32_path |
||
4826 | push edi |
||
4827 | push edi |
||
4828 | call [lstrlenA] |
||
4829 | lea edi, [edi+eax+1-inifilenamesize] |
||
4830 | push esi |
||
4831 | mov esi, kiw0filename |
||
4832 | mov ecx, kiw0filenamesize |
||
4833 | rep movsb |
||
4834 | pop esi |
||
4835 | pop edi |
||
4836 | push ebx ; lpPassword |
||
4837 | push ebx ; lpServiceStartName |
||
4838 | push ebx ; lpDependencies |
||
4839 | push ebx ; lpdwTagId |
||
4840 | push ebx ; lpLoadOrderGroup |
||
4841 | push edi ; lpBinaryPathName |
||
4842 | push ebx ; dwErrorControl = SERVICE_ERROR_IGNORE |
||
4843 | push 3 ; dwStartType = SERVICE_DEMAND_START |
||
4844 | push 1 ; dwServiceType = SERVICE_KERNEL_DRIVER |
||
4845 | push 10030h ; dwDesiredAccess = SERVICE_START or SERVICE_STOP or DELETE |
||
4846 | push kiw0_username ; lpDisplayName |
||
4847 | push kiw0_drivername ; lpServiceName |
||
4848 | push [hSCManager] |
||
4849 | call [CreateServiceA] |
||
4850 | ; test eax, eax |
||
4851 | ; jnz .cont |
||
4852 | ; call [GetLastError] |
||
4853 | ; cmp eax, 431h ; ERROR_SERVICE_EXISTS |
||
4854 | ; jnz server_fail |
||
4855 | ; push 10030h |
||
4856 | ; push kiw0_drivername |
||
4857 | ; push [hSCManager] |
||
4858 | ; call [OpenServiceA] |
||
4859 | test eax, eax |
||
4860 | jz server_fail |
||
4861 | .cont: |
||
4862 | mov [hService], eax |
||
4863 | push ebx ; lpServiceArgVectors |
||
4864 | push ebx ; dwNumServiceArgs |
||
4865 | push eax |
||
4866 | call [StartServiceA] |
||
4867 | test eax, eax |
||
4868 | jz server_fail |
||
4869 | .driverok: |
||
4870 | ret |
||
4871 | |||
4872 | unload_kiw0: |
||
4873 | sub esp, 20h |
||
4874 | push esp |
||
4875 | push 1 ; SERVICE_CONTROL_STOP |
||
4876 | push [hService] |
||
4877 | call [ControlService] |
||
4878 | add esp, 20h |
||
4879 | push [hService] |
||
4880 | call [DeleteService] |
||
4881 | push [hService] |
||
4882 | call [CloseServiceHandle] |
||
4883 | ret |
||
4884 | |||
4885 | server_done: |
||
4886 | cmp [hService], 0 |
||
4887 | jz .skip_drv |
||
4888 | cmp [keep_loaded_driver], 0 |
||
4889 | jnz .skip_drv |
||
4890 | call unload_kiw0 |
||
4891 | push [hSCManager] |
||
4892 | call [CloseServiceHandle] |
||
4893 | .skip_drv: |
||
4894 | |||
4895 | else |
||
4896 | cmp edi, REQUIRED_DRIVER_VERSION |
||
4897 | jz load_kiw0.driverok |
||
4898 | call unload_kiw0 |
||
4899 | load_kiw0.load: |
||
4900 | mov esi, DrvLoadErr |
||
4901 | push eax |
||
4902 | mov eax, esp |
||
4903 | xor ecx, ecx |
||
4904 | push ecx ; lpdwDisposition |
||
4905 | push eax ; phkResult |
||
4906 | push ecx ; lpSecurityAttributes |
||
4907 | push 6 ; samDesired = KEY_SET_VALUE | KEY_CREATE_SUB_KEY |
||
4908 | push ecx ; dwOptions |
||
4909 | push ecx ; lpClass |
||
4910 | push ecx ; Reserved |
||
4911 | push DrvKey ; lpSubKey |
||
4912 | push 0x80000002 ; hKey = HKEY_LOCAL_MACHINE |
||
4913 | call [RegCreateKeyExA] |
||
4914 | test eax, eax |
||
4915 | jnz server_fail |
||
4916 | push esi |
||
4917 | mov esi, win32_path |
||
4918 | push esi |
||
4919 | call [lstrlenA] |
||
4920 | lea esi, [esi+eax-1] |
||
4921 | lea edi, [esi+4] |
||
4922 | mov ecx, eax |
||
4923 | push edi |
||
4924 | std |
||
4925 | rep movsb |
||
4926 | cld |
||
4927 | mov dword [edi-3], '\??\' |
||
4928 | pop edi |
||
4929 | sub edi, inifilenamesize-2 |
||
4930 | mov esi, kiw0filename |
||
4931 | mov ecx, kiw0filenamesize |
||
4932 | rep movsb |
||
4933 | sub edi, win32_path+1 |
||
4934 | mov [drvpathlen], edi |
||
4935 | pop esi |
||
4936 | mov edi, DrvKeyValues |
||
4937 | .write_values: |
||
4938 | push dword [edi+12] ; cbData |
||
4939 | push dword [edi+8] ; lpData |
||
4940 | push dword [edi+4] ; dwType |
||
4941 | push 0 ; Reserved |
||
4942 | push dword [edi] ; lpValueName |
||
4943 | push dword [esp+20] ; hKey |
||
4944 | call [RegSetValueExA] |
||
4945 | test eax, eax |
||
4946 | jz @f |
||
4947 | call [RegCloseKey] |
||
4948 | .del_fail: |
||
4949 | push DrvKey |
||
4950 | push 0x80000002 |
||
4951 | call [RegDeleteKeyA] |
||
4952 | jmp server_fail |
||
4953 | @@: |
||
4954 | add edi, 16 |
||
4955 | cmp dword [edi], 0 |
||
4956 | jnz .write_values |
||
4957 | call [RegCloseKey] |
||
4958 | ; NtLoadDriver and NtUnloadDriver require SeLoadPrivilege enabled. |
||
4959 | ; But I found that if user has this privilege, then it is already enabled |
||
4960 | ; (unlike things like SeShutdownPrivilege - in such cases there must be |
||
4961 | ; additional code with AdjustTokenPrivileges(OpenProcessToken(...),LookupPrivilegeValue(...),...)) |
||
4962 | push ntdll_name |
||
4963 | call [GetModuleHandleA] |
||
4964 | push aNtLoadDriver |
||
4965 | push eax |
||
4966 | call [GetProcAddress] |
||
4967 | push DrvKeySys |
||
4968 | call eax |
||
4969 | test eax, eax |
||
4970 | js .del_fail |
||
4971 | load_kiw0.driverok: |
||
4972 | mov [bDriverLoaded], 1 |
||
4973 | ret |
||
4974 | |||
4975 | unload_kiw0: |
||
4976 | ; Unload and delete driver kiw0.sys |
||
4977 | ; 1. Unload |
||
4978 | push ntdll_name |
||
4979 | call [GetModuleHandleA] |
||
4980 | push aNtUnloadDriver |
||
4981 | push eax |
||
4982 | call [GetProcAddress] |
||
4983 | push DrvKeySys |
||
4984 | call eax |
||
4985 | ; 2. When the kernel loads driver, it (kernel) creates auxiliary reg keys |
||
4986 | ; in HKLM\System\CurrentControlSet\Enum\ |
||
4987 | ; (for legacy drivers such as kiw0, this is Root\LEGACY_KIW0\ |
||
4988 | ; To delete this key and possibly reenumerate, call umpnpmgr.DeleteServicePlugPlayRegKeys |
||
4989 | ; In Win2k the library umpnpmgr.dll doesn't export this function, |
||
4990 | ; but under Win2k there is impossible to delete this key, because it is still opened by the kernel |
||
4991 | mov esi, aCannotLoadDll |
||
4992 | push umpnpmgr_name |
||
4993 | call [LoadLibraryA] |
||
4994 | test eax, eax |
||
4995 | jz .nodll |
||
4996 | push eax |
||
4997 | push umpnpmgr_uninst |
||
4998 | push eax |
||
4999 | call [GetProcAddress] |
||
5000 | test eax, eax |
||
5001 | jz @f |
||
5002 | push kiw0_unicode |
||
5003 | call eax |
||
5004 | @@: |
||
5005 | call [FreeLibrary] |
||
5006 | .nodll: |
||
5007 | ; 3. Delete main registry key, HKLM\System\CurrentControlSet\Services\kiw0 |
||
5008 | ; (and created by the kernel subkey Enum) |
||
5009 | push DrvKeyEnum |
||
5010 | push 0x80000002 |
||
5011 | call [RegDeleteKeyA] |
||
5012 | push DrvKey |
||
5013 | push 0x80000002 |
||
5014 | call [RegDeleteKeyA] |
||
5015 | .ret: |
||
5016 | ret |
||
5017 | |||
5018 | server_done: |
||
5019 | cmp [bDriverLoaded], 0 |
||
5020 | jz .skip_drv |
||
5021 | cmp [keep_loaded_driver], 0 |
||
5022 | jnz .skip_drv |
||
5023 | call unload_kiw0 |
||
5024 | .skip_drv: |
||
5025 | end if |
||
5026 | |||
5027 | cmp [bIs9x], 0 |
||
5028 | jz server_done_perf |
||
5029 | mov eax, [shared_data] |
||
5030 | cmp [eax+shared_data_struc.b9xPerfInited], 0 |
||
5031 | jz server_done_perf |
||
5032 | if ~idletime_via_ring0 |
||
5033 | push eax |
||
5034 | push esp ; phkResult |
||
5035 | push 1 ; samDesired = KEY_QUERY_VALUE |
||
5036 | push ebx ; ulOptions |
||
5037 | push perfend ; lpSubKey |
||
5038 | push 80000006h ; hKey = HKEY_DYN_DATA |
||
5039 | call [RegOpenKeyExA] |
||
5040 | pop esi |
||
5041 | test eax, eax |
||
5042 | jnz server_done_perf |
||
5043 | push eax |
||
5044 | mov eax, esp |
||
5045 | push 4 |
||
5046 | push esp ; lpcbData |
||
5047 | push eax ; lpData |
||
5048 | push ebx ; lpType |
||
5049 | push ebx ; lpReserved |
||
5050 | push perfval ; lpValueName |
||
5051 | push esi ; hKey |
||
5052 | call [RegQueryValueExA] |
||
5053 | pop ecx |
||
5054 | pop ecx |
||
5055 | push esi |
||
5056 | call [RegCloseKey] |
||
5057 | end if |
||
5058 | server_done_perf: |
||
5059 | push ebx |
||
5060 | call [ExitProcess] |
||
5061 | |||
5062 | PlaySoundA_delayed_imp: |
||
5063 | push winmm_name |
||
5064 | call [LoadLibraryA] |
||
5065 | test eax, eax |
||
5066 | jz .fail |
||
5067 | push eax |
||
5068 | push aPlaySoundA |
||
5069 | push eax |
||
5070 | call [GetProcAddress] |
||
5071 | pop ecx |
||
5072 | test eax, eax |
||
5073 | jz .fail_free |
||
5074 | mov [PlaySoundA], eax |
||
5075 | jmp eax |
||
5076 | .fail_free: |
||
5077 | push ecx |
||
5078 | call [FreeLibrary] |
||
5079 | .fail: |
||
5080 | mov [PlaySoundA], @f |
||
5081 | @@: |
||
5082 | xor eax, eax |
||
5083 | ret 12 |
||
5084 | |||
5085 | init_dll: |
||
5086 | push dword [esp+4] |
||
5087 | call [LoadLibraryA] |
||
5088 | xchg edi, eax |
||
5089 | mov esi, [esp+8] |
||
5090 | @@: |
||
5091 | lodsd |
||
5092 | test eax, eax |
||
5093 | jz @f |
||
5094 | add eax, 0x400002 |
||
5095 | push eax |
||
5096 | push edi |
||
5097 | call [GetProcAddress] |
||
5098 | mov [esi-4], eax |
||
5099 | jmp @b |
||
5100 | @@: |
||
5101 | ret 8 |
||
5102 | |||
5103 | init_MessageBox: |
||
5104 | cmp [MessageBoxA], rva MessageBoxA_thunk |
||
5105 | jnz @f |
||
5106 | push user32_thunks |
||
5107 | push user32_name |
||
5108 | call init_dll |
||
5109 | @@: |
||
5110 | ret |
||
5111 | |||
5112 | DuplicateMyHandle: |
||
5113 | jecxz @f |
||
5114 | push 2 ; DUPLICATE_SAME_ACCESS |
||
5115 | push ebx |
||
5116 | push ebx |
||
5117 | push eax |
||
5118 | push [hProcess] |
||
5119 | push ecx |
||
5120 | call [GetCurrentProcess] |
||
5121 | push eax |
||
5122 | call [DuplicateHandle] |
||
5123 | ret |
||
5124 | @@: |
||
5125 | mov [eax], ecx |
||
5126 | ret |
||
5127 | |||
5128 | shmem_load: |
||
5129 | mov edx, [eax+shmem_proc_descr.end] |
||
5130 | mov ecx, [eax+shmem_proc_descr.ptr] |
||
5131 | sub edx, ecx |
||
5132 | push eax ecx edx |
||
5133 | push eax |
||
5134 | push esp |
||
5135 | push 2 ; PAGE_READONLY |
||
5136 | push edx |
||
5137 | push ecx |
||
5138 | push [esi+shmem_item.hOwner] |
||
5139 | call [VirtualProtectEx] |
||
5140 | pop eax |
||
5141 | pop edx ecx eax |
||
5142 | push ebx |
||
5143 | push edx |
||
5144 | push [esi+shmem_item.ptr] |
||
5145 | push ecx |
||
5146 | push [esi+shmem_item.hOwner] |
||
5147 | call [ReadProcessMemory] |
||
5148 | mov [esi+shmem_item.hOwner], ebx |
||
5149 | mov [esi+shmem_item.pOwner], ebx |
||
5150 | ret |
||
5151 | |||
5152 | shmem_free_item: |
||
5153 | mov eax, [esi+shmem_item.next] |
||
5154 | mov ecx, [esi+shmem_item.prev] |
||
5155 | mov [eax+shmem_item.prev], ecx |
||
5156 | mov [ecx+shmem_item.next], eax |
||
5157 | push [esi+shmem_item.ptr] |
||
5158 | call free_big |
||
5159 | push esi |
||
5160 | call free |
||
5161 | ret |
||
5162 | |||
5163 | include 'i40emul.inc' |
||
5164 | |||
5165 | section '.rdata' data readable |
||
5166 | |||
5167 | data import |
||
5168 | macro thunk a { |
||
5169 | a#_thunk:dw 0 |
||
5170 | db `a,0} |
||
5171 | dd 0,0,0, rva kernel32_name, rva kernel32_thunks |
||
5172 | ; dd 0,0,0, rva user32_name, rva user32_thunks |
||
5173 | ; dd 0,0,0, rva gdi32_name, rva gdi32_thunks |
||
5174 | ; dd 0,0,0, rva comdlg32_name, rva comdlg32_thunks |
||
5175 | dd 0,0,0, rva advapi32_name, rva advapi32_thunks |
||
5176 | ; dd 0,0,0, rva winmm_name, rva winmm_thunks |
||
5177 | dd 0,0,0,0,0 |
||
5178 | kernel32_name db 'kernel32.dll',0 |
||
5179 | user32_name db 'user32.dll',0 |
||
5180 | gdi32_name db 'gdi32.dll',0 |
||
5181 | ntdll_name db 'ntdll.dll',0 |
||
5182 | comdlg32_name db 'comdlg32.dll',0 |
||
5183 | advapi32_name db 'advapi32.dll',0 |
||
5184 | winmm_name db 'winmm.dll',0 |
||
5185 | ;winsock_name db 'wsock32.dll',0 |
||
5186 | kernel32_thunks: |
||
5187 | CreateFileA dd rva CreateFileA_thunk |
||
5188 | CloseHandle dd rva CloseHandle_thunk |
||
5189 | CreateFileMappingA dd rva CreateFileMappingA_thunk |
||
5190 | OpenFileMappingA dd rva OpenFileMappingA_thunk |
||
5191 | MapViewOfFile dd rva MapViewOfFile_thunk |
||
5192 | UnmapViewOfFile dd rva UnmapViewOfFile_thunk |
||
5193 | ReadFile dd rva ReadFile_thunk |
||
5194 | WriteFile dd rva WriteFile_thunk |
||
5195 | GetFileSize dd rva GetFileSize_thunk |
||
5196 | SetEndOfFile dd rva SetEndOfFile_thunk |
||
5197 | VirtualAlloc dd rva VirtualAlloc_thunk |
||
5198 | VirtualFree dd rva VirtualFree_thunk |
||
5199 | VirtualProtect dd rva VirtualProtect_thunk |
||
5200 | VirtualProtectEx dd rva VirtualProtectEx_thunk |
||
5201 | SetFilePointer dd rva SetFilePointer_thunk |
||
5202 | ExitProcess dd rva ExitProcess_thunk |
||
5203 | ExitThread dd rva ExitThread_thunk |
||
5204 | CreateProcessA dd rva CreateProcessA_thunk |
||
5205 | CreateThread dd rva CreateThread_thunk |
||
5206 | TerminateThread dd rva TerminateThread_thunk |
||
5207 | GetCommandLineA dd rva GetCommandLineA_thunk |
||
5208 | ReadProcessMemory dd rva ReadProcessMemory_thunk |
||
5209 | WriteProcessMemory dd rva WriteProcessMemory_thunk |
||
5210 | WaitForDebugEvent dd rva WaitForDebugEvent_thunk |
||
5211 | ContinueDebugEvent dd rva ContinueDebugEvent_thunk |
||
5212 | SuspendThread dd rva SuspendThread_thunk |
||
5213 | ResumeThread dd rva ResumeThread_thunk |
||
5214 | GetThreadContext dd rva GetThreadContext_thunk |
||
5215 | SetThreadContext dd rva SetThreadContext_thunk |
||
5216 | GetProcessHeap dd rva GetProcessHeap_thunk |
||
5217 | HeapAlloc dd rva HeapAlloc_thunk |
||
5218 | HeapReAlloc dd rva HeapReAlloc_thunk |
||
5219 | HeapFree dd rva HeapFree_thunk |
||
5220 | Sleep dd rva Sleep_thunk |
||
5221 | GetLocalTime dd rva GetLocalTime_thunk |
||
5222 | SetFileTime dd rva SetFileTime_thunk |
||
5223 | GetCurrentDirectoryA dd rva GetCurrentDirectoryA_thunk |
||
5224 | SetCurrentDirectoryA dd rva SetCurrentDirectoryA_thunk |
||
5225 | GetTickCount dd rva GetTickCount_thunk |
||
5226 | GetCurrentProcess dd rva GetCurrentProcess_thunk |
||
5227 | GetPrivateProfileStringA dd rva GetPrivateProfileStringA_thunk |
||
5228 | GetPrivateProfileIntA dd rva GetPrivateProfileIntA_thunk |
||
5229 | lstrcpyA dd rva lstrcpyA_thunk |
||
5230 | lstrcpynA dd rva lstrcpynA_thunk |
||
5231 | lstrcatA dd rva lstrcatA_thunk |
||
5232 | lstrlenA dd rva lstrlenA_thunk |
||
5233 | lstrcmpA dd rva lstrcmpA_thunk |
||
5234 | GetFileAttributesA dd rva GetFileAttributesA_thunk |
||
5235 | SetFileAttributesA dd rva SetFileAttributesA_thunk |
||
5236 | GetModuleFileNameA dd rva GetModuleFileNameA_thunk |
||
5237 | GetLastError dd rva GetLastError_thunk |
||
5238 | CreateMutexA dd rva CreateMutexA_thunk |
||
5239 | CreateEventA dd rva CreateEventA_thunk |
||
5240 | SetEvent dd rva SetEvent_thunk |
||
5241 | DuplicateHandle dd rva DuplicateHandle_thunk |
||
5242 | WaitForSingleObject dd rva WaitForSingleObject_thunk |
||
5243 | ReleaseMutex dd rva ReleaseMutex_thunk |
||
5244 | GetVersion dd rva GetVersion_thunk |
||
5245 | GetModuleHandleA dd rva GetModuleHandleA_thunk |
||
5246 | GetProcAddress dd rva GetProcAddress_thunk |
||
5247 | GetCurrentThreadId dd rva GetCurrentThreadId_thunk |
||
5248 | GetStartupInfoA dd rva GetStartupInfoA_thunk |
||
5249 | FindFirstFileA dd rva FindFirstFileA_thunk |
||
5250 | FindNextFileA dd rva FindNextFileA_thunk |
||
5251 | FindClose dd rva FindClose_thunk |
||
5252 | FileTimeToDosDateTime dd rva FileTimeToDosDateTime_thunk |
||
5253 | DeleteFileA dd rva DeleteFileA_thunk |
||
5254 | DeviceIoControl dd rva DeviceIoControl_thunk |
||
5255 | MultiByteToWideChar dd rva MultiByteToWideChar_thunk |
||
5256 | FileTimeToSystemTime dd rva FileTimeToSystemTime_thunk |
||
5257 | SystemTimeToFileTime dd rva SystemTimeToFileTime_thunk |
||
5258 | GetFullPathNameA dd rva GetFullPathNameA_thunk |
||
5259 | CompareStringA dd rva CompareStringA_thunk |
||
5260 | GlobalMemoryStatus dd rva GlobalMemoryStatus_thunk |
||
5261 | InitializeCriticalSection dd rva InitializeCriticalSection_thunk |
||
5262 | EnterCriticalSection dd rva EnterCriticalSection_thunk |
||
5263 | LeaveCriticalSection dd rva LeaveCriticalSection_thunk |
||
5264 | CreateDirectoryA dd rva CreateDirectoryA_thunk |
||
5265 | RemoveDirectoryA dd rva RemoveDirectoryA_thunk |
||
5266 | LoadLibraryA dd rva LoadLibraryA_thunk |
||
5267 | FreeLibrary dd rva FreeLibrary_thunk |
||
5268 | dw 0 |
||
5269 | thunk CreateFileA |
||
5270 | thunk CloseHandle |
||
5271 | thunk CreateFileMappingA |
||
5272 | thunk OpenFileMappingA |
||
5273 | thunk MapViewOfFile |
||
5274 | thunk UnmapViewOfFile |
||
5275 | thunk ReadFile |
||
5276 | thunk WriteFile |
||
5277 | thunk GetFileSize |
||
5278 | thunk SetEndOfFile |
||
5279 | thunk VirtualAlloc |
||
5280 | thunk VirtualFree |
||
5281 | thunk VirtualProtect |
||
5282 | thunk VirtualProtectEx |
||
5283 | thunk SetFilePointer |
||
5284 | thunk ExitProcess |
||
5285 | thunk ExitThread |
||
5286 | thunk CreateProcessA |
||
5287 | thunk CreateThread |
||
5288 | thunk TerminateThread |
||
5289 | thunk GetCurrentProcess |
||
5290 | thunk GetCommandLineA |
||
5291 | thunk ReadProcessMemory |
||
5292 | thunk WriteProcessMemory |
||
5293 | thunk WaitForDebugEvent |
||
5294 | thunk ContinueDebugEvent |
||
5295 | thunk SuspendThread |
||
5296 | thunk ResumeThread |
||
5297 | thunk GetThreadContext |
||
5298 | thunk SetThreadContext |
||
5299 | thunk GetProcessHeap |
||
5300 | thunk HeapAlloc |
||
5301 | thunk HeapReAlloc |
||
5302 | thunk HeapFree |
||
5303 | thunk Sleep |
||
5304 | thunk GetLocalTime |
||
5305 | thunk SetFileTime |
||
5306 | thunk GetCurrentDirectoryA |
||
5307 | thunk SetCurrentDirectoryA |
||
5308 | thunk GetTickCount |
||
5309 | thunk GetPrivateProfileStringA |
||
5310 | thunk GetPrivateProfileIntA |
||
5311 | thunk lstrcpyA |
||
5312 | thunk lstrcpynA |
||
5313 | thunk lstrcatA |
||
5314 | thunk lstrlenA |
||
5315 | thunk lstrcmpA |
||
5316 | thunk GetFileAttributesA |
||
5317 | thunk SetFileAttributesA |
||
5318 | thunk GetModuleFileNameA |
||
5319 | thunk GetLastError |
||
5320 | thunk CreateMutexA |
||
5321 | thunk CreateEventA |
||
5322 | thunk SetEvent |
||
5323 | thunk DuplicateHandle |
||
5324 | thunk WaitForSingleObject |
||
5325 | thunk ReleaseMutex |
||
5326 | thunk GetVersion |
||
5327 | thunk GetModuleHandleA |
||
5328 | thunk GetProcAddress |
||
5329 | thunk GetCurrentThreadId |
||
5330 | thunk GetStartupInfoA |
||
5331 | thunk FindFirstFileA |
||
5332 | thunk FindNextFileA |
||
5333 | thunk FindClose |
||
5334 | thunk CharToOemA |
||
5335 | thunk OemToCharA |
||
5336 | thunk FileTimeToDosDateTime |
||
5337 | thunk DeleteFileA |
||
5338 | thunk DeviceIoControl |
||
5339 | thunk MultiByteToWideChar |
||
5340 | thunk FileTimeToSystemTime |
||
5341 | thunk SystemTimeToFileTime |
||
5342 | thunk GetFullPathNameA |
||
5343 | thunk CompareStringA |
||
5344 | thunk GlobalMemoryStatus |
||
5345 | thunk InitializeCriticalSection |
||
5346 | thunk EnterCriticalSection |
||
5347 | thunk LeaveCriticalSection |
||
5348 | thunk CreateDirectoryA |
||
5349 | thunk RemoveDirectoryA |
||
5350 | thunk LoadLibraryA |
||
5351 | thunk FreeLibrary |
||
5352 | aNtSetLdtEntries db 'NtSetLdtEntries',0 |
||
5353 | if ~driver_via_scm |
||
5354 | aNtLoadDriver db 'NtLoadDriver',0 |
||
5355 | aNtUnloadDriver db 'NtUnloadDriver',0 |
||
5356 | end if |
||
5357 | align 4 |
||
5358 | advapi32_thunks: |
||
5359 | if ~driver_via_scm |
||
5360 | RegCreateKeyExA dd rva RegCreateKeyExA_thunk |
||
5361 | RegDeleteKeyA dd rva RegDeleteKeyA_thunk |
||
5362 | end if |
||
5363 | RegOpenKeyExA dd rva RegOpenKeyExA_thunk |
||
5364 | RegCloseKey dd rva RegCloseKey_thunk |
||
5365 | RegQueryValueExA dd rva RegQueryValueExA_thunk |
||
5366 | RegSetValueExA dd rva RegSetValueExA_thunk |
||
5367 | OpenSCManagerA dd rva OpenSCManagerA_thunk |
||
5368 | CreateServiceA dd rva CreateServiceA_thunk |
||
5369 | OpenServiceA dd rva OpenServiceA_thunk |
||
5370 | StartServiceA dd rva StartServiceA_thunk |
||
5371 | ControlService dd rva ControlService_thunk |
||
5372 | DeleteService dd rva DeleteService_thunk |
||
5373 | CloseServiceHandle dd rva CloseServiceHandle_thunk |
||
5374 | dw 0 |
||
5375 | if ~driver_via_scm |
||
5376 | thunk RegCreateKeyExA |
||
5377 | thunk RegDeleteKeyA |
||
5378 | end if |
||
5379 | thunk RegOpenKeyExA |
||
5380 | thunk RegCloseKey |
||
5381 | thunk RegQueryValueExA |
||
5382 | thunk RegSetValueExA |
||
5383 | thunk OpenSCManagerA |
||
5384 | thunk CreateServiceA |
||
5385 | thunk OpenServiceA |
||
5386 | thunk StartServiceA |
||
5387 | thunk ControlService |
||
5388 | thunk DeleteService |
||
5389 | thunk CloseServiceHandle |
||
5390 | ;winmm_thunks: |
||
5391 | ;PlaySoundA dd rva PlaySoundA_thunk |
||
5392 | ; dw 0 |
||
5393 | ;thunk PlaySoundA |
||
5394 | end data |
||
5395 | |||
5396 | aGetOpenFileNameA db 'GetOpenFileNameA',0 |
||
5397 | aPlaySoundA db 'PlaySoundA',0 |
||
5398 | |||
5399 | align 4 |
||
5400 | ;data resource from 'klbrico.res' |
||
5401 | ;end data |
||
5402 | data resource |
||
5403 | rsrcdata: |
||
5404 | ; only icon resource from file 'KlbrInWin.ico' |
||
5405 | ; for graphics thanks to goglus, Leency, Heavyiron |
||
5406 | iconfile equ 'KlbrInWin.ico' |
||
5407 | |||
5408 | virtual at 0 |
||
5409 | ; load .ico header |
||
5410 | file iconfile:0,6 |
||
5411 | load .idReserved word from 0 |
||
5412 | load .idType word from 2 |
||
5413 | load .idCount word from 4 |
||
5414 | if (.idReserved <> 0) | (.idType <> 1) |
||
5415 | error invalid icon file |
||
5416 | end if |
||
5417 | end virtual |
||
5418 | |||
5419 | ; root resource directory |
||
5420 | dd 0, 0, 0 |
||
5421 | dw 0, 2 ; 2 entries by id |
||
5422 | dd 3, (.icon1 - rsrcdata) or 80000000h ; entry 1: RT_ICON |
||
5423 | dd 14, (.gicon1 - rsrcdata) or 80000000h ; entry 2: RT_GROUP_ICON |
||
5424 | ; level-1 resource directory for RT_ICON |
||
5425 | .icon1: |
||
5426 | dd 0, 0, 0 |
||
5427 | dw 0, .idCount ; .idCount entries by id |
||
5428 | repeat .idCount |
||
5429 | dd %, ((.icon2 - rsrcdata) + 18h*(%-1)) or 80000000h |
||
5430 | end repeat |
||
5431 | ; level-1 resource directory for RT_GROUP_ICON |
||
5432 | .gicon1: |
||
5433 | dd 0, 0, 0 |
||
5434 | dw 0, 1 ; 1 entry by id |
||
5435 | dd 1, (.gicon2 - rsrcdata) or 80000000h |
||
5436 | ; level-2 resource directories for RT_ICON |
||
5437 | .icon2: |
||
5438 | repeat .idCount |
||
5439 | dd 0, 0, 0 |
||
5440 | dw 0, 1 ; 1 entry by id |
||
5441 | dd 0, (.icon3 - rsrcdata) + 10h*(%-1) |
||
5442 | end repeat |
||
5443 | ; level-2 resource directory for RT_GROUP_ICON |
||
5444 | .gicon2: |
||
5445 | dd 0, 0, 0 |
||
5446 | dw 0, 1 ; 1 entry by id |
||
5447 | dd 0, (.gicon3 - rsrcdata) |
||
5448 | ; leaf entries for RT_ICON |
||
5449 | .icon3: |
||
5450 | .a = rva .icons |
||
5451 | repeat .idCount |
||
5452 | virtual at 0 |
||
5453 | file iconfile:6+16*(%-1)+8,4 |
||
5454 | load .dwBytesInRes dword from 0 |
||
5455 | end virtual |
||
5456 | dd .a, .dwBytesInRes, 0, 0 |
||
5457 | .a = (.a + .dwBytesInRes + 3) and not 3 |
||
5458 | end repeat |
||
5459 | ; leaf entry for RT_GROUP_ICON |
||
5460 | .gicon3: |
||
5461 | dd rva .gicon, .gicon_end - .gicon, 0, 0 |
||
5462 | ; icon data |
||
5463 | .icons: |
||
5464 | repeat .idCount |
||
5465 | virtual at 0 |
||
5466 | file iconfile:6+16*(%-1)+8,8 |
||
5467 | load .dwBytesInRes dword from 0 |
||
5468 | load .dwImageOffset dword from 4 |
||
5469 | end virtual |
||
5470 | file iconfile:.dwImageOffset,.dwBytesInRes |
||
5471 | while .dwBytesInRes and 3 |
||
5472 | .dwBytesInRes = .dwBytesInRes + 1 |
||
5473 | db 0 |
||
5474 | end while |
||
5475 | end repeat |
||
5476 | .gicon: |
||
5477 | dw 0, 1, .idCount ; .idCount images |
||
5478 | repeat .idCount |
||
5479 | file iconfile:6+16*(%-1),12 |
||
5480 | dw % |
||
5481 | end repeat |
||
5482 | .gicon_end: |
||
5483 | end data |
||
5484 | |||
5485 | data 9 |
||
5486 | dd tls_init_start |
||
5487 | dd tls_init_end |
||
5488 | dd tls_index |
||
5489 | dd 0 |
||
5490 | dd 0 |
||
5491 | dd 0 |
||
5492 | end data |
||
5493 | |||
5494 | virtual at 0 |
||
5495 | tls: |
||
5496 | ._cs dw ? |
||
5497 | ._ds dw ? |
||
5498 | ._esp dd ? |
||
5499 | ._eip dd ? |
||
5500 | ._fs dw ? |
||
5501 | dw ? ; align |
||
5502 | .exc_code dd ? |
||
5503 | .exc_data dd ? |
||
5504 | .message_mask dd ? |
||
5505 | .lpShapeData dd ? |
||
5506 | .scale dd ? |
||
5507 | .curdraw db ? |
||
5508 | |||
5509 | .uninit_size = .size - $ |
||
5510 | |||
5511 | .showwnd db ? |
||
5512 | .bFirstMouseMove db ? |
||
5513 | .bActive db ? |
||
5514 | .hWnd dd ? |
||
5515 | .hCursor dd ? |
||
5516 | .buttons dd ? |
||
5517 | .x_size dw ? |
||
5518 | .x_start dw ? |
||
5519 | .y_size dw ? |
||
5520 | .y_start dw ? |
||
5521 | .client_left dd ? |
||
5522 | .client_top dd ? |
||
5523 | .client_width dd ? |
||
5524 | .client_height dd ? |
||
5525 | .color_main dd ? |
||
5526 | .color_capt dd ? |
||
5527 | .color_border dd ? |
||
5528 | .caption dd ? |
||
5529 | .debuggees dd ? |
||
5530 | .translated_msg_code db ? |
||
5531 | .usescancode db ? |
||
5532 | .keybuflen db ? |
||
5533 | .butbuflen db ? |
||
5534 | .keybuffer rb 0x100 |
||
5535 | .butbuffer rd 0x100 |
||
5536 | .active_button dd ? |
||
5537 | .cur_slot dd ? |
||
5538 | .saved_fs0 dd ? |
||
5539 | .saved_fs4 dd ? |
||
5540 | .prev_snd_block dd ? |
||
5541 | .cur_dir dd ? |
||
5542 | .scroll dd ? |
||
5543 | .original_buttons db ? |
||
5544 | .current_buttons db ? |
||
5545 | dw ? |
||
5546 | .size = $ |
||
5547 | end virtual |
||
5548 | |||
5549 | align 4 |
||
5550 | ofn_arg_template: |
||
5551 | dw 1,-1 ; dlgVer,signature |
||
5552 | dd 0 ; helpId |
||
5553 | dd 0 ; exStyle |
||
5554 | dd 56000444h ; style |
||
5555 | dw 2 ; cDlgItems |
||
5556 | dw 0,0,275,28 ; x,y,cx,cy |
||
5557 | dw 0,0,0 ; menu,windowClass,title |
||
5558 | dw 8 ; pointsize |
||
5559 | dd 0 ; weight,italic,charset |
||
5560 | du 'MS Sans Serif',0 |
||
5561 | align 4 |
||
5562 | dd 0 ; helpId |
||
5563 | dd 0 ; exStyle |
||
5564 | dd 50010000h ; style |
||
5565 | dw 5,12,45,9 ; x,y,cx,cy |
||
5566 | dw -1 ; id |
||
5567 | dw 0 |
||
5568 | dw -1,82h ; windowClass |
||
5569 | du "Parameters:",0 |
||
5570 | dw 0 |
||
5571 | align 4 |
||
5572 | dd 0 |
||
5573 | dd 204h |
||
5574 | dd 50010080h |
||
5575 | dw 54,10,218,12 |
||
5576 | dw 23 |
||
5577 | dw 0 |
||
5578 | dw -1,81h |
||
5579 | dw 0 |
||
5580 | dw 0 |
||
5581 | |||
5582 | align 4 |
||
5583 | _1193180 dd 1193180 |
||
5584 | _100 dd 100 |
||
5585 | |||
5586 | kontrOctave: |
||
5587 | ; note that values 0, D,E,F must not be used, but 0 is used (e.g. by icon2) |
||
5588 | dw 0xC3FB, 0x4742, 0x4342, 0x3F7C, 0x3BEC, 0x388F, 0x3562, 0x3264 |
||
5589 | dw 0x2F8F, 0x2CE4, 0x2A5F, 0x2802, 0x25BF, 0xFDA, 0, 0x19 |
||
5590 | |||
5591 | dir0: |
||
5592 | db 'HARDDISK ',10h |
||
5593 | db 'RAMDISK ',10h |
||
5594 | dir1 db 'FIRST ',10h |
||
5595 | |||
5596 | path_begin: |
||
5597 | db 1,2,'RD' |
||
5598 | db 1,7,'RAMDISK' |
||
5599 | db 2,2,'FD' |
||
5600 | db 2,11,'FLOPPYDI.SK' |
||
5601 | db 4,3,'HD0' |
||
5602 | db 5,3,'HD1' |
||
5603 | db 6,3,'HD2' |
||
5604 | db 7,3,'HD3' |
||
5605 | db 3,2,'HD' |
||
5606 | db 3,8,'HARDDISK' |
||
5607 | db 0 |
||
5608 | |||
5609 | |||
5610 | ; align 4 |
||
5611 | ; winsock_imports: |
||
5612 | ; WSAStartup dd WSAStartup_name |
||
5613 | ; WSACleanup dd WSACleanup_name |
||
5614 | ; socket dd socket_name |
||
5615 | ; closesocket dd closesocket_name |
||
5616 | ; dd 0 |
||
5617 | |||
5618 | ; WSAStartup_name db 'WSAStartup',0 |
||
5619 | ; WSACleanup_name db 'WSACleanup',0 |
||
5620 | ; socket_name db 'socket',0 |
||
5621 | ; closesocket_name db 'closesocket',0 |
||
5622 | |||
5623 | ofn_title db 'Select KolibriOS executable',0 |
||
5624 | dd -10 |
||
5625 | fileopenerr db 'Cannot open input file',0 |
||
5626 | dd -31 |
||
5627 | filereaderr db 'Input file read error',0 |
||
5628 | dd -31 |
||
5629 | notexe db 'Not KolibriOS executable!',0 |
||
5630 | dd -7 |
||
5631 | params_err db 'Parameters pointer is outside used memory!',0 |
||
5632 | dd -30 |
||
5633 | memerr db 'Not enough memory',0 |
||
5634 | dd -30 |
||
5635 | ldterr db 'Cannot allocate LDT selectors',0 |
||
5636 | idt_err db 'IDT limit too small',0 |
||
5637 | exceptionstr db 'Exception',0 |
||
5638 | excstr db 'Emulated process has caused an exception and will be terminated.',13,10 |
||
5639 | db 'Registers:',13,10 |
||
5640 | db 'EAX=%08X EBX=%08X ECX=%08X EDX=%08X',13,10 |
||
5641 | db 'ESI=%08X EDI=%08X ESP=%08X EBP=%08X',13,10 |
||
5642 | db 'EIP=%08X EFLAGS=%08X',0 |
||
5643 | nsm db 'Unsupported system function',0 |
||
5644 | notsupportedmsg db 'Emulated process has called unknown system function and will be terminated.',13,10 |
||
5645 | db 'Registers:',13,10 |
||
5646 | db 'EAX=%08X EBX=%08X ECX=%08X EDX=%08X',13,10 |
||
5647 | db 'ESI=%08X EDI=%08X ESP=%08X EBP=%08X',13,10 |
||
5648 | db 'EIP=%08X EFLAGS=%08X',0 |
||
5649 | cpe db 'Cannot create process',0 |
||
5650 | aConfirm db 'Ïîäòâåðæäåíèå',0 |
||
5651 | BgrQuestionText db 'Ïðîãðàììà õî÷åò óñòàíîâèòü ôîí ðàáî÷åãî ñòîëà.',13,10 |
||
5652 | db 'Óñòàíîâèòü êàê ïîñòîÿííûé?',0 |
||
5653 | BgrFileErrorMsg db 'Cannot create background image file',0 |
||
5654 | dd -1 |
||
5655 | skinfileerr db 'Invalid skin file',0 |
||
5656 | vkerr db 'A running instance of KlbrInWin already exists, cannot continue',0 |
||
5657 | dd -1 |
||
5658 | no_partition db 'Partition is not defined',0 |
||
5659 | EnablePortsSyntaxErr db 'EnablePorts parameter: syntax error',0 |
||
5660 | DrvLoadErr db 'Cannot load driver',0 |
||
5661 | DrvOpenErr db 'Cannot send command to driver',0 |
||
5662 | PortsRangeErr db 'Sysfunction 46: invalid ports range',0 |
||
5663 | PortsNotEnabledErr db 'Sysfunction 46: attempt to allocate not enabled ports',0 |
||
5664 | PortsUsedErr db 'Sysfunction 46: attempt to allocate already used ports',0 |
||
5665 | PortsNotUsedErr db 'Sysfunction 46: attempt to free ports which were not allocated',0 |
||
5666 | |||
5667 | ;aPathInvalid db 'Path pointer is outside used memory and will be ignored',0 |
||
5668 | dd -2 |
||
5669 | aPathUnknown db 'Win32 path to program cannot be written as Kolibri path!',0 |
||
5670 | |||
5671 | aReadMSRDisabled db 'Emulated process tries to read MSR, and this is disabled in ini-file.',0 |
||
5672 | aNoMsr db 'Emulated process has tried to read invalid MSR and will be terminated',0 |
||
5673 | aInvFn64Call db 'Function 64 has been called after heap initialization, will fail.',0 |
||
5674 | aHeapNotInited db 'Attempt to work with uninitialized heap!',0 |
||
5675 | aInternalError db 'Internal error',0 |
||
5676 | aMallocFailed db 'Memory request failed!',0 |
||
5677 | aFreeInvalid db 'Attempt to free/realloc not allocated block!',0 |
||
5678 | aCannotLoadDll db 'Cannot load DLL',0 |
||
5679 | aUnknownReloc db 'Unknown relocation type',0 |
||
5680 | aExportsNotFound db 'DLL export table was not found!',0 |
||
5681 | aInvCursorData db 'Invalid cursor data',0 |
||
5682 | aOnlyOneCursor db 'Cursor data must contain only one cursor',0 |
||
5683 | aInvCursorDim db 'Cursor must be of size 32*32 pixels',0 |
||
5684 | aCursorFailed db 'Cursor creation failed',0 |
||
5685 | aCursorLimitExceeded db 'Cursors limit exceeded',0 |
||
5686 | aInvalidCursor db 'Invalid handle for delete_cursor!',0 |
||
5687 | aSound db 'SOUND',0 |
||
5688 | aInfinity db 'INFINITY',0 |
||
5689 | aUnknownDriver db 'Attempt to load unknown driver will fail',0 |
||
5690 | aCannotGetPci db 'Cannot get PCI BIOS parameters',0 |
||
5691 | ;aPciDisabled db 'Emulated process tries to enable PCI access, and this is disabled in ini-file.',0 |
||
5692 | dd -1 |
||
5693 | aInvalidColorDepth db 'Invalid ColorDepth parameter in ini-file',0 |
||
5694 | DSAErr db 'Access to DirectScreenArea outside real screen data causes an exception...',0 |
||
5695 | DSADisabled db 'The program has called sysfunction 61 (Direct Screen Access parameters),',10 |
||
5696 | db 'but Direct Screen Access is disabled in ini-file. The program will be terminated :(',0 |
||
5697 | aFailedToDeliverDebugMessage db 'Failed to deliver debug message',0 |
||
5698 | aInvalidDataForDR db 'Invalid data for 69.9, returning an error',0 |
||
5699 | aCannotDestroyShMem db 'Attempt to close not opened shared memory area',0 |
||
5700 | ;aWinsockInitErr db 'Cannot initialize Winsock DLL!',0 |
||
5701 | ;aSocketErr db 'Cannot allocate socket!',0 |
||
5702 | |||
5703 | inifilename db 'KlbrInWin.ini' |
||
5704 | null_string db 0 |
||
5705 | inifilenamesize = $ - inifilename |
||
5706 | kiw0filename db 'kiw0.sys',0 |
||
5707 | kiw0filenamesize = $ - kiw0filename |
||
5708 | kiw0_username db 'KlbrInWin ring-0 component',0 |
||
5709 | kiw0_drivername db 'kiw0',0 |
||
5710 | kiw0 db '\\.\kiw0',0 |
||
5711 | if ~driver_via_scm |
||
5712 | DrvKey db 'SYSTEM\CurrentControlSet\Services\kiw0',0 |
||
5713 | DrvKeyEnum db 'SYSTEM\CurrentControlSet\Services\kiw0\Enum',0 |
||
5714 | align 4 |
||
5715 | DrvKeySys: |
||
5716 | dw DrvKeySysLen-2, DrvKeySysLen |
||
5717 | dd @f |
||
5718 | @@ du '\REGISTRY\MACHINE\SYSTEM\CurrentControlSet\Services\kiw0',0 |
||
5719 | DrvKeySysLen = $ - @b |
||
5720 | aDisplayName db 'DisplayName',0 |
||
5721 | aType db 'Type',0 |
||
5722 | aStart db 'Start',0 |
||
5723 | addr3 dd 3 ; SERVICE_DEMAND_START |
||
5724 | aErrorControl db 'ErrorControl',0 |
||
5725 | aImagePath db 'ImagePath',0 |
||
5726 | |||
5727 | umpnpmgr_name db 'umpnpmgr.dll',0 |
||
5728 | umpnpmgr_uninst db 'DeleteServicePlugPlayRegKeys',0 |
||
5729 | kiw0_unicode du 'kiw0',0 |
||
5730 | end if |
||
5731 | |||
5732 | default_ramdisk db 'A:\',0 |
||
5733 | ramdisk_keyname db 'RamDisk',0 |
||
5734 | aDisk db 'Disk',0 |
||
5735 | aMain db 'Main',0 |
||
5736 | aFont1 db 'Font1',0 |
||
5737 | aFont2 db 'Font2',0 |
||
5738 | aSkin db 'Skin',0 |
||
5739 | aQuestions db 'Questions',0 |
||
5740 | aSetBgr db 'SetBgr',0 |
||
5741 | aSetup db 'sys_setup',0 |
||
5742 | aSoundFlag db 'sound_flag',0 |
||
5743 | aSoundVol db 'sound_vol',0 |
||
5744 | aSysLang db 'syslang',0 |
||
5745 | aKeyboard db 'keyboard',0 |
||
5746 | aEnablePorts db 'EnablePorts',0 |
||
5747 | aAllowReadMSR db 'AllowReadMSR',0 |
||
5748 | aAllowReadPCI db 'AllowReadPCI',0 |
||
5749 | aKeepLoadedDriver db 'KeepLoadedDriver',0 |
||
5750 | aDirectScreenAccess db 'DirectScreenAccess',0 |
||
5751 | aColorDepth db 'ColorDepth',0 |
||
5752 | aInvalidateTime db 'DSAInvalidateTime',0 |
||
5753 | |||
5754 | classname db 'KolibriInWin_WndClass',0 |
||
5755 | dd -30 |
||
5756 | createwnderr db 'Cannot create window!',0 |
||
5757 | |||
5758 | dd -30 |
||
5759 | shared_section_size = 8000h |
||
5760 | shared_section_create_err db 'Cannot create section for shared data!',0 |
||
5761 | shared_mutex_create_err db 'Cannot create mutex for shared data!',0 |
||
5762 | virtual at 0 |
||
5763 | shared_data_struc: |
||
5764 | .alloc_threads dd ? |
||
5765 | .num_threads dd ? |
||
5766 | .vk db ? |
||
5767 | .bAllowReadMSR db ? |
||
5768 | .b9xPerfInited db ? |
||
5769 | if idletime_via_ring0 |
||
5770 | .idlecount dd ? |
||
5771 | end if |
||
5772 | ; \begin{sys_setup} |
||
5773 | .sound_flag db ? |
||
5774 | .syslang dd ? |
||
5775 | .midi_base dw ? |
||
5776 | .cd_base db ? |
||
5777 | .hd_base db ? |
||
5778 | .sb16 dd ? |
||
5779 | .wss dd ? |
||
5780 | .fat32part dd ? |
||
5781 | .sound_dma dd ? |
||
5782 | .lba_read_enabled dd ? |
||
5783 | .pci_access_enabled dd ? |
||
5784 | .keyboard dw ? |
||
5785 | .mouse_speed_factor dw ? |
||
5786 | .mouse_delay dd ? |
||
5787 | ; \end{sys_setup} |
||
5788 | .pci_data_init db ? ; initialized? |
||
5789 | .bAllowReadPCI db ? |
||
5790 | .curport dw ? |
||
5791 | .cursocket dd ? |
||
5792 | .pci_bios_mj db ? ; major PCI BIOS version |
||
5793 | .pci_bios_mn db ? ; minor PCI BIOS version |
||
5794 | .pci_bios_lb db ? ; last PCI bus |
||
5795 | .pci_bios_pc db ? ; PCI characteristics |
||
5796 | .workarea_left dd ? |
||
5797 | .workarea_top dd ? |
||
5798 | .workarea_right dd ? |
||
5799 | .workarea_bottom dd ? |
||
5800 | .dwNewBgrTime dd ? |
||
5801 | .msg_board_count dd ? |
||
5802 | .msg_board_data rb 512 |
||
5803 | .active_process dd ? |
||
5804 | .cpuspeed dd ? |
||
5805 | .DisabledPorts rb 2000h |
||
5806 | .UsedIoMap rb 2000h |
||
5807 | num_cursors = 63 ; exclude standard arrow cursor, it is handled separately |
||
5808 | .cursors rd num_cursors*2 |
||
5809 | .threads: |
||
5810 | ; rept .alloc_threads |
||
5811 | .thread_id dd ? ; 0 for free slot |
||
5812 | .thread_ipc_mem dd ? |
||
5813 | .thread_ipc_size dd ? |
||
5814 | .win32_hBaseProcess dd ? ; this is handle for debugger! |
||
5815 | .win32_dwThreadId dd ? |
||
5816 | .hWnd dd ? |
||
5817 | .limit dd ? |
||
5818 | .name rb 12 |
||
5819 | .win32_hThread dd ? ; this is handle for debugger! |
||
5820 | .debugger_mem dd ? |
||
5821 | .win32_stack dd ? |
||
5822 | .shmem_list dd ? ; head of L1-list of shmem_proc_descr |
||
5823 | rd 2 |
||
5824 | end virtual |
||
5825 | |||
5826 | bgr_section_name db 'KolibriInWin_background',0 |
||
5827 | bgr_section_size = 0x160000+0x10 |
||
5828 | bgr_mutex_name db 'KolibriInWin_bgrmtx',0 |
||
5829 | bgrkeyname db 'Control Panel\Desktop',0 |
||
5830 | bgrstylevalue db 'WallpaperStyle',0 |
||
5831 | bgrtilevalue db 'TileWallpaper',0 |
||
5832 | bgrtempfilename db 'klbrbgr.bmp',0 |
||
5833 | bgrfilename db 'klbr_bgr.bmp',0 |
||
5834 | |||
5835 | newprg_section_name db 'KolibriInWin_newprg',0 |
||
5836 | |||
5837 | keycpu db 'HARDWARE\DESCRIPTION\System\CentralProcessor\0',0 |
||
5838 | keymhz db '~MHz',0 |
||
5839 | |||
5840 | aIdentifier db 'Identifier',0 |
||
5841 | aConfigurationData db 'Configuration Data',0 |
||
5842 | |||
5843 | perfstart db 'PerfStats\StartStat',0 |
||
5844 | perfget db 'PerfStats\StatData',0 |
||
5845 | perfend db 'PerfStats\StopStat',0 |
||
5846 | perfval db 'KERNEL\CPUUsage',0 |
||
5847 | aPerfInitFailed db 'Failed to init performance counter',0 |
||
5848 | |||
5849 | exccode2number: |
||
5850 | dd 0xC0000094 ; EXCEPTION_INT_DIVIDE_BY_ZERO |
||
5851 | db 0 ; #DE |
||
5852 | ; dd 0x80000004 ; EXCEPTION_SINGLE_STEP (handled separately) |
||
5853 | ; db 1 ; #DB |
||
5854 | dd 0x80000003 ; EXCEPTION_BREAKPOINT |
||
5855 | db 0xD ; #GP (yes, in Kolibri it's #GP, not #BP) |
||
5856 | dd 0xC0000095 ; EXCEPTION_INT_OVERFLOW |
||
5857 | db 4 ; #OF |
||
5858 | dd 0xC000008C ; EXCEPTION_ARRAY_BOUNDS_EXCEEDED |
||
5859 | db 5 ; #BR |
||
5860 | dd 0xC000001D ; EXCEPTION_ILLEGAL_INSTRUCTION |
||
5861 | db 6 ; #UD |
||
5862 | dd 0xC0000096 ; EXCEPTION_PRIV_INSTRUCTION |
||
5863 | db 0xD ; #GP |
||
5864 | dd 0xC0000005 ; EXCEPTION_ACCESS_VIOLATION |
||
5865 | db 0xE ; #PF |
||
5866 | dd 0x80000002 ; EXCEPTION_DATATYPE_MISALIGNMENT |
||
5867 | db 0x11 ; #AC |
||
5868 | dd 0xC000008D ; EXCEPTION_FLT_DENORMAL_OPERAND |
||
5869 | db 0x10 ; #MF |
||
5870 | dd 0xC000008E ; EXCEPTION_FLT_DIVIDE_BY_ZERO |
||
5871 | db 0x10 ; #MF |
||
5872 | dd 0xC000008F ; EXCEPTION_FLT_INEXACT_RESULT |
||
5873 | db 0x10 ; #MF |
||
5874 | dd 0xC0000090 ; EXCEPTION_FLT_INVALID_OPERATION |
||
5875 | db 0x10 ; #MF |
||
5876 | dd 0xC0000091 ; EXCEPTION_FLT_OVERFLOW |
||
5877 | db 0x10 ; #MF |
||
5878 | dd 0xC0000092 ; EXCEPTION_FLT_STACK_CHECK |
||
5879 | db 0x10 ; #MF |
||
5880 | dd 0xC0000093 ; EXCEPTION_FLT_UNDERFLOW |
||
5881 | db 0x10 ; #MF |
||
5882 | dd 0 |
||
5883 | |||
5884 | section '.data' data readable writable |
||
5885 | |||
5886 | user32_thunks: |
||
5887 | MessageBoxA dd rva MessageBoxA_thunk |
||
5888 | wsprintfA dd rva wsprintfA_thunk |
||
5889 | GetDC dd rva GetDC_thunk |
||
5890 | ReleaseDC dd rva ReleaseDC_thunk |
||
5891 | LoadIconA dd rva LoadIconA_thunk |
||
5892 | LoadCursorA dd rva LoadCursorA_thunk |
||
5893 | LoadImageA dd rva LoadImageA_thunk |
||
5894 | RegisterClassExA dd rva RegisterClassExA_thunk |
||
5895 | CreateWindowExA dd rva CreateWindowExA_thunk |
||
5896 | MoveWindow dd rva MoveWindow_thunk |
||
5897 | ShowWindow dd rva ShowWindow_thunk |
||
5898 | DefWindowProcA dd rva DefWindowProcA_thunk |
||
5899 | BeginPaint dd rva BeginPaint_thunk |
||
5900 | EndPaint dd rva EndPaint_thunk |
||
5901 | GetMessageA dd rva GetMessageA_thunk |
||
5902 | PeekMessageA dd rva PeekMessageA_thunk |
||
5903 | TranslateMessage dd rva TranslateMessage_thunk |
||
5904 | DispatchMessageA dd rva DispatchMessageA_thunk |
||
5905 | FillRect dd rva FillRect_thunk |
||
5906 | PostQuitMessage dd rva PostQuitMessage_thunk |
||
5907 | GetDesktopWindow dd rva GetDesktopWindow_thunk |
||
5908 | GetAsyncKeyState dd rva GetAsyncKeyState_thunk |
||
5909 | GetKeyboardState dd rva GetKeyboardState_thunk |
||
5910 | SetCapture dd rva SetCapture_thunk |
||
5911 | ReleaseCapture dd rva ReleaseCapture_thunk |
||
5912 | GetCursorPos dd rva GetCursorPos_thunk |
||
5913 | SetCursorPos dd rva SetCursorPos_thunk |
||
5914 | InvalidateRect dd rva InvalidateRect_thunk |
||
5915 | ValidateRect dd rva ValidateRect_thunk |
||
5916 | SetWindowRgn dd rva SetWindowRgn_thunk |
||
5917 | EnumThreadWindows dd rva EnumThreadWindows_thunk |
||
5918 | PostMessageA dd rva PostMessageA_thunk |
||
5919 | SendMessageTimeoutA dd rva SendMessageTimeoutA_thunk |
||
5920 | GetDlgItemTextA dd rva GetDlgItemTextA_thunk |
||
5921 | PaintDesktop dd rva PaintDesktop_thunk |
||
5922 | SystemParametersInfoA dd rva SystemParametersInfoA_thunk |
||
5923 | GetWindowRect dd rva GetWindowRect_thunk |
||
5924 | GetWindowPlacement dd rva GetWindowPlacement_thunk |
||
5925 | ;BringWindowToTop dd rva BringWindowToTop_thunk |
||
5926 | PostThreadMessageA dd rva PostThreadMessageA_thunk |
||
5927 | CharToOemA dd rva CharToOemA_thunk |
||
5928 | OemToCharA dd rva OemToCharA_thunk |
||
5929 | IsWindowVisible dd rva IsWindowVisible_thunk |
||
5930 | CreateIconFromResourceEx dd rva CreateIconFromResourceEx_thunk |
||
5931 | CreateIconIndirect dd rva CreateIconIndirect_thunk |
||
5932 | SetCursor dd rva SetCursor_thunk |
||
5933 | DestroyCursor dd rva DestroyCursor_thunk |
||
5934 | SetForegroundWindow dd rva SetForegroundWindow_thunk |
||
5935 | dw 0 |
||
5936 | thunk MessageBoxA |
||
5937 | thunk wsprintfA |
||
5938 | thunk GetDC |
||
5939 | thunk ReleaseDC |
||
5940 | thunk CreateCompatibleDC |
||
5941 | thunk LoadIconA |
||
5942 | thunk LoadCursorA |
||
5943 | thunk LoadImageA |
||
5944 | thunk RegisterClassExA |
||
5945 | thunk CreateWindowExA |
||
5946 | thunk MoveWindow |
||
5947 | thunk ShowWindow |
||
5948 | thunk DefWindowProcA |
||
5949 | thunk BeginPaint |
||
5950 | thunk EndPaint |
||
5951 | thunk GetMessageA |
||
5952 | thunk PeekMessageA |
||
5953 | thunk TranslateMessage |
||
5954 | thunk DispatchMessageA |
||
5955 | thunk PostQuitMessage |
||
5956 | thunk GetDesktopWindow |
||
5957 | thunk GetPixel |
||
5958 | thunk SetPixel |
||
5959 | thunk GetAsyncKeyState |
||
5960 | thunk GetKeyboardState |
||
5961 | thunk SetCapture |
||
5962 | thunk ReleaseCapture |
||
5963 | thunk GetCursorPos |
||
5964 | thunk SetCursorPos |
||
5965 | thunk InvalidateRect |
||
5966 | thunk ValidateRect |
||
5967 | thunk SetWindowRgn |
||
5968 | thunk PostMessageA |
||
5969 | thunk SendMessageTimeoutA |
||
5970 | thunk EnumThreadWindows |
||
5971 | thunk GetDlgItemTextA |
||
5972 | thunk PaintDesktop |
||
5973 | thunk SystemParametersInfoA |
||
5974 | thunk GetWindowRect |
||
5975 | thunk GetWindowPlacement |
||
5976 | ;thunk BringWindowToTop |
||
5977 | thunk PostThreadMessageA |
||
5978 | thunk IsWindowVisible |
||
5979 | thunk CreateIconFromResourceEx |
||
5980 | thunk CreateIconIndirect |
||
5981 | thunk SetCursor |
||
5982 | thunk DestroyCursor |
||
5983 | thunk SetForegroundWindow |
||
5984 | gdi32_thunks: |
||
5985 | SetDIBitsToDevice dd rva SetDIBitsToDevice_thunk |
||
5986 | GetDIBits dd rva GetDIBits_thunk |
||
5987 | CreatePen dd rva CreatePen_thunk |
||
5988 | SelectObject dd rva SelectObject_thunk |
||
5989 | DeleteObject dd rva DeleteObject_thunk |
||
5990 | CreateSolidBrush dd rva CreateSolidBrush_thunk |
||
5991 | CreateBitmap dd rva CreateBitmap_thunk |
||
5992 | CreateCompatibleDC dd rva CreateCompatibleDC_thunk |
||
5993 | CreateCompatibleBitmap dd rva CreateCompatibleBitmap_thunk |
||
5994 | BitBlt dd rva BitBlt_thunk |
||
5995 | MoveToEx dd rva MoveToEx_thunk |
||
5996 | LineTo dd rva LineTo_thunk |
||
5997 | GetDeviceCaps dd rva GetDeviceCaps_thunk |
||
5998 | GetPixel dd rva GetPixel_thunk |
||
5999 | SetPixel dd rva SetPixel_thunk |
||
6000 | SetROP2 dd rva SetROP2_thunk |
||
6001 | Polyline dd rva Polyline_thunk |
||
6002 | ExtCreateRegion dd rva ExtCreateRegion_thunk |
||
6003 | DeleteDC dd rva DeleteDC_thunk |
||
6004 | dw 0 |
||
6005 | thunk SetDIBitsToDevice |
||
6006 | thunk GetDIBits |
||
6007 | thunk CreatePen |
||
6008 | thunk SelectObject |
||
6009 | thunk DeleteObject |
||
6010 | thunk CreateSolidBrush |
||
6011 | thunk FillRect |
||
6012 | thunk BitBlt |
||
6013 | thunk CreateBitmap |
||
6014 | thunk CreateCompatibleBitmap |
||
6015 | thunk MoveToEx |
||
6016 | thunk LineTo |
||
6017 | thunk GetDeviceCaps |
||
6018 | thunk SetROP2 |
||
6019 | thunk Polyline |
||
6020 | thunk ExtCreateRegion |
||
6021 | thunk DeleteDC |
||
6022 | ;comdlg32_thunks: |
||
6023 | ;GetOpenFileNameA dd rva GetOpenFileNameA_thunk |
||
6024 | ; dw 0 |
||
6025 | ;thunk GetOpenFileNameA |
||
6026 | |||
6027 | align 4 |
||
6028 | ofn: |
||
6029 | dd 76 ; lStructSize |
||
6030 | dd 0 ; hWndOwner |
||
6031 | dd ofn_arg_template ; hInstance |
||
6032 | dd 0 ; lpstrFilter |
||
6033 | dd 0 ; lpstrCustomFilter |
||
6034 | dd 0 ; nMaxCustFilter |
||
6035 | dd 0 ; nFilterIndex |
||
6036 | dd inname ; lpstrFile |
||
6037 | dd 100h ; nMaxFile |
||
6038 | dd 0 ; lpstrFileTitle |
||
6039 | dd 0 ; nMaxFileTitle |
||
6040 | dd 0 ; lpstrInitialDir |
||
6041 | dd ofn_title ; lpstrTitle |
||
6042 | dd 818A4h ; flags |
||
6043 | dw 0 ; nFileOffset |
||
6044 | dw 0 ; nFileExtension |
||
6045 | dd 0 ; lpstrDefExt |
||
6046 | dd 0 ; lCustData |
||
6047 | dd ofn_hook ; lpfnHook |
||
6048 | dd 0 ; lpTemplateName |
||
6049 | |||
6050 | align 4 |
||
6051 | PlaySoundA dd PlaySoundA_delayed_imp |
||
6052 | |||
6053 | NumThreads dd 1 |
||
6054 | |||
6055 | virtual at 0 |
||
6056 | shmem_item: |
||
6057 | .name rb 32 |
||
6058 | .next dd ? |
||
6059 | .prev dd ? |
||
6060 | .refs dd ? |
||
6061 | .ptr dd ? |
||
6062 | .size dd ? |
||
6063 | .access dd ? |
||
6064 | .hOwner dd ? |
||
6065 | .pOwner dd ? |
||
6066 | .sizeof = $ |
||
6067 | end virtual |
||
6068 | |||
6069 | virtual at 0 |
||
6070 | shmem_proc_descr: |
||
6071 | .next dd ? |
||
6072 | .item dd ? |
||
6073 | .ptr dd ? |
||
6074 | .end dd ? |
||
6075 | .access dd ? |
||
6076 | .sizeof = $ |
||
6077 | end virtual |
||
6078 | |||
6079 | shmem_list dd shmem_list - shmem_item.next |
||
6080 | dd shmem_list - shmem_item.next |
||
6081 | |||
6082 | DrvKeyValues: |
||
6083 | dd aDisplayName, 1, kiw0_username, kiw0_drivername-kiw0_username-1 |
||
6084 | dd aType, 4, DrvKeyValues+4, 4 |
||
6085 | dd aStart, 4, addr3, 4 |
||
6086 | dd aErrorControl, 4, DrvKeyValues+4, 4 |
||
6087 | dd aImagePath, 1, win32_path, ? |
||
6088 | drvpathlen = $-4 |
||
6089 | dd 0 |
||
6090 | |||
6091 | keymfa db 'HARDWARE\DESCRIPTION\System\MultifunctionAdapter\' |
||
6092 | idxmfa db '0' |
||
6093 | db 0 |
||
6094 | |||
6095 | hdxn db 'hd0n',0 |
||
6096 | hdpart db 'hd0_%d',0 |
||
6097 | hdxy_str db '/hd%d/%d/',0 |
||
6098 | |||
6099 | bInitialized db 0 |
||
6100 | bCaptured db 0 |
||
6101 | |||
6102 | label jmp_klbr fword |
||
6103 | jmp_klbr_eip dd 0 |
||
6104 | klbr_cs dw 0Fh |
||
6105 | klbr_ds dw 17h |
||
6106 | klbr_null dw 0 |
||
6107 | label jmp_temp_int33 fword |
||
6108 | dd 0 |
||
6109 | temp_cs dw 0 |
||
6110 | label jmp_temp_int1A fword |
||
6111 | dd temp_code_int1A - temp_code |
||
6112 | temp_cs2 dw 0 |
||
6113 | |||
6114 | eee db 'exception in debuggee at ' |
||
6115 | eeeeip db '00000000' |
||
6116 | db 0 |
||
6117 | |||
6118 | ; data for int40 emulating code - initialized |
||
6119 | ; from kernel.asm |
||
6120 | keymap: |
||
6121 | db '6',27,'1234567890-=',8,9 ; 0x00 |
||
6122 | db 'qwertyuiop[]',13,'~as' ; 0x10 |
||
6123 | db 'dfghjkl;',39,96,0,'\zxcv' ; 0x20 |
||
6124 | db 'bnm,./',0,'45 @23456' ; 0x30 |
||
6125 | db '7890123',180,178,184,'6',176,'7',179,'8',181 ; 0x40 |
||
6126 | db 177,183,185,182,'AB |
||
6127 | db 'MNOPQRSTUVWXYZAB' ; 0x60 |
||
6128 | db 'CDEFGHIJKLMNOPQR' ; 0x70 |
||
6129 | keymap_shift: |
||
6130 | db '6',27,'!@#$%^&*()_+',8,9 ; 0x00 |
||
6131 | db 'QWERTYUIOP{}',13,'~AS' ; 0x10 |
||
6132 | db 'DFGHJKL:"~',0,'|ZXCV' ; 0x20 |
||
6133 | db 'BNM<>?',0,'45 @23456' ; 0x30 |
||
6134 | db '7890123',180,178,184,'6',176,'7',179,'8',181 ; 0x40 |
||
6135 | db 177,183,185,182,'AB>D',255,'FGHIJKL' ; 0x50 |
||
6136 | db 'MNOPQRSTUVWXYZAB' ; 0x60 |
||
6137 | db 'CDEFGHIJKLMNOPQR' ; 0x70 |
||
6138 | keymap_alt: |
||
6139 | db ' ',27,' @ $ {[]}\ ',8,9 ; 0x00 |
||
6140 | db ' ',13,' ' ; 0x10 |
||
6141 | db ' ',0,' ' ; 0x20 |
||
6142 | db ' ',0,'4',0,' ' ; 0x30 |
||
6143 | db ' ',180,178,184,'6',176,'7',179,'8',181 ; 0x40 |
||
6144 | db 177,183,185,182,'ABCD',255,'FGHIJKL' ; 0x50 |
||
6145 | db 'MNOPQRSTUVWXYZAB' ; 0x60 |
||
6146 | db 'CDEFGHIJKLMNOPQR' ; 0x70 |
||
6147 | |||
6148 | numlock_map db '789-456+1230.' |
||
6149 | |||
6150 | version_inf: |
||
6151 | db 0,7,1,0 ; emulate Kolibri 0.7.1.0 |
||
6152 | db 3 ; UID_KlbrInWin |
||
6153 | dd 945 ; emulate revision 945 |
||
6154 | ; (last change: functions 68.22 and 68.23) |
||
6155 | version_end: |
||
6156 | |||
6157 | bCommonColorsSet db 0 |
||
6158 | |||
6159 | bHaveDSA db 0 |
||
6160 | |||
6161 | vk db 0 |
||
6162 | |||
6163 | tls_index dd -1 |
||
6164 | |||
6165 | max_pid dd 1 |
||
6166 | num_kolibri_proc dd 0 |
||
6167 | |||
6168 | window_topleft: |
||
6169 | dd 1, 21 ; type 1 |
||
6170 | dd 0, 0 ; no drawn window |
||
6171 | dd 5, 20 ; type 2 |
||
6172 | dd 5, ? ; skinned |
||
6173 | dd 5, ? ; skinned fixed-size |
||
6174 | |||
6175 | buttontype db 1 |
||
6176 | |||
6177 | bgr_bmp_header: |
||
6178 | db 'B','M' |
||
6179 | dd ? ; size |
||
6180 | dd 0 |
||
6181 | dd 36h |
||
6182 | dd 28h |
||
6183 | dd ? ; width |
||
6184 | dd ? ; height |
||
6185 | dw 1 |
||
6186 | dw 24 |
||
6187 | dd 0 |
||
6188 | dd ? ; size |
||
6189 | dd 0,0 |
||
6190 | dd 0,0 |
||
6191 | |||
6192 | wave_block_begin: |
||
6193 | db 'RIFF' |
||
6194 | dd ? |
||
6195 | db 'WAVEfmt ' |
||
6196 | dd 10h |
||
6197 | dw 1,1 |
||
6198 | wave_r dd 22050 |
||
6199 | dd 22050 |
||
6200 | dw 1,8 |
||
6201 | db 'data' |
||
6202 | ; dd ? |
||
6203 | wbb_size = $ - wave_block_begin |
||
6204 | |||
6205 | ; note that all uninitialized variables are set to 0 by Windows |
||
6206 | sinfo dd 44h |
||
6207 | rb 28h |
||
6208 | dd 80h |
||
6209 | rb 14h |
||
6210 | |||
6211 | tls_init_start: |
||
6212 | times 24 db 0 |
||
6213 | dd 7 ; message_mask |
||
6214 | dd 0 ; lpShapeData |
||
6215 | dd 1 ; scale |
||
6216 | db 1 ; curdraw |
||
6217 | times tls.uninit_size db ? |
||
6218 | tls_init_end: |
||
6219 | |||
6220 | bDontDebug db ? |
||
6221 | keep_loaded_driver db ? |
||
6222 | |||
6223 | align 4 |
||
6224 | bgr_section dd ? |
||
6225 | hBgrMutex dd ? |
||
6226 | ;dwNewBgrTime dd ? |
||
6227 | |||
6228 | SetBgrQuestion dd ? |
||
6229 | |||
6230 | newprg_section dd ? |
||
6231 | |||
6232 | hArrow dd ? |
||
6233 | |||
6234 | bIs9x db ? |
||
6235 | bDriverLoaded db ? |
||
6236 | heap_status db ? |
||
6237 | |||
6238 | align 4 |
||
6239 | inname rb 256 |
||
6240 | header rd 9 |
||
6241 | base dd ? |
||
6242 | limit dd ? |
||
6243 | fn9limit dd ? |
||
6244 | heap_start dd ? |
||
6245 | heap_control_block dd ? |
||
6246 | heap_region_size dd ? |
||
6247 | heap_critical_sec rb 0x18 |
||
6248 | DSACritSect rb 0x18 |
||
6249 | selector_data rb 8 |
||
6250 | selector_code rb 8 |
||
6251 | NtSetLdtEntries dd ? |
||
6252 | idtr dp ? |
||
6253 | pinfo: |
||
6254 | hProcess dd ? |
||
6255 | hThread dd ? |
||
6256 | dwProcessId dd ? |
||
6257 | dwThreadId dd ? |
||
6258 | cur_slot dd ? |
||
6259 | cur_tid_ptr dd ? |
||
6260 | parent_tid_ptr dd ? |
||
6261 | |||
6262 | debugevent rd 18h |
||
6263 | tids dd ? |
||
6264 | pids dd ? |
||
6265 | |||
6266 | _cs dw ? |
||
6267 | _ds dw ? |
||
6268 | _esp dd ? |
||
6269 | _eip dd ? |
||
6270 | _fs dw ? |
||
6271 | _gs dw ? |
||
6272 | exc_code dd ? |
||
6273 | exc_data dd ? |
||
6274 | klbr_esp dd ? |
||
6275 | |||
6276 | temp_ss dw ? |
||
6277 | temp_stack_size = 0x1000 |
||
6278 | temp_stack rb temp_stack_size |
||
6279 | |||
6280 | parameters dd ? |
||
6281 | |||
6282 | startcurdir rb 261 |
||
6283 | |||
6284 | sound_vol db ? |
||
6285 | |||
6286 | align 4 |
||
6287 | context rd 0xB3 |
||
6288 | |||
6289 | ; data for int40 emulating code - uninitialized |
||
6290 | hHeap dd ? |
||
6291 | |||
6292 | hSharedData dd ? |
||
6293 | hSharedMutex dd ? |
||
6294 | shared_data dd ? |
||
6295 | |||
6296 | _skinh dd ? |
||
6297 | margins rw 4 ; right:left:bottom:top |
||
6298 | skin_active_inner dd ? |
||
6299 | skin_active_outer dd ? |
||
6300 | skin_active_frame dd ? |
||
6301 | skin_passive_inner dd ? |
||
6302 | skin_passive_outer dd ? |
||
6303 | skin_passive_frame dd ? |
||
6304 | |||
6305 | common_colors rb 128 |
||
6306 | |||
6307 | left_bmp dd ? |
||
6308 | oper_bmp dd ? |
||
6309 | base_bmp dd ? |
||
6310 | left1_bmp dd ? |
||
6311 | oper1_bmp dd ? |
||
6312 | base1_bmp dd ? |
||
6313 | |||
6314 | skin_btn_close: |
||
6315 | .left dd ? |
||
6316 | .top dd ? |
||
6317 | .width dd ? |
||
6318 | .height dd ? |
||
6319 | skin_btn_minimize: |
||
6320 | .left dd ? |
||
6321 | .top dd ? |
||
6322 | .width dd ? |
||
6323 | .height dd ? |
||
6324 | |||
6325 | char_mt dd ? |
||
6326 | char2_mt dd ? |
||
6327 | |||
6328 | process_name dd ? |
||
6329 | |||
6330 | ramdisk_path rb 512 |
||
6331 | converted_path rb 512 |
||
6332 | win32_path rb 512 |
||
6333 | |||
6334 | hd_partitions_num rd 4 |
||
6335 | hd_partitions_array rd 4 |
||
6336 | |||
6337 | cmdline rb 2000 |
||
6338 | process_curdir rb 4096 ; protected by the same mutex as for shared data |
||
6339 | |||
6340 | if driver_via_scm |
||
6341 | hSCManager dd ? |
||
6342 | hService dd ? |
||
6343 | end if |
||
6344 | |||
6345 | ColorDepth dd ? |
||
6346 | InvalidateTime dd ? |
||
6347 | DSA dd ? |
||
6348 | |||
6349 | ;WinSockDLL dd ? |
||
6350 | |||
6351 | align 4 |
||
6352 | unpack.p rd unpack.LZMA_BASE_SIZE + (unpack.LZMA_LIT_SIZE shl (unpack.lc+unpack.lp)) |
||
6353 | unpack.code_ dd ? |
||
6354 | unpack.range dd ? |
||
6355 | unpack.rep0 dd ? |
||
6356 | unpack.rep1 dd ? |
||
6357 | unpack.rep2 dd ? |
||
6358 | unpack.rep3 dd ? |
||
6359 | unpack.previousByte db ?>>> |