-
Notifications
You must be signed in to change notification settings - Fork 3
Fixup: MfrFixup
The MfrFixup ("Managed File Redirection Fixup", or MFR for short) is a workhorse fixup library that intercepts a wide variety of Windows API calls that involve the Windows file system and may need help under MSIX. The MfrFixup is the replacement for the FileRedirectionFixup (FRF) library, written to encapsulate all of the knowledge gained in building the FRF over the last several years into a more functional and capable replacement. Like the FRF, the MFR intercepts a wide variety of Windows API calls that involve the Windows file system and may need help under MSIX.
The general causes of issues resulting in needing the MFR include:
- Files that are part of the package under either the 'VFS\AppData' or 'VFS\LocalAppData' folders are not seen by the application. On Windows 10 versions prior to 2004 (20H1) this would also happen to package files under 'VFS\AppDataCommon'. This issue usually occurs when the application attempts to use the normal path that the application would use when natively installed. Unlike other VFS folders in the package, these folders are not correctly layered and the application will not see the files in the package without MFR assistance.
- Files in other VFS folders of the package that the application needs to open for modify. The MFR can assist with this when not in Ilv-Aware mode, but with the default mode of Ilv-Aware it redirects all relevant calls to use the package path and lets InstalledLocationVirtualization do the rest.
- Files in non VFS folders of the package that the application needs to open for modify.
- Accesses that may work improperly due to other redirection. The MFR will apply Reverse VFS and Reverse Redirection logic when necessary.
- Redirection to local system. The MFR will apply Reverse VFS Redirection logic to allow the application to write to certain folders where files may be shared with other applications, such as the Desktop folder.
When the MFR is used, as files are accessed by the application, an evaluation will be made as to if there is a source for the file inside the package and cause a Copy-on-Write (rather than the Copy-on-Access implemented in the FRF) to be made into the MsixWritablePackageRoot folder of the user's LocalAppData folder for this package (if there isn't one already present). It will then complete the call by using redirection to this copy instead.
The MFR intercepts calls to Open and Find folders and files, however, it does not need to intercept the read/write/close associated with that file access and the intercepted call returns a handle to the application which is then used for those operations, ensuring that the activity will also affect the redirected file without additional interceptions.
The MFR currently targets the following Windows API Calls:
API | API | API | API | API |
---|---|---|---|---|
CopyFile | CopyFileEx | CopyFile2 | CreateDirectory | CreateDirectoryEx |
CreateFile | CreateFile2 | CreateHardLink | CreateSymbolicLink | DeleteFile |
GetFileAttributes | GetFileAttributesEx | FindNextFile | FindFirstFileEx | FindNextFile |
FindClose | GetCurrentDirectory | GetPrivateProfileInt | GetPrivateProfileSection | GetPrivateProfileSectionNames |
GetPrivateProfileString | GetPrivateProfileStruct | MoveFile | MoveFileEx (KernelBase) | MoveFileEx (Kernel32) |
MoveFileWithProgress | ReadDirectoryChangesW | ReadDirectoryChangesEx | RemoveDirectory | ReplaceFile |
SearchPath | SetCurrentDirectory | SetFileAttributes | ShellExecute | ShellExecuteEx |
WritePrivateProfileSection | WritePrivateProfileString | WritePrivateProfileStruct |
The MFR has two modes, the default Ilv-Aware enabled and a disabled mode.
The IlvAware true mode assumes that the package level extension "InstalledLocationVirtualization" (ILV) will be added to the package AppXManifest by you via other means. When enabled, the MFR will direct calls to use the package paths whenever possible, allowing ILV to take care of Copy-on-Write and checking the redirection area for additional files. The MFR is still available to provide native to VFS path mapping for those VFS folders not supported by the MSIX runtime, and to provide full redirection support when files should be written to the native file paths, such as to the user's Documents folder.
The IlvAware false mode will assume ILV is not in place and handle all Copy-on-Write and redirection functions itself, in a similar but more advanced form of what the FileRedirectionFixup does.
It is inadvisable to use InstalledLocationVirtualization in a package using either the FileRedirectionFixup in any configuration, or the MfrFixup with IlvAware set to false.
To apply an override to leverage InstalledLocationVirtualization and yet prevent binary files to be written to the redirection area, this might be used:
...
"fixups": [
{
"dll": "MFRFixup.dll",
"config": {
"ilvAware": "true",
"overrideCOW": "default"
}
}
]
...
https://github.com/TimMangan/MSIX-PackageSupportFramework/tree/develop/fixups/MFRFixup#readme