Wrong values of Kernel32.FileShare.Delete and Kernel32.FileAttributes.PosixSemantics
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 83/100
Research direction
Open TruePath/Kernel32.cs and check the FileShare.Delete and FileAttributes.PosixSemantics declarations against the Windows values given in the issue. These members are currently unused, so confirm whether the project has relevant interop tests or references before making the two corrections. Done means both enum values match the stated constants and the project builds.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- C#
- Stars
- 107
- Forks
- 22
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 13
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ForNeVeR/TruePath
-
AbsolutePath.ReadKind allocates a new 16 KiB buffer per directory on Windows: the pooled buffer is not returned on failurePossibly taken @FalconTechDev claimed this today. Openenhancement good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ForNeVeR/TruePath#240 · 1 reaction ·
Maintainers usually reply within 1 day
-
enhancement good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ForNeVeR/TruePath#165 · 2 comments ·
Maintainers usually reply within 1 day
-
Windows tests: symlink access requires dev mode or elevated accessPossibly taken @hamdiakin claimed this today. Opendocumentation help wanted
Difficulty 3/5 1-2 days Newbie friendliness 57/100
ForNeVeR/TruePath#245 · 1 comment ·
Maintainers usually reply within 1 day
-
bug good first issue help wanted
Difficulty 3/5 Half a day Newbie friendliness 57/100
Maintainers usually reply within 1 day
-
enhancement help wanted
Difficulty 5/5 Over a week Newbie friendliness 35/100
Maintainers usually reply within 1 day
All issues in ForNeVeR/TruePath
Similar issues
-
bug priority: P2
Difficulty 1/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
[Docs] README/PRIVACY still name AppCenter although v1.5.6.0+ uses the Microsoft Store Services SDKOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Azure/azure-sdk-tools#17317 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
swisstopo/swissgeol-boreholes-suite#3086 ·
Maintainers usually reply within 1 day