-
Notifications
You must be signed in to change notification settings - Fork 165
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
[Cyberpunk 2077] Conflicts with VFS when using RedFileSystem plugin #2039
Comments
Your problem is not clear to me - When launching anything through MO2, you should not care if it is in Can you clarify the actual issue with a minimal example, i.e., what files do you have in each mods, what files do you expect to see and at which location in the game and what you actually see? |
Sorry, I'll start again:
I was because RedFileSystem implement a security measure, which is supposed to prevent modders to access files outside of Here an example with HUD Painter installed.
Archive of HUD Painter embeds a file:
HUD Painter at startup request its storage endpoint in:
RFS tests if directory exists or not. First time, it doesn't exist. So RFS creates this directory (logs shows it works, no error from STL). But directory is not created in HUD Painter need to read the file (1), MO2 provides this path (2):
HUD Painter write a new file (1), MO2 provides this path (2):
Because of bug A, directory doesn't exist, so file is not created. When writing new file, I can use
When starting the game again, it list both files as expected:
Restarting the game is not convenient nor expected (bug B). It looks like mapping of new directory is not taken into account by VFS of MO2. I hope it is explicit enough. |
If I summarize what you're saying, MO2 does not return what you expect when using |
Yes, when using it for security purpose. But I can probably workaround this issue later. The main problem is described when not using
I'll try to reproduce an example, with the same steps. |
@poirierlouis The expected behaviour of running a program or tool through the MO2 Virtual File System, is that it would not be able to notice it is being virtualized or not. So the unexpected behaviour here is the fact that RedFileSystem should be getting the virtual path inside the game folder, but it is getting the actual path. Regarding Bug A and Bug B. I think the issue is that RedFileSystem is trying to use the Actual path that you get returned by By doing so RedFileSystem is bypassing the VFS, as we are not watching the MO2 Overwrite path, we are watching the game path. The idea is that RedFileSystem should be getting back the virtual path of The VFS will not actually generate the empty folder in overwrite, but it should keep track of it in memory. So if you attempt to generate a file inside it, VFS will know that a folder is supposed to exist, and auto generate all the missing directories in overwrite needed for that new file, even though the file create operation was supposed to fail if parent folders were missing. This should all be invisible to the application. So the takeaway for us here is that it seems there is a problem with The takeaway for you would be that RedFileSystem is supposed to use the Virtual paths, not the actual MO2 paths. Using those virtual paths, we expect the VFS to give back the results you would expect as if it weren't there. |
This might be related to the USVFS bug that affects OpenMW, as that appeared when we switched from |
@Al12rs thank you for all the details.
It was indeed a misconception on my part at first, to try and workaround issues met with MO2 VFS.
I understand that it is an issue from MO2 VFS then. And I should be able to use it regarding the security use case I talked about. Without trying to workaround. Which brings me to:
Currently, and it only applies regarding bug A and B,
I take it is an issue from MO2 VFS on this matter, and RedFileSystem is not supposed to use
Like stated above, this is all good for me. Anyway, I'll come back to you with an example ASAP. |
|
That definitely sounds like something we should be hooking seeing as we're giving a handle to the real file and unhooked, it'd give the non-VFS path. |
I actually found a mistake on my end when using rfs_mo2_vfs_issue.txt Two issues then:
Edit: fix attachment. |
@poirierlouis I'm not sure I got everything correctly. My assumption is that all issues can be traced back to the fact that some Are you saying that even if you make sure the paths passed are all virtual, and you create the parent folder and then the child file, it still fails? My assumption was that it failed because the path constructed for Are you saying that is not the case and that there is a problem with file creation on top of |
Yes. Workaround is to actually call
I don't know, maybe, I lack knowledge about how MO2 VFS works under the hood to answer. |
To explain the role of Overwrite, basically if a new file is created (not replacing an existing file) inside the Game folder, we wouldn't know in which mod folder to put this file, so we put it in a special mod we call Overwrite (because it comes last and potentially overwrites all other mods in case of conflicts). So here is how the VFS is supposed to behave:
I know we have code to handle this in USVFS, so perhaps there is a bug somewhere, or at some point the paths get converted to actual paths, which then bypass the vfs, and that is the actual issue. |
So, the issue I have with that is:
Does it matter how the file is created? As in: should the path be absolute and resolve to overwrite, or to the game folder? Relative doesn't work as that will create the file in /bin |
It does not matter from a game point-of-view (or any hooked program), you should never have to deal with From your point-of-view, it's either relative to the game folder or absolute (but absolute in the game folder, not in MO2 folder). |
Hmm thanks. I'll try with the full game path then. relative doesn't work as the file gets created in the script extender assembly directory (unless I do something like ../../../r6/storage/newFile.json I suppose |
I tried again this time without using In the end, |
Perfect, thank you very much for testing this and reporting back! The problem on the USVFS side then is that @qudix was saying that he managed to trace back the implementation of it to I think we should be able to add a hook to |
When I was chatting with @Al12rs earlier today after some work stuff, he mentioned this issue. Anyway, I've had a double check with some Windows binaries, in addition to Wine
You always want to go for the lowest level user mode functions. So shoot straight for ntdll. I checked the relationships with the higher level APIs of course. Anyway first thing you need to hook is However, this is not the only function needed. For Windows, you also need to hook For Note: In some old snippets of reversed source code on the web, you'll also find I've also written a VFS before, from scratch before I knew USVFS existed (I kinda found out it's been done before 70% into development). Mine was a read only one though 😉 Hope that helps. Happy Hacking 👍 |
Thanks @Sewer56 🙏 |
The problem:
I'm the author of the mod RedFileSystem which allow other modders to read/write files in what I call storage endpoints. Currently, when running Cyberpunk with RedFileSystem and HUDPainter it will not work when using MO2. Path is somehow mixed up between what RedFileSystem expect and what MO2 provides.
To Reproduce:
Environment:
Details:
Hierarchy without MO2 is:
HUDPainter embed a file in its archive to serve to users:
It introduces different mappings when RedFileSystem is used to read / write a file. It is also broken when RFS is used to list files of a storage (using
directory_iterator
):<GAME>
/r6/storages/HUDPainter<MO2>
/mods/HUD Painter/r6/storages/HUDPainter<MO2>
/overwrite/r6/storages/HUDPainterSo far we have been able to bring fixes in RedFileSystem. But, in this case,
r6\storages\HUDPainter\DEFAULT.json
will not be in<MO2>\overwrite\...
but in<MO2>\mods\HUD Painter\...
.My understanding is that when reading an existing file from an installed mod, path "send" to RFS will start with
<MO2>\mods\[ModName]\...
while writing a new file using RFS, path "send" to RFS will start with<MO2>\overwrite\...
.See also this PR where we are discussing this issue.
I'd appreciate any advice and help to work this problem, in order to allow players to use RedFileSystem together with MO2.
More specifically, is it possible to detect/get if a path will be in
<GAME>
,<MO2>\overwrite
or<MO2>\mods\[ModName]
?A proposal might be to update MO2 such as path
r6\storages
could be an exception?Link to Mod Organizer logs:
USVFS:
MO Interface:
The text was updated successfully, but these errors were encountered: