@@ -1319,6 +1319,63 @@ PiControlGetInterfaceDeviceAlias(
13191319 & AliasSymbolicLinkName );
13201320}
13211321
1322+ static
1323+ NTSTATUS
1324+ PiControlDeviceClassAssociation (
1325+ _In_ PPLUGPLAY_CONTROL_CLASS_ASSOCIATION_DATA ControlData )
1326+ {
1327+ PDEVICE_OBJECT DeviceObject = NULL ;
1328+ UNICODE_STRING SymbolicLink ;
1329+ NTSTATUS Status ;
1330+
1331+ DPRINT ("PiControlDeviceClassAssociation()\n" );
1332+ DPRINT ("DeviceInstance: %wZ\n" , & ControlData -> DeviceInstance );
1333+
1334+ if (ControlData -> Register )
1335+ {
1336+ if ((ControlData -> DeviceInstance .Buffer == NULL ) ||
1337+ (ControlData -> DeviceInstance .Length == 0 ))
1338+ return STATUS_INVALID_PARAMETER ;
1339+
1340+ if (ControlData -> InterfaceGuid == NULL )
1341+ return STATUS_INVALID_PARAMETER ;
1342+
1343+ DeviceObject = IopGetDeviceObjectFromDeviceInstance (& ControlData -> DeviceInstance );
1344+ if (DeviceObject == NULL )
1345+ return STATUS_NO_SUCH_DEVICE ;
1346+
1347+ Status = IoRegisterDeviceInterface (DeviceObject ,
1348+ ControlData -> InterfaceGuid ,
1349+ & ControlData -> Reference ,
1350+ & SymbolicLink );
1351+ if (NT_SUCCESS (Status ))
1352+ {
1353+ if (SymbolicLink .Length + sizeof (WCHAR ) <= ControlData -> SymbolicLinkNameLength )
1354+ {
1355+ RtlCopyMemory (ControlData -> SymbolicLinkName , SymbolicLink .Buffer , SymbolicLink .Length );
1356+ ControlData -> SymbolicLinkName [SymbolicLink .Length / sizeof (WCHAR )] = UNICODE_NULL ;
1357+ ControlData -> SymbolicLinkNameLength = SymbolicLink .Length + sizeof (WCHAR );
1358+ }
1359+ else
1360+ {
1361+ ControlData -> SymbolicLinkNameLength = SymbolicLink .Length + sizeof (WCHAR );
1362+ Status = STATUS_BUFFER_TOO_SMALL ;
1363+ }
1364+
1365+ ExFreePool (SymbolicLink .Buffer );
1366+ }
1367+
1368+ ObDereferenceObject (DeviceObject );
1369+ }
1370+ else
1371+ {
1372+ UNIMPLEMENTED ;
1373+ Status = STATUS_NOT_IMPLEMENTED ;
1374+ }
1375+
1376+ return Status ;
1377+ }
1378+
13221379
13231380/* PUBLIC FUNCTIONS **********************************************************/
13241381
@@ -1595,7 +1652,10 @@ NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass,
15951652 return STATUS_INVALID_PARAMETER ;
15961653 return IopGetDeviceProperty ((PPLUGPLAY_CONTROL_PROPERTY_DATA )Buffer );
15971654
1598- // case PlugPlayControlDeviceClassAssociation:
1655+ case PlugPlayControlDeviceClassAssociation :
1656+ if (!Buffer || BufferLength < sizeof (PLUGPLAY_CONTROL_CLASS_ASSOCIATION_DATA ))
1657+ return STATUS_INVALID_PARAMETER ;
1658+ return PiControlDeviceClassAssociation ((PPLUGPLAY_CONTROL_CLASS_ASSOCIATION_DATA )Buffer );
15991659
16001660 case PlugPlayControlGetRelatedDevice :
16011661 if (!Buffer || BufferLength < sizeof (PLUGPLAY_CONTROL_RELATED_DEVICE_DATA ))
0 commit comments