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.

79 lines
1.6 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 1996 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: dllmain.c
  6. * Content: Main entry point for the DLL.
  7. * History:
  8. *@@BEGIN_MSINTERNAL
  9. * Date By Reason
  10. * ==== == ======
  11. * 4/10/96 kipo created it
  12. * 4/15/96 kipo added msinternal
  13. * 6/18/96 kipo changed ghInstance to be an HINSTANCE
  14. *@@END_MSINTERNAL
  15. ***************************************************************************/
  16. #include <windows.h>
  17. #include "dpf.h"
  18. DWORD gdwRefCount = 0; // no. of attached processes
  19. HINSTANCE ghInstance = NULL; // instance of our DLL
  20. /*
  21. * DllMain
  22. *
  23. * Main entry point for DLL.
  24. */
  25. #undef DPF_MODNAME
  26. #define DPF_MODNAME "DllMain"
  27. BOOL WINAPI DllMain(HINSTANCE hmod, DWORD dwReason, LPVOID lpvReserved)
  28. {
  29. switch( dwReason )
  30. {
  31. case DLL_PROCESS_ATTACH:
  32. DisableThreadLibraryCalls( hmod );
  33. DPFINIT(); // bugbug : dpfinit for every proc?
  34. DPF( 0, "====> ENTER: DLLMAIN(%08lx): Process Attach: %08lx, tid=%08lx", DllMain,
  35. GetCurrentProcessId(), GetCurrentThreadId() );
  36. // initialize memory
  37. if( gdwRefCount == 0 )
  38. {
  39. DPF(0,"dllmain - starting up!");
  40. // do one-time initializations
  41. // save the instance
  42. ghInstance = hmod;
  43. }
  44. gdwRefCount++;
  45. break;
  46. case DLL_PROCESS_DETACH:
  47. DPF( 2, "====> ENTER: DLLMAIN(%08lx): Process Detach %08lx, tid=%08lx",
  48. DllMain, GetCurrentProcessId(), GetCurrentThreadId() );
  49. gdwRefCount--;
  50. if (gdwRefCount == 0)
  51. {
  52. DPF(0,"dllmain - going away!");
  53. }
  54. break;
  55. default:
  56. break;
  57. }
  58. return TRUE;
  59. } // DllMain