Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CoreWlan] Make P/Invokes have blittable signatures. #20465

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/CoreWlan/CWKeychain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static partial class CWKeychain {
[UnsupportedOSPlatform ("maccatalyst")]
#endif
[DllImport (Constants.CoreWlanLibrary)]
static extern OSStatus CWKeychainCopyWiFiEAPIdentity (/* CWKeychainDomain */ nint domain, NSDataRef ssid, out SecIdentityRef identity);
unsafe static extern OSStatus CWKeychainCopyWiFiEAPIdentity (/* CWKeychainDomain */ nint domain, NSDataRef ssid, SecIdentityRef* identity);

#if NET
[SupportedOSPlatform ("macos")]
Expand All @@ -37,7 +37,9 @@ public static bool TryFindWiFiEAPIdentity (CWKeychainDomain domain, NSData ssid,
{
identity = null;
IntPtr outPtr = IntPtr.Zero;
status = CWKeychainCopyWiFiEAPIdentity ((nint) (long) domain, ssid.GetHandle (), out outPtr);
unsafe {
status = CWKeychainCopyWiFiEAPIdentity ((nint) (long) domain, ssid.GetHandle (), &outPtr);
}
if (status == 0) {
identity = new SecIdentity (outPtr, true);
}
Expand Down Expand Up @@ -105,7 +107,7 @@ public static bool TryDeleteWiFiPassword (CWKeychainDomain domain, NSData ssid)
[UnsupportedOSPlatform ("maccatalyst")]
#endif
[DllImport (Constants.CoreWlanLibrary)]
static extern OSStatus CWKeychainFindWiFiEAPUsernameAndPassword (/* CWKeychainDomain */ nint domain, NSDataRef ssid, out NSStringRef username, out NSStringRef password);
unsafe static extern OSStatus CWKeychainFindWiFiEAPUsernameAndPassword (/* CWKeychainDomain */ nint domain, NSDataRef ssid, NSStringRef* username, NSStringRef* password);

#if NET
[SupportedOSPlatform ("macos")]
Expand All @@ -117,7 +119,9 @@ public static bool TryFindWiFiEAPUsernameAndPassword (CWKeychainDomain domain, N
password = null;
NSStringRef usernamePtr = IntPtr.Zero;
NSStringRef passwordPtr = IntPtr.Zero;
status = CWKeychainFindWiFiEAPUsernameAndPassword ((nint) (long) domain, ssid.GetHandle (), out usernamePtr, out passwordPtr);
unsafe {
status = CWKeychainFindWiFiEAPUsernameAndPassword ((nint) (long) domain, ssid.GetHandle (), &usernamePtr, &passwordPtr);
}
if (usernamePtr != IntPtr.Zero) {
username = Runtime.GetNSObject<NSString> (usernamePtr, false);
}
Expand Down Expand Up @@ -158,7 +162,7 @@ public static bool TryFindWiFiEAPUsernameAndPassword (CWKeychainDomain domain, N
[UnsupportedOSPlatform ("maccatalyst")]
#endif
[DllImport (Constants.CoreWlanLibrary)]
static extern OSStatus CWKeychainFindWiFiPassword (/* CWKeychainDomain */ nint domain, NSDataRef ssid, out NSStringRef password);
unsafe static extern OSStatus CWKeychainFindWiFiPassword (/* CWKeychainDomain */ nint domain, NSDataRef ssid, NSStringRef* password);

#if NET
[SupportedOSPlatform ("macos")]
Expand All @@ -168,7 +172,9 @@ public static bool TryFindWiFiPassword (CWKeychainDomain domain, NSData ssid, ou
{
password = null;
NSStringRef passwordPtr = IntPtr.Zero;
status = CWKeychainFindWiFiPassword ((nint) (long) domain, ssid.GetHandle (), out passwordPtr);
unsafe {
status = CWKeychainFindWiFiPassword ((nint) (long) domain, ssid.GetHandle (), &passwordPtr);
}
if (passwordPtr != IntPtr.Zero) {
password = Runtime.GetNSObject<NSString> (passwordPtr, false);
}
Expand Down
3 changes: 0 additions & 3 deletions tests/cecil-tests/BlittablePInvokes.KnownFailures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,6 @@ public partial class BlittablePInvokes {
"System.Int32 AudioUnit.AUGraph::NewAUGraph(System.IntPtr&)",
"System.Int32 CoreVideo.CVDisplayLink::CVDisplayLinkTranslateTime(System.IntPtr,CoreVideo.CVTimeStamp,CoreVideo.CVTimeStamp&)",
"System.Int32 CoreVideo.CVMetalTextureCache::CVMetalTextureCacheCreate(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr&)",
"System.Int32 CoreWlan.CWKeychain::CWKeychainCopyWiFiEAPIdentity(System.IntPtr,System.IntPtr,System.IntPtr&)",
"System.Int32 CoreWlan.CWKeychain::CWKeychainFindWiFiEAPUsernameAndPassword(System.IntPtr,System.IntPtr,System.IntPtr&,System.IntPtr&)",
"System.Int32 CoreWlan.CWKeychain::CWKeychainFindWiFiPassword(System.IntPtr,System.IntPtr,System.IntPtr&)",
"System.Int32 Darwin.KernelQueue::kevent(System.Int32,Darwin.KernelEvent*,System.Int32,Darwin.KernelEvent*,System.Int32,Darwin.TimeSpec&)",
"System.Int32 ObjCRuntime.Runtime::_NSGetExecutablePath(System.Byte[],System.Int32&)",
"System.Int32 Security.Authorization::AuthorizationCreate(Security.AuthorizationItemSet*,Security.AuthorizationItemSet*,Security.AuthorizationFlags,System.IntPtr&)",
Expand Down