public static unsafe SafeLoadLibrary LoadLibraryEx(string library) { SafeLoadLibrary result = UnsafeNativeMethods.SafeNetHandles.LoadLibraryExW(library, null, 0); if (result.IsInvalid) { result.SetHandleAsInvalid(); } return(result); }
static WebSocketProtocolComponent() { #if NETSTANDARD1_3 DllFileName = Path.Combine(Environment.GetEnvironmentVariable("SYSTEMROOT"), "System32", WEBSOCKET); #else DllFileName = Path.Combine(Environment.SystemDirectory, WEBSOCKET); #endif WebSocketDllHandle = SafeLoadLibrary.LoadLibraryEx(DllFileName); if (!WebSocketDllHandle.IsInvalid) { PrivateSupportedVersion = GetSupportedVersion(); ServerFakeRequestHeaders = new HttpHeader[] { new HttpHeader() { Name = HttpKnownHeaderNames.Connection, NameLength = (uint)HttpKnownHeaderNames.Connection.Length, Value = HttpKnownHeaderNames.Upgrade, ValueLength = (uint)HttpKnownHeaderNames.Upgrade.Length }, new HttpHeader() { Name = HttpKnownHeaderNames.Upgrade, NameLength = (uint)HttpKnownHeaderNames.Upgrade.Length, Value = WebSocketHelpers.WebSocketUpgradeToken, ValueLength = (uint)WebSocketHelpers.WebSocketUpgradeToken.Length }, new HttpHeader() { Name = HttpKnownHeaderNames.Host, NameLength = (uint)HttpKnownHeaderNames.Host.Length, Value = string.Empty, ValueLength = 0 }, new HttpHeader() { Name = HttpKnownHeaderNames.SecWebSocketVersion, NameLength = (uint)HttpKnownHeaderNames.SecWebSocketVersion.Length, Value = SupportedVersion, ValueLength = (uint)SupportedVersion.Length }, new HttpHeader() { Name = HttpKnownHeaderNames.SecWebSocketKey, NameLength = (uint)HttpKnownHeaderNames.SecWebSocketKey.Length, Value = DummyWebsocketKeyBase64, ValueLength = (uint)DummyWebsocketKeyBase64.Length } }; } }