ReactOS  0.4.13-dev-1165-gd2976ca
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 16 of file inffile.h.

◆ STATUS_BAD_SECTION_NAME_LINE

#define STATUS_BAD_SECTION_NAME_LINE   (0xC0700001)

Definition at line 11 of file inffile.h.

◆ STATUS_NOT_ENOUGH_MEMORY

#define STATUS_NOT_ENOUGH_MEMORY   (0xC0700004)

Definition at line 14 of file inffile.h.

◆ STATUS_SECTION_NAME_TOO_LONG

#define STATUS_SECTION_NAME_TOO_LONG   (0xC0700002)

Definition at line 12 of file inffile.h.

◆ STATUS_WRONG_INF_STYLE

#define STATUS_WRONG_INF_STYLE   (0xC0700003)

Definition at line 13 of file inffile.h.

Typedef Documentation

◆ HINF

typedef PULONG HINF

Definition at line 18 of file inffile.h.

◆ INFCONTEXT

◆ PHINF

typedef PULONG * PHINF

Definition at line 18 of file inffile.h.

◆ PINFCONTEXT

Function Documentation

◆ InfCloseFile()

VOID InfCloseFile ( HINF  InfHandle)

Definition at line 1028 of file inffile.c.

1029 {
1030  PINFCACHE Cache;
1031 
1032  Cache = (PINFCACHE)InfHandle;
1033 
1034  if (Cache == NULL)
1035  {
1036  return;
1037  }
1038 
1039  while (Cache->FirstSection != NULL)
1040  {
1041  Cache->FirstSection = InfpCacheFreeSection(Cache->FirstSection);
1042  }
1043  Cache->LastSection = NULL;
1044 
1046 }
#define TAG_INF_CACHE
Definition: inffile.c:24
Definition: fatfs.h:173
smooth NULL
Definition: ftsmooth.c:416
struct _INFCACHE * PINFCACHE
static PINFCACHESECTION InfpCacheFreeSection(PINFCACHESECTION Section)
Definition: inffile.c:170
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 1050 of file inffile.c.

1055 {
1056  PINFCACHE Cache;
1057  PINFCACHESECTION CacheSection;
1058  PINFCACHELINE CacheLine;
1059 
1060  if ((InfHandle == NULL) || (Section == NULL) || (Context == NULL))
1061  {
1062 // DPRINT("Invalid parameter\n");
1063  return FALSE;
1064  }
1065 
1066  Cache = (PINFCACHE)InfHandle;
1067 
1068  /* Iterate through list of sections */
1069  CacheSection = Cache->FirstSection;
1070  while (Section != NULL)
1071  {
1072 // DPRINT("Comparing '%S' and '%S'\n", CacheSection->Name, Section);
1073 
1074  /* Are the section names the same? */
1075  if (_stricmp(CacheSection->Name, Section) == 0)
1076  {
1077  if (Key != NULL)
1078  {
1079  CacheLine = InfpCacheFindKeyLine(CacheSection, Key);
1080  }
1081  else
1082  {
1083  CacheLine = CacheSection->FirstLine;
1084  }
1085 
1086  if (CacheLine == NULL)
1087  return FALSE;
1088 
1089  Context->Inf = (PVOID)Cache;
1090  Context->Section = (PVOID)CacheSection;
1091  Context->Line = (PVOID)CacheLine;
1092 
1093  return TRUE;
1094  }
1095 
1096  /* Get the next section */
1097  CacheSection = CacheSection->Next;
1098  }
1099 
1100 // DPRINT("Section not found\n");
1101 
1102  return FALSE;
1103 }
CHAR Name[1]
Definition: inffile.c:59
#define TRUE
Definition: types.h:120
Definition: fatfs.h:173
#define _stricmp
Definition: cat.c:22
struct _INFCACHESECTION * Next
Definition: inffile.c:51
smooth NULL
Definition: ftsmooth.c:416
void * PVOID
Definition: retypes.h:9
struct _INFCACHE * PINFCACHE
PINFCACHELINE FirstLine
Definition: inffile.c:54
static PINFCACHELINE InfpCacheFindKeyLine(PINFCACHESECTION Section, PCSTR Key)
Definition: inffile.c:368

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

◆ InfFindFirstMatchLine()

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

Definition at line 1135 of file inffile.c.

1139 {
1140  PINFCACHELINE CacheLine;
1141 
1142  if ((ContextIn == NULL) || (ContextOut == NULL) || (Key == NULL) || (*Key == 0))
1143  return FALSE;
1144 
1145  if (ContextIn->Inf == NULL || ContextIn->Section == NULL)
1146  return FALSE;
1147 
1148  CacheLine = ((PINFCACHESECTION)(ContextIn->Section))->FirstLine;
1149  while (CacheLine != NULL)
1150  {
1151  if ((CacheLine->Key != NULL) && (_stricmp(CacheLine->Key, Key) == 0))
1152  {
1153 
1154  if (ContextIn != ContextOut)
1155  {
1156  ContextOut->Inf = ContextIn->Inf;
1157  ContextOut->Section = ContextIn->Section;
1158  }
1159  ContextOut->Line = (PVOID)CacheLine;
1160 
1161  return TRUE;
1162  }
1163 
1164  CacheLine = CacheLine->Next;
1165  }
1166 
1167  return FALSE;
1168 }
#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:37
HINF Inf
Definition: infsupp.h:24
UINT Line
Definition: infsupp.h:27
PCHAR Key
Definition: inffile.c:42

◆ InfFindNextLine()

BOOLEAN InfFindNextLine ( PINFCONTEXT  ContextIn,
PINFCONTEXT  ContextOut 
)

Definition at line 1107 of file inffile.c.

1110 {
1111  PINFCACHELINE CacheLine;
1112 
1113  if ((ContextIn == NULL) || (ContextOut == NULL))
1114  return FALSE;
1115 
1116  if (ContextIn->Line == NULL)
1117  return FALSE;
1118 
1119  CacheLine = (PINFCACHELINE)ContextIn->Line;
1120  if (CacheLine->Next == NULL)
1121  return FALSE;
1122 
1123  if (ContextIn != ContextOut)
1124  {
1125  ContextOut->Inf = ContextIn->Inf;
1126  ContextOut->Section = ContextIn->Section;
1127  }
1128  ContextOut->Line = (PVOID)(CacheLine->Next);
1129 
1130  return TRUE;
1131 }
#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:37
HINF Inf
Definition: infsupp.h:24
UINT Line
Definition: infsupp.h:27

◆ InfFindNextMatchLine()

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

Definition at line 1172 of file inffile.c.

1176 {
1177  PINFCACHELINE CacheLine;
1178 
1179  if ((ContextIn == NULL) || (ContextOut == NULL) || (Key == NULL) || (*Key == 0))
1180  return FALSE;
1181 
1182  if ((ContextIn->Inf == NULL) || (ContextIn->Section == NULL) || (ContextIn->Line == NULL))
1183  return FALSE;
1184 
1185  CacheLine = (PINFCACHELINE)ContextIn->Line;
1186  while (CacheLine != NULL)
1187  {
1188  if ((CacheLine->Key != NULL) && (_stricmp(CacheLine->Key, Key) == 0))
1189  {
1190 
1191  if (ContextIn != ContextOut)
1192  {
1193  ContextOut->Inf = ContextIn->Inf;
1194  ContextOut->Section = ContextIn->Section;
1195  }
1196  ContextOut->Line = (PVOID)CacheLine;
1197 
1198  return TRUE;
1199  }
1200 
1201  CacheLine = CacheLine->Next;
1202  }
1203 
1204  return FALSE;
1205 }
#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:37
HINF Inf
Definition: infsupp.h:24
UINT Line
Definition: infsupp.h:27
PCHAR Key
Definition: inffile.c:42

◆ InfGetBinaryField()

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

Definition at line 1260 of file inffile.c.

1266 {
1267  PINFCACHELINE CacheLine;
1268  PINFCACHEFIELD CacheField;
1269  ULONG Index;
1270  ULONG Size;
1271  PUCHAR Ptr;
1272 
1273  if ((Context == NULL) || (Context->Line == NULL) || (FieldIndex == 0))
1274  {
1275 // DPRINT("Invalid parameter\n");
1276  return FALSE;
1277  }
1278 
1279  if (RequiredSize != NULL)
1280  *RequiredSize = 0;
1281 
1282  CacheLine = (PINFCACHELINE)Context->Line;
1283 
1284  if (FieldIndex > CacheLine->FieldCount)
1285  return FALSE;
1286 
1287  CacheField = CacheLine->FirstField;
1288  for (Index = 1; Index < FieldIndex; Index++)
1289  CacheField = CacheField->Next;
1290 
1291  Size = CacheLine->FieldCount - FieldIndex + 1;
1292 
1293  if (RequiredSize != NULL)
1294  *RequiredSize = Size;
1295 
1296  if (ReturnBuffer != NULL)
1297  {
1298  if (ReturnBufferSize < Size)
1299  return FALSE;
1300 
1301  /* Copy binary data */
1302  Ptr = ReturnBuffer;
1303  while (CacheField != NULL)
1304  {
1305  *Ptr = (UCHAR)atoi(CacheField->Data); //strtoul(CacheField->Data, NULL, 16);
1306 
1307  Ptr++;
1308  CacheField = CacheField->Next;
1309  }
1310  }
1311 
1312  return TRUE;
1313 }
#define TRUE
Definition: types.h:120
struct _INFCACHELINE * PINFCACHELINE
struct _INFCACHEFIELD * Next
Definition: inffile.c:29
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:40
_In_ DWORD _In_ DWORD ReturnBufferSize
Definition: setupapi.h:1892
PINFCACHEFIELD FirstField
Definition: inffile.c:44
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:1890
static const UCHAR Index[8]
Definition: usbohci.c:18
unsigned char UCHAR
Definition: xmlstorage.h:181
CHAR Data[1]
Definition: inffile.c:32
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 1491 of file inffile.c.

1495 {
1496  PINFCACHELINE CacheKey;
1497 
1498  if ((Context == NULL) || (Context->Line == NULL) || (Data == NULL))
1499  {
1500 // DPRINT("Invalid parameter\n");
1501  return FALSE;
1502  }
1503 
1504  CacheKey = (PINFCACHELINE)Context->Line;
1505  if (Key != NULL)
1506  *Key = CacheKey->Key;
1507 
1508  if (Data != NULL)
1509  {
1510  if (CacheKey->FirstField == NULL)
1511  {
1512  *Data = NULL;
1513  }
1514  else
1515  {
1516  *Data = CacheKey->FirstField->Data;
1517  }
1518  }
1519 
1520  return TRUE;
1521 }
#define TRUE
Definition: types.h:120
struct _INFCACHELINE * PINFCACHELINE
PINFCACHEFIELD FirstField
Definition: inffile.c:44
smooth NULL
Definition: ftsmooth.c:416
if(!(yy_init))
Definition: macro.lex.yy.c:714
CHAR Data[1]
Definition: inffile.c:32
PCHAR Key
Definition: inffile.c:42

◆ InfGetDataField()

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

Definition at line 1525 of file inffile.c.

1529 {
1530  PINFCACHELINE CacheLine;
1531  PINFCACHEFIELD CacheField;
1532  ULONG Index;
1533 
1534  if ((Context == NULL) || (Context->Line == NULL) || (Data == NULL))
1535  {
1536 // DPRINT("Invalid parameter\n");
1537  return FALSE;
1538  }
1539 
1540  CacheLine = (PINFCACHELINE)Context->Line;
1541 
1542  if (FieldIndex > CacheLine->FieldCount)
1543  return FALSE;
1544 
1545  if (FieldIndex == 0)
1546  {
1547  *Data = CacheLine->Key;
1548  }
1549  else
1550  {
1551  CacheField = CacheLine->FirstField;
1552  for (Index = 1; Index < FieldIndex; Index++)
1553  CacheField = CacheField->Next;
1554 
1555  *Data = CacheField->Data;
1556  }
1557 
1558  return TRUE;
1559 }
#define TRUE
Definition: types.h:120
struct _INFCACHELINE * PINFCACHELINE
struct _INFCACHEFIELD * Next
Definition: inffile.c:29
ULONG FieldCount
Definition: inffile.c:40
PINFCACHEFIELD FirstField
Definition: inffile.c:44
smooth NULL
Definition: ftsmooth.c:416
if(!(yy_init))
Definition: macro.lex.yy.c:714
_In_ DWORD FieldIndex
Definition: setupapi.h:1890
static const UCHAR Index[8]
Definition: usbohci.c:18
CHAR Data[1]
Definition: inffile.c:32
unsigned int ULONG
Definition: retypes.h:1
PCHAR Key
Definition: inffile.c:42

◆ InfGetFieldCount()

LONG InfGetFieldCount ( PINFCONTEXT  Context)

Definition at line 1250 of file inffile.c.

1251 {
1252  if ((Context == NULL) || (Context->Line == NULL))
1253  return 0;
1254 
1255  return ((PINFCACHELINE)Context->Line)->FieldCount;
1256 }
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 1209 of file inffile.c.

1212 {
1213  PINFCACHE Cache;
1214  PINFCACHESECTION CacheSection;
1215 
1216  if ((InfHandle == NULL) || (Section == NULL))
1217  {
1218 // DPRINT("Invalid parameter\n");
1219  return -1;
1220  }
1221 
1222  Cache = (PINFCACHE)InfHandle;
1223 
1224  /* Iterate through list of sections */
1225  CacheSection = Cache->FirstSection;
1226  while (Section != NULL)
1227  {
1228 // DPRINT("Comparing '%S' and '%S'\n", CacheSection->Name, Section);
1229 
1230  /* Are the section names the same? */
1231  if (_stricmp(CacheSection->Name, Section) == 0)
1232  {
1233  return CacheSection->LineCount;
1234  }
1235 
1236  /* Get the next section */
1237  CacheSection = CacheSection->Next;
1238  }
1239 
1240 // DPRINT("Section not found\n");
1241 
1242  return -1;
1243 }
LONG LineCount
Definition: inffile.c:57
CHAR Name[1]
Definition: inffile.c:59
Definition: fatfs.h:173
#define _stricmp
Definition: cat.c:22
struct _INFCACHESECTION * Next
Definition: inffile.c:51
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 1361 of file inffile.c.

1367 {
1368  PINFCACHELINE CacheLine;
1369  PINFCACHEFIELD CacheField;
1370  PINFCACHEFIELD FieldPtr;
1371  ULONG Index;
1372  SIZE_T Size;
1373  PCHAR Ptr;
1374 
1375  if ((Context == NULL) || (Context->Line == NULL) || (FieldIndex == 0))
1376  {
1377 // DPRINT("Invalid parameter\n");
1378  return FALSE;
1379  }
1380 
1381  if (RequiredSize != NULL)
1382  *RequiredSize = 0;
1383 
1384  CacheLine = (PINFCACHELINE)Context->Line;
1385 
1386  if (FieldIndex > CacheLine->FieldCount)
1387  return FALSE;
1388 
1389  CacheField = CacheLine->FirstField;
1390  for (Index = 1; Index < FieldIndex; Index++)
1391  CacheField = CacheField->Next;
1392 
1393  /* Calculate the required buffer size */
1394  FieldPtr = CacheField;
1395  Size = 0;
1396  while (FieldPtr != NULL)
1397  {
1398  Size += (strlen(FieldPtr->Data) + 1);
1399  FieldPtr = FieldPtr->Next;
1400  }
1401  Size++;
1402 
1403  if (RequiredSize != NULL)
1404  *RequiredSize = (ULONG)Size;
1405 
1406  if (ReturnBuffer != NULL)
1407  {
1408  if (ReturnBufferSize < Size)
1409  return FALSE;
1410 
1411  /* Copy multi-sz string */
1412  Ptr = ReturnBuffer;
1413  FieldPtr = CacheField;
1414  while (FieldPtr != NULL)
1415  {
1416  Size = strlen(FieldPtr->Data) + 1;
1417 
1418  strcpy(Ptr, FieldPtr->Data);
1419 
1420  Ptr = Ptr + Size;
1421  FieldPtr = FieldPtr->Next;
1422  }
1423  *Ptr = 0;
1424  }
1425 
1426  return TRUE;
1427 }
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:29
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
ULONG FieldCount
Definition: inffile.c:40
_In_ DWORD _In_ DWORD ReturnBufferSize
Definition: setupapi.h:1892
while(1)
Definition: macro.lex.yy.c:740
PINFCACHEFIELD FirstField
Definition: inffile.c:44
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:1890
static const UCHAR Index[8]
Definition: usbohci.c:18
CHAR Data[1]
Definition: inffile.c:32
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 1431 of file inffile.c.

1437 {
1438  PINFCACHELINE CacheLine;
1439  PINFCACHEFIELD CacheField;
1440  ULONG Index;
1441  PCHAR Ptr;
1442  SIZE_T Size;
1443 
1444  if ((Context == NULL) || (Context->Line == NULL))
1445  {
1446 // DPRINT("Invalid parameter\n");
1447  return FALSE;
1448  }
1449 
1450  if (RequiredSize != NULL)
1451  *RequiredSize = 0;
1452 
1453  CacheLine = (PINFCACHELINE)Context->Line;
1454 
1455  if (FieldIndex > CacheLine->FieldCount)
1456  return FALSE;
1457 
1458  if (FieldIndex == 0)
1459  {
1460  Ptr = CacheLine->Key;
1461  }
1462  else
1463  {
1464  CacheField = CacheLine->FirstField;
1465  for (Index = 1; Index < FieldIndex; Index++)
1466  CacheField = CacheField->Next;
1467 
1468  Ptr = CacheField->Data;
1469  }
1470 
1471  Size = strlen(Ptr) + 1;
1472 
1473  if (RequiredSize != NULL)
1474  *RequiredSize = (ULONG)Size;
1475 
1476  if (ReturnBuffer != NULL)
1477  {
1478  if (ReturnBufferSize < Size)
1479  return FALSE;
1480 
1481  strcpy(ReturnBuffer, Ptr);
1482  }
1483 
1484  return TRUE;
1485 }
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:29
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
ULONG FieldCount
Definition: inffile.c:40
_In_ DWORD _In_ DWORD ReturnBufferSize
Definition: setupapi.h:1892
PINFCACHEFIELD FirstField
Definition: inffile.c:44
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:1890
static const UCHAR Index[8]
Definition: usbohci.c:18
CHAR Data[1]
Definition: inffile.c:32
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:42

◆ InfOpenFile()

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

Definition at line 918 of file inffile.c.

922 {
924  ULONG FileId;
925  PCHAR FileBuffer;
930 
931  *InfHandle = NULL;
932  *ErrorLine = (ULONG) - 1;
933 
934  //
935  // Open the .inf file
936  //
937  Status = ArcOpen((PSTR)FileName, OpenReadOnly, &FileId);
938  if (Status != ESUCCESS)
939  {
940  return FALSE;
941  }
942 
943  //
944  // Query file size
945  //
947  if ((Status != ESUCCESS) || (Information.EndingAddress.HighPart != 0))
948  {
949  ArcClose(FileId);
950  return FALSE;
951  }
952  FileSize = Information.EndingAddress.LowPart;
953 
954  //
955  // Allocate buffer to cache the file
956  //
957  FileBuffer = FrLdrTempAlloc(FileSize + 1, TAG_INF_FILE);
958  if (!FileBuffer)
959  {
960  ArcClose(FileId);
961  return FALSE;
962  }
963 
964  //
965  // Read file into memory
966  //
967  Status = ArcRead(FileId, FileBuffer, FileSize, &Count);
968  if ((Status != ESUCCESS) || (Count != FileSize))
969  {
970  ArcClose(FileId);
971  FrLdrTempFree(FileBuffer, TAG_INF_FILE);
972  return FALSE;
973  }
974 
975  //
976  // We don't need the file anymore. Close it
977  //
978  ArcClose(FileId);
979 
980  //
981  // Append string terminator
982  //
983  FileBuffer[FileSize] = 0;
984 
985  //
986  // Allocate infcache header
987  //
989  if (!Cache)
990  {
991  FrLdrTempFree(FileBuffer, TAG_INF_FILE);
992  return FALSE;
993  }
994 
995  //
996  // Initialize inicache header
997  //
998  RtlZeroMemory(Cache, sizeof(INFCACHE));
999 
1000  //
1001  // Parse the inf buffer
1002  //
1004  FileBuffer,
1005  FileBuffer + FileSize,
1006  ErrorLine);
1007  if (!Success)
1008  {
1010  Cache = NULL;
1011  }
1012 
1013  //
1014  // Free file buffer, as it has been parsed
1015  //
1016  FrLdrTempFree(FileBuffer, TAG_INF_FILE);
1017 
1018  //
1019  // Return .inf parsed contents
1020  //
1021  *InfHandle = (HINF)Cache;
1022 
1023  return Success;
1024 }
signed char * PCHAR
Definition: retypes.h:7
#define TAG_INF_CACHE
Definition: inffile.c:24
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:236
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
Status
Definition: gdiplustypes.h:24
signed char * PSTR
Definition: retypes.h:7
ARC_STATUS ArcClose(ULONG FileId)
Definition: fs.c:218
ARC_STATUS ArcGetFileInformation(ULONG FileId, FILEINFORMATION *Information)
Definition: fs.c:250
ARC_STATUS ArcOpen(CHAR *Path, OPENMODE OpenMode, ULONG *FileId)
Definition: fs.c:56
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:878
Iosb Information
Definition: create.c:4377
#define TAG_INF_FILE
Definition: inffile.c:25
FORCEINLINE VOID FrLdrTempFree(PVOID Allocation, ULONG Tag)
Definition: mm.h:186

Referenced by LoadReactOSSetup(), and SetupOpenInfFileExW().