win-pvdrivers

changeset 188:a416c66be9c2

Committing changes to xenhide, but giving up on this approach
author James Harper <james.harper@bendigoit.com.au>
date Mon Feb 18 16:12:48 2008 +1100 (2008-02-18)
parents 8c87bd40fe36
children eeeeb6924803
files common.inc xenhide/xenhide.c
line diff
     1.1 --- a/common.inc	Fri Feb 15 21:40:33 2008 +1100
     1.2 +++ b/common.inc	Mon Feb 18 16:12:48 2008 +1100
     1.3 @@ -1,4 +1,4 @@
     1.4 -VERSION=0.7.0.63
     1.5 +VERSION=0.7.0.74
     1.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     1.7  KMDF_VERSION=1
     1.8  !IF $(_NT_TOOLS_VERSION) > 0x700
     2.1 --- a/xenhide/xenhide.c	Fri Feb 15 21:40:33 2008 +1100
     2.2 +++ b/xenhide/xenhide.c	Mon Feb 18 16:12:48 2008 +1100
     2.3 @@ -212,8 +212,9 @@ XenHide_AddDevice(
     2.4    DeviceObject->Characteristics = 
     2.5      DeviceExtension->NextLowerDevice->Characteristics;
     2.6  
     2.7 -  IoInitializeRemoveLock(&DeviceExtension->RemoveLock, XENHIDE_POOL_TAG, 1, 100);
     2.8 +//  IoInitializeRemoveLock(&DeviceExtension->RemoveLock, XENHIDE_POOL_TAG, 1, 100);
     2.9  
    2.10 +#if 0
    2.11    if (AutoEnumerate)
    2.12    {
    2.13      status = IoRegisterDeviceInterface(PhysicalDeviceObject, (LPGUID)&GUID_XENHIDE_IFACE, NULL, &DeviceExtension->InterfaceName);
    2.14 @@ -234,6 +235,7 @@ XenHide_AddDevice(
    2.15    {
    2.16      KdPrint((__DRIVER_NAME "     Not registering Interface\n"));
    2.17    }
    2.18 +#endif
    2.19  
    2.20    DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
    2.21  
    2.22 @@ -250,7 +252,7 @@ XenHide_StringMatches(PWCHAR String1, PW
    2.23  }
    2.24  
    2.25  static NTSTATUS
    2.26 -XenHide_IoCompletion(PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Context)
    2.27 +XenHide_IoCompletionPciQueryDeviceRelations(PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Context)
    2.28  {
    2.29    ULONG i, j;
    2.30    PDEVICE_RELATIONS Relations;
    2.31 @@ -267,7 +269,7 @@ XenHide_IoCompletion(PDEVICE_OBJECT Devi
    2.32    UNREFERENCED_PARAMETER(DeviceObject);
    2.33    UNREFERENCED_PARAMETER(Context);
    2.34  
    2.35 -  KdPrint((__DRIVER_NAME " --> IoCompletion\n"));
    2.36 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    2.37    KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
    2.38    KdPrint((__DRIVER_NAME "     InternalState = %d\n", DeviceExtension->InternalState));
    2.39  
    2.40 @@ -341,7 +343,7 @@ XenHide_IoCompletion(PDEVICE_OBJECT Devi
    2.41          NewDeviceObject->Characteristics = 
    2.42            NewDeviceExtension->NextLowerDevice->Characteristics;
    2.43  
    2.44 -        IoInitializeRemoveLock(&NewDeviceExtension->RemoveLock, XENHIDE_POOL_TAG, 1, 100);
    2.45 +//        IoInitializeRemoveLock(&NewDeviceExtension->RemoveLock, XENHIDE_POOL_TAG, 1, 100);
    2.46        
    2.47          NewDeviceExtension->Self = NewDeviceObject;
    2.48          NewDeviceExtension->Type = XENHIDE_TYPE_HIDE;
    2.49 @@ -354,85 +356,104 @@ XenHide_IoCompletion(PDEVICE_OBJECT Devi
    2.50      break;
    2.51    }
    2.52  
    2.53 -  KdPrint((__DRIVER_NAME " <-- IoCompletion\n"));
    2.54 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    2.55  
    2.56    return STATUS_SUCCESS; //Irp->IoStatus.Status;
    2.57  }
    2.58  
    2.59  static NTSTATUS
    2.60 +XenHide_IoCompletionHideQueryPnpDeviceState(PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Context)
    2.61 +{
    2.62 +  UNREFERENCED_PARAMETER(DeviceObject);
    2.63 +  UNREFERENCED_PARAMETER(Context);
    2.64 +
    2.65 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    2.66 +
    2.67 +  if (Irp->PendingReturned)
    2.68 +    IoMarkIrpPending(Irp);
    2.69 +
    2.70 +  Irp->IoStatus.Information |= PNP_DEVICE_DONT_DISPLAY_IN_UI|PNP_DEVICE_DISABLED;
    2.71 +
    2.72 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    2.73 +  return STATUS_SUCCESS;
    2.74 +}
    2.75 +
    2.76 +static NTSTATUS
    2.77 +XenHide_IoCompletionPciQueryId(PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Context)
    2.78 +{
    2.79 +  PIO_STACK_LOCATION Stack;
    2.80 +
    2.81 +  UNREFERENCED_PARAMETER(DeviceObject);
    2.82 +  UNREFERENCED_PARAMETER(Context);
    2.83 +
    2.84 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    2.85 +
    2.86 +  if (Irp->PendingReturned)
    2.87 +    IoMarkIrpPending(Irp);
    2.88 +
    2.89 +  Stack = IoGetCurrentIrpStackLocation(Irp);
    2.90 +
    2.91 +  switch (Stack->Parameters.QueryId.IdType)
    2.92 +  {
    2.93 +  case BusQueryDeviceID:
    2.94 +    KdPrint((__DRIVER_NAME "     IdType = BusQueryDeviceID\n"));
    2.95 +    KdPrint((__DRIVER_NAME "     %ws\n", Irp->IoStatus.Information));
    2.96 +    break;
    2.97 +  case BusQueryHardwareIDs:
    2.98 +    KdPrint((__DRIVER_NAME "     IdType = BusQueryHardwareIDs\n"));
    2.99 +    KdPrint((__DRIVER_NAME "     %ws\n", Irp->IoStatus.Information));
   2.100 +    break;
   2.101 +  case BusQueryCompatibleIDs:
   2.102 +    KdPrint((__DRIVER_NAME "     IdType = BusQueryCompatibleIDs\n"));
   2.103 +    KdPrint((__DRIVER_NAME "     %ws\n", Irp->IoStatus.Information));
   2.104 +    break;
   2.105 +  case BusQueryInstanceID:
   2.106 +    KdPrint((__DRIVER_NAME "     IdType = BusQueryInstanceID\n"));
   2.107 +    KdPrint((__DRIVER_NAME "     %ws\n", Irp->IoStatus.Information));
   2.108 +    break;
   2.109 +  default:
   2.110 +    KdPrint((__DRIVER_NAME "     IdType = %08x\n", Stack->Parameters.QueryId.IdType));
   2.111 +    KdPrint((__DRIVER_NAME "     %ws\n", Irp->IoStatus.Information));
   2.112 +    break;
   2.113 +  }
   2.114 +
   2.115 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   2.116 +  return STATUS_SUCCESS;
   2.117 +}
   2.118 +
   2.119 +static NTSTATUS
   2.120 +XenHide_IoCompletionHideStartDevice(PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Context)
   2.121 +{
   2.122 +  UNREFERENCED_PARAMETER(DeviceObject);
   2.123 +  UNREFERENCED_PARAMETER(Context);
   2.124 +
   2.125 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   2.126 +  KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
   2.127 +
   2.128 +  if (Irp->PendingReturned)
   2.129 +    IoMarkIrpPending(Irp);
   2.130 +
   2.131 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   2.132 +  return STATUS_SUCCESS;
   2.133 +}
   2.134 +
   2.135 +static NTSTATUS
   2.136  XenHide_Pass(PDEVICE_OBJECT DeviceObject, PIRP Irp)
   2.137  {
   2.138    PDEVICE_EXTENSION DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
   2.139 -  PIO_STACK_LOCATION Stack;
   2.140    NTSTATUS Status;
   2.141  
   2.142 +#if 0
   2.143    Status = IoAcquireRemoveLock (&DeviceExtension->RemoveLock, Irp);
   2.144    if (!NT_SUCCESS(Status)) {
   2.145      Irp->IoStatus.Status = Status;
   2.146      IoCompleteRequest(Irp, IO_NO_INCREMENT);
   2.147      return Status;
   2.148    }
   2.149 -  if (DeviceExtension->Type == XENHIDE_TYPE_HIDE)
   2.150 -  {
   2.151 -    Stack = IoGetCurrentIrpStackLocation(Irp);
   2.152 -    switch (Stack->MajorFunction)
   2.153 -    {
   2.154 -    case IRP_MJ_CREATE:
   2.155 -      KdPrint(("     IRP_MJ_CREATE\n"));
   2.156 -      break;
   2.157 -    case IRP_MJ_PNP:
   2.158 -      KdPrint(("     IRP_MJ_PNP\n"));
   2.159 -      break;
   2.160 -    case IRP_MJ_POWER:
   2.161 -      KdPrint(("     IRP_MJ_POWER\n"));
   2.162 -      break;
   2.163 -    case IRP_MJ_READ:
   2.164 -      KdPrint(("     IRP_MJ_READ\n"));
   2.165 -      break;
   2.166 -    case IRP_MJ_WRITE:
   2.167 -      KdPrint(("     IRP_MJ_WRITE\n"));
   2.168 -      break;
   2.169 -    case IRP_MJ_FLUSH_BUFFERS:
   2.170 -      KdPrint(("     IRP_MJ_FLUSH_BUFFERS\n"));
   2.171 -      break;
   2.172 -    case IRP_MJ_QUERY_INFORMATION:
   2.173 -      KdPrint(("     IRP_MJ_CREATE\n"));
   2.174 -      break;
   2.175 -    case IRP_MJ_SET_INFORMATION:
   2.176 -      KdPrint(("     IRP_MJ_SET_INFORMATION\n"));
   2.177 -      break;
   2.178 -    case IRP_MJ_DEVICE_CONTROL:
   2.179 -      KdPrint(("     IRP_MJ_DEVICE_CONTROL\n"));
   2.180 -      break;
   2.181 -    case IRP_MJ_INTERNAL_DEVICE_CONTROL:
   2.182 -      KdPrint(("     IRP_MJ_INTERNAL_DEVICE_CONTROL\n"));
   2.183 -      break;
   2.184 -    case IRP_MJ_SYSTEM_CONTROL:
   2.185 -      KdPrint(("     IRP_MJ_SYSTEM_CONTROL\n"));
   2.186 -      break;
   2.187 -    case IRP_MJ_CLEANUP:
   2.188 -      KdPrint(("     IRP_MJ_CLEANUP\n"));
   2.189 -      break;
   2.190 -    case IRP_MJ_CLOSE:
   2.191 -      KdPrint(("     IRP_MJ_CLOSE\n"));
   2.192 -      break;
   2.193 -    case IRP_MJ_SHUTDOWN:
   2.194 -      KdPrint(("     IRP_MJ_SHUTDOWN\n"));
   2.195 -      break;
   2.196 -    default:
   2.197 -      KdPrint(("     %02X\n", Stack->MajorFunction));
   2.198 -      break;
   2.199 -    }
   2.200 -    Irp->IoStatus.Status = Status = STATUS_UNSUCCESSFUL;
   2.201 -    Irp->IoStatus.Information = 0;
   2.202 -    IoCompleteRequest(Irp, IO_NO_INCREMENT);
   2.203 -  }
   2.204 -  else
   2.205 -  {
   2.206 -    IoSkipCurrentIrpStackLocation(Irp);
   2.207 -    Status = IoCallDriver(DeviceExtension->NextLowerDevice, Irp);
   2.208 -  }
   2.209 -  IoReleaseRemoveLock(&DeviceExtension->RemoveLock, Irp); 
   2.210 +#endif
   2.211 +  IoSkipCurrentIrpStackLocation(Irp);
   2.212 +  Status = IoCallDriver(DeviceExtension->NextLowerDevice, Irp);
   2.213 +//  IoReleaseRemoveLock(&DeviceExtension->RemoveLock, Irp); 
   2.214    return Status;
   2.215  }
   2.216  
   2.217 @@ -442,7 +463,7 @@ XenHide_Power(PDEVICE_OBJECT DeviceObjec
   2.218    NTSTATUS Status = STATUS_SUCCESS;
   2.219    PDEVICE_EXTENSION DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
   2.220  
   2.221 -  Status = IoAcquireRemoveLock (&DeviceExtension->RemoveLock, Irp);
   2.222 +//  Status = IoAcquireRemoveLock (&DeviceExtension->RemoveLock, Irp);
   2.223    if (!NT_SUCCESS(Status)) {
   2.224      Irp->IoStatus.Status = Status;
   2.225      PoStartNextPowerIrp(Irp);
   2.226 @@ -453,7 +474,7 @@ XenHide_Power(PDEVICE_OBJECT DeviceObjec
   2.227    PoStartNextPowerIrp(Irp);
   2.228    IoSkipCurrentIrpStackLocation(Irp);
   2.229    Status = PoCallDriver(DeviceExtension->NextLowerDevice, Irp);
   2.230 -  IoReleaseRemoveLock(&DeviceExtension->RemoveLock, Irp); 
   2.231 +//  IoReleaseRemoveLock(&DeviceExtension->RemoveLock, Irp); 
   2.232    return Status;
   2.233  }
   2.234  
   2.235 @@ -463,12 +484,12 @@ XenHide_Pnp(PDEVICE_OBJECT DeviceObject,
   2.236    NTSTATUS Status = STATUS_SUCCESS;
   2.237    PIO_STACK_LOCATION Stack;
   2.238    PDEVICE_EXTENSION DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
   2.239 -  PGUID InterfaceType;
   2.240  
   2.241    KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   2.242    KdPrint((__DRIVER_NAME "     DeviceObject = %p\n", DeviceObject));
   2.243    KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
   2.244  
   2.245 +/*
   2.246    Status = IoAcquireRemoveLock (&DeviceExtension->RemoveLock, Irp);
   2.247    if (!NT_SUCCESS(Status)) {
   2.248      Irp->IoStatus.Status = Status;
   2.249 @@ -476,7 +497,7 @@ XenHide_Pnp(PDEVICE_OBJECT DeviceObject,
   2.250      KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (returning with status %08x)\n", Status));
   2.251      return Status;
   2.252    }
   2.253 -
   2.254 +*/
   2.255    Stack = IoGetCurrentIrpStackLocation(Irp);
   2.256  
   2.257    switch (Stack->MinorFunction)
   2.258 @@ -568,52 +589,85 @@ XenHide_Pnp(PDEVICE_OBJECT DeviceObject,
   2.259        case BusRelations:
   2.260          KdPrint((__DRIVER_NAME "       BusRelations\n"));
   2.261          IoCopyCurrentIrpStackLocationToNext(Irp);
   2.262 -        IoSetCompletionRoutine(Irp, XenHide_IoCompletion, DeviceExtension, TRUE, TRUE, TRUE);
   2.263 -        Status = IoCallDriver(DeviceExtension->NextLowerDevice, Irp);
   2.264 +        IoSetCompletionRoutine(Irp, XenHide_IoCompletionPciQueryDeviceRelations, DeviceExtension, TRUE, TRUE, TRUE);
   2.265          break;
   2.266        default:
   2.267          IoSkipCurrentIrpStackLocation(Irp);
   2.268 -        Status = IoCallDriver(DeviceExtension->NextLowerDevice, Irp);
   2.269          break;  
   2.270        }
   2.271        break;
   2.272 +    case IRP_MN_QUERY_ID:
   2.273 +      IoCopyCurrentIrpStackLocationToNext(Irp);
   2.274 +      IoSetCompletionRoutine(Irp, XenHide_IoCompletionPciQueryId, DeviceExtension, TRUE, TRUE, TRUE);
   2.275 +      break;
   2.276 +    case IRP_MN_QUERY_CAPABILITIES:
   2.277      default:
   2.278        IoSkipCurrentIrpStackLocation(Irp);
   2.279 -      Status = IoCallDriver(DeviceExtension->NextLowerDevice, Irp);
   2.280        break;
   2.281      }
   2.282 +    Status = IoCallDriver(DeviceExtension->NextLowerDevice, Irp);
   2.283      break;
   2.284    case XENHIDE_TYPE_HIDE:
   2.285      KdPrint((__DRIVER_NAME "     As Hide\n"));
   2.286 -    Irp->IoStatus.Information = 0;
   2.287      switch (Stack->MinorFunction)
   2.288      {
   2.289 +/*
   2.290      case IRP_MN_START_DEVICE:
   2.291 -    case IRP_MN_STOP_DEVICE:
   2.292 -    case IRP_MN_REMOVE_DEVICE:
   2.293 -      Irp->IoStatus.Status = Status = STATUS_SUCCESS;
   2.294 -      break;
   2.295 -    case IRP_MN_QUERY_INTERFACE:
   2.296        IoCopyCurrentIrpStackLocationToNext(Irp);
   2.297 -      Status = IoCallDriver(DeviceExtension->NextLowerDevice, Irp);
   2.298 -      KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (returning with status %08x)\n", Status));
   2.299 -      return Status;
   2.300 -    case IRP_MN_QUERY_RESOURCES:
   2.301 -      Irp->IoStatus.Status = Status = STATUS_NOT_SUPPORTED;
   2.302 +      IoSetCompletionRoutine(Irp, XenHide_IoCompletionHideStartDevice, DeviceExtension, TRUE, TRUE, TRUE);
   2.303 +      IoCopyCurrentIrpStackLocationToNext(Irp);
   2.304 +      Stack = IoGetNextIrpStackLocation(Irp);
   2.305 +      Stack->Parameters.StartDevice.AllocatedResources = ExAllocatePoolWithTag(NonPagedPool, sizeof(CM_RESOURCE_LIST), XENHIDE_POOL_TAG);
   2.306 +      Stack->Parameters.StartDevice.AllocatedResources->Count = 1;
   2.307 +      Stack->Parameters.StartDevice.AllocatedResources->List[0].InterfaceType = Internal;
   2.308 +      Stack->Parameters.StartDevice.AllocatedResources->List[0].BusNumber = 0;
   2.309 +      Stack->Parameters.StartDevice.AllocatedResources->List[0].PartialResourceList.Version = 1;
   2.310 +      Stack->Parameters.StartDevice.AllocatedResources->List[0].PartialResourceList.Revision = 1;
   2.311 +      Stack->Parameters.StartDevice.AllocatedResources->List[0].PartialResourceList.Count = 0;
   2.312 +      Stack->Parameters.StartDevice.AllocatedResourcesTranslated = ExAllocatePoolWithTag(NonPagedPool, sizeof(CM_RESOURCE_LIST), XENHIDE_POOL_TAG);
   2.313 +      Stack->Parameters.StartDevice.AllocatedResourcesTranslated->Count = 1;
   2.314 +      Stack->Parameters.StartDevice.AllocatedResourcesTranslated->List[0].InterfaceType = Internal;
   2.315 +      Stack->Parameters.StartDevice.AllocatedResourcesTranslated->List[0].BusNumber = 0;
   2.316 +      Stack->Parameters.StartDevice.AllocatedResourcesTranslated->List[0].PartialResourceList.Version = 1;
   2.317 +      Stack->Parameters.StartDevice.AllocatedResourcesTranslated->List[0].PartialResourceList.Revision = 1;
   2.318 +      Stack->Parameters.StartDevice.AllocatedResourcesTranslated->List[0].PartialResourceList.Count = 0;
   2.319        break;
   2.320      case IRP_MN_QUERY_PNP_DEVICE_STATE:
   2.321 -      Irp->IoStatus.Status = Status = STATUS_SUCCESS;
   2.322 -      Irp->IoStatus.Information = PNP_DEVICE_DONT_DISPLAY_IN_UI;
   2.323 +      IoCopyCurrentIrpStackLocationToNext(Irp);
   2.324 +      IoSetCompletionRoutine(Irp, XenHide_IoCompletionHideQueryPnpDeviceState, DeviceExtension, TRUE, TRUE, TRUE);
   2.325 +      break;
   2.326 +*/
   2.327 +    case IRP_MN_QUERY_ID:
   2.328 +      switch (Stack->Parameters.QueryId.IdType)
   2.329 +      {
   2.330 +      case BusQueryDeviceID:
   2.331 +        KdPrint((__DRIVER_NAME "     BusQueryDeviceID\n"));
   2.332 +        break;
   2.333 +      case BusQueryHardwareIDs:
   2.334 +        KdPrint((__DRIVER_NAME "     BusQueryHardwareIDs\n"));
   2.335 +        break;
   2.336 +      case BusQueryCompatibleIDs:
   2.337 +        KdPrint((__DRIVER_NAME "     BusQueryCompatibleIDs\n"));
   2.338 +        break;
   2.339 +      case BusQueryInstanceID:
   2.340 +        KdPrint((__DRIVER_NAME "     BusQueryInstanceID\n"));
   2.341 +        break;
   2.342 +      default:
   2.343 +        KdPrint((__DRIVER_NAME "     %08x\n", Stack->Parameters.QueryId.IdType));
   2.344 +        break;
   2.345 +      }
   2.346 +      IoCopyCurrentIrpStackLocationToNext(Irp);
   2.347 +      IoSetCompletionRoutine(Irp, XenHide_IoCompletionPciQueryId, DeviceExtension, TRUE, TRUE, TRUE);
   2.348        break;
   2.349      default:
   2.350 -      Irp->IoStatus.Status = Status = STATUS_NOT_SUPPORTED; //STATUS_UNSUCCESSFUL;
   2.351 +      IoSkipCurrentIrpStackLocation(Irp);
   2.352        break;
   2.353      }
   2.354 -    IoCompleteRequest(Irp, IO_NO_INCREMENT);
   2.355 +    Status = IoCallDriver(DeviceExtension->NextLowerDevice, Irp);
   2.356      break;
   2.357    }
   2.358  
   2.359 -  IoReleaseRemoveLock(&DeviceExtension->RemoveLock, Irp); 
   2.360 +//  IoReleaseRemoveLock(&DeviceExtension->RemoveLock, Irp); 
   2.361    
   2.362    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (returning with status %08x)\n", Status));
   2.363