Skip to content

Commit c6b1e89

Browse files
Test
1 parent 3a1871f commit c6b1e89

File tree

7 files changed

+642
-14
lines changed

7 files changed

+642
-14
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#pragma once
2+
3+
#include <string>
4+
#include <chrono>
5+
#include <windows.h>
6+
7+
// Forward declaration for the logging function used throughout the driver
8+
void vddlog(const char* type, const char* message);
9+
10+
// Forward declarations for existing string conversion functions
11+
std::string WStringToString(const std::wstring& wstr);
12+
std::wstring StringToWString(const std::string& str);

Virtual Display Driver (HDR)/MttVDD/Driver.cpp

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ EVT_IDD_CX_MONITOR_QUERY_TARGET_MODES2 VirtualDisplayDriverEvtIddCxMonitorQueryT
7979
EVT_IDD_CX_ADAPTER_COMMIT_MODES2 VirtualDisplayDriverEvtIddCxAdapterCommitModes2;
8080

8181
EVT_IDD_CX_MONITOR_SET_GAMMA_RAMP VirtualDisplayDriverEvtIddCxMonitorSetGammaRamp;
82+
EVT_IDD_CX_DEVICE_IO_CONTROL MttVddEvtIoDeviceControl;
83+
84+
// Forward declaration for IOCTL queue setup function
85+
NTSTATUS SetupIoctlQueue(WDFDEVICE Device);
8286

8387
struct
8488
{
@@ -152,16 +156,7 @@ const char* XorCursorSupportLevelToString(IDDCX_XOR_CURSOR_SUPPORT level) {
152156

153157
vector<unsigned char> Microsoft::IndirectDisp::IndirectDeviceContext::s_KnownMonitorEdid; //Changed to support static vector
154158

155-
struct IndirectDeviceContextWrapper
156-
{
157-
IndirectDeviceContext* pContext;
158159

159-
void Cleanup()
160-
{
161-
delete pContext;
162-
pContext = nullptr;
163-
}
164-
};
165160
void LogQueries(const char* severity, const std::wstring& xmlName) {
166161
if (xmlName.find(L"logging") == std::wstring::npos) {
167162
int size_needed = WideCharToMultiByte(CP_UTF8, 0, xmlName.c_str(), (int)xmlName.size(), NULL, 0, NULL, NULL);
@@ -634,10 +629,6 @@ void InitializeD3DDeviceAndLogGPU() {
634629
vddlog("i", logtext.c_str());
635630
}
636631

637-
638-
// This macro creates the methods for accessing an IndirectDeviceContextWrapper as a context for a WDF object
639-
WDF_DECLARE_CONTEXT_TYPE(IndirectDeviceContextWrapper);
640-
641632
extern "C" BOOL WINAPI DllMain(
642633
_In_ HINSTANCE hInstance,
643634
_In_ UINT dwReason,
@@ -1783,6 +1774,9 @@ NTSTATUS VirtualDisplayDriverDeviceAdd(WDFDRIVER Driver, PWDFDEVICE_INIT pDevice
17831774
IddConfig.EvtIddCxMonitorAssignSwapChain = VirtualDisplayDriverMonitorAssignSwapChain;
17841775
IddConfig.EvtIddCxMonitorUnassignSwapChain = VirtualDisplayDriverMonitorUnassignSwapChain;
17851776

1777+
// Enable IOCTL handling
1778+
IddConfig.EvtIddCxDeviceIoControl = MttVddEvtIoDeviceControl;
1779+
17861780
if (IDD_IS_FIELD_AVAILABLE(IDD_CX_CLIENT_CONFIG, EvtIddCxAdapterQueryTargetInfo))
17871781
{
17881782
IddConfig.EvtIddCxAdapterQueryTargetInfo = VirtualDisplayDriverEvtIddCxAdapterQueryTargetInfo;

Virtual Display Driver (HDR)/MttVDD/Driver.h

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,28 @@
1616
#include <vector>
1717

1818
#include "Trace.h"
19+
#include "mttvdd-ioctl.h"
20+
#include "Common.h"
21+
22+
// Forward declaration for the IndirectDeviceContext class
23+
namespace Microsoft
24+
{
25+
namespace IndirectDisp
26+
{
27+
class IndirectDeviceContext;
28+
}
29+
}
30+
31+
// Forward declarations for driver-defined context type
32+
struct IndirectDeviceContextWrapper
33+
{
34+
Microsoft::IndirectDisp::IndirectDeviceContext* pContext;
35+
36+
void Cleanup(); // Just declare it, don't implement
37+
};
38+
39+
// The WDF context access function is defined by WDF_DECLARE_CONTEXT_TYPE macro
40+
WDF_DECLARE_CONTEXT_TYPE(IndirectDeviceContextWrapper);
1941

2042
namespace Microsoft
2143
{
@@ -85,18 +107,26 @@ namespace Microsoft
85107
void FinishInit();
86108

87109
void CreateMonitor(unsigned int index);
110+
NTSTATUS CreateMonitorWithParams(ULONG Width, ULONG Height, ULONG RefreshRate, GUID* MonitorId);
111+
NTSTATUS DestroyMonitor(ULONG MonitorIndex);
112+
NTSTATUS SetMonitorMode(ULONG MonitorIndex, ULONG Width, ULONG Height, ULONG RefreshRate);
113+
NTSTATUS SetPreferredMode(ULONG MonitorIndex, ULONG Width, ULONG Height, ULONG RefreshRate);
114+
NTSTATUS SetGpuPreference(LUID AdapterLuid);
115+
ULONG GetMonitorCount();
88116

89117
void AssignSwapChain(IDDCX_MONITOR& Monitor, IDDCX_SWAPCHAIN SwapChain, LUID RenderAdapter, HANDLE NewFrameEvent);
90118
void UnassignSwapChain();
91119

92120
protected:
93-
94121
WDFDEVICE m_WdfDevice;
95122
IDDCX_ADAPTER m_Adapter;
96123
IDDCX_MONITOR m_Monitor;
97124
IDDCX_MONITOR m_Monitor2;
98125

99126
std::unique_ptr<SwapChainProcessor> m_ProcessingThread;
127+
128+
// Store a list of connected monitors and their info
129+
std::vector<std::pair<IDDCX_MONITOR, GUID>> m_Monitors;
100130

101131
public:
102132
static const DISPLAYCONFIG_VIDEO_SIGNAL_INFO s_KnownMonitorModes[];
-1.99 KB
Binary file not shown.

Virtual Display Driver (HDR)/MttVDD/MttVDD.vcxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,16 @@
3636
</ItemGroup>
3737
<ItemGroup>
3838
<ClCompile Include="Driver.cpp" />
39+
<ClCompile Include="mttioctl.cpp">
40+
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
41+
</ClCompile>
3942
</ItemGroup>
4043
<ItemGroup>
4144
<ClInclude Include="..\..\..\..\Downloads\wudfwdm.h">
4245
<DeploymentContent>true</DeploymentContent>
4346
</ClInclude>
4447
<ClInclude Include="Driver.h" />
48+
<ClInclude Include="mttvdd-ioctl.h" />
4549
<ClInclude Include="Trace.h" />
4650
</ItemGroup>
4751
<ItemGroup>

0 commit comments

Comments
 (0)