Rev 5088 | Rev 5356 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5088 | Rev 5130 | ||
---|---|---|---|
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: 5088 $ |
8 | $Revision: 5130 $ |
9 | 9 | ||
Line 916... | Line 916... | ||
916 | 916 | ||
917 | ; scan for required DLL in list of already loaded for this process, |
917 | ; scan for required DLL in list of already loaded for this process, |
918 | ; ignore timestamp |
918 | ; ignore timestamp |
Line 919... | Line 919... | ||
919 | cli |
919 | cli |
920 | - | ||
921 | mov esi, [CURRENT_TASK] |
920 | |
922 | shl esi, 8 |
921 | mov esi, [current_process] |
923 | lea edi, [fullname] |
922 | lea edi, [fullname] |
924 | mov ebx, [esi+SLOT_BASE+APPDATA.dlls_list_ptr] |
923 | mov ebx, [esi+PROC.dlls_list_ptr] |
925 | test ebx, ebx |
924 | test ebx, ebx |
926 | jz .not_in_process |
925 | jz .not_in_process |
927 | mov esi, [ebx+HDLL.fd] |
926 | mov esi, [ebx+HDLL.fd] |
Line 1279... | Line 1278... | ||
1279 | ; DLL is per-process object, so APPDATA.dlls_list_ptr must be |
1278 | ; DLL is per-process object, so APPDATA.dlls_list_ptr must be |
1280 | ; kept in sync for all threads of one process. |
1279 | ; kept in sync for all threads of one process. |
1281 | ; out: eax = APPDATA.dlls_list_ptr if all is OK, |
1280 | ; out: eax = APPDATA.dlls_list_ptr if all is OK, |
1282 | ; NULL if memory allocation failed |
1281 | ; NULL if memory allocation failed |
1283 | init_dlls_in_thread: |
1282 | init_dlls_in_thread: |
1284 | mov ebx, [current_slot] |
1283 | mov ebx, [current_process] |
1285 | mov eax, [ebx+APPDATA.dlls_list_ptr] |
1284 | mov eax, [ebx+PROC.dlls_list_ptr] |
1286 | test eax, eax |
1285 | test eax, eax |
1287 | jnz .ret |
1286 | jnz .ret |
1288 | push [ebx+APPDATA.dir_table] |
- | |
- | 1287 | ||
1289 | mov eax, 8 |
1288 | mov eax, 8 |
1290 | call malloc |
1289 | call malloc ; FIXME |
1291 | pop edx |
- | |
1292 | test eax, eax |
1290 | test eax, eax |
1293 | jz .ret |
1291 | jz .ret |
- | 1292 | ||
1294 | mov [eax], eax |
1293 | mov [eax], eax |
1295 | mov [eax+4], eax |
1294 | mov [eax+4], eax |
1296 | mov ecx, [TASK_COUNT] |
- | |
1297 | mov ebx, SLOT_BASE+256 |
- | |
1298 | .set: |
1295 | |
1299 | cmp [ebx+APPDATA.dir_table], edx |
1296 | mov ebx, [current_process] |
1300 | jnz @f |
- | |
1301 | mov [ebx+APPDATA.dlls_list_ptr], eax |
1297 | mov [ebx+PROC.dlls_list_ptr], eax |
1302 | @@: |
- | |
1303 | add ebx, 256 |
- | |
1304 | dec ecx |
- | |
1305 | jnz .set |
- | |
1306 | .ret: |
1298 | .ret: |
1307 | ret |
1299 | ret |
Line 1308... | Line 1300... | ||
1308 | 1300 | ||
1309 | ; in: eax = number of references to delete, esi -> DLLDESCR struc |
1301 | ; in: eax = number of references to delete, esi -> DLLDESCR struc |
Line 1321... | Line 1313... | ||
1321 | .ret: |
1313 | .ret: |
1322 | ret |
1314 | ret |
Line 1323... | Line 1315... | ||
1323 | 1315 | ||
1324 | destroy_hdll: |
1316 | destroy_hdll: |
1325 | push ebx ecx esi edi |
- | |
1326 | push eax |
1317 | push ebx ecx esi edi |
1327 | mov ebx, [eax+HDLL.base] |
1318 | mov ebx, [eax+HDLL.base] |
1328 | mov esi, [eax+HDLL.parent] |
1319 | mov esi, [eax+HDLL.parent] |
1329 | mov edx, [esi+DLLDESCR.size] |
- | |
1330 | ; The following actions require the context of application where HDLL is mapped. |
- | |
1331 | ; However, destroy_hdll can be called in the context of OS thread when |
- | |
1332 | ; cleaning up objects created by the application which is destroyed. |
- | |
1333 | ; So remember current cr3 and set it to page table of target. |
- | |
1334 | mov eax, [ecx+APPDATA.dir_table] |
- | |
1335 | ; Because we cheat with cr3, disable interrupts: task switch would restore |
- | |
1336 | ; page table from APPDATA of current thread. |
- | |
1337 | ; Also set [current_slot] because it is used by user_free. |
- | |
1338 | pushf |
- | |
1339 | cli |
- | |
1340 | push [current_slot] |
- | |
1341 | mov [current_slot], ecx |
- | |
1342 | mov ecx, cr3 |
- | |
1343 | push ecx |
- | |
1344 | mov cr3, eax |
- | |
1345 | push ebx ; argument for user_free |
- | |
1346 | mov eax, ebx |
- | |
1347 | shr ebx, 12 |
- | |
1348 | push ebx |
- | |
1349 | mov esi, [esi+DLLDESCR.data] |
- | |
1350 | shr esi, 12 |
- | |
1351 | .unmap_loop: |
- | |
1352 | push eax |
- | |
1353 | mov eax, 2 |
- | |
1354 | xchg eax, [page_tabs+ebx*4] |
- | |
1355 | mov ecx, [page_tabs+esi*4] |
- | |
1356 | and eax, not 0xFFF |
- | |
1357 | and ecx, not 0xFFF |
- | |
1358 | cmp eax, ecx |
- | |
1359 | jz @f |
- | |
1360 | call free_page |
1320 | mov edx, [esi+DLLDESCR.size] |
1361 | @@: |
- | |
1362 | pop eax |
- | |
1363 | invlpg [eax] |
- | |
1364 | add eax, 0x1000 |
- | |
1365 | inc ebx |
- | |
1366 | inc esi |
- | |
1367 | sub edx, 0x1000 |
- | |
1368 | ja .unmap_loop |
- | |
1369 | pop ebx |
- | |
1370 | and dword [page_tabs+(ebx-1)*4], not DONT_FREE_BLOCK |
- | |
1371 | call user_free |
- | |
1372 | ; Restore context. |
- | |
1373 | pop eax |
- | |
1374 | mov cr3, eax |
- | |
1375 | pop [current_slot] |
- | |
1376 | popf |
- | |
1377 | ; Ok, cheating is done. |
- | |
1378 | pop eax |
1321 | |
1379 | push eax |
1322 | push eax |
1380 | mov esi, [eax+HDLL.parent] |
1323 | mov esi, [eax+HDLL.parent] |
1381 | mov eax, [eax+HDLL.refcount] |
1324 | mov eax, [eax+HDLL.refcount] |
1382 | call dereference_dll |
1325 | call dereference_dll |