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.

88 lines
1.7 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. dllentry.c
  5. Abstract:
  6. This module contains VdmDbgDllEntry, the entrypoint for
  7. vdmdbg.dll. We don't use CRT to speak of, if that changes
  8. this should be renamed DllMain, which DLLMainCRTStartup calls.
  9. Also in that case DisableThreadLibraryCalls may be inappropriate.
  10. Author:
  11. Dave Hart (davehart) 26-Oct-97 Added DllEntry to fix leak
  12. in repeated load/unloads.
  13. Revision History:
  14. --*/
  15. #include <precomp.h>
  16. #pragma hdrstop
  17. BOOL
  18. VdmDbgDllEntry(
  19. IN PVOID DllHandle,
  20. IN ULONG Reason,
  21. IN PCONTEXT Context OPTIONAL
  22. )
  23. /*++
  24. Routine Description:
  25. This function is the "entry point" for the DLL, called with
  26. process and thread attach and detach messages. We disable
  27. thread attach and detach notifications since we don't use them.
  28. The primary reason for this is to clean up open handles to
  29. the shared memory and associated mutex at process detach, so
  30. folks who load and unload vdmdbg.dll repeatedly won't leak.
  31. Arguments:
  32. DllHandle
  33. Reason
  34. Context - Not Used
  35. Return Value:
  36. STATUS_SUCCESS
  37. --*/
  38. {
  39. switch ( Reason ) {
  40. case DLL_PROCESS_ATTACH:
  41. DisableThreadLibraryCalls(DllHandle);
  42. break;
  43. case DLL_PROCESS_DETACH:
  44. //
  45. // Close handles to shared memory and mutex, if we're
  46. // being unloaded from the process (Context/lpReserved
  47. // NULL) as opposed to process shutdown (Context 1)
  48. //
  49. break;
  50. default:
  51. break;
  52. }
  53. return TRUE; // FALSE means don't load for DLL_PROCESS_ATTACH
  54. }