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
|
use core::ptr::null_mut;
use crate::ntrtl::RTL_TIME_ZONE_INFORMATION;
use winapi::shared::basetsd::SIZE_T;
use winapi::shared::minwindef::{BYTE, DWORD, FILETIME};
use winapi::shared::ntdef::{
BOOLEAN, CHAR, HANDLE, LARGE_INTEGER, LONG, PULONG, PVOID, PWSTR, UCHAR, ULONG, UNICODE_STRING,
USHORT, WCHAR,
};
use winapi::shared::windef::HWND;
use winapi::um::winnt::{PSID, STANDARD_RIGHTS_REQUIRED};
pub const WINSTATION_QUERY: u32 = 0x00000001;
pub const WINSTATION_SET: u32 = 0x00000002;
pub const WINSTATION_RESET: u32 = 0x00000004;
pub const WINSTATION_VIRTUAL: u32 = 0x00000008;
pub const WINSTATION_SHADOW: u32 = 0x00000010;
pub const WINSTATION_LOGON: u32 = 0x00000020;
pub const WINSTATION_LOGOFF: u32 = 0x00000040;
pub const WINSTATION_MSG: u32 = 0x00000080;
pub const WINSTATION_CONNECT: u32 = 0x00000100;
pub const WINSTATION_DISCONNECT: u32 = 0x00000200;
pub const WINSTATION_GUEST_ACCESS: u32 = WINSTATION_LOGON;
pub const WINSTATION_CURRENT_GUEST_ACCESS: u32 = WINSTATION_VIRTUAL | WINSTATION_LOGOFF;
pub const WINSTATION_USER_ACCESS: u32 =
WINSTATION_GUEST_ACCESS | WINSTATION_QUERY | WINSTATION_CONNECT;
pub const WINSTATION_CURRENT_USER_ACCESS: u32 = WINSTATION_SET | WINSTATION_RESET
| WINSTATION_VIRTUAL | WINSTATION_LOGOFF | WINSTATION_DISCONNECT;
pub const WINSTATION_ALL_ACCESS: u32 = STANDARD_RIGHTS_REQUIRED | WINSTATION_QUERY | WINSTATION_SET
| WINSTATION_RESET | WINSTATION_VIRTUAL | WINSTATION_SHADOW | WINSTATION_LOGON | WINSTATION_MSG
| WINSTATION_CONNECT | WINSTATION_DISCONNECT;
pub const WDPREFIX_LENGTH: usize = 12;
pub const CALLBACK_LENGTH: usize = 50;
pub const DLLNAME_LENGTH: usize = 32;
pub const CDNAME_LENGTH: usize = 32;
pub const WDNAME_LENGTH: usize = 32;
pub const PDNAME_LENGTH: usize = 32;
pub const DEVICENAME_LENGTH: usize = 128;
pub const MODEMNAME_LENGTH: usize = DEVICENAME_LENGTH;
pub const STACK_ADDRESS_LENGTH: usize = 128;
pub const MAX_BR_NAME: usize = 65;
pub const DIRECTORY_LENGTH: usize = 256;
pub const INITIALPROGRAM_LENGTH: usize = 256;
pub const USERNAME_LENGTH: usize = 20;
pub const DOMAIN_LENGTH: usize = 17;
pub const PASSWORD_LENGTH: usize = 14;
pub const NASISPECIFICNAME_LENGTH: usize = 14;
pub const NASIUSERNAME_LENGTH: usize = 47;
pub const NASIPASSWORD_LENGTH: usize = 24;
pub const NASISESSIONNAME_LENGTH: usize = 16;
pub const NASIFILESERVER_LENGTH: usize = 47;
pub const CLIENTDATANAME_LENGTH: usize = 7;
pub const CLIENTNAME_LENGTH: usize = 20;
pub const CLIENTADDRESS_LENGTH: usize = 30;
pub const IMEFILENAME_LENGTH: usize = 32;
pub const CLIENTLICENSE_LENGTH: usize = 32;
pub const CLIENTMODEM_LENGTH: usize = 40;
pub const CLIENT_PRODUCT_ID_LENGTH: usize = 32;
pub const MAX_COUNTER_EXTENSIONS: u32 = 2;
pub const WINSTATIONNAME_LENGTH: usize = 32;
pub const TERMSRV_TOTAL_SESSIONS: u32 = 1;
pub const TERMSRV_DISC_SESSIONS: u32 = 2;
pub const TERMSRV_RECON_SESSIONS: u32 = 3;
pub const TERMSRV_CURRENT_ACTIVE_SESSIONS: u32 = 4;
pub const TERMSRV_CURRENT_DISC_SESSIONS: u32 = 5;
pub const TERMSRV_PENDING_SESSIONS: u32 = 6;
pub const TERMSRV_SUCC_TOTAL_LOGONS: u32 = 7;
pub const TERMSRV_SUCC_LOCAL_LOGONS: u32 = 8;
pub const TERMSRV_SUCC_REMOTE_LOGONS: u32 = 9;
pub const TERMSRV_SUCC_SESSION0_LOGONS: u32 = 10;
pub const TERMSRV_CURRENT_TERMINATING_SESSIONS: u32 = 11;
pub const TERMSRV_CURRENT_LOGGEDON_SESSIONS: u32 = 12;
pub type PTS_TIME_ZONE_INFORMATION = *mut RTL_TIME_ZONE_INFORMATION;
pub type TS_TIME_ZONE_INFORMATION = RTL_TIME_ZONE_INFORMATION;
pub type WINSTATIONNAME = [WCHAR; WINSTATIONNAME_LENGTH + 1];
STRUCT!{struct VARDATA_WIRE {
Size: USHORT,
Offset: USHORT,
}}
pub type PVARDATA_WIRE = *mut VARDATA_WIRE;
ENUM!{enum WINSTATIONSTATECLASS {
State_Active = 0,
State_Connected = 1,
State_ConnectQuery = 2,
State_Shadow = 3,
State_Disconnected = 4,
State_Idle = 5,
State_Listen = 6,
State_Reset = 7,
State_Down = 8,
State_Init = 9,
}}
UNION!{union SESSIONIDW_u {
SessionId: ULONG,
LogonId: ULONG,
}}
STRUCT!{struct SESSIONIDW {
u: SESSIONIDW_u,
WinStationName: WINSTATIONNAME,
State: WINSTATIONSTATECLASS,
}}
pub type PSESSIONIDW = *mut SESSIONIDW;
ENUM!{enum WINSTATIONINFOCLASS {
WinStationCreateData = 0,
WinStationConfiguration = 1,
WinStationPdParams = 2,
WinStationWd = 3,
WinStationPd = 4,
WinStationPrinter = 5,
WinStationClient = 6,
WinStationModules = 7,
WinStationInformation = 8,
WinStationTrace = 9,
WinStationBeep = 10,
WinStationEncryptionOff = 11,
WinStationEncryptionPerm = 12,
WinStationNtSecurity = 13,
WinStationUserToken = 14,
WinStationUnused1 = 15,
WinStationVideoData = 16,
WinStationInitialProgram = 17,
WinStationCd = 18,
WinStationSystemTrace = 19,
WinStationVirtualData = 20,
WinStationClientData = 21,
WinStationSecureDesktopEnter = 22,
WinStationSecureDesktopExit = 23,
WinStationLoadBalanceSessionTarget = 24,
WinStationLoadIndicator = 25,
WinStationShadowInfo = 26,
WinStationDigProductId = 27,
WinStationLockedState = 28,
WinStationRemoteAddress = 29,
WinStationIdleTime = 30,
WinStationLastReconnectType = 31,
WinStationDisallowAutoReconnect = 32,
WinStationMprNotifyInfo = 33,
WinStationExecSrvSystemPipe = 34,
WinStationSmartCardAutoLogon = 35,
WinStationIsAdminLoggedOn = 36,
WinStationReconnectedFromId = 37,
WinStationEffectsPolicy = 38,
WinStationType = 39,
WinStationInformationEx = 40,
WinStationValidationInfo = 41,
}}
STRUCT!{struct WINSTATIONCREATE {
Bitfields: ULONG,
MaxInstanceCount: ULONG,
}}
BITFIELD!{WINSTATIONCREATE Bitfields: ULONG [
fEnableWinStation set_fEnableWinStation[0..1],
]}
pub type PWINSTATIONCREATE = *mut WINSTATIONCREATE;
STRUCT!{struct WINSTACONFIGWIRE {
Comment: [WCHAR; 61],
OEMId: [CHAR; 4],
UserConfig: VARDATA_WIRE,
NewFields: VARDATA_WIRE,
}}
pub type PWINSTACONFIGWIRE = *mut WINSTACONFIGWIRE;
ENUM!{enum CALLBACKCLASS {
Callback_Disable = 0,
Callback_Roving = 1,
Callback_Fixed = 2,
}}
ENUM!{enum SHADOWCLASS {
Shadow_Disable = 0,
Shadow_EnableInputNotify = 1,
Shadow_EnableInputNoNotify = 2,
Shadow_EnableNoInputNotify = 3,
Shadow_EnableNoInputNoNotify = 4,
}}
STRUCT!{struct USERCONFIG {
Bitfields: ULONG,
Bitfields2: ULONG,
UserName: [WCHAR; USERNAME_LENGTH + 1],
Domain: [WCHAR; DOMAIN_LENGTH + 1],
Password: [WCHAR; PASSWORD_LENGTH + 1],
WorkDirectory: [WCHAR; DIRECTORY_LENGTH + 1],
InitialProgram: [WCHAR; INITIALPROGRAM_LENGTH + 1],
CallbackNumber: [WCHAR; CALLBACK_LENGTH + 1],
Callback: CALLBACKCLASS,
Shadow: SHADOWCLASS,
MaxConnectionTime: ULONG,
MaxDisconnectionTime: ULONG,
MaxIdleTime: ULONG,
KeyboardLayout: ULONG,
MinEncryptionLevel: BYTE,
NWLogonServer: [WCHAR; NASIFILESERVER_LENGTH + 1],
PublishedName: [WCHAR; MAX_BR_NAME],
WFProfilePath: [WCHAR; DIRECTORY_LENGTH + 1],
WFHomeDir: [WCHAR; DIRECTORY_LENGTH + 1],
WFHomeDirDrive: [WCHAR; 4],
}}
BITFIELD!{USERCONFIG Bitfields: ULONG [
fInheritAutoLogon set_fInheritAutoLogon[0..1],
fInheritResetBroken set_fInheritResetBroken[1..2],
fInheritReconnectSame set_fInheritReconnectSame[2..3],
fInheritInitialProgram set_fInheritInitialProgram[3..4],
fInheritCallback set_fInheritCallback[4..5],
fInheritCallbackNumber set_fInheritCallbackNumber[5..6],
fInheritShadow set_fInheritShadow[6..7],
fInheritMaxSessionTime set_fInheritMaxSessionTime[7..8],
fInheritMaxDisconnectionTime set_fInheritMaxDisconnectionTime[8..9],
fInheritMaxIdleTime set_fInheritMaxIdleTime[9..10],
fInheritAutoClient set_fInheritAutoClient[10..11],
fInheritSecurity set_fInheritSecurity[11..12],
fPromptForPassword set_fPromptForPassword[12..13],
fResetBroken set_fResetBroken[13..14],
fReconnectSame set_fReconnectSame[14..15],
fLogonDisabled set_fLogonDisabled[15..16],
fWallPaperDisabled set_fWallPaperDisabled[16..17],
fAutoClientDrives set_fAutoClientDrives[17..18],
fAutoClientLpts set_fAutoClientLpts[18..19],
fForceClientLptDef set_fForceClientLptDef[19..20],
fRequireEncryption set_fRequireEncryption[20..21],
fDisableEncryption set_fDisableEncryption[21..22],
fUnused1 set_fUnused1[22..23],
fHomeDirectoryMapRoot set_fHomeDirectoryMapRoot[23..24],
fUseDefaultGina set_fUseDefaultGina[24..25],
fCursorBlinkDisabled set_fCursorBlinkDisabled[25..26],
fPublishedApp set_fPublishedApp[26..27],
fHideTitleBar set_fHideTitleBar[27..28],
fMaximize set_fMaximize[28..29],
fDisableCpm set_fDisableCpm[29..30],
fDisableCdm set_fDisableCdm[30..31],
fDisableCcm set_fDisableCcm[31..32],
]}
BITFIELD!{USERCONFIG Bitfields2: ULONG [
fDisableLPT set_fDisableLPT[0..1],
fDisableClip set_fDisableClip[1..2],
fDisableExe set_fDisableExe[2..3],
fDisableCam set_fDisableCam[3..4],
fDisableAutoReconnect set_fDisableAutoReconnect[4..5],
ColorDepth set_ColorDepth[5..6],
fInheritColorDepth set_fInheritColorDepth[6..7],
fErrorInvalidProfile set_fErrorInvalidProfile[7..8],
fPasswordIsScPin set_fPasswordIsScPin[8..9],
fDisablePNPRedir set_fDisablePNPRedir[9..10],
]}
pub type PUSERCONFIG = *mut USERCONFIG;
ENUM!{enum SDCLASS {
SdNone = 0,
SdConsole = 1,
SdNetwork = 2,
SdAsync = 3,
SdOemTransport = 4,
}}
pub type DEVICENAME = [WCHAR; DEVICENAME_LENGTH + 1];
pub type MODEMNAME = [WCHAR; MODEMNAME_LENGTH + 1];
pub type NASISPECIFICNAME = [WCHAR; NASISPECIFICNAME_LENGTH + 1];
pub type NASIUSERNAME = [WCHAR; NASIUSERNAME_LENGTH + 1];
pub type NASIPASSWORD = [WCHAR; NASIPASSWORD_LENGTH + 1];
pub type NASISESIONNAME = [WCHAR; NASISESSIONNAME_LENGTH + 1];
pub type NASIFILESERVER = [WCHAR; NASIFILESERVER_LENGTH + 1];
pub type WDNAME = [WCHAR; WDNAME_LENGTH + 1];
pub type WDPREFIX = [WCHAR; WDPREFIX_LENGTH + 1];
pub type CDNAME = [WCHAR; CDNAME_LENGTH + 1];
pub type DLLNAME = [WCHAR; DLLNAME_LENGTH + 1];
pub type PDNAME = [WCHAR; PDNAME_LENGTH + 1];
STRUCT!{struct NETWORKCONFIG {
LanAdapter: LONG,
NetworkName: DEVICENAME,
Flags: ULONG,
}}
pub type PNETWORKCONFIG = *mut NETWORKCONFIG;
ENUM!{enum FLOWCONTROLCLASS {
FlowControl_None = 0,
FlowControl_Hardware = 1,
FlowControl_Software = 2,
}}
ENUM!{enum RECEIVEFLOWCONTROLCLASS {
ReceiveFlowControl_None = 0,
ReceiveFlowControl_RTS = 1,
ReceiveFlowControl_DTR = 2,
}}
ENUM!{enum TRANSMITFLOWCONTROLCLASS {
TransmitFlowControl_None = 0,
TransmitFlowControl_CTS = 1,
TransmitFlowControl_DSR = 2,
}}
ENUM!{enum ASYNCCONNECTCLASS {
Connect_CTS = 0,
Connect_DSR = 1,
Connect_RI = 2,
Connect_DCD = 3,
Connect_FirstChar = 4,
Connect_Perm = 5,
}}
STRUCT!{struct FLOWCONTROLCONFIG {
Bitfields: ULONG,
XonChar: CHAR,
XoffChar: CHAR,
Type: FLOWCONTROLCLASS,
HardwareReceive: RECEIVEFLOWCONTROLCLASS,
HardwareTransmit: TRANSMITFLOWCONTROLCLASS,
}}
BITFIELD!{FLOWCONTROLCONFIG Bitfields: ULONG [
fEnableSoftwareTx set_fEnableSoftwareTx[0..1],
fEnableSoftwareRx set_fEnableSoftwareRx[1..2],
fEnableDTR set_fEnableDTR[2..3],
fEnableRTS set_fEnableRTS[3..4],
]}
pub type PFLOWCONTROLCONFIG = *mut FLOWCONTROLCONFIG;
STRUCT!{struct CONNECTCONFIG {
Type: ASYNCCONNECTCLASS,
Bitfields: ULONG,
}}
BITFIELD!{CONNECTCONFIG Bitfields: ULONG [
fEnableBreakDisconnect set_fEnableBreakDisconnect[0..1],
]}
pub type PCONNECTCONFIG = *mut CONNECTCONFIG;
STRUCT!{struct ASYNCCONFIG {
DeviceName: DEVICENAME,
ModemName: MODEMNAME,
BaudRate: ULONG,
Parity: ULONG,
StopBits: ULONG,
ByteSize: ULONG,
Bitfields: ULONG,
FlowControl: FLOWCONTROLCONFIG,
Connect: CONNECTCONFIG,
}}
BITFIELD!{ASYNCCONFIG Bitfields: ULONG [
fEnableDsrSensitivity set_fEnableDsrSensitivity[0..1],
fConnectionDriver set_fConnectionDriver[1..2],
]}
pub type PASYNCCONFIG = *mut ASYNCCONFIG;
STRUCT!{struct NASICONFIG {
SpecificName: NASISPECIFICNAME,
UserName: NASIUSERNAME,
PassWord: NASIPASSWORD,
SessionName: NASISESIONNAME,
FileServer: NASIFILESERVER,
GlobalSession: BOOLEAN,
}}
pub type PNASICONFIG = *mut NASICONFIG;
STRUCT!{struct OEMTDCONFIG {
Adapter: LONG,
DeviceName: DEVICENAME,
Flags: ULONG,
}}
pub type POEMTDCONFIG = *mut OEMTDCONFIG;
UNION!{union PDPARAMS_u {
Network: NETWORKCONFIG,
Async: ASYNCCONFIG,
Nasi: NASICONFIG,
OemTd: OEMTDCONFIG,
}}
STRUCT!{struct PDPARAMS {
SdClass: SDCLASS,
u: PDPARAMS_u,
}}
pub type PPDPARAMS = *mut PDPARAMS;
STRUCT!{struct WDCONFIG {
WdName: WDNAME,
WdDLL: DLLNAME,
WsxDLL: DLLNAME,
WdFlag: ULONG,
WdInputBufferLength: ULONG,
CfgDLL: DLLNAME,
WdPrefix: WDPREFIX,
}}
pub type PWDCONFIG = *mut WDCONFIG;
STRUCT!{struct PDCONFIG2 {
PdName: PDNAME,
SdClass: SDCLASS,
PdDLL: DLLNAME,
PdFlag: ULONG,
OutBufLength: ULONG,
OutBufCount: ULONG,
OutBufDelay: ULONG,
InteractiveDelay: ULONG,
PortNumber: ULONG,
KeepAliveTimeout: ULONG,
}}
pub type PPDCONFIG2 = *mut PDCONFIG2;
STRUCT!{struct WINSTATIONCLIENT {
Bitfields: ULONG,
ClientName: [WCHAR; CLIENTNAME_LENGTH + 1],
Domain: [WCHAR; DOMAIN_LENGTH + 1],
UserName: [WCHAR; USERNAME_LENGTH + 1],
Password: [WCHAR; PASSWORD_LENGTH + 1],
WorkDirectory: [WCHAR; DIRECTORY_LENGTH + 1],
InitialProgram: [WCHAR; INITIALPROGRAM_LENGTH + 1],
SerialNumber: ULONG,
EncryptionLevel: BYTE,
ClientAddressFamily: ULONG,
ClientAddress: [WCHAR; CLIENTADDRESS_LENGTH + 1],
HRes: USHORT,
VRes: USHORT,
ColorDepth: USHORT,
ProtocolType: USHORT,
KeyboardLayout: ULONG,
KeyboardType: ULONG,
KeyboardSubType: ULONG,
KeyboardFunctionKey: ULONG,
ImeFileName: [WCHAR; IMEFILENAME_LENGTH + 1],
ClientDirectory: [WCHAR; DIRECTORY_LENGTH + 1],
ClientLicense: [WCHAR; CLIENTLICENSE_LENGTH + 1],
ClientModem: [WCHAR; CLIENTMODEM_LENGTH + 1],
ClientBuildNumber: ULONG,
ClientHardwareId: ULONG,
ClientProductId: USHORT,
OutBufCountHost: USHORT,
OutBufCountClient: USHORT,
OutBufLength: USHORT,
AudioDriverName: [WCHAR; 9],
ClientTimeZone: TS_TIME_ZONE_INFORMATION,
ClientSessionId: ULONG,
ClientDigProductId: [WCHAR; CLIENT_PRODUCT_ID_LENGTH],
PerformanceFlags: ULONG,
ActiveInputLocale: ULONG,
}}
BITFIELD!{WINSTATIONCLIENT Bitfields: ULONG [
fTextOnly set_fTextOnly[0..1],
fDisableCtrlAltDel set_fDisableCtrlAltDel[1..2],
fMouse set_fMouse[2..3],
fDoubleClickDetect set_fDoubleClickDetect[3..4],
fINetClient set_fINetClient[4..5],
fPromptForPassword set_fPromptForPassword[5..6],
fMaximizeShell set_fMaximizeShell[6..7],
fEnableWindowsKey set_fEnableWindowsKey[7..8],
fRemoteConsoleAudio set_fRemoteConsoleAudio[8..9],
fPasswordIsScPin set_fPasswordIsScPin[9..10],
fNoAudioPlayback set_fNoAudioPlayback[10..11],
fUsingSavedCreds set_fUsingSavedCreds[11..12],
]}
pub type PWINSTATIONCLIENT = *mut WINSTATIONCLIENT;
STRUCT!{struct TSHARE_COUNTERS {
Reserved: ULONG,
}}
pub type PTSHARE_COUNTERS = *mut TSHARE_COUNTERS;
UNION!{union PROTOCOLCOUNTERS_Specific {
TShareCounters: TSHARE_COUNTERS,
Reserved: [ULONG; 100],
}}
STRUCT!{struct PROTOCOLCOUNTERS {
WdBytes: ULONG,
WdFrames: ULONG,
WaitForOutBuf: ULONG,
Frames: ULONG,
Bytes: ULONG,
CompressedBytes: ULONG,
CompressFlushes: ULONG,
Errors: ULONG,
Timeouts: ULONG,
AsyncFramingError: ULONG,
AsyncOverrunError: ULONG,
AsyncOverflowError: ULONG,
AsyncParityError: ULONG,
TdErrors: ULONG,
ProtocolType: USHORT,
Length: USHORT,
Specific: PROTOCOLCOUNTERS_Specific,
}}
pub type PPROTOCOLCOUNTERS = *mut PROTOCOLCOUNTERS;
STRUCT!{struct THINWIRECACHE {
CacheReads: ULONG,
CacheHits: ULONG,
}}
pub type PTHINWIRECACHE = *mut THINWIRECACHE;
pub const MAX_THINWIRECACHE: usize = 4;
STRUCT!{struct RESERVED_CACHE {
ThinWireCache: [THINWIRECACHE; MAX_THINWIRECACHE],
}}
pub type PRESERVED_CACHE = *mut RESERVED_CACHE;
STRUCT!{struct TSHARE_CACHE {
Reserved: ULONG,
}}
pub type PTSHARE_CACHE = *mut TSHARE_CACHE;
UNION!{union CACHE_STATISTICS_Specific {
ReservedCacheStats: RESERVED_CACHE,
TShareCacheStats: TSHARE_CACHE,
Reserved: [ULONG; 20],
}}
STRUCT!{struct CACHE_STATISTICS {
ProtocolType: USHORT,
Length: USHORT,
Specific: CACHE_STATISTICS_Specific,
}}
pub type PCACHE_STATISTICS = *mut CACHE_STATISTICS;
STRUCT!{struct PROTOCOLSTATUS {
Output: PROTOCOLCOUNTERS,
Input: PROTOCOLCOUNTERS,
Cache: CACHE_STATISTICS,
AsyncSignal: ULONG,
AsyncSignalMask: ULONG,
}}
pub type PPROTOCOLSTATUS = *mut PROTOCOLSTATUS;
STRUCT!{struct WINSTATIONINFORMATION {
ConnectState: WINSTATIONSTATECLASS,
WinStationName: WINSTATIONNAME,
LogonId: ULONG,
ConnectTime: LARGE_INTEGER,
DisconnectTime: LARGE_INTEGER,
LastInputTime: LARGE_INTEGER,
LogonTime: LARGE_INTEGER,
Status: PROTOCOLSTATUS,
Domain: [WCHAR; DOMAIN_LENGTH + 1],
UserName: [WCHAR; USERNAME_LENGTH + 1],
CurrentTime: LARGE_INTEGER,
}}
pub type PWINSTATIONINFORMATION = *mut WINSTATIONINFORMATION;
STRUCT!{struct WINSTATIONUSERTOKEN {
ProcessId: HANDLE,
ThreadId: HANDLE,
UserToken: HANDLE,
}}
pub type PWINSTATIONUSERTOKEN = *mut WINSTATIONUSERTOKEN;
STRUCT!{struct WINSTATIONVIDEODATA {
HResolution: USHORT,
VResolution: USHORT,
fColorDepth: USHORT,
}}
pub type PWINSTATIONVIDEODATA = *mut WINSTATIONVIDEODATA;
ENUM!{enum CDCLASS {
CdNone = 0,
CdModem = 1,
CdClass_Maximum = 2,
}}
STRUCT!{struct CDCONFIG {
CdClass: CDCLASS,
CdName: CDNAME,
CdDLL: DLLNAME,
CdFlag: ULONG,
}}
pub type PCDCONFIG = *mut CDCONFIG;
pub type CLIENTDATANAME = [CHAR; CLIENTDATANAME_LENGTH + 1];
pub type PCLIENTDATANAME = *mut CHAR;
STRUCT!{struct WINSTATIONCLIENTDATA {
DataName: CLIENTDATANAME,
fUnicodeData: BOOLEAN,
}}
pub type PWINSTATIONCLIENTDATA = *mut WINSTATIONCLIENTDATA;
ENUM!{enum LOADFACTORTYPE {
ErrorConstraint = 0,
PagedPoolConstraint = 1,
NonPagedPoolConstraint = 2,
AvailablePagesConstraint = 3,
SystemPtesConstraint = 4,
CPUConstraint = 5,
}}
STRUCT!{struct WINSTATIONLOADINDICATORDATA {
RemainingSessionCapacity: ULONG,
LoadFactor: LOADFACTORTYPE,
TotalSessions: ULONG,
DisconnectedSessions: ULONG,
IdleCPU: LARGE_INTEGER,
TotalCPU: LARGE_INTEGER,
RawSessionCapacity: ULONG,
reserved: [ULONG; 9],
}}
pub type PWINSTATIONLOADINDICATORDATA = *mut WINSTATIONLOADINDICATORDATA;
ENUM!{enum SHADOWSTATECLASS {
State_NoShadow = 0,
State_Shadowing = 1,
State_Shadowed = 2,
}}
STRUCT!{struct WINSTATIONSHADOW {
ShadowState: SHADOWSTATECLASS,
ShadowClass: SHADOWCLASS,
SessionId: ULONG,
ProtocolType: ULONG,
}}
pub type PWINSTATIONSHADOW = *mut WINSTATIONSHADOW;
STRUCT!{struct WINSTATIONPRODID {
DigProductId: [WCHAR; CLIENT_PRODUCT_ID_LENGTH],
ClientDigProductId: [WCHAR; CLIENT_PRODUCT_ID_LENGTH],
OuterMostDigProductId: [WCHAR; CLIENT_PRODUCT_ID_LENGTH],
CurrentSessionId: ULONG,
ClientSessionId: ULONG,
OuterMostSessionId: ULONG,
}}
pub type PWINSTATIONPRODID = *mut WINSTATIONPRODID;
STRUCT!{struct WINSTATIONREMOTEADDRESS_u_ipv4 {
sin_port: USHORT,
sin_addr: ULONG,
sin_zero: [UCHAR; 8],
}}
STRUCT!{struct WINSTATIONREMOTEADDRESS_u_ipv6 {
sin6_port: USHORT,
sin6_flowinfo: ULONG,
sin6_addr: [USHORT; 8],
sin6_scope_id: ULONG,
}}
UNION!{union WINSTATIONREMOTEADDRESS_u {
ipv4: WINSTATIONREMOTEADDRESS_u_ipv4,
ipv6: WINSTATIONREMOTEADDRESS_u_ipv6,
}}
STRUCT!{struct WINSTATIONREMOTEADDRESS {
sin_family: USHORT,
u: WINSTATIONREMOTEADDRESS_u,
}}
pub type PWINSTATIONREMOTEADDRESS = *mut WINSTATIONREMOTEADDRESS;
STRUCT!{struct WINSTATIONINFORMATIONEX_LEVEL1 {
SessionId: ULONG,
SessionState: WINSTATIONSTATECLASS,
SessionFlags: LONG,
WinStationName: WINSTATIONNAME,
UserName: [WCHAR; USERNAME_LENGTH + 1],
DomainName: [WCHAR; DOMAIN_LENGTH + 1],
LogonTime: LARGE_INTEGER,
ConnectTime: LARGE_INTEGER,
DisconnectTime: LARGE_INTEGER,
LastInputTime: LARGE_INTEGER,
CurrentTime: LARGE_INTEGER,
ProtocolStatus: PROTOCOLSTATUS,
}}
pub type PWINSTATIONINFORMATIONEX_LEVEL1 = *mut WINSTATIONINFORMATIONEX_LEVEL1;
STRUCT!{struct WINSTATIONINFORMATIONEX_LEVEL2 {
SessionId: ULONG,
SessionState: WINSTATIONSTATECLASS,
SessionFlags: LONG,
WinStationName: WINSTATIONNAME,
SamCompatibleUserName: [WCHAR; USERNAME_LENGTH + 1],
SamCompatibleDomainName: [WCHAR; DOMAIN_LENGTH + 1],
LogonTime: LARGE_INTEGER,
ConnectTime: LARGE_INTEGER,
DisconnectTime: LARGE_INTEGER,
LastInputTime: LARGE_INTEGER,
CurrentTime: LARGE_INTEGER,
ProtocolStatus: PROTOCOLSTATUS,
UserName: [WCHAR; 257],
DomainName: [WCHAR; 256],
}}
pub type PWINSTATIONINFORMATIONEX_LEVEL2 = *mut WINSTATIONINFORMATIONEX_LEVEL2;
UNION!{union WINSTATIONINFORMATIONEX_LEVEL {
WinStationInfoExLevel1: WINSTATIONINFORMATIONEX_LEVEL1,
WinStationInfoExLevel2: WINSTATIONINFORMATIONEX_LEVEL2,
}}
pub type PWINSTATIONINFORMATIONEX_LEVEL = *mut WINSTATIONINFORMATIONEX_LEVEL;
STRUCT!{struct WINSTATIONINFORMATIONEX {
Level: ULONG,
Data: WINSTATIONINFORMATIONEX_LEVEL,
}}
pub type PWINSTATIONINFORMATIONEX = *mut WINSTATIONINFORMATIONEX;
pub const TS_PROCESS_INFO_MAGIC_NT4: u32 = 0x23495452;
STRUCT!{struct TS_PROCESS_INFORMATION_NT4 {
MagicNumber: ULONG,
LogonId: ULONG,
ProcessSid: PVOID,
Pad: ULONG,
}}
pub type PTS_PROCESS_INFORMATION_NT4 = *mut TS_PROCESS_INFORMATION_NT4;
pub const SIZEOF_TS4_SYSTEM_THREAD_INFORMATION: u32 = 64;
pub const SIZEOF_TS4_SYSTEM_PROCESS_INFORMATION: u32 = 136;
STRUCT!{struct TS_SYS_PROCESS_INFORMATION {
NextEntryOffset: ULONG,
NumberOfThreads: ULONG,
SpareLi1: LARGE_INTEGER,
SpareLi2: LARGE_INTEGER,
SpareLi3: LARGE_INTEGER,
CreateTime: LARGE_INTEGER,
UserTime: LARGE_INTEGER,
KernelTime: LARGE_INTEGER,
ImageName: UNICODE_STRING,
BasePriority: LONG,
UniqueProcessId: ULONG,
InheritedFromUniqueProcessId: ULONG,
HandleCount: ULONG,
SessionId: ULONG,
SpareUl3: ULONG,
PeakVirtualSize: SIZE_T,
VirtualSize: SIZE_T,
PageFaultCount: ULONG,
PeakWorkingSetSize: ULONG,
WorkingSetSize: ULONG,
QuotaPeakPagedPoolUsage: SIZE_T,
QuotaPagedPoolUsage: SIZE_T,
QuotaPeakNonPagedPoolUsage: SIZE_T,
QuotaNonPagedPoolUsage: SIZE_T,
PagefileUsage: SIZE_T,
PeakPagefileUsage: SIZE_T,
PrivatePageCount: SIZE_T,
}}
pub type PTS_SYS_PROCESS_INFORMATION = *mut TS_SYS_PROCESS_INFORMATION;
STRUCT!{struct TS_ALL_PROCESSES_INFO {
pTsProcessInfo: PTS_SYS_PROCESS_INFORMATION,
SizeOfSid: ULONG,
pSid: PSID,
}}
pub type PTS_ALL_PROCESSES_INFO = *mut TS_ALL_PROCESSES_INFO;
STRUCT!{struct TS_COUNTER_HEADER {
dwCounterID: DWORD,
bResult: BOOLEAN,
}}
pub type PTS_COUNTER_HEADER = *mut TS_COUNTER_HEADER;
STRUCT!{struct TS_COUNTER {
CounterHead: TS_COUNTER_HEADER,
dwValue: DWORD,
StartTime: LARGE_INTEGER,
}}
pub type PTS_COUNTER = *mut TS_COUNTER;
pub const WSD_LOGOFF: ULONG = 0x1;
pub const WSD_SHUTDOWN: ULONG = 0x2;
pub const WSD_REBOOT: ULONG = 0x4;
pub const WSD_POWEROFF: ULONG = 0x8;
pub const WEVENT_NONE: ULONG = 0x0;
pub const WEVENT_CREATE: ULONG = 0x1;
pub const WEVENT_DELETE: ULONG = 0x2;
pub const WEVENT_RENAME: ULONG = 0x4;
pub const WEVENT_CONNECT: ULONG = 0x8;
pub const WEVENT_DISCONNECT: ULONG = 0x10;
pub const WEVENT_LOGON: ULONG = 0x20;
pub const WEVENT_LOGOFF: ULONG = 0x40;
pub const WEVENT_STATECHANGE: ULONG = 0x80;
pub const WEVENT_LICENSE: ULONG = 0x100;
pub const WEVENT_ALL: ULONG = 0x7fffffff;
pub const WEVENT_FLUSH: ULONG = 0x80000000;
pub const KBDSHIFT: USHORT = 0x1;
pub const KBDCTRL: USHORT = 0x2;
pub const KBDALT: USHORT = 0x4;
pub const WNOTIFY_ALL_SESSIONS: ULONG = 0x1;
pub const LOGONID_CURRENT: i32 = -1;
pub const SERVERNAME_CURRENT: PWSTR = null_mut();
EXTERN!{extern "system" {
fn WinStationFreeMemory(
Buffer: PVOID,
) -> BOOLEAN;
fn WinStationOpenServerW(
ServerName: PWSTR,
) -> HANDLE;
fn WinStationCloseServer(
ServerHandle: HANDLE,
) -> BOOLEAN;
fn WinStationServerPing(
ServerHandle: HANDLE,
) -> BOOLEAN;
fn WinStationGetTermSrvCountersValue(
ServerHandle: HANDLE,
Count: ULONG,
Counters: PTS_COUNTER,
) -> BOOLEAN;
fn WinStationShutdownSystem(
ServerHandle: HANDLE,
ShutdownFlags: ULONG,
) -> BOOLEAN;
fn WinStationWaitSystemEvent(
ServerHandle: HANDLE,
EventMask: ULONG,
EventFlags: PULONG,
) -> BOOLEAN;
fn WinStationRegisterConsoleNotification(
ServerHandle: HANDLE,
WindowHandle: HWND,
Flags: ULONG,
) -> BOOLEAN;
fn WinStationUnRegisterConsoleNotification(
ServerHandle: HANDLE,
WindowHandle: HWND,
) -> BOOLEAN;
fn WinStationEnumerateW(
ServerHandle: HANDLE,
SessionIds: *mut PSESSIONIDW,
Count: PULONG,
) -> BOOLEAN;
fn WinStationQueryInformationW(
ServerHandle: HANDLE,
SessionId: ULONG,
WinStationInformationClass: WINSTATIONINFOCLASS,
pWinStationInformation: PVOID,
WinStationInformationLength: ULONG,
pReturnLength: PULONG,
) -> BOOLEAN;
fn WinStationSetInformationW(
ServerHandle: HANDLE,
SessionId: ULONG,
WinStationInformationClass: WINSTATIONINFOCLASS,
pWinStationInformation: PVOID,
WinStationInformationLength: ULONG,
) -> BOOLEAN;
fn WinStationNameFromLogonIdW(
ServerHandle: HANDLE,
SessionId: ULONG,
pWinStationName: PWSTR,
) -> BOOLEAN;
fn WinStationSendMessageW(
ServerHandle: HANDLE,
SessionId: ULONG,
Title: PWSTR,
TitleLength: ULONG,
Message: PWSTR,
MessageLength: ULONG,
Style: ULONG,
Timeout: ULONG,
Response: PULONG,
DoNotWait: BOOLEAN,
) -> BOOLEAN;
fn WinStationConnectW(
ServerHandle: HANDLE,
SessionId: ULONG,
TargetSessionId: ULONG,
pPassword: PWSTR,
bWait: BOOLEAN,
) -> BOOLEAN;
fn WinStationDisconnect(
ServerHandle: HANDLE,
SessionId: ULONG,
bWait: BOOLEAN,
) -> BOOLEAN;
fn WinStationReset(
ServerHandle: HANDLE,
SessionId: ULONG,
bWait: BOOLEAN,
) -> BOOLEAN;
fn WinStationShadow(
ServerHandle: HANDLE,
TargetServerName: PWSTR,
TargetSessionId: ULONG,
HotKeyVk: UCHAR,
HotkeyModifiers: USHORT,
) -> BOOLEAN;
fn WinStationShadowStop(
ServerHandle: HANDLE,
SessionId: ULONG,
bWait: BOOLEAN,
) -> BOOLEAN;
fn WinStationEnumerateProcesses(
ServerHandle: HANDLE,
Processes: *mut PVOID,
) -> BOOLEAN;
fn WinStationGetAllProcesses(
ServerHandle: HANDLE,
Level: ULONG,
NumberOfProcesses: PULONG,
Processes: *mut PTS_ALL_PROCESSES_INFO,
) -> BOOLEAN;
fn WinStationFreeGAPMemory(
Level: ULONG,
Processes: PTS_ALL_PROCESSES_INFO,
NumberOfProcesses: ULONG,
) -> BOOLEAN;
fn WinStationTerminateProcess(
ServerHandle: HANDLE,
ProcessId: ULONG,
ExitCode: ULONG,
) -> BOOLEAN;
fn WinStationGetProcessSid(
ServerHandle: HANDLE,
ProcessId: ULONG,
ProcessStartTime: FILETIME,
pProcessUserSid: PVOID,
dwSidSize: PULONG,
) -> BOOLEAN;
fn WinStationSwitchToServicesSession() -> BOOLEAN;
fn WinStationRevertFromServicesSession() -> BOOLEAN;
fn _WinStationWaitForConnect() -> BOOLEAN;
}}
|