[Spice-devel] [PATCH qxl-wddm-dod v5 2/7] Code Analysis fix

Sameeh Jubran sameeh at daynix.com
Mon Sep 26 13:00:06 UTC 2016


The PAGED_CODE macro ensures that the calling thread is running at an
IRQL that is low enough to permit paging. A call to this macro should
be made at the beginning of every driver routine that either contains
pageable code or accesses pageable code.

Based on a patch by Sandy Stutsman <sstutsma at redhat.com>

Signed-off-by: Sameeh Jubran <sameeh at daynix.com>
---
 qxldod/QxlDod.cpp | 224 ++++++++++++++++++++++++++++++++++++++++++++++++------
 qxldod/QxlDod.h   | 149 ++++++++++++++++++++++++++++++++++--
 2 files changed, 344 insertions(+), 29 deletions(-)

diff --git a/qxldod/QxlDod.cpp b/qxldod/QxlDod.cpp
index 798b2f0..136daf7 100755
--- a/qxldod/QxlDod.cpp
+++ b/qxldod/QxlDod.cpp
@@ -2,8 +2,6 @@
 #include "qxldod.h"
 #include "qxl_windows.h"
 
-#pragma code_seg(push)
-#pragma code_seg()
 
 #define WIN_QXL_INT_MASK ((QXL_INTERRUPT_DISPLAY) | \
                           (QXL_INTERRUPT_CURSOR) | \
@@ -47,7 +45,6 @@ BYTE PixelMask[BITS_PER_BYTE]  = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01
                                        ((ULONG)LOWER_5_BITS((Pixel)) << SHIFT_LOWER_5_IN_565_BACK))
 
 
-#pragma code_seg(pop)
 
 struct QXLEscape {
     uint32_t ioctl;
@@ -57,10 +54,12 @@ struct QXLEscape {
     };
 };
 
+__declspec(code_seg("PAGE"))
 QxlDod::QxlDod(_In_ DEVICE_OBJECT* pPhysicalDeviceObject) : m_pPhysicalDevice(pPhysicalDeviceObject),
                                                             m_MonitorPowerState(PowerDeviceD0),
                                                             m_AdapterPowerState(PowerDeviceD0)
 {
+    PAGED_CODE();
     DbgPrint(TRACE_LEVEL_INFORMATION, ("---> %s\n", __FUNCTION__));
     *((UINT*)&m_Flags) = 0;
     RtlZeroMemory(&m_DxgkInterface, sizeof(m_DxgkInterface));
@@ -71,7 +70,7 @@ QxlDod::QxlDod(_In_ DEVICE_OBJECT* pPhysicalDeviceObject) : m_pPhysicalDevice(pP
     DbgPrint(TRACE_LEVEL_INFORMATION, ("<--- %s\n", __FUNCTION__));
 }
 
-
+__declspec(code_seg("PAGE"))
 QxlDod::~QxlDod(void)
 {
     PAGED_CODE();
@@ -80,6 +79,7 @@ QxlDod::~QxlDod(void)
     m_pHWDevice = NULL;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDod::CheckHardware()
 {
     PAGED_CODE();
@@ -117,6 +117,7 @@ NTSTATUS QxlDod::CheckHardware()
     return Status;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDod::StartDevice(_In_  DXGK_START_INFO*   pDxgkStartInfo,
                          _In_  DXGKRNL_INTERFACE* pDxgkInterface,
                          _Out_ ULONG*             pNumberOfViews,
@@ -207,6 +208,7 @@ NTSTATUS QxlDod::StartDevice(_In_  DXGK_START_INFO*   pDxgkStartInfo,
     return STATUS_SUCCESS;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDod::StopDevice(VOID)
 {
     PAGED_CODE();
@@ -214,6 +216,7 @@ NTSTATUS QxlDod::StopDevice(VOID)
     return STATUS_SUCCESS;
 }
 
+__declspec(code_seg("PAGE"))
 VOID QxlDod::CleanUp(VOID)
 {
     PAGED_CODE();
@@ -228,7 +231,7 @@ VOID QxlDod::CleanUp(VOID)
     }
 }
 
-
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDod::DispatchIoRequest(_In_  ULONG VidPnSourceId,
                                    _In_  VIDEO_REQUEST_PACKET* pVideoRequestPacket)
 {
@@ -240,11 +243,13 @@ NTSTATUS QxlDod::DispatchIoRequest(_In_  ULONG VidPnSourceId,
     return STATUS_SUCCESS;
 }
 
+__declspec(code_seg("PAGE"))
 PCHAR
 DbgDevicePowerString(
     __in DEVICE_POWER_STATE Type
     )
 {
+    PAGED_CODE();
     switch (Type)
     {
     case PowerDeviceUnspecified:
@@ -264,11 +269,13 @@ DbgDevicePowerString(
     }
 }
 
+__declspec(code_seg("PAGE"))
 PCHAR
 DbgPowerActionString(
     __in POWER_ACTION Type
     )
 {
+    PAGED_CODE();
     switch (Type)
     {
     case PowerActionNone:
@@ -292,6 +299,7 @@ DbgPowerActionString(
     }
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDod::SetPowerState(_In_  ULONG HardwareUid,
                                _In_  DEVICE_POWER_STATE DevicePowerState,
                                _In_  POWER_ACTION       ActionType)
@@ -325,6 +333,7 @@ NTSTATUS QxlDod::SetPowerState(_In_  ULONG HardwareUid,
     return Status;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDod::QueryChildRelations(_Out_writes_bytes_(ChildRelationsSize) DXGK_CHILD_DESCRIPTOR* pChildRelations,
                                      _In_  ULONG  ChildRelationsSize)
 {
@@ -354,6 +363,7 @@ NTSTATUS QxlDod::QueryChildRelations(_Out_writes_bytes_(ChildRelationsSize) DXGK
     return STATUS_SUCCESS;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDod::QueryChildStatus(_Inout_ DXGK_CHILD_STATUS* pChildStatus,
                                                 _In_    BOOLEAN            NonDestructiveOnly)
 {
@@ -389,6 +399,7 @@ NTSTATUS QxlDod::QueryChildStatus(_Inout_ DXGK_CHILD_STATUS* pChildStatus,
 }
 
 // EDID retrieval
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDod::QueryDeviceDescriptor(_In_    ULONG                   ChildUid,
                                        _Inout_ DXGK_DEVICE_DESCRIPTOR* pDeviceDescriptor)
 {
@@ -401,6 +412,7 @@ NTSTATUS QxlDod::QueryDeviceDescriptor(_In_    ULONG                   ChildUid,
     return STATUS_MONITOR_NO_MORE_DESCRIPTOR_DATA;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDod::QueryAdapterInfo(_In_ CONST DXGKARG_QUERYADAPTERINFO* pQueryAdapterInfo)
 {
     PAGED_CODE();
@@ -445,6 +457,7 @@ NTSTATUS QxlDod::QueryAdapterInfo(_In_ CONST DXGKARG_QUERYADAPTERINFO* pQueryAda
     }
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDod::SetPointerPosition(_In_ CONST DXGKARG_SETPOINTERPOSITION* pSetPointerPosition)
 {
     PAGED_CODE();
@@ -463,6 +476,7 @@ NTSTATUS QxlDod::SetPointerPosition(_In_ CONST DXGKARG_SETPOINTERPOSITION* pSetP
 
 // Basic Sample Display Driver does not support hardware cursors, and reports such
 // in QueryAdapterInfo. Therefore this function should never be called.
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDod::SetPointerShape(_In_ CONST DXGKARG_SETPOINTERSHAPE* pSetPointerShape)
 {
     PAGED_CODE();
@@ -473,6 +487,7 @@ NTSTATUS QxlDod::SetPointerShape(_In_ CONST DXGKARG_SETPOINTERSHAPE* pSetPointer
     return m_pHWDevice->SetPointerShape(pSetPointerShape);
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDod::Escape(_In_ CONST DXGKARG_ESCAPE* pEscape)
 {
     PAGED_CODE();
@@ -486,7 +501,7 @@ NTSTATUS QxlDod::Escape(_In_ CONST DXGKARG_ESCAPE* pEscape)
     return Status;
 }
 
-
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDod::PresentDisplayOnly(_In_ CONST DXGKARG_PRESENT_DISPLAYONLY* pPresentDisplayOnly)
 {
     PAGED_CODE();
@@ -548,6 +563,7 @@ NTSTATUS QxlDod::PresentDisplayOnly(_In_ CONST DXGKARG_PRESENT_DISPLAYONLY* pPre
     return Status;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDod::QueryInterface(_In_ CONST PQUERY_INTERFACE pQueryInterface)
 {
     PAGED_CODE();
@@ -558,6 +574,7 @@ NTSTATUS QxlDod::QueryInterface(_In_ CONST PQUERY_INTERFACE pQueryInterface)
     return STATUS_NOT_SUPPORTED;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDod::StopDeviceAndReleasePostDisplayOwnership(_In_  D3DDDI_VIDEO_PRESENT_TARGET_ID TargetId,
                                                           _Out_ DXGK_DISPLAY_INFORMATION*      pDisplayInfo)
 {
@@ -582,7 +599,7 @@ NTSTATUS QxlDod::StopDeviceAndReleasePostDisplayOwnership(_In_  D3DDDI_VIDEO_PRE
     return StopDevice();
 }
 
-
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDod::QueryVidPnHWCapability(_Inout_ DXGKARG_QUERYVIDPNHWCAPABILITY* pVidPnHWCaps)
 {
     PAGED_CODE();
@@ -606,6 +623,7 @@ NTSTATUS QxlDod::QueryVidPnHWCapability(_Inout_ DXGKARG_QUERYVIDPNHWCAPABILITY*
 
 
 // TODO: Need to also check pinned modes and the path parameters, not just topology
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDod::IsSupportedVidPn(_Inout_ DXGKARG_ISSUPPORTEDVIDPN* pIsSupportedVidPn)
 {
     PAGED_CODE();
@@ -668,6 +686,7 @@ NTSTATUS QxlDod::IsSupportedVidPn(_Inout_ DXGKARG_ISSUPPORTEDVIDPN* pIsSupported
     return STATUS_SUCCESS;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDod::RecommendFunctionalVidPn(_In_ CONST DXGKARG_RECOMMENDFUNCTIONALVIDPN* CONST pRecommendFunctionalVidPn)
 {
     PAGED_CODE();
@@ -678,6 +697,7 @@ NTSTATUS QxlDod::RecommendFunctionalVidPn(_In_ CONST DXGKARG_RECOMMENDFUNCTIONAL
     return STATUS_GRAPHICS_NO_RECOMMENDED_FUNCTIONAL_VIDPN;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDod::RecommendVidPnTopology(_In_ CONST DXGKARG_RECOMMENDVIDPNTOPOLOGY* CONST pRecommendVidPnTopology)
 {
     PAGED_CODE();
@@ -688,6 +708,7 @@ NTSTATUS QxlDod::RecommendVidPnTopology(_In_ CONST DXGKARG_RECOMMENDVIDPNTOPOLOG
     return STATUS_GRAPHICS_NO_RECOMMENDED_FUNCTIONAL_VIDPN;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDod::RecommendMonitorModes(_In_ CONST DXGKARG_RECOMMENDMONITORMODES* CONST pRecommendMonitorModes)
 {
     PAGED_CODE();
@@ -696,7 +717,7 @@ NTSTATUS QxlDod::RecommendMonitorModes(_In_ CONST DXGKARG_RECOMMENDMONITORMODES*
     return AddSingleMonitorMode(pRecommendMonitorModes);
 }
 
-
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDod::AddSingleSourceMode(_In_ CONST DXGK_VIDPNSOURCEMODESET_INTERFACE* pVidPnSourceModeSetInterface,
                                                    D3DKMDT_HVIDPNSOURCEMODESET hVidPnSourceModeSet,
                                                    D3DDDI_VIDEO_PRESENT_SOURCE_ID SourceId)
@@ -753,6 +774,7 @@ NTSTATUS QxlDod::AddSingleSourceMode(_In_ CONST DXGK_VIDPNSOURCEMODESET_INTERFAC
 }
 
 // Add the current mode information (acquired from the POST frame buffer) as the target mode.
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDod::AddSingleTargetMode(_In_ CONST DXGK_VIDPNTARGETMODESET_INTERFACE* pVidPnTargetModeSetInterface,
                                                    D3DKMDT_HVIDPNTARGETMODESET hVidPnTargetModeSet,
                                                    _In_opt_ CONST D3DKMDT_VIDPN_SOURCE_MODE* pVidPnPinnedSourceModeInfo,
@@ -805,7 +827,7 @@ NTSTATUS QxlDod::AddSingleTargetMode(_In_ CONST DXGK_VIDPNTARGETMODESET_INTERFAC
     return STATUS_SUCCESS;
 }
 
-
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDod::AddSingleMonitorMode(_In_ CONST DXGKARG_RECOMMENDMONITORMODES* CONST pRecommendMonitorModes)
 {
     PAGED_CODE();
@@ -925,6 +947,7 @@ NTSTATUS QxlDod::AddSingleMonitorMode(_In_ CONST DXGKARG_RECOMMENDMONITORMODES*
 }
 
 // Tell DMM about all the modes, etc. that are supported
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDod::EnumVidPnCofuncModality(_In_ CONST DXGKARG_ENUMVIDPNCOFUNCMODALITY* CONST pEnumCofuncModality)
 {
     PAGED_CODE();
@@ -1283,6 +1306,7 @@ NTSTATUS QxlDod::EnumVidPnCofuncModality(_In_ CONST DXGKARG_ENUMVIDPNCOFUNCMODAL
     return Status;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDod::SetVidPnSourceVisibility(_In_ CONST DXGKARG_SETVIDPNSOURCEVISIBILITY* pSetVidPnSourceVisibility)
 {
     PAGED_CODE();
@@ -1315,6 +1339,7 @@ NTSTATUS QxlDod::SetVidPnSourceVisibility(_In_ CONST DXGKARG_SETVIDPNSOURCEVISIB
 
 // NOTE: The value of pCommitVidPn->MonitorConnectivityChecks is ignored, since BDD is unable to recognize whether a monitor is connected or not
 // The value of pCommitVidPn->hPrimaryAllocation is also ignored, since BDD is a display only driver and does not deal with allocations
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDod::CommitVidPn(_In_ CONST DXGKARG_COMMITVIDPN* CONST pCommitVidPn)
 {
     PAGED_CODE();
@@ -1473,7 +1498,7 @@ NTSTATUS QxlDod::CommitVidPn(_In_ CONST DXGKARG_COMMITVIDPN* CONST pCommitVidPn)
 
 CommitVidPnExit:
 
-    NTSTATUS TempStatus;
+    NTSTATUS TempStatus(STATUS_SUCCESS);
     UNREFERENCED_PARAMETER(TempStatus);
 
     if ((pVidPnSourceModeSetInterface != NULL) &&
@@ -1504,6 +1529,7 @@ CommitVidPnExit:
     return Status;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDod::SetSourceModeAndPath(CONST D3DKMDT_VIDPN_SOURCE_MODE* pSourceMode,
                                                     CONST D3DKMDT_VIDPN_PRESENT_PATH* pPath)
 {
@@ -1559,6 +1585,7 @@ NTSTATUS QxlDod::SetSourceModeAndPath(CONST D3DKMDT_VIDPN_SOURCE_MODE* pSourceMo
     return Status;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDod::IsVidPnPathFieldsValid(CONST D3DKMDT_VIDPN_PRESENT_PATH* pPath) const
 {
     PAGED_CODE();
@@ -1607,6 +1634,7 @@ NTSTATUS QxlDod::IsVidPnPathFieldsValid(CONST D3DKMDT_VIDPN_PRESENT_PATH* pPath)
     return STATUS_SUCCESS;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDod::IsVidPnSourceModeFieldsValid(CONST D3DKMDT_VIDPN_SOURCE_MODE* pSourceMode) const
 {
     PAGED_CODE();
@@ -1638,6 +1666,7 @@ NTSTATUS QxlDod::IsVidPnSourceModeFieldsValid(CONST D3DKMDT_VIDPN_SOURCE_MODE* p
     return STATUS_GRAPHICS_INVALID_VIDEO_PRESENT_SOURCE_MODE;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDod::UpdateActiveVidPnPresentPath(_In_ CONST DXGKARG_UPDATEACTIVEVIDPNPRESENTPATH* CONST pUpdateActiveVidPnPresentPath)
 {
     PAGED_CODE();
@@ -1663,8 +1692,6 @@ NTSTATUS QxlDod::UpdateActiveVidPnPresentPath(_In_ CONST DXGKARG_UPDATEACTIVEVID
 //
 // Non-Paged Code
 //
-#pragma code_seg(push)
-#pragma code_seg()
 
 VOID QxlDod::DpcRoutine(VOID)
 {
@@ -1789,8 +1816,8 @@ VOID QxlDod::SystemDisplayWrite(_In_reads_bytes_(SourceHeight * SourceStride) VO
 
 }
 
-#pragma code_seg(pop) // End Non-Paged Code
 
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDod::WriteHWInfoStr(_In_ HANDLE DevInstRegKeyHandle, _In_ PCWSTR pszwValueName, _In_ PCSTR pszValue)
 {
     PAGED_CODE();
@@ -1834,7 +1861,8 @@ NTSTATUS QxlDod::WriteHWInfoStr(_In_ HANDLE DevInstRegKeyHandle, _In_ PCWSTR psz
     return Status;
 }
 
-NTSTATUS QxlDod::RegisterHWInfo(ULONG Id)
+__declspec(code_seg("PAGE"))
+NTSTATUS QxlDod::RegisterHWInfo(_In_ ULONG Id)
 {
     PAGED_CODE();
 
@@ -1913,6 +1941,7 @@ NTSTATUS QxlDod::RegisterHWInfo(ULONG Id)
     return Status;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDod::ReadConfiguration()
 {
     PAGED_CODE();
@@ -1967,8 +1996,6 @@ NTSTATUS QxlDod::ReadConfiguration()
 //
 // Non-Paged Code
 //
-#pragma code_seg(push)
-#pragma code_seg()
 D3DDDI_VIDEO_PRESENT_SOURCE_ID QxlDod::FindSourceForTarget(D3DDDI_VIDEO_PRESENT_TARGET_ID TargetId, BOOLEAN DefaultToZero)
 {
     UNREFERENCED_PARAMETER(TargetId);
@@ -1983,12 +2010,10 @@ D3DDDI_VIDEO_PRESENT_SOURCE_ID QxlDod::FindSourceForTarget(D3DDDI_VIDEO_PRESENT_
     return DefaultToZero ? 0 : D3DDDI_ID_UNINITIALIZED;
 }
 
-#pragma code_seg(pop) // End Non-Paged Code
-
 //
 // Frame buffer map/unmap
 //
-
+__declspec(code_seg("PAGE"))
 NTSTATUS
 MapFrameBuffer(
     _In_                       PHYSICAL_ADDRESS    PhysicalAddress,
@@ -2041,6 +2066,7 @@ MapFrameBuffer(
     return STATUS_SUCCESS;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS
 UnmapFrameBuffer(
     _In_reads_bytes_(Length) VOID* VirtualAddress,
@@ -2343,8 +2369,10 @@ VOID BltBits (
     }
 }
 
+__declspec(code_seg("PAGE"))
 VgaDevice::VgaDevice(_In_ QxlDod* pQxlDod)
 {
+    PAGED_CODE();
     m_pQxlDod = pQxlDod;
     m_ModeInfo = NULL;
     m_ModeCount = 0;
@@ -2353,8 +2381,10 @@ VgaDevice::VgaDevice(_In_ QxlDod* pQxlDod)
     m_Id = 0;
 }
 
+__declspec(code_seg("PAGE"))
 VgaDevice::~VgaDevice(void)
 {
+    PAGED_CODE();
     HWClose();
     delete [] reinterpret_cast<BYTE*>(m_ModeInfo);
     delete [] reinterpret_cast<BYTE*>(m_ModeNumbers);
@@ -2365,6 +2395,7 @@ VgaDevice::~VgaDevice(void)
     m_Id = 0;
 }
 
+__declspec(code_seg("PAGE"))
 BOOL VgaDevice::SetVideoModeInfo(UINT Idx, PVBE_MODEINFO pModeInfo)
 {
     PVIDEO_MODE_INFORMATION pMode = NULL;
@@ -2402,6 +2433,7 @@ BOOL VgaDevice::SetVideoModeInfo(UINT Idx, PVBE_MODEINFO pModeInfo)
     return TRUE;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS VgaDevice::GetModeList(DXGK_DISPLAY_INFORMATION* pDispInfo)
 {
     PAGED_CODE();
@@ -2593,8 +2625,10 @@ NTSTATUS VgaDevice::GetModeList(DXGK_DISPLAY_INFORMATION* pDispInfo)
     return Status;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS VgaDevice::QueryCurrentMode(PVIDEO_MODE RequestedMode)
 {
+    PAGED_CODE();
     DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__));
     NTSTATUS Status = STATUS_SUCCESS;
     UNREFERENCED_PARAMETER(RequestedMode);
@@ -2602,8 +2636,11 @@ NTSTATUS VgaDevice::QueryCurrentMode(PVIDEO_MODE RequestedMode)
     return Status;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS VgaDevice::SetCurrentMode(ULONG Mode)
 {
+    PAGED_CODE();
+
     NTSTATUS Status = STATUS_SUCCESS;
     DbgPrint(TRACE_LEVEL_INFORMATION, ("---> %s Mode = %x\n", __FUNCTION__, Mode));
     X86BIOS_REGISTERS regs = {0};
@@ -2618,8 +2655,11 @@ NTSTATUS VgaDevice::SetCurrentMode(ULONG Mode)
     return Status;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS VgaDevice::GetCurrentMode(ULONG* pMode)
 {
+    PAGED_CODE();
+
     NTSTATUS Status = STATUS_SUCCESS;
     DbgPrint(TRACE_LEVEL_INFORMATION, ("---> %s\n", __FUNCTION__));
     X86BIOS_REGISTERS regs = {0};
@@ -2634,8 +2674,11 @@ NTSTATUS VgaDevice::GetCurrentMode(ULONG* pMode)
     return Status;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS VgaDevice::HWInit(PCM_RESOURCE_LIST pResList, DXGK_DISPLAY_INFORMATION* pDispInfo)
 {
+    PAGED_CODE();
+
     DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__));
     UNREFERENCED_PARAMETER(pResList);
     UNREFERENCED_PARAMETER(pDispInfo);
@@ -2643,15 +2686,21 @@ NTSTATUS VgaDevice::HWInit(PCM_RESOURCE_LIST pResList, DXGK_DISPLAY_INFORMATION*
     return GetModeList(pDispInfo);
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS VgaDevice::HWClose(void)
 {
+    PAGED_CODE();
+
     DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__));
     DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__));
     return STATUS_SUCCESS;
 }
 
-NTSTATUS VgaDevice::SetPowerState(_In_  DEVICE_POWER_STATE DevicePowerState, DXGK_DISPLAY_INFORMATION* pDispInfo)
+__declspec(code_seg("PAGE"))
+NTSTATUS VgaDevice::SetPowerState(DEVICE_POWER_STATE DevicePowerState, DXGK_DISPLAY_INFORMATION* pDispInfo)
 {
+    PAGED_CODE();
+
     DbgPrint(TRACE_LEVEL_INFORMATION, ("---> %s\n", __FUNCTION__));
 
     X86BIOS_REGISTERS regs = {0};
@@ -2674,7 +2723,7 @@ NTSTATUS VgaDevice::SetPowerState(_In_  DEVICE_POWER_STATE DevicePowerState, DXG
     return STATUS_SUCCESS;
 }
 
-
+__declspec(code_seg("PAGE"))
 NTSTATUS
 VgaDevice::ExecutePresentDisplayOnly(
     _In_ BYTE*             DstAddr,
@@ -2876,6 +2925,7 @@ VgaDevice::ExecutePresentDisplayOnly(
     return STATUS_SUCCESS;
 }
 
+__declspec(code_seg("PAGE"))
 VOID VgaDevice::BlackOutScreen(CURRENT_BDD_MODE* pCurrentBddMod)
 {
     PAGED_CODE();
@@ -2941,27 +2991,35 @@ VOID VgaDevice::ResetDevice(VOID)
 {
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS  VgaDevice::SetPointerShape(_In_ CONST DXGKARG_SETPOINTERSHAPE* pSetPointerShape)
 {
+    PAGED_CODE();
     UNREFERENCED_PARAMETER(pSetPointerShape);
     return STATUS_NOT_SUPPORTED;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS VgaDevice::SetPointerPosition(_In_ CONST DXGKARG_SETPOINTERPOSITION* pSetPointerPosition)
 {
+    PAGED_CODE();
     UNREFERENCED_PARAMETER(pSetPointerPosition);
     return STATUS_SUCCESS;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS VgaDevice::Escape(_In_ CONST DXGKARG_ESCAPE* pEscap)
 {
+    PAGED_CODE();
     DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__));
     DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__));
     return STATUS_NOT_IMPLEMENTED;
 }
 
+__declspec(code_seg("PAGE"))
 QxlDevice::QxlDevice(_In_ QxlDod* pQxlDod)
 {
+    PAGED_CODE();
     m_pQxlDod = pQxlDod;
     m_ModeInfo = NULL;
     m_ModeCount = 0;
@@ -2972,8 +3030,10 @@ QxlDevice::QxlDevice(_In_ QxlDod* pQxlDod)
     m_Pending = 0;
 }
 
+__declspec(code_seg("PAGE"))
 QxlDevice::~QxlDevice(void)
 {
+    PAGED_CODE();
     HWClose();
     delete [] reinterpret_cast<BYTE*>(m_ModeInfo);
     delete [] reinterpret_cast<BYTE*>(m_ModeNumbers);
@@ -2983,6 +3043,7 @@ QxlDevice::~QxlDevice(void)
     m_ModeCount = 0;
 }
 
+__declspec(code_seg("PAGE"))
 BOOL QxlDevice::SetVideoModeInfo(UINT Idx, QXLMode* pModeInfo)
 {
     PVIDEO_MODE_INFORMATION pMode = NULL;
@@ -3016,6 +3077,7 @@ BOOL QxlDevice::SetVideoModeInfo(UINT Idx, QXLMode* pModeInfo)
     return TRUE;
 }
 
+__declspec(code_seg("PAGE"))
 void QxlDevice::UpdateVideoModeInfo(UINT Idx, UINT xres, UINT yres, UINT bpp)
 {
     PVIDEO_MODE_INFORMATION pMode = NULL;
@@ -3038,6 +3100,7 @@ void QxlDevice::UpdateVideoModeInfo(UINT Idx, UINT xres, UINT yres, UINT bpp)
     pMode->RedMask = pMode->GreenMask << color_bits;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDevice::GetModeList(DXGK_DISPLAY_INFORMATION* pDispInfo)
 {
     PAGED_CODE();
@@ -3145,14 +3208,17 @@ NTSTATUS QxlDevice::GetModeList(DXGK_DISPLAY_INFORMATION* pDispInfo)
     return Status;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDevice::QueryCurrentMode(PVIDEO_MODE RequestedMode)
 {
+    PAGED_CODE();
     DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__));
     NTSTATUS Status = STATUS_SUCCESS;
     UNREFERENCED_PARAMETER(RequestedMode);
     return Status;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDevice::SetCurrentMode(ULONG Mode)
 {
     PAGED_CODE();
@@ -3173,6 +3239,7 @@ NTSTATUS QxlDevice::SetCurrentMode(ULONG Mode)
     return STATUS_UNSUCCESSFUL;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDevice::GetCurrentMode(ULONG* pMode)
 {
     PAGED_CODE();
@@ -3183,8 +3250,10 @@ NTSTATUS QxlDevice::GetCurrentMode(ULONG* pMode)
     return Status;
 }
 
-NTSTATUS QxlDevice::SetPowerState(_In_ DEVICE_POWER_STATE DevicePowerState, DXGK_DISPLAY_INFORMATION* pDispInfo)
+__declspec(code_seg("PAGE"))
+NTSTATUS QxlDevice::SetPowerState(DEVICE_POWER_STATE DevicePowerState, DXGK_DISPLAY_INFORMATION* pDispInfo)
 {
+    PAGED_CODE();
     DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__));
     switch (DevicePowerState)
     {
@@ -3198,8 +3267,10 @@ NTSTATUS QxlDevice::SetPowerState(_In_ DEVICE_POWER_STATE DevicePowerState, DXGK
     return STATUS_SUCCESS;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDevice::HWInit(PCM_RESOURCE_LIST pResList, DXGK_DISPLAY_INFORMATION* pDispInfo)
 {
+    PAGED_CODE();
     DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__));
     PDXGKRNL_INTERFACE pDxgkInterface = m_pQxlDod->GetDxgkInterface();
     UINT pci_range = QXL_RAM_RANGE_INDEX;
@@ -3345,8 +3416,10 @@ NTSTATUS QxlDevice::HWInit(PCM_RESOURCE_LIST pResList, DXGK_DISPLAY_INFORMATION*
     return QxlInit(pDispInfo);
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDevice::QxlInit(DXGK_DISPLAY_INFORMATION* pDispInfo)
 {
+    PAGED_CODE();
     NTSTATUS Status = STATUS_SUCCESS;
 
     if (!InitMemSlots()) {
@@ -3372,13 +3445,17 @@ NTSTATUS QxlDevice::QxlInit(DXGK_DISPLAY_INFORMATION* pDispInfo)
     return Status;
 }
 
+__declspec(code_seg("PAGE"))
 void QxlDevice::QxlClose()
 {
+    PAGED_CODE();
     DestroyMemSlots();
 }
 
+__declspec(code_seg("PAGE"))
 void QxlDevice::UnmapMemory(void)
 {
+    PAGED_CODE();
     PDXGKRNL_INTERFACE pDxgkInterface = m_pQxlDod->GetDxgkInterface();
     if (m_IoMapped && m_IoBase)
     {
@@ -3404,8 +3481,10 @@ void QxlDevice::UnmapMemory(void)
     }
 }
 
+__declspec(code_seg("PAGE"))
 BOOL QxlDevice::InitMemSlots(void)
 {
+    PAGED_CODE();
     DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__));
     m_NumMemSlots = m_RomHdr->slots_end;
     m_SlotGenBits = m_RomHdr->slot_gen_bits;
@@ -3423,14 +3502,17 @@ BOOL QxlDevice::InitMemSlots(void)
     return FALSE;
 }
 
+__declspec(code_seg("PAGE"))
 void QxlDevice::DestroyMemSlots(void)
 {
+    PAGED_CODE();
     DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__));
     delete [] reinterpret_cast<BYTE*>(m_MemSlots);
     m_MemSlots = NULL;
     DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__));
 }
 
+__declspec(code_seg("PAGE"))
 void QxlDevice::CreatePrimarySurface(PVIDEO_MODE_INFORMATION pModeInfo)
 {
     PAGED_CODE();
@@ -3454,23 +3536,29 @@ void QxlDevice::CreatePrimarySurface(PVIDEO_MODE_INFORMATION pModeInfo)
     DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__));
 }
 
+__declspec(code_seg("PAGE"))
 void QxlDevice::DestroyPrimarySurface(void)
 {
+    PAGED_CODE();
     DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__));
 //    AsyncIo(QXL_IO_DESTROY_PRIMARY_ASYNC, 0);
     SyncIo(QXL_IO_DESTROY_PRIMARY, 0);
     DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__));
 }
 
+__declspec(code_seg("PAGE"))
 _inline QXLPHYSICAL QxlDevice::PA(PVOID virt, UINT8 slot_id)
 {
+    PAGED_CODE();
     DbgPrint(TRACE_LEVEL_VERBOSE, ("<--> %s\n", __FUNCTION__));
     MemSlot *pSlot = &m_MemSlots[slot_id];
     return pSlot->high_bits | ((UINT64)virt - pSlot->start_virt_addr);
 }
 
+__declspec(code_seg("PAGE"))
 _inline UINT64 QxlDevice::VA(QXLPHYSICAL paddr, UINT8 slot_id)
 {
+    PAGED_CODE();
     UINT64 virt;
     MemSlot *pSlot = &m_MemSlots[slot_id];
 
@@ -3481,8 +3569,10 @@ _inline UINT64 QxlDevice::VA(QXLPHYSICAL paddr, UINT8 slot_id)
     return virt;
 }
 
+__declspec(code_seg("PAGE"))
 void QxlDevice::SetupHWSlot(UINT8 Idx, MemSlot *pSlot)
 {
+    PAGED_CODE();
     DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__));
     m_RamHdr->mem_slot.mem_start = pSlot->start_phys_addr;
     m_RamHdr->mem_slot.mem_end = pSlot->end_phys_addr;
@@ -3490,8 +3580,10 @@ void QxlDevice::SetupHWSlot(UINT8 Idx, MemSlot *pSlot)
     DbgPrint(TRACE_LEVEL_VERBOSE, ("<---> %s\n", __FUNCTION__));
 }
 
+__declspec(code_seg("PAGE"))
 BOOL QxlDevice::CreateEvents()
 {
+    PAGED_CODE();
     DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__));
     KeInitializeEvent(&m_DisplayEvent,
                       SynchronizationEvent,
@@ -3511,8 +3603,10 @@ BOOL QxlDevice::CreateEvents()
     return TRUE;
 }
 
+__declspec(code_seg("PAGE"))
 BOOL QxlDevice::CreateRings()
 {
+    PAGED_CODE();
     DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__));
     m_CommandRing = &(m_RamHdr->cmd_ring);
     m_CursorRing = &(m_RamHdr->cursor_ring);
@@ -3521,8 +3615,10 @@ BOOL QxlDevice::CreateRings()
     return TRUE;
 }
 
+__declspec(code_seg("PAGE"))
 void QxlDevice::AsyncIo(UCHAR  Port, UCHAR Value)
 {
+    PAGED_CODE();
     LARGE_INTEGER timeout;
     BOOLEAN locked = FALSE;
     locked = WaitForObject(&m_IoLock, NULL);
@@ -3532,16 +3628,20 @@ void QxlDevice::AsyncIo(UCHAR  Port, UCHAR Value)
     ReleaseMutex(&m_IoLock, locked);
 }
 
+__declspec(code_seg("PAGE"))
 void QxlDevice::SyncIo(UCHAR  Port, UCHAR Value)
 {
+    PAGED_CODE();
     BOOLEAN locked = FALSE;
     locked = WaitForObject(&m_IoLock, NULL);
     WRITE_PORT_UCHAR(m_IoBase + Port, Value);
     ReleaseMutex(&m_IoLock, locked);
 }
 
+__declspec(code_seg("PAGE"))
 UINT8 QxlDevice::SetupMemSlot(UINT8 Idx, UINT64 pastart, UINT64 paend, UINT64 vastart, UINT64 vaend)
 {
+    PAGED_CODE();
     UINT64 high_bits;
     MemSlot *pSlot;
     UINT8 slot_index;
@@ -3565,8 +3665,10 @@ UINT8 QxlDevice::SetupMemSlot(UINT8 Idx, UINT64 pastart, UINT64 paend, UINT64 va
     return slot_index;
 }
 
+__declspec(code_seg("PAGE"))
 BOOL QxlDevice::CreateMemSlots(void)
 {
+    PAGED_CODE();
     DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s 3\n", __FUNCTION__));
     UINT64 len = m_RomHdr->surface0_area_size + m_RomHdr->num_pages * PAGE_SIZE;
     m_MainMemSlot = SetupMemSlot(0,
@@ -3584,6 +3686,7 @@ BOOL QxlDevice::CreateMemSlots(void)
     return TRUE;
 }
 
+__declspec(code_seg("PAGE"))
 void QxlDevice::InitDeviceMemoryResources(void)
 {
     PAGED_CODE();
@@ -3593,6 +3696,7 @@ void QxlDevice::InitDeviceMemoryResources(void)
     DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__));
 }
 
+__declspec(code_seg("PAGE"))
 void QxlDevice::InitMonitorConfig(void)
 {
     PAGED_CODE();
@@ -3604,8 +3708,10 @@ void QxlDevice::InitMonitorConfig(void)
     *m_monitor_config_pa = PA(m_monitor_config, m_MainMemSlot);
 }
 
+__declspec(code_seg("PAGE"))
 void QxlDevice::InitMspace(UINT32 mspace_type, UINT8 *start, size_t capacity)
 {
+    PAGED_CODE();
     DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s type = %d, start = %p, capacity = %d\n", __FUNCTION__, mspace_type, start, capacity));
     m_MSInfo[mspace_type]._mspace = create_mspace_with_base(start, capacity, 0, this);
     m_MSInfo[mspace_type].mspace_start = start;
@@ -3621,6 +3727,7 @@ void QxlDevice::ResetDevice(void)
     DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__));
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS
 QxlDevice::ExecutePresentDisplayOnly(
     _In_ BYTE*             DstAddr,
@@ -3809,8 +3916,10 @@ QxlDevice::ExecutePresentDisplayOnly(
     return STATUS_SUCCESS;
 }
 
+__declspec(code_seg("PAGE"))
 void QxlDevice::WaitForReleaseRing(void)
 {
+    PAGED_CODE();
     int wait;
 
     DbgPrint(TRACE_LEVEL_VERBOSE, ("--->%s\n", __FUNCTION__));
@@ -3841,8 +3950,10 @@ void QxlDevice::WaitForReleaseRing(void)
     DbgPrint(TRACE_LEVEL_VERBOSE, ("%s: <---\n", __FUNCTION__));
 }
 
+__declspec(code_seg("PAGE"))
 void QxlDevice::FlushReleaseRing()
 {
+    PAGED_CODE();
     UINT64 output;
     int notify;
     int num_to_release = 50;
@@ -3872,8 +3983,10 @@ void QxlDevice::FlushReleaseRing()
     DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__));
 }
 
+__declspec(code_seg("PAGE"))
 void QxlDevice::EmptyReleaseRing()
 {
+    PAGED_CODE();
     BOOLEAN locked = FALSE;
     locked = WaitForObject(&m_MemLock, NULL);
     while (m_FreeOutputs || !SPICE_RING_IS_EMPTY(m_ReleaseRing)) {
@@ -3882,8 +3995,10 @@ void QxlDevice::EmptyReleaseRing()
     ReleaseMutex(&m_MemLock, locked);
 }
 
+__declspec(code_seg("PAGE"))
 UINT64 QxlDevice::ReleaseOutput(UINT64 output_id)
 {
+    PAGED_CODE();
     QXLOutput *output = (QXLOutput *)output_id;
     Resource **now;
     Resource **end;
@@ -3901,8 +4016,10 @@ UINT64 QxlDevice::ReleaseOutput(UINT64 output_id)
     return next;
 }
 
+__declspec(code_seg("PAGE"))
 void *QxlDevice::AllocMem(UINT32 mspace_type, size_t size, BOOL force)
 {
+    PAGED_CODE();
     PVOID ptr;
     BOOLEAN locked = FALSE;
 
@@ -3949,8 +4066,10 @@ void *QxlDevice::AllocMem(UINT32 mspace_type, size_t size, BOOL force)
     return ptr;
 }
 
+__declspec(code_seg("PAGE"))
 void QxlDevice::FreeMem(UINT32 mspace_type, void *ptr)
 {
+    PAGED_CODE();
     ASSERT(m_MSInfo[mspace_type]._mspace);
     DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__));
 
@@ -3969,8 +4088,10 @@ void QxlDevice::FreeMem(UINT32 mspace_type, void *ptr)
     DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__));
 }
 
+__declspec(code_seg("PAGE"))
 QXLDrawable *QxlDevice::GetDrawable()
 {
+    PAGED_CODE();
     QXLOutput *output;
 
     output = (QXLOutput *)AllocMem(MSPACE_TYPE_VRAM, sizeof(QXLOutput) + sizeof(QXLDrawable), TRUE);
@@ -3981,8 +4102,10 @@ QXLDrawable *QxlDevice::GetDrawable()
     return(QXLDrawable *)output->data;
 }
 
+__declspec(code_seg("PAGE"))
 QXLCursorCmd *QxlDevice::CursorCmd()
 {
+    PAGED_CODE();
     QXLCursorCmd *cursor_cmd;
     QXLOutput *output;
 
@@ -3996,8 +4119,10 @@ QXLCursorCmd *QxlDevice::CursorCmd()
     return cursor_cmd;
 }
 
+__declspec(code_seg("PAGE"))
 BOOL QxlDevice::SetClip(const RECT *clip, QXLDrawable *drawable)
 {
+    PAGED_CODE();
     Resource *rects_res;
 
     if (clip == NULL) {
@@ -4025,37 +4150,47 @@ BOOL QxlDevice::SetClip(const RECT *clip, QXLDrawable *drawable)
     return TRUE;
 }
 
+__declspec(code_seg("PAGE"))
 void QxlDevice::AddRes(QXLOutput *output, Resource *res)
 {
+    PAGED_CODE();
     res->refs++;
     output->resources[output->num_res++] = res;
 }
 
+__declspec(code_seg("PAGE"))
 void QxlDevice::DrawableAddRes(QXLDrawable *drawable, Resource *res)
 {
+    PAGED_CODE();
     QXLOutput *output;
 
     output = (QXLOutput *)((UINT8 *)drawable - sizeof(QXLOutput));
     AddRes(output, res);
 }
 
+__declspec(code_seg("PAGE"))
 void QxlDevice::CursorCmdAddRes(QXLCursorCmd *cmd, Resource *res)
 {
+    PAGED_CODE();
     QXLOutput *output;
 
     output = (QXLOutput *)((UINT8 *)cmd - sizeof(QXLOutput));
     AddRes(output, res);
 }
 
+__declspec(code_seg("PAGE"))
 void QxlDevice::FreeClipRectsEx(Resource *res)
 {
+    PAGED_CODE();
     DbgPrint(TRACE_LEVEL_VERBOSE, ("<--> %s\n", __FUNCTION__));
     QxlDevice* pqxl = (QxlDevice*)res->ptr;
     pqxl->FreeClipRects(res);
 }
 
+__declspec(code_seg("PAGE"))
 void QxlDevice::FreeClipRects(Resource *res)
 {
+    PAGED_CODE();
     QXLPHYSICAL chunk_phys;
     DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__));
 
@@ -4069,15 +4204,19 @@ void QxlDevice::FreeClipRects(Resource *res)
     DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__));
 }
 
+__declspec(code_seg("PAGE"))
 void QxlDevice::FreeBitmapImageEx(Resource *res)
 {
+    PAGED_CODE();
     DbgPrint(TRACE_LEVEL_VERBOSE, ("<--> %s\n", __FUNCTION__));
     QxlDevice* pqxl = (QxlDevice*)res->ptr;
     pqxl->FreeBitmapImage(res);
 }
 
+__declspec(code_seg("PAGE"))
 void QxlDevice::FreeBitmapImage(Resource *res)
 {
+    PAGED_CODE();
     InternalImage *internal;
     QXLPHYSICAL chunk_phys;
     DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__));
@@ -4095,15 +4234,19 @@ void QxlDevice::FreeBitmapImage(Resource *res)
     DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__));
 }
 
+__declspec(code_seg("PAGE"))
 void QxlDevice::FreeCursorEx(Resource *res)
 {
+    PAGED_CODE();
     DbgPrint(TRACE_LEVEL_VERBOSE, ("<--> %s\n", __FUNCTION__));
     QxlDevice* pqxl = (QxlDevice*)res->ptr;
     pqxl->FreeCursor(res);
 }
 
+__declspec(code_seg("PAGE"))
 void QxlDevice::FreeCursor(Resource *res)
 {
+    PAGED_CODE();
     QXLPHYSICAL chunk_phys;
 
     DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__));
@@ -4118,8 +4261,10 @@ void QxlDevice::FreeCursor(Resource *res)
     DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__));
 }
 
+__declspec(code_seg("PAGE"))
 QXLDrawable *QxlDevice::Drawable(UINT8 type, CONST RECT *area, CONST RECT *clip, UINT32 surface_id)
 {
+    PAGED_CODE();
     QXLDrawable *drawable;
 
     ASSERT(area);
@@ -4145,7 +4290,10 @@ QXLDrawable *QxlDevice::Drawable(UINT8 type, CONST RECT *area, CONST RECT *clip,
     return drawable;
 }
 
-void QxlDevice::PushDrawable(QXLDrawable *drawable) {
+__declspec(code_seg("PAGE"))
+void QxlDevice::PushDrawable(QXLDrawable *drawable)
+{
+    PAGED_CODE();
     QXLCommand *cmd;
     DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__));
 
@@ -4160,8 +4308,10 @@ void QxlDevice::PushDrawable(QXLDrawable *drawable) {
     DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__));
 }
 
+__declspec(code_seg("PAGE"))
 void QxlDevice::PushCursorCmd(QXLCursorCmd *cursor_cmd)
 {
+    PAGED_CODE();
     QXLCommand *cmd;
 
     DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__));
@@ -4177,12 +4327,14 @@ void QxlDevice::PushCursorCmd(QXLCursorCmd *cursor_cmd)
     DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__));
 }
 
+__declspec(code_seg("PAGE"))
 VOID QxlDevice::SetImageId(InternalImage *internal,
     BOOL cache_me,
     LONG width,
     LONG height,
     UINT8 format, UINT32 key)
 {
+    PAGED_CODE();
     UINT32 image_info = IMAGE_HASH_INIT_VAL(width, height, format);
 
     if (cache_me) {
@@ -4196,6 +4348,7 @@ VOID QxlDevice::SetImageId(InternalImage *internal,
     }
 }
 
+__declspec(code_seg("PAGE"))
 VOID QxlDevice::BltBits (
     BLT_INFO* pDst,
     CONST BLT_INFO* pSrc,
@@ -4203,6 +4356,7 @@ VOID QxlDevice::BltBits (
     _In_reads_(NumRects) CONST RECT *pRects,
     POINT*   pSourcePoint)
 {
+    PAGED_CODE();
     QXLDrawable *drawable;
     Resource *image_res;
     InternalImage *internal;
@@ -4296,10 +4450,12 @@ VOID QxlDevice::BltBits (
     DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__));
 }
 
+    __declspec(code_seg("PAGE"))
 VOID QxlDevice::PutBytesAlign(QXLDataChunk **chunk_ptr, UINT8 **now_ptr,
                             UINT8 **end_ptr, UINT8 *src, int size,
                             size_t alloc_size, uint32_t alignment)
 {
+    PAGED_CODE();
     QXLDataChunk *chunk = *chunk_ptr;
     UINT8 *now = *now_ptr;
     UINT8 *end = *end_ptr;
@@ -4335,6 +4491,7 @@ VOID QxlDevice::PutBytesAlign(QXLDataChunk **chunk_ptr, UINT8 **now_ptr,
     DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__));
 }
 
+__declspec(code_seg("PAGE"))
 VOID QxlDevice::BlackOutScreen(CURRENT_BDD_MODE* pCurrentBddMod)
 {
     QXLDrawable *drawable;
@@ -4362,15 +4519,19 @@ VOID QxlDevice::BlackOutScreen(CURRENT_BDD_MODE* pCurrentBddMod)
     }
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDevice::HWClose(void)
 {
+    PAGED_CODE();
     QxlClose();
     UnmapMemory();
     return STATUS_SUCCESS;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS  QxlDevice::SetPointerShape(_In_ CONST DXGKARG_SETPOINTERSHAPE* pSetPointerShape)
 {
+    PAGED_CODE();
     DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s flag = %x\n", __FUNCTION__, pSetPointerShape->Flags.Value));
     DbgPrint(TRACE_LEVEL_INFORMATION, ("<--> %s flag = %d pitch = %d, pixels = %p, id = %d, w = %d, h = %d, x = %d, y = %d\n", __FUNCTION__,
                                  pSetPointerShape->Flags.Value,
@@ -4452,8 +4613,10 @@ NTSTATUS  QxlDevice::SetPointerShape(_In_ CONST DXGKARG_SETPOINTERSHAPE* pSetPoi
     return STATUS_SUCCESS;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDevice::SetPointerPosition(_In_ CONST DXGKARG_SETPOINTERPOSITION* pSetPointerPosition)
 {
+    PAGED_CODE();
     DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__));
     DbgPrint(TRACE_LEVEL_INFORMATION, ("<--> %s flag = %d id = %d, x = %d, y = %d\n", __FUNCTION__,
                                  pSetPointerPosition->Flags.Value,
@@ -4475,6 +4638,7 @@ NTSTATUS QxlDevice::SetPointerPosition(_In_ CONST DXGKARG_SETPOINTERPOSITION* pS
     return STATUS_SUCCESS;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDevice::UpdateChildStatus(BOOLEAN connect)
 {
     PAGED_CODE();
@@ -4489,6 +4653,7 @@ NTSTATUS QxlDevice::UpdateChildStatus(BOOLEAN connect)
     return Status;
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDevice::SetCustomDisplay(QXLEscapeSetCustomDisplay* custom_display)
 {
     PAGED_CODE();
@@ -4513,6 +4678,7 @@ NTSTATUS QxlDevice::SetCustomDisplay(QXLEscapeSetCustomDisplay* custom_display)
     return status;
 }
 
+__declspec(code_seg("PAGE"))
 void QxlDevice::SetMonitorConfig(QXLHead * monitor_config)
 {
     PAGED_CODE();
@@ -4529,8 +4695,10 @@ void QxlDevice::SetMonitorConfig(QXLHead * monitor_config)
     AsyncIo(QXL_IO_MONITORS_CONFIG_ASYNC, 0);
 }
 
+__declspec(code_seg("PAGE"))
 NTSTATUS QxlDevice::Escape(_In_ CONST DXGKARG_ESCAPE* pEscape)
 {
+    PAGED_CODE();
     size_t          data_size(sizeof(uint32_t));
     QXLEscape*     pQXLEscape((QXLEscape*) pEscape->pPrivateDriverData);
     NTSTATUS        status(STATUS_SUCCESS);
@@ -4569,8 +4737,10 @@ NTSTATUS QxlDevice::Escape(_In_ CONST DXGKARG_ESCAPE* pEscape)
     return status;
 }
 
+__declspec(code_seg("PAGE"))
 VOID QxlDevice::WaitForCmdRing()
 {
+    PAGED_CODE();
     int wait;
     DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__));
 
@@ -4585,8 +4755,10 @@ VOID QxlDevice::WaitForCmdRing()
     DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__));
 }
 
+__declspec(code_seg("PAGE"))
 VOID QxlDevice::PushCmd()
 {
+    PAGED_CODE();
     int notify;
     DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__));
     SPICE_RING_PUSH(m_CommandRing, notify);
@@ -4596,8 +4768,10 @@ VOID QxlDevice::PushCmd()
     DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s notify = %d\n", __FUNCTION__, notify));
 }
 
+__declspec(code_seg("PAGE"))
 VOID QxlDevice::WaitForCursorRing(VOID)
 {
+    PAGED_CODE();
     int wait;
     DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__));
 
@@ -4618,8 +4792,10 @@ VOID QxlDevice::WaitForCursorRing(VOID)
     }
 }
 
+__declspec(code_seg("PAGE"))
 VOID QxlDevice::PushCursor(VOID)
 {
+    PAGED_CODE();
     int notify;
     DbgPrint(TRACE_LEVEL_VERBOSE, ("---> %s\n", __FUNCTION__));
     SPICE_RING_PUSH(m_CursorRing, notify);
@@ -4736,8 +4912,10 @@ D3DDDIFORMAT PixelFormatFromBPP(UINT BPP)
     }
 }
 
+__declspec(code_seg("PAGE"))
 UINT SpiceFromPixelFormat(D3DDDIFORMAT Format)
 {
+    PAGED_CODE();
     switch (Format)
     {
         case D3DDDIFMT_UNKNOWN:
diff --git a/qxldod/QxlDod.h b/qxldod/QxlDod.h
index 24e0f64..8b90616 100755
--- a/qxldod/QxlDod.h
+++ b/qxldod/QxlDod.h
@@ -215,23 +215,37 @@ class QxlDod;
 
 class HwDeviceInterface {
 public:
+    __declspec(code_seg("PAGE"))
     virtual ~HwDeviceInterface() {;}
+    __declspec(code_seg("PAGE"))
     virtual NTSTATUS QueryCurrentMode(PVIDEO_MODE RequestedMode) = 0;
+    __declspec(code_seg("PAGE"))
     virtual NTSTATUS SetCurrentMode(ULONG Mode) = 0;
+    __declspec(code_seg("PAGE"))
     virtual NTSTATUS GetCurrentMode(ULONG* Mode) = 0;
+    __declspec(code_seg("PAGE"))
     virtual NTSTATUS SetPowerState(DEVICE_POWER_STATE DevicePowerState, DXGK_DISPLAY_INFORMATION* pDispInfo) = 0;
+    __declspec(code_seg("PAGE"))
     virtual NTSTATUS HWInit(PCM_RESOURCE_LIST pResList, DXGK_DISPLAY_INFORMATION* pDispInfo) = 0;
+    __declspec(code_seg("PAGE"))
     virtual NTSTATUS HWClose(void) = 0;
     virtual BOOLEAN InterruptRoutine(_In_ PDXGKRNL_INTERFACE pDxgkInterface, _In_  ULONG MessageNumber) = 0;
     virtual VOID DpcRoutine(PVOID) = 0;
     virtual VOID ResetDevice(void) = 0;
 
+    __declspec(code_seg("PAGE"))
     virtual ULONG GetModeCount(void) = 0;
+    __declspec(code_seg("PAGE"))
     PVIDEO_MODE_INFORMATION GetModeInfo(UINT idx) {return &m_ModeInfo[idx];}
+    __declspec(code_seg("PAGE"))
     USHORT GetModeNumber(USHORT idx) {return m_ModeNumbers[idx];}
+    __declspec(code_seg("PAGE"))
     USHORT GetCurrentModeIndex(void) {return m_CurrentMode;}
+    __declspec(code_seg("PAGE"))
     VOID SetCurrentModeIndex(USHORT idx) {m_CurrentMode = idx;}
+    __declspec(code_seg("PAGE"))
     virtual BOOLEAN EnablePointer(void) = 0;
+    __declspec(code_seg("PAGE"))
     virtual NTSTATUS ExecutePresentDisplayOnly(_In_ BYTE*             DstAddr,
                                  _In_ UINT              DstBitPerPixel,
                                  _In_ BYTE*             SrcAddr,
@@ -243,13 +257,17 @@ public:
                                  _In_ RECT*             pDirtyRect,
                                  _In_ D3DKMDT_VIDPN_PRESENT_PATH_ROTATION Rotation,
                                  _In_ const CURRENT_BDD_MODE* pModeCur) = 0;
-
+    __declspec(code_seg("PAGE"))
     virtual VOID BlackOutScreen(CURRENT_BDD_MODE* pCurrentBddMod) = 0;
+    __declspec(code_seg("PAGE"))
     virtual NTSTATUS SetPointerShape(_In_ CONST DXGKARG_SETPOINTERSHAPE* pSetPointerShape) = 0;
+    __declspec(code_seg("PAGE"))
     virtual NTSTATUS SetPointerPosition(_In_ CONST DXGKARG_SETPOINTERPOSITION* pSetPointerPosition) = 0;
+    __declspec(code_seg("PAGE"))
     virtual NTSTATUS Escape(_In_ CONST DXGKARG_ESCAPE* pEscap) = 0;
     ULONG GetId(void) { return m_Id; }
 protected:
+    __declspec(code_seg("PAGE"))
     virtual NTSTATUS GetModeList(DXGK_DISPLAY_INFORMATION* pDispInfo) = 0;
 protected:
     QxlDod* m_pQxlDod;
@@ -265,16 +283,27 @@ class VgaDevice  :
     public HwDeviceInterface
 {
 public:
+    __declspec(code_seg("PAGE"))
     VgaDevice(_In_ QxlDod* pQxlDod);
+    __declspec(code_seg("PAGE"))
     ~VgaDevice(void);
+    __declspec(code_seg("PAGE"))
     NTSTATUS QueryCurrentMode(PVIDEO_MODE RequestedMode);
+    __declspec(code_seg("PAGE"))
     NTSTATUS SetCurrentMode(ULONG Mode);
+    __declspec(code_seg("PAGE"))
     NTSTATUS GetCurrentMode(ULONG* Mode);
+    __declspec(code_seg("PAGE"))
     ULONG GetModeCount(void) {return m_ModeCount;}
+    __declspec(code_seg("PAGE"))
     NTSTATUS SetPowerState(DEVICE_POWER_STATE DevicePowerState, DXGK_DISPLAY_INFORMATION* pDispInfo);
+    __declspec(code_seg("PAGE"))
     NTSTATUS HWInit(PCM_RESOURCE_LIST pResList, DXGK_DISPLAY_INFORMATION* pDispInfo);
+    __declspec(code_seg("PAGE"))
     NTSTATUS HWClose(void);
+    __declspec(code_seg("PAGE"))
     BOOLEAN EnablePointer(void) { return TRUE; }
+    __declspec(code_seg("PAGE"))
     NTSTATUS ExecutePresentDisplayOnly(_In_ BYTE*             DstAddr,
                                  _In_ UINT              DstBitPerPixel,
                                  _In_ BYTE*             SrcAddr,
@@ -286,16 +315,22 @@ public:
                                  _In_ RECT*             pDirtyRect,
                                  _In_ D3DKMDT_VIDPN_PRESENT_PATH_ROTATION Rotation,
                                  _In_ const CURRENT_BDD_MODE* pModeCur);
+    __declspec(code_seg("PAGE"))
     VOID BlackOutScreen(CURRENT_BDD_MODE* pCurrentBddMod);
     BOOLEAN InterruptRoutine(_In_ PDXGKRNL_INTERFACE pDxgkInterface, _In_  ULONG MessageNumber);
     VOID DpcRoutine(PVOID);
     VOID ResetDevice(VOID);
+    __declspec(code_seg("PAGE"))
     NTSTATUS SetPointerShape(_In_ CONST DXGKARG_SETPOINTERSHAPE* pSetPointerShape);
+    __declspec(code_seg("PAGE"))
     NTSTATUS SetPointerPosition(_In_ CONST DXGKARG_SETPOINTERPOSITION* pSetPointerPosition);
+    __declspec(code_seg("PAGE"))
     NTSTATUS Escape(_In_ CONST DXGKARG_ESCAPE* pEscap);
 protected:
+    __declspec(code_seg("PAGE"))
     NTSTATUS GetModeList(DXGK_DISPLAY_INFORMATION* pDispInfo);
 private:
+    __declspec(code_seg("PAGE"))
     BOOL SetVideoModeInfo(UINT Idx, PVBE_MODEINFO pModeInfo);
 };
 
@@ -438,16 +473,27 @@ class QxlDevice  :
     public HwDeviceInterface
 {
 public:
+    __declspec(code_seg("PAGE"))
     QxlDevice(_In_ QxlDod* pQxlDod);
+    __declspec(code_seg("PAGE"))
     ~QxlDevice(void);
+    __declspec(code_seg("PAGE"))
     NTSTATUS QueryCurrentMode(PVIDEO_MODE RequestedMode);
+    __declspec(code_seg("PAGE"))
     NTSTATUS SetCurrentMode(ULONG Mode);
+    __declspec(code_seg("PAGE"))
     NTSTATUS GetCurrentMode(ULONG* Mode);
+    __declspec(code_seg("PAGE"))
     ULONG GetModeCount(void) {return m_ModeCount;}
+    __declspec(code_seg("PAGE"))
     NTSTATUS SetPowerState(DEVICE_POWER_STATE DevicePowerState, DXGK_DISPLAY_INFORMATION* pDispInfo);
+    __declspec(code_seg("PAGE"))
     NTSTATUS HWInit(PCM_RESOURCE_LIST pResList, DXGK_DISPLAY_INFORMATION* pDispInfo);
+    __declspec(code_seg("PAGE"))
     NTSTATUS HWClose(void);
+    __declspec(code_seg("PAGE"))
     BOOLEAN EnablePointer(void) { return FALSE; }
+    __declspec(code_seg("PAGE"))
     NTSTATUS ExecutePresentDisplayOnly(_In_ BYTE*             DstAddr,
                     _In_ UINT              DstBitPerPixel,
                     _In_ BYTE*             SrcAddr,
@@ -459,83 +505,140 @@ public:
                     _In_ RECT*             pDirtyRect,
                     _In_ D3DKMDT_VIDPN_PRESENT_PATH_ROTATION Rotation,
                     _In_ const CURRENT_BDD_MODE* pModeCur);
+    __declspec(code_seg("PAGE"))
     VOID BlackOutScreen(CURRENT_BDD_MODE* pCurrentBddMod);
     BOOLEAN InterruptRoutine(_In_ PDXGKRNL_INTERFACE pDxgkInterface, _In_  ULONG MessageNumber);
     VOID DpcRoutine(PVOID);
     VOID ResetDevice(VOID);
+    __declspec(code_seg("PAGE"))
     NTSTATUS SetPointerShape(_In_ CONST DXGKARG_SETPOINTERSHAPE* pSetPointerShape);
+    __declspec(code_seg("PAGE"))
     NTSTATUS SetPointerPosition(_In_ CONST DXGKARG_SETPOINTERPOSITION* pSetPointerPosition);
+    __declspec(code_seg("PAGE"))
     NTSTATUS Escape(_In_ CONST DXGKARG_ESCAPE* pEscap);
 protected:
+    __declspec(code_seg("PAGE"))
     NTSTATUS GetModeList(DXGK_DISPLAY_INFORMATION* pDispInfo);
+    __declspec(code_seg("PAGE"))
     VOID BltBits (BLT_INFO* pDst,
                     CONST BLT_INFO* pSrc,
                     UINT  NumRects,
                     _In_reads_(NumRects) CONST RECT *pRects,
                     POINT*   pSourcePoint);
+    __declspec(code_seg("PAGE"))
     QXLDrawable *Drawable(UINT8 type,
                     CONST RECT *area,
                     CONST RECT *clip,
                     UINT32 surface_id);
+    __declspec(code_seg("PAGE"))
     void PushDrawable(QXLDrawable *drawable);
+    __declspec(code_seg("PAGE"))
     void PushCursorCmd(QXLCursorCmd *cursor_cmd);
+    __declspec(code_seg("PAGE"))
     QXLDrawable *GetDrawable();
+    __declspec(code_seg("PAGE"))
     QXLCursorCmd *CursorCmd();
+    __declspec(code_seg("PAGE"))
     void *AllocMem(UINT32 mspace_type, size_t size, BOOL force);
     VOID UpdateArea(CONST RECT* area, UINT32 surface_id);
+    __declspec(code_seg("PAGE"))
     VOID SetImageId(InternalImage *internal,
                     BOOL cache_me,
                     LONG width,
                     LONG height,
                     UINT8 format, UINT32 key);
 private:
+    __declspec(code_seg("PAGE"))
     NTSTATUS QxlInit(DXGK_DISPLAY_INFORMATION* pDispInfo);
+    __declspec(code_seg("PAGE"))
     void QxlClose(void);
+    __declspec(code_seg("PAGE"))
     void UnmapMemory(void);
+    __declspec(code_seg("PAGE"))
     BOOL SetVideoModeInfo(UINT Idx, QXLMode* pModeInfo);
+    __declspec(code_seg("PAGE"))
     void UpdateVideoModeInfo(UINT Idx, UINT xres, UINT yres, UINT bpp);
+    __declspec(code_seg("PAGE"))
     BOOL InitMemSlots(void);
+    __declspec(code_seg("PAGE"))
     BOOL CreateMemSlots(void);
+    __declspec(code_seg("PAGE"))
     void DestroyMemSlots(void);
+    __declspec(code_seg("PAGE"))
     void CreatePrimarySurface(PVIDEO_MODE_INFORMATION pModeInfo);
+    __declspec(code_seg("PAGE"))
     void DestroyPrimarySurface(void);
+    __declspec(code_seg("PAGE"))
     void SetupHWSlot(UINT8 Idx, MemSlot *pSlot);
+    __declspec(code_seg("PAGE"))
     UINT8 SetupMemSlot(UINT8 Idx, UINT64 pastart, UINT64 paend, UINT64 vastart, UINT64 vaend);
+    __declspec(code_seg("PAGE"))
     BOOL CreateEvents(void);
+    __declspec(code_seg("PAGE"))
     BOOL CreateRings(void);
+    __declspec(code_seg("PAGE"))
     UINT64 VA(QXLPHYSICAL paddr, UINT8 slot_id);
+    __declspec(code_seg("PAGE"))
     QXLPHYSICAL PA(PVOID virt, UINT8 slot_id);
+    __declspec(code_seg("PAGE"))
     void InitDeviceMemoryResources(void);
+    __declspec(code_seg("PAGE"))
     void InitMonitorConfig();
+    __declspec(code_seg("PAGE"))
     void InitMspace(UINT32 mspace_type, UINT8 *start, size_t capacity);
+    __declspec(code_seg("PAGE"))
     void FlushReleaseRing();
+    __declspec(code_seg("PAGE"))
     void FreeMem(UINT32 mspace_type, void *ptr);
+    __declspec(code_seg("PAGE"))
     UINT64 ReleaseOutput(UINT64 output_id);
+    __declspec(code_seg("PAGE"))
     void WaitForReleaseRing(void);
+    __declspec(code_seg("PAGE"))
     void EmptyReleaseRing(void);
+    __declspec(code_seg("PAGE"))
     BOOL SetClip(const RECT *clip, QXLDrawable *drawable);
+    __declspec(code_seg("PAGE"))
     void AddRes(QXLOutput *output, Resource *res);
+    __declspec(code_seg("PAGE"))
     void DrawableAddRes(QXLDrawable *drawable, Resource *res);
+    __declspec(code_seg("PAGE"))
     void CursorCmdAddRes(QXLCursorCmd *cmd, Resource *res);
+    __declspec(code_seg("PAGE"))
     void FreeClipRects(Resource *res);
+    __declspec(code_seg("PAGE"))
     void static FreeClipRectsEx(Resource *res);
+    __declspec(code_seg("PAGE"))
     void FreeBitmapImage(Resource *res);
+    __declspec(code_seg("PAGE"))
     void static FreeBitmapImageEx(Resource *res);
+    __declspec(code_seg("PAGE"))
     void static FreeCursorEx(Resource *res);
+    __declspec(code_seg("PAGE"))
     void FreeCursor(Resource *res);
+    __declspec(code_seg("PAGE"))
     void WaitForCmdRing(void);
+    __declspec(code_seg("PAGE"))
     void PushCmd(void);
+    __declspec(code_seg("PAGE"))
     void WaitForCursorRing(void);
+    __declspec(code_seg("PAGE"))
     void PushCursor(void);
+    __declspec(code_seg("PAGE"))
     void PutBytesAlign(QXLDataChunk **chunk_ptr, UINT8 **now_ptr,
                             UINT8 **end_ptr, UINT8 *src, int size,
                             size_t alloc_size, uint32_t alignment);
     BOOLEAN static DpcCallbackEx(PVOID);
     void DpcCallback(PDPC_CB_CONTEXT);
+    __declspec(code_seg("PAGE"))
     void AsyncIo(UCHAR  Port, UCHAR Value);
+    __declspec(code_seg("PAGE"))
     void SyncIo(UCHAR  Port, UCHAR Value);
+    __declspec(code_seg("PAGE"))
     NTSTATUS UpdateChildStatus(BOOLEAN connect);
+    __declspec(code_seg("PAGE"))
     NTSTATUS SetCustomDisplay(QXLEscapeSetCustomDisplay* custom_display);
+    __declspec(code_seg("PAGE"))
     void SetMonitorConfig(QXLHead* monitor_config);
 
 private:
@@ -606,37 +709,41 @@ private:
     DWORD m_VgaCompatible;
     DWORD m_PointerCaps;
 public:
+    __declspec(code_seg("PAGE"))
     QxlDod(_In_ DEVICE_OBJECT* pPhysicalDeviceObject);
+    __declspec(code_seg("PAGE"))
     ~QxlDod(void);
-#pragma code_seg(push)
-#pragma code_seg()
     BOOLEAN IsDriverActive() const
     {
         return m_Flags.DriverStarted;
     }
-#pragma code_seg(pop)
-
+    __declspec(code_seg("PAGE"))
     NTSTATUS StartDevice(_In_  DXGK_START_INFO*   pDxgkStartInfo,
                          _In_  DXGKRNL_INTERFACE* pDxgkInterface,
                          _Out_ ULONG*             pNumberOfViews,
                          _Out_ ULONG*             pNumberOfChildren);
+    __declspec(code_seg("PAGE"))
     NTSTATUS StopDevice(VOID);
     // Must be Non-Paged
     VOID ResetDevice(VOID);
 
+    __declspec(code_seg("PAGE"))
     NTSTATUS DispatchIoRequest(_In_  ULONG VidPnSourceId,
                                _In_  VIDEO_REQUEST_PACKET* pVideoRequestPacket);
+    __declspec(code_seg("PAGE"))
     NTSTATUS SetPowerState(_In_  ULONG HardwareUid,
                                _In_  DEVICE_POWER_STATE DevicePowerState,
                                _In_  POWER_ACTION       ActionType);
     // Report back child capabilities
+    __declspec(code_seg("PAGE"))
     NTSTATUS QueryChildRelations(_Out_writes_bytes_(ChildRelationsSize) DXGK_CHILD_DESCRIPTOR* pChildRelations,
                                  _In_                             ULONG                  ChildRelationsSize);
-
+    __declspec(code_seg("PAGE"))
     NTSTATUS QueryChildStatus(_Inout_ DXGK_CHILD_STATUS* pChildStatus,
                               _In_    BOOLEAN            NonDestructiveOnly);
 
     // Return EDID if previously retrieved
+    __declspec(code_seg("PAGE"))
     NTSTATUS QueryDeviceDescriptor(_In_    ULONG                   ChildUid,
                                    _Inout_ DXGK_DEVICE_DESCRIPTOR* pDeviceDescriptor);
 
@@ -647,37 +754,53 @@ public:
     VOID DpcRoutine(VOID);
 
     // Return DriverCaps, doesn't support other queries though
+    __declspec(code_seg("PAGE"))
     NTSTATUS QueryAdapterInfo(_In_ CONST DXGKARG_QUERYADAPTERINFO* pQueryAdapterInfo);
 
+    __declspec(code_seg("PAGE"))
     NTSTATUS SetPointerPosition(_In_ CONST DXGKARG_SETPOINTERPOSITION* pSetPointerPosition);
 
+    __declspec(code_seg("PAGE"))
     NTSTATUS SetPointerShape(_In_ CONST DXGKARG_SETPOINTERSHAPE* pSetPointerShape);
 
+    __declspec(code_seg("PAGE"))
     NTSTATUS Escape(_In_ CONST DXGKARG_ESCAPE* pEscape);
 
+    __declspec(code_seg("PAGE"))
     NTSTATUS PresentDisplayOnly(_In_ CONST DXGKARG_PRESENT_DISPLAYONLY* pPresentDisplayOnly);
 
+    __declspec(code_seg("PAGE"))
     NTSTATUS QueryInterface(_In_ CONST PQUERY_INTERFACE     QueryInterface);
 
+    __declspec(code_seg("PAGE"))
     NTSTATUS IsSupportedVidPn(_Inout_ DXGKARG_ISSUPPORTEDVIDPN* pIsSupportedVidPn);
 
+    __declspec(code_seg("PAGE"))
     NTSTATUS RecommendFunctionalVidPn(_In_ CONST DXGKARG_RECOMMENDFUNCTIONALVIDPN* CONST pRecommendFunctionalVidPn);
 
+    __declspec(code_seg("PAGE"))
     NTSTATUS RecommendVidPnTopology(_In_ CONST DXGKARG_RECOMMENDVIDPNTOPOLOGY* CONST pRecommendVidPnTopology);
 
+    __declspec(code_seg("PAGE"))
     NTSTATUS RecommendMonitorModes(_In_ CONST DXGKARG_RECOMMENDMONITORMODES* CONST pRecommendMonitorModes);
 
+    __declspec(code_seg("PAGE"))
     NTSTATUS EnumVidPnCofuncModality(_In_ CONST DXGKARG_ENUMVIDPNCOFUNCMODALITY* CONST pEnumCofuncModality);
 
+    __declspec(code_seg("PAGE"))
     NTSTATUS SetVidPnSourceVisibility(_In_ CONST DXGKARG_SETVIDPNSOURCEVISIBILITY* pSetVidPnSourceVisibility);
 
+    __declspec(code_seg("PAGE"))
     NTSTATUS CommitVidPn(_In_ CONST DXGKARG_COMMITVIDPN* CONST pCommitVidPn);
 
+    __declspec(code_seg("PAGE"))
     NTSTATUS UpdateActiveVidPnPresentPath(_In_ CONST DXGKARG_UPDATEACTIVEVIDPNPRESENTPATH* CONST pUpdateActiveVidPnPresentPath);
 
+    __declspec(code_seg("PAGE"))
     NTSTATUS QueryVidPnHWCapability(_Inout_ DXGKARG_QUERYVIDPNHWCAPABILITY* pVidPnHWCaps);
 
     // Part of PnPStop (PnP instance only), returns current mode information (which will be passed to fallback instance by dxgkrnl)
+    __declspec(code_seg("PAGE"))
     NTSTATUS StopDeviceAndReleasePostDisplayOwnership(_In_  D3DDDI_VIDEO_PRESENT_TARGET_ID TargetId,
                                                       _Out_ DXGK_DISPLAY_INFORMATION*      pDisplayInfo);
 
@@ -699,39 +822,52 @@ public:
                                  _In_                                     INT   PositionY);
     PDXGKRNL_INTERFACE GetDxgkInterface(void) { return &m_DxgkInterface;}
 private:
+    __declspec(code_seg("PAGE"))
     VOID CleanUp(VOID);
+    __declspec(code_seg("PAGE"))
     NTSTATUS CheckHardware();
+    __declspec(code_seg("PAGE"))
     NTSTATUS WriteHWInfoStr(_In_ HANDLE DevInstRegKeyHandle, _In_ PCWSTR pszwValueName, _In_ PCSTR pszValue);
     // Set the given source mode on the given path
+    __declspec(code_seg("PAGE"))
     NTSTATUS SetSourceModeAndPath(CONST D3DKMDT_VIDPN_SOURCE_MODE* pSourceMode,
                                   CONST D3DKMDT_VIDPN_PRESENT_PATH* pPath);
 
     // Add the current mode to the given monitor source mode set
+    __declspec(code_seg("PAGE"))
     NTSTATUS AddSingleMonitorMode(_In_ CONST DXGKARG_RECOMMENDMONITORMODES* CONST pRecommendMonitorModes);
 
     // Add the current mode to the given VidPn source mode set
+    __declspec(code_seg("PAGE"))
     NTSTATUS AddSingleSourceMode(_In_ CONST DXGK_VIDPNSOURCEMODESET_INTERFACE* pVidPnSourceModeSetInterface,
                                  D3DKMDT_HVIDPNSOURCEMODESET hVidPnSourceModeSet,
                                  D3DDDI_VIDEO_PRESENT_SOURCE_ID SourceId);
 
     // Add the current mode (or the matching to pinned source mode) to the give VidPn target mode set
+    __declspec(code_seg("PAGE"))
     NTSTATUS AddSingleTargetMode(_In_ CONST DXGK_VIDPNTARGETMODESET_INTERFACE* pVidPnTargetModeSetInterface,
                                  D3DKMDT_HVIDPNTARGETMODESET hVidPnTargetModeSet,
                                  _In_opt_ CONST D3DKMDT_VIDPN_SOURCE_MODE* pVidPnPinnedSourceModeInfo,
                                  D3DDDI_VIDEO_PRESENT_SOURCE_ID SourceId);
     D3DDDI_VIDEO_PRESENT_SOURCE_ID FindSourceForTarget(D3DDDI_VIDEO_PRESENT_TARGET_ID TargetId, BOOLEAN DefaultToZero);
+    __declspec(code_seg("PAGE"))
     NTSTATUS IsVidPnSourceModeFieldsValid(CONST D3DKMDT_VIDPN_SOURCE_MODE* pSourceMode) const;
+    __declspec(code_seg("PAGE"))
     NTSTATUS IsVidPnPathFieldsValid(CONST D3DKMDT_VIDPN_PRESENT_PATH* pPath) const;
+    __declspec(code_seg("PAGE"))
     NTSTATUS RegisterHWInfo(_In_ ULONG Id);
+    __declspec(code_seg("PAGE"))
     NTSTATUS ReadConfiguration();
 };
 
+__declspec(code_seg("PAGE"))
 NTSTATUS
 MapFrameBuffer(
     _In_                PHYSICAL_ADDRESS    PhysicalAddress,
     _In_                ULONG               Length,
     _Outptr_result_bytebuffer_(Length) VOID**              VirtualAddress);
 
+__declspec(code_seg("PAGE"))
 NTSTATUS
 UnmapFrameBuffer(
     _In_reads_bytes_(Length) VOID* VirtualAddress,
@@ -739,6 +875,7 @@ UnmapFrameBuffer(
 
 UINT BPPFromPixelFormat(D3DDDIFORMAT Format);
 D3DDDIFORMAT PixelFormatFromBPP(UINT BPP);
+__declspec(code_seg("PAGE"))
 UINT SpiceFromPixelFormat(D3DDDIFORMAT Format);
 
 VOID CopyBitsGeneric(
-- 
2.7.4



More information about the Spice-devel mailing list