ReactOS  0.4.15-dev-4872-g8a3db97
ldevobj.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _LDEVOBJ
 

Typedefs

typedef struct _LDEVOBJ LDEVOBJ
 
typedef struct _LDEVOBJPLDEVOBJ
 

Enumerations

enum  LDEVTYPE {
  LDEV_DEVICE_DISPLAY = 1, LDEV_DEVICE_PRINTER = 2, LDEV_DEVICE_META = 3, LDEV_DEVICE_MIRROR = 4,
  LDEV_IMAGE = 5, LDEV_FONT = 6
}
 

Functions

NTSTATUS NTAPI InitLDEVImpl (VOID)
 
ULONG LDEVOBJ_ulGetDriverModes (_In_ LPWSTR pwszDriverName, _In_ HANDLE hDriver, _Out_ PDEVMODEW *ppdm)
 
PLDEVOBJ LDEVOBJ_pLoadInternal (_In_ PFN_DrvEnableDriver pfnEnableDriver, _In_ ULONG ldevtype)
 
PLDEVOBJ APIENTRY LDEVOBJ_pLoadDriver (_In_z_ LPWSTR pwszDriverName, _In_ ULONG ldevtype)
 
BOOL LDEVOBJ_bBuildDevmodeList (_Inout_ PGRAPHICS_DEVICE pGraphicsDevice)
 
BOOL LDEVOBJ_bProbeAndCaptureDevmode (_Inout_ PGRAPHICS_DEVICE pGraphicsDevice, _In_ PDEVMODEW RequestedMode, _Out_ PDEVMODEW *pSelectedMode, _In_ BOOL bSearchClosestMode)
 
NTSTATUS APIENTRY DriverEntry (_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPath)
 

Variables

IMAGE_DOS_HEADER __ImageBase
 
static const unsigned GDI_ENGINE_VERSION = DDI_DRIVER_VERSION_NT5_01
 

Typedef Documentation

◆ LDEVOBJ

◆ PLDEVOBJ

Enumeration Type Documentation

◆ LDEVTYPE

Enumerator
LDEV_DEVICE_DISPLAY 
LDEV_DEVICE_PRINTER 
LDEV_DEVICE_META 
LDEV_DEVICE_MIRROR 
LDEV_IMAGE 
LDEV_FONT 

Definition at line 6 of file ldevobj.h.

Function Documentation

◆ DriverEntry()

NTSTATUS APIENTRY DriverEntry ( _In_ PDRIVER_OBJECT  DriverObject,
_In_ PUNICODE_STRING  RegistryPath 
)

Definition at line 1606 of file isapnp.c.

1609 {
1610  DPRINT("%s(%p, %wZ)\n", __FUNCTION__, DriverObject, RegistryPath);
1611 
1612  DriverObject->MajorFunction[IRP_MJ_CREATE] = IsaCreateClose;
1613  DriverObject->MajorFunction[IRP_MJ_CLOSE] = IsaCreateClose;
1614  DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = IsaForwardOrIgnore;
1615  DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = IsaForwardOrIgnore;
1616  DriverObject->MajorFunction[IRP_MJ_PNP] = IsaPnp;
1617  DriverObject->MajorFunction[IRP_MJ_POWER] = IsaPower;
1618  DriverObject->DriverExtension->AddDevice = IsaAddDevice;
1619 
1620  /* FIXME: Fix SDK headers */
1621 #if 0
1623 #endif
1624 
1626  InitializeListHead(&BusListHead);
1627 
1628  /* FIXME: Fix SDK headers */
1629 #if 0
1631 #endif
1632 
1633  return STATUS_SUCCESS;
1634 }
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define TRUE
Definition: types.h:120
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:213
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
KEVENT BusSyncEvent
Definition: isapnp.c:21
#define IRP_MJ_POWER
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define _No_competing_thread_end_
#define IRP_MJ_SYSTEM_CONTROL
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define _No_competing_thread_begin_
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
#define __FUNCTION__
Definition: types.h:112
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52

Referenced by PortAddDevice(), PortUnload(), and StorPortInitialize().

◆ InitLDEVImpl()

NTSTATUS NTAPI InitLDEVImpl ( VOID  )

Private functions

Definition at line 30 of file ldevobj.c.

31 {
32  ULONG cbSize;
33 
34  /* Initialize the LDEV list head */
36 
37  /* Initialize the loader lock */
39  if (!ghsemLDEVList)
40  {
41  ERR("Failed to create ghsemLDEVList\n");
43  }
44 
45  /* Allocate a LDEVOBJ for win32k */
47  sizeof(LDEVOBJ) +
49  GDITAG_LDEV);
50  if (!gpldevWin32k)
51  {
52  return STATUS_NO_MEMORY;
53  }
54 
55  /* Initialize the LDEVOBJ for win32k */
59  gpldevWin32k->cRefs = 1;
63  L"\\SystemRoot\\System32\\win32k.sys");
69  TRUE,
71  &cbSize);
73 
74  return STATUS_SUCCESS;
75 }
#define GDITAG_LDEV
Definition: tags.h:136
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define TRUE
Definition: types.h:120
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122
#define L(x)
Definition: ntvdm.h:50
static HSEMAPHORE ghsemLDEVList
Definition: ldevobj.c:20
static const unsigned GDI_ENGINE_VERSION
Definition: ldevobj.h:4
void * PVOID
Definition: retypes.h:9
static LDEVOBJ * gpldevWin32k
Definition: ldevobj.c:22
static LIST_ENTRY gleLdevListHead
Definition: ldevobj.c:21
SYSTEM_GDI_DRIVER_INFORMATION * pGdiDriverInfo
Definition: ldevobj.h:19
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define RtlImageDirectoryEntryToData
Definition: compat.h:668
#define IMAGE_DIRECTORY_ENTRY_EXPORT
Definition: compat.h:151
#define ERR(fmt,...)
Definition: debug.h:110
DRIVER_INITIALIZE DriverEntry
Definition: condrv.c:21
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define NULL
Definition: types.h:112
ULONG ulDriverVersion
Definition: ldevobj.h:22
HSEMAPHORE WINAPI EngCreateSemaphore(VOID)
Definition: eng.c:75
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
LDEVTYPE ldevtype
Definition: ldevobj.h:20
LIST_ENTRY leLink
Definition: ldevobj.h:18
#define STATUS_SUCCESS
Definition: shellext.h:65
#define __ImageBase
Definition: crt_handler.c:22
PIMAGE_EXPORT_DIRECTORY ExportSectionPointer
Definition: DriverTester.h:49
ULONG cRefs
Definition: ldevobj.h:21

Referenced by DriverEntry().

◆ LDEVOBJ_bBuildDevmodeList()

BOOL LDEVOBJ_bBuildDevmodeList ( _Inout_ PGRAPHICS_DEVICE  pGraphicsDevice)

Definition at line 563 of file ldevobj.c.

565 {
566  PWSTR pwsz;
567  PDEVMODEINFO pdminfo;
568  PDEVMODEW pdm, pdmEnd;
569  ULONG i, cModes = 0;
570  ULONG cbSize, cbFull;
571 
572  if (pGraphicsDevice->pdevmodeInfo)
573  return TRUE;
574  ASSERT(pGraphicsDevice->pDevModeList == NULL);
575 
576  pwsz = pGraphicsDevice->pDiplayDrivers;
577 
578  /* Loop through the driver names
579  * This is a REG_MULTI_SZ string */
580  for (; *pwsz; pwsz += wcslen(pwsz) + 1)
581  {
582  /* Get the mode list from the driver */
583  TRACE("Trying driver: %ls\n", pwsz);
584  cbSize = LDEVOBJ_ulGetDriverModes(pwsz, pGraphicsDevice->DeviceObject, &pdm);
585  if (!cbSize)
586  {
587  WARN("Driver %ls returned no valid mode\n", pwsz);
588  continue;
589  }
590 
591  /* Add space for the header */
592  cbFull = cbSize + FIELD_OFFSET(DEVMODEINFO, adevmode);
593 
594  /* Allocate a buffer for the DEVMODE array */
595  pdminfo = ExAllocatePoolWithTag(PagedPool, cbFull, GDITAG_DEVMODE);
596  if (!pdminfo)
597  {
598  ERR("Could not allocate devmodeinfo\n");
600  continue;
601  }
602 
603  pdminfo->cbdevmode = cbSize;
604  RtlCopyMemory(pdminfo->adevmode, pdm, cbSize);
606 
607  /* Attach the mode info to the device */
608  pdminfo->pdmiNext = pGraphicsDevice->pdevmodeInfo;
609  pGraphicsDevice->pdevmodeInfo = pdminfo;
610 
611  /* Loop all DEVMODEs */
612  pdmEnd = (DEVMODEW*)((PCHAR)pdminfo->adevmode + pdminfo->cbdevmode);
613  for (pdm = pdminfo->adevmode;
614  (pdm + 1 <= pdmEnd) && (pdm->dmSize != 0);
615  pdm = (DEVMODEW*)((PCHAR)pdm + pdm->dmSize + pdm->dmDriverExtra))
616  {
617  /* Count this DEVMODE */
618  cModes++;
619 
620  /* Some drivers like the VBox driver don't fill the dmDeviceName
621  with the name of the display driver. So fix that here. */
622  RtlStringCbCopyW(pdm->dmDeviceName, sizeof(pdm->dmDeviceName), pwsz);
623  }
624  }
625 
626  if (!pGraphicsDevice->pdevmodeInfo || cModes == 0)
627  {
628  ERR("No devmodes\n");
629  return FALSE;
630  }
631 
632  /* Allocate an index buffer */
633  pGraphicsDevice->cDevModes = cModes;
634  pGraphicsDevice->pDevModeList = ExAllocatePoolWithTag(PagedPool,
635  cModes * sizeof(DEVMODEENTRY),
637  if (!pGraphicsDevice->pDevModeList)
638  {
639  ERR("No devmode list\n");
640  return FALSE;
641  }
642 
643  /* Loop through all DEVMODEINFOs */
644  for (pdminfo = pGraphicsDevice->pdevmodeInfo, i = 0;
645  pdminfo;
646  pdminfo = pdminfo->pdmiNext)
647  {
648  /* Calculate End of the DEVMODEs */
649  pdmEnd = (DEVMODEW*)((PCHAR)pdminfo->adevmode + pdminfo->cbdevmode);
650 
651  /* Loop through the DEVMODEs */
652  for (pdm = pdminfo->adevmode;
653  (pdm + 1 <= pdmEnd) && (pdm->dmSize != 0);
654  pdm = (PDEVMODEW)((PCHAR)pdm + pdm->dmSize + pdm->dmDriverExtra))
655  {
656  TRACE(" %S has mode %lux%lux%lu(%lu Hz)\n",
657  pdm->dmDeviceName,
658  pdm->dmPelsWidth,
659  pdm->dmPelsHeight,
660  pdm->dmBitsPerPel,
661  pdm->dmDisplayFrequency);
662 
663  /* Initialize the entry */
664  pGraphicsDevice->pDevModeList[i].dwFlags = 0;
665  pGraphicsDevice->pDevModeList[i].pdm = pdm;
666  i++;
667  }
668  }
669  return TRUE;
670 }
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
#define GDITAG_DEVMODE
Definition: tags.h:73
struct _devicemodeW * PDEVMODEW
#define TRUE
Definition: types.h:120
uint16_t * PWSTR
Definition: typedefs.h:56
#define WARN(fmt,...)
Definition: debug.h:112
WORD dmDriverExtra
Definition: wingdi.h:1621
ULONG LDEVOBJ_ulGetDriverModes(_In_ LPWSTR pwszDriverName, _In_ HANDLE hDriver, _Out_ PDEVMODEW *ppdm)
Definition: ldevobj.c:509
DWORD dmBitsPerPel
Definition: wingdi.h:1647
#define FALSE
Definition: types.h:117
ULONG cbdevmode
Definition: pdevobj.h:46
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:99
#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 FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#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
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

Referenced by LDEVOBJ_bProbeAndCaptureDevmode(), and PDEVOBJ_vRefreshModeList().

◆ LDEVOBJ_bProbeAndCaptureDevmode()

BOOL LDEVOBJ_bProbeAndCaptureDevmode ( _Inout_ PGRAPHICS_DEVICE  pGraphicsDevice,
_In_ PDEVMODEW  RequestedMode,
_Out_ PDEVMODEW pSelectedMode,
_In_ BOOL  bSearchClosestMode 
)

Definition at line 735 of file ldevobj.c.

740 {
741  DEVMODEW dmSearch;
742  PDEVMODEW pdmCurrent, pdm, pdmSelected = NULL;
743  ULONG i;
744  ULONG ulVirtualWidth = 0, ulVirtualHeight = 0;
745  BOOL bResult = TRUE;
747 
748  if (!LDEVOBJ_bBuildDevmodeList(pGraphicsDevice))
749  return FALSE;
750 
751  /* At first, load information from registry */
752  RtlZeroMemory(&dmSearch, sizeof(dmSearch));
753  Status = EngpGetDisplayDriverParameters(pGraphicsDevice, &dmSearch);
754  if (!NT_SUCCESS(Status))
755  {
756  ERR("EngpGetDisplayDriverParameters() failed with status 0x%08x\n", Status);
757  return FALSE;
758  }
759 
760  /* Override values with the new ones provided */
761 
762  _SEH2_TRY
763  {
764  bSearchClosestMode |= RequestedMode->dmFields == 0;
765 
766  /* Copy standard fields (if provided) */
767  if (RequestedMode->dmFields & DM_BITSPERPEL && RequestedMode->dmBitsPerPel != 0)
768  dmSearch.dmBitsPerPel = RequestedMode->dmBitsPerPel;
769  if (RequestedMode->dmFields & DM_PELSWIDTH && RequestedMode->dmPelsWidth != 0)
770  dmSearch.dmPelsWidth = RequestedMode->dmPelsWidth;
771  if (RequestedMode->dmFields & DM_PELSHEIGHT && RequestedMode->dmPelsHeight != 0)
772  dmSearch.dmPelsHeight = RequestedMode->dmPelsHeight;
773  if (RequestedMode->dmFields & DM_DISPLAYFREQUENCY && RequestedMode->dmDisplayFrequency != 0)
774  dmSearch.dmDisplayFrequency = RequestedMode->dmDisplayFrequency;
775 
776  if ((RequestedMode->dmFields & (DM_PANNINGWIDTH | DM_PANNINGHEIGHT)) == (DM_PANNINGWIDTH | DM_PANNINGHEIGHT) &&
777  RequestedMode->dmPanningWidth != 0 && RequestedMode->dmPanningHeight != 0 &&
778  RequestedMode->dmPanningWidth < dmSearch.dmPelsWidth &&
779  RequestedMode->dmPanningHeight < dmSearch.dmPelsHeight)
780  {
781  /* Get new panning values */
782  ulVirtualWidth = RequestedMode->dmPelsWidth;
783  ulVirtualHeight = RequestedMode->dmPelsHeight;
784  dmSearch.dmPelsWidth = RequestedMode->dmPanningWidth;
785  dmSearch.dmPelsHeight = RequestedMode->dmPanningHeight;
786  }
787  else if (dmSearch.dmPanningWidth != 0 && dmSearch.dmPanningHeight != 0 &&
788  dmSearch.dmPanningWidth < dmSearch.dmPelsWidth &&
789  dmSearch.dmPanningHeight < dmSearch.dmPelsHeight)
790  {
791  /* Keep existing panning values */
792  ulVirtualWidth = dmSearch.dmPelsWidth;
793  ulVirtualHeight = dmSearch.dmPelsHeight;
794  dmSearch.dmPelsWidth = dmSearch.dmPanningWidth;
795  dmSearch.dmPelsHeight = dmSearch.dmPanningHeight;
796  }
797  }
799  {
800  bResult = FALSE;
801  }
802  _SEH2_END;
803 
804  if (!bResult)
805  return FALSE;
806 
807  if (bSearchClosestMode)
808  {
809  if (LDEVOBJ_bGetClosestMode(pGraphicsDevice, &dmSearch, &pdmSelected))
810  {
811  /* Ok, found a closest mode. Update search */
812  dmSearch.dmBitsPerPel = pdmSelected->dmBitsPerPel;
813  dmSearch.dmPelsWidth = pdmSelected->dmPelsWidth;
814  dmSearch.dmPelsHeight = pdmSelected->dmPelsHeight;
815  dmSearch.dmDisplayFrequency = pdmSelected->dmDisplayFrequency;
816  }
817  }
818 
819  /* Now, search the exact mode to return to caller */
820  for (i = 0; i < pGraphicsDevice->cDevModes; i++)
821  {
822  pdmCurrent = pGraphicsDevice->pDevModeList[i].pdm;
823 
824  /* For now, we only need those */
825  if (pdmCurrent->dmBitsPerPel != dmSearch.dmBitsPerPel)
826  continue;
827  if (pdmCurrent->dmPelsWidth != dmSearch.dmPelsWidth)
828  continue;
829  if (pdmCurrent->dmPelsHeight != dmSearch.dmPelsHeight)
830  continue;
831  if (pdmCurrent->dmDisplayFrequency != dmSearch.dmDisplayFrequency)
832  continue;
833 
834  pdmSelected = pdmCurrent;
835  break;
836  }
837 
838  if (!pdmSelected)
839  {
840  ERR("Requested mode not found (%dx%dx%d %d Hz)\n",
841  dmSearch.dmPelsWidth,
842  dmSearch.dmPelsHeight,
843  dmSearch.dmBitsPerPel,
844  dmSearch.dmDisplayFrequency);
845  return FALSE;
846  }
847 
848  /* Allocate memory for output */
849  pdm = ExAllocatePoolZero(PagedPool, pdmSelected->dmSize + pdmSelected->dmDriverExtra, GDITAG_DEVMODE);
850  if (!pdm)
851  return FALSE;
852 
853  /* Copy selected mode */
854  RtlCopyMemory(pdm, pdmSelected, pdmSelected->dmSize);
855  RtlCopyMemory((PVOID)((ULONG_PTR)pdm + pdm->dmSize),
856  (PVOID)((ULONG_PTR)pdmSelected + pdmSelected->dmSize),
857  pdmSelected->dmDriverExtra);
858 
859  /* Add back panning */
860  if (ulVirtualWidth != 0 && ulVirtualHeight != 0 &&
861  pdm->dmPelsWidth < ulVirtualWidth &&
862  pdm->dmPelsHeight < ulVirtualHeight)
863  {
865  pdm->dmPanningWidth = pdm->dmPelsWidth;
866  pdm->dmPanningHeight = pdm->dmPelsHeight;
867  pdm->dmPelsWidth = ulVirtualWidth;
868  pdm->dmPelsHeight = ulVirtualHeight;
869  }
870 
871  *pSelectedMode = pdm;
872  return TRUE;
873 }
#define GDITAG_DEVMODE
Definition: tags.h:73
NTSTATUS EngpGetDisplayDriverParameters(_In_ PGRAPHICS_DEVICE pGraphicsDevice, _Out_ PDEVMODEW pdm)
Definition: device.c:168
DWORD dmFields
Definition: wingdi.h:1622
#define TRUE
Definition: types.h:120
static BOOL LDEVOBJ_bGetClosestMode(_Inout_ PGRAPHICS_DEVICE pGraphicsDevice, _In_ PDEVMODEW RequestedMode, _Out_ PDEVMODEW *pSelectedMode)
Definition: ldevobj.c:676
#define DM_PANNINGWIDTH
Definition: wingdi.h:1277
LONG NTSTATUS
Definition: precomp.h:26
WORD dmDriverExtra
Definition: wingdi.h:1621
DWORD dmBitsPerPel
Definition: wingdi.h:1647
_SEH2_TRY
Definition: create.c:4226
#define DM_PELSWIDTH
Definition: wingdi.h:1269
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
WORD dmSize
Definition: wingdi.h:1620
DWORD dmPelsWidth
Definition: wingdi.h:1648
#define DM_DISPLAYFREQUENCY
Definition: wingdi.h:1272
#define ERR(fmt,...)
Definition: debug.h:110
DWORD dmDisplayFrequency
Definition: wingdi.h:1654
_SEH2_END
Definition: create.c:4400
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 DM_PELSHEIGHT
Definition: wingdi.h:1270
#define NULL
Definition: types.h:112
DWORD dmPelsHeight
Definition: wingdi.h:1649
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
BOOL LDEVOBJ_bBuildDevmodeList(_Inout_ PGRAPHICS_DEVICE pGraphicsDevice)
Definition: ldevobj.c:563
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define DM_BITSPERPEL
Definition: wingdi.h:1268
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
#define DM_PANNINGHEIGHT
Definition: wingdi.h:1278

Referenced by MDEVOBJ_Create(), PDEVOBJ_lChangeDisplaySettings(), and UserChangeDisplaySettings().

◆ LDEVOBJ_pLoadDriver()

PLDEVOBJ APIENTRY LDEVOBJ_pLoadDriver ( _In_z_ LPWSTR  pwszDriverName,
_In_ ULONG  ldevtype 
)

Definition at line 347 of file ldevobj.c.

350 {
351  WCHAR acwBuffer[MAX_PATH];
352  PLIST_ENTRY pleLink;
353  PLDEVOBJ pldev;
354  UNICODE_STRING strDriverName;
355  SIZE_T cwcLength;
356  LPWSTR pwsz;
357 
358  TRACE("LDEVOBJ_pLoadDriver(%ls, %lu)\n", pwszDriverName, ldevtype);
359  ASSERT(pwszDriverName);
360 
361  /* Initialize buffer for the the driver name */
362  RtlInitEmptyUnicodeString(&strDriverName, acwBuffer, sizeof(acwBuffer));
363 
364  /* Start path with systemroot */
365  RtlAppendUnicodeToString(&strDriverName, L"\\SystemRoot\\System32\\");
366 
367  /* Get Length of given string */
368  cwcLength = wcslen(pwszDriverName);
369 
370  /* Check if we have a system32 path given */
371  pwsz = pwszDriverName + cwcLength;
372  while (pwsz > pwszDriverName)
373  {
374  if ((*pwsz == L'\\') && (_wcsnicmp(pwsz, L"\\system32\\", 10) == 0))
375  {
376  /* Driver name starts after system32 */
377  pwsz += 10;
378  break;
379  }
380  pwsz--;
381  }
382 
383  /* Append the driver name */
384  RtlAppendUnicodeToString(&strDriverName, pwsz);
385 
386  /* MSDN says "The driver must include this suffix in the pwszDriver string."
387  But in fact it's optional. The function can also load .sys files without
388  appending the .dll extension. */
389  if ((cwcLength < 4) ||
390  ((_wcsnicmp(pwszDriverName + cwcLength - 4, L".dll", 4) != 0) &&
391  (_wcsnicmp(pwszDriverName + cwcLength - 4, L".sys", 4) != 0)) )
392  {
393  /* Append the .dll suffix */
394  RtlAppendUnicodeToString(&strDriverName, L".dll");
395  }
396 
397  /* Lock loader */
399 
400  /* Search the List of LDEVS for the driver name */
401  for (pleLink = gleLdevListHead.Flink;
402  pleLink != &gleLdevListHead;
403  pleLink = pleLink->Flink)
404  {
405  pldev = CONTAINING_RECORD(pleLink, LDEVOBJ, leLink);
406 
407  /* Check if the ldev is associated with a file */
408  if (pldev->pGdiDriverInfo)
409  {
410  /* Check for match (case insensative) */
411  if (RtlEqualUnicodeString(&pldev->pGdiDriverInfo->DriverName, &strDriverName, TRUE))
412  {
413  /* Image found in LDEV list */
414  break;
415  }
416  }
417  }
418 
419  /* Did we find one? */
420  if (pleLink == &gleLdevListHead)
421  {
422  /* No, allocate a new LDEVOBJ */
423  pldev = LDEVOBJ_AllocLDEV(ldevtype);
424  if (!pldev)
425  {
426  ERR("Could not allocate LDEV\n");
427  goto leave;
428  }
429 
430  /* Load the image */
431  if (!LDEVOBJ_bLoadImage(pldev, &strDriverName))
432  {
433  LDEVOBJ_vFreeLDEV(pldev);
434  pldev = NULL;
435  ERR("LDEVOBJ_bLoadImage failed\n");
436  goto leave;
437  }
438 
439  /* Load the driver */
440  if (!LDEVOBJ_bEnableDriver(pldev, pldev->pGdiDriverInfo->EntryPoint))
441  {
442  ERR("LDEVOBJ_bEnableDriver failed\n");
443 
444  /* Unload the image. */
445  LDEVOBJ_bUnloadImage(pldev);
446  LDEVOBJ_vFreeLDEV(pldev);
447  pldev = NULL;
448  goto leave;
449  }
450 
451  /* Insert the LDEV into the global list */
453  }
454 
455  /* Increase ref count */
456  pldev->cRefs++;
457 
458 leave:
459  /* Unlock loader */
461 
462  TRACE("LDEVOBJ_pLoadDriver returning %p\n", pldev);
463  return pldev;
464 }
VOID WINAPI EngReleaseSemaphore(IN HSEMAPHORE hsem)
Definition: eng.c:235
static VOID LDEVOBJ_vFreeLDEV(_In_ _Post_ptr_invalid_ PLDEVOBJ pldev)
Definition: ldevobj.c:103
#define TRUE
Definition: types.h:120
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define L(x)
Definition: ntvdm.h:50
static HSEMAPHORE ghsemLDEVList
Definition: ldevobj.c:20
ENGAPI VOID APIENTRY EngAcquireSemaphore(_Inout_ HSEMAPHORE hsem)
static LIST_ENTRY gleLdevListHead
Definition: ldevobj.c:21
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
SYSTEM_GDI_DRIVER_INFORMATION * pGdiDriverInfo
Definition: ldevobj.h:19
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define TRACE(s)
Definition: solgame.cpp:4
#define ASSERT(a)
Definition: mode.c:44
__wchar_t WCHAR
Definition: xmlstorage.h:180
static PLDEVOBJ LDEVOBJ_AllocLDEV(_In_ LDEVTYPE ldevtype)
Definition: ldevobj.c:79
#define MAX_PATH
Definition: compat.h:34
Definition: typedefs.h:119
static BOOL LDEVOBJ_bEnableDriver(_Inout_ PLDEVOBJ pldev, _In_ PFN_DrvEnableDriver pfnEnableDriver)
Definition: ldevobj.c:165
#define ERR(fmt,...)
Definition: debug.h:110
ULONG_PTR SIZE_T
Definition: typedefs.h:80
static BOOL LDEVOBJ_bUnloadImage(_Inout_ PLDEVOBJ pldev)
Definition: ldevobj.c:269
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define leave
Definition: btrfs_drv.h:138
static BOOL LDEVOBJ_bLoadImage(_Inout_ PLDEVOBJ pldev, _In_ PUNICODE_STRING pustrPathName)
Definition: ldevobj.c:116
LIST_ENTRY leLink
Definition: ldevobj.h:18
WCHAR * LPWSTR
Definition: xmlstorage.h:184
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
ULONG cRefs
Definition: ldevobj.h:21

Referenced by EngLoadImage(), LDEVOBJ_ulGetDriverModes(), and PDEVOBJ_Create().

◆ LDEVOBJ_pLoadInternal()

PLDEVOBJ LDEVOBJ_pLoadInternal ( _In_ PFN_DrvEnableDriver  pfnEnableDriver,
_In_ ULONG  ldevtype 
)

Definition at line 303 of file ldevobj.c.

306 {
307  PLDEVOBJ pldev;
308 
309  TRACE("LDEVOBJ_pLoadInternal(%lu)\n", ldevtype);
310 
311  /* Lock loader */
313 
314  /* Allocate a new LDEVOBJ */
315  pldev = LDEVOBJ_AllocLDEV(ldevtype);
316  if (!pldev)
317  {
318  ERR("Could not allocate LDEV\n");
319  goto leave;
320  }
321 
322  /* Load the driver */
323  if (!LDEVOBJ_bEnableDriver(pldev, pfnEnableDriver))
324  {
325  ERR("LDEVOBJ_bEnableDriver failed\n");
326  LDEVOBJ_vFreeLDEV(pldev);
327  pldev = NULL;
328  goto leave;
329  }
330 
331  /* Insert the LDEV into the global list */
333 
334  /* Increase ref count */
335  pldev->cRefs++;
336 
337 leave:
338  /* Unlock loader */
340 
341  TRACE("LDEVOBJ_pLoadInternal returning %p\n", pldev);
342  return pldev;
343 }
VOID WINAPI EngReleaseSemaphore(IN HSEMAPHORE hsem)
Definition: eng.c:235
static VOID LDEVOBJ_vFreeLDEV(_In_ _Post_ptr_invalid_ PLDEVOBJ pldev)
Definition: ldevobj.c:103
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
static HSEMAPHORE ghsemLDEVList
Definition: ldevobj.c:20
ENGAPI VOID APIENTRY EngAcquireSemaphore(_Inout_ HSEMAPHORE hsem)
static LIST_ENTRY gleLdevListHead
Definition: ldevobj.c:21
#define TRACE(s)
Definition: solgame.cpp:4
static PLDEVOBJ LDEVOBJ_AllocLDEV(_In_ LDEVTYPE ldevtype)
Definition: ldevobj.c:79
static BOOL LDEVOBJ_bEnableDriver(_Inout_ PLDEVOBJ pldev, _In_ PFN_DrvEnableDriver pfnEnableDriver)
Definition: ldevobj.c:165
#define ERR(fmt,...)
Definition: debug.h:110
#define NULL
Definition: types.h:112
#define leave
Definition: btrfs_drv.h:138
LIST_ENTRY leLink
Definition: ldevobj.h:18
ULONG cRefs
Definition: ldevobj.h:21

Referenced by PDEVOBJ_Create().

◆ LDEVOBJ_ulGetDriverModes()

ULONG LDEVOBJ_ulGetDriverModes ( _In_ LPWSTR  pwszDriverName,
_In_ HANDLE  hDriver,
_Out_ PDEVMODEW ppdm 
)

Definition at line 509 of file ldevobj.c.

513 {
514  PLDEVOBJ pldev = NULL;
515  ULONG cbSize = 0;
516  PDEVMODEW pdm = NULL;
517 
518  TRACE("LDEVOBJ_ulGetDriverModes('%ls', %p)\n", pwszDriverName, hDriver);
519 
520  pldev = LDEVOBJ_pLoadDriver(pwszDriverName, LDEV_DEVICE_DISPLAY);
521  if (!pldev)
522  goto cleanup;
523 
524  /* Mirror drivers may omit this function */
525  if (!pldev->pfn.GetModes)
526  goto cleanup;
527 
528  /* Call the driver to get the required size */
529  cbSize = pldev->pfn.GetModes(hDriver, 0, NULL);
530  if (!cbSize)
531  {
532  ERR("DrvGetModes returned 0\n");
533  goto cleanup;
534  }
535 
536  /* Allocate a buffer for the DEVMODE array */
538  if (!pdm)
539  {
540  ERR("Could not allocate devmodeinfo\n");
541  goto cleanup;
542  }
543 
544  /* Call the driver again to fill the buffer */
545  cbSize = pldev->pfn.GetModes(hDriver, cbSize, pdm);
546  if (!cbSize)
547  {
548  /* Could not get modes */
549  ERR("DrvrGetModes returned 0 on second call\n");
551  pdm = NULL;
552  }
553 
554 cleanup:
555  if (pldev)
556  LDEVOBJ_vDereference(pldev);
557 
558  *ppdm = pdm;
559  return cbSize;
560 }
static VOID LDEVOBJ_vDereference(_Inout_ PLDEVOBJ pldev)
Definition: ldevobj.c:468
#define GDITAG_DEVMODE
Definition: tags.h:73
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG _Out_ DEVINFO _In_ HDEV _In_ LPWSTR _In_ HANDLE hDriver
Definition: winddi.h:3553
PFN_DrvGetModes GetModes
Definition: ntgdityp.h:610
DRIVER_FUNCTIONS pfn
Definition: ldevobj.h:27
#define TRACE(s)
Definition: solgame.cpp:4
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define ERR(fmt,...)
Definition: debug.h:110
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
char * cleanup(char *str)
Definition: wpickclick.c:99
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
PLDEVOBJ NTAPI LDEVOBJ_pLoadDriver(_In_z_ LPWSTR pwszDriverName, _In_ ULONG ldevtype)
Definition: ldevobj.c:347

Referenced by LDEVOBJ_bBuildDevmodeList().

Variable Documentation

◆ __ImageBase

IMAGE_DOS_HEADER __ImageBase

This file has no copyright assigned and is placed in the Public Domain. This file is part of the w64 mingw-runtime package. No warranty is given; refer to the file DISCLAIMER.PD within this package.

Definition at line 17 of file mstscax.cpp.

◆ GDI_ENGINE_VERSION

const unsigned GDI_ENGINE_VERSION = DDI_DRIVER_VERSION_NT5_01
static

Definition at line 4 of file ldevobj.h.

Referenced by InitLDEVImpl(), and LDEVOBJ_bEnableDriver().