Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
NetEventSource.cs
Go to the documentation of this file.
4using System.IO;
11
12namespace System.Net;
13
14[EventSource(Name = "Private.InternalDiagnostics.System.Net.Security", LocalizationResources = "FxResources.System.Net.Security.SR")]
15internal sealed class NetEventSource : EventSource
16{
17 public static class Keywords
18 {
19 public const EventKeywords Default = (EventKeywords)1L;
20
21 public const EventKeywords Debug = (EventKeywords)2L;
22 }
23
24 public static readonly System.Net.NetEventSource Log = new System.Net.NetEventSource();
25
26 [NonEvent]
27 public static void DumpBuffer(object thisOrContextObject, ReadOnlySpan<byte> buffer, [CallerMemberName] string memberName = null)
28 {
29 if (Log.IsEnabled())
30 {
31 byte[] buffer2 = buffer[..Math.Min(buffer.Length, 1024)].ToArray();
32 Log.DumpBuffer(IdOf(thisOrContextObject), memberName, buffer2);
33 }
34 }
35
36 [Event(8, Keywords = (EventKeywords)1L, Level = EventLevel.Informational)]
37 public void EnumerateSecurityPackages(string securityPackage)
38 {
39 if (IsEnabled())
40 {
41 WriteEvent(8, securityPackage ?? "");
42 }
43 }
44
45 [Event(9, Keywords = (EventKeywords)1L, Level = EventLevel.Informational)]
46 public void SspiPackageNotFound(string packageName)
47 {
48 if (IsEnabled())
49 {
50 WriteEvent(9, packageName ?? "");
51 }
52 }
53
54 [NonEvent]
55 public void SslStreamCtor(SslStream sslStream, Stream innerStream)
56 {
57 if (!IsEnabled())
58 {
59 return;
60 }
61 string text = null;
62 string remoteId = null;
63 if (innerStream is NetworkStream networkStream)
64 {
65 try
66 {
67 text = networkStream.Socket.LocalEndPoint?.ToString();
68 remoteId = networkStream.Socket.RemoteEndPoint?.ToString();
69 }
70 catch
71 {
72 }
73 }
74 if (text == null)
75 {
76 text = IdOf(innerStream);
77 }
78 SslStreamCtor(IdOf(sslStream), text, remoteId);
79 }
80
81 [Event(38, Keywords = (EventKeywords)1L, Level = EventLevel.Informational)]
82 private void SslStreamCtor(string thisOrContextObject, string localId, string remoteId)
83 {
84 WriteEvent(38, thisOrContextObject, localId, remoteId);
85 }
86
87 [NonEvent]
88 public void SecureChannelCtor(SecureChannel secureChannel, SslStream sslStream, string hostname, X509CertificateCollection clientCertificates, EncryptionPolicy encryptionPolicy)
89 {
90 if (IsEnabled())
91 {
92 SecureChannelCtor(IdOf(secureChannel), hostname, GetHashCode(secureChannel), clientCertificates?.Count ?? 0, encryptionPolicy);
93 }
94 }
95
96 [Event(17, Keywords = (EventKeywords)1L, Level = EventLevel.Informational)]
97 private void SecureChannelCtor(string sslStream, string hostname, int secureChannelHash, int clientCertificatesCount, EncryptionPolicy encryptionPolicy)
98 {
99 WriteEvent(17, sslStream, hostname, secureChannelHash, clientCertificatesCount, (int)encryptionPolicy);
100 }
101
102 [NonEvent]
103 public void LocatingPrivateKey(X509Certificate x509Certificate, object instance)
104 {
105 if (IsEnabled())
106 {
107 LocatingPrivateKey(x509Certificate.ToString(fVerbose: true), GetHashCode(instance));
108 }
109 }
110
111 [Event(18, Keywords = (EventKeywords)1L, Level = EventLevel.Informational)]
112 private void LocatingPrivateKey(string x509Certificate, int secureChannelHash)
113 {
114 WriteEvent(18, x509Certificate, secureChannelHash);
115 }
116
117 [NonEvent]
118 public void CertIsType2(object instance)
119 {
120 if (IsEnabled())
121 {
122 CertIsType2(GetHashCode(instance));
123 }
124 }
125
126 [Event(19, Keywords = (EventKeywords)1L, Level = EventLevel.Informational)]
127 private void CertIsType2(int secureChannelHash)
128 {
129 WriteEvent(19, secureChannelHash);
130 }
131
132 [NonEvent]
133 public void FoundCertInStore(bool serverMode, object instance)
134 {
135 if (IsEnabled())
136 {
137 FoundCertInStore(serverMode ? "LocalMachine" : "CurrentUser", GetHashCode(instance));
138 }
139 }
140
141 [Event(20, Keywords = (EventKeywords)1L, Level = EventLevel.Informational)]
142 private void FoundCertInStore(string store, int secureChannelHash)
143 {
144 WriteEvent(20, store, secureChannelHash);
145 }
146
147 [NonEvent]
148 public void NotFoundCertInStore(object instance)
149 {
150 if (IsEnabled())
151 {
153 }
154 }
155
156 [Event(21, Keywords = (EventKeywords)1L, Level = EventLevel.Informational)]
157 private void NotFoundCertInStore(int secureChannelHash)
158 {
159 WriteEvent(21, secureChannelHash);
160 }
161
162 [NonEvent]
163 public void RemoteCertificate(X509Certificate remoteCertificate)
164 {
165 if (IsEnabled())
166 {
167 RemoteCertificate(remoteCertificate?.ToString(fVerbose: true));
168 }
169 }
170
171 [Event(22, Keywords = (EventKeywords)1L, Level = EventLevel.Informational)]
172 private void RemoteCertificate(string remoteCertificate)
173 {
174 WriteEvent(22, remoteCertificate);
175 }
176
177 [NonEvent]
178 public void CertificateFromDelegate(SecureChannel secureChannel)
179 {
180 if (IsEnabled())
181 {
182 CertificateFromDelegate(GetHashCode(secureChannel));
183 }
184 }
185
186 [Event(23, Keywords = (EventKeywords)1L, Level = EventLevel.Informational)]
187 private void CertificateFromDelegate(int secureChannelHash)
188 {
189 WriteEvent(23, secureChannelHash);
190 }
191
192 [NonEvent]
193 public void NoDelegateNoClientCert(SecureChannel secureChannel)
194 {
195 if (IsEnabled())
196 {
197 NoDelegateNoClientCert(GetHashCode(secureChannel));
198 }
199 }
200
201 [Event(24, Keywords = (EventKeywords)1L, Level = EventLevel.Informational)]
202 private void NoDelegateNoClientCert(int secureChannelHash)
203 {
204 WriteEvent(24, secureChannelHash);
205 }
206
207 [NonEvent]
208 public void NoDelegateButClientCert(SecureChannel secureChannel)
209 {
210 if (IsEnabled())
211 {
212 NoDelegateButClientCert(GetHashCode(secureChannel));
213 }
214 }
215
216 [Event(25, Keywords = (EventKeywords)1L, Level = EventLevel.Informational)]
217 private void NoDelegateButClientCert(int secureChannelHash)
218 {
219 WriteEvent(25, secureChannelHash);
220 }
221
222 [NonEvent]
223 public void AttemptingRestartUsingCert(X509Certificate clientCertificate, SecureChannel secureChannel)
224 {
225 if (IsEnabled())
226 {
227 AttemptingRestartUsingCert(clientCertificate?.ToString(fVerbose: true), GetHashCode(secureChannel));
228 }
229 }
230
231 [Event(26, Keywords = (EventKeywords)1L, Level = EventLevel.Informational)]
232 private void AttemptingRestartUsingCert(string clientCertificate, int secureChannelHash)
233 {
234 WriteEvent(26, clientCertificate, secureChannelHash);
235 }
236
237 [NonEvent]
238 public void NoIssuersTryAllCerts(SecureChannel secureChannel)
239 {
240 if (IsEnabled())
241 {
242 NoIssuersTryAllCerts(GetHashCode(secureChannel));
243 }
244 }
245
246 [Event(27, Keywords = (EventKeywords)1L, Level = EventLevel.Informational)]
247 private void NoIssuersTryAllCerts(int secureChannelHash)
248 {
249 WriteEvent(27, secureChannelHash);
250 }
251
252 [NonEvent]
253 public void LookForMatchingCerts(int issuersCount, SecureChannel secureChannel)
254 {
255 if (IsEnabled())
256 {
257 LookForMatchingCerts(issuersCount, GetHashCode(secureChannel));
258 }
259 }
260
261 [Event(28, Keywords = (EventKeywords)1L, Level = EventLevel.Informational)]
262 private void LookForMatchingCerts(int issuersCount, int secureChannelHash)
263 {
264 WriteEvent(28, issuersCount, secureChannelHash);
265 }
266
267 [NonEvent]
268 public void SelectedCert(X509Certificate clientCertificate, SecureChannel secureChannel)
269 {
270 if (IsEnabled())
271 {
272 SelectedCert(clientCertificate?.ToString(fVerbose: true), GetHashCode(secureChannel));
273 }
274 }
275
276 [Event(29, Keywords = (EventKeywords)1L, Level = EventLevel.Informational)]
277 private void SelectedCert(string clientCertificate, int secureChannelHash)
278 {
279 WriteEvent(29, clientCertificate, secureChannelHash);
280 }
281
282 [NonEvent]
283 public void CertsAfterFiltering(int filteredCertsCount, SecureChannel secureChannel)
284 {
285 if (IsEnabled())
286 {
287 CertsAfterFiltering(filteredCertsCount, GetHashCode(secureChannel));
288 }
289 }
290
291 [Event(30, Keywords = (EventKeywords)1L, Level = EventLevel.Informational)]
292 private void CertsAfterFiltering(int filteredCertsCount, int secureChannelHash)
293 {
294 WriteEvent(30, filteredCertsCount, secureChannelHash);
295 }
296
297 [NonEvent]
298 public void FindingMatchingCerts(SecureChannel secureChannel)
299 {
300 if (IsEnabled())
301 {
302 FindingMatchingCerts(GetHashCode(secureChannel));
303 }
304 }
305
306 [Event(31, Keywords = (EventKeywords)1L, Level = EventLevel.Informational)]
307 private void FindingMatchingCerts(int secureChannelHash)
308 {
309 WriteEvent(31, secureChannelHash);
310 }
311
312 [NonEvent]
313 public void UsingCachedCredential(SecureChannel secureChannel)
314 {
315 if (IsEnabled())
316 {
317 UsingCachedCredential(GetHashCode(secureChannel));
318 }
319 }
320
321 [Event(32, Keywords = (EventKeywords)1L, Level = EventLevel.Informational)]
322 private void UsingCachedCredential(int secureChannelHash)
323 {
324 WriteEvent(32, secureChannelHash);
325 }
326
327 [Event(33, Keywords = (EventKeywords)1L, Level = EventLevel.Informational)]
328 public void SspiSelectedCipherSuite(string process, SslProtocols sslProtocol, CipherAlgorithmType cipherAlgorithm, int cipherStrength, HashAlgorithmType hashAlgorithm, int hashStrength, ExchangeAlgorithmType keyExchangeAlgorithm, int keyExchangeStrength)
329 {
330 if (IsEnabled())
331 {
332 WriteEvent(33, process, (int)sslProtocol, (int)cipherAlgorithm, cipherStrength, (int)hashAlgorithm, hashStrength, (int)keyExchangeAlgorithm, keyExchangeStrength);
333 }
334 }
335
336 [NonEvent]
337 public void RemoteCertificateError(SecureChannel secureChannel, string message)
338 {
339 if (IsEnabled())
340 {
341 RemoteCertificateError(GetHashCode(secureChannel), message);
342 }
343 }
344
345 [Event(34, Keywords = (EventKeywords)1L, Level = EventLevel.Verbose)]
346 private void RemoteCertificateError(int secureChannelHash, string message)
347 {
348 WriteEvent(34, secureChannelHash, message);
349 }
350
351 [NonEvent]
352 public void RemoteCertDeclaredValid(SecureChannel secureChannel)
353 {
354 if (IsEnabled())
355 {
356 RemoteCertDeclaredValid(GetHashCode(secureChannel));
357 }
358 }
359
360 [Event(35, Keywords = (EventKeywords)1L, Level = EventLevel.Verbose)]
361 private void RemoteCertDeclaredValid(int secureChannelHash)
362 {
363 WriteEvent(35, secureChannelHash);
364 }
365
366 [NonEvent]
367 public void RemoteCertHasNoErrors(SecureChannel secureChannel)
368 {
369 if (IsEnabled())
370 {
371 RemoteCertHasNoErrors(GetHashCode(secureChannel));
372 }
373 }
374
375 [Event(36, Keywords = (EventKeywords)1L, Level = EventLevel.Verbose)]
376 private void RemoteCertHasNoErrors(int secureChannelHash)
377 {
378 WriteEvent(36, secureChannelHash);
379 }
380
381 [NonEvent]
383 {
384 if (IsEnabled())
385 {
387 }
388 }
389
390 [Event(37, Keywords = (EventKeywords)1L, Level = EventLevel.Verbose)]
391 private void RemoteCertUserDeclaredInvalid(int secureChannelHash)
392 {
393 WriteEvent(37, secureChannelHash);
394 }
395
396 [NonEvent]
397 public void SentFrame(SslStream sslStream, ReadOnlySpan<byte> frame)
398 {
399 if (IsEnabled())
400 {
402 bool flag = TlsFrameHelper.TryGetFrameInfo(frame, ref info);
403 SentFrame(IdOf(sslStream), info.ToString(), flag ? 1 : 0);
404 }
405 }
406
407 [Event(39, Keywords = (EventKeywords)1L, Level = EventLevel.Verbose)]
408 private void SentFrame(string sslStream, string tlsFrame, int isComplete)
409 {
410 WriteEvent(39, sslStream, tlsFrame, isComplete);
411 }
412
413 [NonEvent]
414 public void ReceivedFrame(SslStream sslStream, TlsFrameHelper.TlsFrameInfo frameInfo)
415 {
416 if (IsEnabled())
417 {
418 ReceivedFrame(IdOf(sslStream), frameInfo.ToString(), 1);
419 }
420 }
421
422 [Event(40, Keywords = (EventKeywords)1L, Level = EventLevel.Verbose)]
423 private void ReceivedFrame(string sslStream, string tlsFrame, int isComplete)
424 {
425 WriteEvent(40, sslStream, tlsFrame, isComplete);
426 }
427
428 [NonEvent]
429 public static void Info(object thisOrContextObject, FormattableString formattableString = null, [CallerMemberName] string memberName = null)
430 {
431 if (Log.IsEnabled())
432 {
433 Log.Info(IdOf(thisOrContextObject), memberName, (formattableString != null) ? Format(formattableString) : "");
434 }
435 }
436
437 [NonEvent]
438 public static void Info(object thisOrContextObject, object message, [CallerMemberName] string memberName = null)
439 {
440 if (Log.IsEnabled())
441 {
442 Log.Info(IdOf(thisOrContextObject), memberName, Format(message).ToString());
443 }
444 }
445
446 [Event(4, Level = EventLevel.Informational, Keywords = (EventKeywords)1L)]
447 private void Info(string thisOrContextObject, string memberName, string message)
448 {
449 WriteEvent(4, thisOrContextObject, memberName ?? "(?)", message);
450 }
451
452 [NonEvent]
453 public static void Error(object thisOrContextObject, FormattableString formattableString, [CallerMemberName] string memberName = null)
454 {
455 if (Log.IsEnabled())
456 {
457 Log.ErrorMessage(IdOf(thisOrContextObject), memberName, Format(formattableString));
458 }
459 }
460
461 [NonEvent]
462 public static void Error(object thisOrContextObject, object message, [CallerMemberName] string memberName = null)
463 {
464 if (Log.IsEnabled())
465 {
466 Log.ErrorMessage(IdOf(thisOrContextObject), memberName, Format(message).ToString());
467 }
468 }
469
470 [Event(5, Level = EventLevel.Error, Keywords = (EventKeywords)1L)]
471 private void ErrorMessage(string thisOrContextObject, string memberName, string message)
472 {
473 WriteEvent(5, thisOrContextObject, memberName ?? "(?)", message);
474 }
475
476 [NonEvent]
477 public static void Verbose(object thisOrContextObject, FormattableString formattableString, [CallerMemberName] string memberName = null)
478 {
479 if (Log.IsEnabled())
480 {
481 Log.ErrorMessage(IdOf(thisOrContextObject), memberName, Format(formattableString));
482 }
483 }
484
485 [Event(7, Level = EventLevel.Verbose, Keywords = (EventKeywords)2L)]
486 private void DumpBuffer(string thisOrContextObject, string memberName, byte[] buffer)
487 {
488 WriteEvent(7, thisOrContextObject, memberName ?? "(?)", buffer);
489 }
490
491 [NonEvent]
492 public static string IdOf(object value)
493 {
494 if (value == null)
495 {
496 return "(null)";
497 }
498 return value.GetType().Name + "#" + GetHashCode(value);
499 }
500
501 [NonEvent]
502 public static int GetHashCode(object value)
503 {
504 return value?.GetHashCode() ?? 0;
505 }
506
507 [NonEvent]
508 public static object Format(object value)
509 {
510 if (value == null)
511 {
512 return "(null)";
513 }
514 string result = null;
515 AdditionalCustomizedToString(value, ref result);
516 if (result != null)
517 {
518 return result;
519 }
520 if (value is Array array)
521 {
522 return $"{array.GetType().GetElementType()}[{((Array)value).Length}]";
523 }
525 {
526 return $"{collection.GetType().Name}({collection.Count})";
527 }
528 if (value is SafeHandle safeHandle)
529 {
530 return $"{safeHandle.GetType().Name}:{safeHandle.GetHashCode()}(0x{safeHandle.DangerousGetHandle():X})";
531 }
532 if (value is IntPtr)
533 {
534 return $"0x{value:X}";
535 }
536 string text = value.ToString();
537 if (text == null || text == value.GetType().FullName)
538 {
539 return IdOf(value);
540 }
541 return value;
542 }
543
544 [NonEvent]
545 private static string Format(FormattableString s)
546 {
547 switch (s.ArgumentCount)
548 {
549 case 0:
550 return s.Format;
551 case 1:
552 return string.Format(s.Format, Format(s.GetArgument(0)));
553 case 2:
554 return string.Format(s.Format, Format(s.GetArgument(0)), Format(s.GetArgument(1)));
555 case 3:
556 return string.Format(s.Format, Format(s.GetArgument(0)), Format(s.GetArgument(1)), Format(s.GetArgument(2)));
557 default:
558 {
559 object[] arguments = s.GetArguments();
560 object[] array = new object[arguments.Length];
561 for (int i = 0; i < arguments.Length; i++)
562 {
563 array[i] = Format(arguments[i]);
564 }
565 return string.Format(s.Format, array);
566 }
567 }
568 }
569
570 private static void AdditionalCustomizedToString<T>(T value, ref string result)
571 {
572 if (value is X509Certificate x509Certificate)
573 {
574 result = x509Certificate.ToString(fVerbose: true);
575 }
576 }
577
578 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = "Parameters to this method are primitive and are trimmer safe")]
579 [NonEvent]
580 private unsafe void WriteEvent(int eventId, string arg1, string arg2, byte[] arg3)
581 {
582 //The blocks IL_004f, IL_0053, IL_0055, IL_006e, IL_0155 are reachable both inside and outside the pinned region starting at IL_004c. ILSpy has duplicated these blocks in order to place them both within and outside the `fixed` statement.
583 if (!Log.IsEnabled())
584 {
585 return;
586 }
587 if (arg1 == null)
588 {
589 arg1 = "";
590 }
591 if (arg2 == null)
592 {
593 arg2 = "";
594 }
595 if (arg3 == null)
596 {
597 arg3 = Array.Empty<byte>();
598 }
599 fixed (char* ptr5 = arg1)
600 {
601 char* intPtr;
602 byte[] array;
603 int size;
604 EventData* intPtr2;
605 nint num;
606 nint num2;
607 nint num3;
608 if (arg2 == null)
609 {
610 char* ptr;
611 intPtr = (ptr = null);
612 array = arg3;
613 fixed (byte* ptr2 = array)
614 {
615 byte* ptr3 = ptr2;
616 size = arg3.Length;
617 EventData* ptr4 = stackalloc EventData[4];
618 intPtr2 = ptr4;
619 *intPtr2 = new EventData
620 {
621 DataPointer = (IntPtr)ptr5,
622 Size = (arg1.Length + 1) * 2
623 };
624 num = (nint)(ptr4 + 1);
625 *(EventData*)num = new EventData
626 {
627 DataPointer = (IntPtr)ptr,
628 Size = (arg2.Length + 1) * 2
629 };
630 num2 = (nint)(ptr4 + 2);
631 *(EventData*)num2 = new EventData
632 {
633 DataPointer = (IntPtr)(&size),
634 Size = 4
635 };
636 num3 = (nint)(ptr4 + 3);
637 *(EventData*)num3 = new EventData
638 {
639 DataPointer = (IntPtr)ptr3,
640 Size = size
641 };
642 WriteEventCore(eventId, 4, ptr4);
643 }
644 return;
645 }
646 fixed (char* ptr6 = &arg2.GetPinnableReference())
647 {
648 char* ptr;
649 intPtr = (ptr = ptr6);
650 array = arg3;
651 fixed (byte* ptr2 = array)
652 {
653 byte* ptr3 = ptr2;
654 size = arg3.Length;
655 EventData* ptr4 = stackalloc EventData[4];
656 intPtr2 = ptr4;
657 *intPtr2 = new EventData
658 {
659 DataPointer = (IntPtr)ptr5,
660 Size = (arg1.Length + 1) * 2
661 };
662 num = (nint)(ptr4 + 1);
663 *(EventData*)num = new EventData
664 {
665 DataPointer = (IntPtr)ptr,
666 Size = (arg2.Length + 1) * 2
667 };
668 num2 = (nint)(ptr4 + 2);
669 *(EventData*)num2 = new EventData
670 {
671 DataPointer = (IntPtr)(&size),
672 Size = 4
673 };
674 num3 = (nint)(ptr4 + 3);
675 *(EventData*)num3 = new EventData
676 {
677 DataPointer = (IntPtr)ptr3,
678 Size = size
679 };
680 WriteEventCore(eventId, 4, ptr4);
681 }
682 }
683 }
684 }
685
686 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = "Parameters to this method are primitive and are trimmer safe")]
687 [NonEvent]
688 private unsafe void WriteEvent(int eventId, string arg1, int arg2, int arg3, int arg4)
689 {
690 if (Log.IsEnabled())
691 {
692 if (arg1 == null)
693 {
694 arg1 = "";
695 }
696 fixed (char* ptr2 = arg1)
697 {
698 EventData* ptr = stackalloc EventData[4];
699 *ptr = new EventData
700 {
701 DataPointer = (IntPtr)ptr2,
702 Size = (arg1.Length + 1) * 2
703 };
704 ptr[1] = new EventData
705 {
706 DataPointer = (IntPtr)(&arg2),
707 Size = 4
708 };
709 ptr[2] = new EventData
710 {
711 DataPointer = (IntPtr)(&arg3),
712 Size = 4
713 };
714 ptr[3] = new EventData
715 {
716 DataPointer = (IntPtr)(&arg4),
717 Size = 4
718 };
719 WriteEventCore(eventId, 4, ptr);
720 }
721 }
722 }
723
724 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = "Parameters to this method are primitive and are trimmer safe")]
725 [NonEvent]
726 private unsafe void WriteEvent(int eventId, string arg1, int arg2, string arg3)
727 {
728 //The blocks IL_0047 are reachable both inside and outside the pinned region starting at IL_0044. ILSpy has duplicated these blocks in order to place them both within and outside the `fixed` statement.
729 if (!Log.IsEnabled())
730 {
731 return;
732 }
733 if (arg1 == null)
734 {
735 arg1 = "";
736 }
737 if (arg3 == null)
738 {
739 arg3 = "";
740 }
741 fixed (char* ptr3 = arg1)
742 {
743 char* intPtr;
744 EventData* intPtr2;
745 nint num;
746 nint num2;
747 if (arg3 == null)
748 {
749 char* ptr;
750 intPtr = (ptr = null);
751 EventData* ptr2 = stackalloc EventData[3];
752 intPtr2 = ptr2;
753 *intPtr2 = new EventData
754 {
755 DataPointer = (IntPtr)ptr3,
756 Size = (arg1.Length + 1) * 2
757 };
758 num = (nint)(ptr2 + 1);
759 *(EventData*)num = new EventData
760 {
761 DataPointer = (IntPtr)(&arg2),
762 Size = 4
763 };
764 num2 = (nint)(ptr2 + 2);
765 *(EventData*)num2 = new EventData
766 {
767 DataPointer = (IntPtr)ptr,
768 Size = (arg3.Length + 1) * 2
769 };
770 WriteEventCore(eventId, 3, ptr2);
771 return;
772 }
773 fixed (char* ptr4 = &arg3.GetPinnableReference())
774 {
775 char* ptr;
776 intPtr = (ptr = ptr4);
777 EventData* ptr2 = stackalloc EventData[3];
778 intPtr2 = ptr2;
779 *intPtr2 = new EventData
780 {
781 DataPointer = (IntPtr)ptr3,
782 Size = (arg1.Length + 1) * 2
783 };
784 num = (nint)(ptr2 + 1);
785 *(EventData*)num = new EventData
786 {
787 DataPointer = (IntPtr)(&arg2),
788 Size = 4
789 };
790 num2 = (nint)(ptr2 + 2);
791 *(EventData*)num2 = new EventData
792 {
793 DataPointer = (IntPtr)ptr,
794 Size = (arg3.Length + 1) * 2
795 };
796 WriteEventCore(eventId, 3, ptr2);
797 }
798 }
799 }
800
801 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = "Parameters to this method are primitive and are trimmer safe")]
802 [NonEvent]
803 private unsafe void WriteEvent(int eventId, string arg1, string arg2, int arg3)
804 {
805 //The blocks IL_0044 are reachable both inside and outside the pinned region starting at IL_0041. ILSpy has duplicated these blocks in order to place them both within and outside the `fixed` statement.
806 if (!Log.IsEnabled())
807 {
808 return;
809 }
810 if (arg1 == null)
811 {
812 arg1 = "";
813 }
814 if (arg2 == null)
815 {
816 arg2 = "";
817 }
818 fixed (char* ptr3 = arg1)
819 {
820 char* intPtr;
821 EventData* intPtr2;
822 nint num;
823 nint num2;
824 if (arg2 == null)
825 {
826 char* ptr;
827 intPtr = (ptr = null);
828 EventData* ptr2 = stackalloc EventData[3];
829 intPtr2 = ptr2;
830 *intPtr2 = new EventData
831 {
832 DataPointer = (IntPtr)ptr3,
833 Size = (arg1.Length + 1) * 2
834 };
835 num = (nint)(ptr2 + 1);
836 *(EventData*)num = new EventData
837 {
838 DataPointer = (IntPtr)ptr,
839 Size = (arg2.Length + 1) * 2
840 };
841 num2 = (nint)(ptr2 + 2);
842 *(EventData*)num2 = new EventData
843 {
844 DataPointer = (IntPtr)(&arg3),
845 Size = 4
846 };
847 WriteEventCore(eventId, 3, ptr2);
848 return;
849 }
850 fixed (char* ptr4 = &arg2.GetPinnableReference())
851 {
852 char* ptr;
853 intPtr = (ptr = ptr4);
854 EventData* ptr2 = stackalloc EventData[3];
855 intPtr2 = ptr2;
856 *intPtr2 = new EventData
857 {
858 DataPointer = (IntPtr)ptr3,
859 Size = (arg1.Length + 1) * 2
860 };
861 num = (nint)(ptr2 + 1);
862 *(EventData*)num = new EventData
863 {
864 DataPointer = (IntPtr)ptr,
865 Size = (arg2.Length + 1) * 2
866 };
867 num2 = (nint)(ptr2 + 2);
868 *(EventData*)num2 = new EventData
869 {
870 DataPointer = (IntPtr)(&arg3),
871 Size = 4
872 };
873 WriteEventCore(eventId, 3, ptr2);
874 }
875 }
876 }
877
878 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = "Parameters to this method are primitive and are trimmer safe")]
879 [NonEvent]
880 private unsafe void WriteEvent(int eventId, string arg1, string arg2, string arg3, int arg4)
881 {
882 //The blocks IL_004f, IL_0052, IL_0064, IL_0151 are reachable both inside and outside the pinned region starting at IL_004c. ILSpy has duplicated these blocks in order to place them both within and outside the `fixed` statement.
883 if (!Log.IsEnabled())
884 {
885 return;
886 }
887 if (arg1 == null)
888 {
889 arg1 = "";
890 }
891 if (arg2 == null)
892 {
893 arg2 = "";
894 }
895 if (arg3 == null)
896 {
897 arg3 = "";
898 }
899 fixed (char* ptr5 = arg1)
900 {
901 char* intPtr;
902 EventData* intPtr2;
903 nint num;
904 nint num2;
905 nint num3;
906 if (arg2 == null)
907 {
908 char* ptr;
909 intPtr = (ptr = null);
910 fixed (char* ptr2 = arg3)
911 {
912 char* ptr3 = ptr2;
913 EventData* ptr4 = stackalloc EventData[4];
914 intPtr2 = ptr4;
915 *intPtr2 = new EventData
916 {
917 DataPointer = (IntPtr)ptr5,
918 Size = (arg1.Length + 1) * 2
919 };
920 num = (nint)(ptr4 + 1);
921 *(EventData*)num = new EventData
922 {
923 DataPointer = (IntPtr)ptr,
924 Size = (arg2.Length + 1) * 2
925 };
926 num2 = (nint)(ptr4 + 2);
927 *(EventData*)num2 = new EventData
928 {
929 DataPointer = (IntPtr)ptr3,
930 Size = (arg3.Length + 1) * 2
931 };
932 num3 = (nint)(ptr4 + 3);
933 *(EventData*)num3 = new EventData
934 {
935 DataPointer = (IntPtr)(&arg4),
936 Size = 4
937 };
938 WriteEventCore(eventId, 4, ptr4);
939 }
940 return;
941 }
942 fixed (char* ptr6 = &arg2.GetPinnableReference())
943 {
944 char* ptr;
945 intPtr = (ptr = ptr6);
946 fixed (char* ptr2 = arg3)
947 {
948 char* ptr3 = ptr2;
949 EventData* ptr4 = stackalloc EventData[4];
950 intPtr2 = ptr4;
951 *intPtr2 = new EventData
952 {
953 DataPointer = (IntPtr)ptr5,
954 Size = (arg1.Length + 1) * 2
955 };
956 num = (nint)(ptr4 + 1);
957 *(EventData*)num = new EventData
958 {
959 DataPointer = (IntPtr)ptr,
960 Size = (arg2.Length + 1) * 2
961 };
962 num2 = (nint)(ptr4 + 2);
963 *(EventData*)num2 = new EventData
964 {
965 DataPointer = (IntPtr)ptr3,
966 Size = (arg3.Length + 1) * 2
967 };
968 num3 = (nint)(ptr4 + 3);
969 *(EventData*)num3 = new EventData
970 {
971 DataPointer = (IntPtr)(&arg4),
972 Size = 4
973 };
974 WriteEventCore(eventId, 4, ptr4);
975 }
976 }
977 }
978 }
979
980 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = "Parameters to this method are primitive and are trimmer safe")]
981 [NonEvent]
982 private unsafe void WriteEvent(int eventId, string arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8)
983 {
984 if (Log.IsEnabled())
985 {
986 if (arg1 == null)
987 {
988 arg1 = "";
989 }
990 fixed (char* ptr2 = arg1)
991 {
992 EventData* ptr = stackalloc EventData[8];
993 *ptr = new EventData
994 {
995 DataPointer = (IntPtr)ptr2,
996 Size = (arg1.Length + 1) * 2
997 };
998 ptr[1] = new EventData
999 {
1000 DataPointer = (IntPtr)(&arg2),
1001 Size = 4
1002 };
1003 ptr[2] = new EventData
1004 {
1005 DataPointer = (IntPtr)(&arg3),
1006 Size = 4
1007 };
1008 ptr[3] = new EventData
1009 {
1010 DataPointer = (IntPtr)(&arg4),
1011 Size = 4
1012 };
1013 ptr[4] = new EventData
1014 {
1015 DataPointer = (IntPtr)(&arg5),
1016 Size = 4
1017 };
1018 ptr[5] = new EventData
1019 {
1020 DataPointer = (IntPtr)(&arg6),
1021 Size = 4
1022 };
1023 ptr[6] = new EventData
1024 {
1025 DataPointer = (IntPtr)(&arg7),
1026 Size = 4
1027 };
1028 ptr[7] = new EventData
1029 {
1030 DataPointer = (IntPtr)(&arg8),
1031 Size = 4
1032 };
1033 WriteEventCore(eventId, 8, ptr);
1034 }
1035 }
1036 }
1037
1038 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern", Justification = "Parameters to this method are primitive and are trimmer safe")]
1039 [NonEvent]
1040 private unsafe void WriteEvent(int eventId, string arg1, string arg2, int arg3, int arg4, int arg5)
1041 {
1042 //The blocks IL_0044 are reachable both inside and outside the pinned region starting at IL_0041. ILSpy has duplicated these blocks in order to place them both within and outside the `fixed` statement.
1043 if (!Log.IsEnabled())
1044 {
1045 return;
1046 }
1047 if (arg1 == null)
1048 {
1049 arg1 = "";
1050 }
1051 if (arg2 == null)
1052 {
1053 arg2 = "";
1054 }
1055 fixed (char* ptr3 = arg1)
1056 {
1057 char* intPtr;
1058 EventData* intPtr2;
1059 nint num;
1060 nint num2;
1061 nint num3;
1062 nint num4;
1063 if (arg2 == null)
1064 {
1065 char* ptr;
1066 intPtr = (ptr = null);
1067 EventData* ptr2 = stackalloc EventData[5];
1068 intPtr2 = ptr2;
1069 *intPtr2 = new EventData
1070 {
1071 DataPointer = (IntPtr)ptr3,
1072 Size = (arg1.Length + 1) * 2
1073 };
1074 num = (nint)(ptr2 + 1);
1075 *(EventData*)num = new EventData
1076 {
1077 DataPointer = (IntPtr)ptr,
1078 Size = (arg2.Length + 1) * 2
1079 };
1080 num2 = (nint)(ptr2 + 2);
1081 *(EventData*)num2 = new EventData
1082 {
1083 DataPointer = (IntPtr)(&arg3),
1084 Size = 4
1085 };
1086 num3 = (nint)(ptr2 + 3);
1087 *(EventData*)num3 = new EventData
1088 {
1089 DataPointer = (IntPtr)(&arg4),
1090 Size = 4
1091 };
1092 num4 = (nint)(ptr2 + 4);
1093 *(EventData*)num4 = new EventData
1094 {
1095 DataPointer = (IntPtr)(&arg5),
1096 Size = 4
1097 };
1098 WriteEventCore(eventId, 5, ptr2);
1099 return;
1100 }
1101 fixed (char* ptr4 = &arg2.GetPinnableReference())
1102 {
1103 char* ptr;
1104 intPtr = (ptr = ptr4);
1105 EventData* ptr2 = stackalloc EventData[5];
1106 intPtr2 = ptr2;
1107 *intPtr2 = new EventData
1108 {
1109 DataPointer = (IntPtr)ptr3,
1110 Size = (arg1.Length + 1) * 2
1111 };
1112 num = (nint)(ptr2 + 1);
1113 *(EventData*)num = new EventData
1114 {
1115 DataPointer = (IntPtr)ptr,
1116 Size = (arg2.Length + 1) * 2
1117 };
1118 num2 = (nint)(ptr2 + 2);
1119 *(EventData*)num2 = new EventData
1120 {
1121 DataPointer = (IntPtr)(&arg3),
1122 Size = 4
1123 };
1124 num3 = (nint)(ptr2 + 3);
1125 *(EventData*)num3 = new EventData
1126 {
1127 DataPointer = (IntPtr)(&arg4),
1128 Size = 4
1129 };
1130 num4 = (nint)(ptr2 + 4);
1131 *(EventData*)num4 = new EventData
1132 {
1133 DataPointer = (IntPtr)(&arg5),
1134 Size = 4
1135 };
1136 WriteEventCore(eventId, 5, ptr2);
1137 }
1138 }
1139 }
1140
1141 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "parameter intent is an enum and is trimmer safe")]
1142 [Event(10, Keywords = (EventKeywords)1L, Level = EventLevel.Informational)]
1143 public void AcquireDefaultCredential(string packageName, global::Interop.SspiCli.CredentialUse intent)
1144 {
1145 if (IsEnabled())
1146 {
1147 WriteEvent(10, packageName, intent);
1148 }
1149 }
1150
1151 [NonEvent]
1152 public void AcquireCredentialsHandle(string packageName, global::Interop.SspiCli.CredentialUse intent, object authdata)
1153 {
1154 if (IsEnabled())
1155 {
1156 AcquireCredentialsHandle(packageName, intent, IdOf(authdata));
1157 }
1158 }
1159
1160 [Event(11, Keywords = (EventKeywords)1L, Level = EventLevel.Informational)]
1161 public void AcquireCredentialsHandle(string packageName, global::Interop.SspiCli.CredentialUse intent, string authdata)
1162 {
1163 if (IsEnabled())
1164 {
1165 WriteEvent(11, packageName, (int)intent, authdata);
1166 }
1167 }
1168
1169 [NonEvent]
1170 public void InitializeSecurityContext(SafeFreeCredentials credential, SafeDeleteContext context, string targetName, global::Interop.SspiCli.ContextFlags inFlags)
1171 {
1172 if (IsEnabled())
1173 {
1174 InitializeSecurityContext(IdOf(credential), IdOf(context), targetName, inFlags);
1175 }
1176 }
1177
1178 [Event(12, Keywords = (EventKeywords)1L, Level = EventLevel.Informational)]
1179 private void InitializeSecurityContext(string credential, string context, string targetName, global::Interop.SspiCli.ContextFlags inFlags)
1180 {
1181 WriteEvent(12, credential, context, targetName, (int)inFlags);
1182 }
1183
1184 [NonEvent]
1185 public void AcceptSecurityContext(SafeFreeCredentials credential, SafeDeleteContext context, global::Interop.SspiCli.ContextFlags inFlags)
1186 {
1187 if (IsEnabled())
1188 {
1189 AcceptSecurityContext(IdOf(credential), IdOf(context), inFlags);
1190 }
1191 }
1192
1193 [Event(15, Keywords = (EventKeywords)1L, Level = EventLevel.Informational)]
1194 private void AcceptSecurityContext(string credential, string context, global::Interop.SspiCli.ContextFlags inFlags)
1195 {
1196 WriteEvent(15, credential, context, (int)inFlags);
1197 }
1198
1199 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "parameter errorCode is an enum and is trimmer safe")]
1200 [Event(16, Keywords = (EventKeywords)1L, Level = EventLevel.Informational)]
1201 public void OperationReturnedSomething(string operation, global::Interop.SECURITY_STATUS errorCode)
1202 {
1203 if (IsEnabled())
1204 {
1205 WriteEvent(16, operation, errorCode);
1206 }
1207 }
1208
1209 [Event(14, Keywords = (EventKeywords)1L, Level = EventLevel.Informational)]
1210 public void SecurityContextInputBuffers(string context, int inputBuffersSize, int outputBufferSize, global::Interop.SECURITY_STATUS errorCode)
1211 {
1212 if (IsEnabled())
1213 {
1214 WriteEvent(14, context, inputBuffersSize, outputBufferSize, (int)errorCode);
1215 }
1216 }
1217}
unsafe void WriteEventCore(int eventId, int eventDataCount, EventData *data)
static byte Min(byte val1, byte val2)
Definition Math.cs:912
void EnumerateSecurityPackages(string securityPackage)
void AttemptingRestartUsingCert(X509Certificate clientCertificate, SecureChannel secureChannel)
void NotFoundCertInStore(object instance)
void RemoteCertUserDeclaredInvalid(int secureChannelHash)
void DumpBuffer(string thisOrContextObject, string memberName, byte[] buffer)
unsafe void WriteEvent(int eventId, string arg1, string arg2, string arg3, int arg4)
void AcceptSecurityContext(string credential, string context, global::Interop.SspiCli.ContextFlags inFlags)
void NoDelegateNoClientCert(int secureChannelHash)
void RemoteCertUserDeclaredInvalid(SecureChannel secureChannel)
void AcquireCredentialsHandle(string packageName, global::Interop.SspiCli.CredentialUse intent, string authdata)
static void AdditionalCustomizedToString< T >(T value, ref string result)
void SecurityContextInputBuffers(string context, int inputBuffersSize, int outputBufferSize, global::Interop.SECURITY_STATUS errorCode)
static readonly System.Net.NetEventSource Log
void NotFoundCertInStore(int secureChannelHash)
void NoDelegateButClientCert(SecureChannel secureChannel)
void NoIssuersTryAllCerts(SecureChannel secureChannel)
static void DumpBuffer(object thisOrContextObject, ReadOnlySpan< byte > buffer, [CallerMemberName] string memberName=null)
void AcquireDefaultCredential(string packageName, global::Interop.SspiCli.CredentialUse intent)
void UsingCachedCredential(SecureChannel secureChannel)
void CertsAfterFiltering(int filteredCertsCount, int secureChannelHash)
void ErrorMessage(string thisOrContextObject, string memberName, string message)
static void Info(object thisOrContextObject, FormattableString formattableString=null, [CallerMemberName] string memberName=null)
void RemoteCertificateError(SecureChannel secureChannel, string message)
static void Error(object thisOrContextObject, object message, [CallerMemberName] string memberName=null)
void AttemptingRestartUsingCert(string clientCertificate, int secureChannelHash)
void SspiSelectedCipherSuite(string process, SslProtocols sslProtocol, CipherAlgorithmType cipherAlgorithm, int cipherStrength, HashAlgorithmType hashAlgorithm, int hashStrength, ExchangeAlgorithmType keyExchangeAlgorithm, int keyExchangeStrength)
void RemoteCertDeclaredValid(int secureChannelHash)
void Info(string thisOrContextObject, string memberName, string message)
void AcquireCredentialsHandle(string packageName, global::Interop.SspiCli.CredentialUse intent, object authdata)
unsafe void WriteEvent(int eventId, string arg1, string arg2, int arg3)
static string IdOf(object value)
void UsingCachedCredential(int secureChannelHash)
static string Format(FormattableString s)
void CertificateFromDelegate(int secureChannelHash)
void OperationReturnedSomething(string operation, global::Interop.SECURITY_STATUS errorCode)
void RemoteCertificateError(int secureChannelHash, string message)
unsafe void WriteEvent(int eventId, string arg1, string arg2, int arg3, int arg4, int arg5)
static void Error(object thisOrContextObject, FormattableString formattableString, [CallerMemberName] string memberName=null)
void SecureChannelCtor(SecureChannel secureChannel, SslStream sslStream, string hostname, X509CertificateCollection clientCertificates, EncryptionPolicy encryptionPolicy)
void FoundCertInStore(string store, int secureChannelHash)
static int GetHashCode(object value)
unsafe void WriteEvent(int eventId, string arg1, string arg2, byte[] arg3)
unsafe void WriteEvent(int eventId, string arg1, int arg2, string arg3)
void NoDelegateButClientCert(int secureChannelHash)
void SecureChannelCtor(string sslStream, string hostname, int secureChannelHash, int clientCertificatesCount, EncryptionPolicy encryptionPolicy)
void AcceptSecurityContext(System.Net.Security.SafeFreeCredentials credential, System.Net.Security.SafeDeleteContext context, global::Interop.SspiCli.ContextFlags inFlags)
void SelectedCert(X509Certificate clientCertificate, SecureChannel secureChannel)
void LocatingPrivateKey(X509Certificate x509Certificate, object instance)
void FindingMatchingCerts(SecureChannel secureChannel)
void CertsAfterFiltering(int filteredCertsCount, SecureChannel secureChannel)
void AcceptSecurityContext(SafeFreeCredentials credential, SafeDeleteContext context, global::Interop.SspiCli.ContextFlags inFlags)
void RemoteCertDeclaredValid(SecureChannel secureChannel)
void ReceivedFrame(string sslStream, string tlsFrame, int isComplete)
unsafe void WriteEvent(int eventId, int arg1, int arg2, int arg3, string arg4, string arg5)
void FindingMatchingCerts(int secureChannelHash)
void RemoteCertHasNoErrors(int secureChannelHash)
unsafe void WriteEvent(int eventId, string arg1, int arg2, int arg3, int arg4)
void InitializeSecurityContext(string credential, string context, string targetName, global::Interop.SspiCli.ContextFlags inFlags)
void CertIsType2(object instance)
void CertificateFromDelegate(SecureChannel secureChannel)
void LookForMatchingCerts(int issuersCount, int secureChannelHash)
void FoundCertInStore(bool serverMode, object instance)
void SslStreamCtor(SslStream sslStream, Stream innerStream)
void CertIsType2(int secureChannelHash)
void InitializeSecurityContext(SafeFreeCredentials credential, SafeDeleteContext context, string targetName, global::Interop.SspiCli.ContextFlags inFlags)
void LookForMatchingCerts(int issuersCount, SecureChannel secureChannel)
void SspiPackageNotFound(string packageName)
void ReceivedFrame(SslStream sslStream, TlsFrameHelper.TlsFrameInfo frameInfo)
static void Info(object thisOrContextObject, object message, [CallerMemberName] string memberName=null)
void RemoteCertHasNoErrors(SecureChannel secureChannel)
unsafe void WriteEvent(int eventId, string arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8)
static object Format(object value)
void RemoteCertificate(X509Certificate remoteCertificate)
void NoIssuersTryAllCerts(int secureChannelHash)
void SelectedCert(string clientCertificate, int secureChannelHash)
void LocatingPrivateKey(string x509Certificate, int secureChannelHash)
void NoDelegateNoClientCert(SecureChannel secureChannel)
void SslStreamCtor(string thisOrContextObject, string localId, string remoteId)
void SentFrame(string sslStream, string tlsFrame, int isComplete)
void RemoteCertificate(string remoteCertificate)
void InitializeSecurityContext(System.Net.Security.SafeFreeCredentials credential, System.Net.Security.SafeDeleteContext context, string targetName, global::Interop.SspiCli.ContextFlags inFlags)
static void Verbose(object thisOrContextObject, FormattableString formattableString, [CallerMemberName] string memberName=null)
void SentFrame(SslStream sslStream, ReadOnlySpan< byte > frame)
static bool TryGetFrameInfo(ReadOnlySpan< byte > frame, ref TlsFrameInfo info, ProcessingOptions options=ProcessingOptions.All, HelloExtensionCallback callback=null)