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.

122 lines
2.9 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1996-1997, Microsoft Corporation.
  4. //
  5. // File: main.cxx
  6. //
  7. // Contents: DLL entry point for query.dll
  8. //
  9. // History: 28-Feb-96 KyleP Created
  10. //
  11. //----------------------------------------------------------------------------
  12. #include <pch.cxx>
  13. #pragma hdrstop
  14. #include <ntverp.h>
  15. #define _DECL_DLLMAIN 1
  16. #include <process.h>
  17. DECLARE_INFOLEVEL(ci);
  18. DECLARE_INFOLEVEL(tb);
  19. DECLARE_INFOLEVEL(vq);
  20. char g_ciBuild[ 120 ] = "none";
  21. //
  22. // Needed because of using a common pch
  23. //
  24. CCoTaskAllocator CoTaskAllocator; // exported data definition
  25. void *
  26. CCoTaskAllocator::Allocate(ULONG cbSize)
  27. {
  28. return(CoTaskMemAlloc(cbSize));
  29. }
  30. void
  31. CCoTaskAllocator::Free(void *pv)
  32. {
  33. CoTaskMemFree(pv);
  34. }
  35. // I couldn't come up with a better way to do this than to have 2 macros
  36. #define MAKELITERALSTRING( s, lit ) s #lit
  37. #define MAKELITERAL( s, lit ) MAKELITERALSTRING( s, lit )
  38. //+---------------------------------------------------------------------------
  39. //
  40. // Function: DllMain
  41. //
  42. // Synopsis: Called from C-Runtime on process/thread attach/detach
  43. //
  44. // Arguments: [hInstance] -- Module handle
  45. // [dwReason] -- Reason for being called
  46. // [lpReserved] --
  47. //
  48. // History: 28-Feb-96 KyleP Created
  49. //
  50. //----------------------------------------------------------------------------
  51. BOOL WINAPI DllMain( HANDLE hInstance, DWORD dwReason, void * lpReserved )
  52. {
  53. BOOL fOk = TRUE;
  54. TRANSLATE_EXCEPTIONS;
  55. TRY
  56. {
  57. if ( fOk )
  58. {
  59. switch ( dwReason )
  60. {
  61. case DLL_PROCESS_ATTACH:
  62. {
  63. sprintf( g_ciBuild,
  64. "query (IS 3/NT 5) %s %s with %d headers on %s at %s.",
  65. #if CIDBG == 1
  66. "chk",
  67. #else // CIDBG == 1
  68. "fre",
  69. #endif // CIDBG == 1
  70. MAKELITERAL( "built by ", BUILD_USERNAME ),
  71. VER_PRODUCTBUILD,
  72. __DATE__,
  73. __TIME__ );
  74. DisableThreadLibraryCalls( (HINSTANCE)hInstance );
  75. //
  76. // Initialize unicode callouts
  77. //
  78. static UNICODECALLOUTS UnicodeCallouts = { WIN32_UNICODECALLOUTS };
  79. RtlSetUnicodeCallouts(&UnicodeCallouts);
  80. break;
  81. }
  82. case DLL_PROCESS_DETACH:
  83. // No need to call Shutdown here. It must already have
  84. // been called by this point since otherwise all of
  85. // our threads but this one will be terminated by now
  86. // by the system.
  87. break;
  88. }
  89. }
  90. }
  91. CATCH( CException, e )
  92. {
  93. // ignore
  94. }
  95. END_CATCH
  96. UNTRANSLATE_EXCEPTIONS;
  97. return fOk;
  98. }