Source code of Windows XP (NT5)
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.

99 lines
1.7 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. intidll.c
  5. Abstract:
  6. This file handles the DLLInitialize spooler API
  7. Environment:
  8. Win32 subsystem, DriverUI module, user mode
  9. Revision History:
  10. 07/17/96 -amandan-
  11. Created it.
  12. --*/
  13. #include "precomp.h"
  14. //
  15. // Global instance handle and critical section
  16. //
  17. HINSTANCE ghInstance;
  18. CRITICAL_SECTION gCriticalSection;
  19. BOOL WINAPI
  20. DllMain(
  21. HANDLE hModule,
  22. ULONG ulReason,
  23. PCONTEXT pContext
  24. )
  25. /*++
  26. Routine Description:
  27. This function is called when the system loads/unloads the DriverUI module.
  28. At DLL_PROCESS_ATTACH, InitializeCriticalSection is called to initialize
  29. the critical section objects.
  30. At DLL_PROCESS_DETACH, DeleteCriticalSection is called to release the
  31. critical section objects.
  32. Arguments:
  33. hModule handle to DLL module
  34. ulReason reason for the call
  35. pContext pointer to context (not used by us)
  36. Return Value:
  37. TRUE if DLL is initialized successfully, FALSE otherwise.
  38. --*/
  39. {
  40. WCHAR wchDllName[MAX_PATH];
  41. BOOL bKeepDllLoaded = FALSE;
  42. switch (ulReason)
  43. {
  44. case DLL_PROCESS_ATTACH:
  45. #if DBG
  46. if (GetEnvironmentVariable(TEXT("UnloadDriverUiDll"), NULL, 0))
  47. bKeepDllLoaded = FALSE;
  48. #endif
  49. //
  50. // Keep our driver UI dll always loaded in memory
  51. //
  52. if (bKeepDllLoaded && GetModuleFileName(hModule, wchDllName, MAX_PATH))
  53. LoadLibrary(wchDllName);
  54. ghInstance = hModule;
  55. InitializeCriticalSection(&gCriticalSection);
  56. break;
  57. case DLL_PROCESS_DETACH:
  58. DeleteCriticalSection(&gCriticalSection);
  59. break;
  60. }
  61. return TRUE;
  62. }