Commit 69e9651c authored by Michael Müller's avatar Michael Müller Committed by Alexandre Julliard

ntdll: Return thread times in NtQuerySystemInformation(SystemProcessInformation).

parent 847b93c7
......@@ -2101,6 +2101,7 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class,
len = 0;
while (ret == STATUS_SUCCESS)
{
int unix_pid = -1;
SERVER_START_REQ( next_process )
{
req->handle = wine_server_obj_handle( handle );
......@@ -2108,6 +2109,8 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class,
wine_server_set_reply( req, procname, sizeof(procname) - sizeof(WCHAR) );
if (!(ret = wine_server_call( req )))
{
unix_pid = reply->unix_pid;
/* Make sure procname is 0 terminated */
procname[wine_server_reply_size(reply) / sizeof(WCHAR)] = 0;
......@@ -2156,31 +2159,38 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class,
i = j = 0;
while (ret == STATUS_SUCCESS)
{
int unix_tid, pid, tid, base_pri, delta_pri;
SERVER_START_REQ( next_thread )
{
req->handle = wine_server_obj_handle( handle );
req->reset = (j == 0);
if (!(ret = wine_server_call( req )))
{
unix_tid = reply->unix_tid;
pid = reply->pid;
tid = reply->tid;
base_pri = reply->base_pri;
delta_pri = reply->delta_pri;
j++;
if (UlongToHandle(reply->pid) == spi->UniqueProcessId)
{
/* ftKernelTime, ftUserTime, ftCreateTime;
* dwTickCount, dwStartAddress
*/
memset(&spi->ti[i], 0, sizeof(spi->ti));
spi->ti[i].CreateTime.QuadPart = 0xdeadbeef;
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].dwBasePriority = reply->base_pri;
i++;
}
}
}
SERVER_END_REQ;
if (!ret)
{
if (UlongToHandle(pid) == spi->UniqueProcessId)
{
memset(&spi->ti[i], 0, sizeof(spi->ti));
spi->ti[i].CreateTime.QuadPart = 0xdeadbeef;
spi->ti[i].ClientId.UniqueProcess = UlongToHandle(pid);
spi->ti[i].ClientId.UniqueThread = UlongToHandle(tid);
spi->ti[i].dwCurrentPriority = base_pri + delta_pri;
spi->ti[i].dwBasePriority = base_pri;
get_thread_times(unix_pid, unix_tid, &spi->ti[i].KernelTime, &spi->ti[i].UserTime);
i++;
}
}
}
if (ret == STATUS_NO_MORE_FILES) ret = STATUS_SUCCESS;
......
......@@ -824,7 +824,7 @@ static void wow64_context_to_server( context_t *to, const WOW64_CONTEXT *from )
#endif /* __x86_64__ */
#ifdef linux
static BOOL get_thread_times(int unix_pid, int unix_tid, LARGE_INTEGER *kernel_time, LARGE_INTEGER *user_time)
BOOL get_thread_times(int unix_pid, int unix_tid, LARGE_INTEGER *kernel_time, LARGE_INTEGER *user_time)
{
unsigned long clocks_per_sec = sysconf( _SC_CLK_TCK );
unsigned long usr, sys;
......@@ -869,7 +869,7 @@ static BOOL get_thread_times(int unix_pid, int unix_tid, LARGE_INTEGER *kernel_t
return FALSE;
}
#else
static BOOL get_thread_times(int unix_pid, int unix_tid, LARGE_INTEGER *kernel_time, LARGE_INTEGER *user_time)
BOOL get_thread_times(int unix_pid, int unix_tid, LARGE_INTEGER *kernel_time, LARGE_INTEGER *user_time)
{
static int once;
if (!once++) FIXME("not implemented on this platform\n");
......
......@@ -209,6 +209,8 @@ extern void virtual_fill_image_information( const pe_image_info_t *pe_info,
SECTION_IMAGE_INFORMATION *info ) DECLSPEC_HIDDEN;
extern NTSTATUS get_thread_ldt_entry( HANDLE handle, void *data, ULONG len, ULONG *ret_len ) DECLSPEC_HIDDEN;
extern BOOL get_thread_times( int unix_pid, int unix_tid, LARGE_INTEGER *kernel_time,
LARGE_INTEGER *user_time ) DECLSPEC_HIDDEN;
extern void signal_init_threading(void) DECLSPEC_HIDDEN;
extern NTSTATUS signal_alloc_thread( TEB *teb ) DECLSPEC_HIDDEN;
extern void signal_free_thread( TEB *teb ) DECLSPEC_HIDDEN;
......
......@@ -2493,7 +2493,7 @@ struct next_thread_reply
thread_id_t tid;
int base_pri;
int delta_pri;
char __pad_28[4];
int unix_tid;
};
......@@ -6702,7 +6702,7 @@ union generic_reply
/* ### protocol_version begin ### */
#define SERVER_PROTOCOL_VERSION 610
#define SERVER_PROTOCOL_VERSION 611
/* ### protocol_version end ### */
......
......@@ -1913,6 +1913,7 @@ enum char_info_mode
thread_id_t tid; /* thread id */
int base_pri; /* base priority */
int delta_pri; /* delta priority */
int unix_tid; /* thread native pid */
@END
......
......@@ -1362,6 +1362,7 @@ C_ASSERT( FIELD_OFFSET(struct next_thread_reply, pid) == 12 );
C_ASSERT( FIELD_OFFSET(struct next_thread_reply, tid) == 16 );
C_ASSERT( FIELD_OFFSET(struct next_thread_reply, base_pri) == 20 );
C_ASSERT( FIELD_OFFSET(struct next_thread_reply, delta_pri) == 24 );
C_ASSERT( FIELD_OFFSET(struct next_thread_reply, unix_tid) == 28 );
C_ASSERT( sizeof(struct next_thread_reply) == 32 );
C_ASSERT( FIELD_OFFSET(struct wait_debug_event_request, get_handle) == 12 );
C_ASSERT( sizeof(struct wait_debug_event_request) == 16 );
......
......@@ -150,6 +150,7 @@ static int snapshot_next_thread( struct snapshot *snapshot, struct next_thread_r
reply->tid = get_thread_id( ptr->thread );
reply->base_pri = ptr->priority;
reply->delta_pri = 0; /* FIXME */
reply->unix_tid = ptr->thread->unix_tid;
return 1;
}
......
......@@ -2412,6 +2412,7 @@ static void dump_next_thread_reply( const struct next_thread_reply *req )
fprintf( stderr, ", tid=%04x", req->tid );
fprintf( stderr, ", base_pri=%d", req->base_pri );
fprintf( stderr, ", delta_pri=%d", req->delta_pri );
fprintf( stderr, ", unix_tid=%d", req->unix_tid );
}
static void dump_wait_debug_event_request( const struct wait_debug_event_request *req )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment