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.

241 lines
5.4 KiB

  1. /*++
  2. Copyright (c) 1994-7 Microsoft Corporation
  3. Module Name:
  4. netinfp.h
  5. Abstract:
  6. This file contains the structures and prototypes necessary for the
  7. netcard inf parser handler.
  8. Author:
  9. Andy Herron (andyhe) 12-Mar-1998
  10. Environment:
  11. User Mode - Win32
  12. Revision History:
  13. --*/
  14. #ifndef _NETINFP_
  15. #define _NETINFP_
  16. #define NETINF_VENDOR_STRING L"VEN_"
  17. #define NETINF_REVISION_STRING L"REV_"
  18. #define NETINF_DEVICE_STRING L"DEV_"
  19. #define NETINF_IOSUBS_STRING L"SUBSYS_"
  20. #define NETINF_BUS_TYPE_PCI 2
  21. #define NETINF_BUS_TYPE_ISAPNP 3
  22. #define NETCARD_HASH_TABLE_SIZE 17
  23. extern CRITICAL_SECTION NetInfLock;
  24. #define RNDM_CONSTANT 314159269 /* default scrambling constant */
  25. #define RNDM_PRIME 1000000007 /* prime number for scrambling */
  26. //
  27. // Compute a string hash value that is invariant to case
  28. //
  29. #define COMPUTE_STRING_HASH( _pus, _phash ) { \
  30. PWCHAR _p = _pus; \
  31. ULONG _chHolder =0; \
  32. \
  33. while( *_p != L'\0' ) { \
  34. _chHolder = 37 * _chHolder + (unsigned int) *(_p++); \
  35. } \
  36. \
  37. *(_phash) = abs(RNDM_CONSTANT * _chHolder) % RNDM_PRIME; \
  38. }
  39. #define HASH_TO_INF_INDEX( _hash ) ((_hash) % NETCARD_HASH_TABLE_SIZE)
  40. //
  41. // this is the block that we keep for every install directory that we
  42. // process INF files for. We then keep the list of configurations as a list
  43. // off of the NetCardEntryList.
  44. //
  45. typedef struct _NETCARD_INF_BLOCK {
  46. ULONG ReferenceCount;
  47. LIST_ENTRY InfBlockEntry; // list entry for global list
  48. // table of list of NETCARD_RESPONSE_DATABASE, hashed by DeviceHw string
  49. LIST_ENTRY NetCardEntries[ NETCARD_HASH_TABLE_SIZE ];
  50. ULONG Architecture;
  51. ULONG StatusFromScan;
  52. PNETINF_CALLBACK FileListCallbackFunction;
  53. LPVOID FileListCallbackContext;
  54. CRITICAL_SECTION Lock;
  55. WCHAR InfDirectory[ANYSIZE_ARRAY]; // inf directory to search
  56. } NETCARD_INF_BLOCK, *PNETCARD_INF_BLOCK;
  57. //
  58. // NetInfGetAllNetcardInfo parses all the INF files in the given directory
  59. // and sets up a structure containing all the data. Be sure to call
  60. // NetInfCloseNetcardInfo when you're all done with the structure.
  61. //
  62. ULONG
  63. NetInfAllocateNetcardInfo (
  64. PWCHAR InfPath,
  65. ULONG Architecture,
  66. PNETCARD_INF_BLOCK *pNetCards
  67. );
  68. //
  69. // This frees all resources associated with the parsing of the INF files.
  70. // Any entries that are in use will not be deleted until they're explicitely
  71. // dereferenced using NetInfDereferenceNetcardEntry.
  72. //
  73. ULONG
  74. NetInfCloseNetcardInfo (
  75. PNETCARD_INF_BLOCK pNetCards
  76. );
  77. //
  78. // This finds a specific driver for a given hardware description.
  79. // Be sure to call NetInfDereferenceNetcardEntry when you're done with the
  80. // entry.
  81. //
  82. ULONG
  83. FindNetcardInfo (
  84. PNETCARD_INF_BLOCK pNetCards,
  85. ULONG CardInfoVersion,
  86. NET_CARD_INFO UNALIGNED * CardIdentity,
  87. PNETCARD_RESPONSE_DATABASE *pInfEntry
  88. );
  89. ULONG
  90. GetSetupLineWideText (
  91. PINFCONTEXT InfContext,
  92. HINF InfHandle,
  93. PWCHAR Section,
  94. PWCHAR Key,
  95. PWCHAR *String,
  96. PULONG SizeOfAllocation OPTIONAL
  97. );
  98. ULONG
  99. GetSetupWideTextField (
  100. PINFCONTEXT InfContext,
  101. DWORD FieldIndex,
  102. PWCHAR *String,
  103. PULONG SizeOfAllocation OPTIONAL
  104. );
  105. ULONG
  106. GetHexValueFromHw (
  107. PWCHAR *String, // this is updated.
  108. PULONG longValue,
  109. PUSHORT shortValue
  110. );
  111. BOOLEAN
  112. IsSubString (
  113. PWCHAR subString,
  114. PWCHAR target,
  115. BOOLEAN ignoreCase
  116. );
  117. ULONG
  118. CheckHwDescription (
  119. PWCHAR HardwareID
  120. );
  121. ULONG
  122. GetNetCardList (
  123. PNETCARD_INF_BLOCK pNetCards
  124. );
  125. ULONG
  126. ProcessInfFile (
  127. PNETCARD_INF_BLOCK pNetCards,
  128. HINF InfHandle,
  129. PWCHAR InfFileName
  130. );
  131. ULONG
  132. ParseCardDetails (
  133. PNETCARD_INF_BLOCK pNetCards,
  134. HINF InfHandle,
  135. PWCHAR InfFileName,
  136. PINFCONTEXT DeviceEnumContext
  137. );
  138. ULONG
  139. GetExtendedSectionName (
  140. PNETCARD_INF_BLOCK pNetCards,
  141. HINF InfHandle,
  142. PWCHAR InfFileName,
  143. PNETCARD_RESPONSE_DATABASE pEntry
  144. );
  145. ULONG
  146. GetServiceAndDriver (
  147. PNETCARD_INF_BLOCK pNetCards,
  148. HINF InfHandle,
  149. PWCHAR InfFileName,
  150. PNETCARD_RESPONSE_DATABASE pEntry
  151. );
  152. ULONG
  153. ProcessCopyFilesSubsection (
  154. PNETCARD_INF_BLOCK pNetCards,
  155. HINF InfHandle,
  156. PWCHAR InfFileName,
  157. PNETCARD_RESPONSE_DATABASE pEntry,
  158. PWCHAR SectionToParse
  159. );
  160. ULONG
  161. GetRegistryParametersForDriver (
  162. PNETCARD_INF_BLOCK pNetCards,
  163. HINF InfHandle,
  164. PWCHAR InfFileName,
  165. PNETCARD_RESPONSE_DATABASE pEntry
  166. );
  167. ULONG
  168. ProcessRegistrySubsection (
  169. PNETCARD_INF_BLOCK pNetCards,
  170. HINF InfHandle,
  171. PWCHAR InfFileName,
  172. PNETCARD_RESPONSE_DATABASE pEntry,
  173. PWCHAR SectionToParse
  174. );
  175. VOID
  176. DereferenceNetcardInfo (
  177. PNETCARD_INF_BLOCK pNetCards
  178. );
  179. ULONG
  180. CreateListOfCardIdentifiers (
  181. NET_CARD_INFO UNALIGNED * CardIdentity,
  182. PWCHAR *CardIdentifiers
  183. );
  184. VOID
  185. ConvertHexToBuffer (
  186. PWCHAR Buff,
  187. USHORT Value
  188. );
  189. #endif _NETINFP_