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.

94 lines
1.8 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. DWORD dwRefCnt=0;// the # of attached processes
  18. BOOL bFirstTime;
  19. #undef DPF_MODNAME
  20. #define DPF_MODNAME "dpwsock sp dllmain"
  21. HANDLE ghInstance; // save this for our dialog box
  22. /*
  23. * DllMain
  24. */
  25. BOOL WINAPI DllMain(HINSTANCE hmod, DWORD dwReason, LPVOID lpvReserved)
  26. {
  27. switch( dwReason )
  28. {
  29. case DLL_PROCESS_ATTACH:
  30. DisableThreadLibraryCalls( hmod );
  31. DPFINIT(); // bugbug : dpfinit for every proc?
  32. DPF( 0, "====> ENTER: DLLMAIN(%08lx): Process Attach: %08lx, tid=%08lx", DllMain,
  33. GetCurrentProcessId(), GetCurrentThreadId() );
  34. /*
  35. * initialize memory
  36. */
  37. if( dwRefCnt == 0 )
  38. {
  39. INIT_DPSP_CSECT();
  40. if( !MemInit() )
  41. {
  42. DPF( 0, "LEAVING, COULD NOT MemInit" );
  43. return FALSE;
  44. }
  45. // save the instance
  46. ghInstance = hmod;
  47. }
  48. dwRefCnt++;
  49. break;
  50. case DLL_PROCESS_DETACH:
  51. DPF( 2, "====> ENTER: DLLMAIN(%08lx): Process Detach %08lx, tid=%08lx",
  52. DllMain, GetCurrentProcessId(), GetCurrentThreadId() );
  53. dwRefCnt--;
  54. if (0==dwRefCnt)
  55. {
  56. DPF(0,"DPWSOCK - dllmain - going away!");
  57. #ifdef DEBUG
  58. MemState();
  59. #endif // debug
  60. MemFini();
  61. FINI_DPSP_CSECT();
  62. }
  63. break;
  64. default:
  65. break;
  66. }
  67. return TRUE;
  68. } /* DllMain */