-
-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollback to previous version of Guy1524's hack for Monster Hunter World.
Not sure if it's enough to fix our Overwatch issue yet. Hopefully a fix for https://github.com/Tk-Glitch/PKGBUILDS/issues/537
- Loading branch information
Showing
5 changed files
with
177 additions
and
293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3413,80 +3413,51 @@ index 90a790241a9..d0cd2639ee9 100644 | |
if (map_prot & SEC_NOCACHE) ret |= PAGE_NOCACHE; | ||
return ret; | ||
} | ||
diff --git a/server/thread.c b/server/thread.c | ||
index edf70c61bd..b9e6bca916 100644 | ||
--- a/server/thread.c | ||
+++ b/server/thread.c | ||
@@ -265,6 +265,11 @@ struct thread *create_thread( int fd, struct process *process, const struct secu | ||
thread->affinity = process->affinity; | ||
if (!current) current = thread; | ||
|
||
+ thread->fake_dbg_ctx = mem_alloc( sizeof(context_t) ); | ||
+ memset(thread->fake_dbg_ctx, 0, sizeof(context_t)); | ||
+ thread->fake_dbg_ctx->cpu = current->process->cpu; | ||
+ thread->fake_dbg_ctx->flags = SERVER_CTX_DEBUG_REGISTERS; | ||
+ | ||
list_add_head( &thread_list, &thread->entry ); | ||
|
||
if (sd && !set_sd_defaults_from_token( &thread->obj, sd, | ||
@@ -326,6 +331,7 @@ static void cleanup_thread( struct thread *thread ) | ||
if (thread->reply_fd) release_object( thread->reply_fd ); | ||
if (thread->wait_fd) release_object( thread->wait_fd ); | ||
free( thread->suspend_context ); | ||
+ free( thread->fake_dbg_ctx ); | ||
cleanup_clipboard_thread(thread); | ||
destroy_thread_windows( thread ); | ||
free_msg_queue( thread ); | ||
@@ -346,6 +352,7 @@ static void cleanup_thread( struct thread *thread ) | ||
thread->wait_fd = NULL; | ||
thread->context = NULL; | ||
thread->suspend_context = NULL; | ||
+ thread->fake_dbg_ctx = NULL; | ||
thread->desktop = 0; | ||
thread->desc = NULL; | ||
thread->desc_len = 0; | ||
@@ -1723,6 +1730,18 @@ DECL_HANDLER(get_thread_context) | ||
if (!(thread = get_thread_from_handle( req->handle, THREAD_GET_CONTEXT ))) return; | ||
reply->self = (thread == current); | ||
|
||
+ if (req->flags == SERVER_CTX_DEBUG_REGISTERS) | ||
+ { | ||
+ if ((context = set_reply_data_size( sizeof(context_t) ))) | ||
+ { | ||
+ memset( context, 0, sizeof(context_t) ); | ||
+ context->cpu = thread->process->cpu; | ||
+ copy_context(context, thread->fake_dbg_ctx, req->flags ); | ||
+ } | ||
+ release_object( thread ); | ||
+ return; | ||
+ } | ||
+ | ||
if (thread != current && !thread->context) | ||
From 24a8f709ec8fcf8fa4fcc349a7885c02cc184d74 Mon Sep 17 00:00:00 2001 | ||
From: Derek Lesho <[email protected]> | ||
Date: Wed, 26 Feb 2020 13:09:48 -0600 | ||
Subject: [PATCH] ntdll: Don't support reading/writing debug registers | ||
|
||
Monster Hunter World continually retrieves these registers, so fast-path | ||
this code. This will break setting debug registers on other threads. | ||
--- | ||
dlls/ntdll/signal_x86_64.c | 14 +++++++++++--- | ||
1 file changed, 11 insertions(+), 3 deletions(-) | ||
|
||
diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c | ||
index 04f3854388c..9752c3889b6 100644 | ||
--- a/dlls/ntdll/signal_x86_64.c | ||
+++ b/dlls/ntdll/signal_x86_64.c | ||
@@ -2115,13 +2115,13 @@ NTSTATUS WINAPI NtSetContextThread( HANDLE handle, const CONTEXT *context ) | ||
BOOL self = (handle == GetCurrentThread()); | ||
|
||
/* debug registers require a server call */ | ||
- if (self && (context->ContextFlags & (CONTEXT_DEBUG_REGISTERS & ~CONTEXT_AMD64))) | ||
+ /*if (self && (context->ContextFlags & (CONTEXT_DEBUG_REGISTERS & ~CONTEXT_AMD64))) | ||
self = (amd64_thread_data()->dr0 == context->Dr0 && | ||
amd64_thread_data()->dr1 == context->Dr1 && | ||
amd64_thread_data()->dr2 == context->Dr2 && | ||
amd64_thread_data()->dr3 == context->Dr3 && | ||
amd64_thread_data()->dr6 == context->Dr6 && | ||
- amd64_thread_data()->dr7 == context->Dr7); | ||
+ amd64_thread_data()->dr7 == context->Dr7);*/ | ||
|
||
if (!self) | ||
{ | ||
/* thread is not suspended, retry (if it's still running) */ | ||
@@ -1765,6 +1784,13 @@ DECL_HANDLER(set_thread_context) | ||
if (!(thread = get_thread_from_handle( req->handle, THREAD_SET_CONTEXT ))) return; | ||
reply->self = (thread == current); | ||
@@ -2149,7 +2149,15 @@ NTSTATUS WINAPI NtGetContextThread( HANDLE handle, CONTEXT *context ) | ||
needed_flags = context->ContextFlags; | ||
|
||
+ if (context->flags == SERVER_CTX_DEBUG_REGISTERS) | ||
/* debug registers require a server call */ | ||
- if (context->ContextFlags & (CONTEXT_DEBUG_REGISTERS & ~CONTEXT_AMD64)) self = FALSE; | ||
+ if (context->ContextFlags & (CONTEXT_DEBUG_REGISTERS & ~CONTEXT_AMD64)) //self = FALSE; | ||
+ { | ||
+ copy_context(thread->fake_dbg_ctx, context, context->flags); | ||
+ release_object( thread ); | ||
+ return; | ||
+ context->Dr0 = amd64_thread_data()->dr0; | ||
+ context->Dr1 = amd64_thread_data()->dr1; | ||
+ context->Dr2 = amd64_thread_data()->dr2; | ||
+ context->Dr3 = amd64_thread_data()->dr3; | ||
+ context->Dr6 = amd64_thread_data()->dr6; | ||
+ context->Dr7 = amd64_thread_data()->dr7; | ||
+ } | ||
+ | ||
if (thread != current && !thread->context) | ||
if (!self) | ||
{ | ||
/* thread is not suspended, retry (if it's still running) */ | ||
diff --git a/server/thread.h b/server/thread.h | ||
index 66e35603d3..c360ab8b9b 100644 | ||
--- a/server/thread.h | ||
+++ b/server/thread.h | ||
@@ -77,6 +77,7 @@ struct thread | ||
int unix_tid; /* Unix tid of client */ | ||
context_t *context; /* current context if in an exception handler */ | ||
context_t *suspend_context; /* current context if suspended */ | ||
+ context_t *fake_dbg_ctx; /* Holds the cached debug registers */ | ||
client_ptr_t teb; /* TEB address (in client address space) */ | ||
client_ptr_t entry_point; /* entry point (in client address space) */ | ||
affinity_t affinity; /* affinity mask */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3471,80 +3471,51 @@ index 90a790241a9..d0cd2639ee9 100644 | |
if (map_prot & SEC_NOCACHE) ret |= PAGE_NOCACHE; | ||
return ret; | ||
} | ||
diff --git a/server/thread.c b/server/thread.c | ||
index edf70c61bd..b9e6bca916 100644 | ||
--- a/server/thread.c | ||
+++ b/server/thread.c | ||
@@ -265,6 +265,11 @@ struct thread *create_thread( int fd, struct process *process, const struct secu | ||
thread->affinity = process->affinity; | ||
if (!current) current = thread; | ||
|
||
+ thread->fake_dbg_ctx = mem_alloc( sizeof(context_t) ); | ||
+ memset(thread->fake_dbg_ctx, 0, sizeof(context_t)); | ||
+ thread->fake_dbg_ctx->cpu = current->process->cpu; | ||
+ thread->fake_dbg_ctx->flags = SERVER_CTX_DEBUG_REGISTERS; | ||
+ | ||
list_add_head( &thread_list, &thread->entry ); | ||
|
||
if (sd && !set_sd_defaults_from_token( &thread->obj, sd, | ||
@@ -326,6 +331,7 @@ static void cleanup_thread( struct thread *thread ) | ||
if (thread->reply_fd) release_object( thread->reply_fd ); | ||
if (thread->wait_fd) release_object( thread->wait_fd ); | ||
free( thread->suspend_context ); | ||
+ free( thread->fake_dbg_ctx ); | ||
cleanup_clipboard_thread(thread); | ||
destroy_thread_windows( thread ); | ||
free_msg_queue( thread ); | ||
@@ -346,6 +352,7 @@ static void cleanup_thread( struct thread *thread ) | ||
thread->wait_fd = NULL; | ||
thread->context = NULL; | ||
thread->suspend_context = NULL; | ||
+ thread->fake_dbg_ctx = NULL; | ||
thread->desktop = 0; | ||
thread->desc = NULL; | ||
thread->desc_len = 0; | ||
@@ -1723,6 +1730,18 @@ DECL_HANDLER(get_thread_context) | ||
if (!(thread = get_thread_from_handle( req->handle, THREAD_GET_CONTEXT ))) return; | ||
reply->self = (thread == current); | ||
|
||
+ if (req->flags == SERVER_CTX_DEBUG_REGISTERS) | ||
+ { | ||
+ if ((context = set_reply_data_size( sizeof(context_t) ))) | ||
+ { | ||
+ memset( context, 0, sizeof(context_t) ); | ||
+ context->cpu = thread->process->cpu; | ||
+ copy_context(context, thread->fake_dbg_ctx, req->flags ); | ||
+ } | ||
+ release_object( thread ); | ||
+ return; | ||
+ } | ||
+ | ||
if (thread != current && !thread->context) | ||
From 24a8f709ec8fcf8fa4fcc349a7885c02cc184d74 Mon Sep 17 00:00:00 2001 | ||
From: Derek Lesho <[email protected]> | ||
Date: Wed, 26 Feb 2020 13:09:48 -0600 | ||
Subject: [PATCH] ntdll: Don't support reading/writing debug registers | ||
|
||
Monster Hunter World continually retrieves these registers, so fast-path | ||
this code. This will break setting debug registers on other threads. | ||
--- | ||
dlls/ntdll/signal_x86_64.c | 14 +++++++++++--- | ||
1 file changed, 11 insertions(+), 3 deletions(-) | ||
|
||
diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c | ||
index 04f3854388c..9752c3889b6 100644 | ||
--- a/dlls/ntdll/signal_x86_64.c | ||
+++ b/dlls/ntdll/signal_x86_64.c | ||
@@ -2115,13 +2115,13 @@ NTSTATUS WINAPI NtSetContextThread( HANDLE handle, const CONTEXT *context ) | ||
BOOL self = (handle == GetCurrentThread()); | ||
|
||
/* debug registers require a server call */ | ||
- if (self && (context->ContextFlags & (CONTEXT_DEBUG_REGISTERS & ~CONTEXT_AMD64))) | ||
+ /*if (self && (context->ContextFlags & (CONTEXT_DEBUG_REGISTERS & ~CONTEXT_AMD64))) | ||
self = (amd64_thread_data()->dr0 == context->Dr0 && | ||
amd64_thread_data()->dr1 == context->Dr1 && | ||
amd64_thread_data()->dr2 == context->Dr2 && | ||
amd64_thread_data()->dr3 == context->Dr3 && | ||
amd64_thread_data()->dr6 == context->Dr6 && | ||
- amd64_thread_data()->dr7 == context->Dr7); | ||
+ amd64_thread_data()->dr7 == context->Dr7);*/ | ||
|
||
if (!self) | ||
{ | ||
/* thread is not suspended, retry (if it's still running) */ | ||
@@ -1765,6 +1784,13 @@ DECL_HANDLER(set_thread_context) | ||
if (!(thread = get_thread_from_handle( req->handle, THREAD_SET_CONTEXT ))) return; | ||
reply->self = (thread == current); | ||
@@ -2149,7 +2149,15 @@ NTSTATUS WINAPI NtGetContextThread( HANDLE handle, CONTEXT *context ) | ||
needed_flags = context->ContextFlags; | ||
|
||
+ if (context->flags == SERVER_CTX_DEBUG_REGISTERS) | ||
/* debug registers require a server call */ | ||
- if (context->ContextFlags & (CONTEXT_DEBUG_REGISTERS & ~CONTEXT_AMD64)) self = FALSE; | ||
+ if (context->ContextFlags & (CONTEXT_DEBUG_REGISTERS & ~CONTEXT_AMD64)) //self = FALSE; | ||
+ { | ||
+ copy_context(thread->fake_dbg_ctx, context, context->flags); | ||
+ release_object( thread ); | ||
+ return; | ||
+ context->Dr0 = amd64_thread_data()->dr0; | ||
+ context->Dr1 = amd64_thread_data()->dr1; | ||
+ context->Dr2 = amd64_thread_data()->dr2; | ||
+ context->Dr3 = amd64_thread_data()->dr3; | ||
+ context->Dr6 = amd64_thread_data()->dr6; | ||
+ context->Dr7 = amd64_thread_data()->dr7; | ||
+ } | ||
+ | ||
if (thread != current && !thread->context) | ||
if (!self) | ||
{ | ||
/* thread is not suspended, retry (if it's still running) */ | ||
diff --git a/server/thread.h b/server/thread.h | ||
index 66e35603d3..c360ab8b9b 100644 | ||
--- a/server/thread.h | ||
+++ b/server/thread.h | ||
@@ -77,6 +77,7 @@ struct thread | ||
int unix_tid; /* Unix tid of client */ | ||
context_t *context; /* current context if in an exception handler */ | ||
context_t *suspend_context; /* current context if suspended */ | ||
+ context_t *fake_dbg_ctx; /* Holds the cached debug registers */ | ||
client_ptr_t teb; /* TEB address (in client address space) */ | ||
client_ptr_t entry_point; /* entry point (in client address space) */ | ||
affinity_t affinity; /* affinity mask */ |
Oops, something went wrong.