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.

58 lines
1.1 KiB

  1. //+-----------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (c) Microsoft Corporation 2000
  6. //
  7. // File: SafeCS.h
  8. //
  9. // Contents: CSafeAutoCriticalSection, protects CriticalSection against AV via try,catch
  10. //
  11. //------------------------------------------------------------------------
  12. #ifndef _SAFECS_H_
  13. #define _SAFECS_H_
  14. class CSafeAutoCriticalSection
  15. {
  16. public:
  17. CSafeAutoCriticalSection();
  18. ~CSafeAutoCriticalSection();
  19. DWORD Lock();
  20. DWORD Unlock();
  21. BOOL IsInitialized() { return (STATE_INITIALIZED == m_lState);}
  22. private:
  23. enum
  24. {
  25. STATE_UNINITIALIZED = 0,
  26. STATE_INITIALIZED = 1
  27. };
  28. CRITICAL_SECTION m_cs;
  29. LONG m_lState;
  30. DWORD m_dwError;
  31. };
  32. class CSafeLock
  33. {
  34. public:
  35. CSafeLock (CSafeAutoCriticalSection* val);
  36. CSafeLock (CSafeAutoCriticalSection& val);
  37. ~CSafeLock ();
  38. DWORD Lock ();
  39. DWORD Unlock ();
  40. private:
  41. private:
  42. BOOL m_locked;
  43. CSafeAutoCriticalSection* m_pSem;
  44. };
  45. #endif // _SAFECS_H_