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.

166 lines
5.2 KiB

  1. //
  2. // SIGVERIF.H
  3. //
  4. #include <windows.h>
  5. #include <windowsx.h>
  6. #include <shellapi.h>
  7. #include <commctrl.h>
  8. #include <setupapi.h>
  9. #include <cfgmgr32.h>
  10. #include <tchar.h>
  11. #include <shlobj.h>
  12. #include <shlwapi.h>
  13. #include <winspool.h>
  14. #include <imagehlp.h>
  15. #include <capi.h>
  16. #include <softpub.h>
  17. #include <sfc.h>
  18. #include "resource.h"
  19. // Macros and pre-defined values
  20. #define cbX(X) sizeof(X)
  21. #define cA(a) (cbX(a)/cbX(a[0]))
  22. #define MALLOC(x) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (x))
  23. #define FREE(x) if (x) { HeapFree(GetProcessHeap(), 0, (x)); x = NULL; }
  24. #define EXIST(x) (GetFileAttributes(x) != 0xFFFFFFFF)
  25. #define MAX_INT 0x7FFFFFFF
  26. #define HASH_SIZE 100
  27. #define NUM_PAGES 2
  28. // Registry key/value names for storing previous settings
  29. #define SIGVERIF_HKEY HKEY_CURRENT_USER
  30. #define SIGVERIF_KEY TEXT("Software\\Microsoft\\Sigverif")
  31. #define SIGVERIF_FLAGS TEXT("Flags")
  32. #define SIGVERIF_LOGNAME TEXT("Logname")
  33. #define SIGVERIF_PRINTER_ENV TEXT("All")
  34. // This structure holds all the information for a specific file.
  35. typedef struct tagFileNode
  36. {
  37. LPTSTR lpFileName;
  38. LPTSTR lpDirName;
  39. LPTSTR lpVersion;
  40. LPTSTR lpCatalog;
  41. LPTSTR lpSignedBy;
  42. LPTSTR lpTypeName;
  43. INT iIcon;
  44. BOOL bSigned;
  45. BOOL bScanned;
  46. BOOL bValidateAgainstAnyOs;
  47. DWORD LastError;
  48. SYSTEMTIME LastModified;
  49. struct tagFileNode *next;
  50. } FILENODE, *LPFILENODE;
  51. // This structure is used by walkpath to keep track of subdirectories
  52. typedef struct tagDirNode {
  53. TCHAR DirName[MAX_PATH];
  54. struct tagDirNode *next;
  55. } DIRNODE, *LPDIRNODE;
  56. // This structure is used when we walk the devicemanager list.
  57. typedef struct _DeviceTreeNode
  58. {
  59. struct _DeviceTreeNode *Child;
  60. struct _DeviceTreeNode *Sibling;
  61. DEVINST DevInst;
  62. TCHAR Driver[MAX_PATH];
  63. } DEVTREENODE, *PDEVTREENODE;
  64. typedef struct _DeviceTreeData
  65. {
  66. HDEVINFO hDeviceInfo;
  67. DEVTREENODE RootNode;
  68. } DEVICETREE, *PDEVICETREE;
  69. // This is our global data structure that hold our global variables.
  70. typedef struct tagAppData
  71. {
  72. HWND hDlg;
  73. HWND hLogging;
  74. HWND hSearch;
  75. HICON hIcon;
  76. HINSTANCE hInstance;
  77. TCHAR szScanPath[MAX_PATH];
  78. TCHAR szScanPattern[MAX_PATH];
  79. TCHAR szAppDir[MAX_PATH];
  80. TCHAR szLogFile[MAX_PATH];
  81. TCHAR szWinDir[MAX_PATH];
  82. LPFILENODE lpFileList;
  83. LPFILENODE lpFileLast;
  84. HCATADMIN hCatAdmin;
  85. DWORD dwFiles;
  86. DWORD dwSigned;
  87. DWORD dwUnsigned;
  88. BOOL bNoBVT;
  89. BOOL bNoDev;
  90. BOOL bNoPRN;
  91. BOOL bOverwrite;
  92. BOOL bLoggingEnabled;
  93. BOOL bLogToRoot;
  94. BOOL bFullSystemScan;
  95. BOOL bScanning;
  96. BOOL bStopScan;
  97. BOOL bUserScan;
  98. BOOL bSubFolders;
  99. DWORD LastError;
  100. } GAPPDATA, *LPGAPPDATA;
  101. // Global function prototypes
  102. BOOL BrowseForFolder(HWND hwnd, LPTSTR lpszBuf);
  103. void BuildFileList(LPTSTR lpPathName);
  104. BOOL VerifyFileList(void);
  105. BOOL VerifyFileNode(LPFILENODE lpFileNode);
  106. void MyLoadString(LPTSTR lpString, UINT uId);
  107. void MyMessageBox(LPTSTR lpString);
  108. void MyErrorBox(LPTSTR lpString);
  109. void MyErrorBoxId(UINT uId);
  110. void MyMessageBoxId(UINT uId);
  111. UINT MyGetWindowsDirectory(LPTSTR lpDirName, UINT uSize);
  112. LPTSTR MyStrStr(LPTSTR lpString, LPTSTR lpSubString);
  113. INT_PTR CALLBACK Details_DlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  114. INT_PTR CALLBACK ListView_DlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  115. INT_PTR CALLBACK LogFile_DlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  116. LPFILENODE CreateFileNode(LPTSTR lpDirectory, LPTSTR lpFileName);
  117. BOOL IsFileAlreadyInList(LPTSTR lpDirName, LPTSTR lpFileName);
  118. void SigVerif_Help(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL bContext);
  119. void AdvancedPropertySheet(HWND hwnd);
  120. void InsertFileNodeIntoList(LPFILENODE lpFileNode);
  121. void DestroyFileList(BOOL bClear);
  122. void DestroyFileNode(LPFILENODE lpFileNode);
  123. void PrintFileList(void);
  124. void Progress_InitRegisterClass(void);
  125. void BuildDriverFileList(void);
  126. void BuildPrinterFileList(void);
  127. void BuildCoreFileList(void);
  128. void MyGetFileInfo(LPFILENODE lpFileInfo);
  129. //
  130. // Context-Sensitive Help/Identifiers specific to SigVerif
  131. //
  132. #define SIGVERIF_HELPFILE TEXT("SIGVERIF.HLP")
  133. #define WINDOWS_HELPFILE TEXT("WINDOWS.HLP")
  134. #define IDH_SIGVERIF_SEARCH_CHECK_SYSTEM 1000
  135. #define IDH_SIGVERIF_SEARCH_LOOK_FOR 1010
  136. #define IDH_SIGVERIF_SEARCH_SCAN_FILES 1020
  137. #define IDH_SIGVERIF_SEARCH_LOOK_IN_FOLDER 1030
  138. #define IDH_SIGVERIF_SEARCH_INCLUDE_SUBFOLDERS 1040
  139. #define IDH_SIGVERIF_LOGGING_ENABLE_LOGGING 1050
  140. #define IDH_SIGVERIF_LOGGING_APPEND 1060
  141. #define IDH_SIGVERIF_LOGGING_OVERWRITE 1070
  142. #define IDH_SIGVERIF_LOGGING_FILENAME 1080
  143. #define IDH_SIGVERIF_LOGGING_VIEW_LOG 1090
  144. //
  145. // Context-Sensitive Help Identifiers for Browse button
  146. //
  147. #define IDH_BROWSE 28496
  148. //
  149. // g_App is allocated in SIGVERIF.C, so everywhere else we want to make it extern
  150. //
  151. #ifndef SIGVERIF_DOT_C
  152. extern GAPPDATA g_App;
  153. #endif