win-pvdrivers

changeset 793:eddfbeb4689f

Add a 'always hide' option so that qemu devices can be hidden in text mode setup where filters don't work.
author James Harper <james.harper@bendigoit.com.au>
date Tue Mar 23 21:26:00 2010 +1100 (2010-03-23)
parents 2a5c4cc78d9d
children aee3767c191d
files xenpci/xenpci.c
line diff
     1.1 --- a/xenpci/xenpci.c	Fri Mar 12 11:13:58 2010 +1100
     1.2 +++ b/xenpci/xenpci.c	Tue Mar 23 21:26:00 2010 +1100
     1.3 @@ -555,6 +555,7 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
     1.4    char Buf[300];// Sometimes bigger then 200 if system reboot from crash
     1.5    ULONG BufLen = 300;
     1.6    PKEY_VALUE_PARTIAL_INFORMATION KeyPartialValue;
     1.7 +  WDFKEY param_key;
     1.8    
     1.9    UNREFERENCED_PARAMETER(RegistryPath);
    1.10  
    1.11 @@ -642,21 +643,25 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
    1.12    if (wcsstr(SystemStartOptions, L"NOGPLPV"))
    1.13      KdPrint((__DRIVER_NAME "     NOGPLPV found\n"));
    1.14    conf_info = IoGetConfigurationInformation();
    1.15 -  if ((conf_info == NULL || conf_info->DiskCount == 0)
    1.16 -      && !wcsstr(SystemStartOptions, L"NOGPLPV")
    1.17 -      && !*InitSafeBootMode)
    1.18 +  
    1.19 +  status = WdfDriverOpenParametersRegistryKey(driver, KEY_QUERY_VALUE, WDF_NO_OBJECT_ATTRIBUTES, &param_key);
    1.20 +  if (NT_SUCCESS(status))
    1.21    {
    1.22 -    if (wcsstr(SystemStartOptions, L"GPLPVUSEFILTERHIDE") == 0 && XenPci_CheckHideQemuDevices())
    1.23 +    ULONG always_hide = 0;
    1.24 +    DECLARE_CONST_UNICODE_STRING(always_hide_name, L"hide_qemu_always");
    1.25 +    
    1.26 +    WdfRegistryQueryULong(param_key, &always_hide_name, &always_hide);
    1.27 +    if (always_hide || ((conf_info == NULL || conf_info->DiskCount == 0)
    1.28 +        && !wcsstr(SystemStartOptions, L"NOGPLPV")
    1.29 +        && !*InitSafeBootMode))
    1.30      {
    1.31 -      DECLARE_CONST_UNICODE_STRING(qemu_hide_flags_name, L"qemu_hide_flags");
    1.32 -      WDFCOLLECTION qemu_hide_flags;
    1.33 -      WDFKEY param_key;
    1.34 -      ULONG i;
    1.35 -      
    1.36 -      WdfCollectionCreate(WDF_NO_OBJECT_ATTRIBUTES, &qemu_hide_flags);
    1.37 -      status = WdfDriverOpenParametersRegistryKey(driver, KEY_QUERY_VALUE, WDF_NO_OBJECT_ATTRIBUTES, &param_key);
    1.38 -      if (NT_SUCCESS(status))
    1.39 +      if (wcsstr(SystemStartOptions, L"GPLPVUSEFILTERHIDE") == 0 && XenPci_CheckHideQemuDevices())
    1.40        {
    1.41 +        DECLARE_CONST_UNICODE_STRING(qemu_hide_flags_name, L"qemu_hide_flags");
    1.42 +        WDFCOLLECTION qemu_hide_flags;
    1.43 +        ULONG i;
    1.44 +        
    1.45 +        WdfCollectionCreate(WDF_NO_OBJECT_ATTRIBUTES, &qemu_hide_flags);
    1.46          status = WdfRegistryQueryMultiString(param_key, &qemu_hide_flags_name, WDF_NO_OBJECT_ATTRIBUTES, qemu_hide_flags);
    1.47          if (!NT_SUCCESS(status))
    1.48          {
    1.49 @@ -675,33 +680,23 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
    1.50              qemu_hide_flags_value |= value;
    1.51            }
    1.52          }
    1.53 -        WdfRegistryClose(param_key);
    1.54 +        XenPci_HideQemuDevices();
    1.55        }
    1.56        else
    1.57        {
    1.58 -        KdPrint(("Error opening parameters key %08x\n", status));
    1.59 -      }
    1.60 -      XenPci_HideQemuDevices();
    1.61 -    }
    1.62 -    else
    1.63 -    {
    1.64 -      DECLARE_CONST_UNICODE_STRING(hide_devices_name, L"hide_devices");
    1.65 -      WDFKEY param_key;
    1.66 -      status = WdfDriverOpenParametersRegistryKey(driver, KEY_QUERY_VALUE, WDF_NO_OBJECT_ATTRIBUTES, &param_key);
    1.67 -      if (NT_SUCCESS(status))
    1.68 -      {
    1.69 +        DECLARE_CONST_UNICODE_STRING(hide_devices_name, L"hide_devices");
    1.70          status = WdfRegistryQueryMultiString(param_key, &hide_devices_name, WDF_NO_OBJECT_ATTRIBUTES, qemu_hide_devices);
    1.71          if (!NT_SUCCESS(status))
    1.72          {
    1.73            KdPrint(("Error reading parameters/hide_devices value %08x\n", status));
    1.74          }
    1.75 -        WdfRegistryClose(param_key);
    1.76 -      }
    1.77 -      else
    1.78 -      {
    1.79 -        KdPrint(("Error opening parameters key %08x\n", status));
    1.80        }
    1.81      }
    1.82 +    WdfRegistryClose(param_key);
    1.83 +  }
    1.84 +  else
    1.85 +  {
    1.86 +    KdPrint(("Error opening parameters key %08x\n", status));
    1.87    }
    1.88  
    1.89    FUNCTION_EXIT();