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.

363 lines
9.4 KiB

  1. /*******************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORP., 2000
  4. *
  5. * TITLE: sti_ci.h
  6. *
  7. * VERSION: 1.0
  8. *
  9. * AUTHOR: KeisukeT
  10. *
  11. * DATE: 27 Mar, 2000
  12. *
  13. * DESCRIPTION:
  14. * Generic header file for WIA class installer.
  15. *
  16. *******************************************************************************/
  17. #ifndef _STI_CI_H_
  18. #define _STI_CI_H_
  19. //
  20. // Include
  21. //
  22. #include <windows.h>
  23. #include <windowsx.h>
  24. #include <assert.h>
  25. #include <tchar.h>
  26. #include <setupapi.h>
  27. #include "resource.h"
  28. #include "cistr.h"
  29. #include "debug.h"
  30. //
  31. // Define
  32. //
  33. #define ID_AUTO -1
  34. #define NUM_WIA_PAGES 5
  35. #define MAX_DATA_SECTION 512*sizeof(TCHAR)
  36. #define MAX_DESCRIPTION 64*sizeof(TCHAR)
  37. #define MAX_FRIENDLYNAME 64
  38. #define MAX_DEVICE_ID 64
  39. #define MAX_COMMANDLINE 256
  40. #define MAX_STRING_LENGTH 1024
  41. #define MAX_MUTEXTIMEOUT 60*1000 // 60 Sec
  42. #define MANUAL_INSTALL_MASK 100
  43. #define INVALID_DEVICE_INDEX -1
  44. #define MONITOR_NAME TEXT("STIMON.EXE")
  45. #define RUNDLL32 TEXT("RUNDLL32.EXE")
  46. #define STILL_IMAGE TEXT("StillImage")
  47. #define FRIENDLYNAME TEXT("FriendlyName")
  48. #define VENDORSETUP TEXT("VendorSetup")
  49. #define DEVICESECTION TEXT("DeviceData")
  50. #define PORTNAME TEXT("PortName")
  51. #define DEVICETYPE TEXT("DeviceType")
  52. #define DEVICESUBTYPE TEXT("DeviceSubType")
  53. #define DRIVERDESC TEXT("DriverDesc")
  54. #define DESCRIPTION TEXT("Description")
  55. #define CREATEFILENAME TEXT("CreateFileName")
  56. #define CAPABILITIES TEXT("Capabilities")
  57. #define EVENTS TEXT("Events")
  58. #define WIASECTION TEXT("WiaSection")
  59. #define PROPERTYPAGES TEXT("PropertyPages")
  60. #define VENDOR TEXT("Vendor")
  61. #define UNINSTALLSECTION TEXT("UninstallSection")
  62. #define SUBCLASS TEXT("SubClass")
  63. #define ICMPROFILES TEXT("ICMProfiles")
  64. #define INFPATH TEXT("InfPath")
  65. #define INFSECTION TEXT("InfSection")
  66. #define ISPNP TEXT("IsPnP")
  67. #define USDCLASS TEXT("USDClass")
  68. #define LPTENUM TEXT("LptEnum")
  69. #define ENUM TEXT("\\Enum")
  70. #define PORTS TEXT("Ports")
  71. #define DONT_LOAD TEXT("don't load")
  72. #define CONTROL_INI TEXT("control.ini")
  73. #define CPL_NAME TEXT("sticpl.cpl")
  74. #define NO TEXT("no")
  75. #define LAUNCH_APP TEXT("LaunchApplications")
  76. #define SZ_GUID TEXT("GUID")
  77. #define CONNECTION TEXT("Connection")
  78. #define SERIAL TEXT("Serial")
  79. #define PARALLEL TEXT("Parallel")
  80. #define BOTH TEXT("Both")
  81. #define AUTO TEXT("AUTO")
  82. #define VIDEO_PATH_ID TEXT("DShowDeviceId")
  83. #define DEVICESECTION TEXT("DeviceData")
  84. #define WIAACMGR_PATH TEXT("wiaacmgr.exe")
  85. #define WIAACMGR_ARG TEXT("-SelectDevice")
  86. #define WIADEVLISTMUTEX TEXT("WiaDeviceListMutex")
  87. #define WIA_GUIDSTRING TEXT("{6BDD1FC6-810F-11D0-BEC7-08002BE2092F}")
  88. #define STI_CI32_ENTRY_WIZMANU TEXT("sti_ci.dll,WiaCreateWizardMenu")
  89. #define LAYOUT_INF_PATH TEXT("\\inf\\layout.inf")
  90. #define SOURCEDISKFILES TEXT("SourceDisksFiles")
  91. #define PROVIDER TEXT("Provider")
  92. #define MICROSOFT TEXT("Microsoft")
  93. #define PORTSELECT TEXT("PortSelect")
  94. #define WIAINSTALLERMUTEX TEXT("WiaInstallerMutex")
  95. #define WIAINSTALLWIZMUTEX TEXT("WiaInstallWizMutex")
  96. #define WIAINSTALLERFILENAME TEXT("sti_ci.dll")
  97. #define WIAWIZARDCHORCUTNAME TEXT("Scanner and Camera Wizard")
  98. #define MESSAGE1 TEXT("Message1")
  99. #define NEWDEVDLL TEXT("newdev.dll")
  100. #define BUTTON_NOT_PUSHED 0
  101. #define BUTTON_NEXT 1
  102. #define BUTTON_BACK 2
  103. #define PORTSELMODE_NORMAL 0
  104. #define PORTSELMODE_SKIP 1
  105. #define PORTSELMODE_MESSAGE1 2
  106. #define EXECDIR_SYSTEM32 1
  107. #ifndef DLLEXPORT
  108. #define DLLEXPORT __declspec(dllexport)
  109. #endif // DLLEXPORT
  110. //
  111. // Registry Paths
  112. //
  113. #define REGKEY_DEVICE_PARMS TEXT("Device Parameters")
  114. #define REGKEY_CONTROLINIFILEMAPPING TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\IniFileMapping\\control.ini")
  115. #define REGSTR_VAL_FRIENDLY_NAME TEXT("FriendlyName")
  116. #define REGSTR_VAL_FRIENDLY_NAME_A "FriendlyName"
  117. #define REGSTR_VAL_DEVICE_ID TEXT("DeviceID")
  118. #define REGSTR_VAL_WIZMENU TEXT("WIAWizardMenu")
  119. #define REGKEY_WIASHEXT TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MyComputer\\NameSpace\\DelegateFolders\\{E211B736-43FD-11D1-9EFB-0000F8757FCD}")
  120. #define REGKEY_INSTALL_NAMESTORE TEXT("SYSTEM\\CurrentControlSet\\Control\\StillImage\\DeviceNameStore")
  121. #define REGSTR_VAL_WIASHEXT TEXT("Scanners & Cameras")
  122. //
  123. // Migration
  124. //
  125. #define NAME_BEGIN_A "BEGIN"
  126. #define NAME_BEGIN_W L"BEGIN"
  127. #define NAME_END_A "END"
  128. #define NAME_END_W L"END"
  129. //
  130. // Macro
  131. //
  132. #ifdef UNICODE
  133. #define AtoT(_d_, _s_) MultiByteToWideChar(CP_ACP, 0, _s_, -1, _d_, MAX_PATH);
  134. #else // UNICODE
  135. #define AtoT(_d_, _s_)
  136. #endif // UNICODE
  137. #define IS_VALID_HANDLE(h) (((h) != NULL) && ((h) != INVALID_HANDLE_VALUE))
  138. #ifndef ARRAYSIZE
  139. #define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
  140. #endif
  141. //
  142. // Struct
  143. //
  144. typedef struct _INSTALLER_CONTEXT {
  145. HDEVINFO hDevInfo;
  146. SP_DEVINFO_DATA spDevInfoData;
  147. HWND hwndWizard;
  148. PVOID pFirstPage;
  149. PVOID pPrevSelectPage;
  150. PVOID pPortSelectPage;
  151. PVOID pNameDevicePage;
  152. PVOID pFinalPage;
  153. PVOID pDevice;
  154. BOOL bShowFirstPage;
  155. BOOL bCalledFromControlPanal;
  156. UCHAR szPortName[MAX_DESCRIPTION];
  157. } INSTALLER_CONTEXT, *PINSTALLER_CONTEXT;
  158. typedef struct _CLEANUPITEM {
  159. BOOL bInstalled;
  160. BOOL bRemoved;
  161. } CLEANUPITEM, *PCLEANUPITEM;
  162. // For migration.
  163. typedef struct _PARAM_LIST {
  164. PVOID pNext;
  165. LPSTR pParam1;
  166. LPSTR pParam2;
  167. } PARAM_LIST, *PPARAM_LIST;
  168. typedef struct _DEVICE_INFO {
  169. LPSTR pszFriendlyName;
  170. LPSTR pszCreateFileName;
  171. LPSTR pszInfPath;
  172. LPSTR pszInfSection;
  173. DWORD dwNumberOfDeviceDataKey;
  174. PPARAM_LIST pDeviceDataParam;
  175. } DEVICE_INFO, *PDEVICE_INFO;
  176. //
  177. // Prototype
  178. //
  179. BOOL
  180. GetInfInforamtionFromSelectedDevice(
  181. HDEVINFO hDevInfo,
  182. LPTSTR pInfFileName,
  183. LPTSTR pInfSectionName
  184. );
  185. BOOL
  186. GetStringFromRegistry(
  187. HKEY hkRegistry,
  188. LPCTSTR szValueName,
  189. LPTSTR pBuffer
  190. );
  191. BOOL
  192. GetDwordFromRegistry(
  193. HKEY hkRegistry,
  194. LPCTSTR szValueName,
  195. LPDWORD pdwValue
  196. );
  197. VOID
  198. ShowInstallerMessage(
  199. DWORD dwMessageId
  200. );
  201. VOID
  202. SetRunonceKey(
  203. LPTSTR szValue,
  204. LPTSTR szData
  205. );
  206. DWORD
  207. DecodeHexA(
  208. LPSTR lpstr
  209. );
  210. BOOL
  211. IsWindowsFile(
  212. LPTSTR szFileName
  213. );
  214. BOOL
  215. IsProviderMs(
  216. LPTSTR szInfName
  217. );
  218. BOOL
  219. IsIhvAndInboxExisting(
  220. HDEVINFO hDevInfo,
  221. PSP_DEVINFO_DATA pDevInfoData
  222. );
  223. BOOL
  224. IsNameAlreadyStored(
  225. LPTSTR szName
  226. );
  227. HFONT
  228. GetIntroFont(
  229. HWND hwnd
  230. );
  231. BOOL
  232. IsDeviceRootEnumerated(
  233. IN HDEVINFO hDevInfo,
  234. IN PSP_DEVINFO_DATA pDevInfoData
  235. );
  236. int
  237. MyStrCmpi(
  238. LPCTSTR str1,
  239. LPCTSTR str2
  240. );
  241. VOID
  242. LogSystemEvent(
  243. WORD wEventType,
  244. DWORD dwEventID,
  245. WORD wNumberOfString,
  246. LPTSTR szMsg[]
  247. );
  248. // from entry.cpp
  249. extern "C"
  250. DWORD
  251. APIENTRY
  252. CoinstallerEntry(
  253. IN DI_FUNCTION diFunction,
  254. IN HDEVINFO hDevInfo,
  255. IN PSP_DEVINFO_DATA pDevInfoData,
  256. IN OUT PCOINSTALLER_CONTEXT_DATA pCoinstallerContext
  257. );
  258. DWORD
  259. APIENTRY
  260. CoinstallerPreProcess(
  261. IN DI_FUNCTION diFunction,
  262. IN HDEVINFO hDevInfo,
  263. IN PSP_DEVINFO_DATA pDevInfoData,
  264. IN OUT PCOINSTALLER_CONTEXT_DATA pCoinstallerContext
  265. );
  266. DWORD
  267. APIENTRY
  268. CoinstallerPostProcess(
  269. IN DI_FUNCTION diFunction,
  270. IN HDEVINFO hDevInfo,
  271. IN PSP_DEVINFO_DATA pDevInfoData,
  272. IN OUT PCOINSTALLER_CONTEXT_DATA pCoinstallerContext
  273. );
  274. BOOL
  275. IsValidMigrationDevice(
  276. PDEVICE_INFO pMigratingDevice
  277. );
  278. BOOL
  279. IsValidFriendlyName(
  280. LPSTR szFriendlyName
  281. );
  282. //
  283. // Class
  284. //
  285. class CInstallerMutex {
  286. private:
  287. HANDLE *m_phMutex;
  288. BOOL m_bSucceeded;
  289. public:
  290. CInstallerMutex(HANDLE* phMutex, LPTSTR szMutexName, DWORD dwTimeout);
  291. ~CInstallerMutex();
  292. inline BOOL Succeeded() {
  293. return m_bSucceeded;
  294. }
  295. };
  296. #endif // _STI_CI_H_