Subversion Repositories Kolibri OS

Rev

Rev 2106 | Rev 2465 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2106 Rev 2434
Line 3... Line 3...
3
;; Copyright (C) KolibriOS team 2004-2009. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2009. 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: 2106 $
8
$Revision: 2434 $
9
 
9
 
Line 137... Line 137...
137
 
137
 
138
	   mov edi, [esi+handle]
138
        mov     edi, [esi+handle]
139
	   cmp [edi+SRV.magic], ' SRV'
139
        cmp     [edi+SRV.magic], ' SRV'
Line 140... Line 140...
140
	   jne .fail
140
        jne     .fail
141
 
141
 
Line 142... Line 142...
142
       cmp [edi+SRV.size], SRV.sizeof
142
        cmp     [edi+SRV.size], sizeof.SRV
143
	   jne .fail
143
        jne     .fail
144
 
144
 
Line 169... Line 169...
169
 
169
 
170
	   mov eax, [ecx+handle]
170
        mov     eax, [ecx+handle]
171
	   cmp [eax+SRV.magic], ' SRV'
171
        cmp     [eax+SRV.magic], ' SRV'
Line 172... Line 172...
172
	   jne .fail
172
        jne     .fail
173
 
173
 
Line 174... Line 174...
174
       cmp [eax+SRV.size], SRV.sizeof
174
        cmp     [eax+SRV.size], sizeof.SRV
175
	   jne .fail
175
        jne     .fail
176
 
176
 
Line 194... Line 194...
194
	   jnz @F
194
        jnz     @F
195
	   ret
195
        ret
196
@@:
196
@@:
197
	   mov edx, [srv.fd]
197
        mov     edx, [srv.fd]
198
@@:
198
@@:
199
	   cmp edx, srv.fd-SRV_FD_OFFSET
199
        cmp     edx, srv.fd-SRV.fd
200
	   je .not_load
200
        je      .not_load
Line 201... Line 201...
201
 
201
 
202
	   stdcall strncmp, edx, [sz_name], 16
202
        stdcall strncmp, edx, [sz_name], 16
203
	   test eax, eax
203
        test    eax, eax
Line 224... Line 224...
224
	   je .fail
224
        je      .fail
Line 225... Line 225...
225
 
225
 
226
	   cmp [handler], eax
226
        cmp     [handler], eax
Line 227... Line 227...
227
	   je .fail
227
        je      .fail
228
 
228
 
229
       mov eax, SRV.sizeof
229
        mov     eax, sizeof.SRV
230
       call malloc
230
        call    malloc
Line 231... Line 231...
231
	   test eax, eax
231
        test    eax, eax
Line 241... Line 241...
241
       movsd
241
        movsd
242
	   pop edi
242
        pop     edi
243
	   pop esi
243
        pop     esi
Line 244... Line 244...
244
 
244
 
245
	   mov [eax+SRV.magic], ' SRV'
245
        mov     [eax+SRV.magic], ' SRV'
Line 246... Line 246...
246
       mov [eax+SRV.size], SRV.sizeof
246
        mov     [eax+SRV.size], sizeof.SRV
247
 
247
 
248
	   mov ebx, srv.fd-SRV_FD_OFFSET
248
        mov     ebx, srv.fd-SRV.fd
249
	   mov edx, [ebx+SRV.fd]
249
        mov     edx, [ebx+SRV.fd]
250
	   mov [eax+SRV.fd], edx
250
        mov     [eax+SRV.fd], edx
251
	   mov [eax+SRV.bk], ebx
251
        mov     [eax+SRV.bk], ebx
Line 512... Line 512...
512
	   endl
512
           endl
Line 513... Line 513...
513
 
513
 
514
	   mov edi, [symbols]
514
        mov     edi, [symbols]
515
	   mov [retval], 1
515
        mov     [retval], 1
516
.fix:
516
.fix:
517
	   movzx ebx, [edi+CSYM.SectionNumber]
517
        movzx   ebx, [edi+COFF_SYM.SectionNumber]
518
	   test ebx, ebx
518
        test    ebx, ebx
519
	   jnz .internal
519
        jnz     .internal
520
	   mov eax, dword [edi+CSYM.Name]
520
        mov     eax, dword [edi+COFF_SYM.Name]
521
	   test eax, eax
521
        test    eax, eax
Line 522... Line 522...
522
	   jnz @F
522
        jnz     @F
523
 
523
 
Line 540... Line 540...
540
	   call sys_msg_board_str
540
        call    sys_msg_board_str
Line 541... Line 541...
541
 
541
 
542
	   mov [retval],0
542
        mov     [retval], 0
543
@@:
543
@@:
544
	   mov edi, [symbols]
544
        mov     edi, [symbols]
545
	   mov [edi+CSYM.Value], eax
545
        mov     [edi+COFF_SYM.Value], eax
546
	   jmp .next
546
        jmp     .next
547
.internal:
547
.internal:
548
	   cmp bx, -1
548
        cmp     bx, -1
549
	   je .next
549
        je      .next
Line 553... Line 553...
553
	   dec ebx
553
        dec     ebx
554
	   shl ebx, 3
554
        shl     ebx, 3
555
	   lea ebx, [ebx+ebx*4]
555
        lea     ebx, [ebx+ebx*4]
556
	   add ebx, [sec]
556
        add     ebx, [sec]
Line 557... Line 557...
557
 
557
 
558
	   mov eax, [ebx+CFS.VirtualAddress]
558
        mov     eax, [ebx+COFF_SECTION.VirtualAddress]
559
	   add [edi+CSYM.Value], eax
559
        add     [edi+COFF_SYM.Value], eax
560
.next:
560
.next:
561
	   add edi, CSYM_SIZE
561
        add     edi, sizeof.COFF_SYM
562
	   mov [symbols], edi
562
        mov     [symbols], edi
563
	   dec [sym_count]
563
        dec     [sym_count]
564
	   jnz .fix
564
        jnz     .fix
565
	   mov eax, [retval]
565
        mov     eax, [retval]
Line 572... Line 572...
572
	   locals
572
           locals
573
	     n_sec     dd ?
573
             n_sec     dd ?
574
	   endl
574
           endl
Line 575... Line 575...
575
 
575
 
576
	   mov eax, [coff]
576
        mov     eax, [coff]
577
	   movzx ebx, [eax+CFH.nSections]
577
        movzx   ebx, [eax+COFF_HEADER.nSections]
578
	   mov [n_sec], ebx
578
        mov     [n_sec], ebx
579
	   lea esi, [eax+20]
579
        lea     esi, [eax+20]
580
.fix_sec:
580
.fix_sec:
581
	   mov edi, [esi+CFS.PtrReloc]
581
        mov     edi, [esi+COFF_SECTION.PtrReloc]
Line 582... Line 582...
582
	   add edi, [coff]
582
        add     edi, [coff]
583
 
583
 
584
	   movzx ecx, [esi+CFS.NumReloc]
584
        movzx   ecx, [esi+COFF_SECTION.NumReloc]
585
	   test ecx, ecx
585
        test    ecx, ecx
586
	   jz .next
586
        jz      .next
587
.reloc_loop:
587
.reloc_loop:
588
	   mov ebx, [edi+CRELOC.SymIndex]
588
        mov     ebx, [edi+COFF_RELOC.SymIndex]
589
	   add ebx,ebx
589
        add     ebx, ebx
Line 590... Line 590...
590
	   lea ebx,[ebx+ebx*8]
590
        lea     ebx, [ebx+ebx*8]
Line 591... Line 591...
591
	   add ebx, [sym]
591
        add     ebx, [sym]
592
 
592
 
Line 593... Line 593...
593
	   mov edx, [ebx+CSYM.Value]
593
        mov     edx, [ebx+COFF_SYM.Value]
594
 
594
 
595
	   cmp [edi+CRELOC.Type], 6
595
        cmp     [edi+COFF_RELOC.Type], 6
596
	   je .dir_32
596
        je      .dir_32
597
 
597
 
598
	   cmp [edi+CRELOC.Type], 20
598
        cmp     [edi+COFF_RELOC.Type], 20
599
	   jne .next_reloc
599
        jne     .next_reloc
600
.rel_32:
600
.rel_32:
601
	   mov eax, [edi+CRELOC.VirtualAddress]
601
        mov     eax, [edi+COFF_RELOC.VirtualAddress]
602
	   add eax, [esi+CFS.VirtualAddress]
602
        add     eax, [esi+COFF_SECTION.VirtualAddress]
603
	   sub edx, eax
603
        sub     edx, eax
604
	   sub edx, 4
604
        sub     edx, 4
605
	   jmp .fix
605
        jmp     .fix
606
.dir_32:
606
.dir_32:
607
	   mov eax, [edi+CRELOC.VirtualAddress]
607
        mov     eax, [edi+COFF_RELOC.VirtualAddress]
608
	   add eax, [esi+CFS.VirtualAddress]
608
        add     eax, [esi+COFF_SECTION.VirtualAddress]
609
.fix:
609
.fix:
610
	   add eax, [delta]
610
        add     eax, [delta]
611
	   add [eax], edx
611
        add     [eax], edx
612
.next_reloc:
612
.next_reloc:
613
	   add edi, 10
613
        add     edi, 10
614
	   dec ecx
614
        dec     ecx
615
	   jnz .reloc_loop
615
        jnz     .reloc_loop
616
.next:
616
.next:
617
	   add esi, COFF_SECTION_SIZE
617
        add     esi, sizeof.COFF_SECTION
Line 627... Line 627...
627
	   locals
627
           locals
628
	     n_sec     dd ?
628
             n_sec     dd ?
629
	   endl
629
           endl
Line 630... Line 630...
630
 
630
 
631
	   mov eax, [coff]
631
        mov     eax, [coff]
632
	   movzx ebx, [eax+CFH.nSections]
632
        movzx   ebx, [eax+COFF_HEADER.nSections]
633
	   mov [n_sec], ebx
633
        mov     [n_sec], ebx
634
	   lea esi, [eax+20]
634
        lea     esi, [eax+20]
635
	   mov edx, [delta]
635
        mov     edx, [delta]
636
.fix_sec:
636
.fix_sec:
637
	   mov edi, [esi+CFS.PtrReloc]
637
        mov     edi, [esi+COFF_SECTION.PtrReloc]
Line 638... Line 638...
638
	   add edi, [coff]
638
        add     edi, [coff]
639
 
639
 
640
	   movzx ecx, [esi+CFS.NumReloc]
640
        movzx   ecx, [esi+COFF_SECTION.NumReloc]
641
	   test ecx, ecx
641
        test    ecx, ecx
642
	   jz .next
642
        jz      .next
643
.reloc_loop:
643
.reloc_loop:
644
	   cmp [edi+CRELOC.Type], 6
644
        cmp     [edi+COFF_RELOC.Type], 6
645
	   jne .next_reloc
645
        jne     .next_reloc
646
.dir_32:
646
.dir_32:
647
	   mov eax, [edi+CRELOC.VirtualAddress]
647
        mov     eax, [edi+COFF_RELOC.VirtualAddress]
648
	   add eax, [esi+CFS.VirtualAddress]
648
        add     eax, [esi+COFF_SECTION.VirtualAddress]
649
	   add [eax+edx], edx
649
        add     [eax+edx], edx
650
.next_reloc:
650
.next_reloc:
651
	   add edi, 10
651
        add     edi, 10
652
	   dec ecx
652
        dec     ecx
653
	   jnz .reloc_loop
653
        jnz     .reloc_loop
654
.next:
654
.next:
655
	   add esi, COFF_SECTION_SIZE
655
        add     esi, sizeof.COFF_SECTION
656
	   dec [n_sec]
656
        dec     [n_sec]
657
	   jnz .fix_sec
657
        jnz     .fix_sec
658
.exit:
658
.exit:
Line 698... Line 698...
698
	   test eax, eax
698
        test    eax, eax
699
	   jz .exit
699
        jz      .exit
Line 700... Line 700...
700
 
700
 
Line 701... Line 701...
701
	   mov [coff], eax
701
        mov     [coff], eax
702
 
702
 
Line 703... Line 703...
703
	   movzx ecx, [eax+CFH.nSections]
703
        movzx   ecx, [eax+COFF_HEADER.nSections]
704
	   xor ebx, ebx
704
        xor     ebx, ebx
705
 
705
 
706
	   lea edx, [eax+20]
706
        lea     edx, [eax+20]
707
@@:
707
@@:
708
	   add ebx, [edx+CFS.SizeOfRawData]
708
        add     ebx, [edx+COFF_SECTION.SizeOfRawData]
709
	   add ebx, 15
709
        add     ebx, 15
710
	   and ebx, not 15
710
        and     ebx, not 15
711
	   add edx, COFF_SECTION_SIZE
711
        add     edx, sizeof.COFF_SECTION
Line 712... Line 712...
712
	   dec ecx
712
        dec     ecx
Line 726... Line 726...
726
	   shr ecx, 2
726
        shr     ecx, 2
727
	   cld
727
        cld
728
	   rep stosd
728
        rep stosd
Line 729... Line 729...
729
 
729
 
730
	   mov edx, [coff]
730
        mov     edx, [coff]
731
	   movzx ebx, [edx+CFH.nSections]
731
        movzx   ebx, [edx+COFF_HEADER.nSections]
732
	   mov edi, [img_base]
732
        mov     edi, [img_base]
733
	   lea eax, [edx+20]
733
        lea     eax, [edx+20]
734
@@:
734
@@:
735
	   mov [eax+CFS.VirtualAddress], edi
735
        mov     [eax+COFF_SECTION.VirtualAddress], edi
736
	   mov esi, [eax+CFS.PtrRawData]
736
        mov     esi, [eax+COFF_SECTION.PtrRawData]
737
	   test esi, esi
737
        test    esi, esi
738
	   jnz .copy
738
        jnz     .copy
739
	   add edi, [eax+CFS.SizeOfRawData]
739
        add     edi, [eax+COFF_SECTION.SizeOfRawData]
740
	   jmp .next
740
        jmp     .next
741
.copy:
741
.copy:
742
	   add esi, edx
742
        add     esi, edx
743
	   mov ecx, [eax+CFS.SizeOfRawData]
743
        mov     ecx, [eax+COFF_SECTION.SizeOfRawData]
744
	   cld
744
        cld
745
	   rep movsb
745
        rep movsb
746
.next:
746
.next:
747
	   add edi, 15
747
        add     edi, 15
748
	   and edi, not 15
748
        and     edi, not 15
749
	   add eax, COFF_SECTION_SIZE
749
        add     eax, sizeof.COFF_SECTION
750
	   dec ebx
750
        dec     ebx
Line 751... Line 751...
751
	   jnz @B
751
        jnz     @B
752
 
752
 
753
	   mov ebx, [edx+CFH.pSymTable]
753
        mov     ebx, [edx+COFF_HEADER.pSymTable]
754
	   add ebx, edx
754
        add     ebx, edx
755
	   mov [sym], ebx
755
        mov     [sym], ebx
756
	   mov ecx, [edx+CFH.nSymbols]
756
        mov     ecx, [edx+COFF_HEADER.nSymbols]
757
	   add ecx,ecx
757
        add     ecx, ecx
758
	   lea ecx,[ecx+ecx*8] ;ecx*=18 = nSymbols*CSYM_SIZE
758
        lea     ecx, [ecx+ecx*8];ecx*=18 = nSymbols*CSYM_SIZE
Line 759... Line 759...
759
	   add ecx, [sym]
759
        add     ecx, [sym]
760
	   mov [strings], ecx
760
        mov     [strings], ecx
761
 
761
 
762
	   lea ebx, [exports]
762
        lea     ebx, [exports]
Line 763... Line 763...
763
	   mov dword [ebx], kernel_export
763
        mov     dword [ebx], kernel_export
764
	   mov dword [ebx+4], 0
764
        mov     dword [ebx+4], 0
765
	   lea eax, [edx+20]
765
        lea     eax, [edx+20]
766
 
766
 
Line 767... Line 767...
767
	   stdcall fix_coff_symbols, eax, [sym], [edx+CFH.nSymbols],\
767
        stdcall fix_coff_symbols, eax, [sym], [edx+COFF_HEADER.nSymbols], \
768
				     [strings], ebx
768
                [strings], ebx
Line 769... Line 769...
769
	   test eax, eax
769
        test    eax, eax
770
	   jz .link_fail
770
        jz      .link_fail
771
 
771
 
Line 772... Line 772...
772
	   mov ebx, [coff]
772
        mov     ebx, [coff]
773
	   stdcall fix_coff_relocs, ebx, [sym], 0
773
        stdcall fix_coff_relocs, ebx, [sym], 0
Line 783... Line 783...
783
 
783
 
784
	   cmp eax, DRV_CURRENT
784
        cmp     eax, DRV_CURRENT
Line 785... Line 785...
785
	   ja .ver_fail
785
        ja      .ver_fail
786
 
786
 
787
	   mov ebx, [coff]
787
        mov     ebx, [coff]
Line 788... Line 788...
788
	   stdcall get_coff_sym,[sym],[ebx+CFH.nSymbols],szSTART
788
        stdcall get_coff_sym, [sym], [ebx+COFF_HEADER.nSymbols], szSTART
Line 789... Line 789...
789
	   mov [start], eax
789
        mov     [start], eax
Line 849... Line 849...
849
; Rules:
849
; Rules:
850
; - if alignment is not given, use default = 4K;
850
; - if alignment is not given, use default = 4K;
851
; - if alignment is given and is no more than 4K, use it;
851
; - if alignment is given and is no more than 4K, use it;
852
; - if alignment is more than 4K, revert to 4K.
852
; - if alignment is more than 4K, revert to 4K.
853
	push	ecx
853
        push    ecx
854
	mov	cl, byte [edx+CFS.Characteristics+2]
854
        mov     cl, byte [edx+COFF_SECTION.Characteristics+2]
855
	mov	eax, 1
855
        mov     eax, 1
856
	shr	cl, 4
856
        shr     cl, 4
857
	dec	cl
857
        dec     cl
858
	js	.default
858
        js      .default
859
	cmp	cl, 12
859
        cmp     cl, 12
Line 953... Line 953...
953
	   mov esi, edi
953
        mov     esi, edi
954
	   mov ecx, -1
954
        mov     ecx, -1
955
	   xor eax, eax
955
        xor     eax, eax
956
	   repnz scasb
956
        repnz scasb
957
	   not ecx
957
        not     ecx
958
	   lea eax, [ecx+DLLDESCR.sizeof]
958
        lea     eax, [ecx+sizeof.DLLDESCR]
959
	   push ecx
959
        push    ecx
960
	   call malloc
960
        call    malloc
961
	   pop ecx
961
        pop     ecx
962
	   test eax, eax
962
        test    eax, eax
963
	   jz .fail_and_free_coff
963
        jz      .fail_and_free_coff
Line 977... Line 977...
977
	   mov [esi+DLLDESCR.bk], eax
977
        mov     [esi+DLLDESCR.bk], eax
978
	   mov [eax+DLLDESCR.fd], esi
978
        mov     [eax+DLLDESCR.fd], esi
Line 979... Line 979...
979
 
979
 
980
; calculate size of loaded DLL
980
; calculate size of loaded DLL
981
	   mov edx, [coff]
981
        mov     edx, [coff]
982
	   movzx ecx, [edx+CFH.nSections]
982
        movzx   ecx, [edx+COFF_HEADER.nSections]
Line 983... Line 983...
983
	   xor ebx, ebx
983
        xor     ebx, ebx
984
 
984
 
985
	   add edx, 20
985
        add     edx, 20
986
@@:
986
@@:
987
	   call coff_get_align
987
        call    coff_get_align
988
	   add ebx, eax
988
        add     ebx, eax
989
	   not eax
989
        not     eax
990
	   and ebx, eax
990
        and     ebx, eax
991
	   add ebx, [edx+CFS.SizeOfRawData]
991
        add     ebx, [edx+COFF_SECTION.SizeOfRawData]
992
	   add edx, COFF_SECTION_SIZE
992
        add     edx, sizeof.COFF_SECTION
993
	   dec ecx
993
        dec     ecx
994
	   jnz @B
994
        jnz     @B
995
; it must be nonzero and not too big
995
; it must be nonzero and not too big
Line 1017... Line 1017...
1017
	   mov [dll_cur_addr], edx
1017
        mov     [dll_cur_addr], edx
Line 1018... Line 1018...
1018
 
1018
 
1019
; copy sections and set correct values for VirtualAddress'es in headers
1019
; copy sections and set correct values for VirtualAddress'es in headers
1020
	   push esi
1020
        push    esi
1021
	   mov edx, [coff]
1021
        mov     edx, [coff]
1022
	   movzx ebx, [edx+CFH.nSections]
1022
        movzx   ebx, [edx+COFF_HEADER.nSections]
1023
	   mov edi, eax
1023
        mov     edi, eax
1024
	   add edx, 20
1024
        add     edx, 20
1025
	   cld
1025
        cld
1026
@@:
1026
@@:
1027
	   call coff_get_align
1027
        call    coff_get_align
1028
	   add ecx, eax
1028
        add     ecx, eax
1029
	   add edi, eax
1029
        add     edi, eax
1030
	   not eax
1030
        not     eax
1031
	   and ecx, eax
1031
        and     ecx, eax
1032
	   and edi, eax
1032
        and     edi, eax
1033
	   mov [edx+CFS.VirtualAddress], ecx
1033
        mov     [edx+COFF_SECTION.VirtualAddress], ecx
1034
	   add ecx, [edx+CFS.SizeOfRawData]
1034
        add     ecx, [edx+COFF_SECTION.SizeOfRawData]
1035
	   mov esi, [edx+CFS.PtrRawData]
1035
        mov     esi, [edx+COFF_SECTION.PtrRawData]
1036
	   push ecx
1036
        push    ecx
1037
	   mov ecx, [edx+CFS.SizeOfRawData]
1037
        mov     ecx, [edx+COFF_SECTION.SizeOfRawData]
1038
	   test esi, esi
1038
        test    esi, esi
1039
	   jnz .copy
1039
        jnz     .copy
1040
	   xor eax, eax
1040
        xor     eax, eax
1041
	   rep stosb
1041
        rep stosb
1042
	   jmp .next
1042
        jmp     .next
1043
.copy:
1043
.copy:
1044
	   add esi, [coff]
1044
        add     esi, [coff]
1045
	   rep movsb
1045
        rep movsb
1046
.next:
1046
.next:
1047
           pop ecx
1047
        pop     ecx
1048
	   add edx, COFF_SECTION_SIZE
1048
        add     edx, sizeof.COFF_SECTION
1049
	   dec ebx
1049
        dec     ebx
1050
	   jnz @B
1050
        jnz     @B
Line 1051... Line 1051...
1051
	   pop esi
1051
        pop     esi
1052
 
1052
 
1053
; save some additional data from COFF file
1053
; save some additional data from COFF file
1054
; later we will use COFF header, headers for sections and symbol table
1054
; later we will use COFF header, headers for sections and symbol table
1055
; and also relocations table for all sections
1055
; and also relocations table for all sections
1056
	   mov edx, [coff]
1056
        mov     edx, [coff]
1057
	   mov ebx, [edx+CFH.pSymTable]
1057
        mov     ebx, [edx+COFF_HEADER.pSymTable]
1058
	   mov edi, dword [fileinfo+32]
1058
        mov     edi, dword [fileinfo+32]
1059
	   sub edi, ebx
1059
        sub     edi, ebx
1060
	   jc .fail_and_free_data
1060
        jc      .fail_and_free_data
1061
	   mov [esi+DLLDESCR.symbols_lim], edi
1061
        mov     [esi+DLLDESCR.symbols_lim], edi
1062
	   add ebx, edx
1062
        add     ebx, edx
1063
	   movzx ecx, [edx+CFH.nSections]
1063
        movzx   ecx, [edx+COFF_HEADER.nSections]
1064
	   lea ecx, [ecx*5]
1064
        lea     ecx, [ecx*5]
1065
	   lea edi, [edi+ecx*8+20]
1065
        lea     edi, [edi+ecx*8+20]
1066
	   add edx, 20
1066
        add     edx, 20
1067
@@:
1067
@@:
1068
	   movzx eax, [edx+CFS.NumReloc]
1068
        movzx   eax, [edx+COFF_SECTION.NumReloc]
1069
	   lea eax, [eax*5]
1069
        lea     eax, [eax*5]
1070
	   lea edi, [edi+eax*2]
1070
        lea     edi, [edi+eax*2]
1071
	   add edx, COFF_SECTION_SIZE
1071
        add     edx, sizeof.COFF_SECTION
1072
	   sub ecx, 5
1072
        sub     ecx, 5
1073
	   jnz @b
1073
        jnz     @b
1074
	   stdcall kernel_alloc, edi
1074
        stdcall kernel_alloc, edi
1075
	   test eax, eax
1075
        test    eax, eax
1076
	   jz  .fail_and_free_data
1076
        jz      .fail_and_free_data
1077
	   mov edx, [coff]
1077
        mov     edx, [coff]
1078
	   movzx ecx, [edx+CFH.nSections]
1078
        movzx   ecx, [edx+COFF_HEADER.nSections]
1079
	   lea ecx, [ecx*5]
1079
        lea     ecx, [ecx*5]
1080
	   lea ecx, [ecx*2+5]
1080
        lea     ecx, [ecx*2+5]
1081
	   mov [esi+DLLDESCR.coff_hdr], eax
1081
        mov     [esi+DLLDESCR.coff_hdr], eax
1082
	   push esi
1082
        push    esi
1083
	   mov esi, edx
1083
        mov     esi, edx
1084
	   mov edi, eax
1084
        mov     edi, eax
1085
	   rep movsd
1085
        rep movsd
1086
	   pop esi
1086
        pop     esi
1087
	   mov [esi+DLLDESCR.symbols_ptr], edi
1087
        mov     [esi+DLLDESCR.symbols_ptr], edi
1088
	   push esi
1088
        push    esi
1089
	   mov ecx, [edx+CFH.nSymbols]
1089
        mov     ecx, [edx+COFF_HEADER.nSymbols]
1090
	   mov [esi+DLLDESCR.symbols_num], ecx
1090
        mov     [esi+DLLDESCR.symbols_num], ecx
1091
	   mov ecx, [esi+DLLDESCR.symbols_lim]
1091
        mov     ecx, [esi+DLLDESCR.symbols_lim]
1092
	   mov esi, ebx
1092
        mov     esi, ebx
1093
	   rep movsb
1093
        rep movsb
1094
	   pop esi
1094
        pop     esi
1095
	   mov ebx, [esi+DLLDESCR.coff_hdr]
1095
        mov     ebx, [esi+DLLDESCR.coff_hdr]
1096
	   push esi
1096
        push    esi
1097
	   movzx eax, [edx+CFH.nSections]
1097
        movzx   eax, [edx+COFF_HEADER.nSections]
1098
	   lea edx, [ebx+20]
1098
        lea     edx, [ebx+20]
1099
@@:
1099
@@:
1100
           movzx ecx, [edx+CFS.NumReloc]
1100
        movzx   ecx, [edx+COFF_SECTION.NumReloc]
1101
           lea ecx, [ecx*5]
1101
        lea     ecx, [ecx*5]
1102
           mov esi, [edx+CFS.PtrReloc]
1102
        mov     esi, [edx+COFF_SECTION.PtrReloc]
1103
           mov [edx+CFS.PtrReloc], edi
1103
        mov     [edx+COFF_SECTION.PtrReloc], edi
1104
           sub [edx+CFS.PtrReloc], ebx
1104
        sub     [edx+COFF_SECTION.PtrReloc], ebx
1105
           add esi, [coff]
1105
        add     esi, [coff]
1106
           shr ecx, 1
1106
        shr     ecx, 1
1107
           rep movsd
1107
        rep movsd
1108
           adc ecx, ecx
1108
        adc     ecx, ecx
1109
           rep movsw
1109
        rep movsw
1110
           add edx, COFF_SECTION_SIZE
1110
        add     edx, sizeof.COFF_SECTION
1111
           dec eax
1111
        dec     eax
Line 1112... Line 1112...
1112
           jnz @b
1112
        jnz     @b
1113
	   pop esi
1113
        pop     esi
1114
 
1114
 
1115
; fixup symbols
1115
; fixup symbols
1116
	   mov edx, ebx
1116
        mov     edx, ebx
1117
	   mov eax, [ebx+CFH.nSymbols]
1117
        mov     eax, [ebx+COFF_HEADER.nSymbols]
1118
	   add edx, 20
1118
        add     edx, 20
1119
	   mov ecx, [esi+DLLDESCR.symbols_num]
1119
        mov     ecx, [esi+DLLDESCR.symbols_num]
Line 1126... Line 1126...
1126
;	   test eax, eax
1126
;          test eax, eax
1127
;	   jnz @F
1127
;          jnz @F
1128
;
1128
;
1129
;@@:
1129
;@@:
Line 1130... Line 1130...
1130
 
1130
 
1131
	   stdcall get_coff_sym,[esi+DLLDESCR.symbols_ptr],[ebx+CFH.nSymbols],szEXPORTS
1131
        stdcall get_coff_sym, [esi+DLLDESCR.symbols_ptr], [ebx+COFF_HEADER.nSymbols], szEXPORTS
1132
	   test eax, eax
1132
        test    eax, eax
Line 1133... Line 1133...
1133
	   jnz @F
1133
        jnz     @F
1134
 
1134
 
1135
	   stdcall get_coff_sym,[esi+DLLDESCR.symbols_ptr],[ebx+CFH.nSymbols],sz_EXPORTS
1135
        stdcall get_coff_sym, [esi+DLLDESCR.symbols_ptr], [ebx+COFF_HEADER.nSymbols], sz_EXPORTS
Line 1136... Line 1136...
1136
@@:
1136
@@:
1137
	   mov [esi+DLLDESCR.exports], eax
1137
        mov     [esi+DLLDESCR.exports], eax
Line 1158... Line 1158...
1158
	   stdcall user_alloc, edi
1158
        stdcall user_alloc, edi
1159
	   test eax, eax
1159
        test    eax, eax
1160
	   jz  .fail_and_dereference
1160
        jz      .fail_and_dereference
1161
@@:
1161
@@:
1162
	   mov [img_base], eax
1162
        mov     [img_base], eax
1163
	   mov eax, HDLL.sizeof
1163
        mov     eax, sizeof.HDLL
1164
	   call malloc
1164
        call    malloc
1165
	   test eax, eax
1165
        test    eax, eax
1166
	   jz  .fail_and_free_user
1166
        jz      .fail_and_free_user
1167
	   mov ebx, [CURRENT_TASK]
1167
        mov     ebx, [CURRENT_TASK]
1168
	   shl ebx, 5
1168
        shl     ebx, 5
Line 1367... Line 1367...
1367
align 4
1367
align 4
1368
stop_all_services:
1368
stop_all_services:
1369
       push ebp
1369
        push    ebp
1370
	   mov edx, [srv.fd]
1370
        mov     edx, [srv.fd]
1371
.next:
1371
.next:
1372
	   cmp edx,  srv.fd-SRV_FD_OFFSET
1372
        cmp     edx, srv.fd-SRV.fd
1373
	   je .done
1373
        je      .done
1374
	   cmp [edx+SRV.magic], ' SRV'
1374
        cmp     [edx+SRV.magic], ' SRV'
1375
	   jne .next
1375
        jne     .next
1376
       cmp [edx+SRV.size], SRV.sizeof
1376
        cmp     [edx+SRV.size], sizeof.SRV
1377
	   jne .next
1377
        jne     .next
Line 1378... Line 1378...
1378
 
1378
 
1379
	   mov ebx, [edx+SRV.entry]
1379
        mov     ebx, [edx+SRV.entry]
1380
	   mov edx, [edx+SRV.fd]
1380
        mov     edx, [edx+SRV.fd]