- Added ProcessBasicInformation class to ntdll.NtQueryInformationProcess.

- Make use of it in kernel32.
This commit is contained in:
Eric Pouech 2004-06-14 17:02:00 +00:00 committed by Alexandre Julliard
parent 552b06a0a4
commit b0fd2ade62
6 changed files with 60 additions and 28 deletions

View File

@ -2079,15 +2079,18 @@ BOOL WINAPI GetExitCodeProcess(
HANDLE hProcess, /* [in] handle to the process */ HANDLE hProcess, /* [in] handle to the process */
LPDWORD lpExitCode) /* [out] address to receive termination status */ LPDWORD lpExitCode) /* [out] address to receive termination status */
{ {
BOOL ret; NTSTATUS status;
SERVER_START_REQ( get_process_info ) PROCESS_BASIC_INFORMATION pbi;
status = NtQueryInformationProcess(hProcess, ProcessBasicInformation, &pbi,
sizeof(pbi), NULL);
if (status == STATUS_SUCCESS)
{ {
req->handle = hProcess; if (lpExitCode) *lpExitCode = pbi.ExitStatus;
ret = !wine_server_call_err( req ); return TRUE;
if (ret && lpExitCode) *lpExitCode = reply->exit_code;
} }
SERVER_END_REQ; SetLastError( RtlNtStatusToDosError(status) );
return ret; return FALSE;
} }
@ -2357,16 +2360,16 @@ HANDLE WINAPI OpenProcess( DWORD access, BOOL inherit, DWORD id )
/********************************************************************* /*********************************************************************
* MapProcessHandle (KERNEL.483) * MapProcessHandle (KERNEL.483)
*/ */
DWORD WINAPI MapProcessHandle( HANDLE handle ) DWORD WINAPI MapProcessHandle( HANDLE hProcess )
{ {
DWORD ret = 0; NTSTATUS status;
SERVER_START_REQ( get_process_info ) PROCESS_BASIC_INFORMATION pbi;
{
req->handle = handle; status = NtQueryInformationProcess(hProcess, ProcessBasicInformation, &pbi,
if (!wine_server_call_err( req )) ret = reply->pid; sizeof(pbi), NULL);
} if (status == STATUS_SUCCESS) return pbi.UniqueProcessId;
SERVER_END_REQ; SetLastError( RtlNtStatusToDosError(status) );
return ret; return 0;
} }
@ -2530,16 +2533,16 @@ BOOL WINAPI SetPriorityClass( HANDLE hprocess, DWORD priorityclass )
/*********************************************************************** /***********************************************************************
* GetPriorityClass (KERNEL32.@) * GetPriorityClass (KERNEL32.@)
*/ */
DWORD WINAPI GetPriorityClass(HANDLE hprocess) DWORD WINAPI GetPriorityClass(HANDLE hProcess)
{ {
DWORD ret = 0; NTSTATUS status;
SERVER_START_REQ( get_process_info ) PROCESS_BASIC_INFORMATION pbi;
{
req->handle = hprocess; status = NtQueryInformationProcess(hProcess, ProcessBasicInformation, &pbi,
if (!wine_server_call_err( req )) ret = reply->priority; sizeof(pbi), NULL);
} if (status == STATUS_SUCCESS) return pbi.BasePriority;
SERVER_END_REQ; SetLastError( RtlNtStatusToDosError(status) );
return ret; return 0;
} }

View File

@ -79,6 +79,27 @@ NTSTATUS WINAPI NtQueryInformationProcess(
switch (ProcessInformationClass) switch (ProcessInformationClass)
{ {
case ProcessBasicInformation:
if (ProcessInformationLength == sizeof(PROCESS_BASIC_INFORMATION))
{
SERVER_START_REQ(get_process_info)
{
req->handle = ProcessHandle;
if ((ret = wine_server_call( req )) == STATUS_SUCCESS)
{
PROCESS_BASIC_INFORMATION* pbi = (PROCESS_BASIC_INFORMATION*)ProcessInformation;
pbi->ExitStatus = reply->exit_code;
pbi->PebBaseAddress = (DWORD)reply->peb;
pbi->AffinityMask = reply->process_affinity;
pbi->BasePriority = reply->priority;
pbi->UniqueProcessId = reply->pid;
pbi->InheritedFromUniqueProcessId = reply->ppid;
}
}
SERVER_END_REQ;
}
else ret = STATUS_INFO_LENGTH_MISMATCH;
break;
case ProcessIoCounters: case ProcessIoCounters:
if (ProcessInformationLength == sizeof(IO_COUNTERS)) if (ProcessInformationLength == sizeof(IO_COUNTERS))
{ {

View File

@ -342,10 +342,12 @@ struct get_process_info_reply
{ {
struct reply_header __header; struct reply_header __header;
process_id_t pid; process_id_t pid;
process_id_t ppid;
int exit_code; int exit_code;
int priority; int priority;
int process_affinity; int process_affinity;
int system_affinity; int system_affinity;
void* peb;
}; };
@ -3572,6 +3574,6 @@ union generic_reply
struct set_global_windows_reply set_global_windows_reply; struct set_global_windows_reply set_global_windows_reply;
}; };
#define SERVER_PROTOCOL_VERSION 142 #define SERVER_PROTOCOL_VERSION 143
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */ #endif /* __WINE_WINE_SERVER_PROTOCOL_H */

View File

@ -1043,10 +1043,12 @@ DECL_HANDLER(get_process_info)
if ((process = get_process_from_handle( req->handle, PROCESS_QUERY_INFORMATION ))) if ((process = get_process_from_handle( req->handle, PROCESS_QUERY_INFORMATION )))
{ {
reply->pid = get_process_id( process ); reply->pid = get_process_id( process );
reply->ppid = process->parent ? get_process_id( process->parent ) : 0;
reply->exit_code = process->exit_code; reply->exit_code = process->exit_code;
reply->priority = process->priority; reply->priority = process->priority;
reply->process_affinity = process->affinity; reply->process_affinity = process->affinity;
reply->system_affinity = 1; reply->system_affinity = 1;
reply->peb = process->peb;
release_object( process ); release_object( process );
} }
} }

View File

@ -301,10 +301,12 @@ typedef struct
obj_handle_t handle; /* process handle */ obj_handle_t handle; /* process handle */
@REPLY @REPLY
process_id_t pid; /* server process id */ process_id_t pid; /* server process id */
process_id_t ppid; /* server process id of parent */
int exit_code; /* process exit code */ int exit_code; /* process exit code */
int priority; /* priority class */ int priority; /* priority class */
int process_affinity; /* process affinity mask */ int process_affinity; /* process affinity mask */
int system_affinity; /* system affinity mask */ int system_affinity; /* system affinity mask */
void* peb; /* PEB address in process address space */
@END @END

View File

@ -537,10 +537,12 @@ static void dump_get_process_info_request( const struct get_process_info_request
static void dump_get_process_info_reply( const struct get_process_info_reply *req ) static void dump_get_process_info_reply( const struct get_process_info_reply *req )
{ {
fprintf( stderr, " pid=%04x,", req->pid ); fprintf( stderr, " pid=%04x,", req->pid );
fprintf( stderr, " ppid=%04x,", req->ppid );
fprintf( stderr, " exit_code=%d,", req->exit_code ); fprintf( stderr, " exit_code=%d,", req->exit_code );
fprintf( stderr, " priority=%d,", req->priority ); fprintf( stderr, " priority=%d,", req->priority );
fprintf( stderr, " process_affinity=%d,", req->process_affinity ); fprintf( stderr, " process_affinity=%d,", req->process_affinity );
fprintf( stderr, " system_affinity=%d", req->system_affinity ); fprintf( stderr, " system_affinity=%d,", req->system_affinity );
fprintf( stderr, " peb=%p", req->peb );
} }
static void dump_set_process_info_request( const struct set_process_info_request *req ) static void dump_set_process_info_request( const struct set_process_info_request *req )