win-pvdrivers

changeset 2:d47d595b0b19

Added a new PCI driver that can hide the Xen provided PCI devices
author James Harper <james.harper@bendigoit.com.au>
date Sun Nov 11 15:16:58 2007 +1100 (2007-11-11)
parents b16f2f5eb611
children 0cd078f41eed
files xenhide/makefile xenhide/sources xenhide/target/xenhide.inf xenhide/xenhide.c xenhide/xenhide.h
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xenhide/makefile	Sun Nov 11 15:16:58 2007 +1100
     1.3 @@ -0,0 +1,1 @@
     1.4 +!INCLUDE $(NTMAKEENV)\makefile.def
     1.5 \ No newline at end of file
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/xenhide/sources	Sun Nov 11 15:16:58 2007 +1100
     2.3 @@ -0,0 +1,14 @@
     2.4 +TARGETNAME=XENHIDE
     2.5 +TARGETTYPE=DRIVER
     2.6 +TARGETPATH=Target
     2.7 +
     2.8 +MSC_WARNING_LEVEL=/W4
     2.9 +
    2.10 +INCLUDES = ..\common\include;..\common\include\public
    2.11 +
    2.12 +NO_BINPLACE=1
    2.13 +KMDF_VERSION=1
    2.14 +TARGETLIBS=$(DDK_LIB_PATH)\ntstrsafe.lib
    2.15 +
    2.16 +SOURCES=xenhide.c
    2.17 +
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/xenhide/target/xenhide.inf	Sun Nov 11 15:16:58 2007 +1100
     3.3 @@ -0,0 +1,101 @@
     3.4 +[Version]
     3.5 +Signature="$WINDOWS NT$"
     3.6 +Class=System
     3.7 +ClassGuid={4d36e97d-e325-11ce-bfc1-08002be10318}
     3.8 +Provider=%JAMESHARPER%
     3.9 +DriverVer=11/11/2007,1.0.0.21
    3.10 +
    3.11 +[ControlFlags]
    3.12 +ExcludeFromSelect = *
    3.13 +
    3.14 +[DestinationDirs]
    3.15 +DefaultDestDir = 12
    3.16 +;ClassInstall32_CopyFiles=11
    3.17 +CoInstaller_CopyFiles = 11
    3.18 +
    3.19 +; ================= Class section =====================
    3.20 +;
    3.21 +;[ClassInstall32]
    3.22 +;Addreg=ClassInstall32_AddReg
    3.23 +;CopyFiles=ClassInstall32_CopyFiles
    3.24 +;
    3.25 +;[ClassInstall32_AddReg]
    3.26 +;HKR,,,0,%ClassName%
    3.27 +;HKR,,Icon,,100
    3.28 +;HKR,,DeviceCharacteristics,0x10001,0x100     ;Use same security checks on relative opens
    3.29 +;HKR,,Security,,"D:P(A;;GA;;;SY)(A;;GA;;;BA)" ;Allow generic all access to system and built-in Admin. 
    3.30 +
    3.31 +;[ClassInstall32_CopyFiles]
    3.32 +
    3.33 +; ================= Device Install section =====================
    3.34 +
    3.35 +[Manufacturer]
    3.36 +%JAMESHARPER%=JAMESHARPER,NTx86
    3.37 +
    3.38 +; For Win2K
    3.39 +[JAMESHARPER]
    3.40 +%XenHide.DRVDESC%=XenHide_Inst, *PNP0A03
    3.41 +
    3.42 +; For XP and later
    3.43 +[JAMESHARPER.NTx86]
    3.44 +%XenHide.DRVDESC%=XenHide_Inst, *PNP0A03
    3.45 +
    3.46 +[XenHide_Inst.NT]
    3.47 +Include=machine.inf
    3.48 +Needs=PCI_DRV_ROOT.NT
    3.49 +CopyFiles=XenHide.CopyFiles
    3.50 +;AddReg=
    3.51 +
    3.52 +[XenHide_Inst.NT.HW]
    3.53 +AddReg = XenHide_Inst_HW_AddReg
    3.54 +Include=machine.inf
    3.55 +Needs=PCI_DRV_ROOT.HW
    3.56 +
    3.57 +[XenHide_Inst_HW_AddReg]
    3.58 +HKR,,"LowerFilters",0x00010000,"XenHide"
    3.59 +
    3.60 +[XenHide.CopyFiles]
    3.61 +xenhide.sys
    3.62 +
    3.63 +[SourceDisksFiles]
    3.64 +xenhide.sys=1
    3.65 +WdfCoinstaller01005.dll=1,,
    3.66 +
    3.67 +[SourceDisksNames.x86]
    3.68 +1 = %DISK_NAME%,,,\i386
    3.69 +
    3.70 +[XenHide_Inst.NT.Services]
    3.71 +AddService=XenHide,,XenHide_Service_Inst
    3.72 +Include=Machine.inf
    3.73 +;Needs=PCI_DRV_ROOT.NT.Services
    3.74 +Needs=PCI_DRV_ROOT.Services
    3.75 +
    3.76 +[XenHide_Service_Inst]
    3.77 +DisplayName    = %XenHide.SVCDESC%                            
    3.78 +ServiceType    = 1
    3.79 +StartType      = 0
    3.80 +ErrorControl   = 1
    3.81 +ServiceBinary  = %12%\xenhide.sys                          
    3.82 +
    3.83 +[XenHide_Inst.NT.CoInstallers]
    3.84 +AddReg=CoInstaller_AddReg
    3.85 +CopyFiles=CoInstaller_CopyFiles
    3.86 +
    3.87 +[CoInstaller_CopyFiles]
    3.88 +WdfCoinstaller01005.dll,,,2
    3.89 +
    3.90 +[CoInstaller_AddReg]
    3.91 +HKR,,CoInstallers32,0x00010000, "WdfCoinstaller01005.dll,WdfCoInstaller"
    3.92 +
    3.93 +[XenHide_Inst.NT.Wdf]
    3.94 +KmdfService = xenhide, XenHide_WDFSect
    3.95 +
    3.96 +[XenHide_WDFSect]
    3.97 +KmdfLibraryVersion = 1.0
    3.98 +
    3.99 +[Strings]
   3.100 +JAMESHARPER = "James Harper"
   3.101 +ClassName = "System devices"
   3.102 +XenHide.SVCDESC = "Xen PCI Device Hider Driver"
   3.103 +XenHide.DRVDESC = "Xen PCI Device Hider Driver"
   3.104 +DISK_NAME = "Xen PCI Device Driver Hider Install Disk"
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/xenhide/xenhide.c	Sun Nov 11 15:16:58 2007 +1100
     4.3 @@ -0,0 +1,310 @@
     4.4 +/*
     4.5 +PV Drivers for Windows Xen HVM Domains
     4.6 +Copyright (C) 2007 James Harper
     4.7 +
     4.8 +This program is free software; you can redistribute it and/or
     4.9 +modify it under the terms of the GNU General Public License
    4.10 +as published by the Free Software Foundation; either version 2
    4.11 +of the License, or (at your option) any later version.
    4.12 +
    4.13 +This program is distributed in the hope that it will be useful,
    4.14 +but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.15 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    4.16 +GNU General Public License for more details.
    4.17 +
    4.18 +You should have received a copy of the GNU General Public License
    4.19 +along with this program; if not, write to the Free Software
    4.20 +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    4.21 +*/
    4.22 +
    4.23 +#include "xenhide.h"
    4.24 +#include <stdlib.h>
    4.25 +
    4.26 +DRIVER_INITIALIZE DriverEntry;
    4.27 +static NTSTATUS
    4.28 +XenHide_AddDevice(WDFDRIVER Driver, PWDFDEVICE_INIT DeviceInit);
    4.29 +static VOID
    4.30 +XenHide_IoInternalDeviceControl(WDFQUEUE Queue, WDFREQUEST Request, size_t OutputBufferLength, size_t InputBufferLength, ULONG IoControlCode);
    4.31 +
    4.32 +#ifdef ALLOC_PRAGMA
    4.33 +#pragma alloc_text (INIT, DriverEntry)
    4.34 +#pragma alloc_text (PAGE, XenHide_AddDevice)
    4.35 +#endif
    4.36 +
    4.37 +static BOOLEAN AutoEnumerate;
    4.38 +
    4.39 +static WDFDEVICE Device;
    4.40 +
    4.41 +NTSTATUS
    4.42 +DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
    4.43 +{
    4.44 +  WDF_DRIVER_CONFIG config;
    4.45 +  NTSTATUS status;
    4.46 +  UNICODE_STRING RegKeyName;
    4.47 +  UNICODE_STRING RegValueName;
    4.48 +  HANDLE RegHandle;
    4.49 +  OBJECT_ATTRIBUTES RegObjectAttributes;
    4.50 +  char Buf[200];
    4.51 +  ULONG BufLen = 200;
    4.52 +  PKEY_VALUE_PARTIAL_INFORMATION KeyPartialValue;
    4.53 +  int State = 0;
    4.54 +  int StartPos = 0;
    4.55 +  WCHAR *SystemStartOptions;
    4.56 +  size_t SystemStartOptionsLen;
    4.57 +  size_t i;
    4.58 +
    4.59 +  KdPrint((__DRIVER_NAME " --> DriverEntry\n"));
    4.60 +
    4.61 +  RtlInitUnicodeString(&RegKeyName, L"\\Registry\\Machine\\System\\CurrentControlSet\\Control");
    4.62 +  InitializeObjectAttributes(&RegObjectAttributes, &RegKeyName, OBJ_CASE_INSENSITIVE, NULL, NULL);
    4.63 +  status = ZwOpenKey(&RegHandle, KEY_READ, &RegObjectAttributes);
    4.64 +  if(!NT_SUCCESS(status))
    4.65 +  {
    4.66 +    KdPrint((__DRIVER_NAME "     ZwOpenKey returned %08x\n", status));
    4.67 +  }
    4.68 +
    4.69 +  RtlInitUnicodeString(&RegValueName, L"SystemStartOptions");
    4.70 +  status = ZwQueryValueKey(RegHandle, &RegValueName, KeyValuePartialInformation, Buf, BufLen, &BufLen);
    4.71 +  if(!NT_SUCCESS(status))
    4.72 +  {
    4.73 +    KdPrint((__DRIVER_NAME "     ZwQueryKeyValue returned %08x\n", status));
    4.74 +  }
    4.75 +  KdPrint((__DRIVER_NAME "     BufLen = %d\n", BufLen));
    4.76 +  KeyPartialValue = (PKEY_VALUE_PARTIAL_INFORMATION)Buf;
    4.77 +  KdPrint((__DRIVER_NAME "     Buf = %ws\n", KeyPartialValue->Data));
    4.78 +  SystemStartOptions = (WCHAR *)KeyPartialValue->Data;
    4.79 +
    4.80 +  AutoEnumerate = FALSE;
    4.81 +
    4.82 +  RtlStringCbLengthW(SystemStartOptions, KeyPartialValue->DataLength, &SystemStartOptionsLen);
    4.83 +
    4.84 +  for (i = 0; i <= SystemStartOptionsLen/2; i++)
    4.85 +  {
    4.86 +    //KdPrint((__DRIVER_NAME "     pos = %d, state = %d, char = '%wc' (%d)\n", i, State, SystemStartOptions[i], SystemStartOptions[i]));
    4.87 +    
    4.88 +    switch (State)
    4.89 +    {
    4.90 +    case 0:
    4.91 +      if (SystemStartOptions[i] == L'G')
    4.92 +      {
    4.93 +        StartPos = i;
    4.94 +        State = 2;
    4.95 +      } else if (SystemStartOptions[i] != L' ')
    4.96 +      {
    4.97 +        State = 1;
    4.98 +      }
    4.99 +      break;
   4.100 +    case 1:
   4.101 +      if (SystemStartOptions[i] == L' ')
   4.102 +        State = 0;
   4.103 +      break;
   4.104 +    case 2:
   4.105 +      if (SystemStartOptions[i] == L'P')
   4.106 +        State = 3;
   4.107 +      else
   4.108 +        State = 0;
   4.109 +      break;
   4.110 +    case 3:
   4.111 +      if (SystemStartOptions[i] == L'L')
   4.112 +        State = 4;
   4.113 +      else
   4.114 +        State = 0;
   4.115 +      break;
   4.116 +    case 4:
   4.117 +      if (SystemStartOptions[i] == L'P')
   4.118 +        State = 5;
   4.119 +      else
   4.120 +        State = 0;
   4.121 +      break;
   4.122 +    case 5:
   4.123 +      if (SystemStartOptions[i] == L'V')
   4.124 +        State = 6;
   4.125 +      else
   4.126 +        State = 0;
   4.127 +      break;
   4.128 +    case 6:
   4.129 +      if (SystemStartOptions[i] == L' ' || SystemStartOptions[i] == 0)
   4.130 +        AutoEnumerate = TRUE;
   4.131 +      State = 0;
   4.132 +      break;
   4.133 +    }
   4.134 +  }
   4.135 +
   4.136 +  KdPrint((__DRIVER_NAME "     AutoEnumerate = %d\n", AutoEnumerate));
   4.137 +
   4.138 +
   4.139 +  WDF_DRIVER_CONFIG_INIT(&config, XenHide_AddDevice);
   4.140 +  status = WdfDriverCreate(
   4.141 +                      DriverObject,
   4.142 +                      RegistryPath,
   4.143 +                      WDF_NO_OBJECT_ATTRIBUTES,
   4.144 +                      &config,
   4.145 +                      WDF_NO_HANDLE);
   4.146 +  if(!NT_SUCCESS(status))
   4.147 +  {
   4.148 +    //KdPrint((__DRIVER_NAME " WdfDriverCreate failed with status 0x%08x\n", status));
   4.149 +  }
   4.150 +
   4.151 +  KdPrint((__DRIVER_NAME " <-- DriverEntry\n"));
   4.152 +
   4.153 +  return status;
   4.154 +}
   4.155 +
   4.156 +static NTSTATUS
   4.157 +XenHide_PreprocessWdmIrpPNP(WDFDEVICE Device, PIRP Irp);
   4.158 +
   4.159 +static NTSTATUS
   4.160 +XenHide_AddDevice(
   4.161 +    IN WDFDRIVER Driver,
   4.162 +    IN PWDFDEVICE_INIT DeviceInit
   4.163 +    )
   4.164 +{
   4.165 +  NTSTATUS status;
   4.166 +  WDF_OBJECT_ATTRIBUTES attributes;
   4.167 +  UCHAR MinorFunctions[1] = { IRP_MN_QUERY_DEVICE_RELATIONS };
   4.168 +
   4.169 +  UNREFERENCED_PARAMETER(Driver);
   4.170 +
   4.171 +  KdPrint((__DRIVER_NAME " --> DeviceAdd\n"));
   4.172 +
   4.173 +  WdfFdoInitSetFilter(DeviceInit);
   4.174 +
   4.175 +  WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
   4.176 +
   4.177 +  WdfDeviceInitAssignWdmIrpPreprocessCallback(DeviceInit, XenHide_PreprocessWdmIrpPNP, IRP_MJ_PNP, MinorFunctions, 1);
   4.178 +
   4.179 +  status = WdfDeviceCreate(&DeviceInit, &attributes, &Device);  
   4.180 +  if(!NT_SUCCESS(status))
   4.181 +  {
   4.182 +    KdPrint((__DRIVER_NAME "     WdfDeviceCreate failed with status 0x%08x\n", status));
   4.183 +    return status;
   4.184 +  }
   4.185 +
   4.186 +  KdPrint((__DRIVER_NAME " <-- DeviceAdd\n"));
   4.187 +
   4.188 +  return status;
   4.189 +}
   4.190 +
   4.191 +static int
   4.192 +XenHide_StringMatches(PWCHAR String1, PWCHAR String2)
   4.193 +{
   4.194 +  for(;*String1 != 0 && *String2 != 0 && *String1 == *String2; String1++, String2++);
   4.195 +  return ((*String1 == 0 && *String2 == 0) || (*String1 == 0 && *String2 == L'\n') || (*String1 == L'\n' && *String2 == 0));
   4.196 +}
   4.197 +
   4.198 +static NTSTATUS
   4.199 +XenHide_IoCompletion(PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Context)
   4.200 +{
   4.201 +  ULONG i;
   4.202 +  PDEVICE_RELATIONS Relations;
   4.203 +  WCHAR Buffer[1000];
   4.204 +  PWCHAR Ptr;
   4.205 +  ULONG Length;
   4.206 +  size_t StrLen;
   4.207 +  int Match;
   4.208 +  int Offset = 0;
   4.209 +
   4.210 +  UNREFERENCED_PARAMETER(DeviceObject);
   4.211 +  UNREFERENCED_PARAMETER(Context);
   4.212 +
   4.213 +  KdPrint((__DRIVER_NAME " --> IoCompletion\n"));
   4.214 +
   4.215 +  Relations = (PDEVICE_RELATIONS)Irp->IoStatus.Information;
   4.216 +
   4.217 +  for (i = 0; i < Relations->Count; i++)
   4.218 +  {
   4.219 +    Length = 1000;
   4.220 +    IoGetDeviceProperty(Relations->Objects[i], DevicePropertyDeviceDescription, Length, Buffer, &Length);
   4.221 +    KdPrint((__DRIVER_NAME "     %3d - %ws\n", i, Buffer));
   4.222 +    Length = 1000;
   4.223 +    IoGetDeviceProperty(Relations->Objects[i], DevicePropertyHardwareID, Length, Buffer, &Length);
   4.224 +    Match = 0;
   4.225 +    StrLen = 0;
   4.226 +    for (Ptr = Buffer; *Ptr != 0; Ptr += StrLen + 1)
   4.227 +    {
   4.228 +      KdPrint((__DRIVER_NAME "         - %ws\n", Ptr));
   4.229 +      if (XenHide_StringMatches(Ptr, L"PCI\\VEN_8086&DEV_7010&SUBSYS_00015853")) {
   4.230 +        Match = 1;
   4.231 +        break;
   4.232 +      }
   4.233 +      RtlStringCchLengthW(Ptr, Length, &StrLen);
   4.234 +    }
   4.235 +    if (Match)
   4.236 +    {
   4.237 +      KdPrint((__DRIVER_NAME "           (Match)\n"));
   4.238 +      Offset++;
   4.239 +    }
   4.240 +    if (Offset != 0)
   4.241 +      Relations->Objects[i] = Relations->Objects[i + Offset];
   4.242 +  }
   4.243 +  Relations->Count -= Offset;
   4.244 +  
   4.245 +  KdPrint((__DRIVER_NAME " <-- IoCompletion\n"));
   4.246 +
   4.247 +  return Irp->IoStatus.Status;
   4.248 +}
   4.249 +
   4.250 +
   4.251 +
   4.252 +static NTSTATUS
   4.253 +XenHide_PreprocessWdmIrpPNP(WDFDEVICE Device, PIRP Irp)
   4.254 +{
   4.255 +  NTSTATUS Status = STATUS_SUCCESS;
   4.256 +  PIO_STACK_LOCATION Stack;
   4.257 +
   4.258 +  KdPrint((__DRIVER_NAME " --> WdmIrpPreprocessPNP\n"));
   4.259 +
   4.260 +  Stack = IoGetCurrentIrpStackLocation(Irp);
   4.261 +
   4.262 +  switch (Stack->MinorFunction) {
   4.263 +  case IRP_MN_QUERY_DEVICE_RELATIONS:
   4.264 +    KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_DEVICE_RELATIONS Device = %08x Irp = %08x, Stack = %08x\n", Device, Irp, Stack));
   4.265 +    switch (Stack->Parameters.QueryDeviceRelations.Type)
   4.266 +    {
   4.267 +    case BusRelations:
   4.268 +      KdPrint((__DRIVER_NAME "       BusRelations\n"));
   4.269 +      if (AutoEnumerate)
   4.270 +      {
   4.271 +        IoCopyCurrentIrpStackLocationToNext(Irp);
   4.272 +        IoSetCompletionRoutine(Irp, XenHide_IoCompletion, NULL, TRUE, TRUE, TRUE);
   4.273 +        Status = WdfDeviceWdmDispatchPreprocessedIrp(Device, Irp);
   4.274 +      }
   4.275 +      else
   4.276 +      {
   4.277 +        IoSkipCurrentIrpStackLocation(Irp);
   4.278 +        Status = WdfDeviceWdmDispatchPreprocessedIrp(Device, Irp);
   4.279 +      }
   4.280 +      break;  
   4.281 +    case EjectionRelations: 
   4.282 +      IoSkipCurrentIrpStackLocation(Irp);
   4.283 +      Status = WdfDeviceWdmDispatchPreprocessedIrp(Device, Irp);
   4.284 +      KdPrint((__DRIVER_NAME "       EjectionRelations\n"));
   4.285 +      break;  
   4.286 +    case RemovalRelations:
   4.287 +      IoSkipCurrentIrpStackLocation(Irp);
   4.288 +      Status = WdfDeviceWdmDispatchPreprocessedIrp(Device, Irp);
   4.289 +      KdPrint((__DRIVER_NAME "       RemovalRelations\n"));
   4.290 +      break;  
   4.291 +    case TargetDeviceRelation:
   4.292 +      IoSkipCurrentIrpStackLocation(Irp);
   4.293 +      Status = WdfDeviceWdmDispatchPreprocessedIrp(Device, Irp);
   4.294 +      KdPrint((__DRIVER_NAME "       TargetDeviceRelation\n"));
   4.295 +      break;  
   4.296 +    default:
   4.297 +      IoSkipCurrentIrpStackLocation(Irp);
   4.298 +      Status = WdfDeviceWdmDispatchPreprocessedIrp(Device, Irp);
   4.299 +      KdPrint((__DRIVER_NAME "     Unknown Type %d\n", Stack->Parameters.QueryDeviceRelations.Type));
   4.300 +      break;  
   4.301 +    }
   4.302 +    break;
   4.303 +  default:
   4.304 +    IoSkipCurrentIrpStackLocation(Irp);
   4.305 +    Status = WdfDeviceWdmDispatchPreprocessedIrp(Device, Irp);
   4.306 +    KdPrint((__DRIVER_NAME "     Unknown Minor %d\n", Stack->MinorFunction));
   4.307 +    break;
   4.308 +  }
   4.309 +
   4.310 +  KdPrint((__DRIVER_NAME " <-- WdmIrpPreprocessPNP (returning with status %08x\n", Status));
   4.311 +
   4.312 +  return Status;
   4.313 +}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/xenhide/xenhide.h	Sun Nov 11 15:16:58 2007 +1100
     5.3 @@ -0,0 +1,105 @@
     5.4 +/*
     5.5 +PV Drivers for Windows Xen HVM Domains
     5.6 +Copyright (C) 2007 James Harper
     5.7 +
     5.8 +This program is free software; you can redistribute it and/or
     5.9 +modify it under the terms of the GNU General Public License
    5.10 +as published by the Free Software Foundation; either version 2
    5.11 +of the License, or (at your option) any later version.
    5.12 +
    5.13 +This program is distributed in the hope that it will be useful,
    5.14 +but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.15 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    5.16 +GNU General Public License for more details.
    5.17 +
    5.18 +You should have received a copy of the GNU General Public License
    5.19 +along with this program; if not, write to the Free Software
    5.20 +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    5.21 +*/
    5.22 +
    5.23 +#if !defined(_XENHIDE_H_)
    5.24 +#define _XENHIDE_H_
    5.25 +
    5.26 +#define __attribute__(arg) /* empty */
    5.27 +#define EISCONN 127
    5.28 +
    5.29 +#include <ntddk.h>
    5.30 +#include <wdm.h>
    5.31 +#include <wdf.h>
    5.32 +#include <initguid.h>
    5.33 +#include <wdmguid.h>
    5.34 +#include <errno.h>
    5.35 +
    5.36 +#define NTSTRSAFE_LIB
    5.37 +#include <ntstrsafe.h>
    5.38 +
    5.39 +#include <xen_windows.h>
    5.40 +
    5.41 +#include <memory.h>
    5.42 +#include <grant_table.h>
    5.43 +#include <event_channel.h>
    5.44 +#include <hvm/params.h>
    5.45 +#include <hvm/hvm_op.h>
    5.46 +
    5.47 +//{C828ABE9-14CA-4445-BAA6-82C2376C6518}
    5.48 +//DEFINE_GUID( GUID_XENPCI_DEVCLASS, 0xC828ABE9, 0x14CA, 0x4445, 0xBA, 0xA6, 0x82, 0xC2, 0x37, 0x6C, 0x65, 0x18);
    5.49 +
    5.50 +#define __DRIVER_NAME "XenHide"
    5.51 +#define XENHIDE_POOL_TAG (ULONG) 'XenH'
    5.52 +//#define XENHIDE_FDO_INSTANCE_SIGNATURE (ULONG) 'XENP'
    5.53 +
    5.54 +#define NR_RESERVED_ENTRIES 8
    5.55 +#define NR_GRANT_FRAMES 4
    5.56 +#define NR_GRANT_ENTRIES (NR_GRANT_FRAMES * PAGE_SIZE / sizeof(grant_entry_t))
    5.57 +
    5.58 +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
    5.59 +
    5.60 +extern char *hypercall_stubs;
    5.61 +
    5.62 +typedef struct _XENHIDE_IDENTIFICATION_DESCRIPTION
    5.63 +{
    5.64 +  WDF_CHILD_IDENTIFICATION_DESCRIPTION_HEADER Header;
    5.65 +  UNICODE_STRING DeviceType;
    5.66 +//  ULONG DeviceIndex;
    5.67 +  char Path[128];
    5.68 +} XENHIDE_IDENTIFICATION_DESCRIPTION, *PXENHIDE_IDENTIFICATION_DESCRIPTION;
    5.69 +
    5.70 +
    5.71 +typedef struct {
    5.72 +  WDFQUEUE          IoDefaultQueue;
    5.73 +
    5.74 +  // Resources
    5.75 +  //WDFINTERRUPT      Interrupt;
    5.76 +  //PULONG            PhysAddress;
    5.77 +
    5.78 +  //ULONG platform_mmio_addr;
    5.79 +  //ULONG platform_mmio_len;
    5.80 +  //ULONG platform_mmio_alloc;
    5.81 +
    5.82 +  //ULONG shared_info_frame;
    5.83 +  //char *hypercall_stubs;
    5.84 +
    5.85 +  //PULONG            IoBaseAddress;
    5.86 +  //ULONG             IoRange;
    5.87 +
    5.88 +  // Grant Table stuff
    5.89 +
    5.90 +  //grant_entry_t *gnttab_table;
    5.91 +  //grant_ref_t gnttab_list[NR_GRANT_ENTRIES];
    5.92 +
    5.93 +} XENHIDE_DEVICE_DATA, *PXENHIDE_DEVICE_DATA;
    5.94 +
    5.95 +WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(XENHIDE_DEVICE_DATA, GetDeviceData);
    5.96 +
    5.97 +typedef unsigned long xenbus_transaction_t;
    5.98 +typedef uint32_t XENSTORE_RING_IDX;
    5.99 +
   5.100 +#define XBT_NIL ((xenbus_transaction_t)0)
   5.101 +
   5.102 +#include <evtchn_public.h>
   5.103 +#include <xenbus_public.h>
   5.104 +#include <xen_public.h>
   5.105 +#include <gnttbl_public.h>
   5.106 +
   5.107 +
   5.108 +#endif