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.

117 lines
4.0 KiB

  1. /***************************************************************************\
  2. *
  3. * File: ResourceManager.h
  4. *
  5. * Description:
  6. * This file declares the ResourceManager used to setup and maintain all
  7. * Thread, Contexts, and other resources used by and with DirectUser.
  8. *
  9. *
  10. * History:
  11. * 4/18/2000: JStall: Created
  12. *
  13. * Copyright (C) 2000 by Microsoft Corporation. All rights reserved.
  14. *
  15. \***************************************************************************/
  16. #if !defined(SERVICES__ResourceManager_h__INCLUDED)
  17. #define SERVICES__ResourceManager_h__INCLUDED
  18. #pragma once
  19. #include "ComManager.h"
  20. #include "DxManager.h"
  21. struct RMData
  22. {
  23. DxManager manDX;
  24. };
  25. class ComponentFactory : public ListNodeT<ComponentFactory>
  26. {
  27. public:
  28. virtual HRESULT Init(UINT nComponent) PURE;
  29. };
  30. /***************************************************************************\
  31. *
  32. * ResourceManager manages all shared resources within DirectUser, including
  33. * initializing Threads and Contexts.
  34. *
  35. \***************************************************************************/
  36. class ResourceManager
  37. {
  38. // Construction
  39. public:
  40. static HRESULT Create();
  41. static void xwDestroy();
  42. // Operations
  43. public:
  44. static HRESULT InitContextNL(INITGADGET * pInit, BOOL fSharedThread, Context ** ppctxNew);
  45. static HRESULT InitComponentNL(UINT nOptionalComponent);
  46. static HRESULT UninitComponentNL(UINT nOptionalComponent);
  47. static void UninitAllComponentsNL();
  48. static void RegisterComponentFactory(ComponentFactory * pfac);
  49. inline static
  50. BOOL IsInitGdiPlus() { return s_fInitGdiPlus; }
  51. static void xwNotifyThreadDestroyNL();
  52. static RMData * GetData();
  53. static HBITMAP RequestCreateCompatibleBitmap(HDC hdc, int cxPxl, int cyPxl);
  54. static void RequestInitGdiplus();
  55. // Implementation
  56. protected:
  57. static HRESULT InitSharedThread();
  58. static void UninitSharedThread(BOOL fAbortInit);
  59. static void ResetSharedThread();
  60. static unsigned __stdcall
  61. SharedThreadProc(void * pvArg);
  62. static HRESULT CALLBACK
  63. SharedEventProc(HGADGET hgadCur, void * pvCur, EventMsg * pMsg);
  64. static void xwDoThreadDestroyNL(Thread * pthrDestroy);
  65. // Data
  66. protected:
  67. static long s_fInit; // RM has been initialized
  68. static HANDLE s_hthSRT; // Shared Resource Thread
  69. static DWORD s_dwSRTID; // Thread ID of SRT
  70. static HANDLE s_hevReady; // SRT has been initialized
  71. static HGADGET s_hgadMsg;
  72. static RMData * s_pData; // Dynamic RM data
  73. static CritLock s_lockContext; // Context creation / destruction
  74. static CritLock s_lockComponent;// Component creation / destruction
  75. static Thread * s_pthrSRT; // SRT thread
  76. static GList<Thread> s_lstAppThreads;
  77. // Set of non-SRT DU-enabled threads
  78. static int s_cAppThreads; // Non-SRT thread count
  79. #if DBG_CHECK_CALLBACKS
  80. static int s_cTotalAppThreads;
  81. // Number of application threads created during lifetime
  82. static BOOL s_fBadMphInit; // Initialization of MPH failed
  83. #endif
  84. // Requests
  85. static MSGID s_idCreateBuffer; // Create a new bitmap buffer
  86. static MSGID s_idInitGdiplus; // Initialize GDI+
  87. // Optional Components
  88. static GList<ComponentFactory>
  89. s_lstComponents; // Dynamic component initializers
  90. static BOOL s_fInitGdiPlus; // GDI+ is initialized
  91. static ULONG_PTR s_gplToken;
  92. static Gdiplus::GdiplusStartupOutput
  93. s_gpgso;
  94. };
  95. inline DxManager * GetDxManager();
  96. #include "ResourceManager.inl"
  97. #endif // SERVICES__ResourceManager_h__INCLUDED