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.

171 lines
5.6 KiB

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