Sewer56 / FileEmulationFramework

Framework for emulating files using Reloaded-II.
GNU Lesser General Public License v3.0
7 stars 7 forks source link

Incorrect file length reported by QueryFullAttributesFile #15

Open AnimatedSwine37 opened 7 months ago

AnimatedSwine37 commented 7 months ago

If a game calls NtQueryFullAttributesFile on a file before ever creating a handle with CreateFile the emulated file will not exist and the original file length will be reported. This is possible as NtQueryFullAttributesFile takes a file path instead of a handle and seemingly never makes uses CreateFile to get a handle internally.

As a workaround an emulator could forcibly create the emulated files before the game gets a chance to get its length. (Definitely not a permanent solution).

I found this occurring in Scarlet Nexus when using UTOC Emulator. The length of the ucas file is queried before it is opened, causing it to have an incorrect length. This is probably a rare occurrence but it can happen.