forked from dotnet/coreclr
/
pal.h
6340 lines (5326 loc) · 166 KB
/
pal.h
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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
/*++
Module Name:
pal.h
Abstract:
Rotor Platform Adaptation Layer (PAL) header file. This file
defines all types and API calls required by the Rotor port of
the Microsoft Common Language Runtime.
Defines which control the behavior of this include file:
UNICODE - define it to set the Ansi/Unicode neutral names to
be the ...W names. Otherwise the neutral names default
to be the ...A names.
PAL_IMPLEMENTATION - define it when implementing the PAL. Otherwise
leave it undefined when consuming the PAL.
Note: some fields in structs have been renamed from the original
SDK documentation names, with _PAL_Undefined appended. This leaves
the structure layout identical to its Win32 version, but prevents
PAL consumers from inadvertently referencing undefined fields.
If you want to add a PAL_ wrapper function to a native function in
here, you also need to edit palinternal.h and win32pal.h.
--*/
#ifndef __PAL_H__
#define __PAL_H__
#ifdef PAL_STDCPP_COMPAT
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
// This macro is used to standardize the wide character string literals between UNIX and Windows.
// Unix L"" is UTF32, and on windows it's UTF16. Because of built-in assumptions on the size
// of string literals, it's important to match behaviour between Unix and Windows. Unix will be defined
// as u"" (char16_t)
#define W(str) u##str
// Undefine the QUOTE_MACRO_L helper and redefine it in terms of u.
// The reason that we do this is that quote macro is defined in ndp\common\inc,
// not inside of coreclr sources.
#define QUOTE_MACRO_L(x) QUOTE_MACRO_u(x)
#define QUOTE_MACRO_u_HELPER(x) u###x
#define QUOTE_MACRO_u(x) QUOTE_MACRO_u_HELPER(x)
#include <pal_char16.h>
#include <pal_error.h>
#include <pal_mstypes.h>
/******************* Processor-specific glue *****************************/
#ifndef _MSC_VER
#if defined(__i686__) && !defined(_M_IX86)
#define _M_IX86 600
#elif defined(__i586__) && !defined(_M_IX86)
#define _M_IX86 500
#elif defined(__i486__) && !defined(_M_IX86)
#define _M_IX86 400
#elif defined(__i386__) && !defined(_M_IX86)
#define _M_IX86 300
#elif defined(__x86_64__) && !defined(_M_AMD64)
#define _M_AMD64 100
#elif defined(__arm__) && !defined(_M_ARM)
#define _M_ARM 7
#elif defined(__aarch64__) && !defined(_M_ARM64)
#define _M_ARM64 1
#endif
#if defined(_M_IX86) && !defined(_X86_)
#define _X86_
#elif defined(_M_AMD64) && !defined(_AMD64_)
#define _AMD64_
#elif defined(_M_ARM) && !defined(_ARM_)
#define _ARM_
#elif defined(_M_ARM64) && !defined(_ARM64_)
#define _ARM64_
#endif
#endif // !_MSC_VER
/******************* ABI-specific glue *******************************/
#ifdef __APPLE__
// Both PowerPC, i386 and x86_64 on Mac OS X use 16-byte alignment.
#define STACK_ALIGN_BITS 4
#define STACK_ALIGN_REQ (1 << STACK_ALIGN_BITS)
#endif
#define MAX_PATH 260
#define _MAX_PATH 260
#define _MAX_DRIVE 3 /* max. length of drive component */
#define _MAX_DIR 256 /* max. length of path component */
#define _MAX_FNAME 256 /* max. length of file name component */
#define _MAX_EXT 256 /* max. length of extension component */
// In some Win32 APIs MAX_PATH is used for file names (even though 256 is the normal file system limit)
// use _MAX_PATH_FNAME to indicate these cases
#define MAX_PATH_FNAME MAX_PATH
#define MAX_LONGPATH 1024 /* max. length of full pathname */
#define MAXSHORT 0x7fff
#define MAXLONG 0x7fffffff
#define MAXCHAR 0x7f
#define MAXDWORD 0xffffffff
// Sorting IDs.
//
// Note that the named locale APIs (eg CompareStringExEx) are recommended.
//
#define LANG_CHINESE 0x04
#define LANG_ENGLISH 0x09
#define LANG_JAPANESE 0x11
#define LANG_KOREAN 0x12
#define LANG_THAI 0x1e
/******************* Compiler-specific glue *******************************/
#ifndef _MSC_VER
#if defined(CORECLR)
// Define this if the underlying platform supports true 2-pass EH.
// At the same time, this enables running several PAL instances
// side-by-side.
#define FEATURE_PAL_SXS 1
#endif // CORECLR
#endif // !_MSC_VER
#if defined(_MSC_VER) || defined(__llvm__)
#define DECLSPEC_ALIGN(x) __declspec(align(x))
#else
#define DECLSPEC_ALIGN(x)
#endif
#define DECLSPEC_NORETURN PAL_NORETURN
#if !defined(_MSC_VER) || defined(SOURCE_FORMATTING)
#define __assume(x) (void)0
#define __annotation(x)
#endif //!MSC_VER
#define UNALIGNED
#ifndef FORCEINLINE
#if _MSC_VER < 1200
#define FORCEINLINE inline
#else
#define FORCEINLINE __forceinline
#endif
#endif
#ifndef PAL_STDCPP_COMPAT
#if __GNUC__
typedef __builtin_va_list va_list;
/* We should consider if the va_arg definition here is actually necessary.
Could we use the standard va_arg definition? */
#define va_start __builtin_va_start
#define va_arg __builtin_va_arg
#define va_copy __builtin_va_copy
#define va_end __builtin_va_end
#define VOID void
#define PUB __attribute__((visibility("default")))
#else // __GNUC__
typedef char * va_list;
#define _INTSIZEOF(n) ( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) )
#if _MSC_VER >= 1400
#ifdef __cplusplus
#define _ADDRESSOF(v) ( &reinterpret_cast<const char &>(v) )
#else
#define _ADDRESSOF(v) ( &(v) )
#endif
#define _crt_va_start(ap,v) ( ap = (va_list)_ADDRESSOF(v) + _INTSIZEOF(v) )
#define _crt_va_arg(ap,t) ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
#define _crt_va_end(ap) ( ap = (va_list)0 )
#define va_start _crt_va_start
#define va_arg _crt_va_arg
#define va_end _crt_va_end
#else // _MSC_VER
#define va_start(ap,v) (ap = (va_list) (&(v)) + _INTSIZEOF(v))
#define va_arg(ap,t) ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
#define va_end(ap)
#endif // _MSC_VER
#define va_copy(dest,src) (dest = src)
#endif // __GNUC__
#endif // !PAL_STDCPP_COMPAT
/******************* PAL-Specific Entrypoints *****************************/
#define IsDebuggerPresent PAL_IsDebuggerPresent
PALIMPORT
BOOL
PALAPI
PAL_IsDebuggerPresent(VOID);
#define MAXIMUM_SUSPEND_COUNT MAXCHAR
#define CHAR_BIT 8
#define SCHAR_MIN (-128)
#define SCHAR_MAX 127
#define UCHAR_MAX 0xff
#define SHRT_MIN (-32768)
#define SHRT_MAX 32767
#define USHRT_MAX 0xffff
#define INT_MIN (-2147483647 - 1)
#define INT_MAX 2147483647
#define UINT_MAX 0xffffffff
#define LONG_MIN (-2147483647L - 1)
#define LONG_MAX 2147483647L
#define ULONG_MAX 0xffffffffUL
#define FLT_MAX 3.402823466e+38F
#define DBL_MAX 1.7976931348623157e+308
/* minimum signed 64 bit value */
#define _I64_MIN (I64(-9223372036854775807) - 1)
/* maximum signed 64 bit value */
#define _I64_MAX I64(9223372036854775807)
/* maximum unsigned 64 bit value */
#define _UI64_MAX UI64(0xffffffffffffffff)
#define _I8_MAX SCHAR_MAX
#define _I8_MIN SCHAR_MIN
#define _I16_MAX SHRT_MAX
#define _I16_MIN SHRT_MIN
#define _I32_MAX INT_MAX
#define _I32_MIN INT_MIN
#define _UI8_MAX UCHAR_MAX
#define _UI8_MIN UCHAR_MIN
#define _UI16_MAX USHRT_MAX
#define _UI16_MIN USHRT_MIN
#define _UI32_MAX UINT_MAX
#define _UI32_MIN UINT_MIN
#ifdef PAL_STDCPP_COMPAT
#undef NULL
#endif
#ifndef NULL
#if defined(__cplusplus)
#define NULL 0
#else
#define NULL ((void *)0)
#endif
#endif
#if defined(PAL_STDCPP_COMPAT) && !defined(__cplusplus)
#define nullptr NULL
#endif // defined(PAL_STDCPP_COMPAT) && !defined(__cplusplus)
#ifndef PAL_STDCPP_COMPAT
#if _WIN64 || _MSC_VER >= 1400
typedef __int64 time_t;
#else
typedef long time_t;
#endif
#define _TIME_T_DEFINED
#endif // !PAL_STDCPP_COMPAT
#if ENABLE_DOWNLEVEL_FOR_NLS
#define MAKELCID(lgid, srtid) ((DWORD)((((DWORD)((WORD )(srtid))) << 16) | \
((DWORD)((WORD )(lgid)))))
#define LANGIDFROMLCID(lcid) ((WORD)(lcid))
#define SORTIDFROMLCID(lcid) ((WORD)((((DWORD)(lcid)) >> 16) & 0xf))
#define LANG_NEUTRAL 0x00
#define LANG_INVARIANT 0x7f
#define SUBLANG_NEUTRAL 0x00 // language neutral
#define SUBLANG_DEFAULT 0x01 // user default
#define SORT_DEFAULT 0x0 // sorting default
#define SUBLANG_SYS_DEFAULT 0x02 // system default
#define MAKELANGID(p, s) ((((WORD )(s)) << 10) | (WORD )(p))
#define PRIMARYLANGID(lgid) ((WORD )(lgid) & 0x3ff)
#define SUBLANGID(lgid) ((WORD )(lgid) >> 10)
#define LANG_SYSTEM_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT))
#define LANG_USER_DEFAULT (MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT))
#define LOCALE_SYSTEM_DEFAULT (MAKELCID(LANG_SYSTEM_DEFAULT, SORT_DEFAULT))
#define LOCALE_USER_DEFAULT (MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT))
#define LOCALE_NEUTRAL (MAKELCID(MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), SORT_DEFAULT))
#define LOCALE_US_ENGLISH (MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT))
#define LOCALE_INVARIANT (MAKELCID(MAKELANGID(LANG_INVARIANT, SUBLANG_NEUTRAL), SORT_DEFAULT))
#define SUBLANG_ENGLISH_US 0x01
#define SUBLANG_CHINESE_TRADITIONAL 0x01 /* Chinese (Traditional) */
#endif // ENABLE_DOWNLEVEL_FOR_NLS
#define CT_CTYPE1 0x00000001 /* ctype 1 information */
#define CT_CTYPE2 0x00000002 /* ctype 2 information */
#define CT_CTYPE3 0x00000004 /* ctype 3 information */
#define C1_UPPER 0x0001 /* upper case */
#define C1_LOWER 0x0002 /* lower case */
#define C1_DIGIT 0x0004 /* decimal digits */
#define C1_SPACE 0x0008 /* spacing characters */
#define C1_PUNCT 0x0010 /* punctuation characters */
#define C1_CNTRL 0x0020 /* control characters */
#define C1_BLANK 0x0040 /* blank characters */
#define C1_XDIGIT 0x0080 /* other digits */
#define C1_ALPHA 0x0100 /* any linguistic character */
#define C2_LEFTTORIGHT 0x0001 /* left to right */
#define C2_RIGHTTOLEFT 0x0002 /* right to left */
#define C2_EUROPENUMBER 0x0003 /* European number, digit */
#define C2_EUROPESEPARATOR 0x0004 /* European numeric separator */
#define C2_EUROPETERMINATOR 0x0005 /* European numeric terminator */
#define C2_ARABICNUMBER 0x0006 /* Arabic number */
#define C2_COMMONSEPARATOR 0x0007 /* common numeric separator */
#define C2_BLOCKSEPARATOR 0x0008 /* block separator */
#define C2_SEGMENTSEPARATOR 0x0009 /* segment separator */
#define C2_WHITESPACE 0x000A /* white space */
#define C2_OTHERNEUTRAL 0x000B /* other neutrals */
#define C2_NOTAPPLICABLE 0x0000 /* no implicit directionality */
#define C3_NONSPACING 0x0001 /* nonspacing character */
#define C3_DIACRITIC 0x0002 /* diacritic mark */
#define C3_VOWELMARK 0x0004 /* vowel mark */
#define C3_SYMBOL 0x0008 /* symbols */
#define C3_KATAKANA 0x0010 /* katakana character */
#define C3_HIRAGANA 0x0020 /* hiragana character */
#define C3_HALFWIDTH 0x0040 /* half width character */
#define C3_FULLWIDTH 0x0080 /* full width character */
#define C3_IDEOGRAPH 0x0100 /* ideographic character */
#define C3_KASHIDA 0x0200 /* Arabic kashida character */
#define C3_LEXICAL 0x0400 /* lexical character */
#define C3_ALPHA 0x8000 /* any ling. char (C1_ALPHA) */
#define C3_NOTAPPLICABLE 0x0000 /* ctype 3 is not applicable */
#define DLL_PROCESS_ATTACH 1
#define DLL_THREAD_ATTACH 2
#define DLL_THREAD_DETACH 3
#define DLL_PROCESS_DETACH 0
#define PAL_INITIALIZE_NONE 0x00
#define PAL_INITIALIZE_SYNC_THREAD 0x01
#define PAL_INITIALIZE_EXEC_ALLOCATOR 0x02
#define PAL_INITIALIZE_STD_HANDLES 0x04
#define PAL_INITIALIZE_REGISTER_SIGTERM_HANDLER 0x08
#define PAL_INITIALIZE_DEBUGGER_EXCEPTIONS 0x10
// PAL_Initialize() flags
#define PAL_INITIALIZE (PAL_INITIALIZE_SYNC_THREAD | PAL_INITIALIZE_STD_HANDLES)
// PAL_InitializeDLL() flags - don't start any of the helper threads
#define PAL_INITIALIZE_DLL PAL_INITIALIZE_NONE
// PAL_InitializeCoreCLR() flags
#define PAL_INITIALIZE_CORECLR (PAL_INITIALIZE | PAL_INITIALIZE_EXEC_ALLOCATOR | PAL_INITIALIZE_REGISTER_SIGTERM_HANDLER | PAL_INITIALIZE_DEBUGGER_EXCEPTIONS)
typedef DWORD (PALAPI *PTHREAD_START_ROUTINE)(LPVOID lpThreadParameter);
typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE;
/******************* PAL-Specific Entrypoints *****************************/
PALIMPORT
int
PALAPI
PAL_Initialize(
int argc,
const char * const argv[]);
PALIMPORT
int
PALAPI
PAL_InitializeDLL(VOID);
PALIMPORT
DWORD
PALAPI
PAL_InitializeCoreCLR(
const char *szExePath);
PALIMPORT
DWORD_PTR
PALAPI
PAL_EntryPoint(
IN LPTHREAD_START_ROUTINE lpStartAddress,
IN LPVOID lpParameter);
/// <summary>
/// This function shuts down PAL WITHOUT exiting the current process.
/// </summary>
PALIMPORT
void
PALAPI
PAL_Shutdown(
void);
/// <summary>
/// This function shuts down PAL and exits the current process.
/// </summary>
PALIMPORT
void
PALAPI
PAL_Terminate(
void);
/// <summary>
/// This function shuts down PAL and exits the current process with
/// the specified exit code.
/// </summary>
PALIMPORT
void
PALAPI
PAL_TerminateEx(
int exitCode);
typedef VOID (*PSHUTDOWN_CALLBACK)(void);
PALIMPORT
VOID
PALAPI
PAL_SetShutdownCallback(
IN PSHUTDOWN_CALLBACK callback);
typedef VOID (*PPAL_STARTUP_CALLBACK)(
char *modulePath,
HMODULE hModule,
PVOID parameter);
PALIMPORT
DWORD
PALAPI
PAL_RegisterForRuntimeStartup(
IN DWORD dwProcessId,
IN PPAL_STARTUP_CALLBACK pfnCallback,
IN PVOID parameter,
OUT PVOID *ppUnregisterToken);
PALIMPORT
DWORD
PALAPI
PAL_UnregisterForRuntimeStartup(
IN PVOID pUnregisterToken);
PALIMPORT
BOOL
PALAPI
PAL_NotifyRuntimeStarted(VOID);
static const int MAX_DEBUGGER_TRANSPORT_PIPE_NAME_LENGTH = 64;
PALIMPORT
VOID
PALAPI
PAL_GetTransportPipeName(
OUT char *name,
IN DWORD id,
IN const char *suffix);
PALIMPORT
void
PALAPI
PAL_InitializeDebug(
void);
PALIMPORT
HINSTANCE
PALAPI
PAL_RegisterModule(
IN LPCSTR lpLibFileName);
PALIMPORT
VOID
PALAPI
PAL_UnregisterModule(
IN HINSTANCE hInstance);
PALIMPORT
BOOL
PALAPI
PAL_GetPALDirectoryW(
OUT LPWSTR lpDirectoryName,
IN OUT UINT* cchDirectoryName);
#ifdef UNICODE
#define PAL_GetPALDirectory PAL_GetPALDirectoryW
#else
#define PAL_GetPALDirectory PAL_GetPALDirectoryA
#endif
PALIMPORT
BOOL
PALAPI
PAL_Random(
IN BOOL bStrong,
IN OUT LPVOID lpBuffer,
IN DWORD dwLength);
PALIMPORT
BOOL
PALAPI
PAL_ProbeMemory(
PVOID pBuffer,
DWORD cbBuffer,
BOOL fWriteAccess);
/******************* winuser.h Entrypoints *******************************/
PALIMPORT
LPSTR
PALAPI
CharNextA(
IN LPCSTR lpsz);
PALIMPORT
LPSTR
PALAPI
CharNextExA(
IN WORD CodePage,
IN LPCSTR lpCurrentChar,
IN DWORD dwFlags);
#ifndef UNICODE
#define CharNext CharNextA
#define CharNextEx CharNextExA
#endif
#define MB_OK 0x00000000L
#define MB_OKCANCEL 0x00000001L
#define MB_ABORTRETRYIGNORE 0x00000002L
#define MB_YESNO 0x00000004L
#define MB_RETRYCANCEL 0x00000005L
#define MB_ICONHAND 0x00000010L
#define MB_ICONQUESTION 0x00000020L
#define MB_ICONEXCLAMATION 0x00000030L
#define MB_ICONASTERISK 0x00000040L
#define MB_ICONINFORMATION MB_ICONASTERISK
#define MB_ICONSTOP MB_ICONHAND
#define MB_ICONERROR MB_ICONHAND
#define MB_DEFBUTTON1 0x00000000L
#define MB_DEFBUTTON2 0x00000100L
#define MB_DEFBUTTON3 0x00000200L
#define MB_SYSTEMMODAL 0x00001000L
#define MB_TASKMODAL 0x00002000L
#define MB_SETFOREGROUND 0x00010000L
#define MB_TOPMOST 0x00040000L
#define MB_NOFOCUS 0x00008000L
#define MB_SETFOREGROUND 0x00010000L
#define MB_DEFAULT_DESKTOP_ONLY 0x00020000L
// Note: this is the NT 4.0 and greater value.
#define MB_SERVICE_NOTIFICATION 0x00200000L
#define MB_TYPEMASK 0x0000000FL
#define MB_ICONMASK 0x000000F0L
#define MB_DEFMASK 0x00000F00L
#define IDOK 1
#define IDCANCEL 2
#define IDABORT 3
#define IDRETRY 4
#define IDIGNORE 5
#define IDYES 6
#define IDNO 7
PALIMPORT
int
PALAPI
MessageBoxW(
IN LPVOID hWnd, // NOTE: diff from winuser.h
IN LPCWSTR lpText,
IN LPCWSTR lpCaption,
IN UINT uType);
#ifdef UNICODE
#define MessageBox MessageBoxW
#else
#define MessageBox MessageBoxA
#endif
/***************** wincon.h Entrypoints **********************************/
#define CTRL_C_EVENT 0
#define CTRL_BREAK_EVENT 1
#define CTRL_CLOSE_EVENT 2
// 3 is reserved!
// 4 is reserved!
#define CTRL_LOGOFF_EVENT 5
#define CTRL_SHUTDOWN_EVENT 6
typedef
BOOL
(PALAPI *PHANDLER_ROUTINE)(
DWORD CtrlType
);
#ifndef CORECLR
PALIMPORT
BOOL
PALAPI
GenerateConsoleCtrlEvent(
IN DWORD dwCtrlEvent,
IN DWORD dwProcessGroupId
);
#endif // !CORECLR
//end wincon.h Entrypoints
// From win32.h
#ifndef _CRTIMP
#ifdef __llvm__
#define _CRTIMP
#else // __llvm__
#define _CRTIMP __declspec(dllimport)
#endif // __llvm__
#endif // _CRTIMP
/******************* winbase.h Entrypoints and defines ************************/
PALIMPORT
BOOL
PALAPI
AreFileApisANSI(
VOID);
typedef struct _SECURITY_ATTRIBUTES {
DWORD nLength;
LPVOID lpSecurityDescriptor;
BOOL bInheritHandle;
} SECURITY_ATTRIBUTES, *PSECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES;
#define _SH_DENYWR 0x20 /* deny write mode */
#define FILE_READ_DATA ( 0x0001 ) // file & pipe
#define FILE_APPEND_DATA ( 0x0004 ) // file
#define GENERIC_READ (0x80000000L)
#define GENERIC_WRITE (0x40000000L)
#define FILE_SHARE_READ 0x00000001
#define FILE_SHARE_WRITE 0x00000002
#define FILE_SHARE_DELETE 0x00000004
#define CREATE_NEW 1
#define CREATE_ALWAYS 2
#define OPEN_EXISTING 3
#define OPEN_ALWAYS 4
#define TRUNCATE_EXISTING 5
#define FILE_ATTRIBUTE_READONLY 0x00000001
#define FILE_ATTRIBUTE_HIDDEN 0x00000002
#define FILE_ATTRIBUTE_SYSTEM 0x00000004
#define FILE_ATTRIBUTE_DIRECTORY 0x00000010
#define FILE_ATTRIBUTE_ARCHIVE 0x00000020
#define FILE_ATTRIBUTE_DEVICE 0x00000040
#define FILE_ATTRIBUTE_NORMAL 0x00000080
#define FILE_FLAG_WRITE_THROUGH 0x80000000
#define FILE_FLAG_NO_BUFFERING 0x20000000
#define FILE_FLAG_RANDOM_ACCESS 0x10000000
#define FILE_FLAG_SEQUENTIAL_SCAN 0x08000000
#define FILE_FLAG_BACKUP_SEMANTICS 0x02000000
#define FILE_BEGIN 0
#define FILE_CURRENT 1
#define FILE_END 2
#define STILL_ACTIVE (0x00000103L)
#define INVALID_SET_FILE_POINTER ((DWORD)-1)
PALIMPORT
HANDLE
PALAPI
CreateFileW(
IN LPCWSTR lpFileName,
IN DWORD dwDesiredAccess,
IN DWORD dwShareMode,
IN LPSECURITY_ATTRIBUTES lpSecurityAttributes,
IN DWORD dwCreationDisposition,
IN DWORD dwFlagsAndAttributes,
IN HANDLE hTemplateFile);
#ifdef UNICODE
#define CreateFile CreateFileW
#else
#define CreateFile CreateFileA
#endif
PALIMPORT
BOOL
PALAPI
LockFile(
IN HANDLE hFile,
IN DWORD dwFileOffsetLow,
IN DWORD dwFileOffsetHigh,
IN DWORD nNumberOfBytesToLockLow,
IN DWORD nNumberOfBytesToLockHigh
);
PALIMPORT
BOOL
PALAPI
UnlockFile(
IN HANDLE hFile,
IN DWORD dwFileOffsetLow,
IN DWORD dwFileOffsetHigh,
IN DWORD nNumberOfBytesToUnlockLow,
IN DWORD nNumberOfBytesToUnlockHigh
);
PALIMPORT
DWORD
PALAPI
SearchPathW(
IN LPCWSTR lpPath,
IN LPCWSTR lpFileName,
IN LPCWSTR lpExtension,
IN DWORD nBufferLength,
OUT LPWSTR lpBuffer,
OUT LPWSTR *lpFilePart
);
#ifdef UNICODE
#define SearchPath SearchPathW
#else
#define SearchPath SearchPathA
#endif // !UNICODE
PALIMPORT
BOOL
PALAPI
CopyFileW(
IN LPCWSTR lpExistingFileName,
IN LPCWSTR lpNewFileName,
IN BOOL bFailIfExists);
#ifdef UNICODE
#define CopyFile CopyFileW
#else
#define CopyFile CopyFileA
#endif
PALIMPORT
BOOL
PALAPI
DeleteFileW(
IN LPCWSTR lpFileName);
#ifdef UNICODE
#define DeleteFile DeleteFileW
#else
#define DeleteFile DeleteFileA
#endif
PALIMPORT
BOOL
PALAPI
MoveFileW(
IN LPCWSTR lpExistingFileName,
IN LPCWSTR lpNewFileName);
#ifdef UNICODE
#define MoveFile MoveFileW
#else
#define MoveFile MoveFileA
#endif
#define MOVEFILE_REPLACE_EXISTING 0x00000001
#define MOVEFILE_COPY_ALLOWED 0x00000002
PALIMPORT
BOOL
PALAPI
MoveFileExW(
IN LPCWSTR lpExistingFileName,
IN LPCWSTR lpNewFileName,
IN DWORD dwFlags);
#ifdef UNICODE
#define MoveFileEx MoveFileExW
#else
#define MoveFileEx MoveFileExA
#endif
PALIMPORT
BOOL
PALAPI
CreateDirectoryW(
IN LPCWSTR lpPathName,
IN LPSECURITY_ATTRIBUTES lpSecurityAttributes);
#ifdef UNICODE
#define CreateDirectory CreateDirectoryW
#else
#define CreateDirectory CreateDirectoryA
#endif
PALIMPORT
BOOL
PALAPI
RemoveDirectoryW(
IN LPCWSTR lpPathName);
#ifdef UNICODE
#define RemoveDirectory RemoveDirectoryW
#else
#define RemoveDirectory RemoveDirectoryA
#endif
typedef struct _BY_HANDLE_FILE_INFORMATION {
DWORD dwFileAttributes;
FILETIME ftCreationTime;
FILETIME ftLastAccessTime;
FILETIME ftLastWriteTime;
DWORD dwVolumeSerialNumber;
DWORD nFileSizeHigh;
DWORD nFileSizeLow;
DWORD nNumberOfLinks;
DWORD nFileIndexHigh;
DWORD nFileIndexLow;
} BY_HANDLE_FILE_INFORMATION, *PBY_HANDLE_FILE_INFORMATION, *LPBY_HANDLE_FILE_INFORMATION;
typedef struct _WIN32_FIND_DATAA {
DWORD dwFileAttributes;
FILETIME ftCreationTime;
FILETIME ftLastAccessTime;
FILETIME ftLastWriteTime;
DWORD nFileSizeHigh;
DWORD nFileSizeLow;
DWORD dwReserved0;
DWORD dwReserved1;
CHAR cFileName[ MAX_PATH_FNAME ];
CHAR cAlternateFileName[ 14 ];
} WIN32_FIND_DATAA, *PWIN32_FIND_DATAA, *LPWIN32_FIND_DATAA;
typedef struct _WIN32_FIND_DATAW {
DWORD dwFileAttributes;
FILETIME ftCreationTime;
FILETIME ftLastAccessTime;
FILETIME ftLastWriteTime;
DWORD nFileSizeHigh;
DWORD nFileSizeLow;
DWORD dwReserved0;
DWORD dwReserved1;
WCHAR cFileName[ MAX_PATH_FNAME ];
WCHAR cAlternateFileName[ 14 ];
} WIN32_FIND_DATAW, *PWIN32_FIND_DATAW, *LPWIN32_FIND_DATAW;
#ifdef UNICODE
typedef WIN32_FIND_DATAW WIN32_FIND_DATA;
typedef PWIN32_FIND_DATAW PWIN32_FIND_DATA;
typedef LPWIN32_FIND_DATAW LPWIN32_FIND_DATA;
#else
typedef WIN32_FIND_DATAA WIN32_FIND_DATA;
typedef PWIN32_FIND_DATAA PWIN32_FIND_DATA;
typedef LPWIN32_FIND_DATAA LPWIN32_FIND_DATA;
#endif
PALIMPORT
HANDLE
PALAPI
FindFirstFileW(
IN LPCWSTR lpFileName,
OUT LPWIN32_FIND_DATAW lpFindFileData);
#ifdef UNICODE
#define FindFirstFile FindFirstFileW
#else
#define FindFirstFile FindFirstFileA
#endif
PALIMPORT
BOOL
PALAPI
FindNextFileW(
IN HANDLE hFindFile,
OUT LPWIN32_FIND_DATAW lpFindFileData);
#ifdef UNICODE
#define FindNextFile FindNextFileW
#else
#define FindNextFile FindNextFileA
#endif
PALIMPORT
BOOL
PALAPI
FindClose(
IN OUT HANDLE hFindFile);
PALIMPORT
DWORD
PALAPI
GetFileAttributesW(
IN LPCWSTR lpFileName);
#ifdef UNICODE
#define GetFileAttributes GetFileAttributesW
#else
#define GetFileAttributes GetFileAttributesA
#endif
typedef enum _GET_FILEEX_INFO_LEVELS {
GetFileExInfoStandard
} GET_FILEEX_INFO_LEVELS;
typedef enum _FINDEX_INFO_LEVELS {
FindExInfoStandard,
FindExInfoBasic,
FindExInfoMaxInfoLevel
} FINDEX_INFO_LEVELS;
typedef enum _FINDEX_SEARCH_OPS {
FindExSearchNameMatch,
FindExSearchLimitToDirectories,
FindExSearchLimitToDevices,
FindExSearchMaxSearchOp
} FINDEX_SEARCH_OPS;
typedef struct _WIN32_FILE_ATTRIBUTE_DATA {
DWORD dwFileAttributes;
FILETIME ftCreationTime;
FILETIME ftLastAccessTime;
FILETIME ftLastWriteTime;
DWORD nFileSizeHigh;
DWORD nFileSizeLow;
} WIN32_FILE_ATTRIBUTE_DATA, *LPWIN32_FILE_ATTRIBUTE_DATA;
PALIMPORT
BOOL
PALAPI
GetFileAttributesExW(
IN LPCWSTR lpFileName,
IN GET_FILEEX_INFO_LEVELS fInfoLevelId,
OUT LPVOID lpFileInformation);
#ifdef UNICODE
#define GetFileAttributesEx GetFileAttributesExW
#endif
PALIMPORT
BOOL
PALAPI
SetFileAttributesW(
IN LPCWSTR lpFileName,
IN DWORD dwFileAttributes);
#ifdef UNICODE
#define SetFileAttributes SetFileAttributesW
#else