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.

436 lines
9.3 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. inf.h
  5. Abstract:
  6. Declares interface for INF wrapper routines. These routines simplify
  7. access of INFs by wrapping the setup APIs with routines that use
  8. pools or grow buffers.
  9. The INF wrapper routines also implement append and replace capabilities,
  10. so any INF used by the Win9x upgrade can be appended in the future, or
  11. completely replaced.
  12. Author:
  13. Marc R. Whitten (marcw) 20-Oct-1997
  14. Revision History:
  15. jimschm 05-Jan-1999 INF parser moved to migutil
  16. marcw 28-Oct-1998 Append/Replace capability
  17. marcw 08-Aug-1997 Pool/Growbuf routines
  18. --*/
  19. typedef enum {
  20. INF_USE_PMHANDLE,
  21. INF_USE_GROWBUFFER,
  22. INF_USE_PRIVATE_GROWBUFFER,
  23. INF_USE_PRIVATE_PMHANDLE
  24. } ALLOCATORTYPES;
  25. typedef struct {
  26. INFCONTEXT Context;
  27. GROWBUFFER GrowBuffer;
  28. PMHANDLE PoolHandle;
  29. ALLOCATORTYPES Allocator;
  30. } INFSTRUCT, *PINFSTRUCT;
  31. #define INFCONTEXT_INIT {NULL,NULL,0,0}
  32. #define INITINFSTRUCT_GROWBUFFER {INFCONTEXT_INIT,INIT_GROWBUFFER,NULL,INF_USE_PRIVATE_GROWBUFFER}
  33. #define INITINFSTRUCT_PMHANDLE {INFCONTEXT_INIT,INIT_GROWBUFFER,NULL,INF_USE_PRIVATE_PMHANDLE}
  34. #define InfOpenAppendInfFile SetupOpenAppendInfFile
  35. VOID
  36. InfCleanUpInfStruct (
  37. PINFSTRUCT Context
  38. );
  39. VOID
  40. InitInfStruct (
  41. OUT PINFSTRUCT Context,
  42. IN PGROWBUFFER GrowBuffer, OPTIONAL
  43. IN PMHANDLE PoolHandle OPTIONAL
  44. );
  45. #define InfOpenInfFileA(f) TRACK_BEGIN(HINF, InfOpenInfFile)\
  46. RealInfOpenInfFileA((f)/*,*/ ALLOCATION_TRACKING_CALL)\
  47. TRACK_END()
  48. #define InfOpenInfFileW(f) TRACK_BEGIN(HINF, InfOpenInfFile)\
  49. RealInfOpenInfFileW((f)/*,*/ ALLOCATION_TRACKING_CALL)\
  50. TRACK_END()
  51. HINF
  52. RealInfOpenInfFileA (
  53. IN PCSTR FileName /*,*/
  54. ALLOCATION_TRACKING_DEF
  55. );
  56. HINF
  57. RealInfOpenInfFileW (
  58. IN PCWSTR FileName /*,*/
  59. ALLOCATION_TRACKING_DEF
  60. );
  61. VOID
  62. InfCloseInfFile (HINF Inf);
  63. //
  64. // See the macros below before calling InfOpenInfInAllSourcesA or W.
  65. //
  66. HINF
  67. InfOpenInfInAllSourcesA (
  68. IN PCSTR InfSpecifier,
  69. IN DWORD SourceCount,
  70. IN PCSTR * SourceDirectories
  71. );
  72. HINF
  73. InfOpenInfInAllSourcesW (
  74. IN PCWSTR InfSpecifier,
  75. IN DWORD SourceCount,
  76. IN PCWSTR *SourceDirectories
  77. );
  78. PSTR
  79. InfGetLineTextA (
  80. IN OUT PINFSTRUCT
  81. );
  82. PWSTR
  83. InfGetLineTextW (
  84. IN OUT PINFSTRUCT
  85. );
  86. PSTR
  87. InfGetStringFieldA (
  88. IN OUT PINFSTRUCT Context,
  89. IN UINT FieldIndex
  90. );
  91. PWSTR
  92. InfGetStringFieldW (
  93. IN OUT PINFSTRUCT Context,
  94. IN UINT FieldIndex
  95. );
  96. PSTR
  97. InfGetMultiSzFieldA (
  98. IN OUT PINFSTRUCT Context,
  99. IN UINT FieldIndex
  100. ) ;
  101. PWSTR
  102. InfGetMultiSzFieldW (
  103. IN OUT PINFSTRUCT Context,
  104. IN UINT FieldIndex
  105. ) ;
  106. BOOL
  107. InfGetIntField (
  108. IN PINFSTRUCT Context,
  109. IN UINT FieldIndex,
  110. IN PINT Value
  111. );
  112. PBYTE
  113. InfGetBinaryField (
  114. IN PINFSTRUCT Context,
  115. IN UINT FieldIndex
  116. );
  117. BOOL
  118. InfGetLineByIndexA(
  119. IN HINF InfHandle,
  120. IN PCSTR Section,
  121. IN DWORD Index,
  122. OUT PINFSTRUCT Context
  123. );
  124. BOOL
  125. InfGetLineByIndexW(
  126. IN HINF InfHandle,
  127. IN PCWSTR Section,
  128. IN DWORD Index,
  129. OUT PINFSTRUCT Context
  130. );
  131. BOOL
  132. InfFindFirstLineA (
  133. IN HINF InfHandle,
  134. IN PCSTR Section,
  135. IN PCSTR Key,
  136. OUT PINFSTRUCT Context
  137. );
  138. BOOL
  139. InfFindFirstLineW (
  140. IN HINF InfHandle,
  141. IN PCWSTR Section,
  142. IN PCWSTR Key,
  143. OUT PINFSTRUCT Context
  144. );
  145. BOOL
  146. InfFindNextLine (
  147. IN OUT PINFSTRUCT Context
  148. );
  149. UINT
  150. InfGetFieldCount (
  151. IN PINFSTRUCT Context
  152. );
  153. PCSTR
  154. InfGetOemStringFieldA (
  155. IN PINFSTRUCT Context,
  156. IN UINT Field
  157. );
  158. BOOL
  159. SetupGetOemStringFieldA (
  160. IN PINFCONTEXT Context,
  161. IN DWORD Index,
  162. IN PTSTR ReturnBuffer,
  163. IN DWORD ReturnBufferSize,
  164. OUT PDWORD RequiredSize
  165. );
  166. VOID
  167. InfResetInfStruct (
  168. IN OUT PINFSTRUCT Context
  169. );
  170. //
  171. // INF parser
  172. //
  173. typedef struct _tagINFLINE {
  174. PCWSTR Key; OPTIONAL
  175. PCWSTR Data;
  176. DWORD LineFlags;
  177. struct _tagINFLINE *Next, *Prev;
  178. struct _tagINFSECTION *Section;
  179. } INFLINE, *PINFLINE;
  180. #define LINEFLAG_KEY_QUOTED 0x0001
  181. #define LINEFLAG_ALL_COMMENTS 0x0002
  182. #define LINEFLAG_TRAILING_COMMENTS 0x0004
  183. typedef struct _tagINFSECTION {
  184. PCWSTR Name;
  185. PINFLINE FirstLine;
  186. PINFLINE LastLine;
  187. UINT LineCount;
  188. struct _tagINFSECTION *Next, *Prev;
  189. } INFSECTION, *PINFSECTION;
  190. PINFSECTION
  191. AddInfSectionToTableA (
  192. IN HINF Inf,
  193. IN PCSTR SectionName
  194. );
  195. PINFSECTION
  196. AddInfSectionToTableW (
  197. IN HINF Inf,
  198. IN PCWSTR SectionName
  199. );
  200. PINFSECTION
  201. FindInfSectionInTableA (
  202. IN HINF Inf,
  203. IN PCSTR SectionName
  204. );
  205. PINFSECTION
  206. GetFirstInfSectionInTable (
  207. IN HINF Inf
  208. );
  209. PINFSECTION
  210. GetNextInfSectionInTable (
  211. IN PINFSECTION Section
  212. );
  213. PINFSECTION
  214. FindInfSectionInTableW (
  215. IN HINF Inf,
  216. IN PCWSTR SectionName
  217. );
  218. PINFLINE
  219. AddInfLineToTableA (
  220. IN HINF Inf,
  221. IN PINFSECTION SectionPtr,
  222. IN PCSTR Key, OPTIONAL
  223. IN PCSTR Data,
  224. IN DWORD LineFlags
  225. );
  226. PINFLINE
  227. AddInfLineToTableW (
  228. IN HINF Inf,
  229. IN PINFSECTION SectionPtr,
  230. IN PCWSTR Key, OPTIONAL
  231. IN PCWSTR Data,
  232. IN DWORD LineFlags
  233. );
  234. PINFLINE
  235. FindLineInInfSectionA (
  236. IN HINF Inf,
  237. IN PINFSECTION Section,
  238. IN PCSTR Key
  239. );
  240. PINFLINE
  241. FindLineInInfSectionW (
  242. IN HINF Inf,
  243. IN PINFSECTION Section,
  244. IN PCWSTR Key
  245. );
  246. PINFLINE
  247. GetFirstLineInSectionStrA (
  248. IN HINF Inf,
  249. IN PCSTR Section
  250. );
  251. PINFLINE
  252. GetFirstLineInSectionStrW (
  253. IN HINF Inf,
  254. IN PCWSTR Section
  255. );
  256. PINFLINE
  257. GetFirstLineInSectionStruct (
  258. IN PINFSECTION Section
  259. );
  260. PINFLINE
  261. GetNextLineInSection (
  262. IN PINFLINE PrevLine
  263. );
  264. UINT
  265. GetInfSectionLineCount (
  266. IN PINFSECTION Section
  267. );
  268. BOOL
  269. DeleteSectionInInfFile (
  270. IN HINF Inf,
  271. IN PINFSECTION Section
  272. );
  273. BOOL
  274. DeleteLineInInfSection (
  275. IN HINF Inf,
  276. IN PINFLINE InfLine
  277. );
  278. HINF
  279. OpenInfFileExA (
  280. IN PCSTR InfFilePath,
  281. IN PSTR SectionList,
  282. IN BOOL KeepComments
  283. );
  284. #define OpenInfFileA(Path) OpenInfFileExA (Path, NULL, TRUE)
  285. HINF
  286. OpenInfFileExW (
  287. IN PCWSTR InfFilePath,
  288. IN PWSTR SectionList,
  289. IN BOOL KeepComments
  290. );
  291. #define OpenInfFileW(Path) OpenInfFileExW (Path, NULL, TRUE)
  292. VOID
  293. CloseInfFile (
  294. HINF InfFile
  295. );
  296. BOOL
  297. SaveInfFileA (
  298. IN HINF Inf,
  299. IN PCSTR SaveToFileSpec
  300. );
  301. BOOL
  302. SaveInfFileW (
  303. IN HINF Inf,
  304. IN PCWSTR SaveToFileSpec
  305. );
  306. //
  307. // ANSI/UNICODE mappings.
  308. //
  309. #ifdef UNICODE
  310. # define InfFindFirstLine InfFindFirstLineW
  311. # define InfGetLineByIndex InfGetLineByIndexW
  312. # define InfGetStringField InfGetStringFieldW
  313. # define InfGetMultiSzField InfGetMultiSzFieldW
  314. # define InfGetLineText InfGetLineTextW
  315. # define InfOpenInfFile InfOpenInfFileW
  316. # define InfGetOemStringField InfGetStringFieldW
  317. # define SetupGetOemStringField SetupGetStringFieldW
  318. # define InfOpenInfInAllSources(x) InfOpenInfInAllSourcesW((x),1,&g_SourceDirectory);
  319. # define AddInfSectionToTable AddInfSectionToTableW
  320. # define FindInfSectionInTable FindInfSectionInTableW
  321. # define AddInfLineToTable AddInfLineToTableW
  322. # define FindLineInInfSection FindLineInInfSectionW
  323. # define GetFirstLineInSectionStr GetFirstLineInSectionStrW
  324. # define OpenInfFileEx OpenInfFileExW
  325. # define OpenInfFile OpenInfFileW
  326. # define SaveInfFile SaveInfFileW
  327. #else
  328. # define InfFindFirstLine InfFindFirstLineA
  329. # define InfGetLineByIndex InfGetLineByIndexA
  330. # define InfGetStringField InfGetStringFieldA
  331. # define InfGetMultiSzField InfGetMultiSzFieldA
  332. # define InfGetLineText InfGetLineTextA
  333. # define InfOpenInfFile InfOpenInfFileA
  334. # define InfGetOemStringField InfGetOemStringFieldA
  335. # define SetupGetOemStringField SetupGetOemStringFieldA
  336. # define InfOpenInfInAllSources(x) InfOpenInfInAllSourcesA((x),g_SourceDirectoryCount,g_SourceDirectories);
  337. # define AddInfSectionToTable AddInfSectionToTableA
  338. # define FindInfSectionInTable FindInfSectionInTableA
  339. # define AddInfLineToTable AddInfLineToTableA
  340. # define FindLineInInfSection FindLineInInfSectionA
  341. # define GetFirstLineInSectionStr GetFirstLineInSectionStrA
  342. # define OpenInfFileEx OpenInfFileExA
  343. # define OpenInfFile OpenInfFileA
  344. # define SaveInfFile SaveInfFileA
  345. #endif