win-pvdrivers

diff xenhide/xenhide.c @ 189:eeeeb6924803

updates preparing for next release
author James Harper <james.harper@bendigoit.com.au>
date Mon Feb 18 22:16:03 2008 +1100 (2008-02-18)
parents a416c66be9c2
children da58a35a8a31
line diff
     1.1 --- a/xenhide/xenhide.c	Mon Feb 18 16:12:48 2008 +1100
     1.2 +++ b/xenhide/xenhide.c	Mon Feb 18 22:16:03 2008 +1100
     1.3 @@ -28,8 +28,6 @@ XenHide_Pass(PDEVICE_OBJECT DeviceObject
     1.4  static NTSTATUS
     1.5  XenHide_Pnp(PDEVICE_OBJECT DeviceObject, PIRP Irp);
     1.6  static NTSTATUS
     1.7 -XenHide_Power(PDEVICE_OBJECT DeviceObject, PIRP Irp);
     1.8 -static NTSTATUS
     1.9  XenHide_AddDevice();
    1.10  //static NTSTATUS
    1.11  //XenHide_Unload();
    1.12 @@ -142,12 +140,8 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
    1.13  
    1.14    for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++)
    1.15      DriverObject->MajorFunction[i] = XenHide_Pass;
    1.16 -
    1.17 -  DriverObject->MajorFunction[IRP_MJ_POWER] = XenHide_Power;
    1.18 -
    1.19    if (AutoEnumerate)
    1.20      DriverObject->MajorFunction[IRP_MJ_PNP] = XenHide_Pnp;
    1.21 -
    1.22    DriverObject->DriverExtension->AddDevice = XenHide_AddDevice;
    1.23  
    1.24    KdPrint((__DRIVER_NAME " <-- DriverEntry\n"));
    1.25 @@ -162,7 +156,7 @@ XenHide_AddDevice(
    1.26    )
    1.27  {
    1.28    NTSTATUS status;
    1.29 -  PDEVICE_OBJECT DeviceObject = NULL;
    1.30 +  PDEVICE_OBJECT deviceObject = NULL;
    1.31    PDEVICE_EXTENSION DeviceExtension;
    1.32    ULONG Length;
    1.33    WCHAR Buffer[1000];
    1.34 @@ -171,50 +165,40 @@ XenHide_AddDevice(
    1.35  
    1.36    Length = 1000;
    1.37    status = IoGetDeviceProperty(PhysicalDeviceObject, DevicePropertyDeviceDescription, Length, Buffer, &Length);
    1.38 -  KdPrint((__DRIVER_NAME "     status = %08x, DevicePropertyDeviceDescription = %ws\n", status, Buffer));
    1.39 +  KdPrint((__DRIVER_NAME " status = %08x, DevicePropertyDeviceDescription = %ws\n", status, Buffer));
    1.40  
    1.41    if (!NT_SUCCESS(status) || wcscmp(Buffer, L"PCI bus") != 0)
    1.42    {
    1.43      KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    1.44      return STATUS_SUCCESS;
    1.45    }
    1.46 -  KdPrint((__DRIVER_NAME "     Found\n"));
    1.47  
    1.48 -  status = IoCreateDevice(DriverObject,
    1.49 +  KdPrint((__DRIVER_NAME " Found\n")); 
    1.50 +
    1.51 +  status = IoCreateDevice (DriverObject,
    1.52      sizeof(DEVICE_EXTENSION),
    1.53      NULL,
    1.54      FILE_DEVICE_UNKNOWN,
    1.55      FILE_DEVICE_SECURE_OPEN,
    1.56      FALSE,
    1.57 -    &DeviceObject);
    1.58 -  if (!NT_SUCCESS(status))
    1.59 -  {
    1.60 -    KdPrint((__DRIVER_NAME "     IoCreateDevice failed 0x%08x\n", status));
    1.61 -    return status;
    1.62 -  }
    1.63 +    &deviceObject);
    1.64  
    1.65 -  DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
    1.66 -
    1.67 -  DeviceExtension->Self = DeviceObject;
    1.68 -  DeviceExtension->PhysicalDeviceObject = PhysicalDeviceObject;
    1.69 -  DeviceExtension->DriverObject = DriverObject;
    1.70 -  DeviceExtension->Type = XENHIDE_TYPE_PCI;
    1.71 -  DeviceExtension->InternalState = 0;
    1.72 +  DeviceExtension = (PDEVICE_EXTENSION)deviceObject->DeviceExtension;
    1.73  
    1.74    DeviceExtension->NextLowerDevice = IoAttachDeviceToDeviceStack(
    1.75 -    DeviceObject,
    1.76 +    deviceObject,
    1.77      PhysicalDeviceObject);
    1.78 +  deviceObject->Flags |= DeviceExtension->NextLowerDevice->Flags;
    1.79  
    1.80 -  DeviceObject->Flags |= DeviceExtension->NextLowerDevice->Flags;
    1.81 +  deviceObject->DeviceType = DeviceExtension->NextLowerDevice->DeviceType;
    1.82  
    1.83 -  DeviceObject->DeviceType = DeviceExtension->NextLowerDevice->DeviceType;
    1.84 -
    1.85 -  DeviceObject->Characteristics = 
    1.86 +  deviceObject->Characteristics = 
    1.87      DeviceExtension->NextLowerDevice->Characteristics;
    1.88  
    1.89 -//  IoInitializeRemoveLock(&DeviceExtension->RemoveLock, XENHIDE_POOL_TAG, 1, 100);
    1.90 +  DeviceExtension->Self = deviceObject;
    1.91  
    1.92 -#if 0
    1.93 +  //INITIALIZE_PNP_STATE(DeviceExtension);
    1.94 +
    1.95    if (AutoEnumerate)
    1.96    {
    1.97      status = IoRegisterDeviceInterface(PhysicalDeviceObject, (LPGUID)&GUID_XENHIDE_IFACE, NULL, &DeviceExtension->InterfaceName);
    1.98 @@ -235,9 +219,8 @@ XenHide_AddDevice(
    1.99    {
   1.100      KdPrint((__DRIVER_NAME "     Not registering Interface\n"));
   1.101    }
   1.102 -#endif
   1.103  
   1.104 -  DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
   1.105 +  deviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
   1.106  
   1.107    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   1.108  
   1.109 @@ -252,7 +235,7 @@ XenHide_StringMatches(PWCHAR String1, PW
   1.110  }
   1.111  
   1.112  static NTSTATUS
   1.113 -XenHide_IoCompletionPciQueryDeviceRelations(PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Context)
   1.114 +XenHide_IoCompletion(PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Context)
   1.115  {
   1.116    ULONG i, j;
   1.117    PDEVICE_RELATIONS Relations;
   1.118 @@ -261,20 +244,16 @@ XenHide_IoCompletionPciQueryDeviceRelati
   1.119    ULONG Length;
   1.120    size_t StrLen;
   1.121    int Match;
   1.122 -  NTSTATUS status;
   1.123 -  PDEVICE_OBJECT NewDeviceObject;
   1.124 +  int Offset = 0;
   1.125    PDEVICE_EXTENSION DeviceExtension = (PDEVICE_EXTENSION)Context;
   1.126 -  PDEVICE_EXTENSION NewDeviceExtension;
   1.127  
   1.128    UNREFERENCED_PARAMETER(DeviceObject);
   1.129    UNREFERENCED_PARAMETER(Context);
   1.130  
   1.131 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   1.132 +  KdPrint((__DRIVER_NAME " --> IoCompletion\n"));
   1.133    KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
   1.134 -  KdPrint((__DRIVER_NAME "     InternalState = %d\n", DeviceExtension->InternalState));
   1.135  
   1.136 -  if (Irp->PendingReturned)
   1.137 -    IoMarkIrpPending(Irp);
   1.138 +  Relations = (PDEVICE_RELATIONS)Irp->IoStatus.Information;
   1.139  
   1.140    switch (DeviceExtension->InternalState)
   1.141    {
   1.142 @@ -282,31 +261,30 @@ XenHide_IoCompletionPciQueryDeviceRelati
   1.143      DeviceExtension->InternalState = 1;
   1.144      break;
   1.145    case 1:
   1.146 -    DeviceExtension->InternalState = 2;
   1.147 -    Relations = (PDEVICE_RELATIONS)Irp->IoStatus.Information;
   1.148 -  
   1.149 +    DeviceExtension->InternalState = 2; 
   1.150      for (i = 0; i < Relations->Count; i++)
   1.151      {
   1.152 +      if (Offset != 0)
   1.153 +        Relations->Objects[i - Offset] = Relations->Objects[i];
   1.154 +  
   1.155        Match = 0;
   1.156        for (j = 0; j < 2 && !Match; j++)
   1.157        {
   1.158          Length = sizeof(Buffer);
   1.159          if (j == 0)
   1.160 -          IoGetDeviceProperty(Relations->Objects[i], DevicePropertyCompatibleIDs, Length, Buffer, &Length);
   1.161 +          IoGetDeviceProperty(Relations->Objects[i - Offset], DevicePropertyCompatibleIDs, Length, Buffer, &Length);
   1.162          else
   1.163 -          IoGetDeviceProperty(Relations->Objects[i], DevicePropertyHardwareID, Length, Buffer, &Length);
   1.164 -        StrLen = 0;
   1.165 +          IoGetDeviceProperty(Relations->Objects[i - Offset], DevicePropertyHardwareID, Length, Buffer, &Length);
   1.166 +         StrLen = 0;
   1.167          for (Ptr = Buffer; *Ptr != 0; Ptr += StrLen + 1)
   1.168          {
   1.169            // Qemu PCI
   1.170            if (XenHide_StringMatches(Ptr, L"PCI\\VEN_8086&DEV_7010")) {
   1.171 -            KdPrint((__DRIVER_NAME "     %ws\n", Ptr));
   1.172              Match = 1;
   1.173              break;
   1.174            }
   1.175            // Qemu Network
   1.176            if (XenHide_StringMatches(Ptr, L"PCI\\VEN_10EC&DEV_8139")) {
   1.177 -            KdPrint((__DRIVER_NAME "     %ws\n", Ptr));
   1.178              Match = 1;
   1.179              break;
   1.180            }
   1.181 @@ -315,167 +293,29 @@ XenHide_IoCompletionPciQueryDeviceRelati
   1.182        }
   1.183        if (Match)
   1.184        {
   1.185 -        KdPrint((__DRIVER_NAME "     Creating and attaching Device\n"));
   1.186 -        NewDeviceObject = NULL;
   1.187 -        status = IoCreateDevice(DeviceExtension->DriverObject,
   1.188 -          sizeof(DEVICE_EXTENSION),
   1.189 -          NULL,
   1.190 -          FILE_DEVICE_UNKNOWN,
   1.191 -          FILE_DEVICE_SECURE_OPEN,
   1.192 -          FALSE,
   1.193 -          &NewDeviceObject);
   1.194 -        if (!NT_SUCCESS(status))
   1.195 -        {
   1.196 -          KdPrint((__DRIVER_NAME "     IoCreateDevice failed 0x%08x\n", status));
   1.197 -          continue;
   1.198 -        }
   1.199 -  
   1.200 -        NewDeviceExtension = (PDEVICE_EXTENSION)NewDeviceObject->DeviceExtension;
   1.201 -        NewDeviceExtension->PhysicalDeviceObject = Relations->Objects[i];
   1.202 -        NewDeviceExtension->InternalState = 0;
   1.203 -        NewDeviceExtension->NextLowerDevice = IoAttachDeviceToDeviceStack(
   1.204 -          NewDeviceObject,
   1.205 -          Relations->Objects[i]);
   1.206 -        NewDeviceObject->Flags |= NewDeviceExtension->NextLowerDevice->Flags;
   1.207 -          
   1.208 -        NewDeviceObject->DeviceType = NewDeviceExtension->NextLowerDevice->DeviceType;
   1.209 -      
   1.210 -        NewDeviceObject->Characteristics = 
   1.211 -          NewDeviceExtension->NextLowerDevice->Characteristics;
   1.212 -
   1.213 -//        IoInitializeRemoveLock(&NewDeviceExtension->RemoveLock, XENHIDE_POOL_TAG, 1, 100);
   1.214 -      
   1.215 -        NewDeviceExtension->Self = NewDeviceObject;
   1.216 -        NewDeviceExtension->Type = XENHIDE_TYPE_HIDE;
   1.217 -      
   1.218 -        NewDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
   1.219 +        Offset++;
   1.220        }
   1.221      }
   1.222 +    Relations->Count -= Offset;
   1.223      break;
   1.224    default:
   1.225      break;
   1.226    }
   1.227 -
   1.228 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   1.229 -
   1.230 -  return STATUS_SUCCESS; //Irp->IoStatus.Status;
   1.231 -}
   1.232 -
   1.233 -static NTSTATUS
   1.234 -XenHide_IoCompletionHideQueryPnpDeviceState(PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Context)
   1.235 -{
   1.236 -  UNREFERENCED_PARAMETER(DeviceObject);
   1.237 -  UNREFERENCED_PARAMETER(Context);
   1.238 -
   1.239 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   1.240 -
   1.241 -  if (Irp->PendingReturned)
   1.242 -    IoMarkIrpPending(Irp);
   1.243 -
   1.244 -  Irp->IoStatus.Information |= PNP_DEVICE_DONT_DISPLAY_IN_UI|PNP_DEVICE_DISABLED;
   1.245 -
   1.246 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   1.247 -  return STATUS_SUCCESS;
   1.248 -}
   1.249 -
   1.250 -static NTSTATUS
   1.251 -XenHide_IoCompletionPciQueryId(PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Context)
   1.252 -{
   1.253 -  PIO_STACK_LOCATION Stack;
   1.254 -
   1.255 -  UNREFERENCED_PARAMETER(DeviceObject);
   1.256 -  UNREFERENCED_PARAMETER(Context);
   1.257 -
   1.258 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   1.259 -
   1.260 -  if (Irp->PendingReturned)
   1.261 -    IoMarkIrpPending(Irp);
   1.262 -
   1.263 -  Stack = IoGetCurrentIrpStackLocation(Irp);
   1.264 +    
   1.265 +  KdPrint((__DRIVER_NAME " <-- IoCompletion\n"));
   1.266  
   1.267 -  switch (Stack->Parameters.QueryId.IdType)
   1.268 -  {
   1.269 -  case BusQueryDeviceID:
   1.270 -    KdPrint((__DRIVER_NAME "     IdType = BusQueryDeviceID\n"));
   1.271 -    KdPrint((__DRIVER_NAME "     %ws\n", Irp->IoStatus.Information));
   1.272 -    break;
   1.273 -  case BusQueryHardwareIDs:
   1.274 -    KdPrint((__DRIVER_NAME "     IdType = BusQueryHardwareIDs\n"));
   1.275 -    KdPrint((__DRIVER_NAME "     %ws\n", Irp->IoStatus.Information));
   1.276 -    break;
   1.277 -  case BusQueryCompatibleIDs:
   1.278 -    KdPrint((__DRIVER_NAME "     IdType = BusQueryCompatibleIDs\n"));
   1.279 -    KdPrint((__DRIVER_NAME "     %ws\n", Irp->IoStatus.Information));
   1.280 -    break;
   1.281 -  case BusQueryInstanceID:
   1.282 -    KdPrint((__DRIVER_NAME "     IdType = BusQueryInstanceID\n"));
   1.283 -    KdPrint((__DRIVER_NAME "     %ws\n", Irp->IoStatus.Information));
   1.284 -    break;
   1.285 -  default:
   1.286 -    KdPrint((__DRIVER_NAME "     IdType = %08x\n", Stack->Parameters.QueryId.IdType));
   1.287 -    KdPrint((__DRIVER_NAME "     %ws\n", Irp->IoStatus.Information));
   1.288 -    break;
   1.289 -  }
   1.290 -
   1.291 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   1.292 -  return STATUS_SUCCESS;
   1.293 -}
   1.294 -
   1.295 -static NTSTATUS
   1.296 -XenHide_IoCompletionHideStartDevice(PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Context)
   1.297 -{
   1.298 -  UNREFERENCED_PARAMETER(DeviceObject);
   1.299 -  UNREFERENCED_PARAMETER(Context);
   1.300 -
   1.301 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   1.302 -  KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
   1.303 -
   1.304 -  if (Irp->PendingReturned)
   1.305 -    IoMarkIrpPending(Irp);
   1.306 -
   1.307 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   1.308 -  return STATUS_SUCCESS;
   1.309 +  return Irp->IoStatus.Status;
   1.310  }
   1.311  
   1.312  static NTSTATUS
   1.313  XenHide_Pass(PDEVICE_OBJECT DeviceObject, PIRP Irp)
   1.314  {
   1.315    PDEVICE_EXTENSION DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
   1.316 -  NTSTATUS Status;
   1.317 -
   1.318 -#if 0
   1.319 -  Status = IoAcquireRemoveLock (&DeviceExtension->RemoveLock, Irp);
   1.320 -  if (!NT_SUCCESS(Status)) {
   1.321 -    Irp->IoStatus.Status = Status;
   1.322 -    IoCompleteRequest(Irp, IO_NO_INCREMENT);
   1.323 -    return Status;
   1.324 -  }
   1.325 -#endif
   1.326 +  NTSTATUS status;
   1.327 +    
   1.328    IoSkipCurrentIrpStackLocation(Irp);
   1.329 -  Status = IoCallDriver(DeviceExtension->NextLowerDevice, Irp);
   1.330 -//  IoReleaseRemoveLock(&DeviceExtension->RemoveLock, Irp); 
   1.331 -  return Status;
   1.332 -}
   1.333 -
   1.334 -static NTSTATUS
   1.335 -XenHide_Power(PDEVICE_OBJECT DeviceObject, PIRP Irp)
   1.336 -{
   1.337 -  NTSTATUS Status = STATUS_SUCCESS;
   1.338 -  PDEVICE_EXTENSION DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
   1.339 -
   1.340 -//  Status = IoAcquireRemoveLock (&DeviceExtension->RemoveLock, Irp);
   1.341 -  if (!NT_SUCCESS(Status)) {
   1.342 -    Irp->IoStatus.Status = Status;
   1.343 -    PoStartNextPowerIrp(Irp);
   1.344 -    IoCompleteRequest(Irp, IO_NO_INCREMENT);
   1.345 -    return Status;
   1.346 -  }
   1.347 -
   1.348 -  PoStartNextPowerIrp(Irp);
   1.349 -  IoSkipCurrentIrpStackLocation(Irp);
   1.350 -  Status = PoCallDriver(DeviceExtension->NextLowerDevice, Irp);
   1.351 -//  IoReleaseRemoveLock(&DeviceExtension->RemoveLock, Irp); 
   1.352 -  return Status;
   1.353 +  status = IoCallDriver(DeviceExtension->NextLowerDevice, Irp);
   1.354 +  return status;
   1.355  }
   1.356  
   1.357  static NTSTATUS
   1.358 @@ -486,189 +326,32 @@ XenHide_Pnp(PDEVICE_OBJECT DeviceObject,
   1.359    PDEVICE_EXTENSION DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
   1.360  
   1.361    KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   1.362 -  KdPrint((__DRIVER_NAME "     DeviceObject = %p\n", DeviceObject));
   1.363    KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
   1.364  
   1.365 -/*
   1.366 -  Status = IoAcquireRemoveLock (&DeviceExtension->RemoveLock, Irp);
   1.367 -  if (!NT_SUCCESS(Status)) {
   1.368 -    Irp->IoStatus.Status = Status;
   1.369 -    IoCompleteRequest(Irp, IO_NO_INCREMENT);
   1.370 -    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (returning with status %08x)\n", Status));
   1.371 -    return Status;
   1.372 -  }
   1.373 -*/
   1.374    Stack = IoGetCurrentIrpStackLocation(Irp);
   1.375  
   1.376 -  switch (Stack->MinorFunction)
   1.377 -  {
   1.378 -  case IRP_MN_START_DEVICE:
   1.379 -    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_START_DEVICE\n"));
   1.380 -    break;
   1.381 -  case IRP_MN_QUERY_STOP_DEVICE:
   1.382 -    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_QUERY_STOP_DEVICE\n"));
   1.383 -    break;
   1.384 -  case IRP_MN_STOP_DEVICE:
   1.385 -    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_STOP_DEVICE\n"));
   1.386 -    break;
   1.387 -  case IRP_MN_CANCEL_STOP_DEVICE:
   1.388 -    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_CANCEL_STOP_DEVICE\n"));
   1.389 -    break;
   1.390 -  case IRP_MN_QUERY_REMOVE_DEVICE:
   1.391 -    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_QUERY_REMOVE_DEVICE\n"));
   1.392 -    break;
   1.393 -  case IRP_MN_REMOVE_DEVICE:
   1.394 -    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_REMOVE_DEVICE\n"));
   1.395 -    break;
   1.396 -  case IRP_MN_CANCEL_REMOVE_DEVICE:
   1.397 -    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_CANCEL_REMOVE_DEVICE\n"));
   1.398 -    break;
   1.399 -  case IRP_MN_SURPRISE_REMOVAL:
   1.400 -    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_SURPRISE_REMOVAL\n"));
   1.401 -    break;
   1.402 -  case IRP_MN_QUERY_CAPABILITIES:
   1.403 -    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_QUERY_CAPABILITIES\n"));
   1.404 -    break;
   1.405 -  case IRP_MN_QUERY_PNP_DEVICE_STATE:
   1.406 -    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_QUERY_PNP_DEVICE_STATE\n"));
   1.407 -    break;
   1.408 -  case IRP_MN_FILTER_RESOURCE_REQUIREMENTS:
   1.409 -    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_FILTER_RESOURCE_REQUIREMENTS\n"));
   1.410 -    break;
   1.411 -  case IRP_MN_DEVICE_USAGE_NOTIFICATION:
   1.412 -    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_DEVICE_USAGE_NOTIFICATION\n"));
   1.413 -    break;
   1.414 +  switch (Stack->MinorFunction) {
   1.415    case IRP_MN_QUERY_DEVICE_RELATIONS:
   1.416 -    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_QUERY_DEVICE_RELATIONS\n"));
   1.417 -    break;
   1.418 -  case IRP_MN_QUERY_RESOURCES:
   1.419 -    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_QUERY_RESOURCES\n"));
   1.420 -    break;
   1.421 -  case IRP_MN_QUERY_RESOURCE_REQUIREMENTS:
   1.422 -    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_QUERY_RESOURCE_REQUIREMENTS\n"));
   1.423 -    break;
   1.424 -  case IRP_MN_QUERY_ID:
   1.425 -    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_QUERY_ID\n"));
   1.426 -    break;
   1.427 -  case IRP_MN_QUERY_DEVICE_TEXT:
   1.428 -    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_QUERY_DEVICE_TEXT\n"));
   1.429 -    break;
   1.430 -  case IRP_MN_QUERY_BUS_INFORMATION:
   1.431 -    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_QUERY_BUS_INFORMATION\n"));
   1.432 -    break;
   1.433 -  case IRP_MN_QUERY_INTERFACE:
   1.434 -    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_QUERY_INTERFACE\n"));
   1.435 -    break;
   1.436 -  case IRP_MN_READ_CONFIG:
   1.437 -    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_READ_CONFIG\n"));
   1.438 -    break;
   1.439 -  case IRP_MN_WRITE_CONFIG:
   1.440 -    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_WRITE_CONFIG\n"));
   1.441 -    break;
   1.442 -  case IRP_MN_EJECT:
   1.443 -    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_EJECT\n"));
   1.444 -    break;
   1.445 -  case IRP_MN_SET_LOCK:
   1.446 -    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_SET_LOCK\n"));
   1.447 +    KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_DEVICE_RELATIONS\n"));
   1.448 +    switch (Stack->Parameters.QueryDeviceRelations.Type)
   1.449 +    {
   1.450 +    case BusRelations:
   1.451 +      KdPrint((__DRIVER_NAME "       BusRelations\n"));
   1.452 +      IoCopyCurrentIrpStackLocationToNext(Irp);
   1.453 +      IoSetCompletionRoutine(Irp, XenHide_IoCompletion, DeviceExtension, TRUE, TRUE, TRUE);
   1.454 +      break;  
   1.455 +    default:
   1.456 +      IoSkipCurrentIrpStackLocation(Irp);
   1.457 +      break;  
   1.458 +    }
   1.459      break;
   1.460    default:
   1.461 -    KdPrint((__DRIVER_NAME "     MinorFunction = %02x\n", Stack->MinorFunction));
   1.462 +    IoSkipCurrentIrpStackLocation(Irp);
   1.463      break;
   1.464    }
   1.465  
   1.466 -  switch (DeviceExtension->Type)
   1.467 -  {
   1.468 -  case XENHIDE_TYPE_PCI:
   1.469 -    KdPrint((__DRIVER_NAME "     As PCI\n"));
   1.470 +  Status = IoCallDriver(DeviceExtension->NextLowerDevice, Irp);
   1.471  
   1.472 -    switch (Stack->MinorFunction) {
   1.473 -    case IRP_MN_QUERY_DEVICE_RELATIONS:
   1.474 -      KdPrint((__DRIVER_NAME "     IRP_MN_QUERY_DEVICE_RELATIONS\n"));
   1.475 -      switch (Stack->Parameters.QueryDeviceRelations.Type)
   1.476 -      {
   1.477 -      case BusRelations:
   1.478 -        KdPrint((__DRIVER_NAME "       BusRelations\n"));
   1.479 -        IoCopyCurrentIrpStackLocationToNext(Irp);
   1.480 -        IoSetCompletionRoutine(Irp, XenHide_IoCompletionPciQueryDeviceRelations, DeviceExtension, TRUE, TRUE, TRUE);
   1.481 -        break;
   1.482 -      default:
   1.483 -        IoSkipCurrentIrpStackLocation(Irp);
   1.484 -        break;  
   1.485 -      }
   1.486 -      break;
   1.487 -    case IRP_MN_QUERY_ID:
   1.488 -      IoCopyCurrentIrpStackLocationToNext(Irp);
   1.489 -      IoSetCompletionRoutine(Irp, XenHide_IoCompletionPciQueryId, DeviceExtension, TRUE, TRUE, TRUE);
   1.490 -      break;
   1.491 -    case IRP_MN_QUERY_CAPABILITIES:
   1.492 -    default:
   1.493 -      IoSkipCurrentIrpStackLocation(Irp);
   1.494 -      break;
   1.495 -    }
   1.496 -    Status = IoCallDriver(DeviceExtension->NextLowerDevice, Irp);
   1.497 -    break;
   1.498 -  case XENHIDE_TYPE_HIDE:
   1.499 -    KdPrint((__DRIVER_NAME "     As Hide\n"));
   1.500 -    switch (Stack->MinorFunction)
   1.501 -    {
   1.502 -/*
   1.503 -    case IRP_MN_START_DEVICE:
   1.504 -      IoCopyCurrentIrpStackLocationToNext(Irp);
   1.505 -      IoSetCompletionRoutine(Irp, XenHide_IoCompletionHideStartDevice, DeviceExtension, TRUE, TRUE, TRUE);
   1.506 -      IoCopyCurrentIrpStackLocationToNext(Irp);
   1.507 -      Stack = IoGetNextIrpStackLocation(Irp);
   1.508 -      Stack->Parameters.StartDevice.AllocatedResources = ExAllocatePoolWithTag(NonPagedPool, sizeof(CM_RESOURCE_LIST), XENHIDE_POOL_TAG);
   1.509 -      Stack->Parameters.StartDevice.AllocatedResources->Count = 1;
   1.510 -      Stack->Parameters.StartDevice.AllocatedResources->List[0].InterfaceType = Internal;
   1.511 -      Stack->Parameters.StartDevice.AllocatedResources->List[0].BusNumber = 0;
   1.512 -      Stack->Parameters.StartDevice.AllocatedResources->List[0].PartialResourceList.Version = 1;
   1.513 -      Stack->Parameters.StartDevice.AllocatedResources->List[0].PartialResourceList.Revision = 1;
   1.514 -      Stack->Parameters.StartDevice.AllocatedResources->List[0].PartialResourceList.Count = 0;
   1.515 -      Stack->Parameters.StartDevice.AllocatedResourcesTranslated = ExAllocatePoolWithTag(NonPagedPool, sizeof(CM_RESOURCE_LIST), XENHIDE_POOL_TAG);
   1.516 -      Stack->Parameters.StartDevice.AllocatedResourcesTranslated->Count = 1;
   1.517 -      Stack->Parameters.StartDevice.AllocatedResourcesTranslated->List[0].InterfaceType = Internal;
   1.518 -      Stack->Parameters.StartDevice.AllocatedResourcesTranslated->List[0].BusNumber = 0;
   1.519 -      Stack->Parameters.StartDevice.AllocatedResourcesTranslated->List[0].PartialResourceList.Version = 1;
   1.520 -      Stack->Parameters.StartDevice.AllocatedResourcesTranslated->List[0].PartialResourceList.Revision = 1;
   1.521 -      Stack->Parameters.StartDevice.AllocatedResourcesTranslated->List[0].PartialResourceList.Count = 0;
   1.522 -      break;
   1.523 -    case IRP_MN_QUERY_PNP_DEVICE_STATE:
   1.524 -      IoCopyCurrentIrpStackLocationToNext(Irp);
   1.525 -      IoSetCompletionRoutine(Irp, XenHide_IoCompletionHideQueryPnpDeviceState, DeviceExtension, TRUE, TRUE, TRUE);
   1.526 -      break;
   1.527 -*/
   1.528 -    case IRP_MN_QUERY_ID:
   1.529 -      switch (Stack->Parameters.QueryId.IdType)
   1.530 -      {
   1.531 -      case BusQueryDeviceID:
   1.532 -        KdPrint((__DRIVER_NAME "     BusQueryDeviceID\n"));
   1.533 -        break;
   1.534 -      case BusQueryHardwareIDs:
   1.535 -        KdPrint((__DRIVER_NAME "     BusQueryHardwareIDs\n"));
   1.536 -        break;
   1.537 -      case BusQueryCompatibleIDs:
   1.538 -        KdPrint((__DRIVER_NAME "     BusQueryCompatibleIDs\n"));
   1.539 -        break;
   1.540 -      case BusQueryInstanceID:
   1.541 -        KdPrint((__DRIVER_NAME "     BusQueryInstanceID\n"));
   1.542 -        break;
   1.543 -      default:
   1.544 -        KdPrint((__DRIVER_NAME "     %08x\n", Stack->Parameters.QueryId.IdType));
   1.545 -        break;
   1.546 -      }
   1.547 -      IoCopyCurrentIrpStackLocationToNext(Irp);
   1.548 -      IoSetCompletionRoutine(Irp, XenHide_IoCompletionPciQueryId, DeviceExtension, TRUE, TRUE, TRUE);
   1.549 -      break;
   1.550 -    default:
   1.551 -      IoSkipCurrentIrpStackLocation(Irp);
   1.552 -      break;
   1.553 -    }
   1.554 -    Status = IoCallDriver(DeviceExtension->NextLowerDevice, Irp);
   1.555 -    break;
   1.556 -  }
   1.557 -
   1.558 -//  IoReleaseRemoveLock(&DeviceExtension->RemoveLock, Irp); 
   1.559 -  
   1.560    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (returning with status %08x)\n", Status));
   1.561  
   1.562    return Status;