ReactOS  0.4.13-dev-464-g6b95727
inffile.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _INFCONTEXT
 

Macros

#define STATUS_BAD_SECTION_NAME_LINE   (0xC0700001)
 
#define STATUS_SECTION_NAME_TOO_LONG   (0xC0700002)
 
#define STATUS_WRONG_INF_STYLE   (0xC0700003)
 
#define STATUS_NOT_ENOUGH_MEMORY   (0xC0700004)
 
#define MAX_INF_STRING_LENGTH   512
 

Typedefs

typedef PULONG HINF
 
typedef PULONGPHINF
 
typedef struct _INFCONTEXT INFCONTEXT
 
typedef struct _INFCONTEXTPINFCONTEXT
 

Functions

BOOLEAN InfOpenFile (PHINF InfHandle, PCSTR FileName, PULONG ErrorLine)
 
VOID InfCloseFile (HINF InfHandle)
 
BOOLEAN InfFindFirstLine (HINF InfHandle, PCSTR Section, PCSTR Key, PINFCONTEXT Context)
 
BOOLEAN InfFindNextLine (PINFCONTEXT ContextIn, PINFCONTEXT ContextOut)
 
BOOLEAN InfFindFirstMatchLine (PINFCONTEXT ContextIn, PCHAR Key, PINFCONTEXT ContextOut)
 
BOOLEAN InfFindNextMatchLine (PINFCONTEXT ContextIn, PCHAR Key, PINFCONTEXT ContextOut)
 
LONG InfGetLineCount (HINF InfHandle, PCHAR Section)
 
LONG InfGetFieldCount (PINFCONTEXT Context)
 
BOOLEAN InfGetBinaryField (PINFCONTEXT Context, ULONG FieldIndex, PUCHAR ReturnBuffer, ULONG ReturnBufferSize, PULONG RequiredSize)
 
BOOLEAN InfGetIntField (PINFCONTEXT Context, ULONG FieldIndex, LONG *IntegerValue)
 
BOOLEAN InfGetMultiSzField (PINFCONTEXT Context, ULONG FieldIndex, PCHAR ReturnBuffer, ULONG ReturnBufferSize, PULONG RequiredSize)
 
BOOLEAN InfGetStringField (PINFCONTEXT Context, ULONG FieldIndex, PCHAR ReturnBuffer, ULONG ReturnBufferSize, PULONG RequiredSize)
 
BOOLEAN InfGetData (PINFCONTEXT Context, PCHAR *Key, PCHAR *Data)
 
BOOLEAN InfGetDataField (PINFCONTEXT Context, ULONG FieldIndex, PCSTR *Data)
 

Macro Definition Documentation

◆ MAX_INF_STRING_LENGTH

#define MAX_INF_STRING_LENGTH   512

Definition at line 35 of file inffile.h.

◆ STATUS_BAD_SECTION_NAME_LINE

#define STATUS_BAD_SECTION_NAME_LINE   (0xC0700001)

Definition at line 30 of file inffile.h.

◆ STATUS_NOT_ENOUGH_MEMORY

#define STATUS_NOT_ENOUGH_MEMORY   (0xC0700004)

Definition at line 33 of file inffile.h.

◆ STATUS_SECTION_NAME_TOO_LONG

#define STATUS_SECTION_NAME_TOO_LONG   (0xC0700002)

Definition at line 31 of file inffile.h.

◆ STATUS_WRONG_INF_STYLE

#define STATUS_WRONG_INF_STYLE   (0xC0700003)

Definition at line 32 of file inffile.h.

Typedef Documentation

◆ HINF

typedef PULONG HINF

Definition at line 37 of file inffile.h.

◆ INFCONTEXT

◆ PHINF

typedef PULONG * PHINF

Definition at line 37 of file inffile.h.

◆ PINFCONTEXT

Function Documentation

◆ InfCloseFile()

VOID InfCloseFile ( HINF  InfHandle)

Definition at line 1046 of file inffile.c.

1047 {
1048  PINFCACHE Cache;
1049 
1050  Cache = (PINFCACHE)InfHandle;
1051 
1052  if (Cache == NULL)
1053  {
1054  return;
1055  }
1056 
1057  while (Cache->FirstSection != NULL)
1058  {
1059  Cache->FirstSection = InfpCacheFreeSection(Cache->FirstSection);
1060  }
1061  Cache->LastSection = NULL;
1062 
1064 }
#define TAG_INF_CACHE
Definition: inffile.c:42
Definition: fatfs.h:173
smooth NULL
Definition: ftsmooth.c:416
struct _INFCACHE * PINFCACHE
static PINFCACHESECTION InfpCacheFreeSection(PINFCACHESECTION Section)
Definition: inffile.c:188
FORCEINLINE VOID FrLdrTempFree(PVOID Allocation, ULONG Tag)
Definition: mm.h:186

◆ InfFindFirstLine()

BOOLEAN InfFindFirstLine ( HINF  InfHandle,
PCSTR  Section,
PCSTR  Key,
PINFCONTEXT  Context 
)

Definition at line 1068 of file inffile.c.

1073 {
1074  PINFCACHE Cache;
1075  PINFCACHESECTION CacheSection;
1076  PINFCACHELINE CacheLine;
1077 
1078  if ((InfHandle == NULL) || (Section == NULL) || (Context == NULL))
1079  {
1080 // DPRINT("Invalid parameter\n");
1081  return FALSE;
1082  }
1083 
1084  Cache = (PINFCACHE)InfHandle;
1085 
1086  /* Iterate through list of sections */
1087  CacheSection = Cache->FirstSection;
1088  while (Section != NULL)
1089  {
1090 // DPRINT("Comparing '%S' and '%S'\n", CacheSection->Name, Section);
1091 
1092  /* Are the section names the same? */
1093  if (_stricmp(CacheSection->Name, Section) == 0)
1094  {
1095  if (Key != NULL)
1096  {
1097  CacheLine = InfpCacheFindKeyLine(CacheSection, Key);
1098  }
1099  else
1100  {
1101  CacheLine = CacheSection->FirstLine;
1102  }
1103 
1104  if (CacheLine == NULL)
1105  return FALSE;
1106 
1107  Context->Inf = (PVOID)Cache;
1108  Context->Section = (PVOID)CacheSection;
1109  Context->Line = (PVOID)CacheLine;
1110 
1111  return TRUE;
1112  }
1113 
1114  /* Get the next section */
1115  CacheSection = CacheSection->Next;
1116  }
1117 
1118 // DPRINT("Section not found\n");
1119 
1120  return FALSE;
1121 }
CHAR Name[1]
Definition: inffile.c:77
#define TRUE
Definition: types.h:120
Definition: fatfs.h:173
#define _stricmp
Definition: cat.c:22
struct _INFCACHESECTION * Next
Definition: inffile.c:69
smooth NULL
Definition: ftsmooth.c:416
void * PVOID
Definition: retypes.h:9
struct _INFCACHE * PINFCACHE
PINFCACHELINE FirstLine
Definition: inffile.c:72
static PINFCACHELINE InfpCacheFindKeyLine(PINFCACHESECTION Section, PCSTR Key)
Definition: inffile.c:386

Referenced by LoadReactOSSetup(), SetupFindFirstLineW(), SetupLdrLoadNlsData(), and SetupLdrScanBootDrivers().

◆ InfFindFirstMatchLine()

BOOLEAN InfFindFirstMatchLine ( PINFCONTEXT  ContextIn,
PCHAR  Key,
PINFCONTEXT  ContextOut 
)

Definition at line 1153 of file inffile.c.

1157 {
1158  PINFCACHELINE CacheLine;
1159 
1160  if ((ContextIn == NULL) || (ContextOut == NULL) || (Key == NULL) || (*Key == 0))
1161  return FALSE;
1162 
1163  if (ContextIn->Inf == NULL || ContextIn->Section == NULL)
1164  return FALSE;
1165 
1166  CacheLine = ((PINFCACHESECTION)(ContextIn->Section))->FirstLine;
1167  while (CacheLine != NULL)
1168  {
1169  if ((CacheLine->Key != NULL) && (_stricmp(CacheLine->Key, Key) == 0))
1170  {
1171 
1172  if (ContextIn != ContextOut)
1173  {
1174  ContextOut->Inf = ContextIn->Inf;
1175  ContextOut->Section = ContextIn->Section;
1176  }
1177  ContextOut->Line = (PVOID)CacheLine;
1178 
1179  return TRUE;
1180  }
1181 
1182  CacheLine = CacheLine->Next;
1183  }
1184 
1185  return FALSE;
1186 }
#define TRUE
Definition: types.h:120
struct _INFCACHESECTION * PINFCACHESECTION
#define _stricmp
Definition: cat.c:22
smooth NULL
Definition: ftsmooth.c:416
void * PVOID
Definition: retypes.h:9
UINT Section
Definition: infsupp.h:26
struct _INFCACHELINE * Next
Definition: inffile.c:55
HINF Inf
Definition: infsupp.h:24
UINT Line
Definition: infsupp.h:27
PCHAR Key
Definition: inffile.c:60

◆ InfFindNextLine()

BOOLEAN InfFindNextLine ( PINFCONTEXT  ContextIn,
PINFCONTEXT  ContextOut 
)

Definition at line 1125 of file inffile.c.

1128 {
1129  PINFCACHELINE CacheLine;
1130 
1131  if ((ContextIn == NULL) || (ContextOut == NULL))
1132  return FALSE;
1133 
1134  if (ContextIn->Line == NULL)
1135  return FALSE;
1136 
1137  CacheLine = (PINFCACHELINE)ContextIn->Line;
1138  if (CacheLine->Next == NULL)
1139  return FALSE;
1140 
1141  if (ContextIn != ContextOut)
1142  {
1143  ContextOut->Inf = ContextIn->Inf;
1144  ContextOut->Section = ContextIn->Section;
1145  }
1146  ContextOut->Line = (PVOID)(CacheLine->Next);
1147 
1148  return TRUE;
1149 }
#define TRUE
Definition: types.h:120
struct _INFCACHELINE * PINFCACHELINE
smooth NULL
Definition: ftsmooth.c:416
void * PVOID
Definition: retypes.h:9
if(!(yy_init))
Definition: macro.lex.yy.c:714
UINT Section
Definition: infsupp.h:26
struct _INFCACHELINE * Next
Definition: inffile.c:55
HINF Inf
Definition: infsupp.h:24
UINT Line
Definition: infsupp.h:27

◆ InfFindNextMatchLine()

BOOLEAN InfFindNextMatchLine ( PINFCONTEXT  ContextIn,
PCHAR  Key,
PINFCONTEXT  ContextOut 
)

Definition at line 1190 of file inffile.c.

1194 {
1195  PINFCACHELINE CacheLine;
1196 
1197  if ((ContextIn == NULL) || (ContextOut == NULL) || (Key == NULL) || (*Key == 0))
1198  return FALSE;
1199 
1200  if ((ContextIn->Inf == NULL) || (ContextIn->Section == NULL) || (ContextIn->Line == NULL))
1201  return FALSE;
1202 
1203  CacheLine = (PINFCACHELINE)ContextIn->Line;
1204  while (CacheLine != NULL)
1205  {
1206  if ((CacheLine->Key != NULL) && (_stricmp(CacheLine->Key, Key) == 0))
1207  {
1208 
1209  if (ContextIn != ContextOut)
1210  {
1211  ContextOut->Inf = ContextIn->Inf;
1212  ContextOut->Section = ContextIn->Section;
1213  }
1214  ContextOut->Line = (PVOID)CacheLine;
1215 
1216  return TRUE;
1217  }
1218 
1219  CacheLine = CacheLine->Next;
1220  }
1221 
1222  return FALSE;
1223 }
#define TRUE
Definition: types.h:120
struct _INFCACHELINE * PINFCACHELINE
#define _stricmp
Definition: cat.c:22
while(1)
Definition: macro.lex.yy.c:740
smooth NULL
Definition: ftsmooth.c:416
void * PVOID
Definition: retypes.h:9
UINT Section
Definition: infsupp.h:26
struct _INFCACHELINE * Next
Definition: inffile.c:55
HINF Inf
Definition: infsupp.h:24
UINT Line
Definition: infsupp.h:27
PCHAR Key
Definition: inffile.c:60

◆ InfGetBinaryField()

BOOLEAN InfGetBinaryField ( PINFCONTEXT  Context,
ULONG  FieldIndex,
PUCHAR  ReturnBuffer,
ULONG  ReturnBufferSize,
PULONG  RequiredSize 
)

Definition at line 1278 of file inffile.c.

1284 {
1285  PINFCACHELINE CacheLine;
1286  PINFCACHEFIELD CacheField;
1287  ULONG Index;
1288  ULONG Size;
1289  PUCHAR Ptr;
1290 
1291  if ((Context == NULL) || (Context->Line == NULL) || (FieldIndex == 0))
1292  {
1293 // DPRINT("Invalid parameter\n");
1294  return FALSE;
1295  }
1296 
1297  if (RequiredSize != NULL)
1298  *RequiredSize = 0;
1299 
1300  CacheLine = (PINFCACHELINE)Context->Line;
1301 
1302  if (FieldIndex > CacheLine->FieldCount)
1303  return FALSE;
1304 
1305  CacheField = CacheLine->FirstField;
1306  for (Index = 1; Index < FieldIndex; Index++)
1307  CacheField = CacheField->Next;
1308 
1309  Size = CacheLine->FieldCount - FieldIndex + 1;
1310 
1311  if (RequiredSize != NULL)
1312  *RequiredSize = Size;
1313 
1314  if (ReturnBuffer != NULL)
1315  {
1316  if (ReturnBufferSize < Size)
1317  return FALSE;
1318 
1319  /* Copy binary data */
1320  Ptr = ReturnBuffer;
1321  while (CacheField != NULL)
1322  {
1323  *Ptr = (UCHAR)atoi(CacheField->Data); //strtoul(CacheField->Data, NULL, 16);
1324 
1325  Ptr++;
1326  CacheField = CacheField->Next;
1327  }
1328  }
1329 
1330  return TRUE;
1331 }
#define TRUE
Definition: types.h:120
struct _INFCACHELINE * PINFCACHELINE
struct _INFCACHEFIELD * Next
Definition: inffile.c:47
unsigned char * PUCHAR
Definition: retypes.h:3
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
ULONG FieldCount
Definition: inffile.c:58
_In_ DWORD _In_ DWORD ReturnBufferSize
Definition: setupapi.h:1891
PINFCACHEFIELD FirstField
Definition: inffile.c:62
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PRTL_BUFFER _In_ SIZE_T RequiredSize
if(!(yy_init))
Definition: macro.lex.yy.c:714
_In_ DWORD FieldIndex
Definition: setupapi.h:1889
static const UCHAR Index[8]
Definition: usbohci.c:18
unsigned char UCHAR
Definition: xmlstorage.h:181
CHAR Data[1]
Definition: inffile.c:50
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
unsigned int ULONG
Definition: retypes.h:1

◆ InfGetData()

BOOLEAN InfGetData ( PINFCONTEXT  Context,
PCHAR Key,
PCHAR Data 
)

Definition at line 1509 of file inffile.c.

1513 {
1514  PINFCACHELINE CacheKey;
1515 
1516  if ((Context == NULL) || (Context->Line == NULL) || (Data == NULL))
1517  {
1518 // DPRINT("Invalid parameter\n");
1519  return FALSE;
1520  }
1521 
1522  CacheKey = (PINFCACHELINE)Context->Line;
1523  if (Key != NULL)
1524  *Key = CacheKey->Key;
1525 
1526  if (Data != NULL)
1527  {
1528  if (CacheKey->FirstField == NULL)
1529  {
1530  *Data = NULL;
1531  }
1532  else
1533  {
1534  *Data = CacheKey->FirstField->Data;
1535  }
1536  }
1537 
1538  return TRUE;
1539 }
#define TRUE
Definition: types.h:120
struct _INFCACHELINE * PINFCACHELINE
PINFCACHEFIELD FirstField
Definition: inffile.c:62
smooth NULL
Definition: ftsmooth.c:416
if(!(yy_init))
Definition: macro.lex.yy.c:714
CHAR Data[1]
Definition: inffile.c:50
PCHAR Key
Definition: inffile.c:60

◆ InfGetDataField()

BOOLEAN InfGetDataField ( PINFCONTEXT  Context,
ULONG  FieldIndex,
PCSTR Data 
)

Definition at line 1543 of file inffile.c.

1547 {
1548  PINFCACHELINE CacheLine;
1549  PINFCACHEFIELD CacheField;
1550  ULONG Index;
1551 
1552  if ((Context == NULL) || (Context->Line == NULL) || (Data == NULL))
1553  {
1554 // DPRINT("Invalid parameter\n");
1555  return FALSE;
1556  }
1557 
1558  CacheLine = (PINFCACHELINE)Context->Line;
1559 
1560  if (FieldIndex > CacheLine->FieldCount)
1561  return FALSE;
1562 
1563  if (FieldIndex == 0)
1564  {
1565  *Data = CacheLine->Key;
1566  }
1567  else
1568  {
1569  CacheField = CacheLine->FirstField;
1570  for (Index = 1; Index < FieldIndex; Index++)
1571  CacheField = CacheField->Next;
1572 
1573  *Data = CacheField->Data;
1574  }
1575 
1576  return TRUE;
1577 }
#define TRUE
Definition: types.h:120
struct _INFCACHELINE * PINFCACHELINE
struct _INFCACHEFIELD * Next
Definition: inffile.c:47
ULONG FieldCount
Definition: inffile.c:58
PINFCACHEFIELD FirstField
Definition: inffile.c:62
smooth NULL
Definition: ftsmooth.c:416
if(!(yy_init))
Definition: macro.lex.yy.c:714
_In_ DWORD FieldIndex
Definition: setupapi.h:1889
static const UCHAR Index[8]
Definition: usbohci.c:18
CHAR Data[1]
Definition: inffile.c:50
unsigned int ULONG
Definition: retypes.h:1
PCHAR Key
Definition: inffile.c:60

◆ InfGetFieldCount()

LONG InfGetFieldCount ( PINFCONTEXT  Context)

Definition at line 1268 of file inffile.c.

1269 {
1270  if ((Context == NULL) || (Context->Line == NULL))
1271  return 0;
1272 
1273  return ((PINFCACHELINE)Context->Line)->FieldCount;
1274 }
smooth NULL
Definition: ftsmooth.c:416

◆ InfGetIntField()

BOOLEAN InfGetIntField ( PINFCONTEXT  Context,
ULONG  FieldIndex,
LONG IntegerValue 
)

◆ InfGetLineCount()

LONG InfGetLineCount ( HINF  InfHandle,
PCHAR  Section 
)

Definition at line 1227 of file inffile.c.

1230 {
1231  PINFCACHE Cache;
1232  PINFCACHESECTION CacheSection;
1233 
1234  if ((InfHandle == NULL) || (Section == NULL))
1235  {
1236 // DPRINT("Invalid parameter\n");
1237  return -1;
1238  }
1239 
1240  Cache = (PINFCACHE)InfHandle;
1241 
1242  /* Iterate through list of sections */
1243  CacheSection = Cache->FirstSection;
1244  while (Section != NULL)
1245  {
1246 // DPRINT("Comparing '%S' and '%S'\n", CacheSection->Name, Section);
1247 
1248  /* Are the section names the same? */
1249  if (_stricmp(CacheSection->Name, Section) == 0)
1250  {
1251  return CacheSection->LineCount;
1252  }
1253 
1254  /* Get the next section */
1255  CacheSection = CacheSection->Next;
1256  }
1257 
1258 // DPRINT("Section not found\n");
1259 
1260  return -1;
1261 }
LONG LineCount
Definition: inffile.c:75
CHAR Name[1]
Definition: inffile.c:77
Definition: fatfs.h:173
#define _stricmp
Definition: cat.c:22
struct _INFCACHESECTION * Next
Definition: inffile.c:69
smooth NULL
Definition: ftsmooth.c:416
struct _INFCACHE * PINFCACHE

◆ InfGetMultiSzField()

BOOLEAN InfGetMultiSzField ( PINFCONTEXT  Context,
ULONG  FieldIndex,
PCHAR  ReturnBuffer,
ULONG  ReturnBufferSize,
PULONG  RequiredSize 
)

Definition at line 1379 of file inffile.c.

1385 {
1386  PINFCACHELINE CacheLine;
1387  PINFCACHEFIELD CacheField;
1388  PINFCACHEFIELD FieldPtr;
1389  ULONG Index;
1390  SIZE_T Size;
1391  PCHAR Ptr;
1392 
1393  if ((Context == NULL) || (Context->Line == NULL) || (FieldIndex == 0))
1394  {
1395 // DPRINT("Invalid parameter\n");
1396  return FALSE;
1397  }
1398 
1399  if (RequiredSize != NULL)
1400  *RequiredSize = 0;
1401 
1402  CacheLine = (PINFCACHELINE)Context->Line;
1403 
1404  if (FieldIndex > CacheLine->FieldCount)
1405  return FALSE;
1406 
1407  CacheField = CacheLine->FirstField;
1408  for (Index = 1; Index < FieldIndex; Index++)
1409  CacheField = CacheField->Next;
1410 
1411  /* Calculate the required buffer size */
1412  FieldPtr = CacheField;
1413  Size = 0;
1414  while (FieldPtr != NULL)
1415  {
1416  Size += (strlen(FieldPtr->Data) + 1);
1417  FieldPtr = FieldPtr->Next;
1418  }
1419  Size++;
1420 
1421  if (RequiredSize != NULL)
1422  *RequiredSize = (ULONG)Size;
1423 
1424  if (ReturnBuffer != NULL)
1425  {
1426  if (ReturnBufferSize < Size)
1427  return FALSE;
1428 
1429  /* Copy multi-sz string */
1430  Ptr = ReturnBuffer;
1431  FieldPtr = CacheField;
1432  while (FieldPtr != NULL)
1433  {
1434  Size = strlen(FieldPtr->Data) + 1;
1435 
1436  strcpy(Ptr, FieldPtr->Data);
1437 
1438  Ptr = Ptr + Size;
1439  FieldPtr = FieldPtr->Next;
1440  }
1441  *Ptr = 0;
1442  }
1443 
1444  return TRUE;
1445 }
signed char * PCHAR
Definition: retypes.h:7
#define TRUE
Definition: types.h:120
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
struct _INFCACHELINE * PINFCACHELINE
struct _INFCACHEFIELD * Next
Definition: inffile.c:47
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
ULONG FieldCount
Definition: inffile.c:58
_In_ DWORD _In_ DWORD ReturnBufferSize
Definition: setupapi.h:1891
while(1)
Definition: macro.lex.yy.c:740
PINFCACHEFIELD FirstField
Definition: inffile.c:62
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PRTL_BUFFER _In_ SIZE_T RequiredSize
if(!(yy_init))
Definition: macro.lex.yy.c:714
_In_ DWORD FieldIndex
Definition: setupapi.h:1889
static const UCHAR Index[8]
Definition: usbohci.c:18
CHAR Data[1]
Definition: inffile.c:50
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
ULONG_PTR SIZE_T
Definition: typedefs.h:78
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
unsigned int ULONG
Definition: retypes.h:1

◆ InfGetStringField()

BOOLEAN InfGetStringField ( PINFCONTEXT  Context,
ULONG  FieldIndex,
PCHAR  ReturnBuffer,
ULONG  ReturnBufferSize,
PULONG  RequiredSize 
)

Definition at line 1449 of file inffile.c.

1455 {
1456  PINFCACHELINE CacheLine;
1457  PINFCACHEFIELD CacheField;
1458  ULONG Index;
1459  PCHAR Ptr;
1460  SIZE_T Size;
1461 
1462  if ((Context == NULL) || (Context->Line == NULL))
1463  {
1464 // DPRINT("Invalid parameter\n");
1465  return FALSE;
1466  }
1467 
1468  if (RequiredSize != NULL)
1469  *RequiredSize = 0;
1470 
1471  CacheLine = (PINFCACHELINE)Context->Line;
1472 
1473  if (FieldIndex > CacheLine->FieldCount)
1474  return FALSE;
1475 
1476  if (FieldIndex == 0)
1477  {
1478  Ptr = CacheLine->Key;
1479  }
1480  else
1481  {
1482  CacheField = CacheLine->FirstField;
1483  for (Index = 1; Index < FieldIndex; Index++)
1484  CacheField = CacheField->Next;
1485 
1486  Ptr = CacheField->Data;
1487  }
1488 
1489  Size = strlen(Ptr) + 1;
1490 
1491  if (RequiredSize != NULL)
1492  *RequiredSize = (ULONG)Size;
1493 
1494  if (ReturnBuffer != NULL)
1495  {
1496  if (ReturnBufferSize < Size)
1497  return FALSE;
1498 
1499  strcpy(ReturnBuffer, Ptr);
1500  }
1501 
1502  return TRUE;
1503 }
signed char * PCHAR
Definition: retypes.h:7
#define TRUE
Definition: types.h:120
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
struct _INFCACHELINE * PINFCACHELINE
struct _INFCACHEFIELD * Next
Definition: inffile.c:47
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
ULONG FieldCount
Definition: inffile.c:58
_In_ DWORD _In_ DWORD ReturnBufferSize
Definition: setupapi.h:1891
PINFCACHEFIELD FirstField
Definition: inffile.c:62
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PRTL_BUFFER _In_ SIZE_T RequiredSize
if(!(yy_init))
Definition: macro.lex.yy.c:714
_In_ DWORD FieldIndex
Definition: setupapi.h:1889
static const UCHAR Index[8]
Definition: usbohci.c:18
CHAR Data[1]
Definition: inffile.c:50
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
ULONG_PTR SIZE_T
Definition: typedefs.h:78
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
unsigned int ULONG
Definition: retypes.h:1
PCHAR Key
Definition: inffile.c:60

◆ InfOpenFile()

BOOLEAN InfOpenFile ( PHINF  InfHandle,
PCSTR  FileName,
PULONG  ErrorLine 
)

Definition at line 936 of file inffile.c.

940 {
942  ULONG FileId;
943  PCHAR FileBuffer;
948 
949  *InfHandle = NULL;
950  *ErrorLine = (ULONG) - 1;
951 
952  //
953  // Open the .inf file
954  //
955  Status = ArcOpen((PCHAR)FileName, OpenReadOnly, &FileId);
956  if (Status != ESUCCESS)
957  {
958  return FALSE;
959  }
960 
961  //
962  // Query file size
963  //
965  if ((Status != ESUCCESS) || (Information.EndingAddress.HighPart != 0))
966  {
967  ArcClose(FileId);
968  return FALSE;
969  }
970  FileSize = Information.EndingAddress.LowPart;
971 
972  //
973  // Allocate buffer to cache the file
974  //
975  FileBuffer = FrLdrTempAlloc(FileSize + 1, TAG_INF_FILE);
976  if (!FileBuffer)
977  {
978  ArcClose(FileId);
979  return FALSE;
980  }
981 
982  //
983  // Read file into memory
984  //
985  Status = ArcRead(FileId, FileBuffer, FileSize, &Count);
986  if ((Status != ESUCCESS) || (Count != FileSize))
987  {
988  ArcClose(FileId);
989  FrLdrTempFree(FileBuffer, TAG_INF_FILE);
990  return FALSE;
991  }
992 
993  //
994  // We don't need the file anymore. Close it
995  //
996  ArcClose(FileId);
997 
998  //
999  // Append string terminator
1000  //
1001  FileBuffer[FileSize] = 0;
1002 
1003  //
1004  // Allocate infcache header
1005  //
1007  if (!Cache)
1008  {
1009  FrLdrTempFree(FileBuffer, TAG_INF_FILE);
1010  return FALSE;
1011  }
1012 
1013  //
1014  // Initialize inicache header
1015  //
1016  RtlZeroMemory(Cache, sizeof(INFCACHE));
1017 
1018  //
1019  // Parse the inf buffer
1020  //
1022  FileBuffer,
1023  FileBuffer + FileSize,
1024  ErrorLine);
1025  if (!Success)
1026  {
1028  Cache = NULL;
1029  }
1030 
1031  //
1032  // Free file buffer, as it has been parsed
1033  //
1034  FrLdrTempFree(FileBuffer, TAG_INF_FILE);
1035 
1036  //
1037  // Return .inf parsed contents
1038  //
1039  *InfHandle = (HINF)Cache;
1040 
1041  return Success;
1042 }
signed char * PCHAR
Definition: retypes.h:7
#define TAG_INF_CACHE
Definition: inffile.c:42
Definition: arc.h:32
Definition: fatfs.h:173
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
ULONG ARC_STATUS
Definition: arc.h:4
PVOID HINF
Definition: infsupp.h:21
FORCEINLINE PVOID FrLdrTempAlloc(_In_ SIZE_T Size, _In_ ULONG Tag)
Definition: mm.h:177
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
struct _INFCACHE * PINFCACHE
ARC_STATUS ArcRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
Definition: fs.c:237
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
Status
Definition: gdiplustypes.h:24
ARC_STATUS ArcClose(ULONG FileId)
Definition: fs.c:219
ARC_STATUS ArcGetFileInformation(ULONG FileId, FILEINFORMATION *Information)
Definition: fs.c:251
ARC_STATUS ArcOpen(CHAR *Path, OPENMODE OpenMode, ULONG *FileId)
Definition: fs.c:57
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
static BOOLEAN InfpParseBuffer(PINFCACHE file, PCCHAR buffer, PCCHAR end, PULONG error_line)
Definition: inffile.c:896
Iosb Information
Definition: create.c:4377
#define TAG_INF_FILE
Definition: inffile.c:43
FORCEINLINE VOID FrLdrTempFree(PVOID Allocation, ULONG Tag)
Definition: mm.h:186

Referenced by LoadReactOSSetup(), and SetupOpenInfFileExW().