ReactOS 0.4.15-dev-5666-gc548b97
cmwraprs.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: ntoskrnl/config/cmwraprs.c
5 * PURPOSE: Configuration Manager - Wrappers for Hive Operations
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7 */
8
9/* INCLUDES ******************************************************************/
10
11#include "ntoskrnl.h"
12#define NDEBUG
13#include "debug.h"
14
15/* FUNCTIONS *****************************************************************/
16
22{
25
26 /* Create the event */
28 NULL,
30 NULL,
31 NULL);
32 Status = ZwCreateEvent(EventHandle,
36 FALSE);
37 if (!NT_SUCCESS(Status)) return Status;
38
39 /* Get a pointer to the object itself */
42 NULL,
44 (PVOID*)Event,
45 NULL);
47
48 /* Return status */
49 return Status;
50}
51
55 IN BOOLEAN Paged,
56 IN ULONG Tag)
57{
59 Size,
60 Tag);
61}
62
63VOID
66 IN ULONG Quota)
67{
69}
70
73CmpFileRead(IN PHHIVE RegistryHive,
78{
79 PCMHIVE CmHive = (PCMHIVE)RegistryHive;
80 HANDLE HiveHandle = CmHive->FileHandles[FileType];
81 LARGE_INTEGER _FileOffset;
84
85 /* Just return success if no file is associated with this hive */
86 if (HiveHandle == NULL)
87 return TRUE;
88
89 _FileOffset.QuadPart = *FileOffset;
90 Status = ZwReadFile(HiveHandle, NULL, NULL, NULL, &IoStatusBlock,
91 Buffer, (ULONG)BufferLength, &_FileOffset, NULL);
92 /* We do synchronous I/O for simplicity - see CmpOpenHiveFiles. */
94 return NT_SUCCESS(Status) ? TRUE : FALSE;
95}
96
99CmpFileWrite(IN PHHIVE RegistryHive,
104{
105 PCMHIVE CmHive = (PCMHIVE)RegistryHive;
106 HANDLE HiveHandle = CmHive->FileHandles[FileType];
107 LARGE_INTEGER _FileOffset;
110
111 /* Just return success if no file is associated with this hive */
112 if (HiveHandle == NULL)
113 return TRUE;
114
115 /* Don't do anything if we're not supposed to */
116 if (CmpNoWrite)
117 return TRUE;
118
119 _FileOffset.QuadPart = *FileOffset;
120 Status = ZwWriteFile(HiveHandle, NULL, NULL, NULL, &IoStatusBlock,
121 Buffer, (ULONG)BufferLength, &_FileOffset, NULL);
122 /* We do synchronous I/O for simplicity - see CmpOpenHiveFiles.
123 * Windows optimizes here by starting an async write for each 64k chunk,
124 * then waiting for all writes to complete at once.
125 */
127 return NT_SUCCESS(Status) ? TRUE : FALSE;
128}
129
131NTAPI
135 IN ULONG OldFileSize)
136{
137 PCMHIVE CmHive = (PCMHIVE)RegistryHive;
138 HANDLE HiveHandle = CmHive->FileHandles[FileType];
139 FILE_END_OF_FILE_INFORMATION EndOfFileInfo;
140 FILE_ALLOCATION_INFORMATION FileAllocationInfo;
143
144 /* Just return success if no file is associated with this hive */
145 if (HiveHandle == NULL)
146 return TRUE;
147
148 EndOfFileInfo.EndOfFile.QuadPart = FileSize;
149 Status = ZwSetInformationFile(HiveHandle,
151 &EndOfFileInfo,
154 if (!NT_SUCCESS(Status)) return FALSE;
155
156 FileAllocationInfo.AllocationSize.QuadPart = FileSize;
157 Status = ZwSetInformationFile(HiveHandle,
159 &FileAllocationInfo,
162 if (!NT_SUCCESS(Status)) return FALSE;
163
164 return TRUE;
165}
166
168NTAPI
169CmpFileFlush(IN PHHIVE RegistryHive,
173{
174 PCMHIVE CmHive = (PCMHIVE)RegistryHive;
175 HANDLE HiveHandle = CmHive->FileHandles[FileType];
178
179 /* Just return success if no file is associated with this hive */
180 if (HiveHandle == NULL)
181 return TRUE;
182
183 /* Don't do anything if we're not supposed to */
184 if (CmpNoWrite)
185 return TRUE;
186
188
189 /* This operation is always synchronous */
192
193 return NT_SUCCESS(Status) ? TRUE : FALSE;
194}
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:160
Definition: bufpool.h:45
struct _CMHIVE * PCMHIVE
BOOLEAN CmpNoWrite
Definition: cmsysini.c:29
BOOLEAN NTAPI CmpFileWrite(IN PHHIVE RegistryHive, IN ULONG FileType, IN PULONG FileOffset, IN PVOID Buffer, IN SIZE_T BufferLength)
Definition: cmwraprs.c:99
VOID NTAPI CmpFree(IN PVOID Ptr, IN ULONG Quota)
Definition: cmwraprs.c:65
BOOLEAN NTAPI CmpFileSetSize(IN PHHIVE RegistryHive, IN ULONG FileType, IN ULONG FileSize, IN ULONG OldFileSize)
Definition: cmwraprs.c:132
BOOLEAN NTAPI CmpFileFlush(IN PHHIVE RegistryHive, IN ULONG FileType, IN OUT PLARGE_INTEGER FileOffset, IN ULONG Length)
Definition: cmwraprs.c:169
NTSTATUS NTAPI CmpCreateEvent(IN EVENT_TYPE EventType, OUT PHANDLE EventHandle, OUT PKEVENT *Event)
Definition: cmwraprs.c:19
PVOID NTAPI CmpAllocate(IN SIZE_T Size, IN BOOLEAN Paged, IN ULONG Tag)
Definition: cmwraprs.c:54
BOOLEAN NTAPI CmpFileRead(IN PHHIVE RegistryHive, IN ULONG FileType, IN PULONG FileOffset, OUT PVOID Buffer, IN SIZE_T BufferLength)
Definition: cmwraprs.c:73
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define NonPagedPool
Definition: env_spec_w32.h:307
#define PagedPool
Definition: env_spec_w32.h:308
@ FileEndOfFileInformation
Definition: from_kernel.h:81
@ FileAllocationInformation
Definition: from_kernel.h:80
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
Status
Definition: gdiplustypes.h:25
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
unsigned int * PULONG
Definition: retypes.h:1
unsigned int ULONG
Definition: retypes.h:1
#define ASSERT(a)
Definition: mode.c:44
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define KernelMode
Definition: asm.h:34
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_ EVENT_TYPE EventType
Definition: exfuncs.h:167
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
enum _EVENT_TYPE EVENT_TYPE
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:455
#define STATUS_PENDING
Definition: ntstatus.h:82
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:494
Definition: cmlib.h:245
HANDLE FileHandles[HFILE_TYPE_MAX]
Definition: cmlib.h:247
LARGE_INTEGER AllocationSize
Definition: winternl.h:688
#define NTAPI
Definition: typedefs.h:36
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define IN
Definition: typedefs.h:39
#define OUT
Definition: typedefs.h:40
LONGLONG QuadPart
Definition: typedefs.h:114
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4065
_In_ WDFDEVICE _In_ WDF_SPECIAL_FILE_TYPE FileType
Definition: wdfdevice.h:2741
_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_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771
_Out_ PHANDLE EventHandle
Definition: iofuncs.h:857
NTSYSAPI NTSTATUS NTAPI ZwFlushBuffersFile(_In_ HANDLE FileHandle, _Out_ PIO_STATUS_BLOCK IoStatusBlock)