win-pvdrivers

changeset 569:00d35855e2e4

removed the rest of xenhide
author James Harper <james.harper@bendigoit.com.au>
date Sun May 10 20:20:23 2009 +1000 (2009-05-10)
parents 21b13cbeb94e
children 36fef48dbfa9
files xenhide/sources xenhide/xenhide.c xenhide/xenhide.h
line diff
     1.1 --- a/xenhide/sources	Sun May 10 20:20:09 2009 +1000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,5 +0,0 @@
     1.4 -!include "..\common.inc"
     1.5 -KMDF_VERSION_MAJOR=1
     1.6 -TARGETNAME=xenhide
     1.7 -TARGETTYPE=DRIVER
     1.8 -SOURCES=xenhide.c
     2.1 --- a/xenhide/xenhide.c	Sun May 10 20:20:09 2009 +1000
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,596 +0,0 @@
     2.4 -/*
     2.5 -PV Drivers for Windows Xen HVM Domains
     2.6 -Copyright (C) 2007 James Harper
     2.7 -
     2.8 -This program is free software; you can redistribute it and/or
     2.9 -modify it under the terms of the GNU General Public License
    2.10 -as published by the Free Software Foundation; either version 2
    2.11 -of the License, or (at your option) any later version.
    2.12 -
    2.13 -This program is distributed in the hope that it will be useful,
    2.14 -but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.15 -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    2.16 -GNU General Public License for more details.
    2.17 -
    2.18 -You should have received a copy of the GNU General Public License
    2.19 -along with this program; if not, write to the Free Software
    2.20 -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    2.21 -*/
    2.22 -
    2.23 -#include "xenhide.h"
    2.24 -#include <stdlib.h>
    2.25 -
    2.26 -extern PULONG InitSafeBootMode;
    2.27 -static BOOLEAN need_gplpv_filter;
    2.28 -static BOOLEAN gplpv_interrogated;
    2.29 -
    2.30 -static NTSTATUS
    2.31 -XenHide_EvtDeviceFilterRemoveResourceRequirements(WDFDEVICE device, WDFIORESREQLIST irrl)
    2.32 -{
    2.33 -  ULONG i;
    2.34 -  WDFIORESLIST irl;
    2.35 -  
    2.36 -  UNREFERENCED_PARAMETER(device);
    2.37 -  
    2.38 -  FUNCTION_ENTER();
    2.39 -  
    2.40 -  for (i = 0; i < WdfIoResourceRequirementsListGetCount(irrl); i++)
    2.41 -  {
    2.42 -    KdPrint((__DRIVER_NAME "     Processing irrl #%d\n", i));
    2.43 -    irl = WdfIoResourceRequirementsListGetIoResList(irrl, i);
    2.44 -    while(WdfIoResourceListGetCount(irl) > 0)
    2.45 -    {
    2.46 -      KdPrint((__DRIVER_NAME "     Removing irl\n"));
    2.47 -      WdfIoResourceListRemove(irl, 0);
    2.48 -    }
    2.49 -  }
    2.50 -  
    2.51 -  FUNCTION_EXIT();
    2.52 -  
    2.53 -  return STATUS_SUCCESS;
    2.54 -}
    2.55 -
    2.56 -/*
    2.57 -static NTSTATUS
    2.58 -XenHide_EvtDeviceD0Entry(WDFDEVICE device, WDF_POWER_DEVICE_STATE previous_state)
    2.59 -{
    2.60 -  NTSTATUS status = STATUS_UNSUCCESSFUL;
    2.61 -  
    2.62 -  UNREFERENCED_PARAMETER(device);
    2.63 -  UNREFERENCED_PARAMETER(previous_state);
    2.64 -
    2.65 -  FUNCTION_ENTER();
    2.66 -  WdfDeviceSetFailed(device, WdfDeviceFailedNoRestart);
    2.67 -  FUNCTION_EXIT();
    2.68 -  return status;
    2.69 -}
    2.70 -*/
    2.71 -
    2.72 -NTSTATUS
    2.73 -XenHide_EvtDevicePrepareHardware (WDFDEVICE device, WDFCMRESLIST resources_raw, WDFCMRESLIST resources_translated)
    2.74 -{
    2.75 -  UNREFERENCED_PARAMETER(device);
    2.76 -  UNREFERENCED_PARAMETER(resources_raw);
    2.77 -  UNREFERENCED_PARAMETER(resources_translated);
    2.78 -  FUNCTION_ENTER();
    2.79 -  FUNCTION_EXIT();
    2.80 -  return STATUS_SUCCESS; //UNSUCCESSFUL;
    2.81 -}
    2.82 -
    2.83 -/*
    2.84 -NTSTATUS
    2.85 -XenHide_EvtDeviceReleaseHardware(WDFDEVICE device, WDFCMRESLIST resources_translated)
    2.86 -{
    2.87 -  UNREFERENCED_PARAMETER(device);
    2.88 -  UNREFERENCED_PARAMETER(resources_translated);
    2.89 -  
    2.90 -  FUNCTION_ENTER();
    2.91 -  FUNCTION_EXIT();
    2.92 -  
    2.93 -  return STATUS_SUCCESS;
    2.94 -}
    2.95 -*/
    2.96 -
    2.97 -
    2.98 -static BOOLEAN
    2.99 -XenHide_IdSuffixMatches(PWDFDEVICE_INIT device_init, PWCHAR matching_id)
   2.100 -{
   2.101 -  NTSTATUS status;
   2.102 -  WDFMEMORY memory;
   2.103 -  ULONG remaining;
   2.104 -  size_t string_length;
   2.105 -  PWCHAR ids;
   2.106 -  PWCHAR ptr;
   2.107 -  size_t ids_length;
   2.108 -  ULONG properties[] = {DevicePropertyCompatibleIDs, DevicePropertyHardwareID};
   2.109 -  int i;
   2.110 -  
   2.111 -//  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   2.112 -  for (i = 0; i < ARRAY_SIZE(properties); i++)
   2.113 -  {
   2.114 -
   2.115 -    status = WdfFdoInitAllocAndQueryProperty(device_init, properties[i], NonPagedPool, WDF_NO_OBJECT_ATTRIBUTES, &memory);
   2.116 -    if (!NT_SUCCESS(status))
   2.117 -      continue;
   2.118 -    ids = WdfMemoryGetBuffer(memory, &ids_length);
   2.119 -
   2.120 -    if (!NT_SUCCESS(status))
   2.121 -    {
   2.122 -//      KdPrint((__DRIVER_NAME "     i = %d, status = %x, ids_length = %d\n", i, status, ids_length));
   2.123 -      continue;
   2.124 -    }
   2.125 -    
   2.126 -    remaining = ids_length / 2;
   2.127 -    for (ptr = ids; *ptr != 0; ptr += string_length + 1)
   2.128 -    {
   2.129 -      RtlStringCchLengthW(ptr, remaining, &string_length);
   2.130 -      remaining -= (ULONG)string_length + 1;
   2.131 -      if (string_length >= wcslen(matching_id))
   2.132 -      {
   2.133 -        ptr += string_length - wcslen(matching_id);
   2.134 -        string_length = wcslen(matching_id);
   2.135 -      }
   2.136 -//      KdPrint((__DRIVER_NAME "     Comparing '%S' and '%S'\n", ptr, matching_id));
   2.137 -      if (wcscmp(ptr, matching_id) == 0)
   2.138 -      {
   2.139 -        //KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (Match)\n"));
   2.140 -        WdfObjectDelete(memory);
   2.141 -        return TRUE;
   2.142 -      }
   2.143 -    }
   2.144 -    WdfObjectDelete(memory);
   2.145 -  }
   2.146 -//  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (No match)\n"));
   2.147 -  return FALSE;
   2.148 -}
   2.149 -
   2.150 -static NTSTATUS
   2.151 -XenHide_EvtDeviceAdd(WDFDRIVER driver, PWDFDEVICE_INIT device_init)
   2.152 -{
   2.153 -  NTSTATUS status;
   2.154 -  WDFMEMORY memory;
   2.155 -  PWCHAR device_description;
   2.156 -  WDF_PNPPOWER_EVENT_CALLBACKS pnp_power_callbacks;
   2.157 -  WDF_FDO_EVENT_CALLBACKS fdo_callbacks;
   2.158 -  WDF_OBJECT_ATTRIBUTES device_attributes;
   2.159 -  UNICODE_STRING dir_name;
   2.160 -  OBJECT_ATTRIBUTES oa;
   2.161 -  HANDLE handle;
   2.162 -  BOOLEAN hide_required = FALSE;
   2.163 -  WDFDEVICE device;
   2.164 -  //PXENHIDE_DEVICE_DATA xhdd;
   2.165 -
   2.166 -  UNREFERENCED_PARAMETER(driver);
   2.167 -#if 0
   2.168 -  PDEVICE_OBJECT deviceObject = NULL;
   2.169 -  ULONG length;
   2.170 -  WCHAR device_description[256];
   2.171 -  USHORT hide_type;
   2.172 -#endif
   2.173 -
   2.174 -  FUNCTION_ENTER();
   2.175 -
   2.176 -  if (!gplpv_interrogated)
   2.177 -  {
   2.178 -    gplpv_interrogated = TRUE;
   2.179 -    RtlInitUnicodeString(&dir_name, L"\\NEED_GPLPV_FILTER");
   2.180 -    InitializeObjectAttributes(&oa, &dir_name, OBJ_KERNEL_HANDLE, NULL, NULL);
   2.181 -    status = ZwOpenDirectoryObject(&handle, DIRECTORY_QUERY, &oa);
   2.182 -    KdPrint((__DRIVER_NAME "     ZwOpenDirectoryObject = %08x\n", status));
   2.183 -    if (NT_SUCCESS(status))
   2.184 -    {
   2.185 -      need_gplpv_filter = TRUE;
   2.186 -      ZwClose(handle);
   2.187 -    }
   2.188 -  }
   2.189 -  
   2.190 -  status = WdfFdoInitAllocAndQueryProperty(device_init, DevicePropertyDeviceDescription, NonPagedPool, WDF_NO_OBJECT_ATTRIBUTES, &memory);
   2.191 -  if (NT_SUCCESS(status))
   2.192 -  {
   2.193 -    device_description = WdfMemoryGetBuffer(memory, NULL);
   2.194 -  }
   2.195 -  else
   2.196 -  {
   2.197 -    device_description = L"<unknown device>";
   2.198 -  }
   2.199 -
   2.200 -  if (need_gplpv_filter)
   2.201 -  {
   2.202 -    /* hide only specific devices */
   2.203 -    if (XenHide_IdSuffixMatches(device_init, L"VEN_8086&DEV_7010")) // Qemu IDE
   2.204 -    {
   2.205 -      hide_required = TRUE;
   2.206 -    }
   2.207 -    else if (XenHide_IdSuffixMatches(device_init, L"VEN_1000&DEV_0012"))// Qemu SCSI
   2.208 -    {
   2.209 -      hide_required = TRUE;
   2.210 -    }
   2.211 -    else if (XenHide_IdSuffixMatches(device_init, L"VEN_10EC&DEV_8139")) // Qemu Network
   2.212 -    {
   2.213 -      hide_required = TRUE;
   2.214 -    }
   2.215 -  }
   2.216 -
   2.217 -  if (!hide_required)
   2.218 -  {
   2.219 -    WdfObjectDelete(memory);
   2.220 -    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (filter not required for %S)\n", device_description));
   2.221 -    return STATUS_SUCCESS;
   2.222 -  }
   2.223 -  
   2.224 -  KdPrint((__DRIVER_NAME "     Installing Filter for %S\n", device_description));
   2.225 -
   2.226 -  WdfFdoInitSetFilter(device_init);
   2.227 -  WdfDeviceInitSetDeviceType(device_init, FILE_DEVICE_UNKNOWN);
   2.228 -  WdfDeviceInitSetExclusive(device_init, FALSE);
   2.229 -
   2.230 -  WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&pnp_power_callbacks);
   2.231 -  pnp_power_callbacks.EvtDevicePrepareHardware = XenHide_EvtDevicePrepareHardware;
   2.232 -  //pnp_power_callbacks.EvtDeviceReleaseHardware = XenHide_EvtDeviceReleaseHardware;
   2.233 -  //pnp_power_callbacks.EvtDeviceD0Entry = XenHide_EvtDeviceD0Entry;
   2.234 -  //pnp_power_callbacks.EvtDeviceD0Exit = XenHide_EvtDeviceD0Exit;
   2.235 -  WdfDeviceInitSetPnpPowerEventCallbacks(device_init, &pnp_power_callbacks);
   2.236 -  
   2.237 -  WDF_FDO_EVENT_CALLBACKS_INIT(&fdo_callbacks);
   2.238 -  fdo_callbacks.EvtDeviceFilterRemoveResourceRequirements = XenHide_EvtDeviceFilterRemoveResourceRequirements;
   2.239 -  WdfFdoInitSetEventCallbacks(device_init, &fdo_callbacks);
   2.240 -
   2.241 -  //WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&device_attributes, XENHIDE_DEVICE_DATA);
   2.242 -  WDF_OBJECT_ATTRIBUTES_INIT(&device_attributes);
   2.243 -  status = WdfDeviceCreate(&device_init, &device_attributes, &device);
   2.244 -  if (!NT_SUCCESS(status))
   2.245 -  {
   2.246 -    KdPrint(("Error creating device %08x\n", status));
   2.247 -    WdfObjectDelete(memory);
   2.248 -    FUNCTION_EXIT();
   2.249 -    return status;
   2.250 -  }
   2.251 -
   2.252 -  //xhdd = GetXhdd(device);
   2.253 -
   2.254 -  //xhdd->filter_do = deviceObject;
   2.255 -
   2.256 -  WdfObjectDelete(memory);
   2.257 -  FUNCTION_EXIT();
   2.258 -
   2.259 -  return status;
   2.260 -}
   2.261 -
   2.262 -
   2.263 -
   2.264 -#if 0
   2.265 -static NTSTATUS
   2.266 -XenHide_Power(PDEVICE_OBJECT device_object, PIRP irp)
   2.267 -{
   2.268 -  NTSTATUS status;
   2.269 -  PXENHIDE_DEVICE_DATA xhdd = (PXENHIDE_DEVICE_DATA)device_object->DeviceExtension;
   2.270 -
   2.271 -  PoStartNextPowerIrp(irp);
   2.272 -  IoSkipCurrentIrpStackLocation(irp);
   2.273 -  status = PoCallDriver(xhdd->lower_do, irp);
   2.274 -  return status;
   2.275 -}
   2.276 -
   2.277 -static BOOLEAN
   2.278 -XenHide_IdSuffixMatches(PDEVICE_OBJECT pdo, PWCHAR matching_id)
   2.279 -{
   2.280 -  NTSTATUS status;
   2.281 -  ULONG remaining;
   2.282 -  size_t string_length;
   2.283 -  WCHAR ids[512];
   2.284 -  PWCHAR ptr;
   2.285 -  ULONG ids_length;
   2.286 -  int i;
   2.287 -  
   2.288 -//  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   2.289 -  for (i = 0; i < 2; i++)
   2.290 -  {
   2.291 -    if (i == 0)
   2.292 -      status = IoGetDeviceProperty(pdo, DevicePropertyCompatibleIDs, sizeof(ids), ids, &ids_length);
   2.293 -    else
   2.294 -      status = IoGetDeviceProperty(pdo, DevicePropertyHardwareID, sizeof(ids), ids, &ids_length);
   2.295 -      
   2.296 -    if (!NT_SUCCESS(status))
   2.297 -    {
   2.298 -//      KdPrint((__DRIVER_NAME "     i = %d, status = %x, ids_length = %d\n", i, status, ids_length));
   2.299 -      continue;
   2.300 -    }
   2.301 -    
   2.302 -    remaining = ids_length / 2;
   2.303 -    for (ptr = ids; *ptr != 0; ptr += string_length + 1)
   2.304 -    {
   2.305 -      RtlStringCchLengthW(ptr, remaining, &string_length);
   2.306 -      remaining -= (ULONG)string_length + 1;
   2.307 -      if (string_length >= wcslen(matching_id))
   2.308 -      {
   2.309 -        ptr += string_length - wcslen(matching_id);
   2.310 -        string_length = (ULONG)wcslen(matching_id);
   2.311 -      }
   2.312 -//      KdPrint((__DRIVER_NAME "     Comparing '%S' and '%S'\n", ptr, matching_id));
   2.313 -      if (wcscmp(ptr, matching_id) == 0)
   2.314 -      {
   2.315 -        //KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (Match)\n"));
   2.316 -        return TRUE;
   2.317 -      }
   2.318 -    }
   2.319 -  }
   2.320 -//  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (No match)\n"));
   2.321 -  return FALSE;
   2.322 -}
   2.323 -
   2.324 -static NTSTATUS
   2.325 -XenHide_AddDevice(
   2.326 -  PDRIVER_OBJECT DriverObject,
   2.327 -  PDEVICE_OBJECT PhysicalDeviceObject
   2.328 -  )
   2.329 -{
   2.330 -  NTSTATUS status;
   2.331 -  PDEVICE_OBJECT deviceObject = NULL;
   2.332 -  PXENHIDE_DEVICE_DATA xhdd;
   2.333 -  ULONG length;
   2.334 -  WCHAR device_description[256];
   2.335 -  USHORT hide_type;
   2.336 -  OBJECT_ATTRIBUTES oa;
   2.337 -  UNICODE_STRING dir_name;
   2.338 -  HANDLE handle;
   2.339 -
   2.340 -  FUNCTION_ENTER();
   2.341 -
   2.342 -  if (!gplpv_interrogated)
   2.343 -  {
   2.344 -    gplpv_interrogated = TRUE;
   2.345 -    RtlInitUnicodeString(&dir_name, L"\\NEED_GPLPV_FILTER");
   2.346 -    InitializeObjectAttributes(&oa, &dir_name, OBJ_KERNEL_HANDLE, NULL, NULL);
   2.347 -    status = ZwOpenDirectoryObject(&handle, DIRECTORY_QUERY, &oa);
   2.348 -    KdPrint((__DRIVER_NAME "     ZwOpenDirectoryObject = %08x\n", status));
   2.349 -    if (NT_SUCCESS(status))
   2.350 -      need_gplpv_filter = TRUE;
   2.351 -  }
   2.352 -  
   2.353 -  length = 512;
   2.354 -  status = IoGetDeviceProperty(PhysicalDeviceObject, DevicePropertyDeviceDescription, length, device_description, &length);
   2.355 -  if (!NT_SUCCESS(status))
   2.356 -  {
   2.357 -    device_description[0] = 0;
   2.358 -  }
   2.359 -
   2.360 -  //KdPrint((__DRIVER_NAME "     Checking '%S'\n", device_description));
   2.361 -
   2.362 -  hide_type = XENHIDE_TYPE_NONE;
   2.363 -  if (need_gplpv_filter)
   2.364 -  {
   2.365 -    /* hide only specific devices */
   2.366 -    if (XenHide_IdSuffixMatches(PhysicalDeviceObject, L"VEN_8086&DEV_7010")) // Qemu IDE
   2.367 -    {
   2.368 -      hide_type = XENHIDE_TYPE_DEVICE;
   2.369 -    }
   2.370 -    else if (XenHide_IdSuffixMatches(PhysicalDeviceObject, L"VEN_1000&DEV_0012"))// Qemu SCSI
   2.371 -    {
   2.372 -      hide_type = XENHIDE_TYPE_DEVICE;
   2.373 -    }
   2.374 -    else if (XenHide_IdSuffixMatches(PhysicalDeviceObject, L"VEN_10EC&DEV_8139")) // Qemu Network
   2.375 -    {
   2.376 -      hide_type = XENHIDE_TYPE_DEVICE;
   2.377 -    }
   2.378 -  }
   2.379 -
   2.380 -  if (hide_type == XENHIDE_TYPE_NONE)
   2.381 -  {
   2.382 -    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (filter not required for %S)\n", device_description));
   2.383 -    return STATUS_SUCCESS;
   2.384 -  }
   2.385 -
   2.386 -  KdPrint((__DRIVER_NAME "     Installing Filter for %S\n", device_description));
   2.387 -
   2.388 -  status = IoCreateDevice (DriverObject,
   2.389 -    sizeof(XENHIDE_DEVICE_DATA),
   2.390 -    NULL,
   2.391 -    FILE_DEVICE_UNKNOWN,
   2.392 -    FILE_DEVICE_SECURE_OPEN,
   2.393 -    FALSE,
   2.394 -    &deviceObject);
   2.395 -
   2.396 -  xhdd = (PXENHIDE_DEVICE_DATA)deviceObject->DeviceExtension;
   2.397 -
   2.398 -  xhdd->hide_type = hide_type;
   2.399 -  
   2.400 -  xhdd->lower_do = IoAttachDeviceToDeviceStack(
   2.401 -    deviceObject, PhysicalDeviceObject);
   2.402 -  deviceObject->Flags |= xhdd->lower_do->Flags;
   2.403 -
   2.404 -  deviceObject->DeviceType = xhdd->lower_do->DeviceType;
   2.405 -
   2.406 -  deviceObject->Characteristics = 
   2.407 -    xhdd->lower_do->Characteristics;
   2.408 -
   2.409 -  xhdd->filter_do = deviceObject;
   2.410 -
   2.411 -  deviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
   2.412 -
   2.413 -  FUNCTION_EXIT();
   2.414 -
   2.415 -  return STATUS_SUCCESS;
   2.416 -}
   2.417 -
   2.418 -static NTSTATUS
   2.419 -XenHide_Pass(PDEVICE_OBJECT DeviceObject, PIRP Irp)
   2.420 -{
   2.421 -  PXENHIDE_DEVICE_DATA xhdd = (PXENHIDE_DEVICE_DATA)DeviceObject->DeviceExtension;
   2.422 -  NTSTATUS status;
   2.423 -    
   2.424 -  //KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   2.425 -
   2.426 -  IoSkipCurrentIrpStackLocation(Irp);
   2.427 -  status = IoCallDriver(xhdd->lower_do, Irp);
   2.428 -
   2.429 -  //KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
   2.430 -
   2.431 -  return status;
   2.432 -}
   2.433 -
   2.434 -static NTSTATUS
   2.435 -XenHide_Pnp_IoCompletion(PDEVICE_OBJECT device_object, PIRP irp, PVOID context)
   2.436 -{
   2.437 -  PKEVENT event = (PKEVENT)context;
   2.438 -
   2.439 -  UNREFERENCED_PARAMETER(device_object);
   2.440 -
   2.441 -//  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   2.442 -
   2.443 -  if (irp->PendingReturned)
   2.444 -  {
   2.445 -    KeSetEvent(event, IO_NO_INCREMENT, FALSE);
   2.446 -  }
   2.447 -
   2.448 -//  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
   2.449 -
   2.450 -  return STATUS_MORE_PROCESSING_REQUIRED;
   2.451 -}
   2.452 -
   2.453 -static NTSTATUS
   2.454 -XenHide_QueueWorkItem(PDEVICE_OBJECT device_object, PIO_WORKITEM_ROUTINE routine, PVOID context)
   2.455 -{
   2.456 -  PIO_WORKITEM work_item;
   2.457 -  NTSTATUS status = STATUS_SUCCESS;
   2.458 -
   2.459 -  work_item = IoAllocateWorkItem(device_object);
   2.460 -  IoQueueWorkItem(work_item, routine, DelayedWorkQueue, context);
   2.461 -
   2.462 -  return status;
   2.463 -}
   2.464 -
   2.465 -static VOID
   2.466 -XenHide_Pnp_StartDeviceCallback(PDEVICE_OBJECT device_object, PVOID context)
   2.467 -{
   2.468 -  NTSTATUS status = STATUS_SUCCESS;
   2.469 -  PIRP irp = context;
   2.470 -
   2.471 -  UNREFERENCED_PARAMETER(device_object);
   2.472 -
   2.473 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   2.474 -
   2.475 -  status = STATUS_UNSUCCESSFUL;
   2.476 -  irp->IoStatus.Status = status;
   2.477 -
   2.478 -  IoCompleteRequest(irp, IO_NO_INCREMENT);
   2.479 -
   2.480 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
   2.481 -}
   2.482 -
   2.483 -static NTSTATUS
   2.484 -XenHide_SendAndWaitForIrp(PDEVICE_OBJECT device_object, PIRP irp)
   2.485 -{
   2.486 -  NTSTATUS status;
   2.487 -  PXENHIDE_DEVICE_DATA xhdd = (PXENHIDE_DEVICE_DATA)device_object->DeviceExtension;
   2.488 -  KEVENT event;
   2.489 -
   2.490 -  UNREFERENCED_PARAMETER(device_object);
   2.491 -
   2.492 -//  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   2.493 -
   2.494 -  KeInitializeEvent(&event, NotificationEvent, FALSE);
   2.495 -
   2.496 -  IoCopyCurrentIrpStackLocationToNext(irp);
   2.497 -  IoSetCompletionRoutine(irp, XenHide_Pnp_IoCompletion, &event, TRUE, TRUE, TRUE);
   2.498 -
   2.499 -  status = IoCallDriver(xhdd->lower_do, irp);
   2.500 -
   2.501 -  if (status == STATUS_PENDING)
   2.502 -  {
   2.503 -    KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
   2.504 -    status = irp->IoStatus.Status;
   2.505 -  }
   2.506 -
   2.507 -//  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
   2.508 -
   2.509 -  return status;
   2.510 -}
   2.511 -
   2.512 -XenHide_Pnp_StartDevice(PDEVICE_OBJECT device_object, PIRP irp)
   2.513 -{
   2.514 -  NTSTATUS status;
   2.515 -
   2.516 -  UNREFERENCED_PARAMETER(device_object);
   2.517 -
   2.518 -  FUNCTION_ENTER();
   2.519 -
   2.520 -  IoMarkIrpPending(irp);
   2.521 -  status = XenHide_SendAndWaitForIrp(device_object, irp);
   2.522 -  XenHide_QueueWorkItem(device_object, XenHide_Pnp_StartDeviceCallback, irp);
   2.523 -
   2.524 -  FUNCTION_EXIT();
   2.525 -
   2.526 -  return STATUS_PENDING;
   2.527 -}
   2.528 -
   2.529 -static NTSTATUS
   2.530 -XenHide_Pnp(PDEVICE_OBJECT device_object, PIRP irp)
   2.531 -{
   2.532 -  NTSTATUS status = STATUS_SUCCESS;
   2.533 -  PIO_STACK_LOCATION stack;
   2.534 -  PXENHIDE_DEVICE_DATA xhdd = (PXENHIDE_DEVICE_DATA)device_object->DeviceExtension;
   2.535 -
   2.536 -  FUNCTION_ENTER();
   2.537 -
   2.538 -  stack = IoGetCurrentIrpStackLocation(irp);
   2.539 -
   2.540 -  switch (stack->MinorFunction) {
   2.541 -  case IRP_MN_START_DEVICE:
   2.542 -    status = XenHide_Pnp_StartDevice(device_object, irp);
   2.543 -    break;
   2.544 -  case IRP_MN_REMOVE_DEVICE:
   2.545 -    //KdPrint((__DRIVER_NAME "     IRP_MN_REMOVE_DEVICE\n"));
   2.546 -    IoSkipCurrentIrpStackLocation(irp);
   2.547 -    status = IoCallDriver(xhdd->lower_do, irp);
   2.548 -    IoDetachDevice(xhdd->lower_do);
   2.549 -    IoDeleteDevice(device_object);
   2.550 -    //irp->IoStatus.Status = status;
   2.551 -    //IoCompleteRequest(irp, IO_NO_INCREMENT);
   2.552 -    break;
   2.553 -  default:
   2.554 -    //KdPrint((__DRIVER_NAME "     Unhandled Minor = %d\n", stack->MinorFunction));
   2.555 -    IoSkipCurrentIrpStackLocation(irp);
   2.556 -    status = IoCallDriver(xhdd->lower_do, irp);
   2.557 -    break;
   2.558 -  }
   2.559 -
   2.560 -  FUNCTION_EXIT();
   2.561 -
   2.562 -  return status;
   2.563 -}
   2.564 -#endif
   2.565 -
   2.566 -static VOID
   2.567 -XenHide_EvtDriverUnload(WDFDRIVER driver)
   2.568 -{
   2.569 -  UNREFERENCED_PARAMETER(driver);
   2.570 -  
   2.571 -  FUNCTION_ENTER();
   2.572 -  FUNCTION_EXIT();
   2.573 -}
   2.574 -
   2.575 -NTSTATUS
   2.576 -DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
   2.577 -{
   2.578 -  NTSTATUS status = STATUS_SUCCESS;
   2.579 -  WDF_DRIVER_CONFIG config;
   2.580 -  WDFDRIVER driver;
   2.581 -  PDRIVER_OBJECT wdm_driver;
   2.582 -
   2.583 -  FUNCTION_ENTER();
   2.584 -
   2.585 -  need_gplpv_filter = FALSE;
   2.586 -  gplpv_interrogated = FALSE;
   2.587 -  
   2.588 -  WDF_DRIVER_CONFIG_INIT(&config, XenHide_EvtDeviceAdd);
   2.589 -  config.EvtDriverUnload = XenHide_EvtDriverUnload;
   2.590 -  status = WdfDriverCreate(DriverObject, RegistryPath, WDF_NO_OBJECT_ATTRIBUTES, &config, &driver);
   2.591 -  if (NT_SUCCESS(status))
   2.592 -  {
   2.593 -    wdm_driver = WdfDriverWdmGetDriverObject(driver);
   2.594 -    ObReferenceObject(wdm_driver);
   2.595 -  }
   2.596 -  FUNCTION_EXIT();
   2.597 -
   2.598 -  return status;
   2.599 -}
     3.1 --- a/xenhide/xenhide.h	Sun May 10 20:20:09 2009 +1000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,56 +0,0 @@
     3.4 -/*PV Drivers for Windows Xen HVM Domains
     3.5 -Copyright (C) 2007 James Harper
     3.6 -
     3.7 -This program is free software; you can redistribute it and/or
     3.8 -modify it under the terms of the GNU General Public License
     3.9 -as published by the Free Software Foundation; either version 2
    3.10 -of the License, or (at your option) any later version.
    3.11 -
    3.12 -This program is distributed in the hope that it will be useful,
    3.13 -but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.14 -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    3.15 -GNU General Public License for more details.
    3.16 -
    3.17 -You should have received a copy of the GNU General Public License
    3.18 -along with this program; if not, write to the Free Software
    3.19 -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    3.20 -*/
    3.21 -
    3.22 -#if !defined(_XENHIDE_H_)
    3.23 -#define _XENHIDE_H_
    3.24 -
    3.25 -#include <ntifs.h>
    3.26 -#include <ntddk.h>
    3.27 -#include <wdf.h>
    3.28 -#include <initguid.h>
    3.29 -#include <wdmguid.h>
    3.30 -#include <errno.h>
    3.31 -
    3.32 -#define NTSTRSAFE_LIB
    3.33 -#include <ntstrsafe.h>
    3.34 -
    3.35 -#define __DRIVER_NAME "XenHide"
    3.36 -
    3.37 -#include <xen_windows.h>
    3.38 -#include <xen_guids.h>
    3.39 -
    3.40 -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
    3.41 -
    3.42 -#define XENHIDE_POOL_TAG (ULONG) 'XHID'
    3.43 -
    3.44 -//{CD433FE7-954F-4D51-BE29-D8A38DFA1108}
    3.45 -//DEFINE_GUID(GUID_XENHIDE_IFACE, 0xCD433FE7, 0x954F, 0x4D51, 0xBE, 0x29, 0xD8, 0xA3, 0x8D, 0xFA, 0x11, 0x08);
    3.46 -
    3.47 -#if 0
    3.48 -typedef struct {
    3.49 -  //PDEVICE_OBJECT filter_do;
    3.50 -  //PDEVICE_OBJECT pdo;
    3.51 -  //PDEVICE_OBJECT lower_do;
    3.52 -  //IO_REMOVE_LOCK RemoveLock;
    3.53 -  USHORT hide_type;
    3.54 -} XENHIDE_DEVICE_DATA, *PXENHIDE_DEVICE_DATA;
    3.55 -
    3.56 -WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(XENHIDE_DEVICE_DATA, GetXhdd)
    3.57 -#endif
    3.58 -
    3.59 -#endif