On Tue Aug 15 14:30:00 2023 +0000, Alexandre Julliard wrote:
If arg == 0x1234 and NtTerminateThread returns to the caller
GetExitCodeThread status would be some other value than 0x1234 unless NtTerminateThread would return 0x1234 to the caller (which it does not). It's possible that it sets the exit code without exiting, this is what NtTerminateProcess does. It really needs an explicit test.
```plaintext int test_ntterminatethread_proc_failed;
DWORD WINAPI test_ntterminatethread_proc( void *arg ) { DWORD status = (UINT_PTR)arg;
status = pNtTerminateThread(0, status);
test_ntterminatethread_proc_failed = 1;
return status; }
/* verifies NtTerminateThread accepts NULL handle */ static void test_terminate_thread(void) { HANDLE thread; DWORD exitcode; NTSTATUS status;
test_ntterminatethread_proc_failed = 0;
status = pNtCreateThreadEx( &thread, THREAD_ALL_ACCESS, NULL, GetCurrentProcess(), (PRTL_THREAD_START_ROUTINE)test_ntterminatethread_proc, (void*)0x1234, 0, 0, 0, 0, NULL );
ok( status == STATUS_SUCCESS, "Got unexpected status %#lx.\n", status );
WaitForSingleObject(thread, INFINITE); GetExitCodeThread(thread, &exitcode); ok( exitcode == 0x1234, "NtTerminateThread failed exitcode = %lx\n", (long)exitcode);
ok( test_ntterminatethread_proc_failed == 0, "NtTerminateThread failed\n"); } ```
Better?