From 365141ea1ecbad1e9d13f17c2010fe368097cc51 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 13 Aug 2026 22:11:24 +0000 Subject: [PATCH 1/5] Bump Microsoft.Windows.CsWin32 from 0.3.183 to 0.3.298 --- updated-dependencies: - dependency-name: Microsoft.Windows.CsWin32 dependency-version: 0.3.298 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- CompactGUI.Core/CompactGUI.Core.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CompactGUI.Core/CompactGUI.Core.csproj b/CompactGUI.Core/CompactGUI.Core.csproj index f7dd71b..25ce4f9 100644 --- a/CompactGUI.Core/CompactGUI.Core.csproj +++ b/CompactGUI.Core/CompactGUI.Core.csproj @@ -14,7 +14,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive From 93a663ac9c67f5238fb634b38683b29e0fae258f Mon Sep 17 00:00:00 2001 From: marcmy <21000174+marcmy@users.noreply.github.com> Date: Sun, 16 Aug 2026 02:09:17 -0400 Subject: [PATCH 2/5] Adapt DeviceIoControl handle for CsWin32 0.3.298 --- CompactGUI.Core/Estimator.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CompactGUI.Core/Estimator.cs b/CompactGUI.Core/Estimator.cs index b482a98..d0374fe 100644 --- a/CompactGUI.Core/Estimator.cs +++ b/CompactGUI.Core/Estimator.cs @@ -159,7 +159,7 @@ private float EstimateCompressabilityHDD(FileStream input, long fileSize, Compre unsafe long GetFirstLcn(string fileName) { - SafeFileHandle handle = File.OpenHandle(fileName); + using SafeFileHandle handle = File.OpenHandle(fileName); if (handle.IsInvalid) throw new IOException("Failed to open file handle for " + fileName); @@ -172,7 +172,7 @@ unsafe long GetFirstLcn(string fileName) uint bytesReturned = 0; var result = PInvoke.DeviceIoControl( - handle, + (Windows.Win32.Foundation.HANDLE)handle.DangerousGetHandle(), NTFSInterop.FSCTL_GET_RETRIEVAL_POINTERS, &inBuffer, inBufferSize, @@ -181,6 +181,8 @@ unsafe long GetFirstLcn(string fileName) &bytesReturned, null); + GC.KeepAlive(handle); + if (!result) return long.MaxValue; int extentOffset = Marshal.OffsetOf("Extents").ToInt32(); @@ -193,4 +195,4 @@ unsafe long GetFirstLcn(string fileName) -} +} \ No newline at end of file From a277c242d587b2b0478a57990b025eacc4ebfd4d Mon Sep 17 00:00:00 2001 From: marcmy <21000174+marcmy@users.noreply.github.com> Date: Sun, 16 Aug 2026 02:09:31 -0400 Subject: [PATCH 3/5] Adapt decompression handle for CsWin32 0.3.298 --- CompactGUI.Core/Uncompactor.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CompactGUI.Core/Uncompactor.cs b/CompactGUI.Core/Uncompactor.cs index e28b68d..db33830 100644 --- a/CompactGUI.Core/Uncompactor.cs +++ b/CompactGUI.Core/Uncompactor.cs @@ -147,7 +147,7 @@ private unsafe FileOperationResult WOFDecompressFile(string file) using (SafeFileHandle fs = File.OpenHandle(file)) { bool succeeded = PInvoke.DeviceIoControl( - fs, + (Windows.Win32.Foundation.HANDLE)fs.DangerousGetHandle(), WOFHelper.FSCTL_DELETE_EXTERNAL_BACKING, null, 0, @@ -156,6 +156,8 @@ private unsafe FileOperationResult WOFDecompressFile(string file) null, null); + GC.KeepAlive(fs); + if (succeeded) return new FileOperationResult(true); int errorCode = Marshal.GetLastWin32Error(); @@ -205,4 +207,4 @@ public void Dispose() -} +} \ No newline at end of file From ec9ff93828a8b670acb18edd90a932cbb7a037b3 Mon Sep 17 00:00:00 2001 From: marcmy <21000174+marcmy@users.noreply.github.com> Date: Sun, 16 Aug 2026 02:09:42 -0400 Subject: [PATCH 4/5] Update WOF call for CsWin32 0.3.298 --- CompactGUI.Core/WOFHelper.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CompactGUI.Core/WOFHelper.cs b/CompactGUI.Core/WOFHelper.cs index 0581f63..32fb525 100644 --- a/CompactGUI.Core/WOFHelper.cs +++ b/CompactGUI.Core/WOFHelper.cs @@ -102,7 +102,7 @@ public static unsafe WOFCompressionAlgorithm DetectCompression(FileInfo fileInfo WOFHelper.WOF_FILE_COMPRESSION_INFO_V1 info; uint buffer = 8; - var ret = PInvoke.WofIsExternalFile(fileInfo.FullName, &isExternalFile, &provider, &info, &buffer); + var ret = PInvoke.WofIsExternalFile(fileInfo.FullName, out isExternalFile, out provider, &info, ref buffer); WOFCompressionAlgorithm algorithm = (WOFCompressionAlgorithm)info.Algorithm; @@ -112,4 +112,4 @@ public static unsafe WOFCompressionAlgorithm DetectCompression(FileInfo fileInfo return algorithm; } -} +} \ No newline at end of file From a7c793b8e5115a0430fee419befa0ae1bf844b27 Mon Sep 17 00:00:00 2001 From: marcmy <21000174+marcmy@users.noreply.github.com> Date: Sun, 16 Aug 2026 02:10:03 -0400 Subject: [PATCH 5/5] Update filesystem calls for CsWin32 0.3.298 --- CompactGUI.Core/SharedMethods.cs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/CompactGUI.Core/SharedMethods.cs b/CompactGUI.Core/SharedMethods.cs index 74bca18..ae0f435 100644 --- a/CompactGUI.Core/SharedMethods.cs +++ b/CompactGUI.Core/SharedMethods.cs @@ -150,17 +150,14 @@ private static string GetShortPath(string filePath) - public static unsafe uint GetClusterSize(string folderPath) + public static uint GetClusterSize(string folderPath) { - UInt32 lpSectorsPerCluster; - UInt32 lpBytesPerSector; - PInvoke.GetDiskFreeSpace( new DirectoryInfo(folderPath).Root.ToString(), - &lpSectorsPerCluster, - &lpBytesPerSector, - null, - null + out UInt32 lpSectorsPerCluster, + out UInt32 lpBytesPerSector, + out _, + out _ ); return lpSectorsPerCluster * lpBytesPerSector; @@ -168,10 +165,9 @@ public static unsafe uint GetClusterSize(string folderPath) } - public static unsafe long GetFileSizeOnDisk(string file) + public static long GetFileSizeOnDisk(string file) { - uint highOrder; - uint lowOrder = PInvoke.GetCompressedFileSize(file, &highOrder); + uint lowOrder = PInvoke.GetCompressedFileSize(file, out uint highOrder); if (lowOrder == 0xFFFFFFFF && (Marshal.GetLastWin32Error() != 0)) return -1; return ((long)highOrder << 32) | lowOrder; } @@ -300,4 +296,4 @@ public static bool IsDirectStorageGameFolder(string folderPath) } -} +} \ No newline at end of file