-
Notifications
You must be signed in to change notification settings - Fork 4.9k
/
Copy pathpal.h
5008 lines (4179 loc) · 128 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.
/*++
Module Name:
pal.h
Abstract:
CoreCLR Platform Adaptation Layer (PAL) header file. This file
defines all types and API calls required by the CoreCLR when
compiled for Unix-like systems.
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 <float.h>
#include <limits.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdint.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.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_error.h>
#include <pal_mstypes.h>
#include <minipal/utils.h>
// Native system libray handle.
// On Unix systems, NATIVE_LIBRARY_HANDLE type represents a library handle not registered with the PAL.
typedef PVOID NATIVE_LIBRARY_HANDLE;
#if defined(HOST_ARM64)
// Flag to check if atomics feature is available on
// the machine
extern bool g_arm64_atomics_present;
#endif
/******************* ABI-specific glue *******************************/
#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_ENGLISH 0x09
/******************* Compiler-specific glue *******************************/
#ifndef THROW_DECL
#if defined(_MSC_VER) || !defined(__cplusplus)
#define THROW_DECL
#else
#define THROW_DECL throw()
#endif // !_MSC_VER
#endif // !THROW_DECL
#ifdef __sun
#define MATH_THROW_DECL
#else
#define MATH_THROW_DECL THROW_DECL
#endif
#if defined(_MSC_VER)
#define DECLSPEC_ALIGN(x) __declspec(align(x))
#else
#define DECLSPEC_ALIGN(x) __attribute__ ((aligned(x)))
#endif
#define DECLSPEC_NORETURN PAL_NORETURN
#ifdef __clang_analyzer__
#define ANALYZER_NORETURN __attribute((analyzer_noreturn))
#else
#define ANALYZER_NORETURN
#endif
#define EMPTY_BASES_DECL
#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 NOOPT_ATTRIBUTE
#if defined(__llvm__)
#define NOOPT_ATTRIBUTE optnone
#elif defined(__GNUC__)
#define NOOPT_ATTRIBUTE optimize("O0")
#endif
#endif
#ifndef NODEBUG_ATTRIBUTE
#if defined(__llvm__)
#define NODEBUG_ATTRIBUTE __nodebug__
#elif defined(__GNUC__)
#define NODEBUG_ATTRIBUTE __artificial__
#endif
#endif
#ifndef __has_cpp_attribute
#define __has_cpp_attribute(x) (0)
#endif
#ifndef FALLTHROUGH
#if __has_cpp_attribute(fallthrough)
#define FALLTHROUGH [[fallthrough]]
#else // __has_cpp_attribute(fallthrough)
#define FALLTHROUGH
#endif // __has_cpp_attribute(fallthrough)
#endif // FALLTHROUGH
#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
#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__
#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
// LONG_MIN, LONG_MAX, ULONG_MAX -- use INT32_MIN etc. instead.
#define FLT_MAX 3.402823466e+38F
#define DBL_MAX 1.7976931348623157e+308
#endif // !PAL_STDCPP_COMPAT
/******************* PAL-Specific Entrypoints *****************************/
#define IsDebuggerPresent PAL_IsDebuggerPresent
PALIMPORT
BOOL
PALAPI
PAL_IsDebuggerPresent();
/* 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
#undef NULL
#if defined(__cplusplus)
#define NULL 0
#else
#define NULL ((PVOID)0)
#endif
#if defined(PAL_STDCPP_COMPAT) && !defined(__cplusplus)
#define nullptr NULL
#endif // defined(PAL_STDCPP_COMPAT) && !defined(__cplusplus)
#ifndef PAL_STDCPP_COMPAT
typedef __int64 time_t;
#define _TIME_T_DEFINED
#endif // !PAL_STDCPP_COMPAT
#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
#define PAL_INITIALIZE_ENSURE_STACK_SIZE 0x20
#define PAL_INITIALIZE_REGISTER_SIGNALS 0x40
#define PAL_INITIALIZE_REGISTER_ACTIVATION_SIGNAL 0x80
// 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 or register any exceptions
#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 | \
PAL_INITIALIZE_ENSURE_STACK_SIZE | \
PAL_INITIALIZE_REGISTER_SIGNALS | \
PAL_INITIALIZE_REGISTER_ACTIVATION_SIGNAL)
typedef DWORD (PALAPI_NOEXPORT *PTHREAD_START_ROUTINE)(LPVOID lpThreadParameter);
typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE;
/******************* PAL-Specific Entrypoints *****************************/
PALIMPORT
int
PALAPI
PAL_Initialize(
int argc,
char * const argv[]);
PALIMPORT
int
PALAPI
PAL_InitializeDLL();
PALIMPORT
void
PALAPI
PAL_SetInitializeDLLFlags(
DWORD flags);
PALIMPORT
DWORD
PALAPI
PAL_InitializeCoreCLR(
const char *szExePath, BOOL runningInExe);
/// <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)(bool isExecutingOnAltStack);
PALIMPORT
VOID
PALAPI
PAL_SetShutdownCallback(
IN PSHUTDOWN_CALLBACK callback);
/// <summary>
/// Used by the single-file and native AOT hosts to connect the linked in version of createdump
/// </summary>
typedef int (*PCREATEDUMP_CALLBACK)(const int argc, const char* argv[]);
PALIMPORT
VOID
PALAPI
PAL_SetCreateDumpCallback(
IN PCREATEDUMP_CALLBACK callback);
PALIMPORT
BOOL
PALAPI
PAL_GenerateCoreDump(
IN LPCSTR dumpName,
IN INT dumpType,
IN ULONG32 flags,
LPSTR errorMessageBuffer,
INT cbErrorMessageBuffer);
typedef VOID (*PPAL_STARTUP_CALLBACK)(
char *modulePath,
HMODULE hModule,
PVOID parameter);
PALIMPORT
DWORD
PALAPI
PAL_RegisterForRuntimeStartup(
IN DWORD dwProcessId,
IN LPCWSTR lpApplicationGroupId,
IN PPAL_STARTUP_CALLBACK pfnCallback,
IN PVOID parameter,
OUT PVOID *ppUnregisterToken);
PALIMPORT
DWORD
PALAPI
PAL_UnregisterForRuntimeStartup(
IN PVOID pUnregisterToken);
PALIMPORT
BOOL
PALAPI
PAL_NotifyRuntimeStarted();
PALIMPORT
LPCSTR
PALAPI
PAL_GetApplicationGroupId();
static const unsigned int MAX_DEBUGGER_TRANSPORT_PIPE_NAME_LENGTH = MAX_PATH;
PALIMPORT
VOID
PALAPI
PAL_GetTransportName(
const unsigned int MAX_TRANSPORT_NAME_LENGTH,
OUT char *name,
IN const char *prefix,
IN DWORD id,
IN const char *applicationGroupId,
IN const char *suffix);
PALIMPORT
VOID
PALAPI
PAL_GetTransportPipeName(
OUT char *name,
IN DWORD id,
IN const char *applicationGroupId,
IN const char *suffix);
PALIMPORT
void
PALAPI
PAL_IgnoreProfileSignal(int signalNum);
PALIMPORT
HINSTANCE
PALAPI
PAL_RegisterModule(
IN LPCSTR lpLibFileName);
PALIMPORT
VOID
PALAPI
PAL_UnregisterModule(
IN HINSTANCE hInstance);
PALIMPORT
VOID
PALAPI
PAL_Random(
IN OUT LPVOID lpBuffer,
IN DWORD dwLength);
PALIMPORT
BOOL
PALAPI
PAL_OpenProcessMemory(
IN DWORD processId,
OUT DWORD* pHandle
);
PALIMPORT
VOID
PALAPI
PAL_CloseProcessMemory(
IN DWORD handle
);
PALIMPORT
BOOL
PALAPI
PAL_ReadProcessMemory(
IN DWORD handle,
IN ULONG64 address,
IN LPVOID buffer,
IN SIZE_T size,
OUT SIZE_T* numberOfBytesRead
);
PALIMPORT
BOOL
PALAPI
PAL_ProbeMemory(
PVOID pBuffer,
DWORD cbBuffer,
BOOL fWriteAccess);
PALIMPORT
int
PALAPI
// Start the jitdump file
PAL_PerfJitDump_Start(const char* path);
PALIMPORT
bool
PALAPI
PAL_PerfJitDump_IsStarted();
PALIMPORT
int
PALAPI
// Log a method to the jitdump file.
PAL_PerfJitDump_LogMethod(void* pCode, size_t codeSize, const char* symbol, void* debugInfo, void* unwindInfo);
PALIMPORT
int
PALAPI
// Finish the jitdump file
PAL_PerfJitDump_Finish();
/******************* winuser.h Entrypoints *******************************/
#define MB_OKCANCEL 0x00000001L
#define MB_ABORTRETRYIGNORE 0x00000002L
#define MB_ICONQUESTION 0x00000020L
#define MB_ICONEXCLAMATION 0x00000030L
#define MB_TASKMODAL 0x00002000L
#define MB_DEFAULT_DESKTOP_ONLY 0x00020000L
#define IDOK 1
#define IDCANCEL 2
#define IDABORT 3
#define IDRETRY 4
// From win32.h
#ifndef _CRTIMP
#ifdef __GNUC__
#define _CRTIMP
#else // __GNUC__
#define _CRTIMP __declspec(dllimport)
#endif // __GNUC__
#endif // _CRTIMP
/******************* winbase.h Entrypoints and defines ************************/
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
DWORD
PALAPI
SearchPathW(
IN LPCWSTR lpPath,
IN LPCWSTR lpFileName,
IN LPCWSTR lpExtension,
IN DWORD nBufferLength,
OUT LPWSTR lpBuffer,
OUT LPWSTR *lpFilePart
);
#define SearchPath SearchPathW
PALIMPORT
BOOL
PALAPI
CopyFileW(
IN LPCWSTR lpExistingFileName,
IN LPCWSTR lpNewFileName,
IN BOOL bFailIfExists);
#ifdef UNICODE
#define CopyFile CopyFileW
#else
#define CopyFile CopyFileA
#endif
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
typedef struct _OVERLAPPED {
ULONG_PTR Internal;
ULONG_PTR InternalHigh;
DWORD Offset;
DWORD OffsetHigh;
HANDLE hEvent;
} OVERLAPPED, *LPOVERLAPPED;
PALIMPORT
BOOL
PALAPI
WriteFile(
IN HANDLE hFile,
IN LPCVOID lpBuffer,
IN DWORD nNumberOfBytesToWrite,
OUT LPDWORD lpNumberOfBytesWritten,
IN LPOVERLAPPED lpOverlapped);
PALIMPORT
BOOL
PALAPI
ReadFile(
IN HANDLE hFile,
OUT LPVOID lpBuffer,
IN DWORD nNumberOfBytesToRead,
OUT LPDWORD lpNumberOfBytesRead,
IN LPOVERLAPPED lpOverlapped);
#define STD_INPUT_HANDLE ((DWORD)-10)
#define STD_OUTPUT_HANDLE ((DWORD)-11)
#define STD_ERROR_HANDLE ((DWORD)-12)
PALIMPORT
HANDLE
PALAPI
GetStdHandle(
IN DWORD nStdHandle);
PALIMPORT
DWORD
PALAPI
SetFilePointer(
IN HANDLE hFile,
IN LONG lDistanceToMove,
IN PLONG lpDistanceToMoveHigh,
IN DWORD dwMoveMethod);
PALIMPORT
BOOL
PALAPI
SetFilePointerEx(
IN HANDLE hFile,
IN LARGE_INTEGER liDistanceToMove,
OUT PLARGE_INTEGER lpNewFilePointer,
IN DWORD dwMoveMethod);
PALIMPORT
DWORD
PALAPI
GetFileSize(
IN HANDLE hFile,
OUT LPDWORD lpFileSizeHigh);
PALIMPORT
BOOL
PALAPI GetFileSizeEx(
IN HANDLE hFile,
OUT PLARGE_INTEGER lpFileSize);
PALIMPORT
VOID
PALAPI
GetSystemTimeAsFileTime(
OUT LPFILETIME lpSystemTimeAsFileTime);
typedef struct _SYSTEMTIME {
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME, *PSYSTEMTIME, *LPSYSTEMTIME;
PALIMPORT
VOID
PALAPI
GetSystemTime(
OUT LPSYSTEMTIME lpSystemTime);
PALIMPORT
BOOL
PALAPI
FileTimeToSystemTime(
IN CONST FILETIME *lpFileTime,
OUT LPSYSTEMTIME lpSystemTime);
PALIMPORT
BOOL
PALAPI
FlushFileBuffers(
IN HANDLE hFile);
PALIMPORT
UINT
PALAPI
GetConsoleOutputCP();
PALIMPORT
DWORD
PALAPI
GetFullPathNameW(
IN LPCWSTR lpFileName,
IN DWORD nBufferLength,
OUT LPWSTR lpBuffer,
OUT LPWSTR *lpFilePart);
#ifdef UNICODE
#define GetFullPathName GetFullPathNameW
#else
#define GetFullPathName GetFullPathNameA
#endif
PALIMPORT
UINT
PALAPI
GetTempFileNameW(
IN LPCWSTR lpPathName,
IN LPCWSTR lpPrefixString,
IN UINT uUnique,
OUT LPWSTR lpTempFileName);
#ifdef UNICODE
#define GetTempFileName GetTempFileNameW
#else
#define GetTempFileName GetTempFileNameA
#endif
PALIMPORT
DWORD
PALAPI
GetTempPathW(
IN DWORD nBufferLength,
OUT LPWSTR lpBuffer);
PALIMPORT
DWORD
PALAPI
GetTempPathA(
IN DWORD nBufferLength,
OUT LPSTR lpBuffer);
#ifdef UNICODE
#define GetTempPath GetTempPathW
#else
#define GetTempPath GetTempPathA
#endif
PALIMPORT
HANDLE
PALAPI
CreateSemaphoreExW(
IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes,
IN LONG lInitialCount,
IN LONG lMaximumCount,
IN LPCWSTR lpName,
IN /*_Reserved_*/ DWORD dwFlags,
IN DWORD dwDesiredAccess);
PALIMPORT
HANDLE
PALAPI
OpenSemaphoreW(
IN DWORD dwDesiredAccess,
IN BOOL bInheritHandle,
IN LPCWSTR lpName);
#define CreateSemaphoreEx CreateSemaphoreExW
PALIMPORT
BOOL
PALAPI
ReleaseSemaphore(
IN HANDLE hSemaphore,
IN LONG lReleaseCount,
OUT LPLONG lpPreviousCount);
PALIMPORT
HANDLE
PALAPI
CreateEventW(
IN LPSECURITY_ATTRIBUTES lpEventAttributes,
IN BOOL bManualReset,
IN BOOL bInitialState,
IN LPCWSTR lpName);
PALIMPORT
HANDLE
PALAPI
CreateEventExW(
IN LPSECURITY_ATTRIBUTES lpEventAttributes,
IN LPCWSTR lpName,