41 HANDLE SourceSubKeyHandle, DestSubKeyHandle;
45 InformationLength = 256;
52 if (InfoBuffer ==
NULL)
58 if (InfoBuffer ==
NULL)
60 ERR_(VIDEOPRT,
"Could not allocate buffer for key info\n");
66 KeyInformation = InfoBuffer;
67 Status = ZwEnumerateKey(SourceKeyHandle,
91 ERR_(VIDEOPRT,
"ZwEnumerateKey failed, status 0x%lx\n",
Status);
109 ERR_(VIDEOPRT,
"failed to open the source key.\n");
119 Status = ZwCreateKey(&DestSubKeyHandle,
128 ERR_(VIDEOPRT,
"failed to create the destination key.\n");
138 WARN_(VIDEOPRT,
"failed to copy subkey '%wZ'.\n", &NameString);
154 if (InfoBuffer ==
NULL)
160 if (InfoBuffer ==
NULL)
162 ERR_(VIDEOPRT,
"Could not allocate buffer for key values\n");
168 KeyValueInformation = InfoBuffer;
169 Status = ZwEnumerateValueKey(SourceKeyHandle,
194 ERR_(VIDEOPRT,
"ZwEnumerateValueKey failed, status 0x%lx\n",
Status);
199 NameString.
Buffer = KeyValueInformation->
Name;
204 Status = ZwSetValueKey(DestKeyHandle,
207 KeyValueInformation->
Type,
213 WARN_(VIDEOPRT,
"failed to set value '%wZ'.\n", &NameString);
222 if (InfoBuffer !=
NULL)
242 Status = ZwQueryValueKey(SourceKeyHandle,
258 if (ValueInformation ==
NULL)
264 Status = ZwQueryValueKey(SourceKeyHandle,
277 Status = ZwSetValueKey(DestKeyHandle,
280 ValueInformation->
Type,
281 ValueInformation->
Data,
288 ERR_(VIDEOPRT,
"ZwSetValueKey failed: status 0x%lx\n",
Status);
311 ERR_(VIDEOPRT,
"Failed to open device software key. Status 0x%lx\n",
Status);
328 ERR_(VIDEOPRT,
"Failed to open settings key. Status 0x%lx\n",
Status);
341 ERR_(VIDEOPRT,
"ZwOpenKey failed for settings key: status 0x%lx\n",
Status);
380 ERR_(VIDEOPRT,
"IoOpenDeviceRegistryKey failed: status 0x%lx\n",
Status);
390 sizeof(VideoIdBuffer),
398 ERR_(VIDEOPRT,
"ExUuidCreate failed: status 0x%lx\n",
Status);
407 ERR_(VIDEOPRT,
"RtlStringFromGUID failed: status 0x%lx\n",
Status);
415 VideoIdString.Buffer,
426 ValueInformation->
Data,
430 ERR_(VIDEOPRT,
"ZwSetValueKey failed: status 0x%lx\n",
Status);
437 VideoIdString.Buffer = (
PWCHAR)ValueInformation->
Data;
439 VideoIdString.MaximumLength = VideoIdString.Length;
445 KeyMaxLength = ControlVideoPathName.
Length +
446 VideoIdString.Length +
457 ERR_(VIDEOPRT,
"Failed to allocate key name buffer.\n");
463 &ControlVideoPathName);
504 ERR_(VIDEOPRT,
"Failed to open settings key. Status 0x%lx\n",
Status);
517 ERR_(VIDEOPRT,
"Failed to open settings key. Status 0x%lx\n",
Status);
536 static WCHAR RegistryMachineSystem[] =
L"\\REGISTRY\\MACHINE\\SYSTEM\\";
537 static WCHAR CurrentControlSet[] =
L"CURRENTCONTROLSET\\";
538 static WCHAR ControlSet[] =
L"CONTROLSET";
539 static WCHAR Insert1[] =
L"Hardware Profiles\\Current\\System\\CurrentControlSet\\";
540 static WCHAR Insert2[] =
L"\\Device0";
549 wcslen(RegistryMachineSystem)));
552 AfterControlSet.
Buffer +=
wcslen(RegistryMachineSystem);
556 if (AfterControlSet.
Length >
sizeof(CurrentControlSet) &&
563 else if (AfterControlSet.
Length >
sizeof(ControlSet) &&
568 while (AfterControlSet.
Length > 0 &&
569 *AfterControlSet.
Buffer >=
L'0' &&
570 *AfterControlSet.
Buffer <=
L'9')
576 Valid = (AfterControlSet.
Length > 0 &&
L'\\' == *AfterControlSet.
Buffer);
591 DeviceRegistryPath->MaximumLength,
593 if (DeviceRegistryPath->Buffer !=
NULL)
596 wcsncpy(DeviceRegistryPath->Buffer,
625 DeviceRegistryPath->MaximumLength,
628 if (!DeviceRegistryPath->Buffer)
635 DPRINT(
"Formatted registry key '%wZ' -> '%wZ'\n",
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
UNICODE_STRING NewRegistryPath
#define STATUS_INSUFFICIENT_RESOURCES
_In_ ULONG _In_ ULONG _In_ ULONG Length
NTSTATUS NTAPI IntCreateNewRegistryPath(PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
#define STATUS_NO_MORE_ENTRIES
#define OBJ_CASE_INSENSITIVE
#define PLUGPLAY_REGKEY_DEVICE
#define GUID_STRING_LENGTH
_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 IntSetupDeviceSettingsKey(PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
#define OBJ_KERNEL_HANDLE
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
#define STATUS_BUFFER_TOO_SMALL
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
#define TAG_VIDEO_PORT_BUFFER
PDEVICE_OBJECT PhysicalDeviceObject
NTSTATUS NTAPI IntCopyRegistryKey(_In_ HANDLE SourceKeyHandle, _In_ HANDLE DestKeyHandle)
NTKERNELAPI NTSTATUS ExUuidCreate(OUT UUID *Uuid)
#define REG_OPTION_NON_VOLATILE
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
#define NT_SUCCESS(StatCode)
struct _KEY_VALUE_PARTIAL_INFORMATION * PKEY_VALUE_PARTIAL_INFORMATION
_In_ WDFCOLLECTION _In_ ULONG Index
NTSTATUS NTAPI IntCreateRegistryPath(IN PCUNICODE_STRING DriverRegistryPath, OUT PUNICODE_STRING DeviceRegistryPath)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define ExAllocatePoolWithTag(hernya, size, tag)
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
#define PLUGPLAY_REGKEY_DRIVER
static const WCHAR Cleanup[]
#define RTL_REGISTRY_ABSOLUTE
_In_ ULONG _In_ ACCESS_MASK _Out_ PHANDLE DevInstRegKey
UNICODE_STRING DriverRegistryPath
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
#define STATUS_BUFFER_OVERFLOW
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
_In_ ULONG _Out_opt_ PULONG RequiredLength
NTSTATUS NTAPI IoOpenDeviceRegistryKey(IN PDEVICE_OBJECT DeviceObject, IN ULONG DevInstKeyType, IN ACCESS_MASK DesiredAccess, OUT PHANDLE DevInstRegKey)
NTSTATUS NTAPI RtlCheckRegistryKey(IN ULONG RelativeTo, IN PWSTR Path)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
#define RtlCopyMemory(Destination, Source, Length)
UNICODE_STRING RegistryPath
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
#define ExFreePoolWithTag(_P, _T)
NTSTATUS NTAPI RtlCreateRegistryKey(IN ULONG RelativeTo, IN PWSTR Path)
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
NTSTATUS NTAPI IntCopyRegistryValue(HANDLE SourceKeyHandle, HANDLE DestKeyHandle, PWSTR ValueName)
#define RTL_CONSTANT_STRING(s)