[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [XENBUS PATCH v2 1/2] Add RegistryQueryQwordValue
Signed-off-by: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx> Reviewed-by: Owen Smith <owen.smith@xxxxxxxxx> --- src/common/registry.c | 70 +++++++++++++++++++++++++++++++++++++++++++ src/common/registry.h | 7 +++++ 2 files changed, 77 insertions(+) diff --git a/src/common/registry.c b/src/common/registry.c index 7965233..1f7a73c 100644 --- a/src/common/registry.c +++ b/src/common/registry.c @@ -853,6 +853,76 @@ fail1: return status; } +NTSTATUS +RegistryQueryQwordValue( + _In_ HANDLE Key, + _In_ PSTR Name, + _Out_ PULONGLONG Value + ) +{ + ANSI_STRING Ansi; + UNICODE_STRING Unicode; + PKEY_VALUE_PARTIAL_INFORMATION Partial; + ULONG Size; + NTSTATUS status; + + RtlInitAnsiString(&Ansi, Name); + + status = RtlAnsiStringToUnicodeString(&Unicode, &Ansi, TRUE); + if (!NT_SUCCESS(status)) + goto fail1; + + status = ZwQueryValueKey(Key, + &Unicode, + KeyValuePartialInformation, + NULL, + 0, + &Size); + if (!NT_SUCCESS(status) && + status != STATUS_BUFFER_OVERFLOW && + status != STATUS_BUFFER_TOO_SMALL) + goto fail2; + + Partial = __RegistryAllocate(Size); + + status = STATUS_NO_MEMORY; + if (Partial == NULL) + goto fail3; + + status = ZwQueryValueKey(Key, + &Unicode, + KeyValuePartialInformation, + Partial, + Size, + &Size); + if (!NT_SUCCESS(status)) + goto fail4; + + status = STATUS_INVALID_PARAMETER; + if (Partial->Type != REG_QWORD || + Partial->DataLength != sizeof (ULONGLONG)) + goto fail5; + + *Value = *(PULONGLONG)Partial->Data; + + __RegistryFree(Partial); + + RtlFreeUnicodeString(&Unicode); + + return STATUS_SUCCESS; + +fail5: +fail4: + __RegistryFree(Partial); + +fail3: +fail2: + RtlFreeUnicodeString(&Unicode); + +fail1: + return status; +} + NTSTATUS RegistryUpdateDwordValue( _In_ HANDLE Key, diff --git a/src/common/registry.h b/src/common/registry.h index e70a6ed..26bc0c6 100644 --- a/src/common/registry.h +++ b/src/common/registry.h @@ -142,6 +142,13 @@ RegistryQueryDwordValue( _Out_ PULONG Value ); +extern NTSTATUS +RegistryQueryQwordValue( + _In_ HANDLE Key, + _In_ PSTR Name, + _Out_ PULONGLONG Value + ); + extern NTSTATUS RegistryUpdateDwordValue( _In_ HANDLE Key, -- 2.50.1.windows.1 Ngoc Tu Dinh | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |