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.

132 lines
3.5 KiB

  1. #ifndef _CDRIVER_H__
  2. #define _CDRIVER_H__
  3. /*++
  4. Copyright (C) Microsoft Corporation
  5. Module Name:
  6. cdriver.h
  7. Abstract:
  8. header file for cdriver.cpp. Defined CDriverFile, CDriver and CService
  9. Author:
  10. William Hsieh (williamh) created
  11. Revision History:
  12. --*/
  13. class CDriverFile
  14. {
  15. public:
  16. CDriverFile() : m_Win32Error(ERROR_FILE_NOT_FOUND), m_Attributes(0xFFFFFFFF),
  17. m_IsDriverBlocked(FALSE)
  18. {};
  19. BOOL Create(LPCTSTR ServiceName,
  20. BOOL LocalMachine,
  21. DWORD Win32Error = ERROR_FILE_NOT_FOUND,
  22. LPCTSTR pszDigitalSigner = NULL,
  23. HSDB hSDBDrvMain = NULL);
  24. LPCTSTR GetProvider()
  25. {
  26. return m_strProvider.IsEmpty() ? NULL : (LPCTSTR)m_strProvider;
  27. }
  28. LPCTSTR GetCopyright(void)
  29. {
  30. return m_strCopyright.IsEmpty() ? NULL : (LPCTSTR)m_strCopyright;
  31. }
  32. LPCTSTR GetVersion(void)
  33. {
  34. return m_strVersion.IsEmpty() ? NULL : (LPCTSTR)m_strVersion;
  35. }
  36. LPCTSTR GetFullPathName(void)
  37. {
  38. return m_strFullPathName.IsEmpty() ? NULL : (LPCTSTR)m_strFullPathName;
  39. }
  40. BOOL HasVersionInfo()
  41. {
  42. return m_HasVersionInfo;
  43. }
  44. DWORD GetWin32Error()
  45. {
  46. return m_Win32Error;
  47. }
  48. DWORD GetAttributes()
  49. {
  50. return m_Attributes;
  51. }
  52. LPCTSTR GetInfDigitalSigner(void)
  53. {
  54. return m_strDigitalSigner.IsEmpty() ? NULL : (LPCTSTR)m_strDigitalSigner;
  55. }
  56. BOOL IsDriverBlocked()
  57. {
  58. return m_IsDriverBlocked;
  59. }
  60. LPCTSTR GetBlockedDriverHtmlHelpID(void)
  61. {
  62. return m_strHtmlHelpID.IsEmpty() ? NULL : (LPCTSTR)m_strHtmlHelpID;
  63. }
  64. BOOL operator ==(CDriverFile& OtherDrvFile);
  65. private:
  66. BOOL GetVersionInfo();
  67. String m_strFullPathName;
  68. String m_strProvider;
  69. String m_strCopyright;
  70. String m_strVersion;
  71. String m_strDigitalSigner;
  72. String m_strHtmlHelpID;
  73. BOOL m_HasVersionInfo;
  74. BOOL m_IsDriverBlocked;
  75. DWORD m_Win32Error;
  76. DWORD m_Attributes;
  77. };
  78. class CDriver
  79. {
  80. public:
  81. CDriver() : m_pDevice(NULL), m_OnLocalMachine(TRUE), m_DriverListBuilt(FALSE),
  82. m_hSDBDrvMain(NULL)
  83. {
  84. m_DigitalSigner.Empty();
  85. }
  86. ~CDriver();
  87. BOOL Create(SC_HANDLE hscManager, LPTSTR tszServiceName);
  88. BOOL Create(CDevice* pDevice);
  89. BOOL GetFirstDriverFile(CDriverFile** ppDrvFile, PVOID& Context);
  90. BOOL GetNextDriverFile(CDriverFile** ppDrvFile, PVOID& Context);
  91. void AddDriverFile(CDriverFile* pDrvFile);
  92. BOOL IsLocal()
  93. {
  94. return m_OnLocalMachine;
  95. }
  96. int GetCount()
  97. {
  98. return m_listDriverFile.GetCount();
  99. }
  100. BOOL BuildDriverList(BOOL bFunctionAndFiltersOnly = FALSE);
  101. void GetDriverSignerString(String& strDriverSigner);
  102. private:
  103. // call back must be a static function(because of the hidden this parameter
  104. static UINT ScanQueueCallback(PVOID Context, UINT Notification, UINT_PTR Param1, UINT_PTR Param2);
  105. void AddFunctionAndFilterDrivers(CDevice* pDevice, HSPFILEQ hFileQueue = INVALID_HANDLE_VALUE);
  106. void CreateFromService(CDevice* pDevice, PCTSTR ServiceName, HSPFILEQ hFileQueue = INVALID_HANDLE_VALUE);
  107. BOOL GetFullPathFromImagePath(LPCTSTR ImagePath, LPTSTR FullPath, UINT FullPathLength);
  108. CList<CDriverFile*,CDriverFile* > m_listDriverFile;
  109. CDevice* m_pDevice;
  110. BOOL m_OnLocalMachine;
  111. BOOL m_DriverListBuilt;
  112. String m_DigitalSigner;
  113. HSDB m_hSDBDrvMain;
  114. };
  115. #endif // _CDRIVER_H__