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.

183 lines
6.9 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. infcache.h
  5. Abstract:
  6. Private header for INFCACHE functions/structures
  7. (See also infcache.c)
  8. Author:
  9. Jamie Hunter (jamiehun) Jan-27-2000
  10. Revision History:
  11. --*/
  12. #define INFCACHE_VERSION (1) // increment for every schema change
  13. #define INFCACHE_NAME_TEMPLATE TEXT("INFCACHE.%d") // name of cache file (number fills last 3 digits)
  14. #define OLDCACHE_NAME_TEMPLATE TEXT("OLDCACHE.%03d") // old cache file
  15. #define INFCACHE_INF_WILDCARD TEXT("*.inf")
  16. //
  17. // file layout is:
  18. //
  19. // CACHEHEADER
  20. // <MatchTable>
  21. // <InfTable>
  22. // <ListData>
  23. //
  24. // file size = sizeof(CACHEHEADER) + MatchTableSize + InfTableSize + ListDataCount*sizeof(CACHELISTENTRY)
  25. // first entry of <ListData> is reference to free-list
  26. //
  27. #include "pshpack1.h"
  28. typedef struct tag_CACHEHEADER {
  29. ULONG Version; // indicates file schema
  30. LCID Locale; // locale (as written)
  31. DWORD Flags; // various flags
  32. ULONG FileSize; // size of file, including header
  33. ULONG MatchTableOffset; // offset of match table portion (allowing for alignment)
  34. ULONG MatchTableSize; // size of match table portion
  35. ULONG InfTableOffset; // offset of inf table portion (allowing for alignment)
  36. ULONG InfTableSize; // size of inf table portion
  37. ULONG ListDataOffset; // offset of list data portion (allowing for alignment)
  38. ULONG ListDataCount; // number of list data items
  39. } CACHEHEADER, * PCACHEHEADER;
  40. //
  41. // MatchTable datum
  42. //
  43. typedef struct tag_CACHEMATCHENTRY {
  44. ULONG InfList; // index into ListTable of list of "hit" INFs
  45. } CACHEMATCHENTRY, * PCACHEMATCHENTRY;
  46. //
  47. // InfTable datum
  48. //
  49. typedef struct tag_CACHEINFENTRY {
  50. FILETIME FileTime; // exactly same as FileTime saved in PNF
  51. ULONG MatchList; // into ListTable (first entry is GUID) cross-link of references to INF
  52. ULONG MatchFlags; // various flags to help expand/reduce search criteria
  53. } CACHEINFENTRY, * PCACHEINFENTRY;
  54. //
  55. // special MatchList values
  56. //
  57. #define CIE_INF_INVALID (ULONG)(-1) // indicates INF entry is outdated
  58. #define CIEF_INF_NOTINF 0 // if flags is zero, this is not a valid INF
  59. #define CIEF_INF_OLDNT 0x00000001 // indicates INF is old-style (Style == INF_STYLE_OLDNT)
  60. #define CIEF_INF_WIN4 0x00000002 // indicates INF is Win4 style (Style == INF_STYLE_WIN4)
  61. #define CIEF_INF_ISINF (CIEF_INF_OLDNT|CIEF_INF_WIN4)
  62. #define CIEF_INF_URL 0x00000004 // indicates INF InfSourceMediaType == SPOST_URL
  63. #define CIEF_INF_CLASSNAME 0x00000008 // indicates INF has a Class Name (or Legacy name if OLDNT)
  64. #define CIEF_INF_CLASSGUID 0x00000010 // indicates INF has a Class GUID
  65. #define CIEF_INF_CLASSINFO (CIEF_INF_CLASSNAME|CIEF_INF_CLASSGUID)
  66. #define CIEF_INF_NULLGUID 0x00000020 // indicates INF has a Class GUID of {0}
  67. #define CIEF_INF_MANUFACTURER 0x00000040 // indicates INF has at least one manufacturer
  68. //
  69. // CacheList datum
  70. //
  71. typedef struct tag_CACHELISTENTRY {
  72. LONG Value; // Typically StringID. For HWID/GUID, index into MatchTable. for INF, index into InfTable
  73. ULONG Next; // index to next entry
  74. } CACHELISTENTRY, * PCACHELISTENTRY;
  75. #include "poppack.h"
  76. //
  77. // Run-Time cache information
  78. //
  79. typedef struct tag_INFCACHE {
  80. HANDLE FileHandle; // information regarding the in-memory image of the cache file
  81. HANDLE MappingHandle;
  82. PVOID BaseAddress;
  83. PCACHEHEADER pHeader; // pointer to header in file image
  84. PVOID pMatchTable; // pointer to match table
  85. PVOID pInfTable; // pointer to inf table
  86. PCACHELISTENTRY pListTable; // pointer to list table
  87. ULONG ListDataAlloc; // how much space is allocated, >= ListDataCount
  88. PVOID pSearchTable; // transient table to handle search state
  89. BOOL bReadOnly; // set if this is mapped, unset if allocated
  90. BOOL bDirty; // set if modified
  91. BOOL bNoWriteBack; // set if we shouldn't write cache (a failure occured so cache isn't good)
  92. } INFCACHE, * PINFCACHE;
  93. #define CHE_FLAGS_PENDING 0x00000001 // set if file is yet to be processed
  94. #define CHE_FLAGS_GUIDMATCH 0x00000002 // set if during search pass we consider this a GUID MATCH
  95. #define CHE_FLAGS_IDMATCH 0x00000004 // set if during search pass we got at least one ID MATCH
  96. //
  97. // SearchTable data
  98. //
  99. typedef struct tag_CACHEHITENTRY {
  100. ULONG Flags; // CHE_FLAGS_xxxx
  101. } CACHEHITENTRY, * PCACHEHITENTRY;
  102. //
  103. // callback
  104. //
  105. typedef BOOL (CALLBACK * InfCacheCallback)(
  106. IN PSETUP_LOG_CONTEXT LogContext,
  107. IN PCTSTR InfPath,
  108. IN PLOADED_INF pInf,
  109. IN BOOL PnfWasUsed,
  110. IN PVOID Context
  111. );
  112. //
  113. // stringtable callback for INF enumeration
  114. //
  115. typedef struct tag_INFCACHE_ENUMDATA {
  116. PSETUP_LOG_CONTEXT LogContext;
  117. PCTSTR InfDir;
  118. InfCacheCallback Callback;
  119. PVOID Context;
  120. ULONG Requirement;
  121. DWORD ExitStatus;
  122. } INFCACHE_ENUMDATA, *PINFCACHE_ENUMDATA;
  123. //
  124. // action flags
  125. //
  126. #define INFCACHE_DEFAULT 0x00000000 // default operation
  127. #define INFCACHE_REBUILD 0x00000001 // ignore existing cache
  128. #define INFCACHE_NOWRITE 0x00000002 // don't write back
  129. #define INFCACHE_ENUMALL 0x00000003 // special combination, just enum all
  130. #define INFCACHE_ACTIONBITS 0x000000FF // primary action bits
  131. #define INFCACHE_EXC_OLDINFS 0x00000100 // exclude INFs that are OLDNT
  132. #define INFCACHE_EXC_URL 0x00000200 // exclude INFs that are marked SPOST_URL
  133. #define INFCACHE_EXC_NOCLASS 0x00000400 // excludes INFs that has no class information
  134. #define INFCACHE_EXC_NULLCLASS 0x00000800 // excludes INFs that has null class
  135. #define INFCACHE_EXC_NOMANU 0x00001000 // excludes INFs that has no (or empty) [Manufacturers] - ignored for OLDNT
  136. #define INFCACHE_FORCE_CACHE 0X00010000 // (try and) force cache creating even if "OEM dir"
  137. #define INFCACHE_FORCE_PNF 0X00020000 // (try and) force PNF creating even if "OEM dir"
  138. DWORD InfCacheSearchPath(
  139. IN PSETUP_LOG_CONTEXT LogContext, OPTIONAL
  140. IN DWORD Action,
  141. IN PCTSTR InfDirPath, OPTIONAL
  142. IN InfCacheCallback Callback, OPTIONAL
  143. IN PVOID Context, OPTIONAL
  144. IN PCTSTR ClassId, OPTIONAL
  145. IN PCTSTR HwIdList OPTIONAL
  146. );
  147. BOOL
  148. InfCacheAwareCopyFile(
  149. IN LPCTSTR Source,
  150. IN LPCTSTR Target
  151. );