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

View File

@ -143,7 +143,7 @@ NTSTATUS WINAPI NtQueryInformationProcess(
{ {
pbi.ExitStatus = reply->exit_code; pbi.ExitStatus = reply->exit_code;
pbi.PebBaseAddress = (DWORD)reply->peb; pbi.PebBaseAddress = (DWORD)reply->peb;
pbi.AffinityMask = reply->process_affinity; pbi.AffinityMask = reply->affinity;
pbi.BasePriority = reply->priority; pbi.BasePriority = reply->priority;
pbi.UniqueProcessId = reply->pid; pbi.UniqueProcessId = reply->pid;
pbi.InheritedFromUniqueProcessId = reply->ppid; pbi.InheritedFromUniqueProcessId = reply->ppid;
@ -306,6 +306,17 @@ NTSTATUS WINAPI NtSetInformationProcess(
switch (ProcessInformationClass) 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: case ProcessPriorityClass:
if (ProcessInformationLength != sizeof(PROCESS_PRIORITY_CLASS)) if (ProcessInformationLength != sizeof(PROCESS_PRIORITY_CLASS))
return STATUS_INVALID_PARAMETER; 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); BOOL WINAPI GetPrivateProfileStructW(LPCWSTR,LPCWSTR,LPVOID,UINT,LPCWSTR);
#define GetPrivateProfileStruct WINELIB_NAME_AW(GetPrivateProfileStruct) #define GetPrivateProfileStruct WINELIB_NAME_AW(GetPrivateProfileStruct)
FARPROC WINAPI GetProcAddress(HMODULE,LPCSTR); 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 GetProcessHeaps(DWORD,PHANDLE);
DWORD WINAPI GetProcessId(HANDLE); DWORD WINAPI GetProcessId(HANDLE);
BOOL WINAPI GetProcessIoCounters(HANDLE,PIO_COUNTERS); BOOL WINAPI GetProcessIoCounters(HANDLE,PIO_COUNTERS);

View File

@ -339,8 +339,7 @@ struct get_process_info_reply
process_id_t ppid; process_id_t ppid;
int exit_code; int exit_code;
int priority; int priority;
int process_affinity; int affinity;
int system_affinity;
void* peb; void* peb;
}; };
@ -4207,6 +4206,6 @@ union generic_reply
struct set_mailslot_info_reply set_mailslot_info_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 */ #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->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->affinity = process->affinity;
reply->system_affinity = 1;
reply->peb = process->peb; reply->peb = process->peb;
release_object( process ); release_object( process );
} }

View File

@ -309,8 +309,7 @@ struct security_descriptor
process_id_t ppid; /* server process id of parent */ 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 affinity; /* process affinity mask */
int system_affinity; /* system affinity mask */
void* peb; /* PEB address in process address space */ void* peb; /* PEB address in process address space */
@END @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, " 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, " affinity=%d,", req->affinity );
fprintf( stderr, " system_affinity=%d,", req->system_affinity );
fprintf( stderr, " peb=%p", req->peb ); fprintf( stderr, " peb=%p", req->peb );
} }