From 90d1772c4a48880ba289de1bacb192d636a373f4 Mon Sep 17 00:00:00 2001 From: Gliniak Date: Sun, 2 Aug 2020 17:09:32 +0200 Subject: [PATCH] NtCreateFile - Return error while trying to create directory with non-directory flag --- src/xenia/kernel/xboxkrnl/xboxkrnl_io.cc | 5 +++++ src/xenia/xbox.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/xenia/kernel/xboxkrnl/xboxkrnl_io.cc b/src/xenia/kernel/xboxkrnl/xboxkrnl_io.cc index c8f88d331..711a90bb8 100644 --- a/src/xenia/kernel/xboxkrnl/xboxkrnl_io.cc +++ b/src/xenia/kernel/xboxkrnl/xboxkrnl_io.cc @@ -105,6 +105,11 @@ dword_result_t NtCreateFile(lpdword_t handle_out, dword_t desired_access, return X_STATUS_OBJECT_NAME_INVALID; } + if (target_path.back() == '\\' && + create_options & CreateOptions::FILE_NON_DIRECTORY_FILE) { + return X_STATUS_FILE_IS_A_DIRECTORY; + } + if (object_attrs->root_directory != 0xFFFFFFFD && // ObDosDevices object_attrs->root_directory != 0) { auto root_file = kernel_state()->object_table()->LookupObject( diff --git a/src/xenia/xbox.h b/src/xenia/xbox.h index 998def9ee..03b9f0d6a 100644 --- a/src/xenia/xbox.h +++ b/src/xenia/xbox.h @@ -64,6 +64,7 @@ typedef uint32_t X_STATUS; #define X_STATUS_PROCEDURE_NOT_FOUND ((X_STATUS)0xC000007AL) #define X_STATUS_INSUFFICIENT_RESOURCES ((X_STATUS)0xC000009AL) #define X_STATUS_MEMORY_NOT_ALLOCATED ((X_STATUS)0xC00000A0L) +#define X_STATUS_FILE_IS_A_DIRECTORY ((X_STATUS)0xC00000BAL) #define X_STATUS_NOT_SUPPORTED ((X_STATUS)0xC00000BBL) #define X_STATUS_INVALID_PARAMETER_1 ((X_STATUS)0xC00000EFL) #define X_STATUS_INVALID_PARAMETER_2 ((X_STATUS)0xC00000F0L)