mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 12:23:14 +00:00
[VIDEOPRT]
Fix buggy monitor device id decode routine. This patch is dedicated to Christoph von Wittlich. svn path=/trunk/; revision=63224
This commit is contained in:
parent
8ce24812f8
commit
94f60baa09
1 changed files with 9 additions and 14 deletions
|
@ -20,6 +20,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "videoprt.h"
|
#include "videoprt.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
@ -33,30 +34,24 @@ IntVideoPortGetMonitorId(
|
||||||
IN OUT PWCHAR Buffer)
|
IN OUT PWCHAR Buffer)
|
||||||
{
|
{
|
||||||
USHORT Manufacturer, Model;
|
USHORT Manufacturer, Model;
|
||||||
UNICODE_STRING UnicodeModelStr;
|
|
||||||
|
|
||||||
/* This must be valid to call this function */
|
/* This must be valid to call this function */
|
||||||
ASSERT(ChildExtension->EdidValid);
|
ASSERT(ChildExtension->EdidValid);
|
||||||
|
|
||||||
/* 3 letters 5-bit ANSI manufacturer code (big endian) */
|
/* 3 letters 5-bit ANSI manufacturer code (big endian) */
|
||||||
Manufacturer = *(PUSHORT)(&ChildExtension->ChildDescriptor[8]);
|
|
||||||
|
|
||||||
/* Letters encoded as A=1 to Z=26 */
|
/* Letters encoded as A=1 to Z=26 */
|
||||||
Buffer[0] = (WCHAR)((Manufacturer & 0x7C00) + 'A' - 1);
|
Manufacturer = *(PUSHORT)(&ChildExtension->ChildDescriptor[8]);
|
||||||
Buffer[1] = (WCHAR)((Manufacturer & 0x03E0) + 'A' - 1);
|
|
||||||
Buffer[2] = (WCHAR)((Manufacturer & 0x001F) + 'A' - 1);
|
|
||||||
|
|
||||||
/* Model number (16-bit little endian) */
|
/* Model number (16-bit little endian) */
|
||||||
Model = *(PUSHORT)(&ChildExtension->ChildDescriptor[10]);
|
Model = *(PUSHORT)(&ChildExtension->ChildDescriptor[10]);
|
||||||
|
|
||||||
/* Use Rtl helper for conversion */
|
/* Convert the Monitor ID to a readable form */
|
||||||
UnicodeModelStr.Buffer = &Buffer[3];
|
swprintf(Buffer,
|
||||||
UnicodeModelStr.Length = 0;
|
L"%C%C%C%04hx",
|
||||||
UnicodeModelStr.MaximumLength = 4 * sizeof(WCHAR);
|
(WCHAR)((Manufacturer >> 10 & 0x001F) + 'A' - 1),
|
||||||
RtlIntegerToUnicodeString(Model, 16, &UnicodeModelStr);
|
(WCHAR)((Manufacturer >> 5 & 0x001F) + 'A' - 1),
|
||||||
|
(WCHAR)((Manufacturer & 0x001F) + 'A' - 1),
|
||||||
/* Terminate it */
|
Model);
|
||||||
Buffer[7] = UNICODE_NULL;
|
|
||||||
|
|
||||||
/* And we're done */
|
/* And we're done */
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue