ReactOS  0.4.15-dev-3163-gf17c2c0
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, _In_ USHORT AdapterNumber, _In_ USHORT DisplayNumber, _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, IN ULONG DeviceNumber, 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 134 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 140 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:140
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:44
#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:3128
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 496 of file videoprt.c.

499 {
500  *CallingProcess = (PKPROCESS)PsGetCurrentProcess();
501  if (*CallingProcess != CsrProcess)
502  {
504  }
505 }
PKPROCESS CsrProcess
Definition: videoprt.c:39
VOID NTAPI KeStackAttachProcess(IN PKPROCESS Process, OUT PRKAPC_STATE ApcState)
Definition: procobj.c:704
#define PsGetCurrentProcess
Definition: psfuncs.h:17
struct _KPROCESS * PKPROCESS
Definition: wdm.template.h:206
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1679

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

◆ IntCopyRegistryKey()

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

Definition at line 31 of file registry.c.

34 {
35  PVOID InfoBuffer;
36  PKEY_BASIC_INFORMATION KeyInformation;
37  PKEY_VALUE_FULL_INFORMATION KeyValueInformation;
39  ULONG Index, InformationLength, RequiredLength;
40  UNICODE_STRING NameString;
42  HANDLE SourceSubKeyHandle, DestSubKeyHandle;
43 
44  /* Start with no buffer, set initial size */
45  InfoBuffer = NULL;
46  InformationLength = 256;
47 
48  /* Start looping with key index 0 */
49  Index = 0;
50  while (TRUE)
51  {
52  /* Check if we have no buffer */
53  if (InfoBuffer == NULL)
54  {
55  /* Allocate a new buffer */
56  InfoBuffer = ExAllocatePoolWithTag(PagedPool,
57  InformationLength,
59  if (InfoBuffer == NULL)
60  {
61  ERR_(VIDEOPRT, "Could not allocate buffer for key info\n");
63  }
64  }
65 
66  /* Enumerate the next sub-key */
67  KeyInformation = InfoBuffer;
68  Status = ZwEnumerateKey(SourceKeyHandle,
69  Index,
71  KeyInformation,
72  InformationLength,
74  if ((Status == STATUS_BUFFER_OVERFLOW) ||
76  {
77  /* Free the buffer and remember the required size */
79  InfoBuffer = NULL;
80  InformationLength = RequiredLength;
81 
82  /* Try again */
83  continue;
84  }
85  else if (Status == STATUS_NO_MORE_ENTRIES)
86  {
87  /* We are done with the sub-keys */
88  break;
89  }
90  else if (!NT_SUCCESS(Status))
91  {
92  ERR_(VIDEOPRT, "ZwEnumerateKey failed, status 0x%lx\n", Status);
93  goto Cleanup;
94  }
95 
96  /* Initialize a unicode string from the key name */
97  NameString.Buffer = KeyInformation->Name;
98  NameString.Length = (USHORT)KeyInformation->NameLength;
99  NameString.MaximumLength = NameString.Length;
100 
101  /* Initialize object attributes and open the source sub-key */
103  &NameString,
105  SourceKeyHandle,
106  NULL);
107  Status = ZwOpenKey(&SourceSubKeyHandle, KEY_READ, &ObjectAttributes);
108  if (!NT_SUCCESS(Status))
109  {
110  ERR_(VIDEOPRT, "failed to open the source key.\n");
111  goto Cleanup;
112  }
113 
114  /* Initialize object attributes and create the dest sub-key */
116  &NameString,
118  DestKeyHandle,
119  NULL);
120  Status = ZwCreateKey(&DestSubKeyHandle,
121  KEY_WRITE,
123  0,
124  NULL,
126  NULL);
127  if (!NT_SUCCESS(Status))
128  {
129  ERR_(VIDEOPRT, "failed to create the destination key.\n");
130  ObCloseHandle(SourceSubKeyHandle, KernelMode);
131  goto Cleanup;
132  }
133 
134  /* Recursively copy the sub-key */
135  Status = IntCopyRegistryKey(SourceSubKeyHandle, DestSubKeyHandle);
136  if (!NT_SUCCESS(Status))
137  {
138  /* Just warn, but continue with the remaining sub-keys */
139  WARN_(VIDEOPRT, "failed to copy subkey '%wZ'.\n", &NameString);
140  }
141 
142  /* Close the sub-key handles */
143  ObCloseHandle(SourceSubKeyHandle, KernelMode);
144  ObCloseHandle(DestSubKeyHandle, KernelMode);
145 
146  /* Next sub-key */
147  Index++;
148  }
149 
150  /* Start looping with value index 0 */
151  Index = 0;
152  while (TRUE)
153  {
154  /* Check if we have no buffer */
155  if (InfoBuffer == NULL)
156  {
157  /* Allocate a new buffer */
158  InfoBuffer = ExAllocatePoolWithTag(PagedPool,
159  InformationLength,
161  if (InfoBuffer == NULL)
162  {
163  ERR_(VIDEOPRT, "Could not allocate buffer for key values\n");
164  return Status;
165  }
166  }
167 
168  /* Enumerate the next value */
169  KeyValueInformation = InfoBuffer;
170  Status = ZwEnumerateValueKey(SourceKeyHandle,
171  Index,
173  KeyValueInformation,
174  InformationLength,
175  &RequiredLength);
176  if ((Status == STATUS_BUFFER_OVERFLOW) ||
178  {
179  /* Free the buffer and remember the required size */
181  InfoBuffer = NULL;
182  InformationLength = RequiredLength;
183 
184  /* Try again */
185  continue;
186  }
187  else if (Status == STATUS_NO_MORE_ENTRIES)
188  {
189  /* We are done with the values */
191  break;
192  }
193  else if (!NT_SUCCESS(Status))
194  {
195  ERR_(VIDEOPRT, "ZwEnumerateValueKey failed, status 0x%lx\n", Status);
196  goto Cleanup;
197  }
198 
199  /* Initialize a unicode string from the value name */
200  NameString.Buffer = KeyValueInformation->Name;
201  NameString.Length = (USHORT)KeyValueInformation->NameLength;
202  NameString.MaximumLength = NameString.Length;
203 
204  /* Create the key value in the destination key */
205  Status = ZwSetValueKey(DestKeyHandle,
206  &NameString,
207  KeyValueInformation->TitleIndex,
208  KeyValueInformation->Type,
209  (PUCHAR)KeyValueInformation + KeyValueInformation->DataOffset,
210  KeyValueInformation->DataLength);
211  if (!NT_SUCCESS(Status))
212  {
213  /* Just warn, but continue with the remaining sub-keys */
214  WARN_(VIDEOPRT, "failed to set value '%wZ'.\n", &NameString);
215  }
216 
217  /* Next subkey */
218  Index++;
219  }
220 
221 Cleanup:
222  /* Free the buffer and return the failure code */
223  if (InfoBuffer != NULL)
225  return Status;
226 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define 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:31
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:3375
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 230 of file registry.c.

234 {
235  PKEY_VALUE_PARTIAL_INFORMATION ValueInformation;
236  UNICODE_STRING ValueNameString;
237  ULONG Length;
239 
240  RtlInitUnicodeString(&ValueNameString, ValueName);
241 
242  /* Query the value length */
243  Status = ZwQueryValueKey(SourceKeyHandle,
244  &ValueNameString,
246  NULL,
247  0,
248  &Length);
249  if ((Status != STATUS_BUFFER_OVERFLOW) &&
251  {
252  /* The key seems not present */
254  return Status;
255  }
256 
257  /* Allocate a buffer */
259  if (ValueInformation == NULL)
260  {
261  return Status;
262  }
263 
264  /* Query the value */
265  Status = ZwQueryValueKey(SourceKeyHandle,
266  &ValueNameString,
268  ValueInformation,
269  Length,
270  &Length);
271  if (!NT_SUCCESS(Status))
272  {
273  ExFreePoolWithTag(ValueInformation, TAG_VIDEO_PORT_BUFFER);
274  return Status;
275  }
276 
277  /* Write the registry value */
278  Status = ZwSetValueKey(DestKeyHandle,
279  &ValueNameString,
280  ValueInformation->TitleIndex,
281  ValueInformation->Type,
282  ValueInformation->Data,
283  ValueInformation->DataLength);
284 
285  ExFreePoolWithTag(ValueInformation, TAG_VIDEO_PORT_BUFFER);
286 
287  if (!NT_SUCCESS(Status))
288  {
289  ERR_(VIDEOPRT, "ZwSetValueKey failed: status 0x%lx\n", Status);
290  }
291 
292  return Status;
293 }
_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:3310

Referenced by IntSetupDeviceSettingsKey().

◆ IntCreateNewRegistryPath()

NTSTATUS NTAPI IntCreateNewRegistryPath ( PVIDEO_PORT_DEVICE_EXTENSION  DeviceExtension)
Todo:
HACK

Definition at line 358 of file registry.c.

360 {
361  static UNICODE_STRING VideoIdValueName = RTL_CONSTANT_STRING(L"VideoId");
362  static UNICODE_STRING ControlVideoPathName =
363  RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Video\\");
364  HANDLE DevInstRegKey, SettingsKey, NewKey;
365  UCHAR VideoIdBuffer[sizeof(KEY_VALUE_PARTIAL_INFORMATION) + GUID_STRING_LENGTH];
366  UNICODE_STRING VideoIdString;
367  UUID VideoId;
368  PKEY_VALUE_PARTIAL_INFORMATION ValueInformation ;
371  USHORT KeyMaxLength;
373  PWCHAR InstanceIdBuffer;
374 
375  /* Open the hardware key: HKLM\System\CurrentControlSet\Enum\... */
379  &DevInstRegKey);
380  if (Status != STATUS_SUCCESS)
381  {
382  ERR_(VIDEOPRT, "IoOpenDeviceRegistryKey failed: status 0x%lx\n", Status);
383  return Status;
384  }
385 
386  /* Query the VideoId value */
387  ValueInformation = (PKEY_VALUE_PARTIAL_INFORMATION)VideoIdBuffer;
388  Status = ZwQueryValueKey(DevInstRegKey,
389  &VideoIdValueName,
391  ValueInformation,
392  sizeof(VideoIdBuffer),
393  &ResultLength);
394  if (!NT_SUCCESS(Status))
395  {
396  /* Create a new video Id */
397  Status = ExUuidCreate(&VideoId);
398  if (!NT_SUCCESS(Status))
399  {
400  ERR_(VIDEOPRT, "ExUuidCreate failed: status 0x%lx\n", Status);
402  return Status;
403  }
404 
405  /* Convert the GUID into a string */
406  Status = RtlStringFromGUID(&VideoId, &VideoIdString);
407  if (!NT_SUCCESS(Status))
408  {
409  ERR_(VIDEOPRT, "RtlStringFromGUID failed: status 0x%lx\n", Status);
411  return Status;
412  }
413 
414  /* Copy the GUID String to our buffer */
415  ValueInformation->DataLength = min(VideoIdString.Length, GUID_STRING_LENGTH);
416  RtlCopyMemory(ValueInformation->Data,
417  VideoIdString.Buffer,
418  ValueInformation->DataLength);
419 
420  /* Free the GUID string */
421  RtlFreeUnicodeString(&VideoIdString);
422 
423  /* Write the VideoId registry value */
424  Status = ZwSetValueKey(DevInstRegKey,
425  &VideoIdValueName,
426  0,
427  REG_SZ,
428  ValueInformation->Data,
429  ValueInformation->DataLength);
430  if (!NT_SUCCESS(Status))
431  {
432  ERR_(VIDEOPRT, "ZwSetValueKey failed: status 0x%lx\n", Status);
434  return Status;
435  }
436  }
437 
438  /* Initialize the VideoId string from the registry data */
439  VideoIdString.Buffer = (PWCHAR)ValueInformation->Data;
440  VideoIdString.Length = (USHORT)ValueInformation->DataLength;
441  VideoIdString.MaximumLength = VideoIdString.Length;
442 
443  /* Close the hardware key */
445 
446  /* Calculate the size needed for the new registry path name */
447  KeyMaxLength = ControlVideoPathName.Length +
448  VideoIdString.Length +
449  sizeof(L"\\0000");
450 
451  /* Allocate the path name buffer */
452  DeviceExtension->NewRegistryPath.Length = 0;
453  DeviceExtension->NewRegistryPath.MaximumLength = KeyMaxLength;
455  KeyMaxLength,
457  if (DeviceExtension->NewRegistryPath.Buffer == NULL)
458  {
459  ERR_(VIDEOPRT, "Failed to allocate key name buffer.\n");
461  }
462 
463  /* Copy the root key name and append the VideoId string */
464  RtlCopyUnicodeString(&DeviceExtension->NewRegistryPath,
465  &ControlVideoPathName);
467  &VideoIdString);
468 
469  /* Check if we have the key already */
471  DeviceExtension->NewRegistryPath.Buffer);
472  if (Status != STATUS_SUCCESS)
473  {
474  /* Try to create the new key */
476  DeviceExtension->NewRegistryPath.Buffer);
477  }
478 
479  /* Append a the instance path */
480  RtlAppendUnicodeToString(&DeviceExtension->NewRegistryPath, L"\\");
481  InstanceIdBuffer = DeviceExtension->NewRegistryPath.Buffer +
482  DeviceExtension->NewRegistryPath.Length / sizeof(WCHAR);
483  RtlAppendUnicodeToString(&DeviceExtension->NewRegistryPath, L"0000");
484 
485  /* Write instance ID */
486  swprintf(InstanceIdBuffer, L"%04u", DeviceExtension->DisplayNumber);
487 
488  /* Check if the name exists */
490  DeviceExtension->NewRegistryPath.Buffer);
491  if (Status != STATUS_SUCCESS)
492  {
493  /* Try to create the new key */
495  DeviceExtension->NewRegistryPath.Buffer);
496  if (!NT_SUCCESS(Status))
497  {
498  ERR_(VIDEOPRT, "Failed create key '%wZ'\n", &DeviceExtension->NewRegistryPath);
499  return Status;
500  }
501  }
502 
503  /* Open the new key */
505  &DeviceExtension->NewRegistryPath,
507  NULL,
508  NULL);
509  Status = ZwOpenKey(&NewKey, KEY_READ, &ObjectAttributes);
510  if (!NT_SUCCESS(Status))
511  {
512  ERR_(VIDEOPRT, "Failed to open settings key. Status 0x%lx\n", Status);
513  return Status;
514  }
515 
516  /* Open the device profile key */
518  &DeviceExtension->RegistryPath,
520  NULL,
521  NULL);
522  Status = ZwOpenKey(&SettingsKey, KEY_READ, &ObjectAttributes);
523  if (!NT_SUCCESS(Status))
524  {
525  ERR_(VIDEOPRT, "Failed to open settings key. Status 0x%lx\n", Status);
526  ObCloseHandle(NewKey, KernelMode);
527  return Status;
528  }
529 
530  /* Copy the registry data from the legacy key */
531  Status = IntCopyRegistryKey(SettingsKey, NewKey);
532 
533  /* Close the key handles */
534  ObCloseHandle(SettingsKey, KernelMode);
535  ObCloseHandle(NewKey, KernelMode);
536 
537  return Status;
538 }
NTKERNELAPI NTSTATUS ExUuidCreate(OUT UUID *Uuid)
Definition: uuid.c:380
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:2786
#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 swprintf
Definition: precomp.h:40
#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:31
Status
Definition: gdiplustypes.h:24
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
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:3375
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:1125
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:2191
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,
IN ULONG  DeviceNumber,
OUT PUNICODE_STRING  DeviceRegistryPath 
)

Definition at line 542 of file registry.c.

546 {
547  static WCHAR RegistryMachineSystem[] = L"\\REGISTRY\\MACHINE\\SYSTEM\\";
548  static WCHAR CurrentControlSet[] = L"CURRENTCONTROLSET\\";
549  static WCHAR ControlSet[] = L"CONTROLSET";
550  static WCHAR Insert1[] = L"Hardware Profiles\\Current\\System\\CurrentControlSet\\";
551  static WCHAR Insert2[] = L"\\Device";
552  UNICODE_STRING DeviceNumberString;
553  WCHAR DeviceNumberBuffer[20];
554  BOOLEAN Valid;
555  UNICODE_STRING AfterControlSet;
557 
558  AfterControlSet = *DriverRegistryPath;
559 
560  /* Convert DeviceNumber to string */
561  DeviceNumberString.Length = 0;
562  DeviceNumberString.MaximumLength = sizeof(DeviceNumberBuffer);
563  DeviceNumberString.Buffer = DeviceNumberBuffer;
564  Status = RtlIntegerToUnicodeString(DeviceNumber, 10, &DeviceNumberString);
565  if (!NT_SUCCESS(Status))
566  {
567  ERR_(VIDEOPRT, "RtlIntegerToUnicodeString(%u) returned 0x%08x\n", DeviceNumber, Status);
568  return Status;
569  }
570 
571  /* Check if path begins with \\REGISTRY\\MACHINE\\SYSTEM\\ */
572  Valid = (DriverRegistryPath->Length > sizeof(RegistryMachineSystem) &&
573  0 == _wcsnicmp(DriverRegistryPath->Buffer, RegistryMachineSystem,
574  wcslen(RegistryMachineSystem)));
575  if (Valid)
576  {
577  AfterControlSet.Buffer += wcslen(RegistryMachineSystem);
578  AfterControlSet.Length -= sizeof(RegistryMachineSystem) - sizeof(UNICODE_NULL);
579 
580  /* Check if path contains CURRENTCONTROLSET */
581  if (AfterControlSet.Length > sizeof(CurrentControlSet) &&
582  0 == _wcsnicmp(AfterControlSet.Buffer, CurrentControlSet, wcslen(CurrentControlSet)))
583  {
584  AfterControlSet.Buffer += wcslen(CurrentControlSet);
585  AfterControlSet.Length -= sizeof(CurrentControlSet) - sizeof(UNICODE_NULL);
586  }
587  /* Check if path contains CONTROLSETnum */
588  else if (AfterControlSet.Length > sizeof(ControlSet) &&
589  0 == _wcsnicmp(AfterControlSet.Buffer, ControlSet, wcslen(ControlSet)))
590  {
591  AfterControlSet.Buffer += wcslen(ControlSet);
592  AfterControlSet.Length -= sizeof(ControlSet) - sizeof(UNICODE_NULL);
593  while (AfterControlSet.Length > 0 &&
594  *AfterControlSet.Buffer >= L'0' &&
595  *AfterControlSet.Buffer <= L'9')
596  {
597  AfterControlSet.Buffer++;
598  AfterControlSet.Length -= sizeof(WCHAR);
599  }
600 
601  Valid = (AfterControlSet.Length > 0 && L'\\' == *AfterControlSet.Buffer);
602  AfterControlSet.Buffer++;
603  AfterControlSet.Length -= sizeof(WCHAR);
604  AfterControlSet.MaximumLength = AfterControlSet.Length;
605  }
606  else
607  {
608  Valid = FALSE;
609  }
610  }
611 
612  if (Valid)
613  {
614  DeviceRegistryPath->MaximumLength = DriverRegistryPath->Length + sizeof(Insert1) + sizeof(Insert2)
615  + DeviceNumberString.Length;
616  DeviceRegistryPath->Buffer = ExAllocatePoolWithTag(PagedPool,
617  DeviceRegistryPath->MaximumLength,
619  if (DeviceRegistryPath->Buffer != NULL)
620  {
621  /* Build device path */
622  wcsncpy(DeviceRegistryPath->Buffer,
624  AfterControlSet.Buffer - DriverRegistryPath->Buffer);
625  DeviceRegistryPath->Length = (AfterControlSet.Buffer - DriverRegistryPath->Buffer) * sizeof(WCHAR);
626  RtlAppendUnicodeToString(DeviceRegistryPath, Insert1);
627  RtlAppendUnicodeStringToString(DeviceRegistryPath, &AfterControlSet);
628  RtlAppendUnicodeToString(DeviceRegistryPath, Insert2);
629  RtlAppendUnicodeStringToString(DeviceRegistryPath, &DeviceNumberString);
630 
631  /* Check if registry key exists */
632  Valid = NT_SUCCESS(RtlCheckRegistryKey(RTL_REGISTRY_ABSOLUTE, DeviceRegistryPath->Buffer));
633 
634  if (!Valid)
635  ExFreePoolWithTag(DeviceRegistryPath->Buffer, TAG_VIDEO_PORT);
636  }
637  else
638  {
639  Valid = FALSE;
640  }
641  }
642  else
643  {
644  WARN_(VIDEOPRT, "Unparsable registry path %wZ\n", DriverRegistryPath);
645  }
646 
647  /* If path doesn't point to *ControlSet*, use DriverRegistryPath directly */
648  if (!Valid)
649  {
650  DeviceRegistryPath->MaximumLength = DriverRegistryPath->Length + sizeof(Insert2) + DeviceNumberString.Length;
651  DeviceRegistryPath->Buffer = ExAllocatePoolWithTag(NonPagedPool,
652  DeviceRegistryPath->MaximumLength,
654 
655  if (!DeviceRegistryPath->Buffer)
656  return STATUS_NO_MEMORY;
657 
658  RtlCopyUnicodeString(DeviceRegistryPath, DriverRegistryPath);
659  RtlAppendUnicodeToString(DeviceRegistryPath, Insert2);
660  RtlAppendUnicodeStringToString(DeviceRegistryPath, &DeviceNumberString);
661  }
662 
663  DPRINT("Formatted registry key '%wZ' -> '%wZ'\n",
664  DriverRegistryPath, DeviceRegistryPath);
665 
666  return STATUS_SUCCESS;
667 }
#define TAG_VIDEO_PORT
Definition: videoprt.h:38
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define ERR_(ch,...)
Definition: debug.h:156
LONG NTSTATUS
Definition: precomp.h:26
_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
Status
Definition: gdiplustypes.h:24
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
NTSYSAPI NTSTATUS NTAPI RtlIntegerToUnicodeString(ULONG Value, ULONG Base, PUNICODE_STRING String)
__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:17
_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
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
NTSTATUS NTAPI RtlCheckRegistryKey(IN ULONG RelativeTo, IN PWSTR Path)
Definition: registry.c:583
#define STATUS_SUCCESS
Definition: shellext.h:65
_In_ PCHAR _In_ ULONG DeviceNumber
Definition: classpnp.h:1229
#define DPRINT
Definition: sndvol32.h:71
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define WARN_(ch,...)
Definition: debug.h:157

Referenced by IntVideoPortCreateAdapterDeviceObject().

◆ IntDetachFromCSRSS()

VOID FASTCALL IntDetachFromCSRSS ( PKPROCESS CallingProcess,
PKAPC_STATE  ApcState 
)

Definition at line 509 of file videoprt.c.

512 {
513  if (*CallingProcess != CsrProcess)
514  {
516  }
517 }
PKPROCESS CsrProcess
Definition: videoprt.c:39
VOID NTAPI KeUnstackDetachProcess(IN PRKAPC_STATE ApcState)
Definition: procobj.c:756
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1679

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

◆ IntInitializeVideoAddressSpace()

NTSTATUS NTAPI IntInitializeVideoAddressSpace ( VOID  )

Definition at line 200 of file int10.c.

201 {
203  NT_ASSERT(FALSE);
204  return STATUS_NOT_IMPLEMENTED;
205 }
return STATUS_NOT_IMPLEMENTED
#define FALSE
Definition: types.h:117
#define UNIMPLEMENTED
Definition: debug.h:115
#define NT_ASSERT
Definition: rtlfuncs.h:3310

Referenced by IntVideoPortDispatchOpen().

◆ IntInt10AllocateBuffer()

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

Definition at line 210 of file int10.c.

215 {
217 #ifdef _M_IX86
218  PVOID MemoryAddress;
219  PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess();
221  SIZE_T Size;
222 
223  TRACE_(VIDEOPRT, "IntInt10AllocateBuffer\n");
224 
225  IntAttachToCSRSS(&CallingProcess, &ApcState);
226 
227  Size = *Length;
228  MemoryAddress = (PVOID)0x20000;
229 
230  Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
231  &MemoryAddress,
232  0,
233  &Size,
234  MEM_COMMIT,
236  if (!NT_SUCCESS(Status))
237  {
238  WARN_(VIDEOPRT, "- ZwAllocateVirtualMemory failed\n");
239  IntDetachFromCSRSS(&CallingProcess, &ApcState);
241  }
242 
243  if (MemoryAddress > (PVOID)(0x100000 - Size))
244  {
245  ZwFreeVirtualMemory(NtCurrentProcess(),
246  &MemoryAddress,
247  &Size,
248  MEM_RELEASE);
249  WARN_(VIDEOPRT, "- Unacceptable memory allocated\n");
250  IntDetachFromCSRSS(&CallingProcess, &ApcState);
252  }
253 
254  *Length = (ULONG)Size;
255  *Seg = (USHORT)((ULONG_PTR)MemoryAddress >> 4);
256  *Off = (USHORT)((ULONG_PTR)MemoryAddress & 0xF);
257 
258  INFO_(VIDEOPRT, "- Segment: %x\n", (ULONG_PTR)MemoryAddress >> 4);
259  INFO_(VIDEOPRT, "- Offset: %x\n", (ULONG_PTR)MemoryAddress & 0xF);
260  INFO_(VIDEOPRT, "- Length: %x\n", *Length);
261 
262  IntDetachFromCSRSS(&CallingProcess, &ApcState);
263 
264  return NO_ERROR;
265 #else
266  Status = x86BiosAllocateBuffer(Length, Seg, Off);
268 #endif
269 }
KAPC_STATE
Definition: ketypes.h:1280
_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:496
unsigned short USHORT
Definition: pedump.c:61
struct _KPROCESS * PKPROCESS
Definition: wdm.template.h:206
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1679
#define MEM_RELEASE
Definition: nt_native.h:1316
VOID FASTCALL IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:509
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 380 of file int10.c.

383 {
384 #ifdef _M_AMD64
385  X86_BIOS_REGISTERS BiosContext;
386 #else
388 #endif
390  PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess();
392 
393  /* Attach to CSRSS */
394  IntAttachToCSRSS(&CallingProcess, &ApcState);
395 
396  /* Clear the context */
398 
399  /* Fill out the bios arguments */
400  BiosContext.Eax = BiosArguments->Eax;
401  BiosContext.Ebx = BiosArguments->Ebx;
402  BiosContext.Ecx = BiosArguments->Ecx;
403  BiosContext.Edx = BiosArguments->Edx;
404  BiosContext.Esi = BiosArguments->Esi;
405  BiosContext.Edi = BiosArguments->Edi;
406  BiosContext.Ebp = BiosArguments->Ebp;
407  BiosContext.SegDs = BiosArguments->SegDs;
408  BiosContext.SegEs = BiosArguments->SegEs;
409 
410  /* Do the ROM BIOS call */
412  Executive,
413  KernelMode,
414  FALSE,
415  NULL);
416 
417  /* The kernel needs access here */
419 #ifdef _M_AMD64
421 #else
422  Status = Ke386CallBios(0x10, &BiosContext);
423 #endif
425 
427 
428  /* Return the arguments */
429  BiosArguments->Eax = BiosContext.Eax;
430  BiosArguments->Ebx = BiosContext.Ebx;
431  BiosArguments->Ecx = BiosContext.Ecx;
432  BiosArguments->Edx = BiosContext.Edx;
433  BiosArguments->Esi = BiosContext.Esi;
434  BiosArguments->Edi = BiosContext.Edi;
435  BiosArguments->Ebp = BiosContext.Ebp;
436  BiosArguments->SegDs = (USHORT)BiosContext.SegDs;
437  BiosArguments->SegEs = (USHORT)BiosContext.SegEs;
438 
439  /* Detach and return status */
440  IntDetachFromCSRSS(&CallingProcess, &ApcState);
441 
442  if (NT_SUCCESS(Status))
443  {
444  return NO_ERROR;
445  }
446 
448 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
KAPC_STATE
Definition: ketypes.h:1280
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
static VOID ProtectLowV86Mem(VOID)
Definition: int10.c:39
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:496
unsigned short USHORT
Definition: pedump.c:61
struct _KPROCESS * PKPROCESS
Definition: wdm.template.h:206
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1679
static VOID UnprotectLowV86Mem(VOID)
Definition: int10.c:62
#define NULL
Definition: types.h:112
VOID FASTCALL IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:509
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 273 of file int10.c.

277 {
279 #ifdef _M_IX86
280  PVOID MemoryAddress = (PVOID)((ULONG_PTR)(Seg << 4) | Off);
281  PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess();
283  SIZE_T Size = 0;
284 
285  TRACE_(VIDEOPRT, "IntInt10FreeBuffer\n");
286  INFO_(VIDEOPRT, "- Segment: %x\n", Seg);
287  INFO_(VIDEOPRT, "- Offset: %x\n", Off);
288 
289  IntAttachToCSRSS(&CallingProcess, &ApcState);
290  Status = ZwFreeVirtualMemory(NtCurrentProcess(),
291  &MemoryAddress,
292  &Size,
293  MEM_RELEASE);
294 
295  IntDetachFromCSRSS(&CallingProcess, &ApcState);
296 
297  return Status;
298 #else
299  Status = x86BiosFreeBuffer(Seg, Off);
301 #endif
302 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
KAPC_STATE
Definition: ketypes.h:1280
#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:496
struct _KPROCESS * PKPROCESS
Definition: wdm.template.h:206
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1679
#define MEM_RELEASE
Definition: nt_native.h:1316
VOID FASTCALL IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:509

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 306 of file int10.c.

312 {
313 #ifdef _M_IX86
314  PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess();
316 
317  TRACE_(VIDEOPRT, "IntInt10ReadMemory\n");
318  INFO_(VIDEOPRT, "- Segment: %x\n", Seg);
319  INFO_(VIDEOPRT, "- Offset: %x\n", Off);
320  INFO_(VIDEOPRT, "- Buffer: %x\n", Buffer);
321  INFO_(VIDEOPRT, "- Length: %x\n", Length);
322 
323  IntAttachToCSRSS(&CallingProcess, &ApcState);
324 
325  if (IsLowV86Mem(Seg, Off))
327  RtlCopyMemory(Buffer, (PVOID)((ULONG_PTR)(Seg << 4) | Off), Length);
328  if (IsLowV86Mem(Seg, Off))
330 
331  IntDetachFromCSRSS(&CallingProcess, &ApcState);
332 
333  return NO_ERROR;
334 #else
336 
337  Status = x86BiosReadMemory(Seg, Off, Buffer, Length);
339 #endif
340 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
KAPC_STATE
Definition: ketypes.h:1280
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define INFO_(ch,...)
Definition: debug.h:159
LONG NTSTATUS
Definition: precomp.h:26
static VOID ProtectLowV86Mem(VOID)
Definition: int10.c:39
#define NO_ERROR
Definition: dderror.h:5
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IsLowV86Mem(_Seg, _Off)
Definition: int10.c:33
#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:496
struct _KPROCESS * PKPROCESS
Definition: wdm.template.h:206
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1679
static VOID UnprotectLowV86Mem(VOID)
Definition: int10.c:62
VOID FASTCALL IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:509
#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 344 of file int10.c.

350 {
351 #ifdef _M_IX86
352  PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess();
354 
355  TRACE_(VIDEOPRT, "IntInt10WriteMemory\n");
356  INFO_(VIDEOPRT, "- Segment: %x\n", Seg);
357  INFO_(VIDEOPRT, "- Offset: %x\n", Off);
358  INFO_(VIDEOPRT, "- Buffer: %x\n", Buffer);
359  INFO_(VIDEOPRT, "- Length: %x\n", Length);
360 
361  IntAttachToCSRSS(&CallingProcess, &ApcState);
362  if (IsLowV86Mem(Seg, Off))
364  RtlCopyMemory((PVOID)((ULONG_PTR)(Seg << 4) | Off), Buffer, Length);
365  if (IsLowV86Mem(Seg, Off))
367  IntDetachFromCSRSS(&CallingProcess, &ApcState);
368 
369  return NO_ERROR;
370 #else
372 
373  Status = x86BiosWriteMemory(Seg, Off, Buffer, Length);
375 #endif
376 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
KAPC_STATE
Definition: ketypes.h:1280
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define INFO_(ch,...)
Definition: debug.h:159
LONG NTSTATUS
Definition: precomp.h:26
static VOID ProtectLowV86Mem(VOID)
Definition: int10.c:39
#define NO_ERROR
Definition: dderror.h:5
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IsLowV86Mem(_Seg, _Off)
Definition: int10.c:33
#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:496
struct _KPROCESS * PKPROCESS
Definition: wdm.template.h:206
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1679
static VOID UnprotectLowV86Mem(VOID)
Definition: int10.c:62
VOID FASTCALL IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:509
#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 297 of file registry.c.

299 {
300  static UNICODE_STRING SettingsKeyName = RTL_CONSTANT_STRING(L"Settings");
301  HANDLE DevInstRegKey, SourceKeyHandle, DestKeyHandle;
304 
305  /* Open the software key: HKLM\System\CurrentControlSet\Control\Class<ClassGUID><n> */
309  &DevInstRegKey);
310  if (Status != STATUS_SUCCESS)
311  {
312  ERR_(VIDEOPRT, "Failed to open device software key. Status 0x%lx\n", Status);
313  return Status;
314  }
315 
316  /* Open the 'Settings' sub-key */
318  &SettingsKeyName,
321  NULL);
322  Status = ZwOpenKey(&DestKeyHandle, KEY_WRITE, &ObjectAttributes);
323 
324  /* Close the device software key */
326 
327  if (Status != STATUS_SUCCESS)
328  {
329  ERR_(VIDEOPRT, "Failed to open settings key. Status 0x%lx\n", Status);
330  return Status;
331  }
332 
333  /* Open the device profile key */
335  &DeviceExtension->RegistryPath,
337  NULL,
338  NULL);
339  Status = ZwOpenKey(&SourceKeyHandle, KEY_WRITE, &ObjectAttributes);
340  if (Status != STATUS_SUCCESS)
341  {
342  ERR_(VIDEOPRT, "ZwOpenKey failed for settings key: status 0x%lx\n", Status);
343  ObCloseHandle(DestKeyHandle, KernelMode);
344  return Status;
345  }
346 
347  IntCopyRegistryValue(SourceKeyHandle, DestKeyHandle, L"InstalledDisplayDrivers");
348  IntCopyRegistryValue(SourceKeyHandle, DestKeyHandle, L"Attach.ToDesktop");
349 
350  ObCloseHandle(SourceKeyHandle, KernelMode);
351  ObCloseHandle(DestKeyHandle, KernelMode);
352 
353  return STATUS_SUCCESS;
354 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define 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:3375
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:1125
#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:2191
#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:230
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

Referenced by IntVideoPortCreateAdapterDeviceObject().

◆ IntVideoPortAddDevice()

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

Definition at line 334 of file dispatch.c.

337 {
341 
342  /* Get the initialization data we saved in VideoPortInitialize. */
344 
345  /* Create adapter device object. */
349  DriverExtension->InitializationData.StartingDeviceNumber,
350  0,
351  &DeviceObject);
352  if (!NT_SUCCESS(Status))
353  {
354  ERR_(VIDEOPRT, "IntVideoPortCreateAdapterDeviceObject() failed with status 0x%lx\n", Status);
355  }
356  return Status;
357 }
#define ERR_(ch,...)
Definition: debug.h:156
LONG NTSTATUS
Definition: precomp.h:26
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1155
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
NTSTATUS NTAPI IntVideoPortCreateAdapterDeviceObject(_In_ PDRIVER_OBJECT DriverObject, _In_ PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, _In_opt_ PDEVICE_OBJECT PhysicalDeviceObject, _In_ USHORT AdapterNumber, _In_ USHORT DisplayNumber, _Out_opt_ PDEVICE_OBJECT *DeviceObject)
Definition: videoprt.c:152
_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:1877
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31

Referenced by VideoPortInitialize().

◆ IntVideoPortCreateAdapterDeviceObject()

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

Definition at line 152 of file videoprt.c.

159 {
160  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
162  ULONG PciSlotNumber;
164  ULONG Size;
166  WCHAR DeviceBuffer[20];
168  PDEVICE_OBJECT DeviceObject_;
169 
170  if (DeviceObject == NULL)
171  DeviceObject = &DeviceObject_;
172 
173  /*
174  * Find the first free device number that can be used for video device
175  * object names and symlinks.
176  */
178  if (DeviceNumber == (ULONG)-1)
179  {
180  WARN_(VIDEOPRT, "Can't find free device number\n");
181  return STATUS_UNSUCCESSFUL;
182  }
183 
184  /*
185  * Create the device object.
186  */
187 
188  /* Create a unicode device name. */
189  swprintf(DeviceBuffer, L"\\Device\\Video%lu", DeviceNumber);
190  RtlInitUnicodeString(&DeviceName, DeviceBuffer);
191 
192  INFO_(VIDEOPRT, "HwDeviceExtension size is: 0x%x\n",
193  DriverExtension->InitializationData.HwDeviceExtensionSize);
194 
195  /* Create the device object. */
197  DriverExtension->InitializationData.HwDeviceExtensionSize;
199  Size,
200  &DeviceName,
202  0,
203  TRUE,
204  DeviceObject);
205 
206  if (!NT_SUCCESS(Status))
207  {
208  WARN_(VIDEOPRT, "IoCreateDevice call failed with status 0x%08x\n", Status);
209  return Status;
210  }
211 
212  /*
213  * Set the buffering strategy here. If you change this, remember
214  * to change VidDispatchDeviceControl too.
215  */
216 
217  (*DeviceObject)->Flags |= DO_BUFFERED_IO;
218 
219  /* Initialize device extension. */
220  DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)((*DeviceObject)->DeviceExtension);
221  DeviceExtension->Common.Fdo = TRUE;
222  DeviceExtension->DeviceNumber = DeviceNumber;
223  DeviceExtension->DriverObject = DriverObject;
224  DeviceExtension->PhysicalDeviceObject = PhysicalDeviceObject;
225  DeviceExtension->FunctionalDeviceObject = *DeviceObject;
226  DeviceExtension->DriverExtension = DriverExtension;
227  DeviceExtension->SessionId = -1;
228  DeviceExtension->AdapterNumber = AdapterNumber;
229  DeviceExtension->DisplayNumber = DisplayNumber;
230 
231  InitializeListHead(&DeviceExtension->ChildDeviceList);
232 
233  /* Get the registry path associated with this device. */
235  DeviceExtension->AdapterNumber,
236  &DeviceExtension->RegistryPath);
237  if (!NT_SUCCESS(Status))
238  {
239  WARN_(VIDEOPRT, "IntCreateRegistryPath() call failed with status 0x%08x\n", Status);
241  *DeviceObject = NULL;
242  return Status;
243  }
244 
245  if (PhysicalDeviceObject != NULL)
246  {
247  /* Get bus number from the upper level bus driver. */
248  Size = sizeof(ULONG);
251  Size,
252  &DeviceExtension->SystemIoBusNumber,
253  &Size);
254  if (!NT_SUCCESS(Status))
255  {
256  WARN_(VIDEOPRT, "Couldn't get an information from bus driver. We will try to\n"
257  "use legacy detection method, but even that doesn't mean that\n"
258  "it will work.\n");
259  DeviceExtension->PhysicalDeviceObject = NULL;
260  }
261  }
262 
263  DeviceExtension->AdapterInterfaceType =
264  DriverExtension->InitializationData.AdapterInterfaceType;
265 
266  if (PhysicalDeviceObject != NULL)
267  {
268  /* Get bus type from the upper level bus driver. */
269  Size = sizeof(ULONG);
272  Size,
273  &DeviceExtension->AdapterInterfaceType,
274  &Size);
275 
276  /* Get bus device address from the upper level bus driver. */
277  Size = sizeof(ULONG);
280  Size,
281  &PciSlotNumber,
282  &Size);
283 
284  /* Convert slotnumber to PCI_SLOT_NUMBER */
285  SlotNumber.u.AsULONG = 0;
286  SlotNumber.u.bits.DeviceNumber = (PciSlotNumber >> 16) & 0xFFFF;
287  SlotNumber.u.bits.FunctionNumber = PciSlotNumber & 0xFFFF;
288  DeviceExtension->SystemIoSlotNumber = SlotNumber.u.AsULONG;
289  }
290 
291  InitializeListHead(&DeviceExtension->AddressMappingListHead);
292  InitializeListHead(&DeviceExtension->DmaAdapterList);
293 
294  KeInitializeDpc(&DeviceExtension->DpcObject,
296  DeviceExtension);
297 
298  KeInitializeMutex(&DeviceExtension->DeviceLock, 0);
299 
300  /* Attach the device. */
301  if ((PhysicalDeviceObject != NULL) && (DisplayNumber == 0))
303  *DeviceObject,
305 
306  Status = IntCreateNewRegistryPath(DeviceExtension);
307  if (!NT_SUCCESS(Status))
308  {
309  ERR_(VIDEOPRT, "IntCreateNewRegistryPath() failed with status 0x%08x\n", Status);
311  *DeviceObject = NULL;
312  return Status;
313  }
314 
315  IntSetupDeviceSettingsKey(DeviceExtension);
316 
317  /* Remove the initailizing flag */
318  (*DeviceObject)->Flags &= ~DO_DEVICE_INITIALIZING;
319 
320  /* Set up the VIDEO/DEVICEMAP registry keys */
321  Status = IntVideoPortAddDeviceMapLink(DeviceExtension);
322  if (!NT_SUCCESS(Status))
323  {
324  ERR_(VIDEOPRT, "IntVideoPortAddDeviceMapLink() failed with status 0x%08x\n", Status);
326  *DeviceObject = NULL;
327  return Status;
328  }
329 
330  if (DisplayNumber == 0)
331  {
332  DriverExtension->InitializationData.StartingDeviceNumber++;
333  }
334 
335  return STATUS_SUCCESS;
336 }
#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:358
VOID NTAPI IntVideoPortDeferredRoutine(IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: videoprt.c:139
#define INFO_(ch,...)
Definition: debug.h:159
VIDEO_PORT_DRIVER_EXTENSION * DriverExtension
Definition: videoprt.h:103
NTSTATUS NTAPI IntCreateRegistryPath(IN PCUNICODE_STRING DriverRegistryPath, IN ULONG DeviceNumber, OUT PUNICODE_STRING DeviceRegistryPath)
Definition: registry.c:542
#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 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:297
#define swprintf
Definition: precomp.h:40
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:1952
static ULONG VideoPortMaxObjectNumber
Definition: videoprt.c:40
_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:141
#define DO_BUFFERED_IO
Definition: env_spec_w32.h:394
#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
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
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
static NTSTATUS IntVideoPortAddDeviceMapLink(PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: videoprt.c:58
#define NULL
Definition: types.h:112
VIDEO_PORT_COMMON_EXTENSION Common
Definition: videoprt.h:84
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31
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:712
INTERFACE_TYPE AdapterInterfaceType
Definition: videoprt.h:98
#define WARN_(ch,...)
Definition: debug.h:157

Referenced by IntVideoPortAddDevice(), VideoPortCreateSecondaryDisplay(), and VideoPortInitialize().

◆ IntVideoPortDispatchCleanup()

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

Definition at line 1100 of file dispatch.c.

1103 {
1104  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1105 
1106  DeviceExtension = DeviceObject->DeviceExtension;
1107  RtlFreeUnicodeString(&DeviceExtension->RegistryPath);
1108 
1109  Irp->IoStatus.Status = STATUS_SUCCESS;
1110  Irp->IoStatus.Information = 0;
1112 
1113  return STATUS_SUCCESS;
1114 }
_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:598
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 432 of file dispatch.c.

435 {
436  TRACE_(VIDEOPRT, "IntVideoPortDispatchClose\n");
437 
439 
440  Irp->IoStatus.Status = STATUS_SUCCESS;
442  return STATUS_SUCCESS;
443 }
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:598
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchDeviceControl()

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

Definition at line 717 of file dispatch.c.

720 {
721  PIO_STACK_LOCATION IrpStack;
724 
725  TRACE_(VIDEOPRT, "IntVideoPortDispatchDeviceControl\n");
726 
727  IrpStack = IoGetCurrentIrpStackLocation(Irp);
728 
729  switch (IrpStack->MajorFunction)
730  {
732  /* This is the main part of this function and is handled below */
733  break;
734 
735  case IRP_MJ_SHUTDOWN:
736  {
737  /* Dereference CSRSS */
738  PKPROCESS OldCsrProcess;
739  OldCsrProcess = InterlockedExchangePointer((PVOID*)&CsrProcess, NULL);
740  if (OldCsrProcess)
741  ObDereferenceObject(OldCsrProcess);
742 
743  Irp->IoStatus.Status = STATUS_SUCCESS;
745  return STATUS_SUCCESS;
746  }
747 
748  default:
749  ERR_(VIDEOPRT, "- Unknown MajorFunction 0x%x\n", IrpStack->MajorFunction);
750  Irp->IoStatus.Status = STATUS_SUCCESS;
752  return STATUS_SUCCESS;
753  }
754 
755  IoControlCode = IrpStack->Parameters.DeviceIoControl.IoControlCode;
756 
757  INFO_(VIDEOPRT, "- IoControlCode: 0x%x: %s\n", IoControlCode, IoctlName(IoControlCode));
758 
759  switch (IoControlCode)
760  {
764  WARN_(VIDEOPRT, "- IOCTL_VIDEO_*_VDM are UNIMPLEMENTED!\n");
766  break;
767 
770  WARN_(VIDEOPRT, "- IOCTL_VIDEO_GET/SET_OUTPUT_DEVICE_POWER_STATE are UNIMPLEMENTED!\n");
772  break;
773 
776  WARN_(VIDEOPRT, "- IOCTL_VIDEO_GET/SET_POWER_MANAGEMENT are UNIMPLEMENTED!\n");
778  break;
779 
783  WARN_(VIDEOPRT, "- IOCTL_VIDEO_*_BRIGHTNESS are UNIMPLEMENTED!\n");
785  break;
786 
788  INFO_(VIDEOPRT, "- IOCTL_VIDEO_INIT_WIN32K_CALLBACKS\n");
790  Irp->AssociatedIrp.SystemBuffer,
791  IrpStack->Parameters.DeviceIoControl.InputBufferLength,
792  &Irp->IoStatus.Information);
793  break;
794 
796  WARN_(VIDEOPRT, "- IOCTL_VIDEO_IS_VGA_DEVICE is UNIMPLEMENTED!\n");
798  break;
799 
801  INFO_(VIDEOPRT, "- IOCTL_VIDEO_USE_DEVICE_IN_SESSION\n");
803  Irp->AssociatedIrp.SystemBuffer,
804  IrpStack->Parameters.DeviceIoControl.InputBufferLength,
805  &Irp->IoStatus.Information);
806  break;
807 
809  INFO_(VIDEOPRT, "- IOCTL_VIDEO_PREPARE_FOR_EARECOVERY\n");
810  /*
811  * The Win32k Watchdog Timer detected that a thread spent more time
812  * in a display driver than the allotted time its threshold specified,
813  * and thus is going to attempt to recover by switching to VGA mode.
814  * If this attempt fails, the watchdog generates bugcheck 0xEA
815  * "THREAD_STUCK_IN_DEVICE_DRIVER".
816  *
817  * Prepare the recovery by resetting the display adapters to
818  * standard VGA 80x25 text mode.
819  */
822  break;
823 
824  default:
825  /* Forward to the Miniport Driver */
827  break;
828  }
829 
830  INFO_(VIDEOPRT, "- Returned status: 0x%x\n", Status);
831 
832  Irp->IoStatus.Status = Status;
834  return Status;
835 }
#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:565
#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:446
_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:623
#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:609
#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:2793
#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:598
static NTSTATUS VideoPortForwardDeviceControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:650
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
#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 369 of file dispatch.c.

372 {
374  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
376 
377  TRACE_(VIDEOPRT, "IntVideoPortDispatchOpen\n");
378 
379  if (!CsrProcess)
380  {
381  /*
382  * We know the first open call will be from the CSRSS process
383  * to let us know its handle.
384  */
385  INFO_(VIDEOPRT, "Referencing CSRSS\n");
388  INFO_(VIDEOPRT, "CsrProcess 0x%p\n", CsrProcess);
389 
391  if (!NT_SUCCESS(Status))
392  {
393  ERR_(VIDEOPRT, "IntInitializeVideoAddressSpace() failed: 0x%lx\n", Status);
395  CsrProcess = NULL;
396  return Status;
397  }
398  }
399 
400  DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
401  DriverExtension = DeviceExtension->DriverExtension;
402 
403  // FIXME: (Re-)initialize INBV only if DeviceObject doesn't belong to a mirror driver.
405 
406  if (DriverExtension->InitializationData.HwInitialize(&DeviceExtension->MiniPortDeviceExtension))
407  {
408  Irp->IoStatus.Status = STATUS_SUCCESS;
409  InterlockedIncrement((PLONG)&DeviceExtension->DeviceOpened);
410  }
411  else
412  {
413  Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
414  }
415 
416  Irp->IoStatus.Information = FILE_OPENED;
418 
419  return STATUS_SUCCESS;
420 }
#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:200
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
CHAR POINTER_ALIGNMENT MiniPortDeviceExtension[1]
Definition: videoprt.h:113
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#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
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#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 386 of file child.c.

389 {
391  NTSTATUS Status = Irp->IoStatus.Status;
392 
394 
395  switch (IrpSp->MinorFunction)
396  {
397  case IRP_MN_START_DEVICE:
398  case IRP_MN_STOP_DEVICE:
399  /* Nothing to do */
401  break;
402 
405  /* None (keep old status) */
406  break;
407 
408  case IRP_MN_QUERY_ID:
409  /* Call our helper */
410  Status = IntVideoPortChildQueryId(DeviceObject->DeviceExtension,
411  Irp,
412  IrpSp);
413  break;
414 
416  /* Call our helper */
418  Irp,
419  IrpSp);
420  break;
421 
425  break;
426 
428  Irp->IoStatus.Status = STATUS_SUCCESS;
431  return STATUS_SUCCESS;
432 
434  /* Call our helper */
436  Irp,
437  IrpSp);
438  break;
439 
441  /* Call our helper */
443  Irp,
444  IrpSp);
445  break;
446 
447  default:
448  break;
449  }
450 
451  Irp->IoStatus.Status = Status;
452 
454 
455  return Status;
456 }
#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:319
#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:292
NTSTATUS NTAPI IntVideoPortChildQueryText(IN PVIDEO_PORT_CHILD_EXTENSION ChildExtension, IN PIRP Irp, IN PIO_STACK_LOCATION IrpSp)
Definition: child.c:242
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
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:117
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#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 1086 of file dispatch.c.

1089 {
1090  PVIDEO_PORT_COMMON_EXTENSION CommonExtension = DeviceObject->DeviceExtension;
1091 
1092  if (CommonExtension->Fdo)
1094  else
1096 }
NTSTATUS NTAPI IntVideoPortDispatchPdoPnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: child.c:386
NTSTATUS NTAPI IntVideoPortDispatchFdoPnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:1009
_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 1118 of file dispatch.c.

1121 {
1123  NTSTATUS Status = Irp->IoStatus.Status;
1124  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
1125 
1127 
1128  if (DeviceExtension->Common.Fdo)
1129  {
1132  return PoCallDriver(DeviceExtension->NextDeviceObject, Irp);
1133  }
1134  else
1135  {
1136  switch (IrpSp->MinorFunction)
1137  {
1138  case IRP_MN_QUERY_POWER:
1139  case IRP_MN_SET_POWER:
1141  break;
1142  }
1144  Irp->IoStatus.Status = Status;
1146  return Status;
1147  }
1148 }
#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:2793
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:746
_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:598
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchSystemControl()

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

Definition at line 1152 of file dispatch.c.

1155 {
1156  NTSTATUS Status;
1157  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
1158 
1159  if (DeviceExtension->Common.Fdo)
1160  {
1162  return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
1163  }
1164  else
1165  {
1166  Status = Irp->IoStatus.Status;
1168  return Status;
1169  }
1170 }
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:598

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.Status;
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:44
#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:1877
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
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31
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
struct _LARGE_INTEGER::@2239 u
#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 341 of file videoprt.c.

345 {
346  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
348  VIDEO_PORT_CONFIG_INFO ConfigInfo;
350  UCHAR Again = FALSE;
351  BOOL LegacyDetection = FALSE;
352 
353  DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
354 
355  /* Setup a ConfigInfo structure that we will pass to HwFindAdapter. */
356  RtlZeroMemory(&ConfigInfo, sizeof(VIDEO_PORT_CONFIG_INFO));
357  ConfigInfo.Length = sizeof(VIDEO_PORT_CONFIG_INFO);
358  ConfigInfo.AdapterInterfaceType = DeviceExtension->AdapterInterfaceType;
359  if (ConfigInfo.AdapterInterfaceType == PCIBus)
360  ConfigInfo.InterruptMode = LevelSensitive;
361  else
362  ConfigInfo.InterruptMode = Latched;
363  ConfigInfo.DriverRegistryPath = DriverExtension->RegistryPath.Buffer;
365  ConfigInfo.SystemIoBusNumber = DeviceExtension->SystemIoBusNumber;
366  ConfigInfo.BusInterruptLevel = DeviceExtension->InterruptLevel;
367  ConfigInfo.BusInterruptVector = DeviceExtension->InterruptVector;
368 
371  sizeof(SystemBasicInfo),
372  NULL);
373  if (NT_SUCCESS(Status))
374  {
377  }
378 
379  // FIXME: Check the adapter key and update VideoDebugLevel variable.
380 
381  /*
382  * Call miniport HwVidFindAdapter entry point to detect if
383  * particular device is present. There are two possible code
384  * paths. The first one is for Legacy drivers (NT4) and cases
385  * when we don't have information about what bus we're on. The
386  * second case is the standard one for Plug & Play drivers.
387  */
388  if (DeviceExtension->PhysicalDeviceObject == NULL)
389  {
390  LegacyDetection = TRUE;
391  }
392 
393  if (LegacyDetection)
394  {
395  ULONG BusNumber, MaxBuses;
396 
397  MaxBuses = DeviceExtension->AdapterInterfaceType == PCIBus ? PCI_MAX_BRIDGE_NUMBER : 1;
398 
399  for (BusNumber = 0; BusNumber < MaxBuses; BusNumber++)
400  {
401  DeviceExtension->SystemIoBusNumber =
402  ConfigInfo.SystemIoBusNumber = BusNumber;
403 
404  RtlZeroMemory(&DeviceExtension->MiniPortDeviceExtension,
405  DriverExtension->InitializationData.HwDeviceExtensionSize);
406 
407  /* FIXME: Need to figure out what string to pass as param 3. */
408  Status = DriverExtension->InitializationData.HwFindAdapter(
409  &DeviceExtension->MiniPortDeviceExtension,
410  DriverExtension->HwContext,
411  NULL,
412  &ConfigInfo,
413  &Again);
414 
416  {
417  continue;
418  }
419  else if (Status == NO_ERROR)
420  {
421  break;
422  }
423  else
424  {
425  ERR_(VIDEOPRT, "HwFindAdapter call failed with error 0x%X\n", Status);
426  goto Failure;
427  }
428  }
429  }
430  else
431  {
432  /* FIXME: Need to figure out what string to pass as param 3. */
433  Status = DriverExtension->InitializationData.HwFindAdapter(
434  &DeviceExtension->MiniPortDeviceExtension,
435  DriverExtension->HwContext,
436  NULL,
437  &ConfigInfo,
438  &Again);
439  }
440 
441  if (Status != NO_ERROR)
442  {
443  ERR_(VIDEOPRT, "HwFindAdapter call failed with error 0x%X\n", Status);
444  goto Failure;
445  }
446 
447  /*
448  * Now we know the device is present, so let's do all additional tasks
449  * such as creating symlinks or setting up interrupts and timer.
450  */
451 
452  /* FIXME: Allocate hardware resources for device. */
453 
454  /* Allocate interrupt for device. */
456  {
458  goto Failure;
459  }
460 
461  /* Allocate timer for device. */
463  {
464  if (DeviceExtension->InterruptObject != NULL)
465  IoDisconnectInterrupt(DeviceExtension->InterruptObject);
466  ERR_(VIDEOPRT, "IntVideoPortSetupTimer failed\n");
468  goto Failure;
469  }
470 
471  /* If the device can be reset, insert it in the list of resettable adapters */
472  InitializeListHead(&DeviceExtension->HwResetListEntry);
473  if (DriverExtension->InitializationData.HwResetHw != NULL)
474  {
476  &DeviceExtension->HwResetListEntry,
478  }
479 
480  /* Query children of the device. */
482 
483  INFO_(VIDEOPRT, "STATUS_SUCCESS\n");
484  return STATUS_SUCCESS;
485 
486 Failure:
487  RtlFreeUnicodeString(&DeviceExtension->RegistryPath);
488  if (DeviceExtension->NextDeviceObject)
489  IoDetachDevice(DeviceExtension->NextDeviceObject);
491  return Status;
492 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define PCI_MAX_BRIDGE_NUMBER
Definition: iotypes.h:3600
#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
#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
PVOID NTAPI IntVideoPortGetProcAddress(IN PVOID HwDeviceExtension, IN PUCHAR FunctionName)
Definition: funclist.c:100
#define FALSE
Definition: types.h:117
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:1178
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
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
SYSTEM_BASIC_INFORMATION SystemBasicInfo
Definition: perfdata.c:45
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
CHAR POINTER_ALIGNMENT MiniPortDeviceExtension[1]
Definition: videoprt.h:113
struct _VIDEO_PORT_CONFIG_INFO VIDEO_PORT_CONFIG_INFO
unsigned char UCHAR
Definition: xmlstorage.h:181
PWSTR DriverRegistryPath
Definition: video.h:194
PDEVICE_OBJECT NextDeviceObject
Definition: videoprt.h:89
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
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31
unsigned int ULONG
Definition: retypes.h:1
#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
INTERFACE_TYPE AdapterInterfaceType
Definition: videoprt.h:98
#define ERROR_DEV_NOT_EXIST
Definition: dderror.h:8
ULONG BusInterruptVector
Definition: video.h:171
KINTERRUPT_MODE InterruptMode
Definition: video.h:172

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:1098
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
if(dx==0 &&dy==0)
Definition: linetemp.h:174
_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
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ ULONG _In_ ULONG _In_ ULONG _Out_ PKIRQL _Out_ PKAFFINITY Affinity
Definition: halfuncs.h:170
ULONG_PTR KAFFINITY
Definition: compat.h:85
#define NULL
Definition: types.h:112
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31
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
if(dx==0 &&dy==0)
Definition: linetemp.h:174
_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
#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
#define NULL
Definition: types.h:112
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31

Referenced by IntVideoPortFindAdapter().

◆ IntVideoPortUnload()

VOID NTAPI IntVideoPortUnload ( PDRIVER_OBJECT  DriverObject)

Definition at line 1174 of file dispatch.c.

1175 {
1176 }

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:467
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:2695
#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:3128

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