ReactOS 0.4.16-dev-2357-g35d0dfe
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)
 
BOOLEAN FASTCALL IntAttachToCSRSS (_Outptr_ PKPROCESS *CallingProcess, _Out_ PKAPC_STATE ApcState)
 Attach the current thread to the CSRSS process. The caller must detach from the process by invoking IntDetachFromCSRSS() after operating in its context.
 
VOID FASTCALL IntDetachFromCSRSS (_In_ PKPROCESS CallingProcess, _In_ PKAPC_STATE ApcState)
 Detach the current thread from the CSRSS process. This routine is to be invoked after a previous successful IntAttachToCSRSS() call.
 
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 IntInitializeInt10 (VOID)
 
VP_STATUS NTAPI IntInt10AllocateBuffer (_In_ PVOID Context, _Out_ PUSHORT Seg, _Out_ PUSHORT Off, _Inout_ 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_writes_bytes_(Length) PVOID Buffer, _In_ ULONG Length)
 
VP_STATUS NTAPI IntInt10WriteMemory (_In_ PVOID Context, _In_ USHORT Seg, _In_ USHORT Off, _In_reads_bytes_(Length) PVOID Buffer, _In_ ULONG Length)
 
VP_STATUS NTAPI IntInt10CallBios (_In_ PVOID Context, _Inout_ 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
 
KSPIN_LOCK HwResetAdaptersLock
 
LIST_ENTRY HwResetAdaptersList
 
KMUTEX VgaSyncLock
 
PVIDEO_PORT_DEVICE_EXTENSION VgaDeviceExtension
 
PVIDEO_ACCESS_RANGE VgaRanges
 
ULONG NumOfVgaRanges
 
KMUTEX VideoPortInt10Mutex
 

Macro Definition Documentation

◆ __BROKEN__

#define __BROKEN__

Definition at line 27 of file videoprt.h.

◆ GUID_STRING_LENGTH

#define GUID_STRING_LENGTH   (38 * sizeof(WCHAR))

Definition at line 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 139 of file videoprt.h.

◆ VIDEO_PORT_GET_DEVICE_EXTENSION

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

Definition at line 145 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:33
Status
Definition: gdiplustypes.h:25
#define ASSERT(a)
Definition: mode.c:44
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
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
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::@1672 Parameters
struct _IO_STACK_LOCATION::@4302::@4328 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:145
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465
#define IRP_MN_QUERY_INTERFACE

Referenced by VideoPortQueryServices().

◆ IntAttachToCSRSS()

BOOLEAN FASTCALL IntAttachToCSRSS ( _Outptr_ PKPROCESS CallingProcess,
_Out_ PKAPC_STATE  ApcState 
)

Attach the current thread to the CSRSS process. The caller must detach from the process by invoking IntDetachFromCSRSS() after operating in its context.

Parameters
[out]CallingProcessPointer to a PKPROCESS variable that receives the current process.
[out]ApcStatePointer to a caller-provided KAPC_STATE structure that will be initialized.
Returns
TRUE if attachment succeeded (the CSRSS process exists); FALSE if not.

Definition at line 736 of file videoprt.c.

739{
740 if (!CsrProcess)
741 return FALSE;
742
743 *CallingProcess = (PKPROCESS)PsGetCurrentProcess();
744 if (*CallingProcess != CsrProcess)
746 return TRUE;
747}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1769
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 VideoPortGetRomImage().

◆ IntCopyRegistryKey()

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

Definition at line 34 of file registry.c.

37{
38 PVOID InfoBuffer;
39 PKEY_BASIC_INFORMATION KeyInformation;
40 PKEY_VALUE_FULL_INFORMATION KeyValueInformation;
42 ULONG Index, InformationLength, RequiredLength;
43 UNICODE_STRING NameString;
45 HANDLE SourceSubKeyHandle, DestSubKeyHandle;
46
47 /* Start with no buffer, set initial size */
48 InfoBuffer = NULL;
49 InformationLength = 256;
50
51 /* Start looping with key index 0 */
52 Index = 0;
53 while (TRUE)
54 {
55 /* Check if we have no buffer */
56 if (InfoBuffer == NULL)
57 {
58 /* Allocate a new buffer */
60 InformationLength,
62 if (InfoBuffer == NULL)
63 {
64 ERR_(VIDEOPRT, "Could not allocate buffer for key info\n");
66 }
67 }
68
69 /* Enumerate the next sub-key */
70 KeyInformation = InfoBuffer;
71 Status = ZwEnumerateKey(SourceKeyHandle,
72 Index,
74 KeyInformation,
75 InformationLength,
79 {
80 /* Free the buffer and remember the required size */
82 InfoBuffer = NULL;
83 InformationLength = RequiredLength;
84
85 /* Try again */
86 continue;
87 }
89 {
90 /* We are done with the sub-keys */
91 break;
92 }
93 else if (!NT_SUCCESS(Status))
94 {
95 ERR_(VIDEOPRT, "ZwEnumerateKey failed, status 0x%lx\n", Status);
96 goto Cleanup;
97 }
98
99 /* Initialize a unicode string from the key name */
100 NameString.Buffer = KeyInformation->Name;
101 NameString.Length = (USHORT)KeyInformation->NameLength;
102 NameString.MaximumLength = NameString.Length;
103
104 /* Initialize object attributes and open the source sub-key */
106 &NameString,
108 SourceKeyHandle,
109 NULL);
110 Status = ZwOpenKey(&SourceSubKeyHandle, KEY_READ, &ObjectAttributes);
111 if (!NT_SUCCESS(Status))
112 {
113 ERR_(VIDEOPRT, "Failed to open the source key\n");
114 goto Cleanup;
115 }
116
117 /* Initialize object attributes and create the dest sub-key */
119 &NameString,
121 DestKeyHandle,
122 NULL);
123 Status = ZwCreateKey(&DestSubKeyHandle,
124 KEY_WRITE,
126 0,
127 NULL,
129 NULL);
130 if (!NT_SUCCESS(Status))
131 {
132 ERR_(VIDEOPRT, "Failed to create the destination key\n");
133 ObCloseHandle(SourceSubKeyHandle, KernelMode);
134 goto Cleanup;
135 }
136
137 /* Recursively copy the sub-key */
138 Status = IntCopyRegistryKey(SourceSubKeyHandle, DestSubKeyHandle);
139 if (!NT_SUCCESS(Status))
140 {
141 /* Just warn, but continue with the remaining sub-keys */
142 WARN_(VIDEOPRT, "Failed to copy subkey '%wZ'\n", &NameString);
143 }
144
145 /* Close the sub-key handles */
146 ObCloseHandle(SourceSubKeyHandle, KernelMode);
147 ObCloseHandle(DestSubKeyHandle, KernelMode);
148
149 /* Next sub-key */
150 Index++;
151 }
152
153 /* Start looping with value index 0 */
154 Index = 0;
155 while (TRUE)
156 {
157 /* Check if we have no buffer */
158 if (InfoBuffer == NULL)
159 {
160 /* Allocate a new buffer */
161 InfoBuffer = ExAllocatePoolWithTag(PagedPool,
162 InformationLength,
164 if (InfoBuffer == NULL)
165 {
166 ERR_(VIDEOPRT, "Could not allocate buffer for key values\n");
167 return Status;
168 }
169 }
170
171 /* Enumerate the next value */
172 KeyValueInformation = InfoBuffer;
173 Status = ZwEnumerateValueKey(SourceKeyHandle,
174 Index,
176 KeyValueInformation,
177 InformationLength,
181 {
182 /* Free the buffer and remember the required size */
184 InfoBuffer = NULL;
185 InformationLength = RequiredLength;
186
187 /* Try again */
188 continue;
189 }
190 else if (Status == STATUS_NO_MORE_ENTRIES)
191 {
192 /* We are done with the values */
194 break;
195 }
196 else if (!NT_SUCCESS(Status))
197 {
198 ERR_(VIDEOPRT, "ZwEnumerateValueKey failed, status 0x%lx\n", Status);
199 goto Cleanup;
200 }
201
202 /* Initialize a unicode string from the value name */
203 NameString.Buffer = KeyValueInformation->Name;
204 NameString.Length = (USHORT)KeyValueInformation->NameLength;
205 NameString.MaximumLength = NameString.Length;
206
207 /* Create the key value in the destination key */
208 Status = ZwSetValueKey(DestKeyHandle,
209 &NameString,
210 KeyValueInformation->TitleIndex,
211 KeyValueInformation->Type,
212 (PUCHAR)KeyValueInformation + KeyValueInformation->DataOffset,
213 KeyValueInformation->DataLength);
214 if (!NT_SUCCESS(Status))
215 {
216 /* Just warn, but continue with the remaining sub-keys */
217 WARN_(VIDEOPRT, "Failed to set value '%wZ'\n", &NameString);
218 }
219
220 /* Next subkey */
221 Index++;
222 }
223
224Cleanup:
225 /* Free the buffer and return the failure code */
226 if (InfoBuffer != NULL)
228 return Status;
229}
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
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 ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define KernelMode
Definition: asm.h:38
@ KeyBasicInformation
Definition: nt_native.h:1134
@ KeyValueFullInformation
Definition: nt_native.h:1184
#define KEY_READ
Definition: nt_native.h:1026
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1060
#define KEY_WRITE
Definition: nt_native.h:1034
#define STATUS_NO_MORE_ENTRIES
Definition: ntstatus.h:285
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3379
unsigned short USHORT
Definition: pedump.c:61
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#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:34
_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 233 of file registry.c.

237{
238 PKEY_VALUE_PARTIAL_INFORMATION ValueInformation;
239 UNICODE_STRING ValueNameString;
242
243 RtlInitUnicodeString(&ValueNameString, ValueName);
244
245 /* Query the value length */
246 Status = ZwQueryValueKey(SourceKeyHandle,
247 &ValueNameString,
249 NULL,
250 0,
251 &Length);
254 {
255 /* The key seems not present */
257 return Status;
258 }
259
260 /* Allocate a buffer */
262 if (ValueInformation == NULL)
263 {
264 return Status;
265 }
266
267 /* Query the value */
268 Status = ZwQueryValueKey(SourceKeyHandle,
269 &ValueNameString,
271 ValueInformation,
272 Length,
273 &Length);
274 if (!NT_SUCCESS(Status))
275 {
276 ExFreePoolWithTag(ValueInformation, TAG_VIDEO_PORT_BUFFER);
277 return Status;
278 }
279
280 /* Write the registry value */
281 Status = ZwSetValueKey(DestKeyHandle,
282 &ValueNameString,
283 ValueInformation->TitleIndex,
284 ValueInformation->Type,
285 ValueInformation->Data,
286 ValueInformation->DataLength);
287
288 ExFreePoolWithTag(ValueInformation, TAG_VIDEO_PORT_BUFFER);
289
290 if (!NT_SUCCESS(Status))
291 ERR_(VIDEOPRT, "ZwSetValueKey failed, status 0x%lx\n", Status);
292
293 return Status;
294}
@ KeyValuePartialInformation
Definition: nt_native.h:1185
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:3327

Referenced by IntSetupDeviceSettingsKey().

◆ IntCreateNewRegistryPath()

NTSTATUS NTAPI IntCreateNewRegistryPath ( PVIDEO_PORT_DEVICE_EXTENSION  DeviceExtension)
Todo:
HACK

Definition at line 408 of file registry.c.

410{
411 static UNICODE_STRING VideoIdValueName = RTL_CONSTANT_STRING(L"VideoId");
412 static UNICODE_STRING ControlVideoPathName =
413 RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Video\\");
414 HANDLE DevInstRegKey, SettingsKey, NewKey;
416 UNICODE_STRING VideoIdString;
417 UUID VideoId;
418 PKEY_VALUE_PARTIAL_INFORMATION ValueInformation ;
421 USHORT KeyMaxLength;
423 PWCHAR InstanceIdBuffer;
424
425 if (!DeviceExtension->PhysicalDeviceObject)
426 {
428 &DeviceExtension->RegistryPath,
429 &DeviceExtension->NewRegistryPath);
430 if (!NT_SUCCESS(Status))
431 ERR_(VIDEOPRT, "IntDuplicateUnicodeString() failed, status 0x%lx\n", Status);
432 return Status;
433 }
434
435 /* Open the hardware key: HKLM\System\CurrentControlSet\Enum\... */
440 if (Status != STATUS_SUCCESS)
441 {
442 ERR_(VIDEOPRT, "IoOpenDeviceRegistryKey failed, status 0x%lx\n", Status);
443 return Status;
444 }
445
446 /* Query the VideoId value */
447 ValueInformation = (PKEY_VALUE_PARTIAL_INFORMATION)VideoIdBuffer;
448 Status = ZwQueryValueKey(DevInstRegKey,
449 &VideoIdValueName,
451 ValueInformation,
452 sizeof(VideoIdBuffer),
453 &ResultLength);
454 if (!NT_SUCCESS(Status))
455 {
456 /* Create a new video Id */
457 Status = ExUuidCreate(&VideoId);
458 if (!NT_SUCCESS(Status))
459 {
460 ERR_(VIDEOPRT, "ExUuidCreate failed, status 0x%lx\n", Status);
462 return Status;
463 }
464
465 /* Convert the GUID into a string */
466 Status = RtlStringFromGUID(&VideoId, &VideoIdString);
467 if (!NT_SUCCESS(Status))
468 {
469 ERR_(VIDEOPRT, "RtlStringFromGUID failed, status 0x%lx\n", Status);
471 return Status;
472 }
473
474 /* Copy the GUID String to our buffer */
475 ValueInformation->DataLength = min(VideoIdString.Length, GUID_STRING_LENGTH);
476 RtlCopyMemory(ValueInformation->Data,
477 VideoIdString.Buffer,
478 ValueInformation->DataLength);
479
480 /* Free the GUID string */
481 RtlFreeUnicodeString(&VideoIdString);
482
483 /* Write the VideoId registry value */
484 Status = ZwSetValueKey(DevInstRegKey,
485 &VideoIdValueName,
486 0,
487 REG_SZ,
488 ValueInformation->Data,
489 ValueInformation->DataLength);
490 if (!NT_SUCCESS(Status))
491 {
492 ERR_(VIDEOPRT, "ZwSetValueKey failed, status 0x%lx\n", Status);
494 return Status;
495 }
496 }
497
498 /* Initialize the VideoId string from the registry data */
499 VideoIdString.Buffer = (PWCHAR)ValueInformation->Data;
500 VideoIdString.Length = (USHORT)ValueInformation->DataLength;
501 VideoIdString.MaximumLength = VideoIdString.Length;
502
503 /* Close the hardware key */
505
506 /* Calculate the size needed for the new registry path name */
507 KeyMaxLength = ControlVideoPathName.Length +
508 VideoIdString.Length +
509 sizeof(L"\\0000");
510
511 /* Allocate the path name buffer */
512 DeviceExtension->NewRegistryPath.Length = 0;
513 DeviceExtension->NewRegistryPath.MaximumLength = KeyMaxLength;
515 KeyMaxLength,
517 if (DeviceExtension->NewRegistryPath.Buffer == NULL)
518 {
519 ERR_(VIDEOPRT, "Failed to allocate key name buffer\n");
521 }
522
523 /* Copy the root key name and append the VideoId string */
524 RtlCopyUnicodeString(&DeviceExtension->NewRegistryPath,
525 &ControlVideoPathName);
527 &VideoIdString);
528
529 /* Check if we have the key already */
531 DeviceExtension->NewRegistryPath.Buffer);
532 if (Status != STATUS_SUCCESS)
533 {
534 /* Try to create the new key */
536 DeviceExtension->NewRegistryPath.Buffer);
537 }
538
539 /* Append the instance path */
540 RtlAppendUnicodeToString(&DeviceExtension->NewRegistryPath, L"\\");
541 InstanceIdBuffer = DeviceExtension->NewRegistryPath.Buffer +
542 DeviceExtension->NewRegistryPath.Length / sizeof(WCHAR);
543 RtlAppendUnicodeToString(&DeviceExtension->NewRegistryPath, L"0000");
544
545 /* Write instance ID */
546 swprintf(InstanceIdBuffer, L"%04u", DeviceExtension->DisplayNumber);
547
548 /* Check if the name exists */
550 DeviceExtension->NewRegistryPath.Buffer);
551 if (Status != STATUS_SUCCESS)
552 {
553 /* Try to create the new key */
555 DeviceExtension->NewRegistryPath.Buffer);
556 if (!NT_SUCCESS(Status))
557 {
558 ERR_(VIDEOPRT, "Failed to create key '%wZ', status 0x%lx\n",
559 &DeviceExtension->NewRegistryPath, Status);
560 return Status;
561 }
562
563 /* Open the new key */
565 &DeviceExtension->NewRegistryPath,
567 NULL,
568 NULL);
569 Status = ZwOpenKey(&NewKey, KEY_WRITE, &ObjectAttributes);
570 if (!NT_SUCCESS(Status))
571 {
572 ERR_(VIDEOPRT, "Failed to open settings key, status 0x%lx\n", Status);
573 return Status;
574 }
575
576 /* Open the device profile key */
578 &DeviceExtension->RegistryPath,
580 NULL,
581 NULL);
582 Status = ZwOpenKey(&SettingsKey, KEY_READ, &ObjectAttributes);
583 if (!NT_SUCCESS(Status))
584 {
585 ERR_(VIDEOPRT, "Failed to open settings key, status 0x%lx\n", Status);
586 ObCloseHandle(NewKey, KernelMode);
587 return Status;
588 }
589
590 /* Copy the registry data from the legacy key */
591 Status = IntCopyRegistryKey(SettingsKey, NewKey);
592
593 /* Close the key handles */
594 ObCloseHandle(SettingsKey, KernelMode);
595 ObCloseHandle(NewKey, KernelMode);
596 }
597
598 return Status;
599}
#define RTL_CONSTANT_STRING(s)
Definition: combase.c:35
#define swprintf
Definition: precomp.h:40
#define L(x)
Definition: resources.c:13
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
#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:1044
#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)
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 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:3782
NTSTATUS IntDuplicateUnicodeString(IN ULONG Flags, IN PCUNICODE_STRING SourceString, OUT PUNICODE_STRING DestinationString)
Definition: registry.c:361
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
NTSYSAPI NTSTATUS WINAPI RtlCheckRegistryKey(ULONG, PWSTR)
#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 603 of file registry.c.

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

Referenced by IntVideoPortCreateAdapterDeviceObject().

◆ IntDetachFromCSRSS()

VOID FASTCALL IntDetachFromCSRSS ( _In_ PKPROCESS  CallingProcess,
_In_ PKAPC_STATE  ApcState 
)

Detach the current thread from the CSRSS process. This routine is to be invoked after a previous successful IntAttachToCSRSS() call.

Parameters
[in]CallingProcessThe calling process that previously invoked IntAttachToCSRSS().
[in]ApcStatePointer to the KAPC_STATE structure that was initialized by a previous IntAttachToCSRSS() call.

Definition at line 763 of file videoprt.c.

766{
768 if (CallingProcess != CsrProcess)
770}
VOID NTAPI KeUnstackDetachProcess(IN PRKAPC_STATE ApcState)
Definition: procobj.c:756

Referenced by VideoPortGetRomImage().

◆ IntInitializeInt10()

NTSTATUS IntInitializeInt10 ( VOID  )

Definition at line 766 of file int10.c.

767{
768 static BOOLEAN FirstInitialization = FALSE;
769
770 if (!FirstInitialization)
771 {
772 FirstInitialization = TRUE;
773#ifdef _M_IX86
774 /* Initialize the x86 emulator if necessary, otherwise fall back to V86 mode */
775 if (!VideoPortDisableX86Emulator)
776 {
777 /* Use the emulation routines */
778 //Int10Vtbl = &Int10IFace[0];
780 return STATUS_SUCCESS;
781 DPRINT1("Could not initialize the x86 emulator; falling back to V86 mode\n");
782 VideoPortDisableX86Emulator = TRUE;
783 }
784
785 /* Fall back to the V86 routines */
786 Int10Vtbl = &Int10IFace[1];
787 return STATUS_SUCCESS;
788#else
789 /* Initialize the x86 emulator */
791#endif
792 }
793
794 /* We should only do that for CSRSS */
796#ifdef _M_IX86
797 return IntInitializeVideoAddressSpace();
798#else
799 return STATUS_SUCCESS;
800#endif
801}
#define DPRINT1
Definition: precomp.h:8
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
static BOOLEAN IntInitializeX86Emu(VOID)
Definition: int10.c:87

Referenced by IntVideoPortDispatchOpen(), and VideoPortInitialize().

◆ IntInt10AllocateBuffer()

VP_STATUS NTAPI IntInt10AllocateBuffer ( _In_ PVOID  Context,
_Out_ PUSHORT  Seg,
_Out_ PUSHORT  Off,
_Inout_ PULONG  Length 
)

Definition at line 375 of file int10.c.

380{
382
383 TRACE_(VIDEOPRT, "IntInt10AllocateBuffer\n");
384
385 Status = INT10(AllocateBuffer)(Context, Seg, Off, Length);
386 if (Status == NO_ERROR)
387 {
388 INFO_(VIDEOPRT, "- Segment: 0x%x\n", *Seg);
389 INFO_(VIDEOPRT, "- Offset : 0x%x\n", *Off);
390 INFO_(VIDEOPRT, "- Length : 0x%x\n", *Length);
391 }
392 return Status;
393}
#define NO_ERROR
Definition: dderror.h:5
#define TRACE_(x)
Definition: compat.h:76
#define INT10(func)
Definition: int10.c:295
LONG VP_STATUS
Definition: video.h:153
_In_ PVOID Context
Definition: storport.h:2269

Referenced by VideoPortQueryServices().

◆ IntInt10CallBios()

VP_STATUS NTAPI IntInt10CallBios ( _In_ PVOID  Context,
_Inout_ PINT10_BIOS_ARGUMENTS  BiosArguments 
)

Definition at line 737 of file int10.c.

740{
741 return INT10(CallBios)(Context, BiosArguments);
742}

Referenced by VideoPortInt10(), and VideoPortQueryServices().

◆ IntInt10FreeBuffer()

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

Definition at line 444 of file int10.c.

448{
449 TRACE_(VIDEOPRT, "IntInt10FreeBuffer\n");
450 INFO_(VIDEOPRT, "- Segment: 0x%x\n", Seg);
451 INFO_(VIDEOPRT, "- Offset : 0x%x\n", Off);
452
453 return INT10(FreeBuffer)(Context, Seg, Off);
454}

Referenced by VideoPortQueryServices().

◆ IntInt10ReadMemory()

VP_STATUS NTAPI IntInt10ReadMemory ( _In_ PVOID  Context,
_In_ USHORT  Seg,
_In_ USHORT  Off,
_Out_writes_bytes_(Length) PVOID  Buffer,
_In_ ULONG  Length 
)

Definition at line 507 of file int10.c.

513{
514 TRACE_(VIDEOPRT, "IntInt10ReadMemory\n");
515 INFO_(VIDEOPRT, "- Segment: 0x%x\n", Seg);
516 INFO_(VIDEOPRT, "- Offset : 0x%x\n", Off);
517 INFO_(VIDEOPRT, "- Buffer : 0x%x\n", Buffer);
518 INFO_(VIDEOPRT, "- Length : 0x%x\n", Length);
519
520 return INT10(ReadMemory)(Context, Seg, Off, Buffer, Length);
521}
Definition: bufpool.h:45
_Must_inspect_result_ _In_ WDFUSBPIPE _In_ WDFREQUEST _In_opt_ WDFMEMORY ReadMemory
Definition: wdfusb.h:2000

Referenced by VideoPortQueryServices().

◆ IntInt10WriteMemory()

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

Definition at line 574 of file int10.c.

580{
581 TRACE_(VIDEOPRT, "IntInt10WriteMemory\n");
582 INFO_(VIDEOPRT, "- Segment: 0x%x\n", Seg);
583 INFO_(VIDEOPRT, "- Offset : 0x%x\n", Off);
584 INFO_(VIDEOPRT, "- Buffer : 0x%x\n", Buffer);
585 INFO_(VIDEOPRT, "- Length : 0x%x\n", Length);
586
587 return INT10(WriteMemory)(Context, Seg, Off, Buffer, Length);
588}
_Must_inspect_result_ _In_ WDFUSBPIPE _In_ WDFREQUEST _In_opt_ WDFMEMORY WriteMemory
Definition: wdfusb.h:1918

Referenced by VideoPortQueryServices().

◆ IntSetupDeviceSettingsKey()

NTSTATUS NTAPI IntSetupDeviceSettingsKey ( PVIDEO_PORT_DEVICE_EXTENSION  DeviceExtension)

Definition at line 298 of file registry.c.

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

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:1916
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:171
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2061
_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 171 of file videoprt.c.

178{
179 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
181 ULONG PciSlotNumber;
183 ULONG Size;
185 WCHAR DeviceBuffer[20];
187 PDEVICE_OBJECT DeviceObject_;
188
189 if (DeviceObject == NULL)
190 DeviceObject = &DeviceObject_;
191
192 /*
193 * Find the first free device number that can be used for video device
194 * object names and symlinks.
195 */
197 if (DeviceNumber == (ULONG)-1)
198 {
199 WARN_(VIDEOPRT, "Can't find free device number\n");
200 return STATUS_UNSUCCESSFUL;
201 }
202
203 /*
204 * Create the device object.
205 */
206
207 /* Create a unicode device name. */
208 swprintf(DeviceBuffer, L"\\Device\\Video%lu", DeviceNumber);
209 RtlInitUnicodeString(&DeviceName, DeviceBuffer);
210
211 INFO_(VIDEOPRT, "HwDeviceExtension size is: 0x%x\n",
212 DriverExtension->InitializationData.HwDeviceExtensionSize);
213
214 /* Create the device object. */
216 DriverExtension->InitializationData.HwDeviceExtensionSize;
218 Size,
219 &DeviceName,
221 0,
222 TRUE,
224
225 if (!NT_SUCCESS(Status))
226 {
227 WARN_(VIDEOPRT, "IoCreateDevice call failed with status 0x%08x\n", Status);
228 return Status;
229 }
230
231 /*
232 * Set the buffering strategy here. If you change this, remember
233 * to change VidDispatchDeviceControl too.
234 */
235
236 (*DeviceObject)->Flags |= DO_BUFFERED_IO;
237
238 /* Initialize device extension. */
239 DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)((*DeviceObject)->DeviceExtension);
240 DeviceExtension->Common.Fdo = TRUE;
241 DeviceExtension->DeviceNumber = DeviceNumber;
242 DeviceExtension->DriverObject = DriverObject;
244 DeviceExtension->FunctionalDeviceObject = *DeviceObject;
245 DeviceExtension->DriverExtension = DriverExtension;
246 DeviceExtension->SessionId = -1;
247 DeviceExtension->AdapterNumber = AdapterNumber;
248 DeviceExtension->DisplayNumber = DisplayNumber;
249 DeviceExtension->IsVgaDriver = IntIsVgaSaveDriver(DriverObject);
250
251 InitializeListHead(&DeviceExtension->ChildDeviceList);
252
253 /*
254 * Miniport owns this blob; many miniports assume it's initially zeroed.
255 * Removing this crashes the NVIDIA GPU driver.
256 */
257 RtlZeroMemory(DeviceExtension->MiniPortDeviceExtension,
258 DriverExtension->InitializationData.HwDeviceExtensionSize);
259
260 /* Get the registry path associated with this device. */
262 DeviceExtension->AdapterNumber,
263 &DeviceExtension->RegistryPath);
264 if (!NT_SUCCESS(Status))
265 {
266 WARN_(VIDEOPRT, "IntCreateRegistryPath() call failed with status 0x%08x\n", Status);
267 goto Failure;
268 }
269
271 {
272 /* Get bus number from the upper level bus driver. */
273 Size = sizeof(ULONG);
276 Size,
277 &DeviceExtension->SystemIoBusNumber,
278 &Size);
279 if (!NT_SUCCESS(Status))
280 {
281 WARN_(VIDEOPRT, "Couldn't get an information from bus driver. We will try to\n"
282 "use legacy detection method, but even that doesn't mean that\n"
283 "it will work.\n");
284 DeviceExtension->PhysicalDeviceObject = NULL;
285 }
286 }
287
288 DeviceExtension->AdapterInterfaceType =
289 DriverExtension->InitializationData.AdapterInterfaceType;
290
292 {
293 /* Get bus type from the upper level bus driver. */
294 Size = sizeof(ULONG);
297 Size,
298 &DeviceExtension->AdapterInterfaceType,
299 &Size);
300
301 /* Get bus device address from the upper level bus driver. */
302 Size = sizeof(ULONG);
305 Size,
306 &PciSlotNumber,
307 &Size);
308
309 /* Convert slotnumber to PCI_SLOT_NUMBER */
310 SlotNumber.u.AsULONG = 0;
311 SlotNumber.u.bits.DeviceNumber = (PciSlotNumber >> 16) & 0xFFFF;
312 SlotNumber.u.bits.FunctionNumber = PciSlotNumber & 0xFFFF;
313 DeviceExtension->SystemIoSlotNumber = SlotNumber.u.AsULONG;
314 }
315
317 InitializeListHead(&DeviceExtension->DmaAdapterList);
318
319 KeInitializeDpc(&DeviceExtension->DpcObject,
321 DeviceExtension);
322
323 KeInitializeMutex(&DeviceExtension->DeviceLock, 0);
324
325 /* Attach the device. */
326 if ((PhysicalDeviceObject != NULL) && (DisplayNumber == 0))
330
331 Status = IntCreateNewRegistryPath(DeviceExtension);
332 if (!NT_SUCCESS(Status))
333 {
334 ERR_(VIDEOPRT, "IntCreateNewRegistryPath() failed with status 0x%08x\n", Status);
335 goto Failure;
336 }
337
338 IntSetupDeviceSettingsKey(DeviceExtension);
339
340 /* Remove the initializing flag */
341 (*DeviceObject)->Flags &= ~DO_DEVICE_INITIALIZING;
342
343 /* Set up the VIDEO/DEVICEMAP registry keys */
344 Status = IntVideoPortAddDeviceMapLink(DeviceExtension);
345 if (!NT_SUCCESS(Status))
346 {
347 ERR_(VIDEOPRT, "IntVideoPortAddDeviceMapLink() failed with status 0x%08x\n", Status);
348 goto Failure;
349 }
350
351 if (DisplayNumber == 0)
352 {
353 DriverExtension->InitializationData.StartingDeviceNumber++;
354 }
355
356 return STATUS_SUCCESS;
357
358Failure:
359 if (DeviceExtension->NextDeviceObject)
360 IoDetachDevice(DeviceExtension->NextDeviceObject);
363 return Status;
364}
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:80
VIDEO_PORT_DRIVER_EXTENSION * DriverExtension
Definition: videoprt.h:103
INTERFACE_TYPE AdapterInterfaceType
Definition: videoprt.h:98
CHAR POINTER_ALIGNMENT MiniPortDeviceExtension[1]
Definition: videoprt.h:118
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
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
VOID NTAPI IntVideoPortDeferredRoutine(IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: videoprt.c:158
static ULONG VideoPortMaxObjectNumber
Definition: videoprt.c:40
static BOOLEAN IntIsVgaSaveDriver(_In_ PDRIVER_OBJECT DriverObject)
Definition: videoprt.c:53
static NTSTATUS IntVideoPortAddDeviceMapLink(PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: videoprt.c:71
struct _VIDEO_PORT_DEVICE_EXTENSTION * PVIDEO_PORT_DEVICE_EXTENSION
struct _VIDEO_PORT_DEVICE_EXTENSTION VIDEO_PORT_DEVICE_EXTENSION
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3281
_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:603
NTSTATUS NTAPI IntCreateNewRegistryPath(PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: registry.c:408
NTSTATUS NTAPI IntSetupDeviceSettingsKey(PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: registry.c:298
@ 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 1214 of file dispatch.c.

1217{
1218 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1219
1220 DeviceExtension = DeviceObject->DeviceExtension;
1221 RtlFreeUnicodeString(&DeviceExtension->RegistryPath);
1222
1223 Irp->IoStatus.Status = STATUS_SUCCESS;
1224 Irp->IoStatus.Information = 0;
1226
1227 return STATUS_SUCCESS;
1228}
_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 434 of file dispatch.c.

437{
438 TRACE_(VIDEOPRT, "IntVideoPortDispatchClose\n");
439
441
442 Irp->IoStatus.Status = STATUS_SUCCESS;
444 return STATUS_SUCCESS;
445}
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 766 of file dispatch.c.

769{
770 PIO_STACK_LOCATION IrpStack;
773
774 TRACE_(VIDEOPRT, "IntVideoPortDispatchDeviceControl\n");
775
777
778 switch (IrpStack->MajorFunction)
779 {
781 /* This is the main part of this function and is handled below */
782 break;
783
784 case IRP_MJ_SHUTDOWN:
785 {
786 /* Dereference CSRSS */
787 PKPROCESS OldCsrProcess;
788 OldCsrProcess = InterlockedExchangePointer((PVOID*)&CsrProcess, NULL);
789 if (OldCsrProcess)
790 ObDereferenceObject(OldCsrProcess);
791
792 Irp->IoStatus.Status = STATUS_SUCCESS;
794 return STATUS_SUCCESS;
795 }
796
797 default:
798 ERR_(VIDEOPRT, "- Unknown MajorFunction 0x%x\n", IrpStack->MajorFunction);
799 Irp->IoStatus.Status = STATUS_SUCCESS;
801 return STATUS_SUCCESS;
802 }
803
804 IoControlCode = IrpStack->Parameters.DeviceIoControl.IoControlCode;
805
806 INFO_(VIDEOPRT, "- IoControlCode: 0x%x: %s\n", IoControlCode, IoctlName(IoControlCode));
807
808 switch (IoControlCode)
809 {
813 WARN_(VIDEOPRT, "- IOCTL_VIDEO_*_VDM are UNIMPLEMENTED!\n");
815 break;
816
819 WARN_(VIDEOPRT, "- IOCTL_VIDEO_GET/SET_OUTPUT_DEVICE_POWER_STATE are UNIMPLEMENTED!\n");
821 break;
822
825 WARN_(VIDEOPRT, "- IOCTL_VIDEO_GET/SET_POWER_MANAGEMENT are UNIMPLEMENTED!\n");
827 break;
828
832 WARN_(VIDEOPRT, "- IOCTL_VIDEO_*_BRIGHTNESS are UNIMPLEMENTED!\n");
834 break;
835
837 INFO_(VIDEOPRT, "- IOCTL_VIDEO_ENUM_MONITOR_PDO\n");
839 Irp->AssociatedIrp.SystemBuffer,
840 &Irp->IoStatus.Information);
841 break;
842
844 INFO_(VIDEOPRT, "- IOCTL_VIDEO_INIT_WIN32K_CALLBACKS\n");
846 Irp->AssociatedIrp.SystemBuffer,
847 IrpStack->Parameters.DeviceIoControl.InputBufferLength,
848 &Irp->IoStatus.Information);
849 break;
850
852 WARN_(VIDEOPRT, "- IOCTL_VIDEO_IS_VGA_DEVICE is UNIMPLEMENTED!\n");
854 break;
855
857 INFO_(VIDEOPRT, "- IOCTL_VIDEO_USE_DEVICE_IN_SESSION\n");
859 Irp->AssociatedIrp.SystemBuffer,
860 IrpStack->Parameters.DeviceIoControl.InputBufferLength,
861 &Irp->IoStatus.Information);
862 break;
863
865 INFO_(VIDEOPRT, "- IOCTL_VIDEO_PREPARE_FOR_EARECOVERY\n");
866 /*
867 * The Win32k Watchdog Timer detected that a thread spent more time
868 * in a display driver than the allotted time its threshold specified,
869 * and thus is going to attempt to recover by switching to VGA mode.
870 * If this attempt fails, the watchdog generates bugcheck 0xEA
871 * "THREAD_STUCK_IN_DEVICE_DRIVER".
872 *
873 * Prepare the recovery by resetting the display adapters to
874 * standard VGA 80x25 text mode.
875 */
878 break;
879
880 default:
881 /* Forward to the Miniport Driver */
883 break;
884 }
885
886 INFO_(VIDEOPRT, "- Returned status: 0x%x\n", Status);
887
888 Irp->IoStatus.Status = Status;
890 return Status;
891}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
#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::@1672::@1673 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
static NTSTATUS VideoPortEnumMonitorPdo(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PVIDEO_MONITOR_DEVICE *ppMonitorDevices, _Out_ PULONG_PTR Information)
Definition: dispatch.c:625
PSTR IoctlName(ULONG Ioctl)
Definition: dispatch.c:448
static NTSTATUS VideoPortForwardDeviceControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:699
static NTSTATUS VideoPortUseDeviceInSession(_Inout_ PDEVICE_OBJECT DeviceObject, _Inout_ PVIDEO_DEVICE_SESSION_STATUS SessionState, _In_ ULONG BufferLength, _Out_ PULONG_PTR Information)
Definition: dispatch.c:567
static NTSTATUS VideoPortInitWin32kCallbacks(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PVIDEO_WIN32K_CALLBACKS Win32kCallbacks, _In_ ULONG BufferLength, _Out_ PULONG_PTR Information)
Definition: dispatch.c:670
#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 /* We know the first open call is from the CSRSS process.
382 * Get a reference to it for Int10 support. */
383 INFO_(VIDEOPRT, "Referencing CSRSS\n");
386 INFO_(VIDEOPRT, "CsrProcess 0x%p\n", CsrProcess);
387
389 if (!NT_SUCCESS(Status))
390 {
391 ERR_(VIDEOPRT, "IntInitializeInt10(CSR) failed: 0x%lx\n", Status);
394 return Status;
395 }
396 }
397
398 DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
399 DriverExtension = DeviceExtension->DriverExtension;
400
401 // FIXME: (Re-)initialize INBV only if DeviceObject doesn't belong to a mirror driver.
403
404 if (DriverExtension->InitializationData.HwInitialize(&DeviceExtension->MiniPortDeviceExtension))
405 {
407 InterlockedIncrement((PLONG)&DeviceExtension->DeviceOpened);
408
409 /* Query children, now that device is opened */
411 }
412 else
413 {
415 }
416
417 Irp->IoStatus.Status = Status;
418 Irp->IoStatus.Information = FILE_OPENED;
420
421 return Status;
422}
#define InterlockedIncrement
Definition: armddk.h:53
NTSTATUS IntInitializeInt10(VOID)
Definition: int10.c:766
#define FILE_OPENED
Definition: nt_native.h:769
VPAPI VP_STATUS NTAPI VideoPortEnumerateChildren(IN PVOID HwDeviceExtension, IN PVOID Reserved)
Definition: videoprt.c:1653
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 404 of file child.c.

407{
409 NTSTATUS Status = Irp->IoStatus.Status;
410
412
413 switch (IrpSp->MinorFunction)
414 {
417 /* Nothing to do */
419 break;
420
423 /* None (keep old status) */
424 break;
425
426 case IRP_MN_QUERY_ID:
427 /* Call our helper */
429 Irp,
430 IrpSp);
431 break;
432
434 /* Call our helper */
436 Irp,
437 IrpSp);
438 break;
439
443 break;
444
446 Irp->IoStatus.Status = STATUS_SUCCESS;
449 return STATUS_SUCCESS;
450
452 /* Call our helper */
454 Irp,
455 IrpSp);
456 break;
457
459 /* Call our helper */
461 Irp,
462 IrpSp);
463 break;
464
465 default:
466 break;
467 }
468
469 Irp->IoStatus.Status = Status;
470
472
473 return Status;
474}
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:310
NTSTATUS NTAPI IntVideoPortChildQueryCapabilities(IN PVIDEO_PORT_CHILD_EXTENSION ChildExtension, IN PIRP Irp, IN PIO_STACK_LOCATION IrpSp)
Definition: child.c:337
NTSTATUS NTAPI IntVideoPortChildQueryText(IN PVIDEO_PORT_CHILD_EXTENSION ChildExtension, IN PIRP Irp, IN PIO_STACK_LOCATION IrpSp)
Definition: child.c:260
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4138
#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 1200 of file dispatch.c.

1203{
1204 PVIDEO_PORT_COMMON_EXTENSION CommonExtension = DeviceObject->DeviceExtension;
1205
1206 if (CommonExtension->Fdo)
1208 else
1210}
NTSTATUS NTAPI IntVideoPortDispatchPdoPnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: child.c:404
NTSTATUS NTAPI IntVideoPortDispatchFdoPnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:1077

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchPower()

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

Definition at line 1232 of file dispatch.c.

1235{
1237 NTSTATUS Status = Irp->IoStatus.Status;
1238 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
1239
1241
1242 if (DeviceExtension->Common.Fdo)
1243 {
1246 return PoCallDriver(DeviceExtension->NextDeviceObject, Irp);
1247 }
1248 else
1249 {
1250 switch (IrpSp->MinorFunction)
1251 {
1252 case IRP_MN_QUERY_POWER:
1253 case IRP_MN_SET_POWER:
1255 break;
1256 }
1258 Irp->IoStatus.Status = Status;
1260 return Status;
1261 }
1262}
#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 1266 of file dispatch.c.

1269{
1271 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
1272
1273 if (DeviceExtension->Common.Fdo)
1274 {
1276 return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
1277 }
1278 else
1279 {
1280 Status = Irp->IoStatus.Status;
1282 return Status;
1283 }
1284}
#define IoCallDriver
Definition: irp.c:1225

Referenced by VideoPortInitialize().

◆ IntVideoPortEnumerateChildren()

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

Definition at line 1489 of file videoprt.c.

1492{
1493 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1494 ULONG Status;
1495 VIDEO_CHILD_ENUM_INFO ChildEnumInfo;
1496 BOOLEAN bHaveLastMonitorID = FALSE;
1497 UCHAR LastMonitorID[10];
1498 ULONG Uid, Unused;
1499 UINT i;
1500 PDEVICE_OBJECT ChildDeviceObject;
1501 PVIDEO_PORT_CHILD_EXTENSION ChildExtension;
1502
1503 INFO_(VIDEOPRT, "Starting child device probe\n");
1504 DeviceExtension = DeviceObject->DeviceExtension;
1506 {
1507 WARN_(VIDEOPRT, "Miniport's HwGetVideoChildDescriptor is NULL!\n");
1508 return STATUS_SUCCESS;
1509 }
1510
1511 if (!IsListEmpty(&DeviceExtension->ChildDeviceList))
1512 {
1513 ERR_(VIDEOPRT, "FIXME: Support calling VideoPortEnumerateChildren again!\n");
1514 return STATUS_SUCCESS;
1515 }
1516
1517 /* Enumerate the children */
1518 for (i = 1; ; i++)
1519 {
1520 Status = IoCreateDevice(DeviceExtension->DriverObject,
1523 NULL,
1526 FALSE,
1527 &ChildDeviceObject);
1528 if (!NT_SUCCESS(Status))
1529 return Status;
1530
1531 ChildExtension = ChildDeviceObject->DeviceExtension;
1532
1533 RtlZeroMemory(ChildExtension,
1536
1537 ChildExtension->Common.Fdo = FALSE;
1538 ChildExtension->ChildId = i;
1539 ChildExtension->PhysicalDeviceObject = ChildDeviceObject;
1540 ChildExtension->DriverObject = DeviceExtension->DriverObject;
1541
1542 /* Setup the ChildEnumInfo */
1543 ChildEnumInfo.Size = sizeof(ChildEnumInfo);
1544 ChildEnumInfo.ChildDescriptorSize = sizeof(ChildExtension->ChildDescriptor);
1545 ChildEnumInfo.ACPIHwId = 0;
1546
1548 ChildEnumInfo.ChildHwDeviceExtension = VIDEO_PORT_GET_CHILD_EXTENSION(ChildExtension);
1549 else
1550 ChildEnumInfo.ChildHwDeviceExtension = NULL;
1551
1552 ChildEnumInfo.ChildIndex = ChildExtension->ChildId;
1553
1554 INFO_(VIDEOPRT, "Probing child: %d\n", ChildEnumInfo.ChildIndex);
1556 DeviceExtension->MiniPortDeviceExtension,
1557 &ChildEnumInfo,
1558 &ChildExtension->ChildType,
1559 ChildExtension->ChildDescriptor,
1560 &Uid,
1561 &Unused);
1563 {
1564 if (ChildExtension->ChildType == Monitor)
1565 {
1566 // Check if the EDID is valid
1567 if (ChildExtension->ChildDescriptor[0] == 0x00 &&
1568 ChildExtension->ChildDescriptor[1] == 0xFF &&
1569 ChildExtension->ChildDescriptor[2] == 0xFF &&
1570 ChildExtension->ChildDescriptor[3] == 0xFF &&
1571 ChildExtension->ChildDescriptor[4] == 0xFF &&
1572 ChildExtension->ChildDescriptor[5] == 0xFF &&
1573 ChildExtension->ChildDescriptor[6] == 0xFF &&
1574 ChildExtension->ChildDescriptor[7] == 0x00)
1575 {
1576 if (bHaveLastMonitorID)
1577 {
1578 // Compare the previous monitor ID with the current one, break the loop if they are identical
1579 if (RtlCompareMemory(LastMonitorID, &ChildExtension->ChildDescriptor[8], sizeof(LastMonitorID)) == sizeof(LastMonitorID))
1580 {
1581 INFO_(VIDEOPRT, "Found identical Monitor ID two times, stopping enumeration\n");
1582 IoDeleteDevice(ChildDeviceObject);
1583 break;
1584 }
1585 }
1586
1587 // Copy 10 bytes from the EDID, which can be used to uniquely identify the monitor
1588 RtlCopyMemory(LastMonitorID, &ChildExtension->ChildDescriptor[8], sizeof(LastMonitorID));
1589 bHaveLastMonitorID = TRUE;
1590
1591 /* Mark it valid */
1592 ChildExtension->EdidValid = TRUE;
1593 }
1594 else
1595 {
1596 /* Mark it invalid */
1597 ChildExtension->EdidValid = FALSE;
1598 }
1599 }
1600 }
1602 {
1603 WARN_(VIDEOPRT, "Child device %d is invalid!\n", ChildEnumInfo.ChildIndex);
1604 IoDeleteDevice(ChildDeviceObject);
1605 continue;
1606 }
1608 {
1609 INFO_(VIDEOPRT, "End of child enumeration! (%d children enumerated)\n", i - 1);
1610 IoDeleteDevice(ChildDeviceObject);
1611 break;
1612 }
1613 else
1614 {
1615 WARN_(VIDEOPRT, "HwGetVideoChildDescriptor returned unknown status code 0x%x!\n", Status);
1616 IoDeleteDevice(ChildDeviceObject);
1617 break;
1618 }
1619
1620 if (ChildExtension->ChildType == Monitor)
1621 {
1622 UINT j;
1623 PUCHAR p = ChildExtension->ChildDescriptor;
1624 INFO_(VIDEOPRT, "Monitor device enumerated! (ChildId = 0x%x)\n", ChildExtension->ChildId);
1625 for (j = 0; j < sizeof (ChildExtension->ChildDescriptor); j += 8)
1626 {
1627 INFO_(VIDEOPRT, "%02x %02x %02x %02x %02x %02x %02x %02x\n",
1628 p[j + 0], p[j + 1], p[j + 2], p[j + 3],
1629 p[j + 4], p[j + 5], p[j + 6], p[j + 7]);
1630 }
1631 }
1632 else if (ChildExtension->ChildType == Other)
1633 {
1634 INFO_(VIDEOPRT, "\"Other\" device enumerated: DeviceId = %S\n", (PWSTR)ChildExtension->ChildDescriptor);
1635 }
1636 else
1637 {
1638 ERR_(VIDEOPRT, "HwGetVideoChildDescriptor returned unsupported type: %d\n", ChildExtension->ChildType);
1639 }
1640
1641 /* Clear the init flag */
1642 ChildDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
1643
1644 InsertTailList(&DeviceExtension->ChildDeviceList,
1645 &ChildExtension->ListEntry);
1646 }
1647
1648 return STATUS_SUCCESS;
1649}
#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:49
#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:132
VIDEO_CHILD_TYPE ChildType
Definition: videoprt.h:126
PDRIVER_OBJECT DriverObject
Definition: videoprt.h:131
VIDEO_PORT_COMMON_EXTENSION Common
Definition: videoprt.h:123
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:139

Referenced by IntVideoPortQueryBusRelations().

◆ IntVideoPortFilterResourceRequirements()

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

Definition at line 81 of file resource.c.

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

Referenced by IntVideoPortDispatchFdoPnp().

◆ IntVideoPortFindAdapter()

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

Definition at line 434 of file videoprt.c.

438{
439 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
441 VP_STATUS vpStatus;
442 VIDEO_PORT_CONFIG_INFO ConfigInfo;
444 UCHAR Again = FALSE;
445 BOOL LegacyDetection = FALSE;
446 BOOLEAN VgaResourcesReleased = FALSE;
447
448 DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
449 DeviceExtension->IsVgaDetect = DeviceExtension->IsVgaDriver;
450 DeviceExtension->IsLegacyDetect = FALSE;
451 DeviceExtension->ReportDevice = FALSE;
452
453 /* Setup a ConfigInfo structure that we will pass to HwFindAdapter */
454 RtlZeroMemory(&ConfigInfo, sizeof(VIDEO_PORT_CONFIG_INFO));
455 ConfigInfo.Length = sizeof(VIDEO_PORT_CONFIG_INFO);
456 ConfigInfo.AdapterInterfaceType = DeviceExtension->AdapterInterfaceType;
457 if (ConfigInfo.AdapterInterfaceType == PCIBus)
458 ConfigInfo.InterruptMode = LevelSensitive;
459 else
460 ConfigInfo.InterruptMode = Latched;
461 ConfigInfo.DriverRegistryPath = DriverExtension->RegistryPath.Buffer;
463 ConfigInfo.SystemIoBusNumber = DeviceExtension->SystemIoBusNumber;
464 ConfigInfo.BusInterruptLevel = DeviceExtension->InterruptLevel;
465 ConfigInfo.BusInterruptVector = DeviceExtension->InterruptVector;
466
469 sizeof(SystemBasicInfo),
470 NULL);
471 if (NT_SUCCESS(Status))
472 {
475 }
476
477 // FIXME: Check the adapter key and update VideoDebugLevel variable.
478
479 /*
480 * Call miniport HwVidFindAdapter entry point to detect if
481 * particular device is present. There are two possible code
482 * paths. The first one is for Legacy drivers (NT4) and cases
483 * when we don't have information about what bus we're on. The
484 * second case is the standard one for Plug & Play drivers.
485 */
486 if (DeviceExtension->PhysicalDeviceObject == NULL)
487 {
488 LegacyDetection = TRUE;
489 DeviceExtension->IsLegacyDevice = TRUE;
490 DeviceExtension->IsLegacyDetect = TRUE;
491 }
492 else
493 {
494 DeviceExtension->IsLegacyDevice = FALSE;
495 }
496
497 /* If we already have a VGA miniport and are about to probe for additional adapters,
498 * release its resources temporarily so conflicts are visible during detection.
499 * We'll reclaim them later if no new adapter successfully claims them. */
502 {
503 INFO_(VIDEOPRT, "Temporarily releasing VGA resources for adapter probing\n");
505 VgaResourcesReleased = TRUE;
506 }
508
509 if (LegacyDetection)
510 {
512
513 /* Suppose first we may not find any suitable device */
514 vpStatus = ERROR_DEV_NOT_EXIST; // ERROR_NO_MORE_DEVICES;
515
516 /* Enumerate all buses of the given type, call HwFindAdapter for each
517 * to find whether a video adapter is recognized there. Stop when an
518 * adapter has been found. */
519 for (BusNumber = 0;
520 (BusNumber < MAXULONG) &&
522 &BusNumber));
523 ++BusNumber)
524 {
525 DPRINT("Bus Type %lu, Number %lu\n",
526 DeviceExtension->AdapterInterfaceType, BusNumber);
527
528 DeviceExtension->SystemIoBusNumber =
529 ConfigInfo.SystemIoBusNumber = BusNumber;
530
531 RtlZeroMemory(&DeviceExtension->MiniPortDeviceExtension,
532 DriverExtension->InitializationData.HwDeviceExtensionSize);
533
534 /* FIXME: Need to figure out what string to pass as param 3. */
535 // FIXME: Handle the 'Again' parameter for legacy detection.
536 vpStatus = DriverExtension->InitializationData.HwFindAdapter(
537 &DeviceExtension->MiniPortDeviceExtension,
538 DriverExtension->HwContext,
539 NULL,
540 &ConfigInfo,
541 &Again);
542
543 if (vpStatus == ERROR_DEV_NOT_EXIST)
544 {
545 continue;
546 }
547 else
548 {
549 break;
550 }
551 }
552 }
553 else
554 {
555 /* FIXME: Need to figure out what string to pass as param 3. */
556 vpStatus = DriverExtension->InitializationData.HwFindAdapter(
557 &DeviceExtension->MiniPortDeviceExtension,
558 DriverExtension->HwContext,
559 NULL,
560 &ConfigInfo,
561 &Again);
562 }
563
564 if (vpStatus != NO_ERROR)
565 {
566 ERR_(VIDEOPRT, "HwFindAdapter failed (vpStatus=0x%X) bus=%u iface=%u legacy=%u vga=%u detect(VGA=%u LEGACY=%u)\n",
567 vpStatus,
568 DeviceExtension->SystemIoBusNumber,
569 DeviceExtension->AdapterInterfaceType,
570 DeviceExtension->IsLegacyDevice,
571 DeviceExtension->IsVgaDriver,
572 DeviceExtension->IsVgaDetect,
573 DeviceExtension->IsLegacyDetect);
574 /* If we released VGA resources, reclaim them so VGA fallback still works */
575 if (VgaResourcesReleased)
576 {
578 {
579 INFO_(VIDEOPRT, "Reclaiming VGA resources after failed probe\n");
583 {
584 WARN_(VIDEOPRT, "Failed to reclaim VGA resources after probe failure\n");
585 }
586 }
587 }
589 goto Failure;
590 }
591
592 /*
593 * Now we know the device is present, so let's do all additional tasks
594 * such as creating symlinks or setting up interrupts and timer.
595 */
596
597 /* FIXME: Allocate hardware resources for device. */
598
599 /* Allocate interrupt for device. */
601 {
603 goto Failure;
604 }
605
606 /* Allocate timer for device. */
608 {
609 if (DeviceExtension->InterruptObject != NULL)
610 IoDisconnectInterrupt(DeviceExtension->InterruptObject);
611 ERR_(VIDEOPRT, "IntVideoPortSetupTimer failed\n");
613 goto Failure;
614 }
615
616 /* If the device can be reset, insert it in the list of resettable adapters */
617 InitializeListHead(&DeviceExtension->HwResetListEntry);
618 if (DriverExtension->InitializationData.HwResetHw != NULL)
619 {
621 &DeviceExtension->HwResetListEntry,
623 }
624
625 if (DeviceExtension->IsVgaDriver)
626 {
629 {
630 VgaDeviceExtension = DeviceExtension;
631 }
633 }
634
635 DeviceExtension->IsVgaDetect = FALSE;
636 DeviceExtension->IsLegacyDetect = FALSE;
637
638 /* For legacy (non-PnP) adapters we should report a detected device so that
639 * a PDO exists for higher layers to enumerate consistently (mirrors ScsiPort).*/
640 if (DeviceExtension->IsLegacyDevice && !DeviceExtension->ReportDevice)
641 {
642 PDEVICE_OBJECT ReportedPdo = NULL;
644 DeviceExtension->AdapterInterfaceType,
645 DeviceExtension->SystemIoBusNumber,
646 DeviceExtension->SystemIoSlotNumber,
647 NULL,
648 NULL,
649 FALSE,
650 &ReportedPdo);
651 if (!NT_SUCCESS(repStatus))
652 {
653 WARN_(VIDEOPRT, "IoReportDetectedDevice failed 0x%08lx (bus=%u slot=%u)\n",
654 repStatus,
655 DeviceExtension->SystemIoBusNumber,
656 DeviceExtension->SystemIoSlotNumber);
657 }
658 else
659 {
660 INFO_(VIDEOPRT, "Reported legacy adapter PDO %p (bus=%u slot=%u)\n",
661 ReportedPdo,
662 DeviceExtension->SystemIoBusNumber,
663 DeviceExtension->SystemIoSlotNumber);
664 DeviceExtension->ReportDevice = TRUE;
665 }
666 }
667
668 /* Attempt to reclaim VGA resources after probing if a VGA device exists */
670 {
671 VP_STATUS vr;
672 INFO_(VIDEOPRT, "Attempt VGA reclaim after probe (ranges=%lu)\n", NumOfVgaRanges);
675 VgaRanges);
676 if (vr != NO_ERROR)
677 {
678 /* Another driver has taken VGA resources; drop fallback state */
679 WARN_(VIDEOPRT, "VGA reclaim failed (vpStatus=0x%X); releasing fallback state\n", vr);
682 VgaRanges = NULL;
683 NumOfVgaRanges = 0;
686
687 }
688 else
689 {
690 INFO_(VIDEOPRT, "VGA reclaim succeeded\n");
691 }
692 }
693
694 INFO_(VIDEOPRT, "STATUS_SUCCESS\n");
695 return STATUS_SUCCESS;
696
697Failure:
698 RtlFreeUnicodeString(&DeviceExtension->RegistryPath);
699 if (DeviceExtension->NextDeviceObject)
700 IoDetachDevice(DeviceExtension->NextDeviceObject);
701
702 /* Explicitly reclaim VGA resources on complete failure */
703 if (VgaResourcesReleased)
704 {
706 {
707 INFO_(VIDEOPRT, "Final reclaim attempt of VGA resources during failure cleanup\n");
711 {
712 WARN_(VIDEOPRT, "VGA reclaim failed during failure cleanup\n");
713 }
714 }
715 }
717 return Status;
718}
#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:106
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:142
LONG NTAPI KeReleaseMutex(IN PKMUTEX Mutex, IN BOOLEAN Wait)
Definition: mutex.c:189
SYSTEM_BASIC_INFORMATION SystemBasicInfo
Definition: perfdata.c:30
NTSTATUS NTAPI IoReportDetectedDevice(_In_ PDRIVER_OBJECT DriverObject, _In_ INTERFACE_TYPE LegacyBusType, _In_ ULONG BusNumber, _In_ ULONG SlotNumber, _In_opt_ PCM_RESOURCE_LIST ResourceList, _In_opt_ PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements, _In_ BOOLEAN ResourceAssigned, _Inout_ PDEVICE_OBJECT *DeviceObject)
Definition: pnpreport.c:148
@ PCIBus
Definition: restypes.h:126
@ Latched
Definition: miniport.h:81
@ LevelSensitive
Definition: miniport.h:80
VPAPI VP_STATUS NTAPI VideoPortVerifyAccessRanges(_In_ PVOID HwDeviceExtension, _In_opt_ ULONG NumAccessRanges, _In_reads_opt_(NumAccessRanges) PVIDEO_ACCESS_RANGE AccessRanges)
Claims or releases a range of hardware resources and checks for conflicts.
Definition: resource.c:976
struct _VIDEO_PORT_CONFIG_INFO VIDEO_PORT_CONFIG_INFO
#define DPRINT
Definition: sndvol32.h:73
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
ULONG NumOfVgaRanges
Definition: videoprt.c:48
PVIDEO_PORT_DEVICE_EXTENSION VgaDeviceExtension
Definition: videoprt.c:46
KMUTEX VgaSyncLock
Definition: videoprt.c:45
static NTSTATUS IntVideoPortEnumBuses(_In_ INTERFACE_TYPE AdapterInterfaceType, _Inout_ PULONG BusNumber)
Enumerates all supported buses on the system.
Definition: videoprt.c:407
KSPIN_LOCK HwResetAdaptersLock
Definition: videoprt.c:43
PVIDEO_ACCESS_RANGE VgaRanges
Definition: videoprt.c:47
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
VOID IntVideoPortReleaseResources(_In_ PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: resource.c:198
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
#define KeWaitForMutexObject
Definition: kefuncs.h:543
@ Executive
Definition: ketypes.h:467

Referenced by IntVideoPortPnPStartDevice(), and VideoPortInitialize().

◆ IntVideoPortGetProcAddress()

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

Definition at line 106 of file funclist.c.

109{
110 ULONG i;
111
112 TRACE_(VIDEOPRT, "VideoPortGetProcAddress(%s)\n", FunctionName);
113
114 /* Search by name */
115 for (i = 0; i < ARRAYSIZE(VideoPortExports); i++)
116 {
118 return VideoPortExports[i].Address;
119 }
120
121 ERR_(VIDEOPRT, "VideoPortGetProcAddress: Can't resolve symbol %s\n", FunctionName);
122 return NULL;
123}
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
LPWSTR Name
Definition: desk.c:124
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3319
const VIDEO_PORT_FUNCTION_TABLE VideoPortExports[]
Definition: funclist.c:37
static WCHAR Address[46]
Definition: ping.c:68
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 244 of file resource.c.

250{
251 OBJECT_ATTRIBUTES ObjAttribs;
253 HANDLE hMemObj;
255 SIZE_T Size;
256
257 /* Initialize object attribs */
258 RtlInitUnicodeString(&UnicodeString, L"\\Device\\PhysicalMemory");
259 InitializeObjectAttributes(&ObjAttribs,
262 NULL, NULL);
263
264 /* Open physical memory section */
265 Status = ZwOpenSection(&hMemObj, SECTION_ALL_ACCESS, &ObjAttribs);
266 if (!NT_SUCCESS(Status))
267 {
268 WARN_(VIDEOPRT, "ZwOpenSection() failed! (0x%x)\n", Status);
269 return Status;
270 }
271
272 /* Map view of section */
273 Size = SizeInBytes;
274 Status = ZwMapViewOfSection(hMemObj,
275 Process,
277 0,
278 Size,
280 &Size,
281 ViewUnmap,
282 0,
283 Protect);
284 ZwClose(hMemObj);
285 if (!NT_SUCCESS(Status))
286 {
287 WARN_(VIDEOPRT, "ZwMapViewOfSection() failed! (0x%x)\n", Status);
288 }
289
290 return Status;
291}
_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:1296
@ ViewUnmap
Definition: nt_native.h:1282
ULONG_PTR SIZE_T
Definition: typedefs.h:80
_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 198 of file resource.c.

200{
202 BOOLEAN ConflictDetected;
203 // An empty CM_RESOURCE_LIST
204 UCHAR EmptyResourceList[FIELD_OFFSET(CM_RESOURCE_LIST, List)] = {0};
205
206 if (DeviceExtension->IsLegacyDevice || DeviceExtension->IsLegacyDetect || DeviceExtension->IsVgaDetect)
207 {
209 DeviceExtension->DriverObject,
210 NULL, 0, /* Driver List */
211 DeviceExtension->PhysicalDeviceObject,
212 (PCM_RESOURCE_LIST)EmptyResourceList,
213 sizeof(EmptyResourceList),
214 &ConflictDetected);
215
216 if (!NT_SUCCESS(Status))
217 {
218 ERR_(VIDEOPRT,
219 "VideoPortReleaseResources (Detect) failed with 0x%08lx ; ConflictDetected: %s\n",
220 Status, ConflictDetected ? "TRUE" : "FALSE");
221 }
222 }
223 else
224 {
226 DeviceExtension->DriverObject,
227 NULL,
228 0,
229 DeviceExtension->PhysicalDeviceObject,
230 (PCM_RESOURCE_LIST)EmptyResourceList,
231 sizeof(EmptyResourceList),
232 FALSE,
233 &ConflictDetected);
234 if (!NT_SUCCESS(Status))
235 {
236 ERR_(VIDEOPRT,
237 "VideoPortReleaseResources (Usage) failed with 0x%08lx ; ConflictDetected: %s\n",
238 Status, ConflictDetected ? "TRUE" : "FALSE");
239 }
240 }
241}
NTSTATUS NTAPI IoReportResourceUsage(_In_opt_ PUNICODE_STRING DriverClassName, _In_ PDRIVER_OBJECT DriverObject, _In_reads_bytes_opt_(DriverListSize) PCM_RESOURCE_LIST DriverList, _In_opt_ ULONG DriverListSize, _In_opt_ PDEVICE_OBJECT DeviceObject, _In_reads_bytes_opt_(DeviceListSize) PCM_RESOURCE_LIST DeviceList, _In_opt_ ULONG DeviceListSize, _In_ BOOLEAN OverrideConflict, _Out_ PBOOLEAN ConflictDetected)
Reports hardware resources in the \Registry\Machine\Hardware\ResourceMap tree, so that a subsequently...
Definition: iorsrce.c:1041
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
static UNICODE_STRING VideoClassName
Definition: resource.c:29

Referenced by IntVideoPortFindAdapter(), and 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:23
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 1288 of file dispatch.c.

1289{
1290}

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: telnetd.h:14
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
_In_ UCHAR _In_ UCHAR MinorFunction
Definition: wdfdevice.h:1705
_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

◆ NumOfVgaRanges

ULONG NumOfVgaRanges
extern

Definition at line 48 of file videoprt.c.

Referenced by IntVideoPortFindAdapter(), and VideoPortVerifyAccessRanges().

◆ VgaDeviceExtension

PVIDEO_PORT_DEVICE_EXTENSION VgaDeviceExtension
extern

Definition at line 46 of file videoprt.c.

Referenced by IntVideoPortFindAdapter(), VbeSetMode(), and VideoPortVerifyAccessRanges().

◆ VgaRanges

PVIDEO_ACCESS_RANGE VgaRanges
extern

Definition at line 47 of file videoprt.c.

Referenced by IntVideoPortFindAdapter(), and VideoPortVerifyAccessRanges().

◆ VgaSyncLock

KMUTEX VgaSyncLock
extern

◆ VideoPortDeviceNumber

ULONG VideoPortDeviceNumber
extern

◆ VideoPortInt10Mutex

KMUTEX VideoPortInt10Mutex
extern

Definition at line 41 of file int10.c.

Referenced by IntInt10CallBiosEmu(), and VideoPortInitialize().

◆ VideoPortUseNewKey

BOOLEAN VideoPortUseNewKey
extern