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.

46 lines
942 B

  1. template<SIZE_T Offset>
  2. class TrackedClassObject
  3. {
  4. static LONG* GetCounter()
  5. {
  6. return reinterpret_cast<LONG*>( reinterpret_cast<char*>( g_GlobalInfo->m_StatSection ) + Offset );
  7. }
  8. protected:
  9. TrackedClassObject()
  10. {
  11. InterlockedIncrement( GetCounter() );
  12. }
  13. ~TrackedClassObject()
  14. {
  15. if (g_ServiceState == MANAGER_INACTIVE)
  16. {
  17. return;
  18. }
  19. InterlockedDecrement( GetCounter() );
  20. }
  21. };
  22. //------------------------------------------------------------------------
  23. template<class T>
  24. class CSimpleExternalIUnknown : public T
  25. {
  26. public:
  27. // IUnknown Methods
  28. STDMETHOD(QueryInterface)(REFIID riid, void **ppvObject);
  29. ULONG _stdcall AddRef(void);
  30. ULONG _stdcall Release(void);
  31. protected:
  32. CSimpleExternalIUnknown();
  33. virtual ~CSimpleExternalIUnknown();
  34. long m_ServiceInstance;
  35. LONG m_refs;
  36. };