On Mon, Sep 13, 2021 at 06:32:25PM +0300, Gabriel Ivăncescu wrote:
Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com> --- dlls/kernel32/tests/process.c | 9 --------- dlls/ntdll/unix/sync.c | 35 ++++++++++++++++++++++++++++++++--- server/process.c | 25 +++++++++++++++++++++++++ server/protocol.def | 1 + 4 files changed, 58 insertions(+), 12 deletions(-)
diff --git a/dlls/ntdll/unix/sync.c b/dlls/ntdll/unix/sync.c index a13e53a..28f7083 100644 --- a/dlls/ntdll/unix/sync.c +++ b/dlls/ntdll/unix/sync.c @@ -791,11 +791,40 @@ NTSTATUS WINAPI NtQueryInformationJobObject( HANDLE handle, JOBOBJECTINFOCLASS c case JobObjectBasicProcessIdList: { JOBOBJECT_BASIC_PROCESS_ID_LIST *process = info; + DWORD count, i;
if (len < sizeof(*process)) return STATUS_INFO_LENGTH_MISMATCH; - memset( process, 0, sizeof(*process) ); - if (ret_len) *ret_len = sizeof(*process); - return STATUS_SUCCESS; + + count = len - FIELD_OFFSET(JOBOBJECT_BASIC_PROCESS_ID_LIST, ProcessIdList); + count /= sizeof(process->ProcessIdList[0]); + + SERVER_START_REQ( get_job_info ) + { + req->handle = wine_server_user_handle(handle); + wine_server_set_reply(req, process->ProcessIdList, count * sizeof(process_id_t)); + if (!(ret = wine_server_call(req))) + { + process->NumberOfAssignedProcesses = reply->active_processes; + process->NumberOfProcessIdsInList = min(count, reply->active_processes); + } + } + SERVER_END_REQ; + + if (ret != STATUS_SUCCESS) return ret; + + if (sizeof(process_id_t) < sizeof(process->ProcessIdList[0])) + { + /* start from the end to not overwrite */ + for (i = process->NumberOfProcessIdsInList; i--;) + { + ULONG_PTR id = ((process_id_t *)(process->ProcessIdList))[i]; + process->ProcessIdList[i] = id; + } + } + + if (ret_len) + *ret_len = (char*)(&process->ProcessIdList[process->NumberOfProcessIdsInList]) - (char*)process;
I missed this last time, but I'd use FIELD_OFFSET() here to match the "count" calculation above. Otherwise, this looks good to me. Huw.