ReactOS 0.4.15-dev-5669-g09dde2c
cmwraprs.c File Reference
#include "ntoskrnl.h"
#include "debug.h"
Include dependency graph for cmwraprs.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS NTAPI CmpCreateEvent (IN EVENT_TYPE EventType, OUT PHANDLE EventHandle, OUT PKEVENT *Event)
 
PVOID NTAPI CmpAllocate (IN SIZE_T Size, IN BOOLEAN Paged, IN ULONG Tag)
 
VOID NTAPI CmpFree (IN PVOID Ptr, IN ULONG Quota)
 
BOOLEAN NTAPI CmpFileRead (IN PHHIVE RegistryHive, IN ULONG FileType, IN PULONG FileOffset, OUT PVOID Buffer, IN SIZE_T BufferLength)
 
BOOLEAN NTAPI CmpFileWrite (IN PHHIVE RegistryHive, IN ULONG FileType, IN PULONG FileOffset, IN PVOID Buffer, IN SIZE_T BufferLength)
 
BOOLEAN NTAPI CmpFileSetSize (IN PHHIVE RegistryHive, IN ULONG FileType, IN ULONG FileSize, IN ULONG OldFileSize)
 
BOOLEAN NTAPI CmpFileFlush (IN PHHIVE RegistryHive, IN ULONG FileType, IN OUT PLARGE_INTEGER FileOffset, IN ULONG Length)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file cmwraprs.c.

Function Documentation

◆ CmpAllocate()

PVOID NTAPI CmpAllocate ( IN SIZE_T  Size,
IN BOOLEAN  Paged,
IN ULONG  Tag 
)

Definition at line 54 of file cmwraprs.c.

57{
59 Size,
60 Tag);
61}
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define NonPagedPool
Definition: env_spec_w32.h:307
#define PagedPool
Definition: env_spec_w32.h:308
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4065
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

◆ CmpCreateEvent()

NTSTATUS NTAPI CmpCreateEvent ( IN EVENT_TYPE  EventType,
OUT PHANDLE  EventHandle,
OUT PKEVENT Event 
)

Definition at line 19 of file cmwraprs.c.

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}
LONG NTSTATUS
Definition: precomp.h:26
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
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
#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)
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
_Out_ PHANDLE EventHandle
Definition: iofuncs.h:857

Referenced by CmpOpenHiveFiles().

◆ CmpFileFlush()

BOOLEAN NTAPI CmpFileFlush ( IN PHHIVE  RegistryHive,
IN ULONG  FileType,
IN OUT PLARGE_INTEGER  FileOffset,
IN ULONG  Length 
)

Definition at line 169 of file cmwraprs.c.

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}
struct _CMHIVE * PCMHIVE
BOOLEAN CmpNoWrite
Definition: cmsysini.c:29
#define TRUE
Definition: types.h:120
#define ASSERT(a)
Definition: mode.c:44
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define STATUS_PENDING
Definition: ntstatus.h:82
Definition: cmlib.h:245
HANDLE FileHandles[HFILE_TYPE_MAX]
Definition: cmlib.h:247
_In_ WDFDEVICE _In_ WDF_SPECIAL_FILE_TYPE FileType
Definition: wdfdevice.h:2741
NTSYSAPI NTSTATUS NTAPI ZwFlushBuffersFile(_In_ HANDLE FileHandle, _Out_ PIO_STATUS_BLOCK IoStatusBlock)

Referenced by CmpInitializeHive().

◆ CmpFileRead()

BOOLEAN NTAPI CmpFileRead ( IN PHHIVE  RegistryHive,
IN ULONG  FileType,
IN PULONG  FileOffset,
OUT PVOID  Buffer,
IN SIZE_T  BufferLength 
)

Definition at line 73 of file cmwraprs.c.

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}
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:160
Definition: bufpool.h:45
uint32_t ULONG
Definition: typedefs.h:59
LONGLONG QuadPart
Definition: typedefs.h:114
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771

Referenced by CmpInitializeHive().

◆ CmpFileSetSize()

BOOLEAN NTAPI CmpFileSetSize ( IN PHHIVE  RegistryHive,
IN ULONG  FileType,
IN ULONG  FileSize,
IN ULONG  OldFileSize 
)

Definition at line 132 of file cmwraprs.c.

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}
@ FileEndOfFileInformation
Definition: from_kernel.h:81
@ FileAllocationInformation
Definition: from_kernel.h:80
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
LARGE_INTEGER AllocationSize
Definition: winternl.h:688

Referenced by CmpInitializeHive().

◆ CmpFileWrite()

BOOLEAN NTAPI CmpFileWrite ( IN PHHIVE  RegistryHive,
IN ULONG  FileType,
IN PULONG  FileOffset,
IN PVOID  Buffer,
IN SIZE_T  BufferLength 
)

Definition at line 99 of file cmwraprs.c.

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}

Referenced by CmpInitializeHive().

◆ CmpFree()

VOID NTAPI CmpFree ( IN PVOID  Ptr,
IN ULONG  Quota 
)

Definition at line 65 of file cmwraprs.c.

67{
69}
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898