ReactOS  0.4.15-dev-1377-ga59cecd
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 <pseh/pseh2.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)
 
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_opt_ PDEVICE_OBJECT PhysicalDeviceObject, _Out_opt_ PDEVICE_OBJECT *DeviceObject)
 
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

PKPROCESS CsrProcess
 
ULONG VideoPortDeviceNumber
 
KMUTEX VideoPortInt10Mutex
 
KSPIN_LOCK HwResetAdaptersLock
 
LIST_ENTRY HwResetAdaptersList
 

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 42 of file videoprt.h.

◆ TAG_REQUEST_PACKET

#define TAG_REQUEST_PACKET   'qRpV'

Definition at line 40 of file videoprt.h.

◆ TAG_VIDEO_PORT

#define TAG_VIDEO_PORT   'PDIV'

Definition at line 38 of file videoprt.h.

◆ TAG_VIDEO_PORT_BUFFER

#define TAG_VIDEO_PORT_BUFFER   '\0mpV'

Definition at line 39 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 131 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 137 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:137
AGP_BUS_INTERFACE_STANDARD AgpInterface
Definition: videoprt.h:105
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
PINTERFACE_REFERENCE InterfaceReference
Definition: ntagp.h:183
struct _INTERFACE * PINTERFACE
Status
Definition: gdiplustypes.h:24
#define ASSERT(a)
Definition: mode.c:45
#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
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
PDEVICE_OBJECT NextDeviceObject
Definition: videoprt.h:89
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
OUT PAGP_RELEASE_VIRTUAL AgpReleaseVirtual
Definition: video.h:741
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:361
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define NULL
Definition: types.h:112
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
#define STATUS_SUCCESS
Definition: shellext.h:65
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:3107
PVOID NTAPI IntAgpReserveVirtual(IN PVOID HwDeviceExtension, IN HANDLE ProcessHandle, IN PVOID PhysicalContext, OUT PVOID *VirtualContext)
Definition: agp.c:419
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 443 of file videoprt.c.

446 {
447  *CallingProcess = (PKPROCESS)PsGetCurrentProcess();
448  if (*CallingProcess != CsrProcess)
449  {
451  }
452 }
PKPROCESS CsrProcess
Definition: videoprt.c:39
VOID NTAPI KeStackAttachProcess(IN PKPROCESS Process, OUT PRKAPC_STATE ApcState)
Definition: procobj.c:701
#define PsGetCurrentProcess
Definition: psfuncs.h:17
struct _KPROCESS * PKPROCESS
Definition: wdm.template.h:206
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1484

Referenced by IntInt10AllocateBuffer(), IntInt10CallBios(), IntInt10FreeBuffer(), IntInt10ReadMemory(), IntInt10WriteMemory(), and VideoPortGetRomImage().

◆ IntCopyRegistryKey()

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

Definition at line 30 of file registry.c.

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

233 {
234  PKEY_VALUE_PARTIAL_INFORMATION ValueInformation;
235  UNICODE_STRING ValueNameString;
236  ULONG Length;
238 
239  RtlInitUnicodeString(&ValueNameString, ValueName);
240 
241  /* Query the value length */
242  Status = ZwQueryValueKey(SourceKeyHandle,
243  &ValueNameString,
245  NULL,
246  0,
247  &Length);
248  if ((Status != STATUS_BUFFER_OVERFLOW) &&
250  {
251  /* The key seems not present */
253  return Status;
254  }
255 
256  /* Allocate a buffer */
258  if (ValueInformation == NULL)
259  {
260  return Status;
261  }
262 
263  /* Query the value */
264  Status = ZwQueryValueKey(SourceKeyHandle,
265  &ValueNameString,
267  ValueInformation,
268  Length,
269  &Length);
270  if (!NT_SUCCESS(Status))
271  {
272  ExFreePoolWithTag(ValueInformation, TAG_VIDEO_PORT_BUFFER);
273  return Status;
274  }
275 
276  /* Write the registry value */
277  Status = ZwSetValueKey(DestKeyHandle,
278  &ValueNameString,
279  ValueInformation->TitleIndex,
280  ValueInformation->Type,
281  ValueInformation->Data,
282  ValueInformation->DataLength);
283 
284  ExFreePoolWithTag(ValueInformation, TAG_VIDEO_PORT_BUFFER);
285 
286  if (!NT_SUCCESS(Status))
287  {
288  ERR_(VIDEOPRT, "ZwSetValueKey failed: status 0x%lx\n", Status);
289  }
290 
291  return Status;
292 }
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define ERR_(ch,...)
Definition: debug.h:156
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define TAG_VIDEO_PORT_BUFFER
Definition: videoprt.h:39
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:240
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define NULL
Definition: types.h:112
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 357 of file registry.c.

359 {
360  static UNICODE_STRING VideoIdValueName = RTL_CONSTANT_STRING(L"VideoId");
361  static UNICODE_STRING ControlVideoPathName =
362  RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Video\\");
363  HANDLE DevInstRegKey, SettingsKey, NewKey;
364  UCHAR VideoIdBuffer[sizeof(KEY_VALUE_PARTIAL_INFORMATION) + GUID_STRING_LENGTH];
365  UNICODE_STRING VideoIdString;
366  UUID VideoId;
367  PKEY_VALUE_PARTIAL_INFORMATION ValueInformation ;
370  USHORT KeyMaxLength;
372 
373  /* Open the hardware key: HKLM\System\CurrentControlSet\Enum\... */
377  &DevInstRegKey);
378  if (Status != STATUS_SUCCESS)
379  {
380  ERR_(VIDEOPRT, "IoOpenDeviceRegistryKey failed: status 0x%lx\n", Status);
381  return Status;
382  }
383 
384  /* Query the VideoId value */
385  ValueInformation = (PKEY_VALUE_PARTIAL_INFORMATION)VideoIdBuffer;
386  Status = ZwQueryValueKey(DevInstRegKey,
387  &VideoIdValueName,
389  ValueInformation,
390  sizeof(VideoIdBuffer),
391  &ResultLength);
392  if (!NT_SUCCESS(Status))
393  {
394  /* Create a new video Id */
395  Status = ExUuidCreate(&VideoId);
396  if (!NT_SUCCESS(Status))
397  {
398  ERR_(VIDEOPRT, "ExUuidCreate failed: status 0x%lx\n", Status);
400  return Status;
401  }
402 
403  /* Convert the GUID into a string */
404  Status = RtlStringFromGUID(&VideoId, &VideoIdString);
405  if (!NT_SUCCESS(Status))
406  {
407  ERR_(VIDEOPRT, "RtlStringFromGUID failed: status 0x%lx\n", Status);
409  return Status;
410  }
411 
412  /* Copy the GUID String to our buffer */
413  ValueInformation->DataLength = min(VideoIdString.Length, GUID_STRING_LENGTH);
414  RtlCopyMemory(ValueInformation->Data,
415  VideoIdString.Buffer,
416  ValueInformation->DataLength);
417 
418  /* Free the GUID string */
419  RtlFreeUnicodeString(&VideoIdString);
420 
421  /* Write the VideoId registry value */
422  Status = ZwSetValueKey(DevInstRegKey,
423  &VideoIdValueName,
424  0,
425  REG_SZ,
426  ValueInformation->Data,
427  ValueInformation->DataLength);
428  if (!NT_SUCCESS(Status))
429  {
430  ERR_(VIDEOPRT, "ZwSetValueKey failed: status 0x%lx\n", Status);
432  return Status;
433  }
434  }
435 
436  /* Initialize the VideoId string from the registry data */
437  VideoIdString.Buffer = (PWCHAR)ValueInformation->Data;
438  VideoIdString.Length = (USHORT)ValueInformation->DataLength;
439  VideoIdString.MaximumLength = VideoIdString.Length;
440 
441  /* Close the hardware key */
443 
444  /* Calculate the size needed for the new registry path name */
445  KeyMaxLength = ControlVideoPathName.Length +
446  VideoIdString.Length +
447  sizeof(L"\\0000");
448 
449  /* Allocate the path name buffer */
450  DeviceExtension->NewRegistryPath.Length = 0;
451  DeviceExtension->NewRegistryPath.MaximumLength = KeyMaxLength;
453  KeyMaxLength,
455  if (DeviceExtension->NewRegistryPath.Buffer == NULL)
456  {
457  ERR_(VIDEOPRT, "Failed to allocate key name buffer.\n");
459  }
460 
461  /* Copy the root key name and append the VideoId string */
462  RtlCopyUnicodeString(&DeviceExtension->NewRegistryPath,
463  &ControlVideoPathName);
465  &VideoIdString);
466 
467  /* Check if we have the key already */
469  DeviceExtension->NewRegistryPath.Buffer);
470  if (Status != STATUS_SUCCESS)
471  {
472  /* Try to create the new key */
474  DeviceExtension->NewRegistryPath.Buffer);
475  }
476 
477  /* Append a the instance path */
478  RtlAppendUnicodeToString(&DeviceExtension->NewRegistryPath, L"\\");
479  RtlAppendUnicodeToString(&DeviceExtension->NewRegistryPath, L"0000");
480 
481  /* Check this key again */
483  DeviceExtension->NewRegistryPath.Buffer);
484  if (Status != STATUS_SUCCESS)
485  {
486  /* Try to create the new key */
488  DeviceExtension->NewRegistryPath.Buffer);
489  if (!NT_SUCCESS(Status))
490  {
491  ERR_(VIDEOPRT, "Failed create key '%wZ'\n", &DeviceExtension->NewRegistryPath);
492  return Status;
493  }
494 
495  /* Open the new key */
497  &DeviceExtension->NewRegistryPath,
499  NULL,
500  NULL);
501  Status = ZwOpenKey(&NewKey, KEY_READ, &ObjectAttributes);
502  if (!NT_SUCCESS(Status))
503  {
504  ERR_(VIDEOPRT, "Failed to open settings key. Status 0x%lx\n", Status);
505  return Status;
506  }
507 
508  /* Open the device profile key */
510  &DeviceExtension->RegistryPath,
512  NULL,
513  NULL);
514  Status = ZwOpenKey(&SettingsKey, KEY_READ, &ObjectAttributes);
515  if (!NT_SUCCESS(Status))
516  {
517  ERR_(VIDEOPRT, "Failed to open settings key. Status 0x%lx\n", Status);
518  ObCloseHandle(NewKey, KernelMode);
519  return Status;
520  }
521 
522  /* Copy the registry data from the legacy key */
523  Status = IntCopyRegistryKey(SettingsKey, NewKey);
524  }
525 
526 
527  return Status;
528 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
UNICODE_STRING NewRegistryPath
Definition: videoprt.h:91
#define TAG_VIDEO_PORT
Definition: videoprt.h:38
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define PLUGPLAY_REGKEY_DEVICE
Definition: iofuncs.h:2782
#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:56
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
PDEVICE_OBJECT PhysicalDeviceObject
Definition: videoprt.h:87
NTSTATUS NTAPI IntCopyRegistryKey(_In_ HANDLE SourceKeyHandle, _In_ HANDLE DestKeyHandle)
Definition: registry.c:30
NTKERNELAPI NTSTATUS ExUuidCreate(OUT UUID *Uuid)
Definition: uuid.c:379
Status
Definition: gdiplustypes.h:24
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 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
#define RTL_REGISTRY_ABSOLUTE
Definition: nt_native.h:161
_In_ ULONG _In_ ACCESS_MASK _Out_ PHANDLE DevInstRegKey
Definition: iofuncs.h:1123
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)
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
#define min(a, b)
Definition: monoChain.cc:55
#define NULL
Definition: types.h:112
NTSTATUS NTAPI IoOpenDeviceRegistryKey(IN PDEVICE_OBJECT DeviceObject, IN ULONG DevInstKeyType, IN ACCESS_MASK DesiredAccess, OUT PHANDLE DevInstRegKey)
Definition: pnpmgr.c:2335
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
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
UNICODE_STRING RegistryPath
Definition: videoprt.h:90
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3776
#define STATUS_SUCCESS
Definition: shellext.h:65
NTSTATUS NTAPI RtlCreateRegistryKey(IN ULONG RelativeTo, IN PWSTR Path)
Definition: registry.c:607
#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 532 of file registry.c.

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

Referenced by IntVideoPortCreateAdapterDeviceObject().

◆ IntDetachFromCSRSS()

VOID FASTCALL IntDetachFromCSRSS ( PKPROCESS CallingProcess,
PKAPC_STATE  ApcState 
)

Definition at line 456 of file videoprt.c.

459 {
460  if (*CallingProcess != CsrProcess)
461  {
463  }
464 }
PKPROCESS CsrProcess
Definition: videoprt.c:39
VOID NTAPI KeUnstackDetachProcess(IN PRKAPC_STATE ApcState)
Definition: procobj.c:753
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1484

Referenced by IntInt10AllocateBuffer(), IntInt10CallBios(), IntInt10FreeBuffer(), IntInt10ReadMemory(), IntInt10WriteMemory(), and VideoPortGetRomImage().

◆ IntInitializeVideoAddressSpace()

NTSTATUS NTAPI IntInitializeVideoAddressSpace ( VOID  )

Definition at line 146 of file int10.c.

147 {
149  NT_ASSERT(FALSE);
150  return STATUS_NOT_IMPLEMENTED;
151 }
return STATUS_NOT_IMPLEMENTED
#define FALSE
Definition: types.h:117
#define UNIMPLEMENTED
Definition: debug.h:115
#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 
)

Definition at line 156 of file int10.c.

161 {
163 #ifdef _M_IX86
164  PVOID MemoryAddress;
165  PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess();
167  SIZE_T Size;
168 
169  TRACE_(VIDEOPRT, "IntInt10AllocateBuffer\n");
170 
171  IntAttachToCSRSS(&CallingProcess, &ApcState);
172 
173  Size = *Length;
174  MemoryAddress = (PVOID)0x20000;
175  Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
176  &MemoryAddress,
177  0,
178  &Size,
179  MEM_COMMIT,
181  if (!NT_SUCCESS(Status))
182  {
183  WARN_(VIDEOPRT, "- ZwAllocateVirtualMemory failed\n");
184  IntDetachFromCSRSS(&CallingProcess, &ApcState);
186  }
187 
188  if (MemoryAddress > (PVOID)(0x100000 - Size))
189  {
190  ZwFreeVirtualMemory(NtCurrentProcess(),
191  &MemoryAddress,
192  &Size,
193  MEM_RELEASE);
194  WARN_(VIDEOPRT, "- Unacceptable memory allocated\n");
195  IntDetachFromCSRSS(&CallingProcess, &ApcState);
197  }
198 
199  *Length = (ULONG)Size;
200  *Seg = (USHORT)((ULONG_PTR)MemoryAddress >> 4);
201  *Off = (USHORT)((ULONG_PTR)MemoryAddress & 0xF);
202 
203  INFO_(VIDEOPRT, "- Segment: %x\n", (ULONG_PTR)MemoryAddress >> 4);
204  INFO_(VIDEOPRT, "- Offset: %x\n", (ULONG_PTR)MemoryAddress & 0xF);
205  INFO_(VIDEOPRT, "- Length: %x\n", *Length);
206 
207  IntDetachFromCSRSS(&CallingProcess, &ApcState);
208 
209  return NO_ERROR;
210 #else
211  Status = x86BiosAllocateBuffer(Length, Seg, Off);
213 #endif
214 }
KAPC_STATE
Definition: ketypes.h:1279
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define INFO_(ch,...)
Definition: debug.h:159
LONG NTSTATUS
Definition: precomp.h:26
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
#define NO_ERROR
Definition: dderror.h:5
#define MEM_COMMIT
Definition: nt_native.h:1313
uint32_t ULONG_PTR
Definition: typedefs.h:65
NTSTATUS NTAPI x86BiosAllocateBuffer(_In_ ULONG *Size, _In_ USHORT *Segment, _In_ USHORT *Offset)
Definition: x86bios.c:152
#define PsGetCurrentProcess
Definition: psfuncs.h:17
void * PVOID
Definition: retypes.h:9
#define NtCurrentProcess()
Definition: nt_native.h:1657
Status
Definition: gdiplustypes.h:24
#define TRACE_(x)
Definition: compat.h:76
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG_PTR SIZE_T
Definition: typedefs.h:80
VOID FASTCALL IntAttachToCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:443
unsigned short USHORT
Definition: pedump.c:61
struct _KPROCESS * PKPROCESS
Definition: wdm.template.h:206
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1484
#define MEM_RELEASE
Definition: nt_native.h:1316
VOID FASTCALL IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:456
unsigned int ULONG
Definition: retypes.h:1
#define PAGE_EXECUTE_READWRITE
Definition: nt_native.h:1308
#define WARN_(ch,...)
Definition: debug.h:157

Referenced by VideoPortQueryServices().

◆ IntInt10CallBios()

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

Definition at line 315 of file int10.c.

318 {
319 #ifdef _M_AMD64
320  X86_BIOS_REGISTERS BiosContext;
321 #else
323 #endif
325  PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess();
327 
328  /* Attach to CSRSS */
329  IntAttachToCSRSS(&CallingProcess, &ApcState);
330 
331  /* Clear the context */
333 
334  /* Fill out the bios arguments */
335  BiosContext.Eax = BiosArguments->Eax;
336  BiosContext.Ebx = BiosArguments->Ebx;
337  BiosContext.Ecx = BiosArguments->Ecx;
338  BiosContext.Edx = BiosArguments->Edx;
339  BiosContext.Esi = BiosArguments->Esi;
340  BiosContext.Edi = BiosArguments->Edi;
341  BiosContext.Ebp = BiosArguments->Ebp;
342  BiosContext.SegDs = BiosArguments->SegDs;
343  BiosContext.SegEs = BiosArguments->SegEs;
344 
345  /* Do the ROM BIOS call */
347  Executive,
348  KernelMode,
349  FALSE,
350  NULL);
351 
352 #ifdef _M_AMD64
354 #else
355  Status = Ke386CallBios(0x10, &BiosContext);
356 #endif
357 
359 
360  /* Return the arguments */
361  BiosArguments->Eax = BiosContext.Eax;
362  BiosArguments->Ebx = BiosContext.Ebx;
363  BiosArguments->Ecx = BiosContext.Ecx;
364  BiosArguments->Edx = BiosContext.Edx;
365  BiosArguments->Esi = BiosContext.Esi;
366  BiosArguments->Edi = BiosContext.Edi;
367  BiosArguments->Ebp = BiosContext.Ebp;
368  BiosArguments->SegDs = (USHORT)BiosContext.SegDs;
369  BiosArguments->SegEs = (USHORT)BiosContext.SegEs;
370 
371  /* Detach and return status */
372  IntDetachFromCSRSS(&CallingProcess, &ApcState);
373 
374  if (NT_SUCCESS(Status))
375  {
376  return NO_ERROR;
377  }
378 
380 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
KAPC_STATE
Definition: ketypes.h:1279
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define KeWaitForMutexObject
Definition: kefuncs.h:555
LONG NTSTATUS
Definition: precomp.h:26
KMUTEX VideoPortInt10Mutex
Definition: videoprt.c:41
LONG NTAPI KeReleaseMutex(IN PKMUTEX Mutex, IN BOOLEAN Wait)
Definition: mutex.c:189
#define NO_ERROR
Definition: dderror.h:5
#define FALSE
Definition: types.h:117
#define PsGetCurrentProcess
Definition: psfuncs.h:17
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
CALLBACK16 BiosContext
Definition: bios32.c:45
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
NTSTATUS NTAPI Ke386CallBios(IN ULONG Int, OUT PCONTEXT Context)
Definition: v86vdm.c:614
VOID FASTCALL IntAttachToCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:443
unsigned short USHORT
Definition: pedump.c:61
struct _KPROCESS * PKPROCESS
Definition: wdm.template.h:206
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1484
#define NULL
Definition: types.h:112
VOID FASTCALL IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:456
BOOLEAN NTAPI x86BiosCall(_In_ ULONG InterruptNumber, _Inout_ PX86_BIOS_REGISTERS Registers)
Definition: x86bios.c:405
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by VideoPortInt10(), and VideoPortQueryServices().

◆ IntInt10FreeBuffer()

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

Definition at line 218 of file int10.c.

222 {
224 #ifdef _M_IX86
225  PVOID MemoryAddress = (PVOID)((ULONG_PTR)(Seg << 4) | Off);
226  PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess();
228  SIZE_T Size = 0;
229 
230  TRACE_(VIDEOPRT, "IntInt10FreeBuffer\n");
231  INFO_(VIDEOPRT, "- Segment: %x\n", Seg);
232  INFO_(VIDEOPRT, "- Offset: %x\n", Off);
233 
234  IntAttachToCSRSS(&CallingProcess, &ApcState);
235  Status = ZwFreeVirtualMemory(NtCurrentProcess(),
236  &MemoryAddress,
237  &Size,
238  MEM_RELEASE);
239 
240  IntDetachFromCSRSS(&CallingProcess, &ApcState);
241 
242  return Status;
243 #else
244  Status = x86BiosFreeBuffer(Seg, Off);
246 #endif
247 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
KAPC_STATE
Definition: ketypes.h:1279
#define INFO_(ch,...)
Definition: debug.h:159
LONG NTSTATUS
Definition: precomp.h:26
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
#define NO_ERROR
Definition: dderror.h:5
uint32_t ULONG_PTR
Definition: typedefs.h:65
NTSTATUS NTAPI x86BiosFreeBuffer(_In_ USHORT Segment, _In_ USHORT Offset)
Definition: x86bios.c:181
#define PsGetCurrentProcess
Definition: psfuncs.h:17
void * PVOID
Definition: retypes.h:9
#define NtCurrentProcess()
Definition: nt_native.h:1657
Status
Definition: gdiplustypes.h:24
#define TRACE_(x)
Definition: compat.h:76
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG_PTR SIZE_T
Definition: typedefs.h:80
VOID FASTCALL IntAttachToCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:443
struct _KPROCESS * PKPROCESS
Definition: wdm.template.h:206
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1484
#define MEM_RELEASE
Definition: nt_native.h:1316
VOID FASTCALL IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:456

Referenced by VideoPortQueryServices().

◆ IntInt10ReadMemory()

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

Definition at line 251 of file int10.c.

257 {
258 #ifdef _M_IX86
259  PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess();
261 
262  TRACE_(VIDEOPRT, "IntInt10ReadMemory\n");
263  INFO_(VIDEOPRT, "- Segment: %x\n", Seg);
264  INFO_(VIDEOPRT, "- Offset: %x\n", Off);
265  INFO_(VIDEOPRT, "- Buffer: %x\n", Buffer);
266  INFO_(VIDEOPRT, "- Length: %x\n", Length);
267 
268  IntAttachToCSRSS(&CallingProcess, &ApcState);
269  RtlCopyMemory(Buffer, (PVOID)((ULONG_PTR)(Seg << 4) | Off), Length);
270  IntDetachFromCSRSS(&CallingProcess, &ApcState);
271 
272  return NO_ERROR;
273 #else
275 
276  Status = x86BiosReadMemory(Seg, Off, Buffer, Length);
278 #endif
279 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
KAPC_STATE
Definition: ketypes.h:1279
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define INFO_(ch,...)
Definition: debug.h:159
LONG NTSTATUS
Definition: precomp.h:26
#define NO_ERROR
Definition: dderror.h:5
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define PsGetCurrentProcess
Definition: psfuncs.h:17
Definition: bufpool.h:45
NTSTATUS NTAPI x86BiosReadMemory(_In_ USHORT Segment, _In_ USHORT Offset, _Out_writes_bytes_(Size) PVOID Buffer, _In_ ULONG Size)
Definition: x86bios.c:205
Status
Definition: gdiplustypes.h:24
#define TRACE_(x)
Definition: compat.h:76
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID FASTCALL IntAttachToCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:443
struct _KPROCESS * PKPROCESS
Definition: wdm.template.h:206
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1484
VOID FASTCALL IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:456
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263

Referenced by VideoPortQueryServices().

◆ IntInt10WriteMemory()

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

Definition at line 283 of file int10.c.

289 {
290 #ifdef _M_IX86
291  PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess();
293 
294  TRACE_(VIDEOPRT, "IntInt10WriteMemory\n");
295  INFO_(VIDEOPRT, "- Segment: %x\n", Seg);
296  INFO_(VIDEOPRT, "- Offset: %x\n", Off);
297  INFO_(VIDEOPRT, "- Buffer: %x\n", Buffer);
298  INFO_(VIDEOPRT, "- Length: %x\n", Length);
299 
300  IntAttachToCSRSS(&CallingProcess, &ApcState);
301  RtlCopyMemory((PVOID)((ULONG_PTR)(Seg << 4) | Off), Buffer, Length);
302  IntDetachFromCSRSS(&CallingProcess, &ApcState);
303 
304  return NO_ERROR;
305 #else
307 
308  Status = x86BiosWriteMemory(Seg, Off, Buffer, Length);
310 #endif
311 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
KAPC_STATE
Definition: ketypes.h:1279
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define INFO_(ch,...)
Definition: debug.h:159
LONG NTSTATUS
Definition: precomp.h:26
#define NO_ERROR
Definition: dderror.h:5
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define PsGetCurrentProcess
Definition: psfuncs.h:17
Definition: bufpool.h:45
Status
Definition: gdiplustypes.h:24
#define TRACE_(x)
Definition: compat.h:76
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID FASTCALL IntAttachToCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:443
struct _KPROCESS * PKPROCESS
Definition: wdm.template.h:206
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1484
VOID FASTCALL IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:456
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
NTSTATUS NTAPI x86BiosWriteMemory(_In_ USHORT Segment, _In_ USHORT Offset, _In_reads_bytes_(Size) PVOID Buffer, _In_ ULONG Size)
Definition: x86bios.c:232

Referenced by VideoPortQueryServices().

◆ IntSetupDeviceSettingsKey()

NTSTATUS NTAPI IntSetupDeviceSettingsKey ( PVIDEO_PORT_DEVICE_EXTENSION  DeviceExtension)

Definition at line 296 of file registry.c.

298 {
299  static UNICODE_STRING SettingsKeyName = RTL_CONSTANT_STRING(L"Settings");
300  HANDLE DevInstRegKey, SourceKeyHandle, DestKeyHandle;
303 
304  /* Open the software key: HKLM\System\CurrentControlSet\Control\Class<ClassGUID><n> */
308  &DevInstRegKey);
309  if (Status != STATUS_SUCCESS)
310  {
311  ERR_(VIDEOPRT, "Failed to open device software key. Status 0x%lx\n", Status);
312  return Status;
313  }
314 
315  /* Open the 'Settings' sub-key */
317  &SettingsKeyName,
320  NULL);
321  Status = ZwOpenKey(&DestKeyHandle, KEY_WRITE, &ObjectAttributes);
322 
323  /* Close the device software key */
325 
326  if (Status != STATUS_SUCCESS)
327  {
328  ERR_(VIDEOPRT, "Failed to open settings key. Status 0x%lx\n", Status);
329  return Status;
330  }
331 
332  /* Open the device profile key */
334  &DeviceExtension->RegistryPath,
336  NULL,
337  NULL);
338  Status = ZwOpenKey(&SourceKeyHandle, KEY_WRITE, &ObjectAttributes);
339  if (Status != STATUS_SUCCESS)
340  {
341  ERR_(VIDEOPRT, "ZwOpenKey failed for settings key: status 0x%lx\n", Status);
342  ObCloseHandle(DestKeyHandle, KernelMode);
343  return Status;
344  }
345 
346  IntCopyRegistryValue(SourceKeyHandle, DestKeyHandle, L"InstalledDisplayDrivers");
347  IntCopyRegistryValue(SourceKeyHandle, DestKeyHandle, L"Attach.ToDesktop");
348 
349  ObCloseHandle(SourceKeyHandle, KernelMode);
350  ObCloseHandle(DestKeyHandle, KernelMode);
351 
352  return STATUS_SUCCESS;
353 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define ERR_(ch,...)
Definition: debug.h:156
LONG NTSTATUS
Definition: precomp.h:26
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
PDEVICE_OBJECT PhysicalDeviceObject
Definition: videoprt.h:87
Status
Definition: gdiplustypes.h:24
#define KEY_WRITE
Definition: nt_native.h:1031
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
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define NULL
Definition: types.h:112
NTSTATUS NTAPI IoOpenDeviceRegistryKey(IN PDEVICE_OBJECT DeviceObject, IN ULONG DevInstKeyType, IN ACCESS_MASK DesiredAccess, OUT PHANDLE DevInstRegKey)
Definition: pnpmgr.c:2335
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
UNICODE_STRING RegistryPath
Definition: videoprt.h:90
#define STATUS_SUCCESS
Definition: shellext.h:65
NTSTATUS NTAPI IntCopyRegistryValue(HANDLE SourceKeyHandle, HANDLE DestKeyHandle, PWSTR ValueName)
Definition: registry.c:229
#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 334 of file dispatch.c.

337 {
341 
342  /* Get the initialization data we saved in VideoPortInitialize. */
344 
345  /* Create adapter device object. */
349  &DeviceObject);
350  if (NT_SUCCESS(Status))
352 
353  return Status;
354 }
NTSTATUS NTAPI IntVideoPortCreateAdapterDeviceObject(_In_ PDRIVER_OBJECT DriverObject, _In_ PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, _In_opt_ PDEVICE_OBJECT PhysicalDeviceObject, _Out_opt_ PDEVICE_OBJECT *DeviceObject)
Definition: videoprt.c:94
LONG NTSTATUS
Definition: precomp.h:26
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1155
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1872
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
ULONG VideoPortDeviceNumber
Definition: videoprt.c:40

Referenced by VideoPortInitialize().

◆ IntVideoPortCreateAdapterDeviceObject()

NTSTATUS NTAPI IntVideoPortCreateAdapterDeviceObject ( _In_ PDRIVER_OBJECT  DriverObject,
_In_ PVIDEO_PORT_DRIVER_EXTENSION  DriverExtension,
_In_opt_ PDEVICE_OBJECT  PhysicalDeviceObject,
_Out_opt_ PDEVICE_OBJECT DeviceObject 
)

Definition at line 94 of file videoprt.c.

99 {
100  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
102  ULONG PciSlotNumber;
104  ULONG Size;
106  WCHAR DeviceBuffer[20];
108  PDEVICE_OBJECT DeviceObject_;
109 
110  if (DeviceObject == NULL)
111  DeviceObject = &DeviceObject_;
112 
113  /*
114  * Find the first free device number that can be used for video device
115  * object names and symlinks.
116  */
118  if (DeviceNumber == 0xFFFFFFFF)
119  {
120  WARN_(VIDEOPRT, "Can't find free device number\n");
121  return STATUS_UNSUCCESSFUL;
122  }
123 
124  /*
125  * Create the device object.
126  */
127 
128  /* Create a unicode device name. */
129  swprintf(DeviceBuffer, L"\\Device\\Video%lu", DeviceNumber);
130  RtlInitUnicodeString(&DeviceName, DeviceBuffer);
131 
132  INFO_(VIDEOPRT, "HwDeviceExtension size is: 0x%x\n",
133  DriverExtension->InitializationData.HwDeviceExtensionSize);
134 
135  /* Create the device object. */
137  DriverExtension->InitializationData.HwDeviceExtensionSize;
139  Size,
140  &DeviceName,
142  0,
143  TRUE,
144  DeviceObject);
145 
146  if (!NT_SUCCESS(Status))
147  {
148  WARN_(VIDEOPRT, "IoCreateDevice call failed with status 0x%08x\n", Status);
149  return Status;
150  }
151 
152  /*
153  * Set the buffering strategy here. If you change this, remember
154  * to change VidDispatchDeviceControl too.
155  */
156 
157  (*DeviceObject)->Flags |= DO_BUFFERED_IO;
158 
159  /* Initialize device extension. */
160  DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)((*DeviceObject)->DeviceExtension);
161  DeviceExtension->Common.Fdo = TRUE;
162  DeviceExtension->DeviceNumber = DeviceNumber;
163  DeviceExtension->DriverObject = DriverObject;
164  DeviceExtension->PhysicalDeviceObject = PhysicalDeviceObject;
165  DeviceExtension->FunctionalDeviceObject = *DeviceObject;
166  DeviceExtension->DriverExtension = DriverExtension;
167  DeviceExtension->SessionId = -1;
168 
169  InitializeListHead(&DeviceExtension->ChildDeviceList);
170 
171  /* Get the registry path associated with this device. */
173  &DeviceExtension->RegistryPath);
174  if (!NT_SUCCESS(Status))
175  {
176  WARN_(VIDEOPRT, "IntCreateRegistryPath() call failed with status 0x%08x\n", Status);
178  *DeviceObject = NULL;
179  return Status;
180  }
181 
182  if (PhysicalDeviceObject != NULL)
183  {
184  /* Get bus number from the upper level bus driver. */
185  Size = sizeof(ULONG);
188  Size,
189  &DeviceExtension->SystemIoBusNumber,
190  &Size);
191  if (!NT_SUCCESS(Status))
192  {
193  WARN_(VIDEOPRT, "Couldn't get an information from bus driver. We will try to\n"
194  "use legacy detection method, but even that doesn't mean that\n"
195  "it will work.\n");
196  DeviceExtension->PhysicalDeviceObject = NULL;
197  }
198  }
199 
200  DeviceExtension->AdapterInterfaceType =
201  DriverExtension->InitializationData.AdapterInterfaceType;
202 
203  if (PhysicalDeviceObject != NULL)
204  {
205  /* Get bus type from the upper level bus driver. */
206  Size = sizeof(ULONG);
209  Size,
210  &DeviceExtension->AdapterInterfaceType,
211  &Size);
212 
213  /* Get bus device address from the upper level bus driver. */
214  Size = sizeof(ULONG);
217  Size,
218  &PciSlotNumber,
219  &Size);
220 
221  /* Convert slotnumber to PCI_SLOT_NUMBER */
222  SlotNumber.u.AsULONG = 0;
223  SlotNumber.u.bits.DeviceNumber = (PciSlotNumber >> 16) & 0xFFFF;
224  SlotNumber.u.bits.FunctionNumber = PciSlotNumber & 0xFFFF;
225  DeviceExtension->SystemIoSlotNumber = SlotNumber.u.AsULONG;
226  }
227 
228  InitializeListHead(&DeviceExtension->AddressMappingListHead);
229  InitializeListHead(&DeviceExtension->DmaAdapterList);
230 
231  KeInitializeDpc(&DeviceExtension->DpcObject,
233  DeviceExtension);
234 
235  KeInitializeMutex(&DeviceExtension->DeviceLock, 0);
236 
237  /* Attach the device. */
238  if (PhysicalDeviceObject != NULL)
240  *DeviceObject,
242 
243  IntCreateNewRegistryPath(DeviceExtension);
244  IntSetupDeviceSettingsKey(DeviceExtension);
245 
246  /* Remove the initailizing flag */
247  (*DeviceObject)->Flags &= ~DO_DEVICE_INITIALIZING;
248  return STATUS_SUCCESS;
249 }
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
_In_ WDFIORESREQLIST _In_ ULONG SlotNumber
Definition: wdfresource.h:65
PDEVICE_OBJECT FunctionalDeviceObject
Definition: videoprt.h:88
NTSTATUS NTAPI IntCreateNewRegistryPath(PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: registry.c:357
VOID NTAPI IntVideoPortDeferredRoutine(IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: videoprt.c:81
#define INFO_(ch,...)
Definition: debug.h:159
VIDEO_PORT_DRIVER_EXTENSION * DriverExtension
Definition: videoprt.h:103
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
struct _VIDEO_PORT_DEVICE_EXTENSTION * PVIDEO_PORT_DEVICE_EXTENSION
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
LIST_ENTRY AddressMappingListHead
Definition: videoprt.h:101
NTSTATUS NTAPI IntSetupDeviceSettingsKey(PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: registry.c:296
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1155
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3272
PDEVICE_OBJECT PhysicalDeviceObject
Definition: videoprt.h:87
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:966
NTSTATUS NTAPI IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, IN ULONG BufferLength, OUT PVOID PropertyBuffer, OUT PULONG ResultLength)
Definition: pnpmgr.c:2096
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
Status
Definition: gdiplustypes.h:24
__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:532
#define swprintf(buf, format,...)
Definition: sprintf.c:56
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
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:89
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
PDRIVER_OBJECT DriverObject
Definition: videoprt.h:86
struct _VIDEO_PORT_DEVICE_EXTENSTION VIDEO_PORT_DEVICE_EXTENSION
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
ULONG VideoPortDeviceNumber
Definition: videoprt.c:40
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define NULL
Definition: types.h:112
VIDEO_PORT_COMMON_EXTENSION Common
Definition: videoprt.h:84
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:90
#define STATUS_SUCCESS
Definition: shellext.h:65
_In_ PCHAR _In_ ULONG DeviceNumber
Definition: classpnp.h:1229
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:711
INTERFACE_TYPE AdapterInterfaceType
Definition: videoprt.h:98
#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 1097 of file dispatch.c.

1100 {
1101  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1102 
1103  DeviceExtension = DeviceObject->DeviceExtension;
1104  RtlFreeUnicodeString(&DeviceExtension->RegistryPath);
1105 
1106  Irp->IoStatus.Status = STATUS_SUCCESS;
1107  Irp->IoStatus.Information = 0;
1109 
1110  return STATUS_SUCCESS;
1111 }
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define IO_NO_INCREMENT
Definition: iotypes.h:581
UNICODE_STRING RegistryPath
Definition: videoprt.h:90
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ IntVideoPortDispatchClose()

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

Definition at line 429 of file dispatch.c.

432 {
433  TRACE_(VIDEOPRT, "IntVideoPortDispatchClose\n");
434 
436 
437  Irp->IoStatus.Status = STATUS_SUCCESS;
439  return STATUS_SUCCESS;
440 }
static NTSTATUS IntVideoPortInbvCleanup(IN PDEVICE_OBJECT DeviceObject)
Definition: dispatch.c:300
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
#define TRACE_(x)
Definition: compat.h:76
#define IO_NO_INCREMENT
Definition: iotypes.h:581
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchDeviceControl()

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

Definition at line 714 of file dispatch.c.

717 {
718  PIO_STACK_LOCATION IrpStack;
721 
722  TRACE_(VIDEOPRT, "IntVideoPortDispatchDeviceControl\n");
723 
724  IrpStack = IoGetCurrentIrpStackLocation(Irp);
725 
726  switch (IrpStack->MajorFunction)
727  {
729  /* This is the main part of this function and is handled below */
730  break;
731 
732  case IRP_MJ_SHUTDOWN:
733  {
734  /* Dereference CSRSS */
735  PKPROCESS OldCsrProcess;
736  OldCsrProcess = InterlockedExchangePointer((PVOID*)&CsrProcess, NULL);
737  if (OldCsrProcess)
738  ObDereferenceObject(OldCsrProcess);
739 
740  Irp->IoStatus.Status = STATUS_SUCCESS;
742  return STATUS_SUCCESS;
743  }
744 
745  default:
746  ERR_(VIDEOPRT, "- Unknown MajorFunction 0x%x\n", IrpStack->MajorFunction);
747  Irp->IoStatus.Status = STATUS_SUCCESS;
749  return STATUS_SUCCESS;
750  }
751 
752  IoControlCode = IrpStack->Parameters.DeviceIoControl.IoControlCode;
753 
754  INFO_(VIDEOPRT, "- IoControlCode: 0x%x: %s\n", IoControlCode, IoctlName(IoControlCode));
755 
756  switch (IoControlCode)
757  {
761  WARN_(VIDEOPRT, "- IOCTL_VIDEO_*_VDM are UNIMPLEMENTED!\n");
763  break;
764 
767  WARN_(VIDEOPRT, "- IOCTL_VIDEO_GET/SET_OUTPUT_DEVICE_POWER_STATE are UNIMPLEMENTED!\n");
769  break;
770 
773  WARN_(VIDEOPRT, "- IOCTL_VIDEO_GET/SET_POWER_MANAGEMENT are UNIMPLEMENTED!\n");
775  break;
776 
780  WARN_(VIDEOPRT, "- IOCTL_VIDEO_*_BRIGHTNESS are UNIMPLEMENTED!\n");
782  break;
783 
785  INFO_(VIDEOPRT, "- IOCTL_VIDEO_INIT_WIN32K_CALLBACKS\n");
787  Irp->AssociatedIrp.SystemBuffer,
788  IrpStack->Parameters.DeviceIoControl.InputBufferLength,
789  &Irp->IoStatus.Information);
790  break;
791 
793  WARN_(VIDEOPRT, "- IOCTL_VIDEO_IS_VGA_DEVICE is UNIMPLEMENTED!\n");
795  break;
796 
798  INFO_(VIDEOPRT, "- IOCTL_VIDEO_USE_DEVICE_IN_SESSION\n");
800  Irp->AssociatedIrp.SystemBuffer,
801  IrpStack->Parameters.DeviceIoControl.InputBufferLength,
802  &Irp->IoStatus.Information);
803  break;
804 
806  INFO_(VIDEOPRT, "- IOCTL_VIDEO_PREPARE_FOR_EARECOVERY\n");
807  /*
808  * The Win32k Watchdog Timer detected that a thread spent more time
809  * in a display driver than the allotted time its threshold specified,
810  * and thus is going to attempt to recover by switching to VGA mode.
811  * If this attempt fails, the watchdog generates bugcheck 0xEA
812  * "THREAD_STUCK_IN_DEVICE_DRIVER".
813  *
814  * Prepare the recovery by resetting the display adapters to
815  * standard VGA 80x25 text mode.
816  */
819  break;
820 
821  default:
822  /* Forward to the Miniport Driver */
824  break;
825  }
826 
827  INFO_(VIDEOPRT, "- Returned status: 0x%x\n", Status);
828 
829  Irp->IoStatus.Status = Status;
831  return Status;
832 }
#define IOCTL_VIDEO_IS_VGA_DEVICE
Definition: ntddvdeo.h:68
static NTSTATUS VideoPortUseDeviceInSession(_Inout_ PDEVICE_OBJECT DeviceObject, _Inout_ PVIDEO_DEVICE_SESSION_STATUS SessionState, _In_ ULONG BufferLength, _Out_ PULONG_PTR Information)
Definition: dispatch.c:562
#define INFO_(ch,...)
Definition: debug.h:159
#define IOCTL_VIDEO_REGISTER_VDM
Definition: ntddvdeo.h:47
#define IRP_MJ_SHUTDOWN
#define ERR_(ch,...)
Definition: debug.h:156
LONG NTSTATUS
Definition: precomp.h:26
#define IOCTL_VIDEO_ENABLE_VDM
Definition: ntddvdeo.h:41
#define IOCTL_VIDEO_GET_POWER_MANAGEMENT
Definition: ntddvdeo.h:98
#define IOCTL_VIDEO_GET_OUTPUT_DEVICE_POWER_STATE
Definition: ntddvdeo.h:53
PKPROCESS CsrProcess
Definition: videoprt.c:39
PSTR IoctlName(ULONG Ioctl)
Definition: dispatch.c:443
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
return STATUS_NOT_IMPLEMENTED
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
#define IOCTL_VIDEO_INIT_WIN32K_CALLBACKS
Definition: ntddvdeo.h:62
static BOOLEAN NTAPI IntVideoPortResetDisplayParametersEx(_In_ ULONG Columns, _In_ ULONG Rows, _In_ BOOLEAN CalledByInbv)
Definition: dispatch.c:72
#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:620
#define IOCTL_VIDEO_SET_POWER_MANAGEMENT
Definition: ntddvdeo.h:170
Status
Definition: gdiplustypes.h:24
#define TRACE_(x)
Definition: compat.h:76
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
#define ObDereferenceObject
Definition: obfuncs.h:203
#define IOCTL_VIDEO_PREPARE_FOR_EARECOVERY
Definition: ntddvdeo.h:74
#define IO_VIDEO_INCREMENT
Definition: iotypes.h:592
#define IOCTL_VIDEO_SET_DISPLAY_BRIGHTNESS
Definition: ntddvdeo.h:200
#define IOCTL_VIDEO_QUERY_SUPPORTED_BRIGHTNESS
Definition: ntddvdeo.h:194
#define IOCTL_VIDEO_DISABLE_VDM
Definition: ntddvdeo.h:44
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
Definition: wdfio.h:318
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
#define NULL
Definition: types.h:112
#define IOCTL_VIDEO_QUERY_DISPLAY_BRIGHTNESS
Definition: ntddvdeo.h:197
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:581
static NTSTATUS VideoPortForwardDeviceControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:647
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107
#define IOCTL_VIDEO_USE_DEVICE_IN_SESSION
Definition: ntddvdeo.h:71
#define WARN_(ch,...)
Definition: debug.h:157
#define IOCTL_VIDEO_SET_OUTPUT_DEVICE_POWER_STATE
Definition: ntddvdeo.h:50
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchOpen()

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

Definition at line 366 of file dispatch.c.

369 {
371  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
373 
374  TRACE_(VIDEOPRT, "IntVideoPortDispatchOpen\n");
375 
376  if (!CsrProcess)
377  {
378  /*
379  * We know the first open call will be from the CSRSS process
380  * to let us know its handle.
381  */
382  INFO_(VIDEOPRT, "Referencing CSRSS\n");
385  INFO_(VIDEOPRT, "CsrProcess 0x%p\n", CsrProcess);
386 
388  if (!NT_SUCCESS(Status))
389  {
390  ERR_(VIDEOPRT, "IntInitializeVideoAddressSpace() failed: 0x%lx\n", Status);
392  CsrProcess = NULL;
393  return Status;
394  }
395  }
396 
397  DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
398  DriverExtension = DeviceExtension->DriverExtension;
399 
400  // FIXME: (Re-)initialize INBV only if DeviceObject doesn't belong to a mirror driver.
402 
403  if (DriverExtension->InitializationData.HwInitialize(&DeviceExtension->MiniPortDeviceExtension))
404  {
405  Irp->IoStatus.Status = STATUS_SUCCESS;
406  InterlockedIncrement((PLONG)&DeviceExtension->DeviceOpened);
407  }
408  else
409  {
410  Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
411  }
412 
413  Irp->IoStatus.Information = FILE_OPENED;
415 
416  return STATUS_SUCCESS;
417 }
#define INFO_(ch,...)
Definition: debug.h:159
VIDEO_PORT_DRIVER_EXTENSION * DriverExtension
Definition: videoprt.h:103
#define ERR_(ch,...)
Definition: debug.h:156
LONG NTSTATUS
Definition: precomp.h:26
struct _VIDEO_PORT_DEVICE_EXTENSTION * PVIDEO_PORT_DEVICE_EXTENSION
#define FILE_OPENED
Definition: nt_native.h:769
PKPROCESS CsrProcess
Definition: videoprt.c:39
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
#define PsGetCurrentProcess
Definition: psfuncs.h:17
#define IoCompleteRequest
Definition: irp.c:1240
NTSTATUS NTAPI IntInitializeVideoAddressSpace(VOID)
Definition: int10.c:146
static NTSTATUS IntVideoPortInbvInitialize(VOID)
Definition: dispatch.c:274
Status
Definition: gdiplustypes.h:24
#define TRACE_(x)
Definition: compat.h:76
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ObDereferenceObject
Definition: obfuncs.h:203
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
#define InterlockedIncrement
Definition: armddk.h:53
struct _KPROCESS * PKPROCESS
Definition: wdm.template.h:206
#define NULL
Definition: types.h:112
#define ObReferenceObject
Definition: obfuncs.h:204
#define IO_NO_INCREMENT
Definition: iotypes.h:581
#define STATUS_SUCCESS
Definition: shellext.h:65
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 */
343  Status = IntVideoPortChildQueryId(DeviceObject->DeviceExtension,
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
#define IRP_MN_QUERY_RESOURCE_REQUIREMENTS
LONG NTSTATUS
Definition: precomp.h:26
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
#define IRP_MN_QUERY_REMOVE_DEVICE
#define IoCompleteRequest
Definition: irp.c:1240
Status
Definition: gdiplustypes.h:24
#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
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
#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:581
#define STATUS_SUCCESS
Definition: shellext.h:65
#define IRP_MN_QUERY_CAPABILITIES

Referenced by IntVideoPortDispatchPnp().

◆ IntVideoPortDispatchPnp()

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

Definition at line 1083 of file dispatch.c.

1086 {
1087  PVIDEO_PORT_COMMON_EXTENSION CommonExtension = DeviceObject->DeviceExtension;
1088 
1089  if (CommonExtension->Fdo)
1091  else
1093 }
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:1006
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchPower()

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

Definition at line 1115 of file dispatch.c.

1118 {
1120  NTSTATUS Status = Irp->IoStatus.Status;
1121  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
1122 
1124 
1125  if (DeviceExtension->Common.Fdo)
1126  {
1129  return PoCallDriver(DeviceExtension->NextDeviceObject, Irp);
1130  }
1131  else
1132  {
1133  switch (IrpSp->MinorFunction)
1134  {
1135  case IRP_MN_QUERY_POWER:
1136  case IRP_MN_SET_POWER:
1138  break;
1139  }
1141  Irp->IoStatus.Status = Status;
1143  return Status;
1144  }
1145 }
#define IRP_MN_QUERY_POWER
LONG NTSTATUS
Definition: precomp.h:26
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
Status
Definition: gdiplustypes.h:24
PDEVICE_OBJECT NextDeviceObject
Definition: videoprt.h:89
#define IRP_MN_SET_POWER
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:737
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
VIDEO_PORT_COMMON_EXTENSION Common
Definition: videoprt.h:84
#define IO_NO_INCREMENT
Definition: iotypes.h:581
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchSystemControl()

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

Definition at line 1149 of file dispatch.c.

1152 {
1153  NTSTATUS Status;
1154  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
1155 
1156  if (DeviceExtension->Common.Fdo)
1157  {
1159  return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
1160  }
1161  else
1162  {
1163  Status = Irp->IoStatus.Status;
1165  return Status;
1166  }
1167 }
LONG NTSTATUS
Definition: precomp.h:26
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
Status
Definition: gdiplustypes.h:24
PDEVICE_OBJECT NextDeviceObject
Definition: videoprt.h:89
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:84
#define IO_NO_INCREMENT
Definition: iotypes.h:581

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;
92  DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
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 }
struct _IO_RESOURCE_REQUIREMENTS_LIST IO_RESOURCE_REQUIREMENTS_LIST
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
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
struct _VIDEO_PORT_DEVICE_EXTENSTION * PVIDEO_PORT_DEVICE_EXTENSION
#define CM_RESOURCE_MEMORY_READ_WRITE
Definition: cmtypes.h:120
#define CmResourceTypePort
Definition: hwresource.cpp:123
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
#define VIDEO_RANGE_PASSIVE_DECODE
Definition: video.h:98
#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
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
struct _IO_RESOURCE_DESCRIPTOR IO_RESOURCE_DESCRIPTOR
Status
Definition: gdiplustypes.h:24
IO_RESOURCE_DESCRIPTOR Descriptors[1]
#define ASSERT(a)
Definition: mode.c:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define CM_RESOURCE_PORT_PASSIVE_DECODE
Definition: cmtypes.h:114
UCHAR RangeShareable
Definition: video.h:219
struct _IO_RESOURCE_DESCRIPTOR * PIO_RESOURCE_DESCRIPTOR
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1872
struct _LARGE_INTEGER::@2277 u
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
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 STATUS_NO_MEMORY
Definition: ntstatus.h:260
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define ULONG_PTR
Definition: config.h:101
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_SUCCESS
Definition: shellext.h:65
#define CmResourceTypeMemory
Definition: hwresource.cpp:125
INTERFACE_TYPE AdapterInterfaceType
Definition: videoprt.h:98
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 254 of file videoprt.c.

258 {
259  WCHAR DeviceVideoBuffer[20];
260  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
262  VIDEO_PORT_CONFIG_INFO ConfigInfo;
264  UCHAR Again = FALSE;
265  WCHAR DeviceBuffer[20];
267  WCHAR SymlinkBuffer[20];
268  UNICODE_STRING SymlinkName;
269  BOOL LegacyDetection = FALSE;
271 
272  DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
273  DeviceNumber = DeviceExtension->DeviceNumber;
274 
275  /* Setup a ConfigInfo structure that we will pass to HwFindAdapter. */
276  RtlZeroMemory(&ConfigInfo, sizeof(VIDEO_PORT_CONFIG_INFO));
277  ConfigInfo.Length = sizeof(VIDEO_PORT_CONFIG_INFO);
278  ConfigInfo.AdapterInterfaceType = DeviceExtension->AdapterInterfaceType;
279  if (ConfigInfo.AdapterInterfaceType == PCIBus)
280  ConfigInfo.InterruptMode = LevelSensitive;
281  else
282  ConfigInfo.InterruptMode = Latched;
283  ConfigInfo.DriverRegistryPath = DriverExtension->RegistryPath.Buffer;
285  ConfigInfo.SystemIoBusNumber = DeviceExtension->SystemIoBusNumber;
286  ConfigInfo.BusInterruptLevel = DeviceExtension->InterruptLevel;
287  ConfigInfo.BusInterruptVector = DeviceExtension->InterruptVector;
288 
291  sizeof(SystemBasicInfo),
292  NULL);
293  if (NT_SUCCESS(Status))
294  {
297  }
298 
299  // FIXME: Check the adapter key and update VideoDebugLevel variable.
300 
301  /*
302  * Call miniport HwVidFindAdapter entry point to detect if
303  * particular device is present. There are two possible code
304  * paths. The first one is for Legacy drivers (NT4) and cases
305  * when we don't have information about what bus we're on. The
306  * second case is the standard one for Plug & Play drivers.
307  */
308  if (DeviceExtension->PhysicalDeviceObject == NULL)
309  {
310  LegacyDetection = TRUE;
311  }
312 
313  if (LegacyDetection)
314  {
315  ULONG BusNumber, MaxBuses;
316 
317  MaxBuses = DeviceExtension->AdapterInterfaceType == PCIBus ? PCI_MAX_BRIDGE_NUMBER : 1;
318 
319  for (BusNumber = 0; BusNumber < MaxBuses; BusNumber++)
320  {
321  DeviceExtension->SystemIoBusNumber =
322  ConfigInfo.SystemIoBusNumber = BusNumber;
323 
324  RtlZeroMemory(&DeviceExtension->MiniPortDeviceExtension,
325  DriverExtension->InitializationData.HwDeviceExtensionSize);
326 
327  /* FIXME: Need to figure out what string to pass as param 3. */
328  Status = DriverExtension->InitializationData.HwFindAdapter(
329  &DeviceExtension->MiniPortDeviceExtension,
330  DriverExtension->HwContext,
331  NULL,
332  &ConfigInfo,
333  &Again);
334 
336  {
337  continue;
338  }
339  else if (Status == NO_ERROR)
340  {
341  break;
342  }
343  else
344  {
345  ERR_(VIDEOPRT, "HwFindAdapter call failed with error 0x%X\n", Status);
346  goto Failure;
347  }
348  }
349  }
350  else
351  {
352  /* FIXME: Need to figure out what string to pass as param 3. */
353  Status = DriverExtension->InitializationData.HwFindAdapter(
354  &DeviceExtension->MiniPortDeviceExtension,
355  DriverExtension->HwContext,
356  NULL,
357  &ConfigInfo,
358  &Again);
359  }
360 
361  if (Status != NO_ERROR)
362  {
363  ERR_(VIDEOPRT, "HwFindAdapter call failed with error 0x%X\n", Status);
364  goto Failure;
365  }
366 
367  /*
368  * Now we know the device is present, so let's do all additional tasks
369  * such as creating symlinks or setting up interrupts and timer.
370  */
371 
372  /* Create a unicode device name. */
373  swprintf(DeviceBuffer, L"\\Device\\Video%lu", DeviceNumber);
374  RtlInitUnicodeString(&DeviceName, DeviceBuffer);
375 
376  /* Create symbolic link "\??\DISPLAYx" */
377  swprintf(SymlinkBuffer, L"\\??\\DISPLAY%lu", DeviceNumber + 1);
378  RtlInitUnicodeString(&SymlinkName, SymlinkBuffer);
379  IoCreateSymbolicLink(&SymlinkName, &DeviceName);
380 
381  /* Add entry to DEVICEMAP\VIDEO key in registry. */
382  swprintf(DeviceVideoBuffer, L"\\Device\\Video%d", DeviceNumber);
385  L"VIDEO",
386  DeviceVideoBuffer,
387  REG_SZ,
388  DeviceExtension->RegistryPath.Buffer,
389  DeviceExtension->RegistryPath.Length + sizeof(UNICODE_NULL));
390 
393  L"VIDEO",
394  L"MaxObjectNumber",
395  REG_DWORD,
396  &DeviceNumber,
397  sizeof(DeviceNumber));
398 
399  /* FIXME: Allocate hardware resources for device. */
400 
401  /* Allocate interrupt for device. */
403  {
405  goto Failure;
406  }
407 
408  /* Allocate timer for device. */
410  {
411  if (DeviceExtension->InterruptObject != NULL)
412  IoDisconnectInterrupt(DeviceExtension->InterruptObject);
413  ERR_(VIDEOPRT, "IntVideoPortSetupTimer failed\n");
415  goto Failure;
416  }
417 
418  /* If the device can be reset, insert it in the list of resettable adapters */
419  InitializeListHead(&DeviceExtension->HwResetListEntry);
420  if (DriverExtension->InitializationData.HwResetHw != NULL)
421  {
423  &DeviceExtension->HwResetListEntry,
425  }
426 
427  /* Query children of the device. */
429 
430  INFO_(VIDEOPRT, "STATUS_SUCCESS\n");
431  return STATUS_SUCCESS;
432 
433 Failure:
434  RtlFreeUnicodeString(&DeviceExtension->RegistryPath);
435  if (DeviceExtension->NextDeviceObject)
436  IoDetachDevice(DeviceExtension->NextDeviceObject);
438  return Status;
439 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define PCI_MAX_BRIDGE_NUMBER
Definition: iotypes.h:3579
#define INFO_(ch,...)
Definition: debug.h:159
#define TRUE
Definition: types.h:120
BOOLEAN NTAPI IntVideoPortSetupTimer(IN PDEVICE_OBJECT DeviceObject, IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension)
Definition: timer.c:43
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
#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:1296
#define NO_ERROR
Definition: dderror.h:5
INTERFACE_TYPE AdapterInterfaceType
Definition: video.h:169
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3272
PVOID NTAPI IntVideoPortGetProcAddress(IN PVOID HwDeviceExtension, IN PUCHAR FunctionName)
Definition: funclist.c:100
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
NTSYSAPI NTSTATUS WINAPI RtlWriteRegistryValue(ULONG, PCWSTR, PCWSTR, ULONG, PVOID, ULONG)
unsigned int BOOL
Definition: ntddk_ex.h:94
PDEVICE_OBJECT PhysicalDeviceObject
Definition: videoprt.h:87
VP_STATUS NTAPI VideoPortEnumerateChildren(IN PVOID HwDeviceExtension, IN PVOID Reserved)
Definition: videoprt.c:1125
NTSYSAPI NTSTATUS NTAPI ZwQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
PVIDEO_PORT_GET_PROC_ADDRESS VideoPortGetProcAddress
Definition: video.h:193
VOID NTAPI IoDisconnectInterrupt(PKINTERRUPT InterruptObject)
Definition: irq.c:140
KSPIN_LOCK HwResetAdaptersLock
Definition: videoprt.c:42
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:156
Status
Definition: gdiplustypes.h:24
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
static const WCHAR L[]
Definition: oid.c:1250
PWSTR DriverRegistryPath
Definition: video.h:194
PDEVICE_OBJECT NextDeviceObject
Definition: videoprt.h:89
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
BOOLEAN NTAPI IntVideoPortSetupInterrupt(IN PDEVICE_OBJECT DeviceObject, IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, IN PVIDEO_PORT_CONFIG_INFO ConfigInfo)
Definition: interrupt.c:45
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
LIST_ENTRY HwResetAdaptersList
UNICODE_STRING RegistryPath
Definition: videoprt.h:90
#define STATUS_SUCCESS
Definition: shellext.h:65
_In_ PCHAR _In_ ULONG DeviceNumber
Definition: classpnp.h:1229
#define RTL_REGISTRY_DEVICEMAP
Definition: nt_native.h:165
INTERFACE_TYPE AdapterInterfaceType
Definition: videoprt.h:98
#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
#define TRACE_(x)
Definition: compat.h:76
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NULL
Definition: types.h:112
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:1274
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 }
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
_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
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
WDF_EXTERN_C_START typedef _Must_inspect_result_ _In_opt_ PCUNICODE_STRING UnicodeString
Definition: wdfstring.h:64
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define SECTION_ALL_ACCESS
Definition: nt_native.h:1293
_Must_inspect_result_ _In_ WDFDMATRANSACTION _In_ PFN_WDF_PROGRAM_DMA _In_ WDF_DMA_DIRECTION _In_ PMDL _In_ PVOID VirtualAddress
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1081
static const WCHAR L[]
Definition: oid.c:1250
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define NULL
Definition: types.h:112
_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 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 
53  DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
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
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
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define FALSE
Definition: types.h:117
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:238
BOOLEAN NTAPI IntVideoPortInterruptRoutine(IN struct _KINTERRUPT *Interrupt, IN PVOID ServiceContext)
Definition: interrupt.c:32
NTHALAPI ULONG NTAPI HalGetInterruptVector(INTERFACE_TYPE, ULONG, ULONG, ULONG, PKIRQL, PKAFFINITY)
Status
Definition: gdiplustypes.h:24
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
ULONG_PTR KAFFINITY
Definition: compat.h:85
#define NULL
Definition: types.h:112
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 
50  DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
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 INFO_(ch,...)
Definition: debug.h:159
#define TRUE
Definition: types.h:120
#define ERR_(ch,...)
Definition: debug.h:156
LONG NTSTATUS
Definition: precomp.h:26
struct _VIDEO_PORT_DEVICE_EXTENSTION * PVIDEO_PORT_DEVICE_EXTENSION
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define FALSE
Definition: types.h:117
Status
Definition: gdiplustypes.h:24
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
#define NULL
Definition: types.h:112

Referenced by IntVideoPortFindAdapter().

◆ IntVideoPortUnload()

VOID NTAPI IntVideoPortUnload ( PDRIVER_OBJECT  DriverObject)

Definition at line 1171 of file dispatch.c.

1172 {
1173 }

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 }
return STATUS_NOT_SUPPORTED
PIRP NTAPI IoBuildSynchronousFsdRequest(IN ULONG MajorFunction, IN PDEVICE_OBJECT DeviceObject, IN PVOID Buffer, IN ULONG Length, IN PLARGE_INTEGER StartingOffset, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:1069
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
LONG NTSTATUS
Definition: precomp.h:26
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:264
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:636
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
_In_ UCHAR _In_ UCHAR MinorFunction
Definition: wdfdevice.h:1697
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:450
PDEVICE_OBJECT NTAPI IoGetAttachedDeviceReference(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1406
Status
Definition: gdiplustypes.h:24
#define STATUS_PENDING
Definition: ntstatus.h:82
#define ObDereferenceObject
Definition: obfuncs.h:203
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2691
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define NULL
Definition: types.h:112
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3107

Referenced by IntAgpGetInterface().

Variable Documentation

◆ CsrProcess

◆ HwResetAdaptersList

◆ HwResetAdaptersLock

KSPIN_LOCK HwResetAdaptersLock

◆ VideoPortDeviceNumber

ULONG VideoPortDeviceNumber

◆ VideoPortInt10Mutex

KMUTEX VideoPortInt10Mutex

Definition at line 41 of file videoprt.c.

Referenced by IntInt10CallBios(), and VideoPortInitialize().