ReactOS  0.4.14-dev-114-gc8cbd56
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
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
IN ULONG IN ULONG Tag
Definition: evtlib.h:159

◆ 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,
35  EventType,
36  FALSE);
37  if (!NT_SUCCESS(Status)) return Status;
38 
39  /* Get a pointer to the object itself */
42  NULL,
43  KernelMode,
44  (PVOID*)Event,
45  NULL);
47 
48  /* Return status */
49  return Status;
50 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
LONG NTSTATUS
Definition: precomp.h:26
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:496
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
Status
Definition: gdiplustypes.h:24
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_ EVENT_TYPE EventType
Definition: exfuncs.h:165
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
_Out_ PHANDLE EventHandle
Definition: iofuncs.h:855

Referenced by CmpOpenHiveFiles().

◆ CmpFileFlush()

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

Definition at line 162 of file cmwraprs.c.

166 {
167  PCMHIVE CmHive = (PCMHIVE)RegistryHive;
168  HANDLE HiveHandle = CmHive->FileHandles[FileType];
171 
172  /* Just return success if no file is associated with this hive */
173  if (HiveHandle == NULL)
174  return TRUE;
175 
176  /* Don't do anything if we're not supposed to */
177  if (CmpNoWrite)
178  return TRUE;
179 
180  Status = ZwFlushBuffersFile(HiveHandle, &IoStatusBlock);
181  return NT_SUCCESS(Status) ? TRUE : FALSE;
182 }
struct _CMHIVE * PCMHIVE
#define TRUE
Definition: types.h:120
NTSYSAPI NTSTATUS NTAPI ZwFlushBuffersFile(_In_ HANDLE FileHandle, _Out_ PIO_STATUS_BLOCK IoStatusBlock)
LONG NTSTATUS
Definition: precomp.h:26
HANDLE FileHandles[HFILE_TYPE_MAX]
Definition: cm.h:394
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN CmpNoWrite
Definition: cmsysini.c:29
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:24
static PCMHIVE CmHive
Definition: registry.c:28
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
Definition: cm.h:391

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  return NT_SUCCESS(Status) ? TRUE : FALSE;
93 }
struct _CMHIVE * PCMHIVE
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
_In_ ULONG BufferLength
Definition: usbdlib.h:225
HANDLE FileHandles[HFILE_TYPE_MAX]
Definition: cm.h:394
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:24
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:151
static PCMHIVE CmHive
Definition: registry.c:28
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
unsigned int ULONG
Definition: retypes.h:1
Definition: cm.h:391
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by CmpInitializeHive().

◆ CmpFileSetSize()

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

Definition at line 125 of file cmwraprs.c.

129 {
130  PCMHIVE CmHive = (PCMHIVE)RegistryHive;
131  HANDLE HiveHandle = CmHive->FileHandles[FileType];
132  FILE_END_OF_FILE_INFORMATION EndOfFileInfo;
133  FILE_ALLOCATION_INFORMATION FileAllocationInfo;
136 
137  /* Just return success if no file is associated with this hive */
138  if (HiveHandle == NULL)
139  return TRUE;
140 
141  EndOfFileInfo.EndOfFile.QuadPart = FileSize;
142  Status = ZwSetInformationFile(HiveHandle,
143  &IoStatusBlock,
144  &EndOfFileInfo,
147  if (!NT_SUCCESS(Status)) return FALSE;
148 
149  FileAllocationInfo.AllocationSize.QuadPart = FileSize;
150  Status = ZwSetInformationFile(HiveHandle,
151  &IoStatusBlock,
152  &FileAllocationInfo,
155  if (!NT_SUCCESS(Status)) return FALSE;
156 
157  return TRUE;
158 }
struct _CMHIVE * PCMHIVE
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
LARGE_INTEGER AllocationSize
Definition: winternl.h:688
HANDLE FileHandles[HFILE_TYPE_MAX]
Definition: cm.h:394
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
Status
Definition: gdiplustypes.h:24
static PCMHIVE CmHive
Definition: registry.c:28
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
Definition: cm.h:391
LONGLONG QuadPart
Definition: typedefs.h:112

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 97 of file cmwraprs.c.

102 {
103  PCMHIVE CmHive = (PCMHIVE)RegistryHive;
104  HANDLE HiveHandle = CmHive->FileHandles[FileType];
105  LARGE_INTEGER _FileOffset;
108 
109  /* Just return success if no file is associated with this hive */
110  if (HiveHandle == NULL)
111  return TRUE;
112 
113  /* Don't do anything if we're not supposed to */
114  if (CmpNoWrite)
115  return TRUE;
116 
117  _FileOffset.QuadPart = *FileOffset;
118  Status = ZwWriteFile(HiveHandle, NULL, NULL, NULL, &IoStatusBlock,
119  Buffer, (ULONG)BufferLength, &_FileOffset, NULL);
120  return NT_SUCCESS(Status) ? TRUE : FALSE;
121 }
struct _CMHIVE * PCMHIVE
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
_In_ ULONG BufferLength
Definition: usbdlib.h:225
HANDLE FileHandles[HFILE_TYPE_MAX]
Definition: cm.h:394
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
BOOLEAN CmpNoWrite
Definition: cmsysini.c:29
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:24
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:151
static PCMHIVE CmHive
Definition: registry.c:28
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
unsigned int ULONG
Definition: retypes.h:1
Definition: cm.h:391
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by CmpInitializeHive().

◆ CmpFree()

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

Definition at line 65 of file cmwraprs.c.

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