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.

65 lines
1.5 KiB

  1. // @doc
  2. /**********************************************************************
  3. *
  4. * @module GckCritSec |
  5. *
  6. * Implementation of CGckCritSection
  7. *
  8. * History
  9. * ----------------------------------------------------------
  10. * Mitchell S. Dernis Original
  11. *
  12. * (c) 1986-1998 Microsoft Corporation. All right reserved.
  13. *
  14. * @topic filter |
  15. * CGckCritSection provides mutex/critical section support for CDeviceFilter
  16. * it is abstracted into this class for easier porting to USER mode.
  17. *
  18. * CGckMutexHandle is used to hold the mutex that is held during a critical section.
  19. * The kernel mode version uses critical section.
  20. *
  21. **********************************************************************/
  22. #ifndef __GckCritSec_h__
  23. #define __GckCritSec_h__
  24. #ifdef COMPILE_FOR_WDM_KERNEL_MODE
  25. //
  26. // The kernel mode version of these classes
  27. //
  28. class CGckMutexHandle
  29. {
  30. public:
  31. friend class CGckCritSection;
  32. friend class CGckMutex;
  33. CGckMutexHandle()
  34. {
  35. KeInitializeSpinLock(&m_SpinLock);
  36. }
  37. private:
  38. KSPIN_LOCK m_SpinLock;
  39. };
  40. class CGckCritSection
  41. {
  42. public:
  43. CGckCritSection(CGckMutexHandle *pMutexHandle):
  44. m_pMutexHandle(pMutexHandle)
  45. {
  46. KeAcquireSpinLock(&m_pMutexHandle->m_SpinLock, &m_OldIrql);
  47. }
  48. ~CGckCritSection()
  49. {
  50. KeReleaseSpinLock(&m_pMutexHandle->m_SpinLock, m_OldIrql);
  51. }
  52. private:
  53. CGckMutexHandle *m_pMutexHandle;
  54. KIRQL m_OldIrql;
  55. };
  56. #endif
  57. //
  58. // Place USER mode definitions here. (protecting with #ifdef of course).
  59. //
  60. #endif