ntoskrnl-Emulator: Move logic for user shared data into separate patchset.

This commit is contained in:
Sebastian Lackner 2014-11-26 11:02:03 +01:00
parent 1979f90644
commit dd4efb315a
4 changed files with 110 additions and 18 deletions

View File

@ -69,6 +69,7 @@ PATCHLIST := \
ntdll-NtSetLdtEntries.ok \
ntdll-Pipe_SpecialCharacters.ok \
ntdll-ThreadTime.ok \
ntdll-User_Shared_Data.ok \
ntdll-WRITECOPY.ok \
ntoskrnl-Emulator.ok \
ntoskrnl-IoCsqInitialize.ok \
@ -1006,6 +1007,18 @@ ntdll-ThreadTime.ok:
echo '+ { "Sebastian Lackner", "ntdll: Return correct values in GetThreadTimes() for all threads.", 1 },'; \
) > ntdll-ThreadTime.ok
# Patchset ntdll-User_Shared_Data
# |
# | Modified files:
# | * dlls/ntdll/ntdll.spec, dlls/ntdll/thread.c
# |
.INTERMEDIATE: ntdll-User_Shared_Data.ok
ntdll-User_Shared_Data.ok:
$(call APPLY_FILE,ntdll-User_Shared_Data/0001-ntdll-Move-code-to-update-user-shared-data-into-a-se.patch)
@( \
echo '+ { "Sebastian Lackner", "ntdll: Move code to update user shared data into a separate function.", 1 },'; \
) > ntdll-User_Shared_Data.ok
# Patchset ntdll-WRITECOPY
# |
# | This patchset fixes the following Wine bugs:
@ -1040,13 +1053,13 @@ ntdll-WRITECOPY.ok:
# | * dlls/ntoskrnl.exe/instr.c, dlls/ntoskrnl.exe/ntoskrnl.c
# |
.INTERMEDIATE: ntoskrnl-Emulator.ok
ntoskrnl-Emulator.ok:
ntoskrnl-Emulator.ok: ntdll-User_Shared_Data.ok
$(call APPLY_FILE,ntoskrnl-Emulator/0001-ntoskrnl-Emulate-mov-Eb-Gb-instruction-on-x86-proces.patch)
$(call APPLY_FILE,ntoskrnl-Emulator/0002-ntoskrnl-Emulate-memory-access-to-KI_USER_SHARED_DAT.patch)
$(call APPLY_FILE,ntoskrnl-Emulator/0003-ntoskrnl-Add-TRACEs-for-instruction-emulator-on-x86_.patch)
@( \
echo '+ { "Sebastian Lackner", "ntoskrnl: Emulate '\''mov Eb, Gb'\'' instruction on x86 processor architecture.", 1 },'; \
echo '+ { "Sebastian Lackner", "ntoskrnl: Emulate memory access to KI_USER_SHARED_DATA on x86_64.", 1 },'; \
echo '+ { "Sebastian Lackner", "ntoskrnl: Emulate memory access to KI_USER_SHARED_DATA on x86_64.", 2 },'; \
echo '+ { "Sebastian Lackner", "ntoskrnl: Add TRACEs for instruction emulator on x86_64 to simplify debugging.", 1 },'; \
) > ntoskrnl-Emulator.ok

View File

@ -0,0 +1,81 @@
From 367e9fd451bf7fb6f521c2410ce193857d8ab12c Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Wed, 26 Nov 2014 10:46:09 +0100
Subject: ntdll: Move code to update user shared data into a separate function.
---
dlls/ntdll/ntdll.spec | 3 +++
dlls/ntdll/thread.c | 32 ++++++++++++++++++++++----------
2 files changed, 25 insertions(+), 10 deletions(-)
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
index 7e95969..729a8f6 100644
--- a/dlls/ntdll/ntdll.spec
+++ b/dlls/ntdll/ntdll.spec
@@ -1434,3 +1434,6 @@
@ cdecl wine_nt_to_unix_file_name(ptr ptr long long)
@ cdecl wine_unix_to_nt_file_name(ptr ptr)
@ cdecl __wine_init_windows_dir(wstr wstr)
+
+# User shared data
+@ cdecl __wine_user_shared_data()
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
index c8461b0..7d317ad 100644
--- a/dlls/ntdll/thread.c
+++ b/dlls/ntdll/thread.c
@@ -202,6 +202,26 @@ static ULONG get_dyld_image_info_addr(void)
}
#endif /* __APPLE__ */
+
+/**************************************************************************
+ * __wine_user_shared_data (NTDLL.@)
+ *
+ * Update user shared data and return the address of the structure.
+ */
+void* CDECL __wine_user_shared_data(void)
+{
+ LARGE_INTEGER now;
+ NtQuerySystemTime( &now );
+ user_shared_data->SystemTime.LowPart = now.u.LowPart;
+ user_shared_data->SystemTime.High1Time = user_shared_data->SystemTime.High2Time = now.u.HighPart;
+ user_shared_data->u.TickCountQuad = (now.QuadPart - server_start_time) / 10000;
+ user_shared_data->u.TickCount.High2Time = user_shared_data->u.TickCount.High1Time;
+ user_shared_data->TickCountLowDeprecated = user_shared_data->u.TickCount.LowPart;
+ user_shared_data->TickCountMultiplier = 1 << 24;
+ return user_shared_data;
+}
+
+
/***********************************************************************
* thread_init
*
@@ -215,7 +235,6 @@ HANDLE thread_init(void)
void *addr;
SIZE_T size, info_size;
HANDLE exe_file = 0;
- LARGE_INTEGER now;
NTSTATUS status;
struct ntdll_thread_data *thread_data;
static struct debug_info debug_info; /* debug info for initial thread */
@@ -317,15 +336,8 @@ HANDLE thread_init(void)
wine_server_fd_to_handle( 2, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, &params.hStdError );
}
- /* initialize time values in user_shared_data */
- NtQuerySystemTime( &now );
- user_shared_data->SystemTime.LowPart = now.u.LowPart;
- user_shared_data->SystemTime.High1Time = user_shared_data->SystemTime.High2Time = now.u.HighPart;
- user_shared_data->u.TickCountQuad = (now.QuadPart - server_start_time) / 10000;
- user_shared_data->u.TickCount.High2Time = user_shared_data->u.TickCount.High1Time;
- user_shared_data->TickCountLowDeprecated = user_shared_data->u.TickCount.LowPart;
- user_shared_data->TickCountMultiplier = 1 << 24;
-
+ /* initialize user_shared_data */
+ __wine_user_shared_data();
fill_cpu_info();
NtCreateKeyedEvent( &keyed_event, GENERIC_READ | GENERIC_WRITE, NULL, 0 );
--
2.1.3

View File

@ -1,15 +1,16 @@
From 9cdc9686cbdd77bfbed039f4811570c955ac26b3 Mon Sep 17 00:00:00 2001
From 015edd2598d688bdf15ef2f647042537423b15ce Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Mon, 10 Nov 2014 21:27:39 +0100
Subject: ntoskrnl: Emulate memory access to KI_USER_SHARED_DATA on x86_64.
(try 2)
---
dlls/ntoskrnl.exe/instr.c | 277 ++++++++++++++++++++++++++++++++++++++++++-
dlls/ntoskrnl.exe/instr.c | 273 ++++++++++++++++++++++++++++++++++++++++++-
dlls/ntoskrnl.exe/ntoskrnl.c | 2 +-
2 files changed, 277 insertions(+), 2 deletions(-)
2 files changed, 273 insertions(+), 2 deletions(-)
diff --git a/dlls/ntoskrnl.exe/instr.c b/dlls/ntoskrnl.exe/instr.c
index 05cd238..51b7bec 100644
index 05cd238..eda16f4 100644
--- a/dlls/ntoskrnl.exe/instr.c
+++ b/dlls/ntoskrnl.exe/instr.c
@@ -4,6 +4,7 @@
@ -20,7 +21,7 @@ index 05cd238..51b7bec 100644
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -470,4 +471,278 @@ LONG CALLBACK vectored_handler( EXCEPTION_POINTERS *ptrs )
@@ -470,4 +471,274 @@ LONG CALLBACK vectored_handler( EXCEPTION_POINTERS *ptrs )
return EXCEPTION_CONTINUE_SEARCH;
}
@ -32,6 +33,8 @@ index 05cd238..51b7bec 100644
+#include "windef.h"
+#include "winbase.h"
+#include "winternl.h"
+#define WIN32_NO_STATUS
+#include "ddk/wdm.h"
+#include "excpt.h"
+#include "wine/debug.h"
+#include "wine/exception.h"
@ -52,7 +55,7 @@ index 05cd238..51b7bec 100644
+#define SIB_BASE(sib, rex) (((sib) & 7) | (((rex) & REX_B) ? 8 : 0))
+
+#define KI_USER_SHARED_DATA 0xfffff78000000000
+static BYTE user_shared_data[0x1000];
+extern void* CDECL __wine_user_shared_data(void);
+
+static inline DWORD64 *get_int_reg( CONTEXT *context, int index )
+{
@ -154,12 +157,6 @@ index 05cd238..51b7bec 100644
+#undef GET_VAL
+}
+
+/* update the content of the user shared data page */
+static void update_user_shared_data(void)
+{
+ FIXME("TODO: update user shared data\n");
+}
+
+
+/***********************************************************************
+ * emulate_instruction
@ -244,9 +241,9 @@ index 05cd238..51b7bec 100644
+ unsigned int data_size = (*instr == 0x8b) ? get_op_size( long_op, rex ) : 1;
+ unsigned int offset = data - (BYTE *)KI_USER_SHARED_DATA;
+
+ if (offset <= sizeof(user_shared_data) - data_size)
+ if (offset <= sizeof(KSHARED_USER_DATA) - data_size)
+ {
+ update_user_shared_data();
+ BYTE *user_shared_data = __wine_user_shared_data();
+ switch (*instr)
+ {
+ case 0x8a: store_reg_byte( context, instr[1], user_shared_data + offset, rex ); break;
@ -266,9 +263,9 @@ index 05cd238..51b7bec 100644
+ unsigned int offset = data - (BYTE *)KI_USER_SHARED_DATA;
+ len = long_addr ? sizeof(DWORD64) : sizeof(DWORD);
+
+ if (offset <= sizeof(user_shared_data) - data_size)
+ if (offset <= sizeof(KSHARED_USER_DATA) - data_size)
+ {
+ update_user_shared_data();
+ BYTE *user_shared_data = __wine_user_shared_data();
+ memcpy( &context->Rax, user_shared_data + offset, data_size );
+ context->Rip += prefixlen + len + 1;
+ return ExceptionContinueExecution;

View File

@ -1 +1,2 @@
Fixes: [33849] Emulate access to KI_USER_SHARED_DATA kernel page on x86_64
Depends: ntdll-User_Shared_Data