diff --git a/reactos/subsystems/win32/win32k/eng/device.c b/reactos/subsystems/win32/win32k/eng/device.c index 6fd6c8746b8..eab85151d81 100644 --- a/reactos/subsystems/win32/win32k/eng/device.c +++ b/reactos/subsystems/win32/win32k/eng/device.c @@ -151,7 +151,7 @@ EngpRegisterGraphicsDevice( /* Loop all DEVMODEs */ pdmEnd = (DEVMODEW*)((PCHAR)pdminfo->adevmode + pdminfo->cbdevmode); for (pdm = pdminfo->adevmode; - pdm + 1 <= pdmEnd; + (pdm + 1 <= pdmEnd) && (pdm->dmSize != 0); pdm = (DEVMODEW*)((PCHAR)pdm + pdm->dmSize + pdm->dmDriverExtra)) { /* Count this DEVMODE */ @@ -195,7 +195,7 @@ EngpRegisterGraphicsDevice( /* Loop through the DEVMODEs */ for (pdm = pdminfo->adevmode; - pdm + 1 <= pdmEnd; + (pdm + 1 <= pdmEnd) && (pdm->dmSize != 0); pdm = (PDEVMODEW)((PCHAR)pdm + pdm->dmSize + pdm->dmDriverExtra)) { /* Compare with the default entry */ diff --git a/reactos/subsystems/win32/win32k/include/pdevobj.h b/reactos/subsystems/win32/win32k/include/pdevobj.h index 34297add5f4..7deabc13b5b 100644 --- a/reactos/subsystems/win32/win32k/include/pdevobj.h +++ b/reactos/subsystems/win32/win32k/include/pdevobj.h @@ -44,7 +44,7 @@ typedef struct _DEVMODEINFO DEVMODEW adevmode[1]; } DEVMODEINFO, *PDEVMODEINFO; -typedef struct +typedef struct _DEVMODEENTRY { DWORD dwFlags; PDEVMODEW pdm; diff --git a/reactos/subsystems/win32/win32k/ntuser/display.c b/reactos/subsystems/win32/win32k/ntuser/display.c index 9c217993f5f..c63ee17f03a 100644 --- a/reactos/subsystems/win32/win32k/ntuser/display.c +++ b/reactos/subsystems/win32/win32k/ntuser/display.c @@ -74,6 +74,7 @@ InitDisplayDriver( ULONG cbSize; HKEY hkey; DEVMODEW dmDefault; + DWORD dwVga; ERR("InitDisplayDriver(%S, %S);\n", pwszDeviceName, pwszRegKey); @@ -128,6 +129,11 @@ InitDisplayDriver( /* Query the default settings */ RegReadDisplaySettings(hkey, &dmDefault); + /* Query if this is a VGA compatible driver */ + cbSize = sizeof(DWORD); + Status = RegQueryValue(hkey, L"VgaCompatible", REG_DWORD, &dwVga, &cbSize); + if (!NT_SUCCESS(Status)) dwVga = 0; + /* Close the registry key */ ZwClose(hkey); @@ -137,6 +143,10 @@ InitDisplayDriver( &ustrDisplayDrivers, &ustrDescription, &dmDefault); + if (pGraphicsDevice && dwVga) + { + pGraphicsDevice->StateFlags |= DISPLAY_DEVICE_VGA_COMPATIBLE; + } return pGraphicsDevice; } @@ -197,7 +207,7 @@ InitVideo() ERR("Could not read MaxObjectNumber, defaulting to 0.\n"); } - TRACE("Found %ld devices\n", ulMaxObjectNumber); + TRACE("Found %ld devices\n", ulMaxObjectNumber + 1); /* Loop through all adapters */ for (iDevNum = 0; iDevNum <= ulMaxObjectNumber; iDevNum++) @@ -218,31 +228,30 @@ InitVideo() pGraphicsDevice = InitDisplayDriver(awcDeviceName, awcBuffer); if (!pGraphicsDevice) continue; - /* Check if this is the VGA adapter */ - if (iDevNum == iVGACompatible) + /* Check if this is a VGA compatible adapter */ + if (pGraphicsDevice->StateFlags & DISPLAY_DEVICE_VGA_COMPATIBLE) { - /* Set the VGA device as primary */ - gpVgaGraphicsDevice = pGraphicsDevice; - ERR("gpVgaGraphicsDevice = %p\n", gpVgaGraphicsDevice); + /* Save this as the VGA adapter */ + if (!gpVgaGraphicsDevice) + gpVgaGraphicsDevice = pGraphicsDevice; + TRACE("gpVgaGraphicsDevice = %p\n", gpVgaGraphicsDevice); + } + else + { + /* Set the first one as primary device */ + if (!gpPrimaryGraphicsDevice) + gpPrimaryGraphicsDevice = pGraphicsDevice; + TRACE("gpPrimaryGraphicsDevice = %p\n", gpPrimaryGraphicsDevice); } - - /* Set the first one as primary device */ - if (!gpPrimaryGraphicsDevice) - gpPrimaryGraphicsDevice = pGraphicsDevice; } /* Close the device map registry key */ ZwClose(hkey); - /* Check if we had any success */ - if (!gpPrimaryGraphicsDevice) - { - ERR("No usable display driver was found.\n"); - return STATUS_UNSUCCESSFUL; - } - + /* Was VGA mode requested? */ if (gbBaseVideo) { + /* Check if we found a VGA compatible device */ if (gpVgaGraphicsDevice) { /* Set the VgaAdapter as primary */ @@ -255,6 +264,22 @@ InitVideo() } } + /* Check if we had any success */ + if (!gpPrimaryGraphicsDevice) + { + /* Check if there is a VGA device we skipped */ + if (gpVgaGraphicsDevice) + { + /* There is, use the VGA device */ + gpPrimaryGraphicsDevice = gpVgaGraphicsDevice; + } + else + { + ERR("No usable display driver was found.\n"); + return STATUS_UNSUCCESSFUL; + } + } + InitSysParams(); return 1;