ReactOS 0.4.15-dev-7924-g5949c20
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 PIO_STACK_LOCATION IrpStack, IN PIRP Irp)
 
VOID IntVideoPortReleaseResources (_In_ PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
 
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 IntVideoPortEnumerateChildren (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
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
 
BOOLEAN VideoPortUseNewKey
 
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)
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Definition at line 134 of file videoprt.h.

◆ VIDEO_PORT_GET_DEVICE_EXTENSION

#define VIDEO_PORT_GET_DEVICE_EXTENSION (   MiniportExtension)
Value:
MiniportExtension, \
MiniPortDeviceExtension)

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;
510
514 {
516 }
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;
558 AgpInterface->AgpFreePhysical = IntAgpFreePhysical;
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}
VOID NTAPI IntAgpFreeVirtual(IN PVOID HwDeviceExtension, IN PVOID VirtualContext, IN ULONG Pages, IN ULONG Offset)
Definition: agp.c:331
PVOID NTAPI IntAgpReserveVirtual(IN PVOID HwDeviceExtension, IN HANDLE ProcessHandle, IN PVOID PhysicalContext, OUT PVOID *VirtualContext)
Definition: agp.c:419
BOOLEAN NTAPI IntAgpSetRate(IN PVOID HwDeviceExtension, IN ULONG Rate)
Definition: agp.c:479
BOOLEAN NTAPI IntAgpCommitPhysical(IN PVOID HwDeviceExtension, IN PVOID PhysicalContext, IN ULONG Pages, IN ULONG Offset)
Definition: agp.c:94
NTSTATUS IopInitiatePnpIrp(PDEVICE_OBJECT DeviceObject, PIO_STATUS_BLOCK IoStatusBlock, UCHAR MinorFunction, PIO_STACK_LOCATION Stack OPTIONAL)
Definition: agp.c:30
VOID NTAPI IntAgpFreePhysical(IN PVOID HwDeviceExtension, IN PVOID PhysicalContext, IN ULONG Pages, IN ULONG Offset)
Definition: agp.c:126
VOID NTAPI IntAgpReleasePhysical(IN PVOID HwDeviceExtension, IN PVOID PhysicalContext)
Definition: agp.c:154
PVOID NTAPI IntAgpCommitVirtual(IN PVOID HwDeviceExtension, IN PVOID VirtualContext, IN ULONG Pages, IN ULONG Offset)
Definition: agp.c:248
PHYSICAL_ADDRESS NTAPI IntAgpReservePhysical(IN PVOID HwDeviceExtension, IN ULONG Pages, IN VIDEO_PORT_CACHE_TYPE Caching, OUT PVOID *PhysicalContext)
Definition: agp.c:183
VOID NTAPI IntAgpReleaseVirtual(IN PVOID HwDeviceExtension, IN PVOID VirtualContext)
Definition: agp.c:385
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:25
#define ASSERT(a)
Definition: mode.c:44
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
struct _AGP_BUS_INTERFACE_STANDARD AGP_BUS_INTERFACE_STANDARD
#define AGP_BUS_INTERFACE_V2
Definition: ntagp.h:32
#define AGP_BUS_INTERFACE_V1
Definition: ntagp.h:31
struct _INTERFACE * PINTERFACE
#define VIDEO_PORT_AGP_INTERFACE_VERSION_1
Definition: video.h:123
#define VIDEO_PORT_AGP_INTERFACE_VERSION_2
Definition: video.h:124
struct _VIDEO_PORT_AGP_INTERFACE_2 * PVIDEO_PORT_AGP_INTERFACE_2
#define INFO_(ch,...)
Definition: debug.h:159
#define WARN_(ch,...)
Definition: debug.h:157
#define STATUS_SUCCESS
Definition: shellext.h:65
PINTERFACE_REFERENCE InterfaceReference
Definition: ntagp.h:183
PINTERFACE_DEREFERENCE InterfaceDereference
Definition: ntagp.h:184
union _IO_STACK_LOCATION::@1564 Parameters
struct _IO_STACK_LOCATION::@3978::@4004 QueryInterface
OUT PAGP_COMMIT_VIRTUAL AgpCommitVirtual
Definition: video.h:750
OUT PAGP_COMMIT_PHYSICAL AgpCommitPhysical
Definition: video.h:746
OUT PAGP_RESERVE_VIRTUAL AgpReserveVirtual
Definition: video.h:748
OUT PINTERFACE_DEREFERENCE InterfaceDereference
Definition: video.h:743
OUT PAGP_RESERVE_PHYSICAL AgpReservePhysical
Definition: video.h:744
OUT PAGP_FREE_VIRTUAL AgpFreeVirtual
Definition: video.h:751
OUT PAGP_SET_RATE AgpSetRate
Definition: video.h:753
OUT ULONGLONG AgpAllocationLimit
Definition: video.h:752
OUT PAGP_RELEASE_VIRTUAL AgpReleaseVirtual
Definition: video.h:749
OUT PINTERFACE_REFERENCE InterfaceReference
Definition: video.h:742
OUT PAGP_FREE_PHYSICAL AgpFreePhysical
Definition: video.h:747
OUT PAGP_RELEASE_PHYSICAL AgpReleasePhysical
Definition: video.h:745
PDEVICE_OBJECT NextDeviceObject
Definition: videoprt.h:89
AGP_BUS_INTERFACE_STANDARD AgpInterface
Definition: videoprt.h:105
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define VIDEO_PORT_GET_DEVICE_EXTENSION(MiniportExtension)
Definition: videoprt.h:140
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465
#define IRP_MN_QUERY_INTERFACE

Referenced by VideoPortQueryServices().

◆ IntAttachToCSRSS()

VOID FASTCALL IntAttachToCSRSS ( PKPROCESS CallingProcess,
PKAPC_STATE  ApcState 
)

Definition at line 575 of file videoprt.c.

578{
579 *CallingProcess = (PKPROCESS)PsGetCurrentProcess();
580 if (*CallingProcess != CsrProcess)
581 {
583 }
584}
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1765
VOID NTAPI KeStackAttachProcess(IN PKPROCESS Process, OUT PRKAPC_STATE ApcState)
Definition: procobj.c:704
PKPROCESS CsrProcess
Definition: videoprt.c:39
struct _KPROCESS * PKPROCESS
Definition: wdm.template.h:201
#define PsGetCurrentProcess
Definition: psfuncs.h:17

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 */
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,
76 {
77 /* Free the buffer and remember the required size */
79 InfoBuffer = NULL;
80 InformationLength = RequiredLength;
81
82 /* Try again */
83 continue;
84 }
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,
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
221Cleanup:
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:36
#define TRUE
Definition: types.h:120
static const WCHAR Cleanup[]
Definition: register.c:80
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define KernelMode
Definition: asm.h:34
@ KeyBasicInformation
Definition: nt_native.h:1131
@ KeyValueFullInformation
Definition: nt_native.h:1181
#define KEY_READ
Definition: nt_native.h:1023
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_WRITE
Definition: nt_native.h:1031
#define STATUS_NO_MORE_ENTRIES
Definition: ntstatus.h:205
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3379
unsigned short USHORT
Definition: pedump.c:61
#define ERR_(ch,...)
Definition: debug.h:156
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
USHORT MaximumLength
Definition: env_spec_w32.h:370
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define TAG_VIDEO_PORT_BUFFER
Definition: videoprt.h:39
_In_ WDFCOLLECTION _In_ ULONG Index
NTSTATUS NTAPI IntCopyRegistryKey(_In_ HANDLE SourceKeyHandle, _In_ HANDLE DestKeyHandle)
Definition: registry.c:31
_In_ ULONG _Out_opt_ PULONG RequiredLength
Definition: wmifuncs.h:30

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;
239
240 RtlInitUnicodeString(&ValueNameString, ValueName);
241
242 /* Query the value length */
243 Status = ZwQueryValueKey(SourceKeyHandle,
244 &ValueNameString,
246 NULL,
247 0,
248 &Length);
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}
@ KeyValuePartialInformation
Definition: nt_native.h:1182
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243
#define NT_ASSERT
Definition: rtlfuncs.h:3310

Referenced by IntSetupDeviceSettingsKey().

◆ IntCreateNewRegistryPath()

NTSTATUS NTAPI IntCreateNewRegistryPath ( PVIDEO_PORT_DEVICE_EXTENSION  DeviceExtension)
Todo:
HACK

Definition at line 407 of file registry.c.

409{
410 static UNICODE_STRING VideoIdValueName = RTL_CONSTANT_STRING(L"VideoId");
411 static UNICODE_STRING ControlVideoPathName =
412 RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Video\\");
413 HANDLE DevInstRegKey, SettingsKey, NewKey;
415 UNICODE_STRING VideoIdString;
416 UUID VideoId;
417 PKEY_VALUE_PARTIAL_INFORMATION ValueInformation ;
420 USHORT KeyMaxLength;
422 PWCHAR InstanceIdBuffer;
423
424 if (!DeviceExtension->PhysicalDeviceObject)
425 {
427 &DeviceExtension->RegistryPath,
428 &DeviceExtension->NewRegistryPath);
429 if (!NT_SUCCESS(Status))
430 ERR_(VIDEOPRT, "IntDuplicateUnicodeString() failed with status 0x%lx\n", Status);
431 return Status;
432 }
433
434 /* Open the hardware key: HKLM\System\CurrentControlSet\Enum\... */
439 if (Status != STATUS_SUCCESS)
440 {
441 ERR_(VIDEOPRT, "IoOpenDeviceRegistryKey failed: status 0x%lx\n", Status);
442 return Status;
443 }
444
445 /* Query the VideoId value */
446 ValueInformation = (PKEY_VALUE_PARTIAL_INFORMATION)VideoIdBuffer;
447 Status = ZwQueryValueKey(DevInstRegKey,
448 &VideoIdValueName,
450 ValueInformation,
451 sizeof(VideoIdBuffer),
452 &ResultLength);
453 if (!NT_SUCCESS(Status))
454 {
455 /* Create a new video Id */
456 Status = ExUuidCreate(&VideoId);
457 if (!NT_SUCCESS(Status))
458 {
459 ERR_(VIDEOPRT, "ExUuidCreate failed: status 0x%lx\n", Status);
461 return Status;
462 }
463
464 /* Convert the GUID into a string */
465 Status = RtlStringFromGUID(&VideoId, &VideoIdString);
466 if (!NT_SUCCESS(Status))
467 {
468 ERR_(VIDEOPRT, "RtlStringFromGUID failed: status 0x%lx\n", Status);
470 return Status;
471 }
472
473 /* Copy the GUID String to our buffer */
474 ValueInformation->DataLength = min(VideoIdString.Length, GUID_STRING_LENGTH);
475 RtlCopyMemory(ValueInformation->Data,
476 VideoIdString.Buffer,
477 ValueInformation->DataLength);
478
479 /* Free the GUID string */
480 RtlFreeUnicodeString(&VideoIdString);
481
482 /* Write the VideoId registry value */
483 Status = ZwSetValueKey(DevInstRegKey,
484 &VideoIdValueName,
485 0,
486 REG_SZ,
487 ValueInformation->Data,
488 ValueInformation->DataLength);
489 if (!NT_SUCCESS(Status))
490 {
491 ERR_(VIDEOPRT, "ZwSetValueKey failed: status 0x%lx\n", Status);
493 return Status;
494 }
495 }
496
497 /* Initialize the VideoId string from the registry data */
498 VideoIdString.Buffer = (PWCHAR)ValueInformation->Data;
499 VideoIdString.Length = (USHORT)ValueInformation->DataLength;
500 VideoIdString.MaximumLength = VideoIdString.Length;
501
502 /* Close the hardware key */
504
505 /* Calculate the size needed for the new registry path name */
506 KeyMaxLength = ControlVideoPathName.Length +
507 VideoIdString.Length +
508 sizeof(L"\\0000");
509
510 /* Allocate the path name buffer */
511 DeviceExtension->NewRegistryPath.Length = 0;
512 DeviceExtension->NewRegistryPath.MaximumLength = KeyMaxLength;
514 KeyMaxLength,
516 if (DeviceExtension->NewRegistryPath.Buffer == NULL)
517 {
518 ERR_(VIDEOPRT, "Failed to allocate key name buffer.\n");
520 }
521
522 /* Copy the root key name and append the VideoId string */
523 RtlCopyUnicodeString(&DeviceExtension->NewRegistryPath,
524 &ControlVideoPathName);
526 &VideoIdString);
527
528 /* Check if we have the key already */
530 DeviceExtension->NewRegistryPath.Buffer);
531 if (Status != STATUS_SUCCESS)
532 {
533 /* Try to create the new key */
535 DeviceExtension->NewRegistryPath.Buffer);
536 }
537
538 /* Append a the instance path */
539 RtlAppendUnicodeToString(&DeviceExtension->NewRegistryPath, L"\\");
540 InstanceIdBuffer = DeviceExtension->NewRegistryPath.Buffer +
541 DeviceExtension->NewRegistryPath.Length / sizeof(WCHAR);
542 RtlAppendUnicodeToString(&DeviceExtension->NewRegistryPath, L"0000");
543
544 /* Write instance ID */
545 swprintf(InstanceIdBuffer, L"%04u", DeviceExtension->DisplayNumber);
546
547 /* Check if the name exists */
549 DeviceExtension->NewRegistryPath.Buffer);
550 if (Status != STATUS_SUCCESS)
551 {
552 /* Try to create the new key */
554 DeviceExtension->NewRegistryPath.Buffer);
555 if (!NT_SUCCESS(Status))
556 {
557 ERR_(VIDEOPRT, "Failed create key '%wZ'\n", &DeviceExtension->NewRegistryPath);
558 return Status;
559 }
560
561 /* Open the new key */
563 &DeviceExtension->NewRegistryPath,
565 NULL,
566 NULL);
567 Status = ZwOpenKey(&NewKey, KEY_WRITE, &ObjectAttributes);
568 if (!NT_SUCCESS(Status))
569 {
570 ERR_(VIDEOPRT, "Failed to open settings key. Status 0x%lx\n", Status);
571 return Status;
572 }
573
574 /* Open the device profile key */
576 &DeviceExtension->RegistryPath,
578 NULL,
579 NULL);
580 Status = ZwOpenKey(&SettingsKey, KEY_READ, &ObjectAttributes);
581 if (!NT_SUCCESS(Status))
582 {
583 ERR_(VIDEOPRT, "Failed to open settings key. Status 0x%lx\n", Status);
584 ObCloseHandle(NewKey, KernelMode);
585 return Status;
586 }
587
588 /* Copy the registry data from the legacy key */
589 Status = IntCopyRegistryKey(SettingsKey, NewKey);
590
591 /* Close the key handles */
592 ObCloseHandle(SettingsKey, KernelMode);
593 ObCloseHandle(NewKey, KernelMode);
594 }
595
596 return Status;
597}
#define swprintf
Definition: precomp.h:40
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
#define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
Definition: green.h:15
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
NTSYSAPI NTSTATUS WINAPI RtlCheckRegistryKey(ULONG, PWSTR)
#define REG_SZ
Definition: layer.c:22
NTKERNELAPI NTSTATUS ExUuidCreate(OUT UUID *Uuid)
Definition: uuid.c:380
#define min(a, b)
Definition: monoChain.cc:55
NTSYSAPI NTSTATUS NTAPI RtlCreateRegistryKey(_In_ ULONG RelativeTo, _In_ PWSTR Path)
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define RTL_REGISTRY_ABSOLUTE
Definition: nt_native.h:161
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
struct _KEY_VALUE_PARTIAL_INFORMATION * PKEY_VALUE_PARTIAL_INFORMATION
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define L(x)
Definition: ntvdm.h:50
NTSTATUS NTAPI IoOpenDeviceRegistryKey(IN PDEVICE_OBJECT DeviceObject, IN ULONG DevInstKeyType, IN ACCESS_MASK DesiredAccess, OUT PHANDLE DevInstRegKey)
Definition: pnpmgr.c:1621
PDEVICE_OBJECT PhysicalDeviceObject
Definition: videoprt.h:87
UNICODE_STRING RegistryPath
Definition: videoprt.h:90
UNICODE_STRING NewRegistryPath
Definition: videoprt.h:91
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint16_t * PWCHAR
Definition: typedefs.h:56
#define TAG_VIDEO_PORT
Definition: videoprt.h:38
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3776
NTSTATUS IntDuplicateUnicodeString(IN ULONG Flags, IN PCUNICODE_STRING SourceString, OUT PUNICODE_STRING DestinationString)
Definition: registry.c:360
#define GUID_STRING_LENGTH
Definition: wmip.h:6
_In_ ULONG _In_ ACCESS_MASK _Out_ PHANDLE DevInstRegKey
Definition: iofuncs.h:1127
#define PLUGPLAY_REGKEY_DEVICE
Definition: iofuncs.h:2786
unsigned char UCHAR
Definition: xmlstorage.h:181
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by IntVideoPortCreateAdapterDeviceObject().

◆ IntCreateRegistryPath()

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

Definition at line 601 of file registry.c.

605{
606 static WCHAR RegistryMachineSystem[] = L"\\REGISTRY\\MACHINE\\SYSTEM\\";
607 static WCHAR CurrentControlSet[] = L"CURRENTCONTROLSET\\";
608 static WCHAR ControlSet[] = L"CONTROLSET";
609 static WCHAR Insert1[] = L"Hardware Profiles\\Current\\System\\CurrentControlSet\\";
610 static WCHAR Insert2[] = L"\\Device";
611 UNICODE_STRING DeviceNumberString;
612 WCHAR DeviceNumberBuffer[20];
613 BOOLEAN Valid;
614 UNICODE_STRING AfterControlSet;
616
617 AfterControlSet = *DriverRegistryPath;
618
619 /* Convert DeviceNumber to string */
620 DeviceNumberString.Length = 0;
621 DeviceNumberString.MaximumLength = sizeof(DeviceNumberBuffer);
622 DeviceNumberString.Buffer = DeviceNumberBuffer;
623 Status = RtlIntegerToUnicodeString(DeviceNumber, 10, &DeviceNumberString);
624 if (!NT_SUCCESS(Status))
625 {
626 ERR_(VIDEOPRT, "RtlIntegerToUnicodeString(%u) returned 0x%08x\n", DeviceNumber, Status);
627 return Status;
628 }
629
630 /* Check if path begins with \\REGISTRY\\MACHINE\\SYSTEM\\ */
631 Valid = (DriverRegistryPath->Length > sizeof(RegistryMachineSystem) &&
632 0 == _wcsnicmp(DriverRegistryPath->Buffer, RegistryMachineSystem,
633 wcslen(RegistryMachineSystem)));
634 if (Valid)
635 {
636 AfterControlSet.Buffer += wcslen(RegistryMachineSystem);
637 AfterControlSet.Length -= sizeof(RegistryMachineSystem) - sizeof(UNICODE_NULL);
638
639 /* Check if path contains CURRENTCONTROLSET */
640 if (AfterControlSet.Length > sizeof(CurrentControlSet) &&
641 0 == _wcsnicmp(AfterControlSet.Buffer, CurrentControlSet, wcslen(CurrentControlSet)))
642 {
643 AfterControlSet.Buffer += wcslen(CurrentControlSet);
644 AfterControlSet.Length -= sizeof(CurrentControlSet) - sizeof(UNICODE_NULL);
645 }
646 /* Check if path contains CONTROLSETnum */
647 else if (AfterControlSet.Length > sizeof(ControlSet) &&
648 0 == _wcsnicmp(AfterControlSet.Buffer, ControlSet, wcslen(ControlSet)))
649 {
650 AfterControlSet.Buffer += wcslen(ControlSet);
651 AfterControlSet.Length -= sizeof(ControlSet) - sizeof(UNICODE_NULL);
652 while (AfterControlSet.Length > 0 &&
653 *AfterControlSet.Buffer >= L'0' &&
654 *AfterControlSet.Buffer <= L'9')
655 {
656 AfterControlSet.Buffer++;
657 AfterControlSet.Length -= sizeof(WCHAR);
658 }
659
660 Valid = (AfterControlSet.Length > 0 && L'\\' == *AfterControlSet.Buffer);
661 AfterControlSet.Buffer++;
662 AfterControlSet.Length -= sizeof(WCHAR);
663 AfterControlSet.MaximumLength = AfterControlSet.Length;
664 }
665 else
666 {
667 Valid = FALSE;
668 }
669 }
670
672 {
673 INFO_(VIDEOPRT, "Using old registry key as 'UseNewKey' is FALSE\n");
674 Valid = FALSE;
675 }
676 else if (Valid)
677 {
678 DeviceRegistryPath->MaximumLength = DriverRegistryPath->Length + sizeof(Insert1) + sizeof(Insert2)
679 + DeviceNumberString.Length;
680 DeviceRegistryPath->Buffer = ExAllocatePoolWithTag(PagedPool,
681 DeviceRegistryPath->MaximumLength,
683 if (DeviceRegistryPath->Buffer != NULL)
684 {
685 /* Build device path */
686 wcsncpy(DeviceRegistryPath->Buffer,
688 AfterControlSet.Buffer - DriverRegistryPath->Buffer);
689 DeviceRegistryPath->Length = (AfterControlSet.Buffer - DriverRegistryPath->Buffer) * sizeof(WCHAR);
690 RtlAppendUnicodeToString(DeviceRegistryPath, Insert1);
691 RtlAppendUnicodeStringToString(DeviceRegistryPath, &AfterControlSet);
692 RtlAppendUnicodeToString(DeviceRegistryPath, Insert2);
693 RtlAppendUnicodeStringToString(DeviceRegistryPath, &DeviceNumberString);
694
695 /* Check if registry key exists */
696 Valid = NT_SUCCESS(RtlCheckRegistryKey(RTL_REGISTRY_ABSOLUTE, DeviceRegistryPath->Buffer));
697
698 if (!Valid)
699 ExFreePoolWithTag(DeviceRegistryPath->Buffer, TAG_VIDEO_PORT);
700 }
701 else
702 {
703 Valid = FALSE;
704 }
705 }
706 else
707 {
708 WARN_(VIDEOPRT, "Unparsable registry path %wZ\n", DriverRegistryPath);
709 }
710
711 /* If path doesn't point to *ControlSet*, use DriverRegistryPath directly */
712 if (!Valid)
713 {
714 DeviceRegistryPath->MaximumLength = DriverRegistryPath->Length + sizeof(Insert2) + DeviceNumberString.Length;
715 DeviceRegistryPath->Buffer = ExAllocatePoolWithTag(NonPagedPool,
716 DeviceRegistryPath->MaximumLength,
718
719 if (!DeviceRegistryPath->Buffer)
720 return STATUS_NO_MEMORY;
721
722 RtlCopyUnicodeString(DeviceRegistryPath, DriverRegistryPath);
723 RtlAppendUnicodeToString(DeviceRegistryPath, Insert2);
724 RtlAppendUnicodeStringToString(DeviceRegistryPath, &DeviceNumberString);
725 }
726
727 DPRINT("Formatted registry key '%wZ' -> '%wZ'\n",
728 DriverRegistryPath, DeviceRegistryPath);
729
730 return STATUS_SUCCESS;
731}
unsigned char BOOLEAN
_In_ PCHAR _In_ ULONG DeviceNumber
Definition: classpnp.h:1230
#define FALSE
Definition: types.h:117
#define NonPagedPool
Definition: env_spec_w32.h:307
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
UNICODE_STRING DriverRegistryPath
Definition: inport.c:17
NTSYSAPI NTSTATUS NTAPI RtlIntegerToUnicodeString(ULONG Value, ULONG Base, PUNICODE_STRING String)
#define UNICODE_NULL
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
_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)
#define DPRINT
Definition: sndvol32.h:71
BOOLEAN VideoPortUseNewKey
Definition: videoprt.c:41

Referenced by IntVideoPortCreateAdapterDeviceObject().

◆ IntDetachFromCSRSS()

VOID FASTCALL IntDetachFromCSRSS ( PKPROCESS CallingProcess,
PKAPC_STATE  ApcState 
)

Definition at line 588 of file videoprt.c.

591{
592 if (*CallingProcess != CsrProcess)
593 {
595 }
596}
VOID NTAPI KeUnstackDetachProcess(IN PRKAPC_STATE ApcState)
Definition: procobj.c:756

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

◆ IntInitializeVideoAddressSpace()

NTSTATUS NTAPI IntInitializeVideoAddressSpace ( VOID  )

Definition at line 200 of file int10.c.

201{
205}
#define UNIMPLEMENTED
Definition: debug.h:115
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239

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,
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,
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
268#endif
269}
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define NO_ERROR
Definition: dderror.h:5
#define TRACE_(x)
Definition: compat.h:76
#define NtCurrentProcess()
Definition: nt_native.h:1657
#define MEM_RELEASE
Definition: nt_native.h:1316
#define MEM_COMMIT
Definition: nt_native.h:1313
#define PAGE_EXECUTE_READWRITE
Definition: nt_native.h:1308
void * PVOID
Definition: typedefs.h:50
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t ULONG_PTR
Definition: typedefs.h:65
VOID FASTCALL IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:588
VOID FASTCALL IntAttachToCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:575
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
NTSTATUS NTAPI x86BiosAllocateBuffer(_In_ ULONG *Size, _In_ USHORT *Segment, _In_ USHORT *Offset)
Definition: x86bios.c:151
KAPC_STATE
Definition: ketypes.h:1409

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
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,
414 FALSE,
415 NULL);
416
417 /* The kernel needs access here */
419#ifdef _M_AMD64
421#else
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}
CALLBACK16 BiosContext
Definition: bios32.c:45
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
static VOID UnprotectLowV86Mem(VOID)
Definition: int10.c:62
static VOID ProtectLowV86Mem(VOID)
Definition: int10.c:39
LONG NTAPI KeReleaseMutex(IN PKMUTEX Mutex, IN BOOLEAN Wait)
Definition: mutex.c:189
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
NTSTATUS NTAPI Ke386CallBios(IN ULONG Int, OUT PCONTEXT Context)
Definition: v86vdm.c:614
KMUTEX VideoPortInt10Mutex
Definition: videoprt.c:42
BOOLEAN NTAPI x86BiosCall(_In_ ULONG InterruptNumber, _Inout_ PX86_BIOS_REGISTERS Registers)
Definition: x86bios.c:410
#define KeWaitForMutexObject
Definition: kefuncs.h:543
@ Executive
Definition: ketypes.h:415

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,
294
295 IntDetachFromCSRSS(&CallingProcess, &ApcState);
296
297 return Status;
298#else
299 Status = x86BiosFreeBuffer(Seg, Off);
301#endif
302}
NTSTATUS NTAPI x86BiosFreeBuffer(_In_ USHORT Segment, _In_ USHORT Offset)
Definition: x86bios.c:180

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
339#endif
340}
Definition: bufpool.h:45
#define IsLowV86Mem(_Seg, _Off)
Definition: int10.c:33
NTSTATUS NTAPI x86BiosReadMemory(_In_ USHORT Segment, _In_ USHORT Offset, _Out_writes_bytes_(Size) PVOID Buffer, _In_ ULONG Size)
Definition: x86bios.c:204

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
375#endif
376}
NTSTATUS NTAPI x86BiosWriteMemory(_In_ USHORT Segment, _In_ USHORT Offset, _In_reads_bytes_(Size) PVOID Buffer, _In_ ULONG Size)
Definition: x86bios.c:231

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 if (!DeviceExtension->PhysicalDeviceObject)
306 return STATUS_SUCCESS;
307
308 /* Open the software key: HKLM\System\CurrentControlSet\Control\Class<ClassGUID><n> */
313 if (Status != STATUS_SUCCESS)
314 {
315 ERR_(VIDEOPRT, "Failed to open device software key. Status 0x%lx\n", Status);
316 return Status;
317 }
318
319 /* Open the 'Settings' sub-key */
321 &SettingsKeyName,
324 NULL);
325 Status = ZwOpenKey(&DestKeyHandle, KEY_WRITE, &ObjectAttributes);
326
327 /* Close the device software key */
329
330 if (Status != STATUS_SUCCESS)
331 {
332 ERR_(VIDEOPRT, "Failed to open settings key. Status 0x%lx\n", Status);
333 return Status;
334 }
335
336 /* Open the device profile key */
338 &DeviceExtension->RegistryPath,
340 NULL,
341 NULL);
342 Status = ZwOpenKey(&SourceKeyHandle, KEY_READ, &ObjectAttributes);
343 if (Status != STATUS_SUCCESS)
344 {
345 ERR_(VIDEOPRT, "ZwOpenKey failed for settings key: status 0x%lx\n", Status);
346 ObCloseHandle(DestKeyHandle, KernelMode);
347 return Status;
348 }
349
350 IntCopyRegistryValue(SourceKeyHandle, DestKeyHandle, L"InstalledDisplayDrivers");
351 IntCopyRegistryValue(SourceKeyHandle, DestKeyHandle, L"Attach.ToDesktop");
352
353 ObCloseHandle(SourceKeyHandle, KernelMode);
354 ObCloseHandle(DestKeyHandle, KernelMode);
355
356 return STATUS_SUCCESS;
357}
#define PLUGPLAY_REGKEY_DRIVER
Definition: usbd.c:42
NTSTATUS NTAPI IntCopyRegistryValue(HANDLE SourceKeyHandle, HANDLE DestKeyHandle, PWSTR ValueName)
Definition: registry.c:230

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}
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1157
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1904
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31
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:159
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213

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 159 of file videoprt.c.

166{
167 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
169 ULONG PciSlotNumber;
171 ULONG Size;
173 WCHAR DeviceBuffer[20];
175 PDEVICE_OBJECT DeviceObject_;
176
177 if (DeviceObject == NULL)
178 DeviceObject = &DeviceObject_;
179
180 /*
181 * Find the first free device number that can be used for video device
182 * object names and symlinks.
183 */
185 if (DeviceNumber == (ULONG)-1)
186 {
187 WARN_(VIDEOPRT, "Can't find free device number\n");
188 return STATUS_UNSUCCESSFUL;
189 }
190
191 /*
192 * Create the device object.
193 */
194
195 /* Create a unicode device name. */
196 swprintf(DeviceBuffer, L"\\Device\\Video%lu", DeviceNumber);
197 RtlInitUnicodeString(&DeviceName, DeviceBuffer);
198
199 INFO_(VIDEOPRT, "HwDeviceExtension size is: 0x%x\n",
200 DriverExtension->InitializationData.HwDeviceExtensionSize);
201
202 /* Create the device object. */
204 DriverExtension->InitializationData.HwDeviceExtensionSize;
206 Size,
207 &DeviceName,
209 0,
210 TRUE,
212
213 if (!NT_SUCCESS(Status))
214 {
215 WARN_(VIDEOPRT, "IoCreateDevice call failed with status 0x%08x\n", Status);
216 return Status;
217 }
218
219 /*
220 * Set the buffering strategy here. If you change this, remember
221 * to change VidDispatchDeviceControl too.
222 */
223
224 (*DeviceObject)->Flags |= DO_BUFFERED_IO;
225
226 /* Initialize device extension. */
227 DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)((*DeviceObject)->DeviceExtension);
228 DeviceExtension->Common.Fdo = TRUE;
229 DeviceExtension->DeviceNumber = DeviceNumber;
230 DeviceExtension->DriverObject = DriverObject;
232 DeviceExtension->FunctionalDeviceObject = *DeviceObject;
233 DeviceExtension->DriverExtension = DriverExtension;
234 DeviceExtension->SessionId = -1;
235 DeviceExtension->AdapterNumber = AdapterNumber;
236 DeviceExtension->DisplayNumber = DisplayNumber;
237
238 InitializeListHead(&DeviceExtension->ChildDeviceList);
239
240 /* Get the registry path associated with this device. */
242 DeviceExtension->AdapterNumber,
243 &DeviceExtension->RegistryPath);
244 if (!NT_SUCCESS(Status))
245 {
246 WARN_(VIDEOPRT, "IntCreateRegistryPath() call failed with status 0x%08x\n", Status);
247 goto Failure;
248 }
249
251 {
252 /* Get bus number from the upper level bus driver. */
253 Size = sizeof(ULONG);
256 Size,
257 &DeviceExtension->SystemIoBusNumber,
258 &Size);
259 if (!NT_SUCCESS(Status))
260 {
261 WARN_(VIDEOPRT, "Couldn't get an information from bus driver. We will try to\n"
262 "use legacy detection method, but even that doesn't mean that\n"
263 "it will work.\n");
264 DeviceExtension->PhysicalDeviceObject = NULL;
265 }
266 }
267
268 DeviceExtension->AdapterInterfaceType =
269 DriverExtension->InitializationData.AdapterInterfaceType;
270
272 {
273 /* Get bus type from the upper level bus driver. */
274 Size = sizeof(ULONG);
277 Size,
278 &DeviceExtension->AdapterInterfaceType,
279 &Size);
280
281 /* Get bus device address from the upper level bus driver. */
282 Size = sizeof(ULONG);
285 Size,
286 &PciSlotNumber,
287 &Size);
288
289 /* Convert slotnumber to PCI_SLOT_NUMBER */
290 SlotNumber.u.AsULONG = 0;
291 SlotNumber.u.bits.DeviceNumber = (PciSlotNumber >> 16) & 0xFFFF;
292 SlotNumber.u.bits.FunctionNumber = PciSlotNumber & 0xFFFF;
293 DeviceExtension->SystemIoSlotNumber = SlotNumber.u.AsULONG;
294 }
295
297 InitializeListHead(&DeviceExtension->DmaAdapterList);
298
299 KeInitializeDpc(&DeviceExtension->DpcObject,
301 DeviceExtension);
302
303 KeInitializeMutex(&DeviceExtension->DeviceLock, 0);
304
305 /* Attach the device. */
306 if ((PhysicalDeviceObject != NULL) && (DisplayNumber == 0))
310
311 Status = IntCreateNewRegistryPath(DeviceExtension);
312 if (!NT_SUCCESS(Status))
313 {
314 ERR_(VIDEOPRT, "IntCreateNewRegistryPath() failed with status 0x%08x\n", Status);
315 goto Failure;
316 }
317
318 IntSetupDeviceSettingsKey(DeviceExtension);
319
320 /* Remove the initializing flag */
321 (*DeviceObject)->Flags &= ~DO_DEVICE_INITIALIZING;
322
323 /* Set up the VIDEO/DEVICEMAP registry keys */
324 Status = IntVideoPortAddDeviceMapLink(DeviceExtension);
325 if (!NT_SUCCESS(Status))
326 {
327 ERR_(VIDEOPRT, "IntVideoPortAddDeviceMapLink() failed with status 0x%08x\n", Status);
328 goto Failure;
329 }
330
331 if (DisplayNumber == 0)
332 {
333 DriverExtension->InitializationData.StartingDeviceNumber++;
334 }
335
336 return STATUS_SUCCESS;
337
338Failure:
339 if (DeviceExtension->NextDeviceObject)
340 IoDetachDevice(DeviceExtension->NextDeviceObject);
343 return Status;
344}
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:712
#define DO_BUFFERED_IO
Definition: env_spec_w32.h:394
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:966
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
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1296
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
VOID NTAPI KeInitializeMutex(IN PKMUTEX Mutex, IN ULONG Level)
Definition: mutex.c:67
NTSTATUS NTAPI IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, IN ULONG BufferLength, OUT PVOID PropertyBuffer, OUT PULONG ResultLength)
Definition: pnpmgr.c:1382
#define FILE_DEVICE_VIDEO
Definition: winioctl.h:141
VIDEO_PORT_DRIVER_EXTENSION * DriverExtension
Definition: videoprt.h:103
INTERFACE_TYPE AdapterInterfaceType
Definition: videoprt.h:98
LIST_ENTRY AddressMappingListHead
Definition: videoprt.h:101
VIDEO_PORT_COMMON_EXTENSION Common
Definition: videoprt.h:84
PDRIVER_OBJECT DriverObject
Definition: videoprt.h:86
PDEVICE_OBJECT FunctionalDeviceObject
Definition: videoprt.h:88
VOID NTAPI IntVideoPortDeferredRoutine(IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: videoprt.c:146
static ULONG VideoPortMaxObjectNumber
Definition: videoprt.c:40
static NTSTATUS IntVideoPortAddDeviceMapLink(PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: videoprt.c:59
struct _VIDEO_PORT_DEVICE_EXTENSTION * PVIDEO_PORT_DEVICE_EXTENSION
struct _VIDEO_PORT_DEVICE_EXTENSTION VIDEO_PORT_DEVICE_EXTENSION
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
_In_ WDFIORESREQLIST _In_ ULONG SlotNumber
Definition: wdfresource.h:68
NTSTATUS NTAPI IntCreateRegistryPath(IN PCUNICODE_STRING DriverRegistryPath, IN ULONG DeviceNumber, OUT PUNICODE_STRING DeviceRegistryPath)
Definition: registry.c:601
NTSTATUS NTAPI IntCreateNewRegistryPath(PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: registry.c:407
NTSTATUS NTAPI IntSetupDeviceSettingsKey(PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: registry.c:297
@ DevicePropertyAddress
Definition: iotypes.h:1211
@ DevicePropertyBusNumber
Definition: iotypes.h:1209
@ DevicePropertyLegacyBusType
Definition: iotypes.h:1208

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

◆ IntVideoPortDispatchCleanup()

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

Definition at line 1123 of file dispatch.c.

1126{
1127 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1128
1129 DeviceExtension = DeviceObject->DeviceExtension;
1130 RtlFreeUnicodeString(&DeviceExtension->RegistryPath);
1131
1132 Irp->IoStatus.Status = STATUS_SUCCESS;
1133 Irp->IoStatus.Information = 0;
1135
1136 return STATUS_SUCCESS;
1137}
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
#define IO_NO_INCREMENT
Definition: iotypes.h:598

◆ IntVideoPortDispatchClose()

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

Definition at line 436 of file dispatch.c.

439{
440 TRACE_(VIDEOPRT, "IntVideoPortDispatchClose\n");
441
443
444 Irp->IoStatus.Status = STATUS_SUCCESS;
446 return STATUS_SUCCESS;
447}
static NTSTATUS IntVideoPortInbvCleanup(IN PDEVICE_OBJECT DeviceObject)
Definition: dispatch.c:300

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchDeviceControl()

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

Definition at line 723 of file dispatch.c.

726{
727 PIO_STACK_LOCATION IrpStack;
730
731 TRACE_(VIDEOPRT, "IntVideoPortDispatchDeviceControl\n");
732
734
735 switch (IrpStack->MajorFunction)
736 {
738 /* This is the main part of this function and is handled below */
739 break;
740
741 case IRP_MJ_SHUTDOWN:
742 {
743 /* Dereference CSRSS */
744 PKPROCESS OldCsrProcess;
745 OldCsrProcess = InterlockedExchangePointer((PVOID*)&CsrProcess, NULL);
746 if (OldCsrProcess)
747 ObDereferenceObject(OldCsrProcess);
748
749 Irp->IoStatus.Status = STATUS_SUCCESS;
751 return STATUS_SUCCESS;
752 }
753
754 default:
755 ERR_(VIDEOPRT, "- Unknown MajorFunction 0x%x\n", IrpStack->MajorFunction);
756 Irp->IoStatus.Status = STATUS_SUCCESS;
758 return STATUS_SUCCESS;
759 }
760
761 IoControlCode = IrpStack->Parameters.DeviceIoControl.IoControlCode;
762
763 INFO_(VIDEOPRT, "- IoControlCode: 0x%x: %s\n", IoControlCode, IoctlName(IoControlCode));
764
765 switch (IoControlCode)
766 {
770 WARN_(VIDEOPRT, "- IOCTL_VIDEO_*_VDM are UNIMPLEMENTED!\n");
772 break;
773
776 WARN_(VIDEOPRT, "- IOCTL_VIDEO_GET/SET_OUTPUT_DEVICE_POWER_STATE are UNIMPLEMENTED!\n");
778 break;
779
782 WARN_(VIDEOPRT, "- IOCTL_VIDEO_GET/SET_POWER_MANAGEMENT are UNIMPLEMENTED!\n");
784 break;
785
789 WARN_(VIDEOPRT, "- IOCTL_VIDEO_*_BRIGHTNESS are UNIMPLEMENTED!\n");
791 break;
792
794 WARN_(VIDEOPRT, "- IOCTL_VIDEO_ENUM_MONITOR_PDO is UNIMPLEMENTED!\n");
796 break;
797
799 INFO_(VIDEOPRT, "- IOCTL_VIDEO_INIT_WIN32K_CALLBACKS\n");
801 Irp->AssociatedIrp.SystemBuffer,
802 IrpStack->Parameters.DeviceIoControl.InputBufferLength,
803 &Irp->IoStatus.Information);
804 break;
805
807 WARN_(VIDEOPRT, "- IOCTL_VIDEO_IS_VGA_DEVICE is UNIMPLEMENTED!\n");
809 break;
810
812 INFO_(VIDEOPRT, "- IOCTL_VIDEO_USE_DEVICE_IN_SESSION\n");
814 Irp->AssociatedIrp.SystemBuffer,
815 IrpStack->Parameters.DeviceIoControl.InputBufferLength,
816 &Irp->IoStatus.Information);
817 break;
818
820 INFO_(VIDEOPRT, "- IOCTL_VIDEO_PREPARE_FOR_EARECOVERY\n");
821 /*
822 * The Win32k Watchdog Timer detected that a thread spent more time
823 * in a display driver than the allotted time its threshold specified,
824 * and thus is going to attempt to recover by switching to VGA mode.
825 * If this attempt fails, the watchdog generates bugcheck 0xEA
826 * "THREAD_STUCK_IN_DEVICE_DRIVER".
827 *
828 * Prepare the recovery by resetting the display adapters to
829 * standard VGA 80x25 text mode.
830 */
833 break;
834
835 default:
836 /* Forward to the Miniport Driver */
838 break;
839 }
840
841 INFO_(VIDEOPRT, "- Returned status: 0x%x\n", Status);
842
843 Irp->IoStatus.Status = Status;
845 return Status;
846}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
#define IOCTL_VIDEO_SET_POWER_MANAGEMENT
Definition: ntddvdeo.h:239
#define IOCTL_VIDEO_IS_VGA_DEVICE
Definition: ntddvdeo.h:137
#define IOCTL_VIDEO_ENABLE_VDM
Definition: ntddvdeo.h:110
#define IOCTL_VIDEO_USE_DEVICE_IN_SESSION
Definition: ntddvdeo.h:140
#define IOCTL_VIDEO_GET_POWER_MANAGEMENT
Definition: ntddvdeo.h:167
#define IOCTL_VIDEO_QUERY_DISPLAY_BRIGHTNESS
Definition: ntddvdeo.h:266
#define IOCTL_VIDEO_SET_DISPLAY_BRIGHTNESS
Definition: ntddvdeo.h:269
#define IOCTL_VIDEO_PREPARE_FOR_EARECOVERY
Definition: ntddvdeo.h:143
#define IOCTL_VIDEO_DISABLE_VDM
Definition: ntddvdeo.h:113
#define IOCTL_VIDEO_GET_OUTPUT_DEVICE_POWER_STATE
Definition: ntddvdeo.h:122
#define IOCTL_VIDEO_REGISTER_VDM
Definition: ntddvdeo.h:116
#define IOCTL_VIDEO_ENUM_MONITOR_PDO
Definition: ntddvdeo.h:128
#define IOCTL_VIDEO_SET_OUTPUT_DEVICE_POWER_STATE
Definition: ntddvdeo.h:119
#define IOCTL_VIDEO_INIT_WIN32K_CALLBACKS
Definition: ntddvdeo.h:131
#define IOCTL_VIDEO_QUERY_SUPPORTED_BRIGHTNESS
Definition: ntddvdeo.h:263
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
struct _IO_STACK_LOCATION::@1564::@1565 DeviceIoControl
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
Definition: wdfio.h:325
static BOOLEAN NTAPI IntVideoPortResetDisplayParametersEx(_In_ ULONG Columns, _In_ ULONG Rows, _In_ BOOLEAN CalledByInbv)
Definition: dispatch.c:72
PSTR IoctlName(ULONG Ioctl)
Definition: dispatch.c:450
static NTSTATUS VideoPortForwardDeviceControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:656
static NTSTATUS VideoPortUseDeviceInSession(_Inout_ PDEVICE_OBJECT DeviceObject, _Inout_ PVIDEO_DEVICE_SESSION_STATUS SessionState, _In_ ULONG BufferLength, _Out_ PULONG_PTR Information)
Definition: dispatch.c:569
static NTSTATUS VideoPortInitWin32kCallbacks(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PVIDEO_WIN32K_CALLBACKS Win32kCallbacks, _In_ ULONG BufferLength, _Out_ PULONG_PTR Information)
Definition: dispatch.c:627
#define IRP_MJ_SHUTDOWN
#define IO_VIDEO_INCREMENT
Definition: iotypes.h:609
#define ObDereferenceObject
Definition: obfuncs.h:203

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);
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 {
409 InterlockedIncrement((PLONG)&DeviceExtension->DeviceOpened);
410
411 /* Query children, now that device is opened */
413 }
414 else
415 {
417 }
418
419 Irp->IoStatus.Status = Status;
420 Irp->IoStatus.Information = FILE_OPENED;
422
423 return Status;
424}
#define InterlockedIncrement
Definition: armddk.h:53
NTSTATUS NTAPI IntInitializeVideoAddressSpace(VOID)
Definition: int10.c:200
#define FILE_OPENED
Definition: nt_native.h:769
VPAPI VP_STATUS NTAPI VideoPortEnumerateChildren(IN PVOID HwDeviceExtension, IN PVOID Reserved)
Definition: videoprt.c:1444
CHAR POINTER_ALIGNMENT MiniPortDeviceExtension[1]
Definition: videoprt.h:113
int32_t * PLONG
Definition: typedefs.h:58
static NTSTATUS IntVideoPortInbvInitialize(VOID)
Definition: dispatch.c:274
#define ObReferenceObject
Definition: obfuncs.h:204

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 {
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 */
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}
NTSTATUS NTAPI IntVideoPortChildQueryId(IN PVIDEO_PORT_CHILD_EXTENSION ChildExtension, IN PIRP Irp, IN PIO_STACK_LOCATION IrpSp)
Definition: child.c:117
NTSTATUS NTAPI IntVideoPortChildQueryRelations(IN PVIDEO_PORT_CHILD_EXTENSION ChildExtension, IN PIRP Irp, IN PIO_STACK_LOCATION IrpSp)
Definition: child.c:292
NTSTATUS NTAPI IntVideoPortChildQueryCapabilities(IN PVIDEO_PORT_CHILD_EXTENSION ChildExtension, IN PIRP Irp, IN PIO_STACK_LOCATION IrpSp)
Definition: child.c:319
NTSTATUS NTAPI IntVideoPortChildQueryText(IN PVIDEO_PORT_CHILD_EXTENSION ChildExtension, IN PIRP Irp, IN PIO_STACK_LOCATION IrpSp)
Definition: child.c:242
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
#define IRP_MN_SURPRISE_REMOVAL
Definition: ntifs_ex.h:408
#define IRP_MN_START_DEVICE
#define IRP_MN_QUERY_RESOURCE_REQUIREMENTS
#define IRP_MN_QUERY_ID
#define IRP_MN_REMOVE_DEVICE
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define IRP_MN_QUERY_DEVICE_TEXT
#define IRP_MN_QUERY_CAPABILITIES
#define IRP_MN_QUERY_RESOURCES
#define IRP_MN_STOP_DEVICE
#define IRP_MN_QUERY_REMOVE_DEVICE

Referenced by IntVideoPortDispatchPnp().

◆ IntVideoPortDispatchPnp()

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

Definition at line 1109 of file dispatch.c.

1112{
1113 PVIDEO_PORT_COMMON_EXTENSION CommonExtension = DeviceObject->DeviceExtension;
1114
1115 if (CommonExtension->Fdo)
1117 else
1119}
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:1032

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchPower()

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

Definition at line 1141 of file dispatch.c.

1144{
1146 NTSTATUS Status = Irp->IoStatus.Status;
1147 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
1148
1150
1151 if (DeviceExtension->Common.Fdo)
1152 {
1155 return PoCallDriver(DeviceExtension->NextDeviceObject, Irp);
1156 }
1157 else
1158 {
1159 switch (IrpSp->MinorFunction)
1160 {
1161 case IRP_MN_QUERY_POWER:
1162 case IRP_MN_SET_POWER:
1164 break;
1165 }
1167 Irp->IoStatus.Status = Status;
1169 return Status;
1170 }
1171}
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:758
#define IRP_MN_SET_POWER
#define IRP_MN_QUERY_POWER

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchSystemControl()

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

Definition at line 1175 of file dispatch.c.

1178{
1180 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
1181
1182 if (DeviceExtension->Common.Fdo)
1183 {
1185 return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
1186 }
1187 else
1188 {
1189 Status = Irp->IoStatus.Status;
1191 return Status;
1192 }
1193}
#define IoCallDriver
Definition: irp.c:1225

Referenced by VideoPortInitialize().

◆ IntVideoPortEnumerateChildren()

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

Definition at line 1280 of file videoprt.c.

1283{
1284 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1285 ULONG Status;
1286 VIDEO_CHILD_ENUM_INFO ChildEnumInfo;
1287 BOOLEAN bHaveLastMonitorID = FALSE;
1288 UCHAR LastMonitorID[10];
1289 ULONG Unused;
1290 UINT i;
1291 PDEVICE_OBJECT ChildDeviceObject;
1292 PVIDEO_PORT_CHILD_EXTENSION ChildExtension;
1293
1294 INFO_(VIDEOPRT, "Starting child device probe\n");
1295 DeviceExtension = DeviceObject->DeviceExtension;
1297 {
1298 WARN_(VIDEOPRT, "Miniport's HwGetVideoChildDescriptor is NULL!\n");
1299 return STATUS_SUCCESS;
1300 }
1301
1302 if (!IsListEmpty(&DeviceExtension->ChildDeviceList))
1303 {
1304 ERR_(VIDEOPRT, "FIXME: Support calling VideoPortEnumerateChildren again!\n");
1305 return STATUS_SUCCESS;
1306 }
1307
1308 /* Enumerate the children */
1309 for (i = 1; ; i++)
1310 {
1311 Status = IoCreateDevice(DeviceExtension->DriverObject,
1314 NULL,
1317 FALSE,
1318 &ChildDeviceObject);
1319 if (!NT_SUCCESS(Status))
1320 return Status;
1321
1322 ChildExtension = ChildDeviceObject->DeviceExtension;
1323
1324 RtlZeroMemory(ChildExtension,
1327
1328 ChildExtension->Common.Fdo = FALSE;
1329 ChildExtension->ChildId = i;
1330 ChildExtension->PhysicalDeviceObject = ChildDeviceObject;
1331 ChildExtension->DriverObject = DeviceExtension->DriverObject;
1332
1333 /* Setup the ChildEnumInfo */
1334 ChildEnumInfo.Size = sizeof(ChildEnumInfo);
1335 ChildEnumInfo.ChildDescriptorSize = sizeof(ChildExtension->ChildDescriptor);
1336 ChildEnumInfo.ACPIHwId = 0;
1337
1339 ChildEnumInfo.ChildHwDeviceExtension = VIDEO_PORT_GET_CHILD_EXTENSION(ChildExtension);
1340 else
1341 ChildEnumInfo.ChildHwDeviceExtension = NULL;
1342
1343 ChildEnumInfo.ChildIndex = ChildExtension->ChildId;
1344
1345 INFO_(VIDEOPRT, "Probing child: %d\n", ChildEnumInfo.ChildIndex);
1347 DeviceExtension->MiniPortDeviceExtension,
1348 &ChildEnumInfo,
1349 &ChildExtension->ChildType,
1350 ChildExtension->ChildDescriptor,
1351 &ChildExtension->ChildId,
1352 &Unused);
1354 {
1355 if (ChildExtension->ChildType == Monitor)
1356 {
1357 // Check if the EDID is valid
1358 if (ChildExtension->ChildDescriptor[0] == 0x00 &&
1359 ChildExtension->ChildDescriptor[1] == 0xFF &&
1360 ChildExtension->ChildDescriptor[2] == 0xFF &&
1361 ChildExtension->ChildDescriptor[3] == 0xFF &&
1362 ChildExtension->ChildDescriptor[4] == 0xFF &&
1363 ChildExtension->ChildDescriptor[5] == 0xFF &&
1364 ChildExtension->ChildDescriptor[6] == 0xFF &&
1365 ChildExtension->ChildDescriptor[7] == 0x00)
1366 {
1367 if (bHaveLastMonitorID)
1368 {
1369 // Compare the previous monitor ID with the current one, break the loop if they are identical
1370 if (RtlCompareMemory(LastMonitorID, &ChildExtension->ChildDescriptor[8], sizeof(LastMonitorID)) == sizeof(LastMonitorID))
1371 {
1372 INFO_(VIDEOPRT, "Found identical Monitor ID two times, stopping enumeration\n");
1373 IoDeleteDevice(ChildDeviceObject);
1374 break;
1375 }
1376 }
1377
1378 // Copy 10 bytes from the EDID, which can be used to uniquely identify the monitor
1379 RtlCopyMemory(LastMonitorID, &ChildExtension->ChildDescriptor[8], sizeof(LastMonitorID));
1380 bHaveLastMonitorID = TRUE;
1381
1382 /* Mark it valid */
1383 ChildExtension->EdidValid = TRUE;
1384 }
1385 else
1386 {
1387 /* Mark it invalid */
1388 ChildExtension->EdidValid = FALSE;
1389 }
1390 }
1391 }
1393 {
1394 WARN_(VIDEOPRT, "Child device %d is invalid!\n", ChildEnumInfo.ChildIndex);
1395 IoDeleteDevice(ChildDeviceObject);
1396 continue;
1397 }
1399 {
1400 INFO_(VIDEOPRT, "End of child enumeration! (%d children enumerated)\n", i - 1);
1401 IoDeleteDevice(ChildDeviceObject);
1402 break;
1403 }
1404 else
1405 {
1406 WARN_(VIDEOPRT, "HwGetVideoChildDescriptor returned unknown status code 0x%x!\n", Status);
1407 IoDeleteDevice(ChildDeviceObject);
1408 break;
1409 }
1410
1411 if (ChildExtension->ChildType == Monitor)
1412 {
1413 UINT j;
1414 PUCHAR p = ChildExtension->ChildDescriptor;
1415 INFO_(VIDEOPRT, "Monitor device enumerated! (ChildId = 0x%x)\n", ChildExtension->ChildId);
1416 for (j = 0; j < sizeof (ChildExtension->ChildDescriptor); j += 8)
1417 {
1418 INFO_(VIDEOPRT, "%02x %02x %02x %02x %02x %02x %02x %02x\n",
1419 p[j + 0], p[j + 1], p[j + 2], p[j + 3],
1420 p[j + 4], p[j + 5], p[j + 6], p[j + 7]);
1421 }
1422 }
1423 else if (ChildExtension->ChildType == Other)
1424 {
1425 INFO_(VIDEOPRT, "\"Other\" device enumerated: DeviceId = %S\n", (PWSTR)ChildExtension->ChildDescriptor);
1426 }
1427 else
1428 {
1429 ERR_(VIDEOPRT, "HwGetVideoChildDescriptor returned unsupported type: %d\n", ChildExtension->ChildType);
1430 }
1431
1432 /* Clear the init flag */
1433 ChildDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
1434
1435 InsertTailList(&DeviceExtension->ChildDeviceList,
1436 &ChildExtension->ListEntry);
1437 }
1438
1439 return STATUS_SUCCESS;
1440}
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
#define InsertTailList(ListHead, Entry)
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
GLfloat GLfloat p
Definition: glext.h:8902
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
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 GLint GLint j
Definition: glfuncs.h:250
#define Unused(x)
Definition: atlwin.h:28
unsigned int UINT
Definition: ndis.h:50
#define FILE_DEVICE_CONTROLLER
Definition: winioctl.h:110
#define VIDEO_ENUM_INVALID_DEVICE
Definition: video.h:141
#define VIDEO_ENUM_NO_MORE_DEVICES
Definition: video.h:140
@ Monitor
Definition: video.h:270
@ Other
Definition: video.h:273
#define VIDEO_ENUM_MORE_DEVICES
Definition: video.h:139
PVOID DeviceExtension
Definition: env_spec_w32.h:418
ULONG ChildDescriptorSize
Definition: video.h:262
PVOID ChildHwDeviceExtension
Definition: video.h:265
PVIDEO_HW_GET_CHILD_DESCRIPTOR HwGetVideoChildDescriptor
Definition: video.h:685
PDEVICE_OBJECT PhysicalDeviceObject
Definition: videoprt.h:127
VIDEO_CHILD_TYPE ChildType
Definition: videoprt.h:121
PDRIVER_OBJECT DriverObject
Definition: videoprt.h:126
VIDEO_PORT_COMMON_EXTENSION Common
Definition: videoprt.h:118
VIDEO_HW_INITIALIZATION_DATA InitializationData
Definition: videoprt.h:72
uint16_t * PWSTR
Definition: typedefs.h:56
#define VIDEO_PORT_GET_CHILD_EXTENSION(MiniportExtension)
Definition: videoprt.h:134

Referenced by IntVideoPortQueryBusRelations().

◆ IntVideoPortFilterResourceRequirements()

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

Definition at line 77 of file resource.c.

81{
84 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
85 PVIDEO_ACCESS_RANGE AccessRanges;
86 ULONG AccessRangeCount, ListSize, i;
88 PIO_RESOURCE_REQUIREMENTS_LIST OldResList = IrpStack->Parameters.FilterResourceRequirements.IoResourceRequirementList;
89 PIO_RESOURCE_DESCRIPTOR CurrentDescriptor;
91
92 DriverObject = DeviceObject->DriverObject;
94 DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
95
96 Status = IntVideoPortGetLegacyResources(DriverExtension, DeviceExtension, &AccessRanges, &AccessRangeCount);
97 if (!NT_SUCCESS(Status))
98 return Status;
99 if (!AccessRangeCount)
100 {
101 /* No legacy resources to report */
102 return Irp->IoStatus.Status;
103 }
104
105 /* OK, we've got the access ranges now. Let's set up the resource requirements list */
106
107 if (OldResList)
108 {
109 /* Already one there so let's add to it */
110 ListSize = OldResList->ListSize + sizeof(IO_RESOURCE_DESCRIPTOR) * AccessRangeCount;
112 ListSize);
113 if (!ResList) return STATUS_NO_MEMORY;
114
115 RtlCopyMemory(ResList, OldResList, OldResList->ListSize);
116
117 ASSERT(ResList->AlternativeLists == 1);
118
119 ResList->ListSize = ListSize;
120 ResList->List[0].Count += AccessRangeCount;
121
122 CurrentDescriptor = (PIO_RESOURCE_DESCRIPTOR)((PUCHAR)ResList + OldResList->ListSize);
123
124 ExFreePool(OldResList);
125 Irp->IoStatus.Information = 0;
126 }
127 else
128 {
129 /* We need to make a new one */
130 ListSize = sizeof(IO_RESOURCE_REQUIREMENTS_LIST) + sizeof(IO_RESOURCE_DESCRIPTOR) * (AccessRangeCount - 1);
132 ListSize);
133 if (!ResList) return STATUS_NO_MEMORY;
134
135 RtlZeroMemory(ResList, ListSize);
136
137 /* We need to initialize some fields */
138 ResList->ListSize = ListSize;
139 ResList->InterfaceType = DeviceExtension->AdapterInterfaceType;
140 ResList->BusNumber = DeviceExtension->SystemIoBusNumber;
141 ResList->SlotNumber = DeviceExtension->SystemIoSlotNumber;
142 ResList->AlternativeLists = 1;
143 ResList->List[0].Version = 1;
144 ResList->List[0].Revision = 1;
145 ResList->List[0].Count = AccessRangeCount;
146
147 CurrentDescriptor = ResList->List[0].Descriptors;
148 }
149
150 for (i = 0; i < AccessRangeCount; i++)
151 {
152 /* This is a required resource */
153 CurrentDescriptor->Option = 0;
154
155 if (AccessRanges[i].RangeInIoSpace)
156 CurrentDescriptor->Type = CmResourceTypePort;
157 else
158 CurrentDescriptor->Type = CmResourceTypeMemory;
159
160 CurrentDescriptor->ShareDisposition =
162
163 CurrentDescriptor->Flags = 0;
164
165 if (CurrentDescriptor->Type == CmResourceTypePort)
166 {
167 CurrentDescriptor->u.Port.Length = AccessRanges[i].RangeLength;
168 CurrentDescriptor->u.Port.MinimumAddress = AccessRanges[i].RangeStart;
169 CurrentDescriptor->u.Port.MaximumAddress.QuadPart = AccessRanges[i].RangeStart.QuadPart + AccessRanges[i].RangeLength - 1;
170 CurrentDescriptor->u.Port.Alignment = 1;
171 if (AccessRanges[i].RangePassive & VIDEO_RANGE_PASSIVE_DECODE)
172 CurrentDescriptor->Flags |= CM_RESOURCE_PORT_PASSIVE_DECODE;
173 if (AccessRanges[i].RangePassive & VIDEO_RANGE_10_BIT_DECODE)
174 CurrentDescriptor->Flags |= CM_RESOURCE_PORT_10_BIT_DECODE;
175 }
176 else
177 {
178 CurrentDescriptor->u.Memory.Length = AccessRanges[i].RangeLength;
179 CurrentDescriptor->u.Memory.MinimumAddress = AccessRanges[i].RangeStart;
180 CurrentDescriptor->u.Memory.MaximumAddress.QuadPart = AccessRanges[i].RangeStart.QuadPart + AccessRanges[i].RangeLength - 1;
181 CurrentDescriptor->u.Memory.Alignment = 1;
182 CurrentDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_WRITE;
183 }
184
185 CurrentDescriptor++;
186 }
187
188 Irp->IoStatus.Information = (ULONG_PTR)ResList;
189
190 return STATUS_SUCCESS;
191}
struct _IO_RESOURCE_DESCRIPTOR * PIO_RESOURCE_DESCRIPTOR
struct _IO_RESOURCE_DESCRIPTOR IO_RESOURCE_DESCRIPTOR
struct _IO_RESOURCE_REQUIREMENTS_LIST IO_RESOURCE_REQUIREMENTS_LIST
#define ULONG_PTR
Definition: config.h:101
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
#define CmResourceTypeMemory
Definition: hwresource.cpp:125
#define CmResourceTypePort
Definition: hwresource.cpp:123
#define CM_RESOURCE_MEMORY_READ_WRITE
Definition: cmtypes.h:120
#define CM_RESOURCE_PORT_PASSIVE_DECODE
Definition: cmtypes.h:114
#define CM_RESOURCE_PORT_10_BIT_DECODE
Definition: cmtypes.h:110
#define VIDEO_RANGE_10_BIT_DECODE
Definition: video.h:99
#define VIDEO_RANGE_PASSIVE_DECODE
Definition: video.h:98
union _IO_RESOURCE_DESCRIPTOR::@21 u
struct _IO_RESOURCE_DESCRIPTOR::@21::@22 Port
UCHAR ShareDisposition
Definition: edit.c:61
struct _IO_RESOURCE_DESCRIPTOR::@21::@23 Memory
ULONG Count
Definition: edit.c:124
USHORT Revision
Definition: edit.c:123
USHORT Version
Definition: edit.c:122
IO_RESOURCE_DESCRIPTOR Descriptors[1]
Definition: edit.c:125
INTERFACE_TYPE InterfaceType
Definition: edit.c:130
IO_RESOURCE_LIST List[1]
Definition: edit.c:135
ULONG RangeLength
Definition: video.h:216
UCHAR RangeShareable
Definition: video.h:219
PHYSICAL_ADDRESS RangeStart
Definition: video.h:215
LONGLONG QuadPart
Definition: typedefs.h:114
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
@ CmResourceShareDeviceExclusive
Definition: cmtypes.h:241
@ CmResourceShareShared
Definition: cmtypes.h:243

Referenced by IntVideoPortDispatchFdoPnp().

◆ IntVideoPortFindAdapter()

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

Definition at line 414 of file videoprt.c.

418{
419 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
421 VP_STATUS vpStatus;
422 VIDEO_PORT_CONFIG_INFO ConfigInfo;
424 UCHAR Again = FALSE;
425 BOOL LegacyDetection = FALSE;
426
427 DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
428
429 /* Setup a ConfigInfo structure that we will pass to HwFindAdapter. */
430 RtlZeroMemory(&ConfigInfo, sizeof(VIDEO_PORT_CONFIG_INFO));
431 ConfigInfo.Length = sizeof(VIDEO_PORT_CONFIG_INFO);
432 ConfigInfo.AdapterInterfaceType = DeviceExtension->AdapterInterfaceType;
433 if (ConfigInfo.AdapterInterfaceType == PCIBus)
434 ConfigInfo.InterruptMode = LevelSensitive;
435 else
436 ConfigInfo.InterruptMode = Latched;
437 ConfigInfo.DriverRegistryPath = DriverExtension->RegistryPath.Buffer;
439 ConfigInfo.SystemIoBusNumber = DeviceExtension->SystemIoBusNumber;
440 ConfigInfo.BusInterruptLevel = DeviceExtension->InterruptLevel;
441 ConfigInfo.BusInterruptVector = DeviceExtension->InterruptVector;
442
445 sizeof(SystemBasicInfo),
446 NULL);
447 if (NT_SUCCESS(Status))
448 {
451 }
452
453 // FIXME: Check the adapter key and update VideoDebugLevel variable.
454
455 /*
456 * Call miniport HwVidFindAdapter entry point to detect if
457 * particular device is present. There are two possible code
458 * paths. The first one is for Legacy drivers (NT4) and cases
459 * when we don't have information about what bus we're on. The
460 * second case is the standard one for Plug & Play drivers.
461 */
462 if (DeviceExtension->PhysicalDeviceObject == NULL)
463 {
464 LegacyDetection = TRUE;
465 }
466
467 if (LegacyDetection)
468 {
470
471 /* Suppose first we may not find any suitable device */
472 vpStatus = ERROR_DEV_NOT_EXIST; // ERROR_NO_MORE_DEVICES;
473
474 /* Enumerate all buses of the given type, call HwFindAdapter for each
475 * to find whether a video adapter is recognized there. Stop when an
476 * adapter has been found. */
477 for (BusNumber = 0;
478 (BusNumber < MAXULONG) &&
480 &BusNumber));
481 ++BusNumber)
482 {
483 DPRINT("Bus Type %lu, Number %lu\n",
484 DeviceExtension->AdapterInterfaceType, BusNumber);
485
486 DeviceExtension->SystemIoBusNumber =
487 ConfigInfo.SystemIoBusNumber = BusNumber;
488
489 RtlZeroMemory(&DeviceExtension->MiniPortDeviceExtension,
490 DriverExtension->InitializationData.HwDeviceExtensionSize);
491
492 /* FIXME: Need to figure out what string to pass as param 3. */
493 // FIXME: Handle the 'Again' parameter for legacy detection.
494 vpStatus = DriverExtension->InitializationData.HwFindAdapter(
495 &DeviceExtension->MiniPortDeviceExtension,
496 DriverExtension->HwContext,
497 NULL,
498 &ConfigInfo,
499 &Again);
500
501 if (vpStatus == ERROR_DEV_NOT_EXIST)
502 {
503 continue;
504 }
505 else
506 {
507 break;
508 }
509 }
510 }
511 else
512 {
513 /* FIXME: Need to figure out what string to pass as param 3. */
514 vpStatus = DriverExtension->InitializationData.HwFindAdapter(
515 &DeviceExtension->MiniPortDeviceExtension,
516 DriverExtension->HwContext,
517 NULL,
518 &ConfigInfo,
519 &Again);
520 }
521
522 if (vpStatus != NO_ERROR)
523 {
524 ERR_(VIDEOPRT, "HwFindAdapter call failed with error 0x%X\n", vpStatus);
526 goto Failure;
527 }
528
529 /*
530 * Now we know the device is present, so let's do all additional tasks
531 * such as creating symlinks or setting up interrupts and timer.
532 */
533
534 /* FIXME: Allocate hardware resources for device. */
535
536 /* Allocate interrupt for device. */
538 {
540 goto Failure;
541 }
542
543 /* Allocate timer for device. */
545 {
546 if (DeviceExtension->InterruptObject != NULL)
547 IoDisconnectInterrupt(DeviceExtension->InterruptObject);
548 ERR_(VIDEOPRT, "IntVideoPortSetupTimer failed\n");
550 goto Failure;
551 }
552
553 /* If the device can be reset, insert it in the list of resettable adapters */
554 InitializeListHead(&DeviceExtension->HwResetListEntry);
555 if (DriverExtension->InitializationData.HwResetHw != NULL)
556 {
558 &DeviceExtension->HwResetListEntry,
560 }
561
562 INFO_(VIDEOPRT, "STATUS_SUCCESS\n");
563 return STATUS_SUCCESS;
564
565Failure:
566 RtlFreeUnicodeString(&DeviceExtension->RegistryPath);
567 if (DeviceExtension->NextDeviceObject)
568 IoDetachDevice(DeviceExtension->NextDeviceObject);
570 return Status;
571}
#define ERROR_DEV_NOT_EXIST
Definition: dderror.h:8
unsigned int BOOL
Definition: ntddk_ex.h:94
NTSYSAPI NTSTATUS NTAPI ZwQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
@ SystemBasicInformation
Definition: ntddk_ex.h:11
PVOID NTAPI IntVideoPortGetProcAddress(IN PVOID HwDeviceExtension, IN PUCHAR FunctionName)
Definition: funclist.c:100
@ PCIBus
Definition: hwresource.cpp:142
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
VOID NTAPI IoDisconnectInterrupt(PKINTERRUPT InterruptObject)
Definition: irq.c:141
SYSTEM_BASIC_INFORMATION SystemBasicInfo
Definition: perfdata.c:30
@ Latched
Definition: miniport.h:81
@ LevelSensitive
Definition: miniport.h:80
LONG VP_STATUS
Definition: video.h:153
struct _VIDEO_PORT_CONFIG_INFO VIDEO_PORT_CONFIG_INFO
KINTERRUPT_MODE InterruptMode
Definition: video.h:172
INTERFACE_TYPE AdapterInterfaceType
Definition: video.h:169
PVIDEO_PORT_GET_PROC_ADDRESS VideoPortGetProcAddress
Definition: video.h:193
ULONG BusInterruptVector
Definition: video.h:171
ULONGLONG SystemMemorySize
Definition: video.h:195
PWSTR DriverRegistryPath
Definition: video.h:194
#define MAXULONG
Definition: typedefs.h:251
static NTSTATUS IntVideoPortEnumBuses(_In_ INTERFACE_TYPE AdapterInterfaceType, _Inout_ PULONG BusNumber)
Enumerates all supported buses on the system.
Definition: videoprt.c:387
KSPIN_LOCK HwResetAdaptersLock
Definition: videoprt.c:43
LIST_ENTRY HwResetAdaptersList
BOOLEAN NTAPI IntVideoPortSetupInterrupt(IN PDEVICE_OBJECT DeviceObject, IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, IN PVIDEO_PORT_CONFIG_INFO ConfigInfo)
Definition: interrupt.c:45
BOOLEAN NTAPI IntVideoPortSetupTimer(IN PDEVICE_OBJECT DeviceObject, IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension)
Definition: timer.c:43
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:160

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 {
114 }
115 }
116
117 ERR_(VIDEOPRT, "VideoPortGetProcAddress: Can't resolve symbol %s\n", FunctionName);
118
119 return NULL;
120}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
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:1279
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
const VIDEO_PORT_FUNCTION_TABLE VideoPortExports[]
Definition: funclist.c:36
char * PCHAR
Definition: typedefs.h:51

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 219 of file resource.c.

225{
226 OBJECT_ATTRIBUTES ObjAttribs;
228 HANDLE hMemObj;
230 SIZE_T Size;
231
232 /* Initialize object attribs */
233 RtlInitUnicodeString(&UnicodeString, L"\\Device\\PhysicalMemory");
234 InitializeObjectAttributes(&ObjAttribs,
237 NULL, NULL);
238
239 /* Open physical memory section */
240 Status = ZwOpenSection(&hMemObj, SECTION_ALL_ACCESS, &ObjAttribs);
241 if (!NT_SUCCESS(Status))
242 {
243 WARN_(VIDEOPRT, "ZwOpenSection() failed! (0x%x)\n", Status);
244 return Status;
245 }
246
247 /* Map view of section */
248 Size = SizeInBytes;
249 Status = ZwMapViewOfSection(hMemObj,
250 Process,
252 0,
253 Size,
255 &Size,
256 ViewUnmap,
257 0,
258 Protect);
259 ZwClose(hMemObj);
260 if (!NT_SUCCESS(Status))
261 {
262 WARN_(VIDEOPRT, "ZwMapViewOfSection() failed! (0x%x)\n", Status);
263 }
264
265 return Status;
266}
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
NTSYSAPI NTSTATUS NTAPI ZwOpenSection(_Out_ PHANDLE SectionHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes)
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define SECTION_ALL_ACCESS
Definition: nt_native.h:1293
@ ViewUnmap
Definition: nt_native.h:1279
_Must_inspect_result_ _In_ WDFDMATRANSACTION _In_ PFN_WDF_PROGRAM_DMA _In_ WDF_DMA_DIRECTION _In_ PMDL _In_ PVOID VirtualAddress
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1098
_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:221

Referenced by IntAgpCommitVirtual(), and IntVideoPortMapMemory().

◆ IntVideoPortReleaseResources()

VOID IntVideoPortReleaseResources ( _In_ PVIDEO_PORT_DEVICE_EXTENSION  DeviceExtension)

Definition at line 194 of file resource.c.

196{
198 BOOLEAN ConflictDetected;
199 // An empty CM_RESOURCE_LIST
200 UCHAR EmptyResourceList[FIELD_OFFSET(CM_RESOURCE_LIST, List)] = {0};
201
203 DeviceExtension->DriverObject,
204 NULL, 0, /* Driver List */
205 DeviceExtension->PhysicalDeviceObject,
206 (PCM_RESOURCE_LIST)EmptyResourceList,
207 sizeof(EmptyResourceList),
208 &ConflictDetected);
209
210 if (!NT_SUCCESS(Status))
211 {
212 DPRINT1("VideoPortReleaseResources IoReportResource failed with 0x%08lx ; ConflictDetected: %s\n",
213 Status, ConflictDetected ? "TRUE" : "FALSE");
214 }
215 /* Ignore the returned status however... */
216}
#define DPRINT1
Definition: precomp.h:8
NTSTATUS NTAPI IoReportResourceForDetection(IN PDRIVER_OBJECT DriverObject, IN PCM_RESOURCE_LIST DriverList OPTIONAL, IN ULONG DriverListSize OPTIONAL, IN PDEVICE_OBJECT DeviceObject OPTIONAL, IN PCM_RESOURCE_LIST DeviceList OPTIONAL, IN ULONG DeviceListSize OPTIONAL, OUT PBOOLEAN ConflictDetected)
Definition: pnpreport.c:394
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550

Referenced by VideoPortVerifyAccessRanges().

◆ 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,
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}
_Out_ PKIRQL Irql
Definition: csq.h:179
ULONG_PTR KAFFINITY
Definition: compat.h:85
NTHALAPI ULONG NTAPI HalGetInterruptVector(INTERFACE_TYPE, ULONG, ULONG, ULONG, PKIRQL, PKAFFINITY)
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
if(dx< 0)
Definition: linetemp.h:194
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
BOOLEAN NTAPI IntVideoPortInterruptRoutine(IN struct _KINTERRUPT *Interrupt, IN PVOID ServiceContext)
Definition: interrupt.c:32
_In_ ULONG _In_ ULONG _In_ ULONG _Out_ PKIRQL _Out_ PKAFFINITY Affinity
Definition: halfuncs.h:174

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}
NTSTATUS NTAPI IoInitializeTimer(IN PDEVICE_OBJECT DeviceObject, IN PIO_TIMER_ROUTINE TimerRoutine, IN PVOID Context)
Definition: iotimer.c:92
VOID NTAPI IntVideoPortTimerRoutine(IN PDEVICE_OBJECT DeviceObject, IN PVOID ServiceContext)
Definition: timer.c:30

Referenced by IntVideoPortFindAdapter().

◆ IntVideoPortUnload()

VOID NTAPI IntVideoPortUnload ( PDRIVER_OBJECT  DriverObject)

Definition at line 1197 of file dispatch.c.

1198{
1199}

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;
40 PIRP Irp;
41
42 /* Always call the top of the device stack */
44
46 &Event,
48 FALSE);
49
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 {
72 sizeof(Stack->Parameters));
73 }
74
75 Status = IoCallDriver(TopDeviceObject, Irp);
77 {
79 &Event,
82 FALSE,
83 NULL);
85 }
86
87 ObDereferenceObject(TopDeviceObject);
88
89 return Status;
90}
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
@ NotificationEvent
PDEVICE_OBJECT NTAPI IoGetAttachedDeviceReference(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1406
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 STATUS_PENDING
Definition: ntstatus.h:82
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
_In_ UCHAR _In_ UCHAR MinorFunction
Definition: wdfdevice.h:1699
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:639
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2695

Referenced by IntAgpGetInterface().

Variable Documentation

◆ CsrProcess

◆ HwResetAdaptersList

LIST_ENTRY HwResetAdaptersList
extern

◆ HwResetAdaptersLock

KSPIN_LOCK HwResetAdaptersLock
extern

◆ VideoPortDeviceNumber

ULONG VideoPortDeviceNumber
extern

◆ VideoPortInt10Mutex

KMUTEX VideoPortInt10Mutex
extern

Definition at line 42 of file videoprt.c.

Referenced by IntInt10CallBios(), and VideoPortInitialize().

◆ VideoPortUseNewKey

BOOLEAN VideoPortUseNewKey
extern