ReactOS  0.4.14-dev-1332-g6db3d88
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

INIT_FUNCTION NTSTATUS NTAPI InitLDEVImpl (VOID)
 
PDEVMODEINFO NTAPI LDEVOBJ_pdmiGetModes (_In_ PLDEVOBJ pldev, _In_ HANDLE hDriver)
 
PLDEVOBJ APIENTRY EngLoadImageEx (_In_z_ LPWSTR pwszDriverName, _In_ ULONG ldevtype)
 
PLDEVOBJ NTAPI EngGetLDEV (PDEVMODEW pdm)
 
INIT_FUNCTION 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()

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

Definition at line 25 of file ksecdd.c.

28 {
29  UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\Device\\KsecDD");
31 
32  /* Create the KsecDD device */
34  0,
35  &DeviceName,
37  0x100u,
38  FALSE,
40  if (!NT_SUCCESS(Status))
41  {
42  DPRINT1("Failed to create KsecDD device: 0x%lx\n", Status);
43  return Status;
44  }
45 
46  /* Set up dispatch table */
54 
55  /* Initialize */
57 
58  return STATUS_SUCCESS;
59 }
#define FILE_DEVICE_KSEC
Definition: winioctl.h:162
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
LONG NTSTATUS
Definition: precomp.h:26
WCHAR DeviceName[]
Definition: adapter.cpp:21
PDEVICE_OBJECT KsecDeviceObject
Definition: ksecdd.c:18
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
#define IRP_MJ_QUERY_VOLUME_INFORMATION
Definition: rdpdr.c:50
VOID NTAPI KsecInitializeEncryptionSupport(VOID)
Definition: crypt.c:32
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI KsecDdDispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: dispatch.c:184
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
#define DPRINT1
Definition: precomp.h:8
#define IRP_MJ_READ
Definition: rdpdr.c:46
PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION+1]
Definition: iotypes.h:2181
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define IRP_MJ_QUERY_INFORMATION
Definition: rdpdr.c:48
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

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

◆ EngGetLDEV()

PLDEVOBJ NTAPI EngGetLDEV ( PDEVMODEW  pdm)

◆ EngLoadImageEx()

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

Definition at line 328 of file ldevobj.c.

331 {
332  WCHAR acwBuffer[MAX_PATH];
333  PLIST_ENTRY pleLink;
334  PLDEVOBJ pldev;
335  UNICODE_STRING strDriverName;
336  SIZE_T cwcLength;
337  LPWSTR pwsz;
338 
339  TRACE("EngLoadImageEx(%ls, %lu)\n", pwszDriverName, ldevtype);
340  ASSERT(pwszDriverName);
341 
342  /* Initialize buffer for the the driver name */
343  RtlInitEmptyUnicodeString(&strDriverName, acwBuffer, sizeof(acwBuffer));
344 
345  /* Start path with systemroot */
346  RtlAppendUnicodeToString(&strDriverName, L"\\SystemRoot\\System32\\");
347 
348  /* Get Length of given string */
349  cwcLength = wcslen(pwszDriverName);
350 
351  /* Check if we have a system32 path given */
352  pwsz = pwszDriverName + cwcLength;
353  while (pwsz > pwszDriverName)
354  {
355  if ((*pwsz == L'\\') && (_wcsnicmp(pwsz, L"\\system32\\", 10) == 0))
356  {
357  /* Driver name starts after system32 */
358  pwsz += 10;
359  break;
360  }
361  pwsz--;
362  }
363 
364  /* Append the driver name */
365  RtlAppendUnicodeToString(&strDriverName, pwsz);
366 
367  /* MSDN says "The driver must include this suffix in the pwszDriver string."
368  But in fact it's optional. The function can also load .sys files without
369  appending the .dll extension. */
370  if ((cwcLength < 4) ||
371  ((_wcsnicmp(pwszDriverName + cwcLength - 4, L".dll", 4) != 0) &&
372  (_wcsnicmp(pwszDriverName + cwcLength - 4, L".sys", 4) != 0)) )
373  {
374  /* Append the .dll suffix */
375  RtlAppendUnicodeToString(&strDriverName, L".dll");
376  }
377 
378  /* Lock loader */
380 
381  /* Search the List of LDEVS for the driver name */
382  for (pleLink = gleLdevListHead.Flink;
383  pleLink != &gleLdevListHead;
384  pleLink = pleLink->Flink)
385  {
386  pldev = CONTAINING_RECORD(pleLink, LDEVOBJ, leLink);
387 
388  /* Check if the ldev is associated with a file */
389  if (pldev->pGdiDriverInfo)
390  {
391  /* Check for match (case insensative) */
392  if (RtlEqualUnicodeString(&pldev->pGdiDriverInfo->DriverName, &strDriverName, TRUE))
393  {
394  /* Image found in LDEV list */
395  break;
396  }
397  }
398  }
399 
400  /* Did we find one? */
401  if (pleLink == &gleLdevListHead)
402  {
403  /* No, allocate a new LDEVOBJ */
404  pldev = LDEVOBJ_AllocLDEV(ldevtype);
405  if (!pldev)
406  {
407  ERR("Could not allocate LDEV\n");
408  goto leave;
409  }
410 
411  /* Load the image */
412  if (!LDEVOBJ_bLoadImage(pldev, &strDriverName))
413  {
414  LDEVOBJ_vFreeLDEV(pldev);
415  pldev = NULL;
416  ERR("LDEVOBJ_bLoadImage failed\n");
417  goto leave;
418  }
419 
420  /* Shall we load a driver? */
421  if (ldevtype != LDEV_IMAGE)
422  {
423  /* Load the driver */
424  if (!LDEVOBJ_bEnableDriver(pldev))
425  {
426  ERR("LDEVOBJ_bEnableDriver failed\n");
427 
428  /* Unload the image. */
429  LDEVOBJ_vUnloadImage(pldev);
430  LDEVOBJ_vFreeLDEV(pldev);
431  pldev = NULL;
432  goto leave;
433  }
434  }
435 
436  /* Insert the LDEV into the global list */
438  }
439 
440  /* Increase ref count */
441  pldev->cRefs++;
442 
443 leave:
444  /* Unlock loader */
446 
447  TRACE("EngLoadImageEx returning %p\n", pldev);
448  return pldev;
449 }
VOID WINAPI EngReleaseSemaphore(IN HSEMAPHORE hsem)
Definition: eng.c:235
#define TRUE
Definition: types.h:120
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 BOOL LDEVOBJ_bEnableDriver(_Inout_ PLDEVOBJ pldev)
Definition: ldevobj.c:248
_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)
static HSEMAPHORE ghsemLDEVList
Definition: ldevobj.c:20
static VOID LDEVOBJ_vUnloadImage(_Inout_ PLDEVOBJ pldev)
Definition: ldevobj.c:217
ENGAPI VOID APIENTRY EngAcquireSemaphore(_Inout_ HSEMAPHORE hsem)
smooth NULL
Definition: ftsmooth.c:416
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:120
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
static PLDEVOBJ LDEVOBJ_AllocLDEV(_In_ LDEVTYPE ldevtype)
Definition: ldevobj.c:79
#define MAX_PATH
Definition: compat.h:26
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static const WCHAR L[]
Definition: oid.c:1250
Definition: typedefs.h:118
#define ERR(fmt,...)
Definition: debug.h:109
ULONG_PTR SIZE_T
Definition: typedefs.h:79
static BOOL LDEVOBJ_bLoadImage(_Inout_ PLDEVOBJ pldev, _In_ PUNICODE_STRING pustrPathName)
Definition: ldevobj.c:168
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)
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
ULONG cRefs
Definition: ldevobj.h:21

Referenced by EngLoadImage(), EngpCreatePDEV(), and EngpPopulateDeviceModeList().

◆ InitLDEVImpl()

INIT_FUNCTION 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:135
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
struct _LIST_ENTRY * Blink
Definition: typedefs.h:121
static HSEMAPHORE ghsemLDEVList
Definition: ldevobj.c:20
static const unsigned GDI_ENGINE_VERSION
Definition: ldevobj.h:4
smooth NULL
Definition: ftsmooth.c:416
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:120
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
static const WCHAR L[]
Definition: oid.c:1250
#define RtlImageDirectoryEntryToData
Definition: compat.h:468
#define IMAGE_DIRECTORY_ENTRY_EXPORT
Definition: compat.h:140
#define ERR(fmt,...)
Definition: debug.h:109
DRIVER_INITIALIZE DriverEntry
Definition: condrv.c:21
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
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 __ImageBase
Definition: crt_handler.c:22
return STATUS_SUCCESS
Definition: btrfs.c:2938
PIMAGE_EXPORT_DIRECTORY ExportSectionPointer
Definition: DriverTester.h:49
ULONG cRefs
Definition: ldevobj.h:21

Referenced by DriverEntry().

◆ LDEVOBJ_pdmiGetModes()

PDEVMODEINFO NTAPI LDEVOBJ_pdmiGetModes ( _In_ PLDEVOBJ  pldev,
_In_ HANDLE  hDriver 
)

Definition at line 116 of file ldevobj.c.

119 {
120  ULONG cbSize, cbFull;
121  PDEVMODEINFO pdminfo;
122 
123  TRACE("LDEVOBJ_pdmiGetModes(%p, %p)\n", pldev, hDriver);
124 
125  /* Mirror drivers may omit this function */
126  if (!pldev->pfn.GetModes)
127  {
128  return NULL;
129  }
130 
131  /* Call the driver to get the required size */
132  cbSize = pldev->pfn.GetModes(hDriver, 0, NULL);
133  if (!cbSize)
134  {
135  ERR("DrvGetModes returned 0\n");
136  return NULL;
137  }
138 
139  /* Add space for the header */
140  cbFull = cbSize + FIELD_OFFSET(DEVMODEINFO, adevmode);
141 
142  /* Allocate a buffer for the DEVMODE array */
143  pdminfo = ExAllocatePoolWithTag(PagedPool, cbFull, GDITAG_DEVMODE);
144  if (!pdminfo)
145  {
146  ERR("Could not allocate devmodeinfo\n");
147  return NULL;
148  }
149 
150  pdminfo->pldev = pldev;
151  pdminfo->cbdevmode = cbSize;
152 
153  /* Call the driver again to fill the buffer */
154  cbSize = pldev->pfn.GetModes(hDriver, cbSize, pdminfo->adevmode);
155  if (!cbSize)
156  {
157  /* Could not get modes */
158  ERR("returned size %lu(%lu)\n", cbSize, pdminfo->cbdevmode);
160  pdminfo = NULL;
161  }
162 
163  return pdminfo;
164 }
#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
ULONG cbdevmode
Definition: pdevobj.h:46
smooth NULL
Definition: ftsmooth.c:416
DEVMODEW adevmode[1]
Definition: pdevobj.h:47
#define TRACE(s)
Definition: solgame.cpp:4
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define ERR(fmt,...)
Definition: debug.h:109
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
unsigned int ULONG
Definition: retypes.h:1
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
struct _LDEVOBJ * pldev
Definition: pdevobj.h:45

Referenced by EngpPopulateDeviceModeList().

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