Implemented kernel32 process affinity handling on top on ntdll.

This commit is contained in:
Eric Pouech 2005-09-27 10:52:10 +00:00 committed by Alexandre Julliard
parent c99a3fafef
commit b09582a890
7 changed files with 41 additions and 32 deletions

View File

@ -2676,16 +2676,16 @@ DWORD WINAPI GetPriorityClass(HANDLE hProcess)
*/
BOOL WINAPI SetProcessAffinityMask( HANDLE hProcess, DWORD_PTR affmask )
{
BOOL ret;
SERVER_START_REQ( set_process_info )
NTSTATUS status;
status = NtSetInformationProcess(hProcess, ProcessAffinityMask,
&affmask, sizeof(DWORD_PTR));
if (!status)
{
req->handle = hProcess;
req->affinity = affmask;
req->mask = SET_PROCESS_INFO_AFFINITY;
ret = !wine_server_call_err( req );
SetLastError( RtlNtStatusToDosError(status) );
return FALSE;
}
SERVER_END_REQ;
return ret;
return TRUE;
}
@ -2693,22 +2693,24 @@ BOOL WINAPI SetProcessAffinityMask( HANDLE hProcess, DWORD_PTR affmask )
* GetProcessAffinityMask (KERNEL32.@)
*/
BOOL WINAPI GetProcessAffinityMask( HANDLE hProcess,
LPDWORD lpProcessAffinityMask,
LPDWORD lpSystemAffinityMask )
PDWORD_PTR lpProcessAffinityMask,
PDWORD_PTR lpSystemAffinityMask )
{
BOOL ret = FALSE;
SERVER_START_REQ( get_process_info )
PROCESS_BASIC_INFORMATION pbi;
NTSTATUS status;
status = NtQueryInformationProcess(hProcess,
ProcessBasicInformation,
&pbi, sizeof(pbi), NULL);
if (status)
{
req->handle = hProcess;
if (!wine_server_call_err( req ))
{
if (lpProcessAffinityMask) *lpProcessAffinityMask = reply->process_affinity;
if (lpSystemAffinityMask) *lpSystemAffinityMask = reply->system_affinity;
ret = TRUE;
}
SetLastError( RtlNtStatusToDosError(status) );
return FALSE;
}
SERVER_END_REQ;
return ret;
if (lpProcessAffinityMask) *lpProcessAffinityMask = pbi.AffinityMask;
/* FIXME */
if (lpSystemAffinityMask) *lpSystemAffinityMask = 1;
return TRUE;
}

View File

@ -143,7 +143,7 @@ NTSTATUS WINAPI NtQueryInformationProcess(
{
pbi.ExitStatus = reply->exit_code;
pbi.PebBaseAddress = (DWORD)reply->peb;
pbi.AffinityMask = reply->process_affinity;
pbi.AffinityMask = reply->affinity;
pbi.BasePriority = reply->priority;
pbi.UniqueProcessId = reply->pid;
pbi.InheritedFromUniqueProcessId = reply->ppid;
@ -306,6 +306,17 @@ NTSTATUS WINAPI NtSetInformationProcess(
switch (ProcessInformationClass)
{
case ProcessAffinityMask:
if (ProcessInformationLength != sizeof(DWORD_PTR)) return STATUS_INVALID_PARAMETER;
SERVER_START_REQ( set_process_info )
{
req->handle = ProcessHandle;
req->affinity = *(PDWORD_PTR)ProcessInformation;
req->mask = SET_PROCESS_INFO_AFFINITY;
ret = wine_server_call( req );
}
SERVER_END_REQ;
break;
case ProcessPriorityClass:
if (ProcessInformationLength != sizeof(PROCESS_PRIORITY_CLASS))
return STATUS_INVALID_PARAMETER;

View File

@ -1559,7 +1559,7 @@ BOOL WINAPI GetPrivateProfileStructA(LPCSTR,LPCSTR,LPVOID,UINT,LPCSTR);
BOOL WINAPI GetPrivateProfileStructW(LPCWSTR,LPCWSTR,LPVOID,UINT,LPCWSTR);
#define GetPrivateProfileStruct WINELIB_NAME_AW(GetPrivateProfileStruct)
FARPROC WINAPI GetProcAddress(HMODULE,LPCSTR);
BOOL WINAPI GetProcessAffinityMask(HANDLE,PDWORD,PDWORD);
BOOL WINAPI GetProcessAffinityMask(HANDLE,PDWORD_PTR,PDWORD_PTR);
DWORD WINAPI GetProcessHeaps(DWORD,PHANDLE);
DWORD WINAPI GetProcessId(HANDLE);
BOOL WINAPI GetProcessIoCounters(HANDLE,PIO_COUNTERS);

View File

@ -339,8 +339,7 @@ struct get_process_info_reply
process_id_t ppid;
int exit_code;
int priority;
int process_affinity;
int system_affinity;
int affinity;
void* peb;
};
@ -4207,6 +4206,6 @@ union generic_reply
struct set_mailslot_info_reply set_mailslot_info_reply;
};
#define SERVER_PROTOCOL_VERSION 193
#define SERVER_PROTOCOL_VERSION 194
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */

View File

@ -1034,8 +1034,7 @@ DECL_HANDLER(get_process_info)
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->affinity = process->affinity;
reply->peb = process->peb;
release_object( process );
}

View File

@ -309,8 +309,7 @@ struct security_descriptor
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 */
int affinity; /* process affinity mask */
void* peb; /* PEB address in process address space */
@END

View File

@ -699,8 +699,7 @@ static void dump_get_process_info_reply( const struct get_process_info_reply *re
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, " affinity=%d,", req->affinity );
fprintf( stderr, " peb=%p", req->peb );
}