ReactOS 0.4.15-dev-6694-g4ba8af9
infrosput.c
Go to the documentation of this file.
1/*
2 * PROJECT: .inf file parser
3 * LICENSE: GPL - See COPYING in the top level directory
4 * COPYRIGHT: Copyright 2005 Ge van Geldorp <gvg@reactos.org>
5 */
6
7/* INCLUDES *****************************************************************/
8
9#include "inflib.h"
10#include "infros.h"
11
12#define NDEBUG
13#include <debug.h>
14
18 PUNICODE_STRING HeaderComment)
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}
109
112 PCWSTR Section,
114{
115 return INF_SUCCESS(InfpFindOrAddSection((PINFCACHE) InfHandle,
116 Section, Context));
117}
118
121{
123}
124
127{
129}
130
131/* EOF */
unsigned char BOOLEAN
#define FREE(ptr, size)
Definition: auth_des.c:64
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_NON_DIRECTORY_FILE
Definition: constants.h:492
#define DPRINT1
Definition: precomp.h:8
#define MALLOC(Size)
Definition: builddep.h:73
#define INF_SUCCESS(x)
Definition: builddep.h:82
Definition: bufpool.h:45
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define BufferSize
Definition: mmc.h:75
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
Status
Definition: gdiplustypes.h:25
INFSTATUS InfpFindOrAddSection(PINFCACHE Cache, PCWSTR Section, PINFCONTEXT *Context)
Definition: infput.c:190
INFSTATUS InfpAddLineWithKey(PINFCONTEXT Context, PCWSTR Key)
Definition: infput.c:224
INFSTATUS InfpBuildFileBuffer(PINFCACHE InfHandle, PWCHAR *Buffer, PULONG BufferSize)
Definition: infput.c:90
int INFSTATUS
Definition: infpriv.h:77
INFSTATUS InfpAddField(PINFCONTEXT Context, PCWSTR Data)
Definition: infput.c:254
BOOLEAN InfHostAddLine(PINFCONTEXT Context, PCWSTR Key)
Definition: infrosput.c:120
BOOLEAN InfHostAddField(PINFCONTEXT Context, PCWSTR Data)
Definition: infrosput.c:126
NTSTATUS InfWriteFile(HINF InfHandle, PUNICODE_STRING FileName, PUNICODE_STRING HeaderComment)
Definition: infrosput.c:16
BOOLEAN InfFindOrAddSection(HINF InfHandle, PCWSTR Section, PINFCONTEXT *Context)
Definition: infrosput.c:111
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
unsigned int UINT
Definition: ndis.h:50
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 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)
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define GENERIC_WRITE
Definition: nt_native.h:90
#define L(x)
Definition: ntvdm.h:50
#define strcpyW(d, s)
Definition: unicode.h:29
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
const uint16_t * PCWSTR
Definition: typedefs.h:57
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFCOLLECTION _In_ ULONG Index
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
__wchar_t WCHAR
Definition: xmlstorage.h:180