-
Notifications
You must be signed in to change notification settings - Fork 2
/
RdpViewerControl.cs
3100 lines (2948 loc) · 106 KB
/
RdpViewerControl.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Drawing;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using System.Threading;
using System.Windows.Forms;
using AxMicrosoft.Virtualization.Client.Interop;
using Microsoft.Virtualization.Client.Interop;
using Microsoft.Virtualization.Client.Management;
using Microsoft.Win32;
namespace Microsoft.Virtualization.Client.InteractiveSession
{
// Token: 0x02000017 RID: 23
internal class RdpViewerControl : Control
{
// Token: 0x06000101 RID: 257 RVA: 0x0000A2EC File Offset: 0x000084EC
[SuppressMessage("Microsoft.Design", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands", Justification = "Called is not granted access to operations or resources that can be used in a destructive manner.")]
public RdpViewerControl(Form form, RdpConnectionInfo rdpConnectionInfo)
{
this._form = form;
this.m_BlockConnectionRequests = 0;
this.m_RdpConnectionInfo = rdpConnectionInfo;
this.ConnectionState = ((rdpConnectionInfo.VirtualMachine != null) ? RdpViewerConnectionState.NotConnected : RdpViewerConnectionState.NoVirtualMachine);
this.m_VMConnectUseEnhancedModeRuntimePreference = ClientVirtualizationSettings.Instance.VMConnectUseEnhancedMode;
base.SuspendLayout();
this.BackColor = Color.Black;
new ComponentResourceManager(typeof(RdpViewerControl)).ApplyResources(this, "$this");
base.TabStop = true;
base.SetStyle(ControlStyles.ContainerControl, true);
this.SetDisplayStrings();
this.CreateRdpClient(true);
base.ResumeLayout();
this.m_SnapshotTracker.HasSnapshotsChanged += this.HandleHasSnapshotsChanged;
this.m_MigrationTracker.MigrationStarted += this.HandleMigrationStarted;
this.m_MigrationTracker.MigrationCompleted += this.HandleMigrationCompleted;
this.m_MouseActivateTimer = new System.Windows.Forms.Timer();
this.m_MouseActivateTimer.Interval = 300;
this.m_MouseActivateTimer.Tick += this.HandleMouseActivateTimer;
}
// Token: 0x06000102 RID: 258 RVA: 0x0000A444 File Offset: 0x00008644
private void CreateRdpClient(bool onInit)
{
VMTrace.TraceInformation("Recreating the RDP client ActiveX control.", Array.Empty<string>());
RdpClient rdpClient = this.m_RdpClient;
this.m_RdpClient = new RdpClient();
this.m_RdpClient.BeginInit();
this.m_RdpClient.Name = "RdpClient";
if (!onInit)
{
this.m_RdpClient.Visible = false;
}
base.Controls.Add(this.m_RdpClient);
this.m_RdpClient.EndInit();
if (rdpClient != null)
{
base.Controls.Remove(rdpClient);
rdpClient.Dispose();
}
this.m_RdpClient.Location = new Point(0, 0);
this.m_RdpClient.Dock = DockStyle.None;
this.SetupRdpEventHandlers();
this.m_RdpClient.AdvancedSettings3.EnableAutoReconnect = false;
this.m_RdpClient.AdvancedSettings.ContainerHandledFullScreen = 1;
this.m_RdpClient.AdvancedSettings7.RelativeMouseMode = true;
this.m_RdpClient.AdvancedSettings7.AuthenticationServiceClass = "Microsoft Virtual Console Service";
if (this.VirtualMachine.Setting.EnhancedSessionTransportType == EnhancedSessionTransportType.HvSocket)
{
this.m_RdpClient.AdvancedSettings8.NetworkConnectionType = 6U;
}
if (this.m_RdpConnectionInfo.Credential != null)
{
this.m_RdpClient.UserName = this.m_RdpConnectionInfo.Credential.LogonName;
IntPtr intPtr = IntPtr.Zero;
try
{
intPtr = Marshal.SecureStringToBSTR(this.m_RdpConnectionInfo.Credential.Password);
this.m_RdpClient.AdvancedSettings7.ClearTextPassword = Marshal.PtrToStringBSTR(intPtr);
}
finally
{
if (intPtr != IntPtr.Zero)
{
Marshal.ZeroFreeBSTR(intPtr);
}
}
}
IMsRdpClientNonScriptable3 msRdpClientNonScriptable = this.m_RdpClient.GetOcx() as IMsRdpClientNonScriptable3;
if (msRdpClientNonScriptable != null)
{
msRdpClientNonScriptable.ConnectionBarText = string.Format(CultureInfo.CurrentCulture, VMISResources.RdpViewer_FullScreenConnectionBarText, this.VirtualMachine.Name, this.VirtualMachine.Server);
}
else
{
VMTrace.TraceError("Query for interface ImsRdpClientNonScriptable failed!", Array.Empty<string>());
}
this.SetSecureModeOn();
this.EnableFrameBufferRedirection();
if (!string.IsNullOrEmpty(Program.TestCmdLineValue))
{
this.m_RdpClient.Debugger.CLXCmdLine = Program.TestCmdLineValue;
}
this.m_RdpClient.AdvancedSettings7.GrabFocusOnConnect = false;
ClientVirtualizationSettings instance = ClientVirtualizationSettings.Instance;
VMConnectKeyboardOption vmconnectKeyboardOption = instance.VMConnectKeyboardOption;
try
{
this.KeyboardHookMode = vmconnectKeyboardOption;
}
catch (ArgumentException)
{
VMTrace.TraceWarning("LocalStorage setting for VMConnectKeyboardOption is set to an invalid value: " + vmconnectKeyboardOption.ToString(), Array.Empty<string>());
}
this.ReleaseKey = instance.VMConnectReleaseKey;
}
// Token: 0x06000103 RID: 259 RVA: 0x0000A6CC File Offset: 0x000088CC
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
{
this.m_MouseActivateTimer.Dispose();
}
}
// Token: 0x14000004 RID: 4
// (add) Token: 0x06000104 RID: 260 RVA: 0x0000A6E4 File Offset: 0x000088E4
// (remove) Token: 0x06000105 RID: 261 RVA: 0x0000A71C File Offset: 0x0000891C
public event EventHandler VMNameChanged;
// Token: 0x14000005 RID: 5
// (add) Token: 0x06000106 RID: 262 RVA: 0x0000A754 File Offset: 0x00008954
// (remove) Token: 0x06000107 RID: 263 RVA: 0x0000A78C File Offset: 0x0000898C
public event EventHandler VMStateChanged;
// Token: 0x14000006 RID: 6
// (add) Token: 0x06000108 RID: 264 RVA: 0x0000A7C4 File Offset: 0x000089C4
// (remove) Token: 0x06000109 RID: 265 RVA: 0x0000A7FC File Offset: 0x000089FC
public event EventHandler VMConfigurationChanged;
// Token: 0x14000007 RID: 7
// (add) Token: 0x0600010A RID: 266 RVA: 0x0000A834 File Offset: 0x00008A34
// (remove) Token: 0x0600010B RID: 267 RVA: 0x0000A86C File Offset: 0x00008A6C
public event EventHandler ConnectionStateChanged;
// Token: 0x14000008 RID: 8
// (add) Token: 0x0600010C RID: 268 RVA: 0x0000A8A4 File Offset: 0x00008AA4
// (remove) Token: 0x0600010D RID: 269 RVA: 0x0000A8DC File Offset: 0x00008ADC
public event EventHandler RequestEnterFullScreen;
// Token: 0x14000009 RID: 9
// (add) Token: 0x0600010E RID: 270 RVA: 0x0000A914 File Offset: 0x00008B14
// (remove) Token: 0x0600010F RID: 271 RVA: 0x0000A94C File Offset: 0x00008B4C
public event EventHandler RequestExitFullScreen;
// Token: 0x1400000A RID: 10
// (add) Token: 0x06000110 RID: 272 RVA: 0x0000A984 File Offset: 0x00008B84
// (remove) Token: 0x06000111 RID: 273 RVA: 0x0000A9BC File Offset: 0x00008BBC
public event EventHandler RequestFullScreenClose;
// Token: 0x1400000B RID: 11
// (add) Token: 0x06000112 RID: 274 RVA: 0x0000A9F4 File Offset: 0x00008BF4
// (remove) Token: 0x06000113 RID: 275 RVA: 0x0000AA2C File Offset: 0x00008C2C
public event EventHandler RequestFullScreenMinimize;
// Token: 0x1400000C RID: 12
// (add) Token: 0x06000114 RID: 276 RVA: 0x0000AA64 File Offset: 0x00008C64
// (remove) Token: 0x06000115 RID: 277 RVA: 0x0000AA9C File Offset: 0x00008C9C
public event EventHandler MouseCursorCapturedChanged;
// Token: 0x1400000D RID: 13
// (add) Token: 0x06000116 RID: 278 RVA: 0x0000AAD4 File Offset: 0x00008CD4
// (remove) Token: 0x06000117 RID: 279 RVA: 0x0000AB0C File Offset: 0x00008D0C
public event EventHandler KeyboardInputCapturedChanged;
// Token: 0x1400000E RID: 14
// (add) Token: 0x06000118 RID: 280 RVA: 0x0000AB44 File Offset: 0x00008D44
// (remove) Token: 0x06000119 RID: 281 RVA: 0x0000AB7C File Offset: 0x00008D7C
public event EventHandler MouseModeRelativeChanged;
// Token: 0x1400000F RID: 15
// (add) Token: 0x0600011A RID: 282 RVA: 0x0000ABB4 File Offset: 0x00008DB4
// (remove) Token: 0x0600011B RID: 283 RVA: 0x0000ABEC File Offset: 0x00008DEC
public event EventHandler HasSnapshotsChanged;
// Token: 0x14000010 RID: 16
// (add) Token: 0x0600011C RID: 284 RVA: 0x0000AC24 File Offset: 0x00008E24
// (remove) Token: 0x0600011D RID: 285 RVA: 0x0000AC5C File Offset: 0x00008E5C
public event EventHandler OfflineDisplayStringsUpdated;
// Token: 0x14000011 RID: 17
// (add) Token: 0x0600011E RID: 286 RVA: 0x0000AC94 File Offset: 0x00008E94
// (remove) Token: 0x0600011F RID: 287 RVA: 0x0000ACCC File Offset: 0x00008ECC
public event EventHandler GuestResolutionChanged;
// Token: 0x17000027 RID: 39
// (get) Token: 0x06000120 RID: 288 RVA: 0x0000AD01 File Offset: 0x00008F01
public IVMComputerSystem VirtualMachine
{
get
{
return this.m_RdpConnectionInfo.VirtualMachine;
}
}
// Token: 0x17000028 RID: 40
// (get) Token: 0x06000121 RID: 289 RVA: 0x0000AD0E File Offset: 0x00008F0E
public bool IsVMMigrating
{
get
{
return this.m_MigrationData.IsMigrating;
}
}
// Token: 0x17000029 RID: 41
// (get) Token: 0x06000122 RID: 290 RVA: 0x0000AD1B File Offset: 0x00008F1B
public bool IsVMMigratingOrMigrated
{
get
{
return this.m_MigrationData.IsMigrating || this.m_MigrationData.IsMigrated;
}
}
// Token: 0x1700002A RID: 42
// (get) Token: 0x06000123 RID: 291 RVA: 0x0000AD37 File Offset: 0x00008F37
public int LaunchIndex
{
get
{
return this.m_RdpConnectionInfo.LaunchIndex;
}
}
// Token: 0x1700002B RID: 43
// (get) Token: 0x06000124 RID: 292 RVA: 0x0000AD44 File Offset: 0x00008F44
public bool ShowOptions
{
get
{
return this.m_RdpConnectionInfo.ShowOptions;
}
}
// Token: 0x06000125 RID: 293 RVA: 0x0000AD54 File Offset: 0x00008F54
public void EnterFullScreen()
{
if (!this.FullScreen)
{
this.FullScreen = true;
if (this.IsConnected)
{
if (this.ConnectionState != RdpViewerConnectionState.ConnectedEnhancedVideoSyncedSession)
{
if (this.ConnectionState != RdpViewerConnectionState.ConnectedEnhancedVideo)
{
this.m_PreFullScreenZoomLevel = new ZoomLevel?(this.m_CurrentZoomLevel);
this.SetZoomLevel(ZoomLevel.P100);
}
this.m_RdpClient.Location = new Point(Math.Max((base.Width - this.m_DesktopResolution.Width) / 2, 0), Math.Max((base.Height - this.m_DesktopResolution.Height) / 2, 0));
}
else
{
this.m_RdpClient.SyncSessionDisplaySettings();
}
}
this.m_RdpClient.FullScreen = true;
this.Refresh();
}
}
// Token: 0x06000126 RID: 294 RVA: 0x0000AE0C File Offset: 0x0000900C
public void ExitFullScreen()
{
if (this.FullScreen)
{
this.FullScreen = false;
this.m_RdpClient.FullScreen = false;
this.m_RdpClient.Location = new Point(0, 0);
if (this.IsConnectedBasic)
{
this.SetZoomLevel(this.m_PreFullScreenZoomLevel.Value);
this.m_PreFullScreenZoomLevel = null;
this.KeyboardInputCaptured = true;
}
this.Refresh();
}
}
// Token: 0x1700002C RID: 44
// (get) Token: 0x06000127 RID: 295 RVA: 0x0000AE78 File Offset: 0x00009078
// (set) Token: 0x06000128 RID: 296 RVA: 0x0000AE80 File Offset: 0x00009080
public bool FullScreen { get; private set; }
// Token: 0x1700002D RID: 45
// (get) Token: 0x06000129 RID: 297 RVA: 0x0000AE89 File Offset: 0x00009089
public bool FullScreenUseAllMonitors
{
get
{
RdpOptions rdpOptions = this.m_RdpOptions;
return rdpOptions != null && rdpOptions.UseAllMonitors;
}
}
// Token: 0x1700002E RID: 46
// (get) Token: 0x0600012A RID: 298 RVA: 0x0000AE9C File Offset: 0x0000909C
public Size DesktopResolution
{
get
{
return this.m_DesktopResolution;
}
}
// Token: 0x1700002F RID: 47
// (get) Token: 0x0600012B RID: 299 RVA: 0x0000AEA4 File Offset: 0x000090A4
public Size ScaledDesktopResolution
{
get
{
return new Size((int)((double)(this.m_DesktopResolution.Width * (int)this.m_CurrentZoomLevel) / 100.0), (int)((double)(this.m_DesktopResolution.Height * (int)this.m_CurrentZoomLevel) / 100.0));
}
}
// Token: 0x17000030 RID: 48
// (get) Token: 0x0600012C RID: 300 RVA: 0x0000AEF2 File Offset: 0x000090F2
public bool IsConnected
{
get
{
return this.ConnectionState >= RdpViewerConnectionState.ConnectedNoVideo;
}
}
// Token: 0x17000031 RID: 49
// (get) Token: 0x0600012D RID: 301 RVA: 0x0000AF00 File Offset: 0x00009100
public bool IsConnectedBasic
{
get
{
return this.ConnectionState >= RdpViewerConnectionState.ConnectedNoVideo && this.ConnectionState < RdpViewerConnectionState.ConnectedEnhancedVideo;
}
}
// Token: 0x17000032 RID: 50
// (get) Token: 0x0600012E RID: 302 RVA: 0x0000AF16 File Offset: 0x00009116
public bool IsConnectedEnhanced
{
get
{
return this.ConnectionState >= RdpViewerConnectionState.ConnectedEnhancedVideo;
}
}
// Token: 0x17000033 RID: 51
// (get) Token: 0x0600012F RID: 303 RVA: 0x0000AF24 File Offset: 0x00009124
// (set) Token: 0x06000130 RID: 304 RVA: 0x0000AF2C File Offset: 0x0000912C
public RdpViewerConnectionState ConnectionState
{
get
{
return this.m_State;
}
private set
{
if (this.m_State != value)
{
this.m_State = value;
this.SetDisplayStrings();
EventHandler connectionStateChanged = this.ConnectionStateChanged;
if (connectionStateChanged == null)
{
return;
}
connectionStateChanged(this, EventArgs.Empty);
}
}
}
// Token: 0x17000034 RID: 52
// (get) Token: 0x06000131 RID: 305 RVA: 0x0000AF5C File Offset: 0x0000915C
public RdpAuthenticationType AuthenticationType
{
get
{
if (this.IsConnected)
{
IMsRdpClientAdvancedSettings6 msRdpClientAdvancedSettings = null;
try
{
msRdpClientAdvancedSettings = this.m_RdpClient.AdvancedSettings7;
}
catch (ObjectDisposedException ex)
{
VMTrace.TraceWarning("Rdp client object is not valid.", ex);
return RdpAuthenticationType.None;
}
return (RdpAuthenticationType)msRdpClientAdvancedSettings.AuthenticationType;
}
return RdpAuthenticationType.None;
}
}
// Token: 0x17000035 RID: 53
// (get) Token: 0x06000132 RID: 306 RVA: 0x0000AFAC File Offset: 0x000091AC
// (set) Token: 0x06000133 RID: 307 RVA: 0x0000AFB4 File Offset: 0x000091B4
public bool MouseCursorCaptured
{
get
{
return this.m_MouseCursorCaptured;
}
private set
{
if (this.m_MouseCursorCaptured != value)
{
this.m_MouseCursorCaptured = value;
if (this.MouseCursorCapturedChanged != null)
{
this.MouseCursorCapturedChanged(this, EventArgs.Empty);
}
}
}
}
// Token: 0x17000036 RID: 54
// (get) Token: 0x06000134 RID: 308 RVA: 0x0000AFDF File Offset: 0x000091DF
// (set) Token: 0x06000135 RID: 309 RVA: 0x0000AFE7 File Offset: 0x000091E7
public bool KeyboardInputCaptured
{
get
{
return this.m_KeyboardInputCaptured;
}
private set
{
if (this.m_KeyboardInputCaptured != value)
{
this.m_KeyboardInputCaptured = value;
if (this.KeyboardInputCapturedChanged != null)
{
this.KeyboardInputCapturedChanged(this, EventArgs.Empty);
}
}
}
}
// Token: 0x17000037 RID: 55
// (get) Token: 0x06000136 RID: 310 RVA: 0x0000B012 File Offset: 0x00009212
// (set) Token: 0x06000137 RID: 311 RVA: 0x0000B01A File Offset: 0x0000921A
public bool MouseModeRelative
{
get
{
return this.m_MouseModeRelative;
}
private set
{
if (this.m_MouseModeRelative != value)
{
this.m_MouseModeRelative = value;
if (!value)
{
this.MouseCursorCaptured = false;
}
if (this.MouseModeRelativeChanged != null)
{
this.MouseModeRelativeChanged(this, EventArgs.Empty);
}
}
}
}
// Token: 0x17000038 RID: 56
// (get) Token: 0x06000138 RID: 312 RVA: 0x0000B04F File Offset: 0x0000924F
// (set) Token: 0x06000139 RID: 313 RVA: 0x0000B061 File Offset: 0x00009261
public VMConnectKeyboardOption KeyboardHookMode
{
get
{
return (VMConnectKeyboardOption)this.m_RdpClient.SecuredSettings2.KeyboardHookMode;
}
set
{
if (value > VMConnectKeyboardOption.FullScreen)
{
throw new InvalidEnumArgumentException("value", (int)value, typeof(VMConnectKeyboardOption));
}
if (this.ConnectionState == RdpViewerConnectionState.NotConnected)
{
this.m_RdpClient.SecuredSettings2.KeyboardHookMode = (int)value;
return;
}
throw new InvalidOperationException();
}
}
// Token: 0x17000039 RID: 57
// (get) Token: 0x0600013A RID: 314 RVA: 0x0000B09D File Offset: 0x0000929D
// (set) Token: 0x0600013B RID: 315 RVA: 0x0000B0B0 File Offset: 0x000092B0
public VMConnectReleaseKey ReleaseKey
{
get
{
return (VMConnectReleaseKey)this.m_RdpClient.AdvancedSettings7.HotKeyFocusReleaseLeft;
}
set
{
if (this.ConnectionState == RdpViewerConnectionState.NotConnected)
{
int num = (int)VMConnectReleaseKeyHelper.ValidateValue(value);
IMsRdpClientAdvancedSettings6 advancedSettings = this.m_RdpClient.AdvancedSettings7;
advancedSettings.HotKeyFocusReleaseLeft = num;
advancedSettings.HotKeyFocusReleaseRight = num;
return;
}
throw new InvalidOperationException();
}
}
// Token: 0x1700003A RID: 58
// (get) Token: 0x0600013C RID: 316 RVA: 0x0000B0EB File Offset: 0x000092EB
public bool HasSnapshots
{
get
{
return this.m_SnapshotTracker.HasSnapshots;
}
}
// Token: 0x1700003B RID: 59
// (get) Token: 0x0600013D RID: 317 RVA: 0x0000B0F8 File Offset: 0x000092F8
// (set) Token: 0x0600013E RID: 318 RVA: 0x0000B13C File Offset: 0x0000933C
public bool KeyboardHookLoaded
{
get
{
bool result;
try
{
result = (this.m_RdpClient.SecuredSettings2.KeyboardHookMode == 1);
}
catch (ObjectDisposedException ex)
{
VMTrace.TraceWarning("Rdp client object is not valid.", ex);
result = false;
}
return result;
}
set
{
if (this.ConnectionState == RdpViewerConnectionState.NotConnected)
{
try
{
if (value)
{
this.m_RdpClient.SecuredSettings2.KeyboardHookMode = 1;
}
else
{
this.m_RdpClient.SecuredSettings2.KeyboardHookMode = 2;
}
return;
}
catch (ObjectDisposedException ex)
{
VMTrace.TraceWarning("Rdp client object is not valid.", ex);
return;
}
}
throw new InvalidOperationException();
}
}
// Token: 0x1700003C RID: 60
// (get) Token: 0x0600013F RID: 319 RVA: 0x0000B1A0 File Offset: 0x000093A0
public bool RdpEnhancedModeAvailable
{
get
{
return this.m_OldRdpEnhancedModeAvailable && !RdpOptions.IsRestrictedAdminModePolicyEnabled();
}
}
// Token: 0x1700003D RID: 61
// (get) Token: 0x06000140 RID: 320 RVA: 0x0000B1B4 File Offset: 0x000093B4
// (set) Token: 0x06000141 RID: 321 RVA: 0x0000B1C6 File Offset: 0x000093C6
public bool PreferEnhancedModeConnection
{
get
{
return this.IsShieldedVm() || this.m_VMConnectUseEnhancedModeRuntimePreference;
}
set
{
this.m_VMConnectUseEnhancedModeRuntimePreference = value;
}
}
// Token: 0x1700003E RID: 62
// (get) Token: 0x06000142 RID: 322 RVA: 0x0000B1CF File Offset: 0x000093CF
public bool IsDeviceRedirectionInitialized
{
get
{
return this.m_RdpClientDeviceRedirectionInitialized;
}
}
// Token: 0x1700003F RID: 63
// (get) Token: 0x06000143 RID: 323 RVA: 0x0000B1D7 File Offset: 0x000093D7
public IReadOnlyList<string> OfflineDisplayStrings
{
get
{
return this.m_DisplayStrings;
}
}
// Token: 0x17000040 RID: 64
// (get) Token: 0x06000144 RID: 324 RVA: 0x0000B1DF File Offset: 0x000093DF
public ZoomLevel CurrentZoomLevel
{
get
{
return this.m_CurrentZoomLevel;
}
}
// Token: 0x06000145 RID: 325 RVA: 0x0000B1E8 File Offset: 0x000093E8
private void OnConnected(object sender, EventArgs ea)
{
VMTrace.TraceUserActionCompleted("RdpViewer connected to virtual machine video successfully.", Array.Empty<string>());
object connectionLock = this.m_ConnectionLock;
lock (connectionLock)
{
this.ConnectionState = (this.m_ConnectInEnhancedMode ? RdpViewerConnectionState.ConnectedEnhancedVideo : RdpViewerConnectionState.ConnectedBasicVideo);
object obj = this.IsConnected && this.ConnectionState != RdpViewerConnectionState.ConnectedNoVideo;
this.m_ReconnectionAttempts = 0;
this.SetDisplayStrings();
object obj2 = obj;
if (obj2 != null)
{
this.m_RdpClient.Visible = true;
this.KeyboardInputCaptured = true;
}
this.CaptureKeyboardFocus();
if (obj2 != null && this.IsConnectedEnhanced && this.m_RdpOptions.FullScreen)
{
EventHandler requestEnterFullScreen = this.RequestEnterFullScreen;
if (requestEnterFullScreen != null)
{
requestEnterFullScreen(this, EventArgs.Empty);
}
}
}
}
// Token: 0x06000146 RID: 326 RVA: 0x0000B2B4 File Offset: 0x000094B4
private void OnDisconnected(object sender, IMsTscAxEvents_OnDisconnectedEvent ea)
{
bool flag = false;
bool enhancedMode = false;
bool flag2 = false;
bool flag3 = false;
this.m_DisconnectInProgress = true;
VMTrace.TraceInformation("RdpViewer disconnected from the virtual machine's video.", Array.Empty<string>());
bool disconnectedWhileConnected = this.IsConnected;
if (!this.IsConnected && this.ConnectionState != RdpViewerConnectionState.Connecting)
{
VMTrace.TraceInformation("OnDisconnected event is being sent when not in the Connected or Connecting state. This is an extra Disconnected event. Ignore.", Array.Empty<string>());
return;
}
string errorMessage = this.GetDisconnectErrorMessage(ea.discReason, this.m_RdpClient.ExtendedDisconnectReason, disconnectedWhileConnected, out this.m_ConnectionErrorReason);
if (this.m_ConnectionErrorReason == RdpViewerControl.ConnectionErrorReason.DisconnectedNormally)
{
if (this.IsVMVideoAvailable() && !this.IsVMMigratingOrMigrated)
{
VMStateChangeAction? informedVMStateChange = this.m_InformedVMStateChange;
VMStateChangeAction vmstateChangeAction = VMStateChangeAction.Reset;
if (!(informedVMStateChange.GetValueOrDefault() == vmstateChangeAction & informedVMStateChange != null))
{
informedVMStateChange = this.m_InformedVMStateChange;
vmstateChangeAction = VMStateChangeAction.Turnoff;
if (!(informedVMStateChange.GetValueOrDefault() == vmstateChangeAction & informedVMStateChange != null))
{
informedVMStateChange = this.m_InformedVMStateChange;
vmstateChangeAction = VMStateChangeAction.SaveState;
if (!(informedVMStateChange.GetValueOrDefault() == vmstateChangeAction & informedVMStateChange != null))
{
informedVMStateChange = this.m_InformedVMStateChange;
vmstateChangeAction = VMStateChangeAction.Shutdown;
if (!(informedVMStateChange.GetValueOrDefault() == vmstateChangeAction & informedVMStateChange != null))
{
goto IL_132;
}
}
}
}
}
this.m_ConnectionErrorReason = RdpViewerControl.ConnectionErrorReason.NoConnectionError;
errorMessage = null;
}
IL_132:
object connectionLock = this.m_ConnectionLock;
lock (connectionLock)
{
flag = this.m_SilentDisconnect;
this.m_SilentDisconnect = false;
flag3 = this.IsConnectedEnhanced;
if (!flag)
{
this.PrintDisconnectionErrorDebugMessage(ea.discReason, errorMessage);
}
this.Deactivate();
if (this.FullScreen)
{
EventHandler requestExitFullScreen = this.RequestExitFullScreen;
if (requestExitFullScreen != null)
{
requestExitFullScreen(this, EventArgs.Empty);
}
}
this.SetDisplayStrings();
this.ConnectionState = RdpViewerConnectionState.NotConnected;
if (this.m_ConnectionModeSwitch != RdpViewerControl.RdpViewerModeSwitch.None)
{
flag2 = true;
enhancedMode = (this.m_ConnectionModeSwitch == RdpViewerControl.RdpViewerModeSwitch.SwitchToEnhanced);
this.m_ConnectionModeSwitch = RdpViewerControl.RdpViewerModeSwitch.None;
}
this.CreateRdpClient(false);
Interlocked.Exchange(ref this.m_BlockConnectionRequests, 0);
this.m_DisconnectInProgress = false;
}
if (this.m_ConnectionErrorReason == RdpViewerControl.ConnectionErrorReason.DisconnectedNormallyLogoffByUser)
{
this.Connect(false, true);
return;
}
if (flag2)
{
this.Connect(enhancedMode, false);
return;
}
if (this.m_ConnectionErrorReason == RdpViewerControl.ConnectionErrorReason.UnexpectedDisconnection && this.m_ReconnectionAttempts < 5)
{
Thread.Sleep(50);
this.m_ReconnectionAttempts++;
base.BeginInvoke(new Action<bool, bool>(this.Connect), new object[]
{
this.m_ConnectInEnhancedMode,
false
});
return;
}
if (this.m_ConnectInEnhancedMode && this.m_ReconnectionAttempts >= 5)
{
this.m_ReconnectionAttempts = 0;
this.m_ConnectInEnhancedMode = false;
this.Connect(false, true);
return;
}
if (!flag && !string.IsNullOrEmpty(errorMessage))
{
if (this.m_ConnectionErrorReason != RdpViewerControl.ConnectionErrorReason.DisconnectedNormally)
{
base.BeginInvoke(new RdpViewerControl.DisplayDisconnectionMessageMethod(this.DisplayDisconnectionMessage), new object[]
{
errorMessage,
disconnectedWhileConnected
});
return;
}
if (flag3 && ea.discReason == 1)
{
this.CloseForm();
return;
}
DelayedUIInvoker delayedUIInvoker = new DelayedUIInvoker();
delayedUIInvoker.DelayTime = TimeSpan.FromSeconds(1.0);
delayedUIInvoker.Invoked += delegate(object o, EventArgs e)
{
if (this.IsVMVideoAvailable())
{
this.DisplayDisconnectionMessage(errorMessage, disconnectedWhileConnected);
return;
}
this.m_ConnectionErrorReason = RdpViewerControl.ConnectionErrorReason.NoConnectionError;
};
delayedUIInvoker.Invoke();
}
}
// Token: 0x06000147 RID: 327 RVA: 0x0000B5E8 File Offset: 0x000097E8
private void OnVirtualMachineResolutionChanged(object sender, IMsTscAxEvents_OnRemoteDesktopSizeChangeEvent ea)
{
VMTrace.TraceInformation(string.Format("Virtual machine desktop resolution changed. New resolution is: ({0}, {1})", ea.width, ea.height), Array.Empty<string>());
this.m_DesktopResolution = new Size(ea.width, ea.height);
EventHandler guestResolutionChanged = this.GuestResolutionChanged;
if (guestResolutionChanged != null)
{
guestResolutionChanged(this, EventArgs.Empty);
}
bool flag = this.ConnectionState == RdpViewerConnectionState.ConnectedNoVideo;
if (this.IsConnected || this.ConnectionState == RdpViewerConnectionState.Connecting)
{
this.m_RdpClient.Size = new Size(Math.Min(base.Width, this.ScaledDesktopResolution.Width), Math.Min(base.Height, this.ScaledDesktopResolution.Height));
if (this.IsConnectedBasic && this.FullScreen)
{
this.m_RdpClient.Location = new Point(Math.Max((base.Width - this.m_DesktopResolution.Width) / 2, 0), Math.Max((base.Height - this.m_DesktopResolution.Height) / 2, 0));
}
if (ea.width == RdpViewerControl.DisabledVideoResolution.Width && ea.height == RdpViewerControl.DisabledVideoResolution.Height)
{
this.ConnectionState = RdpViewerConnectionState.ConnectedNoVideo;
}
else if (flag)
{
this.m_RdpClient.Visible = true;
}
this.SetDisplayStrings();
}
}
// Token: 0x06000148 RID: 328 RVA: 0x0000B749 File Offset: 0x00009949
private void OnMouseActivate(object sender, EventArgs ea)
{
if (this.IsConnected && this.MouseModeRelative)
{
if (!this.FullScreen)
{
this.MouseCursorCaptured = true;
return;
}
this.m_MouseActivateTimer.Start();
}
}
// Token: 0x06000149 RID: 329 RVA: 0x0000B778 File Offset: 0x00009978
private void HandleMouseActivateTimer(object sender, EventArgs ea)
{
this.m_MouseActivateTimer.Stop();
NativeMethods.CURSORINFO cursorinfo = default(NativeMethods.CURSORINFO);
cursorinfo.cbSize = Marshal.SizeOf(typeof(NativeMethods.CURSORINFO));
if (!NativeMethods.GetCursorInfo(ref cursorinfo))
{
VMTrace.TraceWarning("GetCursorInfo failed. Assume cursor is hidden.", Array.Empty<string>());
}
if (cursorinfo.flags == 0)
{
this.MouseCursorCaptured = true;
}
}
// Token: 0x0600014A RID: 330 RVA: 0x0000B7D8 File Offset: 0x000099D8
private void HandleVMCacheUpdated(object sender, EventArgs ea)
{
if (base.InvokeRequired)
{
try
{
base.BeginInvoke(new EventHandler(this.HandleVMStateChangeUIThread), new object[]
{
sender,
ea
});
base.BeginInvoke(new EventHandler(this.HandleVMNameChangeUIThread), new object[]
{
sender,
ea
});
return;
}
catch (InvalidOperationException)
{
return;
}
}
this.HandleVMStateChangeUIThread(sender, ea);
this.HandleVMNameChangeUIThread(sender, ea);
}
// Token: 0x0600014B RID: 331 RVA: 0x0000B854 File Offset: 0x00009A54
private void HandleVMDeleted(object sender, EventArgs ea)
{
if (base.InvokeRequired)
{
base.BeginInvoke(new EventHandler(this.HandleVMDeletedWithWait), new object[]
{
sender,
ea
});
return;
}
this.HandleVMDeletedWithWait(sender, ea);
}
// Token: 0x0600014C RID: 332 RVA: 0x0000B888 File Offset: 0x00009A88
private void HandleVMDeletedWithWait(object sender, EventArgs ea)
{
if (!this.IsVMMigratingOrMigrated)
{
Thread.Sleep(1000);
}
try
{
this.HandleVMDeletedUIThread(sender, ea);
}
catch (InvalidOperationException)
{
}
}
// Token: 0x0600014D RID: 333 RVA: 0x0000B8C8 File Offset: 0x00009AC8
private void HandleVMStateChangeUIThread(object sender, EventArgs ea)
{
if (sender == this.VirtualMachine)
{
VMComputerSystemState state = this.VirtualMachine.State;
VMComputerSystemHealthState healthState = this.VirtualMachine.HealthState;
bool flag = this.VirtualMachine.EnhancedSessionModeState == EnhancedSessionModeStateType.Available;
if (state != this.m_OldVMState || healthState != this.m_OldVMHealthState || flag != this.m_OldRdpEnhancedModeAvailable)
{
this.m_OldLastConfigurationChange = this.VirtualMachine.TimeOfLastConfigurationChange;
this.m_VMIsRestoring = (state == VMComputerSystemState.Starting && this.m_OldVMState == VMComputerSystemState.Saved);
this.m_OldVMState = state;
this.m_OldVMHealthState = healthState;
this.m_OldRdpEnhancedModeAvailable = flag;
VMTrace.TraceInformation(string.Format(CultureInfo.InvariantCulture, "VM State has changed. New state is {0} and new healthstate is {1} ", state, healthState), Array.Empty<string>());
this.SetDisplayStrings();
bool flag2 = flag && this.PrepareForEnhancedMode(false);
bool flag3 = flag2 && (this.IsConnectedBasic || (this.IsShieldedVm() && this.ConnectionState == RdpViewerConnectionState.Connecting));
bool flag4 = state == VMComputerSystemState.Paused && !flag && this.IsConnectedEnhanced;
if (this.IsVMVideoAvailable() && (this.ConnectionState == RdpViewerConnectionState.NotConnected || flag3 || flag4))
{
if (Program.Displayer.NumberOfDialogsOpen < 1)
{
this.Connect(flag2, true);
}
else
{
Program.Displayer.LastDialogClosed += this.ConnectAfterDialogsClose;
}
}
EventHandler vmstateChanged = this.VMStateChanged;
if (vmstateChanged == null)
{
return;
}
vmstateChanged(this, EventArgs.Empty);
return;
}
else
{
DateTime timeOfLastConfigurationChange = this.VirtualMachine.TimeOfLastConfigurationChange;
if (timeOfLastConfigurationChange > this.m_OldLastConfigurationChange)
{
this.m_OldLastConfigurationChange = timeOfLastConfigurationChange;
if (this.VMConfigurationChanged != null)
{
this.VMConfigurationChanged(this, EventArgs.Empty);
}
}
}
}
}
// Token: 0x0600014E RID: 334 RVA: 0x0000BA70 File Offset: 0x00009C70
private void ConnectAfterDialogsClose(object sender, EventArgs ea)
{
Program.Displayer.LastDialogClosed -= this.ConnectAfterDialogsClose;
bool flag = this.m_OldRdpEnhancedModeAvailable && this.PrepareForEnhancedMode(false);
bool flag2 = flag && (this.IsConnectedBasic || (this.IsShieldedVm() && this.ConnectionState == RdpViewerConnectionState.Connecting));
if ((this.IsVMVideoAvailable() && this.ConnectionState == RdpViewerConnectionState.NotConnected) || flag2)
{
this.Connect(flag, true);
}
}
// Token: 0x0600014F RID: 335 RVA: 0x0000BAEC File Offset: 0x00009CEC
private void HandleVMNameChangeUIThread(object sender, EventArgs ea)
{
if (sender == this.VirtualMachine)
{
string name = this.VirtualMachine.Name;
if (name != this.m_OldVMName)
{
this.m_OldVMName = name;
this.SetDisplayStrings();
EventHandler vmnameChanged = this.VMNameChanged;