未验证 提交 2bc86980 编写于 作者: T Thad House 提交者: GitHub

Switch MsQuicOpen to MsQuicOpenVersion (#54443)

* Switch MsQuicOpen to MsQuicOpenVersion

MsQuicOpenVersion is designed so we can update the API without breaking old consumers. The version of MsQuic specified in the readme already has this change, so it is safe to completely switch over.

Also switches the API to function pointers, as it was easier then updating the delegate too.

* Add version contant
上级 d08c08d2
......@@ -119,18 +119,19 @@ private MsQuicApi(NativeApi* vtable)
internal static bool IsQuicSupported { get; }
private const int MsQuicVersion = 1;
static MsQuicApi()
{
// TODO: Consider updating all of these delegates to instead use function pointers.
if (NativeLibrary.TryLoad(Interop.Libraries.MsQuic, typeof(MsQuicApi).Assembly, DllImportSearchPath.AssemblyDirectory, out IntPtr msQuicHandle))
{
try
{
if (NativeLibrary.TryGetExport(msQuicHandle, "MsQuicOpen", out IntPtr msQuicOpenAddress))
if (NativeLibrary.TryGetExport(msQuicHandle, "MsQuicOpenVersion", out IntPtr msQuicOpenVersionAddress))
{
MsQuicOpenDelegate msQuicOpen =
Marshal.GetDelegateForFunctionPointer<MsQuicOpenDelegate>(msQuicOpenAddress);
uint status = msQuicOpen(out NativeApi* vtable);
delegate* unmanaged[Cdecl]<uint, out NativeApi*, uint> msQuicOpenVersion =
(delegate* unmanaged[Cdecl]<uint, out NativeApi*, uint>)msQuicOpenVersionAddress;
uint status = msQuicOpenVersion(MsQuicVersion, out NativeApi* vtable);
if (MsQuicStatusHelper.SuccessfulStatusCode(status))
{
IsQuicSupported = true;
......@@ -148,6 +149,7 @@ static MsQuicApi()
}
}
// TODO: Consider updating all of these delegates to instead use function pointers.
internal RegistrationOpenDelegate RegistrationOpenDelegate { get; }
internal RegistrationCloseDelegate RegistrationCloseDelegate { get; }
......
......@@ -51,10 +51,6 @@ internal struct NativeApi
internal IntPtr DatagramSend;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate uint MsQuicOpenDelegate(
out NativeApi* registration);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate uint SetContextDelegate(
SafeHandle handle,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册