Subversion Repositories Kolibri OS

Rev

Rev 9047 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9047 Rev 9048
Line 3... Line 3...
3
;; Copyright (C) KolibriOS team 2004-2021. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2021. All rights reserved. ;;
4
;;  Distributed under terms of the GNU General Public License.  ;;
4
;;  Distributed under terms of the GNU General Public License.  ;;
5
;;                                                              ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 7... Line 7...
7
 
7
 
Line 8... Line 8...
8
$Revision: 9045 $
8
$Revision: 9048 $
Line 9... Line 9...
9
 
9
 
Line 40... Line 40...
40
        img_base        rd 1    ;0x18
40
        img_base        rd 1    ;0x18
41
        img_size        rd 1
41
        img_size        rd 1
42
        filename_size   rd 1
42
        filename_size   rd 1
43
        cmdline_size    rd 1
43
        cmdline_size    rd 1
44
        path_string     rd 1
44
        path_string     rd 1
-
 
45
        pedescr         rd 1
45
ends
46
ends
Line -... Line 47...
-
 
47
 
-
 
48
; Pointer to this structure is passed as the third argument
-
 
49
; to usermode PE loader by the kernel.
-
 
50
struct kernel_init_data
-
 
51
version         dw      ?
-
 
52
flags           dw      ?
-
 
53
syscall_method  dd      ?
-
 
54
; either one of SYSCALL_METHOD_xxx or pointer to procedure
-
 
55
exe_base        dd      ?
-
 
56
stack_base      dd      ?
-
 
57
stack_size      dd      ?
-
 
58
exe_path        dd      ?
-
 
59
command_line    dd      ?
-
 
60
environment     dd      ?
-
 
61
ends
-
 
62
SYSCALL_METHOD_I40 = 1
-
 
63
SYSCALL_METHOD_SYSENTER = 2
-
 
64
SYSCALL_METHOD_SYSCALL = 3
46
 
65
 
-
 
66
macro _clear_ op
47
macro _clear_ op
67
{
48
{  mov ecx, op/4
68
        mov     ecx, op/4
49
        xor     eax, eax
69
        xor     eax, eax
50
        cld
70
        cld
51
        rep stosd
71
        rep stosd
Line 96... Line 116...
96
        file_base       rd  1
116
        file_base       rd  1
97
        file_size       rd  1
117
        file_size       rd  1
98
        filename_size   rd  1
118
        filename_size   rd  1
99
        cmdline_size    rd  1
119
        cmdline_size    rd  1
100
        path_string     rd  1
120
        path_string     rd  1
-
 
121
        pedescr         rd  1
101
    endl
122
    endl
Line 102... Line 123...
102
 
123
 
103
        mov     [flags], edx
124
        mov     [flags], edx
104
        mov     [cmdline], ecx
125
        mov     [cmdline], ecx
105
        mov     [path_string], ebx
126
        mov     [path_string], ebx
106
        mov     [filename_size], eax
127
        mov     [filename_size], eax
107
        mov     esi, -ERROR_FILE_NOT_FOUND
128
        mov     edi, -ERROR_FILE_NOT_FOUND
108
        test    eax, eax
129
        test    eax, eax
109
        jz      .err_file
130
        jz      .err_file
110
        stdcall load_file, ebx
131
        stdcall load_file, ebx
111
        test    eax, eax
132
        test    eax, eax
112
        jz      .err_file
-
 
-
 
133
        jz      .err_file
-
 
134
        stdcall load_file_maybe_pe, [path_string]
113
 
135
        mov     [pedescr], esi
114
        mov     [file_base], eax
136
        mov     [file_base], eax
-
 
137
        mov     [file_size], ebx
-
 
138
 
-
 
139
        test    esi, esi
-
 
140
        jnz     .file_ok
-
 
141
 
-
 
142
        mov     edi, eax
-
 
143
        cmp     eax, -0x1000
-
 
144
        ja      .err_file
115
        mov     [file_size], ebx
145
 
116
        lea     ebx, [hdr_cmdline]
146
        lea     ebx, [hdr_cmdline]
117
        call    test_app_header  ; fill our app header data locals with values from header of given program (if its correct)
147
        call    test_app_header  ; fill our app header data locals with values from header of given program (if its correct)
118
        mov     esi, -TASKMAN_ERROR_NOT_A_EXECUTABLE
148
        mov     edi, -TASKMAN_ERROR_NOT_A_EXECUTABLE
119
        test    eax, eax
149
        test    eax, eax
Line -... Line 150...
-
 
150
        jz      .err_hdr
120
        jz      .err_hdr
151
 
121
 
152
.file_ok:
122
        call    lock_application_table
153
        call    lock_application_table
123
        call    alloc_thread_slot   ; create a slot for new thread
154
        call    alloc_thread_slot   ; create a slot for new thread
124
        mov     esi, -TASKMAN_ERROR_TOO_MANY_PROCESSES
155
        mov     edi, -TASKMAN_ERROR_TOO_MANY_PROCESSES
Line 125... Line 156...
125
        test    eax, eax
156
        test    eax, eax
126
        jz      .err_0
157
        jz      .err_0
Line 160... Line 191...
160
; if cmdline length >= 256 then increase needed memory size by this length
191
; if cmdline length >= 256 then increase needed memory size by this length
161
        lea     ebx, [eax+1]
192
        lea     ebx, [eax+1]
162
        add     [hdr_emem], ebx
193
        add     [hdr_emem], ebx
163
@@:
194
@@:
164
        mov     [cmdline_size], eax
195
        mov     [cmdline_size], eax
-
 
196
        xor     eax, eax
-
 
197
        cmp     [pedescr], eax
-
 
198
        jz      @f
-
 
199
        mov     [hdr_eip], eax
-
 
200
        mov     [hdr_esp], eax
-
 
201
        mov     [hdr_emem], eax
-
 
202
@@:
165
        stdcall create_process, [hdr_emem]  ; create a new process
203
        stdcall create_process, [hdr_emem]  ; create a new process
166
        mov     esi, -TASKMAN_ERROR_OUT_OF_MEMORY
204
        mov     edi, -TASKMAN_ERROR_OUT_OF_MEMORY
167
        test    eax, eax
205
        test    eax, eax
168
        jz      .err_hdr
206
        jz      .err_hdr
Line 169... Line 207...
169
 
207
 
170
; add new process to the list
208
; add new process to the list
Line 201... Line 239...
201
        mov     eax, [process_number]   ; return process number
239
        mov     eax, [process_number]   ; return process number
202
        call    unlock_application_table
240
        call    unlock_application_table
203
        ret
241
        ret
Line 204... Line 242...
204
 
242
 
-
 
243
.err_0:
-
 
244
        mov     esi, [pedescr]
-
 
245
        test    esi, esi
-
 
246
        jz      @f
-
 
247
        call    dereference_pe
205
.err_0:
248
@@:
206
        call    unlock_application_table
249
        call    unlock_application_table
207
.err_hdr:
250
.err_hdr:
208
        stdcall kernel_free, [file_base]
251
        stdcall kernel_free, [file_base]
209
.err_file:
252
.err_file:
210
        stdcall kernel_free, [path_string]
253
        stdcall kernel_free, [path_string]
211
        mov     eax, esi
254
        mov     eax, edi
212
        ret
255
        ret
Line 213... Line 256...
213
endp
256
endp
214
 
257
 
Line 328... Line 371...
328
        stdcall kernel_alloc, 0x2000
371
        stdcall kernel_alloc, 0x2000
329
        test    eax, eax
372
        test    eax, eax
330
        jz      .fail
373
        jz      .fail
331
        mov     [process], eax
374
        mov     [process], eax
Line 332... Line 375...
332
 
375
 
333
        lea     edi, [eax+PROC.heap_lock]
-
 
Line 334... Line 376...
334
        mov     ecx, (PROC.ht_free-PROC.heap_lock)/4
376
        lea     edi, [eax+PROC.heap_base]
335
 
377
 
336
        list_init eax
378
        list_init eax
-
 
379
        add     eax, PROC.thr_list
-
 
380
        list_init eax
Line -... Line 381...
-
 
381
        add     eax, PROC.smap_list - PROC.thr_list
-
 
382
        list_init eax
-
 
383
 
-
 
384
        lea     ecx, [eax+PROC.heap_lock-PROC.smap_list]
337
        add     eax, PROC.thr_list
385
        call    mutex_init
338
        list_init eax
386
 
339
 
387
        mov     ecx, (PROC.ht_free-PROC.heap_base)/4
Line 340... Line 388...
340
        xor     eax, eax
388
        xor     eax, eax
Line 368... Line 416...
368
        or      eax, PG_SWR
416
        or      eax, PG_SWR
369
        mov     [edi-4096+(page_tabs shr 20)], eax
417
        mov     [edi-4096+(page_tabs shr 20)], eax
Line 370... Line 418...
370
 
418
 
371
        lea     edx, [edi-4096]
419
        lea     edx, [edi-4096]
-
 
420
        mov     esi, [app_tabs]
-
 
421
        test    esi, esi
Line 372... Line 422...
372
        mov     esi, [app_tabs]
422
        jz      .no_page_dirs
373
 
423
 
374
.alloc_page_dir:
424
.alloc_page_dir:
375
        call    alloc_page
425
        call    alloc_page
Line 386... Line 436...
386
 
436
 
387
        add     edx, 4
437
        add     edx, 4
388
        dec     esi
438
        dec     esi
Line -... Line 439...
-
 
439
        jnz     .alloc_page_dir
389
        jnz     .alloc_page_dir
440
 
390
 
441
.no_page_dirs:
Line 391... Line 442...
391
        stdcall map_page, [tmp_task_ptab], 0, PG_UNMAP
442
        stdcall map_page, [tmp_task_ptab], 0, PG_UNMAP
392
        mov     eax, [process]
443
        mov     eax, [process]
393
 
444
 
394
        pop     edi
445
        pop     edi
395
        pop     esi
446
        pop     esi
396
        pop     ebx
447
        pop     ebx
397
        ret
448
        ret
Line 398... Line 449...
398
.fail:
449
.fail:
399
        mov     ecx, [process]
450
        mov     ecx, [process]
400
        jcxz    @F
451
        jecxz   @F
401
 
452
 
Line 417... Line 468...
417
        mov     ecx, 1024
468
        mov     ecx, 1024
418
.free:
469
.free:
419
        mov     eax, [esi]
470
        mov     eax, [esi]
420
        test    eax, 1
471
        test    eax, 1
421
        jz      .next
472
        jz      .next
422
        test    eax, 2
-
 
423
        jz      .next
-
 
424
        test    eax, 1 shl 9
473
        test    eax, 1 shl 9
425
        jnz     .next                     ;skip shared pages
474
        jnz     .next                     ;skip shared pages
426
        call    free_page
475
        call    free_page
427
.next:
476
.next:
428
        add     esi, 4
477
        add     esi, 4
Line 444... Line 493...
444
        push    ecx
493
        push    ecx
Line 445... Line 494...
445
 
494
 
446
        mov     esi, ecx
495
        mov     esi, ecx
Line -... Line 496...
-
 
496
        list_del esi
447
        list_del esi
497
 
-
 
498
        lea     ebx, [esi+PROC.smap_list]
-
 
499
        mov     edi, [esi+PROC.smap_list+SMAP.fd]
-
 
500
.smap_list_destroy:
-
 
501
        cmp     edi, ebx
448
 
502
        jz      .smap_list_done
-
 
503
        push    [edi+SMAP.fd]
-
 
504
        stdcall destroy_smap, [esp+4]
-
 
505
        pop     edi
Line 449... Line 506...
449
        mov     esi, [esi+PROC.dlls_list_ptr]
506
        jmp     .smap_list_destroy
450
        call    destroy_all_hdlls
507
.smap_list_done:
451
 
508
 
452
        mov     esi, [esp]
509
        mov     esi, [esp]
Line 530... Line 587...
530
         slot   dd ?
587
         slot   dd ?
531
         buff   dd ?
588
         buff   dd ?
532
         r_count    dd ?
589
         r_count    dd ?
533
         offset dd ?
590
         offset dd ?
534
         tmp_r_cnt  dd ?
591
         tmp_r_cnt  dd ?
-
 
592
         mapped_size dd ?
535
       endl
593
       endl
Line 536... Line 594...
536
 
594
 
537
        mov     [slot], eax
595
        mov     [slot], eax
538
        mov     [buff], ecx
596
        mov     [buff], ecx
539
        and     [r_count], 0
597
        and     [r_count], 0
540
        mov     [tmp_r_cnt], edx
598
        mov     [tmp_r_cnt], edx
Line 541... Line 599...
541
        mov     [offset], esi
599
        mov     [offset], esi
-
 
600
 
-
 
601
        pushad
542
 
602
        mov     ecx, proc_mem_mutex
543
        pushad
603
        call    mutex_lock
544
.read_mem:
604
.read_mem:
Line 545... Line 605...
545
        mov     edx, [offset]
605
        mov     edx, [offset]
Line 558... Line 618...
558
@@:
618
@@:
559
        mov     ebx, [offset]
619
        mov     ebx, [offset]
Line 560... Line 620...
560
 
620
 
561
        push    ecx
621
        push    ecx
562
        stdcall map_memEx, [proc_mem_map], \
622
        stdcall map_memEx, [proc_mem_map], \
-
 
623
                [slot], ebx, ecx, PG_READ, [proc_mem_tab]
563
                [slot], ebx, ecx, PG_READ
624
        mov     [mapped_size], eax
Line 564... Line 625...
564
        pop     ecx
625
        pop     ecx
565
 
626
 
566
        mov     esi, [offset]
627
        mov     esi, [offset]
567
        and     esi, 0xfff
628
        and     esi, 0xfff
568
        sub     eax, esi
629
        sub     eax, esi
569
        jbe     .ret
630
        jbe     .ret_unmap
570
        cmp     ecx, eax
631
        cmp     ecx, eax
571
        jbe     @f
632
        jbe     @f
572
        mov     ecx, eax
633
        mov     ecx, eax
573
        mov     [tmp_r_cnt], eax
634
        mov     [tmp_r_cnt], eax
574
@@:
635
@@:
575
        add     esi, [proc_mem_map]
636
        add     esi, [proc_mem_map]
576
        mov     edi, [buff]
637
        mov     edi, [buff]
-
 
638
        push    ecx
-
 
639
        rep movsb
-
 
640
        stdcall unmap_memEx, [proc_mem_map], \
577
        mov     edx, ecx
641
                [slot], ebx, [mapped_size], [proc_mem_tab]
Line 578... Line 642...
578
        rep movsb
642
        pop     ecx
579
        add     [r_count], edx
643
        add     [r_count], ecx
580
 
644
 
581
        add     [offset], edx
645
        add     [offset], ecx
-
 
646
        sub     [tmp_r_cnt], ecx
-
 
647
        jnz     .read_mem
582
        sub     [tmp_r_cnt], edx
648
.ret:
583
        jnz     .read_mem
649
        mov     ecx, proc_mem_mutex
584
.ret:
650
        call    mutex_unlock
-
 
651
        popad
-
 
652
        mov     eax, [r_count]
-
 
653
        ret
-
 
654
.ret_unmap:
585
        popad
655
        stdcall unmap_memEx, [proc_mem_map], \
Line 586... Line 656...
586
        mov     eax, [r_count]
656
                [slot], ebx, [mapped_size], [proc_mem_tab]
587
        ret
657
        jmp     .ret
588
endp
658
endp
Line 601... Line 671...
601
         slot   dd ?
671
         slot   dd ?
602
         buff   dd ?
672
         buff   dd ?
603
         w_count    dd ?
673
         w_count    dd ?
604
         offset dd ?
674
         offset dd ?
605
         tmp_w_cnt  dd ?
675
         tmp_w_cnt  dd ?
-
 
676
         mapped_size dd ?
606
       endl
677
       endl
Line 607... Line 678...
607
 
678
 
608
        mov     [slot], eax
679
        mov     [slot], eax
609
        mov     [buff], ecx
680
        mov     [buff], ecx
610
        and     [w_count], 0
681
        and     [w_count], 0
611
        mov     [tmp_w_cnt], edx
682
        mov     [tmp_w_cnt], edx
Line 612... Line 683...
612
        mov     [offset], esi
683
        mov     [offset], esi
-
 
684
 
-
 
685
        pushad
613
 
686
        mov     ecx, proc_mem_mutex
614
        pushad
687
        call    mutex_lock
615
.read_mem:
688
.write_mem:
Line 616... Line 689...
616
        mov     edx, [offset]
689
        mov     edx, [offset]
617
        mov     ebx, [tmp_w_cnt]
690
        mov     ebx, [tmp_w_cnt]
Line 628... Line 701...
628
        mov     ecx, 0x8000
701
        mov     ecx, 0x8000
629
@@:
702
@@:
630
        mov     ebx, [offset]
703
        mov     ebx, [offset]
631
        push    ecx
704
        push    ecx
632
        stdcall map_memEx, [proc_mem_map], \
705
        stdcall map_memEx, [proc_mem_map], \
633
                [slot], ebx, ecx, PG_SWR
706
                [slot], ebx, ecx, PG_SWR, [proc_mem_tab]
-
 
707
        mov     [mapped_size], eax
634
        pop     ecx
708
        pop     ecx
Line 635... Line 709...
635
 
709
 
636
        mov     edi, [offset]
710
        mov     edi, [offset]
637
        and     edi, 0xfff
711
        and     edi, 0xfff
638
        sub     eax, edi
712
        sub     eax, edi
639
        jbe     .ret
713
        jbe     .ret_unmap
640
        cmp     ecx, eax
714
        cmp     ecx, eax
641
        jbe     @f
715
        jbe     @f
642
        mov     ecx, eax
716
        mov     ecx, eax
643
        mov     [tmp_w_cnt], eax
717
        mov     [tmp_w_cnt], eax
644
@@:
718
@@:
645
        add     edi, [proc_mem_map]
719
        add     edi, [proc_mem_map]
646
        mov     esi, [buff]
720
        mov     esi, [buff]
647
        mov     edx, ecx
721
        push    ecx
-
 
722
        rep movsb
-
 
723
        stdcall unmap_memEx, [proc_mem_map], \
-
 
724
                [slot], ebx, [mapped_size], [proc_mem_tab]
Line 648... Line 725...
648
        rep movsb
725
        pop     ecx
649
 
726
 
650
        add     [w_count], edx
727
        add     [w_count], ecx
651
        add     [offset], edx
728
        add     [offset], ecx
652
        sub     [tmp_w_cnt], edx
729
        sub     [tmp_w_cnt], ecx
-
 
730
        jnz     .write_mem
-
 
731
.ret:
653
        jnz     .read_mem
732
        mov     ecx, proc_mem_mutex
654
.ret:
733
        call    mutex_unlock
655
        popad
734
        popad
-
 
735
        mov     eax, [w_count]
-
 
736
        ret
-
 
737
.ret_unmap:
656
        mov     eax, [w_count]
738
        stdcall unmap_memEx, [proc_mem_map], [slot], ebx, [mapped_size], [proc_mem_tab]
Line 657... Line 739...
657
        ret
739
        jmp     .ret
658
endp
740
endp
659
 
741
 
Line 797... Line 879...
797
        mov     ebp, [ebp+APPDATA.exec_params]
879
        mov     ebp, [ebp+APPDATA.exec_params]
798
        test    ebp, ebp
880
        test    ebp, ebp
799
        jz      .exit
881
        jz      .exit
800
; APPDATA.exec_params have first thread only,
882
; APPDATA.exec_params have first thread only,
801
; so second and next threads don't get here (they jump to .exit) 
883
; so second and next threads don't get here (they jump to .exit) 
-
 
884
        cmp     [ebp+APP_HDR.pedescr], 0
-
 
885
        jz      .init_legacy_app
-
 
886
; init PE application
-
 
887
        mov     eax, [current_process]
-
 
888
        mov     [eax+PROC.mem_used], 0xF000 ; leave first 64K as unallocatable
-
 
889
        call    init_heap
-
 
890
        mov     eax, [current_process]
-
 
891
        mov     [eax+PROC.mem_used], 0
-
 
892
        stdcall map_pe_usermode, [ebp+APP_HDR.pedescr],\
-
 
893
                [ebp+APP_HDR.img_base], [ebp+APP_HDR.img_size]
-
 
894
        cmp     eax, -0x1000
-
 
895
        ja      .failed
-
 
896
        push    eax
-
 
897
        stdcall load_file_maybe_pe, pe_loader_usermode
-
 
898
        test    esi, esi
-
 
899
        jz      .pe_loader_notfound
-
 
900
        mov     edx, [esi+PEDESCR.entry]
-
 
901
        mov     [esp+4+20h], edx
-
 
902
        stdcall map_pe_usermode, esi, eax, ebx
-
 
903
        cmp     eax, -0x1000
-
 
904
        ja      .pe_loader_failed
-
 
905
        add     [esp+4+20h], eax
-
 
906
        push    eax
-
 
907
        mov     eax, [ebp+APP_HDR.filename_size]
-
 
908
        add     eax, [ebp+APP_HDR.cmdline_size]
-
 
909
        add     eax, sizeof.kernel_init_data + 2
-
 
910
        stdcall user_alloc, eax
-
 
911
        test    eax, eax
-
 
912
        jz      .failed
-
 
913
        mov     ebx, eax
-
 
914
        mov     dword [eax+kernel_init_data.version], 1 + (0 shl 16) ; version, flags
-
 
915
        mov     [eax+kernel_init_data.syscall_method], SYSCALL_METHOD_I40
-
 
916
        lea     edi, [eax+sizeof.kernel_init_data]
-
 
917
        mov     [eax+kernel_init_data.exe_path], edi
-
 
918
        mov     esi, [ebp+APP_HDR.path_string]
-
 
919
        mov     ecx, [ebp+APP_HDR.filename_size]
-
 
920
        rep movsb
-
 
921
        mov     byte [edi], 0
-
 
922
        inc     edi
-
 
923
        mov     [eax+kernel_init_data.command_line], edi
-
 
924
        lea     esi, [ebp+sizeof.APP_HDR]
-
 
925
        mov     ecx, [ebp+APP_HDR.cmdline_size]
-
 
926
        rep movsb
-
 
927
        mov     byte [edi], 0
-
 
928
        mov     ecx, [ebp+APP_HDR.pedescr]
-
 
929
        mov     ecx, [ecx+PEDESCR.stacksize]
-
 
930
        mov     [eax+kernel_init_data.stack_size], ecx
-
 
931
        stdcall user_alloc, ecx
-
 
932
        test    eax, eax
-
 
933
        jz      .failed
-
 
934
        mov     [ebx+kernel_init_data.stack_base], eax
-
 
935
        add     eax, [ebx+kernel_init_data.stack_size]
-
 
936
        sub     eax, 16
-
 
937
        pop     dword [eax+4]
-
 
938
        pop     [ebx+kernel_init_data.exe_base]
-
 
939
        mov     dword [eax+8], 1 ; DLL_PROCESS_ATTACH
-
 
940
        mov     dword [eax+12], ebx
-
 
941
        mov     [esp+2Ch], eax
-
 
942
        jmp     .common_tls
-
 
943
.pe_loader_notfound:
-
 
944
        cmp     eax, -0x1000
-
 
945
        ja      .pe_loader_failed
-
 
946
        stdcall kernel_free, eax
-
 
947
.pe_loader_failed:
-
 
948
        dbgstr 'Failed to load kolibri.dll'
-
 
949
.failed:
-
 
950
        stdcall kernel_free, [ebp+APP_HDR.path_string]
-
 
951
        jmp     sys_end
-
 
952
.init_legacy_app:
-
 
953
; init MENUETxx application
802
        stdcall map_process_image, [ebp+APP_HDR._emem],\
954
        stdcall map_process_image, [ebp+APP_HDR._emem],\
803
                [ebp+APP_HDR.img_base], [ebp+APP_HDR.img_size]
955
                [ebp+APP_HDR.img_base], [ebp+APP_HDR.img_size]
804
        mov     esi, [ebp+APP_HDR.path_string]
956
        mov     esi, [ebp+APP_HDR.path_string]
805
        mov     edi, [ebp+APP_HDR.path]
957
        mov     edi, [ebp+APP_HDR.path]
806
        mov     ecx, [ebp+APP_HDR.filename_size]
958
        mov     ecx, [ebp+APP_HDR.filename_size]
Line 844... Line 996...
844
        dec     ecx
996
        dec     ecx
845
        rep movsb
997
        rep movsb
846
        mov     byte [edi], 0
998
        mov     byte [edi], 0
847
.check_tls_header:
999
.check_tls_header:
848
        cmp     word [6], '02'
1000
        cmp     word [6], '02'
849
        jne     .try_load_dll ;.cleanup
1001
        jne     .try_load_dll ;.common
850
        call    init_heap
1002
        call    init_heap
-
 
1003
.common_tls:
851
        stdcall user_alloc, 4096
1004
        stdcall user_alloc, 4096
852
        mov     edx, [current_slot]
1005
        mov     edx, [current_slot]
853
        mov     [edx+APPDATA.tls_base], eax
1006
        mov     [edx+APPDATA.tls_base], eax
854
        mov     [tls_data_l+2], ax
1007
        mov     [tls_data_l+2], ax
855
        shr     eax, 16
1008
        shr     eax, 16
Line 860... Line 1013...
860
; { Patch by Coldy, For DLL autoload    
1013
; { Patch by Coldy, For DLL autoload    
861
.try_load_dll:         
1014
.try_load_dll:         
862
; Test app header version 
1015
; Test app header version 
863
        mov     ecx, dword[ebp+APP_HDR.img_base]
1016
        mov     ecx, dword[ebp+APP_HDR.img_base]
864
        cmp     dword[ecx+8], 2
1017
        cmp     dword[ecx+8], 2
865
        jne     .cleanup
1018
        jne     .common
866
;if APP_HEADER.version = 2 => load lib/dll.obj & change eip to APP_STARTUP_THUNK
1019
;if APP_HEADER.version = 2 => load lib/dll.obj & change eip to APP_STARTUP_THUNK
867
        DEBUGF 1, 'K : App header version 2\n'
1020
        DEBUGF 1, 'K : App header version 2\n'
868
        stdcall load_library, dll_lib_path, 0
1021
        stdcall load_library, dll_lib_path, 0
869
        cmp     eax, 0
1022
        cmp     eax, 0
870
        jne     @f
1023
        jne     @f
Line 887... Line 1040...
887
        mov     ecx, [current_slot]
1040
        mov     ecx, [current_slot]
888
        mov     ecx, [ecx+APPDATA.pl0_stack]
1041
        mov     ecx, [ecx+APPDATA.pl0_stack]
889
        mov     [ecx+REG_EIP], eax
1042
        mov     [ecx+REG_EIP], eax
Line 890... Line 1043...
890
        
1043
        
-
 
1044
; } End patch by Coldy, For DLL autoload
-
 
1045
        mov     fs, dx
891
; } End patch by Coldy, For DLL autoload
1046
 
892
.cleanup:
1047
.common:
893
        stdcall free_kernel_space, [ebp+APP_HDR.img_base]
1048
        stdcall free_kernel_space, [ebp+APP_HDR.img_base]
894
        stdcall kernel_free, ebp
1049
        stdcall kernel_free, ebp
895
        mov     ebx, [current_slot]
1050
        mov     ebx, [current_slot]
896
        cmp     [ebx+APPDATA.debugger_slot], 0
1051
        cmp     [ebx+APPDATA.debugger_slot], 0