]> xenbits.xensource.com Git - people/pauldu/xenbus.git/commitdiff
[SCTX-1104] Add WindowsPEMode to xenfilt
authorBen Chalmers <Ben.Chalmers@citrix.com>
Fri, 25 Apr 2014 14:15:27 +0000 (15:15 +0100)
committerBen Chalmers <Ben.Chalmers@citrix.com>
Mon, 28 Apr 2014 14:19:11 +0000 (15:19 +0100)
ParentIdPrefixes are not avilable at Windows PE driver filtering time,
but we don't actually need them if we know emulated devices will be
unplugged, so, if ParentIdPrefix can't be read from the registry and
HKLM\System\CurrentControlSet\Services\xenfilt\WindowsPEMode is set to 1
then just set the prefix to be an empty string and continue

We never set WindowsPEMode anywhere except in the sample Windows PE
scripts, so non-WindowsPE environments are unaffected

Signed-off-by: Ben Chalmers <Ben.Chalmers@citrix.com>
src/xenfilt/fdo.c

index e7dd9fd5c293255323ccf97134c940bd8214712b..8aa40d27103b64c46e5395cedf38a61297a0dec0 100644 (file)
@@ -232,6 +232,51 @@ __FdoGetPhysicalDeviceObject(
     return Fdo->PhysicalDeviceObject;
 }
 
+
+static FORCEINLINE NTSTATUS
+__FdoSetWindowsPEPrefix(
+    IN  PXENFILT_FDO    Fdo
+    )
+{
+    HANDLE                  ServiceKey;
+    DWORD                   WindowsPEMode;
+    NTSTATUS                status;
+
+    status = RegistryOpenServiceKey(KEY_READ,
+                                    &ServiceKey);
+    if (!NT_SUCCESS(status))
+        goto fail1;
+
+    status = RegistryQueryDwordValue(ServiceKey,
+                                     "WindowsPEMode",
+                                     &WindowsPEMode);
+    if (!NT_SUCCESS(status))
+        goto fail2;
+
+    status = STATUS_UNSUCCESSFUL;
+
+    if (!WindowsPEMode)
+        goto fail3;
+
+    Fdo->Prefix[0]=0;
+    
+    RegistryCloseKey(ServiceKey);
+
+    return STATUS_SUCCESS;
+
+fail3:
+    Error("fail3\n");
+
+fail2:
+    Error("fail2\n");
+    RegistryCloseKey(ServiceKey);
+
+fail1:
+    Error("fail1\n");
+
+    return status;
+}
+
 static FORCEINLINE NTSTATUS
 __FdoSetPrefix(
     IN  PXENFILT_FDO        Fdo
@@ -1981,6 +2026,8 @@ FdoCreate(
     __FdoSetName(Fdo, Name);
 
     status = __FdoSetPrefix(Fdo);
+    if (!NT_SUCCESS(status))
+        status = __FdoSetWindowsPEPrefix(Fdo);
     if (!NT_SUCCESS(status))
         goto fail6;