mirror of
https://github.com/reactos/reactos.git
synced 2024-08-29 22:58:34 +00:00
[NTOS:PNP]
- Add missing SEH/Probe in NtGetPlugPlayEvent and IopGetInterfaceDeviceList, and correctly copy the interface list. Patch by Stephan Röger. CORE-9498 #resolve svn path=/trunk/; revision=67129
This commit is contained in:
parent
36e31c92b2
commit
68348f909b
|
@ -214,22 +214,23 @@ static NTSTATUS
|
||||||
IopGetInterfaceDeviceList(PPLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA DeviceList)
|
IopGetInterfaceDeviceList(PPLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA DeviceList)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
PLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA StackList;
|
||||||
UNICODE_STRING DeviceInstance;
|
UNICODE_STRING DeviceInstance;
|
||||||
PDEVICE_OBJECT DeviceObject = NULL;
|
PDEVICE_OBJECT DeviceObject = NULL;
|
||||||
ULONG BufferSize = 0;
|
|
||||||
GUID FilterGuid;
|
GUID FilterGuid;
|
||||||
PZZWSTR SymbolicLinkList = NULL, LinkList;
|
PZZWSTR SymbolicLinkList = NULL, LinkList;
|
||||||
ULONG TotalLength = 0;
|
ULONG TotalLength;
|
||||||
|
|
||||||
_SEH2_TRY
|
_SEH2_TRY
|
||||||
{
|
{
|
||||||
ProbeForRead(DeviceList->FilterGuid, sizeof(GUID), sizeof(UCHAR));
|
RtlCopyMemory(&StackList, DeviceList, sizeof(PLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA));
|
||||||
RtlCopyMemory(&FilterGuid, DeviceList->FilterGuid, sizeof(GUID));
|
|
||||||
|
|
||||||
if (DeviceList->Buffer != NULL && DeviceList->BufferSize != 0)
|
ProbeForRead(StackList.FilterGuid, sizeof(GUID), sizeof(UCHAR));
|
||||||
|
RtlCopyMemory(&FilterGuid, StackList.FilterGuid, sizeof(GUID));
|
||||||
|
|
||||||
|
if (StackList.Buffer != NULL && StackList.BufferSize != 0)
|
||||||
{
|
{
|
||||||
BufferSize = DeviceList->BufferSize;
|
ProbeForWrite(StackList.Buffer, StackList.BufferSize, sizeof(UCHAR));
|
||||||
ProbeForWrite(DeviceList->Buffer, BufferSize, sizeof(UCHAR));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||||
|
@ -238,8 +239,7 @@ IopGetInterfaceDeviceList(PPLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA DeviceLis
|
||||||
}
|
}
|
||||||
_SEH2_END;
|
_SEH2_END;
|
||||||
|
|
||||||
|
Status = IopCaptureUnicodeString(&DeviceInstance, &StackList.DeviceInstance);
|
||||||
Status = IopCaptureUnicodeString(&DeviceInstance, &DeviceList->DeviceInstance);
|
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
/* Get the device object */
|
/* Get the device object */
|
||||||
|
@ -247,7 +247,7 @@ IopGetInterfaceDeviceList(PPLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA DeviceLis
|
||||||
ExFreePool(DeviceInstance.Buffer);
|
ExFreePool(DeviceInstance.Buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = IoGetDeviceInterfaces(&FilterGuid, DeviceObject, DeviceList->Flags, &SymbolicLinkList);
|
Status = IoGetDeviceInterfaces(&FilterGuid, DeviceObject, StackList.Flags, &SymbolicLinkList);
|
||||||
ObDereferenceObject(DeviceObject);
|
ObDereferenceObject(DeviceObject);
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
@ -259,16 +259,28 @@ IopGetInterfaceDeviceList(PPLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA DeviceLis
|
||||||
LinkList = SymbolicLinkList;
|
LinkList = SymbolicLinkList;
|
||||||
while (*SymbolicLinkList != UNICODE_NULL)
|
while (*SymbolicLinkList != UNICODE_NULL)
|
||||||
{
|
{
|
||||||
TotalLength += (wcslen(SymbolicLinkList) + 1) * sizeof(WCHAR);
|
|
||||||
SymbolicLinkList += wcslen(SymbolicLinkList) + (sizeof(UNICODE_NULL) / sizeof(WCHAR));
|
SymbolicLinkList += wcslen(SymbolicLinkList) + (sizeof(UNICODE_NULL) / sizeof(WCHAR));
|
||||||
}
|
}
|
||||||
TotalLength += sizeof(UNICODE_NULL);
|
TotalLength = ((SymbolicLinkList - LinkList + 1) * sizeof(WCHAR));
|
||||||
|
|
||||||
if (BufferSize >= TotalLength)
|
_SEH2_TRY
|
||||||
{
|
{
|
||||||
RtlCopyMemory(DeviceList->Buffer, SymbolicLinkList, TotalLength * sizeof(WCHAR));
|
if (StackList.Buffer != NULL &&
|
||||||
|
StackList.BufferSize >= TotalLength)
|
||||||
|
{
|
||||||
|
// We've already probed the buffer for writing above.
|
||||||
|
RtlCopyMemory(StackList.Buffer, LinkList, TotalLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
DeviceList->BufferSize = TotalLength;
|
||||||
}
|
}
|
||||||
DeviceList->BufferSize = TotalLength;
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||||
|
{
|
||||||
|
ExFreePool(LinkList);
|
||||||
|
_SEH2_YIELD(return _SEH2_GetExceptionCode());
|
||||||
|
}
|
||||||
|
_SEH2_END;
|
||||||
|
|
||||||
ExFreePool(LinkList);
|
ExFreePool(LinkList);
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -831,9 +843,20 @@ NtGetPlugPlayEvent(IN ULONG Reserved1,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy event data to the user buffer */
|
/* Copy event data to the user buffer */
|
||||||
memcpy(Buffer,
|
_SEH2_TRY
|
||||||
&Entry->Event,
|
{
|
||||||
Entry->Event.TotalSize);
|
ProbeForWrite(Buffer,
|
||||||
|
Entry->Event.TotalSize,
|
||||||
|
sizeof(UCHAR));
|
||||||
|
RtlCopyMemory(Buffer,
|
||||||
|
&Entry->Event,
|
||||||
|
Entry->Event.TotalSize);
|
||||||
|
}
|
||||||
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||||
|
{
|
||||||
|
_SEH2_YIELD(return _SEH2_GetExceptionCode());
|
||||||
|
}
|
||||||
|
_SEH2_END;
|
||||||
|
|
||||||
DPRINT("NtGetPlugPlayEvent() done\n");
|
DPRINT("NtGetPlugPlayEvent() done\n");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue