From 3a4617cfcb14be68a44b37b17227fbbb72e568e2 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 4 Mar 2010 21:53:12 +0000 Subject: [PATCH] - Implement VideoPortIsNoVesa svn path=/trunk/; revision=45844 --- reactos/drivers/video/videoprt/videoprt.c | 96 ++++++++++++++++++++ reactos/drivers/video/videoprt/videoprt.spec | 1 + 2 files changed, 97 insertions(+) diff --git a/reactos/drivers/video/videoprt/videoprt.c b/reactos/drivers/video/videoprt/videoprt.c index 6d106f62015..0d85bb559e7 100644 --- a/reactos/drivers/video/videoprt/videoprt.c +++ b/reactos/drivers/video/videoprt/videoprt.c @@ -1417,3 +1417,99 @@ VideoPortAllocateContiguousMemory( return MmAllocateContiguousMemory(NumberOfBytes, HighestAcceptableAddress); } + +/* + * @implemented + */ +BOOLEAN NTAPI +VideoPortIsNoVesa(VOID) +{ + NTSTATUS Status; + HANDLE KeyHandle; + UNICODE_STRING Path = RTL_CONSTANT_STRING(L"\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Control"); + UNICODE_STRING ValueName = RTL_CONSTANT_STRING(L"SystemStartOptions"); + OBJECT_ATTRIBUTES ObjectAttributes; + PKEY_VALUE_PARTIAL_INFORMATION KeyInfo; + ULONG Length, NewLength; + + /* Initialize object attributes with the path we want */ + InitializeObjectAttributes(&ObjectAttributes, + &Path, + OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, + NULL, + NULL); + + /* Open the key */ + Status = ZwOpenKey(&KeyHandle, + KEY_QUERY_VALUE, + &ObjectAttributes); + + if (!NT_SUCCESS(Status)) + { + VideoPortDebugPrint(Error, "ZwOpenKey failed (0x%x)\n", Status); + return FALSE; + } + + /* Find out how large our buffer should be */ + Status = ZwQueryValueKey(KeyHandle, + &ValueName, + KeyValuePartialInformation, + NULL, + 0, + &Length); + if (Status != STATUS_BUFFER_OVERFLOW && Status != STATUS_BUFFER_TOO_SMALL) + { + VideoPortDebugPrint(Error, "ZwQueryValueKey failed (0x%x)\n", Status); + ZwClose(KeyHandle); + return FALSE; + } + + /* Allocate it */ + KeyInfo = ExAllocatePool(PagedPool, Length); + if (!KeyInfo) + { + VideoPortDebugPrint(Error, "Out of memory\n"); + ZwClose(KeyHandle); + return FALSE; + } + + /* Now for real this time */ + Status = ZwQueryValueKey(KeyHandle, + &ValueName, + KeyValuePartialInformation, + KeyInfo, + Length, + &NewLength); + + ZwClose(KeyHandle); + + if (!NT_SUCCESS(Status)) + { + VideoPortDebugPrint(Error, "ZwQueryValueKey failed (0x%x)\n", Status); + ExFreePool(KeyInfo); + return FALSE; + } + + /* Sanity check */ + if (KeyInfo->Type != REG_SZ) + { + VideoPortDebugPrint(Error, "Invalid type for SystemStartOptions\n"); + ExFreePool(KeyInfo); + return FALSE; + } + + /* Check if NOVESA is present in the start options */ + if (wcsstr((PWCHAR)KeyInfo->Data, L"NOVESA")) + { + VideoPortDebugPrint(Info, "VESA mode disabled\n"); + ExFreePool(KeyInfo); + return TRUE; + } + + ExFreePool(KeyInfo); + + VideoPortDebugPrint(Info, "VESA mode enabled\n"); + + return FALSE; +} + diff --git a/reactos/drivers/video/videoprt/videoprt.spec b/reactos/drivers/video/videoprt/videoprt.spec index e07ce343e63..9d5147636fe 100644 --- a/reactos/drivers/video/videoprt/videoprt.spec +++ b/reactos/drivers/video/videoprt/videoprt.spec @@ -47,6 +47,7 @@ @ fastcall VideoPortInterlockedDecrement(ptr) NTOSKRNL.InterlockedDecrement @ fastcall VideoPortInterlockedExchange(ptr long) NTOSKRNL.InterlockedExchange @ fastcall VideoPortInterlockedIncrement(ptr) NTOSKRNL.InterlockedIncrement +@ stdcall VideoPortIsNoVesa() @ stdcall VideoPortLockBuffer(ptr ptr long long) @ stdcall VideoPortLockPages(ptr ptr ptr ptr long) @ stdcall VideoPortLogError(ptr ptr long long)