ChangeSet ID: 20002 CVSROOT: /opt/cvs-commit Module name: wine Changes by: julliard@winehq.org 2005/09/06 05:25:11 Modified files: server : process.c include : winternl.h dlls/ntdll : process.c dlls/kernel : toolhelp.c process.c Log message: Eric Pouech - 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) Patch: http://cvs.winehq.org/patch.py?id=20002 Old revision New revision Changes Path 1.139 1.140 +2 -3 wine/server/process.c 1.163 1.164 +12 -0 wine/include/winternl.h 1.12 1.13 +30 -3 wine/dlls/ntdll/process.c 1.33 1.34 +19 -1 wine/dlls/kernel/toolhelp.c 1.102 1.103 +45 -10 wine/dlls/kernel/process.c Index: wine/server/process.c diff -u -p wine/server/process.c:1.139 wine/server/process.c:1.140 --- wine/server/process.c:1.139 Wed May 22 15:35:10 2013 +++ wine/server/process.c Wed May 22 15:35:10 2013 @@ -37,8 +37,7 @@ #include #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; Index: wine/include/winternl.h diff -u -p wine/include/winternl.h:1.163 wine/include/winternl.h:1.164 --- wine/include/winternl.h:1.163 Wed May 22 15:35:10 2013 +++ wine/include/winternl.h Wed May 22 15:35:10 2013 @@ -932,6 +932,18 @@ typedef struct _PROCESS_BASIC_INFORMATIO #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) */ Index: wine/dlls/ntdll/process.c diff -u -p wine/dlls/ntdll/process.c:1.12 wine/dlls/ntdll/process.c:1.13 --- wine/dlls/ntdll/process.c:1.12 Wed May 22 15:35:10 2013 +++ wine/dlls/ntdll/process.c Wed May 22 15:35:10 2013 @@ -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; } /****************************************************************************** Index: wine/dlls/kernel/toolhelp.c diff -u -p wine/dlls/kernel/toolhelp.c:1.33 wine/dlls/kernel/toolhelp.c:1.34 --- wine/dlls/kernel/toolhelp.c:1.33 Wed May 22 15:35:11 2013 +++ wine/dlls/kernel/toolhelp.c Wed May 22 15:35:11 2013 @@ -160,7 +160,25 @@ static BOOL TOOLHELP_Process32Next( HAND 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) { Index: wine/dlls/kernel/process.c diff -u -p wine/dlls/kernel/process.c:1.102 wine/dlls/kernel/process.c:1.103 --- wine/dlls/kernel/process.c:1.102 Wed May 22 15:35:11 2013 +++ wine/dlls/kernel/process.c Wed May 22 15:35:11 2013 @@ -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 hPr 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; }