ReactOS  0.4.13-dev-464-g6b95727
videoprt.h File Reference
#include <ntifs.h>
#include <miniport.h>
#include <video.h>
#include <ntagp.h>
#include <dderror.h>
#include <windef.h>
#include <wdmguid.h>
Include dependency graph for videoprt.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _VIDEO_PORT_ADDRESS_MAPPING
 
struct  _VIDEO_PORT_AGP_MAPPING
 
struct  _VIDEO_PORT_AGP_VIRTUAL_MAPPING
 
struct  _VIDEO_PORT_DRIVER_EXTENSION
 
struct  _VIDEO_PORT_COMMON_EXTENSION
 
struct  _VIDEO_PORT_DEVICE_EXTENSTION
 
struct  _VIDEO_PORT_CHILD_EXTENSION
 
struct  _VIDEO_PORT_EVENT
 

Macros

#define __BROKEN__
 
#define TAG_VIDEO_PORT   'PDIV'
 
#define TAG_VIDEO_PORT_BUFFER   '\0mpV'
 
#define TAG_REQUEST_PACKET   'qRpV'
 
#define GUID_STRING_LENGTH   38 * sizeof(WCHAR)
 
#define VIDEO_PORT_GET_CHILD_EXTENSION(MiniportExtension)
 
#define VIDEO_PORT_GET_DEVICE_EXTENSION(MiniportExtension)
 

Typedefs

typedef struct _VIDEO_PORT_ADDRESS_MAPPING VIDEO_PORT_ADDRESS_MAPPING
 
typedef struct _VIDEO_PORT_ADDRESS_MAPPINGPVIDEO_PORT_ADDRESS_MAPPING
 
typedef struct _VIDEO_PORT_AGP_MAPPING VIDEO_PORT_AGP_MAPPING
 
typedef struct _VIDEO_PORT_AGP_MAPPINGPVIDEO_PORT_AGP_MAPPING
 
typedef struct _VIDEO_PORT_AGP_VIRTUAL_MAPPING VIDEO_PORT_AGP_VIRTUAL_MAPPING
 
typedef struct _VIDEO_PORT_AGP_VIRTUAL_MAPPINGPVIDEO_PORT_AGP_VIRTUAL_MAPPING
 
typedef struct _VIDEO_PORT_DRIVER_EXTENSION VIDEO_PORT_DRIVER_EXTENSION
 
typedef struct _VIDEO_PORT_DRIVER_EXTENSIONPVIDEO_PORT_DRIVER_EXTENSION
 
typedef struct _VIDEO_PORT_COMMON_EXTENSION VIDEO_PORT_COMMON_EXTENSION
 
typedef struct _VIDEO_PORT_COMMON_EXTENSIONPVIDEO_PORT_COMMON_EXTENSION
 
typedef struct _VIDEO_PORT_DEVICE_EXTENSTION VIDEO_PORT_DEVICE_EXTENSION
 
typedef struct _VIDEO_PORT_DEVICE_EXTENSTIONPVIDEO_PORT_DEVICE_EXTENSION
 
typedef struct _VIDEO_PORT_CHILD_EXTENSION VIDEO_PORT_CHILD_EXTENSION
 
typedef struct _VIDEO_PORT_CHILD_EXTENSIONPVIDEO_PORT_CHILD_EXTENSION
 
typedef struct _VIDEO_PORT_EVENT VIDEO_PORT_EVENT
 
typedef struct _VIDEO_PORT_EVENTPVIDEO_PORT_EVENT
 

Functions

NTSTATUS IopInitiatePnpIrp (PDEVICE_OBJECT DeviceObject, PIO_STATUS_BLOCK IoStatusBlock, UCHAR MinorFunction, PIO_STACK_LOCATION Stack OPTIONAL)
 
NTSTATUS NTAPI IntAgpGetInterface (IN PVOID HwDeviceExtension, IN OUT PINTERFACE Interface)
 
NTSTATUS NTAPI IntVideoPortDispatchPdoPnp (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI IntVideoPortAddDevice (IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PhysicalDeviceObject)
 
NTSTATUS NTAPI IntVideoPortDispatchOpen (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI IntVideoPortDispatchClose (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI IntVideoPortDispatchCleanup (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI IntVideoPortDispatchDeviceControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI IntVideoPortDispatchPnp (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI IntVideoPortDispatchPower (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI IntVideoPortDispatchSystemControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI IntVideoPortDispatchWrite (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
VOID NTAPI IntVideoPortUnload (PDRIVER_OBJECT DriverObject)
 
BOOLEAN NTAPI IntVideoPortSetupTimer (IN PDEVICE_OBJECT DeviceObject, IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension)
 
BOOLEAN NTAPI IntVideoPortSetupInterrupt (IN PDEVICE_OBJECT DeviceObject, IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, IN PVIDEO_PORT_CONFIG_INFO ConfigInfo)
 
NTSTATUS NTAPI IntVideoPortFilterResourceRequirements (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI IntVideoPortMapPhysicalMemory (IN HANDLE Process, IN PHYSICAL_ADDRESS PhysicalAddress, IN ULONG SizeInBytes, IN ULONG Protect, IN OUT PVOID *VirtualAddress OPTIONAL)
 
VOID FASTCALL IntAttachToCSRSS (PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
 
VOID FASTCALL IntDetachFromCSRSS (PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
 
NTSTATUS NTAPI IntVideoPortCreateAdapterDeviceObject (IN PDRIVER_OBJECT DriverObject, IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, OUT PDEVICE_OBJECT *DeviceObject OPTIONAL)
 
NTSTATUS NTAPI IntVideoPortFindAdapter (IN PDRIVER_OBJECT DriverObject, IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, IN PDEVICE_OBJECT DeviceObject)
 
PVOID NTAPI IntVideoPortGetProcAddress (IN PVOID HwDeviceExtension, IN PUCHAR FunctionName)
 
NTSTATUS NTAPI IntInitializeVideoAddressSpace (VOID)
 
VP_STATUS NTAPI IntInt10AllocateBuffer (IN PVOID Context, OUT PUSHORT Seg, OUT PUSHORT Off, IN OUT PULONG Length)
 
VP_STATUS NTAPI IntInt10FreeBuffer (IN PVOID Context, IN USHORT Seg, IN USHORT Off)
 
VP_STATUS NTAPI IntInt10ReadMemory (IN PVOID Context, IN USHORT Seg, IN USHORT Off, OUT PVOID Buffer, IN ULONG Length)
 
VP_STATUS NTAPI IntInt10WriteMemory (IN PVOID Context, IN USHORT Seg, IN USHORT Off, IN PVOID Buffer, IN ULONG Length)
 
VP_STATUS NTAPI IntInt10CallBios (IN PVOID Context, IN OUT PINT10_BIOS_ARGUMENTS BiosArguments)
 
NTSTATUS NTAPI IntCopyRegistryKey (_In_ HANDLE SourceKeyHandle, _In_ HANDLE DestKeyHandle)
 
NTSTATUS NTAPI IntCopyRegistryValue (HANDLE SourceKeyHandle, HANDLE DestKeyHandle, PWSTR ValueName)
 
NTSTATUS NTAPI IntSetupDeviceSettingsKey (PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI IntCreateNewRegistryPath (PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI IntCreateRegistryPath (IN PCUNICODE_STRING DriverRegistryPath, OUT PUNICODE_STRING DeviceRegistryPath)
 

Variables

ULONG CsrssInitialized
 
PKPROCESS Csrss
 
ULONG VideoPortDeviceNumber
 
KMUTEX VideoPortInt10Mutex
 

Macro Definition Documentation

◆ __BROKEN__

#define __BROKEN__

Definition at line 27 of file videoprt.h.

◆ GUID_STRING_LENGTH

#define GUID_STRING_LENGTH   38 * sizeof(WCHAR)

Definition at line 39 of file videoprt.h.

◆ TAG_REQUEST_PACKET

#define TAG_REQUEST_PACKET   'qRpV'

Definition at line 37 of file videoprt.h.

◆ TAG_VIDEO_PORT

#define TAG_VIDEO_PORT   'PDIV'

Definition at line 35 of file videoprt.h.

◆ TAG_VIDEO_PORT_BUFFER

#define TAG_VIDEO_PORT_BUFFER   '\0mpV'

Definition at line 36 of file videoprt.h.

◆ VIDEO_PORT_GET_CHILD_EXTENSION

#define VIDEO_PORT_GET_CHILD_EXTENSION (   MiniportExtension)
Value:
MiniportExtension, \
ChildDeviceExtension)
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

Definition at line 127 of file videoprt.h.

◆ VIDEO_PORT_GET_DEVICE_EXTENSION

#define VIDEO_PORT_GET_DEVICE_EXTENSION (   MiniportExtension)
Value:
MiniportExtension, \
MiniPortDeviceExtension)
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

Definition at line 133 of file videoprt.h.

Typedef Documentation

◆ PVIDEO_PORT_ADDRESS_MAPPING

◆ PVIDEO_PORT_AGP_MAPPING

◆ PVIDEO_PORT_AGP_VIRTUAL_MAPPING

◆ PVIDEO_PORT_CHILD_EXTENSION

◆ PVIDEO_PORT_COMMON_EXTENSION

◆ PVIDEO_PORT_DEVICE_EXTENSION

◆ PVIDEO_PORT_DRIVER_EXTENSION

◆ PVIDEO_PORT_EVENT

◆ VIDEO_PORT_ADDRESS_MAPPING

◆ VIDEO_PORT_AGP_MAPPING

◆ VIDEO_PORT_AGP_VIRTUAL_MAPPING

◆ VIDEO_PORT_CHILD_EXTENSION

◆ VIDEO_PORT_COMMON_EXTENSION

◆ VIDEO_PORT_DEVICE_EXTENSION

◆ VIDEO_PORT_DRIVER_EXTENSION

◆ VIDEO_PORT_EVENT

Function Documentation

◆ IntAgpGetInterface()

NTSTATUS NTAPI IntAgpGetInterface ( IN PVOID  HwDeviceExtension,
IN OUT PINTERFACE  Interface 
)

Definition at line 496 of file agp.c.

499 {
501  IO_STACK_LOCATION IoStack;
503  PVIDEO_PORT_AGP_INTERFACE_2 AgpInterface;
504  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
505  PAGP_BUS_INTERFACE_STANDARD AgpBusInterface;
506 
507  DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
508  AgpBusInterface = &DeviceExtension->AgpInterface;
509  AgpInterface = (PVIDEO_PORT_AGP_INTERFACE_2)Interface;
510 
514  {
515  ASSERT(Interface->Size >= sizeof(VIDEO_PORT_AGP_INTERFACE_2));
516  }
517  else if (Interface->Version == VIDEO_PORT_AGP_INTERFACE_VERSION_1)
518  {
519  ASSERT(Interface->Size >= sizeof(VIDEO_PORT_AGP_INTERFACE));
520  }
521 
522  if (DeviceExtension->NextDeviceObject == NULL)
523  {
524  WARN_(VIDEOPRT, "DeviceExtension->NextDeviceObject is NULL!\n");
525  return STATUS_UNSUCCESSFUL;
526  }
527 
528  /* Query the interface from the AGP bus driver */
529  if (DeviceExtension->AgpInterface.Size == 0)
530  {
531  AgpBusInterface->Size = sizeof(AGP_BUS_INTERFACE_STANDARD);
533  AgpBusInterface->Version = AGP_BUS_INTERFACE_V1;
534  else /* if (InterfaceVersion == VIDEO_PORT_AGP_INTERFACE_VERSION_2) */
535  AgpBusInterface->Version = AGP_BUS_INTERFACE_V2;
536  IoStack.Parameters.QueryInterface.Size = AgpBusInterface->Size;
537  IoStack.Parameters.QueryInterface.Version = AgpBusInterface->Version;
538  IoStack.Parameters.QueryInterface.Interface = (PINTERFACE)AgpBusInterface;
539  IoStack.Parameters.QueryInterface.InterfaceType =
540  &GUID_AGP_TARGET_BUS_INTERFACE_STANDARD;
541  Status = IopInitiatePnpIrp(DeviceExtension->NextDeviceObject,
543  if (!NT_SUCCESS(Status))
544  {
545  WARN_(VIDEOPRT, "IopInitiatePnpIrp() failed! (Status 0x%x)\n", Status);
546  return Status;
547  }
548  INFO_(VIDEOPRT, "Got AGP driver interface!\n");
549  }
550 
551  /* FIXME: Not sure if we should wrap the reference/dereference functions */
552  AgpInterface->Context = AgpBusInterface->AgpContext;
553  AgpInterface->InterfaceReference = AgpBusInterface->InterfaceReference;
554  AgpInterface->InterfaceDereference = AgpBusInterface->InterfaceDereference;
557  AgpInterface->AgpCommitPhysical = IntAgpCommitPhysical;
558  AgpInterface->AgpFreePhysical = IntAgpFreePhysical;
559  AgpInterface->AgpReserveVirtual = IntAgpReserveVirtual;
560  AgpInterface->AgpReleaseVirtual = IntAgpReleaseVirtual;
561  AgpInterface->AgpCommitVirtual = IntAgpCommitVirtual;
562  AgpInterface->AgpFreeVirtual = IntAgpFreeVirtual;
563  AgpInterface->AgpAllocationLimit = 0x1000000; /* FIXME: using 16 MB for now */
564 
565  if (AgpInterface->Version >= VIDEO_PORT_AGP_INTERFACE_VERSION_2)
566  {
567  AgpInterface->AgpSetRate = IntAgpSetRate;
568  }
569 
570  return STATUS_SUCCESS;
571 }
OUT ULONGLONG AgpAllocationLimit
Definition: video.h:744
#define INFO_(ch,...)
Definition: debug.h:159
PHYSICAL_ADDRESS NTAPI IntAgpReservePhysical(IN PVOID HwDeviceExtension, IN ULONG Pages, IN VIDEO_PORT_CACHE_TYPE Caching, OUT PVOID *PhysicalContext)
Definition: agp.c:183
PINTERFACE_DEREFERENCE InterfaceDereference
Definition: ntagp.h:184
OUT PAGP_FREE_PHYSICAL AgpFreePhysical
Definition: video.h:739
VOID NTAPI IntAgpFreePhysical(IN PVOID HwDeviceExtension, IN PVOID PhysicalContext, IN ULONG Pages, IN ULONG Offset)
Definition: agp.c:126
PVOID NTAPI IntAgpCommitVirtual(IN PVOID HwDeviceExtension, IN PVOID VirtualContext, IN ULONG Pages, IN ULONG Offset)
Definition: agp.c:248
OUT PAGP_FREE_VIRTUAL AgpFreeVirtual
Definition: video.h:743
#define AGP_BUS_INTERFACE_V1
Definition: ntagp.h:31
LONG NTSTATUS
Definition: precomp.h:26
OUT PAGP_SET_RATE AgpSetRate
Definition: video.h:745
#define VIDEO_PORT_GET_DEVICE_EXTENSION(MiniportExtension)
Definition: videoprt.h:133
AGP_BUS_INTERFACE_STANDARD AgpInterface
Definition: videoprt.h:102
BOOLEAN NTAPI IntAgpSetRate(IN PVOID HwDeviceExtension, IN ULONG Rate)
Definition: agp.c:479
#define AGP_BUS_INTERFACE_V2
Definition: ntagp.h:32
OUT PAGP_RELEASE_PHYSICAL AgpReleasePhysical
Definition: video.h:737
OUT PAGP_COMMIT_VIRTUAL AgpCommitVirtual
Definition: video.h:742
NTSTATUS IopInitiatePnpIrp(PDEVICE_OBJECT DeviceObject, PIO_STATUS_BLOCK IoStatusBlock, UCHAR MinorFunction, PIO_STACK_LOCATION Stack OPTIONAL)
Definition: agp.c:30
smooth NULL
Definition: ftsmooth.c:416
PINTERFACE_REFERENCE InterfaceReference
Definition: ntagp.h:183
struct _INTERFACE * PINTERFACE
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:359
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
OUT PAGP_COMMIT_PHYSICAL AgpCommitPhysical
Definition: video.h:738
#define VIDEO_PORT_AGP_INTERFACE_VERSION_2
Definition: video.h:124
#define VIDEO_PORT_AGP_INTERFACE_VERSION_1
Definition: video.h:123
#define IRP_MN_QUERY_INTERFACE
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
PDEVICE_OBJECT NextDeviceObject
Definition: videoprt.h:86
BOOLEAN NTAPI IntAgpCommitPhysical(IN PVOID HwDeviceExtension, IN PVOID PhysicalContext, IN ULONG Pages, IN ULONG Offset)
Definition: agp.c:94
OUT PINTERFACE_REFERENCE InterfaceReference
Definition: video.h:734
Status
Definition: gdiplustypes.h:24
OUT PAGP_RELEASE_VIRTUAL AgpReleaseVirtual
Definition: video.h:741
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
OUT PAGP_RESERVE_VIRTUAL AgpReserveVirtual
Definition: video.h:740
VOID NTAPI IntAgpReleaseVirtual(IN PVOID HwDeviceExtension, IN PVOID VirtualContext)
Definition: agp.c:385
OUT PINTERFACE_DEREFERENCE InterfaceDereference
Definition: video.h:735
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
VOID NTAPI IntAgpFreeVirtual(IN PVOID HwDeviceExtension, IN PVOID VirtualContext, IN ULONG Pages, IN ULONG Offset)
Definition: agp.c:331
OUT PAGP_RESERVE_PHYSICAL AgpReservePhysical
Definition: video.h:736
struct _AGP_BUS_INTERFACE_STANDARD AGP_BUS_INTERFACE_STANDARD
struct _VIDEO_PORT_AGP_INTERFACE_2 * PVIDEO_PORT_AGP_INTERFACE_2
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
PVOID NTAPI IntAgpReserveVirtual(IN PVOID HwDeviceExtension, IN HANDLE ProcessHandle, IN PVOID PhysicalContext, OUT PVOID *VirtualContext)
Definition: agp.c:419
return STATUS_SUCCESS
Definition: btrfs.c:2777
VOID NTAPI IntAgpReleasePhysical(IN PVOID HwDeviceExtension, IN PVOID PhysicalContext)
Definition: agp.c:154
#define WARN_(ch,...)
Definition: debug.h:157

Referenced by VideoPortQueryServices().

◆ IntAttachToCSRSS()

VOID FASTCALL IntAttachToCSRSS ( PKPROCESS CallingProcess,
PKAPC_STATE  ApcState 
)

Definition at line 425 of file videoprt.c.

428 {
429  *CallingProcess = (PKPROCESS)PsGetCurrentProcess();
430  if (*CallingProcess != Csrss)
431  {
433  }
434 }
VOID NTAPI KeStackAttachProcess(IN PKPROCESS Process, OUT PRKAPC_STATE ApcState)
Definition: procobj.c:701
#define PsGetCurrentProcess
Definition: psfuncs.h:17
PKPROCESS Csrss
Definition: videoprt.c:34
struct _KPROCESS * PKPROCESS
Definition: wdm.template.h:199
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1484

Referenced by VideoPortGetRomImage(), and VideoPortInt10().

◆ IntCopyRegistryKey()

NTSTATUS NTAPI IntCopyRegistryKey ( _In_ HANDLE  SourceKeyHandle,
_In_ HANDLE  DestKeyHandle 
)

Definition at line 31 of file registry.c.

34 {
35  PVOID InfoBuffer;
36  PKEY_BASIC_INFORMATION KeyInformation;
37  PKEY_VALUE_FULL_INFORMATION KeyValueInformation;
39  ULONG Index, InformationLength, RequiredLength;
40  UNICODE_STRING NameString;
42  HANDLE SourceSubKeyHandle, DestSubKeyHandle;
43 
44  /* Start with no buffer, set initial size */
45  InfoBuffer = NULL;
46  InformationLength = 256;
47 
48  /* Start looping with key index 0 */
49  Index = 0;
50  while (TRUE)
51  {
52  /* Check if we have no buffer */
53  if (InfoBuffer == NULL)
54  {
55  /* Allocate a new buffer */
56  InfoBuffer = ExAllocatePoolWithTag(PagedPool,
57  InformationLength,
59  if (InfoBuffer == NULL)
60  {
61  ERR_(VIDEOPRT, "Could not allocate buffer for key info\n");
63  }
64  }
65 
66  /* Enumerate the next sub-key */
67  KeyInformation = InfoBuffer;
68  Status = ZwEnumerateKey(SourceKeyHandle,
69  Index,
71  KeyInformation,
72  InformationLength,
74  if ((Status == STATUS_BUFFER_OVERFLOW) ||
76  {
77  /* Free the buffer and remember the required size */
79  InfoBuffer = NULL;
80  InformationLength = RequiredLength;
81 
82  /* Try again */
83  continue;
84  }
85  else if (Status == STATUS_NO_MORE_ENTRIES)
86  {
87  /* We are done with the sub-keys */
88  break;
89  }
90  else if (!NT_SUCCESS(Status))
91  {
92  ERR_(VIDEOPRT, "ZwEnumerateKey failed, status 0x%lx\n", Status);
93  goto Cleanup;
94  }
95 
96  /* Initialize a unicode string from the key name */
97  NameString.Buffer = KeyInformation->Name;
98  NameString.Length = (USHORT)KeyInformation->NameLength;
99  NameString.MaximumLength = NameString.Length;
100 
101  /* Initialize object attributes and open the source sub-key */
103  &NameString,
105  SourceKeyHandle,
106  NULL);
107  Status = ZwOpenKey(&SourceSubKeyHandle, KEY_READ, &ObjectAttributes);
108  if (!NT_SUCCESS(Status))
109  {
110  ERR_(VIDEOPRT, "failed to open the source key.\n");
111  goto Cleanup;
112  }
113 
114  /* Initialize object attributes and create the dest sub-key */
116  &NameString,
118  DestKeyHandle,
119  NULL);
120  Status = ZwCreateKey(&DestSubKeyHandle,
121  KEY_WRITE,
123  0,
124  NULL,
125  0,
126  NULL);
127  if (!NT_SUCCESS(Status))
128  {
129  ERR_(VIDEOPRT, "failed to create the destination key.\n");
130  ObCloseHandle(SourceSubKeyHandle, KernelMode);
131  goto Cleanup;
132  }
133 
134  /* Recursively copy the sub-key */
135  Status = IntCopyRegistryKey(SourceSubKeyHandle, DestSubKeyHandle);
136  if (!NT_SUCCESS(Status))
137  {
138  /* Just warn, but continue with the remaining sub-keys */
139  WARN_(VIDEOPRT, "failed to copy subkey '%wZ'.\n", &NameString);
140  }
141 
142  /* Close the sub-key handles */
143  ObCloseHandle(SourceSubKeyHandle, KernelMode);
144  ObCloseHandle(DestSubKeyHandle, KernelMode);
145 
146  /* Next sub-key */
147  Index++;
148  }
149 
150  /* Start looping with value index 0 */
151  Index = 0;
152  while (TRUE)
153  {
154  /* Check if we have no buffer */
155  if (InfoBuffer == NULL)
156  {
157  /* Allocate a new buffer */
158  InfoBuffer = ExAllocatePoolWithTag(PagedPool,
159  InformationLength,
161  if (InfoBuffer == NULL)
162  {
163  ERR_(VIDEOPRT, "Could not allocate buffer for key values\n");
164  return Status;
165  }
166  }
167 
168  /* Enumerate the next value */
169  KeyValueInformation = InfoBuffer;
170  Status = ZwEnumerateValueKey(SourceKeyHandle,
171  Index,
173  KeyValueInformation,
174  InformationLength,
175  &RequiredLength);
176  if ((Status == STATUS_BUFFER_OVERFLOW) ||
178  {
179  /* Free the buffer and remember the required size */
181  InfoBuffer = NULL;
182  InformationLength = RequiredLength;
183 
184  /* Try again */
185  continue;
186  }
187  else if (Status == STATUS_NO_MORE_ENTRIES)
188  {
189  /* We are done with the values */
191  break;
192  }
193  else if (!NT_SUCCESS(Status))
194  {
195  ERR_(VIDEOPRT, "ZwEnumerateValueKey failed, status 0x%lx\n", Status);
196  goto Cleanup;
197  }
198 
199  /* Initialize a unicode string from the value name */
200  NameString.Buffer = KeyValueInformation->Name;
201  NameString.Length = (USHORT)KeyValueInformation->NameLength;
202  NameString.MaximumLength = NameString.Length;
203 
204  /* Create the key value in the destination key */
205  Status = ZwSetValueKey(DestKeyHandle,
206  &NameString,
207  KeyValueInformation->TitleIndex,
208  KeyValueInformation->Type,
209  (PUCHAR)KeyValueInformation + KeyValueInformation->DataOffset,
210  KeyValueInformation->DataLength);
211  if (!NT_SUCCESS(Status))
212  {
213  /* Just warn, but continue with the remaining sub-keys */
214  WARN_(VIDEOPRT, "failed to set value '%wZ'.\n", &NameString);
215  }
216 
217  /* Next subkey */
218  Index++;
219  }
220 
221 Cleanup:
222  /* Free the buffer and return the failure code */
223  if (InfoBuffer != NULL)
225  return Status;
226 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define STATUS_NO_MORE_ENTRIES
Definition: ntstatus.h:193
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define KEY_READ
Definition: nt_native.h:1023
unsigned char * PUCHAR
Definition: retypes.h:3
#define ERR_(ch,...)
Definition: debug.h:156
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
#define TAG_VIDEO_PORT_BUFFER
Definition: videoprt.h:36
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI IntCopyRegistryKey(_In_ HANDLE SourceKeyHandle, _In_ HANDLE DestKeyHandle)
Definition: registry.c:31
#define KEY_WRITE
Definition: nt_native.h:1031
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const UCHAR Index[8]
Definition: usbohci.c:18
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3376
static const WCHAR Cleanup[]
Definition: register.c:80
Status
Definition: gdiplustypes.h:24
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
unsigned short USHORT
Definition: pedump.c:61
_In_ ULONG _Out_opt_ PULONG RequiredLength
Definition: wmifuncs.h:29
unsigned int ULONG
Definition: retypes.h:1
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define WARN_(ch,...)
Definition: debug.h:157

Referenced by IntCopyRegistryKey(), and IntCreateNewRegistryPath().

◆ IntCopyRegistryValue()

NTSTATUS NTAPI IntCopyRegistryValue ( HANDLE  SourceKeyHandle,
HANDLE  DestKeyHandle,
PWSTR  ValueName 
)

Definition at line 230 of file registry.c.

234 {
235  PKEY_VALUE_PARTIAL_INFORMATION ValueInformation;
236  UNICODE_STRING ValueNameString;
237  ULONG Length;
239 
240  RtlInitUnicodeString(&ValueNameString, ValueName);
241 
242  /* Query the value length */
243  Status = ZwQueryValueKey(SourceKeyHandle,
244  &ValueNameString,
246  NULL,
247  0,
248  &Length);
249  if ((Status != STATUS_BUFFER_OVERFLOW) &&
251  {
252  /* The key seems not present */
254  return Status;
255  }
256 
257  /* Allocate a buffer */
259  if (ValueInformation == NULL)
260  {
261  return Status;
262  }
263 
264  /* Query the value */
265  Status = ZwQueryValueKey(SourceKeyHandle,
266  &ValueNameString,
268  ValueInformation,
269  Length,
270  &Length);
271  if (!NT_SUCCESS(Status))
272  {
273  ExFreePoolWithTag(ValueInformation, TAG_VIDEO_PORT_BUFFER);
274  return Status;
275  }
276 
277  /* Write the registry value */
278  Status = ZwSetValueKey(DestKeyHandle,
279  &ValueNameString,
280  ValueInformation->TitleIndex,
281  ValueInformation->Type,
282  ValueInformation->Data,
283  ValueInformation->DataLength);
284 
285  ExFreePoolWithTag(ValueInformation, TAG_VIDEO_PORT_BUFFER);
286 
287  if (!NT_SUCCESS(Status))
288  {
289  ERR_(VIDEOPRT, "ZwSetValueKey failed: status 0x%lx\n", Status);
290  }
291 
292  return Status;
293 }
#define ERR_(ch,...)
Definition: debug.h:156
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
_In_ PUNICODE_STRING ValueName
Definition: cmfuncs.h:264
#define TAG_VIDEO_PORT_BUFFER
Definition: videoprt.h:36
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
Status
Definition: gdiplustypes.h:24
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by IntSetupDeviceSettingsKey().

◆ IntCreateNewRegistryPath()

NTSTATUS NTAPI IntCreateNewRegistryPath ( PVIDEO_PORT_DEVICE_EXTENSION  DeviceExtension)
Todo:
HACK

Definition at line 358 of file registry.c.

360 {
361  static UNICODE_STRING VideoIdValueName = RTL_CONSTANT_STRING(L"VideoId");
362  static UNICODE_STRING ControlVideoPathName =
363  RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Video\\");
364  HANDLE DevInstRegKey, SettingsKey, NewKey;
365  UCHAR VideoIdBuffer[sizeof(KEY_VALUE_PARTIAL_INFORMATION) + GUID_STRING_LENGTH];
366  UNICODE_STRING VideoIdString;
367  UUID VideoId;
368  PKEY_VALUE_PARTIAL_INFORMATION ValueInformation ;
371  USHORT KeyMaxLength;
373 
374  /* Open the hardware key: HKLM\System\CurrentControlSet\Enum\... */
378  &DevInstRegKey);
379  if (Status != STATUS_SUCCESS)
380  {
381  ERR_(VIDEOPRT, "IoOpenDeviceRegistryKey failed: status 0x%lx\n", Status);
382  return Status;
383  }
384 
385  /* Query the VideoId value */
386  ValueInformation = (PKEY_VALUE_PARTIAL_INFORMATION)VideoIdBuffer;
387  Status = ZwQueryValueKey(DevInstRegKey,
388  &VideoIdValueName,
390  ValueInformation,
391  sizeof(VideoIdBuffer),
392  &ResultLength);
393  if (!NT_SUCCESS(Status))
394  {
395  /* Create a new video Id */
396  Status = ExUuidCreate(&VideoId);
397  if (!NT_SUCCESS(Status))
398  {
399  ERR_(VIDEOPRT, "ExUuidCreate failed: status 0x%lx\n", Status);
401  return Status;
402  }
403 
404  /* Convert the GUID into a string */
405  Status = RtlStringFromGUID(&VideoId, &VideoIdString);
406  if (!NT_SUCCESS(Status))
407  {
408  ERR_(VIDEOPRT, "RtlStringFromGUID failed: status 0x%lx\n", Status);
410  return Status;
411  }
412 
413  /* Copy the GUID String to our buffer */
414  ValueInformation->DataLength = min(VideoIdString.Length, GUID_STRING_LENGTH);
415  RtlCopyMemory(ValueInformation->Data,
416  VideoIdString.Buffer,
417  ValueInformation->DataLength);
418 
419  /* Free the GUID string */
420  RtlFreeUnicodeString(&VideoIdString);
421 
422  /* Write the VideoId registry value */
423  Status = ZwSetValueKey(DevInstRegKey,
424  &VideoIdValueName,
425  0,
426  REG_SZ,
427  ValueInformation->Data,
428  ValueInformation->DataLength);
429  if (!NT_SUCCESS(Status))
430  {
431  ERR_(VIDEOPRT, "ZwSetValueKey failed: status 0x%lx\n", Status);
433  return Status;
434  }
435  }
436 
437  /* Initialize the VideoId string from the registry data */
438  VideoIdString.Buffer = (PWCHAR)ValueInformation->Data;
439  VideoIdString.Length = (USHORT)ValueInformation->DataLength;
440  VideoIdString.MaximumLength = VideoIdString.Length;
441 
442  /* Close the hardware key */
444 
445  /* Calculate the size needed for the new registry path name */
446  KeyMaxLength = ControlVideoPathName.Length +
447  VideoIdString.Length +
448  sizeof(L"\\0000");
449 
450  /* Allocate the path name buffer */
451  DeviceExtension->NewRegistryPath.Length = 0;
452  DeviceExtension->NewRegistryPath.MaximumLength = KeyMaxLength;
454  KeyMaxLength,
456  if (DeviceExtension->NewRegistryPath.Buffer == NULL)
457  {
458  ERR_(VIDEOPRT, "Failed to allocate key name buffer.\n");
460  }
461 
462  /* Copy the root key name and append the VideoId string */
463  RtlCopyUnicodeString(&DeviceExtension->NewRegistryPath,
464  &ControlVideoPathName);
466  &VideoIdString);
467 
468  /* Check if we have the key already */
470  DeviceExtension->NewRegistryPath.Buffer);
471  if (Status != STATUS_SUCCESS)
472  {
473  /* Try to create the new key */
475  DeviceExtension->NewRegistryPath.Buffer);
476  }
477 
478  /* Append a the instance path */
479  RtlAppendUnicodeToString(&DeviceExtension->NewRegistryPath, L"\\");
480  RtlAppendUnicodeToString(&DeviceExtension->NewRegistryPath, L"0000");
481 
482  /* Check this key again */
484  DeviceExtension->NewRegistryPath.Buffer);
485  if (Status != STATUS_SUCCESS)
486  {
487  /* Try to create the new key */
489  DeviceExtension->NewRegistryPath.Buffer);
490  if (!NT_SUCCESS(Status))
491  {
492  ERR_(VIDEOPRT, "Failed create key '%wZ'\n", &DeviceExtension->NewRegistryPath);
493  return Status;
494  }
495 
496  /* Open the new key */
498  &DeviceExtension->NewRegistryPath,
500  NULL,
501  NULL);
502  Status = ZwOpenKey(&NewKey, KEY_READ, &ObjectAttributes);
503  if (!NT_SUCCESS(Status))
504  {
505  ERR_(VIDEOPRT, "Failed to open settings key. Status 0x%lx\n", Status);
506  return Status;
507  }
508 
509  /* Open the device profile key */
511  &DeviceExtension->RegistryPath,
513  NULL,
514  NULL);
515  Status = ZwOpenKey(&SettingsKey, KEY_READ, &ObjectAttributes);
516  if (!NT_SUCCESS(Status))
517  {
518  ERR_(VIDEOPRT, "Failed to open settings key. Status 0x%lx\n", Status);
519  ObCloseHandle(NewKey, KernelMode);
520  return Status;
521  }
522 
523  /* Copy the registry data from the legacy key */
524  Status = IntCopyRegistryKey(SettingsKey, NewKey);
525  }
526 
527 
528  return Status;
529 }
IN CINT OUT PVOID IN ULONG OUT PULONG ResultLength
Definition: conport.c:47
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
UNICODE_STRING NewRegistryPath
Definition: videoprt.h:88
#define TAG_VIDEO_PORT
Definition: videoprt.h:35
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define PLUGPLAY_REGKEY_DEVICE
Definition: iofuncs.h:2738
#define KEY_READ
Definition: nt_native.h:1023
#define GUID_STRING_LENGTH
Definition: wmip.h:6
#define ERR_(ch,...)
Definition: debug.h:156
LONG NTSTATUS
Definition: precomp.h:26
uint16_t * PWCHAR
Definition: typedefs.h:54
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
PDEVICE_OBJECT PhysicalDeviceObject
Definition: videoprt.h:84
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI IntCopyRegistryKey(_In_ HANDLE SourceKeyHandle, _In_ HANDLE DestKeyHandle)
Definition: registry.c:31
NTKERNELAPI NTSTATUS ExUuidCreate(OUT UUID *Uuid)
Definition: uuid.c:403
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
struct _KEY_VALUE_PARTIAL_INFORMATION * PKEY_VALUE_PARTIAL_INFORMATION
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
unsigned char UCHAR
Definition: xmlstorage.h:181
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3376
static const WCHAR L[]
Definition: oid.c:1250
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
#define RTL_REGISTRY_ABSOLUTE
Definition: nt_native.h:161
_In_ ULONG _In_ ACCESS_MASK _Out_ PHANDLE DevInstRegKey
Definition: iofuncs.h:1123
Status
Definition: gdiplustypes.h:24
unsigned short USHORT
Definition: pedump.c:61
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
#define min(a, b)
Definition: monoChain.cc:55
NTSTATUS NTAPI IoOpenDeviceRegistryKey(IN PDEVICE_OBJECT DeviceObject, IN ULONG DevInstKeyType, IN ACCESS_MASK DesiredAccess, OUT PHANDLE DevInstRegKey)
Definition: pnpmgr.c:4565
NTSTATUS NTAPI RtlCheckRegistryKey(IN ULONG RelativeTo, IN PWSTR Path)
Definition: registry.c:583
unsigned int ULONG
Definition: retypes.h:1
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
UNICODE_STRING RegistryPath
Definition: videoprt.h:87
NTSTATUS NTAPI RtlCreateRegistryKey(IN ULONG RelativeTo, IN PWSTR Path)
Definition: registry.c:607
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
#define REG_SZ
Definition: layer.c:22

Referenced by IntVideoPortCreateAdapterDeviceObject().

◆ IntCreateRegistryPath()

NTSTATUS NTAPI IntCreateRegistryPath ( IN PCUNICODE_STRING  DriverRegistryPath,
OUT PUNICODE_STRING  DeviceRegistryPath 
)

Definition at line 533 of file registry.c.

536 {
537  static WCHAR RegistryMachineSystem[] = L"\\REGISTRY\\MACHINE\\SYSTEM\\";
538  static WCHAR CurrentControlSet[] = L"CURRENTCONTROLSET\\";
539  static WCHAR ControlSet[] = L"CONTROLSET";
540  static WCHAR Insert1[] = L"Hardware Profiles\\Current\\System\\CurrentControlSet\\";
541  static WCHAR Insert2[] = L"\\Device0";
542  BOOLEAN Valid;
543  UNICODE_STRING AfterControlSet;
544 
545  AfterControlSet = *DriverRegistryPath;
546 
547  /* Check if path begins with \\REGISTRY\\MACHINE\\SYSTEM\\ */
548  Valid = (DriverRegistryPath->Length > sizeof(RegistryMachineSystem) &&
549  0 == _wcsnicmp(DriverRegistryPath->Buffer, RegistryMachineSystem,
550  wcslen(RegistryMachineSystem)));
551  if (Valid)
552  {
553  AfterControlSet.Buffer += wcslen(RegistryMachineSystem);
554  AfterControlSet.Length -= sizeof(RegistryMachineSystem) - sizeof(UNICODE_NULL);
555 
556  /* Check if path contains CURRENTCONTROLSET */
557  if (AfterControlSet.Length > sizeof(CurrentControlSet) &&
558  0 == _wcsnicmp(AfterControlSet.Buffer, CurrentControlSet, wcslen(CurrentControlSet)))
559  {
560  AfterControlSet.Buffer += wcslen(CurrentControlSet);
561  AfterControlSet.Length -= sizeof(CurrentControlSet) - sizeof(UNICODE_NULL);
562  }
563  /* Check if path contains CONTROLSETnum */
564  else if (AfterControlSet.Length > sizeof(ControlSet) &&
565  0 == _wcsnicmp(AfterControlSet.Buffer, ControlSet, wcslen(ControlSet)))
566  {
567  AfterControlSet.Buffer += wcslen(ControlSet);
568  AfterControlSet.Length -= sizeof(ControlSet) - sizeof(UNICODE_NULL);
569  while (AfterControlSet.Length > 0 &&
570  *AfterControlSet.Buffer >= L'0' &&
571  *AfterControlSet.Buffer <= L'9')
572  {
573  AfterControlSet.Buffer++;
574  AfterControlSet.Length -= sizeof(WCHAR);
575  }
576 
577  Valid = (AfterControlSet.Length > 0 && L'\\' == *AfterControlSet.Buffer);
578  AfterControlSet.Buffer++;
579  AfterControlSet.Length -= sizeof(WCHAR);
580  AfterControlSet.MaximumLength = AfterControlSet.Length;
581  }
582  else
583  {
584  Valid = FALSE;
585  }
586  }
587 
588  if (Valid)
589  {
590  DeviceRegistryPath->MaximumLength = DriverRegistryPath->Length + sizeof(Insert1) + sizeof(Insert2);
591  DeviceRegistryPath->Buffer = ExAllocatePoolWithTag(PagedPool,
592  DeviceRegistryPath->MaximumLength,
594  if (DeviceRegistryPath->Buffer != NULL)
595  {
596  /* Build device path */
597  wcsncpy(DeviceRegistryPath->Buffer,
599  AfterControlSet.Buffer - DriverRegistryPath->Buffer);
600  DeviceRegistryPath->Length = (AfterControlSet.Buffer - DriverRegistryPath->Buffer) * sizeof(WCHAR);
601  RtlAppendUnicodeToString(DeviceRegistryPath, Insert1);
602  RtlAppendUnicodeStringToString(DeviceRegistryPath, &AfterControlSet);
603  RtlAppendUnicodeToString(DeviceRegistryPath, Insert2);
604 
605  /* Check if registry key exists */
606  Valid = NT_SUCCESS(RtlCheckRegistryKey(RTL_REGISTRY_ABSOLUTE, DeviceRegistryPath->Buffer));
607 
608  if (!Valid)
609  ExFreePoolWithTag(DeviceRegistryPath->Buffer, TAG_VIDEO_PORT);
610  }
611  else
612  {
613  Valid = FALSE;
614  }
615  }
616  else
617  {
618  WARN_(VIDEOPRT, "Unparsable registry path %wZ\n", DriverRegistryPath);
619  }
620 
621  /* If path doesn't point to *ControlSet*, use DriverRegistryPath directly */
622  if (!Valid)
623  {
624  DeviceRegistryPath->MaximumLength = DriverRegistryPath->Length + sizeof(Insert2);
625  DeviceRegistryPath->Buffer = ExAllocatePoolWithTag(NonPagedPool,
626  DeviceRegistryPath->MaximumLength,
628 
629  if (!DeviceRegistryPath->Buffer)
630  return STATUS_NO_MEMORY;
631 
632  RtlCopyUnicodeString(DeviceRegistryPath, DriverRegistryPath);
633  RtlAppendUnicodeToString(DeviceRegistryPath, Insert2);
634  }
635 
636  DPRINT("Formatted registry key '%wZ' -> '%wZ'\n",
637  DriverRegistryPath, DeviceRegistryPath);
638 
639  return STATUS_SUCCESS;
640 }
#define TAG_VIDEO_PORT
Definition: videoprt.h:35
USHORT MaximumLength
Definition: env_spec_w32.h:370
_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)
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
#define UNICODE_NULL
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
static const WCHAR L[]
Definition: oid.c:1250
#define RTL_REGISTRY_ABSOLUTE
Definition: nt_native.h:161
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
NTSTATUS NTAPI RtlCheckRegistryKey(IN ULONG RelativeTo, IN PWSTR Path)
Definition: registry.c:583
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define WARN_(ch,...)
Definition: debug.h:157
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
UNICODE_STRING DriverRegistryPath
Definition: ramdisk.c:124

Referenced by IntVideoPortCreateAdapterDeviceObject().

◆ IntDetachFromCSRSS()

VOID FASTCALL IntDetachFromCSRSS ( PKPROCESS CallingProcess,
PKAPC_STATE  ApcState 
)

Definition at line 438 of file videoprt.c.

441 {
442  if (*CallingProcess != Csrss)
443  {
445  }
446 }
PKPROCESS Csrss
Definition: videoprt.c:34
VOID NTAPI KeUnstackDetachProcess(IN PRKAPC_STATE ApcState)
Definition: procobj.c:753
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1484

Referenced by VideoPortGetRomImage(), and VideoPortInt10().

◆ IntInitializeVideoAddressSpace()

NTSTATUS NTAPI IntInitializeVideoAddressSpace ( VOID  )

Definition at line 145 of file int10.c.

146 {
148  NT_ASSERT(FALSE);
149  return STATUS_NOT_IMPLEMENTED;
150 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define UNIMPLEMENTED
Definition: debug.h:114
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by IntVideoPortDispatchOpen().

◆ IntInt10AllocateBuffer()

VP_STATUS NTAPI IntInt10AllocateBuffer ( IN PVOID  Context,
OUT PUSHORT  Seg,
OUT PUSHORT  Off,
IN OUT PULONG  Length 
)

Referenced by VideoPortQueryServices().

◆ IntInt10CallBios()

VP_STATUS NTAPI IntInt10CallBios ( IN PVOID  Context,
IN OUT PINT10_BIOS_ARGUMENTS  BiosArguments 
)

Referenced by VideoPortQueryServices().

◆ IntInt10FreeBuffer()

VP_STATUS NTAPI IntInt10FreeBuffer ( IN PVOID  Context,
IN USHORT  Seg,
IN USHORT  Off 
)

Referenced by VideoPortQueryServices().

◆ IntInt10ReadMemory()

VP_STATUS NTAPI IntInt10ReadMemory ( IN PVOID  Context,
IN USHORT  Seg,
IN USHORT  Off,
OUT PVOID  Buffer,
IN ULONG  Length 
)

Referenced by VideoPortQueryServices().

◆ IntInt10WriteMemory()

VP_STATUS NTAPI IntInt10WriteMemory ( IN PVOID  Context,
IN USHORT  Seg,
IN USHORT  Off,
IN PVOID  Buffer,
IN ULONG  Length 
)

Referenced by VideoPortQueryServices().

◆ IntSetupDeviceSettingsKey()

NTSTATUS NTAPI IntSetupDeviceSettingsKey ( PVIDEO_PORT_DEVICE_EXTENSION  DeviceExtension)

Definition at line 297 of file registry.c.

299 {
300  static UNICODE_STRING SettingsKeyName = RTL_CONSTANT_STRING(L"Settings");
301  HANDLE DevInstRegKey, SourceKeyHandle, DestKeyHandle;
304 
305  /* Open the software key: HKLM\System\CurrentControlSet\Control\Class<ClassGUID><n> */
309  &DevInstRegKey);
310  if (Status != STATUS_SUCCESS)
311  {
312  ERR_(VIDEOPRT, "Failed to open device software key. Status 0x%lx\n", Status);
313  return Status;
314  }
315 
316  /* Open the 'Settings' sub-key */
318  &SettingsKeyName,
321  NULL);
322  Status = ZwOpenKey(&DestKeyHandle, KEY_WRITE, &ObjectAttributes);
323 
324  /* Close the device software key */
326 
327  if (Status != STATUS_SUCCESS)
328  {
329  ERR_(VIDEOPRT, "Failed to open settings key. Status 0x%lx\n", Status);
330  return Status;
331  }
332 
333  /* Open the device profile key */
335  &DeviceExtension->RegistryPath,
337  NULL,
338  NULL);
339  Status = ZwOpenKey(&SourceKeyHandle, KEY_WRITE, &ObjectAttributes);
340  if (Status != STATUS_SUCCESS)
341  {
342  ERR_(VIDEOPRT, "ZwOpenKey failed for settings key: status 0x%lx\n", Status);
343  ObCloseHandle(DestKeyHandle, KernelMode);
344  return Status;
345  }
346 
347  IntCopyRegistryValue(SourceKeyHandle, DestKeyHandle, L"InstalledDisplayDrivers");
348  IntCopyRegistryValue(SourceKeyHandle, DestKeyHandle, L"Attach.ToDesktop");
349 
350  ObCloseHandle(SourceKeyHandle, KernelMode);
351  ObCloseHandle(DestKeyHandle, KernelMode);
352 
353  return STATUS_SUCCESS;
354 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define ERR_(ch,...)
Definition: debug.h:156
LONG NTSTATUS
Definition: precomp.h:26
PDEVICE_OBJECT PhysicalDeviceObject
Definition: videoprt.h:84
smooth NULL
Definition: ftsmooth.c:416
#define KEY_WRITE
Definition: nt_native.h:1031
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3376
static const WCHAR L[]
Definition: oid.c:1250
#define PLUGPLAY_REGKEY_DRIVER
Definition: usbd.c:42
_In_ ULONG _In_ ACCESS_MASK _Out_ PHANDLE DevInstRegKey
Definition: iofuncs.h:1123
Status
Definition: gdiplustypes.h:24
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
NTSTATUS NTAPI IoOpenDeviceRegistryKey(IN PDEVICE_OBJECT DeviceObject, IN ULONG DevInstKeyType, IN ACCESS_MASK DesiredAccess, OUT PHANDLE DevInstRegKey)
Definition: pnpmgr.c:4565
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
UNICODE_STRING RegistryPath
Definition: videoprt.h:87
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
NTSTATUS NTAPI IntCopyRegistryValue(HANDLE SourceKeyHandle, HANDLE DestKeyHandle, PWSTR ValueName)
Definition: registry.c:230
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

Referenced by IntVideoPortCreateAdapterDeviceObject().

◆ IntVideoPortAddDevice()

NTSTATUS NTAPI IntVideoPortAddDevice ( IN PDRIVER_OBJECT  DriverObject,
IN PDEVICE_OBJECT  PhysicalDeviceObject 
)

Definition at line 68 of file dispatch.c.

71 {
75 
76  /* Get the initialization data we saved in VideoPortInitialize. */
78 
79  /* Create adapter device object. */
83  &DeviceObject);
84  if (NT_SUCCESS(Status))
86 
87  return Status;
88 }
LONG NTSTATUS
Definition: precomp.h:26
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1842
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
ULONG VideoPortDeviceNumber
Definition: videoprt.c:35
NTSTATUS NTAPI IntVideoPortCreateAdapterDeviceObject(IN PDRIVER_OBJECT DriverObject, IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, IN PDEVICE_OBJECT PhysicalDeviceObject, OUT PDEVICE_OBJECT *DeviceObject OPTIONAL)
Definition: videoprt.c:87

Referenced by VideoPortInitialize().

◆ IntVideoPortCreateAdapterDeviceObject()

NTSTATUS NTAPI IntVideoPortCreateAdapterDeviceObject ( IN PDRIVER_OBJECT  DriverObject,
IN PVIDEO_PORT_DRIVER_EXTENSION  DriverExtension,
IN PDEVICE_OBJECT PhysicalDeviceObject  OPTIONAL,
OUT PDEVICE_OBJECT *DeviceObject  OPTIONAL 
)

Definition at line 87 of file videoprt.c.

92 {
93  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
95  ULONG PciSlotNumber;
97  ULONG Size;
99  WCHAR DeviceBuffer[20];
101  PDEVICE_OBJECT DeviceObject_;
102 
103  if (DeviceObject == NULL)
104  DeviceObject = &DeviceObject_;
105 
106  /*
107  * Find the first free device number that can be used for video device
108  * object names and symlinks.
109  */
111  if (DeviceNumber == 0xFFFFFFFF)
112  {
113  WARN_(VIDEOPRT, "Can't find free device number\n");
114  return STATUS_UNSUCCESSFUL;
115  }
116 
117  /*
118  * Create the device object.
119  */
120 
121  /* Create a unicode device name. */
122  swprintf(DeviceBuffer, L"\\Device\\Video%lu", DeviceNumber);
123  RtlInitUnicodeString(&DeviceName, DeviceBuffer);
124 
125  INFO_(VIDEOPRT, "HwDeviceExtension size is: 0x%x\n",
126  DriverExtension->InitializationData.HwDeviceExtensionSize);
127 
128  /* Create the device object. */
130  DriverExtension->InitializationData.HwDeviceExtensionSize;
132  Size,
133  &DeviceName,
135  0,
136  TRUE,
137  DeviceObject);
138 
139  if (!NT_SUCCESS(Status))
140  {
141  WARN_(VIDEOPRT, "IoCreateDevice call failed with status 0x%08x\n", Status);
142  return Status;
143  }
144 
145  /*
146  * Set the buffering strategy here. If you change this, remember
147  * to change VidDispatchDeviceControl too.
148  */
149 
150  (*DeviceObject)->Flags |= DO_BUFFERED_IO;
151 
152  /* Initialize device extension. */
153  DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)((*DeviceObject)->DeviceExtension);
154  DeviceExtension->Common.Fdo = TRUE;
155  DeviceExtension->DeviceNumber = DeviceNumber;
156  DeviceExtension->DriverObject = DriverObject;
157  DeviceExtension->PhysicalDeviceObject = PhysicalDeviceObject;
158  DeviceExtension->FunctionalDeviceObject = *DeviceObject;
159  DeviceExtension->DriverExtension = DriverExtension;
160  DeviceExtension->SessionId = -1;
161 
162  InitializeListHead(&DeviceExtension->ChildDeviceList);
163 
164  /* Get the registry path associated with this device. */
166  &DeviceExtension->RegistryPath);
167  if (!NT_SUCCESS(Status))
168  {
169  WARN_(VIDEOPRT, "IntCreateRegistryPath() call failed with status 0x%08x\n", Status);
171  *DeviceObject = NULL;
172  return Status;
173  }
174 
175  if (PhysicalDeviceObject != NULL)
176  {
177  /* Get bus number from the upper level bus driver. */
178  Size = sizeof(ULONG);
181  Size,
182  &DeviceExtension->SystemIoBusNumber,
183  &Size);
184  if (!NT_SUCCESS(Status))
185  {
186  WARN_(VIDEOPRT, "Couldn't get an information from bus driver. We will try to\n"
187  "use legacy detection method, but even that doesn't mean that\n"
188  "it will work.\n");
189  DeviceExtension->PhysicalDeviceObject = NULL;
190  }
191  }
192 
193  DeviceExtension->AdapterInterfaceType =
194  DriverExtension->InitializationData.AdapterInterfaceType;
195 
196  if (PhysicalDeviceObject != NULL)
197  {
198  /* Get bus type from the upper level bus driver. */
199  Size = sizeof(ULONG);
202  Size,
203  &DeviceExtension->AdapterInterfaceType,
204  &Size);
205 
206  /* Get bus device address from the upper level bus driver. */
207  Size = sizeof(ULONG);
210  Size,
211  &PciSlotNumber,
212  &Size);
213 
214  /* Convert slotnumber to PCI_SLOT_NUMBER */
215  SlotNumber.u.AsULONG = 0;
216  SlotNumber.u.bits.DeviceNumber = (PciSlotNumber >> 16) & 0xFFFF;
217  SlotNumber.u.bits.FunctionNumber = PciSlotNumber & 0xFFFF;
218  DeviceExtension->SystemIoSlotNumber = SlotNumber.u.AsULONG;
219  }
220 
221  InitializeListHead(&DeviceExtension->AddressMappingListHead);
222  InitializeListHead(&DeviceExtension->DmaAdapterList);
223 
224  KeInitializeDpc(&DeviceExtension->DpcObject,
226  DeviceExtension);
227 
228  KeInitializeMutex(&DeviceExtension->DeviceLock, 0);
229 
230  /* Attach the device. */
231  if (PhysicalDeviceObject != NULL)
233  *DeviceObject,
235 
236  IntCreateNewRegistryPath(DeviceExtension);
237  IntSetupDeviceSettingsKey(DeviceExtension);
238 
239  /* Remove the initailizing flag */
240  (*DeviceObject)->Flags &= ~DO_DEVICE_INITIALIZING;
241  return STATUS_SUCCESS;
242 }
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
#define TRUE
Definition: types.h:120
PDEVICE_OBJECT FunctionalDeviceObject
Definition: videoprt.h:85
NTSTATUS NTAPI IntCreateNewRegistryPath(PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: registry.c:358
VOID NTAPI IntVideoPortDeferredRoutine(IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: videoprt.c:74
#define INFO_(ch,...)
Definition: debug.h:159
VIDEO_PORT_DRIVER_EXTENSION * DriverExtension
Definition: videoprt.h:100
LONG NTSTATUS
Definition: precomp.h:26
struct _VIDEO_PORT_DEVICE_EXTENSTION * PVIDEO_PORT_DEVICE_EXTENSION
LIST_ENTRY AddressMappingListHead
Definition: videoprt.h:98
NTSTATUS NTAPI IntSetupDeviceSettingsKey(PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: registry.c:297
WCHAR DeviceName[]
Definition: adapter.cpp:21
PDEVICE_OBJECT PhysicalDeviceObject
Definition: videoprt.h:84
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:966
smooth NULL
Definition: ftsmooth.c:416
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
NTSTATUS NTAPI IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, IN ULONG BufferLength, OUT PVOID PropertyBuffer, OUT PULONG ResultLength)
Definition: pnpmgr.c:4210
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define FILE_DEVICE_VIDEO
Definition: winioctl.h:140
#define DO_BUFFERED_IO
Definition: env_spec_w32.h:394
NTSTATUS NTAPI IntCreateRegistryPath(IN PCUNICODE_STRING DriverRegistryPath, OUT PUNICODE_STRING DeviceRegistryPath)
Definition: registry.c:533
#define swprintf(buf, format,...)
Definition: sprintf.c:56
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG _In_ ULONG SlotNumber
Definition: halfuncs.h:156
VOID NTAPI KeInitializeMutex(IN PKMUTEX Mutex, IN ULONG Level)
Definition: mutex.c:67
static const WCHAR L[]
Definition: oid.c:1250
PDEVICE_OBJECT NextDeviceObject
Definition: videoprt.h:86
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
Status
Definition: gdiplustypes.h:24
PDRIVER_OBJECT DriverObject
Definition: videoprt.h:83
struct _VIDEO_PORT_DEVICE_EXTENSTION VIDEO_PORT_DEVICE_EXTENSION
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1250
ULONG VideoPortDeviceNumber
Definition: videoprt.c:35
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
VIDEO_PORT_COMMON_EXTENSION Common
Definition: videoprt.h:81
unsigned int ULONG
Definition: retypes.h:1
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
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
UNICODE_STRING RegistryPath
Definition: videoprt.h:87
_In_ PCHAR _In_ ULONG DeviceNumber
Definition: classpnp.h:1036
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:711
INTERFACE_TYPE AdapterInterfaceType
Definition: videoprt.h:95
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define WARN_(ch,...)
Definition: debug.h:157

Referenced by IntVideoPortAddDevice(), and VideoPortInitialize().

◆ IntVideoPortDispatchCleanup()

NTSTATUS NTAPI IntVideoPortDispatchCleanup ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 812 of file dispatch.c.

815 {
816  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
817 
818  DeviceExtension = DeviceObject->DeviceExtension;
819  RtlFreeUnicodeString(&DeviceExtension->RegistryPath);
820 
821  Irp->IoStatus.Status = STATUS_SUCCESS;
822  Irp->IoStatus.Information = 0;
824 
825  return STATUS_SUCCESS;
826 }
_In_ PIRP Irp
Definition: csq.h:116
PVOID DeviceExtension
Definition: env_spec_w32.h:418
#define IoCompleteRequest
Definition: irp.c:1240
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define IO_NO_INCREMENT
Definition: iotypes.h:565
UNICODE_STRING RegistryPath
Definition: videoprt.h:87
return STATUS_SUCCESS
Definition: btrfs.c:2777

◆ IntVideoPortDispatchClose()

NTSTATUS NTAPI IntVideoPortDispatchClose ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 154 of file dispatch.c.

157 {
158  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
159 
160  TRACE_(VIDEOPRT, "IntVideoPortDispatchClose\n");
161 
163  if ((DeviceExtension->DeviceOpened >= 1) &&
164  (InterlockedDecrement((PLONG)&DeviceExtension->DeviceOpened) == 0))
165  {
168  ResetDisplayParametersDeviceExtension = DeviceExtension;
170  }
171 
172  Irp->IoStatus.Status = STATUS_SUCCESS;
174 
175  return STATUS_SUCCESS;
176 }
VOID NTAPI InbvNotifyDisplayOwnershipLost(IN INBV_RESET_DISPLAY_PARAMETERS Callback)
Definition: inbv.c:504
_In_ PIRP Irp
Definition: csq.h:116
struct _VIDEO_PORT_DEVICE_EXTENSTION * PVIDEO_PORT_DEVICE_EXTENSION
BOOLEAN NTAPI IntVideoPortResetDisplayParameters(ULONG Columns, ULONG Rows)
Definition: dispatch.c:42
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
#define IoCompleteRequest
Definition: irp.c:1240
PVIDEO_PORT_DEVICE_EXTENSION ResetDisplayParametersDeviceExtension
Definition: dispatch.c:32
#define TRACE_(x)
Definition: compat.h:66
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define InterlockedDecrement
Definition: armddk.h:52
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define IO_NO_INCREMENT
Definition: iotypes.h:565
return STATUS_SUCCESS
Definition: btrfs.c:2777
signed int * PLONG
Definition: retypes.h:5

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchDeviceControl()

NTSTATUS NTAPI IntVideoPortDispatchDeviceControl ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 450 of file dispatch.c.

453 {
454  PIO_STACK_LOCATION IrpStack;
457 
458  TRACE_(VIDEOPRT, "IntVideoPortDispatchDeviceControl\n");
459 
460  IrpStack = IoGetCurrentIrpStackLocation(Irp);
461 
462  IoControlCode = IrpStack->Parameters.DeviceIoControl.IoControlCode;
463 
464  INFO_(VIDEOPRT, "- IoControlCode: %x: %s\n", IoControlCode, IoctlName(IoControlCode));
465 
466  switch(IoControlCode)
467  {
469  INFO_(VIDEOPRT, "- IOCTL_VIDEO_INIT_WIN32K_CALLBACKS\n");
471  Irp->AssociatedIrp.SystemBuffer,
472  IrpStack->Parameters.DeviceIoControl.InputBufferLength,
473  &Irp->IoStatus.Information);
474  break;
475 
477  INFO_(VIDEOPRT, "- IOCTL_VIDEO_USE_DEVICE_IN_SESSION\n");
479  Irp->AssociatedIrp.SystemBuffer,
480  IrpStack->Parameters.DeviceIoControl.InputBufferLength,
481  &Irp->IoStatus.Information);
482  break;
483 
484  default:
485  /* Forward to the Miniport Driver */
487  break;
488  }
489 
490  INFO_(VIDEOPRT, "- Returned status: %x\n", Irp->IoStatus.Status);
491 
492  Irp->IoStatus.Status = Status;
494 
495  return Status;
496 }
static NTSTATUS VideoPortUseDeviceInSession(_Inout_ PDEVICE_OBJECT DeviceObject, _Inout_ PVIDEO_DEVICE_SESSION_STATUS SessionState, _In_ ULONG BufferLength, _Out_ PULONG_PTR Information)
Definition: dispatch.c:298
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG IoControlCode
Definition: fltkernel.h:1383
#define INFO_(ch,...)
Definition: debug.h:159
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
PSTR IoctlName(ULONG Ioctl)
Definition: dispatch.c:179
#define IOCTL_VIDEO_INIT_WIN32K_CALLBACKS
Definition: ntddvdeo.h:62
#define IoCompleteRequest
Definition: irp.c:1240
static NTSTATUS VideoPortInitWin32kCallbacks(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PVIDEO_WIN32K_CALLBACKS Win32kCallbacks, _In_ ULONG BufferLength, _Out_ PULONG_PTR Information)
Definition: dispatch.c:356
#define TRACE_(x)
Definition: compat.h:66
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:565
static NTSTATUS VideoPortForwardDeviceControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:383
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
#define IOCTL_VIDEO_USE_DEVICE_IN_SESSION
Definition: ntddvdeo.h:71

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchOpen()

NTSTATUS NTAPI IntVideoPortDispatchOpen ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 100 of file dispatch.c.

103 {
104  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
106 
107  TRACE_(VIDEOPRT, "IntVideoPortDispatchOpen\n");
108 
109  if (CsrssInitialized == FALSE)
110  {
111  /*
112  * We know the first open call will be from the CSRSS process
113  * to let us know its handle.
114  */
115 
116  INFO_(VIDEOPRT, "Referencing CSRSS\n");
118  INFO_(VIDEOPRT, "Csrss %p\n", Csrss);
119 
121 
123  }
124 
126  DriverExtension = DeviceExtension->DriverExtension;
127 
128  if (DriverExtension->InitializationData.HwInitialize(&DeviceExtension->MiniPortDeviceExtension))
129  {
130  Irp->IoStatus.Status = STATUS_SUCCESS;
131  InterlockedIncrement((PLONG)&DeviceExtension->DeviceOpened);
132  }
133  else
134  {
135  Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
136  }
137 
138  Irp->IoStatus.Information = FILE_OPENED;
140 
141  return STATUS_SUCCESS;
142 }
#define TRUE
Definition: types.h:120
#define INFO_(ch,...)
Definition: debug.h:159
VIDEO_PORT_DRIVER_EXTENSION * DriverExtension
Definition: videoprt.h:100
_In_ PIRP Irp
Definition: csq.h:116
struct _VIDEO_PORT_DEVICE_EXTENSTION * PVIDEO_PORT_DEVICE_EXTENSION
#define FILE_OPENED
Definition: nt_native.h:769
#define PsGetCurrentProcess
Definition: psfuncs.h:17
PVOID DeviceExtension
Definition: env_spec_w32.h:418
#define IoCompleteRequest
Definition: irp.c:1240
PKPROCESS Csrss
Definition: videoprt.c:34
NTSTATUS NTAPI IntInitializeVideoAddressSpace(VOID)
Definition: int10.c:145
#define TRACE_(x)
Definition: compat.h:66
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define InterlockedIncrement
Definition: armddk.h:53
struct _KPROCESS * PKPROCESS
Definition: wdm.template.h:199
ULONG CsrssInitialized
Definition: videoprt.c:33
#define IO_NO_INCREMENT
Definition: iotypes.h:565
return STATUS_SUCCESS
Definition: btrfs.c:2777
signed int * PLONG
Definition: retypes.h:5

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchPdoPnp()

NTSTATUS NTAPI IntVideoPortDispatchPdoPnp ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 319 of file child.c.

322 {
324  NTSTATUS Status = Irp->IoStatus.Status;
325 
327 
328  switch (IrpSp->MinorFunction)
329  {
330  case IRP_MN_START_DEVICE:
331  case IRP_MN_STOP_DEVICE:
332  /* Nothing to do */
334  break;
335 
338  /* None (keep old status) */
339  break;
340 
341  case IRP_MN_QUERY_ID:
342  /* Call our helper */
344  Irp,
345  IrpSp);
346  break;
347 
349  /* Call our helper */
351  Irp,
352  IrpSp);
353  break;
354 
358  break;
359 
361  Irp->IoStatus.Status = STATUS_SUCCESS;
364  return STATUS_SUCCESS;
365 
367  /* Call our helper */
369  Irp,
370  IrpSp);
371  break;
372 
374  /* Call our helper */
376  Irp,
377  IrpSp);
378  break;
379 
380  default:
381  break;
382  }
383 
384  Irp->IoStatus.Status = Status;
385 
387 
388  return Status;
389 }
#define IRP_MN_QUERY_RESOURCES
#define IRP_MN_REMOVE_DEVICE
#define IRP_MN_QUERY_ID
NTSTATUS NTAPI IntVideoPortChildQueryCapabilities(IN PVIDEO_PORT_CHILD_EXTENSION ChildExtension, IN PIRP Irp, IN PIO_STACK_LOCATION IrpSp)
Definition: child.c:252
_In_ PIRP Irp
Definition: csq.h:116
#define IRP_MN_QUERY_RESOURCE_REQUIREMENTS
LONG NTSTATUS
Definition: precomp.h:26
#define IRP_MN_QUERY_REMOVE_DEVICE
PVOID DeviceExtension
Definition: env_spec_w32.h:418
#define IoCompleteRequest
Definition: irp.c:1240
#define IRP_MN_SURPRISE_REMOVAL
Definition: ntifs_ex.h:408
#define IRP_MN_STOP_DEVICE
#define IRP_MN_START_DEVICE
#define IRP_MN_QUERY_DEVICE_TEXT
NTSTATUS NTAPI IntVideoPortChildQueryRelations(IN PVIDEO_PORT_CHILD_EXTENSION ChildExtension, IN PIRP Irp, IN PIO_STACK_LOCATION IrpSp)
Definition: child.c:225
NTSTATUS NTAPI IntVideoPortChildQueryText(IN PVIDEO_PORT_CHILD_EXTENSION ChildExtension, IN PIRP Irp, IN PIO_STACK_LOCATION IrpSp)
Definition: child.c:186
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1250
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
#define IRP_MN_QUERY_DEVICE_RELATIONS
NTSTATUS NTAPI IntVideoPortChildQueryId(IN PVIDEO_PORT_CHILD_EXTENSION ChildExtension, IN PIRP Irp, IN PIO_STACK_LOCATION IrpSp)
Definition: child.c:61
#define IO_NO_INCREMENT
Definition: iotypes.h:565
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define IRP_MN_QUERY_CAPABILITIES

Referenced by IntVideoPortDispatchPnp().

◆ IntVideoPortDispatchPnp()

NTSTATUS NTAPI IntVideoPortDispatchPnp ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 798 of file dispatch.c.

801 {
803 
804  if (CommonExtension->Fdo)
806  else
808 }
NTSTATUS NTAPI IntVideoPortDispatchPdoPnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: child.c:319
NTSTATUS NTAPI IntVideoPortDispatchFdoPnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:721
_In_ PIRP Irp
Definition: csq.h:116
PVOID DeviceExtension
Definition: env_spec_w32.h:418
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchPower()

NTSTATUS NTAPI IntVideoPortDispatchPower ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 830 of file dispatch.c.

833 {
835  NTSTATUS Status = Irp->IoStatus.Status;
837 
839 
840  if (DeviceExtension->Common.Fdo)
841  {
844  return PoCallDriver(DeviceExtension->NextDeviceObject, Irp);
845  }
846  else
847  {
848  switch (IrpSp->MinorFunction)
849  {
850  case IRP_MN_QUERY_POWER:
851  case IRP_MN_SET_POWER:
853  break;
854  }
856  Irp->IoStatus.Status = Status;
858  return Status;
859  }
860 }
#define IRP_MN_QUERY_POWER
NTSTATUS NTAPI PoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
Definition: power.c:485
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
PVOID DeviceExtension
Definition: env_spec_w32.h:418
#define IoCompleteRequest
Definition: irp.c:1240
PDEVICE_OBJECT NextDeviceObject
Definition: videoprt.h:86
#define IRP_MN_SET_POWER
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:626
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
VIDEO_PORT_COMMON_EXTENSION Common
Definition: videoprt.h:81
#define IO_NO_INCREMENT
Definition: iotypes.h:565
return STATUS_SUCCESS
Definition: btrfs.c:2777

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchSystemControl()

NTSTATUS NTAPI IntVideoPortDispatchSystemControl ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 864 of file dispatch.c.

867 {
870 
871  if (DeviceExtension->Common.Fdo)
872  {
874  return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
875  }
876  else
877  {
878  Status = Irp->IoStatus.Status;
880  return Status;
881  }
882 }
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
PVOID DeviceExtension
Definition: env_spec_w32.h:418
#define IoCompleteRequest
Definition: irp.c:1240
PDEVICE_OBJECT NextDeviceObject
Definition: videoprt.h:86
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
VIDEO_PORT_COMMON_EXTENSION Common
Definition: videoprt.h:81
#define IO_NO_INCREMENT
Definition: iotypes.h:565

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchWrite()

NTSTATUS NTAPI IntVideoPortDispatchWrite ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 517 of file dispatch.c.

520 {
522  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
523  NTSTATUS nErrCode;
524 
526 
527  /*
528  * Storing the device extension pointer in a static variable is an
529  * ugly hack. Unfortunately, we need it in IntVideoPortResetDisplayParameters
530  * and InbvNotifyDisplayOwnershipLost doesn't allow us to pass a userdata
531  * parameter. On the bright side, the DISPLAY device is opened
532  * exclusively, so there can be only one device extension active at
533  * any point in time.
534  *
535  * FIXME: We should process all opened display devices in
536  * IntVideoPortResetDisplayParameters.
537  */
538  ResetDisplayParametersDeviceExtension = DeviceExtension;
540 
541  nErrCode = STATUS_SUCCESS;
542  Irp->IoStatus.Information = piosStack->Parameters.Write.Length;
543  Irp->IoStatus.Status = nErrCode;
545 
546  return nErrCode;
547 }
VOID NTAPI InbvNotifyDisplayOwnershipLost(IN INBV_RESET_DISPLAY_PARAMETERS Callback)
Definition: inbv.c:504
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
struct _VIDEO_PORT_DEVICE_EXTENSTION * PVIDEO_PORT_DEVICE_EXTENSION
BOOLEAN NTAPI IntVideoPortResetDisplayParameters(ULONG Columns, ULONG Rows)
Definition: dispatch.c:42
PVOID DeviceExtension
Definition: env_spec_w32.h:418
#define IoCompleteRequest
Definition: irp.c:1240
PVIDEO_PORT_DEVICE_EXTENSION ResetDisplayParametersDeviceExtension
Definition: dispatch.c:32
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
#define IO_NO_INCREMENT
Definition: iotypes.h:565
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
return STATUS_SUCCESS
Definition: btrfs.c:2777

Referenced by VideoPortInitialize().

◆ IntVideoPortFilterResourceRequirements()

NTSTATUS NTAPI IntVideoPortFilterResourceRequirements ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 77 of file resource.c.

80 {
83  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
84  PVIDEO_ACCESS_RANGE AccessRanges;
85  ULONG AccessRangeCount, ListSize, i;
86  PIO_RESOURCE_REQUIREMENTS_LIST ResList, OldResList = (PVOID)Irp->IoStatus.Information;
87  PIO_RESOURCE_DESCRIPTOR CurrentDescriptor;
89 
90  DriverObject = DeviceObject->DriverObject;
93 
94  Status = IntVideoPortGetLegacyResources(DriverExtension, DeviceExtension, &AccessRanges, &AccessRangeCount);
95  if (!NT_SUCCESS(Status))
96  return Status;
97  if (!AccessRangeCount)
98  {
99  /* No legacy resources to report */
100  return Irp->IoStatus.Information;
101  }
102 
103  /* OK, we've got the access ranges now. Let's set up the resource requirements list */
104 
105  if (OldResList)
106  {
107  /* Already one there so let's add to it */
108  ListSize = OldResList->ListSize + sizeof(IO_RESOURCE_DESCRIPTOR) * AccessRangeCount;
109  ResList = ExAllocatePool(NonPagedPool,
110  ListSize);
111  if (!ResList) return STATUS_NO_MEMORY;
112 
113  RtlCopyMemory(ResList, OldResList, OldResList->ListSize);
114 
115  ASSERT(ResList->AlternativeLists == 1);
116 
117  ResList->ListSize = ListSize;
118  ResList->List[0].Count += AccessRangeCount;
119 
120  CurrentDescriptor = (PIO_RESOURCE_DESCRIPTOR)((PUCHAR)ResList + OldResList->ListSize);
121 
122  ExFreePool(OldResList);
123  Irp->IoStatus.Information = 0;
124  }
125  else
126  {
127  /* We need to make a new one */
128  ListSize = sizeof(IO_RESOURCE_REQUIREMENTS_LIST) + sizeof(IO_RESOURCE_DESCRIPTOR) * (AccessRangeCount - 1);
129  ResList = ExAllocatePool(NonPagedPool,
130  ListSize);
131  if (!ResList) return STATUS_NO_MEMORY;
132 
133  RtlZeroMemory(ResList, ListSize);
134 
135  /* We need to initialize some fields */
136  ResList->ListSize = ListSize;
137  ResList->InterfaceType = DeviceExtension->AdapterInterfaceType;
138  ResList->BusNumber = DeviceExtension->SystemIoBusNumber;
139  ResList->SlotNumber = DeviceExtension->SystemIoSlotNumber;
140  ResList->AlternativeLists = 1;
141  ResList->List[0].Version = 1;
142  ResList->List[0].Revision = 1;
143  ResList->List[0].Count = AccessRangeCount;
144 
145  CurrentDescriptor = ResList->List[0].Descriptors;
146  }
147 
148  for (i = 0; i < AccessRangeCount; i++)
149  {
150  /* This is a required resource */
151  CurrentDescriptor->Option = 0;
152 
153  if (AccessRanges[i].RangeInIoSpace)
154  CurrentDescriptor->Type = CmResourceTypePort;
155  else
156  CurrentDescriptor->Type = CmResourceTypeMemory;
157 
158  CurrentDescriptor->ShareDisposition =
160 
161  CurrentDescriptor->Flags = 0;
162 
163  if (CurrentDescriptor->Type == CmResourceTypePort)
164  {
165  CurrentDescriptor->u.Port.Length = AccessRanges[i].RangeLength;
166  CurrentDescriptor->u.Port.MinimumAddress =
167  CurrentDescriptor->u.Port.MaximumAddress = AccessRanges[i].RangeStart;
168  CurrentDescriptor->u.Port.Alignment = 1;
169  if (AccessRanges[i].RangePassive & VIDEO_RANGE_PASSIVE_DECODE)
170  CurrentDescriptor->Flags |= CM_RESOURCE_PORT_PASSIVE_DECODE;
171  if (AccessRanges[i].RangePassive & VIDEO_RANGE_10_BIT_DECODE)
172  CurrentDescriptor->Flags |= CM_RESOURCE_PORT_10_BIT_DECODE;
173  }
174  else
175  {
176  CurrentDescriptor->u.Memory.Length = AccessRanges[i].RangeLength;
177  CurrentDescriptor->u.Memory.MinimumAddress =
178  CurrentDescriptor->u.Memory.MaximumAddress = AccessRanges[i].RangeStart;
179  CurrentDescriptor->u.Memory.Alignment = 1;
180  CurrentDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_WRITE;
181  }
182 
183  CurrentDescriptor++;
184  }
185 
186  Irp->IoStatus.Information = (ULONG_PTR)ResList;
187 
188  return STATUS_SUCCESS;
189 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
NTSTATUS NTAPI IntVideoPortGetLegacyResources(IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, IN PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension, OUT PVIDEO_ACCESS_RANGE *AccessRanges, OUT PULONG AccessRangeCount)
Definition: resource.c:30
_In_ PIRP Irp
Definition: csq.h:116
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
struct _VIDEO_PORT_DEVICE_EXTENSTION * PVIDEO_PORT_DEVICE_EXTENSION
struct _IO_RESOURCE_REQUIREMENTS_LIST IO_RESOURCE_REQUIREMENTS_LIST
#define CM_RESOURCE_MEMORY_READ_WRITE
Definition: cmtypes.h:120
#define CmResourceTypePort
Definition: hwresource.cpp:123
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 VIDEO_RANGE_PASSIVE_DECODE
Definition: video.h:98
INTERFACE_TYPE InterfaceType
Definition: iotypes.h:2387
PVOID DeviceExtension
Definition: env_spec_w32.h:418
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
#define VIDEO_RANGE_10_BIT_DECODE
Definition: video.h:99
void * PVOID
Definition: retypes.h:9
#define CM_RESOURCE_PORT_10_BIT_DECODE
Definition: cmtypes.h:110
struct _IO_RESOURCE_DESCRIPTOR * PIO_RESOURCE_DESCRIPTOR
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define CM_RESOURCE_PORT_PASSIVE_DECODE
Definition: cmtypes.h:114
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
UCHAR RangeShareable
Definition: video.h:219
IO_RESOURCE_LIST List[1]
Definition: iotypes.h:2392
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1842
IO_RESOURCE_DESCRIPTOR Descriptors[1]
Definition: iotypes.h:2382
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
Status
Definition: gdiplustypes.h:24
struct _IO_RESOURCE_DESCRIPTOR IO_RESOURCE_DESCRIPTOR
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
struct _LARGE_INTEGER::@2196 u
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ULONG_PTR
Definition: config.h:101
#define CmResourceTypeMemory
Definition: hwresource.cpp:125
INTERFACE_TYPE AdapterInterfaceType
Definition: videoprt.h:95
return STATUS_SUCCESS
Definition: btrfs.c:2777
ULONG RangeLength
Definition: video.h:216
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
PHYSICAL_ADDRESS RangeStart
Definition: video.h:215

Referenced by IntVideoPortDispatchFdoPnp().

◆ IntVideoPortFindAdapter()

NTSTATUS NTAPI IntVideoPortFindAdapter ( IN PDRIVER_OBJECT  DriverObject,
IN PVIDEO_PORT_DRIVER_EXTENSION  DriverExtension,
IN PDEVICE_OBJECT  DeviceObject 
)

Definition at line 247 of file videoprt.c.

251 {
252  WCHAR DeviceVideoBuffer[20];
253  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
255  VIDEO_PORT_CONFIG_INFO ConfigInfo;
257  UCHAR Again = FALSE;
258  WCHAR DeviceBuffer[20];
260  WCHAR SymlinkBuffer[20];
261  UNICODE_STRING SymlinkName;
262  BOOL LegacyDetection = FALSE;
264 
266  DeviceNumber = DeviceExtension->DeviceNumber;
267 
268  /* Setup a ConfigInfo structure that we will pass to HwFindAdapter. */
269  RtlZeroMemory(&ConfigInfo, sizeof(VIDEO_PORT_CONFIG_INFO));
270  ConfigInfo.Length = sizeof(VIDEO_PORT_CONFIG_INFO);
271  ConfigInfo.AdapterInterfaceType = DeviceExtension->AdapterInterfaceType;
272  if (ConfigInfo.AdapterInterfaceType == PCIBus)
273  ConfigInfo.InterruptMode = LevelSensitive;
274  else
275  ConfigInfo.InterruptMode = Latched;
276  ConfigInfo.DriverRegistryPath = DriverExtension->RegistryPath.Buffer;
278  ConfigInfo.SystemIoBusNumber = DeviceExtension->SystemIoBusNumber;
279  ConfigInfo.BusInterruptLevel = DeviceExtension->InterruptLevel;
280  ConfigInfo.BusInterruptVector = DeviceExtension->InterruptVector;
281 
284  sizeof(SystemBasicInfo),
285  NULL);
286  if (NT_SUCCESS(Status))
287  {
290  }
291 
292  /*
293  * Call miniport HwVidFindAdapter entry point to detect if
294  * particular device is present. There are two possible code
295  * paths. The first one is for Legacy drivers (NT4) and cases
296  * when we don't have information about what bus we're on. The
297  * second case is the standard one for Plug & Play drivers.
298  */
299  if (DeviceExtension->PhysicalDeviceObject == NULL)
300  {
301  LegacyDetection = TRUE;
302  }
303 
304  if (LegacyDetection)
305  {
306  ULONG BusNumber, MaxBuses;
307 
308  MaxBuses = DeviceExtension->AdapterInterfaceType == PCIBus ? PCI_MAX_BRIDGE_NUMBER : 1;
309 
310  for (BusNumber = 0; BusNumber < MaxBuses; BusNumber++)
311  {
312  DeviceExtension->SystemIoBusNumber =
313  ConfigInfo.SystemIoBusNumber = BusNumber;
314 
315  RtlZeroMemory(&DeviceExtension->MiniPortDeviceExtension,
316  DriverExtension->InitializationData.HwDeviceExtensionSize);
317 
318  /* FIXME: Need to figure out what string to pass as param 3. */
319  Status = DriverExtension->InitializationData.HwFindAdapter(
320  &DeviceExtension->MiniPortDeviceExtension,
321  DriverExtension->HwContext,
322  NULL,
323  &ConfigInfo,
324  &Again);
325 
327  {
328  continue;
329  }
330  else if (Status == NO_ERROR)
331  {
332  break;
333  }
334  else
335  {
336  ERR_(VIDEOPRT, "HwFindAdapter call failed with error 0x%X\n", Status);
337  goto Failure;
338  }
339  }
340  }
341  else
342  {
343  /* FIXME: Need to figure out what string to pass as param 3. */
344  Status = DriverExtension->InitializationData.HwFindAdapter(
345  &DeviceExtension->MiniPortDeviceExtension,
346  DriverExtension->HwContext,
347  NULL,
348  &ConfigInfo,
349  &Again);
350  }
351 
352  if (Status != NO_ERROR)
353  {
354  ERR_(VIDEOPRT, "HwFindAdapter call failed with error 0x%X\n", Status);
355  goto Failure;
356  }
357 
358  /*
359  * Now we know the device is present, so let's do all additional tasks
360  * such as creating symlinks or setting up interrupts and timer.
361  */
362 
363  /* Create a unicode device name. */
364  swprintf(DeviceBuffer, L"\\Device\\Video%lu", DeviceNumber);
365  RtlInitUnicodeString(&DeviceName, DeviceBuffer);
366 
367  /* Create symbolic link "\??\DISPLAYx" */
368  swprintf(SymlinkBuffer, L"\\??\\DISPLAY%lu", DeviceNumber + 1);
369  RtlInitUnicodeString(&SymlinkName, SymlinkBuffer);
370  IoCreateSymbolicLink(&SymlinkName, &DeviceName);
371 
372  /* Add entry to DEVICEMAP\VIDEO key in registry. */
373  swprintf(DeviceVideoBuffer, L"\\Device\\Video%d", DeviceNumber);
376  L"VIDEO",
377  DeviceVideoBuffer,
378  REG_SZ,
379  DeviceExtension->RegistryPath.Buffer,
380  DeviceExtension->RegistryPath.Length + sizeof(UNICODE_NULL));
381 
384  L"VIDEO",
385  L"MaxObjectNumber",
386  REG_DWORD,
387  &DeviceNumber,
388  sizeof(DeviceNumber));
389 
390  /* FIXME: Allocate hardware resources for device. */
391 
392  /* Allocate interrupt for device. */
394  {
396  goto Failure;
397  }
398 
399  /* Allocate timer for device. */
401  {
402  if (DeviceExtension->InterruptObject != NULL)
403  IoDisconnectInterrupt(DeviceExtension->InterruptObject);
404  ERR_(VIDEOPRT, "IntVideoPortSetupTimer failed\n");
406  goto Failure;
407  }
408 
409  /* Query children of the device. */
411 
412  INFO_(VIDEOPRT, "STATUS_SUCCESS\n");
413  return STATUS_SUCCESS;
414 
415 Failure:
416  RtlFreeUnicodeString(&DeviceExtension->RegistryPath);
417  if (DeviceExtension->NextDeviceObject)
418  IoDetachDevice(DeviceExtension->NextDeviceObject);
420  return Status;
421 }
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define PCI_MAX_BRIDGE_NUMBER
Definition: iotypes.h:3243
#define INFO_(ch,...)
Definition: debug.h:159
BOOLEAN NTAPI IntVideoPortSetupTimer(IN PDEVICE_OBJECT DeviceObject, IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension)
Definition: timer.c:43
#define ERR_(ch,...)
Definition: debug.h:156
LONG NTSTATUS
Definition: precomp.h:26
struct _VIDEO_PORT_DEVICE_EXTENSTION * PVIDEO_PORT_DEVICE_EXTENSION
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1295
WCHAR DeviceName[]
Definition: adapter.cpp:21
#define NO_ERROR
Definition: dderror.h:5
INTERFACE_TYPE AdapterInterfaceType
Definition: video.h:169
PVOID NTAPI IntVideoPortGetProcAddress(IN PVOID HwDeviceExtension, IN PUCHAR FunctionName)
Definition: funclist.c:100
#define UNICODE_NULL
unsigned int BOOL
Definition: ntddk_ex.h:94
PDEVICE_OBJECT PhysicalDeviceObject
Definition: videoprt.h:84
VP_STATUS NTAPI VideoPortEnumerateChildren(IN PVOID HwDeviceExtension, IN PVOID Reserved)
Definition: videoprt.c:986
NTSYSAPI NTSTATUS NTAPI ZwQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
PVIDEO_PORT_GET_PROC_ADDRESS VideoPortGetProcAddress
Definition: video.h:193
VOID NTAPI IoDisconnectInterrupt(PKINTERRUPT InterruptObject)
Definition: irq.c:140
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:156
ULONGLONG SystemMemorySize
Definition: video.h:195
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
SYSTEM_BASIC_INFORMATION SystemBasicInfo
Definition: perfdata.c:45
#define swprintf(buf, format,...)
Definition: sprintf.c:56
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
struct _VIDEO_PORT_CONFIG_INFO VIDEO_PORT_CONFIG_INFO
unsigned char UCHAR
Definition: xmlstorage.h:181
NTSYSAPI NTSTATUS WINAPI RtlWriteRegistryValue(ULONG, PCWSTR, PCWSTR, ULONG, PVOID, ULONG)
static const WCHAR L[]
Definition: oid.c:1250
PWSTR DriverRegistryPath
Definition: video.h:194
PDEVICE_OBJECT NextDeviceObject
Definition: videoprt.h:86
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1250
BOOLEAN NTAPI IntVideoPortSetupInterrupt(IN PDEVICE_OBJECT DeviceObject, IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, IN PVIDEO_PORT_CONFIG_INFO ConfigInfo)
Definition: interrupt.c:45
#define SystemBasicInformation
Definition: xboxvmp.h:35
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
UNICODE_STRING RegistryPath
Definition: videoprt.h:87
_In_ PCHAR _In_ ULONG DeviceNumber
Definition: classpnp.h:1036
#define RTL_REGISTRY_DEVICEMAP
Definition: nt_native.h:165
INTERFACE_TYPE AdapterInterfaceType
Definition: videoprt.h:95
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define REG_DWORD
Definition: sdbapi.c:596
#define ERROR_DEV_NOT_EXIST
Definition: dderror.h:8
ULONG BusInterruptVector
Definition: video.h:171
KINTERRUPT_MODE InterruptMode
Definition: video.h:172
#define REG_SZ
Definition: layer.c:22

Referenced by IntVideoPortPnPStartDevice(), and VideoPortInitialize().

◆ IntVideoPortGetProcAddress()

PVOID NTAPI IntVideoPortGetProcAddress ( IN PVOID  HwDeviceExtension,
IN PUCHAR  FunctionName 
)

Definition at line 100 of file funclist.c.

103 {
104  ULONG i;
105 
106  TRACE_(VIDEOPRT, "VideoPortGetProcAddress(%s)\n", FunctionName);
107 
108  /* Search by name */
109  for (i = 0; i < ARRAYSIZE(VideoPortExports); i++)
110  {
112  {
113  return (PVOID)VideoPortExports[i].Address;
114  }
115  }
116 
117  ERR_(VIDEOPRT, "VideoPortGetProcAddress: Can't resolve symbol %s\n", FunctionName);
118 
119  return NULL;
120 }
signed char * PCHAR
Definition: retypes.h:7
#define ERR_(ch,...)
Definition: debug.h:156
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
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
smooth NULL
Definition: ftsmooth.c:416
#define TRACE_(x)
Definition: compat.h:66
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char * FunctionName
Definition: acpixf.h:1252
const VIDEO_PORT_FUNCTION_TABLE VideoPortExports[]
Definition: funclist.c:36
unsigned int ULONG
Definition: retypes.h:1
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

Referenced by IntVideoPortFindAdapter().

◆ IntVideoPortMapPhysicalMemory()

NTSTATUS NTAPI IntVideoPortMapPhysicalMemory ( IN HANDLE  Process,
IN PHYSICAL_ADDRESS  PhysicalAddress,
IN ULONG  SizeInBytes,
IN ULONG  Protect,
IN OUT PVOID *VirtualAddress  OPTIONAL 
)

Definition at line 192 of file resource.c.

198 {
199  OBJECT_ATTRIBUTES ObjAttribs;
201  HANDLE hMemObj;
203  SIZE_T Size;
204 
205  /* Initialize object attribs */
206  RtlInitUnicodeString(&UnicodeString, L"\\Device\\PhysicalMemory");
207  InitializeObjectAttributes(&ObjAttribs,
208  &UnicodeString,
210  NULL, NULL);
211 
212  /* Open physical memory section */
213  Status = ZwOpenSection(&hMemObj, SECTION_ALL_ACCESS, &ObjAttribs);
214  if (!NT_SUCCESS(Status))
215  {
216  WARN_(VIDEOPRT, "ZwOpenSection() failed! (0x%x)\n", Status);
217  return Status;
218  }
219 
220  /* Map view of section */
221  Size = SizeInBytes;
222  Status = ZwMapViewOfSection(hMemObj,
223  Process,
225  0,
226  Size,
228  &Size,
229  ViewUnmap,
230  0,
231  Protect);
232  ZwClose(hMemObj);
233  if (!NT_SUCCESS(Status))
234  {
235  WARN_(VIDEOPRT, "ZwMapViewOfSection() failed! (0x%x)\n", Status);
236  }
237 
238  return Status;
239 }
*BytesInUnicodeString PWCH UnicodeString
Definition: rtlfuncs.h:1980
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T _In_ SECTION_INHERIT _In_ ULONG _In_ ULONG Protect
Definition: zwfuncs.h:214
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
LONG NTSTATUS
Definition: precomp.h:26
#define SECTION_ALL_ACCESS
Definition: nt_native.h:1293
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1060
static const WCHAR L[]
Definition: oid.c:1250
_In_ ULONG _In_ BOOLEAN _Must_inspect_result_ PVOID * VirtualAddress
Definition: ndis.h:3791
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
Status
Definition: gdiplustypes.h:24
ULONG_PTR SIZE_T
Definition: typedefs.h:78
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
NTSYSAPI NTSTATUS NTAPI ZwOpenSection(_Out_ PHANDLE SectionHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes)
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define WARN_(ch,...)
Definition: debug.h:157

Referenced by IntAgpCommitVirtual(), and IntVideoPortMapMemory().

◆ IntVideoPortSetupInterrupt()

BOOLEAN NTAPI IntVideoPortSetupInterrupt ( IN PDEVICE_OBJECT  DeviceObject,
IN PVIDEO_PORT_DRIVER_EXTENSION  DriverExtension,
IN PVIDEO_PORT_CONFIG_INFO  ConfigInfo 
)

Definition at line 45 of file interrupt.c.

49 {
51  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
52 
54 
55  /*
56  * MSDN documentation for VIDEO_PORT_CONFIG_INFO states: "If a miniport driver's
57  * HwVidFindAdapter function finds that the video adapter does not generate
58  * interrupts or that it cannot determine a valid interrupt vector/level for
59  * the adapter, HwVidFindAdapter should set both BusInterruptVector and
60  * BusInterruptLevel to zero.
61  */
62 
63  if (DriverExtension->InitializationData.HwInterrupt != NULL &&
64  (ConfigInfo->BusInterruptLevel != 0 ||
65  ConfigInfo->BusInterruptVector != 0))
66  {
67  ULONG InterruptVector;
68  KIRQL Irql;
70 
71  InterruptVector = HalGetInterruptVector(
72  ConfigInfo->AdapterInterfaceType,
73  ConfigInfo->SystemIoBusNumber,
74  ConfigInfo->BusInterruptLevel,
75  ConfigInfo->BusInterruptVector,
76  &Irql,
77  &Affinity);
78 
79  if (InterruptVector == 0)
80  {
81  WARN_(VIDEOPRT, "HalGetInterruptVector failed\n");
82  return FALSE;
83  }
84 
85  KeInitializeSpinLock(&DeviceExtension->InterruptSpinLock);
87  &DeviceExtension->InterruptObject,
89  DeviceExtension,
90  &DeviceExtension->InterruptSpinLock,
91  InterruptVector,
92  Irql,
93  Irql,
94  ConfigInfo->InterruptMode,
95  DeviceExtension->InterruptShared,
96  Affinity,
97  FALSE);
98 
99  if (!NT_SUCCESS(Status))
100  {
101  WARN_(VIDEOPRT, "IoConnectInterrupt failed with status 0x%08x\n", Status);
102  return FALSE;
103  }
104  }
105 
106  return TRUE;
107 }
#define TRUE
Definition: types.h:120
NTHALAPI ULONG NTAPI HalGetInterruptVector(INTERFACE_TYPE, ULONG, ULONG, ULONG, PKIRQL, PKAFFINITY)
LONG NTSTATUS
Definition: precomp.h:26
struct _VIDEO_PORT_DEVICE_EXTENSTION * PVIDEO_PORT_DEVICE_EXTENSION
_Out_ PKIRQL Irql
Definition: csq.h:179
UCHAR KIRQL
Definition: env_spec_w32.h:591
NTSTATUS NTAPI IoConnectInterrupt(OUT PKINTERRUPT *InterruptObject, IN PKSERVICE_ROUTINE ServiceRoutine, IN PVOID ServiceContext, IN PKSPIN_LOCK SpinLock, IN ULONG Vector, IN KIRQL Irql, IN KIRQL SynchronizeIrql, IN KINTERRUPT_MODE InterruptMode, IN BOOLEAN ShareVector, IN KAFFINITY ProcessorEnableMask, IN BOOLEAN FloatingSave)
Definition: irq.c:22
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN NTAPI IntVideoPortInterruptRoutine(IN struct _KINTERRUPT *Interrupt, IN PVOID ServiceContext)
Definition: interrupt.c:32
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ ULONG _In_ ULONG _In_ ULONG _Out_ PKIRQL _Out_ PKAFFINITY Affinity
Definition: halfuncs.h:170
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
ULONG_PTR KAFFINITY
Definition: compat.h:75
unsigned int ULONG
Definition: retypes.h:1
#define WARN_(ch,...)
Definition: debug.h:157

Referenced by IntVideoPortFindAdapter().

◆ IntVideoPortSetupTimer()

BOOLEAN NTAPI IntVideoPortSetupTimer ( IN PDEVICE_OBJECT  DeviceObject,
IN PVIDEO_PORT_DRIVER_EXTENSION  DriverExtension 
)

Definition at line 43 of file timer.c.

46 {
48  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
49 
51 
52  if (DriverExtension->InitializationData.HwTimer != NULL)
53  {
54  INFO_(VIDEOPRT, "Initializing timer\n");
55 
59  DeviceExtension);
60 
61  if (!NT_SUCCESS(Status))
62  {
63  ERR_(VIDEOPRT, "IoInitializeTimer failed with status 0x%08x\n", Status);
64  return FALSE;
65  }
66  }
67 
68  return TRUE;
69 }
#define TRUE
Definition: types.h:120
#define INFO_(ch,...)
Definition: debug.h:159
#define ERR_(ch,...)
Definition: debug.h:156
LONG NTSTATUS
Definition: precomp.h:26
struct _VIDEO_PORT_DEVICE_EXTENSTION * PVIDEO_PORT_DEVICE_EXTENSION
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI IntVideoPortTimerRoutine(IN PDEVICE_OBJECT DeviceObject, IN PVOID ServiceContext)
Definition: timer.c:30
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI IoInitializeTimer(IN PDEVICE_OBJECT DeviceObject, IN PIO_TIMER_ROUTINE TimerRoutine, IN PVOID Context)
Definition: iotimer.c:92
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560

Referenced by IntVideoPortFindAdapter().

◆ IntVideoPortUnload()

VOID NTAPI IntVideoPortUnload ( PDRIVER_OBJECT  DriverObject)

Definition at line 886 of file dispatch.c.

887 {
888 }

Referenced by VideoPortInitialize().

◆ IopInitiatePnpIrp()

NTSTATUS IopInitiatePnpIrp ( PDEVICE_OBJECT  DeviceObject,
PIO_STATUS_BLOCK  IoStatusBlock,
UCHAR  MinorFunction,
PIO_STACK_LOCATION Stack  OPTIONAL 
)

Definition at line 30 of file agp.c.

35 {
36  PDEVICE_OBJECT TopDeviceObject;
39  KEVENT Event;
40  PIRP Irp;
41 
42  /* Always call the top of the device stack */
43  TopDeviceObject = IoGetAttachedDeviceReference(DeviceObject);
44 
46  &Event,
48  FALSE);
49 
51  IRP_MJ_PNP,
52  TopDeviceObject,
53  NULL,
54  0,
55  NULL,
56  &Event,
58 
59  /* PNP IRPs are always initialized with a status code of
60  STATUS_NOT_SUPPORTED */
61  Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
62  Irp->IoStatus.Information = 0;
63 
66 
67  if (Stack)
68  {
70  &IrpSp->Parameters,
71  &Stack->Parameters,
72  sizeof(Stack->Parameters));
73  }
74 
75  Status = IoCallDriver(TopDeviceObject, Irp);
76  if (Status == STATUS_PENDING)
77  {
79  &Event,
80  Executive,
81  KernelMode,
82  FALSE,
83  NULL);
85  }
86 
87  ObDereferenceObject(TopDeviceObject);
88 
89  return Status;
90 }
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
_In_ PIRP Irp
Definition: csq.h:116
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
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 RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:434
smooth NULL
Definition: ftsmooth.c:416
PDEVICE_OBJECT NTAPI IoGetAttachedDeviceReference(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1405
#define STATUS_PENDING
Definition: ntstatus.h:82
_In_ UCHAR MinorFunction
Definition: pofuncs.h:42
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771

Referenced by IntAgpGetInterface().

Variable Documentation

◆ Csrss

PKPROCESS Csrss

Definition at line 34 of file videoprt.c.

Referenced by IntAttachToCSRSS(), IntDetachFromCSRSS(), and IntVideoPortDispatchOpen().

◆ CsrssInitialized

ULONG CsrssInitialized

Definition at line 33 of file videoprt.c.

Referenced by IntVideoPortDispatchOpen(), and VideoPortInt10().

◆ VideoPortDeviceNumber

ULONG VideoPortDeviceNumber

◆ VideoPortInt10Mutex

KMUTEX VideoPortInt10Mutex

Definition at line 36 of file videoprt.c.

Referenced by VideoPortInitialize(), and VideoPortInt10().