devinst.h
Upload User: caisha3
Upload Date: 2013-09-21
Package Size: 208739k
Code Size: 46k
Category:

Windows Develop

Development Platform:

Visual C++

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