ntdll-ThreadTime: Rebase and re-enable.

This commit is contained in:
Zebediah Figura 2020-06-29 19:03:01 -05:00
parent 70d8178927
commit 40099e26bf
12 changed files with 147 additions and 482 deletions

View File

@ -1,4 +1,4 @@
From 463baa9359f163b4e152f681a3703e602347ab04 Mon Sep 17 00:00:00 2001
From dceb199f694af989df0655f7846a40ae29c67ea0 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sat, 30 May 2015 02:23:15 +0200
Subject: [PATCH] ntdll: Add support for hiding wine version information from
@ -10,10 +10,10 @@ Subject: [PATCH] ntdll: Add support for hiding wine version information from
2 files changed, 104 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index 71efed5fa32..ec9ddc73e9c 100644
index c471755139f..e36764d9a3e 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -77,6 +77,7 @@ const WCHAR system_dir[] = {'C',':','\\','w','i','n','d','o','w','s','\\',
@@ -71,6 +71,7 @@ const WCHAR system_dir[] = {'C',':','\\','w','i','n','d','o','w','s','\\',
const WCHAR syswow64_dir[] = {'C',':','\\','w','i','n','d','o','w','s','\\',
's','y','s','w','o','w','6','4','\\',0};
@ -21,7 +21,7 @@ index 71efed5fa32..ec9ddc73e9c 100644
/* system search path */
static const WCHAR system_path[] =
{'C',':','\\','w','i','n','d','o','w','s','\\','s','y','s','t','e','m','3','2',';',
@@ -85,6 +86,9 @@ static const WCHAR system_path[] =
@@ -79,6 +80,9 @@ static const WCHAR system_path[] =
static const WCHAR dotW[] = {'.',0};
@ -31,7 +31,7 @@ index 71efed5fa32..ec9ddc73e9c 100644
static BOOL imports_fixup_done = FALSE; /* set once the imports have been fixed up, before attaching them */
static BOOL process_detaching = FALSE; /* set on process detach to avoid deadlocks with thread detach */
static int free_lib_count; /* recursion depth of LdrUnloadDll calls */
@@ -101,6 +105,8 @@ struct dll_dir_entry
@@ -95,6 +99,8 @@ struct dll_dir_entry
static struct list dll_dir_list = LIST_INIT( dll_dir_list ); /* extra dirs from LdrAddDllDirectory */
@ -40,7 +40,7 @@ index 71efed5fa32..ec9ddc73e9c 100644
struct ldr_notification
{
struct list entry;
@@ -1810,6 +1816,96 @@ NTSTATUS WINAPI LdrUnlockLoaderLock( ULONG flags, ULONG_PTR magic )
@@ -1709,6 +1715,96 @@ NTSTATUS WINAPI LdrUnlockLoaderLock( ULONG flags, ULONG_PTR magic )
}
@ -137,7 +137,7 @@ index 71efed5fa32..ec9ddc73e9c 100644
/******************************************************************
* LdrGetProcedureAddress (NTDLL.@)
*/
@@ -1830,7 +1926,7 @@ NTSTATUS WINAPI LdrGetProcedureAddress(HMODULE module, const ANSI_STRING *name,
@@ -1729,7 +1825,7 @@ NTSTATUS WINAPI LdrGetProcedureAddress(HMODULE module, const ANSI_STRING *name,
LPCWSTR load_path = NtCurrentTeb()->Peb->ProcessParameters->DllPath.Buffer;
void *proc = name ? find_named_export( module, exports, exp_size, name->Buffer, -1, load_path )
: find_ordinal_export( module, exports, exp_size, ord - exports->Base, load_path );
@ -146,7 +146,7 @@ index 71efed5fa32..ec9ddc73e9c 100644
{
*address = proc;
ret = STATUS_SUCCESS;
@@ -4491,6 +4587,8 @@ void __wine_process_init(void)
@@ -4061,6 +4157,8 @@ void __wine_process_init(void)
NtTerminateProcess( GetCurrentProcess(), status );
}
@ -156,10 +156,10 @@ index 71efed5fa32..ec9ddc73e9c 100644
/* elevate process if necessary */
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
index dbd9a826429..b4666d82c8b 100644
index 1afda71c3ad..d489b850963 100644
--- a/dlls/ntdll/ntdll_misc.h
+++ b/dlls/ntdll/ntdll_misc.h
@@ -283,6 +283,11 @@ void WINAPI LdrInitializeThunk(CONTEXT*,void**,ULONG_PTR,ULONG_PTR);
@@ -153,6 +153,11 @@ void WINAPI LdrInitializeThunk(CONTEXT*,void**,ULONG_PTR,ULONG_PTR);
#define InterlockedCompareExchange64(dest,xchg,cmp) RtlInterlockedCompareExchange64(dest,xchg,cmp)
#endif
@ -168,9 +168,9 @@ index dbd9a826429..b4666d82c8b 100644
+extern const char * CDECL NTDLL_wine_get_build_id(void);
+extern void CDECL NTDLL_wine_get_host_version( const char **sysname, const char **release );
+
/* process / thread time */
extern BOOL read_process_time(int unix_pid, int unix_tid, unsigned long clk_tck,
LARGE_INTEGER *kernel, LARGE_INTEGER *user) DECLSPEC_HIDDEN;
/* string functions */
void * __cdecl NTDLL_memchr( const void *ptr, int c, size_t n );
char * __cdecl NTDLL_strcat( char *dst, const char *src );
--
2.26.2
2.27.0

View File

@ -1,5 +1,3 @@
Fixes: [38656] Add support for hiding wine version information from applications
Depends: ntdll-ThreadTime
Depends: advapi32-Token_Integrity_Level
# Re-enable me when ntdll-ThreadTime gets re-enabled!
Disabled: true

View File

@ -1,163 +0,0 @@
From 4b31157383a5e422660c17d47fd4cda511a991a4 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Fri, 7 Nov 2014 03:26:18 +0100
Subject: [PATCH] ntdll: Return correct values in GetThreadTimes() for all
threads.
Based on a patch by Ray Hinchliffe <ray@pobox.co.uk>.
---
dlls/ntdll/thread.c | 82 ++++++++++++++++++++++++++++++++++++++++++-----------
server/protocol.def | 2 ++
server/thread.c | 2 ++
3 files changed, 69 insertions(+), 17 deletions(-)
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
index c999d4b..1491ebb 100644
--- a/dlls/ntdll/thread.c
+++ b/dlls/ntdll/thread.c
@@ -23,6 +23,8 @@
#include <assert.h>
#include <stdarg.h>
+#include <string.h>
+#include <stdio.h>
#include <limits.h>
#include <sys/types.h>
#ifdef HAVE_SYS_MMAN_H
@@ -1017,7 +1019,10 @@ NTSTATUS WINAPI NtQueryInformationThread( HANDLE handle, THREADINFOCLASS class,
case ThreadTimes:
{
KERNEL_USER_TIMES kusrt;
+ int unix_pid, unix_tid;
+ /* We need to do a server call to get the creation time, exit time, PID and TID */
+ /* This works on any thread */
SERVER_START_REQ( get_thread_times )
{
req->handle = wine_server_obj_handle( handle );
@@ -1026,36 +1031,79 @@ NTSTATUS WINAPI NtQueryInformationThread( HANDLE handle, THREADINFOCLASS class,
{
kusrt.CreateTime.QuadPart = reply->creation_time;
kusrt.ExitTime.QuadPart = reply->exit_time;
+ unix_pid = reply->unix_pid;
+ unix_tid = reply->unix_tid;
}
}
SERVER_END_REQ;
if (status == STATUS_SUCCESS)
{
- /* We call times(2) for kernel time or user time */
- /* We can only (portably) do this for the current thread */
- if (handle == GetCurrentThread())
+ unsigned long clk_tck = sysconf(_SC_CLK_TCK);
+ BOOL filled_times = FALSE;
+
+#ifdef __linux__
+ /* only /proc provides exact values for a specific thread */
+ if (unix_pid != -1 && unix_tid != -1)
{
- struct tms time_buf;
- long clocks_per_sec = sysconf(_SC_CLK_TCK);
+ unsigned long usr, sys;
+ char buf[512], *pos;
+ FILE *fp;
+ int i;
+
+ /* based on https://github.com/torvalds/linux/blob/master/fs/proc/array.c */
+ sprintf( buf, "/proc/%u/task/%u/stat", unix_pid, unix_tid );
+ if ((fp = fopen( buf, "r" )))
+ {
+ pos = fgets( buf, sizeof(buf), fp );
+ fclose( fp );
+
+ /* format of first chunk is "%d (%s) %c" - we have to skip to the last ')'
+ * to avoid misinterpreting the string. */
+ if (pos) pos = strrchr( pos, ')' );
+ if (pos) pos = strchr( pos + 1, ' ' );
+ if (pos) pos++;
+
+ /* skip over the following fields: state, ppid, pgid, sid, tty_nr, tty_pgrp,
+ * task->flags, min_flt, cmin_flt, maj_flt, cmaj_flt */
+ for (i = 0; (i < 11) && pos; i++)
+ {
+ pos = strchr( pos + 1, ' ' );
+ if (pos) pos++;
+ }
+
+ /* the next two values are user and system time */
+ if (pos && (sscanf( pos, "%lu %lu", &usr, &sys ) == 2))
+ {
+ kusrt.KernelTime.QuadPart = (ULONGLONG)sys * 10000000 / clk_tck;
+ kusrt.UserTime.QuadPart = (ULONGLONG)usr * 10000000 / clk_tck;
+ filled_times = TRUE;
+ }
+ }
+ }
+#endif
+ /* get values for current process instead */
+ if (!filled_times && handle == GetCurrentThread())
+ {
+ struct tms time_buf;
times(&time_buf);
- kusrt.KernelTime.QuadPart = (ULONGLONG)time_buf.tms_stime * 10000000 / clocks_per_sec;
- kusrt.UserTime.QuadPart = (ULONGLONG)time_buf.tms_utime * 10000000 / clocks_per_sec;
+
+ kusrt.KernelTime.QuadPart = (ULONGLONG)time_buf.tms_stime * 10000000 / clk_tck;
+ kusrt.UserTime.QuadPart = (ULONGLONG)time_buf.tms_utime * 10000000 / clk_tck;
+ filled_times = TRUE;
}
- else
+
+ /* unable to determine exact values, fill with zero */
+ if (!filled_times)
{
- static BOOL reported = FALSE;
+ static int once;
+ if (!once++)
+ FIXME("Cannot get kerneltime or usertime of other threads\n");
kusrt.KernelTime.QuadPart = 0;
- kusrt.UserTime.QuadPart = 0;
- if (reported)
- TRACE("Cannot get kerneltime or usertime of other threads\n");
- else
- {
- FIXME("Cannot get kerneltime or usertime of other threads\n");
- reported = TRUE;
- }
+ kusrt.UserTime.QuadPart = 0;
}
+
if (data) memcpy( data, &kusrt, min( length, sizeof(kusrt) ));
if (ret_len) *ret_len = min( length, sizeof(kusrt) );
}
diff --git a/server/protocol.def b/server/protocol.def
index 3bed47a..031b490 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -908,6 +908,8 @@ struct rawinput_device
@REPLY
timeout_t creation_time; /* thread creation time */
timeout_t exit_time; /* thread exit time */
+ int unix_pid; /* thread native pid */
+ int unix_tid; /* thread native pid */
@END
diff --git a/server/thread.c b/server/thread.c
index 2cf5054..46fc9a7 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -1413,6 +1413,8 @@ DECL_HANDLER(get_thread_times)
{
reply->creation_time = thread->creation_time;
reply->exit_time = thread->exit_time;
+ reply->unix_pid = thread->unix_pid;
+ reply->unix_tid = thread->unix_tid;
release_object( thread );
}
--
1.9.1

View File

@ -1,46 +1,46 @@
From e6832d1b0f923e7589424ade7571cc67dc768c4d Mon Sep 17 00:00:00 2001
From be1561c5ef6fcc9ef06f998bc06ea245bd187915 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Thu, 9 Mar 2017 00:00:46 +0100
Subject: ntdll: Set correct thread creation time for SystemProcessInformation
in NtQuerySystemInformation.
Subject: [PATCH] ntdll: Set correct thread creation time for
SystemProcessInformation in NtQuerySystemInformation.
---
dlls/ntdll/nt.c | 2 +-
server/protocol.def | 1 +
server/snapshot.c | 11 ++++++-----
server/thread.h | 1 +
4 files changed, 9 insertions(+), 6 deletions(-)
dlls/ntdll/unix/system.c | 2 +-
server/protocol.def | 1 +
server/snapshot.c | 13 +++++++------
server/thread.h | 1 +
4 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c
index 86beb031e9c..fc8e3b1eb4e 100644
--- a/dlls/ntdll/nt.c
+++ b/dlls/ntdll/nt.c
@@ -2012,7 +2012,7 @@ NTSTATUS WINAPI NtQuerySystemInformation(
diff --git a/dlls/ntdll/unix/system.c b/dlls/ntdll/unix/system.c
index 7045bc1550b..f137ccf97a7 100644
--- a/dlls/ntdll/unix/system.c
+++ b/dlls/ntdll/unix/system.c
@@ -2184,7 +2184,7 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class,
{
memset(&spi->ti[i], 0, sizeof(spi->ti));
memset(&spi->ti[i], 0, sizeof(spi->ti));
- spi->ti[i].CreateTime.QuadPart = 0xdeadbeef;
+ spi->ti[i].CreateTime.QuadPart = reply->creation_time;
spi->ti[i].ClientId.UniqueProcess = UlongToHandle(reply->pid);
spi->ti[i].ClientId.UniqueThread = UlongToHandle(reply->tid);
spi->ti[i].dwCurrentPriority = reply->base_pri + reply->delta_pri;
- spi->ti[i].CreateTime.QuadPart = 0xdeadbeef;
+ spi->ti[i].CreateTime.QuadPart = reply->creation_time;
spi->ti[i].ClientId.UniqueProcess = UlongToHandle(pid);
spi->ti[i].ClientId.UniqueThread = UlongToHandle(tid);
spi->ti[i].dwCurrentPriority = base_pri + delta_pri;
diff --git a/server/protocol.def b/server/protocol.def
index 60865a6ffc2..15adc51462f 100644
index 38079f23daf..89a0332691c 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -1783,6 +1783,7 @@ enum char_info_mode
@@ -1911,6 +1911,7 @@ enum char_info_mode
int count; /* thread usage count */
process_id_t pid; /* process id */
thread_id_t tid; /* thread id */
+ timeout_t creation_time; /* thread creation time */
int base_pri; /* base priority */
int delta_pri; /* delta priority */
@END
int unix_tid; /* thread native pid */
diff --git a/server/snapshot.c b/server/snapshot.c
index e35588a136c..858fca898a7 100644
index bdceaef5302..fe25e07e02a 100644
--- a/server/snapshot.c
+++ b/server/snapshot.c
@@ -144,11 +144,12 @@ static int snapshot_next_thread( struct snapshot *snapshot, struct next_thread_r
@@ -145,12 +145,13 @@ static int snapshot_next_thread( struct snapshot *snapshot, struct next_thread_r
return 0;
}
ptr = &snapshot->threads[snapshot->thread_pos++];
@ -49,20 +49,22 @@ index e35588a136c..858fca898a7 100644
- reply->tid = get_thread_id( ptr->thread );
- reply->base_pri = ptr->priority;
- reply->delta_pri = 0; /* FIXME */
- reply->unix_tid = ptr->thread->unix_tid;
+ reply->count = ptr->count;
+ reply->pid = get_process_id( ptr->thread->process );
+ reply->tid = get_thread_id( ptr->thread );
+ reply->creation_time = get_thread_creation_time( ptr->thread );
+ reply->base_pri = ptr->priority;
+ reply->delta_pri = 0; /* FIXME */
+ reply->unix_tid = ptr->thread->unix_tid;
return 1;
}
diff --git a/server/thread.h b/server/thread.h
index 282199149e6..2098c76a472 100644
index 5d12d24dd89..43b17534693 100644
--- a/server/thread.h
+++ b/server/thread.h
@@ -145,5 +145,6 @@ static inline void clear_error(void) { set_error(0); }
@@ -150,5 +150,6 @@ static inline void clear_error(void) { set_error(0); }
static inline void set_win32_error( unsigned int err ) { set_error( 0xc0010000 | err ); }
static inline thread_id_t get_thread_id( struct thread *thread ) { return thread->id; }
@ -70,5 +72,5 @@ index 282199149e6..2098c76a472 100644
#endif /* __WINE_SERVER_THREAD_H */
--
2.11.0
2.27.0

View File

@ -1,162 +0,0 @@
From 2fb8a13c53a38377e8c64d202f91c2b5997669d7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Thu, 9 Mar 2017 16:27:23 +0100
Subject: [PATCH] ntdll: Fill process kernel and user time.
---
dlls/ntdll/nt.c | 6 ++-
dlls/ntdll/ntdll_misc.h | 4 ++
dlls/ntdll/thread.c | 84 +++++++++++++++++++++++------------------
3 files changed, 57 insertions(+), 37 deletions(-)
diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c
index 6f17225b983..bdd169fb335 100644
--- a/dlls/ntdll/nt.c
+++ b/dlls/ntdll/nt.c
@@ -2646,6 +2646,7 @@ NTSTATUS WINAPI NtQuerySystemInformation(
{
SYSTEM_PROCESS_INFORMATION* spi = SystemInformation;
SYSTEM_PROCESS_INFORMATION* last = NULL;
+ unsigned long clk_tck = sysconf(_SC_CLK_TCK);
HANDLE hSnap = 0;
WCHAR procname[1024];
WCHAR* exename;
@@ -2683,7 +2684,7 @@ NTSTATUS WINAPI NtQuerySystemInformation(
if (Length >= len + procstructlen)
{
- /* ftCreationTime, ftUserTime, ftKernelTime;
+ /* ftCreationTime;
* vmCounters, ioCounters
*/
@@ -2701,6 +2702,9 @@ NTSTATUS WINAPI NtQuerySystemInformation(
/* spi->ti will be set later on */
+ if (reply->unix_pid != -1)
+ read_process_time(reply->unix_pid, -1, clk_tck,
+ &spi->KernelTime, &spi->UserTime);
}
len += procstructlen;
}
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
index 27e7141bc65..f30cfa2e36b 100644
--- a/dlls/ntdll/ntdll_misc.h
+++ b/dlls/ntdll/ntdll_misc.h
@@ -301,6 +301,10 @@ void WINAPI LdrInitializeThunk(CONTEXT*,void**,ULONG_PTR,ULONG_PTR);
#define InterlockedCompareExchange64(dest,xchg,cmp) RtlInterlockedCompareExchange64(dest,xchg,cmp)
#endif
+/* process / thread time */
+extern BOOL read_process_time(int unix_pid, int unix_tid, unsigned long clk_tck,
+ LARGE_INTEGER *kernel, LARGE_INTEGER *user) DECLSPEC_HIDDEN;
+
/* string functions */
int __cdecl NTDLL_tolower( int c );
int __cdecl _stricmp( LPCSTR str1, LPCSTR str2 );
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
index de355c51fdd..18f4f5533e2 100644
--- a/dlls/ntdll/thread.c
+++ b/dlls/ntdll/thread.c
@@ -154,6 +154,53 @@ static ULONG_PTR get_image_addr(void)
#endif
+
+BOOL read_process_time(int unix_pid, int unix_tid, unsigned long clk_tck,
+ LARGE_INTEGER *kernel, LARGE_INTEGER *user)
+{
+#ifdef __linux__
+ unsigned long usr, sys;
+ char buf[512], *pos;
+ FILE *fp;
+ int i;
+
+ /* based on https://github.com/torvalds/linux/blob/master/fs/proc/array.c */
+ if (unix_tid != -1)
+ sprintf( buf, "/proc/%u/task/%u/stat", unix_pid, unix_tid );
+ else
+ sprintf( buf, "/proc/%u/stat", unix_pid );
+ if ((fp = fopen( buf, "r" )))
+ {
+ pos = fgets( buf, sizeof(buf), fp );
+ fclose( fp );
+
+ /* format of first chunk is "%d (%s) %c" - we have to skip to the last ')'
+ * to avoid misinterpreting the string. */
+ if (pos) pos = strrchr( pos, ')' );
+ if (pos) pos = strchr( pos + 1, ' ' );
+ if (pos) pos++;
+
+ /* skip over the following fields: state, ppid, pgid, sid, tty_nr, tty_pgrp,
+ * task->flags, min_flt, cmin_flt, maj_flt, cmaj_flt */
+ for (i = 0; (i < 11) && pos; i++)
+ {
+ pos = strchr( pos + 1, ' ' );
+ if (pos) pos++;
+ }
+
+ /* the next two values are user and system time */
+ if (pos && (sscanf( pos, "%lu %lu", &usr, &sys ) == 2))
+ {
+ kernel->QuadPart = (ULONGLONG)sys * 10000000 / clk_tck;
+ user->QuadPart = (ULONGLONG)usr * 10000000 / clk_tck;
+ return TRUE;
+ }
+ }
+#endif
+ return FALSE;
+}
+
+
/***********************************************************************
* __wine_dbg_get_channel_flags (NTDLL.@)
*
@@ -988,42 +1035,7 @@ NTSTATUS WINAPI NtQueryInformationThread( HANDLE handle, THREADINFOCLASS class,
#ifdef __linux__
/* only /proc provides exact values for a specific thread */
if (unix_pid != -1 && unix_tid != -1)
- {
- unsigned long usr, sys;
- char buf[512], *pos;
- FILE *fp;
- int i;
-
- /* based on https://github.com/torvalds/linux/blob/master/fs/proc/array.c */
- sprintf( buf, "/proc/%u/task/%u/stat", unix_pid, unix_tid );
- if ((fp = fopen( buf, "r" )))
- {
- pos = fgets( buf, sizeof(buf), fp );
- fclose( fp );
-
- /* format of first chunk is "%d (%s) %c" - we have to skip to the last ')'
- * to avoid misinterpreting the string. */
- if (pos) pos = strrchr( pos, ')' );
- if (pos) pos = strchr( pos + 1, ' ' );
- if (pos) pos++;
-
- /* skip over the following fields: state, ppid, pgid, sid, tty_nr, tty_pgrp,
- * task->flags, min_flt, cmin_flt, maj_flt, cmaj_flt */
- for (i = 0; (i < 11) && pos; i++)
- {
- pos = strchr( pos + 1, ' ' );
- if (pos) pos++;
- }
-
- /* the next two values are user and system time */
- if (pos && (sscanf( pos, "%lu %lu", &usr, &sys ) == 2))
- {
- kusrt.KernelTime.QuadPart = (ULONGLONG)sys * 10000000 / clk_tck;
- kusrt.UserTime.QuadPart = (ULONGLONG)usr * 10000000 / clk_tck;
- filled_times = TRUE;
- }
- }
- }
+ filled_times = read_process_time(unix_pid, unix_tid, clk_tck, &kusrt.KernelTime, &kusrt.UserTime);
#endif
/* get values for current process instead */
--
2.26.2

View File

@ -1,31 +1,31 @@
From e048ad0cd3879fb8f752af7e2eeda770864f9982 Mon Sep 17 00:00:00 2001
From 72c4b3f95ad4c8a8ed31ad61c3678cf7d534fba9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Thu, 9 Mar 2017 16:32:59 +0100
Subject: ntdll: Set process start time.
Subject: [PATCH] ntdll: Set process start time.
---
dlls/ntdll/nt.c | 1 +
server/protocol.def | 1 +
server/snapshot.c | 15 ++++++++-------
dlls/ntdll/unix/system.c | 1 +
server/protocol.def | 1 +
server/snapshot.c | 15 ++++++++-------
3 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c
index 03cfd032bc..45572cb393 100644
--- a/dlls/ntdll/nt.c
+++ b/dlls/ntdll/nt.c
@@ -2058,6 +2058,7 @@ NTSTATUS WINAPI NtQuerySystemInformation(
spi->UniqueProcessId = UlongToHandle(reply->pid);
spi->ParentProcessId = UlongToHandle(reply->ppid);
spi->HandleCount = reply->handles;
+ spi->CreationTime.QuadPart = reply->start_time;
diff --git a/dlls/ntdll/unix/system.c b/dlls/ntdll/unix/system.c
index f137ccf97a7..94915bd9e47 100644
--- a/dlls/ntdll/unix/system.c
+++ b/dlls/ntdll/unix/system.c
@@ -2137,6 +2137,7 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class,
spi->UniqueProcessId = UlongToHandle(reply->pid);
spi->ParentProcessId = UlongToHandle(reply->ppid);
spi->HandleCount = reply->handles;
+ spi->CreationTime.QuadPart = reply->start_time;
/* spi->ti will be set later on */
/* spi->ti will be set later on */
diff --git a/server/protocol.def b/server/protocol.def
index 320e34384a..1347defe70 100644
index 89a0332691c..b29e014958e 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -1808,6 +1808,7 @@ enum char_info_mode
@@ -1899,6 +1899,7 @@ enum char_info_mode
int priority; /* process priority */
int handles; /* number of handles */
int unix_pid; /* Unix pid */
@ -34,7 +34,7 @@ index 320e34384a..1347defe70 100644
@END
diff --git a/server/snapshot.c b/server/snapshot.c
index f2903d522e..e509e0aca9 100644
index fe25e07e02a..b6b790e21bd 100644
--- a/server/snapshot.c
+++ b/server/snapshot.c
@@ -114,13 +114,14 @@ static int snapshot_next_process( struct snapshot *snapshot, struct next_process
@ -60,5 +60,5 @@ index f2903d522e..e509e0aca9 100644
{
data_size_t len = min( exe_module->namelen, get_reply_max_size() );
--
2.11.0
2.27.0

View File

@ -1,82 +0,0 @@
From 6c3b7e0065c239b488bb224c1c67ff971562fdca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Thu, 9 Mar 2017 21:14:13 +0100
Subject: ntdll: Fill out thread times in process enumeration.
---
dlls/ntdll/nt.c | 6 ++++++
server/protocol.def | 1 +
server/snapshot.c | 1 +
server/thread.h | 1 +
4 files changed, 9 insertions(+)
diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c
index 8c54e7edfb..8b84cd865b 100644
--- a/dlls/ntdll/nt.c
+++ b/dlls/ntdll/nt.c
@@ -1928,6 +1928,7 @@ NTSTATUS WINAPI NtQuerySystemInformation(
WCHAR* exename;
DWORD wlen = 0;
DWORD procstructlen = 0;
+ int unix_pid = -1;
SERVER_START_REQ( create_snapshot )
{
@@ -1982,6 +1983,7 @@ NTSTATUS WINAPI NtQuerySystemInformation(
if (reply->unix_pid != -1)
read_process_time(reply->unix_pid, -1, clk_tck,
&spi->KernelTime, &spi->UserTime);
+ unix_pid = reply->unix_pid;
}
len += procstructlen;
}
@@ -2022,6 +2024,10 @@ NTSTATUS WINAPI NtQuerySystemInformation(
spi->ti[i].ClientId.UniqueThread = UlongToHandle(reply->tid);
spi->ti[i].dwCurrentPriority = reply->base_pri + reply->delta_pri;
spi->ti[i].dwBasePriority = reply->base_pri;
+
+ if (unix_pid != -1 && reply->unix_tid != -1)
+ read_process_time(unix_pid, reply->unix_tid, clk_tck,
+ &spi->ti[i].KernelTime, &spi->ti[i].UserTime);
i++;
}
}
diff --git a/server/protocol.def b/server/protocol.def
index b0b837cb93..542060decd 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -1789,6 +1789,7 @@ enum char_info_mode
timeout_t creation_time; /* thread creation time */
int base_pri; /* base priority */
int delta_pri; /* delta priority */
+ int unix_tid; /* Unix tid */
@END
diff --git a/server/snapshot.c b/server/snapshot.c
index cc8a9be1b5..a32207c720 100644
--- a/server/snapshot.c
+++ b/server/snapshot.c
@@ -151,6 +151,7 @@ static int snapshot_next_thread( struct snapshot *snapshot, struct next_thread_r
reply->creation_time = get_thread_creation_time( ptr->thread );
reply->base_pri = ptr->priority;
reply->delta_pri = 0; /* FIXME */
+ reply->unix_tid = get_thread_unix_tid( ptr->thread );
return 1;
}
diff --git a/server/thread.h b/server/thread.h
index 2098c76a47..9614e2140d 100644
--- a/server/thread.h
+++ b/server/thread.h
@@ -145,6 +145,7 @@ static inline void clear_error(void) { set_error(0); }
static inline void set_win32_error( unsigned int err ) { set_error( 0xc0010000 | err ); }
static inline thread_id_t get_thread_id( struct thread *thread ) { return thread->id; }
+static inline int get_thread_unix_tid( struct thread *thread ) { return thread->unix_tid; }
static inline timeout_t get_thread_creation_time( struct thread *thread ) { return thread->creation_time; }
#endif /* __WINE_SERVER_THREAD_H */
--
2.11.0

View File

@ -1,5 +1,2 @@
Fixes: [20230] Return correct values for GetThreadTimes function
Fixes: Return correct thread creation time in SystemProcessInformation
Fixes: Fill process virtual memory counters in NtQuerySystemInformation
# Split awkwardly between .so and .dll parts (NtQuerySystemInformation vs NtQueryProcess/ThreadInformation).
Disabled: true

View File

@ -176,6 +176,7 @@ patch_enable_all ()
enable_ntdll_ForceBottomUpAlloc="$1"
enable_ntdll_HashLinks="$1"
enable_ntdll_Heap_Improvements="$1"
enable_ntdll_Hide_Wine_Exports="$1"
enable_ntdll_Interrupt_0x2e="$1"
enable_ntdll_Junction_Points="$1"
enable_ntdll_Manifest_Range="$1"
@ -194,6 +195,7 @@ patch_enable_all ()
enable_ntdll_SystemInterruptInformation="$1"
enable_ntdll_SystemModuleInformation="$1"
enable_ntdll_SystemRoot_Symlink="$1"
enable_ntdll_ThreadTime="$1"
enable_ntdll_WRITECOPY="$1"
enable_ntdll_Zero_mod_name="$1"
enable_ntdll_aarch_TEB="$1"
@ -223,6 +225,7 @@ patch_enable_all ()
enable_server_Inherited_ACLs="$1"
enable_server_Object_Types="$1"
enable_server_PeekMessage="$1"
enable_server_Realtime_Priority="$1"
enable_server_Registry_Notifications="$1"
enable_server_Signal_Thread="$1"
enable_server_Stored_ACLs="$1"
@ -612,6 +615,9 @@ patch_enable ()
ntdll-Heap_Improvements)
enable_ntdll_Heap_Improvements="$2"
;;
ntdll-Hide_Wine_Exports)
enable_ntdll_Hide_Wine_Exports="$2"
;;
ntdll-Interrupt-0x2e)
enable_ntdll_Interrupt_0x2e="$2"
;;
@ -666,6 +672,9 @@ patch_enable ()
ntdll-SystemRoot_Symlink)
enable_ntdll_SystemRoot_Symlink="$2"
;;
ntdll-ThreadTime)
enable_ntdll_ThreadTime="$2"
;;
ntdll-WRITECOPY)
enable_ntdll_WRITECOPY="$2"
;;
@ -753,6 +762,9 @@ patch_enable ()
server-PeekMessage)
enable_server_PeekMessage="$2"
;;
server-Realtime_Priority)
enable_server_Realtime_Priority="$2"
;;
server-Registry_Notifications)
enable_server_Registry_Notifications="$2"
;;
@ -1505,6 +1517,13 @@ if test "$enable_shell32_Progress_Dialog" -eq 1; then
enable_shell32_SHFileOperation_Move=1
fi
if test "$enable_server_Realtime_Priority" -eq 1; then
if test "$enable_ntdll_ThreadTime" -gt 1; then
abort "Patchset ntdll-ThreadTime disabled, but server-Realtime_Priority depends on that."
fi
enable_ntdll_ThreadTime=1
fi
if test "$enable_server_Object_Types" -eq 1; then
if test "$enable_ntdll_SystemModuleInformation" -gt 1; then
abort "Patchset ntdll-SystemModuleInformation disabled, but server-Object_Types depends on that."
@ -1586,6 +1605,17 @@ if test "$enable_ntdll_Junction_Points" -eq 1; then
enable_ntdll_DOS_Attributes=1
fi
if test "$enable_ntdll_Hide_Wine_Exports" -eq 1; then
if test "$enable_advapi32_Token_Integrity_Level" -gt 1; then
abort "Patchset advapi32-Token_Integrity_Level disabled, but ntdll-Hide_Wine_Exports depends on that."
fi
if test "$enable_ntdll_ThreadTime" -gt 1; then
abort "Patchset ntdll-ThreadTime disabled, but ntdll-Hide_Wine_Exports depends on that."
fi
enable_advapi32_Token_Integrity_Level=1
enable_ntdll_ThreadTime=1
fi
if test "$enable_ntdll_Builtin_Prot" -eq 1; then
if test "$enable_ntdll_WRITECOPY" -gt 1; then
abort "Patchset ntdll-WRITECOPY disabled, but ntdll-Builtin_Prot depends on that."
@ -3573,6 +3603,38 @@ if test "$enable_ntdll_Heap_Improvements" -eq 1; then
) >> "$patchlist"
fi
# Patchset ntdll-ThreadTime
# |
# | Modified files:
# | * dlls/ntdll/unix/system.c, server/protocol.def, server/snapshot.c, server/thread.h
# |
if test "$enable_ntdll_ThreadTime" -eq 1; then
patch_apply ntdll-ThreadTime/0002-ntdll-Set-correct-thread-creation-time-for-SystemPro.patch
patch_apply ntdll-ThreadTime/0004-ntdll-Set-process-start-time.patch
(
printf '%s\n' '+ { "Michael Müller", "ntdll: Set correct thread creation time for SystemProcessInformation in NtQuerySystemInformation.", 1 },';
printf '%s\n' '+ { "Michael Müller", "ntdll: Set process start time.", 1 },';
) >> "$patchlist"
fi
# Patchset ntdll-Hide_Wine_Exports
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * Staging, advapi32-CreateRestrictedToken, advapi32-Token_Integrity_Level, ntdll-ThreadTime
# |
# | This patchset fixes the following Wine bugs:
# | * [#38656] Add support for hiding wine version information from applications
# |
# | Modified files:
# | * dlls/ntdll/loader.c, dlls/ntdll/ntdll_misc.h
# |
if test "$enable_ntdll_Hide_Wine_Exports" -eq 1; then
patch_apply ntdll-Hide_Wine_Exports/0001-ntdll-Add-support-for-hiding-wine-version-informatio.patch
(
printf '%s\n' '+ { "Sebastian Lackner", "ntdll: Add support for hiding wine version information from applications.", 1 },';
) >> "$patchlist"
fi
# Patchset ntdll-Interrupt-0x2e
# |
# | This patchset fixes the following Wine bugs:
@ -4393,6 +4455,21 @@ if test "$enable_server_PeekMessage" -eq 1; then
) >> "$patchlist"
fi
# Patchset server-Realtime_Priority
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * ntdll-ThreadTime
# |
# | Modified files:
# | * server/Makefile.in, server/main.c, server/scheduler.c, server/thread.c, server/thread.h
# |
if test "$enable_server_Realtime_Priority" -eq 1; then
patch_apply server-Realtime_Priority/0001-wineserver-Draft-to-implement-priority-levels-throug.patch
(
printf '%s\n' '+ { "Joakim Hernberg", "wineserver: Draft to implement priority levels through POSIX scheduling policies on linux.", 1 },';
) >> "$patchlist"
fi
# Patchset server-Registry_Notifications
# |
# | Modified files:

View File

@ -1,4 +1,4 @@
From c85f5ea67bddac0afecdf6d0cd54bf3c6c4df42d Mon Sep 17 00:00:00 2001
From 98bc215910ff978093b666607f2cff3f1c93b7d3 Mon Sep 17 00:00:00 2001
From: Joakim Hernberg <jhernberg@alchemy.lu>
Date: Tue, 31 Mar 2015 20:58:20 +0200
Subject: [PATCH] wineserver: Draft to implement priority levels through POSIX
@ -215,10 +215,10 @@ index 00000000000..4a5d82b208d
+
+#endif
diff --git a/server/thread.c b/server/thread.c
index d6d80a9a864..f161c8f3e24 100644
index 23c0538150f..7feda374487 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -539,7 +539,10 @@ static void set_thread_info( struct thread *thread,
@@ -607,7 +607,10 @@ static void set_thread_info( struct thread *thread,
if ((req->priority >= min && req->priority <= max) ||
req->priority == THREAD_PRIORITY_IDLE ||
req->priority == THREAD_PRIORITY_TIME_CRITICAL)
@ -230,11 +230,11 @@ index d6d80a9a864..f161c8f3e24 100644
set_error( STATUS_INVALID_PARAMETER );
}
diff --git a/server/thread.h b/server/thread.h
index 26dbc494f3c..7957557b6cc 100644
index 43b17534693..924f28a8697 100644
--- a/server/thread.h
+++ b/server/thread.h
@@ -154,4 +154,9 @@ static inline thread_id_t get_thread_id( struct thread *thread ) { return thread
static inline int get_thread_unix_tid( struct thread *thread ) { return thread->unix_tid; }
@@ -152,4 +152,9 @@ static inline void set_win32_error( unsigned int err ) { set_error( 0xc0010000 |
static inline thread_id_t get_thread_id( struct thread *thread ) { return thread->id; }
static inline timeout_t get_thread_creation_time( struct thread *thread ) { return thread->creation_time; }
+/* scheduler functions */
@ -244,5 +244,5 @@ index 26dbc494f3c..7957557b6cc 100644
+
#endif /* __WINE_SERVER_THREAD_H */
--
2.26.0
2.27.0

View File

@ -1,4 +1,2 @@
Fixes: Support for linux priority levels for faster performance
Depends: ntdll-ThreadTime
# Re-enable me when ntdll-ThreadTime gets re-enabled!
Disabled: true