mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2025-01-28 22:04:43 -08:00
Added kernel32-SetProcessDEPPolicy patchset
This commit is contained in:
parent
dff74f4169
commit
507cb29933
@ -0,0 +1,64 @@
|
||||
From 71cb9b2d7c41098881516a2b8f5db2f17f84dca6 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 1/3] kernel32: Implement SetProcessDEPPolicy().
|
||||
|
||||
---
|
||||
dlls/kernel32/process.c | 34 +++++++++++++++++++++++++++++++---
|
||||
1 file changed, 31 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c
|
||||
index 0d0de93eee..7a89207388 100644
|
||||
--- 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 );
|
||||
|
||||
extern void SHELL_LoadRegistry(void);
|
||||
@@ -4376,9 +4378,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.17.1
|
||||
|
@ -0,0 +1,100 @@
|
||||
From 9e92b5b796193d5de1c342576df7ecc07bc09c7d Mon Sep 17 00:00:00 2001
|
||||
From: "Olivier F. R. Dierick" <o.dierick@piezo-forte.be>
|
||||
Date: Tue, 19 Apr 2016 07:33:32 +0200
|
||||
Subject: [PATCH 2/3] kernel32: Implement GetSystemDEPPolicy().
|
||||
|
||||
---
|
||||
dlls/kernel32/process.c | 70 +++++++++++++++++++++++++++++++++++++++--
|
||||
1 file changed, 68 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c
|
||||
index 7a89207388..6bf31516ca 100644
|
||||
--- a/dlls/kernel32/process.c
|
||||
+++ b/dlls/kernel32/process.c
|
||||
@@ -56,6 +56,7 @@
|
||||
#define WIN32_NO_STATUS
|
||||
#include "winternl.h"
|
||||
#include "kernel_private.h"
|
||||
+#include "winreg.h"
|
||||
#include "psapi.h"
|
||||
#include "wine/exception.h"
|
||||
#include "wine/library.h"
|
||||
@@ -4369,8 +4370,73 @@ DWORD WINAPI WTSGetActiveConsoleSessionId(void)
|
||||
*/
|
||||
DEP_SYSTEM_POLICY_TYPE WINAPI GetSystemDEPPolicy(void)
|
||||
{
|
||||
- FIXME("stub\n");
|
||||
- return OptIn;
|
||||
+ char buffer[MAX_PATH+10];
|
||||
+ DWORD size = sizeof(buffer);
|
||||
+ HKEY hkey = 0;
|
||||
+ HKEY appkey = 0;
|
||||
+ DWORD len, tmpvalue;
|
||||
+ WINADVAPI LSTATUS (WINAPI *pRegOpenKeyA)(HKEY,LPCSTR,PHKEY);
|
||||
+ WINADVAPI LSTATUS (WINAPI *pRegQueryValueExA)(HKEY,LPCSTR,LPDWORD,LPDWORD,LPBYTE,LPDWORD);
|
||||
+ WINADVAPI LSTATUS (WINAPI *pRegCloseKey)(HKEY);
|
||||
+
|
||||
+ TRACE("()\n");
|
||||
+
|
||||
+ pRegOpenKeyA = (void*)GetProcAddress(GetModuleHandleA("advapi32"), "RegOpenKeyA");
|
||||
+ pRegQueryValueExA = (void*)GetProcAddress(GetModuleHandleA("advapi32"), "RegQueryValueExA");
|
||||
+ pRegCloseKey = (void*)GetProcAddress(GetModuleHandleA("advapi32"), "RegCloseKey");
|
||||
+ if ( !pRegOpenKeyA || !pRegQueryValueExA || !pRegCloseKey ) return OptIn;
|
||||
+
|
||||
+ /* @@ Wine registry key: HKCU\Software\Wine\Boot.ini */
|
||||
+ if ( pRegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Boot.ini", &hkey ) ) hkey = 0;
|
||||
+
|
||||
+ len = GetModuleFileNameA( 0, buffer, MAX_PATH );
|
||||
+ if (len && len < MAX_PATH)
|
||||
+ {
|
||||
+ HKEY tmpkey;
|
||||
+ /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\Boot.ini */
|
||||
+ if (!pRegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\AppDefaults", &tmpkey ))
|
||||
+ {
|
||||
+ char *p, *appname = buffer;
|
||||
+ if ((p = strrchr( appname, '/' ))) appname = p + 1;
|
||||
+ if ((p = strrchr( appname, '\\' ))) appname = p + 1;
|
||||
+ strcat( appname, "\\Boot.ini" );
|
||||
+ TRACE("appname = [%s]\n", appname);
|
||||
+ if (pRegOpenKeyA( tmpkey, appname, &appkey )) appkey = 0;
|
||||
+ pRegCloseKey( tmpkey );
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (hkey || appkey)
|
||||
+ {
|
||||
+ if ((appkey && !pRegQueryValueExA(appkey, "NoExecute", 0, NULL, (BYTE *)buffer, &size)) ||
|
||||
+ (hkey && !pRegQueryValueExA(hkey, "NoExecute", 0, NULL, (BYTE *)buffer, &size)))
|
||||
+ {
|
||||
+ if (!strcmp(buffer,"OptIn"))
|
||||
+ {
|
||||
+ TRACE("System DEP policy set to OptIn\n");
|
||||
+ system_DEP_policy = OptIn;
|
||||
+ }
|
||||
+ else if (!strcmp(buffer,"OptOut"))
|
||||
+ {
|
||||
+ TRACE("System DEP policy set to OptOut\n");
|
||||
+ system_DEP_policy = OptIn;
|
||||
+ }
|
||||
+ else if (!strcmp(buffer,"AlwaysOn"))
|
||||
+ {
|
||||
+ TRACE("System DEP policy set to AlwaysOn\n");
|
||||
+ system_DEP_policy = AlwaysOn;
|
||||
+ }
|
||||
+ else if (!strcmp(buffer,"AlwaysOff"))
|
||||
+ {
|
||||
+ TRACE("System DEP policy set to AlwaysOff\n");
|
||||
+ system_DEP_policy = AlwaysOff;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (appkey) pRegCloseKey( appkey );
|
||||
+ if (hkey) pRegCloseKey( hkey );
|
||||
+ return system_DEP_policy;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
--
|
||||
2.17.1
|
||||
|
@ -0,0 +1,43 @@
|
||||
From 76e5668f6371a5e3fe8bc524fc25080e375fb680 Mon Sep 17 00:00:00 2001
|
||||
From: "Olivier F. R. Dierick" <o.dierick@piezo-forte.be>
|
||||
Date: Tue, 19 Apr 2016 07:36:41 +0200
|
||||
Subject: [PATCH 3/3] kernel32: Make system DEP policy affect
|
||||
GetProcessDEPPolicy().
|
||||
|
||||
---
|
||||
dlls/kernel32/process.c | 15 +++++++++++----
|
||||
1 file changed, 11 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c
|
||||
index 6bf31516ca..2446491b10 100644
|
||||
--- a/dlls/kernel32/process.c
|
||||
+++ b/dlls/kernel32/process.c
|
||||
@@ -4629,14 +4629,21 @@ BOOL WINAPI GetProcessDEPPolicy(HANDLE process, LPDWORD flags, PBOOL permanent)
|
||||
if (flags)
|
||||
{
|
||||
*flags = 0;
|
||||
- if (dep_flags & MEM_EXECUTE_OPTION_DISABLE)
|
||||
- *flags |= PROCESS_DEP_ENABLE;
|
||||
- if (dep_flags & MEM_EXECUTE_OPTION_DISABLE_THUNK_EMULATION)
|
||||
- *flags |= PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION;
|
||||
+ if (system_DEP_policy != AlwaysOff)
|
||||
+ {
|
||||
+ if (dep_flags & MEM_EXECUTE_OPTION_DISABLE || system_DEP_policy == AlwaysOn)
|
||||
+ *flags |= PROCESS_DEP_ENABLE;
|
||||
+ if (dep_flags & MEM_EXECUTE_OPTION_DISABLE_THUNK_EMULATION)
|
||||
+ *flags |= PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION;
|
||||
+ }
|
||||
}
|
||||
|
||||
if (permanent)
|
||||
+ {
|
||||
*permanent = (dep_flags & MEM_EXECUTE_OPTION_PERMANENT) != 0;
|
||||
+ if (system_DEP_policy == AlwaysOn || system_DEP_policy == AlwaysOff)
|
||||
+ *permanent = TRUE;
|
||||
+ }
|
||||
|
||||
}
|
||||
if (status) SetLastError( RtlNtStatusToDosError(status) );
|
||||
--
|
||||
2.17.1
|
||||
|
1
patches/kernel32-SetProcessDEPPolicy/definition
Normal file
1
patches/kernel32-SetProcessDEPPolicy/definition
Normal file
@ -0,0 +1 @@
|
||||
Fixes: [24125] kernel32: Implement SetProcessDEPPolicy.
|
@ -161,6 +161,7 @@ patch_enable_all ()
|
||||
enable_kernel32_PE_Loader_Fixes="$1"
|
||||
enable_kernel32_Processor_Group="$1"
|
||||
enable_kernel32_SCSI_Sysfs="$1"
|
||||
enable_kernel32_SetProcessDEPPolicy="$1"
|
||||
enable_krnl386_exe16_GDT_LDT_Emulation="$1"
|
||||
enable_krnl386_exe16_Invalid_Console_Handles="$1"
|
||||
enable_libs_Debug_Channel="$1"
|
||||
@ -608,6 +609,9 @@ patch_enable ()
|
||||
kernel32-SCSI_Sysfs)
|
||||
enable_kernel32_SCSI_Sysfs="$2"
|
||||
;;
|
||||
kernel32-SetProcessDEPPolicy)
|
||||
enable_kernel32_SetProcessDEPPolicy="$2"
|
||||
;;
|
||||
krnl386.exe16-GDT_LDT_Emulation)
|
||||
enable_krnl386_exe16_GDT_LDT_Emulation="$2"
|
||||
;;
|
||||
@ -4183,6 +4187,25 @@ if test "$enable_kernel32_SCSI_Sysfs" -eq 1; then
|
||||
) >> "$patchlist"
|
||||
fi
|
||||
|
||||
# Patchset kernel32-SetProcessDEPPolicy
|
||||
# |
|
||||
# | This patchset fixes the following Wine bugs:
|
||||
# | * [#24125] kernel32: Implement SetProcessDEPPolicy.
|
||||
# |
|
||||
# | Modified files:
|
||||
# | * dlls/kernel32/process.c
|
||||
# |
|
||||
if test "$enable_kernel32_SetProcessDEPPolicy" -eq 1; then
|
||||
patch_apply kernel32-SetProcessDEPPolicy/0001-kernel32-Implement-SetProcessDEPPolicy.patch
|
||||
patch_apply kernel32-SetProcessDEPPolicy/0002-kernel32-Implement-GetSystemDEPPolicy.patch
|
||||
patch_apply kernel32-SetProcessDEPPolicy/0003-kernel32-Make-system-DEP-policy-affect-GetProcessDEP.patch
|
||||
(
|
||||
printf '%s\n' '+ { "Olivier F. R. Dierick", "kernel32: Implement SetProcessDEPPolicy().", 1 },';
|
||||
printf '%s\n' '+ { "Olivier F. R. Dierick", "kernel32: Implement GetSystemDEPPolicy().", 1 },';
|
||||
printf '%s\n' '+ { "Olivier F. R. Dierick", "kernel32: Make system DEP policy affect GetProcessDEPPolicy().", 1 },';
|
||||
) >> "$patchlist"
|
||||
fi
|
||||
|
||||
# Patchset krnl386.exe16-GDT_LDT_Emulation
|
||||
# |
|
||||
# | This patchset fixes the following Wine bugs:
|
||||
|
Loading…
x
Reference in New Issue
Block a user