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.

97 lines
2.0 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 1995 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: dllmain.c
  6. * Content: dpwsock.dll initialization
  7. * History:
  8. * Date By Reason
  9. * ==== == ======
  10. * 2/1 andyco created it
  11. ***************************************************************************/
  12. //#define WIN32_LEAN_AND_MEAN
  13. #include <windows.h>
  14. #include "dpf.h"
  15. #include "dpsp.h"
  16. #include "memalloc.h"
  17. #include "helpcli.h"
  18. DWORD dwRefCnt=0;// the # of attached processes
  19. BOOL bFirstTime;
  20. #undef DPF_MODNAME
  21. #define DPF_MODNAME "dpwsock sp dllmain"
  22. HANDLE ghInstance; // save this for our dialog box
  23. /*
  24. * DllMain
  25. */
  26. BOOL WINAPI DllMain(HINSTANCE hmod, DWORD dwReason, LPVOID lpvReserved)
  27. {
  28. switch( dwReason )
  29. {
  30. case DLL_PROCESS_ATTACH:
  31. DisableThreadLibraryCalls( hmod );
  32. DPFINIT(); // bugbug : dpfinit for every proc?
  33. DPF( 0, "====> ENTER: DLLMAIN(%08lx): Process Attach: %08lx, tid=%08lx", DllMain,
  34. GetCurrentProcessId(), GetCurrentThreadId() );
  35. /*
  36. * initialize memory
  37. */
  38. if( dwRefCnt == 0 )
  39. {
  40. INIT_DPSP_CSECT();
  41. if( !MemInit() )
  42. {
  43. DPF( 0, "LEAVING, COULD NOT MemInit" );
  44. return FALSE;
  45. }
  46. // save the instance
  47. ghInstance = hmod;
  48. }
  49. dwRefCnt++;
  50. break;
  51. case DLL_PROCESS_DETACH:
  52. DPF( 2, "====> ENTER: DLLMAIN(%08lx): Process Detach %08lx, tid=%08lx",
  53. DllMain, GetCurrentProcessId(), GetCurrentThreadId() );
  54. dwRefCnt--;
  55. if (0==dwRefCnt)
  56. {
  57. DPF(0,"DPWSOCK - dllmain - going away!");
  58. #ifdef DEBUG
  59. MemState();
  60. #endif // debug
  61. MemFini();
  62. FINI_DPSP_CSECT();
  63. HelpcliFini();
  64. }
  65. break;
  66. default:
  67. break;
  68. }
  69. return TRUE;
  70. } /* DllMain */