Signed-off-by: Paul Gofman pgofman@codeweavers.com --- dlls/kernel32/tests/process.c | 54 +++++++++++++++++++++++++++++++++++ dlls/kernelbase/process.c | 8 ++++++ 2 files changed, 62 insertions(+)
diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c index 52c3036fe59..9acf0aaaaee 100644 --- a/dlls/kernel32/tests/process.c +++ b/dlls/kernel32/tests/process.c @@ -4537,6 +4537,59 @@ static void test_nested_jobs(void) CloseHandle(job2); }
+static void test_job_list_attribute(void) +{ + PPROC_THREAD_ATTRIBUTE_LIST attrs; + HANDLE jobs[2]; + SIZE_T size; + BOOL ret; + + if (!pInitializeProcThreadAttributeList) + { + win_skip("No support for ProcThreadAttributeList\n"); + return; + } + + ret = pInitializeProcThreadAttributeList(NULL, 1, 0, &size); + ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, + "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError()); + attrs = heap_alloc(size); + + + jobs[0] = (HANDLE)0xdeadbeef; + jobs[1] = NULL; + + ret = pInitializeProcThreadAttributeList(attrs, 1, 0, &size); + ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError()); + ret = pUpdateProcThreadAttribute(attrs, 0, PROC_THREAD_ATTRIBUTE_JOB_LIST, jobs, + sizeof(*jobs), NULL, NULL); + if (!ret && GetLastError() == ERROR_NOT_SUPPORTED) + { + /* Supported since Win10. */ + win_skip("PROC_THREAD_ATTRIBUTE_JOB_LIST is not supported.\n"); + pDeleteProcThreadAttributeList(attrs); + heap_free(attrs); + return; + } + ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError()); + + ret = pInitializeProcThreadAttributeList(attrs, 1, 0, &size); + ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError()); + ret = pUpdateProcThreadAttribute(attrs, 0, PROC_THREAD_ATTRIBUTE_JOB_LIST, jobs, + 3, NULL, NULL); + ok(!ret && GetLastError() == ERROR_BAD_LENGTH, "Got unexpected ret %#x, GetLastError() %u.\n", + ret, GetLastError()); + + ret = pInitializeProcThreadAttributeList(attrs, 1, 0, &size); + ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError()); + ret = pUpdateProcThreadAttribute(attrs, 0, PROC_THREAD_ATTRIBUTE_JOB_LIST, jobs, + sizeof(*jobs) * 2, NULL, NULL); + ok(ret, "Got unexpected ret %#x, GetLastError() %u.\n", ret, GetLastError()); + + pDeleteProcThreadAttributeList(attrs); + heap_free(attrs); +} + START_TEST(process) { HANDLE job, hproc, h, h2; @@ -4688,6 +4741,7 @@ START_TEST(process) test_nested_jobs(); job = test_AddSelfToJob(); test_jobInheritance(job); + test_job_list_attribute(); test_BreakawayOk(job); CloseHandle(job); } diff --git a/dlls/kernelbase/process.c b/dlls/kernelbase/process.c index ae91168ecf4..06a90bf55ca 100644 --- a/dlls/kernelbase/process.c +++ b/dlls/kernelbase/process.c @@ -1687,6 +1687,14 @@ BOOL WINAPI DECLSPEC_HOTPATCH UpdateProcThreadAttribute( struct _PROC_THREAD_ATT } break;
+ case PROC_THREAD_ATTRIBUTE_JOB_LIST: + if ((size / sizeof(HANDLE)) * sizeof(HANDLE) != size) + { + SetLastError( ERROR_BAD_LENGTH ); + return FALSE; + } + break; + default: SetLastError( ERROR_NOT_SUPPORTED ); FIXME( "Unhandled attribute %lu\n", attr & PROC_THREAD_ATTRIBUTE_NUMBER );