Wrong values of Kernel32.FileShare.Delete and Kernel32.FileAttributes.PosixSemantics
维护者通常 1 天内回复
评估
调研方向
打开TruePath/Kernel32.cs,并将FileShare.Delete和FileAttributes.PosixSemantics的声明与 issue 中给出的 Windows 值进行核对。这些成员目前未使用,因此在进行两处更正之前,请确认项目是否有相关的 interop 测试或引用。两项 enum 值都与给出的常量一致且项目构建成功,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Two members of the Win32 interop enums in Kernel32.cs have values that don't match the Windows headers:
| Member | Current value | Correct value |
|---|---|---|
FileShare.Delete |
0x03 (that is Read | Write) |
0x04 (FILE_SHARE_DELETE) |
FileAttributes.PosixSemantics |
0x0100000 (seven digits, 0x100000) |
0x01000000 (FILE_FLAG_POSIX_SEMANTICS) |
As written, PosixSemantics has the same value as OpenNoRecall (0x00100000, line 96).
Neither member is used anywhere right now (only FileShare.Read is), so nothing is broken today. But passing either one to CreateFile would silently request different behavior from the one intended: FileShare.Delete would grant read and write sharing instead of delete sharing, and PosixSemantics would request FILE_FLAG_OPEN_NO_RECALL instead.
Repro (the enums are internal, hence the reflection):
var k32 = typeof(AbsolutePath).Assembly.GetType("TruePath.Kernel32")!;
uint Get(string type, string name) =>
Convert.ToUInt32(Enum.Parse(k32.GetNestedType(type, BindingFlags.NonPublic)!, name));
Console.WriteLine($"0x{Get("FileShare", "Delete"):X}"); // 3, expected 4
Console.WriteLine($"0x{Get("FileAttributes", "PosixSemantics"):X}"); // 100000, expected 1000000
All the other constants in the file (FileAttributes, FileAccess, FileShare, the FSCTL_*/IOCTL_* codes, the reparse tags) match the Windows headers.
Recommendations
- Fix the two values.
- Prefer not to hand-roll these declarations at all: either delete the unused members, or generate the interop with CsWin32, which takes the values from the official metadata.
- 主要语言
- C#
- 星标
- 107
- 派生
- 22
- 平均合并
- 3 天 2 小时
- 30 天内合并 PR
- 13
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ForNeVeR/TruePath 的其他 Issue
-
AbsolutePath.ReadKind allocates a new 16 KiB buffer per directory on Windows: the pooled buffer is not returned on failure可能已有人在做 @FalconTechDev 今天认领。 未关闭enhancement good first issue help wanted
难度 2/5 1-3 小时 新手友好度 78/100
ForNeVeR/TruePath#240 · 1 个 reaction ·
维护者通常 1 天内回复
-
enhancement good first issue help wanted
难度 2/5 1-3 小时 新手友好度 68/100
ForNeVeR/TruePath#165 · 2 条评论 ·
维护者通常 1 天内回复
-
Windows tests: symlink access requires dev mode or elevated access可能已有人在做 @hamdiakin 今天认领。 未关闭documentation help wanted
难度 3/5 1-2 天 新手友好度 57/100
ForNeVeR/TruePath#245 · 1 条评论 ·
维护者通常 1 天内回复
-
bug good first issue help wanted
难度 3/5 半天 新手友好度 57/100
维护者通常 1 天内回复
-
enhancement help wanted
难度 5/5 一周以上 新手友好度 35/100
维护者通常 1 天内回复
查看 ForNeVeR/TruePath 的全部 Issue
相似的 Issue
-
bug priority: P2
难度 1/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 77/100
维护者通常 1 天内回复
-
[Docs] README/PRIVACY still name AppCenter although v1.5.6.0+ uses the Microsoft Store Services SDK未关闭
难度 2/5 1-3 小时 新手友好度 78/100
-
needs-triage
难度 2/5 1-3 小时 新手友好度 72/100
Azure/azure-sdk-tools#17317 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 66/100
swisstopo/swissgeol-boreholes-suite#3086 ·
维护者通常 1 天内回复