-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathNativeMethods.cs
More file actions
1119 lines (989 loc) · 47.2 KB
/
NativeMethods.cs
File metadata and controls
1119 lines (989 loc) · 47.2 KB
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
/*
This class was built from multiple sources that I have not kept careful track of.
The majority came from pinvoke.net, but others were probably random Google search
results. Very little will have been written by me.
*/
using Microsoft.Win32.SafeHandles;
using System;
using System.CodeDom.Compiler;
using System.IO;
using System.Net.Sockets;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using System.Text;
using System.Threading;
namespace RandM.RMLib
{
/// <summary>
/// Constants, enumerations, methods, and structures required for certain PInvoke calls
/// </summary>
[GeneratedCodeAttribute("NativeMethods", "1.2.3.4")]
public class NativeMethods
{
#pragma warning disable 1591
//! \cond HIDDEN_SYMBOLS
#region CONSTANTS
public const int CREATE_NEW = 1;
public const int CREATE_UNICODE_ENVIRONMENT = 0x00000400;
public const int EM_GETLINECOUNT = 0x00BA;
public const int EM_LINEINDEX = 0x00BB;
public const int ERROR_BAD_EXE_FORMAT = 193;
public const int FILE_FLAG_DELETE_ON_CLOSE = 0x04000000;
public const int HWND_BROADCAST = 0xffff;
public const UInt32 INFINITE = 0xFFFFFFFF;
public const int INVALID_HANDLE_VALUE = -1;
public const ushort KEY_EVENT = 1;
public const int PRODUCT_UNDEFINED = 0x00000000;
public const int PRODUCT_ULTIMATE = 0x00000001;
public const int PRODUCT_HOME_BASIC = 0x00000002;
public const int PRODUCT_HOME_PREMIUM = 0x00000003;
public const int PRODUCT_ENTERPRISE = 0x00000004;
public const int PRODUCT_HOME_BASIC_N = 0x00000005;
public const int PRODUCT_BUSINESS = 0x00000006;
public const int PRODUCT_STANDARD_SERVER = 0x00000007;
public const int PRODUCT_DATACENTER_SERVER = 0x00000008;
public const int PRODUCT_SMALLBUSINESS_SERVER = 0x00000009;
public const int PRODUCT_ENTERPRISE_SERVER = 0x0000000A;
public const int PRODUCT_STARTER = 0x0000000B;
public const int PRODUCT_DATACENTER_SERVER_CORE = 0x0000000C;
public const int PRODUCT_STANDARD_SERVER_CORE = 0x0000000D;
public const int PRODUCT_ENTERPRISE_SERVER_CORE = 0x0000000E;
public const int PRODUCT_ENTERPRISE_SERVER_IA64 = 0x0000000F;
public const int PRODUCT_BUSINESS_N = 0x00000010;
public const int PRODUCT_WEB_SERVER = 0x00000011;
public const int PRODUCT_CLUSTER_SERVER = 0x00000012;
public const int PRODUCT_HOME_SERVER = 0x00000013;
public const int PRODUCT_STORAGE_EXPRESS_SERVER = 0x00000014;
public const int PRODUCT_STORAGE_STANDARD_SERVER = 0x00000015;
public const int PRODUCT_STORAGE_WORKGROUP_SERVER = 0x00000016;
public const int PRODUCT_STORAGE_ENTERPRISE_SERVER = 0x00000017;
public const int PRODUCT_SERVER_FOR_SMALLBUSINESS = 0x00000018;
public const int PRODUCT_SMALLBUSINESS_SERVER_PREMIUM = 0x00000019;
public const int PRODUCT_HOME_PREMIUM_N = 0x0000001A;
public const int PRODUCT_ENTERPRISE_N = 0x0000001B;
public const int PRODUCT_ULTIMATE_N = 0x0000001C;
public const int PRODUCT_WEB_SERVER_CORE = 0x0000001D;
public const int PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT = 0x0000001E;
public const int PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY = 0x0000001F;
public const int PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING = 0x00000020;
public const int PRODUCT_SERVER_FOR_SMALLBUSINESS_V = 0x00000023;
public const int PRODUCT_STANDARD_SERVER_V = 0x00000024;
public const int PRODUCT_ENTERPRISE_SERVER_V = 0x00000026;
public const int PRODUCT_STANDARD_SERVER_CORE_V = 0x00000028;
public const int PRODUCT_ENTERPRISE_SERVER_CORE_V = 0x00000029;
public const int PRODUCT_HYPERV = 0x0000002A;
public const int STARTF_USESHOWWINDOW = 0x00000001;
public const int STD_INPUT_HANDLE = -10;
public const int STD_OUTPUT_HANDLE = -11;
public const int SC_RESTORE = 61728;
public const int STILL_ACTIVE = 259;
public const int SW_HIDE = 0;
public const int SW_MAXIMIZE = 3;
public const int SW_MINIMIZE = 6;
public const int SW_SHOWNORMAL = 1;
public const int VER_NT_WORKSTATION = 1;
public const int VER_NT_DOMAIN_CONTROLLER = 2;
public const int VER_NT_SERVER = 3;
public const int VER_SUITE_SMALLBUSINESS = 1;
public const int VER_SUITE_ENTERPRISE = 2;
public const int VER_SUITE_TERMINAL = 16;
public const int VER_SUITE_DATACENTER = 128;
public const int VER_SUITE_SINGLEUSERTS = 256;
public const int VER_SUITE_PERSONAL = 512;
public const int VER_SUITE_BLADE = 1024;
public const UInt32 WAIT_ABANDONED = 0x00000080;
public const UInt32 WAIT_OBJECT_0 = 0x00000000;
public const UInt32 WAIT_TIMEOUT = 0x00000102;
public const int WH_KEYBOARD_LL = 13;
public const int WM_KEYDOWN = 0x0100;
public const int WM_SYSCOMMAND = 274;
public const int WM_SYSKEYDOWN = 0x0104;
#endregion
#region ENUMERATIONS
// http://pinvoke.net/default.aspx/ws2_32/Command.html
public enum Command : int
{
/// <summary>
/// Use to determine the amount of data pending in the network's input buffer that can be read from socket s.
/// </summary>
FIONREAD = 1074030207,
/// <summary>
/// The *argp parameter is a pointer to an unsigned long value.
/// Set *argp to a nonzero value if the nonblocking mode should be enabled,
/// or zero if the nonblocking mode should be disabled.
/// </summary>
FIONBIO = -2147195266,
FIOASYNC = 2147195267,
SIOCSHIWAT = 2147192064,
SIOCGHIWAT = 1074033409,
SIOCSLOWAT = 2147192062,
SIOCGLOWAT = 1074033411,
/// <summary>
/// Use to determine if all out of band (OOB) data has been read.
/// </summary>
SIOCATMARK = 1074033415
}
[Flags]
public enum CreateFileAttributes : uint
{
Readonly = 0x00000001,
Hidden = 0x00000002,
System = 0x00000004,
Directory = 0x00000010,
Archive = 0x00000020,
Device = 0x00000040,
Normal = 0x00000080,
Temporary = 0x00000100,
SparseFile = 0x00000200,
ReparsePoint = 0x00000400,
Compressed = 0x00000800,
Offline = 0x00001000,
NotContentIndexed = 0x00002000,
Encrypted = 0x00004000,
Write_Through = 0x80000000,
Overlapped = 0x40000000,
NoBuffering = 0x20000000,
RandomAccess = 0x10000000,
SequentialScan = 0x08000000,
DeleteOnClose = 0x04000000,
BackupSemantics = 0x02000000,
PosixSemantics = 0x01000000,
OpenReparsePoint = 0x00200000,
OpenNoRecall = 0x00100000,
FirstPipeInstance = 0x00080000
}
public enum CreationDisposition : uint
{
/// <summary>
/// Creates a new file. The function fails if a specified file exists.
/// </summary>
New = 1,
/// <summary>
/// Creates a new file, always.
/// If a file exists, the function overwrites the file, clears the existing attributes, combines the specified file attributes,
/// and flags with FILE_ATTRIBUTE_ARCHIVE, but does not set the security descriptor that the SECURITY_ATTRIBUTES structure specifies.
/// </summary>
CreateAlways = 2,
/// <summary>
/// Opens a file. The function fails if the file does not exist.
/// </summary>
OpenExisting = 3,
/// <summary>
/// Opens a file, always.
/// If a file does not exist, the function creates a file as if dwCreationDisposition is CREATE_NEW.
/// </summary>
OpenAlways = 4,
/// <summary>
/// Opens a file and truncates it so that its size is 0 (zero) bytes. The function fails if the file does not exist.
/// The calling process must open the file with the GENERIC_WRITE access right.
/// </summary>
TruncateExisting = 5
}
[Flags]
public enum DuplicateOptions : uint
{
DUPLICATE_CLOSE_SOURCE = (0x00000001),// Closes the source handle. This occurs regardless of any error status returned.
DUPLICATE_SAME_ACCESS = (0x00000002), //Ignores the dwDesiredAccess parameter. The duplicate handle has the same access as the source handle.
}
[Flags]
public enum FileAccess : uint
{
/// <summary>
///
/// </summary>
GenericRead = 0x80000000,
/// <summary>
///
/// </summary>
GenericWrite = 0x40000000,
/// <summary>
///
/// </summary>
GenericExecute = 0x20000000,
/// <summary>
///
/// </summary>
GenericAll = 0x10000000,
/// <summary>
///
/// </summary>
None = 0
}
[Flags]
public enum FileShare : uint
{
/// <summary>
///
/// </summary>
None = 0x00000000,
/// <summary>
/// Enables subsequent open operations on an object to request read access.
/// Otherwise, other processes cannot open the object if they request read access.
/// If this flag is not specified, but the object has been opened for read access, the function fails.
/// </summary>
Read = 0x00000001,
/// <summary>
/// Enables subsequent open operations on an object to request write access.
/// Otherwise, other processes cannot open the object if they request write access.
/// If this flag is not specified, but the object has been opened for write access, the function fails.
/// </summary>
Write = 0x00000002,
/// <summary>
/// Enables subsequent open operations on an object to request delete access.
/// Otherwise, other processes cannot open the object if they request delete access.
/// If this flag is not specified, but the object has been opened for delete access, the function fails.
/// </summary>
Delete = 0x00000004
}
public enum MsgFlags : int
{
MSG_NONE = 0x0,
/// <summary>
/// Processes Out Of Band (OOB) data.
/// </summary>
MSG_OOB = 0x1,
/// <summary>
/// Peeks at the incoming data. The data is copied into the buffer,
/// but is not removed from the input queue.
/// </summary>
MSG_PEEK = 0x2,
/// <summary>
/// send without using routing tables
/// </summary>
MSG_DONTROUTE = 0x4,
/// <summary>
/// The receive request will complete only when one of the following events occurs:
/// </summary>
MSG_WAITALL = 0x8,
/// <summary>
/// partial send or recv for message xport
/// </summary>
MSG_PARTIAL = 0x8000,
/// <summary>
/// ???? ... ???
/// </summary>
MSG_DONTWAIT = 0x1000000
}
public enum ShutDownFlags : int
{
SD_RECEIVE = 0,
SD_SEND = 1,
SD_BOTH = 2
}
public enum VirtualKeyStates : int
{
VK_LBUTTON = 0x01,
VK_RBUTTON = 0x02,
VK_CANCEL = 0x03,
VK_MBUTTON = 0x04,
//
VK_XBUTTON1 = 0x05,
VK_XBUTTON2 = 0x06,
//
VK_BACK = 0x08,
VK_TAB = 0x09,
//
VK_CLEAR = 0x0C,
VK_RETURN = 0x0D,
//
VK_SHIFT = 0x10,
VK_CONTROL = 0x11,
VK_MENU = 0x12,
VK_PAUSE = 0x13,
VK_CAPITAL = 0x14,
//
VK_KANA = 0x15,
VK_HANGEUL = 0x15, /* old name - should be here for compatibility */
VK_HANGUL = 0x15,
VK_JUNJA = 0x17,
VK_FINAL = 0x18,
VK_HANJA = 0x19,
VK_KANJI = 0x19,
//
VK_ESCAPE = 0x1B,
//
VK_CONVERT = 0x1C,
VK_NONCONVERT = 0x1D,
VK_ACCEPT = 0x1E,
VK_MODECHANGE = 0x1F,
//
VK_SPACE = 0x20,
VK_PRIOR = 0x21,
VK_NEXT = 0x22,
VK_END = 0x23,
VK_HOME = 0x24,
VK_LEFT = 0x25,
VK_UP = 0x26,
VK_RIGHT = 0x27,
VK_DOWN = 0x28,
VK_SELECT = 0x29,
VK_PRINT = 0x2A,
VK_EXECUTE = 0x2B,
VK_SNAPSHOT = 0x2C,
VK_INSERT = 0x2D,
VK_DELETE = 0x2E,
VK_HELP = 0x2F,
//
VK_LWIN = 0x5B,
VK_RWIN = 0x5C,
VK_APPS = 0x5D,
//
VK_SLEEP = 0x5F,
//
VK_NUMPAD0 = 0x60,
VK_NUMPAD1 = 0x61,
VK_NUMPAD2 = 0x62,
VK_NUMPAD3 = 0x63,
VK_NUMPAD4 = 0x64,
VK_NUMPAD5 = 0x65,
VK_NUMPAD6 = 0x66,
VK_NUMPAD7 = 0x67,
VK_NUMPAD8 = 0x68,
VK_NUMPAD9 = 0x69,
VK_MULTIPLY = 0x6A,
VK_ADD = 0x6B,
VK_SEPARATOR = 0x6C,
VK_SUBTRACT = 0x6D,
VK_DECIMAL = 0x6E,
VK_DIVIDE = 0x6F,
VK_F1 = 0x70,
VK_F2 = 0x71,
VK_F3 = 0x72,
VK_F4 = 0x73,
VK_F5 = 0x74,
VK_F6 = 0x75,
VK_F7 = 0x76,
VK_F8 = 0x77,
VK_F9 = 0x78,
VK_F10 = 0x79,
VK_F11 = 0x7A,
VK_F12 = 0x7B,
VK_F13 = 0x7C,
VK_F14 = 0x7D,
VK_F15 = 0x7E,
VK_F16 = 0x7F,
VK_F17 = 0x80,
VK_F18 = 0x81,
VK_F19 = 0x82,
VK_F20 = 0x83,
VK_F21 = 0x84,
VK_F22 = 0x85,
VK_F23 = 0x86,
VK_F24 = 0x87,
//
VK_NUMLOCK = 0x90,
VK_SCROLL = 0x91,
//
VK_OEM_NEC_EQUAL = 0x92, // '=' key on numpad
//
VK_OEM_FJ_JISHO = 0x92, // 'Dictionary' key
VK_OEM_FJ_MASSHOU = 0x93, // 'Unregister word' key
VK_OEM_FJ_TOUROKU = 0x94, // 'Register word' key
VK_OEM_FJ_LOYA = 0x95, // 'Left OYAYUBI' key
VK_OEM_FJ_ROYA = 0x96, // 'Right OYAYUBI' key
//
VK_LSHIFT = 0xA0,
VK_RSHIFT = 0xA1,
VK_LCONTROL = 0xA2,
VK_RCONTROL = 0xA3,
VK_LMENU = 0xA4,
VK_RMENU = 0xA5,
//
VK_BROWSER_BACK = 0xA6,
VK_BROWSER_FORWARD = 0xA7,
VK_BROWSER_REFRESH = 0xA8,
VK_BROWSER_STOP = 0xA9,
VK_BROWSER_SEARCH = 0xAA,
VK_BROWSER_FAVORITES = 0xAB,
VK_BROWSER_HOME = 0xAC,
//
VK_VOLUME_MUTE = 0xAD,
VK_VOLUME_DOWN = 0xAE,
VK_VOLUME_UP = 0xAF,
VK_MEDIA_NEXT_TRACK = 0xB0,
VK_MEDIA_PREV_TRACK = 0xB1,
VK_MEDIA_STOP = 0xB2,
VK_MEDIA_PLAY_PAUSE = 0xB3,
VK_LAUNCH_MAIL = 0xB4,
VK_LAUNCH_MEDIA_SELECT = 0xB5,
VK_LAUNCH_APP1 = 0xB6,
VK_LAUNCH_APP2 = 0xB7,
//
VK_OEM_1 = 0xBA, // ';:' for US
VK_OEM_PLUS = 0xBB, // '+' any country
VK_OEM_COMMA = 0xBC, // ',' any country
VK_OEM_MINUS = 0xBD, // '-' any country
VK_OEM_PERIOD = 0xBE, // '.' any country
VK_OEM_2 = 0xBF, // '/?' for US
VK_OEM_3 = 0xC0, // '`~' for US
//
VK_OEM_4 = 0xDB, // '[{' for US
VK_OEM_5 = 0xDC, // '\|' for US
VK_OEM_6 = 0xDD, // ']}' for US
VK_OEM_7 = 0xDE, // ''"' for US
VK_OEM_8 = 0xDF,
//
VK_OEM_AX = 0xE1, // 'AX' key on Japanese AX kbd
VK_OEM_102 = 0xE2, // "<>" or "\|" on RT 102-key kbd.
VK_ICO_HELP = 0xE3, // Help key on ICO
VK_ICO_00 = 0xE4, // 00 key on ICO
//
VK_PROCESSKEY = 0xE5,
//
VK_ICO_CLEAR = 0xE6,
//
VK_PACKET = 0xE7,
//
VK_OEM_RESET = 0xE9,
VK_OEM_JUMP = 0xEA,
VK_OEM_PA1 = 0xEB,
VK_OEM_PA2 = 0xEC,
VK_OEM_PA3 = 0xED,
VK_OEM_WSCTRL = 0xEE,
VK_OEM_CUSEL = 0xEF,
VK_OEM_ATTN = 0xF0,
VK_OEM_FINISH = 0xF1,
VK_OEM_COPY = 0xF2,
VK_OEM_AUTO = 0xF3,
VK_OEM_ENLW = 0xF4,
VK_OEM_BACKTAB = 0xF5,
//
VK_ATTN = 0xF6,
VK_CRSEL = 0xF7,
VK_EXSEL = 0xF8,
VK_EREOF = 0xF9,
VK_PLAY = 0xFA,
VK_ZOOM = 0xFB,
VK_NONAME = 0xFC,
VK_PA1 = 0xFD,
VK_OEM_CLEAR = 0xFE
}
[Flags]
public enum CreateProcessFlags : uint
{
DEBUG_PROCESS = 0x00000001,
DEBUG_ONLY_THIS_PROCESS = 0x00000002,
CREATE_SUSPENDED = 0x00000004,
DETACHED_PROCESS = 0x00000008,
CREATE_NEW_CONSOLE = 0x00000010,
NORMAL_PRIORITY_CLASS = 0x00000020,
IDLE_PRIORITY_CLASS = 0x00000040,
HIGH_PRIORITY_CLASS = 0x00000080,
REALTIME_PRIORITY_CLASS = 0x00000100,
CREATE_NEW_PROCESS_GROUP = 0x00000200,
CREATE_UNICODE_ENVIRONMENT = 0x00000400,
CREATE_SEPARATE_WOW_VDM = 0x00000800,
CREATE_SHARED_WOW_VDM = 0x00001000,
CREATE_FORCEDOS = 0x00002000,
BELOW_NORMAL_PRIORITY_CLASS = 0x00004000,
ABOVE_NORMAL_PRIORITY_CLASS = 0x00008000,
INHERIT_PARENT_AFFINITY = 0x00010000,
INHERIT_CALLER_PRIORITY = 0x00020000,
CREATE_PROTECTED_PROCESS = 0x00040000,
EXTENDED_STARTUPINFO_PRESENT = 0x00080000,
PROCESS_MODE_BACKGROUND_BEGIN = 0x00100000,
PROCESS_MODE_BACKGROUND_END = 0x00200000,
CREATE_BREAKAWAY_FROM_JOB = 0x01000000,
CREATE_PRESERVE_CODE_AUTHZ_LEVEL = 0x02000000,
CREATE_DEFAULT_ERROR_MODE = 0x04000000,
CREATE_NO_WINDOW = 0x08000000,
PROFILE_USER = 0x10000000,
PROFILE_KERNEL = 0x20000000,
PROFILE_SERVER = 0x40000000,
CREATE_IGNORE_SYSTEM_DEFAULT = 0x80000000,
}
#endregion
public delegate IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam);
#region METHODS
// http://blogs.msdn.com/b/toub/archive/2006/05/03/589423.aspx
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);
[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CloseHandle(IntPtr hObject);
// http://pinvoke.net/default.aspx/ws2_32/closesocket.html
[DllImport("ws2_32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern int closesocket(IntPtr s);
// https://github.com/mono/dbus-sharp/blob/master/src/Unix/UnixSocket.cs
[DllImport("libc", CallingConvention = CallingConvention.Cdecl, SetLastError = true, EntryPoint = "close")]
public static extern int close_libc(int fd);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern IntPtr CreateEvent(IntPtr lpEventAttributes, bool bManualReset, bool bInitialState, string lpName);
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr CreateFile(string lpFileName, FileAccess dwDesiredAccess, FileShare dwShareMode, IntPtr lpSecurityAttributes, CreationDisposition dwCreationDisposition, CreateFileAttributes dwFlagsAndAttributes, IntPtr hTemplateFile);
[DllImport("kernel32.dll")]
public static extern IntPtr CreateMailslot(string lpName, uint nMaxMessageSize, uint lReadTimeout, IntPtr lpSecurityAttributes);
// http://pinvoke.net/default.aspx/kernel32.CreateProcess
[DllImport("kernel32.dll")]
public static extern bool CreateProcess(string lpApplicationName, string lpCommandLine, IntPtr lpProcessAttributes, IntPtr lpThreadAttributes, bool bInheritHandles, int dwCreationFlags, IntPtr lpEnvironment, string lpCurrentDirectory, ref STARTUPINFO lpStartupInfo,out PROCESS_INFORMATION lpProcessInformation);
// http://pinvoke.net/default.aspx/kernel32/DeviceIoControl.html
[DllImport("kernel32.dll", ExactSpelling = true, SetLastError = true, CharSet = CharSet.Auto)]
public static extern bool DeviceIoControl(IntPtr hDevice, uint dwIoControlCode, IntPtr lpInBuffer, uint nInBufferSize, IntPtr lpOutBuffer, uint nOutBufferSize, out uint lpBytesReturned, IntPtr lpOverlapped);
// http://www.pinvoke.net/default.aspx/kernel32.duplicatehandle
[DllImport("kernel32.dll", SetLastError=true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DuplicateHandle(IntPtr hSourceProcessHandle, IntPtr hSourceHandle, IntPtr hTargetProcessHandle, out IntPtr lpTargetHandle, uint dwDesiredAccess, [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, uint dwOptions);
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[DllImport("kernel32.dll")]
public static extern bool FindClose(IntPtr handle);
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern SafeFindHandle FindFirstFile(string fileName, [In, Out] WIN32_FIND_DATA data);
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
internal static extern bool FindNextFile(SafeFindHandle hndFindFile, [In, Out, MarshalAs(UnmanagedType.LPStruct)] WIN32_FIND_DATA lpFindFileData);
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
// http://pinvoke.net/default.aspx/kernel32/GetConsoleCursorInfo.html
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool GetConsoleCursorInfo(IntPtr hConsoleOutput, out CONSOLE_CURSOR_INFO lpConsoleCursorInfo);
[DllImport("kernel32")]
public static extern bool GetConsoleFontInfo(IntPtr hOutput, [MarshalAs(UnmanagedType.Bool)]bool bMaximize, uint count, [MarshalAs(UnmanagedType.LPArray), Out] CONSOLE_FONT[] fonts);
// http://pinvoke.net/default.aspx/kernel32/GetConsoleFontSize.html
[DllImport("kernel32.dll", SetLastError = true)]
public static extern COORD GetConsoleFontSize(IntPtr hConsoleOutput, uint nFont);
// http://pinvoke.net/default.aspx/kernel32/GetConsoleScreenBufferInfo.html
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool GetConsoleScreenBufferInfo(IntPtr hConsoleOutput, out CONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo);
[DllImport("kernel32.dll")]
public static extern IntPtr GetConsoleWindow();
// http://www.pinvoke.net/default.aspx/kernel32.getexitcodeprocess
[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetExitCodeProcess(IntPtr hProcess, out int lpExitCode);
// http://pinvoke.net/default.aspx/user32/GetKeyboardState.html
[DllImport("user32.dll")]
public static extern short GetKeyState(VirtualKeyStates nVirtKey);
[DllImport("kernel32.dll")]
public static extern bool GetMailslotInfo(IntPtr hMailslot, ref int lpMaxMessageSize, ref int lpNextSize, ref int lpMessageCount, ref int lpReadTimeout);
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr GetModuleHandle(string moduleName);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern uint GetNumberOfConsoleFonts();
// http://pinvoke.net/default.aspx/kernel32/GetNumberOfConsoleInputEvents.html
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool GetNumberOfConsoleInputEvents(IntPtr hConsoleInput, out uint lpcNumberOfEvents);
[DllImport("kernel32.dll")]
public static extern uint GetPrivateProfileSection(string lpAppName, [In, Out] char[] lpReturnedString, uint nSize, string lpFileName);
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
public static extern uint GetPrivateProfileString(string lpAppName, string lpKeyName, string lpDefault, [In, Out] char[] lpReturnedString, uint nSize, string lpFileName);
[DllImport("kernel32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern IntPtr GetProcAddress(IntPtr hModule, string methodName);
[DllImport("Kernel32.dll")]
public static extern bool GetProductInfo(int osMajorVersion, int osMinorVersion, int spMajorVersion, int spMinorVersion, out int edition);
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern int GetShortPathName([MarshalAs(UnmanagedType.LPTStr)] string path, [MarshalAs(UnmanagedType.LPTStr)] StringBuilder shortPath, int shortPathLength);
// http://pinvoke.net/default.aspx/kernel32/GetStdHandle.html
[DllImport("kernel32.dll", SetLastError = true)]
public static extern IntPtr GetStdHandle(int nStdHandle);
[DllImport("kernel32.dll")]
public static extern bool GetVersionEx(ref OSVERSIONINFOEX osVersionInfo);
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern ushort GlobalAddAtom(string lpString);
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern ushort GlobalDeleteAtom(ushort atom);
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern ushort GlobalFindAtom(string lpString);
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern uint GlobalGetAtomName(ushort nAtom, StringBuilder lpBuffer, int nSize);
// http://pinvoke.net/default.aspx/ws2_32/ioctlsocket.html
[DllImport("Ws2_32.dll")]
public static extern int ioctlsocket(IntPtr s, Command cmd, ref int argp);
[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool IsWow64Process(IntPtr hProcess, [MarshalAs(UnmanagedType.Bool)] out bool isWow64);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern IntPtr OpenVxDHandle(IntPtr hSource);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern bool PostMessage(Int32 hWnd, Int32 wMsg, IntPtr wParam, IntPtr lParam);
// http://pinvoke.net/default.aspx/kernel32/ReadConsoleInput.html
[DllImport("kernel32.dll", EntryPoint = "ReadConsoleInputW", CharSet = CharSet.Unicode)]
public static extern bool ReadConsoleInput(IntPtr hConsoleInput, [Out] INPUT_RECORD[] lpBuffer, uint nLength, out uint lpNumberOfEventsRead);
// http://pinvoke.net/default.aspx/kernel32/ReadConsoleOutput.html
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool ReadConsoleOutput(IntPtr hConsoleOutput, [Out] CHAR_INFO[] lpBuffer, COORD dwBufferSize, COORD dwBufferCoord, ref SMALL_RECT lpReadRegion);
// http://pinvoke.net/default.aspx/kernel32/ReadConsoleOutputAttribute.html
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool ReadConsoleOutputAttribute(IntPtr hConsoleOutput, [Out] ushort[] lpAttribute, uint nLength, COORD dwReadCoord, out uint lpNumberOfAttrsRead);
// http://pinvoke.net/default.aspx/kernel32/ReadConsoleOutputCharacter.html
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool ReadConsoleOutputCharacter(IntPtr hConsoleOutput, [Out] StringBuilder lpCharacter, uint nLength, COORD dwReadCoord, out uint lpNumberOfCharsRead);
//OLD This used to work, but FxCop complained, so we're trying the new version now
//OLD [DllImport("kernel32.dll", SetLastError = true)]
//OLD public static unsafe extern bool ReadFile(IntPtr hFile, byte* pBuffer, uint nNumberOfBytesToRead, out uint lpNumberOfBytesRead, IntPtr lpOverlapped);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern unsafe bool ReadFile(IntPtr hFile, byte* pBuffer, uint nNumberOfBytesToRead, out uint lpNumberOfBytesRead, NativeOverlapped* lpOverlapped);
// http://pinvoke.net/default.aspx/ws2_32/recv.html
[DllImport("Ws2_32.dll")]
public static extern int recv(IntPtr s, IntPtr buf, int len, System.Net.Sockets.SocketFlags flags);
// http://mono-soc-2007.googlecode.com/svn/trunk/brian/FastCgi/src/Mono.FastCgi/SocketAbstractions/UnmanagedSocket.cs
[DllImport("libc", SetLastError = true, EntryPoint = "recv")]
public unsafe static extern int recv_libc(IntPtr s, byte* buffer, int len, int flags);
[DllImport("user32")]
public static extern int RegisterWindowMessage(string message);
// http://pinvoke.net/default.aspx/kernel32/ScrollConsoleScreenBuffer.html
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool ScrollConsoleScreenBuffer(IntPtr hConsoleOutput, [In] ref SMALL_RECT lpScrollRectangle, [In] ref SMALL_RECT lpClipRectangle, COORD dwDestinationOrigin, [In] ref CHAR_INFO lpFill);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool ScrollConsoleScreenBuffer(IntPtr hConsoleOutput, [In] ref SMALL_RECT lpScrollRectangle, [In] IntPtr lpClipRectangle, COORD dwDestinationOrigin, [In] ref CHAR_INFO lpFill);
[DllImport("WS2_32.DLL", SetLastError = true)]
public static extern int select([In] int ignoredParameter, [In, Out] IntPtr[] readfds, [In, Out] IntPtr[] writefds, [In, Out] IntPtr[] exceptfds, [In] ref TimeVal timeout);
[DllImport("WS2_32.DLL", SetLastError = true)]
public static extern int select([In] int ignoredParameter, [In, Out] IntPtr[] readfds, [In, Out] IntPtr[] writefds, [In, Out] IntPtr[] exceptfds, [In] IntPtr nullTimeout);
// http://www.pinvoke.net/default.aspx/ws2_32.send
[DllImport("Ws2_32.dll")]
public static extern int send(IntPtr s, IntPtr buf, int len, MsgFlags flags);
// http://mono-soc-2007.googlecode.com/svn/trunk/brian/FastCgi/src/Mono.FastCgi/SocketAbstractions/UnmanagedSocket.cs
[DllImport("libc", SetLastError = true, EntryPoint = "send")]
public unsafe static extern int send_libc(IntPtr s, byte* buffer, int len, int flags);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern Int32 SendMessage(Int32 hWnd, Int32 wMsg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern Int32 SendNotifyMessage(Int32 hWnd, Int32 wMsg, IntPtr wParam, IntPtr lParam);
// http://pinvoke.net/default.aspx/kernel32/SetConsoleCursorInfo.html
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool SetConsoleCursorInfo(IntPtr hConsoleOutput, [In] ref CONSOLE_CURSOR_INFO lpConsoleCursorInfo);
// http://pinvoke.net/default.aspx/kernel32/SetConsoleCursorPosition.html
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool SetConsoleCursorPosition(IntPtr hConsoleOutput, COORD dwCursorPosition);
[DllImport("kernel32")]
public extern static bool SetConsoleFont(IntPtr hOutput, uint index);
[DllImport("kernel32")]
public static extern bool SetConsoleIcon(IntPtr hIcon);
// http://pinvoke.net/default.aspx/kernel32/SetConsoleTitle.html
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool SetConsoleTitle(string lpConsoleTitle);
// http://pinvoke.net/default.aspx/kernel32/SetConsoleScreenBufferSize.html
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool SetConsoleScreenBufferSize(IntPtr hConsoleOutput, COORD dwSize);
// http://pinvoke.net/default.aspx/kernel32/SetConsoleWindowInfo.html
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool SetConsoleWindowInfo(IntPtr hConsoleOutput, bool bAbsolute, [In] ref SMALL_RECT lpConsoleWindow);
[DllImport("kernel32.dll")]
public static extern bool SetEvent(IntPtr hEvent);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetForegroundWindow(IntPtr hWnd);
// http://blogs.msdn.com/b/toub/archive/2006/05/03/589423.aspx
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId);
[DllImport("user32.dll")]
public static extern int ShowCursor(bool bShow);
[DllImport("user32.dll")]
public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
// http://pinvoke.net/default.aspx/ws2_32/shutdown.html
[DllImport("ws2_32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern int shutdown(IntPtr s, ShutDownFlags how);
// http://mono-soc-2007.googlecode.com/svn/trunk/brian/FastCgi/src/Mono.FastCgi/SocketAbstractions/UnmanagedSocket.cs
[DllImport("libc", SetLastError = true, EntryPoint = "shutdown")]
public static extern int shutdown_libc(IntPtr s, int how);
// http://pinvoke.net/default.aspx/kernel32.TerminateProcess
[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool TerminateProcess(IntPtr hProcess, int uExitCode);
// http://blogs.msdn.com/b/toub/archive/2006/05/03/589423.aspx
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool UnhookWindowsHookEx(IntPtr hhk);
// http://pinvoke.net/default.aspx/kernel32/WriteConsoleOutput.html
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool WriteConsoleOutput(IntPtr hConsoleOutput, CHAR_INFO[] lpBuffer, COORD dwBufferSize, COORD dwBufferCoord, ref SMALL_RECT lpWriteRegion);
// http://pinvoke.net/default.aspx/kernel32/WriteConsoleOutputAttribute.html
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool WriteConsoleOutputAttribute(IntPtr hConsoleOutput, ushort[] lpAttribute, uint nLength, COORD dwWriteCoord, out uint lpNumberOfAttrsWritten);
// http://www.pinvoke.net/default.aspx/kernel32.waitforsingleobject
[DllImport("kernel32.dll", SetLastError = true)]
public static extern UInt32 WaitForSingleObject(IntPtr hHandle, int dwMilliseconds);
// http://pinvoke.net/default.aspx/kernel32/WriteConsoleOutputCharacter.html
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool WriteConsoleOutputCharacter(IntPtr hConsoleOutput, string lpCharacter, uint nLength, COORD dwWriteCoord, out uint lpNumberOfCharsWritten);
//OLD This used to work, but FxCop complained, so we're trying the new version now
//OLD [DllImport("kernel32.dll")]
//OLD public static extern bool WriteFile(IntPtr hFile, byte[] lpBuffer, uint nNumberOfBytesToWrite, out uint lpNumberOfBytesWritten, IntPtr lpOverlapped);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern unsafe bool WriteFile(IntPtr hFile, byte[] lpBuffer, uint nNumberOfBytesToWrite, out uint lpNumberOfBytesWritten, NativeOverlapped* lpOverlapped);
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool WritePrivateProfileString(string lpAppName, string lpKeyName, string lpString, string lpFileName);
[DllImport("WS2_32.DLL", CharSet = CharSet.Auto, SetLastError = true)]
public static extern unsafe SocketError WSADuplicateSocket([In] IntPtr socketHandle, [In] uint processId, [In] byte* pinnedBuffer);
[DllImport("WS2_32.DLL", CharSet = CharSet.Auto, SetLastError = true)]
public static extern int WSAGetLastError();
// http://www.pinvoke.net/default.aspx/ws2_32.wsastartup
[DllImport("ws2_32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern SocketError WSAStartup(Int16 wVersionRequested, out WSAData wsaData);
#endregion
#region STRUCTURES
//CHAR_INFO struct, which was a union in the old days
// so we want to use LayoutKind.Explicit to mimic it as closely
// as we can
[StructLayout(LayoutKind.Explicit)]
public struct CHAR_INFO
{
[FieldOffset(0)]
public char UnicodeChar;
[FieldOffset(0)]
public char AsciiChar;
[FieldOffset(2)] //2 bytes seems to work properly
public UInt16 Attributes;
}
[StructLayout(LayoutKind.Sequential)]
public struct CONSOLE_CURSOR_INFO
{
public uint Size;
public bool Visible;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct CONSOLE_FONT
{
public uint index;
public COORD dim;
}
public struct CONSOLE_SCREEN_BUFFER_INFO
{
public COORD dwSize;
public COORD dwCursorPosition;
public short wAttributes;
public SMALL_RECT srWindow;
public COORD dwMaximumWindowSize;
}
[StructLayout(LayoutKind.Sequential)]
public struct COORD
{
public short X;
public short Y;
}
[StructLayout(LayoutKind.Sequential)]
public struct FOCUS_EVENT_RECORD
{
public uint bSetFocus;
}
[StructLayout(LayoutKind.Explicit)]
public struct INPUT_RECORD
{
[FieldOffset(0)]
public ushort EventType;
[FieldOffset(4)]
public KEY_EVENT_RECORD KeyEvent;
[FieldOffset(4)]
public MOUSE_EVENT_RECORD MouseEvent;
[FieldOffset(4)]
public WINDOW_BUFFER_SIZE_RECORD WindowBufferSizeEvent;
[FieldOffset(4)]
public MENU_EVENT_RECORD MenuEvent;
[FieldOffset(4)]
public FOCUS_EVENT_RECORD FocusEvent;
}
[StructLayout(LayoutKind.Explicit, CharSet = CharSet.Unicode)]
public struct KEY_EVENT_RECORD
{
[FieldOffset(0), MarshalAs(UnmanagedType.Bool)]
public bool bKeyDown;
[FieldOffset(4), MarshalAs(UnmanagedType.U2)]
public ushort wRepeatCount;
[FieldOffset(6), MarshalAs(UnmanagedType.U2)]
//public VirtualKeys wVirtualKeyCode;
public ushort wVirtualKeyCode;
[FieldOffset(8), MarshalAs(UnmanagedType.U2)]
public ushort wVirtualScanCode;
[FieldOffset(10)]
public char UnicodeChar;
[FieldOffset(12), MarshalAs(UnmanagedType.U4)]
//public ControlKeyState dwControlKeyState;
public uint dwControlKeyState;
}
[StructLayout(LayoutKind.Sequential)]
public struct MENU_EVENT_RECORD
{
public uint dwCommandId;
}
[StructLayout(LayoutKind.Sequential)]
public struct MOUSE_EVENT_RECORD
{
public COORD dwMousePosition;
public uint dwButtonState;
public uint dwControlKeyState;
public uint dwEventFlags;
}
[StructLayout(LayoutKind.Sequential)]
public struct OSVERSIONINFOEX
{
public int dwOSVersionInfoSize;
public int dwMajorVersion;
public int dwMinorVersion;
public int dwBuildNumber;
public int dwPlatformId;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
public string szCSDVersion;
public short wServicePackMajor;
public short wServicePackMinor;
public short wSuiteMask;
public byte wProductType;
public byte wReserved;
}
public struct PROCESS_INFORMATION
{
public IntPtr hProcess;
public IntPtr hThread;
public uint dwProcessId;
public uint dwThreadId;
}
public struct SECURITY_ATTRIBUTES
{
public int length;
public IntPtr lpSecurityDescriptor;
public bool bInheritHandle;
}
public struct SMALL_RECT
{
public short Left;
public short Top;
public short Right;
public short Bottom;
}
public struct STARTUPINFO
{
public uint cb;
public string lpReserved;
public string lpDesktop;
public string lpTitle;
public uint dwX;
public uint dwY;
public uint dwXSize;
public uint dwYSize;
public uint dwXCountChars;
public uint dwYCountChars;
public uint dwFillAttribute;
public uint dwFlags;
public short wShowWindow;
public short cbReserved2;
public IntPtr lpReserved2;
public IntPtr hStdInput;
public IntPtr hStdOutput;
public IntPtr hStdError;
}
[StructLayout(LayoutKind.Sequential)]
public struct TimeVal
{
public int Seconds;
public int Microseconds;
}
/// <summary>
/// Contains information about the file that is found
/// by the FindFirstFile or FindNextFile functions.
/// </summary>
[Serializable, StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto), BestFitMapping(false)]
public class WIN32_FIND_DATA
{
public FileAttributes dwFileAttributes;
public uint ftCreationTime_dwLowDateTime;
public uint ftCreationTime_dwHighDateTime;
public uint ftLastAccessTime_dwLowDateTime;
public uint ftLastAccessTime_dwHighDateTime;
public uint ftLastWriteTime_dwLowDateTime;