ReactOS  0.4.15-dev-3733-g974a0f0
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 601 of file device.c.

606 {
608  KEVENT Event;
609  PIRP pIrp;
612 
613  /* Get corresponding device object */
615  if (!pDeviceObject)
616  {
618  }
619 
620  /* Initialize an event */
622 
623  /* Build IO control IRP */
626  lpInBuffer,
627  (ULONG)nInBufferSize,
628  lpOutBuffer,
629  (ULONG)nOutBufferSize,
630  FALSE,
631  &Event,
632  &Iosb);
633  if (!pIrp)
634  {
636  }
637 
638  /* Call the driver */
640 
641  /* Wait if neccessary */
642  if (Status == STATUS_PENDING)
643  {
645  Status = Iosb.Status;
646  }
647 
648  /* Return information to the caller about the operation. */
649  *lpInformation = Iosb.Information;
650 
651  /* This function returns NTSTATUS */
652  return Status;
653 }
_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:600
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 658 of file device.c.

669 {
670  PIRP Irp;
672  KEVENT Event;
675 
676  TRACE("EngDeviceIoControl() called\n");
677 
678  if (!hDevice)
679  {
680  return ERROR_INVALID_HANDLE;
681  }
682 
684 
685  DeviceObject = (PDEVICE_OBJECT) hDevice;
686 
688  DeviceObject,
689  lpInBuffer,
691  lpOutBuffer,
693  FALSE,
694  &Event,
695  &Iosb);
696  if (!Irp) return ERROR_NOT_ENOUGH_MEMORY;
697 
699 
700  if (Status == STATUS_PENDING)
701  {
703  Status = Iosb.Status;
704  }
705 
706  TRACE("EngDeviceIoControl(): Returning %X/%X\n", Iosb.Status,
707  Iosb.Information);
708 
709  /* Return information to the caller about the operation. */
710  *lpBytesReturned = (DWORD)Iosb.Information;
711 
712  /* Convert NT status values to win32 error codes. */
713  switch (Status)
714  {
717 
719  return ERROR_MORE_DATA;
720 
722  return ERROR_INVALID_FUNCTION;
723 
726 
729 
731  return ERROR_DEV_NOT_EXIST;
732 
733  case STATUS_PENDING:
734  return ERROR_IO_PENDING;
735  }
736 
737  return Status;
738 }
#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:600
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 575 of file device.c.

580 {
582 
583  status = EngpFileIoRequest(pFileObject,
584  IRP_MJ_WRITE,
585  lpBuffer,
586  nLength,
587  0,
588  lpBytesWritten);
589  if (!NT_SUCCESS(status))
590  {
591  *lpBytesWritten = 0;
592  }
593 }
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:517
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 517 of file device.c.

524 {
526  KEVENT Event;
527  PIRP pIrp;
530  LARGE_INTEGER liStartOffset;
531 
532  /* Get corresponding device object */
534  if (!pDeviceObject)
535  {
537  }
538 
539  /* Initialize an event */
541 
542  /* Build IRP */
543  liStartOffset.QuadPart = ullStartOffset;
544  pIrp = IoBuildSynchronousFsdRequest(ulMajorFunction,
546  lpBuffer,
547  (ULONG)nBufferSize,
548  &liStartOffset,
549  &Event,
550  &Iosb);
551  if (!pIrp)
552  {
554  }
555 
556  /* Call the driver */
558 
559  /* Wait if neccessary */
560  if (STATUS_PENDING == Status)
561  {
563  Status = Iosb.Status;
564  }
565 
566  /* Return information to the caller about the operation. */
567  *lpInformation = Iosb.Information;
568 
569  /* Return NTSTATUS */
570  return Status;
571 }
_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 472 of file device.c.

476 {
477  UNICODE_STRING ustrCurrent;
478  PGRAPHICS_DEVICE pGraphicsDevice;
479  ULONG i;
480  TRACE("EngpFindGraphicsDevice('%wZ', %lu, 0x%lx)\n",
481  pustrDevice, iDevNum, dwFlags);
482 
483  /* Lock list */
485 
486  if (pustrDevice && pustrDevice->Buffer)
487  {
488  /* Loop through the list of devices */
489  for (pGraphicsDevice = gpGraphicsDeviceFirst;
490  pGraphicsDevice;
491  pGraphicsDevice = pGraphicsDevice->pNextGraphicsDevice)
492  {
493  /* Compare the device name */
494  RtlInitUnicodeString(&ustrCurrent, pGraphicsDevice->szWinDeviceName);
495  if (RtlEqualUnicodeString(&ustrCurrent, pustrDevice, FALSE))
496  {
497  break;
498  }
499  }
500  }
501  else
502  {
503  /* Loop through the list of devices */
504  for (pGraphicsDevice = gpGraphicsDeviceFirst, i = 0;
505  pGraphicsDevice && i < iDevNum;
506  pGraphicsDevice = pGraphicsDevice->pNextGraphicsDevice, i++);
507  }
508 
509  /* Unlock list */
511 
512  return pGraphicsDevice;
513 }
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 128 of file device.c.

131 {
132  PWSTR pwsz;
133  PLDEVOBJ pldev;
134  PDEVMODEINFO pdminfo;
135  PDEVMODEW pdm, pdmEnd;
136  ULONG i, cModes = 0;
137  BOOLEAN bModeMatch = FALSE;
138 
139  ASSERT(pGraphicsDevice->pdevmodeInfo == NULL);
140  ASSERT(pGraphicsDevice->pDevModeList == NULL);
141 
142  pwsz = pGraphicsDevice->pDiplayDrivers;
143 
144  /* Loop through the driver names
145  * This is a REG_MULTI_SZ string */
146  for (; *pwsz; pwsz += wcslen(pwsz) + 1)
147  {
148  /* Try to load the display driver */
149  TRACE("Trying driver: %ls\n", pwsz);
150  pldev = EngLoadImageEx(pwsz, LDEV_DEVICE_DISPLAY);
151  if (!pldev)
152  {
153  ERR("Could not load driver: '%ls'\n", pwsz);
154  continue;
155  }
156 
157  /* Get the mode list from the driver */
158  pdminfo = LDEVOBJ_pdmiGetModes(pldev, pGraphicsDevice->DeviceObject);
159  if (!pdminfo)
160  {
161  ERR("Could not get mode list for '%ls'\n", pwsz);
162  continue;
163  }
164 
165  /* Attach the mode info to the device */
166  pdminfo->pdmiNext = pGraphicsDevice->pdevmodeInfo;
167  pGraphicsDevice->pdevmodeInfo = pdminfo;
168 
169  /* Loop all DEVMODEs */
170  pdmEnd = (DEVMODEW*)((PCHAR)pdminfo->adevmode + pdminfo->cbdevmode);
171  for (pdm = pdminfo->adevmode;
172  (pdm + 1 <= pdmEnd) && (pdm->dmSize != 0);
173  pdm = (DEVMODEW*)((PCHAR)pdm + pdm->dmSize + pdm->dmDriverExtra))
174  {
175  /* Count this DEVMODE */
176  cModes++;
177 
178  /* Some drivers like the VBox driver don't fill the dmDeviceName
179  with the name of the display driver. So fix that here. */
180  RtlStringCbCopyW(pdm->dmDeviceName, sizeof(pdm->dmDeviceName), pwsz);
181  }
182 
183  // FIXME: release the driver again until it's used?
184  }
185 
186  if (!pGraphicsDevice->pdevmodeInfo || cModes == 0)
187  {
188  ERR("No devmodes\n");
189  return FALSE;
190  }
191 
192  /* Allocate an index buffer */
193  pGraphicsDevice->cDevModes = cModes;
194  pGraphicsDevice->pDevModeList = ExAllocatePoolWithTag(PagedPool,
195  cModes * sizeof(DEVMODEENTRY),
197  if (!pGraphicsDevice->pDevModeList)
198  {
199  ERR("No devmode list\n");
200  return FALSE;
201  }
202 
203  TRACE("Looking for mode %lux%lux%lu(%lu Hz)\n",
204  pdmDefault->dmPelsWidth,
205  pdmDefault->dmPelsHeight,
206  pdmDefault->dmBitsPerPel,
207  pdmDefault->dmDisplayFrequency);
208 
209  /* Loop through all DEVMODEINFOs */
210  for (pdminfo = pGraphicsDevice->pdevmodeInfo, i = 0;
211  pdminfo;
212  pdminfo = pdminfo->pdmiNext)
213  {
214  /* Calculate End of the DEVMODEs */
215  pdmEnd = (DEVMODEW*)((PCHAR)pdminfo->adevmode + pdminfo->cbdevmode);
216 
217  /* Loop through the DEVMODEs */
218  for (pdm = pdminfo->adevmode;
219  (pdm + 1 <= pdmEnd) && (pdm->dmSize != 0);
220  pdm = (PDEVMODEW)((PCHAR)pdm + pdm->dmSize + pdm->dmDriverExtra))
221  {
222  TRACE(" %S has mode %lux%lux%lu(%lu Hz)\n",
223  pdm->dmDeviceName,
224  pdm->dmPelsWidth,
225  pdm->dmPelsHeight,
226  pdm->dmBitsPerPel,
227  pdm->dmDisplayFrequency);
228  /* Compare with the default entry */
229  if (!bModeMatch &&
230  pdm->dmBitsPerPel == pdmDefault->dmBitsPerPel &&
231  pdm->dmPelsWidth == pdmDefault->dmPelsWidth &&
232  pdm->dmPelsHeight == pdmDefault->dmPelsHeight)
233  {
234  pGraphicsDevice->iDefaultMode = i;
235  pGraphicsDevice->iCurrentMode = i;
236  TRACE("Found default entry: %lu '%ls'\n", i, pdm->dmDeviceName);
237  if (pdm->dmDisplayFrequency == pdmDefault->dmDisplayFrequency)
238  {
239  /* Uh oh, even the display frequency matches. */
240  bModeMatch = TRUE;
241  }
242  }
243 
244  /* Initialize the entry */
245  pGraphicsDevice->pDevModeList[i].dwFlags = 0;
246  pGraphicsDevice->pDevModeList[i].pdm = pdm;
247  i++;
248  }
249  }
250  return TRUE;
251 }
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:1621
DWORD dmBitsPerPel
Definition: wingdi.h:1647
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:1620
WCHAR dmDeviceName[CCHDEVICENAME]
Definition: wingdi.h:1617
DWORD dmPelsWidth
Definition: wingdi.h:1648
#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:1654
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:1649
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 319 of file device.c.

324 {
325  PGRAPHICS_DEVICE pGraphicsDevice;
327  PFILE_OBJECT pFileObject;
329  VIDEO_WIN32K_CALLBACKS Win32kCallbacks;
330  ULONG ulReturn;
331  PWSTR pwsz;
332  ULONG cj;
333 
334  TRACE("EngpRegisterGraphicsDevice(%wZ)\n", pustrDeviceName);
335 
336  /* Allocate a GRAPHICS_DEVICE structure */
337  pGraphicsDevice = ExAllocatePoolWithTag(PagedPool,
338  sizeof(GRAPHICS_DEVICE),
340  if (!pGraphicsDevice)
341  {
342  ERR("ExAllocatePoolWithTag failed\n");
343  return NULL;
344  }
345 
346  /* Try to open and enable the device */
347  Status = IoGetDeviceObjectPointer(pustrDeviceName,
349  &pFileObject,
350  &pDeviceObject);
351  if (!NT_SUCCESS(Status))
352  {
353  ERR("Could not open device %wZ, 0x%lx\n", pustrDeviceName, Status);
354  ExFreePoolWithTag(pGraphicsDevice, GDITAG_GDEVICE);
355  return NULL;
356  }
357 
358  /* Copy the device and file object pointers */
359  pGraphicsDevice->DeviceObject = pDeviceObject;
360  pGraphicsDevice->FileObject = pFileObject;
361 
362  /* Initialize and register the device with videoprt for Win32k callbacks */
363  Win32kCallbacks.PhysDisp = pGraphicsDevice;
364  Win32kCallbacks.Callout = VideoPortCallout;
365  // Reset the data being returned prior to the call.
366  Win32kCallbacks.bACPI = FALSE;
367  Win32kCallbacks.pPhysDeviceObject = NULL;
368  Win32kCallbacks.DualviewFlags = 0;
369  Status = (NTSTATUS)EngDeviceIoControl((HANDLE)pDeviceObject,
371  &Win32kCallbacks,
372  sizeof(Win32kCallbacks),
373  &Win32kCallbacks,
374  sizeof(Win32kCallbacks),
375  &ulReturn);
376  if (Status != ERROR_SUCCESS)
377  {
378  ERR("EngDeviceIoControl(0x%p, IOCTL_VIDEO_INIT_WIN32K_CALLBACKS) failed, Status 0x%lx\n",
380  }
381  // TODO: Set flags according to the results.
382  // if (Win32kCallbacks.bACPI)
383  // if (Win32kCallbacks.DualviewFlags & ???)
384  // Win32kCallbacks.pPhysDeviceObject;
385 
386  /* Copy the device name */
387  RtlStringCbCopyNW(pGraphicsDevice->szNtDeviceName,
388  sizeof(pGraphicsDevice->szNtDeviceName),
389  pustrDeviceName->Buffer,
390  pustrDeviceName->Length);
391 
392  /* Create a Win32 device name (FIXME: virtual devices!) */
393  RtlStringCbPrintfW(pGraphicsDevice->szWinDeviceName,
394  sizeof(pGraphicsDevice->szWinDeviceName),
395  L"\\\\.\\DISPLAY%d",
396  (int)giDevNum);
397 
398  /* Allocate a buffer for the strings */
399  cj = pustrDiplayDrivers->Length + pustrDescription->Length + sizeof(WCHAR);
401  if (!pwsz)
402  {
403  ERR("Could not allocate string buffer\n");
404  ASSERT(FALSE); // FIXME
405  ExFreePoolWithTag(pGraphicsDevice, GDITAG_GDEVICE);
406  return NULL;
407  }
408 
409  /* Copy the display driver names */
410  pGraphicsDevice->pDiplayDrivers = pwsz;
411  RtlCopyMemory(pGraphicsDevice->pDiplayDrivers,
412  pustrDiplayDrivers->Buffer,
413  pustrDiplayDrivers->Length);
414 
415  /* Copy the description */
416  pGraphicsDevice->pwszDescription = pwsz + pustrDiplayDrivers->Length / sizeof(WCHAR);
417  RtlCopyMemory(pGraphicsDevice->pwszDescription,
418  pustrDescription->Buffer,
419  pustrDescription->Length);
420  pGraphicsDevice->pwszDescription[pustrDescription->Length/sizeof(WCHAR)] = 0;
421 
422  /* Initialize the pdevmodeInfo list and default index */
423  pGraphicsDevice->pdevmodeInfo = NULL;
424  pGraphicsDevice->iDefaultMode = 0;
425  pGraphicsDevice->iCurrentMode = 0;
426 
427  // FIXME: initialize state flags
428  pGraphicsDevice->StateFlags = 0;
429 
430  /* Create the mode list */
431  pGraphicsDevice->pDevModeList = NULL;
432  if (!EngpPopulateDeviceModeList(pGraphicsDevice, pdmDefault))
433  {
434  ExFreePoolWithTag(pGraphicsDevice, GDITAG_GDEVICE);
435  return NULL;
436  }
437 
438  /* Lock loader */
440 
441  /* Insert the device into the global list */
442  pGraphicsDevice->pNextGraphicsDevice = NULL;
444  gpGraphicsDeviceLast->pNextGraphicsDevice = pGraphicsDevice;
445  gpGraphicsDeviceLast = pGraphicsDevice;
447  gpGraphicsDeviceFirst = pGraphicsDevice;
448 
449  /* Increment the device number */
450  giDevNum++;
451 
452  /* Unlock loader */
454  TRACE("Prepared %lu modes for %ls\n", pGraphicsDevice->cDevModes, pGraphicsDevice->pwszDescription);
455 
456  /* HACK: already in graphic mode; display wallpaper on this new display */
458  {
459  UNICODE_STRING DriverName = RTL_CONSTANT_STRING(L"DISPLAY");
460  UNICODE_STRING DisplayName;
461  HDC hdc;
462  RtlInitUnicodeString(&DisplayName, pGraphicsDevice->szWinDeviceName);
463  hdc = IntGdiCreateDC(&DriverName, &DisplayName, NULL, NULL, FALSE);
465  }
466 
467  return pGraphicsDevice;
468 }
BOOLEAN EngpPopulateDeviceModeList(_Inout_ PGRAPHICS_DEVICE pGraphicsDevice, _In_ PDEVMODEW pdmDefault)
Definition: device.c:128
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 L(x)
Definition: ntvdm.h:50
#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:259
static PGRAPHICS_DEVICE gpGraphicsDeviceFirst
Definition: device.c:18
ENGAPI VOID APIENTRY EngAcquireSemaphore(_Inout_ HSEMAPHORE hsem)
BOOL FASTCALL IntPaintDesktop(HDC hDC)
Definition: desktop.c:1798
#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
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], awcWinDeviceName[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 
78  /* Create the display device name */
79  swprintf(awcWinDeviceName, L"\\\\.\\DISPLAY%lu", iDevNum + 1);
80  RtlInitUnicodeString(&ustrDeviceName, awcWinDeviceName);
81 
82  /* Check if the device exists already */
83  pGraphicsDevice = EngpFindGraphicsDevice(&ustrDeviceName, iDevNum, 0);
84  if (pGraphicsDevice != NULL)
85  {
86  continue;
87  }
88 
89  /* Read the reg key name */
90  cbValue = sizeof(awcBuffer);
91  Status = RegQueryValue(hkey, awcDeviceName, REG_SZ, awcBuffer, &cbValue);
92  if (!NT_SUCCESS(Status))
93  {
94  ERR("failed to query the registry path:0x%lx\n", Status);
95  continue;
96  }
97 
98  /* Initialize the driver for this device */
99  pGraphicsDevice = InitDisplayDriver(awcDeviceName, awcBuffer);
100  if (!pGraphicsDevice) continue;
101 
102  /* Check if this is a VGA compatible adapter */
103  if (pGraphicsDevice->StateFlags & DISPLAY_DEVICE_VGA_COMPATIBLE)
104  {
105  /* Save this as the VGA adapter */
106  if (!gpVgaGraphicsDevice)
107  {
108  gpVgaGraphicsDevice = pGraphicsDevice;
109  TRACE("gpVgaGraphicsDevice = %p\n", gpVgaGraphicsDevice);
110  }
111  }
112 
113  /* Set the first one as primary device */
115  {
116  gpPrimaryGraphicsDevice = pGraphicsDevice;
117  TRACE("gpPrimaryGraphicsDevice = %p\n", gpPrimaryGraphicsDevice);
118  }
119  }
120 
121  /* Close the device map registry key */
122  ZwClose(hkey);
123 
124  return STATUS_SUCCESS;
125 }
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
#define L(x)
Definition: ntvdm.h:50
PGRAPHICS_DEVICE NTAPI EngpFindGraphicsDevice(_In_opt_ PUNICODE_STRING pustrDevice, _In_ ULONG iDevNum, _In_ DWORD dwFlags)
Definition: device.c:472
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
#define ERR(fmt,...)
Definition: debug.h:110
#define NULL
Definition: types.h:112
#define DISPLAY_DEVICE_VGA_COMPATIBLE
Definition: wingdi.h:1400
#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:510
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:1570
VOID NTAPI PDEVOBJ_vRelease(_Inout_ PPDEVOBJ ppdev)
Definition: pdevobj.c:93

Referenced by VideoPortCallout().

◆ VideoPortCallout()

VOID NTAPI VideoPortCallout ( _In_ PVOID  Params)

Definition at line 259 of file device.c.

261 {
262 /*
263  * IMPORTANT NOTICE!! On Windows XP/2003 this function triggers the creation of
264  * a specific VideoPortCalloutThread() system thread using the same mechanism
265  * as the RIT/desktop/Ghost system threads.
266  */
267 
269 
270  TRACE("VideoPortCallout(0x%p, 0x%x)\n",
271  CallbackParams, CallbackParams ? CallbackParams->CalloutType : -1);
272 
273  if (!CallbackParams)
274  return;
275 
276  switch (CallbackParams->CalloutType)
277  {
279  {
280  TRACE("VideoPortCallout: VideoFindAdapterCallout called - Param = %s\n",
281  CallbackParams->Param ? "TRUE" : "FALSE");
282  if (CallbackParams->Param == TRUE)
283  {
284  /* Re-enable the display */
286  }
287  else
288  {
289  /* Disable the display */
290  NOTHING; // Nothing to do for the moment...
291  }
292 
293  CallbackParams->Status = STATUS_SUCCESS;
294  break;
295  }
296 
300  case VideoWakeupCallout:
306  ERR("VideoPortCallout: CalloutType 0x%x is UNIMPLEMENTED!\n", CallbackParams->CalloutType);
307  CallbackParams->Status = STATUS_NOT_IMPLEMENTED;
308  break;
309 
310  default:
311  ERR("VideoPortCallout: Unknown CalloutType 0x%x\n", CallbackParams->CalloutType);
312  CallbackParams->Status = STATUS_UNSUCCESSFUL;
313  break;
314  }
315 }
_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 600 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().