20#define GUID_STRING_CHARS 38
21#define GUID_STRING_BYTES (GUID_STRING_CHARS * sizeof(WCHAR))
44 PHANDLE GuidKeyRealP, DeviceKeyRealP, InstanceKeyRealP;
45 HANDLE GuidKeyReal, DeviceKeyReal, InstanceKeyReal;
51 GuidKeyRealP = GuidKey;
53 GuidKeyRealP = &GuidKeyReal;
55 if (DeviceKey !=
NULL)
56 DeviceKeyRealP = DeviceKey;
58 DeviceKeyRealP = &DeviceKeyReal;
60 if (InstanceKey !=
NULL)
61 InstanceKeyRealP = InstanceKey;
63 InstanceKeyRealP = &InstanceKeyReal;
66 *DeviceKeyRealP =
NULL;
67 *InstanceKeyRealP =
NULL;
77 Status = ZwOpenKey(&ClassesKey,
82 DPRINT1(
"Failed to open %wZ\n", &BaseKeyU);
101 Status = ZwCreateKey(GuidKeyRealP,
152 Status = ZwCreateKey(DeviceKeyRealP,
170 Status = ZwCreateKey(InstanceKeyRealP,
202 if (*GuidKeyRealP !=
NULL)
205 if (*DeviceKeyRealP !=
NULL)
208 if (*InstanceKeyRealP !=
NULL)
245 HANDLE InstanceKey, DeviceParametersKey;
263 Status = ZwCreateKey(&DeviceParametersKey,
346 DPRINT(
"RtlStringFromGUID() failed with status 0x%08lx\n",
Status);
355 DPRINT(
"ExAllocatePool() failed\n");
363 DPRINT(
"RtlAppendUnicodeStringToString() failed with status 0x%08lx\n",
Status);
369 DPRINT(
"RtlAppendUnicodeToString() failed with status 0x%08lx\n",
Status);
375 DPRINT(
"RtlAppendUnicodeToString() failed with status 0x%08lx\n",
Status);
381 DPRINT(
"RtlAppendUnicodeStringToString() failed with status 0x%08lx\n",
Status);
397 DPRINT(
"ZwOpenKey() failed with status 0x%08lx\n",
Status);
401 *pInterfaceKey = InterfaceKey;
407 if (InterfaceKey !=
NULL)
474 ULONG i = 0,
j,
Size, NeededLength, ActualLength, LinkedValue;
493 if (DeviceObjectExtension->
DeviceNode->InstancePath.Length == 0)
499 InstanceDevicePath = &DeviceObjectExtension->
DeviceNode->InstancePath;
506 DPRINT(
"IopOpenInterfaceKey() failed with status 0x%08lx\n",
Status);
526 DPRINT(
"ZwEnumerateKey() failed with status 0x%08lx\n",
Status);
533 DPRINT(
"ExAllocatePool() failed\n");
546 DPRINT(
"ZwEnumerateKey() failed with status 0x%08lx\n",
Status);
565 DPRINT(
"ZwOpenKey() failed with status 0x%08lx\n",
Status);
578 ActualLength = NeededLength;
598 FoundRightPDO =
TRUE;
633 DPRINT(
"ZwEnumerateKey() failed with status 0x%08lx\n",
Status);
640 DPRINT(
"ExAllocatePool() failed\n");
653 DPRINT(
"ZwEnumerateKey() failed with status 0x%08lx\n",
Status);
662 goto NextReferenceString;
678 DPRINT(
"ZwOpenKey() failed with status 0x%08lx\n",
Status);
702 goto NextReferenceString;
711 Status = ZwQueryValueKey(ControlKey,
719 ActualLength = NeededLength;
727 Status = ZwQueryValueKey(ControlKey,
742 DPRINT1(
"Bad registry read\n");
752 if (LinkedValue == 0)
755 goto NextReferenceString;
775 DPRINT(
"ZwQueryValueKey() failed with status 0x%08lx\n",
Status);
781 DPRINT(
"ExAllocatePool() failed\n");
794 DPRINT(
"ZwQueryValueKey() failed with status 0x%08lx\n",
Status);
799 DPRINT(
"Unexpected registry type 0x%lx (expected 0x%lx)\n", bip->
Type,
REG_SZ);
805 DPRINT(
"Registry string too short (length %lu, expected %lu at least)\n", bip->
DataLength, 5 *
sizeof(
WCHAR));
826 DPRINT(
"ExAllocatePool() failed\n");
835 ReturnBuffer.
Buffer = NewBuffer;
841 DPRINT(
"RtlAppendUnicodeStringToString() failed with status 0x%08lx\n",
Status);
856 if (ReferenceKey !=
NULL)
861 if (ControlKey !=
NULL)
888 DPRINT(
"ExAllocatePool() failed\n");
897 ReturnBuffer.
Buffer = NewBuffer;
906 if (InterfaceKey !=
NULL)
908 if (DeviceKey !=
NULL)
910 if (ReferenceKey !=
NULL)
912 if (ControlKey !=
NULL)
980 DPRINT(
"IoRegisterDeviceInterface(): PDO %p, RefString: %wZ\n",
994 if (DeviceObjectExtension->
DeviceNode->InstancePath.Length == 0)
1015 DPRINT(
"RtlStringFromGUID() failed with status 0x%08lx\n",
Status);
1023 sizeof(PdoNameInfoBuffer),
1027 DPRINT(
"ObQueryNameString() failed with status 0x%08lx\n",
Status);
1030 ASSERT(PdoNameInfo->Name.Length);
1043 DPRINT(
"ExAllocatePool() failed\n");
1068 DPRINT(
"ZwCreateKey() failed with status 0x%08lx\n",
Status);
1074 InterfaceKeyName.
Length = 0;
1083 if (!InterfaceKeyName.
Buffer)
1085 DPRINT(
"ExAllocatePool() failed\n");
1090 StartIndex = InterfaceKeyName.
Length /
sizeof(
WCHAR);
1094 if (InterfaceKeyName.
Buffer[StartIndex +
i] ==
'\\')
1095 InterfaceKeyName.
Buffer[StartIndex +
i] =
'#';
1119 DPRINT(
"ZwCreateKey() failed with status 0x%08lx\n",
Status);
1135 DPRINT(
"ZwSetValueKey() failed with status 0x%08lx\n",
Status);
1153 DPRINT(
"ExAllocatePool() failed\n");
1183 DPRINT(
"ZwCreateKey() failed with status 0x%08lx\n",
Status);
1206 DPRINT(
"ExAllocatePool() failed\n");
1228 DPRINT(
"IoRegisterDeviceInterface(): creating symbolic link %wZ -> %wZ\n",
SymbolicLinkName, &PdoNameInfo->Name);
1242 DPRINT1(
"IoCreateSymbolicLink() failed with status 0x%08lx\n", SymLinkStatus);
1250 return SymLinkStatus;
1271 DPRINT1(
"ZwSetValueKey() failed with status 0x%08lx\n",
Status);
1318 HANDLE InstanceHandle, ControlHandle;
1327 USHORT ReferenceStringOffset;
1355 if (LinkNameNoPrefix.
Buffer[
i] ==
L'\\')
1360 ReferenceStringOffset =
i *
sizeof(
WCHAR);
1363 ASSERT(LinkNameNoPrefix.
Length >= ReferenceStringOffset);
1395 Status = ZwCreateKey(&ControlHandle,
1405 DPRINT1(
"Failed to create the Control subkey\n");
1409 LinkedValue = (
Enable ? 1 : 0);
1412 Status = ZwSetValueKey(ControlHandle,
1421 DPRINT1(
"Failed to write the Linked value\n");
1458 DPRINT1(
"IopGetDeviceObjectFromDeviceInstance failed to find device object for %wZ\n", &
DeviceInstance);
PDEVICE_OBJECT PhysicalDeviceObject
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
#define STATUS_NOT_IMPLEMENTED
#define NT_SUCCESS(StatCode)
static void cleanup(void)
static const WCHAR SymbolicLink[]
static const WCHAR DeviceInstance[]
#define ASSERT_IRQL_EQUAL(x)
const GUID GUID_DEVICE_INTERFACE_ARRIVAL
const GUID GUID_DEVICE_INTERFACE_REMOVAL
#define ExAllocatePoolWithTag(hernya, size, tag)
#define RtlCompareMemory(s1, s2, l)
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
#define ExAllocatePool(type, size)
_Must_inspect_result_ _In_ WDFDEVICE _In_ REFGUID EventGuid
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
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 GLint GLint j
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define OBJ_KERNEL_HANDLE
#define OBJ_CASE_INSENSITIVE
NTSYSAPI NTSTATUS WINAPI RtlGUIDFromString(PUNICODE_STRING, GUID *)
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
#define ExFreePoolWithTag(_P, _T)
#define InitializeObjectAttributes(p, n, a, r, s)
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ PNDIS_STRING SubKeyName
struct _EXTENDED_DEVOBJ_EXTENSION * PEXTENDED_DEVOBJ_EXTENSION
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
@ KeyValuePartialInformation
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define KEY_CREATE_SUB_KEY
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
#define REG_OPTION_NON_VOLATILE
struct _OBJECT_NAME_INFORMATION OBJECT_NAME_INFORMATION
struct _OBJECT_NAME_INFORMATION * POBJECT_NAME_INFORMATION
#define KEY_ENUMERATE_SUB_KEYS
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSYSAPI BOOLEAN NTAPI RtlPrefixUnicodeString(IN PUNICODE_STRING String1, IN PUNICODE_STRING String2, IN BOOLEAN CaseInSensitive)
#define REG_OPTION_VOLATILE
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
NTSTATUS IopQueueDeviceChangeEvent(_In_ const GUID *EventGuid, _In_ const GUID *InterfaceClassGuid, _In_ PUNICODE_STRING SymbolicLinkName)
VOID PiNotifyDeviceInterfaceChange(_In_ LPCGUID Event, _In_ LPCGUID InterfaceClassGuid, _In_ PUNICODE_STRING SymbolicLinkName)
Delivers the event to all drivers subscribed to EventCategoryDeviceInterfaceChange.
PDEVICE_OBJECT IopGetDeviceObjectFromDeviceInstance(PUNICODE_STRING DeviceInstance)
static NTSTATUS IopOpenInterfaceKey(IN CONST GUID *InterfaceClassGuid, IN ACCESS_MASK DesiredAccess, OUT HANDLE *pInterfaceKey)
NTSTATUS NTAPI IoOpenDeviceInterfaceRegistryKey(IN PUNICODE_STRING SymbolicLinkName, IN ACCESS_MASK DesiredAccess, OUT PHANDLE DeviceInterfaceKey)
NTSTATUS NTAPI IoGetDeviceInterfaces(IN CONST GUID *InterfaceClassGuid, IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, IN ULONG Flags, OUT PWSTR *SymbolicLinkList)
static PWCHAR BaseKeyString
NTSTATUS NTAPI IoGetDeviceInterfaceAlias(IN PUNICODE_STRING SymbolicLinkName, IN CONST GUID *AliasInterfaceClassGuid, OUT PUNICODE_STRING AliasSymbolicLinkName)
NTSTATUS NTAPI IoRegisterDeviceInterface(IN PDEVICE_OBJECT PhysicalDeviceObject, IN CONST GUID *InterfaceClassGuid, IN PUNICODE_STRING ReferenceString OPTIONAL, OUT PUNICODE_STRING SymbolicLinkName)
NTSTATUS NTAPI IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName, IN BOOLEAN Enable)
static NTSTATUS OpenRegistryHandlesFromSymbolicLink(IN PUNICODE_STRING SymbolicLinkName, IN ACCESS_MASK DesiredAccess, IN OPTIONAL PHANDLE GuidKey, IN OPTIONAL PHANDLE DeviceKey, IN OPTIONAL PHANDLE InstanceKey)
#define GUID_STRING_BYTES
NTSTATUS NTAPI IoCreateSymbolicLink(IN PUNICODE_STRING SymbolicLinkName, IN PUNICODE_STRING DeviceName)
NTSTATUS NTAPI IoDeleteSymbolicLink(IN PUNICODE_STRING SymbolicLinkName)
#define STATUS_OBJECT_NAME_EXISTS
#define STATUS_NO_MORE_ENTRIES
#define STATUS_INVALID_PARAMETER_1
NTSTATUS NTAPI ObQueryNameString(IN PVOID Object, OUT POBJECT_NAME_INFORMATION ObjectNameInfo, IN ULONG Length, OUT PULONG ReturnLength)
#define REGSTR_PATH_DEVICE_CLASSES
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define STATUS_BUFFER_TOO_SMALL
PULONG MinorVersion OPTIONAL
struct _DEVICE_NODE * DeviceNode
#define RTL_CONSTANT_STRING(s)
#define RtlCopyMemory(Destination, Source, Length)
#define STATUS_INVALID_DEVICE_REQUEST
#define STATUS_INVALID_PARAMETER
#define STATUS_UNSUCCESSFUL
#define STATUS_OBJECT_NAME_COLLISION
#define STATUS_INSUFFICIENT_RESOURCES
#define STATUS_OBJECT_NAME_NOT_FOUND
_In_ ULONG _In_ PVOID StartPosition
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDEVICE _In_ CONST GUID _In_opt_ PCUNICODE_STRING ReferenceString
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING SymbolicLinkName
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
_In_ WDF_WMI_PROVIDER_CONTROL Control
_Must_inspect_result_ _In_ ULONG Flags
_In_opt_ PDEVICE_OBJECT _In_ ULONG _Outptr_result_nullonfailure_ _At_ * SymbolicLinkList(return==0, __drv_allocatesMem(Mem))) PZZWSTR *SymbolicLinkList
_In_ CONST GUID * AliasInterfaceClassGuid
_In_ ACCESS_MASK _Out_ PHANDLE DeviceInterfaceKey
_In_ CONST GUID * InterfaceClassGuid
#define DEVICE_INTERFACE_INCLUDE_NONACTIVE
#define ObDereferenceObject