Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix original file being read when it is bigger than the emulated version #23

Merged
merged 9 commits into from
Sep 20, 2024

Conversation

AnimatedSwine37
Copy link
Contributor

@AnimatedSwine37 AnimatedSwine37 commented Aug 30, 2024

This fixes the base file emulation framework mod reading into the original file if it was bigger than the emulated one and the entire file was read through something like File.ReadAllText.
This happened because in the NtReadFileImpl when the emulated file returned 0 bytes, the original read file function was called as a fallback. I've changed it so when the emulated file returns no bytes, an end of file status is returned. I don't think there is any scenario where we should be reading the original file if there is an emulated version available.

This pr also contains all of the commits from #17 since they somehow got lost on the main repo.

@AnimatedSwine37 AnimatedSwine37 changed the title Fix original file being read when it is smaller than the emulated version Fix original file being read when it is bigger than the emulated version Aug 30, 2024
}
else
{
_logger.Debug("[FileAccessServer] Read Fail, Length: {0}, Offset: {1}", numReadBytes, requestedOffset);
Copy link
Owner

@Sewer56 Sewer56 Aug 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with the change; this should say likely EOF though in brackets though.
The documentation for ReadData in the interface also needs updating.

Since this is (technically) a breaking change [in behaviour], we'd need to check with @LTSophia and @morgana-x before merging (whether anything breaks). I believe @LTSophia implemented support for some of the less commonly used games (e.g. JSR), and @morgana-x did danganrompa

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the ReadData documentation does this sound fine as the return value?

True if at least one byte was read, false otherwise (this indicates the EOF has been reached).

Copy link
Owner

@Sewer56 Sewer56 Aug 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds good to me.

In the Rust version, we gotta make sure that EOF will be explicitly defined. Unfortunately we can't change it here without breaking API.

If there's a real error (read fail), we would panic there in that case.

@morgana-x
Copy link

I don't think it would break anything, more than happy to update Wad File Emulator to work around the new update if it does

@Sewer56
Copy link
Owner

Sewer56 commented Sep 17, 2024

That works for me, I'll merge later today.

@Sewer56 Sewer56 merged commit 43adc6e into Sewer56:main Sep 20, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants