ReactOS  0.4.15-dev-3446-g30010a5
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)
 
NTSTATUS NTAPI IntVideoPortMapPhysicalMemory (IN HANDLE Process, IN PHYSICAL_ADDRESS PhysicalAddress, IN ULONG SizeInBytes, IN ULONG Protect, IN OUT PVOID *VirtualAddress OPTIONAL)
 
VOID FASTCALL IntAttachToCSRSS (PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
 
VOID FASTCALL IntDetachFromCSRSS (PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
 
NTSTATUS NTAPI IntVideoPortCreateAdapterDeviceObject (_In_ PDRIVER_OBJECT DriverObject, _In_ PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, _In_opt_ PDEVICE_OBJECT PhysicalDeviceObject, _In_ USHORT AdapterNumber, _In_ USHORT DisplayNumber, _Out_opt_ PDEVICE_OBJECT *DeviceObject)
 
NTSTATUS NTAPI IntVideoPortFindAdapter (IN PDRIVER_OBJECT DriverObject, IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, IN PDEVICE_OBJECT DeviceObject)
 
PVOID NTAPI IntVideoPortGetProcAddress (IN PVOID HwDeviceExtension, IN PUCHAR FunctionName)
 
NTSTATUS NTAPI IntInitializeVideoAddressSpace (VOID)
 
VP_STATUS NTAPI IntInt10AllocateBuffer (IN PVOID Context, OUT PUSHORT Seg, OUT PUSHORT Off, IN OUT PULONG Length)
 
VP_STATUS NTAPI IntInt10FreeBuffer (IN PVOID Context, IN USHORT Seg, IN USHORT Off)
 
VP_STATUS NTAPI IntInt10ReadMemory (IN PVOID Context, IN USHORT Seg, IN USHORT Off, OUT PVOID Buffer, IN ULONG Length)
 
VP_STATUS NTAPI IntInt10WriteMemory (IN PVOID Context, IN USHORT Seg, IN USHORT Off, IN PVOID Buffer, IN ULONG Length)
 
VP_STATUS NTAPI IntInt10CallBios (IN PVOID Context, IN OUT PINT10_BIOS_ARGUMENTS BiosArguments)
 
NTSTATUS NTAPI IntCopyRegistryKey (_In_ HANDLE SourceKeyHandle, _In_ HANDLE DestKeyHandle)
 
NTSTATUS NTAPI IntCopyRegistryValue (HANDLE SourceKeyHandle, HANDLE DestKeyHandle, PWSTR ValueName)
 
NTSTATUS NTAPI IntSetupDeviceSettingsKey (PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI IntCreateNewRegistryPath (PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI IntCreateRegistryPath (IN PCUNICODE_STRING DriverRegistryPath, IN ULONG DeviceNumber, OUT PUNICODE_STRING DeviceRegistryPath)
 

Variables

PKPROCESS CsrProcess
 
ULONG VideoPortDeviceNumber
 
KMUTEX VideoPortInt10Mutex
 
KSPIN_LOCK HwResetAdaptersLock
 
LIST_ENTRY HwResetAdaptersList
 

Macro Definition Documentation

◆ __BROKEN__

#define __BROKEN__

Definition at line 27 of file videoprt.h.

◆ GUID_STRING_LENGTH

#define GUID_STRING_LENGTH   (38 * sizeof(WCHAR))

Definition at line 42 of file videoprt.h.

◆ TAG_REQUEST_PACKET

#define TAG_REQUEST_PACKET   'qRpV'

Definition at line 40 of file videoprt.h.

◆ TAG_VIDEO_PORT

#define TAG_VIDEO_PORT   'PDIV'

Definition at line 38 of file videoprt.h.

◆ TAG_VIDEO_PORT_BUFFER

#define TAG_VIDEO_PORT_BUFFER   '\0mpV'

Definition at line 39 of file videoprt.h.

◆ VIDEO_PORT_GET_CHILD_EXTENSION

#define VIDEO_PORT_GET_CHILD_EXTENSION (   MiniportExtension)
Value:
MiniportExtension, \
ChildDeviceExtension)
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Definition at line 134 of file videoprt.h.

◆ VIDEO_PORT_GET_DEVICE_EXTENSION

#define VIDEO_PORT_GET_DEVICE_EXTENSION (   MiniportExtension)
Value:
MiniportExtension, \
MiniPortDeviceExtension)
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Definition at line 140 of file videoprt.h.

Typedef Documentation

◆ PVIDEO_PORT_ADDRESS_MAPPING

◆ PVIDEO_PORT_AGP_MAPPING

◆ PVIDEO_PORT_AGP_VIRTUAL_MAPPING

◆ PVIDEO_PORT_CHILD_EXTENSION

◆ PVIDEO_PORT_COMMON_EXTENSION

◆ PVIDEO_PORT_DEVICE_EXTENSION

◆ PVIDEO_PORT_DRIVER_EXTENSION

◆ PVIDEO_PORT_EVENT

◆ VIDEO_PORT_ADDRESS_MAPPING

◆ VIDEO_PORT_AGP_MAPPING

◆ VIDEO_PORT_AGP_VIRTUAL_MAPPING

◆ VIDEO_PORT_CHILD_EXTENSION

◆ VIDEO_PORT_COMMON_EXTENSION

◆ VIDEO_PORT_DEVICE_EXTENSION

◆ VIDEO_PORT_DRIVER_EXTENSION

◆ VIDEO_PORT_EVENT

Function Documentation

◆ IntAgpGetInterface()

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

Definition at line 496 of file agp.c.

499 {
501  IO_STACK_LOCATION IoStack;
503  PVIDEO_PORT_AGP_INTERFACE_2 AgpInterface;
504  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
505  PAGP_BUS_INTERFACE_STANDARD AgpBusInterface;
506 
507  DeviceExtension = VIDEO_PORT_GET_DEVICE_EXTENSION(HwDeviceExtension);
508  AgpBusInterface = &DeviceExtension->AgpInterface;
509  AgpInterface = (PVIDEO_PORT_AGP_INTERFACE_2)Interface;
510 
514  {
515  ASSERT(Interface->Size >= sizeof(VIDEO_PORT_AGP_INTERFACE_2));
516  }
517  else if (Interface->Version == VIDEO_PORT_AGP_INTERFACE_VERSION_1)
518  {
519  ASSERT(Interface->Size >= sizeof(VIDEO_PORT_AGP_INTERFACE));
520  }
521 
522  if (DeviceExtension->NextDeviceObject == NULL)
523  {
524  WARN_(VIDEOPRT, "DeviceExtension->NextDeviceObject is NULL!\n");
525  return STATUS_UNSUCCESSFUL;
526  }
527 
528  /* Query the interface from the AGP bus driver */
529  if (DeviceExtension->AgpInterface.Size == 0)
530  {
531  AgpBusInterface->Size = sizeof(AGP_BUS_INTERFACE_STANDARD);
533  AgpBusInterface->Version = AGP_BUS_INTERFACE_V1;
534  else /* if (InterfaceVersion == VIDEO_PORT_AGP_INTERFACE_VERSION_2) */
535  AgpBusInterface->Version = AGP_BUS_INTERFACE_V2;
536  IoStack.Parameters.QueryInterface.Size = AgpBusInterface->Size;
537  IoStack.Parameters.QueryInterface.Version = AgpBusInterface->Version;
538  IoStack.Parameters.QueryInterface.Interface = (PINTERFACE)AgpBusInterface;
539  IoStack.Parameters.QueryInterface.InterfaceType =
540  &GUID_AGP_TARGET_BUS_INTERFACE_STANDARD;
541  Status = IopInitiatePnpIrp(DeviceExtension->NextDeviceObject,
543  if (!NT_SUCCESS(Status))
544  {
545  WARN_(VIDEOPRT, "IopInitiatePnpIrp() failed! (Status 0x%x)\n", Status);
546  return Status;
547  }
548  INFO_(VIDEOPRT, "Got AGP driver interface!\n");
549  }
550 
551  /* FIXME: Not sure if we should wrap the reference/dereference functions */
552  AgpInterface->Context = AgpBusInterface->AgpContext;
553  AgpInterface->InterfaceReference = AgpBusInterface->InterfaceReference;
554  AgpInterface->InterfaceDereference = AgpBusInterface->InterfaceDereference;
557  AgpInterface->AgpCommitPhysical = IntAgpCommitPhysical;
558  AgpInterface->AgpFreePhysical = IntAgpFreePhysical;
559  AgpInterface->AgpReserveVirtual = IntAgpReserveVirtual;
560  AgpInterface->AgpReleaseVirtual = IntAgpReleaseVirtual;
561  AgpInterface->AgpCommitVirtual = IntAgpCommitVirtual;
562  AgpInterface->AgpFreeVirtual = IntAgpFreeVirtual;
563  AgpInterface->AgpAllocationLimit = 0x1000000; /* FIXME: using 16 MB for now */
564 
565  if (AgpInterface->Version >= VIDEO_PORT_AGP_INTERFACE_VERSION_2)
566  {
567  AgpInterface->AgpSetRate = IntAgpSetRate;
568  }
569 
570  return STATUS_SUCCESS;
571 }
OUT ULONGLONG AgpAllocationLimit
Definition: video.h:744
#define INFO_(ch,...)
Definition: debug.h:159
PHYSICAL_ADDRESS NTAPI IntAgpReservePhysical(IN PVOID HwDeviceExtension, IN ULONG Pages, IN VIDEO_PORT_CACHE_TYPE Caching, OUT PVOID *PhysicalContext)
Definition: agp.c:183
PINTERFACE_DEREFERENCE InterfaceDereference
Definition: ntagp.h:184
OUT PAGP_FREE_PHYSICAL AgpFreePhysical
Definition: video.h:739
VOID NTAPI IntAgpFreePhysical(IN PVOID HwDeviceExtension, IN PVOID PhysicalContext, IN ULONG Pages, IN ULONG Offset)
Definition: agp.c:126
PVOID NTAPI IntAgpCommitVirtual(IN PVOID HwDeviceExtension, IN PVOID VirtualContext, IN ULONG Pages, IN ULONG Offset)
Definition: agp.c:248
OUT PAGP_FREE_VIRTUAL AgpFreeVirtual
Definition: video.h:743
#define AGP_BUS_INTERFACE_V1
Definition: ntagp.h:31
LONG NTSTATUS
Definition: precomp.h:26
OUT PAGP_SET_RATE AgpSetRate
Definition: video.h:745
#define VIDEO_PORT_GET_DEVICE_EXTENSION(MiniportExtension)
Definition: videoprt.h:140
AGP_BUS_INTERFACE_STANDARD AgpInterface
Definition: videoprt.h:105
BOOLEAN NTAPI IntAgpSetRate(IN PVOID HwDeviceExtension, IN ULONG Rate)
Definition: agp.c:479
#define AGP_BUS_INTERFACE_V2
Definition: ntagp.h:32
OUT PAGP_RELEASE_PHYSICAL AgpReleasePhysical
Definition: video.h:737
OUT PAGP_COMMIT_VIRTUAL AgpCommitVirtual
Definition: video.h:742
NTSTATUS IopInitiatePnpIrp(PDEVICE_OBJECT DeviceObject, PIO_STATUS_BLOCK IoStatusBlock, UCHAR MinorFunction, PIO_STACK_LOCATION Stack OPTIONAL)
Definition: agp.c:30
PINTERFACE_REFERENCE InterfaceReference
Definition: ntagp.h:183
struct _INTERFACE * PINTERFACE
Status
Definition: gdiplustypes.h:24
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
OUT PAGP_COMMIT_PHYSICAL AgpCommitPhysical
Definition: video.h:738
#define VIDEO_PORT_AGP_INTERFACE_VERSION_2
Definition: video.h:124
#define VIDEO_PORT_AGP_INTERFACE_VERSION_1
Definition: video.h:123
#define IRP_MN_QUERY_INTERFACE
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
PDEVICE_OBJECT NextDeviceObject
Definition: videoprt.h:89
BOOLEAN NTAPI IntAgpCommitPhysical(IN PVOID HwDeviceExtension, IN PVOID PhysicalContext, IN ULONG Pages, IN ULONG Offset)
Definition: agp.c:94
OUT PINTERFACE_REFERENCE InterfaceReference
Definition: video.h:734
OUT PAGP_RELEASE_VIRTUAL AgpReleaseVirtual
Definition: video.h:741
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:361
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define NULL
Definition: types.h:112
OUT PAGP_RESERVE_VIRTUAL AgpReserveVirtual
Definition: video.h:740
VOID NTAPI IntAgpReleaseVirtual(IN PVOID HwDeviceExtension, IN PVOID VirtualContext)
Definition: agp.c:385
OUT PINTERFACE_DEREFERENCE InterfaceDereference
Definition: video.h:735
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
VOID NTAPI IntAgpFreeVirtual(IN PVOID HwDeviceExtension, IN PVOID VirtualContext, IN ULONG Pages, IN ULONG Offset)
Definition: agp.c:331
OUT PAGP_RESERVE_PHYSICAL AgpReservePhysical
Definition: video.h:736
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _AGP_BUS_INTERFACE_STANDARD AGP_BUS_INTERFACE_STANDARD
struct _VIDEO_PORT_AGP_INTERFACE_2 * PVIDEO_PORT_AGP_INTERFACE_2
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
PVOID NTAPI IntAgpReserveVirtual(IN PVOID HwDeviceExtension, IN HANDLE ProcessHandle, IN PVOID PhysicalContext, OUT PVOID *VirtualContext)
Definition: agp.c:419
VOID NTAPI IntAgpReleasePhysical(IN PVOID HwDeviceExtension, IN PVOID PhysicalContext)
Definition: agp.c:154
#define WARN_(ch,...)
Definition: debug.h:157

Referenced by VideoPortQueryServices().

◆ IntAttachToCSRSS()

VOID FASTCALL IntAttachToCSRSS ( PKPROCESS CallingProcess,
PKAPC_STATE  ApcState 
)

Definition at line 493 of file videoprt.c.

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

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

◆ IntCopyRegistryKey()

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

Definition at line 31 of file registry.c.

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

Referenced by IntCopyRegistryKey(), and IntCreateNewRegistryPath().

◆ IntCopyRegistryValue()

NTSTATUS NTAPI IntCopyRegistryValue ( HANDLE  SourceKeyHandle,
HANDLE  DestKeyHandle,
PWSTR  ValueName 
)

Definition at line 230 of file registry.c.

234 {
235  PKEY_VALUE_PARTIAL_INFORMATION ValueInformation;
236  UNICODE_STRING ValueNameString;
237  ULONG Length;
239 
240  RtlInitUnicodeString(&ValueNameString, ValueName);
241 
242  /* Query the value length */
243  Status = ZwQueryValueKey(SourceKeyHandle,
244  &ValueNameString,
246  NULL,
247  0,
248  &Length);
249  if ((Status != STATUS_BUFFER_OVERFLOW) &&
251  {
252  /* The key seems not present */
254  return Status;
255  }
256 
257  /* Allocate a buffer */
259  if (ValueInformation == NULL)
260  {
261  return Status;
262  }
263 
264  /* Query the value */
265  Status = ZwQueryValueKey(SourceKeyHandle,
266  &ValueNameString,
268  ValueInformation,
269  Length,
270  &Length);
271  if (!NT_SUCCESS(Status))
272  {
273  ExFreePoolWithTag(ValueInformation, TAG_VIDEO_PORT_BUFFER);
274  return Status;
275  }
276 
277  /* Write the registry value */
278  Status = ZwSetValueKey(DestKeyHandle,
279  &ValueNameString,
280  ValueInformation->TitleIndex,
281  ValueInformation->Type,
282  ValueInformation->Data,
283  ValueInformation->DataLength);
284 
285  ExFreePoolWithTag(ValueInformation, TAG_VIDEO_PORT_BUFFER);
286 
287  if (!NT_SUCCESS(Status))
288  {
289  ERR_(VIDEOPRT, "ZwSetValueKey failed: status 0x%lx\n", Status);
290  }
291 
292  return Status;
293 }
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define ERR_(ch,...)
Definition: debug.h:156
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define TAG_VIDEO_PORT_BUFFER
Definition: videoprt.h:39
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:240
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define NT_ASSERT
Definition: rtlfuncs.h:3310

Referenced by IntSetupDeviceSettingsKey().

◆ IntCreateNewRegistryPath()

NTSTATUS NTAPI IntCreateNewRegistryPath ( PVIDEO_PORT_DEVICE_EXTENSION  DeviceExtension)
Todo:
HACK

Definition at line 407 of file registry.c.

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

Referenced by IntVideoPortCreateAdapterDeviceObject().

◆ IntCreateRegistryPath()

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

Definition at line 601 of file registry.c.

605 {
606  static WCHAR RegistryMachineSystem[] = L"\\REGISTRY\\MACHINE\\SYSTEM\\";
607  static WCHAR CurrentControlSet[] = L"CURRENTCONTROLSET\\";
608  static WCHAR ControlSet[] = L"CONTROLSET";
609  static WCHAR Insert1[] = L"Hardware Profiles\\Current\\System\\CurrentControlSet\\";
610  static WCHAR Insert2[] = L"\\Device";
611  UNICODE_STRING DeviceNumberString;
612  WCHAR DeviceNumberBuffer[20];
613  BOOLEAN Valid;
614  UNICODE_STRING AfterControlSet;
616 
617  AfterControlSet = *DriverRegistryPath;
618 
619  /* Convert DeviceNumber to string */
620  DeviceNumberString.Length = 0;
621  DeviceNumberString.MaximumLength = sizeof(DeviceNumberBuffer);
622  DeviceNumberString.Buffer = DeviceNumberBuffer;
623  Status = RtlIntegerToUnicodeString(DeviceNumber, 10, &DeviceNumberString);
624  if (!NT_SUCCESS(Status))
625  {
626  ERR_(VIDEOPRT, "RtlIntegerToUnicodeString(%u) returned 0x%08x\n", DeviceNumber, Status);
627  return Status;
628  }
629 
630  /* Check if path begins with \\REGISTRY\\MACHINE\\SYSTEM\\ */
631  Valid = (DriverRegistryPath->Length > sizeof(RegistryMachineSystem) &&
632  0 == _wcsnicmp(DriverRegistryPath->Buffer, RegistryMachineSystem,
633  wcslen(RegistryMachineSystem)));
634  if (Valid)
635  {
636  AfterControlSet.Buffer += wcslen(RegistryMachineSystem);
637  AfterControlSet.Length -= sizeof(RegistryMachineSystem) - sizeof(UNICODE_NULL);
638 
639  /* Check if path contains CURRENTCONTROLSET */
640  if (AfterControlSet.Length > sizeof(CurrentControlSet) &&
641  0 == _wcsnicmp(AfterControlSet.Buffer, CurrentControlSet, wcslen(CurrentControlSet)))
642  {
643  AfterControlSet.Buffer += wcslen(CurrentControlSet);
644  AfterControlSet.Length -= sizeof(CurrentControlSet) - sizeof(UNICODE_NULL);
645  }
646  /* Check if path contains CONTROLSETnum */
647  else if (AfterControlSet.Length > sizeof(ControlSet) &&
648  0 == _wcsnicmp(AfterControlSet.Buffer, ControlSet, wcslen(ControlSet)))
649  {
650  AfterControlSet.Buffer += wcslen(ControlSet);
651  AfterControlSet.Length -= sizeof(ControlSet) - sizeof(UNICODE_NULL);
652  while (AfterControlSet.Length > 0 &&
653  *AfterControlSet.Buffer >= L'0' &&
654  *AfterControlSet.Buffer <= L'9')
655  {
656  AfterControlSet.Buffer++;
657  AfterControlSet.Length -= sizeof(WCHAR);
658  }
659 
660  Valid = (AfterControlSet.Length > 0 && L'\\' == *AfterControlSet.Buffer);
661  AfterControlSet.Buffer++;
662  AfterControlSet.Length -= sizeof(WCHAR);
663  AfterControlSet.MaximumLength = AfterControlSet.Length;
664  }
665  else
666  {
667  Valid = FALSE;
668  }
669  }
670 
671  if (Valid)
672  {
673  DeviceRegistryPath->MaximumLength = DriverRegistryPath->Length + sizeof(Insert1) + sizeof(Insert2)
674  + DeviceNumberString.Length;
675  DeviceRegistryPath->Buffer = ExAllocatePoolWithTag(PagedPool,
676  DeviceRegistryPath->MaximumLength,
678  if (DeviceRegistryPath->Buffer != NULL)
679  {
680  /* Build device path */
681  wcsncpy(DeviceRegistryPath->Buffer,
683  AfterControlSet.Buffer - DriverRegistryPath->Buffer);
684  DeviceRegistryPath->Length = (AfterControlSet.Buffer - DriverRegistryPath->Buffer) * sizeof(WCHAR);
685  RtlAppendUnicodeToString(DeviceRegistryPath, Insert1);
686  RtlAppendUnicodeStringToString(DeviceRegistryPath, &AfterControlSet);
687  RtlAppendUnicodeToString(DeviceRegistryPath, Insert2);
688  RtlAppendUnicodeStringToString(DeviceRegistryPath, &DeviceNumberString);
689 
690  /* Check if registry key exists */
691  Valid = NT_SUCCESS(RtlCheckRegistryKey(RTL_REGISTRY_ABSOLUTE, DeviceRegistryPath->Buffer));
692 
693  if (!Valid)
694  ExFreePoolWithTag(DeviceRegistryPath->Buffer, TAG_VIDEO_PORT);
695  }
696  else
697  {
698  Valid = FALSE;
699  }
700  }
701  else
702  {
703  WARN_(VIDEOPRT, "Unparsable registry path %wZ\n", DriverRegistryPath);
704  }
705 
706  /* If path doesn't point to *ControlSet*, use DriverRegistryPath directly */
707  if (!Valid)
708  {
709  DeviceRegistryPath->MaximumLength = DriverRegistryPath->Length + sizeof(Insert2) + DeviceNumberString.Length;
710  DeviceRegistryPath->Buffer = ExAllocatePoolWithTag(NonPagedPool,
711  DeviceRegistryPath->MaximumLength,
713 
714  if (!DeviceRegistryPath->Buffer)
715  return STATUS_NO_MEMORY;
716 
717  RtlCopyUnicodeString(DeviceRegistryPath, DriverRegistryPath);
718  RtlAppendUnicodeToString(DeviceRegistryPath, Insert2);
719  RtlAppendUnicodeStringToString(DeviceRegistryPath, &DeviceNumberString);
720  }
721 
722  DPRINT("Formatted registry key '%wZ' -> '%wZ'\n",
723  DriverRegistryPath, DeviceRegistryPath);
724 
725  return STATUS_SUCCESS;
726 }
#define TAG_VIDEO_PORT
Definition: videoprt.h:38
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define ERR_(ch,...)
Definition: debug.h:156
LONG NTSTATUS
Definition: precomp.h:26
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
unsigned char BOOLEAN
Status
Definition: gdiplustypes.h:24
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
NTSYSAPI NTSTATUS NTAPI RtlIntegerToUnicodeString(ULONG Value, ULONG Base, PUNICODE_STRING String)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define RTL_REGISTRY_ABSOLUTE
Definition: nt_native.h:161
UNICODE_STRING DriverRegistryPath
Definition: inport.c:17
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
NTSTATUS NTAPI RtlCheckRegistryKey(IN ULONG RelativeTo, IN PWSTR Path)
Definition: registry.c:583
#define STATUS_SUCCESS
Definition: shellext.h:65
_In_ PCHAR _In_ ULONG DeviceNumber
Definition: classpnp.h:1229
#define DPRINT
Definition: sndvol32.h:71
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define WARN_(ch,...)
Definition: debug.h:157

Referenced by IntVideoPortCreateAdapterDeviceObject().

◆ IntDetachFromCSRSS()

VOID FASTCALL IntDetachFromCSRSS ( PKPROCESS CallingProcess,
PKAPC_STATE  ApcState 
)

Definition at line 506 of file videoprt.c.

509 {
510  if (*CallingProcess != CsrProcess)
511  {
513  }
514 }
PKPROCESS CsrProcess
Definition: videoprt.c:39
VOID NTAPI KeUnstackDetachProcess(IN PRKAPC_STATE ApcState)
Definition: procobj.c:756
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1680

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

◆ IntInitializeVideoAddressSpace()

NTSTATUS NTAPI IntInitializeVideoAddressSpace ( VOID  )

Definition at line 200 of file int10.c.

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

Referenced by IntVideoPortDispatchOpen().

◆ IntInt10AllocateBuffer()

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

Definition at line 210 of file int10.c.

215 {
217 #ifdef _M_IX86
218  PVOID MemoryAddress;
219  PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess();
221  SIZE_T Size;
222 
223  TRACE_(VIDEOPRT, "IntInt10AllocateBuffer\n");
224 
225  IntAttachToCSRSS(&CallingProcess, &ApcState);
226 
227  Size = *Length;
228  MemoryAddress = (PVOID)0x20000;
229 
230  Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
231  &MemoryAddress,
232  0,
233  &Size,
234  MEM_COMMIT,
236  if (!NT_SUCCESS(Status))
237  {
238  WARN_(VIDEOPRT, "- ZwAllocateVirtualMemory failed\n");
239  IntDetachFromCSRSS(&CallingProcess, &ApcState);
241  }
242 
243  if (MemoryAddress > (PVOID)(0x100000 - Size))
244  {
245  ZwFreeVirtualMemory(NtCurrentProcess(),
246  &MemoryAddress,
247  &Size,
248  MEM_RELEASE);
249  WARN_(VIDEOPRT, "- Unacceptable memory allocated\n");
250  IntDetachFromCSRSS(&CallingProcess, &ApcState);
252  }
253 
254  *Length = (ULONG)Size;
255  *Seg = (USHORT)((ULONG_PTR)MemoryAddress >> 4);
256  *Off = (USHORT)((ULONG_PTR)MemoryAddress & 0xF);
257 
258  INFO_(VIDEOPRT, "- Segment: %x\n", (ULONG_PTR)MemoryAddress >> 4);
259  INFO_(VIDEOPRT, "- Offset: %x\n", (ULONG_PTR)MemoryAddress & 0xF);
260  INFO_(VIDEOPRT, "- Length: %x\n", *Length);
261 
262  IntDetachFromCSRSS(&CallingProcess, &ApcState);
263 
264  return NO_ERROR;
265 #else
266  Status = x86BiosAllocateBuffer(Length, Seg, Off);
268 #endif
269 }
KAPC_STATE
Definition: ketypes.h:1280
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define INFO_(ch,...)
Definition: debug.h:159
LONG NTSTATUS
Definition: precomp.h:26
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
#define NO_ERROR
Definition: dderror.h:5
#define MEM_COMMIT
Definition: nt_native.h:1313
uint32_t ULONG_PTR
Definition: typedefs.h:65
NTSTATUS NTAPI x86BiosAllocateBuffer(_In_ ULONG *Size, _In_ USHORT *Segment, _In_ USHORT *Offset)
Definition: x86bios.c:152
#define PsGetCurrentProcess
Definition: psfuncs.h:17
void * PVOID
Definition: retypes.h:9
#define NtCurrentProcess()
Definition: nt_native.h:1657
Status
Definition: gdiplustypes.h:24
#define TRACE_(x)
Definition: compat.h:76
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG_PTR SIZE_T
Definition: typedefs.h:80
VOID FASTCALL IntAttachToCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:493
unsigned short USHORT
Definition: pedump.c:61
struct _KPROCESS * PKPROCESS
Definition: wdm.template.h:206
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1680
#define MEM_RELEASE
Definition: nt_native.h:1316
VOID FASTCALL IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:506
unsigned int ULONG
Definition: retypes.h:1
#define PAGE_EXECUTE_READWRITE
Definition: nt_native.h:1308
#define WARN_(ch,...)
Definition: debug.h:157

Referenced by VideoPortQueryServices().

◆ IntInt10CallBios()

VP_STATUS NTAPI IntInt10CallBios ( IN PVOID  Context,
IN OUT PINT10_BIOS_ARGUMENTS  BiosArguments 
)

Definition at line 380 of file int10.c.

383 {
384 #ifdef _M_AMD64
385  X86_BIOS_REGISTERS BiosContext;
386 #else
388 #endif
390  PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess();
392 
393  /* Attach to CSRSS */
394  IntAttachToCSRSS(&CallingProcess, &ApcState);
395 
396  /* Clear the context */
398 
399  /* Fill out the bios arguments */
400  BiosContext.Eax = BiosArguments->Eax;
401  BiosContext.Ebx = BiosArguments->Ebx;
402  BiosContext.Ecx = BiosArguments->Ecx;
403  BiosContext.Edx = BiosArguments->Edx;
404  BiosContext.Esi = BiosArguments->Esi;
405  BiosContext.Edi = BiosArguments->Edi;
406  BiosContext.Ebp = BiosArguments->Ebp;
407  BiosContext.SegDs = BiosArguments->SegDs;
408  BiosContext.SegEs = BiosArguments->SegEs;
409 
410  /* Do the ROM BIOS call */
412  Executive,
413  KernelMode,
414  FALSE,
415  NULL);
416 
417  /* The kernel needs access here */
419 #ifdef _M_AMD64
421 #else
422  Status = Ke386CallBios(0x10, &BiosContext);
423 #endif
425 
427 
428  /* Return the arguments */
429  BiosArguments->Eax = BiosContext.Eax;
430  BiosArguments->Ebx = BiosContext.Ebx;
431  BiosArguments->Ecx = BiosContext.Ecx;
432  BiosArguments->Edx = BiosContext.Edx;
433  BiosArguments->Esi = BiosContext.Esi;
434  BiosArguments->Edi = BiosContext.Edi;
435  BiosArguments->Ebp = BiosContext.Ebp;
436  BiosArguments->SegDs = (USHORT)BiosContext.SegDs;
437  BiosArguments->SegEs = (USHORT)BiosContext.SegEs;
438 
439  /* Detach and return status */
440  IntDetachFromCSRSS(&CallingProcess, &ApcState);
441 
442  if (NT_SUCCESS(Status))
443  {
444  return NO_ERROR;
445  }
446 
448 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
KAPC_STATE
Definition: ketypes.h:1280
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define KeWaitForMutexObject
Definition: kefuncs.h:555
LONG NTSTATUS
Definition: precomp.h:26
static VOID ProtectLowV86Mem(VOID)
Definition: int10.c:39
KMUTEX VideoPortInt10Mutex
Definition: videoprt.c:41
LONG NTAPI KeReleaseMutex(IN PKMUTEX Mutex, IN BOOLEAN Wait)
Definition: mutex.c:189
#define NO_ERROR
Definition: dderror.h:5
#define FALSE
Definition: types.h:117
#define PsGetCurrentProcess
Definition: psfuncs.h:17
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
CALLBACK16 BiosContext
Definition: bios32.c:45
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
NTSTATUS NTAPI Ke386CallBios(IN ULONG Int, OUT PCONTEXT Context)
Definition: v86vdm.c:614
VOID FASTCALL IntAttachToCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:493
unsigned short USHORT
Definition: pedump.c:61
struct _KPROCESS * PKPROCESS
Definition: wdm.template.h:206
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1680
static VOID UnprotectLowV86Mem(VOID)
Definition: int10.c:62
#define NULL
Definition: types.h:112
VOID FASTCALL IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:506
BOOLEAN NTAPI x86BiosCall(_In_ ULONG InterruptNumber, _Inout_ PX86_BIOS_REGISTERS Registers)
Definition: x86bios.c:405
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by VideoPortInt10(), and VideoPortQueryServices().

◆ IntInt10FreeBuffer()

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

Definition at line 273 of file int10.c.

277 {
279 #ifdef _M_IX86
280  PVOID MemoryAddress = (PVOID)((ULONG_PTR)(Seg << 4) | Off);
281  PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess();
283  SIZE_T Size = 0;
284 
285  TRACE_(VIDEOPRT, "IntInt10FreeBuffer\n");
286  INFO_(VIDEOPRT, "- Segment: %x\n", Seg);
287  INFO_(VIDEOPRT, "- Offset: %x\n", Off);
288 
289  IntAttachToCSRSS(&CallingProcess, &ApcState);
290  Status = ZwFreeVirtualMemory(NtCurrentProcess(),
291  &MemoryAddress,
292  &Size,
293  MEM_RELEASE);
294 
295  IntDetachFromCSRSS(&CallingProcess, &ApcState);
296 
297  return Status;
298 #else
299  Status = x86BiosFreeBuffer(Seg, Off);
301 #endif
302 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
KAPC_STATE
Definition: ketypes.h:1280
#define INFO_(ch,...)
Definition: debug.h:159
LONG NTSTATUS
Definition: precomp.h:26
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
#define NO_ERROR
Definition: dderror.h:5
uint32_t ULONG_PTR
Definition: typedefs.h:65
NTSTATUS NTAPI x86BiosFreeBuffer(_In_ USHORT Segment, _In_ USHORT Offset)
Definition: x86bios.c:181
#define PsGetCurrentProcess
Definition: psfuncs.h:17
void * PVOID
Definition: retypes.h:9
#define NtCurrentProcess()
Definition: nt_native.h:1657
Status
Definition: gdiplustypes.h:24
#define TRACE_(x)
Definition: compat.h:76
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG_PTR SIZE_T
Definition: typedefs.h:80
VOID FASTCALL IntAttachToCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:493
struct _KPROCESS * PKPROCESS
Definition: wdm.template.h:206
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1680
#define MEM_RELEASE
Definition: nt_native.h:1316
VOID FASTCALL IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:506

Referenced by VideoPortQueryServices().

◆ IntInt10ReadMemory()

VP_STATUS NTAPI IntInt10ReadMemory ( IN PVOID  Context,
IN USHORT  Seg,
IN USHORT  Off,
OUT PVOID  Buffer,
IN ULONG  Length 
)

Definition at line 306 of file int10.c.

312 {
313 #ifdef _M_IX86
314  PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess();
316 
317  TRACE_(VIDEOPRT, "IntInt10ReadMemory\n");
318  INFO_(VIDEOPRT, "- Segment: %x\n", Seg);
319  INFO_(VIDEOPRT, "- Offset: %x\n", Off);
320  INFO_(VIDEOPRT, "- Buffer: %x\n", Buffer);
321  INFO_(VIDEOPRT, "- Length: %x\n", Length);
322 
323  IntAttachToCSRSS(&CallingProcess, &ApcState);
324 
325  if (IsLowV86Mem(Seg, Off))
327  RtlCopyMemory(Buffer, (PVOID)((ULONG_PTR)(Seg << 4) | Off), Length);
328  if (IsLowV86Mem(Seg, Off))
330 
331  IntDetachFromCSRSS(&CallingProcess, &ApcState);
332 
333  return NO_ERROR;
334 #else
336 
337  Status = x86BiosReadMemory(Seg, Off, Buffer, Length);
339 #endif
340 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
KAPC_STATE
Definition: ketypes.h:1280
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define INFO_(ch,...)
Definition: debug.h:159
LONG NTSTATUS
Definition: precomp.h:26
static VOID ProtectLowV86Mem(VOID)
Definition: int10.c:39
#define NO_ERROR
Definition: dderror.h:5
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IsLowV86Mem(_Seg, _Off)
Definition: int10.c:33
#define PsGetCurrentProcess
Definition: psfuncs.h:17
Definition: bufpool.h:45
NTSTATUS NTAPI x86BiosReadMemory(_In_ USHORT Segment, _In_ USHORT Offset, _Out_writes_bytes_(Size) PVOID Buffer, _In_ ULONG Size)
Definition: x86bios.c:205
Status
Definition: gdiplustypes.h:24
#define TRACE_(x)
Definition: compat.h:76
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID FASTCALL IntAttachToCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:493
struct _KPROCESS * PKPROCESS
Definition: wdm.template.h:206
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1680
static VOID UnprotectLowV86Mem(VOID)
Definition: int10.c:62
VOID FASTCALL IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:506
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263

Referenced by VideoPortQueryServices().

◆ IntInt10WriteMemory()

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

Definition at line 344 of file int10.c.

350 {
351 #ifdef _M_IX86
352  PKPROCESS CallingProcess = (PKPROCESS)PsGetCurrentProcess();
354 
355  TRACE_(VIDEOPRT, "IntInt10WriteMemory\n");
356  INFO_(VIDEOPRT, "- Segment: %x\n", Seg);
357  INFO_(VIDEOPRT, "- Offset: %x\n", Off);
358  INFO_(VIDEOPRT, "- Buffer: %x\n", Buffer);
359  INFO_(VIDEOPRT, "- Length: %x\n", Length);
360 
361  IntAttachToCSRSS(&CallingProcess, &ApcState);
362  if (IsLowV86Mem(Seg, Off))
364  RtlCopyMemory((PVOID)((ULONG_PTR)(Seg << 4) | Off), Buffer, Length);
365  if (IsLowV86Mem(Seg, Off))
367  IntDetachFromCSRSS(&CallingProcess, &ApcState);
368 
369  return NO_ERROR;
370 #else
372 
373  Status = x86BiosWriteMemory(Seg, Off, Buffer, Length);
375 #endif
376 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
KAPC_STATE
Definition: ketypes.h:1280
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define INFO_(ch,...)
Definition: debug.h:159
LONG NTSTATUS
Definition: precomp.h:26
static VOID ProtectLowV86Mem(VOID)
Definition: int10.c:39
#define NO_ERROR
Definition: dderror.h:5
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IsLowV86Mem(_Seg, _Off)
Definition: int10.c:33
#define PsGetCurrentProcess
Definition: psfuncs.h:17
Definition: bufpool.h:45
Status
Definition: gdiplustypes.h:24
#define TRACE_(x)
Definition: compat.h:76
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID FASTCALL IntAttachToCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:493
struct _KPROCESS * PKPROCESS
Definition: wdm.template.h:206
_Out_ PKAPC_STATE ApcState
Definition: mm.h:1680
static VOID UnprotectLowV86Mem(VOID)
Definition: int10.c:62
VOID FASTCALL IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
Definition: videoprt.c:506
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
NTSTATUS NTAPI x86BiosWriteMemory(_In_ USHORT Segment, _In_ USHORT Offset, _In_reads_bytes_(Size) PVOID Buffer, _In_ ULONG Size)
Definition: x86bios.c:232

Referenced by VideoPortQueryServices().

◆ IntSetupDeviceSettingsKey()

NTSTATUS NTAPI IntSetupDeviceSettingsKey ( PVIDEO_PORT_DEVICE_EXTENSION  DeviceExtension)

Definition at line 297 of file registry.c.

299 {
300  static UNICODE_STRING SettingsKeyName = RTL_CONSTANT_STRING(L"Settings");
301  HANDLE DevInstRegKey, SourceKeyHandle, DestKeyHandle;
304 
305  if (!DeviceExtension->PhysicalDeviceObject)
306  return STATUS_SUCCESS;
307 
308  /* Open the software key: HKLM\System\CurrentControlSet\Control\Class<ClassGUID><n> */
312  &DevInstRegKey);
313  if (Status != STATUS_SUCCESS)
314  {
315  ERR_(VIDEOPRT, "Failed to open device software key. Status 0x%lx\n", Status);
316  return Status;
317  }
318 
319  /* Open the 'Settings' sub-key */
321  &SettingsKeyName,
324  NULL);
325  Status = ZwOpenKey(&DestKeyHandle, KEY_WRITE, &ObjectAttributes);
326 
327  /* Close the device software key */
329 
330  if (Status != STATUS_SUCCESS)
331  {
332  ERR_(VIDEOPRT, "Failed to open settings key. Status 0x%lx\n", Status);
333  return Status;
334  }
335 
336  /* Open the device profile key */
338  &DeviceExtension->RegistryPath,
340  NULL,
341  NULL);
342  Status = ZwOpenKey(&SourceKeyHandle, KEY_WRITE, &ObjectAttributes);
343  if (Status != STATUS_SUCCESS)
344  {
345  ERR_(VIDEOPRT, "ZwOpenKey failed for settings key: status 0x%lx\n", Status);
346  ObCloseHandle(DestKeyHandle, KernelMode);
347  return Status;
348  }
349 
350  IntCopyRegistryValue(SourceKeyHandle, DestKeyHandle, L"InstalledDisplayDrivers");
351  IntCopyRegistryValue(SourceKeyHandle, DestKeyHandle, L"Attach.ToDesktop");
352 
353  ObCloseHandle(SourceKeyHandle, KernelMode);
354  ObCloseHandle(DestKeyHandle, KernelMode);
355 
356  return STATUS_SUCCESS;
357 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define ERR_(ch,...)
Definition: debug.h:156
LONG NTSTATUS
Definition: precomp.h:26
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define L(x)
Definition: ntvdm.h:50
PDEVICE_OBJECT PhysicalDeviceObject
Definition: videoprt.h:87
Status
Definition: gdiplustypes.h:24
#define KEY_WRITE
Definition: nt_native.h:1031
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3375
#define PLUGPLAY_REGKEY_DRIVER
Definition: usbd.c:42
_In_ ULONG _In_ ACCESS_MASK _Out_ PHANDLE DevInstRegKey
Definition: iofuncs.h:1125
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define NULL
Definition: types.h:112
NTSTATUS NTAPI IoOpenDeviceRegistryKey(IN PDEVICE_OBJECT DeviceObject, IN ULONG DevInstKeyType, IN ACCESS_MASK DesiredAccess, OUT PHANDLE DevInstRegKey)
Definition: pnpmgr.c:2191
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
UNICODE_STRING RegistryPath
Definition: videoprt.h:90
#define STATUS_SUCCESS
Definition: shellext.h:65
NTSTATUS NTAPI IntCopyRegistryValue(HANDLE SourceKeyHandle, HANDLE DestKeyHandle, PWSTR ValueName)
Definition: registry.c:230
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

Referenced by IntVideoPortCreateAdapterDeviceObject().

◆ IntVideoPortAddDevice()

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

Definition at line 334 of file dispatch.c.

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

Referenced by VideoPortInitialize().

◆ IntVideoPortCreateAdapterDeviceObject()

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

Definition at line 152 of file videoprt.c.

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

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

◆ IntVideoPortDispatchCleanup()

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

Definition at line 1101 of file dispatch.c.

1104 {
1105  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
1106 
1107  DeviceExtension = DeviceObject->DeviceExtension;
1108  RtlFreeUnicodeString(&DeviceExtension->RegistryPath);
1109 
1110  Irp->IoStatus.Status = STATUS_SUCCESS;
1111  Irp->IoStatus.Information = 0;
1113 
1114  return STATUS_SUCCESS;
1115 }
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define IO_NO_INCREMENT
Definition: iotypes.h:598
UNICODE_STRING RegistryPath
Definition: videoprt.h:90
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ IntVideoPortDispatchClose()

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

Definition at line 433 of file dispatch.c.

436 {
437  TRACE_(VIDEOPRT, "IntVideoPortDispatchClose\n");
438 
440 
441  Irp->IoStatus.Status = STATUS_SUCCESS;
443  return STATUS_SUCCESS;
444 }
static NTSTATUS IntVideoPortInbvCleanup(IN PDEVICE_OBJECT DeviceObject)
Definition: dispatch.c:300
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
#define TRACE_(x)
Definition: compat.h:76
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchDeviceControl()

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

Definition at line 718 of file dispatch.c.

721 {
722  PIO_STACK_LOCATION IrpStack;
725 
726  TRACE_(VIDEOPRT, "IntVideoPortDispatchDeviceControl\n");
727 
728  IrpStack = IoGetCurrentIrpStackLocation(Irp);
729 
730  switch (IrpStack->MajorFunction)
731  {
733  /* This is the main part of this function and is handled below */
734  break;
735 
736  case IRP_MJ_SHUTDOWN:
737  {
738  /* Dereference CSRSS */
739  PKPROCESS OldCsrProcess;
740  OldCsrProcess = InterlockedExchangePointer((PVOID*)&CsrProcess, NULL);
741  if (OldCsrProcess)
742  ObDereferenceObject(OldCsrProcess);
743 
744  Irp->IoStatus.Status = STATUS_SUCCESS;
746  return STATUS_SUCCESS;
747  }
748 
749  default:
750  ERR_(VIDEOPRT, "- Unknown MajorFunction 0x%x\n", IrpStack->MajorFunction);
751  Irp->IoStatus.Status = STATUS_SUCCESS;
753  return STATUS_SUCCESS;
754  }
755 
756  IoControlCode = IrpStack->Parameters.DeviceIoControl.IoControlCode;
757 
758  INFO_(VIDEOPRT, "- IoControlCode: 0x%x: %s\n", IoControlCode, IoctlName(IoControlCode));
759 
760  switch (IoControlCode)
761  {
765  WARN_(VIDEOPRT, "- IOCTL_VIDEO_*_VDM are UNIMPLEMENTED!\n");
767  break;
768 
771  WARN_(VIDEOPRT, "- IOCTL_VIDEO_GET/SET_OUTPUT_DEVICE_POWER_STATE are UNIMPLEMENTED!\n");
773  break;
774 
777  WARN_(VIDEOPRT, "- IOCTL_VIDEO_GET/SET_POWER_MANAGEMENT are UNIMPLEMENTED!\n");
779  break;
780 
784  WARN_(VIDEOPRT, "- IOCTL_VIDEO_*_BRIGHTNESS are UNIMPLEMENTED!\n");
786  break;
787 
789  INFO_(VIDEOPRT, "- IOCTL_VIDEO_INIT_WIN32K_CALLBACKS\n");
791  Irp->AssociatedIrp.SystemBuffer,
792  IrpStack->Parameters.DeviceIoControl.InputBufferLength,
793  &Irp->IoStatus.Information);
794  break;
795 
797  WARN_(VIDEOPRT, "- IOCTL_VIDEO_IS_VGA_DEVICE is UNIMPLEMENTED!\n");
799  break;
800 
802  INFO_(VIDEOPRT, "- IOCTL_VIDEO_USE_DEVICE_IN_SESSION\n");
804  Irp->AssociatedIrp.SystemBuffer,
805  IrpStack->Parameters.DeviceIoControl.InputBufferLength,
806  &Irp->IoStatus.Information);
807  break;
808 
810  INFO_(VIDEOPRT, "- IOCTL_VIDEO_PREPARE_FOR_EARECOVERY\n");
811  /*
812  * The Win32k Watchdog Timer detected that a thread spent more time
813  * in a display driver than the allotted time its threshold specified,
814  * and thus is going to attempt to recover by switching to VGA mode.
815  * If this attempt fails, the watchdog generates bugcheck 0xEA
816  * "THREAD_STUCK_IN_DEVICE_DRIVER".
817  *
818  * Prepare the recovery by resetting the display adapters to
819  * standard VGA 80x25 text mode.
820  */
823  break;
824 
825  default:
826  /* Forward to the Miniport Driver */
828  break;
829  }
830 
831  INFO_(VIDEOPRT, "- Returned status: 0x%x\n", Status);
832 
833  Irp->IoStatus.Status = Status;
835  return Status;
836 }
#define IOCTL_VIDEO_IS_VGA_DEVICE
Definition: ntddvdeo.h:68
static NTSTATUS VideoPortUseDeviceInSession(_Inout_ PDEVICE_OBJECT DeviceObject, _Inout_ PVIDEO_DEVICE_SESSION_STATUS SessionState, _In_ ULONG BufferLength, _Out_ PULONG_PTR Information)
Definition: dispatch.c:566
#define INFO_(ch,...)
Definition: debug.h:159
#define IOCTL_VIDEO_REGISTER_VDM
Definition: ntddvdeo.h:47
#define IRP_MJ_SHUTDOWN
#define ERR_(ch,...)
Definition: debug.h:156
LONG NTSTATUS
Definition: precomp.h:26
#define IOCTL_VIDEO_ENABLE_VDM
Definition: ntddvdeo.h:41
#define IOCTL_VIDEO_GET_POWER_MANAGEMENT
Definition: ntddvdeo.h:98
#define IOCTL_VIDEO_GET_OUTPUT_DEVICE_POWER_STATE
Definition: ntddvdeo.h:53
PKPROCESS CsrProcess
Definition: videoprt.c:39
PSTR IoctlName(ULONG Ioctl)
Definition: dispatch.c:447
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
return STATUS_NOT_IMPLEMENTED
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
#define IOCTL_VIDEO_INIT_WIN32K_CALLBACKS
Definition: ntddvdeo.h:62
static BOOLEAN NTAPI IntVideoPortResetDisplayParametersEx(_In_ ULONG Columns, _In_ ULONG Rows, _In_ BOOLEAN CalledByInbv)
Definition: dispatch.c:72
#define IoCompleteRequest
Definition: irp.c:1240
static NTSTATUS VideoPortInitWin32kCallbacks(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PVIDEO_WIN32K_CALLBACKS Win32kCallbacks, _In_ ULONG BufferLength, _Out_ PULONG_PTR Information)
Definition: dispatch.c:624
#define IOCTL_VIDEO_SET_POWER_MANAGEMENT
Definition: ntddvdeo.h:170
Status
Definition: gdiplustypes.h:24
#define TRACE_(x)
Definition: compat.h:76
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
#define ObDereferenceObject
Definition: obfuncs.h:203
#define IOCTL_VIDEO_PREPARE_FOR_EARECOVERY
Definition: ntddvdeo.h:74
#define IO_VIDEO_INCREMENT
Definition: iotypes.h:609
#define IOCTL_VIDEO_SET_DISPLAY_BRIGHTNESS
Definition: ntddvdeo.h:200
#define IOCTL_VIDEO_QUERY_SUPPORTED_BRIGHTNESS
Definition: ntddvdeo.h:194
#define IOCTL_VIDEO_DISABLE_VDM
Definition: ntddvdeo.h:44
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
Definition: wdfio.h:318
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
#define NULL
Definition: types.h:112
#define IOCTL_VIDEO_QUERY_DISPLAY_BRIGHTNESS
Definition: ntddvdeo.h:197
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:598
static NTSTATUS VideoPortForwardDeviceControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:651
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
#define IOCTL_VIDEO_USE_DEVICE_IN_SESSION
Definition: ntddvdeo.h:71
#define WARN_(ch,...)
Definition: debug.h:157
#define IOCTL_VIDEO_SET_OUTPUT_DEVICE_POWER_STATE
Definition: ntddvdeo.h:50
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchOpen()

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

Definition at line 369 of file dispatch.c.

372 {
374  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
376 
377  TRACE_(VIDEOPRT, "IntVideoPortDispatchOpen\n");
378 
379  if (!CsrProcess)
380  {
381  /*
382  * We know the first open call will be from the CSRSS process
383  * to let us know its handle.
384  */
385  INFO_(VIDEOPRT, "Referencing CSRSS\n");
388  INFO_(VIDEOPRT, "CsrProcess 0x%p\n", CsrProcess);
389 
391  if (!NT_SUCCESS(Status))
392  {
393  ERR_(VIDEOPRT, "IntInitializeVideoAddressSpace() failed: 0x%lx\n", Status);
395  CsrProcess = NULL;
396  return Status;
397  }
398  }
399 
400  DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
401  DriverExtension = DeviceExtension->DriverExtension;
402 
403  // FIXME: (Re-)initialize INBV only if DeviceObject doesn't belong to a mirror driver.
405 
406  if (DriverExtension->InitializationData.HwInitialize(&DeviceExtension->MiniPortDeviceExtension))
407  {
409  InterlockedIncrement((PLONG)&DeviceExtension->DeviceOpened);
410  }
411  else
412  {
414  }
415 
416  Irp->IoStatus.Status = Status;
417  Irp->IoStatus.Information = FILE_OPENED;
419 
420  return Status;
421 }
#define INFO_(ch,...)
Definition: debug.h:159
VIDEO_PORT_DRIVER_EXTENSION * DriverExtension
Definition: videoprt.h:103
#define ERR_(ch,...)
Definition: debug.h:156
LONG NTSTATUS
Definition: precomp.h:26
struct _VIDEO_PORT_DEVICE_EXTENSTION * PVIDEO_PORT_DEVICE_EXTENSION
#define FILE_OPENED
Definition: nt_native.h:769
PKPROCESS CsrProcess
Definition: videoprt.c:39
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
#define PsGetCurrentProcess
Definition: psfuncs.h:17
#define IoCompleteRequest
Definition: irp.c:1240
NTSTATUS NTAPI IntInitializeVideoAddressSpace(VOID)
Definition: int10.c:200
static NTSTATUS IntVideoPortInbvInitialize(VOID)
Definition: dispatch.c:274
Status
Definition: gdiplustypes.h:24
#define TRACE_(x)
Definition: compat.h:76
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ObDereferenceObject
Definition: obfuncs.h:203
CHAR POINTER_ALIGNMENT MiniPortDeviceExtension[1]
Definition: videoprt.h:113
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define InterlockedIncrement
Definition: armddk.h:53
struct _KPROCESS * PKPROCESS
Definition: wdm.template.h:206
#define NULL
Definition: types.h:112
#define ObReferenceObject
Definition: obfuncs.h:204
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define STATUS_SUCCESS
Definition: shellext.h:65
signed int * PLONG
Definition: retypes.h:5

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchPdoPnp()

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

Definition at line 386 of file child.c.

389 {
391  NTSTATUS Status = Irp->IoStatus.Status;
392 
394 
395  switch (IrpSp->MinorFunction)
396  {
397  case IRP_MN_START_DEVICE:
398  case IRP_MN_STOP_DEVICE:
399  /* Nothing to do */
401  break;
402 
405  /* None (keep old status) */
406  break;
407 
408  case IRP_MN_QUERY_ID:
409  /* Call our helper */
410  Status = IntVideoPortChildQueryId(DeviceObject->DeviceExtension,
411  Irp,
412  IrpSp);
413  break;
414 
416  /* Call our helper */
418  Irp,
419  IrpSp);
420  break;
421 
425  break;
426 
428  Irp->IoStatus.Status = STATUS_SUCCESS;
431  return STATUS_SUCCESS;
432 
434  /* Call our helper */
436  Irp,
437  IrpSp);
438  break;
439 
441  /* Call our helper */
443  Irp,
444  IrpSp);
445  break;
446 
447  default:
448  break;
449  }
450 
451  Irp->IoStatus.Status = Status;
452 
454 
455  return Status;
456 }
#define IRP_MN_QUERY_RESOURCES
#define IRP_MN_REMOVE_DEVICE
#define IRP_MN_QUERY_ID
NTSTATUS NTAPI IntVideoPortChildQueryCapabilities(IN PVIDEO_PORT_CHILD_EXTENSION ChildExtension, IN PIRP Irp, IN PIO_STACK_LOCATION IrpSp)
Definition: child.c:319
#define IRP_MN_QUERY_RESOURCE_REQUIREMENTS
LONG NTSTATUS
Definition: precomp.h:26
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
#define IRP_MN_QUERY_REMOVE_DEVICE
#define IoCompleteRequest
Definition: irp.c:1240
Status
Definition: gdiplustypes.h:24
#define IRP_MN_SURPRISE_REMOVAL
Definition: ntifs_ex.h:408
#define IRP_MN_STOP_DEVICE
#define IRP_MN_START_DEVICE
#define IRP_MN_QUERY_DEVICE_TEXT
NTSTATUS NTAPI IntVideoPortChildQueryRelations(IN PVIDEO_PORT_CHILD_EXTENSION ChildExtension, IN PIRP Irp, IN PIO_STACK_LOCATION IrpSp)
Definition: child.c:292
NTSTATUS NTAPI IntVideoPortChildQueryText(IN PVIDEO_PORT_CHILD_EXTENSION ChildExtension, IN PIRP Irp, IN PIO_STACK_LOCATION IrpSp)
Definition: child.c:242
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
#define IRP_MN_QUERY_DEVICE_RELATIONS
NTSTATUS NTAPI IntVideoPortChildQueryId(IN PVIDEO_PORT_CHILD_EXTENSION ChildExtension, IN PIRP Irp, IN PIO_STACK_LOCATION IrpSp)
Definition: child.c:117
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define STATUS_SUCCESS
Definition: shellext.h:65
#define IRP_MN_QUERY_CAPABILITIES

Referenced by IntVideoPortDispatchPnp().

◆ IntVideoPortDispatchPnp()

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

Definition at line 1087 of file dispatch.c.

1090 {
1091  PVIDEO_PORT_COMMON_EXTENSION CommonExtension = DeviceObject->DeviceExtension;
1092 
1093  if (CommonExtension->Fdo)
1095  else
1097 }
NTSTATUS NTAPI IntVideoPortDispatchPdoPnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: child.c:386
NTSTATUS NTAPI IntVideoPortDispatchFdoPnp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: dispatch.c:1010
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchPower()

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

Definition at line 1119 of file dispatch.c.

1122 {
1124  NTSTATUS Status = Irp->IoStatus.Status;
1125  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
1126 
1128 
1129  if (DeviceExtension->Common.Fdo)
1130  {
1133  return PoCallDriver(DeviceExtension->NextDeviceObject, Irp);
1134  }
1135  else
1136  {
1137  switch (IrpSp->MinorFunction)
1138  {
1139  case IRP_MN_QUERY_POWER:
1140  case IRP_MN_SET_POWER:
1142  break;
1143  }
1145  Irp->IoStatus.Status = Status;
1147  return Status;
1148  }
1149 }
#define IRP_MN_QUERY_POWER
LONG NTSTATUS
Definition: precomp.h:26
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
Status
Definition: gdiplustypes.h:24
PDEVICE_OBJECT NextDeviceObject
Definition: videoprt.h:89
#define IRP_MN_SET_POWER
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:746
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
VIDEO_PORT_COMMON_EXTENSION Common
Definition: videoprt.h:84
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by VideoPortInitialize().

◆ IntVideoPortDispatchSystemControl()

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

Definition at line 1153 of file dispatch.c.

1156 {
1157  NTSTATUS Status;
1158  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
1159 
1160  if (DeviceExtension->Common.Fdo)
1161  {
1163  return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
1164  }
1165  else
1166  {
1167  Status = Irp->IoStatus.Status;
1169  return Status;
1170  }
1171 }
LONG NTSTATUS
Definition: precomp.h:26
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
Status
Definition: gdiplustypes.h:24
PDEVICE_OBJECT NextDeviceObject
Definition: videoprt.h:89
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
VIDEO_PORT_COMMON_EXTENSION Common
Definition: videoprt.h:84
#define IO_NO_INCREMENT
Definition: iotypes.h:598

Referenced by VideoPortInitialize().

◆ IntVideoPortFilterResourceRequirements()

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

Definition at line 77 of file resource.c.

81 {
84  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
85  PVIDEO_ACCESS_RANGE AccessRanges;
86  ULONG AccessRangeCount, ListSize, i;
88  PIO_RESOURCE_REQUIREMENTS_LIST OldResList = IrpStack->Parameters.FilterResourceRequirements.IoResourceRequirementList;
89  PIO_RESOURCE_DESCRIPTOR CurrentDescriptor;
91 
92  DriverObject = DeviceObject->DriverObject;
94  DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
95 
96  Status = IntVideoPortGetLegacyResources(DriverExtension, DeviceExtension, &AccessRanges, &AccessRangeCount);
97  if (!NT_SUCCESS(Status))
98  return Status;
99  if (!AccessRangeCount)
100  {
101  /* No legacy resources to report */
102  return Irp->IoStatus.Status;
103  }
104 
105  /* OK, we've got the access ranges now. Let's set up the resource requirements list */
106 
107  if (OldResList)
108  {
109  /* Already one there so let's add to it */
110  ListSize = OldResList->ListSize + sizeof(IO_RESOURCE_DESCRIPTOR) * AccessRangeCount;
111  ResList = ExAllocatePool(NonPagedPool,
112  ListSize);
113  if (!ResList) return STATUS_NO_MEMORY;
114 
115  RtlCopyMemory(ResList, OldResList, OldResList->ListSize);
116 
117  ASSERT(ResList->AlternativeLists == 1);
118 
119  ResList->ListSize = ListSize;
120  ResList->List[0].Count += AccessRangeCount;
121 
122  CurrentDescriptor = (PIO_RESOURCE_DESCRIPTOR)((PUCHAR)ResList + OldResList->ListSize);
123 
124  ExFreePool(OldResList);
125  Irp->IoStatus.Information = 0;
126  }
127  else
128  {
129  /* We need to make a new one */
130  ListSize = sizeof(IO_RESOURCE_REQUIREMENTS_LIST) + sizeof(IO_RESOURCE_DESCRIPTOR) * (AccessRangeCount - 1);
131  ResList = ExAllocatePool(NonPagedPool,
132  ListSize);
133  if (!ResList) return STATUS_NO_MEMORY;
134 
135  RtlZeroMemory(ResList, ListSize);
136 
137  /* We need to initialize some fields */
138  ResList->ListSize = ListSize;
139  ResList->InterfaceType = DeviceExtension->AdapterInterfaceType;
140  ResList->BusNumber = DeviceExtension->SystemIoBusNumber;
141  ResList->SlotNumber = DeviceExtension->SystemIoSlotNumber;
142  ResList->AlternativeLists = 1;
143  ResList->List[0].Version = 1;
144  ResList->List[0].Revision = 1;
145  ResList->List[0].Count = AccessRangeCount;
146 
147  CurrentDescriptor = ResList->List[0].Descriptors;
148  }
149 
150  for (i = 0; i < AccessRangeCount; i++)
151  {
152  /* This is a required resource */
153  CurrentDescriptor->Option = 0;
154 
155  if (AccessRanges[i].RangeInIoSpace)
156  CurrentDescriptor->Type = CmResourceTypePort;
157  else
158  CurrentDescriptor->Type = CmResourceTypeMemory;
159 
160  CurrentDescriptor->ShareDisposition =
162 
163  CurrentDescriptor->Flags = 0;
164 
165  if (CurrentDescriptor->Type == CmResourceTypePort)
166  {
167  CurrentDescriptor->u.Port.Length = AccessRanges[i].RangeLength;
168  CurrentDescriptor->u.Port.MinimumAddress = AccessRanges[i].RangeStart;
169  CurrentDescriptor->u.Port.MaximumAddress.QuadPart = AccessRanges[i].RangeStart.QuadPart + AccessRanges[i].RangeLength - 1;
170  CurrentDescriptor->u.Port.Alignment = 1;
171  if (AccessRanges[i].RangePassive & VIDEO_RANGE_PASSIVE_DECODE)
172  CurrentDescriptor->Flags |= CM_RESOURCE_PORT_PASSIVE_DECODE;
173  if (AccessRanges[i].RangePassive & VIDEO_RANGE_10_BIT_DECODE)
174  CurrentDescriptor->Flags |= CM_RESOURCE_PORT_10_BIT_DECODE;
175  }
176  else
177  {
178  CurrentDescriptor->u.Memory.Length = AccessRanges[i].RangeLength;
179  CurrentDescriptor->u.Memory.MinimumAddress = AccessRanges[i].RangeStart;
180  CurrentDescriptor->u.Memory.MaximumAddress.QuadPart = AccessRanges[i].RangeStart.QuadPart + AccessRanges[i].RangeLength - 1;
181  CurrentDescriptor->u.Memory.Alignment = 1;
182  CurrentDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_WRITE;
183  }
184 
185  CurrentDescriptor++;
186  }
187 
188  Irp->IoStatus.Information = (ULONG_PTR)ResList;
189 
190  return STATUS_SUCCESS;
191 }
struct _IO_RESOURCE_REQUIREMENTS_LIST IO_RESOURCE_REQUIREMENTS_LIST
struct _IO_RESOURCE_DESCRIPTOR::@1527::@1529 Memory
NTSTATUS NTAPI IntVideoPortGetLegacyResources(IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, IN PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension, OUT PVIDEO_ACCESS_RANGE *AccessRanges, OUT PULONG AccessRangeCount)
Definition: resource.c:30
struct _IO_RESOURCE_DESCRIPTOR::@1527::@1528 Port
union _IO_RESOURCE_DESCRIPTOR::@1527 u
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
struct _VIDEO_PORT_DEVICE_EXTENSTION * PVIDEO_PORT_DEVICE_EXTENSION
#define CM_RESOURCE_MEMORY_READ_WRITE
Definition: cmtypes.h:120
#define CmResourceTypePort
Definition: hwresource.cpp:123
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
#define VIDEO_RANGE_PASSIVE_DECODE
Definition: video.h:98
#define VIDEO_RANGE_10_BIT_DECODE
Definition: video.h:99
#define CM_RESOURCE_PORT_10_BIT_DECODE
Definition: cmtypes.h:110
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
struct _IO_RESOURCE_DESCRIPTOR IO_RESOURCE_DESCRIPTOR
Status
Definition: gdiplustypes.h:24
IO_RESOURCE_DESCRIPTOR Descriptors[1]
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define CM_RESOURCE_PORT_PASSIVE_DECODE
Definition: cmtypes.h:114
UCHAR RangeShareable
Definition: video.h:219
struct _IO_RESOURCE_DESCRIPTOR * PIO_RESOURCE_DESCRIPTOR
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1877
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define ULONG_PTR
Definition: config.h:101
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_SUCCESS
Definition: shellext.h:65
#define CmResourceTypeMemory
Definition: hwresource.cpp:125
INTERFACE_TYPE AdapterInterfaceType
Definition: videoprt.h:98
ULONG RangeLength
Definition: video.h:216
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
LONGLONG QuadPart
Definition: typedefs.h:114
PHYSICAL_ADDRESS RangeStart
Definition: video.h:215

Referenced by IntVideoPortDispatchFdoPnp().

◆ IntVideoPortFindAdapter()

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

Definition at line 341 of file videoprt.c.

345 {
346  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
348  VP_STATUS vpStatus;
349  VIDEO_PORT_CONFIG_INFO ConfigInfo;
351  UCHAR Again = FALSE;
352  BOOL LegacyDetection = FALSE;
353 
354  DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
355 
356  /* Setup a ConfigInfo structure that we will pass to HwFindAdapter. */
357  RtlZeroMemory(&ConfigInfo, sizeof(VIDEO_PORT_CONFIG_INFO));
358  ConfigInfo.Length = sizeof(VIDEO_PORT_CONFIG_INFO);
359  ConfigInfo.AdapterInterfaceType = DeviceExtension->AdapterInterfaceType;
360  if (ConfigInfo.AdapterInterfaceType == PCIBus)
361  ConfigInfo.InterruptMode = LevelSensitive;
362  else
363  ConfigInfo.InterruptMode = Latched;
364  ConfigInfo.DriverRegistryPath = DriverExtension->RegistryPath.Buffer;
366  ConfigInfo.SystemIoBusNumber = DeviceExtension->SystemIoBusNumber;
367  ConfigInfo.BusInterruptLevel = DeviceExtension->InterruptLevel;
368  ConfigInfo.BusInterruptVector = DeviceExtension->InterruptVector;
369 
372  sizeof(SystemBasicInfo),
373  NULL);
374  if (NT_SUCCESS(Status))
375  {
378  }
379 
380  // FIXME: Check the adapter key and update VideoDebugLevel variable.
381 
382  /*
383  * Call miniport HwVidFindAdapter entry point to detect if
384  * particular device is present. There are two possible code
385  * paths. The first one is for Legacy drivers (NT4) and cases
386  * when we don't have information about what bus we're on. The
387  * second case is the standard one for Plug & Play drivers.
388  */
389  if (DeviceExtension->PhysicalDeviceObject == NULL)
390  {
391  LegacyDetection = TRUE;
392  }
393 
394  if (LegacyDetection)
395  {
396  ULONG BusNumber, MaxBuses;
397 
398  MaxBuses = DeviceExtension->AdapterInterfaceType == PCIBus ? PCI_MAX_BRIDGE_NUMBER : 1;
399 
400  for (BusNumber = 0; BusNumber < MaxBuses; BusNumber++)
401  {
402  DeviceExtension->SystemIoBusNumber =
403  ConfigInfo.SystemIoBusNumber = BusNumber;
404 
405  RtlZeroMemory(&DeviceExtension->MiniPortDeviceExtension,
406  DriverExtension->InitializationData.HwDeviceExtensionSize);
407 
408  /* FIXME: Need to figure out what string to pass as param 3. */
409  vpStatus = DriverExtension->InitializationData.HwFindAdapter(
410  &DeviceExtension->MiniPortDeviceExtension,
411  DriverExtension->HwContext,
412  NULL,
413  &ConfigInfo,
414  &Again);
415 
416  if (vpStatus == ERROR_DEV_NOT_EXIST)
417  {
418  continue;
419  }
420  else
421  {
422  break;
423  }
424  }
425  }
426  else
427  {
428  /* FIXME: Need to figure out what string to pass as param 3. */
429  vpStatus = DriverExtension->InitializationData.HwFindAdapter(
430  &DeviceExtension->MiniPortDeviceExtension,
431  DriverExtension->HwContext,
432  NULL,
433  &ConfigInfo,
434  &Again);
435  }
436 
437  if (vpStatus != NO_ERROR)
438  {
439  ERR_(VIDEOPRT, "HwFindAdapter call failed with error 0x%X\n", vpStatus);
441  goto Failure;
442  }
443 
444  /*
445  * Now we know the device is present, so let's do all additional tasks
446  * such as creating symlinks or setting up interrupts and timer.
447  */
448 
449  /* FIXME: Allocate hardware resources for device. */
450 
451  /* Allocate interrupt for device. */
453  {
455  goto Failure;
456  }
457 
458  /* Allocate timer for device. */
460  {
461  if (DeviceExtension->InterruptObject != NULL)
462  IoDisconnectInterrupt(DeviceExtension->InterruptObject);
463  ERR_(VIDEOPRT, "IntVideoPortSetupTimer failed\n");
465  goto Failure;
466  }
467 
468  /* If the device can be reset, insert it in the list of resettable adapters */
469  InitializeListHead(&DeviceExtension->HwResetListEntry);
470  if (DriverExtension->InitializationData.HwResetHw != NULL)
471  {
473  &DeviceExtension->HwResetListEntry,
475  }
476 
477  /* Query children of the device. */
479 
480  INFO_(VIDEOPRT, "STATUS_SUCCESS\n");
481  return STATUS_SUCCESS;
482 
483 Failure:
484  RtlFreeUnicodeString(&DeviceExtension->RegistryPath);
485  if (DeviceExtension->NextDeviceObject)
486  IoDetachDevice(DeviceExtension->NextDeviceObject);
488  return Status;
489 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define PCI_MAX_BRIDGE_NUMBER
Definition: iotypes.h:3600
#define INFO_(ch,...)
Definition: debug.h:159
#define TRUE
Definition: types.h:120
BOOLEAN NTAPI IntVideoPortSetupTimer(IN PDEVICE_OBJECT DeviceObject, IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension)
Definition: timer.c:43
#define ERR_(ch,...)
Definition: debug.h:156
LONG NTSTATUS
Definition: precomp.h:26
struct _VIDEO_PORT_DEVICE_EXTENSTION * PVIDEO_PORT_DEVICE_EXTENSION
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1296
#define NO_ERROR
Definition: dderror.h:5
INTERFACE_TYPE AdapterInterfaceType
Definition: video.h:169
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
PVOID NTAPI IntVideoPortGetProcAddress(IN PVOID HwDeviceExtension, IN PUCHAR FunctionName)
Definition: funclist.c:100
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
PDEVICE_OBJECT PhysicalDeviceObject
Definition: videoprt.h:87
VP_STATUS NTAPI VideoPortEnumerateChildren(IN PVOID HwDeviceExtension, IN PVOID Reserved)
Definition: videoprt.c:1175
NTSYSAPI NTSTATUS NTAPI ZwQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
PVIDEO_PORT_GET_PROC_ADDRESS VideoPortGetProcAddress
Definition: video.h:193
VOID NTAPI IoDisconnectInterrupt(PKINTERRUPT InterruptObject)
Definition: irq.c:140
KSPIN_LOCK HwResetAdaptersLock
Definition: videoprt.c:42
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:156
Status
Definition: gdiplustypes.h:24
ULONGLONG SystemMemorySize
Definition: video.h:195
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
SYSTEM_BASIC_INFORMATION SystemBasicInfo
Definition: perfdata.c:45
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
CHAR POINTER_ALIGNMENT MiniPortDeviceExtension[1]
Definition: videoprt.h:113
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
struct _VIDEO_PORT_CONFIG_INFO VIDEO_PORT_CONFIG_INFO
unsigned char UCHAR
Definition: xmlstorage.h:181
PWSTR DriverRegistryPath
Definition: video.h:194
PDEVICE_OBJECT NextDeviceObject
Definition: videoprt.h:89
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
BOOLEAN NTAPI IntVideoPortSetupInterrupt(IN PDEVICE_OBJECT DeviceObject, IN PVIDEO_PORT_DRIVER_EXTENSION DriverExtension, IN PVIDEO_PORT_CONFIG_INFO ConfigInfo)
Definition: interrupt.c:45
#define NULL
Definition: types.h:112
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
LIST_ENTRY HwResetAdaptersList
LONG VP_STATUS
Definition: video.h:153
UNICODE_STRING RegistryPath
Definition: videoprt.h:90
#define STATUS_SUCCESS
Definition: shellext.h:65
INTERFACE_TYPE AdapterInterfaceType
Definition: videoprt.h:98
#define ERROR_DEV_NOT_EXIST
Definition: dderror.h:8
ULONG BusInterruptVector
Definition: video.h:171
KINTERRUPT_MODE InterruptMode
Definition: video.h:172

Referenced by IntVideoPortPnPStartDevice(), and VideoPortInitialize().

◆ IntVideoPortGetProcAddress()

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

Definition at line 100 of file funclist.c.

103 {
104  ULONG i;
105 
106  TRACE_(VIDEOPRT, "VideoPortGetProcAddress(%s)\n", FunctionName);
107 
108  /* Search by name */
109  for (i = 0; i < ARRAYSIZE(VideoPortExports); i++)
110  {
112  {
113  return (PVOID)VideoPortExports[i].Address;
114  }
115  }
116 
117  ERR_(VIDEOPRT, "VideoPortGetProcAddress: Can't resolve symbol %s\n", FunctionName);
118 
119  return NULL;
120 }
signed char * PCHAR
Definition: retypes.h:7
#define ERR_(ch,...)
Definition: debug.h:156
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define TRACE_(x)
Definition: compat.h:76
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NULL
Definition: types.h:112
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char * FunctionName
Definition: acpixf.h:1274
const VIDEO_PORT_FUNCTION_TABLE VideoPortExports[]
Definition: funclist.c:36
unsigned int ULONG
Definition: retypes.h:1
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

Referenced by IntVideoPortFindAdapter().

◆ IntVideoPortMapPhysicalMemory()

NTSTATUS NTAPI IntVideoPortMapPhysicalMemory ( IN HANDLE  Process,
IN PHYSICAL_ADDRESS  PhysicalAddress,
IN ULONG  SizeInBytes,
IN ULONG  Protect,
IN OUT PVOID *VirtualAddress  OPTIONAL 
)

Definition at line 194 of file resource.c.

200 {
201  OBJECT_ATTRIBUTES ObjAttribs;
203  HANDLE hMemObj;
205  SIZE_T Size;
206 
207  /* Initialize object attribs */
208  RtlInitUnicodeString(&UnicodeString, L"\\Device\\PhysicalMemory");
209  InitializeObjectAttributes(&ObjAttribs,
210  &UnicodeString,
212  NULL, NULL);
213 
214  /* Open physical memory section */
215  Status = ZwOpenSection(&hMemObj, SECTION_ALL_ACCESS, &ObjAttribs);
216  if (!NT_SUCCESS(Status))
217  {
218  WARN_(VIDEOPRT, "ZwOpenSection() failed! (0x%x)\n", Status);
219  return Status;
220  }
221 
222  /* Map view of section */
223  Size = SizeInBytes;
224  Status = ZwMapViewOfSection(hMemObj,
225  Process,
227  0,
228  Size,
230  &Size,
231  ViewUnmap,
232  0,
233  Protect);
234  ZwClose(hMemObj);
235  if (!NT_SUCCESS(Status))
236  {
237  WARN_(VIDEOPRT, "ZwMapViewOfSection() failed! (0x%x)\n", Status);
238  }
239 
240  return Status;
241 }
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T _In_ SECTION_INHERIT _In_ ULONG _In_ ULONG Protect
Definition: zwfuncs.h:214
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
LONG NTSTATUS
Definition: precomp.h:26
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
WDF_EXTERN_C_START typedef _Must_inspect_result_ _In_opt_ PCUNICODE_STRING UnicodeString
Definition: wdfstring.h:64
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define SECTION_ALL_ACCESS
Definition: nt_native.h:1293
#define L(x)
Definition: ntvdm.h:50
_Must_inspect_result_ _In_ WDFDMATRANSACTION _In_ PFN_WDF_PROGRAM_DMA _In_ WDF_DMA_DIRECTION _In_ PMDL _In_ PVOID VirtualAddress
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1098
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
NTSYSAPI NTSTATUS NTAPI ZwOpenSection(_Out_ PHANDLE SectionHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes)
#define WARN_(ch,...)
Definition: debug.h:157

Referenced by IntAgpCommitVirtual(), and IntVideoPortMapMemory().

◆ IntVideoPortSetupInterrupt()

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

Definition at line 45 of file interrupt.c.

49 {
51  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
52 
53  DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
54 
55  /*
56  * MSDN documentation for VIDEO_PORT_CONFIG_INFO states: "If a miniport driver's
57  * HwVidFindAdapter function finds that the video adapter does not generate
58  * interrupts or that it cannot determine a valid interrupt vector/level for
59  * the adapter, HwVidFindAdapter should set both BusInterruptVector and
60  * BusInterruptLevel to zero.
61  */
62 
63  if (DriverExtension->InitializationData.HwInterrupt != NULL &&
64  (ConfigInfo->BusInterruptLevel != 0 ||
65  ConfigInfo->BusInterruptVector != 0))
66  {
67  ULONG InterruptVector;
68  KIRQL Irql;
70 
71  InterruptVector = HalGetInterruptVector(
72  ConfigInfo->AdapterInterfaceType,
73  ConfigInfo->SystemIoBusNumber,
74  ConfigInfo->BusInterruptLevel,
75  ConfigInfo->BusInterruptVector,
76  &Irql,
77  &Affinity);
78 
79  if (InterruptVector == 0)
80  {
81  WARN_(VIDEOPRT, "HalGetInterruptVector failed\n");
82  return FALSE;
83  }
84 
85  KeInitializeSpinLock(&DeviceExtension->InterruptSpinLock);
87  &DeviceExtension->InterruptObject,
89  DeviceExtension,
90  &DeviceExtension->InterruptSpinLock,
91  InterruptVector,
92  Irql,
93  Irql,
94  ConfigInfo->InterruptMode,
95  DeviceExtension->InterruptShared,
96  Affinity,
97  FALSE);
98 
99  if (!NT_SUCCESS(Status))
100  {
101  WARN_(VIDEOPRT, "IoConnectInterrupt failed with status 0x%08x\n", Status);
102  return FALSE;
103  }
104  }
105 
106  return TRUE;
107 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
struct _VIDEO_PORT_DEVICE_EXTENSTION * PVIDEO_PORT_DEVICE_EXTENSION
if(dx==0 &&dy==0)
Definition: linetemp.h:174
_Out_ PKIRQL Irql
Definition: csq.h:179
UCHAR KIRQL
Definition: env_spec_w32.h:591
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define FALSE
Definition: types.h:117
NTSTATUS NTAPI IoConnectInterrupt(OUT PKINTERRUPT *InterruptObject, IN PKSERVICE_ROUTINE ServiceRoutine, IN PVOID ServiceContext, IN PKSPIN_LOCK SpinLock, IN ULONG Vector, IN KIRQL Irql, IN KIRQL SynchronizeIrql, IN KINTERRUPT_MODE InterruptMode, IN BOOLEAN ShareVector, IN KAFFINITY ProcessorEnableMask, IN BOOLEAN FloatingSave)
Definition: irq.c:22
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:238
BOOLEAN NTAPI IntVideoPortInterruptRoutine(IN struct _KINTERRUPT *Interrupt, IN PVOID ServiceContext)
Definition: interrupt.c:32
NTHALAPI ULONG NTAPI HalGetInterruptVector(INTERFACE_TYPE, ULONG, ULONG, ULONG, PKIRQL, PKAFFINITY)
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ ULONG _In_ ULONG _In_ ULONG _Out_ PKIRQL _Out_ PKAFFINITY Affinity
Definition: halfuncs.h:170
ULONG_PTR KAFFINITY
Definition: compat.h:85
#define NULL
Definition: types.h:112
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31
unsigned int ULONG
Definition: retypes.h:1
#define WARN_(ch,...)
Definition: debug.h:157

Referenced by IntVideoPortFindAdapter().

◆ IntVideoPortSetupTimer()

BOOLEAN NTAPI IntVideoPortSetupTimer ( IN PDEVICE_OBJECT  DeviceObject,
IN PVIDEO_PORT_DRIVER_EXTENSION  DriverExtension 
)

Definition at line 43 of file timer.c.

46 {
48  PVIDEO_PORT_DEVICE_EXTENSION DeviceExtension;
49 
50  DeviceExtension = (PVIDEO_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
51 
52  if (DriverExtension->InitializationData.HwTimer != NULL)
53  {
54  INFO_(VIDEOPRT, "Initializing timer\n");
55 
59  DeviceExtension);
60 
61  if (!NT_SUCCESS(Status))
62  {
63  ERR_(VIDEOPRT, "IoInitializeTimer failed with status 0x%08x\n", Status);
64  return FALSE;
65  }
66  }
67 
68  return TRUE;
69 }
#define INFO_(ch,...)
Definition: debug.h:159
#define TRUE
Definition: types.h:120
#define ERR_(ch,...)
Definition: debug.h:156
LONG NTSTATUS
Definition: precomp.h:26
struct _VIDEO_PORT_DEVICE_EXTENSTION * PVIDEO_PORT_DEVICE_EXTENSION
if(dx==0 &&dy==0)
Definition: linetemp.h:174
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define FALSE
Definition: types.h:117
Status
Definition: gdiplustypes.h:24
VOID NTAPI IntVideoPortTimerRoutine(IN PDEVICE_OBJECT DeviceObject, IN PVOID ServiceContext)
Definition: timer.c:30
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI IoInitializeTimer(IN PDEVICE_OBJECT DeviceObject, IN PIO_TIMER_ROUTINE TimerRoutine, IN PVOID Context)
Definition: iotimer.c:92
#define NULL
Definition: types.h:112
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31

Referenced by IntVideoPortFindAdapter().

◆ IntVideoPortUnload()

VOID NTAPI IntVideoPortUnload ( PDRIVER_OBJECT  DriverObject)

Definition at line 1175 of file dispatch.c.

1176 {
1177 }

Referenced by VideoPortInitialize().

◆ IopInitiatePnpIrp()

NTSTATUS IopInitiatePnpIrp ( PDEVICE_OBJECT  DeviceObject,
PIO_STATUS_BLOCK  IoStatusBlock,
UCHAR  MinorFunction,
PIO_STACK_LOCATION Stack  OPTIONAL 
)

Definition at line 30 of file agp.c.

35 {
36  PDEVICE_OBJECT TopDeviceObject;
39  KEVENT Event;
40  PIRP Irp;
41 
42  /* Always call the top of the device stack */
43  TopDeviceObject = IoGetAttachedDeviceReference(DeviceObject);
44 
46  &Event,
48  FALSE);
49 
51  IRP_MJ_PNP,
52  TopDeviceObject,
53  NULL,
54  0,
55  NULL,
56  &Event,
58 
59  /* PNP IRPs are always initialized with a status code of
60  STATUS_NOT_SUPPORTED */
61  Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
62  Irp->IoStatus.Information = 0;
63 
66 
67  if (Stack)
68  {
70  &IrpSp->Parameters,
71  &Stack->Parameters,
72  sizeof(Stack->Parameters));
73  }
74 
75  Status = IoCallDriver(TopDeviceObject, Irp);
76  if (Status == STATUS_PENDING)
77  {
79  &Event,
80  Executive,
81  KernelMode,
82  FALSE,
83  NULL);
85  }
86 
87  ObDereferenceObject(TopDeviceObject);
88 
89  return Status;
90 }
return STATUS_NOT_SUPPORTED
PIRP NTAPI IoBuildSynchronousFsdRequest(IN ULONG MajorFunction, IN PDEVICE_OBJECT DeviceObject, IN PVOID Buffer, IN ULONG Length, IN PLARGE_INTEGER StartingOffset, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:1069
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:636
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
_In_ UCHAR _In_ UCHAR MinorFunction
Definition: wdfdevice.h:1697
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:467
PDEVICE_OBJECT NTAPI IoGetAttachedDeviceReference(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1406
Status
Definition: gdiplustypes.h:24
#define STATUS_PENDING
Definition: ntstatus.h:82
#define ObDereferenceObject
Definition: obfuncs.h:203
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2695
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define NULL
Definition: types.h:112
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128

Referenced by IntAgpGetInterface().

Variable Documentation

◆ CsrProcess

◆ HwResetAdaptersList

◆ HwResetAdaptersLock

KSPIN_LOCK HwResetAdaptersLock

◆ VideoPortDeviceNumber

ULONG VideoPortDeviceNumber

◆ VideoPortInt10Mutex

KMUTEX VideoPortInt10Mutex

Definition at line 41 of file videoprt.c.

Referenced by IntInt10CallBios(), and VideoPortInitialize().