ReactOS  0.4.15-dev-3028-g676dc4b
device.c File Reference
#include <win32k.h>
#include <ntddvdeo.h>
Include dependency graph for device.c:

Go to the source code of this file.

Functions

 DBG_DEFAULT_CHANNEL (EngDev)
 
NTSTATUS NTAPI InitDeviceImpl (VOID)
 
NTSTATUS EngpUpdateGraphicsDeviceList (VOID)
 
BOOLEAN EngpPopulateDeviceModeList (_Inout_ PGRAPHICS_DEVICE pGraphicsDevice, _In_ PDEVMODEW pdmDefault)
 
VOID UserRefreshDisplay (IN PPDEVOBJ ppdev)
 
VOID NTAPI VideoPortCallout (_In_ PVOID Params)
 
PGRAPHICS_DEVICE NTAPI EngpRegisterGraphicsDevice (_In_ PUNICODE_STRING pustrDeviceName, _In_ PUNICODE_STRING pustrDiplayDrivers, _In_ PUNICODE_STRING pustrDescription, _In_ PDEVMODEW pdmDefault)
 
PGRAPHICS_DEVICE NTAPI EngpFindGraphicsDevice (_In_opt_ PUNICODE_STRING pustrDevice, _In_ ULONG iDevNum, _In_ DWORD dwFlags)
 
static NTSTATUS EngpFileIoRequest (_In_ PFILE_OBJECT pFileObject, _In_ ULONG ulMajorFunction, _In_reads_(nBufferSize) PVOID lpBuffer, _In_ SIZE_T nBufferSize, _In_ ULONGLONG ullStartOffset, _Out_ PULONG_PTR lpInformation)
 
VOID APIENTRY EngFileWrite (_In_ PFILE_OBJECT pFileObject, _In_reads_(nLength) PVOID lpBuffer, _In_ SIZE_T nLength, _Out_ PSIZE_T lpBytesWritten)
 
 _Success_ (return >=0) NTSTATUS APIENTRY EngFileIoControl(_In_ PFILE_OBJECT pFileObject
 
_In_ DWORD _In_reads_ (nInBufferSize)
 
 _Success_ (return==0)
 

Variables

PGRAPHICS_DEVICE gpPrimaryGraphicsDevice
 
PGRAPHICS_DEVICE gpVgaGraphicsDevice
 
static PGRAPHICS_DEVICE gpGraphicsDeviceFirst = NULL
 
static PGRAPHICS_DEVICE gpGraphicsDeviceLast = NULL
 
static HSEMAPHORE ghsemGraphicsDeviceList
 
static ULONG giDevNum = 1
 
_In_ DWORD dwIoControlCode
 

Function Documentation

◆ _In_reads_()

_In_ DWORD _In_reads_ ( nInBufferSize  )

Definition at line 598 of file device.c.

603 {
605  KEVENT Event;
606  PIRP pIrp;
609 
610  /* Get corresponding device object */
612  if (!pDeviceObject)
613  {
615  }
616 
617  /* Initialize an event */
619 
620  /* Build IO control IRP */
623  lpInBuffer,
624  (ULONG)nInBufferSize,
625  lpOutBuffer,
626  (ULONG)nOutBufferSize,
627  FALSE,
628  &Event,
629  &Iosb);
630  if (!pIrp)
631  {
633  }
634 
635  /* Call the driver */
637 
638  /* Wait if neccessary */
639  if (Status == STATUS_PENDING)
640  {
642  Status = Iosb.Status;
643  }
644 
645  /* Return information to the caller about the operation. */
646  *lpInformation = Iosb.Information;
647 
648  /* This function returns NTSTATUS */
649  return Status;
650 }
_In_ PNDIS_STRING _In_ PNDIS_STRING _Out_ PDEVICE_OBJECT * pDeviceObject
Definition: ndis.h:4679
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1539
FxIrp * pIrp
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define FALSE
Definition: types.h:117
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:467
_In_ DWORD dwIoControlCode
Definition: device.c:597
Status
Definition: gdiplustypes.h:24
return Iosb
Definition: create.c:4402
#define STATUS_PENDING
Definition: ntstatus.h:82
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
PIRP NTAPI IoBuildDeviceIoControlRequest(IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:881
unsigned int ULONG
Definition: retypes.h:1

◆ _Success_() [1/2]

_Success_ ( return >=  0)

◆ _Success_() [2/2]

_Success_ ( return  = =0)

Definition at line 655 of file device.c.

666 {
667  PIRP Irp;
669  KEVENT Event;
672 
673  TRACE("EngDeviceIoControl() called\n");
674 
675  if (!hDevice)
676  {
677  return ERROR_INVALID_HANDLE;
678  }
679 
681 
682  DeviceObject = (PDEVICE_OBJECT) hDevice;
683 
685  DeviceObject,
686  lpInBuffer,
688  lpOutBuffer,
690  FALSE,
691  &Event,
692  &Iosb);
693  if (!Irp) return ERROR_NOT_ENOUGH_MEMORY;
694 
696 
697  if (Status == STATUS_PENDING)
698  {
700  Status = Iosb.Status;
701  }
702 
703  TRACE("EngDeviceIoControl(): Returning %X/%X\n", Iosb.Status,
704  Iosb.Information);
705 
706  /* Return information to the caller about the operation. */
707  *lpBytesReturned = (DWORD)Iosb.Information;
708 
709  /* Convert NT status values to win32 error codes. */
710  switch (Status)
711  {
714 
716  return ERROR_MORE_DATA;
717 
719  return ERROR_INVALID_FUNCTION;
720 
723 
726 
728  return ERROR_DEV_NOT_EXIST;
729 
730  case STATUS_PENDING:
731  return ERROR_IO_PENDING;
732  }
733 
734  return Status;
735 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define STATUS_DEVICE_DOES_NOT_EXIST
Definition: ntstatus.h:428
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ DWORD _In_ DWORD _In_ DWORD cjOutBufferSize
Definition: winddi.h:1704
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _DEVICE_OBJECT * PDEVICE_OBJECT
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
LONG NTSTATUS
Definition: precomp.h:26
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ERROR_IO_PENDING
Definition: dderror.h:15
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define DWORD
Definition: nt_native.h:44
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
return STATUS_NOT_IMPLEMENTED
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:467
_In_ DWORD _In_ DWORD cjInBufferSize
Definition: winddi.h:1702
switch(r->id)
Definition: btrfs.c:2980
_In_ DWORD dwIoControlCode
Definition: device.c:597
Status
Definition: gdiplustypes.h:24
#define TRACE(s)
Definition: solgame.cpp:4
return Iosb
Definition: create.c:4402
#define STATUS_PENDING
Definition: ntstatus.h:82
#define VOID
Definition: acefi.h:82
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
_In_ DWORD _In_ DWORD _In_ DWORD _Out_ LPDWORD lpBytesReturned
Definition: winddi.h:1704
PIRP NTAPI IoBuildDeviceIoControlRequest(IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:881
#define ERROR_DEV_NOT_EXIST
Definition: dderror.h:8
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( EngDev  )

◆ EngFileWrite()

VOID APIENTRY EngFileWrite ( _In_ PFILE_OBJECT  pFileObject,
_In_reads_(nLength) PVOID  lpBuffer,
_In_ SIZE_T  nLength,
_Out_ PSIZE_T  lpBytesWritten 
)

Definition at line 572 of file device.c.

577 {
579 
580  status = EngpFileIoRequest(pFileObject,
581  IRP_MJ_WRITE,
582  lpBuffer,
583  nLength,
584  0,
585  lpBytesWritten);
586  if (!NT_SUCCESS(status))
587  {
588  *lpBytesWritten = 0;
589  }
590 }
LONG NTSTATUS
Definition: precomp.h:26
_In_ DWORD nLength
Definition: wincon.h:473
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
static SERVICE_STATUS status
Definition: service.c:31
static NTSTATUS EngpFileIoRequest(_In_ PFILE_OBJECT pFileObject, _In_ ULONG ulMajorFunction, _In_reads_(nBufferSize) PVOID lpBuffer, _In_ SIZE_T nBufferSize, _In_ ULONGLONG ullStartOffset, _Out_ PULONG_PTR lpInformation)
Definition: device.c:514
Definition: ps.c:97

◆ EngpFileIoRequest()

static NTSTATUS EngpFileIoRequest ( _In_ PFILE_OBJECT  pFileObject,
_In_ ULONG  ulMajorFunction,
_In_reads_(nBufferSize) PVOID  lpBuffer,
_In_ SIZE_T  nBufferSize,
_In_ ULONGLONG  ullStartOffset,
_Out_ PULONG_PTR  lpInformation 
)
static

Definition at line 514 of file device.c.

521 {
523  KEVENT Event;
524  PIRP pIrp;
527  LARGE_INTEGER liStartOffset;
528 
529  /* Get corresponding device object */
531  if (!pDeviceObject)
532  {
534  }
535 
536  /* Initialize an event */
538 
539  /* Build IRP */
540  liStartOffset.QuadPart = ullStartOffset;
541  pIrp = IoBuildSynchronousFsdRequest(ulMajorFunction,
543  lpBuffer,
544  (ULONG)nBufferSize,
545  &liStartOffset,
546  &Event,
547  &Iosb);
548  if (!pIrp)
549  {
551  }
552 
553  /* Call the driver */
555 
556  /* Wait if neccessary */
557  if (STATUS_PENDING == Status)
558  {
560  Status = Iosb.Status;
561  }
562 
563  /* Return information to the caller about the operation. */
564  *lpInformation = Iosb.Information;
565 
566  /* Return NTSTATUS */
567  return Status;
568 }
_In_ PNDIS_STRING _In_ PNDIS_STRING _Out_ PDEVICE_OBJECT * pDeviceObject
Definition: ndis.h:4679
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
PIRP NTAPI IoBuildSynchronousFsdRequest(IN ULONG MajorFunction, IN PDEVICE_OBJECT DeviceObject, IN PVOID Buffer, IN ULONG Length, IN PLARGE_INTEGER StartingOffset, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:1069
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1539
FxIrp * pIrp
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define FALSE
Definition: types.h:117
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:467
Status
Definition: gdiplustypes.h:24
return Iosb
Definition: create.c:4402
#define STATUS_PENDING
Definition: ntstatus.h:82
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
unsigned int ULONG
Definition: retypes.h:1
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by EngFileWrite().

◆ EngpFindGraphicsDevice()

PGRAPHICS_DEVICE NTAPI EngpFindGraphicsDevice ( _In_opt_ PUNICODE_STRING  pustrDevice,
_In_ ULONG  iDevNum,
_In_ DWORD  dwFlags 
)

Definition at line 469 of file device.c.

473 {
474  UNICODE_STRING ustrCurrent;
475  PGRAPHICS_DEVICE pGraphicsDevice;
476  ULONG i;
477  TRACE("EngpFindGraphicsDevice('%wZ', %lu, 0x%lx)\n",
478  pustrDevice, iDevNum, dwFlags);
479 
480  /* Lock list */
482 
483  if (pustrDevice && pustrDevice->Buffer)
484  {
485  /* Loop through the list of devices */
486  for (pGraphicsDevice = gpGraphicsDeviceFirst;
487  pGraphicsDevice;
488  pGraphicsDevice = pGraphicsDevice->pNextGraphicsDevice)
489  {
490  /* Compare the device name */
491  RtlInitUnicodeString(&ustrCurrent, pGraphicsDevice->szWinDeviceName);
492  if (RtlEqualUnicodeString(&ustrCurrent, pustrDevice, FALSE))
493  {
494  break;
495  }
496  }
497  }
498  else
499  {
500  /* Loop through the list of devices */
501  for (pGraphicsDevice = gpGraphicsDeviceFirst, i = 0;
502  pGraphicsDevice && i < iDevNum;
503  pGraphicsDevice = pGraphicsDevice->pNextGraphicsDevice, i++);
504  }
505 
506  /* Unlock list */
508 
509  return pGraphicsDevice;
510 }
VOID WINAPI EngReleaseSemaphore(IN HSEMAPHORE hsem)
Definition: eng.c:235
WCHAR szWinDeviceName[CCHDEVICENAME/2]
Definition: pdevobj.h:60
#define FALSE
Definition: types.h:117
static PGRAPHICS_DEVICE gpGraphicsDeviceFirst
Definition: device.c:18
ENGAPI VOID APIENTRY EngAcquireSemaphore(_Inout_ HSEMAPHORE hsem)
#define TRACE(s)
Definition: solgame.cpp:4
struct _GRAPHICS_DEVICE * pNextGraphicsDevice
Definition: pdevobj.h:61
static HSEMAPHORE ghsemGraphicsDeviceList
Definition: device.c:20
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)

Referenced by co_IntInitializeDesktopGraphics(), EngpCreatePDEV(), EngpUpdateGraphicsDeviceList(), UserEnumDisplayDevices(), and UserEnumDisplaySettings().

◆ EngpPopulateDeviceModeList()

BOOLEAN EngpPopulateDeviceModeList ( _Inout_ PGRAPHICS_DEVICE  pGraphicsDevice,
_In_ PDEVMODEW  pdmDefault 
)

Definition at line 125 of file device.c.

128 {
129  PWSTR pwsz;
130  PLDEVOBJ pldev;
131  PDEVMODEINFO pdminfo;
132  PDEVMODEW pdm, pdmEnd;
133  ULONG i, cModes = 0;
134  BOOLEAN bModeMatch = FALSE;
135 
136  ASSERT(pGraphicsDevice->pdevmodeInfo == NULL);
137  ASSERT(pGraphicsDevice->pDevModeList == NULL);
138 
139  pwsz = pGraphicsDevice->pDiplayDrivers;
140 
141  /* Loop through the driver names
142  * This is a REG_MULTI_SZ string */
143  for (; *pwsz; pwsz += wcslen(pwsz) + 1)
144  {
145  /* Try to load the display driver */
146  TRACE("Trying driver: %ls\n", pwsz);
147  pldev = EngLoadImageEx(pwsz, LDEV_DEVICE_DISPLAY);
148  if (!pldev)
149  {
150  ERR("Could not load driver: '%ls'\n", pwsz);
151  continue;
152  }
153 
154  /* Get the mode list from the driver */
155  pdminfo = LDEVOBJ_pdmiGetModes(pldev, pGraphicsDevice->DeviceObject);
156  if (!pdminfo)
157  {
158  ERR("Could not get mode list for '%ls'\n", pwsz);
159  continue;
160  }
161 
162  /* Attach the mode info to the device */
163  pdminfo->pdmiNext = pGraphicsDevice->pdevmodeInfo;
164  pGraphicsDevice->pdevmodeInfo = pdminfo;
165 
166  /* Loop all DEVMODEs */
167  pdmEnd = (DEVMODEW*)((PCHAR)pdminfo->adevmode + pdminfo->cbdevmode);
168  for (pdm = pdminfo->adevmode;
169  (pdm + 1 <= pdmEnd) && (pdm->dmSize != 0);
170  pdm = (DEVMODEW*)((PCHAR)pdm + pdm->dmSize + pdm->dmDriverExtra))
171  {
172  /* Count this DEVMODE */
173  cModes++;
174 
175  /* Some drivers like the VBox driver don't fill the dmDeviceName
176  with the name of the display driver. So fix that here. */
177  RtlStringCbCopyW(pdm->dmDeviceName, sizeof(pdm->dmDeviceName), pwsz);
178  }
179 
180  // FIXME: release the driver again until it's used?
181  }
182 
183  if (!pGraphicsDevice->pdevmodeInfo || cModes == 0)
184  {
185  ERR("No devmodes\n");
186  return FALSE;
187  }
188 
189  /* Allocate an index buffer */
190  pGraphicsDevice->cDevModes = cModes;
191  pGraphicsDevice->pDevModeList = ExAllocatePoolWithTag(PagedPool,
192  cModes * sizeof(DEVMODEENTRY),
194  if (!pGraphicsDevice->pDevModeList)
195  {
196  ERR("No devmode list\n");
197  return FALSE;
198  }
199 
200  TRACE("Looking for mode %lux%lux%lu(%lu Hz)\n",
201  pdmDefault->dmPelsWidth,
202  pdmDefault->dmPelsHeight,
203  pdmDefault->dmBitsPerPel,
204  pdmDefault->dmDisplayFrequency);
205 
206  /* Loop through all DEVMODEINFOs */
207  for (pdminfo = pGraphicsDevice->pdevmodeInfo, i = 0;
208  pdminfo;
209  pdminfo = pdminfo->pdmiNext)
210  {
211  /* Calculate End of the DEVMODEs */
212  pdmEnd = (DEVMODEW*)((PCHAR)pdminfo->adevmode + pdminfo->cbdevmode);
213 
214  /* Loop through the DEVMODEs */
215  for (pdm = pdminfo->adevmode;
216  (pdm + 1 <= pdmEnd) && (pdm->dmSize != 0);
217  pdm = (PDEVMODEW)((PCHAR)pdm + pdm->dmSize + pdm->dmDriverExtra))
218  {
219  TRACE(" %S has mode %lux%lux%lu(%lu Hz)\n",
220  pdm->dmDeviceName,
221  pdm->dmPelsWidth,
222  pdm->dmPelsHeight,
223  pdm->dmBitsPerPel,
224  pdm->dmDisplayFrequency);
225  /* Compare with the default entry */
226  if (!bModeMatch &&
227  pdm->dmBitsPerPel == pdmDefault->dmBitsPerPel &&
228  pdm->dmPelsWidth == pdmDefault->dmPelsWidth &&
229  pdm->dmPelsHeight == pdmDefault->dmPelsHeight)
230  {
231  pGraphicsDevice->iDefaultMode = i;
232  pGraphicsDevice->iCurrentMode = i;
233  TRACE("Found default entry: %lu '%ls'\n", i, pdm->dmDeviceName);
234  if (pdm->dmDisplayFrequency == pdmDefault->dmDisplayFrequency)
235  {
236  /* Uh oh, even the display frequency matches. */
237  bModeMatch = TRUE;
238  }
239  }
240 
241  /* Initialize the entry */
242  pGraphicsDevice->pDevModeList[i].dwFlags = 0;
243  pGraphicsDevice->pDevModeList[i].pdm = pdm;
244  i++;
245  }
246  }
247  return TRUE;
248 }
signed char * PCHAR
Definition: retypes.h:7
NTSTRSAFEAPI RtlStringCbCopyW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:174
struct _devicemodeW * PDEVMODEW
PDEVMODEINFO NTAPI LDEVOBJ_pdmiGetModes(_In_ PLDEVOBJ pldev, _In_ HANDLE hDriver)
Definition: ldevobj.c:116
#define TRUE
Definition: types.h:120
uint16_t * PWSTR
Definition: typedefs.h:56
WORD dmDriverExtra
Definition: wingdi.h:1620
DWORD dmBitsPerPel
Definition: wingdi.h:1646
PLDEVOBJ NTAPI EngLoadImageEx(_In_z_ LPWSTR pwszDriverName, _In_ ULONG ldevtype)
Definition: ldevobj.c:328
#define FALSE
Definition: types.h:117
ULONG cbdevmode
Definition: pdevobj.h:46
unsigned char BOOLEAN
DEVMODEW adevmode[1]
Definition: pdevobj.h:47
#define TRACE(s)
Definition: solgame.cpp:4
#define ASSERT(a)
Definition: mode.c:44
struct _DEVMODEINFO * pdmiNext
Definition: pdevobj.h:44
WORD dmSize
Definition: wingdi.h:1619
WCHAR dmDeviceName[CCHDEVICENAME]
Definition: wingdi.h:1616
DWORD dmPelsWidth
Definition: wingdi.h:1647
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define GDITAG_GDEVICE
Definition: tags.h:98
#define ERR(fmt,...)
Definition: debug.h:110
DWORD dmDisplayFrequency
Definition: wingdi.h:1653
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
DWORD dmPelsHeight
Definition: wingdi.h:1648
unsigned int ULONG
Definition: retypes.h:1

Referenced by EngpRegisterGraphicsDevice(), and PDEVOBJ_vRefreshModeList().

◆ EngpRegisterGraphicsDevice()

PGRAPHICS_DEVICE NTAPI EngpRegisterGraphicsDevice ( _In_ PUNICODE_STRING  pustrDeviceName,
_In_ PUNICODE_STRING  pustrDiplayDrivers,
_In_ PUNICODE_STRING  pustrDescription,
_In_ PDEVMODEW  pdmDefault 
)

Definition at line 316 of file device.c.

321 {
322  PGRAPHICS_DEVICE pGraphicsDevice;
324  PFILE_OBJECT pFileObject;
326  VIDEO_WIN32K_CALLBACKS Win32kCallbacks;
327  ULONG ulReturn;
328  PWSTR pwsz;
329  ULONG cj;
330 
331  TRACE("EngpRegisterGraphicsDevice(%wZ)\n", pustrDeviceName);
332 
333  /* Allocate a GRAPHICS_DEVICE structure */
334  pGraphicsDevice = ExAllocatePoolWithTag(PagedPool,
335  sizeof(GRAPHICS_DEVICE),
337  if (!pGraphicsDevice)
338  {
339  ERR("ExAllocatePoolWithTag failed\n");
340  return NULL;
341  }
342 
343  /* Try to open and enable the device */
344  Status = IoGetDeviceObjectPointer(pustrDeviceName,
346  &pFileObject,
347  &pDeviceObject);
348  if (!NT_SUCCESS(Status))
349  {
350  ERR("Could not open device %wZ, 0x%lx\n", pustrDeviceName, Status);
351  ExFreePoolWithTag(pGraphicsDevice, GDITAG_GDEVICE);
352  return NULL;
353  }
354 
355  /* Copy the device and file object pointers */
356  pGraphicsDevice->DeviceObject = pDeviceObject;
357  pGraphicsDevice->FileObject = pFileObject;
358 
359  /* Initialize and register the device with videoprt for Win32k callbacks */
360  Win32kCallbacks.PhysDisp = pGraphicsDevice;
361  Win32kCallbacks.Callout = VideoPortCallout;
362  // Reset the data being returned prior to the call.
363  Win32kCallbacks.bACPI = FALSE;
364  Win32kCallbacks.pPhysDeviceObject = NULL;
365  Win32kCallbacks.DualviewFlags = 0;
366  Status = (NTSTATUS)EngDeviceIoControl((HANDLE)pDeviceObject,
368  &Win32kCallbacks,
369  sizeof(Win32kCallbacks),
370  &Win32kCallbacks,
371  sizeof(Win32kCallbacks),
372  &ulReturn);
373  if (Status != ERROR_SUCCESS)
374  {
375  ERR("EngDeviceIoControl(0x%p, IOCTL_VIDEO_INIT_WIN32K_CALLBACKS) failed, Status 0x%lx\n",
377  }
378  // TODO: Set flags according to the results.
379  // if (Win32kCallbacks.bACPI)
380  // if (Win32kCallbacks.DualviewFlags & ???)
381  // Win32kCallbacks.pPhysDeviceObject;
382 
383  /* Copy the device name */
384  RtlStringCbCopyNW(pGraphicsDevice->szNtDeviceName,
385  sizeof(pGraphicsDevice->szNtDeviceName),
386  pustrDeviceName->Buffer,
387  pustrDeviceName->Length);
388 
389  /* Create a Win32 device name (FIXME: virtual devices!) */
390  RtlStringCbPrintfW(pGraphicsDevice->szWinDeviceName,
391  sizeof(pGraphicsDevice->szWinDeviceName),
392  L"\\\\.\\DISPLAY%d",
393  (int)giDevNum);
394 
395  /* Allocate a buffer for the strings */
396  cj = pustrDiplayDrivers->Length + pustrDescription->Length + sizeof(WCHAR);
398  if (!pwsz)
399  {
400  ERR("Could not allocate string buffer\n");
401  ASSERT(FALSE); // FIXME
402  ExFreePoolWithTag(pGraphicsDevice, GDITAG_GDEVICE);
403  return NULL;
404  }
405 
406  /* Copy the display driver names */
407  pGraphicsDevice->pDiplayDrivers = pwsz;
408  RtlCopyMemory(pGraphicsDevice->pDiplayDrivers,
409  pustrDiplayDrivers->Buffer,
410  pustrDiplayDrivers->Length);
411 
412  /* Copy the description */
413  pGraphicsDevice->pwszDescription = pwsz + pustrDiplayDrivers->Length / sizeof(WCHAR);
414  RtlCopyMemory(pGraphicsDevice->pwszDescription,
415  pustrDescription->Buffer,
416  pustrDescription->Length);
417  pGraphicsDevice->pwszDescription[pustrDescription->Length/sizeof(WCHAR)] = 0;
418 
419  /* Initialize the pdevmodeInfo list and default index */
420  pGraphicsDevice->pdevmodeInfo = NULL;
421  pGraphicsDevice->iDefaultMode = 0;
422  pGraphicsDevice->iCurrentMode = 0;
423 
424  // FIXME: initialize state flags
425  pGraphicsDevice->StateFlags = 0;
426 
427  /* Create the mode list */
428  pGraphicsDevice->pDevModeList = NULL;
429  if (!EngpPopulateDeviceModeList(pGraphicsDevice, pdmDefault))
430  {
431  ExFreePoolWithTag(pGraphicsDevice, GDITAG_GDEVICE);
432  return NULL;
433  }
434 
435  /* Lock loader */
437 
438  /* Insert the device into the global list */
439  pGraphicsDevice->pNextGraphicsDevice = NULL;
441  gpGraphicsDeviceLast->pNextGraphicsDevice = pGraphicsDevice;
442  gpGraphicsDeviceLast = pGraphicsDevice;
444  gpGraphicsDeviceFirst = pGraphicsDevice;
445 
446  /* Increment the device number */
447  giDevNum++;
448 
449  /* Unlock loader */
451  TRACE("Prepared %lu modes for %ls\n", pGraphicsDevice->cDevModes, pGraphicsDevice->pwszDescription);
452 
453  /* HACK: already in graphic mode; display wallpaper on this new display */
455  {
456  UNICODE_STRING DriverName = RTL_CONSTANT_STRING(L"DISPLAY");
457  UNICODE_STRING DisplayName;
458  HDC hdc;
459  RtlInitUnicodeString(&DisplayName, pGraphicsDevice->szWinDeviceName);
460  hdc = IntGdiCreateDC(&DriverName, &DisplayName, NULL, NULL, FALSE);
462  }
463 
464  return pGraphicsDevice;
465 }
BOOLEAN EngpPopulateDeviceModeList(_Inout_ PGRAPHICS_DEVICE pGraphicsDevice, _In_ PDEVMODEW pdmDefault)
Definition: device.c:125
VOID WINAPI EngReleaseSemaphore(IN HSEMAPHORE hsem)
Definition: eng.c:235
_In_ PNDIS_STRING _In_ PNDIS_STRING _Out_ PDEVICE_OBJECT * pDeviceObject
Definition: ndis.h:4679
_In_ ULONG cj
Definition: winddi.h:3540
static PGRAPHICS_DEVICE gpGraphicsDeviceLast
Definition: device.c:19
#define ERROR_SUCCESS
Definition: deptool.c:10
PDEVICE_OBJECT DeviceObject
Definition: pdevobj.h:63
WCHAR szWinDeviceName[CCHDEVICENAME/2]
Definition: pdevobj.h:60
WCHAR szNtDeviceName[CCHDEVICENAME/2]
Definition: pdevobj.h:59
uint16_t * PWSTR
Definition: typedefs.h:56
DWORD StateFlags
Definition: pdevobj.h:66
LONG NTSTATUS
Definition: precomp.h:26
static HDC
Definition: imagelist.c:92
PDEVMODEENTRY pDevModeList
Definition: pdevobj.h:70
NTSTATUS NTAPI IoGetDeviceObjectPointer(IN PUNICODE_STRING ObjectName, IN ACCESS_MASK DesiredAccess, OUT PFILE_OBJECT *FileObject, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1435
IN PVIDEO_WIN32K_CALLOUT Callout
Definition: ntddvdeo.h:263
#define FALSE
Definition: types.h:117
#define IOCTL_VIDEO_INIT_WIN32K_CALLBACKS
Definition: ntddvdeo.h:62
#define FILE_READ_DATA
Definition: nt_native.h:628
NTSTRSAFEAPI RtlStringCbCopyNW(_Out_writes_bytes_(cbDest) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_reads_bytes_(cbToCopy) STRSAFE_LPCWSTR pszSrc, _In_ size_t cbToCopy)
Definition: ntstrsafe.h:416
LPWSTR pwszDescription
Definition: pdevobj.h:72
VOID NTAPI VideoPortCallout(_In_ PVOID Params)
Definition: device.c:256
static PGRAPHICS_DEVICE gpGraphicsDeviceFirst
Definition: device.c:18
ENGAPI VOID APIENTRY EngAcquireSemaphore(_Inout_ HSEMAPHORE hsem)
BOOL FASTCALL IntPaintDesktop(HDC hDC)
Definition: desktop.c:1795
#define FILE_WRITE_DATA
Definition: nt_native.h:631
Status
Definition: gdiplustypes.h:24
#define TRACE(s)
Definition: solgame.cpp:4
struct _GRAPHICS_DEVICE * pNextGraphicsDevice
Definition: pdevobj.h:61
#define ASSERT(a)
Definition: mode.c:44
__wchar_t WCHAR
Definition: xmlstorage.h:180
ULONG iCurrentMode
Definition: pdevobj.h:78
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTRSAFEVAPI RtlStringCbPrintfW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1173
LPWSTR pDiplayDrivers
Definition: pdevobj.h:71
ULONG cDevModes
Definition: pdevobj.h:69
OUT HANDLE pPhysDeviceObject
Definition: ntddvdeo.h:265
static HSEMAPHORE ghsemGraphicsDeviceList
Definition: device.c:20
* PFILE_OBJECT
Definition: iotypes.h:1998
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
static const WCHAR L[]
Definition: oid.c:1250
HDC hdc
Definition: main.c:9
#define NTSTATUS
Definition: precomp.h:20
#define GDITAG_DRVSUP
Definition: tags.h:76
#define GDITAG_GDEVICE
Definition: tags.h:98
OUT ULONG DualviewFlags
Definition: ntddvdeo.h:266
#define ERR(fmt,...)
Definition: debug.h:110
static ULONG giDevNum
Definition: device.c:21
HDC FASTCALL IntGdiCreateDC(PUNICODE_STRING Driver, PUNICODE_STRING pustrDevice, PVOID pUMdhpdev, CONST PDEVMODEW pdmInit, BOOL CreateAsIC)
Definition: dclife.c:1040
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
HDC ScreenDeviceContext
Definition: desktop.c:36
PDEVMODEINFO pdevmodeInfo
Definition: pdevobj.h:68
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
ULONG iDefaultMode
Definition: pdevobj.h:77
PFILE_OBJECT FileObject
Definition: pdevobj.h:75
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

Referenced by InitDisplayDriver().

◆ EngpUpdateGraphicsDeviceList()

NTSTATUS EngpUpdateGraphicsDeviceList ( VOID  )

Definition at line 36 of file device.c.

37 {
38  ULONG iDevNum, iVGACompatible = -1, ulMaxObjectNumber = 0;
39  WCHAR awcDeviceName[20];
40  UNICODE_STRING ustrDeviceName;
41  WCHAR awcBuffer[256];
43  PGRAPHICS_DEVICE pGraphicsDevice;
44  ULONG cbValue;
45  HKEY hkey;
46 
47  /* Open the key for the adapters */
48  Status = RegOpenKey(L"\\Registry\\Machine\\HARDWARE\\DEVICEMAP\\VIDEO", &hkey);
49  if (!NT_SUCCESS(Status))
50  {
51  ERR("Could not open HARDWARE\\DEVICEMAP\\VIDEO registry key:0x%lx\n", Status);
52  return Status;
53  }
54 
55  /* Read the name of the VGA adapter */
56  cbValue = sizeof(awcDeviceName);
57  Status = RegQueryValue(hkey, L"VgaCompatible", REG_SZ, awcDeviceName, &cbValue);
58  if (NT_SUCCESS(Status))
59  {
60  iVGACompatible = _wtoi(&awcDeviceName[sizeof("\\Device\\Video")-1]);
61  ERR("VGA adapter = %lu\n", iVGACompatible);
62  }
63 
64  /* Get the maximum mumber of adapters */
65  if (!RegReadDWORD(hkey, L"MaxObjectNumber", &ulMaxObjectNumber))
66  {
67  ERR("Could not read MaxObjectNumber, defaulting to 0.\n");
68  }
69 
70  TRACE("Found %lu devices\n", ulMaxObjectNumber + 1);
71 
72  /* Loop through all adapters */
73  for (iDevNum = 0; iDevNum <= ulMaxObjectNumber; iDevNum++)
74  {
75  /* Create the adapter's key name */
76  swprintf(awcDeviceName, L"\\Device\\Video%lu", iDevNum);
77  RtlInitUnicodeString(&ustrDeviceName, awcDeviceName);
78 
79  /* Check if the device exists already */
80  pGraphicsDevice = EngpFindGraphicsDevice(&ustrDeviceName, iDevNum, 0);
81  if (pGraphicsDevice != NULL)
82  {
83  continue;
84  }
85 
86  /* Read the reg key name */
87  cbValue = sizeof(awcBuffer);
88  Status = RegQueryValue(hkey, awcDeviceName, REG_SZ, awcBuffer, &cbValue);
89  if (!NT_SUCCESS(Status))
90  {
91  ERR("failed to query the registry path:0x%lx\n", Status);
92  continue;
93  }
94 
95  /* Initialize the driver for this device */
96  pGraphicsDevice = InitDisplayDriver(awcDeviceName, awcBuffer);
97  if (!pGraphicsDevice) continue;
98 
99  /* Check if this is a VGA compatible adapter */
100  if (pGraphicsDevice->StateFlags & DISPLAY_DEVICE_VGA_COMPATIBLE)
101  {
102  /* Save this as the VGA adapter */
103  if (!gpVgaGraphicsDevice)
104  {
105  gpVgaGraphicsDevice = pGraphicsDevice;
106  TRACE("gpVgaGraphicsDevice = %p\n", gpVgaGraphicsDevice);
107  }
108  }
109 
110  /* Set the first one as primary device */
112  {
113  gpPrimaryGraphicsDevice = pGraphicsDevice;
114  TRACE("gpPrimaryGraphicsDevice = %p\n", gpPrimaryGraphicsDevice);
115  }
116  }
117 
118  /* Close the device map registry key */
119  ZwClose(hkey);
120 
121  return STATUS_SUCCESS;
122 }
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
DWORD StateFlags
Definition: pdevobj.h:66
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
LONG NTSTATUS
Definition: precomp.h:26
PGRAPHICS_DEVICE gpVgaGraphicsDevice
Definition: device.c:16
#define swprintf
Definition: precomp.h:40
PGRAPHICS_DEVICE NTAPI InitDisplayDriver(IN PWSTR pwszDeviceName, IN PWSTR pwszRegKey)
Definition: display.c:66
PGRAPHICS_DEVICE gpPrimaryGraphicsDevice
Definition: device.c:15
PGRAPHICS_DEVICE NTAPI EngpFindGraphicsDevice(_In_opt_ PUNICODE_STRING pustrDevice, _In_ ULONG iDevNum, _In_ DWORD dwFlags)
Definition: device.c:469
Status
Definition: gdiplustypes.h:24
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
BOOL NTAPI RegReadDWORD(HKEY hkey, PWSTR pwszValue, PDWORD pdwData)
Definition: registry.c:150
static const WCHAR L[]
Definition: oid.c:1250
#define ERR(fmt,...)
Definition: debug.h:110
#define NULL
Definition: types.h:112
#define DISPLAY_DEVICE_VGA_COMPATIBLE
Definition: wingdi.h:1399
#define RegQueryValue
Definition: winreg.h:523
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define STATUS_SUCCESS
Definition: shellext.h:65
#define RegOpenKey
Definition: winreg.h:519
#define REG_SZ
Definition: layer.c:22

Referenced by InitVideo(), and UserEnumDisplayDevices().

◆ InitDeviceImpl()

NTSTATUS NTAPI InitDeviceImpl ( VOID  )

Definition at line 26 of file device.c.

27 {
31 
32  return STATUS_SUCCESS;
33 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
static HSEMAPHORE ghsemGraphicsDeviceList
Definition: device.c:20
HSEMAPHORE WINAPI EngCreateSemaphore(VOID)
Definition: eng.c:75
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by DriverEntry().

◆ UserRefreshDisplay()

VOID UserRefreshDisplay ( IN PPDEVOBJ  ppdev)

Definition at line 198 of file display.c.

199 {
200  ULONG_PTR ulResult;
201  // PVOID pvOldCursor;
202 
203  // TODO: Re-enable the cursor reset code once this function becomes called
204  // from within a Win32 thread... Indeed UserSetCursor() requires this, but
205  // at the moment this function is directly called from a separate thread
206  // from within videoprt, instead of by a separate win32k system thread.
207 
208  if (!ppdev)
209  return;
210 
211  PDEVOBJ_vReference(ppdev);
212 
213  /* Remove mouse pointer */
214  // pvOldCursor = UserSetCursor(NULL, TRUE);
215 
216  /* Do the mode switch -- Use the actual same current mode */
217  ulResult = PDEVOBJ_bSwitchMode(ppdev, ppdev->pdmwDev);
218  ASSERT(ulResult);
219 
220  /* Restore mouse pointer, no hooks called */
221  // pvOldCursor = UserSetCursor(pvOldCursor, TRUE);
222  // ASSERT(pvOldCursor == NULL);
223 
224  /* Update the system metrics */
225  InitMetrics();
226 
227  /* Set new size of the monitor */
228  // UserUpdateMonitorSize((HDEV)ppdev);
229 
230  //co_IntShowDesktop(pdesk, ppdev->gdiinfo.ulHorzRes, ppdev->gdiinfo.ulVertRes);
232 
233  PDEVOBJ_vRelease(ppdev);
234 }
BOOL NTAPI PDEVOBJ_bSwitchMode(PPDEVOBJ ppdev, PDEVMODEW pdm)
Definition: pdevobj.c:509
FORCEINLINE VOID PDEVOBJ_vReference(_In_ PPDEVOBJ ppdev)
Definition: pdevobj.h:167
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define ASSERT(a)
Definition: mode.c:44
BOOL NTAPI InitMetrics(VOID)
Definition: metric.c:19
VOID APIENTRY UserRedrawDesktop(VOID)
Definition: desktop.c:1565
VOID NTAPI PDEVOBJ_vRelease(_Inout_ PPDEVOBJ ppdev)
Definition: pdevobj.c:93

Referenced by VideoPortCallout().

◆ VideoPortCallout()

VOID NTAPI VideoPortCallout ( _In_ PVOID  Params)

Definition at line 256 of file device.c.

258 {
259 /*
260  * IMPORTANT NOTICE!! On Windows XP/2003 this function triggers the creation of
261  * a specific VideoPortCalloutThread() system thread using the same mechanism
262  * as the RIT/desktop/Ghost system threads.
263  */
264 
266 
267  TRACE("VideoPortCallout(0x%p, 0x%x)\n",
268  CallbackParams, CallbackParams ? CallbackParams->CalloutType : -1);
269 
270  if (!CallbackParams)
271  return;
272 
273  switch (CallbackParams->CalloutType)
274  {
276  {
277  TRACE("VideoPortCallout: VideoFindAdapterCallout called - Param = %s\n",
278  CallbackParams->Param ? "TRUE" : "FALSE");
279  if (CallbackParams->Param == TRUE)
280  {
281  /* Re-enable the display */
283  }
284  else
285  {
286  /* Disable the display */
287  NOTHING; // Nothing to do for the moment...
288  }
289 
290  CallbackParams->Status = STATUS_SUCCESS;
291  break;
292  }
293 
297  case VideoWakeupCallout:
303  ERR("VideoPortCallout: CalloutType 0x%x is UNIMPLEMENTED!\n", CallbackParams->CalloutType);
304  CallbackParams->Status = STATUS_NOT_IMPLEMENTED;
305  break;
306 
307  default:
308  ERR("VideoPortCallout: Unknown CalloutType 0x%x\n", CallbackParams->CalloutType);
309  CallbackParams->Status = STATUS_UNSUCCESSFUL;
310  break;
311  }
312 }
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
Definition: wdfrequest.h:306
VIDEO_WIN32K_CALLBACKS_PARAMS_TYPE CalloutType
Definition: ntddvdeo.h:250
#define TRUE
Definition: types.h:120
PPDEVOBJ gppdevPrimary
Definition: pdevobj.c:13
VOID UserRefreshDisplay(IN PPDEVOBJ ppdev)
Definition: display.c:198
return STATUS_NOT_IMPLEMENTED
#define TRACE(s)
Definition: solgame.cpp:4
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
struct _VIDEO_WIN32K_CALLBACKS_PARAMS * PVIDEO_WIN32K_CALLBACKS_PARAMS
#define NOTHING
Definition: env_spec_w32.h:461
#define ERR(fmt,...)
Definition: debug.h:110
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by EngpRegisterGraphicsDevice().

Variable Documentation

◆ dwIoControlCode

_In_ DWORD dwIoControlCode

Definition at line 597 of file device.c.

Referenced by _In_reads_(), and _Success_().

◆ ghsemGraphicsDeviceList

HSEMAPHORE ghsemGraphicsDeviceList
static

Definition at line 20 of file device.c.

Referenced by EngpFindGraphicsDevice(), EngpRegisterGraphicsDevice(), and InitDeviceImpl().

◆ giDevNum

ULONG giDevNum = 1
static

Definition at line 21 of file device.c.

Referenced by EngpRegisterGraphicsDevice().

◆ gpGraphicsDeviceFirst

PGRAPHICS_DEVICE gpGraphicsDeviceFirst = NULL
static

Definition at line 18 of file device.c.

Referenced by EngpFindGraphicsDevice(), and EngpRegisterGraphicsDevice().

◆ gpGraphicsDeviceLast

PGRAPHICS_DEVICE gpGraphicsDeviceLast = NULL
static

Definition at line 19 of file device.c.

Referenced by EngpRegisterGraphicsDevice().

◆ gpPrimaryGraphicsDevice

PGRAPHICS_DEVICE gpPrimaryGraphicsDevice

Definition at line 15 of file device.c.

Referenced by EngpCreatePDEV(), EngpUpdateGraphicsDeviceList(), and InitVideo().

◆ gpVgaGraphicsDevice

PGRAPHICS_DEVICE gpVgaGraphicsDevice

Definition at line 16 of file device.c.

Referenced by EngpUpdateGraphicsDeviceList(), and InitVideo().