win-pvdrivers

changeset 213:9ae143ae1f91

Non-ACPI-based HALs report PCI root bridges like this: "PCI_HAL\PNP0A03", so change test to catch all strings ending in "PNP0A03".
Reduce stack usage a bit by making some buffers smaller
author Andy Grover <andy.grover@oracle.com>
date Wed Mar 19 16:34:54 2008 -0700 (2008-03-19)
parents 6f57a4124ab7
children b400fd002071
files xenhide/xenhide.c
line diff
     1.1 --- a/xenhide/xenhide.c	Sat Mar 15 00:44:03 2008 +1100
     1.2 +++ b/xenhide/xenhide.c	Wed Mar 19 16:34:54 2008 -0700
     1.3 @@ -159,28 +159,29 @@ XenHide_AddDevice(
     1.4    PDEVICE_OBJECT deviceObject = NULL;
     1.5    PDEVICE_EXTENSION DeviceExtension;
     1.6    ULONG Length;
     1.7 -  WCHAR Buffer[1000];
     1.8 +  WCHAR Buffer[256];
     1.9    size_t StrLen;
    1.10    int Match;
    1.11    PWCHAR Ptr;
    1.12  
    1.13  //  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    1.14  
    1.15 -  Length = 1000;
    1.16 +  Length = sizeof(Buffer);
    1.17    status = IoGetDeviceProperty(PhysicalDeviceObject, DevicePropertyHardwareID, Length, Buffer, &Length);
    1.18  //  KdPrint((__DRIVER_NAME " status = %08x, DevicePropertyHardwareID, = %ws\n", status, Buffer));
    1.19    if (!NT_SUCCESS(status))
    1.20      return STATUS_SUCCESS;
    1.21  
    1.22 +  /* does end of HwID match PNP0A03? */
    1.23    Match = 0;
    1.24 -  StrLen = 0;
    1.25 -  for (Ptr = Buffer; *Ptr != 0; Ptr += StrLen + 1)
    1.26 +  RtlStringCchLengthW(Buffer, Length/2, &StrLen); // get strlen in wchars
    1.27 +  if (StrLen >= 7)
    1.28    {
    1.29 -    if (wcscmp(Ptr, L"*PNP0A03") == 0) {
    1.30 +    Ptr = Buffer + (StrLen - 7);
    1.31 +    if (wcscmp(Ptr, L"PNP0A03") == 0)
    1.32 +    {
    1.33        Match = 1;
    1.34 -      break;
    1.35      }
    1.36 -    RtlStringCchLengthW(Ptr, Length, &StrLen);
    1.37    }
    1.38    if (!Match)
    1.39      return STATUS_SUCCESS;
    1.40 @@ -251,7 +252,7 @@ XenHide_IoCompletion(PDEVICE_OBJECT Devi
    1.41  {
    1.42    ULONG i, j;
    1.43    PDEVICE_RELATIONS Relations;
    1.44 -  WCHAR Buffer[1000];
    1.45 +  WCHAR Buffer[256];
    1.46    PWCHAR Ptr;
    1.47    ULONG Length;
    1.48    size_t StrLen;