ReactOS 0.4.16-dev-1946-g52006dd
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 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 134 of file videoprt.h.

◆ VIDEO_PORT_GET_DEVICE_EXTENSION

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

Definition at line 140 of file videoprt.h.

Typedef Documentation

◆ PVIDEO_PORT_ADDRESS_MAPPING

◆ PVIDEO_PORT_AGP_MAPPING

◆ PVIDEO_PORT_AGP_VIRTUAL_MAPPING

◆ PVIDEO_PORT_CHILD_EXTENSION

◆ PVIDEO_PORT_COMMON_EXTENSION

◆ PVIDEO_PORT_DEVICE_EXTENSION

◆ PVIDEO_PORT_DRIVER_EXTENSION

◆ PVIDEO_PORT_EVENT

◆ VIDEO_PORT_ADDRESS_MAPPING

◆ VIDEO_PORT_AGP_MAPPING

◆ VIDEO_PORT_AGP_VIRTUAL_MAPPING

◆ VIDEO_PORT_CHILD_EXTENSION

◆ VIDEO_PORT_COMMON_EXTENSION

◆ VIDEO_PORT_DEVICE_EXTENSION

◆ VIDEO_PORT_DRIVER_EXTENSION

◆ VIDEO_PORT_EVENT

Function Documentation

◆ IntAgpGetInterface()

NTSTATUS NTAPI IntAgpGetInterface ( IN PVOID  HwDeviceExtension,
IN OUT PINTERFACE  Interface 
)

Definition at line 496 of file agp.c.

499{
501 IO_STACK_LOCATION IoStack;
503 PVIDEO_PORT_AGP_INTERFACE_2 AgpInterface;
504 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
505 PAGP_BUS_INTERFACE_STANDARD AgpBusInterface;
506
507 DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
508 AgpBusInterface = &DeviceExtension->AgpInterface;
510
514 {
516 }
518 {
519 ASSERT(Interface->Size >= sizeof(VIDEO_PORT_AGP_INTERFACE));
520 }
521
522 if (DeviceExtension->NextDeviceObject == NULL)
523 {
524 WARN_(VIDEOPRT, "DeviceExtension->NextDeviceObject is NULL!\n");
525 return STATUS_UNSUCCESSFUL;
526 }
527
528 /* Query the interface from the AGP bus driver */
529 if (DeviceExtension->AgpInterface.Size == 0)
530 {
531 AgpBusInterface->Size = sizeof(AGP_BUS_INTERFACE_STANDARD);
533 AgpBusInterface->Version = AGP_BUS_INTERFACE_V1;
534 else /* if (InterfaceVersion == VIDEO_PORT_AGP_INTERFACE_VERSION_2) */
535 AgpBusInterface->Version = AGP_BUS_INTERFACE_V2;
536 IoStack.Parameters.QueryInterface.Size = AgpBusInterface->Size;
537 IoStack.Parameters.QueryInterface.Version = AgpBusInterface->Version;
538 IoStack.Parameters.QueryInterface.Interface = (PINTERFACE)AgpBusInterface;
539 IoStack.Parameters.QueryInterface.InterfaceType =
540 &GUID_AGP_TARGET_BUS_INTERFACE_STANDARD;
541 Status = IopInitiatePnpIrp(DeviceExtension->NextDeviceObject,
543 if (!NT_SUCCESS(Status))
544 {
545 WARN_(VIDEOPRT, "IopInitiatePnpIrp() failed! (Status 0x%x)\n", Status);
546 return Status;
547 }
548 INFO_(VIDEOPRT, "Got AGP driver interface!\n");
549 }
550
551 /* FIXME: Not sure if we should wrap the reference/dereference functions */
552 AgpInterface->Context = AgpBusInterface->AgpContext;
553 AgpInterface->InterfaceReference = AgpBusInterface->InterfaceReference;
554 AgpInterface->InterfaceDereference = AgpBusInterface->InterfaceDereference;
558 AgpInterface->AgpFreePhysical = IntAgpFreePhysical;
562 AgpInterface->AgpFreeVirtual = IntAgpFreeVirtual;
563 AgpInterface->AgpAllocationLimit = 0x1000000; /* FIXME: using 16 MB for now */
564
565 if (AgpInterface->Version >= VIDEO_PORT_AGP_INTERFACE_VERSION_2)
566 {
567 AgpInterface->AgpSetRate = IntAgpSetRate;
568 }
569
570 return STATUS_SUCCESS;
571}
VOID NTAPI IntAgpFreeVirtual(IN PVOID HwDeviceExtension, IN PVOID VirtualContext, IN ULONG Pages, IN ULONG Offset)
Definition: agp.c:331
PVOID NTAPI IntAgpReserveVirtual(IN PVOID HwDeviceExtension, IN HANDLE ProcessHandle, IN PVOID PhysicalContext, OUT PVOID *VirtualContext)
Definition: agp.c:419
BOOLEAN NTAPI IntAgpSetRate(IN PVOID HwDeviceExtension, IN ULONG Rate)
Definition: agp.c:479
BOOLEAN NTAPI IntAgpCommitPhysical(IN PVOID HwDeviceExtension, IN PVOID PhysicalContext, IN ULONG Pages, IN ULONG Offset)
Definition: agp.c:94
NTSTATUS IopInitiatePnpIrp(PDEVICE_OBJECT DeviceObject, PIO_STATUS_BLOCK IoStatusBlock, UCHAR MinorFunction, PIO_STACK_LOCATION Stack OPTIONAL)
Definition: agp.c:30
VOID NTAPI IntAgpFreePhysical(IN PVOID HwDeviceExtension, IN PVOID PhysicalContext, IN ULONG Pages, IN ULONG Offset)
Definition: agp.c:126
VOID NTAPI IntAgpReleasePhysical(IN PVOID HwDeviceExtension, IN PVOID PhysicalContext)
Definition: agp.c:154
PVOID NTAPI IntAgpCommitVirtual(IN PVOID HwDeviceExtension, IN PVOID VirtualContext, IN ULONG Pages, IN ULONG Offset)
Definition: agp.c:248
PHYSICAL_ADDRESS NTAPI IntAgpReservePhysical(IN PVOID HwDeviceExtension, IN ULONG Pages, IN VIDEO_PORT_CACHE_TYPE Caching, OUT PVOID *PhysicalContext)
Definition: agp.c:183
VOID NTAPI IntAgpReleaseVirtual(IN PVOID HwDeviceExtension, IN PVOID VirtualContext)
Definition: agp.c:385
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c: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::@4278::@4304 QueryInterface
union _IO_STACK_LOCATION::@1694 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:140
_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 589 of file videoprt.c.

592{
593 if (!CsrProcess)
594 return FALSE;
595
596 *CallingProcess = (PKPROCESS)PsGetCurrentProcess();
597 if (*CallingProcess != CsrProcess)
599 return TRUE;
600}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1768
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
wcsncpy
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#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)
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
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 616 of file videoprt.c.

619{
621 if (CallingProcess != CsrProcess)
623}
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:159
_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 159 of file videoprt.c.

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

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchPdoPnp()

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

Definition at line 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 1333 of file videoprt.c.

1336{
1337 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1338 ULONG Status;
1339 VIDEO_CHILD_ENUM_INFO ChildEnumInfo;
1340 BOOLEAN bHaveLastMonitorID = FALSE;
1341 UCHAR LastMonitorID[10];
1342 ULONG Unused;
1343 UINT i;
1344 PDEVICE_OBJECT ChildDeviceObject;
1345 PVIDEO_PORT_CHILD_EXTENSION ChildExtension;
1346
1347 INFO_(VIDEOPRT, "Starting child device probe\n");
1348 DeviceExtension = DeviceObject->DeviceExtension;
1350 {
1351 WARN_(VIDEOPRT, "Miniport's HwGetVideoChildDescriptor is NULL!\n");
1352 return STATUS_SUCCESS;
1353 }
1354
1355 if (!IsListEmpty(&DeviceExtension->ChildDeviceList))
1356 {
1357 ERR_(VIDEOPRT, "FIXME: Support calling VideoPortEnumerateChildren again!\n");
1358 return STATUS_SUCCESS;
1359 }
1360
1361 /* Enumerate the children */
1362 for (i = 1; ; i++)
1363 {
1364 Status = IoCreateDevice(DeviceExtension->DriverObject,
1367 NULL,
1370 FALSE,
1371 &ChildDeviceObject);
1372 if (!NT_SUCCESS(Status))
1373 return Status;
1374
1375 ChildExtension = ChildDeviceObject->DeviceExtension;
1376
1377 RtlZeroMemory(ChildExtension,
1380
1381 ChildExtension->Common.Fdo = FALSE;
1382 ChildExtension->ChildId = i;
1383 ChildExtension->PhysicalDeviceObject = ChildDeviceObject;
1384 ChildExtension->DriverObject = DeviceExtension->DriverObject;
1385
1386 /* Setup the ChildEnumInfo */
1387 ChildEnumInfo.Size = sizeof(ChildEnumInfo);
1388 ChildEnumInfo.ChildDescriptorSize = sizeof(ChildExtension->ChildDescriptor);
1389 ChildEnumInfo.ACPIHwId = 0;
1390
1392 ChildEnumInfo.ChildHwDeviceExtension = VIDEO_PORT_GET_CHILD_EXTENSION(ChildExtension);
1393 else
1394 ChildEnumInfo.ChildHwDeviceExtension = NULL;
1395
1396 ChildEnumInfo.ChildIndex = ChildExtension->ChildId;
1397
1398 INFO_(VIDEOPRT, "Probing child: %d\n", ChildEnumInfo.ChildIndex);
1400 DeviceExtension->MiniPortDeviceExtension,
1401 &ChildEnumInfo,
1402 &ChildExtension->ChildType,
1403 ChildExtension->ChildDescriptor,
1404 &ChildExtension->ChildId,
1405 &Unused);
1407 {
1408 if (ChildExtension->ChildType == Monitor)
1409 {
1410 // Check if the EDID is valid
1411 if (ChildExtension->ChildDescriptor[0] == 0x00 &&
1412 ChildExtension->ChildDescriptor[1] == 0xFF &&
1413 ChildExtension->ChildDescriptor[2] == 0xFF &&
1414 ChildExtension->ChildDescriptor[3] == 0xFF &&
1415 ChildExtension->ChildDescriptor[4] == 0xFF &&
1416 ChildExtension->ChildDescriptor[5] == 0xFF &&
1417 ChildExtension->ChildDescriptor[6] == 0xFF &&
1418 ChildExtension->ChildDescriptor[7] == 0x00)
1419 {
1420 if (bHaveLastMonitorID)
1421 {
1422 // Compare the previous monitor ID with the current one, break the loop if they are identical
1423 if (RtlCompareMemory(LastMonitorID, &ChildExtension->ChildDescriptor[8], sizeof(LastMonitorID)) == sizeof(LastMonitorID))
1424 {
1425 INFO_(VIDEOPRT, "Found identical Monitor ID two times, stopping enumeration\n");
1426 IoDeleteDevice(ChildDeviceObject);
1427 break;
1428 }
1429 }
1430
1431 // Copy 10 bytes from the EDID, which can be used to uniquely identify the monitor
1432 RtlCopyMemory(LastMonitorID, &ChildExtension->ChildDescriptor[8], sizeof(LastMonitorID));
1433 bHaveLastMonitorID = TRUE;
1434
1435 /* Mark it valid */
1436 ChildExtension->EdidValid = TRUE;
1437 }
1438 else
1439 {
1440 /* Mark it invalid */
1441 ChildExtension->EdidValid = FALSE;
1442 }
1443 }
1444 }
1446 {
1447 WARN_(VIDEOPRT, "Child device %d is invalid!\n", ChildEnumInfo.ChildIndex);
1448 IoDeleteDevice(ChildDeviceObject);
1449 continue;
1450 }
1452 {
1453 INFO_(VIDEOPRT, "End of child enumeration! (%d children enumerated)\n", i - 1);
1454 IoDeleteDevice(ChildDeviceObject);
1455 break;
1456 }
1457 else
1458 {
1459 WARN_(VIDEOPRT, "HwGetVideoChildDescriptor returned unknown status code 0x%x!\n", Status);
1460 IoDeleteDevice(ChildDeviceObject);
1461 break;
1462 }
1463
1464 if (ChildExtension->ChildType == Monitor)
1465 {
1466 UINT j;
1467 PUCHAR p = ChildExtension->ChildDescriptor;
1468 INFO_(VIDEOPRT, "Monitor device enumerated! (ChildId = 0x%x)\n", ChildExtension->ChildId);
1469 for (j = 0; j < sizeof (ChildExtension->ChildDescriptor); j += 8)
1470 {
1471 INFO_(VIDEOPRT, "%02x %02x %02x %02x %02x %02x %02x %02x\n",
1472 p[j + 0], p[j + 1], p[j + 2], p[j + 3],
1473 p[j + 4], p[j + 5], p[j + 6], p[j + 7]);
1474 }
1475 }
1476 else if (ChildExtension->ChildType == Other)
1477 {
1478 INFO_(VIDEOPRT, "\"Other\" device enumerated: DeviceId = %S\n", (PWSTR)ChildExtension->ChildDescriptor);
1479 }
1480 else
1481 {
1482 ERR_(VIDEOPRT, "HwGetVideoChildDescriptor returned unsupported type: %d\n", ChildExtension->ChildType);
1483 }
1484
1485 /* Clear the init flag */
1486 ChildDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
1487
1488 InsertTailList(&DeviceExtension->ChildDeviceList,
1489 &ChildExtension->ListEntry);
1490 }
1491
1492 return STATUS_SUCCESS;
1493}
#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:127
VIDEO_CHILD_TYPE ChildType
Definition: videoprt.h:121
PDRIVER_OBJECT DriverObject
Definition: videoprt.h:126
VIDEO_PORT_COMMON_EXTENSION Common
Definition: videoprt.h:118
VIDEO_HW_INITIALIZATION_DATA InitializationData
Definition: videoprt.h:72
uint16_t * PWSTR
Definition: typedefs.h:56
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define VIDEO_PORT_GET_CHILD_EXTENSION(MiniportExtension)
Definition: videoprt.h:134

Referenced by IntVideoPortQueryBusRelations().

◆ IntVideoPortFilterResourceRequirements()

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

Definition at line 87 of file resource.c.

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

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

Referenced by IntVideoPortPnPStartDevice(), and VideoPortInitialize().

◆ IntVideoPortGetProcAddress()

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

Definition at line 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}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char * FunctionName
Definition: acpixf.h:1279
LPWSTR Name
Definition: desk.c:124
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
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 230 of file resource.c.

236{
237 OBJECT_ATTRIBUTES ObjAttribs;
239 HANDLE hMemObj;
241 SIZE_T Size;
242
243 /* Initialize object attribs */
244 RtlInitUnicodeString(&UnicodeString, L"\\Device\\PhysicalMemory");
245 InitializeObjectAttributes(&ObjAttribs,
248 NULL, NULL);
249
250 /* Open physical memory section */
251 Status = ZwOpenSection(&hMemObj, SECTION_ALL_ACCESS, &ObjAttribs);
252 if (!NT_SUCCESS(Status))
253 {
254 WARN_(VIDEOPRT, "ZwOpenSection() failed! (0x%x)\n", Status);
255 return Status;
256 }
257
258 /* Map view of section */
259 Size = SizeInBytes;
260 Status = ZwMapViewOfSection(hMemObj,
261 Process,
263 0,
264 Size,
266 &Size,
267 ViewUnmap,
268 0,
269 Protect);
270 ZwClose(hMemObj);
271 if (!NT_SUCCESS(Status))
272 {
273 WARN_(VIDEOPRT, "ZwMapViewOfSection() failed! (0x%x)\n", Status);
274 }
275
276 return Status;
277}
_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 204 of file resource.c.

206{
208 BOOLEAN ConflictDetected;
209 // An empty CM_RESOURCE_LIST
210 UCHAR EmptyResourceList[FIELD_OFFSET(CM_RESOURCE_LIST, List)] = {0};
211
213 DeviceExtension->DriverObject,
214 NULL, 0, /* Driver List */
215 DeviceExtension->PhysicalDeviceObject,
216 (PCM_RESOURCE_LIST)EmptyResourceList,
217 sizeof(EmptyResourceList),
218 &ConflictDetected);
219
220 if (!NT_SUCCESS(Status))
221 {
222 ERR_(VIDEOPRT,
223 "VideoPortReleaseResources IoReportResource failed with 0x%08lx ; ConflictDetected: %s\n",
224 Status, ConflictDetected ? "TRUE" : "FALSE");
225 }
226 /* Ignore the returned status however... */
227}
NTSTATUS NTAPI IoReportResourceForDetection(IN PDRIVER_OBJECT DriverObject, IN PCM_RESOURCE_LIST DriverList OPTIONAL, IN ULONG DriverListSize OPTIONAL, IN PDEVICE_OBJECT DeviceObject OPTIONAL, IN PCM_RESOURCE_LIST DeviceList OPTIONAL, IN ULONG DeviceListSize OPTIONAL, OUT PBOOLEAN ConflictDetected)
Definition: pnpreport.c:394
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550

Referenced by VideoPortVerifyAccessRanges().

◆ IntVideoPortSetupInterrupt()

BOOLEAN NTAPI IntVideoPortSetupInterrupt ( IN PDEVICE_OBJECT  DeviceObject,
IN PVIDEO_PORT_DRIVER_EXTENSION  DriverExtension,
IN PVIDEO_PORT_CONFIG_INFO  ConfigInfo 
)

Definition at line 45 of file interrupt.c.

49{
51 PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
52
53 DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
54
55 /*
56 * MSDN documentation for VIDEO_PORT_CONFIG_INFO states: "If a miniport driver's
57 * HwVidFindAdapter function finds that the video adapter does not generate
58 * interrupts or that it cannot determine a valid interrupt vector/level for
59 * the adapter, HwVidFindAdapter should set both BusInterruptVector and
60 * BusInterruptLevel to zero.
61 */
62
63 if (DriverExtension->InitializationData.HwInterrupt != NULL &&
64 (ConfigInfo->BusInterruptLevel != 0 ||
65 ConfigInfo->BusInterruptVector != 0))
66 {
67 ULONG InterruptVector;
68 KIRQL Irql;
70
71 InterruptVector = HalGetInterruptVector(
72 ConfigInfo->AdapterInterfaceType,
73 ConfigInfo->SystemIoBusNumber,
74 ConfigInfo->BusInterruptLevel,
75 ConfigInfo->BusInterruptVector,
76 &Irql,
77 &Affinity);
78
79 if (InterruptVector == 0)
80 {
81 WARN_(VIDEOPRT, "HalGetInterruptVector failed\n");
82 return FALSE;
83 }
84
85 KeInitializeSpinLock(&DeviceExtension->InterruptSpinLock);
87 &DeviceExtension->InterruptObject,
89 DeviceExtension,
90 &DeviceExtension->InterruptSpinLock,
91 InterruptVector,
92 Irql,
93 Irql,
94 ConfigInfo->InterruptMode,
95 DeviceExtension->InterruptShared,
97 FALSE);
98
99 if (!NT_SUCCESS(Status))
100 {
101 WARN_(VIDEOPRT, "IoConnectInterrupt failed with status 0x%08x\n", Status);
102 return FALSE;
103 }
104 }
105
106 return TRUE;
107}
_Out_ PKIRQL Irql
Definition: csq.h:179
ULONG_PTR KAFFINITY
Definition: compat.h:85
NTHALAPI ULONG NTAPI HalGetInterruptVector(INTERFACE_TYPE, ULONG, ULONG, ULONG, PKIRQL, PKAFFINITY)
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
if(dx< 0)
Definition: linetemp.h:194
NTSTATUS NTAPI IoConnectInterrupt(OUT PKINTERRUPT *InterruptObject, IN PKSERVICE_ROUTINE ServiceRoutine, IN PVOID ServiceContext, IN PKSPIN_LOCK SpinLock, IN ULONG Vector, IN KIRQL Irql, IN KIRQL SynchronizeIrql, IN KINTERRUPT_MODE InterruptMode, IN BOOLEAN ShareVector, IN KAFFINITY ProcessorEnableMask, IN BOOLEAN FloatingSave)
Definition: irq.c: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
@ Executive
Definition: ketypes.h:467

Referenced by IntAgpGetInterface().

Variable Documentation

◆ CsrProcess

◆ HwResetAdaptersList

LIST_ENTRY HwResetAdaptersList
extern

◆ HwResetAdaptersLock

KSPIN_LOCK HwResetAdaptersLock
extern

◆ VideoPortDeviceNumber

ULONG VideoPortDeviceNumber
extern

◆ VideoPortInt10Mutex

KMUTEX VideoPortInt10Mutex
extern

Definition at line 38 of file int10.c.

Referenced by IntInt10CallBiosEmu(), and VideoPortInitialize().

◆ VideoPortUseNewKey

BOOLEAN VideoPortUseNewKey
extern