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.

137 lines
2.9 KiB

  1. /* File: D:\WACKER\term.c (Created: 23-Nov-1993)
  2. *
  3. * Copyright 1994 by Hilgraeve Inc. -- Monroe, MI
  4. * All rights reserved
  5. *
  6. * $Revision: 3 $
  7. * $Date: 12/20/00 4:36p $
  8. */
  9. #include <windows.h>
  10. #pragma hdrstop
  11. #include <tdll\tdll.h>
  12. #if !defined(NDEBUG)
  13. //#include <nih\smrtheap.h>
  14. // 'MemDefaultPoolFlags = MEM_POOL_SERIALIZE' is required by Smartheap
  15. // if app is multithreaded.
  16. //
  17. #if !defined(NO_SMARTHEAP)
  18. unsigned MemDefaultPoolFlags = MEM_POOL_SERIALIZE;
  19. #endif
  20. #endif
  21. #if defined(MSVS6_DEBUG)
  22. #if defined(_DEBUG)
  23. //
  24. // If compiling a debug build with VC6, then turn on the
  25. // new heap debugging tools. To enable this, add the
  26. // define of MSVS6_DEBUG in your personal.cfg.
  27. //
  28. #include <crtdbg.h>
  29. #endif // _DEBUG
  30. #endif // MSVS6_DEBUG
  31. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  32. * FUNCTION:
  33. * WinMain
  34. *
  35. * DESCRIPTION:
  36. * Entry point for wacker
  37. *
  38. */
  39. int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow)
  40. {
  41. int i;
  42. #if defined(MSVS6_DEBUG)
  43. #if defined(_DEBUG)
  44. //
  45. // If compiling a debug build with VC6, then turn on the
  46. // new heap debugging tools. To enable this, add the
  47. // define of MSVS6_DEBUG in your personal.cfg.
  48. //
  49. // Get the current state of the flag
  50. // and store it in a temporary variable
  51. //
  52. int tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG );
  53. //
  54. // Turn On (OR) - Keep freed memory blocks in the
  55. // heap�s linked list and mark them as freed
  56. //
  57. tmpFlag |= _CRTDBG_DELAY_FREE_MEM_DF;
  58. //
  59. // Turn On (OR) - Enable debug heap allocations
  60. // and use of memory block type identifiers,
  61. // such as _CLIENT_BLOCK.
  62. //
  63. tmpFlag |= _CRTDBG_ALLOC_MEM_DF;
  64. //
  65. // Turn On (OR) - Enable debug heap memory leak check
  66. // at program exit.
  67. //
  68. tmpFlag |= _CRTDBG_LEAK_CHECK_DF;
  69. //
  70. // Turn Off (AND) - prevent _CrtCheckMemory from
  71. // being called at every allocation request
  72. //
  73. tmpFlag &= ~_CRTDBG_CHECK_ALWAYS_DF;
  74. //
  75. // Set the new state for the flag
  76. //
  77. _CrtSetDbgFlag( tmpFlag );
  78. #endif // _DEBUG
  79. #endif // MSVS6_DEBUG
  80. if (hPrevInst)
  81. return FALSE;
  82. /* --- Initialize Smartheap memory manager for debug version only. --- */
  83. #if !defined(NDEBUG)
  84. #if !defined(NO_SMARTHEAP)
  85. MemRegisterTask();
  86. #endif
  87. #endif
  88. /* --- Initialize this instance of the program --- */
  89. if (!InitInstance(hInst, (LPTSTR)lpCmdLine, nCmdShow))
  90. return FALSE;
  91. /* --- Process messages until the end --- */
  92. i = MessageLoop();
  93. /* --- Report any memory leaks in debug version only. --- */
  94. #if !defined(NDEBUG)
  95. #if !defined(NO_SMARTHEAP)
  96. dbgMemReportLeakage(MemDefaultPool, 1, 1); //lint !e522
  97. #endif
  98. #endif
  99. #if defined(MSVS6_DEBUG)
  100. #if defined(_DEBUG)
  101. //
  102. // Dump any memory leaks here.
  103. //
  104. _CrtDumpMemoryLeaks();
  105. #endif // _DEBUG
  106. #endif // MSVS6_DEBUG
  107. return i;
  108. }