Commit b0fd2ade authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

- Added ProcessBasicInformation class to ntdll.NtQueryInformationProcess.

- Make use of it in kernel32.
parent 552b06a0
......@@ -2079,15 +2079,18 @@ BOOL WINAPI GetExitCodeProcess(
HANDLE hProcess, /* [in] handle to the process */
LPDWORD lpExitCode) /* [out] address to receive termination status */
{
BOOL ret;
SERVER_START_REQ( get_process_info )
NTSTATUS status;
PROCESS_BASIC_INFORMATION pbi;
status = NtQueryInformationProcess(hProcess, ProcessBasicInformation, &pbi,
sizeof(pbi), NULL);
if (status == STATUS_SUCCESS)
{
req->handle = hProcess;
ret = !wine_server_call_err( req );
if (ret && lpExitCode) *lpExitCode = reply->exit_code;
if (lpExitCode) *lpExitCode = pbi.ExitStatus;
return TRUE;
}
SERVER_END_REQ;
return ret;
SetLastError( RtlNtStatusToDosError(status) );
return FALSE;
}
......@@ -2357,16 +2360,16 @@ HANDLE WINAPI OpenProcess( DWORD access, BOOL inherit, DWORD id )
/*********************************************************************
* MapProcessHandle (KERNEL.483)
*/
DWORD WINAPI MapProcessHandle( HANDLE handle )
DWORD WINAPI MapProcessHandle( HANDLE hProcess )
{
DWORD ret = 0;
SERVER_START_REQ( get_process_info )
{
req->handle = handle;
if (!wine_server_call_err( req )) ret = reply->pid;
}
SERVER_END_REQ;
return ret;
NTSTATUS status;
PROCESS_BASIC_INFORMATION pbi;
status = NtQueryInformationProcess(hProcess, ProcessBasicInformation, &pbi,
sizeof(pbi), NULL);
if (status == STATUS_SUCCESS) return pbi.UniqueProcessId;
SetLastError( RtlNtStatusToDosError(status) );
return 0;
}
......@@ -2530,16 +2533,16 @@ BOOL WINAPI SetPriorityClass( HANDLE hprocess, DWORD priorityclass )
/***********************************************************************
* GetPriorityClass (KERNEL32.@)
*/
DWORD WINAPI GetPriorityClass(HANDLE hprocess)
DWORD WINAPI GetPriorityClass(HANDLE hProcess)
{
DWORD ret = 0;
SERVER_START_REQ( get_process_info )
{
req->handle = hprocess;
if (!wine_server_call_err( req )) ret = reply->priority;
}
SERVER_END_REQ;
return ret;
NTSTATUS status;
PROCESS_BASIC_INFORMATION pbi;
status = NtQueryInformationProcess(hProcess, ProcessBasicInformation, &pbi,
sizeof(pbi), NULL);
if (status == STATUS_SUCCESS) return pbi.BasePriority;
SetLastError( RtlNtStatusToDosError(status) );
return 0;
}
......
......@@ -79,6 +79,27 @@ NTSTATUS WINAPI NtQueryInformationProcess(
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:
if (ProcessInformationLength == sizeof(IO_COUNTERS))
{
......@@ -92,7 +113,7 @@ NTSTATUS WINAPI NtQueryInformationProcess(
* set it to 0 aka "no debugger" to satisfy copy protections */
if (ProcessInformationLength == 4)
{
memset(ProcessInformation, 0 ,ProcessInformationLength);
memset(ProcessInformation, 0, ProcessInformationLength);
len = 4;
}
else ret = STATUS_INFO_LENGTH_MISMATCH;
......
......@@ -342,10 +342,12 @@ struct get_process_info_reply
{
struct reply_header __header;
process_id_t pid;
process_id_t ppid;
int exit_code;
int priority;
int process_affinity;
int system_affinity;
void* peb;
};
......@@ -3572,6 +3574,6 @@ union generic_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 */
......@@ -1043,10 +1043,12 @@ DECL_HANDLER(get_process_info)
if ((process = get_process_from_handle( req->handle, PROCESS_QUERY_INFORMATION )))
{
reply->pid = get_process_id( process );
reply->ppid = process->parent ? get_process_id( process->parent ) : 0;
reply->exit_code = process->exit_code;
reply->priority = process->priority;
reply->process_affinity = process->affinity;
reply->system_affinity = 1;
reply->peb = process->peb;
release_object( process );
}
}
......
......@@ -301,10 +301,12 @@ typedef struct
obj_handle_t handle; /* process handle */
@REPLY
process_id_t pid; /* server process id */
process_id_t ppid; /* server process id of parent */
int exit_code; /* process exit code */
int priority; /* priority class */
int process_affinity; /* process affinity mask */
int system_affinity; /* system affinity mask */
void* peb; /* PEB address in process address space */
@END
......
......@@ -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 )
{
fprintf( stderr, " pid=%04x,", req->pid );
fprintf( stderr, " ppid=%04x,", req->ppid );
fprintf( stderr, " exit_code=%d,", req->exit_code );
fprintf( stderr, " priority=%d,", req->priority );
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 )
......
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