win-pvdrivers

changeset 187:8c87bd40fe36

Final updates to xenhide. Added a very basic installer (install.bat)
author James Harper <james.harper@bendigoit.com.au>
date Fri Feb 15 21:40:33 2008 +1100 (2008-02-15)
parents 145b318c367c
children a416c66be9c2
files common.inc target/install.bat xenhide/xenhide.c xenhide/xenhide.h xenpci/xenpci.inx xenvbd/xenvbd.c
line diff
     1.1 --- a/common.inc	Thu Feb 14 16:50:10 2008 +1100
     1.2 +++ b/common.inc	Fri Feb 15 21:40:33 2008 +1100
     1.3 @@ -1,4 +1,4 @@
     1.4 -VERSION=0.7.0.49
     1.5 +VERSION=0.7.0.63
     1.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     1.7  KMDF_VERSION=1
     1.8  !IF $(_NT_TOOLS_VERSION) > 0x700
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/target/install.bat	Fri Feb 15 21:40:33 2008 +1100
     2.3 @@ -0,0 +1,29 @@
     2.4 +@ECHO OFF
     2.5 +
     2.6 +ver | find "Version 5.2." > nul
     2.7 +if %ERRORLEVEL% == 0 goto ver_2003
     2.8 +
     2.9 +ver | find "Version 5.1." > nul
    2.10 +if %ERRORLEVEL% == 0 goto ver_xp
    2.11 +
    2.12 +echo No automatic install available or machine not supported.
    2.13 +goto exit
    2.14 +
    2.15 +:ver_2003
    2.16 +echo Windows 2003 Detected... Installing...
    2.17 +shutdownmon -i
    2.18 +cd winnet
    2.19 +dpinst.exe /LM
    2.20 +echo Done
    2.21 +goto exit
    2.22 +
    2.23 +:ver_xp
    2.24 +echo Windows XP Detected... Installing...
    2.25 +shutdownmon -i
    2.26 +cd winnet
    2.27 +dpinst.exe /LM
    2.28 +echo Done
    2.29 +goto exit
    2.30 +
    2.31 +pause
    2.32 +:exit
    2.33 \ No newline at end of file
     3.1 --- a/xenhide/xenhide.c	Thu Feb 14 16:50:10 2008 +1100
     3.2 +++ b/xenhide/xenhide.c	Fri Feb 15 21:40:33 2008 +1100
     3.3 @@ -196,9 +196,10 @@ XenHide_AddDevice(
     3.4    DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
     3.5  
     3.6    DeviceExtension->Self = DeviceObject;
     3.7 +  DeviceExtension->PhysicalDeviceObject = PhysicalDeviceObject;
     3.8    DeviceExtension->DriverObject = DriverObject;
     3.9    DeviceExtension->Type = XENHIDE_TYPE_PCI;
    3.10 -  DeviceExtension->CallCount = 0;
    3.11 +  DeviceExtension->InternalState = 0;
    3.12  
    3.13    DeviceExtension->NextLowerDevice = IoAttachDeviceToDeviceStack(
    3.14      DeviceObject,
    3.15 @@ -259,7 +260,7 @@ XenHide_IoCompletion(PDEVICE_OBJECT Devi
    3.16    size_t StrLen;
    3.17    int Match;
    3.18    NTSTATUS status;
    3.19 -  PDEVICE_OBJECT deviceObject = NULL;
    3.20 +  PDEVICE_OBJECT NewDeviceObject;
    3.21    PDEVICE_EXTENSION DeviceExtension = (PDEVICE_EXTENSION)Context;
    3.22    PDEVICE_EXTENSION NewDeviceExtension;
    3.23  
    3.24 @@ -268,23 +269,18 @@ XenHide_IoCompletion(PDEVICE_OBJECT Devi
    3.25  
    3.26    KdPrint((__DRIVER_NAME " --> IoCompletion\n"));
    3.27    KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
    3.28 -  KdPrint((__DRIVER_NAME "     CallCount = %d\n", DeviceExtension->CallCount));
    3.29 +  KdPrint((__DRIVER_NAME "     InternalState = %d\n", DeviceExtension->InternalState));
    3.30  
    3.31    if (Irp->PendingReturned)
    3.32      IoMarkIrpPending(Irp);
    3.33  
    3.34 -  switch (DeviceExtension->CallCount)
    3.35 +  switch (DeviceExtension->InternalState)
    3.36    {
    3.37    case 0:
    3.38 -    DeviceExtension->CallCount = 1;
    3.39 +    DeviceExtension->InternalState = 1;
    3.40      break;
    3.41    case 1:
    3.42 -    DeviceExtension->CallCount = 2;
    3.43 -/*
    3.44 -    break;
    3.45 -  case 2:
    3.46 -    DeviceExtension->CallCount = 3;
    3.47 -*/
    3.48 +    DeviceExtension->InternalState = 2;
    3.49      Relations = (PDEVICE_RELATIONS)Irp->IoStatus.Information;
    3.50    
    3.51      for (i = 0; i < Relations->Count; i++)
    3.52 @@ -318,38 +314,39 @@ XenHide_IoCompletion(PDEVICE_OBJECT Devi
    3.53        if (Match)
    3.54        {
    3.55          KdPrint((__DRIVER_NAME "     Creating and attaching Device\n"));
    3.56 -        deviceObject = NULL;
    3.57 +        NewDeviceObject = NULL;
    3.58          status = IoCreateDevice(DeviceExtension->DriverObject,
    3.59            sizeof(DEVICE_EXTENSION),
    3.60            NULL,
    3.61            FILE_DEVICE_UNKNOWN,
    3.62            FILE_DEVICE_SECURE_OPEN,
    3.63            FALSE,
    3.64 -          &deviceObject);
    3.65 +          &NewDeviceObject);
    3.66          if (!NT_SUCCESS(status))
    3.67          {
    3.68            KdPrint((__DRIVER_NAME "     IoCreateDevice failed 0x%08x\n", status));
    3.69            continue;
    3.70          }
    3.71    
    3.72 -        NewDeviceExtension = (PDEVICE_EXTENSION)deviceObject->DeviceExtension;
    3.73 -      
    3.74 +        NewDeviceExtension = (PDEVICE_EXTENSION)NewDeviceObject->DeviceExtension;
    3.75 +        NewDeviceExtension->PhysicalDeviceObject = Relations->Objects[i];
    3.76 +        NewDeviceExtension->InternalState = 0;
    3.77          NewDeviceExtension->NextLowerDevice = IoAttachDeviceToDeviceStack(
    3.78 -          deviceObject,
    3.79 +          NewDeviceObject,
    3.80            Relations->Objects[i]);
    3.81 -        deviceObject->Flags |= NewDeviceExtension->NextLowerDevice->Flags;
    3.82 +        NewDeviceObject->Flags |= NewDeviceExtension->NextLowerDevice->Flags;
    3.83            
    3.84 -        deviceObject->DeviceType = NewDeviceExtension->NextLowerDevice->DeviceType;
    3.85 +        NewDeviceObject->DeviceType = NewDeviceExtension->NextLowerDevice->DeviceType;
    3.86        
    3.87 -        deviceObject->Characteristics = 
    3.88 +        NewDeviceObject->Characteristics = 
    3.89            NewDeviceExtension->NextLowerDevice->Characteristics;
    3.90  
    3.91          IoInitializeRemoveLock(&NewDeviceExtension->RemoveLock, XENHIDE_POOL_TAG, 1, 100);
    3.92        
    3.93 -        NewDeviceExtension->Self = deviceObject;
    3.94 +        NewDeviceExtension->Self = NewDeviceObject;
    3.95          NewDeviceExtension->Type = XENHIDE_TYPE_HIDE;
    3.96        
    3.97 -        deviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
    3.98 +        NewDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
    3.99        }
   3.100      }
   3.101      break;
   3.102 @@ -366,6 +363,7 @@ static NTSTATUS
   3.103  XenHide_Pass(PDEVICE_OBJECT DeviceObject, PIRP Irp)
   3.104  {
   3.105    PDEVICE_EXTENSION DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
   3.106 +  PIO_STACK_LOCATION Stack;
   3.107    NTSTATUS Status;
   3.108  
   3.109    Status = IoAcquireRemoveLock (&DeviceExtension->RemoveLock, Irp);
   3.110 @@ -376,6 +374,55 @@ XenHide_Pass(PDEVICE_OBJECT DeviceObject
   3.111    }
   3.112    if (DeviceExtension->Type == XENHIDE_TYPE_HIDE)
   3.113    {
   3.114 +    Stack = IoGetCurrentIrpStackLocation(Irp);
   3.115 +    switch (Stack->MajorFunction)
   3.116 +    {
   3.117 +    case IRP_MJ_CREATE:
   3.118 +      KdPrint(("     IRP_MJ_CREATE\n"));
   3.119 +      break;
   3.120 +    case IRP_MJ_PNP:
   3.121 +      KdPrint(("     IRP_MJ_PNP\n"));
   3.122 +      break;
   3.123 +    case IRP_MJ_POWER:
   3.124 +      KdPrint(("     IRP_MJ_POWER\n"));
   3.125 +      break;
   3.126 +    case IRP_MJ_READ:
   3.127 +      KdPrint(("     IRP_MJ_READ\n"));
   3.128 +      break;
   3.129 +    case IRP_MJ_WRITE:
   3.130 +      KdPrint(("     IRP_MJ_WRITE\n"));
   3.131 +      break;
   3.132 +    case IRP_MJ_FLUSH_BUFFERS:
   3.133 +      KdPrint(("     IRP_MJ_FLUSH_BUFFERS\n"));
   3.134 +      break;
   3.135 +    case IRP_MJ_QUERY_INFORMATION:
   3.136 +      KdPrint(("     IRP_MJ_CREATE\n"));
   3.137 +      break;
   3.138 +    case IRP_MJ_SET_INFORMATION:
   3.139 +      KdPrint(("     IRP_MJ_SET_INFORMATION\n"));
   3.140 +      break;
   3.141 +    case IRP_MJ_DEVICE_CONTROL:
   3.142 +      KdPrint(("     IRP_MJ_DEVICE_CONTROL\n"));
   3.143 +      break;
   3.144 +    case IRP_MJ_INTERNAL_DEVICE_CONTROL:
   3.145 +      KdPrint(("     IRP_MJ_INTERNAL_DEVICE_CONTROL\n"));
   3.146 +      break;
   3.147 +    case IRP_MJ_SYSTEM_CONTROL:
   3.148 +      KdPrint(("     IRP_MJ_SYSTEM_CONTROL\n"));
   3.149 +      break;
   3.150 +    case IRP_MJ_CLEANUP:
   3.151 +      KdPrint(("     IRP_MJ_CLEANUP\n"));
   3.152 +      break;
   3.153 +    case IRP_MJ_CLOSE:
   3.154 +      KdPrint(("     IRP_MJ_CLOSE\n"));
   3.155 +      break;
   3.156 +    case IRP_MJ_SHUTDOWN:
   3.157 +      KdPrint(("     IRP_MJ_SHUTDOWN\n"));
   3.158 +      break;
   3.159 +    default:
   3.160 +      KdPrint(("     %02X\n", Stack->MajorFunction));
   3.161 +      break;
   3.162 +    }
   3.163      Irp->IoStatus.Status = Status = STATUS_UNSUCCESSFUL;
   3.164      Irp->IoStatus.Information = 0;
   3.165      IoCompleteRequest(Irp, IO_NO_INCREMENT);
   3.166 @@ -416,6 +463,7 @@ XenHide_Pnp(PDEVICE_OBJECT DeviceObject,
   3.167    NTSTATUS Status = STATUS_SUCCESS;
   3.168    PIO_STACK_LOCATION Stack;
   3.169    PDEVICE_EXTENSION DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
   3.170 +  PGUID InterfaceType;
   3.171  
   3.172    KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   3.173    KdPrint((__DRIVER_NAME "     DeviceObject = %p\n", DeviceObject));
   3.174 @@ -449,7 +497,7 @@ XenHide_Pnp(PDEVICE_OBJECT DeviceObject,
   3.175      KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_QUERY_REMOVE_DEVICE\n"));
   3.176      break;
   3.177    case IRP_MN_REMOVE_DEVICE:
   3.178 -    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_REMOVE_DEVICEE\n"));
   3.179 +    KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_REMOVE_DEVICE\n"));
   3.180      break;
   3.181    case IRP_MN_CANCEL_REMOVE_DEVICE:
   3.182      KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_CANCEL_REMOVE_DEVICE\n"));
   3.183 @@ -502,6 +550,9 @@ XenHide_Pnp(PDEVICE_OBJECT DeviceObject,
   3.184    case IRP_MN_SET_LOCK:
   3.185      KdPrint((__DRIVER_NAME "     MinorFunction = IRP_MN_SET_LOCK\n"));
   3.186      break;
   3.187 +  default:
   3.188 +    KdPrint((__DRIVER_NAME "     MinorFunction = %02x\n", Stack->MinorFunction));
   3.189 +    break;
   3.190    }
   3.191  
   3.192    switch (DeviceExtension->Type)
   3.193 @@ -542,33 +593,23 @@ XenHide_Pnp(PDEVICE_OBJECT DeviceObject,
   3.194      case IRP_MN_REMOVE_DEVICE:
   3.195        Irp->IoStatus.Status = Status = STATUS_SUCCESS;
   3.196        break;
   3.197 +    case IRP_MN_QUERY_INTERFACE:
   3.198 +      IoCopyCurrentIrpStackLocationToNext(Irp);
   3.199 +      Status = IoCallDriver(DeviceExtension->NextLowerDevice, Irp);
   3.200 +      KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (returning with status %08x)\n", Status));
   3.201 +      return Status;
   3.202 +    case IRP_MN_QUERY_RESOURCES:
   3.203 +      Irp->IoStatus.Status = Status = STATUS_NOT_SUPPORTED;
   3.204 +      break;
   3.205      case IRP_MN_QUERY_PNP_DEVICE_STATE:
   3.206        Irp->IoStatus.Status = Status = STATUS_SUCCESS;
   3.207        Irp->IoStatus.Information = PNP_DEVICE_DONT_DISPLAY_IN_UI;
   3.208        break;
   3.209      default:
   3.210 -      Irp->IoStatus.Status = Status = STATUS_UNSUCCESSFUL;
   3.211 +      Irp->IoStatus.Status = Status = STATUS_NOT_SUPPORTED; //STATUS_UNSUCCESSFUL;
   3.212        break;
   3.213      }
   3.214      IoCompleteRequest(Irp, IO_NO_INCREMENT);
   3.215 -
   3.216 -/*
   3.217 -    switch (Stack->MinorFunction)
   3.218 -    {
   3.219 -    case IRP_MN_START_DEVICE:
   3.220 -      IoCopyCurrentIrpStackLocationToNext(Irp);
   3.221 -      Stack = IoGetNextIrpStackLocation(Irp);
   3.222 -      Stack->Parameters.StartDevice.AllocatedResources->List[0].PartialResourceList.Count = 0;
   3.223 -      Stack->Parameters.StartDevice.AllocatedResourcesTranslated->List[0].PartialResourceList.Count = 0;
   3.224 -      Status = IoCallDriver(DeviceExtension->NextLowerDevice, Irp);
   3.225 -      break;
   3.226 -    default:
   3.227 -      IoSkipCurrentIrpStackLocation(Irp);
   3.228 -      Status = IoCallDriver(DeviceExtension->NextLowerDevice, Irp);
   3.229 -      break;
   3.230 -    }
   3.231 -    IoCompleteRequest(Irp, IO_NO_INCREMENT);
   3.232 -*/
   3.233      break;
   3.234    }
   3.235  
     4.1 --- a/xenhide/xenhide.h	Thu Feb 14 16:50:10 2008 +1100
     4.2 +++ b/xenhide/xenhide.h	Fri Feb 15 21:40:33 2008 +1100
     4.3 @@ -40,12 +40,13 @@ DEFINE_GUID(GUID_XENHIDE_IFACE, 0xCD433F
     4.4  
     4.5  struct _DEVICE_EXTENSION {
     4.6    PDEVICE_OBJECT Self;
     4.7 +  PDEVICE_OBJECT PhysicalDeviceObject;
     4.8    PDRIVER_OBJECT DriverObject;
     4.9    PDEVICE_OBJECT NextLowerDevice;
    4.10    IO_REMOVE_LOCK RemoveLock;
    4.11    UNICODE_STRING InterfaceName;
    4.12    ULONG Type;
    4.13 -  ULONG CallCount;
    4.14 +  ULONG InternalState;
    4.15  } typedef DEVICE_EXTENSION, *PDEVICE_EXTENSION;
    4.16  
    4.17  #endif
     5.1 --- a/xenpci/xenpci.inx	Thu Feb 14 16:50:10 2008 +1100
     5.2 +++ b/xenpci/xenpci.inx	Fri Feb 15 21:40:33 2008 +1100
     5.3 @@ -25,12 +25,6 @@ ExcludeFromSelect=*
     5.4  [XenPCI_Inst.NT]
     5.5  CopyFiles=XenPCI.CopyFiles
     5.6  
     5.7 -;[XenPCI]
     5.8 -;AddReg=XenHide_AddReg
     5.9 -
    5.10 -;[XenHide_AddReg]
    5.11 -;HKLM,
    5.12 -
    5.13  [XenPCI.CopyFiles]
    5.14  xenpci.sys
    5.15  xenhide.sys
    5.16 @@ -68,7 +62,7 @@ ServiceBinary  = %12%\xenhide.sys
    5.17  AddReg         = XenHide_Service_AddReg
    5.18  
    5.19  [XenHide_Service_AddReg]
    5.20 -HKR,,AutoEnumerate,0x00010001, 0
    5.21 +HKLM,SYSTEM\CurrentControlSet\Control\Class\{4D36E97D-E325-11CE-BFC1-08002BE10318},LowerFilters,0x00010008,XenHide
    5.22  
    5.23  [XenPCI_Inst.NT.CoInstallers]
    5.24  AddReg=CoInstaller_AddReg
     6.1 --- a/xenvbd/xenvbd.c	Thu Feb 14 16:50:10 2008 +1100
     6.2 +++ b/xenvbd/xenvbd.c	Fri Feb 15 21:40:33 2008 +1100
     6.3 @@ -948,7 +948,7 @@ XenVbd_HwScsiStartIo(PVOID DeviceExtensi
     6.4      switch(cdb->CDB6GENERIC.OperationCode)
     6.5      {
     6.6      case SCSIOP_TEST_UNIT_READY:
     6.7 -      KdPrint((__DRIVER_NAME "     Command = TEST_UNIT_READY\n"));
     6.8 +//      KdPrint((__DRIVER_NAME "     Command = TEST_UNIT_READY\n"));
     6.9        Srb->SrbStatus = SRB_STATUS_SUCCESS;
    6.10        Srb->ScsiStatus = 0;
    6.11        ScsiPortNotification(RequestComplete, DeviceExtension, Srb);