From 82cd676a72085b9deb44ce83c6b93f969459a198 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sun, 19 Mar 2017 19:40:52 +0100 Subject: [PATCH] Added patch to return user/kernel times for threads and processes in NtQuerySystemInformation. --- ...t-for-hiding-wine-version-informatio.patch | 20 ++- patches/ntdll-Hide_Wine_Exports/definition | 1 + ...-thread-creation-time-for-SystemPro.patch} | 0 ...ll-Fill-process-kernel-and-user-time.patch | 159 ++++++++++++++++++ .../0004-ntdll-Set-process-start-time.patch | 64 +++++++ ...-thread-times-in-process-enumeration.patch | 82 +++++++++ patches/ntdll-ThreadTime/definition | 1 + patches/ntdll-Thread_Creation_Time/definition | 1 - patches/patchinstall.sh | 69 ++++---- ...-to-implement-priority-levels-throug.patch | 16 +- patches/server-Realtime_Priority/definition | 2 +- 11 files changed, 360 insertions(+), 55 deletions(-) rename patches/{ntdll-Thread_Creation_Time/0001-ntdll-Set-correct-thread-creation-time-for-SystemPro.patch => ntdll-ThreadTime/0002-ntdll-Set-correct-thread-creation-time-for-SystemPro.patch} (100%) create mode 100644 patches/ntdll-ThreadTime/0003-ntdll-Fill-process-kernel-and-user-time.patch create mode 100644 patches/ntdll-ThreadTime/0004-ntdll-Set-process-start-time.patch create mode 100644 patches/ntdll-ThreadTime/0005-ntdll-Fill-out-thread-times-in-process-enumeration.patch delete mode 100644 patches/ntdll-Thread_Creation_Time/definition diff --git a/patches/ntdll-Hide_Wine_Exports/0001-ntdll-Add-support-for-hiding-wine-version-informatio.patch b/patches/ntdll-Hide_Wine_Exports/0001-ntdll-Add-support-for-hiding-wine-version-informatio.patch index 91576c31..c0d808df 100644 --- a/patches/ntdll-Hide_Wine_Exports/0001-ntdll-Add-support-for-hiding-wine-version-informatio.patch +++ b/patches/ntdll-Hide_Wine_Exports/0001-ntdll-Add-support-for-hiding-wine-version-informatio.patch @@ -1,4 +1,4 @@ -From d804ddb4f49172915b88eb048cfe532a96eb41df Mon Sep 17 00:00:00 2001 +From 41a15135b0c1894724c1c91311faa255ad96d732 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sat, 30 May 2015 02:23:15 +0200 Subject: ntdll: Add support for hiding wine version information from @@ -10,7 +10,7 @@ Subject: ntdll: Add support for hiding wine version information from 2 files changed, 100 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c -index 130d154..d84e156 100644 +index b95b8852aa..1c0ba6161d 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -63,9 +63,12 @@ WINE_DECLARE_DEBUG_CHANNEL(pid); @@ -26,7 +26,7 @@ index 130d154..d84e156 100644 static const char * const reason_names[] = { -@@ -1543,6 +1546,96 @@ NTSTATUS WINAPI LdrUnlockLoaderLock( ULONG flags, ULONG_PTR magic ) +@@ -1456,6 +1459,96 @@ NTSTATUS WINAPI LdrUnlockLoaderLock( ULONG flags, ULONG_PTR magic ) } @@ -123,7 +123,7 @@ index 130d154..d84e156 100644 /****************************************************************** * LdrGetProcedureAddress (NTDLL.@) */ -@@ -1563,7 +1656,7 @@ NTSTATUS WINAPI LdrGetProcedureAddress(HMODULE module, const ANSI_STRING *name, +@@ -1476,7 +1569,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 ); @@ -132,7 +132,7 @@ index 130d154..d84e156 100644 { *address = proc; ret = STATUS_SUCCESS; -@@ -3198,6 +3291,7 @@ void WINAPI LdrInitializeThunk( void *kernel_start, ULONG_PTR unknown2, +@@ -3099,6 +3192,7 @@ void WINAPI LdrInitializeThunk( void *kernel_start, ULONG_PTR unknown2, if (!peb->ProcessParameters->WindowTitle.Buffer) peb->ProcessParameters->WindowTitle = wm->ldr.FullDllName; version_init( wm->ldr.FullDllName.Buffer ); @@ -141,10 +141,10 @@ index 130d154..d84e156 100644 LdrQueryImageFileExecutionOptions( &peb->ProcessParameters->ImagePathName, globalflagW, diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h -index 5e4c39e..723c3d8 100644 +index 443c86000d..ba4adff249 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h -@@ -266,4 +266,9 @@ extern HANDLE keyed_event DECLSPEC_HIDDEN; +@@ -266,6 +266,11 @@ extern HANDLE keyed_event DECLSPEC_HIDDEN; NTSTATUS WINAPI RtlHashUnicodeString(PCUNICODE_STRING,BOOLEAN,ULONG,ULONG*); @@ -153,7 +153,9 @@ index 5e4c39e..723c3d8 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 ); + - #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; -- -2.8.0 +2.11.0 diff --git a/patches/ntdll-Hide_Wine_Exports/definition b/patches/ntdll-Hide_Wine_Exports/definition index 009161df..aa1866de 100644 --- a/patches/ntdll-Hide_Wine_Exports/definition +++ b/patches/ntdll-Hide_Wine_Exports/definition @@ -1,2 +1,3 @@ Fixes: [38656] Add support for hiding wine version information from applications Depends: ntdll-Attach_Process_DLLs +Depends: ntdll-ThreadTime diff --git a/patches/ntdll-Thread_Creation_Time/0001-ntdll-Set-correct-thread-creation-time-for-SystemPro.patch b/patches/ntdll-ThreadTime/0002-ntdll-Set-correct-thread-creation-time-for-SystemPro.patch similarity index 100% rename from patches/ntdll-Thread_Creation_Time/0001-ntdll-Set-correct-thread-creation-time-for-SystemPro.patch rename to patches/ntdll-ThreadTime/0002-ntdll-Set-correct-thread-creation-time-for-SystemPro.patch diff --git a/patches/ntdll-ThreadTime/0003-ntdll-Fill-process-kernel-and-user-time.patch b/patches/ntdll-ThreadTime/0003-ntdll-Fill-process-kernel-and-user-time.patch new file mode 100644 index 00000000..d833fd0c --- /dev/null +++ b/patches/ntdll-ThreadTime/0003-ntdll-Fill-process-kernel-and-user-time.patch @@ -0,0 +1,159 @@ +From 2578dfb02f0a8781970f5c7d967b1d07ae433e2f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Michael=20M=C3=BCller?= +Date: Thu, 9 Mar 2017 16:27:23 +0100 +Subject: ntdll: Fill process kernel and user time. + +--- + dlls/ntdll/nt.c | 6 +++- + dlls/ntdll/ntdll_misc.h | 3 ++ + dlls/ntdll/thread.c | 84 ++++++++++++++++++++++++++++--------------------- + 3 files changed, 56 insertions(+), 37 deletions(-) + +diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c +index fc8e3b1eb4..6b67397471 100644 +--- a/dlls/ntdll/nt.c ++++ b/dlls/ntdll/nt.c +@@ -1922,6 +1922,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; +@@ -1959,7 +1960,7 @@ NTSTATUS WINAPI NtQuerySystemInformation( + + if (Length >= len + procstructlen) + { +- /* ftCreationTime, ftUserTime, ftKernelTime; ++ /* ftCreationTime; + * vmCounters, ioCounters + */ + +@@ -1977,6 +1978,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 5e4c39e8bd..443c86000d 100644 +--- a/dlls/ntdll/ntdll_misc.h ++++ b/dlls/ntdll/ntdll_misc.h +@@ -266,4 +266,7 @@ extern HANDLE keyed_event DECLSPEC_HIDDEN; + + NTSTATUS WINAPI RtlHashUnicodeString(PCUNICODE_STRING,BOOLEAN,ULONG,ULONG*); + ++/* 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; + #endif +diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c +index 91a59517b3..29b6513f38 100644 +--- a/dlls/ntdll/thread.c ++++ b/dlls/ntdll/thread.c +@@ -71,6 +71,53 @@ static RTL_BITMAP tls_expansion_bitmap; + static RTL_BITMAP fls_bitmap; + static int nb_threads = 1; + ++ ++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; ++} ++ ++ + /*********************************************************************** + * get_unicode_string + * +@@ -1009,42 +1056,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.11.0 + diff --git a/patches/ntdll-ThreadTime/0004-ntdll-Set-process-start-time.patch b/patches/ntdll-ThreadTime/0004-ntdll-Set-process-start-time.patch new file mode 100644 index 00000000..e905d254 --- /dev/null +++ b/patches/ntdll-ThreadTime/0004-ntdll-Set-process-start-time.patch @@ -0,0 +1,64 @@ +From e048ad0cd3879fb8f752af7e2eeda770864f9982 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Michael=20M=C3=BCller?= +Date: Thu, 9 Mar 2017 16:32:59 +0100 +Subject: ntdll: Set process start time. + +--- + dlls/ntdll/nt.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; + + /* spi->ti will be set later on */ + +diff --git a/server/protocol.def b/server/protocol.def +index 320e34384a..1347defe70 100644 +--- a/server/protocol.def ++++ b/server/protocol.def +@@ -1808,6 +1808,7 @@ enum char_info_mode + int priority; /* process priority */ + int handles; /* number of handles */ + int unix_pid; /* Unix pid */ ++ timeout_t start_time; /* start time */ + VARARG(filename,unicode_str); /* file name of main exe */ + @END + +diff --git a/server/snapshot.c b/server/snapshot.c +index f2903d522e..e509e0aca9 100644 +--- a/server/snapshot.c ++++ b/server/snapshot.c +@@ -114,13 +114,14 @@ static int snapshot_next_process( struct snapshot *snapshot, struct next_process + return 0; + } + ptr = &snapshot->processes[snapshot->process_pos++]; +- reply->count = ptr->count; +- reply->pid = get_process_id( ptr->process ); +- reply->ppid = ptr->process->parent_id; +- reply->threads = ptr->threads; +- reply->priority = ptr->priority; +- reply->handles = ptr->handles; +- reply->unix_pid = ptr->process->unix_pid; ++ reply->count = ptr->count; ++ reply->pid = get_process_id( ptr->process ); ++ reply->ppid = ptr->process->parent_id; ++ reply->threads = ptr->threads; ++ reply->priority = ptr->priority; ++ reply->handles = ptr->handles; ++ reply->unix_pid = ptr->process->unix_pid; ++ reply->start_time = ptr->process->start_time; + if ((exe_module = get_process_exe_module( ptr->process )) && exe_module->filename) + { + data_size_t len = min( exe_module->namelen, get_reply_max_size() ); +-- +2.11.0 + diff --git a/patches/ntdll-ThreadTime/0005-ntdll-Fill-out-thread-times-in-process-enumeration.patch b/patches/ntdll-ThreadTime/0005-ntdll-Fill-out-thread-times-in-process-enumeration.patch new file mode 100644 index 00000000..0c317b37 --- /dev/null +++ b/patches/ntdll-ThreadTime/0005-ntdll-Fill-out-thread-times-in-process-enumeration.patch @@ -0,0 +1,82 @@ +From 6c3b7e0065c239b488bb224c1c67ff971562fdca Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Michael=20M=C3=BCller?= +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 + diff --git a/patches/ntdll-ThreadTime/definition b/patches/ntdll-ThreadTime/definition index 3458fcfb..f04b9d59 100644 --- a/patches/ntdll-ThreadTime/definition +++ b/patches/ntdll-ThreadTime/definition @@ -1 +1,2 @@ Fixes: [20230] Return correct values for GetThreadTimes function +Fixes: Return correct thread creation time in SystemProcessInformation diff --git a/patches/ntdll-Thread_Creation_Time/definition b/patches/ntdll-Thread_Creation_Time/definition deleted file mode 100644 index 3c6ce41b..00000000 --- a/patches/ntdll-Thread_Creation_Time/definition +++ /dev/null @@ -1 +0,0 @@ -Fixes: Return correct thread creation time in SystemProcessInformation diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index a081300f..4aa6cead 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -263,7 +263,6 @@ patch_enable_all () enable_ntdll_SystemRecommendedSharedDataAlignment="$1" enable_ntdll_SystemRoot_Symlink="$1" enable_ntdll_ThreadTime="$1" - enable_ntdll_Thread_Creation_Time="$1" enable_ntdll_Threading="$1" enable_ntdll_User_Shared_Data="$1" enable_ntdll_WRITECOPY="$1" @@ -1010,9 +1009,6 @@ patch_enable () ntdll-ThreadTime) enable_ntdll_ThreadTime="$2" ;; - ntdll-Thread_Creation_Time) - enable_ntdll_Thread_Creation_Time="$2" - ;; ntdll-Threading) enable_ntdll_Threading="$2" ;; @@ -2158,10 +2154,10 @@ if test "$enable_server_Shared_Memory" -eq 1; then fi if test "$enable_server_Realtime_Priority" -eq 1; then - if test "$enable_ntdll_Thread_Creation_Time" -gt 1; then - abort "Patchset ntdll-Thread_Creation_Time disabled, but server-Realtime_Priority depends on that." + if test "$enable_ntdll_ThreadTime" -gt 1; then + abort "Patchset ntdll-ThreadTime disabled, but server-Realtime_Priority depends on that." fi - enable_ntdll_Thread_Creation_Time=1 + enable_ntdll_ThreadTime=1 fi if test "$enable_server_Pipe_ObjectName" -eq 1; then @@ -2296,7 +2292,11 @@ if test "$enable_ntdll_Hide_Wine_Exports" -eq 1; then if test "$enable_ntdll_Attach_Process_DLLs" -gt 1; then abort "Patchset ntdll-Attach_Process_DLLs 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_ntdll_Attach_Process_DLLs=1 + enable_ntdll_ThreadTime=1 fi if test "$enable_ntdll_DllRedirects" -eq 1; then @@ -5383,10 +5383,34 @@ if test "$enable_ntdll_Heap_FreeLists" -eq 1; then ) >> "$patchlist" fi +# Patchset ntdll-ThreadTime +# | +# | This patchset fixes the following Wine bugs: +# | * [#20230] Return correct values for GetThreadTimes function +# | +# | Modified files: +# | * dlls/ntdll/nt.c, dlls/ntdll/ntdll_misc.h, dlls/ntdll/thread.c, server/protocol.def, server/snapshot.c, server/thread.c, +# | server/thread.h +# | +if test "$enable_ntdll_ThreadTime" -eq 1; then + patch_apply ntdll-ThreadTime/0001-ntdll-Return-correct-values-in-GetThreadTimes-for-al.patch + patch_apply ntdll-ThreadTime/0002-ntdll-Set-correct-thread-creation-time-for-SystemPro.patch + patch_apply ntdll-ThreadTime/0003-ntdll-Fill-process-kernel-and-user-time.patch + patch_apply ntdll-ThreadTime/0004-ntdll-Set-process-start-time.patch + patch_apply ntdll-ThreadTime/0005-ntdll-Fill-out-thread-times-in-process-enumeration.patch + ( + printf '%s\n' '+ { "Sebastian Lackner", "ntdll: Return correct values in GetThreadTimes() for all threads.", 1 },'; + printf '%s\n' '+ { "Michael Müller", "ntdll: Set correct thread creation time for SystemProcessInformation in NtQuerySystemInformation.", 1 },'; + printf '%s\n' '+ { "Michael Müller", "ntdll: Fill process kernel and user time.", 1 },'; + printf '%s\n' '+ { "Michael Müller", "ntdll: Set process start time.", 1 },'; + printf '%s\n' '+ { "Michael Müller", "ntdll: Fill out thread times in process enumeration.", 1 },'; + ) >> "$patchlist" +fi + # Patchset ntdll-Hide_Wine_Exports # | # | This patchset has the following (direct or indirect) dependencies: -# | * ntdll-Attach_Process_DLLs +# | * ntdll-Attach_Process_DLLs, ntdll-ThreadTime # | # | This patchset fixes the following Wine bugs: # | * [#38656] Add support for hiding wine version information from applications @@ -5821,33 +5845,6 @@ if test "$enable_ntdll_SystemRoot_Symlink" -eq 1; then ) >> "$patchlist" fi -# Patchset ntdll-ThreadTime -# | -# | This patchset fixes the following Wine bugs: -# | * [#20230] Return correct values for GetThreadTimes function -# | -# | Modified files: -# | * dlls/ntdll/thread.c, server/protocol.def, server/thread.c -# | -if test "$enable_ntdll_ThreadTime" -eq 1; then - patch_apply ntdll-ThreadTime/0001-ntdll-Return-correct-values-in-GetThreadTimes-for-al.patch - ( - printf '%s\n' '+ { "Sebastian Lackner", "ntdll: Return correct values in GetThreadTimes() for all threads.", 1 },'; - ) >> "$patchlist" -fi - -# Patchset ntdll-Thread_Creation_Time -# | -# | Modified files: -# | * dlls/ntdll/nt.c, server/protocol.def, server/snapshot.c, server/thread.h -# | -if test "$enable_ntdll_Thread_Creation_Time" -eq 1; then - patch_apply ntdll-Thread_Creation_Time/0001-ntdll-Set-correct-thread-creation-time-for-SystemPro.patch - ( - printf '%s\n' '+ { "Michael Müller", "ntdll: Set correct thread creation time for SystemProcessInformation in NtQuerySystemInformation.", 1 },'; - ) >> "$patchlist" -fi - # Patchset ntdll-Threading # | # | Modified files: @@ -6704,7 +6701,7 @@ fi # Patchset server-Realtime_Priority # | # | This patchset has the following (direct or indirect) dependencies: -# | * ntdll-Thread_Creation_Time +# | * ntdll-ThreadTime # | # | Modified files: # | * server/Makefile.in, server/main.c, server/scheduler.c, server/thread.c, server/thread.h diff --git a/patches/server-Realtime_Priority/0001-wineserver-Draft-to-implement-priority-levels-throug.patch b/patches/server-Realtime_Priority/0001-wineserver-Draft-to-implement-priority-levels-throug.patch index eaa9c24f..8f75e3c2 100644 --- a/patches/server-Realtime_Priority/0001-wineserver-Draft-to-implement-priority-levels-throug.patch +++ b/patches/server-Realtime_Priority/0001-wineserver-Draft-to-implement-priority-levels-throug.patch @@ -1,4 +1,4 @@ -From ba09eea1a2a4de1e182d1d74ee09fde4c10ee275 Mon Sep 17 00:00:00 2001 +From 25c2aa22c5e33bfe2860d54a4edc50afd357505b Mon Sep 17 00:00:00 2001 From: Joakim Hernberg Date: Tue, 31 Mar 2015 20:58:20 +0200 Subject: wineserver: Draft to implement priority levels through POSIX @@ -19,7 +19,7 @@ Changes by Sebastian Lackner : create mode 100644 server/scheduler.c diff --git a/server/Makefile.in b/server/Makefile.in -index 75ba1997c80..e539110cf35 100644 +index 75ba1997c8..e539110cf3 100644 --- a/server/Makefile.in +++ b/server/Makefile.in @@ -30,6 +30,7 @@ C_SRCS = \ @@ -31,7 +31,7 @@ index 75ba1997c80..e539110cf35 100644 serial.c \ signal.c \ diff --git a/server/main.c b/server/main.c -index 7aed338e968..ee8cadde5da 100644 +index 7aed338e96..ee8cadde5d 100644 --- a/server/main.c +++ b/server/main.c @@ -44,6 +44,7 @@ int foreground = 0; @@ -52,7 +52,7 @@ index 7aed338e968..ee8cadde5da 100644 init_registry(); diff --git a/server/scheduler.c b/server/scheduler.c new file mode 100644 -index 00000000000..2fca9661925 +index 0000000000..2fca966192 --- /dev/null +++ b/server/scheduler.c @@ -0,0 +1,163 @@ @@ -220,7 +220,7 @@ index 00000000000..2fca9661925 + +#endif diff --git a/server/thread.c b/server/thread.c -index 67f976d33c3..3e6dc1491f1 100644 +index 4a1c99838c..754b6fbd27 100644 --- a/server/thread.c +++ b/server/thread.c @@ -490,7 +490,10 @@ static void set_thread_info( struct thread *thread, @@ -235,11 +235,11 @@ index 67f976d33c3..3e6dc1491f1 100644 set_error( STATUS_INVALID_PARAMETER ); } diff --git a/server/thread.h b/server/thread.h -index 2098c76a472..25f705b2838 100644 +index 9614e2140d..8d075dacb6 100644 --- a/server/thread.h +++ b/server/thread.h -@@ -147,4 +147,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; } +@@ -148,4 +148,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; } static inline timeout_t get_thread_creation_time( struct thread *thread ) { return thread->creation_time; } +/* scheduler functions */ diff --git a/patches/server-Realtime_Priority/definition b/patches/server-Realtime_Priority/definition index e475a91f..de7045a9 100644 --- a/patches/server-Realtime_Priority/definition +++ b/patches/server-Realtime_Priority/definition @@ -1,2 +1,2 @@ Fixes: Support for linux priority levels for faster performance -Depends: ntdll-Thread_Creation_Time +Depends: ntdll-ThreadTime