Skip to content

Commit

Permalink
Rollback to previous version of Guy1524's hack for Monster Hunter World.
Browse files Browse the repository at this point in the history
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
Tk-Glitch committed Mar 30, 2020
1 parent 0f178f0 commit ace0aa4
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 293 deletions.
10 changes: 5 additions & 5 deletions wine-tkg-git/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pkgver=5.5.r2.g7fe7d87f

# workaround for pkgrel overwritten on regen
pkgrel=1
eval pkgrel=257
eval pkgrel=258

_stgsrcdir='wine-staging-git'
_esyncsrcdir='esync'
Expand Down Expand Up @@ -523,8 +523,8 @@ md5sums=('SKIP'
'30c8b895361d441b2fcfc16e541207a9'
'445c00bc59bcb4f7bbecdc29f46458a4'
'3512dd5e7aafe07de92c254f2ec25d87'
'3c603ca129b30060881928b203057d14'
'3c603ca129b30060881928b203057d14'
'48d502c4843e7a2ecf9f867e6d51e1a6'
'48d502c4843e7a2ecf9f867e6d51e1a6'
'7d9a7cf523c7283c64266148707b8bac'
'fbc02256e0e85668be75e0275637d6c1'
'4aa05580e78d36fdbd80f2ef2f46a6b3'
Expand All @@ -545,8 +545,8 @@ md5sums=('SKIP'
'e15634c0a969edeb4c53c074a02ede42'
'9a64328f39b1101a2f1765357607b6d7'
'efbe514ba50ecfbf7a3983bb6e682c4e'
'89afac49d74bbb73cdbf196bf14d1557'
'e9d08896e77433f134e5d4f4dbe33d6e'
'aa229b4494bcac043dcf03556f521e88'
'b5ba8bf6b217510c040ed38b561cea86'
'f404adafc8648495270e01241cd0601e'
'8681c98f6d488957a206c9c1f2f9547f'
'3d5518c89320a59400774a86b9a1cf2f'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Loading

0 comments on commit ace0aa4

Please sign in to comment.