Index: /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp	(revision 33875)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp	(revision 33876)
@@ -17,4 +17,7 @@
 #include "VBoxVideo.h"
 #include "Helper.h"
+#ifdef VBOX_WITH_WDDM
+#include "wddm/VBoxVideoMisc.h"
+#endif
 
 #include <iprt/log.h>
@@ -99,5 +102,176 @@
    PULONG pUnused);
 
+/*******************************************************************************
+*   Internal Functions                                                         *
+*******************************************************************************/
+
 #ifndef VBOX_WITH_WDDM
+/*+++
+
+Routine Description:
+
+    This routine is used to read back various registry values.
+
+Arguments:
+
+    HwDeviceExtension
+        Supplies a pointer to the miniport's device extension.
+
+    Context
+        Context value passed to the get registry parameters routine.
+        If this is not null assume it's a ULONG* and save the data value in it.
+
+    ValueName
+        Name of the value requested.
+
+    ValueData
+        Pointer to the requested data.
+
+    ValueLength
+        Length of the requested data.
+
+Return Value:
+
+    If the variable doesn't exist return an error,
+    else if a context is supplied assume it's a PULONG and fill in the value
+    and return no error, else if the value is non-zero return an error.
+
+---*/
+static VP_STATUS VBoxRegistryCallback(PVOID HwDeviceExtension, PVOID Context,
+                                      PWSTR ValueName, PVOID ValueData,
+                                      ULONG ValueLength)
+{
+    //dprintf(("VBoxVideo::VBoxRegistryCallback: Context: %p, ValueName: %S, ValueData: %p, ValueLength: %d\n",
+    //         Context, ValueName, ValueData, ValueLength));
+    if (ValueLength)
+    {
+        if (Context)
+            *(ULONG *)Context = *(PULONG)ValueData;
+        else if (*((PULONG)ValueData) != 0)
+            return ERROR_INVALID_PARAMETER;
+        return NO_ERROR;
+    }
+    else
+        return ERROR_INVALID_PARAMETER;
+}
+#endif /* #ifndef VBOX_WITH_WDDM */
+
+static VP_STATUS VBoxVideoCmnRegQueryDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t *pVal)
+{
+#ifndef VBOX_WITH_WDDM
+    return VideoPortGetRegistryParameters(Reg, pName, FALSE, VBoxRegistryCallback, pVal);
+#else
+    if(!Reg)
+        return ERROR_INVALID_PARAMETER;
+    NTSTATUS Status = vboxWddmRegQueryValueDword(Reg, pName, (PDWORD)pVal);
+    return Status == STATUS_SUCCESS ? NO_ERROR : ERROR_INVALID_PARAMETER;
+#endif
+}
+
+static VP_STATUS VBoxVideoCmnRegSetDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t Val)
+{
+#ifndef VBOX_WITH_WDDM
+    return VideoPortSetRegistryParameters(Reg, pName, &Val, sizeof(Val));
+#else
+    if(!Reg)
+        return ERROR_INVALID_PARAMETER;
+    NTSTATUS Status = vboxWddmRegSetValueDword(Reg, pName, Val);
+    return Status == STATUS_SUCCESS ? NO_ERROR : ERROR_INVALID_PARAMETER;
+#endif
+}
+
+static VP_STATUS VBoxVideoCmnRegInit(IN PDEVICE_EXTENSION pDeviceExtension, OUT VBOXCMNREG *pReg)
+{
+#ifndef VBOX_WITH_WDDM
+    *pReg = pDeviceExtension->pPrimary;
+    return NO_ERROR;
+#else
+    WCHAR Buf[512];
+    ULONG cbBuf = sizeof(Buf);
+    NTSTATUS Status = vboxWddmRegQueryDrvKeyName(pDeviceExtension, cbBuf, Buf, &cbBuf);
+    Assert(Status == STATUS_SUCCESS);
+    if (Status == STATUS_SUCCESS)
+    {
+        Status = vboxWddmRegOpenKey(pReg, Buf, GENERIC_READ | GENERIC_WRITE);
+        Assert(Status == STATUS_SUCCESS);
+        if(Status == STATUS_SUCCESS)
+            return NO_ERROR;
+    }
+
+    /* fall-back to make the subsequent VBoxVideoCmnRegXxx calls treat the fail accordingly
+     * basically needed to make as less modifications to the current XPDM code as possible */
+    *pReg = NULL;
+
+    return ERROR_INVALID_PARAMETER;
+#endif
+}
+
+static VP_STATUS VBoxVideoCmnRegFini(IN VBOXCMNREG Reg)
+{
+#ifndef VBOX_WITH_WDDM
+    return NO_ERROR;
+#else
+    if(!Reg)
+        return ERROR_INVALID_PARAMETER;
+
+    NTSTATUS Status = ZwClose(Reg);
+    return Status == STATUS_SUCCESS ? NO_ERROR : ERROR_INVALID_PARAMETER;
+#endif
+}
+
+void VBoxVideoCmnSignalEvent(PVBOXVIDEO_COMMON pCommon, uint64_t pvEvent)
+{
+    PDEVICE_EXTENSION PrimaryExtension = commonToPrimaryExt(pCommon);
+#ifndef VBOX_WITH_WDDM
+    PEVENT pEvent = (PEVENT)pvEvent;
+    PrimaryExtension->u.primary.VideoPortProcs.pfnSetEvent(PrimaryExtension,
+                                                           pEvent);
+#else
+    PKEVENT pEvent = (PKEVENT)pvEvent;
+    KeSetEvent(pEvent, 0, FALSE);
+#endif
+}
+
+
+#define MEM_TAG 'HVBV'
+
+void *VBoxVideoCmnMemAllocDriver(PVBOXVIDEO_COMMON pCommon, size_t cb)
+{
+    ULONG Tag = MEM_TAG;
+#ifndef VBOX_WITH_WDDM
+    PDEVICE_EXTENSION PrimaryExtension = commonToPrimaryExt(pCommon);
+    return PrimaryExtension->u.primary.VideoPortProcs.pfnAllocatePool(PrimaryExtension, (VBOXVP_POOL_TYPE)VpNonPagedPool, cb, Tag);
+#else
+    return ExAllocatePoolWithTag(NonPagedPool, cb, Tag);
+#endif
+}
+
+
+void VBoxVideoCmnMemFreeDriver(PVBOXVIDEO_COMMON pCommon, void *pv)
+{
+#ifndef VBOX_WITH_WDDM
+    PDEVICE_EXTENSION PrimaryExtension = commonToPrimaryExt(pCommon);
+    PrimaryExtension->u.primary.VideoPortProcs.pfnFreePool(PrimaryExtension,
+                                                           pv);
+#else
+    ExFreePool(pv);
+#endif
+}
+
+static VOID VBoxVideoCmnMemZero(PVOID pvMem, ULONG cbMem)
+{
+#ifndef VBOX_WITH_WDDM
+    VideoPortZeroMemory(pvMem, cbMem);
+#else
+    memset(pvMem, 0, cbMem);
+#endif
+}
+
+
+#ifndef VBOX_WITH_WDDM
+static void VBoxSetupVideoPortFunctions(PDEVICE_EXTENSION PrimaryExtension,
+                                VBOXVIDEOPORTPROCS *pCallbacks,
+                                PVIDEO_PORT_CONFIG_INFO pConfigInfo);
+
 ULONG DriverEntry(IN PVOID Context1, IN PVOID Context2)
 {
@@ -147,108 +321,5 @@
     return rc;
 }
-
-/*+++
-
-Routine Description:
-
-    This routine is used to read back various registry values.
-
-Arguments:
-
-    HwDeviceExtension
-        Supplies a pointer to the miniport's device extension.
-
-    Context
-        Context value passed to the get registry parameters routine.
-        If this is not null assume it's a ULONG* and save the data value in it.
-
-    ValueName
-        Name of the value requested.
-
-    ValueData
-        Pointer to the requested data.
-
-    ValueLength
-        Length of the requested data.
-
-Return Value:
-
-    If the variable doesn't exist return an error,
-    else if a context is supplied assume it's a PULONG and fill in the value
-    and return no error, else if the value is non-zero return an error.
-
----*/
-VP_STATUS VBoxRegistryCallback(PVOID HwDeviceExtension, PVOID Context,
-                               PWSTR ValueName, PVOID ValueData, ULONG ValueLength)
-{
-    //dprintf(("VBoxVideo::VBoxRegistryCallback: Context: %p, ValueName: %S, ValueData: %p, ValueLength: %d\n",
-    //         Context, ValueName, ValueData, ValueLength));
-    if (ValueLength)
-    {
-        if (Context)
-            *(ULONG *)Context = *(PULONG)ValueData;
-        else if (*((PULONG)ValueData) != 0)
-            return ERROR_INVALID_PARAMETER;
-        return NO_ERROR;
-    }
-    else
-        return ERROR_INVALID_PARAMETER;
-}
-
-VP_STATUS VBoxVideoCmnRegQueryDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t *pVal)
-{
-    return VideoPortGetRegistryParameters(Reg, pName, FALSE, VBoxRegistryCallback, pVal);
-}
-
-VP_STATUS VBoxVideoCmnRegSetDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t Val)
-{
-    return VideoPortSetRegistryParameters(Reg, pName, &Val, sizeof(Val));
-}
-
-void VBoxVideoCmnSignalEvent(PVBOXVIDEO_COMMON pCommon, uint64_t pvEvent)
-{
-    PDEVICE_EXTENSION PrimaryExtension = commonToPrimaryExt(pCommon);
-#ifndef VBOX_WITH_WDDM
-    PEVENT pEvent = (PEVENT)pvEvent;
-    PrimaryExtension->u.primary.VideoPortProcs.pfnSetEvent(PrimaryExtension,
-                                                           pEvent);
-#else
-    PKEVENT pEvent = (PKEVENT)pvEvent;
-    KeSetEvent(pEvent, 0, FALSE);
-#endif
-}
-
-
-#define MEM_TAG 'HVBV'
-
-void *VBoxVideoCmnMemAllocDriver(PVBOXVIDEO_COMMON pCommon, size_t cb)
-{
-    ULONG Tag = MEM_TAG;
-#ifndef VBOX_WITH_WDDM
-    PDEVICE_EXTENSION PrimaryExtension = commonToPrimaryExt(pCommon);
-    return PrimaryExtension->u.primary.VideoPortProcs.pfnAllocatePool(PrimaryExtension, (VBOXVP_POOL_TYPE)VpNonPagedPool, cb, Tag);
-#else
-    return ExAllocatePoolWithTag(NonPagedPool, cb, Tag);
-#endif
-}
-
-
-void VBoxVideoCmnMemFreeDriver(PVBOXVIDEO_COMMON pCommon, void *pv)
-{
-#ifndef VBOX_WITH_WDDM
-    PDEVICE_EXTENSION PrimaryExtension = commonToPrimaryExt(pCommon);
-    PrimaryExtension->u.primary.VideoPortProcs.pfnFreePool(PrimaryExtension,
-                                                           pv);
-#else
-    ExFreePool(pv);
-#endif
-}
-
-
-static void VBoxSetupVideoPortFunctions(PDEVICE_EXTENSION PrimaryExtension,
-                                VBOXVIDEOPORTPROCS *pCallbacks,
-                                PVIDEO_PORT_CONFIG_INFO pConfigInfo);
-
-#endif /* #ifndef VBOX_WITH_WDDM */
+#endif
 
 #ifdef VBOX_WITH_GENERIC_MULTIMONITOR
@@ -2327,4 +2398,58 @@
 #endif
 
+void VBoxVideoCmnPortWriteUchar(RTIOPORT Port, uint8_t Value)
+{
+#ifndef VBOX_WITH_WDDM
+    VideoPortWritePortUchar((PUCHAR)Port,Value);
+#else
+    WRITE_PORT_UCHAR((PUCHAR)Port,Value);
+#endif
+}
+
+void VBoxVideoCmnPortWriteUshort(RTIOPORT Port, uint16_t Value)
+{
+#ifndef VBOX_WITH_WDDM
+    VideoPortWritePortUshort((PUSHORT)Port,Value);
+#else
+    WRITE_PORT_USHORT((PUSHORT)Port,Value);
+#endif
+}
+
+void VBoxVideoCmnPortWriteUlong(RTIOPORT Port, uint32_t Value)
+{
+#ifndef VBOX_WITH_WDDM
+    VideoPortWritePortUlong((PULONG)Port,Value);
+#else
+    WRITE_PORT_ULONG((PULONG)Port,Value);
+#endif
+}
+
+uint8_t VBoxVideoCmnPortReadUchar(RTIOPORT Port)
+{
+#ifndef VBOX_WITH_WDDM
+    return VideoPortReadPortUchar((PUCHAR)Port);
+#else
+    return READ_PORT_UCHAR((PUCHAR)Port);
+#endif
+}
+
+uint16_t VBoxVideoCmnPortReadUshort(RTIOPORT Port)
+{
+#ifndef VBOX_WITH_WDDM
+    return VideoPortReadPortUshort((PUSHORT)Port);
+#else
+    return READ_PORT_USHORT((PUSHORT)Port);
+#endif
+}
+
+uint32_t VBoxVideoCmnPortReadUlong(RTIOPORT Port)
+{
+#ifndef VBOX_WITH_WDDM
+    return VideoPortReadPortUlong((PULONG)Port);
+#else
+    return READ_PORT_ULONG((PULONG)Port);
+#endif
+}
+
 int VBoxMapAdapterMemory (PVBOXVIDEO_COMMON pCommon, void **ppv, ULONG ulOffset, ULONG ulSize)
 {
@@ -3646,13 +3771,13 @@
 {
     /* set the mode characteristics */
-    VBoxVideoCmnPortWriteUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_XRES);
-    VBoxVideoCmnPortWriteUshort((PUSHORT)VBE_DISPI_IOPORT_DATA, width);
-    VBoxVideoCmnPortWriteUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_YRES);
-    VBoxVideoCmnPortWriteUshort((PUSHORT)VBE_DISPI_IOPORT_DATA, height);
-    VBoxVideoCmnPortWriteUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_BPP);
-    VBoxVideoCmnPortWriteUshort((PUSHORT)VBE_DISPI_IOPORT_DATA, bpp);
+    VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_XRES);
+    VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_DATA, width);
+    VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_YRES);
+    VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_DATA, height);
+    VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_BPP);
+    VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_DATA, bpp);
     /* enable the mode */
-    VBoxVideoCmnPortWriteUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ENABLE);
-    VBoxVideoCmnPortWriteUshort((PUSHORT)VBE_DISPI_IOPORT_DATA, VBE_DISPI_ENABLED | VBE_DISPI_LFB_ENABLED);
+    VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ENABLE);
+    VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_DATA, VBE_DISPI_ENABLED | VBE_DISPI_LFB_ENABLED);
 #ifdef VBOX_WITH_WDDM
     /* encode linear offDisplay to xOffset & yOffset to ensure offset fits USHORT */
@@ -3671,8 +3796,8 @@
     Assert(xOffset <= 0xffff);
     Assert(yOffset <= 0xffff);
-    VBoxVideoCmnPortWriteUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_X_OFFSET);
-    VBoxVideoCmnPortWriteUshort((PUSHORT)VBE_DISPI_IOPORT_DATA, (USHORT)xOffset);
-    VBoxVideoCmnPortWriteUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_Y_OFFSET);
-    VBoxVideoCmnPortWriteUshort((PUSHORT)VBE_DISPI_IOPORT_DATA, (USHORT)yOffset);
+    VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_X_OFFSET);
+    VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_DATA, (USHORT)xOffset);
+    VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_Y_OFFSET);
+    VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_DATA, (USHORT)yOffset);
 #endif
     /** @todo read from the port to see if the mode switch was successful */
@@ -3903,8 +4028,8 @@
         Entry++)
    {
-      VBoxVideoCmnPortWriteUchar((PUCHAR)0x03c8, (UCHAR)Entry);
-      VBoxVideoCmnPortWriteUchar((PUCHAR)0x03c9, ColorLookUpTable->LookupTable[Entry].RgbArray.Red);
-      VBoxVideoCmnPortWriteUchar((PUCHAR)0x03c9, ColorLookUpTable->LookupTable[Entry].RgbArray.Green);
-      VBoxVideoCmnPortWriteUchar((PUCHAR)0x03c9, ColorLookUpTable->LookupTable[Entry].RgbArray.Blue);
+      VBoxVideoCmnPortWriteUchar(0x03c8, (UCHAR)Entry);
+      VBoxVideoCmnPortWriteUchar(0x03c9, ColorLookUpTable->LookupTable[Entry].RgbArray.Red);
+      VBoxVideoCmnPortWriteUchar(0x03c9, ColorLookUpTable->LookupTable[Entry].RgbArray.Green);
+      VBoxVideoCmnPortWriteUchar(0x03c9, ColorLookUpTable->LookupTable[Entry].RgbArray.Blue);
    }
 
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h	(revision 33875)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideo.h	(revision 33876)
@@ -112,7 +112,4 @@
 typedef UCHAR VBOXVCMNIRQL, *PVBOXVCMNIRQL;
 
-typedef PEVENT VBOXVCMNEVENT;
-typedef VBOXVCMNEVENT *PVBOXVCMNEVENT;
-
 typedef struct _DEVICE_EXTENSION * VBOXCMNREG;
 #else
@@ -137,7 +134,4 @@
 typedef KSPIN_LOCK VBOXVCMNSPIN_LOCK, *PVBOXVCMNSPIN_LOCK;
 typedef KIRQL VBOXVCMNIRQL, *PVBOXVCMNIRQL;
-
-typedef KEVENT VBOXVCMNEVENT;
-typedef VBOXVCMNEVENT *PVBOXVCMNEVENT;
 
 typedef HANDLE VBOXCMNREG;
@@ -384,45 +378,25 @@
 void VBoxVideoCmnMemFreeDriver(PVBOXVIDEO_COMMON pCommon, void *pv);
 
+/** Write an 8-bit value to an I/O port. */
+void VBoxVideoCmnPortWriteUchar(RTIOPORT Port, uint8_t Value);
+
+/** Write a 16-bit value to an I/O port. */
+void VBoxVideoCmnPortWriteUshort(RTIOPORT Port, uint16_t Value);
+
+/** Write a 32-bit value to an I/O port. */
+void VBoxVideoCmnPortWriteUlong(RTIOPORT Port, uint32_t Value);
+
+/** Read an 8-bit value from an I/O port. */
+uint8_t VBoxVideoCmnPortReadUchar(RTIOPORT Port);
+
+/** Read a 16-bit value from an I/O port. */
+uint16_t VBoxVideoCmnPortReadUshort(RTIOPORT Port);
+
+/** Read a 32-bit value from an I/O port. */
+uint32_t VBoxVideoCmnPortReadUlong(RTIOPORT Port);
+
 #ifndef VBOX_WITH_WDDM
 /* XPDM-WDDM common API */
 
-typedef PEVENT VBOXVCMNEVENT;
-typedef VBOXVCMNEVENT *PVBOXVCMNEVENT;
-
-DECLINLINE(VOID) VBoxVideoCmnPortWriteUchar(IN PUCHAR Port, IN UCHAR Value)
-{
-    VideoPortWritePortUchar(Port,Value);
-}
-
-DECLINLINE(VOID) VBoxVideoCmnPortWriteUshort(IN PUSHORT Port, IN USHORT Value)
-{
-    VideoPortWritePortUshort(Port,Value);
-}
-
-DECLINLINE(VOID) VBoxVideoCmnPortWriteUlong(IN PULONG Port, IN ULONG Value)
-{
-    VideoPortWritePortUlong(Port,Value);
-}
-
-DECLINLINE(UCHAR) VBoxVideoCmnPortReadUchar(IN PUCHAR  Port)
-{
-    return VideoPortReadPortUchar(Port);
-}
-
-DECLINLINE(USHORT) VBoxVideoCmnPortReadUshort(IN PUSHORT Port)
-{
-    return VideoPortReadPortUshort(Port);
-}
-
-DECLINLINE(ULONG) VBoxVideoCmnPortReadUlong(IN PULONG Port)
-{
-    return VideoPortReadPortUlong(Port);
-}
-
-DECLINLINE(VOID) VBoxVideoCmnMemZero(PVOID pvMem, ULONG cbMem)
-{
-    VideoPortZeroMemory(pvMem, cbMem);
-}
-
 DECLINLINE(VOID) VBoxVideoCmnSpinLockAcquire(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock, OUT PVBOXVCMNIRQL OldIrql)
 {
@@ -430,9 +404,4 @@
 }
 
-DECLINLINE(VOID) VBoxVideoCmnSpinLockAcquireAtDpcLevel(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
-{
-    pDeviceExtension->u.primary.VideoPortProcs.pfnAcquireSpinLockAtDpcLevel(pDeviceExtension, *SpinLock);
-}
-
 DECLINLINE(VOID) VBoxVideoCmnSpinLockRelease(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock, IN VBOXVCMNIRQL NewIrql)
 {
@@ -440,9 +409,4 @@
 }
 
-DECLINLINE(VOID) VBoxVideoCmnSpinLockReleaseFromDpcLevel(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
-{
-    pDeviceExtension->u.primary.VideoPortProcs.pfnReleaseSpinLockFromDpcLevel(pDeviceExtension, *SpinLock);
-}
-
 DECLINLINE(VP_STATUS) VBoxVideoCmnSpinLockCreate(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
 {
@@ -454,38 +418,4 @@
     return pDeviceExtension->u.primary.VideoPortProcs.pfnDeleteSpinLock(pDeviceExtension, *SpinLock);
 }
-
-DECLINLINE(LONG) VBoxVideoCmnEventSet(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent)
-{
-    return pDeviceExtension->u.primary.VideoPortProcs.pfnSetEvent(pDeviceExtension, (VBOXPEVENT)*pEvent); /** @todo slightly bogus cast */
-}
-
-DECLINLINE(VP_STATUS) VBoxVideoCmnEventCreateNotification(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent, IN BOOLEAN bSignaled)
-{
-    ULONG fFlags = NOTIFICATION_EVENT;
-    if(bSignaled)
-        fFlags |= INITIAL_EVENT_SIGNALED;
-
-    return pDeviceExtension->u.primary.VideoPortProcs.pfnCreateEvent(pDeviceExtension, fFlags, NULL, (VBOXPEVENT *)pEvent); /** @todo slightly bogus cast */
-}
-
-DECLINLINE(VP_STATUS) VBoxVideoCmnEventDelete(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent)
-{
-    return pDeviceExtension->u.primary.VideoPortProcs.pfnDeleteEvent(pDeviceExtension, (VBOXPEVENT)*pEvent); /** @todo slightly bogus cast */
-}
-
-DECLINLINE(VP_STATUS) VBoxVideoCmnRegInit(IN PDEVICE_EXTENSION pDeviceExtension, OUT VBOXCMNREG *pReg)
-{
-    *pReg = pDeviceExtension->pPrimary;
-    return NO_ERROR;
-}
-
-DECLINLINE(VP_STATUS) VBoxVideoCmnRegFini(IN VBOXCMNREG Reg)
-{
-    return NO_ERROR;
-}
-
-VP_STATUS VBoxVideoCmnRegQueryDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t *pVal);
-
-VP_STATUS VBoxVideoCmnRegSetDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t Val);
 
 /* */
@@ -498,38 +428,4 @@
 
 /* XPDM-WDDM common API */
-DECLINLINE(VOID) VBoxVideoCmnPortWriteUchar(IN PUCHAR Port, IN UCHAR Value)
-{
-    WRITE_PORT_UCHAR(Port,Value);
-}
-
-DECLINLINE(VOID) VBoxVideoCmnPortWriteUshort(IN PUSHORT Port, IN USHORT Value)
-{
-    WRITE_PORT_USHORT(Port,Value);
-}
-
-DECLINLINE(VOID) VBoxVideoCmnPortWriteUlong(IN PULONG Port, IN ULONG Value)
-{
-    WRITE_PORT_ULONG(Port,Value);
-}
-
-DECLINLINE(UCHAR) VBoxVideoCmnPortReadUchar(IN PUCHAR Port)
-{
-    return READ_PORT_UCHAR(Port);
-}
-
-DECLINLINE(USHORT) VBoxVideoCmnPortReadUshort(IN PUSHORT Port)
-{
-    return READ_PORT_USHORT(Port);
-}
-
-DECLINLINE(ULONG) VBoxVideoCmnPortReadUlong(IN PULONG Port)
-{
-    return READ_PORT_ULONG(Port);
-}
-
-DECLINLINE(VOID) VBoxVideoCmnMemZero(PVOID pvMem, ULONG cbMem)
-{
-    memset(pvMem, 0, cbMem);
-}
 
 DECLINLINE(VOID) VBoxVideoCmnSpinLockAcquire(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock, OUT PVBOXVCMNIRQL OldIrql)
@@ -538,17 +434,7 @@
 }
 
-DECLINLINE(VOID) VBoxVideoCmnSpinLockAcquireAtDpcLevel(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
-{
-    KeAcquireSpinLockAtDpcLevel(SpinLock);
-}
-
 DECLINLINE(VOID) VBoxVideoCmnSpinLockRelease(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock, IN VBOXVCMNIRQL NewIrql)
 {
     KeReleaseSpinLock(SpinLock, NewIrql);
-}
-
-DECLINLINE(VOID) VBoxVideoCmnSpinLockReleaseFromDpcLevel(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
-{
-    KeReleaseSpinLockFromDpcLevel(SpinLock);
 }
 
@@ -563,35 +449,4 @@
     return NO_ERROR;
 }
-
-DECLINLINE(LONG) VBoxVideoCmnEventSet(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent)
-{
-    return KeSetEvent(pEvent, 0, FALSE);
-}
-
-DECLINLINE(VP_STATUS) VBoxVideoCmnEventCreateNotification(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent, IN BOOLEAN bSignaled)
-{
-    KeInitializeEvent(pEvent, NotificationEvent, bSignaled);
-    return NO_ERROR;
-}
-
-DECLINLINE(VP_STATUS) VBoxVideoCmnEventDelete(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent)
-{
-    return NO_ERROR;
-}
-
-VP_STATUS VBoxVideoCmnRegInit(IN PDEVICE_EXTENSION pDeviceExtension, OUT VBOXCMNREG *pReg);
-
-DECLINLINE(VP_STATUS) VBoxVideoCmnRegFini(IN VBOXCMNREG Reg)
-{
-    if(!Reg)
-        return ERROR_INVALID_PARAMETER;
-
-    NTSTATUS Status = ZwClose(Reg);
-    return Status == STATUS_SUCCESS ? NO_ERROR : ERROR_INVALID_PARAMETER;
-}
-
-VP_STATUS VBoxVideoCmnRegQueryDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t *pVal);
-
-VP_STATUS VBoxVideoCmnRegSetDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t Val);
 
 /* */
@@ -801,20 +656,20 @@
 DECLINLINE(void) VBoxHGSMIHostWrite(PVBOXVIDEO_COMMON pCommon, ULONG data)
 {
-    VBoxVideoCmnPortWriteUlong((PULONG)pCommon->IOPortHost, data);
+    VBoxVideoCmnPortWriteUlong(pCommon->IOPortHost, data);
 }
 
 DECLINLINE(ULONG) VBoxHGSMIHostRead(PVBOXVIDEO_COMMON pCommon)
 {
-    return VBoxVideoCmnPortReadUlong((PULONG)pCommon->IOPortHost);
+    return VBoxVideoCmnPortReadUlong(pCommon->IOPortHost);
 }
 
 DECLINLINE(void) VBoxHGSMIGuestWrite(PVBOXVIDEO_COMMON pCommon, ULONG data)
 {
-    VBoxVideoCmnPortWriteUlong((PULONG)pCommon->IOPortGuest, data);
+    VBoxVideoCmnPortWriteUlong(pCommon->IOPortGuest, data);
 }
 
 DECLINLINE(ULONG) VBoxHGSMIGuestRead(PVBOXVIDEO_COMMON pCommon)
 {
-    return VBoxVideoCmnPortReadUlong((PULONG)pCommon->IOPortGuest);
+    return VBoxVideoCmnPortReadUlong(pCommon->IOPortGuest);
 }
 
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideoHGSMI.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideoHGSMI.cpp	(revision 33875)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/VBoxVideoHGSMI.cpp	(revision 33876)
@@ -97,8 +97,8 @@
     USHORT DispiId;
 
-    VBoxVideoCmnPortWriteUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ID);
-    VBoxVideoCmnPortWriteUshort((PUSHORT)VBE_DISPI_IOPORT_DATA, VBE_DISPI_ID_HGSMI);
-
-    DispiId = VBoxVideoCmnPortReadUshort((PUSHORT)VBE_DISPI_IOPORT_DATA);
+    VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ID);
+    VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_DATA, VBE_DISPI_ID_HGSMI);
+
+    DispiId = VBoxVideoCmnPortReadUshort(VBE_DISPI_IOPORT_DATA);
 
     return (DispiId == VBE_DISPI_ID_HGSMI);
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp	(revision 33875)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp	(revision 33876)
@@ -307,41 +307,4 @@
 
 
-VP_STATUS VBoxVideoCmnRegQueryDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t *pVal)
-{
-    if(!Reg)
-        return ERROR_INVALID_PARAMETER;
-    NTSTATUS Status = vboxWddmRegQueryValueDword(Reg, pName, (PDWORD)pVal);
-    return Status == STATUS_SUCCESS ? NO_ERROR : ERROR_INVALID_PARAMETER;
-}
-
-VP_STATUS VBoxVideoCmnRegSetDword(IN VBOXCMNREG Reg, PWSTR pName, uint32_t Val)
-{
-    if(!Reg)
-        return ERROR_INVALID_PARAMETER;
-    NTSTATUS Status = vboxWddmRegSetValueDword(Reg, pName, Val);
-    return Status == STATUS_SUCCESS ? NO_ERROR : ERROR_INVALID_PARAMETER;
-}
-
-VP_STATUS VBoxVideoCmnRegInit(IN PDEVICE_EXTENSION pDeviceExtension, OUT VBOXCMNREG *pReg)
-{
-    WCHAR Buf[512];
-    ULONG cbBuf = sizeof(Buf);
-    NTSTATUS Status = vboxWddmRegQueryDrvKeyName(pDeviceExtension, cbBuf, Buf, &cbBuf);
-    Assert(Status == STATUS_SUCCESS);
-    if (Status == STATUS_SUCCESS)
-    {
-        Status = vboxWddmRegOpenKey(pReg, Buf, GENERIC_READ | GENERIC_WRITE);
-        Assert(Status == STATUS_SUCCESS);
-        if(Status == STATUS_SUCCESS)
-            return NO_ERROR;
-    }
-
-    /* fall-back to make the subsequent VBoxVideoCmnRegXxx calls treat the fail accordingly
-     * basically needed to make as less modifications to the current XPDM code as possible */
-    *pReg = NULL;
-
-    return ERROR_INVALID_PARAMETER;
-}
-
 D3DDDIFORMAT vboxWddmCalcPixelFormat(VIDEO_MODE_INFORMATION *pInfo)
 {
@@ -416,7 +379,7 @@
     *pAdapterMemorySize = VBE_DISPI_TOTAL_VIDEO_MEMORY_BYTES;
 
-    VBoxVideoCmnPortWriteUshort((PUSHORT)VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ID);
-    VBoxVideoCmnPortWriteUshort((PUSHORT)VBE_DISPI_IOPORT_DATA, VBE_DISPI_ID2);
-    DispiId = VBoxVideoCmnPortReadUshort((PUSHORT)VBE_DISPI_IOPORT_DATA);
+    VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_ID);
+    VBoxVideoCmnPortWriteUshort(VBE_DISPI_IOPORT_DATA, VBE_DISPI_ID2);
+    DispiId = VBoxVideoCmnPortReadUshort(VBE_DISPI_IOPORT_DATA);
     if (DispiId == VBE_DISPI_ID2)
     {
@@ -431,5 +394,5 @@
         * an ULONG from the data port without setting an index before.
         */
-       *pAdapterMemorySize = VBoxVideoCmnPortReadUlong((PULONG)VBE_DISPI_IOPORT_DATA);
+       *pAdapterMemorySize = VBoxVideoCmnPortReadUlong(VBE_DISPI_IOPORT_DATA);
        if (VBoxHGSMIIsSupported ())
        {
