Changeset 651 for trunk/src/kernel32/windll.cpp
- Timestamp:
- Aug 23, 1999, 7:04:14 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/windll.cpp
r634 r651 1 /* $Id: windll.cpp,v 1.1 3 1999-08-22 22:11:22sandervl Exp $ */1 /* $Id: windll.cpp,v 1.14 1999-08-23 17:02:35 sandervl Exp $ */ 2 2 3 3 /* … … 31 31 #include "exceptutil.h" 32 32 #include "cio.h" 33 #include "vmutex.h" 34 35 VMutex dlllistmutex; //protects linked lists of heaps 33 36 34 37 /*********************************** … … 40 43 //****************************************************************************** 41 44 //****************************************************************************** 42 Win32Dll::Win32Dll(char *szDllName) : Win32Image(szDllName), referenced(0), 43 fSkipEntryCalls(FALSE), fSystemDll(FALSE) 45 Win32Dll::Win32Dll(char *szDllName, Win32Image *parentImage) 46 : Win32Image(szDllName), referenced(0), 47 fSkipEntryCalls(FALSE), fSystemDll(FALSE), 48 fAttachedToProcess(FALSE) 44 49 { 45 50 fSystemDll = isSystemDll(szFileName); 46 51 fUnloaded = FALSE; 47 next = head; 48 head = this; 52 53 dlllistmutex.enter(); 54 if(head == NULL || parentImage == NULL || parentImage->isDll() == FALSE) { //does the head dll depend on this one? 55 next = head; 56 head = this; 57 } 58 else { 59 //If we have a parent, we must make sure it is deleted before we are! 60 //(inserted after the parent) 61 if(head == parentImage) { 62 next = head->next; 63 head->next = this; 64 } 65 else { 66 Win32Dll *cur = head; 67 while(cur) { 68 if(cur == parentImage) { 69 break; 70 } 71 cur = cur->next; 72 } 73 next = cur->next; 74 cur->next = this; 75 } 76 } 77 dlllistmutex.leave(); 49 78 50 79 dllEntryPoint = 0; 51 80 52 dprintf(("Win32Dll::Win32Dll %s %s", szFileName, szModule)); 81 dprintf(("Win32Dll::Win32Dll %s %s loaded by %s", szFileName, szModule, 82 (parentImage) ? parentImage->getModuleName() : "Unknown")); 53 83 } 54 84 //****************************************************************************** … … 57 87 WIN32DLLENTRY DllEntryPoint) : 58 88 Win32Image(hinstance, NameTableId, Win32TableId), 59 referenced(0), fSkipEntryCalls(FALSE), fSystemDll(FALSE) 89 referenced(0), fSkipEntryCalls(FALSE), fSystemDll(FALSE), 90 fAttachedToProcess(FALSE) 60 91 { 61 92 dllEntryPoint = DllEntryPoint; 62 93 fUnloaded = FALSE; 94 95 dlllistmutex.enter(); 63 96 next = head; 64 97 head = this; 98 dlllistmutex.leave(); 65 99 66 100 dprintf(("Win32Dll::Win32Dll %s", szModule)); … … 86 120 //first remove it from the linked list so converted win32 dlls won't 87 121 //be deleted twice (as DosFreeModule results in a call to DllExitList (wprocess.cpp) 122 dlllistmutex.enter(); 88 123 if(head == this) { 89 124 head = next; … … 95 130 if(dll == NULL) { 96 131 dprintf(("~Win32Dll: Can't find dll!\n")); 132 dlllistmutex.leave(); 97 133 return; 98 134 } 99 135 dll->next = next; 100 136 } 137 dlllistmutex.leave(); 101 138 if(errorState == NO_ERROR && !fUnloaded) 102 139 { … … 281 318 BOOL rc; 282 319 320 if(fAttachedToProcess) 321 return TRUE; 322 323 fAttachedToProcess = TRUE; 324 283 325 //Allocate TLS index for this module 284 326 tlsAlloc(); … … 380 422 void Win32Dll::attachThreadToAllDlls() 381 423 { 382 Win32Dll *dll = Win32Dll::head; 383 424 Win32Dll *dll = Win32Dll::head; 384 425 while(dll) { 385 426 dll->attachThread(); … … 392 433 void Win32Dll::detachThreadFromAllDlls() 393 434 { 394 Win32Dll *dll = Win32Dll::head; 395 435 Win32Dll *dll = Win32Dll::head; 396 436 while(dll) { 397 437 dll->detachThread(); … … 404 444 void Win32Dll::tlsAttachThreadToAllDlls() 405 445 { 406 Win32Dll *dll = Win32Dll::head; 407 446 Win32Dll *dll = Win32Dll::head; 408 447 while(dll) { 409 448 dll->tlsAttachThread(); … … 416 455 void Win32Dll::tlsDetachThreadFromAllDlls() 417 456 { 418 Win32Dll *dll = Win32Dll::head; 419 457 Win32Dll *dll = Win32Dll::head; 420 458 while(dll) { 421 459 dll->tlsDetachThread(); … … 427 465 void Win32Dll::deleteAll() 428 466 { 429 //LIFO removal 467 #ifdef DEBUG 468 dlllistmutex.enter(); 469 Win32Dll *dll = head; 470 471 dprintf(("Win32Dll::deleteAll: List of loaded dlls:")); 472 while(dll) { 473 dprintf(("DLL %s", dll->szModule)); 474 dll = dll->next; 475 } 476 dlllistmutex.leave(); 477 #endif 478 430 479 while(Win32Dll::head) { 431 480 delete Win32Dll::head; … … 436 485 Win32Dll *Win32Dll::findModule(char *dllname) 437 486 { 438 Win32Dll *dll = head;487 Win32Dll *dll; 439 488 char szDllName[CCHMAXPATH]; 440 489 char *dot, *temp; … … 448 497 *dot = 0; 449 498 499 dlllistmutex.enter(); 500 dll = head; 450 501 while(dll) { 451 if(strcmpi(szDllName, dll->szModule) == 0) 502 if(strcmpi(szDllName, dll->szModule) == 0) { 503 dlllistmutex.leave(); 452 504 return(dll); 505 } 453 506 454 507 dll = dll->next; 455 508 } 509 dlllistmutex.leave(); 456 510 return(NULL); 457 511 } … … 460 514 Win32Dll *Win32Dll::findModule(WIN32DLLENTRY DllEntryPoint) 461 515 { 462 Win32Dll *mod = Win32Dll::head;463 464 516 dprintf(("findModule %X", DllEntryPoint)); 517 518 dlllistmutex.enter(); 519 Win32Dll *mod = Win32Dll::head; 465 520 while(mod != NULL) { 466 521 dbgCheckObj(mod); 467 if(mod->dllEntryPoint == DllEntryPoint) 522 if(mod->dllEntryPoint == DllEntryPoint) { 523 dlllistmutex.leave(); 468 524 return(mod); 525 } 469 526 mod = mod->next; 470 527 } 528 dlllistmutex.leave(); 471 529 return(NULL); 472 530 } … … 475 533 Win32Dll *Win32Dll::findModule(HINSTANCE hinstance) 476 534 { 477 Win32Dll *mod = Win32Dll::head;478 479 // eprintf(("findModule inst %X", hinstance));535 dlllistmutex.enter(); 536 537 Win32Dll *mod = Win32Dll::head; 480 538 while(mod != NULL) { 481 539 dbgCheckObj(mod); 482 if(mod->hinstance == hinstance) 540 if(mod->hinstance == hinstance) { 541 dlllistmutex.leave(); 483 542 return(mod); 543 } 484 544 mod = mod->next; 485 545 } 546 dlllistmutex.leave(); 486 547 return(NULL); 487 548 }
Note:
See TracChangeset
for help on using the changeset viewer.