Subversion Repositories Kolibri OS

Rev

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

Rev 3786 Rev 3827
Line 3... Line 3...
3
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2012. 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: 3786 $
8
$Revision: 3827 $
9
 
9
 
Line 1028... Line 1028...
1028
             fileinfo  rb 40
1028
             fileinfo  rb 40
1029
             coff      dd ?
1029
             coff      dd ?
1030
             img_base  dd ?
1030
             img_base  dd ?
1031
           endl
1031
           endl
Line 1032... Line -...
1032
 
-
 
1033
        cli
-
 
1034
 
1032
 
1035
; resolve file name
1033
; resolve file name
1036
        mov     ebx, [file_name]
1034
        mov     ebx, [file_name]
1037
        lea     edi, [fullname+1]
1035
        lea     edi, [fullname+1]
1038
        mov     byte [edi-1], '/'
1036
        mov     byte [edi-1], '/'
1039
        stdcall get_full_file_name, edi, 259
1037
        stdcall get_full_file_name, edi, 259
1040
        test    al, al
1038
        test    al, al
Line 1041... Line 1039...
1041
        jz      .fail
1039
        jz      .fail
1042
 
1040
 
-
 
1041
; scan for required DLL in list of already loaded for this process,
-
 
1042
; ignore timestamp
1043
; scan for required DLL in list of already loaded for this process,
1043
        cli
1044
; ignore timestamp
1044
 
1045
        mov     esi, [CURRENT_TASK]
1045
        mov     esi, [CURRENT_TASK]
1046
        shl     esi, 8
1046
        shl     esi, 8
1047
        lea     edi, [fullname]
1047
        lea     edi, [fullname]
Line 1063... Line 1063...
1063
        mov     ecx, [esi+HDLL.parent]
1063
        mov     ecx, [esi+HDLL.parent]
1064
        inc     [ecx+DLLDESCR.refcount]
1064
        inc     [ecx+DLLDESCR.refcount]
1065
        mov     eax, [ecx+DLLDESCR.exports]
1065
        mov     eax, [ecx+DLLDESCR.exports]
1066
        sub     eax, [ecx+DLLDESCR.defaultbase]
1066
        sub     eax, [ecx+DLLDESCR.defaultbase]
1067
        add     eax, [esi+HDLL.base]
1067
        add     eax, [esi+HDLL.base]
-
 
1068
        sti
1068
        ret
1069
        ret
1069
.next_in_process:
1070
.next_in_process:
1070
        mov     esi, [esi+HDLL.fd]
1071
        mov     esi, [esi+HDLL.fd]
1071
        jmp     .scan_in_process
1072
        jmp     .scan_in_process
1072
.not_in_process:
1073
.not_in_process:
Line 1073... Line 1074...
1073
 
1074
 
-
 
1075
; scan in full list, compare timestamp
1074
; scan in full list, compare timestamp
1076
        sti
1075
        lea     eax, [fileinfo]
1077
        lea     eax, [fileinfo]
1076
        stdcall get_fileinfo, edi, eax
1078
        stdcall get_fileinfo, edi, eax
1077
        test    eax, eax
1079
        test    eax, eax
-
 
1080
        jnz     .fail
1078
        jnz     .fail
1081
        cli
1079
        mov     esi, [dll_list.fd]
1082
        mov     esi, [dll_list.fd]
1080
.scan_for_dlls:
1083
.scan_for_dlls:
1081
        cmp     esi, dll_list
1084
        cmp     esi, dll_list
1082
        jz      .load_new
1085
        jz      .load_new
Line 1095... Line 1098...
1095
        mov     esi, [esi+DLLDESCR.fd]
1098
        mov     esi, [esi+DLLDESCR.fd]
1096
        jmp     .scan_for_dlls
1099
        jmp     .scan_for_dlls
Line 1097... Line 1100...
1097
 
1100
 
1098
; new DLL
1101
; new DLL
-
 
1102
.load_new:
1099
.load_new:
1103
        sti
1100
; load file
1104
; load file
1101
        stdcall load_file, edi
1105
        stdcall load_file, edi
1102
        test    eax, eax
1106
        test    eax, eax
1103
        jz      .fail
1107
        jz      .fail
Line 1122... Line 1126...
1122
        mov     esi, eax
1126
        mov     esi, eax
1123
        mov     eax, dword [fileinfo+24]
1127
        mov     eax, dword [fileinfo+24]
1124
        mov     dword [esi+DLLDESCR.timestamp], eax
1128
        mov     dword [esi+DLLDESCR.timestamp], eax
1125
        mov     eax, dword [fileinfo+28]
1129
        mov     eax, dword [fileinfo+28]
1126
        mov     dword [esi+DLLDESCR.timestamp+4], eax
1130
        mov     dword [esi+DLLDESCR.timestamp+4], eax
1127
; initialize DLLDESCR struct
-
 
1128
        and     dword [esi+DLLDESCR.refcount], 0; no HDLLs yet; later it will be incremented
-
 
1129
        mov     [esi+DLLDESCR.fd], dll_list
-
 
1130
        mov     eax, [dll_list.bk]
-
 
1131
        mov     [dll_list.bk], esi
-
 
1132
        mov     [esi+DLLDESCR.bk], eax
-
 
1133
        mov     [eax+DLLDESCR.fd], esi
-
 
Line 1134... Line 1131...
1134
 
1131
 
1135
; calculate size of loaded DLL
1132
; calculate size of loaded DLL
1136
        mov     edx, [coff]
1133
        mov     edx, [coff]
1137
        movzx   ecx, [edx+COFF_HEADER.nSections]
1134
        movzx   ecx, [edx+COFF_HEADER.nSections]
Line 1298... Line 1295...
1298
        sub     eax, [esi+DLLDESCR.defaultbase]
1295
        sub     eax, [esi+DLLDESCR.defaultbase]
1299
        stdcall fix_coff_relocs, ebx, [esi+DLLDESCR.symbols_ptr], eax
1296
        stdcall fix_coff_relocs, ebx, [esi+DLLDESCR.symbols_ptr], eax
Line 1300... Line 1297...
1300
 
1297
 
Line -... Line 1298...
-
 
1298
        stdcall kernel_free, [coff]
-
 
1299
 
-
 
1300
        cli
-
 
1301
; initialize DLLDESCR struct
-
 
1302
        and     dword [esi+DLLDESCR.refcount], 0; no HDLLs yet; later it will be incremented
-
 
1303
        mov     [esi+DLLDESCR.fd], dll_list
-
 
1304
        mov     eax, [dll_list.bk]
-
 
1305
        mov     [dll_list.bk], esi
1301
        stdcall kernel_free, [coff]
1306
        mov     [esi+DLLDESCR.bk], eax
1302
 
1307
        mov     [eax+DLLDESCR.fd], esi
1303
.dll_already_loaded:
1308
.dll_already_loaded:
1304
        inc     [esi+DLLDESCR.refcount]
1309
        inc     [esi+DLLDESCR.refcount]
1305
        push    esi
1310
        push    esi
Line 1370... Line 1375...
1370
@@:
1375
@@:
Line 1371... Line 1376...
1371
 
1376
 
1372
        mov     eax, [esi+DLLDESCR.exports]
1377
        mov     eax, [esi+DLLDESCR.exports]
1373
        sub     eax, [esi+DLLDESCR.defaultbase]
1378
        sub     eax, [esi+DLLDESCR.defaultbase]
-
 
1379
        add     eax, [img_base]
1374
        add     eax, [img_base]
1380
        sti
1375
        ret
1381
        ret
1376
.fail_and_free_data:
1382
.fail_and_free_data:
1377
        stdcall kernel_free, [esi+DLLDESCR.data]
1383
        stdcall kernel_free, [esi+DLLDESCR.data]
1378
.fail_and_free_dll:
1384
.fail_and_free_dll:
Line 1386... Line 1392...
1386
.fail_and_free_user:
1392
.fail_and_free_user:
1387
        stdcall user_free, [img_base]
1393
        stdcall user_free, [img_base]
1388
.fail_and_dereference:
1394
.fail_and_dereference:
1389
        mov     eax, 1  ; delete 1 reference
1395
        mov     eax, 1  ; delete 1 reference
1390
        call    dereference_dll
1396
        call    dereference_dll
-
 
1397
        sti
1391
        xor     eax, eax
1398
        xor     eax, eax
1392
        ret
1399
        ret
1393
endp
1400
endp
Line 1394... Line 1401...
1394
 
1401