Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.3 KiB

  1. /*
  2. File libmain.c
  3. Contains lib main for mprapi.dll
  4. Paul Mayfield, 5/7/98
  5. */
  6. #include <windows.h>
  7. #include "sdolib.h"
  8. extern CRITICAL_SECTION DsrLock;
  9. extern CRITICAL_SECTION CfgLock;
  10. //
  11. // Standard Win32 lib main function gets called
  12. // as processes and threads attach and detach.
  13. //
  14. // Returns TRUE if successfull, false otherwise
  15. //
  16. BOOL MprLibMain(
  17. IN HANDLE hinstDll,
  18. IN DWORD fdwReason,
  19. IN LPVOID lpReserved)
  20. {
  21. static BOOL DsrLockInitialized;
  22. static BOOL CfgLockInitialized;
  23. switch (fdwReason) {
  24. case DLL_PROCESS_ATTACH:
  25. try {
  26. InitializeCriticalSection(&DsrLock);
  27. DsrLockInitialized = TRUE;
  28. InitializeCriticalSection(&CfgLock);
  29. CfgLockInitialized = TRUE;
  30. }
  31. except (EXCEPTION_EXECUTE_HANDLER) {
  32. return FALSE;
  33. }
  34. DisableThreadLibraryCalls(hinstDll);
  35. break;
  36. case DLL_PROCESS_DETACH:
  37. if (DsrLockInitialized)
  38. DeleteCriticalSection(&DsrLock);
  39. if (CfgLockInitialized)
  40. DeleteCriticalSection(&CfgLock);
  41. break;
  42. }
  43. return TRUE;
  44. }