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.

157 lines
3.7 KiB

  1. /*++
  2. Copyright (c) 1997-1999 Microsoft Corporation
  3. Module Name:
  4. wlnotify.cxx
  5. Abstract:
  6. Main source file for the common DLL that receives Winlogon
  7. notifications.
  8. Author:
  9. Gopal Parupudi <GopalP>
  10. Notes:
  11. A. BACKGROUND:
  12. In Windows 2000, Winlogon allows components to hook into various events
  13. like Logon, Logoff, Lock, Unlock etc via the new Winlogon notifications.
  14. Components are required to write a DLL with exports (that process these
  15. notifications) and add them to the registry under HKLM\Software\Microsoft
  16. \Windows NT\CurrentVersion\Winlogon\Notify Key.
  17. B. PERFORMANCE ISSUE:
  18. As more and more components started hooking into these notifications, the
  19. number of DLLs that were being loaded increased. These notification DLLs
  20. also brought in other DLLs that they were implicitly linked to them and
  21. that were not related to processing of these notifications. This common
  22. DLL is a way to cut down on the number of DLLs that are loaded into the
  23. Winlogon process.
  24. C. HOW TO MERGE YOUR DLL INTO THIS DLL:
  25. In order to merge your DLL into this common notifcation DLL, you need to
  26. take the following steps:
  27. 1. Compile and link your notification processing code into a library
  28. that is propagated to $(BASEDIR)\public\sdk\lib directory. Please
  29. ensure that there is no excess baggage in this library.
  30. 2. Enlist in \nt\private\dllmerge\wlnotify directory.
  31. 3. Modify the sources file to link your library into the DLL.
  32. 4. Add your exports to the .def file for this common DLL. Please
  33. ensure that the names of exports reflect the component that is
  34. processing the notification.
  35. 5. Add your exports to the Winlogon notification registry key, if
  36. you haven't done so already. Modify the DLL name in this registry
  37. key to point to the common DLL.
  38. 6. Remove your standalone notification DLL from the system.
  39. 7. Make sure you boot test your changes before checking them in.
  40. Revision History:
  41. GopalP 1/15/1999 Start.
  42. --*/
  43. //
  44. // Includes
  45. //
  46. #include <nt.h>
  47. #include <ntrtl.h>
  48. #include <nturtl.h>
  49. #include <windows.h>
  50. //
  51. // Globals
  52. //
  53. HANDLE ghNotifyHeap;
  54. #ifdef __cplusplus
  55. extern "C" {
  56. #endif
  57. BOOL TSDLLInit(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved);
  58. #ifdef __cplusplus
  59. }
  60. #endif
  61. #define IsTerminalServer() (BOOLEAN)(USER_SHARED_DATA->SuiteMask & (1 << TerminalServer))
  62. //
  63. // Functions
  64. //
  65. extern "C" int APIENTRY
  66. DllMain(
  67. IN HINSTANCE hInstance,
  68. IN DWORD dwReason,
  69. IN LPVOID lpvReserved
  70. )
  71. /*++
  72. Routine Description:
  73. This routine will get called either when a process attaches to this dll
  74. or when a process detaches from this dll.
  75. Arguments:
  76. Standard DllMain signature.
  77. Return Value:
  78. TRUE - Initialization successfully occurred.
  79. FALSE - Insufficient memory is available for the process to attach to
  80. this dll.
  81. --*/
  82. {
  83. BOOL bSuccess;
  84. switch (dwReason)
  85. {
  86. case DLL_PROCESS_ATTACH:
  87. //
  88. // Disable Thread attach/detach calls
  89. //
  90. bSuccess = DisableThreadLibraryCalls(hInstance);
  91. ASSERT(bSuccess == TRUE);
  92. // Use Default Process heap
  93. ghNotifyHeap = GetProcessHeap();
  94. ASSERT(ghNotifyHeap != NULL);
  95. break;
  96. case DLL_PROCESS_DETACH:
  97. break;
  98. }
  99. if (IsTerminalServer()) {
  100. TSDLLInit(hInstance, dwReason, lpvReserved);
  101. }
  102. return(TRUE);
  103. }