IMHO this should be made consistent with how `NtTerminateProcess()` handles NULL process handle.
There's no special logic for NULL handles in the client[^wineserver] side of `NtTerminateProcess()`:[^NtTerminateProcess]
```c /****************************************************************************** * NtTerminateProcess (NTDLL.@) */ NTSTATUS WINAPI NtTerminateProcess( HANDLE handle, LONG exit_code ) { unsigned int ret; BOOL self;
SERVER_START_REQ( terminate_process ) { req->handle = wine_server_obj_handle( handle ); /* <-- no NULL check here */ req->exit_code = exit_code; ret = wine_server_call( req ); self = reply->self; } SERVER_END_REQ; (...snip...) return ret; } ```
Instead, `NtTerminateProcess()` passes the handle to the wineserver[^wineserver], which is actually responsible for interpreting the process handle (and thus checking for NULL handle as well):[^terminate_process]
```c /* terminate a process */ DECL_HANDLER(terminate_process) { struct process *process;
if (req->handle) /* <-- NULL check here */ { process = get_process_from_handle( req->handle, PROCESS_TERMINATE ); if (!process) return; } else process = (struct process *)grab_object( current->process );
reply->self = (current->process == process); terminate_process( process, current, req->exit_code ); release_object( process ); } ```
The `terminate_thread` handle should be made to accept NULL handle as well.
[^wineserver]: Any Wine app process is a client of the *wineserver*, which emulates the core "kernel" part of the Windows. [^NtTerminateProcess]: https://gitlab.winehq.org/wine/wine/-/blob/f1749b0808c66a0341b77409cc9338ab5... [^terminate_process]: https://gitlab.winehq.org/wine/wine/-/blob/f1749b0808c66a0341b77409cc9338ab5...