42 HANDLE SourceSubKeyHandle, DestSubKeyHandle;
46 InformationLength = 256;
53 if (InfoBuffer ==
NULL)
59 if (InfoBuffer ==
NULL)
61 ERR_(VIDEOPRT,
"Could not allocate buffer for key info\n");
67 KeyInformation = InfoBuffer;
68 Status = ZwEnumerateKey(SourceKeyHandle,
92 ERR_(VIDEOPRT,
"ZwEnumerateKey failed, status 0x%lx\n",
Status);
110 ERR_(VIDEOPRT,
"failed to open the source key.\n");
120 Status = ZwCreateKey(&DestSubKeyHandle,
129 ERR_(VIDEOPRT,
"failed to create the destination key.\n");
139 WARN_(VIDEOPRT,
"failed to copy subkey '%wZ'.\n", &NameString);
155 if (InfoBuffer ==
NULL)
161 if (InfoBuffer ==
NULL)
163 ERR_(VIDEOPRT,
"Could not allocate buffer for key values\n");
169 KeyValueInformation = InfoBuffer;
170 Status = ZwEnumerateValueKey(SourceKeyHandle,
195 ERR_(VIDEOPRT,
"ZwEnumerateValueKey failed, status 0x%lx\n",
Status);
200 NameString.
Buffer = KeyValueInformation->
Name;
205 Status = ZwSetValueKey(DestKeyHandle,
208 KeyValueInformation->
Type,
214 WARN_(VIDEOPRT,
"failed to set value '%wZ'.\n", &NameString);
223 if (InfoBuffer !=
NULL)
243 Status = ZwQueryValueKey(SourceKeyHandle,
259 if (ValueInformation ==
NULL)
265 Status = ZwQueryValueKey(SourceKeyHandle,
278 Status = ZwSetValueKey(DestKeyHandle,
281 ValueInformation->
Type,
282 ValueInformation->
Data,
289 ERR_(VIDEOPRT,
"ZwSetValueKey failed: status 0x%lx\n",
Status);
315 ERR_(VIDEOPRT,
"Failed to open device software key. Status 0x%lx\n",
Status);
332 ERR_(VIDEOPRT,
"Failed to open settings key. Status 0x%lx\n",
Status);
345 ERR_(VIDEOPRT,
"ZwOpenKey failed for settings key: status 0x%lx\n",
Status);
430 ERR_(VIDEOPRT,
"IntDuplicateUnicodeString() failed with status 0x%lx\n",
Status);
441 ERR_(VIDEOPRT,
"IoOpenDeviceRegistryKey failed: status 0x%lx\n",
Status);
451 sizeof(VideoIdBuffer),
459 ERR_(VIDEOPRT,
"ExUuidCreate failed: status 0x%lx\n",
Status);
468 ERR_(VIDEOPRT,
"RtlStringFromGUID failed: status 0x%lx\n",
Status);
476 VideoIdString.Buffer,
487 ValueInformation->
Data,
491 ERR_(VIDEOPRT,
"ZwSetValueKey failed: status 0x%lx\n",
Status);
498 VideoIdString.Buffer = (
PWCHAR)ValueInformation->
Data;
500 VideoIdString.MaximumLength = VideoIdString.Length;
506 KeyMaxLength = ControlVideoPathName.
Length +
507 VideoIdString.Length +
518 ERR_(VIDEOPRT,
"Failed to allocate key name buffer.\n");
524 &ControlVideoPathName);
570 ERR_(VIDEOPRT,
"Failed to open settings key. Status 0x%lx\n",
Status);
583 ERR_(VIDEOPRT,
"Failed to open settings key. Status 0x%lx\n",
Status);
606 static WCHAR RegistryMachineSystem[] =
L"\\REGISTRY\\MACHINE\\SYSTEM\\";
607 static WCHAR CurrentControlSet[] =
L"CURRENTCONTROLSET\\";
608 static WCHAR ControlSet[] =
L"CONTROLSET";
609 static WCHAR Insert1[] =
L"Hardware Profiles\\Current\\System\\CurrentControlSet\\";
610 static WCHAR Insert2[] =
L"\\Device";
612 WCHAR DeviceNumberBuffer[20];
620 DeviceNumberString.
Length = 0;
621 DeviceNumberString.
MaximumLength =
sizeof(DeviceNumberBuffer);
622 DeviceNumberString.
Buffer = DeviceNumberBuffer;
633 wcslen(RegistryMachineSystem)));
636 AfterControlSet.
Buffer +=
wcslen(RegistryMachineSystem);
640 if (AfterControlSet.
Length >
sizeof(CurrentControlSet) &&
647 else if (AfterControlSet.
Length >
sizeof(ControlSet) &&
652 while (AfterControlSet.
Length > 0 &&
653 *AfterControlSet.
Buffer >=
L'0' &&
654 *AfterControlSet.
Buffer <=
L'9')
660 Valid = (AfterControlSet.
Length > 0 &&
L'\\' == *AfterControlSet.
Buffer);
673 INFO_(VIDEOPRT,
"Using old registry key as 'UseNewKey' is FALSE\n");
679 + DeviceNumberString.
Length;
681 DeviceRegistryPath->MaximumLength,
683 if (DeviceRegistryPath->Buffer !=
NULL)
686 wcsncpy(DeviceRegistryPath->Buffer,
716 DeviceRegistryPath->MaximumLength,
719 if (!DeviceRegistryPath->Buffer)
727 DPRINT(
"Formatted registry key '%wZ' -> '%wZ'\n",
_In_ PCHAR _In_ ULONG DeviceNumber
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
#define NT_SUCCESS(StatCode)
static const WCHAR Cleanup[]
#define ExAllocatePoolWithTag(hernya, size, tag)
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
#define RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING
#define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define OBJ_KERNEL_HANDLE
#define OBJ_CASE_INSENSITIVE
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
UNICODE_STRING DriverRegistryPath
NTKERNELAPI NTSTATUS ExUuidCreate(OUT UUID *Uuid)
#define ExFreePoolWithTag(_P, _T)
#define InitializeObjectAttributes(p, n, a, r, s)
_Out_ _Inout_ POEM_STRING _In_ PCUNICODE_STRING SourceString
_Out_ _Inout_ POEM_STRING DestinationString
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
@ KeyValuePartialInformation
@ KeyValueFullInformation
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RTL_REGISTRY_ABSOLUTE
#define REG_OPTION_NON_VOLATILE
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
NTSYSAPI NTSTATUS NTAPI RtlIntegerToUnicodeString(ULONG Value, ULONG Base, PUNICODE_STRING String)
struct _KEY_VALUE_PARTIAL_INFORMATION * PKEY_VALUE_PARTIAL_INFORMATION
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
_In_ ULONG _In_ ULONG _In_ ULONG Length
#define STATUS_NO_MORE_ENTRIES
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
NTSTATUS NTAPI IoOpenDeviceRegistryKey(IN PDEVICE_OBJECT DeviceObject, IN ULONG DevInstKeyType, IN ACCESS_MASK DesiredAccess, OUT PHANDLE DevInstRegKey)
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
NTSTATUS NTAPI RtlCheckRegistryKey(IN ULONG RelativeTo, IN PWSTR Path)
NTSTATUS NTAPI RtlCreateRegistryKey(IN ULONG RelativeTo, IN PWSTR Path)
#define STATUS_BUFFER_TOO_SMALL
#define STATUS_BUFFER_OVERFLOW
unsigned short MaximumLength
PDEVICE_OBJECT PhysicalDeviceObject
UNICODE_STRING RegistryPath
UNICODE_STRING NewRegistryPath
#define RTL_CONSTANT_STRING(s)
#define RtlCopyMemory(Destination, Source, Length)
#define STATUS_INVALID_PARAMETER
#define STATUS_INSUFFICIENT_RESOURCES
#define PLUGPLAY_REGKEY_DRIVER
BOOLEAN VideoPortUseNewKey
#define TAG_VIDEO_PORT_BUFFER
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
NTSTATUS IntDuplicateUnicodeString(IN ULONG Flags, IN PCUNICODE_STRING SourceString, OUT PUNICODE_STRING DestinationString)
NTSTATUS NTAPI IntCreateRegistryPath(IN PCUNICODE_STRING DriverRegistryPath, IN ULONG DeviceNumber, OUT PUNICODE_STRING DeviceRegistryPath)
NTSTATUS NTAPI IntCopyRegistryValue(HANDLE SourceKeyHandle, HANDLE DestKeyHandle, PWSTR ValueName)
NTSTATUS NTAPI IntCreateNewRegistryPath(PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
NTSTATUS NTAPI IntSetupDeviceSettingsKey(PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
NTSTATUS NTAPI IntCopyRegistryKey(_In_ HANDLE SourceKeyHandle, _In_ HANDLE DestKeyHandle)
_In_ ULONG _Out_opt_ PULONG RequiredLength
#define GUID_STRING_LENGTH
_Must_inspect_result_ _In_ ULONG Flags
_In_ ULONG _In_ ACCESS_MASK _Out_ PHANDLE DevInstRegKey
#define PLUGPLAY_REGKEY_DEVICE