clang-format on most of kernel/
This commit is contained in:
@@ -18,15 +18,12 @@
|
||||
#include <xenia/kernel/util/shim_utils.h>
|
||||
#include <xenia/xbox.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
|
||||
using namespace xe::kernel::fs;
|
||||
|
||||
|
||||
SHIM_CALL NtCreateFile_shim(
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
SHIM_CALL NtCreateFile_shim(PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t handle_ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t desired_access = SHIM_GET_ARG_32(1);
|
||||
uint32_t object_attributes_ptr = SHIM_GET_ARG_32(2);
|
||||
@@ -40,19 +37,13 @@ SHIM_CALL NtCreateFile_shim(
|
||||
|
||||
char* object_name = attrs.object_name.Duplicate();
|
||||
|
||||
XELOGD(
|
||||
"NtCreateFile(%.8X, %.8X, %.8X(%s), %.8X, %.8X, %.8X, %d, %d)",
|
||||
handle_ptr,
|
||||
desired_access,
|
||||
object_attributes_ptr,
|
||||
!object_name ? "(null)" : object_name,
|
||||
io_status_block_ptr,
|
||||
allocation_size_ptr,
|
||||
file_attributes,
|
||||
share_access,
|
||||
creation_disposition);
|
||||
XELOGD("NtCreateFile(%.8X, %.8X, %.8X(%s), %.8X, %.8X, %.8X, %d, %d)",
|
||||
handle_ptr, desired_access, object_attributes_ptr,
|
||||
!object_name ? "(null)" : object_name, io_status_block_ptr,
|
||||
allocation_size_ptr, file_attributes, share_access,
|
||||
creation_disposition);
|
||||
|
||||
uint64_t allocation_size = 0; // is this correct???
|
||||
uint64_t allocation_size = 0; // is this correct???
|
||||
if (allocation_size_ptr != 0) {
|
||||
allocation_size = SHIM_MEM_64(allocation_size_ptr);
|
||||
}
|
||||
@@ -65,18 +56,17 @@ SHIM_CALL NtCreateFile_shim(
|
||||
Entry* entry;
|
||||
|
||||
XFile* root_file = NULL;
|
||||
if (attrs.root_directory != 0xFFFFFFFD && // ObDosDevices
|
||||
if (attrs.root_directory != 0xFFFFFFFD && // ObDosDevices
|
||||
attrs.root_directory != 0) {
|
||||
result = state->object_table()->GetObject(
|
||||
attrs.root_directory, (XObject**)&root_file);
|
||||
result = state->object_table()->GetObject(attrs.root_directory,
|
||||
(XObject**)&root_file);
|
||||
assert_true(XSUCCEEDED(result));
|
||||
assert_true(root_file->type() == XObject::Type::kTypeFile);
|
||||
|
||||
auto root_path = root_file->absolute_path();
|
||||
auto target_path = root_path + object_name;
|
||||
entry = fs->ResolvePath(target_path);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Resolve the file using the virtual file system.
|
||||
entry = fs->ResolvePath(object_name);
|
||||
}
|
||||
@@ -87,11 +77,9 @@ SHIM_CALL NtCreateFile_shim(
|
||||
XFile* file = NULL;
|
||||
if (entry && entry->type() == Entry::Type::FILE) {
|
||||
// Open the file.
|
||||
result = entry->Open(
|
||||
state,
|
||||
mode,
|
||||
false, // TODO(benvanik): pick async mode, if needed.
|
||||
&file);
|
||||
result = entry->Open(state, mode,
|
||||
false, // TODO(benvanik): pick async mode, if needed.
|
||||
&file);
|
||||
} else {
|
||||
result = X_STATUS_NO_SUCH_FILE;
|
||||
info = X_FILE_DOES_NOT_EXIST;
|
||||
@@ -101,13 +89,13 @@ SHIM_CALL NtCreateFile_shim(
|
||||
// Handle ref is incremented, so return that.
|
||||
handle = file->handle();
|
||||
file->Release();
|
||||
result = X_STATUS_SUCCESS;
|
||||
info = X_FILE_OPENED;
|
||||
result = X_STATUS_SUCCESS;
|
||||
info = X_FILE_OPENED;
|
||||
}
|
||||
|
||||
if (io_status_block_ptr) {
|
||||
SHIM_SET_MEM_32(io_status_block_ptr, result); // Status
|
||||
SHIM_SET_MEM_32(io_status_block_ptr + 4, info); // Information
|
||||
SHIM_SET_MEM_32(io_status_block_ptr, result); // Status
|
||||
SHIM_SET_MEM_32(io_status_block_ptr + 4, info); // Information
|
||||
}
|
||||
if (XSUCCEEDED(result)) {
|
||||
if (handle_ptr) {
|
||||
@@ -119,8 +107,7 @@ SHIM_CALL NtCreateFile_shim(
|
||||
SHIM_SET_RETURN_32(result);
|
||||
}
|
||||
|
||||
SHIM_CALL NtOpenFile_shim(
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
SHIM_CALL NtOpenFile_shim(PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t handle_ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t desired_access = SHIM_GET_ARG_32(1);
|
||||
uint32_t object_attributes_ptr = SHIM_GET_ARG_32(2);
|
||||
@@ -131,23 +118,19 @@ SHIM_CALL NtOpenFile_shim(
|
||||
|
||||
char* object_name = attrs.object_name.Duplicate();
|
||||
|
||||
XELOGD(
|
||||
"NtOpenFile(%.8X, %.8X, %.8X(%s), %.8X, %d)",
|
||||
handle_ptr,
|
||||
desired_access,
|
||||
object_attributes_ptr,
|
||||
!object_name ? "(null)" : object_name,
|
||||
io_status_block_ptr,
|
||||
open_options);
|
||||
XELOGD("NtOpenFile(%.8X, %.8X, %.8X(%s), %.8X, %d)", handle_ptr,
|
||||
desired_access, object_attributes_ptr,
|
||||
!object_name ? "(null)" : object_name, io_status_block_ptr,
|
||||
open_options);
|
||||
|
||||
X_STATUS result = X_STATUS_NO_SUCH_FILE;
|
||||
uint32_t info = X_FILE_DOES_NOT_EXIST;
|
||||
uint32_t handle;
|
||||
|
||||
XFile* root_file = NULL;
|
||||
if (attrs.root_directory != 0xFFFFFFFD) { // ObDosDevices
|
||||
result = state->object_table()->GetObject(
|
||||
attrs.root_directory, (XObject**)&root_file);
|
||||
if (attrs.root_directory != 0xFFFFFFFD) { // ObDosDevices
|
||||
result = state->object_table()->GetObject(attrs.root_directory,
|
||||
(XObject**)&root_file);
|
||||
assert_true(XSUCCEEDED(result));
|
||||
assert_true(root_file->type() == XObject::Type::kTypeFile);
|
||||
assert_always();
|
||||
@@ -162,13 +145,10 @@ SHIM_CALL NtOpenFile_shim(
|
||||
XFile* file = NULL;
|
||||
if (entry && entry->type() == Entry::Type::FILE) {
|
||||
// Open the file.
|
||||
result = entry->Open(
|
||||
state,
|
||||
mode,
|
||||
false, // TODO(benvanik): pick async mode, if needed.
|
||||
&file);
|
||||
}
|
||||
else {
|
||||
result = entry->Open(state, mode,
|
||||
false, // TODO(benvanik): pick async mode, if needed.
|
||||
&file);
|
||||
} else {
|
||||
result = X_STATUS_NO_SUCH_FILE;
|
||||
info = X_FILE_DOES_NOT_EXIST;
|
||||
}
|
||||
@@ -182,8 +162,8 @@ SHIM_CALL NtOpenFile_shim(
|
||||
}
|
||||
|
||||
if (io_status_block_ptr) {
|
||||
SHIM_SET_MEM_32(io_status_block_ptr, result); // Status
|
||||
SHIM_SET_MEM_32(io_status_block_ptr + 4, info); // Information
|
||||
SHIM_SET_MEM_32(io_status_block_ptr, result); // Status
|
||||
SHIM_SET_MEM_32(io_status_block_ptr + 4, info); // Information
|
||||
}
|
||||
if (XSUCCEEDED(result)) {
|
||||
if (handle_ptr) {
|
||||
@@ -196,7 +176,7 @@ SHIM_CALL NtOpenFile_shim(
|
||||
}
|
||||
|
||||
class xeNtReadFileState {
|
||||
public:
|
||||
public:
|
||||
uint32_t x;
|
||||
};
|
||||
void xeNtReadFileCompleted(XAsyncRequest* request, xeNtReadFileState* state) {
|
||||
@@ -205,8 +185,7 @@ void xeNtReadFileCompleted(XAsyncRequest* request, xeNtReadFileState* state) {
|
||||
delete state;
|
||||
}
|
||||
|
||||
SHIM_CALL NtReadFile_shim(
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
SHIM_CALL NtReadFile_shim(PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t file_handle = SHIM_GET_ARG_32(0);
|
||||
uint32_t event_handle = SHIM_GET_ARG_32(1);
|
||||
uint32_t apc_routine_ptr = SHIM_GET_ARG_32(2);
|
||||
@@ -217,17 +196,10 @@ SHIM_CALL NtReadFile_shim(
|
||||
uint32_t byte_offset_ptr = SHIM_GET_ARG_32(7);
|
||||
size_t byte_offset = byte_offset_ptr ? SHIM_MEM_64(byte_offset_ptr) : 0;
|
||||
|
||||
XELOGD(
|
||||
"NtReadFile(%.8X, %.8X, %.8X, %.8X, %.8X, %.8X, %d, %.8X(%d))",
|
||||
file_handle,
|
||||
event_handle,
|
||||
apc_routine_ptr,
|
||||
apc_context,
|
||||
io_status_block_ptr,
|
||||
buffer,
|
||||
buffer_length,
|
||||
byte_offset_ptr,
|
||||
byte_offset);
|
||||
XELOGD("NtReadFile(%.8X, %.8X, %.8X, %.8X, %.8X, %.8X, %d, %.8X(%d))",
|
||||
file_handle, event_handle, apc_routine_ptr, apc_context,
|
||||
io_status_block_ptr, buffer, buffer_length, byte_offset_ptr,
|
||||
byte_offset);
|
||||
|
||||
// Async not supported yet.
|
||||
assert_zero(apc_routine_ptr);
|
||||
@@ -239,15 +211,13 @@ SHIM_CALL NtReadFile_shim(
|
||||
XEvent* ev = NULL;
|
||||
bool signal_event = false;
|
||||
if (event_handle) {
|
||||
result = state->object_table()->GetObject(
|
||||
event_handle, (XObject**)&ev);
|
||||
result = state->object_table()->GetObject(event_handle, (XObject**)&ev);
|
||||
}
|
||||
|
||||
// Grab file.
|
||||
XFile* file = NULL;
|
||||
if (XSUCCEEDED(result)) {
|
||||
result = state->object_table()->GetObject(
|
||||
file_handle, (XObject**)&file);
|
||||
result = state->object_table()->GetObject(file_handle, (XObject**)&file);
|
||||
}
|
||||
|
||||
// Execute read.
|
||||
@@ -260,17 +230,15 @@ SHIM_CALL NtReadFile_shim(
|
||||
// TODO(benvanik): async path.
|
||||
if (true) {
|
||||
// Synchronous request.
|
||||
if (!byte_offset_ptr ||
|
||||
byte_offset == 0xFFFFFFFFfffffffe) {
|
||||
if (!byte_offset_ptr || byte_offset == 0xFFFFFFFFfffffffe) {
|
||||
// FILE_USE_FILE_POINTER_POSITION
|
||||
byte_offset = -1;
|
||||
}
|
||||
|
||||
// Read now.
|
||||
size_t bytes_read = 0;
|
||||
result = file->Read(
|
||||
SHIM_MEM_ADDR(buffer), buffer_length, byte_offset,
|
||||
&bytes_read);
|
||||
result = file->Read(SHIM_MEM_ADDR(buffer), buffer_length, byte_offset,
|
||||
&bytes_read);
|
||||
if (XSUCCEEDED(result)) {
|
||||
info = (int32_t)bytes_read;
|
||||
}
|
||||
@@ -287,15 +255,15 @@ SHIM_CALL NtReadFile_shim(
|
||||
state, file,
|
||||
(XAsyncRequest::CompletionCallback)xeNtReadFileCompleted,
|
||||
call_state);*/
|
||||
//result = file->Read(buffer, buffer_length, byte_offset, request);
|
||||
// result = file->Read(buffer, buffer_length, byte_offset, request);
|
||||
result = X_STATUS_PENDING;
|
||||
info = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (io_status_block_ptr) {
|
||||
SHIM_SET_MEM_32(io_status_block_ptr, result); // Status
|
||||
SHIM_SET_MEM_32(io_status_block_ptr + 4, info); // Information
|
||||
SHIM_SET_MEM_32(io_status_block_ptr, result); // Status
|
||||
SHIM_SET_MEM_32(io_status_block_ptr + 4, info); // Information
|
||||
}
|
||||
|
||||
if (file) {
|
||||
@@ -311,46 +279,39 @@ SHIM_CALL NtReadFile_shim(
|
||||
SHIM_SET_RETURN_32(result);
|
||||
}
|
||||
|
||||
SHIM_CALL NtSetInformationFile_shim(
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
SHIM_CALL NtSetInformationFile_shim(PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t file_handle = SHIM_GET_ARG_32(0);
|
||||
uint32_t io_status_block_ptr = SHIM_GET_ARG_32(1);
|
||||
uint32_t file_info_ptr = SHIM_GET_ARG_32(2);
|
||||
uint32_t length = SHIM_GET_ARG_32(3);
|
||||
uint32_t file_info_class = SHIM_GET_ARG_32(4);
|
||||
|
||||
XELOGD(
|
||||
"NtSetInformationFile(%.8X, %.8X, %.8X, %.8X, %.8X)",
|
||||
file_handle,
|
||||
io_status_block_ptr,
|
||||
file_info_ptr,
|
||||
length,
|
||||
file_info_class);
|
||||
XELOGD("NtSetInformationFile(%.8X, %.8X, %.8X, %.8X, %.8X)", file_handle,
|
||||
io_status_block_ptr, file_info_ptr, length, file_info_class);
|
||||
|
||||
X_STATUS result = X_STATUS_SUCCESS;
|
||||
uint32_t info = 0;
|
||||
|
||||
// Grab file.
|
||||
XFile* file = NULL;
|
||||
result = state->object_table()->GetObject(
|
||||
file_handle, (XObject**)&file);
|
||||
result = state->object_table()->GetObject(file_handle, (XObject**)&file);
|
||||
|
||||
if (XSUCCEEDED(result)) {
|
||||
result = X_STATUS_SUCCESS;
|
||||
switch (file_info_class) {
|
||||
case XFilePositionInformation:
|
||||
// struct FILE_POSITION_INFORMATION {
|
||||
// LARGE_INTEGER CurrentByteOffset;
|
||||
// };
|
||||
assert_true(length == 8);
|
||||
info = 8;
|
||||
file->set_position(SHIM_MEM_64(file_info_ptr));
|
||||
break;
|
||||
default:
|
||||
// Unsupported, for now.
|
||||
assert_always();
|
||||
info = 0;
|
||||
break;
|
||||
case XFilePositionInformation:
|
||||
// struct FILE_POSITION_INFORMATION {
|
||||
// LARGE_INTEGER CurrentByteOffset;
|
||||
// };
|
||||
assert_true(length == 8);
|
||||
info = 8;
|
||||
file->set_position(SHIM_MEM_64(file_info_ptr));
|
||||
break;
|
||||
default:
|
||||
// Unsupported, for now.
|
||||
assert_always();
|
||||
info = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -358,8 +319,8 @@ SHIM_CALL NtSetInformationFile_shim(
|
||||
info = 0;
|
||||
}
|
||||
if (io_status_block_ptr) {
|
||||
SHIM_SET_MEM_32(io_status_block_ptr, result); // Status
|
||||
SHIM_SET_MEM_32(io_status_block_ptr + 4, info); // Information
|
||||
SHIM_SET_MEM_32(io_status_block_ptr, result); // Status
|
||||
SHIM_SET_MEM_32(io_status_block_ptr + 4, info); // Information
|
||||
}
|
||||
|
||||
if (file) {
|
||||
@@ -369,91 +330,85 @@ SHIM_CALL NtSetInformationFile_shim(
|
||||
SHIM_SET_RETURN_32(result);
|
||||
}
|
||||
|
||||
SHIM_CALL NtQueryInformationFile_shim(
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
SHIM_CALL NtQueryInformationFile_shim(PPCContext* ppc_state,
|
||||
KernelState* state) {
|
||||
uint32_t file_handle = SHIM_GET_ARG_32(0);
|
||||
uint32_t io_status_block_ptr = SHIM_GET_ARG_32(1);
|
||||
uint32_t file_info_ptr = SHIM_GET_ARG_32(2);
|
||||
uint32_t length = SHIM_GET_ARG_32(3);
|
||||
uint32_t file_info_class = SHIM_GET_ARG_32(4);
|
||||
|
||||
XELOGD(
|
||||
"NtQueryInformationFile(%.8X, %.8X, %.8X, %.8X, %.8X)",
|
||||
file_handle,
|
||||
io_status_block_ptr,
|
||||
file_info_ptr,
|
||||
length,
|
||||
file_info_class);
|
||||
XELOGD("NtQueryInformationFile(%.8X, %.8X, %.8X, %.8X, %.8X)", file_handle,
|
||||
io_status_block_ptr, file_info_ptr, length, file_info_class);
|
||||
|
||||
X_STATUS result = X_STATUS_SUCCESS;
|
||||
uint32_t info = 0;
|
||||
|
||||
// Grab file.
|
||||
XFile* file = NULL;
|
||||
result = state->object_table()->GetObject(
|
||||
file_handle, (XObject**)&file);
|
||||
result = state->object_table()->GetObject(file_handle, (XObject**)&file);
|
||||
|
||||
if (XSUCCEEDED(result)) {
|
||||
result = X_STATUS_SUCCESS;
|
||||
switch (file_info_class) {
|
||||
case XFileInternalInformation:
|
||||
// Internal unique file pointer. Not sure why anyone would want this.
|
||||
assert_true(length == 8);
|
||||
info = 8;
|
||||
// TODO(benvanik): use pointer to fs:: entry?
|
||||
SHIM_SET_MEM_64(file_info_ptr, hash_combine(0, file->absolute_path()));
|
||||
break;
|
||||
case XFilePositionInformation:
|
||||
// struct FILE_POSITION_INFORMATION {
|
||||
// LARGE_INTEGER CurrentByteOffset;
|
||||
// };
|
||||
assert_true(length == 8);
|
||||
info = 8;
|
||||
SHIM_SET_MEM_64(file_info_ptr, file->position());
|
||||
break;
|
||||
case XFileNetworkOpenInformation:
|
||||
// struct FILE_NETWORK_OPEN_INFORMATION {
|
||||
// LARGE_INTEGER CreationTime;
|
||||
// LARGE_INTEGER LastAccessTime;
|
||||
// LARGE_INTEGER LastWriteTime;
|
||||
// LARGE_INTEGER ChangeTime;
|
||||
// LARGE_INTEGER AllocationSize;
|
||||
// LARGE_INTEGER EndOfFile;
|
||||
// ULONG FileAttributes;
|
||||
// ULONG Unknown;
|
||||
// };
|
||||
assert_true(length == 56);
|
||||
XFileInfo file_info;
|
||||
result = file->QueryInfo(&file_info);
|
||||
if (XSUCCEEDED(result)) {
|
||||
info = 56;
|
||||
file_info.Write(SHIM_MEM_BASE, file_info_ptr);
|
||||
}
|
||||
break;
|
||||
case XFileXctdCompressionInformation:
|
||||
// Read timeout.
|
||||
if (length == 4) {
|
||||
uint32_t magic;
|
||||
size_t bytes_read;
|
||||
result = file->Read(&magic, sizeof(magic), 0, &bytes_read);
|
||||
case XFileInternalInformation:
|
||||
// Internal unique file pointer. Not sure why anyone would want this.
|
||||
assert_true(length == 8);
|
||||
info = 8;
|
||||
// TODO(benvanik): use pointer to fs:: entry?
|
||||
SHIM_SET_MEM_64(file_info_ptr, hash_combine(0, file->absolute_path()));
|
||||
break;
|
||||
case XFilePositionInformation:
|
||||
// struct FILE_POSITION_INFORMATION {
|
||||
// LARGE_INTEGER CurrentByteOffset;
|
||||
// };
|
||||
assert_true(length == 8);
|
||||
info = 8;
|
||||
SHIM_SET_MEM_64(file_info_ptr, file->position());
|
||||
break;
|
||||
case XFileNetworkOpenInformation:
|
||||
// struct FILE_NETWORK_OPEN_INFORMATION {
|
||||
// LARGE_INTEGER CreationTime;
|
||||
// LARGE_INTEGER LastAccessTime;
|
||||
// LARGE_INTEGER LastWriteTime;
|
||||
// LARGE_INTEGER ChangeTime;
|
||||
// LARGE_INTEGER AllocationSize;
|
||||
// LARGE_INTEGER EndOfFile;
|
||||
// ULONG FileAttributes;
|
||||
// ULONG Unknown;
|
||||
// };
|
||||
assert_true(length == 56);
|
||||
XFileInfo file_info;
|
||||
result = file->QueryInfo(&file_info);
|
||||
if (XSUCCEEDED(result)) {
|
||||
if (bytes_read == sizeof(magic)) {
|
||||
info = 4;
|
||||
SHIM_SET_MEM_32(file_info_ptr, magic == poly::byte_swap(0x0FF512ED));
|
||||
}
|
||||
else {
|
||||
result = X_STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
info = 56;
|
||||
file_info.Write(SHIM_MEM_BASE, file_info_ptr);
|
||||
}
|
||||
} else {
|
||||
result = X_STATUS_INFO_LENGTH_MISMATCH;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// Unsupported, for now.
|
||||
assert_always();
|
||||
info = 0;
|
||||
break;
|
||||
break;
|
||||
case XFileXctdCompressionInformation:
|
||||
// Read timeout.
|
||||
if (length == 4) {
|
||||
uint32_t magic;
|
||||
size_t bytes_read;
|
||||
result = file->Read(&magic, sizeof(magic), 0, &bytes_read);
|
||||
if (XSUCCEEDED(result)) {
|
||||
if (bytes_read == sizeof(magic)) {
|
||||
info = 4;
|
||||
SHIM_SET_MEM_32(file_info_ptr,
|
||||
magic == poly::byte_swap(0x0FF512ED));
|
||||
} else {
|
||||
result = X_STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result = X_STATUS_INFO_LENGTH_MISMATCH;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// Unsupported, for now.
|
||||
assert_always();
|
||||
info = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -461,8 +416,8 @@ SHIM_CALL NtQueryInformationFile_shim(
|
||||
info = 0;
|
||||
}
|
||||
if (io_status_block_ptr) {
|
||||
SHIM_SET_MEM_32(io_status_block_ptr, result); // Status
|
||||
SHIM_SET_MEM_32(io_status_block_ptr + 4, info); // Information
|
||||
SHIM_SET_MEM_32(io_status_block_ptr, result); // Status
|
||||
SHIM_SET_MEM_32(io_status_block_ptr + 4, info); // Information
|
||||
}
|
||||
|
||||
if (file) {
|
||||
@@ -472,8 +427,8 @@ SHIM_CALL NtQueryInformationFile_shim(
|
||||
SHIM_SET_RETURN_32(result);
|
||||
}
|
||||
|
||||
SHIM_CALL NtQueryFullAttributesFile_shim(
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
SHIM_CALL NtQueryFullAttributesFile_shim(PPCContext* ppc_state,
|
||||
KernelState* state) {
|
||||
uint32_t object_attributes_ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t file_info_ptr = SHIM_GET_ARG_32(1);
|
||||
|
||||
@@ -481,18 +436,15 @@ SHIM_CALL NtQueryFullAttributesFile_shim(
|
||||
|
||||
char* object_name = attrs.object_name.Duplicate();
|
||||
|
||||
XELOGD(
|
||||
"NtQueryFullAttributesFile(%.8X(%s), %.8X)",
|
||||
object_attributes_ptr,
|
||||
!object_name ? "(null)" : object_name,
|
||||
file_info_ptr);
|
||||
XELOGD("NtQueryFullAttributesFile(%.8X(%s), %.8X)", object_attributes_ptr,
|
||||
!object_name ? "(null)" : object_name, file_info_ptr);
|
||||
|
||||
X_STATUS result = X_STATUS_NO_SUCH_FILE;
|
||||
|
||||
XFile* root_file = NULL;
|
||||
if (attrs.root_directory != 0xFFFFFFFD) { // ObDosDevices
|
||||
result = state->object_table()->GetObject(
|
||||
attrs.root_directory, (XObject**)&root_file);
|
||||
if (attrs.root_directory != 0xFFFFFFFD) { // ObDosDevices
|
||||
result = state->object_table()->GetObject(attrs.root_directory,
|
||||
(XObject**)&root_file);
|
||||
assert_true(XSUCCEEDED(result));
|
||||
assert_true(root_file->type() == XObject::Type::kTypeFile);
|
||||
assert_always();
|
||||
@@ -514,59 +466,52 @@ SHIM_CALL NtQueryFullAttributesFile_shim(
|
||||
SHIM_SET_RETURN_32(result);
|
||||
}
|
||||
|
||||
SHIM_CALL NtQueryVolumeInformationFile_shim(
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
SHIM_CALL NtQueryVolumeInformationFile_shim(PPCContext* ppc_state,
|
||||
KernelState* state) {
|
||||
uint32_t file_handle = SHIM_GET_ARG_32(0);
|
||||
uint32_t io_status_block_ptr = SHIM_GET_ARG_32(1);
|
||||
uint32_t fs_info_ptr = SHIM_GET_ARG_32(2);
|
||||
uint32_t length = SHIM_GET_ARG_32(3);
|
||||
uint32_t fs_info_class = SHIM_GET_ARG_32(4);
|
||||
|
||||
XELOGD(
|
||||
"NtQueryVolumeInformationFile(%.8X, %.8X, %.8X, %.8X, %.8X)",
|
||||
file_handle,
|
||||
io_status_block_ptr,
|
||||
fs_info_ptr,
|
||||
length,
|
||||
fs_info_class);
|
||||
|
||||
XELOGD("NtQueryVolumeInformationFile(%.8X, %.8X, %.8X, %.8X, %.8X)",
|
||||
file_handle, io_status_block_ptr, fs_info_ptr, length, fs_info_class);
|
||||
|
||||
X_STATUS result = X_STATUS_SUCCESS;
|
||||
uint32_t info = 0;
|
||||
|
||||
// Grab file.
|
||||
XFile* file = NULL;
|
||||
result = state->object_table()->GetObject(
|
||||
file_handle, (XObject**)&file);
|
||||
result = state->object_table()->GetObject(file_handle, (XObject**)&file);
|
||||
|
||||
if (XSUCCEEDED(result)) {
|
||||
result = X_STATUS_SUCCESS;
|
||||
switch (fs_info_class) {
|
||||
case 1: { // FileFsVolumeInformation
|
||||
auto volume_info = (XVolumeInfo*)xe_calloc(length);
|
||||
result = file->QueryVolume(volume_info, length);
|
||||
if (XSUCCEEDED(result)) {
|
||||
volume_info->Write(SHIM_MEM_BASE, fs_info_ptr);
|
||||
info = length;
|
||||
case 1: { // FileFsVolumeInformation
|
||||
auto volume_info = (XVolumeInfo*)xe_calloc(length);
|
||||
result = file->QueryVolume(volume_info, length);
|
||||
if (XSUCCEEDED(result)) {
|
||||
volume_info->Write(SHIM_MEM_BASE, fs_info_ptr);
|
||||
info = length;
|
||||
}
|
||||
xe_free(volume_info);
|
||||
break;
|
||||
}
|
||||
xe_free(volume_info);
|
||||
break;
|
||||
}
|
||||
case 5: { // FileFsAttributeInformation
|
||||
auto fs_attribute_info = (XFileSystemAttributeInfo*)xe_calloc(length);
|
||||
result = file->QueryFileSystemAttributes(fs_attribute_info, length);
|
||||
if (XSUCCEEDED(result)) {
|
||||
fs_attribute_info->Write(SHIM_MEM_BASE, fs_info_ptr);
|
||||
info = length;
|
||||
case 5: { // FileFsAttributeInformation
|
||||
auto fs_attribute_info = (XFileSystemAttributeInfo*)xe_calloc(length);
|
||||
result = file->QueryFileSystemAttributes(fs_attribute_info, length);
|
||||
if (XSUCCEEDED(result)) {
|
||||
fs_attribute_info->Write(SHIM_MEM_BASE, fs_info_ptr);
|
||||
info = length;
|
||||
}
|
||||
xe_free(fs_attribute_info);
|
||||
break;
|
||||
}
|
||||
xe_free(fs_attribute_info);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
// Unsupported, for now.
|
||||
assert_always();
|
||||
info = 0;
|
||||
break;
|
||||
default:
|
||||
// Unsupported, for now.
|
||||
assert_always();
|
||||
info = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -574,8 +519,8 @@ SHIM_CALL NtQueryVolumeInformationFile_shim(
|
||||
info = 0;
|
||||
}
|
||||
if (io_status_block_ptr) {
|
||||
SHIM_SET_MEM_32(io_status_block_ptr, result); // Status
|
||||
SHIM_SET_MEM_32(io_status_block_ptr + 4, info); // Information
|
||||
SHIM_SET_MEM_32(io_status_block_ptr, result); // Status
|
||||
SHIM_SET_MEM_32(io_status_block_ptr + 4, info); // Information
|
||||
}
|
||||
|
||||
if (file) {
|
||||
@@ -585,8 +530,7 @@ SHIM_CALL NtQueryVolumeInformationFile_shim(
|
||||
SHIM_SET_RETURN_32(result);
|
||||
}
|
||||
|
||||
SHIM_CALL NtQueryDirectoryFile_shim(
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
SHIM_CALL NtQueryDirectoryFile_shim(PPCContext* ppc_state, KernelState* state) {
|
||||
uint32_t file_handle = SHIM_GET_ARG_32(0);
|
||||
uint32_t event_handle = SHIM_GET_ARG_32(1);
|
||||
uint32_t apc_routine = SHIM_GET_ARG_32(2);
|
||||
@@ -605,16 +549,10 @@ SHIM_CALL NtQueryDirectoryFile_shim(
|
||||
}
|
||||
|
||||
XELOGD(
|
||||
"NtQueryDirectoryFile(%.8X, %.8X, %.8X, %.8X, %.8X, %.8X, %d, %.8X(%s), %d)",
|
||||
file_handle,
|
||||
event_handle,
|
||||
apc_routine,
|
||||
apc_context,
|
||||
io_status_block_ptr,
|
||||
file_info_ptr,
|
||||
length,
|
||||
file_name_ptr,
|
||||
!file_name ? "(null)" : file_name,
|
||||
"NtQueryDirectoryFile(%.8X, %.8X, %.8X, %.8X, %.8X, %.8X, %d, %.8X(%s), "
|
||||
"%d)",
|
||||
file_handle, event_handle, apc_routine, apc_context, io_status_block_ptr,
|
||||
file_info_ptr, length, file_name_ptr, !file_name ? "(null)" : file_name,
|
||||
restart_scan);
|
||||
|
||||
if (length < 72) {
|
||||
@@ -627,11 +565,11 @@ SHIM_CALL NtQueryDirectoryFile_shim(
|
||||
uint32_t info = 0;
|
||||
|
||||
XFile* file = NULL;
|
||||
result = state->object_table()->GetObject(
|
||||
file_handle, (XObject**)&file);
|
||||
result = state->object_table()->GetObject(file_handle, (XObject**)&file);
|
||||
if (XSUCCEEDED(result)) {
|
||||
XDirectoryInfo* dir_info = (XDirectoryInfo*)xe_calloc(length);
|
||||
result = file->QueryDirectory(dir_info, length, file_name, restart_scan != 0);
|
||||
result =
|
||||
file->QueryDirectory(dir_info, length, file_name, restart_scan != 0);
|
||||
if (XSUCCEEDED(result)) {
|
||||
dir_info->Write(SHIM_MEM_BASE, file_info_ptr);
|
||||
info = length;
|
||||
@@ -643,8 +581,8 @@ SHIM_CALL NtQueryDirectoryFile_shim(
|
||||
info = 0;
|
||||
}
|
||||
if (io_status_block_ptr) {
|
||||
SHIM_SET_MEM_32(io_status_block_ptr, result); // Status
|
||||
SHIM_SET_MEM_32(io_status_block_ptr + 4, info); // Information
|
||||
SHIM_SET_MEM_32(io_status_block_ptr, result); // Status
|
||||
SHIM_SET_MEM_32(io_status_block_ptr + 4, info); // Information
|
||||
}
|
||||
|
||||
if (file) {
|
||||
@@ -655,27 +593,23 @@ SHIM_CALL NtQueryDirectoryFile_shim(
|
||||
SHIM_SET_RETURN_32(result);
|
||||
}
|
||||
|
||||
SHIM_CALL FscSetCacheElementCount_shim(
|
||||
PPCContext* ppc_state, KernelState* state) {
|
||||
SHIM_CALL FscSetCacheElementCount_shim(PPCContext* ppc_state,
|
||||
KernelState* state) {
|
||||
uint32_t unk_0 = SHIM_GET_ARG_32(0);
|
||||
uint32_t unk_1 = SHIM_GET_ARG_32(1);
|
||||
// unk_0 = 0
|
||||
// unk_1 looks like a count? in what units? 256 is a common value
|
||||
|
||||
XELOGD(
|
||||
"FscSetCacheElementCount(%.8X, %.8X)",
|
||||
unk_0, unk_1);
|
||||
XELOGD("FscSetCacheElementCount(%.8X, %.8X)", unk_0, unk_1);
|
||||
|
||||
SHIM_SET_RETURN_32(X_STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
void xe::kernel::xboxkrnl::RegisterIoExports(
|
||||
ExportResolver* export_resolver, KernelState* state) {
|
||||
void xe::kernel::xboxkrnl::RegisterIoExports(ExportResolver* export_resolver,
|
||||
KernelState* state) {
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", NtCreateFile, state);
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", NtOpenFile, state);
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", NtReadFile, state);
|
||||
|
||||
Reference in New Issue
Block a user