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.

823 lines
26 KiB

  1. /*++
  2. Copyright (c) 1993-2000 Microsoft Corporation
  3. Module Name:
  4. infload.h
  5. Abstract:
  6. Private header file for internal inf routines.
  7. Author:
  8. Ted Miller (tedm) 19-Jan-1995
  9. Revision History:
  10. Gabe Schaffer (t-gabes) 19-Jul-1998
  11. Added LogContext to LOADED_INF
  12. --*/
  13. //
  14. // Define maximum string sizes allowed in INFs.
  15. //
  16. #define MAX_STRING_LENGTH 511 // this is the maximum size of an unsubstituted string
  17. #define MAX_SECT_NAME_LEN 255
  18. #if MAX_SECT_NAME_LEN > MAX_STRING_LENGTH
  19. #error MAX_SECT_NAME_LEN is too large!
  20. #endif
  21. #define MAX_LOGCONFKEYSTR_LEN 15
  22. #include "pshpack1.h"
  23. //
  24. // Make absolutely sure that these structures are DWORD aligned
  25. // because we turn alignment off, to make sure sdtructures are
  26. // packed as tightly as possible into memory blocks.
  27. //
  28. //
  29. // Internal representation of a section in an inf file
  30. //
  31. typedef struct _INF_LINE {
  32. //
  33. // Number of values on the line
  34. // This includes the key if Flags has INF_LINE_HASKEY
  35. // (In that case the first two entries in the Values array
  36. // contain the key--the first one in case-insensitive form used
  37. // for lookup, and the second in case-sensitive form for display.
  38. // INF lines with a single value (no key) are treated the same way.)
  39. // Otherwise the first entry in the Values array is the first
  40. // value on the line
  41. //
  42. WORD ValueCount;
  43. WORD Flags;
  44. //
  45. // String IDs for the values on the line.
  46. // The values are stored in the value block,
  47. // one after another.
  48. //
  49. // The value is the offset within the value block as opposed to
  50. // an actual pointer. We do this because the value block gets
  51. // reallocated as the inf file is loaded.
  52. //
  53. UINT Values;
  54. } INF_LINE, *PINF_LINE;
  55. //
  56. // INF_LINE.Flags
  57. //
  58. #define INF_LINE_HASKEY 0x0000001
  59. #define INF_LINE_SEARCHABLE 0x0000002
  60. #define HASKEY(Line) ((Line)->Flags & INF_LINE_HASKEY)
  61. #define ISSEARCHABLE(Line) ((Line)->Flags & INF_LINE_SEARCHABLE)
  62. //
  63. // INF section
  64. // This guy is kept separate and has a pointer to the actual data
  65. // to make sorting the sections a little easier
  66. //
  67. typedef struct _INF_SECTION {
  68. //
  69. // String Table ID of the name of the section
  70. //
  71. LONG SectionName;
  72. //
  73. // Number of lines in this section
  74. //
  75. DWORD LineCount;
  76. //
  77. // The section's lines. The line structures are stored packed
  78. // in the line block, one after another.
  79. //
  80. // The value is the offset within the line block as opposed to
  81. // an actual pointer. We do it this way because the line block
  82. // gets reallocated as the inf file is loaded.
  83. //
  84. UINT Lines;
  85. } INF_SECTION, *PINF_SECTION;
  86. //
  87. // Params for section enumeration
  88. //
  89. typedef struct {
  90. PTSTR Buffer;
  91. UINT Size;
  92. UINT SizeNeeded;
  93. PTSTR End;
  94. } SECTION_ENUM_PARAMS, *PSECTION_ENUM_PARAMS;
  95. #include "poppack.h"
  96. //
  97. // Define structures for user-defined DIRID storage.
  98. //
  99. typedef struct _USERDIRID {
  100. UINT Id;
  101. TCHAR Directory[MAX_PATH];
  102. } USERDIRID, *PUSERDIRID;
  103. typedef struct _USERDIRID_LIST {
  104. PUSERDIRID UserDirIds; // may be NULL
  105. UINT UserDirIdCount;
  106. } USERDIRID_LIST, *PUSERDIRID_LIST;
  107. typedef struct _STRINGSUBST_NODE {
  108. UINT ValueOffset;
  109. LONG TemplateStringId;
  110. BOOL CaseSensitive;
  111. } STRINGSUBST_NODE, *PSTRINGSUBST_NODE;
  112. //
  113. // Any system DIRID (i.e., >0x8000) that has bit 0x4000 set is a 'volatile'
  114. // DIRID (these DIRIDs are volatile in the sense that, while they're not in the
  115. // user-definable range, they're treated as if they were, and string replacement
  116. // is done on-the-fly each time the PNF is loaded. The shell special folders
  117. // (CSIDL_* defines in sdk\inc\shlobj.h), for example, are in this range. In
  118. // the case of shell special folders, the actual CSIDL value (i.e., as is
  119. // passed into SHGetSpecialFolderPath) can be obtained by simply masking out
  120. // the volatile DIRID bit.
  121. //
  122. // Define the bitmask used to determine whether a system DIRID is volatile.
  123. //
  124. #define VOLATILE_DIRID_FLAG 0x4000
  125. //
  126. // Version block structure that is stored (packed) in the opaque
  127. // VersionData buffer of a caller-supplied SP_INF_INFORMATION structure.
  128. //
  129. typedef struct _INF_VERSION_BLOCK {
  130. UINT NextOffset;
  131. FILETIME LastWriteTime;
  132. WORD DatumCount;
  133. WORD OffsetToData; // offset (in bytes) from beginning of Filename buffer.
  134. UINT DataSize; // DataSize and TotalSize are both byte counts.
  135. UINT TotalSize;
  136. TCHAR Filename[ANYSIZE_ARRAY];
  137. //
  138. // Data follows Filename in the buffer
  139. //
  140. } INF_VERSION_BLOCK, *PINF_VERSION_BLOCK;
  141. //
  142. // Internal version block node.
  143. //
  144. typedef struct _INF_VERSION_NODE {
  145. FILETIME LastWriteTime;
  146. UINT FilenameSize;
  147. CONST TCHAR *DataBlock;
  148. UINT DataSize;
  149. WORD DatumCount;
  150. TCHAR Filename[MAX_PATH];
  151. } INF_VERSION_NODE, *PINF_VERSION_NODE;
  152. //
  153. // Internal representation of an inf file.
  154. //
  155. typedef struct _LOADED_INF {
  156. DWORD Signature;
  157. //
  158. // The following 3 fields are used for precompiled INFs (PNF).
  159. // If FileHandle is not INVALID_HANDLE_VALUE, then this is a PNF,
  160. // and the MappingHandle and ViewAddress fields are also valid.
  161. // Otherwise, this is a plain old in-memory INF.
  162. //
  163. HANDLE FileHandle;
  164. HANDLE MappingHandle;
  165. PVOID ViewAddress;
  166. PVOID StringTable;
  167. DWORD SectionCount;
  168. PINF_SECTION SectionBlock;
  169. PINF_LINE LineBlock;
  170. PLONG ValueBlock;
  171. INF_VERSION_NODE VersionBlock;
  172. BOOL HasStrings;
  173. //
  174. // If this INF contains any DIRID references to the system partition, then
  175. // store the OsLoader path that was used when compiling this INF here. (This
  176. // value will always be correct when the INF is loaded. However, if drive letters
  177. // are subsequently reassigned, then it will be incorrect until the INF is unloaded
  178. // and re-loaded.)
  179. //
  180. PCTSTR OsLoaderPath; // may be NULL
  181. //
  182. // Remember the location where this INF originally came from (may be a directory
  183. // path or a URL).
  184. //
  185. DWORD InfSourceMediaType; // SPOST_PATH or SPOST_URL
  186. PCTSTR InfSourcePath; // may be NULL
  187. //
  188. // Remember the INF's original filename, before it was installed into
  189. // %windir%\Inf (i.e., automatically via device installation or explicitly
  190. // via SetupCopyOEMInf).
  191. //
  192. PCTSTR OriginalInfName; // may be NULL
  193. //
  194. // Maintain a list of value offsets that require string substitution at
  195. // run-time.
  196. //
  197. PSTRINGSUBST_NODE SubstValueList; // may be NULL
  198. WORD SubstValueCount;
  199. //
  200. // Place the style WORD here (immediately following another WORD field),
  201. // to fill a single DWORD.
  202. //
  203. WORD Style; // INF_STYLE_OLDNT, INF_STYLE_WIN4
  204. //
  205. // Sizes in bytes of various buffers
  206. //
  207. UINT SectionBlockSizeBytes;
  208. UINT LineBlockSizeBytes;
  209. UINT ValueBlockSizeBytes;
  210. //
  211. // Track what language was used when loading this INF.
  212. //
  213. DWORD LanguageId;
  214. //
  215. // Embedded structure containing information about the current user-defined
  216. // DIRID values.
  217. //
  218. USERDIRID_LIST UserDirIdList;
  219. //
  220. // Synchronization.
  221. //
  222. MYLOCK Lock;
  223. //
  224. // Log context for error logging
  225. //
  226. PSETUP_LOG_CONTEXT LogContext;
  227. //
  228. // Other flags
  229. //
  230. DWORD Flags;
  231. //
  232. // INFs are append-loaded via a doubly-linked list of LOADED_INFs.
  233. // (list is not circular--Prev of head is NULL, Next of tail is NULL)
  234. //
  235. struct _LOADED_INF *Prev;
  236. struct _LOADED_INF *Next;
  237. } LOADED_INF, *PLOADED_INF;
  238. #define LOADED_INF_SIG 0x24666e49 // Inf$
  239. #define LockInf(Inf) BeginSynchronizedAccess(&(Inf)->Lock)
  240. #define UnlockInf(Inf) EndSynchronizedAccess(&(Inf)->Lock)
  241. //
  242. // Define values for LOADED_INF.Flags field
  243. //
  244. //
  245. // WARNING: The LIF_INF_DIGITALLY_SIGNED flag does not guarantee that the INF
  246. // is currently digitally signed. When creating the PNF we verify that the INF
  247. // is correctly digitally signed and then set this bit in the PNF. Currently we
  248. // only use this flag to determine whether we should use the DriverVer date
  249. // or not.
  250. //
  251. #define LIF_HAS_VOLATILE_DIRIDS (0x00000001)
  252. #define LIF_INF_DIGITALLY_SIGNED (0x00000002)
  253. #define LIF_OEM_F6_INF (0x00000004)
  254. #define LIF_INF_AUTHENTICODE_SIGNED (0x00000008)
  255. //
  256. // Helper define
  257. //
  258. #define INF_STYLE_ALL (INF_STYLE_WIN4 | INF_STYLE_OLDNT)
  259. //
  260. // Define file header structure for precompiled INF (.PNF).
  261. //
  262. typedef struct _PNF_HEADER {
  263. WORD Version; // HiByte - Major Ver#, LoByte - Minor Ver#
  264. WORD InfStyle;
  265. DWORD Flags;
  266. DWORD InfSubstValueListOffset;
  267. WORD InfSubstValueCount;
  268. WORD InfVersionDatumCount;
  269. DWORD InfVersionDataSize;
  270. DWORD InfVersionDataOffset;
  271. FILETIME InfVersionLastWriteTime;
  272. DWORD StringTableBlockOffset;
  273. DWORD StringTableBlockSize;
  274. DWORD InfSectionCount;
  275. DWORD InfSectionBlockOffset;
  276. DWORD InfSectionBlockSize;
  277. DWORD InfLineBlockOffset;
  278. DWORD InfLineBlockSize;
  279. DWORD InfValueBlockOffset;
  280. DWORD InfValueBlockSize;
  281. DWORD WinDirPathOffset;
  282. DWORD OsLoaderPathOffset;
  283. WORD StringTableHashBucketCount;
  284. WORD LanguageId;
  285. DWORD InfSourcePathOffset; // may be 0
  286. DWORD OriginalInfNameOffset; // may be 0
  287. } PNF_HEADER, *PPNF_HEADER;
  288. //
  289. // Define Major and Minor versions of the PNF format (currently 1.1)
  290. //
  291. #define PNF_MAJOR_VERSION (0x01)
  292. #define PNF_MINOR_VERSION (0x01)
  293. //
  294. // Define flag values for the PNF header's Flags field.
  295. //
  296. // WARNING: The PNF_FLAG_INF_DIGITALLY_SIGNED flag does not guarantee that the INF
  297. // is currently digitally signed. When creating the PNF we verify that the INF
  298. // is correctly digitally signed and then set this bit in the PNF. Currently we
  299. // only use this flag to determine whether we should use the DriverVer date
  300. // or not.
  301. #define PNF_FLAG_IS_UNICODE (0x00000001)
  302. #define PNF_FLAG_HAS_STRINGS (0x00000002)
  303. #define PNF_FLAG_SRCPATH_IS_URL (0x00000004)
  304. #define PNF_FLAG_HAS_VOLATILE_DIRIDS (0x00000008)
  305. #define PNF_FLAG_RESERVED1 (0x00000010) // was PNF_FLAG_INF_VERIFIED for Win2k
  306. #define PNF_FLAG_INF_DIGITALLY_SIGNED (0x00000020)
  307. #define PNF_FLAG_OEM_F6_INF (0x00000040)
  308. #define PNF_FLAG_16BIT_SUITE (0x00000080) // if set, lower 16 bits of suite
  309. // is in upper 16 bits of flags
  310. #define PNF_FLAG_INF_VERIFIED (0x00000100)
  311. #define PNF_FLAG_INF_AUTHENTICODE_SIGNED (0x00000200)
  312. //
  313. // Public inf functions in infload.c. All other routines are private to
  314. // the inf handler package.
  315. //
  316. DWORD
  317. DetermineInfStyle(
  318. IN PCTSTR Filename,
  319. IN LPWIN32_FIND_DATA FindData
  320. );
  321. //
  322. // Flags for LoadInfFile.
  323. //
  324. #define LDINF_FLAG_MATCH_CLASS_GUID (0x00000001)
  325. #define LDINF_FLAG_ALWAYS_TRY_PNF (0x00000002)
  326. #define LDINF_FLAG_IGNORE_VOLATILE_DIRIDS (0x00000004) // includes system partition
  327. #define LDINF_FLAG_IGNORE_LANGUAGE (0x00000008)
  328. #define LDINF_FLAG_REGENERATE_PNF (0x00000010)
  329. #define LDINF_FLAG_SRCPATH_IS_URL (0x00000020)
  330. #define LDINF_FLAG_ALWAYS_GET_SRCPATH (0x00000040) // used to work around TZ change in FAT
  331. #define LDINF_FLAG_OEM_F6_INF (0x00000080)
  332. #define LDINF_FLAG_ALLOW_PNF_SHARING_LOCK (0x00000100) // don't fail if PNF locked
  333. #define LDINF_FLAG_ALWAYS_IGNORE_PNF (0x00000200) // don't look at PNF
  334. DWORD
  335. LoadInfFile(
  336. IN PCTSTR Filename,
  337. IN LPWIN32_FIND_DATA FileData,
  338. IN DWORD Style,
  339. IN DWORD Flags,
  340. IN PCTSTR ClassGuidString, OPTIONAL
  341. IN PCTSTR InfSourcePath, OPTIONAL
  342. IN PCTSTR OriginalInfName, OPTIONAL
  343. IN PLOADED_INF AppendInf, OPTIONAL
  344. IN PSETUP_LOG_CONTEXT LogContext, OPTIONAL
  345. OUT PLOADED_INF *LoadedInf,
  346. OUT UINT *ErrorLineNumber,
  347. OUT BOOL *PnfWasUsed OPTIONAL
  348. );
  349. VOID
  350. FreeInfFile(
  351. IN PLOADED_INF LoadedInf
  352. );
  353. //
  354. // Global strings used throughout the inf loaders/runtime stuff. Sizes are
  355. // included so that we can do sizeof() instead of lstrlen() to determine string
  356. // length.
  357. //
  358. // The content of the following strings is defined in infstr.h:
  359. //
  360. extern CONST TCHAR pszSignature[SIZECHARS(INFSTR_KEY_SIGNATURE)],
  361. pszVersion[SIZECHARS(INFSTR_SECT_VERSION)],
  362. pszClass[SIZECHARS(INFSTR_KEY_HARDWARE_CLASS)],
  363. pszClassGuid[SIZECHARS(INFSTR_KEY_HARDWARE_CLASSGUID)],
  364. pszProvider[SIZECHARS(INFSTR_KEY_PROVIDER)],
  365. pszStrings[SIZECHARS(SZ_KEY_STRINGS)],
  366. pszLayoutFile[SIZECHARS(SZ_KEY_LAYOUT_FILE)],
  367. pszManufacturer[SIZECHARS(INFSTR_SECT_MFG)],
  368. pszControlFlags[SIZECHARS(INFSTR_CONTROLFLAGS_SECTION)],
  369. pszSourceDisksNames[SIZECHARS(SZ_KEY_SRCDISKNAMES)],
  370. pszSourceDisksFiles[SIZECHARS(SZ_KEY_SRCDISKFILES)],
  371. pszDestinationDirs[SIZECHARS(SZ_KEY_DESTDIRS)],
  372. pszDefaultDestDir[SIZECHARS(SZ_KEY_DEFDESTDIR)],
  373. pszReboot[SIZECHARS(INFSTR_REBOOT)],
  374. pszRestart[SIZECHARS(INFSTR_RESTART)],
  375. pszClassInstall32[SIZECHARS(INFSTR_SECT_CLASS_INSTALL_32)],
  376. pszAddInterface[SIZECHARS(SZ_KEY_ADDINTERFACE)],
  377. pszInterfaceInstall32[SIZECHARS(INFSTR_SECT_INTERFACE_INSTALL_32)],
  378. pszAddService[SIZECHARS(SZ_KEY_ADDSERVICE)],
  379. pszDelService[SIZECHARS(SZ_KEY_DELSERVICE)],
  380. pszCatalogFile[SIZECHARS(INFSTR_KEY_CATALOGFILE)],
  381. pszMemConfig[SIZECHARS(INFSTR_KEY_MEMCONFIG)],
  382. pszIOConfig[SIZECHARS(INFSTR_KEY_IOCONFIG)],
  383. pszIRQConfig[SIZECHARS(INFSTR_KEY_IRQCONFIG)],
  384. pszDMAConfig[SIZECHARS(INFSTR_KEY_DMACONFIG)],
  385. pszPcCardConfig[SIZECHARS(INFSTR_KEY_PCCARDCONFIG)],
  386. pszMfCardConfig[SIZECHARS(INFSTR_KEY_MFCARDCONFIG)],
  387. pszConfigPriority[SIZECHARS(INFSTR_KEY_CONFIGPRIORITY)],
  388. pszDriverVer[SIZECHARS(INFSTR_DRIVERVERSION_SECTION)];
  389. //
  390. // Other misc. global strings:
  391. //
  392. #define DISTR_INF_DRVDESCFMT (TEXT("%s.") INFSTR_STRKEY_DRVDESC)
  393. #define DISTR_INF_HWSECTIONFMT (TEXT("%s.") INFSTR_SUBKEY_HW)
  394. #define DISTR_INF_CHICAGOSIG (TEXT("$Chicago$"))
  395. #define DISTR_INF_WINNTSIG (TEXT("$Windows NT$"))
  396. #define DISTR_INF_WIN95SIG (TEXT("$Windows 95$"))
  397. #define DISTR_INF_WIN_SUFFIX (TEXT(".") INFSTR_PLATFORM_WIN)
  398. #define DISTR_INF_NT_SUFFIX (TEXT(".") INFSTR_PLATFORM_NT)
  399. #define DISTR_INF_PNF_SUFFIX (TEXT(".PNF"))
  400. #define DISTR_INF_INF_SUFFIX (TEXT(".INF"))
  401. #define DISTR_INF_CAT_SUFFIX (TEXT(".CAT"))
  402. #define DISTR_INF_SERVICES_SUFFIX (TEXT(".") INFSTR_SUBKEY_SERVICES)
  403. #define DISTR_INF_INTERFACES_SUFFIX (TEXT(".") INFSTR_SUBKEY_INTERFACES)
  404. #define DISTR_INF_COINSTALLERS_SUFFIX (TEXT(".") INFSTR_SUBKEY_COINSTALLERS)
  405. #define DISTR_INF_LOGCONFIGOVERRIDE_SUFFIX (TEXT(".") INFSTR_SUBKEY_LOGCONFIGOVERRIDE)
  406. #define DISTR_INF_WMI_SUFFIX (TEXT(".") INFSTR_SUBKEY_WMI)
  407. //
  408. // Define all platform-specific suffix strings for which we support non-native
  409. // digital signature verification...
  410. //
  411. #define DISTR_INF_NTALPHA_SUFFIX (TEXT(".") INFSTR_PLATFORM_NTALPHA)
  412. #define DISTR_INF_NTX86_SUFFIX (TEXT(".") INFSTR_PLATFORM_NTX86)
  413. #define DISTR_INF_NTIA64_SUFFIX (TEXT(".") INFSTR_PLATFORM_NTIA64)
  414. #define DISTR_INF_NTAXP64_SUFFIX (TEXT(".") INFSTR_PLATFORM_NTAXP64)
  415. #define DISTR_INF_NTAMD64_SUFFIX (TEXT(".") INFSTR_PLATFORM_NTAMD64)
  416. //
  417. // Define platform decoration strings for use on [SourceDisksNames] and
  418. // [SourceDisksFiles] sections.
  419. //
  420. #define DISTR_INF_SRCDISK_SUFFIX_ALPHA (TEXT("Alpha"))
  421. #define DISTR_INF_SRCDISK_SUFFIX_X86 (TEXT("x86"))
  422. #define DISTR_INF_SRCDISK_SUFFIX_IA64 (TEXT("ia64"))
  423. #define DISTR_INF_SRCDISK_SUFFIX_AXP64 (TEXT("axp64"))
  424. #define DISTR_INF_SRCDISK_SUFFIX_AMD64 (TEXT("amd64"))
  425. //
  426. // (Sizes are included for all strings that we define privately. This
  427. // is done so that we can do sizeof() instead of lstrlen() to determine
  428. // string length. Keep in sync with definitions in infload.c!)
  429. //
  430. extern CONST TCHAR pszDrvDescFormat[SIZECHARS(DISTR_INF_DRVDESCFMT)],
  431. pszHwSectionFormat[SIZECHARS(DISTR_INF_HWSECTIONFMT)],
  432. pszChicagoSig[SIZECHARS(DISTR_INF_CHICAGOSIG)],
  433. pszWindowsNTSig[SIZECHARS(DISTR_INF_WINNTSIG)],
  434. pszWindows95Sig[SIZECHARS(DISTR_INF_WIN95SIG)],
  435. pszWinSuffix[SIZECHARS(DISTR_INF_WIN_SUFFIX)],
  436. pszNtSuffix[SIZECHARS(DISTR_INF_NT_SUFFIX)],
  437. pszNtAlphaSuffix[SIZECHARS(DISTR_INF_NTALPHA_SUFFIX)],
  438. pszNtX86Suffix[SIZECHARS(DISTR_INF_NTX86_SUFFIX)],
  439. pszNtIA64Suffix[SIZECHARS(DISTR_INF_NTIA64_SUFFIX)],
  440. pszNtAXP64Suffix[SIZECHARS(DISTR_INF_NTAXP64_SUFFIX)],
  441. pszNtAMD64Suffix[SIZECHARS(DISTR_INF_NTAMD64_SUFFIX)],
  442. pszPnfSuffix[SIZECHARS(DISTR_INF_PNF_SUFFIX)],
  443. pszInfSuffix[SIZECHARS(DISTR_INF_INF_SUFFIX)],
  444. pszCatSuffix[SIZECHARS(DISTR_INF_CAT_SUFFIX)],
  445. pszServicesSectionSuffix[SIZECHARS(DISTR_INF_SERVICES_SUFFIX)],
  446. pszInterfacesSectionSuffix[SIZECHARS(DISTR_INF_INTERFACES_SUFFIX)],
  447. pszCoInstallersSectionSuffix[SIZECHARS(DISTR_INF_COINSTALLERS_SUFFIX)],
  448. pszLogConfigOverrideSectionSuffix[SIZECHARS(DISTR_INF_LOGCONFIGOVERRIDE_SUFFIX)],
  449. pszWmiSectionSuffix[SIZECHARS(DISTR_INF_WMI_SUFFIX)],
  450. pszAlphaSrcDiskSuffix[SIZECHARS(DISTR_INF_SRCDISK_SUFFIX_ALPHA)],
  451. pszX86SrcDiskSuffix[SIZECHARS(DISTR_INF_SRCDISK_SUFFIX_X86)],
  452. pszIa64SrcDiskSuffix[SIZECHARS(DISTR_INF_SRCDISK_SUFFIX_IA64)],
  453. pszAxp64SrcDiskSuffix[SIZECHARS(DISTR_INF_SRCDISK_SUFFIX_AXP64)],
  454. pszAmd64SrcDiskSuffix[SIZECHARS(DISTR_INF_SRCDISK_SUFFIX_AMD64)];
  455. //
  456. // Define constants that equate to native architecture suffixes...
  457. //
  458. #if defined(_ALPHA_)
  459. #define pszNtPlatformSuffix pszNtAlphaSuffix
  460. #define pszPlatformSrcDiskSuffix pszAlphaSrcDiskSuffix
  461. #elif defined(_X86_)
  462. #define pszNtPlatformSuffix pszNtX86Suffix
  463. #define pszPlatformSrcDiskSuffix pszX86SrcDiskSuffix
  464. #elif defined(_IA64_)
  465. #define pszNtPlatformSuffix pszNtIA64Suffix
  466. #define pszPlatformSrcDiskSuffix pszIa64SrcDiskSuffix
  467. #elif defined(_AXP64_)
  468. #define pszNtPlatformSuffix pszNtAXP64Suffix
  469. #define pszPlatformSrcDiskSuffix pszAxp64SrcDiskSuffix
  470. #elif defined(_AMD64_)
  471. #define pszNtPlatformSuffix pszNtAMD64Suffix
  472. #define pszPlatformSrcDiskSuffix pszAmd64SrcDiskSuffix
  473. #else
  474. #error Unknown processor type
  475. #endif
  476. //
  477. // for now, platform name is same as pszPlatformSrcDiskSuffix (Alpha, x86, ia64, axp64, amd64)
  478. //
  479. #define pszPlatformName pszPlatformSrcDiskSuffix
  480. //
  481. // Define a (non-CONST) array of strings that specifies what lines to look for
  482. // in an INF's [ControlFlags] section when determining whether a particular device
  483. // ID should be excluded. This is filled in during process attach for speed
  484. // reasons.
  485. //
  486. // The max string length (including NULL) is 32, and there can be a maximum of 3
  487. // such strings. E.g.: ExcludeFromSelect, ExcludeFromSelect.NT, ExcludeFromSelect.NTAlpha
  488. //
  489. extern TCHAR pszExcludeFromSelectList[3][32];
  490. extern DWORD ExcludeFromSelectListUb; // contains the number of strings in the above list (2 or 3).
  491. //
  492. // Routine to determine whether a character is whitespace.
  493. //
  494. BOOL
  495. IsWhitespace(
  496. IN PCTSTR pc
  497. );
  498. //
  499. // Routine to skip whitespace (but not newlines)
  500. //
  501. VOID
  502. SkipWhitespace(
  503. IN OUT PCTSTR *Location,
  504. IN PCTSTR BufferEnd
  505. );
  506. PINF_SECTION
  507. InfLocateSection(
  508. IN PLOADED_INF Inf,
  509. IN PCTSTR SectionName,
  510. OUT PUINT SectionNumber OPTIONAL
  511. );
  512. BOOL
  513. InfLocateLine(
  514. IN PLOADED_INF Inf,
  515. IN PINF_SECTION Section,
  516. IN PCTSTR Key, OPTIONAL
  517. IN OUT PUINT LineNumber,
  518. OUT PINF_LINE *Line
  519. );
  520. PTSTR
  521. InfGetKeyOrValue(
  522. IN PLOADED_INF Inf,
  523. IN PCTSTR SectionName,
  524. IN PCTSTR LineKey, OPTIONAL
  525. IN UINT LineNumber, OPTIONAL
  526. IN UINT ValueNumber,
  527. OUT PLONG StringId OPTIONAL
  528. );
  529. PTSTR
  530. InfGetField(
  531. IN PLOADED_INF Inf,
  532. IN PINF_LINE InfLine,
  533. IN UINT ValueNumber,
  534. OUT PLONG StringId OPTIONAL
  535. );
  536. PINF_LINE
  537. InfLineFromContext(
  538. IN PINFCONTEXT Context
  539. );
  540. //
  541. // Define a macro to retrieve the case-insensitive (i.e., searchable) string ID
  542. // for an INF line's key, or -1 if there is no key.
  543. // NOTE: INF lock must have been acquired before calling this macro!
  544. //
  545. // LONG
  546. // pInfGetLineKeyId(
  547. // IN PLOADED_INF Inf,
  548. // IN PINF_LINE InfLine
  549. // )
  550. //
  551. #define pInfGetLineKeyId(Inf,InfLine) (ISSEARCHABLE(InfLine) ? (Inf)->ValueBlock[(InfLine)->Values] : -1)
  552. //
  553. // Routine to allocate and initialize a loaded inf descriptor.
  554. //
  555. PLOADED_INF
  556. AllocateLoadedInfDescriptor(
  557. IN DWORD SectionBlockSize,
  558. IN DWORD LineBlockSize,
  559. IN DWORD ValueBlockSize,
  560. IN PSETUP_LOG_CONTEXT LogContext OPTIONAL
  561. );
  562. VOID
  563. FreeInfOrPnfStructures(
  564. IN PLOADED_INF Inf
  565. );
  566. //
  567. // Define a macro to free all memory blocks associated with a loaded INF or PNF,
  568. // and then free the memory for the loaded INF structure itself
  569. //
  570. // VOID
  571. // FreeLoadedInfDescriptor(
  572. // IN PLOADED_INF Inf
  573. // );
  574. //
  575. #define FreeLoadedInfDescriptor(Inf) { \
  576. FreeInfOrPnfStructures(Inf); \
  577. MyTaggedFree(Inf,MEMTAG_INF); \
  578. }
  579. BOOL
  580. AddDatumToVersionBlock(
  581. IN OUT PINF_VERSION_NODE VersionNode,
  582. IN PCTSTR DatumName,
  583. IN PCTSTR DatumValue
  584. );
  585. //
  586. // Old inf manipulation routines, called by new inf loader
  587. //
  588. DWORD
  589. ParseOldInf(
  590. IN PCTSTR FileImage,
  591. IN DWORD FileImageSize,
  592. IN PSETUP_LOG_CONTEXT LogContext, OPTIONAL
  593. OUT PLOADED_INF *Inf,
  594. OUT UINT *ErrorLineNumber
  595. );
  596. DWORD
  597. ProcessOldInfVersionBlock(
  598. IN PLOADED_INF Inf
  599. );
  600. //
  601. // Run-time helper routines.
  602. //
  603. PCTSTR
  604. pSetupFilenameFromLine(
  605. IN PINFCONTEXT Context,
  606. IN BOOL GetSourceName
  607. );
  608. //
  609. // Logical configuration stuff, inflogcf.c
  610. //
  611. DWORD
  612. pSetupInstallLogConfig(
  613. IN HINF Inf,
  614. IN PCTSTR SectionName,
  615. IN DEVINST DevInst,
  616. IN DWORD Flags,
  617. IN HMACHINE hMachine
  618. );
  619. //
  620. // INF Version information retrieval
  621. //
  622. PCTSTR
  623. pSetupGetVersionDatum(
  624. IN PINF_VERSION_NODE VersionNode,
  625. IN PCTSTR DatumName
  626. );
  627. BOOL
  628. pSetupGetCatalogFileValue(
  629. IN PINF_VERSION_NODE InfVersionNode,
  630. OUT LPTSTR Buffer,
  631. IN DWORD BufferSize,
  632. IN PSP_ALTPLATFORM_INFO_V2 AltPlatformInfo OPTIONAL
  633. );
  634. VOID
  635. pSetupGetPhysicalInfFilepath(
  636. IN PINFCONTEXT LineContext,
  637. OUT LPTSTR Buffer,
  638. IN DWORD BufferSize
  639. );
  640. //
  641. // Private installation routines.
  642. //
  643. //
  644. // Private Flags & context for _SetupInstallFromInfSection.
  645. // passed onto pSetupInstallRegistry
  646. //
  647. typedef struct _REGMOD_CONTEXT {
  648. DWORD Flags; // indicates what fields are filled in
  649. HKEY UserRootKey; // HKR
  650. LPGUID ClassGuid; // INF_PFLAG_CLASSPROP
  651. HMACHINE hMachine; // INF_PFLAG_CLASSPROP
  652. DWORD DevInst; // INF_PFLAG_DEVPROP
  653. } REGMOD_CONTEXT, *PREGMOD_CONTEXT;
  654. #define INF_PFLAG_CLASSPROP (0x00000001) // set if called for a ClassInstall32 section
  655. #define INF_PFLAG_DEVPROP (0x00000002) // set if called for registry properties
  656. #define INF_PFLAG_HKR (0x00000004) // indicates override _SetupInstallFromInfSection RelativeKeyRoot
  657. BOOL
  658. _SetupInstallFromInfSection(
  659. IN HWND Owner, OPTIONAL
  660. IN HINF InfHandle,
  661. IN PCTSTR SectionName,
  662. IN UINT Flags,
  663. IN HKEY RelativeKeyRoot, OPTIONAL
  664. IN PCTSTR SourceRootPath, OPTIONAL
  665. IN UINT CopyFlags,
  666. IN PVOID MsgHandler,
  667. IN PVOID Context, OPTIONAL
  668. IN HDEVINFO DeviceInfoSet, OPTIONAL
  669. IN PSP_DEVINFO_DATA DeviceInfoData, OPTIONAL
  670. IN BOOL IsMsgHandlerNativeCharWidth,
  671. IN PREGMOD_CONTEXT RegContext OPTIONAL
  672. );
  673. DWORD
  674. pSetupInstallFiles(
  675. IN HINF Inf,
  676. IN HINF LayoutInf, OPTIONAL
  677. IN PCTSTR SectionName,
  678. IN PCTSTR SourceRootPath, OPTIONAL
  679. IN PSP_FILE_CALLBACK MsgHandler, OPTIONAL
  680. IN PVOID Context, OPTIONAL
  681. IN UINT CopyStyle,
  682. IN HWND Owner, OPTIONAL
  683. IN HSPFILEQ UserFileQ, OPTIONAL
  684. IN BOOL IsMsgHandlerNativeCharWidth
  685. );
  686. DWORD
  687. pSetupInstallRegistry(
  688. IN HINF Inf,
  689. IN PCTSTR SectionName,
  690. IN PREGMOD_CONTEXT RegContext OPTIONAL
  691. );
  692. DWORD
  693. _AppendStringToMultiSz(
  694. IN PCTSTR SubKeyName, OPTIONAL
  695. IN PCTSTR ValueName, OPTIONAL
  696. IN PCTSTR String,
  697. IN BOOL AllowDuplicates,
  698. IN PREGMOD_CONTEXT RegContext, OPTIONAL
  699. IN UINT Flags OPTIONAL
  700. );
  701. DWORD
  702. _DeleteStringFromMultiSz(
  703. IN PCTSTR SubKeyName, OPTIONAL
  704. IN PCTSTR ValueName, OPTIONAL
  705. IN PCTSTR String,
  706. IN UINT Flags,
  707. IN PREGMOD_CONTEXT RegContext OPTIONAL
  708. );