Source code of Windows XP (NT5)
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.

198 lines
4.2 KiB

  1. #ifndef _DRVCLASS_H
  2. #define _DRVCLASS_H
  3. /*
  4. * title: drvclass.h
  5. *
  6. * purpose: header for wdm kernel device support class
  7. *
  8. */
  9. #define FALSE 0
  10. #define BOOL BOOLEAN
  11. #define BYTE unsigned char
  12. #define PBYTE unsigned char *
  13. //
  14. // CPacket
  15. //
  16. // A ringbuffer "node" class
  17. //
  18. class CPacket
  19. {
  20. // Methods
  21. public:
  22. USHORT& Function() { return m_Function; }
  23. USHORT& Socket() { return m_Socket; }
  24. // Instance variables
  25. private:
  26. USHORT m_Function;
  27. USHORT m_Socket;
  28. };
  29. //
  30. // CRingBuffer
  31. //
  32. // A ringbuffer class
  33. //
  34. class CRingBuffer
  35. {
  36. // Construction
  37. public:
  38. CRingBuffer( ULONG dwSize = 32, POOL_TYPE PoolType = PagedPool );
  39. ~CRingBuffer();
  40. // Methods
  41. public:
  42. void Insert( CPacket& APacket );
  43. BOOL Remove( CPacket* APacket );
  44. BOOL IsEmpty();
  45. BOOL IsValid() const { return ( m_pBuffer && m_pListMutex ); }
  46. // Restricted Access Methods
  47. protected:
  48. void Lock();
  49. void Unlock();
  50. // Instance Variables
  51. private:
  52. ULONG m_Producer;
  53. ULONG m_Consumer;
  54. CPacket* m_pBuffer;
  55. PKMUTEX m_pListMutex;
  56. ULONG m_dwSize;
  57. };
  58. //
  59. // CUString
  60. //
  61. // A class that encapsulates the functionality of
  62. // unicode strings.
  63. //
  64. // Revised on 03-May-96 - JohnT
  65. //
  66. #define OK_ALLOCATED(obj) \
  67. ((obj!=(void *)0) && NT_SUCCESS((obj)->m_status))
  68. void * __cdecl operator new(size_t nSize, POOL_TYPE iType, ULONG iPoolTag);
  69. void __cdecl operator delete(void* p);
  70. class CUString
  71. {
  72. // Construction
  73. public:
  74. // new CUString()
  75. CUString();
  76. // new CUString( ExistingCUString )
  77. CUString( CUString * );
  78. // new CUString( ExistingUnicodeString )
  79. CUString( UNICODE_STRING *);
  80. // new CUString( L"String" );
  81. CUString( PWCHAR );
  82. // new CUString( nNewLength );
  83. CUString( int );
  84. // new CUString( 105, 10 );
  85. CUString( int, int );
  86. // Standard destructor
  87. ~CUString();
  88. // Methods
  89. public:
  90. // String appending. Argument is appended to object
  91. void Append( CUString * );
  92. void Append( UNICODE_STRING* );
  93. void CopyTo( CUString* pTarget );
  94. BOOL operator == ( CUString& );
  95. void operator = ( CUString );
  96. int GetLength() const { return m_String.Length; }
  97. PWCHAR GetString() { return m_String.Buffer; }
  98. void SetLength( USHORT i ) { m_String.Length = i; }
  99. NTSTATUS ToCString( char** );
  100. static ULONG Length( PWCHAR );
  101. void Dump();
  102. // Class Methods
  103. protected:
  104. void NullTerminate()
  105. { m_String.Buffer[ m_String.Length / sizeof( WCHAR ) ] = ( WCHAR )NULL; }
  106. void ZeroBuffer()
  107. { ASSERT( m_String.Buffer ); RtlZeroMemory( m_String.Buffer, m_String.MaximumLength ); }
  108. // Enums
  109. public:
  110. enum
  111. {
  112. TYPE_SYSTEM_ALLOCATED = 0,
  113. TYPE_CLASS_ALLOCATED,
  114. };
  115. // Instance Variables
  116. public:
  117. UNICODE_STRING m_String;
  118. NTSTATUS m_status;
  119. unsigned char m_bType;
  120. };
  121. class CRegistry
  122. {
  123. private: PRTL_QUERY_REGISTRY_TABLE m_pTable;
  124. public: NTSTATUS m_status;
  125. signed long m_lDisposition;
  126. public: CRegistry(int iSize);
  127. ~CRegistry();
  128. BOOL QueryDirect(CUString *location,CUString *key, void **pReceiveBuffer, ULONG uType);
  129. BOOL QueryWithCallback(PRTL_QUERY_REGISTRY_ROUTINE callback,ULONG RelativeTo,PWSTR Path,PVOID Context, PVOID Environment);
  130. BOOL WriteString(ULONG relativeTo, CUString *pBuffer, CUString *pPath, CUString *pKey);
  131. BOOL WriteDWord(ULONG relativeTo, void *pBuffer,CUString *pPath,CUString *pKey);
  132. NTSTATUS zwCreateKey(HANDLE * pKeyHandle,HANDLE root,ACCESS_MASK DesiredAccess,CUString * pPath,ULONG CreateOptions);
  133. NTSTATUS zwOpenKey(HANDLE * pKeyHandle, HANDLE root, ACCESS_MASK DesiredAccess,CUString * pPath);
  134. BOOL zwCloseKey(HANDLE KeyHandle);
  135. NTSTATUS zwWriteValue(HANDLE hTheKey,CUString * ValueName,ULONG lType,PVOID pData,ULONG lSize);
  136. NTSTATUS CheckKey(ULONG RelativePath,PUNICODE_STRING path);
  137. };
  138. class CErrorLogEntry
  139. {
  140. private: PIO_ERROR_LOG_PACKET m_pPacket;
  141. public: CErrorLogEntry(PVOID,ULONG,USHORT,ULONG,NTSTATUS,ULONG *,UCHAR);
  142. ~CErrorLogEntry();
  143. };
  144. #endif //drvclass.h