HaloSPV3/HXE

Replace non-WMI filesystem compression implemented in b31efb95

BinToss opened this issue · 5 comments

We'll use P/Invoke (built-in P/Invoke, dotnet/PInvoke, and/or CsWin32) to leverage DeviceIoControl for compression operations.

A FLOSS implementation such as DiscUtils is preferable, but there's a much higher risk disk error due to of developer-error.
Like many other file system utilities, it does not provide SetCompression methods or something similar. However, it provides everything needed to write this method.
This may also bypass file/directory handles.

The PR to close this issue is being held up by #232 which will be resolved by CodeDead/deadlock-dotnet-sdk

b31efb9
I hope this works the way I think it does.
I'm worried the attribute will be set without the file being compressed.


https://docs.microsoft.com/en-us/dotnet/api/system.io.fileattributes?view=net-6.0#remarks

It is not possible to change the compression status of a File object by using the File.SetAttributes method

Current Options

Traditional P/Invoke

pinvoke.net
PITA. Prefer the other two options.

P/Invoke and Win32 NuGet packages

github:dotnet/pinvoke
https://www.nuget.org/profiles/PInvoke
Most of what I'll use is in PInvoke.Kernel32

P/Invoke and Win32 code generation

github:microsoft/CsWin32
Produces smaller assemblies than PInvoke packages (when not using Trim).

DeviceIoControl sucks. It should be broken down into dozens if not hundreds of specific functions. Telling it what to do via const/enums is terrible for documentation. Some parameters aren't used or need to be passed slightly differently depending on the operation code you use.
I've lost count of how many times I rewritten the function call simply because I don't know what the operation needs from the parameters.
Does it expect a pointer of a specific type here?

Is it safe to cast SafeHandle to SafeObjectHandle?
Is it safe to case short* to void*?
Why do the PInvoke NuGet packages lack IOCTL constants?
Why is OmniSharp unable to use the code generated by CsWin32?
Why can't I do sizeof(typeof((short) variable))?

What was lost has been replaced...