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.

191 lines
5.8 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. #ifdef UNICODE
  16. //
  17. // On NT, we can just include CAPI.H
  18. //
  19. #include <capi.h>
  20. #else
  21. //
  22. // For Win9x we need to do the following hacks before including the NT headers
  23. //
  24. #define SetClassLongPtr SetClassLong
  25. #define DWLP_MSGRESULT DWL_MSGRESULT
  26. #define GCLP_HICON GCL_HICON
  27. #define LONG_PTR LONG
  28. #define ULONG_PTR ULONG
  29. #define INT_PTR INT
  30. #include <wincrypt.h>
  31. #include <sipbase.h>
  32. #include <mscat.h>
  33. #include <mssip.h>
  34. #include <wintrust.h>
  35. #endif
  36. #include <softpub.h>
  37. #include "resource.h"
  38. // Macros and pre-defined values
  39. #define cbX(X) sizeof(X)
  40. #define cA(a) (cbX(a)/cbX(a[0]))
  41. #define MALLOC(x) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (x))
  42. #define FREE(x) if (x) { HeapFree(GetProcessHeap(), 0, (x)); x = NULL; }
  43. #define EXIST(x) (GetFileAttributes(x) != 0xFFFFFFFF)
  44. #define MAX_INT 0x7FFFFFFF
  45. #define HASH_SIZE 100
  46. #define NUM_PAGES 2
  47. #define SIZECHARS(x) (sizeof((x))/sizeof(TCHAR))
  48. // Registry key/value names for storing previous settings
  49. #define SIGVERIF_HKEY HKEY_CURRENT_USER
  50. #define SIGVERIF_KEY TEXT("Software\\Microsoft\\Sigverif")
  51. #define SIGVERIF_FLAGS TEXT("Flags")
  52. #define SIGVERIF_LOGNAME TEXT("Logname")
  53. //
  54. // NT5 allows EnumPrinterDrivers to pass in "All" to get every installed driver.
  55. // Win98 doesn't support this, so assume NT is always Unicode and Win98 is ANSI.
  56. //
  57. #ifdef UNICODE
  58. #define SIGVERIF_PRINTER_ENV TEXT("All")
  59. #else
  60. #define SIGVERIF_PRINTER_ENV NULL
  61. #endif
  62. // This structure holds all the information for a specific file.
  63. typedef struct tagFileNode
  64. {
  65. LPTSTR lpFileName;
  66. LPTSTR lpDirName;
  67. LPTSTR lpVersion;
  68. LPTSTR lpCatalog;
  69. LPTSTR lpSignedBy;
  70. LPTSTR lpTypeName;
  71. INT iIcon;
  72. BOOL bSigned;
  73. BOOL bScanned;
  74. SYSTEMTIME LastModified;
  75. struct tagFileNode *next;
  76. } FILENODE, *LPFILENODE;
  77. // This structure is used by walkpath to keep track of subdirectories
  78. typedef struct tagDirNode {
  79. TCHAR DirName[MAX_PATH];
  80. struct tagDirNode *next;
  81. } DIRNODE, *LPDIRNODE;
  82. // This structure is used when we walk the devicemanager list.
  83. typedef struct _DeviceTreeNode
  84. {
  85. struct _DeviceTreeNode *Child;
  86. struct _DeviceTreeNode *Sibling;
  87. DEVINST DevInst;
  88. TCHAR Driver[MAX_PATH];
  89. } DEVTREENODE, *PDEVTREENODE;
  90. typedef struct _DeviceTreeData
  91. {
  92. HDEVINFO hDeviceInfo;
  93. DEVTREENODE RootNode;
  94. } DEVICETREE, *PDEVICETREE;
  95. // This is our global data structure that hold our global variables.
  96. typedef struct tagAppData
  97. {
  98. HWND hDlg;
  99. HWND hLogging;
  100. HWND hSearch;
  101. HICON hIcon;
  102. HINSTANCE hInstance;
  103. TCHAR szScanPath[MAX_PATH];
  104. TCHAR szScanPattern[MAX_PATH];
  105. TCHAR szAppDir[MAX_PATH];
  106. TCHAR szLogFile[MAX_PATH];
  107. TCHAR szLogDir[MAX_PATH];
  108. TCHAR szWinDir[MAX_PATH];
  109. LPFILENODE lpFileList;
  110. LPFILENODE lpFileLast;
  111. HCATADMIN hCatAdmin;
  112. DWORD dwFiles;
  113. DWORD dwSigned;
  114. DWORD dwUnsigned;
  115. BOOL bNoBVT;
  116. BOOL bNoDev;
  117. BOOL bNoPRN;
  118. BOOL bOverwrite;
  119. BOOL bLoggingEnabled;
  120. BOOL bLogToRoot;
  121. BOOL bFullSystemScan;
  122. BOOL bScanning;
  123. BOOL bStopScan;
  124. BOOL bUserScan;
  125. BOOL bSubFolders;
  126. } GAPPDATA, *LPGAPPDATA;
  127. // Global function prototypes
  128. BOOL BrowseForFolder(HWND hwnd, LPTSTR lpszBuf);
  129. void BuildFileList(LPTSTR lpPathName);
  130. BOOL VerifyFileList(void);
  131. BOOL VerifyFileNode(LPFILENODE lpFileNode);
  132. void MyLoadString(LPTSTR lpString, UINT uId);
  133. void MyMessageBox(LPTSTR lpString);
  134. void MyErrorBox(LPTSTR lpString);
  135. void MyErrorBoxId(UINT uId);
  136. void MyMessageBoxId(UINT uId);
  137. UINT MyGetWindowsDirectory(LPTSTR lpDirName, UINT uSize);
  138. LPTSTR MyStrStr(LPTSTR lpString, LPTSTR lpSubString);
  139. INT_PTR CALLBACK Details_DlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  140. INT_PTR CALLBACK ListView_DlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  141. INT_PTR CALLBACK LogFile_DlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  142. LPFILENODE CreateFileNode(LPTSTR lpDirectory, LPTSTR lpFileName);
  143. BOOL IsFileAlreadyInList(LPTSTR lpDirName, LPTSTR lpFileName);
  144. void SigVerif_Help(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL bContext);
  145. void AdvancedPropertySheet(HWND hwnd);
  146. void InsertFileNodeIntoList(LPFILENODE lpFileNode);
  147. void DestroyFileList(void);
  148. void DestroyFileNode(LPFILENODE lpFileNode);
  149. void PrintFileList(void);
  150. void Progress_InitRegisterClass(void);
  151. void BuildDriverFileList(void);
  152. void BuildPrinterFileList(void);
  153. void BuildCoreFileList(void);
  154. //
  155. // Context-Sensitive Help/Identifiers specific to SigVerif
  156. //
  157. #define SIGVERIF_HELPFILE TEXT("SIGVERIF.HLP")
  158. #define WINDOWS_HELPFILE TEXT("WINDOWS.HLP")
  159. #define IDH_SIGVERIF_SEARCH_CHECK_SYSTEM 1000
  160. #define IDH_SIGVERIF_SEARCH_LOOK_FOR 1010
  161. #define IDH_SIGVERIF_SEARCH_SCAN_FILES 1020
  162. #define IDH_SIGVERIF_SEARCH_LOOK_IN_FOLDER 1030
  163. #define IDH_SIGVERIF_SEARCH_INCLUDE_SUBFOLDERS 1040
  164. #define IDH_SIGVERIF_LOGGING_ENABLE_LOGGING 1050
  165. #define IDH_SIGVERIF_LOGGING_APPEND 1060
  166. #define IDH_SIGVERIF_LOGGING_OVERWRITE 1070
  167. #define IDH_SIGVERIF_LOGGING_FILENAME 1080
  168. #define IDH_SIGVERIF_LOGGING_VIEW_LOG 1090
  169. //
  170. // Context-Sensitive Help Identifiers for Browse button
  171. //
  172. #define IDH_BROWSE 28496
  173. //
  174. // g_App is allocated in SIGVERIF.C, so everywhere else we want to make it extern
  175. //
  176. #ifndef SIGVERIF_DOT_C
  177. extern GAPPDATA g_App;
  178. #endif