ReactOS 0.4.16-dev-106-g10b08aa
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.

7{
12 LDEV_IMAGE = 5,
13 LDEV_FONT = 6,
14} LDEVTYPE;
LDEVTYPE
Definition: ldevobj.h:7
@ LDEV_IMAGE
Definition: ldevobj.h:12
@ LDEV_FONT
Definition: ldevobj.h:13
@ LDEV_DEVICE_PRINTER
Definition: ldevobj.h:9
@ LDEV_DEVICE_DISPLAY
Definition: ldevobj.h:8
@ LDEV_DEVICE_MIRROR
Definition: ldevobj.h:11
@ LDEV_DEVICE_META
Definition: ldevobj.h:10

Function Documentation

◆ DriverEntry()

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

Definition at line 1412 of file isapnp.c.

1415{
1416 DPRINT("%s(%p, %wZ)\n", __FUNCTION__, DriverObject, RegistryPath);
1417
1418 if (IsNEC_98)
1419 {
1422 }
1423
1424 DriverObject->MajorFunction[IRP_MJ_CREATE] = IsaCreateClose;
1425 DriverObject->MajorFunction[IRP_MJ_CLOSE] = IsaCreateClose;
1426 DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = IsaForwardOrIgnore;
1427 DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = IsaForwardOrIgnore;
1428 DriverObject->MajorFunction[IRP_MJ_PNP] = IsaPnp;
1429 DriverObject->MajorFunction[IRP_MJ_POWER] = IsaPower;
1430 DriverObject->DriverExtension->AddDevice = IsaAddDevice;
1431
1432 /* FIXME: Fix SDK headers */
1433#if 0
1435#endif
1436
1438 InitializeListHead(&BusListHead);
1439
1440 /* FIXME: Fix SDK headers */
1441#if 0
1443#endif
1444
1445 return STATUS_SUCCESS;
1446}
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
#define _No_competing_thread_begin_
#define _No_competing_thread_end_
#define TRUE
Definition: types.h:120
ULONG IsaConfigPorts[2]
Definition: hardware.c:23
#define __FUNCTION__
Definition: types.h:116
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
KEVENT BusSyncEvent
Definition: isapnp.c:21
#define ISAPNP_ADDRESS_PC98
Definition: isapnphw.h:19
#define ISAPNP_WRITE_DATA_PC98
Definition: isapnphw.h:20
@ SynchronizationEvent
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
#define IRP_MJ_SYSTEM_CONTROL
#define IRP_MJ_POWER
#define IsNEC_98
Definition: ketypes.h:911

◆ 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) +
50 if (!gpldevWin32k)
51 {
52 return STATUS_NO_MEMORY;
53 }
54
55 /* Initialize the LDEVOBJ for win32k */
63 L"\\SystemRoot\\System32\\win32k.sys");
69 TRUE,
71 &cbSize);
73
74 return STATUS_SUCCESS;
75}
#define ERR(fmt,...)
Definition: precomp.h:57
#define __ImageBase
Definition: crt_handler.c:22
#define NULL
Definition: types.h:112
#define IMAGE_DIRECTORY_ENTRY_EXPORT
Definition: compat.h:151
#define RtlImageDirectoryEntryToData
Definition: compat.h:809
DRIVER_INITIALIZE DriverEntry
Definition: condrv.c:21
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
HSEMAPHORE WINAPI EngCreateSemaphore(VOID)
Definition: eng.c:75
static LDEVOBJ * gpldevWin32k
Definition: ldevobj.c:22
static LIST_ENTRY gleLdevListHead
Definition: ldevobj.c:21
static HSEMAPHORE ghsemLDEVList
Definition: ldevobj.c:20
static const unsigned GDI_ENGINE_VERSION
Definition: ldevobj.h:4
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define L(x)
Definition: ntvdm.h:50
LIST_ENTRY leLink
Definition: ldevobj.h:18
SYSTEM_GDI_DRIVER_INFORMATION * pGdiDriverInfo
Definition: ldevobj.h:19
ULONG cRefs
Definition: ldevobj.h:21
ULONG ulDriverVersion
Definition: ldevobj.h:22
LDEVTYPE ldevtype
Definition: ldevobj.h:20
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
PIMAGE_EXPORT_DIRECTORY ExportSectionPointer
Definition: DriverTester.h:49
void * PVOID
Definition: typedefs.h:50
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define GDITAG_LDEV
Definition: tags.h:136

Referenced by DriverEntry().

◆ LDEVOBJ_bBuildDevmodeList()

BOOL LDEVOBJ_bBuildDevmodeList ( _Inout_ PGRAPHICS_DEVICE  pGraphicsDevice)

Definition at line 565 of file ldevobj.c.

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

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 737 of file ldevobj.c.

742{
743 DEVMODEW dmSearch;
744 PDEVMODEW pdmCurrent, pdm, pdmSelected = NULL;
745 ULONG i;
746 ULONG ulVirtualWidth = 0, ulVirtualHeight = 0;
747 BOOL bResult = TRUE;
749
750 if (!LDEVOBJ_bBuildDevmodeList(pGraphicsDevice))
751 return FALSE;
752
753 /* At first, load information from registry */
754 RtlZeroMemory(&dmSearch, sizeof(dmSearch));
755 Status = EngpGetDisplayDriverParameters(pGraphicsDevice, &dmSearch);
756 if (!NT_SUCCESS(Status))
757 {
758 ERR("EngpGetDisplayDriverParameters() failed with status 0x%08x\n", Status);
759 return FALSE;
760 }
761
762 /* Override values with the new ones provided */
763
765 {
766 bSearchClosestMode |= RequestedMode->dmFields == 0;
767
768 /* Copy standard fields (if provided) */
769 if (RequestedMode->dmFields & DM_BITSPERPEL && RequestedMode->dmBitsPerPel != 0)
770 dmSearch.dmBitsPerPel = RequestedMode->dmBitsPerPel;
771 if (RequestedMode->dmFields & DM_PELSWIDTH && RequestedMode->dmPelsWidth != 0)
772 dmSearch.dmPelsWidth = RequestedMode->dmPelsWidth;
773 if (RequestedMode->dmFields & DM_PELSHEIGHT && RequestedMode->dmPelsHeight != 0)
774 dmSearch.dmPelsHeight = RequestedMode->dmPelsHeight;
775 if (RequestedMode->dmFields & DM_DISPLAYFREQUENCY && RequestedMode->dmDisplayFrequency != 0)
776 dmSearch.dmDisplayFrequency = RequestedMode->dmDisplayFrequency;
777
778 if ((RequestedMode->dmFields & (DM_PANNINGWIDTH | DM_PANNINGHEIGHT)) == (DM_PANNINGWIDTH | DM_PANNINGHEIGHT) &&
779 RequestedMode->dmPanningWidth != 0 && RequestedMode->dmPanningHeight != 0 &&
780 RequestedMode->dmPanningWidth < dmSearch.dmPelsWidth &&
781 RequestedMode->dmPanningHeight < dmSearch.dmPelsHeight)
782 {
783 /* Get new panning values */
784 ulVirtualWidth = RequestedMode->dmPelsWidth;
785 ulVirtualHeight = RequestedMode->dmPelsHeight;
786 dmSearch.dmPelsWidth = RequestedMode->dmPanningWidth;
787 dmSearch.dmPelsHeight = RequestedMode->dmPanningHeight;
788 }
789 else if (dmSearch.dmPanningWidth != 0 && dmSearch.dmPanningHeight != 0 &&
790 dmSearch.dmPanningWidth < dmSearch.dmPelsWidth &&
791 dmSearch.dmPanningHeight < dmSearch.dmPelsHeight)
792 {
793 /* Keep existing panning values */
794 ulVirtualWidth = dmSearch.dmPelsWidth;
795 ulVirtualHeight = dmSearch.dmPelsHeight;
796 dmSearch.dmPelsWidth = dmSearch.dmPanningWidth;
797 dmSearch.dmPelsHeight = dmSearch.dmPanningHeight;
798 }
799 }
801 {
802 bResult = FALSE;
803 }
804 _SEH2_END;
805
806 if (!bResult)
807 return FALSE;
808
809 if (LDEVOBJ_bGetClosestMode(pGraphicsDevice, &dmSearch, &pdmSelected))
810 {
811 if (bSearchClosestMode)
812 {
813 /* Ok, found a closest mode. Update search */
814 dmSearch.dmBitsPerPel = pdmSelected->dmBitsPerPel;
815 dmSearch.dmPelsWidth = pdmSelected->dmPelsWidth;
816 dmSearch.dmPelsHeight = pdmSelected->dmPelsHeight;
817 dmSearch.dmDisplayFrequency = pdmSelected->dmDisplayFrequency;
818 }
819 else
820 {
821 /* Only update not provided fields */
823 {
824 if (!(RequestedMode->dmFields & DM_BITSPERPEL) || RequestedMode->dmBitsPerPel == 0)
825 dmSearch.dmBitsPerPel = pdmSelected->dmBitsPerPel;
826 if (!(RequestedMode->dmFields & DM_PELSWIDTH) || RequestedMode->dmPelsWidth == 0)
827 dmSearch.dmPelsWidth = pdmSelected->dmPelsWidth;
828 if (!(RequestedMode->dmFields & DM_PELSHEIGHT) || RequestedMode->dmPelsHeight == 0)
829 dmSearch.dmPelsHeight = pdmSelected->dmPelsHeight;
830 if (!(RequestedMode->dmFields & DM_DISPLAYFREQUENCY) || RequestedMode->dmDisplayFrequency == 0)
831 dmSearch.dmDisplayFrequency = pdmSelected->dmDisplayFrequency;
832 }
834 {
835 bResult = FALSE;
836 }
837 _SEH2_END;
838
839 if (!bResult)
840 return FALSE;
841 }
842 }
843
844 /* Now, search the exact mode to return to caller */
845 for (i = 0; i < pGraphicsDevice->cDevModes; i++)
846 {
847 pdmCurrent = pGraphicsDevice->pDevModeList[i].pdm;
848
849 /* For now, we only need those */
850 if (pdmCurrent->dmBitsPerPel != dmSearch.dmBitsPerPel)
851 continue;
852 if (pdmCurrent->dmPelsWidth != dmSearch.dmPelsWidth)
853 continue;
854 if (pdmCurrent->dmPelsHeight != dmSearch.dmPelsHeight)
855 continue;
856 if (pdmCurrent->dmDisplayFrequency != dmSearch.dmDisplayFrequency)
857 continue;
858
859 pdmSelected = pdmCurrent;
860 break;
861 }
862
863 if (!pdmSelected)
864 {
865 ERR("Requested mode not found (%dx%dx%d %d Hz)\n",
866 dmSearch.dmPelsWidth,
867 dmSearch.dmPelsHeight,
868 dmSearch.dmBitsPerPel,
869 dmSearch.dmDisplayFrequency);
870 return FALSE;
871 }
872
873 /* Allocate memory for output */
874 pdm = ExAllocatePoolZero(PagedPool, pdmSelected->dmSize + pdmSelected->dmDriverExtra, GDITAG_DEVMODE);
875 if (!pdm)
876 return FALSE;
877
878 /* Copy selected mode */
879 RtlCopyMemory(pdm, pdmSelected, pdmSelected->dmSize);
880 RtlCopyMemory((PVOID)((ULONG_PTR)pdm + pdm->dmSize),
881 (PVOID)((ULONG_PTR)pdmSelected + pdmSelected->dmSize),
882 pdmSelected->dmDriverExtra);
883
884 /* Add back panning */
885 if (ulVirtualWidth != 0 && ulVirtualHeight != 0 &&
886 pdm->dmPelsWidth < ulVirtualWidth &&
887 pdm->dmPelsHeight < ulVirtualHeight)
888 {
890 pdm->dmPanningWidth = pdm->dmPelsWidth;
891 pdm->dmPanningHeight = pdm->dmPelsHeight;
892 pdm->dmPelsWidth = ulVirtualWidth;
893 pdm->dmPelsHeight = ulVirtualHeight;
894 }
895
896 *pSelectedMode = pdm;
897 return TRUE;
898}
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
unsigned int BOOL
Definition: ntddk_ex.h:94
Status
Definition: gdiplustypes.h:25
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
BOOL LDEVOBJ_bBuildDevmodeList(_Inout_ PGRAPHICS_DEVICE pGraphicsDevice)
Definition: ldevobj.c:565
static BOOL LDEVOBJ_bGetClosestMode(_Inout_ PGRAPHICS_DEVICE pGraphicsDevice, _In_ PDEVMODEW RequestedMode, _Out_ PDEVMODEW *pSelectedMode)
Definition: ldevobj.c:678
FORCEINLINE PVOID ExAllocatePoolZero(ULONG PoolType, SIZE_T NumberOfBytes, ULONG Tag)
Definition: precomp.h:45
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
DWORD dmFields
Definition: wingdi.h:1622
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG_PTR
Definition: typedefs.h:65
NTSTATUS EngpGetDisplayDriverParameters(_In_ PGRAPHICS_DEVICE pGraphicsDevice, _Out_ PDEVMODEW pdm)
Definition: device.c:354
#define DM_DISPLAYFREQUENCY
Definition: wingdi.h:1272
#define DM_PELSWIDTH
Definition: wingdi.h:1269
#define DM_PANNINGHEIGHT
Definition: wingdi.h:1278
#define DM_BITSPERPEL
Definition: wingdi.h:1268
#define DM_PELSHEIGHT
Definition: wingdi.h:1270
#define DM_PANNINGWIDTH
Definition: wingdi.h:1277

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 insensitive) */
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 */
441 {
442 ERR("LDEVOBJ_bEnableDriver failed\n");
443
444 /* Unload the image. */
445 if (LDEVOBJ_bUnloadImage(pldev))
446 LDEVOBJ_vFreeLDEV(pldev);
447 else
448 ERR("Could not unload driver. Leaking memory\n");
449 pldev = NULL;
450 goto leave;
451 }
452
453 /* Insert the LDEV into the global list */
455 }
456
457 /* Increase ref count */
458 pldev->cRefs++;
459
460leave:
461 /* Unlock loader */
463
464 TRACE("LDEVOBJ_pLoadDriver returning %p\n", pldev);
465 return pldev;
466}
#define leave
Definition: btrfs_drv.h:138
#define MAX_PATH
Definition: compat.h:34
#define InsertHeadList(ListHead, Entry)
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
VOID WINAPI EngReleaseSemaphore(IN HSEMAPHORE hsem)
Definition: eng.c:235
static BOOL LDEVOBJ_bLoadImage(_Inout_ PLDEVOBJ pldev, _In_ PUNICODE_STRING pustrPathName)
Definition: ldevobj.c:116
static PLDEVOBJ LDEVOBJ_AllocLDEV(_In_ LDEVTYPE ldevtype)
Definition: ldevobj.c:79
static VOID LDEVOBJ_vFreeLDEV(_In_ _Post_ptr_invalid_ PLDEVOBJ pldev)
Definition: ldevobj.c:103
static BOOL LDEVOBJ_bUnloadImage(_Inout_ PLDEVOBJ pldev)
Definition: ldevobj.c:269
static BOOL LDEVOBJ_bEnableDriver(_Inout_ PLDEVOBJ pldev, _In_ PFN_DrvEnableDriver pfnEnableDriver)
Definition: ldevobj.c:165
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
_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)
Definition: typedefs.h:120
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
ENGAPI VOID APIENTRY EngAcquireSemaphore(_Inout_ HSEMAPHORE hsem)
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

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
337leave:
338 /* Unlock loader */
340
341 TRACE("LDEVOBJ_pLoadInternal returning %p\n", pldev);
342 return pldev;
343}

Referenced by PDEVOBJ_Create().

◆ LDEVOBJ_ulGetDriverModes()

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

Definition at line 511 of file ldevobj.c.

515{
516 PLDEVOBJ pldev = NULL;
517 ULONG cbSize = 0;
518 PDEVMODEW pdm = NULL;
519
520 TRACE("LDEVOBJ_ulGetDriverModes('%ls', %p)\n", pwszDriverName, hDriver);
521
522 pldev = LDEVOBJ_pLoadDriver(pwszDriverName, LDEV_DEVICE_DISPLAY);
523 if (!pldev)
524 goto cleanup;
525
526 /* Mirror drivers may omit this function */
527 if (!pldev->pfn.GetModes)
528 goto cleanup;
529
530 /* Call the driver to get the required size */
531 cbSize = pldev->pfn.GetModes(hDriver, 0, NULL);
532 if (!cbSize)
533 {
534 ERR("DrvGetModes returned 0\n");
535 goto cleanup;
536 }
537
538 /* Allocate a buffer for the DEVMODE array */
540 if (!pdm)
541 {
542 ERR("Could not allocate devmodeinfo\n");
543 goto cleanup;
544 }
545
546 /* Call the driver again to fill the buffer */
547 cbSize = pldev->pfn.GetModes(hDriver, cbSize, pdm);
548 if (!cbSize)
549 {
550 /* Could not get modes */
551 ERR("DrvrGetModes returned 0 on second call\n");
553 pdm = NULL;
554 }
555
556cleanup:
557 if (pldev)
559
560 *ppdm = pdm;
561 return cbSize;
562}
static void cleanup(void)
Definition: main.c:1335
static VOID LDEVOBJ_vDereference(_Inout_ PLDEVOBJ pldev)
Definition: ldevobj.c:470
PLDEVOBJ NTAPI LDEVOBJ_pLoadDriver(_In_z_ LPWSTR pwszDriverName, _In_ ULONG ldevtype)
Definition: ldevobj.c:347
PFN_DrvGetModes GetModes
Definition: ntgdityp.h:610
DRIVER_FUNCTIONS pfn
Definition: ldevobj.h:27
_In_ LPWSTR _In_ ULONG _In_ ULONG _In_ ULONG _Out_ DEVINFO _In_ HDEV _In_ LPWSTR _In_ HANDLE hDriver
Definition: winddi.h:3557

Referenced by LDEVOBJ_bBuildDevmodeList().

Variable Documentation

◆ __ImageBase

IMAGE_DOS_HEADER __ImageBase
extern

◆ 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().