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.

115 lines
2.7 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: misc.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. #include "pch.h"
  11. #include <advpub.h> // REGINSTALL
  12. /*-----------------------------------------------------------------------------
  13. / DPA_DestroyCallback
  14. / --------------
  15. / Same as in newer comctl32, but not present in NT4 SP4.
  16. /
  17. / In:
  18. / -
  19. / Out:
  20. /
  21. /----------------------------------------------------------------------------*/
  22. #if(_WIN32_WINNT < 0x0500)
  23. #include <comctrlp.h>
  24. void
  25. DPA_DestroyCallback(LPVOID hdpa, _PFNDPAENUMCALLBACK pfnCB, LPVOID pData)
  26. {
  27. if (!hdpa)
  28. return;
  29. if (pfnCB)
  30. {
  31. for (int i = 0; i < DPA_GetPtrCount(hdpa); i++)
  32. {
  33. if (!pfnCB(DPA_FastGetPtr(hdpa, i), pData))
  34. break;
  35. }
  36. }
  37. DPA_Destroy((HDPA)hdpa);
  38. }
  39. #endif
  40. /*-----------------------------------------------------------------------------
  41. / CallRegInstall
  42. / --------------
  43. / Called by DllRegisterServer and DllUnregisterServer to register/unregister
  44. / this module. Uses the ADVPACK APIs and loads our INF data from resources.
  45. /
  46. / In:
  47. / -
  48. / Out:
  49. / HRESULT
  50. /----------------------------------------------------------------------------*/
  51. HRESULT
  52. CallRegInstall(HMODULE hModule, LPCSTR pszSection)
  53. {
  54. HRESULT hr = E_FAIL;
  55. HINSTANCE hinstAdvPack;
  56. TraceEnter(TRACE_COMMON_MISC, "CallRegInstall");
  57. hinstAdvPack = LoadLibrary(TEXT("ADVPACK.DLL"));
  58. if (hinstAdvPack)
  59. {
  60. REGINSTALL pfnRegInstall = (REGINSTALL)GetProcAddress(hinstAdvPack, achREGINSTALL);
  61. if ( pfnRegInstall )
  62. {
  63. #ifdef UNICODE
  64. STRENTRY seReg[] =
  65. {
  66. // These two NT-specific entries must be at the end
  67. { "25", "%SystemRoot%" },
  68. { "11", "%SystemRoot%\\system32" },
  69. };
  70. STRTABLE stReg = { ARRAYSIZE(seReg), seReg };
  71. hr = pfnRegInstall(hModule, pszSection, &stReg);
  72. #else
  73. hr = pfnRegInstall(hModule, pszSection, NULL);
  74. #endif
  75. }
  76. FreeLibrary(hinstAdvPack);
  77. }
  78. TraceLeaveResult(hr);
  79. }
  80. // This wrapper function required to make prefast shut up when we are
  81. // initializing a critical section in a constructor.
  82. void
  83. ExceptionPropagatingInitializeCriticalSection(LPCRITICAL_SECTION critsec)
  84. {
  85. __try
  86. {
  87. ::InitializeCriticalSection(critsec);
  88. }
  89. // propagate the exception to our caller. This will cause Log::Log
  90. // to abort prematurely, which will jump to the the handler in
  91. // Log::GetInstance
  92. __except (EXCEPTION_CONTINUE_SEARCH)
  93. {
  94. }
  95. }