Skip to content

Commit

Permalink
Improve System.DirectoryServices interop guidelines conformance (#93722)
Browse files Browse the repository at this point in the history
* remove unused usings in SafeNativeMethods

* move OleAut32 VariantInit to Common Interop

* move Activeds FreeADsMem to Common Interop

* move Activeds ADsEncodeBinaryData to Common Interop

* move Activeds ADsGetLastError to Common Interop

* move Activeds ADsSetLastError to Common Interop

* move Netapi32 DsGetSiteName to Common Interop

* move Netapi32 DsEnumerateDomainTrustsW to Common Interop

* move Netapi32 NetApiBufferFree to Common Interop

* move Netapi32 I_NetLogonControl2 to Common Interop

* move Netapi32 DsRoleGetPrimaryDomainInformation to Common Interop

* move Netapi32 DsRoleFreeMemory to Common Interop

* move Netapi32 DsGetDcName to Common Interop

* move Netapi32 DsGetDcOpen to Common Interop

* move Netapi32 DsGetDcNext to Common Interop

* move Netapi32 DsGetDcClose to Common Interop

* move Advapi32 LsaSetForestTrustInformation to Common Interop

* move Advapi32 LsaQueryForestTrustInformation to Common Interop

* move TRUSTED_INFORMATION_CLASS enum to Common Interop (Advapi32)

* move Advapi32 LsaQueryTrustedDomainInfoByName to Common Interop

* move Advapi32 LsaSetTrustedDomainInfoByName to Common Interop

* move Advapi32 LsaDeleteTrustedDomain to Common Interop

* move Advapi32 LsaCreateTrustedDomainEx to Common Interop

* move TRUSTED_POSIX_OFFSET_INFO to Common Interop (Advapi32)

* move TRUSTED_DOMAIN_FULL_INFORMATION to Common Interop (Advapi32)

* move Advapi32 ImpersonateAnonymousToken to Common Interop

* move NtDll RtlInitUnicodeString to Common Interop

* move Kernel32 GetSystemTimeAsFileTime to Common Interop

* move Kernel32 OpenThread to Common Interop

* move Kernel32 CompareString to Common Interop

* move Dnsapi DnsQuery to Common Interop

* move Dnsapi DnsRecordListFree to Common Interop

* move Secur32 LsaDeregisterLogonProcess to Common Interop

* move Secur32 LsaLogonProcessSafeHandle to Common Interop

* move Secur32 LsaConnectUntrusted to Common Interop

* move Secur32 LsaCallAuthenticationPackage to Common Interop

* move Secur32 LsaFreeReturnBuffer to Common Interop

* use string instead of IntPtr in this interop method and obviate the need for mashalling and exception handling at the caller

suggested by review comment #93722 (comment)

* remove MarshalAs attribute from method parameter

the native signature called for LPCWSTR, not LPCTSTR, and this is handled by the StringMarshalling attribute on the method anyway

suggested by review comment #93722 (comment)

* do not set StringMarshalling when strings are not being marhsalled

* do not set EntryPoint when method name matches

* rename file now that it essentially only contains EnumVariant

* remove unused consts

* move Activeds error codes to Common Interop

* these errors are already defined in Common Interop, avoid duplicating them for Activeds

suggested by review comment #93722 (comment)

* consolidate these two overloads

suggested by review comment #93722 (comment)

* accept the enum rather than and int and do away with the casts

suggested by review comment #93722 (comment)

* move DS_DOMAINTRUST_FLAG to Common Interop

* move DS_DOMAIN_TRUSTS to Common Interop

* stop casting DS_DOMAIN_TRUSTS and use DS_DOMAINTRUST_FLAG directly

* make DS_DOMAINTRUST_FLAG a uint since the native sigs are ULONG (i.e. unsigned)

* remove blank line

* remove unused using after move of DS_DOMAINTRUST_FLAG

* change TRUSTED_DOMAIN_FULL_INFORMATION to a struct

suggested by review comment #93722 (comment)

* change TRUSTED_POSIX_OFFSET_INFO to a struct

suggested by review comment #93722 (comment)

* change DS_DOMAIN_TRUSTS to a struct

suggested by review comment #93722 (comment)

* use sizeof since DS_DOMAIN_TRUSTS is now a struct and is also blittable

suggested by review comment #93722 (comment)

* use sizeof since NegotiateCallerNameRequest is blittable

suggested by review comment #93722 (comment)

* make these not nullable

they appear not to be nullable on the unmanaged side
see https://learn.microsoft.com/en-us/windows/win32/api/ntsecapi/ns-ntsecapi-trusted_domain_full_information

suggested by review comment #93722 (comment)

* these are now blittable so use sizeof instead of Marshall.SizeOf

* take advantage of SpanMarshalling for ADsGetLastError

suggested by review comment #93722 (comment)

* reuse already defined win32 error ERROR_ALREADY_EXISTS from Interop.Errors

* move win32 error ERROR_INVALID_LEVEL to Interop.Errors

* remove unused error code ERROR_NOT_FOUND

* move win32 error ERROR_INVALID_DOMAINNAME to Interop.Errors

* move win32 error ERROR_NO_SUCH_DOMAIN to Interop.Errors

* remove unused error code ERROR_NOT_ENOUGH_MEMORY

* move win32 error ERROR_INVALID_FLAGS to Interop.Errors

* reuse already defined win32 error ERROR_NO_MORE_ITEMS from Interop.Errors

* move win32 error ERROR_FILEMARK_DETECTED to Interop.Errors

* move win32 error ERROR_NO_SUCH_LOGON_SESSION to Interop.Errors

* move win32 error DNS_ERROR_RCODE_NAME_ERROR to Interop.Errors

* consolidate these identical consts

* reuse already defined win32 error ERROR_NOT_ENOUGH_MEMORY from Interop.Errors

* move win32 error ERROR_OUTOFMEMORY to Interop.Errors

* move win32 error RPC_S_OUT_OF_RESOURCES to Interop.Errors

* move win32 error ERROR_DS_DRA_OUT_OF_MEM to Interop.Errors

* move win32 error ERROR_DS_DRA_ACCESS_DENIED to Interop.Errors

* move win32 error ERROR_NO_LOGON_SERVERS to Interop.Errors

* move win32 error RPC_S_SERVER_UNAVAILABLE to Interop.Errors

* move win32 error RPC_S_CALL_FAILED to Interop.Errors

* reuse already defined win32 error ERROR_ACCESS_DENIED from Interop.Errors

* move win32 error ERROR_NO_SITENAME to Interop.Errors

* move win32 error ERROR_DS_NAME_UNPARSEABLE to Interop.Errors

* move win32 error ERROR_DS_UNKNOWN_ERROR to Interop.Errors

* move win32 error ERROR_DS_DRA_BAD_DN to Interop.Errors

* reuse already defined win32 error ERROR_CANCELLED from Interop.Errors

* fix signature and use of ADsGetLastError

in 497bbb6 I got the semantics wrong

the native code is expecting the buffers to be not null, but using the SpanMarshaller results in a pit of failure for anyone who wants to call this code, since a span constructed over null (e.g. Span<char>.Empty) will get marshalled as a null pointer

instead, accept char[] to avoid this

i am renting an array for the error buffer to amortize the allocation cost, note that this may lead to error messages longer than 256 characters being returned where they would not have been before due to .Rent returning at least the requested size

avoided returning the rented array in a finally block since intervening code cannot throw

* simplify conversion to these blittable structs

partly related to discussion #93722 (comment)

* fix pre-existing bug which resulted in ArgumentException

at some point in the past, TRUSTED_DOMAIN_INFORMATION_EX was changed to a struct without updating this marshalling code, causing ArgumentExceptions to be thrown

suggested by review comment #93722 (comment)

* remove blank lines

* just allocate the array here rather than renting is it probably isn't worth it

suggested by review comment #93722 (comment)

* Fix error code ordering

Co-authored-by: Aaron Robinson <arobins@microsoft.com>

* Remove redundant EntryPoint property

Co-authored-by: Aaron Robinson <arobins@microsoft.com>

* Fix DsRoleFreeMemory signature

https://learn.microsoft.com/windows/win32/api/dsrole/nf-dsrole-dsrolefreememory

Co-authored-by: Aaron Robinson <arobins@microsoft.com>

* Fix RtlInitUnicodeString signature

https://learn.microsoft.com/windows/win32/api/winternl/nf-winternl-rtlinitunicodestring

Co-authored-by: Aaron Robinson <arobins@microsoft.com>

* Fix ImpersonateAnonymousToken signature and call sites

#93722 (comment)

https://learn.microsoft.com/en-us/windows/win32/api/securitybaseapi/nf-securitybaseapi-impersonateanonymoustoken

* Fix LsaCreateTrustedDomainEx parameter naming

https://learn.microsoft.com/en-gb/windows/win32/api/ntsecapi/nf-ntsecapi-lsacreatetrusteddomainex

Co-authored-by: Aaron Robinson <arobins@microsoft.com>

* Fix LsaSetForestTrustInformation signature and call sites

#93722 (comment)

https://learn.microsoft.com/windows/win32/api/ntsecapi/nf-ntsecapi-lsasetforesttrustinformation

* Use consistent visibility modifiers for TRUSTED_DOMAIN_FULL_INFORMATION struct fields

Co-authored-by: Aaron Robinson <arobins@microsoft.com>

* Remove redundant EntryPoint property

Co-authored-by: Aaron Robinson <arobins@microsoft.com>

* Fix DsGetDcNext signature and call sites

#93722 (comment)

https://learn.microsoft.com/en-us/windows/win32/api/dsgetdc/nf-dsgetdc-dsgetdcnextw

* remove unused method and purge now-unused Dnsapi interop code

* fix memory leak by freeing socket address list after each DsGetDcNext call

discussed at #93722 (comment)

https://learn.microsoft.com/en-us/windows/win32/api/dsgetdc/nf-dsgetdc-dsgetdcnextw

* remove more unused Dndsapi-related code

* remove unused const

was replaced by Interop.StatusOptions.STATUS_QUOTA_EXCEEDED at some point in the past

---------

Co-authored-by: Aaron Robinson <arobins@microsoft.com>
  • Loading branch information
chrisdcmoore and AaronRobinsonMSFT authored Jan 12, 2024
1 parent 9fde15e commit 283a2de
Show file tree
Hide file tree
Showing 60 changed files with 934 additions and 804 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Runtime.InteropServices;

internal static partial class Interop
{
internal static partial class Activeds
{
[LibraryImport(Libraries.Activeds)]
internal static partial int ADsEncodeBinaryData(byte[] data, int length, ref IntPtr result);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Runtime.InteropServices;

internal static partial class Interop
{
internal static partial class Activeds
{
[LibraryImport(Libraries.Activeds)]
internal static partial int ADsGetLastError(out int error, char[] errorBuffer, int errorBufferLength, char[] nameBuffer, int nameBufferLength);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.InteropServices;

internal static partial class Interop
{
internal static partial class Activeds
{
[LibraryImport(Libraries.Activeds, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int ADsSetLastError(int error, string? errorString, string? provider);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Runtime.InteropServices;

internal static partial class Interop
{
internal static partial class Activeds
{
[LibraryImport(Libraries.Activeds)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool FreeADsMem(IntPtr pVoid);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Runtime.InteropServices;

internal static partial class Interop
{
internal static partial class Advapi32
{
[LibraryImport(Libraries.Advapi32, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool ImpersonateAnonymousToken(IntPtr token);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Runtime.InteropServices;
using Microsoft.Win32.SafeHandles;

internal static partial class Interop
{
internal static partial class Advapi32
{
[Flags]
internal enum TRUST_ATTRIBUTE
{
TRUST_ATTRIBUTE_NON_TRANSITIVE = 0x00000001,
TRUST_ATTRIBUTE_UPLEVEL_ONLY = 0x00000002,
TRUST_ATTRIBUTE_QUARANTINED_DOMAIN = 0x00000004,
TRUST_ATTRIBUTE_FOREST_TRANSITIVE = 0x00000008,
TRUST_ATTRIBUTE_CROSS_ORGANIZATION = 0x00000010,
TRUST_ATTRIBUTE_WITHIN_FOREST = 0x00000020,
TRUST_ATTRIBUTE_TREAT_AS_EXTERNAL = 0x00000040
}

[StructLayout(LayoutKind.Sequential)]
internal struct TRUSTED_DOMAIN_INFORMATION_EX
{
public UNICODE_STRING Name;
public UNICODE_STRING FlatName;
public IntPtr Sid;
public int TrustDirection;
public int TrustType;
public TRUST_ATTRIBUTE TrustAttributes;
}

[StructLayout(LayoutKind.Sequential)]
internal struct TRUSTED_DOMAIN_AUTH_INFORMATION
{
public int IncomingAuthInfos;
public IntPtr IncomingAuthenticationInformation;
public IntPtr IncomingPreviousAuthenticationInformation;
public int OutgoingAuthInfos;
public IntPtr OutgoingAuthenticationInformation;
public IntPtr OutgoingPreviousAuthenticationInformation;
}

[LibraryImport(Libraries.Advapi32)]
internal static partial uint LsaCreateTrustedDomainEx(SafeLsaPolicyHandle handle, in TRUSTED_DOMAIN_INFORMATION_EX domainEx, in TRUSTED_DOMAIN_AUTH_INFORMATION authInfo, int desiredAccess, out IntPtr domainHandle);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Runtime.InteropServices;
using Microsoft.Win32.SafeHandles;

internal static partial class Interop
{
internal static partial class Advapi32
{
[LibraryImport(Libraries.Advapi32)]
internal static partial uint LsaDeleteTrustedDomain(SafeLsaPolicyHandle handle, IntPtr pSid);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Runtime.InteropServices;
using Microsoft.Win32.SafeHandles;

internal static partial class Interop
{
internal static partial class Advapi32
{
[LibraryImport(Libraries.Advapi32)]
internal static partial uint LsaQueryForestTrustInformation(SafeLsaPolicyHandle handle, in UNICODE_STRING target, ref IntPtr ForestTrustInfo);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Runtime.InteropServices;
using Microsoft.Win32.SafeHandles;

internal static partial class Interop
{
internal static partial class Advapi32
{
[LibraryImport(Libraries.Advapi32)]
internal static partial uint LsaQueryTrustedDomainInfoByName(SafeLsaPolicyHandle handle, in UNICODE_STRING trustedDomain, TRUSTED_INFORMATION_CLASS infoClass, ref IntPtr buffer);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Runtime.InteropServices;
using Microsoft.Win32.SafeHandles;

internal static partial class Interop
{
internal static partial class Advapi32
{
[LibraryImport(Libraries.Advapi32)]
internal static partial uint LsaSetForestTrustInformation(SafeLsaPolicyHandle handle, in UNICODE_STRING target, IntPtr forestTrustInfo, [MarshalAs(UnmanagedType.U1)] bool checkOnly, out IntPtr collisionInfo);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Runtime.InteropServices;
using Microsoft.Win32.SafeHandles;

internal static partial class Interop
{
internal static partial class Advapi32
{
[LibraryImport(Libraries.Advapi32)]
internal static partial uint LsaSetTrustedDomainInfoByName(SafeLsaPolicyHandle handle, in UNICODE_STRING trustedDomain, TRUSTED_INFORMATION_CLASS infoClass, IntPtr buffer);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.InteropServices;

internal static partial class Interop
{
internal static partial class Advapi32
{
[StructLayout(LayoutKind.Sequential)]
internal struct TRUSTED_DOMAIN_FULL_INFORMATION
{
internal TRUSTED_DOMAIN_INFORMATION_EX Information;
internal TRUSTED_POSIX_OFFSET_INFO PosixOffset;
internal TRUSTED_DOMAIN_AUTH_INFORMATION AuthInformation;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

internal static partial class Interop
{
internal static partial class Advapi32
{
internal enum TRUSTED_INFORMATION_CLASS
{
TrustedDomainNameInformation = 1,
TrustedControllersInformation,
TrustedPosixOffsetInformation,
TrustedPasswordInformation,
TrustedDomainInformationBasic,
TrustedDomainInformationEx,
TrustedDomainAuthInformation,
TrustedDomainFullInformation,
TrustedDomainAuthInformationInternal,
TrustedDomainFullInformationInternal,
TrustedDomainInformationEx2Internal,
TrustedDomainFullInformation2Internal
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.InteropServices;

internal static partial class Interop
{
internal static partial class Advapi32
{
[StructLayout(LayoutKind.Sequential)]
internal struct TRUSTED_POSIX_OFFSET_INFO
{
internal int Offset;
}
}
}
18 changes: 18 additions & 0 deletions src/libraries/Common/src/Interop/Windows/Interop.Errors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ internal static partial class Errors
internal const int ERROR_INVALID_HANDLE = 0x6;
internal const int ERROR_NOT_ENOUGH_MEMORY = 0x8;
internal const int ERROR_INVALID_DATA = 0xD;
internal const int ERROR_OUTOFMEMORY = 0xE;
internal const int ERROR_INVALID_DRIVE = 0xF;
internal const int ERROR_NO_MORE_FILES = 0x12;
internal const int ERROR_NOT_READY = 0x15;
Expand All @@ -34,6 +35,7 @@ internal static partial class Errors
internal const int ERROR_CALL_NOT_IMPLEMENTED = 0x78;
internal const int ERROR_INSUFFICIENT_BUFFER = 0x7A;
internal const int ERROR_INVALID_NAME = 0x7B;
internal const int ERROR_INVALID_LEVEL = 0x7C;
internal const int ERROR_MOD_NOT_FOUND = 0x7E;
internal const int ERROR_NEGATIVE_SEEK = 0x83;
internal const int ERROR_DIR_NOT_EMPTY = 0x91;
Expand Down Expand Up @@ -62,24 +64,29 @@ internal static partial class Errors
internal const int ERROR_OPERATION_ABORTED = 0x3E3;
internal const int ERROR_IO_INCOMPLETE = 0x3E4;
internal const int ERROR_IO_PENDING = 0x3E5;
internal const int ERROR_INVALID_FLAGS = 0x3EC;
internal const int ERROR_NO_TOKEN = 0x3f0;
internal const int ERROR_SERVICE_DOES_NOT_EXIST = 0x424;
internal const int ERROR_EXCEPTION_IN_SERVICE = 0x428;
internal const int ERROR_PROCESS_ABORTED = 0x42B;
internal const int ERROR_FILEMARK_DETECTED = 0x44D;
internal const int ERROR_NO_UNICODE_TRANSLATION = 0x459;
internal const int ERROR_DLL_INIT_FAILED = 0x45A;
internal const int ERROR_COUNTER_TIMEOUT = 0x461;
internal const int ERROR_NO_ASSOCIATION = 0x483;
internal const int ERROR_DDE_FAIL = 0x484;
internal const int ERROR_DLL_NOT_FOUND = 0x485;
internal const int ERROR_NOT_FOUND = 0x490;
internal const int ERROR_INVALID_DOMAINNAME = 0x4BC;
internal const int ERROR_CANCELLED = 0x4C7;
internal const int ERROR_NETWORK_UNREACHABLE = 0x4CF;
internal const int ERROR_NON_ACCOUNT_SID = 0x4E9;
internal const int ERROR_NOT_ALL_ASSIGNED = 0x514;
internal const int ERROR_UNKNOWN_REVISION = 0x519;
internal const int ERROR_INVALID_OWNER = 0x51B;
internal const int ERROR_INVALID_PRIMARY_GROUP = 0x51C;
internal const int ERROR_NO_LOGON_SERVERS = 0x51F;
internal const int ERROR_NO_SUCH_LOGON_SESSION = 0x520;
internal const int ERROR_NO_SUCH_PRIVILEGE = 0x521;
internal const int ERROR_PRIVILEGE_NOT_HELD = 0x522;
internal const int ERROR_INVALID_ACL = 0x538;
Expand All @@ -88,16 +95,27 @@ internal static partial class Errors
internal const int ERROR_BAD_IMPERSONATION_LEVEL = 0x542;
internal const int ERROR_CANT_OPEN_ANONYMOUS = 0x543;
internal const int ERROR_NO_SECURITY_ON_OBJECT = 0x546;
internal const int ERROR_NO_SUCH_DOMAIN = 0x54B;
internal const int ERROR_CANNOT_IMPERSONATE = 0x558;
internal const int ERROR_CLASS_ALREADY_EXISTS = 0x582;
internal const int ERROR_NO_SYSTEM_RESOURCES = 0x5AA;
internal const int ERROR_TIMEOUT = 0x5B4;
internal const int ERROR_EVENTLOG_FILE_CHANGED = 0x5DF;
internal const int RPC_S_OUT_OF_RESOURCES = 0x6B9;
internal const int RPC_S_SERVER_UNAVAILABLE = 0x6BA;
internal const int RPC_S_CALL_FAILED = 0x6BE;
internal const int ERROR_TRUSTED_RELATIONSHIP_FAILURE = 0x6FD;
internal const int ERROR_RESOURCE_TYPE_NOT_FOUND = 0x715;
internal const int ERROR_RESOURCE_LANG_NOT_FOUND = 0x717;
internal const int RPC_S_CALL_CANCELED = 0x71A;
internal const int ERROR_NO_SITENAME = 0x77F;
internal const int ERROR_NOT_A_REPARSE_POINT = 0x1126;
internal const int ERROR_DS_NAME_UNPARSEABLE = 0x209E;
internal const int ERROR_DS_UNKNOWN_ERROR = 0x20EF;
internal const int ERROR_DS_DRA_BAD_DN = 0x20F7;
internal const int ERROR_DS_DRA_OUT_OF_MEM = 0x20FE;
internal const int ERROR_DS_DRA_ACCESS_DENIED = 0x2105;
internal const int DNS_ERROR_RCODE_NAME_ERROR = 0x232B;
internal const int ERROR_EVT_QUERY_RESULT_STALE = 0x3AA3;
internal const int ERROR_EVT_QUERY_RESULT_INVALID_POSITION = 0x3AA4;
internal const int ERROR_EVT_INVALID_EVENT_DATA = 0x3A9D;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ internal static partial class Libraries
internal const string Credui = "credui.dll";
internal const string Crypt32 = "crypt32.dll";
internal const string CryptUI = "cryptui.dll";
internal const string Dnsapi = "dnsapi.dll";
internal const string Dsrole = "dsrole.dll";
internal const string Gdi32 = "gdi32.dll";
internal const string HttpApi = "httpapi.dll";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Runtime.InteropServices;

internal static partial class Interop
{
internal static partial class Kernel32
{
[LibraryImport(Libraries.Kernel32, EntryPoint = "CompareStringW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
internal static partial int CompareString(
uint locale,
uint dwCmpFlags,
string lpString1,
int cchCount1,
string lpString2,
int cchCount2);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Runtime.InteropServices;

internal static partial class Interop
{
internal static partial class Kernel32
{
[LibraryImport(Libraries.Kernel32)]
internal static partial void GetSystemTimeAsFileTime(IntPtr fileTime);
}
}
Loading

0 comments on commit 283a2de

Please sign in to comment.