-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWin32Native.cs
1318 lines (854 loc) · 42.8 KB
/
Win32Native.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
#region Assembly mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\mscorlib.dll
// Decompiled with ICSharpCode.Decompiler 6.1.0.5902
#endregion
using Microsoft.Win32.SafeHandles;
using Microsoft.Win32.SafeHandles.Extracted;
using System;
using System.IO;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Principal;
using System.Text;
using System.Threading;
namespace Microsoft.Win32.Extracted
{
[SecurityCritical]
[SuppressUnmanagedCodeSecurity]
internal static class Win32Native
{
internal struct SystemTime
{
[MarshalAs(UnmanagedType.U2)]
public short Year;
[MarshalAs(UnmanagedType.U2)]
public short Month;
[MarshalAs(UnmanagedType.U2)]
public short DayOfWeek;
[MarshalAs(UnmanagedType.U2)]
public short Day;
[MarshalAs(UnmanagedType.U2)]
public short Hour;
[MarshalAs(UnmanagedType.U2)]
public short Minute;
[MarshalAs(UnmanagedType.U2)]
public short Second;
[MarshalAs(UnmanagedType.U2)]
public short Milliseconds;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
internal struct TimeZoneInformation
{
[MarshalAs(UnmanagedType.I4)]
public int Bias;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public string StandardName;
public SystemTime StandardDate;
[MarshalAs(UnmanagedType.I4)]
public int StandardBias;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public string DaylightName;
public SystemTime DaylightDate;
[MarshalAs(UnmanagedType.I4)]
public int DaylightBias;
public TimeZoneInformation(DynamicTimeZoneInformation dtzi)
{
Bias = dtzi.Bias;
StandardName = dtzi.StandardName;
StandardDate = dtzi.StandardDate;
StandardBias = dtzi.StandardBias;
DaylightName = dtzi.DaylightName;
DaylightDate = dtzi.DaylightDate;
DaylightBias = dtzi.DaylightBias;
}
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
internal struct DynamicTimeZoneInformation
{
[MarshalAs(UnmanagedType.I4)]
public int Bias;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public string StandardName;
public SystemTime StandardDate;
[MarshalAs(UnmanagedType.I4)]
public int StandardBias;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public string DaylightName;
public SystemTime DaylightDate;
[MarshalAs(UnmanagedType.I4)]
public int DaylightBias;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
public string TimeZoneKeyName;
[MarshalAs(UnmanagedType.Bool)]
public bool DynamicDaylightTimeDisabled;
}
internal struct RegistryTimeZoneInformation
{
[MarshalAs(UnmanagedType.I4)]
public int Bias;
[MarshalAs(UnmanagedType.I4)]
public int StandardBias;
[MarshalAs(UnmanagedType.I4)]
public int DaylightBias;
public SystemTime StandardDate;
public SystemTime DaylightDate;
public RegistryTimeZoneInformation(TimeZoneInformation tzi)
{
Bias = tzi.Bias;
StandardDate = tzi.StandardDate;
StandardBias = tzi.StandardBias;
DaylightDate = tzi.DaylightDate;
DaylightBias = tzi.DaylightBias;
}
public RegistryTimeZoneInformation(byte[] bytes)
{
if (bytes == null || bytes.Length != 44)
{
throw new ArgumentException(nameof(bytes)); // Environment.GetResourceString("Argument_InvalidREG_TZI_FORMAT"), "bytes");
}
Bias = BitConverter.ToInt32(bytes, 0);
StandardBias = BitConverter.ToInt32(bytes, 4);
DaylightBias = BitConverter.ToInt32(bytes, 8);
StandardDate.Year = BitConverter.ToInt16(bytes, 12);
StandardDate.Month = BitConverter.ToInt16(bytes, 14);
StandardDate.DayOfWeek = BitConverter.ToInt16(bytes, 16);
StandardDate.Day = BitConverter.ToInt16(bytes, 18);
StandardDate.Hour = BitConverter.ToInt16(bytes, 20);
StandardDate.Minute = BitConverter.ToInt16(bytes, 22);
StandardDate.Second = BitConverter.ToInt16(bytes, 24);
StandardDate.Milliseconds = BitConverter.ToInt16(bytes, 26);
DaylightDate.Year = BitConverter.ToInt16(bytes, 28);
DaylightDate.Month = BitConverter.ToInt16(bytes, 30);
DaylightDate.DayOfWeek = BitConverter.ToInt16(bytes, 32);
DaylightDate.Day = BitConverter.ToInt16(bytes, 34);
DaylightDate.Hour = BitConverter.ToInt16(bytes, 36);
DaylightDate.Minute = BitConverter.ToInt16(bytes, 38);
DaylightDate.Second = BitConverter.ToInt16(bytes, 40);
DaylightDate.Milliseconds = BitConverter.ToInt16(bytes, 42);
}
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
internal class OSVERSIONINFO
{
internal int OSVersionInfoSize;
internal int MajorVersion;
internal int MinorVersion;
internal int BuildNumber;
internal int PlatformId;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
internal string CSDVersion;
internal OSVERSIONINFO()
{
OSVersionInfoSize = Marshal.SizeOf(this);
}
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
internal class OSVERSIONINFOEX
{
internal int OSVersionInfoSize;
internal int MajorVersion;
internal int MinorVersion;
internal int BuildNumber;
internal int PlatformId;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
internal string CSDVersion;
internal ushort ServicePackMajor;
internal ushort ServicePackMinor;
internal short SuiteMask;
internal byte ProductType;
internal byte Reserved;
public OSVERSIONINFOEX()
{
OSVersionInfoSize = Marshal.SizeOf(this);
}
}
internal struct SYSTEM_INFO
{
internal ushort wProcessorArchitecture;
internal ushort wReserved;
internal int dwPageSize;
internal IntPtr lpMinimumApplicationAddress;
internal IntPtr lpMaximumApplicationAddress;
internal IntPtr dwActiveProcessorMask;
internal int dwNumberOfProcessors;
internal int dwProcessorType;
internal int dwAllocationGranularity;
internal short wProcessorLevel;
internal short wProcessorRevision;
}
[StructLayout(LayoutKind.Sequential)]
internal class SECURITY_ATTRIBUTES
{
internal int nLength;
internal unsafe byte* pSecurityDescriptor = null;
internal int bInheritHandle;
}
[Serializable]
internal struct WIN32_FILE_ATTRIBUTE_DATA
{
internal int fileAttributes;
internal FILE_TIME ftCreationTime;
internal FILE_TIME ftLastAccessTime;
internal FILE_TIME ftLastWriteTime;
internal int fileSizeHigh;
internal int fileSizeLow;
[SecurityCritical]
internal void PopulateFrom(ref WIN32_FIND_DATA findData)
{
fileAttributes = findData.dwFileAttributes;
ftCreationTime = findData.ftCreationTime;
ftLastAccessTime = findData.ftLastAccessTime;
ftLastWriteTime = findData.ftLastWriteTime;
fileSizeHigh = findData.nFileSizeHigh;
fileSizeLow = findData.nFileSizeLow;
}
}
internal struct FILE_TIME
{
internal uint ftTimeLow;
internal uint ftTimeHigh;
public FILE_TIME(long fileTime)
{
ftTimeLow = (uint)fileTime;
ftTimeHigh = (uint)(fileTime >> 32);
}
public long ToTicks()
{
return (long)(((ulong)ftTimeHigh << 32) + ftTimeLow);
}
}
[Serializable]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
[BestFitMapping(false)]
internal struct WIN32_FIND_DATA
{
internal int dwFileAttributes;
internal FILE_TIME ftCreationTime;
internal FILE_TIME ftLastAccessTime;
internal FILE_TIME ftLastWriteTime;
internal int nFileSizeHigh;
internal int nFileSizeLow;
internal int dwReserved0;
internal int dwReserved1;
private unsafe fixed char _cFileName[260];
private unsafe fixed char _cAlternateFileName[14];
internal unsafe string cFileName
{
get
{
fixed (char* value = _cFileName)
{
return new string(value);
}
}
}
internal unsafe bool IsRelativeDirectory
{
get
{
fixed (char* ptr = _cFileName)
{
char c = *ptr;
if (c != '.')
{
return false;
}
switch (ptr[1])
{
case '.':
return ptr[2] == '\0';
default:
return false;
case '\0':
return true;
}
}
}
}
internal bool IsFile => (dwFileAttributes & 0x10) == 0;
internal bool IsNormalDirectory
{
get
{
if ((dwFileAttributes & 0x10) != 0)
{
return !IsRelativeDirectory;
}
return false;
}
}
}
internal delegate bool ConsoleCtrlHandlerRoutine(int controlType);
internal struct COORD
{
internal short X;
internal short Y;
}
internal struct SMALL_RECT
{
internal short Left;
internal short Top;
internal short Right;
internal short Bottom;
}
internal struct CONSOLE_SCREEN_BUFFER_INFO
{
internal COORD dwSize;
internal COORD dwCursorPosition;
internal short wAttributes;
internal SMALL_RECT srWindow;
internal COORD dwMaximumWindowSize;
}
internal struct CONSOLE_CURSOR_INFO
{
internal int dwSize;
internal bool bVisible;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
internal struct KeyEventRecord
{
internal bool keyDown;
internal short repeatCount;
internal short virtualKeyCode;
internal short virtualScanCode;
internal char uChar;
internal int controlKeyState;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
internal struct InputRecord
{
internal short eventType;
internal KeyEventRecord keyEvent;
}
[Serializable]
[Flags]
internal enum Color : short
{
Black = 0x0,
ForegroundBlue = 0x1,
ForegroundGreen = 0x2,
ForegroundRed = 0x4,
ForegroundYellow = 0x6,
ForegroundIntensity = 0x8,
BackgroundBlue = 0x10,
BackgroundGreen = 0x20,
BackgroundRed = 0x40,
BackgroundYellow = 0x60,
BackgroundIntensity = 0x80,
ForegroundMask = 0xF,
BackgroundMask = 0xF0,
ColorMask = 0xFF
}
internal struct CHAR_INFO
{
private ushort charData;
private short attributes;
}
[StructLayout(LayoutKind.Sequential)]
internal class USEROBJECTFLAGS
{
internal int fInherit;
internal int fReserved;
internal int dwFlags;
}
internal enum SECURITY_IMPERSONATION_LEVEL
{
Anonymous,
Identification,
Impersonation,
Delegation
}
[StructLayout(LayoutKind.Explicit)]
internal struct CLAIM_SECURITY_ATTRIBUTE_INFORMATION_V1
{
[FieldOffset(0)]
public IntPtr pAttributeV1;
}
internal struct CLAIM_SECURITY_ATTRIBUTES_INFORMATION
{
public ushort Version;
public ushort Reserved;
public uint AttributeCount;
public CLAIM_SECURITY_ATTRIBUTE_INFORMATION_V1 Attribute;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
internal struct CLAIM_SECURITY_ATTRIBUTE_FQBN_VALUE
{
public ulong Version;
[MarshalAs(UnmanagedType.LPWStr)]
public string Name;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
internal struct CLAIM_SECURITY_ATTRIBUTE_OCTET_STRING_VALUE
{
public IntPtr pValue;
public uint ValueLength;
}
[StructLayout(LayoutKind.Explicit, CharSet = CharSet.Unicode)]
internal struct CLAIM_VALUES_ATTRIBUTE_V1
{
[FieldOffset(0)]
public IntPtr pInt64;
[FieldOffset(0)]
public IntPtr pUint64;
[FieldOffset(0)]
public IntPtr ppString;
[FieldOffset(0)]
public IntPtr pFqbn;
[FieldOffset(0)]
public IntPtr pOctetString;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
internal struct CLAIM_SECURITY_ATTRIBUTE_V1
{
[MarshalAs(UnmanagedType.LPWStr)]
public string Name;
public ushort ValueType;
public ushort Reserved;
public uint Flags;
public uint ValueCount;
public CLAIM_VALUES_ATTRIBUTE_V1 Values;
}
internal struct RTL_OSVERSIONINFOEX
{
internal uint dwOSVersionInfoSize;
internal uint dwMajorVersion;
internal uint dwMinorVersion;
internal uint dwBuildNumber;
internal uint dwPlatformId;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
internal string szCSDVersion;
}
internal enum ProcessorArchitecture : ushort
{
Processor_Architecture_INTEL = 0,
Processor_Architecture_ARM = 5,
Processor_Architecture_IA64 = 6,
Processor_Architecture_AMD64 = 9,
Processor_Architecture_ARM64 = 12,
Processor_Architecture_UNKNOWN = ushort.MaxValue
}
internal const int KEY_QUERY_VALUE = 1;
internal const int KEY_SET_VALUE = 2;
internal const int KEY_CREATE_SUB_KEY = 4;
internal const int KEY_ENUMERATE_SUB_KEYS = 8;
internal const int KEY_NOTIFY = 16;
internal const int KEY_CREATE_LINK = 32;
internal const int KEY_READ = 131097;
internal const int KEY_WRITE = 131078;
internal const int KEY_WOW64_64KEY = 256;
internal const int KEY_WOW64_32KEY = 512;
internal const int REG_OPTION_NON_VOLATILE = 0;
internal const int REG_OPTION_VOLATILE = 1;
internal const int REG_OPTION_CREATE_LINK = 2;
internal const int REG_OPTION_BACKUP_RESTORE = 4;
internal const int REG_NONE = 0;
internal const int REG_SZ = 1;
internal const int REG_EXPAND_SZ = 2;
internal const int REG_BINARY = 3;
internal const int REG_DWORD = 4;
internal const int REG_DWORD_LITTLE_ENDIAN = 4;
internal const int REG_DWORD_BIG_ENDIAN = 5;
internal const int REG_LINK = 6;
internal const int REG_MULTI_SZ = 7;
internal const int REG_RESOURCE_LIST = 8;
internal const int REG_FULL_RESOURCE_DESCRIPTOR = 9;
internal const int REG_RESOURCE_REQUIREMENTS_LIST = 10;
internal const int REG_QWORD = 11;
internal const int HWND_BROADCAST = 65535;
internal const int WM_SETTINGCHANGE = 26;
internal const uint CRYPTPROTECTMEMORY_BLOCK_SIZE = 16u;
internal const uint CRYPTPROTECTMEMORY_SAME_PROCESS = 0u;
internal const uint CRYPTPROTECTMEMORY_CROSS_PROCESS = 1u;
internal const uint CRYPTPROTECTMEMORY_SAME_LOGON = 2u;
internal const int SECURITY_ANONYMOUS = 0;
internal const int SECURITY_SQOS_PRESENT = 1048576;
internal const string MICROSOFT_KERBEROS_NAME = "Kerberos";
internal const uint ANONYMOUS_LOGON_LUID = 998u;
internal const int SECURITY_ANONYMOUS_LOGON_RID = 7;
internal const int SECURITY_AUTHENTICATED_USER_RID = 11;
internal const int SECURITY_LOCAL_SYSTEM_RID = 18;
internal const int SECURITY_BUILTIN_DOMAIN_RID = 32;
internal const uint SE_PRIVILEGE_DISABLED = 0u;
internal const uint SE_PRIVILEGE_ENABLED_BY_DEFAULT = 1u;
internal const uint SE_PRIVILEGE_ENABLED = 2u;
internal const uint SE_PRIVILEGE_USED_FOR_ACCESS = 2147483648u;
internal const uint SE_GROUP_MANDATORY = 1u;
internal const uint SE_GROUP_ENABLED_BY_DEFAULT = 2u;
internal const uint SE_GROUP_ENABLED = 4u;
internal const uint SE_GROUP_OWNER = 8u;
internal const uint SE_GROUP_USE_FOR_DENY_ONLY = 16u;
internal const uint SE_GROUP_LOGON_ID = 3221225472u;
internal const uint SE_GROUP_RESOURCE = 536870912u;
internal const uint DUPLICATE_CLOSE_SOURCE = 1u;
internal const uint DUPLICATE_SAME_ACCESS = 2u;
internal const uint DUPLICATE_SAME_ATTRIBUTES = 4u;
internal const int TIME_ZONE_ID_INVALID = -1;
internal const int TIME_ZONE_ID_UNKNOWN = 0;
internal const int TIME_ZONE_ID_STANDARD = 1;
internal const int TIME_ZONE_ID_DAYLIGHT = 2;
internal const int MAX_PATH = 260;
internal const int MUI_LANGUAGE_ID = 4;
internal const int MUI_LANGUAGE_NAME = 8;
internal const int MUI_PREFERRED_UI_LANGUAGES = 16;
internal const int MUI_INSTALLED_LANGUAGES = 32;
internal const int MUI_ALL_LANGUAGES = 64;
internal const int MUI_LANG_NEUTRAL_PE_FILE = 256;
internal const int MUI_NON_LANG_NEUTRAL_FILE = 512;
internal const int LOAD_LIBRARY_AS_DATAFILE = 2;
internal const int LOAD_STRING_MAX_LENGTH = 500;
internal const int READ_CONTROL = 131072;
internal const int SYNCHRONIZE = 1048576;
internal const int STANDARD_RIGHTS_READ = 131072;
internal const int STANDARD_RIGHTS_WRITE = 131072;
internal const int SEMAPHORE_MODIFY_STATE = 2;
internal const int EVENT_MODIFY_STATE = 2;
internal const int MUTEX_MODIFY_STATE = 1;
internal const int MUTEX_ALL_ACCESS = 2031617;
internal const int LMEM_FIXED = 0;
internal const int LMEM_ZEROINIT = 64;
internal const int LPTR = 64;
internal const string KERNEL32 = "kernel32.dll";
internal const string USER32 = "user32.dll";
internal const string ADVAPI32 = "advapi32.dll";
internal const string OLE32 = "ole32.dll";
internal const string OLEAUT32 = "oleaut32.dll";
internal const string SHELL32 = "shell32.dll";
internal const string SHIM = "mscoree.dll";
internal const string CRYPT32 = "crypt32.dll";
internal const string SECUR32 = "secur32.dll";
internal const string NTDLL = "ntdll.dll";
internal const string MSCORWKS = "clr.dll";
internal const int SEM_FAILCRITICALERRORS = 1;
internal const int FIND_STARTSWITH = 1048576;
internal const int FIND_ENDSWITH = 2097152;
internal const int FIND_FROMSTART = 4194304;
internal const int FIND_FROMEND = 8388608;
internal static readonly IntPtr INVALID_HANDLE_VALUE = new IntPtr(-1);
internal const int STD_INPUT_HANDLE = -10;
internal const int STD_OUTPUT_HANDLE = -11;
internal const int STD_ERROR_HANDLE = -12;
internal const int CTRL_C_EVENT = 0;
internal const int CTRL_BREAK_EVENT = 1;
internal const int CTRL_CLOSE_EVENT = 2;
internal const int CTRL_LOGOFF_EVENT = 5;
internal const int CTRL_SHUTDOWN_EVENT = 6;
internal const short KEY_EVENT = 1;
internal const int FILE_TYPE_DISK = 1;
internal const int FILE_TYPE_CHAR = 2;
internal const int FILE_TYPE_PIPE = 3;
internal const int REPLACEFILE_WRITE_THROUGH = 1;
internal const int REPLACEFILE_IGNORE_MERGE_ERRORS = 2;
private const int FORMAT_MESSAGE_IGNORE_INSERTS = 512;
private const int FORMAT_MESSAGE_FROM_SYSTEM = 4096;
private const int FORMAT_MESSAGE_ARGUMENT_ARRAY = 8192;
internal const uint FILE_MAP_WRITE = 2u;
internal const uint FILE_MAP_READ = 4u;
internal const int FILE_ATTRIBUTE_READONLY = 1;
internal const int FILE_ATTRIBUTE_DIRECTORY = 16;
internal const int FILE_ATTRIBUTE_REPARSE_POINT = 1024;
internal const int IO_REPARSE_TAG_MOUNT_POINT = -1610612733;
internal const int PAGE_READWRITE = 4;
internal const int MEM_COMMIT = 4096;
internal const int MEM_RESERVE = 8192;
internal const int MEM_RELEASE = 32768;
internal const int MEM_FREE = 65536;
internal const int ERROR_SUCCESS = 0;
internal const int ERROR_INVALID_FUNCTION = 1;
internal const int ERROR_FILE_NOT_FOUND = 2;
internal const int ERROR_PATH_NOT_FOUND = 3;
internal const int ERROR_ACCESS_DENIED = 5;
internal const int ERROR_INVALID_HANDLE = 6;
internal const int ERROR_NOT_ENOUGH_MEMORY = 8;
internal const int ERROR_INVALID_DATA = 13;
internal const int ERROR_INVALID_DRIVE = 15;
internal const int ERROR_NO_MORE_FILES = 18;
internal const int ERROR_NOT_READY = 21;
internal const int ERROR_BAD_LENGTH = 24;
internal const int ERROR_SHARING_VIOLATION = 32;
internal const int ERROR_NOT_SUPPORTED = 50;
internal const int ERROR_FILE_EXISTS = 80;
internal const int ERROR_INVALID_PARAMETER = 87;
internal const int ERROR_BROKEN_PIPE = 109;
internal const int ERROR_CALL_NOT_IMPLEMENTED = 120;
internal const int ERROR_INSUFFICIENT_BUFFER = 122;
internal const int ERROR_INVALID_NAME = 123;
internal const int ERROR_BAD_PATHNAME = 161;
internal const int ERROR_ALREADY_EXISTS = 183;
internal const int ERROR_ENVVAR_NOT_FOUND = 203;
internal const int ERROR_FILENAME_EXCED_RANGE = 206;
internal const int ERROR_NO_DATA = 232;
internal const int ERROR_PIPE_NOT_CONNECTED = 233;
internal const int ERROR_MORE_DATA = 234;
internal const int ERROR_DIRECTORY = 267;
internal const int ERROR_OPERATION_ABORTED = 995;
internal const int ERROR_NOT_FOUND = 1168;
internal const int ERROR_NO_TOKEN = 1008;
internal const int ERROR_DLL_INIT_FAILED = 1114;
internal const int ERROR_NON_ACCOUNT_SID = 1257;
internal const int ERROR_NOT_ALL_ASSIGNED = 1300;
internal const int ERROR_UNKNOWN_REVISION = 1305;
internal const int ERROR_INVALID_OWNER = 1307;
internal const int ERROR_INVALID_PRIMARY_GROUP = 1308;
internal const int ERROR_NO_SUCH_PRIVILEGE = 1313;
internal const int ERROR_PRIVILEGE_NOT_HELD = 1314;
internal const int ERROR_NONE_MAPPED = 1332;
internal const int ERROR_INVALID_ACL = 1336;
internal const int ERROR_INVALID_SID = 1337;
internal const int ERROR_INVALID_SECURITY_DESCR = 1338;
internal const int ERROR_BAD_IMPERSONATION_LEVEL = 1346;
internal const int ERROR_CANT_OPEN_ANONYMOUS = 1347;
internal const int ERROR_NO_SECURITY_ON_OBJECT = 1350;
internal const int ERROR_TRUSTED_RELATIONSHIP_FAILURE = 1789;
internal const uint STATUS_SUCCESS = 0u;
internal const uint STATUS_SOME_NOT_MAPPED = 263u;
internal const uint STATUS_NO_MEMORY = 3221225495u;
internal const uint STATUS_OBJECT_NAME_NOT_FOUND = 3221225524u;
internal const uint STATUS_NONE_MAPPED = 3221225587u;
internal const uint STATUS_INSUFFICIENT_RESOURCES = 3221225626u;
internal const uint STATUS_ACCESS_DENIED = 3221225506u;
internal const int INVALID_FILE_SIZE = -1;
internal const int STATUS_ACCOUNT_RESTRICTION = -1073741714;
private static readonly Version ThreadErrorModeMinOsVersion = new Version(6, 1, 7600);
internal const int LCID_SUPPORTED = 2;
internal const int ENABLE_PROCESSED_INPUT = 1;
internal const int ENABLE_LINE_INPUT = 2;
internal const int ENABLE_ECHO_INPUT = 4;
internal const int SHGFP_TYPE_CURRENT = 0;
internal const int UOI_FLAGS = 1;
internal const int WSF_VISIBLE = 1;
internal const int CSIDL_FLAG_CREATE = 32768;
internal const int CSIDL_FLAG_DONT_VERIFY = 16384;
internal const int CSIDL_ADMINTOOLS = 48;
internal const int CSIDL_CDBURN_AREA = 59;
internal const int CSIDL_COMMON_ADMINTOOLS = 47;
internal const int CSIDL_COMMON_DOCUMENTS = 46;
internal const int CSIDL_COMMON_MUSIC = 53;
internal const int CSIDL_COMMON_OEM_LINKS = 58;
internal const int CSIDL_COMMON_PICTURES = 54;
internal const int CSIDL_COMMON_STARTMENU = 22;
internal const int CSIDL_COMMON_PROGRAMS = 23;
internal const int CSIDL_COMMON_STARTUP = 24;
internal const int CSIDL_COMMON_DESKTOPDIRECTORY = 25;
internal const int CSIDL_COMMON_TEMPLATES = 45;
internal const int CSIDL_COMMON_VIDEO = 55;
internal const int CSIDL_FONTS = 20;
internal const int CSIDL_MYVIDEO = 14;
internal const int CSIDL_NETHOOD = 19;
internal const int CSIDL_PRINTHOOD = 27;
internal const int CSIDL_PROFILE = 40;