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-2020. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2020. 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: 9034 $
8
$Revision: 9048 $
9
 
9
 
Line 899... Line 899...
899
 
899
 
900
align 4
900
align 4
901
proc load_library stdcall, file_name:dword, encoding:dword
901
proc load_library stdcall, file_name:dword, encoding:dword
902
    locals
902
    locals
903
        fullname    dd  ?
903
        fullname    dd  ?
904
        fileinfo    rb  40
904
        filesize    dd  ?
905
        coff        dd  ?
905
        coff        dd  ?
-
 
906
        img_base    dd  ?
-
 
907
        img_size    dd  ?
-
 
908
        symbols_ptr dd  ?
-
 
909
        symbols_lim dd  ?
906
        img_base    dd  ?
910
        exports     dd  ?
Line 907... Line 911...
907
    endl
911
    endl
908
 
912
 
909
; resolve file name
913
; resolve file name
Line 915... Line 919...
915
        push    ebp
919
        push    ebp
916
        call    getFullPath
920
        call    getFullPath
917
        pop     ebp
921
        pop     ebp
918
        test    eax, eax
922
        test    eax, eax
919
        jz      .fail
923
        jz      .fail
920
; scan for required DLL in list of already loaded for this process,
-
 
921
; ignore timestamp
-
 
922
        cli
-
 
923
        mov     esi, [current_process]
-
 
924
        mov     edi, [fullname]
-
 
925
        mov     ebx, [esi+PROC.dlls_list_ptr]
-
 
926
        test    ebx, ebx
-
 
927
        jz      .not_in_process
-
 
928
        mov     esi, [ebx+HDLL.fd]
-
 
929
.scan_in_process:
-
 
930
        cmp     esi, ebx
-
 
931
        jz      .not_in_process
-
 
932
        mov     eax, [esi+HDLL.parent]
-
 
933
        add     eax, DLLDESCR.name
-
 
934
        stdcall strncmp, eax, edi, -1
-
 
935
        test    eax, eax
-
 
936
        jnz     .next_in_process
-
 
937
; simple variant: load DLL which is already loaded in this process
-
 
938
; just increment reference counters and return address of exports table
-
 
939
        inc     [esi+HDLL.refcount]
-
 
940
        mov     ecx, [esi+HDLL.parent]
-
 
941
        inc     [ecx+DLLDESCR.refcount]
-
 
942
        mov     eax, [ecx+DLLDESCR.exports]
-
 
943
        sub     eax, [ecx+DLLDESCR.defaultbase]
-
 
944
        add     eax, [esi+HDLL.base]
-
 
945
        sti
-
 
946
        push    eax
-
 
947
        stdcall kernel_free, [fullname]
-
 
948
        pop     eax
-
 
949
        ret
-
 
Line 950... Line -...
950
 
-
 
951
.next_in_process:
-
 
952
        mov     esi, [esi+HDLL.fd]
-
 
953
        jmp     .scan_in_process
-
 
954
 
-
 
955
.not_in_process:
-
 
956
; scan in full list, compare timestamp
-
 
957
        sti
-
 
958
        lea     eax, [fileinfo]
-
 
959
        stdcall get_fileinfo, edi, eax
-
 
960
        test    eax, eax
-
 
961
        jnz     .fail
-
 
962
        cli
-
 
963
        mov     esi, [dll_list.fd]
-
 
964
.scan_for_dlls:
-
 
965
        cmp     esi, dll_list
-
 
966
        jz      .load_new
-
 
967
        lea     eax, [esi+DLLDESCR.name]
-
 
968
        stdcall strncmp, eax, edi, -1
-
 
969
        test    eax, eax
-
 
970
        jnz     .continue_scan
-
 
971
.test_prev_dll:
-
 
972
        mov     eax, dword [fileinfo+24]; last modified time
-
 
973
        mov     edx, dword [fileinfo+28]; last modified date
-
 
974
        cmp     dword [esi+DLLDESCR.timestamp], eax
-
 
975
        jnz     .continue_scan
-
 
976
        cmp     dword [esi+DLLDESCR.timestamp+4], edx
-
 
977
        jz      .dll_already_loaded
-
 
978
.continue_scan:
-
 
979
        mov     esi, [esi+DLLDESCR.fd]
-
 
980
        jmp     .scan_for_dlls
-
 
981
 
-
 
982
; new DLL
-
 
983
.load_new:
-
 
984
        sti
924
 
985
; load file
925
; load file
986
        stdcall load_file, edi
926
        stdcall load_file, [fullname]
987
        test    eax, eax
927
        test    eax, eax
988
        jz      .fail
928
        jz      .fail
989
        mov     [coff], eax
-
 
990
        mov     dword [fileinfo+32], ebx
-
 
991
 
-
 
992
; allocate DLLDESCR struct; size is DLLDESCR.sizeof plus size of DLL name
-
 
993
        mov     esi, edi
-
 
994
        mov     ecx, -1
-
 
995
        xor     eax, eax
-
 
996
        repnz scasb
-
 
997
        not     ecx
-
 
998
        lea     eax, [ecx+sizeof.DLLDESCR]
-
 
999
        push    ecx
-
 
1000
        call    malloc
-
 
1001
        pop     ecx
-
 
1002
        test    eax, eax
-
 
1003
        jz      .fail_and_free_coff
-
 
1004
; save timestamp
-
 
1005
        lea     edi, [eax+DLLDESCR.name]
-
 
1006
        rep movsb
929
        mov     [coff], eax
1007
        mov     esi, eax
-
 
1008
        mov     eax, dword [fileinfo+24]
-
 
1009
        mov     dword [esi+DLLDESCR.timestamp], eax
-
 
1010
        mov     eax, dword [fileinfo+28]
-
 
Line 1011... Line 930...
1011
        mov     dword [esi+DLLDESCR.timestamp+4], eax
930
        mov     [filesize], ebx
1012
 
-
 
1013
; calculate size of loaded DLL
931
 
1014
        mov     edx, [coff]
932
; calculate size of loaded DLL
Line 1015... Line 933...
1015
        movzx   ecx, [edx+COFF_HEADER.nSections]
933
        movzx   ecx, [eax+COFF_HEADER.nSections]
1016
        xor     ebx, ebx
934
        xor     ebx, ebx
1017
 
935
 
1018
        add     edx, 20
936
        lea     edx, [eax+20]
1019
@@:
937
@@:
1020
        call    coff_get_align
938
        call    coff_get_align
1021
        add     ebx, eax
939
        add     ebx, eax
1022
        not     eax
940
        not     eax
1023
        and     ebx, eax
941
        and     ebx, eax
1024
        add     ebx, [edx+COFF_SECTION.SizeOfRawData]
942
        add     ebx, [edx+COFF_SECTION.SizeOfRawData]
1025
        add     edx, sizeof.COFF_SECTION
943
        add     edx, sizeof.COFF_SECTION
1026
        dec     ecx
944
        dec     ecx
1027
        jnz     @B
945
        jnz     @B
1028
; it must be nonzero and not too big
946
; it must be nonzero and not too big
1029
        mov     [esi+DLLDESCR.size], ebx
947
        mov     [img_size], ebx
1030
        test    ebx, ebx
948
        test    ebx, ebx
1031
        jz      .fail_and_free_dll
949
        jz      .fail_and_free_coff
-
 
950
        cmp     ebx, 0x10000000
1032
        cmp     ebx, MAX_DEFAULT_DLL_ADDR-MIN_DEFAULT_DLL_ADDR
951
        ja      .fail_and_free_coff
1033
        ja      .fail_and_free_dll
952
; allocate memory
1034
; allocate memory for kernel-side image
953
        call    init_heap
1035
        stdcall kernel_alloc, ebx
-
 
1036
        test    eax, eax
-
 
1037
        jz      .fail_and_free_dll
-
 
1038
        mov     [esi+DLLDESCR.data], eax
-
 
1039
; calculate preferred base address
-
 
1040
        add     ebx, 0x1FFF
-
 
1041
        and     ebx, not 0xFFF
-
 
1042
        mov     ecx, [dll_cur_addr]
-
 
1043
        lea     edx, [ecx+ebx]
-
 
1044
        cmp     edx, MAX_DEFAULT_DLL_ADDR
-
 
1045
        jb      @f
-
 
1046
        mov     ecx, MIN_DEFAULT_DLL_ADDR
-
 
1047
        lea     edx, [ecx+ebx]
954
        stdcall user_alloc, [img_size]
Line 1048... Line 955...
1048
@@:
955
        test    eax, eax
1049
        mov     [esi+DLLDESCR.defaultbase], ecx
-
 
1050
        mov     [dll_cur_addr], edx
956
        jz      .fail_and_free_coff
1051
 
957
        mov	[img_base], eax
1052
; copy sections and set correct values for VirtualAddress'es in headers
958
 
1053
        push    esi
959
; copy sections and set correct values for VirtualAddress'es in headers
1054
        mov     edx, [coff]
960
        mov     edx, [coff]
1055
        movzx   ebx, [edx+COFF_HEADER.nSections]
961
        movzx   ebx, [edx+COFF_HEADER.nSections]
1056
        mov     edi, eax
962
        mov     edi, eax
1057
        add     edx, 20
-
 
1058
        cld
963
        add     edx, 20
1059
@@:
964
        cld
1060
        call    coff_get_align
-
 
1061
        add     ecx, eax
965
@@:
1062
        add     edi, eax
966
        call    coff_get_align
1063
        not     eax
-
 
1064
        and     ecx, eax
967
        add     edi, eax
1065
        and     edi, eax
-
 
1066
        mov     [edx+COFF_SECTION.VirtualAddress], ecx
968
        not     eax
1067
        add     ecx, [edx+COFF_SECTION.SizeOfRawData]
969
        and     edi, eax
1068
        mov     esi, [edx+COFF_SECTION.PtrRawData]
970
        mov     [edx+COFF_SECTION.VirtualAddress], edi
1069
        push    ecx
971
        mov     esi, [edx+COFF_SECTION.PtrRawData]
1070
        mov     ecx, [edx+COFF_SECTION.SizeOfRawData]
972
        mov     ecx, [edx+COFF_SECTION.SizeOfRawData]
1071
        test    esi, esi
973
        test    esi, esi
1072
        jnz     .copy
974
        jnz     .copy
1073
        xor     eax, eax
975
        xor     eax, eax
1074
        rep stosb
976
        rep stosb
1075
        jmp     .next
977
        jmp     .next
1076
.copy:
-
 
1077
        add     esi, [coff]
978
.copy:
1078
        rep movsb
979
        add     esi, [coff]
1079
.next:
980
        rep movsb
1080
        pop     ecx
-
 
Line 1081... Line -...
1081
        add     edx, sizeof.COFF_SECTION
-
 
1082
        dec     ebx
-
 
1083
        jnz     @B
-
 
1084
        pop     esi
981
.next:
1085
 
982
        add     edx, sizeof.COFF_SECTION
1086
; save some additional data from COFF file
983
        dec     ebx
1087
; later we will use COFF header, headers for sections and symbol table
984
        jnz     @B
1088
; and also relocations table for all sections
985
 
1089
        mov     edx, [coff]
986
        mov     edx, [coff]
1090
        mov     ebx, [edx+COFF_HEADER.pSymTable]
987
        mov     ebx, [edx+COFF_HEADER.pSymTable]
1091
        mov     edi, dword [fileinfo+32]
-
 
1092
        sub     edi, ebx
-
 
1093
        jc      .fail_and_free_data
-
 
1094
        mov     [esi+DLLDESCR.symbols_lim], edi
-
 
1095
        add     ebx, edx
-
 
1096
        movzx   ecx, [edx+COFF_HEADER.nSections]
-
 
1097
        lea     ecx, [ecx*5]
-
 
1098
        lea     edi, [edi+ecx*8+20]
-
 
1099
        add     edx, 20
-
 
1100
@@:
-
 
1101
        movzx   eax, [edx+COFF_SECTION.NumReloc]
988
        mov     edi, [filesize]
1102
        lea     eax, [eax*5]
-
 
1103
        lea     edi, [edi+eax*2]
-
 
1104
        add     edx, sizeof.COFF_SECTION
-
 
1105
        sub     ecx, 5
-
 
1106
        jnz     @b
-
 
1107
        stdcall kernel_alloc, edi
-
 
1108
        test    eax, eax
989
        sub     edi, ebx
1109
        jz      .fail_and_free_data
-
 
1110
        mov     edx, [coff]
-
 
1111
        movzx   ecx, [edx+COFF_HEADER.nSections]
-
 
1112
        lea     ecx, [ecx*5]
990
        jc      .fail_and_free_data
1113
        lea     ecx, [ecx*2+5]
-
 
1114
        mov     [esi+DLLDESCR.coff_hdr], eax
-
 
1115
        push    esi
-
 
1116
        mov     esi, edx
-
 
1117
        mov     edi, eax
-
 
1118
        rep movsd
-
 
1119
        pop     esi
-
 
1120
        mov     [esi+DLLDESCR.symbols_ptr], edi
991
        mov     [symbols_lim], edi
1121
        push    esi
-
 
1122
        mov     ecx, [edx+COFF_HEADER.nSymbols]
-
 
1123
        mov     [esi+DLLDESCR.symbols_num], ecx
-
 
1124
        mov     ecx, [esi+DLLDESCR.symbols_lim]
-
 
1125
        mov     esi, ebx
-
 
1126
        rep movsb
-
 
1127
        pop     esi
-
 
1128
        mov     ebx, [esi+DLLDESCR.coff_hdr]
-
 
1129
        push    esi
-
 
1130
        movzx   eax, [edx+COFF_HEADER.nSections]
-
 
1131
        lea     edx, [ebx+20]
-
 
1132
@@:
-
 
1133
        movzx   ecx, [edx+COFF_SECTION.NumReloc]
-
 
1134
        lea     ecx, [ecx*5]
-
 
1135
        mov     esi, [edx+COFF_SECTION.PtrReloc]
-
 
1136
        mov     [edx+COFF_SECTION.PtrReloc], edi
-
 
1137
        sub     [edx+COFF_SECTION.PtrReloc], ebx
-
 
1138
        add     esi, [coff]
-
 
1139
        shr     ecx, 1
-
 
1140
        rep movsd
-
 
1141
        adc     ecx, ecx
-
 
Line 1142... Line 992...
1142
        rep movsw
992
        add     ebx, edx
1143
        add     edx, sizeof.COFF_SECTION
-
 
1144
        dec     eax
993
; coff_hdr = coff
1145
        jnz     @b
994
; symbols_num = coff.nSymbols
1146
        pop     esi
-
 
1147
 
995
	mov	[symbols_ptr], ebx
1148
; fixup symbols
996
        mov     ebx, edx
1149
        mov     edx, ebx
997
 
Line 1150... Line 998...
1150
        mov     eax, [ebx+COFF_HEADER.nSymbols]
998
; fixup symbols
1151
        add     edx, 20
999
        mov     eax, [edx+COFF_HEADER.nSymbols]
1152
        mov     ecx, [esi+DLLDESCR.symbols_num]
1000
        add     edx, 20
1153
        lea     ecx, [ecx*9]
1001
        lea     ecx, [eax*9]
1154
        add     ecx, ecx
1002
        add     ecx, ecx
1155
        add     ecx, [esi+DLLDESCR.symbols_ptr]
1003
        add     ecx, [symbols_ptr]
Line 1156... Line 1004...
1156
 
1004
 
1157
        stdcall fix_coff_symbols, edx, [esi+DLLDESCR.symbols_ptr], eax, \
1005
        stdcall fix_coff_symbols, edx, [symbols_ptr], eax, \
1158
                ecx, 0
1006
                ecx, 0
Line 1159... Line 1007...
1159
;          test eax, eax
1007
;          test eax, eax
1160
;          jnz @F
1008
;          jnz @F
1161
;
1009
;
Line 1162... Line -...
1162
;@@:
-
 
1163
 
-
 
1164
        stdcall get_coff_sym, [esi+DLLDESCR.symbols_ptr], [ebx+COFF_HEADER.nSymbols], szEXPORTS
-
 
1165
        test    eax, eax
-
 
1166
        jnz     @F
-
 
1167
 
1010
;@@:
Line 1168... Line 1011...
1168
        stdcall get_coff_sym, [esi+DLLDESCR.symbols_ptr], [ebx+COFF_HEADER.nSymbols], sz_EXPORTS
1011
 
Line 1169... Line -...
1169
@@:
-
 
1170
        mov     [esi+DLLDESCR.exports], eax
-
 
1171
 
-
 
1172
; fix relocs in the hidden copy in kernel memory to default address
-
 
1173
; it is first fix; usually this will be enough, but second fix
-
 
1174
; can be necessary if real load address will not equal assumption
-
 
1175
        mov     eax, [esi+DLLDESCR.data]
-
 
1176
        sub     eax, [esi+DLLDESCR.defaultbase]
-
 
1177
        stdcall fix_coff_relocs, ebx, [esi+DLLDESCR.symbols_ptr], eax
-
 
1178
 
1012
        stdcall get_coff_sym, [symbols_ptr], [ebx+COFF_HEADER.nSymbols], szEXPORTS
1179
        stdcall kernel_free, [coff]
-
 
1180
 
-
 
1181
        cli
-
 
1182
; initialize DLLDESCR struct
-
 
1183
        and     dword [esi+DLLDESCR.refcount], 0; no HDLLs yet; later it will be incremented
-
 
1184
        mov     [esi+DLLDESCR.fd], dll_list
-
 
1185
        mov     eax, [dll_list.bk]
-
 
1186
        mov     [dll_list.bk], esi
-
 
1187
        mov     [esi+DLLDESCR.bk], eax
-
 
1188
        mov     [eax+DLLDESCR.fd], esi
-
 
1189
.dll_already_loaded:
-
 
1190
        stdcall kernel_free, [fullname]
-
 
1191
        inc     [esi+DLLDESCR.refcount]
-
 
1192
        push    esi
-
 
1193
        call    init_heap
-
 
1194
        pop     esi
-
 
1195
        mov     edi, [esi+DLLDESCR.size]
-
 
1196
        stdcall user_alloc_at, [esi+DLLDESCR.defaultbase], edi
-
 
1197
        test    eax, eax
-
 
1198
        jnz     @f
-
 
1199
        stdcall user_alloc, edi
-
 
1200
        test    eax, eax
-
 
1201
        jz      .fail_and_dereference
-
 
1202
@@:
-
 
1203
        mov     [img_base], eax
-
 
1204
        mov     eax, sizeof.HDLL
-
 
1205
        call    malloc
-
 
1206
        test    eax, eax
-
 
1207
        jz      .fail_and_free_user
-
 
1208
        mov     ebx, [current_slot_idx]
-
 
1209
        shl     ebx, 5
-
 
1210
        mov     edx, [TASK_TABLE+ebx+TASKDATA.pid]
-
 
1211
        mov     [eax+HDLL.pid], edx
-
 
1212
        push    eax
-
 
1213
        call    init_dlls_in_thread
-
 
1214
        pop     ebx
-
 
1215
        test    eax, eax
-
 
1216
        jz      .fail_and_free_user
-
 
1217
        mov     edx, [eax+HDLL.fd]
-
 
1218
        mov     [ebx+HDLL.fd], edx
-
 
1219
        mov     [ebx+HDLL.bk], eax
-
 
1220
        mov     [eax+HDLL.fd], ebx
-
 
1221
        mov     [edx+HDLL.bk], ebx
-
 
1222
        mov     eax, ebx
-
 
1223
        mov     ebx, [img_base]
-
 
1224
        mov     [eax+HDLL.base], ebx
-
 
1225
        mov     [eax+HDLL.size], edi
-
 
1226
        mov     [eax+HDLL.refcount], 1
-
 
1227
        mov     [eax+HDLL.parent], esi
-
 
1228
        mov     edx, ebx
-
 
1229
        shr     edx, 12
-
 
1230
        or      dword [page_tabs+(edx-1)*4], MEM_BLOCK_DONT_FREE
-
 
1231
; copy entries of page table from kernel-side image to usermode
-
 
1232
; use copy-on-write for user-mode image, so map as readonly
-
 
1233
        xor     edi, edi
-
 
1234
        mov     ecx, [esi+DLLDESCR.data]
-
 
1235
        shr     ecx, 12
-
 
1236
.map_pages_loop:
-
 
1237
        mov     eax, [page_tabs+ecx*4]
-
 
1238
        and     eax, not 0xFFF
-
 
Line 1239... Line -...
1239
        or      al, PG_UR
-
 
1240
        xchg    eax, [page_tabs+edx*4]
-
 
1241
        test    al, 1
-
 
1242
        jz      @f
-
 
1243
        call    free_page
-
 
1244
@@:
-
 
1245
        invlpg  [ebx+edi]
-
 
1246
        inc     ecx
-
 
1247
        inc     edx
1013
        test    eax, eax
1248
        add     edi, 0x1000
-
 
1249
        cmp     edi, [esi+DLLDESCR.size]
1014
        jnz     @F
Line 1250... Line 1015...
1250
        jb      .map_pages_loop
1015
 
1251
 
1016
        stdcall get_coff_sym, [symbols_ptr], [ebx+COFF_HEADER.nSymbols], sz_EXPORTS
1252
; if real user-mode base is not equal to preferred base, relocate image
-
 
1253
        sub     ebx, [esi+DLLDESCR.defaultbase]
-
 
1254
        jz      @f
-
 
1255
        stdcall rebase_coff, [esi+DLLDESCR.coff_hdr], [esi+DLLDESCR.symbols_ptr], ebx
1017
@@:
1256
@@:
1018
        mov     [exports], eax
1257
 
1019
 
1258
        mov     eax, [esi+DLLDESCR.exports]
1020
        stdcall fix_coff_relocs, ebx, [symbols_ptr], 0
1259
        sub     eax, [esi+DLLDESCR.defaultbase]
1021
 
1260
        add     eax, [img_base]
1022
        stdcall kernel_free, [coff]
1261
        sti
-
 
1262
        ret
-
 
1263
 
-
 
1264
.fail_and_free_data:
-
 
1265
        stdcall kernel_free, [esi+DLLDESCR.data]
-
 
1266
.fail_and_free_dll:
-
 
1267
        mov     eax, esi
-
 
1268
        call    free
-
 
1269
.fail_and_free_coff:
-
 
1270
        stdcall kernel_free, [coff]
1023
 
Line 1271... Line -...
1271
.fail:
-
 
1272
        stdcall kernel_free, [fullname]
-
 
1273
        xor     eax, eax
-
 
1274
        ret
-
 
1275
 
1024
        stdcall kernel_free, [fullname]
1276
.fail_and_free_user:
1025
 
1277
        stdcall user_free, [img_base]
1026
        mov     eax, [exports]
1278
.fail_and_dereference:
-
 
1279
        mov     eax, 1  ; delete 1 reference
-
 
1280
        call    dereference_dll
-
 
1281
        sti
-
 
1282
        xor     eax, eax
-
 
1283
        ret
-
 
1284
endp
1027
        ret
1285
 
-
 
1286
; initialize [APPDATA.dlls_list_ptr] for given thread
-
 
1287
; DLL is per-process object, so APPDATA.dlls_list_ptr must be
-
 
1288
; kept in sync for all threads of one process.
-
 
1289
; out: eax = APPDATA.dlls_list_ptr if all is OK,
-
 
1290
; NULL if memory allocation failed
-
 
1291
init_dlls_in_thread:
-
 
1292
        mov     ebx, [current_process]
-
 
1293
        mov     eax, [ebx+PROC.dlls_list_ptr]
-
 
1294
        test    eax, eax
-
 
1295
        jnz     .ret
-
 
1296
 
-
 
1297
        mov     eax, 8
1028
 
1298
        call    malloc                               ; FIXME
1029
.fail_and_free_data:
1299
        test    eax, eax
1030
	stdcall	user_free, [img_base]
1300
        jz      .ret
1031
.fail_and_free_coff:
1301
 
1032
        stdcall kernel_free, [coff]
1302
        mov     [eax], eax
1033
.fail:
1303
        mov     [eax+4], eax
-
 
1304
 
1034
        stdcall kernel_free, [fullname]
1305
        mov     ebx, [current_process]
1035
        xor     eax, eax
1306
        mov     [ebx+PROC.dlls_list_ptr], eax
1036
        ret
1307
.ret:
-
 
1308
        ret
-
 
1309
 
-
 
1310
; in: eax = number of references to delete, esi -> DLLDESCR struc
-
 
1311
dereference_dll:
-
 
1312
        sub     [esi+DLLDESCR.refcount], eax
-
 
1313
        jnz     .ret
-
 
1314
        mov     eax, [esi+DLLDESCR.fd]
-
 
1315
        mov     edx, [esi+DLLDESCR.bk]
-
 
1316
        mov     [eax+DLLDESCR.bk], edx
-
 
1317
        mov     [edx+DLLDESCR.fd], eax
-
 
1318
        stdcall kernel_free, [esi+DLLDESCR.coff_hdr]
-
 
1319
        stdcall kernel_free, [esi+DLLDESCR.data]
-
 
1320
        mov     eax, esi
-
 
1321
        call    free
-
 
1322
.ret:
-
 
1323
        ret
-
 
1324
 
-
 
1325
destroy_hdll:
-
 
1326
        push    ebx ecx esi edi
-
 
1327
        mov     ebx, [eax+HDLL.base]
-
 
1328
        mov     esi, [eax+HDLL.parent]
-
 
1329
        mov     edx, [esi+DLLDESCR.size]
-
 
1330
 
-
 
1331
        push    eax
-
 
1332
        mov     esi, [eax+HDLL.parent]
-
 
1333
        mov     eax, [eax+HDLL.refcount]
-
 
1334
        call    dereference_dll
-
 
1335
        pop     eax
-
 
1336
        mov     edx, [eax+HDLL.bk]
-
 
1337
        mov     ebx, [eax+HDLL.fd]
-
 
1338
        mov     [ebx+HDLL.bk], edx
-
 
1339
        mov     [edx+HDLL.fd], ebx
-
 
1340
        call    free
1037
endp
-
 
1038
 
Line 1341... Line 1039...
1341
        pop     edi esi ecx ebx
1039
; in: esi -> PEDESCR struct
1342
        ret
1040
proc dereference_pe
1343
 
1041
        mov     ecx, pe_list_mutex
1344
; ecx -> APPDATA for slot, esi = dlls_list_ptr
1042
        call    mutex_lock