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.

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