' ########################################################################################
' Microsoft Windows
' File: WinBase.inc
' Contents: This module defines the 32-Bit Windows Base APIs
' Copyright (c) 2011 Jos? Roca
' Portions Copyright (c) Microsoft Corporation.
' All Rights Reserved.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
' Note: windows.inc must be included before this file, but can't be done here.
' You must do it in your application.
#IF NOT %DEF(PBX_WinBase_PBI)
#DEFINE PBX_WinBase_PBI
%EQUATE `WINBASE_INC = 1
'/*
' * Compatibility macros
' */
'#define DefineHandleTable(w) ((w),TRUE)
'#define LimitEmsPages(dw)
'#define SetSwapAreaSize(w) (w)
'#define LockSegment(w) GlobalFix((HANDLE)(w))
'#define UnlockSegment(w) GlobalUnfix((HANDLE)(w))
'#define GetCurrentTime() GetTickCount()
'#define Yield()
'#define INVALID_HANDLE_VALUE ((HANDLE)(LONG_PTR)-1)
'#define INVALID_FILE_SIZE ((DWORD)0xFFFFFFFF)
'#define INVALID_SET_FILE_POINTER ((DWORD)-1)
'#define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
%EQUATE `INVALID_HANDLE_VALUE = &HFFFFFFFF
%EQUATE `INVALID_FILE_SIZE = &HFFFFFFFF
%EQUATE `INVALID_SET_FILE_POINTER = &HFFFFFFFF
%EQUATE `INVALID_FILE_ATTRIBUTES = &HFFFFFFFF
%EQUATE `FILE_BEGIN = 0
%EQUATE `FILE_CURRENT = 1
%EQUATE `FILE_END = 2
'#define TIME_ZONE_ID_INVALID ((DWORD)0xFFFFFFFF)
%EQUATE `TIME_ZONE_ID_INVALID = &HFFFFFFFF
'#define WAIT_FAILED ((DWORD)0xFFFFFFFF)
'#define WAIT_OBJECT_0 ((STATUS_WAIT_0 ) + 0 )
%EQUATE `WAIT_FAILED = &HFFFFFFFF
%EQUATE `WAIT_OBJECT_0 = %STATUS_WAIT_0 + 0
'#define WAIT_ABANDONED ((STATUS_ABANDONED_WAIT_0 ) + 0 )
'#define WAIT_ABANDONED_0 ((STATUS_ABANDONED_WAIT_0 ) + 0 )
%EQUATE `WAIT_ABANDONED = %STATUS_ABANDONED_WAIT_0 + 0
%EQUATE `WAIT_ABANDONED_0 = %STATUS_ABANDONED_WAIT_0 + 0
%EQUATE `WAIT_IO_COMPLETION = %STATUS_USER_APC
%EQUATE `STILL_ACTIVE = %STATUS_PENDING
%EQUATE `STATUS_POSSIBLE_DEADLOCK = &HC0000194&
%EQUATE `EXCEPTION_ACCESS_VIOLATION = %STATUS_ACCESS_VIOLATION
%EQUATE `EXCEPTION_DATATYPE_MISALIGNMENT = %STATUS_DATATYPE_MISALIGNMENT
%EQUATE `EXCEPTION_BREAKPOINT = %STATUS_BREAKPOINT
%EQUATE `EXCEPTION_SINGLE_STEP = %STATUS_SINGLE_STEP
%EQUATE `EXCEPTION_ARRAY_BOUNDS_EXCEEDED = %STATUS_ARRAY_BOUNDS_EXCEEDED
%EQUATE `EXCEPTION_FLT_DENORMAL_OPERAND = %STATUS_FLOAT_DENORMAL_OPERAND
%EQUATE `EXCEPTION_FLT_DIVIDE_BY_ZERO = %STATUS_FLOAT_DIVIDE_BY_ZERO
%EQUATE `EXCEPTION_FLT_INEXACT_RESULT = %STATUS_FLOAT_INEXACT_RESULT
%EQUATE `EXCEPTION_FLT_INVALID_OPERATION = %STATUS_FLOAT_INVALID_OPERATION
%EQUATE `EXCEPTION_FLT_OVERFLOW = %STATUS_FLOAT_OVERFLOW
%EQUATE `EXCEPTION_FLT_STACK_CHECK = %STATUS_FLOAT_STACK_CHECK
%EQUATE `EXCEPTION_FLT_UNDERFLOW = %STATUS_FLOAT_UNDERFLOW
%EQUATE `EXCEPTION_INT_DIVIDE_BY_ZERO = %STATUS_INTEGER_DIVIDE_BY_ZERO
%EQUATE `EXCEPTION_INT_OVERFLOW = %STATUS_INTEGER_OVERFLOW
%EQUATE `EXCEPTION_PRIV_INSTRUCTION = %STATUS_PRIVILEGED_INSTRUCTION
%EQUATE `EXCEPTION_IN_PAGE_ERROR = %STATUS_IN_PAGE_ERROR
%EQUATE `EXCEPTION_ILLEGAL_INSTRUCTION = %STATUS_ILLEGAL_INSTRUCTION
%EQUATE `EXCEPTION_NONCONTINUABLE_EXCEPTION = %STATUS_NONCONTINUABLE_EXCEPTION
%EQUATE `EXCEPTION_STACK_OVERFLOW = %STATUS_STACK_OVERFLOW
%EQUATE `EXCEPTION_INVALID_DISPOSITION = %STATUS_INVALID_DISPOSITION
%EQUATE `EXCEPTION_GUARD_PAGE = %STATUS_GUARD_PAGE_VIOLATION
%EQUATE `EXCEPTION_INVALID_HANDLE = %STATUS_INVALID_HANDLE
%EQUATE `EXCEPTION_POSSIBLE_DEADLOCK = %STATUS_POSSIBLE_DEADLOCK
%EQUATE `CONTROL_C_EXIT = %STATUS_CONTROL_C_EXIT
'//
'// File creation flags must start at the high end since they
'// are combined with the attributes
'//
%EQUATE `FILE_FLAG_WRITE_THROUGH = &H80000000
%EQUATE `FILE_FLAG_OVERLAPPED = &H40000000
%EQUATE `FILE_FLAG_NO_BUFFERING = &H20000000
%EQUATE `FILE_FLAG_RANDOM_ACCESS = &H10000000
%EQUATE `FILE_FLAG_SEQUENTIAL_SCAN = &H08000000
%EQUATE `FILE_FLAG_DELETE_ON_CLOSE = &H04000000
%EQUATE `FILE_FLAG_BACKUP_SEMANTICS = &H02000000
%EQUATE `FILE_FLAG_POSIX_SEMANTICS = &H01000000
%EQUATE `FILE_FLAG_OPEN_REPARSE_POINT = &H00200000
%EQUATE `FILE_FLAG_OPEN_NO_RECALL = &H00100000
%EQUATE `FILE_FLAG_FIRST_PIPE_INSTANCE = &H00080000
%EQUATE `CREATE_NEW = 1
%EQUATE `CREATE_ALWAYS = 2
%EQUATE `OPEN_EXISTING = 3
%EQUATE `OPEN_ALWAYS = 4
%EQUATE `TRUNCATE_EXISTING = 5
'#if(_WIN32_WINNT >= 0x0400)
'//
'// Define possible return codes from the CopyFileEx callback routine
'//
%EQUATE `PROGRESS_CONTINUE = 0
%EQUATE `PROGRESS_CANCEL = 1
%EQUATE `PROGRESS_STOP = 2
%EQUATE `PROGRESS_QUIET = 3
'//
'// Define CopyFileEx callback routine state change values
'//
%EQUATE `CALLBACK_CHUNK_FINISHED = &H00000000
%EQUATE `CALLBACK_STREAM_SWITCHED = &H00000001
'//
'// Define CopyFileEx option flags
'//
%EQUATE `COPY_FILE_FAIL_IF_EXISTS = &H00000001
%EQUATE `COPY_FILE_RESTARTABLE = &H00000002
%EQUATE `COPY_FILE_OPEN_SOURCE_FOR_WRITE = &H00000004
%EQUATE `COPY_FILE_ALLOW_DECRYPTED_DESTINATION = &H00000008
'//
'// Gap for private copyfile flags
'//
'#if (_WIN32_WINNT >= 0x0600)
#IF %WINVER >= &H0600
%EQUATE `COPY_FILE_COPY_SYMLINK = &H00000800
%EQUATE `COPY_FILE_NO_BUFFERING = &H00001000
#ENDIF
'#endif /* _WIN32_WINNT >= 0x0400 */
'#if (_WIN32_WINNT >= 0x0500)
'//
'// Define ReplaceFile option flags
'//
%EQUATE `REPLACEFILE_WRITE_THROUGH = &H00000001
%EQUATE `REPLACEFILE_IGNORE_MERGE_ERRORS = &H00000002
'#if (_WIN32_WINNT >= 0x0600)
#IF %WINVER >= &H0600
%EQUATE `REPLACEFILE_IGNORE_ACL_ERRORS = &H00000004
#ENDIF
'#endif
'#endif // #if (_WIN32_WINNT >= 0x0500)
'//
'// Define the NamedPipe definitions
'//
'//
'// Define the dwOpenMode values for CreateNamedPipe
'//
%EQUATE `PIPE_ACCESS_INBOUND = &H00000001
%EQUATE `PIPE_ACCESS_OUTBOUND = &H00000002
%EQUATE `PIPE_ACCESS_DUPLEX = &H00000003
'//
'// Define the Named Pipe End flags for GetNamedPipeInfo
'//
%EQUATE `PIPE_CLIENT_END = &H00000000
%EQUATE `PIPE_SERVER_END = &H00000001
'//
'// Define the dwPipeMode values for CreateNamedPipe
'//
%EQUATE `PIPE_WAIT = &H00000000
%EQUATE `PIPE_NOWAIT = &H00000001
%EQUATE `PIPE_READMODE_BYTE = &H00000000
%EQUATE `PIPE_READMODE_MESSAGE = &H00000002
%EQUATE `PIPE_TYPE_BYTE = &H00000000
%EQUATE `PIPE_TYPE_MESSAGE = &H00000004
%EQUATE `PIPE_ACCEPT_REMOTE_CLIENTS = &H00000000
%EQUATE `PIPE_REJECT_REMOTE_CLIENTS = &H00000008
'//
'// Define the well known values for CreateNamedPipe nMaxInstances
'//
%EQUATE `PIPE_UNLIMITED_INSTANCES = 255
'//
'// Define the Security Quality of Service bits to be passed
'// into CreateFile
'//
'#define SECURITY_ANONYMOUS ( SecurityAnonymous << 16 )
'#define SECURITY_IDENTIFICATION ( SecurityIdentification << 16 )
'#define SECURITY_IMPERSONATION ( SecurityImpersonation << 16 )
'#define SECURITY_DELEGATION ( SecurityDelegation << 16 )
%EQUATE `SECURITY_ANONYMOUS = 0
%EQUATE `SECURITY_IDENTIFICATION = &H00010000
%EQUATE `SECURITY_IMPERSONATION = &H00020000
%EQUATE `SECURITY_DELEGATION = &H00030000
%EQUATE `SECURITY_CONTEXT_TRACKING = &H00040000
%EQUATE `SECURITY_EFFECTIVE_ONLY = &H00080000
%EQUATE `SECURITY_SQOS_PRESENT = &H00100000
%EQUATE `SECURITY_VALID_SQOS_FLAGS = &H001F0000
'//
'// File structures
'//
' // Size = 8 bytes
TYPE OVERLAPPED_UNION_STRUCT DWORD
 Offset AS DWORD ' DWORD Offset
 OffsetHigh AS DWORD ' DWORD OffsetHigh
END TYPE
' // Size = 8 bytes
UNION OVERLAPPED_UNION DWORD
 OVERLAPPED_UNION_STRUCT
 Pointer AS DWORD ' PVOID Pointer
END UNION
' // Size = 20 bytes
TYPE OVERLAPPED DWORD
 Internal AS DWORD ' ULONG_PTR Internal
 InternalHigh AS DWORD ' ULONG_PTR InternalHigh
 OVERLAPPED_UNION
 hEvent AS DWORD ' HANDLE hEvent
END TYPE
' // Size = 16 bytes
TYPE OVERLAPPED_ENTRY DWORD
 lpCompletionKey AS DWORD ' ULONG_PTR
 lpOverlapped AS OVERLAPPED PTR
 Internal AS DWORD ' ULONG_PTR
 dwNumberOfBytesTransferred AS DWORD
END TYPE
#IF NOT %DEF(%SECURITY_ATTRIBUTES_DEFINED)
%EQUATE `SECURITY_ATTRIBUTES_DEFINED = 1
' // Size = 12 bytes
TYPE SECURITY_ATTRIBUTES DWORD
 nLength AS DWORD ' DWORD nLength
 lpSecurityDescriptor AS DWORD ' LPVOID lpSecurityDescriptor
 bInheritHandle AS LONG ' BOOL bInheritHandle
END TYPE
#ENDIF
' // Size = 16 bytes
TYPE PROCESS_INFORMATION DWORD
 hProcess AS DWORD ' HANDLE hProcess
 hThread AS DWORD ' HANDLE hThread
 dwProcessId AS DWORD ' DWORD dwProcessId
 dwThreadId AS DWORD ' DWORD dwThreadId
END TYPE
'//
'// File System time stamps are represented with the following structure:
'//
#IF NOT %DEF(%FILETIME_DEFINED)
%EQUATE `FILETIME_DEFINED = 1
' // Size = 8 bytes
TYPE FILETIME_STRUCT DWORD
 dwLowDateTime AS DWORD
 dwHighDateTime AS DWORD
END TYPE
' // To allow to use both DWORD's and a QUAD
' // Size = 8 bytes
UNION FILETIME DWORD
 FILETIME_STRUCT
 qDateTime AS QUAD
END UNION
#ENDIF
'//
'// System time is represented with the following structure:
'//
#IF NOT %DEF(%SYSTEMTIME_DEFINED)
%EQUATE `SYSTEMTIME_DEFINED = 1
' // Size = 16 bytes
TYPE SYSTEMTIME WORD
 wYear AS WORD ' WORD wYear
 wMonth AS WORD ' WORD wMonth
 wDayOfWeek AS WORD ' WORD wDayOfWeek
 wDay AS WORD ' WORD wDay
 wHour AS WORD ' WORD wHour
 wMinute AS WORD ' WORD wMinute
 wSecond AS WORD ' WORD wSecond
 wMilliseconds AS WORD ' WORD wMilliseconds
END TYPE
#ENDIF
'typedef DWORD (WINAPI *PTHREAD_START_ROUTINE)(
' LPVOID lpThreadParameter
' );
'typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE;
'#if(_WIN32_WINNT >= 0x0400)
'typedef VOID (WINAPI *PFIBER_START_ROUTINE)(
' LPVOID lpFiberParameter
' );
'typedef PFIBER_START_ROUTINE LPFIBER_START_ROUTINE;
'#endif /* _WIN32_WINNT >= 0x0400 */
'#if (_WIN32_WINNT >= 0x0600)
#IF %WINVER >= &H0600
'//
'// Define one-time initialization primitive
'//
'typedef RTL_RUN_ONCE INIT_ONCE;
'typedef PRTL_RUN_ONCE PINIT_ONCE;
'typedef PRTL_RUN_ONCE LPINIT_ONCE;
MACRO INIT_ONCE = RTL_RUN_ONCE
%EQUATE `INIT_ONCE_STATIC_INIT = %RTL_RUN_ONCE_INIT
'//
'// Run once flags
'//
%EQUATE `INIT_ONCE_CHECK_ONLY = %RTL_RUN_ONCE_CHECK_ONLY
%EQUATE `INIT_ONCE_ASYNC = %RTL_RUN_ONCE_ASYNC
%EQUATE `INIT_ONCE_INIT_FAILED = %RTL_RUN_ONCE_INIT_FAILED
'//
'// The context stored in the run once structure must leave the following number
'// of low order bits unused.
'//
%EQUATE `INIT_ONCE_CTX_RESERVED_BITS = %RTL_RUN_ONCE_CTX_RESERVED_BITS
'//
'// FailFast Exception Flags
'//
%EQUATE `FAIL_FAST_GENERATE_EXCEPTION_ADDRESS = &H1
%EQUATE `FAIL_FAST_NO_HARD_ERROR_DLG = &H2
'typedef
'(WINAPI *PINIT_ONCE_FN) (
' );
'FUNCTION INIT_ONCE_FN ( ' BYREF InitOnce AS INIT_ONCE
' , BYREF Parameter AS DWORD
' , BYREF Context AS DWORD
' ) AS LONG
DECLARE SUB InitOnceInitialize LIB "kernel32.dll" ALIAS "InitOnceInitialize" ( BYREF InitOnce AS INIT_ONCE
 ) ' void
DECLARE FUNCTION InitOnceExecuteOnce LIB "kernel32.dll" ALIAS "InitOnceExecuteOnce" ( BYREF InitOnce AS INIT_ONCE , BYVAL InitFn AS QUAD , OPTIONAL BYREF Parameter AS ANY , OPTIONAL BYREF Context AS ANY ) AS LONG
DECLARE FUNCTION InitOnceBeginInitialize LIB "kernel32.dll" ALIAS "InitOnceBeginInitialize" ( BYREF lpInitOnce AS INIT_ONCE
 , BYVAL dwFlags AS DWORD
 , BYREF fPending AS LONG
 , OPTIONAL BYREF lpContext AS ANY
 ) AS LONG
DECLARE FUNCTION InitOnceComplete LIB "kernel32.dll" ALIAS "InitOnceComplete" ( BYREF lpInitOnce AS INIT_ONCE
 , BYVAL dwFlags AS DWORD
 , OPTIONAL BYREF lpContext AS ANY
 ) AS LONG
#ENDIF ' #if (_WIN32_WINNT >= 0x0600)
'//
'// Define the slim r/w lock
'//
'typedef RTL_SRWLOCK SRWLOCK, *PSRWLOCK;
MACRO SRWLOCK = RTL_SRWLOCK
%EQUATE `SRWLOCK_INIT = %RTL_SRWLOCK_INIT
DECLARE SUB InitializeSRWLock LIB "kernel32.dll" ALIAS "InitializeSRWLock" ( BYREF SRWLock AS SRWLOCK ) ' void
DECLARE SUB ReleaseSRWLockExclusive LIB "kernel32.dll" ALIAS "ReleaseSRWLockExclusive" ( BYREF SRWLock AS SRWLOCK ) ' void
DECLARE SUB ReleaseSRWLockShared LIB "kernel32.dll" ALIAS "ReleaseSRWLockShared" ( BYREF SRWLock AS SRWLOCK ) ' void
DECLARE SUB AcquireSRWLockExclusive LIB "kernel32.dll" ALIAS "AcquireSRWLockExclusive" ( BYREF SRWLock AS SRWLOCK ) ' void
DECLARE SUB AcquireSRWLockShared LIB "kernel32.dll" ALIAS "AcquireSRWLockShared" ( BYREF SRWLock AS SRWLOCK ) ' void
DECLARE FUNCTION TryAcquireSRWLockExclusive LIB "kernel32.dll" ALIAS "TryAcquireSRWLockExclusive" ( BYREF SRWLock AS SRWLOCK ) AS BYTE ' BOOLEAN
DECLARE FUNCTION TryAcquireSRWLockShared LIB "kernel32.dll" ALIAS "TryAcquireSRWLockShared" ( BYREF SRWLock AS SRWLOCK ) AS BYTE ' BOOLEAN
'//
'// Define condition variable
'//
'typedef RTL_CONDITION_VARIABLE CONDITION_VARIABLE, *PCONDITION_VARIABLE;
MACRO CONDITION_VARIABLE = RTL_CONDITION_VARIABLE
DECLARE SUB InitializeConditionVariable LIB "kernel32.dll" ALIAS "InitializeConditionVariable" ( BYREF ConditionVariable AS CONDITION_VARIABLE ) ' void
DECLARE SUB WakeConditionVariable LIB "kernel32.dll" ALIAS "WakeConditionVariable" ( BYREF ConditionVariable AS CONDITION_VARIABLE ) ' void
DECLARE SUB WakeAllConditionVariable LIB "kernel32.dll" ALIAS "WakeAllConditionVariable" ( BYREF ConditionVariable AS CONDITION_VARIABLE ) ' void
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION SleepConditionVariableCS LIB "Kernel32.dll" ALIAS "SleepConditionVariableCS" (ConditionVariable AS CONDITION_VARIABLE, CriticalSection AS QUAD, BYVAL dwMilliseconds AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION SleepConditionVariableCS LIB "kernel32.dll" ALIAS "SleepConditionVariableCS" ( BYREF ConditionVariable AS CONDITION_VARIABLE , BYREF CriticalSection AS CRITICAL_SECTION , BYVAL dwMilliseconds AS QUAD ) AS LONG
#ENDIF
DECLARE FUNCTION SleepConditionVariableSRW LIB "kernel32.dll" ALIAS "SleepConditionVariableSRW" ( BYREF ConditionVariable AS CONDITION_VARIABLE , BYREF SRWLock AS SRWLOCK , BYVAL dwMilliseconds AS QUAD , BYVAL Flags AS QUAD ) AS LONG
'//
'// Static initializer for the condition variable
'//
%EQUATE `CONDITION_VARIABLE_INIT = %RTL_CONDITION_VARIABLE_INIT
'//
'// Flags for condition variables
'//
%EQUATE `CONDITION_VARIABLE_LOCKMODE_SHARED = %RTL_CONDITION_VARIABLE_LOCKMODE_SHARED
DECLARE FUNCTION EncodePointer LIB "kernel32.dll" ALIAS "EncodePointer" ( BYVAL Ptr AS QUAD ) AS QUAD
DECLARE FUNCTION DecodePointer LIB "kernel32.dll" ALIAS "DecodePointer" ( BYVAL Ptr AS QUAD
 ) AS DWORD
DECLARE FUNCTION EncodeSystemPointer LIB "kernel32.dll" ALIAS "EncodeSystemPointer" ( BYVAL Ptr AS DWORD
 ) AS DWORD
DECLARE FUNCTION DecodeSystemPointer LIB "kernel32.dll" ALIAS "DecodeSystemPointer" ( BYVAL Ptr AS DWORD
 ) AS DWORD
'#if defined(_X86_)
'typedef PLDT_ENTRY LPLDT_ENTRY;
'#else
'typedef LPVOID LPLDT_ENTRY;
'#endif
%EQUATE `MUTEX_MODIFY_STATE = %MUTANT_QUERY_STATE
%EQUATE `MUTEX_ALL_ACCESS = %MUTANT_ALL_ACCESS
'//
'// Serial provider type.
'//
%EQUATE `SP_SERIALCOMM = &H00000001
'//
'// Provider SubTypes
'//
%EQUATE `PST_UNSPECIFIED = &H00000000
%EQUATE `PST_RS232 = &H00000001
%EQUATE `PST_PARALLELPORT = &H00000002
%EQUATE `PST_RS422 = &H00000003
%EQUATE `PST_RS423 = &H00000004
%EQUATE `PST_RS449 = &H00000005
%EQUATE `PST_FAX = &H00000021
%EQUATE `PST_SCANNER = &H00000022
%EQUATE `PST_NETWORK_BRIDGE = &H00000100
%EQUATE `PST_LAT = &H00000101
%EQUATE `PST_TCPIP_TELNET = &H00000102
%EQUATE `PST_X25 = &H00000103
'//
'// Provider capabilities flags.
'//
%EQUATE `PCF_DTRDSR = &H0001
%EQUATE `PCF_RTSCTS = &H0002
%EQUATE `PCF_RLSD = &H0004
%EQUATE `PCF_PARITY_CHECK = &H0008
%EQUATE `PCF_XONXOFF = &H0010
%EQUATE `PCF_SETXCHAR = &H0020
%EQUATE `PCF_TOTALTIMEOUTS = &H0040
%EQUATE `PCF_INTTIMEOUTS = &H0080
%EQUATE `PCF_SPECIALCHARS = &H0100
%EQUATE `PCF_16BITMODE = &H0200
'//
'// Comm provider settable parameters.
'//
%EQUATE `SP_PARITY = &H0001
%EQUATE `SP_BAUD = &H0002
%EQUATE `SP_DATABITS = &H0004
%EQUATE `SP_STOPBITS = &H0008
%EQUATE `SP_HANDSHAKING = &H0010
%EQUATE `SP_PARITY_CHECK = &H0020
%EQUATE `SP_RLSD = &H0040
'//
'// Settable baud rates in the provider.
'//
%EQUATE `BAUD_075 = &H00000001
%EQUATE `BAUD_110 = &H00000002
%EQUATE `BAUD_134_5 = &H00000004
%EQUATE `BAUD_150 = &H00000008
%EQUATE `BAUD_300 = &H00000010
%EQUATE `BAUD_600 = &H00000020
%EQUATE `BAUD_1200 = &H00000040
%EQUATE `BAUD_1800 = &H00000080
%EQUATE `BAUD_2400 = &H00000100
%EQUATE `BAUD_4800 = &H00000200
%EQUATE `BAUD_7200 = &H00000400
%EQUATE `BAUD_9600 = &H00000800
%EQUATE `BAUD_14400 = &H00001000
%EQUATE `BAUD_19200 = &H00002000
%EQUATE `BAUD_38400 = &H00004000
%EQUATE `BAUD_56K = &H00008000
%EQUATE `BAUD_128K = &H00010000
%EQUATE `BAUD_115200 = &H00020000
%EQUATE `BAUD_57600 = &H00040000
%EQUATE `BAUD_USER = &H10000000
'//
'// Settable Data Bits
'//
%EQUATE `DATABITS_5 = &H0001
%EQUATE `DATABITS_6 = &H0002
%EQUATE `DATABITS_7 = &H0004
%EQUATE `DATABITS_8 = &H0008
%EQUATE `DATABITS_16 = &H0010
%EQUATE `DATABITS_16X = &H0020
'//
'// Settable Stop and Parity bits.
'//
%EQUATE `STOPBITS_10 = &H0001
%EQUATE `STOPBITS_15 = &H0002
%EQUATE `STOPBITS_20 = &H0004
%EQUATE `PARITY_NONE = &H0100
%EQUATE `PARITY_ODD = &H0200
%EQUATE `PARITY_EVEN = &H0400
%EQUATE `PARITY_MARK = &H0800
%EQUATE `PARITY_SPACE = &H1000
' // Size = 64 bytes
TYPE COMMPROP DWORD FILL
 wPacketLength AS WORD ' WORD wPacketLength
 wPacketVersion AS WORD ' WORD wPacketVersion
 dwServiceMask AS DWORD ' DWORD dwServiceMask
 dwReserved1 AS DWORD ' DWORD dwReserved1
 dwMaxTxQueue AS DWORD ' DWORD dwMaxTxQueue
 dwMaxRxQueue AS DWORD ' DWORD dwMaxRxQueue
 dwMaxBaud AS DWORD ' DWORD dwMaxBaud
 dwProvSubType AS DWORD ' DWORD dwProvSubType
 dwProvCapabilities AS DWORD ' DWORD dwProvCapabilities
 dwSettableParams AS DWORD ' DWORD dwSettableParams
 dwSettableBaud AS DWORD ' DWORD dwSettableBaud
 wSettableData AS WORD ' WORD wSettableData
 wSettableStopParity AS WORD ' WORD wSettableStopParity
 dwCurrentTxQueue AS DWORD ' DWORD dwCurrentTxQueue
 dwCurrentRxQueue AS DWORD ' DWORD dwCurrentRxQueue
 dwProvSpec1 AS DWORD ' DWORD dwProvSpec1
 dwProvSpec2 AS DWORD ' DWORD dwProvSpec2
 wcProvChar(1) AS WORD ' WCHAR wcProvChar[1] ' any size
 ' Note: We are using wcProvChar(1) instead of wcProvChar(0) to keep DWORD alignment
END TYPE
'//
'// Set dwProvSpec1 to COMMPROP_INITIALIZED to indicate that wPacketLength
'// is valid before a call to GetCommProperties().
'//
%EQUATE `COMMPROP_INITIALIZED = &HE73CF52E
' // Size = 12 bytes
TYPE COMSTAT DWORD
 fCtsHold AS BIT * 1 IN DWORD ' DWORD fCtsHold : 1
 fDsrHold AS BIT * 1 ' DWORD fDsrHold : 1
 fRlsdHold AS BIT * 1 ' DWORD fRlsdHold : 1
 fXoffHold AS BIT * 1 ' DWORD fXoffHold : 1
 fXoffSent AS BIT * 1 ' DWORD fXoffSent : 1
 fEof AS BIT * 1 ' DWORD fEof : 1
 fTxim AS BIT * 1 ' DWORD fTxim : 1
 fReserved AS BIT * 25 ' DWORD fReserved : 25
 cbInQue AS DWORD ' DWORD cbInQue
 cbOutQue AS DWORD ' DWORD cbOutQue
END TYPE
'//
'// DTR Control Flow Values.
'//
%EQUATE `DTR_CONTROL_DISABLE = &H00
%EQUATE `DTR_CONTROL_ENABLE = &H01
%EQUATE `DTR_CONTROL_HANDSHAKE = &H02
'//
'// RTS Control Flow Values
'//
%EQUATE `RTS_CONTROL_DISABLE = &H00
%EQUATE `RTS_CONTROL_ENABLE = &H01
%EQUATE `RTS_CONTROL_HANDSHAKE = &H02
%EQUATE `RTS_CONTROL_TOGGLE = &H03
' // Size = 28 bytes
TYPE DCB DWORD FILL
 DCBlength AS DWORD ' DWORD DCBlength; /* sizeof(DCB) */
 BaudRate AS DWORD ' DWORD BaudRate; /* Baudrate at which running */
 fBinary AS BIT * 1 IN DWORD ' DWORD fBinary: 1; /* Binary Mode (skip EOF check) */
 fParity AS BIT * 1 ' DWORD fParity: 1; /* Enable parity checking */
 fOutxCtsFlow AS BIT * 1 ' DWORD fOutxCtsFlow:1; /* CTS handshaking on output */
 fOutxDsrFlow AS BIT * 1 ' DWORD fOutxDsrFlow:1; /* DSR handshaking on output */
 fDtrControl AS BIT * 2 ' DWORD fDtrControl:2; /* DTR Flow control */
 fDsrSensitivity AS BIT * 1 ' DWORD fDsrSensitivity:1; /* DSR Sensitivity */
 fTXContinueOnXoff AS BIT * 1 ' DWORD fTXContinueOnXoff: 1; /* Continue TX when Xoff sent */
 fOutX AS BIT * 1 ' DWORD fOutX: 1; /* Enable output X-ON/X-OFF */
 fInX AS BIT * 1 ' DWORD fInX: 1; /* Enable input X-ON/X-OFF */
 fErrorChar AS BIT * 1 ' DWORD fErrorChar: 1; /* Enable Err Replacement */
 fNull AS BIT * 1 ' DWORD fNull: 1; /* Enable Null stripping */
 fRtsControl AS BIT * 2 ' DWORD fRtsControl:2; /* Rts Flow control */
 fAbortOnError AS BIT * 1 ' DWORD fAbortOnError:1; /* Abort all reads and writes on Error */
 fDummy2 AS BIT * 17 ' DWORD fDummy2:17; /* Reserved */
 wReserved AS WORD ' WORD wReserved; /* Not currently used */
 XonLim AS WORD ' WORD XonLim; /* Transmit X-ON threshold */
 XoffLim AS WORD ' WORD XoffLim; /* Transmit X-OFF threshold */
 ByteSize AS BYTE ' BYTE ByteSize; /* Number of bits/byte, 4-8 */
 Parity AS BYTE ' BYTE Parity; /* 0-4=None,Odd,Even,Mark,Space */
 StopBits AS BYTE ' BYTE StopBits; /* 0,1,2 = 1, 1.5, 2 */
 XonChar AS BYTE ' char XonChar; /* Tx and Rx X-ON character */
 XoffChar AS BYTE ' char XoffChar; /* Tx and Rx X-OFF character */
 ErrorChar AS BYTE ' char ErrorChar; /* Error replacement char */
 EofChar AS BYTE ' char EofChar; /* End of Input character */
 EvtChar AS BYTE ' char EvtChar; /* Received Event character */
 wReserved2 AS WORD ' WORD wReserved1; /* Fill for now. */
END TYPE
' // Size = 20 bytes
TYPE COMMTIMEOUTS DWORD
 ReadIntervalTimeout AS DWORD ' DWORD ReadIntervalTimeout; /* Maximum time between read chars. */
 ReadTotalTimeoutMultiplier AS DWORD ' DWORD ReadTotalTimeoutMultiplier; /* Multiplier of characters. */
 ReadTotalTimeoutConstant AS DWORD ' DWORD ReadTotalTimeoutConstant; /* Constant in milliseconds. */
 WriteTotalTimeoutMultiplier AS DWORD ' DWORD WriteTotalTimeoutMultiplier; /* Multiplier of characters. */
 WriteTotalTimeoutConstant AS DWORD ' DWORD WriteTotalTimeoutConstant; /* Constant in milliseconds. */
END TYPE
' // Size = 52 bytes
TYPE COMMCONFIG DWORD FILL
 dwSize AS DWORD ' DWORD dwSize /* Size of the entire struct */
 wVersion AS WORD ' WORD wVersion /* version of the structure */
 wReserved AS WORD ' WORD wReserved /* alignment */
 dcbx AS DCB ' DCB dcb /* device control block */
 dwProviderSubType AS DWORD ' DWORD dwProviderSubType /* ordinal value for identifying
 ' provider-defined data structure format*/
 dwProviderOffset AS DWORD ' DWORD dwProviderOffset /* Specifies the offset of provider specific
 ' data field in bytes from the start */
 dwProviderSize AS DWORD ' DWORD dwProviderSize /* size of the provider-specific data field */
 wcProviderData(1) AS WORD ' WCHAR wcProviderData[1] /* provider-specific data */ any size
 ' // Note: We are using wcProviderData(1) instead of wcProviderData(0) to keep DWORD alignment.
END TYPE
' // Size = 4 bytes
TYPE SYSTEM_INFO_UNION_STRUCT WORD
 wProcessorArchitecture AS WORD ' WORD wProcessorArchitecture
 wReserved AS WORD ' WORD wReserved
END TYPE
' // Size = 4 bytes
UNION SYSTEM_INFO_UNION DWORD
 dwOemId AS DWORD ' DWORD dwOemId; // Obsolete field...do not use
 SYSTEM_INFO_UNION_STRUCT
END UNION
' // Size = 36 bytes
TYPE SYSTEM_INFO DWORD FILL
 SYSTEM_INFO_UNION
 dwPageSize AS DWORD ' DWORD dwPageSize
 lpMinimumApplicationAddress AS DWORD ' LPVOID lpMinimumApplicationAddress
 lpMaximumApplicationAddress AS DWORD ' LPVOID lpMaximumApplicationAddress
 dwActiveProcessorMask AS DWORD ' DWORD_PTR dwActiveProcessorMask
 dwNumberOfProcessors AS DWORD ' DWORD dwNumberOfProcessors;
 dwProcessorType AS DWORD ' DWORD dwProcessorType
 dwAllocationGranularity AS DWORD ' DWORD dwAllocationGranularity
 wProcessorLevel AS WORD ' WORD wProcessorLevel
 wProcessorRevision AS WORD ' WORD wProcessorRevision
END TYPE
'//
'//
'#define FreeModule(hLibModule) FreeLibrary((hLibModule))
'#define MakeProcInstance(lpProc,hInstance) (lpProc)
'#define FreeProcInstance(lpProc) (lpProc)
'/* Global Memory Flags */
%EQUATE `GMEM_FIXED = &H0000
%EQUATE `GMEM_MOVEABLE = &H0002
%EQUATE `GMEM_NOCOMPACT = &H0010
%EQUATE `GMEM_NODISCARD = &H0020
%EQUATE `GMEM_ZEROINIT = &H0040
%EQUATE `GMEM_MODIFY = &H0080
%EQUATE `GMEM_DISCARDABLE = &H0100
%EQUATE `GMEM_NOT_BANKED = &H1000
%EQUATE `GMEM_SHARE = &H2000
%EQUATE `GMEM_DDESHARE = &H2000
%EQUATE `GMEM_NOTIFY = &H4000
%EQUATE `GMEM_LOWER = %GMEM_NOT_BANKED
%EQUATE `GMEM_VALID_FLAGS = &H7F72
%EQUATE `GMEM_INVALID_HANDLE = &H00008000
%EQUATE `GHND = %GMEM_MOVEABLE OR %GMEM_ZEROINIT
%EQUATE `GPTR = %GMEM_FIXED OR %GMEM_ZEROINIT
'#define GlobalLRUNewest( h ) ((HANDLE)(h))
'#define GlobalLRUOldest( h ) ((HANDLE)(h))
'#define GlobalDiscard( h ) GlobalReAlloc( (h), 0, GMEM_MOVEABLE )
'/* Flags returned by GlobalFlags (in addition to GMEM_DISCARDABLE) */
%EQUATE `GMEM_DISCARDED = &H4000
%EQUATE `GMEM_LOCKCOUNT = &H00FF
' // Size = 32 bytes
TYPE MEMORYSTATUS DWORD
 dwLength AS DWORD ' DWORD dwLength
 dwMemoryLoad AS DWORD ' DWORD dwMemoryLoad
 dwTotalPhys AS DWORD ' SIZE_T dwTotalPhys
 dwAvailPhys AS DWORD ' SIZE_T dwAvailPhys
 dwTotalPageFile AS DWORD ' SIZE_T dwTotalPageFile
 dwAvailPageFile AS DWORD ' SIZE_T dwAvailPageFile
 dwTotalVirtual AS DWORD ' SIZE_T dwTotalVirtual
 dwAvailVirtual AS DWORD ' SIZE_T dwAvailVirtual
END TYPE
'/* Local Memory Flags */
%EQUATE `LMEM_FIXED = &H0000
%EQUATE `LMEM_MOVEABLE = &H0002
%EQUATE `LMEM_NOCOMPACT = &H0010
%EQUATE `LMEM_NODISCARD = &H0020
%EQUATE `LMEM_ZEROINIT = &H0040
%EQUATE `LMEM_MODIFY = &H0080
%EQUATE `LMEM_DISCARDABLE = &H0F00
%EQUATE `LMEM_VALID_FLAGS = &H0F72
%EQUATE `LMEM_INVALID_HANDLE = &H8000
%EQUATE `LHND = %LMEM_MOVEABLE + %LMEM_ZEROINIT
%EQUATE `LPTR = %LMEM_FIXED + %LMEM_ZEROINIT
%EQUATE `NONZEROLHND = %LMEM_MOVEABLE
%EQUATE `NONZEROLPTR = %LMEM_FIXED
'#define LocalDiscard( h ) LocalReAlloc( (h), 0, LMEM_MOVEABLE )
'/* Flags returned by LocalFlags (in addition to LMEM_DISCARDABLE) */
%EQUATE `LMEM_DISCARDED = &H4000
%EQUATE `LMEM_LOCKCOUNT = &H00FF
'//
'// NUMA values
'//
%EQUATE `NUMA_NO_PREFERRED_NODE = &HFFFFFFFF ' ((DWORD) -1)
'//
'// dwCreationFlag values
'//
' // Note: The remed flags are predefined in the compiler.
%EQUATE `DEBUG_PROCESS = &H00000001
%EQUATE `DEBUG_ONLY_THIS_PROCESS = &H00000002
%EQUATE `CREATE_SUSPENDED = &H00000004
%EQUATE `DETACHED_PROCESS = &H00000008
%EQUATE `CREATE_NEW_CONSOLE = &H00000010
'%NORMAL_PRIORITY_CLASS = &H00000020
'%IDLE_PRIORITY_CLASS = &H00000040
'%HIGH_PRIORITY_CLASS = &H00000080
'%REALTIME_PRIORITY_CLASS = &H00000100
%EQUATE `CREATE_NEW_PROCESS_GROUP = &H00000200
%EQUATE `CREATE_UNICODE_ENVIRONMENT = &H00000400
%EQUATE `CREATE_SEPARATE_WOW_VDM = &H00000800
%EQUATE `CREATE_SHARED_WOW_VDM = &H00001000
%EQUATE `CREATE_FORCEDOS = &H00002000
%EQUATE `BELOW_NORMAL_PRIORITY_CLASS = &H00004000
%EQUATE `ABOVE_NORMAL_PRIORITY_CLASS = &H00008000
%EQUATE `INHERIT_PARENT_AFFINITY = &H00010000
%EQUATE `INHERIT_CALLER_PRIORITY = &H00020000 ' // Deprecated
%EQUATE `CREATE_PROTECTED_PROCESS = &H00040000
%EQUATE `EXTENDED_STARTUPINFO_PRESENT = &H00080000
%EQUATE `PROCESS_MODE_BACKGROUND_BEGIN = &H00100000
%EQUATE `PROCESS_MODE_BACKGROUND_END = &H00200000
%EQUATE `CREATE_BREAKAWAY_FROM_JOB = &H01000000
%EQUATE `CREATE_PRESERVE_CODE_AUTHZ_LEVEL = &H02000000
%EQUATE `CREATE_DEFAULT_ERROR_MODE = &H04000000
%EQUATE `CREATE_NO_WINDOW = &H08000000
%EQUATE `PROFILE_USER = &H10000000
%EQUATE `PROFILE_KERNEL = &H20000000
%EQUATE `PROFILE_SERVER = &H40000000
%EQUATE `CREATE_IGNORE_SYSTEM_DEFAULT = &H80000000
'//
'// Thread dwCreationFlag values
'//
'//#define CREATE_SUSPENDED 0x00000004
%EQUATE `STACK_SIZE_PARAM_IS_A_RESERVATION = &H00010000 ' // Threads only
'//
'// Priority flags
'//
' // The remed dlags are predefined in the compiler.
'%THREAD_PRIORITY_LOWEST = %THREAD_BASE_PRIORITY_MIN
'%THREAD_PRIORITY_BELOW_NORMAL = %THREAD_PRIORITY_LOWEST + 1
'%THREAD_PRIORITY_NORMAL = 0
'%THREAD_PRIORITY_HIGHEST = %THREAD_BASE_PRIORITY_MAX
'%THREAD_PRIORITY_ABOVE_NORMAL = %THREAD_PRIORITY_HIGHEST - 1
%EQUATE `THREAD_PRIORITY_ERROR_RETURN = %MAXLONG
'%THREAD_PRIORITY_TIME_CRITICAL = %THREAD_BASE_PRIORITY_LOWRT
'%THREAD_PRIORITY_IDLE = %THREAD_BASE_PRIORITY_IDLE
%EQUATE `THREAD_MODE_BACKGROUND_BEGIN = &H00010000
%EQUATE `THREAD_MODE_BACKGROUND_END = &H00020000
'//
'// GetFinalPathNameByHandle
'//
%EQUATE `VOLUME_NAME_DOS = &H0 ' //default
%EQUATE `VOLUME_NAME_GUID = &H1
%EQUATE `VOLUME_NAME_NT = &H2
%EQUATE `VOLUME_NAME_NONE = &H4
%EQUATE `FILE_NAME_NORMALIZED = &H0 ' //default
%EQUATE `FILE_NAME_OPENED = &H8
'//
'// Debug APIs
'//
%EQUATE `EXCEPTION_DEBUG_EVENT = 1
%EQUATE `CREATE_THREAD_DEBUG_EVENT = 2
%EQUATE `CREATE_PROCESS_DEBUG_EVENT = 3
%EQUATE `EXIT_THREAD_DEBUG_EVENT = 4
%EQUATE `EXIT_PROCESS_DEBUG_EVENT = 5
%EQUATE `LOAD_DLL_DEBUG_EVENT = 6
%EQUATE `UNLOAD_DLL_DEBUG_EVENT = 7
%EQUATE `OUTPUT_DEBUG_STRING_EVENT = 8
%EQUATE `RIP_EVENT = 9
' // Size = 84 bytes
TYPE EXCEPTION_DEBUG_INFO DWORD
 ExceptionRecord AS EXCEPTION_RECORD ' EXCEPTION_RECORD ExceptionRecord
 dwFirstChance AS DWORD ' DWORD dwFirstChance
END TYPE
' // Size = 12 bytes
TYPE CREATE_THREAD_DEBUG_INFO DWORD
 hThread AS DWORD ' HANDLE hThread
 lpThreadLocalBase AS DWORD ' LPVOID lpThreadLocalBase
 lpStartAddress AS DWORD ' LPTHREAD_START_ROUTINE lpStartAddress
END TYPE
' // Size = 40 bytes
TYPE CREATE_PROCESS_DEBUG_INFO DWORD
 hFile AS DWORD ' HANDLE hFile
 hProcess AS DWORD ' HANDLE hProcess
 hThread AS DWORD ' HANDLE hThread
 lpBaseOfImage AS DWORD ' LPVOID lpBaseOfImage
 dwDebugInfoFileOffset AS DWORD ' DWORD dwDebugInfoFileOffset
 nDebugInfoSize AS DWORD ' DWORD nDebugInfoSize
 lpThreadLocalBase AS DWORD ' LPVOID lpThreadLocalBase
 lpStartAddress AS DWORD ' LPTHREAD_START_ROUTINE lpStartAddress
 lpImageName AS DWORD PTR ' LPVOID lpImageName
 fUnicode AS WORD ' WORD fUnicode
END TYPE
' // Size = 4 bytes
TYPE EXIT_THREAD_DEBUG_INFO DWORD
 dwExitCode AS DWORD ' DWORD dwExitCode
END TYPE
' // Size = 4 bytes
TYPE EXIT_PROCESS_DEBUG_INFO DWORD
 dwExitCode AS DWORD ' DWORD dwExitCode
END TYPE
' // Size = 24 bytes
TYPE LOAD_DLL_DEBUG_INFO DWORD
 hFile AS DWORD ' HANDLE hFile
 lpBaseOfDll AS LONG ' LPVOID lpBaseOfDll
 dwDebugInfoFileOffset AS DWORD ' DWORD dwDebugInfoFileOffset
 nDebugInfoSize AS DWORD ' DWORD nDebugInfoSize;
 lpImageName AS DWORD PTR ' LPVOID lpImageName
 fUnicode AS WORD ' WORD fUnicode
END TYPE
' // Size = 4 bytes
TYPE UNLOAD_DLL_DEBUG_INFO DWORD
 lpBaseOfDll AS LONG ' LPVOID lpBaseOfDll
END TYPE
' // Size = 8 bytes
TYPE OUTPUT_DEBUG_STRING_INFO DWORD FILL
 lpDebugStringData AS ASCIIZ PTR ' LPSTR lpDebugStringData
 fUnicode AS WORD ' WORD fUnicode
 nDebugStringLength AS WORD ' WORD nDebugStringLength
END TYPE
' // Size = 8 bytes
TYPE RIP_INFO DWORD
 dwError AS DWORD ' DWORD dwError
 dwType AS DWORD ' DWORD dwType
END TYPE
' // Size = 84 bytes
UNION DEBUGEVENTUNION
 deuException AS EXCEPTION_DEBUG_INFO ' EXCEPTION_DEBUG_INFO Exception
 deuCreateThread AS CREATE_THREAD_DEBUG_INFO ' CREATE_THREAD_DEBUG_INFO CreateThread
 deuCreateProcessInfo AS CREATE_PROCESS_DEBUG_INFO ' CREATE_PROCESS_DEBUG_INFO CreateProcessInfo
 deuExitThread AS EXIT_THREAD_DEBUG_INFO ' EXIT_THREAD_DEBUG_INFO ExitThread
 deuExitProcess AS EXIT_PROCESS_DEBUG_INFO ' EXIT_PROCESS_DEBUG_INFO ExitProcess
 deuLoadDll AS LOAD_DLL_DEBUG_INFO ' LOAD_DLL_DEBUG_INFO LoadDll
 deuUnloadDll AS UNLOAD_DLL_DEBUG_INFO ' UNLOAD_DLL_DEBUG_INFO UnloadDll
 deuDebugString AS OUTPUT_DEBUG_STRING_INFO ' OUTPUT_DEBUG_STRING_INFO DebugString
 deuRipInfo AS RIP_INFO ' RIP_INFO RipInfo
END UNION
UNION DEBUG_EVENT_U_UNION
 DEBUGEVENTUNION
 u AS DEBUGEVENTUNION
END UNION
' // Size = 96 bytes
TYPE DEBUG_EVENT DWORD
 dwDebugEventCode AS DWORD ' DWORD dwDebugEventCode
 dwProcessId AS DWORD ' DWORD dwProcessId
 dwThreadId AS DWORD ' DWORD dwThreadId
 DEBUG_EVENT_U_UNION
END TYPE
'//
'// JIT Debugging Info. This structure is defined to have constant size in
'// both the emulated and native environment.
'//
' // Size = 40 bytes
TYPE JIT_DEBUG_INFO QWORD FILL
 dwSize AS DWORD
 dwProcessorArchitecture AS DWORD
 dwThreadID AS DWORD
 dwReserved0 AS DWORD
 lpExceptionAddress AS QUAD ' ULONG64
 lpExceptionRecord AS QUAD ' ULONG64
 lpContextRecord AS QUAD ' ULONG64
END TYPE
%EQUATE `DRIVE_UNKNOWN = 0
%EQUATE `DRIVE_NO_ROOT_DIR = 1
%EQUATE `DRIVE_REMOVABLE = 2
%EQUATE `DRIVE_FIXED = 3
%EQUATE `DRIVE_REMOTE = 4
%EQUATE `DRIVE_CDROM = 5
%EQUATE `DRIVE_RAMDISK = 6
'#ifndef _MAC
'#define GetFreeSpace(w) (0x100000L)
'#else
'WINBASEAPI DWORD WINAPI GetFreeSpace(__in UINT);
'#endif
%EQUATE `FILE_TYPE_UNKNOWN = &H0000
%EQUATE `FILE_TYPE_DISK = &H0001
%EQUATE `FILE_TYPE_CHAR = &H0002
%EQUATE `FILE_TYPE_PIPE = &H0003
%EQUATE `FILE_TYPE_REMOTE = &H8000
%EQUATE `STD_INPUT_HANDLE = &HFFFFFFF6 ' ((DWORD)-10)
%EQUATE `STD_OUTPUT_HANDLE = &HFFFFFFF5 ' ((DWORD)-11)
%EQUATE `STD_ERROR_HANDLE = &HFFFFFFF4 ' ((DWORD)-12)
%EQUATE `NOPARITY = 0
%EQUATE `ODDPARITY = 1
%EQUATE `EVENPARITY = 2
%EQUATE `MARKPARITY = 3
%EQUATE `SPACEPARITY = 4
%EQUATE `ONESTOPBIT = 0
%EQUATE `ONE5STOPBITS = 1
%EQUATE `TWOSTOPBITS = 2
%EQUATE `IGNORE = 0 ' Ignore signal
%EQUATE `INFINITE = &HFFFFFFFF ' Infinite timeout
'//
'// Baud rates at which the communication device operates
'//
%EQUATE `CBR_110 = 110
%EQUATE `CBR_300 = 300
%EQUATE `CBR_600 = 600
%EQUATE `CBR_1200 = 1200
%EQUATE `CBR_2400 = 2400
%EQUATE `CBR_4800 = 4800
%EQUATE `CBR_9600 = 9600
%EQUATE `CBR_14400 = 14400
%EQUATE `CBR_19200 = 19200
%EQUATE `CBR_38400 = 38400
%EQUATE `CBR_56000 = 56000
%EQUATE `CBR_57600 = 57600
%EQUATE `CBR_115200 = 115200
%EQUATE `CBR_128000 = 128000
%EQUATE `CBR_256000 = 256000
'//
'// Error Flags
'//
%EQUATE `CE_RXOVER = &H0001 ' Receive Queue overflow
%EQUATE `CE_OVERRUN = &H0002 ' Receive Overrun Error
%EQUATE `CE_RXPARITY = &H0004 ' Receive Parity Error
%EQUATE `CE_FRAME = &H0008 ' Receive Framing error
%EQUATE `CE_BREAK = &H0010 ' Break Detected
%EQUATE `CE_TXFULL = &H0100 ' TX Queue is full
%EQUATE `CE_PTO = &H0200 ' LPTx Timeout
%EQUATE `CE_IOE = &H0400 ' LPTx I/O Error
%EQUATE `CE_DNS = &H0800 ' LPTx Device not selected
%EQUATE `CE_OOP = &H1000 ' LPTx Out-Of-Paper
%EQUATE `CE_MODE = &H8000 ' Requested mode unsupported
%EQUATE `IE_BADID = -1 ' Invalid or unsupported id
%EQUATE `IE_OPEN = -2 ' Device Already Open
%EQUATE `IE_NOPEN = -3 ' Device Not Open
%EQUATE `IE_MEMORY = -4 ' Unable to allocate queues
%EQUATE `IE_DEFAULT = -5 ' Error in default parameters
%EQUATE `IE_HARDWARE = -10 ' Hardware Not Present
%EQUATE `IE_BYTESIZE = -11 ' Illegal Byte Size
%EQUATE `IE_BAUDRATE = -12 ' Unsupported BaudRate
'//
'// Events
'//
%EQUATE `EV_RXCHAR = &H0001 ' Any Character received
%EQUATE `EV_RXFLAG = &H0002 ' Received certain character
%EQUATE `EV_TXEMPTY = &H0004 ' Transmitt Queue Empty
%EQUATE `EV_CTS = &H0008 ' CTS changed state
%EQUATE `EV_DSR = &H0010 ' DSR changed state
%EQUATE `EV_RLSD = &H0020 ' RLSD changed state
%EQUATE `EV_BREAK = &H0040 ' BREAK received
%EQUATE `EV_ERR = &H0080 ' Line status error occurred
%EQUATE `EV_RING = &H0100 ' Ring signal detected
%EQUATE `EV_PERR = &H0200 ' Printer error occured
%EQUATE `EV_RX80FULL = &H0400 ' Receive buffer is 80 percent full
%EQUATE `EV_EVENT1 = &H0800 ' Provider specific event 1
%EQUATE `EV_EVENT2 = &H1000 ' Provider specific event 2
'//
'// Escape Functions
'//
%EQUATE `SETXOFF = 1 ' Simulate XOFF received
%EQUATE `SETXON = 2 ' Simulate XON received
%EQUATE `SETRTS = 3 ' Set RTS high
%EQUATE `CLRRTS = 4 ' Set RTS low
%EQUATE `SETDTR = 5 ' Set DTR high
%EQUATE `CLRDTR = 6 ' Set DTR low
%EQUATE `RESETDEV = 7 ' Reset device if possible
%EQUATE `SETBREAK = 8 ' Set the device break line
%EQUATE `CLRBREAK = 9 ' Clear the device break line
'//
'// PURGE function flags.
'//
%EQUATE `PURGE_TXABORT = &H0001 ' Kill the pending/current writes to the comm port.
%EQUATE `PURGE_RXABORT = &H0002 ' Kill the pending/current reads to the comm port.
%EQUATE `PURGE_TXCLEAR = &H0004 ' Kill the transmit queue if there.
%EQUATE `PURGE_RXCLEAR = &H0008 ' Kill the typeahead buffer if there.
'#define LPTx 0x80 // Set if ID is for LPT device
%EQUATE `LPTx = &H80 ' Set if ID is for LPT device
'//
'// Modem Status Flags
'//
%EQUATE `MS_CTS_ON = &H0010
%EQUATE `MS_DSR_ON = &H0020
%EQUATE `MS_RING_ON = &H0040
%EQUATE `MS_RLSD_ON = &H0080
'//
'// WaitSoundState() Constants
'//
%EQUATE `S_QUEUEEMPTY = 0
%EQUATE `S_THRESHOLD = 1
%EQUATE `S_ALLTHRESHOLD = 2
'//
'// Accent Modes
'//
%EQUATE `S_NORMAL = 0
%EQUATE `S_LEGATO = 1
%EQUATE `S_STACCATO = 2
'//
'// SetSoundNoise() Sources
'//
%EQUATE `S_PERIOD512 = 0 ' Freq = N/512 high pitch, less coarse hiss
%EQUATE `S_PERIOD1024 = 1 ' Freq = N/1024
%EQUATE `S_PERIOD2048 = 2 ' Freq = N/2048 low pitch, more coarse hiss
%EQUATE `S_PERIODVOICE = 3 ' Source is frequency from voice channel (3)
%EQUATE `S_WHITE512 = 4 ' Freq = N/512 high pitch, less coarse hiss
%EQUATE `S_WHITE1024 = 5 ' Freq = N/1024
%EQUATE `S_WHITE2048 = 6 ' Freq = N/2048 low pitch, more coarse hiss
%EQUATE `S_WHITEVOICE = 7 ' Source is frequency from voice channel (3)
%EQUATE `S_SERDVNA = -1 ' Device not available
%EQUATE `S_SEROFM = -2 ' Out of memory
%EQUATE `S_SERMACT = -3 ' Music active
%EQUATE `S_SERQFUL = -4 ' Queue full
%EQUATE `S_SERBDNT = -5 ' Invalid note
%EQUATE `S_SERDLN = -6 ' Invalid note length
%EQUATE `S_SERDCC = -7 ' Invalid note count
%EQUATE `S_SERDTP = -8 ' Invalid tempo
%EQUATE `S_SERDVL = -9 ' Invalid volume
%EQUATE `S_SERDMD = -10 ' Invalid mode
%EQUATE `S_SERDSH = -11 ' Invalid shape
%EQUATE `S_SERDPT = -12 ' Invalid pitch
%EQUATE `S_SERDFQ = -13 ' Invalid frequency
%EQUATE `S_SERDDR = -14 ' Invalid duration
%EQUATE `S_SERDSR = -15 ' Invalid source
%EQUATE `S_SERDST = -16 ' Invalid state
%EQUATE `NMPWAIT_WAIT_FOREVER = &HFFFFFFFF
%EQUATE `NMPWAIT_NOWAIT = &H00000001
%EQUATE `NMPWAIT_USE_DEFAULT_WAIT = &H00000000
%EQUATE `FS_CASE_IS_PRESERVED = %FILE_CASE_PRESERVED_NAMES
%EQUATE `FS_CASE_SENSITIVE = %FILE_CASE_SENSITIVE_SEARCH
%EQUATE `FS_UNICODE_STORED_ON_DISK = %FILE_UNICODE_ON_DISK
%EQUATE `FS_PERSISTENT_ACLS = %FILE_PERSISTENT_ACLS
%EQUATE `FS_VOL_IS_COMPRESSED = %FILE_VOLUME_IS_COMPRESSED
%EQUATE `FS_FILE_COMPRESSION = %FILE_FILE_COMPRESSION
%EQUATE `FS_FILE_ENCRYPTION = %FILE_SUPPORTS_ENCRYPTION
%EQUATE `FILE_MAP_COPY = %SECTION_QUERY
%EQUATE `FILE_MAP_WRITE = %SECTION_MAP_WRITE
%EQUATE `FILE_MAP_READ = %SECTION_MAP_READ
%EQUATE `FILE_MAP_ALL_ACCESS = %SECTION_ALL_ACCESS
%EQUATE `FILE_MAP_EXECUTE = %SECTION_MAP_EXECUTE_EXPLICIT ' // not included in FILE_MAP_ALL_ACCESS
%EQUATE `OF_READ = &H00000000
%EQUATE `OF_WRITE = &H00000001
%EQUATE `OF_READWRITE = &H00000002
%EQUATE `OF_SHARE_COMPAT = &H00000000
%EQUATE `OF_SHARE_EXCLUSIVE = &H00000010
%EQUATE `OF_SHARE_DENY_WRITE = &H00000020
%EQUATE `OF_SHARE_DENY_READ = &H00000030
%EQUATE `OF_SHARE_DENY_NONE = &H00000040
%EQUATE `OF_PARSE = &H00000100
%EQUATE `OF_DELETE = &H00000200
%EQUATE `OF_VERIFY = &H00000400
%EQUATE `OF_CANCEL = &H00000800
%EQUATE `OF_CREATE = &H00001000
%EQUATE `OF_PROMPT = &H00002000
%EQUATE `OF_EXIST = &H00004000
%EQUATE `OF_REOPEN = &H00008000
%EQUATE `OFS_MAXPATHNAME = 128
' // Size = 136 bytes
TYPE OFSTRUCT BYTE
 cBytes AS BYTE ' BYTE cBytes
 fFixedDisk AS BYTE ' BYTE fFixedDisk
 nErrCode AS WORD ' WORD nErrCode
 Reserved1 AS WORD ' WORD Reserved1
 Reserved2 AS WORD ' WORD Reserved2
 szPathName AS ASCIIZ * %OFS_MAXPATHNAME ' CHAR szPathName[OFS_MAXPATHNAME]
END TYPE
#IF NOT %DEF(%NOWINBASEINTERLOCK) ' -------------------------------------------
#IF NOT %DEF(%NTOS) ' ---------------------------------------------------------
DECLARE FUNCTION InterlockedIncrement LIB "kernel32.dll" ALIAS "InterlockedIncrement" ( BYREF Addend AS LONG ) AS LONG
DECLARE FUNCTION InterlockedDecrement LIB "kernel32.dll" ALIAS "InterlockedDecrement" ( BYREF Addend AS LONG
 ) AS LONG
DECLARE FUNCTION InterlockedExchange LIB "kernel32.dll" ALIAS "InterlockedExchange" ( BYREF Target AS LONG
 , BYVAL Value AS LONG
 ) AS LONG
'#define InterlockedExchangePointer(Target, Value) \
' (PVOID)InterlockedExchange((PLONG)(Target), (LONG)(Value))
DECLARE FUNCTION InterlockedExchangePointer LIB "kernel32.dll" ALIAS "InterlockedExchange" ( BYREF Target AS LONG , BYVAL Value AS LONG ) AS LONG
DECLARE FUNCTION InterlockedExchangeAdd LIB "kernel32.dll" ALIAS "InterlockedExchangeAdd" ( BYREF Addend AS LONG
 , BYVAL Value AS LONG
 ) AS LONG
DECLARE FUNCTION InterlockedCompareExchange LIB "kernel32.dll" ALIAS "InterlockedCompareExchange" ( BYREF Destination AS LONG
 , BYVAL ExChange AS LONG
 , BYVAL Comperand AS LONG
 ) AS LONG
'#if (_WIN32_WINNT >= 0x0502)
DECLARE FUNCTION InterlockedCompareExchange64 LIB "kernel32.dll" ALIAS "InterlockedCompareExchange64" ( BYREF Destination AS QUAD , BYVAL ExChange AS QUAD , BYVAL Comperand AS QUAD ) AS QUAD ' LONGLONG
'#endif
'#if (_WIN32_WINNT >= 0x0502)
#IF %WINVER >= &H0502
'FORCEINLINE
'LONGLONG
'InterlockedAnd64 (
' )
'{
' LONGLONG Old;
' do {
' Old = *Destination;
' } while (InterlockedCompareExchange64(Destination,
' Old & Value,
' Old) != Old);
' return Old;
'}
FUNCTION InterlockedAnd64 (BYREF Destination AS QUAD, BYVAL Value AS QUAD) AS QUAD
 LOCAL Old AS QUAD
 DO
 Old = Destination
 LOOP WHILE InterlockedCompareExchange64(Destination, Old AND Value, Old) <> Old
 FUNCTION = Old
END FUNCTION
'FORCEINLINE
'LONGLONG
'InterlockedOr64 (
' )
'{
' LONGLONG Old;
' do {
' Old = *Destination;
' } while (InterlockedCompareExchange64(Destination,
' Old | Value,
' Old) != Old);
' return Old;
'}
FUNCTION InterlockedOr64 (BYREF Destination AS QUAD, BYVAL Value AS QUAD) AS QUAD
 LOCAL Old AS QUAD
 DO
 Old = Destination
 LOOP WHILE InterlockedCompareExchange64(Destination, Old OR Value, Old) <> Old
 FUNCTION = Old
END FUNCTION
'FORCEINLINE
'LONGLONG
'InterlockedXor64 (
' )
'{
' LONGLONG Old;
' do {
' Old = *Destination;
' } while (InterlockedCompareExchange64(Destination,
' Old ^ Value,
' Old) != Old);
' return Old;
'}
FUNCTION InterlockedXor64 (BYREF Destination AS QUAD, BYVAL Value AS QUAD) AS QUAD
 LOCAL Old AS QUAD
 DO
 Old = Destination
 LOOP WHILE InterlockedCompareExchange64(Destination, Old XOR Value, Old) <> Old
 FUNCTION = Old
END FUNCTION
'FORCEINLINE
'LONGLONG
'InterlockedIncrement64 (
' )
'{
' LONGLONG Old;
' do {
' Old = *Addend;
' } while (InterlockedCompareExchange64(Addend,
' Old + 1,
' Old) != Old);
' return Old + 1;
'}
FUNCTION InterlockedIncrement64 (BYREF Addend AS QUAD) AS QUAD
 LOCAL Old AS QUAD
 DO
 Old = Addend
 LOOP WHILE InterlockedCompareExchange64(Addend, Old + 1, Old) <> Old
 FUNCTION = Old + 1
END FUNCTION
'FORCEINLINE
'LONGLONG
'InterlockedDecrement64 (
' )
'{
' LONGLONG Old;
' do {
' Old = *Addend;
' } while (InterlockedCompareExchange64(Addend,
' Old - 1,
' Old) != Old);
' return Old - 1;
'}
FUNCTION InterlockedDecrement64 (BYREF Addend AS QUAD) AS QUAD
 LOCAL Old AS QUAD
 DO
 Old = Addend
 LOOP WHILE InterlockedCompareExchange64(Addend, Old - 1, Old) <> Old
 FUNCTION = Old - 1
END FUNCTION
'FORCEINLINE
'LONGLONG
'InterlockedExchange64 (
' )
'{
' LONGLONG Old;
' do {
' Old = *Target;
' } while (InterlockedCompareExchange64(Target,
' Value,
' Old) != Old);
' return Old;
'}
FUNCTION InterlockedExchange64 (BYREF Target AS QUAD, BYVAL Value AS QUAD) AS QUAD
 LOCAL Old AS QUAD
 DO
 Old = Target
 LOOP WHILE InterlockedCompareExchange64(Target, Value, Old) <> Old
 FUNCTION = Old
END FUNCTION
'FORCEINLINE
'LONGLONG
'InterlockedExchangeAdd64(
' )
'{
' LONGLONG Old;
' do {
' Old = *Addend;
' } while (InterlockedCompareExchange64(Addend,
' Old + Value,
' Old) != Old);
' return Old;
'}
FUNCTION InterlockedExchangeAdd64 (BYREF Addend AS QUAD, BYVAL Value AS QUAD) AS QUAD
 LOCAL Old AS QUAD
 DO
 Old = Addend
 LOOP WHILE InterlockedCompareExchange64(Addend, Old + Value, Old) <> Old
 FUNCTION = Old
END FUNCTION
'#endif
#ENDIF ' #IF %WINVER >= &H0502
DECLARE SUB InitializeSListHead LIB "kernel32.dll" ALIAS "InitializeSListHead" ( BYREF ListHead AS SLIST_HEADER ) ' void
DECLARE FUNCTION InterlockedPopEntrySList LIB "kernel32.dll" ALIAS "InterlockedPopEntrySList" ( BYREF ListHead AS SLIST_HEADER ) AS QUAD ' PSLIST_ENTRY
DECLARE FUNCTION InterlockedPushEntrySList LIB "kernel32.dll" ALIAS "InterlockedPushEntrySList" ( BYREF ListHead AS SLIST_HEADER,
 BYREF ListEntry AS SLIST_ENTRY
 ) AS DWORD ' PSLIST_ENTRY
DECLARE FUNCTION InterlockedFlushSList LIB "kernel32.dll" ALIAS "InterlockedFlushSList" ( BYREF ListHead AS SLIST_HEADER ) AS QUAD ' PSLIST_ENTRY
DECLARE FUNCTION QueryDepthSList LIB "kernel32.dll" ALIAS "QueryDepthSList" ( BYREF ListHead AS SLIST_HEADER ) AS WORD ' USHORT
#ENDIF ' #IF NOT %DEF(%NTOS) ------------------------------------------------
#ENDIF ' #IF NOT %DEF(%NOWINBASEINTERLOCK) ----------------------------------
DECLARE FUNCTION FreeResource LIB "kernel32.dll" ALIAS "FreeResource" ( BYVAL hResData AS QUAD ) AS LONG
DECLARE FUNCTION LockResource LIB "kernel32.dll" ALIAS "LockResource" ( BYVAL hResData AS QUAD
 ) AS DWORD
'#define UnlockResource(hResData) ((hResData), 0)
'#define MAXINTATOM 0xC000
'#define MAKEINTATOM(i) (LPTSTR)((ULONG_PTR)((WORD)(i)))
'#define INVALID_ATOM ((ATOM)0)
%EQUATE `MAXINTATOM = &HC000
%EQUATE `INVALID_ATOM = 0
DECLARE FUNCTION FreeLibrary LIB "kernel32.dll" ALIAS "FreeLibrary" ( BYVAL hLibModule AS QUAD ) AS LONG
DECLARE SUB FreeLibraryAndExitThread LIB "kernel32.dll" ALIAS "FreeLibraryAndExitThread" ( BYVAL hLibModule AS QUAD
 , BYVAL dwExitCode AS DWORD
 ) ' void
DECLARE FUNCTION DisableThreadLibraryCalls LIB "kernel32.dll" ALIAS "DisableThreadLibraryCalls" ( BYVAL hLibModule AS QUAD ) AS LONG
DECLARE FUNCTION GetProcAddress LIB "kernel32.dll" ALIAS "GetProcAddress" ( BYVAL hModule AS QUAD
 , BYREF lpProcName AS ASCIIZ
 ) AS LONG ' FARPROC
DECLARE FUNCTION GetVersion LIB "kernel32.dll" ALIAS "GetVersion" ( ) AS QUAD
DECLARE FUNCTION GlobalAlloc LIB "kernel32.dll" ALIAS "GlobalAlloc" ( BYVAL uFlags AS QUAD , BYVAL dwBytes AS QUAD
 ) AS DWORD ' HGLOBAL
DECLARE FUNCTION GlobalReAlloc LIB "kernel32.dll" ALIAS "GlobalReAlloc" ( BYVAL hMem AS QUAD , BYVAL dwBytes AS QUAD , BYVAL uFlags AS QUAD ) AS QUAD ' HGLOBAL
DECLARE FUNCTION GlobalSize LIB "kernel32.dll" ALIAS "GlobalSize" ( BYVAL hMem AS QUAD ) AS QUAD ' SIZE_T
DECLARE FUNCTION GlobalFlags LIB "kernel32.dll" ALIAS "GlobalFlags" ( BYVAL hMem AS QUAD ) AS QUAD ' UINT
DECLARE FUNCTION GlobalLock LIB "kernel32.dll" ALIAS "GlobalLock" ( BYVAL hMem AS QUAD ) AS QUAD
DECLARE FUNCTION GlobalHandle LIB "kernel32.dll" ALIAS "GlobalHandle" ( BYVAL pMem AS QUAD
 ) AS DWORD ' HGLOBAL
DECLARE FUNCTION GlobalUnlock LIB "kernel32.dll" ALIAS "GlobalUnlock" ( BYVAL hMem AS QUAD ) AS LONG
DECLARE FUNCTION GlobalFree LIB "kernel32.dll" ALIAS "GlobalFree" ( BYVAL hMem AS QUAD
 ) AS DWORD ' HGLOBAL
DECLARE FUNCTION GlobalCompact LIB "kernel32.dll" ALIAS "GlobalCompact" ( BYVAL dwMinFree AS QUAD ) AS QUAD ' SIZE_T
DECLARE SUB GlobalFix LIB "kernel32.dll" ALIAS "GlobalFix" ( BYVAL hMem AS QUAD ) ' void
DECLARE SUB GlobalUnfix LIB "kernel32.dll" ALIAS "GlobalUnfix" ( BYVAL hMem AS QUAD ) ' void
DECLARE FUNCTION GlobalWire LIB "kernel32.dll" ALIAS "GlobalWire" ( BYVAL hMem AS QUAD ) AS QUAD
DECLARE FUNCTION GlobalUnWire LIB "kernel32.dll" ALIAS "GlobalUnWire" ( BYVAL hMem AS QUAD
 ) AS LONG
DECLARE SUB GlobalMemoryStatus LIB "kernel32.dll" ALIAS "GlobalMemoryStatus" ( BYREF lpBuffer AS MEMORYSTATUS
 ) ' void
' // Size = 64 bytes
TYPE MEMORYSTATUSEX QWORD FILL ' Must be 8 byte aligned
 dwLength AS DWORD ' DWORD dwLength
 dwMemoryLoad AS DWORD ' DWORD dwMemoryLoad
 ullTotalPhys AS QUAD ' DWORDLONG ullTotalPhys
 ullAvailPhys AS QUAD ' DWORDLONG ullAvailPhys
 ullTotalPageFile AS QUAD ' DWORDLONG ullTotalPageFile
 ullAvailPageFile AS QUAD ' DWORDLONG ullAvailPageFile
 ullTotalVirtual AS QUAD ' DWORDLONG ullTotalVirtual
 ullAvailVirtual AS QUAD ' DWORDLONG ullAvailVirtual
 ullAvailExtendedVirtual AS QUAD ' DWORDLONG ullAvailExtendedVirtual
END TYPE
DECLARE FUNCTION GlobalMemoryStatusEx LIB "kernel32.dll" ALIAS "GlobalMemoryStatusEx" ( BYREF lpBuffer AS MEMORYSTATUSEX ) AS LONG
DECLARE FUNCTION LocalAlloc LIB "kernel32.dll" ALIAS "LocalAlloc" ( BYVAL uFlags AS QUAD
 , BYVAL uBytes AS DWORD
 ) AS DWORD ' HLOCAL
DECLARE FUNCTION LocalReAlloc LIB "kernel32.dll" ALIAS "LocalReAlloc" ( BYVAL hMem AS QUAD , BYVAL uBytes AS QUAD , BYVAL uFlags AS QUAD ) AS QUAD ' HLOCAL
DECLARE FUNCTION LocalLock LIB "kernel32.dll" ALIAS "LocalLock" ( BYVAL hMem AS QUAD ) AS QUAD
DECLARE FUNCTION LocalHandle LIB "kernel32.dll" ALIAS "LocalHandle" ( BYVAL pMem AS QUAD
 ) AS DWORD ' HLOCAL
DECLARE FUNCTION LocalUnlock LIB "kernel32.dll" ALIAS "LocalUnlock" ( BYVAL hMem AS QUAD ) AS LONG
DECLARE FUNCTION LocalSize LIB "kernel32.dll" ALIAS "LocalSize" ( BYVAL hMem AS QUAD
 ) AS DWORD ' SIZE_T
DECLARE FUNCTION LocalFlags LIB "kernel32.dll" ALIAS "LocalFlags" ( BYVAL hMem AS QUAD ) AS QUAD ' UINT
DECLARE FUNCTION LocalFree LIB "kernel32.dll" ALIAS "LocalFree" ( BYVAL hMem AS QUAD ) AS QUAD ' HLOCAL
DECLARE FUNCTION LocalShrink LIB "kernel32.dll" ALIAS "LocalShrink" ( BYVAL hMem AS QUAD , BYVAL cbNewSize AS QUAD ) AS QUAD ' SIZE_T
DECLARE FUNCTION LocalCompact LIB "kernel32.dll" ALIAS "LocalCompact" ( BYVAL uMinFree AS QUAD ) AS QUAD ' SIZE_T
DECLARE FUNCTION FlushInstructionCache LIB "kernel32.dll" ALIAS "FlushInstructionCache" ( BYVAL hProcess AS QUAD , BYVAL lpBaseAddress AS QUAD , BYVAL dwSize AS QUAD ) AS LONG
'#if (_WIN32_WINNT >= 0x0600)
#IF %WINVER >= &H0600
DECLARE SUB FlushProcessWriteBuffers LIB "kernel32.dll" ALIAS "FlushProcessWriteBuffers" ( ) ' void
DECLARE FUNCTION QueryThreadCycleTime LIB "kernel32.dll" ALIAS "QueryThreadCycleTime" ( BYVAL ThreadHandle AS QUAD , BYREF CycleTime AS QUAD ) AS LONG
DECLARE FUNCTION QueryProcessCycleTime LIB "kernel32.dll" ALIAS "QueryProcessCycleTime" ( BYVAL ProcessHandle AS QUAD
 , BYREF CycleTime AS QUAD
 ) AS LONG
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION QueryIdleProcessorCycleTime LIB "Kernel32.dll" ALIAS "QueryIdleProcessorCycleTime" (BufferLength AS QUAD, BYVAL ProcessorIdleCycleTime AS QUAD PTR) AS LONG
#ELSE
DECLARE FUNCTION QueryIdleProcessorCycleTime LIB "kernel32.dll" ALIAS "QueryIdleProcessorCycleTime" ( BYREF BufferLength AS QUAD , BYREF ProcessorIdleCycleTime AS QUAD ) AS LONG
#ENDIF
#ENDIF ' #if (_WIN32_WINNT >= 0x0600)
'#if (_WIN32_WINNT >= 0x0601)
#IF %WINVER >= &H0601
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION QueryIdleProcessorCycleTimeEx LIB "Kernel32.dll" ALIAS "QueryIdleProcessorCycleTimeEx" (BYVAL Group AS WORD, BufferLength AS QUAD, BYVAL ProcessorIdleCycleTime AS QUAD PTR) AS LONG
#ELSE
DECLARE FUNCTION QueryIdleProcessorCycleTimeEx LIB "kernel32.dll" ALIAS "QueryIdleProcessorCycleTimeEx" ( BYVAL Group AS WORD , BYREF BufferLength AS QUAD , BYREF ProcessorIdleCycleTime AS QUAD ) AS LONG
#ENDIF
DECLARE FUNCTION QueryUnbiasedInterruptTime LIB "kernel32.dll" ALIAS "QueryUnbiasedInterruptTime" ( BYREF UnbiasedTime AS QUAD ) AS LONG
DECLARE FUNCTION GetProcessorSystemCycleTime LIB "kernel32.dll" ALIAS "GetProcessorSystemCycleTime" ( BYVAL Group AS WORD
 , BYREF Buffer AS ANY
 , BYREF ReturnedLength AS DWORD
 ) AS LONG
#ENDIF ' // (_WIN32_WINNT >= 0x0601)
DECLARE FUNCTION VirtualAlloc LIB "kernel32.dll" ALIAS "VirtualAlloc" ( BYVAL lpAddress AS QUAD , BYVAL dwSize AS QUAD , BYVAL flAllocationType AS QUAD , BYVAL flProtect AS QUAD ) AS QUAD
DECLARE FUNCTION VirtualFree LIB "kernel32.dll" ALIAS "VirtualFree" ( BYVAL lpAddress AS QUAD
 , BYVAL dwSize AS DWORD
 , BYVAL dwFreeType AS DWORD
 ) AS LONG
DECLARE FUNCTION VirtualProtect LIB "kernel32.dll" ALIAS "VirtualProtect" ( BYVAL lpAddress AS DWORD
 , BYVAL dwSize AS DWORD
 , BYVAL flNewProtect AS DWORD
 , BYREF lpflOldProtect AS DWORD
 ) AS LONG
DECLARE FUNCTION VirtualQuery LIB "kernel32.dll" ALIAS "VirtualQuery" ( BYVAL lpAddress AS DWORD
 , BYREF lpBuffer AS MEMORY_BASIC_INFORMATION
 , BYVAL dwLength AS DWORD
 ) AS DWORD ' SIZE_T
DECLARE FUNCTION VirtualAllocEx LIB "kernel32.dll" ALIAS "VirtualAllocEx" ( BYVAL hProcess AS QUAD , BYVAL lpAddress AS QUAD , BYVAL dwSize AS QUAD , BYVAL flAllocationType AS QUAD , BYVAL flProtect AS QUAD ) AS QUAD
'#if _WIN32_WINNT >= 0x0600
#IF %WINVER >= &H0600
DECLARE FUNCTION VirtualAllocExNuma LIB "kernel32.dll" ALIAS "VirtualAllocExNuma" ( BYVAL hProcess AS QUAD , BYVAL lpAddress AS QUAD , BYVAL dwSize AS QUAD , BYVAL flAllocationType AS QUAD , BYVAL flProtect AS QUAD , BYVAL nndPreferred AS QUAD ) AS QUAD
#ENDIF ' // _WIN32_WINNT >= 0x0600
DECLARE FUNCTION GetWriteWatch LIB "kernel32.dll" ALIAS "GetWriteWatch" ( BYVAL dwFlags AS QUAD , BYVAL lpBaseAddress AS QUAD , BYVAL dwRegionSize AS QUAD , BYREF lpAddresses AS ANY , BYREF lpdwCount AS QUAD , BYREF lpdwGranularity AS QUAD ) AS QUAD ' UINT
DECLARE FUNCTION ResetWriteWatch LIB "kernel32.dll" ALIAS "ResetWriteWatch" ( BYVAL lpBaseAddress AS QUAD , BYVAL dwRegionSize AS QUAD ) AS QUAD ' UINT
DECLARE FUNCTION GetLargePageMinimum LIB "kernel32.dll" ALIAS "GetLargePageMinimum" ( ) AS QUAD ' SIZE_T
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION EnumSystemFirmwareTables LIB "Kernel32.dll" ALIAS "EnumSystemFirmwareTables" (BYVAL FirmwareTableProviderSignature AS QUAD, BYVAL pFirmwareTableEnumBuffer AS QUAD, BYVAL BufferSize AS QUAD) AS QUAD
#ELSE
DECLARE FUNCTION EnumSystemFirmwareTables LIB "kernel32.dll" ALIAS "EnumSystemFirmwareTables" ( BYVAL FirmwareTableProviderSignature AS QUAD , BYREF pFirmwareTableEnumBuffer AS ANY , BYVAL BufferSize AS QUAD ) AS QUAD ' UINT
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION GetSystemFirmwareTable LIB "Kernel32.dll" ALIAS "GetSystemFirmwareTable" (BYVAL FirmwareTableProviderSignature AS QUAD, BYVAL FirmwareTableID AS QUAD, BYVAL pFirmwareTableBuffer AS QUAD, BYVAL BufferSize AS QUAD) AS QUAD
#ELSE
DECLARE FUNCTION GetSystemFirmwareTable LIB "kernel32.dll" ALIAS "GetSystemFirmwareTable" ( BYVAL FirmwareTableProviderSignature AS QUAD , BYVAL FirmwareTableID AS QUAD , BYREF pFirmwareTableBuffer AS ANY , BYVAL BufferSize AS QUAD ) AS QUAD ' UINT
#ENDIF
DECLARE FUNCTION GetPhysicallyInstalledSystemMemory LIB "kernel32.dll" ALIAS "GetPhysicallyInstalledSystemMemory" ( BYREF TotalMemoryInKilobytes AS QUAD ) AS LONG
DECLARE FUNCTION VirtualFreeEx LIB "kernel32.dll" ALIAS "VirtualFreeEx" ( BYVAL hProcess AS QUAD
 , BYVAL lpAddress AS DWORD
 , BYVAL dwSize AS DWORD
 , BYVAL dwFreeType AS DWORD
 ) AS LONG
DECLARE FUNCTION VirtualProtectEx LIB "kernel32.dll" ALIAS "VirtualProtectEx" ( BYVAL hProcess AS DWORD
 , BYVAL lpAddress AS DWORD
 , BYVAL dwSize AS DWORD
 , BYVAL flNewProtect AS DWORD
 , BYREF lpflOldProtect AS DWORD
 ) AS LONG
DECLARE FUNCTION VirtualQueryEx LIB "kernel32.dll" ALIAS "VirtualQueryEx" ( BYVAL hProcess AS DWORD
 , BYVAL lpAddress AS DWORD
 , BYREF lpBuffer AS MEMORY_BASIC_INFORMATION
 , BYVAL dwLength AS DWORD
 ) AS DWORD ' SIZE_T
DECLARE FUNCTION HeapCreate LIB "kernel32.dll" ALIAS "HeapCreate" ( BYVAL flOptions AS QUAD , BYVAL dwInitialSize AS QUAD , BYVAL dwMaximumSize AS QUAD ) AS QUAD
DECLARE FUNCTION HeapDestroy LIB "kernel32.dll" ALIAS "HeapDestroy" ( BYVAL hHeap AS QUAD
 ) AS LONG
DECLARE FUNCTION HeapAlloc LIB "kernel32.dll" ALIAS "HeapAlloc" ( BYVAL hHeap AS DWORD
 , BYVAL dwFlags AS DWORD
 , BYVAL dwBytes AS DWORD
 ) AS DWORD
DECLARE FUNCTION HeapReAlloc LIB "kernel32.dll" ALIAS "HeapReAlloc" ( BYVAL hHeap AS DWORD
 , BYVAL dwFlags AS DWORD
 , BYVAL lpMem AS DWORD
 , BYVAL dwBytes AS DWORD
 ) AS DWORD
DECLARE FUNCTION HeapFree LIB "kernel32.dll" ALIAS "HeapFree" ( BYVAL hHeap AS DWORD
 , BYVAL dwFlags AS DWORD
 , BYVAL lpMem AS DWORD
 ) AS LONG
DECLARE FUNCTION HeapSize LIB "kernel32.dll" ALIAS "HeapSize" ( BYVAL hHeap AS DWORD
 , BYVAL dwFlags AS DWORD
 , BYVAL lpMem AS DWORD
 ) AS DWORD ' SIZE_T
DECLARE FUNCTION HeapValidate LIB "kernel32.dll" ALIAS "HeapValidate" ( BYVAL hHeap AS QUAD , BYVAL dwFlags AS QUAD , BYVAL lpMem AS QUAD ) AS LONG
DECLARE FUNCTION HeapCompact LIB "kernel32.dll" ALIAS "HeapCompact" ( BYVAL hHeap AS QUAD
 , BYVAL dwFlags AS DWORD
 ) AS DWORD ' SIZE_T
DECLARE FUNCTION GetProcessHeap LIB "kernel32.dll" ALIAS "GetProcessHeap" ( ) AS QUAD
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION GetProcessHeaps LIB "Kernel32.dll" ALIAS "GetProcessHeaps" (BYVAL NumberOfHeaps AS QUAD, BYVAL ProcessHeaps AS QUAD) AS QUAD
#ELSE
DECLARE FUNCTION GetProcessHeaps LIB "kernel32.dll" ALIAS "GetProcessHeaps" ( BYVAL NumberOfHeaps AS QUAD , BYREF ProcessHeaps AS QUAD ) AS QUAD
#ENDIF
' // Size = 16 bytes
TYPE PROCESS_HEAP_ENTRY_Block DWORD
 hMem AS DWORD
 dwReserved(2) AS DWORD
END TYPE
' // Size = 16 bytes
TYPE PROCESS_HEAP_ENTRY_Region DWORD
 dwCommittedSize AS DWORD
 dwUnCommittedSize AS DWORD
 lpFirstBlock AS DWORD
 lpLastBlock AS DWORD
END TYPE
' // Size = 16 bytes
UNION PROCESS_HEAP_ENTRY_UNION DWORD
 PROCESS_HEAP_ENTRY_Block
 PROCESS_HEAP_ENTRY_Region
END UNION
' // Size = 28 bytes
TYPE PROCESS_HEAP_ENTRY DWORD FILL
 lpData AS DWORD
 cbData AS DWORD
 cbOverhead AS BYTE
 iRegionIndex AS BYTE
 wFlags AS WORD
 PROCESS_HEAP_ENTRY_UNION
END TYPE
%EQUATE `PROCESS_HEAP_REGION = &H0001
%EQUATE `PROCESS_HEAP_UNCOMMITTED_RANGE = &H0002
%EQUATE `PROCESS_HEAP_ENTRY_BUSY = &H0004
%EQUATE `PROCESS_HEAP_ENTRY_MOVEABLE = &H0010
%EQUATE `PROCESS_HEAP_ENTRY_DDESHARE = &H0020
DECLARE FUNCTION HeapLock LIB "kernel32.dll" ALIAS "HeapLock" ( BYVAL hHeap AS QUAD ) AS LONG
DECLARE FUNCTION HeapUnlock LIB "kernel32.dll" ALIAS "HeapUnlock" ( BYVAL hHeap AS QUAD
 ) AS LONG
DECLARE FUNCTION HeapWalk LIB "kernel32.dll" ALIAS "HeapWalk" ( BYVAL hHeap AS DWORD
 , BYREF lpEntry AS PROCESS_HEAP_ENTRY
 ) AS LONG
DECLARE FUNCTION HeapSetInformation LIB "kernel32.dll" ALIAS "HeapSetInformation" ( BYVAL HeapHandle AS DWORD
 , BYVAL HeapInformationClass AS LONG
 , BYREF HeapInformation AS ANY
 , BYVAL HeapInformationLength AS DWORD
 ) AS LONG
DECLARE FUNCTION HeapQueryInformation LIB "kernel32.dll" ALIAS "HeapQueryInformation" ( BYVAL HeapHandle AS DWORD
 , BYVAL HeapInformationClass AS LONG
 , BYREF HeapInformation AS ANY
 , BYVAL HeapInformationLength AS DWORD
 , BYREF ReturnLength AS DWORD
 ) AS LONG
'// GetBinaryType return values.
%EQUATE `SCS_32BIT_BINARY = 0
%EQUATE `SCS_DOS_BINARY = 1
%EQUATE `SCS_WOW_BINARY = 2
%EQUATE `SCS_PIF_BINARY = 3
%EQUATE `SCS_POSIX_BINARY = 4
%EQUATE `SCS_OS216_BINARY = 5
%EQUATE `SCS_64BIT_BINARY = 6
'#if defined(_WIN64)
'# define SCS_THIS_PLATFORM_BINARY SCS_64BIT_BINARY
'#else
'# define SCS_THIS_PLATFORM_BINARY SCS_32BIT_BINARY
'#endif
DECLARE FUNCTION GetBinaryTypeA LIB "kernel32.dll" ALIAS "GetBinaryTypeA" ( BYREF lpApplicationName AS ASCIIZ , BYREF lpBinaryType AS QUAD ) AS LONG
DECLARE FUNCTION GetBinaryTypeW LIB "kernel32.dll" ALIAS "GetBinaryTypeW" ( BYREF lpApplicationName AS WSTRINGZ
 , BYREF lpBinaryType AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO GetBinaryType = GetBinaryTypeW
#ELSE
 MACRO GetBinaryType = GetBinaryTypeA
#ENDIF
DECLARE FUNCTION GetShortPathNameA LIB "kernel32.dll" ALIAS "GetShortPathNameA" ( BYREF lpszLongPath AS ASCIIZ , BYREF lpszShortPath AS ASCIIZ , BYVAL cchBuffer AS QUAD ) AS QUAD
DECLARE FUNCTION GetShortPathNameW LIB "kernel32.dll" ALIAS "GetShortPathNameW" ( BYREF lpszLongPath AS WSTRINGZ
 , BYREF lpszShortPath AS WSTRINGZ
 , BYVAL cchBuffer AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO GetShortPathName = GetShortPathNameW
#ELSE
 MACRO GetShortPathName = GetShortPathNameA
#ENDIF
DECLARE FUNCTION GetLongPathNameA LIB "kernel32.dll" ALIAS "GetLongPathNameA" ( BYREF lpszShortPath AS ASCIIZ , BYREF lpszLongPath AS ASCIIZ , BYVAL cchBuffer AS QUAD ) AS QUAD
DECLARE FUNCTION GetLongPathNameW LIB "kernel32.dll" ALIAS "GetLongPathNameW" ( BYREF lpszShortPath AS WSTRINGZ
 , BYREF lpszLongPath AS WSTRINGZ
 , BYVAL cchBuffer AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO GetLongPathName = GetLongPathNameW
#ELSE
 MACRO GetLongPathName = GetLongPathNameA
#ENDIF
'#if _WIN32_WINNT >= 0x0600
#IF %WINVER >= &H0600
DECLARE FUNCTION GetLongPathNameTransactedA LIB "kernel32.dll" ALIAS "GetLongPathNameTransactedA" ( BYREF lpszShortPath AS ASCIIZ , BYREF lpszLongPath AS ASCIIZ , BYVAL cchBuffer AS QUAD , BYVAL hTransaction AS QUAD ) AS QUAD
DECLARE FUNCTION GetLongPathNameTransactedW LIB "kernel32.dll" ALIAS "GetLongPathNameTransactedW" ( BYREF lpszShortPath AS WSTRINGZ
 , BYREF lpszLongPath AS WSTRINGZ
 , BYVAL cchBuffer AS DWORD
 , BYVAL hTransaction AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO GetLongPathNameTransacted = GetLongPathNameTransactedW
#ELSE
 MACRO GetLongPathNameTransacted = GetLongPathNameTransactedA
#ENDIF
#ENDIF ' // _WIN32_WINNT >= 0x0600
DECLARE FUNCTION GetProcessAffinityMask LIB "kernel32.dll" ALIAS "GetProcessAffinityMask" ( BYVAL hProcess AS QUAD , BYREF lpProcessAffinityMask AS QUAD , BYREF lpSystemAffinityMask AS QUAD ) AS LONG
DECLARE FUNCTION SetProcessAffinityMask LIB "kernel32.dll" ALIAS "SetProcessAffinityMask" ( BYVAL hProcess AS QUAD
 , BYVAL dwProcessAffinityMask AS DWORD
 ) AS LONG
'#if _WIN32_WINNT >= 0x0601
#IF %WINVER >= &H0601
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION GetProcessGroupAffinity LIB "Kernel32.dll" ALIAS "GetProcessGroupAffinity" (BYVAL hProcess AS QUAD, GroupCount AS WORD, BYVAL GroupArray AS WORD PTR) AS LONG
#ELSE
DECLARE FUNCTION GetProcessGroupAffinity LIB "kernel32.dll" ALIAS "GetProcessGroupAffinity" ( BYVAL hProcess AS QUAD , BYREF GroupCount AS WORD , BYREF GroupArray AS WORD ) AS LONG
#ENDIF
#ENDIF ' // _WIN32_WINNT >= 0x0601
'#if _WIN32_WINNT >= 0x0501
DECLARE FUNCTION GetProcessHandleCount LIB "kernel32.dll" ALIAS "GetProcessHandleCount" ( BYVAL hProcess AS QUAD , BYREF pdwHandleCount AS QUAD ) AS LONG
'#endif // (_WIN32_WINNT >= 0x0501)
DECLARE FUNCTION GetProcessTimes LIB "kernel32.dll" ALIAS "GetProcessTimes" ( BYVAL hProcess AS QUAD , BYREF lpCreationTime AS FILETIME , BYREF lpExitTime AS FILETIME , BYREF lpKernelTime AS FILETIME , BYREF lpUserTime AS FILETIME ) AS LONG
DECLARE FUNCTION GetProcessIoCounters LIB "kernel32.dll" ALIAS "GetProcessIoCounters" ( BYVAL hProcess AS QUAD
 , BYREF lpIoCounters AS IO_COUNTERS
 ) AS LONG
DECLARE FUNCTION GetProcessWorkingSetSize LIB "kernel32.dll" ALIAS "GetProcessWorkingSetSize" ( BYVAL hProcess AS DWORD
 , BYREF lpMinimumWorkingSetSize AS DWORD
 , BYREF lpMaximumWorkingSetSize AS DWORD
 ) AS LONG
DECLARE FUNCTION GetProcessWorkingSetSizeEx LIB "kernel32.dll" ALIAS "GetProcessWorkingSetSizeEx" ( BYVAL hProcess AS DWORD
 , BYREF lpMinimumWorkingSetSize AS DWORD
 , BYREF lpMaximumWorkingSetSize AS DWORD
 , BYREF Flags AS DWORD
 ) AS LONG
DECLARE FUNCTION SetProcessWorkingSetSize LIB "kernel32.dll" ALIAS "SetProcessWorkingSetSize" ( BYVAL hProcess AS DWORD
 , BYVAL dwMinimumWorkingSetSize AS DWORD
 , BYVAL dwMaximumWorkingSetSize AS DWORD
 ) AS LONG
DECLARE FUNCTION SetProcessWorkingSetSizeEx LIB "kernel32.dll" ALIAS "SGetProcessWorkingSetSizeEx" ( BYVAL hProcess AS DWORD
 , BYVAL dwMinimumWorkingSetSize AS DWORD
 , BYVAL dwMaximumWorkingSetSize AS DWORD
 , BYVAL Flags AS DWORD
 ) AS LONG
'#if (_WIN32_WINNT >= 0x0600)
#IF %WINVER >= &H0600
%EQUATE `PROCESS_AFFINITY_ENABLE_AUTO_UPDATE = &H00000001
DECLARE FUNCTION SetProcessAffinityUpdateMode LIB "kernel32.dll" ALIAS "SetProcessAffinityUpdateMode" ( BYVAL hProcess AS QUAD , BYVAL Flags AS QUAD ) AS LONG
DECLARE FUNCTION QueryProcessAffinityUpdateMode LIB "kernel32.dll" ALIAS "QueryProcessAffinityUpdateMode" ( BYVAL hProcess AS QUAD
 , BYREF lpdwFlags AS DWORD
 ) AS LONG
'#endif // _WIN32_WINNT >= 0x0600
#ENDIF
DECLARE FUNCTION OpenProcess LIB "kernel32.dll" ALIAS "OpenProcess" ( BYVAL dwDesiredAccess AS QUAD , BYVAL bInheritHandle AS LONG , BYVAL dwProcessId AS QUAD ) AS QUAD
DECLARE FUNCTION GetCurrentProcess LIB "kernel32.dll" ALIAS "GetCurrentProcess" ( ) AS QUAD
DECLARE FUNCTION GetCurrentProcessId LIB "kernel32.dll" ALIAS "GetCurrentProcessId" ( ) AS QUAD
DECLARE SUB ExitProcess LIB "kernel32.dll" ALIAS "ExitProcess" ( BYVAL uExitCode AS QUAD
 ) ' void
DECLARE FUNCTION TerminateProcess LIB "kernel32.dll" ALIAS "TerminateProcess" ( BYVAL hProcess AS QUAD , BYVAL uExitCode AS QUAD ) AS LONG
DECLARE FUNCTION GetExitCodeProcess LIB "kernel32.dll" ALIAS "GetExitCodeProcess" ( BYVAL hProcess AS QUAD
 , BYREF lpExitCode AS DWORD
 ) AS LONG
DECLARE SUB FatalExit LIB "kernel32.dll" ALIAS "FatalExit" ( BYVAL ExitCode AS LONG
 ) ' void
DECLARE FUNCTION GetEnvironmentStringsA LIB "kernel32.dll" ALIAS "GetEnvironmentStringsA" ( ) AS QUAD
DECLARE FUNCTION GetEnvironmentStringsW LIB "kernel32.dll" ALIAS "GetEnvironmentStringsW" ( ) AS QUAD
#IF %DEF(%UNICODE)
 MACRO GetEnvironmentStrings = GetEnvironmentStringsW
#ELSE
 MACRO GetEnvironmentStrings = GetEnvironmentStringsA
#ENDIF
' Requires Windows Vista
DECLARE FUNCTION SetEnvironmentStringsA LIB "kernel32.dll" ALIAS "SetEnvironmentStringsA" ( BYVAL NewEnvironment AS QUAD ) AS LONG
' Requires Windows Vista
DECLARE FUNCTION SetEnvironmentStringsW LIB "kernel32.dll" ALIAS "SetEnvironmentStringsW" ( BYVAL NewEnvironment AS QUAD ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SetEnvironmentStrings = SetEnvironmentStringsW
#ELSE
 MACRO SetEnvironmentStrings = SetEnvironmentStringsA
#ENDIF
DECLARE FUNCTION FreeEnvironmentStringsA LIB "kernel32.dll" ALIAS "FreeEnvironmentStringsA" ( BYVAL lpszEnvironmentBlock AS QUAD ) AS LONG
DECLARE FUNCTION FreeEnvironmentStringsW LIB "kernel32.dll" ALIAS "FreeEnvironmentStringsW" ( BYVAL lpszEnvironmentBlock AS QUAD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO FreeEnvironmentStrings = FreeEnvironmentStringsW
#ELSE
 MACRO FreeEnvironmentStrings = FreeEnvironmentStringsA
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE SUB RaiseException LIB "Kernel32.dll" ALIAS "RaiseException" (BYVAL dwExceptionCode AS QUAD, BYVAL dwExceptionFlags AS QUAD, BYVAL nNumberOfArguments AS QUAD, BYVAL lpArguments AS QUAD)
#ELSE
DECLARE SUB RaiseException LIB "kernel32.dll" ALIAS "RaiseException" ( BYVAL dwExceptionCode AS QUAD , BYVAL dwExceptionFlags AS QUAD , BYVAL nNumberOfArguments AS QUAD , BYREF lpArguments AS QUAD ) ' void
#ENDIF
DECLARE SUB RaiseFailFastException LIB "kernel32.dll" ALIAS "RaiseFailFastException" ( BYREF pExceptionRecord AS EXCEPTION_RECORD , BYREF pContextRecord AS CONTEXT , BYVAL dwFlags AS QUAD ) ' void
'WINBASEAPI
'WINAPI
'UnhandledExceptionFilter(
' );
'FUNCTION UnhandledExceptionFilter ' BYREF ExceptionInfo AS EXCEPTION_POINTERS
' ) AS LONG
'typedef LONG (WINAPI *PTOP_LEVEL_EXCEPTION_FILTER)(
' );
'typedef PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER;
DECLARE FUNCTION SetUnhandledExceptionFilter LIB "kernel32.dll" ALIAS "SetUnhandledExceptionFilter" ( BYVAL lpTopLevelExceptionFilter AS QUAD ) AS QUAD ' LPTOP_LEVEL_EXCEPTION_FILTER
'#if(_WIN32_WINNT >= 0x0400)
'//
'// Fiber creation flags
'//
%EQUATE `FIBER_FLAG_FLOAT_SWITCH = &H1 ' // context switch floating point
DECLARE FUNCTION CreateFiber LIB "kernel32.dll" ALIAS "CreateFiber" ( BYVAL dwStackSize AS QUAD , BYVAL lpStartAddress AS QUAD , BYVAL lpParameter AS QUAD ) AS QUAD
DECLARE FUNCTION CreateFiberEx LIB "kernel32.dll" ALIAS "CreateFiberEx" ( BYVAL dwStackCommitSize AS QUAD
 , BYVAL dwStackReserveSize AS DWORD
 , BYVAL dwFlags AS DWORD
 , BYVAL lpStartAddress AS DWORD
 , BYVAL lpParameter AS DWORD
 ) AS DWORD
DECLARE SUB DeleteFiber LIB "kernel32.dll" ALIAS "DeleteFiber" ( BYVAL lpFiber AS DWORD
 ) ' void
DECLARE FUNCTION ConvertThreadToFiber LIB "kernel32.dll" ALIAS "ConvertThreadToFiber" ( BYVAL lpParameter AS QUAD ) AS QUAD
DECLARE FUNCTION ConvertThreadToFiberEx LIB "kernel32.dll" ALIAS "ConvertThreadToFiberEx" ( BYVAL lpParameter AS QUAD
 , BYVAL dwFlags AS DWORD
 ) AS DWORD
'#if (_WIN32_WINNT >= 0x0501)
DECLARE FUNCTION ConvertFiberToThread LIB "kernel32.dll" ALIAS "ConvertFiberToThread" ( ) AS LONG
'#endif
'#if (_WIN32_WINNT >= 0x0600)
#IF %WINVER >= &H0600
DECLARE FUNCTION IsThreadAFiber LIB "kernel32.dll" ALIAS "IsThreadAFiber" ( ) AS LONG
#ENDIF
DECLARE SUB SwitchToFiber LIB "kernel32.dll" ALIAS "SwitchToFiber" ( BYVAL lpFiber AS QUAD ) ' void
DECLARE FUNCTION SwitchToThread LIB "kernel32.dll" ALIAS "SwitchToThread" ( ) AS LONG
'//
'// UMS begin
'//
'#if (_WIN32_WINNT >= 0x0601) && !defined(MIDL_PASS)
#IF %WINVER >= &H0601
%EQUATE `UMS_VERSION = %RTL_UMS_VERSION
'typedef void *PUMS_CONTEXT;
'typedef void *PUMS_COMPLETION_LIST;
'typedef enum _RTL_UMS_THREAD_INFO_CLASS UMS_THREAD_INFO_CLASS, *PUMS_THREAD_INFO_CLASS;
'typedef enum _RTL_UMS_SCHEDULER_REASON UMS_SCHEDULER_REASON;
'typedef PRTL_UMS_SCHEDULER_ENTRY_POINT PUMS_SCHEDULER_ENTRY_POINT;
' // Size = 16 bytes
TYPE UMS_SCHEDULER_STARTUP_INFO DWORD
 ' // UMS Version the application was built to. Should be set to UMS_VERSION
 UmsVersion AS DWORD ' ULONG
 ' // Completion List to associate the new User Scheduler to.
 CompletionList AS DWORD ' PUMS_COMPLETION_LIST
 ' // A pointer to the application-defined function that represents the starting
 ' // address of the Sheduler.
 SchedulerProc AS DWORD ' PUMS_SCHEDULER_ENTRY_POINT
 ' // pointer to a variable to be passed to the scheduler uppon first activation.
 SchedulerParam AS DWORD
END TYPE
DECLARE FUNCTION CreateUmsCompletionList LIB "kernel32.dll" ALIAS "CreateUmsCompletionList" ( BYREF UmsCompletionList AS ANY ) AS LONG
DECLARE FUNCTION DequeueUmsCompletionListItems LIB "kernel32.dll" ALIAS "DequeueUmsCompletionListItems" ( BYREF UmsCompletionList AS ANY
 , BYVAL WaitTimeOut AS DWORD
 , BYREF UmsThreadList AS ANY
 ) AS LONG
DECLARE FUNCTION GetUmsCompletionListEvent LIB "kernel32.dll" ALIAS "GetUmsCompletionListEvent" ( BYREF UmsCompletionList AS ANY
 , BYREF UmsCompletionEvent AS DWORD
 ) AS LONG
DECLARE FUNCTION ExecuteUmsThread LIB "kernel32.dll" ALIAS "ExecuteUmsThread" ( BYREF UmsThread AS ANY
 ) AS LONG
DECLARE FUNCTION UmsThreadYield LIB "kernel32.dll" ALIAS "UmsThreadYield" ( BYREF SchedulerParam AS ANY
 ) AS LONG
DECLARE FUNCTION DeleteUmsCompletionList LIB "kernel32.dll" ALIAS "DeleteUmsCompletionList" ( BYREF UmsCompletionList AS ANY
 ) AS LONG
DECLARE FUNCTION GetCurrentUmsThread LIB "kernel32.dll" ALIAS "GetCurrentUmsThread" ( ) AS DWORD ' PUMS_CONTEXT
DECLARE FUNCTION GetNextUmsListItem LIB "kernel32.dll" ALIAS "GetNextUmsListItem" ( BYREF UmsContext AS ANY ) AS QUAD ' PUMS_CONTEXT
DECLARE FUNCTION QueryUmsThreadInformation LIB "kernel32.dll" ALIAS "QueryUmsThreadInformation" ( BYREF UmsThread AS ANY , BYVAL UmsThreadInfoClass AS LONG , BYREF UmsThreadInformation AS ANY , BYVAL UmsThreadInformationLength AS QUAD , BYREF ReturnLength AS QUAD ) AS LONG
DECLARE FUNCTION SetUmsThreadInformation LIB "kernel32.dll" ALIAS "SetUmsThreadInformation" ( BYREF UmsThread AS ANY
 , BYVAL UmsThreadInfoClass AS LONG
 , BYREF UmsThreadInformation AS ANY
 , BYVAL UmsThreadInformationLength AS DWORD
 ) AS LONG
DECLARE FUNCTION DeleteUmsThreadContext LIB "kernel32.dll" ALIAS "DeleteUmsThreadContext" ( BYREF UmsThread AS ANY
 ) AS LONG
DECLARE FUNCTION CreateUmsThreadContext LIB "kernel32.dll" ALIAS "CreateUmsThreadContext" ( BYREF lpUmsThread AS ANY
 ) AS LONG
DECLARE FUNCTION EnterUmsSchedulingMode LIB "kernel32.dll" ALIAS "EnterUmsSchedulingMode" ( BYREF SchedulerStartupInfo AS UMS_SCHEDULER_STARTUP_INFO
 ) AS LONG
#ENDIF ' // (_WIN32_WINNT >= 0x0601) && !defined(MIDL_PASS)
'typedef struct _PROC_THREAD_ATTRIBUTE_LIST *PPROC_THREAD_ATTRIBUTE_LIST, *LPPROC_THREAD_ATTRIBUTE_LIST;
'//
'// UMS end
'//
'#endif /* _WIN32_WINNT >= 0x0400 */
DECLARE FUNCTION CreateThread LIB "kernel32.dll" ALIAS "CreateThread" ( BYREF lpThreadAttributes AS SECURITY_ATTRIBUTES , BYVAL dwStackSize AS QUAD , BYVAL lpStartAddress AS QUAD , BYVAL lpParameter AS QUAD , BYVAL dwCreationFlags AS QUAD , BYREF lpThreadId AS QUAD ) AS QUAD
DECLARE FUNCTION CreateRemoteThread LIB "kernel32.dll" ALIAS "CreateRemoteThread" ( BYVAL hProcess AS QUAD
 , BYREF lpThreadAttributes AS SECURITY_ATTRIBUTES
 , BYVAL dwStackSize AS DWORD
 , BYVAL lpStartAddress AS DWORD
 , BYVAL lpParameter AS DWORD
 , BYVAL dwCreationFlags AS DWORD
 , BYREF lpThreadId AS DWORD
 ) AS DWORD
DECLARE FUNCTION CreateRemoteThreadEx LIB "kernel32.dll" ALIAS "CreateRemoteThreadEx" ( BYVAL hProcess AS DWORD
 , BYREF lpThreadAttributes AS SECURITY_ATTRIBUTES
 , BYVAL dwStackSize AS DWORD
 , BYVAL lpStartAddress AS DWORD
 , BYVAL lpParameter AS DWORD
 , BYVAL dwCreationFlags AS DWORD
 , BYVAL lpAttributeList AS DWORD
 , BYREF lpThreadId AS DWORD
 ) AS DWORD
DECLARE FUNCTION GetCurrentThread LIB "kernel32.dll" ALIAS "GetCurrentThread" ( ) AS DWORD
DECLARE FUNCTION GetCurrentThreadId LIB "kernel32.dll" ALIAS "GetCurrentThreadId" ( ) AS DWORD
DECLARE FUNCTION SetThreadStackGuarantee LIB "kernel32.dll" ALIAS "SetThreadStackGuarantee" ( BYREF StackSizeInBytes AS DWORD
 ) AS LONG
DECLARE FUNCTION GetProcessIdOfThread LIB "kernel32.dll" ALIAS "GetProcessIdOfThread" ( BYVAL Thread AS DWORD
 ) AS DWORD
'#if (_WIN32_WINNT >= 0x0502)
DECLARE FUNCTION GetThreadId LIB "kernel32.dll" ALIAS "GetThreadId" ( BYVAL Thread AS QUAD ) AS QUAD
'#endif // _WIN32_WINNT >= 0x0502
DECLARE FUNCTION GetProcessId LIB "kernel32.dll" ALIAS "GetProcessId" ( BYVAL Process AS QUAD ) AS QUAD
DECLARE FUNCTION GetCurrentProcessorNumber LIB "kernel32.dll" ALIAS "GetCurrentProcessorNumber" ( ) AS QUAD
'#if (_WIN32_WINNT >= 0x0601)
#IF %WINVER >= &H0601
DECLARE SUB GetCurrentProcessorNumberEx LIB "kernel32.dll" ALIAS "GetCurrentProcessorNumberEx" ( BYREF ProcNumber AS PROCESSOR_NUMBER )
#ENDIF
'#if (_WIN32_WINNT >= 0x0601)
#IF %WINVER >= &H0601
DECLARE FUNCTION GetThreadGroupAffinity LIB "kernel32.dll" ALIAS "GetThreadGroupAffinity" ( BYVAL hThread AS QUAD , BYREF GroupAffinity AS GROUP_AFFINITY ) AS LONG
#ENDIF ' // _WIN32_WINNT >= 0x0601
DECLARE FUNCTION SetThreadAffinityMask LIB "kernel32.dll" ALIAS "SetThreadAffinityMask" ( BYVAL hThread AS QUAD , BYVAL dwThreadAffinityMask AS QUAD ) AS QUAD ' DWORD_PTR
'#if (_WIN32_WINNT >= 0x0601)
#IF %WINVER >= &H0601
DECLARE FUNCTION SetThreadGroupAffinity LIB "kernel32.dll" ALIAS "SetThreadGroupAffinity" ( BYVAL hThread AS QUAD , BYREF GroupAffinity AS GROUP_AFFINITY , BYREF PreviousGroupAffinity AS GROUP_AFFINITY ) AS LONG
DECLARE FUNCTION SetThreadIdealProcessorEx LIB "kernel32.dll" ALIAS "SetThreadIdealProcessorEx" ( BYVAL hThread AS QUAD
 , BYREF lpIdealProcessor AS PROCESSOR_NUMBER
 , BYREF lpPreviousIdealProcessor AS PROCESSOR_NUMBER
 ) AS LONG
DECLARE FUNCTION GetThreadIdealProcessorEx LIB "kernel32.dll" ALIAS "GetThreadIdealProcessorEx" ( BYVAL hThread AS DWORD
 , BYREF lpIdealProcessor AS PROCESSOR_NUMBER
 ) AS LONG
#ENDIF ' // _WIN32_WINNT >= 0x0601
'#if(_WIN32_WINNT >= 0x0400)
DECLARE FUNCTION SetThreadIdealProcessor LIB "kernel32.dll" ALIAS "SetThreadIdealProcessor" ( BYVAL hThread AS QUAD , BYVAL dwIdealProcessor AS QUAD ) AS QUAD
'#endif /* _WIN32_WINNT >= 0x0400 */
'#if (_WIN32_WINNT >= 0x0600)
#IF %WINVER >= &H0600
%EQUATE `PROCESS_DEP_ENABLE = &H00000001
%EQUATE `PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION = &H00000002
DECLARE FUNCTION SetProcessDEPPolicy LIB "kernel32.dll" ALIAS "SetProcessDEPPolicy" ( BYVAL dwFlags AS QUAD ) AS LONG
DECLARE FUNCTION GetProcessDEPPolicy LIB "kernel32.dll" ALIAS "GetProcessDEPPolicy" ( BYVAL hProcess AS QUAD
 , BYREF lpFlags AS DWORD
 , BYREF lpPermanent AS LONG
 ) AS LONG
'#endif // _WIN32_WINNT >= 0x0600
#ENDIF
DECLARE FUNCTION SetProcessPriorityBoost LIB "kernel32.dll" ALIAS "SetProcessPriorityBoost" ( BYVAL hProcess AS QUAD , BYVAL bDisablePriorityBoost AS LONG ) AS LONG
DECLARE FUNCTION GetProcessPriorityBoost LIB "kernel32.dll" ALIAS "GetProcessPriorityBoost" ( BYVAL hProcess AS QUAD
 , BYREF pDisablePriorityBoost AS LONG
 ) AS LONG
DECLARE FUNCTION RequestWakeupLatency LIB "kernel32.dll" ALIAS "RequestWakeupLatency" ( BYVAL latency AS LONG
 ) AS LONG
DECLARE FUNCTION IsSystemResumeAutomatic LIB "kernel32.dll" ALIAS "IsSystemResumeAutomatic" ( ) AS LONG
DECLARE FUNCTION OpenThread LIB "kernel32.dll" ALIAS "OpenThread" ( BYVAL dwDesiredAccess AS DWORD
 , BYVAL bInheritHandle AS LONG
 , BYVAL dwThreadId AS DWORD
 ) AS DWORD
DECLARE FUNCTION SetThreadPriority LIB "kernel32.dll" ALIAS "SetThreadPriority" ( BYVAL hThread AS DWORD
 , BYVAL nPriority AS LONG
 ) AS LONG
DECLARE FUNCTION SetThreadPriorityBoost LIB "kernel32.dll" ALIAS "SetThreadPriorityBoost" ( BYVAL hThread AS DWORD
 , BYVAL bDisablePriorityBoost AS LONG
 ) AS LONG
DECLARE FUNCTION GetThreadPriorityBoost LIB "kernel32.dll" ALIAS "GetThreadPriorityBoost" ( BYVAL hThread AS DWORD
 , BYREF pDisablePriorityBoost AS LONG
 ) AS LONG
DECLARE FUNCTION GetThreadPriority LIB "kernel32.dll" ALIAS "GetThreadPriority" ( BYVAL hThread AS DWORD
 ) AS LONG ' int
DECLARE FUNCTION GetThreadTimes LIB "kernel32.dll" ALIAS "GetThreadTimes" ( BYVAL hThread AS QUAD , BYREF lpCreationTime AS FILETIME , BYREF lpExitTime AS FILETIME , BYREF lpKernelTime AS FILETIME , BYREF lpUserTime AS FILETIME ) AS LONG
'#if _WIN32_WINNT >= 0x0501
DECLARE FUNCTION GetThreadIOPendingFlag LIB "kernel32.dll" ALIAS "GetThreadIOPendingFlag" ( BYVAL hThread AS QUAD , BYREF lpIOIsPending AS LONG ) AS LONG
'#endif // (_WIN32_WINNT >= 0x0501)
DECLARE SUB ExitThread LIB "kernel32.dll" ALIAS "ExitThread" ( BYVAL dwExitCode AS QUAD ) ' void
DECLARE FUNCTION TerminateThread LIB "kernel32.dll" ALIAS "TerminateThread" ( BYVAL hThread AS QUAD , BYVAL dwExitCode AS QUAD ) AS LONG
DECLARE FUNCTION GetExitCodeThread LIB "kernel32.dll" ALIAS "GetExitCodeThread" ( BYVAL hThread AS QUAD
 , BYREF lpExitCode AS DWORD
 ) AS LONG
DECLARE FUNCTION GetThreadSelectorEntry LIB "kernel32.dll" ALIAS "GetThreadSelectorEntry" ( BYVAL hThread AS DWORD
 , BYVAL dwSelector AS DWORD
 , BYREF lpSelectorEntry AS LDT_ENTRY
 ) AS LONG
DECLARE FUNCTION SetThreadExecutionState LIB "kernel32.dll" ALIAS "SetThreadExecutionState" ( BYVAL esFlags AS DWORD
 ) AS DWORD ' EXECUTION_STATE
'#if (_WIN32_WINNT >= _WIN32_WINNT_WIN7)
#IF %WINVER >= &H0601
' // Size = 16 bytes
TYPE REASON_CONTEXT_Detailed DWORD
 LocalizedReasonModule AS DWORD ' HMODULE
 LocalizedReasonId AS DWORD ' ULONG
 ReasonStringCount AS DWORD ' ULONG
 ReasonStrings AS WSTRINGZ PTR ' LPWSTR*
END TYPE
' // Size = 16 bytes
UNION REASON_CONTEXT_UNION DWORD
 Detailed AS REASON_CONTEXT_Detailed
 SimpleReasonString AS WSTRINGZ PTR
END UNION
' // Size = 24 bytes
TYPE REASON_CONTEXT DWORD
 Version AS DWORD ' ULONG
 Flags AS DWORD
 Reason AS REASON_CONTEXT_UNION
END TYPE
'//
'// Power Request APIs
'//
'typedef REASON_CONTEXT POWER_REQUEST_CONTEXT, *PPOWER_REQUEST_CONTEXT, *LPPOWER_REQUEST_CONTEXT;
DECLARE FUNCTION PowerCreateRequest LIB "kernel32.dll" ALIAS "PowerCreateRequest" ( BYREF Context AS REASON_CONTEXT ) AS QUAD
DECLARE FUNCTION PowerSetRequest LIB "kernel32.dll" ALIAS "PowerSetRequest" ( BYVAL PowerRequest AS QUAD
 , BYVAL RequestType AS LONG
 ) AS LONG
DECLARE FUNCTION PowerClearRequest LIB "kernel32.dll" ALIAS "PowerClearRequest" ( BYVAL PowerRequest AS DWORD
 , BYVAL RequestType AS LONG
 ) AS LONG
#ENDIF ' // (_WIN32_WINNT >= _WIN32_WINNT_WIN7)
DECLARE FUNCTION GetLastError LIB "kernel32.dll" ALIAS "GetLastError" ( ) AS QUAD
DECLARE SUB SetLastError LIB "kernel32.dll" ALIAS "SetLastError" ( BYVAL dwErrCode AS QUAD
 ) ' void
DECLARE SUB RestoreLastError LIB "kernel32.dll" ALIAS "RestoreLastError" ( BYVAL dwErrCode AS QUAD ) ' void
'typedef VOID (WINAPI* PRESTORE_LAST_ERROR)(DWORD);
'#define RESTORE_LAST_ERROR_NAME_A "RestoreLastError"
'#define RESTORE_LAST_ERROR_NAME_W L"RestoreLastError"
'#define RESTORE_LAST_ERROR_NAME TEXT("RestoreLastError")
$RESTORE_LAST_ERROR_NAME_A = "RestoreLastError"
$RESTORE_LAST_ERROR_NAME = "RestoreLastError"
'#endif
'#define HasOverlappedIoCompleted(lpOverlapped) (((DWORD)(lpOverlapped)->Internal) != STATUS_PENDING)
DECLARE FUNCTION GetOverlappedResult LIB "kernel32.dll" ALIAS "GetOverlappedResult" ( BYVAL hFile AS QUAD , BYREF lpOverlapped AS OVERLAPPED , BYREF lpNumberOfBytesTransferred AS LONG , BYVAL bWait AS LONG ) AS LONG
DECLARE FUNCTION CreateIoCompletionPort LIB "kernel32.dll" ALIAS "CreateIoCompletionPort" ( BYVAL FileHandle AS QUAD
 , BYVAL ExistingCompletionPort AS DWORD
 , BYVAL CompletionKey AS DWORD
 , BYVAL NumberOfConcurrentThreads AS DWORD
 ) AS DWORD
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION GetQueuedCompletionStatus LIB "Kernel32.dll" ALIAS "GetQueuedCompletionStatus" (BYVAL CompletionPort AS QUAD, lpNumberOfBytesTransferred AS QUAD, lpCompletionKey AS QUAD, lpOverlapped AS OVERLAPPED, BYVAL dwMilliseconds AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION GetQueuedCompletionStatus LIB "kernel32.dll" ALIAS "GetQueuedCompletionStatus" ( BYVAL CompletionPort AS QUAD , BYREF lpNumberOfBytesTransferred AS QUAD , BYREF lpCompletionKey AS QUAD , BYREF lpOverlapped AS QUAD , BYVAL dwMilliseconds AS QUAD ) AS LONG
#ENDIF
'#if (_WIN32_WINNT >= 0x0600)
#IF %WINVER >= &H0600
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION GetQueuedCompletionStatusEx LIB "Kernel32.dll" ALIAS "GetQueuedCompletionStatusEx" (BYVAL CompletionPort AS QUAD, lpCompletionPortEntries AS QUAD, BYVAL ulCount AS QUAD, ulNumEntriesRemoved AS QUAD, BYVAL dwMilliseconds AS QUAD, BYVAL fAlertable AS LONG) AS LONG
#ELSE
DECLARE FUNCTION GetQueuedCompletionStatusEx LIB "kernel32.dll" ALIAS "GetQueuedCompletionStatusEx" ( BYVAL CompletionPort AS QUAD , BYREF lpCompletionPortEntries AS OVERLAPPED_ENTRY , BYVAL ulCount AS QUAD , BYREF ulNumEntriesRemoved AS QUAD , BYVAL dwMilliseconds AS QUAD , BYVAL fAlertable AS LONG ) AS LONG
#ENDIF
#ENDIF ' // _WIN32_WINNT >= 0x0600
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION PostQueuedCompletionStatus LIB "Kernel32.dll" ALIAS "PostQueuedCompletionStatus" (BYVAL CompletionPort AS QUAD, BYVAL dwNumberOfBytesTransferred AS QUAD, BYVAL dwCompletionKey AS QUAD, lpOverlapped AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION PostQueuedCompletionStatus LIB "kernel32.dll" ALIAS "PostQueuedCompletionStatus" ( BYVAL CompletionPort AS QUAD , BYVAL dwNumberOfBytesTransferred AS QUAD , BYVAL dwCompletionKey AS QUAD , OPTIONAL BYREF lpOverlapped AS OVERLAPPED ) AS LONG
#ENDIF
'#if (_WIN32_WINNT >= 0x0600)
#IF %WINVER >= &H0600
'//
'// The following flags allows an application to change
'// the semantics of IO completion notification.
'//
'//
'// Don't queue an entry to an associated completion port if returning success
'// synchronously.
'//
%EQUATE `FILE_SKIP_COMPLETION_PORT_ON_SUCCESS = &H1
'//
'// Don't set the file handle event on IO completion.
'//
%EQUATE `FILE_SKIP_SET_EVENT_ON_HANDLE = &H2
DECLARE FUNCTION SetFileCompletionNotificationModes LIB "kernel32.dll" ALIAS "SetFileCompletionNotificationModes" ( BYVAL FileHandle AS QUAD , BYVAL Flags AS BYTE ) AS LONG
DECLARE FUNCTION SetFileIoOverlappedRange LIB "kernel32.dll" ALIAS "SetFileIoOverlappedRange" ( BYVAL FileHandle AS QUAD
 , BYVAL OverlappedRangeStart AS BYTE PTR
 , BYVAL Length AS DWORD
 ) AS LONG
#ENDIF ' // _WIN32_WINNT >= 0x0600
%EQUATE `SEM_FAILCRITICALERRORS = &H0001
%EQUATE `SEM_NOALIGNMENTFAULTEXCEPT = &H0004
%EQUATE `SEM_NOGPFAULTERRORBOX = &H0002
%EQUATE `SEM_NOOPENFILEERRORBOX = &H8000
DECLARE FUNCTION GetErrorMode LIB "kernel32.dll" ALIAS "GetErrorMode" ( ) AS QUAD ' UINT
DECLARE FUNCTION SetErrorMode LIB "kernel32.dll" ALIAS "SetErrorMode" ( BYVAL uMode AS QUAD ) AS QUAD ' UINT
'//
'// Thread error mode support
'//
DECLARE FUNCTION GetThreadErrorMode LIB "kernel32.dll" ALIAS "GetThreadErrorMode" ( ) AS QUAD
DECLARE FUNCTION SetThreadErrorMode LIB "kernel32.dll" ALIAS "SetThreadErrorMode" ( BYVAL dwNewMode AS QUAD , BYREF lpOldMode AS QUAD
 ) AS LONG
DECLARE FUNCTION ReadProcessMemory LIB "kernel32.dll" ALIAS "ReadProcessMemory" ( BYVAL hProcess AS DWORD
 , BYVAL lpBaseAddress AS DWORD
 , BYREF lpBuffer AS ANY
 , BYVAL nSize AS DWORD
 , BYREF lpNumberOfBytesRead AS DWORD
 ) AS LONG
DECLARE FUNCTION WriteProcessMemory LIB "kernel32.dll" ALIAS "WriteProcessMemory" ( BYVAL hProcess AS DWORD
 , BYVAL lpBaseAddress AS DWORD
 , BYREF lpBuffer AS ANY
 , BYVAL nSize AS DWORD
 , BYREF lpNumberOfBytesWritten AS DWORD
 ) AS LONG
'#if !defined(MIDL_PASS)
DECLARE FUNCTION GetThreadContext LIB "kernel32.dll" ALIAS "GetThreadContext" ( BYVAL hThread AS QUAD , BYREF lpContext AS CONTEXT ) AS LONG
DECLARE FUNCTION SetThreadContext LIB "kernel32.dll" ALIAS "SetThreadContext" ( BYVAL hThread AS QUAD
 , BYREF lpContext AS CONTEXT
 ) AS LONG
DECLARE FUNCTION Wow64GetThreadContext LIB "kernel32.dll" ALIAS "Wow64GetThreadContext" ( BYVAL hThread AS DWORD
 , BYREF lpContext AS WOW64_CONTEXT
 ) AS LONG
'#if(_WIN32_WINNT >= 0x0601)
#IF %WINVER >= &H0601
DECLARE FUNCTION Wow64GetThreadSelectorEntry LIB "kernel32.dll" ALIAS "Wow64GetThreadSelectorEntry" ( BYVAL hThread AS QUAD , BYVAL dwSelector AS QUAD , BYREF lpSelectorEntry AS WOW64_LDT_ENTRY ) AS LONG
#ENDIF ' /* _WIN32_WINNT >= 0x0601 */
DECLARE FUNCTION Wow64SetThreadContext LIB "kernel32.dll" ALIAS "Wow64SetThreadContext" ( BYVAL hThread AS QUAD , BYREF lpContext AS WOW64_CONTEXT ) AS LONG
'#endif
DECLARE FUNCTION SuspendThread LIB "kernel32.dll" ALIAS "SuspendThread" ( BYVAL hThread AS QUAD ) AS QUAD
DECLARE FUNCTION Wow64SuspendThread LIB "kernel32.dll" ALIAS "Wow64SuspendThread" ( BYVAL hThread AS QUAD
 ) AS DWORD
DECLARE FUNCTION ResumeThread LIB "kernel32.dll" ALIAS "ResumeThread" ( BYVAL hThread AS DWORD
 ) AS DWORD
'#if(_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)
DECLARE FUNCTION QueueUserAPC LIB "kernel32.dll" ALIAS "QueueUserAPC" ( BYVAL pfnAPC AS QUAD , BYVAL hThread AS QUAD , BYVAL dwData AS QUAD ) AS QUAD
'#endif /* _WIN32_WINNT >= 0x0400 || _WIN32_WINDOWS > 0x0400 */
'#if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)
DECLARE FUNCTION IsDebuggerPresent LIB "kernel32.dll" ALIAS "IsDebuggerPresent" ( ) AS LONG
'#endif
'#if _WIN32_WINNT >= 0x0501
DECLARE FUNCTION CheckRemoteDebuggerPresent LIB "kernel32.dll" ALIAS "CheckRemoteDebuggerPresent" ( BYVAL hProcess AS QUAD , BYREF pbDebuggerPresent AS LONG ) AS LONG
'#endif // (_WIN32_WINNT >= 0x0501)
DECLARE SUB DebugBreak LIB "kernel32.dll" ALIAS "DebugBreak" () ' void
DECLARE FUNCTION WaitForDebugEvent LIB "kernel32.dll" ALIAS "WaitForDebugEvent" ( BYREF lpDebugEvent AS DEBUG_EVENT , BYVAL dwMilliseconds AS QUAD ) AS LONG
DECLARE FUNCTION ContinueDebugEvent LIB "kernel32.dll" ALIAS "ContinueDebugEvent" ( BYVAL dwProcessId AS QUAD
 , BYVAL dwThreadId AS DWORD
 , BYVAL dwContinueStatus AS DWORD
 ) AS LONG
DECLARE FUNCTION DebugActiveProcess LIB "kernel32.dll" ALIAS "DebugActiveProcess" ( BYVAL dwProcessId AS DWORD
 ) AS LONG
DECLARE FUNCTION DebugActiveProcessStop LIB "kernel32.dll" ALIAS "DebugActiveProcessStop" ( BYVAL dwProcessId AS DWORD
 ) AS LONG
DECLARE FUNCTION DebugSetProcessKillOnExit LIB "kernel32.dll" ALIAS "DebugSetProcessKillOnExit" ( BYVAL KillOnExit AS LONG
 ) AS LONG
DECLARE FUNCTION DebugBreakProcess LIB "kernel32.dll" ALIAS "DebugBreakProcess" ( BYVAL Process AS DWORD
 ) AS LONG
DECLARE SUB InitializeCriticalSection LIB "kernel32.dll" ALIAS "InitializeCriticalSection" ( BYREF lpCriticalSection AS CRITICAL_SECTION
 ) ' void
DECLARE SUB EnterCriticalSection LIB "kernel32.dll" ALIAS "EnterCriticalSection" ( BYREF lpCriticalSection AS CRITICAL_SECTION ) ' void
DECLARE SUB LeaveCriticalSection LIB "kernel32.dll" ALIAS "LeaveCriticalSection" ( BYREF lpCriticalSection AS CRITICAL_SECTION ) ' void
'#if (_WIN32_WINNT >= 0x0403)
%EQUATE `CRITICAL_SECTION_NO_DEBUG_INFO = %RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO
DECLARE FUNCTION InitializeCriticalSectionAndSpinCount LIB "kernel32.dll" ALIAS "InitializeCriticalSectionAndSpinCount" ( BYREF lpCriticalSection AS CRITICAL_SECTION , BYVAL dwSpinCount AS QUAD ) AS LONG
DECLARE FUNCTION SetCriticalSectionSpinCount LIB "kernel32.dll" ALIAS "SetCriticalSectionSpinCount" ( BYREF lpCriticalSection AS CRITICAL_SECTION
 , BYVAL dwSpinCount AS DWORD
 ) AS DWORD
'#endif
'#if(_WIN32_WINNT >= 0x0400)
DECLARE FUNCTION TryEnterCriticalSection LIB "kernel32.dll" ALIAS "TryEnterCriticalSection" ( BYREF lpCriticalSection AS CRITICAL_SECTION ) AS LONG
'#endif /* _WIN32_WINNT >= 0x0400 */
DECLARE SUB DeleteCriticalSection LIB "kernel32.dll" ALIAS "DeleteCriticalSection" ( BYREF lpCriticalSection AS CRITICAL_SECTION ) ' void
DECLARE FUNCTION SetEvent LIB "kernel32.dll" ALIAS "SetEvent" ( BYVAL hEvent AS QUAD ) AS LONG
DECLARE FUNCTION ResetEvent LIB "kernel32.dll" ALIAS "ResetEvent" ( BYVAL hEvent AS QUAD
 ) AS LONG
DECLARE FUNCTION PulseEvent LIB "kernel32.dll" ALIAS "PulseEvent" ( BYVAL hEvent AS DWORD
 ) AS LONG
DECLARE FUNCTION ReleaseSemaphore LIB "kernel32.dll" ALIAS "ReleaseSemaphore" ( BYVAL hSemaphore AS DWORD
 , BYVAL lReleaseCount AS LONG
 , BYREF lpPreviousCount AS LONG
 ) AS LONG
DECLARE FUNCTION ReleaseMutex LIB "kernel32.dll" ALIAS "ReleaseMutex" ( BYVAL hMutex AS DWORD
 ) AS LONG
DECLARE FUNCTION WaitForSingleObject LIB "kernel32.dll" ALIAS "WaitForSingleObject" ( BYVAL hHandle AS DWORD
 , BYVAL dwMilliseconds AS DWORD
 ) AS DWORD
DECLARE FUNCTION WaitForMultipleObjects LIB "kernel32.dll" ALIAS "WaitForMultipleObjects" ( BYVAL nCount AS DWORD
 , BYREF lpHandles AS DWORD
 , BYVAL bWaitAll AS LONG
 , BYVAL dwMilliseconds AS DWORD
 ) AS DWORD
DECLARE SUB ApiSleep LIB "kernel32.dll" ALIAS "Sleep" ( BYVAL dwMilliseconds AS DWORD
 ) ' void
DECLARE FUNCTION LoadResource LIB "kernel32.dll" ALIAS "LoadResource" ( BYVAL hModule AS QUAD , BYVAL hResInfo AS QUAD ) AS QUAD ' HGLOBAL
DECLARE FUNCTION SizeofResource LIB "kernel32.dll" ALIAS "SizeofResource" ( BYVAL hModule AS QUAD , BYVAL hResInfo AS QUAD ) AS QUAD
DECLARE FUNCTION GlobalDeleteAtom LIB "kernel32.dll" ALIAS "GlobalDeleteAtom" ( BYVAL nAtom AS WORD
 ) AS WORD ' ATOM
DECLARE FUNCTION InitAtomTable LIB "kernel32.dll" ALIAS "InitAtomTable" ( BYVAL nSize AS QUAD ) AS LONG
DECLARE FUNCTION DeleteAtom LIB "kernel32.dll" ALIAS "DeleteAtom" ( BYVAL nAtom AS WORD
 ) AS WORD ' ATOM
DECLARE FUNCTION SetHandleCount LIB "kernel32.dll" ALIAS "SetHandleCount" ( BYVAL uNumber AS QUAD ) AS QUAD ' UINT
DECLARE FUNCTION GetLogicalDrives LIB "kernel32.dll" ALIAS "GetLogicalDrives" ( ) AS QUAD
DECLARE FUNCTION LockFile LIB "kernel32.dll" ALIAS "LockFile" ( BYVAL hFile AS QUAD , BYVAL dwFileOffsetLow AS QUAD
 , BYVAL dwFileOffsetHigh AS DWORD
 , BYVAL nNumberOfBytesToLockLow AS DWORD
 , BYVAL nNumberOfBytesToLockHigh AS DWORD
 ) AS LONG
DECLARE FUNCTION UnlockFile LIB "kernel32.dll" ALIAS "UnlockFile" ( BYVAL hFile AS DWORD
 , BYVAL dwFileOffsetLow AS DWORD
 , BYVAL dwFileOffsetHigh AS DWORD
 , BYVAL nNumberOfBytesToLockLow AS DWORD
 , BYVAL nNumberOfBytesToLockHigh AS DWORD
 ) AS LONG
DECLARE FUNCTION LockFileEx LIB "kernel32.dll" ALIAS "LockFileEx" ( BYVAL hFile AS DWORD
 , BYVAL dwFlags AS DWORD
 , BYVAL dwReserved AS DWORD
 , BYVAL nNumberOfBytesToLockLow AS DWORD
 , BYVAL nNumberOfBytesToLockHigh AS DWORD
 , BYREF lpOverlapped AS OVERLAPPED
 ) AS LONG
%EQUATE `LOCKFILE_FAIL_IMMEDIATELY = &H00000001
%EQUATE `LOCKFILE_EXCLUSIVE_LOCK = &H00000002
DECLARE FUNCTION UnlockFileEx LIB "kernel32.dll" ALIAS "UnlockFileEx" ( BYVAL hFile AS QUAD , BYVAL dwReserved AS QUAD , BYVAL nNumberOfBytesToUnlockLow AS QUAD , BYVAL nNumberOfBytesToUnlockHigh AS QUAD , BYREF lpOverlapped AS OVERLAPPED ) AS LONG
' // Size = 52 bytes
TYPE BY_HANDLE_FILE_INFORMATION DWORD
 dwFileAttributes AS DWORD ' DWORD dwFileAttributes
 ftCreationTime AS FILETIME ' FILETIME ftCreationTime
 ftLastAccessTime AS FILETIME ' FILETIME ftLastAccessTime
 ftLastWriteTime AS FILETIME ' FILETIME ftLastWriteTime
 dwVolumeSerialNumber AS DWORD ' DWORD dwVolumeSerialNumber
 nFileSizeHigh AS DWORD ' DWORD nFileSizeHigh
 nFileSizeLow AS DWORD ' DWORD nFileSizeLow
 nNumberOfLinks AS DWORD ' DWORD nNumberOfLinks
 nFileIndexHigh AS DWORD ' DWORD nFileIndexHigh
 nFileIndexLow AS DWORD ' DWORD nFileIndexLow
END TYPE
DECLARE FUNCTION GetFileInformationByHandle LIB "kernel32.dll" ALIAS "GetFileInformationByHandle" ( BYVAL hFile AS QUAD , BYREF lpFileInformation AS BY_HANDLE_FILE_INFORMATION ) AS LONG
DECLARE FUNCTION GetFileType LIB "kernel32.dll" ALIAS "GetFileType" ( BYVAL hFile AS QUAD
 ) AS DWORD
DECLARE FUNCTION GetFileSize LIB "kernel32.dll" ALIAS "GetFileSize" ( BYVAL hFile AS DWORD
 , BYREF lpFileSizeHigh AS LONG
 ) AS DWORD
DECLARE FUNCTION GetFileSizeEx LIB "kernel32.dll" ALIAS "GetFileSizeEx" ( BYVAL hFile AS DWORD
 , BYREF lpFileSize AS QUAD
 ) AS LONG
DECLARE FUNCTION GetStdHandle LIB "kernel32.dll" ALIAS "GetStdHandle" ( BYVAL nStdHandle AS DWORD
 ) AS DWORD
DECLARE FUNCTION SetStdHandle LIB "kernel32.dll" ALIAS "SetStdHandle" ( BYVAL nStdHandle AS DWORD
 , BYVAL hHandle AS DWORD
 ) AS LONG
'#if (_WIN32_WINNT >= 0x0600)
#IF %WINVER >= &H0600
DECLARE FUNCTION SetStdHandleEx LIB "kernel32.dll" ALIAS "SetStdHandleEx" ( BYVAL nStdHandle AS QUAD , BYVAL hHandle AS QUAD , BYREF phPrevValue AS QUAD ) AS LONG
#ENDIF ' // _WIN32_WINNT >= 0x0600
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION WriteFile LIB "Kernel32.dll" ALIAS "WriteFile" (BYVAL hFile AS QUAD, BYVAL lpBuffer AS QUAD, BYVAL nNumberOfBytesToWrite AS QUAD, lpNumberOfBytesWritten AS QUAD, lpOverlapped AS OVERLAPPED) AS LONG
#ELSE
DECLARE FUNCTION WriteFile LIB "kernel32.dll" ALIAS "WriteFile" ( BYVAL hFile AS QUAD , BYREF lpBuffer AS ANY , BYVAL nNumberOfBytesToWrite AS QUAD , OPTIONAL BYREF lpNumberOfBytesWritten AS QUAD , OPTIONAL BYREF lpOverlapped AS OVERLAPPED ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION ReadFile LIB "Kernel32.dll" ALIAS "ReadFile" (BYVAL hFile AS QUAD, BYVAL lpBuffer AS QUAD, BYVAL nNumberOfBytesToRead AS QUAD, lpNumberOfBytesRead AS QUAD, lpOverlapped AS OVERLAPPED) AS LONG
#ELSE
DECLARE FUNCTION ReadFile LIB "kernel32.dll" ALIAS "ReadFile" ( BYVAL hFile AS QUAD , BYREF lpBuffer AS ANY , BYVAL nNumberOfBytesToRead AS QUAD , OPTIONAL BYREF lpNumberOfBytesRead AS QUAD , OPTIONAL BYREF lpOverlapped AS OVERLAPPED ) AS LONG
#ENDIF
DECLARE FUNCTION FlushFileBuffers LIB "kernel32.dll" ALIAS "FlushFileBuffers" ( BYVAL hFile AS QUAD ) AS LONG
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION DeviceIoControl LIB "Kernel32.dll" ALIAS "DeviceIoControl" (BYVAL hDevice AS QUAD, BYVAL dwIoControlCode AS QUAD, BYVAL lpInBuffer AS QUAD, BYVAL nInBufferSize AS QUAD, BYVAL lpOutBuffer AS QUAD, BYVAL nOutBufferSize AS QUAD, lpBytesReturned AS LONG, lpOverlapped AS OVERLAPPED) AS LONG
#ELSE
DECLARE FUNCTION DeviceIoControl LIB "kernel32.dll" ALIAS "DeviceIoControl" ( BYVAL hDevice AS QUAD , BYVAL dwIoControlCode AS QUAD , BYREF lpInBuffer AS ANY , BYVAL nInBufferSize AS QUAD , BYREF lpOutBuffer AS ANY , BYVAL nOutBufferSize AS QUAD , BYREF lpBytesReturned AS QUAD , BYREF lpOverlapped AS OVERLAPPED ) AS LONG
#ENDIF
DECLARE FUNCTION RequestDeviceWakeup LIB "kernel32.dll" ALIAS "RequestDeviceWakeup" ( BYVAL hDevice AS QUAD ) AS LONG
DECLARE FUNCTION CancelDeviceWakeupRequest LIB "kernel32.dll" ALIAS "CancelDeviceWakeupRequest" ( BYVAL hDevice AS QUAD
 ) AS LONG
DECLARE FUNCTION GetDevicePowerState LIB "kernel32.dll" ALIAS "GetDevicePowerState" ( BYVAL hDevice AS DWORD
 , BYREF pfOn AS DWORD
 ) AS LONG
DECLARE FUNCTION SetMessageWaitingIndicator LIB "kernel32.dll" ALIAS "SetMessageWaitingIndicator" ( BYVAL hMsgIndicator AS DWORD
 , BYVAL ulMsgCount AS DWORD
 ) AS LONG
DECLARE FUNCTION SetEndOfFile LIB "kernel32.dll" ALIAS "SetEndOfFile" ( BYVAL hFile AS DWORD
 ) AS LONG
DECLARE FUNCTION SetFilePointer LIB "kernel32.dll" ALIAS "SetFilePointer" ( BYVAL hFile AS DWORD
 , BYVAL lDistanceToMove AS LONG
 , BYREF lpDistanceToMoveHigh AS LONG
 , BYVAL dwMoveMethod AS DWORD
 ) AS DWORD
DECLARE FUNCTION SetFilePointerEx LIB "kernel32.dll" ALIAS "SetFilePointerEx" ( BYVAL hFile AS DWORD
 , BYVAL lDistanceToMove AS QUAD
 , BYREF lpNewFilePointer AS QUAD
 , BYVAL dwMoveMethod AS DWORD
 ) AS LONG
DECLARE FUNCTION FindClose LIB "kernel32.dll" ALIAS "FindClose" ( BYVAL hFindFile AS DWORD
 ) AS LONG
DECLARE FUNCTION GetFileTime LIB "kernel32.dll" ALIAS "GetFileTime" ( BYVAL hFile AS DWORD
 , BYREF lpCreationTime AS FILETIME
 , BYREF lpLastAccessTime AS FILETIME
 , BYREF lpLastWriteTime AS FILETIME
 ) AS LONG
DECLARE FUNCTION SetFileTime LIB "kernel32.dll" ALIAS "SetFileTime" ( BYVAL hFile AS DWORD
 , BYREF lpCreationTime AS FILETIME
 , BYREF lpLastAccessTime AS FILETIME
 , BYREF lpLastWriteTime AS FILETIME
 ) AS LONG
'#if _WIN32_WINNT >= 0x0501
DECLARE FUNCTION SetFileValidData LIB "kernel32.dll" ALIAS "SetFileValidData" ( BYVAL hFile AS QUAD , BYVAL ValidDataLength AS QUAD ) AS LONG
'#endif // (_WIN32_WINNT >= 0x0501)
DECLARE FUNCTION SetFileShortNameA LIB "kernel32.dll" ALIAS "SetFileShortNameA" ( BYVAL hFile AS QUAD , BYREF lpShortName AS ASCIIZ ) AS LONG
DECLARE FUNCTION SetFileShortNameW LIB "kernel32.dll" ALIAS "SetFileShortNameW" ( BYVAL hFile AS QUAD
 , BYREF lpShortName AS WSTRINGZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SetFileShortName = SetFileShortNameW
#ELSE
 MACRO SetFileShortName = SetFileShortNameA
#ENDIF
DECLARE FUNCTION CloseHandle LIB "kernel32.dll" ALIAS "CloseHandle" ( BYVAL hObject AS QUAD ) AS LONG
DECLARE FUNCTION DuplicateHandle LIB "kernel32.dll" ALIAS "DuplicateHandle" ( BYVAL hSourceProcessHandle AS QUAD
 , BYVAL hSourceHandle AS DWORD
 , BYVAL hTargetProcessHandle AS DWORD
 , BYREF lpTargetHandle AS DWORD
 , BYVAL dwDesiredAccess AS DWORD
 , BYVAL bInheritHandle AS LONG
 , BYVAL dwOptions AS DWORD
 ) AS LONG
DECLARE FUNCTION GetHandleInformation LIB "kernel32.dll" ALIAS "GetHandleInformation" ( BYVAL hObject AS DWORD
 , BYREF lpdwFlags AS DWORD
 ) AS LONG
DECLARE FUNCTION SetHandleInformation LIB "kernel32.dll" ALIAS "SetHandleInformation" ( BYVAL hObject AS DWORD
 , BYVAL dwMask AS DWORD
 , BYVAL dwFlags AS DWORD
 ) AS LONG
%EQUATE `HANDLE_FLAG_INHERIT = &H00000001
%EQUATE `HANDLE_FLAG_PROTECT_FROM_CLOSE = &H00000002
%EQUATE `HINSTANCE_ERROR = 32
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION LoadModule LIB "Kernel32.dll" ALIAS "LoadModule" (lpModuleName AS ASCIIZ, BYVAL lpParameterBlock AS QUAD) AS QUAD
#ELSE
DECLARE FUNCTION LoadModule LIB "kernel32.dll" ALIAS "LoadModule" ( BYREF lpModuleName AS ASCIIZ , BYREF lpParameterBlock AS ANY ) AS QUAD
#ENDIF
DECLARE FUNCTION WinExec LIB "kernel32.dll" ALIAS "WinExec" ( BYREF lpCmdLine AS ASCIIZ , BYVAL uCmdShow AS QUAD ) AS QUAD ' UINT
DECLARE FUNCTION ClearCommBreak LIB "kernel32.dll" ALIAS "ClearCommBreak" ( BYVAL hFile AS QUAD ) AS LONG
DECLARE FUNCTION ClearCommError LIB "kernel32.dll" ALIAS "ClearCommError" ( BYVAL hFile AS QUAD
 , BYREF lpErrors AS DWORD
 , BYREF lpStat AS COMSTAT
 ) AS LONG
DECLARE FUNCTION SetupComm LIB "kernel32.dll" ALIAS "SetupComm" ( BYVAL hFile AS DWORD
 , BYVAL dwInQueue AS DWORD
 , BYVAL dwOutQueue AS DWORD
 ) AS LONG
DECLARE FUNCTION EscapeCommFunction LIB "kernel32.dll" ALIAS "EscapeCommFunction" ( BYVAL hFile AS DWORD
 , BYVAL dwFunc AS DWORD
 ) AS LONG
DECLARE FUNCTION GetCommConfig LIB "kernel32.dll" ALIAS "GetCommConfig" ( BYVAL hCommDev AS DWORD
 , BYREF lpCC AS COMMCONFIG
 , BYREF lpdwSize AS DWORD
 ) AS LONG
DECLARE FUNCTION GetCommMask LIB "kernel32.dll" ALIAS "GetCommMask" ( BYVAL hFile AS DWORD
 , BYREF lpEvtMask AS DWORD
 ) AS LONG
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION GetCommProperties LIB "Kernel32.dll" ALIAS "GetCommProperties" (BYVAL hFile AS QUAD, BYVAL lpCommProp AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION GetCommProperties LIB "kernel32.dll" ALIAS "GetCommProperties" ( BYVAL hFile AS QUAD , BYREF lpCommProp AS COMMPROP ) AS LONG
#ENDIF
DECLARE FUNCTION GetCommModemStatus LIB "kernel32.dll" ALIAS "GetCommModemStatus" ( BYVAL hFile AS QUAD , BYREF lpModemStat AS QUAD ) AS LONG
DECLARE FUNCTION GetCommState LIB "kernel32.dll" ALIAS "GetCommState" ( BYVAL hFile AS QUAD
 , BYREF lpDCB AS DCB
 ) AS LONG
DECLARE FUNCTION GetCommTimeouts LIB "kernel32.dll" ALIAS "GetCommTimeouts" ( BYVAL hFile AS DWORD
 , BYREF lpCommTimeouts AS COMMTIMEOUTS
 ) AS LONG
DECLARE FUNCTION PurgeComm LIB "kernel32.dll" ALIAS "PurgeComm" ( BYVAL hFile AS DWORD
 , BYVAL dwFlags AS DWORD
 ) AS LONG
DECLARE FUNCTION SetCommBreak LIB "kernel32.dll" ALIAS "SetCommBreak" ( BYVAL hFile AS DWORD
 ) AS LONG
DECLARE FUNCTION SetCommConfig LIB "kernel32.dll" ALIAS "SetCommConfig" ( BYVAL hCommDev AS DWORD
 , BYREF lpCC AS COMMCONFIG
 , BYVAL dwSize AS DWORD
 ) AS LONG
DECLARE FUNCTION SetCommMask LIB "kernel32.dll" ALIAS "SetCommMask" ( BYVAL hFile AS DWORD
 , BYVAL dwEvtMask AS DWORD
 ) AS LONG
DECLARE FUNCTION SetCommState LIB "kernel32.dll" ALIAS "SetCommState" ( BYVAL hFile AS DWORD
 , BYREF lpDCB AS DCB
 ) AS LONG
DECLARE FUNCTION SetCommTimeouts LIB "kernel32.dll" ALIAS "SetCommTimeouts" ( BYVAL hFile AS DWORD
 , BYREF lpCommTimeouts AS COMMTIMEOUTS
 ) AS LONG
DECLARE FUNCTION TransmitCommChar LIB "kernel32.dll" ALIAS "TransmitCommChar" ( BYVAL hFile AS DWORD
 , BYVAL cChar AS BYTE
 ) AS LONG
DECLARE FUNCTION WaitCommEvent LIB "kernel32.dll" ALIAS "WaitCommEvent" ( BYVAL hFile AS DWORD
 , BYREF lpEvtMask AS DWORD
 , BYREF lpOverlapped AS OVERLAPPED
 ) AS LONG
DECLARE FUNCTION SetTapePosition LIB "kernel32.dll" ALIAS "SetTapePosition" ( BYVAL hDevice AS DWORD
 , BYVAL dwPositionMethod AS DWORD
 , BYVAL dwPartition AS DWORD
 , BYVAL dwOffsetLow AS DWORD
 , BYVAL dwOffsetHigh AS DWORD
 , BYVAL bImmediate AS LONG
 ) AS DWORD
DECLARE FUNCTION GetTapePosition LIB "kernel32.dll" ALIAS "GetTapePosition" ( BYVAL hDevice AS DWORD
 , BYVAL dwPositionType AS DWORD
 , BYREF lpdwPartition AS DWORD
 , BYREF lpdwOffsetLow AS DWORD
 , BYREF lpdwOffsetHigh AS DWORD
 ) AS DWORD
DECLARE FUNCTION PrepareTape LIB "kernel32.dll" ALIAS "PrepareTape" ( BYVAL hDevice AS DWORD
 , BYVAL dwOperation AS DWORD
 , BYVAL bImmediate AS LONG
 ) AS DWORD
DECLARE FUNCTION EraseTape LIB "kernel32.dll" ALIAS "EraseTape" ( BYVAL hDevice AS DWORD
 , BYVAL dwEraseType AS DWORD
 , BYVAL bImmediate AS LONG
 ) AS DWORD
DECLARE FUNCTION CreateTapePartition LIB "kernel32.dll" ALIAS "CreateTapePartition" ( BYVAL hDevice AS DWORD
 , BYVAL dwPartitionMethod AS DWORD
 , BYVAL dwCount AS DWORD
 , BYVAL dwSize AS DWORD
 ) AS DWORD
DECLARE FUNCTION WriteTapemark LIB "kernel32.dll" ALIAS "WriteTapemark" ( BYVAL hDevice AS DWORD
 , BYVAL dwTapemarkType AS DWORD
 , BYVAL dwTapemarkCount AS DWORD
 , BYVAL bImmediate AS LONG
 ) AS DWORD
DECLARE FUNCTION GetTapeStatus LIB "kernel32.dll" ALIAS "GetTapeStatus" ( BYVAL hDevice AS DWORD
 ) AS DWORD
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION GetTapeParameters LIB "Kernel32.dll" ALIAS "GetTapeParameters" (BYVAL hDevice AS QUAD, BYVAL dwOperation AS QUAD, lpdwSize AS QUAD, BYVAL lpTapeInformation AS QUAD) AS QUAD
#ELSE
DECLARE FUNCTION GetTapeParameters LIB "kernel32.dll" ALIAS "GetTapeParameters" ( BYVAL hDevice AS QUAD , BYVAL dwOperation AS QUAD , BYREF lpdwSize AS QUAD , BYREF lpTapeInformation AS ANY ) AS QUAD
#ENDIF
%EQUATE `GET_TAPE_MEDIA_INFORMATION = 0
%EQUATE `GET_TAPE_DRIVE_INFORMATION = 1
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION SetTapeParameters LIB "Kernel32.dll" ALIAS "SetTapeParameters" (BYVAL hDevice AS QUAD, BYVAL dwOperation AS QUAD, BYVAL lpTapeInformation AS QUAD) AS QUAD
#ELSE
DECLARE FUNCTION SetTapeParameters LIB "kernel32.dll" ALIAS "SetTapeParameters" ( BYVAL hDevice AS QUAD , BYVAL dwOperation AS QUAD , BYREF lpTapeInformation AS ANY ) AS QUAD
#ENDIF
%EQUATE `SET_TAPE_MEDIA_INFORMATION = 0
%EQUATE `SET_TAPE_DRIVE_INFORMATION = 1
DECLARE FUNCTION WinBeep LIB "kernel32.dll" ALIAS "Beep" ( BYVAL dwFreq AS QUAD , BYVAL dwDuration AS QUAD ) AS LONG
DECLARE FUNCTION MulDiv LIB "kernel32.dll" ALIAS "MulDiv" ( BYVAL nNumber AS LONG
 , BYVAL nNumerator AS LONG
 , BYVAL nDenominator AS LONG
 ) AS LONG ' int
DECLARE SUB GetSystemTime LIB "kernel32.dll" ALIAS "GetSystemTime" ( BYREF lpSystemTime AS SYSTEMTIME ) ' void
DECLARE SUB GetSystemTimeAsFileTime LIB "kernel32.dll" ALIAS "GetSystemTimeAsFileTime" ( BYREF lpSystemTimeAsFileTime AS FILETIME ) ' void
DECLARE FUNCTION SetSystemTime LIB "kernel32.dll" ALIAS "SetSystemTime" ( BYREF lpSystemTime AS SYSTEMTIME ) AS LONG
DECLARE SUB GetLocalTime LIB "kernel32.dll" ALIAS "GetLocalTime" ( BYREF lpSystemTime AS SYSTEMTIME
 ) ' void
DECLARE FUNCTION SetLocalTime LIB "kernel32.dll" ALIAS "SetLocalTime" ( BYREF lpSystemTime AS SYSTEMTIME ) AS LONG
DECLARE SUB GetSystemInfo LIB "kernel32.dll" ALIAS "GetSystemInfo" ( BYREF lpSystemInfo AS SYSTEM_INFO
 ) ' void
' enum DEP_SYSTEM_POLICY_TYPE
%EQUATE `DEPPolicyAlwaysOff = 0
%EQUATE `DEPPolicyAlwaysOn = 1
%EQUATE `DEPPolicyOptIn = 2
%EQUATE `DEPPolicyOptOut = 3
%EQUATE `DEPTotalPolicyCount = 4
DECLARE FUNCTION GetSystemDEPPolicy LIB "kernel32.dll" ALIAS "GetSystemDEPPolicy" ( ) AS LONG ' DEP_SYSTEM_POLICY_TYPE
'#if _WIN32_WINNT >= 0x0502
%EQUATE `FILE_CACHE_FLAGS_DEFINED = 1
%EQUATE `FILE_CACHE_MAX_HARD_ENABLE = &H00000001
%EQUATE `FILE_CACHE_MAX_HARD_DISABLE = &H00000002
%EQUATE `FILE_CACHE_MIN_HARD_ENABLE = &H00000004
%EQUATE `FILE_CACHE_MIN_HARD_DISABLE = &H00000008
DECLARE FUNCTION SetSystemFileCacheSize LIB "kernel32.dll" ALIAS "SetSystemFileCacheSize" ( BYVAL MinimumFileCacheSize AS QUAD , BYVAL MaximumFileCacheSize AS QUAD , BYVAL Flags AS QUAD ) AS LONG
DECLARE FUNCTION GetSystemFileCacheSize LIB "kernel32.dll" ALIAS "GetSystemFileCacheSize" ( BYREF lpMinimumFileCacheSize AS QUAD
 , BYREF lpMaximumFileCacheSize AS DWORD
 , BYREF lpFlags AS DWORD
 ) AS LONG
'#endif // (_WIN32_WINNT >= 0x0502)
'#if _WIN32_WINNT >= 0x0501
DECLARE FUNCTION GetSystemRegistryQuota LIB "kernel32.dll" ALIAS "GetSystemRegistryQuota" ( BYREF pdwQuotaAllowed AS QUAD , BYREF pdwQuotaUsed AS QUAD ) AS LONG
DECLARE FUNCTION GetSystemTimes LIB "kernel32.dll" ALIAS "GetSystemTimes" ( BYREF lpIdleTime AS FILETIME
 , BYREF lpKernelTime AS FILETIME
 , BYREF lpUserTime AS FILETIME
 ) AS LONG
'#endif // (_WIN32_WINNT >= 0x0501)
'#if _WIN32_WINNT >= 0x0501
DECLARE SUB GetNativeSystemInfo LIB "kernel32.dll" ALIAS "GetNativeSystemInfo" ( BYREF lpSystemInfo AS SYSTEM_INFO ) ' void
'#endif
DECLARE FUNCTION IsProcessorFeaturePresent LIB "kernel32.dll" ALIAS "IsProcessorFeaturePresent" ( BYVAL ProcessorFeature AS QUAD ) AS LONG
' // Size = 172 bytes
TYPE TIME_ZONE_INFORMATION DWORD
 Bias AS LONG
 StandardName AS WSTRINGZ * 32 ' WCHAR[32]
 StandardDate AS SYSTEMTIME ' SYSTEMTIME
 StandardBias AS LONG
 DaylightName AS WSTRINGZ * 32 ' WCHAR[32]
 DaylightDate AS SYSTEMTIME ' SYSTEMTIME
 DaylightBias AS LONG
END TYPE
' // Size = 432 bytes
TYPE DYNAMIC_TIME_ZONE_INFORMATION DWORD
 Bias AS LONG
 StandardName AS WSTRINGZ * 32 ' WCHAR[32]
 StandardDate AS SYSTEMTIME ' SYSTEMTIME
 StandardBias AS LONG
 DaylightName AS WSTRINGZ * 32 ' WCHAR[32]
 DaylightDate AS SYSTEMTIME ' SYSTEMTIME
 DaylightBias AS LONG
 TimeZoneKeyName AS WSTRINGZ * 128 ' WCHAR
 DynamicDaylightTimeDisabled AS BYTE ' BOOLEAN
END TYPE
DECLARE FUNCTION SystemTimeToTzSpecificLocalTime LIB "kernel32.dll" ALIAS "SystemTimeToTzSpecificLocalTime" ( BYREF lpTimeZoneInformation AS TIME_ZONE_INFORMATION , BYREF lpUniversalTime AS SYSTEMTIME , BYREF lpLocalTime AS SYSTEMTIME ) AS LONG
DECLARE FUNCTION TzSpecificLocalTimeToSystemTime LIB "kernel32.dll" ALIAS "TzSpecificLocalTimeToSystemTime" ( BYREF lpTimeZoneInformation AS TIME_ZONE_INFORMATION
 , BYREF lpLocalTime AS SYSTEMTIME
 , BYREF lpUniversalTime AS SYSTEMTIME
 ) AS LONG
DECLARE FUNCTION GetTimeZoneInformationForYear LIB "kernel32.dll" ALIAS "GetTimeZoneInformationForYear" ( BYVAL wYear AS WORD
 , BYREF pdtzi AS DYNAMIC_TIME_ZONE_INFORMATION
 , BYREF ptzi AS TIME_ZONE_INFORMATION
 ) AS LONG
DECLARE FUNCTION GetTimeZoneInformation LIB "kernel32.dll" ALIAS "GetTimeZoneInformation" ( BYREF lpTimeZoneInformation AS TIME_ZONE_INFORMATION
 ) AS DWORD
DECLARE FUNCTION SetTimeZoneInformation LIB "kernel32.dll" ALIAS "SetTimeZoneInformation" ( BYREF lpTimeZoneInformation AS TIME_ZONE_INFORMATION
 ) AS LONG
DECLARE FUNCTION GetDynamicTimeZoneInformation LIB "kernel32.dll" ALIAS "GetDynamicTimeZoneInformation" ( BYREF lpTimeZoneInformation AS DYNAMIC_TIME_ZONE_INFORMATION
 ) AS DWORD
DECLARE FUNCTION SetDynamicTimeZoneInformation LIB "kernel32.dll" ALIAS "SetDynamicTimeZoneInformation" ( BYREF lpTimeZoneInformation AS DYNAMIC_TIME_ZONE_INFORMATION
 ) AS LONG
'//
'// Routines to convert back and forth between system time and file time
'//
DECLARE FUNCTION SystemTimeToFileTime LIB "kernel32.dll" ALIAS "SystemTimeToFileTime" ( BYREF lpSystemTime AS SYSTEMTIME , BYREF lpFileTime AS FILETIME ) AS LONG
DECLARE FUNCTION FileTimeToLocalFileTime LIB "kernel32.dll" ALIAS "FileTimeToLocalFileTime" ( BYREF lpFileTime AS FILETIME
 , BYREF lpLocalFileTime AS FILETIME
 ) AS LONG
DECLARE FUNCTION LocalFileTimeToFileTime LIB "kernel32.dll" ALIAS "LocalFileTimeToFileTime" ( BYREF lpLocalFileTime AS FILETIME
 , BYREF lpFileTime AS FILETIME
 ) AS LONG
DECLARE FUNCTION FileTimeToSystemTime LIB "kernel32.dll" ALIAS "FileTimeToSystemTime" ( BYREF lpFileTime AS FILETIME
 , BYREF lpSystemTime AS SYSTEMTIME
 ) AS LONG
DECLARE FUNCTION CompareFileTime LIB "kernel32.dll" ALIAS "CompareFileTime" ( BYREF lpFileTime1 AS FILETIME
 , BYREF lpFileTime2 AS FILETIME
 ) AS LONG
DECLARE FUNCTION FileTimeToDosDateTime LIB "kernel32.dll" ALIAS "FileTimeToDosDateTime" ( BYREF lpFileTime2 AS FILETIME
 , BYREF lpFatDate AS WORD
 , BYREF lpFatTime AS WORD
 ) AS LONG
DECLARE FUNCTION DosDateTimeToFileTime LIB "kernel32.dll" ALIAS "DosDateTimeToFileTime" ( BYVAL wFatDate AS WORD
 , BYVAL wFatTime AS WORD
 , BYREF lpFileTime AS FILETIME
 ) AS LONG
DECLARE FUNCTION GetTickCount LIB "kernel32.dll" ALIAS "GetTickCount" ( ) AS DWORD
'#if (_WIN32_WINNT >= 0x0600)
#IF %WINVER >= &H0600
DECLARE FUNCTION GetTickCount64 LIB "kernel32.dll" ALIAS "GetTickCount64" ( ) AS QUAD ' ULONGULONG
#ENDIF
'#endif
DECLARE FUNCTION SetSystemTimeAdjustment LIB "kernel32.dll" ALIAS "SetSystemTimeAdjustment" ( BYVAL dwTimeAdjustment AS QUAD , BYVAL bTimeAdjustmentDisabled AS LONG ) AS LONG
DECLARE FUNCTION GetSystemTimeAdjustment LIB "kernel32.dll" ALIAS "GetSystemTimeAdjustment" ( BYREF lpTimeAdjustment AS QUAD
 , BYREF lpTimeIncrement AS DWORD
 , BYREF lpTimeAdjustmentDisabled AS LONG
 ) AS LONG
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION FormatMessageA LIB "Kernel32.dll" ALIAS "FormatMessageA" (BYVAL dwFlags AS QUAD, BYVAL lpSource AS QUAD, BYVAL dwMessageId AS QUAD, BYVAL dwLanguageId AS QUAD, lpBuffer AS ASCIIZ, BYVAL nSize AS QUAD, BYVAL Arguments AS QUAD) AS QUAD
' // Note: The Arguments parameter should be BYREF ANY, but it has been declared as
' // BYVAL DWORD for compatibility with the PowerBASIC include files to no break
' // existing code.
#ELSE
DECLARE FUNCTION FormatMessageA LIB "kernel32.dll" ALIAS "FormatMessageA" ( BYVAL dwFlags AS QUAD , BYREF lpSource AS ANY , BYVAL dwMessageId AS QUAD , BYVAL dwLanguageId AS QUAD , BYREF lpBuffer AS ASCIIZ , BYVAL nSize AS QUAD , BYVAL Arguments AS QUAD ) AS QUAD
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION FormatMessageW LIB "Kernel32.dll" ALIAS "FormatMessageW" (BYVAL dwFlags AS QUAD, BYVAL lpSource AS QUAD, BYVAL dwMessageId AS QUAD, BYVAL dwLanguageId AS QUAD, lpBuffer AS WSTRINGZ, BYVAL nSize AS QUAD, BYVAL Arguments AS QUAD) AS QUAD
#ELSE
DECLARE FUNCTION FormatMessageW LIB "kernel32.dll" ALIAS "FormatMessageW" ( BYVAL dwFlags AS QUAD , BYREF lpSource AS ANY , BYVAL dwMessageId AS QUAD , BYVAL dwLanguageId AS QUAD , BYREF lpBuffer AS WSTRINGZ , BYVAL nSize AS QUAD , BYVAL Arguments AS QUAD ) AS QUAD
#ENDIF
#IF %DEF(%UNICODE)
 MACRO FormatMessage = FormatMessageW
#ELSE
 MACRO FormatMessage = FormatMessageA
#ENDIF
%EQUATE `FORMAT_MESSAGE_ALLOCATE_BUFFER = &H00000100
%EQUATE `FORMAT_MESSAGE_IGNORE_INSERTS = &H00000200
%EQUATE `FORMAT_MESSAGE_FROM_STRING = &H00000400
%EQUATE `FORMAT_MESSAGE_FROM_HMODULE = &H00000800
%EQUATE `FORMAT_MESSAGE_FROM_SYSTEM = &H00001000
%EQUATE `FORMAT_MESSAGE_ARGUMENT_ARRAY = &H00002000
%EQUATE `FORMAT_MESSAGE_MAX_WIDTH_MASK = &H000000FF
DECLARE FUNCTION CreatePipe LIB "kernel32.dll" ALIAS "CreatePipe" ( BYREF hReadPipe AS QUAD , BYREF hWritePipe AS QUAD , BYREF lpPipeAttributes AS SECURITY_ATTRIBUTES , BYVAL nSize AS QUAD ) AS LONG
DECLARE FUNCTION ConnectNamedPipe LIB "kernel32.dll" ALIAS "ConnectNamedPipe" ( BYVAL hNamedPipe AS QUAD
 , BYREF lpOverlapped AS OVERLAPPED
 ) AS LONG
DECLARE FUNCTION DisconnectNamedPipe LIB "kernel32.dll" ALIAS "DisconnectNamedPipe" ( BYVAL hNamedPipe AS DWORD
 ) AS LONG
DECLARE FUNCTION SetNamedPipeHandleState LIB "kernel32.dll" ALIAS "SetNamedPipeHandleState" ( BYVAL hNamedPipe AS DWORD
 , BYREF lpMode AS DWORD
 , BYREF lpMaxCollectionCount AS DWORD
 , BYREF lpCollectDataTimeout AS DWORD
 ) AS LONG
DECLARE FUNCTION GetNamedPipeInfo LIB "kernel32.dll" ALIAS "GetNamedPipeInfo" ( BYVAL hNamedPipe AS DWORD
 , BYREF lpFlags AS DWORD
 , BYREF lpOutBufferSize AS DWORD
 , BYREF lpInBufferSize AS DWORD
 , BYREF lpMaxInstances AS DWORD
 ) AS LONG
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION PeekNamedPipe LIB "Kernel32.dll" ALIAS "PeekNamedPipe" (BYVAL hNamedPipe AS QUAD, BYVAL lpBuffer AS QUAD, BYVAL nBufferSize AS QUAD, lpBytesRead AS QUAD, lpTotalBytesAvail AS QUAD, lpBytesLeftThisMessage AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION PeekNamedPipe LIB "kernel32.dll" ALIAS "PeekNamedPipe" ( BYVAL hNamedPipe AS QUAD , BYREF lpBuffer AS ANY , BYVAL nBufferSize AS QUAD , BYREF lpBytesRead AS QUAD , BYREF lpTotalBytesAvail AS QUAD , BYREF lpBytesLeftThisMessage AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION TransactNamedPipe LIB "Kernel32.dll" ALIAS "TransactNamedPipe" (BYVAL hNamedPipe AS QUAD, BYVAL lpInBuffer AS QUAD, BYVAL nInBufferSize AS QUAD, BYVAL lpOutBuffer AS QUAD, BYVAL nOutBufferSize AS QUAD, lpBytesRead AS QUAD, lpOverlapped AS OVERLAPPED) AS LONG
#ELSE
DECLARE FUNCTION TransactNamedPipe LIB "kernel32.dll" ALIAS "TransactNamedPipe" ( BYVAL hNamedPipe AS QUAD , BYREF lpInBuffer AS ANY , BYVAL nInBufferSize AS QUAD , BYREF lpOutBuffer AS ANY , BYVAL nOutBufferSize AS QUAD , BYREF lpBytesRead AS QUAD , BYREF lpOverlapped AS OVERLAPPED ) AS LONG
#ENDIF
DECLARE FUNCTION CreateMailslotA LIB "kernel32.dll" ALIAS "CreateMailslotA" ( BYREF lpName AS ASCIIZ , BYVAL nMaxMessageSize AS QUAD , BYVAL lReadTimeout AS QUAD , BYREF lpSecurityAttributes AS SECURITY_ATTRIBUTES ) AS QUAD
DECLARE FUNCTION CreateMailslotW LIB "kernel32.dll" ALIAS "CreateMailslotW" ( BYREF lpName AS WSTRINGZ
 , BYVAL nMaxMessageSize AS DWORD
 , BYVAL lReadTimeout AS DWORD
 , BYREF lpSecurityAttributes AS SECURITY_ATTRIBUTES
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO CreateMailslot = CreateMailslotW
#ELSE
 MACRO CreateMailslot = CreateMailslotA
#ENDIF
DECLARE FUNCTION GetMailslotInfo LIB "kernel32.dll" ALIAS "GetMailslotInfo" ( BYVAL hMailslot AS QUAD , BYREF lpMaxMessageSize AS QUAD , BYREF lpNextSize AS QUAD , BYREF lpMessageCount AS QUAD , BYREF lpReadTimeout AS QUAD ) AS LONG
DECLARE FUNCTION SetMailslotInfo LIB "kernel32.dll" ALIAS "SetMailslotInfo" ( BYVAL hMailslot AS QUAD
 , BYVAL lReadTimeout AS DWORD
 ) AS LONG
DECLARE FUNCTION MapViewOfFile LIB "kernel32.dll" ALIAS "MapViewOfFile" ( BYVAL hFileMappingObject AS DWORD
 , BYVAL dwDesiredAccess AS DWORD
 , BYVAL dwFileOffsetHigh AS DWORD
 , BYVAL dwFileOffsetLow AS DWORD
 , BYVAL dwNumberOfBytesToMap AS DWORD
 ) AS DWORD
DECLARE FUNCTION FlushViewOfFile LIB "kernel32.dll" ALIAS "FlushViewOfFile" ( BYVAL lpBaseAddress AS DWORD
 , BYVAL dwNumberOfBytesToFlush AS DWORD
 ) AS LONG
DECLARE FUNCTION UnmapViewOfFile LIB "kernel32.dll" ALIAS "UnmapViewOfFile" ( BYVAL lpBaseAddress AS DWORD
 ) AS LONG
'//
'// File Encryption API
'//
DECLARE FUNCTION EncryptFileA LIB "advapi32.dll" ALIAS "EncryptFileA" ( BYREF lpFileName AS ASCIIZ ) AS LONG
DECLARE FUNCTION EncryptFileW LIB "advapi32.dll" ALIAS "EncryptFileW" ( BYREF lpFileName AS WSTRINGZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO EncryptFile = EncryptFileW
#ELSE
 MACRO EncryptFile = EncryptFileA
#ENDIF
DECLARE FUNCTION DecryptFileA LIB "advapi32.dll" ALIAS "DecryptFileA" ( BYREF lpFileName AS ASCIIZ , BYVAL dwReserved AS QUAD ) AS LONG
DECLARE FUNCTION DecryptFileW LIB "advapi32.dll" ALIAS "DecryptFileW" ( BYREF lpFileName AS WSTRINGZ
 , BYVAL dwReserved AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO DecryptFile = DecryptFileW
#ELSE
 MACRO DecryptFile = DecryptFileA
#ENDIF
'//
'// Encryption Status Value
'//
%EQUATE `FILE_ENCRYPTABLE = 0
%EQUATE `FILE_IS_ENCRYPTED = 1
%EQUATE `FILE_SYSTEM_ATTR = 2
%EQUATE `FILE_ROOT_DIR = 3
%EQUATE `FILE_SYSTEM_DIR = 4
%EQUATE `FILE_UNKNOWN = 5
%EQUATE `FILE_SYSTEM_NOT_SUPPORT = 6
%EQUATE `FILE_USER_DISALLOWED = 7
%EQUATE `FILE_READ_ONLY = 8
%EQUATE `FILE_DIR_DISALLOWED = 9
DECLARE FUNCTION FileEncryptionStatusA LIB "advapi32.dll" ALIAS "FileEncryptionStatusA" ( BYREF lpFileName AS ASCIIZ , BYREF lpStatus AS QUAD ) AS LONG
DECLARE FUNCTION FileEncryptionStatusW LIB "advapi32.dll" ALIAS "FileEncryptionStatusW" ( BYREF lpFileName AS WSTRINGZ
 , BYREF lpStatus AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO FileEncryptionStatus = FileEncryptionStatusW
#ELSE
 MACRO FileEncryptionStatus = FileEncryptionStatusA
#ENDIF
'//
'// Currently defined recovery flags
'//
%EQUATE `EFS_USE_RECOVERY_KEYS = &H1
'typedef
'(WINAPI *PFE_EXPORT_FUNC)(
' );
'typedef
'(WINAPI *PFE_IMPORT_FUNC)(
' );
'//
'// OpenRaw flag values
'//
%EQUATE `CREATE_FOR_IMPORT = 1
%EQUATE `CREATE_FOR_DIR = 2
%EQUATE `OVERWRITE_HIDDEN = 4
%EQUATE `EFSRPC_SECURE_ONLY = 8
DECLARE FUNCTION OpenEncryptedFileRawA LIB "advapi32.dll" ALIAS "OpenEncryptedFileRawA" ( BYREF lpFileName AS ASCIIZ , BYVAL ulFlags AS QUAD , BYREF pvContext AS ANY ) AS QUAD
DECLARE FUNCTION OpenEncryptedFileRawW LIB "advapi32.dll" ALIAS "OpenEncryptedFileRawW" ( BYREF lpFileName AS WSTRINGZ
 , BYVAL ulFlags AS DWORD
 , BYREF pvContext AS ANY
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO OpenEncryptedFileRaw = OpenEncryptedFileRawW
#ELSE
 MACRO OpenEncryptedFileRaw = OpenEncryptedFileRawA
#ENDIF
DECLARE FUNCTION ReadEncryptedFileRaw LIB "advapi32.dll" ALIAS "ReadEncryptedFileRaw" ( BYVAL pfExportCallback AS QUAD , BYVAL pvCallbackContext AS QUAD , BYVAL pvContext AS QUAD ) AS QUAD
DECLARE FUNCTION WriteEncryptedFileRaw LIB "advapi32.dll" ALIAS "WriteEncryptedFileRaw" ( BYVAL pfImportCallback AS QUAD
 , BYVAL pvCallbackContext AS DWORD
 , BYVAL pvContext AS DWORD
 ) AS DWORD
DECLARE SUB CloseEncryptedFileRaw LIB "advapi32.dll" ALIAS "CloseEncryptedFileRaw" ( BYVAL pvContext AS DWORD
 ) ' void
'//
'// _l Compat Functions
'//
DECLARE FUNCTION lstrcmpA LIB "kernel32.dll" ALIAS "lstrcmpA" ( BYREF lpString1 AS ASCIIZ , BYREF lpString2 AS ASCIIZ ) AS LONG ' int
DECLARE FUNCTION lstrcmpW LIB "kernel32.dll" ALIAS "lstrcmpW" ( BYREF lpString1 AS WSTRINGZ , BYREF lpString2 AS WSTRINGZ ) AS LONG ' int
#IF %DEF(%UNICODE)
 MACRO lstrcmp = lstrcmpW
#ELSE
 MACRO lstrcmp = lstrcmpA
#ENDIF
DECLARE FUNCTION lstrcmpiA LIB "kernel32.dll" ALIAS "lstrcmpiA" ( BYREF lpString1 AS ASCIIZ , BYREF lpString2 AS ASCIIZ ) AS LONG ' int
DECLARE FUNCTION lstrcmpiW LIB "kernel32.dll" ALIAS "lstrcmpiW" ( BYREF lpString1 AS WSTRINGZ , BYREF lpString2 AS WSTRINGZ ) AS LONG ' int
#IF %DEF(%UNICODE)
 MACRO lstrcmpi = lstrcmpiW
#ELSE
 MACRO lstrcmpi = lstrcmpiA
#ENDIF
DECLARE FUNCTION lstrcpynA LIB "kernel32.dll" ALIAS "lstrcpynA" ( BYREF lpString1 AS ASCIIZ , BYREF lpString2 AS ASCIIZ , BYVAL iMaxLength AS LONG ) AS QUAD
DECLARE FUNCTION lstrcpynW LIB "kernel32.dll" ALIAS "lstrcpynW" ( BYREF lpString1 AS WSTRINGZ
 , BYREF lpString2 AS WSTRINGZ
 , BYVAL iMaxLength AS LONG
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO lstrcpyn = lstrcpynW
#ELSE
 MACRO lstrcpyn = lstrcpynA
#ENDIF
DECLARE FUNCTION lstrcpyA LIB "kernel32.dll" ALIAS "lstrcpyA" ( BYREF lpString1 AS ASCIIZ , BYREF lpString2 AS ASCIIZ ) AS QUAD
DECLARE FUNCTION lstrcpyW LIB "kernel32.dll" ALIAS "lstrcpyW" ( BYREF lpString1 AS WSTRINGZ
 , BYREF lpString2 AS WSTRINGZ
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO lstrcpy = lstrcpyW
#ELSE
 MACRO lstrcpy = lstrcpyA
#ENDIF
DECLARE FUNCTION lstrcatA LIB "kernel32.dll" ALIAS "lstrcatA" ( BYREF lpString1 AS ASCIIZ , BYREF lpString2 AS ASCIIZ ) AS QUAD
DECLARE FUNCTION lstrcatW LIB "kernel32.dll" ALIAS "lstrcatW" ( BYREF lpString1 AS WSTRINGZ
 , BYREF lpString2 AS WSTRINGZ
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO lstrcat = lstrcatW
#ELSE
 MACRO lstrcat = lstrcatA
#ENDIF
DECLARE FUNCTION lstrlenA LIB "kernel32.dll" ALIAS "lstrlenA" ( BYREF lpString AS ASCIIZ ) AS LONG ' int
DECLARE FUNCTION lstrlenw LIB "kernel32.dll" ALIAS "lstrlenW" ( BYREF lpString AS WSTRINGZ ) AS LONG ' int
#IF %DEF(%UNICODE)
 MACRO lstrlen = lstrlenw
#ELSE
 MACRO lstrlen = lstrlenA
#ENDIF
DECLARE FUNCTION OpenFile LIB "kernel32.dll" ALIAS "OpenFile" ( BYREF lpFileName AS ASCIIZ , BYREF lpReOpenBuff AS OFSTRUCT , BYVAL uStyle AS QUAD ) AS QUAD ' HFILE
DECLARE FUNCTION lopen LIB "kernel32.dll" ALIAS "_lopen" ( BYREF lpPathName0 AS ASCIIZ , BYVAL iReadWrite AS LONG ) AS QUAD ' HFILE
DECLARE FUNCTION lcreat LIB "kernel32.dll" ALIAS "_lcreat" ( BYREF lpPathName AS ASCIIZ , BYVAL iAttribute AS LONG ) AS QUAD ' HFILE
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION lread LIB "Kernel32.dll" ALIAS "_lread" (BYVAL hFile AS QUAD, BYVAL lpBuffer AS QUAD, BYVAL uBytes AS QUAD) AS QUAD
#ELSE
DECLARE FUNCTION lread LIB "kernel32.dll" ALIAS "_lread" ( BYVAL hFile AS QUAD , BYREF lpBuffer AS ANY , BYVAL uBytes AS QUAD ) AS QUAD ' UINT
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION lwrite LIB "Kernel32.dll" ALIAS "_lwrite" (BYVAL hFile AS QUAD, BYVAL lpBuffer AS QUAD, BYVAL uBytes AS QUAD) AS QUAD
#ELSE
DECLARE FUNCTION lwrite LIB "kernel32.dll" ALIAS "_lwrite" ( BYVAL hFile AS QUAD , BYREF lpBuffer AS ASCIIZ , BYVAL uBytes AS QUAD ) AS QUAD ' UINT
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION hread LIB "Kernel32.dll" ALIAS "_hread" (BYVAL hFile AS QUAD, BYVAL lpBuffer AS QUAD, BYVAL lBytes AS LONG) AS LONG
#ELSE
DECLARE FUNCTION hread LIB "kernel32.dll" ALIAS "_hread" ( BYVAL hFile AS QUAD , BYREF lpBuffer AS ANY , BYVAL lBytes AS LONG ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION hwrite LIB "Kernel32.dll" ALIAS "_hwrite" (BYVAL hFile AS QUAD, BYVAL lpBuffer AS QUAD, BYVAL lBytes AS LONG) AS LONG
#ELSE
DECLARE FUNCTION hwrite LIB "kernel32.dll" ALIAS "_hwrite" ( BYVAL hFile AS QUAD , BYREF lpBuffer AS ASCIIZ , BYVAL lBytes AS LONG ) AS LONG
#ENDIF
DECLARE FUNCTION lclose LIB "kernel32.dll" ALIAS "_lclose" ( BYVAL hFile AS QUAD ) AS QUAD ' HFILE
DECLARE FUNCTION llseek LIB "kernel32.dll" ALIAS "_llseek" ( BYVAL hFile AS QUAD , BYVAL lOffset AS LONG , BYVAL iOrigin AS LONG ) AS LONG
DECLARE FUNCTION IsTextUnicode LIB "advapi32.dll" ALIAS "IsTextUnicode" ( BYVAL lpv AS QUAD
 , BYVAL iSize AS LONG
 , OPTIONAL BYREF lpiResult AS LONG
 ) AS LONG
%EQUATE `FLS_OUT_OF_INDEXES = &HFFFFFFFF ' ((DWORD)0xFFFFFFFF)
DECLARE FUNCTION FlsAlloc LIB "kernel32.dll" ALIAS "FlsAlloc" ( BYVAL lpCallback AS QUAD ) AS QUAD
DECLARE FUNCTION FlsGetValue LIB "kernel32.dll" ALIAS "FlsGetValue" ( BYVAL dwFlsIndex AS QUAD
 ) AS DWORD
DECLARE FUNCTION FlsSetValue LIB "kernel32.dll" ALIAS "FlsSetValue" ( BYVAL dwFlsIndex AS DWORD
 , OPTIONAL BYVAL lpFlsData AS DWORD
 ) AS LONG
DECLARE FUNCTION FlsFree LIB "kernel32.dll" ALIAS "FlsFree" ( BYVAL dwFlsIndex AS DWORD
 ) AS LONG
%EQUATE `TLS_OUT_OF_INDEXES = &HFFFFFFFF ' ((DWORD)0xFFFFFFFF)
DECLARE FUNCTION TlsAlloc LIB "kernel32.dll" ALIAS "TlsAlloc" ( ) AS QUAD
DECLARE FUNCTION TlsGetValue LIB "kernel32.dll" ALIAS "TlsGetValue" ( BYVAL dwTlsIndex AS QUAD
 ) AS DWORD
DECLARE FUNCTION TlsSetValue LIB "kernel32.dll" ALIAS "TlsSetValue" ( BYVAL dwTlsIndex AS DWORD
 , BYREF lpTlsValue AS ANY
 ) AS LONG
DECLARE FUNCTION TlsFree LIB "kernel32.dll" ALIAS "TlsFree" ( BYVAL dwTlsIndex AS DWORD
 ) AS LONG
'typedef
'(WINAPI *LPOVERLAPPED_COMPLETION_ROUTINE)(
' );
DECLARE FUNCTION SleepEx LIB "kernel32.dll" ALIAS "SleepEx" ( BYVAL dwMilliseconds AS QUAD , BYVAL bAlertable AS LONG ) AS QUAD
DECLARE FUNCTION WaitForSingleObjectEx LIB "kernel32.dll" ALIAS "WaitForSingleObjectEx" ( BYVAL hHandle AS QUAD
 , BYVAL dwMilliseconds AS DWORD
 , BYVAL bAlertable AS LONG
 ) AS DWORD
DECLARE FUNCTION WaitForMultipleObjectsEx LIB "kernel32.dll" ALIAS "WaitForMultipleObjectsEx" ( BYVAL nCount AS DWORD
 , BYREF lpHandles AS DWORD
 , BYVAL bWaitAll AS LONG
 , BYVAL dwMilliseconds AS DWORD
 , BYVAL bAlertable AS LONG
 ) AS DWORD
'#if(_WIN32_WINNT >= 0x0400)
DECLARE FUNCTION SignalObjectAndWait LIB "kernel32.dll" ALIAS "SignalObjectAndWait" ( BYVAL hObjectToSignal AS QUAD , BYVAL hObjectToWaitOn AS QUAD , BYVAL dwMilliseconds AS QUAD , BYVAL bAlertable AS LONG ) AS QUAD
'#endif /* _WIN32_WINNT >= 0x0400 */
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION ReadFileEx LIB "Kernel32.dll" ALIAS "ReadFileEx" (BYVAL hFile AS QUAD, BYVAL lpBuffer AS QUAD, BYVAL nNumberOfBytesToRead AS QUAD, lpOverlapped AS OVERLAPPED, BYVAL lpCompletionRoutine AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION ReadFileEx LIB "kernel32.dll" ALIAS "ReadFileEx" ( BYVAL hFile AS QUAD , BYREF lpBuffer AS ANY , BYVAL nNumberOfBytesToRead AS QUAD , BYREF lpOverlapped AS OVERLAPPED , BYVAL lpCompletionRoutine AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION WriteFileEx LIB "Kernel32.dll" ALIAS "WriteFileEx" (BYVAL hFile AS QUAD, BYVAL lpBuffer AS QUAD, BYVAL nNumberOfBytesToWrite AS QUAD, lpOverlapped AS OVERLAPPED, BYVAL lpCompletionRoutine AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION WriteFileEx LIB "kernel32.dll" ALIAS "WriteFileEx" ( BYVAL hFile AS QUAD , BYREF lpBuffer AS ANY , BYVAL nNumberOfBytesToWrite AS QUAD , BYREF lpOverlapped AS OVERLAPPED , BYVAL lpCompletionRoutine AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION BackupRead LIB "Kernel32.dll" ALIAS "BackupRead" (BYVAL hFile AS QUAD, BYVAL lpBuffer AS QUAD, BYVAL nNumberOfBytesToRead AS QUAD, lpNumberOfBytesRead AS QUAD, BYVAL bAbort AS LONG, BYVAL bProcessSecurity AS LONG, lpContext AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION BackupRead LIB "kernel32.dll" ALIAS "BackupRead" ( BYVAL hFile AS QUAD , BYREF lpBuffer AS ANY , BYVAL nNumberOfBytesToRead AS QUAD , BYREF lpNumberOfBytesRead AS QUAD , BYVAL bAbort AS LONG , BYVAL bProcessSecurity AS LONG , BYREF lpContext AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION BackupSeek LIB "Kernel32.dll" ALIAS "BackupSeek" (BYVAL hFile AS QUAD, BYVAL dwLowBytesToSeek AS QUAD, BYVAL dwHighBytesToSeek AS QUAD, lpdwLowByteSeeked AS QUAD, lpdwHighByteSeeked AS LONG, lpContext AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION BackupSeek LIB "kernel32.dll" ALIAS "BackupSeek" ( BYVAL hFile AS QUAD , BYVAL dwLowBytesToSeek AS QUAD , BYVAL dwHighBytesToSeek AS QUAD , BYREF lpdwLowByteSeeked AS QUAD , BYREF lpdwHighByteSeeked AS QUAD , BYVAL lpContext AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION BackupWrite LIB "Kernel32.dll" ALIAS "BackupWrite" (BYVAL hFile AS QUAD, BYVAL lpBuffer AS QUAD, BYVAL nNumberOfBytesToWrite AS QUAD, lpNumberOfBytesWritten AS QUAD, BYVAL bAbort AS LONG, BYVAL bProcessSecurity AS LONG, lpContext AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION BackupWrite LIB "kernel32.dll" ALIAS "BackupWrite" ( BYVAL hFile AS QUAD , BYREF lpBuffer AS ANY , BYVAL nNumberOfBytesToWrite AS QUAD , BYREF lpNumberOfBytesWritten AS QUAD , BYVAL bAbort AS LONG , BYVAL bProcessSecurity AS LONG , BYVAL lpContext AS QUAD ) AS LONG
#ENDIF
'//
'// Stream id structure
'//
' // Size = 24 bytes
TYPE WIN32_STREAM_ID DWORD
 dwStreamID AS DWORD ' DWORD dwStreamId
 dwStreamAttributes AS DWORD ' DWORD dwStreamAttributes
 qsize AS QUAD ' LARGE_INTEGER Size
 dwStreamNameSize AS DWORD ' DWORD dwStreamNameSize
 cStreamName(0) AS WORD ' WCHAR cStreamName[ ANYSIZE_ARRAY ]
END TYPE
'//
'// Stream Ids
'//
%EQUATE `BACKUP_INVALID = &H00000000
%EQUATE `BACKUP_DATA = &H00000001
%EQUATE `BACKUP_EA_DATA = &H00000002
%EQUATE `BACKUP_SECURITY_DATA = &H00000003
%EQUATE `BACKUP_ALTERNATE_DATA = &H00000004
%EQUATE `BACKUP_LINK = &H00000005
%EQUATE `BACKUP_PROPERTY_DATA = &H00000006
%EQUATE `BACKUP_OBJECT_ID = &H00000007
%EQUATE `BACKUP_REPARSE_DATA = &H00000008
%EQUATE `BACKUP_SPARSE_BLOCK = &H00000009
%EQUATE `BACKUP_TXFS_DATA = &H0000000a
'//
'// Stream Attributes
'//
%EQUATE `STREAM_NORMAL_ATTRIBUTE = &H00000000
%EQUATE `STREAM_MODIFIED_WHEN_READ = &H00000001
%EQUATE `STREAM_CONTAINS_SECURITY = &H00000002
%EQUATE `STREAM_CONTAINS_PROPERTIES = &H00000004
%EQUATE `STREAM_SPARSE_ATTRIBUTE = &H00000008
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION ReadFileScatter LIB "Kernel32.dll" ALIAS "ReadFileScatter" (BYVAL hFile AS QUAD, BYVAL aSegmentArray AS FILE_SEGMENT_ELEMENT PTR, BYVAL nNumberOfBytesToRead AS QUAD, BYVAL lpReserved AS QUAD, lpOverlapped AS OVERLAPPED) AS LONG
#ELSE
DECLARE FUNCTION ReadFileScatter LIB "kernel32.dll" ALIAS "ReadFileScatter" ( BYVAL hFile AS QUAD , BYREF aSegmentArray AS FILE_SEGMENT_ELEMENT , BYVAL nNumberOfBytesToRead AS QUAD , BYVAL lpReserved AS QUAD , BYREF lpOverlapped AS OVERLAPPED ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION WriteFileGather LIB "Kernel32.dll" ALIAS "WriteFileGather" (BYVAL hFile AS QUAD, BYVAL aSegmentArray AS FILE_SEGMENT_ELEMENT PTR, BYVAL nNumberOfBytesToWrite AS QUAD, BYVAL lpReserved AS QUAD, lpOverlapped AS OVERLAPPED) AS LONG
#ELSE
DECLARE FUNCTION WriteFileGather LIB "kernel32.dll" ALIAS "WriteFileGather" ( BYVAL hFile AS QUAD , BYREF aSegmentArray AS FILE_SEGMENT_ELEMENT , BYVAL nNumberOfBytesToWrite AS QUAD , BYVAL lpReserved AS QUAD , BYREF lpOverlapped AS OVERLAPPED ) AS LONG
#ENDIF
'//
'// Dual Mode API below this line. Dual Mode Structures also included.
'//
%EQUATE `STARTF_USESHOWWINDOW = &H00000001
%EQUATE `STARTF_USESIZE = &H00000002
%EQUATE `STARTF_USEPOSITION = &H00000004
%EQUATE `STARTF_USECOUNTCHARS = &H00000008
%EQUATE `STARTF_USEFILLATTRIBUTE = &H00000010
%EQUATE `STARTF_RUNFULLSCREEN = &H00000020 ' ignored for non-x86 platforms
%EQUATE `STARTF_FORCEONFEEDBACK = &H00000040
%EQUATE `STARTF_FORCEOFFFEEDBACK = &H00000080
%EQUATE `STARTF_USESTDHANDLES = &H00000100
'#if(WINVER >= 0x0400)
%EQUATE `STARTF_USEHOTKEY = &H00000200
%EQUATE `STARTF_TITLEISLINKNAME = &H00000800
%EQUATE `STARTF_TITLEISAPPID = &H00001000
%EQUATE `STARTF_PREVENTPINNING = &H00002000
'#endif /* WINVER >= 0x0400 */
' // Size = 68 bytes
TYPE STARTUPINFOA DWORD FILL
 cb AS DWORD ' DWORD cb
 lpReserved AS ASCIIZ PTR ' LPSTR lpReserved
 lpDesktop AS ASCIIZ PTR ' LPSTR lpDesktop
 lpTitle AS ASCIIZ PTR ' LPSTR lpTitle
 dwX AS DWORD ' DWORD dwX
 dwY AS DWORD ' DWORD dwY
 dwXSize AS DWORD ' DWORD dwXSize
 dwYSize AS DWORD ' DWORD dwYSize
 dwXCountChars AS DWORD ' DWORD dwXCountChars
 dwYCountChars AS DWORD ' DWORD dwYCountChars
 dwFillAttribute AS DWORD ' DWORD dwFillAttribute
 dwFlags AS DWORD ' DWORD dwFlags
 wShowWindow AS WORD ' WORD wShowWindow
 cbReserved2 AS WORD ' WORD cbReserved2
 lpReserved2 AS BYTE PTR ' LPBYTE lpReserved2
 hStdInput AS DWORD ' HANDLE hStdInput
 hStdOutput AS DWORD ' HANDLE hStdOutput
 hStdError AS DWORD ' HANDLE hStdError
END TYPE
' // Size = 68 bytes
TYPE STARTUPINFOW DWORD FILL
 cb AS DWORD ' DWORD cb
 lpReserved AS WSTRINGZ PTR ' LPWSTR lpReserved
 lpDesktop AS WSTRINGZ PTR ' LPWSTR lpDesktop
 lpTitle AS WSTRINGZ PTR ' LPWSTR lpTitle
 dwX AS DWORD ' DWORD dwX
 dwY AS DWORD ' DWORD dwY
 dwXSize AS DWORD ' DWORD dwXSize
 dwYSize AS DWORD ' DWORD dwYSize
 dwXCountChars AS DWORD ' DWORD dwXCountChars
 dwYCountChars AS DWORD ' DWORD dwYCountChars
 dwFillAttribute AS DWORD ' DWORD dwFillAttribute
 dwFlags AS DWORD ' DWORD dwFlags
 wShowWindow AS WORD ' WORD wShowWindow
 cbReserved2 AS WORD ' WORD cbReserved2
 lpReserved2 AS BYTE PTR ' LPBYTE lpReserved2
 hStdInput AS DWORD ' HANDLE hStdInput
 hStdOutput AS DWORD ' HANDLE hStdOutput
 hStdError AS DWORD ' HANDLE hStdError
END TYPE
#IF %DEF(%UNICODE)
 MACRO STARTUPINFO = STARTUPINFOW
#ELSE
 MACRO STARTUPINFO = STARTUPINFOA
#ENDIF
'#if (_WIN32_WINNT >= 0x0600)
UNION STARTUPINFOEXA_UNION
 StartupInfo AS STARTUPINFOA
 ' // For compatibility with the PB declares
 StartupInfoValue AS STARTUPINFOA
END UNION
' // Size = 72 bytes
TYPE STARTUPINFOEXA DWORD FILL
 STARTUPINFOEXA_UNION
 lpAttributeList AS DWORD ' LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList
END TYPE
UNION STARTUPINFOEXW_UNION
 StartupInfo AS STARTUPINFOW
 ' // For compatibility with the PB declares
 StartupInfoValue AS STARTUPINFOW
END UNION
' // Size = 72 bytes
TYPE STARTUPINFOEXW DWORD FILL
 STARTUPINFOEXW_UNION
 lpAttributeList AS DWORD ' LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList
END TYPE
#IF %DEF(%UNICODE)
 MACRO STARTUPINFOEX = STARTUPINFOEXW
#ELSE
 MACRO STARTUPINFOEX = STARTUPINFOEXA
#ENDIF
'#endif // (_WIN32_WINNT >= 0x0600)
%EQUATE `SHUTDOWN_NORETRY = &H00000001
' // Size = 320 bytes
TYPE WIN32_FIND_DATAA DWORD
 dwFileAttributes AS DWORD ' DWORD dwFileAttributes
 ftCreationTime AS FILETIME ' FILETIME ftCreationTime
 ftLastAccessTime AS FILETIME ' FILETIME ftLastAccessTime
 ftLastWriteTime AS FILETIME ' FILETIME ftLastWriteTime
 nFileSizeHigh AS DWORD ' DWORD nFileSizeHigh
 nFileSizeLow AS DWORD ' DWORD nFileSizeLow
 dwReserved0 AS DWORD ' DWORD dwReserved0
 dwReserved1 AS DWORD ' DWORD dwReserved1
 cFileName AS ASCIIZ * %MAX_PATH ' CHAR cFileName[ MAX_PATH ]
 cAlternateFileName AS ASCIIZ * 14 ' CHAR cAlternateFileName[ 14 ]
END TYPE
' // Size = 592 bytes
TYPE WIN32_FIND_DATAW DWORD
 dwFileAttributes AS DWORD ' DWORD dwFileAttributes
 ftCreationTime AS FILETIME ' FILETIME ftCreationTime
 ftLastAccessTime AS FILETIME ' FILETIME ftLastAccessTime
 ftLastWriteTime AS FILETIME ' FILETIME ftLastWriteTime
 nFileSizeHigh AS DWORD ' DWORD nFileSizeHigh
 nFileSizeLow AS DWORD ' DWORD nFileSizeLow
 dwReserved0 AS DWORD ' DWORD dwReserved0
 dwReserved1 AS DWORD ' DWORD dwReserved1
 cFileName AS WSTRINGZ * %MAX_PATH ' WCHAR cFileName[ MAX_PATH ]
 cAlternateFileName AS WSTRINGZ * 14 ' WCHAR cAlternateFileName[ 14 ]
END TYPE
#IF %DEF(%UNICODE)
 MACRO WIN32_FIND_DATA = WIN32_FIND_DATAW
#ELSE
 MACRO WIN32_FIND_DATA = WIN32_FIND_DATAA
#ENDIF
' // Size = 36 bytes
TYPE WIN32_FILE_ATTRIBUTE_DATA DWORD
 dwFileAttributes AS DWORD ' DWORD dwFileAttributes
 ftCreationTime AS FILETIME ' FILETIME ftCreationTime
 ftLastAccessTime AS FILETIME ' FILETIME ftLastAccessTime
 ftLastWriteTime AS FILETIME ' FILETIME ftLastWriteTime
 nFileSizeHigh AS DWORD ' DWORD nFileSizeHigh
 nFileSizeLow AS DWORD ' DWORD nFileSizeLow
END TYPE
DECLARE FUNCTION CreateMutexA LIB "kernel32.dll" ALIAS "CreateMutexA" ( BYREF lpMutexAttributes AS SECURITY_ATTRIBUTES , BYVAL bInitialOwner AS LONG , BYREF lpName AS ASCIIZ ) AS QUAD
DECLARE FUNCTION CreateMutexW LIB "kernel32.dll" ALIAS "CreateMutexW" ( BYREF lpMutexAttributes AS SECURITY_ATTRIBUTES
 , BYVAL bInitialOwner AS LONG
 , BYREF lpName AS WSTRINGZ
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO CreateMutex = CreateMutexW
#ELSE
 MACRO CreateMutex = CreateMutexA
#ENDIF
DECLARE FUNCTION OpenMutexA LIB "kernel32.dll" ALIAS "OpenMutexA" ( BYVAL dwDesiredAccess AS QUAD , BYVAL bInheritHandle AS LONG , BYREF lpName AS ASCIIZ ) AS QUAD
DECLARE FUNCTION OpenMutexW LIB "kernel32.dll" ALIAS "OpenMutexW" ( BYVAL dwDesiredAccess AS QUAD
 , BYVAL bInheritHandle AS LONG
 , BYREF lpName AS WSTRINGZ
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO OpenMutex = OpenMutexW
#ELSE
 MACRO OpenMutex = OpenMutexA
#ENDIF
DECLARE FUNCTION CreateEventA LIB "kernel32.dll" ALIAS "CreateEventA" ( BYREF lpEventAttributes AS SECURITY_ATTRIBUTES , BYVAL bManualReset AS LONG , BYVAL bInitialState AS LONG , BYREF lpName AS ASCIIZ ) AS QUAD
DECLARE FUNCTION CreateEventW LIB "kernel32.dll" ALIAS "CreateEventW" ( BYREF lpEventAttributes AS SECURITY_ATTRIBUTES
 , BYVAL bManualReset AS LONG
 , BYVAL bInitialState AS LONG
 , BYREF lpName AS WSTRINGZ
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO CreateEvent = CreateEventW
#ELSE
 MACRO CreateEvent = CreateEventA
#ENDIF
DECLARE FUNCTION OpenEventA LIB "kernel32.dll" ALIAS "OpenEventA" ( BYVAL dwDesiredAccess AS QUAD , BYVAL bInheritHandle AS LONG , BYREF lpName AS ASCIIZ ) AS QUAD
DECLARE FUNCTION OpenEventW LIB "kernel32.dll" ALIAS "OpenEventW" ( BYVAL dwDesiredAccess AS QUAD
 , BYVAL bInheritHandle AS LONG
 , BYREF lpName AS WSTRINGZ
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO OpenEvent = OpenEventW
#ELSE
 MACRO OpenEvent = OpenEventA
#ENDIF
DECLARE FUNCTION CreateSemaphoreA LIB "kernel32.dll" ALIAS "CreateSemaphoreA" ( BYREF lpSemaphoreAttributes AS SECURITY_ATTRIBUTES , BYVAL lInitialCount AS LONG , BYVAL lMaximumCount AS LONG , BYREF lpName AS ASCIIZ ) AS QUAD
DECLARE FUNCTION CreateSemaphoreW LIB "kernel32.dll" ALIAS "CreateSemaphoreW" ( BYREF lpSemaphoreAttributes AS SECURITY_ATTRIBUTES
 , BYVAL lInitialCount AS LONG
 , BYVAL lMaximumCount AS LONG
 , BYREF lpName AS WSTRINGZ
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO CreateSemaphore = CreateSemaphoreW
#ELSE
 MACRO CreateSemaphore = CreateSemaphoreA
#ENDIF
DECLARE FUNCTION OpenSemaphoreA LIB "kernel32.dll" ALIAS "OpenSemaphoreA" ( BYVAL dwDesiredAccess AS QUAD , BYVAL bInheritHandle AS LONG , BYREF lpName AS ASCIIZ ) AS QUAD
DECLARE FUNCTION OpenSemaphoreW LIB "kernel32.dll" ALIAS "OpenSemaphoreW" ( BYVAL dwDesiredAccess AS QUAD
 , BYVAL bInheritHandle AS LONG
 , BYREF lpName AS WSTRINGZ
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO OpenSemaphore = OpenSemaphoreW
#ELSE
 MACRO OpenSemaphore = OpenSemaphoreA
#ENDIF
'#if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400)
'typedef
'(APIENTRY *PTIMERAPCROUTINE)(
' );
DECLARE FUNCTION CreateWaitableTimerA LIB "kernel32.dll" ALIAS "CreateWaitableTimerA" ( BYREF lpTimerAttributes AS SECURITY_ATTRIBUTES , BYVAL bManualReset AS LONG , BYREF lpTimerName AS ASCIIZ ) AS QUAD
DECLARE FUNCTION CreateWaitableTimerW LIB "kernel32.dll" ALIAS "CreateWaitableTimerW" ( BYREF lpTimerAttributes AS SECURITY_ATTRIBUTES
 , BYVAL bManualReset AS LONG
 , BYREF lpTimerName AS WSTRINGZ
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO CreateWaitableTimer = CreateWaitableTimerW
#ELSE
 MACRO CreateWaitableTimer = CreateWaitableTimerA
#ENDIF
DECLARE FUNCTION OpenWaitableTimerA LIB "kernel32.dll" ALIAS "OpenWaitableTimerA" ( BYVAL dwDesiredAccess AS QUAD , BYVAL bInheritHandle AS LONG , BYREF lpTimerName AS ASCIIZ ) AS QUAD
DECLARE FUNCTION OpenWaitableTimerW LIB "kernel32.dll" ALIAS "OpenWaitableTimerW" ( BYVAL dwDesiredAccess AS QUAD
 , BYVAL bInheritHandle AS LONG
 , BYREF lpTimerName AS WSTRINGZ
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO OpenWaitableTimer = OpenWaitableTimerW
#ELSE
 MACRO OpenWaitableTimer = OpenWaitableTimerA
#ENDIF
'#if (_WIN32_WINNT >= _WIN32_WINNT_WIN7)
#IF %WINVER >= &H0601
' Note: Although the lpDueTime parameter is a QUAD, it is more practical to use
' a FILETIME structure. Therefore, the parameter as been declared BYREF ANY to
' allow passing a QUAD or a FILETIME structure.
DECLARE FUNCTION SetWaitableTimerEx LIB "kernel32.dll" ALIAS "SetWaitableTimerEx" ( BYVAL hTimer AS QUAD , BYREF lpDueTime AS ANY , BYVAL lPeriod AS LONG , BYVAL pfnCompletionRoutine AS QUAD , BYREF lpArgToCompletionRoutine AS ANY , BYREF WakeContext AS REASON_CONTEXT , BYVAL TolerableDelay AS QUAD ) AS LONG
#ENDIF ' // (_WIN32_WINNT >= _WIN32_WINNT_WIN7)
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION SetWaitableTimer LIB "Kernel32.dll" ALIAS "SetWaitableTimer" (BYVAL hTimer AS QUAD, lpDueTime AS ANY, BYVAL lPeriod AS LONG, BYVAL pfnCompletionRoutine AS QUAD, BYVAL lpArgToCompletionRoutine AS QUAD, BYVAL fResume AS LONG) AS LONG
#ELSE
' Note: Although the lpDueTime parameter is a QUAD, it is more practical to use
' a FILETIME structure. Therefore, the parameter as been declared BYREF ANY to
' allow passing a QUAD or a FILETIME structure.
DECLARE FUNCTION SetWaitableTimer LIB "kernel32.dll" ALIAS "SetWaitableTimer" ( BYVAL hTimer AS QUAD , BYREF lpDueTime AS ANY , BYVAL lPeriod AS LONG , BYVAL pfnCompletionRoutine AS QUAD , BYVAL lpArgToCompletionRoutine AS QUAD , BYVAL fResume AS LONG ) AS LONG
#ENDIF
DECLARE FUNCTION CancelWaitableTimer LIB "kernel32.dll" ALIAS "CancelWaitableTimer" ( BYVAL hTimer AS QUAD ) AS LONG
'#if (_WIN32_WINNT >= 0x0600)
#IF %WINVER >= &H0600
%EQUATE `CREATE_MUTEX_INITIAL_OWNER = &H00000001
DECLARE FUNCTION CreateMutexExA LIB "kernel32.dll" ALIAS "CreateMutexExA" ( BYREF lpMutexAttributes AS SECURITY_ATTRIBUTES , BYREF lpName AS ASCIIZ , BYVAL dwFlags AS QUAD , BYVAL dwDesiredAccess AS QUAD ) AS QUAD
DECLARE FUNCTION CreateMutexExW LIB "kernel32.dll" ALIAS "CreateMutexExW" ( BYREF lpMutexAttributes AS SECURITY_ATTRIBUTES
 , BYREF lpName AS WSTRINGZ
 , BYVAL dwFlags AS DWORD
 , BYVAL dwDesiredAccess AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO CreateMutexEx = CreateMutexExW
#ELSE
 MACRO CreateMutexEx = CreateMutexExA
#ENDIF
%EQUATE `CREATE_EVENT_MANUAL_RESET = &H00000001
%EQUATE `CREATE_EVENT_INITIAL_SET = &H00000002
DECLARE FUNCTION CreateEventExA LIB "kernel32.dll" ALIAS "CreateEventExA" ( BYREF lpEventAttributes AS SECURITY_ATTRIBUTES , BYREF lpName AS ASCIIZ , BYVAL dwFlags AS QUAD , BYVAL dwDesiredAccess AS QUAD ) AS QUAD
DECLARE FUNCTION CreateEventExW LIB "kernel32.dll" ALIAS "CreateEventExW" ( BYREF lpEventAttributes AS SECURITY_ATTRIBUTES
 , BYREF lpName AS WSTRINGZ
 , BYVAL dwFlags AS DWORD
 , BYVAL dwDesiredAccess AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO CreateEventEx = CreateEventExW
#ELSE
 MACRO CreateEventEx = CreateEventExA
#ENDIF
DECLARE FUNCTION CreateSemaphoreExA LIB "kernel32.dll" ALIAS "CreateSemaphoreExA" ( BYREF lpSemaphoreAttributes AS SECURITY_ATTRIBUTES , BYVAL lInitialCount AS LONG , BYVAL lMaximumCount AS LONG , BYREF lpName AS ASCIIZ , BYVAL dwFlags AS QUAD , BYVAL dwDesiredAccess AS QUAD ) AS QUAD
DECLARE FUNCTION CreateSemaphoreExW LIB "kernel32.dll" ALIAS "CreateSemaphoreExW" ( BYREF lpSemaphoreAttributes AS SECURITY_ATTRIBUTES
 , BYVAL lInitialCount AS LONG
 , BYVAL lMaximumCount AS LONG
 , BYREF lpName AS WSTRINGZ
 , BYVAL dwFlags AS DWORD
 , BYVAL dwDesiredAccess AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO CreateSemaphoreEx = CreateSemaphoreExW
#ELSE
 MACRO CreateSemaphoreEx = CreateSemaphoreExA
#ENDIF
%EQUATE `CREATE_WAITABLE_TIMER_MANUAL_RESET = &H00000001
DECLARE FUNCTION CreateWaitableTimerExA LIB "kernel32.dll" ALIAS "CreateWaitableTimerExA" ( BYREF lpSemaphoreAttributes AS SECURITY_ATTRIBUTES , BYREF lpTimerName AS ASCIIZ , BYVAL dwFlags AS QUAD , BYVAL dwDesiredAccess AS QUAD ) AS QUAD
DECLARE FUNCTION CreateWaitableTimerExW LIB "kernel32.dll" ALIAS "CreateWaitableTimerExW" ( BYREF lpSemaphoreAttributes AS SECURITY_ATTRIBUTES
 , BYREF lpTimerName AS WSTRINGZ
 , BYVAL dwFlags AS DWORD
 , BYVAL dwDesiredAccess AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO CreateWaitableTimerEx = CreateWaitableTimerExW
#ELSE
 MACRO CreateWaitableTimerEx = CreateWaitableTimerExA
#ENDIF
#ENDIF ' /* (_WIN32_WINNT >= 0x0600) */
'#endif /* (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400) */
DECLARE FUNCTION CreateFileMappingA LIB "kernel32.dll" ALIAS "CreateFileMappingA" ( BYVAL hFile AS QUAD , BYREF lpFileMappingAttributes AS SECURITY_ATTRIBUTES , BYVAL flProtect AS QUAD , BYVAL dwMaximumSizeHigh AS QUAD , BYVAL dwMaximumSizeLow AS QUAD , BYREF lpName AS ASCIIZ ) AS QUAD
DECLARE FUNCTION CreateFileMappingW LIB "kernel32.dll" ALIAS "CreateFileMappingW" ( BYVAL hFile AS QUAD
 , BYREF lpFileMappingAttributes AS SECURITY_ATTRIBUTES
 , BYVAL flProtect AS DWORD
 , BYVAL dwMaximumSizeHigh AS DWORD
 , BYVAL dwMaximumSizeLow AS DWORD
 , BYREF lpName AS WSTRINGZ
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO CreateFileMapping = CreateFileMappingW
#ELSE
 MACRO CreateFileMapping = CreateFileMappingA
#ENDIF
'#if _WIN32_WINNT >= 0x0600
#IF %WINVER >= &H0600
DECLARE FUNCTION CreateFileMappingNumaA LIB "kernel32.dll" ALIAS "CreateFileMappingNumaA" ( BYVAL hFile AS QUAD , BYREF lpFileMappingAttributes AS SECURITY_ATTRIBUTES , BYVAL flProtect AS QUAD , BYVAL dwMaximumSizeHigh AS QUAD , BYVAL dwMaximumSizeLow AS QUAD , BYREF lpName AS ASCIIZ , BYVAL nndPreferred AS QUAD ) AS QUAD
DECLARE FUNCTION CreateFileMappingNumaW LIB "kernel32.dll" ALIAS "CreateFileMappingNumaW" ( BYVAL hFile AS QUAD
 , BYREF lpFileMappingAttributes AS SECURITY_ATTRIBUTES
 , BYVAL flProtect AS DWORD
 , BYVAL dwMaximumSizeHigh AS DWORD
 , BYVAL dwMaximumSizeLow AS DWORD
 , BYREF lpName AS WSTRINGZ
 , BYVAL nndPreferred AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO CreateFileMappingNuma = CreateFileMappingNumaW
#ELSE
 MACRO CreateFileMappingNuma = CreateFileMappingNumaA
#ENDIF
#ENDIF ' // _WIN32_WINNT >= 0x0600
DECLARE FUNCTION OpenFileMappingA LIB "kernel32.dll" ALIAS "OpenFileMappingA" ( BYVAL dwDesiredAccess AS QUAD , BYVAL bInheritHandle AS LONG , BYREF lpName AS ASCIIZ ) AS QUAD
DECLARE FUNCTION OpenFileMappingW LIB "kernel32.dll" ALIAS "OpenFileMappingW" ( BYVAL dwDesiredAccess AS QUAD
 , BYVAL bInheritHandle AS LONG
 , BYREF lpName AS WSTRINGZ
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO OpenFileMapping = OpenFileMappingW
#ELSE
 MACRO OpenFileMapping = OpenFileMappingA
#ENDIF
' // Note: The lpBuffer parameter has been declared as BYVAL DWORD instead of BYREF ASCIIZ/WSTRINGZ
' // to allow to pass a pointer to another kind of buffer, since it returns a series of
' // null-terminated strings, one for each valid drive in the system, plus with an additional null character.
DECLARE FUNCTION GetLogicalDriveStringsA LIB "kernel32.dll" ALIAS "GetLogicalDriveStringsA" ( BYVAL nBufferLength AS QUAD , BYVAL lpBuffer AS QUAD ) AS QUAD
DECLARE FUNCTION GetLogicalDriveStringsW LIB "kernel32.dll" ALIAS "GetLogicalDriveStringsW" ( BYVAL nBufferLength AS QUAD
 , BYVAL lpBuffer AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO GetLogicalDriveStrings = GetLogicalDriveStringsW
#ELSE
 MACRO GetLogicalDriveStrings = GetLogicalDriveStringsA
#ENDIF
'#if _WIN32_WINNT >= 0x0501
' MEMORY_RESOURCE_NOTIFICATION_TYPE enum
%EQUATE `LowMemoryResourceNotification = 0
%EQUATE `HighMemoryResourceNotification = 1
DECLARE FUNCTION CreateMemoryResourceNotification LIB "kernel32.dll" ALIAS "CreateMemoryResourceNotification" ( BYVAL NotificationType AS QUAD ) AS QUAD
DECLARE FUNCTION QueryMemoryResourceNotification LIB "kernel32.dll" ALIAS "QueryMemoryResourceNotification" ( BYVAL ResourceNotificationHandle AS QUAD
 , BYREF ResourceState AS LONG
 ) AS LONG
'#endif // _WIN32_WINNT >= 0x0501
DECLARE FUNCTION LoadLibraryA LIB "kernel32.dll" ALIAS "LoadLibraryA" ( BYREF lpLibFileName AS ASCIIZ ) AS QUAD ' HMODULE
DECLARE FUNCTION LoadLibraryW LIB "kernel32.dll" ALIAS "LoadLibraryW" ( BYREF lpLibFileName AS WSTRINGZ ) AS QUAD ' HMODULE
#IF %DEF(%UNICODE)
 MACRO LoadLibrary = LoadLibraryW
#ELSE
 MACRO LoadLibrary = LoadLibraryA
#ENDIF
DECLARE FUNCTION LoadLibraryExA LIB "kernel32.dll" ALIAS "LoadLibraryExA" ( BYREF lpLibFileName AS ASCIIZ , BYVAL hFile AS QUAD , BYVAL dwFlags AS QUAD ) AS QUAD ' HMODULE
DECLARE FUNCTION LoadLibraryExW LIB "kernel32.dll" ALIAS "LoadLibraryExW" ( BYREF lpLibFileName AS WSTRINGZ , BYVAL hFile AS QUAD , BYVAL dwFlags AS QUAD ) AS QUAD ' HMODULE
#IF %DEF(%UNICODE)
 MACRO LoadLibraryEx = LoadLibraryExW
#ELSE
 MACRO LoadLibraryEx = LoadLibraryExA
#ENDIF
%EQUATE `DONT_RESOLVE_DLL_REFERENCES = &H00000001
%EQUATE `LOAD_LIBRARY_AS_DATAFILE = &H00000002
%EQUATE `LOAD_WITH_ALTERED_SEARCH_PATH = &H00000008
%EQUATE `LOAD_IGNORE_CODE_AUTHZ_LEVEL = &H00000010
%EQUATE `LOAD_LIBRARY_AS_IMAGE_RESOURCE = &H00000020
%EQUATE `LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE = &H00000040
%EQUATE `LOAD_LIBRARY_REQUIRE_SIGNED_TARGET = &H00000080
DECLARE FUNCTION GetModuleFileNameA LIB "kernel32.dll" ALIAS "GetModuleFileNameA" ( BYVAL hModule AS QUAD , BYREF lpFilename AS ASCIIZ , BYVAL nSize AS QUAD ) AS QUAD
DECLARE FUNCTION GetModuleFileNameW LIB "kernel32.dll" ALIAS "GetModuleFileNameW" ( BYVAL hModule AS QUAD
 , BYREF lpFilename AS WSTRINGZ
 , BYVAL nSize AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO GetModuleFileName = GetModuleFileNameW
#ELSE
 MACRO GetModuleFileName = GetModuleFileNameA
#ENDIF
DECLARE FUNCTION GetModuleHandleA LIB "kernel32.dll" ALIAS "GetModuleHandleA" ( BYREF lpModuleName AS ASCIIZ ) AS QUAD ' HMODULE
DECLARE FUNCTION GetModuleHandleW LIB "kernel32.dll" ALIAS "GetModuleHandleW" ( BYREF lpModuleName AS WSTRINGZ ) AS QUAD ' HMODULE
#IF %DEF(%UNICODE)
 MACRO GetModuleHandle = GetModuleHandleW
#ELSE
 MACRO GetModuleHandle = GetModuleHandleA
#ENDIF
' // Wrapper function (not in the SDK)
FUNCTION GethInst() AS DWORD
 FUNCTION = GetModuleHandle(BYVAL %NULL)
END FUNCTION
'#if !defined(RC_INVOKED)
'#if _WIN32_WINNT > 0x0500 || defined(WINBASE_DECLARE_GET_MODULE_HANDLE_EX) || ISOLATION_AWARE_ENABLED
%EQUATE `GET_MODULE_HANDLE_EX_FLAG_PIN = &H00000001
%EQUATE `GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT = &H00000002
%EQUATE `GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS = &H00000004
'typedef
'(WINAPI*
'PGET_MODULE_HANDLE_EXA)(
' );
'typedef
'(WINAPI*
'PGET_MODULE_HANDLE_EXW)(
' );
DECLARE FUNCTION GetModuleHandleExA LIB "kernel32.dll" ALIAS "GetModuleHandleExA" ( BYVAL dwFlags AS QUAD , BYREF lpModuleName AS ASCIIZ , BYREF phModule AS QUAD ) AS LONG
DECLARE FUNCTION GetModuleHandleExW LIB "kernel32.dll" ALIAS "GetModuleHandleExW" ( BYVAL dwFlags AS QUAD
 , BYREF lpModuleName AS WSTRINGZ
 , BYREF phModule AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO GetModuleHandleEx = GetModuleHandleExW
#ELSE
 MACRO GetModuleHandleEx = GetModuleHandleExA
#ENDIF
'#if _WIN32_WINNT >= 0x0502
DECLARE FUNCTION NeedCurrentDirectoryForExePathA LIB "kernel32.dll" ALIAS "NeedCurrentDirectoryForExePathA" ( BYREF ExeName AS ASCIIZ ) AS LONG
DECLARE FUNCTION NeedCurrentDirectoryForExePathW LIB "kernel32.dll" ALIAS "NeedCurrentDirectoryForExePathW" ( BYREF ExeName AS WSTRINGZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO NeedCurrentDirectoryForExePath = NeedCurrentDirectoryForExePathW
#ELSE
 MACRO NeedCurrentDirectoryForExePath = NeedCurrentDirectoryForExePathA
#ENDIF
'#endif
'#if _WIN32_WINNT >= 0x0600
#IF %WINVER >= &H0600
%EQUATE `PROCESS_NAME_NATIVE = &H00000001
DECLARE FUNCTION QueryFullProcessImageNameA LIB "kernel32.dll" ALIAS "QueryFullProcessImageNameA" ( BYVAL hProcess AS QUAD , BYVAL dwFlags AS QUAD , BYREF lpExeName AS ASCIIZ , BYREF lpdwSize AS QUAD ) AS LONG
DECLARE FUNCTION QueryFullProcessImageNameW LIB "kernel32.dll" ALIAS "QueryFullProcessImageNameW" ( BYVAL hProcess AS QUAD
 , BYVAL dwFlags AS DWORD
 , BYREF lpExeName AS WSTRINGZ
 , BYREF lpdwSize AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO QueryFullProcessImageName = QueryFullProcessImageNameW
#ELSE
 MACRO QueryFullProcessImageName = QueryFullProcessImageNameA
#ENDIF
#ENDIF
'#if (_WIN32_WINNT >= 0x0600)
'//
'// Extended process and thread attribute support
'//
%EQUATE `PROC_THREAD_ATTRIBUTE_NUMBER = &H0000FFFF
%EQUATE `PROC_THREAD_ATTRIBUTE_THREAD = &H00010000 ' // Attribute may be used with thread creation
%EQUATE `PROC_THREAD_ATTRIBUTE_INPUT = &H00020000 ' // Attribute is input only
%EQUATE `PROC_THREAD_ATTRIBUTE_ADDITIVE = &H00040000 ' // Attribute may be "accumulated," e.g. bitmasks, counters, etc.
' enum PROC_THREAD_ATTRIBUTE_NUM
%EQUATE `ProcThreadAttributeParentProcess = 0
%EQUATE `ProcThreadAttributeExtendedFlags = 1
%EQUATE `ProcThreadAttributeHandleList = 2
%EQUATE `ProcThreadAttributeGroupAffinity = 3
%EQUATE `ProcThreadAttributePreferredNode = 4
%EQUATE `ProcThreadAttributeIdealProcessor = 5
%EQUATE `ProcThreadAttributeUmsThread = 6
%EQUATE `ProcThreadAttributeMitigationPolicy = 7
%EQUATE `ProcThreadAttributeMax = 8
'#define ProcThreadAttributeValue(Number, Thread, Input, Additive) \
' (((Number) & PROC_THREAD_ATTRIBUTE_NUMBER) | \
' ((Thread != FALSE) ? PROC_THREAD_ATTRIBUTE_THREAD : 0) | \
' ((Input != FALSE) ? PROC_THREAD_ATTRIBUTE_INPUT : 0) | \
' ((Additive != FALSE) ? PROC_THREAD_ATTRIBUTE_ADDITIVE : 0))
'#define PROC_THREAD_ATTRIBUTE_PARENT_PROCESS \
' ProcThreadAttributeValue (ProcThreadAttributeParentProcess, FALSE, TRUE, FALSE)
'#define PROC_THREAD_ATTRIBUTE_EXTENDED_FLAGS \
' ProcThreadAttributeValue (ProcThreadAttributeExtendedFlags, FALSE, TRUE, TRUE)
'#define PROC_THREAD_ATTRIBUTE_HANDLE_LIST \
' ProcThreadAttributeValue (ProcThreadAttributeHandleList, FALSE, TRUE, FALSE)
'#define PROC_THREAD_ATTRIBUTE_GROUP_AFFINITY \
' ProcThreadAttributeValue (ProcThreadAttributeGroupAffinity, TRUE, TRUE, FALSE)
'#define PROC_THREAD_ATTRIBUTE_PREFERRED_NODE \
' ProcThreadAttributeValue (ProcThreadAttributePreferredNode, FALSE, TRUE, FALSE)
'#define PROC_THREAD_ATTRIBUTE_IDEAL_PROCESSOR \
' ProcThreadAttributeValue (ProcThreadAttributeIdealProcessor, TRUE, TRUE, FALSE)
'#define PROC_THREAD_ATTRIBUTE_UMS_THREAD \
' ProcThreadAttributeValue (ProcThreadAttributeUmsThread, TRUE, TRUE, FALSE)
'#define PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY \
' ProcThreadAttributeValue (ProcThreadAttributeMitigationPolicy, FALSE, TRUE, FALSE)
%EQUATE `PROCESS_CREATION_MITIGATION_POLICY_DEP_ENABLE = &H01
%EQUATE `PROCESS_CREATION_MITIGATION_POLICY_DEP_ATL_THUNK_ENABLE = &H02
%EQUATE `PROCESS_CREATION_MITIGATION_POLICY_SEHOP_ENABLE = &H04
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION InitializeProcThreadAttributeList LIB "Kernel32.dll" ALIAS "InitializeProcThreadAttributeList" (BYVAL lpAttributeList AS QUAD, BYVAL dwAttributeCount AS QUAD, BYVAL dwFlags AS QUAD, lpSize AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION InitializeProcThreadAttributeList LIB "kernel32.dll" ALIAS "InitializeProcThreadAttributeList" ( BYREF lpAttributeList AS QUAD , BYVAL dwAttributeCount AS QUAD , BYVAL dwFlags AS QUAD , BYREF lpSize AS QUAD ) AS LONG
#ENDIF
DECLARE SUB DeleteProcThreadAttributeList LIB "kernel32.dll" ALIAS "DeleteProcThreadAttributeList" ( BYREF lpAttributeList AS QUAD ) ' void
%EQUATE `PROC_THREAD_ATTRIBUTE_REPLACE_VALUE = &H00000001
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION UpdateProcThreadAttribute LIB "Kernel32.dll" ALIAS "UpdateProcThreadAttribute" (BYVAL lpAttributeList AS QUAD, BYVAL dwFlags AS QUAD, BYVAL dAttribute AS QUAD, BYVAL lpValue AS QUAD, BYVAL cbSize AS QUAD, BYVAL lpPreviousValue AS QUAD, BYVAL lpReturnSize AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION UpdateProcThreadAttribute LIB "kernel32.dll" ALIAS "UpdateProcThreadAttribute" ( BYREF lpAttributeList AS QUAD , BYVAL dwFlags AS QUAD , BYVAL Attribute AS QUAD , BYVAL lpValue AS QUAD , BYVAL cbSize AS QUAD , OPTIONAL BYREF lpPreviousValue AS QUAD , BYVAL lpReturnSize AS QUAD ) AS LONG
#ENDIF
'#endif // (_WIN32_WINNT >= 0x0600)
DECLARE FUNCTION CreateProcessA LIB "kernel32.dll" ALIAS "CreateProcessA" ( BYREF lpApplicationName AS ASCIIZ , BYREF lpCommandLine AS ASCIIZ , BYREF lpProcessAttributes AS SECURITY_ATTRIBUTES , BYREF lpThreadAttributes AS SECURITY_ATTRIBUTES , BYVAL bInheritHandles AS LONG , BYVAL dwCreationFlags AS QUAD , BYVAL lpEnvironment AS QUAD , BYREF lpCurrentDirectory AS ASCIIZ , BYREF lpStartupInfo AS STARTUPINFOA , BYREF lpProcessInformation AS PROCESS_INFORMATION ) AS LONG
DECLARE FUNCTION CreateProcessW LIB "kernel32.dll" ALIAS "CreateProcessW" ( BYREF lpApplicationName AS WSTRINGZ
 , BYREF lpCommandLine AS WSTRINGZ
 , BYREF lpProcessAttributes AS SECURITY_ATTRIBUTES
 , BYREF lpThreadAttributes AS SECURITY_ATTRIBUTES
 , BYVAL bInheritHandles AS LONG
 , BYVAL dwCreationFlags AS DWORD
 , BYVAL lpEnvironment AS DWORD
 , BYREF lpCurrentDirectory AS WSTRINGZ
 , BYREF lpStartupInfo AS STARTUPINFOW
 , BYREF lpProcessInformation AS PROCESS_INFORMATION
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO CreateProcess = CreateProcessW
#ELSE
 MACRO CreateProcess = CreateProcessA
#ENDIF
DECLARE FUNCTION SetProcessShutdownParameters LIB "kernel32.dll" ALIAS "SetProcessShutdownParameters" ( BYVAL dwLevel AS QUAD , BYVAL dwFlags AS QUAD ) AS LONG
DECLARE FUNCTION GetProcessShutdownParameters LIB "kernel32.dll" ALIAS "GetProcessShutdownParameters" ( BYREF lpdwLevel AS QUAD
 , BYREF lpdwFlags AS DWORD
 ) AS LONG
DECLARE FUNCTION GetProcessVersion LIB "kernel32.dll" ALIAS "GetProcessVersion" ( BYVAL ProcessId AS DWORD
 ) AS DWORD
DECLARE SUB FatalAppExitA LIB "kernel32.dll" ALIAS "FatalAppExitA" ( BYVAL uAction AS DWORD
 , BYREF lpMessageText AS ASCIIZ
 ) ' void
DECLARE SUB FatalAppExitW LIB "kernel32.dll" ALIAS "FatalAppExitW" ( BYVAL uAction AS QUAD , BYREF lpMessageText AS WSTRINGZ ) ' void
#IF %DEF(%UNICODE)
 MACRO FatalAppExit = FatalAppExitW
#ELSE
 MACRO FatalAppExit = FatalAppExitA
#ENDIF
DECLARE SUB GetStartupInfoA LIB "kernel32.dll" ALIAS "GetStartupInfoA" ( BYREF lpStartupInfo AS STARTUPINFOA ) ' void
DECLARE SUB GetStartupInfoW LIB "kernel32.dll" ALIAS "GetStartupInfoW" ( BYREF lpStartupInfo AS STARTUPINFOW ) ' void
#IF %DEF(%UNICODE)
 MACRO GetStartupInfo = GetStartupInfoW
#ELSE
 MACRO GetStartupInfo = GetStartupInfoA
#ENDIF
DECLARE FUNCTION GetCommandLineA LIB "kernel32.dll" ALIAS "GetCommandLineA" ( ) AS QUAD
DECLARE FUNCTION GetCommandLineW LIB "kernel32.dll" ALIAS "GetCommandLineW" ( ) AS QUAD
#IF %DEF(%UNICODE)
 MACRO GetCommandLine = GetCommandLineW
#ELSE
 MACRO GetCommandLine = GetCommandLineA
#ENDIF
DECLARE FUNCTION GetEnvironmentVariableA LIB "kernel32.dll" ALIAS "GetEnvironmentVariableA" ( BYREF lpName AS ASCIIZ , BYREF lpBuffer AS ASCIIZ , BYVAL nSize AS QUAD ) AS QUAD
DECLARE FUNCTION GetEnvironmentVariableW LIB "kernel32.dll" ALIAS "GetEnvironmentVariableW" ( BYREF lpName AS WSTRINGZ
 , BYREF lpBuffer AS WSTRINGZ
 , BYVAL nSize AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO GetEnvironmentVariable = GetEnvironmentVariableW
#ELSE
 MACRO GetEnvironmentVariable = GetEnvironmentVariableA
#ENDIF
'#if defined(_M_CEE)
'#undef GetEnvironmentVariable
'GetEnvironmentVariable(
' )
'{
'#ifdef UNICODE
' return GetEnvironmentVariableW(
'#else
' return GetEnvironmentVariableA(
'#endif
' lpName,
' lpBuffer,
'	nSize
' );
'}
'#endif /* _M_CEE */
DECLARE FUNCTION SetEnvironmentVariableA LIB "kernel32.dll" ALIAS "SetEnvironmentVariableA" ( BYREF lpName AS ASCIIZ , BYREF lpValue AS ASCIIZ ) AS LONG
DECLARE FUNCTION SetEnvironmentVariableW LIB "kernel32.dll" ALIAS "SetEnvironmentVariableW" ( BYREF lpName AS WSTRINGZ
 , BYREF lpValue AS WSTRINGZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SetEnvironmentVariable = SetEnvironmentVariableW
#ELSE
 MACRO SetEnvironmentVariable = SetEnvironmentVariableA
#ENDIF
DECLARE FUNCTION ExpandEnvironmentStringsA LIB "kernel32.dll" ALIAS "ExpandEnvironmentStringsA" ( BYREF lpSrc AS ASCIIZ , BYREF lpDst AS ASCIIZ , BYVAL nSize AS QUAD ) AS QUAD
DECLARE FUNCTION ExpandEnvironmentStringsW LIB "kernel32.dll" ALIAS "ExpandEnvironmentStringsW" ( BYREF lpSrc AS WSTRINGZ
 , BYREF lpDst AS WSTRINGZ
 , BYVAL nSize AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO ExpandEnvironmentStrings = ExpandEnvironmentStringsW
#ELSE
 MACRO ExpandEnvironmentStrings = ExpandEnvironmentStringsA
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION GetFirmwareEnvironmentVariableA LIB "Kernel32.dll" ALIAS "GetFirmwareEnvironmentVariableA" (lpName AS ASCIIZ, lpGuid AS ASCIIZ, BYVAL pBuffer AS QUAD, BYVAL nSize AS QUAD) AS QUAD
#ELSE
DECLARE FUNCTION GetFirmwareEnvironmentVariableA LIB "kernel32.dll" ALIAS "GetFirmwareEnvironmentVariableA" ( BYREF lpName AS ASCIIZ , BYREF lpGuid AS ASCIIZ , BYREF pBuffer AS ANY , BYVAL nSize AS QUAD ) AS QUAD
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION GetFirmwareEnvironmentVariableW LIB "Kernel32.dll" ALIAS "GetFirmwareEnvironmentVariableW" (lpName AS WSTRINGZ, lpGuid AS WSTRINGZ, BYVAL pBuffer AS QUAD, BYVAL nSize AS QUAD) AS QUAD
#ELSE
DECLARE FUNCTION GetFirmwareEnvironmentVariableW LIB "kernel32.dll" ALIAS "GetFirmwareEnvironmentVariableW" ( BYREF lpName AS WSTRINGZ , BYREF lpGuid AS WSTRINGZ , BYREF pBuffer AS ANY , BYVAL nSize AS QUAD ) AS QUAD
#ENDIF
#IF %DEF(%UNICODE)
 MACRO GetFirmwareEnvironmentVariable = GetFirmwareEnvironmentVariableW
#ELSE
 MACRO GetFirmwareEnvironmentVariable = GetFirmwareEnvironmentVariableA
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION SetFirmwareEnvironmentVariableA LIB "Kernel32.dll" ALIAS "SetFirmwareEnvironmentVariableA" (lpName AS ASCIIZ, lpGuid AS ASCIIZ, BYVAL pBuffer AS QUAD, BYVAL nSize AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION SetFirmwareEnvironmentVariableA LIB "kernel32.dll" ALIAS "SetFirmwareEnvironmentVariableA" ( BYREF lpName AS ASCIIZ , BYREF lpGuid AS ASCIIZ , BYREF pValue AS ANY , BYVAL nSize AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION SetFirmwareEnvironmentVariableW LIB "Kernel32.dll" ALIAS "SetFirmwareEnvironmentVariableW" (lpName AS WSTRINGZ, lpGuid AS WSTRINGZ, BYVAL pBuffer AS QUAD, BYVAL nSize AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION SetFirmwareEnvironmentVariableW LIB "kernel32.dll" ALIAS "SetFirmwareEnvironmentVariableW" ( BYREF lpName AS WSTRINGZ , BYREF lpGuid AS WSTRINGZ , BYREF pValue AS ANY , BYVAL nSize AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%UNICODE)
 MACRO SetFirmwareEnvironmentVariable = SetFirmwareEnvironmentVariableW
#ELSE
 MACRO SetFirmwareEnvironmentVariable = SetFirmwareEnvironmentVariableA
#ENDIF
DECLARE SUB OutputDebugStringA LIB "kernel32.dll" ALIAS "OutputDebugStringA" ( BYREF lpOutputString AS ASCIIZ ) ' void
DECLARE SUB OutputDebugStringW LIB "kernel32.dll" ALIAS "OutputDebugStringW" ( BYREF lpOutputString AS WSTRINGZ ) ' void
#IF %DEF(%UNICODE)
 MACRO OutputDebugString = OutputDebugStringW
#ELSE
 MACRO OutputDebugString = OutputDebugStringA
#ENDIF
DECLARE FUNCTION FindResourceA LIB "kernel32.dll" ALIAS "FindResourceA" ( BYVAL hModule AS QUAD , BYREF lpName AS ASCIIZ , BYREF lpType AS ASCIIZ ) AS QUAD ' HRSRC
DECLARE FUNCTION FindResourceW LIB "kernel32.dll" ALIAS "FindResourceW" ( BYVAL hModule AS QUAD , BYREF lpName AS WSTRINGZ , BYREF lpType AS WSTRINGZ ) AS QUAD ' HRSRC
#IF %DEF(%UNICODE)
 MACRO FindResource = FindResourceW
#ELSE
 MACRO FindResource = FindResourceA
#ENDIF
DECLARE FUNCTION FindResourceExA LIB "kernel32.dll" ALIAS "FindResourceExA" ( BYVAL hModule AS QUAD , BYREF lpType AS ASCIIZ , BYREF lpName AS ASCIIZ , BYVAL wLanguage AS WORD ) AS QUAD ' HRSRC
DECLARE FUNCTION FindResourceExW LIB "kernel32.dll" ALIAS "FindResourceExW" ( BYVAL hModule AS QUAD , BYREF lpType AS WSTRINGZ , BYREF lpName AS WSTRINGZ , BYVAL wLanguage AS WORD ) AS QUAD ' HRSRC
#IF %DEF(%UNICODE)
 MACRO FindResourceEx = FindResourceExW
#ELSE
 MACRO FindResourceEx = FindResourceExA
#ENDIF
'typedef BOOL (CALLBACK* ENUMRESNAMEPROCA)(__in HMODULE hModule, __in LPCSTR lpType,
'typedef BOOL (CALLBACK* ENUMRESNAMEPROCW)(__in HMODULE hModule, __in LPCWSTR lpType,
'typedef BOOL (CALLBACK* ENUMRESLANGPROCA)(__in HMODULE hModule, __in LPCSTR lpType,
'typedef BOOL (CALLBACK* ENUMRESLANGPROCW)(__in HMODULE hModule, __in LPCWSTR lpType,
DECLARE FUNCTION EnumResourceTypesA LIB "kernel32.dll" ALIAS "EnumResourceTypesA" ( BYVAL hModule AS QUAD , BYVAL lpEnumFunc AS QUAD , BYVAL lParam AS LONG ) AS LONG
DECLARE FUNCTION EnumResourceTypesW LIB "kernel32.dll" ALIAS "EnumResourceTypesW" ( BYVAL hModule AS QUAD
 , BYVAL lpEnumFunc AS DWORD
 , BYVAL lParam AS LONG
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO EnumResourceTypes = EnumResourceTypesW
#ELSE
 MACRO EnumResourceTypes = EnumResourceTypesA
#ENDIF
DECLARE FUNCTION EnumResourceNamesA LIB "kernel32.dll" ALIAS "EnumResourceNamesA" ( BYVAL hModule AS QUAD , BYREF lpType AS ASCIIZ , BYVAL lpEnumFunc AS QUAD , BYVAL lParam AS LONG ) AS LONG
DECLARE FUNCTION EnumResourceNamesW LIB "kernel32.dll" ALIAS "EnumResourceNamesW" ( BYVAL hModule AS QUAD
 , BYREF lpType AS WSTRINGZ
 , BYVAL lpEnumFunc AS DWORD
 , BYVAL lParam AS LONG
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO EnumResourceNames = EnumResourceNamesW
#ELSE
 MACRO EnumResourceNames = EnumResourceNamesA
#ENDIF
DECLARE FUNCTION EnumResourceLanguagesA LIB "kernel32.dll" ALIAS "EnumResourceLanguagesA" ( BYVAL hModule AS QUAD , BYREF lpType AS ASCIIZ , BYREF lpName AS ASCIIZ , BYVAL lpEnumFunc AS QUAD , BYVAL lParam AS LONG ) AS LONG
DECLARE FUNCTION EnumResourceLanguagesW LIB "kernel32.dll" ALIAS "EnumResourceLanguagesW" ( BYVAL hModule AS QUAD
 , BYREF lpType AS WSTRINGZ
 , BYREF lpName AS WSTRINGZ
 , BYVAL lpEnumFunc AS DWORD
 , BYVAL lParam AS LONG
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO EnumResourceLanguages = EnumResourceLanguagesW
#ELSE
 MACRO EnumResourceLanguages = EnumResourceLanguagesA
#ENDIF
%EQUATE `RESOURCE_ENUM_LN = &H0001
%EQUATE `RESOURCE_ENUM_MUI = &H0002
%EQUATE `RESOURCE_ENUM_MUI_SYSTEM = &H0004
%EQUATE `RESOURCE_ENUM_VALIDATE = &H0008
'%RESOURCE_UPDATE_LN = &H0010 ' // Renamed in Windows 7 SDL
%EQUATE `RESOURCE_ENUM_MODULE_EXACT = &H0010
'%RESOURCE_UPDATE_MUI = &H0020 ' // Removed in Windows 7 SDK
DECLARE FUNCTION EnumResourceTypesExA LIB "kernel32.dll" ALIAS "EnumResourceTypesExA" ( BYVAL hModule AS QUAD , BYVAL lpEnumFunc AS QUAD , BYVAL lParam AS LONG , BYVAL dwFlags AS QUAD , BYVAL LangId AS WORD ) AS LONG
DECLARE FUNCTION EnumResourceTypesExW LIB "kernel32.dll" ALIAS "EnumResourceTypesExW" ( BYVAL hModule AS QUAD
 , BYVAL lpEnumFunc AS DWORD
 , BYVAL lParam AS LONG
 , BYVAL dwFlags AS DWORD
 , BYVAL LangId AS WORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO EnumResourceTypesEx = EnumResourceTypesExW
#ELSE
 MACRO EnumResourceTypesEx = EnumResourceTypesExA
#ENDIF
DECLARE FUNCTION EnumResourceNamesExA LIB "kernel32.dll" ALIAS "EnumResourceNamesExA" ( BYVAL hModule AS QUAD , BYREF lpType AS ASCIIZ , BYVAL lpEnumFunc AS QUAD , BYVAL lParam AS LONG , BYVAL dwFlags AS QUAD , BYVAL LangId AS WORD ) AS LONG
DECLARE FUNCTION EnumResourceNamesExW LIB "kernel32.dll" ALIAS "EnumResourceNamesExW" ( BYVAL hModule AS QUAD
 , BYREF lpType AS WSTRINGZ
 , BYVAL lpEnumFunc AS DWORD
 , BYVAL lParam AS LONG
 , BYVAL dwFlags AS DWORD
 , BYVAL LangId AS WORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO EnumResourceNamesEx = EnumResourceNamesExW
#ELSE
 MACRO EnumResourceNamesEx = EnumResourceNamesExA
#ENDIF
DECLARE FUNCTION EnumResourceLanguagesExA LIB "kernel32.dll" ALIAS "EnumResourceLanguagesExA" ( BYVAL hModule AS QUAD , BYREF lpType AS ASCIIZ , BYREF lpName AS ASCIIZ , BYVAL lpEnumFunc AS QUAD , BYVAL lParam AS LONG , BYVAL dwFlags AS QUAD , BYVAL LangId AS WORD ) AS LONG
DECLARE FUNCTION EnumResourceLanguagesExW LIB "kernel32.dll" ALIAS "EnumResourceLanguagesExW" ( BYVAL hModule AS QUAD
 , BYREF lpType AS WSTRINGZ
 , BYREF lpName AS WSTRINGZ
 , BYVAL lpEnumFunc AS DWORD
 , BYVAL lParam AS LONG
 , BYVAL dwFlags AS DWORD
 , BYVAL LangId AS WORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO EnumResourceLanguagesEx = EnumResourceLanguagesExW
#ELSE
 MACRO EnumResourceLanguagesEx = EnumResourceLanguagesExA
#ENDIF
DECLARE FUNCTION BeginUpdateResourceA LIB "kernel32.dll" ALIAS "BeginUpdateResourceA" ( BYREF pFileName AS ASCIIZ , BYVAL bDeleteExistingResources AS LONG ) AS QUAD
DECLARE FUNCTION BeginUpdateResourceW LIB "kernel32.dll" ALIAS "BeginUpdateResourceW" ( BYREF pFileName AS WSTRINGZ
 , BYVAL bDeleteExistingResources AS LONG
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO BeginUpdateResource = BeginUpdateResourceW
#ELSE
 MACRO BeginUpdateResource = BeginUpdateResourceA
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION UpdateResourceA LIB "Kernel32.dll" ALIAS "UpdateResourceA" (BYVAL hUpdate AS QUAD, lpType AS ASCIIZ, lpName AS ASCIIZ, BYVAL wLanguage AS WORD, BYVAL lpData AS QUAD, BYVAL cbData AS QUAD) AS QUAD
#ELSE
DECLARE FUNCTION UpdateResourceA LIB "kernel32.dll" ALIAS "UpdateResourceA" ( BYVAL hUpdate AS QUAD , BYREF lpType AS ASCIIZ , BYREF lpName AS ASCIIZ , BYVAL wLanguage AS WORD , BYREF lpData AS ANY , BYVAL c AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION UpdateResourceW LIB "Kernel32.dll" ALIAS "UpdateResourceW" (BYVAL hUpdate AS QUAD, lpType AS WSTRINGZ, lpName AS WSTRINGZ, BYVAL wLanguage AS WORD, BYVAL lpData AS QUAD, BYVAL cbData AS QUAD) AS QUAD
#ELSE
DECLARE FUNCTION UpdateResourceW LIB "kernel32.dll" ALIAS "UpdateResourceW" ( BYVAL hUpdate AS QUAD , BYREF lpType AS WSTRINGZ , BYREF lpName AS WSTRINGZ , BYVAL wLanguage AS WORD , BYREF lpData AS ANY , BYVAL c AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%UNICODE)
 MACRO UpdateResource = UpdateResourceW
#ELSE
 MACRO UpdateResource = UpdateResourceA
#ENDIF
DECLARE FUNCTION EndUpdateResourceA LIB "kernel32.dll" ALIAS "EndUpdateResourceA" ( BYVAL hUpdate AS QUAD , BYVAL fDiscard AS LONG ) AS LONG
DECLARE FUNCTION EndUpdateResourceW LIB "kernel32.dll" ALIAS "EndUpdateResourceW" ( BYVAL hUpdate AS QUAD
 , BYVAL fDiscard AS LONG
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO EndUpdateResource = EndUpdateResourceW
#ELSE
 MACRO EndUpdateResource = EndUpdateResourceA
#ENDIF
DECLARE FUNCTION GlobalAddAtomA LIB "kernel32.dll" ALIAS "GlobalAddAtomA" ( BYREF lpString AS ASCIIZ ) AS WORD ' ATOM
DECLARE FUNCTION GlobalAddAtomW LIB "kernel32.dll" ALIAS "GlobalAddAtomW" ( BYREF lpString AS WSTRINGZ ) AS WORD ' ATOM
#IF %DEF(%UNICODE)
 MACRO GlobalAddAtom = GlobalAddAtomW
#ELSE
 MACRO GlobalAddAtom = GlobalAddAtomA
#ENDIF
DECLARE FUNCTION GlobalFindAtomA LIB "kernel32.dll" ALIAS "GlobalFindAtomA" ( BYREF lpString AS ASCIIZ ) AS WORD ' ATOM
DECLARE FUNCTION GlobalFindAtomW LIB "kernel32.dll" ALIAS "GlobalFindAtomW" ( BYREF lpString AS WSTRINGZ ) AS WORD ' ATOM
#IF %DEF(%UNICODE)
 MACRO GlobalFindAtom = GlobalFindAtomW
#ELSE
 MACRO GlobalFindAtom = GlobalFindAtomA
#ENDIF
DECLARE FUNCTION GlobalGetAtomNameA LIB "kernel32.dll" ALIAS "GlobalGetAtomNameA" ( BYVAL nAtom AS WORD , BYREF lpBuffer AS ASCIIZ , BYVAL nSize AS QUAD ) AS QUAD ' UINT
DECLARE FUNCTION GlobalGetAtomNameW LIB "kernel32.dll" ALIAS "GlobalGetAtomNameW" ( BYVAL nAtom AS WORD , BYREF lpBuffer AS WSTRINGZ , BYVAL nSize AS QUAD ) AS QUAD ' UINT
#IF %DEF(%UNICODE)
 MACRO GlobalGetAtomName = GlobalGetAtomNameW
#ELSE
 MACRO GlobalGetAtomName = GlobalGetAtomNameA
#ENDIF
DECLARE FUNCTION AddAtomA LIB "kernel32.dll" ALIAS "AddAtomA" ( BYREF lpString AS ASCIIZ ) AS WORD ' ATOM
DECLARE FUNCTION AddAtomW LIB "kernel32.dll" ALIAS "AddAtomW" ( BYREF lpString AS WSTRINGZ ) AS WORD ' ATOM
#IF %DEF(%UNICODE)
 MACRO AddAtom = AddAtomW
#ELSE
 MACRO AddAtom = AddAtomA
#ENDIF
DECLARE FUNCTION FindAtomA LIB "kernel32.dll" ALIAS "FindAtomA" ( BYREF lpString AS ASCIIZ ) AS WORD ' ATOM
DECLARE FUNCTION FindAtomW LIB "kernel32.dll" ALIAS "FindAtomW" ( BYREF lpString AS WSTRINGZ ) AS WORD ' ATOM
#IF %DEF(%UNICODE)
 MACRO FindAtom = FindAtomW
#ELSE
 MACRO FindAtom = FindAtomA
#ENDIF
DECLARE FUNCTION GetAtomNameA LIB "kernel32.dll" ALIAS "GetAtomNameA" ( BYVAL nAtom AS WORD , BYREF lpBuffer AS ASCIIZ , BYVAL nSize AS QUAD ) AS QUAD ' UINT
DECLARE FUNCTION GetAtomNameW LIB "kernel32.dll" ALIAS "GetAtomNameW" ( BYVAL nAtom AS WORD , BYREF lpBuffer AS WSTRINGZ , BYVAL nSize AS QUAD ) AS QUAD ' UINT
#IF %DEF(%UNICODE)
 MACRO GetAtomName = GetAtomNameW
#ELSE
 MACRO GetAtomName = GetAtomNameA
#ENDIF
DECLARE FUNCTION GetProfileIntA LIB "kernel32.dll" ALIAS "GetProfileIntA" ( BYREF lpAppName AS ASCIIZ , BYREF lpKeyName AS ASCIIZ , BYVAL nDefault AS LONG ) AS QUAD ' UINT
DECLARE FUNCTION GetProfileIntW LIB "kernel32.dll" ALIAS "GetProfileIntW" ( BYREF lpAppName AS WSTRINGZ , BYREF lpKeyName AS WSTRINGZ , BYVAL nDefault AS LONG ) AS QUAD ' UINT
#IF %DEF(%UNICODE)
 MACRO GetProfileInt = GetProfileIntW
#ELSE
 MACRO GetProfileInt = GetProfileIntA
#ENDIF
DECLARE FUNCTION GetProfileStringA LIB "kernel32.dll" ALIAS "GetProfileStringA" ( BYREF lpAppName AS ASCIIZ , BYREF lpKeyName AS ASCIIZ , BYREF lpDefault AS ASCIIZ , BYREF lpReturnedString AS ASCIIZ , BYVAL nSize AS QUAD ) AS QUAD
DECLARE FUNCTION GetProfileStringW LIB "kernel32.dll" ALIAS "GetProfileStringW" ( BYREF lpAppName AS WSTRINGZ
 , BYREF lpKeyName AS WSTRINGZ
 , BYREF lpDefault AS WSTRINGZ
 , BYREF lpReturnedString AS WSTRINGZ
 , BYVAL nSize AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO GetProfileString = GetProfileStringW
#ELSE
 MACRO GetProfileString = GetProfileStringA
#ENDIF
DECLARE FUNCTION WriteProfileStringA LIB "kernel32.dll" ALIAS "WriteProfileStringA" ( BYREF lpAppName AS ASCIIZ , BYREF lpKeyName AS ASCIIZ , BYREF lpString AS ASCIIZ ) AS LONG
DECLARE FUNCTION WriteProfileStringW LIB "kernel32.dll" ALIAS "WriteProfileStringW" ( BYREF lpAppName AS WSTRINGZ
 , BYREF lpKeyName AS WSTRINGZ
 , BYREF lpString AS WSTRINGZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO WriteProfileString = WriteProfileStringW
#ELSE
 MACRO WriteProfileString = WriteProfileStringA
#ENDIF
DECLARE FUNCTION GetProfileSectionA LIB "kernel32.dll" ALIAS "GetProfileSectionA" ( BYREF lpAppName AS ASCIIZ , BYREF lpReturnedString AS ASCIIZ , BYVAL nSize AS QUAD ) AS QUAD
DECLARE FUNCTION GetProfileSectionW LIB "kernel32.dll" ALIAS "GetProfileSectionW" ( BYREF lpAppName AS WSTRINGZ
 , BYREF lpReturnedString AS WSTRINGZ
 , BYVAL nSize AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO GetProfileSection = GetProfileSectionW
#ELSE
 MACRO GetProfileSection = GetProfileSectionA
#ENDIF
DECLARE FUNCTION WriteProfileSectionA LIB "kernel32.dll" ALIAS "WriteProfileSectionA" ( BYREF lpAppName AS ASCIIZ , BYREF lpString AS ASCIIZ ) AS LONG
DECLARE FUNCTION WriteProfileSectionW LIB "kernel32.dll" ALIAS "WriteProfileSectionW" ( BYREF lpAppName AS WSTRINGZ
 , BYREF lpString AS WSTRINGZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO WriteProfileSection = WriteProfileSectionW
#ELSE
 MACRO WriteProfileSection = WriteProfileSectionA
#ENDIF
DECLARE FUNCTION GetPrivateProfileIntA LIB "kernel32.dll" ALIAS "GetPrivateProfileIntA" ( BYREF lpAppName AS ASCIIZ , BYREF lpKeyName AS ASCIIZ , BYVAL nDefault AS LONG , BYREF lpFileName AS ASCIIZ ) AS QUAD ' UINT
DECLARE FUNCTION GetPrivateProfileIntW LIB "kernel32.dll" ALIAS "GetPrivateProfileIntW" ( BYREF lpAppName AS WSTRINGZ , BYREF lpKeyName AS WSTRINGZ , BYVAL nDefault AS LONG , BYREF lpFileName AS WSTRINGZ ) AS QUAD ' UINT
#IF %DEF(%UNICODE)
 MACRO GetPrivateProfileInt = GetPrivateProfileIntW
#ELSE
 MACRO GetPrivateProfileInt = GetPrivateProfileIntA
#ENDIF
DECLARE FUNCTION GetPrivateProfileStringA LIB "kernel32.dll" ALIAS "GetPrivateProfileStringA" ( BYREF lpAppName AS ASCIIZ , BYREF lpKeyName AS ASCIIZ , BYREF lpDefault AS ASCIIZ , BYREF lpReturnedString AS ASCIIZ , BYVAL nSize AS QUAD , BYREF lpFileName AS ASCIIZ ) AS QUAD
DECLARE FUNCTION GetPrivateProfileStringW LIB "kernel32.dll" ALIAS "GetPrivateProfileStringW" ( BYREF lpAppName AS WSTRINGZ
 , BYREF lpKeyName AS WSTRINGZ
 , BYREF lpDefault AS WSTRINGZ
 , BYREF lpReturnedString AS WSTRINGZ
 , BYVAL nSize AS DWORD
 , BYREF lpFileName AS WSTRINGZ
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO GetPrivateProfileString = GetPrivateProfileStringW
#ELSE
 MACRO GetPrivateProfileString = GetPrivateProfileStringA
#ENDIF
DECLARE FUNCTION WritePrivateProfileStringA LIB "kernel32.dll" ALIAS "WritePrivateProfileStringA" ( BYREF lpAppName AS ASCIIZ , BYREF lpKeyName AS ASCIIZ , BYREF lpString AS ASCIIZ , BYREF lpFileName AS ASCIIZ ) AS LONG
DECLARE FUNCTION WritePrivateProfileStringW LIB "kernel32.dll" ALIAS "WritePrivateProfileStringW" ( BYREF lpAppName AS WSTRINGZ
 , BYREF lpKeyName AS WSTRINGZ
 , BYREF lpString AS WSTRINGZ
 , BYREF lpFileName AS WSTRINGZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO WritePrivateProfileString = WritePrivateProfileStringW
#ELSE
 MACRO WritePrivateProfileString = WritePrivateProfileStringA
#ENDIF
DECLARE FUNCTION GetPrivateProfileSectionA LIB "kernel32.dll" ALIAS "GetPrivateProfileSectionA" ( BYREF lpAppName AS ASCIIZ , BYREF lpReturnedString AS ASCIIZ , BYVAL nSize AS QUAD , BYREF lpFileName AS ASCIIZ ) AS QUAD
DECLARE FUNCTION GetPrivateProfileSectionW LIB "kernel32.dll" ALIAS "GetPrivateProfileSectionW" ( BYREF lpAppName AS WSTRINGZ
 , BYREF lpReturnedString AS WSTRINGZ
 , BYVAL nSize AS DWORD
 , BYREF lpFileName AS WSTRINGZ
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO GetPrivateProfileSection = GetPrivateProfileSectionW
#ELSE
 MACRO GetPrivateProfileSection = GetPrivateProfileSectionA
#ENDIF
DECLARE FUNCTION WritePrivateProfileSectionA LIB "kernel32.dll" ALIAS "WritePrivateProfileSectionA" ( BYREF lpAppName AS ASCIIZ , BYREF lpString AS ASCIIZ , BYREF lpFileName AS ASCIIZ ) AS LONG
DECLARE FUNCTION WritePrivateProfileSectionW LIB "kernel32.dll" ALIAS "WritePrivateProfileSectionW" ( BYREF lpAppName AS WSTRINGZ
 , BYREF lpString AS WSTRINGZ
 , BYREF lpFileName AS WSTRINGZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO WritePrivateProfileSection = WritePrivateProfileSectionW
#ELSE
 MACRO WritePrivateProfileSection = WritePrivateProfileSectionA
#ENDIF
DECLARE FUNCTION GetPrivateProfileSectionNamesA LIB "kernel32.dll" ALIAS "GetPrivateProfileSectionNamesA" ( BYREF lpszReturnBuffer AS ASCIIZ , BYVAL nSize AS QUAD , BYREF lpFileName AS ASCIIZ ) AS QUAD
DECLARE FUNCTION GetPrivateProfileSectionNamesW LIB "kernel32.dll" ALIAS "GetPrivateProfileSectionNamesW" ( BYREF lpszReturnBuffer AS WSTRINGZ
 , BYVAL nSize AS DWORD
 , BYREF lpFileName AS WSTRINGZ
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO GetPrivateProfileSectionNames = GetPrivateProfileSectionNamesW
#ELSE
 MACRO GetPrivateProfileSectionNames = GetPrivateProfileSectionNamesA
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION GetPrivateProfileStructA LIB "Kernel32.dll" ALIAS "GetPrivateProfileStructA" (lpApplicationName AS ASCIIZ, lpKeyName AS ASCIIZ, BYVAL lpStruct AS QUAD, BYVAL nSize AS QUAD, lpFileName AS ASCIIZ) AS QUAD
#ELSE
DECLARE FUNCTION GetPrivateProfileStructA LIB "kernel32.dll" ALIAS "GetPrivateProfileStructA" ( BYREF lpszSection AS ASCIIZ , BYREF lpszKey AS ASCIIZ , BYREF lpStruct AS ANY , BYVAL uSizeStruct AS QUAD , BYREF szFile AS ASCIIZ ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION GetPrivateProfileStructW LIB "Kernel32.dll" ALIAS "GetPrivateProfileStructW" (lpApplicationName AS WSTRINGZ, lpKeyName AS WSTRINGZ, BYVAL lpStruct AS QUAD, BYVAL nSize AS QUAD, lpFileName AS WSTRINGZ) AS QUAD
#ELSE
DECLARE FUNCTION GetPrivateProfileStructW LIB "kernel32.dll" ALIAS "GetPrivateProfileStructW" ( BYREF lpszSection AS WSTRINGZ , BYREF lpszKey AS WSTRINGZ , BYREF lpStruct AS ANY , BYVAL uSizeStruct AS QUAD , BYREF szFile AS WSTRINGZ ) AS LONG
#ENDIF
#IF %DEF(%UNICODE)
 MACRO GetPrivateProfileStruct = GetPrivateProfileStructW
#ELSE
 MACRO GetPrivateProfileStruct = GetPrivateProfileStructA
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION WritePrivateProfileStructA LIB "Kernel32.dll" ALIAS "WritePrivateProfileStructA" (lpApplicationName AS ASCIIZ, lpKeyName AS ASCIIZ, BYVAL lpStruct AS QUAD, BYVAL uSizeStruct AS QUAD, lpFileName AS ASCIIZ) AS LONG
#ELSE
DECLARE FUNCTION WritePrivateProfileStructA LIB "kernel32.dll" ALIAS "WritePrivateProfileStructA" ( BYREF lpszSection AS ASCIIZ , BYREF lpszKey AS ASCIIZ , BYREF lpStruct AS ANY , BYVAL uSizeStruct AS QUAD , BYREF szFile AS ASCIIZ ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION WritePrivateProfileStructW LIB "Kernel32.dll" ALIAS "WritePrivateProfileStructW" (lpApplicationName AS WSTRINGZ, lpKeyName AS WSTRINGZ, BYVAL lpStruct AS QUAD, BYVAL uSizeStruct AS QUAD, lpFileName AS WSTRINGZ) AS LONG
#ELSE
DECLARE FUNCTION WritePrivateProfileStructW LIB "kernel32.dll" ALIAS "WritePrivateProfileStructW" ( BYREF lpszSection AS WSTRINGZ , BYREF lpszKey AS WSTRINGZ , BYREF lpStruct AS ANY , BYVAL uSizeStruct AS QUAD , BYREF szFile AS WSTRINGZ ) AS LONG
#ENDIF
#IF %DEF(%UNICODE)
 MACRO WritePrivateProfileStruct = WritePrivateProfileStructW
#ELSE
 MACRO WritePrivateProfileStruct = WritePrivateProfileStructA
#ENDIF
DECLARE FUNCTION GetDriveTypeA LIB "kernel32.dll" ALIAS "GetDriveTypeA" ( BYREF lpRootPathName AS ASCIIZ ) AS QUAD ' UINT
DECLARE FUNCTION GetDriveTypeW LIB "kernel32.dll" ALIAS "GetDriveTypeW" ( BYREF lpRootPathName AS WSTRINGZ ) AS QUAD ' UINT
#IF %DEF(%UNICODE)
 MACRO GetDriveType = GetDriveTypeW
#ELSE
 MACRO GetDriveType = GetDriveTypeA
#ENDIF
DECLARE FUNCTION GetSystemDirectoryA LIB "kernel32.dll" ALIAS "GetSystemDirectoryA" ( BYREF lpBuffer AS ASCIIZ , BYVAL uSize AS QUAD ) AS QUAD ' UINT
DECLARE FUNCTION GetSystemDirectoryW LIB "kernel32.dll" ALIAS "GetSystemDirectoryW" ( BYREF lpBuffer AS WSTRINGZ , BYVAL uSize AS QUAD ) AS QUAD ' UINT
#IF %DEF(%UNICODE)
 MACRO GetSystemDirectory = GetSystemDirectoryW
#ELSE
 MACRO GetSystemDirectory = GetSystemDirectoryA
#ENDIF
DECLARE FUNCTION GetTempPathA LIB "kernel32.dll" ALIAS "GetTempPathA" ( BYVAL nBufferLength AS LONG , BYREF lpBuffer AS ASCIIZ ) AS QUAD
DECLARE FUNCTION GetTempPathW LIB "kernel32.dll" ALIAS "GetTempPathW" ( BYVAL nBufferLength AS LONG
 , BYREF lpBuffer AS WSTRINGZ
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO GetTempPath = GetTempPathW
#ELSE
 MACRO GetTempPath = GetTempPathA
#ENDIF
DECLARE FUNCTION GetTempFileNameA LIB "kernel32.dll" ALIAS "GetTempFileNameA" ( BYREF lpPathName AS ASCIIZ , BYREF lpPrefixString AS ASCIIZ , BYVAL uUnique AS QUAD , BYREF lpTempFileName AS ASCIIZ ) AS QUAD ' UINT
DECLARE FUNCTION GetTempFileNameW LIB "kernel32.dll" ALIAS "GetTempFileNameW" ( BYREF lpPathName AS WSTRINGZ , BYREF lpPrefixString AS WSTRINGZ , BYVAL uUnique AS QUAD , BYREF lpTempFileName AS WSTRINGZ ) AS QUAD ' UINT
#IF %DEF(%UNICODE)
 MACRO GetTempFileName = GetTempFileNameW
#ELSE
 MACRO GetTempFileName = GetTempFileNameA
#ENDIF
DECLARE FUNCTION GetWindowsDirectoryA LIB "kernel32.dll" ALIAS "GetWindowsDirectoryA" ( BYREF lpBuffer AS ASCIIZ , BYVAL uSize AS QUAD ) AS QUAD ' UINT
DECLARE FUNCTION GetWindowsDirectoryW LIB "kernel32.dll" ALIAS "GetWindowsDirectoryW" ( BYREF lpBuffer AS WSTRINGZ , BYVAL uSize AS QUAD ) AS QUAD ' UINT
#IF %DEF(%UNICODE)
 MACRO GetWindowsDirectory = GetWindowsDirectoryW
#ELSE
 MACRO GetWindowsDirectory = GetWindowsDirectoryA
#ENDIF
DECLARE FUNCTION GetSystemWindowsDirectoryA LIB "kernel32.dll" ALIAS "GetSystemWindowsDirectoryA" ( BYREF lpBuffer AS ASCIIZ , BYVAL uSize AS QUAD ) AS QUAD ' UINT
DECLARE FUNCTION GetSystemWindowsDirectoryW LIB "kernel32.dll" ALIAS "GetSystemWindowsDirectoryW" ( BYREF lpBuffer AS WSTRINGZ , BYVAL uSize AS QUAD ) AS QUAD ' UINT
#IF %DEF(%UNICODE)
 MACRO GetSystemWindowsDirectory = GetSystemWindowsDirectoryW
#ELSE
 MACRO GetSystemWindowsDirectory = GetSystemWindowsDirectoryA
#ENDIF
'#if _WIN32_WINNT >= 0x0501 || defined(WINBASE_DECLARE_GET_SYSTEM_WOW64_DIRECTORY)
DECLARE FUNCTION GetSystemWow64DirectoryA LIB "kernel32.dll" ALIAS "GetSystemWow64DirectoryA" ( BYREF lpBuffer AS ASCIIZ , BYVAL uSize AS QUAD ) AS QUAD ' UINT
DECLARE FUNCTION GetSystemWow64DirectoryW LIB "kernel32.dll" ALIAS "GetSystemWow64DirectoryW" ( BYREF lpBuffer AS WSTRINGZ , BYVAL uSize AS QUAD ) AS QUAD ' UINT
#IF %DEF(%UNICODE)
 MACRO GetSystemWow64Directory = GetSystemWow64DirectoryW
#ELSE
 MACRO GetSystemWow64Directory = GetSystemWow64DirectoryA
#ENDIF
DECLARE FUNCTION Wow64EnableWow64FsRedirection LIB "kernel32.dll" ALIAS "Wow64EnableWow64FsRedirection" ( BYVAL Wow64FsEnableRedirection AS BYTE ) AS BYTE ' BOOLEAN
DECLARE FUNCTION Wow64DisableWow64FsRedirection LIB "kernel32.dll" ALIAS "Wow64DisableWow64FsRedirection" ( BYREF OldValue AS QUAD ) AS LONG
DECLARE FUNCTION Wow64RevertWow64FsRedirection LIB "kernel32.dll" ALIAS "Wow64RevertWow64FsRedirection" ( BYVAL OldValue AS QUAD
 ) AS LONG
'//
'// for GetProcAddress
'//
'typedef UINT (WINAPI* PGET_SYSTEM_WOW64_DIRECTORY_A)(__out_ecount_part_opt(uSize, return + 1) LPSTR lpBuffer, __in UINT uSize);
'typedef UINT (WINAPI* PGET_SYSTEM_WOW64_DIRECTORY_W)(__out_ecount_part_opt(uSize, return + 1) LPWSTR lpBuffer, __in UINT uSize);
'//
'// GetProcAddress only accepts GET_SYSTEM_WOW64_DIRECTORY_NAME_A_A,
'// GET_SYSTEM_WOW64_DIRECTORY_NAME_W_A, GET_SYSTEM_WOW64_DIRECTORY_NAME_T_A.
'// The others are if you want to use the strings in some other way.
'//
'#define GET_SYSTEM_WOW64_DIRECTORY_NAME_A_A "GetSystemWow64DirectoryA"
'#define GET_SYSTEM_WOW64_DIRECTORY_NAME_A_W L"GetSystemWow64DirectoryA"
'#define GET_SYSTEM_WOW64_DIRECTORY_NAME_A_T TEXT("GetSystemWow64DirectoryA")
'#define GET_SYSTEM_WOW64_DIRECTORY_NAME_W_A "GetSystemWow64DirectoryW"
'#define GET_SYSTEM_WOW64_DIRECTORY_NAME_W_W L"GetSystemWow64DirectoryW"
'#define GET_SYSTEM_WOW64_DIRECTORY_NAME_W_T TEXT("GetSystemWow64DirectoryW")
$GET_SYSTEM_WOW64_DIRECTORY_NAME_A_A = "GetSystemWow64DirectoryA"
$$GET_SYSTEM_WOW64_DIRECTORY_NAME_A_W = "GetSystemWow64DirectoryA"$$
$GET_SYSTEM_WOW64_DIRECTORY_NAME_W_A = "GetSystemWow64DirectoryW"
$$GET_SYSTEM_WOW64_DIRECTORY_NAME_W_W = "GetSystemWow64DirectoryW"$$
#IF %DEF(%UNICODE)
 MACRO GET_SYSTEM_WOW64_DIRECTORY_NAME = $GET_SYSTEM_WOW64_DIRECTORY_NAME_A_A
#ELSE
 MACRO GET_SYSTEM_WOW64_DIRECTORY_NAME = $$GET_SYSTEM_WOW64_DIRECTORY_NAME_A_W
#ENDIF
'#ifdef UNICODE
'#define GET_SYSTEM_WOW64_DIRECTORY_NAME_T_A GET_SYSTEM_WOW64_DIRECTORY_NAME_W_A
'#define GET_SYSTEM_WOW64_DIRECTORY_NAME_T_W GET_SYSTEM_WOW64_DIRECTORY_NAME_W_W
'#define GET_SYSTEM_WOW64_DIRECTORY_NAME_T_T GET_SYSTEM_WOW64_DIRECTORY_NAME_W_T
'#else
'#define GET_SYSTEM_WOW64_DIRECTORY_NAME_T_A GET_SYSTEM_WOW64_DIRECTORY_NAME_A_A
'#define GET_SYSTEM_WOW64_DIRECTORY_NAME_T_W GET_SYSTEM_WOW64_DIRECTORY_NAME_A_W
'#define GET_SYSTEM_WOW64_DIRECTORY_NAME_T_T GET_SYSTEM_WOW64_DIRECTORY_NAME_A_T
'#endif
'#endif // _WIN32_WINNT >= 0x0501
'#endif
DECLARE FUNCTION SetCurrentDirectoryA LIB "kernel32.dll" ALIAS "SetCurrentDirectoryA" ( BYREF lpPathName AS ASCIIZ ) AS LONG
DECLARE FUNCTION SetCurrentDirectoryW LIB "kernel32.dll" ALIAS "SetCurrentDirectoryW" ( BYREF lpPathName AS WSTRINGZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SetCurrentDirectory = SetCurrentDirectoryW
#ELSE
 MACRO SetCurrentDirectory = SetCurrentDirectoryA
#ENDIF
DECLARE FUNCTION GetCurrentDirectoryA LIB "kernel32.dll" ALIAS "GetCurrentDirectoryA" ( BYVAL nBufferLength AS QUAD , BYREF lpBuffer AS ASCIIZ ) AS QUAD
DECLARE FUNCTION GetCurrentDirectoryW LIB "kernel32.dll" ALIAS "GetCurrentDirectoryW" ( BYVAL nBufferLength AS QUAD
 , BYREF lpBuffer AS WSTRINGZ
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO GetCurrentDirectory = GetCurrentDirectoryW
#ELSE
 MACRO GetCurrentDirectory = GetCurrentDirectoryA
#ENDIF
'#if _WIN32_WINNT >= 0x0502
DECLARE FUNCTION SetDllDirectoryA LIB "kernel32.dll" ALIAS "SetDllDirectoryA" ( BYREF lpPathName AS ASCIIZ ) AS LONG
DECLARE FUNCTION SetDllDirectoryW LIB "kernel32.dll" ALIAS "SetDllDirectoryW" ( BYREF lpPathName AS WSTRINGZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SetDllDirectory = SetDllDirectoryW
#ELSE
 MACRO SetDllDirectory = SetDllDirectoryA
#ENDIF
DECLARE FUNCTION GetDllDirectoryA LIB "kernel32.dll" ALIAS "GetDllDirectory" ( BYVAL nBufferLength AS QUAD , BYREF lpBuffer AS ASCIIZ ) AS QUAD
DECLARE FUNCTION GetDllDirectoryW LIB "kernel32.dll" ALIAS "GetDllDirectoryW" ( BYVAL nBufferLength AS QUAD
 , BYREF lpBuffer AS WSTRINGZ
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO GetDllDirectory = GetDllDirectoryW
#ELSE
 MACRO GetDllDirectory = GetDllDirectoryA
#ENDIF
'#endif // _WIN32_WINNT >= 0x0502
%EQUATE `BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE = &H1
%EQUATE `BASE_SEARCH_PATH_DISABLE_SAFE_SEARCHMODE = &H10000
%EQUATE `BASE_SEARCH_PATH_PERMANENT = &H8000
%EQUATE `BASE_SEARCH_PATH_INVALID_FLAGS = NOT &H18001 ' ~0x18001
DECLARE FUNCTION SetSearchPathMode LIB "kernel32.dll" ALIAS "SetSearchPathMode" ( BYVAL Flags AS QUAD ) AS LONG
DECLARE FUNCTION GetDiskFreeSpaceA LIB "kernel32.dll" ALIAS "GetDiskFreeSpaceA" ( BYREF lpRootPathName AS ASCIIZ
 , BYREF lpSectorsPerCluster AS DWORD
 , BYREF lpBytesPerSector AS DWORD
 , BYREF lpNumberOfFreeClusters AS DWORD
 , BYREF lpTotalNumberOfClusters AS DWORD
 ) AS LONG
DECLARE FUNCTION GetDiskFreeSpaceW LIB "kernel32.dll" ALIAS "GetDiskFreeSpaceW" ( BYREF lpRootPathName AS WSTRINGZ
 , BYREF lpSectorsPerCluster AS DWORD
 , BYREF lpBytesPerSector AS DWORD
 , BYREF lpNumberOfFreeClusters AS DWORD
 , BYREF lpTotalNumberOfClusters AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO GetDiskFreeSpace = GetDiskFreeSpaceW
#ELSE
 MACRO GetDiskFreeSpace = GetDiskFreeSpaceA
#ENDIF
DECLARE FUNCTION GetDiskFreeSpaceExA LIB "kernel32.dll" ALIAS "GetDiskFreeSpaceExA" ( BYREF lpDirectoryName AS ASCIIZ , BYREF lpFreeBytesAvailableToCaller AS QUAD , BYREF lpTotalNumberOfBytes AS QUAD , BYREF lpTotalNumberOfFreeBytes AS QUAD ) AS LONG
DECLARE FUNCTION GetDiskFreeSpaceExW LIB "kernel32.dll" ALIAS "GetDiskFreeSpaceExW" ( BYREF lpDirectoryName AS WSTRINGZ
 , BYREF lpFreeBytesAvailableToCaller AS QUAD
 , BYREF lpTotalNumberOfBytes AS QUAD
 , BYREF lpTotalNumberOfFreeBytes AS QUAD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO GetDiskFreeSpaceEx = GetDiskFreeSpaceExW
#ELSE
 MACRO GetDiskFreeSpaceEx = GetDiskFreeSpaceExA
#ENDIF
DECLARE FUNCTION CreateDirectoryA LIB "kernel32.dll" ALIAS "CreateDirectoryA" ( BYREF lpPathName AS ASCIIZ , BYREF lpSecurityAttributes AS SECURITY_ATTRIBUTES ) AS LONG
DECLARE FUNCTION CreateDirectoryW LIB "kernel32.dll" ALIAS "CreateDirectoryW" ( BYREF lpPathName AS WSTRINGZ
 , BYREF lpSecurityAttributes AS SECURITY_ATTRIBUTES
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO CreateDirectory = CreateDirectoryW
#ELSE
 MACRO CreateDirectory = CreateDirectoryA
#ENDIF
DECLARE FUNCTION CreateDirectoryExA LIB "kernel32.dll" ALIAS "CreateDirectoryExA" ( BYREF lpTemplateDirectory AS ASCIIZ , BYREF lpNewDirectory AS ASCIIZ , BYREF lpSecurityAttributes AS SECURITY_ATTRIBUTES ) AS LONG
DECLARE FUNCTION CreateDirectoryExW LIB "kernel32.dll" ALIAS "CreateDirectoryExW" ( BYREF lpTemplateDirectory AS WSTRINGZ
 , BYREF lpNewDirectory AS WSTRINGZ
 , BYREF lpSecurityAttributes AS SECURITY_ATTRIBUTES
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO CreateDirectoryEx = CreateDirectoryExW
#ELSE
 MACRO CreateDirectoryEx = CreateDirectoryExA
#ENDIF
'#if _WIN32_WINNT >= 0x0600
#IF %WINVER >= &H0600
DECLARE FUNCTION CreateDirectoryTransactedA LIB "kernel32.dll" ALIAS "CreateDirectoryTransactedA" ( BYREF lpTemplateDirectory AS ASCIIZ , BYREF lpNewDirectory AS ASCIIZ , BYREF lpSecurityAttributes AS SECURITY_ATTRIBUTES , BYVAL hTransaction AS QUAD ) AS LONG
DECLARE FUNCTION CreateDirectoryTransactedW LIB "kernel32.dll" ALIAS "CreateDirectoryTransactedW" ( BYREF lpTemplateDirectory AS WSTRINGZ
 , BYREF lpNewDirectory AS WSTRINGZ
 , BYREF lpSecurityAttributes AS SECURITY_ATTRIBUTES
 , BYVAL hTransaction AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO CreateDirectoryTransacted = CreateDirectoryTransactedW
#ELSE
 MACRO CreateDirectoryTransacted = CreateDirectoryTransactedA
#ENDIF
#ENDIF ' // _WIN32_WINNT >= 0x0600
DECLARE FUNCTION RemoveDirectoryA LIB "kernel32.dll" ALIAS "RemoveDirectoryA" ( BYREF lpPathName AS ASCIIZ ) AS LONG
DECLARE FUNCTION RemoveDirectoryW LIB "kernel32.dll" ALIAS "RemoveDirectoryW" ( BYREF lpPathName AS WSTRINGZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO RemoveDirectory = RemoveDirectoryW
#ELSE
 MACRO RemoveDirectory = RemoveDirectoryA
#ENDIF
'#if _WIN32_WINNT >= 0x0600
#IF %WINVER >= &H0600
DECLARE FUNCTION RemoveDirectoryTransactedA LIB "kernel32.dll" ALIAS "RemoveDirectoryTransactedA" ( BYREF lpPathName AS ASCIIZ , BYVAL hTransaction AS QUAD ) AS LONG
DECLARE FUNCTION RemoveDirectoryTransactedW LIB "kernel32.dll" ALIAS "RemoveDirectoryTransactedW" ( BYREF lpPathName AS WSTRINGZ
 , BYVAL hTransaction AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO RemoveDirectoryTransacted = RemoveDirectoryTransactedW
#ELSE
 MACRO RemoveDirectoryTransacted = RemoveDirectoryTransactedA
#ENDIF
#ENDIF ' // _WIN32_WINNT >= 0x0600
DECLARE FUNCTION GetFullPathNameA LIB "kernel32.dll" ALIAS "GetFullPathNameA" ( BYREF lpFileName AS ASCIIZ , BYVAL nBufferLength AS QUAD , BYREF lpBuffer AS ASCIIZ , OPTIONAL BYREF lpFilePart AS QUAD ) AS QUAD
DECLARE FUNCTION GetFullPathNameW LIB "kernel32.dll" ALIAS "GetFullPathNameW" ( BYREF lpFileName AS WSTRINGZ
 , BYVAL nBufferLength AS DWORD
 , BYREF lpBuffer AS WSTRINGZ
 , OPTIONAL BYREF lpFilePart AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO GetFullPathName = GetFullPathNameW
#ELSE
 MACRO GetFullPathName = GetFullPathNameA
#ENDIF
'#if _WIN32_WINNT >= 0x0600
#IF %WINVER >= &H0600
DECLARE FUNCTION GetFullPathNameTransactedA LIB "kernel32.dll" ALIAS "GetFullPathNameTransactedA" ( BYREF lpFileName AS ASCIIZ , BYVAL nBufferLength AS QUAD , BYREF lpBuffer AS ASCIIZ , BYREF lpFilePart AS QUAD , BYVAL hTransaction AS QUAD ) AS QUAD
DECLARE FUNCTION GetFullPathNameTransactedW LIB "kernel32.dll" ALIAS "GetFullPathNameTransactedW" ( BYREF lpFileName AS WSTRINGZ
 , BYVAL nBufferLength AS DWORD
 , BYREF lpBuffer AS WSTRINGZ
 , BYREF lpFilePart AS DWORD
 , BYVAL hTransaction AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO GetFullPathNameTransacted = GetFullPathNameTransactedW
#ELSE
 MACRO GetFullPathNameTransacted = GetFullPathNameTransactedA
#ENDIF
#ENDIF ' // _WIN32_WINNT >= 0x0600
%EQUATE `DDD_RAW_TARGET_PATH = &H00000001
%EQUATE `DDD_REMOVE_DEFINITION = &H00000002
%EQUATE `DDD_EXACT_MATCH_ON_REMOVE = &H00000004
%EQUATE `DDD_NO_BROADCAST_SYSTEM = &H00000008
%EQUATE `DDD_LUID_BROADCAST_DRIVE = &H00000010
DECLARE FUNCTION DefineDosDeviceA LIB "kernel32.dll" ALIAS "DefineDosDeviceA" ( BYVAL dwFlags AS QUAD , BYREF lpDeviceName AS ASCIIZ , BYREF lpTargetPath AS ASCIIZ ) AS LONG
DECLARE FUNCTION DefineDosDeviceW LIB "kernel32.dll" ALIAS "DefineDosDeviceW" ( BYVAL dwFlags AS QUAD
 , BYREF lpDeviceName AS WSTRINGZ
 , BYREF lpTargetPath AS WSTRINGZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO DefineDosDevice = DefineDosDeviceW
#ELSE
 MACRO DefineDosDevice = DefineDosDeviceA
#ENDIF
DECLARE FUNCTION QueryDosDeviceA LIB "kernel32.dll" ALIAS "QueryDosDeviceA" ( BYREF lpDeviceName AS ASCIIZ , BYREF lpTargetPath AS ASCIIZ , BYVAL ucchMax AS QUAD ) AS QUAD
DECLARE FUNCTION QueryDosDeviceW LIB "kernel32.dll" ALIAS "QueryDosDeviceW" ( BYREF lpDeviceName AS WSTRINGZ
 , BYREF lpTargetPath AS WSTRINGZ
 , BYVAL ucchMax AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO QueryDosDevice = QueryDosDeviceW
#ELSE
 MACRO QueryDosDevice = QueryDosDeviceA
#ENDIF
'#define EXPAND_LOCAL_DRIVES
DECLARE FUNCTION CreateFileA LIB "kernel32.dll" ALIAS "CreateFileA" ( BYREF lpFileName AS ASCIIZ , BYVAL dwDesiredAccess AS QUAD , BYVAL dwShareMode AS QUAD , BYREF lpSecurityAttributes AS SECURITY_ATTRIBUTES , BYVAL dwCreationDisposition AS QUAD , BYVAL dwFlagsAndAttributes AS QUAD , BYVAL hTemplateFile AS QUAD ) AS QUAD
DECLARE FUNCTION CreateFileW LIB "kernel32.dll" ALIAS "CreateFileW" ( BYREF lpFileName AS WSTRINGZ
 , BYVAL dwDesiredAccess AS DWORD
 , BYVAL dwShareMode AS DWORD
 , BYREF lpSecurityAttributes AS SECURITY_ATTRIBUTES
 , BYVAL dwCreationDisposition AS DWORD
 , BYVAL dwFlagsAndAttributes AS DWORD
 , BYVAL hTemplateFile AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO CreateFile = CreateFileW
#ELSE
 MACRO CreateFile = CreateFileA
#ENDIF
'#if _WIN32_WINNT >= 0x0600
#IF %WINVER >= &H0600
DECLARE FUNCTION CreateFileTransactedA LIB "kernel32.dll" ALIAS "CreateFileTransactedA" ( BYREF lpFileName AS ASCIIZ , BYVAL dwDesiredAccess AS QUAD , BYVAL dwShareMode AS QUAD , BYREF lpSecurityAttributes AS SECURITY_ATTRIBUTES , BYVAL dwCreationDisposition AS QUAD , BYVAL dwFlagsAndAttributes AS QUAD , BYVAL hTemplateFile AS QUAD , BYVAL hTransaction AS QUAD , BYREF pusMiniVersion AS WORD , BYVAL lpExtendedParameter AS QUAD ) AS QUAD
DECLARE FUNCTION CreateFileTransactedW LIB "kernel32.dll" ALIAS "CreateFileTransactedW" ( BYREF lpFileName AS WSTRINGZ
 , BYVAL dwDesiredAccess AS DWORD
 , BYVAL dwShareMode AS DWORD
 , BYREF lpSecurityAttributes AS SECURITY_ATTRIBUTES
 , BYVAL dwCreationDisposition AS DWORD
 , BYVAL dwFlagsAndAttributes AS DWORD
 , BYVAL hTemplateFile AS DWORD
 , BYVAL hTransaction AS DWORD
 , BYREF pusMiniVersion AS WORD
 , BYVAL lpExtendedParameter AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO CreateFileTransacted = CreateFileTransactedW
#ELSE
 MACRO CreateFileTransacted = CreateFileTransactedA
#ENDIF
#ENDIF ' // _WIN32_WINNT >= 0x0600
'#if _WIN32_WINNT >= 0x0502
DECLARE FUNCTION ReOpenFile LIB "kernel32.dll" ALIAS "ReOpenFile" ( BYVAL hOriginalFile AS QUAD , BYVAL dwDesiredAccess AS QUAD , BYVAL dwShareMode AS QUAD , BYVAL dwFlagsAndAttributes AS QUAD ) AS QUAD
'#endif // _WIN32_WINNT >= 0x0502
DECLARE FUNCTION SetFileAttributesA LIB "kernel32.dll" ALIAS "SetFileAttributesA" ( BYREF lpFileName AS ASCIIZ , BYVAL dwFileAttributes AS QUAD ) AS LONG
DECLARE FUNCTION SetFileAttributesW LIB "kernel32.dll" ALIAS "SetFileAttributesW" ( BYREF lpFileName AS WSTRINGZ
 , BYVAL dwFileAttributes AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SetFileAttributes = SetFileAttributesW
#ELSE
 MACRO SetFileAttributes = SetFileAttributesA
#ENDIF
DECLARE FUNCTION GetFileAttributesA LIB "kernel32.dll" ALIAS "GetFileAttributesA" ( BYREF lpFileName AS ASCIIZ ) AS QUAD
DECLARE FUNCTION GetFileAttributesW LIB "kernel32.dll" ALIAS "GetFileAttributesW" ( BYREF lpFileName AS WSTRINGZ
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO GetFileAttributes = GetFileAttributesW
#ELSE
 MACRO GetFileAttributes = GetFileAttributesA
#ENDIF
'#if _WIN32_WINNT >= 0x0600
#IF %WINVER >= &H0600
DECLARE FUNCTION SetFileAttributesTransactedA LIB "kernel32.dll" ALIAS "SetFileAttributesTransactedA" ( BYREF lpFileName AS ASCIIZ , BYVAL dwFileAttributes AS QUAD , BYVAL hTransaction AS QUAD ) AS LONG
DECLARE FUNCTION SetFileAttributesTransactedW LIB "kernel32.dll" ALIAS "SetFileAttributesTransactedW" ( BYREF lpFileName AS WSTRINGZ
 , BYVAL dwFileAttributes AS DWORD
 , BYVAL hTransaction AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SetFileAttributesTransacted = SetFileAttributesTransactedW
#ELSE
 MACRO SetFileAttributesTransacted = SetFileAttributesTransactedA
#ENDIF
#ENDIF ' // _WIN32_WINNT >= 0x0600
' GET_FILEEX_INFO_LEVELS enum
%EQUATE `GetFileExInfoStandard = 0
%EQUATE `GetFileExMaxInfoLevel = 1
'#if _WIN32_WINNT >= 0x0600
#IF %WINVER >= &H0600
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION GetFileAttributesTransactedA LIB "Kernel32.dll" ALIAS "GetFileAttributesTransactedA" (lpFileName AS ASCIIZ, BYVAL fInfoLevelId AS LONG, BYVAL lpFileInformation AS QUAD, BYVAL hTransaction AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION GetFileAttributesTransactedA LIB "kernel32.dll" ALIAS "GetFileAttributesTransactedA" ( BYREF lpFileName AS ASCIIZ , BYVAL fInfoLevelId AS LONG , BYREF lpFileInformation AS ANY , BYVAL hTransaction AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION GetFileAttributesTransactedW LIB "Kernel32.dll" ALIAS "GetFileAttributesTransactedW" (lpFileName AS WSTRINGZ, BYVAL fInfoLevelId AS LONG, BYVAL lpFileInformation AS QUAD, BYVAL hTransaction AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION GetFileAttributesTransactedW LIB "kernel32.dll" ALIAS "GetFileAttributesTransactedW" ( BYREF lpFileName AS WSTRINGZ , BYVAL fInfoLevelId AS LONG , BYREF lpFileInformation AS ANY , BYVAL hTransaction AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%UNICODE)
 MACRO GetFileAttributesTransacted = GetFileAttributesTransactedW
#ELSE
 MACRO GetFileAttributesTransacted = GetFileAttributesTransactedA
#ENDIF
#ENDIF ' // _WIN32_WINNT >= 0x0600
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION GetFileAttributesExA LIB "Kernel32.dll" ALIAS "GetFileAttributesExA" (lpFileName AS ASCIIZ, BYVAL fInfoLevelId AS LONG, BYVAL lpFileInformation AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION GetFileAttributesExA LIB "kernel32.dll" ALIAS "GetFileAttributesExA" ( BYREF lpFileName AS ASCIIZ , BYVAL fInfoLevelId AS LONG , BYREF lpFileInformation AS ANY ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION GetFileAttributesExW LIB "Kernel32.dll" ALIAS "GetFileAttributesExW" (lpFileName AS WSTRINGZ, BYVAL fInfoLevelId AS LONG, BYVAL lpFileInformation AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION GetFileAttributesExW LIB "kernel32.dll" ALIAS "GetFileAttributesExW" ( BYREF lpFileName AS WSTRINGZ , BYVAL fInfoLevelId AS LONG , BYREF lpFileInformation AS ANY ) AS LONG
#ENDIF
#IF %DEF(%UNICODE)
 MACRO GetFileAttributesEx = GetFileAttributesExW
#ELSE
 MACRO GetFileAttributesEx = GetFileAttributesExA
#ENDIF
DECLARE FUNCTION GetCompressedFileSizeA LIB "kernel32.dll" ALIAS "GetCompressedFileSizeA" ( BYREF lpFileName AS ASCIIZ , BYREF lpFileSizeHigh AS QUAD ) AS QUAD
DECLARE FUNCTION GetCompressedFileSizeW LIB "kernel32.dll" ALIAS "GetCompressedFileSizeW" ( BYREF lpFileName AS WSTRINGZ
 , BYREF lpFileSizeHigh AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO GetCompressedFileSize = GetCompressedFileSizeW
#ELSE
 MACRO GetCompressedFileSize = GetCompressedFileSizeA
#ENDIF
'#if _WIN32_WINNT >= 0x0600
#IF %WINVER >= &H0600
DECLARE FUNCTION GetCompressedFileSizeTransactedA LIB "kernel32.dll" ALIAS "GetCompressedFileSizeTransactedA" ( BYREF lpFileName AS ASCIIZ , BYREF lpFileSizeHigh AS QUAD , BYVAL hTransaction AS QUAD ) AS QUAD
DECLARE FUNCTION GetCompressedFileSizeTransactedW LIB "kernel32.dll" ALIAS "GetCompressedFileSizeTransactedW" ( BYREF lpFileName AS WSTRINGZ
 , BYREF lpFileSizeHigh AS DWORD
 , BYVAL hTransaction AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO GetCompressedFileSizeTransacted = GetCompressedFileSizeTransactedW
#ELSE
 MACRO GetCompressedFileSizeTransacted = GetCompressedFileSizeTransactedA
#ENDIF
#ENDIF ' // _WIN32_WINNT >= 0x0600
DECLARE FUNCTION DeleteFileA LIB "kernel32.dll" ALIAS "DeleteFileA" ( BYREF lpFileName AS ASCIIZ ) AS LONG
DECLARE FUNCTION DeleteFileW LIB "kernel32.dll" ALIAS "DeleteFileW" ( BYREF lpFileName AS WSTRINGZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO DeleteFile = DeleteFileW
#ELSE
 MACRO DeleteFile = DeleteFileA
#ENDIF
'#if _WIN32_WINNT >= 0x0600
#IF %WINVER >= &H0600
DECLARE FUNCTION DeleteFileTransactedA LIB "kernel32.dll" ALIAS "DeleteFileTransactedA" ( BYREF lpFileName AS ASCIIZ , BYVAL hTransaction AS QUAD ) AS LONG
DECLARE FUNCTION DeleteFileTransactedW LIB "kernel32.dll" ALIAS "DeleteFileTransactedW" ( BYREF lpFileName AS WSTRINGZ
 , BYVAL hTransaction AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO DeleteFileTransacted = DeleteFileTransactedW
#ELSE
 MACRO DeleteFileTransacted = DeleteFileTransactedA
#ENDIF
#ENDIF ' // _WIN32_WINNT >= 0x0600
'#if _WIN32_WINNT >= 0x0501
DECLARE FUNCTION CheckNameLegalDOS8Dot3A LIB "kernel32.dll" ALIAS "CheckNameLegalDOS8Dot3A" ( BYREF lpName AS ASCIIZ , BYREF lpOemName AS ASCIIZ , BYVAL OemNameSize AS QUAD , BYREF pbNameContainsSpaces AS LONG , BYREF pbNameLegal AS LONG ) AS LONG
DECLARE FUNCTION CheckNameLegalDOS8Dot3W LIB "kernel32.dll" ALIAS "CheckNameLegalDOS8Dot3W" ( BYREF lpName AS WSTRINGZ
 , BYREF lpOemName AS WSTRINGZ
 , BYVAL OemNameSize AS DWORD
 , BYREF pbNameContainsSpaces AS LONG
 , BYREF pbNameLegal AS LONG
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO CheckNameLegalDOS8Dot3 = CheckNameLegalDOS8Dot3W
#ELSE
 MACRO CheckNameLegalDOS8Dot3 = CheckNameLegalDOS8Dot3A
#ENDIF
'#endif // (_WIN32_WINNT >= 0x0501)
'#if(_WIN32_WINNT >= 0x0400)
' FINDEX_INFO_LEVELS enum
%EQUATE `FindExInfoStandard = 0
%EQUATE `FindExInfoBasic = 1
%EQUATE `FindExInfoMaxInfoLevel = 2
' FINDEX_SEARCH_OPS enum
%EQUATE `FindExSearchNameMatch = 0
%EQUATE `FindExSearchLimitToDirectories = 1
%EQUATE `FindExSearchLimitToDevices = 2
%EQUATE `FindExSearchMaxSearchOp = 3
%EQUATE `FIND_FIRST_EX_CASE_SENSITIVE = &H00000001
%EQUATE `FIND_FIRST_EX_LARGE_FETCH = &H00000002
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION FindFirstFileExA LIB "Kernel32.dll" ALIAS "FindFirstFileExA" (lpFileName AS ASCIIZ, BYVAL fInfoLevelId AS LONG, BYVAL lpFindFileData AS QUAD, BYVAL fSearchOp AS LONG, BYVAL lpSearchFilter AS QUAD, BYVAL dwAdditionalFlags AS QUAD) AS QUAD
#ELSE
DECLARE FUNCTION FindFirstFileExA LIB "kernel32.dll" ALIAS "FindFirstFileExA" ( BYREF lpFileName AS ASCIIZ , BYVAL fInfoLevelId AS LONG , BYREF lpFindFileData AS ANY , BYVAL fSearchOp AS LONG , BYVAL lpSearchFilter AS QUAD , BYVAL dwAdditionalFlags AS QUAD ) AS QUAD
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION FindFirstFileExW LIB "Kernel32.dll" ALIAS "FindFirstFileExW" (lpFileName AS WSTRINGZ, BYVAL fInfoLevelId AS LONG, BYVAL lpFindFileData AS QUAD, BYVAL fSearchOp AS LONG, BYVAL lpSearchFilter AS QUAD, BYVAL dwAdditionalFlags AS QUAD) AS QUAD
#ELSE
DECLARE FUNCTION FindFirstFileExW LIB "kernel32.dll" ALIAS "FindFirstFileExW" ( BYREF lpFileName AS WSTRINGZ , BYVAL fInfoLevelId AS LONG , BYREF lpFindFileData AS ANY , BYVAL fSearchOp AS LONG , BYVAL lpSearchFilter AS QUAD , BYVAL dwAdditionalFlags AS QUAD ) AS QUAD
#ENDIF
#IF %DEF(%UNICODE)
 MACRO FindFirstFileEx = FindFirstFileExW
#ELSE
 MACRO FindFirstFileEx = FindFirstFileExA
#ENDIF
'#if _WIN32_WINNT >= 0x0600
#IF %WINVER >= &H0600
DECLARE FUNCTION FindFirstFileTransactedA LIB "kernel32.dll" ALIAS "FindFirstFileTransactedA" ( BYREF lpFileName AS ASCIIZ , BYVAL fInfoLevelId AS LONG , BYREF lpFindFileData AS ANY , BYVAL fSearchOp AS LONG , BYVAL lpSearchFilter AS QUAD , BYVAL dwAdditionalFlags AS QUAD , BYVAL hTransaction AS QUAD ) AS QUAD
DECLARE FUNCTION FindFirstFileTransactedW LIB "kernel32.dll" ALIAS "FindFirstFileTransactedW" ( BYREF lpFileName AS WSTRINGZ
 , BYVAL fInfoLevelId AS LONG
 , BYREF lpFindFileData AS ANY
 , BYVAL fSearchOp AS LONG
 , BYVAL lpSearchFilter AS DWORD
 , BYVAL dwAdditionalFlags AS DWORD
 , BYVAL hTransaction AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO FindFirstFileTransacted = FindFirstFileTransactedW
#ELSE
 MACRO FindFirstFileTransacted = FindFirstFileTransactedA
#ENDIF
#ENDIF
DECLARE FUNCTION FindFirstFileA LIB "kernel32.dll" ALIAS "FindFirstFileA" ( BYREF lpFileName AS ASCIIZ , BYREF lpFindFileData AS WIN32_FIND_DATAA ) AS QUAD
DECLARE FUNCTION FindFirstFileW LIB "kernel32.dll" ALIAS "FindFirstFileW" ( BYREF lpFileName AS WSTRINGZ
 , BYREF lpFindFileData AS WIN32_FIND_DATAW
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO FindFirstFile = FindFirstFileW
#ELSE
 MACRO FindFirstFile = FindFirstFileA
#ENDIF
DECLARE FUNCTION FindNextFileA LIB "kernel32.dll" ALIAS "FindNextFileA" ( BYVAL hFindFile AS QUAD , BYREF lpFindFileData AS WIN32_FIND_DATAA ) AS LONG
DECLARE FUNCTION FindNextFileW LIB "kernel32.dll" ALIAS "FindNextFileW" ( BYVAL hFindFile AS QUAD
 , BYREF lpFindFileData AS WIN32_FIND_DATAW
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO FindNextFile = FindNextFileW
#ELSE
 MACRO FindNextFile = FindNextFileA
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION SearchPathA LIB "Kernel32.dll" ALIAS "SearchPathA" (lpPath AS ASCIIZ, lpFileName AS ASCIIZ, lpExtension AS ASCIIZ, BYVAL nBufferLength AS LONG, lpBuffer AS ASCIIZ, lpFilePart AS ASCIIZ) AS QUAD
#ELSE
DECLARE FUNCTION SearchPathA LIB "kernel32.dll" ALIAS "SearchPathA" ( BYREF lpPath AS ASCIIZ , BYREF lpFileName AS ASCIIZ , BYREF lpExtension AS ASCIIZ , BYVAL nBufferLength AS QUAD , BYREF lpBuffer AS ASCIIZ , OPTIONAL BYREF lpFilePart AS QUAD ) AS QUAD
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION SearchPathW LIB "Kernel32.dll" ALIAS "SearchPathW" (lpPath AS WSTRINGZ, lpFileName AS WSTRINGZ, lpExtension AS WSTRINGZ, BYVAL nBufferLength AS LONG, lpBuffer AS WSTRINGZ, lpFilePart AS WSTRINGZ) AS QUAD
#ELSE
DECLARE FUNCTION SearchPathW LIB "kernel32.dll" ALIAS "SearchPathW" ( BYREF lpPath AS WSTRINGZ , BYREF lpFileName AS WSTRINGZ , BYREF lpExtension AS WSTRINGZ , BYVAL nBufferLength AS QUAD , BYREF lpBuffer AS WSTRINGZ , OPTIONAL BYREF lpFilePart AS QUAD ) AS QUAD
#ENDIF
#IF %DEF(%UNICODE)
 MACRO SearchPath = SearchPathW
#ELSE
 MACRO SearchPath = SearchPathA
#ENDIF
DECLARE FUNCTION CopyFileA LIB "kernel32.dll" ALIAS "CopyFileA" ( BYREF lpExistingFileName AS ASCIIZ , BYREF lpNewFileName AS ASCIIZ , BYVAL bFailIfExists AS LONG ) AS LONG
DECLARE FUNCTION CopyFileW LIB "kernel32.dll" ALIAS "CopyFileW" ( BYREF lpExistingFileName AS WSTRINGZ
 , BYREF lpNewFileName AS WSTRINGZ
 , BYVAL bFailIfExists AS LONG
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO CopyFile = CopyFileW
#ELSE
 MACRO CopyFile = CopyFileA
#ENDIF
'#if(_WIN32_WINNT >= 0x0400)
'typedef
'(WINAPI *LPPROGRESS_ROUTINE)(
' );
DECLARE FUNCTION CopyFileExA LIB "kernel32.dll" ALIAS "CopyFileExA" ( BYREF lpExistingFileName AS ASCIIZ , BYREF lpNewFileName AS ASCIIZ , BYVAL lpProgressRoutine AS QUAD , BYVAL lpData AS QUAD , BYREF pbCancel AS LONG , BYVAL dwCopyFlags AS QUAD ) AS LONG
DECLARE FUNCTION CopyFileExW LIB "kernel32.dll" ALIAS "CopyFileExW" ( BYREF lpExistingFileName AS WSTRINGZ
 , BYREF lpNewFileName AS WSTRINGZ
 , BYVAL lpProgressRoutine AS DWORD
 , BYVAL lpData AS DWORD
 , BYREF pbCancel AS LONG
 , BYVAL dwCopyFlags AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO CopyFileEx = CopyFileExW
#ELSE
 MACRO CopyFileEx = CopyFileExA
#ENDIF
'#if _WIN32_WINNT >= 0x0600
#IF %WINVER >= &H0600
DECLARE FUNCTION CopyFileTransactedA LIB "kernel32.dll" ALIAS "CopyFileTransactedA" ( BYREF lpExistingFileName AS ASCIIZ , BYREF lpNewFileName AS ASCIIZ , BYVAL lpProgressRoutine AS QUAD , BYVAL lpData AS QUAD , BYREF pbCancel AS LONG , BYVAL dwCopyFlags AS QUAD , BYVAL hTransaction AS QUAD ) AS LONG
DECLARE FUNCTION CopyFileTransactedW LIB "kernel32.dll" ALIAS "CopyFileTransactedW" ( BYREF lpExistingFileName AS WSTRINGZ
 , BYREF lpNewFileName AS WSTRINGZ
 , BYVAL lpProgressRoutine AS DWORD
 , BYVAL lpData AS DWORD
 , BYREF pbCancel AS LONG
 , BYVAL dwCopyFlags AS DWORD
 , BYVAL hTransaction AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO CopyFileTransacted = CopyFileTransactedW
#ELSE
 MACRO CopyFileTransacted = CopyFileTransactedA
#ENDIF
#ENDIF ' // _WIN32_WINNT >= 0x0600
'#ENDIF ' /* _WIN32_WINNT >= 0x0400 */
DECLARE FUNCTION MoveFileA LIB "kernel32.dll" ALIAS "MoveFileA" ( BYREF lpExistingFileName AS ASCIIZ , BYREF lpNewFileName AS ASCIIZ ) AS LONG
DECLARE FUNCTION MoveFileW LIB "kernel32.dll" ALIAS "MoveFileW" ( BYREF lpExistingFileName AS WSTRINGZ
 , BYREF lpNewFileName AS WSTRINGZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO MoveFile = MoveFileW
#ELSE
 MACRO MoveFile = MoveFileA
#ENDIF
DECLARE FUNCTION MoveFileExA LIB "kernel32.dll" ALIAS "MoveFileExA" ( BYREF lpExistingFileName AS ASCIIZ , BYREF lpNewFileName AS ASCIIZ , BYVAL dwFlags AS QUAD ) AS LONG
DECLARE FUNCTION MoveFileExW LIB "kernel32.dll" ALIAS "MoveFileExW" ( BYREF lpExistingFileName AS WSTRINGZ
 , BYREF lpNewFileName AS WSTRINGZ
 , BYVAL dwFlags AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO MoveFileEx = MoveFileExW
#ELSE
 MACRO MoveFileEx = MoveFileExA
#ENDIF
'#if (_WIN32_WINNT >= 0x0500)
DECLARE FUNCTION MoveFileWithProgressA LIB "kernel32.dll" ALIAS "MoveFileWithProgressA" ( BYREF lpExistingFileName AS ASCIIZ , BYREF lpNewFileName AS ASCIIZ , BYVAL lpProgressRoutine AS QUAD , BYVAL lpData AS QUAD , BYVAL dwFlags AS QUAD ) AS LONG
DECLARE FUNCTION MoveFileWithProgressW LIB "kernel32.dll" ALIAS "MoveFileWithProgressW" ( BYREF lpExistingFileName AS WSTRINGZ
 , BYREF lpNewFileName AS WSTRINGZ
 , BYVAL lpProgressRoutine AS DWORD
 , BYVAL lpData AS DWORD
 , BYVAL dwFlags AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO MoveFileWithProgress = MoveFileWithProgressW
#ELSE
 MACRO MoveFileWithProgress = MoveFileWithProgressA
#ENDIF
'#if (_WIN32_WINNT >= 0x0600)
#IF %WINVER >= &H0600
DECLARE FUNCTION MoveFileTransactedA LIB "kernel32.dll" ALIAS "MoveFileTransactedA" ( BYREF lpExistingFileName AS ASCIIZ , BYREF lpNewFileName AS ASCIIZ , BYVAL lpProgressRoutine AS QUAD , BYVAL lpData AS QUAD , BYVAL dwFlags AS QUAD , BYVAL hTransaction AS QUAD ) AS LONG
DECLARE FUNCTION MoveFileTransactedW LIB "kernel32.dll" ALIAS "MoveFileTransactedW" ( BYREF lpExistingFileName AS WSTRINGZ
 , BYREF lpNewFileName AS WSTRINGZ
 , BYVAL lpProgressRoutine AS DWORD
 , BYVAL lpData AS DWORD
 , BYVAL dwFlags AS DWORD
 , BYVAL hTransaction AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO MoveFileTransacted = MoveFileTransactedW
#ELSE
 MACRO MoveFileTransacted = MoveFileTransactedA
#ENDIF
#ENDIF ' // (_WIN32_WINNT >= 0x0600)
%EQUATE `MOVEFILE_REPLACE_EXISTING = &H00000001
%EQUATE `MOVEFILE_COPY_ALLOWED = &H00000002
%EQUATE `MOVEFILE_DELAY_UNTIL_REBOOT = &H00000004
%EQUATE `MOVEFILE_WRITE_THROUGH = &H00000008
'#if (_WIN32_WINNT >= 0x0500)
%EQUATE `MOVEFILE_CREATE_HARDLINK = &H00000010
%EQUATE `MOVEFILE_FAIL_IF_NOT_TRACKABLE = &H00000020
'#endif // (_WIN32_WINNT >= 0x0500)
'#if (_WIN32_WINNT >= 0x0500)
DECLARE FUNCTION ReplaceFileA LIB "kernel32.dll" ALIAS "ReplaceFileA" ( BYREF lpReplacedFileName AS ASCIIZ , BYREF lpReplacementFileName AS ASCIIZ , BYREF lpBackupFileName AS ASCIIZ , BYVAL dwReplaceFlags AS QUAD , BYVAL lpExclude AS QUAD , BYVAL lpReserved AS QUAD ) AS LONG
DECLARE FUNCTION ReplaceFileW LIB "kernel32.dll" ALIAS "ReplaceFileW" ( BYREF lpReplacedFileName AS WSTRINGZ
 , BYREF lpReplacementFileName AS WSTRINGZ
 , BYREF lpBackupFileName AS WSTRINGZ
 , BYVAL dwReplaceFlags AS DWORD
 , BYVAL lpExclude AS DWORD
 , BYVAL lpReserved AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO ReplaceFile = ReplaceFileW
#ELSE
 MACRO ReplaceFile = ReplaceFileA
#ENDIF
'#if (_WIN32_WINNT >= 0x0500)
'//
'// API call to create hard links.
'//
DECLARE FUNCTION CreateHardLinkA LIB "kernel32.dll" ALIAS "CreateHardLinkA" ( BYREF lpFileName AS ASCIIZ , BYREF lpExistingFileName AS ASCIIZ , BYREF lpSecurityAttributes AS SECURITY_ATTRIBUTES ) AS LONG
DECLARE FUNCTION CreateHardLinkW LIB "kernel32.dll" ALIAS "CreateHardLinkW" ( BYREF lpFileName AS WSTRINGZ
 , BYREF lpExistingFileName AS WSTRINGZ
 , BYREF lpSecurityAttributes AS SECURITY_ATTRIBUTES
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO CreateHardLink = CreateHardLinkW
#ELSE
 MACRO CreateHardLink = CreateHardLinkA
#ENDIF
'#endif // (_WIN32_WINNT >= 0x0500)
'#if (_WIN32_WINNT >= 0x0600)
#IF %WINVER >= &H0600
'//
'// API call to create hard links.
'//
DECLARE FUNCTION CreateHardLinkTransactedA LIB "kernel32.dll" ALIAS "CreateHardLinkTransactedA" ( BYREF lpFileName AS ASCIIZ , BYREF lpExistingFileName AS ASCIIZ , BYREF lpSecurityAttributes AS SECURITY_ATTRIBUTES , BYVAL hTransaction AS QUAD ) AS LONG
DECLARE FUNCTION CreateHardLinkTransactedW LIB "kernel32.dll" ALIAS "CreateHardLinkTransactedW" ( BYREF lpFileName AS WSTRINGZ
 , BYREF lpExistingFileName AS WSTRINGZ
 , BYREF lpSecurityAttributes AS SECURITY_ATTRIBUTES
 , BYVAL hTransaction AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO CreateHardLinkTransacted = CreateHardLinkTransactedW
#ELSE
 MACRO CreateHardLinkTransacted = CreateHardLinkTransactedA
#ENDIF
#ENDIF ' // (_WIN32_WINNT >= 0x0600)
'#if (_WIN32_WINNT >= 0x0501)
'//
'// API call to enumerate for streams within a file
'//
' STREAM_INFO_LEVELS enum
%EQUATE `FindStreamInfoStandard = 0
%EQUATE `FindStreamInfoMaxInfoLevel = 1
' // Size = 600 bytes
TYPE WIN32_FIND_STREAM_DATA ' Must be 8 byte aligned
 StreamSize AS QUAD ' LARGE_INTEGER StreamSize
 cStreamName AS WSTRINGZ * %MAX_PATH + 36 ' WCHAR cStreamName[ MAX_PATH + 36 ]
END TYPE
DECLARE FUNCTION FindFirstStreamW LIB "kernel32.dll" ALIAS "FindFirstStreamW" ( BYREF lpFileName AS WSTRINGZ , BYVAL InfoLevel AS QUAD , BYREF lpFindStreamData AS ANY , BYVAL dwFlags AS QUAD ) AS QUAD
MACRO FindFirstStream = FindFirstStreamW
'#if _WIN32_WINNT >= 0x0600
#IF %WINVER >= &H0600
DECLARE FUNCTION FindFirstStreamTransactedW LIB "kernel32.dll" ALIAS "FindFirstStreamTransactedW" ( BYREF lpFileName AS WSTRINGZ , BYVAL InfoLevel AS QUAD , BYREF lpFindStreamData AS ANY , BYVAL dwFlags AS QUAD , BYVAL hTransaction AS QUAD ) AS QUAD
#ENDIF
MACRO FindFirstStreamTransacted = FindFirstStreamTransactedW
'#endif // _WIN32_WINNT >= 0x600
DECLARE FUNCTION FindNextStreamW LIB "kernel32.dll" ALIAS "FindNextStreamW" ( BYVAL hFindStream AS QUAD , BYREF lpFindStreamData AS ANY ) AS LONG
MACRO FindNextStream = FindNextStreamW
'#endif // (_WIN32_WINNT >= 0x0501)
'#if _WIN32_WINNT >= 0x0600
#IF %WINVER >= &H0600
DECLARE FUNCTION FindFirstFileNameW LIB "kernel32.dll" ALIAS "FindFirstFileNameW" ( BYREF lpFileName AS WSTRINGZ , BYVAL dwFlags AS QUAD , BYREF StringLength AS QUAD , BYREF LinkName AS WSTRINGZ ) AS QUAD
MACRO FindFirstFileName = FindFirstFileNameW
DECLARE FUNCTION FindNextFileNameW LIB "kernel32.dll" ALIAS "FindNextFileNameW" ( BYVAL hFindStream AS QUAD , BYREF StringLength AS QUAD , BYREF LinkName AS WSTRINGZ ) AS LONG
MACRO FindNextFileName = FindNextFileNameW
DECLARE FUNCTION FindFirstFileNameTransactedW LIB "kernel32.dll" ALIAS "FindFirstFileNameTransactedW" ( BYREF lpFileName AS WSTRINGZ , BYVAL dwFlags AS QUAD , BYREF StringLength AS QUAD , BYREF LinkName AS WSTRINGZ , BYVAL hTransaction AS QUAD ) AS QUAD
MACRO FindFirstFileNameTransacted = FindFirstFileNameTransactedW
#ENDIF
DECLARE FUNCTION CreateNamedPipeA LIB "kernel32.dll" ALIAS "CreateNamedPipeA" ( BYREF lpName AS ASCIIZ , BYVAL dwOpenMode AS QUAD , BYVAL dwPipeMode AS QUAD , BYVAL nMaxInstances AS QUAD , BYVAL nOutBufferSize AS QUAD , BYVAL nInBufferSize AS QUAD , BYVAL nDefaultTimeOut AS QUAD , BYREF lpSecurityAttributes AS SECURITY_ATTRIBUTES ) AS QUAD
DECLARE FUNCTION CreateNamedPipeW LIB "kernel32.dll" ALIAS "CreateNamedPipeW" ( BYREF lpName AS WSTRINGZ
 , BYVAL dwOpenMode AS DWORD
 , BYVAL dwPipeMode AS DWORD
 , BYVAL nMaxInstances AS DWORD
 , BYVAL nOutBufferSize AS DWORD
 , BYVAL nInBufferSize AS DWORD
 , BYVAL nDefaultTimeOut AS DWORD
 , BYREF lpSecurityAttributes AS SECURITY_ATTRIBUTES
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO CreateNamedPipe = CreateNamedPipeW
#ELSE
 MACRO CreateNamedPipe = CreateNamedPipeA
#ENDIF
DECLARE FUNCTION GetNamedPipeHandleStateA LIB "kernel32.dll" ALIAS "GetNamedPipeHandleStateA" ( BYVAL hNamedPipe AS QUAD , BYREF lpState AS QUAD , BYREF lpCurInstances AS QUAD , BYREF lpMaxCollectionCount AS QUAD , BYREF lpCollectDataTimeout AS QUAD , BYREF lpUserName AS ASCIIZ , BYVAL nMaxUserNameSize AS QUAD ) AS LONG
DECLARE FUNCTION GetNamedPipeHandleStateW LIB "kernel32.dll" ALIAS "GetNamedPipeHandleStateW" ( BYVAL hNamedPipe AS QUAD
 , BYREF lpState AS DWORD
 , BYREF lpCurInstances AS DWORD
 , BYREF lpMaxCollectionCount AS DWORD
 , BYREF lpCollectDataTimeout AS DWORD
 , BYREF lpUserName AS WSTRINGZ
 , BYVAL nMaxUserNameSize AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO GetNamedPipeHandleState = GetNamedPipeHandleStateW
#ELSE
 MACRO GetNamedPipeHandleState = GetNamedPipeHandleStateA
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION CallNamedPipeA LIB "Kernel32.dll" ALIAS "CallNamedPipeA" (lpNamedPipeName AS ASCIIZ, BYVAL lpInBuffer AS QUAD, BYVAL nInBufferSize AS QUAD, BYVAL lpOutBuffer AS QUAD, BYVAL nOutBufferSize AS QUAD, lpBytesRead AS QUAD, BYVAL nTimeOut AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION CallNamedPipeA LIB "kernel32.dll" ALIAS "CallNamedPipeA" ( BYREF lpNamedPipeName AS ASCIIZ , BYREF lpInBuffer AS ANY , BYVAL nInBufferSize AS QUAD , BYREF lpOutBuffer AS ANY , BYVAL nOutBufferSize AS QUAD , BYREF lpBytesRead AS QUAD , BYVAL nTimeOut AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION CallNamedPipeW LIB "Kernel32.dll" ALIAS "CallNamedPipeW" (lpNamedPipeName AS WSTRINGZ, BYVAL lpInBuffer AS QUAD, BYVAL nInBufferSize AS QUAD, BYVAL lpOutBuffer AS QUAD, BYVAL nOutBufferSize AS QUAD, lpBytesRead AS QUAD, BYVAL nTimeOut AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION CallNamedPipeW LIB "kernel32.dll" ALIAS "CallNamedPipeW" ( BYREF lpNamedPipeName AS WSTRINGZ , BYREF lpInBuffer AS ANY , BYVAL nInBufferSize AS QUAD , BYREF lpOutBuffer AS ANY , BYVAL nOutBufferSize AS QUAD , BYREF lpBytesRead AS QUAD , BYVAL nTimeOut AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%UNICODE)
 MACRO CallNamedPipe = CallNamedPipeW
#ELSE
 MACRO CallNamedPipe = CallNamedPipeA
#ENDIF
DECLARE FUNCTION WaitNamedPipeA LIB "kernel32.dll" ALIAS "WaitNamedPipeA" ( BYREF lpNamedPipeName AS ASCIIZ , BYVAL nTimeOut AS QUAD ) AS LONG
DECLARE FUNCTION WaitNamedPipeW LIB "kernel32.dll" ALIAS "WaitNamedPipeW" ( BYREF lpNamedPipeName AS WSTRINGZ
 , BYVAL nTimeOut AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO WaitNamedPipe = WaitNamedPipeW
#ELSE
 MACRO WaitNamedPipe = WaitNamedPipeA
#ENDIF
' enum PIPE_ATTRIBUTE_TYPE
%EQUATE `PipeAttribute = 0
%EQUATE `PipeConnectionAttribute = 1
%EQUATE `PipeHandleAttribute = 2
' // Undocumented
DECLARE FUNCTION GetNamedPipeAttribute LIB "kernel32.dll" ALIAS "GetNamedPipeAttribute" ( BYVAL Pipe AS QUAD , BYVAL AttributeType AS QUAD , BYREF AttributeName AS ASCIIZ , BYREF AttributeValue AS ANY , BYREF AttributeValueLength AS QUAD ) AS LONG
' // Undocumented
DECLARE FUNCTION SetNamedPipeAttribute LIB "kernel32.dll" ALIAS "SetNamedPipeAttribute" ( BYVAL Pipe AS QUAD , BYVAL AttributeType AS QUAD , BYREF AttributeName AS ASCIIZ , BYREF AttributeValue AS ANY , BYVAL AttributeValueLength AS QUAD ) AS LONG
DECLARE FUNCTION GetNamedPipeClientComputerNameA LIB "kernel32.dll" ALIAS "GetNamedPipeClientComputerNameA" ( BYVAL Pipe AS QUAD
 , BYREF ClientComputerName AS ASCIIZ
 , BYVAL ClientComputerNameLength AS DWORD
 ) AS LONG
DECLARE FUNCTION GetNamedPipeClientComputerNameW LIB "kernel32.dll" ALIAS "GetNamedPipeClientComputerNameW" ( BYVAL Pipe AS DWORD
 , BYREF ClientComputerName AS WSTRINGZ
 , BYVAL ClientComputerNameLength AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO GetNamedPipeClientComputerName = GetNamedPipeClientComputerNameW
#ELSE
 MACRO GetNamedPipeClientComputerName = GetNamedPipeClientComputerNameA
#ENDIF
DECLARE FUNCTION GetNamedPipeClientProcessId LIB "kernel32.dll" ALIAS "GetNamedPipeClientProcessId" ( BYVAL Pipe AS QUAD , BYREF ClientProcessId AS QUAD ) AS LONG
DECLARE FUNCTION GetNamedPipeClientSessionId LIB "kernel32.dll" ALIAS "GetNamedPipeClientSessionId" ( BYVAL Pipe AS QUAD
 , BYREF ClientSessionId AS DWORD
 ) AS LONG
DECLARE FUNCTION GetNamedPipeServerProcessId LIB "kernel32.dll" ALIAS "GetNamedPipeServerProcessId" ( BYVAL Pipe AS DWORD
 , BYREF ServerProcessId AS DWORD
 ) AS LONG
DECLARE FUNCTION GetNamedPipeServerSessionId LIB "kernel32.dll" ALIAS "GetNamedPipeServerSessionId" ( BYVAL Pipe AS DWORD
 , BYREF ServerSessionId AS DWORD
 ) AS LONG
DECLARE FUNCTION SetVolumeLabelA LIB "kernel32.dll" ALIAS "SetVolumeLabelA" ( BYREF lpRootPathName AS ASCIIZ
 , BYREF lpVolumeName AS ASCIIZ
 ) AS LONG
DECLARE FUNCTION SetVolumeLabelW LIB "kernel32.dll" ALIAS "SetVolumeLabelW" ( BYREF lpRootPathName AS WSTRINGZ
 , BYREF lpVolumeName AS WSTRINGZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SetVolumeLabel = SetVolumeLabelW
#ELSE
 MACRO SetVolumeLabel = SetVolumeLabelA
#ENDIF
DECLARE SUB SetFileApisToOEM LIB "kernel32.dll" ALIAS "SetFileApisToOEM" () ' void
DECLARE SUB SetFileApisToANSI LIB "kernel32.dll" ALIAS "SetFileApisToANSI" () ' void
DECLARE FUNCTION AreFileApisANSI LIB "kenel32.dll" ALIAS "AreFileApisANSI" ( ) AS LONG
DECLARE FUNCTION GetVolumeInformationA LIB "kernel32.dll" ALIAS "GetVolumeInformationA" ( BYREF lpRootPathName AS ASCIIZ , BYREF lpVolumeNameBuffer AS ASCIIZ
 , BYVAL nVolumeNameSize AS DWORD
 , BYREF lpVolumeSerialNumber AS DWORD
 , BYREF lpMaximumComponentLength AS DWORD
 , BYREF lpFileSystemFlags AS DWORD
 , BYREF lpFileSystemNameBuffer AS ASCIIZ
 , BYVAL nFileSystemNameSize AS DWORD
 ) AS LONG
DECLARE FUNCTION GetVolumeInformationW LIB "kernel32.dll" ALIAS "GetVolumeInformationW" ( BYREF lpRootPathName AS WSTRINGZ
 , BYREF lpVolumeNameBuffer AS WSTRINGZ
 , BYVAL nVolumeNameSize AS DWORD
 , BYREF lpVolumeSerialNumber AS DWORD
 , BYREF lpMaximumComponentLength AS DWORD
 , BYREF lpFileSystemFlags AS DWORD
 , BYREF lpFileSystemNameBuffer AS WSTRINGZ
 , BYVAL nFileSystemNameSize AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO GetVolumeInformation = GetVolumeInformationW
#ELSE
 MACRO GetVolumeInformation = GetVolumeInformationA
#ENDIF
'#if(_WIN32_WINNT >= 0x0600)
#IF %WINVER >= &H0600
DECLARE FUNCTION GetVolumeInformationByHandleW LIB "kernel32.dll" ALIAS "GetVolumeInformationByHandleW" ( BYVAL hFile AS QUAD , BYREF lpVolumeNameBuffer AS WSTRINGZ , BYVAL nVolumeNameSize AS QUAD , BYREF lpVolumeSerialNumber AS QUAD , BYREF lpMaximumComponentLength AS QUAD , BYREF lpFileSystemFlags AS QUAD , BYREF lpFileSystemNameBuffer AS WSTRINGZ , BYVAL nFileSystemNameSize AS QUAD ) AS LONG
MACRO GetVolumeInformationByHandle = GetVolumeInformationByHandleW
#ENDIF ' /* _WIN32_WINNT >= 0x0600 */
DECLARE FUNCTION CancelSynchronousIo LIB "kernel32.dll" ALIAS "CancelSynchronousIo" ( BYVAL hThread AS QUAD ) AS LONG
DECLARE FUNCTION CancelIoEx LIB "kernel32.dll" ALIAS "CancelIoEx" ( BYVAL hFile AS QUAD
 , BYREF lpOverlapped AS OVERLAPPED
 ) AS LONG
DECLARE FUNCTION CancelIo LIB "kernel32.dll" ALIAS "CancelIo" ( BYVAL hFile AS DWORD
 ) AS LONG
DECLARE FUNCTION SetFileBandwidthReservation LIB "kernel32.dll" ALIAS "SetFileBandwidthReservation" ( BYVAL hFile AS DWORD
 , BYVAL nPeriodMilliseconds AS DWORD
 , BYVAL nBytesPerPeriod AS DWORD
 , BYVAL bDiscardable AS LONG
 , BYREF lpTransferSize AS DWORD
 , BYREF lpNumOutstandingRequests AS DWORD
 ) AS LONG
DECLARE FUNCTION GetFileBandwidthReservation LIB "kernel32.dll" ALIAS "GetFileBandwidthReservation" ( BYVAL hFile AS DWORD
 , BYREF lpPeriodMilliseconds AS DWORD
 , BYREF lpBytesPerPeriod AS DWORD
 , BYREF pDiscardable AS DWORD
 , BYREF lpTransferSize AS DWORD
 , BYREF lpNumOutstandingRequests AS DWORD
 ) AS LONG
'//
'// Event logging APIs
'//
DECLARE FUNCTION ClearEventLogA LIB "advapi32.dll" ALIAS "ClearEventLogA" ( BYVAL hEventLog AS QUAD , BYREF lpBackupFileName AS ASCIIZ ) AS LONG
DECLARE FUNCTION ClearEventLogW LIB "advapi32.dll" ALIAS "ClearEventLogW" ( BYVAL hEventLog AS QUAD
 , BYREF lpBackupFileName AS WSTRINGZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO ClearEventLog = ClearEventLogW
#ELSE
 MACRO ClearEventLog = ClearEventLogA
#ENDIF
DECLARE FUNCTION BackupEventLogA LIB "advapi32.dll" ALIAS "BackupEventLogA" ( BYVAL hEventLog AS QUAD , BYREF lpBackupFileName AS ASCIIZ ) AS LONG
DECLARE FUNCTION BackupEventLogW LIB "advapi32.dll" ALIAS "BackupEventLogW" ( BYVAL hEventLog AS QUAD
 , BYREF lpBackupFileName AS WSTRINGZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO BackupEventLog = BackupEventLogW
#ELSE
 MACRO BackupEventLog = BackupEventLogA
#ENDIF
DECLARE FUNCTION CloseEventLog LIB "advapi32.dll" ALIAS "CloseEventLog" ( BYVAL hEventLog AS QUAD ) AS LONG
DECLARE FUNCTION DeregisterEventSource LIB "advapi32.dll" ALIAS "DeregisterEventSource" ( BYVAL hEventLog AS QUAD
 ) AS LONG
DECLARE FUNCTION NotifyChangeEventLog LIB "advapi32.dll" ALIAS "NotifyChangeEventLog" ( BYVAL hEventLog AS DWORD
 , BYVAL hEvent AS DWORD
 ) AS LONG
DECLARE FUNCTION GetNumberOfEventLogRecords LIB "advapi32.dll" ALIAS "GetNumberOfEventLogRecords" ( BYVAL hEventLog AS DWORD
 , BYREF NumberOfRecords AS DWORD
 ) AS LONG
DECLARE FUNCTION GetOldestEventLogRecord LIB "advapi32.dll" ALIAS "GetOldestEventLogRecord" ( BYVAL hEventLog AS DWORD
 , BYREF OldestRecord AS DWORD
 ) AS LONG
DECLARE FUNCTION OpenEventLogA LIB "advapi32.dll" ALIAS "OpenEventLogA" ( BYREF lpUNCServerName AS ASCIIZ
 , BYREF lpSourceName AS ASCIIZ
 ) AS DWORD
DECLARE FUNCTION OpenEventLogW LIB "advapi32.dll" ALIAS "OpenEventLogW" ( BYREF lpUNCServerName AS WSTRINGZ
 , BYREF lpSourceName AS WSTRINGZ
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO OpenEventLog = OpenEventLogW
#ELSE
 MACRO OpenEventLog = OpenEventLogA
#ENDIF
DECLARE FUNCTION RegisterEventSourceA LIB "advapi32.dll" ALIAS "RegisterEventSourceA" ( BYREF lpUNCServerName AS ASCIIZ , BYREF lpSourceName AS ASCIIZ ) AS QUAD
DECLARE FUNCTION RegisterEventSourceW LIB "advapi32.dll" ALIAS "RegisterEventSourceW" ( BYREF lpUNCServerName AS WSTRINGZ
 , BYREF lpSourceName AS WSTRINGZ
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO RegisterEventSource = RegisterEventSourceW
#ELSE
 MACRO RegisterEventSource = RegisterEventSourceA
#ENDIF
DECLARE FUNCTION OpenBackupEventLogA LIB "advapi32.dll" ALIAS "OpenBackupEventLogA" ( BYREF lpUNCServerName AS ASCIIZ , BYREF lpFileName AS ASCIIZ ) AS QUAD
DECLARE FUNCTION OpenBackupEventLogW LIB "advapi32.dll" ALIAS "OpenBackupEventLogW" ( BYREF lpUNCServerName AS WSTRINGZ
 , BYREF lpFileName AS WSTRINGZ
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO OpenBackupEventLog = OpenBackupEventLogW
#ELSE
 MACRO OpenBackupEventLog = OpenBackupEventLogA
#ENDIF
DECLARE FUNCTION ReadEventLogA LIB "advapi32.dll" ALIAS "ReadEventLogA" ( BYVAL hEventLog AS QUAD , BYVAL dwReadFlags AS QUAD , BYVAL dwRecordOffset AS QUAD , BYREF lpBuffer AS EVENTLOGRECORD , BYVAL nNumberOfBytesToRead AS QUAD , BYREF pnBytesRead AS QUAD , BYREF pnMinNumberOfBytesNeeded AS QUAD ) AS LONG
DECLARE FUNCTION ReadEventLogW LIB "advapi32.dll" ALIAS "ReadEventLogW" ( BYVAL hEventLog AS QUAD
 , BYVAL dwReadFlags AS DWORD
 , BYVAL dwRecordOffset AS DWORD
 , BYREF lpBuffer AS EVENTLOGRECORD
 , BYVAL nNumberOfBytesToRead AS DWORD
 , BYREF pnBytesRead AS DWORD
 , BYREF pnMinNumberOfBytesNeeded AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO ReadEventLog = ReadEventLogW
#ELSE
 MACRO ReadEventLog = ReadEventLogA
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION ReportEventA LIB "AdvApi32.dll" ALIAS "ReportEventA" (BYVAL hEventLog AS QUAD, BYVAL wType AS WORD, BYVAL wCategory AS WORD, BYVAL dwEventId AS QUAD, lpUserSid AS SID, BYVAL wNumStrings AS WORD, BYVAL dwDataSize AS QUAD, BYVAL lpStrings AS QUAD, BYVAL lpRawData AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION ReportEventA LIB "advapi32.dll" ALIAS "ReportEventA" ( BYVAL hEventLog AS QUAD , BYVAL wType AS WORD , BYVAL wCategory AS WORD , BYVAL dwEventID AS QUAD , BYVAL lpUserSid AS SID PTR , BYVAL wNumStrings AS WORD , BYVAL dwDataSize AS QUAD , BYREF lpStrings AS ASCIIZ , BYREF lpRawData AS ANY ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION ReportEventW LIB "AdvApi32.dll" ALIAS "ReportEventW" (BYVAL hEventLog AS QUAD, BYVAL wType AS WORD, BYVAL wCategory AS WORD, BYVAL dwEventId AS QUAD, lpUserSid AS SID, BYVAL wNumStrings AS WORD, BYVAL dwDataSize AS QUAD, BYVAL lpStrings AS QUAD, BYVAL lpRawData AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION ReportEventW LIB "advapi32.dll" ALIAS "ReportEventW" ( BYVAL hEventLog AS QUAD , BYVAL wType AS WORD , BYVAL wCategory AS WORD , BYVAL dwEventID AS QUAD , BYVAL lpUserSid AS SID PTR , BYVAL wNumStrings AS WORD , BYVAL dwDataSize AS QUAD , BYREF lpStrings AS WSTRINGZ , BYREF lpRawData AS ANY ) AS LONG
#ENDIF
#IF %DEF(%UNICODE)
 MACRO ReportEvent = ReportEventW
#ELSE
 MACRO ReportEvent = ReportEventA
#ENDIF
%EQUATE `EVENTLOG_FULL_INFO = 0
' // Size = 4 bytes
TYPE EVENTLOG_FULL_INFORMATION DWORD
 dwFull AS DWORD ' DWORD dwFull
END TYPE
DECLARE FUNCTION GetEventLogInformation LIB "kernel32.dll" ALIAS "GetEventLogInformation" ( BYVAL hEventLog AS QUAD , BYVAL dwInfoLevel AS QUAD , BYREF lpBuffer AS ANY , BYVAL cbBufSize AS QUAD , BYREF pcbBytesNeeded AS QUAD ) AS LONG
'//
'//
'// Security APIs
'//
DECLARE FUNCTION DuplicateToken LIB "advapi32.dll" ALIAS "DuplicateToken" ( BYVAL ExistingTokenHandle AS QUAD , BYREF ImpersonationLevel AS LONG , BYREF DuplicateTokenHandle AS QUAD ) AS LONG
DECLARE FUNCTION GetKernelObjectSecurity LIB "advapi32.dll" ALIAS "GetKernelObjectSecurity" ( BYVAL Handle AS QUAD
 , BYVAL RequestedInformation AS SECURITY_INFORMATION
 , BYREF pSecurityDescriptor AS SECURITY_DESCRIPTOR
 , BYVAL nLength AS DWORD
 , BYREF lpnLengthNeeded AS DWORD
 ) AS LONG
DECLARE FUNCTION ImpersonateNamedPipeClient LIB "advapi32.dll" ALIAS "ImpersonateNamedPipeClient" ( BYVAL hNamedPipe AS DWORD
 ) AS LONG
DECLARE FUNCTION ImpersonateSelf LIB "advapi32.dll" ALIAS "ImpersonateSelf" ( BYVAL ImpersonationLevel AS LONG
 ) AS LONG
DECLARE FUNCTION RevertToSelf LIB "advapi32.dll" ALIAS "RevertToSelf" ( ) AS LONG
DECLARE FUNCTION SetThreadToken LIB "advapi32.dll" ALIAS "SetThreadToken" ( BYREF Thread AS DWORD
 , BYVAL Token AS DWORD
 ) AS LONG
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION AccessCheck LIB "AdvApi32.dll" ALIAS "AccessCheck" (pSecurityDescriptor AS SECURITY_DESCRIPTOR, BYVAL ClientToken AS QUAD, BYVAL DesiredAccess AS QUAD, GenericMapping AS GENERIC_MAPPING, BYVAL PrivilegeSet AS QUAD, PrivilegeSetLength AS QUAD, GrantedAccess AS QUAD, AccessStatus AS LONG) AS LONG
#ELSE
DECLARE FUNCTION AccessCheck LIB "advapi32.dll" ALIAS "AccessCheck" ( BYREF pSecurityDescriptor AS SECURITY_DESCRIPTOR , BYVAL ClientToken AS QUAD , BYVAL DesiredAccess AS QUAD , BYREF GenericMapping AS GENERIC_MAPPING , BYREF PrivilegeSet AS PRIVILEGE_SET , BYREF PrivilegeSetLength AS QUAD , BYREF GrantedAccess AS QUAD , BYREF AccessStatus AS LONG ) AS LONG
#ENDIF
'#if(_WIN32_WINNT >= 0x0500)
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION AccessCheckByType LIB "AdvApi32.dll" ALIAS "AccessCheckByType" (pSecurityDescriptor AS SECURITY_DESCRIPTOR, PrincipalSelfSid AS SID, BYVAL ClientToken AS QUAD, BYVAL DesiredAccess AS QUAD, BYVAL ObjectTypeList AS OBJECT_TYPE_LIST PTR, BYVAL ObjectTypeListLength AS QUAD, GenericMapping AS GENERIC_MAPPING, BYVAL PrivilegeSet AS QUAD, PrivilegeSetLength AS QUAD, GrantedAccess AS QUAD, AccessStatus AS LONG) AS LONG
#ELSE
DECLARE FUNCTION AccessCheckByType LIB "advapi32.dll" ALIAS "AccessCheckByType" ( BYREF pSecurityDescriptor AS SECURITY_DESCRIPTOR , BYVAL PrincipalSelfSid AS SID PTR , BYVAL ClientToken AS SID PTR , BYVAL DesiredAccess AS QUAD , BYREF ObjectTypeList AS OBJECT_TYPE_LIST , BYVAL ObjectTypeListLength AS QUAD , BYREF GenericMapping AS GENERIC_MAPPING , BYREF PrivilegeSet AS PRIVILEGE_SET , BYREF PrivilegeSetLength AS QUAD , BYREF GrantedAccess AS QUAD , BYREF AccessStatus AS LONG ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION AccessCheckByTypeResultList LIB "AdvApi32.dll" ALIAS "AccessCheckByTypeResultList" (pSecurityDescriptor AS SECURITY_DESCRIPTOR, PrincipalSelfSid AS SID, BYVAL ClientToken AS QUAD, BYVAL DesiredAccess AS QUAD, BYVAL ObjectTypeList AS OBJECT_TYPE_LIST PTR, BYVAL ObjectTypeListLength AS QUAD, GenericMapping AS GENERIC_MAPPING, BYVAL PrivilegeSet AS QUAD, PrivilegeSetLength AS QUAD, GrantedAccess AS QUAD, AccessStatusList AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION AccessCheckByTypeResultList LIB "advapi32.dll" ALIAS "AccessCheckByTypeResultList" ( BYREF pSecurityDescriptor AS SECURITY_DESCRIPTOR , BYVAL PrincipalSelfSid AS SID PTR , BYVAL ClientToken AS QUAD , BYVAL DesiredAccess AS QUAD , BYREF ObjectTypeList AS OBJECT_TYPE_LIST , BYVAL ObjectTypeListLength AS QUAD , BYREF GenericMapping AS GENERIC_MAPPING , BYREF PrivilegeSet AS PRIVILEGE_SET , BYREF PrivilegeSetLength AS QUAD , BYREF GrantedAccessList AS QUAD , BYREF AccessStatusList AS QUAD ) AS LONG
#ENDIF
'#endif /* _WIN32_WINNT >= 0x0500 */
DECLARE FUNCTION OpenProcessToken LIB "advapi32.dll" ALIAS "OpenProcessToken" ( BYVAL ProcessHandle AS QUAD , BYVAL DesiredAccess AS QUAD , BYREF TokenHandle AS QUAD ) AS LONG
DECLARE FUNCTION OpenThreadToken LIB "advapi32.dll" ALIAS "OpenThreadToken" ( BYVAL ThreadHandle AS QUAD
 , BYVAL DesiredAccess AS DWORD
 , BYVAL OpenAsSelf AS LONG
 , BYREF TokenHandle AS DWORD
 ) AS LONG
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION GetTokenInformation LIB "AdvApi32.dll" ALIAS "GetTokenInformation" (BYVAL TokenHandle AS QUAD, BYVAL TokenInformationClass AS LONG, BYVAL TokenInformation AS QUAD, BYVAL TokenInformationLength AS QUAD, ReturnLength AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION GetTokenInformation LIB "advapi32.dll" ALIAS "GetTokenInformation" ( BYVAL TokenHandle AS QUAD , BYVAL TokenInformationClass AS LONG , BYREF TokenInformation AS ANY , BYVAL TokenInformationLength AS QUAD , BYREF ReturnLength AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION SetTokenInformation LIB "AdvApi32.dll" ALIAS "SetTokenInformation" (BYVAL TokenHandle AS QUAD, BYVAL TokenInformationClass AS LONG, BYVAL TokenInformation AS QUAD, BYVAL TokenInformationLength AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION SetTokenInformation LIB "advapi32.dll" ALIAS "SetTokenInformation" ( BYVAL TokenHandle AS QUAD , BYVAL TokenInformationClass AS LONG , BYREF TokenInformation AS ANY , BYVAL TokenInformationLength AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION AdjustTokenPrivileges LIB "AdvApi32.dll" ALIAS "AdjustTokenPrivileges" (BYVAL TokenHandle AS QUAD, BYVAL DisableAllPrivileges AS LONG, BYVAL NewState AS QUAD, BYVAL BufferLength AS QUAD, BYVAL PreviousState AS QUAD, ReturnLength AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION AdjustTokenPrivileges LIB "advapi32.dll" ALIAS "AdjustTokenPrivileges" ( BYVAL TokenHandle AS QUAD , BYVAL DisableAllPrivileges AS LONG , BYREF NewState AS TOKEN_PRIVILEGES , BYVAL BufferLength AS QUAD , BYREF PreviousState AS TOKEN_PRIVILEGES , BYREF ReturnLength AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION AdjustTokenGroups LIB "AdvApi32.dll" ALIAS "AdjustTokenGroups" (BYVAL TokenHandle AS QUAD, BYVAL ResetToDefault AS LONG, BYVAL NewState AS QUAD, BYVAL BufferLength AS QUAD, BYVAL PreviousState AS QUAD, ReturnLength AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION AdjustTokenGroups LIB "advapi32.dll" ALIAS "AdjustTokenGroups" ( BYVAL TokenHandle AS QUAD , BYVAL ResetToDefault AS LONG , BYREF NewState AS TOKEN_GROUPS , BYVAL BufferLength AS QUAD , BYREF PreviousState AS TOKEN_GROUPS , BYREF ReturnLength AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION PrivilegeCheck LIB "AdvApi32.dll" ALIAS "PrivilegeCheck" (BYVAL ClientToken AS LONG, BYVAL RequiredPrivileges AS QUAD, pfResult AS LONG) AS LONG
#ELSE
DECLARE FUNCTION PrivilegeCheck LIB "advapi32.dll" ALIAS "PrivilegeCheck" ( BYVAL ClientToken AS LONG , BYREF RequiredPrivileges AS PRIVILEGE_SET , BYREF pfResult AS LONG ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION AccessCheckAndAuditAlarmA LIB "AdvApi32.dll" ALIAS "AccessCheckAndAuditAlarmA" (SubsystemName AS ASCIIZ, HandleId AS QUAD, ObjectTypeName AS ASCIIZ, ObjectName AS ASCIIZ, SecurityDescriptor AS SECURITY_DESCRIPTOR, BYVAL DesiredAccess AS QUAD, GenericMapping AS GENERIC_MAPPING, BYVAL ObjectCreation AS LONG, GrantedAccess AS QUAD, BYVAL AccessStatus AS LONG, BYVAL pfGenerateOnClose AS LONG) AS LONG
#ELSE
DECLARE FUNCTION AccessCheckAndAuditAlarmA LIB "advapi32.dll" ALIAS "AccessCheckAndAuditAlarmA" ( BYREF SubsystemName AS ASCIIZ , BYVAL HandleId AS QUAD , BYREF ObjectTypeName AS ASCIIZ , BYREF ObjectName AS ASCIIZ , BYREF SecurityDescriptor AS SECURITY_DESCRIPTOR , BYVAL DesiredAccess AS QUAD , BYREF GenericMapping AS GENERIC_MAPPING , BYVAL ObjectCreation AS LONG , BYREF GrantedAccess AS QUAD , BYREF AccessStatus AS LONG , BYREF pfGenerateOnClose AS LONG ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION AccessCheckAndAuditAlarmW LIB "AdvApi32.dll" ALIAS "AccessCheckAndAuditAlarmW" (SubsystemName AS WSTRINGZ, HandleId AS QUAD, ObjectTypeName AS WSTRINGZ, ObjectName AS WSTRINGZ, SecurityDescriptor AS SECURITY_DESCRIPTOR, BYVAL DesiredAccess AS QUAD, GenericMapping AS GENERIC_MAPPING, BYVAL ObjectCreation AS LONG, GrantedAccess AS QUAD, BYVAL AccessStatus AS LONG, BYVAL pfGenerateOnClose AS LONG) AS LONG
#ELSE
DECLARE FUNCTION AccessCheckAndAuditAlarmW LIB "advapi32.dll" ALIAS "AccessCheckAndAuditAlarmW" ( BYREF SubsystemName AS WSTRINGZ , BYVAL HandleId AS QUAD , BYREF ObjectTypeName AS WSTRINGZ , BYREF ObjectName AS WSTRINGZ , BYREF SecurityDescriptor AS SECURITY_DESCRIPTOR , BYVAL DesiredAccess AS QUAD , BYREF GenericMapping AS GENERIC_MAPPING , BYVAL ObjectCreation AS LONG , BYREF GrantedAccess AS QUAD , BYREF AccessStatus AS LONG , BYREF pfGenerateOnClose AS LONG ) AS LONG
#ENDIF
#IF %DEF(%UNICODE)
 MACRO AccessCheckAndAuditAlarm = AccessCheckAndAuditAlarmW
#ELSE
 MACRO AccessCheckAndAuditAlarm = AccessCheckAndAuditAlarmA
#ENDIF
'#if(_WIN32_WINNT >= 0x0500)
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION AccessCheckByTypeAndAuditAlarmA LIB "AdvApi32.dll" ALIAS "AccessCheckByTypeAndAuditAlarmA" (SubsystemName AS ASCIIZ, HandleId AS QUAD, ObjectTypeName AS ASCIIZ, ObjectName AS ASCIIZ, SecurityDescriptor AS SECURITY_DESCRIPTOR, PrincipalSelfSid AS SID, BYVAL DesiredAccess AS QUAD, BYVAL AuditType AS LONG, BYVAL Flags AS QUAD, ObjectTypeList AS OBJECT_TYPE_LIST, BYVAL ObjectTypeListLength AS QUAD, GenericMapping AS GENERIC_MAPPING, BYVAL ObjectCreation AS LONG, GrantedAccess AS QUAD, AccessStatus AS LONG, pfGenerateOnClose AS LONG) AS LONG
#ELSE
DECLARE FUNCTION AccessCheckByTypeAndAuditAlarmA LIB "advapi32.dll" ALIAS "AccessCheckByTypeAndAuditAlarmA" ( BYREF SubsystemName AS ASCIIZ , BYVAL HandleId AS QUAD , BYREF ObjectTypeName AS ASCIIZ , BYREF ObjectName AS ASCIIZ , BYREF SecurityDescriptor AS SECURITY_DESCRIPTOR , BYVAL PrincipalSelfSid AS SID PTR , BYVAL DesiredAccess AS QUAD , BYVAL AuditType AS LONG , BYVAL Flags AS QUAD , BYREF ObjectTypeList AS OBJECT_TYPE_LIST , BYVAL ObjectTypeListLength AS QUAD , BYREF GenericMapping AS GENERIC_MAPPING , BYVAL ObjectCreation AS LONG , BYREF AccessStatus AS QUAD , BYREF AccessStatus AS LONG , BYREF pfGenerateOnClose AS LONG ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION AccessCheckByTypeAndAuditAlarmW LIB "AdvApi32.dll" ALIAS "AccessCheckByTypeAndAuditAlarmW" (SubsystemName AS WSTRINGZ, HandleId AS QUAD, ObjectTypeName AS WSTRINGZ, ObjectName AS WSTRINGZ, SecurityDescriptor AS SECURITY_DESCRIPTOR, PrincipalSelfSid AS SID, BYVAL DesiredAccess AS QUAD, BYVAL AuditType AS LONG, BYVAL Flags AS QUAD, ObjectTypeList AS OBJECT_TYPE_LIST, BYVAL ObjectTypeListLength AS QUAD, GenericMapping AS GENERIC_MAPPING, BYVAL ObjectCreation AS LONG, GrantedAccess AS QUAD, AccessStatus AS LONG, pfGenerateOnClose AS LONG) AS LONG
#ELSE
DECLARE FUNCTION AccessCheckByTypeAndAuditAlarmW LIB "advapi32.dll" ALIAS "AccessCheckByTypeAndAuditAlarmW" ( BYREF SubsystemName AS WSTRINGZ , BYVAL HandleId AS QUAD , BYREF ObjectTypeName AS WSTRINGZ , BYREF ObjectName AS WSTRINGZ , BYREF SecurityDescriptor AS SECURITY_DESCRIPTOR , BYVAL PrincipalSelfSid AS SID PTR , BYVAL DesiredAccess AS QUAD , BYVAL AuditType AS LONG , BYVAL Flags AS QUAD , BYREF ObjectTypeList AS OBJECT_TYPE_LIST , BYVAL ObjectTypeListLength AS QUAD , BYREF GenericMapping AS GENERIC_MAPPING , BYVAL ObjectCreation AS LONG , BYREF AccessStatus AS QUAD , BYREF AccessStatus AS LONG , BYREF pfGenerateOnClose AS LONG ) AS LONG
#ENDIF
#IF %DEF(%UNICODE)
 MACRO AccessCheckByTypeAndAuditAlarm = AccessCheckByTypeAndAuditAlarmW
#ELSE
 MACRO AccessCheckByTypeAndAuditAlarm = AccessCheckByTypeAndAuditAlarmW
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION AccessCheckByTypeResultListAndAuditAlarmA LIB "AdvApi32.dll" ALIAS "AccessCheckByTypeResultListAndAuditAlarmA" (SubsystemName AS ASCIIZ, HandleId AS QUAD, ObjectTypeName AS ASCIIZ, ObjectName AS ASCIIZ, SecurityDescriptor AS SECURITY_DESCRIPTOR, PrincipalSelfSid AS SID, BYVAL DesiredAccess AS QUAD, BYVAL AuditType AS LONG, BYVAL Flags AS QUAD, ObjectTypeList AS OBJECT_TYPE_LIST, GenericMapping AS GENERIC_MAPPING, BYVAL ObjectCreation AS LONG, GrantedAccess AS QUAD, AccessStatusList AS QUAD, pfGenerateOnClose AS LONG) AS LONG
#ELSE
DECLARE FUNCTION AccessCheckByTypeResultListAndAuditAlarmA LIB "advapi32.dll" ALIAS "AccessCheckByTypeResultListAndAuditAlarmA" ( BYREF SubsystemName AS ASCIIZ , BYVAL HandleId AS QUAD , BYREF ObjectTypeName AS ASCIIZ , BYREF ObjectName AS ASCIIZ , BYREF SecurityDescriptor AS SECURITY_DESCRIPTOR , BYVAL PrincipalSelfSid AS SID PTR , BYVAL DesiredAccess AS QUAD , BYVAL AuditType AS LONG , BYVAL Flags AS QUAD , BYREF ObjectTypeListLength AS OBJECT_TYPE_LIST , BYREF GenericMapping AS GENERIC_MAPPING , BYVAL ObjectCreation AS LONG , BYREF GrantedAccess AS QUAD , BYREF AccessStatusList AS QUAD , BYREF pfGenerateOnClose AS LONG ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION AccessCheckByTypeResultListAndAuditAlarmW LIB "AdvApi32.dll" ALIAS "AccessCheckByTypeResultListAndAuditAlarmW" (SubsystemName AS WSTRINGZ, HandleId AS QUAD, ObjectTypeName AS WSTRINGZ, ObjectName AS WSTRINGZ, SecurityDescriptor AS SECURITY_DESCRIPTOR, PrincipalSelfSid AS SID, BYVAL DesiredAccess AS QUAD, BYVAL AuditType AS LONG, BYVAL Flags AS QUAD, ObjectTypeList AS OBJECT_TYPE_LIST, GenericMapping AS GENERIC_MAPPING, BYVAL ObjectCreation AS LONG, GrantedAccess AS QUAD, AccessStatusList AS QUAD, pfGenerateOnClose AS LONG) AS LONG
#ELSE
DECLARE FUNCTION AccessCheckByTypeResultListAndAuditAlarmW LIB "advapi32.dll" ALIAS "AccessCheckByTypeResultListAndAuditAlarmW" ( BYREF SubsystemName AS WSTRINGZ , BYVAL HandleId AS QUAD , BYREF ObjectTypeName AS WSTRINGZ , BYREF ObjectName AS WSTRINGZ , BYREF SecurityDescriptor AS SECURITY_DESCRIPTOR , BYVAL PrincipalSelfSid AS SID PTR , BYVAL DesiredAccess AS QUAD , BYVAL AuditType AS LONG , BYVAL Flags AS QUAD , BYREF ObjectTypeListLength AS OBJECT_TYPE_LIST , BYREF GenericMapping AS GENERIC_MAPPING , BYVAL ObjectCreation AS LONG , BYREF GrantedAccess AS QUAD , BYREF AccessStatusList AS QUAD , BYREF pfGenerateOnClose AS LONG ) AS LONG
#ENDIF
#IF %DEF(%UNICODE)
 MACRO AccessCheckByTypeResultListAndAuditAlarm = AccessCheckByTypeResultListAndAuditAlarmW
#ELSE
 MACRO AccessCheckByTypeResultListAndAuditAlarm = AccessCheckByTypeResultListAndAuditAlarmA
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION AccessCheckByTypeResultListAndAuditAlarmByHandleA LIB "AdvApi32.dll" ALIAS "AccessCheckByTypeResultListAndAuditAlarmByHandleA" (SubsystemName AS ASCIIZ, HandleId AS QUAD, BYVAL ClientToken AS QUAD, ObjectTypeName AS ASCIIZ, ObjectName AS ASCIIZ, SecurityDescriptor AS SECURITY_DESCRIPTOR, PrincipalSelfSid AS SID, BYVAL DesiredAccess AS QUAD, BYVAL AuditType AS LONG, BYVAL Flags AS QUAD, ObjectTypeList AS OBJECT_TYPE_LIST, BYVAL ObjectTypeListLength AS QUAD, BYVAL GenericMapping AS GENERIC_MAPPING, BYVAL ObjectCreation AS LONG, GrantedAccess AS QUAD, AccessStatusList AS QUAD, pfGenerateOnClose AS LONG) AS LONG
#ELSE
DECLARE FUNCTION AccessCheckByTypeResultListAndAuditAlarmByHandleA LIB "advapi32.dll" ALIAS "AccessCheckByTypeResultListAndAuditAlarmByHandleA" ( BYREF pfGenerateOnClose AS ASCIIZ , BYVAL HandleId AS QUAD , BYVAL ClientToken AS QUAD , BYREF ObjectTypeName AS ASCIIZ , BYREF ObjectName AS ASCIIZ , BYREF SecurityDescriptor AS SECURITY_DESCRIPTOR , BYVAL PrincipalSelfSid AS SID PTR , BYVAL DesiredAccess AS QUAD , BYVAL AuditType AS LONG , BYVAL Flags AS QUAD , BYREF ObjectTypeList AS OBJECT_TYPE_LIST , BYVAL ObjectTypeListLength AS QUAD , BYREF GenericMapping AS GENERIC_MAPPING , BYVAL ObjectCreation AS LONG , BYREF GrantedAccess AS QUAD , BYREF AccessStatusList AS QUAD , BYREF pfGenerateOnClose AS LONG ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION AccessCheckByTypeResultListAndAuditAlarmByHandleW LIB "AdvApi32.dll" ALIAS "AccessCheckByTypeResultListAndAuditAlarmByHandleW" (SubsystemName AS WSTRINGZ, HandleId AS QUAD, BYVAL ClientToken AS QUAD, ObjectTypeName AS WSTRINGZ, ObjectName AS WSTRINGZ, SecurityDescriptor AS SECURITY_DESCRIPTOR, PrincipalSelfSid AS SID, BYVAL DesiredAccess AS QUAD, BYVAL AuditType AS LONG, BYVAL Flags AS QUAD, ObjectTypeList AS OBJECT_TYPE_LIST, BYVAL ObjectTypeListLength AS QUAD, BYVAL GenericMapping AS GENERIC_MAPPING, BYVAL ObjectCreation AS LONG, GrantedAccess AS QUAD, AccessStatusList AS QUAD, pfGenerateOnClose AS LONG) AS LONG
#ELSE
DECLARE FUNCTION AccessCheckByTypeResultListAndAuditAlarmByHandleW LIB "advapi32.dll" ALIAS "AccessCheckByTypeResultListAndAuditAlarmByHandleW" ( BYREF pfGenerateOnClose AS WSTRINGZ , BYVAL HandleId AS QUAD , BYVAL ClientToken AS QUAD , BYREF ObjectTypeName AS WSTRINGZ , BYREF ObjectName AS WSTRINGZ , BYREF SecurityDescriptor AS SECURITY_DESCRIPTOR , BYVAL PrincipalSelfSid AS SID PTR , BYVAL DesiredAccess AS QUAD , BYVAL AuditType AS LONG , BYVAL Flags AS QUAD , BYREF ObjectTypeList AS OBJECT_TYPE_LIST , BYVAL ObjectTypeListLength AS QUAD , BYREF GenericMapping AS GENERIC_MAPPING , BYVAL ObjectCreation AS LONG , BYREF GrantedAccess AS QUAD , BYREF AccessStatusList AS QUAD , BYREF pfGenerateOnClose AS LONG ) AS LONG
#ENDIF
#IF %DEF(%UNICODE)
 MACRO AccessCheckByTypeResultListAndAuditAlarmByHandle = AccessCheckByTypeResultListAndAuditAlarmByHandleW
#ELSE
 MACRO AccessCheckByTypeResultListAndAuditAlarmByHandle = AccessCheckByTypeResultListAndAuditAlarmByHandleA
#ENDIF
'#endif //(_WIN32_WINNT >= 0x0500)
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION ObjectOpenAuditAlarmA LIB "AdvApi32.dll" ALIAS "ObjectOpenAuditAlarmA" (SubsystemName AS ASCIIZ, HandleId AS QUAD, ObjectTypeName AS ASCIIZ, ObjectName AS ASCIIZ, pSecurityDescriptor AS SECURITY_DESCRIPTOR, BYVAL ClientToken AS LONG, BYVAL DesiredAccess AS LONG, BYVAL GrantedAccess AS LONG, BYVAL Privileges AS QUAD, BYVAL ObjectCreation AS LONG, BYVAL AccessGranted AS LONG, GenerateOnClose AS LONG) AS LONG
#ELSE
DECLARE FUNCTION ObjectOpenAuditAlarmA LIB "kernel32.dll" ALIAS "ObjectOpenAuditAlarmA" ( BYREF SubsystemName AS ASCIIZ , BYVAL HandleId AS QUAD , BYREF ObjectTypeName AS ASCIIZ , BYREF ObjectName AS ASCIIZ , BYREF pSecurityDescriptor AS SECURITY_DESCRIPTOR , BYVAL ClientToken AS QUAD , BYVAL DesiredAccess AS QUAD , BYVAL GrantedAccess AS QUAD , BYREF Privileges AS PRIVILEGE_SET , BYVAL ObjectCreation AS LONG , BYVAL AccessGranted AS LONG , BYREF GenerateOnClose AS LONG ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION ObjectOpenAuditAlarmW LIB "AdvApi32.dll" ALIAS "ObjectOpenAuditAlarmW" (SubsystemName AS WSTRINGZ, HandleId AS QUAD, ObjectTypeName AS WSTRINGZ, ObjectName AS WSTRINGZ, pSecurityDescriptor AS SECURITY_DESCRIPTOR, BYVAL ClientToken AS LONG, BYVAL DesiredAccess AS LONG, BYVAL GrantedAccess AS LONG, BYVAL Privileges AS QUAD, BYVAL ObjectCreation AS LONG, BYVAL AccessGranted AS LONG, GenerateOnClose AS LONG) AS LONG
#ELSE
DECLARE FUNCTION ObjectOpenAuditAlarmW LIB "kernel32.dll" ALIAS "ObjectOpenAuditAlarmW" ( BYREF SubsystemName AS WSTRINGZ , BYVAL HandleId AS QUAD , BYREF ObjectTypeName AS WSTRINGZ , BYREF ObjectName AS WSTRINGZ , BYREF pSecurityDescriptor AS SECURITY_DESCRIPTOR , BYVAL ClientToken AS QUAD , BYVAL DesiredAccess AS QUAD , BYVAL GrantedAccess AS QUAD , BYREF Privileges AS PRIVILEGE_SET , BYVAL ObjectCreation AS LONG , BYVAL AccessGranted AS LONG , BYREF GenerateOnClose AS LONG ) AS LONG
#ENDIF
#IF %DEF(%UNICODE)
 MACRO ObjectOpenAuditAlarm = ObjectOpenAuditAlarmW
#ELSE
 MACRO ObjectOpenAuditAlarm = ObjectOpenAuditAlarmA
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION ObjectPrivilegeAuditAlarmA LIB "AdvApi32.dll" ALIAS "ObjectPrivilegeAuditAlarmA" (SubsystemName AS ASCIIZ, HandleId AS QUAD, BYVAL ClientToken AS QUAD, BYVAL DesiredAccess AS QUAD, BYVAL Privileges AS QUAD, BYVAL AccessGranted AS LONG) AS LONG
#ELSE
DECLARE FUNCTION ObjectPrivilegeAuditAlarmA LIB "advapi32.dll" ALIAS "ObjectPrivilegeAuditAlarmA" ( BYREF SubsystemName AS ASCIIZ , BYVAL HandleId AS QUAD , BYVAL ClientToken AS QUAD , BYVAL DesiredAccess AS QUAD , BYREF Privileges AS PRIVILEGE_SET , BYVAL AccessGranted AS LONG ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION ObjectPrivilegeAuditAlarmW LIB "AdvApi32.dll" ALIAS "ObjectPrivilegeAuditAlarmW" (SubsystemName AS WSTRINGZ, HandleId AS QUAD, BYVAL ClientToken AS QUAD, BYVAL DesiredAccess AS QUAD, BYVAL Privileges AS QUAD, BYVAL AccessGranted AS LONG) AS LONG
#ELSE
DECLARE FUNCTION ObjectPrivilegeAuditAlarmW LIB "advapi32.dll" ALIAS "ObjectPrivilegeAuditAlarmW" ( BYREF SubsystemName AS WSTRINGZ , BYVAL HandleId AS QUAD , BYVAL ClientToken AS QUAD , BYVAL DesiredAccess AS QUAD , BYREF Privileges AS PRIVILEGE_SET , BYVAL AccessGranted AS LONG ) AS LONG
#ENDIF
#IF %DEF(%UNICODE)
 MACRO ObjectPrivilegeAuditAlarm = ObjectPrivilegeAuditAlarmW
#ELSE
 MACRO ObjectPrivilegeAuditAlarm = ObjectPrivilegeAuditAlarmA
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION ObjectCloseAuditAlarmA LIB "AdvApi32.dll" ALIAS "ObjectCloseAuditAlarmA" (SubsystemName AS ASCIIZ, HandleId AS QUAD, BYVAL GenerateOnClose AS LONG) AS LONG
#ELSE
DECLARE FUNCTION ObjectCloseAuditAlarmA LIB "advapi32.dll" ALIAS "ObjectCloseAuditAlarmA" ( BYREF SubsystemName AS ASCIIZ , BYVAL HandleId AS QUAD , BYVAL GenerateOnClose AS LONG ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION ObjectCloseAuditAlarmW LIB "AdvApi32.dll" ALIAS "ObjectCloseAuditAlarmW" (SubsystemName AS WSTRINGZ, HandleId AS QUAD, BYVAL GenerateOnClose AS LONG) AS LONG
#ELSE
DECLARE FUNCTION ObjectCloseAuditAlarmW LIB "advapi32.dll" ALIAS "ObjectCloseAuditAlarmW" ( BYREF SubsystemName AS WSTRINGZ , BYVAL HandleId AS QUAD , BYVAL GenerateOnClose AS LONG ) AS LONG
#ENDIF
#IF %DEF(%UNICODE)
 MACRO ObjectCloseAuditAlarm = ObjectCloseAuditAlarmW
#ELSE
 MACRO ObjectCloseAuditAlarm = ObjectCloseAuditAlarmA
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION ObjectDeleteAuditAlarmA LIB "AdvApi32.dll" ALIAS "ObjectDeleteAuditAlarmA" (SubsystemName AS ASCIIZ, HandleId AS QUAD, BYVAL GenerateOnClose AS LONG) AS LONG
#ELSE
DECLARE FUNCTION ObjectDeleteAuditAlarmA LIB "advapi32.dll" ALIAS "ObjectDeleteAuditAlarmA" ( BYREF SubsystemName AS ASCIIZ , BYVAL HandleId AS QUAD , BYVAL GenerateOnClose AS LONG ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION ObjectDeleteAuditAlarmW LIB "AdvApi32.dll" ALIAS "ObjectDeleteAuditAlarmW" (SubsystemName AS WSTRINGZ, HandleId AS QUAD, BYVAL GenerateOnClose AS LONG) AS LONG
#ELSE
DECLARE FUNCTION ObjectDeleteAuditAlarmW LIB "advapi32.dll" ALIAS "ObjectDeleteAuditAlarmW" ( BYREF SubsystemName AS WSTRINGZ , BYVAL HandleId AS QUAD , BYVAL GenerateOnClose AS LONG ) AS LONG
#ENDIF
#IF %DEF(%UNICODE)
 MACRO ObjectDeleteAuditAlarm = ObjectDeleteAuditAlarmW
#ELSE
 MACRO ObjectDeleteAuditAlarm = ObjectDeleteAuditAlarmA
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION PrivilegedServiceAuditAlarmA LIB "AdvApi32.dll" ALIAS "PrivilegedServiceAuditAlarmA" (SubsystemName AS ASCIIZ, ServiceName AS ASCIIZ, BYVAL ClientToken AS QUAD, BYVAL Privileges AS QUAD, BYVAL AccessGranted AS LONG) AS LONG
#ELSE
DECLARE FUNCTION PrivilegedServiceAuditAlarmA LIB "advapi32.dll" ALIAS "PrivilegedServiceAuditAlarmA" ( BYREF SubsystemName AS ASCIIZ , BYREF ServiceName AS ASCIIZ , BYVAL ClientToken AS QUAD , BYREF Privileges AS PRIVILEGE_SET , BYVAL AccessGranted AS LONG ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION PrivilegedServiceAuditAlarmW LIB "AdvApi32.dll" ALIAS "PrivilegedServiceAuditAlarmW" (SubsystemName AS WSTRINGZ, ServiceName AS WSTRINGZ, BYVAL ClientToken AS QUAD, BYVAL Privileges AS QUAD, BYVAL AccessGranted AS LONG) AS LONG
#ELSE
DECLARE FUNCTION PrivilegedServiceAuditAlarmW LIB "advapi32.dll" ALIAS "PrivilegedServiceAuditAlarmW" ( BYREF SubsystemName AS WSTRINGZ , BYREF ServiceName AS WSTRINGZ , BYVAL ClientToken AS QUAD , BYREF Privileges AS PRIVILEGE_SET , BYVAL AccessGranted AS LONG ) AS LONG
#ENDIF
#IF %DEF(%UNICODE)
 MACRO PrivilegedServiceAuditAlarm = PrivilegedServiceAuditAlarmW
#ELSE
 MACRO PrivilegedServiceAuditAlarm = PrivilegedServiceAuditAlarmA
#ENDIF
'#if(_WIN32_WINNT >= 0x0501)
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION IsWellKnownSid LIB "AdvApi32.dll" ALIAS "IsWellKnownSid" (pSid AS SID, BYVAL WellKnownSidType AS LONG) AS LONG
#ELSE
DECLARE FUNCTION IsWellKnownSid LIB "advapi32.dll" ALIAS "IsWellKnownSid" ( BYVAL pSid AS SID PTR , BYVAL WellKnownSidType AS LONG ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION CreateWellKnownSid LIB "AdvApi32.dll" ALIAS "CreateWellKnownSid" (BYVAL WellKnownSidType AS LONG, DomainSid AS SID, pSid AS SID, cbSid AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION CreateWellKnownSid LIB "advapi32.dll" ALIAS "CreateWellKnownSid" ( BYVAL WellKnownSidType AS LONG , BYVAL DomainSid AS SID PTR , BYREF pSid AS ANY , BYREF cbSid AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION EqualDomainSid LIB "AdvApi32.dll" ALIAS "EqualDomainSid" (pSid1 AS SID, pSid2 AS SID, pfEqual AS LONG) AS LONG
#ELSE
DECLARE FUNCTION EqualDomainSid LIB "advapi32.dll" ALIAS "EqualDomainSid" ( BYVAL pSid1 AS SID PTR , BYVAL pSid1 AS SID PTR , BYREF pfEqual AS LONG ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION GetWindowsAccountDomainSid LIB "AdvApi32.dll" ALIAS "GetWindowsAccountDomainSid" (pSid AS SID, pDomainSid AS SID, cbDomainSid AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION GetWindowsAccountDomainSid LIB "advapi32.dll" ALIAS "GetWindowsAccountDomainSid" ( BYVAL pSid AS SID PTR , BYREF pDomainSid AS ANY , BYREF cbDomainSid AS QUAD ) AS LONG
#ENDIF
'#endif //(_WIN32_WINNT >= 0x0501)
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION IsValidSid LIB "AdvApi32.dll" ALIAS "IsValidSid" (pSid AS SID) AS LONG
#ELSE
DECLARE FUNCTION IsValidSid LIB "advapi32.dll" ALIAS "IsValidSid" ( BYVAL pSid AS SID PTR ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION EqualSid LIB "AdvApi32.dll" ALIAS "EqualSid" (pSid1 AS SID, pSid2 AS SID) AS LONG
#ELSE
DECLARE FUNCTION EqualSid LIB "advapi32.dll" ALIAS "EqualSid" ( BYVAL pSid1 AS SID PTR , BYVAL pSid2 AS SID PTR ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION EqualPrefixSid LIB "AdvApi32.dll" ALIAS "EqualPrefixSid" (pSid1 AS SID, pSid2 AS SID) AS LONG
#ELSE
DECLARE FUNCTION EqualPrefixSid LIB "advapi32.dll" ALIAS "EqualPrefixSid" ( BYVAL pSid1 AS SID PTR , BYVAL pSid2 AS SID PTR ) AS LONG
#ENDIF
DECLARE FUNCTION GetSidLengthRequired LIB "advapi32.dll" ALIAS "GetSidLengthRequired" ( BYVAL nSubAuthorityCount AS BYTE ) AS QUAD
DECLARE FUNCTION AllocateAndInitializeSid LIB "advapi32.dll" ALIAS "AllocateAndInitializeSid" ( BYREF pIdentifierAuthority AS SID_IDENTIFIER_AUTHORITY
 , BYVAL nSubAuthorityCount AS BYTE
 , BYVAL nSubAuthority0 AS DWORD
 , BYVAL nSubAuthority1 AS DWORD
 , BYVAL nSubAuthority2 AS DWORD
 , BYVAL nSubAuthority3 AS DWORD
 , BYVAL nSubAuthority4 AS DWORD
 , BYVAL nSubAuthority5 AS DWORD
 , BYVAL nSubAuthority6 AS DWORD
 , BYVAL nSubAuthority7 AS DWORD
 , BYREF pSid AS ANY
 ) AS LONG
#IF %DEF(%USEPBDECL)
DECLARE SUB FreeSid LIB "AdvApi32.dll" ALIAS "FreeSid" (pSid AS SID)
#ELSE
DECLARE FUNCTION FreeSid LIB "advapi32.dll" ALIAS "FreeSid" ( BYVAL pSid AS SID PTR ) AS QUAD
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION InitializeSid LIB "AdvApi32.dll" ALIAS "InitializeSid" (pSid AS SID, pIdentifierAuthority AS SID_IDENTIFIER_AUTHORITY, BYVAL nSubAuthorityCount AS BYTE) AS LONG
#ELSE
DECLARE FUNCTION InitializeSid LIB "advapi32.dll" ALIAS "InitializeSid" ( BYVAL pSid AS SID PTR , BYREF pIdentifierAuthority AS SID_IDENTIFIER_AUTHORITY , BYVAL nSubAuthorityCount AS BYTE ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION GetSidIdentifierAuthority LIB "AdvApi32.dll" ALIAS "GetSidIdentifierAuthority" (pSid AS SID) AS QUAD
#ELSE
DECLARE FUNCTION GetSidIdentifierAuthority LIB "advapi32.dll" ALIAS "GetSidIdentifierAuthority" ( BYVAL pSid AS SID PTR ) AS QUAD ' PSID_IDENTIFIER_AUTHORITY
#ENDIF
'#IF %DEF(%USEPBDECL)
'DECLARE FUNCTION GetSidSubAuthority LIB "AdvApi32.dll" ' ALIAS "GetSidSubAuthority" (dwFlags AS DWORD, ' BYVAL nSubAuthority AS DWORD) AS DWORD
'#ELSE
DECLARE FUNCTION GetSidSubAuthority LIB "advapi32.dll" ALIAS "GetSidSubAuthority" ( BYVAL pSid AS SID PTR , BYVAL nSubAuthority AS QUAD ) AS QUAD
'#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION GetSidSubAuthorityCount LIB "AdvApi32.dll" ALIAS "GetSidSubAuthorityCount" (pSid AS SID) AS QUAD
#ELSE
DECLARE FUNCTION GetSidSubAuthorityCount LIB "advapi32.dll" ALIAS "GetSidSubAuthorityCount" ( BYVAL pSid AS SID PTR ) AS QUAD
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION GetLengthSid LIB "AdvApi32.dll" ALIAS "GetLengthSid" (pSid AS SID) AS QUAD
#ELSE
DECLARE FUNCTION GetLengthSid LIB "advapi32.dll" ALIAS "GetLengthSid" ( BYVAL pSid AS SID PTR ) AS QUAD
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION CopySid LIB "AdvApi32.dll" ALIAS "CopySid" (BYVAL nDestinationSidLength AS QUAD, pDestinationSid AS SID, pSourceSid AS SID) AS LONG
#ELSE
DECLARE FUNCTION CopySid LIB "advapi32.dll" ALIAS "CopySid" ( BYVAL nDestinationSidLength AS QUAD , BYREF pDestinationSid AS ANY , BYVAL pSourceSid AS SID PTR ) AS LONG
#ENDIF
DECLARE FUNCTION AreAllAccessesGranted LIB "advapi32.dll" ALIAS "AreAllAccessesGranted" ( BYVAL GrantedAccess AS QUAD , BYVAL DesiredAccess AS QUAD ) AS LONG
DECLARE FUNCTION AreAnyAccessesGranted LIB "advapi32.dll" ALIAS "AreAnyAccessesGranted" ( BYVAL GrantedAccess AS QUAD
 , BYVAL DesiredAccess AS DWORD
 ) AS LONG
DECLARE SUB MapGenericMask LIB "advapi32.dll" ALIAS "MapGenericMask" ( BYREF AccessMask AS DWORD
 , BYREF GenericMapping AS GENERIC_MAPPING
 ) ' void
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION IsValidAcl LIB "AdvApi32.dll" ALIAS "IsValidAcl" (pAcl AS ACL) AS LONG
#ELSE
DECLARE FUNCTION IsValidAcl LIB "advapi32.dll" ALIAS "IsValidAcl" ( BYVAL pAcl AS ACL PTR ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION InitializeAcl LIB "AdvApi32.dll" ALIAS "InitializeAcl" (pAcl AS ACL, BYVAL nAclLength AS QUAD, BYVAL dwAclRevision AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION InitializeAcl LIB "advapi32.dll" ALIAS "InitializeAcl" ( BYVAL pAcl AS ACL PTR , BYVAL nAclLength AS QUAD , BYVAL dwAclRevision AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION GetAclInformation LIB "AdvApi32.dll" ALIAS "GetAclInformation" (pAcl AS ACL, BYVAL pAclInformation AS QUAD, BYVAL nAclInformationLength AS QUAD, BYVAL dwAclInformationClass AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION GetAclInformation LIB "advapi32.dll" ALIAS "GetAclInformation" ( BYVAL pAcl AS ACL PTR , BYREF pAclInformation AS ANY , BYVAL nAclInformationLength AS QUAD , BYVAL dwAclInformationClass AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION SetAclInformation LIB "AdvApi32.dll" ALIAS "SetAclInformation" (pAcl AS ACL, BYVAL pAclInformation AS QUAD, BYVAL nAclInformationLength AS QUAD, BYVAL dwAclInformationClass AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION SetAclInformation LIB "advapi32.dll" ALIAS "SetAclInformation" ( BYVAL pAcl AS ACL PTR , BYREF pAclInformation AS ANY , BYVAL nAclInformationLength AS QUAD , BYVAL dwAclInformationClass AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION AddAce LIB "AdvApi32.dll" ALIAS "AddAce" (pAcl AS ACL, BYVAL dwAceRevision AS QUAD, BYVAL dwStartingAceIndex AS QUAD, BYVAL pAceList AS QUAD, BYVAL nAceListLength AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION AddAce LIB "advapi32.dll" ALIAS "AddAce" ( BYVAL pAcl AS ACL PTR , BYVAL dwAceRevision AS QUAD , BYVAL dwStartingAceIndex AS QUAD , BYREF pAceList AS ANY , BYVAL nAceListLength AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION DeleteAce LIB "AdvApi32.dll" ALIAS "DeleteAce" (pAcl AS ACL, BYVAL dwAceIndex AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION DeleteAce LIB "advapi32.dll" ALIAS "DeleteAce" ( BYVAL pAcl AS ACL PTR , BYVAL dwAceIndex AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION GetAce LIB "AdvApi32.dll" ALIAS "GetAce" (pAcl AS ACL, BYVAL dwAceIndex AS QUAD, BYVAL pAce AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION GetAce LIB "advapi32.dll" ALIAS "GetAce" ( BYVAL pAcl AS ACL PTR , BYVAL dwAceIndex AS QUAD , BYREF pAce AS ANY ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION AddAccessAllowedAce LIB "AdvApi32.dll" ALIAS "AddAccessAllowedAce" (pAcl AS ACL, BYVAL dwAceRevision AS QUAD, BYVAL AccessMask AS QUAD, dwFlags AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION AddAccessAllowedAce LIB "advapi32.dll" ALIAS "AddAccessAllowedAce" ( BYVAL pAcl AS ACL PTR , BYVAL dwAceRevision AS QUAD , BYVAL AccessMask AS QUAD , BYVAL pSid AS SID PTR ) AS LONG
#ENDIF
'#if(_WIN32_WINNT >= 0x0500)
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION AddAccessAllowedAceEx LIB "AdvApi32.dll" ALIAS "AddAccessAllowedAceEx" (pAcl AS ACL, BYVAL dwAceRevision AS QUAD, BYVAL AceFlags AS QUAD, BYVAL AccessMask AS QUAD, pSid AS SID) AS LONG
#ELSE
DECLARE FUNCTION AddAccessAllowedAceEx LIB "advapi32.dll" ALIAS "AddAccessAllowedAceEx" ( BYVAL pAcl AS ACL PTR , BYVAL dwAceRevision AS QUAD , BYVAL AceFlags AS QUAD , BYVAL AccessMask AS QUAD , BYVAL pSid AS SID PTR ) AS LONG
#ENDIF
'#endif /* _WIN32_WINNT >= 0x0500 */
'#if(_WIN32_WINNT >= 0x0600)
#IF %WINVER >= &H0600
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION AddMandatoryAce LIB "AdvApi32.dll" ALIAS "AddMandatoryAce" ( pAcl AS ACL, BYVAL dwAceRevision AS QUAD, BYVAL AceFlags AS QUAD, BYVAL MandatoryPolicy AS QUAD, pLabelSid AS SID) AS LONG
#ELSE
DECLARE FUNCTION AddMandatoryAce LIB "advapi32.dll" ALIAS "AddMandatoryAce" ( BYVAL pAcl AS ACL PTR , BYVAL dwAceRevision AS QUAD , BYVAL AceFlags AS QUAD , BYVAL MandatoryPolicy AS QUAD , BYVAL pLabelSid AS SID PTR ) AS LONG
#ENDIF
#ENDIF ' /* _WIN32_WINNT >= 0x0600 */
'#if(_WIN32_WINNT >= 0x0601)
#IF %WINVER >= &H0601
'#IF %DEF(%USEPBDECL)
'DECLARE FUNCTION AddConditionalAce LIB "AdvApi32.dll" ' ALIAS "AddConditionalAce" ( ' pAcl AS ACL, ' BYVAL dwAceRevision AS DWORD, ' BYVAL AceFlags AS DWORD, ' BYVAL AceType AS BYTE, ' BYVAL AccessMask AS DWORD, ' BYVAL pSid AS SID, ' ConditionStr AS WSTRINGZ, ' ReturnLength AS DWORD) ' AS LONG
'#ELSE
DECLARE FUNCTION AddConditionalAce LIB "advapi32.dll" ALIAS "AddConditionalAce" ( BYVAL pAcl AS ACL PTR , BYVAL dwAceRevision AS QUAD , BYVAL AceFlags AS QUAD , BYVAL AceType AS BYTE , BYVAL AccessMask AS QUAD , BYVAL pSid AS SID PTR , BYREF ConditionStr AS WSTRINGZ , BYREF ReturnLength AS QUAD ) AS LONG
'#ENDIF
#ENDIF ' /* _WIN32_WINNT >= 0x0601 */
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION AddAccessDeniedAce LIB "AdvApi32.dll" ALIAS "AddAccessDeniedAce" (pAcl AS ACL, BYVAL dwAceRevision AS QUAD, BYVAL AccessMask AS QUAD, pSid AS SID) AS LONG
#ELSE
DECLARE FUNCTION AddAccessDeniedAce LIB "advapi32.dll" ALIAS "AddAccessDeniedAce" ( BYVAL pAcl AS ACL PTR , BYVAL dwAceRevision AS QUAD , BYVAL AccessMask AS QUAD , BYVAL pSid AS SID PTR ) AS LONG
#ENDIF
'#if(_WIN32_WINNT >= 0x0500)
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION AccessDeniedAceEx LIB "AdvApi32.dll" ALIAS "AccessDeniedAceEx" (pAcl AS ACL, BYVAL dwAceRevision AS QUAD, BYVAL AceFlags AS QUAD, BYVAL AccessMask AS QUAD, pSid AS SID) AS LONG
#ELSE
DECLARE FUNCTION AccessDeniedAceEx LIB "advapi32.dll" ALIAS "AccessDeniedAceEx" ( BYVAL pAcl AS ACL PTR , BYVAL dwAceRevision AS QUAD , BYVAL AceFlags AS QUAD , BYVAL AccessMask AS QUAD , BYVAL pSid AS SID PTR ) AS LONG
#ENDIF
'#endif /* _WIN32_WINNT >= 0x0500 */
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION AddAuditAccessAce LIB "AdvApi32.dll" ALIAS "AddAuditAccessAce" (pAcl AS ACL, BYVAL dwAceRevision AS QUAD, BYVAL dwAccessMask AS QUAD, pSid AS SID, BYVAL bAuditSuccess AS LONG, BYVAL bAuditFailure AS LONG) AS LONG
#ELSE
DECLARE FUNCTION AddAuditAccessAce LIB "advapi32.dll" ALIAS "AddAuditAccessAce" ( BYVAL pAcl AS ACL PTR , BYVAL dwAceRevision AS QUAD , BYVAL dwAccessMask AS QUAD , BYVAL pSid AS SID PTR , BYVAL bAuditSuccess AS LONG , BYVAL bAuditFailure AS LONG ) AS LONG
#ENDIF
'#if(_WIN32_WINNT >= 0x0500)
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION AddAuditAccessAceEx LIB "AdvApi32.dll" ALIAS "AddAuditAccessAceEx" (pAcl AS ACL, BYVAL dwAceRevision AS QUAD, BYVAL AceFlags AS QUAD, BYVAL dwAccessMask AS QUAD, pSid AS SID, BYVAL bAuditSuccess AS LONG, BYVAL bAuditFailure AS LONG) AS LONG
#ELSE
DECLARE FUNCTION AddAuditAccessAceEx LIB "advapi32.dll" ALIAS "AddAuditAccessAceEx" ( BYVAL pAcl AS ACL PTR , BYVAL dwAceRevision AS QUAD , BYVAL AceFlags AS QUAD , BYVAL dwAccessMask AS QUAD , BYVAL pSid AS SID PTR , BYVAL bAuditSuccess AS LONG , BYVAL bAuditFailure AS LONG ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION AddAccessAllowedObjectAce LIB "AdvApi32.dll" ALIAS "AddAccessAllowedObjectAce" (pAcl AS ACL, BYVAL dwAceRevision AS QUAD, BYVAL AceFlags AS QUAD, BYVAL AccessMask AS QUAD, ObjectTypeGuid AS GUID, InheritedObjectTypeGuid AS GUID, psid AS SID) AS LONG
#ELSE
DECLARE FUNCTION AddAccessAllowedObjectAce LIB "advapi32.dll" ALIAS "AddAccessAllowedObjectAce" ( BYVAL pAcl AS ACL PTR , BYVAL dwAceRevision AS QUAD , BYVAL AceFlags AS QUAD , BYVAL AccessMask AS QUAD , BYREF ObjectTypeGuid AS GUID , BYREF InheritedObjectTypeGuid AS GUID , BYVAL pSid AS SID PTR ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION AddAccessDeniedObjectAce LIB "AdvApi32.dll" ALIAS "AddAccessDeniedObjectAce" (pAcl AS ACL, BYVAL dwAceRevision AS QUAD, BYVAL AceFlags AS QUAD, BYVAL AccessMask AS QUAD, ObjectTypeGuid AS GUID, InheritedObjectTypeGuid AS GUID, pSid AS SID) AS LONG
#ELSE
DECLARE FUNCTION AddAccessDeniedObjectAce LIB "advapi32.dll" ALIAS "AddAccessDeniedObjectAce" ( BYVAL pAcl AS ACL PTR , BYVAL dwAceRevision AS QUAD , BYVAL AceFlags AS QUAD , BYVAL AccessMask AS QUAD , BYREF ObjectTypeGuid AS GUID , BYREF InheritedObjectTypeGuid AS GUID , BYVAL pSid AS SID PTR ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION AddAuditAccessObjectAce LIB "AdvApi32.dll" ALIAS "AddAuditAccessObjectAce" (pAcl AS ACL, BYVAL dwAceRevision AS QUAD, BYVAL AceFlags AS QUAD, BYVAL AccessMask AS QUAD, ObjectTypeGuid AS GUID, InheritedObjectTypeGuid AS GUID, pSid AS SID, BYVAL bAuditSuccess AS LONG, BYVAL bAuditFailure AS LONG) AS LONG
#ELSE
DECLARE FUNCTION AddAuditAccessObjectAce LIB "advapi32.dll" ALIAS "AddAuditAccessObjectAce" ( BYVAL pAcl AS ACL PTR , BYVAL dwAceRevision AS QUAD , BYVAL AceFlags AS QUAD , BYVAL AccessMask AS QUAD , BYREF ObjectTypeGuid AS GUID , BYREF InheritedObjectTypeGuid AS GUID , BYVAL pSid AS SID PTR , BYVAL bAuditSuccess AS LONG , BYVAL bAuditFailure AS LONG ) AS LONG
#ENDIF
'#endif /* _WIN32_WINNT >= 0x0500 */
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION FindFirstFreeAce LIB "AdvApi32.dll" ALIAS "FindFirstFreeAce" (pAcl AS ACL, pAce AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION FindFirstFreeAce LIB "advapi32.dll" ALIAS "FindFirstFreeAce" ( BYVAL pAcl AS ACL PTR , BYREF pAce AS ANY ) AS LONG
#ENDIF
DECLARE FUNCTION InitializeSecurityDescriptor LIB "advapi32.dll" ALIAS "InitializeSecurityDescriptor" ( BYREF pSecurityDescriptor AS SECURITY_DESCRIPTOR , BYVAL dwRevision AS QUAD ) AS LONG
DECLARE FUNCTION IsValidSecurityDescriptor LIB "advapi32.dll" ALIAS "IsValidSecurityDescriptor" ( BYREF pSecurityDescriptor AS SECURITY_DESCRIPTOR
 ) AS LONG
DECLARE FUNCTION IsValidRelativeSecurityDescriptor LIB "advapi32.dll" ALIAS "IsValidRelativeSecurityDescriptor" ( BYREF pSecurityDescriptor AS SECURITY_DESCRIPTOR
 , BYVAL SecurityDescriptorLength AS DWORD
 , BYVAL RequiredInformation AS SECURITY_INFORMATION
 ) AS LONG
DECLARE FUNCTION GetSecurityDescriptorLength LIB "advapi32.dll" ALIAS "GetSecurityDescriptorLength" ( BYREF pSecurityDescriptor AS SECURITY_DESCRIPTOR
 ) AS DWORD
'#IF %DEF(%USEPBDECL)
'DECLARE FUNCTION GetSecurityDescriptorControl LIB "AdvApi32.dll" ' ALIAS "GetSecurityDescriptorControl" ' (pSecurityDescriptor AS SECURITY_DESCRIPTOR, ' pControl AS SECURITY_DESCRIPTOR, lpdwRevision AS DWORD) AS LONG
'#ELSE
DECLARE FUNCTION GetSecurityDescriptorControl LIB "advapi32.dll" ALIAS "GetSecurityDescriptorControl" ( BYREF pSecurityDescriptor AS SECURITY_DESCRIPTOR , BYREF pControl AS WORD , BYREF lpdwRevision AS QUAD ) AS LONG
'#ENDIF
'#if(_WIN32_WINNT >= 0x0500)
DECLARE FUNCTION SetSecurityDescriptorControl LIB "advapi32.dll" ALIAS "SetSecurityDescriptorControl" ( BYREF pSecurityDescriptor AS SECURITY_DESCRIPTOR , BYVAl ControlBitsOfInterest AS WORD , BYVAL ControlBitsToSet AS WORD ) AS LONG
'#endif /* _WIN32_WINNT >= 0x0500 */
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION SetSecurityDescriptorDacl LIB "AdvApi32.dll" ALIAS "SetSecurityDescriptorDacl" (pSecurityDescriptor AS SECURITY_DESCRIPTOR, BYVAL bDaclPresent AS LONG, pDacl AS ACL, BYVAL bDaclDefaulted AS LONG) AS LONG
#ELSE
DECLARE FUNCTION SetSecurityDescriptorDacl LIB "advapi32.dll" ALIAS "SetSecurityDescriptorDacl" ( BYREF pSecurityDescriptor AS SECURITY_DESCRIPTOR , BYVAL bDaclPresent AS LONG , BYVAL pDacl AS ACL PTR , BYVAL bDaclDefaulted AS LONG ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION GetSecurityDescriptorDacl LIB "AdvApi32.dll" ALIAS "GetSecurityDescriptorDacl" (pSecurityDescriptor AS SECURITY_DESCRIPTOR, lpbDaclPresent AS LONG, pDacl AS QUAD, lpbDaclDefaulted AS LONG) AS LONG
#ELSE
DECLARE FUNCTION GetSecurityDescriptorDacl LIB "advapi32.dll" ALIAS "GetSecurityDescriptorDacl" ( BYREF pSecurityDescriptor AS SECURITY_DESCRIPTOR , BYREF lpbDaclPresent AS LONG , BYREF pDacl AS ANY , BYREF lpbDaclDefaulted AS LONG ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION SetSecurityDescriptorSacl LIB "AdvApi32.dll" ALIAS "SetSecurityDescriptorSacl" (pSecurityDescriptor AS SECURITY_DESCRIPTOR, BYVAL bSaclPresent AS LONG, pSacl AS ACL, BYVAL bSaclDefaulted AS LONG) AS LONG
#ELSE
DECLARE FUNCTION SetSecurityDescriptorSacl LIB "advapi32.dll" ALIAS "SetSecurityDescriptorSacl" ( BYREF pSecurityDescriptor AS SECURITY_DESCRIPTOR , BYVAL bSaclPresent AS LONG , BYVAL pSacl AS ACL PTR , BYVAL bSaclDefaulted AS LONG ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION GetSecurityDescriptorSacl LIB "AdvApi32.dll" ALIAS "GetSecurityDescriptorSacl" (pSecurityDescriptor AS SECURITY_DESCRIPTOR, BYVAL lpbSaclPresent AS LONG, pSacl AS QUAD, lpbSaclDefaulted AS LONG) AS LONG
#ELSE
DECLARE FUNCTION GetSecurityDescriptorSacl LIB "advapi32.dll" ALIAS "GetSecurityDescriptorSacl" ( BYREF pSecurityDescriptor AS SECURITY_DESCRIPTOR , BYREF lpbSaclPresent AS LONG , BYREF pSacl AS ANY , BYREF lpbSaclDefaulted AS LONG ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION SetSecurityDescriptorOwner LIB "AdvApi32.dll" ALIAS "SetSecurityDescriptorOwner" (pSecurityDescriptor AS SECURITY_DESCRIPTOR, pOwner AS SID, BYVAL bOwnerDefaulted AS LONG) AS LONG
#ELSE
DECLARE FUNCTION SetSecurityDescriptorOwner LIB "advapi32.dll" ALIAS "SetSecurityDescriptorOwner" ( BYREF pSecurityDescriptor AS SECURITY_DESCRIPTOR , BYVAL pOwner AS SID PTR , BYVAL bOwnerDefaulted AS LONG ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION GetSecurityDescriptorOwner LIB "AdvApi32.dll" ALIAS "GetSecurityDescriptorOwner" (pSecurityDescriptor AS SECURITY_DESCRIPTOR, pOwner AS QUAD, BYVAL lpbOwnerDefaulted AS LONG) AS LONG
#ELSE
DECLARE FUNCTION GetSecurityDescriptorOwner LIB "advapi32.dll" ALIAS "GetSecurityDescriptorOwner" ( BYREF pSecurityDescriptor AS SECURITY_DESCRIPTOR , BYREF pOwner AS ANY , BYREF lpbOwnerDefaulted AS LONG ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION SetSecurityDescriptorGroup LIB "AdvApi32.dll" ALIAS "SetSecurityDescriptorGroup" (pSecurityDescriptor AS SECURITY_DESCRIPTOR, pGroup AS SID, BYVAL bGroupDefaulted AS LONG) AS LONG
#ELSE
DECLARE FUNCTION SetSecurityDescriptorGroup LIB "advapi32.dll" ALIAS "SetSecurityDescriptorGroup" ( BYREF pSecurityDescriptor AS SECURITY_DESCRIPTOR , BYVAL pGroup AS SID PTR , BYVAL bGroupDefaulted AS LONG ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION GetSecurityDescriptorGroup LIB "AdvApi32.dll" ALIAS "GetSecurityDescriptorGroup" (pSecurityDescriptor AS SECURITY_DESCRIPTOR, pGroup AS QUAD, lpbGroupDefaulted AS LONG) AS LONG
#ELSE
DECLARE FUNCTION GetSecurityDescriptorGroup LIB "advapi32.dll" ALIAS "GetSecurityDescriptorGroup" ( BYREF pSecurityDescriptor AS SECURITY_DESCRIPTOR ) AS LONG ' PSECURITY_DESCRIPTOR pSecurityDescriptor , BYREF pGroup AS ANY , BYREF lpbGroupDefaulted AS LONG
#ENDIF
DECLARE FUNCTION SetSecurityDescriptorRMControl LIB "advapi32.dll" ALIAS "SetSecurityDescriptorRMControl" ( BYREF SecurityDescriptor AS SECURITY_DESCRIPTOR , BYVAL RMControl AS BYTE PTR ) AS QUAD
DECLARE FUNCTION GetSecurityDescriptorRMControl LIB "advapi32.dll" ALIAS "GetSecurityDescriptorRMControl" ( BYREF SecurityDescriptor AS SECURITY_DESCRIPTOR
 , BYVAL RMControl AS BYTE PTR
 ) AS DWORD
DECLARE FUNCTION CreatePrivateObjectSecurity LIB "advapi32.dll" ALIAS "CreatePrivateObjectSecurity" ( BYREF ParentDescriptor AS SECURITY_DESCRIPTOR
 , BYREF CreatorDescriptor AS SECURITY_DESCRIPTOR
 , BYREF NewDescriptor AS DWORD
 , BYVAL IsDirectoryObject AS LONG
 , BYVAL Token AS DWORD
 , BYREF GenericMapping AS GENERIC_MAPPING
 ) AS LONG
'#if(_WIN32_WINNT >= 0x0500)
DECLARE FUNCTION ConvertToAutoInheritPrivateObjectSecurity LIB "advapi32.dll" ALIAS "ConvertToAutoInheritPrivateObjectSecurity" ( BYREF ParentDescriptor AS SECURITY_DESCRIPTOR , BYREF CurrentSecurityDescriptor AS SECURITY_DESCRIPTOR , BYREF NewSecurityDescriptor AS QUAD , BYREF ObjectType AS GUID , BYVAL IsDirectoryObject AS BYTE , BYREF GenericMapping AS GENERIC_MAPPING ) AS LONG
DECLARE FUNCTION CreatePrivateObjectSecurityEx LIB "advapi32.dll" ALIAS "CreatePrivateObjectSecurityEx" ( BYREF ParentDescriptor AS SECURITY_DESCRIPTOR
 , BYREF CreatorDescriptor AS SECURITY_DESCRIPTOR
 , BYREF NewDescriptor AS DWORD
 , BYREF ObjectType AS GUID
 , BYVAL IsContainerObject AS LONG
 , BYVAL AutoInheritFlags AS DWORD
 , BYVAL Token AS DWORD
 , BYREF GenericMapping AS GENERIC_MAPPING
 ) AS LONG
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION CreatePrivateObjectSecurityWithMultipleInheritance LIB "AdvApi32.dll" ALIAS "CreatePrivateObjectSecurityWithMultipleInheritance" (ParentDescriptor AS SECURITY_DESCRIPTOR, CreatorDescriptor AS SECURITY_DESCRIPTOR, NewDescriptor AS QUAD, BYVAL ObjectTypes AS QUAD, BYVAL GuidCount AS QUAD, BYVAL IsDirectoryObject AS LONG, BYVAL AutoInheritFlags AS QUAD, BYVAL Token AS QUAD, GenericMapping AS GENERIC_MAPPING) AS LONG
#ELSE
DECLARE FUNCTION CreatePrivateObjectSecurityWithMultipleInheritance LIB "advapi32.dll" ALIAS "CreatePrivateObjectSecurityWithMultipleInheritance" ( BYREF ParentDescriptor AS SECURITY_DESCRIPTOR , BYREF CreatorDescriptor AS SECURITY_DESCRIPTOR , BYREF NewDescriptor AS QUAD , BYREF ObjectTypes AS GUID , BYVAL GuidCount AS QUAD , BYVAL IsContainerObject AS LONG , BYVAL AutoInheritFlags AS QUAD , BYVAL Token AS QUAD , BYREF GenericMapping AS GENERIC_MAPPING ) AS LONG
#ENDIF
'#endif /* _WIN32_WINNT >= 0x0500 */
DECLARE FUNCTION SetPrivateObjectSecurity LIB "advapi32.dll" ALIAS "SetPrivateObjectSecurity" ( BYVAL SecurityInformation AS SECURITY_INFORMATION , BYREF ModificationDescriptor AS SECURITY_DESCRIPTOR , BYREF ObjectsSecurityDescriptor AS SECURITY_DESCRIPTOR , BYREF GenericMapping AS GENERIC_MAPPING , BYVAL Token AS QUAD ) AS LONG
'#if(_WIN32_WINNT >= 0x0500)
DECLARE FUNCTION SetPrivateObjectSecurityEx LIB "advapi32.dll" ALIAS "SetPrivateObjectSecurityEx" ( BYVAL SecurityInformation AS SECURITY_INFORMATION , BYREF ModificationDescriptor AS SECURITY_DESCRIPTOR , BYREF ObjectsSecurityDescriptor AS QUAD , BYVAL AutoInheritFlags AS QUAD , BYREF GenericMapping AS GENERIC_MAPPING , BYVAL Token AS QUAD ) AS LONG
'#endif /* _WIN32_WINNT >= 0x0500 */
DECLARE FUNCTION GetPrivateObjectSecurity LIB "advapi32.dll" ALIAS "GetPrivateObjectSecurity" ( BYREF ObjectDescriptor AS SECURITY_DESCRIPTOR , BYVAL SecurityInformation AS SECURITY_INFORMATION , BYREF ResultantDescriptor AS SECURITY_DESCRIPTOR , BYVAL DescriptorLength AS QUAD , BYREF ReturnLengt AS QUAD ) AS LONG
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION DestroyPrivateObjectSecurity LIB "AdvApi32.dll" ALIAS "DestroyPrivateObjectSecurity" (ObjectDescriptor AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION DestroyPrivateObjectSecurity LIB "advapi32.dll" ALIAS "DestroyPrivateObjectSecurity" ( BYREF ObjectDescriptor AS SECURITY_DESCRIPTOR ) AS LONG
#ENDIF
DECLARE FUNCTION MakeSelfRelativeSD LIB "advapi32.dll" ALIAS "MakeSelfRelativeSD" ( BYREF pAbsoluteSecurityDescriptor AS SECURITY_DESCRIPTOR , BYREF pSelfRelativeSecurityDescriptor AS SECURITY_DESCRIPTOR , BYREF lpdwBufferLength AS QUAD ) AS LONG
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION MakeAbsoluteSD LIB "AdvApi32.dll" ALIAS "MakeAbsoluteSD" (pSelfRelativeSecurityDescriptor AS SECURITY_DESCRIPTOR, pAbsoluteSecurityDescriptor AS SECURITY_DESCRIPTOR, lpdwAbsoluteSecurityDescriptorSize AS QUAD, pDacl AS ACL, lpdwDaclSize AS QUAD, pSacl AS ACL, lpdwSaclSize AS QUAD, pOwner AS SID, lpdwOwnerSize AS QUAD, pPrimaryGroup AS SID, lpdwPrimaryGroupSize AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION MakeAbsoluteSD LIB "advapi32.dll" ALIAS "MakeAbsoluteSD" ( BYREF pSelfRelativeSecurityDescriptor AS SECURITY_DESCRIPTOR , BYREF pAbsoluteSecurityDescriptor AS SECURITY_DESCRIPTOR , BYREF lpdwAbsoluteSecurityDescriptorSize AS QUAD , BYREF pDacl AS ANY , BYREF lpdwDaclSize AS QUAD , BYREF pSacl AS ANY , BYREF lpdwSaclSize AS QUAD , BYREF pOwner AS ANY , BYREF lpdwOwnerSize AS QUAD , BYREF pPrimaryGroup AS ANY , BYREF lpdwPrimaryGroupSize AS QUAD ) AS LONG
#ENDIF
DECLARE FUNCTION MakeAbsoluteSD2 LIB "advapi32.dll" ALIAS "MakeAbsoluteSD2" ( BYREF pSelfRelativeSecurityDescriptor AS SECURITY_DESCRIPTOR , BYREF lpdwBufferSize AS QUAD ) AS LONG
DECLARE SUB QuerySecurityAccessMask LIB "advapi32.dll" ALIAS "QuerySecurityAccessMask" ( BYVAL SecurityInformation AS SECURITY_INFORMATION
 , BYREF DesiredAccess AS DWORD
 )
DECLARE FUNCTION SetFileSecurityA LIB "advapi32.dll" ALIAS "SetFileSecurityA" ( BYREF lpFileName AS ASCIIZ
 , BYVAL SecurityInformation AS SECURITY_INFORMATION
 , BYREF pSecurityDescriptor AS SECURITY_DESCRIPTOR
 ) AS LONG
DECLARE FUNCTION SetFileSecurityW LIB "advapi32.dll" ALIAS "SetFileSecurityW" ( BYREF lpFileName AS WSTRINGZ
 , BYVAL SecurityInformation AS SECURITY_INFORMATION
 , BYREF pSecurityDescriptor AS SECURITY_DESCRIPTOR
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SetFileSecurity = SetFileSecurityW
#ELSE
 MACRO SetFileSecurity = SetFileSecurityA
#ENDIF
DECLARE FUNCTION GetFileSecurityA LIB "advapi32.dll" ALIAS "GetFileSecurityA" ( BYREF lpFileName AS ASCIIZ , BYVAL RequestedInformation AS SECURITY_INFORMATION , BYREF pSecurityDescriptor AS SECURITY_DESCRIPTOR , BYVAL nLength AS QUAD , BYREF lpnLengthNeeded AS QUAD ) AS LONG
DECLARE FUNCTION GetFileSecurityW LIB "advapi32.dll" ALIAS "GetFileSecurityW" ( BYREF lpFileName AS WSTRINGZ
 , BYVAL RequestedInformation AS SECURITY_INFORMATION
 , BYREF pSecurityDescriptor AS SECURITY_DESCRIPTOR
 , BYVAL nLength AS DWORD
 , BYREF lpnLengthNeeded AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO GetFileSecurity = GetFileSecurityW
#ELSE
 MACRO GetFileSecurity = GetFileSecurityA
#ENDIF
DECLARE FUNCTION SetKernelObjectSecurity LIB "advapi32.dll" ALIAS "SetKernelObjectSecurity" ( BYVAL Handle AS QUAD , BYVAL SecurityInformation AS SECURITY_INFORMATION , BYREF SecurityDescriptor AS SECURITY_DESCRIPTOR ) AS LONG
DECLARE FUNCTION FindFirstChangeNotificationA LIB "kernel32.dll" ALIAS "FindFirstChangeNotificationA" ( BYREF lpPathName AS ASCIIZ
 , BYVAL bWatchSubtree AS LONG
 , BYVAL dwNotifyFilter AS DWORD
 ) AS DWORD
DECLARE FUNCTION FindFirstChangeNotificationW LIB "kernel32.dll" ALIAS "FindFirstChangeNotificationW" ( BYREF lpPathName AS WSTRINGZ
 , BYVAL bWatchSubtree AS LONG
 , BYVAL dwNotifyFilter AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO FindFirstChangeNotification = FindFirstChangeNotificationW
#ELSE
 MACRO FindFirstChangeNotification = FindFirstChangeNotificationA
#ENDIF
DECLARE FUNCTION FindNextChangeNotification LIB "kernel32.dll" ALIAS "FindNextChangeNotification" ( BYVAL hChangeHandle AS QUAD ) AS LONG
DECLARE FUNCTION FindCloseChangeNotification LIB "kernel32.dll" ALIAS "FindCloseChangeNotification" ( BYVAL hChangeHandle AS QUAD
 ) AS LONG
'#if(_WIN32_WINNT >= 0x0400)
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION ReadDirectoryChangesW LIB "Kernel32.dll" ALIAS "ReadDirectoryChangesW" (BYVAL hDirectory AS QUAD, BYVAL lpBuffer AS QUAD, BYVAL nBufferLength AS QUAD, BYVAL bWatchSubtree AS LONG, BYVAL dwNotifyFilter AS QUAD, lpBytesReturned AS QUAD, lpOverlapped AS OVERLAPPED, BYVAL lpCompletionRoutine AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION ReadDirectoryChangesW LIB "kernel32.dll" ALIAS "ReadDirectoryChangesW" ( BYVAL hDirectory AS QUAD , BYREF lpBuffer AS ANY , BYVAL nBufferLength AS QUAD , BYVAL bWatchSubtree AS LONG , BYVAL dwNotifyFilter AS QUAD , BYREF lpBytesReturned AS QUAD , BYREF lpOverlapped AS OVERLAPPED , BYVAL lpCompletionRoutine AS QUAD ) AS LONG
#ENDIF
MACRO ReadDirectoryChanges = ReadDirectoryChangesW
'#endif /* _WIN32_WINNT >= 0x0400 */
DECLARE FUNCTION VirtualLock LIB "kernel32.dll" ALIAS "VirtualLock" ( BYVAL lpAddress AS QUAD , BYVAL dwSize AS QUAD ) AS LONG
DECLARE FUNCTION VirtualUnlock LIB "kernel32.dll" ALIAS "VirtualUnlock" ( BYVAL lpAddress AS QUAD
 , BYVAL dwSize AS DWORD
 ) AS LONG
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION MapViewOfFileEx LIB "Kernel32.dll" ALIAS "MapViewOfFileEx" (BYVAL hFileMappingObject AS QUAD, BYVAL dwDesiredAccess AS QUAD, BYVAL dwFileOffsetHigh AS QUAD, BYVAL dwFileOffsetLow AS QUAD, BYVAL dwNumberOfBytesToMap AS QUAD, lpBaseAddress AS QUAD) AS QUAD
#ELSE
DECLARE FUNCTION MapViewOfFileEx LIB "kernel32.dll" ALIAS "MapViewOfFileEx" ( BYVAL hFileMappingObject AS QUAD , BYVAL dwDesiredAccess AS QUAD , BYVAL dwFileOffsetHigh AS QUAD , BYVAL dwFileOffsetLow AS QUAD , BYVAL dwNumberOfBytesToMap AS QUAD , OPTIONAL BYVAL lpBaseAddress AS QUAD ) AS QUAD
#ENDIF
'#if _WIN32_WINNT >= 0x0600
#IF %WINVER >= &H0600
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION MapViewOfFileExNuma LIB "Kernel32.dll" ALIAS "MapViewOfFileExNuma" (BYVAL hFileMappingObject AS QUAD, BYVAL dwDesiredAccess AS QUAD, BYVAL dwFileOffsetHigh AS QUAD, BYVAL dwFileOffsetLow AS QUAD, BYVAL dwNumberOfBytesToMap AS QUAD, lpBaseAddress AS QUAD, BYVAL nndPreferred AS QUAD) AS QUAD
#ELSE
DECLARE FUNCTION MapViewOfFileExNuma LIB "kernel32.dll" ALIAS "MapViewOfFileExNuma" ( BYVAL hFileMappingObject AS QUAD , BYVAL dwDesiredAccess AS QUAD , BYVAL dwFileOffsetHigh AS QUAD , BYVAL dwFileOffsetLow AS QUAD , BYVAL dwNumberOfBytesToMap AS QUAD , BYVAL lpBaseAddress AS QUAD , BYVAL nndPreferred AS QUAD ) AS QUAD
#ENDIF
#ENDIF ' // _WIN32_WINNT >= 0x0600
DECLARE FUNCTION SetPriorityClass LIB "kernel32.dll" ALIAS "SetPriorityClass" ( BYVAL hProcess AS QUAD , BYVAL dwPriorityClass AS QUAD ) AS LONG
DECLARE FUNCTION GetPriorityClass LIB "kernel32.dll" ALIAS "GetPriorityClass" ( BYVAL hProcess AS QUAD
 ) AS DWORD
DECLARE FUNCTION IsBadReadPtr LIB "kernel32.dll" ALIAS "IsBadReadPtr" ( BYVAL lp AS DWORD
 , BYVAL ucb AS DWORD
 ) AS LONG
DECLARE FUNCTION IsBadWritePtr LIB "kernel32.dll" ALIAS "IsBadWritePtr" ( BYVAL lp AS DWORD
 , BYVAL ucb AS DWORD
 ) AS LONG
DECLARE FUNCTION IsBadHugeReadPtr LIB "kernel32.dll" ALIAS "IsBadHugeReadPtr" ( BYVAL lp AS DWORD
 , BYVAL ucb AS DWORD
 ) AS LONG
DECLARE FUNCTION IsBadHugeWritePtr LIB "kernel32.dll" ALIAS "IsBadHugeWritePtr" ( BYVAL lp AS DWORD
 , BYVAL ucb AS DWORD
 ) AS LONG
DECLARE FUNCTION IsBadCodePtr LIB "kernel32.dll" ALIAS "IsBadCodePtr" ( BYVAL lpfn AS DWORD
 ) AS LONG
DECLARE FUNCTION IsBadStringPtrA LIB "kernel32.dll" ALIAS "IsBadStringPtrA" ( BYREF lpsz AS ASCIIZ
 , BYVAL ucchMax AS DWORD
 ) AS LONG
DECLARE FUNCTION IsBadStringPtrW LIB "kernel32.dll" ALIAS "IsBadStringPtrW" ( BYREF lpsz AS WSTRINGZ
 , BYVAL ucchMax AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO IsBadStringPtr = IsBadStringPtrW
#ELSE
 MACRO IsBadStringPtr = IsBadStringPtrA
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION LookupAccountSidA LIB "AdvApi32.dll" ALIAS "LookupAccountSidA" (lpSystemName AS ASCIIZ, pSid AS SID, xName AS ASCIIZ, cbName AS QUAD, ReferencedDomainName AS ASCIIZ, cbReferencedDomainName AS LONG, peUse AS LONG) AS LONG
#ELSE
DECLARE FUNCTION LookupAccountSidA LIB "advapi32.dll" ALIAS "LookupAccountSidA" ( BYREF lpSystemName AS ASCIIZ , BYVAL Sid AS SID PTR , BYREF Name AS ASCIIZ , BYREF cchName AS QUAD , BYREF ReferencedDomainName AS ASCIIZ , BYREF cchReferencedDomainName AS QUAD , BYREF peUse AS LONG ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION LookupAccountSidW LIB "AdvApi32.dll" ALIAS "LookupAccountSidW" (lpSystemName AS WSTRINGZ, pSid AS SID, xName AS WSTRINGZ, cbName AS QUAD, ReferencedDomainName AS WSTRINGZ, cbReferencedDomainName AS LONG, peUse AS LONG) AS LONG
#ELSE
DECLARE FUNCTION LookupAccountSidW LIB "advapi32.dll" ALIAS "LookupAccountSidW" ( BYREF lpSystemName AS WSTRINGZ , BYVAL Sid AS SID PTR , BYREF Name AS WSTRINGZ , BYREF cchName AS QUAD , BYREF ReferencedDomainName AS WSTRINGZ , BYREF cchReferencedDomainName AS QUAD , BYREF peUse AS LONG ) AS LONG
#ENDIF
#IF %DEF(%UNICODE)
 MACRO LookupAccountSid = LookupAccountSidW
#ELSE
 MACRO LookupAccountSid = LookupAccountSidA
#ENDIF
DECLARE FUNCTION LookupAccountSidLocalA LIB "advapi32.dll" ALIAS "LookupAccountSidLocalA" ( BYVAL Sid AS SID PTR , BYREF Name AS ASCIIZ , BYREF cchName AS QUAD , BYREF ReferencedDomainName AS ASCIIZ , BYREF cchReferencedDomainName AS QUAD , BYREF peUse AS LONG ) AS LONG
DECLARE FUNCTION LookupAccountSidLocalW LIB "advapi32.dll" ALIAS "LookupAccountSidLocalW" ( BYVAL Sid AS SID PTR
 , BYREF Name AS WSTRINGZ
 , BYREF cchName AS DWORD
 , BYREF ReferencedDomainName AS WSTRINGZ
 , BYREF cchReferencedDomainName AS DWORD
 , BYREF peUse AS LONG
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO LookupAccountSidLocal = LookupAccountSidLocalW
#ELSE
 MACRO LookupAccountSidLocal = LookupAccountSidLocalA
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION LookupAccountNameA LIB "AdvApi32.dll" ALIAS "LookupAccountNameA" (lpSystemName AS ASCIIZ, lpAccountName AS ASCIIZ, pSid AS SID, cbSid AS QUAD, ReferencedDomainName AS ASCIIZ, cbReferencedDomainName AS QUAD, peUse AS LONG) AS LONG
#ELSE
DECLARE FUNCTION LookupAccountNameA LIB "advapi32.dll" ALIAS "LookupAccountNameA" ( BYREF lpSystemName AS ASCIIZ , BYREF lpAccountName AS ASCIIZ , BYREF Sid AS ANY , BYREF cbSid AS QUAD , BYREF ReferencedDomainName AS ASCIIZ , BYREF cchReferencedDomainName AS QUAD , BYREF peUse AS LONG ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION LookupAccountNameW LIB "AdvApi32.dll" ALIAS "LookupAccountNameW" (lpSystemName AS WSTRINGZ, lpAccountName AS WSTRINGZ, pSid AS SID, cbSid AS QUAD, ReferencedDomainName AS WSTRINGZ, cbReferencedDomainName AS QUAD, peUse AS LONG) AS LONG
#ELSE
DECLARE FUNCTION LookupAccountNameW LIB "advapi32.dll" ALIAS "LookupAccountNameW" ( BYREF lpSystemName AS WSTRINGZ , BYREF lpAccountName AS WSTRINGZ , BYREF Sid AS ANY , BYREF cbSid AS QUAD , BYREF ReferencedDomainName AS WSTRINGZ , BYREF cchReferencedDomainName AS QUAD , BYREF peUse AS LONG ) AS LONG
#ENDIF
#IF %DEF(%UNICODE)
 MACRO LookupAccountName = LookupAccountNameW
#ELSE
 MACRO LookupAccountName = LookupAccountNameA
#ENDIF
DECLARE FUNCTION LookupAccountNameLocalA LIB "advapi32.dll" ALIAS "LookupAccountNameLocalA" ( BYREF lpAccountName AS ASCIIZ , BYREF Sid AS ANY , BYREF cbSid AS QUAD , BYREF ReferencedDomainName AS ASCIIZ , BYREF cchReferencedDomainName AS QUAD , BYREF peUse AS LONG ) AS LONG
DECLARE FUNCTION LookupAccountNameLocalW LIB "advapi32.dll" ALIAS "LookupAccountNameLocalW" ( BYREF lpAccountName AS WSTRINGZ
 , BYREF Sid AS ANY
 , BYREF cbSid AS DWORD
 , BYREF ReferencedDomainName AS WSTRINGZ
 , BYREF cchReferencedDomainName AS DWORD
 , BYREF peUse AS LONG
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO LookupAccountNameLocal = LookupAccountNameLocalW
#ELSE
 MACRO LookupAccountNameLocal = LookupAccountNameLocalA
#ENDIF
DECLARE FUNCTION LookupPrivilegeValueA LIB "advapi32.dll" ALIAS "LookupPrivilegeValueA" ( BYREF lpSystemName AS ASCIIZ , BYREF lpName AS ASCIIZ , BYREF lpLuid AS ANY ) AS LONG
DECLARE FUNCTION LookupPrivilegeValueW LIB "advapi32.dll" ALIAS "LookupPrivilegeValueW" ( BYREF lpSystemName AS WSTRINGZ
 , BYREF lpName AS WSTRINGZ
 , BYREF lpLuid AS ANY
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO LookupPrivilegeValue = LookupPrivilegeValueW
#ELSE
 MACRO LookupPrivilegeValue = LookupPrivilegeValueA
#ENDIF
DECLARE FUNCTION LookupPrivilegeNameA LIB "advapi32.dll" ALIAS "LookupPrivilegeNameA" ( BYREF lpSystemName AS ASCIIZ , BYREF lpLuid AS ANY , BYREF lpName AS ASCIIZ , BYREF cchName AS QUAD ) AS LONG
DECLARE FUNCTION LookupPrivilegeNameW LIB "advapi32.dll" ALIAS "LookupPrivilegeNameW" ( BYREF lpSystemName AS WSTRINGZ
 , BYREF lpLuid AS ANY
 , BYREF lpName AS WSTRINGZ
 , BYREF cchName AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO LookupPrivilegeName = LookupPrivilegeNameW
#ELSE
 MACRO LookupPrivilegeName = LookupPrivilegeNameA
#ENDIF
DECLARE FUNCTION LookupPrivilegeDisplayNameA LIB "advapi32.dll" ALIAS "LookupPrivilegeDisplayNameA" ( BYREF lpSystemName AS ASCIIZ , BYREF lpName AS ASCIIZ , BYREF lpDisplayName AS ASCIIZ , BYREF cchDisplayName AS QUAD , BYREF lpLanguageId AS QUAD ) AS LONG
DECLARE FUNCTION LookupPrivilegeDisplayNameW LIB "advapi32.dll" ALIAS "LookupPrivilegeDisplayNameW" ( BYREF lpSystemName AS WSTRINGZ
 , BYREF lpName AS WSTRINGZ
 , BYREF lpDisplayName AS WSTRINGZ
 , BYREF cchDisplayName AS DWORD
 , BYREF lpLanguageId AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO LookupPrivilegeDisplayName = LookupPrivilegeDisplayNameW
#ELSE
 MACRO LookupPrivilegeDisplayName = LookupPrivilegeDisplayNameA
#ENDIF
DECLARE FUNCTION AllocateLocallyUniqueId LIB "advapi32.dll" ALIAS "AllocateLocallyUniqueId" ( BYREF Luid AS ANY ) AS LONG
DECLARE FUNCTION BuildCommDCBA LIB "kernel32.dll" ALIAS "BuildCommDCBA" ( BYREF lpDef AS ASCIIZ
 , BYREF lpDCB AS DCB
 ) AS LONG
DECLARE FUNCTION BuildCommDCBW LIB "kernel32.dll" ALIAS "BuildCommDCBW" ( BYREF lpDef AS WSTRINGZ
 , BYREF lpDCB AS DCB
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO BuildCommDCB = BuildCommDCBW
#ELSE
 MACRO BuildCommDCB = BuildCommDCBA
#ENDIF
DECLARE FUNCTION BuildCommDCBAndTimeoutsA LIB "kernel32.dll" ALIAS "BuildCommDCBAndTimeoutsA" ( BYREF lpDef AS ASCIIZ , BYREF lpDCB AS DCB , BYREF lpCommTimeouts AS COMMTIMEOUTS ) AS LONG
DECLARE FUNCTION BuildCommDCBAndTimeoutsW LIB "kernel32.dll" ALIAS "BuildCommDCBAndTimeoutsW" ( BYREF lpDef AS WSTRINGZ
 , BYREF lpDCB AS DCB
 , BYREF lpCommTimeouts AS COMMTIMEOUTS
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO BuildCommDCBAndTimeouts = BuildCommDCBAndTimeoutsW
#ELSE
 MACRO BuildCommDCBAndTimeouts = BuildCommDCBAndTimeoutsA
#ENDIF
DECLARE FUNCTION CommConfigDialogA LIB "kernel32.dll" ALIAS "CommConfigDialogA" ( BYREF lpszName AS ASCIIZ , BYVAL hWnd AS QUAD , BYREF lpCC AS COMMCONFIG ) AS LONG
DECLARE FUNCTION CommConfigDialogW LIB "kernel32.dll" ALIAS "CommConfigDialogW" ( BYREF lpszName AS WSTRINGZ
 , BYVAL hWnd AS DWORD
 , BYREF lpCC AS COMMCONFIG
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO CommConfigDialog = CommConfigDialogW
#ELSE
 MACRO CommConfigDialog = CommConfigDialogA
#ENDIF
DECLARE FUNCTION GetDefaultCommConfigA LIB "kernel32.dll" ALIAS "GetDefaultCommConfigA" ( BYREF lpszName AS ASCIIZ , BYREF lpCC AS COMMCONFIG , BYREF lpdwSize AS QUAD ) AS LONG
DECLARE FUNCTION GetDefaultCommConfigW LIB "kernel32.dll" ALIAS "GetDefaultCommConfigW" ( BYREF lpszName AS WSTRINGZ
 , BYREF lpCC AS COMMCONFIG
 , BYREF lpdwSize AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO GetDefaultCommConfig = GetDefaultCommConfigW
#ELSE
 MACRO GetDefaultCommConfig = GetDefaultCommConfigA
#ENDIF
DECLARE FUNCTION SetDefaultCommConfigA LIB "kernel32.dll" ALIAS "SetDefaultCommConfigA" ( BYREF lpszName AS ASCIIZ , BYREF lpCC AS COMMCONFIG , BYVAL dwSize AS QUAD ) AS LONG
DECLARE FUNCTION SetDefaultCommConfigW LIB "kernel32.dll" ALIAS "SetDefaultCommConfigW" ( BYREF lpszName AS WSTRINGZ
 , BYREF lpCC AS COMMCONFIG
 , BYVAL dwSize AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SetDefaultCommConfig = SetDefaultCommConfigW
#ELSE
 MACRO SetDefaultCommConfig = SetDefaultCommConfigA
#ENDIF
%EQUATE `MAX_COMPUTERNAME_LENGTH = 15
DECLARE FUNCTION GetComputerNameA LIB "kernel32.dll" ALIAS "GetComputerNameA" ( BYREF lpBuffer AS ASCIIZ , BYREF nSize AS QUAD ) AS LONG
DECLARE FUNCTION GetComputerNameW LIB "kernel32.dll" ALIAS "GetComputerNameW" ( BYREF lpBuffer AS WSTRINGZ
 , BYREF nSize AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO GetComputerName = GetComputerNameW
#ELSE
 MACRO GetComputerName = GetComputerNameA
#ENDIF
DECLARE FUNCTION SetComputerNameA LIB "kernel32.dll" ALIAS "SetComputerNameA" ( BYREF lpComputerName AS ASCIIZ ) AS LONG
DECLARE FUNCTION SetComputerNameW LIB "kernel32.dll" ALIAS "SetComputerNameW" ( BYREF lpComputerName AS WSTRINGZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SetComputerName = SetComputerNameW
#ELSE
 MACRO SetComputerName = SetComputerNameA
#ENDIF
'#if (_WIN32_WINNT >= 0x0500)
' COMPUTER_NAME_FORMAT enum
%EQUATE `ComputerNameNetBIOS = 0
%EQUATE `ComputerNameDnsHostname = 1
%EQUATE `ComputerNameDnsDomain = 2
%EQUATE `ComputerNameDnsFullyQualified = 3
%EQUATE `ComputerNamePhysicalNetBIOS = 4
%EQUATE `ComputerNamePhysicalDnsHostname = 5
%EQUATE `ComputerNamePhysicalDnsDomain = 6
%EQUATE `ComputerNamePhysicalDnsFullyQualified = 7
%EQUATE `ComputerNameMax = 8
DECLARE FUNCTION GetComputerNameExA LIB "kernel32.dll" ALIAS "GetComputerNameExA" ( BYVAL NameType AS LONG , BYREF lpBuffer AS ASCIIZ , BYREF nSize AS QUAD ) AS LONG
DECLARE FUNCTION GetComputerNameExW LIB "kernel32.dll" ALIAS "GetComputerNameExW" ( BYVAL NameType AS LONG
 , BYREF lpBuffer AS WSTRINGZ
 , BYREF nSize AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO GetComputerNameEx = GetComputerNameExW
#ELSE
 MACRO GetComputerNameEx = GetComputerNameExA
#ENDIF
DECLARE FUNCTION SetComputerNameExA LIB "kernel32.dll" ALIAS "SetComputerNameExA" ( BYVAL NameType AS LONG , BYREF lpBuffer AS ASCIIZ ) AS LONG
DECLARE FUNCTION SetComputerNameExW LIB "kernel32.dll" ALIAS "SetComputerNameExW" ( BYVAL NameType AS LONG
 , BYREF lpBuffer AS WSTRINGZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SetComputerNameEx = SetComputerNameExW
#ELSE
 MACRO SetComputerNameEx = SetComputerNameExA
#ENDIF
DECLARE FUNCTION DnsHostnameToComputerNameA LIB "kernel32.dll" ALIAS "DnsHostnameToComputerNameA" ( BYREF Hostname AS ASCIIZ , BYREF ComputerName AS ASCIIZ , BYREF nSize AS QUAD ) AS LONG
DECLARE FUNCTION DnsHostnameToComputerNameW LIB "kernel32.dll" ALIAS "DnsHostnameToComputerNameW" ( BYREF Hostname AS WSTRINGZ
 , BYREF ComputerName AS WSTRINGZ
 , BYREF nSize AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO DnsHostnameToComputerName = DnsHostnameToComputerNameW
#ELSE
 MACRO DnsHostnameToComputerName = DnsHostnameToComputerNameA
#ENDIF
'#endif // _WIN32_WINNT
DECLARE FUNCTION GetUserNameA LIB "advapi32.dll" ALIAS "GetUserNameA" ( BYREF lpBuffer AS ASCIIZ , BYREF pcbBuffer AS QUAD ) AS LONG
DECLARE FUNCTION GetUserNameW LIB "advapi32.dll" ALIAS "GetUserNameW" ( BYREF lpBuffer AS WSTRINGZ
 , BYREF pcbBuffer AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO GetUserName = GetUserNameW
#ELSE
 MACRO GetUserName = GetUserNameA
#ENDIF
'//
'// Logon Support APIs
'//
%EQUATE `LOGON32_LOGON_INTERACTIVE = 2
%EQUATE `LOGON32_LOGON_NETWORK = 3
%EQUATE `LOGON32_LOGON_BATCH = 4
%EQUATE `LOGON32_LOGON_SERVICE = 5
%EQUATE `LOGON32_LOGON_UNLOCK = 7
'#if(_WIN32_WINNT >= 0x0500)
%EQUATE `LOGON32_LOGON_NETWORK_CLEARTEXT = 8
%EQUATE `LOGON32_LOGON_NEW_CREDENTIALS = 9
'#endif // (_WIN32_WINNT >= 0x0500)
'#define LOGON32_PROVIDER_DEFAULT 0
'#define LOGON32_PROVIDER_WINNT35 1
'#if(_WIN32_WINNT >= 0x0400)
'#define LOGON32_PROVIDER_WINNT40 2
'#endif /* _WIN32_WINNT >= 0x0400 */
'#if(_WIN32_WINNT >= 0x0500)
'#define LOGON32_PROVIDER_WINNT50 3
'#endif // (_WIN32_WINNT >= 0x0500)
'#if(_WIN32_WINNT >= 0x0600)
'#define LOGON32_PROVIDER_VIRTUAL 4
'#endif // (_WIN32_WINNT >= 0x0600)
%EQUATE `LOGON32_PROVIDER_DEFAULT = 0
%EQUATE `LOGON32_PROVIDER_WINNT35 = 1
%EQUATE `LOGON32_PROVIDER_WINNT40 = 2
%EQUATE `LOGON32_PROVIDER_WINNT50 = 3
%EQUATE `LOGON32_PROVIDER_VIRTUAL = 4
DECLARE FUNCTION LogonUserA LIB "advapi32.dll" ALIAS "LogonUserA" ( BYREF lpszUsername AS ASCIIZ , BYREF lpszDomain AS ASCIIZ , BYREF lpszPassword AS ASCIIZ , BYVAL dwLogonType AS QUAD , BYVAL dwLogonProvider AS QUAD , BYREF phToken AS QUAD ) AS LONG
DECLARE FUNCTION LogonUserW LIB "advapi32.dll" ALIAS "LogonUserW" ( BYREF lpszUsername AS WSTRINGZ
 , BYREF lpszDomain AS WSTRINGZ
 , BYREF lpszPassword AS WSTRINGZ
 , BYVAL dwLogonType AS DWORD
 , BYVAL dwLogonProvider AS DWORD
 , BYREF phToken AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO LogonUser = LogonUserW
#ELSE
 MACRO LogonUser = LogonUserA
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION LogonUserExA LIB "AdvApi32.dll" ALIAS "LogonUserExA" (lpszUsername AS ASCIIZ, lpszDomain AS ASCIIZ, lpszPassword AS ASCIIZ, BYVAL dwLogonType AS QUAD, BYVAL dwLogonProvider AS QUAD, phToken AS QUAD, ppLogonSid AS QUAD, ppProfileBuffer AS QUAD, pdwProfileLength AS QUAD, pQuotaLimits AS QUOTA_LIMITS) AS LONG
#ELSE
DECLARE FUNCTION LogonUserExA LIB "advapi32.dll" ALIAS "LogonUserExA" ( BYREF lpszUsername AS ASCIIZ , BYREF lpszDomain AS ASCIIZ , BYREF lpszPassword AS ASCIIZ , BYVAL dwLogonType AS QUAD , BYVAL dwLogonProvider AS QUAD , BYREF phToken AS QUAD , BYREF ppLogonSid AS ANY , BYREF ppProfileBuffer AS ANY , BYREF pdwProfileLength AS QUAD , BYREF pQuotaLimits AS QUOTA_LIMITS ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION LogonUserExW LIB "AdvApi32.dll" ALIAS "LogonUserExW" (lpszUsername AS WSTRINGZ, lpszDomain AS WSTRINGZ, lpszPassword AS WSTRINGZ, BYVAL dwLogonType AS QUAD, BYVAL dwLogonProvider AS QUAD, phToken AS QUAD, ppLogonSid AS QUAD, ppProfileBuffer AS QUAD, pdwProfileLength AS QUAD, pQuotaLimits AS QUOTA_LIMITS) AS LONG
#ELSE
DECLARE FUNCTION LogonUserExW LIB "advapi32.dll" ALIAS "LogonUserExW" ( BYREF lpszUsername AS WSTRINGZ , BYREF lpszDomain AS WSTRINGZ , BYREF lpszPassword AS WSTRINGZ , BYVAL dwLogonType AS QUAD , BYVAL dwLogonProvider AS QUAD , BYREF phToken AS QUAD , BYREF ppLogonSid AS ANY , BYREF ppProfileBuffer AS ANY , BYREF pdwProfileLength AS QUAD , BYREF pQuotaLimits AS QUOTA_LIMITS ) AS LONG
#ENDIF
#IF %DEF(%UNICODE)
 MACRO LogonUserEx = LogonUserExW
#ELSE
 MACRO LogonUserEx = LogonUserExA
#ENDIF
DECLARE FUNCTION ImpersonateLoggedOnUser LIB "advapi32.dll" ALIAS "ImpersonateLoggedOnUser" ( BYVAL hToken AS QUAD ) AS LONG
DECLARE FUNCTION CreateProcessAsUserA LIB "advapi32.dll" ALIAS "CreateProcessAsUserA" ( BYVAL hToken AS QUAD
 , BYREF lpApplicationName AS ASCIIZ
 , BYREF lpCommandLine AS ASCIIZ
 , BYREF lpProcessAttributes AS SECURITY_ATTRIBUTES
 , BYREF lpThreadAttributes AS SECURITY_ATTRIBUTES
 , BYVAL bInheritHandles AS LONG
 , BYVAL dwCreationFlags AS DWORD
 , BYVAL lpEnvironment AS DWORD
 , BYREF lpCurrentDirectory AS ASCIIZ
 , BYREF lpStartupInfo AS STARTUPINFOA
 , BYREF lpProcessInformation AS PROCESS_INFORMATION
 ) AS LONG
DECLARE FUNCTION CreateProcessAsUserW LIB "advapi32.dll" ALIAS "CreateProcessAsUserW" ( BYVAL hToken AS DWORD
 , BYREF lpApplicationName AS WSTRINGZ
 , BYREF lpCommandLine AS WSTRINGZ
 , BYREF lpProcessAttributes AS SECURITY_ATTRIBUTES
 , BYREF lpThreadAttributes AS SECURITY_ATTRIBUTES
 , BYVAL bInheritHandles AS LONG
 , BYVAL dwCreationFlags AS DWORD
 , BYVAL lpEnvironment AS DWORD
 , BYREF lpCurrentDirectory AS WSTRINGZ
 , BYREF lpStartupInfo AS STARTUPINFOW
 , BYREF lpProcessInformation AS PROCESS_INFORMATION
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO CreateProcessAsUser = CreateProcessAsUserW
#ELSE
 MACRO CreateProcessAsUser = CreateProcessAsUserA
#ENDIF
'#if(_WIN32_WINNT >= 0x0500)
'//
'// LogonFlags
'//
%EQUATE `LOGON_WITH_PROFILE = &H00000001
%EQUATE `LOGON_NETCREDENTIALS_ONLY = &H00000002
%EQUATE `LOGON_ZERO_PASSWORD_BUFFER = &H80000000
DECLARE FUNCTION CreateProcessWithLogonW LIB "advapi32.dll" ALIAS "CreateProcessWithLogonW" ( BYREF lpUsername AS WSTRINGZ , BYREF lpDomain AS WSTRINGZ , BYREF lpPassword AS WSTRINGZ , BYVAL dwLogonFlags AS QUAD , BYREF lpApplicationName AS WSTRINGZ , BYREF lpCommandLine AS WSTRINGZ , BYVAL dwCreationFlags AS QUAD , BYVAL lpEnvironment AS QUAD , BYREF lpCurrentDirectory AS WSTRINGZ , BYREF lpStartupInfo AS STARTUPINFOW , BYREF lpProcessInformation AS PROCESS_INFORMATION ) AS LONG
MACRO CreateProcessWithLogon = CreateProcessWithLogonW
DECLARE FUNCTION CreateProcessWithTokenW LIB "advapi32.dll" ALIAS "CreateProcessWithTokenW" ( BYVAL hToken AS QUAD , BYVAL dwLogonFlags AS QUAD , BYREF lpApplicationName AS WSTRINGZ , BYREF lpCommandLine AS WSTRINGZ , BYVAL dwCreationFlags AS QUAD , BYVAL lpEnvironment AS QUAD , BYREF lpCurrentDirectory AS WSTRINGZ , BYREF lpStartupInfo AS STARTUPINFOW , BYREF lpProcessInformation AS PROCESS_INFORMATION ) AS LONG
MACRO CreateProcessWithToken = CreateProcessWithTokenW
'#endif // (_WIN32_WINNT >= 0x0500)
DECLARE FUNCTION ImpersonateAnonymousToken LIB "advapi32.dll" ALIAS "ImpersonateAnonymousToken" ( BYVAL ThreadHandle AS QUAD ) AS LONG
DECLARE FUNCTION DuplicateTokenEx LIB "advapi32.dll" ALIAS "DuplicateTokenEx" ( BYVAL hExistingToken AS QUAD
 , BYVAL dwDesiredAccess AS DWORD
 , BYREF lpTokenAttributes AS SECURITY_ATTRIBUTES
 , BYVAL ImpersonationLevel AS LONG
 , BYVAL TokenType AS LONG
 , BYREF phNewToken AS DWORD
 ) AS LONG
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION CreateRestrictedToken LIB "AdvApi32.dll" ALIAS "CreateRestrictedToken" (BYVAL ExistingTokenHandle AS QUAD, BYVAL Flags AS QUAD, BYVAL DisableSidCount AS QUAD, BYVAL SidsToDisable AS SID_AND_ATTRIBUTES PTR, BYVAL DeletePrivilegeCount AS QUAD, BYVAL PrivilegesToDelete AS LUID_AND_ATTRIBUTES PTR, BYVAL RestrictedSidCount AS QUAD, BYVAL SidsToRestrict AS SID_AND_ATTRIBUTES PTR, NewTokenHandle AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION CreateRestrictedToken LIB "advapi32.dll" ALIAS "CreateRestrictedToken" ( BYVAL ExistingTokenHandle AS QUAD , BYVAL Flags AS QUAD , BYVAL DisableSidCount AS QUAD , BYREF SidsToDisable AS SID_AND_ATTRIBUTES , BYVAL DeletePrivilegeCount AS QUAD , BYREF PrivilegesToDelete AS LUID_AND_ATTRIBUTES , BYVAL RestrictedSidCount AS QUAD , BYREF SidsToRestrict AS SID_AND_ATTRIBUTES , BYREF NewTokenHandle AS QUAD ) AS LONG
#ENDIF
DECLARE FUNCTION IsTokenRestricted LIB "advapi32.dll" ALIAS "IsTokenRestricted" ( BYVAL TokenHandle AS QUAD ) AS LONG
DECLARE FUNCTION IsTokenUntrusted LIB "advapi32.dll" ALIAS "IsTokenUntrusted" ( BYVAL TokenHandle AS QUAD
 ) AS LONG
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION CheckTokenMembership LIB "AdvApi32.dll" ALIAS "CheckTokenMembership" (BYVAL hToken AS QUAD, SidToCheck AS SID, IsMember AS LONG) AS LONG
#ELSE
DECLARE FUNCTION CheckTokenMembership LIB "advapi32.dll" ALIAS "CheckTokenMembership" ( BYVAL TokenHandle AS QUAD , BYVAL SidToCheck AS SID PTR , BYREF IsMember AS LONG ) AS LONG
#ENDIF
'//
'// Thread pool API's
'//
'#if (_WIN32_WINNT >= 0x0500)
'typedef WAITORTIMERCALLBACKFUNC WAITORTIMERCALLBACK ;
DECLARE FUNCTION RegisterWaitForSingleObject LIB "kernel32.dll" ALIAS "RegisterWaitForSingleObject" ( BYREF phNewWaitObject AS QUAD , BYVAL hObject AS QUAD , BYVAL Callback AS QUAD , BYVAL Context AS QUAD , BYVAL dwMilliseconds AS QUAD , BYVAL dwFlags AS QUAD ) AS LONG
DECLARE FUNCTION RegisterWaitForSingleObjectEx LIB "kernel32.dll" ALIAS "RegisterWaitForSingleObjectEx" ( BYVAL hObject AS QUAD
 , BYVAL Callback AS DWORD
 , BYVAL Context AS DWORD
 , BYVAL dwMilliseconds AS DWORD
 , BYVAL dwFlags AS DWORD
 ) AS DWORD
DECLARE FUNCTION UnregisterWait LIB "kernel32.dll" ALIAS "UnregisterWait" ( BYVAL WaitHandle AS DWORD
 ) AS LONG
DECLARE FUNCTION UnregisterWaitEx LIB "kernel32.dll" ALIAS "UnregisterWaitEx" ( BYVAL WaitHandle AS DWORD
 , OPTIONAL BYVAL CompletionEvent AS DWORD
 ) AS LONG
DECLARE FUNCTION QueueUserWorkItem LIB "kernel32.dll" ALIAS "QueueUserWorkItem" ( BYVAL Function AS DWORD
 , BYVAL Context AS DWORD
 , BYVAL Flags AS DWORD
 ) AS LONG
DECLARE FUNCTION BindIoCompletionCallback LIB "kernel32.dll" ALIAS "BindIoCompletionCallback" ( BYVAL FileHandle AS DWORD
 , BYVAL Function AS DWORD
 , BYVAL Flags AS DWORD
 ) AS LONG
DECLARE FUNCTION CreateTimerQueue LIB "kernel32.dll" ALIAS "CreateTimerQueue" ( ) AS DWORD
DECLARE FUNCTION CreateTimerQueueTimer LIB "kernel32.dll" ALIAS "CreateTimerQueueTimer" ( BYREF phNewTimer AS DWORD
 , BYVAL TimerQueue AS DWORD
 , BYVAL Callback AS DWORD
 , BYVAL Parameter AS DWORD
 , BYVAL DueTime AS DWORD
 , BYVAL Period AS DWORD
 , BYVAL Flags AS DWORD
 ) AS LONG
DECLARE FUNCTION ChangeTimerQueueTimer LIB "kernel32.dll" ALIAS "ChangeTimerQueueTimer" ( BYVAL TimerQueue AS DWORD
 , BYVAL Timer AS DWORD
 , BYVAL DueTime AS DWORD
 , BYVAL Period AS DWORD
 ) AS LONG
DECLARE FUNCTION DeleteTimerQueueTimer LIB "kernel32.dll" ALIAS "DeleteTimerQueueTimer" ( BYVAL TimerQueue AS DWORD
 , BYVAL Timer AS DWORD
 , BYVAL CompletionEvent AS DWORD
 ) AS LONG
DECLARE FUNCTION DeleteTimerQueueEx LIB "kernel32.dll" ALIAS "DeleteTimerQueueEx" ( BYVAL TimerQueue AS DWORD
 , BYVAL CompletionEvent AS DWORD
 ) AS LONG
DECLARE FUNCTION SetTimerQueueTimer LIB "kernel32.dll" ALIAS "SetTimerQueueTimer" ( BYVAL TimerQueue AS DWORD
 , BYVAL Callback AS DWORD
 , BYVAL Parameter AS DWORD
 , BYVAL DueTime AS DWORD
 , BYVAL Period AS DWORD
 , BYVAL PreferIo AS LONG
 ) AS DWORD
DECLARE FUNCTION CancelTimerQueueTimer LIB "kernel32.dll" ALIAS "CancelTimerQueueTimer" ( BYVAL TimerQueue AS DWORD
 , BYVAL Timer AS DWORD
 ) AS LONG
DECLARE FUNCTION DeleteTimerQueue LIB "kernel32.dll" ALIAS "DeleteTimerQueue" ( BYVAL TimerQueue AS DWORD
 ) AS LONG
'#endif // _WIN32_WINNT
'#if (_WIN32_WINNT >= 0x0600)
'typedef VOID (WINAPI *PTP_WIN32_IO_CALLBACK)(
' );
DECLARE FUNCTION CreateThreadpool LIB "kernel32.dll" ALIAS "CreateThreadpool" ( BYVAL reserved AS QUAD ) AS QUAD ' PTP_POOL
DECLARE SUB SetThreadpoolThreadMaximum LIB "kernel32.dll" ALIAS "SetThreadpoolThreadMaximum" ( BYVAL ptpp AS QUAD , BYVAL cthrdMost AS QUAD ) ' void
DECLARE FUNCTION SetThreadpoolThreadMinimum LIB "kernel32.dll" ALIAS "SetThreadpoolThreadMinimum" ( BYVAL ptpp AS QUAD , BYVAL cthrdMic AS QUAD ) AS LONG
DECLARE FUNCTION SetThreadpoolStackInformation LIB "kernel32.dll" ALIAS "SetThreadpoolStackInformation" ( BYVAL ptpp AS QUAD
 , BYREF ptpsi AS TP_POOL_STACK_INFORMATION
 ) AS LONG
DECLARE FUNCTION QueryThreadpoolStackInformation LIB "kernel32.dll" ALIAS "QueryThreadpoolStackInformation" ( BYVAL ptpp AS DWORD
 , BYREF ptpsi AS TP_POOL_STACK_INFORMATION
 ) AS LONG
DECLARE SUB CloseThreadpool LIB "kernel32.dll" ALIAS "CloseThreadpool" ( BYVAL ptpp AS DWORD
 ) ' void
DECLARE FUNCTION CreateThreadpoolCleanupGroup LIB "kernel32.dll" ALIAS "CreateThreadpoolCleanupGroup" ( ) AS QUAD ' PTP_CLEANUP_GROUP
DECLARE SUB CloseThreadpoolCleanupGroup LIB "kernel32.dll" ALIAS "CloseThreadpoolCleanupGroup" ( BYVAL ptpcg AS QUAD ) ' void
'FORCEINLINE
'InitializeThreadpoolEnvironment(
' )
'{
' TpInitializeCallbackEnviron(pcbe);
'}
MACRO InitializeThreadpoolEnvironment (pcbe)
 TpInitializeCallbackEnviron(pcbe)
END MACRO
'FORCEINLINE
'SetThreadpoolCallbackPool(
' )
'{
' TpSetCallbackThreadpool(pcbe, ptpp);
'}
MACRO SetThreadpoolCallbackPool (pcbe, ptpp)
 TpSetCallbackThreadpool(pcbe, ptpp)
END MACRO
'FORCEINLINE
'SetThreadpoolCallbackCleanupGroup(
' )
'{
' TpSetCallbackCleanupGroup(pcbe, ptpcg, pfng);
'}
MACRO SetThreadpoolCallbackCleanupGroup (pcbe, ptpcg, pfng)
 TpSetCallbackCleanupGroup(pcbe, ptpcg, pfng)
END MACRO
'FORCEINLINE
'SetThreadpoolCallbackRunsLong(
' )
'{
' TpSetCallbackLongFunction(pcbe);
'}
MACRO SetThreadpoolCallbackRunsLong (pcbe)
 TpSetCallbackLongFunction(pcbe)
END MACRO
'FORCEINLINE
'SetThreadpoolCallbackLibrary(
' )
'{
' TpSetCallbackRaceWithDll(pcbe, mod);
'}
MACRO SetThreadpoolCallbackLibrary (pcbe, xmod)
 TpSetCallbackRaceWithDll(pcbe, xmod)
END MACRO
'#if (_WIN32_WINNT >= _WIN32_WINNT_WIN7)
#IF %WINVER >= &H0601
'FORCEINLINE
'SetThreadpoolCallbackPriority(
' )
'{
' TpSetCallbackPriority(pcbe, Priority);
'}
MACRO SetThreadpoolCallbackPriority (pcbe, nPriority)
 TpSetCallbackPriority(pcbe, nPriority)
END MACRO
#ENDIF
'FORCEINLINE
'SetThreadpoolCallbackPersistent(
' )
'{
' TpSetCallbackPersistent(pcbe);
'}
MACRO SetThreadpoolCallbackPersistent (pcbe)
 TpSetCallbackPersistent(pcbe)
END MACRO
'FORCEINLINE
'DestroyThreadpoolEnvironment(
' )
'{
' TpDestroyCallbackEnviron(pcbe);
'}
MACRO DestroyThreadpoolEnvironment (pcbe)
 TpDestroyCallbackEnviron(pcbe)
END MACRO
DECLARE SUB SetEventWhenCallbackReturns LIB "kernel32.dll" ALIAS "SetEventWhenCallbackReturns" ( BYVAL pci AS QUAD , BYVAL evt AS QUAD ) ' void
DECLARE SUB ReleaseSemaphoreWhenCallbackReturns LIB "kernel32.dll" ALIAS "ReleaseSemaphoreWhenCallbackReturns" ( BYVAL pci AS QUAD , BYVAL sem AS QUAD , BYVAL crel AS QUAD ) ' void
DECLARE SUB ReleaseMutexWhenCallbackReturns LIB "kernel32.dll" ALIAS "ReleaseMutexWhenCallbackReturns" ( BYVAL pci AS QUAD , BYVAL mut AS QUAD ) ' void
DECLARE SUB LeaveCriticalSectionWhenCallbackReturns LIB "kernel32.dll" ALIAS "LeaveCriticalSectionWhenCallbackReturns" ( BYVAL pci AS QUAD , BYREF pcs AS CRITICAL_SECTION ) ' void
DECLARE SUB FreeLibraryWhenCallbackReturns LIB "kernel32.dll" ALIAS "FreeLibraryWhenCallbackReturns" ( BYVAL pci AS QUAD , BYVAL mod AS QUAD ) ' void
DECLARE FUNCTION CallbackMayRunLong LIB "kernel32.dll" ALIAS "CallbackMayRunLong" ( BYVAL pci AS QUAD ) AS LONG
DECLARE SUB DisassociateCurrentThreadFromCallback LIB "kernel32.dll" ALIAS "DisassociateCurrentThreadFromCallback" ( BYVAL pci AS QUAD
 ) ' void
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION TrySubmitThreadpoolCallback LIB "Kernel32.dll" ALIAS "TrySubmitThreadpoolCallback" (BYVAL pfns AS QUAD, BYVAL pv AS QUAD, BYVAL pcbe AS QUAD) AS LONG
#ELSE
DECLARE SUB TrySubmitThreadpoolCallback LIB "kernel32.dll" ALIAS "TrySubmitThreadpoolCallback" ( BYVAL pfns AS QUAD , BYREF pv AS ANY , BYREF pcbe AS TP_CALLBACK_ENVIRON ) ' void
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION CreateThreadpoolWork LIB "Kernel32.dll" ALIAS "CreateThreadpoolWork" (BYVAL pfnwk AS QUAD, BYVAL pv AS QUAD, BYVAL pcbe AS QUAD) AS QUAD
#ELSE
DECLARE FUNCTION CreateThreadpoolWork LIB "kernel32.dll" ALIAS "CreateThreadpoolWork" ( BYVAL pfnwk AS QUAD , BYREF pv AS ANY , BYREF pcbe AS TP_CALLBACK_ENVIRON ) AS QUAD ' PTP_WORK
#ENDIF
DECLARE SUB SubmitThreadpoolWork LIB "kernel32.dll" ALIAS "SubmitThreadpoolWork" ( BYVAL pwk AS QUAD ) ' void
DECLARE SUB WaitForThreadpoolWorkCallbacks LIB "kernel32.dll" ALIAS "WaitForThreadpoolWorkCallbacks" ( BYVAL pwk AS QUAD , BYVAL fCancelPendingCallbacks AS LONG ) ' void
DECLARE SUB CloseThreadpoolWork LIB "kernel32.dll" ALIAS "CloseThreadpoolWork" ( BYVAL pwk AS QUAD ) ' void
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION CreateThreadpoolTimer LIB "Kernel32.dll" ALIAS "CreateThreadpoolTimer" (BYVAL pfnit AS QUAD, BYVAL pv AS QUAD, BYVAL pcbe AS QUAD) AS QUAD
#ELSE
DECLARE FUNCTION CreateThreadpoolTimer LIB "kernel32.dll" ALIAS "CreateThreadpoolTimer" ( BYVAL pfnti AS QUAD , BYREF pv AS ANY , BYREF pcbe AS TP_CALLBACK_ENVIRON ) AS QUAD ' PTP_TIMER
#ENDIF
DECLARE SUB SetThreadpoolTimer LIB "kernel32.dll" ALIAS "SetThreadpoolTimer" ( BYVAL pti AS QUAD , BYREF pftDueTime AS FILETIME , BYVAL msPeriod AS QUAD , BYVAL msWindowLength AS QUAD ) ' void
DECLARE FUNCTION IsThreadpoolTimerSet LIB "kernel32.dll" ALIAS "IsThreadpoolTimerSet" ( BYVAL pti AS QUAD ) AS LONG
DECLARE SUB WaitForThreadpoolTimerCallbacks LIB "kernel32.dll" ALIAS "WaitForThreadpoolTimerCallbacks" ( BYVAL pti AS QUAD
 , BYVAL fCancelPendingCallbacks AS LONG
 ) ' void
DECLARE SUB CloseThreadpoolTimer LIB "kernel32.dll" ALIAS "CloseThreadpoolTimer" ( BYVAL pti AS QUAD ) ' void
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION CreateThreadpoolWait LIB "Kernel32.dll" ALIAS "CreateThreadpoolWait" (BYVAL pfnwa AS QUAD, BYVAL pv AS QUAD, BYVAL pcbe AS QUAD) AS QUAD
#ELSE
DECLARE FUNCTION CreateThreadpoolWait LIB "kernel32.dll" ALIAS "CreateThreadpoolWait" ( BYVAL pfnwa AS QUAD , BYREF pv AS ANY , BYREF pcbe AS TP_CALLBACK_ENVIRON ) AS QUAD ' PTP_WAIT
#ENDIF
DECLARE SUB SetThreadpoolWait LIB "kernel32.dll" ALIAS "SetThreadpoolWait" ( BYVAL pwa AS QUAD , BYVAL h AS QUAD , BYREF pftTimeout AS FILETIME ) ' void
DECLARE SUB WaitForThreadpoolWaitCallbacks LIB "kernel32.dll" ALIAS "WaitForThreadpoolWaitCallbacks" ( BYVAL pwa AS QUAD , BYVAL fCancelPendingCallbacks AS LONG ) ' void
DECLARE SUB CloseThreadpoolWait LIB "kernel32.dll" ALIAS "CloseThreadpoolWait" ( BYVAL pwa AS QUAD ) ' void
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION CreateThreadpoolIo LIB "Kernel32.dll" ALIAS "CreateThreadpoolIo" (BYVAL fl AS QUAD, BYVAL pfnio AS QUAD, BYVAL pv AS QUAD, pbce AS TP_CALLBACK_ENVIRON) AS QUAD
#ELSE
DECLARE FUNCTION CreateThreadpoolIo LIB "kernel32.dll" ALIAS "CreateThreadpoolIo" ( BYVAL fl AS QUAD , BYVAL pfnio AS QUAD , BYREF pv AS ANY , BYREF pcbe AS TP_CALLBACK_ENVIRON ) AS QUAD ' PTP_IO
#ENDIF
DECLARE SUB StartThreadpoolIo LIB "kernel32.dll" ALIAS "StartThreadpoolIo" ( BYVAL pio AS QUAD ) ' void
DECLARE SUB CancelThreadpoolIo LIB "kernel32.dll" ALIAS "CancelThreadpoolIo" ( BYVAL pio AS QUAD ) ' void
DECLARE SUB WaitForThreadpoolIoCallbacks LIB "kernel32.dll" ALIAS "WaitForThreadpoolIoCallbacks" ( BYVAL pio AS QUAD , BYVAL fCancelPendingCallbacks AS LONG ) ' void
DECLARE SUB CloseThreadpoolIo LIB "kernel32.dll" ALIAS "CloseThreadpoolIo" ( BYVAL pio AS QUAD ) ' void
'//
'// Private Namespaces support
'//
DECLARE FUNCTION CreatePrivateNamespaceA LIB "kernel32.dll" ALIAS "CreatePrivateNamespaceA" ( BYREF lpPrivateNamespaceAttributes AS SECURITY_ATTRIBUTES , BYVAL lpBoundaryDescriptor AS QUAD , BYREF lpAliasPrefix AS ASCIIZ ) AS QUAD
DECLARE FUNCTION CreatePrivateNamespaceW LIB "kernel32.dll" ALIAS "CreatePrivateNamespaceW" ( BYREF lpPrivateNamespaceAttributes AS SECURITY_ATTRIBUTES
 , BYVAL lpBoundaryDescriptor AS DWORD
 , BYREF lpAliasPrefix AS WSTRINGZ
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO CreatePrivateNamespace = CreatePrivateNamespaceW
#ELSE
 MACRO CreatePrivateNamespace = CreatePrivateNamespaceA
#ENDIF
DECLARE FUNCTION OpenPrivateNamespaceA LIB "kernel32.dll" ALIAS "OpenPrivateNamespaceA" ( BYVAL lpBoundaryDescriptor AS QUAD , BYREF lpAliasPrefix AS ASCIIZ ) AS QUAD
DECLARE FUNCTION OpenPrivateNamespaceW LIB "kernel32.dll" ALIAS "OpenPrivateNamespaceW" ( BYVAL lpBoundaryDescriptor AS QUAD
 , BYREF lpAliasPrefix AS WSTRINGZ
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO OpenPrivateNamespace = OpenPrivateNamespaceW
#ELSE
 MACRO OpenPrivateNamespace = OpenPrivateNamespaceA
#ENDIF
%EQUATE `PRIVATE_NAMESPACE_FLAG_DESTROY = &H00000001
DECLARE FUNCTION ClosePrivateNamespace LIB "kernel32.dll" ALIAS "ClosePrivateNamespace" ( BYVAL Handle AS QUAD , BYVAL Flags AS QUAD ) AS BYTE ' BOOLEAN
'//
'// Boundary descriptors support
'//
DECLARE FUNCTION CreateBoundaryDescriptorA LIB "kernel32.dll" ALIAS "CreateBoundaryDescriptorA" ( BYREF Name AS ASCIIZ , BYVAL Flags AS QUAD ) AS QUAD
DECLARE FUNCTION CreateBoundaryDescriptorW LIB "kernel32.dll" ALIAS "CreateBoundaryDescriptorW" ( BYREF Name AS WSTRINGZ
 , BYVAL Flags AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO CreateBoundaryDescriptor = CreateBoundaryDescriptorW
#ELSE
 MACRO CreateBoundaryDescriptor = CreateBoundaryDescriptorA
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION AddSIDToBoundaryDescriptor LIB "Kernel32.dll" ALIAS "AddSIDToBoundaryDescriptor" (hBoundaryDescriptor AS QUAD, RequiredSid AS SID) AS LONG
#ELSE
DECLARE FUNCTION AddSIDToBoundaryDescriptor LIB "kernel32.dll" ALIAS "AddSIDToBoundaryDescriptor" ( BYREF BoundaryDescriptor AS QUAD , BYVAL RequiredSid AS SID PTR ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION AddIntegrityLabelToBoundaryDescriptor LIB "Kernel32.dll" ALIAS "AddIntegrityLabelToBoundaryDescriptor" ( BoundaryDescriptor AS QUAD,
 IntegrityLabel AS SID) AS LONG
#ELSE
DECLARE FUNCTION AddIntegrityLabelToBoundaryDescriptor LIB "kernel32.dll" ALIAS "AddIntegrityLabelToBoundaryDescriptor" ( BYREF BoundaryDescriptor AS QUAD , BYVAL IntegrityLabel AS SID PTR ) AS LONG
#ENDIF
DECLARE SUB DeleteBoundaryDescriptor LIB "kernel32.dll" ALIAS "DeleteBoundaryDescriptor" ( BYVAL BoundaryDescriptor AS QUAD ) ' void
'#endif // _WIN32_WINNT >= 0x0600
'#endif // _WIN32_WINNT >= 0x0500
'#if(_WIN32_WINNT >= 0x0400)
'//
'// Plug-and-Play API's
'//
%EQUATE `HW_PROFILE_GUIDLEN = 39 ' 36-characters plus NULL terminator
%EQUATE `MAX_PROFILE_LEN = 80
%EQUATE `DOCKINFO_UNDOCKED = &H1
%EQUATE `DOCKINFO_DOCKED = &H2
%EQUATE `DOCKINFO_USER_SUPPLIED = &H4
%EQUATE `DOCKINFO_USER_UNDOCKED = %DOCKINFO_USER_SUPPLIED OR %DOCKINFO_UNDOCKED
%EQUATE `DOCKINFO_USER_DOCKED = %DOCKINFO_USER_SUPPLIED OR %DOCKINFO_DOCKED
' // Size = 124 bytes
TYPE HW_PROFILE_INFOA DWORD
 dwDockInfo AS DWORD ' DWORD dwDockInfo
 szHwProfileGuid AS ASCIIZ * %HW_PROFILE_GUIDLEN ' CHAR szHwProfileGuid[HW_PROFILE_GUIDLEN]
 szHwProfileName AS ASCIIZ * %MAX_PROFILE_LEN ' CHAR szHwProfileName[MAX_PROFILE_LEN]
END TYPE
' // Size = 244 bytes
TYPE HW_PROFILE_INFOW DWORD
 dwDockInfo AS DWORD ' DWORD dwDockInfo
 szHwProfileGuid AS WSTRINGZ * %HW_PROFILE_GUIDLEN ' WCHAR szHwProfileGuid[HW_PROFILE_GUIDLEN]
 szHwProfileName AS WSTRINGZ * %MAX_PROFILE_LEN ' WCHAR szHwProfileName[MAX_PROFILE_LEN]
END TYPE
MACRO HW_PROFILE_INFO = HW_PROFILE_INFOA
DECLARE FUNCTION GetCurrentHwProfileA LIB "advapi32.dll" ALIAS "GetCurrentHwProfileA" ( BYREF lpHwProfileInfo AS HW_PROFILE_INFOA ) AS LONG
DECLARE FUNCTION GetCurrentHwProfileW LIB "advapi32.dll" ALIAS "GetCurrentHwProfileW" ( BYREF lpHwProfileInfo AS HW_PROFILE_INFOW
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO GetCurrentHwProfile = GetCurrentHwProfileW
#ELSE
 MACRO GetCurrentHwProfile = GetCurrentHwProfileA
#ENDIF
'//
'// Performance counter API's
'//
DECLARE FUNCTION QueryPerformanceCounter LIB "kernel32.dll" ALIAS "QueryPerformanceCounter" ( BYREF lpPerformanceCount AS QUAD ) AS LONG
DECLARE FUNCTION QueryPerformanceFrequency LIB "kernel32.dll" ALIAS "QueryPerformanceFrequency" ( BYREF lpFrequency AS QUAD
 ) AS LONG
' Note: Parameter declared AS ANY because it may accept both an OSVERSIONINFOA
' or OSVERSIONINFOEXA structure.
DECLARE FUNCTION GetVersionExA LIB "kernel32.dll" ALIAS "GetVersionExA" ( BYREF lpVersionInformation AS ANY ) AS LONG
' Note: Parameter declared AS ANY because it may accept both an OSVERSIONINFOW
' or OSVERSIONINFOEXW structure.
DECLARE FUNCTION GetVersionExW LIB "kernel32.dll" ALIAS "GetVersionExW" ( BYREF lpVersionInformation AS ANY ) AS LONG
#IF %DEF(%UNICODE)
 MACRO GetVersionEx = GetVersionExW
#ELSE
 MACRO GetVersionEx = GetVersionExA
#ENDIF
DECLARE FUNCTION VerifyVersionInfoA LIB "kernel32.dll" ALIAS "VerifyVersionInfoA" ( BYREF lpVersionInformation AS OSVERSIONINFOEXA , BYVAL dwTypeMask AS QUAD , BYVAL dwlConditionMask AS QUAD ) AS LONG
DECLARE FUNCTION VerifyVersionInfoW LIB "kernel32.dll" ALIAS "VerifyVersionInfoW" ( BYREF lpVersionInformation AS OSVERSIONINFOEXW
 , BYVAL dwTypeMask AS DWORD
 , BYVAL dwlConditionMask AS QUAD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO VerifyVersionInfo = VerifyVersionInfoW
#ELSE
 MACRO VerifyVersionInfo = VerifyVersionInfoA
#ENDIF
'#if (_WIN32_WINNT >= 0x0600)
#IF %WINVER >= &H0600
DECLARE FUNCTION GetProductInfo LIB "kernel32.dll" ALIAS "GetProductInfo" ( BYVAL DWORD , BYVAL DWORD , BYVAL DWORD , BYVAL DWORD , BYREF DWORD ) AS LONG
#ENDIF
'// DOS and OS/2 Compatible Error Code definitions returned by the Win32 Base
'// API functions.
'//
#INCLUDE ONCE "Legacy/Platform/WinError.inc"
'/* Abnormal termination codes */
%EQUATE `TC_NORMAL = 0
%EQUATE `TC_HARDERR = 1
%EQUATE `TC_GP_TRAP = 2
%EQUATE `TC_SIGNAL = 3
'#if(WINVER >= 0x0400)
'//
'// Power Management APIs
'//
%EQUATE `AC_LINE_OFFLINE = &H00
%EQUATE `AC_LINE_ONLINE = &H01
%EQUATE `AC_LINE_BACKUP_POWER = &H02
%EQUATE `AC_LINE_UNKNOWN = &HFF
%EQUATE `BATTERY_FLAG_HIGH = &H01
%EQUATE `BATTERY_FLAG_LOW = &H02
%EQUATE `BATTERY_FLAG_CRITICAL = &H04
%EQUATE `BATTERY_FLAG_CHARGING = &H08
%EQUATE `BATTERY_FLAG_NO_BATTERY = &H80
%EQUATE `BATTERY_FLAG_UNKNOWN = &HFF
%EQUATE `BATTERY_PERCENTAGE_UNKNOWN = &HFF
%EQUATE `BATTERY_LIFE_UNKNOWN = &HFFFFFFFF
' // Size = 12 bytes
TYPE SYSTEM_POWER_STATUS DWORD FILL
 ACLineStatus AS BYTE ' BYTE ACLineStatus
 BatteryFlag AS BYTE ' BYTE BatteryFlag
 BatteryLifePercent AS BYTE ' BYTE BatteryLifePercent
 Reserved1 AS BYTE ' BYTE Reserved1
 BatteryLifeTime AS DWORD ' DWORD BatteryLifeTime
 BatteryFullLifeTime AS DWORD ' DWORD BatteryFullLifeTime
END TYPE
DECLARE FUNCTION GetSystemPowerStatus LIB "kernel32.dll" ALIAS "GetSystemPowerStatus" ( BYREF lpSystemPowerStatus AS SYSTEM_POWER_STATUS ) AS LONG
DECLARE FUNCTION SetSystemPowerState LIB "kernel32.dll" ALIAS "SetSystemPowerState" ( BYVAL fSuspend AS LONG
 , BYVAL fForce AS LONG
 ) AS LONG
'#endif /* WINVER >= 0x0400 */
'#if (_WIN32_WINNT >= 0x0500)
'//
'// Very Large Memory API Subset
'//
DECLARE FUNCTION AllocateUserPhysicalPages LIB "kernel32.dll" ALIAS "AllocateUserPhysicalPages" ( BYVAL hProcess AS QUAD , BYREF NumberOfPages AS QUAD , BYREF PageArray AS QUAD ) AS LONG
'#if _WIN32_WINNT >= 0x0600
#IF %WINVER >= &H0600
DECLARE FUNCTION AllocateUserPhysicalPagesNuma LIB "kernel32.dll" ALIAS "AllocateUserPhysicalPagesNuma" ( BYVAL hProcess AS QUAD , BYREF NumberOfPages AS QUAD , BYREF PageArray AS QUAD , BYVAL nndPreferred AS QUAD ) AS LONG
#ENDIF ' // _WIN32_WINNT >= 0x0600
DECLARE FUNCTION FreeUserPhysicalPages LIB "kernel32.dll" ALIAS "FreeUserPhysicalPages" ( BYVAL hProcess AS QUAD , BYREF NumberOfPages AS QUAD , BYREF PageArray AS QUAD ) AS LONG
DECLARE FUNCTION MapUserPhysicalPages LIB "kernel32.dll" ALIAS "MapUserPhysicalPages" ( BYVAL VirtualAddress AS QUAD
 , BYVAL NumberOfPages AS DWORD
 , BYREF PageArray AS DWORD
 ) AS LONG
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION MapUserPhysicalPagesScatter LIB "Kernel32.dll" ALIAS "MapUserPhysicalPagesScatter" (BYVAL VirtualAddresses AS QUAD, BYVAL NumberOfPages AS QUAD, PageArray AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION MapUserPhysicalPagesScatter LIB "kernel32.dll" ALIAS "MapUserPhysicalPagesScatter" ( BYREF VirtualAddress AS QUAD , BYVAL NumberOfPages AS QUAD , BYREF PageArray AS QUAD ) AS LONG
#ENDIF
DECLARE FUNCTION CreateJobObjectA LIB "kernel32.dll" ALIAS "CreateJobObjectA" ( BYREF lpJobAttributes AS SECURITY_ATTRIBUTES , BYREF lpName AS ASCIIZ ) AS QUAD
DECLARE FUNCTION CreateJobObjectW LIB "kernel32.dll" ALIAS "CreateJobObjectW" ( BYREF lpJobAttributes AS SECURITY_ATTRIBUTES
 , BYREF lpName AS WSTRINGZ
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO CreateJobObject = CreateJobObjectW
#ELSE
 MACRO CreateJobObject = CreateJobObjectA
#ENDIF
DECLARE FUNCTION OpenJobObjectA LIB "kernel32.dll" ALIAS "OpenJobObjectA" ( BYVAL dwDesiredAccess AS QUAD , BYVAL bInheritHandle AS LONG , BYREF lpName AS ASCIIZ ) AS QUAD
DECLARE FUNCTION OpenJobObjectW LIB "kernel32.dll" ALIAS "OpenJobObjectW" ( BYVAL dwDesiredAccess AS QUAD
 , BYVAL bInheritHandle AS LONG
 , BYREF lpName AS WSTRINGZ
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO OpenJobObject = OpenJobObjectW
#ELSE
 MACRO OpenJobObject = OpenJobObjectA
#ENDIF
DECLARE FUNCTION AssignProcessToJobObject LIB "kernel32.dll" ALIAS "AssignProcessToJobObject" ( BYVAL hJob AS QUAD , BYVAL hProcess AS QUAD ) AS LONG
DECLARE FUNCTION TerminateJobObject LIB "kernel32.dll" ALIAS "TerminateJobObject" ( BYVAL hJob AS QUAD
 , BYVAL uExitCode AS DWORD
 ) AS LONG
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION QueryInformationJobObject LIB "Kernel32.dll" ALIAS "QueryInformationJobObject" (BYVAL hJob AS QUAD, BYVAL JobObjectInformationClass AS LONG, BYVAL lpJobObjectInformation AS QUAD, BYVAL cbJobObjectInformationLength AS QUAD, lpReturnlength AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION QueryInformationJobObject LIB "kernel32.dll" ALIAS "QueryInformationJobObject" ( BYVAL hJob AS QUAD , BYVAL JobObjectInformationClass AS LONG , BYREF lpJobObjectInformation AS ANY , BYVAL cbJobObjectInformationLength AS QUAD , BYREF lpReturnLength AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION SetInformationJobObject LIB "Kernel32.dll" ALIAS "SetInformationJobObject" (BYVAL hJob AS QUAD, BYVAL JobObjectInformationClass AS LONG, BYVAL lpJobObjectInformation AS QUAD, BYVAL cbJobObjectInformationLength AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION SetInformationJobObject LIB "kernel32.dll" ALIAS "SetInformationJobObject" ( BYVAL hJob AS QUAD , BYVAL JobObjectInformationClass AS LONG , BYREF lpJobObjectInformation AS ANY , BYVAL cbJobObjectInformationLength AS QUAD ) AS LONG
#ENDIF
'#if (_WIN32_WINNT >= 0x0501)
DECLARE FUNCTION IsProcessInJob LIB "kernel32.dll" ALIAS "IsProcessInJob" ( BYVAL ProcessHandle AS QUAD , BYVAL JobHandle AS QUAD , BYREF Result AS LONG ) AS LONG
'#endif
DECLARE FUNCTION CreateJobSet LIB "kernel32.dll" ALIAS "CreateJobSet" ( BYVAL NumJob AS QUAD , BYREF UserJobSet AS JOB_SET_ARRAY , BYVAL Flags AS QUAD ) AS LONG
DECLARE FUNCTION AddVectoredExceptionHandler LIB "kernel32.dll" ALIAS "AddVectoredExceptionHandler" ( BYVAL First AS QUAD
 , BYVAL Handler AS DWORD
 ) AS DWORD
DECLARE FUNCTION RemoveVectoredExceptionHandler LIB "kernel32.dll" ALIAS "RemoveVectoredExceptionHandler" ( BYVAL Handle AS DWORD
 ) AS DWORD ' ULONG
DECLARE FUNCTION AddVectoredContinueHandler LIB "kernel32.dll" ALIAS "AddVectoredContinueHandler" ( BYVAL First AS QUAD , BYVAL Handler AS QUAD ) AS QUAD
DECLARE FUNCTION RemoveVectoredContinueHandler LIB "kernel32.dll" ALIAS "RemoveVectoredContinueHandler" ( BYVAL Handle AS QUAD
 ) AS DWORD ' ULONG
'//
'// New Volume Mount Point API.
'//
DECLARE FUNCTION FindFirstVolumeA LIB "kernel32.dll" ALIAS "FindFirstVolumeA" ( BYREF lpszVolumeName AS ASCIIZ , BYVAL cchBufferLength AS QUAD ) AS QUAD
DECLARE FUNCTION FindFirstVolumeW LIB "kernel32.dll" ALIAS "FindFirstVolumeW" ( BYREF lpszVolumeName AS WSTRINGZ
 , BYVAL cchBufferLength AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO FindFirstVolume = FindFirstVolumeW
#ELSE
 MACRO FindFirstVolume = FindFirstVolumeA
#ENDIF
DECLARE FUNCTION FindNextVolumeA LIB "kernel32.dll" ALIAS "FindNextVolumeA" ( BYVAL hFindVolume AS QUAD , BYREF lpszVolumeName AS ASCIIZ , BYVAL cchBufferLength AS QUAD ) AS LONG
DECLARE FUNCTION FindNextVolumeW LIB "kernel32.dll" ALIAS "FindNextVolumeW" ( BYVAL hFindVolume AS QUAD
 , BYREF lpszVolumeName AS WSTRINGZ
 , BYVAL cchBufferLength AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO FindNextVolume = FindNextVolumeW
#ELSE
 MACRO FindNextVolume = FindNextVolumeA
#ENDIF
DECLARE FUNCTION FindVolumeClose LIB "kernel32.dll" ALIAS "FindVolumeClose" ( BYVAL hFindVolume AS QUAD ) AS LONG
DECLARE FUNCTION FindFirstVolumeMountPointA LIB "kernel32.dll" ALIAS "FindFirstVolumeMountPointA" ( BYREF lpszRootPathName AS ASCIIZ
 , BYREF lpszVolumeMountPoint AS ASCIIZ
 , BYVAL cchBufferLength AS DWORD
 ) AS DWORD
DECLARE FUNCTION FindFirstVolumeMountPointW LIB "kernel32.dll" ALIAS "FindFirstVolumeMountPointW" ( BYREF lpszRootPathName AS WSTRINGZ
 , BYREF lpszVolumeMountPoint AS WSTRINGZ
 , BYVAL cchBufferLength AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO FindFirstVolumeMountPoint = FindFirstVolumeMountPointW
#ELSE
 MACRO FindFirstVolumeMountPoint = FindFirstVolumeMountPointA
#ENDIF
DECLARE FUNCTION FindNextVolumeMountPointA LIB "kernel32.dll" ALIAS "FindNextVolumeMountPointA" ( BYVAL hFindVolumeMountPoint AS QUAD , BYREF lpszVolumeMountPoint AS ASCIIZ , BYVAL cchBufferLength AS QUAD ) AS LONG
DECLARE FUNCTION FindNextVolumeMountPointW LIB "kernel32.dll" ALIAS "FindNextVolumeMountPointW" ( BYVAL hFindVolumeMountPoint AS QUAD
 , BYREF lpszVolumeMountPoint AS WSTRINGZ
 , BYVAL cchBufferLength AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO FindNextVolumeMountPoint = FindNextVolumeMountPointW
#ELSE
 MACRO FindNextVolumeMountPoint = FindNextVolumeMountPointA
#ENDIF
DECLARE FUNCTION FindVolumeMountPointClose LIB "kernel32.dll" ALIAS "FindVolumeMountPointClose" ( BYVAL hFindVolumeMountPoint AS QUAD ) AS LONG
DECLARE FUNCTION SetVolumeMountPointA LIB "kernel32.dll" ALIAS "SetVolumeMountPointA" ( BYREF lpszVolumeMountPoint AS ASCIIZ
 , BYREF lpszVolumeName AS ASCIIZ
 ) AS LONG
DECLARE FUNCTION SetVolumeMountPointW LIB "kernel32.dll" ALIAS "SetVolumeMountPointW" ( BYREF lpszVolumeMountPoint AS WSTRINGZ
 , BYREF lpszVolumeName AS WSTRINGZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SetVolumeMountPoint = SetVolumeMountPointW
#ELSE
 MACRO SetVolumeMountPoint = SetVolumeMountPointA
#ENDIF
DECLARE FUNCTION DeleteVolumeMountPointA LIB "kernel32.dll" ALIAS "DeleteVolumeMountPointA" ( BYREF lpszVolumeMountPoint AS ASCIIZ ) AS LONG
DECLARE FUNCTION DeleteVolumeMountPointW LIB "kernel32.dll" ALIAS "DeleteVolumeMountPointW" ( BYREF lpszVolumeMountPoint AS WSTRINGZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO DeleteVolumeMountPoint = DeleteVolumeMountPointW
#ELSE
 MACRO DeleteVolumeMountPoint = DeleteVolumeMountPointA
#ENDIF
DECLARE FUNCTION GetVolumeNameForVolumeMountPointA LIB "kernel32.dll" ALIAS "GetVolumeNameForVolumeMountPointA" ( BYREF lpszVolumeMountPoint AS ASCIIZ , BYREF lpszVolumeName AS ASCIIZ , BYVAL cchBufferLength AS QUAD ) AS LONG
DECLARE FUNCTION GetVolumeNameForVolumeMountPointW LIB "kernel32.dll" ALIAS "GetVolumeNameForVolumeMountPointW" ( BYREF lpszVolumeMountPoint AS WSTRINGZ
 , BYREF lpszVolumeName AS WSTRINGZ
 , BYVAL cchBufferLength AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO GetVolumeNameForVolumeMountPoint = GetVolumeNameForVolumeMountPointW
#ELSE
 MACRO GetVolumeNameForVolumeMountPoint = GetVolumeNameForVolumeMountPointA
#ENDIF
DECLARE FUNCTION GetVolumePathNameA LIB "kernel32.dll" ALIAS "GetVolumePathNameA" ( BYREF lpszFileName AS ASCIIZ , BYREF lpszVolumePathName AS ASCIIZ , BYVAL cchBufferLength AS QUAD ) AS LONG
DECLARE FUNCTION GetVolumePathNameW LIB "kernel32.dll" ALIAS "GetVolumePathNameW" ( BYREF lpszFileName AS WSTRINGZ
 , BYREF lpszVolumePathName AS WSTRINGZ
 , BYVAL cchBufferLength AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO GetVolumePathName = GetVolumePathNameW
#ELSE
 MACRO GetVolumePathName = GetVolumePathNameA
#ENDIF
'#endif
'#if(_WIN32_WINNT >= 0x0501)
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION GetVolumePathNamesForVolumeNameA LIB "Kernel32.dll" ALIAS "GetVolumePathNamesForVolumeNameA" (lpszVolumeName AS ASCIIZ, BYVAL lpszVolumePathNames AS QUAD, BYVAL ccBufferLength AS QUAD, lpcchReturnLength AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION GetVolumePathNamesForVolumeNameA LIB "kernel32.dll" ALIAS "GetVolumePathNamesForVolumeNameA" ( BYREF lpszVolumeName AS ASCIIZ , BYREF lpszVolumePathNames AS ANY , BYVAL cchBufferLength AS QUAD , BYREF lpcchReturnLength AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION GetVolumePathNamesForVolumeNameW LIB "Kernel32.dll" ALIAS "GetVolumePathNamesForVolumeNameW" (lpszVolumeName AS WSTRINGZ, BYVAL lpszVolumePathNames AS QUAD, BYVAL ccBufferLength AS QUAD, lpcchReturnLength AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION GetVolumePathNamesForVolumeNameW LIB "kernel32.dll" ALIAS "GetVolumePathNamesForVolumeNameW" ( BYREF lpszVolumeName AS WSTRINGZ , BYREF lpszVolumePathNames AS ANY , BYVAL cchBufferLength AS QUAD , BYREF lpcchReturnLength AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%UNICODE)
 MACRO GetVolumePathNamesForVolumeName = GetVolumePathNamesForVolumeNameW
#ELSE
 MACRO GetVolumePathNamesForVolumeName = GetVolumePathNamesForVolumeNameA
#ENDIF
'#endif // (_WIN32_WINNT >= 0x0501)
'#if (_WIN32_WINNT >= 0x0500) || (_WIN32_FUSION >= 0x0100) || ISOLATION_AWARE_ENABLED
%EQUATE `ACTCTX_FLAG_PROCESSOR_ARCHITECTURE_VALID = &H00000001
%EQUATE `ACTCTX_FLAG_LANGID_VALID = &H00000002
%EQUATE `ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID = &H00000004
%EQUATE `ACTCTX_FLAG_RESOURCE_NAME_VALID = &H00000008
%EQUATE `ACTCTX_FLAG_SET_PROCESS_DEFAULT = &H00000010
%EQUATE `ACTCTX_FLAG_APPLICATION_NAME_VALID = &H00000020
%EQUATE `ACTCTX_FLAG_SOURCE_IS_ASSEMBLYREF = &H00000040
%EQUATE `ACTCTX_FLAG_HMODULE_VALID = &H00000080
' // Size = 32 bytes
TYPE ACTCTXA DWORD FILL
 cbSize AS DWORD ' ULONG cbSize
 dwFlags AS DWORD ' DWORD dwFlags
 lpSource AS ASCIIZ PTR ' LPCSTR lpSource
 wProcessorArchitecture AS WORD ' USHORT wProcessorArchitecture
 wLangId AS WORD ' LANGID wLangId
 lpAssemblyDirectory AS ASCIIZ PTR ' LPCSTR lpAssemblyDirectory
 lpResourceName AS ASCIIZ PTR ' LPCSTR lpResourceName
 lpApplicationName AS ASCIIZ PTR ' LPCSTR lpApplicationName
 hModule AS DWORD ' HMODULE hModule
END TYPE
' // Size = 32 bytes
TYPE ACTCTXW DWORD FILL
 cbSize AS DWORD ' ULONG cbSize
 dwFlags AS DWORD ' DWORD dwFlags
 lpSource AS WSTRINGZ PTR ' LPWCSTR lpSource
 wProcessorArchitecture AS WORD ' USHORT wProcessorArchitecture
 wLangId AS WORD ' LANGID wLangId
 lpAssemblyDirectory AS WSTRINGZ PTR ' LPCWSTR lpAssemblyDirectory
 lpResourceName AS WSTRINGZ PTR ' LPCWSTR lpResourceName
 lpApplicationName AS WSTRINGZ PTR ' LPCWSTR lpApplicationName
 hModule AS DWORD ' HMODULE hModule
END TYPE
MACRO ACTCTX = ACTCTXA
'#endif
'#if (_WIN32_WINNT >= 0x0500) || (_WIN32_FUSION >= 0x0100)
DECLARE FUNCTION CreateActCtxA LIB "kernel32.dll" ALIAS "CreateActCtxA" ( BYREF pActCtx AS ACTCTXA ) AS QUAD
DECLARE FUNCTION CreateActCtxW LIB "kernel32.dll" ALIAS "CreateActCtxW" ( BYREF pActCtx AS ACTCTXW
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO CreateActCtx = CreateActCtxW
#ELSE
 MACRO CreateActCtx = CreateActCtxA
#ENDIF
DECLARE SUB AddRefActCtx LIB "kernel32.dll" ALIAS "AddRefActCtx" ( BYVAL hActCtx AS QUAD ) ' void
DECLARE SUB ReleaseActCtx LIB "kernel32.dll" ALIAS "ReleaseActCtx" ( BYVAL hActCtx AS QUAD ) ' void
DECLARE FUNCTION ZombifyActCtx LIB "kernel32.dll" ALIAS "ZombifyActCtx" ( BYVAL hActCtx AS QUAD ) AS LONG
DECLARE FUNCTION ActivateActCtx LIB "kernel32.dll" ALIAS "ActivateActCtx" ( BYVAL hActCtx AS QUAD
 , BYREF lpCookie AS DWORD
 ) AS LONG
%EQUATE `DEACTIVATE_ACTCTX_FLAG_FORCE_EARLY_DEACTIVATION = &H00000001
DECLARE FUNCTION DeactivateActCtx LIB "kernel32.dll" ALIAS "DeactivateActCtx" ( BYVAL dwFlags AS QUAD , BYVAL ulCookie AS QUAD ) AS LONG
DECLARE FUNCTION GetCurrentActCtx LIB "kernel32.dll" ALIAS "GetCurrentActCtx" ( BYREF lphActCtx AS QUAD
 ) AS LONG
'#endif
'#if (_WIN32_WINNT >= 0x0500) || (_WIN32_FUSION >= 0x0100) || ISOLATION_AWARE_ENABLED
' // Size = 40 bytes
TYPE ACTCTX_SECTION_KEYED_DATA_2600 DWORD
 cbSize AS DWORD ' ULONG cbSize
 ulDataFormatVersion AS DWORD ' ULONG ulDataFormatVersion
 lpData AS DWORD ' PVOID lpData
 ulLength AS DWORD ' ULONG ulLength
 lpSectionGlobalData AS DWORD ' PVOID lpSectionGlobalData
 ulSectionGlobalDataLength AS DWORD ' ULONG ulSectionGlobalDataLength
 lpSectionBase AS DWORD ' PVOID lpSectionBase
 ulSectionTotalLength AS DWORD ' ULONG ulSectionTotalLength
 hActCtx AS DWORD ' HANDLE hActCtx
 ulAssemblyRosterIndex AS DWORD ' ULONG ulAssemblyRosterIndex
END TYPE
' // Size = 20 bytes
TYPE ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA DWORD
 lpInformation AS DWORD ' PVOID lpInformation
 lpSectionBase AS DWORD ' PVOID lpSectionBase
 ulSectionLength AS DWORD ' ULONG ulSectionLength
 lpSectionGlobalDataBase AS DWORD ' PVOID lpSectionGlobalDataBase
 ulSectionGlobalDataLength AS DWORD ' ULONG ulSectionGlobalDataLength
END TYPE
' // Size = 64 bytes
TYPE ACTCTX_SECTION_KEYED_DATA DWORD
 cbSize AS DWORD ' ULONG cbSize
 ulDataFormatVersion AS DWORD ' ULONG ulDataFormatVersion
 lpData AS DWORD ' PVOID lpData
 ulLength AS DWORD ' ULONG ulLength
 lpSectionGlobalData AS DWORD ' PVOID lpSectionGlobalData
 ulSectionGlobalDataLength AS DWORD ' ULONG ulSectionGlobalDataLength
 lpSectionBase AS DWORD ' PVOID lpSectionBase
 ulSectionTotalLength AS DWORD ' ULONG ulSectionTotalLength
 hActCtx AS DWORD ' HANDLE hActCtx
 ulAssemblyRosterIndex AS DWORD ' ULONG ulAssemblyRosterIndex
 '// 2600 stops here
 ulFlags AS DWORD ' ULONG ulFlags
 AssemblyMetadata AS ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA ' ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA AssemblyMetadata
END TYPE
%EQUATE `FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX = &H00000001
%EQUATE `FIND_ACTCTX_SECTION_KEY_RETURN_FLAGS = &H00000002
%EQUATE `FIND_ACTCTX_SECTION_KEY_RETURN_ASSEMBLY_METADATA = &H00000004
'#endif
'#if (_WIN32_WINNT >= 0x0500) || (_WIN32_FUSION >= 0x0100)
DECLARE FUNCTION FindActCtxSectionStringA LIB "kernel32.dll" ALIAS "FindActCtxSectionStringA" ( BYVAL dwFlags AS QUAD , BYREF lpExtensionGuid AS GUID , BYVAL ulSectionId AS QUAD , BYREF lpStringToFind AS ASCIIZ , BYREF ReturnedData AS ACTCTX_SECTION_KEYED_DATA ) AS LONG
DECLARE FUNCTION FindActCtxSectionStringW LIB "kernel32.dll" ALIAS "FindActCtxSectionStringW" ( BYVAL dwFlags AS QUAD
 , BYREF lpExtensionGuid AS GUID
 , BYVAL ulSectionId AS DWORD
 , BYREF lpStringToFind AS WSTRINGZ
 , BYREF ReturnedData AS ACTCTX_SECTION_KEYED_DATA
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO FindActCtxSectionString = FindActCtxSectionStringW
#ELSE
 MACRO FindActCtxSectionString = FindActCtxSectionStringA
#ENDIF
DECLARE FUNCTION FindActCtxSectionGuid LIB "kernel32.dll" ALIAS "FindActCtxSectionGuid" ( BYVAL dwFlags AS QUAD , BYREF lpExtensionGuid AS GUID , BYVAL ulSectionId AS QUAD , BYREF lpGuidToFind AS GUID , BYREF ReturnedData AS ACTCTX_SECTION_KEYED_DATA ) AS LONG
'#endif
'#if (_WIN32_WINNT >= 0x0500) || (_WIN32_FUSION >= 0x0100) || ISOLATION_AWARE_ENABLED
'#if !defined(RC_INVOKED) /* RC complains about long symbols in #ifs */
'#if !defined(ACTIVATION_CONTEXT_BASIC_INFORMATION_DEFINED)
' // Size = 8 bytes
TYPE ACTIVATION_CONTEXT_BASIC_INFORMATION DWORD
 hActCtx AS DWORD ' HANDLE hActCtx
 dwFlags AS DWORD ' DWORD dwFlags
END TYPE
%EQUATE `ACTIVATION_CONTEXT_BASIC_INFORMATION_DEFINED = 1
'#endif // !defined(ACTIVATION_CONTEXT_BASIC_INFORMATION_DEFINED)
'#endif
%EQUATE `QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX = &H00000004
%EQUATE `QUERY_ACTCTX_FLAG_ACTCTX_IS_HMODULE = &H00000008
%EQUATE `QUERY_ACTCTX_FLAG_ACTCTX_IS_ADDRESS = &H00000010
%EQUATE `QUERY_ACTCTX_FLAG_NO_ADDREF = &H80000000
'#endif
'#if (_WIN32_WINNT >= 0x0500) || (_WIN32_FUSION >= 0x0100)
'//
'// switch (ulInfoClass)
'//
'// case ActivationContextBasicInformation:
'// pvSubInstance == NULL
'// pvBuffer is of type PACTIVATION_CONTEXT_BASIC_INFORMATION
'//
'// case ActivationContextDetailedInformation:
'// pvSubInstance == NULL
'// pvBuffer is of type PACTIVATION_CONTEXT_DETAILED_INFORMATION
'//
'// case AssemblyDetailedInformationInActivationContext:
'// pvSubInstance is of type PULONG
'// *pvSubInstance < ACTIVATION_CONTEXT_DETAILED_INFORMATION::ulAssemblyCount
'// pvBuffer is of type PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
'//
'// case FileInformationInAssemblyOfAssemblyInActivationContext:
'// pvSubInstance is of type PACTIVATION_CONTEXT_QUERY_INDEX
'// pvSubInstance->ulAssemblyIndex < ACTIVATION_CONTEXT_DETAILED_INFORMATION::ulAssemblyCount
'// pvSubInstance->ulFileIndexInAssembly < ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION::ulFileCount
'// pvBuffer is of type PASSEMBLY_FILE_DETAILED_INFORMATION
'//
'// String are placed after the structs.
'//
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION QueryActCtxW LIB "Kernel32.dll" ALIAS "QueryActCtxW" (BYVAL dwFlags AS QUAD, BYVAL hActCtx AS QUAD, BYVAL pvSubInstance AS QUAD, BYVAL ulInfoClass AS QUAD, BYVAL pvBuffer AS QUAD, BYVAL cbBuffer AS QUAD, pcbWrittenOrRequired AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION QueryActCtxW LIB "kernel32.dll" ALIAS "QueryActCtxW" ( BYVAL dwFlags AS QUAD , BYVAL hActCtx AS QUAD , BYVAL pvSubInstance AS QUAD , BYVAL ulInfoClass AS QUAD , BYREF pvBuffer AS ANY , BYVAL cbBuffer AS QUAD , BYREF pcbWrittenOrRequired AS QUAD ) AS LONG
#ENDIF
MACRO QueryActCtx = QueryActCtxW
'#endif // (_WIN32_WINNT > 0x0500) || (_WIN32_FUSION >= 0x0100)
DECLARE FUNCTION ProcessIdToSessionId LIB "kernel32.dll" ALIAS "ProcessIdToSessionId" ( BYVAL dwProcessId AS QUAD , BYREF pSessionId AS QUAD ) AS LONG
'#if _WIN32_WINNT >= 0x0501
DECLARE FUNCTION WTSGetActiveConsoleSessionId LIB "kernel32.dll" ALIAS "WTSGetActiveConsoleSessionId" ( ) AS QUAD
DECLARE FUNCTION IsWow64Process LIB "kernel32.dll" ALIAS "IsWow64Process" ( BYVAL hProcess AS QUAD , BYREF Wow64Process AS LONG
 ) AS LONG
'#endif // (_WIN32_WINNT >= 0x0501)
DECLARE FUNCTION GetLogicalProcessorInformation LIB "kernel32.dll" ALIAS "GetLogicalProcessorInformation" ( BYREF Buffer AS SYSTEM_LOGICAL_PROCESSOR_INFORMATION , BYREF ReturnedLength AS QUAD ) AS LONG
'#if _WIN32_WINNT >= 0x0601
#IF %WINVER >= &H0601
DECLARE FUNCTION GetLogicalProcessorInformationEx LIB "kernel32.dll" ALIAS "GetLogicalProcessorInformationEx" ( BYVAL RelationshipType AS LONG , BYREF Buffer AS SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX , BYREF ReturnedLength AS QUAD ) AS LONG
DECLARE FUNCTION GetActiveProcessorGroupCount LIB "kernel32.dll" ALIAS "GetActiveProcessorGroupCount" ( ) AS WORD ' WORD
DECLARE FUNCTION GetMaximumProcessorGroupCount LIB "kernel32.dll" ALIAS "GetMaximumProcessorGroupCount" ( ) AS WORD ' WORD
DECLARE FUNCTION GetActiveProcessorCount LIB "kernel32.dll" ALIAS "GetActiveProcessorCount" ( BYVAL GroupNumber AS WORD ) AS QUAD
DECLARE FUNCTION GetMaximumProcessorCount LIB "kernel32.dll" ALIAS "GetMaximumProcessorCount" ( BYVAL GroupNumber AS WORD
 ) AS DWORD
#ENDIF ' // (_WIN32_WINNT >=0x0601)
'//
'// NUMA Information routines.
'//
DECLARE FUNCTION GetNumaHighestNodeNumber LIB "kernel32.dll" ALIAS "GetNumaHighestNodeNumber" ( BYREF HighestNodeNumber AS QUAD ) AS LONG
DECLARE FUNCTION GetNumaProcessorNode LIB "kernel32.dll" ALIAS "GetNumaProcessorNode" ( BYVAL Processor AS BYTE
 , BYREF NodeNumber AS BYTE
 ) AS LONG
'#if _WIN32_WINNT >= 0x0601
#IF %WINVER >= &H0601
DECLARE FUNCTION GetNumaNodeNumberFromHandle LIB "kernel32.dll" ALIAS "GetNumaNodeNumberFromHandle" ( BYVAL hFile AS QUAD , BYREF NodeNumber AS WORD ) AS LONG
#ENDIF ' // (_WIN32_WINNT >=0x0601)
'#if _WIN32_WINNT >= 0x0601
#IF %WINVER >= &H0601
DECLARE FUNCTION GetNumaProcessorNodeEx LIB "kernel32.dll" ALIAS "GetNumaProcessorNodeEx" ( BYREF Processor AS PROCESSOR_NUMBER , BYREF NodeNumber AS WORD ) AS LONG
#ENDIF ' // (_WIN32_WINNT >=0x0601)
DECLARE FUNCTION GetNumaNodeProcessorMask LIB "kernel32.dll" ALIAS "GetNumaNodeProcessorMask" ( BYVAL Node AS BYTE , BYREF ProcessorMask AS QUAD ) AS LONG
'#if _WIN32_WINNT >= 0x0601
#IF %WINVER >= &H0601
DECLARE FUNCTION GetNumaNodeProcessorMaskEx LIB "kernel32.dll" ALIAS "GetNumaNodeProcessorMaskEx" ( BYVAL Node AS WORD , BYREF ProcessorMask AS GROUP_AFFINITY ) AS LONG
#ENDIF ' // (_WIN32_WINNT >=0x0601)
DECLARE FUNCTION GetNumaAvailableMemoryNode LIB "kernel32.dll" ALIAS "GetNumaAvailableMemoryNode" ( BYVAL Node AS BYTE , BYREF AvailableBytes AS QUAD ) AS LONG
'#if _WIN32_WINNT >= 0x0601
#IF %WINVER >= &H0601
DECLARE FUNCTION GetNumaAvailableMemoryNodeEx LIB "kernel32.dll" ALIAS "GetNumaAvailableMemoryNodeEx" ( BYVAL Node AS WORD , BYREF AvailableBytes AS QUAD ) AS LONG
#ENDIF ' // (_WIN32_WINNT >=0x0601)
'#if (_WIN32_WINNT >= 0x0600)
#IF %WINVER >= &H0600
DECLARE FUNCTION GetNumaProximityNode LIB "kernel32.dll" ALIAS "GetNumaProximityNode" ( BYVAL ProximityId AS QUAD , BYREF NodeNumber AS BYTE ) AS LONG
#ENDIF
'#if _WIN32_WINNT >= 0x0601
#IF %WINVER >= &H0601
DECLARE FUNCTION GetNumaProximityNodeEx LIB "kernel32.dll" ALIAS "GetNumaProximityNodeEx" ( BYVAL ProximityId AS QUAD , BYREF NodeNumber AS WORD ) AS LONG
#ENDIF ' // (_WIN32_WINNT >=0x0601)
'//
'// Application restart and data recovery callback
'//
'typedef DWORD (WINAPI *APPLICATION_RECOVERY_CALLBACK)(PVOID pvParameter);
'//
'// Max length of commandline in characters (including the NULL character that can be registered for restart)
'//
%EQUATE `RESTART_MAX_CMD_LINE = 1024
'//
'// Do not restart the process for termination due to application crashes
'//
%EQUATE `RESTART_NO_CRASH = 1
'//
'// Do not restart the process for termination due to application hangs
'//
%EQUATE `RESTART_NO_HANG = 2
'//
'// Do not restart the process for termination due to patch installations
'//
%EQUATE `RESTART_NO_PATCH = 4
'//
'// Do not restart the process when the system is rebooted due to patch installations
'//
%EQUATE `RESTART_NO_REBOOT = 8
DECLARE FUNCTION RegisterApplicationRecoveryCallback LIB "kernel32.dll" ALIAS "RegisterApplicationRecoveryCallback" ( BYVAL pRecoveyCallback AS QUAD , BYVAL pvParameter AS QUAD , BYVAL dwPingInterval AS QUAD , BYVAL dwFlags AS QUAD ) AS LONG
DECLARE FUNCTION UnregisterApplicationRecoveryCallback LIB "kernel32.dll" ALIAS "UnregisterApplicationRecoveryCallback" ( ) AS LONG
DECLARE FUNCTION RegisterApplicationRestart LIB "kernel32.dll" ALIAS "RegisterApplicationRestart" ( BYREF pwzCommandline AS WSTRINGZ
 , BYVAL dwFlags AS DWORD
 ) AS LONG
DECLARE FUNCTION UnregisterApplicationRestart LIB "kernel32.dll" ALIAS "UnregisterApplicationRestart" ( ) AS LONG
%EQUATE `RECOVERY_DEFAULT_PING_INTERVAL = 5000
%EQUATE `RECOVERY_MAX_PING_INTERVAL = (5 * 60 * 1000)
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION GetApplicationRecoveryCallback LIB "Kernel32.dll" ALIAS "GetApplicationRecoveryCallback" (BYVAL hProcess AS QUAD, BYVAL pRecoveryCallback AS QUAD, BYVAL ppvParameter AS QUAD, pdwPingInterval AS QUAD, pdwFlags AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION GetApplicationRecoveryCallback LIB "kernel32.dll" ALIAS "GetApplicationRecoveryCallback" ( BYVAL hProcess AS QUAD , BYREF pRecoveryCallback AS QUAD , BYREF ppvParameter AS ANY , BYREF pdwPingInterval AS QUAD , BYREF pdwFlags AS QUAD ) AS LONG
#ENDIF
DECLARE FUNCTION GetApplicationRestartSettings LIB "kernel32.dll" ALIAS "GetApplicationRestartSettings" ( BYVAL hProcess AS QUAD , BYREF pwzCommandline AS WSTRINGZ , BYREF pcchSize AS QUAD , BYREF pdwFlags AS QUAD ) AS LONG
DECLARE FUNCTION ApplicationRecoveryInProgress LIB "kernel32.dll" ALIAS "ApplicationRecoveryInProgress" ( BYREF pbCancelled AS LONG
 ) AS LONG
DECLARE SUB ApplicationRecoveryFinished LIB "kernel32.dll" ALIAS "ApplicationRecoveryFinished" ( BYVAL bSuccess AS LONG
 ) ' void
'#if (_WIN32_WINNT >= 0x0600)
#IF %WINVER >= &H0600
' enum FILE_INFO_BY_HANDLE_CLASS
%EQUATE `FileBasicInfo = 0
%EQUATE `FileStandardInfo = 1
%EQUATE `FileNameInfo = 2
%EQUATE `FileRenameInfo = 3
%EQUATE `FileDispositionInfo = 4
%EQUATE `FileAllocationInfo = 5
%EQUATE `FileEndOfFileInfo = 6
%EQUATE `FileStreamInfo = 7
%EQUATE `FileCompressionInfo = 8
%EQUATE `FileAttributeTagInfo = 9
%EQUATE `FileIdBothDirectoryInfo = 10
%EQUATE `FileIdBothDirectoryRestartInfo = 11
%EQUATE `FileIoPriorityHintInfo = 12
%EQUATE `FileRemoteProtocolInfo = 13
%EQUATE `MaximumFileInfoByHandleClass = 14
' // Size = 40 bytes
TYPE FILE_BASIC_INFO ' Must be 8 byte aligned
 CreationTime AS QUAD ' LARGE_INTEGER
 LastAccessTime AS QUAD ' LARGE_INTEGER
 LastWriteTime AS QUAD ' LARGE_INTEGER
 ChangeTime AS QUAD ' LARGE_INTEGER
 FileAttributes AS DWORD
 alignment__ AS DWORD ' // To keep 8 byte alignment
END TYPE
' // Size = 24 bytes
TYPE FILE_STANDARD_INFO ' Must be 8 byte aligned
 AllocationSize AS QUAD ' LARGE_INTEGER
 EndOfFile AS QUAD ' LARGE_INTEGER
 NumberOfLinks AS DWORD
 DeletePending AS BYTE ' BOOLEAN
 Directory AS BYTE ' BOOLEAN
 alignment__ AS WORD ' // To keep 8 byte alignment
END TYPE
' // Size = 8 bytes
TYPE FILE_NAME_INFO DWORD
 FileNameLength AS DWORD
 FileName AS WSTRINGZ * 1 ' WCHAR - variable length
END TYPE
' // Size = 16 bytes
TYPE FILE_RENAME_INFO DWORD
 ReplaceIfExists AS BYTE ' BOOLEAN
 RootDirectory AS DWORD
 FileNameLength AS DWORD
 FileName AS WSTRINGZ * 1 ' WCHAR - variable length
END TYPE
' // Size = 8 bytes
TYPE FILE_ALLOCATION_INFO QWORD
 AllocationSize AS QUAD ' LARGE_INTEGER
END TYPE
' // Size = 8 bytes
TYPE FILE_END_OF_FILE_INFO QWORD
 EndOfFile AS QUAD ' LARGE_INTEGER
END TYPE
' // Size = 32 bytes
TYPE FILE_STREAM_INFO QWORD FILL
 NextEntryOffset AS DWORD
 StreamNameLength AS DWORD
 StreamSize AS QUAD ' LARGE_INTEGER
 StreamAllocationSize AS QUAD ' LARGE_INTEGER
 StreamName AS WSTRINGZ * 4 ' WCHAR - variable length
 ' Note: We are using * 4 instead of * 1 to keep 7 byte alignment
END TYPE
' // Size = 16 bytes
TYPE FILE_COMPRESSION_INFO QWORD FILL
 CompressedFileSize AS QUAD ' LARGE_INTEGER
 CompressionFormat AS WORD ' WORD
 CompressionUnitShift AS BYTE ' UCHAR
 ChunkShift AS BYTE ' UCHAR
 ClusterShift AS BYTE ' UCHAR
 Reserved(2) AS BYTE ' UCHAR[3]
END TYPE
' // Size = 8 bytes
TYPE FILE_ATTRIBUTE_TAG_INFO DWORD
 FileAttributes AS DWORD
 ReparseTag AS DWORD
END TYPE
' // Size = 1 byte
TYPE FILE_DISPOSITION_INFO BYTE
 DeleteFile AS BYTE ' BOOLEAN
END TYPE
' // Size = 112 byte
TYPE FILE_ID_BOTH_DIR_INFO QWORD FILL
 NextEntryOffset AS DWORD
 FileIndex AS DWORD
 CreationTime AS QUAD ' LARGE_INTEGER
 LastAccessTime AS QUAD ' LARGE_INTEGER
 LastWriteTime AS QUAD ' LARGE_INTEGER
 ChangeTime AS QUAD ' LARGE_INTEGER
 EndOfFile AS QUAD ' LARGE_INTEGER
 AllocationSize AS QUAD ' LARGE_INTEGER
 FileAttributes AS DWORD
 FileNameLength AS DWORD
 EaSize AS DWORD
 ShortNameLength AS ASCIIZ PTR ' CCHAR
 ShortName AS WSTRINGZ * 12 ' WCHAR
 FileId AS QUAD ' LARGE_INTEGER
 FileName AS WSTRINGZ * 4 ' WCHAR - variable length
 ' Note: We are using * 4 instead of * 1 to keep 8 byte alignment
END TYPE
' enum PRIORITY_HINT
%EQUATE `IoPriorityHintVeryLow = 0
%EQUATE `IoPriorityHintLow = 1
%EQUATE `IoPriorityHintNormal = 2
%EQUATE `MaximumIoPriorityHintType = 3
' // Size = 4 byte
TYPE FILE_IO_PRIORITY_HINT_INFO DWORD
 PriorityHint AS DWORD ' PRIORITY_HINT
END TYPE
'// Structure and constants must match those in ntioapi_x.w
%EQUATE `REMOTE_PROTOCOL_INFO_FLAG_LOOPBACK = &H00000001
%EQUATE `REMOTE_PROTOCOL_INFO_FLAG_OFFLINE = &H00000002
' // Size = 32 byte
TYPE FILE_REMOTE_PROTOCOL_INFO_GenericReserved
 Reserved(7) AS DWORD ' DWORD[8]
END TYPE
' // Size = 64 byte
TYPE FILE_REMOTE_PROTOCOL_INFO_ProtocolSpecificReserved
 Reserved(15) AS DWORD ' DWORD[16]
END TYPE
' // Size = 116 byte
TYPE FILE_REMOTE_PROTOCOL_INFO DWORD FILL
 ' // Structure Version
 StructureVersion AS WORD ' USHORT // 1
 StructureSize AS WORD ' USHORT // sizeof(FILE_REMOTE_PROTOCOL_INFO)
 Protocol AS DWORD ' DWORD // Protocol (WNNC_NET_*) defined in wnnc.h or ntifs.h.
 ' // Protocol Version & Type
 ProtocolMajorVersion AS WORD ' USHORT
 ProtocolMinorVersion AS WORD ' USHORT
 ProtocolRevision AS WORD ' USHORT
 Reserved AS WORD ' USHORT
 ' // Protocol-Generic Information
 Flags AS DWORD
 GenericReserved AS FILE_REMOTE_PROTOCOL_INFO_GenericReserved
 ' // Protocol specific information
 ProtocolSpecificReserved AS FILE_REMOTE_PROTOCOL_INFO_ProtocolSpecificReserved
END TYPE
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION SetFileInformationByHandle LIB "Kernel32.dll" ALIAS "SetFileInformationByHandle" (BYVAL hFile AS QUAD, BYVAL FileInformationClass AS LONG, BYVAL lpFileInformation AS QUAD, BYVAL dwBufferSize AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION SetFileInformationByHandle LIB "kernel32.dll" ALIAS "SetFileInformationByHandle" ( BYVAL hFile AS QUAD , BYVAL FileInformationClass AS QUAD , BYREF lpFileInformation AS ANY , BYVAL dwBufferSize AS QUAD ) AS LONG
#ENDIF
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION GetFileInformationByHandleEx LIB "Kernel32.dll" ALIAS "GetFileInformationByHandleEx" (BYVAL hFile AS QUAD, BYVAL FileInformationClass AS LONG, BYVAL lpFileInformation AS QUAD, BYVAL dwBufferSize AS QUAD) AS LONG
#ELSE
DECLARE FUNCTION GetFileInformationByHandleEx LIB "kernel32.dll" ALIAS "GetFileInformationByHandleEx" ( BYVAL hFile AS QUAD , BYVAL FileInformationClass AS QUAD , BYREF lpFileInformation AS ANY , BYVAL dwBufferSize AS QUAD ) AS LONG
#ENDIF
' enum FILE_ID_TYPE
%EQUATE `FileIdType = 0
%EQUATE `ObjectIdType = 1
%EQUATE `MaximumFileIdType = 2
' // Size = 116 byte
UNION FILE_ID_DESCRIPTOR_UNION QWORD FILL
 FileId AS QUAD ' LARGE_INTEGER
 ObjectId AS GUID ' GUID
END UNION
UNION FILE_ID_DESCRIPTOR_TYPE_UNION
 Type AS DWORD ' FILE_ID_TYPE // Describes the type of identifier passed in.
 ' // For compoatibility with the PB declares
 fidType AS DWORD
END UNION
' // Size = 24 byte
TYPE FILE_ID_DESCRIPTOR QWORD FILL
 dwSize AS DWORD ' DWORD // Size of the struct
 FILE_ID_DESCRIPTOR_TYPE_UNION
 FILE_ID_DESCRIPTOR_UNION
END TYPE
#IF %DEF(%USEPBDECL)
DECLARE FUNCTION OpenFileById LIB "Kernel32.dll" ALIAS "OpenFileById" (BYVAL hVolumeHint AS QUAD, lpFileId AS LONG, BYVAL dwDesiredAccess AS QUAD, BYVAL dwShareMode AS QUAD, lpSecurityAttributes AS SECURITY_ATTRIBUTES, BYVAL dwFlagsAndAttributes AS QUAD) AS QUAD
#ELSE
DECLARE FUNCTION OpenFileById LIB "kernel32.dll" ALIAS "OpenFileById" ( BYVAL hVolumeHint AS QUAD , BYREF lpFileId AS FILE_ID_DESCRIPTOR , BYVAL dwDesiredAccess AS QUAD , BYVAL dwShareMode AS QUAD , BYREF lpSecurityAttributes AS SECURITY_ATTRIBUTES , BYVAL dwFlagsAndAttributes AS QUAD ) AS QUAD
#ENDIF
#ENDIF ' #if (_WIN32_WINNT >= 0x0600)
'#if (_WIN32_WINNT >= 0x0600)
#IF %WINVER >= &H0600
'//
'// Flags to be passed into CREATE_SYMBOLIC_LINK
'//
%EQUATE `SYMBOLIC_LINK_FLAG_DIRECTORY = &H1
%EQUATE `VALID_SYMBOLIC_LINK_FLAGS = %SYMBOLIC_LINK_FLAG_DIRECTORY ' // & whatever other flags we think of!
DECLARE FUNCTION CreateSymbolicLinkA LIB "kernel32.dll" ALIAS "CreateSymbolicLinkA" ( BYREF lpSymlinkFileName AS ASCIIZ , BYREF lpTargetFileName AS ASCIIZ , BYVAL dwFlags AS QUAD ) AS BYTE ' BOOLEAN
DECLARE FUNCTION CreateSymbolicLinkW LIB "kernel32.dll" ALIAS "CreateSymbolicLinkW" ( BYREF lpSymlinkFileName AS WSTRINGZ , BYREF lpTargetFileName AS WSTRINGZ , BYVAL dwFlags AS QUAD ) AS BYTE ' BOOLEAN
#IF %DEF(%UNICODE)
 MACRO CreateSymbolicLink = CreateSymbolicLinkW
#ELSE
 MACRO CreateSymbolicLink = CreateSymbolicLinkA
#ENDIF
DECLARE FUNCTION CreateSymbolicLinkTransactedA LIB "kernel32.dll" ALIAS "CreateSymbolicLinkTransactedA" ( BYREF lpSymlinkFileName AS ASCIIZ , BYREF lpTargetFileName AS ASCIIZ , BYVAL dwFlags AS QUAD , BYVAL hTransaction AS QUAD ) AS BYTE ' BOOLEAN
DECLARE FUNCTION CreateSymbolicLinkTransactedW LIB "kernel32.dll" ALIAS "CreateSymbolicLinkTransactedW" ( BYREF lpSymlinkFileName AS WSTRINGZ , BYREF lpTargetFileName AS WSTRINGZ , BYVAL dwFlags AS QUAD , BYVAL hTransaction AS QUAD ) AS BYTE ' BOOLEAN
#IF %DEF(%UNICODE)
 MACRO CreateSymbolicLinkTransacted = CreateSymbolicLinkTransactedW
#ELSE
 MACRO CreateSymbolicLinkTransacted = CreateSymbolicLinkTransactedA
#ENDIF
DECLARE FUNCTION GetFinalPathNameByHandleA LIB "kernel32.dll" ALIAS "GetFinalPathNameByHandleA" ( BYVAL hFile AS QUAD , BYREF lpszFilePath AS ASCIIZ , BYVAL cchFilePath AS QUAD , BYVAL dwFlags AS QUAD ) AS QUAD
DECLARE FUNCTION GetFinalPathNameByHandleW LIB "kernel32.dll" ALIAS "GetFinalPathNameByHandleW" ( BYVAL hFile AS QUAD
 , BYREF lpszFilePath AS WSTRINGZ
 , BYVAL cchFilePath AS DWORD
 , BYVAL dwFlags AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO GetFinalPathNameByHandle = GetFinalPathNameByHandleW
#ELSE
 MACRO GetFinalPathNameByHandle = GetFinalPathNameByHandleA
#ENDIF
#ENDIF ' // (_WIN32_WINNT >= 0x0600)
'#if (_WIN32_WINNT >= 0x0600)
#IF %WINVER >= &H0600
DECLARE FUNCTION QueryActCtxSettingsW LIB "kernel32.dll" ALIAS "QueryActCtxSettingsW" ( BYVAL dwFlags AS QUAD , BYVAL hActCtx AS QUAD , BYREF settingsNameSpace AS WSTRINGZ , BYREF settingName AS WSTRINGZ , BYREF pvBuffer AS WSTRINGZ , BYVAL dwBuffer AS QUAD , BYREF pdwWrittenOrRequired AS QUAD ) AS LONG
MACRO QueryActCtxSettings = QueryActCtxSettingsW
#ENDIF ' #if (_WIN32_WINNT >= 0x0600)
'#if (_WIN32_WINNT >= 0x0600)
#IF %WINVER >= &H0600
DECLARE FUNCTION ReplacePartitionUnit LIB "kernel32.dll" ALIAS "ReplacePartitionUnit" ( BYREF TargetPartition AS WSTRINGZ , BYREF SparePartition AS WSTRINGZ , BYVAL Flags AS QUAD ) AS LONG
#ENDIF
'#endif
'#if (_WIN32_WINNT >= 0x0600)
#IF %WINVER >= &H0600
DECLARE FUNCTION AddSecureMemoryCacheCallback LIB "kernel32.dll" ALIAS "AddSecureMemoryCacheCallback" ( BYVAL pfnCallBack AS QUAD ) AS LONG
DECLARE FUNCTION RemoveSecureMemoryCacheCallback LIB "kernel32.dll" ALIAS "RemoveSecureMemoryCacheCallback" ( BYVAL pfnCallBack AS QUAD
 ) AS LONG
#ENDIF
'#endif
'#if (_WIN32_WINNT >= 0x0601)
#IF %WINVER >= &H0601
DECLARE FUNCTION CopyExtendedContext LIB "kernel32.dll" ALIAS "CopyExtendedContext" ( BYREF Destination AS CONTEXT_EX , BYVAL ContextFlags AS QUAD , BYREF Source AS CONTEXT_EX ) AS LONG
DECLARE FUNCTION InitializeExtendedContext LIB "kernel32.dll" ALIAS "InitializeExtendedContext" ( BYREF Context AS ANY
 , BYVAL ContextFlags AS DWORD
 , BYREF ContextEx AS CONTEXT_EX
 ) AS LONG
DECLARE FUNCTION GetEnabledExtendedFeatures LIB "kernel32.dll" ALIAS "GetEnabledExtendedFeatures" ( BYVAL FeatureMask AS QUAD
 ) AS QUAD ' DWORD64
DECLARE FUNCTION GetExtendedContextLength LIB "kernel32.dll" ALIAS "GetExtendedContextLength" ( BYVAL ContextFlags AS QUAD , BYREF ContextLength AS QUAD ) AS LONG
DECLARE FUNCTION GetExtendedFeaturesMask LIB "kernel32.dll" ALIAS "GetExtendedFeaturesMask" ( BYREF ContextEx AS CONTEXT_EX
 ) AS QUAD ' DWORD64
DECLARE FUNCTION LocateExtendedFeature LIB "kernel32.dll" ALIAS "LocateExtendedFeature" ( BYREF ContextEx AS CONTEXT_EX , BYVAL FeatureId AS QUAD , BYREF Length AS QUAD ) AS QUAD
DECLARE FUNCTION LocateLegacyContext LIB "kernel32.dll" ALIAS "LocateLegacyContext" ( BYREF ContextEx AS CONTEXT_EX
 , BYREF Length AS DWORD
 ) AS DWORD
DECLARE SUB SetExtendedFeaturesMask LIB "kernel32.dll" ALIAS "SetExtendedFeaturesMask" ( BYREF ContextEx AS CONTEXT_EX
 , BYVAL FeatureMask AS QUAD
 )
DECLARE FUNCTION EnableThreadProfiling LIB "kernel32.dll" ALIAS "EnableThreadProfiling" ( BYVAL ThreadHandle AS DWORD
 , BYVAL Flags AS DWORD
 , BYVAL HardwareCounters AS QUAD
 , BYREF PerformanceDataHandle AS DWORD
 ) AS DWORD
DECLARE FUNCTION DisableThreadProfiling LIB "kernel32.dll" ALIAS "DisableThreadProfiling" ( BYVAL PerformanceDataHandle AS DWORD
 ) AS DWORD
DECLARE FUNCTION QueryThreadProfiling LIB "kernel32.dll" ALIAS "QueryThreadProfiling" ( BYVAL ThreadHandle AS DWORD
 , BYREF Enabled AS BYTE
 ) AS DWORD
DECLARE FUNCTION ReadThreadProfilingData LIB "kernel32.dll" ALIAS "ReadThreadProfilingData" ( BYVAL PerformanceDataHandle AS DWORD
 , BYVAL Flags AS DWORD
 , BYREF PerformanceData AS PERFORMANCE_DATA
 ) AS DWORD
#ENDIF
#ENDIF
