Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

664 lines
14 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. hwcomp.h
  5. Abstract:
  6. This file declares the interface for hardware compatibility code.
  7. This includes the routines that build hwcomp.dat (the NT PNP ID
  8. list), that compare the hardware on Win9x to what is supported by
  9. NT, that enumerate the Win9x devices, and that manage the Have Disk
  10. capability for drivers.
  11. Author:
  12. Jim Schmidt (jimschm) 06-Jul-1996
  13. Revision History:
  14. jimschm 09-Jan-1998 Work on hwcomp.dat rebuild detection
  15. jimschm 11-Nov-1997 Have Disk capability, online detection
  16. jimschm 09-Oct-1997 Revised to use project's APIs
  17. --*/
  18. #pragma once
  19. #define MAX_HARDWARE_STRING 256
  20. //
  21. // The list of fields needed from a device
  22. //
  23. #define DEVICE_FIELDS \
  24. DECLARE(Class, TEXT("Class")) \
  25. DECLARE(DeviceDesc, TEXT("DeviceDesc")) \
  26. DECLARE(Mfg, TEXT("Mfg")) \
  27. DECLARE(Driver, TEXT("Driver")) \
  28. DECLARE(HardwareID, TEXT("HardwareID")) \
  29. DECLARE(CompatibleIDs, TEXT("CompatibleIDs")) \
  30. DECLARE(HWRevision, TEXT("HWRevision")) \
  31. DECLARE(BusType, TEXT("BusType")) \
  32. DECLARE(InfName, TEXT("InfName")) \
  33. DECLARE(CurrentDriveLetter, TEXT("CurrentDriveLetter")) \
  34. DECLARE(ProductId, TEXT("ProductId")) \
  35. DECLARE(SCSILUN, TEXT("SCSILUN")) \
  36. DECLARE(SCSITargetID, TEXT("SCSITargetID")) \
  37. DECLARE(ClassGUID, TEXT("ClassGUID")) \
  38. DECLARE(MasterCopy, TEXT("MasterCopy")) \
  39. DECLARE(UserDriveLetter, TEXT("UserDriveLetter")) \
  40. DECLARE(CurrentDriveLetterAssignment, TEXT("CurrentDriveLetterAssignment")) \
  41. DECLARE(UserDriveLetterAssignment, TEXT("UserDriveLetterAssignment")) \
  42. #define DECLARE(varname,text) PCTSTR varname;
  43. typedef enum {
  44. ENUM_ALL_DEVICES,
  45. ENUM_COMPATIBLE_DEVICES,
  46. ENUM_INCOMPATIBLE_DEVICES,
  47. ENUM_UNSUPPORTED_DEVICES,
  48. ENUM_NON_FUNCTIONAL_DEVICES
  49. } TYPE_OF_ENUM;
  50. //
  51. // Things caller does NOT want from enumeration
  52. // (makes enumeration faster)
  53. //
  54. #define ENUM_DONT_WANT_DEV_FIELDS 0x0001
  55. #define ENUM_DONT_WANT_USER_SUPPLIED 0x0002
  56. //
  57. // Things caller wants from enumerations
  58. //
  59. #define ENUM_WANT_USER_SUPPLIED_ONLY 0x0004
  60. #define ENUM_WANT_DEV_FIELDS 0x0000 // default!
  61. #define ENUM_WANT_ONLINE_FLAG 0x0010
  62. #define ENUM_WANT_COMPATIBLE_FLAG 0x0020
  63. #define ENUM_WANT_USER_SUPPLIED_FLAG 0x0040
  64. //
  65. // Flag to supress the requirement for the Hardware ID.
  66. //
  67. #define ENUM_DONT_REQUIRE_HARDWAREID 0x0100
  68. #define ENUM_WANT_ALL (ENUM_WANT_DEV_FIELDS| \
  69. ENUM_WANT_ONLINE_FLAG| \
  70. ENUM_WANT_COMPATIBLE_FLAG| \
  71. ENUM_WANT_USER_SUPPLIED_FLAG)
  72. typedef struct {
  73. //
  74. // Enumeration state
  75. //
  76. PCTSTR InstanceId;
  77. PCTSTR FullKey;
  78. HKEY KeyHandle;
  79. //
  80. // Optional enumeration elements
  81. //
  82. // Not filled when ENUM_DONT_WANT_DEV_FIELDS is specified in EnumFlags
  83. DEVICE_FIELDS
  84. // Only when ENUM_WANT_ONLINE_FLAG is specified in EnumFlags
  85. BOOL Online;
  86. // Only when ENUM_WANT_COMPATIBLE_FLAG is specified in EnumFlags
  87. BOOL HardwareIdCompatible;
  88. BOOL CompatibleIdCompatible;
  89. BOOL SuppliedByUi;
  90. BOOL Compatible;
  91. BOOL HardwareIdUnsupported;
  92. BOOL CompatibleIdUnsupported;
  93. BOOL Unsupported;
  94. //
  95. // Enumeration position
  96. //
  97. REGTREE_ENUM ek;
  98. REGVALUE_ENUM ev;
  99. UINT State;
  100. TYPE_OF_ENUM TypeOfEnum;
  101. DWORD EnumFlags;
  102. } HARDWARE_ENUM, *PHARDWARE_ENUM;
  103. #undef DECLARE
  104. BOOL
  105. WINAPI
  106. HwComp_Entry(
  107. HINSTANCE hInstance,
  108. DWORD dwReason,
  109. LPVOID lpReserved
  110. );
  111. BOOL
  112. RealEnumFirstHardware (
  113. OUT PHARDWARE_ENUM EnumPtr,
  114. IN TYPE_OF_ENUM TypeOfEnum,
  115. IN DWORD EnumFlags
  116. );
  117. #define EnumFirstHardware(e,type,flags) SETTRACKCOMMENT(BOOL,"EnumFirstHardware",__FILE__,__LINE__)\
  118. RealEnumFirstHardware(e,type,flags)\
  119. CLRTRACKCOMMENT
  120. BOOL
  121. RealEnumNextHardware (
  122. IN OUT PHARDWARE_ENUM EnumPtr
  123. );
  124. #define EnumNextHardware(e) SETTRACKCOMMENT(BOOL,"EnumNextHardware",__FILE__,__LINE__)\
  125. RealEnumNextHardware(e)\
  126. CLRTRACKCOMMENT
  127. VOID
  128. AbortHardwareEnum (
  129. IN OUT PHARDWARE_ENUM EnumPtr
  130. );
  131. BOOL
  132. CreateNtHardwareList (
  133. IN PCTSTR * NtInfPaths,
  134. IN UINT NtInfPathCount,
  135. IN PCTSTR HwCompDatPath, OPTIONAL
  136. IN INT UiMode
  137. );
  138. BOOL
  139. HwComp_ScanForCriticalDevices (
  140. VOID
  141. );
  142. VOID
  143. FreeNtHardwareList (
  144. VOID
  145. );
  146. BOOL
  147. FindHardwareId (
  148. IN PCTSTR PnpId,
  149. OUT PTSTR InfFileName
  150. );
  151. BOOL
  152. FindUnsupportedHardwareId (
  153. IN PCTSTR PnpId,
  154. OUT PTSTR InfFileName
  155. );
  156. BOOL
  157. FindUserSuppliedDriver (
  158. IN PCTSTR HardwareIdList, OPTIONAL
  159. IN PCTSTR CompatibleIdList OPTIONAL
  160. );
  161. BOOL
  162. FindHardwareIdInHashTable (
  163. IN PCTSTR PnpIdList,
  164. OUT PTSTR InfFileName, OPTIONAL
  165. IN HASHTABLE StrTable,
  166. IN BOOL UseOverrideList
  167. );
  168. typedef enum {
  169. QUERY,
  170. LOAD,
  171. DUMP
  172. } LOADOP;
  173. BOOL
  174. LoadDeviceList (
  175. IN LOADOP QueryFlag,
  176. IN PCTSTR HwCompDat
  177. );
  178. BOOL
  179. SaveDeviceList (
  180. PCTSTR HwCompDat
  181. );
  182. PCTSTR
  183. ExtractPnpId (
  184. IN PCTSTR PnpIdList,
  185. OUT PTSTR PnpIdBuf
  186. );
  187. BOOL
  188. AddPnpIdsToHashTable (
  189. IN OUT HASHTABLE Table,
  190. IN PCTSTR PnpIdList
  191. );
  192. BOOL
  193. AddPnpIdsToGrowList (
  194. IN OUT PGROWLIST GrowList,
  195. IN PCTSTR PnpIdList
  196. );
  197. PCTSTR
  198. AddPnpIdsToGrowBuf (
  199. IN OUT PGROWBUFFER GrowBuffer,
  200. IN PCTSTR PnpIdList
  201. );
  202. #define KNOWN_HARDWARE TRUE
  203. #define UNKNOWN_HARDWARE FALSE
  204. //
  205. // Network adapter enumeration
  206. //
  207. typedef enum {
  208. BUSTYPE_ISA,
  209. BUSTYPE_EISA,
  210. BUSTYPE_MCA,
  211. BUSTYPE_PCI,
  212. BUSTYPE_PNPISA,
  213. BUSTYPE_PCMCIA,
  214. BUSTYPE_ROOT,
  215. BUSTYPE_UNKNOWN
  216. } BUSTYPE;
  217. extern PCTSTR g_BusType[];
  218. typedef enum {
  219. TRANSCIEVERTYPE_AUTO,
  220. TRANSCIEVERTYPE_THICKNET,
  221. TRANSCIEVERTYPE_THINNET,
  222. TRANSCIEVERTYPE_TP,
  223. TRANSCIEVERTYPE_UNKNOWN
  224. } TRANSCIEVERTYPE;
  225. extern PCTSTR g_TranscieverType[];
  226. typedef enum {
  227. IOCHANNELREADY_EARLY,
  228. IOCHANNELREADY_LATE,
  229. IOCHANNELREADY_NEVER,
  230. IOCHANNELREADY_AUTODETECT,
  231. IOCHANNELREADY_UNKNOWN
  232. } IOCHANNELREADY;
  233. extern PCTSTR g_IoChannelReady[];
  234. typedef struct {
  235. // Enumeration output
  236. TCHAR HardwareId[MAX_HARDWARE_STRING];
  237. TCHAR CompatibleIDs[MAX_HARDWARE_STRING];
  238. TCHAR Description[MAX_HARDWARE_STRING];
  239. BUSTYPE BusType;
  240. TCHAR IoAddrs[MAX_HARDWARE_STRING];
  241. TCHAR Irqs[MAX_HARDWARE_STRING];
  242. TCHAR Dma[MAX_HARDWARE_STRING];
  243. TCHAR MemRanges[MAX_HARDWARE_STRING];
  244. TCHAR CurrentKey[MAX_HARDWARE_STRING];
  245. TRANSCIEVERTYPE TranscieverType;
  246. IOCHANNELREADY IoChannelReady;
  247. // Enumeration variables
  248. HARDWARE_ENUM HardwareEnum;
  249. UINT State;
  250. } NETCARD_ENUM, *PNETCARD_ENUM;
  251. BOOL
  252. EnumFirstNetCard (
  253. OUT PNETCARD_ENUM EnumPtr
  254. );
  255. BOOL
  256. EnumNextNetCard (
  257. IN OUT PNETCARD_ENUM EnumPtr
  258. );
  259. VOID
  260. EnumNetCardAbort (
  261. IN PNETCARD_ENUM EnumPtr
  262. );
  263. BOOL
  264. GetLegacyKeyboardId (
  265. OUT PTSTR Buffer,
  266. IN UINT BufferSize
  267. );
  268. //
  269. // HKEY_DYN_DATA enumeration functions
  270. //
  271. typedef struct {
  272. PTSTR ClassFilter; // supplied by caller
  273. REGKEY_ENUM CurrentDevice; // for enumeration
  274. HKEY ConfigMgrKey; // key to HKDD\Config Manager
  275. HKEY EnumKey; // key to HKLM\Enum
  276. HKEY ActualDeviceKey; // key to HKLM\Enum\<enumerator>\<pnpid>\<device>
  277. BOOL NotFirst; // for enumeration
  278. TCHAR RegLocation[MAX_REGISTRY_KEY]; // <enumerator>\<pnpid>\<instance>
  279. } ACTIVE_HARDWARE_ENUM, *PACTIVE_HARDWARE_ENUM;
  280. BOOL
  281. EnumFirstActiveHardware (
  282. OUT PACTIVE_HARDWARE_ENUM EnumPtr,
  283. IN PCTSTR ClassFilter OPTIONAL
  284. );
  285. BOOL
  286. EnumNextActiveHardware (
  287. IN OUT PACTIVE_HARDWARE_ENUM EnumPtr
  288. );
  289. VOID
  290. AbortActiveHardwareEnum (
  291. IN PACTIVE_HARDWARE_ENUM EnumPtr
  292. );
  293. BOOL
  294. IsPnpIdOnline (
  295. IN PCTSTR PnpId,
  296. IN PCTSTR Class OPTIONAL
  297. );
  298. BOOL
  299. HwComp_DoesDatFileNeedRebuilding (
  300. VOID
  301. );
  302. INT
  303. HwComp_GetProgressMax (
  304. VOID
  305. );
  306. LONG
  307. HwComp_PrepareReport (
  308. VOID
  309. );
  310. //
  311. // PNPREPT encoding and decoding routines
  312. //
  313. #define MAX_INF_DESCRIPTION 512
  314. #define MAX_PNPID_LENGTH 256
  315. #define MAX_ENCODED_PNPID_LENGTH (MAX_PNPID_LENGTH*2)
  316. VOID
  317. EncodePnpId (
  318. IN OUT PSTR Id
  319. );
  320. VOID
  321. DecodePnpId (
  322. IN OUT PSTR Id
  323. );
  324. #define REGULAR_OUTPUT 0
  325. #define VERBOSE_OUTPUT 1
  326. #define PNPREPT_OUTPUT 2
  327. BOOL
  328. HwComp_DialUpAdapterFound (
  329. VOID
  330. );
  331. BOOL
  332. HwComp_NtUsableHardDriveExists (
  333. VOID
  334. );
  335. BOOL
  336. HwComp_NtUsableCdRomDriveExists (
  337. VOID
  338. );
  339. BOOL
  340. HwComp_MakeLocalSourceDeviceExists (
  341. VOID
  342. );
  343. BOOL
  344. HwComp_ReportIncompatibleController (
  345. VOID
  346. );
  347. BOOL
  348. ScanPathForDrivers (
  349. IN HWND CopyDlgParent, OPTIONAL
  350. IN PCTSTR SourceInfDir,
  351. IN PCTSTR TempDir,
  352. IN HANDLE CancelEvent OPTIONAL
  353. );
  354. #define WMX_BEGIN_FILE_COPY (WM_APP+100)
  355. typedef struct {
  356. //
  357. // Enumeration return member
  358. //
  359. PBYTE Resource;
  360. DWORD Type;
  361. PBYTE ResourceData;
  362. //
  363. // Internal enumeration member (do not modify)
  364. //
  365. PBYTE Resources;
  366. PBYTE NextResource;
  367. } DEVNODERESOURCE_ENUM, *PDEVNODERESOURCE_ENUM;
  368. PBYTE
  369. GetDevNodeResources (
  370. IN PCTSTR RegKey
  371. );
  372. VOID
  373. FreeDevNodeResources (
  374. IN PBYTE ResourceData
  375. );
  376. BOOL
  377. EnumFirstDevNodeResourceEx (
  378. OUT PDEVNODERESOURCE_ENUM EnumPtr,
  379. IN PBYTE DevNodeResources
  380. );
  381. BOOL
  382. EnumNextDevNodeResourceEx (
  383. IN OUT PDEVNODERESOURCE_ENUM EnumPtr
  384. );
  385. BOOL
  386. EnumFirstDevNodeResource (
  387. OUT PDEVNODERESOURCE_ENUM EnumPtr,
  388. IN PCTSTR DevNode
  389. );
  390. BOOL
  391. EnumNextDevNodeResource (
  392. IN OUT PDEVNODERESOURCE_ENUM EnumPtr
  393. );
  394. #define MAX_RESOURCE_NAME 64
  395. #define MAX_RESOURCE_VALUE 128
  396. typedef struct {
  397. //
  398. // Enumeration output
  399. //
  400. TCHAR ResourceName[MAX_RESOURCE_NAME];
  401. TCHAR Value[MAX_RESOURCE_VALUE];
  402. //
  403. // Internal state
  404. //
  405. DEVNODERESOURCE_ENUM Enum;
  406. } DEVNODESTRING_ENUM, *PDEVNODESTRING_ENUM;
  407. BOOL
  408. EnumFirstDevNodeString (
  409. OUT PDEVNODESTRING_ENUM EnumPtr,
  410. IN PCTSTR DevNodeKeyStr
  411. );
  412. BOOL
  413. EnumNextDevNodeString (
  414. IN OUT PDEVNODESTRING_ENUM EnumPtr
  415. );
  416. #pragma pack(push,1)
  417. //
  418. // MEM_RANGE Structure for Win9x
  419. //
  420. typedef struct {
  421. DWORD MR_Align; // specifies mask for base alignment
  422. DWORD MR_nBytes; // specifies number of bytes required
  423. DWORD MR_Min; // specifies minimum address of the range
  424. DWORD MR_Max; // specifies maximum address of the range
  425. WORD MR_Flags; // specifies flags describing range (fMD flags)
  426. WORD MR_Reserved;
  427. DWORD MR_PcCardFlags;
  428. DWORD MR_MemCardAddr;
  429. } MEM_RANGE_9X, *PMEM_RANGE_9X;
  430. //
  431. // MEM_DES structure for Win9x
  432. //
  433. typedef struct {
  434. WORD MD_Count; // number of MEM_RANGE structs in MEM_RESOURCE
  435. WORD MD_Type; // size (in bytes) of MEM_RANGE (MType_Range)
  436. DWORD MD_Alloc_Base; // base memory address of range allocated
  437. DWORD MD_Alloc_End; // end of allocated range
  438. WORD MD_Flags; // flags describing allocated range (fMD flags)
  439. WORD MD_Reserved;
  440. } MEM_DES_9X, *PMEM_DES_9X;
  441. //
  442. // MEM_RESOURCE structure for Win9x
  443. //
  444. typedef struct {
  445. MEM_DES_9X MEM_Header; // info about memory range list
  446. MEM_RANGE_9X MEM_Data[ANYSIZE_ARRAY]; // list of memory ranges
  447. } MEM_RESOURCE_9X, *PMEM_RESOURCE_9X;
  448. //
  449. // IO_RANGE structure for Win9x
  450. //
  451. typedef struct {
  452. WORD IOR_Align; // mask for base alignment
  453. WORD IOR_nPorts; // number of ports
  454. WORD IOR_Min; // minimum port address
  455. WORD IOR_Max; // maximum port address
  456. WORD IOR_RangeFlags; // flags for this port range
  457. BYTE IOR_Alias; // multiplier that generates aliases for port(s)
  458. BYTE IOR_Decode;
  459. DWORD PcCardFlags;
  460. } IO_RANGE_9X, *PIO_RANGE_9X;
  461. //
  462. // IO_DES structure for Win9x
  463. //
  464. typedef struct {
  465. WORD IOD_Count; // number of IO_RANGE structs in IO_RESOURCE
  466. WORD IOD_Type; // size (in bytes) of IO_RANGE (IOType_Range)
  467. WORD IOD_Alloc_Base; // base of allocated port range
  468. WORD IOD_Alloc_End; // end of allocated port range
  469. WORD IOD_DesFlags; // flags relating to allocated port range
  470. BYTE IOD_Alloc_Alias;
  471. BYTE IOD_Alloc_Decode;
  472. } IO_DES_9X, *PIO_DES_9X;
  473. //
  474. // IO_RESOURCE for Win9x
  475. //
  476. typedef struct {
  477. IO_DES_9X IO_Header; // info about I/O port range list
  478. IO_RANGE_9X IO_Data[ANYSIZE_ARRAY]; // list of I/O port ranges
  479. } IO_RESOURCE_9X, *PIO_RESOURCE_9X;
  480. //
  481. // DMA_RESOURCE for Win9x
  482. //
  483. typedef struct {
  484. WORD DMA_Unknown;
  485. WORD DMA_Bits;
  486. } DMA_RESOURCE_9X, *PDMA_RESOURCE_9X;
  487. #define DMA_CHANNEL_0 0x0001
  488. #define DMA_CHANNEL_1 0x0002
  489. #define DMA_CHANNEL_2 0x0004
  490. #define DMA_CHANNEL_3 0x0008
  491. //
  492. // IRQ_RESOURCE for Win9x
  493. //
  494. typedef struct {
  495. WORD Flags;
  496. WORD AllocNum;
  497. WORD ReqMask;
  498. WORD Reserved;
  499. DWORD PcCardFlags;
  500. } IRQ_RESOURCE_9X, *PIRQ_RESOURCE_9X;
  501. #pragma pack(pop)
  502. BOOL
  503. EjectDriverMedia (
  504. IN PCSTR IgnoreMediaOnDrive OPTIONAL
  505. );
  506. BOOL
  507. IsComputerOffline (
  508. VOID
  509. );
  510. BOOL
  511. HwComp_AnyNeededDrivers (
  512. VOID
  513. );
  514. BOOL
  515. AppendDynamicSuppliedDrivers (
  516. IN PCTSTR DriversPath
  517. );