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

- rewrite kernel32:{Set|Get}PriorityClass on top of ntdll equivalent

- priority for process in wineserver is now the NTDLL form (no longer the kernel32 one)
parent 1228ce26
......@@ -2607,16 +2607,38 @@ HANDLE WINAPI CreateSocketHandle(void)
*/
BOOL WINAPI SetPriorityClass( HANDLE hprocess, DWORD priorityclass )
{
BOOL ret;
SERVER_START_REQ( set_process_info )
NTSTATUS status;
PROCESS_PRIORITY_CLASS ppc;
ppc.Foreground = FALSE;
switch (priorityclass)
{
case IDLE_PRIORITY_CLASS:
ppc.PriorityClass = PROCESS_PRIOCLASS_IDLE; break;
case BELOW_NORMAL_PRIORITY_CLASS:
ppc.PriorityClass = PROCESS_PRIOCLASS_BELOW_NORMAL; break;
case NORMAL_PRIORITY_CLASS:
ppc.PriorityClass = PROCESS_PRIOCLASS_NORMAL; break;
case ABOVE_NORMAL_PRIORITY_CLASS:
ppc.PriorityClass = PROCESS_PRIOCLASS_ABOVE_NORMAL; break;
case HIGH_PRIORITY_CLASS:
ppc.PriorityClass = PROCESS_PRIOCLASS_HIGH; break;
case REALTIME_PRIORITY_CLASS:
ppc.PriorityClass = PROCESS_PRIOCLASS_REALTIME; break;
default:
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
status = NtSetInformationProcess(hprocess, ProcessPriorityClass,
&ppc, sizeof(ppc));
if (status != STATUS_SUCCESS)
{
req->handle = hprocess;
req->priority = priorityclass;
req->mask = SET_PROCESS_INFO_PRIORITY;
ret = !wine_server_call_err( req );
SetLastError( RtlNtStatusToDosError(status) );
return FALSE;
}
SERVER_END_REQ;
return ret;
return TRUE;
}
......@@ -2630,8 +2652,21 @@ DWORD WINAPI GetPriorityClass(HANDLE hProcess)
status = NtQueryInformationProcess(hProcess, ProcessBasicInformation, &pbi,
sizeof(pbi), NULL);
if (status == STATUS_SUCCESS) return pbi.BasePriority;
SetLastError( RtlNtStatusToDosError(status) );
if (status != STATUS_SUCCESS)
{
SetLastError( RtlNtStatusToDosError(status) );
return 0;
}
switch (pbi.BasePriority)
{
case PROCESS_PRIOCLASS_IDLE: return IDLE_PRIORITY_CLASS;
case PROCESS_PRIOCLASS_BELOW_NORMAL: return BELOW_NORMAL_PRIORITY_CLASS;
case PROCESS_PRIOCLASS_NORMAL: return NORMAL_PRIORITY_CLASS;
case PROCESS_PRIOCLASS_ABOVE_NORMAL: return ABOVE_NORMAL_PRIORITY_CLASS;
case PROCESS_PRIOCLASS_HIGH: return HIGH_PRIORITY_CLASS;
case PROCESS_PRIOCLASS_REALTIME: return REALTIME_PRIORITY_CLASS;
}
SetLastError( ERROR_INVALID_PARAMETER );
return 0;
}
......
......@@ -160,7 +160,25 @@ static BOOL TOOLHELP_Process32Next( HANDLE handle, LPPROCESSENTRY32W lppe, BOOL
lppe->th32ModuleID = (DWORD)reply->module;
lppe->cntThreads = reply->threads;
lppe->th32ParentProcessID = reply->ppid;
lppe->pcPriClassBase = reply->priority;
switch (reply->priority)
{
case PROCESS_PRIOCLASS_IDLE:
lppe->pcPriClassBase = IDLE_PRIORITY_CLASS; break;
case PROCESS_PRIOCLASS_BELOW_NORMAL:
lppe->pcPriClassBase = BELOW_NORMAL_PRIORITY_CLASS; break;
case PROCESS_PRIOCLASS_NORMAL:
lppe->pcPriClassBase = NORMAL_PRIORITY_CLASS; break;
case PROCESS_PRIOCLASS_ABOVE_NORMAL:
lppe->pcPriClassBase = ABOVE_NORMAL_PRIORITY_CLASS; break;
case PROCESS_PRIOCLASS_HIGH:
lppe->pcPriClassBase = HIGH_PRIORITY_CLASS; break;
case PROCESS_PRIOCLASS_REALTIME:
lppe->pcPriClassBase = REALTIME_PRIORITY_CLASS; break;
default:
FIXME("Unknown NT priority class %d, setting to normal\n", reply->priority);
lppe->pcPriClassBase = NORMAL_PRIORITY_CLASS;
break;
}
lppe->dwFlags = -1; /* FIXME */
if (unicode)
{
......
......@@ -302,9 +302,36 @@ NTSTATUS WINAPI NtSetInformationProcess(
IN PVOID ProcessInformation,
IN ULONG ProcessInformationLength)
{
FIXME("(%p,0x%08x,%p,0x%08lx) stub\n",
ProcessHandle,ProcessInformationClass,ProcessInformation,ProcessInformationLength);
return 0;
NTSTATUS ret = STATUS_SUCCESS;
switch (ProcessInformationClass)
{
case ProcessPriorityClass:
if (ProcessInformationLength != sizeof(PROCESS_PRIORITY_CLASS))
return STATUS_INVALID_PARAMETER;
else
{
PROCESS_PRIORITY_CLASS* ppc = ProcessInformation;
SERVER_START_REQ( set_process_info )
{
req->handle = ProcessHandle;
/* FIXME Foreground isn't used */
req->priority = ppc->PriorityClass;
req->mask = SET_PROCESS_INFO_PRIORITY;
ret = wine_server_call( req );
}
SERVER_END_REQ;
}
break;
default:
FIXME("(%p,0x%08x,%p,0x%08lx) stub\n",
ProcessHandle,ProcessInformationClass,ProcessInformation,
ProcessInformationLength);
ret = STATUS_NOT_IMPLEMENTED;
break;
}
return ret;
}
/******************************************************************************
......
......@@ -932,6 +932,18 @@ typedef struct _PROCESS_BASIC_INFORMATION {
#endif
} PROCESS_BASIC_INFORMATION, *PPROCESS_BASIC_INFORMATION;
#define PROCESS_PRIOCLASS_IDLE 1
#define PROCESS_PRIOCLASS_NORMAL 2
#define PROCESS_PRIOCLASS_HIGH 3
#define PROCESS_PRIOCLASS_REALTIME 4
#define PROCESS_PRIOCLASS_BELOW_NORMAL 5
#define PROCESS_PRIOCLASS_ABOVE_NORMAL 6
typedef struct _PROCESS_PRIORITY_CLASS {
BOOLEAN Foreground;
UCHAR PriorityClass;
} PROCESS_PRIORITY_CLASS, *PPROCESS_PRIORITY_CLASS;
typedef struct _RTL_HEAP_DEFINITION {
ULONG Length; /* = sizeof(RTL_HEAP_DEFINITION) */
......
......@@ -37,8 +37,7 @@
#include <poll.h>
#endif
#include "windef.h"
#include "winnt.h"
#include "winternl.h"
#include "file.h"
#include "handle.h"
......@@ -233,7 +232,7 @@ struct thread *create_process( int fd )
process->msg_fd = NULL;
process->exit_code = STILL_ACTIVE;
process->running_threads = 0;
process->priority = NORMAL_PRIORITY_CLASS;
process->priority = PROCESS_PRIOCLASS_NORMAL;
process->affinity = 1;
process->suspend = 0;
process->create_flags = 0;
......
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