2019-12-04 14:32:37 -08:00
|
|
|
From 63db3d2aef606a1c197dac103510479391044f84 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
|
|
|
|
|
|
|
---
|
2019-11-12 17:56:51 -08:00
|
|
|
dlls/kernel32/process.c | 36 +++++++++++++++++++++++++++++++++---
|
|
|
|
1 file changed, 33 insertions(+), 3 deletions(-)
|
2019-06-30 15:19:00 -07:00
|
|
|
|
|
|
|
diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c
|
2019-12-04 14:32:37 -08:00
|
|
|
index 4ec6ebc415b..70c5b33f14c 100644
|
2019-06-30 15:19:00 -07:00
|
|
|
--- a/dlls/kernel32/process.c
|
|
|
|
+++ b/dlls/kernel32/process.c
|
2019-12-04 14:32:37 -08:00
|
|
|
@@ -71,6 +71,8 @@ typedef struct
|
2019-11-12 17:56:51 -08:00
|
|
|
DWORD dwReserved;
|
|
|
|
} LOADPARMS32;
|
2019-06-30 15:19:00 -07:00
|
|
|
|
2019-11-12 17:56:51 -08:00
|
|
|
+static BOOL is_wow64;
|
|
|
|
+
|
|
|
|
HMODULE kernel32_handle = 0;
|
|
|
|
SYSTEM_BASIC_INFORMATION system_info = { 0 };
|
|
|
|
|
2019-12-04 14:32:37 -08:00
|
|
|
@@ -86,6 +88,7 @@ const WCHAR DIR_System[] = {'C',':','\\','w','i','n','d','o','w','s',
|
2019-11-12 17:56:51 -08:00
|
|
|
#define PDB32_FILE_APIS_OEM 0x0040 /* File APIs are OEM */
|
|
|
|
#define PDB32_WIN32S_PROC 0x8000 /* Win32s process */
|
2019-06-30 15:19:00 -07:00
|
|
|
|
|
|
|
+static DEP_SYSTEM_POLICY_TYPE system_DEP_policy = OptIn;
|
2019-11-12 17:56:51 -08:00
|
|
|
|
2019-12-04 14:32:37 -08:00
|
|
|
#ifdef __i386__
|
|
|
|
extern DWORD call_process_entry( PEB *peb, LPTHREAD_START_ROUTINE entry );
|
|
|
|
@@ -188,6 +191,7 @@ void * CDECL __wine_kernel_init(void)
|
|
|
|
static const WCHAR kernel32W[] = {'k','e','r','n','e','l','3','2',0};
|
|
|
|
|
2019-11-12 17:56:51 -08:00
|
|
|
kernel32_handle = GetModuleHandleW(kernel32W);
|
|
|
|
+ IsWow64Process( GetCurrentProcess(), &is_wow64 );
|
|
|
|
RtlSetUnhandledExceptionFilter( UnhandledExceptionFilter );
|
|
|
|
|
|
|
|
LOCALE_Init();
|
2019-12-04 14:32:37 -08:00
|
|
|
@@ -890,9 +894,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-12-04 14:32:37 -08:00
|
|
|
2.17.1
|
2019-06-30 15:19:00 -07:00
|
|
|
|