[Kernel] Added support for XFileDispositionInformation

This is set and used in 415607DD to overwrite savefile
This commit is contained in:
Gliniak 2024-08-16 20:40:53 +02:00
parent 49584ff664
commit 651fdc0344
4 changed files with 14 additions and 2 deletions

View File

@ -253,6 +253,7 @@ dword_result_t NtSetInformationFile_entry(
// Used to set deletion flag. Which we don't support. Probably? // Used to set deletion flag. Which we don't support. Probably?
auto info = info_ptr.as<X_FILE_DISPOSITION_INFORMATION*>(); auto info = info_ptr.as<X_FILE_DISPOSITION_INFORMATION*>();
bool delete_on_close = info->delete_file ? true : false; bool delete_on_close = info->delete_file ? true : false;
file->entry()->SetForDeletion(static_cast<bool>(info->delete_file));
out_length = 0; out_length = 0;
XELOGW("NtSetInformationFile ignoring delete on close: {}", XELOGW("NtSetInformationFile ignoring delete on close: {}",
delete_on_close); delete_on_close);

View File

@ -21,7 +21,12 @@ HostPathFile::HostPathFile(
HostPathFile::~HostPathFile() = default; HostPathFile::~HostPathFile() = default;
void HostPathFile::Destroy() { delete this; } void HostPathFile::Destroy() {
if (entry_ && entry_->delete_on_close()) {
entry()->Delete();
}
delete this;
}
X_STATUS HostPathFile::ReadSync(void* buffer, size_t buffer_length, X_STATUS HostPathFile::ReadSync(void* buffer, size_t buffer_length,
size_t byte_offset, size_t* out_bytes_read) { size_t byte_offset, size_t* out_bytes_read) {

View File

@ -25,7 +25,8 @@ Entry::Entry(Device* device, Entry* parent, const std::string_view path)
allocation_size_(0), allocation_size_(0),
create_timestamp_(0), create_timestamp_(0),
access_timestamp_(0), access_timestamp_(0),
write_timestamp_(0) { write_timestamp_(0),
delete_on_close_(false) {
assert_not_null(device); assert_not_null(device);
absolute_path_ = xe::utf8::join_guest_paths(device->mount_path(), path); absolute_path_ = xe::utf8::join_guest_paths(device->mount_path(), path);
name_ = xe::utf8::find_name_from_guest_path(path); name_ = xe::utf8::find_name_from_guest_path(path);

View File

@ -93,11 +93,15 @@ class Entry {
uint64_t create_timestamp() const { return create_timestamp_; } uint64_t create_timestamp() const { return create_timestamp_; }
uint64_t access_timestamp() const { return access_timestamp_; } uint64_t access_timestamp() const { return access_timestamp_; }
uint64_t write_timestamp() const { return write_timestamp_; } uint64_t write_timestamp() const { return write_timestamp_; }
bool delete_on_close() const { return delete_on_close_; }
virtual bool SetAttributes(uint64_t attributes) { return false; } virtual bool SetAttributes(uint64_t attributes) { return false; }
virtual bool SetCreateTimestamp(uint64_t timestamp) { return false; } virtual bool SetCreateTimestamp(uint64_t timestamp) { return false; }
virtual bool SetAccessTimestamp(uint64_t timestamp) { return false; } virtual bool SetAccessTimestamp(uint64_t timestamp) { return false; }
virtual bool SetWriteTimestamp(uint64_t timestamp) { return false; } virtual bool SetWriteTimestamp(uint64_t timestamp) { return false; }
void SetForDeletion(bool delete_on_close) {
delete_on_close_ = delete_on_close;
}
bool is_read_only() const; bool is_read_only() const;
@ -151,6 +155,7 @@ class Entry {
uint64_t create_timestamp_; uint64_t create_timestamp_;
uint64_t access_timestamp_; uint64_t access_timestamp_;
uint64_t write_timestamp_; uint64_t write_timestamp_;
bool delete_on_close_;
std::vector<std::unique_ptr<Entry>> children_; std::vector<std::unique_ptr<Entry>> children_;
}; };