win-pvdrivers

changeset 184:524ffdb246b6

Updates to xenhide to properly hide intel ide and realtek network device, without resorting to tricks that the wdm documentation frowns upon.
author James Harper <james.harper@bendigoit.com.au>
date Wed Feb 13 23:25:32 2008 +1100 (2008-02-13)
parents 8d778a60aa2c
children e13475347e4a
files common.inc makedist.bat xenhide/makefile.inc xenhide/sources xenhide/xenhide.c xenhide/xenhide.h xenpci/xenpci.inx
line diff
     1.1 --- a/common.inc	Wed Feb 06 15:39:32 2008 +1100
     1.2 +++ b/common.inc	Wed Feb 13 23:25:32 2008 +1100
     1.3 @@ -1,4 +1,4 @@
     1.4 -VERSION=0.7.0.5
     1.5 +VERSION=0.7.0.44
     1.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     1.7  KMDF_VERSION=1
     1.8  !IF $(_NT_TOOLS_VERSION) > 0x700
     2.1 --- a/makedist.bat	Wed Feb 06 15:39:32 2008 +1100
     2.2 +++ b/makedist.bat	Wed Feb 13 23:25:32 2008 +1100
     2.3 @@ -1,5 +1,5 @@
     2.4  @echo off
     2.5 -cmd /C "C:\WinDDK\6001.17121\bin\setenv.bat C:\WinDDK\6001.17121\ chk AMD64 WNET && CD \Projects\win-pvdrivers.hg && build -cZg"
     2.6 +cmd /C "C:\WinDDK\6001.17121\bin\setenv.bat C:\WinDDK\6001.17121\ chk x64 WNET && CD \Projects\win-pvdrivers.hg && build -cZg"
     2.7  cmd /C "C:\WinDDK\6001.17121\bin\setenv.bat C:\WinDDK\6001.17121\ chk WNET && CD \Projects\win-pvdrivers.hg && build -cZg"
     2.8  cmd /C "C:\WinDDK\6001.17121\bin\setenv.bat C:\WinDDK\6001.17121\ chk WXP && CD \Projects\win-pvdrivers.hg && build -cZg"
     2.9  xcopy target\* dist /E /EXCLUDE:exclude.txt /I /D /Y
     3.1 --- a/xenhide/makefile.inc	Wed Feb 06 15:39:32 2008 +1100
     3.2 +++ b/xenhide/makefile.inc	Wed Feb 13 23:25:32 2008 +1100
     3.3 @@ -1,6 +0,0 @@
     3.4 -_LNG=$(LANGUAGE)
     3.5 -STAMP=stampinf -f $@ -a $(_BUILDARCH) -d * -v $(VERSION)
     3.6 -
     3.7 -..\Target\$(DDK_TARGET_OS)\$(INF_NAME).inf: $(INF_NAME).inx sources ..\common.inc
     3.8 -    copy $(@B).inx $@
     3.9 -    $(STAMP)
     4.1 --- a/xenhide/sources	Wed Feb 06 15:39:32 2008 +1100
     4.2 +++ b/xenhide/sources	Wed Feb 13 23:25:32 2008 +1100
     4.3 @@ -3,6 +3,4 @@
     4.4  !UNDEF KMDF_VERSION_MAJOR
     4.5  TARGETNAME=xenhide
     4.6  TARGETTYPE=DRIVER
     4.7 -INF_NAME=$(TARGETNAME)
     4.8 -MISCFILES=..\Target\$(DDK_TARGET_OS)\$(INF_NAME).inf
     4.9  SOURCES=xenhide.c
     5.1 --- a/xenhide/xenhide.c	Wed Feb 06 15:39:32 2008 +1100
     5.2 +++ b/xenhide/xenhide.c	Wed Feb 13 23:25:32 2008 +1100
     5.3 @@ -56,6 +56,8 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
     5.4    size_t SystemStartOptionsLen;
     5.5    size_t i;
     5.6  
     5.7 +  UNREFERENCED_PARAMETER(RegistryPath);
     5.8 +
     5.9    KdPrint((__DRIVER_NAME " --> DriverEntry\n"));
    5.10    KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
    5.11  
    5.12 @@ -154,33 +156,55 @@ XenHide_AddDevice(
    5.13    )
    5.14  {
    5.15    NTSTATUS status;
    5.16 -  PDEVICE_OBJECT deviceObject = NULL;
    5.17 +  PDEVICE_OBJECT DeviceObject = NULL;
    5.18    PDEVICE_EXTENSION DeviceExtension;
    5.19 +  ULONG Length;
    5.20 +  WCHAR Buffer[1000];
    5.21  
    5.22    KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    5.23  
    5.24 -  status = IoCreateDevice (DriverObject,
    5.25 +  Length = 1000;
    5.26 +  status = IoGetDeviceProperty(PhysicalDeviceObject, DevicePropertyDeviceDescription, Length, Buffer, &Length);
    5.27 +  KdPrint((__DRIVER_NAME "     status = %08x, DevicePropertyDeviceDescription = %ws\n", status, Buffer));
    5.28 +
    5.29 +  if (!NT_SUCCESS(status) || wcscmp(Buffer, L"PCI bus") != 0)
    5.30 +  {
    5.31 +    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    5.32 +    return STATUS_SUCCESS;
    5.33 +  }
    5.34 +  KdPrint((__DRIVER_NAME "     Found\n"));
    5.35 +
    5.36 +  status = IoCreateDevice(DriverObject,
    5.37      sizeof(DEVICE_EXTENSION),
    5.38      NULL,
    5.39      FILE_DEVICE_UNKNOWN,
    5.40      FILE_DEVICE_SECURE_OPEN,
    5.41      FALSE,
    5.42 -    &deviceObject);
    5.43 +    &DeviceObject);
    5.44 +  if (!NT_SUCCESS(status))
    5.45 +  {
    5.46 +    KdPrint((__DRIVER_NAME "     IoCreateDevice failed 0x%08x\n", status));
    5.47 +    return status;
    5.48 +  }
    5.49  
    5.50 -  DeviceExtension = (PDEVICE_EXTENSION)deviceObject->DeviceExtension;
    5.51 +  DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
    5.52 +
    5.53 +  DeviceExtension->Self = DeviceObject;
    5.54 +  DeviceExtension->DriverObject = DriverObject;
    5.55 +  DeviceExtension->Type = XENHIDE_TYPE_PCI;
    5.56 +  DeviceExtension->CallCount = 0;
    5.57  
    5.58    DeviceExtension->NextLowerDevice = IoAttachDeviceToDeviceStack(
    5.59 -    deviceObject,
    5.60 +    DeviceObject,
    5.61      PhysicalDeviceObject);
    5.62 -  deviceObject->Flags |= DeviceExtension->NextLowerDevice->Flags;
    5.63  
    5.64 -  deviceObject->DeviceType = DeviceExtension->NextLowerDevice->DeviceType;
    5.65 +  DeviceObject->Flags |= DeviceExtension->NextLowerDevice->Flags;
    5.66  
    5.67 -  deviceObject->Characteristics = 
    5.68 +  DeviceObject->DeviceType = DeviceExtension->NextLowerDevice->DeviceType;
    5.69 +
    5.70 +  DeviceObject->Characteristics = 
    5.71      DeviceExtension->NextLowerDevice->Characteristics;
    5.72  
    5.73 -  DeviceExtension->Self = deviceObject;
    5.74 -
    5.75    //INITIALIZE_PNP_STATE(DeviceExtension);
    5.76  
    5.77    if (AutoEnumerate)
    5.78 @@ -204,7 +228,7 @@ XenHide_AddDevice(
    5.79      KdPrint((__DRIVER_NAME "     Not registering Interface\n"));
    5.80    }
    5.81  
    5.82 -  deviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
    5.83 +  DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
    5.84  
    5.85    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    5.86  
    5.87 @@ -228,66 +252,126 @@ XenHide_IoCompletion(PDEVICE_OBJECT Devi
    5.88    ULONG Length;
    5.89    size_t StrLen;
    5.90    int Match;
    5.91 -  int Offset = 0;
    5.92 +  NTSTATUS status;
    5.93 +  PDEVICE_OBJECT deviceObject = NULL;
    5.94 +  PDEVICE_EXTENSION DeviceExtension = (PDEVICE_EXTENSION)Context;
    5.95 +  PDEVICE_EXTENSION NewDeviceExtension;
    5.96  
    5.97    UNREFERENCED_PARAMETER(DeviceObject);
    5.98    UNREFERENCED_PARAMETER(Context);
    5.99  
   5.100    KdPrint((__DRIVER_NAME " --> IoCompletion\n"));
   5.101    KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
   5.102 +  KdPrint((__DRIVER_NAME "     CallCount = %d\n", DeviceExtension->CallCount));
   5.103  
   5.104 -  Relations = (PDEVICE_RELATIONS)Irp->IoStatus.Information;
   5.105 +  if (Irp->PendingReturned)
   5.106 +    IoMarkIrpPending(Irp);
   5.107  
   5.108 -  for (i = 0; i < Relations->Count; i++)
   5.109 +  switch (DeviceExtension->CallCount)
   5.110    {
   5.111 -    if (Offset != 0)
   5.112 -      Relations->Objects[i - Offset] = Relations->Objects[i];
   5.113 -
   5.114 -    Match = 0;
   5.115 -    for (j = 0; j < 2 && !Match; j++)
   5.116 +  case 0:
   5.117 +    DeviceExtension->CallCount = 1;
   5.118 +    break;
   5.119 +  case 1:
   5.120 +    DeviceExtension->CallCount = 2;
   5.121 +/*
   5.122 +    break;
   5.123 +  case 2:
   5.124 +    DeviceExtension->CallCount = 3;
   5.125 +*/
   5.126 +    Relations = (PDEVICE_RELATIONS)Irp->IoStatus.Information;
   5.127 +  
   5.128 +    for (i = 0; i < Relations->Count; i++)
   5.129      {
   5.130 -      Length = sizeof(Buffer);
   5.131 -      if (j == 0)
   5.132 -        IoGetDeviceProperty(Relations->Objects[i - Offset], DevicePropertyCompatibleIDs, Length, Buffer, &Length);
   5.133 -      else
   5.134 -        IoGetDeviceProperty(Relations->Objects[i - Offset], DevicePropertyHardwareID, Length, Buffer, &Length);
   5.135 -      StrLen = 0;
   5.136 -      for (Ptr = Buffer; *Ptr != 0; Ptr += StrLen + 1)
   5.137 +      Match = 0;
   5.138 +      for (j = 0; j < 2 && !Match; j++)
   5.139        {
   5.140 -        // Qemu PCI
   5.141 -        if (XenHide_StringMatches(Ptr, L"PCI\\VEN_8086&DEV_7010")) {
   5.142 -          Match = 1;
   5.143 -          break;
   5.144 +        Length = sizeof(Buffer);
   5.145 +        if (j == 0)
   5.146 +          IoGetDeviceProperty(Relations->Objects[i], DevicePropertyCompatibleIDs, Length, Buffer, &Length);
   5.147 +        else
   5.148 +          IoGetDeviceProperty(Relations->Objects[i], DevicePropertyHardwareID, Length, Buffer, &Length);
   5.149 +        StrLen = 0;
   5.150 +        for (Ptr = Buffer; *Ptr != 0; Ptr += StrLen + 1)
   5.151 +        {
   5.152 +          // Qemu PCI
   5.153 +          if (XenHide_StringMatches(Ptr, L"PCI\\VEN_8086&DEV_7010")) {
   5.154 +            KdPrint((__DRIVER_NAME "     %ws\n", Ptr));
   5.155 +            Match = 1;
   5.156 +            break;
   5.157 +          }
   5.158 +          // Qemu Network
   5.159 +          if (XenHide_StringMatches(Ptr, L"PCI\\VEN_10EC&DEV_8139")) {
   5.160 +            KdPrint((__DRIVER_NAME "     %ws\n", Ptr));
   5.161 +            Match = 1;
   5.162 +            break;
   5.163 +          }
   5.164 +          RtlStringCchLengthW(Ptr, Length, &StrLen);
   5.165          }
   5.166 -        // Qemu Network
   5.167 -        if (XenHide_StringMatches(Ptr, L"PCI\\VEN_10EC&DEV_8139")) {
   5.168 -          Match = 1;
   5.169 -          break;
   5.170 +      }
   5.171 +      if (Match)
   5.172 +      {
   5.173 +        KdPrint((__DRIVER_NAME "     Creating and attaching Device\n"));
   5.174 +        deviceObject = NULL;
   5.175 +        status = IoCreateDevice(DeviceExtension->DriverObject,
   5.176 +          sizeof(DEVICE_EXTENSION),
   5.177 +          NULL,
   5.178 +          FILE_DEVICE_UNKNOWN,
   5.179 +          FILE_DEVICE_SECURE_OPEN,
   5.180 +          FALSE,
   5.181 +          &deviceObject);
   5.182 +        if (!NT_SUCCESS(status))
   5.183 +        {
   5.184 +          KdPrint((__DRIVER_NAME "     IoCreateDevice failed 0x%08x\n", status));
   5.185 +          continue;
   5.186          }
   5.187 -        RtlStringCchLengthW(Ptr, Length, &StrLen);
   5.188 +  
   5.189 +        NewDeviceExtension = (PDEVICE_EXTENSION)deviceObject->DeviceExtension;
   5.190 +      
   5.191 +        NewDeviceExtension->NextLowerDevice = IoAttachDeviceToDeviceStack(
   5.192 +          deviceObject,
   5.193 +          Relations->Objects[i]);
   5.194 +        deviceObject->Flags |= NewDeviceExtension->NextLowerDevice->Flags;
   5.195 +          
   5.196 +        deviceObject->DeviceType = NewDeviceExtension->NextLowerDevice->DeviceType;
   5.197 +      
   5.198 +        deviceObject->Characteristics = 
   5.199 +          NewDeviceExtension->NextLowerDevice->Characteristics;
   5.200 +      
   5.201 +        NewDeviceExtension->Self = deviceObject;
   5.202 +        NewDeviceExtension->Type = XENHIDE_TYPE_HIDE;
   5.203 +      
   5.204 +        deviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
   5.205        }
   5.206      }
   5.207 -    if (Match)
   5.208 -    {
   5.209 -      Offset++;
   5.210 -    }
   5.211 +    break;
   5.212 +  default:
   5.213 +    break;
   5.214    }
   5.215 -  Relations->Count -= Offset;
   5.216 -  
   5.217 +
   5.218    KdPrint((__DRIVER_NAME " <-- IoCompletion\n"));
   5.219  
   5.220 -  return Irp->IoStatus.Status;
   5.221 +  return STATUS_SUCCESS; //Irp->IoStatus.Status;
   5.222  }
   5.223  
   5.224  static NTSTATUS
   5.225  XenHide_Pass(PDEVICE_OBJECT DeviceObject, PIRP Irp)
   5.226  {
   5.227    PDEVICE_EXTENSION DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
   5.228 -  NTSTATUS status;
   5.229 +  NTSTATUS Status;
   5.230      
   5.231 -  IoSkipCurrentIrpStackLocation(Irp);
   5.232 -  status = IoCallDriver(DeviceExtension->NextLowerDevice, Irp);
   5.233 -  return status;
   5.234 +  if (DeviceExtension->Type == XENHIDE_TYPE_HIDE)
   5.235 +  {
   5.236 +    Irp->IoStatus.Status = Status = STATUS_UNSUCCESSFUL;
   5.237 +    Irp->IoStatus.Information = 0;
   5.238 +    IoCompleteRequest(Irp, IO_NO_INCREMENT);
   5.239 +  }
   5.240 +  else
   5.241 +  {
   5.242 +    IoSkipCurrentIrpStackLocation(Irp);
   5.243 +    Status = IoCallDriver(DeviceExtension->NextLowerDevice, Irp);
   5.244 +  }
   5.245 +  return Status;
   5.246  }
   5.247  
   5.248  static NTSTATUS
   5.249 @@ -298,33 +382,151 @@ XenHide_Pnp(PDEVICE_OBJECT DeviceObject,
   5.250    PDEVICE_EXTENSION DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
   5.251  
   5.252    KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   5.253 +  KdPrint((__DRIVER_NAME "     DeviceObject = %p\n", DeviceObject));
   5.254    KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
   5.255  
   5.256    Stack = IoGetCurrentIrpStackLocation(Irp);
   5.257  
   5.258 -  switch (Stack->MinorFunction) {
   5.259 +  switch (Stack->MinorFunction)
   5.260 +  {
   5.261 +  case IRP_MN_START_DEVICE:
   5.262 +    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_START_DEVICE\n"));
   5.263 +    break;
   5.264 +  case IRP_MN_QUERY_STOP_DEVICE:
   5.265 +    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_QUERY_STOP_DEVICE\n"));
   5.266 +    break;
   5.267 +  case IRP_MN_STOP_DEVICE:
   5.268 +    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_STOP_DEVICE\n"));
   5.269 +    break;
   5.270 +  case IRP_MN_CANCEL_STOP_DEVICE:
   5.271 +    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_CANCEL_STOP_DEVICE\n"));
   5.272 +    break;
   5.273 +  case IRP_MN_QUERY_REMOVE_DEVICE:
   5.274 +    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_QUERY_REMOVE_DEVICE\n"));
   5.275 +    break;
   5.276 +  case IRP_MN_REMOVE_DEVICE:
   5.277 +    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_REMOVE_DEVICEE\n"));
   5.278 +    break;
   5.279 +  case IRP_MN_CANCEL_REMOVE_DEVICE:
   5.280 +    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_CANCEL_REMOVE_DEVICE\n"));
   5.281 +    break;
   5.282 +  case IRP_MN_SURPRISE_REMOVAL:
   5.283 +    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_SURPRISE_REMOVAL\n"));
   5.284 +    break;
   5.285 +  case IRP_MN_QUERY_CAPABILITIES:
   5.286 +    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_QUERY_CAPABILITIES\n"));
   5.287 +    break;
   5.288 +  case IRP_MN_QUERY_PNP_DEVICE_STATE:
   5.289 +    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_QUERY_PNP_DEVICE_STATE\n"));
   5.290 +    break;
   5.291 +  case IRP_MN_FILTER_RESOURCE_REQUIREMENTS:
   5.292 +    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_FILTER_RESOURCE_REQUIREMENTS\n"));
   5.293 +    break;
   5.294 +  case IRP_MN_DEVICE_USAGE_NOTIFICATION:
   5.295 +    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_DEVICE_USAGE_NOTIFICATION\n"));
   5.296 +    break;
   5.297    case IRP_MN_QUERY_DEVICE_RELATIONS:
   5.298 -    KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_DEVICE_RELATIONS\n"));
   5.299 -    switch (Stack->Parameters.QueryDeviceRelations.Type)
   5.300 -    {
   5.301 -    case BusRelations:
   5.302 -      KdPrint((__DRIVER_NAME "       BusRelations\n"));
   5.303 -      IoCopyCurrentIrpStackLocationToNext(Irp);
   5.304 -      IoSetCompletionRoutine(Irp, XenHide_IoCompletion, NULL, TRUE, TRUE, TRUE);
   5.305 -      Status = IoCallDriver(DeviceExtension->NextLowerDevice, Irp);
   5.306 -      break;  
   5.307 +    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_QUERY_DEVICE_RELATIONS\n"));
   5.308 +    break;
   5.309 +  case IRP_MN_QUERY_RESOURCES:
   5.310 +    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_QUERY_RESOURCES\n"));
   5.311 +    break;
   5.312 +  case IRP_MN_QUERY_RESOURCE_REQUIREMENTS:
   5.313 +    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_QUERY_RESOURCE_REQUIREMENTS\n"));
   5.314 +    break;
   5.315 +  case IRP_MN_QUERY_ID:
   5.316 +    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_QUERY_ID\n"));
   5.317 +    break;
   5.318 +  case IRP_MN_QUERY_DEVICE_TEXT:
   5.319 +    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_QUERY_DEVICE_TEXT\n"));
   5.320 +    break;
   5.321 +  case IRP_MN_QUERY_BUS_INFORMATION:
   5.322 +    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_QUERY_BUS_INFORMATION\n"));
   5.323 +    break;
   5.324 +  case IRP_MN_QUERY_INTERFACE:
   5.325 +    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_QUERY_INTERFACE\n"));
   5.326 +    break;
   5.327 +  case IRP_MN_READ_CONFIG:
   5.328 +    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_READ_CONFIG\n"));
   5.329 +    break;
   5.330 +  case IRP_MN_WRITE_CONFIG:
   5.331 +    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_WRITE_CONFIG\n"));
   5.332 +    break;
   5.333 +  case IRP_MN_EJECT:
   5.334 +    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_EJECT\n"));
   5.335 +    break;
   5.336 +  case IRP_MN_SET_LOCK:
   5.337 +    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_SET_LOCK\n"));
   5.338 +    break;
   5.339 +  }
   5.340 +
   5.341 +  switch (DeviceExtension->Type)
   5.342 +  {
   5.343 +  case XENHIDE_TYPE_PCI:
   5.344 +    KdPrint((__DRIVER_NAME "     As PCI\n"));
   5.345 +
   5.346 +    switch (Stack->MinorFunction) {
   5.347 +    case IRP_MN_QUERY_DEVICE_RELATIONS:
   5.348 +      KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_DEVICE_RELATIONS\n"));
   5.349 +      switch (Stack->Parameters.QueryDeviceRelations.Type)
   5.350 +      {
   5.351 +      case BusRelations:
   5.352 +        KdPrint((__DRIVER_NAME "       BusRelations\n"));
   5.353 +        IoCopyCurrentIrpStackLocationToNext(Irp);
   5.354 +        IoSetCompletionRoutine(Irp, XenHide_IoCompletion, DeviceExtension, TRUE, TRUE, TRUE);
   5.355 +        Status = IoCallDriver(DeviceExtension->NextLowerDevice, Irp);
   5.356 +        break;
   5.357 +      default:
   5.358 +        IoSkipCurrentIrpStackLocation(Irp);
   5.359 +        Status = IoCallDriver(DeviceExtension->NextLowerDevice, Irp);
   5.360 +        break;  
   5.361 +      }
   5.362 +      break;
   5.363      default:
   5.364        IoSkipCurrentIrpStackLocation(Irp);
   5.365        Status = IoCallDriver(DeviceExtension->NextLowerDevice, Irp);
   5.366 -      break;  
   5.367 +      break;
   5.368      }
   5.369      break;
   5.370 -  default:
   5.371 -    IoSkipCurrentIrpStackLocation(Irp);
   5.372 -    Status = IoCallDriver(DeviceExtension->NextLowerDevice, Irp);
   5.373 +  case XENHIDE_TYPE_HIDE:
   5.374 +    KdPrint((__DRIVER_NAME "     As Hide\n"));
   5.375 +    Irp->IoStatus.Information = 0;
   5.376 +    switch (Stack->MinorFunction)
   5.377 +    {
   5.378 +    case IRP_MN_START_DEVICE:
   5.379 +    case IRP_MN_STOP_DEVICE:
   5.380 +      Irp->IoStatus.Status = Status = STATUS_SUCCESS;
   5.381 +      break;
   5.382 +    case IRP_MN_QUERY_PNP_DEVICE_STATE:
   5.383 +      Irp->IoStatus.Status = Status = STATUS_SUCCESS;
   5.384 +      Irp->IoStatus.Information = PNP_DEVICE_DONT_DISPLAY_IN_UI;
   5.385 +      break;
   5.386 +    default:
   5.387 +      Irp->IoStatus.Status = Status = STATUS_UNSUCCESSFUL;
   5.388 +      break;
   5.389 +    }
   5.390 +    IoCompleteRequest(Irp, IO_NO_INCREMENT);
   5.391 +
   5.392 +/*
   5.393 +    switch (Stack->MinorFunction)
   5.394 +    {
   5.395 +    case IRP_MN_START_DEVICE:
   5.396 +      IoCopyCurrentIrpStackLocationToNext(Irp);
   5.397 +      Stack = IoGetNextIrpStackLocation(Irp);
   5.398 +      Stack->Parameters.StartDevice.AllocatedResources->List[0].PartialResourceList.Count = 0;
   5.399 +      Stack->Parameters.StartDevice.AllocatedResourcesTranslated->List[0].PartialResourceList.Count = 0;
   5.400 +      Status = IoCallDriver(DeviceExtension->NextLowerDevice, Irp);
   5.401 +      break;
   5.402 +    default:
   5.403 +      IoSkipCurrentIrpStackLocation(Irp);
   5.404 +      Status = IoCallDriver(DeviceExtension->NextLowerDevice, Irp);
   5.405 +      break;
   5.406 +    }
   5.407 +    IoCompleteRequest(Irp, IO_NO_INCREMENT);
   5.408 +*/
   5.409      break;
   5.410    }
   5.411 -
   5.412 +  
   5.413    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (returning with status %08x)\n", Status));
   5.414  
   5.415    return Status;
     6.1 --- a/xenhide/xenhide.h	Wed Feb 06 15:39:32 2008 +1100
     6.2 +++ b/xenhide/xenhide.h	Wed Feb 13 23:25:32 2008 +1100
     6.3 @@ -1,5 +1,4 @@
     6.4 -/*
     6.5 -PV Drivers for Windows Xen HVM Domains
     6.6 +/*PV Drivers for Windows Xen HVM Domains
     6.7  Copyright (C) 2007 James Harper
     6.8  
     6.9  This program is free software; you can redistribute it and/or
    6.10 @@ -34,10 +33,17 @@ Foundation, Inc., 51 Franklin Street, Fi
    6.11  //{CD433FE7-954F-4D51-BE29-D8A38DFA1108}
    6.12  DEFINE_GUID(GUID_XENHIDE_IFACE, 0xCD433FE7, 0x954F, 0x4D51, 0xBE, 0x29, 0xD8, 0xA3, 0x8D, 0xFA, 0x11, 0x08);
    6.13  
    6.14 +#define XENHIDE_TYPE_PCI 1
    6.15 +#define XENHIDE_TYPE_HIDE 2
    6.16 +
    6.17  struct _DEVICE_EXTENSION {
    6.18    PDEVICE_OBJECT Self;
    6.19 +  PDRIVER_OBJECT DriverObject;
    6.20 +  BOOLEAN SeenQueryDeviceRelations;
    6.21    PDEVICE_OBJECT NextLowerDevice;
    6.22    UNICODE_STRING InterfaceName;
    6.23 +  ULONG Type;
    6.24 +  ULONG CallCount;
    6.25  } typedef DEVICE_EXTENSION, *PDEVICE_EXTENSION;
    6.26  
    6.27  #endif
     7.1 --- a/xenpci/xenpci.inx	Wed Feb 06 15:39:32 2008 +1100
     7.2 +++ b/xenpci/xenpci.inx	Wed Feb 13 23:25:32 2008 +1100
     7.3 @@ -25,11 +25,19 @@ ExcludeFromSelect=*
     7.4  [XenPCI_Inst.NT]
     7.5  CopyFiles=XenPCI.CopyFiles
     7.6  
     7.7 +;[XenPCI]
     7.8 +;AddReg=XenHide_AddReg
     7.9 +
    7.10 +;[XenHide_AddReg]
    7.11 +;HKLM,
    7.12 +
    7.13  [XenPCI.CopyFiles]
    7.14  xenpci.sys
    7.15 +xenhide.sys
    7.16  
    7.17  [SourceDisksFiles]
    7.18  xenpci.sys=1
    7.19 +xenhide.sys=1
    7.20  WdfCoinstaller$KMDFCOINSTALLERVERSION$.dll=1,,
    7.21  
    7.22  [SourceDisksNames.x86]
    7.23 @@ -39,7 +47,8 @@ 1 = %DISK_NAME%,,,\i386
    7.24  1 = %DISK_NAME%,,,\amd64
    7.25  
    7.26  [XenPCI_Inst.NT.Services]
    7.27 -AddService=XenPCI,2,XenPCI_Service 
    7.28 +AddService=XenPCI,2,XenPCI_Service
    7.29 +AddService=XenHide,0,XenHide_Service
    7.30  
    7.31  [XenPCI_Service]
    7.32  DisplayName    = %XenPCI.SVCDESC%                            
    7.33 @@ -49,6 +58,18 @@ ErrorControl   = 1
    7.34  LoadOrderGroup = System Bus Extender
    7.35  ServiceBinary  = %12%\xenpci.sys                            
    7.36  
    7.37 +[XenHide_Service]
    7.38 +DisplayName    = %XenHide.SVCDESC%
    7.39 +ServiceType    = 1
    7.40 +StartType      = 0
    7.41 +ErrorControl   = 1
    7.42 +LoadOrderGroup = Boot Bus Extender
    7.43 +ServiceBinary  = %12%\xenhide.sys
    7.44 +AddReg         = XenHide_Service_AddReg
    7.45 +
    7.46 +[XenHide_Service_AddReg]
    7.47 +HKR,,AutoEnumerate,0x00010001, 0
    7.48 +
    7.49  [XenPCI_Inst.NT.CoInstallers]
    7.50  AddReg=CoInstaller_AddReg
    7.51  CopyFiles=CoInstaller_CopyFiles
    7.52 @@ -69,5 +90,6 @@ KmdfLibraryVersion = $KMDFVERSION$
    7.53  XenGplPv = "Xen GPL PV Driver Developers"
    7.54  XenPCI.SVCDESC = "Xen PCI Device Driver"
    7.55  XenPCI.DRVDESC = "Xen PCI Device Driver"
    7.56 +XenHide.SVCDESC = "Xen PCI Device Hider Driver"
    7.57  DISK_NAME = "Xen PCI Device Driver Install Disk"
    7.58