mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2024-11-21 16:46:54 -08:00
81 lines
2.5 KiB
Diff
81 lines
2.5 KiB
Diff
From 2399eb182bc12b6643953d9182c1c89ba42fcce3 Mon Sep 17 00:00:00 2001
|
|
From: "Olivier F. R. Dierick" <o.dierick@piezo-forte.be>
|
|
Date: Tue, 19 Apr 2016 07:25:39 +0200
|
|
Subject: [PATCH] kernel32: Implement SetProcessDEPPolicy().
|
|
|
|
---
|
|
dlls/kernel32/process.c | 36 +++++++++++++++++++++++++++++++++---
|
|
1 file changed, 33 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c
|
|
index e5e51a93d..e582c6d5b 100644
|
|
--- a/dlls/kernel32/process.c
|
|
+++ b/dlls/kernel32/process.c
|
|
@@ -70,6 +70,8 @@ typedef struct
|
|
DWORD dwReserved;
|
|
} LOADPARMS32;
|
|
|
|
+static BOOL is_wow64;
|
|
+
|
|
HMODULE kernel32_handle = 0;
|
|
SYSTEM_BASIC_INFORMATION system_info = { 0 };
|
|
|
|
@@ -85,6 +87,7 @@ const WCHAR DIR_System[] = {'C',':','\\','w','i','n','d','o','w','s',
|
|
#define PDB32_FILE_APIS_OEM 0x0040 /* File APIs are OEM */
|
|
#define PDB32_WIN32S_PROC 0x8000 /* Win32s process */
|
|
|
|
+static DEP_SYSTEM_POLICY_TYPE system_DEP_policy = OptIn;
|
|
|
|
#ifdef __i386__
|
|
extern DWORD call_process_entry( PEB *peb, LPTHREAD_START_ROUTINE entry );
|
|
@@ -171,6 +174,7 @@ void * CDECL __wine_kernel_init(void)
|
|
static const WCHAR kernel32W[] = {'k','e','r','n','e','l','3','2',0};
|
|
|
|
kernel32_handle = GetModuleHandleW(kernel32W);
|
|
+ IsWow64Process( GetCurrentProcess(), &is_wow64 );
|
|
RtlSetUnhandledExceptionFilter( UnhandledExceptionFilter );
|
|
|
|
return start_process_wrapper;
|
|
@@ -871,9 +875,35 @@ DEP_SYSTEM_POLICY_TYPE WINAPI GetSystemDEPPolicy(void)
|
|
*/
|
|
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);
|
|
+
|
|
+ if (is_wow64 || (system_DEP_policy != OptIn && system_DEP_policy != OptOut) )
|
|
+ {
|
|
+ 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;
|
|
}
|
|
|
|
/**********************************************************************
|
|
--
|
|
2.24.0
|
|
|