ReactOS 0.4.16-dev-125-g798ea90
rxact.c File Reference
#include <rtl.h>
#include <ndk/cmfuncs.h>
#include <debug.h>
Include dependency graph for rxact.c:

Go to the source code of this file.

Classes

struct  _RXACT_INFO
 
struct  _RXACT_DATA
 
struct  _RXACT_CONTEXT
 
struct  _RXACT_ACTION
 

Macros

#define NDEBUG
 
#define RXACT_DEFAULT_BUFFER_SIZE   (4 * PAGE_SIZE)
 

Typedefs

typedef struct _RXACT_INFO RXACT_INFO
 
typedef struct _RXACT_INFOPRXACT_INFO
 
typedef struct _RXACT_DATA RXACT_DATA
 
typedef struct _RXACT_DATAPRXACT_DATA
 
typedef struct _RXACT_CONTEXT RXACT_CONTEXT
 
typedef struct _RXACT_CONTEXTPRXACT_CONTEXT
 
typedef struct _RXACT_ACTION RXACT_ACTION
 
typedef struct _RXACT_ACTIONPRXACT_ACTION
 

Enumerations

enum  { RXactDeleteKey = 1 , RXactSetValueKey = 2 }
 

Functions

static VOID NTAPI RXactInitializeContext (PRXACT_CONTEXT Context, HANDLE RootDirectory, HANDLE KeyHandle)
 
static NTSTATUS NTAPI RXactpOpenTargetKey (HANDLE RootDirectory, ULONG ActionType, PUNICODE_STRING KeyName, PHANDLE KeyHandle)
 
static NTSTATUS NTAPI RXactpCommit (PRXACT_CONTEXT Context)
 
NTSTATUS NTAPI RtlStartRXact (PRXACT_CONTEXT Context)
 
NTSTATUS NTAPI RtlAbortRXact (PRXACT_CONTEXT Context)
 
NTSTATUS NTAPI RtlInitializeRXact (HANDLE RootDirectory, BOOLEAN Commit, PRXACT_CONTEXT *OutContext)
 
NTSTATUS NTAPI RtlAddAttributeActionToRXact (PRXACT_CONTEXT Context, ULONG ActionType, PUNICODE_STRING KeyName, HANDLE KeyHandle, PUNICODE_STRING ValueName, ULONG ValueType, PVOID ValueData, ULONG ValueDataSize)
 
NTSTATUS NTAPI RtlAddActionToRXact (PRXACT_CONTEXT Context, ULONG ActionType, PUNICODE_STRING KeyName, ULONG ValueType, PVOID ValueData, ULONG ValueDataSize)
 
NTSTATUS NTAPI RtlApplyRXactNoFlush (PRXACT_CONTEXT Context)
 
NTSTATUS NTAPI RtlApplyRXact (PRXACT_CONTEXT Context)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file rxact.c.

◆ RXACT_DEFAULT_BUFFER_SIZE

#define RXACT_DEFAULT_BUFFER_SIZE   (4 * PAGE_SIZE)

Definition at line 17 of file rxact.c.

Typedef Documentation

◆ PRXACT_ACTION

◆ PRXACT_CONTEXT

◆ PRXACT_DATA

◆ PRXACT_INFO

◆ RXACT_ACTION

◆ RXACT_CONTEXT

◆ RXACT_DATA

◆ RXACT_INFO

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
RXactDeleteKey 
RXactSetValueKey 

Definition at line 53 of file rxact.c.

54{
57};
@ RXactSetValueKey
Definition: rxact.c:56
@ RXactDeleteKey
Definition: rxact.c:55

Function Documentation

◆ RtlAbortRXact()

NTSTATUS NTAPI RtlAbortRXact ( PRXACT_CONTEXT  Context)

Definition at line 276 of file rxact.c.

278{
279 /* We must have a data buffer */
280 if (Context->Data == NULL)
281 {
283 }
284
285 /* Free the buffer */
286 RtlFreeHeap(RtlGetProcessHeap(), 0, Context->Data);
287
288 /* Reinitialize the context */
289 RXactInitializeContext(Context, Context->RootDirectory, Context->KeyHandle);
290
291 return STATUS_SUCCESS;
292}
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
#define NULL
Definition: types.h:112
#define STATUS_RXACT_INVALID_STATE
Definition: ntstatus.h:520
static VOID NTAPI RXactInitializeContext(PRXACT_CONTEXT Context, HANDLE RootDirectory, HANDLE KeyHandle)
Definition: rxact.c:64
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by RtlApplyRXact(), RtlApplyRXactNoFlush(), and RtlInitializeRXact().

◆ RtlAddActionToRXact()

NTSTATUS NTAPI RtlAddActionToRXact ( PRXACT_CONTEXT  Context,
ULONG  ActionType,
PUNICODE_STRING  KeyName,
ULONG  ValueType,
PVOID  ValueData,
ULONG  ValueDataSize 
)

Definition at line 604 of file rxact.c.

611{
613
614 /* Create a key and set the default key value or delete a key. */
617 ActionType,
618 KeyName,
620 &ValueName,
621 ValueType,
622 ValueData,
623 ValueDataSize);
624}
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
_In_ GUID _In_ PVOID ValueData
Definition: hubbusif.h:312
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSTATUS NTAPI RtlAddAttributeActionToRXact(PRXACT_CONTEXT Context, ULONG ActionType, PUNICODE_STRING KeyName, HANDLE KeyHandle, PUNICODE_STRING ValueName, ULONG ValueType, PVOID ValueData, ULONG ValueDataSize)
Definition: rxact.c:491
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2699
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG _Out_opt_ PULONG _Out_opt_ PULONG ValueType
Definition: wdfregistry.h:282
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243

◆ RtlAddAttributeActionToRXact()

NTSTATUS NTAPI RtlAddAttributeActionToRXact ( PRXACT_CONTEXT  Context,
ULONG  ActionType,
PUNICODE_STRING  KeyName,
HANDLE  KeyHandle,
PUNICODE_STRING  ValueName,
ULONG  ValueType,
PVOID  ValueData,
ULONG  ValueDataSize 
)

Definition at line 491 of file rxact.c.

500{
501 ULONG ActionSize;
504 ULONG CurrentOffset;
505 PRXACT_DATA NewData;
507
508 /* Validate ActionType parameter */
509 if ((ActionType != RXactDeleteKey) && (ActionType != RXactSetValueKey))
510 {
512 }
513
514 /* Calculate the size of the new action record */
515 ActionSize = ALIGN_UP_BY(ValueName->Length, sizeof(ULONG)) +
516 ALIGN_UP_BY(ValueDataSize, sizeof(ULONG)) +
517 ALIGN_UP_BY(KeyName->Length, sizeof(ULONG)) +
518 ALIGN_UP_BY(sizeof(RXACT_ACTION), sizeof(ULONG));
519
520 /* Calculate the new buffer size we need */
521 RequiredSize = ActionSize + Context->Data->CurrentSize;
522
523 /* Check for integer overflow */
524 if (RequiredSize < ActionSize)
525 {
526 return STATUS_NO_MEMORY;
527 }
528
529 /* Check if the buffer is large enough */
530 BufferSize = Context->Data->BufferSize;
532 {
533 /* Increase by a factor of 2, until it is large enough */
534 while (BufferSize < RequiredSize)
535 {
536 BufferSize *= 2;
537 }
538
539 /* Allocate a new buffer from the heap */
540 NewData = RtlAllocateHeap(RtlGetProcessHeap(), 0, BufferSize);
541 if (NewData == NULL)
542 {
543 return STATUS_NO_MEMORY;
544 }
545
546 /* Copy the old buffer to the new one */
547 RtlCopyMemory(NewData, Context->Data, Context->Data->CurrentSize);
548
549 /* Free the old buffer and use the new one */
550 RtlFreeHeap(RtlGetProcessHeap(), 0, Context->Data);
551 Context->Data = NewData;
552 NewData->BufferSize = BufferSize;
553 }
554
555 /* Get the next action record */
556 Action = (RXACT_ACTION *)((PUCHAR)Context->Data + Context->Data->CurrentSize);
557
558 /* Fill in the fields */
559 Action->Size = ActionSize;
560 Action->Type = ActionType;
561 Action->KeyName = *KeyName;
562 Action->ValueName = *ValueName;
563 Action->ValueType = ValueType;
564 Action->ValueDataSize = ValueDataSize;
565 Action->KeyHandle = KeyHandle;
566
567 /* Copy the key name (and convert the pointer to a buffer offset) */
568 CurrentOffset = Context->Data->CurrentSize + sizeof(RXACT_ACTION);
569 Action->KeyName.Buffer = UlongToPtr(CurrentOffset);
570 RtlCopyMemory((PUCHAR)Context->Data + CurrentOffset,
571 KeyName->Buffer,
572 KeyName->Length);
573
574 /* Copy the value name (and convert the pointer to a buffer offset) */
575 CurrentOffset += ALIGN_UP_BY(KeyName->Length, sizeof(ULONG));
576 Action->ValueName.Buffer = UlongToPtr(CurrentOffset);
577 RtlCopyMemory((PUCHAR)Context->Data + CurrentOffset,
578 ValueName->Buffer,
579 ValueName->Length);
580
581 /* Update the offset */
582 CurrentOffset += ALIGN_UP_BY(ValueName->Length, sizeof(ULONG));
583
584 /* Is this a set action? */
585 if (ActionType == RXactSetValueKey)
586 {
587 /* Copy the key value data as well */
588 Action->ValueData = UlongToPtr(CurrentOffset);
589 RtlCopyMemory((PUCHAR)Context->Data + CurrentOffset,
590 ValueData,
591 ValueDataSize);
592 CurrentOffset += ALIGN_UP_BY(ValueDataSize, sizeof(ULONG));
593 }
594
595 /* Update data site and action count */
596 Context->Data->CurrentSize = CurrentOffset;
597 Context->Data->ActionCount++;
598
599 return STATUS_SUCCESS;
600}
#define ALIGN_UP_BY(size, align)
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
#define BufferSize
Definition: mmc.h:75
#define UlongToPtr(u)
Definition: config.h:106
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
struct _RXACT_ACTION RXACT_ACTION
ULONG BufferSize
Definition: rxact.c:29
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4439
_In_ WDFIOTARGET _In_ _Strict_type_match_ WDF_IO_TARGET_SENT_IO_ACTION Action
Definition: wdfiotarget.h:510
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254

Referenced by RtlAddActionToRXact().

◆ RtlApplyRXact()

NTSTATUS NTAPI RtlApplyRXact ( PRXACT_CONTEXT  Context)

Definition at line 649 of file rxact.c.

651{
654
655 /* Temporarily safe the current transaction in the 'Log' key value */
657 Status = ZwSetValueKey(Context->KeyHandle,
658 &ValueName,
659 0,
661 Context->Data,
662 Context->Data->CurrentSize);
663 if (!NT_SUCCESS(Status))
664 {
665 return Status;
666 }
667
668 /* Flush the key */
669 Status = NtFlushKey(Context->KeyHandle);
670 if (!NT_SUCCESS(Status))
671 {
672 NtDeleteValueKey(Context->KeyHandle, &ValueName);
673 return Status;
674 }
675
676 /* Now commit the transaction */
678 if (!NT_SUCCESS(Status))
679 {
680 NtDeleteValueKey(Context->KeyHandle, &ValueName);
681 return Status;
682 }
683
684 /* Delete the 'Log' key value */
687
688 /* Reset the transaction */
691
692 return STATUS_SUCCESS;
693}
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
Status
Definition: gdiplustypes.h:25
#define ASSERT(a)
Definition: mode.c:44
#define REG_BINARY
Definition: nt_native.h:1496
NTSYSAPI NTSTATUS NTAPI NtDeleteValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName)
Definition: ntapi.c:1014
NTSTATUS NTAPI NtFlushKey(IN HANDLE KeyHandle)
Definition: ntapi.c:1085
#define L(x)
Definition: ntvdm.h:50
static NTSTATUS NTAPI RXactpCommit(PRXACT_CONTEXT Context)
Definition: rxact.c:126
NTSTATUS NTAPI RtlAbortRXact(PRXACT_CONTEXT Context)
Definition: rxact.c:276

◆ RtlApplyRXactNoFlush()

NTSTATUS NTAPI RtlApplyRXactNoFlush ( PRXACT_CONTEXT  Context)

Definition at line 628 of file rxact.c.

630{
632
633 /* Commit the transaction */
635 if (!NT_SUCCESS(Status))
636 {
637 return Status;
638 }
639
640 /* Reset the transaction */
643
644 return Status;
645}

◆ RtlInitializeRXact()

NTSTATUS NTAPI RtlInitializeRXact ( HANDLE  RootDirectory,
BOOLEAN  Commit,
PRXACT_CONTEXT OutContext 
)

Definition at line 296 of file rxact.c.

300{
301 NTSTATUS Status, TmpStatus;
303 PKEY_VALUE_FULL_INFORMATION KeyValueInformation;
304 KEY_VALUE_BASIC_INFORMATION KeyValueBasicInfo;
308 RXACT_INFO TransactionInfo;
311 ULONG ValueDataLength;
314
315 /* Open or create the 'RXACT' key in the root directory */
318 &KeyName,
321 NULL);
322 Status = ZwCreateKey(&KeyHandle,
325 0,
326 NULL,
327 0,
328 &Disposition);
329 if (!NT_SUCCESS(Status))
330 {
331 return Status;
332 }
333
334 /* Allocate a new context */
335 Context = RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeof(*Context));
336 *OutContext = Context;
337 if (Context == NULL)
338 {
339 TmpStatus = ZwDeleteKey(KeyHandle);
340 ASSERT(NT_SUCCESS(TmpStatus));
341
342 TmpStatus = NtClose(KeyHandle);
343 ASSERT(NT_SUCCESS(TmpStatus));
344
345 return STATUS_NO_MEMORY;
346 }
347
348 /* Initialize the context */
350
351 /* Check if we created a new key */
353 {
354 /* The key is new, set the default value */
355 TransactionInfo.Revision = 1;
357 Status = ZwSetValueKey(KeyHandle,
358 &ValueName,
359 0,
360 REG_NONE,
361 &TransactionInfo,
362 sizeof(TransactionInfo));
363 if (!NT_SUCCESS(Status))
364 {
365 TmpStatus = ZwDeleteKey(KeyHandle);
366 ASSERT(NT_SUCCESS(TmpStatus));
367
368 TmpStatus = NtClose(KeyHandle);
369 ASSERT(NT_SUCCESS(TmpStatus));
370
371 RtlFreeHeap(RtlGetProcessHeap(), 0, *OutContext);
372 return Status;
373 }
374
376 }
377 else
378 {
379 /* The key exited, get the default key value */
380 ValueDataLength = sizeof(TransactionInfo);
382 &ValueType,
383 &TransactionInfo,
384 &ValueDataLength,
385 0);
386 if (!NT_SUCCESS(Status))
387 {
388 TmpStatus = NtClose(KeyHandle);
389 ASSERT(NT_SUCCESS(TmpStatus));
390 RtlFreeHeap(RtlGetProcessHeap(), 0, Context);
391 return Status;
392 }
393
394 /* Check if the value date is valid */
395 if ((ValueDataLength != sizeof(TransactionInfo)) ||
396 (TransactionInfo.Revision != 1))
397 {
398 TmpStatus = NtClose(KeyHandle);
399 ASSERT(NT_SUCCESS(TmpStatus));
400 RtlFreeHeap(RtlGetProcessHeap(), 0, Context);
402 }
403
404 /* Query the 'Log' key value */
406 Status = ZwQueryValueKey(KeyHandle,
407 &ValueName,
409 &KeyValueBasicInfo,
410 sizeof(KeyValueBasicInfo),
411 &Length);
412 if (!NT_SUCCESS(Status))
413 {
414 /* There is no 'Log', so we are done */
415 return STATUS_SUCCESS;
416 }
417
418 /* Check if the caller asked to commit the current state */
419 if (!Commit)
420 {
421 /* We have a log, that must be committed first! */
423 }
424
425 /* Query the size of the 'Log' key value */
426 Status = ZwQueryValueKey(KeyHandle,
427 &ValueName,
429 NULL,
430 0,
431 &Length);
433 {
434 return Status;
435 }
436
437 /* Allocate a buffer for the key value information */
438 KeyValueInformation = RtlAllocateHeap(RtlGetProcessHeap(), 0, Length);
439 if (KeyValueInformation == NULL)
440 {
441 return STATUS_NO_MEMORY;
442 }
443
444 /* Query the 'Log' key value */
445 Status = ZwQueryValueKey(KeyHandle,
446 &ValueName,
448 KeyValueInformation,
449 Length,
450 &Length);
451 if (!NT_SUCCESS(Status))
452 {
453 RtlFreeHeap(RtlGetProcessHeap(), 0, KeyValueInformation);
454 RtlFreeHeap(RtlGetProcessHeap(), 0, Context);
455 return Status;
456 }
457
458 /* Set the Data pointer to the key value data */
459 Context->Data = (PRXACT_DATA)((PUCHAR)KeyValueInformation +
460 KeyValueInformation->DataOffset);
461
462 /* This is an old log, don't use handles when committing! */
463 Context->CanUseHandles = FALSE;
464
465 /* Commit the data */
467 if (!NT_SUCCESS(Status))
468 {
469 RtlFreeHeap(RtlGetProcessHeap(), 0, KeyValueInformation);
470 RtlFreeHeap(RtlGetProcessHeap(), 0, Context);
471 return Status;
472 }
473
474 /* Delete the old key */
477
478 /* Set the data member to the allocated buffer, so it will get freed */
479 Context->Data = (PRXACT_DATA)KeyValueInformation;
480
481 /* Abort the old transaction */
484
485 return Status;
486 }
487}
WCHAR RootDirectory[MAX_PATH]
Definition: format.c:74
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define FALSE
Definition: types.h:117
#define OBJ_OPENIF
Definition: winternl.h:229
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Reserved_ ULONG _In_opt_ PUNICODE_STRING _In_ ULONG _Out_opt_ PULONG Disposition
Definition: cmfuncs.h:56
@ KeyValueBasicInformation
Definition: nt_native.h:1180
@ KeyValueFullInformation
Definition: nt_native.h:1181
#define KEY_READ
Definition: nt_native.h:1023
#define REG_CREATED_NEW_KEY
Definition: nt_native.h:1084
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define DELETE
Definition: nt_native.h:57
#define KEY_WRITE
Definition: nt_native.h:1031
#define REG_NONE
Definition: nt_native.h:1492
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define STATUS_UNKNOWN_REVISION
Definition: ntstatus.h:324
#define STATUS_RXACT_STATE_CREATED
Definition: ntstatus.h:118
#define STATUS_RXACT_COMMIT_NECESSARY
Definition: ntstatus.h:204
struct _RXACT_DATA * PRXACT_DATA
NTSTATUS NTAPI RtlpNtQueryValueKey(IN HANDLE KeyHandle, OUT PULONG Type OPTIONAL, OUT PVOID Data OPTIONAL, IN OUT PULONG DataLength OPTIONAL, IN ULONG Unused)
Definition: registry.c:933
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
ULONG Revision
Definition: rxact.c:21

◆ RtlStartRXact()

NTSTATUS NTAPI RtlStartRXact ( PRXACT_CONTEXT  Context)

Definition at line 247 of file rxact.c.

249{
251
252 /* We must not have a buffer yet */
253 if (Context->Data != NULL)
254 {
256 }
257
258 /* Allocate a buffer */
259 Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, RXACT_DEFAULT_BUFFER_SIZE);
260 if (Buffer == NULL)
261 {
262 return STATUS_NO_MEMORY;
263 }
264
265 /* Initialize the buffer */
266 Buffer->ActionCount = 0;
267 Buffer->BufferSize = RXACT_DEFAULT_BUFFER_SIZE;
268 Buffer->CurrentSize = sizeof(RXACT_DATA);
269 Context->Data = Buffer;
270
271 return STATUS_SUCCESS;
272}
Definition: bufpool.h:45
struct _RXACT_DATA RXACT_DATA
#define RXACT_DEFAULT_BUFFER_SIZE
Definition: rxact.c:17

◆ RXactInitializeContext()

static VOID NTAPI RXactInitializeContext ( PRXACT_CONTEXT  Context,
HANDLE  RootDirectory,
HANDLE  KeyHandle 
)
static

Definition at line 64 of file rxact.c.

68{
69 Context->Data = NULL;
70 Context->RootDirectory = RootDirectory;
71 Context->CanUseHandles = TRUE;
72 Context->KeyHandle = KeyHandle;
73}
#define TRUE
Definition: types.h:120

Referenced by RtlAbortRXact(), and RtlInitializeRXact().

◆ RXactpCommit()

static NTSTATUS NTAPI RXactpCommit ( PRXACT_CONTEXT  Context)
static

Definition at line 126 of file rxact.c.

128{
131 NTSTATUS Status, TmpStatus;
133 ULONG i;
134
135 Data = Context->Data;
136
137 /* The first action record starts after the data header */
138 Action = (PRXACT_ACTION)(Data + 1);
139
140 /* Loop all recorded actions */
141 for (i = 0; i < Data->ActionCount; i++)
142 {
143 /* Translate relative offsets to actual pointers */
144 Action->KeyName.Buffer = (PWSTR)((PUCHAR)Data + (ULONG_PTR)Action->KeyName.Buffer);
145 Action->ValueName.Buffer = (PWSTR)((PUCHAR)Data + (ULONG_PTR)Action->ValueName.Buffer);
146 Action->ValueData = (PUCHAR)Data + (ULONG_PTR)Action->ValueData;
147
148 /* Check what kind of action this is */
149 if (Action->Type == RXactDeleteKey)
150 {
151 /* This is a delete action. Check if we can use a handle */
152 if ((Action->KeyHandle != INVALID_HANDLE_VALUE) && Context->CanUseHandles)
153 {
154 /* Delete the key by the given handle */
155 Status = ZwDeleteKey(Action->KeyHandle);
156 if (!NT_SUCCESS(Status))
157 {
158 return Status;
159 }
160 }
161 else
162 {
163 /* We cannot use a handle, open the key first by it's name */
164 Status = RXactpOpenTargetKey(Context->RootDirectory,
166 &Action->KeyName,
167 &KeyHandle);
168 if (NT_SUCCESS(Status))
169 {
170 Status = ZwDeleteKey(KeyHandle);
171 TmpStatus = NtClose(KeyHandle);
172 ASSERT(NT_SUCCESS(TmpStatus));
173 if (!NT_SUCCESS(Status))
174 {
175 return Status;
176 }
177 }
178 else
179 {
180 /* Failed to open the key, it's ok, if it was not found */
182 return Status;
183 }
184 }
185 }
186 else if (Action->Type == RXactSetValueKey)
187 {
188 /* This is a set action. Check if we can use a handle */
189 if ((Action->KeyHandle != INVALID_HANDLE_VALUE) && Context->CanUseHandles)
190 {
191 /* Set the key value using the given key handle */
192 Status = ZwSetValueKey(Action->KeyHandle,
193 &Action->ValueName,
194 0,
195 Action->ValueType,
196 Action->ValueData,
197 Action->ValueDataSize);
198 if (!NT_SUCCESS(Status))
199 {
200 return Status;
201 }
202 }
203 else
204 {
205 /* We cannot use a handle, open the key first by it's name */
206 Status = RXactpOpenTargetKey(Context->RootDirectory,
208 &Action->KeyName,
209 &KeyHandle);
210 if (!NT_SUCCESS(Status))
211 {
212 return Status;
213 }
214
215 /* Set the key value */
216 Status = ZwSetValueKey(KeyHandle,
217 &Action->ValueName,
218 0,
219 Action->ValueType,
220 Action->ValueData,
221 Action->ValueDataSize);
222
223 TmpStatus = NtClose(KeyHandle);
224 ASSERT(NT_SUCCESS(TmpStatus));
225
226 if (!NT_SUCCESS(Status))
227 {
228 return Status;
229 }
230 }
231 }
232 else
233 {
234 ASSERT(FALSE);
236 }
237
238 /* Go to the next action record */
240 }
241
242 return STATUS_SUCCESS;
243}
#define ULONG_PTR
Definition: config.h:101
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
struct _RXACT_ACTION * PRXACT_ACTION
static NTSTATUS NTAPI RXactpOpenTargetKey(HANDLE RootDirectory, ULONG ActionType, PUNICODE_STRING KeyName, PHANDLE KeyHandle)
Definition: rxact.c:78
uint16_t * PWSTR
Definition: typedefs.h:56
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149

Referenced by RtlApplyRXact(), RtlApplyRXactNoFlush(), and RtlInitializeRXact().

◆ RXactpOpenTargetKey()

static NTSTATUS NTAPI RXactpOpenTargetKey ( HANDLE  RootDirectory,
ULONG  ActionType,
PUNICODE_STRING  KeyName,
PHANDLE  KeyHandle 
)
static

Definition at line 78 of file rxact.c.

83{
87
88 /* Check what kind of action this is */
89 if (ActionType == RXactDeleteKey)
90 {
91 /* This is a delete, so open the key for delete */
93 KeyName,
96 NULL);
98 }
99 else if (ActionType == RXactSetValueKey)
100 {
101 /* This is a create, so open or create with write access */
103 KeyName,
106 NULL);
107 Status = ZwCreateKey(KeyHandle,
108 KEY_WRITE,
110 0,
111 NULL,
112 0,
113 &Disposition);
114 }
115 else
116 {
118 }
119
120 return Status;
121}

Referenced by RXactpCommit().