advapi32: Add a manifest to prevent registry virtualization.

Vincent Povirk madewokherd at gmail.com
Thu Nov 19 16:21:52 CST 2015


I promise I'm not just making up excuses to add manifests, this is a
real thing, see
https://msdn.microsoft.com/en-us/library/windows/desktop/aa965884.aspx

The failure I get on Windows 8 is "RegDeleteValueA failed: 5", in
test_machine_guid, and it only happens the first time I run the test
as a given limited user. It doesn't seem to happen on Windows 10, my
guess is they improved registry virtualization so that it presents a
more consistent view of things.

The reason for this failure is that RegOpenKeyExA APPEARS to succeed,
due to registry virtualization, even though the user doesn't have the
required permissions for the Cryptography key. Any new or modified
values will go to a user-specific space in HKEY_USERS\<User
SID>_Classes\VirtualStore\Software, which is an overlay over the real
HKLM\Software.

However, we're trying to delete an existing value, MachineGuid.
Because the virtual store is only an overlay, we're accessing the real
MachineGuid value, which we don't have permission to delete, hence the
access denied error.

After this, we "restore" MachineGuid using RegSetValueExA, which goes
into our virtual store.

Further runs will "successfully" delete the MachineGuid value that the
previous run added to the virtual store, but really the value still
exists (and our test program would see the real value, if we tried to
read it after deleting the virtual one).

The failure can be seen again for the same user by finding the
Cryptography key in VirtualStore and deleting it. Even when it doesn't
fail, you can see that we don't skip this test when running as a
limited user, which makes no sense.

While we could modify our test to detect this seemingly impossible
situation, I think it's better to just prevent registry
virtualization. (Then again, if we ever want to write tests for
registry virtualization, they should probably go in advapi32, so maybe
editing the test is better.)
-------------- next part --------------
From 66ca7a36a67195b8effc42277c4e3a0bef35af31 Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent at codeweavers.com>
Date: Thu, 19 Nov 2015 15:47:07 -0600
Subject: [PATCH] advapi32: Add a manifest to prevent registry virtualization.

Registry virtualization causes problems for test_machine_guid on 32-bit
Windows 8 as a limited user, the first time the test is run by that user.

Signed-off-by: Vincent Povirk <vincent at codeweavers.com>
---
 dlls/advapi32/tests/Makefile.in       |  2 ++
 dlls/advapi32/tests/advapi32.manifest | 11 +++++++++++
 dlls/advapi32/tests/advapi32.rc       | 25 +++++++++++++++++++++++++
 3 files changed, 38 insertions(+)
 create mode 100644 dlls/advapi32/tests/advapi32.manifest
 create mode 100644 dlls/advapi32/tests/advapi32.rc

diff --git a/dlls/advapi32/tests/Makefile.in b/dlls/advapi32/tests/Makefile.in
index 36ce031..b8a979c 100644
--- a/dlls/advapi32/tests/Makefile.in
+++ b/dlls/advapi32/tests/Makefile.in
@@ -13,3 +13,5 @@ C_SRCS = \
 	registry.c \
 	security.c \
 	service.c
+
+RC_SRCS = advapi32.rc
diff --git a/dlls/advapi32/tests/advapi32.manifest b/dlls/advapi32/tests/advapi32.manifest
new file mode 100644
index 0000000..2d936b1
--- /dev/null
+++ b/dlls/advapi32/tests/advapi32.manifest
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
+    <assemblyIdentity type="win32" name="Wine.Advapi32Test" version="0.0.0.0"/>
+    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
+        <security>
+            <requestedPrivileges>
+                <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
+            </requestedPrivileges>
+        </security>
+    </trustInfo>
+</assembly>
diff --git a/dlls/advapi32/tests/advapi32.rc b/dlls/advapi32/tests/advapi32.rc
new file mode 100644
index 0000000..c0a7a73
--- /dev/null
+++ b/dlls/advapi32/tests/advapi32.rc
@@ -0,0 +1,25 @@
+/*
+ * advapi32 test resources
+ *
+ * Copyright 2015 Vincent Povirk
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ *
+ */
+
+#include <winuser.rh>
+
+/* @makedep: advapi32.manifest */
+1 RT_MANIFEST advapi32.manifest
-- 
2.5.0



More information about the wine-patches mailing list