Corrupted last error after deprecated/unsupported API calls
Windows Terminal version
No response
Windows build number
10.0.19044.2006
Other Software
No response
Steps to reproduce
Basically the problem is nicely described in this SO answer.
https://github.com/microsoft/terminal/blob/3c78e01ab5a025290b8953a6dc0f2695c76c223e/src/server/ApiDispatchersInternal.cpp#L22
ServerDeprecatedApi uses E_NOTIMPL (0x80004001), which on its way to the caller suffers several transformations and becomes 0x00004001, which is not a valid Windows error code.
It is quite unfortunate, given that the whole idea is to make it clear to the caller that the call is deprecated/not implemented.
Perhaps the function could use a different code that won't get fubared beyond recognition?
Given that it is passed to RtlNtStatusToDosError on its way, it probably should be NTSTATUS in the first place, either just raw STATUS_NOT_IMPLEMENTED or packed into HRESULT as HRESULT_FROM_NT(STATUS_NOT_IMPLEMENTED).
Expected Behavior
After an unsupported call:
GetLastError()should return a sensible value, e.g.ERROR_INVALID_FUNCTIONorERROR_CALL_NOT_IMPLEMENTED- (optionally)
RtlGetLastNtStatus()should return a sensible value, e.g.STATUS_NOT_IMPLEMENTED
Actual Behavior
GetLastError()returns 0x0004001, which is an invalid error code.RtlGetLastNtStatus()returns 0xC0074001, which is the same invalid win32 error code withSTATUS_SEVERITY_ERRORandFACILITY_NTWIN32bits.