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.

166 lines
3.8 KiB

  1. #ifndef _CHECK_DEVICE_H_
  2. #define _CHECK_DEVICE_H_
  3. #include <windows.h>
  4. #include <infnode.h>
  5. #include <setupapi.h>
  6. #include <regstr.h>
  7. #include <wincrypt.h>
  8. #include <wintrust.h>
  9. #include <mscat.h>
  10. #include <softpub.h>
  11. //#define HASH_SIZE 40 // TODO: is this correct???
  12. int __stdcall FindDriverFiles(LPCSTR szDeviceID, LPSTR szBuffer, DWORD dwLength);
  13. UINT __stdcall ScanQueueCallback(PVOID pvContext, UINT Notify, UINT_PTR Param1, UINT_PTR Param2);
  14. BOOL CheckFile (TCHAR *szFileName);
  15. #define WINDOWS_2000_BETA_AUTHORITY "Microsoft Windows 2000 Beta"
  16. #define WINDOWS_2000_REAL_AUTHORITY "Microsoft Windows 2000 Publisher"
  17. #define WINDOWS_ME_REAL_AUTHORITY "Microsoft Consumer Windows Publisher"
  18. struct LogoFileVersion
  19. {
  20. DWORD dwProductVersionLS;
  21. DWORD dwProductVersionMS;
  22. DWORD dwFileVersionLS;
  23. DWORD dwFileVersionMS;
  24. LogoFileVersion();
  25. };
  26. #define pFileVersion *FileVersion
  27. struct CatalogAttribute
  28. {
  29. TCHAR *Attrib;
  30. TCHAR *Value;
  31. void *pNext;
  32. CatalogAttribute();
  33. ~CatalogAttribute();
  34. };
  35. class CheckDevice; //forward declaration
  36. class FileNode
  37. {
  38. friend class CheckDevice;
  39. public:
  40. LogoFileVersion Version;
  41. FILETIME TimeStamp;
  42. ULONG FileSize; // hope no-one makes a driver that is greater in size than 4-gig
  43. BYTE *baHashValue;
  44. DWORD dwHashSize;
  45. BOOL bSigned;
  46. FileNode *pNext;
  47. FileNode();
  48. ~FileNode();
  49. BOOL GetCatalogInfo(LPWSTR lpwzCatName, HCATADMIN hCatAdmin, HCATINFO hCatInfo);
  50. BOOL GetFileInformation(void);
  51. BOOL VerifyFile(void);
  52. BOOL VerifyIsFileSigned(LPTSTR pcszMatchFile, PDRIVER_VER_INFO lpVerInfo);
  53. TCHAR *FileName(void) {return lpszFileName;};
  54. TCHAR *FileExt(void) {return lpszFileExt;};
  55. //TCHAR *FilePath(void) {return lpszFilePath;};
  56. CString FilePath() {return lpszFilePath;};
  57. //TCHAR *CatalogName(void) {return lpszCatalogName;};
  58. CString CatalogName() {return lpszCatalogName;};
  59. TCHAR *CatalogPath(void) {return lpszCatalogPath;};
  60. //TCHAR *SignedBy(void) {return lpszSignedBy;};
  61. CString SignedBy(void) {return lpszSignedBy;};
  62. // BOOL GetCertInfo(PCCERT_CONTEXT pCertContext);
  63. CatalogAttribute *m_pCatAttrib;
  64. CheckDevice *pDevnode;
  65. //protected:
  66. TCHAR *lpszFileName; // pointer into lpszFilePath which just contains the filename
  67. TCHAR *lpszFileExt; // pointer into lpszFilePath which just contains the extention
  68. // TCHAR *lpszFilePath;
  69. CString lpszFilePath;
  70. TCHAR *lpszCatalogPath; // name of the catalog which has signed this file (if exitst)
  71. //TCHAR *lpszCatalogName;
  72. CString lpszCatalogName;
  73. //TCHAR *lpszSignedBy; // name of the signer
  74. CString lpszSignedBy;
  75. };
  76. #define pFileNode *FileNode
  77. class CheckDevice : public InfnodeClass
  78. {
  79. public:
  80. CheckDevice();
  81. CheckDevice(DEVNODE hDevice, DEVNODE hParent);
  82. ~CheckDevice();
  83. BOOL CreateFileNode(void);
  84. BOOL CreateFileNode_Class(void);
  85. BOOL CreateFileNode_Driver(void);
  86. FileNode * GetFileList (void);
  87. BOOL AddFileNode(TCHAR *szFileName , UINT uiWin32Error = 0 , LPCTSTR szSigner = NULL);
  88. BOOL GetServiceNameAndDriver(void);
  89. TCHAR *ServiceName(void) {return lpszServiceName;};
  90. TCHAR *ServiceImage(void) {return lpszServiceImage;};
  91. protected:
  92. FileNode *m_FileList;
  93. HANDLE m_hDevInfo; // this is just to keep the setupapi dll's from coming and going
  94. TCHAR *lpszServiceName;
  95. TCHAR *lpszServiceImage;
  96. private:
  97. };
  98. #define pCheckDevice *CheckDevice
  99. BOOL WalkCertChain(HANDLE hWVTStateData);
  100. #endif // _CHECK_DEVICE_H_
  101. // these lines required by cl.exe