ReactOS 0.4.16-dev-2208-g6350669
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
struct _IO_STACK_LOCATION::@4301::@4327 QueryInterface
union _IO_STACK_LOCATION::@1710 Parameters
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 728 of file videoprt.c.

731{
732 if (!CsrProcess)
733 return FALSE;
734
735 *CallingProcess = (PKPROCESS)PsGetCurrentProcess();
736 if (*CallingProcess != CsrProcess)
738 return TRUE;
739}
#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 OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define KernelMode
Definition: asm.h: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 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 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
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
NTSYSAPI NTSTATUS WINAPI RtlCheckRegistryKey(ULONG, PWSTR)
#define REG_SZ
Definition: layer.c:22
NTKERNELAPI NTSTATUS ExUuidCreate(OUT UUID *Uuid)
Definition: uuid.c:380
#define min(a, b)
Definition: monoChain.cc:55
NTSYSAPI NTSTATUS NTAPI RtlCreateRegistryKey(_In_ ULONG RelativeTo, _In_ PWSTR Path)
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
#define KEY_ALL_ACCESS
Definition: nt_native.h: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 RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint16_t * PWCHAR
Definition: typedefs.h:56
#define TAG_VIDEO_PORT
Definition: videoprt.h:38
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3782
NTSTATUS IntDuplicateUnicodeString(IN ULONG Flags, IN PCUNICODE_STRING SourceString, OUT PUNICODE_STRING DestinationString)
Definition: registry.c:361
#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
_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 755 of file videoprt.c.

758{
760 if (CallingProcess != CsrProcess)
762}
VOID NTAPI KeUnstackDetachProcess(IN PRKAPC_STATE ApcState)
Definition: procobj.c:756

Referenced by VideoPortGetRomImage().

◆ IntInitializeInt10()

NTSTATUS IntInitializeInt10 ( VOID  )

Definition at line 737 of file int10.c.

738{
739#ifdef _M_IX86
740 /* We should only do that for CSRSS */
742
743 /* Initialize the x86 emulator if necessary, otherwise fall back to V86 mode */
744 if (!VideoPortDisableX86Emulator)
745 {
746 /* Use the emulation routines */
747 //Int10Vtbl = &Int10IFace[0];
749 return STATUS_SUCCESS;
750 DPRINT1("Could not initialize the x86 emulator; falling back to V86 mode\n");
751 VideoPortDisableX86Emulator = TRUE;
752 }
753
754 /* Fall back to the V86 routines */
755 Int10Vtbl = &Int10IFace[1];
756 return IntInitializeVideoAddressSpace();
757#else
758 /* Initialize the x86 emulator */
760#endif
761}
#define DPRINT1
Definition: precomp.h:8
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
static BOOLEAN IntInitializeX86Emu(VOID)
Definition: int10.c:84

Referenced by IntVideoPortDispatchOpen().

◆ IntInt10AllocateBuffer()

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

Definition at line 370 of file int10.c.

375{
377
378 TRACE_(VIDEOPRT, "IntInt10AllocateBuffer\n");
379
380 Status = INT10(AllocateBuffer)(Context, Seg, Off, Length);
381 if (Status == NO_ERROR)
382 {
383 INFO_(VIDEOPRT, "- Segment: 0x%x\n", *Seg);
384 INFO_(VIDEOPRT, "- Offset : 0x%x\n", *Off);
385 INFO_(VIDEOPRT, "- Length : 0x%x\n", *Length);
386 }
387 return Status;
388}
#define NO_ERROR
Definition: dderror.h:5
#define TRACE_(x)
Definition: compat.h:76
#define INT10(func)
Definition: int10.c:290
LONG VP_STATUS
Definition: video.h:153

Referenced by VideoPortQueryServices().

◆ IntInt10CallBios()

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

Definition at line 708 of file int10.c.

711{
712 return INT10(CallBios)(Context, BiosArguments);
713}

Referenced by VideoPortInt10(), and VideoPortQueryServices().

◆ IntInt10FreeBuffer()

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

Definition at line 439 of file int10.c.

443{
444 TRACE_(VIDEOPRT, "IntInt10FreeBuffer\n");
445 INFO_(VIDEOPRT, "- Segment: 0x%x\n", Seg);
446 INFO_(VIDEOPRT, "- Offset : 0x%x\n", Off);
447
448 return INT10(FreeBuffer)(Context, Seg, Off);
449}

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

508{
509 TRACE_(VIDEOPRT, "IntInt10ReadMemory\n");
510 INFO_(VIDEOPRT, "- Segment: 0x%x\n", Seg);
511 INFO_(VIDEOPRT, "- Offset : 0x%x\n", Off);
512 INFO_(VIDEOPRT, "- Buffer : 0x%x\n", Buffer);
513 INFO_(VIDEOPRT, "- Length : 0x%x\n", Length);
514
515 return INT10(ReadMemory)(Context, Seg, Off, Buffer, Length);
516}
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 569 of file int10.c.

575{
576 TRACE_(VIDEOPRT, "IntInt10WriteMemory\n");
577 INFO_(VIDEOPRT, "- Segment: 0x%x\n", Seg);
578 INFO_(VIDEOPRT, "- Offset : 0x%x\n", Off);
579 INFO_(VIDEOPRT, "- Buffer : 0x%x\n", Buffer);
580 INFO_(VIDEOPRT, "- Length : 0x%x\n", Length);
581
582 return INT10(WriteMemory)(Context, Seg, Off, Buffer, Length);
583}
_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:170
_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 170 of file videoprt.c.

177{
178 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
180 ULONG PciSlotNumber;
182 ULONG Size;
184 WCHAR DeviceBuffer[20];
186 PDEVICE_OBJECT DeviceObject_;
187
188 if (DeviceObject == NULL)
189 DeviceObject = &DeviceObject_;
190
191 /*
192 * Find the first free device number that can be used for video device
193 * object names and symlinks.
194 */
196 if (DeviceNumber == (ULONG)-1)
197 {
198 WARN_(VIDEOPRT, "Can't find free device number\n");
199 return STATUS_UNSUCCESSFUL;
200 }
201
202 /*
203 * Create the device object.
204 */
205
206 /* Create a unicode device name. */
207 swprintf(DeviceBuffer, L"\\Device\\Video%lu", DeviceNumber);
208 RtlInitUnicodeString(&DeviceName, DeviceBuffer);
209
210 INFO_(VIDEOPRT, "HwDeviceExtension size is: 0x%x\n",
211 DriverExtension->InitializationData.HwDeviceExtensionSize);
212
213 /* Create the device object. */
215 DriverExtension->InitializationData.HwDeviceExtensionSize;
217 Size,
218 &DeviceName,
220 0,
221 TRUE,
223
224 if (!NT_SUCCESS(Status))
225 {
226 WARN_(VIDEOPRT, "IoCreateDevice call failed with status 0x%08x\n", Status);
227 return Status;
228 }
229
230 /*
231 * Set the buffering strategy here. If you change this, remember
232 * to change VidDispatchDeviceControl too.
233 */
234
235 (*DeviceObject)->Flags |= DO_BUFFERED_IO;
236
237 /* Initialize device extension. */
238 DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)((*DeviceObject)->DeviceExtension);
239 DeviceExtension->Common.Fdo = TRUE;
240 DeviceExtension->DeviceNumber = DeviceNumber;
241 DeviceExtension->DriverObject = DriverObject;
243 DeviceExtension->FunctionalDeviceObject = *DeviceObject;
244 DeviceExtension->DriverExtension = DriverExtension;
245 DeviceExtension->SessionId = -1;
246 DeviceExtension->AdapterNumber = AdapterNumber;
247 DeviceExtension->DisplayNumber = DisplayNumber;
248
249 InitializeListHead(&DeviceExtension->ChildDeviceList);
250
251 /* Get the registry path associated with this device. */
253 DeviceExtension->AdapterNumber,
254 &DeviceExtension->RegistryPath);
255 if (!NT_SUCCESS(Status))
256 {
257 WARN_(VIDEOPRT, "IntCreateRegistryPath() call failed with status 0x%08x\n", Status);
258 goto Failure;
259 }
260
262 {
263 /* Get bus number from the upper level bus driver. */
264 Size = sizeof(ULONG);
267 Size,
268 &DeviceExtension->SystemIoBusNumber,
269 &Size);
270 if (!NT_SUCCESS(Status))
271 {
272 WARN_(VIDEOPRT, "Couldn't get an information from bus driver. We will try to\n"
273 "use legacy detection method, but even that doesn't mean that\n"
274 "it will work.\n");
275 DeviceExtension->PhysicalDeviceObject = NULL;
276 }
277 }
278
279 DeviceExtension->AdapterInterfaceType =
280 DriverExtension->InitializationData.AdapterInterfaceType;
281
283 {
284 /* Get bus type from the upper level bus driver. */
285 Size = sizeof(ULONG);
288 Size,
289 &DeviceExtension->AdapterInterfaceType,
290 &Size);
291
292 /* Get bus device address from the upper level bus driver. */
293 Size = sizeof(ULONG);
296 Size,
297 &PciSlotNumber,
298 &Size);
299
300 /* Convert slotnumber to PCI_SLOT_NUMBER */
301 SlotNumber.u.AsULONG = 0;
302 SlotNumber.u.bits.DeviceNumber = (PciSlotNumber >> 16) & 0xFFFF;
303 SlotNumber.u.bits.FunctionNumber = PciSlotNumber & 0xFFFF;
304 DeviceExtension->SystemIoSlotNumber = SlotNumber.u.AsULONG;
305 }
306
308 InitializeListHead(&DeviceExtension->DmaAdapterList);
309
310 KeInitializeDpc(&DeviceExtension->DpcObject,
312 DeviceExtension);
313
314 KeInitializeMutex(&DeviceExtension->DeviceLock, 0);
315
316 /* Attach the device. */
317 if ((PhysicalDeviceObject != NULL) && (DisplayNumber == 0))
321
322 Status = IntCreateNewRegistryPath(DeviceExtension);
323 if (!NT_SUCCESS(Status))
324 {
325 ERR_(VIDEOPRT, "IntCreateNewRegistryPath() failed with status 0x%08x\n", Status);
326 goto Failure;
327 }
328
329 IntSetupDeviceSettingsKey(DeviceExtension);
330
331 /* Remove the initializing flag */
332 (*DeviceObject)->Flags &= ~DO_DEVICE_INITIALIZING;
333
334 /* Set up the VIDEO/DEVICEMAP registry keys */
335 Status = IntVideoPortAddDeviceMapLink(DeviceExtension);
336 if (!NT_SUCCESS(Status))
337 {
338 ERR_(VIDEOPRT, "IntVideoPortAddDeviceMapLink() failed with status 0x%08x\n", Status);
339 goto Failure;
340 }
341
342 if (DisplayNumber == 0)
343 {
344 DriverExtension->InitializationData.StartingDeviceNumber++;
345 }
346
347 return STATUS_SUCCESS;
348
349Failure:
350 if (DeviceExtension->NextDeviceObject)
351 IoDetachDevice(DeviceExtension->NextDeviceObject);
354 return Status;
355}
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
LIST_ENTRY AddressMappingListHead
Definition: videoprt.h:101
VIDEO_PORT_COMMON_EXTENSION Common
Definition: videoprt.h:84
PDRIVER_OBJECT DriverObject
Definition: videoprt.h:86
PDEVICE_OBJECT FunctionalDeviceObject
Definition: videoprt.h:88
VOID NTAPI IntVideoPortDeferredRoutine(IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: videoprt.c:157
static ULONG VideoPortMaxObjectNumber
Definition: videoprt.c:40
static NTSTATUS IntVideoPortAddDeviceMapLink(PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: videoprt.c:70
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 1168 of file dispatch.c.

1171{
1172 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1173
1174 DeviceExtension = DeviceObject->DeviceExtension;
1175 RtlFreeUnicodeString(&DeviceExtension->RegistryPath);
1176
1177 Irp->IoStatus.Status = STATUS_SUCCESS;
1178 Irp->IoStatus.Information = 0;
1180
1181 return STATUS_SUCCESS;
1182}
_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::@1710::@1711 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() 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:737
#define FILE_OPENED
Definition: nt_native.h:769
VPAPI VP_STATUS NTAPI VideoPortEnumerateChildren(IN PVOID HwDeviceExtension, IN PVOID Reserved)
Definition: videoprt.c:1637
CHAR POINTER_ALIGNMENT MiniPortDeviceExtension[1]
Definition: videoprt.h:118
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 1154 of file dispatch.c.

1157{
1158 PVIDEO_PORT_COMMON_EXTENSION CommonExtension = DeviceObject->DeviceExtension;
1159
1160 if (CommonExtension->Fdo)
1162 else
1164}
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 1186 of file dispatch.c.

1189{
1191 NTSTATUS Status = Irp->IoStatus.Status;
1192 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
1193
1195
1196 if (DeviceExtension->Common.Fdo)
1197 {
1200 return PoCallDriver(DeviceExtension->NextDeviceObject, Irp);
1201 }
1202 else
1203 {
1204 switch (IrpSp->MinorFunction)
1205 {
1206 case IRP_MN_QUERY_POWER:
1207 case IRP_MN_SET_POWER:
1209 break;
1210 }
1212 Irp->IoStatus.Status = Status;
1214 return Status;
1215 }
1216}
#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 1220 of file dispatch.c.

1223{
1225 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
1226
1227 if (DeviceExtension->Common.Fdo)
1228 {
1230 return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
1231 }
1232 else
1233 {
1234 Status = Irp->IoStatus.Status;
1236 return Status;
1237 }
1238}
#define IoCallDriver
Definition: irp.c:1225

Referenced by VideoPortInitialize().

◆ IntVideoPortEnumerateChildren()

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

Definition at line 1473 of file videoprt.c.

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

93{
96 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
97 PVIDEO_ACCESS_RANGE AccessRanges;
98 ULONG AccessRangeCount, ListSize, i;
100 PIO_RESOURCE_REQUIREMENTS_LIST OldResList = IrpStack->Parameters.FilterResourceRequirements.IoResourceRequirementList;
101 PIO_RESOURCE_DESCRIPTOR CurrentDescriptor;
103
104 DriverObject = DeviceObject->DriverObject;
106 DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
107
108 Status = IntVideoPortGetLegacyResources(DriverExtension, DeviceExtension, &AccessRanges, &AccessRangeCount);
109 if (!NT_SUCCESS(Status))
110 return Status;
111 if (!AccessRangeCount)
112 {
113 /* No legacy resources to report */
114 return Irp->IoStatus.Status;
115 }
116
117 /* OK, we've got the access ranges now. Let's set up the resource requirements list */
118
119 if (OldResList)
120 {
121 /* Already one there so let's add to it */
122 ListSize = OldResList->ListSize + sizeof(IO_RESOURCE_DESCRIPTOR) * AccessRangeCount;
124 ListSize);
125 if (!ResList) return STATUS_NO_MEMORY;
126
127 RtlCopyMemory(ResList, OldResList, OldResList->ListSize);
128
129 ASSERT(ResList->AlternativeLists == 1);
130
131 ResList->ListSize = ListSize;
132 ResList->List[0].Count += AccessRangeCount;
133
134 CurrentDescriptor = (PIO_RESOURCE_DESCRIPTOR)((PUCHAR)ResList + OldResList->ListSize);
135
136 ExFreePool(OldResList);
137 Irp->IoStatus.Information = 0;
138 }
139 else
140 {
141 /* We need to make a new one */
142 ListSize = sizeof(IO_RESOURCE_REQUIREMENTS_LIST) + sizeof(IO_RESOURCE_DESCRIPTOR) * (AccessRangeCount - 1);
144 ListSize);
145 if (!ResList) return STATUS_NO_MEMORY;
146
147 RtlZeroMemory(ResList, ListSize);
148
149 /* We need to initialize some fields */
150 ResList->ListSize = ListSize;
151 ResList->InterfaceType = DeviceExtension->AdapterInterfaceType;
152 ResList->BusNumber = DeviceExtension->SystemIoBusNumber;
153 ResList->SlotNumber = DeviceExtension->SystemIoSlotNumber;
154 ResList->AlternativeLists = 1;
155 ResList->List[0].Version = 1;
156 ResList->List[0].Revision = 1;
157 ResList->List[0].Count = AccessRangeCount;
158
159 CurrentDescriptor = ResList->List[0].Descriptors;
160 }
161
162 for (i = 0; i < AccessRangeCount; i++)
163 {
164 /* This is a required resource */
165 CurrentDescriptor->Option = 0;
166
167 if (AccessRanges[i].RangeInIoSpace)
168 CurrentDescriptor->Type = CmResourceTypePort;
169 else
170 CurrentDescriptor->Type = CmResourceTypeMemory;
171
172 CurrentDescriptor->ShareDisposition =
174
175 CurrentDescriptor->Flags = 0;
176
177 if (CurrentDescriptor->Type == CmResourceTypePort)
178 {
179 CurrentDescriptor->u.Port.Length = AccessRanges[i].RangeLength;
180 CurrentDescriptor->u.Port.MinimumAddress = AccessRanges[i].RangeStart;
181 CurrentDescriptor->u.Port.MaximumAddress.QuadPart = AccessRanges[i].RangeStart.QuadPart + AccessRanges[i].RangeLength - 1;
182 CurrentDescriptor->u.Port.Alignment = 1;
183 if (AccessRanges[i].RangePassive & VIDEO_RANGE_PASSIVE_DECODE)
184 CurrentDescriptor->Flags |= CM_RESOURCE_PORT_PASSIVE_DECODE;
185 if (AccessRanges[i].RangePassive & VIDEO_RANGE_10_BIT_DECODE)
186 CurrentDescriptor->Flags |= CM_RESOURCE_PORT_10_BIT_DECODE;
187 }
188 else
189 {
190 CurrentDescriptor->u.Memory.Length = AccessRanges[i].RangeLength;
191 CurrentDescriptor->u.Memory.MinimumAddress = AccessRanges[i].RangeStart;
192 CurrentDescriptor->u.Memory.MaximumAddress.QuadPart = AccessRanges[i].RangeStart.QuadPart + AccessRanges[i].RangeLength - 1;
193 CurrentDescriptor->u.Memory.Alignment = 1;
194 CurrentDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_WRITE;
195 }
196
197 CurrentDescriptor++;
198 }
199
200 Irp->IoStatus.Information = (ULONG_PTR)ResList;
201
202 return STATUS_SUCCESS;
203}
#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:120
#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
struct _IO_RESOURCE_DESCRIPTOR::@2250::@2251 Port
struct _IO_RESOURCE_DESCRIPTOR::@2250::@2252 Memory
union _IO_RESOURCE_DESCRIPTOR::@2250 u
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:42
@ 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 425 of file videoprt.c.

429{
430 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
432 VP_STATUS vpStatus;
433 VIDEO_PORT_CONFIG_INFO ConfigInfo;
435 UCHAR Again = FALSE;
436 BOOL LegacyDetection = FALSE;
437 BOOLEAN VgaResourcesReleased = FALSE;
438
439 DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
441 DeviceExtension->IsVgaDetect = DeviceExtension->IsVgaDriver;
442 DeviceExtension->IsLegacyDetect = FALSE;
443 DeviceExtension->ReportDevice = FALSE;
444
445 /* Setup a ConfigInfo structure that we will pass to HwFindAdapter. */
446 RtlZeroMemory(&ConfigInfo, sizeof(VIDEO_PORT_CONFIG_INFO));
447 ConfigInfo.Length = sizeof(VIDEO_PORT_CONFIG_INFO);
448 ConfigInfo.AdapterInterfaceType = DeviceExtension->AdapterInterfaceType;
449 if (ConfigInfo.AdapterInterfaceType == PCIBus)
450 ConfigInfo.InterruptMode = LevelSensitive;
451 else
452 ConfigInfo.InterruptMode = Latched;
453 ConfigInfo.DriverRegistryPath = DriverExtension->RegistryPath.Buffer;
455 ConfigInfo.SystemIoBusNumber = DeviceExtension->SystemIoBusNumber;
456 ConfigInfo.BusInterruptLevel = DeviceExtension->InterruptLevel;
457 ConfigInfo.BusInterruptVector = DeviceExtension->InterruptVector;
458
461 sizeof(SystemBasicInfo),
462 NULL);
463 if (NT_SUCCESS(Status))
464 {
467 }
468
469 // FIXME: Check the adapter key and update VideoDebugLevel variable.
470
471 /*
472 * Call miniport HwVidFindAdapter entry point to detect if
473 * particular device is present. There are two possible code
474 * paths. The first one is for Legacy drivers (NT4) and cases
475 * when we don't have information about what bus we're on. The
476 * second case is the standard one for Plug & Play drivers.
477 */
478 if (DeviceExtension->PhysicalDeviceObject == NULL)
479 {
480 LegacyDetection = TRUE;
481 DeviceExtension->IsLegacyDevice = TRUE;
482 DeviceExtension->IsLegacyDetect = TRUE;
483 }
484 else
485 {
486 DeviceExtension->IsLegacyDevice = FALSE;
487 }
488
489 /* If we already have a VGA miniport and are about to probe for additional adapters,
490 * release its resources temporarily so conflicts are visible during detection.
491 * We'll reclaim them later if no new adapter successfully claims them. */
494 {
495 INFO_(VIDEOPRT, "Temporarily releasing VGA resources for adapter probing\n");
497 VgaResourcesReleased = TRUE;
498 }
500
501 if (LegacyDetection)
502 {
504
505 /* Suppose first we may not find any suitable device */
506 vpStatus = ERROR_DEV_NOT_EXIST; // ERROR_NO_MORE_DEVICES;
507
508 /* Enumerate all buses of the given type, call HwFindAdapter for each
509 * to find whether a video adapter is recognized there. Stop when an
510 * adapter has been found. */
511 for (BusNumber = 0;
512 (BusNumber < MAXULONG) &&
514 &BusNumber));
515 ++BusNumber)
516 {
517 DPRINT("Bus Type %lu, Number %lu\n",
518 DeviceExtension->AdapterInterfaceType, BusNumber);
519
520 DeviceExtension->SystemIoBusNumber =
521 ConfigInfo.SystemIoBusNumber = BusNumber;
522
523 RtlZeroMemory(&DeviceExtension->MiniPortDeviceExtension,
524 DriverExtension->InitializationData.HwDeviceExtensionSize);
525
526 /* FIXME: Need to figure out what string to pass as param 3. */
527 // FIXME: Handle the 'Again' parameter for legacy detection.
528 vpStatus = DriverExtension->InitializationData.HwFindAdapter(
529 &DeviceExtension->MiniPortDeviceExtension,
530 DriverExtension->HwContext,
531 NULL,
532 &ConfigInfo,
533 &Again);
534
535 if (vpStatus == ERROR_DEV_NOT_EXIST)
536 {
537 continue;
538 }
539 else
540 {
541 break;
542 }
543 }
544 }
545 else
546 {
547 /* FIXME: Need to figure out what string to pass as param 3. */
548 vpStatus = DriverExtension->InitializationData.HwFindAdapter(
549 &DeviceExtension->MiniPortDeviceExtension,
550 DriverExtension->HwContext,
551 NULL,
552 &ConfigInfo,
553 &Again);
554 }
555
556 if (vpStatus != NO_ERROR)
557 {
558 ERR_(VIDEOPRT, "HwFindAdapter failed (vpStatus=0x%X) bus=%u iface=%u legacy=%u vga=%u detect(VGA=%u LEGACY=%u)\n",
559 vpStatus,
560 DeviceExtension->SystemIoBusNumber,
561 DeviceExtension->AdapterInterfaceType,
562 DeviceExtension->IsLegacyDevice,
563 DeviceExtension->IsVgaDriver,
564 DeviceExtension->IsVgaDetect,
565 DeviceExtension->IsLegacyDetect);
566 /* If we released VGA resources, reclaim them so VGA fallback still works */
567 if (VgaResourcesReleased)
568 {
570 {
571 INFO_(VIDEOPRT, "Reclaiming VGA resources after failed probe\n");
575 {
576 WARN_(VIDEOPRT, "Failed to reclaim VGA resources after probe failure\n");
577 }
578 }
579 }
581 goto Failure;
582 }
583
584 /*
585 * Now we know the device is present, so let's do all additional tasks
586 * such as creating symlinks or setting up interrupts and timer.
587 */
588
589 /* FIXME: Allocate hardware resources for device. */
590
591 /* Allocate interrupt for device. */
593 {
595 goto Failure;
596 }
597
598 /* Allocate timer for device. */
600 {
601 if (DeviceExtension->InterruptObject != NULL)
602 IoDisconnectInterrupt(DeviceExtension->InterruptObject);
603 ERR_(VIDEOPRT, "IntVideoPortSetupTimer failed\n");
605 goto Failure;
606 }
607
608 /* If the device can be reset, insert it in the list of resettable adapters */
609 InitializeListHead(&DeviceExtension->HwResetListEntry);
610 if (DriverExtension->InitializationData.HwResetHw != NULL)
611 {
613 &DeviceExtension->HwResetListEntry,
615 }
616
617 if (DeviceExtension->IsVgaDriver)
618 {
621 {
622 VgaDeviceExtension = DeviceExtension;
623 }
625 }
626
627 DeviceExtension->IsVgaDetect = FALSE;
628 DeviceExtension->IsLegacyDetect = FALSE;
629
630 /* For legacy (non-PnP) adapters we should report a detected device so that
631 * a PDO exists for higher layers to enumerate consistently (mirrors ScsiPort).*/
632 if (DeviceExtension->IsLegacyDevice && !DeviceExtension->ReportDevice)
633 {
634 PDEVICE_OBJECT ReportedPdo = NULL;
636 DeviceExtension->AdapterInterfaceType,
637 DeviceExtension->SystemIoBusNumber,
638 DeviceExtension->SystemIoSlotNumber,
639 NULL,
640 NULL,
641 FALSE,
642 &ReportedPdo);
643 if (!NT_SUCCESS(repStatus))
644 {
645 WARN_(VIDEOPRT, "IoReportDetectedDevice failed 0x%08lx (bus=%u slot=%u)\n",
646 repStatus,
647 DeviceExtension->SystemIoBusNumber,
648 DeviceExtension->SystemIoSlotNumber);
649 }
650 else
651 {
652 INFO_(VIDEOPRT, "Reported legacy adapter PDO %p (bus=%u slot=%u)\n",
653 ReportedPdo,
654 DeviceExtension->SystemIoBusNumber,
655 DeviceExtension->SystemIoSlotNumber);
656 DeviceExtension->ReportDevice = TRUE;
657 }
658 }
659
660 /* Attempt to reclaim VGA resources after probing if a VGA device exists */
662 {
663 VP_STATUS vr;
664 INFO_(VIDEOPRT, "Attempt VGA reclaim after probe (ranges=%lu)\n", NumOfVgaRanges);
667 VgaRanges);
668 if (vr != NO_ERROR)
669 {
670 /* Another driver has taken VGA resources; drop fallback state */
671 WARN_(VIDEOPRT, "VGA reclaim failed (vpStatus=0x%X); releasing fallback state\n", vr);
674 VgaRanges = NULL;
675 NumOfVgaRanges = 0;
678
679 }
680 else
681 {
682 INFO_(VIDEOPRT, "VGA reclaim succeeded\n");
683 }
684 }
685
686 INFO_(VIDEOPRT, "STATUS_SUCCESS\n");
687 return STATUS_SUCCESS;
688
689Failure:
690 RtlFreeUnicodeString(&DeviceExtension->RegistryPath);
691 if (DeviceExtension->NextDeviceObject)
692 IoDetachDevice(DeviceExtension->NextDeviceObject);
693
694 /* Explicitly reclaim VGA resources on complete failure */
695 if (VgaResourcesReleased)
696 {
698 {
699 INFO_(VIDEOPRT, "Final reclaim attempt of VGA resources during failure cleanup\n");
703 {
704 WARN_(VIDEOPRT, "VGA reclaim failed during failure cleanup\n");
705 }
706 }
707 }
709 return Status;
710}
#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:984
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:398
KSPIN_LOCK HwResetAdaptersLock
Definition: videoprt.c:43
PVIDEO_ACCESS_RANGE VgaRanges
Definition: videoprt.c:47
static BOOLEAN IntIsVgaSaveDriverName(_In_ PDRIVER_OBJECT DriverObject)
Definition: videoprt.c:53
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:206
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 252 of file resource.c.

258{
259 OBJECT_ATTRIBUTES ObjAttribs;
261 HANDLE hMemObj;
263 SIZE_T Size;
264
265 /* Initialize object attribs */
266 RtlInitUnicodeString(&UnicodeString, L"\\Device\\PhysicalMemory");
267 InitializeObjectAttributes(&ObjAttribs,
270 NULL, NULL);
271
272 /* Open physical memory section */
273 Status = ZwOpenSection(&hMemObj, SECTION_ALL_ACCESS, &ObjAttribs);
274 if (!NT_SUCCESS(Status))
275 {
276 WARN_(VIDEOPRT, "ZwOpenSection() failed! (0x%x)\n", Status);
277 return Status;
278 }
279
280 /* Map view of section */
281 Size = SizeInBytes;
282 Status = ZwMapViewOfSection(hMemObj,
283 Process,
285 0,
286 Size,
288 &Size,
289 ViewUnmap,
290 0,
291 Protect);
292 ZwClose(hMemObj);
293 if (!NT_SUCCESS(Status))
294 {
295 WARN_(VIDEOPRT, "ZwMapViewOfSection() failed! (0x%x)\n", Status);
296 }
297
298 return Status;
299}
_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 206 of file resource.c.

208{
210 BOOLEAN ConflictDetected;
211 // An empty CM_RESOURCE_LIST
212 UCHAR EmptyResourceList[FIELD_OFFSET(CM_RESOURCE_LIST, List)] = {0};
213
214 if (DeviceExtension->IsLegacyDevice || DeviceExtension->IsLegacyDetect || DeviceExtension->IsVgaDetect)
215 {
217 DeviceExtension->DriverObject,
218 NULL, 0, /* Driver List */
219 DeviceExtension->PhysicalDeviceObject,
220 (PCM_RESOURCE_LIST)EmptyResourceList,
221 sizeof(EmptyResourceList),
222 &ConflictDetected);
223
224 if (!NT_SUCCESS(Status))
225 {
226 ERR_(VIDEOPRT,
227 "VideoPortReleaseResources (Detect) failed with 0x%08lx ; ConflictDetected: %s\n",
228 Status, ConflictDetected ? "TRUE" : "FALSE");
229 }
230 }
231 else
232 {
234 DeviceExtension->DriverObject,
235 NULL,
236 0,
237 DeviceExtension->PhysicalDeviceObject,
238 (PCM_RESOURCE_LIST)EmptyResourceList,
239 sizeof(EmptyResourceList),
240 FALSE,
241 &ConflictDetected);
242 if (!NT_SUCCESS(Status))
243 {
244 ERR_(VIDEOPRT,
245 "VideoPortReleaseResources (Usage) failed with 0x%08lx ; ConflictDetected: %s\n",
246 Status, ConflictDetected ? "TRUE" : "FALSE");
247 }
248 }
249}
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 1242 of file dispatch.c.

1243{
1244}

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

Referenced by IntInt10CallBiosEmu(), and VideoPortInitialize().

◆ VideoPortUseNewKey

BOOLEAN VideoPortUseNewKey
extern