2019-08-09 17:54:43 -07:00
|
|
|
From d14d9f0265a8adb9bbcb6eb3b0e76b6c88655218 Mon Sep 17 00:00:00 2001
|
2019-06-30 15:19:00 -07:00
|
|
|
From: "Olivier F. R. Dierick" <o.dierick@piezo-forte.be>
|
|
|
|
Date: Tue, 19 Apr 2016 07:25:39 +0200
|
2019-08-09 17:54:43 -07:00
|
|
|
Subject: [PATCH] kernel32: Implement SetProcessDEPPolicy().
|
2019-06-30 15:19:00 -07:00
|
|
|
|
|
|
|
---
|
|
|
|
dlls/kernel32/process.c | 34 +++++++++++++++++++++++++++++++---
|
|
|
|
1 file changed, 31 insertions(+), 3 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c
|
2019-08-09 17:54:43 -07:00
|
|
|
index 992437047..e10bfd95a 100644
|
2019-06-30 15:19:00 -07:00
|
|
|
--- a/dlls/kernel32/process.c
|
|
|
|
+++ b/dlls/kernel32/process.c
|
|
|
|
@@ -114,6 +114,8 @@ static WCHAR winevdm[] = {'C',':','\\','w','i','n','d','o','w','s',
|
|
|
|
|
|
|
|
static const char * const cpu_names[] = { "x86", "x86_64", "PowerPC", "ARM", "ARM64" };
|
|
|
|
|
|
|
|
+static DEP_SYSTEM_POLICY_TYPE system_DEP_policy = OptIn;
|
|
|
|
+
|
|
|
|
static void exec_process( LPCWSTR name );
|
|
|
|
|
2019-08-09 17:54:43 -07:00
|
|
|
/* return values for get_binary_info */
|
|
|
|
@@ -3919,9 +3921,35 @@ DEP_SYSTEM_POLICY_TYPE WINAPI GetSystemDEPPolicy(void)
|
2019-06-30 15:19:00 -07:00
|
|
|
*/
|
|
|
|
BOOL WINAPI SetProcessDEPPolicy(DWORD newDEP)
|
|
|
|
{
|
|
|
|
- FIXME("(%d): stub\n", newDEP);
|
|
|
|
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
- return FALSE;
|
|
|
|
+ ULONG dep_flags = 0;
|
|
|
|
+ NTSTATUS status;
|
|
|
|
+
|
|
|
|
+ TRACE("(%d)\n", newDEP);
|
|
|
|
+
|
2019-08-18 17:09:36 -07:00
|
|
|
+ if (is_wow64 || (system_DEP_policy != OptIn && system_DEP_policy != OptOut) )
|
2019-06-30 15:19:00 -07:00
|
|
|
+ {
|
|
|
|
+ SetLastError(ERROR_ACCESS_DENIED);
|
|
|
|
+ return FALSE;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!newDEP)
|
|
|
|
+ dep_flags = MEM_EXECUTE_OPTION_ENABLE;
|
|
|
|
+ else if (newDEP & PROCESS_DEP_ENABLE)
|
|
|
|
+ dep_flags = MEM_EXECUTE_OPTION_DISABLE|MEM_EXECUTE_OPTION_PERMANENT;
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ SetLastError(ERROR_ACCESS_DENIED);
|
|
|
|
+ return FALSE;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (newDEP & PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION)
|
|
|
|
+ dep_flags |= MEM_EXECUTE_OPTION_DISABLE_THUNK_EMULATION;
|
|
|
|
+
|
|
|
|
+ status = NtSetInformationProcess( GetCurrentProcess(), ProcessExecuteFlags,
|
|
|
|
+ &dep_flags, sizeof(dep_flags) );
|
|
|
|
+
|
|
|
|
+ if (status) SetLastError( RtlNtStatusToDosError(status) );
|
|
|
|
+ return !status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
--
|
2019-08-09 17:54:43 -07:00
|
|
|
2.22.0
|
2019-06-30 15:19:00 -07:00
|
|
|
|