Jinoh Kang (@iamahuman) commented about dlls/kernelbase/file.c:
*/ if (status == STATUS_OBJECT_NAME_COLLISION) SetLastError( ERROR_FILE_EXISTS );
else if (status == STATUS_FILE_IS_A_DIRECTORY)
{
WCHAR last = filename[wcslen(filename) - 1];
SetLastError(last == '\\' || last == '/' ? ERROR_PATH_NOT_FOUND : ERROR_ACCESS_DENIED);
}
I believe this causes regression for some drivers that handle `IRP_MJ_CREATE` and may return `STATUS_FILE_IS_A_DIRECTORY` from there.
`NtCreateFile()` is ***not*** just a wrapper for `open()`. For custom devices like `\.\MyCustomDriver`, it delegates to the third-party driver. The third-party driver might return `STATUS_FILE_IS_A_DIRECTORY` *but* still expect it to be translated to `ERROR_ACCESS_DENIED` even with the trailing slash.
I suspect the real culprit is that `NtCreateFile()` is incorrectly translating Unix `EISDIR` to `STATUS_FILE_IS_A_DIRECTORY` *unconditionally*. In this case, the bug needs to be fixed in ntdll, not kernelbase.