ReactOS  0.4.13-dev-443-g10f00f8
infros.h File Reference
#include <infcommon.h>
Include dependency graph for infros.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

VOID InfSetHeap (PVOID Heap)
 
NTSTATUS InfOpenBufferedFile (PHINF InfHandle, PVOID Buffer, ULONG BufferSize, LANGID LanguageId, PULONG ErrorLine)
 
NTSTATUS InfOpenFile (PHINF InfHandle, PUNICODE_STRING FileName, LANGID LanguageId, PULONG ErrorLine)
 
NTSTATUS InfWriteFile (HINF InfHandle, PUNICODE_STRING FileName, PUNICODE_STRING HeaderComment)
 
VOID InfCloseFile (HINF InfHandle)
 
BOOLEAN InfFindFirstLine (HINF InfHandle, PCWSTR Section, PCWSTR Key, PINFCONTEXT *Context)
 
BOOLEAN InfFindNextLine (PINFCONTEXT ContextIn, PINFCONTEXT ContextOut)
 
BOOLEAN InfFindFirstMatchLine (PINFCONTEXT ContextIn, PCWSTR Key, PINFCONTEXT ContextOut)
 
BOOLEAN InfFindNextMatchLine (PINFCONTEXT ContextIn, PCWSTR Key, PINFCONTEXT ContextOut)
 
LONG InfGetLineCount (HINF InfHandle, PCWSTR Section)
 
LONG InfGetFieldCount (PINFCONTEXT Context)
 
BOOLEAN InfGetBinaryField (PINFCONTEXT Context, ULONG FieldIndex, PUCHAR ReturnBuffer, ULONG ReturnBufferSize, PULONG RequiredSize)
 
BOOLEAN InfGetIntField (PINFCONTEXT Context, ULONG FieldIndex, INT *IntegerValue)
 
BOOLEAN InfGetMultiSzField (PINFCONTEXT Context, ULONG FieldIndex, PWSTR ReturnBuffer, ULONG ReturnBufferSize, PULONG RequiredSize)
 
BOOLEAN InfGetStringField (PINFCONTEXT Context, ULONG FieldIndex, PWSTR ReturnBuffer, ULONG ReturnBufferSize, PULONG RequiredSize)
 
BOOLEAN InfGetData (PINFCONTEXT Context, PWCHAR *Key, PWCHAR *Data)
 
BOOLEAN InfGetDataField (PINFCONTEXT Context, ULONG FieldIndex, PWCHAR *Data)
 
BOOLEAN InfFindOrAddSection (HINF InfHandle, PCWSTR Section, PINFCONTEXT *Context)
 
BOOLEAN InfAddLine (PINFCONTEXT Context, PCWSTR Key)
 
BOOLEAN InfAddField (PINFCONTEXT Context, PCWSTR Data)
 
VOID InfFreeContext (PINFCONTEXT Context)
 

Function Documentation

◆ InfAddField()

BOOLEAN InfAddField ( PINFCONTEXT  Context,
PCWSTR  Data 
)

◆ InfAddLine()

BOOLEAN InfAddLine ( PINFCONTEXT  Context,
PCWSTR  Key 
)

◆ 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,
PCWSTR  Section,
PCWSTR  Key,
PINFCONTEXT Context 
)

Definition at line 19 of file infrosget.c.

23 {
24  return INF_SUCCESS(InfpFindFirstLine(InfHandle, Section, Key, Context));
25 }
#define INF_SUCCESS(x)
Definition: builddep.h:82
INFSTATUS InfpFindFirstLine(PINFCACHE Cache, PCWSTR Section, PCWSTR Key, PINFCONTEXT *Context)
Definition: infget.c:173

◆ InfFindFirstMatchLine()

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

Definition at line 37 of file infrosget.c.

40 {
41  return INF_SUCCESS(InfpFindFirstMatchLine(ContextIn, Key, ContextOut));
42 }
#define INF_SUCCESS(x)
Definition: builddep.h:82
INFSTATUS InfpFindFirstMatchLine(PINFCONTEXT ContextIn, PCWSTR Key, PINFCONTEXT ContextOut)
Definition: infget.c:251

◆ 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,
PCWSTR  Key,
PINFCONTEXT  ContextOut 
)

Definition at line 46 of file infrosget.c.

49 {
50  return INF_SUCCESS(InfpFindNextMatchLine(ContextIn, Key, ContextOut));
51 }
#define INF_SUCCESS(x)
Definition: builddep.h:82
INFSTATUS InfpFindNextMatchLine(PINFCONTEXT ContextIn, PCWSTR Key, PINFCONTEXT ContextOut)
Definition: infget.c:287

◆ InfFindOrAddSection()

BOOLEAN InfFindOrAddSection ( HINF  InfHandle,
PCWSTR  Section,
PINFCONTEXT Context 
)

Definition at line 111 of file infrosput.c.

114 {
115  return INF_SUCCESS(InfpFindOrAddSection((PINFCACHE) InfHandle,
116  Section, Context));
117 }
#define INF_SUCCESS(x)
Definition: builddep.h:82
INFSTATUS InfpFindOrAddSection(PINFCACHE Cache, PCWSTR Section, PINFCONTEXT *Context)
Definition: infput.c:190

◆ InfFreeContext()

VOID InfFreeContext ( PINFCONTEXT  Context)

Definition at line 135 of file infrosget.c.

136 {
138 }
VOID InfpFreeContext(PINFCONTEXT Context)
Definition: infget.c:673

Referenced by SetupFindFirstLineW().

◆ 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,
PWCHAR Key,
PWCHAR Data 
)

Definition at line 118 of file infrosget.c.

121 {
123 }
#define INF_SUCCESS(x)
Definition: builddep.h:82
INFSTATUS InfpGetData(PINFCONTEXT Context, PWCHAR *Key, PWCHAR *Data)
Definition: infget.c:604

◆ InfGetDataField()

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

Definition at line 127 of file infrosget.c.

130 {
132 }
#define INF_SUCCESS(x)
Definition: builddep.h:82
INFSTATUS InfpGetDataField(PINFCONTEXT Context, ULONG FieldIndex, PWCHAR *Data)
Definition: infget.c:637
_In_ DWORD FieldIndex
Definition: setupapi.h:1889

◆ 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,
INT IntegerValue 
)

Definition at line 1335 of file inffile.c.

1339 {
1340  PINFCACHELINE CacheLine;
1341  PINFCACHEFIELD CacheField;
1342  ULONG Index;
1343  PCHAR Ptr;
1344 
1345  if ((Context == NULL) || (Context->Line == NULL) || (IntegerValue == NULL))
1346  {
1347 // DPRINT("Invalid parameter\n");
1348  return FALSE;
1349  }
1350 
1351  CacheLine = (PINFCACHELINE)Context->Line;
1352 
1353  if (FieldIndex > CacheLine->FieldCount)
1354  {
1355 // DPRINT("Invalid parameter\n");
1356  return FALSE;
1357  }
1358 
1359  if (FieldIndex == 0)
1360  {
1361  Ptr = CacheLine->Key;
1362  }
1363  else
1364  {
1365  CacheField = CacheLine->FirstField;
1366  for (Index = 1; Index < FieldIndex; Index++)
1367  CacheField = CacheField->Next;
1368 
1369  Ptr = CacheField->Data;
1370  }
1371 
1372  *IntegerValue = atoi(Ptr); //strtol(Ptr, NULL, 0);
1373 
1374  return TRUE;
1375 }
signed char * PCHAR
Definition: retypes.h:7
#define TRUE
Definition: types.h:120
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
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
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
unsigned int ULONG
Definition: retypes.h:1
PCHAR Key
Definition: inffile.c:60

◆ InfGetLineCount()

LONG InfGetLineCount ( HINF  InfHandle,
PCWSTR  Section 
)

Definition at line 55 of file infrosget.c.

57 {
58  return InfpGetLineCount(InfHandle, Section);
59 }
LONG InfpGetLineCount(HINF InfHandle, PCWSTR Section)
Definition: infget.c:323

◆ InfGetMultiSzField()

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

Definition at line 94 of file infrosget.c.

99 {
100  return INF_SUCCESS(InfpGetMultiSzField(Context, FieldIndex, ReturnBuffer,
102 }
#define INF_SUCCESS(x)
Definition: builddep.h:82
_In_ DWORD _In_ DWORD ReturnBufferSize
Definition: setupapi.h:1891
_Inout_ PRTL_BUFFER _In_ SIZE_T RequiredSize
_In_ DWORD FieldIndex
Definition: setupapi.h:1889
INFSTATUS InfpGetMultiSzField(PINFCONTEXT Context, ULONG FieldIndex, PWSTR ReturnBuffer, ULONG ReturnBufferSize, PULONG RequiredSize)
Definition: infget.c:470

◆ InfGetStringField()

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

Definition at line 106 of file infrosget.c.

111 {
112  return INF_SUCCESS(InfpGetStringField(Context, FieldIndex, ReturnBuffer,
114 }
#define INF_SUCCESS(x)
Definition: builddep.h:82
_In_ DWORD _In_ DWORD ReturnBufferSize
Definition: setupapi.h:1891
INFSTATUS InfpGetStringField(PINFCONTEXT Context, ULONG FieldIndex, PWSTR ReturnBuffer, ULONG ReturnBufferSize, PULONG RequiredSize)
Definition: infget.c:539
_Inout_ PRTL_BUFFER _In_ SIZE_T RequiredSize
_In_ DWORD FieldIndex
Definition: setupapi.h:1889

◆ InfOpenBufferedFile()

NTSTATUS InfOpenBufferedFile ( PHINF  InfHandle,
PVOID  Buffer,
ULONG  BufferSize,
LANGID  LanguageId,
PULONG  ErrorLine 
)

Definition at line 51 of file infrosgen.c.

56 {
59  PCHAR FileBuffer;
60  ULONG FileBufferSize;
61 
62  CheckHeap();
63 
64  *InfHandle = NULL;
65  *ErrorLine = (ULONG)-1;
66 
67  /* Allocate file buffer */
68  FileBufferSize = BufferSize + 2;
69  FileBuffer = MALLOC(FileBufferSize);
70  if (FileBuffer == NULL)
71  {
72  DPRINT1("MALLOC() failed\n");
74  }
75 
76  MEMCPY(FileBuffer, Buffer, BufferSize);
77 
78  /* Append string terminator */
79  FileBuffer[BufferSize] = 0;
80  FileBuffer[BufferSize + 1] = 0;
81 
82  /* Allocate infcache header */
83  Cache = (PINFCACHE)MALLOC(sizeof(INFCACHE));
84  if (Cache == NULL)
85  {
86  DPRINT("MALLOC() failed\n");
87  FREE(FileBuffer);
89  }
90 
91  /* Initialize inicache header */
93  sizeof(INFCACHE));
94 
95  Cache->LanguageId = LanguageId;
96 
97  /* Parse the inf buffer */
98  if (!RtlIsTextUnicode(FileBuffer, FileBufferSize, NULL))
99  {
100 // static const BYTE utf8_bom[3] = { 0xef, 0xbb, 0xbf };
101  WCHAR *new_buff;
102 // UINT codepage = CP_ACP;
103  UINT offset = 0;
104 
105 // if (BufferSize > sizeof(utf8_bom) && !memcmp(FileBuffer, utf8_bom, sizeof(utf8_bom) ))
106 // {
107 // codepage = CP_UTF8;
108 // offset = sizeof(utf8_bom);
109 // }
110 
111  new_buff = MALLOC(FileBufferSize * sizeof(WCHAR));
112  if (new_buff != NULL)
113  {
114  ULONG len;
115  Status = RtlMultiByteToUnicodeN(new_buff,
116  FileBufferSize * sizeof(WCHAR),
117  &len,
118  (char *)FileBuffer + offset,
119  FileBufferSize - offset);
120 
122  new_buff,
123  new_buff + len / sizeof(WCHAR),
124  ErrorLine);
125  FREE(new_buff);
126  }
127  else
129  }
130  else
131  {
132  WCHAR *new_buff = (WCHAR *)FileBuffer;
133  /* UCS-16 files should start with the Unicode BOM; we should skip it */
134  if (*new_buff == 0xfeff)
135  {
136  new_buff++;
137  FileBufferSize -= sizeof(WCHAR);
138  }
140  new_buff,
141  (WCHAR*)((char*)new_buff + FileBufferSize),
142  ErrorLine);
143  }
144 
145  if (!INF_SUCCESS(Status))
146  {
147  FREE(Cache);
148  Cache = NULL;
149  }
150 
151  /* Free file buffer */
152  FREE(FileBuffer);
153 
154  *InfHandle = (HINF)Cache;
155 
156  return(Status);
157 }
signed char * PCHAR
Definition: retypes.h:7
#define INF_SUCCESS(x)
Definition: builddep.h:82
#define MALLOC(Size)
Definition: builddep.h:73
Definition: fatfs.h:173
NTSYSAPI NTSTATUS WINAPI RtlMultiByteToUnicodeN(LPWSTR, DWORD, LPDWORD, LPCSTR, DWORD)
#define INF_STATUS_INSUFFICIENT_RESOURCES
Definition: infpriv.h:15
GLintptr offset
Definition: glext.h:5920
PVOID HINF
Definition: infsupp.h:21
int INFSTATUS
Definition: infpriv.h:73
NTSYSAPI BOOLEAN NTAPI RtlIsTextUnicode(_In_ CONST VOID *Buffer, _In_ INT Size, _Inout_opt_ INT *Flags)
static VOID CheckHeap(VOID)
Definition: infrosgen.c:22
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MEMCPY(DST, SRC, BYTES)
Definition: macros.h:231
struct _INFCACHE * PINFCACHE
#define BufferSize
Definition: classpnp.h:419
#define FREE(ptr, size)
Definition: auth_des.c:64
GLenum GLsizei len
Definition: glext.h:6722
Status
Definition: gdiplustypes.h:24
unsigned int UINT
Definition: ndis.h:50
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
static BOOLEAN InfpParseBuffer(PINFCACHE file, PCCHAR buffer, PCCHAR end, PULONG error_line)
Definition: inffile.c:896
#define ZEROMEMORY(Area, Size)
Definition: builddep.h:74

Referenced by INF_OpenBufferedFileA().

◆ InfOpenFile()

NTSTATUS InfOpenFile ( PHINF  InfHandle,
PUNICODE_STRING  FileName,
LANGID  LanguageId,
PULONG  ErrorLine 
)

Definition at line 161 of file infrosgen.c.

165 {
171  PCHAR FileBuffer;
173  ULONG FileBufferLength;
176 
177  CheckHeap();
178 
179  *InfHandle = NULL;
180  *ErrorLine = (ULONG)-1;
181 
182  /* Open the inf file */
184  FileName,
185  0,
186  NULL,
187  NULL);
188 
192  &IoStatusBlock,
195  if (!INF_SUCCESS(Status))
196  {
197  DPRINT("NtOpenFile() failed (Status %lx)\n", Status);
198  return(Status);
199  }
200 
201  DPRINT("NtOpenFile() successful\n");
202 
203  /* Query file size */
205  &IoStatusBlock,
206  &FileInfo,
209  if (!INF_SUCCESS(Status))
210  {
211  DPRINT("NtQueryInformationFile() failed (Status %lx)\n", Status);
213  return(Status);
214  }
215 
216  FileLength = FileInfo.EndOfFile.u.LowPart;
217 
218  DPRINT("File size: %lu\n", FileLength);
219 
220  /* Allocate file buffer */
221  FileBufferLength = FileLength + 2;
222  FileBuffer = MALLOC(FileBufferLength);
223  if (FileBuffer == NULL)
224  {
225  DPRINT1("MALLOC() failed\n");
228  }
229 
230  /* Read file */
231  FileOffset.QuadPart = 0ULL;
233  NULL,
234  NULL,
235  NULL,
236  &IoStatusBlock,
237  FileBuffer,
238  FileLength,
239  &FileOffset,
240  NULL);
241 
242  /* Append string terminator */
243  FileBuffer[FileLength] = 0;
244  FileBuffer[FileLength + 1] = 0;
245 
247 
248  if (!INF_SUCCESS(Status))
249  {
250  DPRINT("NtReadFile() failed (Status %lx)\n", Status);
251  FREE(FileBuffer);
252  return(Status);
253  }
254 
255  /* Allocate infcache header */
256  Cache = (PINFCACHE)MALLOC(sizeof(INFCACHE));
257  if (Cache == NULL)
258  {
259  DPRINT("MALLOC() failed\n");
260  FREE(FileBuffer);
262  }
263 
264  /* Initialize inicache header */
266  sizeof(INFCACHE));
267 
268  Cache->LanguageId = LanguageId;
269 
270  /* Parse the inf buffer */
271  if (!RtlIsTextUnicode(FileBuffer, FileBufferLength, NULL))
272  {
273 // static const BYTE utf8_bom[3] = { 0xef, 0xbb, 0xbf };
274  WCHAR *new_buff;
275 // UINT codepage = CP_ACP;
276  UINT offset = 0;
277 
278 // if (FileLength > sizeof(utf8_bom) && !memcmp(FileBuffer, utf8_bom, sizeof(utf8_bom) ))
279 // {
280 // codepage = CP_UTF8;
281 // offset = sizeof(utf8_bom);
282 // }
283 
284  new_buff = MALLOC(FileBufferLength * sizeof(WCHAR));
285  if (new_buff != NULL)
286  {
287  ULONG len;
288  Status = RtlMultiByteToUnicodeN(new_buff,
289  FileBufferLength * sizeof(WCHAR),
290  &len,
291  (char *)FileBuffer + offset,
292  FileBufferLength - offset);
293 
295  new_buff,
296  new_buff + len / sizeof(WCHAR),
297  ErrorLine);
298  FREE(new_buff);
299  }
300  else
302  }
303  else
304  {
305  WCHAR *new_buff = (WCHAR *)FileBuffer;
306  /* UCS-16 files should start with the Unicode BOM; we should skip it */
307  if (*new_buff == 0xfeff)
308  {
309  new_buff++;
310  FileBufferLength -= sizeof(WCHAR);
311  }
313  new_buff,
314  (WCHAR*)((char*)new_buff + FileBufferLength),
315  ErrorLine);
316  }
317 
318  if (!INF_SUCCESS(Status))
319  {
320  FREE(Cache);
321  Cache = NULL;
322  }
323 
324  /* Free file buffer */
325  FREE(FileBuffer);
326 
327  *InfHandle = (HINF)Cache;
328 
329  return(Status);
330 }
signed char * PCHAR
Definition: retypes.h:7
#define INF_SUCCESS(x)
Definition: builddep.h:82
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
_Out_ PNDIS_HANDLE _Out_ PUINT FileLength
Definition: ndis.h:3227
#define MALLOC(Size)
Definition: builddep.h:73
Definition: fatfs.h:173
NTSYSAPI NTSTATUS WINAPI RtlMultiByteToUnicodeN(LPWSTR, DWORD, LPDWORD, LPCSTR, DWORD)
LONG NTSTATUS
Definition: precomp.h:26
#define INF_STATUS_INSUFFICIENT_RESOURCES
Definition: infpriv.h:15
GLintptr offset
Definition: glext.h:5920
PVOID HINF
Definition: infsupp.h:21
#define FILE_SHARE_READ
Definition: compat.h:125
HANDLE FileHandle
Definition: stats.c:38
NTSYSAPI BOOLEAN NTAPI RtlIsTextUnicode(_In_ CONST VOID *Buffer, _In_ INT Size, _Inout_opt_ INT *Flags)
static VOID CheckHeap(VOID)
Definition: infrosgen.c:22
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define ULL(a, b)
Definition: format_msg.c:27
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
Definition: file.c:3951
__wchar_t WCHAR
Definition: xmlstorage.h:180
struct _INFCACHE * PINFCACHE
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
#define FREE(ptr, size)
Definition: auth_des.c:64
#define FILE_NON_DIRECTORY_FILE
Definition: constants.h:492
GLenum GLsizei len
Definition: glext.h:6722
#define GENERIC_READ
Definition: compat.h:124
NTSTATUS NTAPI NtQueryInformationFile(HANDLE hFile, PIO_STATUS_BLOCK io, PVOID ptr, ULONG len, FILE_INFORMATION_CLASS FileInformationClass)
#define SYNCHRONIZE
Definition: nt_native.h:61
Status
Definition: gdiplustypes.h:24
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:151
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
unsigned int UINT
Definition: ndis.h:50
#define DPRINT1
Definition: precomp.h:8
#define FileStandardInformation
Definition: propsheet.cpp:61
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
struct FileInfo FileInfo
unsigned int ULONG
Definition: retypes.h:1
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
static BOOLEAN InfpParseBuffer(PINFCACHE file, PCCHAR buffer, PCCHAR end, PULONG error_line)
Definition: inffile.c:896
#define ZEROMEMORY(Area, Size)
Definition: builddep.h:74
NTSTATUS NTAPI NtReadFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer, ULONG Length, PLARGE_INTEGER ByteOffset, PULONG Key)

◆ InfSetHeap()

VOID InfSetHeap ( PVOID  Heap)

Definition at line 40 of file infrosgen.c.

41 {
42  if (NULL == InfpHeap)
43  {
44  InfpHeap = Heap;
45  InfpHeapRefCount = -1;
46  }
47 }
PVOID InfpHeap
Definition: infrosgen.c:37
smooth NULL
Definition: ftsmooth.c:416
static int InfpHeapRefCount
Definition: infrosgen.c:19

Referenced by RunUSetup().

◆ InfWriteFile()

NTSTATUS InfWriteFile ( HINF  InfHandle,
PUNICODE_STRING  FileName,
PUNICODE_STRING  HeaderComment 
)

Definition at line 16 of file infrosput.c.

19 {
24  INFSTATUS InfStatus;
25  PWCHAR Buffer;
27  PWCHAR HeaderBuffer;
28  ULONG HeaderBufferSize;
29  UINT Index;
30 
31  InfStatus = InfpBuildFileBuffer((PINFCACHE) InfHandle, &Buffer, &BufferSize);
32  if (! INF_SUCCESS(InfStatus))
33  {
34  DPRINT("Failed to create buffer (Status 0x%lx)\n", InfStatus);
35  return InfStatus;
36  }
37 
38  /* Open the inf file */
40  FileName,
41  0,
42  NULL,
43  NULL);
44 
49  0,
51  if (!INF_SUCCESS(Status))
52  {
53  DPRINT1("NtOpenFile() failed (Status %lx)\n", Status);
54  FREE(Buffer);
55  return Status;
56  }
57 
58  DPRINT("NtOpenFile() successful\n");
59 
60  if (NULL != HeaderComment && 0 != HeaderComment->Length)
61  {
62  /* This is just a comment header, don't abort on errors here */
63  HeaderBufferSize = HeaderComment->Length + 7 * sizeof(WCHAR);
64  HeaderBuffer = MALLOC(HeaderBufferSize);
65  if (NULL != HeaderBuffer)
66  {
67  strcpyW(HeaderBuffer, L"; ");
68  for (Index = 0; Index < HeaderComment->Length / sizeof(WCHAR); Index++)
69  {
70  HeaderBuffer[2 + Index] = HeaderComment->Buffer[Index];
71  }
72  strcpyW(HeaderBuffer + (2 + HeaderComment->Length / sizeof(WCHAR)),
73  L"\r\n\r\n");
75  NULL,
76  NULL,
77  NULL,
79  HeaderBuffer,
80  HeaderBufferSize,
81  NULL,
82  NULL);
83  FREE(HeaderBuffer);
84  }
85  }
86 
87  /* Write main contents */
89  NULL,
90  NULL,
91  NULL,
93  Buffer,
94  BufferSize,
95  NULL,
96  NULL);
97 
99  FREE(Buffer);
100 
101  if (!INF_SUCCESS(Status))
102  {
103  DPRINT1("NtWriteFile() failed (Status %lx)\n", Status);
104  return(Status);
105  }
106 
107  return STATUS_SUCCESS;
108 }
#define INF_SUCCESS(x)
Definition: builddep.h:82
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define MALLOC(Size)
Definition: builddep.h:73
LONG NTSTATUS
Definition: precomp.h:26
uint16_t * PWCHAR
Definition: typedefs.h:54
int INFSTATUS
Definition: infpriv.h:73
HANDLE FileHandle
Definition: stats.c:38
INFSTATUS InfpBuildFileBuffer(PINFCACHE InfHandle, PWCHAR *Buffer, PULONG BufferSize)
Definition: infput.c:90
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
Definition: file.c:3951
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const UCHAR Index[8]
Definition: usbohci.c:18
#define BufferSize
Definition: classpnp.h:419
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
static const WCHAR L[]
Definition: oid.c:1250
#define FREE(ptr, size)
Definition: auth_des.c:64
NTSYSAPI NTSTATUS NTAPI NtWriteFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID WriteBuffer, IN ULONG WriteBufferLength, IN PLARGE_INTEGER FileOffset OPTIONAL, IN PULONG LockOperationKey OPTIONAL)
#define FILE_NON_DIRECTORY_FILE
Definition: constants.h:492
#define SYNCHRONIZE
Definition: nt_native.h:61
Status
Definition: gdiplustypes.h:24
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
unsigned int UINT
Definition: ndis.h:50
#define DPRINT1
Definition: precomp.h:8
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
unsigned int ULONG
Definition: retypes.h:1
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2777