ReactOS 0.4.15-dev-8102-g108db8f
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 1028 of file inffile.c.

1029{
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}
FORCEINLINE VOID FrLdrTempFree(PVOID Allocation, ULONG Tag)
Definition: mm.h:197
#define NULL
Definition: types.h:112
#define TAG_INF_CACHE
Definition: inffile.c:24
static PINFCACHESECTION InfpCacheFreeSection(PINFCACHESECTION Section)
Definition: inffile.c:170
struct _INFCACHE * PINFCACHE
Definition: fatfs.h:173

◆ 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}
INFSTATUS InfpFindFirstMatchLine(PINFCONTEXT ContextIn, PCWSTR Key, PINFCONTEXT ContextOut)
Definition: infget.c:251

◆ 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
#define FALSE
Definition: types.h:117
struct _INFCACHELINE * PINFCACHELINE
if(dx< 0)
Definition: linetemp.h:194
struct _INFCACHELINE * Next
Definition: inffile.c:37
HINF Inf
Definition: infsupp.h:24
UINT Line
Definition: infsupp.h:27
UINT Section
Definition: infsupp.h:26
void * PVOID
Definition: typedefs.h:50

◆ 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}
INFSTATUS InfpFindNextMatchLine(PINFCONTEXT ContextIn, PCWSTR Key, PINFCONTEXT ContextOut)
Definition: infget.c:289

◆ 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}
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:679

Referenced by SetupFindFirstLineW().

◆ 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}
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
_In_ DWORD FieldIndex
Definition: setupapi.h:1895
_In_ DWORD _In_ DWORD ReturnBufferSize
Definition: setupapi.h:1897
struct _INFCACHEFIELD * Next
Definition: inffile.c:29
CHAR Data[1]
Definition: inffile.c:32
PINFCACHEFIELD FirstField
Definition: inffile.c:44
ULONG FieldCount
Definition: inffile.c:40
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4439
unsigned char UCHAR
Definition: xmlstorage.h:181

◆ InfGetData()

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

Definition at line 118 of file infrosget.c.

121{
123}
INFSTATUS InfpGetData(PINFCONTEXT Context, PWCHAR *Key, PWCHAR *Data)
Definition: infget.c:610

◆ InfGetDataField()

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

Definition at line 127 of file infrosget.c.

130{
132}
INFSTATUS InfpGetDataField(PINFCONTEXT Context, ULONG FieldIndex, PWCHAR *Data)
Definition: infget.c:643

◆ 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}

◆ InfGetIntField()

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

Definition at line 85 of file infrosget.c.

88{
89 return INF_SUCCESS(InfpGetIntField(Context, FieldIndex, IntegerValue));
90}
INFSTATUS InfpGetIntField(PINFCONTEXT Context, ULONG FieldIndex, INT *IntegerValue)
Definition: infget.c:433

◆ 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:327

◆ InfGetMultiSzField()

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

Definition at line 94 of file infrosget.c.

99{
102}
INFSTATUS InfpGetMultiSzField(PINFCONTEXT Context, ULONG FieldIndex, PWSTR ReturnBuffer, ULONG ReturnBufferSize, PULONG RequiredSize)
Definition: infget.c:476

◆ 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}
INFSTATUS InfpGetStringField(PINFCONTEXT Context, ULONG FieldIndex, PWSTR ReturnBuffer, ULONG ReturnBufferSize, PULONG RequiredSize)
Definition: infget.c:545

◆ 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;
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}
#define FREE(ptr, size)
Definition: auth_des.c:64
#define DPRINT1
Definition: precomp.h:8
#define MALLOC(Size)
Definition: builddep.h:73
#define ZEROMEMORY(Area, Size)
Definition: builddep.h:74
Definition: bufpool.h:45
#define BufferSize
Definition: mmc.h:75
Status
Definition: gdiplustypes.h:25
GLenum GLsizei len
Definition: glext.h:6722
GLintptr offset
Definition: glext.h:5920
static BOOLEAN InfpParseBuffer(PINFCACHE file, PCCHAR buffer, PCCHAR end, PULONG error_line)
Definition: inffile.c:878
int INFSTATUS
Definition: infpriv.h:77
#define INF_STATUS_INSUFFICIENT_RESOURCES
Definition: infpriv.h:15
static VOID CheckHeap(VOID)
Definition: infrosgen.c:22
PVOID HINF
Definition: infsupp.h:21
#define MEMCPY(DST, SRC, BYTES)
Definition: macros.h:231
unsigned int UINT
Definition: ndis.h:50
NTSYSAPI BOOLEAN NTAPI RtlIsTextUnicode(_In_ CONST VOID *Buffer, _In_ INT Size, _Inout_opt_ INT *Flags)
_Use_decl_annotations_ NTSTATUS NTAPI RtlMultiByteToUnicodeN(_Out_ PWCH UnicodeString, _In_ ULONG UnicodeSize, _Out_opt_ PULONG ResultSize, _In_ PCCH MbString, _In_ ULONG MbSize)
Definition: nlsboot.c:62
#define DPRINT
Definition: sndvol32.h:73
char * PCHAR
Definition: typedefs.h:51
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
__wchar_t WCHAR
Definition: xmlstorage.h:180

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
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 */
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,
237 FileBuffer,
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;
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}
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_NON_DIRECTORY_FILE
Definition: constants.h:492
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:160
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define GENERIC_READ
Definition: compat.h:135
#define FILE_SHARE_READ
Definition: compat.h:136
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
#define ULL(a, b)
Definition: format_msg.c:27
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
_Out_ PNDIS_HANDLE _Out_ PUINT FileLength
Definition: ndis.h:3228
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:3952
#define SYNCHRONIZE
Definition: nt_native.h:61
NTSYSAPI NTSTATUS NTAPI NtQueryInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, OUT PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define FileStandardInformation
Definition: propsheet.cpp:61
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;
46 }
47}
static int InfpHeapRefCount
Definition: infrosgen.c:19
PVOID InfpHeap
Definition: infrosgen.c:37

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;
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 */
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,
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}
INFSTATUS InfpBuildFileBuffer(PINFCACHE InfHandle, PWCHAR *Buffer, PULONG BufferSize)
Definition: infput.c:90
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 GENERIC_WRITE
Definition: nt_native.h:90
#define L(x)
Definition: ntvdm.h:50
#define strcpyW(d, s)
Definition: unicode.h:35
#define STATUS_SUCCESS
Definition: shellext.h:65
uint16_t * PWCHAR
Definition: typedefs.h:56