https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fa547041582fb13eed180…
commit fa547041582fb13eed1804b2d44c49a99974e218
Author: Hervé Poussineau <hpoussin(a)reactos.org>
AuthorDate: Sat May 29 22:55:15 2021 +0200
Commit: Hervé Poussineau <hpoussin(a)reactos.org>
CommitDate: Sat Jun 5 23:38:05 2021 +0200
[VIDEOPRT] Report monitor name instead of the generic 'Monitor' string
---
win32ss/drivers/videoprt/child.c | 87 +++++++++++++++++++++++++++++++++++-----
1 file changed, 76 insertions(+), 11 deletions(-)
diff --git a/win32ss/drivers/videoprt/child.c b/win32ss/drivers/videoprt/child.c
index bfca7069b1d..2c280850a8b 100644
--- a/win32ss/drivers/videoprt/child.c
+++ b/win32ss/drivers/videoprt/child.c
@@ -57,6 +57,60 @@ IntVideoPortGetMonitorId(
return TRUE;
}
+BOOLEAN
+NTAPI
+IntVideoPortSearchDescriptor(
+ IN PUCHAR Descriptor,
+ IN UCHAR DescriptorID,
+ OUT PUCHAR* pDescriptorData)
+{
+ if (Descriptor[0] != 0 || Descriptor[1] != 0 || Descriptor[2] != 0)
+ return FALSE;
+ if (Descriptor[3] != DescriptorID)
+ return FALSE;
+
+ *pDescriptorData = Descriptor + 4;
+ return TRUE;
+}
+
+BOOLEAN
+NTAPI
+IntVideoPortSearchDescriptors(
+ IN PVIDEO_PORT_CHILD_EXTENSION ChildExtension,
+ IN UCHAR DescriptorID,
+ OUT PUCHAR* pDescriptorData)
+{
+ if (!ChildExtension->EdidValid)
+ return FALSE;
+
+ if (IntVideoPortSearchDescriptor(ChildExtension->ChildDescriptor + 0x36,
DescriptorID, pDescriptorData))
+ return TRUE;
+ if (IntVideoPortSearchDescriptor(ChildExtension->ChildDescriptor + 0x48,
DescriptorID, pDescriptorData))
+ return TRUE;
+ if (IntVideoPortSearchDescriptor(ChildExtension->ChildDescriptor + 0x5A,
DescriptorID, pDescriptorData))
+ return TRUE;
+ if (IntVideoPortSearchDescriptor(ChildExtension->ChildDescriptor + 0x6C,
DescriptorID, pDescriptorData))
+ return TRUE;
+
+ /* FIXME: search in extension? */
+ return FALSE;
+}
+
+BOOLEAN
+NTAPI
+IntVideoPortGetMonitorDescription(
+ IN PVIDEO_PORT_CHILD_EXTENSION ChildExtension,
+ OUT PCHAR* pMonitorDescription)
+{
+ PUCHAR MonitorDescription;
+
+ if (!IntVideoPortSearchDescriptors(ChildExtension, 0xFC, &MonitorDescription))
+ return FALSE;
+
+ *pMonitorDescription = (PCHAR)MonitorDescription;
+ return TRUE;
+}
+
NTSTATUS NTAPI
IntVideoPortChildQueryId(
IN PVIDEO_PORT_CHILD_EXTENSION ChildExtension,
@@ -188,7 +242,9 @@ IntVideoPortChildQueryText(
IN PIRP Irp,
IN PIO_STACK_LOCATION IrpSp)
{
- PWCHAR Buffer, StaticBuffer;
+ ANSI_STRING StringA;
+ UNICODE_STRING StringU;
+ NTSTATUS Status;
if (IrpSp->Parameters.QueryDeviceText.DeviceTextType != DeviceTextDescription)
return Irp->IoStatus.Status;
@@ -196,27 +252,36 @@ IntVideoPortChildQueryText(
switch (ChildExtension->ChildType)
{
case Monitor:
- /* FIXME: We can return a better description I think */
- StaticBuffer = L"Monitor";
+ if (IntVideoPortGetMonitorDescription(ChildExtension,
+ &StringA.Buffer))
+ {
+ StringA.Buffer++; /* Skip reserved byte */
+ StringA.MaximumLength = 13;
+ for (StringA.Length = 0;
+ StringA.Length < StringA.MaximumLength &&
StringA.Buffer[StringA.Length] != '\n';
+ StringA.Length++)
+ ;
+ }
+ else
+ RtlInitAnsiString(&StringA, "Monitor");
break;
case VideoChip:
/* FIXME: No idea what we return here */
- StaticBuffer = L"Video chip";
+ RtlInitAnsiString(&StringA, "Video chip");
break;
default: /* Other */
- StaticBuffer = L"Other device";
+ RtlInitAnsiString(&StringA, "Other device");
break;
}
- Buffer = ExAllocatePool(PagedPool, (wcslen(StaticBuffer) + 1) * sizeof(WCHAR));
- if (!Buffer) return STATUS_NO_MEMORY;
-
- RtlCopyMemory(Buffer, StaticBuffer, (wcslen(StaticBuffer) + 1) * sizeof(WCHAR));
+ Status = RtlAnsiStringToUnicodeString(&StringU, &StringA, TRUE);
+ if (!NT_SUCCESS(Status))
+ return Status;
- INFO_(VIDEOPRT, "Reporting description: %S\n", Buffer);
- Irp->IoStatus.Information = (ULONG_PTR)Buffer;
+ INFO_(VIDEOPRT, "Reporting description: %S\n", StringU.Buffer);
+ Irp->IoStatus.Information = (ULONG_PTR)StringU.Buffer;
return STATUS_SUCCESS;
}