Skip to content

Update SetCredentialsAttributesW to match the native C API declaration - #131425

Merged
wfurt merged 1 commit into
dotnet:mainfrom
ksharperd:fix-131416
Jul 28, 2026
Merged

Update SetCredentialsAttributesW to match the native C API declaration#131425
wfurt merged 1 commit into
dotnet:mainfrom
ksharperd:fix-131416

Conversation

@ksharperd

Copy link
Copy Markdown
Contributor

Change the P/Invoke declaration for SetCredentialsAttributesW to use uint rather than long, since C unsigned long is 4 bytes on Windows.

Fix #131416

Copilot AI review requested due to automatic review settings July 27, 2026 16:46
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Jul 27, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@ksharperd

Copy link
Copy Markdown
Contributor Author

@dotnet-policy-service agree

@ksharperd please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@dotnet-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@dotnet-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@dotnet-policy-service agree company="Microsoft"

Contributor License Agreement

@dotnet-policy-service agree

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/ncl, @bartonjs, @vcsjones
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Windows SSPI interop for SetCredentialsAttributesW so its parameter widths match the native unsigned long (32-bit) declaration, preventing x86 stdcall name decoration mismatches during NativeAOT DirectPInvoke linking.

Changes:

  • Changed Interop.SspiCli.SetCredentialsAttributesW P/Invoke parameters from long to uint (4 bytes) to match native ULONG on Windows.
  • Updated the SslStreamPal.Windows call site to pass uint values for the attribute and buffer size.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/libraries/System.Net.Security/src/System/Net/Security/SslStreamPal.Windows.cs Updates the call site to pass 32-bit uint arguments matching the corrected P/Invoke signature.
src/libraries/Common/src/Interop/Windows/SspiCli/Interop.SSPI.cs Fixes SetCredentialsAttributesW P/Invoke signature to use 32-bit uint parameters for x86 correctness.

@wfurt

wfurt commented Jul 28, 2026

Copy link
Copy Markdown
Member

@ksharperd

Copy link
Copy Markdown
Contributor Author

The documentation shows "unsigned long": https://learn.microsoft.com/en-us/windows/win32/api/sspi/nf-sspi-setcredentialsattributesw

unsigned long is always 4 bytes on Windows, per #131416 (comment)

@wfurt

wfurt commented Jul 28, 2026

Copy link
Copy Markdown
Member

it sad the the compilation is not smart enough to know that but so be it...

@wfurt
wfurt merged commit 9f9485d into dotnet:main Jul 28, 2026
94 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.Net.Security community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DirectPInvoke with NativeAOT on Windows x86 fails on SetCredentialsAttributesW due to mismatched signature size

3 participants