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.

89 lines
1.8 KiB

  1. //
  2. // gcompart.h
  3. //
  4. #ifndef GCOMPART_H
  5. #define GCOMPART_H
  6. #include "private.h"
  7. #include "tfprop.h"
  8. #include "smblock.h"
  9. #define INITIAL_GCOMPART_SIZE 0x10000
  10. class CGCompartList;
  11. extern CGCompartList g_gcomplist;
  12. #define CALCID(pgc, pgcl) (DWORD)(DWORD_PTR)((BYTE *)pgc - (BYTE *)&pgcl->rgGCompart[0]) / sizeof(GLOBALCOMPARTMENT)
  13. class CGCompartList
  14. {
  15. public:
  16. void CleanUp()
  17. {
  18. if (_psb)
  19. delete _psb;
  20. _psb = NULL;
  21. }
  22. BOOL Enter()
  23. {
  24. if (!_psb || !_psb->GetBase())
  25. return FALSE;
  26. if (ISINDLLMAIN())
  27. return TRUE;
  28. if (!_psb->GetMutex() || !_psb->GetMutex()->Enter())
  29. return FALSE;
  30. return TRUE;
  31. }
  32. void Leave()
  33. {
  34. if (ISINDLLMAIN())
  35. return;
  36. _psb->GetMutex()->Leave();
  37. }
  38. typedef struct tag_GLOBALCOMPARTMENTPROP {
  39. TfPropertyType type;
  40. union {
  41. GUID guid;
  42. DWORD dw;
  43. };
  44. } GLOBALCOMPARTMENTPROP;
  45. typedef struct tag_GLOBALCOMPARTMENT {
  46. GUID guid;
  47. DWORD dwId;
  48. LONG cRef;
  49. GLOBALCOMPARTMENTPROP gprop;
  50. } GLOBALCOMPARTMENT;
  51. typedef struct tag_GLOBALCOMPARTMENTLIST {
  52. ULONG ulNum;
  53. GLOBALCOMPARTMENT rgGCompart[1];
  54. } GLOBALCOMPARTMENTLIST;
  55. BOOL Init(SYSTHREAD *psfn);
  56. BOOL Start();
  57. BOOL Uninit(SYSTHREAD *psfn);
  58. DWORD SetProperty(REFGUID guid, TFPROPERTY *pProp);
  59. BOOL GetProperty(REFGUID guid, TFPROPERTY *pProp);
  60. DWORD GetId(REFGUID guid);
  61. private:
  62. GLOBALCOMPARTMENT *FindProperty(REFGUID guid);
  63. static CSharedBlock *_psb;
  64. static ULONG _ulCommitSize;
  65. static LONG _nRef;
  66. static BOOL _fCreate;
  67. };
  68. #endif // GCOMPART_H