Skip to content

Commit efd1956

Browse files
authored
Require CETCompat to be false and other improvements (#15)
* Disable CETCompat Solves issue described here: AssetRipper/AssetRipper#2047 * .NET 10 and Readme Update * Update .NET version in Directory.Build.props * TerraFX 10.0.26100.6 and publish.yaml fix - Changed TerraFX version from 10.0.26100.2 -> 10.0.26100.6 - Changed net9.0 path to net10.0 in publish.yaml - Removed TargetFramework property from .csproj - Added links to similar issues in README.md * All Files Filter name changed in Save Dialog To stay consistent with the standard convention and keep the behavior uniform across dialogs, I also changed All Files to All Files (*.*) in the Save File dialog.
1 parent 6e7a80a commit efd1956

File tree

8 files changed

+39
-19
lines changed

8 files changed

+39
-19
lines changed

.github/workflows/publish.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- name: Setup .NET
2727
uses: actions/setup-dotnet@v4
2828
with:
29-
dotnet-version: 9.0.x
29+
dotnet-version: 10.0.x
3030

3131
# https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/cross-compile#linux
3232
- name: Install Arm64 Dependencies
@@ -56,10 +56,10 @@ jobs:
5656
with:
5757
name: Example_${{ matrix.config.name }}
5858
path: |
59-
./AssetRipper.NativeDialogs.Example/bin/Release/net9.0/${{ matrix.config.runtime }}/publish/${{ matrix.config.executable }}
60-
./AssetRipper.NativeDialogs.Example/bin/Release/net9.0/${{ matrix.config.runtime }}/publish/*.dll
61-
./AssetRipper.NativeDialogs.Example/bin/Release/net9.0/${{ matrix.config.runtime }}/publish/*.so
62-
./AssetRipper.NativeDialogs.Example/bin/Release/net9.0/${{ matrix.config.runtime }}/publish/*.dylib
59+
./AssetRipper.NativeDialogs.Example/bin/Release/net10.0/${{ matrix.config.runtime }}/publish/${{ matrix.config.executable }}
60+
./AssetRipper.NativeDialogs.Example/bin/Release/net10.0/${{ matrix.config.runtime }}/publish/*.dll
61+
./AssetRipper.NativeDialogs.Example/bin/Release/net10.0/${{ matrix.config.runtime }}/publish/*.so
62+
./AssetRipper.NativeDialogs.Example/bin/Release/net10.0/${{ matrix.config.runtime }}/publish/*.dylib
6363
if-no-files-found: error
6464

6565
publish_web_api:
@@ -80,7 +80,7 @@ jobs:
8080
- name: Setup .NET
8181
uses: actions/setup-dotnet@v4
8282
with:
83-
dotnet-version: 9.0.x
83+
dotnet-version: 10.0.x
8484

8585
# https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/cross-compile#linux
8686
- name: Install Arm64 Dependencies
@@ -110,8 +110,8 @@ jobs:
110110
with:
111111
name: WebApi_${{ matrix.config.name }}
112112
path: |
113-
./AssetRipper.NativeDialogs.WebApi/bin/Release/net9.0/${{ matrix.config.runtime }}/publish/${{ matrix.config.executable }}
114-
./AssetRipper.NativeDialogs.WebApi/bin/Release/net9.0/${{ matrix.config.runtime }}/publish/*.dll
115-
./AssetRipper.NativeDialogs.WebApi/bin/Release/net9.0/${{ matrix.config.runtime }}/publish/*.so
116-
./AssetRipper.NativeDialogs.WebApi/bin/Release/net9.0/${{ matrix.config.runtime }}/publish/*.dylib
113+
./AssetRipper.NativeDialogs.WebApi/bin/Release/net10.0/${{ matrix.config.runtime }}/publish/${{ matrix.config.executable }}
114+
./AssetRipper.NativeDialogs.WebApi/bin/Release/net10.0/${{ matrix.config.runtime }}/publish/*.dll
115+
./AssetRipper.NativeDialogs.WebApi/bin/Release/net10.0/${{ matrix.config.runtime }}/publish/*.so
116+
./AssetRipper.NativeDialogs.WebApi/bin/Release/net10.0/${{ matrix.config.runtime }}/publish/*.dylib
117117
if-no-files-found: error

AssetRipper.NativeDialogs.Example/AssetRipper.NativeDialogs.Example.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<PublishAot>true</PublishAot>
6+
<CETCompat>false</CETCompat>
67
<InvariantGlobalization>true</InvariantGlobalization>
78
</PropertyGroup>
89

AssetRipper.NativeDialogs.WebApi/AssetRipper.NativeDialogs.WebApi.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Web">
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net9.0</TargetFramework>
54
<Nullable>enable</Nullable>
65
<ImplicitUsings>enable</ImplicitUsings>
76
<InvariantGlobalization>true</InvariantGlobalization>
87
<PublishAot>true</PublishAot>
8+
<CETCompat>false</CETCompat>
99
</PropertyGroup>
1010

1111
<ItemGroup>

AssetRipper.NativeDialogs/AssetRipper.NativeDialogs.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
5+
<CETCompat>false</CETCompat>
56

67
<PackageId>AssetRipper.NativeDialogs</PackageId>
78
<PackageTags>C# file</PackageTags>
@@ -13,7 +14,7 @@
1314
</PropertyGroup>
1415

1516
<ItemGroup>
16-
<PackageReference Include="TerraFX.Interop.Windows" Version="10.0.26100.2" />
17+
<PackageReference Include="TerraFX.Interop.Windows" Version="10.0.26100.6" />
1718
</ItemGroup>
1819

1920
<ItemGroup>

AssetRipper.NativeDialogs/OpenFileDialog.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Buffers;
2-
using System.Diagnostics;
32
using System.Runtime.CompilerServices;
43
using System.Runtime.Versioning;
54
using TerraFX.Interop.Windows;
@@ -37,7 +36,7 @@ public static class OpenFileDialog
3736
new Span<char>(buffer).Clear();
3837

3938
fixed (char* bufferPtr = buffer)
40-
fixed (char* filterPtr = "All Files\0*.*\0")
39+
fixed (char* filterPtr = "All Files (*.*)\0*.*\0\0")
4140
{
4241
OPENFILENAMEW ofn = default;
4342
ofn.lStructSize = (uint)Unsafe.SizeOf<OPENFILENAMEW>();
@@ -46,7 +45,7 @@ public static class OpenFileDialog
4645
ofn.nMaxFile = (uint)buffer.Length;
4746
ofn.lpstrFilter = filterPtr;
4847
ofn.nFilterIndex = 1; // The first pair of strings has an index value of 1.
49-
ofn.Flags = OFN.OFN_PATHMUSTEXIST | OFN.OFN_FILEMUSTEXIST;
48+
ofn.Flags = OFN.OFN_PATHMUSTEXIST | OFN.OFN_FILEMUSTEXIST | OFN.OFN_EXPLORER;
5049
if (Windows.GetOpenFileNameW(&ofn))
5150
{
5251
int length = Array.IndexOf(buffer, '\0');
@@ -116,7 +115,7 @@ public static class OpenFileDialog
116115
new Span<char>(buffer).Clear();
117116

118117
fixed (char* bufferPtr = buffer)
119-
fixed (char* filterPtr = "All Files\0*.*\0")
118+
fixed (char* filterPtr = "All Files (*.*)\0*.*\0\0")
120119
{
121120
OPENFILENAMEW ofn = default;
122121
ofn.lStructSize = (uint)Unsafe.SizeOf<OPENFILENAMEW>();

AssetRipper.NativeDialogs/SaveFileDialog.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static class SaveFileDialog
3535
char[] buffer = ArrayPool<char>.Shared.Rent(ushort.MaxValue + 1); // Should be enough for the overwhelming majority of cases.
3636
new Span<char>(buffer).Clear();
3737

38-
string filter = "All Files\0*.*\0\0";
38+
string filter = "All Files (*.*)\0*.*\0\0";
3939

4040
fixed (char* bufferPtr = buffer)
4141
fixed (char* filterPtr = filter)

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<TargetFramework>net9.0</TargetFramework>
3+
<TargetFramework>net10.0</TargetFramework>
44
<ImplicitUsings>enable</ImplicitUsings>
55
<LangVersion>Latest</LangVersion>
66
<Nullable>enable</Nullable>

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
11
# AssetRipper.NativeDialogs
22

33
A cross-platform library for picking files and folders in .NET applications.
4+
5+
## CETCompat requirement (Windows)
6+
7+
On Windows, downstream projects must disable `CETCompat`. Leaving it enabled may cause crashes when opening native file dialogs.
8+
9+
Add the following to the consuming project’s `.csproj`:
10+
11+
```xml
12+
<PropertyGroup>
13+
<CETCompat>false</CETCompat>
14+
</PropertyGroup>
15+
```
16+
### Why?
17+
18+
Native file dialogs can load .NET Framework components that do not support CET mitigations. When CETCompat is enabled, this may lead to shadow stack violations and runtime crashes. CET affects the entire process, so it must be disabled by the application that uses this library.
19+
20+
### Similar issues in other repositories
21+
- https://github.com/dotnet/wpf/issues/10483#issuecomment-2669897861
22+
- https://github.com/microsoft/PowerToys/issues/37254#issue-2826006174

0 commit comments

Comments
 (0)