[PATCH] ntdll/tests: Handle case where process doesn't have its own DEP policy

Alex Henrie alexhenrie24 at gmail.com
Wed Sep 12 01:31:54 CDT 2018


If neither MEM_EXECUTE_OPTION_ENABLE nor MEM_EXECUTE_OPTION_DISABLE is
set in the ProcessExecuteFlags, the process is using the system DEP
setting.

Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
This should fix the test crashes on Windows Server 2008.
---
 dlls/ntdll/tests/info.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c
index 2ab12e4257..e7b07e57af 100644
--- a/dlls/ntdll/tests/info.c
+++ b/dlls/ntdll/tests/info.c
@@ -38,6 +38,7 @@ static NTSTATUS (WINAPI * pNtClose)(HANDLE);
 static ULONG    (WINAPI * pNtGetCurrentProcessorNumber)(void);
 static BOOL     (WINAPI * pIsWow64Process)(HANDLE, PBOOL);
 static BOOL     (WINAPI * pGetLogicalProcessorInformationEx)(LOGICAL_PROCESSOR_RELATIONSHIP,SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*,DWORD*);
+static DEP_SYSTEM_POLICY_TYPE (WINAPI * pGetSystemDEPPolicy)(void);
 
 static BOOL is_wow64;
 
@@ -96,6 +97,8 @@ static BOOL InitFunctionPtrs(void)
     pIsWow64Process = (void *)GetProcAddress(hkernel32, "IsWow64Process");
     if (!pIsWow64Process || !pIsWow64Process( GetCurrentProcess(), &is_wow64 )) is_wow64 = FALSE;
 
+    pGetSystemDEPPolicy = (void *)GetProcAddress(hkernel32, "GetSystemDEPPolicy");
+
     /* starting with Win7 */
     pNtQuerySystemInformationEx = (void *) GetProcAddress(hntdll, "NtQuerySystemInformationEx");
     if (!pNtQuerySystemInformationEx)
@@ -1851,7 +1854,7 @@ static void test_mapprotection(void)
     ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status );
     trace("Process execute flags %08x\n", oldflags);
 
-    if (oldflags & MEM_EXECUTE_OPTION_DISABLE)
+    if (!(oldflags & MEM_EXECUTE_OPTION_ENABLE))
     {
         if (oldflags & MEM_EXECUTE_OPTION_PERMANENT)
         {
@@ -1859,6 +1862,12 @@ static void test_mapprotection(void)
             return;
         }
 
+        if (pGetSystemDEPPolicy && pGetSystemDEPPolicy() == AlwaysOn)
+        {
+            skip("System policy requires noexec\n");
+            return;
+        }
+
         status = pNtSetInformationProcess( GetCurrentProcess(), ProcessExecuteFlags, &flags, sizeof(flags) );
         ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status );
         reset_flags = TRUE;
-- 
2.19.0




More information about the wine-devel mailing list