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.

1603 lines
48 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. devinst.h
  5. Abstract:
  6. Private header file for setup device installation routines.
  7. Author:
  8. Lonny McMichael (lonnym) 10-May-1995
  9. Revision History:
  10. --*/
  11. //
  12. // For now, define the size (in characters) of a GUID string,
  13. // including terminating NULL.
  14. //
  15. #define GUID_STRING_LEN (39)
  16. //
  17. // Define the maximum number of IDs that may be present in an ID list
  18. // (either HardwareID or CompatibleIDs).
  19. //
  20. #define MAX_HCID_COUNT (64)
  21. //
  22. // Global strings used by device installer routines. Sizes are included
  23. // so that we can do sizeof() instead of lstrlen() to determine string
  24. // length.
  25. //
  26. // The content of the following strings is defined in regstr.h:
  27. //
  28. extern CONST TCHAR pszNoUseClass[SIZECHARS(REGSTR_VAL_NOUSECLASS)],
  29. pszNoInstallClass[SIZECHARS(REGSTR_VAL_NOINSTALLCLASS)],
  30. pszNoDisplayClass[SIZECHARS(REGSTR_VAL_NODISPLAYCLASS)],
  31. pszDeviceDesc[SIZECHARS(REGSTR_VAL_DEVDESC)],
  32. pszDevicePath[SIZECHARS(REGSTR_VAL_DEVICEPATH)],
  33. pszPathSetup[SIZECHARS(REGSTR_PATH_SETUP)],
  34. pszKeySetup[SIZECHARS(REGSTR_KEY_SETUP)],
  35. pszPathRunOnce[SIZECHARS(REGSTR_PATH_RUNONCE)],
  36. pszSourcePath[SIZECHARS(REGSTR_VAL_SRCPATH)],
  37. pszSvcPackPath[SIZECHARS(REGSTR_VAL_SVCPAKSRCPATH)],
  38. pszDriverCachePath[SIZECHARS(REGSTR_VAL_DRIVERCACHEPATH)],
  39. pszBootDir[SIZECHARS(REGSTR_VAL_BOOTDIR)],
  40. pszInsIcon[SIZECHARS(REGSTR_VAL_INSICON)],
  41. pszInstaller32[SIZECHARS(REGSTR_VAL_INSTALLER_32)],
  42. pszEnumPropPages32[SIZECHARS(REGSTR_VAL_ENUMPROPPAGES_32)],
  43. pszInfPath[SIZECHARS(REGSTR_VAL_INFPATH)],
  44. pszInfSection[SIZECHARS(REGSTR_VAL_INFSECTION)],
  45. pszDrvDesc[SIZECHARS(REGSTR_VAL_DRVDESC)],
  46. pszHardwareID[SIZECHARS(REGSTR_VAL_HARDWAREID)],
  47. pszCompatibleIDs[SIZECHARS(REGSTR_VAL_COMPATIBLEIDS)],
  48. pszDriver[SIZECHARS(REGSTR_VAL_DRIVER)],
  49. pszConfigFlags[SIZECHARS(REGSTR_VAL_CONFIGFLAGS)],
  50. pszMfg[SIZECHARS(REGSTR_VAL_MFG)],
  51. pszService[SIZECHARS(REGSTR_VAL_SERVICE)],
  52. pszProviderName[SIZECHARS(REGSTR_VAL_PROVIDER_NAME)],
  53. pszFriendlyName[SIZECHARS(REGSTR_VAL_FRIENDLYNAME)],
  54. pszServicesRegPath[SIZECHARS(REGSTR_PATH_SERVICES)],
  55. pszLegacyInfOption[SIZECHARS(REGSTR_VAL_LEGACYINFOPT)],
  56. pszInfSectionExt[SIZECHARS(REGSTR_VAL_INFSECTIONEXT)],
  57. pszDeviceClassesPath[SIZECHARS(REGSTR_PATH_DEVICE_CLASSES)],
  58. pszDeviceInstance[SIZECHARS(REGSTR_VAL_DEVICE_INSTANCE)],
  59. pszDefault[SIZECHARS(REGSTR_VAL_DEFAULT)],
  60. pszControl[SIZECHARS(REGSTR_KEY_CONTROL)],
  61. pszLinked[SIZECHARS(REGSTR_VAL_LINKED)],
  62. pszDeviceParameters[SIZECHARS(REGSTR_KEY_DEVICEPARAMETERS)],
  63. pszLocationInformation[SIZECHARS(REGSTR_VAL_LOCATION_INFORMATION)],
  64. pszCapabilities[SIZECHARS(REGSTR_VAL_CAPABILITIES)],
  65. pszUiNumber[SIZECHARS(REGSTR_VAL_UI_NUMBER)],
  66. pszRemovalPolicyOverride[SIZECHARS(REGSTR_VAL_REMOVAL_POLICY)],
  67. pszUpperFilters[SIZECHARS(REGSTR_VAL_UPPERFILTERS)],
  68. pszLowerFilters[SIZECHARS(REGSTR_VAL_LOWERFILTERS)],
  69. pszMatchingDeviceId[SIZECHARS(REGSTR_VAL_MATCHINGDEVID)],
  70. pszBasicProperties32[SIZECHARS(REGSTR_VAL_BASICPROPERTIES_32)],
  71. pszCoInstallers32[SIZECHARS(REGSTR_VAL_COINSTALLERS_32)],
  72. pszPathCoDeviceInstallers[SIZECHARS(REGSTR_PATH_CODEVICEINSTALLERS)],
  73. pszSystem[SIZECHARS(REGSTR_KEY_SYSTEM)],
  74. pszDrvSignPath[SIZECHARS(REGSTR_PATH_DRIVERSIGN)],
  75. pszNonDrvSignPath[SIZECHARS(REGSTR_PATH_NONDRIVERSIGN)],
  76. pszDrvSignPolicyPath[SIZECHARS(REGSTR_PATH_DRIVERSIGN_POLICY)],
  77. pszNonDrvSignPolicyPath[SIZECHARS(REGSTR_PATH_NONDRIVERSIGN_POLICY)],
  78. pszDrvSignPolicyValue[SIZECHARS(REGSTR_VAL_POLICY)],
  79. pszDrvSignBehaviorOnFailedVerifyDS[SIZECHARS(REGSTR_VAL_BEHAVIOR_ON_FAILED_VERIFY)],
  80. pszDriverDate[SIZECHARS(REGSTR_VAL_DRIVERDATE)],
  81. pszDriverDateData[SIZECHARS(REGSTR_VAL_DRIVERDATEDATA)],
  82. pszDriverVersion[SIZECHARS(REGSTR_VAL_DRIVERVERSION)],
  83. pszDevSecurity[SIZECHARS(REGSTR_VAL_DEVICE_SECURITY_DESCRIPTOR)],
  84. pszDevType[SIZECHARS(REGSTR_VAL_DEVICE_TYPE)],
  85. pszExclusive[SIZECHARS(REGSTR_VAL_DEVICE_EXCLUSIVE)],
  86. pszCharacteristics[SIZECHARS(REGSTR_VAL_DEVICE_CHARACTERISTICS)],
  87. pszUiNumberDescFormat[SIZECHARS(REGSTR_VAL_UI_NUMBER_DESC_FORMAT)],
  88. pszReinstallPath[SIZECHARS(REGSTR_PATH_REINSTALL)],
  89. pszReinstallDeviceInstanceIds[SIZECHARS(REGSTR_VAL_REINSTALL_DEVICEINSTANCEIDS)],
  90. pszReinstallDisplayName[SIZECHARS(REGSTR_VAL_REINSTALL_DISPLAYNAME)],
  91. pszReinstallString[SIZECHARS(REGSTR_VAL_REINSTALL_STRING)];
  92. //
  93. // Other misc. global strings:
  94. //
  95. #define DISTR_INF_WILDCARD (TEXT("*.inf"))
  96. #define DISTR_OEMINF_WILDCARD (TEXT("oem*.inf"))
  97. #define DISTR_CI_DEFAULTPROC (TEXT("ClassInstall"))
  98. #define DISTR_SPACE_LPAREN (TEXT(" ("))
  99. #define DISTR_RPAREN (TEXT(")"))
  100. #define DISTR_UNIQUE_SUBKEY (TEXT("\\%04u"))
  101. #define DISTR_OEMINF_GENERATE (TEXT("%s\\oem%d.inf"))
  102. #define DISTR_OEMINF_DEFAULTPATH (TEXT("A:\\"))
  103. #define DISTR_DEFAULT_SERVICE (TEXT("Default Service"))
  104. #define DISTR_GUID_NULL (TEXT("{00000000-0000-0000-0000-000000000000}"))
  105. #define DISTR_EVENTLOG (TEXT("\\EventLog"))
  106. #define DISTR_GROUPORDERLIST_PATH (REGSTR_PATH_CURRENT_CONTROL_SET TEXT("\\GroupOrderList"))
  107. #define DISTR_SERVICEGROUPORDER_PATH (REGSTR_PATH_CURRENT_CONTROL_SET TEXT("\\ServiceGroupOrder"))
  108. #define DISTR_OPTIONS (TEXT("Options"))
  109. #define DISTR_OPTIONSTEXT (TEXT("OptionsText"))
  110. #define DISTR_LANGUAGESSUPPORTED (TEXT("LanguagesSupported"))
  111. #define DISTR_RUNONCE_EXE (TEXT("runonce"))
  112. #define DISTR_GRPCONV (TEXT("grpconv -o"))
  113. #define DISTR_GRPCONV_NOUI (TEXT("grpconv -u"))
  114. #define DISTR_DEFAULT_SYSPART (TEXT("C:\\"))
  115. #define DISTR_BASICPROP_DEFAULTPROC (TEXT("BasicProperties"))
  116. #define DISTR_ENUMPROP_DEFAULTPROC (TEXT("EnumPropPages"))
  117. #define DISTR_CODEVICEINSTALL_DEFAULTPROC (TEXT("CoDeviceInstall"))
  118. #define DISTR_DRIVER_OBJECT_PATH_PREFIX (TEXT("\\DRIVER\\")) // must be uppercase!
  119. #define DISTR_DRIVER_SIGNING_CLASSES (TEXT("DriverSigningClasses"))
  120. #define DISTR_PATH_EMBEDDED_NT_SECURITY (TEXT("Software\\Microsoft\\EmbeddedNT\\Security"))
  121. #define DISTR_VAL_MINIMIZE_FOOTPRINT (TEXT("MinimizeFootprint"))
  122. #define DISTR_VAL_DISABLE_SCE (TEXT("DisableSCE"))
  123. extern CONST TCHAR pszInfWildcard[SIZECHARS(DISTR_INF_WILDCARD)],
  124. pszOemInfWildcard[SIZECHARS(DISTR_OEMINF_WILDCARD)],
  125. pszCiDefaultProc[SIZECHARS(DISTR_CI_DEFAULTPROC)],
  126. pszSpaceLparen[SIZECHARS(DISTR_SPACE_LPAREN)],
  127. pszRparen[SIZECHARS(DISTR_RPAREN)],
  128. pszUniqueSubKey[SIZECHARS(DISTR_UNIQUE_SUBKEY)],
  129. pszOemInfGenerate[SIZECHARS(DISTR_OEMINF_GENERATE)],
  130. pszOemInfDefaultPath[SIZECHARS(DISTR_OEMINF_DEFAULTPATH)],
  131. pszDefaultService[SIZECHARS(DISTR_DEFAULT_SERVICE)],
  132. pszGuidNull[SIZECHARS(DISTR_GUID_NULL)],
  133. pszEventLog[SIZECHARS(DISTR_EVENTLOG)],
  134. pszGroupOrderListPath[SIZECHARS(DISTR_GROUPORDERLIST_PATH)],
  135. pszServiceGroupOrderPath[SIZECHARS(DISTR_SERVICEGROUPORDER_PATH)],
  136. pszOptions[SIZECHARS(DISTR_OPTIONS)],
  137. pszOptionsText[SIZECHARS(DISTR_OPTIONSTEXT)],
  138. pszLanguagesSupported[SIZECHARS(DISTR_LANGUAGESSUPPORTED)],
  139. pszRunOnceExe[SIZECHARS(DISTR_RUNONCE_EXE)],
  140. pszGrpConv[SIZECHARS(DISTR_GRPCONV)],
  141. pszGrpConvNoUi[SIZECHARS(DISTR_GRPCONV_NOUI)],
  142. pszDefaultSystemPartition[SIZECHARS(DISTR_DEFAULT_SYSPART)],
  143. pszBasicPropDefaultProc[SIZECHARS(DISTR_BASICPROP_DEFAULTPROC)],
  144. pszEnumPropDefaultProc[SIZECHARS(DISTR_ENUMPROP_DEFAULTPROC)],
  145. pszCoInstallerDefaultProc[SIZECHARS(DISTR_CODEVICEINSTALL_DEFAULTPROC)],
  146. pszDriverObjectPathPrefix[SIZECHARS(DISTR_DRIVER_OBJECT_PATH_PREFIX)],
  147. pszDriverSigningClasses[SIZECHARS(DISTR_DRIVER_SIGNING_CLASSES)],
  148. pszEmbeddedNTSecurity[SIZECHARS(DISTR_PATH_EMBEDDED_NT_SECURITY)],
  149. pszMinimizeFootprint[SIZECHARS(DISTR_VAL_MINIMIZE_FOOTPRINT)],
  150. pszDisableSCE[SIZECHARS(DISTR_VAL_DISABLE_SCE)];
  151. //
  152. // Global translation array for finding CM_DRP_* ordinal
  153. // given property name or SPDRP_* value.
  154. //
  155. extern STRING_TO_DATA InfRegValToDevRegProp[];
  156. extern STRING_TO_DATA InfRegValToClassRegProp[];
  157. //
  158. // Define a macro that does the DI-to-CM property translation
  159. //
  160. #define SPDRP_TO_CMDRP(i) (InfRegValToDevRegProp[(i)].Data)
  161. //
  162. // Class registry translation uses the same table
  163. //
  164. #define SPCRP_TO_CMCRP(i) (InfRegValToClassRegProp[(i)].Data)
  165. //
  166. // Define a value indicating a no-match ranking.
  167. //
  168. #define RANK_NO_MATCH (0xFFFFFFFF)
  169. //
  170. // Driver ranking bases. Lower Ranks are better. Rank 0 is the best possible Rank.
  171. // Any Rank less than 0x00001000 is a HardwareID match that is considered a good match.
  172. //
  173. #define RANK_HWID_INF_HWID_BASE 0x00000000 // For match with Hardware's HardwareID and INF's HardwareID
  174. #define RANK_HWID_INF_CID_BASE 0x00001000 // For match with Hardware's HardwareID and INF's CompatibleID
  175. #define RANK_CID_INF_HWID_BASE 0x00002000 // For match with Hardware's CompatibleID and INF's HardwareID
  176. #define RANK_CID_INF_CID_BASE 0x00003000 // For match with Hardware's CompatibleID and INF's CompatibleID
  177. #define RANK_CID_INF_CID_INC 0x00000100 // added to RANK_CID_INF_CID_BASE for each CompatID location
  178. //
  179. // Define special value used to indicate that one of our enumeration 'hint'
  180. // indices is invalid.
  181. //
  182. #define INVALID_ENUM_INDEX (0xFFFFFFFF)
  183. //
  184. // Define prototype of callback function supplied by class installers.
  185. //
  186. typedef DWORD (CALLBACK* CLASS_INSTALL_PROC) (
  187. IN DI_FUNCTION InstallFunction,
  188. IN HDEVINFO DeviceInfoSet,
  189. IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
  190. );
  191. //
  192. // Define prototype of property sheet provider function--basically, an
  193. // ExtensionPropSheetPageProc function with a (potentially) different name.
  194. //
  195. typedef BOOL (CALLBACK* PROPSHEET_PROVIDER_PROC) (
  196. IN PSP_PROPSHEETPAGE_REQUEST PropPageRequest,
  197. IN LPFNADDPROPSHEETPAGE lpfnAddPropSheetPageProc,
  198. IN LPARAM lParam
  199. );
  200. //
  201. // Define prototype of the co-installer function.
  202. //
  203. typedef DWORD (CALLBACK* COINSTALLER_PROC) (
  204. IN DI_FUNCTION InstallFunction,
  205. IN HDEVINFO DeviceInfoSet,
  206. IN PSP_DEVINFO_DATA DeviceInfoData, OPTIONAL
  207. IN OUT PCOINSTALLER_CONTEXT_DATA Context
  208. );
  209. //
  210. // Define structure for the internal representation of a single
  211. // driver information node.
  212. //
  213. typedef struct _DRIVER_NODE {
  214. struct _DRIVER_NODE *Next;
  215. UINT Rank;
  216. FILETIME InfDate;
  217. LONG DrvDescription;
  218. //
  219. // Have to have both forms of the strings below because we must have both
  220. // case-insensitive (i.e., atom-like) behavior, and keep the original case
  221. // for display.
  222. //
  223. LONG DevDescription;
  224. LONG DevDescriptionDisplayName;
  225. LONG ProviderName;
  226. LONG ProviderDisplayName;
  227. LONG MfgName;
  228. LONG MfgDisplayName;
  229. LONG InfFileName;
  230. LONG InfSectionName;
  231. //
  232. // The following field is only valid if this is a legacy INF driver node. It
  233. // tells us what language to use when running the INF interpreter.
  234. //
  235. LONG LegacyInfLang;
  236. LONG HardwareId;
  237. DWORD NumCompatIds;
  238. PLONG CompatIdList;
  239. //
  240. // Store the index of the device ID that a compatible match was based on. If
  241. // this was a HardwareId match, this value is -1, otherwise, it is the index
  242. // into the CompatIdList array of the device ID that matched.
  243. //
  244. LONG MatchingDeviceId;
  245. DWORD Flags;
  246. DWORD_PTR PrivateData;
  247. //
  248. // Store the GUID index INF's class from which this node came. We need to do this,
  249. // in order to easily determine the class of the driver node (e.g., so that we
  250. // can change the device's class when a new driver node is selected).
  251. //
  252. LONG GuidIndex;
  253. FILETIME DriverDate;
  254. DWORDLONG DriverVersion;
  255. } DRIVER_NODE, *PDRIVER_NODE;
  256. //
  257. // Define structure to contain a co-installer entry.
  258. //
  259. typedef struct _COINSTALLER_NODE {
  260. HINSTANCE hinstCoInstaller;
  261. COINSTALLER_PROC CoInstallerEntryPoint;
  262. HANDLE CoInstallerFusionContext;
  263. } COINSTALLER_NODE, *PCOINSTALLER_NODE;
  264. //
  265. // Define structure containing context information about co-installer
  266. // callbacks for the duration of a DIF call.
  267. //
  268. typedef struct _COINSTALLER_INTERNAL_CONTEXT {
  269. COINSTALLER_CONTEXT_DATA Context;
  270. BOOL DoPostProcessing;
  271. COINSTALLER_PROC CoInstallerEntryPoint;
  272. HANDLE CoInstallerFusionContext;
  273. } COINSTALLER_INTERNAL_CONTEXT, *PCOINSTALLER_INTERNAL_CONTEXT;
  274. //
  275. // Define structure for the internal storage of device installation
  276. // parameters.
  277. //
  278. typedef struct _DEVINSTALL_PARAM_BLOCK {
  279. //
  280. // Flags for controlling installation and UI functions.
  281. //
  282. DWORD Flags;
  283. DWORD FlagsEx;
  284. //
  285. // Specifies the window handle that will own UI related to this
  286. // installation. MAY BE NULL.
  287. //
  288. HWND hwndParent;
  289. //
  290. // Installation message handling parameters.
  291. //
  292. PSP_FILE_CALLBACK InstallMsgHandler;
  293. PVOID InstallMsgHandlerContext;
  294. BOOL InstallMsgHandlerIsNativeCharWidth;
  295. //
  296. // Handle to a caller-supplied copy-queue. If this handle is present,
  297. // then file copy/rename/delete operations will be queued to this handle
  298. // instead of being acted upon. This will only happen if the DI_NOVCP
  299. // bit is set in the Flags field.
  300. // If no caller-supplied queue is present, this value is NULL
  301. // (_not_ INVALID_HANDLE_VALUE).
  302. //
  303. HSPFILEQ UserFileQ;
  304. //
  305. // Private DWORD reserved for Class Installer usage.
  306. //
  307. ULONG_PTR ClassInstallReserved;
  308. //
  309. // Specifies the string table index of an optional INF file
  310. // path. If the string is not supplied, its index will be -1.
  311. //
  312. LONG DriverPath;
  313. //
  314. // Pointer to class installer parameters. The first field of any class
  315. // installer parameter block is always a SP_CLASSINSTALL_HEADER structure.
  316. // The cbSize field of that structure gives the size, in bytes, of the header
  317. // (used for versioning), and the InstallFunction field gives the DI_FUNCTION
  318. // code that indicates how the parameter buffer is to be interpreted.
  319. // MAY BE NULL!
  320. //
  321. PSP_CLASSINSTALL_HEADER ClassInstallHeader;
  322. DWORD ClassInstallParamsSize;
  323. //
  324. // THE FOLLOWING PARAMETERS ARE NOT EXPOSED TO CALLERS (i.e., via
  325. // SetupDi(Get|Set)DeviceInstallParams).
  326. //
  327. HINSTANCE hinstClassInstaller;
  328. CLASS_INSTALL_PROC ClassInstallerEntryPoint;
  329. HANDLE ClassInstallerFusionContext;
  330. HINSTANCE hinstClassPropProvider;
  331. PROPSHEET_PROVIDER_PROC ClassEnumPropPagesEntryPoint;
  332. HANDLE ClassEnumPropPagesFusionContext;
  333. HINSTANCE hinstDevicePropProvider;
  334. PROPSHEET_PROVIDER_PROC DeviceEnumPropPagesEntryPoint;
  335. HANDLE DeviceEnumPropPagesFusionContext;
  336. HINSTANCE hinstBasicPropProvider;
  337. PROPSHEET_PROVIDER_PROC EnumBasicPropertiesEntryPoint;
  338. HANDLE EnumBasicPropertiesFusionContext;
  339. //
  340. // Maintain a list of co-installers to be called along with the class installer.
  341. // The count will be -1 if the list hasn't been retrieved yet.
  342. //
  343. LONG CoInstallerCount;
  344. PCOINSTALLER_NODE CoInstallerList;
  345. //
  346. // Logging context -- this is only here because this struct is shared
  347. // by both DEVINFO_ELEM and DEVINFO_SET.
  348. //
  349. PSETUP_LOG_CONTEXT LogContext;
  350. } DEVINSTALL_PARAM_BLOCK, *PDEVINSTALL_PARAM_BLOCK;
  351. //
  352. // Define structures used for associating lists of interface devices with
  353. // devinfo elements.
  354. //
  355. typedef struct _INTERFACE_DEVICE_NODE {
  356. struct _INTERFACE_DEVICE_NODE *Next;
  357. //
  358. // String table ID for this interface device's symbolic link name.
  359. //
  360. LONG SymLinkName;
  361. //
  362. // Store the interface class GUID index in each node. We need to do this,
  363. // in order to easily determine the class of the node.
  364. //
  365. LONG GuidIndex;
  366. //
  367. // The Flags field contains the same flags as the client sees in their
  368. // SP_INTERFACE_DEVICE_DATA structure.
  369. //
  370. DWORD Flags;
  371. //
  372. // Store a back-pointer to the devinfo element, because interface devices
  373. // may be enumerated outside the context of a device information element, and
  374. // we need to know how to get back to the owning device instance.
  375. //
  376. struct _DEVINFO_ELEM *OwningDevInfoElem;
  377. } INTERFACE_DEVICE_NODE, *PINTERFACE_DEVICE_NODE;
  378. typedef struct _INTERFACE_CLASS_LIST {
  379. LONG GuidIndex;
  380. PINTERFACE_DEVICE_NODE InterfaceDeviceNode;
  381. PINTERFACE_DEVICE_NODE InterfaceDeviceTruncateNode; // used for rollback.
  382. DWORD InterfaceDeviceCount;
  383. } INTERFACE_CLASS_LIST, *PINTERFACE_CLASS_LIST;
  384. //
  385. // Define flags for DiElemFlags field of DEVINFO_ELEM structure.
  386. //
  387. #define DIE_IS_PHANTOM (0x00000001) // is this a phantom (not live) devinst?
  388. #define DIE_IS_REGISTERED (0x00000002) // has this devinst been registered?
  389. #define DIE_IS_LOCKED (0x00000004) // are we explicitly locked during some UI
  390. // operation (e.g., wizard)?
  391. //
  392. // Define structure for the internal representation of a single
  393. // device information element.
  394. //
  395. typedef struct _DEVINFO_ELEM {
  396. //
  397. // Store the address of the containing devinfo set at the beginning of
  398. // this structure. This is used for validation of a caller-supplied
  399. // SP_DEVINFO_DATA, and is more efficient than the previous method of
  400. // searching through all devinfo elements in the set to make sure the
  401. // specified element exists in the set. This field should be zeroed
  402. // out when this element is destroyed.
  403. //
  404. struct _DEVICE_INFO_SET *ContainingDeviceInfoSet;
  405. //
  406. // Pointer to the next element in the set.
  407. //
  408. struct _DEVINFO_ELEM *Next;
  409. //
  410. // Specifies the device instance handle for this device. This will
  411. // be a phantom device instance handle if DIE_IS_PHANTOM is set.
  412. //
  413. // This should always contain a handle, unless the device instance
  414. // handle could not be re-opened after a re-enumeration (in which case,
  415. // the DI_NEEDREBOOT flag will be set), or if the device information
  416. // element was globally removed or config-specific removed from the last
  417. // hardware profile.
  418. //
  419. DEVINST DevInst;
  420. //
  421. // Specifies the GUID for this device's class.
  422. //
  423. GUID ClassGuid;
  424. //
  425. // Specifies flags pertaining to this device information element.
  426. // These DIE_* flags are for internal use only.
  427. //
  428. DWORD DiElemFlags;
  429. //
  430. // List of class drivers for this element.
  431. //
  432. UINT ClassDriverCount;
  433. PDRIVER_NODE ClassDriverHead;
  434. PDRIVER_NODE ClassDriverTail;
  435. //
  436. // class drivernode index 'hint' to speed up enumeration via
  437. // SetupDiEnumDriverInfo
  438. //
  439. PDRIVER_NODE ClassDriverEnumHint; // may be NULL
  440. DWORD ClassDriverEnumHintIndex; // may be INVALID_ENUM_INDEX
  441. //
  442. // List of compatible drivers for this element.
  443. //
  444. UINT CompatDriverCount;
  445. PDRIVER_NODE CompatDriverHead;
  446. PDRIVER_NODE CompatDriverTail;
  447. //
  448. // compatible drivernode index 'hint' to speed up enumeration via
  449. // SetupDiEnumDriverInfo
  450. //
  451. PDRIVER_NODE CompatDriverEnumHint; // may be NULL
  452. DWORD CompatDriverEnumHintIndex; // may be INVALID_ENUM_INDEX
  453. //
  454. // Pointer to selected driver for this element (may be
  455. // NULL if none currently selected). Whether this is a
  456. // class or compatible driver is specified by the
  457. // SelectedDriverType field.
  458. //
  459. PDRIVER_NODE SelectedDriver;
  460. DWORD SelectedDriverType;
  461. //
  462. // Installation parameter block.
  463. //
  464. DEVINSTALL_PARAM_BLOCK InstallParamBlock;
  465. //
  466. // Specifies the string table index of the device description.
  467. // If no description is known, this value will be -1.
  468. //
  469. // We store this string twice--once case-sensitively and once case-insensitively,
  470. // because we need it for displaying _and_ for fast lookup.
  471. //
  472. LONG DeviceDescription;
  473. LONG DeviceDescriptionDisplayName;
  474. //
  475. // Maintain an array of interface device lists. These lists represent the interface
  476. // devices owned by this device instance (but only those that have been retrieved, e.g.
  477. // by calling SetupDiGetClassDevs(...DIGCF_INTERFACEDEVICE...)
  478. //
  479. // (This array pointer may be NULL.)
  480. //
  481. PINTERFACE_CLASS_LIST InterfaceClassList;
  482. DWORD InterfaceClassListSize;
  483. //
  484. // Extra (non-class installer) data associated with each device information element.
  485. // Only exposed via private API for use during GUI-mode setup.
  486. //
  487. DWORD Context;
  488. } DEVINFO_ELEM, *PDEVINFO_ELEM;
  489. //
  490. // Structure containing dialog data for wizard pages. (Amalgamation of
  491. // DIALOGDATA structures defined in setupx and sysdm.)
  492. //
  493. typedef struct _SP_DIALOGDATA {
  494. INT iBitmap; // index into mini-icon bitmap
  495. HDEVINFO DevInfoSet; // DevInfo set we're working with
  496. PDEVINFO_ELEM DevInfoElem; // if DD_FLAG_USE_DEVINFO_ELEM flag set
  497. UINT flags;
  498. HWND hwndDrvList; // window of the driver list
  499. HWND hwndMfgList; // window of the Manufacturer list
  500. BOOL bShowCompat;
  501. BOOL bKeeplpCompatDrvList;
  502. BOOL bKeeplpClassDrvList;
  503. BOOL bKeeplpSelectedDrv;
  504. LONG iCurDesc; // string table index for the description of currently
  505. // selected driver (or to-be-selected driver)
  506. BOOL AuxThreadRunning; // Is our class driver search thread still running?
  507. DWORD PendingAction; // What (if anything) should we do when it finishes?
  508. int CurSelectionForSuccess; // If we have a pending successful return, what is the
  509. // listbox index for the successful selection?
  510. HIMAGELIST hImageList;
  511. HFONT hFontNormal;
  512. HFONT hFontBold;
  513. } SP_DIALOGDATA, *PSP_DIALOGDATA;
  514. //
  515. // Flags for SP_DIALOGDATA.flags:
  516. //
  517. #define DD_FLAG_USE_DEVINFO_ELEM 0x00000001
  518. #define DD_FLAG_IS_DIALOGBOX 0x00000002
  519. #define DD_FLAG_CLASSLIST_FAILED 0x00000004
  520. #define DD_FLAG_SHOWSIMILARDRIVERS 0x00000008
  521. //
  522. // Pending Action codes used in the NEWDEVWIZ_DATA structure to indicate what
  523. // should happen as soon as the auxilliary class driver search thread notifies us
  524. // of its termination.
  525. //
  526. #define PENDING_ACTION_NONE 0
  527. #define PENDING_ACTION_SELDONE 1
  528. #define PENDING_ACTION_SHOWCLASS 2
  529. #define PENDING_ACTION_CANCEL 3
  530. #define PENDING_ACTION_OEM 4
  531. #define PENDING_ACTION_WINDOWSUPDATE 5
  532. //
  533. // Icons that are associated with an item in the list view.
  534. //
  535. #define IMAGE_ICON_NOT_SIGNED 0
  536. #define IMAGE_ICON_SIGNED 1
  537. //
  538. // Define structure used for internal state storage by Device Installer
  539. // wizard pages. (From NEWDEVWIZ_INSTANCE struct in Win95 sysdm.)
  540. //
  541. typedef struct _NEWDEVWIZ_DATA {
  542. SP_INSTALLWIZARD_DATA InstallData;
  543. SP_DIALOGDATA ddData;
  544. BOOL bInit;
  545. UINT_PTR idTimer;
  546. } NEWDEVWIZ_DATA, *PNEWDEVWIZ_DATA;
  547. //
  548. // Define wizard page object structure used to ensure that wizard page
  549. // buffer is kept as long as needed, and destroyed when no longer in use.
  550. //
  551. typedef struct _WIZPAGE_OBJECT {
  552. struct _WIZPAGE_OBJECT *Next;
  553. DWORD RefCount;
  554. PNEWDEVWIZ_DATA ndwData;
  555. } WIZPAGE_OBJECT, *PWIZPAGE_OBJECT;
  556. //
  557. // Define driver list object structure used in the device information set
  558. // to keep track of the various class driver lists that devinfo elements
  559. // have referenced.
  560. //
  561. typedef struct _DRIVER_LIST_OBJECT {
  562. struct _DRIVER_LIST_OBJECT *Next;
  563. DWORD RefCount;
  564. //
  565. // We keep track of what parameters were used to create this driver
  566. // list, so that we can copy them to a new devinfo element during
  567. // inheritance.
  568. //
  569. DWORD ListCreationFlags;
  570. DWORD ListCreationFlagsEx;
  571. LONG ListCreationDriverPath;
  572. //
  573. // Also, keep track of what class this list was built for. Although a
  574. // device's class may change, this GUID remains constant.
  575. //
  576. GUID ClassGuid;
  577. //
  578. // Actual driver list. (This is also used as an ID used to find the
  579. // driver list object given a driver list head. We can do this, since
  580. // we know that once a driver list is built, the head element never
  581. // changes.)
  582. //
  583. PDRIVER_NODE DriverListHead;
  584. } DRIVER_LIST_OBJECT, *PDRIVER_LIST_OBJECT;
  585. //
  586. // Define node that tracks addition module handles to be unloaded when the
  587. // device information set is destroyed. This is used when a class installer,
  588. // property page provider, or co-installer becomes invalid (e.g., as a result
  589. // of a change in the device's class), but we can't unload the module yet.
  590. //
  591. typedef struct _MODULE_HANDLE_LIST_INSTANCE {
  592. HINSTANCE ModuleHandle;
  593. HANDLE FusionContext;
  594. } MODULE_HANDLE_LIST_INSTANCE,*PMODULE_HANDLE_LIST_INSTANCE;
  595. typedef struct _MODULE_HANDLE_LIST_NODE {
  596. struct _MODULE_HANDLE_LIST_NODE *Next;
  597. DWORD ModuleCount;
  598. MODULE_HANDLE_LIST_INSTANCE ModuleList[ANYSIZE_ARRAY];
  599. } MODULE_HANDLE_LIST_NODE, *PMODULE_HANDLE_LIST_NODE;
  600. //
  601. // Define structure for the internal representation of a
  602. // device information set.
  603. //
  604. typedef struct _DEVICE_INFO_SET {
  605. //
  606. // Specifies whether there is a class GUID associated
  607. // with this set, and if so, what it is.
  608. //
  609. BOOL HasClassGuid;
  610. GUID ClassGuid;
  611. //
  612. // List of class drivers for this set.
  613. //
  614. UINT ClassDriverCount;
  615. PDRIVER_NODE ClassDriverHead;
  616. PDRIVER_NODE ClassDriverTail;
  617. //
  618. // class drivernode index 'hint' to speed up enumeration via
  619. // SetupDiEnumDriverInfo
  620. //
  621. PDRIVER_NODE ClassDriverEnumHint; // may be NULL
  622. DWORD ClassDriverEnumHintIndex; // may be INVALID_ENUM_INDEX
  623. //
  624. // Pointer to selected class driver for this device information
  625. // set (may be NULL if none currently selected).
  626. //
  627. PDRIVER_NODE SelectedClassDriver;
  628. //
  629. // List of device information elements in the set.
  630. //
  631. UINT DeviceInfoCount;
  632. PDEVINFO_ELEM DeviceInfoHead;
  633. PDEVINFO_ELEM DeviceInfoTail;
  634. //
  635. // devinfo element index 'hint' to speed up enumeration via
  636. // SetupDiEnumDeviceInfo
  637. //
  638. PDEVINFO_ELEM DeviceInfoEnumHint; // may be NULL
  639. DWORD DeviceInfoEnumHintIndex; // may be INVALID_ENUM_INDEX
  640. //
  641. // Pointer to selected device for this device information set (may
  642. // be NULL if none currently selected). This is used during
  643. // installation wizard.
  644. //
  645. PDEVINFO_ELEM SelectedDevInfoElem;
  646. //
  647. // Installation parameter block (for global class driver list, if
  648. // present).
  649. //
  650. DEVINSTALL_PARAM_BLOCK InstallParamBlock;
  651. //
  652. // Private string table.
  653. //
  654. PVOID StringTable;
  655. //
  656. // Maintain a list of currently-active wizard objects. This allows us
  657. // to do the refcounting correctly for each object, and to keep the
  658. // set from being deleted until all wizard objects are destroyed.
  659. //
  660. PWIZPAGE_OBJECT WizPageList;
  661. //
  662. // Maintain a list of class driver lists that are currently being referenced
  663. // by various devinfo elements, as well as by the device info set itself
  664. // (i.e., for the current global class driver list.)
  665. //
  666. PDRIVER_LIST_OBJECT ClassDrvListObjectList;
  667. //
  668. // Maintain a reference count on how many times a thread has acquired
  669. // the lock on this device information set. This indicates how deeply
  670. // nested we currently are in device installer calls. The set can only
  671. // be deleted if this count is 1.
  672. //
  673. DWORD LockRefCount;
  674. //
  675. // Maintain a list of additional module handles we need to do a FreeLibrary
  676. // on when this device information set is destroyed.
  677. //
  678. PMODULE_HANDLE_LIST_NODE ModulesToFree;
  679. //
  680. // Maintain an array of class GUIDs for all driver nodes and device
  681. // interfaces used by members of this set. (May be NULL.)
  682. //
  683. LPGUID GuidTable;
  684. DWORD GuidTableSize;
  685. //
  686. // ConfigMgr machine name (string id) and handle, if this is a remote HDEVINFO set.
  687. //
  688. LONG MachineName; // -1 if local
  689. HMACHINE hMachine; // NULL if local
  690. //
  691. // Synchronization
  692. //
  693. MYLOCK Lock;
  694. } DEVICE_INFO_SET, *PDEVICE_INFO_SET;
  695. #define LockDeviceInfoSet(d) BeginSynchronizedAccess(&((d)->Lock))
  696. #define UnlockDeviceInfoSet(d) \
  697. \
  698. ((d)->LockRefCount)--; \
  699. EndSynchronizedAccess(&((d)->Lock))
  700. //
  701. // Define structures for global mini-icon storage.
  702. //
  703. typedef struct _CLASSICON {
  704. CONST GUID *ClassGuid;
  705. UINT MiniBitmapIndex;
  706. struct _CLASSICON *Next;
  707. } CLASSICON, *PCLASSICON;
  708. typedef struct _MINI_ICON_LIST {
  709. //
  710. // HDC for memory containing mini-icon bitmap
  711. //
  712. HDC hdcMiniMem;
  713. //
  714. // Handle to the bitmap image for the mini-icons
  715. //
  716. HBITMAP hbmMiniImage;
  717. //
  718. // Handle to the bitmap image for the mini-icon mask.
  719. //
  720. HBITMAP hbmMiniMask;
  721. //
  722. // Number of mini-icons in the bitmap
  723. //
  724. UINT NumClassImages;
  725. //
  726. // Head of list for installer-provided class icons.
  727. //
  728. PCLASSICON ClassIconList;
  729. //
  730. // Synchronization
  731. //
  732. MYLOCK Lock;
  733. } MINI_ICON_LIST, *PMINI_ICON_LIST;
  734. #define LockMiniIconList(d) BeginSynchronizedAccess(&((d)->Lock))
  735. #define UnlockMiniIconList(d) EndSynchronizedAccess(&((d)->Lock))
  736. //
  737. // Global mini-icon list.
  738. //
  739. extern MINI_ICON_LIST GlobalMiniIconList;
  740. typedef struct _CLASS_IMAGE_LIST {
  741. //
  742. // Index of the "Unknown" class image
  743. //
  744. int UnknownImageIndex;
  745. //
  746. // List of class guids
  747. //
  748. LPGUID ClassGuidList;
  749. //
  750. // Head of linked list of class icons.
  751. //
  752. PCLASSICON ClassIconList;
  753. //
  754. // Synchronization
  755. //
  756. MYLOCK Lock;
  757. } CLASS_IMAGE_LIST, *PCLASS_IMAGE_LIST;
  758. #define LockImageList(d) BeginSynchronizedAccess(&((d)->Lock))
  759. #define UnlockImageList(d) EndSynchronizedAccess(&((d)->Lock))
  760. typedef struct _DRVSEARCH_INPROGRESS_NODE {
  761. struct _DRVSEARCH_INPROGRESS_NODE *Next;
  762. //
  763. // Handle of device information set for which driver list is
  764. // currently being built.
  765. //
  766. HDEVINFO DeviceInfoSet;
  767. //
  768. // Flag indicating that the driver search should be aborted.
  769. //
  770. BOOL CancelSearch;
  771. //
  772. // Event handle that auxiliary thread waits on once it has set
  773. // the 'CancelSearch' flag (and once it has release the list
  774. // lock). When the thread doing the search notices the cancel
  775. // request, it will signal the event, thus the waiting thread
  776. // can ensure that the search has been cancelled before it returns.
  777. //
  778. HANDLE SearchCancelledEvent;
  779. } DRVSEARCH_INPROGRESS_NODE, *PDRVSEARCH_INPROGRESS_NODE;
  780. typedef struct _DRVSEARCH_INPROGRESS_LIST {
  781. //
  782. // Head of linked list containing nodes for each device information
  783. // set for which a driver search is currently underway.
  784. //
  785. PDRVSEARCH_INPROGRESS_NODE DrvSearchHead;
  786. //
  787. // Synchronization
  788. //
  789. MYLOCK Lock;
  790. } DRVSEARCH_INPROGRESS_LIST, *PDRVSEARCH_INPROGRESS_LIST;
  791. #define LockDrvSearchInProgressList(d) BeginSynchronizedAccess(&((d)->Lock))
  792. #define UnlockDrvSearchInProgressList(d) EndSynchronizedAccess(&((d)->Lock))
  793. //
  794. // Global "Driver Search In-Progress" list.
  795. //
  796. extern DRVSEARCH_INPROGRESS_LIST GlobalDrvSearchInProgressList;
  797. //
  798. // Device Information Set manipulation routines
  799. //
  800. PDEVICE_INFO_SET
  801. AllocateDeviceInfoSet(
  802. VOID
  803. );
  804. VOID
  805. DestroyDeviceInfoElement(
  806. IN HDEVINFO hDevInfo,
  807. IN PDEVICE_INFO_SET pDeviceInfoSet,
  808. IN PDEVINFO_ELEM DeviceInfoElement
  809. );
  810. DWORD
  811. DestroyDeviceInfoSet(
  812. IN HDEVINFO hDevInfo, OPTIONAL
  813. IN PDEVICE_INFO_SET pDeviceInfoSet
  814. );
  815. PDEVICE_INFO_SET
  816. AccessDeviceInfoSet(
  817. IN HDEVINFO DeviceInfoSet
  818. );
  819. PDEVICE_INFO_SET
  820. CloneDeviceInfoSet(
  821. IN HDEVINFO hDevInfo
  822. );
  823. PDEVICE_INFO_SET
  824. RollbackDeviceInfoSet(
  825. IN HDEVINFO hDevInfo,
  826. IN PDEVICE_INFO_SET ClonedDeviceInfoSet
  827. );
  828. PDEVICE_INFO_SET
  829. CommitDeviceInfoSet(
  830. IN HDEVINFO hDevInfo,
  831. IN PDEVICE_INFO_SET ClonedDeviceInfoSet
  832. );
  833. PDEVINFO_ELEM
  834. FindDevInfoByDevInst(
  835. IN PDEVICE_INFO_SET DeviceInfoSet,
  836. IN DEVINST DevInst,
  837. OUT PDEVINFO_ELEM *PrevDevInfoElem OPTIONAL
  838. );
  839. BOOL
  840. DevInfoDataFromDeviceInfoElement(
  841. IN PDEVICE_INFO_SET DeviceInfoSet,
  842. IN PDEVINFO_ELEM DevInfoElem,
  843. OUT PSP_DEVINFO_DATA DeviceInfoData
  844. );
  845. PDEVINFO_ELEM
  846. FindAssociatedDevInfoElem(
  847. IN PDEVICE_INFO_SET DeviceInfoSet,
  848. IN PSP_DEVINFO_DATA DeviceInfoData,
  849. OUT PDEVINFO_ELEM *PreviousElement OPTIONAL
  850. );
  851. //
  852. // Driver Node manipulation routines.
  853. //
  854. DWORD
  855. CreateDriverNode(
  856. IN UINT Rank,
  857. IN PCTSTR DevDescription,
  858. IN PCTSTR DrvDescription,
  859. IN PCTSTR ProviderName, OPTIONAL
  860. IN PCTSTR MfgName,
  861. IN PFILETIME InfDate,
  862. IN PCTSTR InfFileName,
  863. IN PCTSTR InfSectionName,
  864. IN PVOID StringTable,
  865. IN LONG InfClassGuidIndex,
  866. OUT PDRIVER_NODE *DriverNode
  867. );
  868. PDRIVER_LIST_OBJECT
  869. GetAssociatedDriverListObject(
  870. IN PDRIVER_LIST_OBJECT ObjectListHead,
  871. IN PDRIVER_NODE DriverListHead,
  872. OUT PDRIVER_LIST_OBJECT *PrevDriverListObject OPTIONAL
  873. );
  874. VOID
  875. DereferenceClassDriverList(
  876. IN PDEVICE_INFO_SET DeviceInfoSet,
  877. IN PDRIVER_NODE DriverListHead OPTIONAL
  878. );
  879. VOID
  880. DestroyDriverNodes(
  881. IN PDRIVER_NODE DriverNode,
  882. IN PDEVICE_INFO_SET pDeviceInfoSet
  883. );
  884. BOOL
  885. DrvInfoDataFromDriverNode(
  886. IN PDEVICE_INFO_SET DeviceInfoSet,
  887. IN PDRIVER_NODE DriverNode,
  888. IN DWORD DriverType,
  889. OUT PSP_DRVINFO_DATA DriverInfoData
  890. );
  891. PDRIVER_NODE
  892. FindAssociatedDriverNode(
  893. IN PDRIVER_NODE DriverListHead,
  894. IN PSP_DRVINFO_DATA DriverInfoData,
  895. OUT PDRIVER_NODE *PreviousNode OPTIONAL
  896. );
  897. PDRIVER_NODE
  898. SearchForDriverNode(
  899. IN PVOID StringTable,
  900. IN PDRIVER_NODE DriverListHead,
  901. IN PSP_DRVINFO_DATA DriverInfoData,
  902. OUT PDRIVER_NODE *PreviousNode OPTIONAL
  903. );
  904. DWORD
  905. DrvInfoDetailsFromDriverNode(
  906. IN PDEVICE_INFO_SET DeviceInfoSet,
  907. IN PDRIVER_NODE DriverNode,
  908. OUT PSP_DRVINFO_DETAIL_DATA DriverInfoDetailData, OPTIONAL
  909. IN DWORD BufferSize,
  910. OUT PDWORD RequiredSize OPTIONAL
  911. );
  912. //
  913. // Installation parameter manipulation routines
  914. //
  915. DWORD
  916. GetDevInstallParams(
  917. IN PDEVICE_INFO_SET DeviceInfoSet,
  918. IN PDEVINSTALL_PARAM_BLOCK DevInstParamBlock,
  919. OUT PSP_DEVINSTALL_PARAMS DeviceInstallParams
  920. );
  921. DWORD
  922. GetClassInstallParams(
  923. IN PDEVINSTALL_PARAM_BLOCK DevInstParamBlock,
  924. OUT PSP_CLASSINSTALL_HEADER ClassInstallParams, OPTIONAL
  925. IN DWORD BufferSize,
  926. OUT PDWORD RequiredSize OPTIONAL
  927. );
  928. DWORD
  929. SetDevInstallParams(
  930. IN OUT PDEVICE_INFO_SET DeviceInfoSet,
  931. IN PSP_DEVINSTALL_PARAMS DeviceInstallParams,
  932. OUT PDEVINSTALL_PARAM_BLOCK DevInstParamBlock,
  933. IN BOOL MsgHandlerIsNativeCharWidth
  934. );
  935. DWORD
  936. SetClassInstallParams(
  937. IN OUT PDEVICE_INFO_SET DeviceInfoSet,
  938. IN PSP_CLASSINSTALL_HEADER ClassInstallParams, OPTIONAL
  939. IN DWORD ClassInstallParamsSize,
  940. OUT PDEVINSTALL_PARAM_BLOCK DevInstParamBlock
  941. );
  942. VOID
  943. DestroyInstallParamBlock(
  944. IN HDEVINFO hDevInfo, OPTIONAL
  945. IN PDEVICE_INFO_SET pDeviceInfoSet,
  946. IN PDEVINFO_ELEM DevInfoElem, OPTIONAL
  947. IN PDEVINSTALL_PARAM_BLOCK InstallParamBlock
  948. );
  949. DWORD
  950. GetDrvInstallParams(
  951. IN PDRIVER_NODE DriverNode,
  952. OUT PSP_DRVINSTALL_PARAMS DriverInstallParams
  953. );
  954. DWORD
  955. SetDrvInstallParams(
  956. IN PSP_DRVINSTALL_PARAMS DriverInstallParams,
  957. OUT PDRIVER_NODE DriverNode
  958. );
  959. //
  960. // Device Instance manipulation routines
  961. //
  962. #if 0 // This functionality is performed by CM APIs.
  963. BOOL
  964. ValidateDeviceInstanceId(
  965. IN PCTSTR DeviceInstanceId
  966. );
  967. VOID
  968. CopyFixedUpDeviceId(
  969. OUT PTSTR DestinationString,
  970. IN PCTSTR SourceString,
  971. IN DWORD SourceStringLen
  972. );
  973. #endif // This functionality is performed by CM APIs.
  974. //
  975. // String Table helper functions
  976. //
  977. LONG
  978. AddMultiSzToStringTable(
  979. IN PVOID StringTable,
  980. IN PTCHAR MultiSzBuffer,
  981. OUT PLONG StringIdList,
  982. IN DWORD StringIdListSize,
  983. IN BOOL CaseSensitive,
  984. OUT PTCHAR *UnprocessedBuffer OPTIONAL
  985. );
  986. LONG
  987. LookUpStringInDevInfoSet(
  988. IN HDEVINFO DeviceInfoSet,
  989. IN PTSTR String,
  990. IN BOOL CaseSensitive
  991. );
  992. //
  993. // INF processing functions
  994. //
  995. typedef struct _DRVSEARCH_CONTEXT {
  996. PDRIVER_NODE *pDriverListHead;
  997. PDRIVER_NODE *pDriverListTail;
  998. PUINT pDriverCount;
  999. GUID ClassGuid;
  1000. PDEVICE_INFO_SET DeviceInfoSet;
  1001. DWORD Flags;
  1002. BOOL BuildClassDrvList;
  1003. LONG IdList[2][MAX_HCID_COUNT+1]; // leave extra entry for '-1' end-of-list marker.
  1004. PVOID StringTable;
  1005. PBOOL CancelSearch;
  1006. TCHAR ClassGuidString[GUID_STRING_LEN];
  1007. TCHAR ClassName[MAX_CLASS_NAME_LEN];
  1008. TCHAR LegacyClassName[MAX_CLASS_NAME_LEN];
  1009. TCHAR LegacyClassLang[32]; // e.g., "ENG", "GER", "FREN", "SPAN", etc.
  1010. LONG InstalledDescription;
  1011. LONG InstalledMfgName;
  1012. LONG InstalledProviderName;
  1013. LONG InstalledInfSection;
  1014. LONG InstalledInfSectionExt;
  1015. PSP_ALTPLATFORM_INFO_V2 AltPlatformInfo; // may be NULL
  1016. HCATADMIN hCatAdmin; // NULL upon entry, free if non-NULL upon return via CryptCATAdminReleaseContext
  1017. } DRVSEARCH_CONTEXT, *PDRVSEARCH_CONTEXT;
  1018. //
  1019. // DRVSEARCH_CONTEXT.Flags
  1020. //
  1021. #define DRVSRCH_HASCLASSGUID 0x00000001
  1022. #define DRVSRCH_FILTERCLASS 0x00000002
  1023. #define DRVSRCH_TRY_PNF 0x00000004
  1024. #define DRVSRCH_USEOLDINFS 0x00000008
  1025. #define DRVSRCH_FROM_INET 0x00000010
  1026. #define DRVSRCH_CLEANUP_SOURCE_PATH 0x00000020
  1027. #define DRVSRCH_EXCLUDE_OLD_INET_DRIVERS 0x00000040
  1028. #define DRVSRCH_ALLOWEXCLUDEDDRVS 0x00000080
  1029. #define DRVSRCH_FILTERSIMILARDRIVERS 0x00000100
  1030. #define DRVSRCH_INSTALLEDDRIVER 0x00000200
  1031. #define DRVSRCH_NO_CLASSLIST_NODE_MERGE 0x00000400
  1032. DWORD
  1033. EnumSingleDrvInf(
  1034. IN PCTSTR InfName,
  1035. IN OUT LPWIN32_FIND_DATA InfFileData,
  1036. IN DWORD SearchControl,
  1037. IN InfCacheCallback EnumInfCallback,
  1038. IN PSETUP_LOG_CONTEXT LogContext,
  1039. IN OUT PDRVSEARCH_CONTEXT Context
  1040. );
  1041. DWORD
  1042. EnumDrvInfsInDirPathList(
  1043. IN PCTSTR DirPathList, OPTIONAL
  1044. IN DWORD SearchControl,
  1045. IN InfCacheCallback EnumInfCallback,
  1046. IN BOOL IgnoreNonCriticalErrors,
  1047. IN PSETUP_LOG_CONTEXT LogContext,
  1048. IN OUT PDRVSEARCH_CONTEXT Context
  1049. );
  1050. BOOL
  1051. GetDecoratedModelsSection(
  1052. IN PSETUP_LOG_CONTEXT LogContext, OPTIONAL
  1053. IN PLOADED_INF Inf,
  1054. IN PINF_LINE MfgListLine,
  1055. IN PSP_ALTPLATFORM_INFO_V2 AltPlatformInfo, OPTIONAL
  1056. OUT PTSTR DecoratedModelsSection OPTIONAL
  1057. );
  1058. PTSTR
  1059. GetFullyQualifiedMultiSzPathList(
  1060. IN PCTSTR PathList
  1061. );
  1062. BOOL
  1063. pRemoveDirectory(
  1064. PTSTR Path
  1065. );
  1066. BOOL
  1067. ShouldClassBeExcluded(
  1068. IN LPGUID ClassGuid,
  1069. IN BOOL ExcludeNoInstallClass
  1070. );
  1071. BOOL
  1072. ClassGuidFromInfVersionNode(
  1073. IN PINF_VERSION_NODE VersionNode,
  1074. OUT LPGUID ClassGuid
  1075. );
  1076. VOID
  1077. AppendLoadIncludedInfs(
  1078. IN HINF hDeviceInf,
  1079. IN PCTSTR InfFileName,
  1080. IN PCTSTR InfSectionName,
  1081. IN BOOL AppendLayoutInfs
  1082. );
  1083. DWORD
  1084. InstallFromInfSectionAndNeededSections(
  1085. IN HWND Owner, OPTIONAL
  1086. IN HINF InfHandle,
  1087. IN PCTSTR SectionName,
  1088. IN UINT Flags,
  1089. IN HKEY RelativeKeyRoot, OPTIONAL
  1090. IN PCTSTR SourceRootPath, OPTIONAL
  1091. IN UINT CopyFlags,
  1092. IN PSP_FILE_CALLBACK MsgHandler,
  1093. IN PVOID Context, OPTIONAL
  1094. IN HDEVINFO DeviceInfoSet, OPTIONAL
  1095. IN PSP_DEVINFO_DATA DeviceInfoData, OPTIONAL
  1096. IN HSPFILEQ UserFileQ OPTIONAL
  1097. );
  1098. DWORD
  1099. MarkQueueForDeviceInstall(
  1100. IN HSPFILEQ QueueHandle,
  1101. IN HINF DeviceInfHandle,
  1102. IN PCTSTR DeviceDesc OPTIONAL
  1103. );
  1104. //
  1105. // Icon list manipulation functions.
  1106. //
  1107. BOOL
  1108. InitMiniIconList(
  1109. VOID
  1110. );
  1111. BOOL
  1112. DestroyMiniIconList(
  1113. VOID
  1114. );
  1115. //
  1116. // "Driver Search In-Progress" list functions.
  1117. //
  1118. BOOL
  1119. InitDrvSearchInProgressList(
  1120. VOID
  1121. );
  1122. BOOL
  1123. DestroyDrvSearchInProgressList(
  1124. VOID
  1125. );
  1126. //
  1127. // 'helper module' manipulation functions.
  1128. //
  1129. DWORD
  1130. GetModuleEntryPoint(
  1131. IN HKEY hk, OPTIONAL
  1132. IN LPCTSTR RegistryValue,
  1133. IN LPCTSTR DefaultProcName,
  1134. OUT HINSTANCE *phinst,
  1135. OUT FARPROC *pEntryPoint,
  1136. OUT HANDLE *pFusionContext,
  1137. OUT BOOL *pMustAbort, OPTIONAL
  1138. IN PSETUP_LOG_CONTEXT LogContext, OPTIONAL
  1139. IN HWND Owner, OPTIONAL
  1140. IN CONST GUID *DeviceSetupClassGuid, OPTIONAL
  1141. IN SetupapiVerifyProblem Problem,
  1142. IN LPCTSTR DeviceDesc, OPTIONAL
  1143. IN DWORD DriverSigningPolicy,
  1144. IN DWORD NoUI,
  1145. IN OUT HCATADMIN *hCatAdmin OPTIONAL
  1146. );
  1147. //
  1148. // Define flags for InvalidateHelperModules
  1149. //
  1150. #define IHM_COINSTALLERS_ONLY 0x00000001
  1151. #define IHM_FREE_IMMEDIATELY 0x00000002
  1152. DWORD
  1153. InvalidateHelperModules(
  1154. IN HDEVINFO DeviceInfoSet,
  1155. IN PSP_DEVINFO_DATA DeviceInfoData, OPTIONAL
  1156. IN DWORD Flags
  1157. );
  1158. //
  1159. // Define flags for _SetupDiCallClassInstaller
  1160. //
  1161. #define CALLCI_LOAD_HELPERS 0x00000001
  1162. #define CALLCI_CALL_HELPERS 0x00000002
  1163. #define CALLCI_ALLOW_DRVSIGN_UI 0x00000004
  1164. BOOL
  1165. _SetupDiCallClassInstaller(
  1166. IN DI_FUNCTION InstallFunction,
  1167. IN HDEVINFO DeviceInfoSet,
  1168. IN PSP_DEVINFO_DATA DeviceInfoData, OPTIONAL
  1169. IN DWORD Flags
  1170. );
  1171. //
  1172. // OEM driver selection routines.
  1173. //
  1174. DWORD
  1175. SelectOEMDriver(
  1176. IN HWND hwndParent, OPTIONAL
  1177. IN HDEVINFO DeviceInfoSet,
  1178. IN PSP_DEVINFO_DATA DeviceInfoData, OPTIONAL
  1179. IN BOOL IsWizard
  1180. );
  1181. //
  1182. // Registry helper routines.
  1183. //
  1184. DWORD
  1185. pSetupDeleteDevRegKeys(
  1186. IN DEVINST DevInst,
  1187. IN DWORD Scope,
  1188. IN DWORD HwProfile,
  1189. IN DWORD KeyType,
  1190. IN BOOL DeleteUserKeys
  1191. );
  1192. VOID
  1193. GetRegSubkeysFromDeviceInterfaceName(
  1194. IN OUT PTSTR DeviceInterfaceName,
  1195. OUT PTSTR *SubKeyName
  1196. );
  1197. LONG
  1198. OpenDeviceInterfaceSubKey(
  1199. IN HKEY hKeyInterfaceClass,
  1200. IN PCTSTR DeviceInterfaceName,
  1201. IN REGSAM samDesired,
  1202. OUT PHKEY phkResult,
  1203. OUT PTSTR OwningDevInstName, OPTIONAL
  1204. IN OUT PDWORD OwningDevInstNameSize OPTIONAL
  1205. );
  1206. //
  1207. // Guid table routines.
  1208. //
  1209. LONG
  1210. AddOrGetGuidTableIndex(
  1211. IN PDEVICE_INFO_SET DeviceInfoSet,
  1212. IN CONST GUID *ClassGuid,
  1213. IN BOOL AddIfNotPresent
  1214. );
  1215. //
  1216. // Interface device routines.
  1217. //
  1218. PINTERFACE_CLASS_LIST
  1219. AddOrGetInterfaceClassList(
  1220. IN PDEVICE_INFO_SET DeviceInfoSet,
  1221. IN PDEVINFO_ELEM DevInfoElem,
  1222. IN LONG InterfaceClassGuidIndex,
  1223. IN BOOL AddIfNotPresent
  1224. );
  1225. BOOL
  1226. InterfaceDeviceDataFromNode(
  1227. IN PINTERFACE_DEVICE_NODE InterfaceDeviceNode,
  1228. IN CONST GUID *InterfaceClassGuid,
  1229. OUT PSP_DEVICE_INTERFACE_DATA InterfaceDeviceData
  1230. );
  1231. PDEVINFO_ELEM
  1232. FindDevInfoElemForInterfaceDevice(
  1233. IN PDEVICE_INFO_SET DeviceInfoSet,
  1234. IN PSP_DEVICE_INTERFACE_DATA InterfaceDeviceData
  1235. );
  1236. //
  1237. // Service installation routines.
  1238. //
  1239. typedef struct _SVCNAME_NODE {
  1240. struct _SVCNAME_NODE *Next;
  1241. TCHAR Name[MAX_SERVICE_NAME_LEN];
  1242. BOOL DeleteEventLog;
  1243. TCHAR EventLogType[256];
  1244. TCHAR EventLogName[256];
  1245. DWORD Flags;
  1246. } SVCNAME_NODE, *PSVCNAME_NODE;
  1247. //
  1248. // Define an additional (private) SPSVCINST flag for
  1249. // InstallNtService.
  1250. //
  1251. #define SPSVCINST_NO_DEVINST_CHECK (0x80000000)
  1252. DWORD
  1253. InstallNtService(
  1254. IN PDEVINFO_ELEM DevInfoElem, OPTIONAL
  1255. IN HINF hDeviceInf,
  1256. IN PCTSTR InfFileName, OPTIONAL
  1257. IN PCTSTR szSectionName, OPTIONAL
  1258. OUT PSVCNAME_NODE *ServicesToDelete, OPTIONAL
  1259. IN DWORD Flags,
  1260. OUT PBOOL NullDriverInstalled
  1261. );
  1262. //
  1263. // Ansi/Unicode conversion routines.
  1264. //
  1265. DWORD
  1266. pSetupDiDevInstParamsAnsiToUnicode(
  1267. IN PSP_DEVINSTALL_PARAMS_A AnsiDevInstParams,
  1268. OUT PSP_DEVINSTALL_PARAMS_W UnicodeDevInstParams
  1269. );
  1270. DWORD
  1271. pSetupDiDevInstParamsUnicodeToAnsi(
  1272. IN PSP_DEVINSTALL_PARAMS_W UnicodeDevInstParams,
  1273. OUT PSP_DEVINSTALL_PARAMS_A AnsiDevInstParams
  1274. );
  1275. DWORD
  1276. pSetupDiSelDevParamsAnsiToUnicode(
  1277. IN PSP_SELECTDEVICE_PARAMS_A AnsiSelDevParams,
  1278. OUT PSP_SELECTDEVICE_PARAMS_W UnicodeSelDevParams
  1279. );
  1280. DWORD
  1281. pSetupDiSelDevParamsUnicodeToAnsi(
  1282. IN PSP_SELECTDEVICE_PARAMS_W UnicodeSelDevParams,
  1283. OUT PSP_SELECTDEVICE_PARAMS_A AnsiSelDevParams
  1284. );
  1285. DWORD
  1286. pSetupDiDrvInfoDataAnsiToUnicode(
  1287. IN PSP_DRVINFO_DATA_A AnsiDrvInfoData,
  1288. OUT PSP_DRVINFO_DATA_W UnicodeDrvInfoData
  1289. );
  1290. DWORD
  1291. pSetupDiDrvInfoDataUnicodeToAnsi(
  1292. IN PSP_DRVINFO_DATA_W UnicodeDrvInfoData,
  1293. OUT PSP_DRVINFO_DATA_A AnsiDrvInfoData
  1294. );
  1295. DWORD
  1296. pSetupDiDevInfoSetDetailDataUnicodeToAnsi(
  1297. IN PSP_DEVINFO_LIST_DETAIL_DATA_W UnicodeDevInfoSetDetails,
  1298. OUT PSP_DEVINFO_LIST_DETAIL_DATA_A AnsiDevInfoSetDetails
  1299. );
  1300. //
  1301. // Misc. utility routines
  1302. //
  1303. DWORD
  1304. MapCrToSpError(
  1305. IN CONFIGRET CmReturnCode,
  1306. IN DWORD Default
  1307. );
  1308. VOID
  1309. SetDevnodeNeedsRebootProblemWithArg2(
  1310. IN PDEVINFO_ELEM DevInfoElem,
  1311. IN PDEVICE_INFO_SET DevInfoSet,
  1312. IN DWORD Reason, OPTIONAL
  1313. IN ULONG_PTR Arg1, OPTIONAL
  1314. IN ULONG_PTR Arg2 OPTIONAL
  1315. );
  1316. #define SetDevnodeNeedsRebootProblemWithArg(DevInfoElem,DevInfoSet,Reason,Arg) SetDevnodeNeedsRebootProblemWithArg2(DevInfoElem,DevInfoSet,Reason,Arg,0)
  1317. #define SetDevnodeNeedsRebootProblem(DevInfoElem,DevInfoSet,Reason) SetDevnodeNeedsRebootProblemWithArg2(DevInfoElem,DevInfoSet,Reason,0,0)
  1318. BOOL
  1319. GetBestDeviceDesc(
  1320. IN HDEVINFO DeviceInfoSet,
  1321. IN PSP_DEVINFO_DATA DeviceInfoData, OPTIONAL
  1322. OUT PTSTR DeviceDescBuffer
  1323. );