win-pvdrivers

changeset 200:b29b0e8d9126

Made the detection of PCI Bus language independant.
author James Harper <james.harper@bendigoit.com.au>
date Thu Feb 28 17:45:08 2008 +1100 (2008-02-28)
parents 99985a5aa1dc
children 63780c11acbe
files common.inc xenhide/xenhide.c
line diff
     1.1 --- a/common.inc	Thu Feb 28 09:44:14 2008 +1100
     1.2 +++ b/common.inc	Thu Feb 28 17:45:08 2008 +1100
     1.3 @@ -1,4 +1,4 @@
     1.4 -VERSION=0.8.4.3
     1.5 +VERSION=0.8.4.8
     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	Thu Feb 28 09:44:14 2008 +1100
     2.2 +++ b/xenhide/xenhide.c	Thu Feb 28 17:45:08 2008 +1100
     2.3 @@ -160,20 +160,32 @@ XenHide_AddDevice(
     2.4    PDEVICE_EXTENSION DeviceExtension;
     2.5    ULONG Length;
     2.6    WCHAR Buffer[1000];
     2.7 +  size_t StrLen;
     2.8 +  int Match;
     2.9 +  PWCHAR Ptr;
    2.10  
    2.11  //  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    2.12  
    2.13    Length = 1000;
    2.14 -  status = IoGetDeviceProperty(PhysicalDeviceObject, DevicePropertyDeviceDescription, Length, Buffer, &Length);
    2.15 -//  KdPrint((__DRIVER_NAME " status = %08x, DevicePropertyDeviceDescription = %ws\n", status, Buffer));
    2.16 +  status = IoGetDeviceProperty(PhysicalDeviceObject, DevicePropertyHardwareID, Length, Buffer, &Length);
    2.17 +//  KdPrint((__DRIVER_NAME " status = %08x, DevicePropertyHardwareID, = %ws\n", status, Buffer));
    2.18 +  if (!NT_SUCCESS(status))
    2.19 +    return STATUS_SUCCESS;
    2.20  
    2.21 -  if (!NT_SUCCESS(status) || wcscmp(Buffer, L"PCI bus") != 0)
    2.22 +  Match = 0;
    2.23 +  StrLen = 0;
    2.24 +  for (Ptr = Buffer; *Ptr != 0; Ptr += StrLen + 1)
    2.25    {
    2.26 -//    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    2.27 +    if (wcscmp(Ptr, L"*PNP0A03") == 0) {
    2.28 +      Match = 1;
    2.29 +      break;
    2.30 +    }
    2.31 +    RtlStringCchLengthW(Ptr, Length, &StrLen);
    2.32 +  }
    2.33 +  if (!Match)
    2.34      return STATUS_SUCCESS;
    2.35 -  }
    2.36  
    2.37 -//  KdPrint((__DRIVER_NAME " Found\n")); 
    2.38 +  KdPrint((__DRIVER_NAME " Found\n")); 
    2.39  
    2.40    status = IoCreateDevice (DriverObject,
    2.41      sizeof(DEVICE_EXTENSION),
    2.42 @@ -262,46 +274,48 @@ XenHide_IoCompletion(PDEVICE_OBJECT Devi
    2.43      break;
    2.44    case 1:
    2.45      DeviceExtension->InternalState = 2; 
    2.46 -    for (i = 0; i < Relations->Count; i++)
    2.47 +    if (Relations != NULL)
    2.48      {
    2.49 -      if (Offset != 0)
    2.50 -        Relations->Objects[i - Offset] = Relations->Objects[i];
    2.51 -  
    2.52 -      Match = 0;
    2.53 -      for (j = 0; j < 2 && !Match; j++)
    2.54 +      for (i = 0; i < Relations->Count; i++)
    2.55        {
    2.56 -        Length = sizeof(Buffer);
    2.57 -        if (j == 0)
    2.58 -          IoGetDeviceProperty(Relations->Objects[i - Offset], DevicePropertyCompatibleIDs, Length, Buffer, &Length);
    2.59 -        else
    2.60 -          IoGetDeviceProperty(Relations->Objects[i - Offset], DevicePropertyHardwareID, Length, Buffer, &Length);
    2.61 -         StrLen = 0;
    2.62 -        for (Ptr = Buffer; *Ptr != 0; Ptr += StrLen + 1)
    2.63 +        if (Offset != 0)
    2.64 +          Relations->Objects[i - Offset] = Relations->Objects[i];
    2.65 +    
    2.66 +        Match = 0;
    2.67 +        for (j = 0; j < 2 && !Match; j++)
    2.68          {
    2.69 -          // Qemu PCI
    2.70 -          if (XenHide_StringMatches(Ptr, L"PCI\\VEN_8086&DEV_7010")) {
    2.71 -            Match = 1;
    2.72 -            break;
    2.73 +          Length = sizeof(Buffer);
    2.74 +          if (j == 0)
    2.75 +            IoGetDeviceProperty(Relations->Objects[i - Offset], DevicePropertyCompatibleIDs, Length, Buffer, &Length);
    2.76 +          else
    2.77 +            IoGetDeviceProperty(Relations->Objects[i - Offset], DevicePropertyHardwareID, Length, Buffer, &Length);
    2.78 +           StrLen = 0;
    2.79 +          for (Ptr = Buffer; *Ptr != 0; Ptr += StrLen + 1)
    2.80 +          {
    2.81 +            // Qemu PCI
    2.82 +            if (XenHide_StringMatches(Ptr, L"PCI\\VEN_8086&DEV_7010")) {
    2.83 +              Match = 1;
    2.84 +              break;
    2.85 +            }
    2.86 +            // Qemu Network
    2.87 +            if (XenHide_StringMatches(Ptr, L"PCI\\VEN_10EC&DEV_8139")) {
    2.88 +              Match = 1;
    2.89 +              break;
    2.90 +            }
    2.91 +            RtlStringCchLengthW(Ptr, Length, &StrLen);
    2.92            }
    2.93 -          // Qemu Network
    2.94 -          if (XenHide_StringMatches(Ptr, L"PCI\\VEN_10EC&DEV_8139")) {
    2.95 -            Match = 1;
    2.96 -            break;
    2.97 -          }
    2.98 -          RtlStringCchLengthW(Ptr, Length, &StrLen);
    2.99 +        }
   2.100 +        if (Match)
   2.101 +        {
   2.102 +          Offset++;
   2.103          }
   2.104        }
   2.105 -      if (Match)
   2.106 -      {
   2.107 -        Offset++;
   2.108 -      }
   2.109 +      Relations->Count -= Offset;
   2.110 +      break;
   2.111 +    default:
   2.112 +      break;
   2.113      }
   2.114 -    Relations->Count -= Offset;
   2.115 -    break;
   2.116 -  default:
   2.117 -    break;
   2.118 -  }
   2.119 -    
   2.120 +  }    
   2.121  //  KdPrint((__DRIVER_NAME " <-- IoCompletion\n"));
   2.122  
   2.123    return Irp->IoStatus.Status;