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.

453 lines
10 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. InfGlobalInit (
  37. IN BOOL Terminate
  38. );
  39. VOID
  40. InfCleanUpInfStruct (
  41. PINFSTRUCT Context
  42. );
  43. VOID
  44. InitInfStruct (
  45. OUT PINFSTRUCT Context,
  46. IN PGROWBUFFER GrowBuffer, OPTIONAL
  47. IN PMHANDLE PoolHandle OPTIONAL
  48. );
  49. #define InfOpenInfFileA(f) TRACK_BEGIN(HINF, InfOpenInfFile)\
  50. RealInfOpenInfFileA((f)/*,*/ ALLOCATION_TRACKING_CALL)\
  51. TRACK_END()
  52. #define InfOpenInfFileW(f) TRACK_BEGIN(HINF, InfOpenInfFile)\
  53. RealInfOpenInfFileW((f)/*,*/ ALLOCATION_TRACKING_CALL)\
  54. TRACK_END()
  55. HINF
  56. RealInfOpenInfFileA (
  57. IN PCSTR FileName /*,*/
  58. ALLOCATION_TRACKING_DEF
  59. );
  60. HINF
  61. RealInfOpenInfFileW (
  62. IN PCWSTR FileName /*,*/
  63. ALLOCATION_TRACKING_DEF
  64. );
  65. VOID
  66. InfCloseInfFile (HINF Inf);
  67. //
  68. // See the macros below before calling InfOpenInfInAllSourcesA or W.
  69. //
  70. HINF
  71. InfOpenInfInAllSourcesA (
  72. IN PCSTR InfSpecifier,
  73. IN DWORD SourceCount,
  74. IN PCSTR * SourceDirectories
  75. );
  76. HINF
  77. InfOpenInfInAllSourcesW (
  78. IN PCWSTR InfSpecifier,
  79. IN DWORD SourceCount,
  80. IN PCWSTR *SourceDirectories
  81. );
  82. PSTR
  83. InfGetLineTextA (
  84. IN OUT PINFSTRUCT
  85. );
  86. PWSTR
  87. InfGetLineTextW (
  88. IN OUT PINFSTRUCT
  89. );
  90. PSTR
  91. InfGetStringFieldA (
  92. IN OUT PINFSTRUCT Context,
  93. IN UINT FieldIndex
  94. );
  95. PWSTR
  96. InfGetStringFieldW (
  97. IN OUT PINFSTRUCT Context,
  98. IN UINT FieldIndex
  99. );
  100. PSTR
  101. InfGetMultiSzFieldA (
  102. IN OUT PINFSTRUCT Context,
  103. IN UINT FieldIndex
  104. ) ;
  105. PWSTR
  106. InfGetMultiSzFieldW (
  107. IN OUT PINFSTRUCT Context,
  108. IN UINT FieldIndex
  109. ) ;
  110. BOOL
  111. InfGetIntField (
  112. IN PINFSTRUCT Context,
  113. IN UINT FieldIndex,
  114. IN PINT Value
  115. );
  116. PBYTE
  117. InfGetBinaryField (
  118. IN PINFSTRUCT Context,
  119. IN UINT FieldIndex
  120. );
  121. BOOL
  122. InfGetLineByIndexA(
  123. IN HINF InfHandle,
  124. IN PCSTR Section,
  125. IN DWORD Index,
  126. OUT PINFSTRUCT Context
  127. );
  128. BOOL
  129. InfGetLineByIndexW(
  130. IN HINF InfHandle,
  131. IN PCWSTR Section,
  132. IN DWORD Index,
  133. OUT PINFSTRUCT Context
  134. );
  135. BOOL
  136. InfFindFirstLineA (
  137. IN HINF InfHandle,
  138. IN PCSTR Section,
  139. IN PCSTR Key,
  140. OUT PINFSTRUCT Context
  141. );
  142. BOOL
  143. InfFindFirstLineW (
  144. IN HINF InfHandle,
  145. IN PCWSTR Section,
  146. IN PCWSTR Key,
  147. OUT PINFSTRUCT Context
  148. );
  149. BOOL
  150. InfFindNextLine (
  151. IN OUT PINFSTRUCT Context
  152. );
  153. UINT
  154. InfGetFieldCount (
  155. IN PINFSTRUCT Context
  156. );
  157. PCSTR
  158. InfGetOemStringFieldA (
  159. IN PINFSTRUCT Context,
  160. IN UINT Field
  161. );
  162. BOOL
  163. SetupGetOemStringFieldA (
  164. IN PINFCONTEXT Context,
  165. IN DWORD Index,
  166. IN PSTR ReturnBuffer,
  167. IN DWORD ReturnBufferSize,
  168. OUT PDWORD RequiredSize
  169. );
  170. VOID
  171. InfResetInfStruct (
  172. IN OUT PINFSTRUCT Context
  173. );
  174. VOID
  175. InfLogContext (
  176. IN PCSTR LogType,
  177. IN HINF InfHandle,
  178. IN PINFSTRUCT InfStruct
  179. );
  180. VOID
  181. InfNameHandle (
  182. IN HINF Inf,
  183. IN PCSTR NewName,
  184. IN BOOL OverwriteExistingName
  185. );
  186. //
  187. // INF parser
  188. //
  189. typedef struct _tagINFLINE {
  190. PCWSTR Key; OPTIONAL
  191. PCWSTR Data;
  192. DWORD LineFlags;
  193. struct _tagINFLINE *Next, *Prev;
  194. struct _tagINFSECTION *Section;
  195. } INFLINE, *PINFLINE;
  196. #define LINEFLAG_KEY_QUOTED 0x0001
  197. #define LINEFLAG_ALL_COMMENTS 0x0002
  198. #define LINEFLAG_TRAILING_COMMENTS 0x0004
  199. typedef struct _tagINFSECTION {
  200. PCWSTR Name;
  201. PINFLINE FirstLine;
  202. PINFLINE LastLine;
  203. UINT LineCount;
  204. struct _tagINFSECTION *Next, *Prev;
  205. } INFSECTION, *PINFSECTION;
  206. PINFSECTION
  207. AddInfSectionToTableA (
  208. IN HINF Inf,
  209. IN PCSTR SectionName
  210. );
  211. PINFSECTION
  212. AddInfSectionToTableW (
  213. IN HINF Inf,
  214. IN PCWSTR SectionName
  215. );
  216. PINFSECTION
  217. FindInfSectionInTableA (
  218. IN HINF Inf,
  219. IN PCSTR SectionName
  220. );
  221. PINFSECTION
  222. GetFirstInfSectionInTable (
  223. IN HINF Inf
  224. );
  225. PINFSECTION
  226. GetNextInfSectionInTable (
  227. IN PINFSECTION Section
  228. );
  229. PINFSECTION
  230. FindInfSectionInTableW (
  231. IN HINF Inf,
  232. IN PCWSTR SectionName
  233. );
  234. PINFLINE
  235. AddInfLineToTableA (
  236. IN HINF Inf,
  237. IN PINFSECTION SectionPtr,
  238. IN PCSTR Key, OPTIONAL
  239. IN PCSTR Data,
  240. IN DWORD LineFlags
  241. );
  242. PINFLINE
  243. AddInfLineToTableW (
  244. IN HINF Inf,
  245. IN PINFSECTION SectionPtr,
  246. IN PCWSTR Key, OPTIONAL
  247. IN PCWSTR Data,
  248. IN DWORD LineFlags
  249. );
  250. PINFLINE
  251. FindLineInInfSectionA (
  252. IN HINF Inf,
  253. IN PINFSECTION Section,
  254. IN PCSTR Key
  255. );
  256. PINFLINE
  257. FindLineInInfSectionW (
  258. IN HINF Inf,
  259. IN PINFSECTION Section,
  260. IN PCWSTR Key
  261. );
  262. PINFLINE
  263. GetFirstLineInSectionStrA (
  264. IN HINF Inf,
  265. IN PCSTR Section
  266. );
  267. PINFLINE
  268. GetFirstLineInSectionStrW (
  269. IN HINF Inf,
  270. IN PCWSTR Section
  271. );
  272. PINFLINE
  273. GetFirstLineInSectionStruct (
  274. IN PINFSECTION Section
  275. );
  276. PINFLINE
  277. GetNextLineInSection (
  278. IN PINFLINE PrevLine
  279. );
  280. UINT
  281. GetInfSectionLineCount (
  282. IN PINFSECTION Section
  283. );
  284. BOOL
  285. DeleteSectionInInfFile (
  286. IN HINF Inf,
  287. IN PINFSECTION Section
  288. );
  289. BOOL
  290. DeleteLineInInfSection (
  291. IN HINF Inf,
  292. IN PINFLINE InfLine
  293. );
  294. HINF
  295. OpenInfFileExA (
  296. IN PCSTR InfFilePath,
  297. IN PSTR SectionList,
  298. IN BOOL KeepComments
  299. );
  300. #define OpenInfFileA(Path) OpenInfFileExA (Path, NULL, TRUE)
  301. HINF
  302. OpenInfFileExW (
  303. IN PCWSTR InfFilePath,
  304. IN PWSTR SectionList,
  305. IN BOOL KeepComments
  306. );
  307. #define OpenInfFileW(Path) OpenInfFileExW (Path, NULL, TRUE)
  308. VOID
  309. CloseInfFile (
  310. HINF InfFile
  311. );
  312. BOOL
  313. SaveInfFileA (
  314. IN HINF Inf,
  315. IN PCSTR SaveToFileSpec
  316. );
  317. BOOL
  318. SaveInfFileW (
  319. IN HINF Inf,
  320. IN PCWSTR SaveToFileSpec
  321. );
  322. //
  323. // ANSI/UNICODE mappings.
  324. //
  325. #ifdef UNICODE
  326. # define InfFindFirstLine InfFindFirstLineW
  327. # define InfGetLineByIndex InfGetLineByIndexW
  328. # define InfGetStringField InfGetStringFieldW
  329. # define InfGetMultiSzField InfGetMultiSzFieldW
  330. # define InfGetLineText InfGetLineTextW
  331. # define InfOpenInfFile InfOpenInfFileW
  332. # define InfGetOemStringField InfGetStringFieldW
  333. # define SetupGetOemStringField SetupGetStringFieldW
  334. # define InfOpenInfInAllSources(x) InfOpenInfInAllSourcesW((x),1,&g_SourceDirectory);
  335. # define AddInfSectionToTable AddInfSectionToTableW
  336. # define FindInfSectionInTable FindInfSectionInTableW
  337. # define AddInfLineToTable AddInfLineToTableW
  338. # define FindLineInInfSection FindLineInInfSectionW
  339. # define GetFirstLineInSectionStr GetFirstLineInSectionStrW
  340. # define OpenInfFileEx OpenInfFileExW
  341. # define OpenInfFile OpenInfFileW
  342. # define SaveInfFile SaveInfFileW
  343. #else
  344. # define InfFindFirstLine InfFindFirstLineA
  345. # define InfGetLineByIndex InfGetLineByIndexA
  346. # define InfGetStringField InfGetStringFieldA
  347. # define InfGetMultiSzField InfGetMultiSzFieldA
  348. # define InfGetLineText InfGetLineTextA
  349. # define InfOpenInfFile InfOpenInfFileA
  350. # define InfGetOemStringField InfGetOemStringFieldA
  351. # define SetupGetOemStringField SetupGetOemStringFieldA
  352. # define InfOpenInfInAllSources(x) InfOpenInfInAllSourcesA((x),g_SourceDirectoryCount,g_SourceDirectories);
  353. # define AddInfSectionToTable AddInfSectionToTableA
  354. # define FindInfSectionInTable FindInfSectionInTableA
  355. # define AddInfLineToTable AddInfLineToTableA
  356. # define FindLineInInfSection FindLineInInfSectionA
  357. # define GetFirstLineInSectionStr GetFirstLineInSectionStrA
  358. # define OpenInfFileEx OpenInfFileExA
  359. # define OpenInfFile OpenInfFileA
  360. # define SaveInfFile SaveInfFileA
  361. #endif