diff options
Diffstat (limited to 'winpr/include')
70 files changed, 25174 insertions, 0 deletions
diff --git a/winpr/include/CMakeLists.txt b/winpr/include/CMakeLists.txt new file mode 100644 index 0000000..5dc4885 --- /dev/null +++ b/winpr/include/CMakeLists.txt @@ -0,0 +1,57 @@ +# WinPR: Windows Portable Runtime +# winpr cmake build script +# +# Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +configure_file(config/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/winpr/version.h) +configure_file(config/wtypes.h.in ${CMAKE_CURRENT_BINARY_DIR}/winpr/wtypes.h) +configure_file(config/build-config.h.in ${CMAKE_CURRENT_BINARY_DIR}/winpr/build-config.h) +configure_file(config/buildflags.h.in ${CMAKE_CURRENT_BINARY_DIR}/winpr/buildflags.h) +configure_file(config/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/winpr/config.h) + +file(GLOB_RECURSE WINPR_PUBLIC_COMMON_HEADERS + LIST_DIRECTORIES false + "winpr/*.h" +) + +set(WINPR_PUBLIC_TOOLS_HEADERS ${WINPR_PUBLIC_COMMON_HEADERS}) +list(FILTER WINPR_PUBLIC_TOOLS_HEADERS INCLUDE REGEX ".*winpr/tools.*") +list(FILTER WINPR_PUBLIC_COMMON_HEADERS EXCLUDE REGEX ".*winpr/tools.*") + +file(GLOB_RECURSE WINPR_PUBLIC_COMMON_BIN_HEADERS + LIST_DIRECTORIES false + "${CMAKE_CURRENT_BINARY_DIR}/*.h" +) +list(APPEND WINPR_PUBLIC_COMMON_HEADERS ${WINPR_PUBLIC_COMMON_BIN_HEADERS}) +list(SORT WINPR_PUBLIC_COMMON_HEADERS) + +set_property(TARGET winpr APPEND PROPERTY SOURCES + ${WINPR_PUBLIC_COMMON_HEADERS} +) + +if (WITH_WINPR_TOOLS) + set_property(TARGET winpr-tools APPEND PROPERTY SOURCES + ${WINPR_PUBLIC_TOOLS_HEADERS} + ) +endif() + +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ + DESTINATION ${WINPR_INCLUDE_DIR} + FILES_MATCHING PATTERN "*.h") + +install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ + DESTINATION ${WINPR_INCLUDE_DIR} + FILES_MATCHING PATTERN "*.h") + diff --git a/winpr/include/config/build-config.h.in b/winpr/include/config/build-config.h.in new file mode 100644 index 0000000..823f418 --- /dev/null +++ b/winpr/include/config/build-config.h.in @@ -0,0 +1,22 @@ +#ifndef WINPR_BUILD_CONFIG_H +#define WINPR_BUILD_CONFIG_H + +#define WINPR_DATA_PATH "${WINPR_DATA_PATH}" +#define WINPR_KEYMAP_PATH "${WINPR_KEYMAP_PATH}" +#define WINPR_PLUGIN_PATH "${WINPR_PLUGIN_PATH}" + +#define WINPR_INSTALL_PREFIX "${WINPR_INSTALL_PREFIX}" + +#define WINPR_LIBRARY_PATH "${WINPR_LIBRARY_PATH}" + +#define WINPR_ADDIN_PATH "${WINPR_ADDIN_PATH}" + +#define WINPR_SHARED_LIBRARY_SUFFIX "${CMAKE_SHARED_LIBRARY_SUFFIX}" +#define WINPR_SHARED_LIBRARY_PREFIX "${CMAKE_SHARED_LIBRARY_PREFIX}" + +#define WINPR_VENDOR_STRING "${VENDOR}" +#define WINPR_PRODUCT_STRING "${PRODUCT}" + +#define WINPR_PROXY_PLUGINDIR "${WINPR_PROXY_PLUGINDIR}" + +#endif /* WINPR_BUILD_CONFIG_H */ diff --git a/winpr/include/config/buildflags.h.in b/winpr/include/config/buildflags.h.in new file mode 100644 index 0000000..1e43c37 --- /dev/null +++ b/winpr/include/config/buildflags.h.in @@ -0,0 +1,11 @@ +#ifndef WINPR_BUILD_FLAGS_H +#define WINPR_BUILD_FLAGS_H + +#define WINPR_CFLAGS "${CMAKE_C_FLAGS}" +#define WINPR_COMPILER_ID "${CMAKE_C_COMPILER_ID}" +#define WINPR_COMPILER_VERSION "${CMAKE_C_COMPILER_VERSION}" +#define WINPR_TARGET_ARCH "${TARGET_ARCH}" +#define WINPR_BUILD_CONFIG "${WINPR_BUILD_CONFIG}" +#define WINPR_BUILD_TYPE "${CMAKE_BUILD_TYPE}" + +#endif /* WINPR_BUILD_FLAGS_H */ diff --git a/winpr/include/config/config.h.in b/winpr/include/config/config.h.in new file mode 100644 index 0000000..8d289aa --- /dev/null +++ b/winpr/include/config/config.h.in @@ -0,0 +1,46 @@ +#ifndef WINPR_CONFIG_H +#define WINPR_CONFIG_H + +/* Include files */ +#cmakedefine WINPR_HAVE_FCNTL_H +#cmakedefine WINPR_HAVE_UNISTD_H +#cmakedefine WINPR_HAVE_INTTYPES_H +#cmakedefine WINPR_HAVE_STDBOOL_H +#cmakedefine WINPR_HAVE_AIO_H +#cmakedefine WINPR_HAVE_SYS_FILIO_H +#cmakedefine WINPR_HAVE_SYS_SELECT_H +#cmakedefine WINPR_HAVE_SYS_SOCKIO_H +#cmakedefine WINPR_HAVE_SYS_EVENTFD_H +#cmakedefine WINPR_HAVE_SYS_TIMERFD_H +#cmakedefine WINPR_HAVE_TM_GMTOFF +#cmakedefine WINPR_HAVE_AIO_H +#cmakedefine WINPR_HAVE_POLL_H +#cmakedefine WINPR_HAVE_SYSLOG_H +#cmakedefine WINPR_HAVE_JOURNALD_H +#cmakedefine WINPR_HAVE_PTHREAD_MUTEX_TIMEDLOCK +#cmakedefine WINPR_HAVE_EXECINFO_H +#cmakedefine WINPR_HAVE_GETLOGIN_R +#cmakedefine WINPR_HAVE_GETPWUID_R +#cmakedefine WINPR_HAVE_STRNDUP +#cmakedefine WINPR_HAVE_UNWIND_H +#cmakedefine WINPR_WITH_PNG + +#cmakedefine WINPR_HAVE_STRERROR_R + +#cmakedefine WITH_EVENTFD_READ_WRITE + +#cmakedefine WITH_NATIVE_SSPI +#cmakedefine WITH_INTERNAL_RC4 +#cmakedefine WITH_INTERNAL_MD4 +#cmakedefine WITH_INTERNAL_MD5 + +#cmakedefine WITH_DEBUG_NTLM +#cmakedefine WITH_DEBUG_THREADS +#cmakedefine WITH_DEBUG_EVENTS +#cmakedefine WITH_DEBUG_MUTEX + +#cmakedefine WINPR_UTILS_IMAGE_WEBP +#cmakedefine WINPR_UTILS_IMAGE_PNG +#cmakedefine WINPR_UTILS_IMAGE_JPEG + +#endif /* WINPR_CONFIG_H */ diff --git a/winpr/include/config/version.h.in b/winpr/include/config/version.h.in new file mode 100644 index 0000000..8b8c0ab --- /dev/null +++ b/winpr/include/config/version.h.in @@ -0,0 +1,32 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Version includes + * + * Copyright 2013 Thincast Technologies GmbH + * Copyright 2013 Bernhard Miklautz <bernhard.miklautz@thincast.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef WINPR_VERSION_H_ +#define WINPR_VERSION_H_ + +#define WINPR_VERSION_MAJOR ${WINPR_VERSION_MAJOR} +#define WINPR_VERSION_MINOR ${WINPR_VERSION_MINOR} +#define WINPR_VERSION_REVISION ${WINPR_VERSION_REVISION} +#define WINPR_VERSION_SUFFIX "${WINPR_VERSION_SUFFIX}" +#define WINPR_API_VERSION "${WINPR_API_VERSION}" +#define WINPR_VERSION "${WINPR_VERSION}" +#define WINPR_VERSION_FULL "${WINPR_VERSION_FULL}" +#define WINPR_GIT_REVISION "${GIT_REVISION}" + +#endif // _WINPR_VERSION_H_ diff --git a/winpr/include/config/wtypes.h.in b/winpr/include/config/wtypes.h.in new file mode 100644 index 0000000..14869d8 --- /dev/null +++ b/winpr/include/config/wtypes.h.in @@ -0,0 +1,606 @@ +/** + * WinPR: Windows Portable Runtime + * Windows Data Types + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_WTYPES_H +#define WINPR_WTYPES_H + +#include <winpr/platform.h> + +// C99 related macros +#if defined(__STDC__) && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) +#define WINPR_RESTRICT restrict +#elif defined(_MSC_VER) && _MSC_VER >= 1900 +#define WINPR_RESTRICT __restrict +#else +#define WINPR_RESTRICT +#endif + +// C23 related macros +#if defined(__STDC__) && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L) +#define WINPR_FALLTHROUGH [[fallthrough]]; +#elif defined(__clang__) +#define WINPR_FALLTHROUGH __attribute__((fallthrough)); +#elif defined(__GNUC__) && (__GNUC__ >= 7) +#define WINPR_FALLTHROUGH __attribute__((fallthrough)); +#else +#define WINPR_FALLTHROUGH +#endif + +/* Set by CMake during configuration */ +#cmakedefine WINPR_HAVE_STDINT_H +#cmakedefine WINPR_HAVE_STDBOOL_H + +#if !defined(_MSC_VER) || _MSC_VER >= 1900 +/* Microsoft's inttypes.h is broken before MSVC 2015 */ +#cmakedefine WINPR_HAVE_INTTYPES_H +#endif + +/* MSDN: Windows Data Types - http://msdn.microsoft.com/en-us/library/aa383751/ */ +/* [MS-DTYP]: Windows Data Types - http://msdn.microsoft.com/en-us/library/cc230273/ */ + +#include <wchar.h> +#include <winpr/windows.h> + +#include <winpr/spec.h> + +#ifdef WINPR_HAVE_STDBOOL_H +#include <stdbool.h> +#endif + +#ifdef WINPR_HAVE_STDINT_H +#include <stdint.h> +#endif + +#ifdef WINPR_HAVE_INTTYPES_H +#include <inttypes.h> +#endif + +#include <limits.h> + +#if defined(_WIN32) || defined(__MINGW32__) +#include <wtypes.h> + +/* Handle missing ssize_t on Windows */ +#ifdef _WIN64 +typedef long long LONG_PTR; +#else +typedef long LONG_PTR; +#endif + +#if ssize_t +typedef ssize_t SSIZE_T +#else +typedef LONG_PTR SSIZE_T; +#endif + +#endif + +#if defined(__OBJC__) && defined(__APPLE__) +#include <objc/objc.h> +#endif + +#ifndef CONST +#define CONST const +#endif + +#ifndef VOID +#define VOID void +#endif + +WINPR_PRAGMA_DIAG_PUSH +WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO + +#if !defined(_WIN32) && !defined(__MINGW32__) + +#define CALLBACK + +#define WINAPI +#define CDECL + +#ifndef FAR +#define FAR +#endif + +#ifndef NEAR +#define NEAR +#endif + +#ifdef WINPR_HAVE_STDINT_H +typedef int8_t __int8; +typedef uint8_t __uint8; +typedef int16_t __int16; +typedef uint16_t __uint16; +typedef int32_t __int32; +typedef uint32_t __uint32; +typedef int64_t __int64; +typedef uint64_t __uint64; +#else +#if UCHAR_MAX == 0xFF +typedef signed char __int8; +typedef unsigned char __uint8; +#else +#error "8-bit type not configured" +#endif +#if USHRT_MAX == 0xFFFF +typedef short __int16; +typedef unsigned short __uint16; +#elif UINT_MAX == 0xFFFF +typedef int __int16; +typedef unsigned int __uint16; +#error "16-bit type not configured" +#endif +#if UINT_MAX == 0xFFFFFFFF +typedef int __int32; +typedef unsigned int __uint32; +#elif ULONG_MAX == 0xFFFFFFFF +typedef long __int32; +typedef unsigned long __uint32; +#else +#error "32-bit type not configured" +#endif +#if ULONG_MAX == 0xFFFFFFFFFFFFFFFF +typedef long __int64; +typedef unsigned long __uint64; +#elif ULLONG_MAX == 0xFFFFFFFFFFFFFFFF +typedef long long __int64; +typedef unsigned long long __uint64; +#else +#error "64-bit type not configured" +#endif +#endif /* WINPR_HAVE_STDINT_H */ + +#ifdef WINPR_HAVE_STDINT_H +#if defined(__ILP64__) || defined(__LP64__) +#define __int3264 int64_t +#define __uint3264 uint64_t +#else +#define __int3264 int32_t +#define __uint3264 uint32_t +#endif +#else +#if defined(__ILP64__) || defined(__LP64__) +#define __int3264 __int64 +#define __uint3264 __uint64 +#else +#define __int3264 __int32 +#define __uint3264 __uint32 +#endif +#endif /* WINPR_HAVE_STDINT_H */ + + +typedef void* PVOID, *LPVOID, *PVOID64, *LPVOID64; + +#ifndef XMD_H /* X11/Xmd.h typedef collision with BOOL */ +#ifndef __OBJC__ /* objc.h typedef collision with BOOL */ +#ifndef __APPLE__ +typedef __int32 BOOL; +#else /* __APPLE__ */ +#include <TargetConditionals.h> + +/* ensure compatibility with objc libraries */ +#if (defined(TARGET_OS_IPHONE) && (TARGET_OS_IPHONE != 0) && defined(__LP64__)) || (defined(TARGET_OS_WATCH) && (TARGET_OS_WATCH != 0)) +typedef bool BOOL; +#else +typedef signed char BOOL; +#endif +#endif /* __APPLE__ */ +#endif /* __OBJC__ */ +#endif /* XMD_H */ + +typedef BOOL* PBOOL, *LPBOOL; + +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef XMD_H /* X11/Xmd.h typedef collision with BYTE */ +typedef __uint8 BYTE; +#endif /* XMD_H */ +typedef BYTE byte, *PBYTE, *LPBYTE; +typedef BYTE BOOLEAN, PBOOLEAN; + +#if CHAR_BIT == 8 +typedef char CHAR; +typedef unsigned char UCHAR; +#else +typedef __int8 CHAR; +typedef __uint8 UCHAR; +#endif +typedef CHAR CCHAR, *PCHAR, *LPCH, *PCH, *PSTR, *LPSTR; +typedef const CHAR* LPCCH, *PCCH, *LPCSTR, *PCSTR; +typedef UCHAR* PUCHAR; + +typedef __uint16 WCHAR; +typedef WCHAR UNICODE, *PWCHAR, *LPWCH, *PWCH, *BSTR, *LMSTR, *LPWSTR, *PWSTR; +typedef const WCHAR* LPCWCH, *PCWCH, *LMCSTR, *LPCWSTR, *PCWSTR; + +typedef __int16 SHORT, *PSHORT; +typedef __int32 INT, *PINT, *LPINT; +typedef __int32 LONG, *PLONG, *LPLONG; +typedef __int64 LONGLONG, *PLONGLONG; + +typedef __uint32 UINT, *PUINT, *LPUINT; +typedef __uint16 USHORT, *PUSHORT; +typedef __uint32 ULONG, *PULONG; +typedef __uint64 ULONGLONG, *PULONGLONG; + +#ifndef XMD_H /* X11/Xmd.h typedef collisions */ +typedef __int8 INT8; +typedef __int16 INT16; +typedef __int32 INT32; +typedef __int64 INT64; +#endif +typedef INT8* PINT8; +typedef INT16* PINT16; +typedef INT32* PINT32; +typedef INT64* PINT64; + +typedef __int32 LONG32, *PLONG32; +#ifndef LONG64 /* X11/Xmd.h uses/defines LONG64 */ +typedef __int64 LONG64, *PLONG64; +#endif + +typedef __uint8 UINT8, *PUINT8; +typedef __uint16 UINT16, *PUINT16; +typedef __uint32 UINT32, *PUINT32; +typedef __uint64 UINT64, *PUINT64; +typedef __uint64 ULONG64, *PULONG64; + +typedef __uint16 WORD, *PWORD, *LPWORD; +typedef __uint32 DWORD, DWORD32, *PDWORD, *LPDWORD, *PDWORD32; +typedef __uint64 DWORD64, DWORDLONG, QWORD, *PDWORD64, *PDWORDLONG, *PQWORD; + +typedef __int3264 INT_PTR, *PINT_PTR; +typedef __uint3264 UINT_PTR, *PUINT_PTR; +typedef __int3264 LONG_PTR, *PLONG_PTR; +typedef __uint3264 ULONG_PTR, *PULONG_PTR; +typedef __uint3264 DWORD_PTR, *PDWORD_PTR; + +typedef ULONG_PTR SIZE_T, *PSIZE_T; +typedef LONG_PTR SSIZE_T, *PSSIZE_T; + +typedef float FLOAT; + +typedef double DOUBLE; + +typedef void* HANDLE, *PHANDLE, *LPHANDLE; +typedef HANDLE HINSTANCE; +typedef HANDLE HMODULE; +typedef HANDLE HWND; +typedef HANDLE HBITMAP; +typedef HANDLE HICON; +typedef HANDLE HCURSOR; +typedef HANDLE HBRUSH; +typedef HANDLE HMENU; + +typedef DWORD HCALL; + +typedef ULONG error_status_t; +typedef LONG HRESULT; +typedef LONG SCODE; +typedef SCODE* PSCODE; + +typedef struct s_POINTL /* ptl */ +{ + LONG x; + LONG y; +} POINTL, *PPOINTL; + +typedef struct tagSIZE +{ + LONG cx; + LONG cy; +} SIZE, *PSIZE, *LPSIZE; + +typedef SIZE SIZEL; + +typedef struct s_GUID +{ + UINT32 Data1; + UINT16 Data2; + UINT16 Data3; + BYTE Data4[8]; +} GUID, UUID, *PGUID, *LPGUID, *LPCGUID; +typedef GUID CLSID; + +typedef struct s_LUID +{ + DWORD LowPart; + LONG HighPart; +} LUID, *PLUID; + +typedef GUID IID; +typedef IID* REFIID; + +#ifdef UNICODE +#define _T(x) L ## x +#else +#define _T(x) x +#endif + +#ifdef UNICODE +typedef LPWSTR PTSTR; +typedef LPWSTR LPTCH; +typedef LPWSTR LPTSTR; +typedef LPCWSTR LPCTSTR; +#else +typedef LPSTR PTSTR; +typedef LPSTR LPTCH; +typedef LPSTR LPTSTR; +typedef LPCSTR LPCTSTR; +#endif + +typedef union u_ULARGE_INTEGER +{ + struct + { + DWORD LowPart; + DWORD HighPart; + } DUMMYSTRUCTNAME; + + struct + { + DWORD LowPart; + DWORD HighPart; + } u; + + ULONGLONG QuadPart; +} ULARGE_INTEGER, *PULARGE_INTEGER; + +typedef union u_LARGE_INTEGER +{ + struct + { + DWORD LowPart; + LONG HighPart; + } DUMMYSTRUCTNAME; + + struct + { + DWORD LowPart; + LONG HighPart; + } u; + + LONGLONG QuadPart; +} LARGE_INTEGER, *PLARGE_INTEGER; + +typedef struct s_FILETIME +{ + DWORD dwLowDateTime; + DWORD dwHighDateTime; +} FILETIME, *PFILETIME, *LPFILETIME; + +typedef struct s_SYSTEMTIME +{ + WORD wYear; + WORD wMonth; + WORD wDayOfWeek; + WORD wDay; + WORD wHour; + WORD wMinute; + WORD wSecond; + WORD wMilliseconds; +} SYSTEMTIME, *PSYSTEMTIME, *LPSYSTEMTIME; + +typedef struct s_RPC_SID_IDENTIFIER_AUTHORITY +{ + BYTE Value[6]; +} RPC_SID_IDENTIFIER_AUTHORITY; + +typedef DWORD SECURITY_INFORMATION, *PSECURITY_INFORMATION; + +typedef struct s_RPC_SID +{ + UCHAR Revision; + UCHAR SubAuthorityCount; + RPC_SID_IDENTIFIER_AUTHORITY IdentifierAuthority; + ULONG SubAuthority[1]; +} RPC_SID, *PRPC_SID, *PSID; + +typedef struct s_ACL +{ + UCHAR AclRevision; + UCHAR Sbz1; + USHORT AclSize; + USHORT AceCount; + USHORT Sbz2; +} ACL, *PACL; + +typedef struct s_SECURITY_DESCRIPTOR +{ + UCHAR Revision; + UCHAR Sbz1; + USHORT Control; + PSID Owner; + PSID Group; + PACL Sacl; + PACL Dacl; +} SECURITY_DESCRIPTOR, *PSECURITY_DESCRIPTOR; + +typedef WORD SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL; + +typedef struct s_SECURITY_ATTRIBUTES +{ + DWORD nLength; + LPVOID lpSecurityDescriptor; + BOOL bInheritHandle; +} SECURITY_ATTRIBUTES, *PSECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES; + +typedef struct s_PROCESS_INFORMATION +{ + HANDLE hProcess; + HANDLE hThread; + DWORD dwProcessId; + DWORD dwThreadId; +} PROCESS_INFORMATION, *PPROCESS_INFORMATION, *LPPROCESS_INFORMATION; + +typedef DWORD (*PTHREAD_START_ROUTINE)(LPVOID lpThreadParameter); +typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE; + +typedef void* FARPROC; + +typedef struct tagDEC +{ + USHORT wReserved; + union + { + struct + { + BYTE scale; + BYTE sign; + } DUMMYSTRUCTNAME; + USHORT signscale; + } DUMMYUNIONNAME; + ULONG Hi32; + union + { + struct + { + ULONG Lo32; + ULONG Mid32; + } DUMMYSTRUCTNAME2; + ULONGLONG Lo64; + } DUMMYUNIONNAME2; +} DECIMAL; + +typedef DECIMAL* LPDECIMAL; + +#define DECIMAL_NEG ((BYTE) 0x80) +#define DECIMAL_SETZERO(dec) { (dec).Lo64 = 0; (dec).Hi32 = 0; (dec).signscale = 0; } + +typedef DWORD LCID; +typedef PDWORD PLCID; +typedef WORD LANGID; + +#endif /* _WIN32 not defined */ + +typedef void* PCONTEXT_HANDLE; +typedef PCONTEXT_HANDLE* PPCONTEXT_HANDLE; + +#ifndef _NTDEF +typedef LONG NTSTATUS; +typedef NTSTATUS* PNTSTATUS; +#endif + +#ifndef _LPCVOID_DEFINED +#define _LPCVOID_DEFINED +typedef const VOID* LPCVOID; +#endif + +#ifndef _LPCBYTE_DEFINED +#define _LPCBYTE_DEFINED +typedef const BYTE* LPCBYTE; +#endif + +/* integer format specifiers */ +#ifndef WINPR_HAVE_INTTYPES_H +#define PRId8 "hhd" +#define PRIi8 "hhi" +#define PRIu8 "hhu" +#define PRIo8 "hho" +#define PRIx8 "hhx" +#define PRIX8 "hhX" +#define PRId16 "hd" +#define PRIi16 "hi" +#define PRIu16 "hu" +#define PRIo16 "ho" +#define PRIx16 "hx" +#define PRIX16 "hX" +#if defined(_MSC_VER) +#define PRId32 "I32d" +#define PRIi32 "I32i" +#define PRIu32 "I32u" +#define PRIo32 "I32o" +#define PRIx32 "I32x" +#define PRIX32 "I32X" +#define PRId64 "I64d" +#define PRIi64 "I64i" +#define PRIu64 "I64u" +#define PRIo64 "I64o" +#define PRIx64 "I64x" +#define PRIX64 "I64X" +#else +#define PRId32 "d" +#define PRIi32 "i" +#define PRIu32 "u" +#define PRIo32 "o" +#define PRIx32 "x" +#define PRIX32 "X" +#if ULONG_MAX == 0xFFFFFFFFFFFFFFFF +#define PRId64 "ld" +#define PRIi64 "li" +#define PRIu64 "lu" +#define PRIo64 "lo" +#define PRIx64 "lx" +#define PRIX64 "lX" +#else +#define PRId64 "lld" +#define PRIi64 "lli" +#define PRIu64 "llu" +#define PRIo64 "llo" +#define PRIx64 "llx" +#define PRIX64 "llX" +#endif +#endif /* _MSC_VER */ +#endif /* WINPR_HAVE_INTTYPES_H not defined*/ + +#ifndef SSIZE_MAX +#if defined(_POSIX_SSIZE_MAX) +#define SSIZE_MAX _POSIX_SSIZE_MAX +#elif defined(_WIN64) +#define SSIZE_MAX _I64_MAX +#elif defined(_WIN32) +#define SSIZE_MAX LONG_MAX +#else +#define SSIZE_MAX LONG_MAX +#endif +#endif + +#if defined(_MSC_VER) && _MSC_VER < 1900 +/* %z not supported before MSVC 2015 */ +#define PRIdz "Id" +#define PRIiz "Ii" +#define PRIuz "Iu" +#define PRIoz "Io" +#define PRIxz "Ix" +#define PRIXz "IX" +#else +#define PRIdz "zd" +#define PRIiz "zi" +#define PRIuz "zu" +#define PRIoz "zo" +#define PRIxz "zx" +#define PRIXz "zX" +#endif + + +#include <winpr/user.h> + +#ifndef _WIN32 +#define _fseeki64(fp, offset, origin) fseeko(fp, offset, origin) +#define _ftelli64(fp) ftello(fp) +#endif + +WINPR_PRAGMA_DIAG_POP + +#endif /* WINPR_WTYPES_H */ diff --git a/winpr/include/winpr/asn1.h b/winpr/include/winpr/asn1.h new file mode 100644 index 0000000..d4b6443 --- /dev/null +++ b/winpr/include/winpr/asn1.h @@ -0,0 +1,212 @@ +/** + * WinPR: Windows Portable Runtime + * ASN1 encoder / decoder + * + * Copyright 2022 David Fort <contact@hardening-consulting.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_ASN1_H_ +#define WINPR_ASN1_H_ + +#include <winpr/winpr.h> +#include <winpr/wtypes.h> +#include <winpr/stream.h> + +#define ER_TAG_MASK 0x1F + +enum +{ + ER_TAG_BOOLEAN = 0x01, + ER_TAG_INTEGER = 0x02, + ER_TAG_BIT_STRING = 0x03, + ER_TAG_OCTET_STRING = 0x04, + ER_TAG_NULL = 0x05, + ER_TAG_OBJECT_IDENTIFIER = 0x06, + ER_TAG_ENUMERATED = 0x0A, + ER_TAG_UTF8STRING = 0x0C, + ER_TAG_PRINTABLE_STRING = 0x13, + ER_TAG_IA5STRING = 0x16, + ER_TAG_UTCTIME = 0x17, + ER_TAG_GENERAL_STRING = 0x1B, + ER_TAG_GENERALIZED_TIME = 0x18, + + ER_TAG_APP = 0x60, + ER_TAG_SEQUENCE = 0x30, + ER_TAG_SEQUENCE_OF = 0x30, + ER_TAG_SET = 0x31, + ER_TAG_SET_OF = 0x31, + + ER_TAG_CONTEXTUAL = 0xA0 +}; + +/** @brief rules for encoding */ +typedef enum +{ + WINPR_ASN1_BER, + WINPR_ASN1_DER +} WinPrAsn1EncodingRule; + +typedef struct WinPrAsn1Encoder WinPrAsn1Encoder; + +struct WinPrAsn1Decoder +{ + WinPrAsn1EncodingRule encoding; + wStream source; +}; + +typedef struct WinPrAsn1Decoder WinPrAsn1Decoder; + +typedef BYTE WinPrAsn1_tag; +typedef BYTE WinPrAsn1_tagId; +typedef BOOL WinPrAsn1_BOOL; +typedef INT32 WinPrAsn1_INTEGER; +typedef INT32 WinPrAsn1_ENUMERATED; +typedef char* WinPrAsn1_STRING; +typedef char* WinPrAsn1_IA5STRING; +typedef struct +{ + size_t len; + BYTE* data; +} WinPrAsn1_MemoryChunk; + +typedef WinPrAsn1_MemoryChunk WinPrAsn1_OID; +typedef WinPrAsn1_MemoryChunk WinPrAsn1_OctetString; + +typedef struct +{ + UINT16 year; + UINT8 month; + UINT8 day; + UINT8 hour; + UINT8 minute; + UINT8 second; + char tz; +} WinPrAsn1_UTCTIME; + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + + WINPR_API void WinPrAsn1FreeOID(WinPrAsn1_OID* poid); + WINPR_API void WinPrAsn1FreeOctetString(WinPrAsn1_OctetString* octets); + + /* decoder functions */ + + WINPR_API void WinPrAsn1Decoder_Init(WinPrAsn1Decoder* dec, WinPrAsn1EncodingRule encoding, + wStream* source); + WINPR_API void WinPrAsn1Decoder_InitMem(WinPrAsn1Decoder* dec, WinPrAsn1EncodingRule encoding, + const BYTE* source, size_t len); + + WINPR_API BOOL WinPrAsn1DecPeekTag(WinPrAsn1Decoder* dec, WinPrAsn1_tag* tag); + WINPR_API size_t WinPrAsn1DecReadTagAndLen(WinPrAsn1Decoder* dec, WinPrAsn1_tag* tag, + size_t* len); + WINPR_API size_t WinPrAsn1DecPeekTagAndLen(WinPrAsn1Decoder* dec, WinPrAsn1_tag* tag, + size_t* len); + WINPR_API size_t WinPrAsn1DecReadTagLenValue(WinPrAsn1Decoder* dec, WinPrAsn1_tag* tag, + size_t* len, WinPrAsn1Decoder* value); + WINPR_API size_t WinPrAsn1DecReadBoolean(WinPrAsn1Decoder* dec, WinPrAsn1_BOOL* target); + WINPR_API size_t WinPrAsn1DecReadInteger(WinPrAsn1Decoder* dec, WinPrAsn1_INTEGER* target); + WINPR_API size_t WinPrAsn1DecReadEnumerated(WinPrAsn1Decoder* dec, + WinPrAsn1_ENUMERATED* target); + WINPR_API size_t WinPrAsn1DecReadOID(WinPrAsn1Decoder* dec, WinPrAsn1_OID* target, + BOOL allocate); + WINPR_API size_t WinPrAsn1DecReadOctetString(WinPrAsn1Decoder* dec, + WinPrAsn1_OctetString* target, BOOL allocate); + WINPR_API size_t WinPrAsn1DecReadIA5String(WinPrAsn1Decoder* dec, WinPrAsn1_IA5STRING* target); + WINPR_API size_t WinPrAsn1DecReadGeneralString(WinPrAsn1Decoder* dec, WinPrAsn1_STRING* target); + WINPR_API size_t WinPrAsn1DecReadUtcTime(WinPrAsn1Decoder* dec, WinPrAsn1_UTCTIME* target); + WINPR_API size_t WinPrAsn1DecReadNull(WinPrAsn1Decoder* dec); + + WINPR_API size_t WinPrAsn1DecReadApp(WinPrAsn1Decoder* dec, WinPrAsn1_tagId* tagId, + WinPrAsn1Decoder* setDec); + WINPR_API size_t WinPrAsn1DecReadSequence(WinPrAsn1Decoder* dec, WinPrAsn1Decoder* seqDec); + WINPR_API size_t WinPrAsn1DecReadSet(WinPrAsn1Decoder* dec, WinPrAsn1Decoder* setDec); + + WINPR_API size_t WinPrAsn1DecReadContextualTag(WinPrAsn1Decoder* dec, WinPrAsn1_tagId* tagId, + WinPrAsn1Decoder* ctxtDec); + WINPR_API size_t WinPrAsn1DecPeekContextualTag(WinPrAsn1Decoder* dec, WinPrAsn1_tagId* tagId, + WinPrAsn1Decoder* ctxtDec); + + WINPR_API size_t WinPrAsn1DecReadContextualBool(WinPrAsn1Decoder* dec, WinPrAsn1_tagId tagId, + BOOL* error, WinPrAsn1_BOOL* target); + WINPR_API size_t WinPrAsn1DecReadContextualInteger(WinPrAsn1Decoder* dec, WinPrAsn1_tagId tagId, + BOOL* error, WinPrAsn1_INTEGER* target); + WINPR_API size_t WinPrAsn1DecReadContextualOID(WinPrAsn1Decoder* dec, WinPrAsn1_tagId tagId, + BOOL* error, WinPrAsn1_OID* target, + BOOL allocate); + WINPR_API size_t WinPrAsn1DecReadContextualOctetString(WinPrAsn1Decoder* dec, + WinPrAsn1_tagId tagId, BOOL* error, + WinPrAsn1_OctetString* target, + BOOL allocate); + WINPR_API size_t WinPrAsn1DecReadContextualSequence(WinPrAsn1Decoder* dec, + WinPrAsn1_tagId tagId, BOOL* error, + WinPrAsn1Decoder* target); + WINPR_API wStream WinPrAsn1DecGetStream(WinPrAsn1Decoder* dec); + + /* encoder functions */ + + WINPR_API void WinPrAsn1Encoder_Free(WinPrAsn1Encoder** penc); + WINPR_API WinPrAsn1Encoder* WinPrAsn1Encoder_New(WinPrAsn1EncodingRule encoding); + + WINPR_API void WinPrAsn1Encoder_Reset(WinPrAsn1Encoder* enc); + + WINPR_API BOOL WinPrAsn1EncAppContainer(WinPrAsn1Encoder* enc, WinPrAsn1_tagId tagId); + WINPR_API BOOL WinPrAsn1EncSeqContainer(WinPrAsn1Encoder* enc); + WINPR_API BOOL WinPrAsn1EncContextualSeqContainer(WinPrAsn1Encoder* enc, WinPrAsn1_tagId tagId); + WINPR_API BOOL WinPrAsn1EncSetContainer(WinPrAsn1Encoder* enc); + WINPR_API BOOL WinPrAsn1EncContextualSetContainer(WinPrAsn1Encoder* enc, WinPrAsn1_tagId tagId); + WINPR_API BOOL WinPrAsn1EncContextualContainer(WinPrAsn1Encoder* enc, WinPrAsn1_tagId tagId); + WINPR_API BOOL WinPrAsn1EncOctetStringContainer(WinPrAsn1Encoder* enc); + WINPR_API BOOL WinPrAsn1EncContextualOctetStringContainer(WinPrAsn1Encoder* enc, + WinPrAsn1_tagId tagId); + WINPR_API size_t WinPrAsn1EncEndContainer(WinPrAsn1Encoder* enc); + + WINPR_API size_t WinPrAsn1EncRawContent(WinPrAsn1Encoder* enc, const WinPrAsn1_MemoryChunk* c); + WINPR_API size_t WinPrAsn1EncContextualRawContent(WinPrAsn1Encoder* enc, WinPrAsn1_tagId tagId, + const WinPrAsn1_MemoryChunk* c); + WINPR_API size_t WinPrAsn1EncInteger(WinPrAsn1Encoder* enc, WinPrAsn1_INTEGER integer); + WINPR_API size_t WinPrAsn1EncContextualInteger(WinPrAsn1Encoder* enc, WinPrAsn1_tagId tagId, + WinPrAsn1_INTEGER integer); + WINPR_API size_t WinPrAsn1EncBoolean(WinPrAsn1Encoder* enc, WinPrAsn1_BOOL b); + WINPR_API size_t WinPrAsn1EncContextualBoolean(WinPrAsn1Encoder* enc, WinPrAsn1_tagId tagId, + WinPrAsn1_BOOL b); + WINPR_API size_t WinPrAsn1EncEnumerated(WinPrAsn1Encoder* enc, WinPrAsn1_ENUMERATED e); + WINPR_API size_t WinPrAsn1EncContextualEnumerated(WinPrAsn1Encoder* enc, WinPrAsn1_tagId tagId, + WinPrAsn1_ENUMERATED e); + + WINPR_API size_t WinPrAsn1EncOID(WinPrAsn1Encoder* enc, const WinPrAsn1_OID* oid); + WINPR_API size_t WinPrAsn1EncContextualOID(WinPrAsn1Encoder* enc, WinPrAsn1_tagId tagId, + const WinPrAsn1_OID* oid); + WINPR_API size_t WinPrAsn1EncOctetString(WinPrAsn1Encoder* enc, + const WinPrAsn1_OctetString* oid); + WINPR_API size_t WinPrAsn1EncContextualOctetString(WinPrAsn1Encoder* enc, WinPrAsn1_tagId tagId, + const WinPrAsn1_OctetString* oid); + WINPR_API size_t WinPrAsn1EncIA5String(WinPrAsn1Encoder* enc, WinPrAsn1_IA5STRING ia5); + WINPR_API size_t WinPrAsn1EncGeneralString(WinPrAsn1Encoder* enc, WinPrAsn1_STRING str); + WINPR_API size_t WinPrAsn1EncContextualIA5String(WinPrAsn1Encoder* enc, WinPrAsn1_tagId tagId, + WinPrAsn1_IA5STRING ia5); + WINPR_API size_t WinPrAsn1EncUtcTime(WinPrAsn1Encoder* enc, const WinPrAsn1_UTCTIME* utc); + WINPR_API size_t WinPrAsn1EncContextualUtcTime(WinPrAsn1Encoder* enc, WinPrAsn1_tagId tagId, + const WinPrAsn1_UTCTIME* utc); + + WINPR_API BOOL WinPrAsn1EncStreamSize(WinPrAsn1Encoder* enc, size_t* s); + WINPR_API BOOL WinPrAsn1EncToStream(WinPrAsn1Encoder* enc, wStream* s); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* WINPR_ASN1_H_ */ diff --git a/winpr/include/winpr/assert.h b/winpr/include/winpr/assert.h new file mode 100644 index 0000000..059cdeb --- /dev/null +++ b/winpr/include/winpr/assert.h @@ -0,0 +1,60 @@ +/** + * WinPR: Windows Portable Runtime + * Runtime ASSERT macros + * + * Copyright 2021 Armin Novak <armin.novak@thincast.com> + * Copyright 2021 Thincast Technologies GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_ASSERT_H +#define WINPR_ASSERT_H + +#include <stdlib.h> +#include <winpr/winpr.h> +#include <winpr/wtypes.h> +#include <winpr/wlog.h> +#include <winpr/debug.h> + +#if defined(WITH_VERBOSE_WINPR_ASSERT) && (WITH_VERBOSE_WINPR_ASSERT != 0) +#ifdef __cplusplus +extern "C" +{ +#endif +#define WINPR_ASSERT(cond) \ + do \ + { \ + if (!(cond)) \ + winpr_int_assert(#cond, __FILE__, __func__, __LINE__); \ + } while (0) + + static INLINE WINPR_NORETURN(void winpr_int_assert(const char* condstr, const char* file, + const char* fkt, size_t line)) + { + wLog* _log_cached_ptr = WLog_Get("com.freerdp.winpr.assert"); + WLog_Print(_log_cached_ptr, WLOG_FATAL, "%s [%s:%s:%" PRIuz "]", condstr, file, fkt, line); + winpr_log_backtrace_ex(_log_cached_ptr, WLOG_FATAL, 20); + abort(); + } + +#ifdef __cplusplus +} +#endif + +#else +#include <assert.h> +#define WINPR_ASSERT(cond) assert(cond) +#endif + +#endif /* WINPR_ERROR_H */ diff --git a/winpr/include/winpr/bcrypt.h b/winpr/include/winpr/bcrypt.h new file mode 100644 index 0000000..db36a1f --- /dev/null +++ b/winpr/include/winpr/bcrypt.h @@ -0,0 +1,338 @@ +/** + * WinPR: Windows Portable Runtime + * Cryptography API: Next Generation + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_BCRYPT_H +#define WINPR_BCRYPT_H + +#ifdef _WIN32 +#include <bcrypt.h> +#else + +#include <winpr/winpr.h> +#include <winpr/wtypes.h> + +typedef PVOID BCRYPT_HANDLE; +typedef PVOID BCRYPT_ALG_HANDLE; +typedef PVOID BCRYPT_KEY_HANDLE; +typedef PVOID BCRYPT_HASH_HANDLE; +typedef PVOID BCRYPT_SECRET_HANDLE; + +#define BCRYPT_RSA_ALGORITHM \ + (const WCHAR*)"R\x00S\x00" \ + "A\x00\x00" +#define BCRYPT_RSA_SIGN_ALGORITHM \ + (const WCHAR*)"R\x00S\x00" \ + "A\x00_\x00S\x00I\x00G\x00N\x00\x00" +#define BCRYPT_DH_ALGORITHM (const WCHAR*)"D\x00H\x00\x00" +#define BCRYPT_DSA_ALGORITHM \ + (const WCHAR*)"D\x00S\x00" \ + "A\x00\x00" +#define BCRYPT_RC2_ALGORITHM \ + (const WCHAR*)"R\x00" \ + "C\x002\x00\x00" +#define BCRYPT_RC4_ALGORITHM \ + (const WCHAR*)"R\x00" \ + "C\x004\x00\x00" +#define BCRYPT_AES_ALGORITHM \ + (const WCHAR*)"A\x00" \ + "E\x00S\x00\x00" +#define BCRYPT_DES_ALGORITHM \ + (const WCHAR*)"D\x00" \ + "E\x00S\x00\x00" +#define BCRYPT_DESX_ALGORITHM \ + (const WCHAR*)"D\x00" \ + "E\x00S\x00X\x00\x00" +#define BCRYPT_3DES_ALGORITHM \ + (const WCHAR*)"3\x00" \ + "D\x00" \ + "E\x00S\x00\x00" +#define BCRYPT_3DES_112_ALGORITHM \ + (const WCHAR*)"3\x00" \ + "D\x00" \ + "E\x00S\x00_\x001\x001\x002\x00\x00" +#define BCRYPT_MD2_ALGORITHM \ + (const WCHAR*)"M\x00" \ + "D\x002\x00\x00" +#define BCRYPT_MD4_ALGORITHM \ + (const WCHAR*)"M\x00" \ + "D\x004\x00\x00" +#define BCRYPT_MD5_ALGORITHM \ + (const WCHAR*)"M\x00" \ + "D\x005\x00\x00" +#define BCRYPT_SHA1_ALGORITHM \ + (const WCHAR*)"S\x00H\x00" \ + "A\x001\x00\x00" +#define BCRYPT_SHA256_ALGORITHM \ + (const WCHAR*)"S\x00H\x00" \ + "A\x002\x005\x006\x00\x00" +#define BCRYPT_SHA384_ALGORITHM \ + (const WCHAR*)"S\x00H\x00" \ + "A\x003\x008\x004\x00\x00" +#define BCRYPT_SHA512_ALGORITHM \ + (const WCHAR*)"S\x00H\x00" \ + "A\x005\x001\x002\x00\x00" +#define BCRYPT_AES_GMAC_ALGORITHM \ + (const WCHAR*)"A\x00" \ + "E\x00S\x00-\x00G\x00M\x00" \ + "A\x00" \ + "C\x00\x00" +#define BCRYPT_ECDSA_ALGORITHM \ + (const WCHAR*)"E\x00" \ + "C\x00" \ + "D\x00S\x00" \ + "A\x00\x00" +#define BCRYPT_ECDSA_P256_ALGORITHM \ + (const WCHAR*)"E\x00" \ + "C\x00" \ + "D\x00S\x00" \ + "A\x00_\x00P\x002\x005\x006\x00\x00" +#define BCRYPT_ECDSA_P384_ALGORITHM \ + (const WCHAR*)"E\x00" \ + "C\x00" \ + "D\x00S\x00" \ + "A\x00_\x00P\x003\x008\x004\x00\x00" +#define BCRYPT_ECDSA_P521_ALGORITHM \ + (const WCHAR*)"E\x00" \ + "C\x00" \ + "D\x00S\x00" \ + "A\x00_\x00P\x005\x002\x001\x00\x00" +#define BCRYPT_ECDH_P256_ALGORITHM \ + (const WCHAR*)"E\x00" \ + "C\x00" \ + "D\x00S\x00" \ + "A\x00_\x00P\x002\x005\x006\x00\x00" +#define BCRYPT_ECDH_P384_ALGORITHM \ + (const WCHAR*)"E\x00" \ + "C\x00" \ + "D\x00S\x00" \ + "A\x00_\x00P\x003\x008\x004\x00\x00" +#define BCRYPT_ECDH_P521_ALGORITHM \ + (const WCHAR*)"E\x00" \ + "C\x00" \ + "D\x00S\x00" \ + "A\x00_\x00P\x005\x002\x001\x00\x00" +#define BCRYPT_RNG_ALGORITHM (const WCHAR*)"R\x00N\x00G\x00\x00" +#define BCRYPT_RNG_FIPS186_DSA_ALGORITHM \ + (const WCHAR*)"F\x00I\x00P\x00S\x001\x008\x006\x00" \ + "D\x00S\x00" \ + "A\x00R\x00N\x00G\x00\x00" +#define BCRYPT_RNG_DUAL_EC_ALGORITHM \ + (const WCHAR*)"D\x00U\x00" \ + "A\x00L\x00" \ + "E\x00R\x00N\x00G\x00\x00" + +#define MS_PRIMITIVE_PROVIDER \ + (const WCHAR*)"M\x00i\x00" \ + "c\x00r\x00o\x00s\x00o\x00" \ + "f\x00t\x00 " \ + "\x00P\x00r\x00i\x00m\x00i\x00t\x00i\x00v\x00" \ + "e\x00 " \ + "\x00P\x00r\x00o\x00v\x00i\x00" \ + "d\x00" \ + "e\x00r\x00\x00" + +#define BCRYPT_ALG_HANDLE_HMAC_FLAG 0x00000008 +#define BCRYPT_PROV_DISPATCH 0x00000001 + +#define BCRYPT_OBJECT_LENGTH \ + (const WCHAR*)"O\x00" \ + "b\x00j\x00" \ + "e\x00" \ + "c\x00t\x00L\x00" \ + "e\x00n\x00g\x00t\x00h\x00\x00" +#define BCRYPT_ALGORITHM_NAME \ + (const WCHAR*)"A\x00l\x00g\x00o\x00r\x00i\x00t\x00h\x00m\x00N\x00" \ + "a\x00m\x00" \ + "e\x00\x00" +#define BCRYPT_PROVIDER_HANDLE \ + (const WCHAR*)"P\x00r\x00o\x00v\x00i\x00" \ + "d\x00" \ + "e\x00r\x00H\x00" \ + "a\x00n\x00" \ + "d\x00l\x00" \ + "e\x00\x00" +#define BCRYPT_CHAINING_MODE \ + (const WCHAR*)"C\x00h\x00" \ + "a\x00i\x00n\x00i\x00n\x00g\x00M\x00o\x00" \ + "d\x00" \ + "e\x00\x00" +#define BCRYPT_BLOCK_LENGTH \ + (const WCHAR*)"B\x00l\x00o\x00" \ + "c\x00k\x00L\x00" \ + "e\x00n\x00g\x00t\x00h\x00\x00" +#define BCRYPT_KEY_LENGTH \ + (const WCHAR*)"K\x00" \ + "e\x00y\x00L\x00" \ + "e\x00n\x00g\x00t\x00h\x00\x00" +#define BCRYPT_KEY_OBJECT_LENGTH \ + (const WCHAR*)"K\x00" \ + "e\x00y\x00O\x00" \ + "b\x00j\x00" \ + "e\x00" \ + "c\x00t\x00L\x00" \ + "e\x00n\x00g\x00t\x00h\x00" \ + "\x00" +#define BCRYPT_KEY_STRENGTH \ + (const WCHAR*)"K\x00" \ + "e\x00y\x00S\x00t\x00r\x00" \ + "e\x00n\x00g\x00t\x00h\x00\x00" +#define BCRYPT_KEY_LENGTHS \ + (const WCHAR*)"K\x00" \ + "e\x00y\x00L\x00" \ + "e\x00n\x00g\x00t\x00h\x00s\x00\x00" +#define BCRYPT_BLOCK_SIZE_LIST \ + (const WCHAR*)"B\x00l\x00o\x00" \ + "c\x00k\x00S\x00i\x00z\x00" \ + "e\x00L\x00i\x00s\x00t\x00\x00" +#define BCRYPT_EFFECTIVE_KEY_LENGTH \ + (const WCHAR*)"E\x00" \ + "f\x00" \ + "f\x00" \ + "e\x00" \ + "c\x00t\x00i\x00v\x00" \ + "e\x00K\x00" \ + "e\x00y\x00L\x00" \ + "e\x00n\x00g" \ + "\x00t\x00h\x00\x00" +#define BCRYPT_HASH_LENGTH \ + (const WCHAR*)"H\x00" \ + "a\x00s\x00h\x00" \ + "D\x00i\x00g\x00" \ + "e\x00s\x00t\x00L\x00" \ + "e\x00n\x00g\x00t\x00h" \ + "\x00\x00" +#define BCRYPT_HASH_OID_LIST \ + (const WCHAR*)"H\x00" \ + "a\x00s\x00h\x00O\x00I\x00" \ + "D\x00L\x00i\x00s\x00t\x00\x00" +#define BCRYPT_PADDING_SCHEMES \ + (const WCHAR*)"P\x00" \ + "a\x00" \ + "d\x00" \ + "d\x00i\x00n\x00g\x00S\x00" \ + "c\x00h\x00" \ + "e\x00m\x00" \ + "e\x00s\x00\x00" +#define BCRYPT_SIGNATURE_LENGTH \ + (const WCHAR*)"S\x00i\x00g\x00n\x00" \ + "a\x00t\x00u\x00r\x00" \ + "e\x00L\x00" \ + "e\x00n\x00g\x00t\x00h\x00" \ + "\x00" +#define BCRYPT_HASH_BLOCK_LENGTH \ + (const WCHAR*)"H\x00" \ + "a\x00s\x00h\x00" \ + "B\x00l\x00o\x00" \ + "c\x00k\x00L\x00" \ + "e\x00n\x00g\x00t\x00h\x00" \ + "\x00" +#define BCRYPT_AUTH_TAG_LENGTH \ + (const WCHAR*)"A\x00u\x00t\x00h\x00T\x00" \ + "a\x00g\x00L\x00" \ + "e\x00n\x00g\x00t\x00h\x00\x00" +#define BCRYPT_PRIMITIVE_TYPE \ + (const WCHAR*)"P\x00r\x00i\x00m\x00i\x00t\x00i\x00v\x00" \ + "e\x00T\x00y\x00p\x00" \ + "e\x00\x00" +#define BCRYPT_IS_KEYED_HASH \ + (const WCHAR*)"I\x00s\x00K\x00" \ + "e\x00y\x00" \ + "e\x00" \ + "d\x00H\x00" \ + "a\x00s\x00h\x00\x00" + +#define BCRYPT_KEY_DATA_BLOB \ + (const WCHAR*)"K\x00" \ + "e\x00y\x00" \ + "D\x00" \ + "a\x00t\x00" \ + "a\x00" \ + "B\x00l\x00o\x00" \ + "b\x00\x00" + +#define BCRYPT_BLOCK_PADDING 0x00000001 + +#define BCRYPT_KEY_DATA_BLOB_MAGIC 0x4d42444b +#define BCRYPT_KEY_DATA_BLOB_VERSION1 0x1 + +typedef struct +{ + ULONG dwMagic; + ULONG dwVersion; + ULONG cbKeyData; +} BCRYPT_KEY_DATA_BLOB_HEADER, *PBCRYPT_KEY_DATA_BLOB_HEADER; + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API NTSTATUS BCryptOpenAlgorithmProvider(BCRYPT_ALG_HANDLE* phAlgorithm, LPCWSTR pszAlgId, + LPCWSTR pszImplementation, ULONG dwFlags); + + WINPR_API NTSTATUS BCryptCloseAlgorithmProvider(BCRYPT_ALG_HANDLE hAlgorithm, ULONG dwFlags); + + WINPR_API NTSTATUS BCryptGetProperty(BCRYPT_HANDLE hObject, LPCWSTR pszProperty, + PUCHAR pbOutput, ULONG cbOutput, ULONG* pcbResult, + ULONG dwFlags); + + WINPR_API NTSTATUS BCryptCreateHash(BCRYPT_ALG_HANDLE hAlgorithm, BCRYPT_HASH_HANDLE* phHash, + PUCHAR pbHashObject, ULONG cbHashObject, PUCHAR pbSecret, + ULONG cbSecret, ULONG dwFlags); + + WINPR_API NTSTATUS BCryptDestroyHash(BCRYPT_HASH_HANDLE hHash); + + WINPR_API NTSTATUS BCryptHashData(BCRYPT_HASH_HANDLE hHash, PUCHAR pbInput, ULONG cbInput, + ULONG dwFlags); + + WINPR_API NTSTATUS BCryptFinishHash(BCRYPT_HASH_HANDLE hHash, PUCHAR pbOutput, ULONG cbOutput, + ULONG dwFlags); + + WINPR_API NTSTATUS BCryptGenRandom(BCRYPT_ALG_HANDLE hAlgorithm, PUCHAR pbBuffer, + ULONG cbBuffer, ULONG dwFlags); + + WINPR_API NTSTATUS BCryptGenerateSymmetricKey(BCRYPT_ALG_HANDLE hAlgorithm, + BCRYPT_KEY_HANDLE* phKey, PUCHAR pbKeyObject, + ULONG cbKeyObject, PUCHAR pbSecret, + ULONG cbSecret, ULONG dwFlags); + + WINPR_API NTSTATUS BCryptGenerateKeyPair(BCRYPT_ALG_HANDLE hAlgorithm, BCRYPT_KEY_HANDLE* phKey, + ULONG dwLength, ULONG dwFlags); + + WINPR_API NTSTATUS BCryptImportKey(BCRYPT_ALG_HANDLE hAlgorithm, BCRYPT_KEY_HANDLE hImportKey, + LPCWSTR pszBlobType, BCRYPT_KEY_HANDLE* phKey, + PUCHAR pbKeyObject, ULONG cbKeyObject, PUCHAR pbInput, + ULONG cbInput, ULONG dwFlags); + + WINPR_API NTSTATUS BCryptDestroyKey(BCRYPT_KEY_HANDLE hKey); + + WINPR_API NTSTATUS BCryptEncrypt(BCRYPT_KEY_HANDLE hKey, PUCHAR pbInput, ULONG cbInput, + VOID* pPaddingInfo, PUCHAR pbIV, ULONG cbIV, PUCHAR pbOutput, + ULONG cbOutput, ULONG* pcbResult, ULONG dwFlags); + + WINPR_API NTSTATUS BCryptDecrypt(BCRYPT_KEY_HANDLE hKey, PUCHAR pbInput, ULONG cbInput, + VOID* pPaddingInfo, PUCHAR pbIV, ULONG cbIV, PUCHAR pbOutput, + ULONG cbOutput, ULONG* pcbResult, ULONG dwFlags); + +#ifdef __cplusplus +} +#endif + +#endif /* _WIN32 */ +#endif /* WINPR_BCRYPT_H */ diff --git a/winpr/include/winpr/bitstream.h b/winpr/include/winpr/bitstream.h new file mode 100644 index 0000000..4a8327e --- /dev/null +++ b/winpr/include/winpr/bitstream.h @@ -0,0 +1,186 @@ +/* + * WinPR: Windows Portable Runtime + * BitStream Utils + * + * Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_UTILS_BITSTREAM_H +#define WINPR_UTILS_BITSTREAM_H + +#include <winpr/assert.h> +#include <winpr/winpr.h> +#include <winpr/wtypes.h> + +#include <winpr/crt.h> +#include <winpr/wlog.h> + +typedef struct +{ + const BYTE* buffer; + BYTE* pointer; + UINT32 position; + UINT32 length; + UINT32 capacity; + UINT32 mask; + UINT32 offset; + UINT32 prefetch; + UINT32 accumulator; +} wBitStream; + +#define BITDUMP_MSB_FIRST 0x00000001 +#define BITDUMP_STDERR 0x00000002 + +#ifdef __cplusplus +extern "C" +{ +#endif + + static INLINE void BitStream_Prefetch(wBitStream* _bs) + { + WINPR_ASSERT(_bs); + + (_bs->prefetch) = 0; + if (((UINT32)(_bs->pointer - _bs->buffer) + 4) < (_bs->capacity)) + (_bs->prefetch) |= ((UINT32) * (_bs->pointer + 4) << 24); + if (((UINT32)(_bs->pointer - _bs->buffer) + 5) < (_bs->capacity)) + (_bs->prefetch) |= ((UINT32) * (_bs->pointer + 5) << 16); + if (((UINT32)(_bs->pointer - _bs->buffer) + 6) < (_bs->capacity)) + (_bs->prefetch) |= ((UINT32) * (_bs->pointer + 6) << 8); + if (((UINT32)(_bs->pointer - _bs->buffer) + 7) < (_bs->capacity)) + (_bs->prefetch) |= ((UINT32) * (_bs->pointer + 7) << 0); + } + + static INLINE void BitStream_Fetch(wBitStream* _bs) + { + WINPR_ASSERT(_bs); + (_bs->accumulator) = 0; + if (((UINT32)(_bs->pointer - _bs->buffer) + 0) < (_bs->capacity)) + (_bs->accumulator) |= ((UINT32) * (_bs->pointer + 0) << 24); + if (((UINT32)(_bs->pointer - _bs->buffer) + 1) < (_bs->capacity)) + (_bs->accumulator) |= ((UINT32) * (_bs->pointer + 1) << 16); + if (((UINT32)(_bs->pointer - _bs->buffer) + 2) < (_bs->capacity)) + (_bs->accumulator) |= ((UINT32) * (_bs->pointer + 2) << 8); + if (((UINT32)(_bs->pointer - _bs->buffer) + 3) < (_bs->capacity)) + (_bs->accumulator) |= ((UINT32) * (_bs->pointer + 3) << 0); + BitStream_Prefetch(_bs); + } + + static INLINE void BitStream_Flush(wBitStream* _bs) + { + WINPR_ASSERT(_bs); + if (((UINT32)(_bs->pointer - _bs->buffer) + 0) < (_bs->capacity)) + *(_bs->pointer + 0) = (BYTE)((UINT32)_bs->accumulator >> 24); + if (((UINT32)(_bs->pointer - _bs->buffer) + 1) < (_bs->capacity)) + *(_bs->pointer + 1) = (BYTE)((UINT32)_bs->accumulator >> 16); + if (((UINT32)(_bs->pointer - _bs->buffer) + 2) < (_bs->capacity)) + *(_bs->pointer + 2) = (BYTE)((UINT32)_bs->accumulator >> 8); + if (((UINT32)(_bs->pointer - _bs->buffer) + 3) < (_bs->capacity)) + *(_bs->pointer + 3) = (BYTE)((UINT32)_bs->accumulator >> 0); + } + + static INLINE void BitStream_Shift(wBitStream* _bs, UINT32 _nbits) + { + WINPR_ASSERT(_bs); + if (_nbits == 0) + { + } + else if ((_nbits > 0) && (_nbits < 32)) + { + _bs->accumulator <<= _nbits; + _bs->position += _nbits; + _bs->offset += _nbits; + if (_bs->offset < 32) + { + _bs->mask = (UINT32)((1UL << _nbits) - 1UL); + _bs->accumulator |= ((_bs->prefetch >> (32 - _nbits)) & _bs->mask); + _bs->prefetch <<= _nbits; + } + else + { + _bs->mask = (UINT32)((1UL << _nbits) - 1UL); + _bs->accumulator |= ((_bs->prefetch >> (32 - _nbits)) & _bs->mask); + _bs->prefetch <<= _nbits; + _bs->offset -= 32; + _bs->pointer += 4; + BitStream_Prefetch(_bs); + if (_bs->offset) + { + _bs->mask = (UINT32)((1UL << _bs->offset) - 1UL); + _bs->accumulator |= ((_bs->prefetch >> (32 - _bs->offset)) & _bs->mask); + _bs->prefetch <<= _bs->offset; + } + } + } + else + { + WLog_WARN("com.winpr.bitstream", "warning: BitStream_Shift(%u)", (unsigned)_nbits); + } + } + + static INLINE void BitStream_Shift32(wBitStream* _bs) + { + WINPR_ASSERT(_bs); + BitStream_Shift(_bs, 16); + BitStream_Shift(_bs, 16); + } + + static INLINE void BitStream_Write_Bits(wBitStream* _bs, UINT32 _bits, UINT32 _nbits) + { + WINPR_ASSERT(_bs); + _bs->position += _nbits; + _bs->offset += _nbits; + if (_bs->offset < 32) + { + _bs->accumulator |= (_bits << (32 - _bs->offset)); + } + else + { + _bs->offset -= 32; + _bs->mask = ((1 << (_nbits - _bs->offset)) - 1); + _bs->accumulator |= ((_bits >> _bs->offset) & _bs->mask); + BitStream_Flush(_bs); + _bs->accumulator = 0; + _bs->pointer += 4; + if (_bs->offset) + { + _bs->mask = (UINT32)((1UL << _bs->offset) - 1); + _bs->accumulator |= ((_bits & _bs->mask) << (32 - _bs->offset)); + } + } + } + + static INLINE size_t BitStream_GetRemainingLength(wBitStream* _bs) + { + WINPR_ASSERT(_bs); + return (_bs->length - _bs->position); + } + + WINPR_API void BitDump(const char* tag, UINT32 level, const BYTE* buffer, UINT32 length, + UINT32 flags); + WINPR_API UINT32 ReverseBits32(UINT32 bits, UINT32 nbits); + + WINPR_API void BitStream_Attach(wBitStream* bs, const BYTE* buffer, UINT32 capacity); + + WINPR_API void BitStream_Free(wBitStream* bs); + + WINPR_ATTR_MALLOC(BitStream_Free, 1) + WINPR_API wBitStream* BitStream_New(void); + +#ifdef __cplusplus +} +#endif + +#endif /* WINPR_UTILS_BITSTREAM_H */ diff --git a/winpr/include/winpr/clipboard.h b/winpr/include/winpr/clipboard.h new file mode 100644 index 0000000..5a6a8ce --- /dev/null +++ b/winpr/include/winpr/clipboard.h @@ -0,0 +1,109 @@ +/** + * WinPR: Windows Portable Runtime + * Clipboard Functions + * + * Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_CLIPBOARD_H +#define WINPR_CLIPBOARD_H + +#include <winpr/winpr.h> +#include <winpr/wtypes.h> + +typedef struct s_wClipboard wClipboard; + +typedef void* (*CLIPBOARD_SYNTHESIZE_FN)(wClipboard* clipboard, UINT32 formatId, const void* data, + UINT32* pSize); + +typedef struct +{ + UINT32 streamId; + UINT32 listIndex; +} wClipboardFileSizeRequest; + +typedef struct +{ + UINT32 streamId; + UINT32 listIndex; + UINT32 nPositionLow; + UINT32 nPositionHigh; + UINT32 cbRequested; +} wClipboardFileRangeRequest; + +typedef struct s_wClipboardDelegate wClipboardDelegate; + +struct s_wClipboardDelegate +{ + wClipboard* clipboard; + void* custom; + char* basePath; + + UINT (*ClientRequestFileSize)(wClipboardDelegate*, const wClipboardFileSizeRequest*); + UINT(*ClipboardFileSizeSuccess) + (wClipboardDelegate*, const wClipboardFileSizeRequest*, UINT64 fileSize); + UINT(*ClipboardFileSizeFailure) + (wClipboardDelegate*, const wClipboardFileSizeRequest*, UINT errorCode); + + UINT (*ClientRequestFileRange)(wClipboardDelegate*, const wClipboardFileRangeRequest*); + UINT(*ClipboardFileRangeSuccess) + (wClipboardDelegate*, const wClipboardFileRangeRequest*, const BYTE* data, UINT32 size); + UINT(*ClipboardFileRangeFailure) + (wClipboardDelegate*, const wClipboardFileRangeRequest*, UINT errorCode); + + BOOL (*IsFileNameComponentValid)(LPCWSTR lpFileName); +}; + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API void ClipboardLock(wClipboard* clipboard); + WINPR_API void ClipboardUnlock(wClipboard* clipboard); + + WINPR_API BOOL ClipboardEmpty(wClipboard* clipboard); + WINPR_API UINT32 ClipboardCountFormats(wClipboard* clipboard); + WINPR_API UINT32 ClipboardGetFormatIds(wClipboard* clipboard, UINT32** ppFormatIds); + + WINPR_API UINT32 ClipboardCountRegisteredFormats(wClipboard* clipboard); + WINPR_API UINT32 ClipboardGetRegisteredFormatIds(wClipboard* clipboard, UINT32** ppFormatIds); + WINPR_API UINT32 ClipboardRegisterFormat(wClipboard* clipboard, const char* name); + + WINPR_API BOOL ClipboardRegisterSynthesizer(wClipboard* clipboard, UINT32 formatId, + UINT32 syntheticId, + CLIPBOARD_SYNTHESIZE_FN pfnSynthesize); + + WINPR_API UINT32 ClipboardGetFormatId(wClipboard* clipboard, const char* name); + WINPR_API const char* ClipboardGetFormatName(wClipboard* clipboard, UINT32 formatId); + WINPR_API void* ClipboardGetData(wClipboard* clipboard, UINT32 formatId, UINT32* pSize); + WINPR_API BOOL ClipboardSetData(wClipboard* clipboard, UINT32 formatId, const void* data, + UINT32 size); + + WINPR_API UINT64 ClipboardGetOwner(wClipboard* clipboard); + WINPR_API void ClipboardSetOwner(wClipboard* clipboard, UINT64 ownerId); + + WINPR_API wClipboardDelegate* ClipboardGetDelegate(wClipboard* clipboard); + + WINPR_API wClipboard* ClipboardCreate(void); + WINPR_API void ClipboardDestroy(wClipboard* clipboard); + + WINPR_API const char* ClipboardGetFormatIdString(UINT32 formatId); + +#ifdef __cplusplus +} +#endif + +#endif /* WINPR_CLIPBOARD_H */ diff --git a/winpr/include/winpr/cmdline.h b/winpr/include/winpr/cmdline.h new file mode 100644 index 0000000..5221df1 --- /dev/null +++ b/winpr/include/winpr/cmdline.h @@ -0,0 +1,183 @@ +/** + * WinPR: Windows Portable Runtime + * Command-Line Utils + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_CMDLINE_H +#define WINPR_CMDLINE_H + +#include <winpr/winpr.h> +#include <winpr/wtypes.h> + +/* Command-Line Argument Flags */ + +#define COMMAND_LINE_INPUT_FLAG_MASK 0x0000FFFF +#define COMMAND_LINE_OUTPUT_FLAG_MASK 0xFFFF0000 + +/* Command-Line Argument Input Flags */ + +#define COMMAND_LINE_VALUE_FLAG 0x00000001 +#define COMMAND_LINE_VALUE_REQUIRED 0x00000002 +#define COMMAND_LINE_VALUE_OPTIONAL 0x00000004 +#define COMMAND_LINE_VALUE_BOOL 0x00000008 + +#define COMMAND_LINE_ADVANCED 0x00000100 +#define COMMAND_LINE_PRINT 0x00000200 +#define COMMAND_LINE_PRINT_HELP 0x00000400 +#define COMMAND_LINE_PRINT_VERSION 0x00000800 +#define COMMAND_LINE_PRINT_BUILDCONFIG 0x00001000 + +/* Command-Line Argument Output Flags */ + +#define COMMAND_LINE_ARGUMENT_PRESENT 0x80000000 +#define COMMAND_LINE_VALUE_PRESENT 0x40000000 + +/* Command-Line Parsing Flags */ + +#define COMMAND_LINE_SIGIL_NONE 0x00000001 +#define COMMAND_LINE_SIGIL_SLASH 0x00000002 +#define COMMAND_LINE_SIGIL_DASH 0x00000004 +#define COMMAND_LINE_SIGIL_DOUBLE_DASH 0x00000008 +#define COMMAND_LINE_SIGIL_PLUS_MINUS 0x00000010 +#define COMMAND_LINE_SIGIL_ENABLE_DISABLE 0x00000020 +#define COMMAND_LINE_SIGIL_NOT_ESCAPED 0x00000040 + +#define COMMAND_LINE_SEPARATOR_COLON 0x00000100 +#define COMMAND_LINE_SEPARATOR_EQUAL 0x00000200 +#define COMMAND_LINE_SEPARATOR_SPACE 0x00000400 + +/* Supress COMMAND_LINE_ERROR_NO_KEYWORD return. */ +#define COMMAND_LINE_IGN_UNKNOWN_KEYWORD 0x00001000 +#define COMMAND_LINE_SILENCE_PARSER 0x00002000 + +/* Command-Line Parsing Error Codes */ + +#define COMMAND_LINE_ERROR -1000 +#define COMMAND_LINE_ERROR_NO_KEYWORD -1001 +#define COMMAND_LINE_ERROR_UNEXPECTED_VALUE -1002 +#define COMMAND_LINE_ERROR_MISSING_VALUE -1003 +#define COMMAND_LINE_ERROR_MISSING_ARGUMENT -1004 +#define COMMAND_LINE_ERROR_UNEXPECTED_SIGIL -1005 +#define COMMAND_LINE_ERROR_MEMORY -1006 +#define COMMAND_LINE_ERROR_LAST -1999 + +/* Command-Line Parsing Status Codes */ + +#define COMMAND_LINE_STATUS_PRINT -2001 +#define COMMAND_LINE_STATUS_PRINT_HELP -2002 +#define COMMAND_LINE_STATUS_PRINT_VERSION -2003 +#define COMMAND_LINE_STATUS_PRINT_BUILDCONFIG -2004 +#define COMMAND_LINE_STATUS_PRINT_LAST -2999 + +/* Command-Line Macros */ + +#define CommandLineSwitchStart(_arg) \ + if (0) \ + { \ + } +#define CommandLineSwitchCase(_arg, _name) else if (strcmp(_arg->Name, _name) == 0) +#define CommandLineSwitchDefault(_arg) else +#define CommandLineSwitchEnd(_arg) + +#define BoolValueTrue ((LPSTR)1) +#define BoolValueFalse ((LPSTR)0) + +typedef struct +{ + LPCSTR Name; + DWORD Flags; + LPCSTR Format; + LPCSTR Default; + LPSTR Value; + LONG Index; + LPCSTR Alias; + LPCSTR Text; +} COMMAND_LINE_ARGUMENT_A; + +typedef struct +{ + LPCWSTR Name; + DWORD Flags; + LPCSTR Format; + LPWSTR Default; + LPWSTR Value; + LONG Index; + LPCWSTR Alias; + LPCWSTR Text; +} COMMAND_LINE_ARGUMENT_W; + +#ifdef UNICODE +#define COMMAND_LINE_ARGUMENT COMMAND_LINE_ARGUMENT_W +#else +#define COMMAND_LINE_ARGUMENT COMMAND_LINE_ARGUMENT_A +#endif + +typedef int (*COMMAND_LINE_PRE_FILTER_FN_A)(void* context, int index, int argc, LPSTR* argv); +typedef int (*COMMAND_LINE_PRE_FILTER_FN_W)(void* context, int index, int argc, LPWSTR* argv); + +typedef int (*COMMAND_LINE_POST_FILTER_FN_A)(void* context, COMMAND_LINE_ARGUMENT_A* arg); +typedef int (*COMMAND_LINE_POST_FILTER_FN_W)(void* context, COMMAND_LINE_ARGUMENT_W* arg); + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API int CommandLineClearArgumentsA(COMMAND_LINE_ARGUMENT_A* options); + WINPR_API int CommandLineClearArgumentsW(COMMAND_LINE_ARGUMENT_W* options); + + WINPR_API int CommandLineParseArgumentsA(int argc, LPSTR* argv, + COMMAND_LINE_ARGUMENT_A* options, DWORD flags, + void* context, COMMAND_LINE_PRE_FILTER_FN_A preFilter, + COMMAND_LINE_POST_FILTER_FN_A postFilter); + WINPR_API int CommandLineParseArgumentsW(int argc, LPWSTR* argv, + COMMAND_LINE_ARGUMENT_W* options, DWORD flags, + void* context, COMMAND_LINE_PRE_FILTER_FN_W preFilter, + COMMAND_LINE_POST_FILTER_FN_W postFilter); + + WINPR_API const COMMAND_LINE_ARGUMENT_A* + CommandLineFindArgumentA(const COMMAND_LINE_ARGUMENT_A* options, LPCSTR Name); + WINPR_API const COMMAND_LINE_ARGUMENT_W* + CommandLineFindArgumentW(const COMMAND_LINE_ARGUMENT_W* options, LPCWSTR Name); + + WINPR_API const COMMAND_LINE_ARGUMENT_A* + CommandLineFindNextArgumentA(const COMMAND_LINE_ARGUMENT_A* argument); + + WINPR_API char** CommandLineParseCommaSeparatedValues(const char* list, size_t* count); + + WINPR_API char** CommandLineParseCommaSeparatedValuesEx(const char* name, const char* list, + size_t* count); + + WINPR_API char* CommandLineToCommaSeparatedValues(int argc, char* argv[]); + WINPR_API char* CommandLineToCommaSeparatedValuesEx(int argc, char* argv[], + const char* filters[], size_t number); + +#ifdef __cplusplus +} +#endif + +#ifdef UNICODE +#define CommandLineClearArguments CommandLineClearArgumentsW +#define CommandLineParseArguments CommandLineParseArgumentsW +#define CommandLineFindArgument CommandLineFindArgumentW +#else +#define CommandLineClearArguments CommandLineClearArgumentsA +#define CommandLineParseArguments CommandLineParseArgumentsA +#define CommandLineFindArgument CommandLineFindArgumentA +#endif + +#endif /* WINPR_CMDLINE_H */ diff --git a/winpr/include/winpr/collections.h b/winpr/include/winpr/collections.h new file mode 100644 index 0000000..ec3de72 --- /dev/null +++ b/winpr/include/winpr/collections.h @@ -0,0 +1,871 @@ +/** + * WinPR: Windows Portable Runtime + * Collections + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_COLLECTIONS_H +#define WINPR_COLLECTIONS_H + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdarg.h> + +#include <winpr/winpr.h> +#include <winpr/wtypes.h> +#include <winpr/assert.h> + +#include <winpr/crt.h> +#include <winpr/synch.h> +#include <winpr/stream.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef void* (*OBJECT_NEW_FN)(const void* val); + typedef void (*OBJECT_INIT_FN)(void* obj); + typedef void (*OBJECT_UNINIT_FN)(void* obj); + typedef void (*OBJECT_FREE_FN)(void* obj); + typedef BOOL (*OBJECT_EQUALS_FN)(const void* objA, const void* objB); + + /** @struct wObject + * @brief This struct contains function pointer to initialize/free objects + * + * @var fnObjectNew A new function that creates a clone of the input + * @var fnObjectInit A function initializing an object, but not allocating it + * @var fnObjectUninit A function to deinitialize an object, but not free it + * @var fnObjectFree A function freeing an object + * @var fnObjectEquals A function to compare two objects + */ + typedef struct + { + OBJECT_NEW_FN fnObjectNew; + OBJECT_INIT_FN fnObjectInit; + OBJECT_UNINIT_FN fnObjectUninit; + OBJECT_FREE_FN fnObjectFree; + OBJECT_EQUALS_FN fnObjectEquals; + } wObject; + + /* utility function with compatible arguments for string data */ + WINPR_API void* winpr_ObjectStringClone(const void* pvstr); + WINPR_API void* winpr_ObjectWStringClone(const void* pvstr); + WINPR_API void winpr_ObjectStringFree(void* pvstr); + + /* System.Collections.Queue */ + + typedef struct s_wQueue wQueue; + + /** @brief Return the number of elements in the queue + * + * @param queue A pointer to a queue, must not be \b NULL + * + * @return the number of objects queued + */ + WINPR_API size_t Queue_Count(wQueue* queue); + + /** @brief Mutex-Lock a queue + * + * @param queue A pointer to a queue, must not be \b NULL + */ + WINPR_API void Queue_Lock(wQueue* queue); + + /** @brief Mutex-Unlock a queue + * + * @param queue A pointer to a queue, must not be \b NULL + */ + WINPR_API void Queue_Unlock(wQueue* queue); + + /** @brief Get an event handle for the queue, usable by \b WaitForSingleObject or \b + * WaitForMultipleObjects + * + * @param queue A pointer to a queue, must not be \b NULL + */ + WINPR_API HANDLE Queue_Event(wQueue* queue); + + /** @brief Mutex-Lock a queue + * + * @param queue A pointer to a queue, must not be \b NULL + * + * @return A pointer to a \b wObject that contains the allocation/cleanup handlers for queue + * elements + */ + WINPR_API wObject* Queue_Object(wQueue* queue); + + /** @brief Remove all elements from a queue, call \b wObject cleanup functions \b fnObjectFree + * + * @param queue A pointer to a queue, must not be \b NULL + */ + WINPR_API void Queue_Clear(wQueue* queue); + + /** @brief Check if the queue contains an object + * + * @param queue A pointer to a queue, must not be \b NULL + * @param obj The object to look for. \b fnObjectEquals is called internally + * + * @return \b TRUE if the object was found, \b FALSE otherwise. + */ + WINPR_API BOOL Queue_Contains(wQueue* queue, const void* obj); + + /** \brief Pushes a new element into the queue. + * If a \b fnObjectNew is set, the element is copied and the queue takes + * ownership of the memory, otherwise the ownership stays with the caller. + * + * \param queue The queue to operate on + * \param obj A pointer to the object to queue + * + * \return TRUE for success, FALSE if failed. + */ + WINPR_API BOOL Queue_Enqueue(wQueue* queue, const void* obj); + + /** \brief returns the element at the top of the queue. The element is removed from the queue, + * ownership of the element is passed on to the caller. + * + * \param queue The queue to check + * + * \return NULL if empty, a pointer to the memory on top of the queue otherwise. + */ + WINPR_API void* Queue_Dequeue(wQueue* queue); + + /** \brief returns the element at the top of the queue. The element is not removed from the + * queue, ownership of the element stays with the queue. + * + * \param queue The queue to check + * + * \return NULL if empty, a pointer to the memory on top of the queue otherwise. + */ + WINPR_API void* Queue_Peek(wQueue* queue); + + /** \brief Removes the element at the top of the queue. If fnObjectFree is set, the element is + * freed. This can be used in combination with Queue_Peek to handle an element and discard it + * with this function afterward. An alternative is Queue_Dequeue with calling the appropriate + * free function afterward. + * + * \param queue The queue to operate on + */ + WINPR_API void Queue_Discard(wQueue* queue); + + /** @brief Clean up a queue, free all resources (e.g. calls \b Queue_Clear) + * + * @param queue The queue to free, may be \b NULL + */ + WINPR_API void Queue_Free(wQueue* queue); + + /** @brief Creates a new queue + * + * @return A newly allocated queue or \b NULL in case of failure + */ + WINPR_ATTR_MALLOC(Queue_Free, 1) + WINPR_API wQueue* Queue_New(BOOL synchronized, SSIZE_T capacity, SSIZE_T growthFactor); + + /* System.Collections.Stack */ + + typedef struct s_wStack wStack; + + WINPR_API size_t Stack_Count(wStack* stack); + WINPR_API BOOL Stack_IsSynchronized(wStack* stack); + + WINPR_API wObject* Stack_Object(wStack* stack); + + WINPR_API void Stack_Clear(wStack* stack); + WINPR_API BOOL Stack_Contains(wStack* stack, const void* obj); + + WINPR_API void Stack_Push(wStack* stack, void* obj); + WINPR_API void* Stack_Pop(wStack* stack); + + WINPR_API void* Stack_Peek(wStack* stack); + + WINPR_API void Stack_Free(wStack* stack); + + WINPR_ATTR_MALLOC(Stack_Free, 1) + WINPR_API wStack* Stack_New(BOOL synchronized); + + /* System.Collections.ArrayList */ + + typedef struct s_wArrayList wArrayList; + + WINPR_API size_t ArrayList_Capacity(wArrayList* arrayList); + WINPR_API size_t ArrayList_Count(wArrayList* arrayList); + WINPR_API size_t ArrayList_Items(wArrayList* arrayList, ULONG_PTR** ppItems); + WINPR_API BOOL ArrayList_IsFixedSized(wArrayList* arrayList); + WINPR_API BOOL ArrayList_IsReadOnly(wArrayList* arrayList); + WINPR_API BOOL ArrayList_IsSynchronized(wArrayList* arrayList); + + WINPR_API void ArrayList_Lock(wArrayList* arrayList); + WINPR_API void ArrayList_Unlock(wArrayList* arrayList); + + WINPR_API void* ArrayList_GetItem(wArrayList* arrayList, size_t index); + WINPR_API BOOL ArrayList_SetItem(wArrayList* arrayList, size_t index, const void* obj); + + WINPR_API wObject* ArrayList_Object(wArrayList* arrayList); + + typedef BOOL (*ArrayList_ForEachFkt)(void* data, size_t index, va_list ap); + + WINPR_API BOOL ArrayList_ForEach(wArrayList* arrayList, ArrayList_ForEachFkt fkt, ...); + WINPR_API BOOL ArrayList_ForEachAP(wArrayList* arrayList, ArrayList_ForEachFkt fkt, va_list ap); + + WINPR_API void ArrayList_Clear(wArrayList* arrayList); + WINPR_API BOOL ArrayList_Contains(wArrayList* arrayList, const void* obj); + +#if defined(WITH_WINPR_DEPRECATED) + WINPR_API WINPR_DEPRECATED(int ArrayList_Add(wArrayList* arrayList, const void* obj)); +#endif + + WINPR_API BOOL ArrayList_Append(wArrayList* arrayList, const void* obj); + WINPR_API BOOL ArrayList_Insert(wArrayList* arrayList, size_t index, const void* obj); + + WINPR_API BOOL ArrayList_Remove(wArrayList* arrayList, const void* obj); + WINPR_API BOOL ArrayList_RemoveAt(wArrayList* arrayList, size_t index); + + WINPR_API SSIZE_T ArrayList_IndexOf(wArrayList* arrayList, const void* obj, SSIZE_T startIndex, + SSIZE_T count); + WINPR_API SSIZE_T ArrayList_LastIndexOf(wArrayList* arrayList, const void* obj, + SSIZE_T startIndex, SSIZE_T count); + + WINPR_API void ArrayList_Free(wArrayList* arrayList); + + WINPR_ATTR_MALLOC(ArrayList_Free, 1) + WINPR_API wArrayList* ArrayList_New(BOOL synchronized); + + /* System.Collections.DictionaryBase */ + + /* System.Collections.Specialized.ListDictionary */ + typedef struct s_wListDictionary wListDictionary; + + /** @brief Get the \b wObject function pointer struct for the \b key of the dictionary. + * + * @param listDictionary A dictionary to query, must not be \b NULL + * + * @return a \b wObject used to initialize the key object, \b NULL in case of failure + */ + WINPR_API wObject* ListDictionary_KeyObject(wListDictionary* listDictionary); + + /** @brief Get the \b wObject function pointer struct for the \b value of the dictionary. + * + * @param listDictionary A dictionary to query, must not be \b NULL + * + * @return a \b wObject used to initialize the value object, \b NULL in case of failure + */ + WINPR_API wObject* ListDictionary_ValueObject(wListDictionary* listDictionary); + + /** @brief Return the number of entries in the dictionary + * + * @param listDictionary A dictionary to query, must not be \b NULL + * + * @return the number of entries + */ + WINPR_API size_t ListDictionary_Count(wListDictionary* listDictionary); + + /** @brief mutex-lock a dictionary + * + * @param listDictionary A dictionary to query, must not be \b NULL + */ + WINPR_API void ListDictionary_Lock(wListDictionary* listDictionary); + /** @brief mutex-unlock a dictionary + * + * @param listDictionary A dictionary to query, must not be \b NULL + */ + WINPR_API void ListDictionary_Unlock(wListDictionary* listDictionary); + + /** @brief mutex-lock a dictionary + * + * @param listDictionary A dictionary to query, must not be \b NULL + * @param key The key identifying the entry, if set cloned with \b fnObjectNew + * @param value The value to store for the \b key. May be \b NULL. if set cloned with \b + * fnObjectNew + * + * @return \b TRUE for successfull addition, \b FALSE for failure + */ + WINPR_API BOOL ListDictionary_Add(wListDictionary* listDictionary, const void* key, + const void* value); + + /** @brief Remove an item from the dictionary and return the value. Cleanup is up to the caller. + * + * @param listDictionary A dictionary to query, must not be \b NULL + * @param key The key identifying the entry + * + * @return a pointer to the value stored or \b NULL in case of failure or not found + */ + WINPR_API void* ListDictionary_Take(wListDictionary* listDictionary, const void* key); + + /** @brief Remove an item from the dictionary and call \b fnObjectFree for key and value + * + * @param listDictionary A dictionary to query, must not be \b NULL + * @param key The key identifying the entry + */ + WINPR_API void ListDictionary_Remove(wListDictionary* listDictionary, const void* key); + + /** @brief Remove the head item from the dictionary and return the value. Cleanup is up to the + * caller. + * + * @param listDictionary A dictionary to query, must not be \b NULL + * + * @return a pointer to the value stored or \b NULL in case of failure or not found + */ + WINPR_API void* ListDictionary_Take_Head(wListDictionary* listDictionary); + + /** @brief Remove the head item from the dictionary and call \b fnObjectFree for key and value + * + * @param listDictionary A dictionary to query, must not be \b NULL + */ + WINPR_API void ListDictionary_Remove_Head(wListDictionary* listDictionary); + + /** @brief Remove all items from the dictionary and call \b fnObjectFree for key and value + * + * @param listDictionary A dictionary to query, must not be \b NULL + */ + WINPR_API void ListDictionary_Clear(wListDictionary* listDictionary); + + /** @brief Check if a dictionary contains \b key (\b fnObjectEquals of the key object is called) + * + * @param listDictionary A dictionary to query, must not be \b NULL + * @param key A key to look for + * + * @return \b TRUE if found, \b FALSE otherwise + */ + WINPR_API BOOL ListDictionary_Contains(wListDictionary* listDictionary, const void* key); + + /** @brief return all keys the dictionary contains + * + * @param listDictionary A dictionary to query, must not be \b NULL + * @param ppKeys A pointer to a \b ULONG_PTR array that will hold the result keys. Call \b free + * if no longer required + * + * @return the number of keys found in the dictionary or \b 0 if \b ppKeys is \b NULL + */ + WINPR_API size_t ListDictionary_GetKeys(wListDictionary* listDictionary, ULONG_PTR** ppKeys); + + /** @brief Get the value in the dictionary for a \b key. The ownership of the data stays with + * the dictionary. + * + * @param listDictionary A dictionary to query, must not be \b NULL + * @param key A key to look for (\b fnObjectEquals of the key object is called) + * + * @return A pointer to the data in the dictionary or \b NULL if not found + */ + WINPR_API void* ListDictionary_GetItemValue(wListDictionary* listDictionary, const void* key); + + /** @brief Set the value in the dictionary for a \b key. The entry must already exist, \b value + * is copied if \b fnObjectNew is set + * + * @param listDictionary A dictionary to query, must not be \b NULL + * @param key A key to look for (\b fnObjectEquals of the key object is called) + * @param value A pointer to the value to set + * + * @return \b TRUE for success, \b FALSE in case of failure + */ + WINPR_API BOOL ListDictionary_SetItemValue(wListDictionary* listDictionary, const void* key, + const void* value); + + /** @brief Free memory allocated by a dictionary. Calls \b ListDictionary_Clear + * + * @param listDictionary A dictionary to query, may be \b NULL + */ + WINPR_API void ListDictionary_Free(wListDictionary* listDictionary); + + /** @brief allocate a new dictionary + * + * @param synchronized Create the dictionary with automatic mutex lock + * + * @return A newly allocated dictionary or \b NULL in case of failure + */ + WINPR_ATTR_MALLOC(ListDictionary_Free, 1) + WINPR_API wListDictionary* ListDictionary_New(BOOL synchronized); + + /* System.Collections.Generic.LinkedList<T> */ + + typedef struct s_wLinkedList wLinkedList; + + /** @brief Return the current number of elements in the linked list + * + * @param list A pointer to the list, must not be \b NULL + * + * @return the number of elements in the list + */ + WINPR_API size_t LinkedList_Count(wLinkedList* list); + + /** @brief Return the first element of the list, ownership stays with the list + * + * @param list A pointer to the list, must not be \b NULL + * + * @return A pointer to the element or \b NULL if empty + */ + WINPR_API void* LinkedList_First(wLinkedList* list); + + /** @brief Return the last element of the list, ownership stays with the list + * + * @param list A pointer to the list, must not be \b NULL + * + * @return A pointer to the element or \b NULL if empty + */ + WINPR_API void* LinkedList_Last(wLinkedList* list); + + /** @brief Check if the linked list contains a value + * + * @param list A pointer to the list, must not be \b NULL + * @param value A value to check for + * + * @return \b TRUE if found, \b FALSE otherwise + */ + WINPR_API BOOL LinkedList_Contains(wLinkedList* list, const void* value); + + /** @brief Remove all elements of the linked list. \b fnObjectUninit and \b fnObjectFree are + * called for each entry + * + * @param list A pointer to the list, must not be \b NULL + * + */ + WINPR_API void LinkedList_Clear(wLinkedList* list); + + /** @brief Add a new element at the start of the linked list. \b fnObjectNew and \b fnObjectInit + * is called for the new entry + * + * @param list A pointer to the list, must not be \b NULL + * @param value The value to add + * + * @return \b TRUE if successful, \b FALSE otherwise. + */ + WINPR_API BOOL LinkedList_AddFirst(wLinkedList* list, const void* value); + + /** @brief Add a new element at the end of the linked list. \b fnObjectNew and \b fnObjectInit + * is called for the new entry + * + * @param list A pointer to the list, must not be \b NULL + * @param value The value to add + * + * @return \b TRUE if successful, \b FALSE otherwise. + */ + WINPR_API BOOL LinkedList_AddLast(wLinkedList* list, const void* value); + + /** @brief Remove a element identified by \b value from the linked list. \b fnObjectUninit and + * \b fnObjectFree is called for the entry + * + * @param list A pointer to the list, must not be \b NULL + * @param value The value to remove + * + * @return \b TRUE if successful, \b FALSE otherwise. + */ + WINPR_API BOOL LinkedList_Remove(wLinkedList* list, const void* value); + + /** @brief Remove the first element from the linked list. \b fnObjectUninit and \b fnObjectFree + * is called for the entry + * + * @param list A pointer to the list, must not be \b NULL + * + */ + WINPR_API void LinkedList_RemoveFirst(wLinkedList* list); + + /** @brief Remove the last element from the linked list. \b fnObjectUninit and \b fnObjectFree + * is called for the entry + * + * @param list A pointer to the list, must not be \b NULL + * + */ + WINPR_API void LinkedList_RemoveLast(wLinkedList* list); + + /** @brief Move enumerator to the first element + * + * @param list A pointer to the list, must not be \b NULL + * + */ + WINPR_API void LinkedList_Enumerator_Reset(wLinkedList* list); + + /** @brief Return the value for the current position of the enumerator + * + * @param list A pointer to the list, must not be \b NULL + * + * @return A pointer to the current entry or \b NULL + */ + WINPR_API void* LinkedList_Enumerator_Current(wLinkedList* list); + + /** @brief Move enumerator to the next element + * + * @param list A pointer to the list, must not be \b NULL + * + * @return \b TRUE if the move was successful, \b FALSE if not (e.g. no more entries) + */ + WINPR_API BOOL LinkedList_Enumerator_MoveNext(wLinkedList* list); + + /** @brief Free a linked list + * + * @param list A pointer to the list, may be \b NULL + */ + WINPR_API void LinkedList_Free(wLinkedList* list); + + /** @brief Allocate a linked list + * + * @return A pointer to the newly allocated linked list or \b NULL in case of failure + */ + WINPR_ATTR_MALLOC(LinkedList_Free, 1) + WINPR_API wLinkedList* LinkedList_New(void); + + /** @brief Return the \b wObject function pointers for list elements + * + * @param list A pointer to the list, must not be \b NULL + * + * @return A pointer to the wObject or \b NULL in case of failure + */ + WINPR_API wObject* LinkedList_Object(wLinkedList* list); + + /* System.Collections.Generic.KeyValuePair<TKey,TValue> */ + + /* Countdown Event */ + + typedef struct CountdownEvent wCountdownEvent; + + /** @brief return the current event count of the CountdownEvent + * + * @param countdown A pointer to a CountdownEvent, must not be \b NULL + * + * @return The current event count + */ + WINPR_API size_t CountdownEvent_CurrentCount(wCountdownEvent* countdown); + + /** @brief return the initial event count of the CountdownEvent + * + * @param countdown A pointer to a CountdownEvent, must not be \b NULL + * + * @return The initial event count + */ + WINPR_API size_t CountdownEvent_InitialCount(wCountdownEvent* countdown); + + /** @brief return the current event state of the CountdownEvent + * + * @param countdown A pointer to a CountdownEvent, must not be \b NULL + * + * @return \b TRUE if set, \b FALSE otherwise + */ + WINPR_API BOOL CountdownEvent_IsSet(wCountdownEvent* countdown); + + /** @brief return the event HANDLE of the CountdownEvent to be used by \b WaitForSingleObject or + * \b WaitForMultipleObjects + * + * @param countdown A pointer to a CountdownEvent, must not be \b NULL + * + * @return a \b HANDLE or \b NULL in case of failure + */ + WINPR_API HANDLE CountdownEvent_WaitHandle(wCountdownEvent* countdown); + + /** @brief add \b signalCount to the current event count of the CountdownEvent + * + * @param countdown A pointer to a CountdownEvent, must not be \b NULL + * @param signalCount The amount to add to CountdownEvent + * + */ + WINPR_API void CountdownEvent_AddCount(wCountdownEvent* countdown, size_t signalCount); + + /** @brief Increase the current event signal state of the CountdownEvent + * + * @param countdown A pointer to a CountdownEvent, must not be \b NULL + * @param signalCount The amount of signaled events to add + * + * @return \b TRUE if event is set, \b FALSE otherwise + */ + WINPR_API BOOL CountdownEvent_Signal(wCountdownEvent* countdown, size_t signalCount); + + /** @brief reset the CountdownEvent + * + * @param countdown A pointer to a CountdownEvent, must not be \b NULL + * + */ + WINPR_API void CountdownEvent_Reset(wCountdownEvent* countdown, size_t count); + + /** @brief Free a CountdownEvent + * + * @param countdown A pointer to a CountdownEvent, may be \b NULL + */ + WINPR_API void CountdownEvent_Free(wCountdownEvent* countdown); + + /** @brief Allocte a CountdownEvent with \b initialCount + * + * @param initialCount The initial value of the event + * + * @return The newly allocated event or \b NULL in case of failure + */ + WINPR_ATTR_MALLOC(CountdownEvent_Free, 1) + WINPR_API wCountdownEvent* CountdownEvent_New(size_t initialCount); + + /* Hash Table */ + + typedef UINT32 (*HASH_TABLE_HASH_FN)(const void* key); + + typedef struct s_wHashTable wHashTable; + + typedef BOOL (*HASH_TABLE_FOREACH_FN)(const void* key, void* value, void* arg); + + WINPR_API size_t HashTable_Count(wHashTable* table); + +#if defined(WITH_WINPR_DEPRECATED) + WINPR_API WINPR_DEPRECATED(int HashTable_Add(wHashTable* table, const void* key, + const void* value)); +#endif + + WINPR_API BOOL HashTable_Insert(wHashTable* table, const void* key, const void* value); + WINPR_API BOOL HashTable_Remove(wHashTable* table, const void* key); + WINPR_API void HashTable_Clear(wHashTable* table); + WINPR_API BOOL HashTable_Contains(wHashTable* table, const void* key); + WINPR_API BOOL HashTable_ContainsKey(wHashTable* table, const void* key); + WINPR_API BOOL HashTable_ContainsValue(wHashTable* table, const void* value); + WINPR_API void* HashTable_GetItemValue(wHashTable* table, const void* key); + WINPR_API BOOL HashTable_SetItemValue(wHashTable* table, const void* key, const void* value); + WINPR_API size_t HashTable_GetKeys(wHashTable* table, ULONG_PTR** ppKeys); + WINPR_API BOOL HashTable_Foreach(wHashTable* table, HASH_TABLE_FOREACH_FN fn, VOID* arg); + + WINPR_API UINT32 HashTable_PointerHash(const void* pointer); + WINPR_API BOOL HashTable_PointerCompare(const void* pointer1, const void* pointer2); + + WINPR_API UINT32 HashTable_StringHash(const void* key); + WINPR_API BOOL HashTable_StringCompare(const void* string1, const void* string2); + WINPR_API void* HashTable_StringClone(const void* str); + WINPR_API void HashTable_StringFree(void* str); + + WINPR_API void HashTable_Free(wHashTable* table); + + WINPR_ATTR_MALLOC(HashTable_Free, 1) + WINPR_API wHashTable* HashTable_New(BOOL synchronized); + + WINPR_API void HashTable_Lock(wHashTable* table); + WINPR_API void HashTable_Unlock(wHashTable* table); + + WINPR_API wObject* HashTable_KeyObject(wHashTable* table); + WINPR_API wObject* HashTable_ValueObject(wHashTable* table); + + WINPR_API BOOL HashTable_SetHashFunction(wHashTable* table, HASH_TABLE_HASH_FN fn); + + /* Utility function to setup hash table for strings */ + WINPR_API BOOL HashTable_SetupForStringData(wHashTable* table, BOOL stringValues); + + /* BufferPool */ + + typedef struct s_wBufferPool wBufferPool; + + WINPR_API SSIZE_T BufferPool_GetPoolSize(wBufferPool* pool); + WINPR_API SSIZE_T BufferPool_GetBufferSize(wBufferPool* pool, const void* buffer); + + WINPR_API void* BufferPool_Take(wBufferPool* pool, SSIZE_T bufferSize); + WINPR_API BOOL BufferPool_Return(wBufferPool* pool, void* buffer); + WINPR_API void BufferPool_Clear(wBufferPool* pool); + + WINPR_API void BufferPool_Free(wBufferPool* pool); + + WINPR_ATTR_MALLOC(BufferPool_Free, 1) + WINPR_API wBufferPool* BufferPool_New(BOOL synchronized, SSIZE_T fixedSize, DWORD alignment); + + /* ObjectPool */ + + typedef struct s_wObjectPool wObjectPool; + + WINPR_API void* ObjectPool_Take(wObjectPool* pool); + WINPR_API void ObjectPool_Return(wObjectPool* pool, void* obj); + WINPR_API void ObjectPool_Clear(wObjectPool* pool); + + WINPR_API wObject* ObjectPool_Object(wObjectPool* pool); + + WINPR_API void ObjectPool_Free(wObjectPool* pool); + + WINPR_ATTR_MALLOC(ObjectPool_Free, 1) + WINPR_API wObjectPool* ObjectPool_New(BOOL synchronized); + + /* Message Queue */ + + typedef struct s_wMessage wMessage; + + typedef void (*MESSAGE_FREE_FN)(wMessage* message); + + struct s_wMessage + { + UINT32 id; + void* context; + void* wParam; + void* lParam; + UINT64 time; + MESSAGE_FREE_FN Free; + }; + + typedef struct s_wMessageQueue wMessageQueue; + +#define WMQ_QUIT 0xFFFFFFFF + + WINPR_API wObject* MessageQueue_Object(wMessageQueue* queue); + WINPR_API HANDLE MessageQueue_Event(wMessageQueue* queue); + WINPR_API BOOL MessageQueue_Wait(wMessageQueue* queue); + WINPR_API size_t MessageQueue_Size(wMessageQueue* queue); + + WINPR_API BOOL MessageQueue_Dispatch(wMessageQueue* queue, const wMessage* message); + WINPR_API BOOL MessageQueue_Post(wMessageQueue* queue, void* context, UINT32 type, void* wParam, + void* lParam); + WINPR_API BOOL MessageQueue_PostQuit(wMessageQueue* queue, int nExitCode); + + WINPR_API int MessageQueue_Get(wMessageQueue* queue, wMessage* message); + WINPR_API int MessageQueue_Peek(wMessageQueue* queue, wMessage* message, BOOL remove); + + /*! \brief Clears all elements in a message queue. + * + * \note If dynamically allocated data is part of the messages, + * a custom cleanup handler must be passed in the 'callback' + * argument for MessageQueue_New. + * + * \param queue The queue to clear. + * + * \return 0 in case of success or a error code otherwise. + */ + WINPR_API int MessageQueue_Clear(wMessageQueue* queue); + + /*! \brief Frees resources allocated by a message queue. + * This function will only free resources allocated + * internally. + * + * \note Empty the queue before calling this function with + * 'MessageQueue_Clear', 'MessageQueue_Get' or + * 'MessageQueue_Peek' to free all resources allocated + * by the message contained. + * + * \param queue A pointer to the queue to be freed. + */ + WINPR_API void MessageQueue_Free(wMessageQueue* queue); + + /*! \brief Creates a new message queue. + * If 'callback' is null, no custom cleanup will be done + * on message queue deallocation. + * If the 'callback' argument contains valid uninit or + * free functions those will be called by + * 'MessageQueue_Clear'. + * + * \param callback a pointer to custom initialization / cleanup functions. + * Can be NULL if not used. + * + * \return A pointer to a newly allocated MessageQueue or NULL. + */ + WINPR_ATTR_MALLOC(MessageQueue_Free, 1) + WINPR_API wMessageQueue* MessageQueue_New(const wObject* callback); + + /* Message Pipe */ + + typedef struct + { + wMessageQueue* In; + wMessageQueue* Out; + } wMessagePipe; + + WINPR_API void MessagePipe_PostQuit(wMessagePipe* pipe, int nExitCode); + + WINPR_API void MessagePipe_Free(wMessagePipe* pipe); + + WINPR_ATTR_MALLOC(MessagePipe_Free, 1) + WINPR_API wMessagePipe* MessagePipe_New(void); + + /* Publisher/Subscriber Pattern */ + + typedef struct + { + DWORD Size; + const char* Sender; + } wEventArgs; + + typedef void (*pEventHandler)(void* context, const wEventArgs* e); + +#ifdef __cplusplus +#define WINPR_EVENT_CAST(t, val) reinterpret_cast<t>(val) +#else +#define WINPR_EVENT_CAST(t, val) (t)(val) +#endif + +#define MAX_EVENT_HANDLERS 32 + + typedef struct + { + const char* EventName; + wEventArgs EventArgs; + size_t EventHandlerCount; + pEventHandler EventHandlers[MAX_EVENT_HANDLERS]; + } wEventType; + +#define EventArgsInit(_event_args, _sender) \ + memset(_event_args, 0, sizeof(*_event_args)); \ + (_event_args)->e.Size = sizeof(*_event_args); \ + (_event_args)->e.Sender = _sender + +#define DEFINE_EVENT_HANDLER(name) \ + typedef void (*p##name##EventHandler)(void* context, const name##EventArgs* e) + +#define DEFINE_EVENT_RAISE(name) \ + static INLINE int PubSub_On##name(wPubSub* pubSub, void* context, const name##EventArgs* e) \ + { \ + WINPR_ASSERT(e); \ + return PubSub_OnEvent(pubSub, #name, context, &e->e); \ + } + +#define DEFINE_EVENT_SUBSCRIBE(name) \ + static INLINE int PubSub_Subscribe##name(wPubSub* pubSub, p##name##EventHandler EventHandler) \ + { \ + return PubSub_Subscribe(pubSub, #name, EventHandler); \ + } + +#define DEFINE_EVENT_UNSUBSCRIBE(name) \ + static INLINE int PubSub_Unsubscribe##name(wPubSub* pubSub, \ + p##name##EventHandler EventHandler) \ + { \ + return PubSub_Unsubscribe(pubSub, #name, EventHandler); \ + } + +#define DEFINE_EVENT_BEGIN(name) \ + typedef struct \ + { \ + wEventArgs e; + +#define DEFINE_EVENT_END(name) \ + } \ + name##EventArgs; \ + DEFINE_EVENT_HANDLER(name); \ + DEFINE_EVENT_RAISE(name) \ + DEFINE_EVENT_SUBSCRIBE(name) \ + DEFINE_EVENT_UNSUBSCRIBE(name) + +#define DEFINE_EVENT_ENTRY(name) \ + { \ +#name, { sizeof(name##EventArgs), NULL }, 0, \ + { \ + NULL \ + } \ + } + + typedef struct s_wPubSub wPubSub; + + WINPR_API void PubSub_Lock(wPubSub* pubSub); + WINPR_API void PubSub_Unlock(wPubSub* pubSub); + + WINPR_API wEventType* PubSub_GetEventTypes(wPubSub* pubSub, size_t* count); + WINPR_API void PubSub_AddEventTypes(wPubSub* pubSub, wEventType* events, size_t count); + WINPR_API wEventType* PubSub_FindEventType(wPubSub* pubSub, const char* EventName); + + WINPR_API int PubSub_Subscribe(wPubSub* pubSub, const char* EventName, ...); + WINPR_API int PubSub_Unsubscribe(wPubSub* pubSub, const char* EventName, ...); + + WINPR_API int PubSub_OnEvent(wPubSub* pubSub, const char* EventName, void* context, + const wEventArgs* e); + + WINPR_API void PubSub_Free(wPubSub* pubSub); + + WINPR_ATTR_MALLOC(PubSub_Free, 1) + WINPR_API wPubSub* PubSub_New(BOOL synchronized); + +#ifdef __cplusplus +} +#endif + +#endif /* WINPR_COLLECTIONS_H */ diff --git a/winpr/include/winpr/comm.h b/winpr/include/winpr/comm.h new file mode 100644 index 0000000..9eb535c --- /dev/null +++ b/winpr/include/winpr/comm.h @@ -0,0 +1,565 @@ +/** + * WinPR: Windows Portable Runtime + * Serial Communication API + * + * Copyright 2011 O.S. Systems Software Ltda. + * Copyright 2011 Eduardo Fiss Beloni <beloni@ossystems.com.br> + * Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * Copyright 2014 Hewlett-Packard Development Company, L.P. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_COMM_H +#define WINPR_COMM_H + +#include <winpr/collections.h> +#include <winpr/file.h> +#include <winpr/winpr.h> +#include <winpr/wtypes.h> + +#if defined __linux__ && !defined ANDROID + +#define NOPARITY 0 +#define ODDPARITY 1 +#define EVENPARITY 2 +#define MARKPARITY 3 +#define SPACEPARITY 4 + +#define ONESTOPBIT 0 +#define ONE5STOPBITS 1 +#define TWOSTOPBITS 2 + +#ifndef IGNORE +#define IGNORE 0 +#endif + +#define CBR_110 110 +#define CBR_300 300 +#define CBR_600 600 +#define CBR_1200 1200 +#define CBR_2400 2400 +#define CBR_4800 4800 +#define CBR_9600 9600 +#define CBR_14400 14400 +#define CBR_19200 19200 +#define CBR_38400 38400 +#define CBR_56000 56000 +#define CBR_57600 57600 +#define CBR_115200 115200 +#define CBR_128000 128000 +#define CBR_256000 256000 + +#define CE_RXOVER 0x0001 +#define CE_OVERRUN 0x0002 +#define CE_RXPARITY 0x0004 +#define CE_FRAME 0x0008 +#define CE_BREAK 0x0010 +#define CE_TXFULL 0x0100 +#define CE_PTO 0x0200 +#define CE_IOE 0x0400 +#define CE_DNS 0x0800 +#define CE_OOP 0x1000 +#define CE_MODE 0x8000 + +#define IE_BADID (-1) +#define IE_OPEN (-2) +#define IE_NOPEN (-3) +#define IE_MEMORY (-4) +#define IE_DEFAULT (-5) +#define IE_HARDWARE (-10) +#define IE_BYTESIZE (-11) +#define IE_BAUDRATE (-12) + +#define EV_RXCHAR 0x0001 +#define EV_RXFLAG 0x0002 +#define EV_TXEMPTY 0x0004 +#define EV_CTS 0x0008 +#define EV_DSR 0x0010 +#define EV_RLSD 0x0020 +#define EV_BREAK 0x0040 +#define EV_ERR 0x0080 +#define EV_RING 0x0100 +#define EV_PERR 0x0200 +#define EV_RX80FULL 0x0400 +#define EV_EVENT1 0x0800 +#define EV_EVENT2 0x1000 + +#define SETXOFF 1 +#define SETXON 2 +#define SETRTS 3 +#define CLRRTS 4 +#define SETDTR 5 +#define CLRDTR 6 +#define RESETDEV 7 +#define SETBREAK 8 +#define CLRBREAK 9 + +#define PURGE_TXABORT 0x0001 +#define PURGE_RXABORT 0x0002 +#define PURGE_TXCLEAR 0x0004 +#define PURGE_RXCLEAR 0x0008 + +#define LPTx 0x80 + +#define MS_CTS_ON ((DWORD)0x0010) +#define MS_DSR_ON ((DWORD)0x0020) +#define MS_RING_ON ((DWORD)0x0040) +#define MS_RLSD_ON ((DWORD)0x0080) + +#define SP_SERIALCOMM ((DWORD)0x00000001) + +#define PST_UNSPECIFIED ((DWORD)0x00000000) +#define PST_RS232 ((DWORD)0x00000001) +#define PST_PARALLELPORT ((DWORD)0x00000002) +#define PST_RS422 ((DWORD)0x00000003) +#define PST_RS423 ((DWORD)0x00000004) +#define PST_RS449 ((DWORD)0x00000005) +#define PST_MODEM ((DWORD)0x00000006) +#define PST_FAX ((DWORD)0x00000021) +#define PST_SCANNER ((DWORD)0x00000022) +#define PST_NETWORK_BRIDGE ((DWORD)0x00000100) +#define PST_LAT ((DWORD)0x00000101) +#define PST_TCPIP_TELNET ((DWORD)0x00000102) +#define PST_X25 ((DWORD)0x00000103) + +#define PCF_DTRDSR ((DWORD)0x0001) +#define PCF_RTSCTS ((DWORD)0x0002) +#define PCF_RLSD ((DWORD)0x0004) +#define PCF_PARITY_CHECK ((DWORD)0x0008) +#define PCF_XONXOFF ((DWORD)0x0010) +#define PCF_SETXCHAR ((DWORD)0x0020) +#define PCF_TOTALTIMEOUTS ((DWORD)0x0040) +#define PCF_INTTIMEOUTS ((DWORD)0x0080) +#define PCF_SPECIALCHARS ((DWORD)0x0100) +#define PCF_16BITMODE ((DWORD)0x0200) + +#define SP_PARITY ((DWORD)0x0001) +#define SP_BAUD ((DWORD)0x0002) +#define SP_DATABITS ((DWORD)0x0004) +#define SP_STOPBITS ((DWORD)0x0008) +#define SP_HANDSHAKING ((DWORD)0x0010) +#define SP_PARITY_CHECK ((DWORD)0x0020) +#define SP_RLSD ((DWORD)0x0040) + +#define BAUD_075 ((DWORD)0x00000001) +#define BAUD_110 ((DWORD)0x00000002) +#define BAUD_134_5 ((DWORD)0x00000004) +#define BAUD_150 ((DWORD)0x00000008) +#define BAUD_300 ((DWORD)0x00000010) +#define BAUD_600 ((DWORD)0x00000020) +#define BAUD_1200 ((DWORD)0x00000040) +#define BAUD_1800 ((DWORD)0x00000080) +#define BAUD_2400 ((DWORD)0x00000100) +#define BAUD_4800 ((DWORD)0x00000200) +#define BAUD_7200 ((DWORD)0x00000400) +#define BAUD_9600 ((DWORD)0x00000800) +#define BAUD_14400 ((DWORD)0x00001000) +#define BAUD_19200 ((DWORD)0x00002000) +#define BAUD_38400 ((DWORD)0x00004000) +#define BAUD_56K ((DWORD)0x00008000) +#define BAUD_128K ((DWORD)0x00010000) +#define BAUD_115200 ((DWORD)0x00020000) +#define BAUD_57600 ((DWORD)0x00040000) +#define BAUD_USER ((DWORD)0x10000000) + +#define DATABITS_5 ((WORD)0x0001) +#define DATABITS_6 ((WORD)0x0002) +#define DATABITS_7 ((WORD)0x0004) +#define DATABITS_8 ((WORD)0x0008) +#define DATABITS_16 ((WORD)0x0010) +#define DATABITS_16X ((WORD)0x0020) + +#define STOPBITS_10 ((WORD)0x0001) +#define STOPBITS_15 ((WORD)0x0002) +#define STOPBITS_20 ((WORD)0x0004) + +#define PARITY_NONE ((WORD)0x0100) +#define PARITY_ODD ((WORD)0x0200) +#define PARITY_EVEN ((WORD)0x0400) +#define PARITY_MARK ((WORD)0x0800) +#define PARITY_SPACE ((WORD)0x1000) + +#define COMMPROP_INITIALIZED ((DWORD)0xE73CF52E) + +#define DTR_CONTROL_DISABLE 0x00 +#define DTR_CONTROL_ENABLE 0x01 +#define DTR_CONTROL_HANDSHAKE 0x02 + +#define RTS_CONTROL_DISABLE 0x00 +#define RTS_CONTROL_ENABLE 0x01 +#define RTS_CONTROL_HANDSHAKE 0x02 +#define RTS_CONTROL_TOGGLE 0x03 + +// http://msdn.microsoft.com/en-us/library/windows/desktop/aa363214%28v=vs.85%29.aspx +typedef struct +{ + DWORD DCBlength; + DWORD BaudRate; + DWORD fBinary : 1; + DWORD fParity : 1; + DWORD fOutxCtsFlow : 1; + DWORD fOutxDsrFlow : 1; + DWORD fDtrControl : 2; + DWORD fDsrSensitivity : 1; + DWORD fTXContinueOnXoff : 1; + DWORD fOutX : 1; + DWORD fInX : 1; + DWORD fErrorChar : 1; + DWORD fNull : 1; + DWORD fRtsControl : 2; + DWORD fAbortOnError : 1; + DWORD fDummy2 : 17; + WORD wReserved; + WORD XonLim; + WORD XoffLim; + BYTE ByteSize; + BYTE Parity; + BYTE StopBits; + char XonChar; + char XoffChar; + char ErrorChar; + char EofChar; + char EvtChar; + WORD wReserved1; +} DCB, *LPDCB; + +typedef struct +{ + DWORD dwSize; + WORD wVersion; + WORD wReserved; + DCB dcb; + DWORD dwProviderSubType; + DWORD dwProviderOffset; + DWORD dwProviderSize; + WCHAR wcProviderData[1]; +} COMMCONFIG, *LPCOMMCONFIG; + +typedef struct +{ + WORD wPacketLength; + WORD wPacketVersion; + DWORD dwServiceMask; + DWORD dwReserved1; + DWORD dwMaxTxQueue; + DWORD dwMaxRxQueue; + DWORD dwMaxBaud; + DWORD dwProvSubType; + DWORD dwProvCapabilities; + DWORD dwSettableParams; + DWORD dwSettableBaud; + WORD wSettableData; + WORD wSettableStopParity; + DWORD dwCurrentTxQueue; + DWORD dwCurrentRxQueue; + DWORD dwProvSpec1; + DWORD dwProvSpec2; + WCHAR wcProvChar[1]; +} COMMPROP, *LPCOMMPROP; + +typedef struct +{ + DWORD ReadIntervalTimeout; + DWORD ReadTotalTimeoutMultiplier; + DWORD ReadTotalTimeoutConstant; + DWORD WriteTotalTimeoutMultiplier; + DWORD WriteTotalTimeoutConstant; +} COMMTIMEOUTS, *LPCOMMTIMEOUTS; + +typedef struct +{ + DWORD fCtsHold : 1; + DWORD fDsrHold : 1; + DWORD fRlsdHold : 1; + DWORD fXoffHold : 1; + DWORD fXoffSent : 1; + DWORD fEof : 1; + DWORD fTxim : 1; + DWORD fReserved : 25; + DWORD cbInQue; + DWORD cbOutQue; +} COMSTAT, *LPCOMSTAT; + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API BOOL BuildCommDCBA(LPCSTR lpDef, LPDCB lpDCB); + WINPR_API BOOL BuildCommDCBW(LPCWSTR lpDef, LPDCB lpDCB); + + WINPR_API BOOL BuildCommDCBAndTimeoutsA(LPCSTR lpDef, LPDCB lpDCB, + LPCOMMTIMEOUTS lpCommTimeouts); + WINPR_API BOOL BuildCommDCBAndTimeoutsW(LPCWSTR lpDef, LPDCB lpDCB, + LPCOMMTIMEOUTS lpCommTimeouts); + + WINPR_API BOOL CommConfigDialogA(LPCSTR lpszName, HWND hWnd, LPCOMMCONFIG lpCC); + WINPR_API BOOL CommConfigDialogW(LPCWSTR lpszName, HWND hWnd, LPCOMMCONFIG lpCC); + + WINPR_API BOOL GetCommConfig(HANDLE hCommDev, LPCOMMCONFIG lpCC, LPDWORD lpdwSize); + WINPR_API BOOL SetCommConfig(HANDLE hCommDev, LPCOMMCONFIG lpCC, DWORD dwSize); + + WINPR_API BOOL GetCommMask(HANDLE hFile, PDWORD lpEvtMask); + WINPR_API BOOL SetCommMask(HANDLE hFile, DWORD dwEvtMask); + + WINPR_API BOOL GetCommModemStatus(HANDLE hFile, PDWORD lpModemStat); + WINPR_API BOOL GetCommProperties(HANDLE hFile, LPCOMMPROP lpCommProp); + + WINPR_API BOOL GetCommState(HANDLE hFile, LPDCB lpDCB); + WINPR_API BOOL SetCommState(HANDLE hFile, LPDCB lpDCB); + + WINPR_API BOOL GetCommTimeouts(HANDLE hFile, LPCOMMTIMEOUTS lpCommTimeouts); + WINPR_API BOOL SetCommTimeouts(HANDLE hFile, LPCOMMTIMEOUTS lpCommTimeouts); + + WINPR_API BOOL GetDefaultCommConfigA(LPCSTR lpszName, LPCOMMCONFIG lpCC, LPDWORD lpdwSize); + WINPR_API BOOL GetDefaultCommConfigW(LPCWSTR lpszName, LPCOMMCONFIG lpCC, LPDWORD lpdwSize); + + WINPR_API BOOL SetDefaultCommConfigA(LPCSTR lpszName, LPCOMMCONFIG lpCC, DWORD dwSize); + WINPR_API BOOL SetDefaultCommConfigW(LPCWSTR lpszName, LPCOMMCONFIG lpCC, DWORD dwSize); + + WINPR_API BOOL SetCommBreak(HANDLE hFile); + WINPR_API BOOL ClearCommBreak(HANDLE hFile); + WINPR_API BOOL ClearCommError(HANDLE hFile, PDWORD lpErrors, LPCOMSTAT lpStat); + + WINPR_API BOOL PurgeComm(HANDLE hFile, DWORD dwFlags); + WINPR_API BOOL SetupComm(HANDLE hFile, DWORD dwInQueue, DWORD dwOutQueue); + + WINPR_API BOOL EscapeCommFunction(HANDLE hFile, DWORD dwFunc); + + WINPR_API BOOL TransmitCommChar(HANDLE hFile, char cChar); + + WINPR_API BOOL WaitCommEvent(HANDLE hFile, PDWORD lpEvtMask, LPOVERLAPPED lpOverlapped); + +#ifdef UNICODE +#define BuildCommDCB BuildCommDCBW +#define BuildCommDCBAndTimeouts BuildCommDCBAndTimeoutsW +#define CommConfigDialog CommConfigDialogW +#define GetDefaultCommConfig GetDefaultCommConfigW +#define SetDefaultCommConfig SetDefaultCommConfigW +#else +#define BuildCommDCB BuildCommDCBA +#define BuildCommDCBAndTimeouts BuildCommDCBAndTimeoutsA +#define CommConfigDialog CommConfigDialogA +#define GetDefaultCommConfig GetDefaultCommConfigA +#define SetDefaultCommConfig SetDefaultCommConfigA +#endif + +/* Extended API */ + +/* FIXME: MAXULONG should be defined arround winpr/limits.h */ +#ifndef MAXULONG +#define MAXULONG (4294967295UL) +#endif + + /** + * IOCTLs table according the server's serial driver: + * http://msdn.microsoft.com/en-us/library/windows/hardware/dn265347%28v=vs.85%29.aspx + */ + typedef enum + { + SerialDriverUnknown = 0, + SerialDriverSerialSys, + SerialDriverSerCxSys, + SerialDriverSerCx2Sys /* default fallback, see also CommDeviceIoControl() */ + } SERIAL_DRIVER_ID; + + /* + * About DefineCommDevice() / QueryDosDevice() + * + * Did something close to QueryDosDevice() and DefineDosDevice() but with + * folowing constraints: + * - mappings are stored in a static array. + * - QueryCommDevice returns only the mappings that have been defined through + * DefineCommDevice() + */ + WINPR_API BOOL DefineCommDevice(/* DWORD dwFlags,*/ LPCTSTR lpDeviceName, LPCTSTR lpTargetPath); + WINPR_API DWORD QueryCommDevice(LPCTSTR lpDeviceName, LPTSTR lpTargetPath, DWORD ucchMax); + WINPR_API BOOL IsCommDevice(LPCTSTR lpDeviceName); + + /** + * A handle can only be created on defined devices with DefineCommDevice(). This + * also ensures that CommCreateFileA() has been registered through + * RegisterHandleCreator(). + */ + WINPR_API HANDLE CommCreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, + LPSECURITY_ATTRIBUTES lpSecurityAttributes, + DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, + HANDLE hTemplateFile); + +#define IOCTL_SERIAL_SET_BAUD_RATE 0x001B0004 +#define IOCTL_SERIAL_GET_BAUD_RATE 0x001B0050 +#define IOCTL_SERIAL_SET_LINE_CONTROL 0x001B000C +#define IOCTL_SERIAL_GET_LINE_CONTROL 0x001B0054 +#define IOCTL_SERIAL_SET_TIMEOUTS 0x001B001C +#define IOCTL_SERIAL_GET_TIMEOUTS 0x001B0020 +/* GET_CHARS and SET_CHARS are swapped in the RDP docs [MS-RDPESP] */ +#define IOCTL_SERIAL_GET_CHARS 0x001B0058 +#define IOCTL_SERIAL_SET_CHARS 0x001B005C + +#define IOCTL_SERIAL_SET_DTR 0x001B0024 +#define IOCTL_SERIAL_CLR_DTR 0x001B0028 +#define IOCTL_SERIAL_RESET_DEVICE 0x001B002C +#define IOCTL_SERIAL_SET_RTS 0x001B0030 +#define IOCTL_SERIAL_CLR_RTS 0x001B0034 +#define IOCTL_SERIAL_SET_XOFF 0x001B0038 +#define IOCTL_SERIAL_SET_XON 0x001B003C +#define IOCTL_SERIAL_SET_BREAK_ON 0x001B0010 +#define IOCTL_SERIAL_SET_BREAK_OFF 0x001B0014 +#define IOCTL_SERIAL_SET_QUEUE_SIZE 0x001B0008 +#define IOCTL_SERIAL_GET_WAIT_MASK 0x001B0040 +#define IOCTL_SERIAL_SET_WAIT_MASK 0x001B0044 +#define IOCTL_SERIAL_WAIT_ON_MASK 0x001B0048 +#define IOCTL_SERIAL_IMMEDIATE_CHAR 0x001B0018 +#define IOCTL_SERIAL_PURGE 0x001B004C +#define IOCTL_SERIAL_GET_HANDFLOW 0x001B0060 +#define IOCTL_SERIAL_SET_HANDFLOW 0x001B0064 +#define IOCTL_SERIAL_GET_MODEMSTATUS 0x001B0068 +#define IOCTL_SERIAL_GET_DTRRTS 0x001B0078 + +/* according to [MS-RDPESP] it should be 0x001B0084, but servers send 0x001B006C */ +#define IOCTL_SERIAL_GET_COMMSTATUS 0x001B006C + +#define IOCTL_SERIAL_GET_PROPERTIES 0x001B0074 +/* IOCTL_SERIAL_XOFF_COUNTER 0x001B0070 */ +/* IOCTL_SERIAL_LSRMST_INSERT 0x001B007C */ +#define IOCTL_SERIAL_CONFIG_SIZE 0x001B0080 +/* IOCTL_SERIAL_GET_STATS 0x001B008C */ +/* IOCTL_SERIAL_CLEAR_STATS 0x001B0090 */ +/* IOCTL_SERIAL_GET_MODEM_CONTROL 0x001B0094 */ +/* IOCTL_SERIAL_SET_MODEM_CONTROL 0x001B0098 */ +/* IOCTL_SERIAL_SET_FIFO_CONTROL 0x001B009C */ + +/* IOCTL_PAR_QUERY_INFORMATION 0x00160004 */ +/* IOCTL_PAR_SET_INFORMATION 0x00160008 */ +/* IOCTL_PAR_QUERY_DEVICE_ID 0x0016000C */ +/* IOCTL_PAR_QUERY_DEVICE_ID_SIZE 0x00160010 */ +/* IOCTL_IEEE1284_GET_MODE 0x00160014 */ +/* IOCTL_IEEE1284_NEGOTIATE 0x00160018 */ +/* IOCTL_PAR_SET_WRITE_ADDRESS 0x0016001C */ +/* IOCTL_PAR_SET_READ_ADDRESS 0x00160020 */ +/* IOCTL_PAR_GET_DEVICE_CAPS 0x00160024 */ +/* IOCTL_PAR_GET_DEFAULT_MODES 0x00160028 */ +/* IOCTL_PAR_QUERY_RAW_DEVICE_ID 0x00160030 */ +/* IOCTL_PAR_IS_PORT_FREE 0x00160054 */ + +/* http://msdn.microsoft.com/en-us/library/windows/hardware/ff551803(v=vs.85).aspx */ +#define IOCTL_USBPRINT_GET_1284_ID 0x220034 + + typedef struct + { + ULONG number; + const char* name; + } _SERIAL_IOCTL_NAME; + + static const _SERIAL_IOCTL_NAME _SERIAL_IOCTL_NAMES[] = { + { IOCTL_SERIAL_SET_BAUD_RATE, "IOCTL_SERIAL_SET_BAUD_RATE" }, + { IOCTL_SERIAL_GET_BAUD_RATE, "IOCTL_SERIAL_GET_BAUD_RATE" }, + { IOCTL_SERIAL_SET_LINE_CONTROL, "IOCTL_SERIAL_SET_LINE_CONTROL" }, + { IOCTL_SERIAL_GET_LINE_CONTROL, "IOCTL_SERIAL_GET_LINE_CONTROL" }, + { IOCTL_SERIAL_SET_TIMEOUTS, "IOCTL_SERIAL_SET_TIMEOUTS" }, + { IOCTL_SERIAL_GET_TIMEOUTS, "IOCTL_SERIAL_GET_TIMEOUTS" }, + { IOCTL_SERIAL_GET_CHARS, "IOCTL_SERIAL_GET_CHARS" }, + { IOCTL_SERIAL_SET_CHARS, "IOCTL_SERIAL_SET_CHARS" }, + { IOCTL_SERIAL_SET_DTR, "IOCTL_SERIAL_SET_DTR" }, + { IOCTL_SERIAL_CLR_DTR, "IOCTL_SERIAL_CLR_DTR" }, + { IOCTL_SERIAL_RESET_DEVICE, "IOCTL_SERIAL_RESET_DEVICE" }, + { IOCTL_SERIAL_SET_RTS, "IOCTL_SERIAL_SET_RTS" }, + { IOCTL_SERIAL_CLR_RTS, "IOCTL_SERIAL_CLR_RTS" }, + { IOCTL_SERIAL_SET_XOFF, "IOCTL_SERIAL_SET_XOFF" }, + { IOCTL_SERIAL_SET_XON, "IOCTL_SERIAL_SET_XON" }, + { IOCTL_SERIAL_SET_BREAK_ON, "IOCTL_SERIAL_SET_BREAK_ON" }, + { IOCTL_SERIAL_SET_BREAK_OFF, "IOCTL_SERIAL_SET_BREAK_OFF" }, + { IOCTL_SERIAL_SET_QUEUE_SIZE, "IOCTL_SERIAL_SET_QUEUE_SIZE" }, + { IOCTL_SERIAL_GET_WAIT_MASK, "IOCTL_SERIAL_GET_WAIT_MASK" }, + { IOCTL_SERIAL_SET_WAIT_MASK, "IOCTL_SERIAL_SET_WAIT_MASK" }, + { IOCTL_SERIAL_WAIT_ON_MASK, "IOCTL_SERIAL_WAIT_ON_MASK" }, + { IOCTL_SERIAL_IMMEDIATE_CHAR, "IOCTL_SERIAL_IMMEDIATE_CHAR" }, + { IOCTL_SERIAL_PURGE, "IOCTL_SERIAL_PURGE" }, + { IOCTL_SERIAL_GET_HANDFLOW, "IOCTL_SERIAL_GET_HANDFLOW" }, + { IOCTL_SERIAL_SET_HANDFLOW, "IOCTL_SERIAL_SET_HANDFLOW" }, + { IOCTL_SERIAL_GET_MODEMSTATUS, "IOCTL_SERIAL_GET_MODEMSTATUS" }, + { IOCTL_SERIAL_GET_DTRRTS, "IOCTL_SERIAL_GET_DTRRTS" }, + { IOCTL_SERIAL_GET_COMMSTATUS, "IOCTL_SERIAL_GET_COMMSTATUS" }, + { IOCTL_SERIAL_GET_PROPERTIES, "IOCTL_SERIAL_GET_PROPERTIES" }, + // {IOCTL_SERIAL_XOFF_COUNTER, "IOCTL_SERIAL_XOFF_COUNTER"}, + // {IOCTL_SERIAL_LSRMST_INSERT, "IOCTL_SERIAL_LSRMST_INSERT"}, + { IOCTL_SERIAL_CONFIG_SIZE, "IOCTL_SERIAL_CONFIG_SIZE" }, + // {IOCTL_SERIAL_GET_STATS, "IOCTL_SERIAL_GET_STATS"}, + // {IOCTL_SERIAL_CLEAR_STATS, "IOCTL_SERIAL_CLEAR_STATS"}, + // {IOCTL_SERIAL_GET_MODEM_CONTROL,"IOCTL_SERIAL_GET_MODEM_CONTROL"}, + // {IOCTL_SERIAL_SET_MODEM_CONTROL,"IOCTL_SERIAL_SET_MODEM_CONTROL"}, + // {IOCTL_SERIAL_SET_FIFO_CONTROL, "IOCTL_SERIAL_SET_FIFO_CONTROL"}, + + // {IOCTL_PAR_QUERY_INFORMATION, "IOCTL_PAR_QUERY_INFORMATION"}, + // {IOCTL_PAR_SET_INFORMATION, "IOCTL_PAR_SET_INFORMATION"}, + // {IOCTL_PAR_QUERY_DEVICE_ID, "IOCTL_PAR_QUERY_DEVICE_ID"}, + // {IOCTL_PAR_QUERY_DEVICE_ID_SIZE,"IOCTL_PAR_QUERY_DEVICE_ID_SIZE"}, + // {IOCTL_IEEE1284_GET_MODE, "IOCTL_IEEE1284_GET_MODE"}, + // {IOCTL_IEEE1284_NEGOTIATE, "IOCTL_IEEE1284_NEGOTIATE"}, + // {IOCTL_PAR_SET_WRITE_ADDRESS, "IOCTL_PAR_SET_WRITE_ADDRESS"}, + // {IOCTL_PAR_SET_READ_ADDRESS, "IOCTL_PAR_SET_READ_ADDRESS"}, + // {IOCTL_PAR_GET_DEVICE_CAPS, "IOCTL_PAR_GET_DEVICE_CAPS"}, + // {IOCTL_PAR_GET_DEFAULT_MODES, "IOCTL_PAR_GET_DEFAULT_MODES"}, + // {IOCTL_PAR_QUERY_RAW_DEVICE_ID, "IOCTL_PAR_QUERY_RAW_DEVICE_ID"}, + // {IOCTL_PAR_IS_PORT_FREE, "IOCTL_PAR_IS_PORT_FREE"}, + + { IOCTL_USBPRINT_GET_1284_ID, "IOCTL_USBPRINT_GET_1284_ID" }, + + { 0, NULL } + }; + + /** + * FIXME: got a proper function name and place + */ + WINPR_API const char* _comm_serial_ioctl_name(ULONG number); + + /** + * FIXME: got a proper function name and place + */ + WINPR_API void _comm_setServerSerialDriver(HANDLE hComm, SERIAL_DRIVER_ID); + + /** + * FIXME: got a proper function name and place + * + * permissive mode is disabled by default. + */ + WINPR_API BOOL _comm_set_permissive(HANDLE hDevice, BOOL permissive); + + /** + * FIXME: to be moved in comm_ioctl.h + */ + WINPR_API BOOL CommDeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID lpInBuffer, + DWORD nInBufferSize, LPVOID lpOutBuffer, + DWORD nOutBufferSize, LPDWORD lpBytesReturned, + LPOVERLAPPED lpOverlapped); + + /** + * FIXME: to be moved in comm_io.h + */ + WINPR_API BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, + LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped); + + /** + * FIXME: to be moved in comm_io.h + */ + WINPR_API BOOL CommWriteFile(HANDLE hDevice, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, + LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped); + +#ifdef __cplusplus +} +#endif + +#endif /* __linux__ */ + +#endif /* WINPR_COMM_H */ diff --git a/winpr/include/winpr/cred.h b/winpr/include/winpr/cred.h new file mode 100644 index 0000000..0c7ce8f --- /dev/null +++ b/winpr/include/winpr/cred.h @@ -0,0 +1,62 @@ +/** + * WinPR: Windows Portable Runtime + * Windows credentials + * + * Copyright 2022 David Fort <contact@hardening-consulting.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef WINPR_CRED_H_ +#define WINPR_CRED_H_ + +#include <winpr/winpr.h> + +#ifdef _WIN32 +#include <wincred.h> +#else + +#define CERT_HASH_LENGTH 20 + +typedef enum +{ + CertCredential, + UsernameTargetCredential, + BinaryBlobCredential, + UsernameForPackedCredentials, + BinaryBlobForSystem +} CRED_MARSHAL_TYPE, + *PCRED_MARSHAL_TYPE; + +typedef struct +{ + ULONG cbSize; + UCHAR rgbHashOfCert[CERT_HASH_LENGTH]; +} CERT_CREDENTIAL_INFO, *PCERT_CREDENTIAL_INFO; + +#if 0 /* shall we implement these ? */ +WINPR_API BOOL CredMarshalCredentialA(CRED_MARSHAL_TYPE CredType, PVOID Credential, + LPSTR* MarshaledCredential); +WINPR_API BOOL CredMarshalCredentialW(CRED_MARSHAL_TYPE CredType, PVOID Credential, + LPWSTR* MarshaledCredential); + +#ifdef UNICODE +#define CredMarshalCredential CredMarshalCredentialW +#else +#define CredMarshalCredential CredMarshalCredentialA +#endif + +#endif /* 0 */ + +#endif /* _WIN32 */ + +#endif /* WINPR_CRED_H_ */ diff --git a/winpr/include/winpr/crt.h b/winpr/include/winpr/crt.h new file mode 100644 index 0000000..6c155ee --- /dev/null +++ b/winpr/include/winpr/crt.h @@ -0,0 +1,233 @@ +/** + * WinPR: Windows Portable Runtime + * C Run-Time Library Routines + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_CRT_H +#define WINPR_CRT_H + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <winpr/platform.h> +#include <winpr/winpr.h> + +#include <winpr/spec.h> +#include <winpr/string.h> + +#ifndef _WIN32 + +#include <unistd.h> + +#ifndef _write +#define _write write +#endif + +#ifndef _strtoui64 +#define _strtoui64 strtoull +#endif /* _strtoui64 */ + +#ifndef _strtoi64 +#define _strtoi64 strtoll +#endif /* _strtoi64 */ + +#ifndef _rotl +static INLINE UINT32 _rotl(UINT32 value, int shift) +{ + return (value << shift) | (value >> (32 - shift)); +} +#endif /* _rotl */ + +#ifndef _rotl64 +static INLINE UINT64 _rotl64(UINT64 value, int shift) +{ + return (value << shift) | (value >> (64 - shift)); +} +#endif /* _rotl64 */ + +#ifndef _rotr +static INLINE UINT32 _rotr(UINT32 value, int shift) +{ + return (value >> shift) | (value << (32 - shift)); +} +#endif /* _rotr */ + +#ifndef _rotr64 +static INLINE UINT64 _rotr64(UINT64 value, int shift) +{ + return (value >> shift) | (value << (64 - shift)); +} +#endif /* _rotr64 */ + +#if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)) + +#define _byteswap_ulong(_val) __builtin_bswap32(_val) +#define _byteswap_uint64(_val) __builtin_bswap64(_val) + +#else + +static INLINE UINT32 _byteswap_ulong(UINT32 _val) +{ + return (((_val) >> 24) | (((_val)&0x00FF0000) >> 8) | (((_val)&0x0000FF00) << 8) | + ((_val) << 24)); +} + +static INLINE UINT64 _byteswap_uint64(UINT64 _val) +{ + return (((_val) << 56) | (((_val) << 40) & 0xFF000000000000) | + (((_val) << 24) & 0xFF0000000000) | (((_val) << 8) & 0xFF00000000) | + (((_val) >> 8) & 0xFF000000) | (((_val) >> 24) & 0xFF0000) | (((_val) >> 40) & 0xFF00) | + ((_val) >> 56)); +} + +#endif /* (__GNUC__ > 4) || ... */ + +#if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)) + +#define _byteswap_ushort(_val) __builtin_bswap16(_val) + +#else + +static INLINE UINT16 _byteswap_ushort(UINT16 _val) +{ +#ifdef __cplusplus +#define winpr_byteswap_cast(t, val) static_cast<t>(val) +#else +#define winpr_byteswap_cast(t, val) (t)(val) +#endif + return winpr_byteswap_cast(UINT16, ((_val) >> 8U) | ((_val) << 8U)); +#undef winpr_byteswap_cast +} + +#endif /* (__GNUC__ > 4) || ... */ + +#define CopyMemory(Destination, Source, Length) memcpy((Destination), (Source), (Length)) +#define MoveMemory(Destination, Source, Length) memmove((Destination), (Source), (Length)) +#define FillMemory(Destination, Length, Fill) memset((Destination), (Fill), (Length)) +#define ZeroMemory(Destination, Length) memset((Destination), 0, (Length)) + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API PVOID SecureZeroMemory(PVOID ptr, SIZE_T cnt); + +#ifdef __cplusplus +} +#endif + +#endif /* _WIN32 */ + +/* Data Alignment */ + +WINPR_PRAGMA_DIAG_PUSH +WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO + +#ifndef _ERRNO_T_DEFINED +#define _ERRNO_T_DEFINED +typedef int errno_t; +#endif /* _ERRNO_T_DEFINED */ + +WINPR_PRAGMA_DIAG_POP + +#ifndef _WIN32 + +#ifdef __cplusplus +extern "C" +{ +#endif + + /* Data Conversion */ + + WINPR_API errno_t _itoa_s(int value, char* buffer, size_t sizeInCharacters, int radix); + + /* Buffer Manipulation */ + + WINPR_API errno_t memmove_s(void* dest, size_t numberOfElements, const void* src, size_t count); + WINPR_API errno_t wmemmove_s(WCHAR* dest, size_t numberOfElements, const WCHAR* src, + size_t count); +#ifdef __cplusplus +} +#endif + +#endif /* _WIN32 */ + +#if !defined(_WIN32) || (defined(__MINGW32__) && !defined(_UCRT)) +/* note: we use our own implementation of _aligned_XXX function when: + * - it's not win32 + * - it's mingw with native libs (not ucrt64) because we didn't managed to have it working + * and not have C runtime deadly mixes + */ +#if defined(WINPR_MSVCR_ALIGNMENT_EMULATE) +#define _aligned_malloc winpr_aligned_malloc +#define _aligned_realloc winpr_aligned_realloc +#define _aligned_recalloc winpr_aligned_recalloc +#define _aligned_offset_malloc winpr_aligned_offset_malloc +#define _aligned_offset_realloc winpr_aligned_offset_realloc +#define _aligned_offset_recalloc winpr_aligned_offset_recalloc +#define _aligned_msize winpr_aligned_msize +#define _aligned_free winpr_aligned_free +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API void* winpr_aligned_malloc(size_t size, size_t alignment); + + WINPR_API void* winpr_aligned_calloc(size_t count, size_t size, size_t alignment); + + WINPR_API void* winpr_aligned_realloc(void* memblock, size_t size, size_t alignment); + + WINPR_API void* winpr_aligned_recalloc(void* memblock, size_t num, size_t size, + size_t alignment); + + WINPR_API void* winpr_aligned_offset_malloc(size_t size, size_t alignment, size_t offset); + + WINPR_API void* winpr_aligned_offset_realloc(void* memblock, size_t size, size_t alignment, + size_t offset); + + WINPR_API void* winpr_aligned_offset_recalloc(void* memblock, size_t num, size_t size, + size_t alignment, size_t offset); + + WINPR_API size_t winpr_aligned_msize(void* memblock, size_t alignment, size_t offset); + + WINPR_API void winpr_aligned_free(void* memblock); + +#ifdef __cplusplus +} +#endif + +#else +#define winpr_aligned_malloc _aligned_malloc +#define winpr_aligned_realloc _aligned_realloc +#define winpr_aligned_recalloc _aligned_recalloc +#define winpr_aligned_offset_malloc _aligned_offset_malloc +#define winpr_aligned_offset_realloc _aligned_offset_realloc +#define winpr_aligned_offset_recalloc _aligned_offset_recalloc +#define winpr_aligned_msize _aligned_msize +#define winpr_aligned_free _aligned_free +#endif /* !defined(_WIN32) || (defined(__MINGW32__) ... */ + +#if defined(_WIN32) && (!defined(__MINGW32__) || defined(_UCRT)) +#define winpr_aligned_calloc(count, size, alignment) _aligned_recalloc(NULL, count, size, alignment) +#endif /* defined(_WIN32) && (!defined(__MINGW32__) || defined(_UCRT)) */ + +#endif /* WINPR_CRT_H */ diff --git a/winpr/include/winpr/crypto.h b/winpr/include/winpr/crypto.h new file mode 100644 index 0000000..df38fed --- /dev/null +++ b/winpr/include/winpr/crypto.h @@ -0,0 +1,26 @@ +/** + * WinPR: Windows Portable Runtime + * Cryptography API (CryptoAPI) + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_CRYPTO_H +#define WINPR_CRYPTO_H + +#include <winpr/custom-crypto.h> +#include <winpr/wincrypt.h> + +#endif /* WINPR_CRYPTO_H */ diff --git a/winpr/include/winpr/custom-crypto.h b/winpr/include/winpr/custom-crypto.h new file mode 100644 index 0000000..32ff5d4 --- /dev/null +++ b/winpr/include/winpr/custom-crypto.h @@ -0,0 +1,269 @@ +/** + * WinPR: Windows Portable Runtime + * Cryptography API (CryptoAPI) + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_CUSTOM_CRYPTO_H +#define WINPR_CUSTOM_CRYPTO_H + +#include <winpr/winpr.h> +#include <winpr/wtypes.h> + +#include <winpr/error.h> + +/** + * Custom Crypto API Abstraction Layer + */ + +#define WINPR_MD4_DIGEST_LENGTH 16 +#define WINPR_MD5_DIGEST_LENGTH 16 +#define WINPR_SHA1_DIGEST_LENGTH 20 +#define WINPR_SHA224_DIGEST_LENGTH 28 +#define WINPR_SHA256_DIGEST_LENGTH 32 +#define WINPR_SHA384_DIGEST_LENGTH 48 +#define WINPR_SHA512_DIGEST_LENGTH 64 +#define WINPR_RIPEMD160_DIGEST_LENGTH 20 +#define WINPR_SHA3_224_DIGEST_LENGTH 28 +#define WINPR_SHA3_256_DIGEST_LENGTH 32 +#define WINPR_SHA3_384_DIGEST_LENGTH 48 +#define WINPR_SHA3_512_DIGEST_LENGTH 64 +#define WINPR_SHAKE128_DIGEST_LENGTH 16 +#define WINPR_SHAKE256_DIGEST_LENGTH 32 + +/** + * HMAC + */ +typedef enum +{ + WINPR_MD_NONE = 0, + WINPR_MD_MD2 = 1, + WINPR_MD_MD4 = 2, + WINPR_MD_MD5 = 3, + WINPR_MD_SHA1 = 4, + WINPR_MD_SHA224 = 5, + WINPR_MD_SHA256 = 6, + WINPR_MD_SHA384 = 7, + WINPR_MD_SHA512 = 8, + WINPR_MD_RIPEMD160 = 9, + WINPR_MD_SHA3_224 = 10, + WINPR_MD_SHA3_256 = 11, + WINPR_MD_SHA3_384 = 12, + WINPR_MD_SHA3_512 = 13, + WINPR_MD_SHAKE128 = 14, + WINPR_MD_SHAKE256 = 15 +} WINPR_MD_TYPE; + +typedef struct winpr_hmac_ctx_private_st WINPR_HMAC_CTX; + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API WINPR_MD_TYPE winpr_md_type_from_string(const char* name); + WINPR_API const char* winpr_md_type_to_string(WINPR_MD_TYPE md); + + WINPR_API void winpr_HMAC_Free(WINPR_HMAC_CTX* ctx); + + WINPR_ATTR_MALLOC(winpr_HMAC_Free, 1) + WINPR_API WINPR_HMAC_CTX* winpr_HMAC_New(void); + WINPR_API BOOL winpr_HMAC_Init(WINPR_HMAC_CTX* ctx, WINPR_MD_TYPE md, const void* key, + size_t keylen); + WINPR_API BOOL winpr_HMAC_Update(WINPR_HMAC_CTX* ctx, const void* input, size_t ilen); + WINPR_API BOOL winpr_HMAC_Final(WINPR_HMAC_CTX* ctx, void* output, size_t ilen); + + WINPR_API BOOL winpr_HMAC(WINPR_MD_TYPE md, const void* key, size_t keylen, const void* input, + size_t ilen, void* output, size_t olen); + +#ifdef __cplusplus +} +#endif + +/** + * Generic Digest API + */ + +typedef struct winpr_digest_ctx_private_st WINPR_DIGEST_CTX; + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API void winpr_Digest_Free(WINPR_DIGEST_CTX* ctx); + + WINPR_ATTR_MALLOC(winpr_Digest_Free, 1) + WINPR_API WINPR_DIGEST_CTX* winpr_Digest_New(void); + WINPR_API BOOL winpr_Digest_Init_Allow_FIPS(WINPR_DIGEST_CTX* ctx, WINPR_MD_TYPE md); + WINPR_API BOOL winpr_Digest_Init(WINPR_DIGEST_CTX* ctx, WINPR_MD_TYPE md); + WINPR_API BOOL winpr_Digest_Update(WINPR_DIGEST_CTX* ctx, const void* input, size_t ilen); + WINPR_API BOOL winpr_Digest_Final(WINPR_DIGEST_CTX* ctx, void* output, size_t ilen); + + WINPR_API BOOL winpr_Digest_Allow_FIPS(WINPR_MD_TYPE md, const void* input, size_t ilen, + void* output, size_t olen); + WINPR_API BOOL winpr_Digest(WINPR_MD_TYPE md, const void* input, size_t ilen, void* output, + size_t olen); + + WINPR_API BOOL winpr_DigestSign_Init(WINPR_DIGEST_CTX* ctx, WINPR_MD_TYPE md, void* key); + WINPR_API BOOL winpr_DigestSign_Update(WINPR_DIGEST_CTX* ctx, const void* input, size_t ilen); + WINPR_API BOOL winpr_DigestSign_Final(WINPR_DIGEST_CTX* ctx, void* output, size_t* piolen); + +#ifdef __cplusplus +} +#endif + +/** + * Random Number Generation + */ + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API int winpr_RAND(void* output, size_t len); + WINPR_API int winpr_RAND_pseudo(void* output, size_t len); + +#ifdef __cplusplus +} +#endif + +/** + * RC4 + */ + +typedef struct winpr_rc4_ctx_private_st WINPR_RC4_CTX; + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API void winpr_RC4_Free(WINPR_RC4_CTX* ctx); + + WINPR_ATTR_MALLOC(winpr_RC4_Free, 1) + WINPR_API WINPR_RC4_CTX* winpr_RC4_New_Allow_FIPS(const void* key, size_t keylen); + + WINPR_ATTR_MALLOC(winpr_RC4_Free, 1) + WINPR_API WINPR_RC4_CTX* winpr_RC4_New(const void* key, size_t keylen); + WINPR_API BOOL winpr_RC4_Update(WINPR_RC4_CTX* ctx, size_t length, const void* input, + void* output); + +#ifdef __cplusplus +} +#endif + +/** + * Generic Cipher API + */ + +#define WINPR_AES_BLOCK_SIZE 16 + +/* cipher operation types */ +#define WINPR_ENCRYPT 0 +#define WINPR_DECRYPT 1 + +/* cipher types */ +#define WINPR_CIPHER_NONE 0 +#define WINPR_CIPHER_NULL 1 +#define WINPR_CIPHER_AES_128_ECB 2 +#define WINPR_CIPHER_AES_192_ECB 3 +#define WINPR_CIPHER_AES_256_ECB 4 +#define WINPR_CIPHER_AES_128_CBC 5 +#define WINPR_CIPHER_AES_192_CBC 6 +#define WINPR_CIPHER_AES_256_CBC 7 +#define WINPR_CIPHER_AES_128_CFB128 8 +#define WINPR_CIPHER_AES_192_CFB128 9 +#define WINPR_CIPHER_AES_256_CFB128 10 +#define WINPR_CIPHER_AES_128_CTR 11 +#define WINPR_CIPHER_AES_192_CTR 12 +#define WINPR_CIPHER_AES_256_CTR 13 +#define WINPR_CIPHER_AES_128_GCM 14 +#define WINPR_CIPHER_AES_192_GCM 15 +#define WINPR_CIPHER_AES_256_GCM 16 +#define WINPR_CIPHER_CAMELLIA_128_ECB 17 +#define WINPR_CIPHER_CAMELLIA_192_ECB 18 +#define WINPR_CIPHER_CAMELLIA_256_ECB 19 +#define WINPR_CIPHER_CAMELLIA_128_CBC 20 +#define WINPR_CIPHER_CAMELLIA_192_CBC 21 +#define WINPR_CIPHER_CAMELLIA_256_CBC 22 +#define WINPR_CIPHER_CAMELLIA_128_CFB128 23 +#define WINPR_CIPHER_CAMELLIA_192_CFB128 24 +#define WINPR_CIPHER_CAMELLIA_256_CFB128 25 +#define WINPR_CIPHER_CAMELLIA_128_CTR 26 +#define WINPR_CIPHER_CAMELLIA_192_CTR 27 +#define WINPR_CIPHER_CAMELLIA_256_CTR 28 +#define WINPR_CIPHER_CAMELLIA_128_GCM 29 +#define WINPR_CIPHER_CAMELLIA_192_GCM 30 +#define WINPR_CIPHER_CAMELLIA_256_GCM 31 +#define WINPR_CIPHER_DES_ECB 32 +#define WINPR_CIPHER_DES_CBC 33 +#define WINPR_CIPHER_DES_EDE_ECB 34 +#define WINPR_CIPHER_DES_EDE_CBC 35 +#define WINPR_CIPHER_DES_EDE3_ECB 36 +#define WINPR_CIPHER_DES_EDE3_CBC 37 +#define WINPR_CIPHER_BLOWFISH_ECB 38 +#define WINPR_CIPHER_BLOWFISH_CBC 39 +#define WINPR_CIPHER_BLOWFISH_CFB64 40 +#define WINPR_CIPHER_BLOWFISH_CTR 41 +#define WINPR_CIPHER_ARC4_128 42 +#define WINPR_CIPHER_AES_128_CCM 43 +#define WINPR_CIPHER_AES_192_CCM 44 +#define WINPR_CIPHER_AES_256_CCM 45 +#define WINPR_CIPHER_CAMELLIA_128_CCM 46 +#define WINPR_CIPHER_CAMELLIA_192_CCM 47 +#define WINPR_CIPHER_CAMELLIA_256_CCM 48 + +typedef struct winpr_cipher_ctx_private_st WINPR_CIPHER_CTX; + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API void winpr_Cipher_Free(WINPR_CIPHER_CTX* ctx); + + WINPR_ATTR_MALLOC(winpr_Cipher_Free, 1) + WINPR_API WINPR_CIPHER_CTX* winpr_Cipher_New(int cipher, int op, const void* key, + const void* iv); + WINPR_API BOOL winpr_Cipher_SetPadding(WINPR_CIPHER_CTX* ctx, BOOL enabled); + WINPR_API BOOL winpr_Cipher_Update(WINPR_CIPHER_CTX* ctx, const void* input, size_t ilen, + void* output, size_t* olen); + WINPR_API BOOL winpr_Cipher_Final(WINPR_CIPHER_CTX* ctx, void* output, size_t* olen); + +#ifdef __cplusplus +} +#endif + +/** + * Key Generation + */ + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API int winpr_Cipher_BytesToKey(int cipher, WINPR_MD_TYPE md, const void* salt, + const void* data, size_t datal, size_t count, void* key, + void* iv); + +#ifdef __cplusplus +} +#endif + +#endif /* WINPR_CUSTOM_CRYPTO_H */ diff --git a/winpr/include/winpr/debug.h b/winpr/include/winpr/debug.h new file mode 100644 index 0000000..43e6d21 --- /dev/null +++ b/winpr/include/winpr/debug.h @@ -0,0 +1,45 @@ +/** + * WinPR: Windows Portable Runtime + * WinPR Debugging helpers + * + * Copyright 2014 Armin Novak <armin.novak@thincast.com> + * Copyright 2014 Thincast Technologies GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_DEBUG_H +#define WINPR_DEBUG_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include <winpr/wtypes.h> +#include <winpr/winpr.h> +#include <winpr/wlog.h> + + WINPR_API void winpr_log_backtrace(const char* tag, DWORD level, DWORD size); + WINPR_API void winpr_log_backtrace_ex(wLog* log, DWORD level, DWORD size); + WINPR_API void* winpr_backtrace(DWORD size); + WINPR_API void winpr_backtrace_free(void* buffer); + WINPR_API char** winpr_backtrace_symbols(void* buffer, size_t* used); + WINPR_API void winpr_backtrace_symbols_fd(void* buffer, int fd); + WINPR_API char* winpr_strerror(DWORD dw, char* dmsg, size_t size); + +#ifdef __cplusplus +} +#endif + +#endif /* WINPR_WLOG_H */ diff --git a/winpr/include/winpr/dsparse.h b/winpr/include/winpr/dsparse.h new file mode 100644 index 0000000..63b2b54 --- /dev/null +++ b/winpr/include/winpr/dsparse.h @@ -0,0 +1,127 @@ +/** + * WinPR: Windows Portable Runtime + * Active Directory Domain Services Parsing Functions + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_DSPARSE_H +#define WINPR_DSPARSE_H + +#if defined(_WIN32) && !defined(_UWP) + +#include <winpr/windows.h> +#include <winpr/rpc.h> + +#include <ntdsapi.h> + +#else + +#include <winpr/crt.h> +#include <winpr/winpr.h> +#include <winpr/wtypes.h> +#include <winpr/error.h> + +typedef enum +{ + DS_NAME_NO_FLAGS = 0x0, + DS_NAME_FLAG_SYNTACTICAL_ONLY = 0x1, + DS_NAME_FLAG_EVAL_AT_DC = 0x2, + DS_NAME_FLAG_GCVERIFY = 0x4, + DS_NAME_FLAG_TRUST_REFERRAL = 0x8 +} DS_NAME_FLAGS; + +typedef enum +{ + DS_UNKNOWN_NAME = 0, + DS_FQDN_1779_NAME = 1, + DS_NT4_ACCOUNT_NAME = 2, + DS_DISPLAY_NAME = 3, + DS_UNIQUE_ID_NAME = 6, + DS_CANONICAL_NAME = 7, + DS_USER_PRINCIPAL_NAME = 8, + DS_CANONICAL_NAME_EX = 9, + DS_SERVICE_PRINCIPAL_NAME = 10, + DS_SID_OR_SID_HISTORY_NAME = 11, + DS_DNS_DOMAIN_NAME = 12 +} DS_NAME_FORMAT; + +typedef enum +{ + DS_NAME_NO_ERROR = 0, + DS_NAME_ERROR_RESOLVING = 1, + DS_NAME_ERROR_NOT_FOUND = 2, + DS_NAME_ERROR_NOT_UNIQUE = 3, + DS_NAME_ERROR_NO_MAPPING = 4, + DS_NAME_ERROR_DOMAIN_ONLY = 5, + DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING = 6, + DS_NAME_ERROR_TRUST_REFERRAL = 7 +} DS_NAME_ERROR; + +typedef enum +{ + DS_SPN_DNS_HOST = 0, + DS_SPN_DN_HOST = 1, + DS_SPN_NB_HOST = 2, + DS_SPN_DOMAIN = 3, + DS_SPN_NB_DOMAIN = 4, + DS_SPN_SERVICE = 5 +} DS_SPN_NAME_TYPE; + +typedef struct +{ + DWORD status; + LPTSTR pDomain; + LPTSTR pName; +} DS_NAME_RESULT_ITEM, *PDS_NAME_RESULT_ITEM; + +typedef struct +{ + DWORD cItems; + PDS_NAME_RESULT_ITEM rItems; +} DS_NAME_RESULT, *PDS_NAME_RESULT; + +#ifdef __cplusplus +extern "C" +{ +#endif + +#ifdef UNICODE +#define DsMakeSpn DsMakeSpnW +#else +#define DsMakeSpn DsMakeSpnA +#endif + + WINPR_API DWORD DsMakeSpnW(LPCWSTR ServiceClass, LPCWSTR ServiceName, LPCWSTR InstanceName, + USHORT InstancePort, LPCWSTR Referrer, DWORD* pcSpnLength, + LPWSTR pszSpn); + + WINPR_API DWORD DsMakeSpnA(LPCSTR ServiceClass, LPCSTR ServiceName, LPCSTR InstanceName, + USHORT InstancePort, LPCSTR Referrer, DWORD* pcSpnLength, + LPSTR pszSpn); + +#ifdef __cplusplus +} +#endif + +#ifdef UNICODE +#define DsMakeSpn DsMakeSpnW +#else +#define DsMakeSpn DsMakeSpnA +#endif + +#endif + +#endif /* WINPR_DSPARSE_H */ diff --git a/winpr/include/winpr/endian.h b/winpr/include/winpr/endian.h new file mode 100644 index 0000000..e29872b --- /dev/null +++ b/winpr/include/winpr/endian.h @@ -0,0 +1,196 @@ +/* + * WinPR: Windows Portable Runtime + * Endianness Macros + * + * Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_ENDIAN_H +#define WINPR_ENDIAN_H + +#include <winpr/winpr.h> +#include <winpr/wtypes.h> +#include <winpr/platform.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define Data_Read_UINT8_NE(_d, _v) \ + do \ + { \ + _v = *((const BYTE*)_d); \ + } while (0) + +#define Data_Read_UINT8(_d, _v) \ + do \ + { \ + _v = *((const BYTE*)_d); \ + } while (0) + +#define Data_Read_UINT16_NE(_d, _v) \ + do \ + { \ + _v = *((const UINT16*)_d); \ + } while (0) + +#define Data_Read_UINT16(_d, _v) \ + do \ + { \ + _v = (UINT16)(*((const BYTE*)_d)) + (UINT16)(((UINT16)(*((const BYTE*)_d + 1))) << 8); \ + } while (0) + +#define Data_Read_UINT16_BE(_d, _v) \ + do \ + { \ + _v = (((UINT16)(*(const BYTE*)_d)) << 8) + (UINT16)(*((const BYTE*)_d + 1)); \ + } while (0) + +#define Data_Read_UINT32_NE(_d, _v) \ + do \ + { \ + _v = *((UINT32*)_d); \ + } while (0) + +#define Data_Read_UINT32(_d, _v) \ + do \ + { \ + _v = (UINT32)(*((const BYTE*)_d)) + (((UINT32)(*((const BYTE*)_d + 1))) << 8) + \ + (((UINT32)(*((const BYTE*)_d + 2))) << 16) + \ + (((UINT32)(*((const BYTE*)_d + 3))) << 24); \ + } while (0) + +#define Data_Read_UINT32_BE(_d, _v) \ + do \ + { \ + _v = (((UINT32)(*((const BYTE*)_d))) << 24) + (((UINT32)(*((const BYTE*)_d + 1))) << 16) + \ + (((UINT32)(*((const BYTE*)_d + 2))) << 8) + (((UINT32)(*((const BYTE*)_d + 3)))); \ + } while (0) + +#define Data_Read_UINT64_NE(_d, _v) \ + do \ + { \ + _v = *((UINT64*)_d); \ + } while (0) + +#define Data_Read_UINT64(_d, _v) \ + do \ + { \ + _v = (UINT64)(*((const BYTE*)_d)) + (((UINT64)(*((const BYTE*)_d + 1))) << 8) + \ + (((UINT64)(*((const BYTE*)_d + 2))) << 16) + \ + (((UINT64)(*((const BYTE*)_d + 3))) << 24) + \ + (((UINT64)(*((const BYTE*)_d + 4))) << 32) + \ + (((UINT64)(*((const BYTE*)_d + 5))) << 40) + \ + (((UINT64)(*((const BYTE*)_d + 6))) << 48) + \ + (((UINT64)(*((const BYTE*)_d + 7))) << 56); \ + } while (0) + +#define Data_Read_UINT64_BE(_d, _v) \ + do \ + { \ + _v = (((UINT64)(*((const BYTE*)_d))) << 56) + (((UINT64)(*((const BYTE*)_d + 1))) << 48) + \ + (((UINT64)(*((const BYTE*)_d + 2))) << 40) + \ + (((UINT64)(*((const BYTE*)_d + 3))) << 32) + \ + (((UINT64)(*((const BYTE*)_d + 4))) << 24) + \ + (((UINT64)(*((const BYTE*)_d + 5))) << 16) + \ + (((UINT64)(*((const BYTE*)_d + 6))) << 8) + (((UINT64)(*((const BYTE*)_d + 7)))); \ + } while (0) + +#define Data_Write_UINT8_NE(_d, _v) \ + do \ + { \ + *((UINT8*)_d) = v; \ + } while (0) + +#define Data_Write_UINT8(_d, _v) \ + do \ + { \ + *_d = (UINT8)(_v); \ + } while (0) + +#define Data_Write_UINT16_NE(_d, _v) \ + do \ + { \ + *((UINT16*)_d) = _v; \ + } while (0) + +#define Data_Write_UINT16(_d, _v) \ + do \ + { \ + *((BYTE*)_d) = (_v)&0xFF; \ + *((BYTE*)_d + 1) = ((_v) >> 8) & 0xFF; \ + } while (0) + +#define Data_Write_UINT16_BE(_d, _v) \ + do \ + { \ + *((BYTE*)_d) = ((_v) >> 8) & 0xFF; \ + *((BYTE*)_d + 1) = (_v)&0xFF; \ + } while (0) + +#define Data_Write_UINT32_NE(_d, _v) \ + do \ + { \ + *((UINT32*)_d) = _v; \ + } while (0) + +#define Data_Write_UINT32(_d, _v) \ + do \ + { \ + *((BYTE*)_d) = (_v)&0xFF; \ + *((BYTE*)_d + 1) = ((_v) >> 8) & 0xFF; \ + *((BYTE*)_d + 2) = ((_v) >> 16) & 0xFF; \ + *((BYTE*)_d + 3) = ((_v) >> 24) & 0xFF; \ + } while (0) + +#define Data_Write_UINT32_BE(_d, _v) \ + do \ + { \ + Data_Write_UINT16_BE((BYTE*)_d, ((_v) >> 16 & 0xFFFF)); \ + Data_Write_UINT16_BE((BYTE*)_d + 2, ((_v)&0xFFFF)); \ + } while (0) + +#define Data_Write_UINT64_NE(_d, _v) \ + do \ + { \ + *((UINT64*)_d) = _v; \ + } while (0) + +#define Data_Write_UINT64(_d, _v) \ + do \ + { \ + *((BYTE*)_d) = (UINT64)(_v)&0xFF; \ + *((BYTE*)_d + 1) = ((UINT64)(_v) >> 8) & 0xFF; \ + *((BYTE*)_d + 2) = ((UINT64)(_v) >> 16) & 0xFF; \ + *((BYTE*)_d + 3) = ((UINT64)(_v) >> 24) & 0xFF; \ + *((BYTE*)_d + 4) = ((UINT64)(_v) >> 32) & 0xFF; \ + *((BYTE*)_d + 5) = ((UINT64)(_v) >> 40) & 0xFF; \ + *((BYTE*)_d + 6) = ((UINT64)(_v) >> 48) & 0xFF; \ + *((BYTE*)_d + 7) = ((UINT64)(_v) >> 56) & 0xFF; \ + } while (0) + +#define Data_Write_UINT64_BE(_d, _v) \ + do \ + { \ + Data_Write_UINT32_BE((BYTE*)_d, ((_v) >> 32 & 0xFFFFFFFF)); \ + Data_Write_UINT32_BE((BYTE*)_d + 4, ((_v)&0xFFFFFFFF)); \ + } while (0) + +#ifdef __cplusplus +} +#endif + +#endif /* WINPR_ENDIAN_H */ diff --git a/winpr/include/winpr/environment.h b/winpr/include/winpr/environment.h new file mode 100644 index 0000000..f530d59 --- /dev/null +++ b/winpr/include/winpr/environment.h @@ -0,0 +1,144 @@ +/** + * WinPR: Windows Portable Runtime + * Process Environment Functions + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * Copyright 2013 Thincast Technologies GmbH + * Copyright 2013 DI (FH) Martin Haimberger <martin.haimberger@thincast.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_ENVIRONMENT_H +#define WINPR_ENVIRONMENT_H + +#include <winpr/winpr.h> +#include <winpr/wtypes.h> + +#ifndef _WIN32 + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API DWORD GetCurrentDirectoryA(DWORD nBufferLength, LPSTR lpBuffer); + WINPR_API DWORD GetCurrentDirectoryW(DWORD nBufferLength, LPWSTR lpBuffer); + + WINPR_API BOOL SetCurrentDirectoryA(LPCSTR lpPathName); + WINPR_API BOOL SetCurrentDirectoryW(LPCWSTR lpPathName); + + WINPR_API DWORD SearchPathA(LPCSTR lpPath, LPCSTR lpFileName, LPCSTR lpExtension, + DWORD nBufferLength, LPSTR lpBuffer, LPSTR* lpFilePart); + WINPR_API DWORD SearchPathW(LPCWSTR lpPath, LPCWSTR lpFileName, LPCWSTR lpExtension, + DWORD nBufferLength, LPWSTR lpBuffer, LPWSTR* lpFilePart); + + WINPR_API LPSTR GetCommandLineA(VOID); + WINPR_API LPWSTR GetCommandLineW(VOID); + + WINPR_API BOOL NeedCurrentDirectoryForExePathA(LPCSTR ExeName); + WINPR_API BOOL NeedCurrentDirectoryForExePathW(LPCWSTR ExeName); + +#ifdef __cplusplus +} +#endif + +#ifdef UNICODE +#define GetCurrentDirectory GetCurrentDirectoryW +#define SetCurrentDirectory SetCurrentDirectoryW +#define SearchPath SearchPathW +#define GetCommandLine GetCommandLineW +#define NeedCurrentDirectoryForExePath NeedCurrentDirectoryForExePathW +#else +#define GetCurrentDirectory GetCurrentDirectoryA +#define SetCurrentDirectory SetCurrentDirectoryA +#define SearchPath SearchPathA +#define GetCommandLine GetCommandLineA +#define NeedCurrentDirectoryForExePath NeedCurrentDirectoryForExePathA +#endif + +#endif + +#if !defined(_WIN32) || defined(_UWP) + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API DWORD GetEnvironmentVariableA(LPCSTR lpName, LPSTR lpBuffer, DWORD nSize); + WINPR_API DWORD GetEnvironmentVariableW(LPCWSTR lpName, LPWSTR lpBuffer, DWORD nSize); + + WINPR_API BOOL SetEnvironmentVariableA(LPCSTR lpName, LPCSTR lpValue); + WINPR_API BOOL SetEnvironmentVariableW(LPCWSTR lpName, LPCWSTR lpValue); + + /** + * A brief history of the GetEnvironmentStrings functions: + * http://blogs.msdn.com/b/oldnewthing/archive/2013/01/17/10385718.aspx + */ + + WINPR_API LPCH GetEnvironmentStrings(VOID); + WINPR_API LPWCH GetEnvironmentStringsW(VOID); + + WINPR_API BOOL SetEnvironmentStringsA(LPCH NewEnvironment); + WINPR_API BOOL SetEnvironmentStringsW(LPWCH NewEnvironment); + + WINPR_API DWORD ExpandEnvironmentStringsA(LPCSTR lpSrc, LPSTR lpDst, DWORD nSize); + WINPR_API DWORD ExpandEnvironmentStringsW(LPCWSTR lpSrc, LPWSTR lpDst, DWORD nSize); + + WINPR_API BOOL FreeEnvironmentStringsA(LPCH lpszEnvironmentBlock); + WINPR_API BOOL FreeEnvironmentStringsW(LPWCH lpszEnvironmentBlock); + +#ifdef __cplusplus +} +#endif + +#ifdef UNICODE +#define GetEnvironmentVariable GetEnvironmentVariableW +#define SetEnvironmentVariable SetEnvironmentVariableW +#define GetEnvironmentStrings GetEnvironmentStringsW +#define SetEnvironmentStrings SetEnvironmentStringsW +#define ExpandEnvironmentStrings ExpandEnvironmentStringsW +#define FreeEnvironmentStrings FreeEnvironmentStringsW +#else +#define GetEnvironmentVariable GetEnvironmentVariableA +#define SetEnvironmentVariable SetEnvironmentVariableA +#define GetEnvironmentStringsA GetEnvironmentStrings +#define SetEnvironmentStrings SetEnvironmentStringsA +#define ExpandEnvironmentStrings ExpandEnvironmentStringsA +#define FreeEnvironmentStrings FreeEnvironmentStringsA +#endif + +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API LPCH MergeEnvironmentStrings(PCSTR original, PCSTR merge); + + WINPR_API DWORD GetEnvironmentVariableEBA(LPCSTR envBlock, LPCSTR lpName, LPSTR lpBuffer, + DWORD nSize); + WINPR_API BOOL SetEnvironmentVariableEBA(LPSTR* envBlock, LPCSTR lpName, LPCSTR lpValue); + + WINPR_API char** EnvironmentBlockToEnvpA(LPCH lpszEnvironmentBlock); + + WINPR_API DWORD GetEnvironmentVariableX(const char* lpName, char* lpBuffer, DWORD nSize); + WINPR_API char* GetEnvAlloc(LPCSTR lpName); + +#ifdef __cplusplus +} +#endif + +#endif /* WINPR_ENVIRONMENT_H */ diff --git a/winpr/include/winpr/error.h b/winpr/include/winpr/error.h new file mode 100644 index 0000000..5c1676a --- /dev/null +++ b/winpr/include/winpr/error.h @@ -0,0 +1,3111 @@ +/** + * WinPR: Windows Portable Runtime + * Error Handling Functions + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_ERROR_H +#define WINPR_ERROR_H + +#include <winpr/platform.h> +#include <winpr/winpr.h> +#include <winpr/wtypes.h> + +#ifdef _WIN32 + +#include <winerror.h> + +/* mingw is possibly missing some definitions */ +#ifndef RPC_S_PROXY_ACCESS_DENIED +#define RPC_S_PROXY_ACCESS_DENIED 0x000006C1 +#endif + +#ifndef RPC_S_COOKIE_AUTH_FAILED +#define RPC_S_COOKIE_AUTH_FAILED 0x00000729 +#endif + +#ifndef ERROR_OPERATION_IN_PROGRESS +#define ERROR_OPERATION_IN_PROGRESS 0x00000149 +#endif + +#else + +#ifndef NO_ERROR +#define NO_ERROR 0 +#endif + +#define E_UNEXPECTED -2147418113l // 0x8000FFFFL +#define E_ACCESSDENIED -2147024891l // 0x80070005L +#define E_HANDLE -2147024890l // 0x80070006L +#define E_OUTOFMEMORY -2147024882l // 0x8007000EL + +#define E_INVALIDARG -2147024809l // 0x80070057L +#define E_NOTIMPL -2147467263l // 0x80004001L +#define E_NOINTERFACE -2147467262l // 0x80004002L +#define E_POINTER -2147467261l // 0x80004003L +#define E_ABORT -2147467260l // 0x80004004L +#define E_FAIL -2147467259l // 0x80004005L + +#define CO_E_INIT_TLS -2147467258l // 0x80004006l +#define CO_E_INIT_SHARED_ALLOCATOR -2147467257l // 0x80004007l +#define CO_E_INIT_MEMORY_ALLOCATOR -2147467256l // 0x80004008l +#define CO_E_INIT_CLASS_CACHE -2147467255l // 0x80004009l +#define CO_E_INIT_RPC_CHANNEL -2147467254l // 0x8000400Al +#define CO_E_INIT_TLS_SET_CHANNEL_CONTROL -2147467253l // 0x8000400Bl +#define CO_E_INIT_TLS_CHANNEL_CONTROL -2147467252l // 0x8000400Cl +#define CO_E_INIT_UNACCEPTED_USER_ALLOCATOR -2147467251l // 0x8000400Dl +#define CO_E_INIT_SCM_MUTEX_EXISTS -2147467250l // 0x8000400El +#define CO_E_INIT_SCM_FILE_MAPPING_EXISTS -2147467249l // 0x8000400Fl +#define CO_E_INIT_SCM_MAP_VIEW_OF_FILE -2147467248l // 0x80004010l +#define CO_E_INIT_SCM_EXEC_FAILURE -2147467247l // 0x80004011l +#define CO_E_INIT_ONLY_SINGLE_THREADED -2147467246l // 0x80004012l +#define CO_E_CANT_REMOTE -2147467245l // 0x80004013l +#define CO_E_BAD_SERVER_NAME -2147467244l // 0x80004014l +#define CO_E_WRONG_SERVER_IDENTITY -2147467243l // 0x80004015l +#define CO_E_OLE1DDE_DISABLED -2147467242l // 0x80004016l +#define CO_E_RUNAS_SYNTAX -2147467241l // 0x80004017l +#define CO_E_CREATEPROCESS_FAILURE -2147467240l // 0x80004018l +#define CO_E_RUNAS_CREATEPROCESS_FAILURE -2147467239l // 0x80004019l +#define CO_E_RUNAS_LOGON_FAILURE -2147467238l // 0x8000401Al +#define CO_E_LAUNCH_PERMSSION_DENIED -2147467237l // 0x8000401Bl +#define CO_E_START_SERVICE_FAILURE -2147467236l // 0x8000401Cl +#define CO_E_REMOTE_COMMUNICATION_FAILURE -2147467235l // 0x8000401Dl +#define CO_E_SERVER_START_TIMEOUT -2147467234l // 0x8000401El +#define CO_E_CLSREG_INCONSISTENT -2147467233l // 0x8000401Fl +#define CO_E_IIDREG_INCONSISTENT -2147467232l // 0x80004020l +#define CO_E_NOT_SUPPORTED -2147467231l // 0x80004021l +#define CO_E_RELOAD_DLL -2147467230l // 0x80004022l +#define CO_E_MSI_ERROR -2147467229l // 0x80004023l +#define CO_E_ATTEMPT_TO_CREATE_OUTSIDE_CLIENT_CONTEXT -2147467228l // 0x80004024l +#define CO_E_SERVER_PAUSED -2147467227l // 0x80004025l +#define CO_E_SERVER_NOT_PAUSED -2147467226l // 0x80004026l +#define CO_E_CLASS_DISABLED -2147467225l // 0x80004027l +#define CO_E_CLRNOTAVAILABLE -2147467224l // 0x80004028l +#define CO_E_ASYNC_WORK_REJECTED -2147467223l // 0x80004029l +#define CO_E_SERVER_INIT_TIMEOUT -2147467222l // 0x8000402Al +#define CO_E_NO_SECCTX_IN_ACTIVATE -2147467221l // 0x8000402Bl +#define CO_E_TRACKER_CONFIG -2147467216l // 0x80004030l +#define CO_E_THREADPOOL_CONFIG -2147467215l // 0x80004031l +#define CO_E_SXS_CONFIG -2147467214l // 0x80004032l +#define CO_E_MALFORMED_SPN -2147467213l // 0x80004033l + +#define FACILITY_WINDOWSUPDATE 36 +#define FACILITY_WINDOWS_CE 24 +#define FACILITY_WINDOWS 8 +#define FACILITY_URT 19 +#define FACILITY_UMI 22 +#define FACILITY_SXS 23 +#define FACILITY_STORAGE 3 +#define FACILITY_STATE_MANAGEMENT 34 +#define FACILITY_SSPI 9 +#define FACILITY_SCARD 16 +#define FACILITY_SETUPAPI 15 +#define FACILITY_SECURITY 9 +#define FACILITY_RPC 1 +#define FACILITY_WIN32 7 +#define FACILITY_CONTROL 10 +#define FACILITY_NULL 0 +#define FACILITY_METADIRECTORY 35 +#define FACILITY_MSMQ 14 +#define FACILITY_MEDIASERVER 13 +#define FACILITY_INTERNET 12 +#define FACILITY_ITF 4 +#define FACILITY_HTTP 25 +#define FACILITY_DPLAY 21 +#define FACILITY_DISPATCH 2 +#define FACILITY_DIRECTORYSERVICE 37 +#define FACILITY_CONFIGURATION 33 +#define FACILITY_COMPLUS 17 +#define FACILITY_CERT 11 +#define FACILITY_BACKGROUNDCOPY 32 +#define FACILITY_ACS 20 +#define FACILITY_AAF 18 + +#define FACILITY_NT_BIT 0x10000000 + +#define SEVERITY_SUCCESS 0 +#define SEVERITY_ERROR 1 + +#define HRESULT_CODE(hr) ((hr)&0xFFFF) +#define HRESULT_FACILITY(hr) (((hr) >> 16) & 0x1FFF) + +#define HRESULT_FROM_NT(x) (((x) | FACILITY_NT_BIT)) + +WINPR_PRAGMA_DIAG_PUSH +WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO + +#ifdef __cplusplus +#define ERROR_CAST(t, val) static_cast<t>(val) +#else +#define ERROR_CAST(t, val) (t)(val) +#endif +static INLINE HRESULT HRESULT_FROM_WIN32(unsigned long x) +{ + HRESULT hx = ERROR_CAST(HRESULT, x); + if (hx <= 0) + return hx; + return ERROR_CAST(HRESULT, (((x)&0x0000FFFF) | (FACILITY_WIN32 << 16) | 0x80000000)); +} + +WINPR_PRAGMA_DIAG_POP + +#define HRESULT_SEVERITY(hr) (((hr) >> 31) & 0x1) + +#define SUCCEEDED(hr) (((hr)) >= 0) +#define FAILED(hr) (((hr)) < 0) +#define IS_ERROR(Status) ((ERROR_CAST(unsigned long, Status)) >> 31 == SEVERITY_ERROR) + +#define MAKE_HRESULT(sev, fac, code) \ + ((HRESULT)((ERROR_CAST(unsigned long, sev) << 31) | (ERROR_CAST(unsigned long, fac) << 16) | \ + (ERROR_CAST(unsigned long, code)))) + +#define SCODE_CODE(sc) ((sc)&0xFFFF) +#define SCODE_FACILITY(sc) (((sc) >> 16) & 0x1FFF) +#define SCODE_SEVERITY(sc) (((sc) >> 31) & 0x1) + +#define MAKE_SCODE(sev, fac, code) \ + ((SCODE)((ERROR_CAST(unsigned long, sev) << 31) | (ERROR_CAST(unsigned long, fac) << 16) | \ + (ERROR_CAST(unsigned long, code)))) + +#define S_OK (0L) +#define S_FALSE (1L) + +/* System Error Codes (0-499) */ + +#define ERROR_SUCCESS 0x00000000 +#define ERROR_INVALID_FUNCTION 0x00000001 +#define ERROR_FILE_NOT_FOUND 0x00000002 +#define ERROR_PATH_NOT_FOUND 0x00000003 +#define ERROR_TOO_MANY_OPEN_FILES 0x00000004 +#define ERROR_ACCESS_DENIED 0x00000005 +#define ERROR_INVALID_HANDLE 0x00000006 +#define ERROR_ARENA_TRASHED 0x00000007 +#define ERROR_NOT_ENOUGH_MEMORY 0x00000008 +#define ERROR_INVALID_BLOCK 0x00000009 +#define ERROR_BAD_ENVIRONMENT 0x0000000A +#define ERROR_BAD_FORMAT 0x0000000B +#define ERROR_INVALID_ACCESS 0x0000000C +#define ERROR_INVALID_DATA 0x0000000D +#define ERROR_OUTOFMEMORY 0x0000000E +#define ERROR_INVALID_DRIVE 0x0000000F +#define ERROR_CURRENT_DIRECTORY 0x00000010 +#define ERROR_NOT_SAME_DEVICE 0x00000011 +#define ERROR_NO_MORE_FILES 0x00000012 +#define ERROR_WRITE_PROTECT 0x00000013 +#define ERROR_BAD_UNIT 0x00000014 +#define ERROR_NOT_READY 0x00000015 +#define ERROR_BAD_COMMAND 0x00000016 +#define ERROR_CRC 0x00000017 +#define ERROR_BAD_LENGTH 0x00000018 +#define ERROR_SEEK 0x00000019 +#define ERROR_NOT_DOS_DISK 0x0000001A +#define ERROR_SECTOR_NOT_FOUND 0x0000001B +#define ERROR_OUT_OF_PAPER 0x0000001C +#define ERROR_WRITE_FAULT 0x0000001D +#define ERROR_READ_FAULT 0x0000001E +#define ERROR_GEN_FAILURE 0x0000001F +#define ERROR_SHARING_VIOLATION 0x00000020 +#define ERROR_LOCK_VIOLATION 0x00000021 +#define ERROR_WRONG_DISK 0x00000022 +#define ERROR_SHARING_BUFFER_EXCEEDED 0x00000024 +#define ERROR_HANDLE_EOF 0x00000026 +#define ERROR_HANDLE_DISK_FULL 0x00000027 +#define ERROR_NOT_SUPPORTED 0x00000032 +#define ERROR_REM_NOT_LIST 0x00000033 +#define ERROR_DUP_NAME 0x00000034 +#define ERROR_BAD_NETPATH 0x00000035 +#define ERROR_NETWORK_BUSY 0x00000036 +#define ERROR_DEV_NOT_EXIST 0x00000037 +#define ERROR_TOO_MANY_CMDS 0x00000038 +#define ERROR_ADAP_HDW_ERR 0x00000039 +#define ERROR_BAD_NET_RESP 0x0000003A +#define ERROR_UNEXP_NET_ERR 0x0000003B +#define ERROR_BAD_REM_ADAP 0x0000003C +#define ERROR_PRINTQ_FULL 0x0000003D +#define ERROR_NO_SPOOL_SPACE 0x0000003E +#define ERROR_PRINT_CANCELLED 0x0000003F +#define ERROR_NETNAME_DELETED 0x00000040 +#define ERROR_NETWORK_ACCESS_DENIED 0x00000041 +#define ERROR_BAD_DEV_TYPE 0x00000042 +#define ERROR_BAD_NET_NAME 0x00000043 +#define ERROR_TOO_MANY_NAMES 0x00000044 +#define ERROR_TOO_MANY_SESS 0x00000045 +#define ERROR_SHARING_PAUSED 0x00000046 +#define ERROR_REQ_NOT_ACCEP 0x00000047 +#define ERROR_REDIR_PAUSED 0x00000048 +#define ERROR_FILE_EXISTS 0x00000050 +#define ERROR_CANNOT_MAKE 0x00000052 +#define ERROR_FAIL_I24 0x00000053 +#define ERROR_OUT_OF_STRUCTURES 0x00000054 +#define ERROR_ALREADY_ASSIGNED 0x00000055 +#define ERROR_INVALID_PASSWORD 0x00000056 +#define ERROR_INVALID_PARAMETER 0x00000057 +#define ERROR_NET_WRITE_FAULT 0x00000058 +#define ERROR_NO_PROC_SLOTS 0x00000059 +#define ERROR_TOO_MANY_SEMAPHORES 0x00000064 +#define ERROR_EXCL_SEM_ALREADY_OWNED 0x00000065 +#define ERROR_SEM_IS_SET 0x00000066 +#define ERROR_TOO_MANY_SEM_REQUESTS 0x00000067 +#define ERROR_INVALID_AT_INTERRUPT_TIME 0x00000068 +#define ERROR_SEM_OWNER_DIED 0x00000069 +#define ERROR_SEM_USER_LIMIT 0x0000006A +#define ERROR_DISK_CHANGE 0x0000006B +#define ERROR_DRIVE_LOCKED 0x0000006C +#define ERROR_BROKEN_PIPE 0x0000006D +#define ERROR_OPEN_FAILED 0x0000006E +#define ERROR_BUFFER_OVERFLOW 0x0000006F +#define ERROR_DISK_FULL 0x00000070 +#define ERROR_NO_MORE_SEARCH_HANDLES 0x00000071 +#define ERROR_INVALID_TARGET_HANDLE 0x00000072 +#define ERROR_INVALID_CATEGORY 0x00000075 +#define ERROR_INVALID_VERIFY_SWITCH 0x00000076 +#define ERROR_BAD_DRIVER_LEVEL 0x00000077 +#define ERROR_CALL_NOT_IMPLEMENTED 0x00000078 +#define ERROR_SEM_TIMEOUT 0x00000079 +#define ERROR_INSUFFICIENT_BUFFER 0x0000007A +#define ERROR_INVALID_NAME 0x0000007B +#define ERROR_INVALID_LEVEL 0x0000007C +#define ERROR_NO_VOLUME_LABEL 0x0000007D +#define ERROR_MOD_NOT_FOUND 0x0000007E +#define ERROR_PROC_NOT_FOUND 0x0000007F +#define ERROR_WAIT_NO_CHILDREN 0x00000080 +#define ERROR_CHILD_NOT_COMPLETE 0x00000081 +#define ERROR_DIRECT_ACCESS_HANDLE 0x00000082 +#define ERROR_NEGATIVE_SEEK 0x00000083 +#define ERROR_SEEK_ON_DEVICE 0x00000084 +#define ERROR_IS_JOIN_TARGET 0x00000085 +#define ERROR_IS_JOINED 0x00000086 +#define ERROR_IS_SUBSTED 0x00000087 +#define ERROR_NOT_JOINED 0x00000088 +#define ERROR_NOT_SUBSTED 0x00000089 +#define ERROR_JOIN_TO_JOIN 0x0000008A +#define ERROR_SUBST_TO_SUBST 0x0000008B +#define ERROR_JOIN_TO_SUBST 0x0000008C +#define ERROR_SUBST_TO_JOIN 0x0000008D +#define ERROR_BUSY_DRIVE 0x0000008E +#define ERROR_SAME_DRIVE 0x0000008F +#define ERROR_DIR_NOT_ROOT 0x00000090 +#define ERROR_DIR_NOT_EMPTY 0x00000091 +#define ERROR_IS_SUBST_PATH 0x00000092 +#define ERROR_IS_JOIN_PATH 0x00000093 +#define ERROR_PATH_BUSY 0x00000094 +#define ERROR_IS_SUBST_TARGET 0x00000095 +#define ERROR_SYSTEM_TRACE 0x00000096 +#define ERROR_INVALID_EVENT_COUNT 0x00000097 +#define ERROR_TOO_MANY_MUXWAITERS 0x00000098 +#define ERROR_INVALID_LIST_FORMAT 0x00000099 +#define ERROR_LABEL_TOO_LONG 0x0000009A +#define ERROR_TOO_MANY_TCBS 0x0000009B +#define ERROR_SIGNAL_REFUSED 0x0000009C +#define ERROR_DISCARDED 0x0000009D +#define ERROR_NOT_LOCKED 0x0000009E +#define ERROR_BAD_THREADID_ADDR 0x0000009F +#define ERROR_BAD_ARGUMENTS 0x000000A0 +#define ERROR_BAD_PATHNAME 0x000000A1 +#define ERROR_SIGNAL_PENDING 0x000000A2 +#define ERROR_MAX_THRDS_REACHED 0x000000A4 +#define ERROR_LOCK_FAILED 0x000000A7 +#define ERROR_BUSY 0x000000AA +#define ERROR_DEVICE_SUPPORT_IN_PROGRESS 0x000000AB +#define ERROR_CANCEL_VIOLATION 0x000000AD +#define ERROR_ATOMIC_LOCKS_NOT_SUPPORTED 0x000000AE +#define ERROR_INVALID_SEGMENT_NUMBER 0x000000B4 +#define ERROR_INVALID_ORDINAL 0x000000B6 +#define ERROR_ALREADY_EXISTS 0x000000B7 +#define ERROR_INVALID_FLAG_NUMBER 0x000000BA +#define ERROR_SEM_NOT_FOUND 0x000000BB +#define ERROR_INVALID_STARTING_CODESEG 0x000000BC +#define ERROR_INVALID_STACKSEG 0x000000BD +#define ERROR_INVALID_MODULETYPE 0x000000BE +#define ERROR_INVALID_EXE_SIGNATURE 0x000000BF +#define ERROR_EXE_MARKED_INVALID 0x000000C0 +#define ERROR_BAD_EXE_FORMAT 0x000000C1 +#define ERROR_ITERATED_DATA_EXCEEDS_64k 0x000000C2 +#define ERROR_INVALID_MINALLOCSIZE 0x000000C3 +#define ERROR_DYNLINK_FROM_INVALID_RING 0x000000C4 +#define ERROR_IOPL_NOT_ENABLED 0x000000C5 +#define ERROR_INVALID_SEGDPL 0x000000C6 +#define ERROR_AUTODATASEG_EXCEEDS_64k 0x000000C7 +#define ERROR_RING2SEG_MUST_BE_MOVABLE 0x000000C8 +#define ERROR_RELOC_CHAIN_XEEDS_SEGLIM 0x000000C9 +#define ERROR_INFLOOP_IN_RELOC_CHAIN 0x000000CA +#define ERROR_ENVVAR_NOT_FOUND 0x000000CB +#define ERROR_NO_SIGNAL_SENT 0x000000CD +#define ERROR_FILENAME_EXCED_RANGE 0x000000CE +#define ERROR_RING2_STACK_IN_USE 0x000000CF +#define ERROR_META_EXPANSION_TOO_LONG 0x000000D0 +#define ERROR_INVALID_SIGNAL_NUMBER 0x000000D1 +#define ERROR_THREAD_1_INACTIVE 0x000000D2 +#define ERROR_LOCKED 0x000000D4 +#define ERROR_TOO_MANY_MODULES 0x000000D6 +#define ERROR_NESTING_NOT_ALLOWED 0x000000D7 +#define ERROR_EXE_MACHINE_TYPE_MISMATCH 0x000000D8 +#define ERROR_EXE_CANNOT_MODIFY_SIGNED_BINARY 0x000000D9 +#define ERROR_EXE_CANNOT_MODIFY_STRONG_SIGNED_BINARY 0x000000DA +#define ERROR_FILE_CHECKED_OUT 0x000000DC +#define ERROR_CHECKOUT_REQUIRED 0x000000DD +#define ERROR_BAD_FILE_TYPE 0x000000DE +#define ERROR_FILE_TOO_LARGE 0x000000DF +#define ERROR_FORMS_AUTH_REQUIRED 0x000000E0 +#define ERROR_VIRUS_INFECTED 0x000000E1 +#define ERROR_VIRUS_DELETED 0x000000E2 +#define ERROR_PIPE_LOCAL 0x000000E5 +#define ERROR_BAD_PIPE 0x000000E6 +#define ERROR_PIPE_BUSY 0x000000E7 +#define ERROR_NO_DATA 0x000000E8 +#define ERROR_PIPE_NOT_CONNECTED 0x000000E9 +#define ERROR_MORE_DATA 0x000000EA +#define ERROR_VC_DISCONNECTED 0x000000F0 +#define ERROR_INVALID_EA_NAME 0x000000FE +#define ERROR_EA_LIST_INCONSISTENT 0x000000FF +#define WAIT_TIMEOUT 0x00000102 +#define ERROR_NO_MORE_ITEMS 0x00000103 +#define ERROR_CANNOT_COPY 0x0000010A +#define ERROR_DIRECTORY 0x0000010B +#define ERROR_EAS_DIDNT_FIT 0x00000113 +#define ERROR_EA_FILE_CORRUPT 0x00000114 +#define ERROR_EA_TABLE_FULL 0x00000115 +#define ERROR_INVALID_EA_HANDLE 0x00000116 +#define ERROR_EAS_NOT_SUPPORTED 0x0000011A +#define ERROR_NOT_OWNER 0x00000120 +#define ERROR_TOO_MANY_POSTS 0x0000012A +#define ERROR_PARTIAL_COPY 0x0000012B +#define ERROR_OPLOCK_NOT_GRANTED 0x0000012C +#define ERROR_INVALID_OPLOCK_PROTOCOL 0x0000012D +#define ERROR_DISK_TOO_FRAGMENTED 0x0000012E +#define ERROR_DELETE_PENDING 0x0000012F +#define ERROR_INCOMPATIBLE_WITH_GLOBAL_SHORT_NAME_REGISTRY_SETTING 0x00000130 +#define ERROR_SHORT_NAMES_NOT_ENABLED_ON_VOLUME 0x00000131 +#define ERROR_SECURITY_STREAM_IS_INCONSISTENT 0x00000132 +#define ERROR_INVALID_LOCK_RANGE 0x00000133 +#define ERROR_IMAGE_SUBSYSTEM_NOT_PRESENT 0x00000134 +#define ERROR_NOTIFICATION_GUID_ALREADY_DEFINED 0x00000135 +#define ERROR_INVALID_EXCEPTION_HANDLER 0x00000136 +#define ERROR_DUPLICATE_PRIVILEGES 0x00000137 +#define ERROR_NO_RANGES_PROCESSED 0x00000138 +#define ERROR_NOT_ALLOWED_ON_SYSTEM_FILE 0x00000139 +#define ERROR_DISK_RESOURCES_EXHAUSTED 0x0000013A +#define ERROR_INVALID_TOKEN 0x0000013B +#define ERROR_DEVICE_FEATURE_NOT_SUPPORTED 0x0000013C +#define ERROR_MR_MID_NOT_FOUND 0x0000013D +#define ERROR_SCOPE_NOT_FOUND 0x0000013E +#define ERROR_UNDEFINED_SCOPE 0x0000013F +#define ERROR_INVALID_CAP 0x00000140 +#define ERROR_DEVICE_UNREACHABLE 0x00000141 +#define ERROR_DEVICE_NO_RESOURCES 0x00000142 +#define ERROR_DATA_CHECKSUM_ERROR 0x00000143 +#define ERROR_INTERMIXED_KERNEL_EA_OPERATION 0x00000144 +#define ERROR_FILE_LEVEL_TRIM_NOT_SUPPORTED 0x00000146 +#define ERROR_OFFSET_ALIGNMENT_VIOLATION 0x00000147 +#define ERROR_INVALID_FIELD_IN_PARAMETER_LIST 0x00000148 +#define ERROR_OPERATION_IN_PROGRESS 0x00000149 +#define ERROR_BAD_DEVICE_PATH 0x0000014A +#define ERROR_TOO_MANY_DESCRIPTORS 0x0000014B +#define ERROR_SCRUB_DATA_DISABLED 0x0000014C +#define ERROR_NOT_REDUNDANT_STORAGE 0x0000014D +#define ERROR_RESIDENT_FILE_NOT_SUPPORTED 0x0000014E +#define ERROR_COMPRESSED_FILE_NOT_SUPPORTED 0x0000014F +#define ERROR_DIRECTORY_NOT_SUPPORTED 0x00000150 +#define ERROR_NOT_READ_FROM_COPY 0x00000151 +#define ERROR_FAIL_NOACTION_REBOOT 0x0000015E +#define ERROR_FAIL_SHUTDOWN 0x0000015F +#define ERROR_FAIL_RESTART 0x00000160 +#define ERROR_MAX_SESSIONS_REACHED 0x00000161 +#define ERROR_THREAD_MODE_ALREADY_BACKGROUND 0x00000190 +#define ERROR_THREAD_MODE_NOT_BACKGROUND 0x00000191 +#define ERROR_PROCESS_MODE_ALREADY_BACKGROUND 0x00000192 +#define ERROR_PROCESS_MODE_NOT_BACKGROUND 0x00000193 +#define ERROR_INVALID_ADDRESS 0x000001E7 + +/* System Error Codes (500-999) */ + +#define ERROR_USER_PROFILE_LOAD 0x000001F4 +#define ERROR_ARITHMETIC_OVERFLOW 0x00000216 +#define ERROR_PIPE_CONNECTED 0x00000217 +#define ERROR_PIPE_LISTENING 0x00000218 +#define ERROR_VERIFIER_STOP 0x00000219 +#define ERROR_ABIOS_ERROR 0x0000021A +#define ERROR_WX86_WARNING 0x0000021B +#define ERROR_WX86_ERROR 0x0000021C +#define ERROR_TIMER_NOT_CANCELED 0x0000021D +#define ERROR_UNWIND 0x0000021E +#define ERROR_BAD_STACK 0x0000021F +#define ERROR_INVALID_UNWIND_TARGET 0x00000220 +#define ERROR_INVALID_PORT_ATTRIBUTES 0x00000221 +#define ERROR_PORT_MESSAGE_TOO_LONG 0x00000222 +#define ERROR_INVALID_QUOTA_LOWER 0x00000223 +#define ERROR_DEVICE_ALREADY_ATTACHED 0x00000224 +#define ERROR_INSTRUCTION_MISALIGNMENT 0x00000225 +#define ERROR_PROFILING_NOT_STARTED 0x00000226 +#define ERROR_PROFILING_NOT_STOPPED 0x00000227 +#define ERROR_COULD_NOT_INTERPRET 0x00000228 +#define ERROR_PROFILING_AT_LIMIT 0x00000229 +#define ERROR_CANT_WAIT 0x0000022A +#define ERROR_CANT_TERMINATE_SELF 0x0000022B +#define ERROR_UNEXPECTED_MM_CREATE_ERR 0x0000022C +#define ERROR_UNEXPECTED_MM_MAP_ERROR 0x0000022D +#define ERROR_UNEXPECTED_MM_EXTEND_ERR 0x0000022E +#define ERROR_BAD_FUNCTION_TABLE 0x0000022F +#define ERROR_NO_GUID_TRANSLATION 0x00000230 +#define ERROR_INVALID_LDT_SIZE 0x00000231 +#define ERROR_INVALID_LDT_OFFSET 0x00000233 +#define ERROR_INVALID_LDT_DESCRIPTOR 0x00000234 +#define ERROR_TOO_MANY_THREADS 0x00000235 +#define ERROR_THREAD_NOT_IN_PROCESS 0x00000236 +#define ERROR_PAGEFILE_QUOTA_EXCEEDED 0x00000237 +#define ERROR_LOGON_SERVER_CONFLICT 0x00000238 +#define ERROR_SYNCHRONIZATION_REQUIRED 0x00000239 +#define ERROR_NET_OPEN_FAILED 0x0000023A +#define ERROR_IO_PRIVILEGE_FAILED 0x0000023B +#define ERROR_CONTROL_C_EXIT 0x0000023C +#define ERROR_MISSING_SYSTEMFILE 0x0000023D +#define ERROR_UNHANDLED_EXCEPTION 0x0000023E +#define ERROR_APP_INIT_FAILURE 0x0000023F +#define ERROR_PAGEFILE_CREATE_FAILED 0x00000240 +#define ERROR_INVALID_IMAGE_HASH 0x00000241 +#define ERROR_NO_PAGEFILE 0x00000242 +#define ERROR_ILLEGAL_FLOAT_CONTEXT 0x00000243 +#define ERROR_NO_EVENT_PAIR 0x00000244 +#define ERROR_DOMAIN_CTRLR_CONFIG_ERROR 0x00000245 +#define ERROR_ILLEGAL_CHARACTER 0x00000246 +#define ERROR_UNDEFINED_CHARACTER 0x00000247 +#define ERROR_FLOPPY_VOLUME 0x00000248 +#define ERROR_BIOS_FAILED_TO_CONNECT_INTERRUPT 0x00000249 +#define ERROR_BACKUP_CONTROLLER 0x0000024A +#define ERROR_MUTANT_LIMIT_EXCEEDED 0x0000024B +#define ERROR_FS_DRIVER_REQUIRED 0x0000024C +#define ERROR_CANNOT_LOAD_REGISTRY_FILE 0x0000024D +#define ERROR_DEBUG_ATTACH_FAILED 0x0000024E +#define ERROR_SYSTEM_PROCESS_TERMINATED 0x0000024F +#define ERROR_DATA_NOT_ACCEPTED 0x00000250 +#define ERROR_VDM_HARD_ERROR 0x00000251 +#define ERROR_DRIVER_CANCEL_TIMEOUT 0x00000252 +#define ERROR_REPLY_MESSAGE_MISMATCH 0x00000253 +#define ERROR_LOST_WRITEBEHIND_DATA 0x00000254 +#define ERROR_CLIENT_SERVER_PARAMETERS_INVALID 0x00000255 +#define ERROR_NOT_TINY_STREAM 0x00000256 +#define ERROR_STACK_OVERFLOW_READ 0x00000257 +#define ERROR_CONVERT_TO_LARGE 0x00000258 +#define ERROR_FOUND_OUT_OF_SCOPE 0x00000259 +#define ERROR_ALLOCATE_BUCKET 0x0000025A +#define ERROR_MARSHALL_OVERFLOW 0x0000025B +#define ERROR_INVALID_VARIANT 0x0000025C +#define ERROR_BAD_COMPRESSION_BUFFER 0x0000025D +#define ERROR_AUDIT_FAILED 0x0000025E +#define ERROR_TIMER_RESOLUTION_NOT_SET 0x0000025F +#define ERROR_INSUFFICIENT_LOGON_INFO 0x00000260 +#define ERROR_BAD_DLL_ENTRYPOINT 0x00000261 +#define ERROR_BAD_SERVICE_ENTRYPOINT 0x00000262 +#define ERROR_IP_ADDRESS_CONFLICT1 0x00000263 +#define ERROR_IP_ADDRESS_CONFLICT2 0x00000264 +#define ERROR_REGISTRY_QUOTA_LIMIT 0x00000265 +#define ERROR_NO_CALLBACK_ACTIVE 0x00000266 +#define ERROR_PWD_TOO_SHORT 0x00000267 +#define ERROR_PWD_TOO_RECENT 0x00000268 +#define ERROR_PWD_HISTORY_CONFLICT 0x00000269 +#define ERROR_UNSUPPORTED_COMPRESSION 0x0000026A +#define ERROR_INVALID_HW_PROFILE 0x0000026B +#define ERROR_INVALID_PLUGPLAY_DEVICE_PATH 0x0000026C +#define ERROR_QUOTA_LIST_INCONSISTENT 0x0000026D +#define ERROR_EVALUATION_EXPIRATION 0x0000026E +#define ERROR_ILLEGAL_DLL_RELOCATION 0x0000026F +#define ERROR_DLL_INIT_FAILED_LOGOFF 0x00000270 +#define ERROR_VALIDATE_CONTINUE 0x00000271 +#define ERROR_NO_MORE_MATCHES 0x00000272 +#define ERROR_RANGE_LIST_CONFLICT 0x00000273 +#define ERROR_SERVER_SID_MISMATCH 0x00000274 +#define ERROR_CANT_ENABLE_DENY_ONLY 0x00000275 +#define ERROR_FLOAT_MULTIPLE_FAULTS 0x00000276 +#define ERROR_FLOAT_MULTIPLE_TRAPS 0x00000277 +#define ERROR_NOINTERFACE 0x00000278 +#define ERROR_DRIVER_FAILED_SLEEP 0x00000279 +#define ERROR_CORRUPT_SYSTEM_FILE 0x0000027A +#define ERROR_COMMITMENT_MINIMUM 0x0000027B +#define ERROR_PNP_RESTART_ENUMERATION 0x0000027C +#define ERROR_SYSTEM_IMAGE_BAD_SIGNATURE 0x0000027D +#define ERROR_PNP_REBOOT_REQUIRED 0x0000027E +#define ERROR_INSUFFICIENT_POWER 0x0000027F +#define ERROR_MULTIPLE_FAULT_VIOLATION 0x00000280 +#define ERROR_SYSTEM_SHUTDOWN 0x00000281 +#define ERROR_PORT_NOT_SET 0x00000282 +#define ERROR_DS_VERSION_CHECK_FAILURE 0x00000283 +#define ERROR_RANGE_NOT_FOUND 0x00000284 +#define ERROR_NOT_SAFE_MODE_DRIVER 0x00000286 +#define ERROR_FAILED_DRIVER_ENTRY 0x00000287 +#define ERROR_DEVICE_ENUMERATION_ERROR 0x00000288 +#define ERROR_MOUNT_POINT_NOT_RESOLVED 0x00000289 +#define ERROR_INVALID_DEVICE_OBJECT_PARAMETER 0x0000028A +/* The following is not a typo. It's the same spelling as in the Microsoft headers */ +#define ERROR_MCA_OCCURED 0x0000028B +#define ERROR_DRIVER_DATABASE_ERROR 0x0000028C +#define ERROR_SYSTEM_HIVE_TOO_LARGE 0x0000028D +#define ERROR_DRIVER_FAILED_PRIOR_UNLOAD 0x0000028E +#define ERROR_VOLSNAP_PREPARE_HIBERNATE 0x0000028F +#define ERROR_HIBERNATION_FAILURE 0x00000290 +#define ERROR_PWD_TOO_LONG 0x00000291 +#define ERROR_FILE_SYSTEM_LIMITATION 0x00000299 +#define ERROR_ASSERTION_FAILURE 0x0000029C +#define ERROR_ACPI_ERROR 0x0000029D +#define ERROR_WOW_ASSERTION 0x0000029E +#define ERROR_PNP_BAD_MPS_TABLE 0x0000029F +#define ERROR_PNP_TRANSLATION_FAILED 0x000002A0 +#define ERROR_PNP_IRQ_TRANSLATION_FAILED 0x000002A1 +#define ERROR_PNP_INVALID_ID 0x000002A2 +#define ERROR_WAKE_SYSTEM_DEBUGGER 0x000002A3 +#define ERROR_HANDLES_CLOSED 0x000002A4 +#define ERROR_EXTRANEOUS_INFORMATION 0x000002A5 +#define ERROR_RXACT_COMMIT_NECESSARY 0x000002A6 +#define ERROR_MEDIA_CHECK 0x000002A7 +#define ERROR_GUID_SUBSTITUTION_MADE 0x000002A8 +#define ERROR_STOPPED_ON_SYMLINK 0x000002A9 +#define ERROR_LONGJUMP 0x000002AA +#define ERROR_PLUGPLAY_QUERY_VETOED 0x000002AB +#define ERROR_UNWIND_CONSOLIDATE 0x000002AC +#define ERROR_REGISTRY_HIVE_RECOVERED 0x000002AD +#define ERROR_DLL_MIGHT_BE_INSECURE 0x000002AE +#define ERROR_DLL_MIGHT_BE_INCOMPATIBLE 0x000002AF +#define ERROR_DBG_EXCEPTION_NOT_HANDLED 0x000002B0 +#define ERROR_DBG_REPLY_LATER 0x000002B1 +#define ERROR_DBG_UNABLE_TO_PROVIDE_HANDLE 0x000002B2 +#define ERROR_DBG_TERMINATE_THREAD 0x000002B3 +#define ERROR_DBG_TERMINATE_PROCESS 0x000002B4 +#define ERROR_DBG_CONTROL_C 0x000002B5 +#define ERROR_DBG_PRINTEXCEPTION_C 0x000002B6 +#define ERROR_DBG_RIPEXCEPTION 0x000002B7 +#define ERROR_DBG_CONTROL_BREAK 0x000002B8 +#define ERROR_DBG_COMMAND_EXCEPTION 0x000002B9 +#define ERROR_OBJECT_NAME_EXISTS 0x000002BA +#define ERROR_THREAD_WAS_SUSPENDED 0x000002BB +#define ERROR_IMAGE_NOT_AT_BASE 0x000002BC +#define ERROR_RXACT_STATE_CREATED 0x000002BD +#define ERROR_SEGMENT_NOTIFICATION 0x000002BE +#define ERROR_BAD_CURRENT_DIRECTORY 0x000002BF +#define ERROR_FT_READ_RECOVERY_FROM_BACKUP 0x000002C0 +#define ERROR_FT_WRITE_RECOVERY 0x000002C1 +#define ERROR_IMAGE_MACHINE_TYPE_MISMATCH 0x000002C2 +#define ERROR_RECEIVE_PARTIAL 0x000002C3 +#define ERROR_RECEIVE_EXPEDITED 0x000002C4 +#define ERROR_RECEIVE_PARTIAL_EXPEDITED 0x000002C5 +#define ERROR_EVENT_DONE 0x000002C6 +#define ERROR_EVENT_PENDING 0x000002C7 +#define ERROR_CHECKING_FILE_SYSTEM 0x000002C8 +#define ERROR_FATAL_APP_EXIT 0x000002C9 +#define ERROR_PREDEFINED_HANDLE 0x000002CA +#define ERROR_WAS_UNLOCKED 0x000002CB +#define ERROR_SERVICE_NOTIFICATION 0x000002CC +#define ERROR_WAS_LOCKED 0x000002CD +#define ERROR_LOG_HARD_ERROR 0x000002CE +#define ERROR_ALREADY_WIN32 0x000002CF +#define ERROR_IMAGE_MACHINE_TYPE_MISMATCH_EXE 0x000002D0 +#define ERROR_NO_YIELD_PERFORMED 0x000002D1 +#define ERROR_TIMER_RESUME_IGNORED 0x000002D2 +#define ERROR_ARBITRATION_UNHANDLED 0x000002D3 +#define ERROR_CARDBUS_NOT_SUPPORTED 0x000002D4 +#define ERROR_MP_PROCESSOR_MISMATCH 0x000002D5 +#define ERROR_HIBERNATED 0x000002D6 +#define ERROR_RESUME_HIBERNATION 0x000002D7 +#define ERROR_FIRMWARE_UPDATED 0x000002D8 +#define ERROR_DRIVERS_LEAKING_LOCKED_PAGES 0x000002D9 +#define ERROR_WAKE_SYSTEM 0x000002DA +#define ERROR_WAIT_1 0x000002DB +#define ERROR_WAIT_2 0x000002DC +#define ERROR_WAIT_3 0x000002DD +#define ERROR_WAIT_63 0x000002DE +#define ERROR_ABANDONED_WAIT_0 0x000002DF +#define ERROR_ABANDONED_WAIT_63 0x000002E0 +#define ERROR_USER_APC 0x000002E1 +#define ERROR_KERNEL_APC 0x000002E2 +#define ERROR_ALERTED 0x000002E3 +#define ERROR_ELEVATION_REQUIRED 0x000002E4 +#define ERROR_REPARSE 0x000002E5 +#define ERROR_OPLOCK_BREAK_IN_PROGRESS 0x000002E6 +#define ERROR_VOLUME_MOUNTED 0x000002E7 +#define ERROR_RXACT_COMMITTED 0x000002E8 +#define ERROR_NOTIFY_CLEANUP 0x000002E9 +#define ERROR_PRIMARY_TRANSPORT_CONNECT_FAILED 0x000002EA +#define ERROR_PAGE_FAULT_TRANSITION 0x000002EB +#define ERROR_PAGE_FAULT_DEMAND_ZERO 0x000002EC +#define ERROR_PAGE_FAULT_COPY_ON_WRITE 0x000002ED +#define ERROR_PAGE_FAULT_GUARD_PAGE 0x000002EE +#define ERROR_PAGE_FAULT_PAGING_FILE 0x000002EF +#define ERROR_CACHE_PAGE_LOCKED 0x000002F0 +#define ERROR_CRASH_DUMP 0x000002F1 +#define ERROR_BUFFER_ALL_ZEROS 0x000002F2 +#define ERROR_REPARSE_OBJECT 0x000002F3 +#define ERROR_RESOURCE_REQUIREMENTS_CHANGED 0x000002F4 +#define ERROR_TRANSLATION_COMPLETE 0x000002F5 +#define ERROR_NOTHING_TO_TERMINATE 0x000002F6 +#define ERROR_PROCESS_NOT_IN_JOB 0x000002F7 +#define ERROR_PROCESS_IN_JOB 0x000002F8 +#define ERROR_VOLSNAP_HIBERNATE_READY 0x000002F9 +#define ERROR_FSFILTER_OP_COMPLETED_SUCCESSFULLY 0x000002FA +#define ERROR_INTERRUPT_VECTOR_ALREADY_CONNECTED 0x000002FB +#define ERROR_INTERRUPT_STILL_CONNECTED 0x000002FC +#define ERROR_WAIT_FOR_OPLOCK 0x000002FD +#define ERROR_DBG_EXCEPTION_HANDLED 0x000002FE +#define ERROR_DBG_CONTINUE 0x000002FF +#define ERROR_CALLBACK_POP_STACK 0x00000300 +#define ERROR_COMPRESSION_DISABLED 0x00000301 +#define ERROR_CANTFETCHBACKWARDS 0x00000302 +#define ERROR_CANTSCROLLBACKWARDS 0x00000303 +#define ERROR_ROWSNOTRELEASED 0x00000304 +#define ERROR_BAD_ACCESSOR_FLAGS 0x00000305 +#define ERROR_ERRORS_ENCOUNTERED 0x00000306 +#define ERROR_NOT_CAPABLE 0x00000307 +#define ERROR_REQUEST_OUT_OF_SEQUENCE 0x00000308 +#define ERROR_VERSION_PARSE_ERROR 0x00000309 +#define ERROR_BADSTARTPOSITION 0x0000030A +#define ERROR_MEMORY_HARDWARE 0x0000030B +#define ERROR_DISK_REPAIR_DISABLED 0x0000030C +#define ERROR_INSUFFICIENT_RESOURCE_FOR_SPECIFIED_SHARED_SECTION_SIZE 0x0000030D +#define ERROR_SYSTEM_POWERSTATE_TRANSITION 0x0000030E +#define ERROR_SYSTEM_POWERSTATE_COMPLEX_TRANSITION 0x0000030F +#define ERROR_MCA_EXCEPTION 0x00000310 +#define ERROR_ACCESS_AUDIT_BY_POLICY 0x00000311 +#define ERROR_ACCESS_DISABLED_NO_SAFER_UI_BY_POLICY 0x00000312 +#define ERROR_ABANDON_HIBERFILE 0x00000313 +#define ERROR_LOST_WRITEBEHIND_DATA_NETWORK_DISCONNECTED 0x00000314 +#define ERROR_LOST_WRITEBEHIND_DATA_NETWORK_SERVER_ERROR 0x00000315 +#define ERROR_LOST_WRITEBEHIND_DATA_LOCAL_DISK_ERROR 0x00000316 +#define ERROR_BAD_MCFG_TABLE 0x00000317 +#define ERROR_DISK_REPAIR_REDIRECTED 0x00000318 +#define ERROR_DISK_REPAIR_UNSUCCESSFUL 0x00000319 +#define ERROR_CORRUPT_LOG_OVERFULL 0x0000031A +#define ERROR_CORRUPT_LOG_CORRUPTED 0x0000031B +#define ERROR_CORRUPT_LOG_UNAVAILABLE 0x0000031C +#define ERROR_CORRUPT_LOG_DELETED_FULL 0x0000031D +#define ERROR_CORRUPT_LOG_CLEARED 0x0000031E +#define ERROR_ORPHAN_NAME_EXHAUSTED 0x0000031F +#define ERROR_OPLOCK_SWITCHED_TO_NEW_HANDLE 0x00000320 +#define ERROR_CANNOT_GRANT_REQUESTED_OPLOCK 0x00000321 +#define ERROR_CANNOT_BREAK_OPLOCK 0x00000322 +#define ERROR_OPLOCK_HANDLE_CLOSED 0x00000323 +#define ERROR_NO_ACE_CONDITION 0x00000324 +#define ERROR_INVALID_ACE_CONDITION 0x00000325 +#define ERROR_FILE_HANDLE_REVOKED 0x00000326 +#define ERROR_IMAGE_AT_DIFFERENT_BASE 0x00000327 +#define ERROR_EA_ACCESS_DENIED 0x000003E2 +#define ERROR_OPERATION_ABORTED 0x000003E3 +#define ERROR_IO_INCOMPLETE 0x000003E4 +#define ERROR_IO_PENDING 0x000003E5 +#define ERROR_NOACCESS 0x000003E6 +#define ERROR_SWAPERROR 0x000003E7 + +/* System Error Codes (1000-1299) */ + +#define ERROR_STACK_OVERFLOW 0x000003E9 +#define ERROR_INVALID_MESSAGE 0x000003EA +#define ERROR_CAN_NOT_COMPLETE 0x000003EB +#define ERROR_INVALID_FLAGS 0x000003EC +#define ERROR_UNRECOGNIZED_VOLUME 0x000003ED +#define ERROR_FILE_INVALID 0x000003EE +#define ERROR_FULLSCREEN_MODE 0x000003EF +#define ERROR_NO_TOKEN 0x000003F0 +#define ERROR_BADDB 0x000003F1 +#define ERROR_BADKEY 0x000003F2 +#define ERROR_CANTOPEN 0x000003F3 +#define ERROR_CANTREAD 0x000003F4 +#define ERROR_CANTWRITE 0x000003F5 +#define ERROR_REGISTRY_RECOVERED 0x000003F6 +#define ERROR_REGISTRY_CORRUPT 0x000003F7 +#define ERROR_REGISTRY_IO_FAILED 0x000003F8 +#define ERROR_NOT_REGISTRY_FILE 0x000003F9 +#define ERROR_KEY_DELETED 0x000003FA +#define ERROR_NO_LOG_SPACE 0x000003FB +#define ERROR_KEY_HAS_CHILDREN 0x000003FC +#define ERROR_CHILD_MUST_BE_VOLATILE 0x000003FD +#define ERROR_NOTIFY_ENUM_DIR 0x000003FE +#define ERROR_DEPENDENT_SERVICES_RUNNING 0x0000041B +#define ERROR_INVALID_SERVICE_CONTROL 0x0000041C +#define ERROR_SERVICE_REQUEST_TIMEOUT 0x0000041D +#define ERROR_SERVICE_NO_THREAD 0x0000041E +#define ERROR_SERVICE_DATABASE_LOCKED 0x0000041F +#define ERROR_SERVICE_ALREADY_RUNNING 0x00000420 +#define ERROR_INVALID_SERVICE_ACCOUNT 0x00000421 +#define ERROR_SERVICE_DISABLED 0x00000422 +#define ERROR_CIRCULAR_DEPENDENCY 0x00000423 +#define ERROR_SERVICE_DOES_NOT_EXIST 0x00000424 +#define ERROR_SERVICE_CANNOT_ACCEPT_CTRL 0x00000425 +#define ERROR_SERVICE_NOT_ACTIVE 0x00000426 +#define ERROR_FAILED_SERVICE_CONTROLLER_CONNECT 0x00000427 +#define ERROR_EXCEPTION_IN_SERVICE 0x00000428 +#define ERROR_DATABASE_DOES_NOT_EXIST 0x00000429 +#define ERROR_SERVICE_SPECIFIC_ERROR 0x0000042A +#define ERROR_PROCESS_ABORTED 0x0000042B +#define ERROR_SERVICE_DEPENDENCY_FAIL 0x0000042C +#define ERROR_SERVICE_LOGON_FAILED 0x0000042D +#define ERROR_SERVICE_START_HANG 0x0000042E +#define ERROR_INVALID_SERVICE_LOCK 0x0000042F +#define ERROR_SERVICE_MARKED_FOR_DELETE 0x00000430 +#define ERROR_SERVICE_EXISTS 0x00000431 +#define ERROR_ALREADY_RUNNING_LKG 0x00000432 +#define ERROR_SERVICE_DEPENDENCY_DELETED 0x00000433 +#define ERROR_BOOT_ALREADY_ACCEPTED 0x00000434 +#define ERROR_SERVICE_NEVER_STARTED 0x00000435 +#define ERROR_DUPLICATE_SERVICE_NAME 0x00000436 +#define ERROR_DIFFERENT_SERVICE_ACCOUNT 0x00000437 +#define ERROR_CANNOT_DETECT_DRIVER_FAILURE 0x00000438 +#define ERROR_CANNOT_DETECT_PROCESS_ABORT 0x00000439 +#define ERROR_NO_RECOVERY_PROGRAM 0x0000043A +#define ERROR_SERVICE_NOT_IN_EXE 0x0000043B +#define ERROR_NOT_SAFEBOOT_SERVICE 0x0000043C +#define ERROR_END_OF_MEDIA 0x0000044C +#define ERROR_FILEMARK_DETECTED 0x0000044D +#define ERROR_BEGINNING_OF_MEDIA 0x0000044E +#define ERROR_SETMARK_DETECTED 0x0000044F +#define ERROR_NO_DATA_DETECTED 0x00000450 +#define ERROR_PARTITION_FAILURE 0x00000451 +#define ERROR_INVALID_BLOCK_LENGTH 0x00000452 +#define ERROR_DEVICE_NOT_PARTITIONED 0x00000453 +#define ERROR_UNABLE_TO_LOCK_MEDIA 0x00000454 +#define ERROR_UNABLE_TO_UNLOAD_MEDIA 0x00000455 +#define ERROR_MEDIA_CHANGED 0x00000456 +#define ERROR_BUS_RESET 0x00000457 +#define ERROR_NO_MEDIA_IN_DRIVE 0x00000458 +#define ERROR_NO_UNICODE_TRANSLATION 0x00000459 +#define ERROR_DLL_INIT_FAILED 0x0000045A +#define ERROR_SHUTDOWN_IN_PROGRESS 0x0000045B +#define ERROR_NO_SHUTDOWN_IN_PROGRESS 0x0000045C +#define ERROR_IO_DEVICE 0x0000045D +#define ERROR_SERIAL_NO_DEVICE 0x0000045E +#define ERROR_IRQ_BUSY 0x0000045F +#define ERROR_MORE_WRITES 0x00000460 +#define ERROR_COUNTER_TIMEOUT 0x00000461 +#define ERROR_FLOPPY_ID_MARK_NOT_FOUND 0x00000462 +#define ERROR_FLOPPY_WRONG_CYLINDER 0x00000463 +#define ERROR_FLOPPY_UNKNOWN_ERROR 0x00000464 +#define ERROR_FLOPPY_BAD_REGISTERS 0x00000465 +#define ERROR_DISK_RECALIBRATE_FAILED 0x00000466 +#define ERROR_DISK_OPERATION_FAILED 0x00000467 +#define ERROR_DISK_RESET_FAILED 0x00000468 +#define ERROR_EOM_OVERFLOW 0x00000469 +#define ERROR_NOT_ENOUGH_SERVER_MEMORY 0x0000046A +#define ERROR_POSSIBLE_DEADLOCK 0x0000046B +#define ERROR_MAPPED_ALIGNMENT 0x0000046C +#define ERROR_SET_POWER_STATE_VETOED 0x00000474 +#define ERROR_SET_POWER_STATE_FAILED 0x00000475 +#define ERROR_TOO_MANY_LINKS 0x00000476 +#define ERROR_OLD_WIN_VERSION 0x0000047E +#define ERROR_APP_WRONG_OS 0x0000047F +#define ERROR_SINGLE_INSTANCE_APP 0x00000480 +#define ERROR_RMODE_APP 0x00000481 +#define ERROR_INVALID_DLL 0x00000482 +#define ERROR_NO_ASSOCIATION 0x00000483 +#define ERROR_DDE_FAIL 0x00000484 +#define ERROR_DLL_NOT_FOUND 0x00000485 +#define ERROR_NO_MORE_USER_HANDLES 0x00000486 +#define ERROR_MESSAGE_SYNC_ONLY 0x00000487 +#define ERROR_SOURCE_ELEMENT_EMPTY 0x00000488 +#define ERROR_DESTINATION_ELEMENT_FULL 0x00000489 +#define ERROR_ILLEGAL_ELEMENT_ADDRESS 0x0000048A +#define ERROR_MAGAZINE_NOT_PRESENT 0x0000048B +#define ERROR_DEVICE_REINITIALIZATION_NEEDED 0x0000048C +#define ERROR_DEVICE_REQUIRES_CLEANING 0x0000048D +#define ERROR_DEVICE_DOOR_OPEN 0x0000048E +#define ERROR_DEVICE_NOT_CONNECTED 0x0000048F +#define ERROR_NOT_FOUND 0x00000490 +#define ERROR_NO_MATCH 0x00000491 +#define ERROR_SET_NOT_FOUND 0x00000492 +#define ERROR_POINT_NOT_FOUND 0x00000493 +#define ERROR_NO_TRACKING_SERVICE 0x00000494 +#define ERROR_NO_VOLUME_ID 0x00000495 +#define ERROR_UNABLE_TO_REMOVE_REPLACED 0x00000497 +#define ERROR_UNABLE_TO_MOVE_REPLACEMENT 0x00000498 +#define ERROR_UNABLE_TO_MOVE_REPLACEMENT_2 0x00000499 +#define ERROR_JOURNAL_DELETE_IN_PROGRESS 0x0000049A +#define ERROR_JOURNAL_NOT_ACTIVE 0x0000049B +#define ERROR_POTENTIAL_FILE_FOUND 0x0000049C +#define ERROR_JOURNAL_ENTRY_DELETED 0x0000049D +#define ERROR_SHUTDOWN_IS_SCHEDULED 0x000004A6 +#define ERROR_SHUTDOWN_USERS_LOGGED_ON 0x000004A7 +#define ERROR_BAD_DEVICE 0x000004B0 +#define ERROR_CONNECTION_UNAVAIL 0x000004B1 +#define ERROR_DEVICE_ALREADY_REMEMBERED 0x000004B2 +#define ERROR_NO_NET_OR_BAD_PATH 0x000004B3 +#define ERROR_BAD_PROVIDER 0x000004B4 +#define ERROR_CANNOT_OPEN_PROFILE 0x000004B5 +#define ERROR_BAD_PROFILE 0x000004B6 +#define ERROR_NOT_CONTAINER 0x000004B7 +#define ERROR_EXTENDED_ERROR 0x000004B8 +#define ERROR_INVALID_GROUPNAME 0x000004B9 +#define ERROR_INVALID_COMPUTERNAME 0x000004BA +#define ERROR_INVALID_EVENTNAME 0x000004BB +#define ERROR_INVALID_DOMAINNAME 0x000004BC +#define ERROR_INVALID_SERVICENAME 0x000004BD +#define ERROR_INVALID_NETNAME 0x000004BE +#define ERROR_INVALID_SHARENAME 0x000004BF +#define ERROR_INVALID_PASSWORDNAME 0x000004C0 +#define ERROR_INVALID_MESSAGENAME 0x000004C1 +#define ERROR_INVALID_MESSAGEDEST 0x000004C2 +#define ERROR_SESSION_CREDENTIAL_CONFLICT 0x000004C3 +#define ERROR_REMOTE_SESSION_LIMIT_EXCEEDED 0x000004C4 +#define ERROR_DUP_DOMAINNAME 0x000004C5 +#define ERROR_NO_NETWORK 0x000004C6 +#define ERROR_CANCELLED 0x000004C7 +#define ERROR_USER_MAPPED_FILE 0x000004C8 +#define ERROR_CONNECTION_REFUSED 0x000004C9 +#define ERROR_GRACEFUL_DISCONNECT 0x000004CA +#define ERROR_ADDRESS_ALREADY_ASSOCIATED 0x000004CB +#define ERROR_ADDRESS_NOT_ASSOCIATED 0x000004CC +#define ERROR_CONNECTION_INVALID 0x000004CD +#define ERROR_CONNECTION_ACTIVE 0x000004CE +#define ERROR_NETWORK_UNREACHABLE 0x000004CF +#define ERROR_HOST_UNREACHABLE 0x000004D0 +#define ERROR_PROTOCOL_UNREACHABLE 0x000004D1 +#define ERROR_PORT_UNREACHABLE 0x000004D2 +#define ERROR_REQUEST_ABORTED 0x000004D3 +#define ERROR_CONNECTION_ABORTED 0x000004D4 +#define ERROR_RETRY 0x000004D5 +#define ERROR_CONNECTION_COUNT_LIMIT 0x000004D6 +#define ERROR_LOGIN_TIME_RESTRICTION 0x000004D7 +#define ERROR_LOGIN_WKSTA_RESTRICTION 0x000004D8 +#define ERROR_INCORRECT_ADDRESS 0x000004D9 +#define ERROR_ALREADY_REGISTERED 0x000004DA +#define ERROR_SERVICE_NOT_FOUND 0x000004DB +#define ERROR_NOT_AUTHENTICATED 0x000004DC +#define ERROR_NOT_LOGGED_ON 0x000004DD +#define ERROR_CONTINUE 0x000004DE +#define ERROR_ALREADY_INITIALIZED 0x000004DF +#define ERROR_NO_MORE_DEVICES 0x000004E0 +#define ERROR_NO_SUCH_SITE 0x000004E1 +#define ERROR_DOMAIN_CONTROLLER_EXISTS 0x000004E2 +#define ERROR_ONLY_IF_CONNECTED 0x000004E3 +#define ERROR_OVERRIDE_NOCHANGES 0x000004E4 +#define ERROR_BAD_USER_PROFILE 0x000004E5 +#define ERROR_NOT_SUPPORTED_ON_SBS 0x000004E6 +#define ERROR_SERVER_SHUTDOWN_IN_PROGRESS 0x000004E7 +#define ERROR_HOST_DOWN 0x000004E8 +#define ERROR_NON_ACCOUNT_SID 0x000004E9 +#define ERROR_NON_DOMAIN_SID 0x000004EA +#define ERROR_APPHELP_BLOCK 0x000004EB +#define ERROR_ACCESS_DISABLED_BY_POLICY 0x000004EC +#define ERROR_REG_NAT_CONSUMPTION 0x000004ED +#define ERROR_CSCSHARE_OFFLINE 0x000004EE +#define ERROR_PKINIT_FAILURE 0x000004EF +#define ERROR_SMARTCARD_SUBSYSTEM_FAILURE 0x000004F0 +#define ERROR_DOWNGRADE_DETECTED 0x000004F1 +#define ERROR_MACHINE_LOCKED 0x000004F7 +#define ERROR_CALLBACK_SUPPLIED_INVALID_DATA 0x000004F9 +#define ERROR_SYNC_FOREGROUND_REFRESH_REQUIRED 0x000004FA +#define ERROR_DRIVER_BLOCKED 0x000004FB +#define ERROR_INVALID_IMPORT_OF_NON_DLL 0x000004FC +#define ERROR_ACCESS_DISABLED_WEBBLADE 0x000004FD +#define ERROR_ACCESS_DISABLED_WEBBLADE_TAMPER 0x000004FE +#define ERROR_RECOVERY_FAILURE 0x000004FF +#define ERROR_ALREADY_FIBER 0x00000500 +#define ERROR_ALREADY_THREAD 0x00000501 +#define ERROR_STACK_BUFFER_OVERRUN 0x00000502 +#define ERROR_PARAMETER_QUOTA_EXCEEDED 0x00000503 +#define ERROR_DEBUGGER_INACTIVE 0x00000504 +#define ERROR_DELAY_LOAD_FAILED 0x00000505 +#define ERROR_VDM_DISALLOWED 0x00000506 +#define ERROR_UNIDENTIFIED_ERROR 0x00000507 +#define ERROR_INVALID_CRUNTIME_PARAMETER 0x00000508 +#define ERROR_BEYOND_VDL 0x00000509 +#define ERROR_INCOMPATIBLE_SERVICE_SID_TYPE 0x0000050A +#define ERROR_DRIVER_PROCESS_TERMINATED 0x0000050B +#define ERROR_IMPLEMENTATION_LIMIT 0x0000050C +#define ERROR_PROCESS_IS_PROTECTED 0x0000050D +#define ERROR_SERVICE_NOTIFY_CLIENT_LAGGING 0x0000050E +#define ERROR_DISK_QUOTA_EXCEEDED 0x0000050F +#define ERROR_CONTENT_BLOCKED 0x00000510 +#define ERROR_INCOMPATIBLE_SERVICE_PRIVILEGE 0x00000511 +#define ERROR_APP_HANG 0x00000512 +#define ERROR_INVALID_LABEL 0x00000513 + +/* System Error Codes (1300-1699) */ +#define ERROR_NOT_ALL_ASSIGNED 0x00000514 +#define ERROR_SOME_NOT_MAPPED 0x00000515 +#define ERROR_NO_QUOTAS_FOR_ACCOUNT 0x00000516 +#define ERROR_LOCAL_USER_SESSION_KEY 0x00000517 +#define ERROR_NULL_LM_PASSWORD 0x00000518 +#define ERROR_UNKNOWN_REVISION 0x00000519 +#define ERROR_REVISION_MISMATCH 0x0000051A +#define ERROR_INVALID_OWNER 0x0000051B +#define ERROR_INVALID_PRIMARY_GROUP 0x0000051C +#define ERROR_NO_IMPERSONATION_TOKEN 0x0000051D +#define ERROR_CANT_DISABLE_MANDATORY 0x0000051E +#define ERROR_NO_LOGON_SERVERS 0x0000051F +#define ERROR_NO_SUCH_LOGON_SESSION 0x00000520 +#define ERROR_NO_SUCH_PRIVILEGE 0x00000521 +#define ERROR_PRIVILEGE_NOT_HELD 0x00000522 +#define ERROR_INVALID_ACCOUNT_NAME 0x00000523 +#define ERROR_USER_EXISTS 0x00000524 +#define ERROR_NO_SUCH_USER 0x00000525 +#define ERROR_GROUP_EXISTS 0x00000526 +#define ERROR_NO_SUCH_GROUP 0x00000527 +#define ERROR_MEMBER_IN_GROUP 0x00000528 +#define ERROR_MEMBER_NOT_IN_GROUP 0x00000529 +#define ERROR_LAST_ADMIN 0x0000052A +#define ERROR_WRONG_PASSWORD 0x0000052B +#define ERROR_ILL_FORMED_PASSWORD 0x0000052C +#define ERROR_PASSWORD_RESTRICTION 0x0000052D +#define ERROR_LOGON_FAILURE 0x0000052E +#define ERROR_ACCOUNT_RESTRICTION 0x0000052F +#define ERROR_INVALID_LOGON_HOURS 0x00000530 +#define ERROR_INVALID_WORKSTATION 0x00000531 +#define ERROR_PASSWORD_EXPIRED 0x00000532 +#define ERROR_ACCOUNT_DISABLED 0x00000533 +#define ERROR_NONE_MAPPED 0x00000534 +#define ERROR_TOO_MANY_LUIDS_REQUESTED 0x00000535 +#define ERROR_LUIDS_EXHAUSTED 0x00000536 +#define ERROR_INVALID_SUB_AUTHORITY 0x00000537 +#define ERROR_INVALID_ACL 0x00000538 +#define ERROR_INVALID_SID 0x00000539 +#define ERROR_INVALID_SECURITY_DESCR 0x0000053A +#define ERROR_BAD_INHERITANCE_ACL 0x0000053C +#define ERROR_SERVER_DISABLED 0x0000053D +#define ERROR_SERVER_NOT_DISABLED 0x0000053E +#define ERROR_INVALID_ID_AUTHORITY 0x0000053F +#define ERROR_ALLOTTED_SPACE_EXCEEDED 0x00000540 +#define ERROR_INVALID_GROUP_ATTRIBUTES 0x00000541 +#define ERROR_BAD_IMPERSONATION_LEVEL 0x00000542 +#define ERROR_CANT_OPEN_ANONYMOUS 0x00000543 +#define ERROR_BAD_VALIDATION_CLASS 0x00000544 +#define ERROR_BAD_TOKEN_TYPE 0x00000545 +#define ERROR_NO_SECURITY_ON_OBJECT 0x00000546 +#define ERROR_CANT_ACCESS_DOMAIN_INFO 0x00000547 +#define ERROR_INVALID_SERVER_STATE 0x00000548 +#define ERROR_INVALID_DOMAIN_STATE 0x00000549 +#define ERROR_INVALID_DOMAIN_ROLE 0x0000054A +#define ERROR_NO_SUCH_DOMAIN 0x0000054B +#define ERROR_DOMAIN_EXISTS 0x0000054C +#define ERROR_DOMAIN_LIMIT_EXCEEDED 0x0000054D +#define ERROR_INTERNAL_DB_CORRUPTION 0x0000054E +#define ERROR_INTERNAL_ERROR 0x0000054F +#define ERROR_GENERIC_NOT_MAPPED 0x00000550 +#define ERROR_BAD_DESCRIPTOR_FORMAT 0x00000551 +#define ERROR_NOT_LOGON_PROCESS 0x00000552 +#define ERROR_LOGON_SESSION_EXISTS 0x00000553 +#define ERROR_NO_SUCH_PACKAGE 0x00000554 +#define ERROR_BAD_LOGON_SESSION_STATE 0x00000555 +#define ERROR_LOGON_SESSION_COLLISION 0x00000556 +#define ERROR_INVALID_LOGON_TYPE 0x00000557 +#define ERROR_CANNOT_IMPERSONATE 0x00000558 +#define ERROR_RXACT_INVALID_STATE 0x00000559 +#define ERROR_RXACT_COMMIT_FAILURE 0x0000055A +#define ERROR_SPECIAL_ACCOUNT 0x0000055B +#define ERROR_SPECIAL_GROUP 0x0000055C +#define ERROR_SPECIAL_USER 0x0000055D +#define ERROR_MEMBERS_PRIMARY_GROUP 0x0000055E +#define ERROR_TOKEN_ALREADY_IN_USE 0x0000055F +#define ERROR_NO_SUCH_ALIAS 0x00000560 +#define ERROR_MEMBER_NOT_IN_ALIAS 0x00000561 +#define ERROR_MEMBER_IN_ALIAS 0x00000562 +#define ERROR_ALIAS_EXISTS 0x00000563 +#define ERROR_LOGON_NOT_GRANTED 0x00000564 +#define ERROR_TOO_MANY_SECRETS 0x00000565 +#define ERROR_SECRET_TOO_LONG 0x00000566 +#define ERROR_INTERNAL_DB_ERROR 0x00000567 +#define ERROR_TOO_MANY_CONTEXT_IDS 0x00000568 +#define ERROR_LOGON_TYPE_NOT_GRANTED 0x00000569 +#define ERROR_NT_CROSS_ENCRYPTION_REQUIRED 0x0000056A +#define ERROR_NO_SUCH_MEMBER 0x0000056B +#define ERROR_INVALID_MEMBER 0x0000056C +#define ERROR_TOO_MANY_SIDS 0x0000056D +#define ERROR_LM_CROSS_ENCRYPTION_REQUIRED 0x0000056E +#define ERROR_NO_INHERITANCE 0x0000056F +#define ERROR_FILE_CORRUPT 0x00000570 +#define ERROR_DISK_CORRUPT 0x00000571 +#define ERROR_NO_USER_SESSION_KEY 0x00000572 +#define ERROR_LICENSE_QUOTA_EXCEEDED 0x00000573 +#define ERROR_WRONG_TARGET_NAME 0x00000574 +#define ERROR_MUTUAL_AUTH_FAILED 0x00000575 +#define ERROR_TIME_SKEW 0x00000576 +#define ERROR_CURRENT_DOMAIN_NOT_ALLOWED 0x00000577 +#define ERROR_INVALID_WINDOW_HANDLE 0x00000578 +#define ERROR_INVALID_MENU_HANDLE 0x00000579 +#define ERROR_INVALID_CURSOR_HANDLE 0x0000057A +#define ERROR_INVALID_ACCEL_HANDLE 0x0000057B +#define ERROR_INVALID_HOOK_HANDLE 0x0000057C +#define ERROR_INVALID_DWP_HANDLE 0x0000057D +#define ERROR_TLW_WITH_WSCHILD 0x0000057E +#define ERROR_CANNOT_FIND_WND_CLASS 0x0000057F +#define ERROR_WINDOW_OF_OTHER_THREAD 0x00000580 +#define ERROR_HOTKEY_ALREADY_REGISTERED 0x00000581 +#define ERROR_CLASS_ALREADY_EXISTS 0x00000582 +#define ERROR_CLASS_DOES_NOT_EXIST 0x00000583 +#define ERROR_CLASS_HAS_WINDOWS 0x00000584 +#define ERROR_INVALID_INDEX 0x00000585 +#define ERROR_INVALID_ICON_HANDLE 0x00000586 +#define ERROR_PRIVATE_DIALOG_INDEX 0x00000587 +#define ERROR_LISTBOX_ID_NOT_FOUND 0x00000588 +#define ERROR_NO_WILDCARD_CHARACTERS 0x00000589 +#define ERROR_CLIPBOARD_NOT_OPEN 0x0000058A +#define ERROR_HOTKEY_NOT_REGISTERED 0x0000058B +#define ERROR_WINDOW_NOT_DIALOG 0x0000058C +#define ERROR_CONTROL_ID_NOT_FOUND 0x0000058D +#define ERROR_INVALID_COMBOBOX_MESSAGE 0x0000058E +#define ERROR_WINDOW_NOT_COMBOBOX 0x0000058F +#define ERROR_INVALID_EDIT_HEIGHT 0x00000590 +#define ERROR_DC_NOT_FOUND 0x00000591 +#define ERROR_INVALID_HOOK_FILTER 0x00000592 +#define ERROR_INVALID_FILTER_PROC 0x00000593 +#define ERROR_HOOK_NEEDS_HMOD 0x00000594 +#define ERROR_GLOBAL_ONLY_HOOK 0x00000595 +#define ERROR_JOURNAL_HOOK_SET 0x00000596 +#define ERROR_HOOK_NOT_INSTALLED 0x00000597 +#define ERROR_INVALID_LB_MESSAGE 0x00000598 +#define ERROR_SETCOUNT_ON_BAD_LB 0x00000599 +#define ERROR_LB_WITHOUT_TABSTOPS 0x0000059A +#define ERROR_DESTROY_OBJECT_OF_OTHER_THREAD 0x0000059B +#define ERROR_CHILD_WINDOW_MENU 0x0000059C +#define ERROR_NO_SYSTEM_MENU 0x0000059D +#define ERROR_INVALID_MSGBOX_STYLE 0x0000059E +#define ERROR_INVALID_SPI_VALUE 0x0000059F +#define ERROR_SCREEN_ALREADY_LOCKED 0x000005A0 +#define ERROR_HWNDS_HAVE_DIFF_PARENT 0x000005A1 +#define ERROR_NOT_CHILD_WINDOW 0x000005A2 +#define ERROR_INVALID_GW_COMMAND 0x000005A3 +#define ERROR_INVALID_THREAD_ID 0x000005A4 +#define ERROR_NON_MDICHILD_WINDOW 0x000005A5 +#define ERROR_POPUP_ALREADY_ACTIVE 0x000005A6 +#define ERROR_NO_SCROLLBARS 0x000005A7 +#define ERROR_INVALID_SCROLLBAR_RANGE 0x000005A8 +#define ERROR_INVALID_SHOWWIN_COMMAND 0x000005A9 +#define ERROR_NO_SYSTEM_RESOURCES 0x000005AA +#define ERROR_NONPAGED_SYSTEM_RESOURCES 0x000005AB +#define ERROR_PAGED_SYSTEM_RESOURCES 0x000005AC +#define ERROR_WORKING_SET_QUOTA 0x000005AD +#define ERROR_PAGEFILE_QUOTA 0x000005AE +#define ERROR_COMMITMENT_LIMIT 0x000005AF +#define ERROR_MENU_ITEM_NOT_FOUND 0x000005B0 +#define ERROR_INVALID_KEYBOARD_HANDLE 0x000005B1 +#define ERROR_HOOK_TYPE_NOT_ALLOWED 0x000005B2 +#define ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION 0x000005B3 +#define ERROR_TIMEOUT 0x000005B4 +#define ERROR_INVALID_MONITOR_HANDLE 0x000005B5 +#define ERROR_INCORRECT_SIZE 0x000005B6 +#define ERROR_SYMLINK_CLASS_DISABLED 0x000005B7 +#define ERROR_SYMLINK_NOT_SUPPORTED 0x000005B8 +#define ERROR_XML_PARSE_ERROR 0x000005B9 +#define ERROR_XMLDSIG_ERROR 0x000005BA +#define ERROR_RESTART_APPLICATION 0x000005BB +#define ERROR_WRONG_COMPARTMENT 0x000005BC +#define ERROR_AUTHIP_FAILURE 0x000005BD +#define ERROR_NO_NVRAM_RESOURCES 0x000005BE +#define ERROR_NOT_GUI_PROCESS 0x000005BF +#define ERROR_EVENTLOG_FILE_CORRUPT 0x000005DC +#define ERROR_EVENTLOG_CANT_START 0x000005DD +#define ERROR_LOG_FILE_FULL 0x000005DE +#define ERROR_EVENTLOG_FILE_CHANGED 0x000005DF +#define ERROR_INVALID_TASK_NAME 0x0000060E +#define ERROR_INVALID_TASK_INDEX 0x0000060F +#define ERROR_THREAD_ALREADY_IN_TASK 0x00000610 +#define ERROR_INSTALL_SERVICE_FAILURE 0x00000641 +#define ERROR_INSTALL_USEREXIT 0x00000642 +#define ERROR_INSTALL_FAILURE 0x00000643 +#define ERROR_INSTALL_SUSPEND 0x00000644 +#define ERROR_UNKNOWN_PRODUCT 0x00000645 +#define ERROR_UNKNOWN_FEATURE 0x00000646 +#define ERROR_UNKNOWN_COMPONENT 0x00000647 +#define ERROR_UNKNOWN_PROPERTY 0x00000648 +#define ERROR_INVALID_HANDLE_STATE 0x00000649 +#define ERROR_BAD_CONFIGURATION 0x0000064A +#define ERROR_INDEX_ABSENT 0x0000064B +#define ERROR_INSTALL_SOURCE_ABSENT 0x0000064C +#define ERROR_INSTALL_PACKAGE_VERSION 0x0000064D +#define ERROR_PRODUCT_UNINSTALLED 0x0000064E +#define ERROR_BAD_QUERY_SYNTAX 0x0000064F +#define ERROR_INVALID_FIELD 0x00000650 +#define ERROR_DEVICE_REMOVED 0x00000651 +#define ERROR_INSTALL_ALREADY_RUNNING 0x00000652 +#define ERROR_INSTALL_PACKAGE_OPEN_FAILED 0x00000653 +#define ERROR_INSTALL_PACKAGE_INVALID 0x00000654 +#define ERROR_INSTALL_UI_FAILURE 0x00000655 +#define ERROR_INSTALL_LOG_FAILURE 0x00000656 +#define ERROR_INSTALL_LANGUAGE_UNSUPPORTED 0x00000657 +#define ERROR_INSTALL_TRANSFORM_FAILURE 0x00000658 +#define ERROR_INSTALL_PACKAGE_REJECTED 0x00000659 +#define ERROR_FUNCTION_NOT_CALLED 0x0000065A +#define ERROR_FUNCTION_FAILED 0x0000065B +#define ERROR_INVALID_TABLE 0x0000065C +#define ERROR_DATATYPE_MISMATCH 0x0000065D +#define ERROR_UNSUPPORTED_TYPE 0x0000065E +#define ERROR_CREATE_FAILED 0x0000065F +#define ERROR_INSTALL_TEMP_UNWRITABLE 0x00000660 +#define ERROR_INSTALL_PLATFORM_UNSUPPORTED 0x00000661 +#define ERROR_INSTALL_NOTUSED 0x00000662 +#define ERROR_PATCH_PACKAGE_OPEN_FAILED 0x00000663 +#define ERROR_PATCH_PACKAGE_INVALID 0x00000664 +#define ERROR_PATCH_PACKAGE_UNSUPPORTED 0x00000665 +#define ERROR_PRODUCT_VERSION 0x00000666 +#define ERROR_INVALID_COMMAND_LINE 0x00000667 +#define ERROR_INSTALL_REMOTE_DISALLOWED 0x00000668 +#define ERROR_SUCCESS_REBOOT_INITIATED 0x00000669 +#define ERROR_PATCH_TARGET_NOT_FOUND 0x0000066A +#define ERROR_PATCH_PACKAGE_REJECTED 0x0000066B +#define ERROR_INSTALL_TRANSFORM_REJECTED 0x0000066C +#define ERROR_INSTALL_REMOTE_PROHIBITED 0x0000066D +#define ERROR_PATCH_REMOVAL_UNSUPPORTED 0x0000066E +#define ERROR_UNKNOWN_PATCH 0x0000066F +#define ERROR_PATCH_NO_SEQUENCE 0x00000670 +#define ERROR_PATCH_REMOVAL_DISALLOWED 0x00000671 +#define ERROR_INVALID_PATCH_XML 0x00000672 +#define ERROR_PATCH_MANAGED_ADVERTISED_PRODUCT 0x00000673 +#define ERROR_INSTALL_SERVICE_SAFEBOOT 0x00000674 +#define ERROR_FAIL_FAST_EXCEPTION 0x00000675 +#define ERROR_INSTALL_REJECTED 0x00000676 + +/* System Error Codes (1700-3999) */ + +#define RPC_S_INVALID_STRING_BINDING 0x000006A4 +#define RPC_S_WRONG_KIND_OF_BINDING 0x000006A5 +#define RPC_S_INVALID_BINDING 0x000006A6 +#define RPC_S_PROTSEQ_NOT_SUPPORTED 0x000006A7 +#define RPC_S_INVALID_RPC_PROTSEQ 0x000006A8 +#define RPC_S_INVALID_STRING_UUID 0x000006A9 +#define RPC_S_INVALID_ENDPOINT_FORMAT 0x000006AA +#define RPC_S_INVALID_NET_ADDR 0x000006AB +#define RPC_S_NO_ENDPOINT_FOUND 0x000006AC +#define RPC_S_INVALID_TIMEOUT 0x000006AD +#define RPC_S_OBJECT_NOT_FOUND 0x000006AE +#define RPC_S_ALREADY_REGISTERED 0x000006AF +#define RPC_S_TYPE_ALREADY_REGISTERED 0x000006B0 +#define RPC_S_ALREADY_LISTENING 0x000006B1 +#define RPC_S_NO_PROTSEQS_REGISTERED 0x000006B2 +#define RPC_S_NOT_LISTENING 0x000006B3 +#define RPC_S_UNKNOWN_MGR_TYPE 0x000006B4 +#define RPC_S_UNKNOWN_IF 0x000006B5 +#define RPC_S_NO_BINDINGS 0x000006B6 +#define RPC_S_NO_PROTSEQS 0x000006B7 +#define RPC_S_CANT_CREATE_ENDPOINT 0x000006B8 +#define RPC_S_OUT_OF_RESOURCES 0x000006B9 +#define RPC_S_SERVER_UNAVAILABLE 0x000006BA +#define RPC_S_SERVER_TOO_BUSY 0x000006BB +#define RPC_S_INVALID_NETWORK_OPTIONS 0x000006BC +#define RPC_S_NO_CALL_ACTIVE 0x000006BD +#define RPC_S_CALL_FAILED 0x000006BE +#define RPC_S_CALL_FAILED_DNE 0x000006BF +#define RPC_S_PROTOCOL_ERROR 0x000006C0 +#define RPC_S_PROXY_ACCESS_DENIED 0x000006C1 +#define RPC_S_UNSUPPORTED_TRANS_SYN 0x000006C2 +#define RPC_S_UNSUPPORTED_TYPE 0x000006C4 +#define RPC_S_INVALID_TAG 0x000006C5 +#define RPC_S_INVALID_BOUND 0x000006C6 +#define RPC_S_NO_ENTRY_NAME 0x000006C7 +#define RPC_S_INVALID_NAME_SYNTAX 0x000006C8 +#define RPC_S_UNSUPPORTED_NAME_SYNTAX 0x000006C9 +#define RPC_S_UUID_NO_ADDRESS 0x000006CB +#define RPC_S_DUPLICATE_ENDPOINT 0x000006CC +#define RPC_S_UNKNOWN_AUTHN_TYPE 0x000006CD +#define RPC_S_MAX_CALLS_TOO_SMALL 0x000006CE +#define RPC_S_STRING_TOO_LONG 0x000006CF +#define RPC_S_PROTSEQ_NOT_FOUND 0x000006D0 +#define RPC_S_PROCNUM_OUT_OF_RANGE 0x000006D1 +#define RPC_S_BINDING_HAS_NO_AUTH 0x000006D2 +#define RPC_S_UNKNOWN_AUTHN_SERVICE 0x000006D3 +#define RPC_S_UNKNOWN_AUTHN_LEVEL 0x000006D4 +#define RPC_S_INVALID_AUTH_IDENTITY 0x000006D5 +#define RPC_S_UNKNOWN_AUTHZ_SERVICE 0x000006D6 +#define EPT_S_INVALID_ENTRY 0x000006D7 +#define EPT_S_CANT_PERFORM_OP 0x000006D8 +#define EPT_S_NOT_REGISTERED 0x000006D9 +#define RPC_S_NOTHING_TO_EXPORT 0x000006DA +#define RPC_S_INCOMPLETE_NAME 0x000006DB +#define RPC_S_INVALID_VERS_OPTION 0x000006DC +#define RPC_S_NO_MORE_MEMBERS 0x000006DD +#define RPC_S_NOT_ALL_OBJS_UNEXPORTED 0x000006DE +#define RPC_S_INTERFACE_NOT_FOUND 0x000006DF +#define RPC_S_ENTRY_ALREADY_EXISTS 0x000006E0 +#define RPC_S_ENTRY_NOT_FOUND 0x000006E1 +#define RPC_S_NAME_SERVICE_UNAVAILABLE 0x000006E2 +#define RPC_S_INVALID_NAF_ID 0x000006E3 +#define RPC_S_CANNOT_SUPPORT 0x000006E4 +#define RPC_S_NO_CONTEXT_AVAILABLE 0x000006E5 +#define RPC_S_INTERNAL_ERROR 0x000006E6 +#define RPC_S_ZERO_DIVIDE 0x000006E7 +#define RPC_S_ADDRESS_ERROR 0x000006E8 +#define RPC_S_FP_DIV_ZERO 0x000006E9 +#define RPC_S_FP_UNDERFLOW 0x000006EA +#define RPC_S_FP_OVERFLOW 0x000006EB +#define RPC_X_NO_MORE_ENTRIES 0x000006EC +#define RPC_X_SS_CHAR_TRANS_OPEN_FAIL 0x000006ED +#define RPC_X_SS_CHAR_TRANS_SHORT_FILE 0x000006EE +#define RPC_X_SS_IN_NULL_CONTEXT 0x000006EF +#define RPC_X_SS_CONTEXT_DAMAGED 0x000006F1 +#define RPC_X_SS_HANDLES_MISMATCH 0x000006F2 +#define RPC_X_SS_CANNOT_GET_CALL_HANDLE 0x000006F3 +#define RPC_X_NULL_REF_POINTER 0x000006F4 +#define RPC_X_ENUM_VALUE_OUT_OF_RANGE 0x000006F5 +#define RPC_X_BYTE_COUNT_TOO_SMALL 0x000006F6 +#define RPC_X_BAD_STUB_DATA 0x000006F7 +#define ERROR_INVALID_USER_BUFFER 0x000006F8 +#define ERROR_UNRECOGNIZED_MEDIA 0x000006F9 +#define ERROR_NO_TRUST_LSA_SECRET 0x000006FA +#define ERROR_NO_TRUST_SAM_ACCOUNT 0x000006FB +#define ERROR_TRUSTED_DOMAIN_FAILURE 0x000006FC +#define ERROR_TRUSTED_RELATIONSHIP_FAILURE 0x000006FD +#define ERROR_TRUST_FAILURE 0x000006FE +#define RPC_S_CALL_IN_PROGRESS 0x000006FF +#define ERROR_NETLOGON_NOT_STARTED 0x00000700 +#define ERROR_ACCOUNT_EXPIRED 0x00000701 +#define ERROR_REDIRECTOR_HAS_OPEN_HANDLES 0x00000702 +#define ERROR_PRINTER_DRIVER_ALREADY_INSTALLED 0x00000703 +#define ERROR_UNKNOWN_PORT 0x00000704 +#define ERROR_UNKNOWN_PRINTER_DRIVER 0x00000705 +#define ERROR_UNKNOWN_PRINTPROCESSOR 0x00000706 +#define ERROR_INVALID_SEPARATOR_FILE 0x00000707 +#define ERROR_INVALID_PRIORITY 0x00000708 +#define ERROR_INVALID_PRINTER_NAME 0x00000709 +#define ERROR_PRINTER_ALREADY_EXISTS 0x0000070A +#define ERROR_INVALID_PRINTER_COMMAND 0x0000070B +#define ERROR_INVALID_DATATYPE 0x0000070C +#define ERROR_INVALID_ENVIRONMENT 0x0000070D +#define RPC_S_NO_MORE_BINDINGS 0x0000070E +#define ERROR_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT 0x0000070F +#define ERROR_NOLOGON_WORKSTATION_TRUST_ACCOUNT 0x00000710 +#define ERROR_NOLOGON_SERVER_TRUST_ACCOUNT 0x00000711 +#define ERROR_DOMAIN_TRUST_INCONSISTENT 0x00000712 +#define ERROR_SERVER_HAS_OPEN_HANDLES 0x00000713 +#define ERROR_RESOURCE_DATA_NOT_FOUND 0x00000714 +#define ERROR_RESOURCE_TYPE_NOT_FOUND 0x00000715 +#define ERROR_RESOURCE_NAME_NOT_FOUND 0x00000716 +#define ERROR_RESOURCE_LANG_NOT_FOUND 0x00000717 +#define ERROR_NOT_ENOUGH_QUOTA 0x00000718 +#define RPC_S_NO_INTERFACES 0x00000719 +#define RPC_S_CALL_CANCELLED 0x0000071A +#define RPC_S_BINDING_INCOMPLETE 0x0000071B +#define RPC_S_COMM_FAILURE 0x0000071C +#define RPC_S_UNSUPPORTED_AUTHN_LEVEL 0x0000071D +#define RPC_S_NO_PRINC_NAME 0x0000071E +#define RPC_S_NOT_RPC_ERROR 0x0000071F +#define RPC_S_UUID_LOCAL_ONLY 0x00000720 +#define RPC_S_SEC_PKG_ERROR 0x00000721 +#define RPC_S_NOT_CANCELLED 0x00000722 +#define RPC_X_INVALID_ES_ACTION 0x00000723 +#define RPC_X_WRONG_ES_VERSION 0x00000724 +#define RPC_X_WRONG_STUB_VERSION 0x00000725 +#define RPC_X_INVALID_PIPE_OBJECT 0x00000726 +#define RPC_X_WRONG_PIPE_ORDER 0x00000727 +#define RPC_X_WRONG_PIPE_VERSION 0x00000728 +#define RPC_S_COOKIE_AUTH_FAILED 0x00000729 +#define RPC_S_GROUP_MEMBER_NOT_FOUND 0x0000076A +#define EPT_S_CANT_CREATE 0x0000076B +#define RPC_S_INVALID_OBJECT 0x0000076C +#define ERROR_INVALID_TIME 0x0000076D +#define ERROR_INVALID_FORM_NAME 0x0000076E +#define ERROR_INVALID_FORM_SIZE 0x0000076F +#define ERROR_ALREADY_WAITING 0x00000770 +#define ERROR_PRINTER_DELETED 0x00000771 +#define ERROR_INVALID_PRINTER_STATE 0x00000772 +#define ERROR_PASSWORD_MUST_CHANGE 0x00000773 +#define ERROR_DOMAIN_CONTROLLER_NOT_FOUND 0x00000774 +#define ERROR_ACCOUNT_LOCKED_OUT 0x00000775 +#define OR_INVALID_OXID 0x00000776 +#define OR_INVALID_OID 0x00000777 +#define OR_INVALID_SET 0x00000778 +#define RPC_S_SEND_INCOMPLETE 0x00000779 +#define RPC_S_INVALID_ASYNC_HANDLE 0x0000077A +#define RPC_S_INVALID_ASYNC_CALL 0x0000077B +#define RPC_X_PIPE_CLOSED 0x0000077C +#define RPC_X_PIPE_DISCIPLINE_ERROR 0x0000077D +#define RPC_X_PIPE_EMPTY 0x0000077E +#define ERROR_NO_SITENAME 0x0000077F +#define ERROR_CANT_ACCESS_FILE 0x00000780 +#define ERROR_CANT_RESOLVE_FILENAME 0x00000781 +#define RPC_S_ENTRY_TYPE_MISMATCH 0x00000782 +#define RPC_S_NOT_ALL_OBJS_EXPORTED 0x00000783 +#define RPC_S_INTERFACE_NOT_EXPORTED 0x00000784 +#define RPC_S_PROFILE_NOT_ADDED 0x00000785 +#define RPC_S_PRF_ELT_NOT_ADDED 0x00000786 +#define RPC_S_PRF_ELT_NOT_REMOVED 0x00000787 +#define RPC_S_GRP_ELT_NOT_ADDED 0x00000788 +#define RPC_S_GRP_ELT_NOT_REMOVED 0x00000789 +#define ERROR_KM_DRIVER_BLOCKED 0x0000078A +#define ERROR_CONTEXT_EXPIRED 0x0000078B +#define ERROR_PER_USER_TRUST_QUOTA_EXCEEDED 0x0000078C +#define ERROR_ALL_USER_TRUST_QUOTA_EXCEEDED 0x0000078D +#define ERROR_USER_DELETE_TRUST_QUOTA_EXCEEDED 0x0000078E +#define ERROR_AUTHENTICATION_FIREWALL_FAILED 0x0000078F +#define ERROR_REMOTE_PRINT_CONNECTIONS_BLOCKED 0x00000790 +#define ERROR_NTLM_BLOCKED 0x00000791 +#define ERROR_PASSWORD_CHANGE_REQUIRED 0x00000792 +#define ERROR_INVALID_PIXEL_FORMAT 0x000007D0 +#define ERROR_BAD_DRIVER 0x000007D1 +#define ERROR_INVALID_WINDOW_STYLE 0x000007D2 +#define ERROR_METAFILE_NOT_SUPPORTED 0x000007D3 +#define ERROR_TRANSFORM_NOT_SUPPORTED 0x000007D4 +#define ERROR_CLIPPING_NOT_SUPPORTED 0x000007D5 +#define ERROR_INVALID_CMM 0x000007DA +#define ERROR_INVALID_PROFILE 0x000007DB +#define ERROR_TAG_NOT_FOUND 0x000007DC +#define ERROR_TAG_NOT_PRESENT 0x000007DD +#define ERROR_DUPLICATE_TAG 0x000007DE +#define ERROR_PROFILE_NOT_ASSOCIATED_WITH_DEVICE 0x000007DF +#define ERROR_PROFILE_NOT_FOUND 0x000007E0 +#define ERROR_INVALID_COLORSPACE 0x000007E1 +#define ERROR_ICM_NOT_ENABLED 0x000007E2 +#define ERROR_DELETING_ICM_XFORM 0x000007E3 +#define ERROR_INVALID_TRANSFORM 0x000007E4 +#define ERROR_COLORSPACE_MISMATCH 0x000007E5 +#define ERROR_INVALID_COLORINDEX 0x000007E6 +#define ERROR_PROFILE_DOES_NOT_MATCH_DEVICE 0x000007E7 +#define ERROR_CONNECTED_OTHER_PASSWORD 0x0000083C +#define ERROR_CONNECTED_OTHER_PASSWORD_DEFAULT 0x0000083D +#define ERROR_BAD_USERNAME 0x0000089A +#define ERROR_NOT_CONNECTED 0x000008CA +#define ERROR_OPEN_FILES 0x00000961 +#define ERROR_ACTIVE_CONNECTIONS 0x00000962 +#define ERROR_DEVICE_IN_USE 0x00000964 +#define ERROR_UNKNOWN_PRINT_MONITOR 0x00000BB8 +#define ERROR_PRINTER_DRIVER_IN_USE 0x00000BB9 +#define ERROR_SPOOL_FILE_NOT_FOUND 0x00000BBA +#define ERROR_SPL_NO_STARTDOC 0x00000BBB +#define ERROR_SPL_NO_ADDJOB 0x00000BBC +#define ERROR_PRINT_PROCESSOR_ALREADY_INSTALLED 0x00000BBD +#define ERROR_PRINT_MONITOR_ALREADY_INSTALLED 0x00000BBE +#define ERROR_INVALID_PRINT_MONITOR 0x00000BBF +#define ERROR_PRINT_MONITOR_IN_USE 0x00000BC0 +#define ERROR_PRINTER_HAS_JOBS_QUEUED 0x00000BC1 +#define ERROR_SUCCESS_REBOOT_REQUIRED 0x00000BC2 +#define ERROR_SUCCESS_RESTART_REQUIRED 0x00000BC3 +#define ERROR_PRINTER_NOT_FOUND 0x00000BC4 +#define ERROR_PRINTER_DRIVER_WARNED 0x00000BC5 +#define ERROR_PRINTER_DRIVER_BLOCKED 0x00000BC6 +#define ERROR_PRINTER_DRIVER_PACKAGE_IN_USE 0x00000BC7 +#define ERROR_CORE_DRIVER_PACKAGE_NOT_FOUND 0x00000BC8 +#define ERROR_FAIL_REBOOT_REQUIRED 0x00000BC9 +#define ERROR_FAIL_REBOOT_INITIATED 0x00000BCA +#define ERROR_PRINTER_DRIVER_DOWNLOAD_NEEDED 0x00000BCB +#define ERROR_PRINT_JOB_RESTART_REQUIRED 0x00000BCC +#define ERROR_INVALID_PRINTER_DRIVER_MANIFEST 0x00000BCD +#define ERROR_PRINTER_NOT_SHAREABLE 0x00000BCE +#define ERROR_REQUEST_PAUSED 0x00000BEA +#define ERROR_IO_REISSUE_AS_CACHED 0x00000F6E + +/* System Error Codes (4000-5999) */ + +#define ERROR_WINS_INTERNAL 0x00000FA0 +#define ERROR_CAN_NOT_DEL_LOCAL_WINS 0x00000FA1 +#define ERROR_STATIC_INIT 0x00000FA2 +#define ERROR_INC_BACKUP 0x00000FA3 +#define ERROR_FULL_BACKUP 0x00000FA4 +#define ERROR_REC_NON_EXISTENT 0x00000FA5 +#define ERROR_RPL_NOT_ALLOWED 0x00000FA6 +#define PEERDIST_ERROR_CONTENTINFO_VERSION_UNSUPPORTED 0x00000FD2 +#define PEERDIST_ERROR_CANNOT_PARSE_CONTENTINFO 0x00000FD3 +#define PEERDIST_ERROR_MISSING_DATA 0x00000FD4 +#define PEERDIST_ERROR_NO_MORE 0x00000FD5 +#define PEERDIST_ERROR_NOT_INITIALIZED 0x00000FD6 +#define PEERDIST_ERROR_ALREADY_INITIALIZED 0x00000FD7 +#define PEERDIST_ERROR_SHUTDOWN_IN_PROGRESS 0x00000FD8 +#define PEERDIST_ERROR_INVALIDATED 0x00000FD9 +#define PEERDIST_ERROR_ALREADY_EXISTS 0x00000FDA +#define PEERDIST_ERROR_OPERATION_NOTFOUND 0x00000FDB +#define PEERDIST_ERROR_ALREADY_COMPLETED 0x00000FDC +#define PEERDIST_ERROR_OUT_OF_BOUNDS 0x00000FDD +#define PEERDIST_ERROR_VERSION_UNSUPPORTED 0x00000FDE +#define PEERDIST_ERROR_INVALID_CONFIGURATION 0x00000FDF +#define PEERDIST_ERROR_NOT_LICENSED 0x00000FE0 +#define PEERDIST_ERROR_SERVICE_UNAVAILABLE 0x00000FE1 +#define PEERDIST_ERROR_TRUST_FAILURE 0x00000FE2 +#define ERROR_DHCP_ADDRESS_CONFLICT 0x00001004 +#define ERROR_WMI_GUID_NOT_FOUND 0x00001068 +#define ERROR_WMI_INSTANCE_NOT_FOUND 0x00001069 +#define ERROR_WMI_ITEMID_NOT_FOUND 0x0000106A +#define ERROR_WMI_TRY_AGAIN 0x0000106B +#define ERROR_WMI_DP_NOT_FOUND 0x0000106C +#define ERROR_WMI_UNRESOLVED_INSTANCE_REF 0x0000106D +#define ERROR_WMI_ALREADY_ENABLED 0x0000106E +#define ERROR_WMI_GUID_DISCONNECTED 0x0000106F +#define ERROR_WMI_SERVER_UNAVAILABLE 0x00001070 +#define ERROR_WMI_DP_FAILED 0x00001071 +#define ERROR_WMI_INVALID_MOF 0x00001072 +#define ERROR_WMI_INVALID_REGINFO 0x00001073 +#define ERROR_WMI_ALREADY_DISABLED 0x00001074 +#define ERROR_WMI_READ_ONLY 0x00001075 +#define ERROR_WMI_SET_FAILURE 0x00001076 +#define ERROR_NOT_APPCONTAINER 0x0000109A +#define ERROR_APPCONTAINER_REQUIRED 0x0000109B +#define ERROR_NOT_SUPPORTED_IN_APPCONTAINER 0x0000109C +#define ERROR_INVALID_PACKAGE_SID_LENGTH 0x0000109D +#define ERROR_INVALID_MEDIA 0x000010CC +#define ERROR_INVALID_LIBRARY 0x000010CD +#define ERROR_INVALID_MEDIA_POOL 0x000010CE +#define ERROR_DRIVE_MEDIA_MISMATCH 0x000010CF +#define ERROR_MEDIA_OFFLINE 0x000010D0 +#define ERROR_LIBRARY_OFFLINE 0x000010D1 +#define ERROR_EMPTY 0x000010D2 +#define ERROR_NOT_EMPTY 0x000010D3 +#define ERROR_MEDIA_UNAVAILABLE 0x000010D4 +#define ERROR_RESOURCE_DISABLED 0x000010D5 +#define ERROR_INVALID_CLEANER 0x000010D6 +#define ERROR_UNABLE_TO_CLEAN 0x000010D7 +#define ERROR_OBJECT_NOT_FOUND 0x000010D8 +#define ERROR_DATABASE_FAILURE 0x000010D9 +#define ERROR_DATABASE_FULL 0x000010DA +#define ERROR_MEDIA_INCOMPATIBLE 0x000010DB +#define ERROR_RESOURCE_NOT_PRESENT 0x000010DC +#define ERROR_INVALID_OPERATION 0x000010DD +#define ERROR_MEDIA_NOT_AVAILABLE 0x000010DE +#define ERROR_DEVICE_NOT_AVAILABLE 0x000010DF +#define ERROR_REQUEST_REFUSED 0x000010E0 +#define ERROR_INVALID_DRIVE_OBJECT 0x000010E1 +#define ERROR_LIBRARY_FULL 0x000010E2 +#define ERROR_MEDIUM_NOT_ACCESSIBLE 0x000010E3 +#define ERROR_UNABLE_TO_LOAD_MEDIUM 0x000010E4 +#define ERROR_UNABLE_TO_INVENTORY_DRIVE 0x000010E5 +#define ERROR_UNABLE_TO_INVENTORY_SLOT 0x000010E6 +#define ERROR_UNABLE_TO_INVENTORY_TRANSPORT 0x000010E7 +#define ERROR_TRANSPORT_FULL 0x000010E8 +#define ERROR_CONTROLLING_IEPORT 0x000010E9 +#define ERROR_UNABLE_TO_EJECT_MOUNTED_MEDIA 0x000010EA +#define ERROR_CLEANER_SLOT_SET 0x000010EB +#define ERROR_CLEANER_SLOT_NOT_SET 0x000010EC +#define ERROR_CLEANER_CARTRIDGE_SPENT 0x000010ED +#define ERROR_UNEXPECTED_OMID 0x000010EE +#define ERROR_CANT_DELETE_LAST_ITEM 0x000010EF +#define ERROR_MESSAGE_EXCEEDS_MAX_SIZE 0x000010F0 +#define ERROR_VOLUME_CONTAINS_SYS_FILES 0x000010F1 +#define ERROR_INDIGENOUS_TYPE 0x000010F2 +#define ERROR_NO_SUPPORTING_DRIVES 0x000010F3 +#define ERROR_CLEANER_CARTRIDGE_INSTALLED 0x000010F4 +#define ERROR_IEPORT_FULL 0x000010F5 +#define ERROR_FILE_OFFLINE 0x000010FE +#define ERROR_REMOTE_STORAGE_NOT_ACTIVE 0x000010FF +#define ERROR_REMOTE_STORAGE_MEDIA_ERROR 0x00001100 +#define ERROR_NOT_A_REPARSE_POINT 0x00001126 +#define ERROR_REPARSE_ATTRIBUTE_CONFLICT 0x00001127 +#define ERROR_INVALID_REPARSE_DATA 0x00001128 +#define ERROR_REPARSE_TAG_INVALID 0x00001129 +#define ERROR_REPARSE_TAG_MISMATCH 0x0000112A +#define ERROR_APP_DATA_NOT_FOUND 0x00001130 +#define ERROR_APP_DATA_EXPIRED 0x00001131 +#define ERROR_APP_DATA_CORRUPT 0x00001132 +#define ERROR_APP_DATA_LIMIT_EXCEEDED 0x00001133 +#define ERROR_APP_DATA_REBOOT_REQUIRED 0x00001134 +#define ERROR_SECUREBOOT_ROLLBACK_DETECTED 0x00001144 +#define ERROR_SECUREBOOT_POLICY_VIOLATION 0x00001145 +#define ERROR_SECUREBOOT_INVALID_POLICY 0x00001146 +#define ERROR_SECUREBOOT_POLICY_PUBLISHER_NOT_FOUND 0x00001147 +#define ERROR_SECUREBOOT_POLICY_NOT_SIGNED 0x00001148 +#define ERROR_SECUREBOOT_NOT_ENABLED 0x00001149 +#define ERROR_SECUREBOOT_FILE_REPLACED 0x0000114A +#define ERROR_OFFLOAD_READ_FLT_NOT_SUPPORTED 0x00001158 +#define ERROR_OFFLOAD_WRITE_FLT_NOT_SUPPORTED 0x00001159 +#define ERROR_OFFLOAD_READ_FILE_NOT_SUPPORTED 0x0000115A +#define ERROR_OFFLOAD_WRITE_FILE_NOT_SUPPORTED 0x0000115B +#define ERROR_VOLUME_NOT_SIS_ENABLED 0x00001194 +#define ERROR_DEPENDENT_RESOURCE_EXISTS 0x00001389 +#define ERROR_DEPENDENCY_NOT_FOUND 0x0000138A +#define ERROR_DEPENDENCY_ALREADY_EXISTS 0x0000138B +#define ERROR_RESOURCE_NOT_ONLINE 0x0000138C +#define ERROR_HOST_NODE_NOT_AVAILABLE 0x0000138D +#define ERROR_RESOURCE_NOT_AVAILABLE 0x0000138E +#define ERROR_RESOURCE_NOT_FOUND 0x0000138F +#define ERROR_SHUTDOWN_CLUSTER 0x00001390 +#define ERROR_CANT_EVICT_ACTIVE_NODE 0x00001391 +#define ERROR_OBJECT_ALREADY_EXISTS 0x00001392 +#define ERROR_OBJECT_IN_LIST 0x00001393 +#define ERROR_GROUP_NOT_AVAILABLE 0x00001394 +#define ERROR_GROUP_NOT_FOUND 0x00001395 +#define ERROR_GROUP_NOT_ONLINE 0x00001396 +#define ERROR_HOST_NODE_NOT_RESOURCE_OWNER 0x00001397 +#define ERROR_HOST_NODE_NOT_GROUP_OWNER 0x00001398 +#define ERROR_RESMON_CREATE_FAILED 0x00001399 +#define ERROR_RESMON_ONLINE_FAILED 0x0000139A +#define ERROR_RESOURCE_ONLINE 0x0000139B +#define ERROR_QUORUM_RESOURCE 0x0000139C +#define ERROR_NOT_QUORUM_CAPABLE 0x0000139D +#define ERROR_CLUSTER_SHUTTING_DOWN 0x0000139E +#define ERROR_INVALID_STATE 0x0000139F +#define ERROR_RESOURCE_PROPERTIES_STORED 0x000013A0 +#define ERROR_NOT_QUORUM_CLASS 0x000013A1 +#define ERROR_CORE_RESOURCE 0x000013A2 +#define ERROR_QUORUM_RESOURCE_ONLINE_FAILED 0x000013A3 +#define ERROR_QUORUMLOG_OPEN_FAILED 0x000013A4 +#define ERROR_CLUSTERLOG_CORRUPT 0x000013A5 +#define ERROR_CLUSTERLOG_RECORD_EXCEEDS_MAXSIZE 0x000013A6 +#define ERROR_CLUSTERLOG_EXCEEDS_MAXSIZE 0x000013A7 +#define ERROR_CLUSTERLOG_CHKPOINT_NOT_FOUND 0x000013A8 +#define ERROR_CLUSTERLOG_NOT_ENOUGH_SPACE 0x000013A9 +#define ERROR_QUORUM_OWNER_ALIVE 0x000013AA +#define ERROR_NETWORK_NOT_AVAILABLE 0x000013AB +#define ERROR_NODE_NOT_AVAILABLE 0x000013AC +#define ERROR_ALL_NODES_NOT_AVAILABLE 0x000013AD +#define ERROR_RESOURCE_FAILED 0x000013AE +#define ERROR_CLUSTER_INVALID_NODE 0x000013AF +#define ERROR_CLUSTER_NODE_EXISTS 0x000013B0 +#define ERROR_CLUSTER_JOIN_IN_PROGRESS 0x000013B1 +#define ERROR_CLUSTER_NODE_NOT_FOUND 0x000013B2 +#define ERROR_CLUSTER_LOCAL_NODE_NOT_FOUND 0x000013B3 +#define ERROR_CLUSTER_NETWORK_EXISTS 0x000013B4 +#define ERROR_CLUSTER_NETWORK_NOT_FOUND 0x000013B5 +#define ERROR_CLUSTER_NETINTERFACE_EXISTS 0x000013B6 +#define ERROR_CLUSTER_NETINTERFACE_NOT_FOUND 0x000013B7 +#define ERROR_CLUSTER_INVALID_REQUEST 0x000013B8 +#define ERROR_CLUSTER_INVALID_NETWORK_PROVIDER 0x000013B9 +#define ERROR_CLUSTER_NODE_DOWN 0x000013BA +#define ERROR_CLUSTER_NODE_UNREACHABLE 0x000013BB +#define ERROR_CLUSTER_NODE_NOT_MEMBER 0x000013BC +#define ERROR_CLUSTER_JOIN_NOT_IN_PROGRESS 0x000013BD +#define ERROR_CLUSTER_INVALID_NETWORK 0x000013BE +#define ERROR_CLUSTER_NODE_UP 0x000013C0 +#define ERROR_CLUSTER_IPADDR_IN_USE 0x000013C1 +#define ERROR_CLUSTER_NODE_NOT_PAUSED 0x000013C2 +#define ERROR_CLUSTER_NO_SECURITY_CONTEXT 0x000013C3 +#define ERROR_CLUSTER_NETWORK_NOT_INTERNAL 0x000013C4 +#define ERROR_CLUSTER_NODE_ALREADY_UP 0x000013C5 +#define ERROR_CLUSTER_NODE_ALREADY_DOWN 0x000013C6 +#define ERROR_CLUSTER_NETWORK_ALREADY_ONLINE 0x000013C7 +#define ERROR_CLUSTER_NETWORK_ALREADY_OFFLINE 0x000013C8 +#define ERROR_CLUSTER_NODE_ALREADY_MEMBER 0x000013C9 +#define ERROR_CLUSTER_LAST_INTERNAL_NETWORK 0x000013CA +#define ERROR_CLUSTER_NETWORK_HAS_DEPENDENTS 0x000013CB +#define ERROR_INVALID_OPERATION_ON_QUORUM 0x000013CC +#define ERROR_DEPENDENCY_NOT_ALLOWED 0x000013CD +#define ERROR_CLUSTER_NODE_PAUSED 0x000013CE +#define ERROR_NODE_CANT_HOST_RESOURCE 0x000013CF +#define ERROR_CLUSTER_NODE_NOT_READY 0x000013D0 +#define ERROR_CLUSTER_NODE_SHUTTING_DOWN 0x000013D1 +#define ERROR_CLUSTER_JOIN_ABORTED 0x000013D2 +#define ERROR_CLUSTER_INCOMPATIBLE_VERSIONS 0x000013D3 +#define ERROR_CLUSTER_MAXNUM_OF_RESOURCES_EXCEEDED 0x000013D4 +#define ERROR_CLUSTER_SYSTEM_CONFIG_CHANGED 0x000013D5 +#define ERROR_CLUSTER_RESOURCE_TYPE_NOT_FOUND 0x000013D6 +#define ERROR_CLUSTER_RESTYPE_NOT_SUPPORTED 0x000013D7 +#define ERROR_CLUSTER_RESNAME_NOT_FOUND 0x000013D8 +#define ERROR_CLUSTER_NO_RPC_PACKAGES_REGISTERED 0x000013D9 +#define ERROR_CLUSTER_OWNER_NOT_IN_PREFLIST 0x000013DA +#define ERROR_CLUSTER_DATABASE_SEQMISMATCH 0x000013DB +#define ERROR_RESMON_INVALID_STATE 0x000013DC +#define ERROR_CLUSTER_GUM_NOT_LOCKER 0x000013DD +#define ERROR_QUORUM_DISK_NOT_FOUND 0x000013DE +#define ERROR_DATABASE_BACKUP_CORRUPT 0x000013DF +#define ERROR_CLUSTER_NODE_ALREADY_HAS_DFS_ROOT 0x000013E0 +#define ERROR_RESOURCE_PROPERTY_UNCHANGEABLE 0x000013E1 +#define ERROR_CLUSTER_MEMBERSHIP_INVALID_STATE 0x00001702 +#define ERROR_CLUSTER_QUORUMLOG_NOT_FOUND 0x00001703 +#define ERROR_CLUSTER_MEMBERSHIP_HALT 0x00001704 +#define ERROR_CLUSTER_INSTANCE_ID_MISMATCH 0x00001705 +#define ERROR_CLUSTER_NETWORK_NOT_FOUND_FOR_IP 0x00001706 +#define ERROR_CLUSTER_PROPERTY_DATA_TYPE_MISMATCH 0x00001707 +#define ERROR_CLUSTER_EVICT_WITHOUT_CLEANUP 0x00001708 +#define ERROR_CLUSTER_PARAMETER_MISMATCH 0x00001709 +#define ERROR_NODE_CANNOT_BE_CLUSTERED 0x0000170A +#define ERROR_CLUSTER_WRONG_OS_VERSION 0x0000170B +#define ERROR_CLUSTER_CANT_CREATE_DUP_CLUSTER_NAME 0x0000170C +#define ERROR_CLUSCFG_ALREADY_COMMITTED 0x0000170D +#define ERROR_CLUSCFG_ROLLBACK_FAILED 0x0000170E +#define ERROR_CLUSCFG_SYSTEM_DISK_DRIVE_LETTER_CONFLICT 0x0000170F +#define ERROR_CLUSTER_OLD_VERSION 0x00001710 +#define ERROR_CLUSTER_MISMATCHED_COMPUTER_ACCT_NAME 0x00001711 +#define ERROR_CLUSTER_NO_NET_ADAPTERS 0x00001712 +#define ERROR_CLUSTER_POISONED 0x00001713 +#define ERROR_CLUSTER_GROUP_MOVING 0x00001714 +#define ERROR_CLUSTER_RESOURCE_TYPE_BUSY 0x00001715 +#define ERROR_RESOURCE_CALL_TIMED_OUT 0x00001716 +#define ERROR_INVALID_CLUSTER_IPV6_ADDRESS 0x00001717 +#define ERROR_CLUSTER_INTERNAL_INVALID_FUNCTION 0x00001718 +#define ERROR_CLUSTER_PARAMETER_OUT_OF_BOUNDS 0x00001719 +#define ERROR_CLUSTER_PARTIAL_SEND 0x0000171A +#define ERROR_CLUSTER_REGISTRY_INVALID_FUNCTION 0x0000171B +#define ERROR_CLUSTER_INVALID_STRING_TERMINATION 0x0000171C +#define ERROR_CLUSTER_INVALID_STRING_FORMAT 0x0000171D +#define ERROR_CLUSTER_DATABASE_TRANSACTION_IN_PROGRESS 0x0000171E +#define ERROR_CLUSTER_DATABASE_TRANSACTION_NOT_IN_PROGRESS 0x0000171F +#define ERROR_CLUSTER_NULL_DATA 0x00001720 +#define ERROR_CLUSTER_PARTIAL_READ 0x00001721 +#define ERROR_CLUSTER_PARTIAL_WRITE 0x00001722 +#define ERROR_CLUSTER_CANT_DESERIALIZE_DATA 0x00001723 +#define ERROR_DEPENDENT_RESOURCE_PROPERTY_CONFLICT 0x00001724 +#define ERROR_CLUSTER_NO_QUORUM 0x00001725 +#define ERROR_CLUSTER_INVALID_IPV6_NETWORK 0x00001726 +#define ERROR_CLUSTER_INVALID_IPV6_TUNNEL_NETWORK 0x00001727 +#define ERROR_QUORUM_NOT_ALLOWED_IN_THIS_GROUP 0x00001728 +#define ERROR_DEPENDENCY_TREE_TOO_COMPLEX 0x00001729 +#define ERROR_EXCEPTION_IN_RESOURCE_CALL 0x0000172A +#define ERROR_CLUSTER_RHS_FAILED_INITIALIZATION 0x0000172B +#define ERROR_CLUSTER_NOT_INSTALLED 0x0000172C +#define ERROR_CLUSTER_RESOURCES_MUST_BE_ONLINE_ON_THE_SAME_NODE 0x0000172D +#define ERROR_CLUSTER_MAX_NODES_IN_CLUSTER 0x0000172E +#define ERROR_CLUSTER_TOO_MANY_NODES 0x0000172F +#define ERROR_CLUSTER_OBJECT_ALREADY_USED 0x00001730 +#define ERROR_NONCORE_GROUPS_FOUND 0x00001731 +#define ERROR_FILE_SHARE_RESOURCE_CONFLICT 0x00001732 +#define ERROR_CLUSTER_EVICT_INVALID_REQUEST 0x00001733 +#define ERROR_CLUSTER_SINGLETON_RESOURCE 0x00001734 +#define ERROR_CLUSTER_GROUP_SINGLETON_RESOURCE 0x00001735 +#define ERROR_CLUSTER_RESOURCE_PROVIDER_FAILED 0x00001736 +#define ERROR_CLUSTER_RESOURCE_CONFIGURATION_ERROR 0x00001737 +#define ERROR_CLUSTER_GROUP_BUSY 0x00001738 +#define ERROR_CLUSTER_NOT_SHARED_VOLUME 0x00001739 +#define ERROR_CLUSTER_INVALID_SECURITY_DESCRIPTOR 0x0000173A +#define ERROR_CLUSTER_SHARED_VOLUMES_IN_USE 0x0000173B +#define ERROR_CLUSTER_USE_SHARED_VOLUMES_API 0x0000173C +#define ERROR_CLUSTER_BACKUP_IN_PROGRESS 0x0000173D +#define ERROR_NON_CSV_PATH 0x0000173E +#define ERROR_CSV_VOLUME_NOT_LOCAL 0x0000173F +#define ERROR_CLUSTER_WATCHDOG_TERMINATING 0x00001740 +#define ERROR_CLUSTER_RESOURCE_VETOED_MOVE_INCOMPATIBLE_NODES 0x00001741 +#define ERROR_CLUSTER_INVALID_NODE_WEIGHT 0x00001742 +#define ERROR_CLUSTER_RESOURCE_VETOED_CALL 0x00001743 +#define ERROR_RESMON_SYSTEM_RESOURCES_LACKING 0x00001744 +#define ERROR_CLUSTER_RESOURCE_VETOED_MOVE_NOT_ENOUGH_RESOURCES_ON_DESTINATION 0x00001745 +#define ERROR_CLUSTER_RESOURCE_VETOED_MOVE_NOT_ENOUGH_RESOURCES_ON_SOURCE 0x00001746 +#define ERROR_CLUSTER_GROUP_QUEUED 0x00001747 +#define ERROR_CLUSTER_RESOURCE_LOCKED_STATUS 0x00001748 +#define ERROR_CLUSTER_SHARED_VOLUME_FAILOVER_NOT_ALLOWED 0x00001749 +#define ERROR_CLUSTER_NODE_DRAIN_IN_PROGRESS 0x0000174A +#define ERROR_CLUSTER_DISK_NOT_CONNECTED 0x0000174B +#define ERROR_DISK_NOT_CSV_CAPABLE 0x0000174C +#define ERROR_RESOURCE_NOT_IN_AVAILABLE_STORAGE 0x0000174D +#define ERROR_CLUSTER_SHARED_VOLUME_REDIRECTED 0x0000174E +#define ERROR_CLUSTER_SHARED_VOLUME_NOT_REDIRECTED 0x0000174F +#define ERROR_CLUSTER_CANNOT_RETURN_PROPERTIES 0x00001750 +#define ERROR_CLUSTER_RESOURCE_CONTAINS_UNSUPPORTED_DIFF_AREA_FOR_SHARED_VOLUMES 0x00001751 +#define ERROR_CLUSTER_RESOURCE_IS_IN_MAINTENANCE_MODE 0x00001752 +#define ERROR_CLUSTER_AFFINITY_CONFLICT 0x00001753 +#define ERROR_CLUSTER_RESOURCE_IS_REPLICA_VIRTUAL_MACHINE 0x00001754 + +/* System Error Codes (6000-8199) */ + +#define ERROR_ENCRYPTION_FAILED 0x00001770 +#define ERROR_DECRYPTION_FAILED 0x00001771 +#define ERROR_FILE_ENCRYPTED 0x00001772 +#define ERROR_NO_RECOVERY_POLICY 0x00001773 +#define ERROR_NO_EFS 0x00001774 +#define ERROR_WRONG_EFS 0x00001775 +#define ERROR_NO_USER_KEYS 0x00001776 +#define ERROR_FILE_NOT_ENCRYPTED 0x00001777 +#define ERROR_NOT_EXPORT_FORMAT 0x00001778 +#define ERROR_FILE_READ_ONLY 0x00001779 +#define ERROR_DIR_EFS_DISALLOWED 0x0000177A +#define ERROR_EFS_SERVER_NOT_TRUSTED 0x0000177B +#define ERROR_BAD_RECOVERY_POLICY 0x0000177C +#define ERROR_EFS_ALG_BLOB_TOO_BIG 0x0000177D +#define ERROR_VOLUME_NOT_SUPPORT_EFS 0x0000177E +#define ERROR_EFS_DISABLED 0x0000177F +#define ERROR_EFS_VERSION_NOT_SUPPORT 0x00001780 +#define ERROR_CS_ENCRYPTION_INVALID_SERVER_RESPONSE 0x00001781 +#define ERROR_CS_ENCRYPTION_UNSUPPORTED_SERVER 0x00001782 +#define ERROR_CS_ENCRYPTION_EXISTING_ENCRYPTED_FILE 0x00001783 +#define ERROR_CS_ENCRYPTION_NEW_ENCRYPTED_FILE 0x00001784 +#define ERROR_CS_ENCRYPTION_FILE_NOT_CSE 0x00001785 +#define ERROR_ENCRYPTION_POLICY_DENIES_OPERATION 0x00001786 +#define ERROR_NO_BROWSER_SERVERS_FOUND 0x000017E6 +#define SCHED_E_SERVICE_NOT_LOCALSYSTEM 0x00001838 +#define ERROR_LOG_SECTOR_INVALID 0x000019C8 +#define ERROR_LOG_SECTOR_PARITY_INVALID 0x000019C9 +#define ERROR_LOG_SECTOR_REMAPPED 0x000019CA +#define ERROR_LOG_BLOCK_INCOMPLETE 0x000019CB +#define ERROR_LOG_INVALID_RANGE 0x000019CC +#define ERROR_LOG_BLOCKS_EXHAUSTED 0x000019CD +#define ERROR_LOG_READ_CONTEXT_INVALID 0x000019CE +#define ERROR_LOG_RESTART_INVALID 0x000019CF +#define ERROR_LOG_BLOCK_VERSION 0x000019D0 +#define ERROR_LOG_BLOCK_INVALID 0x000019D1 +#define ERROR_LOG_READ_MODE_INVALID 0x000019D2 +#define ERROR_LOG_NO_RESTART 0x000019D3 +#define ERROR_LOG_METADATA_CORRUPT 0x000019D4 +#define ERROR_LOG_METADATA_INVALID 0x000019D5 +#define ERROR_LOG_METADATA_INCONSISTENT 0x000019D6 +#define ERROR_LOG_RESERVATION_INVALID 0x000019D7 +#define ERROR_LOG_CANT_DELETE 0x000019D8 +#define ERROR_LOG_CONTAINER_LIMIT_EXCEEDED 0x000019D9 +#define ERROR_LOG_START_OF_LOG 0x000019DA +#define ERROR_LOG_POLICY_ALREADY_INSTALLED 0x000019DB +#define ERROR_LOG_POLICY_NOT_INSTALLED 0x000019DC +#define ERROR_LOG_POLICY_INVALID 0x000019DD +#define ERROR_LOG_POLICY_CONFLICT 0x000019DE +#define ERROR_LOG_PINNED_ARCHIVE_TAIL 0x000019DF +#define ERROR_LOG_RECORD_NONEXISTENT 0x000019E0 +#define ERROR_LOG_RECORDS_RESERVED_INVALID 0x000019E1 +#define ERROR_LOG_SPACE_RESERVED_INVALID 0x000019E2 +#define ERROR_LOG_TAIL_INVALID 0x000019E3 +#define ERROR_LOG_FULL 0x000019E4 +#define ERROR_COULD_NOT_RESIZE_LOG 0x000019E5 +#define ERROR_LOG_MULTIPLEXED 0x000019E6 +#define ERROR_LOG_DEDICATED 0x000019E7 +#define ERROR_LOG_ARCHIVE_NOT_IN_PROGRESS 0x000019E8 +#define ERROR_LOG_ARCHIVE_IN_PROGRESS 0x000019E9 +#define ERROR_LOG_EPHEMERAL 0x000019EA +#define ERROR_LOG_NOT_ENOUGH_CONTAINERS 0x000019EB +#define ERROR_LOG_CLIENT_ALREADY_REGISTERED 0x000019EC +#define ERROR_LOG_CLIENT_NOT_REGISTERED 0x000019ED +#define ERROR_LOG_FULL_HANDLER_IN_PROGRESS 0x000019EE +#define ERROR_LOG_CONTAINER_READ_FAILED 0x000019EF +#define ERROR_LOG_CONTAINER_WRITE_FAILED 0x000019F0 +#define ERROR_LOG_CONTAINER_OPEN_FAILED 0x000019F1 +#define ERROR_LOG_CONTAINER_STATE_INVALID 0x000019F2 +#define ERROR_LOG_STATE_INVALID 0x000019F3 +#define ERROR_LOG_PINNED 0x000019F4 +#define ERROR_LOG_METADATA_FLUSH_FAILED 0x000019F5 +#define ERROR_LOG_INCONSISTENT_SECURITY 0x000019F6 +#define ERROR_LOG_APPENDED_FLUSH_FAILED 0x000019F7 +#define ERROR_LOG_PINNED_RESERVATION 0x000019F8 +#define ERROR_INVALID_TRANSACTION 0x00001A2C +#define ERROR_TRANSACTION_NOT_ACTIVE 0x00001A2D +#define ERROR_TRANSACTION_REQUEST_NOT_VALID 0x00001A2E +#define ERROR_TRANSACTION_NOT_REQUESTED 0x00001A2F +#define ERROR_TRANSACTION_ALREADY_ABORTED 0x00001A30 +#define ERROR_TRANSACTION_ALREADY_COMMITTED 0x00001A31 +#define ERROR_TM_INITIALIZATION_FAILED 0x00001A32 +#define ERROR_RESOURCEMANAGER_READ_ONLY 0x00001A33 +#define ERROR_TRANSACTION_NOT_JOINED 0x00001A34 +#define ERROR_TRANSACTION_SUPERIOR_EXISTS 0x00001A35 +#define ERROR_CRM_PROTOCOL_ALREADY_EXISTS 0x00001A36 +#define ERROR_TRANSACTION_PROPAGATION_FAILED 0x00001A37 +#define ERROR_CRM_PROTOCOL_NOT_FOUND 0x00001A38 +#define ERROR_TRANSACTION_INVALID_MARSHALL_BUFFER 0x00001A39 +#define ERROR_CURRENT_TRANSACTION_NOT_VALID 0x00001A3A +#define ERROR_TRANSACTION_NOT_FOUND 0x00001A3B +#define ERROR_RESOURCEMANAGER_NOT_FOUND 0x00001A3C +#define ERROR_ENLISTMENT_NOT_FOUND 0x00001A3D +#define ERROR_TRANSACTIONMANAGER_NOT_FOUND 0x00001A3E +#define ERROR_TRANSACTIONMANAGER_NOT_ONLINE 0x00001A3F +#define ERROR_TRANSACTIONMANAGER_RECOVERY_NAME_COLLISION 0x00001A40 +#define ERROR_TRANSACTION_NOT_ROOT 0x00001A41 +#define ERROR_TRANSACTION_OBJECT_EXPIRED 0x00001A42 +#define ERROR_TRANSACTION_RESPONSE_NOT_ENLISTED 0x00001A43 +#define ERROR_TRANSACTION_RECORD_TOO_LONG 0x00001A44 +#define ERROR_IMPLICIT_TRANSACTION_NOT_SUPPORTED 0x00001A45 +#define ERROR_TRANSACTION_INTEGRITY_VIOLATED 0x00001A46 +#define ERROR_TRANSACTIONMANAGER_IDENTITY_MISMATCH 0x00001A47 +#define ERROR_RM_CANNOT_BE_FROZEN_FOR_SNAPSHOT 0x00001A48 +#define ERROR_TRANSACTION_MUST_WRITETHROUGH 0x00001A49 +#define ERROR_TRANSACTION_NO_SUPERIOR 0x00001A4A +#define ERROR_HEURISTIC_DAMAGE_POSSIBLE 0x00001A4B +#define ERROR_TRANSACTIONAL_CONFLICT 0x00001A90 +#define ERROR_RM_NOT_ACTIVE 0x00001A91 +#define ERROR_RM_METADATA_CORRUPT 0x00001A92 +#define ERROR_DIRECTORY_NOT_RM 0x00001A93 +#define ERROR_TRANSACTIONS_UNSUPPORTED_REMOTE 0x00001A95 +#define ERROR_LOG_RESIZE_INVALID_SIZE 0x00001A96 +#define ERROR_OBJECT_NO_LONGER_EXISTS 0x00001A97 +#define ERROR_STREAM_MINIVERSION_NOT_FOUND 0x00001A98 +#define ERROR_STREAM_MINIVERSION_NOT_VALID 0x00001A99 +#define ERROR_MINIVERSION_INACCESSIBLE_FROM_SPECIFIED_TRANSACTION 0x00001A9A +#define ERROR_CANT_OPEN_MINIVERSION_WITH_MODIFY_INTENT 0x00001A9B +#define ERROR_CANT_CREATE_MORE_STREAM_MINIVERSIONS 0x00001A9C +#define ERROR_REMOTE_FILE_VERSION_MISMATCH 0x00001A9E +#define ERROR_HANDLE_NO_LONGER_VALID 0x00001A9F +#define ERROR_NO_TXF_METADATA 0x00001AA0 +#define ERROR_LOG_CORRUPTION_DETECTED 0x00001AA1 +#define ERROR_CANT_RECOVER_WITH_HANDLE_OPEN 0x00001AA2 +#define ERROR_RM_DISCONNECTED 0x00001AA3 +#define ERROR_ENLISTMENT_NOT_SUPERIOR 0x00001AA4 +#define ERROR_RECOVERY_NOT_NEEDED 0x00001AA5 +#define ERROR_RM_ALREADY_STARTED 0x00001AA6 +#define ERROR_FILE_IDENTITY_NOT_PERSISTENT 0x00001AA7 +#define ERROR_CANT_BREAK_TRANSACTIONAL_DEPENDENCY 0x00001AA8 +#define ERROR_CANT_CROSS_RM_BOUNDARY 0x00001AA9 +#define ERROR_TXF_DIR_NOT_EMPTY 0x00001AAA +#define ERROR_INDOUBT_TRANSACTIONS_EXIST 0x00001AAB +#define ERROR_TM_VOLATILE 0x00001AAC +#define ERROR_ROLLBACK_TIMER_EXPIRED 0x00001AAD +#define ERROR_TXF_ATTRIBUTE_CORRUPT 0x00001AAE +#define ERROR_EFS_NOT_ALLOWED_IN_TRANSACTION 0x00001AAF +#define ERROR_TRANSACTIONAL_OPEN_NOT_ALLOWED 0x00001AB0 +#define ERROR_LOG_GROWTH_FAILED 0x00001AB1 +#define ERROR_TRANSACTED_MAPPING_UNSUPPORTED_REMOTE 0x00001AB2 +#define ERROR_TXF_METADATA_ALREADY_PRESENT 0x00001AB3 +#define ERROR_TRANSACTION_SCOPE_CALLBACKS_NOT_SET 0x00001AB4 +#define ERROR_TRANSACTION_REQUIRED_PROMOTION 0x00001AB5 +#define ERROR_CANNOT_EXECUTE_FILE_IN_TRANSACTION 0x00001AB6 +#define ERROR_TRANSACTIONS_NOT_FROZEN 0x00001AB7 +#define ERROR_TRANSACTION_FREEZE_IN_PROGRESS 0x00001AB8 +#define ERROR_NOT_SNAPSHOT_VOLUME 0x00001AB9 +#define ERROR_NO_SAVEPOINT_WITH_OPEN_FILES 0x00001ABA +#define ERROR_DATA_LOST_REPAIR 0x00001ABB +#define ERROR_SPARSE_NOT_ALLOWED_IN_TRANSACTION 0x00001ABC +#define ERROR_TM_IDENTITY_MISMATCH 0x00001ABD +#define ERROR_FLOATED_SECTION 0x00001ABE +#define ERROR_CANNOT_ACCEPT_TRANSACTED_WORK 0x00001ABF +#define ERROR_CANNOT_ABORT_TRANSACTIONS 0x00001AC0 +#define ERROR_BAD_CLUSTERS 0x00001AC1 +#define ERROR_COMPRESSION_NOT_ALLOWED_IN_TRANSACTION 0x00001AC2 +#define ERROR_VOLUME_DIRTY 0x00001AC3 +#define ERROR_NO_LINK_TRACKING_IN_TRANSACTION 0x00001AC4 +#define ERROR_OPERATION_NOT_SUPPORTED_IN_TRANSACTION 0x00001AC5 +#define ERROR_EXPIRED_HANDLE 0x00001AC6 +#define ERROR_TRANSACTION_NOT_ENLISTED 0x00001AC7 +#define ERROR_CTX_WINSTATION_NAME_INVALID 0x00001B59 +#define ERROR_CTX_INVALID_PD 0x00001B5A +#define ERROR_CTX_PD_NOT_FOUND 0x00001B5B +#define ERROR_CTX_WD_NOT_FOUND 0x00001B5C +#define ERROR_CTX_CANNOT_MAKE_EVENTLOG_ENTRY 0x00001B5D +#define ERROR_CTX_SERVICE_NAME_COLLISION 0x00001B5E +#define ERROR_CTX_CLOSE_PENDING 0x00001B5F +#define ERROR_CTX_NO_OUTBUF 0x00001B60 +#define ERROR_CTX_MODEM_INF_NOT_FOUND 0x00001B61 +#define ERROR_CTX_INVALID_MODEMNAME 0x00001B62 +#define ERROR_CTX_MODEM_RESPONSE_ERROR 0x00001B63 +#define ERROR_CTX_MODEM_RESPONSE_TIMEOUT 0x00001B64 +#define ERROR_CTX_MODEM_RESPONSE_NO_CARRIER 0x00001B65 +#define ERROR_CTX_MODEM_RESPONSE_NO_DIALTONE 0x00001B66 +#define ERROR_CTX_MODEM_RESPONSE_BUSY 0x00001B67 +#define ERROR_CTX_MODEM_RESPONSE_VOICE 0x00001B68 +#define ERROR_CTX_TD_ERROR 0x00001B69 +#define ERROR_CTX_WINSTATION_NOT_FOUND 0x00001B6E +#define ERROR_CTX_WINSTATION_ALREADY_EXISTS 0x00001B6F +#define ERROR_CTX_WINSTATION_BUSY 0x00001B70 +#define ERROR_CTX_BAD_VIDEO_MODE 0x00001B71 +#define ERROR_CTX_GRAPHICS_INVALID 0x00001B7B +#define ERROR_CTX_LOGON_DISABLED 0x00001B7D +#define ERROR_CTX_NOT_CONSOLE 0x00001B7E +#define ERROR_CTX_CLIENT_QUERY_TIMEOUT 0x00001B80 +#define ERROR_CTX_CONSOLE_DISCONNECT 0x00001B81 +#define ERROR_CTX_CONSOLE_CONNECT 0x00001B82 +#define ERROR_CTX_SHADOW_DENIED 0x00001B84 +#define ERROR_CTX_WINSTATION_ACCESS_DENIED 0x00001B85 +#define ERROR_CTX_INVALID_WD 0x00001B89 +#define ERROR_CTX_SHADOW_INVALID 0x00001B8A +#define ERROR_CTX_SHADOW_DISABLED 0x00001B8B +#define ERROR_CTX_CLIENT_LICENSE_IN_USE 0x00001B8C +#define ERROR_CTX_CLIENT_LICENSE_NOT_SET 0x00001B8D +#define ERROR_CTX_LICENSE_NOT_AVAILABLE 0x00001B8E +#define ERROR_CTX_LICENSE_CLIENT_INVALID 0x00001B8F +#define ERROR_CTX_LICENSE_EXPIRED 0x00001B90 +#define ERROR_CTX_SHADOW_NOT_RUNNING 0x00001B91 +#define ERROR_CTX_SHADOW_ENDED_BY_MODE_CHANGE 0x00001B92 +#define ERROR_ACTIVATION_COUNT_EXCEEDED 0x00001B93 +#define ERROR_CTX_WINSTATIONS_DISABLED 0x00001B94 +#define ERROR_CTX_ENCRYPTION_LEVEL_REQUIRED 0x00001B95 +#define ERROR_CTX_SESSION_IN_USE 0x00001B96 +#define ERROR_CTX_NO_FORCE_LOGOFF 0x00001B97 +#define ERROR_CTX_ACCOUNT_RESTRICTION 0x00001B98 +#define ERROR_RDP_PROTOCOL_ERROR 0x00001B99 +#define ERROR_CTX_CDM_CONNECT 0x00001B9A +#define ERROR_CTX_CDM_DISCONNECT 0x00001B9B +#define ERROR_CTX_SECURITY_LAYER_ERROR 0x00001B9C +#define ERROR_TS_INCOMPATIBLE_SESSIONS 0x00001B9D +#define ERROR_TS_VIDEO_SUBSYSTEM_ERROR 0x00001B9E +#define FRS_ERR_INVALID_API_SEQUENCE 0x00001F41 +#define FRS_ERR_STARTING_SERVICE 0x00001F42 +#define FRS_ERR_STOPPING_SERVICE 0x00001F43 +#define FRS_ERR_INTERNAL_API 0x00001F44 +#define FRS_ERR_INTERNAL 0x00001F45 +#define FRS_ERR_SERVICE_COMM 0x00001F46 +#define FRS_ERR_INSUFFICIENT_PRIV 0x00001F47 +#define FRS_ERR_AUTHENTICATION 0x00001F48 +#define FRS_ERR_PARENT_INSUFFICIENT_PRIV 0x00001F49 +#define FRS_ERR_PARENT_AUTHENTICATION 0x00001F4A +#define FRS_ERR_CHILD_TO_PARENT_COMM 0x00001F4B +#define FRS_ERR_PARENT_TO_CHILD_COMM 0x00001F4C +#define FRS_ERR_SYSVOL_POPULATE 0x00001F4D +#define FRS_ERR_SYSVOL_POPULATE_TIMEOUT 0x00001F4E +#define FRS_ERR_SYSVOL_IS_BUSY 0x00001F4F +#define FRS_ERR_SYSVOL_DEMOTE 0x00001F50 +#define FRS_ERR_INVALID_SERVICE_PARAMETER 0x00001F51 + +/* System Error Codes (8200-8999) */ + +#define ERROR_DS_NOT_INSTALLED 0x00002008 +#define ERROR_DS_MEMBERSHIP_EVALUATED_LOCALLY 0x00002009 +#define ERROR_DS_NO_ATTRIBUTE_OR_VALUE 0x0000200A +#define ERROR_DS_INVALID_ATTRIBUTE_SYNTAX 0x0000200B +#define ERROR_DS_ATTRIBUTE_TYPE_UNDEFINED 0x0000200C +#define ERROR_DS_ATTRIBUTE_OR_VALUE_EXISTS 0x0000200D +#define ERROR_DS_BUSY 0x0000200E +#define ERROR_DS_UNAVAILABLE 0x0000200F +#define ERROR_DS_NO_RIDS_ALLOCATED 0x00002010 +#define ERROR_DS_NO_MORE_RIDS 0x00002011 +#define ERROR_DS_INCORRECT_ROLE_OWNER 0x00002012 +#define ERROR_DS_RIDMGR_INIT_ERROR 0x00002013 +#define ERROR_DS_OBJ_CLASS_VIOLATION 0x00002014 +#define ERROR_DS_CANT_ON_NON_LEAF 0x00002015 +#define ERROR_DS_CANT_ON_RDN 0x00002016 +#define ERROR_DS_CANT_MOD_OBJ_CLASS 0x00002017 +#define ERROR_DS_CROSS_DOM_MOVE_ERROR 0x00002018 +#define ERROR_DS_GC_NOT_AVAILABLE 0x00002019 +#define ERROR_SHARED_POLICY 0x0000201A +#define ERROR_POLICY_OBJECT_NOT_FOUND 0x0000201B +#define ERROR_POLICY_ONLY_IN_DS 0x0000201C +#define ERROR_PROMOTION_ACTIVE 0x0000201D +#define ERROR_NO_PROMOTION_ACTIVE 0x0000201E +#define ERROR_DS_OPERATIONS_ERROR 0x00002020 +#define ERROR_DS_PROTOCOL_ERROR 0x00002021 +#define ERROR_DS_TIMELIMIT_EXCEEDED 0x00002022 +#define ERROR_DS_SIZELIMIT_EXCEEDED 0x00002023 +#define ERROR_DS_ADMIN_LIMIT_EXCEEDED 0x00002024 +#define ERROR_DS_COMPARE_FALSE 0x00002025 +#define ERROR_DS_COMPARE_TRUE 0x00002026 +#define ERROR_DS_AUTH_METHOD_NOT_SUPPORTED 0x00002027 +#define ERROR_DS_STRONG_AUTH_REQUIRED 0x00002028 +#define ERROR_DS_INAPPROPRIATE_AUTH 0x00002029 +#define ERROR_DS_AUTH_UNKNOWN 0x0000202A +#define ERROR_DS_REFERRAL 0x0000202B +#define ERROR_DS_UNAVAILABLE_CRIT_EXTENSION 0x0000202C +#define ERROR_DS_CONFIDENTIALITY_REQUIRED 0x0000202D +#define ERROR_DS_INAPPROPRIATE_MATCHING 0x0000202E +#define ERROR_DS_CONSTRAINT_VIOLATION 0x0000202F +#define ERROR_DS_NO_SUCH_OBJECT 0x00002030 +#define ERROR_DS_ALIAS_PROBLEM 0x00002031 +#define ERROR_DS_INVALID_DN_SYNTAX 0x00002032 +#define ERROR_DS_IS_LEAF 0x00002033 +#define ERROR_DS_ALIAS_DEREF_PROBLEM 0x00002034 +#define ERROR_DS_UNWILLING_TO_PERFORM 0x00002035 +#define ERROR_DS_LOOP_DETECT 0x00002036 +#define ERROR_DS_NAMING_VIOLATION 0x00002037 +#define ERROR_DS_OBJECT_RESULTS_TOO_LARGE 0x00002038 +#define ERROR_DS_AFFECTS_MULTIPLE_DSAS 0x00002039 +#define ERROR_DS_SERVER_DOWN 0x0000203A +#define ERROR_DS_LOCAL_ERROR 0x0000203B +#define ERROR_DS_ENCODING_ERROR 0x0000203C +#define ERROR_DS_DECODING_ERROR 0x0000203D +#define ERROR_DS_FILTER_UNKNOWN 0x0000203E +#define ERROR_DS_PARAM_ERROR 0x0000203F +#define ERROR_DS_NOT_SUPPORTED 0x00002040 +#define ERROR_DS_NO_RESULTS_RETURNED 0x00002041 +#define ERROR_DS_CONTROL_NOT_FOUND 0x00002042 +#define ERROR_DS_CLIENT_LOOP 0x00002043 +#define ERROR_DS_REFERRAL_LIMIT_EXCEEDED 0x00002044 +#define ERROR_DS_SORT_CONTROL_MISSING 0x00002045 +#define ERROR_DS_OFFSET_RANGE_ERROR 0x00002046 +#define ERROR_DS_RIDMGR_DISABLED 0x00002047 +#define ERROR_DS_ROOT_MUST_BE_NC 0x0000206D +#define ERROR_DS_ADD_REPLICA_INHIBITED 0x0000206E +#define ERROR_DS_ATT_NOT_DEF_IN_SCHEMA 0x0000206F +#define ERROR_DS_MAX_OBJ_SIZE_EXCEEDED 0x00002070 +#define ERROR_DS_OBJ_STRING_NAME_EXISTS 0x00002071 +#define ERROR_DS_NO_RDN_DEFINED_IN_SCHEMA 0x00002072 +#define ERROR_DS_RDN_DOESNT_MATCH_SCHEMA 0x00002073 +#define ERROR_DS_NO_REQUESTED_ATTS_FOUND 0x00002074 +#define ERROR_DS_USER_BUFFER_TO_SMALL 0x00002075 +#define ERROR_DS_ATT_IS_NOT_ON_OBJ 0x00002076 +#define ERROR_DS_ILLEGAL_MOD_OPERATION 0x00002077 +#define ERROR_DS_OBJ_TOO_LARGE 0x00002078 +#define ERROR_DS_BAD_INSTANCE_TYPE 0x00002079 +#define ERROR_DS_MASTERDSA_REQUIRED 0x0000207A +#define ERROR_DS_OBJECT_CLASS_REQUIRED 0x0000207B +#define ERROR_DS_MISSING_REQUIRED_ATT 0x0000207C +#define ERROR_DS_ATT_NOT_DEF_FOR_CLASS 0x0000207D +#define ERROR_DS_ATT_ALREADY_EXISTS 0x0000207E +#define ERROR_DS_CANT_ADD_ATT_VALUES 0x00002080 +#define ERROR_DS_SINGLE_VALUE_CONSTRAINT 0x00002081 +#define ERROR_DS_RANGE_CONSTRAINT 0x00002082 +#define ERROR_DS_ATT_VAL_ALREADY_EXISTS 0x00002083 +#define ERROR_DS_CANT_REM_MISSING_ATT 0x00002084 +#define ERROR_DS_CANT_REM_MISSING_ATT_VAL 0x00002085 +#define ERROR_DS_ROOT_CANT_BE_SUBREF 0x00002086 +#define ERROR_DS_NO_CHAINING 0x00002087 +#define ERROR_DS_NO_CHAINED_EVAL 0x00002088 +#define ERROR_DS_NO_PARENT_OBJECT 0x00002089 +#define ERROR_DS_PARENT_IS_AN_ALIAS 0x0000208A +#define ERROR_DS_CANT_MIX_MASTER_AND_REPS 0x0000208B +#define ERROR_DS_CHILDREN_EXIST 0x0000208C +#define ERROR_DS_OBJ_NOT_FOUND 0x0000208D +#define ERROR_DS_ALIASED_OBJ_MISSING 0x0000208E +#define ERROR_DS_BAD_NAME_SYNTAX 0x0000208F +#define ERROR_DS_ALIAS_POINTS_TO_ALIAS 0x00002090 +#define ERROR_DS_CANT_DEREF_ALIAS 0x00002091 +#define ERROR_DS_OUT_OF_SCOPE 0x00002092 +#define ERROR_DS_OBJECT_BEING_REMOVED 0x00002093 +#define ERROR_DS_CANT_DELETE_DSA_OBJ 0x00002094 +#define ERROR_DS_GENERIC_ERROR 0x00002095 +#define ERROR_DS_DSA_MUST_BE_INT_MASTER 0x00002096 +#define ERROR_DS_CLASS_NOT_DSA 0x00002097 +#define ERROR_DS_INSUFF_ACCESS_RIGHTS 0x00002098 +#define ERROR_DS_ILLEGAL_SUPERIOR 0x00002099 +#define ERROR_DS_ATTRIBUTE_OWNED_BY_SAM 0x0000209A +#define ERROR_DS_NAME_TOO_MANY_PARTS 0x0000209B +#define ERROR_DS_NAME_TOO_LONG 0x0000209C +#define ERROR_DS_NAME_VALUE_TOO_LONG 0x0000209D +#define ERROR_DS_NAME_UNPARSEABLE 0x0000209E +#define ERROR_DS_NAME_TYPE_UNKNOWN 0x0000209F +#define ERROR_DS_NOT_AN_OBJECT 0x000020A0 +#define ERROR_DS_SEC_DESC_TOO_SHORT 0x000020A1 +#define ERROR_DS_SEC_DESC_INVALID 0x000020A2 +#define ERROR_DS_NO_DELETED_NAME 0x000020A3 +#define ERROR_DS_SUBREF_MUST_HAVE_PARENT 0x000020A4 +#define ERROR_DS_NCNAME_MUST_BE_NC 0x000020A5 +#define ERROR_DS_CANT_ADD_SYSTEM_ONLY 0x000020A6 +#define ERROR_DS_CLASS_MUST_BE_CONCRETE 0x000020A7 +#define ERROR_DS_INVALID_DMD 0x000020A8 +#define ERROR_DS_OBJ_GUID_EXISTS 0x000020A9 +#define ERROR_DS_NOT_ON_BACKLINK 0x000020AA +#define ERROR_DS_NO_CROSSREF_FOR_NC 0x000020AB +#define ERROR_DS_SHUTTING_DOWN 0x000020AC +#define ERROR_DS_UNKNOWN_OPERATION 0x000020AD +#define ERROR_DS_INVALID_ROLE_OWNER 0x000020AE +#define ERROR_DS_COULDNT_CONTACT_FSMO 0x000020AF +#define ERROR_DS_CROSS_NC_DN_RENAME 0x000020B0 +#define ERROR_DS_CANT_MOD_SYSTEM_ONLY 0x000020B1 +#define ERROR_DS_REPLICATOR_ONLY 0x000020B2 +#define ERROR_DS_OBJ_CLASS_NOT_DEFINED 0x000020B3 +#define ERROR_DS_OBJ_CLASS_NOT_SUBCLASS 0x000020B4 +#define ERROR_DS_NAME_REFERENCE_INVALID 0x000020B5 +#define ERROR_DS_CROSS_REF_EXISTS 0x000020B6 +#define ERROR_DS_CANT_DEL_MASTER_CROSSREF 0x000020B7 +#define ERROR_DS_SUBTREE_NOTIFY_NOT_NC_HEAD 0x000020B8 +#define ERROR_DS_NOTIFY_FILTER_TOO_COMPLEX 0x000020B9 +#define ERROR_DS_DUP_RDN 0x000020BA +#define ERROR_DS_DUP_OID 0x000020BB +#define ERROR_DS_DUP_MAPI_ID 0x000020BC +#define ERROR_DS_DUP_SCHEMA_ID_GUID 0x000020BD +#define ERROR_DS_DUP_LDAP_DISPLAY_NAME 0x000020BE +#define ERROR_DS_SEMANTIC_ATT_TEST 0x000020BF +#define ERROR_DS_SYNTAX_MISMATCH 0x000020C0 +#define ERROR_DS_EXISTS_IN_MUST_HAVE 0x000020C1 +#define ERROR_DS_EXISTS_IN_MAY_HAVE 0x000020C2 +#define ERROR_DS_NONEXISTENT_MAY_HAVE 0x000020C3 +#define ERROR_DS_NONEXISTENT_MUST_HAVE 0x000020C4 +#define ERROR_DS_AUX_CLS_TEST_FAIL 0x000020C5 +#define ERROR_DS_NONEXISTENT_POSS_SUP 0x000020C6 +#define ERROR_DS_SUB_CLS_TEST_FAIL 0x000020C7 +#define ERROR_DS_BAD_RDN_ATT_ID_SYNTAX 0x000020C8 +#define ERROR_DS_EXISTS_IN_AUX_CLS 0x000020C9 +#define ERROR_DS_EXISTS_IN_SUB_CLS 0x000020CA +#define ERROR_DS_EXISTS_IN_POSS_SUP 0x000020CB +#define ERROR_DS_RECALCSCHEMA_FAILED 0x000020CC +#define ERROR_DS_TREE_DELETE_NOT_FINISHED 0x000020CD +#define ERROR_DS_CANT_DELETE 0x000020CE +#define ERROR_DS_ATT_SCHEMA_REQ_ID 0x000020CF +#define ERROR_DS_BAD_ATT_SCHEMA_SYNTAX 0x000020D0 +#define ERROR_DS_CANT_CACHE_ATT 0x000020D1 +#define ERROR_DS_CANT_CACHE_CLASS 0x000020D2 +#define ERROR_DS_CANT_REMOVE_ATT_CACHE 0x000020D3 +#define ERROR_DS_CANT_REMOVE_CLASS_CACHE 0x000020D4 +#define ERROR_DS_CANT_RETRIEVE_DN 0x000020D5 +#define ERROR_DS_MISSING_SUPREF 0x000020D6 +#define ERROR_DS_CANT_RETRIEVE_INSTANCE 0x000020D7 +#define ERROR_DS_CODE_INCONSISTENCY 0x000020D8 +#define ERROR_DS_DATABASE_ERROR 0x000020D9 +#define ERROR_DS_GOVERNSID_MISSING 0x000020DA +#define ERROR_DS_MISSING_EXPECTED_ATT 0x000020DB +#define ERROR_DS_NCNAME_MISSING_CR_REF 0x000020DC +#define ERROR_DS_SECURITY_CHECKING_ERROR 0x000020DD +#define ERROR_DS_SCHEMA_NOT_LOADED 0x000020DE +#define ERROR_DS_SCHEMA_ALLOC_FAILED 0x000020DF +#define ERROR_DS_ATT_SCHEMA_REQ_SYNTAX 0x000020E0 +#define ERROR_DS_GCVERIFY_ERROR 0x000020E1 +#define ERROR_DS_DRA_SCHEMA_MISMATCH 0x000020E2 +#define ERROR_DS_CANT_FIND_DSA_OBJ 0x000020E3 +#define ERROR_DS_CANT_FIND_EXPECTED_NC 0x000020E4 +#define ERROR_DS_CANT_FIND_NC_IN_CACHE 0x000020E5 +#define ERROR_DS_CANT_RETRIEVE_CHILD 0x000020E6 +#define ERROR_DS_SECURITY_ILLEGAL_MODIFY 0x000020E7 +#define ERROR_DS_CANT_REPLACE_HIDDEN_REC 0x000020E8 +#define ERROR_DS_BAD_HIERARCHY_FILE 0x000020E9 +#define ERROR_DS_BUILD_HIERARCHY_TABLE_FAILED 0x000020EA +#define ERROR_DS_CONFIG_PARAM_MISSING 0x000020EB +#define ERROR_DS_COUNTING_AB_INDICES_FAILED 0x000020EC +#define ERROR_DS_HIERARCHY_TABLE_MALLOC_FAILED 0x000020ED +#define ERROR_DS_INTERNAL_FAILURE 0x000020EE +#define ERROR_DS_UNKNOWN_ERROR 0x000020EF +#define ERROR_DS_ROOT_REQUIRES_CLASS_TOP 0x000020F0 +#define ERROR_DS_REFUSING_FSMO_ROLES 0x000020F1 +#define ERROR_DS_MISSING_FSMO_SETTINGS 0x000020F2 +#define ERROR_DS_UNABLE_TO_SURRENDER_ROLES 0x000020F3 +#define ERROR_DS_DRA_GENERIC 0x000020F4 +#define ERROR_DS_DRA_INVALID_PARAMETER 0x000020F5 +#define ERROR_DS_DRA_BUSY 0x000020F6 +#define ERROR_DS_DRA_BAD_DN 0x000020F7 +#define ERROR_DS_DRA_BAD_NC 0x000020F8 +#define ERROR_DS_DRA_DN_EXISTS 0x000020F9 +#define ERROR_DS_DRA_INTERNAL_ERROR 0x000020FA +#define ERROR_DS_DRA_INCONSISTENT_DIT 0x000020FB +#define ERROR_DS_DRA_CONNECTION_FAILED 0x000020FC +#define ERROR_DS_DRA_BAD_INSTANCE_TYPE 0x000020FD +#define ERROR_DS_DRA_OUT_OF_MEM 0x000020FE +#define ERROR_DS_DRA_MAIL_PROBLEM 0x000020FF +#define ERROR_DS_DRA_REF_ALREADY_EXISTS 0x00002100 +#define ERROR_DS_DRA_REF_NOT_FOUND 0x00002101 +#define ERROR_DS_DRA_OBJ_IS_REP_SOURCE 0x00002102 +#define ERROR_DS_DRA_DB_ERROR 0x00002103 +#define ERROR_DS_DRA_NO_REPLICA 0x00002104 +#define ERROR_DS_DRA_ACCESS_DENIED 0x00002105 +#define ERROR_DS_DRA_NOT_SUPPORTED 0x00002106 +#define ERROR_DS_DRA_RPC_CANCELLED 0x00002107 +#define ERROR_DS_DRA_SOURCE_DISABLED 0x00002108 +#define ERROR_DS_DRA_SINK_DISABLED 0x00002109 +#define ERROR_DS_DRA_NAME_COLLISION 0x0000210A +#define ERROR_DS_DRA_SOURCE_REINSTALLED 0x0000210B +#define ERROR_DS_DRA_MISSING_PARENT 0x0000210C +#define ERROR_DS_DRA_PREEMPTED 0x0000210D +#define ERROR_DS_DRA_ABANDON_SYNC 0x0000210E +#define ERROR_DS_DRA_SHUTDOWN 0x0000210F +#define ERROR_DS_DRA_INCOMPATIBLE_PARTIAL_SET 0x00002110 +#define ERROR_DS_DRA_SOURCE_IS_PARTIAL_REPLICA 0x00002111 +#define ERROR_DS_DRA_EXTN_CONNECTION_FAILED 0x00002112 +#define ERROR_DS_INSTALL_SCHEMA_MISMATCH 0x00002113 +#define ERROR_DS_DUP_LINK_ID 0x00002114 +#define ERROR_DS_NAME_ERROR_RESOLVING 0x00002115 +#define ERROR_DS_NAME_ERROR_NOT_FOUND 0x00002116 +#define ERROR_DS_NAME_ERROR_NOT_UNIQUE 0x00002117 +#define ERROR_DS_NAME_ERROR_NO_MAPPING 0x00002118 +#define ERROR_DS_NAME_ERROR_DOMAIN_ONLY 0x00002119 +#define ERROR_DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING 0x0000211A +#define ERROR_DS_CONSTRUCTED_ATT_MOD 0x0000211B +#define ERROR_DS_WRONG_OM_OBJ_CLASS 0x0000211C +#define ERROR_DS_DRA_REPL_PENDING 0x0000211D +#define ERROR_DS_DS_REQUIRED 0x0000211E +#define ERROR_DS_INVALID_LDAP_DISPLAY_NAME 0x0000211F +#define ERROR_DS_NON_BASE_SEARCH 0x00002120 +#define ERROR_DS_CANT_RETRIEVE_ATTS 0x00002121 +#define ERROR_DS_BACKLINK_WITHOUT_LINK 0x00002122 +#define ERROR_DS_EPOCH_MISMATCH 0x00002123 +#define ERROR_DS_SRC_NAME_MISMATCH 0x00002124 +#define ERROR_DS_SRC_AND_DST_NC_IDENTICAL 0x00002125 +#define ERROR_DS_DST_NC_MISMATCH 0x00002126 +#define ERROR_DS_NOT_AUTHORITIVE_FOR_DST_NC 0x00002127 +#define ERROR_DS_SRC_GUID_MISMATCH 0x00002128 +#define ERROR_DS_CANT_MOVE_DELETED_OBJECT 0x00002129 +#define ERROR_DS_PDC_OPERATION_IN_PROGRESS 0x0000212A +#define ERROR_DS_CROSS_DOMAIN_CLEANUP_REQD 0x0000212B +#define ERROR_DS_ILLEGAL_XDOM_MOVE_OPERATION 0x0000212C +#define ERROR_DS_CANT_WITH_ACCT_GROUP_MEMBERSHPS 0x0000212D +#define ERROR_DS_NC_MUST_HAVE_NC_PARENT 0x0000212E +#define ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE 0x0000212F +#define ERROR_DS_DST_DOMAIN_NOT_NATIVE 0x00002130 +#define ERROR_DS_MISSING_INFRASTRUCTURE_CONTAINER 0x00002131 +#define ERROR_DS_CANT_MOVE_ACCOUNT_GROUP 0x00002132 +#define ERROR_DS_CANT_MOVE_RESOURCE_GROUP 0x00002133 +#define ERROR_DS_INVALID_SEARCH_FLAG 0x00002134 +#define ERROR_DS_NO_TREE_DELETE_ABOVE_NC 0x00002135 +#define ERROR_DS_COULDNT_LOCK_TREE_FOR_DELETE 0x00002136 +#define ERROR_DS_COULDNT_IDENTIFY_OBJECTS_FOR_TREE_DELETE 0x00002137 +#define ERROR_DS_SAM_INIT_FAILURE 0x00002138 +#define ERROR_DS_SENSITIVE_GROUP_VIOLATION 0x00002139 +#define ERROR_DS_CANT_MOD_PRIMARYGROUPID 0x0000213A +#define ERROR_DS_ILLEGAL_BASE_SCHEMA_MOD 0x0000213B +#define ERROR_DS_NONSAFE_SCHEMA_CHANGE 0x0000213C +#define ERROR_DS_SCHEMA_UPDATE_DISALLOWED 0x0000213D +#define ERROR_DS_CANT_CREATE_UNDER_SCHEMA 0x0000213E +#define ERROR_DS_INSTALL_NO_SRC_SCH_VERSION 0x0000213F +#define ERROR_DS_INSTALL_NO_SCH_VERSION_IN_INIFILE 0x00002140 +#define ERROR_DS_INVALID_GROUP_TYPE 0x00002141 +#define ERROR_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN 0x00002142 +#define ERROR_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN 0x00002143 +#define ERROR_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER 0x00002144 +#define ERROR_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER 0x00002145 +#define ERROR_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER 0x00002146 +#define ERROR_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER 0x00002147 +#define ERROR_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER 0x00002148 +#define ERROR_DS_HAVE_PRIMARY_MEMBERS 0x00002149 +#define ERROR_DS_STRING_SD_CONVERSION_FAILED 0x0000214A +#define ERROR_DS_NAMING_MASTER_GC 0x0000214B +#define ERROR_DS_DNS_LOOKUP_FAILURE 0x0000214C +#define ERROR_DS_COULDNT_UPDATE_SPNS 0x0000214D +#define ERROR_DS_CANT_RETRIEVE_SD 0x0000214E +#define ERROR_DS_KEY_NOT_UNIQUE 0x0000214F +#define ERROR_DS_WRONG_LINKED_ATT_SYNTAX 0x00002150 +#define ERROR_DS_SAM_NEED_BOOTKEY_PASSWORD 0x00002151 +#define ERROR_DS_SAM_NEED_BOOTKEY_FLOPPY 0x00002152 +#define ERROR_DS_CANT_START 0x00002153 +#define ERROR_DS_INIT_FAILURE 0x00002154 +#define ERROR_DS_NO_PKT_PRIVACY_ON_CONNECTION 0x00002155 +#define ERROR_DS_SOURCE_DOMAIN_IN_FOREST 0x00002156 +#define ERROR_DS_DESTINATION_DOMAIN_NOT_IN_FOREST 0x00002157 +#define ERROR_DS_DESTINATION_AUDITING_NOT_ENABLED 0x00002158 +#define ERROR_DS_CANT_FIND_DC_FOR_SRC_DOMAIN 0x00002159 +#define ERROR_DS_SRC_OBJ_NOT_GROUP_OR_USER 0x0000215A +#define ERROR_DS_SRC_SID_EXISTS_IN_FOREST 0x0000215B +#define ERROR_DS_SRC_AND_DST_OBJECT_CLASS_MISMATCH 0x0000215C +#define ERROR_SAM_INIT_FAILURE 0x0000215D +#define ERROR_DS_DRA_SCHEMA_INFO_SHIP 0x0000215E +#define ERROR_DS_DRA_SCHEMA_CONFLICT 0x0000215F +#define ERROR_DS_DRA_EARLIER_SCHEMA_CONFLICT 0x00002160 +#define ERROR_DS_DRA_OBJ_NC_MISMATCH 0x00002161 +#define ERROR_DS_NC_STILL_HAS_DSAS 0x00002162 +#define ERROR_DS_GC_REQUIRED 0x00002163 +#define ERROR_DS_LOCAL_MEMBER_OF_LOCAL_ONLY 0x00002164 +#define ERROR_DS_NO_FPO_IN_UNIVERSAL_GROUPS 0x00002165 +#define ERROR_DS_CANT_ADD_TO_GC 0x00002166 +#define ERROR_DS_NO_CHECKPOINT_WITH_PDC 0x00002167 +#define ERROR_DS_SOURCE_AUDITING_NOT_ENABLED 0x00002168 +#define ERROR_DS_CANT_CREATE_IN_NONDOMAIN_NC 0x00002169 +#define ERROR_DS_INVALID_NAME_FOR_SPN 0x0000216A +#define ERROR_DS_FILTER_USES_CONTRUCTED_ATTRS 0x0000216B +#define ERROR_DS_UNICODEPWD_NOT_IN_QUOTES 0x0000216C +#define ERROR_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED 0x0000216D +#define ERROR_DS_MUST_BE_RUN_ON_DST_DC 0x0000216E +#define ERROR_DS_SRC_DC_MUST_BE_SP4_OR_GREATER 0x0000216F +#define ERROR_DS_CANT_TREE_DELETE_CRITICAL_OBJ 0x00002170 +#define ERROR_DS_INIT_FAILURE_CONSOLE 0x00002171 +#define ERROR_DS_SAM_INIT_FAILURE_CONSOLE 0x00002172 +#define ERROR_DS_FOREST_VERSION_TOO_HIGH 0x00002173 +#define ERROR_DS_DOMAIN_VERSION_TOO_HIGH 0x00002174 +#define ERROR_DS_FOREST_VERSION_TOO_LOW 0x00002175 +#define ERROR_DS_DOMAIN_VERSION_TOO_LOW 0x00002176 +#define ERROR_DS_INCOMPATIBLE_VERSION 0x00002177 +#define ERROR_DS_LOW_DSA_VERSION 0x00002178 +#define ERROR_DS_NO_BEHAVIOR_VERSION_IN_MIXEDDOMAIN 0x00002179 +#define ERROR_DS_NOT_SUPPORTED_SORT_ORDER 0x0000217A +#define ERROR_DS_NAME_NOT_UNIQUE 0x0000217B +#define ERROR_DS_MACHINE_ACCOUNT_CREATED_PRENT4 0x0000217C +#define ERROR_DS_OUT_OF_VERSION_STORE 0x0000217D +#define ERROR_DS_INCOMPATIBLE_CONTROLS_USED 0x0000217E +#define ERROR_DS_NO_REF_DOMAIN 0x0000217F +#define ERROR_DS_RESERVED_LINK_ID 0x00002180 +#define ERROR_DS_LINK_ID_NOT_AVAILABLE 0x00002181 +#define ERROR_DS_AG_CANT_HAVE_UNIVERSAL_MEMBER 0x00002182 +#define ERROR_DS_MODIFYDN_DISALLOWED_BY_INSTANCE_TYPE 0x00002183 +#define ERROR_DS_NO_OBJECT_MOVE_IN_SCHEMA_NC 0x00002184 +#define ERROR_DS_MODIFYDN_DISALLOWED_BY_FLAG 0x00002185 +#define ERROR_DS_MODIFYDN_WRONG_GRANDPARENT 0x00002186 +#define ERROR_DS_NAME_ERROR_TRUST_REFERRAL 0x00002187 +#define ERROR_NOT_SUPPORTED_ON_STANDARD_SERVER 0x00002188 +#define ERROR_DS_CANT_ACCESS_REMOTE_PART_OF_AD 0x00002189 +#define ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE_V2 0x0000218A +#define ERROR_DS_THREAD_LIMIT_EXCEEDED 0x0000218B +#define ERROR_DS_NOT_CLOSEST 0x0000218C +#define ERROR_DS_CANT_DERIVE_SPN_WITHOUT_SERVER_REF 0x0000218D +#define ERROR_DS_SINGLE_USER_MODE_FAILED 0x0000218E +#define ERROR_DS_NTDSCRIPT_SYNTAX_ERROR 0x0000218F +#define ERROR_DS_NTDSCRIPT_PROCESS_ERROR 0x00002190 +#define ERROR_DS_DIFFERENT_REPL_EPOCHS 0x00002191 +#define ERROR_DS_DRS_EXTENSIONS_CHANGED 0x00002192 +#define ERROR_DS_REPLICA_SET_CHANGE_NOT_ALLOWED_ON_DISABLED_CR 0x00002193 +#define ERROR_DS_NO_MSDS_INTID 0x00002194 +#define ERROR_DS_DUP_MSDS_INTID 0x00002195 +#define ERROR_DS_EXISTS_IN_RDNATTID 0x00002196 +#define ERROR_DS_AUTHORIZATION_FAILED 0x00002197 +#define ERROR_DS_INVALID_SCRIPT 0x00002198 +#define ERROR_DS_REMOTE_CROSSREF_OP_FAILED 0x00002199 +#define ERROR_DS_CROSS_REF_BUSY 0x0000219A +#define ERROR_DS_CANT_DERIVE_SPN_FOR_DELETED_DOMAIN 0x0000219B +#define ERROR_DS_CANT_DEMOTE_WITH_WRITEABLE_NC 0x0000219C +#define ERROR_DS_DUPLICATE_ID_FOUND 0x0000219D +#define ERROR_DS_INSUFFICIENT_ATTR_TO_CREATE_OBJECT 0x0000219E +#define ERROR_DS_GROUP_CONVERSION_ERROR 0x0000219F +#define ERROR_DS_CANT_MOVE_APP_BASIC_GROUP 0x000021A0 +#define ERROR_DS_CANT_MOVE_APP_QUERY_GROUP 0x000021A1 +#define ERROR_DS_ROLE_NOT_VERIFIED 0x000021A2 +#define ERROR_DS_WKO_CONTAINER_CANNOT_BE_SPECIAL 0x000021A3 +#define ERROR_DS_DOMAIN_RENAME_IN_PROGRESS 0x000021A4 +#define ERROR_DS_EXISTING_AD_CHILD_NC 0x000021A5 +#define ERROR_DS_REPL_LIFETIME_EXCEEDED 0x000021A6 +#define ERROR_DS_DISALLOWED_IN_SYSTEM_CONTAINER 0x000021A7 +#define ERROR_DS_LDAP_SEND_QUEUE_FULL 0x000021A8 +#define ERROR_DS_DRA_OUT_SCHEDULE_WINDOW 0x000021A9 +#define ERROR_DS_POLICY_NOT_KNOWN 0x000021AA +#define ERROR_NO_SITE_SETTINGS_OBJECT 0x000021AB +#define ERROR_NO_SECRETS 0x000021AC +#define ERROR_NO_WRITABLE_DC_FOUND 0x000021AD +#define ERROR_DS_NO_SERVER_OBJECT 0x000021AE +#define ERROR_DS_NO_NTDSA_OBJECT 0x000021AF +#define ERROR_DS_NON_ASQ_SEARCH 0x000021B0 +#define ERROR_DS_AUDIT_FAILURE 0x000021B1 +#define ERROR_DS_INVALID_SEARCH_FLAG_SUBTREE 0x000021B2 +#define ERROR_DS_INVALID_SEARCH_FLAG_TUPLE 0x000021B3 +#define ERROR_DS_HIERARCHY_TABLE_TOO_DEEP 0x000021B4 +#define ERROR_DS_DRA_CORRUPT_UTD_VECTOR 0x000021B5 +#define ERROR_DS_DRA_SECRETS_DENIED 0x000021B6 +#define ERROR_DS_RESERVED_MAPI_ID 0x000021B7 +#define ERROR_DS_MAPI_ID_NOT_AVAILABLE 0x000021B8 +#define ERROR_DS_DRA_MISSING_KRBTGT_SECRET 0x000021B9 +#define ERROR_DS_DOMAIN_NAME_EXISTS_IN_FOREST 0x000021BA +#define ERROR_DS_FLAT_NAME_EXISTS_IN_FOREST 0x000021BB +#define ERROR_INVALID_USER_PRINCIPAL_NAME 0x000021BC +#define ERROR_DS_OID_MAPPED_GROUP_CANT_HAVE_MEMBERS 0x000021BD +#define ERROR_DS_OID_NOT_FOUND 0x000021BE +#define ERROR_DS_DRA_RECYCLED_TARGET 0x000021BF +#define ERROR_DS_DISALLOWED_NC_REDIRECT 0x000021C0 +#define ERROR_DS_HIGH_ADLDS_FFL 0x000021C1 +#define ERROR_DS_HIGH_DSA_VERSION 0x000021C2 +#define ERROR_DS_LOW_ADLDS_FFL 0x000021C3 +#define ERROR_DOMAIN_SID_SAME_AS_LOCAL_WORKSTATION 0x000021C4 +#define ERROR_DS_UNDELETE_SAM_VALIDATION_FAILED 0x000021C5 +#define ERROR_INCORRECT_ACCOUNT_TYPE 0x000021C6 + +/* System Error Codes (9000-11999) */ + +#define DNS_ERROR_RCODE_FORMAT_ERROR 0x00002329 +#define DNS_ERROR_RCODE_SERVER_FAILURE 0x0000232A +#define DNS_ERROR_RCODE_NAME_ERROR 0x0000232B +#define DNS_ERROR_RCODE_NOT_IMPLEMENTED 0x0000232C +#define DNS_ERROR_RCODE_REFUSED 0x0000232D +#define DNS_ERROR_RCODE_YXDOMAIN 0x0000232E +#define DNS_ERROR_RCODE_YXRRSET 0x0000232F +#define DNS_ERROR_RCODE_NXRRSET 0x00002330 +#define DNS_ERROR_RCODE_NOTAUTH 0x00002331 +#define DNS_ERROR_RCODE_NOTZONE 0x00002332 +#define DNS_ERROR_RCODE_BADSIG 0x00002338 +#define DNS_ERROR_RCODE_BADKEY 0x00002339 +#define DNS_ERROR_RCODE_BADTIME 0x0000233A +#define DNS_ERROR_KEYMASTER_REQUIRED 0x0000238D +#define DNS_ERROR_NOT_ALLOWED_ON_SIGNED_ZONE 0x0000238E +#define DNS_ERROR_NSEC3_INCOMPATIBLE_WITH_RSA_SHA1 0x0000238F +#define DNS_ERROR_NOT_ENOUGH_SIGNING_KEY_DESCRIPTORS 0x00002390 +#define DNS_ERROR_UNSUPPORTED_ALGORITHM 0x00002391 +#define DNS_ERROR_INVALID_KEY_SIZE 0x00002392 +#define DNS_ERROR_SIGNING_KEY_NOT_ACCESSIBLE 0x00002393 +#define DNS_ERROR_KSP_DOES_NOT_SUPPORT_PROTECTION 0x00002394 +#define DNS_ERROR_UNEXPECTED_DATA_PROTECTION_ERROR 0x00002395 +#define DNS_ERROR_UNEXPECTED_CNG_ERROR 0x00002396 +#define DNS_ERROR_UNKNOWN_SIGNING_PARAMETER_VERSION 0x00002397 +#define DNS_ERROR_KSP_NOT_ACCESSIBLE 0x00002398 +#define DNS_ERROR_TOO_MANY_SKDS 0x00002399 +#define DNS_ERROR_INVALID_ROLLOVER_PERIOD 0x0000239A +#define DNS_ERROR_INVALID_INITIAL_ROLLOVER_OFFSET 0x0000239B +#define DNS_ERROR_ROLLOVER_IN_PROGRESS 0x0000239C +#define DNS_ERROR_STANDBY_KEY_NOT_PRESENT 0x0000239D +#define DNS_ERROR_NOT_ALLOWED_ON_ZSK 0x0000239E +#define DNS_ERROR_NOT_ALLOWED_ON_ACTIVE_SKD 0x0000239F +#define DNS_ERROR_ROLLOVER_ALREADY_QUEUED 0x000023A0 +#define DNS_ERROR_NOT_ALLOWED_ON_UNSIGNED_ZONE 0x000023A1 +#define DNS_ERROR_BAD_KEYMASTER 0x000023A2 +#define DNS_ERROR_INVALID_SIGNATURE_VALIDITY_PERIOD 0x000023A3 +#define DNS_ERROR_INVALID_NSEC3_ITERATION_COUNT 0x000023A4 +#define DNS_ERROR_DNSSEC_IS_DISABLED 0x000023A5 +#define DNS_ERROR_INVALID_XML 0x000023A6 +#define DNS_ERROR_NO_VALID_TRUST_ANCHORS 0x000023A7 +#define DNS_ERROR_ROLLOVER_NOT_POKEABLE 0x000023A8 +#define DNS_ERROR_NSEC3_NAME_COLLISION 0x000023A9 +#define DNS_ERROR_NSEC_INCOMPATIBLE_WITH_NSEC3_RSA_SHA1 0x000023AA +#define DNS_INFO_NO_RECORDS 0x0000251D +#define DNS_ERROR_BAD_PACKET 0x0000251E +#define DNS_ERROR_NO_PACKET 0x0000251F +#define DNS_ERROR_RCODE 0x00002520 +#define DNS_ERROR_UNSECURE_PACKET 0x00002521 +#define DNS_REQUEST_PENDING 0x00002522 +#define DNS_ERROR_INVALID_TYPE 0x0000254F +#define DNS_ERROR_INVALID_IP_ADDRESS 0x00002550 +#define DNS_ERROR_INVALID_PROPERTY 0x00002551 +#define DNS_ERROR_TRY_AGAIN_LATER 0x00002552 +#define DNS_ERROR_NOT_UNIQUE 0x00002553 +#define DNS_ERROR_NON_RFC_NAME 0x00002554 +#define DNS_STATUS_FQDN 0x00002555 +#define DNS_STATUS_DOTTED_NAME 0x00002556 +#define DNS_STATUS_SINGLE_PART_NAME 0x00002557 +#define DNS_ERROR_INVALID_NAME_CHAR 0x00002558 +#define DNS_ERROR_NUMERIC_NAME 0x00002559 +#define DNS_ERROR_NOT_ALLOWED_ON_ROOT_SERVER 0x0000255A +#define DNS_ERROR_NOT_ALLOWED_UNDER_DELEGATION 0x0000255B +#define DNS_ERROR_CANNOT_FIND_ROOT_HINTS 0x0000255C +#define DNS_ERROR_INCONSISTENT_ROOT_HINTS 0x0000255D +#define DNS_ERROR_DWORD_VALUE_TOO_SMALL 0x0000255E +#define DNS_ERROR_DWORD_VALUE_TOO_LARGE 0x0000255F +#define DNS_ERROR_BACKGROUND_LOADING 0x00002560 +#define DNS_ERROR_NOT_ALLOWED_ON_RODC 0x00002561 +#define DNS_ERROR_NOT_ALLOWED_UNDER_DNAME 0x00002562 +#define DNS_ERROR_DELEGATION_REQUIRED 0x00002563 +#define DNS_ERROR_INVALID_POLICY_TABLE 0x00002564 +#define DNS_ERROR_ZONE_DOES_NOT_EXIST 0x00002581 +#define DNS_ERROR_NO_ZONE_INFO 0x00002582 +#define DNS_ERROR_INVALID_ZONE_OPERATION 0x00002583 +#define DNS_ERROR_ZONE_CONFIGURATION_ERROR 0x00002584 +#define DNS_ERROR_ZONE_HAS_NO_SOA_RECORD 0x00002585 +#define DNS_ERROR_ZONE_HAS_NO_NS_RECORDS 0x00002586 +#define DNS_ERROR_ZONE_LOCKED 0x00002587 +#define DNS_ERROR_ZONE_CREATION_FAILED 0x00002588 +#define DNS_ERROR_ZONE_ALREADY_EXISTS 0x00002589 +#define DNS_ERROR_AUTOZONE_ALREADY_EXISTS 0x0000258A +#define DNS_ERROR_INVALID_ZONE_TYPE 0x0000258B +#define DNS_ERROR_SECONDARY_REQUIRES_MASTER_IP 0x0000258C +#define DNS_ERROR_ZONE_NOT_SECONDARY 0x0000258D +#define DNS_ERROR_NEED_SECONDARY_ADDRESSES 0x0000258E +#define DNS_ERROR_WINS_INIT_FAILED 0x0000258F +#define DNS_ERROR_NEED_WINS_SERVERS 0x00002590 +#define DNS_ERROR_NBSTAT_INIT_FAILED 0x00002591 +#define DNS_ERROR_SOA_DELETE_INVALID 0x00002592 +#define DNS_ERROR_FORWARDER_ALREADY_EXISTS 0x00002593 +#define DNS_ERROR_ZONE_REQUIRES_MASTER_IP 0x00002594 +#define DNS_ERROR_ZONE_IS_SHUTDOWN 0x00002595 +#define DNS_ERROR_ZONE_LOCKED_FOR_SIGNING 0x00002596 +#define DNS_ERROR_PRIMARY_REQUIRES_DATAFILE 0x000025B3 +#define DNS_ERROR_INVALID_DATAFILE_NAME 0x000025B4 +#define DNS_ERROR_DATAFILE_OPEN_FAILURE 0x000025B5 +#define DNS_ERROR_FILE_WRITEBACK_FAILED 0x000025B6 +#define DNS_ERROR_DATAFILE_PARSING 0x000025B7 +#define DNS_ERROR_RECORD_DOES_NOT_EXIST 0x000025E5 +#define DNS_ERROR_RECORD_FORMAT 0x000025E6 +#define DNS_ERROR_NODE_CREATION_FAILED 0x000025E7 +#define DNS_ERROR_UNKNOWN_RECORD_TYPE 0x000025E8 +#define DNS_ERROR_RECORD_TIMED_OUT 0x000025E9 +#define DNS_ERROR_NAME_NOT_IN_ZONE 0x000025EA +#define DNS_ERROR_CNAME_LOOP 0x000025EB +#define DNS_ERROR_NODE_IS_CNAME 0x000025EC +#define DNS_ERROR_CNAME_COLLISION 0x000025ED +#define DNS_ERROR_RECORD_ONLY_AT_ZONE_ROOT 0x000025EE +#define DNS_ERROR_RECORD_ALREADY_EXISTS 0x000025EF +#define DNS_ERROR_SECONDARY_DATA 0x000025F0 +#define DNS_ERROR_NO_CREATE_CACHE_DATA 0x000025F1 +#define DNS_ERROR_NAME_DOES_NOT_EXIST 0x000025F2 +#define DNS_WARNING_PTR_CREATE_FAILED 0x000025F3 +#define DNS_WARNING_DOMAIN_UNDELETED 0x000025F4 +#define DNS_ERROR_DS_UNAVAILABLE 0x000025F5 +#define DNS_ERROR_DS_ZONE_ALREADY_EXISTS 0x000025F6 +#define DNS_ERROR_NO_BOOTFILE_IF_DS_ZONE 0x000025F7 +#define DNS_ERROR_NODE_IS_DNAME 0x000025F8 +#define DNS_ERROR_DNAME_COLLISION 0x000025F9 +#define DNS_ERROR_ALIAS_LOOP 0x000025FA +#define DNS_INFO_AXFR_COMPLETE 0x00002617 +#define DNS_ERROR_AXFR 0x00002618 +#define DNS_INFO_ADDED_LOCAL_WINS 0x00002619 +#define DNS_STATUS_CONTINUE_NEEDED 0x00002649 +#define DNS_ERROR_NO_TCPIP 0x0000267B +#define DNS_ERROR_NO_DNS_SERVERS 0x0000267C +#define DNS_ERROR_DP_DOES_NOT_EXIST 0x000026AD +#define DNS_ERROR_DP_ALREADY_EXISTS 0x000026AE +#define DNS_ERROR_DP_NOT_ENLISTED 0x000026AF +#define DNS_ERROR_DP_ALREADY_ENLISTED 0x000026B0 +#define DNS_ERROR_DP_NOT_AVAILABLE 0x000026B1 +#define DNS_ERROR_DP_FSMO_ERROR 0x000026B2 +#define WSAEINTR 0x00002714 +#define WSAEBADF 0x00002719 +#define WSAEACCES 0x0000271D +#define WSAEFAULT 0x0000271E +#define WSAEINVAL 0x00002726 +#define WSAEMFILE 0x00002728 +#define WSAEWOULDBLOCK 0x00002733 +#define WSAEINPROGRESS 0x00002734 +#define WSAEALREADY 0x00002735 +#define WSAENOTSOCK 0x00002736 +#define WSAEDESTADDRREQ 0x00002737 +#define WSAEMSGSIZE 0x00002738 +#define WSAEPROTOTYPE 0x00002739 +#define WSAENOPROTOOPT 0x0000273A +#define WSAEPROTONOSUPPORT 0x0000273B +#define WSAESOCKTNOSUPPORT 0x0000273C +#define WSAEOPNOTSUPP 0x0000273D +#define WSAEPFNOSUPPORT 0x0000273E +#define WSAEAFNOSUPPORT 0x0000273F +#define WSAEADDRINUSE 0x00002740 +#define WSAEADDRNOTAVAIL 0x00002741 +#define WSAENETDOWN 0x00002742 +#define WSAENETUNREACH 0x00002743 +#define WSAENETRESET 0x00002744 +#define WSAECONNABORTED 0x00002745 +#define WSAECONNRESET 0x00002746 +#define WSAENOBUFS 0x00002747 +#define WSAEISCONN 0x00002748 +#define WSAENOTCONN 0x00002749 +#define WSAESHUTDOWN 0x0000274A +#define WSAETOOMANYREFS 0x0000274B +#define WSAETIMEDOUT 0x0000274C +#define WSAECONNREFUSED 0x0000274D +#define WSAELOOP 0x0000274E +#define WSAENAMETOOLONG 0x0000274F +#define WSAEHOSTDOWN 0x00002750 +#define WSAEHOSTUNREACH 0x00002751 +#define WSAENOTEMPTY 0x00002752 +#define WSAEPROCLIM 0x00002753 +#define WSAEUSERS 0x00002754 +#define WSAEDQUOT 0x00002755 +#define WSAESTALE 0x00002756 +#define WSAEREMOTE 0x00002757 +#define WSASYSNOTREADY 0x0000276B +#define WSAVERNOTSUPPORTED 0x0000276C +#define WSANOTINITIALISED 0x0000276D +#define WSAEDISCON 0x00002775 +#define WSAENOMORE 0x00002776 +#define WSAECANCELLED 0x00002777 +#define WSAEINVALIDPROCTABLE 0x00002778 +#define WSAEINVALIDPROVIDER 0x00002779 +#define WSAEPROVIDERFAILEDINIT 0x0000277A +#define WSASYSCALLFAILURE 0x0000277B +#define WSASERVICE_NOT_FOUND 0x0000277C +#define WSATYPE_NOT_FOUND 0x0000277D +#define WSA_E_NO_MORE 0x0000277E +#define WSA_E_CANCELLED 0x0000277F +#define WSAEREFUSED 0x00002780 +#define WSAHOST_NOT_FOUND 0x00002AF9 +#define WSATRY_AGAIN 0x00002AFA +#define WSANO_RECOVERY 0x00002AFB +#define WSANO_DATA 0x00002AFC +#define WSA_QOS_RECEIVERS 0x00002AFD +#define WSA_QOS_SENDERS 0x00002AFE +#define WSA_QOS_NO_SENDERS 0x00002AFF +#define WSA_QOS_NO_RECEIVERS 0x00002B00 +#define WSA_QOS_REQUEST_CONFIRMED 0x00002B01 +#define WSA_QOS_ADMISSION_FAILURE 0x00002B02 +#define WSA_QOS_POLICY_FAILURE 0x00002B03 +#define WSA_QOS_BAD_STYLE 0x00002B04 +#define WSA_QOS_BAD_OBJECT 0x00002B05 +#define WSA_QOS_TRAFFIC_CTRL_ERROR 0x00002B06 +#define WSA_QOS_GENERIC_ERROR 0x00002B07 +#define WSA_QOS_ESERVICETYPE 0x00002B08 +#define WSA_QOS_EFLOWSPEC 0x00002B09 +#define WSA_QOS_EPROVSPECBUF 0x00002B0A +#define WSA_QOS_EFILTERSTYLE 0x00002B0B +#define WSA_QOS_EFILTERTYPE 0x00002B0C +#define WSA_QOS_EFILTERCOUNT 0x00002B0D +#define WSA_QOS_EOBJLENGTH 0x00002B0E +#define WSA_QOS_EFLOWCOUNT 0x00002B0F +#define WSA_QOS_EUNKOWNPSOBJ 0x00002B10 +#define WSA_QOS_EPOLICYOBJ 0x00002B11 +#define WSA_QOS_EFLOWDESC 0x00002B12 +#define WSA_QOS_EPSFLOWSPEC 0x00002B13 +#define WSA_QOS_EPSFILTERSPEC 0x00002B14 +#define WSA_QOS_ESDMODEOBJ 0x00002B15 +#define WSA_QOS_ESHAPERATEOBJ 0x00002B16 +#define WSA_QOS_RESERVED_PETYPE 0x00002B17 +#define WSA_SECURE_HOST_NOT_FOUND 0x00002B18 +#define WSA_IPSEC_NAME_POLICY_ERROR 0x00002B19 + +/* System Error Codes (12000-15999) */ + +/* ERROR_INTERNET_* : (12000 - 12175) defined in WinInet.h */ + +#define ERROR_IPSEC_QM_POLICY_EXISTS 0x000032C8 +#define ERROR_IPSEC_QM_POLICY_NOT_FOUND 0x000032C9 +#define ERROR_IPSEC_QM_POLICY_IN_USE 0x000032CA +#define ERROR_IPSEC_MM_POLICY_EXISTS 0x000032CB +#define ERROR_IPSEC_MM_POLICY_NOT_FOUND 0x000032CC +#define ERROR_IPSEC_MM_POLICY_IN_USE 0x000032CD +#define ERROR_IPSEC_MM_FILTER_EXISTS 0x000032CE +#define ERROR_IPSEC_MM_FILTER_NOT_FOUND 0x000032CF +#define ERROR_IPSEC_TRANSPORT_FILTER_EXISTS 0x000032D0 +#define ERROR_IPSEC_TRANSPORT_FILTER_NOT_FOUND 0x000032D1 +#define ERROR_IPSEC_MM_AUTH_EXISTS 0x000032D2 +#define ERROR_IPSEC_MM_AUTH_NOT_FOUND 0x000032D3 +#define ERROR_IPSEC_MM_AUTH_IN_USE 0x000032D4 +#define ERROR_IPSEC_DEFAULT_MM_POLICY_NOT_FOUND 0x000032D5 +#define ERROR_IPSEC_DEFAULT_MM_AUTH_NOT_FOUND 0x000032D6 +#define ERROR_IPSEC_DEFAULT_QM_POLICY_NOT_FOUND 0x000032D7 +#define ERROR_IPSEC_TUNNEL_FILTER_EXISTS 0x000032D8 +#define ERROR_IPSEC_TUNNEL_FILTER_NOT_FOUND 0x000032D9 +#define ERROR_IPSEC_MM_FILTER_PENDING_DELETION 0x000032DA +#define ERROR_IPSEC_TRANSPORT_FILTER_PENDING_DELETION 0x000032DB +#define ERROR_IPSEC_TUNNEL_FILTER_PENDING_DELETION 0x000032DC +#define ERROR_IPSEC_MM_POLICY_PENDING_DELETION 0x000032DD +#define ERROR_IPSEC_MM_AUTH_PENDING_DELETION 0x000032DE +#define ERROR_IPSEC_QM_POLICY_PENDING_DELETION 0x000032DF +#define WARNING_IPSEC_MM_POLICY_PRUNED 0x000032E0 +#define WARNING_IPSEC_QM_POLICY_PRUNED 0x000032E1 +#define ERROR_IPSEC_IKE_NEG_STATUS_BEGIN 0x000035E8 +#define ERROR_IPSEC_IKE_AUTH_FAIL 0x000035E9 +#define ERROR_IPSEC_IKE_ATTRIB_FAIL 0x000035EA +#define ERROR_IPSEC_IKE_NEGOTIATION_PENDING 0x000035EB +#define ERROR_IPSEC_IKE_GENERAL_PROCESSING_ERROR 0x000035EC +#define ERROR_IPSEC_IKE_TIMED_OUT 0x000035ED +#define ERROR_IPSEC_IKE_NO_CERT 0x000035EE +#define ERROR_IPSEC_IKE_SA_DELETED 0x000035EF +#define ERROR_IPSEC_IKE_SA_REAPED 0x000035F0 +#define ERROR_IPSEC_IKE_MM_ACQUIRE_DROP 0x000035F1 +#define ERROR_IPSEC_IKE_QM_ACQUIRE_DROP 0x000035F2 +#define ERROR_IPSEC_IKE_QUEUE_DROP_MM 0x000035F3 +#define ERROR_IPSEC_IKE_QUEUE_DROP_NO_MM 0x000035F4 +#define ERROR_IPSEC_IKE_DROP_NO_RESPONSE 0x000035F5 +#define ERROR_IPSEC_IKE_MM_DELAY_DROP 0x000035F6 +#define ERROR_IPSEC_IKE_QM_DELAY_DROP 0x000035F7 +#define ERROR_IPSEC_IKE_ERROR 0x000035F8 +#define ERROR_IPSEC_IKE_CRL_FAILED 0x000035F9 +#define ERROR_IPSEC_IKE_INVALID_KEY_USAGE 0x000035FA +#define ERROR_IPSEC_IKE_INVALID_CERT_TYPE 0x000035FB +#define ERROR_IPSEC_IKE_NO_PRIVATE_KEY 0x000035FC +#define ERROR_IPSEC_IKE_SIMULTANEOUS_REKEY 0x000035FD +#define ERROR_IPSEC_IKE_DH_FAIL 0x000035FE +#define ERROR_IPSEC_IKE_CRITICAL_PAYLOAD_NOT_RECOGNIZED 0x000035FF +#define ERROR_IPSEC_IKE_INVALID_HEADER 0x00003600 +#define ERROR_IPSEC_IKE_NO_POLICY 0x00003601 +#define ERROR_IPSEC_IKE_INVALID_SIGNATURE 0x00003602 +#define ERROR_IPSEC_IKE_KERBEROS_ERROR 0x00003603 +#define ERROR_IPSEC_IKE_NO_PUBLIC_KEY 0x00003604 +#define ERROR_IPSEC_IKE_PROCESS_ERR 0x00003605 +#define ERROR_IPSEC_IKE_PROCESS_ERR_SA 0x00003606 +#define ERROR_IPSEC_IKE_PROCESS_ERR_PROP 0x00003607 +#define ERROR_IPSEC_IKE_PROCESS_ERR_TRANS 0x00003608 +#define ERROR_IPSEC_IKE_PROCESS_ERR_KE 0x00003609 +#define ERROR_IPSEC_IKE_PROCESS_ERR_ID 0x0000360A +#define ERROR_IPSEC_IKE_PROCESS_ERR_CERT 0x0000360B +#define ERROR_IPSEC_IKE_PROCESS_ERR_CERT_REQ 0x0000360C +#define ERROR_IPSEC_IKE_PROCESS_ERR_HASH 0x0000360D +#define ERROR_IPSEC_IKE_PROCESS_ERR_SIG 0x0000360E +#define ERROR_IPSEC_IKE_PROCESS_ERR_NONCE 0x0000360F +#define ERROR_IPSEC_IKE_PROCESS_ERR_NOTIFY 0x00003610 +#define ERROR_IPSEC_IKE_PROCESS_ERR_DELETE 0x00003611 +#define ERROR_IPSEC_IKE_PROCESS_ERR_VENDOR 0x00003612 +#define ERROR_IPSEC_IKE_INVALID_PAYLOAD 0x00003613 +#define ERROR_IPSEC_IKE_LOAD_SOFT_SA 0x00003614 +#define ERROR_IPSEC_IKE_SOFT_SA_TORN_DOWN 0x00003615 +#define ERROR_IPSEC_IKE_INVALID_COOKIE 0x00003616 +#define ERROR_IPSEC_IKE_NO_PEER_CERT 0x00003617 +#define ERROR_IPSEC_IKE_PEER_CRL_FAILED 0x00003618 +#define ERROR_IPSEC_IKE_POLICY_CHANGE 0x00003619 +#define ERROR_IPSEC_IKE_NO_MM_POLICY 0x0000361A +#define ERROR_IPSEC_IKE_NOTCBPRIV 0x0000361B +#define ERROR_IPSEC_IKE_SECLOADFAIL 0x0000361C +#define ERROR_IPSEC_IKE_FAILSSPINIT 0x0000361D +#define ERROR_IPSEC_IKE_FAILQUERYSSP 0x0000361E +#define ERROR_IPSEC_IKE_SRVACQFAIL 0x0000361F +#define ERROR_IPSEC_IKE_SRVQUERYCRED 0x00003620 +#define ERROR_IPSEC_IKE_GETSPIFAIL 0x00003621 +#define ERROR_IPSEC_IKE_INVALID_FILTER 0x00003622 +#define ERROR_IPSEC_IKE_OUT_OF_MEMORY 0x00003623 +#define ERROR_IPSEC_IKE_ADD_UPDATE_KEY_FAILED 0x00003624 +#define ERROR_IPSEC_IKE_INVALID_POLICY 0x00003625 +#define ERROR_IPSEC_IKE_UNKNOWN_DOI 0x00003626 +#define ERROR_IPSEC_IKE_INVALID_SITUATION 0x00003627 +#define ERROR_IPSEC_IKE_DH_FAILURE 0x00003628 +#define ERROR_IPSEC_IKE_INVALID_GROUP 0x00003629 +#define ERROR_IPSEC_IKE_ENCRYPT 0x0000362A +#define ERROR_IPSEC_IKE_DECRYPT 0x0000362B +#define ERROR_IPSEC_IKE_POLICY_MATCH 0x0000362C +#define ERROR_IPSEC_IKE_UNSUPPORTED_ID 0x0000362D +#define ERROR_IPSEC_IKE_INVALID_HASH 0x0000362E +#define ERROR_IPSEC_IKE_INVALID_HASH_ALG 0x0000362F +#define ERROR_IPSEC_IKE_INVALID_HASH_SIZE 0x00003630 +#define ERROR_IPSEC_IKE_INVALID_ENCRYPT_ALG 0x00003631 +#define ERROR_IPSEC_IKE_INVALID_AUTH_ALG 0x00003632 +#define ERROR_IPSEC_IKE_INVALID_SIG 0x00003633 +#define ERROR_IPSEC_IKE_LOAD_FAILED 0x00003634 +#define ERROR_IPSEC_IKE_RPC_DELETE 0x00003635 +#define ERROR_IPSEC_IKE_BENIGN_REINIT 0x00003636 +#define ERROR_IPSEC_IKE_INVALID_RESPONDER_LIFETIME_NOTIFY 0x00003637 +#define ERROR_IPSEC_IKE_INVALID_MAJOR_VERSION 0x00003638 +#define ERROR_IPSEC_IKE_INVALID_CERT_KEYLEN 0x00003639 +#define ERROR_IPSEC_IKE_MM_LIMIT 0x0000363A +#define ERROR_IPSEC_IKE_NEGOTIATION_DISABLED 0x0000363B +#define ERROR_IPSEC_IKE_QM_LIMIT 0x0000363C +#define ERROR_IPSEC_IKE_MM_EXPIRED 0x0000363D +#define ERROR_IPSEC_IKE_PEER_MM_ASSUMED_INVALID 0x0000363E +#define ERROR_IPSEC_IKE_CERT_CHAIN_POLICY_MISMATCH 0x0000363F +#define ERROR_IPSEC_IKE_UNEXPECTED_MESSAGE_ID 0x00003640 +#define ERROR_IPSEC_IKE_INVALID_AUTH_PAYLOAD 0x00003641 +#define ERROR_IPSEC_IKE_DOS_COOKIE_SENT 0x00003642 +#define ERROR_IPSEC_IKE_SHUTTING_DOWN 0x00003643 +#define ERROR_IPSEC_IKE_CGA_AUTH_FAILED 0x00003644 +#define ERROR_IPSEC_IKE_PROCESS_ERR_NATOA 0x00003645 +#define ERROR_IPSEC_IKE_INVALID_MM_FOR_QM 0x00003646 +#define ERROR_IPSEC_IKE_QM_EXPIRED 0x00003647 +#define ERROR_IPSEC_IKE_TOO_MANY_FILTERS 0x00003648 +#define ERROR_IPSEC_IKE_NEG_STATUS_END 0x00003649 +#define ERROR_IPSEC_IKE_KILL_DUMMY_NAP_TUNNEL 0x0000364A +#define ERROR_IPSEC_IKE_INNER_IP_ASSIGNMENT_FAILURE 0x0000364B +#define ERROR_IPSEC_IKE_REQUIRE_CP_PAYLOAD_MISSING 0x0000364C +#define ERROR_IPSEC_KEY_MODULE_IMPERSONATION_NEGOTIATION_PENDING 0x0000364D +#define ERROR_IPSEC_IKE_COEXISTENCE_SUPPRESS 0x0000364E +#define ERROR_IPSEC_IKE_RATELIMIT_DROP 0x0000364F +#define ERROR_IPSEC_IKE_PEER_DOESNT_SUPPORT_MOBIKE 0x00003650 +#define ERROR_IPSEC_IKE_AUTHORIZATION_FAILURE 0x00003651 +#define ERROR_IPSEC_IKE_STRONG_CRED_AUTHORIZATION_FAILURE 0x00003652 +#define ERROR_IPSEC_IKE_AUTHORIZATION_FAILURE_WITH_OPTIONAL_RETRY 0x00003653 +#define ERROR_IPSEC_IKE_STRONG_CRED_AUTHORIZATION_AND_CERTMAP_FAILURE 0x00003654 +#define ERROR_IPSEC_IKE_NEG_STATUS_EXTENDED_END 0x00003655 +#define ERROR_IPSEC_BAD_SPI 0x00003656 +#define ERROR_IPSEC_SA_LIFETIME_EXPIRED 0x00003657 +#define ERROR_IPSEC_WRONG_SA 0x00003658 +#define ERROR_IPSEC_REPLAY_CHECK_FAILED 0x00003659 +#define ERROR_IPSEC_INVALID_PACKET 0x0000365A +#define ERROR_IPSEC_INTEGRITY_CHECK_FAILED 0x0000365B +#define ERROR_IPSEC_CLEAR_TEXT_DROP 0x0000365C +#define ERROR_IPSEC_AUTH_FIREWALL_DROP 0x0000365D +#define ERROR_IPSEC_THROTTLE_DROP 0x0000365E +#define ERROR_IPSEC_DOSP_BLOCK 0x00003665 +#define ERROR_IPSEC_DOSP_RECEIVED_MULTICAST 0x00003666 +#define ERROR_IPSEC_DOSP_INVALID_PACKET 0x00003667 +#define ERROR_IPSEC_DOSP_STATE_LOOKUP_FAILED 0x00003668 +#define ERROR_IPSEC_DOSP_MAX_ENTRIES 0x00003669 +#define ERROR_IPSEC_DOSP_KEYMOD_NOT_ALLOWED 0x0000366A +#define ERROR_IPSEC_DOSP_NOT_INSTALLED 0x0000366B +#define ERROR_IPSEC_DOSP_MAX_PER_IP_RATELIMIT_QUEUES 0x0000366C +#define ERROR_SXS_SECTION_NOT_FOUND 0x000036B0 +#define ERROR_SXS_CANT_GEN_ACTCTX 0x000036B1 +#define ERROR_SXS_INVALID_ACTCTXDATA_FORMAT 0x000036B2 +#define ERROR_SXS_ASSEMBLY_NOT_FOUND 0x000036B3 +#define ERROR_SXS_MANIFEST_FORMAT_ERROR 0x000036B4 +#define ERROR_SXS_MANIFEST_PARSE_ERROR 0x000036B5 +#define ERROR_SXS_ACTIVATION_CONTEXT_DISABLED 0x000036B6 +#define ERROR_SXS_KEY_NOT_FOUND 0x000036B7 +#define ERROR_SXS_VERSION_CONFLICT 0x000036B8 +#define ERROR_SXS_WRONG_SECTION_TYPE 0x000036B9 +#define ERROR_SXS_THREAD_QUERIES_DISABLED 0x000036BA +#define ERROR_SXS_PROCESS_DEFAULT_ALREADY_SET 0x000036BB +#define ERROR_SXS_UNKNOWN_ENCODING_GROUP 0x000036BC +#define ERROR_SXS_UNKNOWN_ENCODING 0x000036BD +#define ERROR_SXS_INVALID_XML_NAMESPACE_URI 0x000036BE +#define ERROR_SXS_ROOT_MANIFEST_DEPENDENCY_NOT_INSTALLED 0x000036BF +#define ERROR_SXS_LEAF_MANIFEST_DEPENDENCY_NOT_INSTALLED 0x000036C0 +#define ERROR_SXS_INVALID_ASSEMBLY_IDENTITY_ATTRIBUTE 0x000036C1 +#define ERROR_SXS_MANIFEST_MISSING_REQUIRED_DEFAULT_NAMESPACE 0x000036C2 +#define ERROR_SXS_MANIFEST_INVALID_REQUIRED_DEFAULT_NAMESPACE 0x000036C3 +#define ERROR_SXS_PRIVATE_MANIFEST_CROSS_PATH_WITH_REPARSE_POINT 0x000036C4 +#define ERROR_SXS_DUPLICATE_DLL_NAME 0x000036C5 +#define ERROR_SXS_DUPLICATE_WINDOWCLASS_NAME 0x000036C6 +#define ERROR_SXS_DUPLICATE_CLSID 0x000036C7 +#define ERROR_SXS_DUPLICATE_IID 0x000036C8 +#define ERROR_SXS_DUPLICATE_TLBID 0x000036C9 +#define ERROR_SXS_DUPLICATE_PROGID 0x000036CA +#define ERROR_SXS_DUPLICATE_ASSEMBLY_NAME 0x000036CB +#define ERROR_SXS_FILE_HASH_MISMATCH 0x000036CC +#define ERROR_SXS_POLICY_PARSE_ERROR 0x000036CD +#define ERROR_SXS_XML_E_MISSINGQUOTE 0x000036CE +#define ERROR_SXS_XML_E_COMMENTSYNTAX 0x000036CF +#define ERROR_SXS_XML_E_BADSTARTNAMECHAR 0x000036D0 +#define ERROR_SXS_XML_E_BADNAMECHAR 0x000036D1 +#define ERROR_SXS_XML_E_BADCHARINSTRING 0x000036D2 +#define ERROR_SXS_XML_E_XMLDECLSYNTAX 0x000036D3 +#define ERROR_SXS_XML_E_BADCHARDATA 0x000036D4 +#define ERROR_SXS_XML_E_MISSINGWHITESPACE 0x000036D5 +#define ERROR_SXS_XML_E_EXPECTINGTAGEND 0x000036D6 +#define ERROR_SXS_XML_E_MISSINGSEMICOLON 0x000036D7 +#define ERROR_SXS_XML_E_UNBALANCEDPAREN 0x000036D8 +#define ERROR_SXS_XML_E_INTERNALERROR 0x000036D9 +#define ERROR_SXS_XML_E_UNEXPECTED_WHITESPACE 0x000036DA +#define ERROR_SXS_XML_E_INCOMPLETE_ENCODING 0x000036DB +#define ERROR_SXS_XML_E_MISSING_PAREN 0x000036DC +#define ERROR_SXS_XML_E_EXPECTINGCLOSEQUOTE 0x000036DD +#define ERROR_SXS_XML_E_MULTIPLE_COLONS 0x000036DE +#define ERROR_SXS_XML_E_INVALID_DECIMAL 0x000036DF +#define ERROR_SXS_XML_E_INVALID_HEXIDECIMAL 0x000036E0 +#define ERROR_SXS_XML_E_INVALID_UNICODE 0x000036E1 +#define ERROR_SXS_XML_E_WHITESPACEORQUESTIONMARK 0x000036E2 +#define ERROR_SXS_XML_E_UNEXPECTEDENDTAG 0x000036E3 +#define ERROR_SXS_XML_E_UNCLOSEDTAG 0x000036E4 +#define ERROR_SXS_XML_E_DUPLICATEATTRIBUTE 0x000036E5 +#define ERROR_SXS_XML_E_MULTIPLEROOTS 0x000036E6 +#define ERROR_SXS_XML_E_INVALIDATROOTLEVEL 0x000036E7 +#define ERROR_SXS_XML_E_BADXMLDECL 0x000036E8 +#define ERROR_SXS_XML_E_MISSINGROOT 0x000036E9 +#define ERROR_SXS_XML_E_UNEXPECTEDEOF 0x000036EA +#define ERROR_SXS_XML_E_BADPEREFINSUBSET 0x000036EB +#define ERROR_SXS_XML_E_UNCLOSEDSTARTTAG 0x000036EC +#define ERROR_SXS_XML_E_UNCLOSEDENDTAG 0x000036ED +#define ERROR_SXS_XML_E_UNCLOSEDSTRING 0x000036EE +#define ERROR_SXS_XML_E_UNCLOSEDCOMMENT 0x000036EF +#define ERROR_SXS_XML_E_UNCLOSEDDECL 0x000036F0 +#define ERROR_SXS_XML_E_UNCLOSEDCDATA 0x000036F1 +#define ERROR_SXS_XML_E_RESERVEDNAMESPACE 0x000036F2 +#define ERROR_SXS_XML_E_INVALIDENCODING 0x000036F3 +#define ERROR_SXS_XML_E_INVALIDSWITCH 0x000036F4 +#define ERROR_SXS_XML_E_BADXMLCASE 0x000036F5 +#define ERROR_SXS_XML_E_INVALID_STANDALONE 0x000036F6 +#define ERROR_SXS_XML_E_UNEXPECTED_STANDALONE 0x000036F7 +#define ERROR_SXS_XML_E_INVALID_VERSION 0x000036F8 +#define ERROR_SXS_XML_E_MISSINGEQUALS 0x000036F9 +#define ERROR_SXS_PROTECTION_RECOVERY_FAILED 0x000036FA +#define ERROR_SXS_PROTECTION_PUBLIC_KEY_TOO_SHORT 0x000036FB +#define ERROR_SXS_PROTECTION_CATALOG_NOT_VALID 0x000036FC +#define ERROR_SXS_UNTRANSLATABLE_HRESULT 0x000036FD +#define ERROR_SXS_PROTECTION_CATALOG_FILE_MISSING 0x000036FE +#define ERROR_SXS_MISSING_ASSEMBLY_IDENTITY_ATTRIBUTE 0x000036FF +#define ERROR_SXS_INVALID_ASSEMBLY_IDENTITY_ATTRIBUTE_NAME 0x00003700 +#define ERROR_SXS_ASSEMBLY_MISSING 0x00003701 +#define ERROR_SXS_CORRUPT_ACTIVATION_STACK 0x00003702 +#define ERROR_SXS_CORRUPTION 0x00003703 +#define ERROR_SXS_EARLY_DEACTIVATION 0x00003704 +#define ERROR_SXS_INVALID_DEACTIVATION 0x00003705 +#define ERROR_SXS_MULTIPLE_DEACTIVATION 0x00003706 +#define ERROR_SXS_PROCESS_TERMINATION_REQUESTED 0x00003707 +#define ERROR_SXS_RELEASE_ACTIVATION_CONTEXT 0x00003708 +#define ERROR_SXS_SYSTEM_DEFAULT_ACTIVATION_CONTEXT_EMPTY 0x00003709 +#define ERROR_SXS_INVALID_IDENTITY_ATTRIBUTE_VALUE 0x0000370A +#define ERROR_SXS_INVALID_IDENTITY_ATTRIBUTE_NAME 0x0000370B +#define ERROR_SXS_IDENTITY_DUPLICATE_ATTRIBUTE 0x0000370C +#define ERROR_SXS_IDENTITY_PARSE_ERROR 0x0000370D +#define ERROR_MALFORMED_SUBSTITUTION_STRING 0x0000370E +#define ERROR_SXS_INCORRECT_PUBLIC_KEY_TOKEN 0x0000370F +#define ERROR_UNMAPPED_SUBSTITUTION_STRING 0x00003710 +#define ERROR_SXS_ASSEMBLY_NOT_LOCKED 0x00003711 +#define ERROR_SXS_COMPONENT_STORE_CORRUPT 0x00003712 +#define ERROR_ADVANCED_INSTALLER_FAILED 0x00003713 +#define ERROR_XML_ENCODING_MISMATCH 0x00003714 +#define ERROR_SXS_MANIFEST_IDENTITY_SAME_BUT_CONTENTS_DIFFERENT 0x00003715 +#define ERROR_SXS_IDENTITIES_DIFFERENT 0x00003716 +#define ERROR_SXS_ASSEMBLY_IS_NOT_A_DEPLOYMENT 0x00003717 +#define ERROR_SXS_FILE_NOT_PART_OF_ASSEMBLY 0x00003718 +#define ERROR_SXS_MANIFEST_TOO_BIG 0x00003719 +#define ERROR_SXS_SETTING_NOT_REGISTERED 0x0000371A +#define ERROR_SXS_TRANSACTION_CLOSURE_INCOMPLETE 0x0000371B +#define ERROR_SMI_PRIMITIVE_INSTALLER_FAILED 0x0000371C +#define ERROR_GENERIC_COMMAND_FAILED 0x0000371D +#define ERROR_SXS_FILE_HASH_MISSING 0x0000371E +#define ERROR_EVT_INVALID_CHANNEL_PATH 0x00003A98 +#define ERROR_EVT_INVALID_QUERY 0x00003A99 +#define ERROR_EVT_PUBLISHER_METADATA_NOT_FOUND 0x00003A9A +#define ERROR_EVT_EVENT_TEMPLATE_NOT_FOUND 0x00003A9B +#define ERROR_EVT_INVALID_PUBLISHER_NAME 0x00003A9C +#define ERROR_EVT_INVALID_EVENT_DATA 0x00003A9D +#define ERROR_EVT_CHANNEL_NOT_FOUND 0x00003A9F +#define ERROR_EVT_MALFORMED_XML_TEXT 0x00003AA0 +#define ERROR_EVT_SUBSCRIPTION_TO_DIRECT_CHANNEL 0x00003AA1 +#define ERROR_EVT_CONFIGURATION_ERROR 0x00003AA2 +#define ERROR_EVT_QUERY_RESULT_STALE 0x00003AA3 +#define ERROR_EVT_QUERY_RESULT_INVALID_POSITION 0x00003AA4 +#define ERROR_EVT_NON_VALIDATING_MSXML 0x00003AA5 +#define ERROR_EVT_FILTER_ALREADYSCOPED 0x00003AA6 +#define ERROR_EVT_FILTER_NOTELTSET 0x00003AA7 +#define ERROR_EVT_FILTER_INVARG 0x00003AA8 +#define ERROR_EVT_FILTER_INVTEST 0x00003AA9 +#define ERROR_EVT_FILTER_INVTYPE 0x00003AAA +#define ERROR_EVT_FILTER_PARSEERR 0x00003AAB +#define ERROR_EVT_FILTER_UNSUPPORTEDOP 0x00003AAC +#define ERROR_EVT_FILTER_UNEXPECTEDTOKEN 0x00003AAD +#define ERROR_EVT_INVALID_OPERATION_OVER_ENABLED_DIRECT_CHANNEL 0x00003AAE +#define ERROR_EVT_INVALID_CHANNEL_PROPERTY_VALUE 0x00003AAF +#define ERROR_EVT_INVALID_PUBLISHER_PROPERTY_VALUE 0x00003AB0 +#define ERROR_EVT_CHANNEL_CANNOT_ACTIVATE 0x00003AB1 +#define ERROR_EVT_FILTER_TOO_COMPLEX 0x00003AB2 +#define ERROR_EVT_MESSAGE_NOT_FOUND 0x00003AB3 +#define ERROR_EVT_MESSAGE_ID_NOT_FOUND 0x00003AB4 +#define ERROR_EVT_UNRESOLVED_VALUE_INSERT 0x00003AB5 +#define ERROR_EVT_UNRESOLVED_PARAMETER_INSERT 0x00003AB6 +#define ERROR_EVT_MAX_INSERTS_REACHED 0x00003AB7 +#define ERROR_EVT_EVENT_DEFINITION_NOT_FOUND 0x00003AB8 +#define ERROR_EVT_MESSAGE_LOCALE_NOT_FOUND 0x00003AB9 +#define ERROR_EVT_VERSION_TOO_OLD 0x00003ABA +#define ERROR_EVT_VERSION_TOO_NEW 0x00003ABB +#define ERROR_EVT_CANNOT_OPEN_CHANNEL_OF_QUERY 0x00003ABC +#define ERROR_EVT_PUBLISHER_DISABLED 0x00003ABD +#define ERROR_EVT_FILTER_OUT_OF_RANGE 0x00003ABE +#define ERROR_EC_SUBSCRIPTION_CANNOT_ACTIVATE 0x00003AE8 +#define ERROR_EC_LOG_DISABLED 0x00003AE9 +#define ERROR_EC_CIRCULAR_FORWARDING 0x00003AEA +#define ERROR_EC_CREDSTORE_FULL 0x00003AEB +#define ERROR_EC_CRED_NOT_FOUND 0x00003AEC +#define ERROR_EC_NO_ACTIVE_CHANNEL 0x00003AED +#define ERROR_MUI_FILE_NOT_FOUND 0x00003AFC +#define ERROR_MUI_INVALID_FILE 0x00003AFD +#define ERROR_MUI_INVALID_RC_CONFIG 0x00003AFE +#define ERROR_MUI_INVALID_LOCALE_NAME 0x00003AFF +#define ERROR_MUI_INVALID_ULTIMATEFALLBACK_NAME 0x00003B00 +#define ERROR_MUI_FILE_NOT_LOADED 0x00003B01 +#define ERROR_RESOURCE_ENUM_USER_STOP 0x00003B02 +#define ERROR_MUI_INTLSETTINGS_UILANG_NOT_INSTALLED 0x00003B03 +#define ERROR_MUI_INTLSETTINGS_INVALID_LOCALE_NAME 0x00003B04 +#define ERROR_MRM_RUNTIME_NO_DEFAULT_OR_NEUTRAL_RESOURCE 0x00003B06 +#define ERROR_MRM_INVALID_PRICONFIG 0x00003B07 +#define ERROR_MRM_INVALID_FILE_TYPE 0x00003B08 +#define ERROR_MRM_UNKNOWN_QUALIFIER 0x00003B09 +#define ERROR_MRM_INVALID_QUALIFIER_VALUE 0x00003B0A +#define ERROR_MRM_NO_CANDIDATE 0x00003B0B +#define ERROR_MRM_NO_MATCH_OR_DEFAULT_CANDIDATE 0x00003B0C +#define ERROR_MRM_RESOURCE_TYPE_MISMATCH 0x00003B0D +#define ERROR_MRM_DUPLICATE_MAP_NAME 0x00003B0E +#define ERROR_MRM_DUPLICATE_ENTRY 0x00003B0F +#define ERROR_MRM_INVALID_RESOURCE_IDENTIFIER 0x00003B10 +#define ERROR_MRM_FILEPATH_TOO_LONG 0x00003B11 +#define ERROR_MRM_UNSUPPORTED_DIRECTORY_TYPE 0x00003B12 +#define ERROR_MRM_INVALID_PRI_FILE 0x00003B16 +#define ERROR_MRM_NAMED_RESOURCE_NOT_FOUND 0x00003B17 +#define ERROR_MRM_MAP_NOT_FOUND 0x00003B1F +#define ERROR_MRM_UNSUPPORTED_PROFILE_TYPE 0x00003B20 +#define ERROR_MRM_INVALID_QUALIFIER_OPERATOR 0x00003B21 +#define ERROR_MRM_INDETERMINATE_QUALIFIER_VALUE 0x00003B22 +#define ERROR_MRM_AUTOMERGE_ENABLED 0x00003B23 +#define ERROR_MRM_TOO_MANY_RESOURCES 0x00003B24 +#define ERROR_MCA_INVALID_CAPABILITIES_STRING 0x00003B60 +#define ERROR_MCA_INVALID_VCP_VERSION 0x00003B61 +#define ERROR_MCA_MONITOR_VIOLATES_MCCS_SPECIFICATION 0x00003B62 +#define ERROR_MCA_MCCS_VERSION_MISMATCH 0x00003B63 +#define ERROR_MCA_UNSUPPORTED_MCCS_VERSION 0x00003B64 +#define ERROR_MCA_INTERNAL_ERROR 0x00003B65 +#define ERROR_MCA_INVALID_TECHNOLOGY_TYPE_RETURNED 0x00003B66 +#define ERROR_MCA_UNSUPPORTED_COLOR_TEMPERATURE 0x00003B67 +#define ERROR_AMBIGUOUS_SYSTEM_DEVICE 0x00003B92 +#define ERROR_SYSTEM_DEVICE_NOT_FOUND 0x00003BC3 +#define ERROR_HASH_NOT_SUPPORTED 0x00003BC4 +#define ERROR_HASH_NOT_PRESENT 0x00003BC5 +#define ERROR_SECONDARY_IC_PROVIDER_NOT_REGISTERED 0x00003BD9 +#define ERROR_GPIO_CLIENT_INFORMATION_INVALID 0x00003BDA +#define ERROR_GPIO_VERSION_NOT_SUPPORTED 0x00003BDB +#define ERROR_GPIO_INVALID_REGISTRATION_PACKET 0x00003BDC +#define ERROR_GPIO_OPERATION_DENIED 0x00003BDD +#define ERROR_GPIO_INCOMPATIBLE_CONNECT_MODE 0x00003BDE +#define ERROR_GPIO_INTERRUPT_ALREADY_UNMASKED 0x00003BDF +#define ERROR_CANNOT_SWITCH_RUNLEVEL 0x00003C28 +#define ERROR_INVALID_RUNLEVEL_SETTING 0x00003C29 +#define ERROR_RUNLEVEL_SWITCH_TIMEOUT 0x00003C2A +#define ERROR_RUNLEVEL_SWITCH_AGENT_TIMEOUT 0x00003C2B +#define ERROR_RUNLEVEL_SWITCH_IN_PROGRESS 0x00003C2C +#define ERROR_SERVICES_FAILED_AUTOSTART 0x00003C2D +#define ERROR_COM_TASK_STOP_PENDING 0x00003C8D +#define ERROR_INSTALL_OPEN_PACKAGE_FAILED 0x00003CF0 +#define ERROR_INSTALL_PACKAGE_NOT_FOUND 0x00003CF1 +#define ERROR_INSTALL_INVALID_PACKAGE 0x00003CF2 +#define ERROR_INSTALL_RESOLVE_DEPENDENCY_FAILED 0x00003CF3 +#define ERROR_INSTALL_OUT_OF_DISK_SPACE 0x00003CF4 +#define ERROR_INSTALL_NETWORK_FAILURE 0x00003CF5 +#define ERROR_INSTALL_REGISTRATION_FAILURE 0x00003CF6 +#define ERROR_INSTALL_DEREGISTRATION_FAILURE 0x00003CF7 +#define ERROR_INSTALL_CANCEL 0x00003CF8 +#define ERROR_INSTALL_FAILED 0x00003CF9 +#define ERROR_REMOVE_FAILED 0x00003CFA +#define ERROR_PACKAGE_ALREADY_EXISTS 0x00003CFB +#define ERROR_NEEDS_REMEDIATION 0x00003CFC +#define ERROR_INSTALL_PREREQUISITE_FAILED 0x00003CFD +#define ERROR_PACKAGE_REPOSITORY_CORRUPTED 0x00003CFE +#define ERROR_INSTALL_POLICY_FAILURE 0x00003CFF +#define ERROR_PACKAGE_UPDATING 0x00003D00 +#define ERROR_DEPLOYMENT_BLOCKED_BY_POLICY 0x00003D01 +#define ERROR_PACKAGES_IN_USE 0x00003D02 +#define ERROR_RECOVERY_FILE_CORRUPT 0x00003D03 +#define ERROR_INVALID_STAGED_SIGNATURE 0x00003D04 +#define ERROR_DELETING_EXISTING_APPLICATIONDATA_STORE_FAILED 0x00003D05 +#define ERROR_INSTALL_PACKAGE_DOWNGRADE 0x00003D06 +#define ERROR_SYSTEM_NEEDS_REMEDIATION 0x00003D07 +#define ERROR_APPX_INTEGRITY_FAILURE_CLR_NGEN 0x00003D08 +#define ERROR_RESILIENCY_FILE_CORRUPT 0x00003D09 +#define ERROR_INSTALL_FIREWALL_SERVICE_NOT_RUNNING 0x00003D0A +#define APPMODEL_ERROR_NO_PACKAGE 0x00003D54 +#define APPMODEL_ERROR_PACKAGE_RUNTIME_CORRUPT 0x00003D55 +#define APPMODEL_ERROR_PACKAGE_IDENTITY_CORRUPT 0x00003D56 +#define APPMODEL_ERROR_NO_APPLICATION 0x00003D57 +#define ERROR_STATE_LOAD_STORE_FAILED 0x00003DB8 +#define ERROR_STATE_GET_VERSION_FAILED 0x00003DB9 +#define ERROR_STATE_SET_VERSION_FAILED 0x00003DBA +#define ERROR_STATE_STRUCTURED_RESET_FAILED 0x00003DBB +#define ERROR_STATE_OPEN_CONTAINER_FAILED 0x00003DBC +#define ERROR_STATE_CREATE_CONTAINER_FAILED 0x00003DBD +#define ERROR_STATE_DELETE_CONTAINER_FAILED 0x00003DBE +#define ERROR_STATE_READ_SETTING_FAILED 0x00003DBF +#define ERROR_STATE_WRITE_SETTING_FAILED 0x00003DC0 +#define ERROR_STATE_DELETE_SETTING_FAILED 0x00003DC1 +#define ERROR_STATE_QUERY_SETTING_FAILED 0x00003DC2 +#define ERROR_STATE_READ_COMPOSITE_SETTING_FAILED 0x00003DC3 +#define ERROR_STATE_WRITE_COMPOSITE_SETTING_FAILED 0x00003DC4 +#define ERROR_STATE_ENUMERATE_CONTAINER_FAILED 0x00003DC5 +#define ERROR_STATE_ENUMERATE_SETTINGS_FAILED 0x00003DC6 +#define ERROR_STATE_COMPOSITE_SETTING_VALUE_SIZE_LIMIT_EXCEEDED 0x00003DC7 +#define ERROR_STATE_SETTING_VALUE_SIZE_LIMIT_EXCEEDED 0x00003DC8 +#define ERROR_STATE_SETTING_NAME_SIZE_LIMIT_EXCEEDED 0x00003DC9 +#define ERROR_STATE_CONTAINER_NAME_SIZE_LIMIT_EXCEEDED 0x00003DCA +#define ERROR_API_UNAVAILABLE 0x00003DE1 + +#ifndef FACILITY_WEBSERVICES +#define FACILITY_WEBSERVICES 61 +#define WS_S_ASYNC 0x003D0000 +#define WS_S_END 0x003D0001 +#define WS_E_INVALID_FORMAT 0x803D0000 +#define WS_E_OBJECT_FAULTED 0x803D0001 +#define WS_E_NUMERIC_OVERFLOW 0x803D0002 +#define WS_E_INVALID_OPERATION 0x803D0003 +#define WS_E_OPERATION_ABORTED 0x803D0004 +#define WS_E_ENDPOINT_ACCESS_DENIED 0x803D0005 +#define WS_E_OPERATION_TIMED_OUT 0x803D0006 +#define WS_E_OPERATION_ABANDONED 0x803D0007 +#define WS_E_QUOTA_EXCEEDED 0x803D0008 +#define WS_E_NO_TRANSLATION_AVAILABLE 0x803D0009 +#define WS_E_SECURITY_VERIFICATION_FAILURE 0x803D000A +#define WS_E_ADDRESS_IN_USE 0x803D000B +#define WS_E_ADDRESS_NOT_AVAILABLE 0x803D000C +#define WS_E_ENDPOINT_NOT_FOUND 0x803D000D +#define WS_E_ENDPOINT_NOT_AVAILABLE 0x803D000E +#define WS_E_ENDPOINT_FAILURE 0x803D000F +#define WS_E_ENDPOINT_UNREACHABLE 0x803D0010 +#define WS_E_ENDPOINT_ACTION_NOT_SUPPORTED 0x803D0011 +#define WS_E_ENDPOINT_TOO_BUSY 0x803D0012 +#define WS_E_ENDPOINT_FAULT_RECEIVED 0x803D0013 +#define WS_E_ENDPOINT_DISCONNECTED 0x803D0014 +#define WS_E_PROXY_FAILURE 0x803D0015 +#define WS_E_PROXY_ACCESS_DENIED 0x803D0016 +#define WS_E_NOT_SUPPORTED 0x803D0017 +#define WS_E_PROXY_REQUIRES_BASIC_AUTH 0x803D0018 +#define WS_E_PROXY_REQUIRES_DIGEST_AUTH 0x803D0019 +#define WS_E_PROXY_REQUIRES_NTLM_AUTH 0x803D001A +#define WS_E_PROXY_REQUIRES_NEGOTIATE_AUTH 0x803D001B +#define WS_E_SERVER_REQUIRES_BASIC_AUTH 0x803D001C +#define WS_E_SERVER_REQUIRES_DIGEST_AUTH 0x803D001D +#define WS_E_SERVER_REQUIRES_NTLM_AUTH 0x803D001E +#define WS_E_SERVER_REQUIRES_NEGOTIATE_AUTH 0x803D001F +#define WS_E_INVALID_ENDPOINT_URL 0x803D0020 +#define WS_E_OTHER 0x803D0021 +#define WS_E_SECURITY_TOKEN_EXPIRED 0x803D0022 +#define WS_E_SECURITY_SYSTEM_FAILURE 0x803D0023 +#endif + +#define NTE_BAD_UID (0x80090001) +#define NTE_BAD_HASH (0x80090002) +#define NTE_BAD_KEY (0x80090003) +#define NTE_BAD_LEN (0x80090004) +#define NTE_BAD_DATA (0x80090005) +#define NTE_BAD_SIGNATURE (0x80090006) +#define NTE_BAD_VER (0x80090007) +#define NTE_BAD_ALGID (0x80090008) +#define NTE_BAD_FLAGS (0x80090009) +#define NTE_BAD_TYPE (0x8009000A) +#define NTE_BAD_KEY_STATE (0x8009000B) +#define NTE_BAD_HASH_STATE (0x8009000C) +#define NTE_NO_KEY (0x8009000D) +#define NTE_NO_MEMORY (0x8009000E) +#define NTE_EXISTS (0x8009000F) +#define NTE_PERM (0x80090010) +#define NTE_NOT_FOUND (0x80090011) +#define NTE_DOUBLE_ENCRYPT (0x80090012) +#define NTE_BAD_PROVIDER (0x80090013) +#define NTE_BAD_PROV_TYPE (0x80090014) +#define NTE_BAD_PUBLIC_KEY (0x80090015) +#define NTE_BAD_KEYSET (0x80090016) +#define NTE_PROV_TYPE_NOT_DEF (0x80090017) +#define NTE_PROV_TYPE_ENTRY_BAD (0x80090018) +#define NTE_KEYSET_NOT_DEF (0x80090019) +#define NTE_KEYSET_ENTRY_BAD (0x8009001A) +#define NTE_PROV_TYPE_NO_MATCH (0x8009001B) +#define NTE_SIGNATURE_FILE_BAD (0x8009001C) +#define NTE_PROVIDER_DLL_FAIL (0x8009001D) +#define NTE_PROV_DLL_NOT_FOUND (0x8009001E) +#define NTE_BAD_KEYSET_PARAM (0x8009001F) +#define NTE_FAIL (0x80090020) +#define NTE_SYS_ERR (0x80090021) +#define NTE_SILENT_CONTEXT (0x80090022) +#define NTE_TOKEN_KEYSET_STORAGE_FULL (0x80090023) +#define NTE_TEMPORARY_PROFILE (0x80090024) +#define NTE_FIXEDPARAMETER (0x80090025) +#define NTE_NO_MORE_ITEMS ERROR_NO_MORE_ITEMS +#define NTE_NOT_SUPPORTED ERROR_NOT_SUPPORTED +#define NTE_INVALID_PARAMETER (0x80090027) + +#define EXCEPTION_MAXIMUM_PARAMETERS 15 + +typedef struct s_EXCEPTION_RECORD EXCEPTION_RECORD; +typedef struct s_EXCEPTION_RECORD* PEXCEPTION_RECORD; + +struct s_EXCEPTION_RECORD +{ + DWORD ExceptionCode; + DWORD ExceptionFlags; + PEXCEPTION_RECORD ExceptionRecord; + PVOID ExceptionAddress; + DWORD NumberParameters; + ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; +}; + +typedef void* PCONTEXT; + +typedef struct s_EXCEPTION_POINTERS +{ + PEXCEPTION_RECORD ExceptionRecord; + PCONTEXT ContextRecord; +} EXCEPTION_POINTERS, *PEXCEPTION_POINTERS; + +typedef LONG (*PTOP_LEVEL_EXCEPTION_FILTER)(PEXCEPTION_POINTERS ExceptionInfo); +typedef PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER; + +typedef LONG (*PVECTORED_EXCEPTION_HANDLER)(PEXCEPTION_POINTERS ExceptionInfo); + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API UINT GetErrorMode(void); + + WINPR_API UINT SetErrorMode(UINT uMode); + + WINPR_API DWORD GetLastError(void); + + WINPR_API VOID SetLastError(DWORD dwErrCode); + + WINPR_API VOID RestoreLastError(DWORD dwErrCode); + + WINPR_API VOID RaiseException(DWORD dwExceptionCode, DWORD dwExceptionFlags, + DWORD nNumberOfArguments, CONST ULONG_PTR* lpArguments); + + WINPR_API LONG UnhandledExceptionFilter(PEXCEPTION_POINTERS ExceptionInfo); + + WINPR_API LPTOP_LEVEL_EXCEPTION_FILTER + SetUnhandledExceptionFilter(LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter); + + WINPR_API PVOID AddVectoredExceptionHandler(ULONG First, PVECTORED_EXCEPTION_HANDLER Handler); + + WINPR_API ULONG RemoveVectoredExceptionHandler(PVOID Handle); + + WINPR_API PVOID AddVectoredContinueHandler(ULONG First, PVECTORED_EXCEPTION_HANDLER Handler); + + WINPR_API ULONG RemoveVectoredContinueHandler(PVOID Handle); + +#ifdef __cplusplus +} +#endif + +#endif + +#endif /* WINPR_ERROR_H */ diff --git a/winpr/include/winpr/file.h b/winpr/include/winpr/file.h new file mode 100644 index 0000000..c455d74 --- /dev/null +++ b/winpr/include/winpr/file.h @@ -0,0 +1,550 @@ +/** + * WinPR: Windows Portable Runtime + * File Functions + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * Copyright 2016 David PHAM-VAN <d.phamvan@inuvika.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_FILE_H +#define WINPR_FILE_H + +#include <winpr/winpr.h> +#include <winpr/wtypes.h> + +#include <winpr/nt.h> +#include <winpr/io.h> +#include <winpr/error.h> + +#ifndef _WIN32 + +#include <stdio.h> + +#ifndef MAX_PATH +#define MAX_PATH 260 +#endif + +#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) + +#define FILE_ATTRIBUTE_READONLY 0x00000001u +#define FILE_ATTRIBUTE_HIDDEN 0x00000002u +#define FILE_ATTRIBUTE_SYSTEM 0x00000004u +#define FILE_ATTRIBUTE_DIRECTORY 0x00000010u +#define FILE_ATTRIBUTE_ARCHIVE 0x00000020u +#define FILE_ATTRIBUTE_DEVICE 0x00000040u +#define FILE_ATTRIBUTE_NORMAL 0x00000080u +#define FILE_ATTRIBUTE_TEMPORARY 0x00000100u +#define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200u +#define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400u +#define FILE_ATTRIBUTE_COMPRESSED 0x00000800u +#define FILE_ATTRIBUTE_OFFLINE 0x00001000u +#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000u +#define FILE_ATTRIBUTE_ENCRYPTED 0x00004000u +#define FILE_ATTRIBUTE_VIRTUAL 0x00010000u + +#define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001 +#define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002 +#define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004 +#define FILE_NOTIFY_CHANGE_SIZE 0x00000008 +#define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010 +#define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020 +#define FILE_NOTIFY_CHANGE_CREATION 0x00000040 +#define FILE_NOTIFY_CHANGE_SECURITY 0x00000100 + +#define FILE_ACTION_ADDED 0x00000001 +#define FILE_ACTION_REMOVED 0x00000002 +#define FILE_ACTION_MODIFIED 0x00000003 +#define FILE_ACTION_RENAMED_OLD_NAME 0x00000004 +#define FILE_ACTION_RENAMED_NEW_NAME 0x00000005 + +#define FILE_CASE_SENSITIVE_SEARCH 0x00000001 +#define FILE_CASE_PRESERVED_NAMES 0x00000002 +#define FILE_UNICODE_ON_DISK 0x00000004 +#define FILE_PERSISTENT_ACLS 0x00000008 +#define FILE_FILE_COMPRESSION 0x00000010 +#define FILE_VOLUME_QUOTAS 0x00000020 +#define FILE_SUPPORTS_SPARSE_FILES 0x00000040 +#define FILE_SUPPORTS_REPARSE_POINTS 0x00000080 +#define FILE_SUPPORTS_REMOTE_STORAGE 0x00000100 +#define FILE_VOLUME_IS_COMPRESSED 0x00008000 +#define FILE_SUPPORTS_OBJECT_IDS 0x00010000 +#define FILE_SUPPORTS_ENCRYPTION 0x00020000 +#define FILE_NAMED_STREAMS 0x00040000 +#define FILE_READ_ONLY_VOLUME 0x00080000 +#define FILE_SEQUENTIAL_WRITE_ONCE 0x00100000 +#define FILE_SUPPORTS_TRANSACTIONS 0x00200000 +#define FILE_SUPPORTS_HARD_LINKS 0x00400000 +#define FILE_SUPPORTS_EXTENDED_ATTRIBUTES 0x00800000 +#define FILE_SUPPORTS_OPEN_BY_FILE_ID 0x01000000 +#define FILE_SUPPORTS_USN_JOURNAL 0x02000000 + +#define FILE_FLAG_WRITE_THROUGH 0x80000000 +#define FILE_FLAG_OVERLAPPED 0x40000000 +#define FILE_FLAG_NO_BUFFERING 0x20000000 +#define FILE_FLAG_RANDOM_ACCESS 0x10000000 +#define FILE_FLAG_SEQUENTIAL_SCAN 0x08000000 +#define FILE_FLAG_DELETE_ON_CLOSE 0x04000000 +#define FILE_FLAG_BACKUP_SEMANTICS 0x02000000 +#define FILE_FLAG_POSIX_SEMANTICS 0x01000000 +#define FILE_FLAG_OPEN_REPARSE_POINT 0x00200000 +#define FILE_FLAG_OPEN_NO_RECALL 0x00100000 +#define FILE_FLAG_FIRST_PIPE_INSTANCE 0x00080000 + +#define PAGE_NOACCESS 0x00000001 +#define PAGE_READONLY 0x00000002 +#define PAGE_READWRITE 0x00000004 +#define PAGE_WRITECOPY 0x00000008 +#define PAGE_EXECUTE 0x00000010 +#define PAGE_EXECUTE_READ 0x00000020 +#define PAGE_EXECUTE_READWRITE 0x00000040 +#define PAGE_EXECUTE_WRITECOPY 0x00000080 +#define PAGE_GUARD 0x00000100 +#define PAGE_NOCACHE 0x00000200 +#define PAGE_WRITECOMBINE 0x00000400 + +#define MEM_COMMIT 0x00001000 +#define MEM_RESERVE 0x00002000 +#define MEM_DECOMMIT 0x00004000 +#define MEM_RELEASE 0x00008000 +#define MEM_FREE 0x00010000 +#define MEM_PRIVATE 0x00020000 +#define MEM_MAPPED 0x00040000 +#define MEM_RESET 0x00080000 +#define MEM_TOP_DOWN 0x00100000 +#define MEM_WRITE_WATCH 0x00200000 +#define MEM_PHYSICAL 0x00400000 +#define MEM_4MB_PAGES 0x80000000 +#define MEM_IMAGE SEC_IMAGE + +#define SEC_NO_CHANGE 0x00400000 +#define SEC_FILE 0x00800000 +#define SEC_IMAGE 0x01000000 +#define SEC_VLM 0x02000000 +#define SEC_RESERVE 0x04000000 +#define SEC_COMMIT 0x08000000 +#define SEC_NOCACHE 0x10000000 +#define SEC_WRITECOMBINE 0x40000000 +#define SEC_LARGE_PAGES 0x80000000 + +#define SECTION_MAP_EXECUTE_EXPLICIT 0x00020 +#define SECTION_EXTEND_SIZE 0x00010 +#define SECTION_MAP_READ 0x00004 +#define SECTION_MAP_WRITE 0x00002 +#define SECTION_QUERY 0x00001 +#define SECTION_MAP_EXECUTE 0x00008 +#define SECTION_ALL_ACCESS 0xF001F + +#define FILE_MAP_COPY SECTION_QUERY +#define FILE_MAP_WRITE SECTION_MAP_WRITE +#define FILE_MAP_READ SECTION_MAP_READ +#define FILE_MAP_ALL_ACCESS SECTION_ALL_ACCESS +#define FILE_MAP_EXECUTE SECTION_MAP_EXECUTE_EXPLICIT + +#define CREATE_NEW 1 +#define CREATE_ALWAYS 2 +#define OPEN_EXISTING 3 +#define OPEN_ALWAYS 4 +#define TRUNCATE_EXISTING 5 + +#define FIND_FIRST_EX_CASE_SENSITIVE 0x1 +#define FIND_FIRST_EX_LARGE_FETCH 0x2 + +#define STD_INPUT_HANDLE (DWORD) - 10 +#define STD_OUTPUT_HANDLE (DWORD) - 11 +#define STD_ERROR_HANDLE (DWORD) - 12 + +#define FILE_BEGIN 0 +#define FILE_CURRENT 1 +#define FILE_END 2 + +#define LOCKFILE_FAIL_IMMEDIATELY 1 +#define LOCKFILE_EXCLUSIVE_LOCK 2 + +#define MOVEFILE_REPLACE_EXISTING 0x1 +#define MOVEFILE_COPY_ALLOWED 0x2 +#define MOVEFILE_DELAY_UNTIL_REBOOT 0x4 +#define MOVEFILE_WRITE_THROUGH 0x8 +#define MOVEFILE_CREATE_HARDLINK 0x10 +#define MOVEFILE_FAIL_IF_NOT_TRACKABLE 0x20 + +typedef union +{ + PVOID64 Buffer; + ULONGLONG Alignment; +} FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT; + +typedef struct +{ + DWORD dwFileAttributes; + FILETIME ftCreationTime; + FILETIME ftLastAccessTime; + FILETIME ftLastWriteTime; + DWORD nFileSizeHigh; + DWORD nFileSizeLow; + DWORD dwReserved0; + DWORD dwReserved1; + CHAR cFileName[MAX_PATH]; + CHAR cAlternateFileName[14]; +} WIN32_FIND_DATAA, *PWIN32_FIND_DATAA, *LPWIN32_FIND_DATAA; + +typedef struct +{ + DWORD dwFileAttributes; + FILETIME ftCreationTime; + FILETIME ftLastAccessTime; + FILETIME ftLastWriteTime; + DWORD nFileSizeHigh; + DWORD nFileSizeLow; + DWORD dwReserved0; + DWORD dwReserved1; + WCHAR cFileName[MAX_PATH]; + WCHAR cAlternateFileName[14]; +} WIN32_FIND_DATAW, *PWIN32_FIND_DATAW, *LPWIN32_FIND_DATAW; + +typedef struct +{ + DWORD dwFileAttributes; + FILETIME ftCreationTime; + FILETIME ftLastAccessTime; + FILETIME ftLastWriteTime; + DWORD dwVolumeSerialNumber; + DWORD nFileSizeHigh; + DWORD nFileSizeLow; + DWORD nNumberOfLinks; + DWORD nFileIndexHigh; + DWORD nFileIndexLow; +} BY_HANDLE_FILE_INFORMATION, *PBY_HANDLE_FILE_INFORMATION, *LPBY_HANDLE_FILE_INFORMATION; + +typedef enum +{ + FindExInfoStandard, + FindExInfoMaxInfoLevel +} FINDEX_INFO_LEVELS; + +typedef enum +{ + FindExSearchNameMatch, + FindExSearchLimitToDirectories, + FindExSearchLimitToDevices, + FindExSearchMaxSearchOp +} FINDEX_SEARCH_OPS; + +typedef VOID (*LPOVERLAPPED_COMPLETION_ROUTINE)(DWORD dwErrorCode, DWORD dwNumberOfBytesTransfered, + LPOVERLAPPED lpOverlapped); + +#ifdef UNICODE +#define WIN32_FIND_DATA WIN32_FIND_DATAW +#define PWIN32_FIND_DATA PWIN32_FIND_DATAW +#define LPWIN32_FIND_DATA LPWIN32_FIND_DATAW +#else +#define WIN32_FIND_DATA WIN32_FIND_DATAA +#define PWIN32_FIND_DATA PWIN32_FIND_DATAA +#define LPWIN32_FIND_DATA LPWIN32_FIND_DATAA +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API HANDLE CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, + LPSECURITY_ATTRIBUTES lpSecurityAttributes, + DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, + HANDLE hTemplateFile); + + WINPR_API HANDLE CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, + LPSECURITY_ATTRIBUTES lpSecurityAttributes, + DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, + HANDLE hTemplateFile); + + WINPR_API BOOL DeleteFileA(LPCSTR lpFileName); + + WINPR_API BOOL DeleteFileW(LPCWSTR lpFileName); + + WINPR_API BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, + LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped); + + WINPR_API BOOL ReadFileEx(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, + LPOVERLAPPED lpOverlapped, + LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine); + + WINPR_API BOOL ReadFileScatter(HANDLE hFile, FILE_SEGMENT_ELEMENT aSegmentArray[], + DWORD nNumberOfBytesToRead, LPDWORD lpReserved, + LPOVERLAPPED lpOverlapped); + + WINPR_API BOOL WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, + LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped); + + WINPR_API BOOL WriteFileEx(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, + LPOVERLAPPED lpOverlapped, + LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine); + + WINPR_API BOOL WriteFileGather(HANDLE hFile, FILE_SEGMENT_ELEMENT aSegmentArray[], + DWORD nNumberOfBytesToWrite, LPDWORD lpReserved, + LPOVERLAPPED lpOverlapped); + + WINPR_API BOOL FlushFileBuffers(HANDLE hFile); + + typedef struct + { + DWORD dwFileAttributes; + FILETIME ftCreationTime; + FILETIME ftLastAccessTime; + FILETIME ftLastWriteTime; + DWORD nFileSizeHigh; + DWORD nFileSizeLow; + } WIN32_FILE_ATTRIBUTE_DATA, *LPWIN32_FILE_ATTRIBUTE_DATA; + + typedef enum + { + GetFileExInfoStandard, + GetFileExMaxInfoLevel + } GET_FILEEX_INFO_LEVELS; + + WINPR_API BOOL GetFileAttributesExA(LPCSTR lpFileName, GET_FILEEX_INFO_LEVELS fInfoLevelId, + LPVOID lpFileInformation); + + WINPR_API DWORD GetFileAttributesA(LPCSTR lpFileName); + + WINPR_API BOOL GetFileAttributesExW(LPCWSTR lpFileName, GET_FILEEX_INFO_LEVELS fInfoLevelId, + LPVOID lpFileInformation); + + WINPR_API DWORD GetFileAttributesW(LPCWSTR lpFileName); + + WINPR_API BOOL GetFileInformationByHandle(HANDLE hFile, + LPBY_HANDLE_FILE_INFORMATION lpFileInformation); + + WINPR_API BOOL SetFileAttributesA(LPCSTR lpFileName, DWORD dwFileAttributes); + + WINPR_API BOOL SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes); + + WINPR_API BOOL SetEndOfFile(HANDLE hFile); + + WINPR_API DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh); + + WINPR_API DWORD SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, + DWORD dwMoveMethod); + + WINPR_API BOOL SetFilePointerEx(HANDLE hFile, LARGE_INTEGER liDistanceToMove, + PLARGE_INTEGER lpNewFilePointer, DWORD dwMoveMethod); + + WINPR_API BOOL LockFile(HANDLE hFile, DWORD dwFileOffsetLow, DWORD dwFileOffsetHigh, + DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh); + + WINPR_API BOOL LockFileEx(HANDLE hFile, DWORD dwFlags, DWORD dwReserved, + DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh, + LPOVERLAPPED lpOverlapped); + + WINPR_API BOOL UnlockFile(HANDLE hFile, DWORD dwFileOffsetLow, DWORD dwFileOffsetHigh, + DWORD nNumberOfBytesToUnlockLow, DWORD nNumberOfBytesToUnlockHigh); + + WINPR_API BOOL UnlockFileEx(HANDLE hFile, DWORD dwReserved, DWORD nNumberOfBytesToUnlockLow, + DWORD nNumberOfBytesToUnlockHigh, LPOVERLAPPED lpOverlapped); + + WINPR_API BOOL SetFileTime(HANDLE hFile, const FILETIME* lpCreationTime, + const FILETIME* lpLastAccessTime, const FILETIME* lpLastWriteTime); + + WINPR_API HANDLE FindFirstFileA(LPCSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData); + WINPR_API HANDLE FindFirstFileW(LPCWSTR lpFileName, LPWIN32_FIND_DATAW lpFindFileData); + + WINPR_API HANDLE FindFirstFileExA(LPCSTR lpFileName, FINDEX_INFO_LEVELS fInfoLevelId, + LPVOID lpFindFileData, FINDEX_SEARCH_OPS fSearchOp, + LPVOID lpSearchFilter, DWORD dwAdditionalFlags); + WINPR_API HANDLE FindFirstFileExW(LPCWSTR lpFileName, FINDEX_INFO_LEVELS fInfoLevelId, + LPVOID lpFindFileData, FINDEX_SEARCH_OPS fSearchOp, + LPVOID lpSearchFilter, DWORD dwAdditionalFlags); + + WINPR_API BOOL FindNextFileA(HANDLE hFindFile, LPWIN32_FIND_DATAA lpFindFileData); + WINPR_API BOOL FindNextFileW(HANDLE hFindFile, LPWIN32_FIND_DATAW lpFindFileData); + + WINPR_API BOOL FindClose(HANDLE hFindFile); + + WINPR_API BOOL CreateDirectoryA(LPCSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes); + WINPR_API BOOL CreateDirectoryW(LPCWSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes); + + WINPR_API BOOL RemoveDirectoryA(LPCSTR lpPathName); + WINPR_API BOOL RemoveDirectoryW(LPCWSTR lpPathName); + + WINPR_API HANDLE GetStdHandle(DWORD nStdHandle); + WINPR_API BOOL SetStdHandle(DWORD nStdHandle, HANDLE hHandle); + WINPR_API BOOL SetStdHandleEx(DWORD dwStdHandle, HANDLE hNewHandle, HANDLE* phOldHandle); + + WINPR_API BOOL GetDiskFreeSpaceA(LPCSTR lpRootPathName, LPDWORD lpSectorsPerCluster, + LPDWORD lpBytesPerSector, LPDWORD lpNumberOfFreeClusters, + LPDWORD lpTotalNumberOfClusters); + + WINPR_API BOOL GetDiskFreeSpaceW(LPCWSTR lpRootPathName, LPDWORD lpSectorsPerCluster, + LPDWORD lpBytesPerSector, LPDWORD lpNumberOfFreeClusters, + LPDWORD lpTotalNumberOfClusters); + + WINPR_API BOOL MoveFileExA(LPCSTR lpExistingFileName, LPCSTR lpNewFileName, DWORD dwFlags); + + WINPR_API BOOL MoveFileExW(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName, DWORD dwFlags); + + WINPR_API BOOL MoveFileA(LPCSTR lpExistingFileName, LPCSTR lpNewFileName); + + WINPR_API BOOL MoveFileW(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName); + +#ifdef __cplusplus +} +#endif + +#ifdef UNICODE +#define CreateFile CreateFileW +#define DeleteFile DeleteFileW +#define FindFirstFile FindFirstFileW +#define FindFirstFileEx FindFirstFileExW +#define FindNextFile FindNextFileW +#define CreateDirectory CreateDirectoryW +#define RemoveDirectory RemoveDirectoryW +#define GetFileAttributesEx GetFileAttributesExW +#define GetFileAttributes GetFileAttributesW +#define SetFileAttributes SetFileAttributesW +#define GetDiskFreeSpace GetDiskFreeSpaceW +#define MoveFileEx MoveFileExW +#define MoveFile MoveFileW +#else +#define CreateFile CreateFileA +#define DeleteFile DeleteFileA +#define FindFirstFile FindFirstFileA +#define FindFirstFileEx FindFirstFileExA +#define FindNextFile FindNextFileA +#define CreateDirectory CreateDirectoryA +#define RemoveDirectory RemoveDirectoryA +#define GetFileAttributesEx GetFileAttributesExA +#define GetFileAttributes GetFileAttributesA +#define SetFileAttributes SetFileAttributesA +#define GetDiskFreeSpace GetDiskFreeSpaceA +#define MoveFileEx MoveFileExA +#define MoveFile MoveFileA +#endif + +/* Extra Functions */ + +typedef BOOL (*pcIsFileHandled)(LPCSTR lpFileName); +typedef HANDLE (*pcCreateFileA)(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, + LPSECURITY_ATTRIBUTES lpSecurityAttributes, + DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, + HANDLE hTemplateFile); + +typedef struct +{ + pcIsFileHandled IsHandled; + pcCreateFileA CreateFileA; +} HANDLE_CREATOR, *PHANDLE_CREATOR, *LPHANDLE_CREATOR; + +#endif /* _WIN32 */ + +WINPR_API BOOL ValidFileNameComponent(LPCWSTR lpFileName); + +#ifdef _UWP + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API HANDLE CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, + LPSECURITY_ATTRIBUTES lpSecurityAttributes, + DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, + HANDLE hTemplateFile); + + WINPR_API HANDLE CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, + LPSECURITY_ATTRIBUTES lpSecurityAttributes, + DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, + HANDLE hTemplateFile); + + WINPR_API DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh); + + WINPR_API DWORD SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, + DWORD dwMoveMethod); + + WINPR_API HANDLE FindFirstFileA(LPCSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData); + WINPR_API HANDLE FindFirstFileW(LPCWSTR lpFileName, LPWIN32_FIND_DATAW lpFindFileData); + + WINPR_API DWORD GetFullPathNameA(LPCSTR lpFileName, DWORD nBufferLength, LPSTR lpBuffer, + LPSTR* lpFilePart); + + WINPR_API BOOL GetDiskFreeSpaceA(LPCSTR lpRootPathName, LPDWORD lpSectorsPerCluster, + LPDWORD lpBytesPerSector, LPDWORD lpNumberOfFreeClusters, + LPDWORD lpTotalNumberOfClusters); + + WINPR_API BOOL GetDiskFreeSpaceW(LPCWSTR lpRootPathName, LPDWORD lpSectorsPerCluster, + LPDWORD lpBytesPerSector, LPDWORD lpNumberOfFreeClusters, + LPDWORD lpTotalNumberOfClusters); + + WINPR_API DWORD GetLogicalDriveStringsA(DWORD nBufferLength, LPSTR lpBuffer); + + WINPR_API DWORD GetLogicalDriveStringsW(DWORD nBufferLength, LPWSTR lpBuffer); + + WINPR_API BOOL PathIsDirectoryEmptyA(LPCSTR pszPath); + + WINPR_API UINT GetACP(void); + +#ifdef UNICODE +#define CreateFile CreateFileW +#define FindFirstFile FindFirstFileW +#else +#define CreateFile CreateFileA +#define FindFirstFile FindFirstFileA +#endif + +#ifdef __cplusplus +} +#endif + +#ifdef UNICODE +#define FindFirstFile FindFirstFileW +#else +#define FindFirstFile FindFirstFileA +#endif + +#endif + +#define WILDCARD_STAR 0x00000001 +#define WILDCARD_QM 0x00000002 +#define WILDCARD_DOS 0x00000100 +#define WILDCARD_DOS_STAR 0x00000110 +#define WILDCARD_DOS_QM 0x00000120 +#define WILDCARD_DOS_DOT 0x00000140 + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API BOOL FilePatternMatchA(LPCSTR lpFileName, LPCSTR lpPattern); + WINPR_API LPSTR FilePatternFindNextWildcardA(LPCSTR lpPattern, DWORD* pFlags); + + WINPR_API int UnixChangeFileMode(const char* filename, int flags); + + WINPR_API BOOL IsNamedPipeFileNameA(LPCSTR lpName); + WINPR_API char* GetNamedPipeNameWithoutPrefixA(LPCSTR lpName); + WINPR_API char* GetNamedPipeUnixDomainSocketBaseFilePathA(void); + WINPR_API char* GetNamedPipeUnixDomainSocketFilePathA(LPCSTR lpName); + + WINPR_API int GetNamePipeFileDescriptor(HANDLE hNamedPipe); + WINPR_API HANDLE GetFileHandleForFileDescriptor(int fd); + + WINPR_API FILE* winpr_fopen(const char* path, const char* mode); + +#ifdef __cplusplus +} +#endif + +#endif /* WINPR_FILE_H */ diff --git a/winpr/include/winpr/handle.h b/winpr/include/winpr/handle.h new file mode 100644 index 0000000..ca2b4b7 --- /dev/null +++ b/winpr/include/winpr/handle.h @@ -0,0 +1,64 @@ +/** + * WinPR: Windows Portable Runtime + * Handle Management + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_HANDLE_H +#define WINPR_HANDLE_H + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <winpr/winpr.h> +#include <winpr/wtypes.h> +#include <winpr/security.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define WINPR_FD_READ_BIT 0 +#define WINPR_FD_READ (1 << WINPR_FD_READ_BIT) + +#define WINPR_FD_WRITE_BIT 1 +#define WINPR_FD_WRITE (1 << WINPR_FD_WRITE_BIT) + +#ifndef _WIN32 + +#define DUPLICATE_CLOSE_SOURCE 0x00000001 +#define DUPLICATE_SAME_ACCESS 0x00000002 + +#define HANDLE_FLAG_INHERIT 0x00000001 +#define HANDLE_FLAG_PROTECT_FROM_CLOSE 0x00000002 + + WINPR_API BOOL CloseHandle(HANDLE hObject); + + WINPR_API BOOL DuplicateHandle(HANDLE hSourceProcessHandle, HANDLE hSourceHandle, + HANDLE hTargetProcessHandle, LPHANDLE lpTargetHandle, + DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwOptions); + + WINPR_API BOOL GetHandleInformation(HANDLE hObject, LPDWORD lpdwFlags); + WINPR_API BOOL SetHandleInformation(HANDLE hObject, DWORD dwMask, DWORD dwFlags); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* WINPR_HANDLE_H */ diff --git a/winpr/include/winpr/image.h b/winpr/include/winpr/image.h new file mode 100644 index 0000000..cf33c5f --- /dev/null +++ b/winpr/include/winpr/image.h @@ -0,0 +1,121 @@ +/** + * WinPR: Windows Portable Runtime + * Image Utils + * + * Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_IMAGE_H +#define WINPR_IMAGE_H + +#include <winpr/winpr.h> +#include <winpr/wtypes.h> + +#pragma pack(push, 1) + +typedef struct +{ + BYTE bfType[2]; + UINT32 bfSize; + UINT16 bfReserved1; + UINT16 bfReserved2; + UINT32 bfOffBits; +} WINPR_BITMAP_FILE_HEADER; + +typedef struct +{ + UINT32 biSize; + INT32 biWidth; + INT32 biHeight; + UINT16 biPlanes; + UINT16 biBitCount; + UINT32 biCompression; + UINT32 biSizeImage; + INT32 biXPelsPerMeter; + INT32 biYPelsPerMeter; + UINT32 biClrUsed; + UINT32 biClrImportant; +} WINPR_BITMAP_INFO_HEADER; + +typedef struct +{ + UINT32 bcSize; + UINT16 bcWidth; + UINT16 bcHeight; + UINT16 bcPlanes; + UINT16 bcBitCount; +} WINPR_BITMAP_CORE_HEADER; + +#pragma pack(pop) + +#define WINPR_IMAGE_BITMAP 0 +#define WINPR_IMAGE_PNG 1 +#define WINPR_IMAGE_JPEG 2 +#define WINPR_IMAGE_WEBP 3 + +#define WINPR_IMAGE_BMP_HEADER_LEN 54 + +typedef struct +{ + int type; + UINT32 width; + UINT32 height; + BYTE* data; + UINT32 scanline; + UINT32 bitsPerPixel; + UINT32 bytesPerPixel; +} wImage; + +typedef enum +{ + WINPR_IMAGE_CMP_NO_FLAGS = 0, + WINPR_IMAGE_CMP_IGNORE_DEPTH = 1, + WINPR_IMAGE_CMP_IGNORE_ALPHA = 2, + WINPR_IMAGE_CMP_FUZZY = 4 +} wImageFlags; + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API int winpr_bitmap_write(const char* filename, const BYTE* data, size_t width, + size_t height, size_t bpp); + WINPR_API int winpr_bitmap_write_ex(const char* filename, const BYTE* data, size_t stride, + size_t width, size_t height, size_t bpp); + WINPR_API BYTE* winpr_bitmap_construct_header(size_t width, size_t height, size_t bpp); + + WINPR_API int winpr_image_write(wImage* image, const char* filename); + WINPR_API int winpr_image_write_ex(wImage* image, UINT32 format, const char* filename); + WINPR_API int winpr_image_read(wImage* image, const char* filename); + + WINPR_API void* winpr_image_write_buffer(wImage* image, UINT32 format, size_t* size); + WINPR_API int winpr_image_read_buffer(wImage* image, const BYTE* buffer, size_t size); + + WINPR_API void winpr_image_free(wImage* image, BOOL bFreeBuffer); + + WINPR_ATTR_MALLOC(winpr_image_free, 1) + WINPR_API wImage* winpr_image_new(void); + + WINPR_API BOOL winpr_image_format_is_supported(UINT32 format); + WINPR_API const char* winpr_image_format_extension(UINT32 format); + WINPR_API const char* winpr_image_format_mime(UINT32 format); + WINPR_API BOOL winpr_image_equal(const wImage* imageA, const wImage* imageB, UINT32 flags); + +#ifdef __cplusplus +} +#endif + +#endif /* WINPR_IMAGE_H */ diff --git a/winpr/include/winpr/ini.h b/winpr/include/winpr/ini.h new file mode 100644 index 0000000..6deefae --- /dev/null +++ b/winpr/include/winpr/ini.h @@ -0,0 +1,157 @@ +/** + * WinPR: Windows Portable Runtime + * .ini config file + * + * Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_UTILS_INI_H +#define WINPR_UTILS_INI_H + +#include <winpr/winpr.h> +#include <winpr/wtypes.h> + +typedef struct s_wIniFile wIniFile; + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** @brief read an ini file from a buffer + * + * @param ini The instance to use, must not be \b NULL + * @param buffer The buffer to read from, must be a '\0' terminated string. + * + * @return > 0 for success, < 0 for failure + */ + WINPR_API int IniFile_ReadBuffer(wIniFile* ini, const char* buffer); + + /** @brief read an ini file from a file + * + * @param ini The instance to use, must not be \b NULL + * @param filename The name of the file to read from, must be a '\0' terminated string. + * + * @return > 0 for success, < 0 for failure + */ + WINPR_API int IniFile_ReadFile(wIniFile* ini, const char* filename); + + /** @brief write an ini instance to a buffer + * + * @param ini The instance to use, must not be \b NULL + * + * @return A newly allocated string, use \b free after use. \b NULL in case of failure + */ + WINPR_API char* IniFile_WriteBuffer(wIniFile* ini); + + /** @brief write an ini instance to a file + * + * @param ini The instance to use, must not be \b NULL + * @param filename The name of the file as '\0' terminated string. + * + * @return > 0 for success, < 0 for failure + */ + WINPR_API int IniFile_WriteFile(wIniFile* ini, const char* filename); + + /** @brief Get the number and names of sections in the ini instance + * + * @param ini The instance to use, must not be \b NULL + * @param count A buffer that will contain the number of sections + * + * @return A newly allocated array of strings (size \b count). Use \b free after use + */ + WINPR_API char** IniFile_GetSectionNames(wIniFile* ini, size_t* count); + + /** @brief Get the number and names of keys of a section in the ini instance + * + * @param ini The instance to use, must not be \b NULL + * @param section The name of the section as '\0' terminated string. + * @param count A buffer that will contain the number of sections + * + * @return A newly allocated array of strings (size \b count). Use \b free after use + */ + WINPR_API char** IniFile_GetSectionKeyNames(wIniFile* ini, const char* section, size_t* count); + + /** @brief Get an ini [section/key] value of type string + * + * @param ini The instance to use, must not be \b NULL + * @param section The name of the section as '\0' terminated string. + * @param key The name of the key as '\0' terminated string. + * + * @return The value of the [section/key] as '\0' terminated string or \b NULL + */ + WINPR_API const char* IniFile_GetKeyValueString(wIniFile* ini, const char* section, + const char* key); + + /** @brief Get an ini [section/key] value of type int + * + * @param ini The instance to use, must not be \b NULL + * @param section The name of the section as '\0' terminated string. + * @param key The name of the key as '\0' terminated string. + * + * @return The value of the [section/key] + */ + WINPR_API int IniFile_GetKeyValueInt(wIniFile* ini, const char* section, const char* key); + + /** @brief Set an ini [section/key] value of type string + * + * @param ini The instance to use, must not be \b NULL + * @param section The name of the section as '\0' terminated string. + * @param key The name of the key as '\0' terminated string. + * @param value The value of the [section/key] as '\0' terminated string. + * + * @return > 0 for success, < 0 for failure + */ + WINPR_API int IniFile_SetKeyValueString(wIniFile* ini, const char* section, const char* key, + const char* value); + + /** @brief Set an ini [section/key] value of type int + * + * @param ini The instance to use, must not be \b NULL + * @param section The name of the section as '\0' terminated string. + * @param key The name of the key as '\0' terminated string. + * @param value The value of the [section/key] + * + * @return > 0 for success, < 0 for failure + */ + WINPR_API int IniFile_SetKeyValueInt(wIniFile* ini, const char* section, const char* key, + int value); + + /** @brief Free a ini instance + * + * @param ini The instance to free, may be \b NULL + */ + WINPR_API void IniFile_Free(wIniFile* ini); + + /** @brief Create a new ini instance + * + * @return The newly allocated instance or \b NULL if failed. + */ + WINPR_ATTR_MALLOC(IniFile_Free, 1) + WINPR_API wIniFile* IniFile_New(void); + + /** @brief Clone a ini instance + * + * @param ini The instance to free, may be \b NULL + * + * @return the cloned instance or \b NULL in case of \b ini was \b NULL or failure + */ + WINPR_API wIniFile* IniFile_Clone(const wIniFile* ini); + +#ifdef __cplusplus +} +#endif + +#endif /* WINPR_UTILS_INI_H */ diff --git a/winpr/include/winpr/input.h b/winpr/include/winpr/input.h new file mode 100644 index 0000000..9f5eda8 --- /dev/null +++ b/winpr/include/winpr/input.h @@ -0,0 +1,909 @@ +/** + * WinPR: Windows Portable Runtime + * Input Functions + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_INPUT_H +#define WINPR_INPUT_H + +#include <winpr/winpr.h> +#include <winpr/wtypes.h> + +/** + * Key Flags + */ + +#define KBDEXT 0x0100u +#define KBDMULTIVK 0x0200u +#define KBDSPECIAL 0x0400u +#define KBDNUMPAD 0x0800u +#define KBDUNICODE 0x1000u +#define KBDINJECTEDVK 0x2000u +#define KBDMAPPEDVK 0x4000u +#define KBDBREAK 0x8000u + +/* + * Virtual Key Codes (Windows): + * http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731/ + * http://msdn.microsoft.com/en-us/library/ms927178.aspx + */ + +/* Mouse buttons */ + +#define VK_LBUTTON 0x01 /* Left mouse button */ +#define VK_RBUTTON 0x02 /* Right mouse button */ +#define VK_CANCEL 0x03 /* Control-break processing */ +#define VK_MBUTTON 0x04 /* Middle mouse button (three-button mouse) */ +#define VK_XBUTTON1 0x05 /* Windows 2000/XP: X1 mouse button */ +#define VK_XBUTTON2 0x06 /* Windows 2000/XP: X2 mouse button */ + +/* 0x07 is undefined */ + +#define VK_BACK 0x08 /* BACKSPACE key */ +#define VK_TAB 0x09 /* TAB key */ + +/* 0x0A to 0x0B are reserved */ + +#define VK_CLEAR 0x0C /* CLEAR key */ +#define VK_RETURN 0x0D /* ENTER key */ + +/* 0x0E to 0x0F are undefined */ + +#define VK_SHIFT 0x10 /* SHIFT key */ +#define VK_CONTROL 0x11 /* CTRL key */ +#define VK_MENU 0x12 /* ALT key */ +#define VK_PAUSE 0x13 /* PAUSE key */ +#define VK_CAPITAL 0x14 /* CAPS LOCK key */ +#define VK_KANA 0x15 /* Input Method Editor (IME) Kana mode */ +#define VK_HANGUEL \ + 0x15 /* IME Hanguel mode (maintained for compatibility; use #define VK_HANGUL) \ + */ +#define VK_HANGUL 0x15 /* IME Hangul mode */ + +/* 0x16 is undefined */ + +#define VK_JUNJA 0x17 /* IME Junja mode */ +#define VK_FINAL 0x18 /* IME final mode */ +#define VK_HANJA 0x19 /* IME Hanja mode */ +#define VK_KANJI 0x19 /* IME Kanji mode */ + +/* 0x1A is undefined, use it for missing Hiragana/Katakana Toggle */ + +#define VK_HKTG 0x1A /* Hiragana/Katakana toggle */ +#define VK_ESCAPE 0x1B /* ESC key */ +#define VK_CONVERT 0x1C /* IME convert */ +#define VK_NONCONVERT 0x1D /* IME nonconvert */ +#define VK_ACCEPT 0x1E /* IME accept */ +#define VK_MODECHANGE 0x1F /* IME mode change request */ + +#define VK_SPACE 0x20 /* SPACEBAR */ +#define VK_PRIOR 0x21 /* PAGE UP key */ +#define VK_NEXT 0x22 /* PAGE DOWN key */ +#define VK_END 0x23 /* END key */ +#define VK_HOME 0x24 /* HOME key */ +#define VK_LEFT 0x25 /* LEFT ARROW key */ +#define VK_UP 0x26 /* UP ARROW key */ +#define VK_RIGHT 0x27 /* RIGHT ARROW key */ +#define VK_DOWN 0x28 /* DOWN ARROW key */ +#define VK_SELECT 0x29 /* SELECT key */ +#define VK_PRINT 0x2A /* PRINT key */ +#define VK_EXECUTE 0x2B /* EXECUTE key */ +#define VK_SNAPSHOT 0x2C /* PRINT SCREEN key */ +#define VK_INSERT 0x2D /* INS key */ +#define VK_DELETE 0x2E /* DEL key */ +#define VK_HELP 0x2F /* HELP key */ + +/* Digits, the last 4 bits of the code represent the corresponding digit */ + +#define VK_KEY_0 0x30 /* '0' key */ +#define VK_KEY_1 0x31 /* '1' key */ +#define VK_KEY_2 0x32 /* '2' key */ +#define VK_KEY_3 0x33 /* '3' key */ +#define VK_KEY_4 0x34 /* '4' key */ +#define VK_KEY_5 0x35 /* '5' key */ +#define VK_KEY_6 0x36 /* '6' key */ +#define VK_KEY_7 0x37 /* '7' key */ +#define VK_KEY_8 0x38 /* '8' key */ +#define VK_KEY_9 0x39 /* '9' key */ + +/* 0x3A to 0x40 are undefined */ + +/* The alphabet, the code corresponds to the capitalized letter in the ASCII code */ + +#define VK_KEY_A 0x41 /* 'A' key */ +#define VK_KEY_B 0x42 /* 'B' key */ +#define VK_KEY_C 0x43 /* 'C' key */ +#define VK_KEY_D 0x44 /* 'D' key */ +#define VK_KEY_E 0x45 /* 'E' key */ +#define VK_KEY_F 0x46 /* 'F' key */ +#define VK_KEY_G 0x47 /* 'G' key */ +#define VK_KEY_H 0x48 /* 'H' key */ +#define VK_KEY_I 0x49 /* 'I' key */ +#define VK_KEY_J 0x4A /* 'J' key */ +#define VK_KEY_K 0x4B /* 'K' key */ +#define VK_KEY_L 0x4C /* 'L' key */ +#define VK_KEY_M 0x4D /* 'M' key */ +#define VK_KEY_N 0x4E /* 'N' key */ +#define VK_KEY_O 0x4F /* 'O' key */ +#define VK_KEY_P 0x50 /* 'P' key */ +#define VK_KEY_Q 0x51 /* 'Q' key */ +#define VK_KEY_R 0x52 /* 'R' key */ +#define VK_KEY_S 0x53 /* 'S' key */ +#define VK_KEY_T 0x54 /* 'T' key */ +#define VK_KEY_U 0x55 /* 'U' key */ +#define VK_KEY_V 0x56 /* 'V' key */ +#define VK_KEY_W 0x57 /* 'W' key */ +#define VK_KEY_X 0x58 /* 'X' key */ +#define VK_KEY_Y 0x59 /* 'Y' key */ +#define VK_KEY_Z 0x5A /* 'Z' key */ + +#define VK_LWIN 0x5B /* Left Windows key (Microsoft Natural keyboard) */ +#define VK_RWIN 0x5C /* Right Windows key (Natural keyboard) */ +#define VK_APPS 0x5D /* Applications key (Natural keyboard) */ + +/* 0x5E is reserved */ + +#define VK_POWER 0x5E /* Power key */ + +#define VK_SLEEP 0x5F /* Computer Sleep key */ + +/* Numeric keypad digits, the last four bits of the code represent the corresponding digit */ + +#define VK_NUMPAD0 0x60 /* Numeric keypad '0' key */ +#define VK_NUMPAD1 0x61 /* Numeric keypad '1' key */ +#define VK_NUMPAD2 0x62 /* Numeric keypad '2' key */ +#define VK_NUMPAD3 0x63 /* Numeric keypad '3' key */ +#define VK_NUMPAD4 0x64 /* Numeric keypad '4' key */ +#define VK_NUMPAD5 0x65 /* Numeric keypad '5' key */ +#define VK_NUMPAD6 0x66 /* Numeric keypad '6' key */ +#define VK_NUMPAD7 0x67 /* Numeric keypad '7' key */ +#define VK_NUMPAD8 0x68 /* Numeric keypad '8' key */ +#define VK_NUMPAD9 0x69 /* Numeric keypad '9' key */ + +/* Numeric keypad operators and special keys */ + +#define VK_MULTIPLY 0x6A /* Multiply key */ +#define VK_ADD 0x6B /* Add key */ +#define VK_SEPARATOR 0x6C /* Separator key */ +#define VK_SUBTRACT 0x6D /* Subtract key */ +#define VK_DECIMAL 0x6E /* Decimal key */ +#define VK_DIVIDE 0x6F /* Divide key */ + +/* Function keys, from F1 to F24 */ + +#define VK_F1 0x70 /* F1 key */ +#define VK_F2 0x71 /* F2 key */ +#define VK_F3 0x72 /* F3 key */ +#define VK_F4 0x73 /* F4 key */ +#define VK_F5 0x74 /* F5 key */ +#define VK_F6 0x75 /* F6 key */ +#define VK_F7 0x76 /* F7 key */ +#define VK_F8 0x77 /* F8 key */ +#define VK_F9 0x78 /* F9 key */ +#define VK_F10 0x79 /* F10 key */ +#define VK_F11 0x7A /* F11 key */ +#define VK_F12 0x7B /* F12 key */ +#define VK_F13 0x7C /* F13 key */ +#define VK_F14 0x7D /* F14 key */ +#define VK_F15 0x7E /* F15 key */ +#define VK_F16 0x7F /* F16 key */ +#define VK_F17 0x80 /* F17 key */ +#define VK_F18 0x81 /* F18 key */ +#define VK_F19 0x82 /* F19 key */ +#define VK_F20 0x83 /* F20 key */ +#define VK_F21 0x84 /* F21 key */ +#define VK_F22 0x85 /* F22 key */ +#define VK_F23 0x86 /* F23 key */ +#define VK_F24 0x87 /* F24 key */ + +/* 0x88 to 0x8F are unassigned */ + +#define VK_NUMLOCK 0x90 /* NUM LOCK key */ +#define VK_SCROLL 0x91 /* SCROLL LOCK key */ + +/* 0x92 to 0x96 are OEM specific */ +/* 0x97 to 0x9F are unassigned */ + +/* Modifier keys */ + +#define VK_LSHIFT 0xA0 /* Left SHIFT key */ +#define VK_RSHIFT 0xA1 /* Right SHIFT key */ +#define VK_LCONTROL 0xA2 /* Left CONTROL key */ +#define VK_RCONTROL 0xA3 /* Right CONTROL key */ +#define VK_LMENU 0xA4 /* Left MENU key */ +#define VK_RMENU 0xA5 /* Right MENU key */ + +/* Browser related keys */ + +#define VK_BROWSER_BACK 0xA6 /* Windows 2000/XP: Browser Back key */ +#define VK_BROWSER_FORWARD 0xA7 /* Windows 2000/XP: Browser Forward key */ +#define VK_BROWSER_REFRESH 0xA8 /* Windows 2000/XP: Browser Refresh key */ +#define VK_BROWSER_STOP 0xA9 /* Windows 2000/XP: Browser Stop key */ +#define VK_BROWSER_SEARCH 0xAA /* Windows 2000/XP: Browser Search key */ +#define VK_BROWSER_FAVORITES 0xAB /* Windows 2000/XP: Browser Favorites key */ +#define VK_BROWSER_HOME 0xAC /* Windows 2000/XP: Browser Start and Home key */ + +/* Volume related keys */ + +#define VK_VOLUME_MUTE 0xAD /* Windows 2000/XP: Volume Mute key */ +#define VK_VOLUME_DOWN 0xAE /* Windows 2000/XP: Volume Down key */ +#define VK_VOLUME_UP 0xAF /* Windows 2000/XP: Volume Up key */ + +/* Media player related keys */ + +#define VK_MEDIA_NEXT_TRACK 0xB0 /* Windows 2000/XP: Next Track key */ +#define VK_MEDIA_PREV_TRACK 0xB1 /* Windows 2000/XP: Previous Track key */ +#define VK_MEDIA_STOP 0xB2 /* Windows 2000/XP: Stop Media key */ +#define VK_MEDIA_PLAY_PAUSE 0xB3 /* Windows 2000/XP: Play/Pause Media key */ + +/* Application launcher keys */ + +#define VK_LAUNCH_MAIL 0xB4 /* Windows 2000/XP: Start Mail key */ +#define VK_MEDIA_SELECT 0xB5 /* Windows 2000/XP: Select Media key */ +#define VK_LAUNCH_MEDIA_SELECT 0xB5 /* Windows 2000/XP: Select Media key */ +#define VK_LAUNCH_APP1 0xB6 /* Windows 2000/XP: Start Application 1 key */ +#define VK_LAUNCH_APP2 0xB7 /* Windows 2000/XP: Start Application 2 key */ + +/* 0xB8 and 0xB9 are reserved */ + +/* OEM keys */ + +#define VK_OEM_1 0xBA /* Used for miscellaneous characters; it can vary by keyboard. */ + /* Windows 2000/XP: For the US standard keyboard, the ';:' key */ + +#define VK_OEM_PLUS 0xBB /* Windows 2000/XP: For any country/region, the '+' key */ +#define VK_OEM_COMMA 0xBC /* Windows 2000/XP: For any country/region, the ',' key */ +#define VK_OEM_MINUS 0xBD /* Windows 2000/XP: For any country/region, the '-' key */ +#define VK_OEM_PERIOD 0xBE /* Windows 2000/XP: For any country/region, the '.' key */ + +#define VK_OEM_2 0xBF /* Used for miscellaneous characters; it can vary by keyboard. */ + /* Windows 2000/XP: For the US standard keyboard, the '/?' key */ + +#define VK_OEM_3 0xC0 /* Used for miscellaneous characters; it can vary by keyboard. */ + /* Windows 2000/XP: For the US standard keyboard, the '`~' key */ + +/* 0xC1 to 0xD7 are reserved */ +#define VK_ABNT_C1 0xC1 /* Brazilian (ABNT) Keyboard */ +#define VK_ABNT_C2 0xC2 /* Brazilian (ABNT) Keyboard */ + +/* 0xD8 to 0xDA are unassigned */ + +#define VK_OEM_4 0xDB /* Used for miscellaneous characters; it can vary by keyboard. */ + /* Windows 2000/XP: For the US standard keyboard, the '[{' key */ + +#define VK_OEM_5 0xDC /* Used for miscellaneous characters; it can vary by keyboard. */ + /* Windows 2000/XP: For the US standard keyboard, the '\|' key */ + +#define VK_OEM_6 0xDD /* Used for miscellaneous characters; it can vary by keyboard. */ + /* Windows 2000/XP: For the US standard keyboard, the ']}' key */ + +#define VK_OEM_7 0xDE /* Used for miscellaneous characters; it can vary by keyboard. */ +/* Windows 2000/XP: For the US standard keyboard, the 'single-quote/double-quote' key */ + +#define VK_OEM_8 0xDF /* Used for miscellaneous characters; it can vary by keyboard. */ + +/* 0xE0 is reserved */ + +#define VK_OEM_AX 0xE1 /* AX key on Japanese AX keyboard */ + +#define VK_OEM_102 0xE2 /* Windows 2000/XP: Either the angle bracket key or */ + /* the backslash key on the RT 102-key keyboard */ + +/* 0xE3 and 0xE4 are OEM specific */ + +#define VK_PROCESSKEY \ + 0xE5 /* Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP: IME PROCESS key \ + */ + +/* 0xE6 is OEM specific */ + +#define VK_PACKET \ + 0xE7 /* Windows 2000/XP: Used to pass Unicode characters as if they were keystrokes. */ +/* The #define VK_PACKET key is the low word of a 32-bit Virtual Key value used */ +/* for non-keyboard input methods. For more information, */ +/* see Remark in KEYBDINPUT, SendInput, WM_KEYDOWN, and WM_KEYUP */ + +/* 0xE8 is unassigned */ +/* 0xE9 to 0xF5 are OEM specific */ + +#define VK_OEM_RESET 0xE9 +#define VK_OEM_JUMP 0xEA +#define VK_OEM_PA1 0xEB +#define VK_OEM_PA2 0xEC +#define VK_OEM_PA3 0xED +#define VK_OEM_WSCTRL 0xEE +#define VK_OEM_CUSEL 0xEF +#define VK_OEM_ATTN 0xF0 +#define VK_OEM_FINISH 0xF1 +#define VK_OEM_COPY 0xF2 +#define VK_OEM_AUTO 0xF3 +#define VK_OEM_ENLW 0xF4 +#define VK_OEM_BACKTAB 0xF5 + +#define VK_ATTN 0xF6 /* Attn key */ +#define VK_CRSEL 0xF7 /* CrSel key */ +#define VK_EXSEL 0xF8 /* ExSel key */ +#define VK_EREOF 0xF9 /* Erase EOF key */ +#define VK_PLAY 0xFA /* Play key */ +#define VK_ZOOM 0xFB /* Zoom key */ +#define VK_NONAME 0xFC /* Reserved */ +#define VK_PA1 0xFD /* PA1 key */ +#define VK_OEM_CLEAR 0xFE /* Clear key */ + +#define VK_NONE 0xFF /* no key */ + +/** + * For East Asian Input Method Editors (IMEs) + * the following additional virtual keyboard definitions must be observed. + */ + +#define VK_DBE_ALPHANUMERIC 0xF0 /* Changes the mode to alphanumeric. */ +#define VK_DBE_KATAKANA 0xF1 /* Changes the mode to Katakana. */ +#define VK_DBE_HIRAGANA 0xF2 /* Changes the mode to Hiragana. */ +#define VK_DBE_SBCSCHAR 0xF3 /* Changes the mode to single-byte characters. */ +#define VK_DBE_DBCSCHAR 0xF4 /* Changes the mode to double-byte characters. */ +#define VK_DBE_ROMAN 0xF5 /* Changes the mode to Roman characters. */ +#define VK_DBE_NOROMAN 0xF6 /* Changes the mode to non-Roman characters. */ +#define VK_DBE_ENTERWORDREGISTERMODE 0xF7 /* Activates the word registration dialog box. */ +#define VK_DBE_ENTERIMECONFIGMODE \ + 0xF8 /* Activates a dialog box for setting up an IME environment. */ +#define VK_DBE_FLUSHSTRING 0xF9 /* Deletes the undetermined string without determining it. */ +#define VK_DBE_CODEINPUT 0xFA /* Changes the mode to code input. */ +#define VK_DBE_NOCODEINPUT 0xFB /* Changes the mode to no-code input. */ + +/* + * Virtual Scan Codes + */ + +/** + * Keyboard Type 4 + */ + +#define KBD4_T00 VK_NONE +#define KBD4_T01 VK_ESCAPE +#define KBD4_T02 VK_KEY_1 +#define KBD4_T03 VK_KEY_2 +#define KBD4_T04 VK_KEY_3 +#define KBD4_T05 VK_KEY_4 +#define KBD4_T06 VK_KEY_5 +#define KBD4_T07 VK_KEY_6 +#define KBD4_T08 VK_KEY_7 +#define KBD4_T09 VK_KEY_8 +#define KBD4_T0A VK_KEY_9 +#define KBD4_T0B VK_KEY_0 +#define KBD4_T0C VK_OEM_MINUS +#define KBD4_T0D VK_OEM_PLUS /* NE */ +#define KBD4_T0E VK_BACK +#define KBD4_T0F VK_TAB +#define KBD4_T10 VK_KEY_Q +#define KBD4_T11 VK_KEY_W +#define KBD4_T12 VK_KEY_E +#define KBD4_T13 VK_KEY_R +#define KBD4_T14 VK_KEY_T +#define KBD4_T15 VK_KEY_Y +#define KBD4_T16 VK_KEY_U +#define KBD4_T17 VK_KEY_I +#define KBD4_T18 VK_KEY_O +#define KBD4_T19 VK_KEY_P +#define KBD4_T1A VK_OEM_4 /* NE */ +#define KBD4_T1B VK_OEM_6 /* NE */ +#define KBD4_T1C VK_RETURN +#define KBD4_T1D VK_LCONTROL +#define KBD4_T1E VK_KEY_A +#define KBD4_T1F VK_KEY_S +#define KBD4_T20 VK_KEY_D +#define KBD4_T21 VK_KEY_F +#define KBD4_T22 VK_KEY_G +#define KBD4_T23 VK_KEY_H +#define KBD4_T24 VK_KEY_J +#define KBD4_T25 VK_KEY_K +#define KBD4_T26 VK_KEY_L +#define KBD4_T27 VK_OEM_1 /* NE */ +#define KBD4_T28 VK_OEM_7 /* NE */ +#define KBD4_T29 VK_OEM_3 /* NE */ +#define KBD4_T2A VK_LSHIFT +#define KBD4_T2B VK_OEM_5 +#define KBD4_T2C VK_KEY_Z +#define KBD4_T2D VK_KEY_X +#define KBD4_T2E VK_KEY_C +#define KBD4_T2F VK_KEY_V +#define KBD4_T30 VK_KEY_B +#define KBD4_T31 VK_KEY_N +#define KBD4_T32 VK_KEY_M +#define KBD4_T33 VK_OEM_COMMA +#define KBD4_T34 VK_OEM_PERIOD +#define KBD4_T35 VK_OEM_2 +#define KBD4_T36 VK_RSHIFT +#define KBD4_T37 VK_MULTIPLY +#define KBD4_T38 VK_LMENU +#define KBD4_T39 VK_SPACE +#define KBD4_T3A VK_CAPITAL +#define KBD4_T3B VK_F1 +#define KBD4_T3C VK_F2 +#define KBD4_T3D VK_F3 +#define KBD4_T3E VK_F4 +#define KBD4_T3F VK_F5 +#define KBD4_T40 VK_F6 +#define KBD4_T41 VK_F7 +#define KBD4_T42 VK_F8 +#define KBD4_T43 VK_F9 +#define KBD4_T44 VK_F10 +#define KBD4_T45 VK_NUMLOCK +#define KBD4_T46 VK_SCROLL +#define KBD4_T47 VK_NUMPAD7 /* VK_HOME */ +#define KBD4_T48 VK_NUMPAD8 /* VK_UP */ +#define KBD4_T49 VK_NUMPAD9 /* VK_PRIOR */ +#define KBD4_T4A VK_SUBTRACT +#define KBD4_T4B VK_NUMPAD4 /* VK_LEFT */ +#define KBD4_T4C VK_NUMPAD5 /* VK_CLEAR */ +#define KBD4_T4D VK_NUMPAD6 /* VK_RIGHT */ +#define KBD4_T4E VK_ADD +#define KBD4_T4F VK_NUMPAD1 /* VK_END */ +#define KBD4_T50 VK_NUMPAD2 /* VK_DOWN */ +#define KBD4_T51 VK_NUMPAD3 /* VK_NEXT */ +#define KBD4_T52 VK_NUMPAD0 /* VK_INSERT */ +#define KBD4_T53 VK_DECIMAL /* VK_DELETE */ +#define KBD4_T54 VK_SNAPSHOT +#define KBD4_T55 VK_NONE +#define KBD4_T56 VK_OEM_102 /* NE */ +#define KBD4_T57 VK_F11 /* NE */ +#define KBD4_T58 VK_F12 /* NE */ +#define KBD4_T59 VK_CLEAR +#define KBD4_T5A VK_OEM_WSCTRL +#define KBD4_T5B VK_OEM_FINISH +#define KBD4_T5C VK_OEM_JUMP +#define KBD4_T5D VK_EREOF +#define KBD4_T5E VK_OEM_BACKTAB +#define KBD4_T5F VK_OEM_AUTO +#define KBD4_T60 VK_NONE +#define KBD4_T61 VK_NONE +#define KBD4_T62 VK_ZOOM +#define KBD4_T63 VK_HELP +#define KBD4_T64 VK_F13 +#define KBD4_T65 VK_F14 +#define KBD4_T66 VK_F15 +#define KBD4_T67 VK_F16 +#define KBD4_T68 VK_F17 +#define KBD4_T69 VK_F18 +#define KBD4_T6A VK_F19 +#define KBD4_T6B VK_F20 +#define KBD4_T6C VK_F21 +#define KBD4_T6D VK_F22 +#define KBD4_T6E VK_F23 +#define KBD4_T6F VK_OEM_PA3 +#define KBD4_T70 VK_NONE +#define KBD4_T71 VK_OEM_RESET +#define KBD4_T72 VK_NONE +#define KBD4_T73 VK_ABNT_C1 +#define KBD4_T74 VK_NONE +#define KBD4_T75 VK_NONE +#define KBD4_T76 VK_F24 +#define KBD4_T77 VK_NONE +#define KBD4_T78 VK_NONE +#define KBD4_T79 VK_NONE +#define KBD4_T7A VK_NONE +#define KBD4_T7B VK_OEM_PA1 +#define KBD4_T7C VK_TAB +#define KBD4_T7D VK_NONE +#define KBD4_T7E VK_ABNT_C2 +#define KBD4_T7F VK_OEM_PA2 + +#define KBD4_X10 VK_MEDIA_PREV_TRACK +#define KBD4_X19 VK_MEDIA_NEXT_TRACK +#define KBD4_X1C VK_RETURN +#define KBD4_X1D VK_RCONTROL +#define KBD4_X20 VK_VOLUME_MUTE +#define KBD4_X21 VK_LAUNCH_APP2 +#define KBD4_X22 VK_MEDIA_PLAY_PAUSE +#define KBD4_X24 VK_MEDIA_STOP +#define KBD4_X2E VK_VOLUME_DOWN +#define KBD4_X30 VK_VOLUME_UP +#define KBD4_X32 VK_BROWSER_HOME +#define KBD4_X35 VK_DIVIDE +#define KBD4_X37 VK_SNAPSHOT +#define KBD4_X38 VK_RMENU +#define KBD4_X46 VK_PAUSE /* VK_CANCEL */ +#define KBD4_X47 VK_HOME +#define KBD4_X48 VK_UP +#define KBD4_X49 VK_PRIOR +#define KBD4_X4B VK_LEFT +#define KBD4_X4D VK_RIGHT +#define KBD4_X4F VK_END +#define KBD4_X50 VK_DOWN +#define KBD4_X51 VK_NEXT /* NE */ +#define KBD4_X52 VK_INSERT +#define KBD4_X53 VK_DELETE +#define KBD4_X5B VK_LWIN +#define KBD4_X5C VK_RWIN +#define KBD4_X5D VK_APPS +#define KBD4_X5E VK_POWER +#define KBD4_X5F VK_SLEEP +#define KBD4_X65 VK_BROWSER_SEARCH +#define KBD4_X66 VK_BROWSER_FAVORITES +#define KBD4_X67 VK_BROWSER_REFRESH +#define KBD4_X68 VK_BROWSER_STOP +#define KBD4_X69 VK_BROWSER_FORWARD +#define KBD4_X6A VK_BROWSER_BACK +#define KBD4_X6B VK_LAUNCH_APP1 +#define KBD4_X6C VK_LAUNCH_MAIL +#define KBD4_X6D VK_LAUNCH_MEDIA_SELECT + +#define KBD4_Y1D VK_PAUSE + +/** + * Keyboard Type 7 + */ + +#define KBD7_T00 VK_NONE +#define KBD7_T01 VK_ESCAPE +#define KBD7_T02 VK_KEY_1 +#define KBD7_T03 VK_KEY_2 +#define KBD7_T04 VK_KEY_3 +#define KBD7_T05 VK_KEY_4 +#define KBD7_T06 VK_KEY_5 +#define KBD7_T07 VK_KEY_6 +#define KBD7_T08 VK_KEY_7 +#define KBD7_T09 VK_KEY_8 +#define KBD7_T0A VK_KEY_9 +#define KBD7_T0B VK_KEY_0 +#define KBD7_T0C VK_OEM_MINUS +#define KBD7_T0D VK_OEM_PLUS +#define KBD7_T0E VK_BACK +#define KBD7_T0F VK_TAB +#define KBD7_T10 VK_KEY_Q +#define KBD7_T11 VK_KEY_W +#define KBD7_T12 VK_KEY_E +#define KBD7_T13 VK_KEY_R +#define KBD7_T14 VK_KEY_T +#define KBD7_T15 VK_KEY_Y +#define KBD7_T16 VK_KEY_U +#define KBD7_T17 VK_KEY_I +#define KBD7_T18 VK_KEY_O +#define KBD7_T19 VK_KEY_P +#define KBD7_T1A VK_OEM_4 /* NE */ +#define KBD7_T1B VK_OEM_6 /* NE */ +#define KBD7_T1C VK_RETURN +#define KBD7_T1D VK_LCONTROL +#define KBD7_T1E VK_KEY_A +#define KBD7_T1F VK_KEY_S +#define KBD7_T20 VK_KEY_D +#define KBD7_T21 VK_KEY_F +#define KBD7_T22 VK_KEY_G +#define KBD7_T23 VK_KEY_H +#define KBD7_T24 VK_KEY_J +#define KBD7_T25 VK_KEY_K +#define KBD7_T26 VK_KEY_L +#define KBD7_T27 VK_OEM_1 +#define KBD7_T28 VK_OEM_7 +#define KBD7_T29 VK_OEM_3 /* NE */ +#define KBD7_T2A VK_LSHIFT +#define KBD7_T2B VK_OEM_5 /* NE */ +#define KBD7_T2C VK_KEY_Z +#define KBD7_T2D VK_KEY_X +#define KBD7_T2E VK_KEY_C +#define KBD7_T2F VK_KEY_V +#define KBD7_T30 VK_KEY_B +#define KBD7_T31 VK_KEY_N +#define KBD7_T32 VK_KEY_M +#define KBD7_T33 VK_OEM_COMMA +#define KBD7_T34 VK_OEM_PERIOD +#define KBD7_T35 VK_OEM_2 +#define KBD7_T36 VK_RSHIFT +#define KBD7_T37 VK_MULTIPLY +#define KBD7_T38 VK_LMENU +#define KBD7_T39 VK_SPACE +#define KBD7_T3A VK_CAPITAL +#define KBD7_T3B VK_F1 +#define KBD7_T3C VK_F2 +#define KBD7_T3D VK_F3 +#define KBD7_T3E VK_F4 +#define KBD7_T3F VK_F5 +#define KBD7_T40 VK_F6 +#define KBD7_T41 VK_F7 +#define KBD7_T42 VK_F8 +#define KBD7_T43 VK_F9 +#define KBD7_T44 VK_F10 +#define KBD7_T45 VK_NUMLOCK +#define KBD7_T46 VK_SCROLL +#define KBD7_T47 VK_NUMPAD7 /* VK_HOME */ +#define KBD7_T48 VK_NUMPAD8 /* VK_UP */ +#define KBD7_T49 VK_NUMPAD9 /* VK_PRIOR */ +#define KBD7_T4A VK_SUBTRACT +#define KBD7_T4B VK_NUMPAD4 /* VK_LEFT */ +#define KBD7_T4C VK_NUMPAD5 /* VK_CLEAR */ +#define KBD7_T4D VK_NUMPAD6 /* VK_RIGHT */ +#define KBD7_T4E VK_ADD +#define KBD7_T4F VK_NUMPAD1 /* VK_END */ +#define KBD7_T50 VK_NUMPAD2 /* VK_DOWN */ +#define KBD7_T51 VK_NUMPAD3 /* VK_NEXT */ +#define KBD7_T52 VK_NUMPAD0 /* VK_INSERT */ +#define KBD7_T53 VK_DECIMAL /* VK_DELETE */ +#define KBD7_T54 VK_SNAPSHOT +#define KBD7_T55 VK_NONE +#define KBD7_T56 VK_OEM_102 +#define KBD7_T57 VK_F11 +#define KBD7_T58 VK_F12 +#define KBD7_T59 VK_CLEAR +#define KBD7_T5A VK_NONAME /* NE */ +#define KBD7_T5B VK_NONAME /* NE */ +#define KBD7_T5C VK_NONAME /* NE */ +#define KBD7_T5D VK_EREOF +#define KBD7_T5E VK_NONE /* NE */ +#define KBD7_T5F VK_NONAME /* NE */ +#define KBD7_T60 VK_NONE +#define KBD7_T61 VK_NONE /* NE */ +#define KBD7_T62 VK_NONE /* NE */ +#define KBD7_T63 VK_NONE +#define KBD7_T64 VK_F13 +#define KBD7_T65 VK_F14 +#define KBD7_T66 VK_F15 +#define KBD7_T67 VK_F16 +#define KBD7_T68 VK_F17 +#define KBD7_T69 VK_F18 +#define KBD7_T6A VK_F19 +#define KBD7_T6B VK_F20 +#define KBD7_T6C VK_F21 +#define KBD7_T6D VK_F22 +#define KBD7_T6E VK_F23 +#define KBD7_T6F VK_NONE /* NE */ +#define KBD7_T70 VK_HKTG /* NE */ +#define KBD7_T71 VK_NONE /* NE */ +#define KBD7_T72 VK_NONE +#define KBD7_T73 VK_ABNT_C1 +#define KBD7_T74 VK_NONE +#define KBD7_T75 VK_NONE +#define KBD7_T76 VK_F24 +#define KBD7_T77 VK_NONE +#define KBD7_T78 VK_NONE +#define KBD7_T79 VK_CONVERT /* NE */ +#define KBD7_T7A VK_NONE +#define KBD7_T7B VK_NONCONVERT /* NE */ +#define KBD7_T7C VK_TAB +#define KBD7_T7D VK_OEM_8 +#define KBD7_T7E VK_ABNT_C2 +#define KBD7_T7F VK_OEM_PA2 + +#define KBD7_X10 VK_MEDIA_PREV_TRACK +#define KBD7_X19 VK_MEDIA_NEXT_TRACK +#define KBD7_X1C VK_RETURN +#define KBD7_X1D VK_RCONTROL +#define KBD7_X20 VK_VOLUME_MUTE +#define KBD7_X21 VK_LAUNCH_APP2 +#define KBD7_X22 VK_MEDIA_PLAY_PAUSE +#define KBD7_X24 VK_MEDIA_STOP +#define KBD7_X2E VK_VOLUME_DOWN +#define KBD7_X30 VK_VOLUME_UP +#define KBD7_X32 VK_BROWSER_HOME +#define KBD7_X33 VK_NONE +#define KBD7_X35 VK_DIVIDE +#define KBD7_X37 VK_SNAPSHOT +#define KBD7_X38 VK_RMENU +#define KBD7_X42 VK_NONE +#define KBD7_X43 VK_NONE +#define KBD7_X44 VK_NONE +#define KBD7_X46 VK_CANCEL +#define KBD7_X47 VK_HOME +#define KBD7_X48 VK_UP +#define KBD7_X49 VK_PRIOR +#define KBD7_X4B VK_LEFT +#define KBD7_X4D VK_RIGHT +#define KBD7_X4F VK_END +#define KBD7_X50 VK_DOWN +#define KBD7_X51 VK_NEXT +#define KBD7_X52 VK_INSERT +#define KBD7_X53 VK_DELETE +#define KBD7_X5B VK_LWIN +#define KBD7_X5C VK_RWIN +#define KBD7_X5D VK_APPS +#define KBD7_X5E VK_POWER +#define KBD7_X5F VK_SLEEP +#define KBD7_X65 VK_BROWSER_SEARCH +#define KBD7_X66 VK_BROWSER_FAVORITES +#define KBD7_X67 VK_BROWSER_REFRESH +#define KBD7_X68 VK_BROWSER_STOP +#define KBD7_X69 VK_BROWSER_FORWARD +#define KBD7_X6A VK_BROWSER_BACK +#define KBD7_X6B VK_LAUNCH_APP1 +#define KBD7_X6C VK_LAUNCH_MAIL +#define KBD7_X6D VK_LAUNCH_MEDIA_SELECT +#define KBD7_XF1 VK_NONE /* NE */ +#define KBD7_XF2 VK_NONE /* NE */ + +#define KBD7_Y1D VK_PAUSE + +/** + * X11 Keycodes + */ + +/** + * Mac OS X + */ + +#define APPLE_VK_ANSI_A 0x00 +#define APPLE_VK_ANSI_S 0x01 +#define APPLE_VK_ANSI_D 0x02 +#define APPLE_VK_ANSI_F 0x03 +#define APPLE_VK_ANSI_H 0x04 +#define APPLE_VK_ANSI_G 0x05 +#define APPLE_VK_ANSI_Z 0x06 +#define APPLE_VK_ANSI_X 0x07 +#define APPLE_VK_ANSI_C 0x08 +#define APPLE_VK_ANSI_V 0x09 +#define APPLE_VK_ISO_Section 0x0A +#define APPLE_VK_ANSI_B 0x0B +#define APPLE_VK_ANSI_Q 0x0C +#define APPLE_VK_ANSI_W 0x0D +#define APPLE_VK_ANSI_E 0x0E +#define APPLE_VK_ANSI_R 0x0F +#define APPLE_VK_ANSI_Y 0x10 +#define APPLE_VK_ANSI_T 0x11 +#define APPLE_VK_ANSI_1 0x12 +#define APPLE_VK_ANSI_2 0x13 +#define APPLE_VK_ANSI_3 0x14 +#define APPLE_VK_ANSI_4 0x15 +#define APPLE_VK_ANSI_6 0x16 +#define APPLE_VK_ANSI_5 0x17 +#define APPLE_VK_ANSI_Equal 0x18 +#define APPLE_VK_ANSI_9 0x19 +#define APPLE_VK_ANSI_7 0x1A +#define APPLE_VK_ANSI_Minus 0x1B +#define APPLE_VK_ANSI_8 0x1C +#define APPLE_VK_ANSI_0 0x1D +#define APPLE_VK_ANSI_RightBracket 0x1E +#define APPLE_VK_ANSI_O 0x1F +#define APPLE_VK_ANSI_U 0x20 +#define APPLE_VK_ANSI_LeftBracket 0x21 +#define APPLE_VK_ANSI_I 0x22 +#define APPLE_VK_ANSI_P 0x23 +#define APPLE_VK_Return 0x24 +#define APPLE_VK_ANSI_L 0x25 +#define APPLE_VK_ANSI_J 0x26 +#define APPLE_VK_ANSI_Quote 0x27 +#define APPLE_VK_ANSI_K 0x28 +#define APPLE_VK_ANSI_Semicolon 0x29 +#define APPLE_VK_ANSI_Backslash 0x2A +#define APPLE_VK_ANSI_Comma 0x2B +#define APPLE_VK_ANSI_Slash 0x2C +#define APPLE_VK_ANSI_N 0x2D +#define APPLE_VK_ANSI_M 0x2E +#define APPLE_VK_ANSI_Period 0x2F +#define APPLE_VK_Tab 0x30 +#define APPLE_VK_Space 0x31 +#define APPLE_VK_ANSI_Grave 0x32 +#define APPLE_VK_Delete 0x33 +#define APPLE_VK_0x34 0x34 +#define APPLE_VK_Escape 0x35 +#define APPLE_VK_0x36 0x36 +#define APPLE_VK_Command 0x37 +#define APPLE_VK_Shift 0x38 +#define APPLE_VK_CapsLock 0x39 +#define APPLE_VK_Option 0x3A +#define APPLE_VK_Control 0x3B +#define APPLE_VK_RightShift 0x3C +#define APPLE_VK_RightOption 0x3D +#define APPLE_VK_RightControl 0x3E +#define APPLE_VK_Function 0x3F +#define APPLE_VK_F17 0x40 +#define APPLE_VK_ANSI_KeypadDecimal 0x41 +#define APPLE_VK_0x42 0x42 +#define APPLE_VK_ANSI_KeypadMultiply 0x43 +#define APPLE_VK_0x44 0x44 +#define APPLE_VK_ANSI_KeypadPlus 0x45 +#define APPLE_VK_0x46 0x46 +#define APPLE_VK_ANSI_KeypadClear 0x47 +#define APPLE_VK_VolumeUp 0x48 +#define APPLE_VK_VolumeDown 0x49 +#define APPLE_VK_Mute 0x4A +#define APPLE_VK_ANSI_KeypadDivide 0x4B +#define APPLE_VK_ANSI_KeypadEnter 0x4C +#define APPLE_VK_0x4D 0x4D +#define APPLE_VK_ANSI_KeypadMinus 0x4E +#define APPLE_VK_F18 0x4F +#define APPLE_VK_F19 0x50 +#define APPLE_VK_ANSI_KeypadEquals 0x51 +#define APPLE_VK_ANSI_Keypad0 0x52 +#define APPLE_VK_ANSI_Keypad1 0x53 +#define APPLE_VK_ANSI_Keypad2 0x54 +#define APPLE_VK_ANSI_Keypad3 0x55 +#define APPLE_VK_ANSI_Keypad4 0x56 +#define APPLE_VK_ANSI_Keypad5 0x57 +#define APPLE_VK_ANSI_Keypad6 0x58 +#define APPLE_VK_ANSI_Keypad7 0x59 +#define APPLE_VK_F20 0x5A +#define APPLE_VK_ANSI_Keypad8 0x5B +#define APPLE_VK_ANSI_Keypad9 0x5C +#define APPLE_VK_JIS_Yen 0x5D +#define APPLE_VK_JIS_Underscore 0x5E +#define APPLE_VK_JIS_KeypadComma 0x5F +#define APPLE_VK_F5 0x60 +#define APPLE_VK_F6 0x61 +#define APPLE_VK_F7 0x62 +#define APPLE_VK_F3 0x63 +#define APPLE_VK_F8 0x64 +#define APPLE_VK_F9 0x65 +#define APPLE_VK_JIS_Eisu 0x66 +#define APPLE_VK_F11 0x67 +#define APPLE_VK_JIS_Kana 0x68 +#define APPLE_VK_F13 0x69 +#define APPLE_VK_F16 0x6A +#define APPLE_VK_F14 0x6B +#define APPLE_VK_F10 0x6D +#define APPLE_VK_0x6C 0x6C +#define APPLE_VK_0x6E 0x6E +#define APPLE_VK_F12 0x6F +#define APPLE_VK_0x70 0x70 +#define APPLE_VK_F15 0x71 +#define APPLE_VK_Help 0x72 +#define APPLE_VK_Home 0x73 +#define APPLE_VK_PageUp 0x74 +#define APPLE_VK_ForwardDelete 0x75 +#define APPLE_VK_F4 0x76 +#define APPLE_VK_End 0x77 +#define APPLE_VK_F2 0x78 +#define APPLE_VK_PageDown 0x79 +#define APPLE_VK_F1 0x7A +#define APPLE_VK_LeftArrow 0x7B +#define APPLE_VK_RightArrow 0x7C +#define APPLE_VK_DownArrow 0x7D +#define APPLE_VK_UpArrow 0x7E + +#ifdef __cplusplus +extern "C" +{ +#endif + + /* [MS-RDPBCGR] 2.2.1.3.2 Client Core Data (TS_UD_CS_CORE) KeyboardType */ + enum WINPR_KBD_TYPE + { + WINPR_KBD_TYPE_IBM_PC_XT = 0x00000001, /* IBM PC/XT or compatible (83-key) keyboard */ + WINPR_KBD_TYPE_OLIVETTI_ICO = 0x00000002, /* Olivetti "ICO" (102-key) keyboard */ + WINPR_KBD_TYPE_IBM_PC_AT = 0x00000003, /* IBM PC/AT (84-key) and similar keyboards */ + WINPR_KBD_TYPE_IBM_ENHANCED = 0x00000004, /* IBM enhanced (101-key or 102-key) keyboard */ + WINPR_KBD_TYPE_NOKIA_1050 = 0x00000005, /* Nokia 1050 and similar keyboards */ + WINPR_KBD_TYPE_NOKIA_9140 = 0x00000006, /* Nokia 9140 and similar keyboards */ + WINPR_KBD_TYPE_JAPANESE = 0x00000007 /* Japanese keyboard */ + }; + + /** + * Functions + */ + + WINPR_API const char* GetVirtualKeyName(DWORD vkcode); + WINPR_API DWORD GetVirtualKeyCodeFromName(const char* vkname); + WINPR_API DWORD GetVirtualKeyCodeFromXkbKeyName(const char* xkbname); + + WINPR_API DWORD GetVirtualKeyCodeFromVirtualScanCode(DWORD scancode, + DWORD /* WINPR_KBD_TYPE */ dwKeyboardType); + WINPR_API DWORD GetVirtualScanCodeFromVirtualKeyCode(DWORD vkcode, + DWORD /* WINPR_KBD_TYPE */ dwKeyboardType); + + typedef enum + { + WINPR_KEYCODE_TYPE_NONE = 0x00000000, + WINPR_KEYCODE_TYPE_APPLE = 0x00000001, + WINPR_KEYCODE_TYPE_EVDEV = 0x00000002, + WINPR_KEYCODE_TYPE_XKB = 0x00000003 + } WINPR_KEYCODE_TYPE; + + WINPR_API DWORD GetVirtualKeyCodeFromKeycode(DWORD keycode, WINPR_KEYCODE_TYPE type); + WINPR_API DWORD GetKeycodeFromVirtualKeyCode(DWORD keycode, WINPR_KEYCODE_TYPE type); + +#ifdef __cplusplus +} +#endif + +#endif /* WINPR_INPUT_H */ diff --git a/winpr/include/winpr/interlocked.h b/winpr/include/winpr/interlocked.h new file mode 100644 index 0000000..a0f9521 --- /dev/null +++ b/winpr/include/winpr/interlocked.h @@ -0,0 +1,216 @@ +/** + * WinPR: Windows Portable Runtime + * Interlocked Singly-Linked Lists + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_INTERLOCKED_H +#define WINPR_INTERLOCKED_H + +#include <winpr/spec.h> +#include <winpr/platform.h> +#include <winpr/winpr.h> +#include <winpr/wtypes.h> +#include <winpr/platform.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + +#ifndef _WIN32 + +#ifndef CONTAINING_RECORD +#define CONTAINING_RECORD(address, type, field) \ + ((type*)(((ULONG_PTR)address) - (ULONG_PTR)(&(((type*)0)->field)))) +#endif + + typedef struct S_WINPR_LIST_ENTRY WINPR_LIST_ENTRY; + typedef struct S_WINPR_LIST_ENTRY* WINPR_PLIST_ENTRY; + + struct S_WINPR_LIST_ENTRY + { + WINPR_PLIST_ENTRY Flink; + WINPR_PLIST_ENTRY Blink; + }; + + typedef struct S_WINPR_SINGLE_LIST_ENTRY WINPR_SINGLE_LIST_ENTRY; + typedef struct S_WINPR_SINGLE_LIST_ENTRY* WINPR_PSINGLE_LIST_ENTRY; + + struct S_WINPR_SINGLE_LIST_ENTRY + { + WINPR_PSINGLE_LIST_ENTRY Next; + }; + + typedef struct WINPR_LIST_ENTRY32 + { + DWORD Flink; + DWORD Blink; + } WINPR_LIST_ENTRY32; + typedef WINPR_LIST_ENTRY32* WINPR_PLIST_ENTRY32; + + typedef struct WINPR_LIST_ENTRY64 + { + ULONGLONG Flink; + ULONGLONG Blink; + } WINPR_LIST_ENTRY64; + typedef WINPR_LIST_ENTRY64* WINPR_PLIST_ENTRY64; + +#ifdef _WIN64 + + typedef struct S_WINPR_SLIST_ENTRY* WINPR_PSLIST_ENTRY; + typedef struct DECLSPEC_ALIGN(16) S_WINPR_SLIST_ENTRY + { + WINPR_PSLIST_ENTRY Next; + } WINPR_SLIST_ENTRY; + +#else /* _WIN64 */ + + WINPR_PRAGMA_DIAG_PUSH + WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO + +#define WINPR_SLIST_ENTRY WINPR_SINGLE_LIST_ENTRY +#define _WINPR_SLIST_ENTRY _WINPR_SINGLE_LIST_ENTRY +#define WINPR_PSLIST_ENTRY WINPR_PSINGLE_LIST_ENTRY + + WINPR_PRAGMA_DIAG_POP + +#endif /* _WIN64 */ + +#ifdef _WIN64 + + typedef union DECLSPEC_ALIGN(16) + { + struct + { + ULONGLONG Alignment; + ULONGLONG Region; + } DUMMYSTRUCTNAME; + + struct + { + ULONGLONG Depth : 16; + ULONGLONG Sequence : 9; + ULONGLONG NextEntry : 39; + ULONGLONG HeaderType : 1; + ULONGLONG Init : 1; + ULONGLONG Reserved : 59; + ULONGLONG Region : 3; + } Header8; + + struct + { + ULONGLONG Depth : 16; + ULONGLONG Sequence : 48; + ULONGLONG HeaderType : 1; + ULONGLONG Reserved : 3; + ULONGLONG NextEntry : 60; + } HeaderX64; + } WINPR_SLIST_HEADER, *WINPR_PSLIST_HEADER; + +#else /* _WIN64 */ + + typedef union + { + ULONGLONG Alignment; + + struct + { + WINPR_SLIST_ENTRY Next; + WORD Depth; + WORD Sequence; + } DUMMYSTRUCTNAME; + } WINPR_SLIST_HEADER, *WINPR_PSLIST_HEADER; + +#endif /* _WIN64 */ + + /* Singly-Linked List */ + + WINPR_API VOID InitializeSListHead(WINPR_PSLIST_HEADER ListHead); + + WINPR_API WINPR_PSLIST_ENTRY InterlockedPushEntrySList(WINPR_PSLIST_HEADER ListHead, + WINPR_PSLIST_ENTRY ListEntry); + WINPR_API WINPR_PSLIST_ENTRY InterlockedPushListSListEx(WINPR_PSLIST_HEADER ListHead, + WINPR_PSLIST_ENTRY List, + WINPR_PSLIST_ENTRY ListEnd, + ULONG Count); + WINPR_API WINPR_PSLIST_ENTRY InterlockedPopEntrySList(WINPR_PSLIST_HEADER ListHead); + WINPR_API WINPR_PSLIST_ENTRY InterlockedFlushSList(WINPR_PSLIST_HEADER ListHead); + + WINPR_API USHORT QueryDepthSList(WINPR_PSLIST_HEADER ListHead); + + WINPR_API LONG InterlockedIncrement(LONG volatile* Addend); + WINPR_API LONG InterlockedDecrement(LONG volatile* Addend); + + WINPR_API LONG InterlockedExchange(LONG volatile* Target, LONG Value); + WINPR_API LONG InterlockedExchangeAdd(LONG volatile* Addend, LONG Value); + + WINPR_API LONG InterlockedCompareExchange(LONG volatile* Destination, LONG Exchange, + LONG Comperand); + + WINPR_API PVOID InterlockedCompareExchangePointer(PVOID volatile* Destination, PVOID Exchange, + PVOID Comperand); + +#else /* _WIN32 */ +#define WINPR_LIST_ENTRY LIST_ENTRY +#define WINPR_PLIST_ENTRY PLIST_ENTRY + +#define WINPR_SINGLE_LIST_ENTRY SINGLE_LIST_ENTRY +#define WINPR_PSINGLE_LIST_ENTRY PSINGLE_LIST_ENTRY + +#define WINPR_SLIST_ENTRY SLIST_ENTRY +#define WINPR_PSLIST_ENTRY PSLIST_ENTRY + +#define WINPR_SLIST_HEADER SLIST_HEADER +#define WINPR_PSLIST_HEADER PSLIST_HEADER + +#endif /* _WIN32 */ + +#if (!defined(_WIN32) || \ + (defined(_WIN32) && (_WIN32_WINNT < 0x0502) && !defined(InterlockedCompareExchange64))) +#define WINPR_INTERLOCKED_COMPARE_EXCHANGE64 1 +#endif + +#ifdef WINPR_INTERLOCKED_COMPARE_EXCHANGE64 + + WINPR_API LONGLONG InterlockedCompareExchange64(LONGLONG volatile* Destination, + LONGLONG Exchange, LONGLONG Comperand); + +#endif + + /* Doubly-Linked List */ + + WINPR_API VOID InitializeListHead(WINPR_PLIST_ENTRY ListHead); + + WINPR_API BOOL IsListEmpty(const WINPR_LIST_ENTRY* ListHead); + + WINPR_API BOOL RemoveEntryList(WINPR_PLIST_ENTRY Entry); + + WINPR_API VOID InsertHeadList(WINPR_PLIST_ENTRY ListHead, WINPR_PLIST_ENTRY Entry); + WINPR_API WINPR_PLIST_ENTRY RemoveHeadList(WINPR_PLIST_ENTRY ListHead); + + WINPR_API VOID InsertTailList(WINPR_PLIST_ENTRY ListHead, WINPR_PLIST_ENTRY Entry); + WINPR_API WINPR_PLIST_ENTRY RemoveTailList(WINPR_PLIST_ENTRY ListHead); + WINPR_API VOID AppendTailList(WINPR_PLIST_ENTRY ListHead, WINPR_PLIST_ENTRY ListToAppend); + + WINPR_API VOID PushEntryList(WINPR_PSINGLE_LIST_ENTRY ListHead, WINPR_PSINGLE_LIST_ENTRY Entry); + WINPR_API WINPR_PSINGLE_LIST_ENTRY PopEntryList(WINPR_PSINGLE_LIST_ENTRY ListHead); + +#ifdef __cplusplus +} +#endif + +#endif /* WINPR_INTERLOCKED_H */ diff --git a/winpr/include/winpr/intrin.h b/winpr/include/winpr/intrin.h new file mode 100644 index 0000000..066f45f --- /dev/null +++ b/winpr/include/winpr/intrin.h @@ -0,0 +1,93 @@ +/** + * WinPR: Windows Portable Runtime + * C Run-Time Library Routines + * + * Copyright 2015 Thincast Technologies GmbH + * Copyright 2015 Bernhard Miklautz <bernhard.miklautz@thincast.com> + * + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_INTRIN_H +#define WINPR_INTRIN_H + +#if !defined(_WIN32) || defined(__MINGW32__) + +/** + * __lzcnt16, __lzcnt, __lzcnt64: + * http://msdn.microsoft.com/en-us/library/bb384809/ + * + * Beware: the result of __builtin_clz(0) is undefined + */ + +#if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)) + +static INLINE UINT32 __lzcnt(UINT32 _val32) +{ + return ((UINT32)__builtin_clz(_val32)); +} + +#if !(defined(__MINGW32__) && defined(__clang__)) +static INLINE UINT16 __lzcnt16(UINT16 _val16) +{ + return ((UINT16)(__builtin_clz((UINT32)_val16) - 16)); +} +#endif /* !(defined(__MINGW32__) && defined(__clang__)) */ + +#else /* (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2) */ + +static INLINE UINT32 __lzcnt(UINT32 x) +{ + unsigned y; + int n = 32; + y = x >> 16; + if (y != 0) + { + n = n - 16; + x = y; + } + y = x >> 8; + if (y != 0) + { + n = n - 8; + x = y; + } + y = x >> 4; + if (y != 0) + { + n = n - 4; + x = y; + } + y = x >> 2; + if (y != 0) + { + n = n - 2; + x = y; + } + y = x >> 1; + if (y != 0) + return n - 2; + return n - x; +} + +static INLINE UINT16 __lzcnt16(UINT16 x) +{ + return ((UINT16)__lzcnt((UINT32)x)); +} + +#endif /* (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2) */ + +#endif /* !defined(_WIN32) || defined(__MINGW32__) */ + +#endif /* WINPR_INTRIN_H */ diff --git a/winpr/include/winpr/io.h b/winpr/include/winpr/io.h new file mode 100644 index 0000000..2a0e34c --- /dev/null +++ b/winpr/include/winpr/io.h @@ -0,0 +1,254 @@ +/** + * WinPR: Windows Portable Runtime + * Asynchronous I/O Functions + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_IO_H +#define WINPR_IO_H + +#include <winpr/winpr.h> +#include <winpr/wtypes.h> + +#ifdef _WIN32 + +#include <winioctl.h> + +#else + +#include <winpr/nt.h> + +typedef struct +{ + ULONG_PTR Internal; + ULONG_PTR InternalHigh; + union + { + struct + { + DWORD Offset; + DWORD OffsetHigh; + }; + PVOID Pointer; + }; + HANDLE hEvent; +} OVERLAPPED, *LPOVERLAPPED; + +typedef struct +{ + ULONG_PTR lpCompletionKey; + LPOVERLAPPED lpOverlapped; + ULONG_PTR Internal; + DWORD dwNumberOfBytesTransferred; +} OVERLAPPED_ENTRY, *LPOVERLAPPED_ENTRY; + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API BOOL GetOverlappedResult(HANDLE hFile, LPOVERLAPPED lpOverlapped, + LPDWORD lpNumberOfBytesTransferred, BOOL bWait); + + WINPR_API BOOL GetOverlappedResultEx(HANDLE hFile, LPOVERLAPPED lpOverlapped, + LPDWORD lpNumberOfBytesTransferred, DWORD dwMilliseconds, + BOOL bAlertable); + + WINPR_API BOOL DeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID lpInBuffer, + DWORD nInBufferSize, LPVOID lpOutBuffer, DWORD nOutBufferSize, + LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped); + + WINPR_API HANDLE CreateIoCompletionPort(HANDLE FileHandle, HANDLE ExistingCompletionPort, + ULONG_PTR CompletionKey, + DWORD NumberOfConcurrentThreads); + + WINPR_API BOOL GetQueuedCompletionStatus(HANDLE CompletionPort, + LPDWORD lpNumberOfBytesTransferred, + PULONG_PTR lpCompletionKey, LPOVERLAPPED* lpOverlapped, + DWORD dwMilliseconds); + + WINPR_API BOOL GetQueuedCompletionStatusEx(HANDLE CompletionPort, + LPOVERLAPPED_ENTRY lpCompletionPortEntries, + ULONG ulCount, PULONG ulNumEntriesRemoved, + DWORD dwMilliseconds, BOOL fAlertable); + + WINPR_API BOOL PostQueuedCompletionStatus(HANDLE CompletionPort, + DWORD dwNumberOfBytesTransferred, + ULONG_PTR dwCompletionKey, LPOVERLAPPED lpOverlapped); + + WINPR_API BOOL CancelIo(HANDLE hFile); + + WINPR_API BOOL CancelIoEx(HANDLE hFile, LPOVERLAPPED lpOverlapped); + + WINPR_API BOOL CancelSynchronousIo(HANDLE hThread); + +#ifdef __cplusplus +} +#endif + +#define DEVICE_TYPE ULONG + +#define FILE_DEVICE_BEEP 0x00000001 +#define FILE_DEVICE_CD_ROM 0x00000002 +#define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003 +#define FILE_DEVICE_CONTROLLER 0x00000004 +#define FILE_DEVICE_DATALINK 0x00000005 +#define FILE_DEVICE_DFS 0x00000006 +#define FILE_DEVICE_DISK 0x00000007 +#define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008 +#define FILE_DEVICE_FILE_SYSTEM 0x00000009 +#define FILE_DEVICE_INPORT_PORT 0x0000000a +#define FILE_DEVICE_KEYBOARD 0x0000000b +#define FILE_DEVICE_MAILSLOT 0x0000000c +#define FILE_DEVICE_MIDI_IN 0x0000000d +#define FILE_DEVICE_MIDI_OUT 0x0000000e +#define FILE_DEVICE_MOUSE 0x0000000f +#define FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010 +#define FILE_DEVICE_NAMED_PIPE 0x00000011 +#define FILE_DEVICE_NETWORK 0x00000012 +#define FILE_DEVICE_NETWORK_BROWSER 0x00000013 +#define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014 +#define FILE_DEVICE_NULL 0x00000015 +#define FILE_DEVICE_PARALLEL_PORT 0x00000016 +#define FILE_DEVICE_PHYSICAL_NETCARD 0x00000017 +#define FILE_DEVICE_PRINTER 0x00000018 +#define FILE_DEVICE_SCANNER 0x00000019 +#define FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a +#define FILE_DEVICE_SERIAL_PORT 0x0000001b +#define FILE_DEVICE_SCREEN 0x0000001c +#define FILE_DEVICE_SOUND 0x0000001d +#define FILE_DEVICE_STREAMS 0x0000001e +#define FILE_DEVICE_TAPE 0x0000001f +#define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020 +#define FILE_DEVICE_TRANSPORT 0x00000021 +#define FILE_DEVICE_UNKNOWN 0x00000022 +#define FILE_DEVICE_VIDEO 0x00000023 +#define FILE_DEVICE_VIRTUAL_DISK 0x00000024 +#define FILE_DEVICE_WAVE_IN 0x00000025 +#define FILE_DEVICE_WAVE_OUT 0x00000026 +#define FILE_DEVICE_8042_PORT 0x00000027 +#define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028 +#define FILE_DEVICE_BATTERY 0x00000029 +#define FILE_DEVICE_BUS_EXTENDER 0x0000002a +#define FILE_DEVICE_MODEM 0x0000002b +#define FILE_DEVICE_VDM 0x0000002c +#define FILE_DEVICE_MASS_STORAGE 0x0000002d +#define FILE_DEVICE_SMB 0x0000002e +#define FILE_DEVICE_KS 0x0000002f +#define FILE_DEVICE_CHANGER 0x00000030 +#define FILE_DEVICE_SMARTCARD 0x00000031 +#define FILE_DEVICE_ACPI 0x00000032 +#define FILE_DEVICE_DVD 0x00000033 +#define FILE_DEVICE_FULLSCREEN_VIDEO 0x00000034 +#define FILE_DEVICE_DFS_FILE_SYSTEM 0x00000035 +#define FILE_DEVICE_DFS_VOLUME 0x00000036 +#define FILE_DEVICE_SERENUM 0x00000037 +#define FILE_DEVICE_TERMSRV 0x00000038 +#define FILE_DEVICE_KSEC 0x00000039 +#define FILE_DEVICE_FIPS 0x0000003A +#define FILE_DEVICE_INFINIBAND 0x0000003B +#define FILE_DEVICE_VMBUS 0x0000003E +#define FILE_DEVICE_CRYPT_PROVIDER 0x0000003F +#define FILE_DEVICE_WPD 0x00000040 +#define FILE_DEVICE_BLUETOOTH 0x00000041 +#define FILE_DEVICE_MT_COMPOSITE 0x00000042 +#define FILE_DEVICE_MT_TRANSPORT 0x00000043 +#define FILE_DEVICE_BIOMETRIC 0x00000044 +#define FILE_DEVICE_PMI 0x00000045 + +#define CTL_CODE(DeviceType, Function, Method, Access) \ + (((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method)) + +#define DEVICE_TYPE_FROM_CTL_CODE(ctrlCode) (((DWORD)(ctrlCode & 0xFFFF0000)) >> 16) + +#define METHOD_FROM_CTL_CODE(ctrlCode) ((DWORD)(ctrlCode & 3)) + +#define METHOD_BUFFERED 0 +#define METHOD_IN_DIRECT 1 +#define METHOD_OUT_DIRECT 2 +#define METHOD_NEITHER 3 + +#define FILE_ANY_ACCESS 0 +#define FILE_SPECIAL_ACCESS (FILE_ANY_ACCESS) +#define FILE_READ_ACCESS (0x0001) +#define FILE_WRITE_ACCESS (0x0002) + +/* + * WinPR I/O Manager Custom API + */ + +typedef HANDLE PDRIVER_OBJECT_EX; +typedef HANDLE PDEVICE_OBJECT_EX; + +WINPR_API NTSTATUS _IoCreateDeviceEx(PDRIVER_OBJECT_EX DriverObject, ULONG DeviceExtensionSize, + PUNICODE_STRING DeviceName, DEVICE_TYPE DeviceType, + ULONG DeviceCharacteristics, BOOLEAN Exclusive, + PDEVICE_OBJECT_EX* DeviceObject); + +WINPR_API VOID _IoDeleteDeviceEx(PDEVICE_OBJECT_EX DeviceObject); + +#endif + +#ifdef _UWP + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API BOOL GetOverlappedResult(HANDLE hFile, LPOVERLAPPED lpOverlapped, + LPDWORD lpNumberOfBytesTransferred, BOOL bWait); + + WINPR_API BOOL DeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID lpInBuffer, + DWORD nInBufferSize, LPVOID lpOutBuffer, DWORD nOutBufferSize, + LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped); + + WINPR_API HANDLE CreateIoCompletionPort(HANDLE FileHandle, HANDLE ExistingCompletionPort, + ULONG_PTR CompletionKey, + DWORD NumberOfConcurrentThreads); + + WINPR_API BOOL GetQueuedCompletionStatus(HANDLE CompletionPort, + LPDWORD lpNumberOfBytesTransferred, + PULONG_PTR lpCompletionKey, LPOVERLAPPED* lpOverlapped, + DWORD dwMilliseconds); + + WINPR_API BOOL GetQueuedCompletionStatusEx(HANDLE CompletionPort, + LPOVERLAPPED_ENTRY lpCompletionPortEntries, + ULONG ulCount, PULONG ulNumEntriesRemoved, + DWORD dwMilliseconds, BOOL fAlertable); + + WINPR_API BOOL PostQueuedCompletionStatus(HANDLE CompletionPort, + DWORD dwNumberOfBytesTransferred, + ULONG_PTR dwCompletionKey, LPOVERLAPPED lpOverlapped); + + WINPR_API BOOL CancelIo(HANDLE hFile); + + WINPR_API BOOL CancelSynchronousIo(HANDLE hThread); + +#ifdef __cplusplus +} +#endif + +#endif + +/** + * Extended API + */ + +#define ACCESS_FROM_CTL_CODE(ctrlCode) ((DWORD)((ctrlCode >> 14) & 0x3)) +#define FUNCTION_FROM_CTL_CODE(ctrlCode) ((DWORD)((ctrlCode >> 2) & 0xFFF)) + +#endif /* WINPR_IO_H */ diff --git a/winpr/include/winpr/library.h b/winpr/include/winpr/library.h new file mode 100644 index 0000000..8cdd6db --- /dev/null +++ b/winpr/include/winpr/library.h @@ -0,0 +1,119 @@ +/** + * WinPR: Windows Portable Runtime + * Library Loader + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_LIBRARY_H +#define WINPR_LIBRARY_H + +#include <winpr/winpr.h> +#include <winpr/wtypes.h> + +#if !defined(_WIN32) || defined(_UWP) + +typedef HANDLE DLL_DIRECTORY_COOKIE; + +#define LOAD_LIBRARY_SEARCH_APPLICATION_DIR 0x00000200 +#define LOAD_LIBRARY_SEARCH_DEFAULT_DIRS 0x00001000 +#define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800 +#define LOAD_LIBRARY_SEARCH_USER_DIRS 0x00000400 + +#define DONT_RESOLVE_DLL_REFERENCES 0x00000001 +#define LOAD_LIBRARY_AS_DATAFILE 0x00000002 +#define LOAD_WITH_ALTERED_SEARCH_PATH 0x00000008 +#define LOAD_IGNORE_CODE_AUTHZ_LEVEL 0x00000010 +#define LOAD_LIBRARY_AS_IMAGE_RESOURCE 0x00000020 +#define LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE 0x00000040 +#define LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR 0x00000100 +#define LOAD_LIBRARY_SEARCH_APPLICATION_DIR 0x00000200 +#define LOAD_LIBRARY_SEARCH_USER_DIRS 0x00000400 +#define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800 +#define LOAD_LIBRARY_SEARCH_DEFAULT_DIRS 0x00001000 + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API DLL_DIRECTORY_COOKIE AddDllDirectory(PCWSTR NewDirectory); + WINPR_API BOOL RemoveDllDirectory(DLL_DIRECTORY_COOKIE Cookie); + WINPR_API BOOL SetDefaultDllDirectories(DWORD DirectoryFlags); + + WINPR_API HMODULE LoadLibraryA(LPCSTR lpLibFileName); + WINPR_API HMODULE LoadLibraryW(LPCWSTR lpLibFileName); + + WINPR_API HMODULE LoadLibraryExA(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags); + WINPR_API HMODULE LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags); + +#ifdef __cplusplus +} +#endif + +#ifdef UNICODE +#define LoadLibrary LoadLibraryW +#define LoadLibraryEx LoadLibraryExW +#else +#define LoadLibrary LoadLibraryA +#define LoadLibraryEx LoadLibraryExA +#endif + +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API HMODULE LoadLibraryX(LPCSTR lpLibFileName); + WINPR_API HMODULE LoadLibraryExX(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags); + +#ifdef __cplusplus +} +#endif + +#if !defined(_WIN32) && !defined(__CYGWIN__) + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API HMODULE GetModuleHandleA(LPCSTR lpModuleName); + WINPR_API HMODULE GetModuleHandleW(LPCWSTR lpModuleName); + + WINPR_API DWORD GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize); + WINPR_API DWORD GetModuleFileNameW(HMODULE hModule, LPWSTR lpFilename, DWORD nSize); + + WINPR_API FARPROC GetProcAddress(HMODULE hModule, LPCSTR lpProcName); + + WINPR_API BOOL FreeLibrary(HMODULE hLibModule); + +#ifdef __cplusplus +} +#endif + +#ifdef UNICODE +#define GetModuleHandle GetModuleHandleW +#define GetModuleFileName GetModuleFileNameW +#else +#define GetModuleHandle GetModuleHandleA +#define GetModuleFileName GetModuleFileNameA +#endif + +#endif + +#endif /* WINPR_LIBRARY_H */ diff --git a/winpr/include/winpr/memory.h b/winpr/include/winpr/memory.h new file mode 100644 index 0000000..850d6b2 --- /dev/null +++ b/winpr/include/winpr/memory.h @@ -0,0 +1,76 @@ +/** + * WinPR: Windows Portable Runtime + * Memory Allocation + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_MEMORY_H +#define WINPR_MEMORY_H + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <winpr/winpr.h> +#include <winpr/wtypes.h> + +#include <winpr/crt.h> +#include <winpr/file.h> + +#ifndef _WIN32 + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API HANDLE CreateFileMappingA(HANDLE hFile, LPSECURITY_ATTRIBUTES lpAttributes, + DWORD flProtect, DWORD dwMaximumSizeHigh, + DWORD dwMaximumSizeLow, LPCSTR lpName); + WINPR_API HANDLE CreateFileMappingW(HANDLE hFile, LPSECURITY_ATTRIBUTES lpAttributes, + DWORD flProtect, DWORD dwMaximumSizeHigh, + DWORD dwMaximumSizeLow, LPCWSTR lpName); + + WINPR_API HANDLE OpenFileMappingA(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCSTR lpName); + WINPR_API HANDLE OpenFileMappingW(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCWSTR lpName); + + WINPR_API LPVOID MapViewOfFile(HANDLE hFileMappingObject, DWORD dwDesiredAccess, + DWORD dwFileOffsetHigh, DWORD dwFileOffsetLow, + SIZE_T dwNumberOfBytesToMap); + + WINPR_API LPVOID MapViewOfFileEx(HANDLE hFileMappingObject, DWORD dwDesiredAccess, + DWORD dwFileOffsetHigh, DWORD dwFileOffsetLow, + SIZE_T dwNumberOfBytesToMap, LPVOID lpBaseAddress); + + WINPR_API BOOL FlushViewOfFile(LPCVOID lpBaseAddress, SIZE_T dwNumberOfBytesToFlush); + + WINPR_API BOOL UnmapViewOfFile(LPCVOID lpBaseAddress); + +#ifdef __cplusplus +} +#endif + +#ifdef UNICODE +#define CreateFileMapping CreateFileMappingW +#define OpenFileMapping OpenFileMappingW +#else +#define CreateFileMapping CreateFileMappingA +#define OpenFileMapping OpenFileMappingA +#endif + +#endif + +#endif /* WINPR_MEMORY_H */ diff --git a/winpr/include/winpr/ncrypt.h b/winpr/include/winpr/ncrypt.h new file mode 100644 index 0000000..5f83a98 --- /dev/null +++ b/winpr/include/winpr/ncrypt.h @@ -0,0 +1,219 @@ +/** + * WinPR: Windows Portable Runtime + * NCrypt library + * + * Copyright 2021 David Fort <contact@hardening-consulting.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_INCLUDE_WINPR_NCRYPT_H_ +#define WINPR_INCLUDE_WINPR_NCRYPT_H_ + +#ifdef _WIN32 +#include <wincrypt.h> +#include <ncrypt.h> +#else + +#include <winpr/wtypes.h> +#include <winpr/winpr.h> + +#ifndef __SECSTATUS_DEFINED__ +typedef LONG SECURITY_STATUS; +#define __SECSTATUS_DEFINED__ +#endif + +typedef ULONG_PTR NCRYPT_HANDLE; +typedef ULONG_PTR NCRYPT_PROV_HANDLE; +typedef ULONG_PTR NCRYPT_KEY_HANDLE; + +#define MS_KEY_STORAGE_PROVIDER \ + (const WCHAR*)"M\x00i\x00" \ + "c\x00r\x00o\x00s\x00o\x00" \ + "f\x00t\x00 " \ + "\x00S\x00o\x00" \ + "f\x00t\x00w\x00" \ + "a\x00r\x00" \ + "e\x00 \x00K\x00" \ + "e\x00y\x00 " \ + "\x00S\x00t\x00o\x00r\x00" \ + "a\x00g\x00" \ + "e\x00 " \ + "\x00P\x00r\x00o\x00v\x00i\x00" \ + "d\x00" \ + "e\x00r\x00\x00" +#define MS_SMART_CARD_KEY_STORAGE_PROVIDER \ + (const WCHAR*)"M\x00i\x00" \ + "c\x00r\x00o\x00s\x00o\x00" \ + "f\x00t\x00 \x00S\x00m\x00" \ + "a\x00r\x00t\x00 " \ + "\x00" \ + "C\x00" \ + "a\x00r\x00" \ + "d\x00 \x00K\x00" \ + "e\x00y\x00 " \ + "\x00S\x00t\x00o\x00r\x00" \ + "a\x00g\x00" \ + "e\x00 " \ + "\x00P\x00r\x00o\x00v\x00i\x00" \ + "d\x00" \ + "e\x00r\x00\x00" + +#define MS_SCARD_PROV_A "Microsoft Base Smart Card Crypto Provider" +#define MS_SCARD_PROV \ + (const WCHAR*)("M\x00i\x00" \ + "c\x00r\x00o\x00s\x00o\x00" \ + "f\x00t\x00 \x00" \ + "B\x00" \ + "a\x00s\x00" \ + "e\x00 " \ + "\x00S\x00m\x00" \ + "a\x00r\x00t\x00 \x00" \ + "C\x00" \ + "a\x00r\x00" \ + "d\x00 " \ + "\x00" \ + "C\x00r\x00y\x00p\x00t\x00o\x00 " \ + "\x00P\x00r\x00o\x00v\x00i\x00" \ + "d\x00" \ + "e\x00r\x00\x00") + +#define MS_PLATFORM_KEY_STORAGE_PROVIDER \ + (const WCHAR*)"M\x00i\x00" \ + "c\x00r\x00o\x00s\x00o\x00" \ + "f\x00t\x00 " \ + "\x00P\x00l\x00" \ + "a\x00t\x00" \ + "f\x00o\x00r\x00m\x00 " \ + "\x00" \ + "C\x00r\x00y\x00p\x00t\x00o\x00 " \ + "\x00P\x00r\x00o\x00v\x00i\x00" \ + "d\x00" \ + "e\x00r\x00\x00" + +#define NCRYPT_CERTIFICATE_PROPERTY \ + (const WCHAR*)"S\x00m\x00" \ + "a\x00r\x00t\x00" \ + "C\x00" \ + "a\x00r\x00" \ + "d\x00K\x00" \ + "e\x00y\x00" \ + "C\x00" \ + "e\x00r\x00t" \ + "\x00i\x00" \ + "f\x00i\x00" \ + "c\x00" \ + "a\x00t\x00" \ + "e\x00\x00" +#define NCRYPT_NAME_PROPERTY (const WCHAR*)"N\x00a\x00m\x00e\x00\x00" +#define NCRYPT_UNIQUE_NAME_PROPERTY \ + (const WCHAR*)"U\x00n\x00i\x00q\x00u\x00" \ + "e\x00 \x00N\x00" \ + "a\x00m\x00" \ + "e\x00\x00" +#define NCRYPT_READER_PROPERTY \ + (const WCHAR*)"S\x00m\x00" \ + "a\x00r\x00t\x00" \ + "C\x00" \ + "a\x00r\x00" \ + "d\x00R\x00" \ + "e\x00" \ + "a\x00" \ + "d\x00" \ + "e\x00r\x00\x00" + +/* winpr specific properties */ +#define NCRYPT_WINPR_SLOTID (const WCHAR*)"S\x00l\x00o\x00t\x00\x00" + +#define NCRYPT_MACHINE_KEY_FLAG 0x20 +#define NCRYPT_SILENT_FLAG 0x40 + +/** @brief a key name descriptor */ +typedef struct NCryptKeyName +{ + LPWSTR pszName; + LPWSTR pszAlgid; + DWORD dwLegacyKeySpec; + DWORD dwFlags; +} NCryptKeyName; + +/** @brief a provider name descriptor */ +typedef struct NCryptProviderName +{ + LPWSTR pszName; + LPWSTR pszComment; +} NCryptProviderName; + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API SECURITY_STATUS NCryptEnumStorageProviders(DWORD* wProviderCount, + NCryptProviderName** ppProviderList, + DWORD dwFlags); + + WINPR_API SECURITY_STATUS NCryptOpenStorageProvider(NCRYPT_PROV_HANDLE* phProvider, + LPCWSTR pszProviderName, DWORD dwFlags); + + WINPR_API SECURITY_STATUS NCryptEnumKeys(NCRYPT_PROV_HANDLE hProvider, LPCWSTR pszScope, + NCryptKeyName** ppKeyName, PVOID* ppEnumState, + DWORD dwFlags); + + WINPR_API SECURITY_STATUS NCryptOpenKey(NCRYPT_PROV_HANDLE hProvider, NCRYPT_KEY_HANDLE* phKey, + LPCWSTR pszKeyName, DWORD dwLegacyKeySpec, + DWORD dwFlags); + + WINPR_API SECURITY_STATUS NCryptGetProperty(NCRYPT_HANDLE hObject, LPCWSTR pszProperty, + PBYTE pbOutput, DWORD cbOutput, DWORD* pcbResult, + DWORD dwFlags); + + WINPR_API SECURITY_STATUS NCryptFreeObject(NCRYPT_HANDLE hObject); + WINPR_API SECURITY_STATUS NCryptFreeBuffer(PVOID pvInput); + +#ifdef __cplusplus +} +#endif + +#endif /* _WIN32 */ + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * custom NCryptOpenStorageProvider that allows to provide a list of modules to load + * + * @param phProvider [out] resulting provider handle + * @param dwFlags [in] the flags to use + * @param modulePaths [in] an array of library path to try to load ended with a NULL string + * @return ERROR_SUCCESS or an NTE error code something failed + */ + WINPR_API SECURITY_STATUS winpr_NCryptOpenStorageProviderEx(NCRYPT_PROV_HANDLE* phProvider, + LPCWSTR pszProviderName, + DWORD dwFlags, LPCSTR* modulePaths); + + /** + * Gives a string representation of a SECURITY_STATUS + * + * @param status [in] SECURITY_STATUS that we want as string + * @return the string representation of status + */ + WINPR_API const char* winpr_NCryptSecurityStatusError(SECURITY_STATUS status); + +#ifdef __cplusplus +} +#endif + +#endif /* WINPR_INCLUDE_WINPR_NCRYPT_H_ */ diff --git a/winpr/include/winpr/nt.h b/winpr/include/winpr/nt.h new file mode 100644 index 0000000..2662b48 --- /dev/null +++ b/winpr/include/winpr/nt.h @@ -0,0 +1,1575 @@ +/** + * WinPR: Windows Portable Runtime + * Windows Native System Services + * + * Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_NT_H +#define WINPR_NT_H + +#include <winpr/winpr.h> +#include <winpr/wtypes.h> +#include <winpr/windows.h> + +#ifdef __cplusplus +#define STATUS_CAST(t, val) static_cast<t>(val) +#else +#define STATUS_CAST(t, val) (t)(val) +#endif + +#ifndef _WIN32 + +/* Defined in winnt.h, do not redefine */ +#define STATUS_WAIT_0 STATUS_CAST(NTSTATUS, 0x00000000L) +#define STATUS_ABANDONED_WAIT_0 STATUS_CAST(NTSTATUS, 0x00000080L) +#define STATUS_USER_APC STATUS_CAST(NTSTATUS, 0x000000C0L) +#define STATUS_TIMEOUT STATUS_CAST(NTSTATUS, 0x00000102L) +#define STATUS_PENDING STATUS_CAST(NTSTATUS, 0x00000103L) +#define DBG_EXCEPTION_HANDLED STATUS_CAST(NTSTATUS, 0x00010001L) +#define DBG_CONTINUE STATUS_CAST(NTSTATUS, 0x00010002L) +#define STATUS_SEGMENT_NOTIFICATION STATUS_CAST(NTSTATUS, 0x40000005L) +#define STATUS_FATAL_APP_EXIT STATUS_CAST(NTSTATUS, 0x40000015L) +#define DBG_TERMINATE_THREAD STATUS_CAST(NTSTATUS, 0x40010003L) +#define DBG_TERMINATE_PROCESS STATUS_CAST(NTSTATUS, 0x40010004L) +#define DBG_CONTROL_C STATUS_CAST(NTSTATUS, 0x40010005L) +#define DBG_PRINTEXCEPTION_C STATUS_CAST(NTSTATUS, 0x40010006L) +#define DBG_RIPEXCEPTION STATUS_CAST(NTSTATUS, 0x40010007L) +#define DBG_CONTROL_BREAK STATUS_CAST(NTSTATUS, 0x40010008L) +#define DBG_COMMAND_EXCEPTION STATUS_CAST(NTSTATUS, 0x40010009L) +#define STATUS_GUARD_PAGE_VIOLATION STATUS_CAST(NTSTATUS, 0x80000001L) +#define STATUS_DATATYPE_MISALIGNMENT STATUS_CAST(NTSTATUS, 0x80000002L) +#define STATUS_BREAKPOINT STATUS_CAST(NTSTATUS, 0x80000003L) +#define STATUS_SINGLE_STEP STATUS_CAST(NTSTATUS, 0x80000004L) +#define STATUS_LONGJUMP STATUS_CAST(NTSTATUS, 0x80000026L) +#define STATUS_UNWIND_CONSOLIDATE STATUS_CAST(NTSTATUS, 0x80000029L) +#define DBG_EXCEPTION_NOT_HANDLED STATUS_CAST(NTSTATUS, 0x80010001L) +#define STATUS_ACCESS_VIOLATION STATUS_CAST(NTSTATUS, 0xC0000005L) +#define STATUS_IN_PAGE_ERROR STATUS_CAST(NTSTATUS, 0xC0000006L) +#define STATUS_INVALID_HANDLE STATUS_CAST(NTSTATUS, 0xC0000008L) +#define STATUS_INVALID_PARAMETER STATUS_CAST(NTSTATUS, 0xC000000DL) +#define STATUS_NO_MEMORY STATUS_CAST(NTSTATUS, 0xC0000017L) +#define STATUS_ILLEGAL_INSTRUCTION STATUS_CAST(NTSTATUS, 0xC000001DL) +#define STATUS_NONCONTINUABLE_EXCEPTION STATUS_CAST(NTSTATUS, 0xC0000025L) +#define STATUS_INVALID_DISPOSITION STATUS_CAST(NTSTATUS, 0xC0000026L) +#define STATUS_ARRAY_BOUNDS_EXCEEDED STATUS_CAST(NTSTATUS, 0xC000008CL) +#define STATUS_FLOAT_DENORMAL_OPERAND STATUS_CAST(NTSTATUS, 0xC000008DL) +#define STATUS_FLOAT_DIVIDE_BY_ZERO STATUS_CAST(NTSTATUS, 0xC000008EL) +#define STATUS_FLOAT_INEXACT_RESULT STATUS_CAST(NTSTATUS, 0xC000008FL) +#define STATUS_FLOAT_INVALID_OPERATION STATUS_CAST(NTSTATUS, 0xC0000090L) +#define STATUS_FLOAT_OVERFLOW STATUS_CAST(NTSTATUS, 0xC0000091L) +#define STATUS_FLOAT_STACK_CHECK STATUS_CAST(NTSTATUS, 0xC0000092L) +#define STATUS_FLOAT_UNDERFLOW STATUS_CAST(NTSTATUS, 0xC0000093L) +#define STATUS_INTEGER_DIVIDE_BY_ZERO STATUS_CAST(NTSTATUS, 0xC0000094L) +#define STATUS_INTEGER_OVERFLOW STATUS_CAST(NTSTATUS, 0xC0000095L) +#define STATUS_PRIVILEGED_INSTRUCTION STATUS_CAST(NTSTATUS, 0xC0000096L) +#define STATUS_STACK_OVERFLOW STATUS_CAST(NTSTATUS, 0xC00000FDL) +#define STATUS_DLL_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC0000135L) +#define STATUS_ORDINAL_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC0000138L) +#define STATUS_ENTRYPOINT_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC0000139L) +#define STATUS_CONTROL_C_EXIT STATUS_CAST(NTSTATUS, 0xC000013AL) +#define STATUS_DLL_INIT_FAILED STATUS_CAST(NTSTATUS, 0xC0000142L) +#define STATUS_FLOAT_MULTIPLE_FAULTS STATUS_CAST(NTSTATUS, 0xC00002B4L) +#define STATUS_FLOAT_MULTIPLE_TRAPS STATUS_CAST(NTSTATUS, 0xC00002B5L) +#define STATUS_REG_NAT_CONSUMPTION STATUS_CAST(NTSTATUS, 0xC00002C9L) +#define STATUS_STACK_BUFFER_OVERRUN STATUS_CAST(NTSTATUS, 0xC0000409L) +#define STATUS_INVALID_CRUNTIME_PARAMETER STATUS_CAST(NTSTATUS, 0xC0000417L) +#define STATUS_ASSERTION_FAILURE STATUS_CAST(NTSTATUS, 0xC0000420L) +#define STATUS_SXS_EARLY_DEACTIVATION STATUS_CAST(NTSTATUS, 0xC015000FL) +#define STATUS_SXS_INVALID_DEACTIVATION STATUS_CAST(NTSTATUS, 0xC0150010L) + +#endif + +/* Defined in wincred.h, do not redefine */ + +#if defined(_WIN32) && !defined(_UWP) + +#include <wincred.h> + +#else + +#define STATUS_LOGON_FAILURE STATUS_CAST(NTSTATUS, 0xC000006DL) +#define STATUS_WRONG_PASSWORD STATUS_CAST(NTSTATUS, 0xC000006AL) +#define STATUS_PASSWORD_EXPIRED STATUS_CAST(NTSTATUS, 0xC0000071L) +#define STATUS_PASSWORD_MUST_CHANGE STATUS_CAST(NTSTATUS, 0xC0000224L) +#define STATUS_ACCESS_DENIED STATUS_CAST(NTSTATUS, 0xC0000022L) +#define STATUS_DOWNGRADE_DETECTED STATUS_CAST(NTSTATUS, 0xC0000388L) +#define STATUS_AUTHENTICATION_FIREWALL_FAILED STATUS_CAST(NTSTATUS, 0xC0000413L) +#define STATUS_ACCOUNT_DISABLED STATUS_CAST(NTSTATUS, 0xC0000072L) +#define STATUS_ACCOUNT_RESTRICTION STATUS_CAST(NTSTATUS, 0xC000006EL) +#define STATUS_ACCOUNT_LOCKED_OUT STATUS_CAST(NTSTATUS, 0xC0000234L) +#define STATUS_ACCOUNT_EXPIRED STATUS_CAST(NTSTATUS, 0xC0000193L) +#define STATUS_LOGON_TYPE_NOT_GRANTED STATUS_CAST(NTSTATUS, 0xC000015BL) + +#endif + +#define FACILITY_DEBUGGER 0x1 +#define FACILITY_RPC_RUNTIME 0x2 +#define FACILITY_RPC_STUBS 0x3 +#define FACILITY_IO_ERROR_CODE 0x4 +#define FACILITY_TERMINAL_SERVER 0xA +#define FACILITY_USB_ERROR_CODE 0x10 +#define FACILITY_HID_ERROR_CODE 0x11 +#define FACILITY_FIREWIRE_ERROR_CODE 0x12 +#define FACILITY_CLUSTER_ERROR_CODE 0x13 +#define FACILITY_ACPI_ERROR_CODE 0x14 +#define FACILITY_SXS_ERROR_CODE 0x15 + +/** + * NTSTATUS codes + */ + +#if !defined(STATUS_SUCCESS) +#define STATUS_SUCCESS STATUS_CAST(NTSTATUS, 0x00000000) +#endif + +#define STATUS_SEVERITY_SUCCESS 0x0 +#define STATUS_SEVERITY_INFORMATIONAL 0x1 +#define STATUS_SEVERITY_WARNING 0x2 +#define STATUS_SEVERITY_ERROR 0x3 + +#define STATUS_WAIT_1 STATUS_CAST(NTSTATUS, 0x00000001) +#define STATUS_WAIT_2 STATUS_CAST(NTSTATUS, 0x00000002) +#define STATUS_WAIT_3 STATUS_CAST(NTSTATUS, 0x00000003) +#define STATUS_WAIT_63 STATUS_CAST(NTSTATUS, 0x0000003f) +#define STATUS_ABANDONED STATUS_CAST(NTSTATUS, 0x00000080) +#define STATUS_ABANDONED_WAIT_63 STATUS_CAST(NTSTATUS, 0x000000BF) +//#define STATUS_USER_APC STATUS_CAST(NTSTATUS,0x000000C0) +#define STATUS_KERNEL_APC STATUS_CAST(NTSTATUS, 0x00000100) +#define STATUS_ALERTED STATUS_CAST(NTSTATUS, 0x00000101) +//#define STATUS_TIMEOUT STATUS_CAST(NTSTATUS,0x00000102) +//#define STATUS_PENDING STATUS_CAST(NTSTATUS,0x00000103) +#define STATUS_REPARSE STATUS_CAST(NTSTATUS, 0x00000104) +#define STATUS_MORE_ENTRIES STATUS_CAST(NTSTATUS, 0x00000105) +#define STATUS_NOT_ALL_ASSIGNED STATUS_CAST(NTSTATUS, 0x00000106) +#define STATUS_SOME_NOT_MAPPED STATUS_CAST(NTSTATUS, 0x00000107) +#define STATUS_OPLOCK_BREAK_IN_PROGRESS STATUS_CAST(NTSTATUS, 0x00000108) +#define STATUS_VOLUME_MOUNTED STATUS_CAST(NTSTATUS, 0x00000109) +#define STATUS_RXACT_COMMITTED STATUS_CAST(NTSTATUS, 0x0000010A) +#define STATUS_NOTIFY_CLEANUP STATUS_CAST(NTSTATUS, 0x0000010B) +#define STATUS_NOTIFY_ENUM_DIR STATUS_CAST(NTSTATUS, 0x0000010C) +#define STATUS_NO_QUOTAS_FOR_ACCOUNT STATUS_CAST(NTSTATUS, 0x0000010D) +#define STATUS_PRIMARY_TRANSPORT_CONNECT_FAILED STATUS_CAST(NTSTATUS, 0x0000010E) +#define STATUS_PAGE_FAULT_TRANSITION STATUS_CAST(NTSTATUS, 0x00000110) +#define STATUS_PAGE_FAULT_DEMAND_ZERO STATUS_CAST(NTSTATUS, 0x00000111) +#define STATUS_PAGE_FAULT_COPY_ON_WRITE STATUS_CAST(NTSTATUS, 0x00000112) +#define STATUS_PAGE_FAULT_GUARD_PAGE STATUS_CAST(NTSTATUS, 0x00000113) +#define STATUS_PAGE_FAULT_PAGING_FILE STATUS_CAST(NTSTATUS, 0x00000114) +#define STATUS_CACHE_PAGE_LOCKED STATUS_CAST(NTSTATUS, 0x00000115) +#define STATUS_CRASH_DUMP STATUS_CAST(NTSTATUS, 0x00000116) +#define STATUS_BUFFER_ALL_ZEROS STATUS_CAST(NTSTATUS, 0x00000117) +#define STATUS_REPARSE_OBJECT STATUS_CAST(NTSTATUS, 0x00000118) +#define STATUS_RESOURCE_REQUIREMENTS_CHANGED STATUS_CAST(NTSTATUS, 0x00000119) +#define STATUS_TRANSLATION_COMPLETE STATUS_CAST(NTSTATUS, 0x00000120) +#define STATUS_DS_MEMBERSHIP_EVALUATED_LOCALLY STATUS_CAST(NTSTATUS, 0x00000121) +#define STATUS_NOTHING_TO_TERMINATE STATUS_CAST(NTSTATUS, 0x00000122) +#define STATUS_PROCESS_NOT_IN_JOB STATUS_CAST(NTSTATUS, 0x00000123) +#define STATUS_PROCESS_IN_JOB STATUS_CAST(NTSTATUS, 0x00000124) +#define STATUS_VOLSNAP_HIBERNATE_READY STATUS_CAST(NTSTATUS, 0x00000125) +#define STATUS_FSFILTER_OP_COMPLETED_SUCCESSFULLY STATUS_CAST(NTSTATUS, 0x00000126) + +#define STATUS_OBJECT_NAME_EXISTS STATUS_CAST(NTSTATUS, 0x40000000) +#define STATUS_THREAD_WAS_SUSPENDED STATUS_CAST(NTSTATUS, 0x40000001) +#define STATUS_WORKING_SET_LIMIT_RANGE STATUS_CAST(NTSTATUS, 0x40000002) +#define STATUS_IMAGE_NOT_AT_BASE STATUS_CAST(NTSTATUS, 0x40000003) +#define STATUS_RXACT_STATE_CREATED STATUS_CAST(NTSTATUS, 0x40000004) +//#define STATUS_SEGMENT_NOTIFICATION STATUS_CAST(NTSTATUS,0x40000005) +#define STATUS_LOCAL_USER_SESSION_KEY STATUS_CAST(NTSTATUS, 0x40000006) +#define STATUS_BAD_CURRENT_DIRECTORY STATUS_CAST(NTSTATUS, 0x40000007) +#define STATUS_SERIAL_MORE_WRITES STATUS_CAST(NTSTATUS, 0x40000008) +#define STATUS_REGISTRY_RECOVERED STATUS_CAST(NTSTATUS, 0x40000009) +#define STATUS_FT_READ_RECOVERY_FROM_BACKUP STATUS_CAST(NTSTATUS, 0x4000000A) +#define STATUS_FT_WRITE_RECOVERY STATUS_CAST(NTSTATUS, 0x4000000B) +#define STATUS_SERIAL_COUNTER_TIMEOUT STATUS_CAST(NTSTATUS, 0x4000000C) +#define STATUS_NULL_LM_PASSWORD STATUS_CAST(NTSTATUS, 0x4000000D) +#define STATUS_IMAGE_MACHINE_TYPE_MISMATCH STATUS_CAST(NTSTATUS, 0x4000000E) +#define STATUS_RECEIVE_PARTIAL STATUS_CAST(NTSTATUS, 0x4000000F) +#define STATUS_RECEIVE_EXPEDITED STATUS_CAST(NTSTATUS, 0x40000010) +#define STATUS_RECEIVE_PARTIAL_EXPEDITED STATUS_CAST(NTSTATUS, 0x40000011) +#define STATUS_EVENT_DONE STATUS_CAST(NTSTATUS, 0x40000012) +#define STATUS_EVENT_PENDING STATUS_CAST(NTSTATUS, 0x40000013) +#define STATUS_CHECKING_FILE_SYSTEM STATUS_CAST(NTSTATUS, 0x40000014) +//#define STATUS_FATAL_APP_EXIT STATUS_CAST(NTSTATUS,0x40000015) +#define STATUS_PREDEFINED_HANDLE STATUS_CAST(NTSTATUS, 0x40000016) +#define STATUS_WAS_UNLOCKED STATUS_CAST(NTSTATUS, 0x40000017) +#define STATUS_SERVICE_NOTIFICATION STATUS_CAST(NTSTATUS, 0x40000018) +#define STATUS_WAS_LOCKED STATUS_CAST(NTSTATUS, 0x40000019) +#define STATUS_LOG_HARD_ERROR STATUS_CAST(NTSTATUS, 0x4000001A) +#define STATUS_ALREADY_WIN32 STATUS_CAST(NTSTATUS, 0x4000001B) +#define STATUS_WX86_UNSIMULATE STATUS_CAST(NTSTATUS, 0x4000001C) +#define STATUS_WX86_CONTINUE STATUS_CAST(NTSTATUS, 0x4000001D) +#define STATUS_WX86_SINGLE_STEP STATUS_CAST(NTSTATUS, 0x4000001E) +#define STATUS_WX86_BREAKPOINT STATUS_CAST(NTSTATUS, 0x4000001F) +#define STATUS_WX86_EXCEPTION_CONTINUE STATUS_CAST(NTSTATUS, 0x40000020) +#define STATUS_WX86_EXCEPTION_LASTCHANCE STATUS_CAST(NTSTATUS, 0x40000021) +#define STATUS_WX86_EXCEPTION_CHAIN STATUS_CAST(NTSTATUS, 0x40000022) +#define STATUS_IMAGE_MACHINE_TYPE_MISMATCH_EXE STATUS_CAST(NTSTATUS, 0x40000023) +#define STATUS_NO_YIELD_PERFORMED STATUS_CAST(NTSTATUS, 0x40000024) +#define STATUS_TIMER_RESUME_IGNORED STATUS_CAST(NTSTATUS, 0x40000025) +#define STATUS_ARBITRATION_UNHANDLED STATUS_CAST(NTSTATUS, 0x40000026) +#define STATUS_CARDBUS_NOT_SUPPORTED STATUS_CAST(NTSTATUS, 0x40000027) +#define STATUS_WX86_CREATEWX86TIB STATUS_CAST(NTSTATUS, 0x40000028) +#define STATUS_MP_PROCESSOR_MISMATCH STATUS_CAST(NTSTATUS, 0x40000029) +#define STATUS_HIBERNATED STATUS_CAST(NTSTATUS, 0x4000002A) +#define STATUS_RESUME_HIBERNATION STATUS_CAST(NTSTATUS, 0x4000002B) +#define STATUS_FIRMWARE_UPDATED STATUS_CAST(NTSTATUS, 0x4000002C) +#define STATUS_WAKE_SYSTEM STATUS_CAST(NTSTATUS, 0x40000294) +#define STATUS_DS_SHUTTING_DOWN STATUS_CAST(NTSTATUS, 0x40000370) + +#define RPC_NT_UUID_LOCAL_ONLY STATUS_CAST(NTSTATUS, 0x40020056) +#define RPC_NT_SEND_INCOMPLETE STATUS_CAST(NTSTATUS, 0x400200AF) + +#define STATUS_CTX_CDM_CONNECT STATUS_CAST(NTSTATUS, 0x400A0004) +#define STATUS_CTX_CDM_DISCONNECT STATUS_CAST(NTSTATUS, 0x400A0005) + +#define STATUS_SXS_RELEASE_ACTIVATION_CONTEXT STATUS_CAST(NTSTATUS, 0x4015000D) + +//#define STATUS_GUARD_PAGE_VIOLATION STATUS_CAST(NTSTATUS,0x80000001) +//#define STATUS_DATATYPE_MISALIGNMENT STATUS_CAST(NTSTATUS,0x80000002) +//#define STATUS_BREAKPOINT STATUS_CAST(NTSTATUS,0x80000003) +//#define STATUS_SINGLE_STEP STATUS_CAST(NTSTATUS,0x80000004) +#define STATUS_BUFFER_OVERFLOW STATUS_CAST(NTSTATUS, 0x80000005) +#define STATUS_NO_MORE_FILES STATUS_CAST(NTSTATUS, 0x80000006) +#define STATUS_WAKE_SYSTEM_DEBUGGER STATUS_CAST(NTSTATUS, 0x80000007) + +#define STATUS_HANDLES_CLOSED STATUS_CAST(NTSTATUS, 0x8000000A) +#define STATUS_NO_INHERITANCE STATUS_CAST(NTSTATUS, 0x8000000B) +#define STATUS_GUID_SUBSTITUTION_MADE STATUS_CAST(NTSTATUS, 0x8000000C) +#define STATUS_PARTIAL_COPY STATUS_CAST(NTSTATUS, 0x8000000D) +#define STATUS_DEVICE_PAPER_EMPTY STATUS_CAST(NTSTATUS, 0x8000000E) +#define STATUS_DEVICE_POWERED_OFF STATUS_CAST(NTSTATUS, 0x8000000F) +#define STATUS_DEVICE_OFF_LINE STATUS_CAST(NTSTATUS, 0x80000010) +#define STATUS_DEVICE_BUSY STATUS_CAST(NTSTATUS, 0x80000011) +#define STATUS_NO_MORE_EAS STATUS_CAST(NTSTATUS, 0x80000012) +#define STATUS_INVALID_EA_NAME STATUS_CAST(NTSTATUS, 0x80000013) +#define STATUS_EA_LIST_INCONSISTENT STATUS_CAST(NTSTATUS, 0x80000014) +#define STATUS_INVALID_EA_FLAG STATUS_CAST(NTSTATUS, 0x80000015) +#define STATUS_VERIFY_REQUIRED STATUS_CAST(NTSTATUS, 0x80000016) +#define STATUS_EXTRANEOUS_INFORMATION STATUS_CAST(NTSTATUS, 0x80000017) +#define STATUS_RXACT_COMMIT_NECESSARY STATUS_CAST(NTSTATUS, 0x80000018) +#define STATUS_NO_MORE_ENTRIES STATUS_CAST(NTSTATUS, 0x8000001A) +#define STATUS_FILEMARK_DETECTED STATUS_CAST(NTSTATUS, 0x8000001B) +#define STATUS_MEDIA_CHANGED STATUS_CAST(NTSTATUS, 0x8000001C) +#define STATUS_BUS_RESET STATUS_CAST(NTSTATUS, 0x8000001D) +#define STATUS_END_OF_MEDIA STATUS_CAST(NTSTATUS, 0x8000001E) +#define STATUS_BEGINNING_OF_MEDIA STATUS_CAST(NTSTATUS, 0x8000001F) +#define STATUS_MEDIA_CHECK STATUS_CAST(NTSTATUS, 0x80000020) +#define STATUS_SETMARK_DETECTED STATUS_CAST(NTSTATUS, 0x80000021) +#define STATUS_NO_DATA_DETECTED STATUS_CAST(NTSTATUS, 0x80000022) +#define STATUS_REDIRECTOR_HAS_OPEN_HANDLES STATUS_CAST(NTSTATUS, 0x80000023) +#define STATUS_SERVER_HAS_OPEN_HANDLES STATUS_CAST(NTSTATUS, 0x80000024) +#define STATUS_ALREADY_DISCONNECTED STATUS_CAST(NTSTATUS, 0x80000025) +//#define STATUS_LONGJUMP STATUS_CAST(NTSTATUS,0x80000026) +#define STATUS_CLEANER_CARTRIDGE_INSTALLED STATUS_CAST(NTSTATUS, 0x80000027) +#define STATUS_PLUGPLAY_QUERY_VETOED STATUS_CAST(NTSTATUS, 0x80000028) +//#define STATUS_UNWIND_CONSOLIDATE STATUS_CAST(NTSTATUS,0x80000029) +#define STATUS_REGISTRY_HIVE_RECOVERED STATUS_CAST(NTSTATUS, 0x8000002A) +#define STATUS_DLL_MIGHT_BE_INSECURE STATUS_CAST(NTSTATUS, 0x8000002B) +#define STATUS_DLL_MIGHT_BE_INCOMPATIBLE STATUS_CAST(NTSTATUS, 0x8000002C) + +#define STATUS_DEVICE_REQUIRES_CLEANING STATUS_CAST(NTSTATUS, 0x80000288) +#define STATUS_DEVICE_DOOR_OPEN STATUS_CAST(NTSTATUS, 0x80000289) + +#define STATUS_CLUSTER_NODE_ALREADY_UP STATUS_CAST(NTSTATUS, 0x80130001) +#define STATUS_CLUSTER_NODE_ALREADY_DOWN STATUS_CAST(NTSTATUS, 0x80130002) +#define STATUS_CLUSTER_NETWORK_ALREADY_ONLINE STATUS_CAST(NTSTATUS, 0x80130003) +#define STATUS_CLUSTER_NETWORK_ALREADY_OFFLINE STATUS_CAST(NTSTATUS, 0x80130004) +#define STATUS_CLUSTER_NODE_ALREADY_MEMBER STATUS_CAST(NTSTATUS, 0x80130005) + +//#define STATUS_WAIT_0 STATUS_CAST(NTSTATUS,0x00000000) +#define STATUS_UNSUCCESSFUL STATUS_CAST(NTSTATUS, 0xC0000001) +#define STATUS_NOT_IMPLEMENTED STATUS_CAST(NTSTATUS, 0xC0000002) +#define STATUS_INVALID_INFO_CLASS STATUS_CAST(NTSTATUS, 0xC0000003) +#define STATUS_INFO_LENGTH_MISMATCH STATUS_CAST(NTSTATUS, 0xC0000004) +//#define STATUS_ACCESS_VIOLATION STATUS_CAST(NTSTATUS,0xC0000005) +//#define STATUS_IN_PAGE_ERROR STATUS_CAST(NTSTATUS,0xC0000006) +#define STATUS_PAGEFILE_QUOTA STATUS_CAST(NTSTATUS, 0xC0000007) +//#define STATUS_INVALID_HANDLE STATUS_CAST(NTSTATUS,0xC0000008) +#define STATUS_BAD_INITIAL_STACK STATUS_CAST(NTSTATUS, 0xC0000009) +#define STATUS_BAD_INITIAL_PC STATUS_CAST(NTSTATUS, 0xC000000A) +#define STATUS_INVALID_CID STATUS_CAST(NTSTATUS, 0xC000000B) +#define STATUS_TIMER_NOT_CANCELED STATUS_CAST(NTSTATUS, 0xC000000C) +//#define STATUS_INVALID_PARAMETER STATUS_CAST(NTSTATUS,0xC000000D) +#define STATUS_NO_SUCH_DEVICE STATUS_CAST(NTSTATUS, 0xC000000E) +#define STATUS_NO_SUCH_FILE STATUS_CAST(NTSTATUS, 0xC000000F) +#define STATUS_INVALID_DEVICE_REQUEST STATUS_CAST(NTSTATUS, 0xC0000010) +#define STATUS_END_OF_FILE STATUS_CAST(NTSTATUS, 0xC0000011) +#define STATUS_WRONG_VOLUME STATUS_CAST(NTSTATUS, 0xC0000012) +#define STATUS_NO_MEDIA_IN_DEVICE STATUS_CAST(NTSTATUS, 0xC0000013) +#define STATUS_UNRECOGNIZED_MEDIA STATUS_CAST(NTSTATUS, 0xC0000014) +#define STATUS_NONEXISTENT_SECTOR STATUS_CAST(NTSTATUS, 0xC0000015) +#define STATUS_MORE_PROCESSING_REQUIRED STATUS_CAST(NTSTATUS, 0xC0000016) +//#define STATUS_NO_MEMORY STATUS_CAST(NTSTATUS,0xC0000017) +#define STATUS_CONFLICTING_ADDRESSES STATUS_CAST(NTSTATUS, 0xC0000018) +#define STATUS_NOT_MAPPED_VIEW STATUS_CAST(NTSTATUS, 0xC0000019) +#define STATUS_UNABLE_TO_FREE_VM STATUS_CAST(NTSTATUS, 0xC000001A) +#define STATUS_UNABLE_TO_DELETE_SECTION STATUS_CAST(NTSTATUS, 0xC000001B) +#define STATUS_INVALID_SYSTEM_SERVICE STATUS_CAST(NTSTATUS, 0xC000001C) +//#define STATUS_ILLEGAL_INSTRUCTION STATUS_CAST(NTSTATUS,0xC000001D) +#define STATUS_INVALID_LOCK_SEQUENCE STATUS_CAST(NTSTATUS, 0xC000001E) +#define STATUS_INVALID_VIEW_SIZE STATUS_CAST(NTSTATUS, 0xC000001F) +#define STATUS_INVALID_FILE_FOR_SECTION STATUS_CAST(NTSTATUS, 0xC0000020) +#define STATUS_ALREADY_COMMITTED STATUS_CAST(NTSTATUS, 0xC0000021) +//#define STATUS_ACCESS_DENIED STATUS_CAST(NTSTATUS,0xC0000022) +#define STATUS_BUFFER_TOO_SMALL STATUS_CAST(NTSTATUS, 0xC0000023) +#define STATUS_OBJECT_TYPE_MISMATCH STATUS_CAST(NTSTATUS, 0xC0000024) +//#define STATUS_NONCONTINUABLE_EXCEPTION STATUS_CAST(NTSTATUS,0xC0000025) +//#define STATUS_INVALID_DISPOSITION STATUS_CAST(NTSTATUS,0xC0000026) +#define STATUS_UNWIND STATUS_CAST(NTSTATUS, 0xC0000027) +#define STATUS_BAD_STACK STATUS_CAST(NTSTATUS, 0xC0000028) +#define STATUS_INVALID_UNWIND_TARGET STATUS_CAST(NTSTATUS, 0xC0000029) +#define STATUS_NOT_LOCKED STATUS_CAST(NTSTATUS, 0xC000002A) +#define STATUS_PARITY_ERROR STATUS_CAST(NTSTATUS, 0xC000002B) +#define STATUS_UNABLE_TO_DECOMMIT_VM STATUS_CAST(NTSTATUS, 0xC000002C) +#define STATUS_NOT_COMMITTED STATUS_CAST(NTSTATUS, 0xC000002D) +#define STATUS_INVALID_PORT_ATTRIBUTES STATUS_CAST(NTSTATUS, 0xC000002E) +#define STATUS_PORT_MESSAGE_TOO_LONG STATUS_CAST(NTSTATUS, 0xC000002F) +#define STATUS_INVALID_PARAMETER_MIX STATUS_CAST(NTSTATUS, 0xC0000030) +#define STATUS_INVALID_QUOTA_LOWER STATUS_CAST(NTSTATUS, 0xC0000031) +#define STATUS_DISK_CORRUPT_ERROR STATUS_CAST(NTSTATUS, 0xC0000032) +#define STATUS_OBJECT_NAME_INVALID STATUS_CAST(NTSTATUS, 0xC0000033) +#define STATUS_OBJECT_NAME_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC0000034) +#define STATUS_OBJECT_NAME_COLLISION STATUS_CAST(NTSTATUS, 0xC0000035) +#define STATUS_PORT_DISCONNECTED STATUS_CAST(NTSTATUS, 0xC0000037) +#define STATUS_DEVICE_ALREADY_ATTACHED STATUS_CAST(NTSTATUS, 0xC0000038) +#define STATUS_OBJECT_PATH_INVALID STATUS_CAST(NTSTATUS, 0xC0000039) +#define STATUS_OBJECT_PATH_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC000003A) +#define STATUS_OBJECT_PATH_SYNTAX_BAD STATUS_CAST(NTSTATUS, 0xC000003B) +#define STATUS_DATA_OVERRUN STATUS_CAST(NTSTATUS, 0xC000003C) +#define STATUS_DATA_LATE_ERROR STATUS_CAST(NTSTATUS, 0xC000003D) +#define STATUS_DATA_ERROR STATUS_CAST(NTSTATUS, 0xC000003E) +#define STATUS_CRC_ERROR STATUS_CAST(NTSTATUS, 0xC000003F) +#define STATUS_SECTION_TOO_BIG STATUS_CAST(NTSTATUS, 0xC0000040) +#define STATUS_PORT_CONNECTION_REFUSED STATUS_CAST(NTSTATUS, 0xC0000041) +#define STATUS_INVALID_PORT_HANDLE STATUS_CAST(NTSTATUS, 0xC0000042) +#define STATUS_SHARING_VIOLATION STATUS_CAST(NTSTATUS, 0xC0000043) +#define STATUS_QUOTA_EXCEEDED STATUS_CAST(NTSTATUS, 0xC0000044) +#define STATUS_INVALID_PAGE_PROTECTION STATUS_CAST(NTSTATUS, 0xC0000045) +#define STATUS_MUTANT_NOT_OWNED STATUS_CAST(NTSTATUS, 0xC0000046) +#define STATUS_SEMAPHORE_LIMIT_EXCEEDED STATUS_CAST(NTSTATUS, 0xC0000047) +#define STATUS_PORT_ALREADY_SET STATUS_CAST(NTSTATUS, 0xC0000048) +#define STATUS_SECTION_NOT_IMAGE STATUS_CAST(NTSTATUS, 0xC0000049) +#define STATUS_SUSPEND_COUNT_EXCEEDED STATUS_CAST(NTSTATUS, 0xC000004A) +#define STATUS_THREAD_IS_TERMINATING STATUS_CAST(NTSTATUS, 0xC000004B) +#define STATUS_BAD_WORKING_SET_LIMIT STATUS_CAST(NTSTATUS, 0xC000004C) +#define STATUS_INCOMPATIBLE_FILE_MAP STATUS_CAST(NTSTATUS, 0xC000004D) +#define STATUS_SECTION_PROTECTION STATUS_CAST(NTSTATUS, 0xC000004E) +#define STATUS_EAS_NOT_SUPPORTED STATUS_CAST(NTSTATUS, 0xC000004F) +#define STATUS_EA_TOO_LARGE STATUS_CAST(NTSTATUS, 0xC0000050) +#define STATUS_NONEXISTENT_EA_ENTRY STATUS_CAST(NTSTATUS, 0xC0000051) +#define STATUS_NO_EAS_ON_FILE STATUS_CAST(NTSTATUS, 0xC0000052) +#define STATUS_EA_CORRUPT_ERROR STATUS_CAST(NTSTATUS, 0xC0000053) +#define STATUS_FILE_LOCK_CONFLICT STATUS_CAST(NTSTATUS, 0xC0000054) +#define STATUS_LOCK_NOT_GRANTED STATUS_CAST(NTSTATUS, 0xC0000055) +#define STATUS_DELETE_PENDING STATUS_CAST(NTSTATUS, 0xC0000056) +#define STATUS_CTL_FILE_NOT_SUPPORTED STATUS_CAST(NTSTATUS, 0xC0000057) +#define STATUS_UNKNOWN_REVISION STATUS_CAST(NTSTATUS, 0xC0000058) +#define STATUS_REVISION_MISMATCH STATUS_CAST(NTSTATUS, 0xC0000059) +#define STATUS_INVALID_OWNER STATUS_CAST(NTSTATUS, 0xC000005A) +#define STATUS_INVALID_PRIMARY_GROUP STATUS_CAST(NTSTATUS, 0xC000005B) +#define STATUS_NO_IMPERSONATION_TOKEN STATUS_CAST(NTSTATUS, 0xC000005C) +#define STATUS_CANT_DISABLE_MANDATORY STATUS_CAST(NTSTATUS, 0xC000005D) +#define STATUS_NO_LOGON_SERVERS STATUS_CAST(NTSTATUS, 0xC000005E) +#ifndef STATUS_NO_SUCH_LOGON_SESSION +#define STATUS_NO_SUCH_LOGON_SESSION STATUS_CAST(NTSTATUS, 0xC000005F) +#endif +#define STATUS_NO_SUCH_PRIVILEGE STATUS_CAST(NTSTATUS, 0xC0000060) +#define STATUS_PRIVILEGE_NOT_HELD STATUS_CAST(NTSTATUS, 0xC0000061) +#define STATUS_INVALID_ACCOUNT_NAME STATUS_CAST(NTSTATUS, 0xC0000062) +#define STATUS_USER_EXISTS STATUS_CAST(NTSTATUS, 0xC0000063) +#ifndef STATUS_NO_SUCH_USER +#define STATUS_NO_SUCH_USER STATUS_CAST(NTSTATUS, 0xC0000064) +#endif +#define STATUS_GROUP_EXISTS STATUS_CAST(NTSTATUS, 0xC0000065) +#define STATUS_NO_SUCH_GROUP STATUS_CAST(NTSTATUS, 0xC0000066) +#define STATUS_MEMBER_IN_GROUP STATUS_CAST(NTSTATUS, 0xC0000067) +#define STATUS_MEMBER_NOT_IN_GROUP STATUS_CAST(NTSTATUS, 0xC0000068) +#define STATUS_LAST_ADMIN STATUS_CAST(NTSTATUS, 0xC0000069) +//#define STATUS_WRONG_PASSWORD STATUS_CAST(NTSTATUS,0xC000006A) +#define STATUS_ILL_FORMED_PASSWORD STATUS_CAST(NTSTATUS, 0xC000006B) +#define STATUS_PASSWORD_RESTRICTION STATUS_CAST(NTSTATUS, 0xC000006C) +//#define STATUS_LOGON_FAILURE STATUS_CAST(NTSTATUS,0xC000006D) +//#define STATUS_ACCOUNT_RESTRICTION STATUS_CAST(NTSTATUS,0xC000006E) +#define STATUS_INVALID_LOGON_HOURS STATUS_CAST(NTSTATUS, 0xC000006F) +#define STATUS_INVALID_WORKSTATION STATUS_CAST(NTSTATUS, 0xC0000070) +//#define STATUS_PASSWORD_EXPIRED STATUS_CAST(NTSTATUS,0xC0000071) +//#define STATUS_ACCOUNT_DISABLED STATUS_CAST(NTSTATUS,0xC0000072) +#define STATUS_NONE_MAPPED STATUS_CAST(NTSTATUS, 0xC0000073) +#define STATUS_TOO_MANY_LUIDS_REQUESTED STATUS_CAST(NTSTATUS, 0xC0000074) +#define STATUS_LUIDS_EXHAUSTED STATUS_CAST(NTSTATUS, 0xC0000075) +#define STATUS_INVALID_SUB_AUTHORITY STATUS_CAST(NTSTATUS, 0xC0000076) +#define STATUS_INVALID_ACL STATUS_CAST(NTSTATUS, 0xC0000077) +#define STATUS_INVALID_SID STATUS_CAST(NTSTATUS, 0xC0000078) +#define STATUS_INVALID_SECURITY_DESCR STATUS_CAST(NTSTATUS, 0xC0000079) +#define STATUS_PROCEDURE_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC000007A) +#define STATUS_INVALID_IMAGE_FORMAT STATUS_CAST(NTSTATUS, 0xC000007B) +#define STATUS_NO_TOKEN STATUS_CAST(NTSTATUS, 0xC000007C) +#define STATUS_BAD_INHERITANCE_ACL STATUS_CAST(NTSTATUS, 0xC000007D) +#define STATUS_RANGE_NOT_LOCKED STATUS_CAST(NTSTATUS, 0xC000007E) +#define STATUS_DISK_FULL STATUS_CAST(NTSTATUS, 0xC000007F) +#define STATUS_SERVER_DISABLED STATUS_CAST(NTSTATUS, 0xC0000080) +#define STATUS_SERVER_NOT_DISABLED STATUS_CAST(NTSTATUS, 0xC0000081) +#define STATUS_TOO_MANY_GUIDS_REQUESTED STATUS_CAST(NTSTATUS, 0xC0000082) +#define STATUS_GUIDS_EXHAUSTED STATUS_CAST(NTSTATUS, 0xC0000083) +#define STATUS_INVALID_ID_AUTHORITY STATUS_CAST(NTSTATUS, 0xC0000084) +#define STATUS_AGENTS_EXHAUSTED STATUS_CAST(NTSTATUS, 0xC0000085) +#define STATUS_INVALID_VOLUME_LABEL STATUS_CAST(NTSTATUS, 0xC0000086) +#define STATUS_SECTION_NOT_EXTENDED STATUS_CAST(NTSTATUS, 0xC0000087) +#define STATUS_NOT_MAPPED_DATA STATUS_CAST(NTSTATUS, 0xC0000088) +#define STATUS_RESOURCE_DATA_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC0000089) +#define STATUS_RESOURCE_TYPE_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC000008A) +#define STATUS_RESOURCE_NAME_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC000008B) +//#define STATUS_ARRAY_BOUNDS_EXCEEDED STATUS_CAST(NTSTATUS,0xC000008C) +//#define STATUS_FLOAT_DENORMAL_OPERAND STATUS_CAST(NTSTATUS,0xC000008D) +//#define STATUS_FLOAT_DIVIDE_BY_ZERO STATUS_CAST(NTSTATUS,0xC000008E) +//#define STATUS_FLOAT_INEXACT_RESULT STATUS_CAST(NTSTATUS,0xC000008F) +//#define STATUS_FLOAT_INVALID_OPERATION STATUS_CAST(NTSTATUS,0xC0000090) +//#define STATUS_FLOAT_OVERFLOW STATUS_CAST(NTSTATUS,0xC0000091) +//#define STATUS_FLOAT_STACK_CHECK STATUS_CAST(NTSTATUS,0xC0000092) +//#define STATUS_FLOAT_UNDERFLOW STATUS_CAST(NTSTATUS,0xC0000093) +//#define STATUS_INTEGER_DIVIDE_BY_ZERO STATUS_CAST(NTSTATUS,0xC0000094) +//#define STATUS_INTEGER_OVERFLOW STATUS_CAST(NTSTATUS,0xC0000095) +//#define STATUS_PRIVILEGED_INSTRUCTION STATUS_CAST(NTSTATUS,0xC0000096) +#define STATUS_TOO_MANY_PAGING_FILES STATUS_CAST(NTSTATUS, 0xC0000097) +#define STATUS_FILE_INVALID STATUS_CAST(NTSTATUS, 0xC0000098) +#define STATUS_ALLOTTED_SPACE_EXCEEDED STATUS_CAST(NTSTATUS, 0xC0000099) +#define STATUS_INSUFFICIENT_RESOURCES STATUS_CAST(NTSTATUS, 0xC000009A) +#define STATUS_DFS_EXIT_PATH_FOUND STATUS_CAST(NTSTATUS, 0xC000009B) +#define STATUS_DEVICE_DATA_ERROR STATUS_CAST(NTSTATUS, 0xC000009C) +#define STATUS_DEVICE_NOT_CONNECTED STATUS_CAST(NTSTATUS, 0xC000009D) +#define STATUS_DEVICE_POWER_FAILURE STATUS_CAST(NTSTATUS, 0xC000009E) +#define STATUS_FREE_VM_NOT_AT_BASE STATUS_CAST(NTSTATUS, 0xC000009F) +#define STATUS_MEMORY_NOT_ALLOCATED STATUS_CAST(NTSTATUS, 0xC00000A0) +#define STATUS_WORKING_SET_QUOTA STATUS_CAST(NTSTATUS, 0xC00000A1) +#define STATUS_MEDIA_WRITE_PROTECTED STATUS_CAST(NTSTATUS, 0xC00000A2) +#define STATUS_DEVICE_NOT_READY STATUS_CAST(NTSTATUS, 0xC00000A3) +#define STATUS_INVALID_GROUP_ATTRIBUTES STATUS_CAST(NTSTATUS, 0xC00000A4) +#define STATUS_BAD_IMPERSONATION_LEVEL STATUS_CAST(NTSTATUS, 0xC00000A5) +#define STATUS_CANT_OPEN_ANONYMOUS STATUS_CAST(NTSTATUS, 0xC00000A6) +#define STATUS_BAD_VALIDATION_CLASS STATUS_CAST(NTSTATUS, 0xC00000A7) +#define STATUS_BAD_TOKEN_TYPE STATUS_CAST(NTSTATUS, 0xC00000A8) +#define STATUS_BAD_MASTER_BOOT_RECORD STATUS_CAST(NTSTATUS, 0xC00000A9) +#define STATUS_INSTRUCTION_MISALIGNMENT STATUS_CAST(NTSTATUS, 0xC00000AA) +#define STATUS_INSTANCE_NOT_AVAILABLE STATUS_CAST(NTSTATUS, 0xC00000AB) +#define STATUS_PIPE_NOT_AVAILABLE STATUS_CAST(NTSTATUS, 0xC00000AC) +#define STATUS_INVALID_PIPE_STATE STATUS_CAST(NTSTATUS, 0xC00000AD) +#define STATUS_PIPE_BUSY STATUS_CAST(NTSTATUS, 0xC00000AE) +#define STATUS_ILLEGAL_FUNCTION STATUS_CAST(NTSTATUS, 0xC00000AF) +#define STATUS_PIPE_DISCONNECTED STATUS_CAST(NTSTATUS, 0xC00000B0) +#define STATUS_PIPE_CLOSING STATUS_CAST(NTSTATUS, 0xC00000B1) +#define STATUS_PIPE_CONNECTED STATUS_CAST(NTSTATUS, 0xC00000B2) +#define STATUS_PIPE_LISTENING STATUS_CAST(NTSTATUS, 0xC00000B3) +#define STATUS_INVALID_READ_MODE STATUS_CAST(NTSTATUS, 0xC00000B4) +#define STATUS_IO_TIMEOUT STATUS_CAST(NTSTATUS, 0xC00000B5) +#define STATUS_FILE_FORCED_CLOSED STATUS_CAST(NTSTATUS, 0xC00000B6) +#define STATUS_PROFILING_NOT_STARTED STATUS_CAST(NTSTATUS, 0xC00000B7) +#define STATUS_PROFILING_NOT_STOPPED STATUS_CAST(NTSTATUS, 0xC00000B8) +#define STATUS_COULD_NOT_INTERPRET STATUS_CAST(NTSTATUS, 0xC00000B9) +#define STATUS_FILE_IS_A_DIRECTORY STATUS_CAST(NTSTATUS, 0xC00000BA) +#define STATUS_NOT_SUPPORTED STATUS_CAST(NTSTATUS, 0xC00000BB) +#define STATUS_REMOTE_NOT_LISTENING STATUS_CAST(NTSTATUS, 0xC00000BC) +#define STATUS_DUPLICATE_NAME STATUS_CAST(NTSTATUS, 0xC00000BD) +#define STATUS_BAD_NETWORK_PATH STATUS_CAST(NTSTATUS, 0xC00000BE) +#define STATUS_NETWORK_BUSY STATUS_CAST(NTSTATUS, 0xC00000BF) +#define STATUS_DEVICE_DOES_NOT_EXIST STATUS_CAST(NTSTATUS, 0xC00000C0) +#define STATUS_TOO_MANY_COMMANDS STATUS_CAST(NTSTATUS, 0xC00000C1) +#define STATUS_ADAPTER_HARDWARE_ERROR STATUS_CAST(NTSTATUS, 0xC00000C2) +#define STATUS_INVALID_NETWORK_RESPONSE STATUS_CAST(NTSTATUS, 0xC00000C3) +#define STATUS_UNEXPECTED_NETWORK_ERROR STATUS_CAST(NTSTATUS, 0xC00000C4) +#define STATUS_BAD_REMOTE_ADAPTER STATUS_CAST(NTSTATUS, 0xC00000C5) +#define STATUS_PRINT_QUEUE_FULL STATUS_CAST(NTSTATUS, 0xC00000C6) +#define STATUS_NO_SPOOL_SPACE STATUS_CAST(NTSTATUS, 0xC00000C7) +#define STATUS_PRINT_CANCELLED STATUS_CAST(NTSTATUS, 0xC00000C8) +#define STATUS_NETWORK_NAME_DELETED STATUS_CAST(NTSTATUS, 0xC00000C9) +#define STATUS_NETWORK_ACCESS_DENIED STATUS_CAST(NTSTATUS, 0xC00000CA) +#define STATUS_BAD_DEVICE_TYPE STATUS_CAST(NTSTATUS, 0xC00000CB) +#define STATUS_BAD_NETWORK_NAME STATUS_CAST(NTSTATUS, 0xC00000CC) +#define STATUS_TOO_MANY_NAMES STATUS_CAST(NTSTATUS, 0xC00000CD) +#define STATUS_TOO_MANY_SESSIONS STATUS_CAST(NTSTATUS, 0xC00000CE) +#define STATUS_SHARING_PAUSED STATUS_CAST(NTSTATUS, 0xC00000CF) +#define STATUS_REQUEST_NOT_ACCEPTED STATUS_CAST(NTSTATUS, 0xC00000D0) +#define STATUS_REDIRECTOR_PAUSED STATUS_CAST(NTSTATUS, 0xC00000D1) +#define STATUS_NET_WRITE_FAULT STATUS_CAST(NTSTATUS, 0xC00000D2) +#define STATUS_PROFILING_AT_LIMIT STATUS_CAST(NTSTATUS, 0xC00000D3) +#define STATUS_NOT_SAME_DEVICE STATUS_CAST(NTSTATUS, 0xC00000D4) +#define STATUS_FILE_RENAMED STATUS_CAST(NTSTATUS, 0xC00000D5) +#define STATUS_VIRTUAL_CIRCUIT_CLOSED STATUS_CAST(NTSTATUS, 0xC00000D6) +#define STATUS_NO_SECURITY_ON_OBJECT STATUS_CAST(NTSTATUS, 0xC00000D7) +#define STATUS_CANT_WAIT STATUS_CAST(NTSTATUS, 0xC00000D8) +#define STATUS_PIPE_EMPTY STATUS_CAST(NTSTATUS, 0xC00000D9) +#define STATUS_CANT_ACCESS_DOMAIN_INFO STATUS_CAST(NTSTATUS, 0xC00000DA) +#define STATUS_CANT_TERMINATE_SELF STATUS_CAST(NTSTATUS, 0xC00000DB) +#define STATUS_INVALID_SERVER_STATE STATUS_CAST(NTSTATUS, 0xC00000DC) +#define STATUS_INVALID_DOMAIN_STATE STATUS_CAST(NTSTATUS, 0xC00000DD) +#define STATUS_INVALID_DOMAIN_ROLE STATUS_CAST(NTSTATUS, 0xC00000DE) +#define STATUS_NO_SUCH_DOMAIN STATUS_CAST(NTSTATUS, 0xC00000DF) +#define STATUS_DOMAIN_EXISTS STATUS_CAST(NTSTATUS, 0xC00000E0) +#define STATUS_DOMAIN_LIMIT_EXCEEDED STATUS_CAST(NTSTATUS, 0xC00000E1) +#define STATUS_OPLOCK_NOT_GRANTED STATUS_CAST(NTSTATUS, 0xC00000E2) +#define STATUS_INVALID_OPLOCK_PROTOCOL STATUS_CAST(NTSTATUS, 0xC00000E3) +#define STATUS_INTERNAL_DB_CORRUPTION STATUS_CAST(NTSTATUS, 0xC00000E4) +#define STATUS_INTERNAL_ERROR STATUS_CAST(NTSTATUS, 0xC00000E5) +#define STATUS_GENERIC_NOT_MAPPED STATUS_CAST(NTSTATUS, 0xC00000E6) +#define STATUS_BAD_DESCRIPTOR_FORMAT STATUS_CAST(NTSTATUS, 0xC00000E7) +#define STATUS_INVALID_USER_BUFFER STATUS_CAST(NTSTATUS, 0xC00000E8) +#define STATUS_UNEXPECTED_IO_ERROR STATUS_CAST(NTSTATUS, 0xC00000E9) +#define STATUS_UNEXPECTED_MM_CREATE_ERR STATUS_CAST(NTSTATUS, 0xC00000EA) +#define STATUS_UNEXPECTED_MM_MAP_ERROR STATUS_CAST(NTSTATUS, 0xC00000EB) +#define STATUS_UNEXPECTED_MM_EXTEND_ERR STATUS_CAST(NTSTATUS, 0xC00000EC) +#define STATUS_NOT_LOGON_PROCESS STATUS_CAST(NTSTATUS, 0xC00000ED) +#define STATUS_LOGON_SESSION_EXISTS STATUS_CAST(NTSTATUS, 0xC00000EE) +#define STATUS_INVALID_PARAMETER_1 STATUS_CAST(NTSTATUS, 0xC00000EF) +#define STATUS_INVALID_PARAMETER_2 STATUS_CAST(NTSTATUS, 0xC00000F0) +#define STATUS_INVALID_PARAMETER_3 STATUS_CAST(NTSTATUS, 0xC00000F1) +#define STATUS_INVALID_PARAMETER_4 STATUS_CAST(NTSTATUS, 0xC00000F2) +#define STATUS_INVALID_PARAMETER_5 STATUS_CAST(NTSTATUS, 0xC00000F3) +#define STATUS_INVALID_PARAMETER_6 STATUS_CAST(NTSTATUS, 0xC00000F4) +#define STATUS_INVALID_PARAMETER_7 STATUS_CAST(NTSTATUS, 0xC00000F5) +#define STATUS_INVALID_PARAMETER_8 STATUS_CAST(NTSTATUS, 0xC00000F6) +#define STATUS_INVALID_PARAMETER_9 STATUS_CAST(NTSTATUS, 0xC00000F7) +#define STATUS_INVALID_PARAMETER_10 STATUS_CAST(NTSTATUS, 0xC00000F8) +#define STATUS_INVALID_PARAMETER_11 STATUS_CAST(NTSTATUS, 0xC00000F9) +#define STATUS_INVALID_PARAMETER_12 STATUS_CAST(NTSTATUS, 0xC00000FA) +#define STATUS_REDIRECTOR_NOT_STARTED STATUS_CAST(NTSTATUS, 0xC00000FB) +#define STATUS_REDIRECTOR_STARTED STATUS_CAST(NTSTATUS, 0xC00000FC) +//#define STATUS_STACK_OVERFLOW STATUS_CAST(NTSTATUS,0xC00000FD) +#define STATUS_NO_SUCH_PACKAGE STATUS_CAST(NTSTATUS, 0xC00000FE) +#define STATUS_BAD_FUNCTION_TABLE STATUS_CAST(NTSTATUS, 0xC00000FF) +#define STATUS_VARIABLE_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC0000100) +#define STATUS_DIRECTORY_NOT_EMPTY STATUS_CAST(NTSTATUS, 0xC0000101) +#define STATUS_FILE_CORRUPT_ERROR STATUS_CAST(NTSTATUS, 0xC0000102) +#define STATUS_NOT_A_DIRECTORY STATUS_CAST(NTSTATUS, 0xC0000103) +#define STATUS_BAD_LOGON_SESSION_STATE STATUS_CAST(NTSTATUS, 0xC0000104) +#define STATUS_LOGON_SESSION_COLLISION STATUS_CAST(NTSTATUS, 0xC0000105) +#define STATUS_NAME_TOO_LONG STATUS_CAST(NTSTATUS, 0xC0000106) +#define STATUS_FILES_OPEN STATUS_CAST(NTSTATUS, 0xC0000107) +#define STATUS_CONNECTION_IN_USE STATUS_CAST(NTSTATUS, 0xC0000108) +#define STATUS_MESSAGE_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC0000109) +#define STATUS_PROCESS_IS_TERMINATING STATUS_CAST(NTSTATUS, 0xC000010A) +#define STATUS_INVALID_LOGON_TYPE STATUS_CAST(NTSTATUS, 0xC000010B) +#define STATUS_NO_GUID_TRANSLATION STATUS_CAST(NTSTATUS, 0xC000010C) +#define STATUS_CANNOT_IMPERSONATE STATUS_CAST(NTSTATUS, 0xC000010D) +#define STATUS_IMAGE_ALREADY_LOADED STATUS_CAST(NTSTATUS, 0xC000010E) +#define STATUS_ABIOS_NOT_PRESENT STATUS_CAST(NTSTATUS, 0xC000010F) +#define STATUS_ABIOS_LID_NOT_EXIST STATUS_CAST(NTSTATUS, 0xC0000110) +#define STATUS_ABIOS_LID_ALREADY_OWNED STATUS_CAST(NTSTATUS, 0xC0000111) +#define STATUS_ABIOS_NOT_LID_OWNER STATUS_CAST(NTSTATUS, 0xC0000112) +#define STATUS_ABIOS_INVALID_COMMAND STATUS_CAST(NTSTATUS, 0xC0000113) +#define STATUS_ABIOS_INVALID_LID STATUS_CAST(NTSTATUS, 0xC0000114) +#define STATUS_ABIOS_SELECTOR_NOT_AVAILABLE STATUS_CAST(NTSTATUS, 0xC0000115) +#define STATUS_ABIOS_INVALID_SELECTOR STATUS_CAST(NTSTATUS, 0xC0000116) +#define STATUS_NO_LDT STATUS_CAST(NTSTATUS, 0xC0000117) +#define STATUS_INVALID_LDT_SIZE STATUS_CAST(NTSTATUS, 0xC0000118) +#define STATUS_INVALID_LDT_OFFSET STATUS_CAST(NTSTATUS, 0xC0000119) +#define STATUS_INVALID_LDT_DESCRIPTOR STATUS_CAST(NTSTATUS, 0xC000011A) +#define STATUS_INVALID_IMAGE_NE_FORMAT STATUS_CAST(NTSTATUS, 0xC000011B) +#define STATUS_RXACT_INVALID_STATE STATUS_CAST(NTSTATUS, 0xC000011C) +#define STATUS_RXACT_COMMIT_FAILURE STATUS_CAST(NTSTATUS, 0xC000011D) +#define STATUS_MAPPED_FILE_SIZE_ZERO STATUS_CAST(NTSTATUS, 0xC000011E) +#define STATUS_TOO_MANY_OPENED_FILES STATUS_CAST(NTSTATUS, 0xC000011F) +#define STATUS_CANCELLED STATUS_CAST(NTSTATUS, 0xC0000120) +#define STATUS_CANNOT_DELETE STATUS_CAST(NTSTATUS, 0xC0000121) +#define STATUS_INVALID_COMPUTER_NAME STATUS_CAST(NTSTATUS, 0xC0000122) +#define STATUS_FILE_DELETED STATUS_CAST(NTSTATUS, 0xC0000123) +#define STATUS_SPECIAL_ACCOUNT STATUS_CAST(NTSTATUS, 0xC0000124) +#define STATUS_SPECIAL_GROUP STATUS_CAST(NTSTATUS, 0xC0000125) +#define STATUS_SPECIAL_USER STATUS_CAST(NTSTATUS, 0xC0000126) +#define STATUS_MEMBERS_PRIMARY_GROUP STATUS_CAST(NTSTATUS, 0xC0000127) +#define STATUS_FILE_CLOSED STATUS_CAST(NTSTATUS, 0xC0000128) +#define STATUS_TOO_MANY_THREADS STATUS_CAST(NTSTATUS, 0xC0000129) +#define STATUS_THREAD_NOT_IN_PROCESS STATUS_CAST(NTSTATUS, 0xC000012A) +#define STATUS_TOKEN_ALREADY_IN_USE STATUS_CAST(NTSTATUS, 0xC000012B) +#define STATUS_PAGEFILE_QUOTA_EXCEEDED STATUS_CAST(NTSTATUS, 0xC000012C) +#define STATUS_COMMITMENT_LIMIT STATUS_CAST(NTSTATUS, 0xC000012D) +#define STATUS_INVALID_IMAGE_LE_FORMAT STATUS_CAST(NTSTATUS, 0xC000012E) +#define STATUS_INVALID_IMAGE_NOT_MZ STATUS_CAST(NTSTATUS, 0xC000012F) +#define STATUS_INVALID_IMAGE_PROTECT STATUS_CAST(NTSTATUS, 0xC0000130) +#define STATUS_INVALID_IMAGE_WIN_16 STATUS_CAST(NTSTATUS, 0xC0000131) +#define STATUS_LOGON_SERVER_CONFLICT STATUS_CAST(NTSTATUS, 0xC0000132) +#define STATUS_TIME_DIFFERENCE_AT_DC STATUS_CAST(NTSTATUS, 0xC0000133) +#define STATUS_SYNCHRONIZATION_REQUIRED STATUS_CAST(NTSTATUS, 0xC0000134) +//#define STATUS_DLL_NOT_FOUND STATUS_CAST(NTSTATUS,0xC0000135) +#define STATUS_OPEN_FAILED STATUS_CAST(NTSTATUS, 0xC0000136) +#define STATUS_IO_PRIVILEGE_FAILED STATUS_CAST(NTSTATUS, 0xC0000137) +//#define STATUS_ORDINAL_NOT_FOUND STATUS_CAST(NTSTATUS,0xC0000138) +//#define STATUS_ENTRYPOINT_NOT_FOUND STATUS_CAST(NTSTATUS,0xC0000139) +//#define STATUS_CONTROL_C_EXIT STATUS_CAST(NTSTATUS,0xC000013A) +#define STATUS_LOCAL_DISCONNECT STATUS_CAST(NTSTATUS, 0xC000013B) +#define STATUS_REMOTE_DISCONNECT STATUS_CAST(NTSTATUS, 0xC000013C) +#define STATUS_REMOTE_RESOURCES STATUS_CAST(NTSTATUS, 0xC000013D) +#define STATUS_LINK_FAILED STATUS_CAST(NTSTATUS, 0xC000013E) +#define STATUS_LINK_TIMEOUT STATUS_CAST(NTSTATUS, 0xC000013F) +#define STATUS_INVALID_CONNECTION STATUS_CAST(NTSTATUS, 0xC0000140) +#define STATUS_INVALID_ADDRESS STATUS_CAST(NTSTATUS, 0xC0000141) +//#define STATUS_DLL_INIT_FAILED STATUS_CAST(NTSTATUS,0xC0000142) +#define STATUS_MISSING_SYSTEMFILE STATUS_CAST(NTSTATUS, 0xC0000143) +#define STATUS_UNHANDLED_EXCEPTION STATUS_CAST(NTSTATUS, 0xC0000144) +#define STATUS_APP_INIT_FAILURE STATUS_CAST(NTSTATUS, 0xC0000145) +#define STATUS_PAGEFILE_CREATE_FAILED STATUS_CAST(NTSTATUS, 0xC0000146) +#define STATUS_NO_PAGEFILE STATUS_CAST(NTSTATUS, 0xC0000147) +#define STATUS_INVALID_LEVEL STATUS_CAST(NTSTATUS, 0xC0000148) +#define STATUS_WRONG_PASSWORD_CORE STATUS_CAST(NTSTATUS, 0xC0000149) +#define STATUS_ILLEGAL_FLOAT_CONTEXT STATUS_CAST(NTSTATUS, 0xC000014A) +#define STATUS_PIPE_BROKEN STATUS_CAST(NTSTATUS, 0xC000014B) +#define STATUS_REGISTRY_CORRUPT STATUS_CAST(NTSTATUS, 0xC000014C) +#define STATUS_REGISTRY_IO_FAILED STATUS_CAST(NTSTATUS, 0xC000014D) +#define STATUS_NO_EVENT_PAIR STATUS_CAST(NTSTATUS, 0xC000014E) +#define STATUS_UNRECOGNIZED_VOLUME STATUS_CAST(NTSTATUS, 0xC000014F) +#define STATUS_SERIAL_NO_DEVICE_INITED STATUS_CAST(NTSTATUS, 0xC0000150) +#define STATUS_NO_SUCH_ALIAS STATUS_CAST(NTSTATUS, 0xC0000151) +#define STATUS_MEMBER_NOT_IN_ALIAS STATUS_CAST(NTSTATUS, 0xC0000152) +#define STATUS_MEMBER_IN_ALIAS STATUS_CAST(NTSTATUS, 0xC0000153) +#define STATUS_ALIAS_EXISTS STATUS_CAST(NTSTATUS, 0xC0000154) +#define STATUS_LOGON_NOT_GRANTED STATUS_CAST(NTSTATUS, 0xC0000155) +#define STATUS_TOO_MANY_SECRETS STATUS_CAST(NTSTATUS, 0xC0000156) +#define STATUS_SECRET_TOO_LONG STATUS_CAST(NTSTATUS, 0xC0000157) +#define STATUS_INTERNAL_DB_ERROR STATUS_CAST(NTSTATUS, 0xC0000158) +#define STATUS_FULLSCREEN_MODE STATUS_CAST(NTSTATUS, 0xC0000159) +#define STATUS_TOO_MANY_CONTEXT_IDS STATUS_CAST(NTSTATUS, 0xC000015A) +//#define STATUS_LOGON_TYPE_NOT_GRANTED STATUS_CAST(NTSTATUS,0xC000015B) +#define STATUS_NOT_REGISTRY_FILE STATUS_CAST(NTSTATUS, 0xC000015C) +#define STATUS_NT_CROSS_ENCRYPTION_REQUIRED STATUS_CAST(NTSTATUS, 0xC000015D) +#define STATUS_DOMAIN_CTRLR_CONFIG_ERROR STATUS_CAST(NTSTATUS, 0xC000015E) +#define STATUS_FT_MISSING_MEMBER STATUS_CAST(NTSTATUS, 0xC000015F) +#define STATUS_ILL_FORMED_SERVICE_ENTRY STATUS_CAST(NTSTATUS, 0xC0000160) +#define STATUS_ILLEGAL_CHARACTER STATUS_CAST(NTSTATUS, 0xC0000161) +#define STATUS_UNMAPPABLE_CHARACTER STATUS_CAST(NTSTATUS, 0xC0000162) +#define STATUS_UNDEFINED_CHARACTER STATUS_CAST(NTSTATUS, 0xC0000163) +#define STATUS_FLOPPY_VOLUME STATUS_CAST(NTSTATUS, 0xC0000164) +#define STATUS_FLOPPY_ID_MARK_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC0000165) +#define STATUS_FLOPPY_WRONG_CYLINDER STATUS_CAST(NTSTATUS, 0xC0000166) +#define STATUS_FLOPPY_UNKNOWN_ERROR STATUS_CAST(NTSTATUS, 0xC0000167) +#define STATUS_FLOPPY_BAD_REGISTERS STATUS_CAST(NTSTATUS, 0xC0000168) +#define STATUS_DISK_RECALIBRATE_FAILED STATUS_CAST(NTSTATUS, 0xC0000169) +#define STATUS_DISK_OPERATION_FAILED STATUS_CAST(NTSTATUS, 0xC000016A) +#define STATUS_DISK_RESET_FAILED STATUS_CAST(NTSTATUS, 0xC000016B) +#define STATUS_SHARED_IRQ_BUSY STATUS_CAST(NTSTATUS, 0xC000016C) +#define STATUS_FT_ORPHANING STATUS_CAST(NTSTATUS, 0xC000016D) +#define STATUS_BIOS_FAILED_TO_CONNECT_INTERRUPT STATUS_CAST(NTSTATUS, 0xC000016E) + +#define STATUS_PARTITION_FAILURE STATUS_CAST(NTSTATUS, 0xC0000172) +#define STATUS_INVALID_BLOCK_LENGTH STATUS_CAST(NTSTATUS, 0xC0000173) +#define STATUS_DEVICE_NOT_PARTITIONED STATUS_CAST(NTSTATUS, 0xC0000174) +#define STATUS_UNABLE_TO_LOCK_MEDIA STATUS_CAST(NTSTATUS, 0xC0000175) +#define STATUS_UNABLE_TO_UNLOAD_MEDIA STATUS_CAST(NTSTATUS, 0xC0000176) +#define STATUS_EOM_OVERFLOW STATUS_CAST(NTSTATUS, 0xC0000177) +#define STATUS_NO_MEDIA STATUS_CAST(NTSTATUS, 0xC0000178) +#define STATUS_NO_SUCH_MEMBER STATUS_CAST(NTSTATUS, 0xC000017A) +#define STATUS_INVALID_MEMBER STATUS_CAST(NTSTATUS, 0xC000017B) +#define STATUS_KEY_DELETED STATUS_CAST(NTSTATUS, 0xC000017C) +#define STATUS_NO_LOG_SPACE STATUS_CAST(NTSTATUS, 0xC000017D) +#define STATUS_TOO_MANY_SIDS STATUS_CAST(NTSTATUS, 0xC000017E) +#define STATUS_LM_CROSS_ENCRYPTION_REQUIRED STATUS_CAST(NTSTATUS, 0xC000017F) +#define STATUS_KEY_HAS_CHILDREN STATUS_CAST(NTSTATUS, 0xC0000180) +#define STATUS_CHILD_MUST_BE_VOLATILE STATUS_CAST(NTSTATUS, 0xC0000181) +#define STATUS_DEVICE_CONFIGURATION_ERROR STATUS_CAST(NTSTATUS, 0xC0000182) +#define STATUS_DRIVER_INTERNAL_ERROR STATUS_CAST(NTSTATUS, 0xC0000183) +#define STATUS_INVALID_DEVICE_STATE STATUS_CAST(NTSTATUS, 0xC0000184) +#define STATUS_IO_DEVICE_ERROR STATUS_CAST(NTSTATUS, 0xC0000185) +#define STATUS_DEVICE_PROTOCOL_ERROR STATUS_CAST(NTSTATUS, 0xC0000186) +#define STATUS_BACKUP_CONTROLLER STATUS_CAST(NTSTATUS, 0xC0000187) +#define STATUS_LOG_FILE_FULL STATUS_CAST(NTSTATUS, 0xC0000188) +#define STATUS_TOO_LATE STATUS_CAST(NTSTATUS, 0xC0000189) +#define STATUS_NO_TRUST_LSA_SECRET STATUS_CAST(NTSTATUS, 0xC000018A) +#define STATUS_NO_TRUST_SAM_ACCOUNT STATUS_CAST(NTSTATUS, 0xC000018B) +#define STATUS_TRUSTED_DOMAIN_FAILURE STATUS_CAST(NTSTATUS, 0xC000018C) +#define STATUS_TRUSTED_RELATIONSHIP_FAILURE STATUS_CAST(NTSTATUS, 0xC000018D) +#define STATUS_EVENTLOG_FILE_CORRUPT STATUS_CAST(NTSTATUS, 0xC000018E) +#define STATUS_EVENTLOG_CANT_START STATUS_CAST(NTSTATUS, 0xC000018F) +#define STATUS_TRUST_FAILURE STATUS_CAST(NTSTATUS, 0xC0000190) +#define STATUS_MUTANT_LIMIT_EXCEEDED STATUS_CAST(NTSTATUS, 0xC0000191) +#define STATUS_NETLOGON_NOT_STARTED STATUS_CAST(NTSTATUS, 0xC0000192) +//#define STATUS_ACCOUNT_EXPIRED STATUS_CAST(NTSTATUS,0xC0000193) +#define STATUS_POSSIBLE_DEADLOCK STATUS_CAST(NTSTATUS, 0xC0000194) +#define STATUS_NETWORK_CREDENTIAL_CONFLICT STATUS_CAST(NTSTATUS, 0xC0000195) +#define STATUS_REMOTE_SESSION_LIMIT STATUS_CAST(NTSTATUS, 0xC0000196) +#define STATUS_EVENTLOG_FILE_CHANGED STATUS_CAST(NTSTATUS, 0xC0000197) +#define STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT STATUS_CAST(NTSTATUS, 0xC0000198) +#define STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT STATUS_CAST(NTSTATUS, 0xC0000199) +#define STATUS_NOLOGON_SERVER_TRUST_ACCOUNT STATUS_CAST(NTSTATUS, 0xC000019A) +#define STATUS_DOMAIN_TRUST_INCONSISTENT STATUS_CAST(NTSTATUS, 0xC000019B) +#define STATUS_FS_DRIVER_REQUIRED STATUS_CAST(NTSTATUS, 0xC000019C) +#define STATUS_NO_USER_SESSION_KEY STATUS_CAST(NTSTATUS, 0xC0000202) +#define STATUS_USER_SESSION_DELETED STATUS_CAST(NTSTATUS, 0xC0000203) +#define STATUS_RESOURCE_LANG_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC0000204) +#define STATUS_INSUFF_SERVER_RESOURCES STATUS_CAST(NTSTATUS, 0xC0000205) +#define STATUS_INVALID_BUFFER_SIZE STATUS_CAST(NTSTATUS, 0xC0000206) +#define STATUS_INVALID_ADDRESS_COMPONENT STATUS_CAST(NTSTATUS, 0xC0000207) +#define STATUS_INVALID_ADDRESS_WILDCARD STATUS_CAST(NTSTATUS, 0xC0000208) +#define STATUS_TOO_MANY_ADDRESSES STATUS_CAST(NTSTATUS, 0xC0000209) +#define STATUS_ADDRESS_ALREADY_EXISTS STATUS_CAST(NTSTATUS, 0xC000020A) +#define STATUS_ADDRESS_CLOSED STATUS_CAST(NTSTATUS, 0xC000020B) +#define STATUS_CONNECTION_DISCONNECTED STATUS_CAST(NTSTATUS, 0xC000020C) +#define STATUS_CONNECTION_RESET STATUS_CAST(NTSTATUS, 0xC000020D) +#define STATUS_TOO_MANY_NODES STATUS_CAST(NTSTATUS, 0xC000020E) +#define STATUS_TRANSACTION_ABORTED STATUS_CAST(NTSTATUS, 0xC000020F) +#define STATUS_TRANSACTION_TIMED_OUT STATUS_CAST(NTSTATUS, 0xC0000210) +#define STATUS_TRANSACTION_NO_RELEASE STATUS_CAST(NTSTATUS, 0xC0000211) +#define STATUS_TRANSACTION_NO_MATCH STATUS_CAST(NTSTATUS, 0xC0000212) +#define STATUS_TRANSACTION_RESPONDED STATUS_CAST(NTSTATUS, 0xC0000213) +#define STATUS_TRANSACTION_INVALID_ID STATUS_CAST(NTSTATUS, 0xC0000214) +#define STATUS_TRANSACTION_INVALID_TYPE STATUS_CAST(NTSTATUS, 0xC0000215) +#define STATUS_NOT_SERVER_SESSION STATUS_CAST(NTSTATUS, 0xC0000216) +#define STATUS_NOT_CLIENT_SESSION STATUS_CAST(NTSTATUS, 0xC0000217) +#define STATUS_CANNOT_LOAD_REGISTRY_FILE STATUS_CAST(NTSTATUS, 0xC0000218) +#define STATUS_DEBUG_ATTACH_FAILED STATUS_CAST(NTSTATUS, 0xC0000219) +#define STATUS_SYSTEM_PROCESS_TERMINATED STATUS_CAST(NTSTATUS, 0xC000021A) +#define STATUS_DATA_NOT_ACCEPTED STATUS_CAST(NTSTATUS, 0xC000021B) +#define STATUS_NO_BROWSER_SERVERS_FOUND STATUS_CAST(NTSTATUS, 0xC000021C) +#define STATUS_VDM_HARD_ERROR STATUS_CAST(NTSTATUS, 0xC000021D) +#define STATUS_DRIVER_CANCEL_TIMEOUT STATUS_CAST(NTSTATUS, 0xC000021E) +#define STATUS_REPLY_MESSAGE_MISMATCH STATUS_CAST(NTSTATUS, 0xC000021F) +#define STATUS_MAPPED_ALIGNMENT STATUS_CAST(NTSTATUS, 0xC0000220) +#define STATUS_IMAGE_CHECKSUM_MISMATCH STATUS_CAST(NTSTATUS, 0xC0000221) +#define STATUS_LOST_WRITEBEHIND_DATA STATUS_CAST(NTSTATUS, 0xC0000222) +#define STATUS_CLIENT_SERVER_PARAMETERS_INVALID STATUS_CAST(NTSTATUS, 0xC0000223) +//#define STATUS_PASSWORD_MUST_CHANGE STATUS_CAST(NTSTATUS,0xC0000224) +#define STATUS_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC0000225) +#define STATUS_NOT_TINY_STREAM STATUS_CAST(NTSTATUS, 0xC0000226) +#define STATUS_RECOVERY_FAILURE STATUS_CAST(NTSTATUS, 0xC0000227) +#define STATUS_STACK_OVERFLOW_READ STATUS_CAST(NTSTATUS, 0xC0000228) +#define STATUS_FAIL_CHECK STATUS_CAST(NTSTATUS, 0xC0000229) +#define STATUS_DUPLICATE_OBJECTID STATUS_CAST(NTSTATUS, 0xC000022A) +#define STATUS_OBJECTID_EXISTS STATUS_CAST(NTSTATUS, 0xC000022B) +#define STATUS_CONVERT_TO_LARGE STATUS_CAST(NTSTATUS, 0xC000022C) +#define STATUS_RETRY STATUS_CAST(NTSTATUS, 0xC000022D) +#define STATUS_FOUND_OUT_OF_SCOPE STATUS_CAST(NTSTATUS, 0xC000022E) +#define STATUS_ALLOCATE_BUCKET STATUS_CAST(NTSTATUS, 0xC000022F) +#define STATUS_PROPSET_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC0000230) +#define STATUS_MARSHALL_OVERFLOW STATUS_CAST(NTSTATUS, 0xC0000231) +#define STATUS_INVALID_VARIANT STATUS_CAST(NTSTATUS, 0xC0000232) +#define STATUS_DOMAIN_CONTROLLER_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC0000233) +//#define STATUS_ACCOUNT_LOCKED_OUT STATUS_CAST(NTSTATUS,0xC0000234) +#define STATUS_HANDLE_NOT_CLOSABLE STATUS_CAST(NTSTATUS, 0xC0000235) +#define STATUS_CONNECTION_REFUSED STATUS_CAST(NTSTATUS, 0xC0000236) +#define STATUS_GRACEFUL_DISCONNECT STATUS_CAST(NTSTATUS, 0xC0000237) +#define STATUS_ADDRESS_ALREADY_ASSOCIATED STATUS_CAST(NTSTATUS, 0xC0000238) +#define STATUS_ADDRESS_NOT_ASSOCIATED STATUS_CAST(NTSTATUS, 0xC0000239) +#define STATUS_CONNECTION_INVALID STATUS_CAST(NTSTATUS, 0xC000023A) +#define STATUS_CONNECTION_ACTIVE STATUS_CAST(NTSTATUS, 0xC000023B) +#define STATUS_NETWORK_UNREACHABLE STATUS_CAST(NTSTATUS, 0xC000023C) +#define STATUS_HOST_UNREACHABLE STATUS_CAST(NTSTATUS, 0xC000023D) +#define STATUS_PROTOCOL_UNREACHABLE STATUS_CAST(NTSTATUS, 0xC000023E) +#define STATUS_PORT_UNREACHABLE STATUS_CAST(NTSTATUS, 0xC000023F) +#define STATUS_REQUEST_ABORTED STATUS_CAST(NTSTATUS, 0xC0000240) +#define STATUS_CONNECTION_ABORTED STATUS_CAST(NTSTATUS, 0xC0000241) +#define STATUS_BAD_COMPRESSION_BUFFER STATUS_CAST(NTSTATUS, 0xC0000242) +#define STATUS_USER_MAPPED_FILE STATUS_CAST(NTSTATUS, 0xC0000243) +#define STATUS_AUDIT_FAILED STATUS_CAST(NTSTATUS, 0xC0000244) +#define STATUS_TIMER_RESOLUTION_NOT_SET STATUS_CAST(NTSTATUS, 0xC0000245) +#define STATUS_CONNECTION_COUNT_LIMIT STATUS_CAST(NTSTATUS, 0xC0000246) +#define STATUS_LOGIN_TIME_RESTRICTION STATUS_CAST(NTSTATUS, 0xC0000247) +#define STATUS_LOGIN_WKSTA_RESTRICTION STATUS_CAST(NTSTATUS, 0xC0000248) +#define STATUS_IMAGE_MP_UP_MISMATCH STATUS_CAST(NTSTATUS, 0xC0000249) +#define STATUS_INSUFFICIENT_LOGON_INFO STATUS_CAST(NTSTATUS, 0xC0000250) +#define STATUS_BAD_DLL_ENTRYPOINT STATUS_CAST(NTSTATUS, 0xC0000251) +#define STATUS_BAD_SERVICE_ENTRYPOINT STATUS_CAST(NTSTATUS, 0xC0000252) +#define STATUS_LPC_REPLY_LOST STATUS_CAST(NTSTATUS, 0xC0000253) +#define STATUS_IP_ADDRESS_CONFLICT1 STATUS_CAST(NTSTATUS, 0xC0000254) +#define STATUS_IP_ADDRESS_CONFLICT2 STATUS_CAST(NTSTATUS, 0xC0000255) +#define STATUS_REGISTRY_QUOTA_LIMIT STATUS_CAST(NTSTATUS, 0xC0000256) +#define STATUS_PATH_NOT_COVERED STATUS_CAST(NTSTATUS, 0xC0000257) +#define STATUS_NO_CALLBACK_ACTIVE STATUS_CAST(NTSTATUS, 0xC0000258) +#define STATUS_LICENSE_QUOTA_EXCEEDED STATUS_CAST(NTSTATUS, 0xC0000259) +#define STATUS_PWD_TOO_SHORT STATUS_CAST(NTSTATUS, 0xC000025A) +#define STATUS_PWD_TOO_RECENT STATUS_CAST(NTSTATUS, 0xC000025B) +#define STATUS_PWD_HISTORY_CONFLICT STATUS_CAST(NTSTATUS, 0xC000025C) +#define STATUS_PLUGPLAY_NO_DEVICE STATUS_CAST(NTSTATUS, 0xC000025E) +#define STATUS_UNSUPPORTED_COMPRESSION STATUS_CAST(NTSTATUS, 0xC000025F) +#define STATUS_INVALID_HW_PROFILE STATUS_CAST(NTSTATUS, 0xC0000260) +#define STATUS_INVALID_PLUGPLAY_DEVICE_PATH STATUS_CAST(NTSTATUS, 0xC0000261) +#define STATUS_DRIVER_ORDINAL_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC0000262) +#define STATUS_DRIVER_ENTRYPOINT_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC0000263) +#define STATUS_RESOURCE_NOT_OWNED STATUS_CAST(NTSTATUS, 0xC0000264) +#define STATUS_TOO_MANY_LINKS STATUS_CAST(NTSTATUS, 0xC0000265) +#define STATUS_QUOTA_LIST_INCONSISTENT STATUS_CAST(NTSTATUS, 0xC0000266) +#define STATUS_FILE_IS_OFFLINE STATUS_CAST(NTSTATUS, 0xC0000267) +#define STATUS_EVALUATION_EXPIRATION STATUS_CAST(NTSTATUS, 0xC0000268) +#define STATUS_ILLEGAL_DLL_RELOCATION STATUS_CAST(NTSTATUS, 0xC0000269) +#define STATUS_LICENSE_VIOLATION STATUS_CAST(NTSTATUS, 0xC000026A) +#define STATUS_DLL_INIT_FAILED_LOGOFF STATUS_CAST(NTSTATUS, 0xC000026B) +#define STATUS_DRIVER_UNABLE_TO_LOAD STATUS_CAST(NTSTATUS, 0xC000026C) +#define STATUS_DFS_UNAVAILABLE STATUS_CAST(NTSTATUS, 0xC000026D) +#define STATUS_VOLUME_DISMOUNTED STATUS_CAST(NTSTATUS, 0xC000026E) +#define STATUS_WX86_INTERNAL_ERROR STATUS_CAST(NTSTATUS, 0xC000026F) +#define STATUS_WX86_FLOAT_STACK_CHECK STATUS_CAST(NTSTATUS, 0xC0000270) +#define STATUS_VALIDATE_CONTINUE STATUS_CAST(NTSTATUS, 0xC0000271) +#define STATUS_NO_MATCH STATUS_CAST(NTSTATUS, 0xC0000272) +#define STATUS_NO_MORE_MATCHES STATUS_CAST(NTSTATUS, 0xC0000273) +#define STATUS_NOT_A_REPARSE_POINT STATUS_CAST(NTSTATUS, 0xC0000275) +#define STATUS_IO_REPARSE_TAG_INVALID STATUS_CAST(NTSTATUS, 0xC0000276) +#define STATUS_IO_REPARSE_TAG_MISMATCH STATUS_CAST(NTSTATUS, 0xC0000277) +#define STATUS_IO_REPARSE_DATA_INVALID STATUS_CAST(NTSTATUS, 0xC0000278) +#define STATUS_IO_REPARSE_TAG_NOT_HANDLED STATUS_CAST(NTSTATUS, 0xC0000279) +#define STATUS_REPARSE_POINT_NOT_RESOLVED STATUS_CAST(NTSTATUS, 0xC0000280) +#define STATUS_DIRECTORY_IS_A_REPARSE_POINT STATUS_CAST(NTSTATUS, 0xC0000281) +#define STATUS_RANGE_LIST_CONFLICT STATUS_CAST(NTSTATUS, 0xC0000282) +#define STATUS_SOURCE_ELEMENT_EMPTY STATUS_CAST(NTSTATUS, 0xC0000283) +#define STATUS_DESTINATION_ELEMENT_FULL STATUS_CAST(NTSTATUS, 0xC0000284) +#define STATUS_ILLEGAL_ELEMENT_ADDRESS STATUS_CAST(NTSTATUS, 0xC0000285) +#define STATUS_MAGAZINE_NOT_PRESENT STATUS_CAST(NTSTATUS, 0xC0000286) +#define STATUS_REINITIALIZATION_NEEDED STATUS_CAST(NTSTATUS, 0xC0000287) +#define STATUS_ENCRYPTION_FAILED STATUS_CAST(NTSTATUS, 0xC000028A) +#define STATUS_DECRYPTION_FAILED STATUS_CAST(NTSTATUS, 0xC000028B) +#define STATUS_RANGE_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC000028C) +#define STATUS_NO_RECOVERY_POLICY STATUS_CAST(NTSTATUS, 0xC000028D) +#define STATUS_NO_EFS STATUS_CAST(NTSTATUS, 0xC000028E) +#define STATUS_WRONG_EFS STATUS_CAST(NTSTATUS, 0xC000028F) +#define STATUS_NO_USER_KEYS STATUS_CAST(NTSTATUS, 0xC0000290) +#define STATUS_FILE_NOT_ENCRYPTED STATUS_CAST(NTSTATUS, 0xC0000291) +#define STATUS_NOT_EXPORT_FORMAT STATUS_CAST(NTSTATUS, 0xC0000292) +#define STATUS_FILE_ENCRYPTED STATUS_CAST(NTSTATUS, 0xC0000293) +#define STATUS_WMI_GUID_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC0000295) +#define STATUS_WMI_INSTANCE_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC0000296) +#define STATUS_WMI_ITEMID_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC0000297) +#define STATUS_WMI_TRY_AGAIN STATUS_CAST(NTSTATUS, 0xC0000298) +#define STATUS_SHARED_POLICY STATUS_CAST(NTSTATUS, 0xC0000299) +#define STATUS_POLICY_OBJECT_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC000029A) +#define STATUS_POLICY_ONLY_IN_DS STATUS_CAST(NTSTATUS, 0xC000029B) +#define STATUS_VOLUME_NOT_UPGRADED STATUS_CAST(NTSTATUS, 0xC000029C) +#define STATUS_REMOTE_STORAGE_NOT_ACTIVE STATUS_CAST(NTSTATUS, 0xC000029D) +#define STATUS_REMOTE_STORAGE_MEDIA_ERROR STATUS_CAST(NTSTATUS, 0xC000029E) +#define STATUS_NO_TRACKING_SERVICE STATUS_CAST(NTSTATUS, 0xC000029F) +#define STATUS_SERVER_SID_MISMATCH STATUS_CAST(NTSTATUS, 0xC00002A0) +#define STATUS_DS_NO_ATTRIBUTE_OR_VALUE STATUS_CAST(NTSTATUS, 0xC00002A1) +#define STATUS_DS_INVALID_ATTRIBUTE_SYNTAX STATUS_CAST(NTSTATUS, 0xC00002A2) +#define STATUS_DS_ATTRIBUTE_TYPE_UNDEFINED STATUS_CAST(NTSTATUS, 0xC00002A3) +#define STATUS_DS_ATTRIBUTE_OR_VALUE_EXISTS STATUS_CAST(NTSTATUS, 0xC00002A4) +#define STATUS_DS_BUSY STATUS_CAST(NTSTATUS, 0xC00002A5) +#define STATUS_DS_UNAVAILABLE STATUS_CAST(NTSTATUS, 0xC00002A6) +#define STATUS_DS_NO_RIDS_ALLOCATED STATUS_CAST(NTSTATUS, 0xC00002A7) +#define STATUS_DS_NO_MORE_RIDS STATUS_CAST(NTSTATUS, 0xC00002A8) +#define STATUS_DS_INCORRECT_ROLE_OWNER STATUS_CAST(NTSTATUS, 0xC00002A9) +#define STATUS_DS_RIDMGR_INIT_ERROR STATUS_CAST(NTSTATUS, 0xC00002AA) +#define STATUS_DS_OBJ_CLASS_VIOLATION STATUS_CAST(NTSTATUS, 0xC00002AB) +#define STATUS_DS_CANT_ON_NON_LEAF STATUS_CAST(NTSTATUS, 0xC00002AC) +#define STATUS_DS_CANT_ON_RDN STATUS_CAST(NTSTATUS, 0xC00002AD) +#define STATUS_DS_CANT_MOD_OBJ_CLASS STATUS_CAST(NTSTATUS, 0xC00002AE) +#define STATUS_DS_CROSS_DOM_MOVE_FAILED STATUS_CAST(NTSTATUS, 0xC00002AF) +#define STATUS_DS_GC_NOT_AVAILABLE STATUS_CAST(NTSTATUS, 0xC00002B0) +#define STATUS_DIRECTORY_SERVICE_REQUIRED STATUS_CAST(NTSTATUS, 0xC00002B1) +#define STATUS_REPARSE_ATTRIBUTE_CONFLICT STATUS_CAST(NTSTATUS, 0xC00002B2) +#define STATUS_CANT_ENABLE_DENY_ONLY STATUS_CAST(NTSTATUS, 0xC00002B3) +//#define STATUS_FLOAT_MULTIPLE_FAULTS STATUS_CAST(NTSTATUS,0xC00002B4) +//#define STATUS_FLOAT_MULTIPLE_TRAPS STATUS_CAST(NTSTATUS,0xC00002B5) +#define STATUS_DEVICE_REMOVED STATUS_CAST(NTSTATUS, 0xC00002B6) +#define STATUS_JOURNAL_DELETE_IN_PROGRESS STATUS_CAST(NTSTATUS, 0xC00002B7) +#define STATUS_JOURNAL_NOT_ACTIVE STATUS_CAST(NTSTATUS, 0xC00002B8) +#define STATUS_NOINTERFACE STATUS_CAST(NTSTATUS, 0xC00002B9) +#define STATUS_DS_ADMIN_LIMIT_EXCEEDED STATUS_CAST(NTSTATUS, 0xC00002C1) +#define STATUS_DRIVER_FAILED_SLEEP STATUS_CAST(NTSTATUS, 0xC00002C2) +#define STATUS_MUTUAL_AUTHENTICATION_FAILED STATUS_CAST(NTSTATUS, 0xC00002C3) +#define STATUS_CORRUPT_SYSTEM_FILE STATUS_CAST(NTSTATUS, 0xC00002C4) +#define STATUS_DATATYPE_MISALIGNMENT_ERROR STATUS_CAST(NTSTATUS, 0xC00002C5) +#define STATUS_WMI_READ_ONLY STATUS_CAST(NTSTATUS, 0xC00002C6) +#define STATUS_WMI_SET_FAILURE STATUS_CAST(NTSTATUS, 0xC00002C7) +#define STATUS_COMMITMENT_MINIMUM STATUS_CAST(NTSTATUS, 0xC00002C8) +//#define STATUS_REG_NAT_CONSUMPTION STATUS_CAST(NTSTATUS,0xC00002C9) +#define STATUS_TRANSPORT_FULL STATUS_CAST(NTSTATUS, 0xC00002CA) +#define STATUS_DS_SAM_INIT_FAILURE STATUS_CAST(NTSTATUS, 0xC00002CB) +#define STATUS_ONLY_IF_CONNECTED STATUS_CAST(NTSTATUS, 0xC00002CC) +#define STATUS_DS_SENSITIVE_GROUP_VIOLATION STATUS_CAST(NTSTATUS, 0xC00002CD) +#define STATUS_PNP_RESTART_ENUMERATION STATUS_CAST(NTSTATUS, 0xC00002CE) +#define STATUS_JOURNAL_ENTRY_DELETED STATUS_CAST(NTSTATUS, 0xC00002CF) +#define STATUS_DS_CANT_MOD_PRIMARYGROUPID STATUS_CAST(NTSTATUS, 0xC00002D0) +#define STATUS_SYSTEM_IMAGE_BAD_SIGNATURE STATUS_CAST(NTSTATUS, 0xC00002D1) +#define STATUS_PNP_REBOOT_REQUIRED STATUS_CAST(NTSTATUS, 0xC00002D2) +#define STATUS_POWER_STATE_INVALID STATUS_CAST(NTSTATUS, 0xC00002D3) +#define STATUS_DS_INVALID_GROUP_TYPE STATUS_CAST(NTSTATUS, 0xC00002D4) +#define STATUS_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN STATUS_CAST(NTSTATUS, 0xC00002D5) +#define STATUS_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN STATUS_CAST(NTSTATUS, 0xC00002D6) +#define STATUS_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER STATUS_CAST(NTSTATUS, 0xC00002D7) +#define STATUS_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER STATUS_CAST(NTSTATUS, 0xC00002D8) +#define STATUS_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER STATUS_CAST(NTSTATUS, 0xC00002D9) +#define STATUS_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER STATUS_CAST(NTSTATUS, 0xC00002DA) +#define STATUS_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER STATUS_CAST(NTSTATUS, 0xC00002DB) +#define STATUS_DS_HAVE_PRIMARY_MEMBERS STATUS_CAST(NTSTATUS, 0xC00002DC) +#define STATUS_WMI_NOT_SUPPORTED STATUS_CAST(NTSTATUS, 0xC00002DD) +#define STATUS_INSUFFICIENT_POWER STATUS_CAST(NTSTATUS, 0xC00002DE) +#define STATUS_SAM_NEED_BOOTKEY_PASSWORD STATUS_CAST(NTSTATUS, 0xC00002DF) +#define STATUS_SAM_NEED_BOOTKEY_FLOPPY STATUS_CAST(NTSTATUS, 0xC00002E0) +#define STATUS_DS_CANT_START STATUS_CAST(NTSTATUS, 0xC00002E1) +#define STATUS_DS_INIT_FAILURE STATUS_CAST(NTSTATUS, 0xC00002E2) +#define STATUS_SAM_INIT_FAILURE STATUS_CAST(NTSTATUS, 0xC00002E3) +#define STATUS_DS_GC_REQUIRED STATUS_CAST(NTSTATUS, 0xC00002E4) +#define STATUS_DS_LOCAL_MEMBER_OF_LOCAL_ONLY STATUS_CAST(NTSTATUS, 0xC00002E5) +#define STATUS_DS_NO_FPO_IN_UNIVERSAL_GROUPS STATUS_CAST(NTSTATUS, 0xC00002E6) +#define STATUS_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED STATUS_CAST(NTSTATUS, 0xC00002E7) +#define STATUS_MULTIPLE_FAULT_VIOLATION STATUS_CAST(NTSTATUS, 0xC00002E8) +#define STATUS_CURRENT_DOMAIN_NOT_ALLOWED STATUS_CAST(NTSTATUS, 0xC00002E9) +#define STATUS_CANNOT_MAKE STATUS_CAST(NTSTATUS, 0xC00002EA) +#define STATUS_SYSTEM_SHUTDOWN STATUS_CAST(NTSTATUS, 0xC00002EB) +#define STATUS_DS_INIT_FAILURE_CONSOLE STATUS_CAST(NTSTATUS, 0xC00002EC) +#define STATUS_DS_SAM_INIT_FAILURE_CONSOLE STATUS_CAST(NTSTATUS, 0xC00002ED) +#define STATUS_UNFINISHED_CONTEXT_DELETED STATUS_CAST(NTSTATUS, 0xC00002EE) +#define STATUS_NO_TGT_REPLY STATUS_CAST(NTSTATUS, 0xC00002EF) +#define STATUS_OBJECTID_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC00002F0) +#define STATUS_NO_IP_ADDRESSES STATUS_CAST(NTSTATUS, 0xC00002F1) +#define STATUS_WRONG_CREDENTIAL_HANDLE STATUS_CAST(NTSTATUS, 0xC00002F2) +#define STATUS_CRYPTO_SYSTEM_INVALID STATUS_CAST(NTSTATUS, 0xC00002F3) +#define STATUS_MAX_REFERRALS_EXCEEDED STATUS_CAST(NTSTATUS, 0xC00002F4) +#define STATUS_MUST_BE_KDC STATUS_CAST(NTSTATUS, 0xC00002F5) +#define STATUS_STRONG_CRYPTO_NOT_SUPPORTED STATUS_CAST(NTSTATUS, 0xC00002F6) +#define STATUS_TOO_MANY_PRINCIPALS STATUS_CAST(NTSTATUS, 0xC00002F7) +#define STATUS_NO_PA_DATA STATUS_CAST(NTSTATUS, 0xC00002F8) +#define STATUS_PKINIT_NAME_MISMATCH STATUS_CAST(NTSTATUS, 0xC00002F9) +#define STATUS_SMARTCARD_LOGON_REQUIRED STATUS_CAST(NTSTATUS, 0xC00002FA) +#define STATUS_KDC_INVALID_REQUEST STATUS_CAST(NTSTATUS, 0xC00002FB) +#define STATUS_KDC_UNABLE_TO_REFER STATUS_CAST(NTSTATUS, 0xC00002FC) +#define STATUS_KDC_UNKNOWN_ETYPE STATUS_CAST(NTSTATUS, 0xC00002FD) +#define STATUS_SHUTDOWN_IN_PROGRESS STATUS_CAST(NTSTATUS, 0xC00002FE) +#define STATUS_SERVER_SHUTDOWN_IN_PROGRESS STATUS_CAST(NTSTATUS, 0xC00002FF) +#define STATUS_NOT_SUPPORTED_ON_SBS STATUS_CAST(NTSTATUS, 0xC0000300) +#define STATUS_WMI_GUID_DISCONNECTED STATUS_CAST(NTSTATUS, 0xC0000301) +#define STATUS_WMI_ALREADY_DISABLED STATUS_CAST(NTSTATUS, 0xC0000302) +#define STATUS_WMI_ALREADY_ENABLED STATUS_CAST(NTSTATUS, 0xC0000303) +#define STATUS_MFT_TOO_FRAGMENTED STATUS_CAST(NTSTATUS, 0xC0000304) +#define STATUS_COPY_PROTECTION_FAILURE STATUS_CAST(NTSTATUS, 0xC0000305) +#define STATUS_CSS_AUTHENTICATION_FAILURE STATUS_CAST(NTSTATUS, 0xC0000306) +#define STATUS_CSS_KEY_NOT_PRESENT STATUS_CAST(NTSTATUS, 0xC0000307) +#define STATUS_CSS_KEY_NOT_ESTABLISHED STATUS_CAST(NTSTATUS, 0xC0000308) +#define STATUS_CSS_SCRAMBLED_SECTOR STATUS_CAST(NTSTATUS, 0xC0000309) +#define STATUS_CSS_REGION_MISMATCH STATUS_CAST(NTSTATUS, 0xC000030A) +#define STATUS_CSS_RESETS_EXHAUSTED STATUS_CAST(NTSTATUS, 0xC000030B) +#define STATUS_PKINIT_FAILURE STATUS_CAST(NTSTATUS, 0xC0000320) +#define STATUS_SMARTCARD_SUBSYSTEM_FAILURE STATUS_CAST(NTSTATUS, 0xC0000321) +#define STATUS_NO_KERB_KEY STATUS_CAST(NTSTATUS, 0xC0000322) +#define STATUS_HOST_DOWN STATUS_CAST(NTSTATUS, 0xC0000350) +#define STATUS_UNSUPPORTED_PREAUTH STATUS_CAST(NTSTATUS, 0xC0000351) +#define STATUS_EFS_ALG_BLOB_TOO_BIG STATUS_CAST(NTSTATUS, 0xC0000352) +#define STATUS_PORT_NOT_SET STATUS_CAST(NTSTATUS, 0xC0000353) +#define STATUS_DEBUGGER_INACTIVE STATUS_CAST(NTSTATUS, 0xC0000354) +#define STATUS_DS_VERSION_CHECK_FAILURE STATUS_CAST(NTSTATUS, 0xC0000355) +#define STATUS_AUDITING_DISABLED STATUS_CAST(NTSTATUS, 0xC0000356) +#define STATUS_PRENT4_MACHINE_ACCOUNT STATUS_CAST(NTSTATUS, 0xC0000357) +#define STATUS_DS_AG_CANT_HAVE_UNIVERSAL_MEMBER STATUS_CAST(NTSTATUS, 0xC0000358) +#define STATUS_INVALID_IMAGE_WIN_32 STATUS_CAST(NTSTATUS, 0xC0000359) +#define STATUS_INVALID_IMAGE_WIN_64 STATUS_CAST(NTSTATUS, 0xC000035A) +#define STATUS_BAD_BINDINGS STATUS_CAST(NTSTATUS, 0xC000035B) +#define STATUS_NETWORK_SESSION_EXPIRED STATUS_CAST(NTSTATUS, 0xC000035C) +#define STATUS_APPHELP_BLOCK STATUS_CAST(NTSTATUS, 0xC000035D) +#define STATUS_ALL_SIDS_FILTERED STATUS_CAST(NTSTATUS, 0xC000035E) +#define STATUS_NOT_SAFE_MODE_DRIVER STATUS_CAST(NTSTATUS, 0xC000035F) +#define STATUS_ACCESS_DISABLED_BY_POLICY_DEFAULT STATUS_CAST(NTSTATUS, 0xC0000361) +#define STATUS_ACCESS_DISABLED_BY_POLICY_PATH STATUS_CAST(NTSTATUS, 0xC0000362) +#define STATUS_ACCESS_DISABLED_BY_POLICY_PUBLISHER STATUS_CAST(NTSTATUS, 0xC0000363) +#define STATUS_ACCESS_DISABLED_BY_POLICY_OTHER STATUS_CAST(NTSTATUS, 0xC0000364) +#define STATUS_FAILED_DRIVER_ENTRY STATUS_CAST(NTSTATUS, 0xC0000365) +#define STATUS_DEVICE_ENUMERATION_ERROR STATUS_CAST(NTSTATUS, 0xC0000366) +#define STATUS_WAIT_FOR_OPLOCK STATUS_CAST(NTSTATUS, 0x00000367) +#define STATUS_MOUNT_POINT_NOT_RESOLVED STATUS_CAST(NTSTATUS, 0xC0000368) +#define STATUS_INVALID_DEVICE_OBJECT_PARAMETER STATUS_CAST(NTSTATUS, 0xC0000369) +/* The following is not a typo. It's the same spelling as in the Microsoft headers */ +#define STATUS_MCA_OCCURED STATUS_CAST(NTSTATUS, 0xC000036A) +#define STATUS_DRIVER_BLOCKED_CRITICAL STATUS_CAST(NTSTATUS, 0xC000036B) +#define STATUS_DRIVER_BLOCKED STATUS_CAST(NTSTATUS, 0xC000036C) +#define STATUS_DRIVER_DATABASE_ERROR STATUS_CAST(NTSTATUS, 0xC000036D) +#define STATUS_SYSTEM_HIVE_TOO_LARGE STATUS_CAST(NTSTATUS, 0xC000036E) +#define STATUS_INVALID_IMPORT_OF_NON_DLL STATUS_CAST(NTSTATUS, 0xC000036F) +#define STATUS_SMARTCARD_WRONG_PIN STATUS_CAST(NTSTATUS, 0xC0000380) +#define STATUS_SMARTCARD_CARD_BLOCKED STATUS_CAST(NTSTATUS, 0xC0000381) +#define STATUS_SMARTCARD_CARD_NOT_AUTHENTICATED STATUS_CAST(NTSTATUS, 0xC0000382) +#define STATUS_SMARTCARD_NO_CARD STATUS_CAST(NTSTATUS, 0xC0000383) +#define STATUS_SMARTCARD_NO_KEY_CONTAINER STATUS_CAST(NTSTATUS, 0xC0000384) +#define STATUS_SMARTCARD_NO_CERTIFICATE STATUS_CAST(NTSTATUS, 0xC0000385) +#define STATUS_SMARTCARD_NO_KEYSET STATUS_CAST(NTSTATUS, 0xC0000386) +#define STATUS_SMARTCARD_IO_ERROR STATUS_CAST(NTSTATUS, 0xC0000387) +//#define STATUS_DOWNGRADE_DETECTED STATUS_CAST(NTSTATUS,0xC0000388) +#define STATUS_SMARTCARD_CERT_REVOKED STATUS_CAST(NTSTATUS, 0xC0000389) +#define STATUS_ISSUING_CA_UNTRUSTED STATUS_CAST(NTSTATUS, 0xC000038A) +#define STATUS_REVOCATION_OFFLINE_C STATUS_CAST(NTSTATUS, 0xC000038B) +#define STATUS_PKINIT_CLIENT_FAILURE STATUS_CAST(NTSTATUS, 0xC000038C) +#define STATUS_SMARTCARD_CERT_EXPIRED STATUS_CAST(NTSTATUS, 0xC000038D) +#define STATUS_DRIVER_FAILED_PRIOR_UNLOAD STATUS_CAST(NTSTATUS, 0xC000038E) +#define STATUS_SMARTCARD_SILENT_CONTEXT STATUS_CAST(NTSTATUS, 0xC000038F) +#define STATUS_PER_USER_TRUST_QUOTA_EXCEEDED STATUS_CAST(NTSTATUS, 0xC0000401) +#define STATUS_ALL_USER_TRUST_QUOTA_EXCEEDED STATUS_CAST(NTSTATUS, 0xC0000402) +#define STATUS_USER_DELETE_TRUST_QUOTA_EXCEEDED STATUS_CAST(NTSTATUS, 0xC0000403) +#define STATUS_DS_NAME_NOT_UNIQUE STATUS_CAST(NTSTATUS, 0xC0000404) +#define STATUS_DS_DUPLICATE_ID_FOUND STATUS_CAST(NTSTATUS, 0xC0000405) +#define STATUS_DS_GROUP_CONVERSION_ERROR STATUS_CAST(NTSTATUS, 0xC0000406) +#define STATUS_VOLSNAP_PREPARE_HIBERNATE STATUS_CAST(NTSTATUS, 0xC0000407) +#define STATUS_USER2USER_REQUIRED STATUS_CAST(NTSTATUS, 0xC0000408) +//#define STATUS_STACK_BUFFER_OVERRUN STATUS_CAST(NTSTATUS,0xC0000409) +#define STATUS_NO_S4U_PROT_SUPPORT STATUS_CAST(NTSTATUS, 0xC000040A) +#define STATUS_CROSSREALM_DELEGATION_FAILURE STATUS_CAST(NTSTATUS, 0xC000040B) +#define STATUS_REVOCATION_OFFLINE_KDC STATUS_CAST(NTSTATUS, 0xC000040C) +#define STATUS_ISSUING_CA_UNTRUSTED_KDC STATUS_CAST(NTSTATUS, 0xC000040D) +#define STATUS_KDC_CERT_EXPIRED STATUS_CAST(NTSTATUS, 0xC000040E) +#define STATUS_KDC_CERT_REVOKED STATUS_CAST(NTSTATUS, 0xC000040F) +#define STATUS_PARAMETER_QUOTA_EXCEEDED STATUS_CAST(NTSTATUS, 0xC0000410) +#define STATUS_HIBERNATION_FAILURE STATUS_CAST(NTSTATUS, 0xC0000411) +#define STATUS_DELAY_LOAD_FAILED STATUS_CAST(NTSTATUS, 0xC0000412) +//#define STATUS_AUTHENTICATION_FIREWALL_FAILED STATUS_CAST(NTSTATUS,0xC0000413) +#define STATUS_VDM_DISALLOWED STATUS_CAST(NTSTATUS, 0xC0000414) +#define STATUS_HUNG_DISPLAY_DRIVER_THREAD STATUS_CAST(NTSTATUS, 0xC0000415) +//#define STATUS_INVALID_CRUNTIME_PARAMETER STATUS_CAST(NTSTATUS,0xC0000417) +//#define STATUS_ASSERTION_FAILURE STATUS_CAST(NTSTATUS,0xC0000420L) +#define STATUS_CALLBACK_POP_STACK STATUS_CAST(NTSTATUS, 0xC0000423) +#define STATUS_WOW_ASSERTION STATUS_CAST(NTSTATUS, 0xC0009898) + +#define RPC_NT_INVALID_STRING_BINDING STATUS_CAST(NTSTATUS, 0xC0020001) +#define RPC_NT_WRONG_KIND_OF_BINDING STATUS_CAST(NTSTATUS, 0xC0020002) +#define RPC_NT_INVALID_BINDING STATUS_CAST(NTSTATUS, 0xC0020003) +#define RPC_NT_PROTSEQ_NOT_SUPPORTED STATUS_CAST(NTSTATUS, 0xC0020004) +#define RPC_NT_INVALID_RPC_PROTSEQ STATUS_CAST(NTSTATUS, 0xC0020005) +#define RPC_NT_INVALID_STRING_UUID STATUS_CAST(NTSTATUS, 0xC0020006) +#define RPC_NT_INVALID_ENDPOINT_FORMAT STATUS_CAST(NTSTATUS, 0xC0020007) +#define RPC_NT_INVALID_NET_ADDR STATUS_CAST(NTSTATUS, 0xC0020008) +#define RPC_NT_NO_ENDPOINT_FOUND STATUS_CAST(NTSTATUS, 0xC0020009) +#define RPC_NT_INVALID_TIMEOUT STATUS_CAST(NTSTATUS, 0xC002000A) +#define RPC_NT_OBJECT_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC002000B) +#define RPC_NT_ALREADY_REGISTERED STATUS_CAST(NTSTATUS, 0xC002000C) +#define RPC_NT_TYPE_ALREADY_REGISTERED STATUS_CAST(NTSTATUS, 0xC002000D) +#define RPC_NT_ALREADY_LISTENING STATUS_CAST(NTSTATUS, 0xC002000E) +#define RPC_NT_NO_PROTSEQS_REGISTERED STATUS_CAST(NTSTATUS, 0xC002000F) +#define RPC_NT_NOT_LISTENING STATUS_CAST(NTSTATUS, 0xC0020010) +#define RPC_NT_UNKNOWN_MGR_TYPE STATUS_CAST(NTSTATUS, 0xC0020011) +#define RPC_NT_UNKNOWN_IF STATUS_CAST(NTSTATUS, 0xC0020012) +#define RPC_NT_NO_BINDINGS STATUS_CAST(NTSTATUS, 0xC0020013) +#define RPC_NT_NO_PROTSEQS STATUS_CAST(NTSTATUS, 0xC0020014) +#define RPC_NT_CANT_CREATE_ENDPOINT STATUS_CAST(NTSTATUS, 0xC0020015) +#define RPC_NT_OUT_OF_RESOURCES STATUS_CAST(NTSTATUS, 0xC0020016) +#define RPC_NT_SERVER_UNAVAILABLE STATUS_CAST(NTSTATUS, 0xC0020017) +#define RPC_NT_SERVER_TOO_BUSY STATUS_CAST(NTSTATUS, 0xC0020018) +#define RPC_NT_INVALID_NETWORK_OPTIONS STATUS_CAST(NTSTATUS, 0xC0020019) +#define RPC_NT_NO_CALL_ACTIVE STATUS_CAST(NTSTATUS, 0xC002001A) +#define RPC_NT_CALL_FAILED STATUS_CAST(NTSTATUS, 0xC002001B) +#define RPC_NT_CALL_FAILED_DNE STATUS_CAST(NTSTATUS, 0xC002001C) +#define RPC_NT_PROTOCOL_ERROR STATUS_CAST(NTSTATUS, 0xC002001D) +#define RPC_NT_UNSUPPORTED_TRANS_SYN STATUS_CAST(NTSTATUS, 0xC002001F) +#define RPC_NT_UNSUPPORTED_TYPE STATUS_CAST(NTSTATUS, 0xC0020021) +#define RPC_NT_INVALID_TAG STATUS_CAST(NTSTATUS, 0xC0020022) +#define RPC_NT_INVALID_BOUND STATUS_CAST(NTSTATUS, 0xC0020023) +#define RPC_NT_NO_ENTRY_NAME STATUS_CAST(NTSTATUS, 0xC0020024) +#define RPC_NT_INVALID_NAME_SYNTAX STATUS_CAST(NTSTATUS, 0xC0020025) +#define RPC_NT_UNSUPPORTED_NAME_SYNTAX STATUS_CAST(NTSTATUS, 0xC0020026) +#define RPC_NT_UUID_NO_ADDRESS STATUS_CAST(NTSTATUS, 0xC0020028) +#define RPC_NT_DUPLICATE_ENDPOINT STATUS_CAST(NTSTATUS, 0xC0020029) +#define RPC_NT_UNKNOWN_AUTHN_TYPE STATUS_CAST(NTSTATUS, 0xC002002A) +#define RPC_NT_MAX_CALLS_TOO_SMALL STATUS_CAST(NTSTATUS, 0xC002002B) +#define RPC_NT_STRING_TOO_LONG STATUS_CAST(NTSTATUS, 0xC002002C) +#define RPC_NT_PROTSEQ_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC002002D) +#define RPC_NT_PROCNUM_OUT_OF_RANGE STATUS_CAST(NTSTATUS, 0xC002002E) +#define RPC_NT_BINDING_HAS_NO_AUTH STATUS_CAST(NTSTATUS, 0xC002002F) +#define RPC_NT_UNKNOWN_AUTHN_SERVICE STATUS_CAST(NTSTATUS, 0xC0020030) +#define RPC_NT_UNKNOWN_AUTHN_LEVEL STATUS_CAST(NTSTATUS, 0xC0020031) +#define RPC_NT_INVALID_AUTH_IDENTITY STATUS_CAST(NTSTATUS, 0xC0020032) +#define RPC_NT_UNKNOWN_AUTHZ_SERVICE STATUS_CAST(NTSTATUS, 0xC0020033) +#define EPT_NT_INVALID_ENTRY STATUS_CAST(NTSTATUS, 0xC0020034) +#define EPT_NT_CANT_PERFORM_OP STATUS_CAST(NTSTATUS, 0xC0020035) +#define EPT_NT_NOT_REGISTERED STATUS_CAST(NTSTATUS, 0xC0020036) +#define RPC_NT_NOTHING_TO_EXPORT STATUS_CAST(NTSTATUS, 0xC0020037) +#define RPC_NT_INCOMPLETE_NAME STATUS_CAST(NTSTATUS, 0xC0020038) +#define RPC_NT_INVALID_VERS_OPTION STATUS_CAST(NTSTATUS, 0xC0020039) +#define RPC_NT_NO_MORE_MEMBERS STATUS_CAST(NTSTATUS, 0xC002003A) +#define RPC_NT_NOT_ALL_OBJS_UNEXPORTED STATUS_CAST(NTSTATUS, 0xC002003B) +#define RPC_NT_INTERFACE_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC002003C) +#define RPC_NT_ENTRY_ALREADY_EXISTS STATUS_CAST(NTSTATUS, 0xC002003D) +#define RPC_NT_ENTRY_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC002003E) +#define RPC_NT_NAME_SERVICE_UNAVAILABLE STATUS_CAST(NTSTATUS, 0xC002003F) +#define RPC_NT_INVALID_NAF_ID STATUS_CAST(NTSTATUS, 0xC0020040) +#define RPC_NT_CANNOT_SUPPORT STATUS_CAST(NTSTATUS, 0xC0020041) +#define RPC_NT_NO_CONTEXT_AVAILABLE STATUS_CAST(NTSTATUS, 0xC0020042) +#define RPC_NT_INTERNAL_ERROR STATUS_CAST(NTSTATUS, 0xC0020043) +#define RPC_NT_ZERO_DIVIDE STATUS_CAST(NTSTATUS, 0xC0020044) +#define RPC_NT_ADDRESS_ERROR STATUS_CAST(NTSTATUS, 0xC0020045) +#define RPC_NT_FP_DIV_ZERO STATUS_CAST(NTSTATUS, 0xC0020046) +#define RPC_NT_FP_UNDERFLOW STATUS_CAST(NTSTATUS, 0xC0020047) +#define RPC_NT_FP_OVERFLOW STATUS_CAST(NTSTATUS, 0xC0020048) +#define RPC_NT_CALL_IN_PROGRESS STATUS_CAST(NTSTATUS, 0xC0020049) +#define RPC_NT_NO_MORE_BINDINGS STATUS_CAST(NTSTATUS, 0xC002004A) +#define RPC_NT_GROUP_MEMBER_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC002004B) +#define EPT_NT_CANT_CREATE STATUS_CAST(NTSTATUS, 0xC002004C) +#define RPC_NT_INVALID_OBJECT STATUS_CAST(NTSTATUS, 0xC002004D) +#define RPC_NT_NO_INTERFACES STATUS_CAST(NTSTATUS, 0xC002004F) +#define RPC_NT_CALL_CANCELLED STATUS_CAST(NTSTATUS, 0xC0020050) +#define RPC_NT_BINDING_INCOMPLETE STATUS_CAST(NTSTATUS, 0xC0020051) +#define RPC_NT_COMM_FAILURE STATUS_CAST(NTSTATUS, 0xC0020052) +#define RPC_NT_UNSUPPORTED_AUTHN_LEVEL STATUS_CAST(NTSTATUS, 0xC0020053) +#define RPC_NT_NO_PRINC_NAME STATUS_CAST(NTSTATUS, 0xC0020054) +#define RPC_NT_NOT_RPC_ERROR STATUS_CAST(NTSTATUS, 0xC0020055) +#define RPC_NT_SEC_PKG_ERROR STATUS_CAST(NTSTATUS, 0xC0020057) +#define RPC_NT_NOT_CANCELLED STATUS_CAST(NTSTATUS, 0xC0020058) +#define RPC_NT_INVALID_ASYNC_HANDLE STATUS_CAST(NTSTATUS, 0xC0020062) +#define RPC_NT_INVALID_ASYNC_CALL STATUS_CAST(NTSTATUS, 0xC0020063) + +#define RPC_NT_NO_MORE_ENTRIES STATUS_CAST(NTSTATUS, 0xC0030001) +#define RPC_NT_SS_CHAR_TRANS_OPEN_FAIL STATUS_CAST(NTSTATUS, 0xC0030002) +#define RPC_NT_SS_CHAR_TRANS_SHORT_FILE STATUS_CAST(NTSTATUS, 0xC0030003) +#define RPC_NT_SS_IN_NULL_CONTEXT STATUS_CAST(NTSTATUS, 0xC0030004) +#define RPC_NT_SS_CONTEXT_MISMATCH STATUS_CAST(NTSTATUS, 0xC0030005) +#define RPC_NT_SS_CONTEXT_DAMAGED STATUS_CAST(NTSTATUS, 0xC0030006) +#define RPC_NT_SS_HANDLES_MISMATCH STATUS_CAST(NTSTATUS, 0xC0030007) +#define RPC_NT_SS_CANNOT_GET_CALL_HANDLE STATUS_CAST(NTSTATUS, 0xC0030008) +#define RPC_NT_NULL_REF_POINTER STATUS_CAST(NTSTATUS, 0xC0030009) +#define RPC_NT_ENUM_VALUE_OUT_OF_RANGE STATUS_CAST(NTSTATUS, 0xC003000A) +#define RPC_NT_BYTE_COUNT_TOO_SMALL STATUS_CAST(NTSTATUS, 0xC003000B) +#define RPC_NT_BAD_STUB_DATA STATUS_CAST(NTSTATUS, 0xC003000C) +#define RPC_NT_INVALID_ES_ACTION STATUS_CAST(NTSTATUS, 0xC0030059) +#define RPC_NT_WRONG_ES_VERSION STATUS_CAST(NTSTATUS, 0xC003005A) +#define RPC_NT_WRONG_STUB_VERSION STATUS_CAST(NTSTATUS, 0xC003005B) +#define RPC_NT_INVALID_PIPE_OBJECT STATUS_CAST(NTSTATUS, 0xC003005C) +#define RPC_NT_INVALID_PIPE_OPERATION STATUS_CAST(NTSTATUS, 0xC003005D) +#define RPC_NT_WRONG_PIPE_VERSION STATUS_CAST(NTSTATUS, 0xC003005E) +#define RPC_NT_PIPE_CLOSED STATUS_CAST(NTSTATUS, 0xC003005F) +#define RPC_NT_PIPE_DISCIPLINE_ERROR STATUS_CAST(NTSTATUS, 0xC0030060) +#define RPC_NT_PIPE_EMPTY STATUS_CAST(NTSTATUS, 0xC0030061) + +#define STATUS_PNP_BAD_MPS_TABLE STATUS_CAST(NTSTATUS, 0xC0040035) +#define STATUS_PNP_TRANSLATION_FAILED STATUS_CAST(NTSTATUS, 0xC0040036) +#define STATUS_PNP_IRQ_TRANSLATION_FAILED STATUS_CAST(NTSTATUS, 0xC0040037) +#define STATUS_PNP_INVALID_ID STATUS_CAST(NTSTATUS, 0xC0040038) + +#define STATUS_ACPI_INVALID_OPCODE STATUS_CAST(NTSTATUS, 0xC0140001L) +#define STATUS_ACPI_STACK_OVERFLOW STATUS_CAST(NTSTATUS, 0xC0140002L) +#define STATUS_ACPI_ASSERT_FAILED STATUS_CAST(NTSTATUS, 0xC0140003L) +#define STATUS_ACPI_INVALID_INDEX STATUS_CAST(NTSTATUS, 0xC0140004L) +#define STATUS_ACPI_INVALID_ARGUMENT STATUS_CAST(NTSTATUS, 0xC0140005L) +#define STATUS_ACPI_FATAL STATUS_CAST(NTSTATUS, 0xC0140006L) +#define STATUS_ACPI_INVALID_SUPERNAME STATUS_CAST(NTSTATUS, 0xC0140007L) +#define STATUS_ACPI_INVALID_ARGTYPE STATUS_CAST(NTSTATUS, 0xC0140008L) +#define STATUS_ACPI_INVALID_OBJTYPE STATUS_CAST(NTSTATUS, 0xC0140009L) +#define STATUS_ACPI_INVALID_TARGETTYPE STATUS_CAST(NTSTATUS, 0xC014000AL) +#define STATUS_ACPI_INCORRECT_ARGUMENT_COUNT STATUS_CAST(NTSTATUS, 0xC014000BL) +#define STATUS_ACPI_ADDRESS_NOT_MAPPED STATUS_CAST(NTSTATUS, 0xC014000CL) +#define STATUS_ACPI_INVALID_EVENTTYPE STATUS_CAST(NTSTATUS, 0xC014000DL) +#define STATUS_ACPI_HANDLER_COLLISION STATUS_CAST(NTSTATUS, 0xC014000EL) +#define STATUS_ACPI_INVALID_DATA STATUS_CAST(NTSTATUS, 0xC014000FL) +#define STATUS_ACPI_INVALID_REGION STATUS_CAST(NTSTATUS, 0xC0140010L) +#define STATUS_ACPI_INVALID_ACCESS_SIZE STATUS_CAST(NTSTATUS, 0xC0140011L) +#define STATUS_ACPI_ACQUIRE_GLOBAL_LOCK STATUS_CAST(NTSTATUS, 0xC0140012L) +#define STATUS_ACPI_ALREADY_INITIALIZED STATUS_CAST(NTSTATUS, 0xC0140013L) +#define STATUS_ACPI_NOT_INITIALIZED STATUS_CAST(NTSTATUS, 0xC0140014L) +#define STATUS_ACPI_INVALID_MUTEX_LEVEL STATUS_CAST(NTSTATUS, 0xC0140015L) +#define STATUS_ACPI_MUTEX_NOT_OWNED STATUS_CAST(NTSTATUS, 0xC0140016L) +#define STATUS_ACPI_MUTEX_NOT_OWNER STATUS_CAST(NTSTATUS, 0xC0140017L) +#define STATUS_ACPI_RS_ACCESS STATUS_CAST(NTSTATUS, 0xC0140018L) +#define STATUS_ACPI_INVALID_TABLE STATUS_CAST(NTSTATUS, 0xC0140019L) +#define STATUS_ACPI_REG_HANDLER_FAILED STATUS_CAST(NTSTATUS, 0xC0140020L) +#define STATUS_ACPI_POWER_REQUEST_FAILED STATUS_CAST(NTSTATUS, 0xC0140021L) + +#define STATUS_CTX_WINSTATION_NAME_INVALID STATUS_CAST(NTSTATUS, 0xC00A0001) +#define STATUS_CTX_INVALID_PD STATUS_CAST(NTSTATUS, 0xC00A0002) +#define STATUS_CTX_PD_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC00A0003) +#define STATUS_CTX_CLOSE_PENDING STATUS_CAST(NTSTATUS, 0xC00A0006) +#define STATUS_CTX_NO_OUTBUF STATUS_CAST(NTSTATUS, 0xC00A0007) +#define STATUS_CTX_MODEM_INF_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC00A0008) +#define STATUS_CTX_INVALID_MODEMNAME STATUS_CAST(NTSTATUS, 0xC00A0009) +#define STATUS_CTX_RESPONSE_ERROR STATUS_CAST(NTSTATUS, 0xC00A000A) +#define STATUS_CTX_MODEM_RESPONSE_TIMEOUT STATUS_CAST(NTSTATUS, 0xC00A000B) +#define STATUS_CTX_MODEM_RESPONSE_NO_CARRIER STATUS_CAST(NTSTATUS, 0xC00A000C) +#define STATUS_CTX_MODEM_RESPONSE_NO_DIALTONE STATUS_CAST(NTSTATUS, 0xC00A000D) +#define STATUS_CTX_MODEM_RESPONSE_BUSY STATUS_CAST(NTSTATUS, 0xC00A000E) +#define STATUS_CTX_MODEM_RESPONSE_VOICE STATUS_CAST(NTSTATUS, 0xC00A000F) +#define STATUS_CTX_TD_ERROR STATUS_CAST(NTSTATUS, 0xC00A0010) +#define STATUS_CTX_LICENSE_CLIENT_INVALID STATUS_CAST(NTSTATUS, 0xC00A0012) +#define STATUS_CTX_LICENSE_NOT_AVAILABLE STATUS_CAST(NTSTATUS, 0xC00A0013) +#define STATUS_CTX_LICENSE_EXPIRED STATUS_CAST(NTSTATUS, 0xC00A0014) +#define STATUS_CTX_WINSTATION_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC00A0015) +#define STATUS_CTX_WINSTATION_NAME_COLLISION STATUS_CAST(NTSTATUS, 0xC00A0016) +#define STATUS_CTX_WINSTATION_BUSY STATUS_CAST(NTSTATUS, 0xC00A0017) +#define STATUS_CTX_BAD_VIDEO_MODE STATUS_CAST(NTSTATUS, 0xC00A0018) +#define STATUS_CTX_GRAPHICS_INVALID STATUS_CAST(NTSTATUS, 0xC00A0022) +#define STATUS_CTX_NOT_CONSOLE STATUS_CAST(NTSTATUS, 0xC00A0024) +#define STATUS_CTX_CLIENT_QUERY_TIMEOUT STATUS_CAST(NTSTATUS, 0xC00A0026) +#define STATUS_CTX_CONSOLE_DISCONNECT STATUS_CAST(NTSTATUS, 0xC00A0027) +#define STATUS_CTX_CONSOLE_CONNECT STATUS_CAST(NTSTATUS, 0xC00A0028) +#define STATUS_CTX_SHADOW_DENIED STATUS_CAST(NTSTATUS, 0xC00A002A) +#define STATUS_CTX_WINSTATION_ACCESS_DENIED STATUS_CAST(NTSTATUS, 0xC00A002B) +#define STATUS_CTX_INVALID_WD STATUS_CAST(NTSTATUS, 0xC00A002E) +#define STATUS_CTX_WD_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC00A002F) +#define STATUS_CTX_SHADOW_INVALID STATUS_CAST(NTSTATUS, 0xC00A0030) +#define STATUS_CTX_SHADOW_DISABLED STATUS_CAST(NTSTATUS, 0xC00A0031) +#define STATUS_RDP_PROTOCOL_ERROR STATUS_CAST(NTSTATUS, 0xC00A0032) +#define STATUS_CTX_CLIENT_LICENSE_NOT_SET STATUS_CAST(NTSTATUS, 0xC00A0033) +#define STATUS_CTX_CLIENT_LICENSE_IN_USE STATUS_CAST(NTSTATUS, 0xC00A0034) +#define STATUS_CTX_SHADOW_ENDED_BY_MODE_CHANGE STATUS_CAST(NTSTATUS, 0xC00A0035) +#define STATUS_CTX_SHADOW_NOT_RUNNING STATUS_CAST(NTSTATUS, 0xC00A0036) + +#define STATUS_CLUSTER_INVALID_NODE STATUS_CAST(NTSTATUS, 0xC0130001) +#define STATUS_CLUSTER_NODE_EXISTS STATUS_CAST(NTSTATUS, 0xC0130002) +#define STATUS_CLUSTER_JOIN_IN_PROGRESS STATUS_CAST(NTSTATUS, 0xC0130003) +#define STATUS_CLUSTER_NODE_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC0130004) +#define STATUS_CLUSTER_LOCAL_NODE_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC0130005) +#define STATUS_CLUSTER_NETWORK_EXISTS STATUS_CAST(NTSTATUS, 0xC0130006) +#define STATUS_CLUSTER_NETWORK_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC0130007) +#define STATUS_CLUSTER_NETINTERFACE_EXISTS STATUS_CAST(NTSTATUS, 0xC0130008) +#define STATUS_CLUSTER_NETINTERFACE_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC0130009) +#define STATUS_CLUSTER_INVALID_REQUEST STATUS_CAST(NTSTATUS, 0xC013000A) +#define STATUS_CLUSTER_INVALID_NETWORK_PROVIDER STATUS_CAST(NTSTATUS, 0xC013000B) +#define STATUS_CLUSTER_NODE_DOWN STATUS_CAST(NTSTATUS, 0xC013000C) +#define STATUS_CLUSTER_NODE_UNREACHABLE STATUS_CAST(NTSTATUS, 0xC013000D) +#define STATUS_CLUSTER_NODE_NOT_MEMBER STATUS_CAST(NTSTATUS, 0xC013000E) +#define STATUS_CLUSTER_JOIN_NOT_IN_PROGRESS STATUS_CAST(NTSTATUS, 0xC013000F) +#define STATUS_CLUSTER_INVALID_NETWORK STATUS_CAST(NTSTATUS, 0xC0130010) +#define STATUS_CLUSTER_NO_NET_ADAPTERS STATUS_CAST(NTSTATUS, 0xC0130011) +#define STATUS_CLUSTER_NODE_UP STATUS_CAST(NTSTATUS, 0xC0130012) +#define STATUS_CLUSTER_NODE_PAUSED STATUS_CAST(NTSTATUS, 0xC0130013) +#define STATUS_CLUSTER_NODE_NOT_PAUSED STATUS_CAST(NTSTATUS, 0xC0130014) +#define STATUS_CLUSTER_NO_SECURITY_CONTEXT STATUS_CAST(NTSTATUS, 0xC0130015) +#define STATUS_CLUSTER_NETWORK_NOT_INTERNAL STATUS_CAST(NTSTATUS, 0xC0130016) +#define STATUS_CLUSTER_POISONED STATUS_CAST(NTSTATUS, 0xC0130017) + +#define STATUS_SXS_SECTION_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC0150001) +#define STATUS_SXS_CANT_GEN_ACTCTX STATUS_CAST(NTSTATUS, 0xC0150002) +#define STATUS_SXS_INVALID_ACTCTXDATA_FORMAT STATUS_CAST(NTSTATUS, 0xC0150003) +#define STATUS_SXS_ASSEMBLY_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC0150004) +#define STATUS_SXS_MANIFEST_FORMAT_ERROR STATUS_CAST(NTSTATUS, 0xC0150005) +#define STATUS_SXS_MANIFEST_PARSE_ERROR STATUS_CAST(NTSTATUS, 0xC0150006) +#define STATUS_SXS_ACTIVATION_CONTEXT_DISABLED STATUS_CAST(NTSTATUS, 0xC0150007) +#define STATUS_SXS_KEY_NOT_FOUND STATUS_CAST(NTSTATUS, 0xC0150008) +#define STATUS_SXS_VERSION_CONFLICT STATUS_CAST(NTSTATUS, 0xC0150009) +#define STATUS_SXS_WRONG_SECTION_TYPE STATUS_CAST(NTSTATUS, 0xC015000A) +#define STATUS_SXS_THREAD_QUERIES_DISABLED STATUS_CAST(NTSTATUS, 0xC015000B) +#define STATUS_SXS_ASSEMBLY_MISSING STATUS_CAST(NTSTATUS, 0xC015000C) +#define STATUS_SXS_PROCESS_DEFAULT_ALREADY_SET STATUS_CAST(NTSTATUS, 0xC015000E) +//#define STATUS_SXS_EARLY_DEACTIVATION STATUS_CAST(NTSTATUS,0xC015000F) +//#define STATUS_SXS_INVALID_DEACTIVATION STATUS_CAST(NTSTATUS,0xC0150010) +#define STATUS_SXS_MULTIPLE_DEACTIVATION STATUS_CAST(NTSTATUS, 0xC0150011) +#define STATUS_SXS_SYSTEM_DEFAULT_ACTIVATION_CONTEXT_EMPTY STATUS_CAST(NTSTATUS, 0xC0150012) +#define STATUS_SXS_PROCESS_TERMINATION_REQUESTED STATUS_CAST(NTSTATUS, 0xC0150013) +#define STATUS_SXS_CORRUPT_ACTIVATION_STACK STATUS_CAST(NTSTATUS, 0xC0150014) +#define STATUS_SXS_CORRUPTION STATUS_CAST(NTSTATUS, 0xC0150015) +#define STATUS_SXS_INVALID_IDENTITY_ATTRIBUTE_VALUE STATUS_CAST(NTSTATUS, 0xC0150016) +#define STATUS_SXS_INVALID_IDENTITY_ATTRIBUTE_NAME STATUS_CAST(NTSTATUS, 0xC0150017) +#define STATUS_SXS_IDENTITY_DUPLICATE_ATTRIBUTE STATUS_CAST(NTSTATUS, 0xC0150018) +#define STATUS_SXS_IDENTITY_PARSE_ERROR STATUS_CAST(NTSTATUS, 0xC0150019) +#define STATUS_SXS_COMPONENT_STORE_CORRUPT STATUS_CAST(NTSTATUS, 0xC015001A) +#define STATUS_SXS_FILE_HASH_MISMATCH STATUS_CAST(NTSTATUS, 0xC015001B) +#define STATUS_SXS_MANIFEST_IDENTITY_SAME_BUT_CONTENTS_DIFFERENT STATUS_CAST(NTSTATUS, 0xC015001C) +#define STATUS_SXS_IDENTITIES_DIFFERENT STATUS_CAST(NTSTATUS, 0xC015001D) +#define STATUS_SXS_ASSEMBLY_IS_NOT_A_DEPLOYMENT STATUS_CAST(NTSTATUS, 0xC015001E) +#define STATUS_SXS_FILE_NOT_PART_OF_ASSEMBLY STATUS_CAST(NTSTATUS, 0xC015001F) +#define STATUS_ADVANCED_INSTALLER_FAILED STATUS_CAST(NTSTATUS, 0xC0150020) +#define STATUS_XML_ENCODING_MISMATCH STATUS_CAST(NTSTATUS, 0xC0150021) +#define STATUS_SXS_MANIFEST_TOO_BIG STATUS_CAST(NTSTATUS, 0xC0150022) +#define STATUS_SXS_SETTING_NOT_REGISTERED STATUS_CAST(NTSTATUS, 0xC0150023) +#define STATUS_SXS_TRANSACTION_CLOSURE_INCOMPLETE STATUS_CAST(NTSTATUS, 0xC0150024) +#define STATUS_SXS_PRIMITIVE_INSTALLER_FAILED STATUS_CAST(NTSTATUS, 0xC0150025) +#define STATUS_GENERIC_COMMAND_FAILED STATUS_CAST(NTSTATUS, 0xC0150026) +#define STATUS_SXS_FILE_HASH_MISSING STATUS_CAST(NTSTATUS, 0xC0150027) + +/* Defined in winternl.h, always define since we do not include this header */ + +/* defined in ntstatus.h */ +#if !defined(NTSTATUS_FROM_WIN32) && !defined(INLINE_NTSTATUS_FROM_WIN32) +static INLINE NTSTATUS NTSTATUS_FROM_WIN32(long x) +{ + return x <= 0 ? STATUS_CAST(NTSTATUS, x) + : STATUS_CAST(NTSTATUS, ((x)&0x0000FFFF) | (0x7 << 16) | 0xC0000000); +} +#endif + +#if defined(_WIN32) && !defined(__MINGW32__) + +/** + * winternl.h contains an incomplete definition of enum FILE_INFORMATION_CLASS + * avoid conflict by prefixing the winternl.h definition by _WINTERNL_ and then + * make a complete definition of enum FILE_INFORMATION_CLASS ourselves. + * + * For more information, refer to [MS-FSCC]: File System Control Codes: + * http://msdn.microsoft.com/en-us/library/cc231987.aspx + */ + +#define FILE_INFORMATION_CLASS _WINTERNL_FILE_INFORMATION_CLASS +#define _FILE_INFORMATION_CLASS _WINTERNL__FILE_INFORMATION_CLASS +#define FileDirectoryInformation _WINTERNL_FileDirectoryInformation + +#include <winternl.h> + +#undef FILE_INFORMATION_CLASS +#undef _FILE_INFORMATION_CLASS +#undef FileDirectoryInformation + +#elif defined(_WIN32) +#include <winternl.h> +#endif + +#ifndef __MINGW32__ +typedef enum +{ + FileDirectoryInformation = 1, + FileFullDirectoryInformation, + FileBothDirectoryInformation, + FileBasicInformation, + FileStandardInformation, + FileInternalInformation, + FileEaInformation, + FileAccessInformation, + FileNameInformation, + FileRenameInformation, + FileLinkInformation, + FileNamesInformation, + FileDispositionInformation, + FilePositionInformation, + FileFullEaInformation, + FileModeInformation, + FileAlignmentInformation, + FileAllInformation, + FileAllocationInformation, + FileEndOfFileInformation, + FileAlternateNameInformation, + FileStreamInformation, + FilePipeInformation, + FilePipeLocalInformation, + FilePipeRemoteInformation, + FileMailslotQueryInformation, + FileMailslotSetInformation, + FileCompressionInformation, + FileObjectIdInformation, + FileUnknownInformation1, + FileMoveClusterInformation, + FileQuotaInformation, + FileReparsePointInformation, + FileNetworkOpenInformation, + FileAttributeTagInformation, + FileTrackingInformation, + FileIdBothDirectoryInformation, + FileIdFullDirectoryInformation, + FileValidDataLengthInformation, + FileShortNameInformation +} FILE_INFORMATION_CLASS; +#endif /* !__MINGW32__ */ + +#if !defined(_WIN32) || defined(__MINGW32__) +/* defined in <winternl.h> */ +#define FILE_SUPERSEDED 0x00000000 +#define FILE_OPENED 0x00000001 +#define FILE_CREATED 0x00000002 +#define FILE_OVERWRITTEN 0x00000003 +#define FILE_EXISTS 0x00000004 +#define FILE_DOES_NOT_EXIST 0x00000005 +#endif + +#if !defined(_WIN32) || defined(_UWP) + +#define FILE_SUPERSEDE 0x00000000 +#define FILE_OPEN 0x00000001 +#define FILE_CREATE 0x00000002 +#define FILE_OPEN_IF 0x00000003 +#define FILE_OVERWRITE 0x00000004 +#define FILE_OVERWRITE_IF 0x00000005 +#define FILE_MAXIMUM_DISPOSITION 0x00000005 + +#define FILE_DIRECTORY_FILE 0x00000001 +#define FILE_WRITE_THROUGH 0x00000002 +#define FILE_SEQUENTIAL_ONLY 0x00000004 +#define FILE_NO_INTERMEDIATE_BUFFERING 0x00000008 + +#define FILE_SYNCHRONOUS_IO_ALERT 0x00000010 +#define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020 +#define FILE_NON_DIRECTORY_FILE 0x00000040 +#define FILE_CREATE_TREE_CONNECTION 0x00000080 + +#define FILE_COMPLETE_IF_OPLOCKED 0x00000100 +#define FILE_NO_EA_KNOWLEDGE 0x00000200 +#define FILE_OPEN_REMOTE_INSTANCE 0x00000400 +#define FILE_RANDOM_ACCESS 0x00000800 + +#define FILE_DELETE_ON_CLOSE 0x00001000 +#define FILE_OPEN_BY_FILE_ID 0x00002000 +#define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000 +#define FILE_NO_COMPRESSION 0x00008000 + +#define FILE_OPEN_REQUIRING_OPLOCK 0x00010000 + +#define FILE_RESERVE_OPFILTER 0x00100000 +#define FILE_OPEN_REPARSE_POINT 0x00200000 +#define FILE_OPEN_NO_RECALL 0x00400000 +#define FILE_OPEN_FOR_FREE_SPACE_QUERY 0x00800000 + +#define FILE_VALID_OPTION_FLAGS 0x00FFFFFF +#define FILE_VALID_PIPE_OPTION_FLAGS 0x00000032 +#define FILE_VALID_MAILSLOT_OPTION_FLAGS 0x00000032 +#define FILE_VALID_SET_FLAGS 0x00000036 + +typedef CONST char* PCSZ; + +typedef struct +{ + USHORT Length; + USHORT MaximumLength; + PCHAR Buffer; +} STRING; +typedef STRING* PSTRING; + +typedef STRING ANSI_STRING; +typedef PSTRING PANSI_STRING; +typedef PSTRING PCANSI_STRING; + +typedef STRING OEM_STRING; +typedef PSTRING POEM_STRING; +typedef CONST STRING* PCOEM_STRING; + +typedef struct +{ + USHORT Length; + USHORT MaximumLength; + PWSTR Buffer; +} LSA_UNICODE_STRING, *PLSA_UNICODE_STRING, UNICODE_STRING, *PUNICODE_STRING; + +#define OBJ_INHERIT 0x00000002L +#define OBJ_PERMANENT 0x00000010L +#define OBJ_EXCLUSIVE 0x00000020L +#define OBJ_CASE_INSENSITIVE 0x00000040L +#define OBJ_OPENIF 0x00000080L +#define OBJ_OPENLINK 0x00000100L +#define OBJ_KERNEL_HANDLE 0x00000200L +#define OBJ_FORCE_ACCESS_CHECK 0x00000400L +#define OBJ_VALID_ATTRIBUTES 0x000007F2L + +typedef struct +{ + ULONG Length; + HANDLE RootDirectory; + PUNICODE_STRING ObjectName; + ULONG Attributes; + PVOID SecurityDescriptor; + PVOID SecurityQualityOfService; +} OBJECT_ATTRIBUTES; +typedef OBJECT_ATTRIBUTES* POBJECT_ATTRIBUTES; + +typedef struct +{ + union + { +#ifdef _WIN32 + NTSTATUS Status; +#else + NTSTATUS status; +#endif + PVOID Pointer; + }; + ULONG_PTR Information; +} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK; + +typedef VOID (*PIO_APC_ROUTINE)(PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, ULONG Reserved); + +#endif + +#if !defined(_WIN32) + +typedef struct S_PEB PEB; +typedef struct S_PEB* PPEB; + +typedef struct S_TEB TEB; +typedef struct S_TEB* PTEB; + +/** + * Process Environment Block + */ + +typedef struct +{ + DWORD ThreadId; + TEB* ThreadEnvironmentBlock; +} THREAD_BLOCK_ID; + +struct S_PEB +{ + DWORD ThreadCount; + DWORD ThreadArraySize; + THREAD_BLOCK_ID* Threads; +}; + +/* + * Thread Environment Block + */ + +struct S_TEB +{ + PEB* ProcessEnvironmentBlock; + + DWORD LastErrorValue; + PVOID TlsSlots[64]; +}; + +#define GENERIC_READ 0x80000000 +#define GENERIC_WRITE 0x40000000 +#define GENERIC_EXECUTE 0x20000000 +#define GENERIC_ALL 0x10000000 + +#define DELETE 0x00010000 +#define READ_CONTROL 0x00020000 +#define WRITE_DAC 0x00040000 +#define WRITE_OWNER 0x00080000 +#define SYNCHRONIZE 0x00100000 +#define STANDARD_RIGHTS_REQUIRED 0x000F0000 +#define STANDARD_RIGHTS_READ 0x00020000 +#define STANDARD_RIGHTS_WRITE 0x00020000 +#define STANDARD_RIGHTS_EXECUTE 0x00020000 +#define STANDARD_RIGHTS_ALL 0x001F0000 +#define SPECIFIC_RIGHTS_ALL 0x0000FFFF +#define ACCESS_SYSTEM_SECURITY 0x01000000 +#define MAXIMUM_ALLOWED 0x02000000 + +#define FILE_READ_DATA 0x0001 +#define FILE_LIST_DIRECTORY 0x0001 +#define FILE_WRITE_DATA 0x0002 +#define FILE_ADD_FILE 0x0002 +#define FILE_APPEND_DATA 0x0004 +#define FILE_ADD_SUBDIRECTORY 0x0004 +#define FILE_CREATE_PIPE_INSTANCE 0x0004 +#define FILE_READ_EA 0x0008 +#define FILE_WRITE_EA 0x0010 +#define FILE_EXECUTE 0x0020 +#define FILE_TRAVERSE 0x0020 +#define FILE_DELETE_CHILD 0x0040 +#define FILE_READ_ATTRIBUTES 0x0080 +#define FILE_WRITE_ATTRIBUTES 0x0100 + +#define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF) +#define FILE_GENERIC_READ \ + (STANDARD_RIGHTS_READ | FILE_READ_DATA | FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE) +#define FILE_GENERIC_WRITE \ + (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | \ + FILE_APPEND_DATA | SYNCHRONIZE) +#define FILE_GENERIC_EXECUTE \ + (STANDARD_RIGHTS_EXECUTE | FILE_READ_ATTRIBUTES | FILE_EXECUTE | SYNCHRONIZE) + +#define FILE_SHARE_READ 0x00000001 +#define FILE_SHARE_WRITE 0x00000002 +#define FILE_SHARE_DELETE 0x00000004 + +typedef DWORD ACCESS_MASK; +typedef ACCESS_MASK* PACCESS_MASK; + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API PTEB NtCurrentTeb(void); + +#ifdef __cplusplus +} +#endif + +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API const char* NtStatus2Tag(DWORD ntstatus); + WINPR_API const char* Win32ErrorCode2Tag(UINT16 code); + +#ifdef __cplusplus +} +#endif + +#endif /* WINPR_NT_H */ diff --git a/winpr/include/winpr/ntlm.h b/winpr/include/winpr/ntlm.h new file mode 100644 index 0000000..85b3f29 --- /dev/null +++ b/winpr/include/winpr/ntlm.h @@ -0,0 +1,68 @@ +/** + * WinPR: Windows Portable Runtime + * NTLM Utils + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_UTILS_NTLM_H +#define WINPR_UTILS_NTLM_H + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <winpr/winpr.h> +#include <winpr/wtypes.h> +#include <winpr/sspi.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef SECURITY_STATUS (*psPeerComputeNtlmHash)(void* client, + const SEC_WINNT_AUTH_IDENTITY* authIdentity, + const SecBuffer* ntproofvalue, + const BYTE* randkey, const BYTE* mic, + const SecBuffer* micvalue, BYTE* ntlmhash); + + WINPR_API BOOL NTOWFv1W(LPWSTR Password, UINT32 PasswordLength, BYTE* NtHash); + WINPR_API BOOL NTOWFv1A(LPSTR Password, UINT32 PasswordLength, BYTE* NtHash); + + WINPR_API BOOL NTOWFv2W(LPWSTR Password, UINT32 PasswordLength, LPWSTR User, UINT32 UserLength, + LPWSTR Domain, UINT32 DomainLength, BYTE* NtHash); + WINPR_API BOOL NTOWFv2A(LPSTR Password, UINT32 PasswordLength, LPSTR User, UINT32 UserLength, + LPSTR Domain, UINT32 DomainLength, BYTE* NtHash); + + WINPR_API BOOL NTOWFv2FromHashW(BYTE* NtHashV1, LPWSTR User, UINT32 UserLength, LPWSTR Domain, + UINT32 DomainLength, BYTE* NtHash); + WINPR_API BOOL NTOWFv2FromHashA(BYTE* NtHashV1, LPSTR User, UINT32 UserLength, LPSTR Domain, + UINT32 DomainLength, BYTE* NtHash); + +#ifdef __cplusplus +} +#endif + +#ifdef UNICODE +#define NTOWFv1 NTOWFv1W +#define NTOWFv2 NTOWFv2W +#define NTOWFv2FromHash NTOWFv2FromHashW +#else +#define NTOWFv1 NTOWFv1A +#define NTOWFv2 NTOWFv2A +#define NTOWFv2FromHash NTOWFv2FromHashA +#endif + +#endif /* WINPR_UTILS_NTLM_H */ diff --git a/winpr/include/winpr/pack.h b/winpr/include/winpr/pack.h new file mode 100644 index 0000000..f97ba9a --- /dev/null +++ b/winpr/include/winpr/pack.h @@ -0,0 +1,100 @@ +/** + * WinPR: Windows Portable Runtime + * Pragma Pack + * + * Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * This header is meant to be repeatedly included + * after defining the operation to be done: + * + * #define WINPR_PACK_PUSH + * #include <winpr/pack.h> // enables packing + * + * #define WINPR_PACK_POP + * #include <winpr/pack.h> // disables packing + * + * On each include, WINPR_PACK_* macros are undefined. + */ + +#if !defined(__APPLE__) +#ifndef WINPR_PRAGMA_PACK_EXT +#define WINPR_PRAGMA_PACK_EXT +#endif +#endif + +#ifdef PRAGMA_PACK_PUSH +#ifndef PRAGMA_PACK_PUSH1 +#define PRAGMA_PACK_PUSH1 +#endif +#undef PRAGMA_PACK_PUSH +#endif + +#ifdef PRAGMA_PACK_PUSH1 +#ifdef WINPR_PRAGMA_PACK_EXT +#pragma pack(push, 1) +#else +#pragma pack(1) +#endif +#undef PRAGMA_PACK_PUSH1 +#endif + +#ifdef PRAGMA_PACK_PUSH2 +#ifdef WINPR_PRAGMA_PACK_EXT +#pragma pack(push, 2) +#else +#pragma pack(2) +#endif +#undef PRAGMA_PACK_PUSH2 +#endif + +#ifdef PRAGMA_PACK_PUSH4 +#ifdef WINPR_PRAGMA_PACK_EXT +#pragma pack(push, 4) +#else +#pragma pack(4) +#endif +#undef PRAGMA_PACK_PUSH4 +#endif + +#ifdef PRAGMA_PACK_PUSH8 +#ifdef WINPR_PRAGMA_PACK_EXT +#pragma pack(push, 8) +#else +#pragma pack(8) +#endif +#undef PRAGMA_PACK_PUSH8 +#endif + +#ifdef PRAGMA_PACK_PUSH16 +#ifdef WINPR_PRAGMA_PACK_EXT +#pragma pack(push, 16) +#else +#pragma pack(16) +#endif +#undef PRAGMA_PACK_PUSH16 +#endif + +#ifdef PRAGMA_PACK_POP +#ifdef WINPR_PRAGMA_PACK_EXT +#pragma pack(pop) +#else +#pragma pack() +#endif +#undef PRAGMA_PACK_POP +#endif + +#undef WINPR_PRAGMA_PACK_EXT diff --git a/winpr/include/winpr/path.h b/winpr/include/winpr/path.h new file mode 100644 index 0000000..4554f49 --- /dev/null +++ b/winpr/include/winpr/path.h @@ -0,0 +1,356 @@ +/** + * WinPR: Windows Portable Runtime + * Path Functions + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_PATH_H +#define WINPR_PATH_H + +#include <winpr/winpr.h> +#include <winpr/tchar.h> +#include <winpr/error.h> +#include <winpr/wtypes.h> + +//#define WINPR_HAVE_PATHCCH_H 1 + +#ifdef WINPR_HAVE_PATHCCH_H + +#include <Pathcch.h> + +#else + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define PATHCCH_ALLOW_LONG_PATHS \ + 0x00000001 /* Allow building of \\?\ paths if longer than MAX_PATH */ + +#define VOLUME_PREFIX _T("\\\\?\\Volume") +#define VOLUME_PREFIX_LEN ((sizeof(VOLUME_PREFIX) / sizeof(TCHAR)) - 1) + + /* + * Maximum number of characters we support using the "\\?\" syntax + * (0x7FFF + 1 for NULL terminator) + */ + +#define PATHCCH_MAX_CCH 0x8000 + + WINPR_API HRESULT PathCchAddBackslashA(PSTR pszPath, size_t cchPath); + WINPR_API HRESULT PathCchAddBackslashW(PWSTR pszPath, size_t cchPath); + + WINPR_API HRESULT PathCchRemoveBackslashA(PSTR pszPath, size_t cchPath); + WINPR_API HRESULT PathCchRemoveBackslashW(PWSTR pszPath, size_t cchPath); + + WINPR_API HRESULT PathCchAddBackslashExA(PSTR pszPath, size_t cchPath, PSTR* ppszEnd, + size_t* pcchRemaining); + WINPR_API HRESULT PathCchAddBackslashExW(PWSTR pszPath, size_t cchPath, PWSTR* ppszEnd, + size_t* pcchRemaining); + + WINPR_API HRESULT PathCchRemoveBackslashExA(PSTR pszPath, size_t cchPath, PSTR* ppszEnd, + size_t* pcchRemaining); + WINPR_API HRESULT PathCchRemoveBackslashExW(PWSTR pszPath, size_t cchPath, PWSTR* ppszEnd, + size_t* pcchRemaining); + + WINPR_API HRESULT PathCchAddExtensionA(PSTR pszPath, size_t cchPath, PCSTR pszExt); + WINPR_API HRESULT PathCchAddExtensionW(PWSTR pszPath, size_t cchPath, PCWSTR pszExt); + + WINPR_API HRESULT PathCchAppendA(PSTR pszPath, size_t cchPath, PCSTR pszMore); + WINPR_API HRESULT PathCchAppendW(PWSTR pszPath, size_t cchPath, PCWSTR pszMore); + + WINPR_API HRESULT PathCchAppendExA(PSTR pszPath, size_t cchPath, PCSTR pszMore, + unsigned long dwFlags); + WINPR_API HRESULT PathCchAppendExW(PWSTR pszPath, size_t cchPath, PCWSTR pszMore, + unsigned long dwFlags); + + WINPR_API HRESULT PathCchCanonicalizeA(PSTR pszPathOut, size_t cchPathOut, PCSTR pszPathIn); + WINPR_API HRESULT PathCchCanonicalizeW(PWSTR pszPathOut, size_t cchPathOut, PCWSTR pszPathIn); + + WINPR_API HRESULT PathCchCanonicalizeExA(PSTR pszPathOut, size_t cchPathOut, PCSTR pszPathIn, + unsigned long dwFlags); + WINPR_API HRESULT PathCchCanonicalizeExW(PWSTR pszPathOut, size_t cchPathOut, PCWSTR pszPathIn, + unsigned long dwFlags); + + WINPR_API HRESULT PathAllocCanonicalizeA(PCSTR pszPathIn, unsigned long dwFlags, + PSTR* ppszPathOut); + WINPR_API HRESULT PathAllocCanonicalizeW(PCWSTR pszPathIn, unsigned long dwFlags, + PWSTR* ppszPathOut); + + WINPR_API HRESULT PathCchCombineA(PSTR pszPathOut, size_t cchPathOut, PCSTR pszPathIn, + PCSTR pszMore); + WINPR_API HRESULT PathCchCombineW(PWSTR pszPathOut, size_t cchPathOut, PCWSTR pszPathIn, + PCWSTR pszMore); + + WINPR_API HRESULT PathCchCombineExA(PSTR pszPathOut, size_t cchPathOut, PCSTR pszPathIn, + PCSTR pszMore, unsigned long dwFlags); + WINPR_API HRESULT PathCchCombineExW(PWSTR pszPathOut, size_t cchPathOut, PCWSTR pszPathIn, + PCWSTR pszMore, unsigned long dwFlags); + + WINPR_API HRESULT PathAllocCombineA(PCSTR pszPathIn, PCSTR pszMore, unsigned long dwFlags, + PSTR* ppszPathOut); + WINPR_API HRESULT PathAllocCombineW(PCWSTR pszPathIn, PCWSTR pszMore, unsigned long dwFlags, + PWSTR* ppszPathOut); + + WINPR_API HRESULT PathCchFindExtensionA(PCSTR pszPath, size_t cchPath, PCSTR* ppszExt); + WINPR_API HRESULT PathCchFindExtensionW(PCWSTR pszPath, size_t cchPath, PCWSTR* ppszExt); + + WINPR_API HRESULT PathCchRenameExtensionA(PSTR pszPath, size_t cchPath, PCSTR pszExt); + WINPR_API HRESULT PathCchRenameExtensionW(PWSTR pszPath, size_t cchPath, PCWSTR pszExt); + + WINPR_API HRESULT PathCchRemoveExtensionA(PSTR pszPath, size_t cchPath); + WINPR_API HRESULT PathCchRemoveExtensionW(PWSTR pszPath, size_t cchPath); + + WINPR_API BOOL PathCchIsRootA(PCSTR pszPath); + WINPR_API BOOL PathCchIsRootW(PCWSTR pszPath); + + WINPR_API BOOL PathIsUNCExA(PCSTR pszPath, PCSTR* ppszServer); + WINPR_API BOOL PathIsUNCExW(PCWSTR pszPath, PCWSTR* ppszServer); + + WINPR_API HRESULT PathCchSkipRootA(PCSTR pszPath, PCSTR* ppszRootEnd); + WINPR_API HRESULT PathCchSkipRootW(PCWSTR pszPath, PCWSTR* ppszRootEnd); + + WINPR_API HRESULT PathCchStripToRootA(PSTR pszPath, size_t cchPath); + WINPR_API HRESULT PathCchStripToRootW(PWSTR pszPath, size_t cchPath); + + WINPR_API HRESULT PathCchStripPrefixA(PSTR pszPath, size_t cchPath); + WINPR_API HRESULT PathCchStripPrefixW(PWSTR pszPath, size_t cchPath); + + WINPR_API HRESULT PathCchRemoveFileSpecA(PSTR pszPath, size_t cchPath); + WINPR_API HRESULT PathCchRemoveFileSpecW(PWSTR pszPath, size_t cchPath); + +#ifdef UNICODE +#define PathCchAddBackslash PathCchAddBackslashW +#define PathCchRemoveBackslash PathCchRemoveBackslashW +#define PathCchAddBackslashEx PathCchAddBackslashExW +#define PathCchRemoveBackslashEx PathCchRemoveBackslashExW +#define PathCchAddExtension PathCchAddExtensionW +#define PathCchAppend PathCchAppendW +#define PathCchAppendEx PathCchAppendExW +#define PathCchCanonicalize PathCchCanonicalizeW +#define PathCchCanonicalizeEx PathCchCanonicalizeExW +#define PathAllocCanonicalize PathAllocCanonicalizeW +#define PathCchCombine PathCchCombineW +#define PathCchCombineEx PathCchCombineExW +#define PathAllocCombine PathAllocCombineW +#define PathCchFindExtension PathCchFindExtensionW +#define PathCchRenameExtension PathCchRenameExtensionW +#define PathCchRemoveExtension PathCchRemoveExtensionW +#define PathCchIsRoot PathCchIsRootW +#define PathIsUNCEx PathIsUNCExW +#define PathCchSkipRoot PathCchSkipRootW +#define PathCchStripToRoot PathCchStripToRootW +#define PathCchStripPrefix PathCchStripPrefixW +#define PathCchRemoveFileSpec PathCchRemoveFileSpecW +#else +#define PathCchAddBackslash PathCchAddBackslashA +#define PathCchRemoveBackslash PathCchRemoveBackslashA +#define PathCchAddBackslashEx PathCchAddBackslashExA +#define PathCchRemoveBackslashEx PathCchRemoveBackslashExA +#define PathCchAddExtension PathCchAddExtensionA +#define PathCchAppend PathCchAppendA +#define PathCchAppendEx PathCchAppendExA +#define PathCchCanonicalize PathCchCanonicalizeA +#define PathCchCanonicalizeEx PathCchCanonicalizeExA +#define PathAllocCanonicalize PathAllocCanonicalizeA +#define PathCchCombine PathCchCombineA +#define PathCchCombineEx PathCchCombineExA +#define PathAllocCombine PathAllocCombineA +#define PathCchFindExtension PathCchFindExtensionA +#define PathCchRenameExtension PathCchRenameExtensionA +#define PathCchRemoveExtension PathCchRemoveExtensionA +#define PathCchIsRoot PathCchIsRootA +#define PathIsUNCEx PathIsUNCExA +#define PathCchSkipRoot PathCchSkipRootA +#define PathCchStripToRoot PathCchStripToRootA +#define PathCchStripPrefix PathCchStripPrefixA +#define PathCchRemoveFileSpec PathCchRemoveFileSpecA +#endif + + /* Unix-style Paths */ + + WINPR_API HRESULT PathCchAddSlashA(PSTR pszPath, size_t cchPath); + WINPR_API HRESULT PathCchAddSlashW(PWSTR pszPath, size_t cchPath); + + WINPR_API HRESULT PathCchAddSlashExA(PSTR pszPath, size_t cchPath, PSTR* ppszEnd, + size_t* pcchRemaining); + WINPR_API HRESULT PathCchAddSlashExW(PWSTR pszPath, size_t cchPath, PWSTR* ppszEnd, + size_t* pcchRemaining); + + WINPR_API HRESULT UnixPathCchAddExtensionA(PSTR pszPath, size_t cchPath, PCSTR pszExt); + WINPR_API HRESULT UnixPathCchAddExtensionW(PWSTR pszPath, size_t cchPath, PCWSTR pszExt); + + WINPR_API HRESULT UnixPathCchAppendA(PSTR pszPath, size_t cchPath, PCSTR pszMore); + WINPR_API HRESULT UnixPathCchAppendW(PWSTR pszPath, size_t cchPath, PCWSTR pszMore); + + WINPR_API HRESULT UnixPathAllocCombineA(PCSTR pszPathIn, PCSTR pszMore, unsigned long dwFlags, + PSTR* ppszPathOut); + WINPR_API HRESULT UnixPathAllocCombineW(PCWSTR pszPathIn, PCWSTR pszMore, unsigned long dwFlags, + PWSTR* ppszPathOut); + +#ifdef UNICODE +#define PathCchAddSlash PathCchAddSlashW +#define PathCchAddSlashEx PathCchAddSlashExW +#define UnixPathCchAddExtension UnixPathCchAddExtensionW +#define UnixPathCchAppend UnixPathCchAppendW +#define UnixPathAllocCombine UnixPathAllocCombineW +#else +#define PathCchAddSlash PathCchAddSlashA +#define PathCchAddSlashEx PathCchAddSlashExA +#define UnixPathCchAddExtension UnixPathCchAddExtensionA +#define UnixPathCchAppend UnixPathCchAppendA +#define UnixPathAllocCombine UnixPathAllocCombineA +#endif + + /* Native-style Paths */ + + WINPR_API HRESULT PathCchAddSeparatorA(PSTR pszPath, size_t cchPath); + WINPR_API HRESULT PathCchAddSeparatorW(PWSTR pszPath, size_t cchPath); + + WINPR_API HRESULT PathCchAddSeparatorExA(PSTR pszPath, size_t cchPath, PSTR* ppszEnd, + size_t* pcchRemaining); + WINPR_API HRESULT PathCchAddSeparatorExW(PWSTR pszPath, size_t cchPath, PWSTR* ppszEnd, + size_t* pcchRemaining); + + WINPR_API HRESULT NativePathCchAddExtensionA(PSTR pszPath, size_t cchPath, PCSTR pszExt); + WINPR_API HRESULT NativePathCchAddExtensionW(PWSTR pszPath, size_t cchPath, PCWSTR pszExt); + + WINPR_API HRESULT NativePathCchAppendA(PSTR pszPath, size_t cchPath, PCSTR pszMore); + WINPR_API HRESULT NativePathCchAppendW(PWSTR pszPath, size_t cchPath, PCWSTR pszMore); + + WINPR_API HRESULT NativePathAllocCombineA(PCSTR pszPathIn, PCSTR pszMore, unsigned long dwFlags, + PSTR* ppszPathOut); + WINPR_API HRESULT NativePathAllocCombineW(PCWSTR pszPathIn, PCWSTR pszMore, + unsigned long dwFlags, PWSTR* ppszPathOut); + +#ifdef UNICODE +#define PathCchAddSeparator PathCchAddSeparatorW +#define PathCchAddSeparatorEx PathCchAddSeparatorExW +#define NativePathCchAddExtension NativePathCchAddExtensionW +#define NativePathCchAppend NativePathCchAppendW +#define NativePathAllocCombine NativePathAllocCombineW +#else +#define PathCchAddSeparator PathCchAddSeparatorA +#define PathCchAddSeparatorEx PathCchAddSeparatorExA +#define NativePathCchAddExtension NativePathCchAddExtensionA +#define NativePathCchAppend NativePathCchAppendA +#define NativePathAllocCombine NativePathAllocCombineA +#endif + + /* Path Portability Functions */ + +#define PATH_STYLE_WINDOWS 0x00000001 +#define PATH_STYLE_UNIX 0x00000002 +#define PATH_STYLE_NATIVE 0x00000003 + +#define PATH_SHARED_LIB_EXT_WITH_DOT 0x00000001 +#define PATH_SHARED_LIB_EXT_APPLE_SO 0x00000002 +#define PATH_SHARED_LIB_EXT_EXPLICIT 0x80000000 +#define PATH_SHARED_LIB_EXT_EXPLICIT_DLL 0x80000001 +#define PATH_SHARED_LIB_EXT_EXPLICIT_SO 0x80000002 +#define PATH_SHARED_LIB_EXT_EXPLICIT_DYLIB 0x80000003 + + WINPR_API HRESULT PathCchConvertStyleA(PSTR pszPath, size_t cchPath, unsigned long dwFlags); + WINPR_API HRESULT PathCchConvertStyleW(PWSTR pszPath, size_t cchPath, unsigned long dwFlags); + + WINPR_API char PathGetSeparatorA(unsigned long dwFlags); + WINPR_API WCHAR PathGetSeparatorW(unsigned long dwFlags); + + WINPR_API PCSTR PathGetSharedLibraryExtensionA(unsigned long dwFlags); + WINPR_API PCWSTR PathGetSharedLibraryExtensionW(unsigned long dwFlags); + +#ifdef UNICODE +#define PathCchConvertStyle PathCchConvertStyleW +#define PathGetSeparator PathGetSeparatorW +#define PathGetSharedLibraryExtension PathGetSharedLibraryExtensionW +#else +#define PathCchConvertStyle PathCchConvertStyleA +#define PathGetSeparator PathGetSeparatorW +#define PathGetSharedLibraryExtension PathGetSharedLibraryExtensionA +#endif + +#ifdef __cplusplus +} +#endif + +#endif + +/** + * Shell Path Functions + */ + +#define KNOWN_PATH_HOME 1 +#define KNOWN_PATH_TEMP 2 +#define KNOWN_PATH_XDG_DATA_HOME 3 +#define KNOWN_PATH_XDG_CONFIG_HOME 4 +#define KNOWN_PATH_XDG_CACHE_HOME 5 +#define KNOWN_PATH_XDG_RUNTIME_DIR 6 + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API const char* GetKnownPathIdString(int id); + WINPR_API char* GetKnownPath(int id); + WINPR_API char* GetKnownSubPath(int id, const char* path); + WINPR_API char* GetEnvironmentPath(char* name); + WINPR_API char* GetEnvironmentSubPath(char* name, const char* path); + WINPR_API char* GetCombinedPath(const char* basePath, const char* subPath); + + WINPR_API BOOL PathMakePathA(LPCSTR path, LPSECURITY_ATTRIBUTES lpAttributes); + WINPR_API BOOL PathMakePathW(LPCWSTR path, LPSECURITY_ATTRIBUTES lpAttributes); + +#if !defined(_WIN32) || defined(_UWP) + + WINPR_API BOOL PathIsRelativeA(LPCSTR pszPath); + WINPR_API BOOL PathIsRelativeW(LPCWSTR pszPath); + + WINPR_API BOOL PathFileExistsA(LPCSTR pszPath); + WINPR_API BOOL PathFileExistsW(LPCWSTR pszPath); + + WINPR_API BOOL PathIsDirectoryEmptyA(LPCSTR pszPath); + WINPR_API BOOL PathIsDirectoryEmptyW(LPCWSTR pszPath); + +#ifdef UNICODE +#define PathFileExists PathFileExistsW +#define PathIsDirectoryEmpty PathIsDirectoryEmptyW +#else +#define PathFileExists PathFileExistsA +#define PathIsDirectoryEmpty PathIsDirectoryEmptyA +#endif + +#endif + + WINPR_API BOOL winpr_MoveFile(LPCSTR lpExistingFileName, LPCSTR lpNewFileName); + WINPR_API BOOL winpr_MoveFileEx(LPCSTR lpExistingFileName, LPCSTR lpNewFileName, DWORD dwFlags); + WINPR_API BOOL winpr_DeleteFile(const char* lpFileName); + WINPR_API BOOL winpr_RemoveDirectory(LPCSTR lpPathName); + WINPR_API BOOL winpr_RemoveDirectory_RecursiveA(LPCSTR lpPathName); + WINPR_API BOOL winpr_RemoveDirectory_RecursiveW(LPCWSTR lpPathName); + WINPR_API BOOL winpr_PathFileExists(const char* pszPath); + WINPR_API BOOL winpr_PathMakePath(const char* path, LPSECURITY_ATTRIBUTES lpAttributes); + +#ifdef __cplusplus +} +#endif + +#ifdef _WIN32 +#include <shlwapi.h> +#endif + +#endif /* WINPR_PATH_H */ diff --git a/winpr/include/winpr/pipe.h b/winpr/include/winpr/pipe.h new file mode 100644 index 0000000..932fda5 --- /dev/null +++ b/winpr/include/winpr/pipe.h @@ -0,0 +1,127 @@ +/** + * WinPR: Windows Portable Runtime + * Pipe Functions + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_PIPE_H +#define WINPR_PIPE_H + +#include <winpr/file.h> +#include <winpr/winpr.h> +#include <winpr/error.h> +#include <winpr/handle.h> +#include <winpr/wtypes.h> + +#ifndef _WIN32 + +#define PIPE_UNLIMITED_INSTANCES 0xFF + +#define PIPE_ACCESS_INBOUND 0x00000001 +#define PIPE_ACCESS_OUTBOUND 0x00000002 +#define PIPE_ACCESS_DUPLEX 0x00000003 + +#define FILE_FLAG_FIRST_PIPE_INSTANCE 0x00080000 +#define FILE_FLAG_WRITE_THROUGH 0x80000000 +#define FILE_FLAG_OVERLAPPED 0x40000000 + +#define PIPE_CLIENT_END 0x00000000 +#define PIPE_SERVER_END 0x00000001 + +#define PIPE_TYPE_BYTE 0x00000000 +#define PIPE_TYPE_MESSAGE 0x00000004 + +#define PIPE_READMODE_BYTE 0x00000000 +#define PIPE_READMODE_MESSAGE 0x00000002 + +#define PIPE_WAIT 0x00000000 +#define PIPE_NOWAIT 0x00000001 + +#define PIPE_ACCEPT_REMOTE_CLIENTS 0x00000000 +#define PIPE_REJECT_REMOTE_CLIENTS 0x00000008 + +#define NMPWAIT_USE_DEFAULT_WAIT 0x00000000 +#define NMPWAIT_NOWAIT 0x00000001 +#define NMPWAIT_WAIT_FOREVER 0xFFFFFFFF + +#ifdef __cplusplus +extern "C" +{ +#endif + + /** + * Unnamed pipe + */ + + WINPR_API BOOL CreatePipe(PHANDLE hReadPipe, PHANDLE hWritePipe, + LPSECURITY_ATTRIBUTES lpPipeAttributes, DWORD nSize); + + /** + * Named pipe + */ + + WINPR_API HANDLE CreateNamedPipeA(LPCSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, + DWORD nMaxInstances, DWORD nOutBufferSize, + DWORD nInBufferSize, DWORD nDefaultTimeOut, + LPSECURITY_ATTRIBUTES lpSecurityAttributes); + WINPR_API HANDLE CreateNamedPipeW(LPCWSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, + DWORD nMaxInstances, DWORD nOutBufferSize, + DWORD nInBufferSize, DWORD nDefaultTimeOut, + LPSECURITY_ATTRIBUTES lpSecurityAttributes); + + WINPR_API BOOL ConnectNamedPipe(HANDLE hNamedPipe, LPOVERLAPPED lpOverlapped); + + WINPR_API BOOL DisconnectNamedPipe(HANDLE hNamedPipe); + + WINPR_API BOOL PeekNamedPipe(HANDLE hNamedPipe, LPVOID lpBuffer, DWORD nBufferSize, + LPDWORD lpBytesRead, LPDWORD lpTotalBytesAvail, + LPDWORD lpBytesLeftThisMessage); + + WINPR_API BOOL TransactNamedPipe(HANDLE hNamedPipe, LPVOID lpInBuffer, DWORD nInBufferSize, + LPVOID lpOutBuffer, DWORD nOutBufferSize, LPDWORD lpBytesRead, + LPOVERLAPPED lpOverlapped); + + WINPR_API BOOL WaitNamedPipeA(LPCSTR lpNamedPipeName, DWORD nTimeOut); + WINPR_API BOOL WaitNamedPipeW(LPCWSTR lpNamedPipeName, DWORD nTimeOut); + + WINPR_API BOOL SetNamedPipeHandleState(HANDLE hNamedPipe, LPDWORD lpMode, + LPDWORD lpMaxCollectionCount, + LPDWORD lpCollectDataTimeout); + + WINPR_API BOOL ImpersonateNamedPipeClient(HANDLE hNamedPipe); + + WINPR_API BOOL GetNamedPipeClientComputerNameA(HANDLE Pipe, LPCSTR ClientComputerName, + ULONG ClientComputerNameLength); + WINPR_API BOOL GetNamedPipeClientComputerNameW(HANDLE Pipe, LPCWSTR ClientComputerName, + ULONG ClientComputerNameLength); + +#ifdef UNICODE +#define CreateNamedPipe CreateNamedPipeW +#define WaitNamedPipe WaitNamedPipeW +#define GetNamedPipeClientComputerName GetNamedPipeClientComputerNameW +#else +#define CreateNamedPipe CreateNamedPipeA +#define WaitNamedPipe WaitNamedPipeA +#define GetNamedPipeClientComputerName GetNamedPipeClientComputerNameA +#endif + +#ifdef __cplusplus +} +#endif + +#endif + +#endif /* WINPR_PIPE_H */ diff --git a/winpr/include/winpr/platform.h b/winpr/include/winpr/platform.h new file mode 100644 index 0000000..00f9d22 --- /dev/null +++ b/winpr/include/winpr/platform.h @@ -0,0 +1,352 @@ +/** + * WinPR: Windows Portable Runtime + * Platform-Specific Definitions + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_PLATFORM_H +#define WINPR_PLATFORM_H + +#include <stdlib.h> + +#if defined(__clang__) +#define WINPR_PRAGMA_DIAG_PUSH _Pragma("clang diagnostic push") +#define WINPR_PRAGMA_DIAG_IGNORED_PEDANTIC _Pragma("clang diagnostic ignored \"-Wpedantic\"") +#define WINPR_PRAGMA_DIAG_IGNORED_MISSING_PROTOTYPES \ + _Pragma("clang diagnostic ignored \"-Wmissing-prototypes\"") +#define WINPR_PRAGMA_DIAG_IGNORED_STRICT_PROTOTYPES \ + _Pragma("clang diagnostic ignored \"-Wstrict-prototypes\"") +#define WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO \ + _Pragma("clang diagnostic ignored \"-Wreserved-id-macro\"") +#define WINPR_PRAGMA_DIAG_IGNORED_ATOMIC_SEQ_CST \ + _Pragma("clang diagnostic ignored \"-Watomic-implicit-seq-cst\"") +#define WINPR_PRAGMA_DIAG_IGNORED_UNUSED_CONST_VAR \ + _Pragma("clang diagnostic ignored \"-Wunused-const-variable\"") +#define WINPR_PRAGMA_DIAG_IGNORED_FORMAT_SECURITY \ + _Pragma("clang diagnostic ignored \"-Wformat-security\"") +#define WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC \ + _Pragma("clang diagnostic ignored \"-Wmismatched-dealloc\"") +#define WINPR_PRAGMA_DIAG_POP _Pragma("clang diagnostic pop") +#elif defined(__GNUC__) +#define WINPR_PRAGMA_DIAG_PUSH _Pragma("GCC diagnostic push") +#define WINPR_PRAGMA_DIAG_IGNORED_PEDANTIC _Pragma("GCC diagnostic ignored \"-Wpedantic\"") +#define WINPR_PRAGMA_DIAG_IGNORED_MISSING_PROTOTYPES \ + _Pragma("GCC diagnostic ignored \"-Wmissing-prototypes\"") +#define WINPR_PRAGMA_DIAG_IGNORED_STRICT_PROTOTYPES \ + _Pragma("GCC diagnostic ignored \"-Wstrict-prototypes\"") +#define WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO /* not supported _Pragma("GCC diagnostic \ + ignored \"-Wreserved-id-macro\"") */ +#define WINPR_PRAGMA_DIAG_IGNORED_ATOMIC_SEQ_CST /* not supported _Pragma("GCC diagnostic \ + ignored \ + \"-Watomic-implicit-seq-cst\"") */ +#define WINPR_PRAGMA_DIAG_IGNORED_UNUSED_CONST_VAR \ + _Pragma("GCC diagnostic ignored \"-Wunused-const-variable\"") +#define WINPR_PRAGMA_DIAG_IGNORED_FORMAT_SECURITY \ + _Pragma("GCC diagnostic ignored \"-Wformat-security\"") +#define WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC \ + _Pragma("GCC diagnostic ignored \"-Wmismatched-dealloc\"") +#define WINPR_PRAGMA_DIAG_POP _Pragma("GCC diagnostic pop") +#else +#define WINPR_PRAGMA_DIAG_PUSH +#define WINPR_PRAGMA_DIAG_IGNORED_PEDANTIC +#define WINPR_PRAGMA_DIAG_IGNORED_MISSING_PROTOTYPES +#define WINPR_PRAGMA_DIAG_IGNORED_STRICT_PROTOTYPES +#define WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO +#define WINPR_PRAGMA_DIAG_IGNORED_ATOMIC_SEQ_CST +#define WINPR_PRAGMA_DIAG_IGNORED_UNUSED_CONST_VAR +#define WINPR_PRAGMA_DIAG_IGNORED_FORMAT_SECURITY +#define WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC +#define WINPR_PRAGMA_DIAG_POP +#endif + +WINPR_PRAGMA_DIAG_PUSH + +WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO + +/* + * Processor Architectures: + * http://sourceforge.net/p/predef/wiki/Architectures/ + * + * Visual Studio Predefined Macros: + * http://msdn.microsoft.com/en-ca/library/vstudio/b0084kay.aspx + */ + +/* Intel x86 (_M_IX86) */ + +#if defined(i386) || defined(__i386) || defined(__i386__) || defined(__i486__) || \ + defined(__i586__) || defined(__i686__) || defined(__X86__) || defined(_X86_) || \ + defined(__I86__) || defined(__IA32__) || defined(__THW_INTEL__) || defined(__INTEL__) +#ifndef _M_IX86 +#define _M_IX86 1 +#endif +#endif + +/* AMD64 (_M_AMD64) */ + +#if defined(__amd64) || defined(__amd64__) || defined(__x86_64) || defined(__x86_64__) || \ + defined(_M_X64) +#ifndef _M_AMD64 +#define _M_AMD64 1 +#endif +#endif + +/* Intel x86 or AMD64 (_M_IX86_AMD64) */ + +#if defined(_M_IX86) || defined(_M_AMD64) +#ifndef _M_IX86_AMD64 +#define _M_IX86_AMD64 1 +#endif +#endif + +/* ARM (_M_ARM) */ + +#if defined(__arm__) || defined(__thumb__) || defined(__TARGET_ARCH_ARM) || \ + defined(__TARGET_ARCH_THUMB) +#ifndef _M_ARM +#define _M_ARM 1 +#endif +#endif + +/* ARM64 (_M_ARM64) */ + +#if defined(__aarch64__) +#ifndef _M_ARM64 +#define _M_ARM64 1 +#endif +#endif + +/* MIPS (_M_MIPS) */ + +#if defined(mips) || defined(__mips) || defined(__mips__) || defined(__MIPS__) +#ifndef _M_MIPS +#define _M_MIPS 1 +#endif +#endif + +/* MIPS64 (_M_MIPS64) */ + +#if defined(mips64) || defined(__mips64) || defined(__mips64__) || defined(__MIPS64__) +#ifndef _M_MIPS64 +#define _M_MIPS64 1 +#endif +#endif + +/* PowerPC (_M_PPC) */ + +#if defined(__ppc__) || defined(__powerpc) || defined(__powerpc__) || defined(__POWERPC__) || \ + defined(_ARCH_PPC) +#ifndef _M_PPC +#define _M_PPC 1 +#endif +#endif + +/* Intel Itanium (_M_IA64) */ + +#if defined(__ia64) || defined(__ia64__) || defined(_IA64) || defined(__IA64__) +#ifndef _M_IA64 +#define _M_IA64 1 +#endif +#endif + +/* Alpha (_M_ALPHA) */ + +#if defined(__alpha) || defined(__alpha__) +#ifndef _M_ALPHA +#define _M_ALPHA 1 +#endif +#endif + +/* SPARC (_M_SPARC) */ + +#if defined(__sparc) || defined(__sparc__) +#ifndef _M_SPARC +#define _M_SPARC 1 +#endif +#endif + +/* E2K (_M_E2K) */ + +#if defined(__e2k__) +#ifndef _M_E2K +#define _M_E2K 1 +#endif +#endif + +/** + * Operating Systems: + * http://sourceforge.net/p/predef/wiki/OperatingSystems/ + */ + +/* Windows (_WIN32) */ + +/* WinRT (_WINRT) */ + +#if defined(WINAPI_FAMILY) +#if (WINAPI_FAMILY == WINAPI_FAMILY_APP) +#ifndef _WINRT +#define _WINRT 1 +#endif +#endif +#endif + +#if defined(__cplusplus_winrt) +#ifndef _WINRT +#define _WINRT 1 +#endif +#endif + +/* Linux (__linux__) */ + +#if defined(linux) || defined(__linux) +#ifndef __linux__ +#define __linux__ 1 +#endif +#endif + +/* GNU/Linux (__gnu_linux__) */ + +/* Apple Platforms (iOS, Mac OS X) */ + +#if (defined(__APPLE__) && defined(__MACH__)) + +#include <TargetConditionals.h> + +#if (TARGET_OS_IPHONE == 1) || (TARGET_IPHONE_SIMULATOR == 1) + +/* iOS (__IOS__) */ + +#ifndef __IOS__ +#define __IOS__ 1 +#endif + +#elif (TARGET_OS_MAC == 1) + +/* Mac OS X (__MACOSX__) */ + +#ifndef __MACOSX__ +#define __MACOSX__ 1 +#endif + +#endif +#endif + +/* Android (__ANDROID__) */ + +/* Cygwin (__CYGWIN__) */ + +/* FreeBSD (__FreeBSD__) */ + +/* NetBSD (__NetBSD__) */ + +/* OpenBSD (__OpenBSD__) */ + +/* DragonFly (__DragonFly__) */ + +/* Solaris (__sun) */ + +#if defined(sun) +#ifndef __sun +#define __sun 1 +#endif +#endif + +/* IRIX (__sgi) */ + +#if defined(sgi) +#ifndef __sgi +#define __sgi 1 +#endif +#endif + +/* AIX (_AIX) */ + +#if defined(__TOS_AIX__) +#ifndef _AIX +#define _AIX 1 +#endif +#endif + +/* HP-UX (__hpux) */ + +#if defined(hpux) || defined(_hpux) +#ifndef __hpux +#define __hpux 1 +#endif +#endif + +/* BeOS (__BEOS__) */ + +/* QNX (__QNXNTO__) */ + +/** + * Endianness: + * http://sourceforge.net/p/predef/wiki/Endianness/ + */ + +#if defined(__gnu_linux__) +#include <endian.h> +#endif + +#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \ + defined(__DragonFly__) || defined(__APPLE__) +#include <sys/param.h> +#endif + +/* Big-Endian */ + +#ifdef __BYTE_ORDER + +#if (__BYTE_ORDER == __BIG_ENDIAN) +#ifndef __BIG_ENDIAN__ +#define __BIG_ENDIAN__ 1 +#endif +#endif + +#else + +#if defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || defined(_MIPSEB) || \ + defined(__MIPSEB) || defined(__MIPSEB__) +#ifndef __BIG_ENDIAN__ +#define __BIG_ENDIAN__ 1 +#endif +#endif + +#endif /* __BYTE_ORDER */ + +/* Little-Endian */ + +#ifdef __BYTE_ORDER + +#if (__BYTE_ORDER == __LITTLE_ENDIAN) +#ifndef __LITTLE_ENDIAN__ +#define __LITTLE_ENDIAN__ 1 +#endif +#endif + +#else + +#if defined(__ARMEL__) || defined(__THUMBEL__) || defined(__AARCH64EL__) || defined(_MIPSEL) || \ + defined(__MIPSEL) || defined(__MIPSEL__) || defined(__e2k__) +#ifndef __LITTLE_ENDIAN__ +#define __LITTLE_ENDIAN__ 1 +#endif +#endif + +#endif /* __BYTE_ORDER */ + +WINPR_PRAGMA_DIAG_POP + +#endif /* WINPR_PLATFORM_H */ diff --git a/winpr/include/winpr/pool.h b/winpr/include/winpr/pool.h new file mode 100644 index 0000000..3160ae3 --- /dev/null +++ b/winpr/include/winpr/pool.h @@ -0,0 +1,282 @@ +/** + * WinPR: Windows Portable Runtime + * Thread Pool API + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_POOL_H +#define WINPR_POOL_H + +#include <winpr/winpr.h> +#include <winpr/wtypes.h> + +#include <winpr/synch.h> +#include <winpr/thread.h> + +#ifndef _WIN32 + +typedef DWORD TP_VERSION, *PTP_VERSION; + +typedef struct S_TP_CALLBACK_INSTANCE TP_CALLBACK_INSTANCE, *PTP_CALLBACK_INSTANCE; + +typedef VOID (*PTP_SIMPLE_CALLBACK)(PTP_CALLBACK_INSTANCE Instance, PVOID Context); + +typedef struct S_TP_POOL TP_POOL, *PTP_POOL; + +typedef struct +{ + SIZE_T StackReserve; + SIZE_T StackCommit; +} TP_POOL_STACK_INFORMATION, *PTP_POOL_STACK_INFORMATION; + +typedef struct S_TP_CLEANUP_GROUP TP_CLEANUP_GROUP, *PTP_CLEANUP_GROUP; + +typedef VOID (*PTP_CLEANUP_GROUP_CANCEL_CALLBACK)(PVOID ObjectContext, PVOID CleanupContext); + +typedef struct +{ + TP_VERSION Version; + PTP_POOL Pool; + PTP_CLEANUP_GROUP CleanupGroup; + PTP_CLEANUP_GROUP_CANCEL_CALLBACK CleanupGroupCancelCallback; + PVOID RaceDll; + PTP_SIMPLE_CALLBACK FinalizationCallback; + + union + { + DWORD Flags; + struct + { + DWORD LongFunction : 1; + DWORD Persistent : 1; + DWORD Private : 30; + } s; + } u; +} TP_CALLBACK_ENVIRON_V1; + +typedef TP_CALLBACK_ENVIRON_V1 TP_CALLBACK_ENVIRON, *PTP_CALLBACK_ENVIRON; + +typedef struct S_TP_WORK TP_WORK, *PTP_WORK; +typedef struct S_TP_TIMER TP_TIMER, *PTP_TIMER; + +typedef DWORD TP_WAIT_RESULT; +typedef struct S_TP_WAIT TP_WAIT, *PTP_WAIT; + +typedef struct S_TP_IO TP_IO, *PTP_IO; + +typedef VOID (*PTP_WORK_CALLBACK)(PTP_CALLBACK_INSTANCE Instance, PVOID Context, PTP_WORK Work); +typedef VOID (*PTP_TIMER_CALLBACK)(PTP_CALLBACK_INSTANCE Instance, PVOID Context, PTP_TIMER Timer); +typedef VOID (*PTP_WAIT_CALLBACK)(PTP_CALLBACK_INSTANCE Instance, PVOID Context, PTP_WAIT Wait, + TP_WAIT_RESULT WaitResult); + +#endif /* _WIN32 not defined */ + +/* +There is a bug in the Win8 header that defines the IO +callback unconditionally. Versions of Windows greater +than XP will conditionally define it. The following +logic tries to fix that. +*/ +#ifdef _THREADPOOLAPISET_H_ +#define PTP_WIN32_IO_CALLBACK_DEFINED 1 +#else +#if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0600) +#define PTP_WIN32_IO_CALLBACK_DEFINED 1 +#endif +#endif + +#ifndef PTP_WIN32_IO_CALLBACK_DEFINED + +typedef VOID (*PTP_WIN32_IO_CALLBACK)(PTP_CALLBACK_INSTANCE Instance, PVOID Context, + PVOID Overlapped, ULONG IoResult, + ULONG_PTR NumberOfBytesTransferred, PTP_IO Io); + +#endif + +#if !defined(_WIN32) +#define WINPR_THREAD_POOL 1 +#elif defined(_WIN32) && (_WIN32_WINNT < 0x0600) +#define WINPR_THREAD_POOL 1 +#elif defined(__MINGW32__) && (__MINGW64_VERSION_MAJOR < 8) +#define WINPR_THREAD_POOL 1 +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + + /* Synch */ + +#ifdef WINPR_THREAD_POOL + + WINPR_API PTP_WAIT winpr_CreateThreadpoolWait(PTP_WAIT_CALLBACK pfnwa, PVOID pv, + PTP_CALLBACK_ENVIRON pcbe); + WINPR_API VOID winpr_CloseThreadpoolWait(PTP_WAIT pwa); + WINPR_API VOID winpr_SetThreadpoolWait(PTP_WAIT pwa, HANDLE h, PFILETIME pftTimeout); + WINPR_API VOID winpr_WaitForThreadpoolWaitCallbacks(PTP_WAIT pwa, BOOL fCancelPendingCallbacks); + +#define CreateThreadpoolWait winpr_CreateThreadpoolWait +#define CloseThreadpoolWait winpr_CloseThreadpoolWait +#define SetThreadpoolWait winpr_SetThreadpoolWait +#define WaitForThreadpoolWaitCallbacks winpr_WaitForThreadpoolWaitCallbacks + + /* Work */ + + WINPR_API PTP_WORK winpr_CreateThreadpoolWork(PTP_WORK_CALLBACK pfnwk, PVOID pv, + PTP_CALLBACK_ENVIRON pcbe); + WINPR_API VOID winpr_CloseThreadpoolWork(PTP_WORK pwk); + WINPR_API VOID winpr_SubmitThreadpoolWork(PTP_WORK pwk); + WINPR_API BOOL winpr_TrySubmitThreadpoolCallback(PTP_SIMPLE_CALLBACK pfns, PVOID pv, + PTP_CALLBACK_ENVIRON pcbe); + WINPR_API VOID winpr_WaitForThreadpoolWorkCallbacks(PTP_WORK pwk, BOOL fCancelPendingCallbacks); + +#define CreateThreadpoolWork winpr_CreateThreadpoolWork +#define CloseThreadpoolWork winpr_CloseThreadpoolWork +#define SubmitThreadpoolWork winpr_SubmitThreadpoolWork +#define TrySubmitThreadpoolCallback winpr_TrySubmitThreadpoolCallback +#define WaitForThreadpoolWorkCallbacks winpr_WaitForThreadpoolWorkCallbacks + + /* Timer */ + + WINPR_API PTP_TIMER winpr_CreateThreadpoolTimer(PTP_TIMER_CALLBACK pfnti, PVOID pv, + PTP_CALLBACK_ENVIRON pcbe); + WINPR_API VOID winpr_CloseThreadpoolTimer(PTP_TIMER pti); + WINPR_API BOOL winpr_IsThreadpoolTimerSet(PTP_TIMER pti); + WINPR_API VOID winpr_SetThreadpoolTimer(PTP_TIMER pti, PFILETIME pftDueTime, DWORD msPeriod, + DWORD msWindowLength); + WINPR_API VOID winpr_WaitForThreadpoolTimerCallbacks(PTP_TIMER pti, + BOOL fCancelPendingCallbacks); + +#define CreateThreadpoolTimer winpr_CreateThreadpoolTimer +#define CloseThreadpoolTimer winpr_CloseThreadpoolTimer +#define IsThreadpoolTimerSet winpr_IsThreadpoolTimerSet +#define SetThreadpoolTimer winpr_SetThreadpoolTimer +#define WaitForThreadpoolTimerCallbacks winpr_WaitForThreadpoolTimerCallbacks + + /* I/O */ + + WINPR_API PTP_IO winpr_CreateThreadpoolIo(HANDLE fl, PTP_WIN32_IO_CALLBACK pfnio, PVOID pv, + PTP_CALLBACK_ENVIRON pcbe); + WINPR_API VOID winpr_CloseThreadpoolIo(PTP_IO pio); + WINPR_API VOID winpr_StartThreadpoolIo(PTP_IO pio); + WINPR_API VOID winpr_CancelThreadpoolIo(PTP_IO pio); + WINPR_API VOID winpr_WaitForThreadpoolIoCallbacks(PTP_IO pio, BOOL fCancelPendingCallbacks); + +#define CreateThreadpoolIo winpr_CreateThreadpoolIo +#define CloseThreadpoolIo winpr_CloseThreadpoolIo +#define StartThreadpoolIo winpr_StartThreadpoolIo +#define CancelThreadpoolIo winpr_CancelThreadpoolIo +#define WaitForThreadpoolIoCallbacks winpr_WaitForThreadpoolIoCallbacks + + /* Clean-up Group */ + + WINPR_API VOID winpr_SetThreadpoolCallbackCleanupGroup(PTP_CALLBACK_ENVIRON pcbe, + PTP_CLEANUP_GROUP ptpcg, + PTP_CLEANUP_GROUP_CANCEL_CALLBACK pfng); + WINPR_API PTP_CLEANUP_GROUP winpr_CreateThreadpoolCleanupGroup(void); + WINPR_API VOID winpr_CloseThreadpoolCleanupGroupMembers(PTP_CLEANUP_GROUP ptpcg, + BOOL fCancelPendingCallbacks, + PVOID pvCleanupContext); + WINPR_API VOID winpr_CloseThreadpoolCleanupGroup(PTP_CLEANUP_GROUP ptpcg); + +#define SetThreadpoolCallbackCleanupGroup winpr_SetThreadpoolCallbackCleanupGroup +#define CreateThreadpoolCleanupGroup winpr_CreateThreadpoolCleanupGroup +#define CloseThreadpoolCleanupGroupMembers winpr_CloseThreadpoolCleanupGroupMembers +#define CloseThreadpoolCleanupGroup winpr_CloseThreadpoolCleanupGroup + + /* Pool */ + + WINPR_API PTP_POOL winpr_CreateThreadpool(PVOID reserved); + WINPR_API VOID winpr_CloseThreadpool(PTP_POOL ptpp); + WINPR_API BOOL winpr_SetThreadpoolThreadMinimum(PTP_POOL ptpp, DWORD cthrdMic); + WINPR_API VOID winpr_SetThreadpoolThreadMaximum(PTP_POOL ptpp, DWORD cthrdMost); + +#define CreateThreadpool winpr_CreateThreadpool +#define CloseThreadpool winpr_CloseThreadpool +#define SetThreadpoolThreadMinimum winpr_SetThreadpoolThreadMinimum +#define SetThreadpoolThreadMaximum winpr_SetThreadpoolThreadMaximum + + /* Callback */ + + WINPR_API BOOL winpr_CallbackMayRunLong(PTP_CALLBACK_INSTANCE pci); + + /* Callback Clean-up */ + + WINPR_API VOID winpr_SetEventWhenCallbackReturns(PTP_CALLBACK_INSTANCE pci, HANDLE evt); + WINPR_API VOID winpr_ReleaseSemaphoreWhenCallbackReturns(PTP_CALLBACK_INSTANCE pci, HANDLE sem, + DWORD crel); + WINPR_API VOID winpr_ReleaseMutexWhenCallbackReturns(PTP_CALLBACK_INSTANCE pci, HANDLE mut); + WINPR_API VOID winpr_LeaveCriticalSectionWhenCallbackReturns(PTP_CALLBACK_INSTANCE pci, + PCRITICAL_SECTION pcs); + WINPR_API VOID winpr_FreeLibraryWhenCallbackReturns(PTP_CALLBACK_INSTANCE pci, HMODULE mod); + WINPR_API VOID winpr_DisassociateCurrentThreadFromCallback(PTP_CALLBACK_INSTANCE pci); + +#define SetEventWhenCallbackReturns winpr_SetEventWhenCallbackReturns +#define ReleaseSemaphoreWhenCallbackReturns winpr_ReleaseSemaphoreWhenCallbackReturns +#define ReleaseMutexWhenCallbackReturns winpr_ReleaseMutexWhenCallbackReturns +#define LeaveCriticalSectionWhenCallbackReturns winpr_LeaveCriticalSectionWhenCallbackReturns +#define FreeLibraryWhenCallbackReturns winpr_FreeLibraryWhenCallbackReturns +#define DisassociateCurrentThreadFromCallback winpr_DisassociateCurrentThreadFromCallback + +#endif /* WINPR_THREAD_POOL */ + +#if !defined(_WIN32) +#define WINPR_CALLBACK_ENVIRON 1 +#elif defined(_WIN32) && (_WIN32_WINNT < 0x0600) +#define WINPR_CALLBACK_ENVIRON 1 +#elif defined(__MINGW32__) && (__MINGW64_VERSION_MAJOR < 9) +#define WINPR_CALLBACK_ENVIRON 1 +#endif + +#ifdef WINPR_CALLBACK_ENVIRON + /* some version of mingw are missing Callback Environment functions */ + + /* Callback Environment */ + + static INLINE VOID InitializeThreadpoolEnvironment(PTP_CALLBACK_ENVIRON pcbe) + { + const TP_CALLBACK_ENVIRON empty = { 0 }; + *pcbe = empty; + pcbe->Version = 1; + } + + static INLINE VOID DestroyThreadpoolEnvironment(PTP_CALLBACK_ENVIRON pcbe) + { + /* no actions, this may change in a future release. */ + } + + static INLINE VOID SetThreadpoolCallbackPool(PTP_CALLBACK_ENVIRON pcbe, PTP_POOL ptpp) + { + pcbe->Pool = ptpp; + } + + static INLINE VOID SetThreadpoolCallbackRunsLong(PTP_CALLBACK_ENVIRON pcbe) + { + pcbe->u.s.LongFunction = 1; + } + + static INLINE VOID SetThreadpoolCallbackLibrary(PTP_CALLBACK_ENVIRON pcbe, PVOID mod) + { + pcbe->RaceDll = mod; + } +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* WINPR_POOL_H */ diff --git a/winpr/include/winpr/print.h b/winpr/include/winpr/print.h new file mode 100644 index 0000000..beb44f1 --- /dev/null +++ b/winpr/include/winpr/print.h @@ -0,0 +1,54 @@ +/** + * WinPR: Windows Portable Runtime + * Print Utils + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_UTILS_PRINT_H +#define WINPR_UTILS_PRINT_H + +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> + +#include <winpr/winpr.h> +#include <winpr/wtypes.h> +#include <winpr/wlog.h> + +#define WINPR_HEXDUMP_LINE_LENGTH 16 + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API void winpr_HexDump(const char* tag, UINT32 lvl, const void* data, size_t length); + WINPR_API void winpr_HexLogDump(wLog* log, UINT32 lvl, const void* data, size_t length); + WINPR_API void winpr_CArrayDump(const char* tag, UINT32 lvl, const void* data, size_t length, + size_t width); + + WINPR_API char* winpr_BinToHexString(const BYTE* data, size_t length, BOOL space); + WINPR_API size_t winpr_BinToHexStringBuffer(const BYTE* data, size_t length, char* dstStr, + size_t dstSize, BOOL space); + + WINPR_API size_t winpr_HexStringToBinBuffer(const char* str, size_t strLength, BYTE* data, + size_t dataLength); + +#ifdef __cplusplus +} +#endif + +#endif /* WINPR_UTILS_PRINT_H */ diff --git a/winpr/include/winpr/registry.h b/winpr/include/winpr/registry.h new file mode 100644 index 0000000..e596a39 --- /dev/null +++ b/winpr/include/winpr/registry.h @@ -0,0 +1,426 @@ +/** + * WinPR: Windows Portable Runtime + * Windows Registry + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_REGISTRY_H +#define WINPR_REGISTRY_H + +#include <winpr/windows.h> + +#if defined(_WIN32) && !defined(_UWP) + +#include <winreg.h> + +#else + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include <winpr/winpr.h> +#include <winpr/wtypes.h> + +#include <winpr/nt.h> +#include <winpr/io.h> +#include <winpr/error.h> + +#ifndef _WIN32 + +#define OWNER_SECURITY_INFORMATION 0x00000001 +#define GROUP_SECURITY_INFORMATION 0x00000002 +#define DACL_SECURITY_INFORMATION 0x00000004 +#define SACL_SECURITY_INFORMATION 0x00000008 + +#define REG_OPTION_RESERVED 0x00000000 +#define REG_OPTION_NON_VOLATILE 0x00000000 +#define REG_OPTION_VOLATILE 0x00000001 +#define REG_OPTION_CREATE_LINK 0x00000002 +#define REG_OPTION_BACKUP_RESTORE 0x00000004 +#define REG_OPTION_OPEN_LINK 0x00000008 + +#define REG_CREATED_NEW_KEY 0x00000001 +#define REG_OPENED_EXISTING_KEY 0x00000002 + +#define REG_NOTIFY_CHANGE_NAME 0x01 +#define REG_NOTIFY_CHANGE_ATTRIBUTES 0x02 +#define REG_NOTIFY_CHANGE_LAST_SET 0x04 +#define REG_NOTIFY_CHANGE_SECURITY 0x08 + +#define KEY_QUERY_VALUE 0x00000001 +#define KEY_SET_VALUE 0x00000002 +#define KEY_CREATE_SUB_KEY 0x00000004 +#define KEY_ENUMERATE_SUB_KEYS 0x00000008 +#define KEY_NOTIFY 0x00000010 +#define KEY_CREATE_LINK 0x00000020 +#define KEY_WOW64_64KEY 0x00000100 +#define KEY_WOW64_32KEY 0x00000200 +#define KEY_WOW64_RES 0x00000300 + +#define REG_WHOLE_HIVE_VOLATILE 0x00000001 +#define REG_REFRESH_HIVE 0x00000002 +#define REG_NO_LAZY_FLUSH 0x00000004 +#define REG_FORCE_RESTORE 0x00000008 + +#define KEY_READ \ + ((STANDARD_RIGHTS_READ | KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY) & \ + (~SYNCHRONIZE)) + +#define KEY_WRITE ((STANDARD_RIGHTS_WRITE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY) & (~SYNCHRONIZE)) + +#define KEY_EXECUTE ((KEY_READ) & (~SYNCHRONIZE)) + +#define KEY_ALL_ACCESS \ + ((STANDARD_RIGHTS_ALL | KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY | \ + KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY | KEY_CREATE_LINK) & \ + (~SYNCHRONIZE)) + + typedef enum + { + REG_NONE = 0, + REG_SZ = 1, + REG_EXPAND_SZ = 2, + REG_BINARY = 3, + REG_DWORD = 4, + REG_DWORD_LITTLE_ENDIAN = REG_DWORD, + REG_DWORD_BIG_ENDIAN = 5, + REG_LINK = 6, + REG_MULTI_SZ = 7, + REG_RESOURCE_LIST = 8, + REG_FULL_RESOURCE_DESCRIPTOR = 9, + REG_RESOURCE_REQUIREMENTS_LIST = 10, + REG_QWORD = 11, + REG_QWORD_LITTLE_ENDIAN = REG_QWORD + } eRegTypes; + + typedef HANDLE HKEY; + typedef HANDLE* PHKEY; + +#endif + + typedef ACCESS_MASK REGSAM; + +#define HKEY_CLASSES_ROOT ((HKEY)(LONG_PTR)(LONG)0x80000000) +#define HKEY_CURRENT_USER ((HKEY)(LONG_PTR)(LONG)0x80000001) +#define HKEY_LOCAL_MACHINE ((HKEY)(LONG_PTR)(LONG)0x80000002) +#define HKEY_USERS ((HKEY)(LONG_PTR)(LONG)0x80000003) +#define HKEY_PERFORMANCE_DATA ((HKEY)(LONG_PTR)(LONG)0x80000004) +#define HKEY_PERFORMANCE_TEXT ((HKEY)(LONG_PTR)(LONG)0x80000050) +#define HKEY_PERFORMANCE_NLSTEXT ((HKEY)(LONG_PTR)(LONG)0x80000060) +#define HKEY_CURRENT_CONFIG ((HKEY)(LONG_PTR)(LONG)0x80000005) +#define HKEY_DYN_DATA ((HKEY)(LONG_PTR)(LONG)0x80000006) +#define HKEY_CURRENT_USER_LOCAL_SETTINGS ((HKEY)(LONG_PTR)(LONG)0x80000007) + +#define RRF_RT_REG_NONE 0x00000001 +#define RRF_RT_REG_SZ 0x00000002 +#define RRF_RT_REG_EXPAND_SZ 0x00000004 +#define RRF_RT_REG_BINARY 0x00000008 +#define RRF_RT_REG_DWORD 0x00000010 +#define RRF_RT_REG_MULTI_SZ 0x00000020 +#define RRF_RT_REG_QWORD 0x00000040 + +#define RRF_RT_DWORD (RRF_RT_REG_BINARY | RRF_RT_REG_DWORD) +#define RRF_RT_QWORD (RRF_RT_REG_BINARY | RRF_RT_REG_QWORD) +#define RRF_RT_ANY 0x0000FFFF + +#define RRF_NOEXPAND 0x10000000 +#define RRF_ZEROONFAILURE 0x20000000 + + struct val_context + { + int valuelen; + LPVOID value_context; + LPVOID val_buff_ptr; + }; + + typedef struct val_context* PVALCONTEXT; + + typedef struct pvalueA + { + LPSTR pv_valuename; + int pv_valuelen; + LPVOID pv_value_context; + DWORD pv_type; + } PVALUEA, *PPVALUEA; + + typedef struct pvalueW + { + LPWSTR pv_valuename; + int pv_valuelen; + LPVOID pv_value_context; + DWORD pv_type; + } PVALUEW, *PPVALUEW; + +#ifdef UNICODE + typedef PVALUEW PVALUE; + typedef PPVALUEW PPVALUE; +#else +typedef PVALUEA PVALUE; +typedef PPVALUEA PPVALUE; +#endif + + typedef struct value_entA + { + LPSTR ve_valuename; + DWORD ve_valuelen; + DWORD_PTR ve_valueptr; + DWORD ve_type; + } VALENTA, *PVALENTA; + + typedef struct value_entW + { + LPWSTR ve_valuename; + DWORD ve_valuelen; + DWORD_PTR ve_valueptr; + DWORD ve_type; + } VALENTW, *PVALENTW; + +#ifdef UNICODE + typedef VALENTW VALENT; + typedef PVALENTW PVALENT; +#else +typedef VALENTA VALENT; +typedef PVALENTA PVALENT; +#endif + + WINPR_API LONG RegCloseKey(HKEY hKey); + + WINPR_API LONG RegCopyTreeW(HKEY hKeySrc, LPCWSTR lpSubKey, HKEY hKeyDest); + WINPR_API LONG RegCopyTreeA(HKEY hKeySrc, LPCSTR lpSubKey, HKEY hKeyDest); + +#ifdef UNICODE +#define RegCopyTree RegCopyTreeW +#else +#define RegCopyTree RegCopyTreeA +#endif + + WINPR_API LONG RegCreateKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD Reserved, LPWSTR lpClass, + DWORD dwOptions, REGSAM samDesired, + LPSECURITY_ATTRIBUTES lpSecurityAttributes, PHKEY phkResult, + LPDWORD lpdwDisposition); + WINPR_API LONG RegCreateKeyExA(HKEY hKey, LPCSTR lpSubKey, DWORD Reserved, LPSTR lpClass, + DWORD dwOptions, REGSAM samDesired, + LPSECURITY_ATTRIBUTES lpSecurityAttributes, PHKEY phkResult, + LPDWORD lpdwDisposition); + +#ifdef UNICODE +#define RegCreateKeyEx RegCreateKeyExW +#else +#define RegCreateKeyEx RegCreateKeyExA +#endif + + WINPR_API LONG RegDeleteKeyExW(HKEY hKey, LPCWSTR lpSubKey, REGSAM samDesired, DWORD Reserved); + WINPR_API LONG RegDeleteKeyExA(HKEY hKey, LPCSTR lpSubKey, REGSAM samDesired, DWORD Reserved); + +#ifdef UNICODE +#define RegDeleteKeyEx RegDeleteKeyExW +#else +#define RegDeleteKeyEx RegDeleteKeyExA +#endif + + WINPR_API LONG RegDeleteTreeW(HKEY hKey, LPCWSTR lpSubKey); + WINPR_API LONG RegDeleteTreeA(HKEY hKey, LPCSTR lpSubKey); + +#ifdef UNICODE +#define RegDeleteTree RegDeleteTreeW +#else +#define RegDeleteTree RegDeleteTreeA +#endif + + WINPR_API LONG RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName); + WINPR_API LONG RegDeleteValueA(HKEY hKey, LPCSTR lpValueName); + +#ifdef UNICODE +#define RegDeleteValue RegDeleteValueW +#else +#define RegDeleteValue RegDeleteValueA +#endif + + WINPR_API LONG RegDisablePredefinedCacheEx(void); + + WINPR_API LONG RegEnumKeyExW(HKEY hKey, DWORD dwIndex, LPWSTR lpName, LPDWORD lpcName, + LPDWORD lpReserved, LPWSTR lpClass, LPDWORD lpcClass, + PFILETIME lpftLastWriteTime); + WINPR_API LONG RegEnumKeyExA(HKEY hKey, DWORD dwIndex, LPSTR lpName, LPDWORD lpcName, + LPDWORD lpReserved, LPSTR lpClass, LPDWORD lpcClass, + PFILETIME lpftLastWriteTime); + +#ifdef UNICODE +#define RegEnumKeyEx RegEnumKeyExW +#else +#define RegEnumKeyEx RegEnumKeyExA +#endif + + WINPR_API LONG RegEnumValueW(HKEY hKey, DWORD dwIndex, LPWSTR lpValueName, + LPDWORD lpcchValueName, LPDWORD lpReserved, LPDWORD lpType, + LPBYTE lpData, LPDWORD lpcbData); + WINPR_API LONG RegEnumValueA(HKEY hKey, DWORD dwIndex, LPSTR lpValueName, + LPDWORD lpcchValueName, LPDWORD lpReserved, LPDWORD lpType, + LPBYTE lpData, LPDWORD lpcbData); + +#ifdef UNICODE +#define RegEnumValue RegEnumValueW +#else +#define RegEnumValue RegEnumValueA +#endif + + WINPR_API LONG RegFlushKey(HKEY hKey); + + WINPR_API LONG RegGetKeySecurity(HKEY hKey, SECURITY_INFORMATION SecurityInformation, + PSECURITY_DESCRIPTOR pSecurityDescriptor, + LPDWORD lpcbSecurityDescriptor); + + WINPR_API LONG RegGetValueW(HKEY hkey, LPCWSTR lpSubKey, LPCWSTR lpValue, DWORD dwFlags, + LPDWORD pdwType, PVOID pvData, LPDWORD pcbData); + WINPR_API LONG RegGetValueA(HKEY hkey, LPCSTR lpSubKey, LPCSTR lpValue, DWORD dwFlags, + LPDWORD pdwType, PVOID pvData, LPDWORD pcbData); + +#ifdef UNICODE +#define RegGetValue RegGetValueW +#else +#define RegGetValue RegGetValueA +#endif + + WINPR_API LONG RegLoadAppKeyW(LPCWSTR lpFile, PHKEY phkResult, REGSAM samDesired, + DWORD dwOptions, DWORD Reserved); + WINPR_API LONG RegLoadAppKeyA(LPCSTR lpFile, PHKEY phkResult, REGSAM samDesired, + DWORD dwOptions, DWORD Reserved); + +#ifdef UNICODE +#define RegLoadAppKey RegLoadAppKeyW +#else +#define RegLoadAppKey RegLoadAppKeyA +#endif + + WINPR_API LONG RegLoadKeyW(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpFile); + WINPR_API LONG RegLoadKeyA(HKEY hKey, LPCSTR lpSubKey, LPCSTR lpFile); + +#ifdef UNICODE +#define RegLoadKey RegLoadKeyW +#else +#define RegLoadKey RegLoadKeyA +#endif + + WINPR_API LONG RegLoadMUIStringW(HKEY hKey, LPCWSTR pszValue, LPWSTR pszOutBuf, DWORD cbOutBuf, + LPDWORD pcbData, DWORD Flags, LPCWSTR pszDirectory); + WINPR_API LONG RegLoadMUIStringA(HKEY hKey, LPCSTR pszValue, LPSTR pszOutBuf, DWORD cbOutBuf, + LPDWORD pcbData, DWORD Flags, LPCSTR pszDirectory); + +#ifdef UNICODE +#define RegLoadMUIString RegLoadMUIStringW +#else +#define RegLoadMUIString RegLoadMUIStringA +#endif + + WINPR_API LONG RegNotifyChangeKeyValue(HKEY hKey, BOOL bWatchSubtree, DWORD dwNotifyFilter, + HANDLE hEvent, BOOL fAsynchronous); + + WINPR_API LONG RegOpenCurrentUser(REGSAM samDesired, PHKEY phkResult); + + WINPR_API LONG RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, + PHKEY phkResult); + WINPR_API LONG RegOpenKeyExA(HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, + PHKEY phkResult); + +#ifdef UNICODE +#define RegOpenKeyEx RegOpenKeyExW +#else +#define RegOpenKeyEx RegOpenKeyExA +#endif + + WINPR_API LONG RegOpenUserClassesRoot(HANDLE hToken, DWORD dwOptions, REGSAM samDesired, + PHKEY phkResult); + + WINPR_API LONG RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, + LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, + LPDWORD lpcMaxClassLen, LPDWORD lpcValues, + LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, + LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime); + WINPR_API LONG RegQueryInfoKeyA(HKEY hKey, LPSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, + LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, + LPDWORD lpcMaxClassLen, LPDWORD lpcValues, + LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, + LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime); + +#ifdef UNICODE +#define RegQueryInfoKey RegQueryInfoKeyW +#else +#define RegQueryInfoKey RegQueryInfoKeyA +#endif + + WINPR_API LONG RegQueryValueExW(HKEY hKey, LPCWSTR lpValueName, LPDWORD lpReserved, + LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData); + WINPR_API LONG RegQueryValueExA(HKEY hKey, LPCSTR lpValueName, LPDWORD lpReserved, + LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData); + +#ifdef UNICODE +#define RegQueryValueEx RegQueryValueExW +#else +#define RegQueryValueEx RegQueryValueExA +#endif + + WINPR_API LONG RegRestoreKeyW(HKEY hKey, LPCWSTR lpFile, DWORD dwFlags); + WINPR_API LONG RegRestoreKeyA(HKEY hKey, LPCSTR lpFile, DWORD dwFlags); + +#ifdef UNICODE +#define RegRestoreKey RegRestoreKeyW +#else +#define RegRestoreKey RegRestoreKeyA +#endif + + WINPR_API LONG RegSaveKeyExW(HKEY hKey, LPCWSTR lpFile, + LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD Flags); + WINPR_API LONG RegSaveKeyExA(HKEY hKey, LPCSTR lpFile, + LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD Flags); + +#ifdef UNICODE +#define RegSaveKeyEx RegSaveKeyExW +#else +#define RegSaveKeyEx RegSaveKeyExA +#endif + + WINPR_API LONG RegSetKeySecurity(HKEY hKey, SECURITY_INFORMATION SecurityInformation, + PSECURITY_DESCRIPTOR pSecurityDescriptor); + + WINPR_API LONG RegSetValueExW(HKEY hKey, LPCWSTR lpValueName, DWORD Reserved, DWORD dwType, + const BYTE* lpData, DWORD cbData); + WINPR_API LONG RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, + const BYTE* lpData, DWORD cbData); + +#ifdef UNICODE +#define RegSetValueEx RegSetValueExW +#else +#define RegSetValueEx RegSetValueExA +#endif + + WINPR_API LONG RegUnLoadKeyW(HKEY hKey, LPCWSTR lpSubKey); + WINPR_API LONG RegUnLoadKeyA(HKEY hKey, LPCSTR lpSubKey); + +#ifdef UNICODE +#define RegUnLoadKey RegUnLoadKeyW +#else +#define RegUnLoadKey RegUnLoadKeyA +#endif + +#ifdef __cplusplus +} +#endif + +#endif + +#endif /* WINPR_REGISTRY_H */ diff --git a/winpr/include/winpr/rpc.h b/winpr/include/winpr/rpc.h new file mode 100644 index 0000000..4bfb3af --- /dev/null +++ b/winpr/include/winpr/rpc.h @@ -0,0 +1,725 @@ +/** + * WinPR: Windows Portable Runtime + * Microsoft Remote Procedure Call (MSRPC) + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_RPC_H +#define WINPR_RPC_H + +#include <winpr/wtypes.h> + +typedef struct +{ + UINT32 ContextType; + GUID ContextUuid; +} CONTEXT_HANDLE; + +typedef PCONTEXT_HANDLE PTUNNEL_CONTEXT_HANDLE_NOSERIALIZE; +typedef PCONTEXT_HANDLE PTUNNEL_CONTEXT_HANDLE_SERIALIZE; + +typedef PCONTEXT_HANDLE PCHANNEL_CONTEXT_HANDLE_NOSERIALIZE; +typedef PCONTEXT_HANDLE PCHANNEL_CONTEXT_HANDLE_SERIALIZE; + +#if defined(_WIN32) && !defined(_UWP) + +#include <rpc.h> + +#else + +#include <winpr/winpr.h> +#include <winpr/wtypes.h> +#include <winpr/sspi.h> +#include <winpr/spec.h> +#include <winpr/error.h> + +#define RPC_S_OK ERROR_SUCCESS +#define RPC_S_INVALID_ARG ERROR_INVALID_PARAMETER +#define RPC_S_OUT_OF_MEMORY ERROR_OUTOFMEMORY +#define RPC_S_OUT_OF_THREADS ERROR_MAX_THRDS_REACHED +#define RPC_S_INVALID_LEVEL ERROR_INVALID_PARAMETER +#define RPC_S_BUFFER_TOO_SMALL ERROR_INSUFFICIENT_BUFFER +#define RPC_S_INVALID_SECURITY_DESC ERROR_INVALID_SECURITY_DESCR +#define RPC_S_ACCESS_DENIED ERROR_ACCESS_DENIED +#define RPC_S_SERVER_OUT_OF_MEMORY ERROR_NOT_ENOUGH_SERVER_MEMORY +#define RPC_S_ASYNC_CALL_PENDING ERROR_IO_PENDING +#define RPC_S_UNKNOWN_PRINCIPAL ERROR_NONE_MAPPED +#define RPC_S_TIMEOUT ERROR_TIMEOUT + +#define RPC_X_NO_MEMORY RPC_S_OUT_OF_MEMORY +#define RPC_X_INVALID_BOUND RPC_S_INVALID_BOUND +#define RPC_X_INVALID_TAG RPC_S_INVALID_TAG +#define RPC_X_ENUM_VALUE_TOO_LARGE RPC_X_ENUM_VALUE_OUT_OF_RANGE +#define RPC_X_SS_CONTEXT_MISMATCH ERROR_INVALID_HANDLE +#define RPC_X_INVALID_BUFFER ERROR_INVALID_USER_BUFFER +#define RPC_X_PIPE_APP_MEMORY ERROR_OUTOFMEMORY +#define RPC_X_INVALID_PIPE_OPERATION RPC_X_WRONG_PIPE_ORDER + +#define RPC_VAR_ENTRY __cdecl + +typedef long RPC_STATUS; + +#ifndef _WIN32 +typedef CHAR* RPC_CSTR; +typedef WCHAR* RPC_WSTR; +#endif + +typedef void* I_RPC_HANDLE; +typedef I_RPC_HANDLE RPC_BINDING_HANDLE; +typedef RPC_BINDING_HANDLE handle_t; + +typedef struct +{ + unsigned long Count; + RPC_BINDING_HANDLE BindingH[1]; +} RPC_BINDING_VECTOR; +#define rpc_binding_vector_t RPC_BINDING_VECTOR + +typedef struct +{ + unsigned long Count; + UUID* Uuid[1]; +} UUID_VECTOR; +#define uuid_vector_t UUID_VECTOR + +typedef void* RPC_IF_HANDLE; + +typedef struct +{ + UUID Uuid; + unsigned short VersMajor; + unsigned short VersMinor; +} RPC_IF_ID; + +#define RPC_C_BINDING_INFINITE_TIMEOUT 10 +#define RPC_C_BINDING_MIN_TIMEOUT 0 +#define RPC_C_BINDING_DEFAULT_TIMEOUT 5 +#define RPC_C_BINDING_MAX_TIMEOUT 9 + +#define RPC_C_CANCEL_INFINITE_TIMEOUT -1 + +#define RPC_C_LISTEN_MAX_CALLS_DEFAULT 1234 +#define RPC_C_PROTSEQ_MAX_REQS_DEFAULT 10 + +#define RPC_C_BIND_TO_ALL_NICS 1 +#define RPC_C_USE_INTERNET_PORT 0x1 +#define RPC_C_USE_INTRANET_PORT 0x2 +#define RPC_C_DONT_FAIL 0x4 + +#define RPC_C_MQ_TEMPORARY 0x0000 +#define RPC_C_MQ_PERMANENT 0x0001 +#define RPC_C_MQ_CLEAR_ON_OPEN 0x0002 +#define RPC_C_MQ_USE_EXISTING_SECURITY 0x0004 +#define RPC_C_MQ_AUTHN_LEVEL_NONE 0x0000 +#define RPC_C_MQ_AUTHN_LEVEL_PKT_INTEGRITY 0x0008 +#define RPC_C_MQ_AUTHN_LEVEL_PKT_PRIVACY 0x0010 + +#define RPC_C_OPT_MQ_DELIVERY 1 +#define RPC_C_OPT_MQ_PRIORITY 2 +#define RPC_C_OPT_MQ_JOURNAL 3 +#define RPC_C_OPT_MQ_ACKNOWLEDGE 4 +#define RPC_C_OPT_MQ_AUTHN_SERVICE 5 +#define RPC_C_OPT_MQ_AUTHN_LEVEL 6 +#define RPC_C_OPT_MQ_TIME_TO_REACH_QUEUE 7 +#define RPC_C_OPT_MQ_TIME_TO_BE_RECEIVED 8 +#define RPC_C_OPT_BINDING_NONCAUSAL 9 +#define RPC_C_OPT_SECURITY_CALLBACK 10 +#define RPC_C_OPT_UNIQUE_BINDING 11 +#define RPC_C_OPT_CALL_TIMEOUT 12 +#define RPC_C_OPT_DONT_LINGER 13 +#define RPC_C_OPT_MAX_OPTIONS 14 + +#define RPC_C_MQ_EXPRESS 0 +#define RPC_C_MQ_RECOVERABLE 1 + +#define RPC_C_MQ_JOURNAL_NONE 0 +#define RPC_C_MQ_JOURNAL_DEADLETTER 1 +#define RPC_C_MQ_JOURNAL_ALWAYS 2 + +#define RPC_C_FULL_CERT_CHAIN 0x0001 + +typedef struct +{ + unsigned int Count; + unsigned char* Protseq[1]; +} RPC_PROTSEQ_VECTORA; + +typedef struct +{ + unsigned int Count; + unsigned short* Protseq[1]; +} RPC_PROTSEQ_VECTORW; + +#ifdef UNICODE +#define RPC_PROTSEQ_VECTOR RPC_PROTSEQ_VECTORW +#else +#define RPC_PROTSEQ_VECTOR RPC_PROTSEQ_VECTORA +#endif + +typedef struct +{ + unsigned int Length; + unsigned long EndpointFlags; + unsigned long NICFlags; +} RPC_POLICY, *PRPC_POLICY; + +typedef void RPC_OBJECT_INQ_FN(UUID* ObjectUuid, UUID* TypeUuid, RPC_STATUS* pStatus); +typedef RPC_STATUS RPC_IF_CALLBACK_FN(RPC_IF_HANDLE InterfaceUuid, void* Context); +typedef void RPC_SECURITY_CALLBACK_FN(void* Context); + +#define RPC_MGR_EPV void + +typedef struct +{ + unsigned int Count; + unsigned long Stats[1]; +} RPC_STATS_VECTOR; + +#define RPC_C_STATS_CALLS_IN 0 +#define RPC_C_STATS_CALLS_OUT 1 +#define RPC_C_STATS_PKTS_IN 2 +#define RPC_C_STATS_PKTS_OUT 3 + +typedef struct +{ + unsigned long Count; + RPC_IF_ID* IfId[1]; +} RPC_IF_ID_VECTOR; + +#ifndef _WIN32 + +typedef void* RPC_AUTH_IDENTITY_HANDLE; +typedef void* RPC_AUTHZ_HANDLE; + +#define RPC_C_AUTHN_LEVEL_DEFAULT 0 +#define RPC_C_AUTHN_LEVEL_NONE 1 +#define RPC_C_AUTHN_LEVEL_CONNECT 2 +#define RPC_C_AUTHN_LEVEL_CALL 3 +#define RPC_C_AUTHN_LEVEL_PKT 4 +#define RPC_C_AUTHN_LEVEL_PKT_INTEGRITY 5 +#define RPC_C_AUTHN_LEVEL_PKT_PRIVACY 6 + +#define RPC_C_IMP_LEVEL_DEFAULT 0 +#define RPC_C_IMP_LEVEL_ANONYMOUS 1 +#define RPC_C_IMP_LEVEL_IDENTIFY 2 +#define RPC_C_IMP_LEVEL_IMPERSONATE 3 +#define RPC_C_IMP_LEVEL_DELEGATE 4 + +#define RPC_C_QOS_IDENTITY_STATIC 0 +#define RPC_C_QOS_IDENTITY_DYNAMIC 1 + +#define RPC_C_QOS_CAPABILITIES_DEFAULT 0x0 +#define RPC_C_QOS_CAPABILITIES_MUTUAL_AUTH 0x1 +#define RPC_C_QOS_CAPABILITIES_MAKE_FULLSIC 0x2 +#define RPC_C_QOS_CAPABILITIES_ANY_AUTHORITY 0x4 +#define RPC_C_QOS_CAPABILITIES_IGNORE_DELEGATE_FAILURE 0x8 +#define RPC_C_QOS_CAPABILITIES_LOCAL_MA_HINT 0x10 + +#define RPC_C_PROTECT_LEVEL_DEFAULT (RPC_C_AUTHN_LEVEL_DEFAULT) +#define RPC_C_PROTECT_LEVEL_NONE (RPC_C_AUTHN_LEVEL_NONE) +#define RPC_C_PROTECT_LEVEL_CONNECT (RPC_C_AUTHN_LEVEL_CONNECT) +#define RPC_C_PROTECT_LEVEL_CALL (RPC_C_AUTHN_LEVEL_CALL) +#define RPC_C_PROTECT_LEVEL_PKT (RPC_C_AUTHN_LEVEL_PKT) +#define RPC_C_PROTECT_LEVEL_PKT_INTEGRITY (RPC_C_AUTHN_LEVEL_PKT_INTEGRITY) +#define RPC_C_PROTECT_LEVEL_PKT_PRIVACY (RPC_C_AUTHN_LEVEL_PKT_PRIVACY) + +#define RPC_C_AUTHN_NONE 0 +#define RPC_C_AUTHN_DCE_PRIVATE 1 +#define RPC_C_AUTHN_DCE_PUBLIC 2 +#define RPC_C_AUTHN_DEC_PUBLIC 4 +#define RPC_C_AUTHN_GSS_NEGOTIATE 9 +#define RPC_C_AUTHN_WINNT 10 +#define RPC_C_AUTHN_GSS_SCHANNEL 14 +#define RPC_C_AUTHN_GSS_KERBEROS 16 +#define RPC_C_AUTHN_DPA 17 +#define RPC_C_AUTHN_MSN 18 +#define RPC_C_AUTHN_DIGEST 21 +#define RPC_C_AUTHN_MQ 100 +#define RPC_C_AUTHN_DEFAULT 0xFFFFFFFFL + +#define RPC_C_NO_CREDENTIALS ((RPC_AUTH_IDENTITY_HANDLE)MAXUINT_PTR) + +#define RPC_C_SECURITY_QOS_VERSION 1L +#define RPC_C_SECURITY_QOS_VERSION_1 1L + +typedef struct +{ + unsigned long Version; + unsigned long Capabilities; + unsigned long IdentityTracking; + unsigned long ImpersonationType; +} RPC_SECURITY_QOS, *PRPC_SECURITY_QOS; + +#define RPC_C_SECURITY_QOS_VERSION_2 2L + +#define RPC_C_AUTHN_INFO_TYPE_HTTP 1 + +#define RPC_C_HTTP_AUTHN_TARGET_SERVER 1 +#define RPC_C_HTTP_AUTHN_TARGET_PROXY 2 + +#define RPC_C_HTTP_AUTHN_SCHEME_BASIC 0x00000001 +#define RPC_C_HTTP_AUTHN_SCHEME_NTLM 0x00000002 +#define RPC_C_HTTP_AUTHN_SCHEME_PASSPORT 0x00000004 +#define RPC_C_HTTP_AUTHN_SCHEME_DIGEST 0x00000008 +#define RPC_C_HTTP_AUTHN_SCHEME_NEGOTIATE 0x00000010 +#define RPC_C_HTTP_AUTHN_SCHEME_CERT 0x00010000 + +#define RPC_C_HTTP_FLAG_USE_SSL 1 +#define RPC_C_HTTP_FLAG_USE_FIRST_AUTH_SCHEME 2 +#define RPC_C_HTTP_FLAG_IGNORE_CERT_CN_INVALID 8 + +typedef struct +{ + SEC_WINNT_AUTH_IDENTITY_W* TransportCredentials; + unsigned long Flags; + unsigned long AuthenticationTarget; + unsigned long NumberOfAuthnSchemes; + unsigned long* AuthnSchemes; + unsigned short* ServerCertificateSubject; +} RPC_HTTP_TRANSPORT_CREDENTIALS_W, *PRPC_HTTP_TRANSPORT_CREDENTIALS_W; + +typedef struct +{ + SEC_WINNT_AUTH_IDENTITY_A* TransportCredentials; + unsigned long Flags; + unsigned long AuthenticationTarget; + unsigned long NumberOfAuthnSchemes; + unsigned long* AuthnSchemes; + unsigned char* ServerCertificateSubject; +} RPC_HTTP_TRANSPORT_CREDENTIALS_A, *PRPC_HTTP_TRANSPORT_CREDENTIALS_A; + +typedef struct +{ + unsigned long Version; + unsigned long Capabilities; + unsigned long IdentityTracking; + unsigned long ImpersonationType; + unsigned long AdditionalSecurityInfoType; + union + { + RPC_HTTP_TRANSPORT_CREDENTIALS_W* HttpCredentials; + } u; +} RPC_SECURITY_QOS_V2_W, *PRPC_SECURITY_QOS_V2_W; + +typedef struct +{ + unsigned long Version; + unsigned long Capabilities; + unsigned long IdentityTracking; + unsigned long ImpersonationType; + unsigned long AdditionalSecurityInfoType; + union + { + RPC_HTTP_TRANSPORT_CREDENTIALS_A* HttpCredentials; + } u; +} RPC_SECURITY_QOS_V2_A, *PRPC_SECURITY_QOS_V2_A; + +#define RPC_C_SECURITY_QOS_VERSION_3 3L + +typedef struct +{ + unsigned long Version; + unsigned long Capabilities; + unsigned long IdentityTracking; + unsigned long ImpersonationType; + unsigned long AdditionalSecurityInfoType; + union + { + RPC_HTTP_TRANSPORT_CREDENTIALS_W* HttpCredentials; + } u; + void* Sid; +} RPC_SECURITY_QOS_V3_W, *PRPC_SECURITY_QOS_V3_W; + +typedef struct +{ + unsigned long Version; + unsigned long Capabilities; + unsigned long IdentityTracking; + unsigned long ImpersonationType; + unsigned long AdditionalSecurityInfoType; + union + { + RPC_HTTP_TRANSPORT_CREDENTIALS_A* HttpCredentials; + } u; + void* Sid; +} RPC_SECURITY_QOS_V3_A, *PRPC_SECURITY_QOS_V3_A; + +typedef enum +{ + RPCHTTP_RS_REDIRECT = 1, + RPCHTTP_RS_ACCESS_1, + RPCHTTP_RS_SESSION, + RPCHTTP_RS_ACCESS_2, + RPCHTTP_RS_INTERFACE +} RPC_HTTP_REDIRECTOR_STAGE; + +typedef RPC_STATUS (*RPC_NEW_HTTP_PROXY_CHANNEL)( + RPC_HTTP_REDIRECTOR_STAGE RedirectorStage, unsigned short* ServerName, + unsigned short* ServerPort, unsigned short* RemoteUser, unsigned short* AuthType, + void* ResourceUuid, void* Metadata, void* SessionId, void* Interface, void* Reserved, + unsigned long Flags, unsigned short** NewServerName, unsigned short** NewServerPort); + +typedef void (*RPC_HTTP_PROXY_FREE_STRING)(unsigned short* String); + +#define RPC_C_AUTHZ_NONE 0 +#define RPC_C_AUTHZ_NAME 1 +#define RPC_C_AUTHZ_DCE 2 +#define RPC_C_AUTHZ_DEFAULT 0xFFFFFFFF + +#endif + +typedef void (*RPC_AUTH_KEY_RETRIEVAL_FN)(void* Arg, unsigned short* ServerPrincName, + unsigned long KeyVer, void** Key, RPC_STATUS* pStatus); + +#define DCE_C_ERROR_STRING_LEN 256 + +typedef I_RPC_HANDLE* RPC_EP_INQ_HANDLE; + +#define RPC_C_EP_ALL_ELTS 0 +#define RPC_C_EP_MATCH_BY_IF 1 +#define RPC_C_EP_MATCH_BY_OBJ 2 +#define RPC_C_EP_MATCH_BY_BOTH 3 + +#define RPC_C_VERS_ALL 1 +#define RPC_C_VERS_COMPATIBLE 2 +#define RPC_C_VERS_EXACT 3 +#define RPC_C_VERS_MAJOR_ONLY 4 +#define RPC_C_VERS_UPTO 5 + +typedef int (*RPC_MGMT_AUTHORIZATION_FN)(RPC_BINDING_HANDLE ClientBinding, + unsigned long RequestedMgmtOperation, RPC_STATUS* pStatus); + +#define RPC_C_MGMT_INQ_IF_IDS 0 +#define RPC_C_MGMT_INQ_PRINC_NAME 1 +#define RPC_C_MGMT_INQ_STATS 2 +#define RPC_C_MGMT_IS_SERVER_LISTEN 3 +#define RPC_C_MGMT_STOP_SERVER_LISTEN 4 + +#define RPC_C_PARM_MAX_PACKET_LENGTH 1 +#define RPC_C_PARM_BUFFER_LENGTH 2 + +#define RPC_IF_AUTOLISTEN 0x0001 +#define RPC_IF_OLE 0x0002 +#define RPC_IF_ALLOW_UNKNOWN_AUTHORITY 0x0004 +#define RPC_IF_ALLOW_SECURE_ONLY 0x0008 +#define RPC_IF_ALLOW_CALLBACKS_WITH_NO_AUTH 0x0010 +#define RPC_IF_ALLOW_LOCAL_ONLY 0x0020 +#define RPC_IF_SEC_NO_CACHE 0x0040 + +typedef struct +{ + unsigned long Version; + unsigned long Flags; + unsigned long ComTimeout; + unsigned long CallTimeout; +} RPC_BINDING_HANDLE_OPTIONS_V1, RPC_BINDING_HANDLE_OPTIONS; + +typedef struct +{ + unsigned long Version; + unsigned short* ServerPrincName; + unsigned long AuthnLevel; + unsigned long AuthnSvc; + SEC_WINNT_AUTH_IDENTITY* AuthIdentity; + RPC_SECURITY_QOS* SecurityQos; +} RPC_BINDING_HANDLE_SECURITY_V1, RPC_BINDING_HANDLE_SECURITY; + +typedef struct +{ + unsigned long Version; + unsigned long Flags; + unsigned long ProtocolSequence; + unsigned short* NetworkAddress; + unsigned short* StringEndpoint; + union + { + unsigned short* Reserved; + } u1; + UUID ObjectUuid; +} RPC_BINDING_HANDLE_TEMPLATE_V1, RPC_BINDING_HANDLE_TEMPLATE; + +#define RPC_CALL_STATUS_IN_PROGRESS 0x01 +#define RPC_CALL_STATUS_CANCELLED 0x02 +#define RPC_CALL_STATUS_DISCONNECTED 0x03 + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API RPC_STATUS RpcBindingCopy(RPC_BINDING_HANDLE SourceBinding, + RPC_BINDING_HANDLE* DestinationBinding); + WINPR_API RPC_STATUS RpcBindingFree(RPC_BINDING_HANDLE* Binding); + WINPR_API RPC_STATUS RpcBindingSetOption(RPC_BINDING_HANDLE hBinding, unsigned long option, + ULONG_PTR optionValue); + WINPR_API RPC_STATUS RpcBindingInqOption(RPC_BINDING_HANDLE hBinding, unsigned long option, + ULONG_PTR* pOptionValue); + WINPR_API RPC_STATUS RpcBindingFromStringBindingA(RPC_CSTR StringBinding, + RPC_BINDING_HANDLE* Binding); + WINPR_API RPC_STATUS RpcBindingFromStringBindingW(RPC_WSTR StringBinding, + RPC_BINDING_HANDLE* Binding); + WINPR_API RPC_STATUS RpcSsGetContextBinding(void* ContextHandle, RPC_BINDING_HANDLE* Binding); + WINPR_API RPC_STATUS RpcBindingInqObject(RPC_BINDING_HANDLE Binding, UUID* ObjectUuid); + WINPR_API RPC_STATUS RpcBindingReset(RPC_BINDING_HANDLE Binding); + WINPR_API RPC_STATUS RpcBindingSetObject(RPC_BINDING_HANDLE Binding, UUID* ObjectUuid); + WINPR_API RPC_STATUS RpcMgmtInqDefaultProtectLevel(unsigned long AuthnSvc, + unsigned long* AuthnLevel); + WINPR_API RPC_STATUS RpcBindingToStringBindingA(RPC_BINDING_HANDLE Binding, + RPC_CSTR* StringBinding); + WINPR_API RPC_STATUS RpcBindingToStringBindingW(RPC_BINDING_HANDLE Binding, + RPC_WSTR* StringBinding); + WINPR_API RPC_STATUS RpcBindingVectorFree(RPC_BINDING_VECTOR** BindingVector); + WINPR_API RPC_STATUS RpcStringBindingComposeA(RPC_CSTR ObjUuid, RPC_CSTR Protseq, + RPC_CSTR NetworkAddr, RPC_CSTR Endpoint, + RPC_CSTR Options, RPC_CSTR* StringBinding); + WINPR_API RPC_STATUS RpcStringBindingComposeW(RPC_WSTR ObjUuid, RPC_WSTR Protseq, + RPC_WSTR NetworkAddr, RPC_WSTR Endpoint, + RPC_WSTR Options, RPC_WSTR* StringBinding); + WINPR_API RPC_STATUS RpcStringBindingParseA(RPC_CSTR StringBinding, RPC_CSTR* ObjUuid, + RPC_CSTR* Protseq, RPC_CSTR* NetworkAddr, + RPC_CSTR* Endpoint, RPC_CSTR* NetworkOptions); + WINPR_API RPC_STATUS RpcStringBindingParseW(RPC_WSTR StringBinding, RPC_WSTR* ObjUuid, + RPC_WSTR* Protseq, RPC_WSTR* NetworkAddr, + RPC_WSTR* Endpoint, RPC_WSTR* NetworkOptions); + WINPR_API RPC_STATUS RpcStringFreeA(RPC_CSTR* String); + WINPR_API RPC_STATUS RpcStringFreeW(RPC_WSTR* String); + WINPR_API RPC_STATUS RpcIfInqId(RPC_IF_HANDLE RpcIfHandle, RPC_IF_ID* RpcIfId); + WINPR_API RPC_STATUS RpcNetworkIsProtseqValidA(RPC_CSTR Protseq); + WINPR_API RPC_STATUS RpcNetworkIsProtseqValidW(RPC_WSTR Protseq); + WINPR_API RPC_STATUS RpcMgmtInqComTimeout(RPC_BINDING_HANDLE Binding, unsigned int* Timeout); + WINPR_API RPC_STATUS RpcMgmtSetComTimeout(RPC_BINDING_HANDLE Binding, unsigned int Timeout); + WINPR_API RPC_STATUS RpcMgmtSetCancelTimeout(long Timeout); + WINPR_API RPC_STATUS RpcNetworkInqProtseqsA(RPC_PROTSEQ_VECTORA** ProtseqVector); + WINPR_API RPC_STATUS RpcNetworkInqProtseqsW(RPC_PROTSEQ_VECTORW** ProtseqVector); + WINPR_API RPC_STATUS RpcObjectInqType(UUID* ObjUuid, UUID* TypeUuid); + WINPR_API RPC_STATUS RpcObjectSetInqFn(RPC_OBJECT_INQ_FN* InquiryFn); + WINPR_API RPC_STATUS RpcObjectSetType(UUID* ObjUuid, UUID* TypeUuid); + WINPR_API RPC_STATUS RpcProtseqVectorFreeA(RPC_PROTSEQ_VECTORA** ProtseqVector); + WINPR_API RPC_STATUS RpcProtseqVectorFreeW(RPC_PROTSEQ_VECTORW** ProtseqVector); + WINPR_API RPC_STATUS RpcServerInqBindings(RPC_BINDING_VECTOR** BindingVector); + WINPR_API RPC_STATUS RpcServerInqIf(RPC_IF_HANDLE IfSpec, UUID* MgrTypeUuid, + RPC_MGR_EPV** MgrEpv); + WINPR_API RPC_STATUS RpcServerListen(unsigned int MinimumCallThreads, unsigned int MaxCalls, + unsigned int DontWait); + WINPR_API RPC_STATUS RpcServerRegisterIf(RPC_IF_HANDLE IfSpec, UUID* MgrTypeUuid, + RPC_MGR_EPV* MgrEpv); + WINPR_API RPC_STATUS RpcServerRegisterIfEx(RPC_IF_HANDLE IfSpec, UUID* MgrTypeUuid, + RPC_MGR_EPV* MgrEpv, unsigned int Flags, + unsigned int MaxCalls, + RPC_IF_CALLBACK_FN* IfCallback); + WINPR_API RPC_STATUS RpcServerRegisterIf2(RPC_IF_HANDLE IfSpec, UUID* MgrTypeUuid, + RPC_MGR_EPV* MgrEpv, unsigned int Flags, + unsigned int MaxCalls, unsigned int MaxRpcSize, + RPC_IF_CALLBACK_FN* IfCallbackFn); + WINPR_API RPC_STATUS RpcServerUnregisterIf(RPC_IF_HANDLE IfSpec, UUID* MgrTypeUuid, + unsigned int WaitForCallsToComplete); + WINPR_API RPC_STATUS RpcServerUnregisterIfEx(RPC_IF_HANDLE IfSpec, UUID* MgrTypeUuid, + int RundownContextHandles); + WINPR_API RPC_STATUS RpcServerUseAllProtseqs(unsigned int MaxCalls, void* SecurityDescriptor); + WINPR_API RPC_STATUS RpcServerUseAllProtseqsEx(unsigned int MaxCalls, void* SecurityDescriptor, + PRPC_POLICY Policy); + WINPR_API RPC_STATUS RpcServerUseAllProtseqsIf(unsigned int MaxCalls, RPC_IF_HANDLE IfSpec, + void* SecurityDescriptor); + WINPR_API RPC_STATUS RpcServerUseAllProtseqsIfEx(unsigned int MaxCalls, RPC_IF_HANDLE IfSpec, + void* SecurityDescriptor, PRPC_POLICY Policy); + WINPR_API RPC_STATUS RpcServerUseProtseqA(RPC_CSTR Protseq, unsigned int MaxCalls, + void* SecurityDescriptor); + WINPR_API RPC_STATUS RpcServerUseProtseqExA(RPC_CSTR Protseq, unsigned int MaxCalls, + void* SecurityDescriptor, PRPC_POLICY Policy); + WINPR_API RPC_STATUS RpcServerUseProtseqW(RPC_WSTR Protseq, unsigned int MaxCalls, + void* SecurityDescriptor); + WINPR_API RPC_STATUS RpcServerUseProtseqExW(RPC_WSTR Protseq, unsigned int MaxCalls, + void* SecurityDescriptor, PRPC_POLICY Policy); + WINPR_API RPC_STATUS RpcServerUseProtseqEpA(RPC_CSTR Protseq, unsigned int MaxCalls, + RPC_CSTR Endpoint, void* SecurityDescriptor); + WINPR_API RPC_STATUS RpcServerUseProtseqEpExA(RPC_CSTR Protseq, unsigned int MaxCalls, + RPC_CSTR Endpoint, void* SecurityDescriptor, + PRPC_POLICY Policy); + WINPR_API RPC_STATUS RpcServerUseProtseqEpW(RPC_WSTR Protseq, unsigned int MaxCalls, + RPC_WSTR Endpoint, void* SecurityDescriptor); + WINPR_API RPC_STATUS RpcServerUseProtseqEpExW(RPC_WSTR Protseq, unsigned int MaxCalls, + RPC_WSTR Endpoint, void* SecurityDescriptor, + PRPC_POLICY Policy); + WINPR_API RPC_STATUS RpcServerUseProtseqIfA(RPC_CSTR Protseq, unsigned int MaxCalls, + RPC_IF_HANDLE IfSpec, void* SecurityDescriptor); + WINPR_API RPC_STATUS RpcServerUseProtseqIfExA(RPC_CSTR Protseq, unsigned int MaxCalls, + RPC_IF_HANDLE IfSpec, void* SecurityDescriptor, + PRPC_POLICY Policy); + WINPR_API RPC_STATUS RpcServerUseProtseqIfW(RPC_WSTR Protseq, unsigned int MaxCalls, + RPC_IF_HANDLE IfSpec, void* SecurityDescriptor); + WINPR_API RPC_STATUS RpcServerUseProtseqIfExW(RPC_WSTR Protseq, unsigned int MaxCalls, + RPC_IF_HANDLE IfSpec, void* SecurityDescriptor, + PRPC_POLICY Policy); + WINPR_API void RpcServerYield(void); + WINPR_API RPC_STATUS RpcMgmtStatsVectorFree(RPC_STATS_VECTOR** StatsVector); + WINPR_API RPC_STATUS RpcMgmtInqStats(RPC_BINDING_HANDLE Binding, RPC_STATS_VECTOR** Statistics); + WINPR_API RPC_STATUS RpcMgmtIsServerListening(RPC_BINDING_HANDLE Binding); + WINPR_API RPC_STATUS RpcMgmtStopServerListening(RPC_BINDING_HANDLE Binding); + WINPR_API RPC_STATUS RpcMgmtWaitServerListen(void); + WINPR_API RPC_STATUS RpcMgmtSetServerStackSize(unsigned long ThreadStackSize); + WINPR_API void RpcSsDontSerializeContext(void); + WINPR_API RPC_STATUS RpcMgmtEnableIdleCleanup(void); + WINPR_API RPC_STATUS RpcMgmtInqIfIds(RPC_BINDING_HANDLE Binding, RPC_IF_ID_VECTOR** IfIdVector); + WINPR_API RPC_STATUS RpcIfIdVectorFree(RPC_IF_ID_VECTOR** IfIdVector); + WINPR_API RPC_STATUS RpcMgmtInqServerPrincNameA(RPC_BINDING_HANDLE Binding, + unsigned long AuthnSvc, + RPC_CSTR* ServerPrincName); + WINPR_API RPC_STATUS RpcMgmtInqServerPrincNameW(RPC_BINDING_HANDLE Binding, + unsigned long AuthnSvc, + RPC_WSTR* ServerPrincName); + WINPR_API RPC_STATUS RpcServerInqDefaultPrincNameA(unsigned long AuthnSvc, RPC_CSTR* PrincName); + WINPR_API RPC_STATUS RpcServerInqDefaultPrincNameW(unsigned long AuthnSvc, RPC_WSTR* PrincName); + WINPR_API RPC_STATUS RpcEpResolveBinding(RPC_BINDING_HANDLE Binding, RPC_IF_HANDLE IfSpec); + WINPR_API RPC_STATUS RpcNsBindingInqEntryNameA(RPC_BINDING_HANDLE Binding, + unsigned long EntryNameSyntax, + RPC_CSTR* EntryName); + WINPR_API RPC_STATUS RpcNsBindingInqEntryNameW(RPC_BINDING_HANDLE Binding, + unsigned long EntryNameSyntax, + RPC_WSTR* EntryName); + + WINPR_API RPC_STATUS RpcImpersonateClient(RPC_BINDING_HANDLE BindingHandle); + WINPR_API RPC_STATUS RpcRevertToSelfEx(RPC_BINDING_HANDLE BindingHandle); + WINPR_API RPC_STATUS RpcRevertToSelf(void); + WINPR_API RPC_STATUS RpcBindingInqAuthClientA(RPC_BINDING_HANDLE ClientBinding, + RPC_AUTHZ_HANDLE* Privs, + RPC_CSTR* ServerPrincName, + unsigned long* AuthnLevel, + unsigned long* AuthnSvc, unsigned long* AuthzSvc); + WINPR_API RPC_STATUS RpcBindingInqAuthClientW(RPC_BINDING_HANDLE ClientBinding, + RPC_AUTHZ_HANDLE* Privs, + RPC_WSTR* ServerPrincName, + unsigned long* AuthnLevel, + unsigned long* AuthnSvc, unsigned long* AuthzSvc); + WINPR_API RPC_STATUS RpcBindingInqAuthClientExA(RPC_BINDING_HANDLE ClientBinding, + RPC_AUTHZ_HANDLE* Privs, + RPC_CSTR* ServerPrincName, + unsigned long* AuthnLevel, + unsigned long* AuthnSvc, + unsigned long* AuthzSvc, unsigned long Flags); + WINPR_API RPC_STATUS RpcBindingInqAuthClientExW(RPC_BINDING_HANDLE ClientBinding, + RPC_AUTHZ_HANDLE* Privs, + RPC_WSTR* ServerPrincName, + unsigned long* AuthnLevel, + unsigned long* AuthnSvc, + unsigned long* AuthzSvc, unsigned long Flags); + WINPR_API RPC_STATUS RpcBindingInqAuthInfoA(RPC_BINDING_HANDLE Binding, + RPC_CSTR* ServerPrincName, + unsigned long* AuthnLevel, unsigned long* AuthnSvc, + RPC_AUTH_IDENTITY_HANDLE* AuthIdentity, + unsigned long* AuthzSvc); + WINPR_API RPC_STATUS RpcBindingInqAuthInfoW(RPC_BINDING_HANDLE Binding, + RPC_WSTR* ServerPrincName, + unsigned long* AuthnLevel, unsigned long* AuthnSvc, + RPC_AUTH_IDENTITY_HANDLE* AuthIdentity, + unsigned long* AuthzSvc); + WINPR_API RPC_STATUS RpcBindingSetAuthInfoA(RPC_BINDING_HANDLE Binding, + RPC_CSTR ServerPrincName, unsigned long AuthnLevel, + unsigned long AuthnSvc, + RPC_AUTH_IDENTITY_HANDLE AuthIdentity, + unsigned long AuthzSvc); + WINPR_API RPC_STATUS RpcBindingSetAuthInfoExA(RPC_BINDING_HANDLE Binding, + RPC_CSTR ServerPrincName, + unsigned long AuthnLevel, unsigned long AuthnSvc, + RPC_AUTH_IDENTITY_HANDLE AuthIdentity, + unsigned long AuthzSvc, + RPC_SECURITY_QOS* SecurityQos); + WINPR_API RPC_STATUS RpcBindingSetAuthInfoW(RPC_BINDING_HANDLE Binding, + RPC_WSTR ServerPrincName, unsigned long AuthnLevel, + unsigned long AuthnSvc, + RPC_AUTH_IDENTITY_HANDLE AuthIdentity, + unsigned long AuthzSvc); + WINPR_API RPC_STATUS RpcBindingSetAuthInfoExW(RPC_BINDING_HANDLE Binding, + RPC_WSTR ServerPrincName, + unsigned long AuthnLevel, unsigned long AuthnSvc, + RPC_AUTH_IDENTITY_HANDLE AuthIdentity, + unsigned long AuthzSvc, + RPC_SECURITY_QOS* SecurityQOS); + WINPR_API RPC_STATUS RpcBindingInqAuthInfoExA( + RPC_BINDING_HANDLE Binding, RPC_CSTR* ServerPrincName, unsigned long* AuthnLevel, + unsigned long* AuthnSvc, RPC_AUTH_IDENTITY_HANDLE* AuthIdentity, unsigned long* AuthzSvc, + unsigned long RpcQosVersion, RPC_SECURITY_QOS* SecurityQOS); + WINPR_API RPC_STATUS RpcBindingInqAuthInfoExW( + RPC_BINDING_HANDLE Binding, RPC_WSTR* ServerPrincName, unsigned long* AuthnLevel, + unsigned long* AuthnSvc, RPC_AUTH_IDENTITY_HANDLE* AuthIdentity, unsigned long* AuthzSvc, + unsigned long RpcQosVersion, RPC_SECURITY_QOS* SecurityQOS); + + WINPR_API RPC_STATUS RpcServerRegisterAuthInfoA(RPC_CSTR ServerPrincName, + unsigned long AuthnSvc, + RPC_AUTH_KEY_RETRIEVAL_FN GetKeyFn, void* Arg); + WINPR_API RPC_STATUS RpcServerRegisterAuthInfoW(RPC_WSTR ServerPrincName, + unsigned long AuthnSvc, + RPC_AUTH_KEY_RETRIEVAL_FN GetKeyFn, void* Arg); + + WINPR_API RPC_STATUS RpcBindingServerFromClient(RPC_BINDING_HANDLE ClientBinding, + RPC_BINDING_HANDLE* ServerBinding); + WINPR_API DECLSPEC_NORETURN void RpcRaiseException(RPC_STATUS exception); + WINPR_API RPC_STATUS RpcTestCancel(void); + WINPR_API RPC_STATUS RpcServerTestCancel(RPC_BINDING_HANDLE BindingHandle); + WINPR_API RPC_STATUS RpcCancelThread(void* Thread); + WINPR_API RPC_STATUS RpcCancelThreadEx(void* Thread, long Timeout); + + WINPR_API RPC_STATUS UuidCreate(UUID* Uuid); + WINPR_API RPC_STATUS UuidCreateSequential(UUID* Uuid); + WINPR_API RPC_STATUS UuidToStringA(const UUID* Uuid, RPC_CSTR* StringUuid); + WINPR_API RPC_STATUS UuidFromStringA(RPC_CSTR StringUuid, UUID* Uuid); + WINPR_API RPC_STATUS UuidToStringW(const UUID* Uuid, RPC_WSTR* StringUuid); + WINPR_API RPC_STATUS UuidFromStringW(RPC_WSTR StringUuid, UUID* Uuid); + WINPR_API signed int UuidCompare(const UUID* Uuid1, const UUID* Uuid2, RPC_STATUS* Status); + WINPR_API RPC_STATUS UuidCreateNil(UUID* NilUuid); + WINPR_API int UuidEqual(const UUID* Uuid1, const UUID* Uuid2, RPC_STATUS* Status); + WINPR_API unsigned short UuidHash(const UUID* Uuid, RPC_STATUS* Status); + WINPR_API int UuidIsNil(const UUID* Uuid, RPC_STATUS* Status); + + WINPR_API RPC_STATUS RpcEpRegisterNoReplaceA(RPC_IF_HANDLE IfSpec, + RPC_BINDING_VECTOR* BindingVector, + UUID_VECTOR* UuidVector, RPC_CSTR Annotation); + WINPR_API RPC_STATUS RpcEpRegisterNoReplaceW(RPC_IF_HANDLE IfSpec, + RPC_BINDING_VECTOR* BindingVector, + UUID_VECTOR* UuidVector, RPC_WSTR Annotation); + WINPR_API RPC_STATUS RpcEpRegisterA(RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR* BindingVector, + UUID_VECTOR* UuidVector, RPC_CSTR Annotation); + WINPR_API RPC_STATUS RpcEpRegisterW(RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR* BindingVector, + UUID_VECTOR* UuidVector, RPC_WSTR Annotation); + WINPR_API RPC_STATUS RpcEpUnregister(RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR* BindingVector, + UUID_VECTOR* UuidVector); + + WINPR_API RPC_STATUS DceErrorInqTextA(RPC_STATUS RpcStatus, RPC_CSTR ErrorText); + WINPR_API RPC_STATUS DceErrorInqTextW(RPC_STATUS RpcStatus, RPC_WSTR ErrorText); + + WINPR_API RPC_STATUS RpcMgmtEpEltInqBegin(RPC_BINDING_HANDLE EpBinding, + unsigned long InquiryType, RPC_IF_ID* IfId, + unsigned long VersOption, UUID* ObjectUuid, + RPC_EP_INQ_HANDLE* InquiryContext); + WINPR_API RPC_STATUS RpcMgmtEpEltInqDone(RPC_EP_INQ_HANDLE* InquiryContext); + WINPR_API RPC_STATUS RpcMgmtEpEltInqNextA(RPC_EP_INQ_HANDLE InquiryContext, RPC_IF_ID* IfId, + RPC_BINDING_HANDLE* Binding, UUID* ObjectUuid, + RPC_CSTR* Annotation); + WINPR_API RPC_STATUS RpcMgmtEpEltInqNextW(RPC_EP_INQ_HANDLE InquiryContext, RPC_IF_ID* IfId, + RPC_BINDING_HANDLE* Binding, UUID* ObjectUuid, + RPC_WSTR* Annotation); + WINPR_API RPC_STATUS RpcMgmtEpUnregister(RPC_BINDING_HANDLE EpBinding, RPC_IF_ID* IfId, + RPC_BINDING_HANDLE Binding, UUID* ObjectUuid); + WINPR_API RPC_STATUS RpcMgmtSetAuthorizationFn(RPC_MGMT_AUTHORIZATION_FN AuthorizationFn); + + WINPR_API RPC_STATUS RpcServerInqBindingHandle(RPC_BINDING_HANDLE* Binding); + +#ifdef __cplusplus +} +#endif + +#endif + +#endif /* WINPR_RPC_H */ diff --git a/winpr/include/winpr/sam.h b/winpr/include/winpr/sam.h new file mode 100644 index 0000000..c1efaa1 --- /dev/null +++ b/winpr/include/winpr/sam.h @@ -0,0 +1,59 @@ +/** + * WinPR: Windows Portable Runtime + * Security Accounts Manager (SAM) + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_UTILS_SAM_H +#define WINPR_UTILS_SAM_H + +#include <winpr/winpr.h> +#include <winpr/wtypes.h> + +typedef struct winpr_sam WINPR_SAM; + +struct winpr_sam_entry +{ + LPSTR User; + UINT32 UserLength; + LPSTR Domain; + UINT32 DomainLength; + BYTE LmHash[16]; + BYTE NtHash[16]; +}; +typedef struct winpr_sam_entry WINPR_SAM_ENTRY; + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API WINPR_SAM_ENTRY* SamLookupUserA(WINPR_SAM* sam, LPCSTR User, UINT32 UserLength, + LPCSTR Domain, UINT32 DomainLength); + WINPR_API WINPR_SAM_ENTRY* SamLookupUserW(WINPR_SAM* sam, LPCWSTR User, UINT32 UserLength, + LPCWSTR Domain, UINT32 DomainLength); + + WINPR_API void SamResetEntry(WINPR_SAM_ENTRY* entry); + WINPR_API void SamFreeEntry(WINPR_SAM* sam, WINPR_SAM_ENTRY* entry); + + WINPR_API WINPR_SAM* SamOpen(const char* filename, BOOL readOnly); + WINPR_API void SamClose(WINPR_SAM* sam); + +#ifdef __cplusplus +} +#endif + +#endif /* WINPR_UTILS_SAM_H */ diff --git a/winpr/include/winpr/schannel.h b/winpr/include/winpr/schannel.h new file mode 100644 index 0000000..e4d5fab --- /dev/null +++ b/winpr/include/winpr/schannel.h @@ -0,0 +1,284 @@ +/** + * WinPR: Windows Portable Runtime + * Schannel Security Package + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_SSPI_SCHANNEL_H +#define WINPR_SSPI_SCHANNEL_H + +#include <winpr/sspi.h> +#include <winpr/crypto.h> + +#if defined(_WIN32) && !defined(_UWP) + +#include <schannel.h> + +#else + +#define SCHANNEL_NAME_A "Schannel" +#define SCHANNEL_NAME_W L"Schannel" + +#ifdef _UNICODE +#define SCHANNEL_NAME SCHANNEL_NAME_W +#else +#define SCHANNEL_NAME SCHANNEL_NAME_A +#endif + +#define SECPKG_ATTR_SUPPORTED_ALGS 86 +#define SECPKG_ATTR_CIPHER_STRENGTHS 87 +#define SECPKG_ATTR_SUPPORTED_PROTOCOLS 88 + +typedef struct +{ + DWORD cSupportedAlgs; + ALG_ID* palgSupportedAlgs; +} SecPkgCred_SupportedAlgs, *PSecPkgCred_SupportedAlgs; + +typedef struct +{ + DWORD dwMinimumCipherStrength; + DWORD dwMaximumCipherStrength; +} SecPkgCred_CipherStrengths, *PSecPkgCred_CipherStrengths; + +typedef struct +{ + DWORD grbitProtocol; +} SecPkgCred_SupportedProtocols, *PSecPkgCred_SupportedProtocols; + +enum eTlsSignatureAlgorithm +{ + TlsSignatureAlgorithm_Anonymous = 0, + TlsSignatureAlgorithm_Rsa = 1, + TlsSignatureAlgorithm_Dsa = 2, + TlsSignatureAlgorithm_Ecdsa = 3 +}; + +enum eTlsHashAlgorithm +{ + TlsHashAlgorithm_None = 0, + TlsHashAlgorithm_Md5 = 1, + TlsHashAlgorithm_Sha1 = 2, + TlsHashAlgorithm_Sha224 = 3, + TlsHashAlgorithm_Sha256 = 4, + TlsHashAlgorithm_Sha384 = 5, + TlsHashAlgorithm_Sha512 = 6 +}; + +#define SCH_CRED_V1 0x00000001 +#define SCH_CRED_V2 0x00000002 +#define SCH_CRED_VERSION 0x00000002 +#define SCH_CRED_V3 0x00000003 +#define SCHANNEL_CRED_VERSION 0x00000004 + +typedef struct +{ + DWORD dwVersion; + DWORD cCreds; + PCCERT_CONTEXT* paCred; + HCERTSTORE hRootStore; + + DWORD cSupportedAlgs; + ALG_ID* palgSupportedAlgs; + + DWORD grbitEnabledProtocols; + DWORD dwMinimumCipherStrength; + DWORD dwMaximumCipherStrength; + DWORD dwSessionLifespan; + DWORD dwFlags; + DWORD dwCredFormat; +} SCHANNEL_CRED, *PSCHANNEL_CRED; + +#define SCH_CRED_FORMAT_CERT_CONTEXT 0x00000000 +#define SCH_CRED_FORMAT_CERT_HASH 0x00000001 +#define SCH_CRED_FORMAT_CERT_HASH_STORE 0x00000002 + +#define SCH_CRED_MAX_STORE_NAME_SIZE 128 +#define SCH_CRED_MAX_SUPPORTED_ALGS 256 +#define SCH_CRED_MAX_SUPPORTED_CERTS 100 + +typedef struct +{ + DWORD dwLength; + DWORD dwFlags; + HCRYPTPROV hProv; + BYTE ShaHash[20]; +} SCHANNEL_CERT_HASH, *PSCHANNEL_CERT_HASH; + +typedef struct +{ + DWORD dwLength; + DWORD dwFlags; + HCRYPTPROV hProv; + BYTE ShaHash[20]; + WCHAR pwszStoreName[SCH_CRED_MAX_STORE_NAME_SIZE]; +} SCHANNEL_CERT_HASH_STORE, *PSCHANNEL_CERT_HASH_STORE; + +#define SCH_MACHINE_CERT_HASH 0x00000001 + +#define SCH_CRED_NO_SYSTEM_MAPPER 0x00000002 +#define SCH_CRED_NO_SERVERNAME_CHECK 0x00000004 +#define SCH_CRED_MANUAL_CRED_VALIDATION 0x00000008 +#define SCH_CRED_NO_DEFAULT_CREDS 0x00000010 +#define SCH_CRED_AUTO_CRED_VALIDATION 0x00000020 +#define SCH_CRED_USE_DEFAULT_CREDS 0x00000040 +#define SCH_CRED_DISABLE_RECONNECTS 0x00000080 + +#define SCH_CRED_REVOCATION_CHECK_END_CERT 0x00000100 +#define SCH_CRED_REVOCATION_CHECK_CHAIN 0x00000200 +#define SCH_CRED_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT 0x00000400 +#define SCH_CRED_IGNORE_NO_REVOCATION_CHECK 0x00000800 +#define SCH_CRED_IGNORE_REVOCATION_OFFLINE 0x00001000 + +#define SCH_CRED_RESTRICTED_ROOTS 0x00002000 +#define SCH_CRED_REVOCATION_CHECK_CACHE_ONLY 0x00004000 +#define SCH_CRED_CACHE_ONLY_URL_RETRIEVAL 0x00008000 + +#define SCH_CRED_MEMORY_STORE_CERT 0x00010000 + +#define SCH_CRED_CACHE_ONLY_URL_RETRIEVAL_ON_CREATE 0x00020000 + +#define SCH_SEND_ROOT_CERT 0x00040000 +#define SCH_CRED_SNI_CREDENTIAL 0x00080000 +#define SCH_CRED_SNI_ENABLE_OCSP 0x00100000 +#define SCH_SEND_AUX_RECORD 0x00200000 + +#define SCHANNEL_RENEGOTIATE 0 +#define SCHANNEL_SHUTDOWN 1 +#define SCHANNEL_ALERT 2 +#define SCHANNEL_SESSION 3 + +typedef struct +{ + DWORD dwTokenType; + DWORD dwAlertType; + DWORD dwAlertNumber; +} SCHANNEL_ALERT_TOKEN; + +#define TLS1_ALERT_WARNING 1 +#define TLS1_ALERT_FATAL 2 + +#define TLS1_ALERT_CLOSE_NOTIFY 0 +#define TLS1_ALERT_UNEXPECTED_MESSAGE 10 +#define TLS1_ALERT_BAD_RECORD_MAC 20 +#define TLS1_ALERT_DECRYPTION_FAILED 21 +#define TLS1_ALERT_RECORD_OVERFLOW 22 +#define TLS1_ALERT_DECOMPRESSION_FAIL 30 +#define TLS1_ALERT_HANDSHAKE_FAILURE 40 +#define TLS1_ALERT_BAD_CERTIFICATE 42 +#define TLS1_ALERT_UNSUPPORTED_CERT 43 +#define TLS1_ALERT_CERTIFICATE_REVOKED 44 +#define TLS1_ALERT_CERTIFICATE_EXPIRED 45 +#define TLS1_ALERT_CERTIFICATE_UNKNOWN 46 +#define TLS1_ALERT_ILLEGAL_PARAMETER 47 +#define TLS1_ALERT_UNKNOWN_CA 48 +#define TLS1_ALERT_ACCESS_DENIED 49 +#define TLS1_ALERT_DECODE_ERROR 50 +#define TLS1_ALERT_DECRYPT_ERROR 51 +#define TLS1_ALERT_EXPORT_RESTRICTION 60 +#define TLS1_ALERT_PROTOCOL_VERSION 70 +#define TLS1_ALERT_INSUFFIENT_SECURITY 71 +#define TLS1_ALERT_INTERNAL_ERROR 80 +#define TLS1_ALERT_USER_CANCELED 90 +#define TLS1_ALERT_NO_RENEGOTIATION 100 +#define TLS1_ALERT_UNSUPPORTED_EXT 110 + +#define SSL_SESSION_ENABLE_RECONNECTS 1 +#define SSL_SESSION_DISABLE_RECONNECTS 2 + +typedef struct +{ + DWORD dwTokenType; + DWORD dwFlags; +} SCHANNEL_SESSION_TOKEN; + +typedef struct +{ + DWORD cbLength; + ALG_ID aiHash; + DWORD cbHash; + BYTE HashValue[36]; + BYTE CertThumbprint[20]; +} SCHANNEL_CLIENT_SIGNATURE, *PSCHANNEL_CLIENT_SIGNATURE; + +#define SP_PROT_SSL3_SERVER 0x00000010 +#define SP_PROT_SSL3_CLIENT 0x00000020 +#define SP_PROT_SSL3 (SP_PROT_SSL3_SERVER | SP_PROT_SSL3_CLIENT) + +#define SP_PROT_TLS1_SERVER 0x00000040 +#define SP_PROT_TLS1_CLIENT 0x00000080 +#define SP_PROT_TLS1 (SP_PROT_TLS1_SERVER | SP_PROT_TLS1_CLIENT) + +#define SP_PROT_SSL3TLS1_CLIENTS (SP_PROT_TLS1_CLIENT | SP_PROT_SSL3_CLIENT) +#define SP_PROT_SSL3TLS1_SERVERS (SP_PROT_TLS1_SERVER | SP_PROT_SSL3_SERVER) +#define SP_PROT_SSL3TLS1 (SP_PROT_SSL3 | SP_PROT_TLS1) + +#define SP_PROT_UNI_SERVER 0x40000000 +#define SP_PROT_UNI_CLIENT 0x80000000 +#define SP_PROT_UNI (SP_PROT_UNI_SERVER | SP_PROT_UNI_CLIENT) + +#define SP_PROT_ALL 0xFFFFFFFF +#define SP_PROT_NONE 0 +#define SP_PROT_CLIENTS (SP_PROT_SSL3_CLIENT | SP_PROT_UNI_CLIENT | SP_PROT_TLS1_CLIENT) +#define SP_PROT_SERVERS (SP_PROT_SSL3_SERVER | SP_PROT_UNI_SERVER | SP_PROT_TLS1_SERVER) + +#define SP_PROT_TLS1_0_SERVER SP_PROT_TLS1_SERVER +#define SP_PROT_TLS1_0_CLIENT SP_PROT_TLS1_CLIENT +#define SP_PROT_TLS1_0 (SP_PROT_TLS1_0_SERVER | SP_PROT_TLS1_0_CLIENT) + +#define SP_PROT_TLS1_1_SERVER 0x00000100 +#define SP_PROT_TLS1_1_CLIENT 0x00000200 +#define SP_PROT_TLS1_1 (SP_PROT_TLS1_1_SERVER | SP_PROT_TLS1_1_CLIENT) + +#define SP_PROT_TLS1_2_SERVER 0x00000400 +#define SP_PROT_TLS1_2_CLIENT 0x00000800 +#define SP_PROT_TLS1_2 (SP_PROT_TLS1_2_SERVER | SP_PROT_TLS1_2_CLIENT) + +#define SP_PROT_DTLS_SERVER 0x00010000 +#define SP_PROT_DTLS_CLIENT 0x00020000 +#define SP_PROT_DTLS (SP_PROT_DTLS_SERVER | SP_PROT_DTLS_CLIENT) + +#define SP_PROT_DTLS1_0_SERVER SP_PROT_DTLS_SERVER +#define SP_PROT_DTLS1_0_CLIENT SP_PROT_DTLS_CLIENT +#define SP_PROT_DTLS1_0 (SP_PROT_DTLS1_0_SERVER | SP_PROT_DTLS1_0_CLIENT) + +#define SP_PROT_DTLS1_X_SERVER SP_PROT_DTLS1_0_SERVER + +#define SP_PROT_DTLS1_X_CLIENT SP_PROT_DTLS1_0_CLIENT + +#define SP_PROT_DTLS1_X (SP_PROT_DTLS1_X_SERVER | SP_PROT_DTLS1_X_CLIENT) + +#define SP_PROT_TLS1_1PLUS_SERVER (SP_PROT_TLS1_1_SERVER | SP_PROT_TLS1_2_SERVER) +#define SP_PROT_TLS1_1PLUS_CLIENT (SP_PROT_TLS1_1_CLIENT | SP_PROT_TLS1_2_CLIENT) + +#define SP_PROT_TLS1_1PLUS (SP_PROT_TLS1_1PLUS_SERVER | SP_PROT_TLS1_1PLUS_CLIENT) + +#define SP_PROT_TLS1_X_SERVER \ + (SP_PROT_TLS1_0_SERVER | SP_PROT_TLS1_1_SERVER | SP_PROT_TLS1_2_SERVER) +#define SP_PROT_TLS1_X_CLIENT \ + (SP_PROT_TLS1_0_CLIENT | SP_PROT_TLS1_1_CLIENT | SP_PROT_TLS1_2_CLIENT) +#define SP_PROT_TLS1_X (SP_PROT_TLS1_X_SERVER | SP_PROT_TLS1_X_CLIENT) + +#define SP_PROT_SSL3TLS1_X_CLIENTS (SP_PROT_TLS1_X_CLIENT | SP_PROT_SSL3_CLIENT) +#define SP_PROT_SSL3TLS1_X_SERVERS (SP_PROT_TLS1_X_SERVER | SP_PROT_SSL3_SERVER) +#define SP_PROT_SSL3TLS1_X (SP_PROT_SSL3 | SP_PROT_TLS1_X) + +#define SP_PROT_X_CLIENTS (SP_PROT_CLIENTS | SP_PROT_TLS1_X_CLIENT | SP_PROT_DTLS1_X_CLIENT) +#define SP_PROT_X_SERVERS (SP_PROT_SERVERS | SP_PROT_TLS1_X_SERVER | SP_PROT_DTLS1_X_SERVER) + +#endif + +#endif /* WINPR_SSPI_SCHANNEL_H */ diff --git a/winpr/include/winpr/secapi.h b/winpr/include/winpr/secapi.h new file mode 100644 index 0000000..e191070 --- /dev/null +++ b/winpr/include/winpr/secapi.h @@ -0,0 +1,78 @@ +/** + * WinPR: Windows Portable Runtime + * Schannel Security Package + * + * Copyright 2023 David Fort <contact@hardening-consulting.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_SECAPI_H_ +#define WINPR_SECAPI_H_ + +#ifdef _WIN32 +#define _NTDEF_ +#include <ntsecapi.h> +#else + +#include <winpr/wtypes.h> + +typedef enum _KERB_LOGON_SUBMIT_TYPE +{ + KerbInteractiveLogon = 2, + KerbSmartCardLogon = 6, + KerbWorkstationUnlockLogon = 7, + KerbSmartCardUnlockLogon = 8, + KerbProxyLogon = 9, + KerbTicketLogon = 10, + KerbTicketUnlockLogon = 11, + KerbS4ULogon = 12, + KerbCertificateLogon = 13, + KerbCertificateS4ULogon = 14, + KerbCertificateUnlockLogon = 15, + KerbNoElevationLogon = 83, + KerbLuidLogon = 84 +} KERB_LOGON_SUBMIT_TYPE, + *PKERB_LOGON_SUBMIT_TYPE; + +typedef struct _KERB_TICKET_LOGON +{ + KERB_LOGON_SUBMIT_TYPE MessageType; + ULONG Flags; + ULONG ServiceTicketLength; + ULONG TicketGrantingTicketLength; + PUCHAR ServiceTicket; + PUCHAR TicketGrantingTicket; +} KERB_TICKET_LOGON, *PKERB_TICKET_LOGON; + +#define KERB_LOGON_FLAG_ALLOW_EXPIRED_TICKET 0x1 + +#define MSV1_0_OWF_PASSWORD_LENGTH 16 + +typedef struct _MSV1_0_SUPPLEMENTAL_CREDENTIAL +{ + ULONG Version; + ULONG Flags; + UCHAR LmPassword[MSV1_0_OWF_PASSWORD_LENGTH]; + UCHAR NtPassword[MSV1_0_OWF_PASSWORD_LENGTH]; +} MSV1_0_SUPPLEMENTAL_CREDENTIAL, *PMSV1_0_SUPPLEMENTAL_CREDENTIAL; + +#define MSV1_0_CRED_VERSION_REMOTE 0xffff0002 + +#endif /* _WIN32 */ + +#ifndef KERB_LOGON_FLAG_REDIRECTED +#define KERB_LOGON_FLAG_REDIRECTED 0x2 +#endif + +#endif /* WINPR_SECAPI_H_ */ diff --git a/winpr/include/winpr/security.h b/winpr/include/winpr/security.h new file mode 100644 index 0000000..0d71b21 --- /dev/null +++ b/winpr/include/winpr/security.h @@ -0,0 +1,449 @@ +/** + * WinPR: Windows Portable Runtime + * Security Definitions + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_SECURITY_H +#define WINPR_SECURITY_H + +#include <winpr/winpr.h> +#include <winpr/wtypes.h> + +/** + * Windows Integrity Mechanism Design: + * http://msdn.microsoft.com/en-us/library/bb625963.aspx + */ + +#ifndef _WIN32 + +#include <winpr/nt.h> + +#define ANYSIZE_ARRAY 1 + +typedef enum +{ + SecurityAnonymous, + SecurityIdentification, + SecurityImpersonation, + SecurityDelegation +} SECURITY_IMPERSONATION_LEVEL, + *PSECURITY_IMPERSONATION_LEVEL; + +#define SECURITY_MAX_IMPERSONATION_LEVEL SecurityDelegation +#define SECURITY_MIN_IMPERSONATION_LEVEL SecurityAnonymous +#define DEFAULT_IMPERSONATION_LEVEL SecurityImpersonation +#define VALID_IMPERSONATION_LEVEL(L) \ + (((L) >= SECURITY_MIN_IMPERSONATION_LEVEL) && ((L) <= SECURITY_MAX_IMPERSONATION_LEVEL)) + +#define TOKEN_ASSIGN_PRIMARY (0x0001) +#define TOKEN_DUPLICATE (0x0002) +#define TOKEN_IMPERSONATE (0x0004) +#define TOKEN_QUERY (0x0008) +#define TOKEN_QUERY_SOURCE (0x0010) +#define TOKEN_ADJUST_PRIVILEGES (0x0020) +#define TOKEN_ADJUST_GROUPS (0x0040) +#define TOKEN_ADJUST_DEFAULT (0x0080) +#define TOKEN_ADJUST_SESSIONID (0x0100) + +#define TOKEN_ALL_ACCESS_P \ + (STANDARD_RIGHTS_REQUIRED | TOKEN_ASSIGN_PRIMARY | TOKEN_DUPLICATE | TOKEN_IMPERSONATE | \ + TOKEN_QUERY | TOKEN_QUERY_SOURCE | TOKEN_ADJUST_PRIVILEGES | TOKEN_ADJUST_GROUPS | \ + TOKEN_ADJUST_DEFAULT) + +#define TOKEN_ALL_ACCESS (TOKEN_ALL_ACCESS_P | TOKEN_ADJUST_SESSIONID) + +#define TOKEN_READ (STANDARD_RIGHTS_READ | TOKEN_QUERY) + +#define TOKEN_WRITE \ + (STANDARD_RIGHTS_WRITE | TOKEN_ADJUST_PRIVILEGES | TOKEN_ADJUST_GROUPS | TOKEN_ADJUST_DEFAULT) + +#define TOKEN_EXECUTE (STANDARD_RIGHTS_EXECUTE) + +#define TOKEN_MANDATORY_POLICY_OFF 0x0 +#define TOKEN_MANDATORY_POLICY_NO_WRITE_UP 0x1 +#define TOKEN_MANDATORY_POLICY_NEW_PROCESS_MIN 0x2 + +#define TOKEN_MANDATORY_POLICY_VALID_MASK \ + (TOKEN_MANDATORY_POLICY_NO_WRITE_UP | TOKEN_MANDATORY_POLICY_NEW_PROCESS_MIN) + +#define POLICY_AUDIT_SUBCATEGORY_COUNT (56) + +#define TOKEN_SOURCE_LENGTH 8 + +#define SID_REVISION (1) +#define SID_MAX_SUB_AUTHORITIES (15) +#define SID_RECOMMENDED_SUB_AUTHORITIES (1) + +#define SID_HASH_SIZE 32 + +#define SECURITY_MANDATORY_UNTRUSTED_RID 0x0000 +#define SECURITY_MANDATORY_LOW_RID 0x1000 +#define SECURITY_MANDATORY_MEDIUM_RID 0x2000 +#define SECURITY_MANDATORY_HIGH_RID 0x3000 +#define SECURITY_MANDATORY_SYSTEM_RID 0x4000 + +#define SECURITY_NULL_SID_AUTHORITY \ + { \ + 0, 0, 0, 0, 0, 0 \ + } +#define SECURITY_WORLD_SID_AUTHORITY \ + { \ + 0, 0, 0, 0, 0, 1 \ + } +#define SECURITY_LOCAL_SID_AUTHORITY \ + { \ + 0, 0, 0, 0, 0, 2 \ + } +#define SECURITY_CREATOR_SID_AUTHORITY \ + { \ + 0, 0, 0, 0, 0, 3 \ + } +#define SECURITY_NON_UNIQUE_AUTHORITY \ + { \ + 0, 0, 0, 0, 0, 4 \ + } +#define SECURITY_RESOURCE_MANAGER_AUTHORITY \ + { \ + 0, 0, 0, 0, 0, 9 \ + } + +#define SECURITY_NULL_RID (0x00000000L) +#define SECURITY_WORLD_RID (0x00000000L) +#define SECURITY_LOCAL_RID (0x00000000L) +#define SECURITY_LOCAL_LOGON_RID (0x00000001L) + +#define SECURITY_CREATOR_OWNER_RID (0x00000000L) +#define SECURITY_CREATOR_GROUP_RID (0x00000001L) +#define SECURITY_CREATOR_OWNER_SERVER_RID (0x00000002L) +#define SECURITY_CREATOR_GROUP_SERVER_RID (0x00000003L) +#define SECURITY_CREATOR_OWNER_RIGHTS_RID (0x00000004L) + +typedef PVOID PACCESS_TOKEN; +typedef PVOID PCLAIMS_BLOB; + +typedef struct +{ + LUID Luid; + DWORD Attributes; +} LUID_AND_ATTRIBUTES, *PLUID_AND_ATTRIBUTES; +typedef LUID_AND_ATTRIBUTES LUID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY]; +typedef LUID_AND_ATTRIBUTES_ARRAY* PLUID_AND_ATTRIBUTES_ARRAY; + +typedef struct +{ + BYTE Value[6]; +} SID_IDENTIFIER_AUTHORITY, *PSID_IDENTIFIER_AUTHORITY; + +typedef struct +{ + BYTE Revision; + BYTE SubAuthorityCount; + SID_IDENTIFIER_AUTHORITY IdentifierAuthority; + DWORD SubAuthority[ANYSIZE_ARRAY]; +} SID, *PISID; + +typedef enum +{ + SidTypeUser = 1, + SidTypeGroup, + SidTypeDomain, + SidTypeAlias, + SidTypeWellKnownGroup, + SidTypeDeletedAccount, + SidTypeInvalid, + SidTypeUnknown, + SidTypeComputer, + SidTypeLabel +} SID_NAME_USE, + *PSID_NAME_USE; + +typedef struct +{ + PSID Sid; + DWORD Attributes; +} SID_AND_ATTRIBUTES, *PSID_AND_ATTRIBUTES; + +typedef SID_AND_ATTRIBUTES SID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY]; +typedef SID_AND_ATTRIBUTES_ARRAY* PSID_AND_ATTRIBUTES_ARRAY; + +typedef ULONG_PTR SID_HASH_ENTRY, *PSID_HASH_ENTRY; + +typedef struct +{ + DWORD SidCount; + PSID_AND_ATTRIBUTES SidAttr; + SID_HASH_ENTRY Hash[SID_HASH_SIZE]; +} SID_AND_ATTRIBUTES_HASH, *PSID_AND_ATTRIBUTES_HASH; + +typedef enum +{ + TokenPrimary = 1, + TokenImpersonation +} TOKEN_TYPE; +typedef TOKEN_TYPE* PTOKEN_TYPE; + +typedef enum +{ + TokenElevationTypeDefault = 1, + TokenElevationTypeFull, + TokenElevationTypeLimited +} TOKEN_ELEVATION_TYPE, + *PTOKEN_ELEVATION_TYPE; + +typedef enum +{ + TokenUser = 1, + TokenGroups, + TokenPrivileges, + TokenOwner, + TokenPrimaryGroup, + TokenDefaultDacl, + TokenSource, + TokenType, + TokenImpersonationLevel, + TokenStatistics, + TokenRestrictedSids, + TokenSessionId, + TokenGroupsAndPrivileges, + TokenSessionReference, + TokenSandBoxInert, + TokenAuditPolicy, + TokenOrigin, + TokenElevationType, + TokenLinkedToken, + TokenElevation, + TokenHasRestrictions, + TokenAccessInformation, + TokenVirtualizationAllowed, + TokenVirtualizationEnabled, + TokenIntegrityLevel, + TokenUIAccess, + TokenMandatoryPolicy, + TokenLogonSid, + TokenIsAppContainer, + TokenCapabilities, + TokenAppContainerSid, + TokenAppContainerNumber, + TokenUserClaimAttributes, + TokenDeviceClaimAttributes, + TokenRestrictedUserClaimAttributes, + TokenRestrictedDeviceClaimAttributes, + TokenDeviceGroups, + TokenRestrictedDeviceGroups, + TokenSecurityAttributes, + TokenIsRestricted, + MaxTokenInfoClass +} TOKEN_INFORMATION_CLASS, + *PTOKEN_INFORMATION_CLASS; + +typedef struct +{ + SID_AND_ATTRIBUTES User; +} TOKEN_USER, *PTOKEN_USER; + +typedef struct +{ + DWORD GroupCount; + SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY]; +} TOKEN_GROUPS, *PTOKEN_GROUPS; + +typedef struct +{ + DWORD PrivilegeCount; + LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY]; +} TOKEN_PRIVILEGES, *PTOKEN_PRIVILEGES; + +typedef struct +{ + PSID Owner; +} TOKEN_OWNER, *PTOKEN_OWNER; + +typedef struct +{ + PSID PrimaryGroup; +} TOKEN_PRIMARY_GROUP, *PTOKEN_PRIMARY_GROUP; + +typedef struct +{ + PACL DefaultDacl; +} TOKEN_DEFAULT_DACL, *PTOKEN_DEFAULT_DACL; + +typedef struct +{ + PCLAIMS_BLOB UserClaims; +} TOKEN_USER_CLAIMS, *PTOKEN_USER_CLAIMS; + +typedef struct +{ + PCLAIMS_BLOB DeviceClaims; +} TOKEN_DEVICE_CLAIMS, *PTOKEN_DEVICE_CLAIMS; + +typedef struct +{ + DWORD SidCount; + DWORD SidLength; + PSID_AND_ATTRIBUTES Sids; + DWORD RestrictedSidCount; + DWORD RestrictedSidLength; + PSID_AND_ATTRIBUTES RestrictedSids; + DWORD PrivilegeCount; + DWORD PrivilegeLength; + PLUID_AND_ATTRIBUTES Privileges; + LUID AuthenticationId; +} TOKEN_GROUPS_AND_PRIVILEGES, *PTOKEN_GROUPS_AND_PRIVILEGES; + +typedef struct +{ + HANDLE LinkedToken; +} TOKEN_LINKED_TOKEN, *PTOKEN_LINKED_TOKEN; + +typedef struct +{ + DWORD TokenIsElevated; +} TOKEN_ELEVATION, *PTOKEN_ELEVATION; + +typedef struct +{ + SID_AND_ATTRIBUTES Label; +} TOKEN_MANDATORY_LABEL, *PTOKEN_MANDATORY_LABEL; + +typedef struct +{ + DWORD Policy; +} TOKEN_MANDATORY_POLICY, *PTOKEN_MANDATORY_POLICY; + +typedef struct +{ + PSID_AND_ATTRIBUTES_HASH SidHash; + PSID_AND_ATTRIBUTES_HASH RestrictedSidHash; + PTOKEN_PRIVILEGES Privileges; + LUID AuthenticationId; + TOKEN_TYPE TokenType; + SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; + TOKEN_MANDATORY_POLICY MandatoryPolicy; + DWORD Flags; + DWORD AppContainerNumber; + PSID PackageSid; + PSID_AND_ATTRIBUTES_HASH CapabilitiesHash; +} TOKEN_ACCESS_INFORMATION, *PTOKEN_ACCESS_INFORMATION; + +typedef struct +{ + BYTE PerUserPolicy[((POLICY_AUDIT_SUBCATEGORY_COUNT) >> 1) + 1]; +} TOKEN_AUDIT_POLICY, *PTOKEN_AUDIT_POLICY; + +typedef struct +{ + CHAR SourceName[TOKEN_SOURCE_LENGTH]; + LUID SourceIdentifier; +} TOKEN_SOURCE, *PTOKEN_SOURCE; + +typedef struct +{ + LUID TokenId; + LUID AuthenticationId; + LARGE_INTEGER ExpirationTime; + TOKEN_TYPE TokenType; + SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; + DWORD DynamicCharged; + DWORD DynamicAvailable; + DWORD GroupCount; + DWORD PrivilegeCount; + LUID ModifiedId; +} TOKEN_STATISTICS, *PTOKEN_STATISTICS; + +typedef struct +{ + LUID TokenId; + LUID AuthenticationId; + LUID ModifiedId; + TOKEN_SOURCE TokenSource; +} TOKEN_CONTROL, *PTOKEN_CONTROL; + +typedef struct +{ + LUID OriginatingLogonSession; +} TOKEN_ORIGIN, *PTOKEN_ORIGIN; + +typedef enum +{ + MandatoryLevelUntrusted = 0, + MandatoryLevelLow, + MandatoryLevelMedium, + MandatoryLevelHigh, + MandatoryLevelSystem, + MandatoryLevelSecureProcess, + MandatoryLevelCount +} MANDATORY_LEVEL, + *PMANDATORY_LEVEL; + +typedef struct +{ + PSID TokenAppContainer; +} TOKEN_APPCONTAINER_INFORMATION, *PTOKEN_APPCONTAINER_INFORMATION; + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API BOOL InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurityDescriptor, + DWORD dwRevision); + WINPR_API DWORD GetSecurityDescriptorLength(PSECURITY_DESCRIPTOR pSecurityDescriptor); + WINPR_API BOOL IsValidSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurityDescriptor); + + WINPR_API BOOL GetSecurityDescriptorControl(PSECURITY_DESCRIPTOR pSecurityDescriptor, + PSECURITY_DESCRIPTOR_CONTROL pControl, + LPDWORD lpdwRevision); + WINPR_API BOOL SetSecurityDescriptorControl(PSECURITY_DESCRIPTOR pSecurityDescriptor, + SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest, + SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet); + + WINPR_API BOOL GetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR pSecurityDescriptor, + LPBOOL lpbDaclPresent, PACL* pDacl, + LPBOOL lpbDaclDefaulted); + WINPR_API BOOL SetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR pSecurityDescriptor, + BOOL bDaclPresent, PACL pDacl, BOOL bDaclDefaulted); + + WINPR_API BOOL GetSecurityDescriptorGroup(PSECURITY_DESCRIPTOR pSecurityDescriptor, + PSID* pGroup, LPBOOL lpbGroupDefaulted); + WINPR_API BOOL SetSecurityDescriptorGroup(PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID pGroup, + BOOL bGroupDefaulted); + + WINPR_API BOOL GetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR pSecurityDescriptor, + PSID* pOwner, LPBOOL lpbOwnerDefaulted); + WINPR_API BOOL SetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID pOwner, + BOOL bOwnerDefaulted); + + WINPR_API DWORD GetSecurityDescriptorRMControl(PSECURITY_DESCRIPTOR SecurityDescriptor, + PUCHAR RMControl); + WINPR_API DWORD SetSecurityDescriptorRMControl(PSECURITY_DESCRIPTOR SecurityDescriptor, + PUCHAR RMControl); + + WINPR_API BOOL GetSecurityDescriptorSacl(PSECURITY_DESCRIPTOR pSecurityDescriptor, + LPBOOL lpbSaclPresent, PACL* pSacl, + LPBOOL lpbSaclDefaulted); + WINPR_API BOOL SetSecurityDescriptorSacl(PSECURITY_DESCRIPTOR pSecurityDescriptor, + BOOL bSaclPresent, PACL pSacl, BOOL bSaclDefaulted); + +#ifdef __cplusplus +} +#endif + +#endif + +#endif /* WINPR_SECURITY_H */ diff --git a/winpr/include/winpr/shell.h b/winpr/include/winpr/shell.h new file mode 100644 index 0000000..376ebb1 --- /dev/null +++ b/winpr/include/winpr/shell.h @@ -0,0 +1,108 @@ +/** + * WinPR: Windows Portable Runtime + * Shell Functions + * + * Copyright 2015 Dell Software <Mike.McDonald@software.dell.com> + * Copyright 2016 David PHAM-VAN <d.phamvan@inuvika.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_SHELL_H +#define WINPR_SHELL_H + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <winpr/winpr.h> +#include <winpr/wtypes.h> + +#ifdef _WIN32 + +#include <shlobj.h> +#include <userenv.h> + +#else + +/* Shell clipboard formats */ +typedef struct +{ + DWORD dwFlags; + CLSID clsid; + SIZEL sizel; + POINTL pointl; + DWORD dwFileAttributes; + FILETIME ftCreationTime; + FILETIME ftLastAccessTime; + FILETIME ftLastWriteTime; + DWORD nFileSizeHigh; + DWORD nFileSizeLow; + WCHAR cFileName[260]; +} FILEDESCRIPTORW; + +/* Legacy definition, some types do not match the windows equivalent. */ +typedef struct +{ + DWORD dwFlags; + BYTE clsid[16]; + BYTE sizel[8]; + BYTE pointl[8]; + DWORD dwFileAttributes; + FILETIME ftCreationTime; + FILETIME ftLastAccessTime; + FILETIME ftLastWriteTime; + DWORD nFileSizeHigh; + DWORD nFileSizeLow; + WCHAR cFileName[260]; +} FILEDESCRIPTOR; + +/* FILEDESCRIPTOR.dwFlags */ +typedef enum +{ + FD_CLSID = 0x00000001, + FD_SIZEPOINT = 0x00000002, + FD_ATTRIBUTES = 0x00000004, + FD_CREATETIME = 0x00000008, + FD_ACCESSTIME = 0x00000010, + FD_WRITESTIME = 0x00000020, + FD_FILESIZE = 0x00000040, + FD_PROGRESSUI = 0x00004000, + FD_LINKUI = 0x00008000, +} FD_FLAGS; +#define FD_UNICODE 0x80000000 + +/* Deprecated, here for compatibility */ +#define FD_SHOWPROGRESSUI FD_PROGRESSUI + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API BOOL GetUserProfileDirectoryA(HANDLE hToken, LPSTR lpProfileDir, LPDWORD lpcchSize); + + WINPR_API BOOL GetUserProfileDirectoryW(HANDLE hToken, LPWSTR lpProfileDir, LPDWORD lpcchSize); + +#ifdef __cplusplus +} +#endif + +#ifdef UNICODE +#define GetUserProfileDirectory GetUserProfileDirectoryW +#else +#define GetUserProfileDirectory GetUserProfileDirectoryA +#endif + +#endif + +#endif /* WINPR_SHELL_H */ diff --git a/winpr/include/winpr/smartcard.h b/winpr/include/winpr/smartcard.h new file mode 100644 index 0000000..278786c --- /dev/null +++ b/winpr/include/winpr/smartcard.h @@ -0,0 +1,1217 @@ +/** + * WinPR: Windows Portable Runtime + * Smart Card API + * + * Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * Copyright 2020 Armin Novak <armin.novak@thincast.com> + * Copyright 2020 Thincast Technologies GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_SMARTCARD_H +#define WINPR_SMARTCARD_H + +#include <winpr/platform.h> +#include <winpr/winpr.h> +#include <winpr/wtypes.h> + +#include <winpr/io.h> +#include <winpr/error.h> + +WINPR_PRAGMA_DIAG_PUSH +WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO + +#ifndef _WINSCARD_H_ +#define _WINSCARD_H_ /* do not include winscard.h */ +#endif + +WINPR_PRAGMA_DIAG_POP + +#ifndef SCARD_S_SUCCESS + +#define SCARD_S_SUCCESS NO_ERROR + +#define SCARD_F_INTERNAL_ERROR -2146435071l // (0x80100001L) +#define SCARD_E_CANCELLED -2146435070l // (0x80100002L) +#define SCARD_E_INVALID_HANDLE -2146435069l // (0x80100003L) +#define SCARD_E_INVALID_PARAMETER -2146435068l // (0x80100004L) +#define SCARD_E_INVALID_TARGET -2146435067l // (0x80100005L) +#define SCARD_E_NO_MEMORY -2146435066l // (0x80100006L) +#define SCARD_F_WAITED_TOO_LONG -2146435065l // (0x80100007L) +#define SCARD_E_INSUFFICIENT_BUFFER -2146435064l // (0x80100008L) +#define SCARD_E_UNKNOWN_READER -2146435063l // (0x80100009L) +#define SCARD_E_TIMEOUT -2146435062l // (0x8010000AL) +#define SCARD_E_SHARING_VIOLATION -2146435061l // (0x8010000BL) +#define SCARD_E_NO_SMARTCARD -2146435060l // (0x8010000CL) +#define SCARD_E_UNKNOWN_CARD -2146435059l // (0x8010000DL) +#define SCARD_E_CANT_DISPOSE -2146435058l // (0x8010000EL) +#define SCARD_E_PROTO_MISMATCH -2146435057l // (0x8010000FL) +#define SCARD_E_NOT_READY -2146435056l // (0x80100010L) +#define SCARD_E_INVALID_VALUE -2146435055l // (0x80100011L) +#define SCARD_E_SYSTEM_CANCELLED -2146435054l // (0x80100012L) +#define SCARD_F_COMM_ERROR -2146435053l // (0x80100013L) +#define SCARD_F_UNKNOWN_ERROR -2146435052l // (0x80100014L) +#define SCARD_E_INVALID_ATR -2146435051l // (0x80100015L) +#define SCARD_E_NOT_TRANSACTED -2146435050l // (0x80100016L) +#define SCARD_E_READER_UNAVAILABLE -2146435049l // (0x80100017L) +#define SCARD_P_SHUTDOWN -2146435048l // (0x80100018L) +#define SCARD_E_PCI_TOO_SMALL -2146435047l // (0x80100019L) +#define SCARD_E_READER_UNSUPPORTED -2146435046l // (0x8010001AL) +#define SCARD_E_DUPLICATE_READER -2146435045l // (0x8010001BL) +#define SCARD_E_CARD_UNSUPPORTED -2146435044l // (0x8010001CL) +#define SCARD_E_NO_SERVICE -2146435043l // (0x8010001DL) +#define SCARD_E_SERVICE_STOPPED -2146435042l // (0x8010001EL) +#define SCARD_E_UNEXPECTED -2146435041l // (0x8010001FL) +#define SCARD_E_ICC_INSTALLATION -2146435040l // (0x80100020L) +#define SCARD_E_ICC_CREATEORDER -2146435039l // (0x80100021L) +#define SCARD_E_UNSUPPORTED_FEATURE -2146435038l // (0x80100022L) +#define SCARD_E_DIR_NOT_FOUND -2146435037l // (0x80100023L) +#define SCARD_E_FILE_NOT_FOUND -2146435036l // (0x80100024L) +#define SCARD_E_NO_DIR -2146435035l // (0x80100025L) +#define SCARD_E_NO_FILE -2146435034l // (0x80100026L) +#define SCARD_E_NO_ACCESS -2146435033l // (0x80100027L) +#define SCARD_E_WRITE_TOO_MANY -2146435032l // (0x80100028L) +#define SCARD_E_BAD_SEEK -2146435031l // (0x80100029L) +#define SCARD_E_INVALID_CHV -2146435030l // (0x8010002AL) +#define SCARD_E_UNKNOWN_RES_MNG -2146435029l // (0x8010002BL) +#define SCARD_E_NO_SUCH_CERTIFICATE -2146435028l // (0x8010002CL) +#define SCARD_E_CERTIFICATE_UNAVAILABLE -2146435027l // (0x8010002DL) +#define SCARD_E_NO_READERS_AVAILABLE -2146435026l // (0x8010002EL) +#define SCARD_E_COMM_DATA_LOST -2146435025l // (0x8010002FL) +#define SCARD_E_NO_KEY_CONTAINER -2146435024l // (0x80100030L) +#define SCARD_E_SERVER_TOO_BUSY -2146435023l // (0x80100031L) +#define SCARD_E_PIN_CACHE_EXPIRED -2146435022l // (0x80100032L) +#define SCARD_E_NO_PIN_CACHE -2146435021l // (0x80100033L) +#define SCARD_E_READ_ONLY_CARD -2146435020l // (0x80100034L) + +#define SCARD_W_UNSUPPORTED_CARD -2146434971l // (0x80100065L) +#define SCARD_W_UNRESPONSIVE_CARD -2146434970l // (0x80100066L) +#define SCARD_W_UNPOWERED_CARD -2146434969l // (0x80100067L) +#define SCARD_W_RESET_CARD -2146434968l // (0x80100068L) +#define SCARD_W_REMOVED_CARD -2146434967l // (0x80100069L) +#define SCARD_W_SECURITY_VIOLATION -2146434966l // (0x8010006AL) +#define SCARD_W_WRONG_CHV -2146434965l // (0x8010006BL) +#define SCARD_W_CHV_BLOCKED -2146434964l // (0x8010006CL) +#define SCARD_W_EOF -2146434963l // (0x8010006DL) +#define SCARD_W_CANCELLED_BY_USER -2146434962l // (0x8010006EL) +#define SCARD_W_CARD_NOT_AUTHENTICATED -2146434961l // (0x8010006FL) +#define SCARD_W_CACHE_ITEM_NOT_FOUND -2146434960l // (0x80100070L) +#define SCARD_W_CACHE_ITEM_STALE -2146434959l // (0x80100071L) +#define SCARD_W_CACHE_ITEM_TOO_BIG -2146434958l // (0x80100072L) + +#endif + +/* ------------------------ missing definition with mingw --------------------*/ +#ifndef SCARD_E_PIN_CACHE_EXPIRED +#define SCARD_E_PIN_CACHE_EXPIRED -2146435022l // (0x80100032L) +#endif + +#ifndef SCARD_E_NO_PIN_CACHE +#define SCARD_E_NO_PIN_CACHE -2146435021l // (0x80100033L) +#endif + +#ifndef SCARD_E_READ_ONLY_CARD +#define SCARD_E_READ_ONLY_CARD -2146435020l // (0x80100034L) +#endif + +#ifndef SCARD_W_CACHE_ITEM_TOO_BIG +#define SCARD_W_CACHE_ITEM_TOO_BIG -2146434958l // (0x80100072L) +#endif +/* -------------------------------------------------------------------------- */ + +#define SCARD_ATR_LENGTH 33 + +#define SCARD_PROTOCOL_UNDEFINED 0x00000000u +#define SCARD_PROTOCOL_T0 0x00000001u +#define SCARD_PROTOCOL_T1 0x00000002u +#define SCARD_PROTOCOL_RAW 0x00010000u + +#define SCARD_PROTOCOL_Tx (SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1) +#define SCARD_PROTOCOL_DEFAULT 0x80000000u +#define SCARD_PROTOCOL_OPTIMAL 0x00000000u + +#define SCARD_POWER_DOWN 0 +#define SCARD_COLD_RESET 1 +#define SCARD_WARM_RESET 2 + +#define SCARD_CTL_CODE(code) \ + CTL_CODE(FILE_DEVICE_SMARTCARD, (code), METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define IOCTL_SMARTCARD_POWER SCARD_CTL_CODE(1) +#define IOCTL_SMARTCARD_GET_ATTRIBUTE SCARD_CTL_CODE(2) +#define IOCTL_SMARTCARD_SET_ATTRIBUTE SCARD_CTL_CODE(3) +#define IOCTL_SMARTCARD_CONFISCATE SCARD_CTL_CODE(4) +#define IOCTL_SMARTCARD_TRANSMIT SCARD_CTL_CODE(5) +#define IOCTL_SMARTCARD_EJECT SCARD_CTL_CODE(6) +#define IOCTL_SMARTCARD_SWALLOW SCARD_CTL_CODE(7) +#define IOCTL_SMARTCARD_IS_PRESENT SCARD_CTL_CODE(10) +#define IOCTL_SMARTCARD_IS_ABSENT SCARD_CTL_CODE(11) +#define IOCTL_SMARTCARD_SET_PROTOCOL SCARD_CTL_CODE(12) +#define IOCTL_SMARTCARD_GET_STATE SCARD_CTL_CODE(14) +#define IOCTL_SMARTCARD_GET_LAST_ERROR SCARD_CTL_CODE(15) +#define IOCTL_SMARTCARD_GET_PERF_CNTR SCARD_CTL_CODE(16) + +#define IOCTL_SMARTCARD_GET_FEATURE_REQUEST SCARD_CTL_CODE(3400) + +#define MAXIMUM_ATTR_STRING_LENGTH 32 +#define MAXIMUM_SMARTCARD_READERS 10 + +#define SCARD_ATTR_VALUE(Class, Tag) ((((ULONG)(Class)) << 16) | ((ULONG)(Tag))) + +#define SCARD_CLASS_VENDOR_INFO 1 +#define SCARD_CLASS_COMMUNICATIONS 2 +#define SCARD_CLASS_PROTOCOL 3 +#define SCARD_CLASS_POWER_MGMT 4 +#define SCARD_CLASS_SECURITY 5 +#define SCARD_CLASS_MECHANICAL 6 +#define SCARD_CLASS_VENDOR_DEFINED 7 +#define SCARD_CLASS_IFD_PROTOCOL 8 +#define SCARD_CLASS_ICC_STATE 9 +#define SCARD_CLASS_PERF 0x7FFE +#define SCARD_CLASS_SYSTEM 0x7FFF + +#define SCARD_ATTR_VENDOR_NAME SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_INFO, 0x0100) +#define SCARD_ATTR_VENDOR_IFD_TYPE SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_INFO, 0x0101) +#define SCARD_ATTR_VENDOR_IFD_VERSION SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_INFO, 0x0102) +#define SCARD_ATTR_VENDOR_IFD_SERIAL_NO SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_INFO, 0x0103) +#define SCARD_ATTR_CHANNEL_ID SCARD_ATTR_VALUE(SCARD_CLASS_COMMUNICATIONS, 0x0110) +#define SCARD_ATTR_PROTOCOL_TYPES SCARD_ATTR_VALUE(SCARD_CLASS_PROTOCOL, 0x0120) +#define SCARD_ATTR_DEFAULT_CLK SCARD_ATTR_VALUE(SCARD_CLASS_PROTOCOL, 0x0121) +#define SCARD_ATTR_MAX_CLK SCARD_ATTR_VALUE(SCARD_CLASS_PROTOCOL, 0x0122) +#define SCARD_ATTR_DEFAULT_DATA_RATE SCARD_ATTR_VALUE(SCARD_CLASS_PROTOCOL, 0x0123) +#define SCARD_ATTR_MAX_DATA_RATE SCARD_ATTR_VALUE(SCARD_CLASS_PROTOCOL, 0x0124) +#define SCARD_ATTR_MAX_IFSD SCARD_ATTR_VALUE(SCARD_CLASS_PROTOCOL, 0x0125) +#define SCARD_ATTR_POWER_MGMT_SUPPORT SCARD_ATTR_VALUE(SCARD_CLASS_POWER_MGMT, 0x0131) +#define SCARD_ATTR_USER_TO_CARD_AUTH_DEVICE SCARD_ATTR_VALUE(SCARD_CLASS_SECURITY, 0x0140) +#define SCARD_ATTR_USER_AUTH_INPUT_DEVICE SCARD_ATTR_VALUE(SCARD_CLASS_SECURITY, 0x0142) +#define SCARD_ATTR_CHARACTERISTICS SCARD_ATTR_VALUE(SCARD_CLASS_MECHANICAL, 0x0150) + +#define SCARD_ATTR_CURRENT_PROTOCOL_TYPE SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0201) +#define SCARD_ATTR_CURRENT_CLK SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0202) +#define SCARD_ATTR_CURRENT_F SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0203) +#define SCARD_ATTR_CURRENT_D SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0204) +#define SCARD_ATTR_CURRENT_N SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0205) +#define SCARD_ATTR_CURRENT_W SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0206) +#define SCARD_ATTR_CURRENT_IFSC SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0207) +#define SCARD_ATTR_CURRENT_IFSD SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0208) +#define SCARD_ATTR_CURRENT_BWT SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x0209) +#define SCARD_ATTR_CURRENT_CWT SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x020a) +#define SCARD_ATTR_CURRENT_EBC_ENCODING SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x020b) +#define SCARD_ATTR_EXTENDED_BWT SCARD_ATTR_VALUE(SCARD_CLASS_IFD_PROTOCOL, 0x020c) + +#define SCARD_ATTR_ICC_PRESENCE SCARD_ATTR_VALUE(SCARD_CLASS_ICC_STATE, 0x0300) +#define SCARD_ATTR_ICC_INTERFACE_STATUS SCARD_ATTR_VALUE(SCARD_CLASS_ICC_STATE, 0x0301) +#define SCARD_ATTR_CURRENT_IO_STATE SCARD_ATTR_VALUE(SCARD_CLASS_ICC_STATE, 0x0302) +#define SCARD_ATTR_ATR_STRING SCARD_ATTR_VALUE(SCARD_CLASS_ICC_STATE, 0x0303) +#define SCARD_ATTR_ICC_TYPE_PER_ATR SCARD_ATTR_VALUE(SCARD_CLASS_ICC_STATE, 0x0304) + +#define SCARD_ATTR_ESC_RESET SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_DEFINED, 0xA000) +#define SCARD_ATTR_ESC_CANCEL SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_DEFINED, 0xA003) +#define SCARD_ATTR_ESC_AUTHREQUEST SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_DEFINED, 0xA005) +#define SCARD_ATTR_MAXINPUT SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_DEFINED, 0xA007) + +#define SCARD_ATTR_DEVICE_UNIT SCARD_ATTR_VALUE(SCARD_CLASS_SYSTEM, 0x0001) +#define SCARD_ATTR_DEVICE_IN_USE SCARD_ATTR_VALUE(SCARD_CLASS_SYSTEM, 0x0002) +#define SCARD_ATTR_DEVICE_FRIENDLY_NAME_A SCARD_ATTR_VALUE(SCARD_CLASS_SYSTEM, 0x0003) +#define SCARD_ATTR_DEVICE_SYSTEM_NAME_A SCARD_ATTR_VALUE(SCARD_CLASS_SYSTEM, 0x0004) +#define SCARD_ATTR_DEVICE_FRIENDLY_NAME_W SCARD_ATTR_VALUE(SCARD_CLASS_SYSTEM, 0x0005) +#define SCARD_ATTR_DEVICE_SYSTEM_NAME_W SCARD_ATTR_VALUE(SCARD_CLASS_SYSTEM, 0x0006) +#define SCARD_ATTR_SUPRESS_T1_IFS_REQUEST SCARD_ATTR_VALUE(SCARD_CLASS_SYSTEM, 0x0007) + +#define SCARD_PERF_NUM_TRANSMISSIONS SCARD_ATTR_VALUE(SCARD_CLASS_PERF, 0x0001) +#define SCARD_PERF_BYTES_TRANSMITTED SCARD_ATTR_VALUE(SCARD_CLASS_PERF, 0x0002) +#define SCARD_PERF_TRANSMISSION_TIME SCARD_ATTR_VALUE(SCARD_CLASS_PERF, 0x0003) + +#ifdef UNICODE +#define SCARD_ATTR_DEVICE_FRIENDLY_NAME SCARD_ATTR_DEVICE_FRIENDLY_NAME_W +#define SCARD_ATTR_DEVICE_SYSTEM_NAME SCARD_ATTR_DEVICE_SYSTEM_NAME_W +#else +#define SCARD_ATTR_DEVICE_FRIENDLY_NAME SCARD_ATTR_DEVICE_FRIENDLY_NAME_A +#define SCARD_ATTR_DEVICE_SYSTEM_NAME SCARD_ATTR_DEVICE_SYSTEM_NAME_A +#endif + +#define SCARD_T0_HEADER_LENGTH 7 +#define SCARD_T0_CMD_LENGTH 5 + +#define SCARD_T1_PROLOGUE_LENGTH 3 +#define SCARD_T1_EPILOGUE_LENGTH 2 +#define SCARD_T1_MAX_IFS 254 + +#define SCARD_UNKNOWN 0 +#define SCARD_ABSENT 1 +#define SCARD_PRESENT 2 +#define SCARD_SWALLOWED 3 +#define SCARD_POWERED 4 +#define SCARD_NEGOTIABLE 5 +#define SCARD_SPECIFIC 6 + +#pragma pack(push, 1) + +typedef struct +{ + DWORD dwProtocol; + DWORD cbPciLength; +} SCARD_IO_REQUEST, *PSCARD_IO_REQUEST, *LPSCARD_IO_REQUEST; +typedef const SCARD_IO_REQUEST* LPCSCARD_IO_REQUEST; + +typedef struct +{ + BYTE bCla, bIns, bP1, bP2, bP3; +} SCARD_T0_COMMAND, *LPSCARD_T0_COMMAND; + +typedef struct +{ + SCARD_IO_REQUEST ioRequest; + BYTE bSw1, bSw2; + union + { + SCARD_T0_COMMAND CmdBytes; + BYTE rgbHeader[5]; + } DUMMYUNIONNAME; +} SCARD_T0_REQUEST; + +typedef SCARD_T0_REQUEST *PSCARD_T0_REQUEST, *LPSCARD_T0_REQUEST; + +typedef struct +{ + SCARD_IO_REQUEST ioRequest; +} SCARD_T1_REQUEST; +typedef SCARD_T1_REQUEST *PSCARD_T1_REQUEST, *LPSCARD_T1_REQUEST; + +#define SCARD_READER_SWALLOWS 0x00000001 +#define SCARD_READER_EJECTS 0x00000002 +#define SCARD_READER_CONFISCATES 0x00000004 + +#define SCARD_READER_TYPE_SERIAL 0x01 +#define SCARD_READER_TYPE_PARALELL 0x02 +#define SCARD_READER_TYPE_KEYBOARD 0x04 +#define SCARD_READER_TYPE_SCSI 0x08 +#define SCARD_READER_TYPE_IDE 0x10 +#define SCARD_READER_TYPE_USB 0x20 +#define SCARD_READER_TYPE_PCMCIA 0x40 +#define SCARD_READER_TYPE_TPM 0x80 +#define SCARD_READER_TYPE_NFC 0x100 +#define SCARD_READER_TYPE_UICC 0x200 +#define SCARD_READER_TYPE_VENDOR 0xF0 + +#ifndef WINSCARDAPI +#define WINSCARDAPI WINPR_API +#endif + +typedef ULONG_PTR SCARDCONTEXT; +typedef SCARDCONTEXT *PSCARDCONTEXT, *LPSCARDCONTEXT; + +typedef ULONG_PTR SCARDHANDLE; +typedef SCARDHANDLE *PSCARDHANDLE, *LPSCARDHANDLE; + +#define SCARD_AUTOALLOCATE (DWORD)(-1) + +#define SCARD_SCOPE_USER 0 +#define SCARD_SCOPE_TERMINAL 1 +#define SCARD_SCOPE_SYSTEM 2 + +#define SCARD_STATE_UNAWARE 0x00000000 +#define SCARD_STATE_IGNORE 0x00000001 +#define SCARD_STATE_CHANGED 0x00000002 +#define SCARD_STATE_UNKNOWN 0x00000004 +#define SCARD_STATE_UNAVAILABLE 0x00000008 +#define SCARD_STATE_EMPTY 0x00000010 +#define SCARD_STATE_PRESENT 0x00000020 +#define SCARD_STATE_ATRMATCH 0x00000040 +#define SCARD_STATE_EXCLUSIVE 0x00000080 +#define SCARD_STATE_INUSE 0x00000100 +#define SCARD_STATE_MUTE 0x00000200 +#define SCARD_STATE_UNPOWERED 0x00000400 + +#define SCARD_SHARE_EXCLUSIVE 1 +#define SCARD_SHARE_SHARED 2 +#define SCARD_SHARE_DIRECT 3 + +#define SCARD_LEAVE_CARD 0 +#define SCARD_RESET_CARD 1 +#define SCARD_UNPOWER_CARD 2 +#define SCARD_EJECT_CARD 3 + +#define SC_DLG_MINIMAL_UI 0x01 +#define SC_DLG_NO_UI 0x02 +#define SC_DLG_FORCE_UI 0x04 + +#define SCERR_NOCARDNAME 0x4000 +#define SCERR_NOGUIDS 0x8000 + +typedef SCARDHANDLE(WINAPI* LPOCNCONNPROCA)(SCARDCONTEXT hSCardContext, LPSTR szReader, + LPSTR mszCards, PVOID pvUserData); +typedef SCARDHANDLE(WINAPI* LPOCNCONNPROCW)(SCARDCONTEXT hSCardContext, LPWSTR szReader, + LPWSTR mszCards, PVOID pvUserData); + +typedef BOOL(WINAPI* LPOCNCHKPROC)(SCARDCONTEXT hSCardContext, SCARDHANDLE hCard, PVOID pvUserData); +typedef void(WINAPI* LPOCNDSCPROC)(SCARDCONTEXT hSCardContext, SCARDHANDLE hCard, PVOID pvUserData); + +#define SCARD_READER_SEL_AUTH_PACKAGE ((DWORD)-629) + +#define SCARD_AUDIT_CHV_FAILURE 0x0 +#define SCARD_AUDIT_CHV_SUCCESS 0x1 + +#define SCardListCardTypes SCardListCards + +#define PCSCardIntroduceCardType(hContext, szCardName, pbAtr, pbAtrMask, cbAtrLen, \ + pguidPrimaryProvider, rgguidInterfaces, dwInterfaceCount) \ + SCardIntroduceCardType(hContext, szCardName, pguidPrimaryProvider, rgguidInterfaces, \ + dwInterfaceCount, pbAtr, pbAtrMask, cbAtrLen) + +#define SCardGetReaderCapabilities SCardGetAttrib +#define SCardSetReaderCapabilities SCardSetAttrib + +typedef struct +{ + LPSTR szReader; + LPVOID pvUserData; + DWORD dwCurrentState; + DWORD dwEventState; + DWORD cbAtr; + BYTE rgbAtr[36]; +} SCARD_READERSTATEA, *PSCARD_READERSTATEA, *LPSCARD_READERSTATEA; + +typedef struct +{ + LPWSTR szReader; + LPVOID pvUserData; + DWORD dwCurrentState; + DWORD dwEventState; + DWORD cbAtr; + BYTE rgbAtr[36]; +} SCARD_READERSTATEW, *PSCARD_READERSTATEW, *LPSCARD_READERSTATEW; + +typedef struct +{ + DWORD cbAtr; + BYTE rgbAtr[36]; + BYTE rgbMask[36]; +} SCARD_ATRMASK, *PSCARD_ATRMASK, *LPSCARD_ATRMASK; + +typedef struct +{ + DWORD dwStructSize; + LPSTR lpstrGroupNames; + DWORD nMaxGroupNames; + LPCGUID rgguidInterfaces; + DWORD cguidInterfaces; + LPSTR lpstrCardNames; + DWORD nMaxCardNames; + LPOCNCHKPROC lpfnCheck; + LPOCNCONNPROCA lpfnConnect; + LPOCNDSCPROC lpfnDisconnect; + LPVOID pvUserData; + DWORD dwShareMode; + DWORD dwPreferredProtocols; +} OPENCARD_SEARCH_CRITERIAA, *POPENCARD_SEARCH_CRITERIAA, *LPOPENCARD_SEARCH_CRITERIAA; + +typedef struct +{ + DWORD dwStructSize; + LPWSTR lpstrGroupNames; + DWORD nMaxGroupNames; + LPCGUID rgguidInterfaces; + DWORD cguidInterfaces; + LPWSTR lpstrCardNames; + DWORD nMaxCardNames; + LPOCNCHKPROC lpfnCheck; + LPOCNCONNPROCW lpfnConnect; + LPOCNDSCPROC lpfnDisconnect; + LPVOID pvUserData; + DWORD dwShareMode; + DWORD dwPreferredProtocols; +} OPENCARD_SEARCH_CRITERIAW, *POPENCARD_SEARCH_CRITERIAW, *LPOPENCARD_SEARCH_CRITERIAW; + +typedef struct +{ + DWORD dwStructSize; + SCARDCONTEXT hSCardContext; + HWND hwndOwner; + DWORD dwFlags; + LPCSTR lpstrTitle; + LPCSTR lpstrSearchDesc; + HICON hIcon; + POPENCARD_SEARCH_CRITERIAA pOpenCardSearchCriteria; + LPOCNCONNPROCA lpfnConnect; + LPVOID pvUserData; + DWORD dwShareMode; + DWORD dwPreferredProtocols; + LPSTR lpstrRdr; + DWORD nMaxRdr; + LPSTR lpstrCard; + DWORD nMaxCard; + DWORD dwActiveProtocol; + SCARDHANDLE hCardHandle; +} OPENCARDNAME_EXA, *POPENCARDNAME_EXA, *LPOPENCARDNAME_EXA; + +typedef struct +{ + DWORD dwStructSize; + SCARDCONTEXT hSCardContext; + HWND hwndOwner; + DWORD dwFlags; + LPCWSTR lpstrTitle; + LPCWSTR lpstrSearchDesc; + HICON hIcon; + POPENCARD_SEARCH_CRITERIAW pOpenCardSearchCriteria; + LPOCNCONNPROCW lpfnConnect; + LPVOID pvUserData; + DWORD dwShareMode; + DWORD dwPreferredProtocols; + LPWSTR lpstrRdr; + DWORD nMaxRdr; + LPWSTR lpstrCard; + DWORD nMaxCard; + DWORD dwActiveProtocol; + SCARDHANDLE hCardHandle; +} OPENCARDNAME_EXW, *POPENCARDNAME_EXW, *LPOPENCARDNAME_EXW; + +#define OPENCARDNAMEA_EX OPENCARDNAME_EXA +#define OPENCARDNAMEW_EX OPENCARDNAME_EXW +#define POPENCARDNAMEA_EX POPENCARDNAME_EXA +#define POPENCARDNAMEW_EX POPENCARDNAME_EXW +#define LPOPENCARDNAMEA_EX LPOPENCARDNAME_EXA +#define LPOPENCARDNAMEW_EX LPOPENCARDNAME_EXW + +typedef enum +{ + RSR_MATCH_TYPE_READER_AND_CONTAINER = 1, + RSR_MATCH_TYPE_SERIAL_NUMBER, + RSR_MATCH_TYPE_ALL_CARDS +} READER_SEL_REQUEST_MATCH_TYPE; + +typedef struct +{ + DWORD dwShareMode; + DWORD dwPreferredProtocols; + READER_SEL_REQUEST_MATCH_TYPE MatchType; + union + { + struct + { + DWORD cbReaderNameOffset; + DWORD cchReaderNameLength; + DWORD cbContainerNameOffset; + DWORD cchContainerNameLength; + DWORD dwDesiredCardModuleVersion; + DWORD dwCspFlags; + } ReaderAndContainerParameter; + struct + { + DWORD cbSerialNumberOffset; + DWORD cbSerialNumberLength; + DWORD dwDesiredCardModuleVersion; + } SerialNumberParameter; + }; +} READER_SEL_REQUEST, *PREADER_SEL_REQUEST; + +typedef struct +{ + DWORD cbReaderNameOffset; + DWORD cchReaderNameLength; + DWORD cbCardNameOffset; + DWORD cchCardNameLength; +} READER_SEL_RESPONSE, *PREADER_SEL_RESPONSE; + +typedef struct +{ + DWORD dwStructSize; + HWND hwndOwner; + SCARDCONTEXT hSCardContext; + LPSTR lpstrGroupNames; + DWORD nMaxGroupNames; + LPSTR lpstrCardNames; + DWORD nMaxCardNames; + LPCGUID rgguidInterfaces; + DWORD cguidInterfaces; + LPSTR lpstrRdr; + DWORD nMaxRdr; + LPSTR lpstrCard; + DWORD nMaxCard; + LPCSTR lpstrTitle; + DWORD dwFlags; + LPVOID pvUserData; + DWORD dwShareMode; + DWORD dwPreferredProtocols; + DWORD dwActiveProtocol; + LPOCNCONNPROCA lpfnConnect; + LPOCNCHKPROC lpfnCheck; + LPOCNDSCPROC lpfnDisconnect; + SCARDHANDLE hCardHandle; +} OPENCARDNAMEA, *POPENCARDNAMEA, *LPOPENCARDNAMEA; + +typedef struct +{ + DWORD dwStructSize; + HWND hwndOwner; + SCARDCONTEXT hSCardContext; + LPWSTR lpstrGroupNames; + DWORD nMaxGroupNames; + LPWSTR lpstrCardNames; + DWORD nMaxCardNames; + LPCGUID rgguidInterfaces; + DWORD cguidInterfaces; + LPWSTR lpstrRdr; + DWORD nMaxRdr; + LPWSTR lpstrCard; + DWORD nMaxCard; + LPCWSTR lpstrTitle; + DWORD dwFlags; + LPVOID pvUserData; + DWORD dwShareMode; + DWORD dwPreferredProtocols; + DWORD dwActiveProtocol; + LPOCNCONNPROCW lpfnConnect; + LPOCNCHKPROC lpfnCheck; + LPOCNDSCPROC lpfnDisconnect; + SCARDHANDLE hCardHandle; +} OPENCARDNAMEW, *POPENCARDNAMEW, *LPOPENCARDNAMEW; + +#pragma pack(pop) + +#ifdef UNICODE +#define LPOCNCONNPROC LPOCNCONNPROCW +#define SCARD_READERSTATE SCARD_READERSTATEW +#define PSCARD_READERSTATE PSCARD_READERSTATEW +#define LPSCARD_READERSTATE LPSCARD_READERSTATEW +#define OPENCARD_SEARCH_CRITERIA OPENCARD_SEARCH_CRITERIAW +#define LOPENCARD_SEARCH_CRITERIA LOPENCARD_SEARCH_CRITERIAW +#define LPOPENCARD_SEARCH_CRITERIA LPOPENCARD_SEARCH_CRITERIAW +#define OPENCARDNAME_EX OPENCARDNAME_EXW +#define LOPENCARDNAME_EX LOPENCARDNAME_EXW +#define LPOPENCARDNAME_EX LPOPENCARDNAME_EXW +#define OPENCARDNAME OPENCARDNAMEW +#define LOPENCARDNAME LOPENCARDNAMEW +#define LPOPENCARDNAME LPOPENCARDNAMEW +#else +#define LPOCNCONNPROC LPOCNCONNPROCA +#define SCARD_READERSTATE SCARD_READERSTATEA +#define PSCARD_READERSTATE PSCARD_READERSTATEA +#define LPSCARD_READERSTATE LPSCARD_READERSTATEA +#define OPENCARD_SEARCH_CRITERIA OPENCARD_SEARCH_CRITERIAA +#define LOPENCARD_SEARCH_CRITERIA LOPENCARD_SEARCH_CRITERIAA +#define LPOPENCARD_SEARCH_CRITERIA LPOPENCARD_SEARCH_CRITERIAA +#define OPENCARDNAME_EX OPENCARDNAME_EXA +#define LOPENCARDNAME_EX LOPENCARDNAME_EXA +#define LPOPENCARDNAME_EX LPOPENCARDNAME_EXA +#define OPENCARDNAME OPENCARDNAMEA +#define LOPENCARDNAME LOPENCARDNAMEA +#define LPOPENCARDNAME LPOPENCARDNAMEA +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API extern const SCARD_IO_REQUEST g_rgSCardT0Pci; + WINPR_API extern const SCARD_IO_REQUEST g_rgSCardT1Pci; + WINPR_API extern const SCARD_IO_REQUEST g_rgSCardRawPci; + +#define SCARD_PCI_T0 (&g_rgSCardT0Pci) +#define SCARD_PCI_T1 (&g_rgSCardT1Pci) +#define SCARD_PCI_RAW (&g_rgSCardRawPci) + + WINSCARDAPI LONG WINAPI SCardEstablishContext(DWORD dwScope, LPCVOID pvReserved1, + LPCVOID pvReserved2, LPSCARDCONTEXT phContext); + + WINSCARDAPI LONG WINAPI SCardReleaseContext(SCARDCONTEXT hContext); + + WINSCARDAPI LONG WINAPI SCardIsValidContext(SCARDCONTEXT hContext); + + WINSCARDAPI LONG WINAPI SCardListReaderGroupsA(SCARDCONTEXT hContext, LPSTR mszGroups, + LPDWORD pcchGroups); + WINSCARDAPI LONG WINAPI SCardListReaderGroupsW(SCARDCONTEXT hContext, LPWSTR mszGroups, + LPDWORD pcchGroups); + + WINSCARDAPI LONG WINAPI SCardListReadersA(SCARDCONTEXT hContext, LPCSTR mszGroups, + LPSTR mszReaders, LPDWORD pcchReaders); + WINSCARDAPI LONG WINAPI SCardListReadersW(SCARDCONTEXT hContext, LPCWSTR mszGroups, + LPWSTR mszReaders, LPDWORD pcchReaders); + + WINSCARDAPI LONG WINAPI SCardListCardsA(SCARDCONTEXT hContext, LPCBYTE pbAtr, + LPCGUID rgquidInterfaces, DWORD cguidInterfaceCount, + CHAR* mszCards, LPDWORD pcchCards); + + WINSCARDAPI LONG WINAPI SCardListCardsW(SCARDCONTEXT hContext, LPCBYTE pbAtr, + LPCGUID rgquidInterfaces, DWORD cguidInterfaceCount, + WCHAR* mszCards, LPDWORD pcchCards); + + WINSCARDAPI LONG WINAPI SCardListInterfacesA(SCARDCONTEXT hContext, LPCSTR szCard, + LPGUID pguidInterfaces, LPDWORD pcguidInterfaces); + WINSCARDAPI LONG WINAPI SCardListInterfacesW(SCARDCONTEXT hContext, LPCWSTR szCard, + LPGUID pguidInterfaces, LPDWORD pcguidInterfaces); + + WINSCARDAPI LONG WINAPI SCardGetProviderIdA(SCARDCONTEXT hContext, LPCSTR szCard, + LPGUID pguidProviderId); + WINSCARDAPI LONG WINAPI SCardGetProviderIdW(SCARDCONTEXT hContext, LPCWSTR szCard, + LPGUID pguidProviderId); + + WINSCARDAPI LONG WINAPI SCardGetCardTypeProviderNameA(SCARDCONTEXT hContext, LPCSTR szCardName, + DWORD dwProviderId, CHAR* szProvider, + LPDWORD pcchProvider); + WINSCARDAPI LONG WINAPI SCardGetCardTypeProviderNameW(SCARDCONTEXT hContext, LPCWSTR szCardName, + DWORD dwProviderId, WCHAR* szProvider, + LPDWORD pcchProvider); + + WINSCARDAPI LONG WINAPI SCardIntroduceReaderGroupA(SCARDCONTEXT hContext, LPCSTR szGroupName); + WINSCARDAPI LONG WINAPI SCardIntroduceReaderGroupW(SCARDCONTEXT hContext, LPCWSTR szGroupName); + + WINSCARDAPI LONG WINAPI SCardForgetReaderGroupA(SCARDCONTEXT hContext, LPCSTR szGroupName); + WINSCARDAPI LONG WINAPI SCardForgetReaderGroupW(SCARDCONTEXT hContext, LPCWSTR szGroupName); + + WINSCARDAPI LONG WINAPI SCardIntroduceReaderA(SCARDCONTEXT hContext, LPCSTR szReaderName, + LPCSTR szDeviceName); + WINSCARDAPI LONG WINAPI SCardIntroduceReaderW(SCARDCONTEXT hContext, LPCWSTR szReaderName, + LPCWSTR szDeviceName); + + WINSCARDAPI LONG WINAPI SCardForgetReaderA(SCARDCONTEXT hContext, LPCSTR szReaderName); + WINSCARDAPI LONG WINAPI SCardForgetReaderW(SCARDCONTEXT hContext, LPCWSTR szReaderName); + + WINSCARDAPI LONG WINAPI SCardAddReaderToGroupA(SCARDCONTEXT hContext, LPCSTR szReaderName, + LPCSTR szGroupName); + WINSCARDAPI LONG WINAPI SCardAddReaderToGroupW(SCARDCONTEXT hContext, LPCWSTR szReaderName, + LPCWSTR szGroupName); + + WINSCARDAPI LONG WINAPI SCardRemoveReaderFromGroupA(SCARDCONTEXT hContext, LPCSTR szReaderName, + LPCSTR szGroupName); + WINSCARDAPI LONG WINAPI SCardRemoveReaderFromGroupW(SCARDCONTEXT hContext, LPCWSTR szReaderName, + LPCWSTR szGroupName); + + WINSCARDAPI LONG WINAPI SCardIntroduceCardTypeA(SCARDCONTEXT hContext, LPCSTR szCardName, + LPCGUID pguidPrimaryProvider, + LPCGUID rgguidInterfaces, + DWORD dwInterfaceCount, LPCBYTE pbAtr, + LPCBYTE pbAtrMask, DWORD cbAtrLen); + WINSCARDAPI LONG WINAPI SCardIntroduceCardTypeW(SCARDCONTEXT hContext, LPCWSTR szCardName, + LPCGUID pguidPrimaryProvider, + LPCGUID rgguidInterfaces, + DWORD dwInterfaceCount, LPCBYTE pbAtr, + LPCBYTE pbAtrMask, DWORD cbAtrLen); + + WINSCARDAPI LONG WINAPI SCardSetCardTypeProviderNameA(SCARDCONTEXT hContext, LPCSTR szCardName, + DWORD dwProviderId, LPCSTR szProvider); + WINSCARDAPI LONG WINAPI SCardSetCardTypeProviderNameW(SCARDCONTEXT hContext, LPCWSTR szCardName, + DWORD dwProviderId, LPCWSTR szProvider); + + WINSCARDAPI LONG WINAPI SCardForgetCardTypeA(SCARDCONTEXT hContext, LPCSTR szCardName); + WINSCARDAPI LONG WINAPI SCardForgetCardTypeW(SCARDCONTEXT hContext, LPCWSTR szCardName); + + WINSCARDAPI LONG WINAPI SCardFreeMemory(SCARDCONTEXT hContext, LPVOID pvMem); + + WINSCARDAPI HANDLE WINAPI SCardAccessStartedEvent(void); + + WINSCARDAPI void WINAPI SCardReleaseStartedEvent(void); + + WINSCARDAPI LONG WINAPI SCardLocateCardsA(SCARDCONTEXT hContext, LPCSTR mszCards, + LPSCARD_READERSTATEA rgReaderStates, DWORD cReaders); + WINSCARDAPI LONG WINAPI SCardLocateCardsW(SCARDCONTEXT hContext, LPCWSTR mszCards, + LPSCARD_READERSTATEW rgReaderStates, DWORD cReaders); + + WINSCARDAPI LONG WINAPI SCardLocateCardsByATRA(SCARDCONTEXT hContext, + LPSCARD_ATRMASK rgAtrMasks, DWORD cAtrs, + LPSCARD_READERSTATEA rgReaderStates, + DWORD cReaders); + WINSCARDAPI LONG WINAPI SCardLocateCardsByATRW(SCARDCONTEXT hContext, + LPSCARD_ATRMASK rgAtrMasks, DWORD cAtrs, + LPSCARD_READERSTATEW rgReaderStates, + DWORD cReaders); + + WINSCARDAPI LONG WINAPI SCardGetStatusChangeA(SCARDCONTEXT hContext, DWORD dwTimeout, + LPSCARD_READERSTATEA rgReaderStates, + DWORD cReaders); + WINSCARDAPI LONG WINAPI SCardGetStatusChangeW(SCARDCONTEXT hContext, DWORD dwTimeout, + LPSCARD_READERSTATEW rgReaderStates, + DWORD cReaders); + + WINSCARDAPI LONG WINAPI SCardCancel(SCARDCONTEXT hContext); + + WINSCARDAPI LONG WINAPI SCardConnectA(SCARDCONTEXT hContext, LPCSTR szReader, DWORD dwShareMode, + DWORD dwPreferredProtocols, LPSCARDHANDLE phCard, + LPDWORD pdwActiveProtocol); + WINSCARDAPI LONG WINAPI SCardConnectW(SCARDCONTEXT hContext, LPCWSTR szReader, + DWORD dwShareMode, DWORD dwPreferredProtocols, + LPSCARDHANDLE phCard, LPDWORD pdwActiveProtocol); + + WINSCARDAPI LONG WINAPI SCardReconnect(SCARDHANDLE hCard, DWORD dwShareMode, + DWORD dwPreferredProtocols, DWORD dwInitialization, + LPDWORD pdwActiveProtocol); + + WINSCARDAPI LONG WINAPI SCardDisconnect(SCARDHANDLE hCard, DWORD dwDisposition); + + WINSCARDAPI LONG WINAPI SCardBeginTransaction(SCARDHANDLE hCard); + + WINSCARDAPI LONG WINAPI SCardEndTransaction(SCARDHANDLE hCard, DWORD dwDisposition); + + WINSCARDAPI LONG WINAPI SCardCancelTransaction(SCARDHANDLE hCard); + + WINSCARDAPI LONG WINAPI SCardState(SCARDHANDLE hCard, LPDWORD pdwState, LPDWORD pdwProtocol, + LPBYTE pbAtr, LPDWORD pcbAtrLen); + + WINSCARDAPI LONG WINAPI SCardStatusA(SCARDHANDLE hCard, LPSTR mszReaderNames, + LPDWORD pcchReaderLen, LPDWORD pdwState, + LPDWORD pdwProtocol, LPBYTE pbAtr, LPDWORD pcbAtrLen); + WINSCARDAPI LONG WINAPI SCardStatusW(SCARDHANDLE hCard, LPWSTR mszReaderNames, + LPDWORD pcchReaderLen, LPDWORD pdwState, + LPDWORD pdwProtocol, LPBYTE pbAtr, LPDWORD pcbAtrLen); + + WINSCARDAPI LONG WINAPI SCardTransmit(SCARDHANDLE hCard, LPCSCARD_IO_REQUEST pioSendPci, + LPCBYTE pbSendBuffer, DWORD cbSendLength, + LPSCARD_IO_REQUEST pioRecvPci, LPBYTE pbRecvBuffer, + LPDWORD pcbRecvLength); + + WINSCARDAPI LONG WINAPI SCardGetTransmitCount(SCARDHANDLE hCard, LPDWORD pcTransmitCount); + + WINSCARDAPI LONG WINAPI SCardControl(SCARDHANDLE hCard, DWORD dwControlCode, LPCVOID lpInBuffer, + DWORD cbInBufferSize, LPVOID lpOutBuffer, + DWORD cbOutBufferSize, LPDWORD lpBytesReturned); + + WINSCARDAPI LONG WINAPI SCardGetAttrib(SCARDHANDLE hCard, DWORD dwAttrId, LPBYTE pbAttr, + LPDWORD pcbAttrLen); + + WINSCARDAPI LONG WINAPI SCardSetAttrib(SCARDHANDLE hCard, DWORD dwAttrId, LPCBYTE pbAttr, + DWORD cbAttrLen); + + WINSCARDAPI LONG WINAPI SCardUIDlgSelectCardA(LPOPENCARDNAMEA_EX pDlgStruc); + WINSCARDAPI LONG WINAPI SCardUIDlgSelectCardW(LPOPENCARDNAMEW_EX pDlgStruc); + + WINSCARDAPI LONG WINAPI GetOpenCardNameA(LPOPENCARDNAMEA pDlgStruc); + WINSCARDAPI LONG WINAPI GetOpenCardNameW(LPOPENCARDNAMEW pDlgStruc); + + WINSCARDAPI LONG WINAPI SCardDlgExtendedError(void); + + WINSCARDAPI LONG WINAPI SCardReadCacheA(SCARDCONTEXT hContext, UUID* CardIdentifier, + DWORD FreshnessCounter, LPSTR LookupName, PBYTE Data, + DWORD* DataLen); + WINSCARDAPI LONG WINAPI SCardReadCacheW(SCARDCONTEXT hContext, UUID* CardIdentifier, + DWORD FreshnessCounter, LPWSTR LookupName, PBYTE Data, + DWORD* DataLen); + + WINSCARDAPI LONG WINAPI SCardWriteCacheA(SCARDCONTEXT hContext, UUID* CardIdentifier, + DWORD FreshnessCounter, LPSTR LookupName, PBYTE Data, + DWORD DataLen); + WINSCARDAPI LONG WINAPI SCardWriteCacheW(SCARDCONTEXT hContext, UUID* CardIdentifier, + DWORD FreshnessCounter, LPWSTR LookupName, PBYTE Data, + DWORD DataLen); + + WINSCARDAPI LONG WINAPI SCardGetReaderIconA(SCARDCONTEXT hContext, LPCSTR szReaderName, + LPBYTE pbIcon, LPDWORD pcbIcon); + WINSCARDAPI LONG WINAPI SCardGetReaderIconW(SCARDCONTEXT hContext, LPCWSTR szReaderName, + LPBYTE pbIcon, LPDWORD pcbIcon); + + WINSCARDAPI LONG WINAPI SCardGetDeviceTypeIdA(SCARDCONTEXT hContext, LPCSTR szReaderName, + LPDWORD pdwDeviceTypeId); + WINSCARDAPI LONG WINAPI SCardGetDeviceTypeIdW(SCARDCONTEXT hContext, LPCWSTR szReaderName, + LPDWORD pdwDeviceTypeId); + + WINSCARDAPI LONG WINAPI SCardGetReaderDeviceInstanceIdA(SCARDCONTEXT hContext, + LPCSTR szReaderName, + LPSTR szDeviceInstanceId, + LPDWORD pcchDeviceInstanceId); + WINSCARDAPI LONG WINAPI SCardGetReaderDeviceInstanceIdW(SCARDCONTEXT hContext, + LPCWSTR szReaderName, + LPWSTR szDeviceInstanceId, + LPDWORD pcchDeviceInstanceId); + + WINSCARDAPI LONG WINAPI SCardListReadersWithDeviceInstanceIdA(SCARDCONTEXT hContext, + LPCSTR szDeviceInstanceId, + LPSTR mszReaders, + LPDWORD pcchReaders); + WINSCARDAPI LONG WINAPI SCardListReadersWithDeviceInstanceIdW(SCARDCONTEXT hContext, + LPCWSTR szDeviceInstanceId, + LPWSTR mszReaders, + LPDWORD pcchReaders); + + WINSCARDAPI LONG WINAPI SCardAudit(SCARDCONTEXT hContext, DWORD dwEvent); + +#ifdef UNICODE +#define SCardListReaderGroups SCardListReaderGroupsW +#define SCardListReaders SCardListReadersW +#define SCardListCards SCardListCardsW +#define SCardListInterfaces SCardListInterfacesW +#define SCardGetProviderId SCardGetProviderIdW +#define SCardGetCardTypeProviderName SCardGetCardTypeProviderNameW +#define SCardIntroduceReaderGroup SCardIntroduceReaderGroupW +#define SCardForgetReaderGroup SCardForgetReaderGroupW +#define SCardIntroduceReader SCardIntroduceReaderW +#define SCardForgetReader SCardForgetReaderW +#define SCardAddReaderToGroup SCardAddReaderToGroupW +#define SCardRemoveReaderFromGroup SCardRemoveReaderFromGroupW +#define SCardIntroduceCardType SCardIntroduceCardTypeW +#define SCardSetCardTypeProviderName SCardSetCardTypeProviderNameW +#define SCardForgetCardType SCardForgetCardTypeW +#define SCardLocateCards SCardLocateCardsW +#define SCardLocateCardsByATR SCardLocateCardsByATRW +#define SCardGetStatusChange SCardGetStatusChangeW +#define SCardConnect SCardConnectW +#define SCardStatus SCardStatusW +#define SCardUIDlgSelectCard SCardUIDlgSelectCardW +#define GetOpenCardName GetOpenCardNameW +#define SCardReadCache SCardReadCacheW +#define SCardWriteCache SCardWriteCacheW +#define SCardGetReaderIcon SCardGetReaderIconW +#define SCardGetDeviceTypeId SCardGetDeviceTypeIdW +#define SCardGetReaderDeviceInstanceId SCardGetReaderDeviceInstanceIdW +#define SCardListReadersWithDeviceInstanceId SCardListReadersWithDeviceInstanceIdW +#else +#define SCardListReaderGroups SCardListReaderGroupsA +#define SCardListReaders SCardListReadersA +#define SCardListCards SCardListCardsA +#define SCardListInterfaces SCardListInterfacesA +#define SCardGetProviderId SCardGetProviderIdA +#define SCardGetCardTypeProviderName SCardGetCardTypeProviderNameA +#define SCardIntroduceReaderGroup SCardIntroduceReaderGroupA +#define SCardForgetReaderGroup SCardForgetReaderGroupA +#define SCardIntroduceReader SCardIntroduceReaderA +#define SCardForgetReader SCardForgetReaderA +#define SCardAddReaderToGroup SCardAddReaderToGroupA +#define SCardRemoveReaderFromGroup SCardRemoveReaderFromGroupA +#define SCardIntroduceCardType SCardIntroduceCardTypeA +#define SCardSetCardTypeProviderName SCardSetCardTypeProviderNameA +#define SCardForgetCardType SCardForgetCardTypeA +#define SCardLocateCards SCardLocateCardsA +#define SCardLocateCardsByATR SCardLocateCardsByATRA +#define SCardGetStatusChange SCardGetStatusChangeA +#define SCardConnect SCardConnectA +#define SCardStatus SCardStatusA +#define SCardUIDlgSelectCard SCardUIDlgSelectCardA +#define GetOpenCardName GetOpenCardNameA +#define SCardReadCache SCardReadCacheA +#define SCardWriteCache SCardWriteCacheA +#define SCardGetReaderIcon SCardGetReaderIconA +#define SCardGetDeviceTypeId SCardGetDeviceTypeIdA +#define SCardGetReaderDeviceInstanceId SCardGetReaderDeviceInstanceIdA +#define SCardListReadersWithDeviceInstanceId SCardListReadersWithDeviceInstanceIdA +#endif + +#ifdef __cplusplus +} +#endif + +/** + * Extended API + */ + +typedef LONG(WINAPI* fnSCardEstablishContext)(DWORD dwScope, LPCVOID pvReserved1, + LPCVOID pvReserved2, LPSCARDCONTEXT phContext); + +typedef LONG(WINAPI* fnSCardReleaseContext)(SCARDCONTEXT hContext); + +typedef LONG(WINAPI* fnSCardIsValidContext)(SCARDCONTEXT hContext); + +typedef LONG(WINAPI* fnSCardListReaderGroupsA)(SCARDCONTEXT hContext, LPSTR mszGroups, + LPDWORD pcchGroups); +typedef LONG(WINAPI* fnSCardListReaderGroupsW)(SCARDCONTEXT hContext, LPWSTR mszGroups, + LPDWORD pcchGroups); + +typedef LONG(WINAPI* fnSCardListReadersA)(SCARDCONTEXT hContext, LPCSTR mszGroups, LPSTR mszReaders, + LPDWORD pcchReaders); +typedef LONG(WINAPI* fnSCardListReadersW)(SCARDCONTEXT hContext, LPCWSTR mszGroups, + LPWSTR mszReaders, LPDWORD pcchReaders); + +typedef LONG(WINAPI* fnSCardListCardsA)(SCARDCONTEXT hContext, LPCBYTE pbAtr, + LPCGUID rgquidInterfaces, DWORD cguidInterfaceCount, + CHAR* mszCards, LPDWORD pcchCards); + +typedef LONG(WINAPI* fnSCardListCardsW)(SCARDCONTEXT hContext, LPCBYTE pbAtr, + LPCGUID rgquidInterfaces, DWORD cguidInterfaceCount, + WCHAR* mszCards, LPDWORD pcchCards); + +typedef LONG(WINAPI* fnSCardListInterfacesA)(SCARDCONTEXT hContext, LPCSTR szCard, + LPGUID pguidInterfaces, LPDWORD pcguidInterfaces); +typedef LONG(WINAPI* fnSCardListInterfacesW)(SCARDCONTEXT hContext, LPCWSTR szCard, + LPGUID pguidInterfaces, LPDWORD pcguidInterfaces); + +typedef LONG(WINAPI* fnSCardGetProviderIdA)(SCARDCONTEXT hContext, LPCSTR szCard, + LPGUID pguidProviderId); +typedef LONG(WINAPI* fnSCardGetProviderIdW)(SCARDCONTEXT hContext, LPCWSTR szCard, + LPGUID pguidProviderId); + +typedef LONG(WINAPI* fnSCardGetCardTypeProviderNameA)(SCARDCONTEXT hContext, LPCSTR szCardName, + DWORD dwProviderId, CHAR* szProvider, + LPDWORD pcchProvider); +typedef LONG(WINAPI* fnSCardGetCardTypeProviderNameW)(SCARDCONTEXT hContext, LPCWSTR szCardName, + DWORD dwProviderId, WCHAR* szProvider, + LPDWORD pcchProvider); + +typedef LONG(WINAPI* fnSCardIntroduceReaderGroupA)(SCARDCONTEXT hContext, LPCSTR szGroupName); +typedef LONG(WINAPI* fnSCardIntroduceReaderGroupW)(SCARDCONTEXT hContext, LPCWSTR szGroupName); + +typedef LONG(WINAPI* fnSCardForgetReaderGroupA)(SCARDCONTEXT hContext, LPCSTR szGroupName); +typedef LONG(WINAPI* fnSCardForgetReaderGroupW)(SCARDCONTEXT hContext, LPCWSTR szGroupName); + +typedef LONG(WINAPI* fnSCardIntroduceReaderA)(SCARDCONTEXT hContext, LPCSTR szReaderName, + LPCSTR szDeviceName); +typedef LONG(WINAPI* fnSCardIntroduceReaderW)(SCARDCONTEXT hContext, LPCWSTR szReaderName, + LPCWSTR szDeviceName); + +typedef LONG(WINAPI* fnSCardForgetReaderA)(SCARDCONTEXT hContext, LPCSTR szReaderName); +typedef LONG(WINAPI* fnSCardForgetReaderW)(SCARDCONTEXT hContext, LPCWSTR szReaderName); + +typedef LONG(WINAPI* fnSCardAddReaderToGroupA)(SCARDCONTEXT hContext, LPCSTR szReaderName, + LPCSTR szGroupName); +typedef LONG(WINAPI* fnSCardAddReaderToGroupW)(SCARDCONTEXT hContext, LPCWSTR szReaderName, + LPCWSTR szGroupName); + +typedef LONG(WINAPI* fnSCardRemoveReaderFromGroupA)(SCARDCONTEXT hContext, LPCSTR szReaderName, + LPCSTR szGroupName); +typedef LONG(WINAPI* fnSCardRemoveReaderFromGroupW)(SCARDCONTEXT hContext, LPCWSTR szReaderName, + LPCWSTR szGroupName); + +typedef LONG(WINAPI* fnSCardIntroduceCardTypeA)(SCARDCONTEXT hContext, LPCSTR szCardName, + LPCGUID pguidPrimaryProvider, + LPCGUID rgguidInterfaces, DWORD dwInterfaceCount, + LPCBYTE pbAtr, LPCBYTE pbAtrMask, DWORD cbAtrLen); +typedef LONG(WINAPI* fnSCardIntroduceCardTypeW)(SCARDCONTEXT hContext, LPCWSTR szCardName, + LPCGUID pguidPrimaryProvider, + LPCGUID rgguidInterfaces, DWORD dwInterfaceCount, + LPCBYTE pbAtr, LPCBYTE pbAtrMask, DWORD cbAtrLen); + +typedef LONG(WINAPI* fnSCardSetCardTypeProviderNameA)(SCARDCONTEXT hContext, LPCSTR szCardName, + DWORD dwProviderId, LPCSTR szProvider); +typedef LONG(WINAPI* fnSCardSetCardTypeProviderNameW)(SCARDCONTEXT hContext, LPCWSTR szCardName, + DWORD dwProviderId, LPCWSTR szProvider); + +typedef LONG(WINAPI* fnSCardForgetCardTypeA)(SCARDCONTEXT hContext, LPCSTR szCardName); +typedef LONG(WINAPI* fnSCardForgetCardTypeW)(SCARDCONTEXT hContext, LPCWSTR szCardName); + +typedef LONG(WINAPI* fnSCardFreeMemory)(SCARDCONTEXT hContext, LPVOID pvMem); + +typedef HANDLE(WINAPI* fnSCardAccessStartedEvent)(void); + +typedef void(WINAPI* fnSCardReleaseStartedEvent)(void); + +typedef LONG(WINAPI* fnSCardLocateCardsA)(SCARDCONTEXT hContext, LPCSTR mszCards, + LPSCARD_READERSTATEA rgReaderStates, DWORD cReaders); +typedef LONG(WINAPI* fnSCardLocateCardsW)(SCARDCONTEXT hContext, LPCWSTR mszCards, + LPSCARD_READERSTATEW rgReaderStates, DWORD cReaders); + +typedef LONG(WINAPI* fnSCardLocateCardsByATRA)(SCARDCONTEXT hContext, LPSCARD_ATRMASK rgAtrMasks, + DWORD cAtrs, LPSCARD_READERSTATEA rgReaderStates, + DWORD cReaders); +typedef LONG(WINAPI* fnSCardLocateCardsByATRW)(SCARDCONTEXT hContext, LPSCARD_ATRMASK rgAtrMasks, + DWORD cAtrs, LPSCARD_READERSTATEW rgReaderStates, + DWORD cReaders); + +typedef LONG(WINAPI* fnSCardGetStatusChangeA)(SCARDCONTEXT hContext, DWORD dwTimeout, + LPSCARD_READERSTATEA rgReaderStates, DWORD cReaders); +typedef LONG(WINAPI* fnSCardGetStatusChangeW)(SCARDCONTEXT hContext, DWORD dwTimeout, + LPSCARD_READERSTATEW rgReaderStates, DWORD cReaders); + +typedef LONG(WINAPI* fnSCardCancel)(SCARDCONTEXT hContext); + +typedef LONG(WINAPI* fnSCardConnectA)(SCARDCONTEXT hContext, LPCSTR szReader, DWORD dwShareMode, + DWORD dwPreferredProtocols, LPSCARDHANDLE phCard, + LPDWORD pdwActiveProtocol); +typedef LONG(WINAPI* fnSCardConnectW)(SCARDCONTEXT hContext, LPCWSTR szReader, DWORD dwShareMode, + DWORD dwPreferredProtocols, LPSCARDHANDLE phCard, + LPDWORD pdwActiveProtocol); + +typedef LONG(WINAPI* fnSCardReconnect)(SCARDHANDLE hCard, DWORD dwShareMode, + DWORD dwPreferredProtocols, DWORD dwInitialization, + LPDWORD pdwActiveProtocol); + +typedef LONG(WINAPI* fnSCardDisconnect)(SCARDHANDLE hCard, DWORD dwDisposition); + +typedef LONG(WINAPI* fnSCardBeginTransaction)(SCARDHANDLE hCard); + +typedef LONG(WINAPI* fnSCardEndTransaction)(SCARDHANDLE hCard, DWORD dwDisposition); + +typedef LONG(WINAPI* fnSCardCancelTransaction)(SCARDHANDLE hCard); + +typedef LONG(WINAPI* fnSCardState)(SCARDHANDLE hCard, LPDWORD pdwState, LPDWORD pdwProtocol, + LPBYTE pbAtr, LPDWORD pcbAtrLen); + +typedef LONG(WINAPI* fnSCardStatusA)(SCARDHANDLE hCard, LPSTR mszReaderNames, LPDWORD pcchReaderLen, + LPDWORD pdwState, LPDWORD pdwProtocol, LPBYTE pbAtr, + LPDWORD pcbAtrLen); +typedef LONG(WINAPI* fnSCardStatusW)(SCARDHANDLE hCard, LPWSTR mszReaderNames, + LPDWORD pcchReaderLen, LPDWORD pdwState, LPDWORD pdwProtocol, + LPBYTE pbAtr, LPDWORD pcbAtrLen); + +typedef LONG(WINAPI* fnSCardTransmit)(SCARDHANDLE hCard, LPCSCARD_IO_REQUEST pioSendPci, + LPCBYTE pbSendBuffer, DWORD cbSendLength, + LPSCARD_IO_REQUEST pioRecvPci, LPBYTE pbRecvBuffer, + LPDWORD pcbRecvLength); + +typedef LONG(WINAPI* fnSCardGetTransmitCount)(SCARDHANDLE hCard, LPDWORD pcTransmitCount); + +typedef LONG(WINAPI* fnSCardControl)(SCARDHANDLE hCard, DWORD dwControlCode, LPCVOID lpInBuffer, + DWORD cbInBufferSize, LPVOID lpOutBuffer, + DWORD cbOutBufferSize, LPDWORD lpBytesReturned); + +typedef LONG(WINAPI* fnSCardGetAttrib)(SCARDHANDLE hCard, DWORD dwAttrId, LPBYTE pbAttr, + LPDWORD pcbAttrLen); + +typedef LONG(WINAPI* fnSCardSetAttrib)(SCARDHANDLE hCard, DWORD dwAttrId, LPCBYTE pbAttr, + DWORD cbAttrLen); + +typedef LONG(WINAPI* fnSCardUIDlgSelectCardA)(LPOPENCARDNAMEA_EX pDlgStruc); +typedef LONG(WINAPI* fnSCardUIDlgSelectCardW)(LPOPENCARDNAMEW_EX pDlgStruc); + +typedef LONG(WINAPI* fnGetOpenCardNameA)(LPOPENCARDNAMEA pDlgStruc); +typedef LONG(WINAPI* fnGetOpenCardNameW)(LPOPENCARDNAMEW pDlgStruc); + +typedef LONG(WINAPI* fnSCardDlgExtendedError)(void); + +typedef LONG(WINAPI* fnSCardReadCacheA)(SCARDCONTEXT hContext, UUID* CardIdentifier, + DWORD FreshnessCounter, LPSTR LookupName, PBYTE Data, + DWORD* DataLen); +typedef LONG(WINAPI* fnSCardReadCacheW)(SCARDCONTEXT hContext, UUID* CardIdentifier, + DWORD FreshnessCounter, LPWSTR LookupName, PBYTE Data, + DWORD* DataLen); + +typedef LONG(WINAPI* fnSCardWriteCacheA)(SCARDCONTEXT hContext, UUID* CardIdentifier, + DWORD FreshnessCounter, LPSTR LookupName, PBYTE Data, + DWORD DataLen); +typedef LONG(WINAPI* fnSCardWriteCacheW)(SCARDCONTEXT hContext, UUID* CardIdentifier, + DWORD FreshnessCounter, LPWSTR LookupName, PBYTE Data, + DWORD DataLen); + +typedef LONG(WINAPI* fnSCardGetReaderIconA)(SCARDCONTEXT hContext, LPCSTR szReaderName, + LPBYTE pbIcon, LPDWORD pcbIcon); +typedef LONG(WINAPI* fnSCardGetReaderIconW)(SCARDCONTEXT hContext, LPCWSTR szReaderName, + LPBYTE pbIcon, LPDWORD pcbIcon); + +typedef LONG(WINAPI* fnSCardGetDeviceTypeIdA)(SCARDCONTEXT hContext, LPCSTR szReaderName, + LPDWORD pdwDeviceTypeId); +typedef LONG(WINAPI* fnSCardGetDeviceTypeIdW)(SCARDCONTEXT hContext, LPCWSTR szReaderName, + LPDWORD pdwDeviceTypeId); + +typedef LONG(WINAPI* fnSCardGetReaderDeviceInstanceIdA)(SCARDCONTEXT hContext, LPCSTR szReaderName, + LPSTR szDeviceInstanceId, + LPDWORD pcchDeviceInstanceId); +typedef LONG(WINAPI* fnSCardGetReaderDeviceInstanceIdW)(SCARDCONTEXT hContext, LPCWSTR szReaderName, + LPWSTR szDeviceInstanceId, + LPDWORD pcchDeviceInstanceId); + +typedef LONG(WINAPI* fnSCardListReadersWithDeviceInstanceIdA)(SCARDCONTEXT hContext, + LPCSTR szDeviceInstanceId, + LPSTR mszReaders, + LPDWORD pcchReaders); +typedef LONG(WINAPI* fnSCardListReadersWithDeviceInstanceIdW)(SCARDCONTEXT hContext, + LPCWSTR szDeviceInstanceId, + LPWSTR mszReaders, + LPDWORD pcchReaders); + +typedef LONG(WINAPI* fnSCardAudit)(SCARDCONTEXT hContext, DWORD dwEvent); + +typedef struct +{ + DWORD dwVersion; + DWORD dwFlags; + + fnSCardEstablishContext pfnSCardEstablishContext; + fnSCardReleaseContext pfnSCardReleaseContext; + fnSCardIsValidContext pfnSCardIsValidContext; + fnSCardListReaderGroupsA pfnSCardListReaderGroupsA; + fnSCardListReaderGroupsW pfnSCardListReaderGroupsW; + fnSCardListReadersA pfnSCardListReadersA; + fnSCardListReadersW pfnSCardListReadersW; + fnSCardListCardsA pfnSCardListCardsA; + fnSCardListCardsW pfnSCardListCardsW; + fnSCardListInterfacesA pfnSCardListInterfacesA; + fnSCardListInterfacesW pfnSCardListInterfacesW; + fnSCardGetProviderIdA pfnSCardGetProviderIdA; + fnSCardGetProviderIdW pfnSCardGetProviderIdW; + fnSCardGetCardTypeProviderNameA pfnSCardGetCardTypeProviderNameA; + fnSCardGetCardTypeProviderNameW pfnSCardGetCardTypeProviderNameW; + fnSCardIntroduceReaderGroupA pfnSCardIntroduceReaderGroupA; + fnSCardIntroduceReaderGroupW pfnSCardIntroduceReaderGroupW; + fnSCardForgetReaderGroupA pfnSCardForgetReaderGroupA; + fnSCardForgetReaderGroupW pfnSCardForgetReaderGroupW; + fnSCardIntroduceReaderA pfnSCardIntroduceReaderA; + fnSCardIntroduceReaderW pfnSCardIntroduceReaderW; + fnSCardForgetReaderA pfnSCardForgetReaderA; + fnSCardForgetReaderW pfnSCardForgetReaderW; + fnSCardAddReaderToGroupA pfnSCardAddReaderToGroupA; + fnSCardAddReaderToGroupW pfnSCardAddReaderToGroupW; + fnSCardRemoveReaderFromGroupA pfnSCardRemoveReaderFromGroupA; + fnSCardRemoveReaderFromGroupW pfnSCardRemoveReaderFromGroupW; + fnSCardIntroduceCardTypeA pfnSCardIntroduceCardTypeA; + fnSCardIntroduceCardTypeW pfnSCardIntroduceCardTypeW; + fnSCardSetCardTypeProviderNameA pfnSCardSetCardTypeProviderNameA; + fnSCardSetCardTypeProviderNameW pfnSCardSetCardTypeProviderNameW; + fnSCardForgetCardTypeA pfnSCardForgetCardTypeA; + fnSCardForgetCardTypeW pfnSCardForgetCardTypeW; + fnSCardFreeMemory pfnSCardFreeMemory; + fnSCardAccessStartedEvent pfnSCardAccessStartedEvent; + fnSCardReleaseStartedEvent pfnSCardReleaseStartedEvent; + fnSCardLocateCardsA pfnSCardLocateCardsA; + fnSCardLocateCardsW pfnSCardLocateCardsW; + fnSCardLocateCardsByATRA pfnSCardLocateCardsByATRA; + fnSCardLocateCardsByATRW pfnSCardLocateCardsByATRW; + fnSCardGetStatusChangeA pfnSCardGetStatusChangeA; + fnSCardGetStatusChangeW pfnSCardGetStatusChangeW; + fnSCardCancel pfnSCardCancel; + fnSCardConnectA pfnSCardConnectA; + fnSCardConnectW pfnSCardConnectW; + fnSCardReconnect pfnSCardReconnect; + fnSCardDisconnect pfnSCardDisconnect; + fnSCardBeginTransaction pfnSCardBeginTransaction; + fnSCardEndTransaction pfnSCardEndTransaction; + fnSCardCancelTransaction pfnSCardCancelTransaction; + fnSCardState pfnSCardState; + fnSCardStatusA pfnSCardStatusA; + fnSCardStatusW pfnSCardStatusW; + fnSCardTransmit pfnSCardTransmit; + fnSCardGetTransmitCount pfnSCardGetTransmitCount; + fnSCardControl pfnSCardControl; + fnSCardGetAttrib pfnSCardGetAttrib; + fnSCardSetAttrib pfnSCardSetAttrib; + fnSCardUIDlgSelectCardA pfnSCardUIDlgSelectCardA; + fnSCardUIDlgSelectCardW pfnSCardUIDlgSelectCardW; + fnGetOpenCardNameA pfnGetOpenCardNameA; + fnGetOpenCardNameW pfnGetOpenCardNameW; + fnSCardDlgExtendedError pfnSCardDlgExtendedError; + fnSCardReadCacheA pfnSCardReadCacheA; + fnSCardReadCacheW pfnSCardReadCacheW; + fnSCardWriteCacheA pfnSCardWriteCacheA; + fnSCardWriteCacheW pfnSCardWriteCacheW; + fnSCardGetReaderIconA pfnSCardGetReaderIconA; + fnSCardGetReaderIconW pfnSCardGetReaderIconW; + fnSCardGetDeviceTypeIdA pfnSCardGetDeviceTypeIdA; + fnSCardGetDeviceTypeIdW pfnSCardGetDeviceTypeIdW; + fnSCardGetReaderDeviceInstanceIdA pfnSCardGetReaderDeviceInstanceIdA; + fnSCardGetReaderDeviceInstanceIdW pfnSCardGetReaderDeviceInstanceIdW; + fnSCardListReadersWithDeviceInstanceIdA pfnSCardListReadersWithDeviceInstanceIdA; + fnSCardListReadersWithDeviceInstanceIdW pfnSCardListReadersWithDeviceInstanceIdW; + fnSCardAudit pfnSCardAudit; +} SCardApiFunctionTable; +typedef SCardApiFunctionTable* PSCardApiFunctionTable; + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINSCARDAPI const char* WINAPI SCardGetErrorString(LONG errorCode); + WINSCARDAPI const char* WINAPI SCardGetAttributeString(DWORD dwAttrId); + WINSCARDAPI const char* WINAPI SCardGetProtocolString(DWORD dwProtocols); + WINSCARDAPI const char* WINAPI SCardGetShareModeString(DWORD dwShareMode); + WINSCARDAPI const char* WINAPI SCardGetDispositionString(DWORD dwDisposition); + WINSCARDAPI const char* WINAPI SCardGetScopeString(DWORD dwScope); + WINSCARDAPI const char* WINAPI SCardGetCardStateString(DWORD dwCardState); + WINSCARDAPI char* WINAPI SCardGetReaderStateString(DWORD dwReaderState); + + WINPR_API BOOL WinSCard_LoadApiTableFunctions(PSCardApiFunctionTable pWinSCardApiTable, + HMODULE hWinSCardLibrary); + WINPR_API const SCardApiFunctionTable* WinPR_GetSCardApiFunctionTable(void); + +#ifdef __cplusplus +} +#endif + +#endif /* WINPR_SMARTCARD_H */ diff --git a/winpr/include/winpr/spec.h b/winpr/include/winpr/spec.h new file mode 100644 index 0000000..3ebf1b1 --- /dev/null +++ b/winpr/include/winpr/spec.h @@ -0,0 +1,986 @@ +/** + * WinPR: Windows Portable Runtime + * Compiler Specification Strings + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_SPEC_H +#define WINPR_SPEC_H + +#include <winpr/platform.h> + +#ifdef _WIN32 + +#include <specstrings.h> +#ifndef _COM_Outptr_ +#define _COM_Outptr_ +#endif + +#else + +WINPR_PRAGMA_DIAG_PUSH +WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO + +#define DUMMYUNIONNAME u +#define DUMMYUNIONNAME1 u1 +#define DUMMYUNIONNAME2 u2 +#define DUMMYUNIONNAME3 u3 +#define DUMMYUNIONNAME4 u4 +#define DUMMYUNIONNAME5 u5 +#define DUMMYUNIONNAME6 u6 +#define DUMMYUNIONNAME7 u7 +#define DUMMYUNIONNAME8 u8 + +#define DUMMYSTRUCTNAME s +#define DUMMYSTRUCTNAME1 s1 +#define DUMMYSTRUCTNAME2 s2 +#define DUMMYSTRUCTNAME3 s3 +#define DUMMYSTRUCTNAME4 s4 +#define DUMMYSTRUCTNAME5 s5 + +#if (defined(_M_AMD64) || defined(_M_ARM)) && !defined(_WIN32) +#define _UNALIGNED __unaligned +#else +#define _UNALIGNED +#endif + +#ifndef DECLSPEC_ALIGN +#if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS) +#define DECLSPEC_ALIGN(x) __declspec(align(x)) +#elif defined(__GNUC__) +#define DECLSPEC_ALIGN(x) __attribute__((__aligned__(x))) +#else +#define DECLSPEC_ALIGN(x) +#endif +#endif /* DECLSPEC_ALIGN */ + +#ifdef _M_AMD64 +#define MEMORY_ALLOCATION_ALIGNMENT 16 +#else +#define MEMORY_ALLOCATION_ALIGNMENT 8 +#endif + +#ifdef __GNUC__ +#ifndef __declspec +#define __declspec(e) __attribute__((e)) +#endif +#endif + +#ifndef DECLSPEC_NORETURN +#if (defined(__GNUC__) || defined(_MSC_VER) || defined(__clang__)) +#define DECLSPEC_NORETURN __declspec(noreturn) +#else +#define DECLSPEC_NORETURN +#endif +#endif /* DECLSPEC_NORETURN */ + +/** + * Header Annotations: + * http://msdn.microsoft.com/en-us/library/windows/desktop/aa383701/ + */ + +#define __field_bcount(size) __notnull __byte_writableTo(size) +#define __field_ecount(size) __notnull __elem_writableTo(size) +#define __post_invalid _Post_ __notvalid + +#define __deref_in +#define __deref_in_ecount(size) +#define __deref_in_bcount(size) +#define __deref_in_opt +#define __deref_in_ecount_opt(size) +#define __deref_in_bcount_opt(size) +#define __deref_opt_in +#define __deref_opt_in_ecount(size) +#define __deref_opt_in_bcount(size) +#define __deref_opt_in_opt +#define __deref_opt_in_ecount_opt(size) +#define __deref_opt_in_bcount_opt(size) +#define __out_awcount(expr, size) +#define __in_awcount(expr, size) +#define __nullnullterminated +#define __in_data_source(src_sym) +#define __kernel_entry +#define __out_data_source(src_sym) +#define __analysis_noreturn +#define _Check_return_opt_ +#define _Check_return_wat_ + +#define __inner_exceptthat +#define __inner_typefix(ctype) +#define _Always_(annos) +#define _Analysis_noreturn_ +#define _Analysis_assume_(expr) +#define _At_(target, annos) +#define _At_buffer_(target, iter, bound, annos) +#define _Check_return_ +#define _COM_Outptr_ +#define _COM_Outptr_opt_ +#define _COM_Outptr_opt_result_maybenull_ +#define _COM_Outptr_result_maybenull_ +#define _Const_ +#define _Deref_in_bound_ +#define _Deref_in_range_(lb, ub) +#define _Deref_inout_bound_ +#define _Deref_inout_z_ +#define _Deref_inout_z_bytecap_c_(size) +#define _Deref_inout_z_cap_c_(size) +#define _Deref_opt_out_ +#define _Deref_opt_out_opt_ +#define _Deref_opt_out_opt_z_ +#define _Deref_opt_out_z_ +#define _Deref_out_ +#define _Deref_out_bound_ +#define _Deref_out_opt_ +#define _Deref_out_opt_z_ +#define _Deref_out_range_(lb, ub) +#define _Deref_out_z_ +#define _Deref_out_z_bytecap_c_(size) +#define _Deref_out_z_cap_c_(size) +#define _Deref_post_bytecap_(size) +#define _Deref_post_bytecap_c_(size) +#define _Deref_post_bytecap_x_(size) +#define _Deref_post_bytecount_(size) +#define _Deref_post_bytecount_c_(size) +#define _Deref_post_bytecount_x_(size) +#define _Deref_post_cap_(size) +#define _Deref_post_cap_c_(size) +#define _Deref_post_cap_x_(size) +#define _Deref_post_count_(size) +#define _Deref_post_count_c_(size) +#define _Deref_post_count_x_(size) +#define _Deref_post_maybenull_ +#define _Deref_post_notnull_ +#define _Deref_post_null_ +#define _Deref_post_opt_bytecap_(size) +#define _Deref_post_opt_bytecap_c_(size) +#define _Deref_post_opt_bytecap_x_(size) +#define _Deref_post_opt_bytecount_(size) +#define _Deref_post_opt_bytecount_c_(size) +#define _Deref_post_opt_bytecount_x_(size) +#define _Deref_post_opt_cap_(size) +#define _Deref_post_opt_cap_c_(size) +#define _Deref_post_opt_cap_x_(size) +#define _Deref_post_opt_count_(size) +#define _Deref_post_opt_count_c_(size) +#define _Deref_post_opt_count_x_(size) +#define _Deref_post_opt_valid_ +#define _Deref_post_opt_valid_bytecap_(size) +#define _Deref_post_opt_valid_bytecap_c_(size) +#define _Deref_post_opt_valid_bytecap_x_(size) +#define _Deref_post_opt_valid_cap_(size) +#define _Deref_post_opt_valid_cap_c_(size) +#define _Deref_post_opt_valid_cap_x_(size) +#define _Deref_post_opt_z_ +#define _Deref_post_opt_z_bytecap_(size) +#define _Deref_post_opt_z_bytecap_c_(size) +#define _Deref_post_opt_z_bytecap_x_(size) +#define _Deref_post_opt_z_cap_(size) +#define _Deref_post_opt_z_cap_c_(size) +#define _Deref_post_opt_z_cap_x_(size) +#define _Deref_post_valid_ +#define _Deref_post_valid_bytecap_(size) +#define _Deref_post_valid_bytecap_c_(size) +#define _Deref_post_valid_bytecap_x_(size) +#define _Deref_post_valid_cap_(size) +#define _Deref_post_valid_cap_c_(size) +#define _Deref_post_valid_cap_x_(size) +#define _Deref_post_z_ +#define _Deref_post_z_bytecap_(size) +#define _Deref_post_z_bytecap_c_(size) +#define _Deref_post_z_bytecap_x_(size) +#define _Deref_post_z_cap_(size) +#define _Deref_post_z_cap_c_(size) +#define _Deref_post_z_cap_x_(size) +#define _Deref_pre_bytecap_(size) +#define _Deref_pre_bytecap_c_(size) +#define _Deref_pre_bytecap_x_(size) +#define _Deref_pre_bytecount_(size) +#define _Deref_pre_bytecount_c_(size) +#define _Deref_pre_bytecount_x_(size) +#define _Deref_pre_cap_(size) +#define _Deref_pre_cap_c_(size) +#define _Deref_pre_cap_x_(size) +#define _Deref_pre_count_(size) +#define _Deref_pre_count_c_(size) +#define _Deref_pre_count_x_(size) +#define _Deref_pre_invalid_ +#define _Deref_pre_maybenull_ +#define _Deref_pre_notnull_ +#define _Deref_pre_null_ +#define _Deref_pre_opt_bytecap_(size) +#define _Deref_pre_opt_bytecap_c_(size) +#define _Deref_pre_opt_bytecap_x_(size) +#define _Deref_pre_opt_bytecount_(size) +#define _Deref_pre_opt_bytecount_c_(size) +#define _Deref_pre_opt_bytecount_x_(size) +#define _Deref_pre_opt_cap_(size) +#define _Deref_pre_opt_cap_c_(size) +#define _Deref_pre_opt_cap_x_(size) +#define _Deref_pre_opt_count_(size) +#define _Deref_pre_opt_count_c_(size) +#define _Deref_pre_opt_count_x_(size) +#define _Deref_pre_opt_valid_ +#define _Deref_pre_opt_valid_bytecap_(size) +#define _Deref_pre_opt_valid_bytecap_c_(size) +#define _Deref_pre_opt_valid_bytecap_x_(size) +#define _Deref_pre_opt_valid_cap_(size) +#define _Deref_pre_opt_valid_cap_c_(size) +#define _Deref_pre_opt_valid_cap_x_(size) +#define _Deref_pre_opt_z_ +#define _Deref_pre_opt_z_bytecap_(size) +#define _Deref_pre_opt_z_bytecap_c_(size) +#define _Deref_pre_opt_z_bytecap_x_(size) +#define _Deref_pre_opt_z_cap_(size) +#define _Deref_pre_opt_z_cap_c_(size) +#define _Deref_pre_opt_z_cap_x_(size) +#define _Deref_pre_readonly_ +#define _Deref_pre_valid_ +#define _Deref_pre_valid_bytecap_(size) +#define _Deref_pre_valid_bytecap_c_(size) +#define _Deref_pre_valid_bytecap_x_(size) +#define _Deref_pre_valid_cap_(size) +#define _Deref_pre_valid_cap_c_(size) +#define _Deref_pre_valid_cap_x_(size) +#define _Deref_pre_writeonly_ +#define _Deref_pre_z_ +#define _Deref_pre_z_bytecap_(size) +#define _Deref_pre_z_bytecap_c_(size) +#define _Deref_pre_z_bytecap_x_(size) +#define _Deref_pre_z_cap_(size) +#define _Deref_pre_z_cap_c_(size) +#define _Deref_pre_z_cap_x_(size) +#define _Deref_prepost_bytecap_(size) +#define _Deref_prepost_bytecap_x_(size) +#define _Deref_prepost_bytecount_(size) +#define _Deref_prepost_bytecount_x_(size) +#define _Deref_prepost_cap_(size) +#define _Deref_prepost_cap_x_(size) +#define _Deref_prepost_count_(size) +#define _Deref_prepost_count_x_(size) +#define _Deref_prepost_opt_bytecap_(size) +#define _Deref_prepost_opt_bytecap_x_(size) +#define _Deref_prepost_opt_bytecount_(size) +#define _Deref_prepost_opt_bytecount_x_(size) +#define _Deref_prepost_opt_cap_(size) +#define _Deref_prepost_opt_cap_x_(size) +#define _Deref_prepost_opt_count_(size) +#define _Deref_prepost_opt_count_x_(size) +#define _Deref_prepost_opt_valid_ +#define _Deref_prepost_opt_valid_bytecap_(size) +#define _Deref_prepost_opt_valid_bytecap_x_(size) +#define _Deref_prepost_opt_valid_cap_(size) +#define _Deref_prepost_opt_valid_cap_x_(size) +#define _Deref_prepost_opt_z_ +#define _Deref_prepost_opt_z_bytecap_(size) +#define _Deref_prepost_opt_z_cap_(size) +#define _Deref_prepost_valid_ +#define _Deref_prepost_valid_bytecap_(size) +#define _Deref_prepost_valid_bytecap_x_(size) +#define _Deref_prepost_valid_cap_(size) +#define _Deref_prepost_valid_cap_x_(size) +#define _Deref_prepost_z_ +#define _Deref_prepost_z_bytecap_(size) +#define _Deref_prepost_z_cap_(size) +#define _Deref_ret_bound_ +#define _Deref_ret_opt_z_ +#define _Deref_ret_range_(lb, ub) +#define _Deref_ret_z_ +#define _Deref2_pre_readonly_ +#define _Field_range_(min, max) +#define _Field_size_(size) +#define _Field_size_bytes_(size) +#define _Field_size_bytes_full_(size) +#define _Field_size_bytes_full_opt_(size) +#define _Field_size_bytes_opt_(size) +#define _Field_size_bytes_part_(size, count) +#define _Field_size_bytes_part_opt_(size, count) +#define _Field_size_full_(size) +#define _Field_size_full_opt_(size) +#define _Field_size_opt_(size) +#define _Field_size_part_(size, count) +#define _Field_size_part_opt_(size, count) +#define _Field_z_ +#define _Function_class_(x) +#define _Group_(annos) +#define _In_ +#define _In_bound_ +#define _In_bytecount_(size) +#define _In_bytecount_c_(size) +#define _In_bytecount_x_(size) +#define _In_count_(size) +#define _In_count_c_(size) +#define _In_count_x_(size) +#define _In_defensive_(annotes) +#define _In_opt_ +#define _In_opt_bytecount_(size) +#define _In_opt_bytecount_c_(size) +#define _In_opt_bytecount_x_(size) +#define _In_opt_count_(size) +#define _In_opt_count_c_(size) +#define _In_opt_count_x_(size) +#define _In_opt_ptrdiff_count_(size) +#define _In_opt_z_ +#define _In_opt_z_bytecount_(size) +#define _In_opt_z_bytecount_c_(size) +#define _In_opt_z_count_(size) +#define _In_opt_z_count_c_(size) +#define _In_ptrdiff_count_(size) +#define _In_range_(lb, ub) +#define _In_reads_(size) +#define _In_reads_bytes_(size) +#define _In_reads_bytes_opt_(size) +#define _In_reads_opt_(size) +#define _In_reads_opt_z_(size) +#define _In_reads_or_z_(size) +#define _In_reads_to_ptr_(ptr) +#define _In_reads_to_ptr_opt_(ptr) +#define _In_reads_to_ptr_opt_z_(ptr) +#define _In_reads_to_ptr_z_(ptr) +#define _In_reads_z_(size) +#define _In_z_ +#define _In_z_bytecount_(size) +#define _In_z_bytecount_c_(size) +#define _In_z_count_(size) +#define _In_z_count_c_(size) +#define _Inout_ +#define _Inout_bytecap_(size) +#define _Inout_bytecap_c_(size) +#define _Inout_bytecap_x_(size) +#define _Inout_bytecount_(size) +#define _Inout_bytecount_c_(size) +#define _Inout_bytecount_x_(size) +#define _Inout_cap_(size) +#define _Inout_cap_c_(size) +#define _Inout_cap_x_(size) +#define _Inout_count_(size) +#define _Inout_count_c_(size) +#define _Inout_count_x_(size) +#define _Inout_defensive_(annotes) +#define _Inout_opt_ +#define _Inout_opt_bytecap_(size) +#define _Inout_opt_bytecap_c_(size) +#define _Inout_opt_bytecap_x_(size) +#define _Inout_opt_bytecount_(size) +#define _Inout_opt_bytecount_c_(size) +#define _Inout_opt_bytecount_x_(size) +#define _Inout_opt_cap_(size) +#define _Inout_opt_cap_c_(size) +#define _Inout_opt_cap_x_(size) +#define _Inout_opt_count_(size) +#define _Inout_opt_count_c_(size) +#define _Inout_opt_count_x_(size) +#define _Inout_opt_ptrdiff_count_(size) +#define _Inout_opt_z_ +#define _Inout_opt_z_bytecap_(size) +#define _Inout_opt_z_bytecap_c_(size) +#define _Inout_opt_z_bytecap_x_(size) +#define _Inout_opt_z_bytecount_(size) +#define _Inout_opt_z_bytecount_c_(size) +#define _Inout_opt_z_cap_(size) +#define _Inout_opt_z_cap_c_(size) +#define _Inout_opt_z_cap_x_(size) +#define _Inout_opt_z_count_(size) +#define _Inout_opt_z_count_c_(size) +#define _Inout_ptrdiff_count_(size) +#define _Inout_updates_(size) +#define _Inout_updates_all_(size) +#define _Inout_updates_all_opt_(size) +#define _Inout_updates_bytes_(size) +#define _Inout_updates_bytes_all_(size) +#define _Inout_updates_bytes_all_opt_(size) +#define _Inout_updates_bytes_opt_(size) +#define _Inout_updates_bytes_to_(size, count) +#define _Inout_updates_bytes_to_opt_(size, count) +#define _Inout_updates_opt_(size) +#define _Inout_updates_opt_z_(size) +#define _Inout_updates_to_(size, count) +#define _Inout_updates_to_opt_(size, count) +#define _Inout_updates_z_(size) +#define _Inout_z_ +#define _Inout_z_bytecap_(size) +#define _Inout_z_bytecap_c_(size) +#define _Inout_z_bytecap_x_(size) +#define _Inout_z_bytecount_(size) +#define _Inout_z_bytecount_c_(size) +#define _Inout_z_cap_(size) +#define _Inout_z_cap_c_(size) +#define _Inout_z_cap_x_(size) +#define _Inout_z_count_(size) +#define _Inout_z_count_c_(size) +#define _Interlocked_operand_ +#define _Literal_ +#define _Maybenull_ +#define _Maybevalid_ +#define _Maybe_raises_SEH_exception +#define _Must_inspect_result_ +#define _Notliteral_ +#define _Notnull_ +#define _Notref_ +#define _Notvalid_ +#define _Null_ +#define _Null_terminated_ +#define _NullNull_terminated_ +#define _On_failure_(annos) +#define _Out_ +#define _Out_bound_ +#define _Out_bytecap_(size) +#define _Out_bytecap_c_(size) +#define _Out_bytecap_post_bytecount_(cap, count) +#define _Out_bytecap_x_(size) +#define _Out_bytecapcount_(capcount) +#define _Out_bytecapcount_x_(capcount) +#define _Out_cap_(size) +#define _Out_cap_c_(size) +#define _Out_cap_m_(mult, size) +#define _Out_cap_post_count_(cap, count) +#define _Out_cap_x_(size) +#define _Out_capcount_(capcount) +#define _Out_capcount_x_(capcount) +#define _Out_defensive_(annotes) +#define _Out_opt_ +#define _Out_opt_bytecap_(size) +#define _Out_opt_bytecap_c_(size) +#define _Out_opt_bytecap_post_bytecount_(cap, count) +#define _Out_opt_bytecap_x_(size) +#define _Out_opt_bytecapcount_(capcount) +#define _Out_opt_bytecapcount_x_(capcount) +#define _Out_opt_cap_(size) +#define _Out_opt_cap_c_(size) +#define _Out_opt_cap_m_(mult, size) +#define _Out_opt_cap_post_count_(cap, count) +#define _Out_opt_cap_x_(size) +#define _Out_opt_capcount_(capcount) +#define _Out_opt_capcount_x_(capcount) +#define _Out_opt_ptrdiff_cap_(size) +#define _Out_opt_z_bytecap_(size) +#define _Out_opt_z_bytecap_c_(size) +#define _Out_opt_z_bytecap_post_bytecount_(cap, count) +#define _Out_opt_z_bytecap_x_(size) +#define _Out_opt_z_bytecapcount_(capcount) +#define _Out_opt_z_cap_(size) +#define _Out_opt_z_cap_c_(size) +#define _Out_opt_z_cap_m_(mult, size) +#define _Out_opt_z_cap_post_count_(cap, count) +#define _Out_opt_z_cap_x_(size) +#define _Out_opt_z_capcount_(capcount) +#define _Out_ptrdiff_cap_(size) +#define _Out_range_(lb, ub) +#define _Out_writes_(size) +#define _Out_writes_all_(size) +#define _Out_writes_all_opt_(size) +#define _Out_writes_bytes_(size) +#define _Out_writes_bytes_all_(size) +#define _Out_writes_bytes_all_opt_(size) +#define _Out_writes_bytes_opt_(size) +#define _Out_writes_bytes_to_(size, count) +#define _Out_writes_bytes_to_opt_(size, count) +#define _Out_writes_opt_(size) +#define _Out_writes_opt_z_(size) +#define _Out_writes_to_(size, count) +#define _Out_writes_to_opt_(size, count) +#define _Out_writes_to_ptr_(ptr) +#define _Out_writes_to_ptr_opt_(ptr) +#define _Out_writes_to_ptr_opt_z_(ptr) +#define _Out_writes_to_ptr_z_(ptr) +#define _Out_writes_z_(size) +#define _Out_z_bytecap_(size) +#define _Out_z_bytecap_c_(size) +#define _Out_z_bytecap_post_bytecount_(cap, count) +#define _Out_z_bytecap_x_(size) +#define _Out_z_bytecapcount_(capcount) +#define _Out_z_cap_(size) +#define _Out_z_cap_c_(size) +#define _Out_z_cap_m_(mult, size) +#define _Out_z_cap_post_count_(cap, count) +#define _Out_z_cap_x_(size) +#define _Out_z_capcount_(capcount) +#define _Outptr_ +#define _Outptr_opt_ +#define _Outptr_opt_result_buffer_(size) +#define _Outptr_opt_result_buffer_all_(size) +#define _Outptr_opt_result_buffer_all_maybenull_(size) +#define _Outptr_opt_result_buffer_maybenull_(size) +#define _Outptr_opt_result_buffer_to_(size, count) +#define _Outptr_opt_result_buffer_to_maybenull_(size, count) +#define _Outptr_opt_result_bytebuffer_(size) +#define _Outptr_opt_result_bytebuffer_all_(size) +#define _Outptr_opt_result_bytebuffer_all_maybenull_(size) +#define _Outptr_opt_result_bytebuffer_maybenull_(size) +#define _Outptr_opt_result_bytebuffer_to_(size, count) +#define _Outptr_opt_result_bytebuffer_to_maybenull_(size, count) +#define _Outptr_opt_result_maybenull_ +#define _Outptr_opt_result_maybenull_z_ +#define _Outptr_opt_result_nullonfailure_ +#define _Outptr_opt_result_z_ +#define _Outptr_result_buffer_(size) +#define _Outptr_result_buffer_all_(size) +#define _Outptr_result_buffer_all_maybenull_(size) +#define _Outptr_result_buffer_maybenull_(size) +#define _Outptr_result_buffer_to_(size, count) +#define _Outptr_result_buffer_to_maybenull_(size, count) +#define _Outptr_result_bytebuffer_(size) +#define _Outptr_result_bytebuffer_all_(size) +#define _Outptr_result_bytebuffer_all_maybenull_(size) +#define _Outptr_result_bytebuffer_maybenull_(size) +#define _Outptr_result_bytebuffer_to_(size, count) +#define _Outptr_result_bytebuffer_to_maybenull_(size, count) +#define _Outptr_result_maybenull_ +#define _Outptr_result_maybenull_z_ +#define _Outptr_result_nullonfailure_ +#define _Outptr_result_z_ +#define _Outref_ +#define _Outref_result_buffer_(size) +#define _Outref_result_buffer_all_(size) +#define _Outref_result_buffer_all_maybenull_(size) +#define _Outref_result_buffer_maybenull_(size) +#define _Outref_result_buffer_to_(size, count) +#define _Outref_result_buffer_to_maybenull_(size, count) +#define _Outref_result_bytebuffer_(size) +#define _Outref_result_bytebuffer_all_(size) +#define _Outref_result_bytebuffer_all_maybenull_(size) +#define _Outref_result_bytebuffer_maybenull_(size) +#define _Outref_result_bytebuffer_to_(size, count) +#define _Outref_result_bytebuffer_to_maybenull_(size, count) +#define _Outref_result_maybenull_ +#define _Outref_result_nullonfailure_ +#define _Points_to_data_ +#define _Post_ +#define _Post_bytecap_(size) +#define _Post_bytecount_(size) +#define _Post_bytecount_c_(size) +#define _Post_bytecount_x_(size) +#define _Post_cap_(size) +#define _Post_count_(size) +#define _Post_count_c_(size) +#define _Post_count_x_(size) +#define _Post_defensive_ +#define _Post_equal_to_(expr) +#define _Post_invalid_ +#define _Post_maybenull_ +#define _Post_maybez_ +#define _Post_notnull_ +#define _Post_null_ +#define _Post_ptr_invalid_ +#define _Post_readable_byte_size_(size) +#define _Post_readable_size_(size) +#define _Post_satisfies_(cond) +#define _Post_valid_ +#define _Post_writable_byte_size_(size) +#define _Post_writable_size_(size) +#define _Post_z_ +#define _Post_z_bytecount_(size) +#define _Post_z_bytecount_c_(size) +#define _Post_z_bytecount_x_(size) +#define _Post_z_count_(size) +#define _Post_z_count_c_(size) +#define _Post_z_count_x_(size) +#define _Pre_ +#define _Pre_bytecap_(size) +#define _Pre_bytecap_c_(size) +#define _Pre_bytecap_x_(size) +#define _Pre_bytecount_(size) +#define _Pre_bytecount_c_(size) +#define _Pre_bytecount_x_(size) +#define _Pre_cap_(size) +#define _Pre_cap_c_(size) +#define _Pre_cap_c_one_ +#define _Pre_cap_for_(param) +#define _Pre_cap_m_(mult, size) +#define _Pre_cap_x_(size) +#define _Pre_count_(size) +#define _Pre_count_c_(size) +#define _Pre_count_x_(size) +#define _Pre_defensive_ +#define _Pre_equal_to_(expr) +#define _Pre_invalid_ +#define _Pre_maybenull_ +#define _Pre_notnull_ +#define _Pre_null_ +#define _Pre_opt_bytecap_(size) +#define _Pre_opt_bytecap_c_(size) +#define _Pre_opt_bytecap_x_(size) +#define _Pre_opt_bytecount_(size) +#define _Pre_opt_bytecount_c_(size) +#define _Pre_opt_bytecount_x_(size) +#define _Pre_opt_cap_(size) +#define _Pre_opt_cap_c_(size) +#define _Pre_opt_cap_c_one_ +#define _Pre_opt_cap_for_(param) +#define _Pre_opt_cap_m_(mult, size) +#define _Pre_opt_cap_x_(size) +#define _Pre_opt_count_(size) +#define _Pre_opt_count_c_(size) +#define _Pre_opt_count_x_(size) +#define _Pre_opt_ptrdiff_cap_(ptr) +#define _Pre_opt_ptrdiff_count_(ptr) +#define _Pre_opt_valid_ +#define _Pre_opt_valid_bytecap_(size) +#define _Pre_opt_valid_bytecap_c_(size) +#define _Pre_opt_valid_bytecap_x_(size) +#define _Pre_opt_valid_cap_(size) +#define _Pre_opt_valid_cap_c_(size) +#define _Pre_opt_valid_cap_x_(size) +#define _Pre_opt_z_ +#define _Pre_opt_z_bytecap_(size) +#define _Pre_opt_z_bytecap_c_(size) +#define _Pre_opt_z_bytecap_x_(size) +#define _Pre_opt_z_cap_(size) +#define _Pre_opt_z_cap_c_(size) +#define _Pre_opt_z_cap_x_(size) +#define _Pre_ptrdiff_cap_(ptr) +#define _Pre_ptrdiff_count_(ptr) +#define _Pre_readable_byte_size_(size) +#define _Pre_readable_size_(size) +#define _Pre_readonly_ +#define _Pre_satisfies_(cond) +#define _Pre_unknown_ +#define _Pre_valid_ +#define _Pre_valid_bytecap_(size) +#define _Pre_valid_bytecap_c_(size) +#define _Pre_valid_bytecap_x_(size) +#define _Pre_valid_cap_(size) +#define _Pre_valid_cap_c_(size) +#define _Pre_valid_cap_x_(size) +#define _Pre_writable_byte_size_(size) +#define _Pre_writable_size_(size) +#define _Pre_writeonly_ +#define _Pre_z_ +#define _Pre_z_bytecap_(size) +#define _Pre_z_bytecap_c_(size) +#define _Pre_z_bytecap_x_(size) +#define _Pre_z_cap_(size) +#define _Pre_z_cap_c_(size) +#define _Pre_z_cap_x_(size) +#define _Prepost_bytecount_(size) +#define _Prepost_bytecount_c_(size) +#define _Prepost_bytecount_x_(size) +#define _Prepost_count_(size) +#define _Prepost_count_c_(size) +#define _Prepost_count_x_(size) +#define _Prepost_opt_bytecount_(size) +#define _Prepost_opt_bytecount_c_(size) +#define _Prepost_opt_bytecount_x_(size) +#define _Prepost_opt_count_(size) +#define _Prepost_opt_count_c_(size) +#define _Prepost_opt_count_x_(size) +#define _Prepost_opt_valid_ +#define _Prepost_opt_z_ +#define _Prepost_valid_ +#define _Prepost_z_ +#define _Printf_format_string_ +#define _Raises_SEH_exception_ +#define _Maybe_raises_SEH_exception_ +#define _Readable_bytes_(size) +#define _Readable_elements_(size) +#define _Reserved_ +#define _Result_nullonfailure_ +#define _Result_zeroonfailure_ +#define __inner_callback +#define _Ret_ +#define _Ret_bound_ +#define _Ret_bytecap_(size) +#define _Ret_bytecap_c_(size) +#define _Ret_bytecap_x_(size) +#define _Ret_bytecount_(size) +#define _Ret_bytecount_c_(size) +#define _Ret_bytecount_x_(size) +#define _Ret_cap_(size) +#define _Ret_cap_c_(size) +#define _Ret_cap_x_(size) +#define _Ret_count_(size) +#define _Ret_count_c_(size) +#define _Ret_count_x_(size) +#define _Ret_maybenull_ +#define _Ret_maybenull_z_ +#define _Ret_notnull_ +#define _Ret_null_ +#define _Ret_opt_ +#define _Ret_opt_bytecap_(size) +#define _Ret_opt_bytecap_c_(size) +#define _Ret_opt_bytecap_x_(size) +#define _Ret_opt_bytecount_(size) +#define _Ret_opt_bytecount_c_(size) +#define _Ret_opt_bytecount_x_(size) +#define _Ret_opt_cap_(size) +#define _Ret_opt_cap_c_(size) +#define _Ret_opt_cap_x_(size) +#define _Ret_opt_count_(size) +#define _Ret_opt_count_c_(size) +#define _Ret_opt_count_x_(size) +#define _Ret_opt_valid_ +#define _Ret_opt_z_ +#define _Ret_opt_z_bytecap_(size) +#define _Ret_opt_z_bytecount_(size) +#define _Ret_opt_z_cap_(size) +#define _Ret_opt_z_count_(size) +#define _Ret_range_(lb, ub) +#define _Ret_valid_ +#define _Ret_writes_(size) +#define _Ret_writes_bytes_(size) +#define _Ret_writes_bytes_maybenull_(size) +#define _Ret_writes_bytes_to_(size, count) +#define _Ret_writes_bytes_to_maybenull_(size, count) +#define _Ret_writes_maybenull_(size) +#define _Ret_writes_maybenull_z_(size) +#define _Ret_writes_to_(size, count) +#define _Ret_writes_to_maybenull_(size, count) +#define _Ret_writes_z_(size) +#define _Ret_z_ +#define _Ret_z_bytecap_(size) +#define _Ret_z_bytecount_(size) +#define _Ret_z_cap_(size) +#define _Ret_z_count_(size) +#define _Return_type_success_(expr) +#define _Scanf_format_string_ +#define _Scanf_s_format_string_ +#define _Struct_size_bytes_(size) +#define _Success_(expr) +#define _Unchanged_(e) +#define _Use_decl_annotations_ +#define _Valid_ +#define _When_(expr, annos) +#define _Writable_bytes_(size) +#define _Writable_elements_(size) + +#define __bcount(size) +#define __bcount_opt(size) +#define __deref_bcount(size) +#define __deref_bcount_opt(size) +#define __deref_ecount(size) +#define __deref_ecount_opt(size) +#define __deref_in +#define __deref_in_bcount(size) +#define __deref_in_bcount_opt(size) +#define __deref_in_ecount(size) +#define __deref_in_ecount_opt(size) +#define __deref_in_opt +#define __deref_inout +#define __deref_inout_bcount(size) +#define __deref_inout_bcount_full(size) +#define __deref_inout_bcount_full_opt(size) +#define __deref_inout_bcount_opt(size) +#define __deref_inout_bcount_part(size, length) +#define __deref_inout_bcount_part_opt(size, length) +#define __deref_inout_ecount(size) +#define __deref_inout_ecount_full(size) +#define __deref_inout_ecount_full_opt(size) +#define __deref_inout_ecount_opt(size) +#define __deref_inout_ecount_part(size, length) +#define __deref_inout_ecount_part_opt(size, length) +#define __deref_inout_opt +#define __deref_opt_bcount(size) +#define __deref_opt_bcount_opt(size) +#define __deref_opt_ecount(size) +#define __deref_opt_ecount_opt(size) +#define __deref_opt_in +#define __deref_opt_in_bcount(size) +#define __deref_opt_in_bcount_opt(size) +#define __deref_opt_in_ecount(size) +#define __deref_opt_in_ecount_opt(size) +#define __deref_opt_in_opt +#define __deref_opt_inout +#define __deref_opt_inout_bcount(size) +#define __deref_opt_inout_bcount_full(size) +#define __deref_opt_inout_bcount_full_opt(size) +#define __deref_opt_inout_bcount_opt(size) +#define __deref_opt_inout_bcount_part(size, length) +#define __deref_opt_inout_bcount_part_opt(size, length) +#define __deref_opt_inout_ecount(size) +#define __deref_opt_inout_ecount_full(size) +#define __deref_opt_inout_ecount_full_opt(size) +#define __deref_opt_inout_ecount_opt(size) +#define __deref_opt_inout_ecount_part(size, length) +#define __deref_opt_inout_ecount_part_opt(size, length) +#define __deref_opt_inout_opt +#define __deref_opt_out +#define __deref_opt_out_bcount(size) +#define __deref_opt_out_bcount_full(size) +#define __deref_opt_out_bcount_full_opt(size) +#define __deref_opt_out_bcount_opt(size) +#define __deref_opt_out_bcount_part(size, length) +#define __deref_opt_out_bcount_part_opt(size, length) +#define __deref_opt_out_ecount(size) +#define __deref_opt_out_ecount_full(size) +#define __deref_opt_out_ecount_full_opt(size) +#define __deref_opt_out_ecount_opt(size) +#define __deref_opt_out_ecount_part(size, length) +#define __deref_opt_out_ecount_part_opt(size, length) +#define __deref_opt_out_opt +#define __deref_out +#define __deref_out_bcount(size) +#define __deref_out_bcount_full(size) +#define __deref_out_bcount_full_opt(size) +#define __deref_out_bcount_opt(size) +#define __deref_out_bcount_part(size, length) +#define __deref_out_bcount_part_opt(size, length) +#define __deref_out_ecount(size) +#define __deref_out_ecount_full(size) +#define __deref_out_ecount_full_opt(size) +#define __deref_out_ecount_opt(size) +#define __deref_out_ecount_part(size, length) +#define __deref_out_ecount_part_opt(size, length) +#define __deref_out_opt +#define __ecount(size) +#define __ecount_opt(size) +//#define __in /* Conflicts with libstdc++ header macros */ +#define __in_bcount(size) +#define __in_bcount_opt(size) +#define __in_ecount(size) +#define __in_ecount_opt(size) +#define __in_opt +#define __inout +#define __inout_bcount(size) +#define __inout_bcount_full(size) +#define __inout_bcount_full_opt(size) +#define __inout_bcount_opt(size) +#define __inout_bcount_part(size, length) +#define __inout_bcount_part_opt(size, length) +#define __inout_ecount(size) +#define __inout_ecount_full(size) +#define __inout_ecount_full_opt(size) +#define __inout_ecount_opt(size) +#define __inout_ecount_part(size, length) +#define __inout_ecount_part_opt(size, length) +#define __inout_opt +//#define __out /* Conflicts with libstdc++ header macros */ +#define __out_bcount(size) +#define __out_bcount_full(size) +#define __out_bcount_full_opt(size) +#define __out_bcount_opt(size) +#define __out_bcount_part(size, length) +#define __out_bcount_part_opt(size, length) +#define __out_ecount(size) +#define __out_ecount_full(size) +#define __out_ecount_full_opt(size) +#define __out_ecount_opt(size) +#define __out_ecount_part(size, length) +#define __out_ecount_part_opt(size, length) +#define __out_opt + +#define __blocksOn(resource) +#define __callback +#define __checkReturn +#define __format_string +#define __in_awcount(expr, size) +#define __nullnullterminated +#define __nullterminated +#define __out_awcount(expr, size) +#define __override +//#define __reserved /* Conflicts with header included by CarbonCore.h on OS X */ +#define __success(expr) +#define __typefix(ctype) + +#ifndef _countof +#ifndef __cplusplus +#define _countof(_Array) (sizeof(_Array) / sizeof(_Array[0])) +#else +extern "C++" +{ + template <typename _CountofType, size_t _SizeOfArray> + char (*__countof_helper(_CountofType (&_Array)[_SizeOfArray]))[_SizeOfArray]; +#define _countof(_Array) sizeof(*__countof_helper(_Array)) +} +#endif +#endif + +/** + * RTL Definitions + */ + +#define MINCHAR 0x80 +#define MAXCHAR 0x7F + +#ifndef MINSHORT +#define MINSHORT 0x8000 +#endif + +#ifndef MAXSHORT +#define MAXSHORT 0x7FFF +#endif + +#define MINLONG 0x80000000 +#define MAXLONG 0x7FFFFFFF +#define MAXBYTE 0xFF +#define MAXWORD 0xFFFF +#define MAXDWORD 0xFFFFFFFF + +#define FIELD_OFFSET(type, field) ((LONG)(LONG_PTR) & (((type*)0)->field)) + +#define RTL_FIELD_SIZE(type, field) (sizeof(((type*)0)->field)) + +#define RTL_SIZEOF_THROUGH_FIELD(type, field) \ + (FIELD_OFFSET(type, field) + RTL_FIELD_SIZE(type, field)) + +#define RTL_CONTAINS_FIELD(Struct, Size, Field) \ + ((((PCHAR)(&(Struct)->Field)) + sizeof((Struct)->Field)) <= (((PCHAR)(Struct)) + (Size))) + +#define RTL_NUMBER_OF_V1(A) (sizeof(A) / sizeof((A)[0])) +#define RTL_NUMBER_OF_V2(A) RTL_NUMBER_OF_V1(A) + +#define RTL_NUMBER_OF(A) RTL_NUMBER_OF_V1(A) + +#define ARRAYSIZE(A) RTL_NUMBER_OF_V2(A) +#define _ARRAYSIZE(A) RTL_NUMBER_OF_V1(A) + +#define RTL_FIELD_TYPE(type, field) (((type*)0)->field) + +#define RTL_NUMBER_OF_FIELD(type, field) (RTL_NUMBER_OF(RTL_FIELD_TYPE(type, field))) + +#define RTL_PADDING_BETWEEN_FIELDS(T, F1, F2) \ + ((FIELD_OFFSET(T, F2) > FIELD_OFFSET(T, F1)) \ + ? (FIELD_OFFSET(T, F2) - FIELD_OFFSET(T, F1) - RTL_FIELD_SIZE(T, F1)) \ + : (FIELD_OFFSET(T, F1) - FIELD_OFFSET(T, F2) - RTL_FIELD_SIZE(T, F2))) + +#if defined(__cplusplus) +#define RTL_CONST_CAST(type) const_cast<type> +#else +#define RTL_CONST_CAST(type) (type) +#endif + +#define RTL_BITS_OF(sizeOfArg) (sizeof(sizeOfArg) * 8) + +#define RTL_BITS_OF_FIELD(type, field) (RTL_BITS_OF(RTL_FIELD_TYPE(type, field))) + +#define CONTAINING_RECORD(address, type, field) \ + ((type*)((PCHAR)(address) - (ULONG_PTR)(&((type*)0)->field))) + +#if defined(__clang__) +WINPR_PRAGMA_DIAG_POP +#endif + +#endif + +#if defined(_WIN32) || defined(__CYGWIN__) +#ifdef __GNUC__ +#define DECLSPEC_EXPORT __attribute__((dllexport)) +#ifndef DECLSPEC_IMPORT +#define DECLSPEC_IMPORT __attribute__((dllimport)) +#endif /* DECLSPEC_IMPORT */ +#else +#define DECLSPEC_EXPORT __declspec(dllexport) +#define DECLSPEC_IMPORT __declspec(dllimport) +#endif /* __GNUC__ */ +#else +#if defined(__GNUC__) && __GNUC__ >= 4 +#define DECLSPEC_EXPORT __attribute__((visibility("default"))) +#define DECLSPEC_IMPORT +#else +#define DECLSPEC_EXPORT +#define DECLSPEC_IMPORT +#endif +#endif + +#endif /* WINPR_SPEC_H */ diff --git a/winpr/include/winpr/ssl.h b/winpr/include/winpr/ssl.h new file mode 100644 index 0000000..ff50097 --- /dev/null +++ b/winpr/include/winpr/ssl.h @@ -0,0 +1,49 @@ +/** + * WinPR: Windows Portable Runtime + * OpenSSL Library Initialization + * + * Copyright 2014 Thincast Technologies GmbH + * Copyright 2014 Norbert Federa <norbert.federa@thincast.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_SSL_H +#define WINPR_SSL_H + +#include <winpr/wtypes.h> +#include <winpr/winpr.h> + +#define WINPR_SSL_INIT_DEFAULT 0x00 +#define WINPR_SSL_INIT_ALREADY_INITIALIZED 0x01 +#define WINPR_SSL_INIT_ENABLE_LOCKING 0x2 +#define WINPR_SSL_INIT_ENABLE_FIPS 0x4 + +#define WINPR_SSL_CLEANUP_GLOBAL 0x01 +#define WINPR_SSL_CLEANUP_THREAD 0x02 + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API BOOL winpr_InitializeSSL(DWORD flags); + WINPR_API BOOL winpr_CleanupSSL(DWORD flags); + + WINPR_API BOOL winpr_FIPSMode(void); + +#ifdef __cplusplus +} +#endif + +#endif /* WINPR_SSL_H */ diff --git a/winpr/include/winpr/sspi.h b/winpr/include/winpr/sspi.h new file mode 100644 index 0000000..e565b40 --- /dev/null +++ b/winpr/include/winpr/sspi.h @@ -0,0 +1,1436 @@ +/** + * WinPR: Windows Portable Runtime + * Security Support Provider Interface (SSPI) + * + * Copyright 2012-2014 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_SSPI_H +#define WINPR_SSPI_H + +#include <winpr/platform.h> +#include <winpr/winpr.h> +#include <winpr/wtypes.h> +#include <winpr/windows.h> +#include <winpr/security.h> + +#ifdef _WIN32 + +#include <tchar.h> +#include <winerror.h> + +#define SECURITY_WIN32 +#include <sspi.h> +#include <security.h> + +#endif /* _WIN32 */ + +#if !defined(_WIN32) || defined(_UWP) + +#ifndef SEC_ENTRY +#define SEC_ENTRY +#endif /* SEC_ENTRY */ + +typedef CHAR SEC_CHAR; +typedef WCHAR SEC_WCHAR; + +typedef struct +{ + UINT32 LowPart; + INT32 HighPart; +} SECURITY_INTEGER; + +typedef SECURITY_INTEGER TimeStamp; +typedef SECURITY_INTEGER* PTimeStamp; + +WINPR_PRAGMA_DIAG_PUSH +WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO + +#ifndef __SECSTATUS_DEFINED__ +typedef LONG SECURITY_STATUS; +#define __SECSTATUS_DEFINED__ +#endif /* __SECSTATUS_DEFINED__ */ + +WINPR_PRAGMA_DIAG_POP + +typedef struct +{ + UINT32 fCapabilities; + UINT16 wVersion; + UINT16 wRPCID; + UINT32 cbMaxToken; + SEC_CHAR* Name; + SEC_CHAR* Comment; +} SecPkgInfoA; +typedef SecPkgInfoA* PSecPkgInfoA; + +typedef struct +{ + UINT32 fCapabilities; + UINT16 wVersion; + UINT16 wRPCID; + UINT32 cbMaxToken; + SEC_WCHAR* Name; + SEC_WCHAR* Comment; +} SecPkgInfoW; +typedef SecPkgInfoW* PSecPkgInfoW; + +#ifdef UNICODE +#define SecPkgInfo SecPkgInfoW +#define PSecPkgInfo PSecPkgInfoW +#else +#define SecPkgInfo SecPkgInfoA +#define PSecPkgInfo PSecPkgInfoA +#endif /* UNICODE */ + +#endif /* !defined(_WIN32) || defined(_UWP) */ + +#define NTLM_SSP_NAME _T("NTLM") +#define KERBEROS_SSP_NAME _T("Kerberos") +#define NEGO_SSP_NAME _T("Negotiate") + +#define SECPKG_ID_NONE 0xFFFF + +#define SECPKG_FLAG_INTEGRITY 0x00000001 +#define SECPKG_FLAG_PRIVACY 0x00000002 +#define SECPKG_FLAG_TOKEN_ONLY 0x00000004 +#define SECPKG_FLAG_DATAGRAM 0x00000008 +#define SECPKG_FLAG_CONNECTION 0x00000010 +#define SECPKG_FLAG_MULTI_REQUIRED 0x00000020 +#define SECPKG_FLAG_CLIENT_ONLY 0x00000040 +#define SECPKG_FLAG_EXTENDED_ERROR 0x00000080 +#define SECPKG_FLAG_IMPERSONATION 0x00000100 +#define SECPKG_FLAG_ACCEPT_WIN32_NAME 0x00000200 +#define SECPKG_FLAG_STREAM 0x00000400 +#define SECPKG_FLAG_NEGOTIABLE 0x00000800 +#define SECPKG_FLAG_GSS_COMPATIBLE 0x00001000 +#define SECPKG_FLAG_LOGON 0x00002000 +#define SECPKG_FLAG_ASCII_BUFFERS 0x00004000 +#define SECPKG_FLAG_FRAGMENT 0x00008000 +#define SECPKG_FLAG_MUTUAL_AUTH 0x00010000 +#define SECPKG_FLAG_DELEGATION 0x00020000 +#define SECPKG_FLAG_READONLY_WITH_CHECKSUM 0x00040000 +#define SECPKG_FLAG_RESTRICTED_TOKENS 0x00080000 +#define SECPKG_FLAG_NEGO_EXTENDER 0x00100000 +#define SECPKG_FLAG_NEGOTIABLE2 0x00200000 + +#ifndef _WINERROR_ + +#define SEC_E_OK (SECURITY_STATUS)0x00000000L +#define SEC_E_INSUFFICIENT_MEMORY (SECURITY_STATUS)0x80090300L +#define SEC_E_INVALID_HANDLE (SECURITY_STATUS)0x80090301L +#define SEC_E_UNSUPPORTED_FUNCTION (SECURITY_STATUS)0x80090302L +#define SEC_E_TARGET_UNKNOWN (SECURITY_STATUS)0x80090303L +#define SEC_E_INTERNAL_ERROR (SECURITY_STATUS)0x80090304L +#define SEC_E_SECPKG_NOT_FOUND (SECURITY_STATUS)0x80090305L +#define SEC_E_NOT_OWNER (SECURITY_STATUS)0x80090306L +#define SEC_E_CANNOT_INSTALL (SECURITY_STATUS)0x80090307L +#define SEC_E_INVALID_TOKEN (SECURITY_STATUS)0x80090308L +#define SEC_E_CANNOT_PACK (SECURITY_STATUS)0x80090309L +#define SEC_E_QOP_NOT_SUPPORTED (SECURITY_STATUS)0x8009030AL +#define SEC_E_NO_IMPERSONATION (SECURITY_STATUS)0x8009030BL +#define SEC_E_LOGON_DENIED (SECURITY_STATUS)0x8009030CL +#define SEC_E_UNKNOWN_CREDENTIALS (SECURITY_STATUS)0x8009030DL +#define SEC_E_NO_CREDENTIALS (SECURITY_STATUS)0x8009030EL +#define SEC_E_MESSAGE_ALTERED (SECURITY_STATUS)0x8009030FL +#define SEC_E_OUT_OF_SEQUENCE (SECURITY_STATUS)0x80090310L +#define SEC_E_NO_AUTHENTICATING_AUTHORITY (SECURITY_STATUS)0x80090311L +#define SEC_E_BAD_PKGID (SECURITY_STATUS)0x80090316L +#define SEC_E_CONTEXT_EXPIRED (SECURITY_STATUS)0x80090317L +#define SEC_E_INCOMPLETE_MESSAGE (SECURITY_STATUS)0x80090318L +#define SEC_E_INCOMPLETE_CREDENTIALS (SECURITY_STATUS)0x80090320L +#define SEC_E_BUFFER_TOO_SMALL (SECURITY_STATUS)0x80090321L +#define SEC_E_WRONG_PRINCIPAL (SECURITY_STATUS)0x80090322L +#define SEC_E_TIME_SKEW (SECURITY_STATUS)0x80090324L +#define SEC_E_UNTRUSTED_ROOT (SECURITY_STATUS)0x80090325L +#define SEC_E_ILLEGAL_MESSAGE (SECURITY_STATUS)0x80090326L +#define SEC_E_CERT_UNKNOWN (SECURITY_STATUS)0x80090327L +#define SEC_E_CERT_EXPIRED (SECURITY_STATUS)0x80090328L +#define SEC_E_ENCRYPT_FAILURE (SECURITY_STATUS)0x80090329L +#define SEC_E_DECRYPT_FAILURE (SECURITY_STATUS)0x80090330L +#define SEC_E_ALGORITHM_MISMATCH (SECURITY_STATUS)0x80090331L +#define SEC_E_SECURITY_QOS_FAILED (SECURITY_STATUS)0x80090332L +#define SEC_E_UNFINISHED_CONTEXT_DELETED (SECURITY_STATUS)0x80090333L +#define SEC_E_NO_TGT_REPLY (SECURITY_STATUS)0x80090334L +#define SEC_E_NO_IP_ADDRESSES (SECURITY_STATUS)0x80090335L +#define SEC_E_WRONG_CREDENTIAL_HANDLE (SECURITY_STATUS)0x80090336L +#define SEC_E_CRYPTO_SYSTEM_INVALID (SECURITY_STATUS)0x80090337L +#define SEC_E_MAX_REFERRALS_EXCEEDED (SECURITY_STATUS)0x80090338L +#define SEC_E_MUST_BE_KDC (SECURITY_STATUS)0x80090339L +#define SEC_E_STRONG_CRYPTO_NOT_SUPPORTED (SECURITY_STATUS)0x8009033AL +#define SEC_E_TOO_MANY_PRINCIPALS (SECURITY_STATUS)0x8009033BL +#define SEC_E_NO_PA_DATA (SECURITY_STATUS)0x8009033CL +#define SEC_E_PKINIT_NAME_MISMATCH (SECURITY_STATUS)0x8009033DL +#define SEC_E_SMARTCARD_LOGON_REQUIRED (SECURITY_STATUS)0x8009033EL +#define SEC_E_SHUTDOWN_IN_PROGRESS (SECURITY_STATUS)0x8009033FL +#define SEC_E_KDC_INVALID_REQUEST (SECURITY_STATUS)0x80090340L +#define SEC_E_KDC_UNABLE_TO_REFER (SECURITY_STATUS)0x80090341L +#define SEC_E_KDC_UNKNOWN_ETYPE (SECURITY_STATUS)0x80090342L +#define SEC_E_UNSUPPORTED_PREAUTH (SECURITY_STATUS)0x80090343L +#define SEC_E_DELEGATION_REQUIRED (SECURITY_STATUS)0x80090345L +#define SEC_E_BAD_BINDINGS (SECURITY_STATUS)0x80090346L +#define SEC_E_MULTIPLE_ACCOUNTS (SECURITY_STATUS)0x80090347L +#define SEC_E_NO_KERB_KEY (SECURITY_STATUS)0x80090348L +#define SEC_E_CERT_WRONG_USAGE (SECURITY_STATUS)0x80090349L +#define SEC_E_DOWNGRADE_DETECTED (SECURITY_STATUS)0x80090350L +#define SEC_E_SMARTCARD_CERT_REVOKED (SECURITY_STATUS)0x80090351L +#define SEC_E_ISSUING_CA_UNTRUSTED (SECURITY_STATUS)0x80090352L +#define SEC_E_REVOCATION_OFFLINE_C (SECURITY_STATUS)0x80090353L +#define SEC_E_PKINIT_CLIENT_FAILURE (SECURITY_STATUS)0x80090354L +#define SEC_E_SMARTCARD_CERT_EXPIRED (SECURITY_STATUS)0x80090355L +#define SEC_E_NO_S4U_PROT_SUPPORT (SECURITY_STATUS)0x80090356L +#define SEC_E_CROSSREALM_DELEGATION_FAILURE (SECURITY_STATUS)0x80090357L +#define SEC_E_REVOCATION_OFFLINE_KDC (SECURITY_STATUS)0x80090358L +#define SEC_E_ISSUING_CA_UNTRUSTED_KDC (SECURITY_STATUS)0x80090359L +#define SEC_E_KDC_CERT_EXPIRED (SECURITY_STATUS)0x8009035AL +#define SEC_E_KDC_CERT_REVOKED (SECURITY_STATUS)0x8009035BL +#define SEC_E_INVALID_PARAMETER (SECURITY_STATUS)0x8009035DL +#define SEC_E_DELEGATION_POLICY (SECURITY_STATUS)0x8009035EL +#define SEC_E_POLICY_NLTM_ONLY (SECURITY_STATUS)0x8009035FL +#define SEC_E_NO_CONTEXT (SECURITY_STATUS)0x80090361L +#define SEC_E_PKU2U_CERT_FAILURE (SECURITY_STATUS)0x80090362L +#define SEC_E_MUTUAL_AUTH_FAILED (SECURITY_STATUS)0x80090363L + +#define SEC_I_CONTINUE_NEEDED (SECURITY_STATUS)0x00090312L +#define SEC_I_COMPLETE_NEEDED (SECURITY_STATUS)0x00090313L +#define SEC_I_COMPLETE_AND_CONTINUE (SECURITY_STATUS)0x00090314L +#define SEC_I_LOCAL_LOGON (SECURITY_STATUS)0x00090315L +#define SEC_I_CONTEXT_EXPIRED (SECURITY_STATUS)0x00090317L +#define SEC_I_INCOMPLETE_CREDENTIALS (SECURITY_STATUS)0x00090320L +#define SEC_I_RENEGOTIATE (SECURITY_STATUS)0x00090321L +#define SEC_I_NO_LSA_CONTEXT (SECURITY_STATUS)0x00090323L +#define SEC_I_SIGNATURE_NEEDED (SECURITY_STATUS)0x0009035CL +#define SEC_I_NO_RENEGOTIATION (SECURITY_STATUS)0x00090360L + +#endif /* _WINERROR_ */ + +/* ============== some definitions missing in mingw ========================*/ +#ifndef SEC_E_INVALID_PARAMETER +#define SEC_E_INVALID_PARAMETER (SECURITY_STATUS)0x8009035DL +#endif + +#ifndef SEC_E_DELEGATION_POLICY +#define SEC_E_DELEGATION_POLICY (SECURITY_STATUS)0x8009035EL +#endif + +#ifndef SEC_E_POLICY_NLTM_ONLY +#define SEC_E_POLICY_NLTM_ONLY (SECURITY_STATUS)0x8009035FL +#endif + +#ifndef SEC_E_NO_CONTEXT +#define SEC_E_NO_CONTEXT (SECURITY_STATUS)0x80090361L +#endif + +#ifndef SEC_E_PKU2U_CERT_FAILURE +#define SEC_E_PKU2U_CERT_FAILURE (SECURITY_STATUS)0x80090362L +#endif + +#ifndef SEC_E_MUTUAL_AUTH_FAILED +#define SEC_E_MUTUAL_AUTH_FAILED (SECURITY_STATUS)0x80090363L +#endif + +#ifndef SEC_I_SIGNATURE_NEEDED +#define SEC_I_SIGNATURE_NEEDED (SECURITY_STATUS)0x0009035CL +#endif + +#ifndef SEC_I_NO_RENEGOTIATION +#define SEC_I_NO_RENEGOTIATION (SECURITY_STATUS)0x00090360L +#endif + +/* ==================================================================================== */ + +#define SECURITY_NATIVE_DREP 0x00000010 +#define SECURITY_NETWORK_DREP 0x00000000 + +#define SECPKG_CRED_INBOUND 0x00000001 +#define SECPKG_CRED_OUTBOUND 0x00000002 +#define SECPKG_CRED_BOTH 0x00000003 +#define SECPKG_CRED_AUTOLOGON_RESTRICTED 0x00000010 +#define SECPKG_CRED_PROCESS_POLICY_ONLY 0x00000020 + +/* Security Context Attributes */ + +#define SECPKG_ATTR_SIZES 0 +#define SECPKG_ATTR_NAMES 1 +#define SECPKG_ATTR_LIFESPAN 2 +#define SECPKG_ATTR_DCE_INFO 3 +#define SECPKG_ATTR_STREAM_SIZES 4 +#define SECPKG_ATTR_KEY_INFO 5 +#define SECPKG_ATTR_AUTHORITY 6 +#define SECPKG_ATTR_PROTO_INFO 7 +#define SECPKG_ATTR_PASSWORD_EXPIRY 8 +#define SECPKG_ATTR_SESSION_KEY 9 +#define SECPKG_ATTR_PACKAGE_INFO 10 +#define SECPKG_ATTR_USER_FLAGS 11 +#define SECPKG_ATTR_NEGOTIATION_INFO 12 +#define SECPKG_ATTR_NATIVE_NAMES 13 +#define SECPKG_ATTR_FLAGS 14 +#define SECPKG_ATTR_USE_VALIDATED 15 +#define SECPKG_ATTR_CREDENTIAL_NAME 16 +#define SECPKG_ATTR_TARGET_INFORMATION 17 +#define SECPKG_ATTR_ACCESS_TOKEN 18 +#define SECPKG_ATTR_TARGET 19 +#define SECPKG_ATTR_AUTHENTICATION_ID 20 +#define SECPKG_ATTR_LOGOFF_TIME 21 +#define SECPKG_ATTR_NEGO_KEYS 22 +#define SECPKG_ATTR_PROMPTING_NEEDED 24 +#define SECPKG_ATTR_UNIQUE_BINDINGS 25 +#define SECPKG_ATTR_ENDPOINT_BINDINGS 26 +#define SECPKG_ATTR_CLIENT_SPECIFIED_TARGET 27 +#define SECPKG_ATTR_LAST_CLIENT_TOKEN_STATUS 30 +#define SECPKG_ATTR_NEGO_PKG_INFO 31 +#define SECPKG_ATTR_NEGO_STATUS 32 +#define SECPKG_ATTR_CONTEXT_DELETED 33 + +#if !defined(_WIN32) || defined(_UWP) + +typedef struct +{ + void* AccessToken; +} SecPkgContext_AccessToken; + +typedef struct +{ + UINT32 dwFlags; + UINT32 cbAppData; + BYTE* pbAppData; +} SecPkgContext_SessionAppData; + +typedef struct +{ + char* sAuthorityName; +} SecPkgContext_Authority; + +typedef struct +{ + char* sTargetName; +} SecPkgContext_ClientSpecifiedTarget; + +typedef UINT32 ALG_ID; + +typedef struct +{ + UINT32 dwProtocol; + ALG_ID aiCipher; + UINT32 dwCipherStrength; + ALG_ID aiHash; + UINT32 dwHashStrength; + ALG_ID aiExch; + UINT32 dwExchStrength; +} SecPkgContext_ConnectionInfo; + +typedef struct +{ + UINT32 AuthBufferLen; + BYTE* AuthBuffer; +} SecPkgContext_ClientCreds; + +typedef struct +{ + UINT32 AuthzSvc; + void* pPac; +} SecPkgContex_DceInfo; + +typedef struct +{ + UINT32 dwInitiatorAddrType; + UINT32 cbInitiatorLength; + UINT32 dwInitiatorOffset; + UINT32 dwAcceptorAddrType; + UINT32 cbAcceptorLength; + UINT32 dwAcceptorOffset; + UINT32 cbApplicationDataLength; + UINT32 dwApplicationDataOffset; +} SEC_CHANNEL_BINDINGS; + +typedef struct +{ + BYTE rgbKeys[128]; + BYTE rgbIVs[64]; +} SecPkgContext_EapKeyBlock; + +typedef struct +{ + UINT32 Flags; +} SecPkgContext_Flags; + +typedef struct +{ + char* sSignatureAlgorithmName; + char* sEncryptAlgorithmName; + UINT32 KeySize; + UINT32 SignatureAlgorithm; + UINT32 EncryptAlgorithm; +} SecPkgContext_KeyInfo; + +typedef struct +{ + TimeStamp tsStart; + TimeStamp tsExpiry; +} SecPkgContext_Lifespan; + +typedef struct +{ + char* sUserName; +} SecPkgContext_Names; + +typedef struct +{ + char* sClientName; + char* sServerName; +} SecPkgContext_NativeNames; + +typedef struct +{ + SecPkgInfo* PackageInfo; + UINT32 NegotiationState; +} SecPkgContext_NegotiationInfo; + +typedef struct +{ + SecPkgInfo* PackageInfo; +} SecPkgContext_PackageInfo; + +typedef struct +{ + TimeStamp tsPasswordExpires; +} SecPkgContext_PasswordExpiry; + +typedef struct +{ + UINT32 SessionKeyLength; + BYTE* SessionKey; +} SecPkgContext_SessionKey; + +typedef struct +{ + UINT32 dwFlags; + UINT32 cbSessionId; + BYTE rgbSessionId[32]; +} SecPkgContext_SessionInfo; + +typedef struct +{ + UINT32 cbMaxToken; + UINT32 cbMaxSignature; + UINT32 cbBlockSize; + UINT32 cbSecurityTrailer; +} SecPkgContext_Sizes; + +typedef struct +{ + UINT32 cbHeader; + UINT32 cbTrailer; + UINT32 cbMaximumMessage; + UINT32 cBuffers; + UINT32 cbBlockSize; +} SecPkgContext_StreamSizes; + +typedef struct +{ + void* AttributeInfo; +} SecPkgContext_SubjectAttributes; + +typedef struct +{ + UINT16 cSignatureAndHashAlgorithms; + UINT16* pSignatureAndHashAlgorithms; +} SecPkgContext_SupportedSignatures; + +typedef struct +{ + UINT32 MarshalledTargetInfoLength; + BYTE* MarshalledTargetInfo; +} SecPkgContext_TargetInformation; + +/* Security Credentials Attributes */ + +#define SECPKG_CRED_ATTR_NAMES 1 +#define SECPKG_CRED_ATTR_SSI_PROVIDER 2 +#define SECPKG_CRED_ATTR_CERT 4 +#define SECPKG_CRED_ATTR_PAC_BYPASS 5 + +typedef struct +{ + SEC_CHAR* sUserName; +} SecPkgCredentials_NamesA; +typedef SecPkgCredentials_NamesA* PSecPkgCredentials_NamesA; + +typedef struct +{ + SEC_WCHAR* sUserName; +} SecPkgCredentials_NamesW; +typedef SecPkgCredentials_NamesW* PSecPkgCredentials_NamesW; + +#ifdef UNICODE +#define SecPkgCredentials_Names SecPkgCredentials_NamesW +#define PSecPkgCredentials_Names PSecPkgCredentials_NamesW +#else +#define SecPkgCredentials_Names SecPkgCredentials_NamesA +#define PSecPkgCredentials_Names PSecPkgCredentials_NamesA +#endif + +typedef struct +{ + SEC_WCHAR* sProviderName; + unsigned long ProviderInfoLength; + char* ProviderInfo; +} SecPkgCredentials_SSIProviderW, *PSecPkgCredentials_SSIProviderW; + +typedef struct +{ + SEC_CHAR* sProviderName; + unsigned long ProviderInfoLength; + char* ProviderInfo; +} SecPkgCredentials_SSIProviderA, *PSecPkgCredentials_SSIProviderA; + +#ifdef UNICODE +#define SecPkgCredentials_SSIProvider SecPkgCredentials_SSIProviderW +#define PSecPkgCredentials_SSIProvider PSecPkgCredentials_SSIProviderW +#else +#define SecPkgCredentials_SSIProvider SecPkgCredentials_SSIProviderA +#define PSecPkgCredentials_SSIProvider PSecPkgCredentials_SSIProviderA +#endif + +typedef struct _SecPkgCredentials_Cert +{ + unsigned long EncodedCertSize; + unsigned char* EncodedCert; +} SecPkgCredentials_Cert, *PSecPkgCredentials_Cert; + +#endif /* !defined(_WIN32) || defined(_UWP) */ + +#if !defined(_WIN32) || defined(_UWP) || (defined(__MINGW32__) && (__MINGW64_VERSION_MAJOR <= 8)) + +#define SECPKG_CRED_ATTR_KDC_PROXY_SETTINGS 3 + +#define KDC_PROXY_SETTINGS_V1 1 +#define KDC_PROXY_SETTINGS_FLAGS_FORCEPROXY 0x1 + +typedef struct +{ + ULONG Version; + ULONG Flags; + USHORT ProxyServerOffset; + USHORT ProxyServerLength; + USHORT ClientTlsCredOffset; + USHORT ClientTlsCredLength; +} SecPkgCredentials_KdcProxySettingsW, *PSecPkgCredentials_KdcProxySettingsW; + +typedef struct +{ + ULONG Version; + ULONG Flags; + USHORT ProxyServerOffset; + USHORT ProxyServerLength; + USHORT ClientTlsCredOffset; + USHORT ClientTlsCredLength; +} SecPkgCredentials_KdcProxySettingsA, *PSecPkgCredentials_KdcProxySettingsA; + +#ifdef UNICODE +#define SecPkgCredentials_KdcProxySettings SecPkgCredentials_KdcProxySettingsW +#define PSecPkgCredentials_KdcProxySettings PSecPkgCredentials_KdcProxySettingsW +#else +#define SecPkgCredentials_KdcProxySettings SecPkgCredentials_KdcProxySettingsA +#define PSecPkgCredentials_KdcProxySettings SecPkgCredentials_KdcProxySettingsA +#endif + +typedef struct +{ + UINT32 BindingsLength; + SEC_CHANNEL_BINDINGS* Bindings; +} SecPkgContext_Bindings; +#endif + +/* InitializeSecurityContext Flags */ + +#define ISC_REQ_DELEGATE 0x00000001 +#define ISC_REQ_MUTUAL_AUTH 0x00000002 +#define ISC_REQ_REPLAY_DETECT 0x00000004 +#define ISC_REQ_SEQUENCE_DETECT 0x00000008 +#define ISC_REQ_CONFIDENTIALITY 0x00000010 +#define ISC_REQ_USE_SESSION_KEY 0x00000020 +#define ISC_REQ_PROMPT_FOR_CREDS 0x00000040 +#define ISC_REQ_USE_SUPPLIED_CREDS 0x00000080 +#define ISC_REQ_ALLOCATE_MEMORY 0x00000100 +#define ISC_REQ_USE_DCE_STYLE 0x00000200 +#define ISC_REQ_DATAGRAM 0x00000400 +#define ISC_REQ_CONNECTION 0x00000800 +#define ISC_REQ_CALL_LEVEL 0x00001000 +#define ISC_REQ_FRAGMENT_SUPPLIED 0x00002000 +#define ISC_REQ_EXTENDED_ERROR 0x00004000 +#define ISC_REQ_STREAM 0x00008000 +#define ISC_REQ_INTEGRITY 0x00010000 +#define ISC_REQ_IDENTIFY 0x00020000 +#define ISC_REQ_NULL_SESSION 0x00040000 +#define ISC_REQ_MANUAL_CRED_VALIDATION 0x00080000 +#define ISC_REQ_RESERVED1 0x00100000 +#define ISC_REQ_FRAGMENT_TO_FIT 0x00200000 +#define ISC_REQ_FORWARD_CREDENTIALS 0x00400000 +#define ISC_REQ_NO_INTEGRITY 0x00800000 +#define ISC_REQ_USE_HTTP_STYLE 0x01000000 + +#define ISC_RET_DELEGATE 0x00000001 +#define ISC_RET_MUTUAL_AUTH 0x00000002 +#define ISC_RET_REPLAY_DETECT 0x00000004 +#define ISC_RET_SEQUENCE_DETECT 0x00000008 +#define ISC_RET_CONFIDENTIALITY 0x00000010 +#define ISC_RET_USE_SESSION_KEY 0x00000020 +#define ISC_RET_USED_COLLECTED_CREDS 0x00000040 +#define ISC_RET_USED_SUPPLIED_CREDS 0x00000080 +#define ISC_RET_ALLOCATED_MEMORY 0x00000100 +#define ISC_RET_USED_DCE_STYLE 0x00000200 +#define ISC_RET_DATAGRAM 0x00000400 +#define ISC_RET_CONNECTION 0x00000800 +#define ISC_RET_INTERMEDIATE_RETURN 0x00001000 +#define ISC_RET_CALL_LEVEL 0x00002000 +#define ISC_RET_EXTENDED_ERROR 0x00004000 +#define ISC_RET_STREAM 0x00008000 +#define ISC_RET_INTEGRITY 0x00010000 +#define ISC_RET_IDENTIFY 0x00020000 +#define ISC_RET_NULL_SESSION 0x00040000 +#define ISC_RET_MANUAL_CRED_VALIDATION 0x00080000 +#define ISC_RET_RESERVED1 0x00100000 +#define ISC_RET_FRAGMENT_ONLY 0x00200000 +#define ISC_RET_FORWARD_CREDENTIALS 0x00400000 +#define ISC_RET_USED_HTTP_STYLE 0x01000000 + +/* AcceptSecurityContext Flags */ + +#define ASC_REQ_DELEGATE 0x00000001 +#define ASC_REQ_MUTUAL_AUTH 0x00000002 +#define ASC_REQ_REPLAY_DETECT 0x00000004 +#define ASC_REQ_SEQUENCE_DETECT 0x00000008 +#define ASC_REQ_CONFIDENTIALITY 0x00000010 +#define ASC_REQ_USE_SESSION_KEY 0x00000020 +#define ASC_REQ_ALLOCATE_MEMORY 0x00000100 +#define ASC_REQ_USE_DCE_STYLE 0x00000200 +#define ASC_REQ_DATAGRAM 0x00000400 +#define ASC_REQ_CONNECTION 0x00000800 +#define ASC_REQ_CALL_LEVEL 0x00001000 +#define ASC_REQ_EXTENDED_ERROR 0x00008000 +#define ASC_REQ_STREAM 0x00010000 +#define ASC_REQ_INTEGRITY 0x00020000 +#define ASC_REQ_LICENSING 0x00040000 +#define ASC_REQ_IDENTIFY 0x00080000 +#define ASC_REQ_ALLOW_NULL_SESSION 0x00100000 +#define ASC_REQ_ALLOW_NON_USER_LOGONS 0x00200000 +#define ASC_REQ_ALLOW_CONTEXT_REPLAY 0x00400000 +#define ASC_REQ_FRAGMENT_TO_FIT 0x00800000 +#define ASC_REQ_FRAGMENT_SUPPLIED 0x00002000 +#define ASC_REQ_NO_TOKEN 0x01000000 +#define ASC_REQ_PROXY_BINDINGS 0x04000000 +#define ASC_REQ_ALLOW_MISSING_BINDINGS 0x10000000 + +#define ASC_RET_DELEGATE 0x00000001 +#define ASC_RET_MUTUAL_AUTH 0x00000002 +#define ASC_RET_REPLAY_DETECT 0x00000004 +#define ASC_RET_SEQUENCE_DETECT 0x00000008 +#define ASC_RET_CONFIDENTIALITY 0x00000010 +#define ASC_RET_USE_SESSION_KEY 0x00000020 +#define ASC_RET_ALLOCATED_MEMORY 0x00000100 +#define ASC_RET_USED_DCE_STYLE 0x00000200 +#define ASC_RET_DATAGRAM 0x00000400 +#define ASC_RET_CONNECTION 0x00000800 +#define ASC_RET_CALL_LEVEL 0x00002000 +#define ASC_RET_THIRD_LEG_FAILED 0x00004000 +#define ASC_RET_EXTENDED_ERROR 0x00008000 +#define ASC_RET_STREAM 0x00010000 +#define ASC_RET_INTEGRITY 0x00020000 +#define ASC_RET_LICENSING 0x00040000 +#define ASC_RET_IDENTIFY 0x00080000 +#define ASC_RET_NULL_SESSION 0x00100000 +#define ASC_RET_ALLOW_NON_USER_LOGONS 0x00200000 +#define ASC_RET_FRAGMENT_ONLY 0x00800000 +#define ASC_RET_NO_TOKEN 0x01000000 +#define ASC_RET_NO_PROXY_BINDINGS 0x04000000 +#define ASC_RET_MISSING_BINDINGS 0x10000000 + +#define SEC_WINNT_AUTH_IDENTITY_ANSI 0x1 +#define SEC_WINNT_AUTH_IDENTITY_UNICODE 0x2 +#define SEC_WINNT_AUTH_IDENTITY_MARSHALLED 0x4 +#define SEC_WINNT_AUTH_IDENTITY_ONLY 0x8 +#define SEC_WINNT_AUTH_IDENTITY_EXTENDED 0x100 + +#if !defined(_WIN32) || defined(_UWP) || defined(__MINGW32__) + +WINPR_PRAGMA_DIAG_PUSH +WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO + +#ifndef _AUTH_IDENTITY_DEFINED +#define _AUTH_IDENTITY_DEFINED + +typedef struct +{ + UINT16* User; + ULONG UserLength; + UINT16* Domain; + ULONG DomainLength; + UINT16* Password; + ULONG PasswordLength; + UINT32 Flags; +} SEC_WINNT_AUTH_IDENTITY_W, *PSEC_WINNT_AUTH_IDENTITY_W; + +typedef struct +{ + BYTE* User; + ULONG UserLength; + BYTE* Domain; + ULONG DomainLength; + BYTE* Password; + ULONG PasswordLength; + UINT32 Flags; +} SEC_WINNT_AUTH_IDENTITY_A, *PSEC_WINNT_AUTH_IDENTITY_A; + +// Always define SEC_WINNT_AUTH_IDENTITY to SEC_WINNT_AUTH_IDENTITY_W + +#ifdef UNICODE +#define SEC_WINNT_AUTH_IDENTITY SEC_WINNT_AUTH_IDENTITY_W +#define PSEC_WINNT_AUTH_IDENTITY PSEC_WINNT_AUTH_IDENTITY_W +#else +#define SEC_WINNT_AUTH_IDENTITY SEC_WINNT_AUTH_IDENTITY_W +#define PSEC_WINNT_AUTH_IDENTITY PSEC_WINNT_AUTH_IDENTITY_W +#endif + +#endif /* _AUTH_IDENTITY_DEFINED */ + +#ifndef SEC_WINNT_AUTH_IDENTITY_VERSION +#define SEC_WINNT_AUTH_IDENTITY_VERSION 0x200 + +typedef struct +{ + UINT32 Version; + UINT32 Length; + UINT16* User; + UINT32 UserLength; + UINT16* Domain; + UINT32 DomainLength; + UINT16* Password; + UINT32 PasswordLength; + UINT32 Flags; + UINT16* PackageList; + UINT32 PackageListLength; +} SEC_WINNT_AUTH_IDENTITY_EXW, *PSEC_WINNT_AUTH_IDENTITY_EXW; + +typedef struct +{ + UINT32 Version; + UINT32 Length; + BYTE* User; + UINT32 UserLength; + BYTE* Domain; + UINT32 DomainLength; + BYTE* Password; + UINT32 PasswordLength; + UINT32 Flags; + BYTE* PackageList; + UINT32 PackageListLength; +} SEC_WINNT_AUTH_IDENTITY_EXA, *PSEC_WINNT_AUTH_IDENTITY_EXA; + +#ifdef UNICODE +#define SEC_WINNT_AUTH_IDENTITY_EX SEC_WINNT_AUTH_IDENTITY_EXW +#define PSEC_WINNT_AUTH_IDENTITY_EX PSEC_WINNT_AUTH_IDENTITY_EXW +#else +#define SEC_WINNT_AUTH_IDENTITY_EX SEC_WINNT_AUTH_IDENTITY_EXA +#define PSEC_WINNT_AUTH_IDENTITY_EX PSEC_WINNT_AUTH_IDENTITY_EXA +#endif + +#endif /* SEC_WINNT_AUTH_IDENTITY_VERSION */ + +#ifndef SEC_WINNT_AUTH_IDENTITY_VERSION_2 +#define SEC_WINNT_AUTH_IDENTITY_VERSION_2 0x201 + +typedef struct _SEC_WINNT_AUTH_IDENTITY_EX2 +{ + UINT32 Version; + UINT16 cbHeaderLength; + UINT32 cbStructureLength; + UINT32 UserOffset; + UINT16 UserLength; + UINT32 DomainOffset; + UINT16 DomainLength; + UINT32 PackedCredentialsOffset; + UINT16 PackedCredentialsLength; + UINT32 Flags; + UINT32 PackageListOffset; + UINT16 PackageListLength; +} SEC_WINNT_AUTH_IDENTITY_EX2, *PSEC_WINNT_AUTH_IDENTITY_EX2; + +#endif /* SEC_WINNT_AUTH_IDENTITY_VERSION_2 */ + +#ifndef _AUTH_IDENTITY_INFO_DEFINED +#define _AUTH_IDENTITY_INFO_DEFINED + +// https://docs.microsoft.com/en-us/windows/win32/api/sspi/ns-sspi-sec_winnt_auth_identity_info + +typedef union _SEC_WINNT_AUTH_IDENTITY_INFO +{ + SEC_WINNT_AUTH_IDENTITY_EXW AuthIdExw; + SEC_WINNT_AUTH_IDENTITY_EXA AuthIdExa; + SEC_WINNT_AUTH_IDENTITY_A AuthId_a; + SEC_WINNT_AUTH_IDENTITY_W AuthId_w; + SEC_WINNT_AUTH_IDENTITY_EX2 AuthIdEx2; +} SEC_WINNT_AUTH_IDENTITY_INFO, *PSEC_WINNT_AUTH_IDENTITY_INFO; + +#define SEC_WINNT_AUTH_IDENTITY_FLAGS_PROCESS_ENCRYPTED 0x10 +#define SEC_WINNT_AUTH_IDENTITY_FLAGS_SYSTEM_PROTECTED 0x20 +#define SEC_WINNT_AUTH_IDENTITY_FLAGS_USER_PROTECTED 0x40 +#define SEC_WINNT_AUTH_IDENTITY_FLAGS_SYSTEM_ENCRYPTED 0x80 +#define SEC_WINNT_AUTH_IDENTITY_FLAGS_RESERVED 0x10000 +#define SEC_WINNT_AUTH_IDENTITY_FLAGS_NULL_USER 0x20000 +#define SEC_WINNT_AUTH_IDENTITY_FLAGS_NULL_DOMAIN 0x40000 +#define SEC_WINNT_AUTH_IDENTITY_FLAGS_ID_PROVIDER 0x80000 + +#define SEC_WINNT_AUTH_IDENTITY_FLAGS_SSPIPFC_USE_MASK 0xFF000000 +#define SEC_WINNT_AUTH_IDENTITY_FLAGS_SSPIPFC_CREDPROV_DO_NOT_SAVE 0x80000000 +#define SEC_WINNT_AUTH_IDENTITY_FLAGS_SSPIPFC_SAVE_CRED_CHECKED 0x40000000 +#define SEC_WINNT_AUTH_IDENTITY_FLAGS_SSPIPFC_NO_CHECKBOX 0x20000000 +#define SEC_WINNT_AUTH_IDENTITY_FLAGS_SSPIPFC_CREDPROV_DO_NOT_LOAD 0x10000000 + +#define SEC_WINNT_AUTH_IDENTITY_FLAGS_VALID_SSPIPFC_FLAGS \ + (SEC_WINNT_AUTH_IDENTITY_FLAGS_SSPIPFC_CREDPROV_DO_NOT_SAVE | \ + SEC_WINNT_AUTH_IDENTITY_FLAGS_SSPIPFC_SAVE_CRED_CHECKED | \ + SEC_WINNT_AUTH_IDENTITY_FLAGS_SSPIPFC_NO_CHECKBOX | \ + SEC_WINNT_AUTH_IDENTITY_FLAGS_SSPIPFC_CREDPROV_DO_NOT_LOAD) + +#endif /* _AUTH_IDENTITY_INFO_DEFINED */ + +WINPR_PRAGMA_DIAG_POP + +#if !defined(__MINGW32__) +typedef struct +{ + ULONG_PTR dwLower; + ULONG_PTR dwUpper; +} SecHandle; +typedef SecHandle* PSecHandle; + +typedef SecHandle CredHandle; +typedef CredHandle* PCredHandle; +typedef SecHandle CtxtHandle; +typedef CtxtHandle* PCtxtHandle; + +#define SecInvalidateHandle(x) \ + ((PSecHandle)(x))->dwLower = ((PSecHandle)(x))->dwUpper = ((ULONG_PTR)((INT_PTR)-1)) + +#define SecIsValidHandle(x) \ + ((((PSecHandle)(x))->dwLower != ((ULONG_PTR)((INT_PTR)-1))) && \ + (((PSecHandle)(x))->dwUpper != ((ULONG_PTR)((INT_PTR)-1)))) + +typedef struct +{ + ULONG cbBuffer; + ULONG BufferType; + void* pvBuffer; +} SecBuffer; +typedef SecBuffer* PSecBuffer; + +typedef struct +{ + ULONG ulVersion; + ULONG cBuffers; + PSecBuffer pBuffers; +} SecBufferDesc; +typedef SecBufferDesc* PSecBufferDesc; + +#endif /* __MINGW32__ */ + +#endif /* !defined(_WIN32) || defined(_UWP) || defined(__MINGW32__) */ + +typedef SECURITY_STATUS (*psSspiNtlmHashCallback)(void* client, + const SEC_WINNT_AUTH_IDENTITY* authIdentity, + const SecBuffer* ntproofvalue, + const BYTE* randkey, const BYTE* mic, + const SecBuffer* micvalue, BYTE* ntlmhash); + +typedef struct +{ + char* samFile; + psSspiNtlmHashCallback hashCallback; + void* hashCallbackArg; +} SEC_WINPR_NTLM_SETTINGS; + +typedef struct +{ + char* kdcUrl; + char* keytab; + char* cache; + char* armorCache; + char* pkinitX509Anchors; + char* pkinitX509Identity; + BOOL withPac; + INT32 startTime; + INT32 renewLifeTime; + INT32 lifeTime; + BYTE certSha1[20]; +} SEC_WINPR_KERBEROS_SETTINGS; + +typedef struct +{ + SEC_WINNT_AUTH_IDENTITY_EXW identity; + SEC_WINPR_NTLM_SETTINGS* ntlmSettings; + SEC_WINPR_KERBEROS_SETTINGS* kerberosSettings; +} SEC_WINNT_AUTH_IDENTITY_WINPR; + +#define SECBUFFER_VERSION 0 + +/* Buffer Types */ +#define SECBUFFER_EMPTY 0 +#define SECBUFFER_DATA 1 +#define SECBUFFER_TOKEN 2 +#define SECBUFFER_PKG_PARAMS 3 +#define SECBUFFER_MISSING 4 +#define SECBUFFER_EXTRA 5 +#define SECBUFFER_STREAM_TRAILER 6 +#define SECBUFFER_STREAM_HEADER 7 +#define SECBUFFER_NEGOTIATION_INFO 8 +#define SECBUFFER_PADDING 9 +#define SECBUFFER_STREAM 10 +#define SECBUFFER_MECHLIST 11 +#define SECBUFFER_MECHLIST_SIGNATURE 12 +#define SECBUFFER_TARGET 13 +#define SECBUFFER_CHANNEL_BINDINGS 14 +#define SECBUFFER_CHANGE_PASS_RESPONSE 15 +#define SECBUFFER_TARGET_HOST 16 +#define SECBUFFER_ALERT 17 + +/* Security Buffer Flags */ +#define SECBUFFER_ATTRMASK 0xF0000000 +#define SECBUFFER_READONLY 0x80000000 +#define SECBUFFER_READONLY_WITH_CHECKSUM 0x10000000 +#define SECBUFFER_RESERVED 0x60000000 + +#if !defined(_WIN32) || defined(_UWP) + +typedef void(SEC_ENTRY* SEC_GET_KEY_FN)(void* Arg, void* Principal, UINT32 KeyVer, void** Key, + SECURITY_STATUS* pStatus); + +typedef SECURITY_STATUS(SEC_ENTRY* ENUMERATE_SECURITY_PACKAGES_FN_A)(ULONG* pcPackages, + PSecPkgInfoA* ppPackageInfo); +typedef SECURITY_STATUS(SEC_ENTRY* ENUMERATE_SECURITY_PACKAGES_FN_W)(ULONG* pcPackages, + PSecPkgInfoW* ppPackageInfo); + +#ifdef UNICODE +#define EnumerateSecurityPackages EnumerateSecurityPackagesW +#define ENUMERATE_SECURITY_PACKAGES_FN ENUMERATE_SECURITY_PACKAGES_FN_W +#else +#define EnumerateSecurityPackages EnumerateSecurityPackagesA +#define ENUMERATE_SECURITY_PACKAGES_FN ENUMERATE_SECURITY_PACKAGES_FN_A +#endif + +typedef SECURITY_STATUS(SEC_ENTRY* QUERY_CREDENTIALS_ATTRIBUTES_FN_A)(PCredHandle phCredential, + ULONG ulAttribute, + void* pBuffer); +typedef SECURITY_STATUS(SEC_ENTRY* QUERY_CREDENTIALS_ATTRIBUTES_FN_W)(PCredHandle phCredential, + ULONG ulAttribute, + void* pBuffer); + +#ifdef UNICODE +#define QueryCredentialsAttributes QueryCredentialsAttributesW +#define QUERY_CREDENTIALS_ATTRIBUTES_FN QUERY_CREDENTIALS_ATTRIBUTES_FN_W +#else +#define QueryCredentialsAttributes QueryCredentialsAttributesA +#define QUERY_CREDENTIALS_ATTRIBUTES_FN QUERY_CREDENTIALS_ATTRIBUTES_FN_A +#endif + +typedef SECURITY_STATUS(SEC_ENTRY* ACQUIRE_CREDENTIALS_HANDLE_FN_A)( + LPSTR pszPrincipal, LPSTR pszPackage, ULONG fCredentialUse, void* pvLogonID, void* pAuthData, + SEC_GET_KEY_FN pGetKeyFn, void* pvGetKeyArgument, PCredHandle phCredential, + PTimeStamp ptsExpiry); +typedef SECURITY_STATUS(SEC_ENTRY* ACQUIRE_CREDENTIALS_HANDLE_FN_W)( + LPWSTR pszPrincipal, LPWSTR pszPackage, ULONG fCredentialUse, void* pvLogonID, void* pAuthData, + SEC_GET_KEY_FN pGetKeyFn, void* pvGetKeyArgument, PCredHandle phCredential, + PTimeStamp ptsExpiry); + +#ifdef UNICODE +#define AcquireCredentialsHandle AcquireCredentialsHandleW +#define ACQUIRE_CREDENTIALS_HANDLE_FN ACQUIRE_CREDENTIALS_HANDLE_FN_W +#else +#define AcquireCredentialsHandle AcquireCredentialsHandleA +#define ACQUIRE_CREDENTIALS_HANDLE_FN ACQUIRE_CREDENTIALS_HANDLE_FN_A +#endif + +typedef SECURITY_STATUS(SEC_ENTRY* FREE_CREDENTIALS_HANDLE_FN)(PCredHandle phCredential); + +typedef SECURITY_STATUS(SEC_ENTRY* INITIALIZE_SECURITY_CONTEXT_FN_A)( + PCredHandle phCredential, PCtxtHandle phContext, SEC_CHAR* pszTargetName, ULONG fContextReq, + ULONG Reserved1, ULONG TargetDataRep, PSecBufferDesc pInput, ULONG Reserved2, + PCtxtHandle phNewContext, PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry); +typedef SECURITY_STATUS(SEC_ENTRY* INITIALIZE_SECURITY_CONTEXT_FN_W)( + PCredHandle phCredential, PCtxtHandle phContext, SEC_WCHAR* pszTargetName, ULONG fContextReq, + ULONG Reserved1, ULONG TargetDataRep, PSecBufferDesc pInput, ULONG Reserved2, + PCtxtHandle phNewContext, PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsExpiry); + +#ifdef UNICODE +#define InitializeSecurityContext InitializeSecurityContextW +#define INITIALIZE_SECURITY_CONTEXT_FN INITIALIZE_SECURITY_CONTEXT_FN_W +#else +#define InitializeSecurityContext InitializeSecurityContextA +#define INITIALIZE_SECURITY_CONTEXT_FN INITIALIZE_SECURITY_CONTEXT_FN_A +#endif + +typedef SECURITY_STATUS(SEC_ENTRY* ACCEPT_SECURITY_CONTEXT_FN)( + PCredHandle phCredential, PCtxtHandle phContext, PSecBufferDesc pInput, ULONG fContextReq, + ULONG TargetDataRep, PCtxtHandle phNewContext, PSecBufferDesc pOutput, PULONG pfContextAttr, + PTimeStamp ptsTimeStamp); + +typedef SECURITY_STATUS(SEC_ENTRY* COMPLETE_AUTH_TOKEN_FN)(PCtxtHandle phContext, + PSecBufferDesc pToken); + +typedef SECURITY_STATUS(SEC_ENTRY* DELETE_SECURITY_CONTEXT_FN)(PCtxtHandle phContext); + +typedef SECURITY_STATUS(SEC_ENTRY* APPLY_CONTROL_TOKEN_FN)(PCtxtHandle phContext, + PSecBufferDesc pInput); + +typedef SECURITY_STATUS(SEC_ENTRY* QUERY_CONTEXT_ATTRIBUTES_FN_A)(PCtxtHandle phContext, + ULONG ulAttribute, void* pBuffer); +typedef SECURITY_STATUS(SEC_ENTRY* QUERY_CONTEXT_ATTRIBUTES_FN_W)(PCtxtHandle phContext, + ULONG ulAttribute, void* pBuffer); + +#ifdef UNICODE +#define QueryContextAttributes QueryContextAttributesW +#define QUERY_CONTEXT_ATTRIBUTES_FN QUERY_CONTEXT_ATTRIBUTES_FN_W +#else +#define QueryContextAttributes QueryContextAttributesA +#define QUERY_CONTEXT_ATTRIBUTES_FN QUERY_CONTEXT_ATTRIBUTES_FN_A +#endif + +typedef SECURITY_STATUS(SEC_ENTRY* IMPERSONATE_SECURITY_CONTEXT_FN)(PCtxtHandle phContext); + +typedef SECURITY_STATUS(SEC_ENTRY* REVERT_SECURITY_CONTEXT_FN)(PCtxtHandle phContext); + +typedef SECURITY_STATUS(SEC_ENTRY* MAKE_SIGNATURE_FN)(PCtxtHandle phContext, ULONG fQOP, + PSecBufferDesc pMessage, ULONG MessageSeqNo); + +typedef SECURITY_STATUS(SEC_ENTRY* VERIFY_SIGNATURE_FN)(PCtxtHandle phContext, + PSecBufferDesc pMessage, ULONG MessageSeqNo, + PULONG pfQOP); + +typedef SECURITY_STATUS(SEC_ENTRY* FREE_CONTEXT_BUFFER_FN)(void* pvContextBuffer); + +typedef SECURITY_STATUS(SEC_ENTRY* QUERY_SECURITY_PACKAGE_INFO_FN_A)(SEC_CHAR* pszPackageName, + PSecPkgInfoA* ppPackageInfo); +typedef SECURITY_STATUS(SEC_ENTRY* QUERY_SECURITY_PACKAGE_INFO_FN_W)(SEC_WCHAR* pszPackageName, + PSecPkgInfoW* ppPackageInfo); + +#ifdef UNICODE +#define QuerySecurityPackageInfo QuerySecurityPackageInfoW +#define QUERY_SECURITY_PACKAGE_INFO_FN QUERY_SECURITY_PACKAGE_INFO_FN_W +#else +#define QuerySecurityPackageInfo QuerySecurityPackageInfoA +#define QUERY_SECURITY_PACKAGE_INFO_FN QUERY_SECURITY_PACKAGE_INFO_FN_A +#endif + +typedef SECURITY_STATUS(SEC_ENTRY* EXPORT_SECURITY_CONTEXT_FN)(PCtxtHandle phContext, ULONG fFlags, + PSecBuffer pPackedContext, + HANDLE* pToken); + +typedef SECURITY_STATUS(SEC_ENTRY* IMPORT_SECURITY_CONTEXT_FN_A)(SEC_CHAR* pszPackage, + PSecBuffer pPackedContext, + HANDLE pToken, + PCtxtHandle phContext); +typedef SECURITY_STATUS(SEC_ENTRY* IMPORT_SECURITY_CONTEXT_FN_W)(SEC_WCHAR* pszPackage, + PSecBuffer pPackedContext, + HANDLE pToken, + PCtxtHandle phContext); + +#ifdef UNICODE +#define ImportSecurityContext ImportSecurityContextW +#define IMPORT_SECURITY_CONTEXT_FN IMPORT_SECURITY_CONTEXT_FN_W +#else +#define ImportSecurityContext ImportSecurityContextA +#define IMPORT_SECURITY_CONTEXT_FN IMPORT_SECURITY_CONTEXT_FN_A +#endif + +typedef SECURITY_STATUS(SEC_ENTRY* ADD_CREDENTIALS_FN_A)( + PCredHandle hCredentials, SEC_CHAR* pszPrincipal, SEC_CHAR* pszPackage, UINT32 fCredentialUse, + void* pAuthData, SEC_GET_KEY_FN pGetKeyFn, void* pvGetKeyArgument, PTimeStamp ptsExpiry); +typedef SECURITY_STATUS(SEC_ENTRY* ADD_CREDENTIALS_FN_W)( + PCredHandle hCredentials, SEC_WCHAR* pszPrincipal, SEC_WCHAR* pszPackage, UINT32 fCredentialUse, + void* pAuthData, SEC_GET_KEY_FN pGetKeyFn, void* pvGetKeyArgument, PTimeStamp ptsExpiry); + +#ifdef UNICODE +#define AddCredentials AddCredentialsW +#define ADD_CREDENTIALS_FN ADD_CREDENTIALS_FN_W +#else +#define AddCredentials AddCredentialsA +#define ADD_CREDENTIALS_FN ADD_CREDENTIALS_FN_A +#endif + +typedef SECURITY_STATUS(SEC_ENTRY* QUERY_SECURITY_CONTEXT_TOKEN_FN)(PCtxtHandle phContext, + HANDLE* phToken); + +typedef SECURITY_STATUS(SEC_ENTRY* ENCRYPT_MESSAGE_FN)(PCtxtHandle phContext, ULONG fQOP, + PSecBufferDesc pMessage, ULONG MessageSeqNo); + +typedef SECURITY_STATUS(SEC_ENTRY* DECRYPT_MESSAGE_FN)(PCtxtHandle phContext, + PSecBufferDesc pMessage, ULONG MessageSeqNo, + PULONG pfQOP); + +typedef SECURITY_STATUS(SEC_ENTRY* SET_CONTEXT_ATTRIBUTES_FN_A)(PCtxtHandle phContext, + ULONG ulAttribute, void* pBuffer, + ULONG cbBuffer); +typedef SECURITY_STATUS(SEC_ENTRY* SET_CONTEXT_ATTRIBUTES_FN_W)(PCtxtHandle phContext, + ULONG ulAttribute, void* pBuffer, + ULONG cbBuffer); + +#ifdef UNICODE +#define SetContextAttributes SetContextAttributesW +#define SET_CONTEXT_ATTRIBUTES_FN SET_CONTEXT_ATTRIBUTES_FN_W +#else +#define SetContextAttributes SetContextAttributesA +#define SET_CONTEXT_ATTRIBUTES_FN SET_CONTEXT_ATTRIBUTES_FN_A +#endif + +typedef SECURITY_STATUS(SEC_ENTRY* SET_CREDENTIALS_ATTRIBUTES_FN_A)(PCredHandle phCredential, + ULONG ulAttribute, + void* pBuffer, ULONG cbBuffer); + +typedef SECURITY_STATUS(SEC_ENTRY* SET_CREDENTIALS_ATTRIBUTES_FN_W)(PCredHandle phCredential, + ULONG ulAttribute, + void* pBuffer, ULONG cbBuffer); + +#ifdef UNICODE +#define SetCredentialsAttributes SetCredentialsAttributesW +#define SET_CREDENTIALS_ATTRIBUTES_FN SET_CREDENTIALS_ATTRIBUTES_FN_W +#else +#define SetCredentialsAttributes SetCredentialsAttributesA +#define SET_CREDENTIALS_ATTRIBUTES_FN SET_CREDENTIALS_ATTRIBUTES_FN_A +#endif + +#define SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION \ + 1 /* Interface has all routines through DecryptMessage */ +#define SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION_2 \ + 2 /* Interface has all routines through SetContextAttributes */ +#define SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION_3 \ + 3 /* Interface has all routines through SetCredentialsAttributes */ +#define SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION_4 \ + 4 /* Interface has all routines through ChangeAccountPassword */ + +typedef struct +{ + UINT32 dwVersion; + ENUMERATE_SECURITY_PACKAGES_FN_A EnumerateSecurityPackagesA; + QUERY_CREDENTIALS_ATTRIBUTES_FN_A QueryCredentialsAttributesA; + ACQUIRE_CREDENTIALS_HANDLE_FN_A AcquireCredentialsHandleA; + FREE_CREDENTIALS_HANDLE_FN FreeCredentialsHandle; + void* Reserved2; + INITIALIZE_SECURITY_CONTEXT_FN_A InitializeSecurityContextA; + ACCEPT_SECURITY_CONTEXT_FN AcceptSecurityContext; + COMPLETE_AUTH_TOKEN_FN CompleteAuthToken; + DELETE_SECURITY_CONTEXT_FN DeleteSecurityContext; + APPLY_CONTROL_TOKEN_FN ApplyControlToken; + QUERY_CONTEXT_ATTRIBUTES_FN_A QueryContextAttributesA; + IMPERSONATE_SECURITY_CONTEXT_FN ImpersonateSecurityContext; + REVERT_SECURITY_CONTEXT_FN RevertSecurityContext; + MAKE_SIGNATURE_FN MakeSignature; + VERIFY_SIGNATURE_FN VerifySignature; + FREE_CONTEXT_BUFFER_FN FreeContextBuffer; + QUERY_SECURITY_PACKAGE_INFO_FN_A QuerySecurityPackageInfoA; + void* Reserved3; + void* Reserved4; + EXPORT_SECURITY_CONTEXT_FN ExportSecurityContext; + IMPORT_SECURITY_CONTEXT_FN_A ImportSecurityContextA; + ADD_CREDENTIALS_FN_A AddCredentialsA; + void* Reserved8; + QUERY_SECURITY_CONTEXT_TOKEN_FN QuerySecurityContextToken; + ENCRYPT_MESSAGE_FN EncryptMessage; + DECRYPT_MESSAGE_FN DecryptMessage; + SET_CONTEXT_ATTRIBUTES_FN_A SetContextAttributesA; + SET_CREDENTIALS_ATTRIBUTES_FN_A SetCredentialsAttributesA; +} SecurityFunctionTableA; +typedef SecurityFunctionTableA* PSecurityFunctionTableA; + +typedef struct +{ + UINT32 dwVersion; + ENUMERATE_SECURITY_PACKAGES_FN_W EnumerateSecurityPackagesW; + QUERY_CREDENTIALS_ATTRIBUTES_FN_W QueryCredentialsAttributesW; + ACQUIRE_CREDENTIALS_HANDLE_FN_W AcquireCredentialsHandleW; + FREE_CREDENTIALS_HANDLE_FN FreeCredentialsHandle; + void* Reserved2; + INITIALIZE_SECURITY_CONTEXT_FN_W InitializeSecurityContextW; + ACCEPT_SECURITY_CONTEXT_FN AcceptSecurityContext; + COMPLETE_AUTH_TOKEN_FN CompleteAuthToken; + DELETE_SECURITY_CONTEXT_FN DeleteSecurityContext; + APPLY_CONTROL_TOKEN_FN ApplyControlToken; + QUERY_CONTEXT_ATTRIBUTES_FN_W QueryContextAttributesW; + IMPERSONATE_SECURITY_CONTEXT_FN ImpersonateSecurityContext; + REVERT_SECURITY_CONTEXT_FN RevertSecurityContext; + MAKE_SIGNATURE_FN MakeSignature; + VERIFY_SIGNATURE_FN VerifySignature; + FREE_CONTEXT_BUFFER_FN FreeContextBuffer; + QUERY_SECURITY_PACKAGE_INFO_FN_W QuerySecurityPackageInfoW; + void* Reserved3; + void* Reserved4; + EXPORT_SECURITY_CONTEXT_FN ExportSecurityContext; + IMPORT_SECURITY_CONTEXT_FN_W ImportSecurityContextW; + ADD_CREDENTIALS_FN_W AddCredentialsW; + void* Reserved8; + QUERY_SECURITY_CONTEXT_TOKEN_FN QuerySecurityContextToken; + ENCRYPT_MESSAGE_FN EncryptMessage; + DECRYPT_MESSAGE_FN DecryptMessage; + SET_CONTEXT_ATTRIBUTES_FN_W SetContextAttributesW; + SET_CREDENTIALS_ATTRIBUTES_FN_W SetCredentialsAttributesW; +} SecurityFunctionTableW; +typedef SecurityFunctionTableW* PSecurityFunctionTableW; + +typedef PSecurityFunctionTableA(SEC_ENTRY* INIT_SECURITY_INTERFACE_A)(void); +typedef PSecurityFunctionTableW(SEC_ENTRY* INIT_SECURITY_INTERFACE_W)(void); + +#ifdef UNICODE +#define InitSecurityInterface InitSecurityInterfaceW +#define SecurityFunctionTable SecurityFunctionTableW +#define PSecurityFunctionTable PSecurityFunctionTableW +#define INIT_SECURITY_INTERFACE INIT_SECURITY_INTERFACE_W +#else +#define InitSecurityInterface InitSecurityInterfaceA +#define SecurityFunctionTable SecurityFunctionTableA +#define PSecurityFunctionTable PSecurityFunctionTableA +#define INIT_SECURITY_INTERFACE INIT_SECURITY_INTERFACE_A +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + +#ifdef SSPI_DLL + + /* Package Management */ + + WINPR_API SECURITY_STATUS SEC_ENTRY EnumerateSecurityPackagesA(ULONG* pcPackages, + PSecPkgInfoA* ppPackageInfo); + WINPR_API SECURITY_STATUS SEC_ENTRY EnumerateSecurityPackagesW(ULONG* pcPackages, + PSecPkgInfoW* ppPackageInfo); + + WINPR_API PSecurityFunctionTableA SEC_ENTRY InitSecurityInterfaceA(void); + WINPR_API PSecurityFunctionTableW SEC_ENTRY InitSecurityInterfaceW(void); + + WINPR_API SECURITY_STATUS SEC_ENTRY QuerySecurityPackageInfoA(SEC_CHAR* pszPackageName, + PSecPkgInfoA* ppPackageInfo); + WINPR_API SECURITY_STATUS SEC_ENTRY QuerySecurityPackageInfoW(SEC_WCHAR* pszPackageName, + PSecPkgInfoW* ppPackageInfo); + + /* Credential Management */ + + WINPR_API SECURITY_STATUS SEC_ENTRY AcquireCredentialsHandleA( + SEC_CHAR* pszPrincipal, SEC_CHAR* pszPackage, ULONG fCredentialUse, void* pvLogonID, + void* pAuthData, SEC_GET_KEY_FN pGetKeyFn, void* pvGetKeyArgument, PCredHandle phCredential, + PTimeStamp ptsExpiry); + WINPR_API SECURITY_STATUS SEC_ENTRY AcquireCredentialsHandleW( + SEC_WCHAR* pszPrincipal, SEC_WCHAR* pszPackage, ULONG fCredentialUse, void* pvLogonID, + void* pAuthData, SEC_GET_KEY_FN pGetKeyFn, void* pvGetKeyArgument, PCredHandle phCredential, + PTimeStamp ptsExpiry); + + WINPR_API SECURITY_STATUS SEC_ENTRY ExportSecurityContext(PCtxtHandle phContext, ULONG fFlags, + PSecBuffer pPackedContext, + HANDLE* pToken); + WINPR_API SECURITY_STATUS SEC_ENTRY FreeCredentialsHandle(PCredHandle phCredential); + + WINPR_API SECURITY_STATUS SEC_ENTRY ImportSecurityContextA(SEC_CHAR* pszPackage, + PSecBuffer pPackedContext, + HANDLE pToken, + PCtxtHandle phContext); + WINPR_API SECURITY_STATUS SEC_ENTRY ImportSecurityContextW(SEC_WCHAR* pszPackage, + PSecBuffer pPackedContext, + HANDLE pToken, + PCtxtHandle phContext); + + WINPR_API SECURITY_STATUS SEC_ENTRY QueryCredentialsAttributesA(PCredHandle phCredential, + ULONG ulAttribute, + void* pBuffer); + WINPR_API SECURITY_STATUS SEC_ENTRY QueryCredentialsAttributesW(PCredHandle phCredential, + ULONG ulAttribute, + void* pBuffer); + + /* Context Management */ + + WINPR_API SECURITY_STATUS SEC_ENTRY + AcceptSecurityContext(PCredHandle phCredential, PCtxtHandle phContext, PSecBufferDesc pInput, + ULONG fContextReq, ULONG TargetDataRep, PCtxtHandle phNewContext, + PSecBufferDesc pOutput, PULONG pfContextAttr, PTimeStamp ptsTimeStamp); + + WINPR_API SECURITY_STATUS SEC_ENTRY ApplyControlToken(PCtxtHandle phContext, + PSecBufferDesc pInput); + WINPR_API SECURITY_STATUS SEC_ENTRY CompleteAuthToken(PCtxtHandle phContext, + PSecBufferDesc pToken); + WINPR_API SECURITY_STATUS SEC_ENTRY DeleteSecurityContext(PCtxtHandle phContext); + WINPR_API SECURITY_STATUS SEC_ENTRY FreeContextBuffer(void* pvContextBuffer); + WINPR_API SECURITY_STATUS SEC_ENTRY ImpersonateSecurityContext(PCtxtHandle phContext); + + WINPR_API SECURITY_STATUS SEC_ENTRY InitializeSecurityContextA( + PCredHandle phCredential, PCtxtHandle phContext, SEC_CHAR* pszTargetName, ULONG fContextReq, + ULONG Reserved1, ULONG TargetDataRep, PSecBufferDesc pInput, ULONG Reserved2, + PCtxtHandle phNewContext, PSecBufferDesc pOutput, PULONG pfContextAttr, + PTimeStamp ptsExpiry); + WINPR_API SECURITY_STATUS SEC_ENTRY InitializeSecurityContextW( + PCredHandle phCredential, PCtxtHandle phContext, SEC_WCHAR* pszTargetName, + ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep, PSecBufferDesc pInput, + ULONG Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput, PULONG pfContextAttr, + PTimeStamp ptsExpiry); + + WINPR_API SECURITY_STATUS SEC_ENTRY QueryContextAttributes(PCtxtHandle phContext, + ULONG ulAttribute, void* pBuffer); + WINPR_API SECURITY_STATUS SEC_ENTRY QuerySecurityContextToken(PCtxtHandle phContext, + HANDLE* phToken); + WINPR_API SECURITY_STATUS SEC_ENTRY SetContextAttributes(PCtxtHandle phContext, + ULONG ulAttribute, void* pBuffer, + ULONG cbBuffer); + WINPR_API SECURITY_STATUS SEC_ENTRY RevertSecurityContext(PCtxtHandle phContext); + + /* Message Support */ + + WINPR_API SECURITY_STATUS SEC_ENTRY DecryptMessage(PCtxtHandle phContext, + PSecBufferDesc pMessage, ULONG MessageSeqNo, + PULONG pfQOP); + WINPR_API SECURITY_STATUS SEC_ENTRY EncryptMessage(PCtxtHandle phContext, ULONG fQOP, + PSecBufferDesc pMessage, ULONG MessageSeqNo); + WINPR_API SECURITY_STATUS SEC_ENTRY MakeSignature(PCtxtHandle phContext, ULONG fQOP, + PSecBufferDesc pMessage, ULONG MessageSeqNo); + WINPR_API SECURITY_STATUS SEC_ENTRY VerifySignature(PCtxtHandle phContext, + PSecBufferDesc pMessage, ULONG MessageSeqNo, + PULONG pfQOP); + +#endif /* SSPI_DLL */ + +#ifdef __cplusplus +} +#endif + +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + + /* Custom API */ + +/* Extended SECPKG_ATTR IDs begin at 1000 */ +#define SECPKG_ATTR_AUTH_IDENTITY 1001 +#define SECPKG_ATTR_AUTH_PASSWORD 1002 +#define SECPKG_ATTR_AUTH_NTLM_HASH 1003 +#define SECPKG_ATTR_AUTH_NTLM_MESSAGE 1100 +#define SECPKG_ATTR_AUTH_NTLM_TIMESTAMP 1101 +#define SECPKG_ATTR_AUTH_NTLM_CLIENT_CHALLENGE 1102 +#define SECPKG_ATTR_AUTH_NTLM_SERVER_CHALLENGE 1103 +#define SECPKG_ATTR_AUTH_NTLM_NTPROOF_VALUE 1104 +#define SECPKG_ATTR_AUTH_NTLM_RANDKEY 1105 +#define SECPKG_ATTR_AUTH_NTLM_MIC 1106 +#define SECPKG_ATTR_AUTH_NTLM_MIC_VALUE 1107 + + typedef struct + { + char User[256 + 1]; + char Domain[256 + 1]; + } SecPkgContext_AuthIdentity; + + typedef struct + { + char Password[256 + 1]; + } SecPkgContext_AuthPassword; + + typedef struct + { + int Version; + BYTE NtlmHash[16]; + } SecPkgContext_AuthNtlmHash; + + typedef struct + { + BYTE Timestamp[8]; + BOOL ChallengeOrResponse; + } SecPkgContext_AuthNtlmTimestamp; + + typedef struct + { + BYTE ClientChallenge[8]; + } SecPkgContext_AuthNtlmClientChallenge; + + typedef struct + { + BYTE ServerChallenge[8]; + } SecPkgContext_AuthNtlmServerChallenge; + + typedef struct + { + UINT32 type; + UINT32 length; + BYTE* buffer; + } SecPkgContext_AuthNtlmMessage; + +#define SSPI_INTERFACE_WINPR 0x00000001 +#define SSPI_INTERFACE_NATIVE 0x00000002 + + typedef PSecurityFunctionTableA(SEC_ENTRY* INIT_SECURITY_INTERFACE_EX_A)(DWORD flags); + typedef PSecurityFunctionTableW(SEC_ENTRY* INIT_SECURITY_INTERFACE_EX_W)(DWORD flags); + + WINPR_API void sspi_GlobalInit(void); + WINPR_API void sspi_GlobalFinish(void); + + WINPR_API void* sspi_SecBufferAlloc(PSecBuffer SecBuffer, ULONG size); + WINPR_API void sspi_SecBufferFree(PSecBuffer SecBuffer); + +#define sspi_SetAuthIdentity sspi_SetAuthIdentityA + WINPR_API int sspi_SetAuthIdentityA(SEC_WINNT_AUTH_IDENTITY* identity, const char* user, + const char* domain, const char* password); + WINPR_API int sspi_SetAuthIdentityW(SEC_WINNT_AUTH_IDENTITY* identity, const WCHAR* user, + const WCHAR* domain, const WCHAR* password); + WINPR_API int sspi_SetAuthIdentityWithLengthW(SEC_WINNT_AUTH_IDENTITY* identity, + const WCHAR* user, size_t userLen, + const WCHAR* domain, size_t domainLen, + const WCHAR* password, size_t passwordLen); + WINPR_API UINT32 sspi_GetAuthIdentityVersion(const void* identity); + WINPR_API UINT32 sspi_GetAuthIdentityFlags(const void* identity); + WINPR_API BOOL sspi_GetAuthIdentityUserDomainW(const void* identity, const WCHAR** pUser, + UINT32* pUserLength, const WCHAR** pDomain, + UINT32* pDomainLength); + WINPR_API BOOL sspi_GetAuthIdentityUserDomainA(const void* identity, const char** pUser, + UINT32* pUserLength, const char** pDomain, + UINT32* pDomainLength); + WINPR_API BOOL sspi_GetAuthIdentityPasswordW(const void* identity, const WCHAR** pPassword, + UINT32* pPasswordLength); + WINPR_API BOOL sspi_GetAuthIdentityPasswordA(const void* identity, const char** pPassword, + UINT32* pPasswordLength); + WINPR_API BOOL sspi_CopyAuthIdentityFieldsA(const SEC_WINNT_AUTH_IDENTITY_INFO* identity, + char** pUser, char** pDomain, char** pPassword); + WINPR_API BOOL sspi_CopyAuthIdentityFieldsW(const SEC_WINNT_AUTH_IDENTITY_INFO* identity, + WCHAR** pUser, WCHAR** pDomain, WCHAR** pPassword); + WINPR_API BOOL sspi_CopyAuthPackageListA(const SEC_WINNT_AUTH_IDENTITY_INFO* identity, + char** pPackageList); + WINPR_API int sspi_CopyAuthIdentity(SEC_WINNT_AUTH_IDENTITY* identity, + const SEC_WINNT_AUTH_IDENTITY_INFO* srcIdentity); + + WINPR_API void sspi_FreeAuthIdentity(SEC_WINNT_AUTH_IDENTITY* identity); + + WINPR_API const char* GetSecurityStatusString(SECURITY_STATUS status); + + WINPR_API SecurityFunctionTableW* SEC_ENTRY InitSecurityInterfaceExW(DWORD flags); + WINPR_API SecurityFunctionTableA* SEC_ENTRY InitSecurityInterfaceExA(DWORD flags); + +#ifdef UNICODE +#define InitSecurityInterfaceEx InitSecurityInterfaceExW +#define INIT_SECURITY_INTERFACE_EX INIT_SECURITY_INTERFACE_EX_W +#else +#define InitSecurityInterfaceEx InitSecurityInterfaceExA +#define INIT_SECURITY_INTERFACE_EX INIT_SECURITY_INTERFACE_EX_A +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* WINPR_SSPI_H */ diff --git a/winpr/include/winpr/sspicli.h b/winpr/include/winpr/sspicli.h new file mode 100644 index 0000000..bea9e9a --- /dev/null +++ b/winpr/include/winpr/sspicli.h @@ -0,0 +1,147 @@ +/** + * WinPR: Windows Portable Runtime + * Security Support Provider Interface + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_SSPICLI_H +#define WINPR_SSPICLI_H + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <winpr/winpr.h> +#include <winpr/wtypes.h> + +#ifndef _WIN32 + +#define LOGON32_LOGON_INTERACTIVE 2 +#define LOGON32_LOGON_NETWORK 3 +#define LOGON32_LOGON_BATCH 4 +#define LOGON32_LOGON_SERVICE 5 +#define LOGON32_LOGON_UNLOCK 7 +#define LOGON32_LOGON_NETWORK_CLEARTEXT 8 +#define LOGON32_LOGON_NEW_CREDENTIALS 9 + +#define LOGON32_PROVIDER_DEFAULT 0 +#define LOGON32_PROVIDER_WINNT35 1 +#define LOGON32_PROVIDER_WINNT40 2 +#define LOGON32_PROVIDER_WINNT50 3 +#define LOGON32_PROVIDER_VIRTUAL 4 + +typedef struct +{ + SIZE_T PagedPoolLimit; + SIZE_T NonPagedPoolLimit; + SIZE_T MinimumWorkingSetSize; + SIZE_T MaximumWorkingSetSize; + SIZE_T PagefileLimit; + LARGE_INTEGER TimeLimit; +} QUOTA_LIMITS, *PQUOTA_LIMITS; + +typedef enum +{ + /* An unknown name type */ + NameUnknown = 0, + + /* The fully qualified distinguished name (for example, CN=Jeff + Smith,OU=Users,DC=Engineering,DC=Microsoft,DC=Com) */ + NameFullyQualifiedDN = 1, + + /* + * A legacy account name (for example, Engineering\JSmith). + * The domain-only version includes trailing backslashes (\\) + */ + NameSamCompatible = 2, + + /* + * A "friendly" display name (for example, Jeff Smith). + * The display name is not necessarily the defining relative distinguished name (RDN) + */ + NameDisplay = 3, + + /* A GUID string that the IIDFromString function returns (for example, + {4fa050f0-f561-11cf-bdd9-00aa003a77b6}) */ + NameUniqueId = 6, + + /* + * The complete canonical name (for example, engineering.microsoft.com/software/someone). + * The domain-only version includes a trailing forward slash (/) + */ + NameCanonical = 7, + + /* The user principal name (for example, someone@example.com) */ + NameUserPrincipal = 8, + + /* + * The same as NameCanonical except that the rightmost forward slash (/) + * is replaced with a new line character (\n), even in a domain-only case + * (for example, engineering.microsoft.com/software\nJSmith) + */ + NameCanonicalEx = 9, + + /* The generalized service principal name (for example, www/www.microsoft.com@microsoft.com) */ + NameServicePrincipal = 10, + + /* The DNS domain name followed by a backward-slash and the SAM user name */ + NameDnsDomain = 12 + +} EXTENDED_NAME_FORMAT, + *PEXTENDED_NAME_FORMAT; + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API BOOL LogonUserA(LPCSTR lpszUsername, LPCSTR lpszDomain, LPCSTR lpszPassword, + DWORD dwLogonType, DWORD dwLogonProvider, PHANDLE phToken); + + WINPR_API BOOL LogonUserW(LPCWSTR lpszUsername, LPCWSTR lpszDomain, LPCWSTR lpszPassword, + DWORD dwLogonType, DWORD dwLogonProvider, PHANDLE phToken); + + WINPR_API BOOL LogonUserExA(LPCSTR lpszUsername, LPCSTR lpszDomain, LPCSTR lpszPassword, + DWORD dwLogonType, DWORD dwLogonProvider, PHANDLE phToken, + PSID* ppLogonSid, PVOID* ppProfileBuffer, LPDWORD pdwProfileLength, + PQUOTA_LIMITS pQuotaLimits); + + WINPR_API BOOL LogonUserExW(LPCWSTR lpszUsername, LPCWSTR lpszDomain, LPCWSTR lpszPassword, + DWORD dwLogonType, DWORD dwLogonProvider, PHANDLE phToken, + PSID* ppLogonSid, PVOID* ppProfileBuffer, LPDWORD pdwProfileLength, + PQUOTA_LIMITS pQuotaLimits); + + WINPR_API BOOL GetUserNameExA(EXTENDED_NAME_FORMAT NameFormat, LPSTR lpNameBuffer, + PULONG nSize); + WINPR_API BOOL GetUserNameExW(EXTENDED_NAME_FORMAT NameFormat, LPWSTR lpNameBuffer, + PULONG nSize); + +#ifdef __cplusplus +} +#endif + +#ifdef UNICODE +#define LogonUser LogonUserW +#define LogonUserEx LogonUserExW +#define GetUserNameEx GetUserNameExW +#else +#define LogonUser LogonUserA +#define LogonUserEx LogonUserExA +#define GetUserNameEx GetUserNameExA +#endif + +#endif + +#endif /* WINPR_SSPICLI_H */ diff --git a/winpr/include/winpr/stream.h b/winpr/include/winpr/stream.h new file mode 100644 index 0000000..6dd5a0e --- /dev/null +++ b/winpr/include/winpr/stream.h @@ -0,0 +1,842 @@ +/* + * WinPR: Windows Portable Runtime + * Stream Utils + * + * Copyright 2011 Vic Lee + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * Copyright 2017 Armin Novak <armin.novak@thincast.com> + * Copyright 2017 Thincast Technologies GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_UTILS_STREAM_H +#define WINPR_UTILS_STREAM_H + +#include <winpr/winpr.h> +#include <winpr/wtypes.h> +#include <winpr/endian.h> +#include <winpr/synch.h> +#include <winpr/assert.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct s_wStreamPool wStreamPool; + + typedef struct + { + BYTE* buffer; + BYTE* pointer; + size_t length; + size_t capacity; + + DWORD count; + wStreamPool* pool; + BOOL isAllocatedStream; + BOOL isOwner; + } wStream; + + static INLINE size_t Stream_Capacity(const wStream* _s); + WINPR_API size_t Stream_GetRemainingCapacity(const wStream* _s); + WINPR_API size_t Stream_GetRemainingLength(const wStream* _s); + + WINPR_API BOOL Stream_EnsureCapacity(wStream* s, size_t size); + WINPR_API BOOL Stream_EnsureRemainingCapacity(wStream* s, size_t size); + +#ifdef __cplusplus +#define WINPR_STREAM_CAST(t, val) static_cast<t>(val) +#else +#define WINPR_STREAM_CAST(t, val) (t)(val) +#endif + +#define Stream_CheckAndLogRequiredCapacityOfSize(tag, s, nmemb, size) \ + Stream_CheckAndLogRequiredCapacityEx(tag, WLOG_WARN, s, nmemb, size, "%s(%s:%" PRIuz ")", \ + __func__, __FILE__, (size_t)__LINE__) +#define Stream_CheckAndLogRequiredCapacity(tag, s, len) \ + Stream_CheckAndLogRequiredCapacityOfSize((tag), (s), (len), 1) + + WINPR_API BOOL Stream_CheckAndLogRequiredCapacityEx(const char* tag, DWORD level, wStream* s, + size_t nmemb, size_t size, const char* fmt, + ...); + WINPR_API BOOL Stream_CheckAndLogRequiredCapacityExVa(const char* tag, DWORD level, wStream* s, + size_t nmemb, size_t size, + const char* fmt, va_list args); + +#define Stream_CheckAndLogRequiredCapacityOfSizeWLog(log, s, nmemb, size) \ + Stream_CheckAndLogRequiredCapacityWLogEx(log, WLOG_WARN, s, nmemb, size, "%s(%s:%" PRIuz ")", \ + __func__, __FILE__, (size_t)__LINE__) + +#define Stream_CheckAndLogRequiredCapacityWLog(log, s, len) \ + Stream_CheckAndLogRequiredCapacityOfSizeWLog((log), (s), (len), 1) + + WINPR_API BOOL Stream_CheckAndLogRequiredCapacityWLogEx(wLog* log, DWORD level, wStream* s, + size_t nmemb, size_t size, + const char* fmt, ...); + WINPR_API BOOL Stream_CheckAndLogRequiredCapacityWLogExVa(wLog* log, DWORD level, wStream* s, + size_t nmemb, size_t size, + const char* fmt, va_list args); + + WINPR_API void Stream_Free(wStream* s, BOOL bFreeBuffer); + + WINPR_ATTR_MALLOC(Stream_Free, 1) + WINPR_API wStream* Stream_New(BYTE* buffer, size_t size); + WINPR_API wStream* Stream_StaticConstInit(wStream* s, const BYTE* buffer, size_t size); + WINPR_API wStream* Stream_StaticInit(wStream* s, BYTE* buffer, size_t size); + +#define Stream_CheckAndLogRequiredLengthOfSize(tag, s, nmemb, size) \ + Stream_CheckAndLogRequiredLengthEx(tag, WLOG_WARN, s, nmemb, size, "%s(%s:%" PRIuz ")", \ + __func__, __FILE__, (size_t)__LINE__) +#define Stream_CheckAndLogRequiredLength(tag, s, len) \ + Stream_CheckAndLogRequiredLengthOfSize(tag, s, len, 1) + + WINPR_API BOOL Stream_CheckAndLogRequiredLengthEx(const char* tag, DWORD level, wStream* s, + size_t nmemb, size_t size, const char* fmt, + ...); + WINPR_API BOOL Stream_CheckAndLogRequiredLengthExVa(const char* tag, DWORD level, wStream* s, + size_t nmemb, size_t size, const char* fmt, + va_list args); + +#define Stream_CheckAndLogRequiredLengthOfSizeWLog(log, s, nmemb, size) \ + Stream_CheckAndLogRequiredLengthWLogEx(log, WLOG_WARN, s, nmemb, size, "%s(%s:%" PRIuz ")", \ + __func__, __FILE__, (size_t)__LINE__) +#define Stream_CheckAndLogRequiredLengthWLog(log, s, len) \ + Stream_CheckAndLogRequiredLengthOfSizeWLog(log, s, len, 1) + + WINPR_API BOOL Stream_CheckAndLogRequiredLengthWLogEx(wLog* log, DWORD level, wStream* s, + size_t nmemb, size_t size, + const char* fmt, ...); + WINPR_API BOOL Stream_CheckAndLogRequiredLengthWLogExVa(wLog* log, DWORD level, wStream* s, + size_t nmemb, size_t size, + const char* fmt, va_list args); + + static INLINE void Stream_Seek(wStream* s, size_t _offset) + { + WINPR_ASSERT(s); + WINPR_ASSERT(Stream_GetRemainingCapacity(s) >= _offset); + s->pointer += (_offset); + } + + static INLINE void Stream_Rewind(wStream* s, size_t _offset) + { + size_t cur; + WINPR_ASSERT(s); + WINPR_ASSERT(s->buffer <= s->pointer); + cur = WINPR_STREAM_CAST(size_t, s->pointer - s->buffer); + WINPR_ASSERT(cur >= _offset); + if (cur >= _offset) + s->pointer -= (_offset); + else + s->pointer = s->buffer; + } + + static INLINE UINT8 stream_read_u8(wStream* _s, BOOL seek) + { + WINPR_ASSERT(_s); + WINPR_ASSERT(Stream_GetRemainingLength(_s) >= sizeof(UINT8)); + + const UINT8 v = WINPR_STREAM_CAST(UINT8, *(_s)->pointer); + if (seek) + Stream_Seek(_s, sizeof(UINT8)); + return v; + } + + static INLINE INT8 stream_read_i8(wStream* _s, BOOL seek) + { + WINPR_ASSERT(_s); + WINPR_ASSERT(Stream_GetRemainingLength(_s) >= sizeof(INT8)); + + const INT8 v = WINPR_STREAM_CAST(INT8, *(_s)->pointer); + if (seek) + Stream_Seek(_s, sizeof(INT8)); + return v; + } + + static INLINE UINT16 stream_read_u16_le(wStream* _s, BOOL seek) + { + WINPR_ASSERT(_s); + WINPR_ASSERT(Stream_GetRemainingLength(_s) >= sizeof(UINT16)); + + const UINT16 v = WINPR_STREAM_CAST( + UINT16, (*(_s)->pointer) + ((WINPR_STREAM_CAST(UINT16, *((_s)->pointer + 1))) << 8)); + if (seek) + Stream_Seek(_s, sizeof(UINT16)); + return v; + } + + static INLINE UINT16 stream_read_u16_be(wStream* _s, BOOL seek) + { + WINPR_ASSERT(_s); + WINPR_ASSERT(Stream_GetRemainingLength(_s) >= sizeof(UINT16)); + + const UINT16 v = ((WINPR_STREAM_CAST(UINT16, *(_s)->pointer) << 8) + + (WINPR_STREAM_CAST(UINT16, *((_s)->pointer + 1)))); + if (seek) + Stream_Seek(_s, sizeof(UINT16)); + return v; + } + + static INLINE UINT16 stream_read_i16_le(wStream* _s, BOOL seek) + { + WINPR_ASSERT(_s); + WINPR_ASSERT(Stream_GetRemainingLength(_s) >= sizeof(INT16)); + + const INT16 v = WINPR_STREAM_CAST( + INT16, (*(_s)->pointer) + ((WINPR_STREAM_CAST(INT16, *((_s)->pointer + 1))) << 8)); + if (seek) + Stream_Seek(_s, sizeof(INT16)); + return v; + } + + static INLINE UINT16 stream_read_i16_be(wStream* _s, BOOL seek) + { + WINPR_ASSERT(_s); + WINPR_ASSERT(Stream_GetRemainingLength(_s) >= sizeof(INT16)); + + const INT16 v = ((WINPR_STREAM_CAST(INT16, *(_s)->pointer) << 8) + + (WINPR_STREAM_CAST(INT16, *((_s)->pointer + 1)))); + if (seek) + Stream_Seek(_s, sizeof(INT16)); + return v; + } + + static INLINE UINT32 stream_read_u32_le(wStream* _s, BOOL seek) + { + WINPR_ASSERT(_s); + WINPR_ASSERT(Stream_GetRemainingLength(_s) >= sizeof(UINT32)); + + const UINT32 v = (WINPR_STREAM_CAST(UINT32, *(_s)->pointer) << 0) + + ((WINPR_STREAM_CAST(UINT32, *((_s)->pointer + 1))) << 8) + + ((WINPR_STREAM_CAST(UINT32, *((_s)->pointer + 2))) << 16) + + (((WINPR_STREAM_CAST(UINT32, *((_s)->pointer + 3))) << 24)); + if (seek) + Stream_Seek(_s, sizeof(UINT32)); + return v; + } + + static INLINE UINT32 stream_read_u32_be(wStream* _s, BOOL seek) + { + WINPR_ASSERT(_s); + WINPR_ASSERT(Stream_GetRemainingLength(_s) >= sizeof(UINT32)); + + const UINT32 v = (WINPR_STREAM_CAST(UINT32, *(_s)->pointer) << 24) + + ((WINPR_STREAM_CAST(UINT32, *((_s)->pointer + 1))) << 16) + + ((WINPR_STREAM_CAST(UINT32, *((_s)->pointer + 2))) << 8) + + (((WINPR_STREAM_CAST(UINT32, *((_s)->pointer + 3))) << 0)); + if (seek) + Stream_Seek(_s, sizeof(UINT32)); + return v; + } + + static INLINE INT32 stream_read_i32_le(wStream* _s, BOOL seek) + { + WINPR_ASSERT(_s); + WINPR_ASSERT(Stream_GetRemainingLength(_s) >= sizeof(UINT32)); + + const INT32 v = + WINPR_STREAM_CAST(INT32, (WINPR_STREAM_CAST(UINT32, *(_s)->pointer) << 0) + + ((WINPR_STREAM_CAST(UINT32, *((_s)->pointer + 1))) << 8) + + ((WINPR_STREAM_CAST(UINT32, *((_s)->pointer + 2))) << 16) + + ((WINPR_STREAM_CAST(UINT32, *((_s)->pointer + 3))) << 24)); + if (seek) + Stream_Seek(_s, sizeof(UINT32)); + return v; + } + + static INLINE INT32 stream_read_i32_be(wStream* _s, BOOL seek) + { + WINPR_ASSERT(_s); + WINPR_ASSERT(Stream_GetRemainingLength(_s) >= sizeof(UINT32)); + + const INT32 v = WINPR_STREAM_CAST( + INT32, (WINPR_STREAM_CAST(UINT32, *(_s)->pointer) << 24) + + ((WINPR_STREAM_CAST(UINT32, *((_s)->pointer + 1))) << 16) + + ((WINPR_STREAM_CAST(UINT32, *((_s)->pointer + 2))) << 8) + + (((WINPR_STREAM_CAST(UINT32, *((_s)->pointer + 3))) << 0))); + if (seek) + Stream_Seek(_s, sizeof(UINT32)); + return v; + } + + static INLINE UINT64 stream_read_u64_le(wStream* _s, BOOL seek) + { + WINPR_ASSERT(_s); + WINPR_ASSERT(Stream_GetRemainingLength(_s) >= sizeof(UINT64)); + + const UINT64 v = (WINPR_STREAM_CAST(UINT64, *(_s)->pointer) << 0) + + ((WINPR_STREAM_CAST(UINT64, *((_s)->pointer + 1))) << 8) + + ((WINPR_STREAM_CAST(UINT64, *((_s)->pointer + 2))) << 16) + + ((WINPR_STREAM_CAST(UINT64, *((_s)->pointer + 3))) << 24) + + ((WINPR_STREAM_CAST(UINT64, *((_s)->pointer + 4))) << 32) + + ((WINPR_STREAM_CAST(UINT64, *((_s)->pointer + 5))) << 40) + + ((WINPR_STREAM_CAST(UINT64, *((_s)->pointer + 6))) << 48) + + ((WINPR_STREAM_CAST(UINT64, *((_s)->pointer + 7))) << 56); + + if (seek) + Stream_Seek(_s, sizeof(UINT64)); + return v; + } + + static INLINE UINT64 stream_read_u64_be(wStream* _s, BOOL seek) + { + WINPR_ASSERT(_s); + WINPR_ASSERT(Stream_GetRemainingLength(_s) >= sizeof(UINT64)); + + const UINT64 v = (WINPR_STREAM_CAST(UINT64, *(_s)->pointer) << 56) + + ((WINPR_STREAM_CAST(UINT64, *((_s)->pointer + 1))) << 48) + + ((WINPR_STREAM_CAST(UINT64, *((_s)->pointer + 2))) << 40) + + ((WINPR_STREAM_CAST(UINT64, *((_s)->pointer + 3))) << 32) + + ((WINPR_STREAM_CAST(UINT64, *((_s)->pointer + 4))) << 24) + + ((WINPR_STREAM_CAST(UINT64, *((_s)->pointer + 5))) << 16) + + ((WINPR_STREAM_CAST(UINT64, *((_s)->pointer + 6))) << 8) + + ((WINPR_STREAM_CAST(UINT64, *((_s)->pointer + 7))) << 0); + + if (seek) + Stream_Seek(_s, sizeof(UINT64)); + return v; + } + + static INLINE INT64 stream_read_i64_le(wStream* _s, BOOL seek) + { + WINPR_ASSERT(_s); + WINPR_ASSERT(Stream_GetRemainingLength(_s) >= sizeof(INT64)); + + const INT64 v = + WINPR_STREAM_CAST(INT64, ((WINPR_STREAM_CAST(UINT64, *(_s)->pointer) << 0) + + ((WINPR_STREAM_CAST(UINT64, *((_s)->pointer + 1))) << 8) + + ((WINPR_STREAM_CAST(UINT64, *((_s)->pointer + 2))) << 16) + + ((WINPR_STREAM_CAST(UINT64, *((_s)->pointer + 3))) << 24) + + ((WINPR_STREAM_CAST(UINT64, *((_s)->pointer + 4))) << 32) + + ((WINPR_STREAM_CAST(UINT64, *((_s)->pointer + 5))) << 40) + + ((WINPR_STREAM_CAST(UINT64, *((_s)->pointer + 6))) << 48) + + ((WINPR_STREAM_CAST(UINT64, *((_s)->pointer + 7))) << 56))); + + if (seek) + Stream_Seek(_s, sizeof(UINT64)); + return v; + } + + static INLINE INT64 stream_read_i64_be(wStream* _s, BOOL seek) + { + WINPR_ASSERT(_s); + WINPR_ASSERT(Stream_GetRemainingLength(_s) >= sizeof(INT64)); + + const INT64 v = + WINPR_STREAM_CAST(INT64, ((WINPR_STREAM_CAST(UINT64, *(_s)->pointer) << 56) + + ((WINPR_STREAM_CAST(UINT64, *((_s)->pointer + 1))) << 48) + + ((WINPR_STREAM_CAST(UINT64, *((_s)->pointer + 2))) << 40) + + ((WINPR_STREAM_CAST(UINT64, *((_s)->pointer + 3))) << 32) + + ((WINPR_STREAM_CAST(UINT64, *((_s)->pointer + 4))) << 24) + + ((WINPR_STREAM_CAST(UINT64, *((_s)->pointer + 5))) << 16) + + ((WINPR_STREAM_CAST(UINT64, *((_s)->pointer + 6))) << 8) + + ((WINPR_STREAM_CAST(UINT64, *((_s)->pointer + 7))) << 0))); + + if (seek) + Stream_Seek(_s, sizeof(UINT64)); + return v; + } + +#define Stream_Read_UINT8(_s, _v) \ + do \ + { \ + _v = stream_read_u8(_s, TRUE); \ + } while (0) + +#define Stream_Read_INT8(_s, _v) \ + do \ + { \ + _v = stream_read_i8(_s, TRUE); \ + } while (0) + +#define Stream_Read_UINT16(_s, _v) \ + do \ + { \ + _v = stream_read_u16_le(_s, TRUE); \ + } while (0) + +#define Stream_Read_INT16(_s, _v) \ + do \ + { \ + _v = stream_read_i16_le(_s, TRUE); \ + } while (0) + +#define Stream_Read_UINT16_BE(_s, _v) \ + do \ + { \ + _v = stream_read_u16_be(_s, TRUE); \ + } while (0) + +#define Stream_Read_INT16_BE(_s, _v) \ + do \ + { \ + _v = stream_read_i16_be(_s, TRUE); \ + } while (0) + +#define Stream_Read_UINT32(_s, _v) \ + do \ + { \ + _v = stream_read_u32_le(_s, TRUE); \ + } while (0) + +#define Stream_Read_INT32(_s, _v) \ + do \ + { \ + _v = stream_read_i32_le(_s, TRUE); \ + } while (0) + +#define Stream_Read_UINT32_BE(_s, _v) \ + do \ + { \ + _v = stream_read_u32_be(_s, TRUE); \ + } while (0) + +#define Stream_Read_INT32_BE(_s, _v) \ + do \ + { \ + _v = stream_read_i32_be(_s, TRUE); \ + } while (0) + +#define Stream_Read_UINT64(_s, _v) \ + do \ + { \ + _v = stream_read_u64_le(_s, TRUE); \ + } while (0) + +#define Stream_Read_INT64(_s, _v) \ + do \ + { \ + _v = stream_read_i64_le(_s, TRUE); \ + } while (0) + +#define Stream_Read_UINT64_BE(_s, _v) \ + do \ + { \ + _v = stream_read_u64_be(_s, TRUE); \ + } while (0) + +#define Stream_Read_INT64_BE(_s, _v) \ + do \ + { \ + _v = stream_read_i64_be(_s, TRUE); \ + } while (0) + + static INLINE void Stream_Read(wStream* _s, void* _b, size_t _n) + { + WINPR_ASSERT(_s); + WINPR_ASSERT(_b || (_n == 0)); + WINPR_ASSERT(Stream_GetRemainingCapacity(_s) >= _n); + memcpy(_b, (_s->pointer), (_n)); + Stream_Seek(_s, _n); + } + +#define Stream_Peek_UINT8(_s, _v) \ + do \ + { \ + _v = stream_read_u8(_s, FALSE); \ + } while (0) + +#define Stream_Peek_INT8(_s, _v) \ + do \ + { \ + _v = stream_read_i8(_s, FALSE); \ + } while (0) + +#define Stream_Peek_UINT16(_s, _v) \ + do \ + { \ + _v = stream_read_u16_le(_s, FALSE); \ + } while (0) + +#define Stream_Peek_INT16(_s, _v) \ + do \ + { \ + _v = stream_read_i16_le(_s, FALSE); \ + } while (0) + +#define Stream_Peek_UINT16_BE(_s, _v) \ + do \ + { \ + _v = stream_read_u16_be(_s, FALSE); \ + } while (0) + +#define Stream_Peek_INT16_BE(_s, _v) \ + do \ + { \ + _v = stream_read_i16_be(_s, FALSE); \ + } while (0) + +#define Stream_Peek_UINT32(_s, _v) \ + do \ + { \ + _v = stream_read_u32_le(_s, FALSE); \ + } while (0) + +#define Stream_Peek_INT32(_s, _v) \ + do \ + { \ + _v = stream_read_i32_le(_s, FALSE); \ + } while (0) + +#define Stream_Peek_UINT32_BE(_s, _v) \ + do \ + { \ + _v = stream_read_u32_be(_s, FALSE); \ + } while (0) + +#define Stream_Peek_INT32_BE(_s, _v) \ + do \ + { \ + _v = stream_read_i32_be(_s, FALSE); \ + } while (0) + +#define Stream_Peek_UINT64(_s, _v) \ + do \ + { \ + _v = stream_read_u64_le(_s, FALSE); \ + } while (0) + +#define Stream_Peek_INT64(_s, _v) \ + do \ + { \ + _v = stream_read_i64_le(_s, FALSE); \ + } while (0) + +#define Stream_Peek_UINT64_BE(_s, _v) \ + do \ + { \ + _v = stream_read_u64_be(_s, FALSE); \ + } while (0) + +#define Stream_Peek_INT64_BE(_s, _v) \ + do \ + { \ + _v = stream_read_i64_be(_s, FALSE); \ + } while (0) + + static INLINE void Stream_Peek(const wStream* _s, void* _b, size_t _n) + { + WINPR_ASSERT(_s); + WINPR_ASSERT(_b || (_n == 0)); + WINPR_ASSERT(Stream_GetRemainingCapacity(_s) >= _n); + memcpy(_b, (_s->pointer), (_n)); + } + + static INLINE void Stream_Write_UINT8(wStream* _s, UINT8 _v) + { + WINPR_ASSERT(_s); + WINPR_ASSERT(_s->pointer); + WINPR_ASSERT(Stream_GetRemainingCapacity(_s) >= 1); + *_s->pointer++ = (_v); + } + + static INLINE void Stream_Write_INT16(wStream* _s, INT16 _v) + { + WINPR_ASSERT(_s); + WINPR_ASSERT(_s->pointer); + WINPR_ASSERT(Stream_GetRemainingCapacity(_s) >= 2); + *_s->pointer++ = (_v)&0xFF; + *_s->pointer++ = ((_v) >> 8) & 0xFF; + } + + static INLINE void Stream_Write_UINT16(wStream* _s, UINT16 _v) + { + WINPR_ASSERT(_s); + WINPR_ASSERT(_s->pointer); + WINPR_ASSERT(Stream_GetRemainingCapacity(_s) >= 2); + *_s->pointer++ = (_v)&0xFF; + *_s->pointer++ = ((_v) >> 8) & 0xFF; + } + + static INLINE void Stream_Write_UINT16_BE(wStream* _s, UINT16 _v) + { + WINPR_ASSERT(_s); + WINPR_ASSERT(_s->pointer); + WINPR_ASSERT(Stream_GetRemainingCapacity(_s) >= 2); + *_s->pointer++ = ((_v) >> 8) & 0xFF; + *_s->pointer++ = (_v)&0xFF; + } + + static INLINE void Stream_Write_UINT24_BE(wStream* _s, UINT32 _v) + { + WINPR_ASSERT(_s); + WINPR_ASSERT(_s->pointer); + WINPR_ASSERT(_v <= 0x00FFFFFF); + WINPR_ASSERT(Stream_GetRemainingCapacity(_s) >= 3); + *_s->pointer++ = ((_v) >> 16) & 0xFF; + *_s->pointer++ = ((_v) >> 8) & 0xFF; + *_s->pointer++ = (_v)&0xFF; + } + + static INLINE void Stream_Write_INT32(wStream* _s, INT32 _v) + { + WINPR_ASSERT(_s); + WINPR_ASSERT(_s->pointer); + WINPR_ASSERT(Stream_GetRemainingCapacity(_s) >= 4); + *_s->pointer++ = (_v)&0xFF; + *_s->pointer++ = ((_v) >> 8) & 0xFF; + *_s->pointer++ = ((_v) >> 16) & 0xFF; + *_s->pointer++ = ((_v) >> 24) & 0xFF; + } + + static INLINE void Stream_Write_UINT32(wStream* _s, UINT32 _v) + { + WINPR_ASSERT(_s); + WINPR_ASSERT(_s->pointer); + WINPR_ASSERT(Stream_GetRemainingCapacity(_s) >= 4); + *_s->pointer++ = (_v)&0xFF; + *_s->pointer++ = ((_v) >> 8) & 0xFF; + *_s->pointer++ = ((_v) >> 16) & 0xFF; + *_s->pointer++ = ((_v) >> 24) & 0xFF; + } + + static INLINE void Stream_Write_UINT32_BE(wStream* _s, UINT32 _v) + { + WINPR_ASSERT(Stream_GetRemainingCapacity(_s) >= 4); + Stream_Write_UINT16_BE(_s, ((_v) >> 16 & 0xFFFF)); + Stream_Write_UINT16_BE(_s, ((_v)&0xFFFF)); + } + + static INLINE void Stream_Write_UINT64(wStream* _s, UINT64 _v) + { + WINPR_ASSERT(_s); + WINPR_ASSERT(_s->pointer); + WINPR_ASSERT(Stream_GetRemainingCapacity(_s) >= 8); + *_s->pointer++ = (_v)&0xFF; + *_s->pointer++ = (_v >> 8) & 0xFF; + *_s->pointer++ = (_v >> 16) & 0xFF; + *_s->pointer++ = (_v >> 24) & 0xFF; + *_s->pointer++ = (_v >> 32) & 0xFF; + *_s->pointer++ = (_v >> 40) & 0xFF; + *_s->pointer++ = (_v >> 48) & 0xFF; + *_s->pointer++ = (_v >> 56) & 0xFF; + } + static INLINE void Stream_Write(wStream* _s, const void* _b, size_t _n) + { + if (_n > 0) + { + WINPR_ASSERT(_s); + WINPR_ASSERT(_b); + WINPR_ASSERT(Stream_GetRemainingCapacity(_s) >= _n); + memcpy(_s->pointer, (_b), (_n)); + Stream_Seek(_s, _n); + } + } + + static INLINE void Stream_Seek_UINT8(wStream* _s) + { + Stream_Seek(_s, sizeof(UINT8)); + } + static INLINE void Stream_Seek_UINT16(wStream* _s) + { + Stream_Seek(_s, sizeof(UINT16)); + } + static INLINE void Stream_Seek_UINT32(wStream* _s) + { + Stream_Seek(_s, sizeof(UINT32)); + } + static INLINE void Stream_Seek_UINT64(wStream* _s) + { + Stream_Seek(_s, sizeof(UINT64)); + } + + static INLINE void Stream_Rewind_UINT8(wStream* _s) + { + Stream_Rewind(_s, sizeof(UINT8)); + } + static INLINE void Stream_Rewind_UINT16(wStream* _s) + { + Stream_Rewind(_s, sizeof(UINT16)); + } + static INLINE void Stream_Rewind_UINT32(wStream* _s) + { + Stream_Rewind(_s, sizeof(UINT32)); + } + static INLINE void Stream_Rewind_UINT64(wStream* _s) + { + Stream_Rewind(_s, sizeof(UINT64)); + } + + static INLINE void Stream_Zero(wStream* _s, size_t _n) + { + WINPR_ASSERT(_s); + WINPR_ASSERT(Stream_GetRemainingCapacity(_s) >= (_n)); + memset(_s->pointer, '\0', (_n)); + Stream_Seek(_s, _n); + } + + static INLINE void Stream_Fill(wStream* _s, int _v, size_t _n) + { + WINPR_ASSERT(_s); + WINPR_ASSERT(Stream_GetRemainingCapacity(_s) >= (_n)); + memset(_s->pointer, _v, (_n)); + Stream_Seek(_s, _n); + } + + static INLINE void Stream_Copy(wStream* _src, wStream* _dst, size_t _n) + { + WINPR_ASSERT(_src); + WINPR_ASSERT(_dst); + WINPR_ASSERT(Stream_GetRemainingCapacity(_src) >= (_n)); + WINPR_ASSERT(Stream_GetRemainingCapacity(_dst) >= (_n)); + + memcpy(_dst->pointer, _src->pointer, _n); + Stream_Seek(_dst, _n); + Stream_Seek(_src, _n); + } + + static INLINE BYTE* Stream_Buffer(wStream* _s) + { + WINPR_ASSERT(_s); + return _s->buffer; + } + + static INLINE const BYTE* Stream_ConstBuffer(const wStream* _s) + { + WINPR_ASSERT(_s); + return _s->buffer; + } + +#define Stream_GetBuffer(_s, _b) _b = Stream_Buffer(_s) +#define Stream_PointerAs(s, type) (type*)Stream_Pointer(s) + + static INLINE void* Stream_Pointer(wStream* _s) + { + WINPR_ASSERT(_s); + return _s->pointer; + } + + static INLINE const void* Stream_ConstPointer(const wStream* _s) + { + WINPR_ASSERT(_s); + return _s->pointer; + } + +#define Stream_GetPointer(_s, _p) _p = Stream_Pointer(_s) + +#if defined(WITH_WINPR_DEPRECATED) + WINPR_API WINPR_DEPRECATED_VAR("Use Stream_SetPosition instead", + BOOL Stream_SetPointer(wStream* _s, BYTE* _p)); + WINPR_API WINPR_DEPRECATED_VAR("Use Stream_New(buffer, capacity) instead", + BOOL Stream_SetBuffer(wStream* _s, BYTE* _b)); + WINPR_API WINPR_DEPRECATED_VAR("Use Stream_New(buffer, capacity) instead", + void Stream_SetCapacity(wStream* _s, size_t capacity)); +#endif + + static INLINE size_t Stream_Length(const wStream* _s) + { + WINPR_ASSERT(_s); + return _s->length; + } + +#define Stream_GetLength(_s, _l) _l = Stream_Length(_s) + WINPR_API BOOL Stream_SetLength(wStream* _s, size_t _l); + + static INLINE size_t Stream_Capacity(const wStream* _s) + { + WINPR_ASSERT(_s); + return _s->capacity; + } + +#define Stream_GetCapacity(_s, _c) _c = Stream_Capacity(_s); + + static INLINE size_t Stream_GetPosition(const wStream* _s) + { + WINPR_ASSERT(_s); + WINPR_ASSERT(_s->buffer <= _s->pointer); + return WINPR_STREAM_CAST(size_t, (_s->pointer - _s->buffer)); + } + + WINPR_API BOOL Stream_SetPosition(wStream* _s, size_t _p); + + WINPR_API void Stream_SealLength(wStream* _s); + + static INLINE void Stream_Clear(wStream* _s) + { + WINPR_ASSERT(_s); + memset(_s->buffer, 0, _s->capacity); + } + +#define Stream_SafeSeek(s, size) Stream_SafeSeekEx(s, size, __FILE__, __LINE__, __func__) + WINPR_API BOOL Stream_SafeSeekEx(wStream* s, size_t size, const char* file, size_t line, + const char* fkt); + + WINPR_API BOOL Stream_Read_UTF16_String(wStream* s, WCHAR* dst, size_t charLength); + WINPR_API BOOL Stream_Write_UTF16_String(wStream* s, const WCHAR* src, size_t charLength); + + /** \brief Reads a WCHAR string from a stream and converts it to UTF-8 and returns a newly + * allocated string + * + * \param s The stream to read data from + * \param wcharLength The number of WCHAR characters to read (NOT the size in bytes!) + * \param pUtfCharLength Ignored if \b NULL, otherwise will be set to the number of + * characters in the resulting UTF-8 string + * \return A '\0' terminated UTF-8 encoded string or NULL for any failure. + */ + WINPR_API char* Stream_Read_UTF16_String_As_UTF8(wStream* s, size_t wcharLength, + size_t* pUtfCharLength); + + /** \brief Reads a WCHAR string from a stream and converts it to UTF-8 and + * writes it to the supplied buffer + * + * \param s The stream to read data from + * \param wcharLength The number of WCHAR characters to read (NOT the size in bytes!) + * \param utfBuffer A pointer to a buffer holding the result string + * \param utfBufferCharLength The size of the result buffer + * \return The char length (strlen) of the result string or -1 for failure + */ + WINPR_API SSIZE_T Stream_Read_UTF16_String_As_UTF8_Buffer(wStream* s, size_t wcharLength, + char* utfBuffer, + size_t utfBufferCharLength); + + /** \brief Writes a UTF-8 string UTF16 encoded to the stream. If the UTF-8 + * string is short, the remainig characters are filled up with '\0' + * + * \param s The stream to write to + * \param wcharLength the length (in WCHAR characters) to write + * \param src The source data buffer with the UTF-8 data + * \param length The length in bytes of the UTF-8 buffer + * \param fill If \b TRUE fill the unused parts of the wcharLength with 0 + * + * \b return number of used characters for success, /b -1 for failure + */ + WINPR_API SSIZE_T Stream_Write_UTF16_String_From_UTF8(wStream* s, size_t wcharLength, + const char* src, size_t length, + BOOL fill); + + /* StreamPool */ + + WINPR_API void StreamPool_Return(wStreamPool* pool, wStream* s); + + WINPR_API wStream* StreamPool_Take(wStreamPool* pool, size_t size); + + WINPR_API void Stream_AddRef(wStream* s); + WINPR_API void Stream_Release(wStream* s); + + WINPR_API wStream* StreamPool_Find(wStreamPool* pool, BYTE* ptr); + + WINPR_API void StreamPool_Clear(wStreamPool* pool); + + WINPR_API void StreamPool_Free(wStreamPool* pool); + + WINPR_ATTR_MALLOC(StreamPool_Free, 1) + WINPR_API wStreamPool* StreamPool_New(BOOL synchronized, size_t defaultSize); + + WINPR_API char* StreamPool_GetStatistics(wStreamPool* pool, char* buffer, size_t size); + +#ifdef __cplusplus +} +#endif + +#endif /* WINPR_UTILS_STREAM_H */ diff --git a/winpr/include/winpr/string.h b/winpr/include/winpr/string.h new file mode 100644 index 0000000..09b253c --- /dev/null +++ b/winpr/include/winpr/string.h @@ -0,0 +1,434 @@ +/** + * WinPR: Windows Portable Runtime + * String Manipulation (CRT) + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * Copyright 2016 David PHAM-VAN <d.phamvan@inuvika.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_CRT_STRING_H +#define WINPR_CRT_STRING_H + +#include <wchar.h> +#include <stdio.h> +#include <string.h> +#include <winpr/config.h> +#include <winpr/winpr.h> +#include <winpr/wtypes.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API char* winpr_str_url_encode(const char* str, size_t len); + WINPR_API char* winpr_str_url_decode(const char* str, size_t len); + + WINPR_API BOOL winpr_str_append(const char* what, char* buffer, size_t size, + const char* separator); + + WINPR_API int winpr_asprintf(char** s, size_t* slen, const char* templ, ...); + WINPR_API int winpr_vasprintf(char** s, size_t* slen, const char* templ, va_list ap); + +#ifndef _WIN32 + +#define CSTR_LESS_THAN 1 +#define CSTR_EQUAL 2 +#define CSTR_GREATER_THAN 3 + +#define CP_ACP 0 +#define CP_OEMCP 1 +#define CP_MACCP 2 +#define CP_THREAD_ACP 3 +#define CP_SYMBOL 42 +#define CP_UTF7 65000 +#define CP_UTF8 65001 + +#define MB_PRECOMPOSED 0x00000001 +#define MB_COMPOSITE 0x00000002 +#define MB_USEGLYPHCHARS 0x00000004 +#define MB_ERR_INVALID_CHARS 0x00000008 + + WINPR_API char* _strdup(const char* strSource); + WINPR_API WCHAR* _wcsdup(const WCHAR* strSource); + + WINPR_API int _stricmp(const char* string1, const char* string2); + WINPR_API int _strnicmp(const char* string1, const char* string2, size_t count); + + WINPR_API int _wcscmp(const WCHAR* string1, const WCHAR* string2); + WINPR_API int _wcsncmp(const WCHAR* string1, const WCHAR* string2, size_t count); + + WINPR_API size_t _wcslen(const WCHAR* str); + WINPR_API size_t _wcsnlen(const WCHAR* str, size_t maxNumberOfElements); + + WINPR_API WCHAR* _wcsstr(const WCHAR* str, const WCHAR* strSearch); + + WINPR_API WCHAR* _wcschr(const WCHAR* str, WCHAR c); + WINPR_API WCHAR* _wcsrchr(const WCHAR* str, WCHAR c); + + WINPR_API char* strtok_s(char* strToken, const char* strDelimit, char** context); + WINPR_API WCHAR* wcstok_s(WCHAR* strToken, const WCHAR* strDelimit, WCHAR** context); + + WINPR_API WCHAR* _wcsncat(WCHAR* dst, const WCHAR* src, size_t sz); +#else + +#define _wcscmp wcscmp +#define _wcsncmp wcsncmp +#define _wcslen wcslen +#define _wcsnlen wcsnlen +#define _wcsstr wcsstr +#define _wcschr wcschr +#define _wcsrchr wcsrchr +#define _wcsncat wcsncat + +#endif /* _WIN32 */ + +#if !defined(_WIN32) || defined(_UWP) + + WINPR_API LPSTR CharUpperA(LPSTR lpsz); + WINPR_API LPWSTR CharUpperW(LPWSTR lpsz); + +#ifdef UNICODE +#define CharUpper CharUpperW +#else +#define CharUpper CharUpperA +#endif + + WINPR_API DWORD CharUpperBuffA(LPSTR lpsz, DWORD cchLength); + WINPR_API DWORD CharUpperBuffW(LPWSTR lpsz, DWORD cchLength); + +#ifdef UNICODE +#define CharUpperBuff CharUpperBuffW +#else +#define CharUpperBuff CharUpperBuffA +#endif + + WINPR_API LPSTR CharLowerA(LPSTR lpsz); + WINPR_API LPWSTR CharLowerW(LPWSTR lpsz); + +#ifdef UNICODE +#define CharLower CharLowerW +#else +#define CharLower CharLowerA +#endif + + WINPR_API DWORD CharLowerBuffA(LPSTR lpsz, DWORD cchLength); + WINPR_API DWORD CharLowerBuffW(LPWSTR lpsz, DWORD cchLength); + +#ifdef UNICODE +#define CharLowerBuff CharLowerBuffW +#else +#define CharLowerBuff CharLowerBuffA +#endif + + WINPR_API BOOL IsCharAlphaA(CHAR ch); + WINPR_API BOOL IsCharAlphaW(WCHAR ch); + +#ifdef UNICODE +#define IsCharAlpha IsCharAlphaW +#else +#define IsCharAlpha IsCharAlphaA +#endif + + WINPR_API BOOL IsCharAlphaNumericA(CHAR ch); + WINPR_API BOOL IsCharAlphaNumericW(WCHAR ch); + +#ifdef UNICODE +#define IsCharAlphaNumeric IsCharAlphaNumericW +#else +#define IsCharAlphaNumeric IsCharAlphaNumericA +#endif + + WINPR_API BOOL IsCharUpperA(CHAR ch); + WINPR_API BOOL IsCharUpperW(WCHAR ch); + +#ifdef UNICODE +#define IsCharUpper IsCharUpperW +#else +#define IsCharUpper IsCharUpperA +#endif + + WINPR_API BOOL IsCharLowerA(CHAR ch); + WINPR_API BOOL IsCharLowerW(WCHAR ch); + +#ifdef UNICODE +#define IsCharLower IsCharLowerW +#else +#define IsCharLower IsCharLowerA +#endif + +#endif + +#ifndef _WIN32 + +#define sprintf_s snprintf +#define _snprintf snprintf +#define _scprintf(...) snprintf(NULL, 0, __VA_ARGS__) + +#define _scprintf(...) snprintf(NULL, 0, __VA_ARGS__) + + /* Unicode Conversion */ + +#if defined(WITH_WINPR_DEPRECATED) + WINPR_API WINPR_DEPRECATED_VAR("Use ConvertUtf8ToWChar instead", + int MultiByteToWideChar(UINT CodePage, DWORD dwFlags, + LPCSTR lpMultiByteStr, int cbMultiByte, + LPWSTR lpWideCharStr, int cchWideChar)); + + WINPR_API WINPR_DEPRECATED_VAR("Use ConvertWCharToUtf8 instead", + int WideCharToMultiByte(UINT CodePage, DWORD dwFlags, + LPCWSTR lpWideCharStr, int cchWideChar, + LPSTR lpMultiByteStr, int cbMultiByte, + LPCSTR lpDefaultChar, + LPBOOL lpUsedDefaultChar)); +#endif + +#endif + + /* Extended API */ + /** \brief Converts form UTF-16 to UTF-8 + * + * The function does string conversions of any '\0' terminated input string + * + * Supplying len = 0 will return the required size of the buffer in characters. + * + * \warning Supplying a buffer length smaller than required will result in + * platform dependent (=undefined) behaviour! + * + * \param wstr A '\0' terminated WCHAR string, may be NULL + * \param str A pointer to the result string + * \param len The length in characters of the result buffer + * + * \return the size of the converted string in char (strlen), or -1 for failure + */ + WINPR_API SSIZE_T ConvertWCharToUtf8(const WCHAR* wstr, char* str, size_t len); + + /** \brief Converts form UTF-16 to UTF-8 + * + * The function does string conversions of any input string of wlen (or less) + * characters until it reaches the first '\0'. + * + * Supplying len = 0 will return the required size of the buffer in characters. + * + * \warning Supplying a buffer length smaller than required will result in + * platform dependent (=undefined) behaviour! + * + * \param wstr A WCHAR string of \b wlen length + * \param wlen The (buffer) length in characters of \b wstr + * \param str A pointer to the result string + * \param len The length in characters of the result buffer + * + * \return the size of the converted string in char (strlen), or -1 for failure + */ + WINPR_API SSIZE_T ConvertWCharNToUtf8(const WCHAR* wstr, size_t wlen, char* str, size_t len); + + /** \brief Converts multistrings form UTF-16 to UTF-8 + * + * The function does string conversions of any input string of wlen characters. + * Any character in the buffer (incuding any '\0') is converted. + * + * Supplying len = 0 will return the required size of the buffer in characters. + * + * \warning Supplying a buffer length smaller than required will result in + * platform dependent (=undefined) behaviour! + * + * \param wstr A WCHAR string of \b wlen length + * \param wlen The (buffer) length in characters of \b wstr + * \param str A pointer to the result string + * \param len The length in characters of the result buffer + * + * \return the size of the converted string in CHAR characters (including any '\0'), or -1 for + * failure + */ + WINPR_API SSIZE_T ConvertMszWCharNToUtf8(const WCHAR* wstr, size_t wlen, char* str, size_t len); + + /** \brief Converts form UTF-8 to UTF-16 + * + * The function does string conversions of any '\0' terminated input string + * + * Supplying len = 0 will return the required size of the buffer in characters. + * + * \warning Supplying a buffer length smaller than required will result in + * platform dependent (=undefined) behaviour! + * + * \param str A '\0' terminated CHAR string, may be NULL + * \param wstr A pointer to the result WCHAR string + * \param wlen The length in WCHAR characters of the result buffer + * + * \return the size of the converted string in WCHAR characters (wcslen), or -1 for failure + */ + WINPR_API SSIZE_T ConvertUtf8ToWChar(const char* str, WCHAR* wstr, size_t wlen); + + /** \brief Converts form UTF-8 to UTF-16 + * + * The function does string conversions of any input string of len (or less) + * characters until it reaches the first '\0'. + * + * Supplying len = 0 will return the required size of the buffer in characters. + * + * \warning Supplying a buffer length smaller than required will result in + * platform dependent (=undefined) behaviour! + * + * \param str A CHAR string of \b len length + * \param len The (buffer) length in characters of \b str + * \param wstr A pointer to the result WCHAR string + * \param wlen The length in WCHAR characters of the result buffer + * + * \return the size of the converted string in WCHAR characters (wcslen), or -1 for failure + */ + WINPR_API SSIZE_T ConvertUtf8NToWChar(const char* str, size_t len, WCHAR* wstr, size_t wlen); + + /** \brief Converts multistrings form UTF-8 to UTF-16 + * + * The function does string conversions of any input string of len characters. + * Any character in the buffer (incuding any '\0') is converted. + * + * Supplying len = 0 will return the required size of the buffer in characters. + * + * \warning Supplying a buffer length smaller than required will result in + * platform dependent (=undefined) behaviour! + * + * \param str A CHAR string of \b len length + * \param len The (buffer) length in characters of \b str + * \param wstr A pointer to the result WCHAR string + * \param wlen The length in WCHAR characters of the result buffer + * + * \return the size of the converted string in WCHAR characters (including any '\0'), or -1 for + * failure + */ + WINPR_API SSIZE_T ConvertMszUtf8NToWChar(const char* str, size_t len, WCHAR* wstr, size_t wlen); + + /** \brief Converts form UTF-16 to UTF-8, returns an allocated string + * + * The function does string conversions of any '\0' terminated input string + * + * \param wstr A '\0' terminated WCHAR string, may be NULL + * \param pSize Ignored if NULL, otherwise receives the length of the result string in + * characters (strlen) + * + * \return An allocated zero terminated UTF-8 string or NULL in case of failure. + */ + WINPR_API char* ConvertWCharToUtf8Alloc(const WCHAR* wstr, size_t* pSize); + + /** \brief Converts form UTF-16 to UTF-8, returns an allocated string + * + * The function does string conversions of any input string of wlen (or less) + * characters until it reaches the first '\0'. + * + * \param wstr A WCHAR string of \b wlen length + * \param wlen The (buffer) length in characters of \b wstr + * \param pSize Ignored if NULL, otherwise receives the length of the result string in + * characters (strlen) + * + * \return An allocated zero terminated UTF-8 string or NULL in case of failure. + */ + WINPR_API char* ConvertWCharNToUtf8Alloc(const WCHAR* wstr, size_t wlen, size_t* pSize); + + /** \brief Converts multistring form UTF-16 to UTF-8, returns an allocated string + * + * The function does string conversions of any input string of len characters. + * Any character in the buffer (incuding any '\0') is converted. + * + * \param wstr A WCHAR string of \b len character length + * \param wlen The (buffer) length in characters of \b str + * \param pSize Ignored if NULL, otherwise receives the length of the result string in + * characters (including any '\0' character) + * + * \return An allocated double zero terminated UTF-8 string or NULL in case of failure. + */ + WINPR_API char* ConvertMszWCharNToUtf8Alloc(const WCHAR* wstr, size_t wlen, size_t* pSize); + + /** \brief Converts form UTF-8 to UTF-16, returns an allocated string + * + * The function does string conversions of any '\0' terminated input string + * + * \param str A '\0' terminated CHAR string, may be NULL + * \param pSize Ignored if NULL, otherwise receives the length of the result string in + * characters (wcslen) + * + * \return An allocated zero terminated UTF-16 string or NULL in case of failure. + */ + WINPR_API WCHAR* ConvertUtf8ToWCharAlloc(const char* str, size_t* pSize); + + /** \brief Converts form UTF-8 to UTF-16, returns an allocated string + * + * The function does string conversions of any input string of len (or less) + * characters until it reaches the first '\0'. + * + * \param str A CHAR string of \b len length + * \param len The (buffer) length in characters of \b str + * \param pSize Ignored if NULL, otherwise receives the length of the result string in + * characters (wcslen) + * + * \return An allocated zero terminated UTF-16 string or NULL in case of failure. + */ + WINPR_API WCHAR* ConvertUtf8NToWCharAlloc(const char* str, size_t len, size_t* pSize); + + /** \brief Converts multistring form UTF-8 to UTF-16, returns an allocated string + * + * The function does string conversions of any input string of len characters. + * Any character in the buffer (incuding any '\0') is converted. + * + * \param str A CHAR string of \b len byte length + * \param len The (buffer) length in characters of \b str + * \param pSize Ignored if NULL, otherwise receives the length of the result string in + * characters (including any '\0' character) + * + * \return An allocated double zero terminated UTF-16 string or NULL in case of failure. + */ + WINPR_API WCHAR* ConvertMszUtf8NToWCharAlloc(const char* str, size_t len, size_t* pSize); + + /** \brief Helper function to initialize const WCHAR pointer from a Utf8 string + * + * \param str The Utf8 string to use for initialization + * \param buffer The WCHAR buffer used to store the converted data + * \param len The size of the buffer in number of WCHAR + * + * \return The WCHAR string (a pointer to buffer) + */ + WINPR_API const WCHAR* InitializeConstWCharFromUtf8(const char* str, WCHAR* buffer, size_t len); + +#if defined(WITH_WINPR_DEPRECATED) + WINPR_API WINPR_DEPRECATED_VAR("Use ConvertUtf8ToWChar functions instead", + int ConvertToUnicode(UINT CodePage, DWORD dwFlags, + LPCSTR lpMultiByteStr, int cbMultiByte, + LPWSTR* lpWideCharStr, int cchWideChar)); + + WINPR_API WINPR_DEPRECATED_VAR("Use ConvertWCharToUtf8 functions instead", + int ConvertFromUnicode(UINT CodePage, DWORD dwFlags, + LPCWSTR lpWideCharStr, int cchWideChar, + LPSTR* lpMultiByteStr, int cbMultiByte, + LPCSTR lpDefaultChar, + LPBOOL lpUsedDefaultChar)); +#endif + + WINPR_API const WCHAR* ByteSwapUnicode(WCHAR* wstr, size_t length); + + WINPR_API size_t ConvertLineEndingToLF(char* str, size_t size); + WINPR_API char* ConvertLineEndingToCRLF(const char* str, size_t* size); + + WINPR_API char* StrSep(char** stringp, const char* delim); + + WINPR_API INT64 GetLine(char** lineptr, size_t* size, FILE* stream); + +#if !defined(WINPR_HAVE_STRNDUP) + WINPR_API char* strndup(const char* s, size_t n); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* WINPR_CRT_STRING_H */ diff --git a/winpr/include/winpr/strlst.h b/winpr/include/winpr/strlst.h new file mode 100644 index 0000000..346946d --- /dev/null +++ b/winpr/include/winpr/strlst.h @@ -0,0 +1,41 @@ +/** + * String list Manipulation (UTILS) + * + * Copyright 2018 Pascal Bourguignon <pjb@informatimago.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_UTILS_STRLST_H +#define WINPR_UTILS_STRLST_H + +#include <stdio.h> + +#include <winpr/winpr.h> +#include <winpr/wtypes.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API void string_list_free(char** string_list); + WINPR_API int string_list_length(const char* const* string_list); + WINPR_API char** string_list_copy(const char* const* string_list); + WINPR_API void string_list_print(FILE* out, const char* const* string_list); + +#ifdef __cplusplus +} +#endif + +#endif /* WINPR_UTILS_STRLST_H */ diff --git a/winpr/include/winpr/synch.h b/winpr/include/winpr/synch.h new file mode 100644 index 0000000..b310a3b --- /dev/null +++ b/winpr/include/winpr/synch.h @@ -0,0 +1,423 @@ +/** + * WinPR: Windows Portable Runtime + * Synchronization Functions + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * Copyright 2014 Thincast Technologies GmbH + * Copyright 2014 Norbert Federa <norbert.federa@thincast.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_SYNCH_H +#define WINPR_SYNCH_H + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <winpr/platform.h> +#include <winpr/winpr.h> +#include <winpr/wtypes.h> +#include <winpr/error.h> +#include <winpr/handle.h> + +#include <winpr/nt.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + +#ifndef _WIN32 + +/* Mutex */ +#define CREATE_MUTEX_INITIAL_OWNER 0x00000001 + + WINPR_API HANDLE CreateMutexA(LPSECURITY_ATTRIBUTES lpMutexAttributes, BOOL bInitialOwner, + LPCSTR lpName); + WINPR_API HANDLE CreateMutexW(LPSECURITY_ATTRIBUTES lpMutexAttributes, BOOL bInitialOwner, + LPCWSTR lpName); + + WINPR_API HANDLE CreateMutexExA(LPSECURITY_ATTRIBUTES lpMutexAttributes, LPCSTR lpName, + DWORD dwFlags, DWORD dwDesiredAccess); + WINPR_API HANDLE CreateMutexExW(LPSECURITY_ATTRIBUTES lpMutexAttributes, LPCWSTR lpName, + DWORD dwFlags, DWORD dwDesiredAccess); + + WINPR_API HANDLE OpenMutexA(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCSTR lpName); + WINPR_API HANDLE OpenMutexW(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCWSTR lpName); + + WINPR_API BOOL ReleaseMutex(HANDLE hMutex); + +#ifdef UNICODE +#define CreateMutex CreateMutexW +#define CreateMutexEx CreateMutexExW +#define OpenMutex OpenMutexW +#else +#define CreateMutex CreateMutexA +#define CreateMutexEx CreateMutexExA +#define OpenMutex OpenMutexA +#endif + + /* Semaphore */ + + WINPR_API HANDLE CreateSemaphoreA(LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, + LONG lInitialCount, LONG lMaximumCount, LPCSTR lpName); + WINPR_API HANDLE CreateSemaphoreW(LPSECURITY_ATTRIBUTES lpSemaphoreAttributes, + LONG lInitialCount, LONG lMaximumCount, LPCWSTR lpName); + + WINPR_API HANDLE OpenSemaphoreA(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCSTR lpName); + WINPR_API HANDLE OpenSemaphoreW(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCWSTR lpName); + +#ifdef UNICODE +#define CreateSemaphore CreateSemaphoreW +#define OpenSemaphore OpenSemaphoreW +#else +#define CreateSemaphore CreateSemaphoreA +#define OpenSemaphore OpenSemaphoreA +#endif + + WINPR_API BOOL ReleaseSemaphore(HANDLE hSemaphore, LONG lReleaseCount, LPLONG lpPreviousCount); + +/* Event */ +#define CREATE_EVENT_MANUAL_RESET 0x00000001 +#define CREATE_EVENT_INITIAL_SET 0x00000002 + + WINPR_API HANDLE CreateEventA(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset, + BOOL bInitialState, LPCSTR lpName); + WINPR_API HANDLE CreateEventW(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset, + BOOL bInitialState, LPCWSTR lpName); + + WINPR_API HANDLE CreateEventExA(LPSECURITY_ATTRIBUTES lpEventAttributes, LPCSTR lpName, + DWORD dwFlags, DWORD dwDesiredAccess); + WINPR_API HANDLE CreateEventExW(LPSECURITY_ATTRIBUTES lpEventAttributes, LPCWSTR lpName, + DWORD dwFlags, DWORD dwDesiredAccess); + + WINPR_API HANDLE OpenEventA(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCSTR lpName); + WINPR_API HANDLE OpenEventW(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCWSTR lpName); + + WINPR_API BOOL SetEvent(HANDLE hEvent); + WINPR_API BOOL ResetEvent(HANDLE hEvent); + +#if defined(WITH_DEBUG_EVENTS) +#define DumpEventHandles() DumpEventHandles_(__func__, __FILE__, __LINE__) + WINPR_API void DumpEventHandles_(const char* fkt, const char* file, size_t line); +#endif +#ifdef UNICODE +#define CreateEvent CreateEventW +#define CreateEventEx CreateEventExW +#define OpenEvent OpenEventW +#else +#define CreateEvent CreateEventA +#define CreateEventEx CreateEventExA +#define OpenEvent OpenEventA +#endif + + /* Condition Variable */ + + typedef PVOID RTL_CONDITION_VARIABLE; + typedef RTL_CONDITION_VARIABLE CONDITION_VARIABLE, *PCONDITION_VARIABLE; + + /* Critical Section */ + + typedef struct + { + PVOID DebugInfo; + LONG LockCount; + LONG RecursionCount; + HANDLE OwningThread; + HANDLE LockSemaphore; + ULONG_PTR SpinCount; + } RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION; + + typedef RTL_CRITICAL_SECTION CRITICAL_SECTION; + typedef PRTL_CRITICAL_SECTION PCRITICAL_SECTION; + typedef PRTL_CRITICAL_SECTION LPCRITICAL_SECTION; + + WINPR_API VOID InitializeCriticalSection(LPCRITICAL_SECTION lpCriticalSection); + WINPR_API BOOL InitializeCriticalSectionEx(LPCRITICAL_SECTION lpCriticalSection, + DWORD dwSpinCount, DWORD Flags); + WINPR_API BOOL InitializeCriticalSectionAndSpinCount(LPCRITICAL_SECTION lpCriticalSection, + DWORD dwSpinCount); + + WINPR_API DWORD SetCriticalSectionSpinCount(LPCRITICAL_SECTION lpCriticalSection, + DWORD dwSpinCount); + + WINPR_API VOID EnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection); + WINPR_API BOOL TryEnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection); + + WINPR_API VOID LeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection); + + WINPR_API VOID DeleteCriticalSection(LPCRITICAL_SECTION lpCriticalSection); + + /* Sleep */ + + WINPR_API VOID Sleep(DWORD dwMilliseconds); + WINPR_API DWORD SleepEx(DWORD dwMilliseconds, BOOL bAlertable); + + /* Address */ + + WINPR_API VOID WakeByAddressAll(PVOID Address); + WINPR_API VOID WakeByAddressSingle(PVOID Address); + + WINPR_API BOOL WaitOnAddress(VOID volatile* Address, PVOID CompareAddress, SIZE_T AddressSize, + DWORD dwMilliseconds); + + /* Wait */ + +#define INFINITE 0xFFFFFFFFUL + +#define WAIT_OBJECT_0 0x00000000UL +#define WAIT_ABANDONED 0x00000080UL +#define WAIT_IO_COMPLETION 0x000000C0UL + +#ifndef WAIT_TIMEOUT +#define WAIT_TIMEOUT 0x00000102UL +#endif + +#define WAIT_FAILED 0xFFFFFFFFUL + +#define MAXIMUM_WAIT_OBJECTS 64 + + WINPR_API DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds); + WINPR_API DWORD WaitForSingleObjectEx(HANDLE hHandle, DWORD dwMilliseconds, BOOL bAlertable); + WINPR_API DWORD WaitForMultipleObjects(DWORD nCount, const HANDLE* lpHandles, BOOL bWaitAll, + DWORD dwMilliseconds); + WINPR_API DWORD WaitForMultipleObjectsEx(DWORD nCount, const HANDLE* lpHandles, BOOL bWaitAll, + DWORD dwMilliseconds, BOOL bAlertable); + + WINPR_API DWORD SignalObjectAndWait(HANDLE hObjectToSignal, HANDLE hObjectToWaitOn, + DWORD dwMilliseconds, BOOL bAlertable); + + /* Waitable Timer */ + +#define CREATE_WAITABLE_TIMER_MANUAL_RESET 0x00000001 + + typedef struct + { + ULONG Version; + DWORD Flags; + + union + { + struct + { + HMODULE LocalizedReasonModule; + ULONG LocalizedReasonId; + ULONG ReasonStringCount; + LPWSTR* ReasonStrings; + } Detailed; + + LPWSTR SimpleReasonString; + } Reason; + } REASON_CONTEXT, *PREASON_CONTEXT; + + typedef VOID (*PTIMERAPCROUTINE)(LPVOID lpArgToCompletionRoutine, DWORD dwTimerLowValue, + DWORD dwTimerHighValue); + + WINPR_API HANDLE CreateWaitableTimerA(LPSECURITY_ATTRIBUTES lpTimerAttributes, + BOOL bManualReset, LPCSTR lpTimerName); + WINPR_API HANDLE CreateWaitableTimerW(LPSECURITY_ATTRIBUTES lpTimerAttributes, + BOOL bManualReset, LPCWSTR lpTimerName); + + WINPR_API HANDLE CreateWaitableTimerExA(LPSECURITY_ATTRIBUTES lpTimerAttributes, + LPCSTR lpTimerName, DWORD dwFlags, + DWORD dwDesiredAccess); + WINPR_API HANDLE CreateWaitableTimerExW(LPSECURITY_ATTRIBUTES lpTimerAttributes, + LPCWSTR lpTimerName, DWORD dwFlags, + DWORD dwDesiredAccess); + + WINPR_API BOOL SetWaitableTimer(HANDLE hTimer, const LARGE_INTEGER* lpDueTime, LONG lPeriod, + PTIMERAPCROUTINE pfnCompletionRoutine, + LPVOID lpArgToCompletionRoutine, BOOL fResume); + + WINPR_API BOOL SetWaitableTimerEx(HANDLE hTimer, const LARGE_INTEGER* lpDueTime, LONG lPeriod, + PTIMERAPCROUTINE pfnCompletionRoutine, + LPVOID lpArgToCompletionRoutine, PREASON_CONTEXT WakeContext, + ULONG TolerableDelay); + + WINPR_API HANDLE OpenWaitableTimerA(DWORD dwDesiredAccess, BOOL bInheritHandle, + LPCSTR lpTimerName); + WINPR_API HANDLE OpenWaitableTimerW(DWORD dwDesiredAccess, BOOL bInheritHandle, + LPCWSTR lpTimerName); + + WINPR_API BOOL CancelWaitableTimer(HANDLE hTimer); + +#ifdef UNICODE +#define CreateWaitableTimer CreateWaitableTimerW +#define CreateWaitableTimerEx CreateWaitableTimerExW +#define OpenWaitableTimer OpenWaitableTimerW +#else +#define CreateWaitableTimer CreateWaitableTimerA +#define CreateWaitableTimerEx CreateWaitableTimerExA +#define OpenWaitableTimer OpenWaitableTimerA +#endif + + WINPR_API int GetTimerFileDescriptor(HANDLE hEvent); + + /** + * Timer-Queue Timer + */ + +#define WT_EXECUTEDEFAULT 0x00000000 +#define WT_EXECUTEINIOTHREAD 0x00000001 +#define WT_EXECUTEINUITHREAD 0x00000002 +#define WT_EXECUTEINWAITTHREAD 0x00000004 +#define WT_EXECUTEONLYONCE 0x00000008 +#define WT_EXECUTELONGFUNCTION 0x00000010 +#define WT_EXECUTEINTIMERTHREAD 0x00000020 +#define WT_EXECUTEINPERSISTENTIOTHREAD 0x00000040 +#define WT_EXECUTEINPERSISTENTTHREAD 0x00000080 +#define WT_TRANSFER_IMPERSONATION 0x00000100 + + typedef VOID (*WAITORTIMERCALLBACK)(PVOID lpParameter, BOOLEAN TimerOrWaitFired); + + WINPR_API HANDLE CreateTimerQueue(void); + WINPR_API BOOL DeleteTimerQueue(HANDLE TimerQueue); + WINPR_API BOOL DeleteTimerQueueEx(HANDLE TimerQueue, HANDLE CompletionEvent); + + WINPR_API BOOL CreateTimerQueueTimer(PHANDLE phNewTimer, HANDLE TimerQueue, + WAITORTIMERCALLBACK Callback, PVOID Parameter, + DWORD DueTime, DWORD Period, ULONG Flags); + WINPR_API BOOL ChangeTimerQueueTimer(HANDLE TimerQueue, HANDLE Timer, ULONG DueTime, + ULONG Period); + WINPR_API BOOL DeleteTimerQueueTimer(HANDLE TimerQueue, HANDLE Timer, HANDLE CompletionEvent); + +#endif + +#if (defined(_WIN32) && (_WIN32_WINNT < 0x0600)) +#define InitializeCriticalSectionEx(lpCriticalSection, dwSpinCount, Flags) \ + InitializeCriticalSectionAndSpinCount(lpCriticalSection, dwSpinCount) +#endif + + WINPR_PRAGMA_DIAG_PUSH + WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO + +#ifndef _RTL_RUN_ONCE_DEF +#define _RTL_RUN_ONCE_DEF + + WINPR_PRAGMA_DIAG_POP + +#define RTL_RUN_ONCE_INIT \ + { \ + 0 \ + } + +#define RTL_RUN_ONCE_CHECK_ONLY 0x00000001 +#define RTL_RUN_ONCE_ASYNC 0x00000002 +#define RTL_RUN_ONCE_INIT_FAILED 0x00000004 + +#define RTL_RUN_ONCE_CTX_RESERVED_BITS 2 + + typedef struct + { + PVOID Ptr; + } RTL_RUN_ONCE, *PRTL_RUN_ONCE; + + typedef ULONG CALLBACK RTL_RUN_ONCE_INIT_FN(PRTL_RUN_ONCE RunOnce, PVOID Parameter, + PVOID* Context); + typedef RTL_RUN_ONCE_INIT_FN* PRTL_RUN_ONCE_INIT_FN; + +#endif + +#if (!defined(_WIN32)) || (defined(_WIN32) && (_WIN32_WINNT < 0x0600)) + + /* One-Time Initialization */ + +#define INIT_ONCE_STATIC_INIT RTL_RUN_ONCE_INIT + + typedef RTL_RUN_ONCE INIT_ONCE; + typedef PRTL_RUN_ONCE PINIT_ONCE; + typedef PRTL_RUN_ONCE LPINIT_ONCE; + typedef BOOL(CALLBACK* PINIT_ONCE_FN)(PINIT_ONCE InitOnce, PVOID Parameter, PVOID* Context); + + WINPR_API BOOL winpr_InitOnceBeginInitialize(LPINIT_ONCE lpInitOnce, DWORD dwFlags, + PBOOL fPending, LPVOID* lpContext); + WINPR_API BOOL winpr_InitOnceComplete(LPINIT_ONCE lpInitOnce, DWORD dwFlags, LPVOID lpContext); + WINPR_API BOOL winpr_InitOnceExecuteOnce(PINIT_ONCE InitOnce, PINIT_ONCE_FN InitFn, + PVOID Parameter, LPVOID* Context); + WINPR_API VOID winpr_InitOnceInitialize(PINIT_ONCE InitOnce); + +#define InitOnceBeginInitialize winpr_InitOnceBeginInitialize +#define InitOnceComplete winpr_InitOnceComplete +#define InitOnceExecuteOnce winpr_InitOnceExecuteOnce +#define InitOnceInitialize winpr_InitOnceInitialize +#endif + + /* Synchronization Barrier */ + +#if (!defined(_WIN32)) || (defined(_WIN32) && (_WIN32_WINNT < 0x0602) && !defined(_SYNCHAPI_H_)) +#define WINPR_SYNCHRONIZATION_BARRIER 1 +#endif + +#ifdef WINPR_SYNCHRONIZATION_BARRIER + + typedef struct + { + DWORD Reserved1; + DWORD Reserved2; + ULONG_PTR Reserved3[2]; + DWORD Reserved4; + DWORD Reserved5; + } RTL_BARRIER, *PRTL_BARRIER; + + typedef RTL_BARRIER SYNCHRONIZATION_BARRIER; + typedef PRTL_BARRIER PSYNCHRONIZATION_BARRIER; + typedef PRTL_BARRIER LPSYNCHRONIZATION_BARRIER; + +#define SYNCHRONIZATION_BARRIER_FLAGS_SPIN_ONLY 0x01 +#define SYNCHRONIZATION_BARRIER_FLAGS_BLOCK_ONLY 0x02 +#define SYNCHRONIZATION_BARRIER_FLAGS_NO_DELETE 0x04 + + WINPR_API BOOL WINAPI winpr_InitializeSynchronizationBarrier( + LPSYNCHRONIZATION_BARRIER lpBarrier, LONG lTotalThreads, LONG lSpinCount); + WINPR_API BOOL WINAPI winpr_EnterSynchronizationBarrier(LPSYNCHRONIZATION_BARRIER lpBarrier, + DWORD dwFlags); + WINPR_API BOOL WINAPI winpr_DeleteSynchronizationBarrier(LPSYNCHRONIZATION_BARRIER lpBarrier); + +#define InitializeSynchronizationBarrier winpr_InitializeSynchronizationBarrier +#define EnterSynchronizationBarrier winpr_EnterSynchronizationBarrier +#define DeleteSynchronizationBarrier winpr_DeleteSynchronizationBarrier + +#endif + + /* Extended API */ + + WINPR_API VOID USleep(DWORD dwMicroseconds); + + WINPR_API HANDLE CreateFileDescriptorEventW(LPSECURITY_ATTRIBUTES lpEventAttributes, + BOOL bManualReset, BOOL bInitialState, + int FileDescriptor, ULONG mode); + WINPR_API HANDLE CreateFileDescriptorEventA(LPSECURITY_ATTRIBUTES lpEventAttributes, + BOOL bManualReset, BOOL bInitialState, + int FileDescriptor, ULONG mode); + + WINPR_API HANDLE CreateWaitObjectEvent(LPSECURITY_ATTRIBUTES lpEventAttributes, + BOOL bManualReset, BOOL bInitialState, void* pObject); + +#ifdef UNICODE +#define CreateFileDescriptorEvent CreateFileDescriptorEventW +#else +#define CreateFileDescriptorEvent CreateFileDescriptorEventA +#endif + + WINPR_API int GetEventFileDescriptor(HANDLE hEvent); + WINPR_API int SetEventFileDescriptor(HANDLE hEvent, int FileDescriptor, ULONG mode); + + WINPR_API void* GetEventWaitObject(HANDLE hEvent); + +#ifdef __cplusplus +} +#endif + +#endif /* WINPR_SYNCH_H */ diff --git a/winpr/include/winpr/sysinfo.h b/winpr/include/winpr/sysinfo.h new file mode 100644 index 0000000..d7d6dd8 --- /dev/null +++ b/winpr/include/winpr/sysinfo.h @@ -0,0 +1,358 @@ +/** + * WinPR: Windows Portable Runtime + * System Information + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_SYSINFO_H +#define WINPR_SYSINFO_H + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <winpr/winpr.h> +#include <winpr/wtypes.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + +#ifndef _WIN32 + +#define PROCESSOR_ARCHITECTURE_INTEL 0 +#define PROCESSOR_ARCHITECTURE_MIPS 1 +#define PROCESSOR_ARCHITECTURE_ALPHA 2 +#define PROCESSOR_ARCHITECTURE_PPC 3 +#define PROCESSOR_ARCHITECTURE_SHX 4 +#define PROCESSOR_ARCHITECTURE_ARM 5 +#define PROCESSOR_ARCHITECTURE_IA64 6 +#define PROCESSOR_ARCHITECTURE_ALPHA64 7 +#define PROCESSOR_ARCHITECTURE_MSIL 8 +#define PROCESSOR_ARCHITECTURE_AMD64 9 +#define PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 10 +#define PROCESSOR_ARCHITECTURE_NEUTRAL 11 +#define PROCESSOR_ARCHITECTURE_ARM64 12 +#define PROCESSOR_ARCHITECTURE_MIPS64 13 +#define PROCESSOR_ARCHITECTURE_E2K 14 +#define PROCESSOR_ARCHITECTURE_UNKNOWN 0xFFFF + +#define PROCESSOR_INTEL_386 386 +#define PROCESSOR_INTEL_486 486 +#define PROCESSOR_INTEL_PENTIUM 586 +#define PROCESSOR_INTEL_IA64 2200 +#define PROCESSOR_AMD_X8664 8664 +#define PROCESSOR_MIPS_R4000 4000 +#define PROCESSOR_ALPHA_21064 21064 +#define PROCESSOR_PPC_601 601 +#define PROCESSOR_PPC_603 603 +#define PROCESSOR_PPC_604 604 +#define PROCESSOR_PPC_620 620 +#define PROCESSOR_HITACHI_SH3 10003 +#define PROCESSOR_HITACHI_SH3E 10004 +#define PROCESSOR_HITACHI_SH4 10005 +#define PROCESSOR_MOTOROLA_821 821 +#define PROCESSOR_SHx_SH3 103 +#define PROCESSOR_SHx_SH4 104 +#define PROCESSOR_STRONGARM 2577 +#define PROCESSOR_ARM720 1824 +#define PROCESSOR_ARM820 2080 +#define PROCESSOR_ARM920 2336 +#define PROCESSOR_ARM_7TDMI 70001 +#define PROCESSOR_OPTIL 0x494F + + typedef struct + { + union + { + DWORD dwOemId; + + struct + { + WORD wProcessorArchitecture; + WORD wReserved; + }; + }; + + DWORD dwPageSize; + LPVOID lpMinimumApplicationAddress; + LPVOID lpMaximumApplicationAddress; + DWORD_PTR dwActiveProcessorMask; + DWORD dwNumberOfProcessors; + DWORD dwProcessorType; + DWORD dwAllocationGranularity; + WORD wProcessorLevel; + WORD wProcessorRevision; + } SYSTEM_INFO, *LPSYSTEM_INFO; + + WINPR_API void GetSystemInfo(LPSYSTEM_INFO lpSystemInfo); + WINPR_API void GetNativeSystemInfo(LPSYSTEM_INFO lpSystemInfo); + +#if defined(WITH_WINPR_DEPRECATED) + typedef struct + { + DWORD dwOSVersionInfoSize; + DWORD dwMajorVersion; + DWORD dwMinorVersion; + DWORD dwBuildNumber; + DWORD dwPlatformId; + CHAR szCSDVersion[128]; + } OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA; + + typedef struct + { + DWORD dwOSVersionInfoSize; + DWORD dwMajorVersion; + DWORD dwMinorVersion; + DWORD dwBuildNumber; + DWORD dwPlatformId; + WCHAR szCSDVersion[128]; + } OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW; + + typedef struct + { + DWORD dwOSVersionInfoSize; + DWORD dwMajorVersion; + DWORD dwMinorVersion; + DWORD dwBuildNumber; + DWORD dwPlatformId; + CHAR szCSDVersion[128]; + WORD wServicePackMajor; + WORD wServicePackMinor; + WORD wSuiteMask; + BYTE wProductType; + BYTE wReserved; + } OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA; + + typedef struct + { + DWORD dwOSVersionInfoSize; + DWORD dwMajorVersion; + DWORD dwMinorVersion; + DWORD dwBuildNumber; + DWORD dwPlatformId; + WCHAR szCSDVersion[128]; + WORD wServicePackMajor; + WORD wServicePackMinor; + WORD wSuiteMask; + BYTE wProductType; + BYTE wReserved; + } OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW; + +#ifdef UNICODE +#define OSVERSIONINFO OSVERSIONINFOW +#define OSVERSIONINFOEX OSVERSIONINFOEXW +#define POSVERSIONINFO POSVERSIONINFOW +#define POSVERSIONINFOEX POSVERSIONINFOEXW +#define LPOSVERSIONINFO LPOSVERSIONINFOW +#define LPOSVERSIONINFOEX LPOSVERSIONINFOEXW +#else +#define OSVERSIONINFO OSVERSIONINFOA +#define OSVERSIONINFOEX OSVERSIONINFOEXA +#define POSVERSIONINFO POSVERSIONINFOA +#define POSVERSIONINFOEX POSVERSIONINFOEXA +#define LPOSVERSIONINFO LPOSVERSIONINFOA +#define LPOSVERSIONINFOEX LPOSVERSIONINFOEXA +#endif + +#define VER_PLATFORM_WIN32_NT 0x00000002 + +#define VER_SUITE_BACKOFFICE 0x00000004 +#define VER_SUITE_BLADE 0x00000400 +#define VER_SUITE_COMPUTE_SERVER 0x00004000 +#define VER_SUITE_DATACENTER 0x00000080 +#define VER_SUITE_ENTERPRISE 0x00000002 +#define VER_SUITE_EMBEDDEDNT 0x00000040 +#define VER_SUITE_PERSONAL 0x00000200 +#define VER_SUITE_SINGLEUSERTS 0x00000100 +#define VER_SUITE_SMALLBUSINESS 0x00000001 +#define VER_SUITE_SMALLBUSINESS_RESTRICTED 0x00000020 +#define VER_SUITE_STORAGE_SERVER 0x00002000 +#define VER_SUITE_TERMINAL 0x00000010 +#define VER_SUITE_WH_SERVER 0x00008000 +#endif + +#define VER_NT_DOMAIN_CONTROLLER 0x0000002 +#define VER_NT_SERVER 0x0000003 +#define VER_NT_WORKSTATION 0x0000001 + + WINPR_API void GetSystemTime(LPSYSTEMTIME lpSystemTime); + WINPR_API BOOL SetSystemTime(CONST SYSTEMTIME* lpSystemTime); + WINPR_API VOID GetLocalTime(LPSYSTEMTIME lpSystemTime); + WINPR_API BOOL SetLocalTime(CONST SYSTEMTIME* lpSystemTime); + + WINPR_API VOID GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime); + WINPR_API BOOL GetSystemTimeAdjustment(PDWORD lpTimeAdjustment, PDWORD lpTimeIncrement, + PBOOL lpTimeAdjustmentDisabled); + + WINPR_API BOOL IsProcessorFeaturePresent(DWORD ProcessorFeature); + +#define PF_FLOATING_POINT_PRECISION_ERRATA 0 +#define PF_FLOATING_POINT_EMULATED 1 +#define PF_COMPARE_EXCHANGE_DOUBLE 2 +#define PF_MMX_INSTRUCTIONS_AVAILABLE 3 +#define PF_PPC_MOVEMEM_64BIT_OK 4 +#define PF_XMMI_INSTRUCTIONS_AVAILABLE 6 /* SSE */ +#define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7 +#define PF_RDTSC_INSTRUCTION_AVAILABLE 8 +#define PF_PAE_ENABLED 9 +#define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10 /* SSE2 */ +#define PF_SSE_DAZ_MODE_AVAILABLE 11 +#define PF_NX_ENABLED 12 +#define PF_SSE3_INSTRUCTIONS_AVAILABLE 13 +#define PF_COMPARE_EXCHANGE128 14 +#define PF_COMPARE64_EXCHANGE128 15 +#define PF_CHANNELS_ENABLED 16 +#define PF_XSAVE_ENABLED 17 +#define PF_ARM_VFP_32_REGISTERS_AVAILABLE 18 +#define PF_ARM_NEON_INSTRUCTIONS_AVAILABLE 19 +#define PF_SECOND_LEVEL_ADDRESS_TRANSLATION 20 +#define PF_VIRT_FIRMWARE_ENABLED 21 +#define PF_RDWRFSGSBASE_AVAILABLE 22 +#define PF_FASTFAIL_AVAILABLE 23 +#define PF_ARM_DIVIDE_INSTRUCTION_AVAILABLE 24 +#define PF_ARM_64BIT_LOADSTORE_ATOMIC 25 +#define PF_ARM_EXTERNAL_CACHE_AVAILABLE 26 +#define PF_ARM_FMAC_INSTRUCTIONS_AVAILABLE 27 + +#define PF_ARM_V4 0x80000001 +#define PF_ARM_V5 0x80000002 +#define PF_ARM_V6 0x80000003 +#define PF_ARM_V7 0x80000004 +#define PF_ARM_THUMB 0x80000005 +#define PF_ARM_JAZELLE 0x80000006 +#define PF_ARM_DSP 0x80000007 +#define PF_ARM_MOVE_CP 0x80000008 +#define PF_ARM_VFP10 0x80000009 +#define PF_ARM_MPU 0x8000000A +#define PF_ARM_WRITE_BUFFER 0x8000000B +#define PF_ARM_MBX 0x8000000C +#define PF_ARM_L2CACHE 0x8000000D +#define PF_ARM_PHYSICALLY_TAGGED_CACHE 0x8000000E +#define PF_ARM_VFP_SINGLE_PRECISION 0x8000000F +#define PF_ARM_VFP_DOUBLE_PRECISION 0x80000010 +#define PF_ARM_ITCM 0x80000011 +#define PF_ARM_DTCM 0x80000012 +#define PF_ARM_UNIFIED_CACHE 0x80000013 +#define PF_ARM_WRITE_BACK_CACHE 0x80000014 +#define PF_ARM_CACHE_CAN_BE_LOCKED_DOWN 0x80000015 +#define PF_ARM_L2CACHE_MEMORY_MAPPED 0x80000016 +#define PF_ARM_L2CACHE_COPROC 0x80000017 +#define PF_ARM_THUMB2 0x80000018 +#define PF_ARM_T2EE 0x80000019 +#define PF_ARM_VFP3 0x8000001A +#define PF_ARM_NEON 0x8000001B +#define PF_ARM_UNALIGNED_ACCESS 0x8000001C + +#define PF_ARM_INTEL_XSCALE 0x80010001 +#define PF_ARM_INTEL_PMU 0x80010002 +#define PF_ARM_INTEL_WMMX 0x80010003 + +#endif + +#if !defined(_WIN32) || defined(_UWP) + +#if defined(WITH_WINPR_DEPRECATED) + WINPR_API BOOL GetVersionExA(LPOSVERSIONINFOA lpVersionInformation); + WINPR_API BOOL GetVersionExW(LPOSVERSIONINFOW lpVersionInformation); + +#ifdef UNICODE +#define GetVersionEx GetVersionExW +#else +#define GetVersionEx GetVersionExA +#endif + +#endif +#endif + +#if !defined(_WIN32) || defined(_UWP) + + WINPR_API DWORD GetTickCount(void); + + typedef enum + { + ComputerNameNetBIOS, + ComputerNameDnsHostname, + ComputerNameDnsDomain, + ComputerNameDnsFullyQualified, + ComputerNamePhysicalNetBIOS, + ComputerNamePhysicalDnsHostname, + ComputerNamePhysicalDnsDomain, + ComputerNamePhysicalDnsFullyQualified, + ComputerNameMax + } COMPUTER_NAME_FORMAT; + +#define MAX_COMPUTERNAME_LENGTH 31 + + WINPR_API BOOL GetComputerNameA(LPSTR lpBuffer, LPDWORD lpnSize); + WINPR_API BOOL GetComputerNameW(LPWSTR lpBuffer, LPDWORD lpnSize); + + WINPR_API BOOL GetComputerNameExA(COMPUTER_NAME_FORMAT NameType, LPSTR lpBuffer, + LPDWORD lpnSize); + WINPR_API BOOL GetComputerNameExW(COMPUTER_NAME_FORMAT NameType, LPWSTR lpBuffer, + LPDWORD lpnSize); + +#ifdef UNICODE +#define GetComputerName GetComputerNameW +#define GetComputerNameEx GetComputerNameExW +#else +#define GetComputerName GetComputerNameA +#define GetComputerNameEx GetComputerNameExA +#endif + +#endif + +#if (!defined(_WIN32)) || (defined(_WIN32) && (_WIN32_WINNT < 0x0600)) + + WINPR_API ULONGLONG winpr_GetTickCount64(void); +#define GetTickCount64 winpr_GetTickCount64 + +#endif + + WINPR_API DWORD GetTickCountPrecise(void); + + WINPR_API BOOL IsProcessorFeaturePresentEx(DWORD ProcessorFeature); + +/* extended flags */ +#define PF_EX_LZCNT 1 +#define PF_EX_3DNOW_PREFETCH 2 +#define PF_EX_SSSE3 3 +#define PF_EX_SSE41 4 +#define PF_EX_SSE42 5 +#define PF_EX_AVX 6 +#define PF_EX_FMA 7 +#define PF_EX_AVX_AES 8 +#define PF_EX_AVX2 9 +#define PF_EX_ARM_VFP1 10 +#define PF_EX_ARM_VFP3D16 11 +#define PF_EX_ARM_VFP4 12 +#define PF_EX_ARM_IDIVA 13 +#define PF_EX_ARM_IDIVT 14 +#define PF_EX_AVX_PCLMULQDQ 15 +#define PF_EX_AVX512F 16 + +/* + * some "aliases" for the standard defines + * to be more clear + */ +#define PF_SSE_INSTRUCTIONS_AVAILABLE PF_XMMI_INSTRUCTIONS_AVAILABLE +#define PF_SSE2_INSTRUCTIONS_AVAILABLE PF_XMMI64_INSTRUCTIONS_AVAILABLE + +#ifdef __cplusplus +} +#endif + +#endif /* WINPR_SYSINFO_H */ diff --git a/winpr/include/winpr/tchar.h b/winpr/include/winpr/tchar.h new file mode 100644 index 0000000..5128352 --- /dev/null +++ b/winpr/include/winpr/tchar.h @@ -0,0 +1,70 @@ +/** + * WinPR: Windows Portable Runtime + * TCHAR + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_TCHAR_H +#define WINPR_TCHAR_H + +#include <winpr/crt.h> +#include <winpr/wtypes.h> + +#ifdef _WIN32 + +#include <tchar.h> + +#else + +#ifdef UNICODE +typedef WCHAR TCHAR; +#else +typedef CHAR TCHAR; +#endif + +#ifdef UNICODE +#define _tprintf wprintf +#define _sntprintf snwprintf +#define _tcslen _wcslen +#define _tcsdup _wcsdup +#define _tcscmp wcscmp +#define _tcsncmp wcsncmp +#define _tcscpy wcscpy +#define _tcscat wcscat +#define _tcschr wcschr +#define _tcsrchr wcsrchr +#define _tcsstr wcsstr +#define _stprintf_s swprintf_s +#define _tcsnccmp wcsncmp +#else +#define _tprintf printf +#define _sntprintf snprintf +#define _tcslen strlen +#define _tcsdup _strdup +#define _tcscmp strcmp +#define _tcsncmp strncmp +#define _tcscpy strcpy +#define _tcscat strcat +#define _tcschr strchr +#define _tcsrchr strrchr +#define _tcsstr strstr +#define _stprintf_s sprintf_s +#define _tcsnccmp strncmp +#endif + +#endif + +#endif /* WINPR_TCHAR_H */ diff --git a/winpr/include/winpr/thread.h b/winpr/include/winpr/thread.h new file mode 100644 index 0000000..2f17603 --- /dev/null +++ b/winpr/include/winpr/thread.h @@ -0,0 +1,257 @@ +/** + * WinPR: Windows Portable Runtime + * Process Thread Functions + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_THREAD_H +#define WINPR_THREAD_H + +#include <winpr/winpr.h> +#include <winpr/wtypes.h> + +#include <winpr/spec.h> +#include <winpr/handle.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + +#ifndef _WIN32 + + typedef struct + { + DWORD cb; + LPSTR lpReserved; + LPSTR lpDesktop; + LPSTR lpTitle; + DWORD dwX; + DWORD dwY; + DWORD dwXSize; + DWORD dwYSize; + DWORD dwXCountChars; + DWORD dwYCountChars; + DWORD dwFillAttribute; + DWORD dwFlags; + WORD wShowWindow; + WORD cbReserved2; + LPBYTE lpReserved2; + HANDLE hStdInput; + HANDLE hStdOutput; + HANDLE hStdError; + } STARTUPINFOA, *LPSTARTUPINFOA; + + typedef struct + { + DWORD cb; + LPWSTR lpReserved; + LPWSTR lpDesktop; + LPWSTR lpTitle; + DWORD dwX; + DWORD dwY; + DWORD dwXSize; + DWORD dwYSize; + DWORD dwXCountChars; + DWORD dwYCountChars; + DWORD dwFillAttribute; + DWORD dwFlags; + WORD wShowWindow; + WORD cbReserved2; + LPBYTE lpReserved2; + HANDLE hStdInput; + HANDLE hStdOutput; + HANDLE hStdError; + } STARTUPINFOW, *LPSTARTUPINFOW; + +#ifdef UNICODE + typedef STARTUPINFOW STARTUPINFO; + typedef LPSTARTUPINFOW LPSTARTUPINFO; +#else + typedef STARTUPINFOA STARTUPINFO; + typedef LPSTARTUPINFOA LPSTARTUPINFO; +#endif + +#define STARTF_USESHOWWINDOW 0x00000001 +#define STARTF_USESIZE 0x00000002 +#define STARTF_USEPOSITION 0x00000004 +#define STARTF_USECOUNTCHARS 0x00000008 +#define STARTF_USEFILLATTRIBUTE 0x00000010 +#define STARTF_RUNFULLSCREEN 0x00000020 +#define STARTF_FORCEONFEEDBACK 0x00000040 +#define STARTF_FORCEOFFFEEDBACK 0x00000080 +#define STARTF_USESTDHANDLES 0x00000100 +#define STARTF_USEHOTKEY 0x00000200 +#define STARTF_TITLEISLINKNAME 0x00000800 +#define STARTF_TITLEISAPPID 0x00001000 +#define STARTF_PREVENTPINNING 0x00002000 + + /* Process */ + +#define LOGON_WITH_PROFILE 0x00000001 +#define LOGON_NETCREDENTIALS_ONLY 0x00000002 +#define LOGON_ZERO_PASSWORD_BUFFER 0x80000000 + + WINPR_API BOOL CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, + LPSECURITY_ATTRIBUTES lpProcessAttributes, + LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, + DWORD dwCreationFlags, LPVOID lpEnvironment, + LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, + LPPROCESS_INFORMATION lpProcessInformation); + + WINPR_API BOOL CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, + LPSECURITY_ATTRIBUTES lpProcessAttributes, + LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, + DWORD dwCreationFlags, LPVOID lpEnvironment, + LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, + LPPROCESS_INFORMATION lpProcessInformation); + + WINPR_API BOOL CreateProcessAsUserA(HANDLE hToken, LPCSTR lpApplicationName, + LPSTR lpCommandLine, + LPSECURITY_ATTRIBUTES lpProcessAttributes, + LPSECURITY_ATTRIBUTES lpThreadAttributes, + BOOL bInheritHandles, DWORD dwCreationFlags, + LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, + LPSTARTUPINFOA lpStartupInfo, + LPPROCESS_INFORMATION lpProcessInformation); + + WINPR_API BOOL CreateProcessAsUserW(HANDLE hToken, LPCWSTR lpApplicationName, + LPWSTR lpCommandLine, + LPSECURITY_ATTRIBUTES lpProcessAttributes, + LPSECURITY_ATTRIBUTES lpThreadAttributes, + BOOL bInheritHandles, DWORD dwCreationFlags, + LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, + LPSTARTUPINFOW lpStartupInfo, + LPPROCESS_INFORMATION lpProcessInformation); + + WINPR_API BOOL CreateProcessWithLogonA(LPCSTR lpUsername, LPCSTR lpDomain, LPCSTR lpPassword, + DWORD dwLogonFlags, LPCSTR lpApplicationName, + LPSTR lpCommandLine, DWORD dwCreationFlags, + LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, + LPSTARTUPINFOA lpStartupInfo, + LPPROCESS_INFORMATION lpProcessInformation); + + WINPR_API BOOL CreateProcessWithLogonW(LPCWSTR lpUsername, LPCWSTR lpDomain, LPCWSTR lpPassword, + DWORD dwLogonFlags, LPCWSTR lpApplicationName, + LPWSTR lpCommandLine, DWORD dwCreationFlags, + LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, + LPSTARTUPINFOW lpStartupInfo, + LPPROCESS_INFORMATION lpProcessInformation); + + WINPR_API BOOL CreateProcessWithTokenA(HANDLE hToken, DWORD dwLogonFlags, + LPCSTR lpApplicationName, LPSTR lpCommandLine, + DWORD dwCreationFlags, LPVOID lpEnvironment, + LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, + LPPROCESS_INFORMATION lpProcessInformation); + + WINPR_API BOOL CreateProcessWithTokenW(HANDLE hToken, DWORD dwLogonFlags, + LPCWSTR lpApplicationName, LPWSTR lpCommandLine, + DWORD dwCreationFlags, LPVOID lpEnvironment, + LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, + LPPROCESS_INFORMATION lpProcessInformation); + +#ifdef UNICODE +#define CreateProcess CreateProcessW +#define CreateProcessAsUser CreateProcessAsUserW +#define CreateProcessWithLogon CreateProcessWithLogonW +#define CreateProcessWithToken CreateProcessWithTokenW +#else +#define CreateProcess CreateProcessA +#define CreateProcessAsUser CreateProcessAsUserA +#define CreateProcessWithLogon CreateProcessWithLogonA +#define CreateProcessWithToken CreateProcessWithTokenA +#endif + + DECLSPEC_NORETURN WINPR_API VOID ExitProcess(UINT uExitCode); + WINPR_API BOOL GetExitCodeProcess(HANDLE hProcess, LPDWORD lpExitCode); + + WINPR_API HANDLE _GetCurrentProcess(void); + WINPR_API DWORD GetCurrentProcessId(void); + + WINPR_API BOOL TerminateProcess(HANDLE hProcess, UINT uExitCode); + + /* Process Argument Vector Parsing */ + + WINPR_API LPWSTR* CommandLineToArgvW(LPCWSTR lpCmdLine, int* pNumArgs); + +#ifdef UNICODE +#define CommandLineToArgv CommandLineToArgvW +#else +#define CommandLineToArgv CommandLineToArgvA +#endif + + /* Thread */ + +#define CREATE_SUSPENDED 0x00000004 +#define STACK_SIZE_PARAM_IS_A_RESERVATION 0x00010000 + + WINPR_API HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, + LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, + DWORD dwCreationFlags, LPDWORD lpThreadId); + + WINPR_API HANDLE CreateRemoteThread(HANDLE hProcess, LPSECURITY_ATTRIBUTES lpThreadAttributes, + SIZE_T dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, + LPVOID lpParameter, DWORD dwCreationFlags, + LPDWORD lpThreadId); + + WINPR_API VOID ExitThread(DWORD dwExitCode); + WINPR_API BOOL GetExitCodeThread(HANDLE hThread, LPDWORD lpExitCode); + + WINPR_API HANDLE _GetCurrentThread(void); + WINPR_API DWORD GetCurrentThreadId(void); + + typedef void (*PAPCFUNC)(ULONG_PTR Parameter); + WINPR_API DWORD QueueUserAPC(PAPCFUNC pfnAPC, HANDLE hThread, ULONG_PTR dwData); + + WINPR_API DWORD ResumeThread(HANDLE hThread); + WINPR_API DWORD SuspendThread(HANDLE hThread); + WINPR_API BOOL SwitchToThread(void); + + WINPR_API BOOL TerminateThread(HANDLE hThread, DWORD dwExitCode); + + /* Processor */ + + WINPR_API DWORD GetCurrentProcessorNumber(void); + + /* Thread-Local Storage */ + +#define TLS_OUT_OF_INDEXES ((DWORD)0xFFFFFFFF) + + WINPR_API DWORD TlsAlloc(void); + WINPR_API LPVOID TlsGetValue(DWORD dwTlsIndex); + WINPR_API BOOL TlsSetValue(DWORD dwTlsIndex, LPVOID lpTlsValue); + WINPR_API BOOL TlsFree(DWORD dwTlsIndex); + +#else + +/* + * GetCurrentProcess / GetCurrentThread cause a conflict on Mac OS X + */ +#define _GetCurrentProcess GetCurrentProcess +#define _GetCurrentThread GetCurrentThread + +#endif + + /* CommandLineToArgvA is not present in the original Windows API, WinPR always exports it */ + + WINPR_API LPSTR* CommandLineToArgvA(LPCSTR lpCmdLine, int* pNumArgs); + WINPR_API VOID DumpThreadHandles(void); + +#ifdef __cplusplus +} +#endif + +#endif /* WINPR_THREAD_H */ diff --git a/winpr/include/winpr/timezone.h b/winpr/include/winpr/timezone.h new file mode 100644 index 0000000..d1c2f3e --- /dev/null +++ b/winpr/include/winpr/timezone.h @@ -0,0 +1,115 @@ +/** + * WinPR: Windows Portable Runtime + * Time Zone + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_TIMEZONE_H +#define WINPR_TIMEZONE_H + +#include <winpr/winpr.h> +#include <winpr/wtypes.h> + +#include <winpr/windows.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + +#ifndef _WIN32 + + typedef struct + { + LONG Bias; + WCHAR StandardName[32]; + SYSTEMTIME StandardDate; + LONG StandardBias; + WCHAR DaylightName[32]; + SYSTEMTIME DaylightDate; + LONG DaylightBias; + } TIME_ZONE_INFORMATION, *PTIME_ZONE_INFORMATION, *LPTIME_ZONE_INFORMATION; + + typedef struct + { + LONG Bias; + WCHAR StandardName[32]; + SYSTEMTIME StandardDate; + LONG StandardBias; + WCHAR DaylightName[32]; + SYSTEMTIME DaylightDate; + LONG DaylightBias; + WCHAR TimeZoneKeyName[128]; + BOOLEAN DynamicDaylightTimeDisabled; + } DYNAMIC_TIME_ZONE_INFORMATION, *PDYNAMIC_TIME_ZONE_INFORMATION, + *LPDYNAMIC_TIME_ZONE_INFORMATION; + + WINPR_API DWORD GetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation); + WINPR_API BOOL SetTimeZoneInformation(const TIME_ZONE_INFORMATION* lpTimeZoneInformation); + WINPR_API BOOL SystemTimeToFileTime(const SYSTEMTIME* lpSystemTime, LPFILETIME lpFileTime); + WINPR_API BOOL FileTimeToSystemTime(const FILETIME* lpFileTime, LPSYSTEMTIME lpSystemTime); + WINPR_API BOOL SystemTimeToTzSpecificLocalTime(LPTIME_ZONE_INFORMATION lpTimeZone, + LPSYSTEMTIME lpUniversalTime, + LPSYSTEMTIME lpLocalTime); + WINPR_API BOOL TzSpecificLocalTimeToSystemTime(LPTIME_ZONE_INFORMATION lpTimeZoneInformation, + LPSYSTEMTIME lpLocalTime, + LPSYSTEMTIME lpUniversalTime); + +#endif + +/* + * GetDynamicTimeZoneInformation is provided by the SDK if _WIN32_WINNT >= 0x0600 in SDKs above 7.1A + * and incorrectly if _WIN32_WINNT >= 0x0501 in older SDKs + */ +#if !defined(_WIN32) || \ + (defined(_WIN32) && (defined(NTDDI_WIN8) && _WIN32_WINNT < 0x0600 || \ + !defined(NTDDI_WIN8) && _WIN32_WINNT < 0x0501)) /* Windows Vista */ + + WINPR_API DWORD + GetDynamicTimeZoneInformation(PDYNAMIC_TIME_ZONE_INFORMATION pTimeZoneInformation); + WINPR_API BOOL + SetDynamicTimeZoneInformation(const DYNAMIC_TIME_ZONE_INFORMATION* lpTimeZoneInformation); + WINPR_API BOOL GetTimeZoneInformationForYear(USHORT wYear, PDYNAMIC_TIME_ZONE_INFORMATION pdtzi, + LPTIME_ZONE_INFORMATION ptzi); + +#endif + +#if !defined(_WIN32) || (defined(_WIN32) && (_WIN32_WINNT < 0x0601)) /* Windows 7 */ + + WINPR_API BOOL + SystemTimeToTzSpecificLocalTimeEx(const DYNAMIC_TIME_ZONE_INFORMATION* lpTimeZoneInformation, + const SYSTEMTIME* lpUniversalTime, LPSYSTEMTIME lpLocalTime); + WINPR_API BOOL + TzSpecificLocalTimeToSystemTimeEx(const DYNAMIC_TIME_ZONE_INFORMATION* lpTimeZoneInformation, + const SYSTEMTIME* lpLocalTime, LPSYSTEMTIME lpUniversalTime); + +#endif + +#if !defined(_WIN32) || (defined(_WIN32) && (_WIN32_WINNT < 0x0602)) /* Windows 8 */ + + WINPR_API DWORD EnumDynamicTimeZoneInformation( + const DWORD dwIndex, PDYNAMIC_TIME_ZONE_INFORMATION lpTimeZoneInformation); + WINPR_API DWORD GetDynamicTimeZoneInformationEffectiveYears( + const PDYNAMIC_TIME_ZONE_INFORMATION lpTimeZoneInformation, LPDWORD FirstYear, + LPDWORD LastYear); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* WINPR_TIMEZONE_H */ diff --git a/winpr/include/winpr/tools/makecert.h b/winpr/include/winpr/tools/makecert.h new file mode 100644 index 0000000..8a6d30f --- /dev/null +++ b/winpr/include/winpr/tools/makecert.h @@ -0,0 +1,50 @@ +/** + * WinPR: Windows Portable Runtime + * makecert replacement + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef MAKECERT_TOOL_H +#define MAKECERT_TOOL_H + +#include <winpr/winpr.h> +#include <winpr/wtypes.h> +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct S_MAKECERT_CONTEXT MAKECERT_CONTEXT; + + WINPR_API int makecert_context_process(MAKECERT_CONTEXT* context, int argc, char** argv); + + WINPR_API int makecert_context_set_output_file_name(MAKECERT_CONTEXT* context, + const char* name); + WINPR_API int makecert_context_output_certificate_file(MAKECERT_CONTEXT* context, + const char* path); + WINPR_API int makecert_context_output_private_key_file(MAKECERT_CONTEXT* context, + const char* path); + + WINPR_API void makecert_context_free(MAKECERT_CONTEXT* context); + + WINPR_ATTR_MALLOC(makecert_context_free, 1) + WINPR_API MAKECERT_CONTEXT* makecert_context_new(void); + +#ifdef __cplusplus +} +#endif + +#endif /* MAKECERT_TOOL_H */ diff --git a/winpr/include/winpr/user.h b/winpr/include/winpr/user.h new file mode 100644 index 0000000..d819f43 --- /dev/null +++ b/winpr/include/winpr/user.h @@ -0,0 +1,296 @@ +/** + * WinPR: Windows Portable Runtime + * User Environment + * + * Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_USER_H +#define WINPR_USER_H + +#include <winpr/wtypes.h> + +/** + * Standard Clipboard Formats + */ + +#ifndef _WIN32 + +#define MB_OK 0x00000000L +#define MB_OKCANCEL 0x00000001L +#define MB_ABORTRETRYIGNORE 0x00000002L +#define MB_YESNOCANCEL 0x00000003L +#define MB_YESNO 0x00000004L +#define MB_RETRYCANCEL 0x00000005L +#define MB_CANCELTRYCONTINUE 0x00000006L + +#define IDOK 1 +#define IDCANCEL 2 +#define IDABORT 3 +#define IDRETRY 4 +#define IDIGNORE 5 +#define IDYES 6 +#define IDNO 7 +#define IDTRYAGAIN 10 +#define IDCONTINUE 11 +#define IDTIMEOUT 32000 +#define IDASYNC 32001 + +#define CF_RAW 0 +#define CF_TEXT 1 +#define CF_BITMAP 2 +#define CF_METAFILEPICT 3 +#define CF_SYLK 4 +#define CF_DIF 5 +#define CF_TIFF 6 +#define CF_OEMTEXT 7 +#define CF_DIB 8 +#define CF_PALETTE 9 +#define CF_PENDATA 10 +#define CF_RIFF 11 +#define CF_WAVE 12 +#define CF_UNICODETEXT 13 +#define CF_ENHMETAFILE 14 +#define CF_HDROP 15 +#define CF_LOCALE 16 +#define CF_DIBV5 17 +#define CF_MAX 18 + +#define CF_OWNERDISPLAY 0x0080 +#define CF_DSPTEXT 0x0081 +#define CF_DSPBITMAP 0x0082 +#define CF_DSPMETAFILEPICT 0x0083 +#define CF_DSPENHMETAFILE 0x008E + +#define CF_PRIVATEFIRST 0x0200 +#define CF_PRIVATELAST 0x02FF + +#define CF_GDIOBJFIRST 0x0300 +#define CF_GDIOBJLAST 0x03FF + +/* Windows Metafile Picture Format */ + +#define MM_TEXT 1 +#define MM_LOMETRIC 2 +#define MM_HIMETRIC 3 +#define MM_LOENGLISH 4 +#define MM_HIENGLISH 5 +#define MM_TWIPS 6 +#define MM_ISOTROPIC 7 +#define MM_ANISOTROPIC 8 + +#define MM_MIN MM_TEXT +#define MM_MAX MM_ANISOTROPIC +#define MM_MAX_FIXEDSCALE MM_TWIPS + +#endif + +/** + * Bitmap Definitions + */ + +#if !defined(_WIN32) + +#pragma pack(push, 1) + +typedef LONG FXPT16DOT16, FAR *LPFXPT16DOT16; +typedef LONG FXPT2DOT30, FAR *LPFXPT2DOT30; + +typedef struct tagCIEXYZ +{ + FXPT2DOT30 ciexyzX; + FXPT2DOT30 ciexyzY; + FXPT2DOT30 ciexyzZ; +} CIEXYZ; + +typedef CIEXYZ FAR* LPCIEXYZ; + +typedef struct tagICEXYZTRIPLE +{ + CIEXYZ ciexyzRed; + CIEXYZ ciexyzGreen; + CIEXYZ ciexyzBlue; +} CIEXYZTRIPLE; + +typedef CIEXYZTRIPLE FAR* LPCIEXYZTRIPLE; + +typedef struct tagBITMAP +{ + LONG bmType; + LONG bmWidth; + LONG bmHeight; + LONG bmWidthBytes; + WORD bmPlanes; + WORD bmBitsPixel; + LPVOID bmBits; +} BITMAP, *PBITMAP, NEAR *NPBITMAP, FAR *LPBITMAP; + +typedef struct tagRGBTRIPLE +{ + BYTE rgbtBlue; + BYTE rgbtGreen; + BYTE rgbtRed; +} RGBTRIPLE, *PRGBTRIPLE, NEAR *NPRGBTRIPLE, FAR *LPRGBTRIPLE; + +typedef struct tagRGBQUAD +{ + BYTE rgbBlue; + BYTE rgbGreen; + BYTE rgbRed; + BYTE rgbReserved; +} RGBQUAD; + +typedef RGBQUAD FAR* LPRGBQUAD; + +#define BI_RGB 0 +#define BI_RLE8 1 +#define BI_RLE4 2 +#define BI_BITFIELDS 3 +#define BI_JPEG 4 +#define BI_PNG 5 + +#define PROFILE_LINKED 'LINK' +#define PROFILE_EMBEDDED 'MBED' + +typedef struct tagBITMAPINFOHEADER +{ + DWORD biSize; + LONG biWidth; + LONG biHeight; + WORD biPlanes; + WORD biBitCount; + DWORD biCompression; + DWORD biSizeImage; + LONG biXPelsPerMeter; + LONG biYPelsPerMeter; + DWORD biClrUsed; + DWORD biClrImportant; +} BITMAPINFOHEADER, FAR *LPBITMAPINFOHEADER, *PBITMAPINFOHEADER; + +typedef struct +{ + BITMAPINFOHEADER bmiHeader; + RGBQUAD bmiColors[1]; +} BITMAPINFO, FAR *LPBITMAPINFO, *PBITMAPINFO; + +typedef enum +{ + ORIENTATION_PREFERENCE_NONE = 0x0, + ORIENTATION_PREFERENCE_LANDSCAPE = 0x1, + + ORIENTATION_PREFERENCE_PORTRAIT = 0x2, + ORIENTATION_PREFERENCE_LANDSCAPE_FLIPPED = 0x4, + ORIENTATION_PREFERENCE_PORTRAIT_FLIPPED = 0x8 +} ORIENTATION_PREFERENCE; + +#pragma pack(pop) + +#endif + +#if !defined(_WIN32) || defined(_UWP) + +#pragma pack(push, 1) + +typedef struct tagBITMAPCOREHEADER +{ + DWORD bcSize; + WORD bcWidth; + WORD bcHeight; + WORD bcPlanes; + WORD bcBitCount; +} BITMAPCOREHEADER, FAR *LPBITMAPCOREHEADER, *PBITMAPCOREHEADER; + +typedef struct +{ + DWORD bV4Size; + LONG bV4Width; + LONG bV4Height; + WORD bV4Planes; + WORD bV4BitCount; + DWORD bV4V4Compression; + DWORD bV4SizeImage; + LONG bV4XPelsPerMeter; + LONG bV4YPelsPerMeter; + DWORD bV4ClrUsed; + DWORD bV4ClrImportant; + DWORD bV4RedMask; + DWORD bV4GreenMask; + DWORD bV4BlueMask; + DWORD bV4AlphaMask; + DWORD bV4CSType; + CIEXYZTRIPLE bV4Endpoints; + DWORD bV4GammaRed; + DWORD bV4GammaGreen; + DWORD bV4GammaBlue; +} BITMAPV4HEADER, FAR *LPBITMAPV4HEADER, *PBITMAPV4HEADER; + +typedef struct +{ + DWORD bV5Size; + LONG bV5Width; + LONG bV5Height; + WORD bV5Planes; + WORD bV5BitCount; + DWORD bV5Compression; + DWORD bV5SizeImage; + LONG bV5XPelsPerMeter; + LONG bV5YPelsPerMeter; + DWORD bV5ClrUsed; + DWORD bV5ClrImportant; + DWORD bV5RedMask; + DWORD bV5GreenMask; + DWORD bV5BlueMask; + DWORD bV5AlphaMask; + DWORD bV5CSType; + CIEXYZTRIPLE bV5Endpoints; + DWORD bV5GammaRed; + DWORD bV5GammaGreen; + DWORD bV5GammaBlue; + DWORD bV5Intent; + DWORD bV5ProfileData; + DWORD bV5ProfileSize; + DWORD bV5Reserved; +} BITMAPV5HEADER, FAR *LPBITMAPV5HEADER, *PBITMAPV5HEADER; + +typedef struct tagBITMAPCOREINFO +{ + BITMAPCOREHEADER bmciHeader; + RGBTRIPLE bmciColors[1]; +} BITMAPCOREINFO, FAR *LPBITMAPCOREINFO, *PBITMAPCOREINFO; + +typedef struct tagBITMAPFILEHEADER +{ + WORD bfType; + DWORD bfSize; + WORD bfReserved1; + WORD bfReserved2; + DWORD bfOffBits; +} BITMAPFILEHEADER, FAR *LPBITMAPFILEHEADER, *PBITMAPFILEHEADER; + +#pragma pack(pop) + +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* WINPR_USER_H */ diff --git a/winpr/include/winpr/wincrypt.h b/winpr/include/winpr/wincrypt.h new file mode 100644 index 0000000..cda3131 --- /dev/null +++ b/winpr/include/winpr/wincrypt.h @@ -0,0 +1,738 @@ +/** + * WinPR: Windows Portable Runtime + * Cryptography API (CryptoAPI) + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_WINCRYPT_H +#define WINPR_WINCRYPT_H + +#include <winpr/winpr.h> +#include <winpr/wtypes.h> + +#include <winpr/error.h> + +#ifdef _WIN32 + +#include <wincrypt.h> + +#endif + +#ifndef ALG_TYPE_RESERVED7 +#define ALG_TYPE_RESERVED7 (7 << 9) +#endif + +#if !defined(NTDDI_VERSION) || (NTDDI_VERSION <= 0x05010200) +#define ALG_SID_SHA_256 12 +#define ALG_SID_SHA_384 13 +#define ALG_SID_SHA_512 14 +#define CALG_SHA_256 (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_256) +#define CALG_SHA_384 (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_384) +#define CALG_SHA_512 (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_512) +#endif + +#ifndef _WIN32 + +/* ncrypt.h */ + +typedef ULONG_PTR NCRYPT_HANDLE; +typedef ULONG_PTR NCRYPT_PROV_HANDLE; +typedef ULONG_PTR NCRYPT_KEY_HANDLE; +typedef ULONG_PTR NCRYPT_HASH_HANDLE; +typedef ULONG_PTR NCRYPT_SECRET_HANDLE; + +/* wincrypt.h */ + +#define GET_ALG_CLASS(x) (x & (7 << 13)) +#define GET_ALG_TYPE(x) (x & (15 << 9)) +#define GET_ALG_SID(x) (x & (511)) + +#define ALG_CLASS_ANY (0) +#define ALG_CLASS_SIGNATURE (1 << 13) +#define ALG_CLASS_MSG_ENCRYPT (2 << 13) +#define ALG_CLASS_DATA_ENCRYPT (3 << 13) +#define ALG_CLASS_HASH (4 << 13) +#define ALG_CLASS_KEY_EXCHANGE (5 << 13) +#define ALG_CLASS_ALL (7 << 13) + +#define ALG_TYPE_ANY (0) +#define ALG_TYPE_DSS (1 << 9) +#define ALG_TYPE_RSA (2 << 9) +#define ALG_TYPE_BLOCK (3 << 9) +#define ALG_TYPE_STREAM (4 << 9) +#define ALG_TYPE_DH (5 << 9) +#define ALG_TYPE_SECURECHANNEL (6 << 9) + +#define ALG_SID_ANY (0) + +#define ALG_SID_RSA_ANY 0 +#define ALG_SID_RSA_PKCS 1 +#define ALG_SID_RSA_MSATWORK 2 +#define ALG_SID_RSA_ENTRUST 3 +#define ALG_SID_RSA_PGP 4 + +#define ALG_SID_DSS_ANY 0 +#define ALG_SID_DSS_PKCS 1 +#define ALG_SID_DSS_DMS 2 + +#define ALG_SID_DES 1 +#define ALG_SID_3DES 3 +#define ALG_SID_DESX 4 +#define ALG_SID_IDEA 5 +#define ALG_SID_CAST 6 +#define ALG_SID_SAFERSK64 7 +#define ALG_SID_SAFERSK128 8 +#define ALG_SID_3DES_112 9 +#define ALG_SID_CYLINK_MEK 12 +#define ALG_SID_RC5 13 + +#define ALG_SID_AES_128 14 +#define ALG_SID_AES_192 15 +#define ALG_SID_AES_256 16 +#define ALG_SID_AES 17 + +#define ALG_SID_SKIPJACK 10 +#define ALG_SID_TEK 11 + +#define CRYPT_MODE_CBCI 6 +#define CRYPT_MODE_CFBP 7 +#define CRYPT_MODE_OFBP 8 +#define CRYPT_MODE_CBCOFM 9 +#define CRYPT_MODE_CBCOFMI 10 + +#define ALG_SID_RC2 2 + +#define ALG_SID_RC4 1 +#define ALG_SID_SEAL 2 + +#define ALG_SID_DH_SANDF 1 +#define ALG_SID_DH_EPHEM 2 +#define ALG_SID_AGREED_KEY_ANY 3 +#define ALG_SID_KEA 4 + +#define ALG_SID_ECDH 5 + +#define ALG_SID_MD2 1 +#define ALG_SID_MD4 2 +#define ALG_SID_MD5 3 +#define ALG_SID_SHA 4 +#define ALG_SID_SHA1 4 +#define ALG_SID_MAC 5 +#define ALG_SID_RIPEMD 6 +#define ALG_SID_RIPEMD160 7 +#define ALG_SID_SSL3SHAMD5 8 +#define ALG_SID_HMAC 9 +#define ALG_SID_TLS1PRF 10 + +#define ALG_SID_HASH_REPLACE_OWF 11 + +#define ALG_SID_SHA_256 12 +#define ALG_SID_SHA_384 13 +#define ALG_SID_SHA_512 14 + +#define ALG_SID_SSL3_MASTER 1 +#define ALG_SID_SCHANNEL_MASTER_HASH 2 +#define ALG_SID_SCHANNEL_MAC_KEY 3 +#define ALG_SID_PCT1_MASTER 4 +#define ALG_SID_SSL2_MASTER 5 +#define ALG_SID_TLS1_MASTER 6 +#define ALG_SID_SCHANNEL_ENC_KEY 7 + +#define ALG_SID_ECMQV 1 + +#define CALG_MD2 (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MD2) +#define CALG_MD4 (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MD4) +#define CALG_MD5 (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MD5) +#define CALG_SHA (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA) +#define CALG_SHA1 (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA1) +#define CALG_MAC (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_MAC) +#define CALG_RSA_SIGN (ALG_CLASS_SIGNATURE | ALG_TYPE_RSA | ALG_SID_RSA_ANY) +#define CALG_DSS_SIGN (ALG_CLASS_SIGNATURE | ALG_TYPE_DSS | ALG_SID_DSS_ANY) + +#define CALG_NO_SIGN (ALG_CLASS_SIGNATURE | ALG_TYPE_ANY | ALG_SID_ANY) + +#define CALG_RSA_KEYX (ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_RSA | ALG_SID_RSA_ANY) +#define CALG_DES (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_DES) +#define CALG_3DES_112 (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_3DES_112) +#define CALG_3DES (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_3DES) +#define CALG_DESX (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_DESX) +#define CALG_RC2 (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_RC2) +#define CALG_RC4 (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_STREAM | ALG_SID_RC4) +#define CALG_SEAL (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_STREAM | ALG_SID_SEAL) +#define CALG_DH_SF (ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_DH | ALG_SID_DH_SANDF) +#define CALG_DH_EPHEM (ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_DH | ALG_SID_DH_EPHEM) +#define CALG_AGREEDKEY_ANY (ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_DH | ALG_SID_AGREED_KEY_ANY) +#define CALG_KEA_KEYX (ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_DH | ALG_SID_KEA) +#define CALG_HUGHES_MD5 (ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_ANY | ALG_SID_MD5) +#define CALG_SKIPJACK (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_SKIPJACK) +#define CALG_TEK (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_TEK) +#define CALG_CYLINK_MEK (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_CYLINK_MEK) +#define CALG_SSL3_SHAMD5 (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SSL3SHAMD5) +#define CALG_SSL3_MASTER (ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL | ALG_SID_SSL3_MASTER) +#define CALG_SCHANNEL_MASTER_HASH \ + (ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL | ALG_SID_SCHANNEL_MASTER_HASH) +#define CALG_SCHANNEL_MAC_KEY \ + (ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL | ALG_SID_SCHANNEL_MAC_KEY) +#define CALG_SCHANNEL_ENC_KEY \ + (ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL | ALG_SID_SCHANNEL_ENC_KEY) +#define CALG_PCT1_MASTER (ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL | ALG_SID_PCT1_MASTER) +#define CALG_SSL2_MASTER (ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL | ALG_SID_SSL2_MASTER) +#define CALG_TLS1_MASTER (ALG_CLASS_MSG_ENCRYPT | ALG_TYPE_SECURECHANNEL | ALG_SID_TLS1_MASTER) +#define CALG_RC5 (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_RC5) +#define CALG_HMAC (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_HMAC) +#define CALG_TLS1PRF (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_TLS1PRF) + +#define CALG_HASH_REPLACE_OWF (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_HASH_REPLACE_OWF) +#define CALG_AES_128 (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_AES_128) +#define CALG_AES_192 (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_AES_192) +#define CALG_AES_256 (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_AES_256) +#define CALG_AES (ALG_CLASS_DATA_ENCRYPT | ALG_TYPE_BLOCK | ALG_SID_AES) + +#define CALG_SHA_256 (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_256) +#define CALG_SHA_384 (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_384) +#define CALG_SHA_512 (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_512) + +#define CALG_ECDH (ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_DH | ALG_SID_ECDH) +#define CALG_ECMQV (ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_ANY | ALG_SID_ECMQV) + +typedef struct +{ + DWORD cbData; + BYTE* pbData; +} CRYPT_INTEGER_BLOB, *PCRYPT_INTEGER_BLOB, CRYPT_UINT_BLOB, *PCRYPT_UINT_BLOB, CRYPT_OBJID_BLOB, + *PCRYPT_OBJID_BLOB, CERT_NAME_BLOB, *PCERT_NAME_BLOB, CERT_RDN_VALUE_BLOB, + *PCERT_RDN_VALUE_BLOB, CERT_BLOB, *PCERT_BLOB, CRL_BLOB, *PCRL_BLOB, DATA_BLOB, *PDATA_BLOB, + CRYPT_DATA_BLOB, *PCRYPT_DATA_BLOB, CRYPT_HASH_BLOB, *PCRYPT_HASH_BLOB, CRYPT_DIGEST_BLOB, + *PCRYPT_DIGEST_BLOB, CRYPT_DER_BLOB, *PCRYPT_DER_BLOB, CRYPT_ATTR_BLOB, *PCRYPT_ATTR_BLOB; + +typedef struct +{ + LPSTR pszObjId; + CRYPT_OBJID_BLOB Parameters; +} CRYPT_ALGORITHM_IDENTIFIER, *PCRYPT_ALGORITHM_IDENTIFIER; + +typedef struct +{ + DWORD cbData; + BYTE* pbData; + DWORD cUnusedBits; +} CRYPT_BIT_BLOB, *PCRYPT_BIT_BLOB; + +typedef struct +{ + CRYPT_ALGORITHM_IDENTIFIER Algorithm; + CRYPT_BIT_BLOB PublicKey; +} CERT_PUBLIC_KEY_INFO, *PCERT_PUBLIC_KEY_INFO; + +typedef struct +{ + LPSTR pszObjId; + BOOL fCritical; + CRYPT_OBJID_BLOB Value; +} CERT_EXTENSION, *PCERT_EXTENSION; +typedef const CERT_EXTENSION* PCCERT_EXTENSION; + +typedef struct +{ + DWORD dwVersion; + CRYPT_INTEGER_BLOB SerialNumber; + CRYPT_ALGORITHM_IDENTIFIER SignatureAlgorithm; + CERT_NAME_BLOB Issuer; + FILETIME NotBefore; + FILETIME NotAfter; + CERT_NAME_BLOB Subject; + CERT_PUBLIC_KEY_INFO SubjectPublicKeyInfo; + CRYPT_BIT_BLOB IssuerUniqueId; + CRYPT_BIT_BLOB SubjectUniqueId; + DWORD cExtension; + PCERT_EXTENSION rgExtension; +} CERT_INFO, *PCERT_INFO; + +typedef void* HCERTSTORE; +typedef ULONG_PTR HCRYPTPROV; +typedef ULONG_PTR HCRYPTPROV_LEGACY; + +typedef struct +{ + DWORD dwCertEncodingType; + BYTE* pbCertEncoded; + DWORD cbCertEncoded; + PCERT_INFO pCertInfo; + HCERTSTORE hCertStore; +} CERT_CONTEXT, *PCERT_CONTEXT; +typedef const CERT_CONTEXT* PCCERT_CONTEXT; + +#if !defined(AT_KEYEXCHANGE) +#define AT_KEYEXCHANGE (1) +#endif +#if !defined(AT_SIGNATURE) +#define AT_SIGNATURE (2) +#endif +#if !defined(AT_AUTHENTICATE) +#define AT_AUTHENTICATE (3) +#endif + +#define CERT_ENCODING_TYPE_MASK 0x0000FFFF +#define CMSG_ENCODING_TYPE_MASK 0xFFFF0000 +#define GET_CERT_ENCODING_TYPE(x) (x & CERT_ENCODING_TYPE_MASK) +#define GET_CMSG_ENCODING_TYPE(x) (x & CMSG_ENCODING_TYPE_MASK) + +#define CRYPT_ASN_ENCODING 0x00000001 +#define CRYPT_NDR_ENCODING 0x00000002 +#define X509_ASN_ENCODING 0x00000001 +#define X509_NDR_ENCODING 0x00000002 +#define PKCS_7_ASN_ENCODING 0x00010000 +#define PKCS_7_NDR_ENCODING 0x00020000 + +#define CERT_KEY_PROV_HANDLE_PROP_ID 1 +#define CERT_KEY_PROV_INFO_PROP_ID 2 +#define CERT_SHA1_HASH_PROP_ID 3 +#define CERT_MD5_HASH_PROP_ID 4 +#define CERT_HASH_PROP_ID CERT_SHA1_HASH_PROP_ID +#define CERT_KEY_CONTEXT_PROP_ID 5 +#define CERT_KEY_SPEC_PROP_ID 6 +#define CERT_IE30_RESERVED_PROP_ID 7 +#define CERT_PUBKEY_HASH_RESERVED_PROP_ID 8 +#define CERT_ENHKEY_USAGE_PROP_ID 9 +#define CERT_CTL_USAGE_PROP_ID CERT_ENHKEY_USAGE_PROP_ID +#define CERT_NEXT_UPDATE_LOCATION_PROP_ID 10 +#define CERT_FRIENDLY_NAME_PROP_ID 11 +#define CERT_PVK_FILE_PROP_ID 12 +#define CERT_DESCRIPTION_PROP_ID 13 +#define CERT_ACCESS_STATE_PROP_ID 14 +#define CERT_SIGNATURE_HASH_PROP_ID 15 +#define CERT_SMART_CARD_DATA_PROP_ID 16 +#define CERT_EFS_PROP_ID 17 +#define CERT_FORTEZZA_DATA_PROP_ID 18 +#define CERT_ARCHIVED_PROP_ID 19 +#define CERT_KEY_IDENTIFIER_PROP_ID 20 +#define CERT_AUTO_ENROLL_PROP_ID 21 +#define CERT_PUBKEY_ALG_PARA_PROP_ID 22 +#define CERT_CROSS_CERT_DIST_POINTS_PROP_ID 23 +#define CERT_ISSUER_PUBLIC_KEY_MD5_HASH_PROP_ID 24 +#define CERT_SUBJECT_PUBLIC_KEY_MD5_HASH_PROP_ID 25 +#define CERT_ENROLLMENT_PROP_ID 26 +#define CERT_DATE_STAMP_PROP_ID 27 +#define CERT_ISSUER_SERIAL_NUMBER_MD5_HASH_PROP_ID 28 +#define CERT_SUBJECT_NAME_MD5_HASH_PROP_ID 29 +#define CERT_EXTENDED_ERROR_INFO_PROP_ID 30 +#define CERT_RENEWAL_PROP_ID 64 +#define CERT_ARCHIVED_KEY_HASH_PROP_ID 65 +#define CERT_AUTO_ENROLL_RETRY_PROP_ID 66 +#define CERT_AIA_URL_RETRIEVED_PROP_ID 67 +#define CERT_AUTHORITY_INFO_ACCESS_PROP_ID 68 +#define CERT_BACKED_UP_PROP_ID 69 +#define CERT_OCSP_RESPONSE_PROP_ID 70 +#define CERT_REQUEST_ORIGINATOR_PROP_ID 71 +#define CERT_SOURCE_LOCATION_PROP_ID 72 +#define CERT_SOURCE_URL_PROP_ID 73 +#define CERT_NEW_KEY_PROP_ID 74 +#define CERT_OCSP_CACHE_PREFIX_PROP_ID 75 +#define CERT_SMART_CARD_ROOT_INFO_PROP_ID 76 +#define CERT_NO_AUTO_EXPIRE_CHECK_PROP_ID 77 +#define CERT_NCRYPT_KEY_HANDLE_PROP_ID 78 +#define CERT_HCRYPTPROV_OR_NCRYPT_KEY_HANDLE_PROP_ID 79 +#define CERT_SUBJECT_INFO_ACCESS_PROP_ID 80 +#define CERT_CA_OCSP_AUTHORITY_INFO_ACCESS_PROP_ID 81 +#define CERT_CA_DISABLE_CRL_PROP_ID 82 +#define CERT_ROOT_PROGRAM_CERT_POLICIES_PROP_ID 83 +#define CERT_ROOT_PROGRAM_NAME_CONSTRAINTS_PROP_ID 84 +#define CERT_SUBJECT_OCSP_AUTHORITY_INFO_ACCESS_PROP_ID 85 +#define CERT_SUBJECT_DISABLE_CRL_PROP_ID 86 +#define CERT_CEP_PROP_ID 87 +#define CERT_SIGN_HASH_CNG_ALG_PROP_ID 89 +#define CERT_SCARD_PIN_ID_PROP_ID 90 +#define CERT_SCARD_PIN_INFO_PROP_ID 91 +#define CERT_SUBJECT_PUB_KEY_BIT_LENGTH_PROP_ID 92 +#define CERT_PUB_KEY_CNG_ALG_BIT_LENGTH_PROP_ID 93 +#define CERT_ISSUER_PUB_KEY_BIT_LENGTH_PROP_ID 94 +#define CERT_ISSUER_CHAIN_SIGN_HASH_CNG_ALG_PROP_ID 95 +#define CERT_ISSUER_CHAIN_PUB_KEY_CNG_ALG_BIT_LENGTH_PROP_ID 96 +#define CERT_NO_EXPIRE_NOTIFICATION_PROP_ID 97 +#define CERT_AUTH_ROOT_SHA256_HASH_PROP_ID 98 +#define CERT_NCRYPT_KEY_HANDLE_TRANSFER_PROP_ID 99 +#define CERT_HCRYPTPROV_TRANSFER_PROP_ID 100 +#define CERT_SMART_CARD_READER_PROP_ID 101 +#define CERT_SEND_AS_TRUSTED_ISSUER_PROP_ID 102 +#define CERT_KEY_REPAIR_ATTEMPTED_PROP_ID 103 +#define CERT_DISALLOWED_FILETIME_PROP_ID 104 +#define CERT_ROOT_PROGRAM_CHAIN_POLICIES_PROP_ID 105 +#define CERT_SMART_CARD_READER_NON_REMOVABLE_PROP_ID 106 +#define CERT_SHA256_HASH_PROP_ID 107 +#define CERT_SCEP_SERVER_CERTS_PROP_ID 108 +#define CERT_SCEP_RA_SIGNATURE_CERT_PROP_ID 109 +#define CERT_SCEP_RA_ENCRYPTION_CERT_PROP_ID 110 +#define CERT_SCEP_CA_CERT_PROP_ID 111 +#define CERT_SCEP_SIGNER_CERT_PROP_ID 112 +#define CERT_SCEP_NONCE_PROP_ID 113 +#define CERT_SCEP_ENCRYPT_HASH_CNG_ALG_PROP_ID 114 +#define CERT_SCEP_FLAGS_PROP_ID 115 +#define CERT_SCEP_GUID_PROP_ID 116 +#define CERT_SERIALIZABLE_KEY_CONTEXT_PROP_ID 117 +#define CERT_ISOLATED_KEY_PROP_ID 118 +#define CERT_SERIAL_CHAIN_PROP_ID 119 +#define CERT_KEY_CLASSIFICATION_PROP_ID 120 +#define CERT_OCSP_MUST_STAPLE_PROP_ID 121 +#define CERT_DISALLOWED_ENHKEY_USAGE_PROP_ID 122 +#define CERT_NONCOMPLIANT_ROOT_URL_PROP_ID 123 +#define CERT_PIN_SHA256_HASH_PROP_ID 124 +#define CERT_CLR_DELETE_KEY_PROP_ID 125 +#define CERT_NOT_BEFORE_FILETIME_PROP_ID 126 +#define CERT_NOT_BEFORE_ENHKEY_USAGE_PROP_ID 127 + +#define CERT_FIRST_RESERVED_PROP_ID 107 +#define CERT_LAST_RESERVED_PROP_ID 0x00007fff +#define CERT_FIRST_USER_PROP_ID 0x8000 +#define CERT_LAST_USER_PROP_ID 0x0000ffff + +#define CERT_COMPARE_MASK 0xFFFF +#define CERT_COMPARE_SHIFT 16 +#define CERT_COMPARE_ANY 0 +#define CERT_COMPARE_SHA1_HASH 1 +#define CERT_COMPARE_NAME 2 +#define CERT_COMPARE_ATTR 3 +#define CERT_COMPARE_MD5_HASH 4 +#define CERT_COMPARE_PROPERTY 5 +#define CERT_COMPARE_PUBLIC_KEY 6 +#define CERT_COMPARE_HASH CERT_COMPARE_SHA1_HASH +#define CERT_COMPARE_NAME_STR_A 7 +#define CERT_COMPARE_NAME_STR_W 8 +#define CERT_COMPARE_KEY_SPEC 9 +#define CERT_COMPARE_ENHKEY_USAGE 10 +#define CERT_COMPARE_CTL_USAGE CERT_COMPARE_ENHKEY_USAGE +#define CERT_COMPARE_SUBJECT_CERT 11 +#define CERT_COMPARE_ISSUER_OF 12 +#define CERT_COMPARE_EXISTING 13 +#define CERT_COMPARE_SIGNATURE_HASH 14 +#define CERT_COMPARE_KEY_IDENTIFIER 15 +#define CERT_COMPARE_CERT_ID 16 +#define CERT_COMPARE_CROSS_CERT_DIST_POINTS 17 +#define CERT_COMPARE_PUBKEY_MD5_HASH 18 +#define CERT_COMPARE_SUBJECT_INFO_ACCESS 19 +#define CERT_COMPARE_HASH_STR 20 +#define CERT_COMPARE_HAS_PRIVATE_KEY 21 + +#define CERT_FIND_ANY (CERT_COMPARE_ANY << CERT_COMPARE_SHIFT) +#define CERT_FIND_SHA1_HASH (CERT_COMPARE_SHA1_HASH << CERT_COMPARE_SHIFT) +#define CERT_FIND_MD5_HASH (CERT_COMPARE_MD5_HASH << CERT_COMPARE_SHIFT) +#define CERT_FIND_SIGNATURE_HASH (CERT_COMPARE_SIGNATURE_HASH << CERT_COMPARE_SHIFT) +#define CERT_FIND_KEY_IDENTIFIER (CERT_COMPARE_KEY_IDENTIFIER << CERT_COMPARE_SHIFT) +#define CERT_FIND_HASH CERT_FIND_SHA1_HASH +#define CERT_FIND_PROPERTY (CERT_COMPARE_PROPERTY << CERT_COMPARE_SHIFT) +#define CERT_FIND_PUBLIC_KEY (CERT_COMPARE_PUBLIC_KEY << CERT_COMPARE_SHIFT) +#define CERT_FIND_SUBJECT_NAME (CERT_COMPARE_NAME << CERT_COMPARE_SHIFT | CERT_INFO_SUBJECT_FLAG) +#define CERT_FIND_SUBJECT_ATTR (CERT_COMPARE_ATTR << CERT_COMPARE_SHIFT | CERT_INFO_SUBJECT_FLAG) +#define CERT_FIND_ISSUER_NAME (CERT_COMPARE_NAME << CERT_COMPARE_SHIFT | CERT_INFO_ISSUER_FLAG) +#define CERT_FIND_ISSUER_ATTR (CERT_COMPARE_ATTR << CERT_COMPARE_SHIFT | CERT_INFO_ISSUER_FLAG) +#define CERT_FIND_SUBJECT_STR_A \ + (CERT_COMPARE_NAME_STR_A << CERT_COMPARE_SHIFT | CERT_INFO_SUBJECT_FLAG) +#define CERT_FIND_SUBJECT_STR_W \ + (CERT_COMPARE_NAME_STR_W << CERT_COMPARE_SHIFT | CERT_INFO_SUBJECT_FLAG) +#define CERT_FIND_SUBJECT_STR CERT_FIND_SUBJECT_STR_W +#define CERT_FIND_ISSUER_STR_A \ + (CERT_COMPARE_NAME_STR_A << CERT_COMPARE_SHIFT | CERT_INFO_ISSUER_FLAG) +#define CERT_FIND_ISSUER_STR_W \ + (CERT_COMPARE_NAME_STR_W << CERT_COMPARE_SHIFT | CERT_INFO_ISSUER_FLAG) +#define CERT_FIND_ISSUER_STR CERT_FIND_ISSUER_STR_W +#define CERT_FIND_KEY_SPEC (CERT_COMPARE_KEY_SPEC << CERT_COMPARE_SHIFT) +#define CERT_FIND_ENHKEY_USAGE (CERT_COMPARE_ENHKEY_USAGE << CERT_COMPARE_SHIFT) +#define CERT_FIND_CTL_USAGE CERT_FIND_ENHKEY_USAGE +#define CERT_FIND_SUBJECT_CERT (CERT_COMPARE_SUBJECT_CERT << CERT_COMPARE_SHIFT) +#define CERT_FIND_ISSUER_OF (CERT_COMPARE_ISSUER_OF << CERT_COMPARE_SHIFT) +#define CERT_FIND_EXISTING (CERT_COMPARE_EXISTING << CERT_COMPARE_SHIFT) +#define CERT_FIND_CERT_ID (CERT_COMPARE_CERT_ID << CERT_COMPARE_SHIFT) +#define CERT_FIND_CROSS_CERT_DIST_POINTS (CERT_COMPARE_CROSS_CERT_DIST_POINTS << CERT_COMPARE_SHIFT) +#define CERT_FIND_PUBKEY_MD5_HASH (CERT_COMPARE_PUBKEY_MD5_HASH << CERT_COMPARE_SHIFT) +#define CERT_FIND_SUBJECT_INFO_ACCESS (CERT_COMPARE_SUBJECT_INFO_ACCESS << CERT_COMPARE_SHIFT) +#define CERT_FIND_HASH_STR (CERT_COMPARE_HASH_STR << CERT_COMPARE_SHIFT) +#define CERT_FIND_HAS_PRIVATE_KEY (CERT_COMPARE_HAS_PRIVATE_KEY << CERT_COMPARE_SHIFT) + +#define CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG 0x1 +#define CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG 0x2 +#define CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG 0x4 +#define CERT_FIND_NO_ENHKEY_USAGE_FLAG 0x8 +#define CERT_FIND_OR_ENHKEY_USAGE_FLAG 0x10 +#define CERT_FIND_VALID_ENHKEY_USAGE_FLAG 0x20 +#define CERT_FIND_OPTIONAL_CTL_USAGE_FLAG CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG +#define CERT_FIND_EXT_ONLY_CTL_USAGE_FLAG CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG +#define CERT_FIND_PROP_ONLY_CTL_USAGE_FLAG CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG +#define CERT_FIND_NO_CTL_USAGE_FLAG CERT_FIND_NO_ENHKEY_USAGE_FLAG +#define CERT_FIND_OR_CTL_USAGE_FLAG CERT_FIND_OR_ENHKEY_USAGE_FLAG +#define CERT_FIND_VALID_CTL_USAGE_FLAG CERT_FIND_VALID_ENHKEY_USAGE_FLAG + +#define CERT_NAME_EMAIL_TYPE 1 +#define CERT_NAME_RDN_TYPE 2 +#define CERT_NAME_ATTR_TYPE 3 +#define CERT_NAME_SIMPLE_DISPLAY_TYPE 4 +#define CERT_NAME_FRIENDLY_DISPLAY_TYPE 5 +#define CERT_NAME_DNS_TYPE 6 +#define CERT_NAME_URL_TYPE 7 +#define CERT_NAME_UPN_TYPE 8 + +#define CERT_NAME_ISSUER_FLAG 0x1 +#define CERT_NAME_DISABLE_IE4_UTF8_FLAG 0x00010000 + +#define CERT_NAME_SEARCH_ALL_NAMES_FLAG 0x2 + +#define CERT_STORE_PROV_MSG ((LPCSTR)1) +#define CERT_STORE_PROV_MEMORY ((LPCSTR)2) +#define CERT_STORE_PROV_FILE ((LPCSTR)3) +#define CERT_STORE_PROV_REG ((LPCSTR)4) +#define CERT_STORE_PROV_PKCS7 ((LPCSTR)5) +#define CERT_STORE_PROV_SERIALIZED ((LPCSTR)6) +#define CERT_STORE_PROV_FILENAME_A ((LPCSTR)7) +#define CERT_STORE_PROV_FILENAME_W ((LPCSTR)8) +#define CERT_STORE_PROV_FILENAME CERT_STORE_PROV_FILENAME_W +#define CERT_STORE_PROV_SYSTEM_A ((LPCSTR)9) +#define CERT_STORE_PROV_SYSTEM_W ((LPCSTR)10) +#define CERT_STORE_PROV_SYSTEM CERT_STORE_PROV_SYSTEM_W +#define CERT_STORE_PROV_COLLECTION ((LPCSTR)11) +#define CERT_STORE_PROV_SYSTEM_REGISTRY_A ((LPCSTR)12) +#define CERT_STORE_PROV_SYSTEM_REGISTRY_W ((LPCSTR)13) +#define CERT_STORE_PROV_SYSTEM_REGISTRY CERT_STORE_PROV_SYSTEM_REGISTRY_W +#define CERT_STORE_PROV_PHYSICAL_W ((LPCSTR)14) +#define CERT_STORE_PROV_PHYSICAL CERT_STORE_PROV_PHYSICAL_W +#define CERT_STORE_PROV_SMART_CARD_W ((LPCSTR)15) +#define CERT_STORE_PROV_SMART_CARD CERT_STORE_PROV_SMART_CARD_W +#define CERT_STORE_PROV_LDAP_W ((LPCSTR)16) +#define CERT_STORE_PROV_LDAP CERT_STORE_PROV_LDAP_W +#define CERT_STORE_PROV_PKCS12 ((LPCSTR)17) +#define sz_CERT_STORE_PROV_MEMORY "Memory" +#define sz_CERT_STORE_PROV_FILENAME_W "File" +#define sz_CERT_STORE_PROV_FILENAME sz_CERT_STORE_PROV_FILENAME_W +#define sz_CERT_STORE_PROV_SYSTEM_W "System" +#define sz_CERT_STORE_PROV_SYSTEM sz_CERT_STORE_PROV_SYSTEM_W +#define sz_CERT_STORE_PROV_PKCS7 "PKCS7" +#define sz_CERT_STORE_PROV_PKCS12 "PKCS12" +#define sz_CERT_STORE_PROV_SERIALIZED "Serialized" +#define sz_CERT_STORE_PROV_COLLECTION "Collection" +#define sz_CERT_STORE_PROV_SYSTEM_REGISTRY_W "SystemRegistry" +#define sz_CERT_STORE_PROV_SYSTEM_REGISTRY sz_CERT_STORE_PROV_SYSTEM_REGISTRY_W +#define sz_CERT_STORE_PROV_PHYSICAL_W "Physical" +#define sz_CERT_STORE_PROV_PHYSICAL sz_CERT_STORE_PROV_PHYSICAL_W +#define sz_CERT_STORE_PROV_SMART_CARD_W "SmartCard" +#define sz_CERT_STORE_PROV_SMART_CARD sz_CERT_STORE_PROV_SMART_CARD_W +#define sz_CERT_STORE_PROV_LDAP_W "Ldap" +#define sz_CERT_STORE_PROV_LDAP sz_CERT_STORE_PROV_LDAP_W + +#define CERT_STORE_SIGNATURE_FLAG 0x00000001 +#define CERT_STORE_TIME_VALIDITY_FLAG 0x00000002 +#define CERT_STORE_REVOCATION_FLAG 0x00000004 +#define CERT_STORE_NO_CRL_FLAG 0x00010000 +#define CERT_STORE_NO_ISSUER_FLAG 0x00020000 +#define CERT_STORE_BASE_CRL_FLAG 0x00000100 +#define CERT_STORE_DELTA_CRL_FLAG 0x00000200 + +#define CERT_STORE_NO_CRYPT_RELEASE_FLAG 0x00000001 +#define CERT_STORE_SET_LOCALIZED_NAME_FLAG 0x00000002 +#define CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG 0x00000004 +#define CERT_STORE_DELETE_FLAG 0x00000010 +#define CERT_STORE_UNSAFE_PHYSICAL_FLAG 0x00000020 +#define CERT_STORE_SHARE_STORE_FLAG 0x00000040 +#define CERT_STORE_SHARE_CONTEXT_FLAG 0x00000080 +#define CERT_STORE_MANIFOLD_FLAG 0x00000100 +#define CERT_STORE_ENUM_ARCHIVED_FLAG 0x00000200 +#define CERT_STORE_UPDATE_KEYID_FLAG 0x00000400 +#define CERT_STORE_BACKUP_RESTORE_FLAG 0x00000800 +#define CERT_STORE_READONLY_FLAG 0x00008000 +#define CERT_STORE_OPEN_EXISTING_FLAG 0x00004000 +#define CERT_STORE_CREATE_NEW_FLAG 0x00002000 +#define CERT_STORE_MAXIMUM_ALLOWED_FLAG 0x00001000 + +#define CERT_SYSTEM_STORE_MASK 0xFFFF0000 +#define CERT_SYSTEM_STORE_RELOCATE_FLAG 0x80000000 +#define CERT_SYSTEM_STORE_UNPROTECTED_FLAG 0x40000000 +#define CERT_SYSTEM_STORE_DEFER_READ_FLAG 0x20000000 +#define CERT_SYSTEM_STORE_LOCATION_MASK 0x00FF0000 +#define CERT_SYSTEM_STORE_LOCATION_SHIFT 16 +#define CERT_SYSTEM_STORE_CURRENT_USER_ID 1 +#define CERT_SYSTEM_STORE_LOCAL_MACHINE_ID 2 +#define CERT_SYSTEM_STORE_CURRENT_SERVICE_ID 4 +#define CERT_SYSTEM_STORE_SERVICES_ID 5 +#define CERT_SYSTEM_STORE_USERS_ID 6 +#define CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY_ID 7 +#define CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY_ID 8 +#define CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE_ID 9 + +#define CERT_SYSTEM_STORE_CURRENT_USER \ + (CERT_SYSTEM_STORE_CURRENT_USER_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT) +#define CERT_SYSTEM_STORE_LOCAL_MACHINE \ + (CERT_SYSTEM_STORE_LOCAL_MACHINE_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT) +#define CERT_SYSTEM_STORE_CURRENT_SERVICE \ + (CERT_SYSTEM_STORE_CURRENT_SERVICE_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT) +#define CERT_SYSTEM_STORE_SERVICES \ + (CERT_SYSTEM_STORE_SERVICES_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT) +#define CERT_SYSTEM_STORE_USERS (CERT_SYSTEM_STORE_USERS_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT) +#define CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY \ + (CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT) +#define CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY \ + (CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT) +#define CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE \ + (CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE_ID << CERT_SYSTEM_STORE_LOCATION_SHIFT) + +WINPR_API HCERTSTORE CertOpenStore(LPCSTR lpszStoreProvider, DWORD dwMsgAndCertEncodingType, + HCRYPTPROV_LEGACY hCryptProv, DWORD dwFlags, const void* pvPara); + +WINPR_API HCERTSTORE CertOpenSystemStoreW(HCRYPTPROV_LEGACY hProv, LPCWSTR szSubsystemProtocol); +WINPR_API HCERTSTORE CertOpenSystemStoreA(HCRYPTPROV_LEGACY hProv, LPCSTR szSubsystemProtocol); + +WINPR_API BOOL CertCloseStore(HCERTSTORE hCertStore, DWORD dwFlags); + +#ifdef UNICODE +#define CertOpenSystemStore CertOpenSystemStoreW +#else +#define CertOpenSystemStore CertOpenSystemStoreA +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API PCCERT_CONTEXT CertFindCertificateInStore(HCERTSTORE hCertStore, + DWORD dwCertEncodingType, DWORD dwFindFlags, + DWORD dwFindType, const void* pvFindPara, + PCCERT_CONTEXT pPrevCertContext); + + WINPR_API PCCERT_CONTEXT CertEnumCertificatesInStore(HCERTSTORE hCertStore, + PCCERT_CONTEXT pPrevCertContext); + + WINPR_API DWORD CertGetNameStringW(PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, + void* pvTypePara, LPWSTR pszNameString, DWORD cchNameString); + WINPR_API DWORD CertGetNameStringA(PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, + void* pvTypePara, LPSTR pszNameString, DWORD cchNameString); + +#ifdef __cplusplus +} +#endif + +#ifdef UNICODE +#define CertGetNameString CertGetNameStringW +#else +#define CertGetNameString CertGetNameStringA +#endif + +/** + * Data Protection API (DPAPI) + */ + +#define CRYPTPROTECTMEMORY_BLOCK_SIZE 16 + +#define CRYPTPROTECTMEMORY_SAME_PROCESS 0x00000000 +#define CRYPTPROTECTMEMORY_CROSS_PROCESS 0x00000001 +#define CRYPTPROTECTMEMORY_SAME_LOGON 0x00000002 + +#define CRYPTPROTECT_PROMPT_ON_UNPROTECT 0x00000001 +#define CRYPTPROTECT_PROMPT_ON_PROTECT 0x00000002 +#define CRYPTPROTECT_PROMPT_RESERVED 0x00000004 +#define CRYPTPROTECT_PROMPT_STRONG 0x00000008 +#define CRYPTPROTECT_PROMPT_REQUIRE_STRONG 0x00000010 + +#define CRYPTPROTECT_UI_FORBIDDEN 0x1 +#define CRYPTPROTECT_LOCAL_MACHINE 0x4 +#define CRYPTPROTECT_CRED_SYNC 0x8 +#define CRYPTPROTECT_AUDIT 0x10 +#define CRYPTPROTECT_NO_RECOVERY 0x20 +#define CRYPTPROTECT_VERIFY_PROTECTION 0x40 +#define CRYPTPROTECT_CRED_REGENERATE 0x80 + +#define CRYPTPROTECT_FIRST_RESERVED_FLAGVAL 0x0FFFFFFF +#define CRYPTPROTECT_LAST_RESERVED_FLAGVAL 0xFFFFFFFF + +typedef struct +{ + DWORD cbSize; + DWORD dwPromptFlags; + HWND hwndApp; + LPCWSTR szPrompt; +} CRYPTPROTECT_PROMPTSTRUCT, *PCRYPTPROTECT_PROMPTSTRUCT; + +#define CRYPTPROTECT_DEFAULT_PROVIDER \ + { \ + 0xdf9d8cd0, 0x1501, 0x11d1, \ + { \ + 0x8c, 0x7a, 0x00, 0xc0, 0x4f, 0xc2, 0x97, 0xeb \ + } \ + } + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API BOOL CryptProtectMemory(LPVOID pData, DWORD cbData, DWORD dwFlags); + WINPR_API BOOL CryptUnprotectMemory(LPVOID pData, DWORD cbData, DWORD dwFlags); + + WINPR_API BOOL CryptProtectData(DATA_BLOB* pDataIn, LPCWSTR szDataDescr, + DATA_BLOB* pOptionalEntropy, PVOID pvReserved, + CRYPTPROTECT_PROMPTSTRUCT* pPromptStruct, DWORD dwFlags, + DATA_BLOB* pDataOut); + WINPR_API BOOL CryptUnprotectData(DATA_BLOB* pDataIn, LPWSTR* ppszDataDescr, + DATA_BLOB* pOptionalEntropy, PVOID pvReserved, + CRYPTPROTECT_PROMPTSTRUCT* pPromptStruct, DWORD dwFlags, + DATA_BLOB* pDataOut); + +#ifdef __cplusplus +} +#endif + +#define CRYPT_STRING_BASE64HEADER 0x00000000 +#define CRYPT_STRING_BASE64 0x00000001 +#define CRYPT_STRING_BINARY 0x00000002 +#define CRYPT_STRING_BASE64REQUESTHEADER 0x00000003 +#define CRYPT_STRING_HEX 0x00000004 +#define CRYPT_STRING_HEXASCII 0x00000005 +#define CRYPT_STRING_BASE64_ANY 0x00000006 +#define CRYPT_STRING_ANY 0x00000007 +#define CRYPT_STRING_HEX_ANY 0x00000008 +#define CRYPT_STRING_BASE64X509CRLHEADER 0x00000009 +#define CRYPT_STRING_HEXADDR 0x0000000A +#define CRYPT_STRING_HEXASCIIADDR 0x0000000B +#define CRYPT_STRING_HEXRAW 0x0000000C + +#define CRYPT_STRING_HASHDATA 0x10000000 +#define CRYPT_STRING_STRICT 0x20000000 +#define CRYPT_STRING_NOCRLF 0x40000000 +#define CRYPT_STRING_NOCR 0x80000000 + +WINPR_API BOOL CryptStringToBinaryW(LPCWSTR pszString, DWORD cchString, DWORD dwFlags, + BYTE* pbBinary, DWORD* pcbBinary, DWORD* pdwSkip, + DWORD* pdwFlags); +WINPR_API BOOL CryptStringToBinaryA(LPCSTR pszString, DWORD cchString, DWORD dwFlags, + BYTE* pbBinary, DWORD* pcbBinary, DWORD* pdwSkip, + DWORD* pdwFlags); + +WINPR_API BOOL CryptBinaryToStringW(CONST BYTE* pbBinary, DWORD cbBinary, DWORD dwFlags, + LPWSTR pszString, DWORD* pcchString); +WINPR_API BOOL CryptBinaryToStringA(CONST BYTE* pbBinary, DWORD cbBinary, DWORD dwFlags, + LPSTR pszString, DWORD* pcchString); + +#ifdef UNICODE +#define CryptStringToBinary CryptStringToBinaryW +#define CryptBinaryToString CryptBinaryToStringW +#else +#define CryptStringToBinary CryptStringToBinaryA +#define CryptBinaryToString CryptBinaryToStringA +#endif + +#endif + +#ifndef ALG_SID_ECSDA +#define ALG_SID_ECDSA 3 +#define CALG_ECDSA (ALG_CLASS_SIGNATURE | ALG_TYPE_DSS | ALG_SID_ECDSA) +#endif + +#endif /* WINPR_WINCRYPT_H */ diff --git a/winpr/include/winpr/windows.h b/winpr/include/winpr/windows.h new file mode 100644 index 0000000..5bc6722 --- /dev/null +++ b/winpr/include/winpr/windows.h @@ -0,0 +1,130 @@ +/** + * WinPR: Windows Portable Runtime + * Windows Header Include Wrapper + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_WINDOWS_H +#define WINPR_WINDOWS_H + +/* Windows header include order is important, use this instead of including windows.h directly */ + +#ifdef _WIN32 + +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif + +#include <winsock2.h> +#include <windows.h> +#include <ws2tcpip.h> + +#else + +/* Client System Parameters Update PDU + * defined in winuser.h + */ +typedef enum +{ + SPI_SETDRAGFULLWINDOWS = 0x00000025, + SPI_SETKEYBOARDCUES = 0x0000100B, + SPI_SETKEYBOARDPREF = 0x00000045, + SPI_SETWORKAREA = 0x0000002f, + RAIL_SPI_DISPLAYCHANGE = 0x0000F001, + SPI_SETMOUSEBUTTONSWAP = 0x00000021, + RAIL_SPI_TASKBARPOS = 0x0000F000, + SPI_SETHIGHCONTRAST = 0x00000043, + SPI_SETCARETWIDTH = 0x00002007, + SPI_SETSTICKYKEYS = 0x0000003B, + SPI_SETTOGGLEKEYS = 0x00000035, + SPI_SETFILTERKEYS = 0x00000033, + RAIL_SPI_DISPLAY_ANIMATIONS_ENABLED = 0x0000F002, + RAIL_SPI_DISPLAY_ADVANCED_EFFECTS_ENABLED = 0x0000F003, + RAIL_SPI_DISPLAY_AUTO_HIDE_SCROLLBARS = 0x0000F004, + RAIL_SPI_DISPLAY_MESSAGE_DURATION = 0x0000F005, + RAIL_SPI_CLOSED_CAPTION_FONT_COLOR = 0x0000F006, + RAIL_SPI_CLOSED_CAPTION_FONT_OPACITY = 0x0000F007, + RAIL_SPI_CLOSED_CAPTION_FONT_SIZE = 0x0000F008, + RAIL_SPI_CLOSED_CAPTION_FONT_STYLE = 0x0000F009, + RAIL_SPI_CLOSED_CAPTION_FONT_EDGE_EFFECT = 0x0000F00A, + RAIL_SPI_CLOSED_CAPTION_BACKGROUND_COLOR = 0x0000F00B, + RAIL_SPI_CLOSED_CAPTION_BACKGROUND_OPACITY = 0x0000F00C, + RAIL_SPI_CLOSED_CAPTION_REGION_COLOR = 0x0000F00D, + RAIL_SPI_CLOSED_CAPTION_REGION_OPACITY = 0x0000F00E +} SystemParam; + +/* Server System Parameters Update PDU */ +#define SPI_SETSCREENSAVEACTIVE 0x00000011 + +/* HIGHCONTRAST flags values */ +#define HCF_HIGHCONTRASTON 0x00000001 +#define HCF_AVAILABLE 0x00000002 +#define HCF_HOTKEYACTIVE 0x00000004 +#define HCF_CONFIRMHOTKEY 0x00000008 +#define HCF_HOTKEYSOUND 0x00000010 +#define HCF_INDICATOR 0x00000020 +#define HCF_HOTKEYAVAILABLE 0x00000040 + +/* TS_FILTERKEYS */ +#define FKF_FILTERKEYSON 0x00000001 +#define FKF_AVAILABLE 0x00000002 +#define FKF_HOTKEYACTIVE 0x00000004 +#define FKF_CONFIRMHOTKEY 0x00000008 +#define FKF_HOTKEYSOUND 0x00000010 +#define FKF_INDICATOR 0x00000020 +#define FKF_CLICKON 0x00000040 + +/* TS_TOGGLEKEYS */ +#define TKF_TOGGLEKEYSON 0x00000001 +#define TKF_AVAILABLE 0x00000002 +#define TKF_HOTKEYACTIVE 0x00000004 +#define TKF_CONFIRMHOTKEY 0x00000008 +#define TKF_HOTKEYSOUND 0x00000010 + +/* TS_STICKYKEYS */ +#define SKF_STICKYKEYSON 0x00000001 +#define SKF_AVAILABLE 0x00000002 +#define SKF_HOTKEYACTIVE 0x00000004 +#define SKF_CONFIRMHOTKEY 0x00000008 +#define SKF_HOTKEYSOUND 0x00000010 +#define SKF_INDICATOR 0x00000020 +#define SKF_AUDIBLEFEEDBACK 0x00000040 +#define SKF_TRISTATE 0x00000080 +#define SKF_TWOKEYSOFF 0x00000100 +#define SKF_LSHIFTLOCKED 0x00010000 +#define SKF_RSHIFTLOCKED 0x00020000 +#define SKF_LCTLLOCKED 0x00040000 +#define SKF_RCTLLOCKED 0x00080000 +#define SKF_LALTLOCKED 0x00100000 +#define SKF_RALTLOCKED 0x00200000 +#define SKF_LWINLOCKED 0x00400000 +#define SKF_RWINLOCKED 0x00800000 +#define SKF_LSHIFTLATCHED 0x01000000 +#define SKF_RSHIFTLATCHED 0x02000000 +#define SKF_LCTLLATCHED 0x04000000 +#define SKF_RCTLLATCHED 0x08000000 +#define SKF_LALTLATCHED 0x10000000 +#define SKF_RALTLATCHED 0x20000000 +#define SKF_LWINLATCHED 0x40000000 +#define SKF_RWINLATCHED 0x80000000 + +#endif + +#ifndef SPI_SETSCREENSAVESECURE +#define SPI_SETSCREENSAVESECURE 0x00000077 +#endif + +#endif /* WINPR_WINDOWS_H */ diff --git a/winpr/include/winpr/winpr.h b/winpr/include/winpr/winpr.h new file mode 100644 index 0000000..04311d8 --- /dev/null +++ b/winpr/include/winpr/winpr.h @@ -0,0 +1,129 @@ +/** + * WinPR: Windows Portable Runtime + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_H +#define WINPR_H + +#include <winpr/platform.h> + +#ifdef WINPR_DLL +#if defined _WIN32 || defined __CYGWIN__ +#ifdef WINPR_EXPORTS +#ifdef __GNUC__ +#define WINPR_API __attribute__((dllexport)) +#else +#define WINPR_API __declspec(dllexport) +#endif +#else +#ifdef __GNUC__ +#define WINPR_API __attribute__((dllimport)) +#else +#define WINPR_API __declspec(dllimport) +#endif +#endif +#else +#if defined(__GNUC__) && (__GNUC__ >= 4) +#define WINPR_API __attribute__((visibility("default"))) +#else +#define WINPR_API +#endif +#endif +#else /* WINPR_DLL */ +#define WINPR_API +#endif + +#if defined(__clang__) || defined(__GNUC__) && (__GNUC__ <= 10) +#define WINPR_ATTR_MALLOC(deallocator, ptrindex) __attribute__((malloc, warn_unused_result)) +#elif defined(__GNUC__) +#define WINPR_ATTR_MALLOC(deallocator, ptrindex) \ + __attribute__((malloc(deallocator, ptrindex), warn_unused_result)) +#else +#define WINPR_ATTR_MALLOC(deallocator, ptrindex) +#endif + +#if defined(__GNUC__) || defined(__clang__) +#define WINPR_ATTR_FORMAT_ARG(pos, args) __attribute__((__format__(__printf__, pos, args))) +#define WINPR_FORMAT_ARG /**/ +#else +#define WINPR_ATTR_FORMAT_ARG(pos, args) +#define WINPR_FORMAT_ARG _Printf_format_string_ +#endif + +#if defined(__STDC__) && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L) +#define WINPR_DEPRECATED(obj) [[deprecated]] obj +#define WINPR_DEPRECATED_VAR(text, obj) [[deprecated(text)]] obj +#define WINPR_NORETURN(obj) [[noreturn]] obj +#elif defined(WIN32) && !defined(__CYGWIN__) +#define WINPR_DEPRECATED(obj) __declspec(deprecated) obj +#define WINPR_DEPRECATED_VAR(text, obj) __declspec(deprecated(text)) obj +#define WINPR_NORETURN(obj) __declspec(noreturn) obj +#elif defined(__GNUC__) +#define WINPR_DEPRECATED(obj) obj __attribute__((deprecated)) +#define WINPR_DEPRECATED_VAR(text, obj) obj __attribute__((deprecated(text))) +#define WINPR_NORETURN(obj) __attribute__((__noreturn__)) obj +#else +#define WINPR_DEPRECATED(obj) obj +#define WINPR_DEPRECATED_VAR(text, obj) obj +#define WINPR_NORETURN(obj) obj +#endif + +#if defined(EXPORT_ALL_SYMBOLS) +#define WINPR_LOCAL WINPR_API +#else +#if defined _WIN32 || defined __CYGWIN__ +#define WINPR_LOCAL +#else +#if defined(__GNUC__) && (__GNUC__ >= 4) +#define WINPR_LOCAL __attribute__((visibility("hidden"))) +#else +#define WINPR_LOCAL +#endif +#endif +#endif + +// WARNING: *do not* use thread-local storage for new code because it is not portable +// It is only used for VirtualChannelInit, and all FreeRDP channels use VirtualChannelInitEx +// The old virtual channel API is only realistically used on Windows where TLS is available +#if defined _WIN32 || defined __CYGWIN__ +#ifdef __GNUC__ +#define WINPR_TLS __thread +#else +#define WINPR_TLS __declspec(thread) +#endif +#elif !defined(__IOS__) +#define WINPR_TLS __thread +#else +// thread-local storage is not supported on iOS +// don't warn because it isn't actually used on iOS +#define WINPR_TLS +#endif + +#ifdef _WIN32 +#define INLINE __inline +#else +#define INLINE inline +#endif + +WINPR_API void winpr_get_version(int* major, int* minor, int* revision); +WINPR_API const char* winpr_get_version_string(void); +WINPR_API const char* winpr_get_build_revision(void); +WINPR_API const char* winpr_get_build_config(void); + +#define WINPR_UNUSED(x) (void)(x) + +#endif /* WINPR_H */ diff --git a/winpr/include/winpr/winsock.h b/winpr/include/winpr/winsock.h new file mode 100644 index 0000000..73dc9ae --- /dev/null +++ b/winpr/include/winpr/winsock.h @@ -0,0 +1,366 @@ +/** + * WinPR: Windows Portable Runtime + * Windows Sockets (Winsock) + * + * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_WINSOCK_H +#define WINPR_WINSOCK_H + +#include <winpr/platform.h> +#include <winpr/winpr.h> +#include <winpr/wtypes.h> +#include <winpr/windows.h> + +#ifdef _WIN32 + +#define _accept accept +#define _bind bind +#define _connect connect +#define _ioctlsocket ioctlsocket +#define _getpeername getpeername +#define _getsockname getsockname +#define _getsockopt getsockopt +#define _htonl htonl +#define _htons htons +#define _inet_addr inet_addr +#define _inet_ntoa inet_ntoa +#define _listen listen +#define _ntohl ntohl +#define _ntohs ntohs +#define _recv recv +#define _recvfrom recvfrom +#define _select select +#define _send send +#define _sendto sendto +#define _setsockopt setsockopt +#define _shutdown shutdown +#define _socket socket +#define _gethostbyaddr gethostbyaddr +#define _gethostbyname gethostbyname +#define _gethostname gethostname +#define _getservbyport getservbyport +#define _getservbyname getservbyname +#define _getprotobynumber getprotobynumber +#define _getprotobyname getprotobyname + +#define _IFF_UP IFF_UP +#define _IFF_BROADCAST IFF_BROADCAST +#define _IFF_LOOPBACK IFF_LOOPBACK +#define _IFF_POINTTOPOINT IFF_POINTTOPOINT +#define _IFF_MULTICAST IFF_MULTICAST + +#if (_WIN32_WINNT < 0x0600) + +WINPR_API PCSTR winpr_inet_ntop(INT Family, PVOID pAddr, PSTR pStringBuf, size_t StringBufSize); +WINPR_API INT winpr_inet_pton(INT Family, PCSTR pszAddrString, PVOID pAddrBuf); + +#define inet_ntop winpr_inet_ntop +#define inet_pton winpr_inet_pton + +#endif /* (_WIN32_WINNT < 0x0600) */ + +#else /* _WIN32 */ + +#include <netdb.h> +#include <unistd.h> +#include <sys/un.h> +#include <sys/ioctl.h> +#include <sys/socket.h> +#include <arpa/inet.h> +#include <netinet/in.h> +#include <netinet/tcp.h> +#include <net/if.h> + +#include <winpr/io.h> +#include <winpr/error.h> +#include <winpr/platform.h> + +#define WSAEVENT HANDLE +#define LPWSAEVENT LPHANDLE +#define WSAOVERLAPPED OVERLAPPED +typedef OVERLAPPED* LPWSAOVERLAPPED; + +typedef UINT_PTR SOCKET; +typedef struct sockaddr_storage SOCKADDR_STORAGE; + +#ifndef INVALID_SOCKET +#define INVALID_SOCKET (SOCKET)(~0) +#endif + +#define WSADESCRIPTION_LEN 256 +#define WSASYS_STATUS_LEN 128 + +#define FD_READ_BIT 0 +#define FD_READ (1 << FD_READ_BIT) + +#define FD_WRITE_BIT 1 +#define FD_WRITE (1 << FD_WRITE_BIT) + +#define FD_OOB_BIT 2 +#define FD_OOB (1 << FD_OOB_BIT) + +#define FD_ACCEPT_BIT 3 +#define FD_ACCEPT (1 << FD_ACCEPT_BIT) + +#define FD_CONNECT_BIT 4 +#define FD_CONNECT (1 << FD_CONNECT_BIT) + +#define FD_CLOSE_BIT 5 +#define FD_CLOSE (1 << FD_CLOSE_BIT) + +#define FD_QOS_BIT 6 +#define FD_QOS (1 << FD_QOS_BIT) + +#define FD_GROUP_QOS_BIT 7 +#define FD_GROUP_QOS (1 << FD_GROUP_QOS_BIT) + +#define FD_ROUTING_INTERFACE_CHANGE_BIT 8 +#define FD_ROUTING_INTERFACE_CHANGE (1 << FD_ROUTING_INTERFACE_CHANGE_BIT) + +#define FD_ADDRESS_LIST_CHANGE_BIT 9 +#define FD_ADDRESS_LIST_CHANGE (1 << FD_ADDRESS_LIST_CHANGE_BIT) + +#define FD_MAX_EVENTS 10 +#define FD_ALL_EVENTS ((1 << FD_MAX_EVENTS) - 1) + +#define SD_RECEIVE 0 +#define SD_SEND 1 +#define SD_BOTH 2 + +#define SOCKET_ERROR (-1) + +typedef struct WSAData +{ + WORD wVersion; + WORD wHighVersion; +#ifdef _M_AMD64 + unsigned short iMaxSockets; + unsigned short iMaxUdpDg; + char* lpVendorInfo; + char szDescription[WSADESCRIPTION_LEN + 1]; + char szSystemStatus[WSASYS_STATUS_LEN + 1]; +#else + char szDescription[WSADESCRIPTION_LEN + 1]; + char szSystemStatus[WSASYS_STATUS_LEN + 1]; + unsigned short iMaxSockets; + unsigned short iMaxUdpDg; + char* lpVendorInfo; +#endif +} WSADATA, *LPWSADATA; + +#ifndef MAKEWORD +#define MAKEWORD(a, b) \ + ((WORD)(((BYTE)((DWORD_PTR)(a)&0xFF)) | (((WORD)((BYTE)((DWORD_PTR)(b)&0xFF))) << 8))) +#endif + +typedef struct in6_addr IN6_ADDR; +typedef struct in6_addr* PIN6_ADDR; +typedef struct in6_addr* LPIN6_ADDR; + +struct sockaddr_in6_old +{ + SHORT sin6_family; + USHORT sin6_port; + ULONG sin6_flowinfo; + IN6_ADDR sin6_addr; +}; + +typedef union sockaddr_gen +{ + struct sockaddr Address; + struct sockaddr_in AddressIn; + struct sockaddr_in6_old AddressIn6; +} sockaddr_gen; + +WINPR_PRAGMA_DIAG_PUSH +WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO + +#define _IFF_UP 0x00000001 +#define _IFF_BROADCAST 0x00000002 +#define _IFF_LOOPBACK 0x00000004 +#define _IFF_POINTTOPOINT 0x00000008 +#define _IFF_MULTICAST 0x00000010 + +WINPR_PRAGMA_DIAG_POP + +typedef struct +{ + ULONG iiFlags; + sockaddr_gen iiAddress; + sockaddr_gen iiBroadcastAddress; + sockaddr_gen iiNetmask; +} INTERFACE_INFO; +typedef INTERFACE_INFO* LPINTERFACE_INFO; + +#define MAX_PROTOCOL_CHAIN 7 +#define WSAPROTOCOL_LEN 255 + +typedef struct +{ + int ChainLen; + DWORD ChainEntries[MAX_PROTOCOL_CHAIN]; +} WSAPROTOCOLCHAIN, *LPWSAPROTOCOLCHAIN; + +typedef struct +{ + DWORD dwServiceFlags1; + DWORD dwServiceFlags2; + DWORD dwServiceFlags3; + DWORD dwServiceFlags4; + DWORD dwProviderFlags; + GUID ProviderId; + DWORD dwCatalogEntryId; + WSAPROTOCOLCHAIN ProtocolChain; + int iVersion; + int iAddressFamily; + int iMaxSockAddr; + int iMinSockAddr; + int iSocketType; + int iProtocol; + int iProtocolMaxOffset; + int iNetworkByteOrder; + int iSecurityScheme; + DWORD dwMessageSize; + DWORD dwProviderReserved; + CHAR szProtocol[WSAPROTOCOL_LEN + 1]; +} WSAPROTOCOL_INFOA, *LPWSAPROTOCOL_INFOA; + +typedef struct +{ + DWORD dwServiceFlags1; + DWORD dwServiceFlags2; + DWORD dwServiceFlags3; + DWORD dwServiceFlags4; + DWORD dwProviderFlags; + GUID ProviderId; + DWORD dwCatalogEntryId; + WSAPROTOCOLCHAIN ProtocolChain; + int iVersion; + int iAddressFamily; + int iMaxSockAddr; + int iMinSockAddr; + int iSocketType; + int iProtocol; + int iProtocolMaxOffset; + int iNetworkByteOrder; + int iSecurityScheme; + DWORD dwMessageSize; + DWORD dwProviderReserved; + WCHAR szProtocol[WSAPROTOCOL_LEN + 1]; +} WSAPROTOCOL_INFOW, *LPWSAPROTOCOL_INFOW; + +typedef void(CALLBACK* LPWSAOVERLAPPED_COMPLETION_ROUTINE)(DWORD dwError, DWORD cbTransferred, + LPWSAOVERLAPPED lpOverlapped, + DWORD dwFlags); + +typedef UINT32 GROUP; +#define SG_UNCONSTRAINED_GROUP 0x01 +#define SG_CONSTRAINED_GROUP 0x02 + +#define SIO_GET_INTERFACE_LIST _IOR('t', 127, ULONG) +#define SIO_GET_INTERFACE_LIST_EX _IOR('t', 126, ULONG) +#define SIO_SET_MULTICAST_FILTER _IOW('t', 125, ULONG) +#define SIO_GET_MULTICAST_FILTER _IOW('t', 124 | IOC_IN, ULONG) +#define SIOCSIPMSFILTER SIO_SET_MULTICAST_FILTER +#define SIOCGIPMSFILTER SIO_GET_MULTICAST_FILTER + +#ifdef UNICODE +#define WSAPROTOCOL_INFO WSAPROTOCOL_INFOW +#define LPWSAPROTOCOL_INFO LPWSAPROTOCOL_INFOW +#else +#define WSAPROTOCOL_INFO WSAPROTOCOL_INFOA +#define LPWSAPROTOCOL_INFO LPWSAPROTOCOL_INFOA +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API int WSAStartup(WORD wVersionRequired, LPWSADATA lpWSAData); + WINPR_API int WSACleanup(void); + + WINPR_API void WSASetLastError(int iError); + WINPR_API int WSAGetLastError(void); + + WINPR_API HANDLE WSACreateEvent(void); + WINPR_API BOOL WSASetEvent(HANDLE hEvent); + WINPR_API BOOL WSAResetEvent(HANDLE hEvent); + WINPR_API BOOL WSACloseEvent(HANDLE hEvent); + + WINPR_API int WSAEventSelect(SOCKET s, WSAEVENT hEventObject, LONG lNetworkEvents); + + WINPR_API DWORD WSAWaitForMultipleEvents(DWORD cEvents, const HANDLE* lphEvents, BOOL fWaitAll, + DWORD dwTimeout, BOOL fAlertable); + + WINPR_API SOCKET WSASocketA(int af, int type, int protocol, LPWSAPROTOCOL_INFOA lpProtocolInfo, + GROUP g, DWORD dwFlags); + WINPR_API SOCKET WSASocketW(int af, int type, int protocol, LPWSAPROTOCOL_INFOW lpProtocolInfo, + GROUP g, DWORD dwFlags); + + WINPR_API int WSAIoctl(SOCKET s, DWORD dwIoControlCode, LPVOID lpvInBuffer, DWORD cbInBuffer, + LPVOID lpvOutBuffer, DWORD cbOutBuffer, LPDWORD lpcbBytesReturned, + LPWSAOVERLAPPED lpOverlapped, + LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine); + + WINPR_API SOCKET _accept(SOCKET s, struct sockaddr* addr, int* addrlen); + WINPR_API int _bind(SOCKET s, const struct sockaddr* addr, int namelen); + WINPR_API int closesocket(SOCKET s); + WINPR_API int _connect(SOCKET s, const struct sockaddr* name, int namelen); + WINPR_API int _ioctlsocket(SOCKET s, long cmd, u_long* argp); + WINPR_API int _getpeername(SOCKET s, struct sockaddr* name, int* namelen); + WINPR_API int _getsockname(SOCKET s, struct sockaddr* name, int* namelen); + WINPR_API int _getsockopt(SOCKET s, int level, int optname, char* optval, int* optlen); + WINPR_API u_long _htonl(u_long hostlong); + WINPR_API u_short _htons(u_short hostshort); + WINPR_API unsigned long _inet_addr(const char* cp); + WINPR_API char* _inet_ntoa(struct in_addr in); + WINPR_API int _listen(SOCKET s, int backlog); + WINPR_API u_long _ntohl(u_long netlong); + WINPR_API u_short _ntohs(u_short netshort); + WINPR_API int _recv(SOCKET s, char* buf, int len, int flags); + WINPR_API int _recvfrom(SOCKET s, char* buf, int len, int flags, struct sockaddr* from, + int* fromlen); + WINPR_API int _select(int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, + const struct timeval* timeout); + WINPR_API int _send(SOCKET s, const char* buf, int len, int flags); + WINPR_API int _sendto(SOCKET s, const char* buf, int len, int flags, const struct sockaddr* to, + int tolen); + WINPR_API int _setsockopt(SOCKET s, int level, int optname, const char* optval, int optlen); + WINPR_API int _shutdown(SOCKET s, int how); + WINPR_API SOCKET _socket(int af, int type, int protocol); + WINPR_API struct hostent* _gethostbyaddr(const char* addr, int len, int type); + WINPR_API struct hostent* _gethostbyname(const char* name); + WINPR_API int _gethostname(char* name, int namelen); + WINPR_API struct servent* _getservbyport(int port, const char* proto); + WINPR_API struct servent* _getservbyname(const char* name, const char* proto); + WINPR_API struct protoent* _getprotobynumber(int number); + WINPR_API struct protoent* _getprotobyname(const char* name); + +#ifdef __cplusplus +} +#endif + +#ifdef UNICODE +#define WSASocket WSASocketW +#else +#define WSASocket WSASocketA +#endif + +#endif /* _WIN32 */ + +#endif /* WINPR_WINSOCK_H */ diff --git a/winpr/include/winpr/wlog.h b/winpr/include/winpr/wlog.h new file mode 100644 index 0000000..c3918f5 --- /dev/null +++ b/winpr/include/winpr/wlog.h @@ -0,0 +1,246 @@ +/** + * WinPR: Windows Portable Runtime + * WinPR Logger + * + * Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * Copyright 2015 Thincast Technologies GmbH + * Copyright 2015 Bernhard Miklautz <bernhard.miklautz@thincast.com> + * + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_LOG_H +#define WINPR_LOG_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include <stdarg.h> +#include <winpr/wtypes.h> +#include <winpr/winpr.h> +#include <winpr/synch.h> +#include <winpr/thread.h> + +/** + * Log Levels + */ +#define WLOG_TRACE 0 +#define WLOG_DEBUG 1 +#define WLOG_INFO 2 +#define WLOG_WARN 3 +#define WLOG_ERROR 4 +#define WLOG_FATAL 5 +#define WLOG_OFF 6 +#define WLOG_LEVEL_INHERIT 0xFFFF + +/** + * Log Message + */ +#define WLOG_MESSAGE_TEXT 0 +#define WLOG_MESSAGE_DATA 1 +#define WLOG_MESSAGE_IMAGE 2 +#define WLOG_MESSAGE_PACKET 3 + +/** + * Log Appenders + */ +#define WLOG_APPENDER_CONSOLE 0 +#define WLOG_APPENDER_FILE 1 +#define WLOG_APPENDER_BINARY 2 +#define WLOG_APPENDER_CALLBACK 3 +#define WLOG_APPENDER_SYSLOG 4 +#define WLOG_APPENDER_JOURNALD 5 +#define WLOG_APPENDER_UDP 6 + + typedef struct + { + DWORD Type; + + DWORD Level; + + LPSTR PrefixString; + + LPCSTR FormatString; + LPCSTR TextString; + + size_t LineNumber; /* __LINE__ */ + LPCSTR FileName; /* __FILE__ */ + LPCSTR FunctionName; /* __func__ */ + + /* Data Message */ + + void* Data; + size_t Length; + + /* Image Message */ + + void* ImageData; + size_t ImageWidth; + size_t ImageHeight; + size_t ImageBpp; + + /* Packet Message */ + + void* PacketData; + size_t PacketLength; + DWORD PacketFlags; + } wLogMessage; + typedef struct s_wLogLayout wLogLayout; + typedef struct s_wLogAppender wLogAppender; + typedef struct s_wLog wLog; + +#define WLOG_PACKET_INBOUND 1 +#define WLOG_PACKET_OUTBOUND 2 + + WINPR_API BOOL WLog_PrintMessage(wLog* log, DWORD type, DWORD level, size_t line, + const char* file, const char* function, ...); + WINPR_API BOOL WLog_PrintMessageVA(wLog* log, DWORD type, DWORD level, size_t line, + const char* file, const char* function, va_list args); + + WINPR_API wLog* WLog_GetRoot(void); + WINPR_API wLog* WLog_Get(LPCSTR name); + WINPR_API DWORD WLog_GetLogLevel(wLog* log); + WINPR_API BOOL WLog_IsLevelActive(wLog* _log, DWORD _log_level); + + /** @brief Set a custom context for a dynamic logger. + * This can be used to print a customized prefix, e.g. some session id for a specific context + * + * @param log The logger to ste the context for. Must not be \b NULL + * @param fkt A function pointer that is called to get the custimized string. + * @param context A context \b fkt is called with. Caller must ensure it is still allocated + * when \b log is used + * + * @return \b TRUE for success, \b FALSE otherwise. + */ + WINPR_API BOOL WLog_SetContext(wLog* log, const char* (*fkt)(void*), void* context); + +#define WLog_Print_unchecked(_log, _log_level, ...) \ + do \ + { \ + WLog_PrintMessage(_log, WLOG_MESSAGE_TEXT, _log_level, __LINE__, __FILE__, __func__, \ + __VA_ARGS__); \ + } while (0) + +#define WLog_Print(_log, _log_level, ...) \ + do \ + { \ + if (WLog_IsLevelActive(_log, _log_level)) \ + { \ + WLog_Print_unchecked(_log, _log_level, ##__VA_ARGS__); \ + } \ + } while (0) + +#define WLog_Print_tag(_tag, _log_level, ...) \ + do \ + { \ + static wLog* _log_cached_ptr = NULL; \ + if (!_log_cached_ptr) \ + _log_cached_ptr = WLog_Get(_tag); \ + WLog_Print(_log_cached_ptr, _log_level, __VA_ARGS__); \ + } while (0) + +#define WLog_PrintVA_unchecked(_log, _log_level, _args) \ + do \ + { \ + WLog_PrintMessageVA(_log, WLOG_MESSAGE_TEXT, _log_level, __LINE__, __FILE__, __func__, \ + _args); \ + } while (0) + +#define WLog_PrintVA(_log, _log_level, _args) \ + do \ + { \ + if (WLog_IsLevelActive(_log, _log_level)) \ + { \ + WLog_PrintVA_unchecked(_log, _log_level, _args); \ + } \ + } while (0) + +#define WLog_Data(_log, _log_level, ...) \ + do \ + { \ + if (WLog_IsLevelActive(_log, _log_level)) \ + { \ + WLog_PrintMessage(_log, WLOG_MESSAGE_DATA, _log_level, __LINE__, __FILE__, __func__, \ + __VA_ARGS__); \ + } \ + } while (0) + +#define WLog_Image(_log, _log_level, ...) \ + do \ + { \ + if (WLog_IsLevelActive(_log, _log_level)) \ + { \ + WLog_PrintMessage(_log, WLOG_MESSAGE_DATA, _log_level, __LINE__, __FILE__, __func__, \ + __VA_ARGS__); \ + } \ + } while (0) + +#define WLog_Packet(_log, _log_level, ...) \ + do \ + { \ + if (WLog_IsLevelActive(_log, _log_level)) \ + { \ + WLog_PrintMessage(_log, WLOG_MESSAGE_PACKET, _log_level, __LINE__, __FILE__, __func__, \ + __VA_ARGS__); \ + } \ + } while (0) + +#define WLog_LVL(tag, lvl, ...) WLog_Print_tag(tag, lvl, __VA_ARGS__) +#define WLog_VRB(tag, ...) WLog_Print_tag(tag, WLOG_TRACE, __VA_ARGS__) +#define WLog_DBG(tag, ...) WLog_Print_tag(tag, WLOG_DEBUG, __VA_ARGS__) +#define WLog_INFO(tag, ...) WLog_Print_tag(tag, WLOG_INFO, __VA_ARGS__) +#define WLog_WARN(tag, ...) WLog_Print_tag(tag, WLOG_WARN, __VA_ARGS__) +#define WLog_ERR(tag, ...) WLog_Print_tag(tag, WLOG_ERROR, __VA_ARGS__) +#define WLog_FATAL(tag, ...) WLog_Print_tag(tag, WLOG_FATAL, __VA_ARGS__) + + WINPR_API BOOL WLog_SetLogLevel(wLog* log, DWORD logLevel); + WINPR_API BOOL WLog_SetStringLogLevel(wLog* log, LPCSTR level); + WINPR_API BOOL WLog_AddStringLogFilters(LPCSTR filter); + + WINPR_API BOOL WLog_SetLogAppenderType(wLog* log, DWORD logAppenderType); + WINPR_API wLogAppender* WLog_GetLogAppender(wLog* log); + WINPR_API BOOL WLog_OpenAppender(wLog* log); + WINPR_API BOOL WLog_CloseAppender(wLog* log); + WINPR_API BOOL WLog_ConfigureAppender(wLogAppender* appender, const char* setting, void* value); + + WINPR_API wLogLayout* WLog_GetLogLayout(wLog* log); + WINPR_API BOOL WLog_Layout_SetPrefixFormat(wLog* log, wLogLayout* layout, const char* format); + +#if defined(WITH_WINPR_DEPRECATED) + /** Deprecated */ + WINPR_API WINPR_DEPRECATED(BOOL WLog_Init(void)); + /** Deprecated */ + WINPR_API WINPR_DEPRECATED(BOOL WLog_Uninit(void)); +#endif + + typedef BOOL (*wLogCallbackMessage_t)(const wLogMessage* msg); + typedef BOOL (*wLogCallbackData_t)(const wLogMessage* msg); + typedef BOOL (*wLogCallbackImage_t)(const wLogMessage* msg); + typedef BOOL (*wLogCallbackPackage_t)(const wLogMessage* msg); + + typedef struct + { + wLogCallbackData_t data; + wLogCallbackImage_t image; + wLogCallbackMessage_t message; + wLogCallbackPackage_t package; + } wLogCallbacks; + +#ifdef __cplusplus +} +#endif + +#endif /* WINPR_WLOG_H */ diff --git a/winpr/include/winpr/wtsapi.h b/winpr/include/winpr/wtsapi.h new file mode 100644 index 0000000..bd5616f --- /dev/null +++ b/winpr/include/winpr/wtsapi.h @@ -0,0 +1,1512 @@ +/** + * WinPR: Windows Portable Runtime + * Windows Terminal Services API + * + * Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com> + * Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com> + * Copyright 2015 Copyright 2015 Thincast Technologies GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef WINPR_WTSAPI_H +#define WINPR_WTSAPI_H + +#include <winpr/winpr.h> +#include <winpr/wtypes.h> + +#include <winpr/file.h> + +#define CHANNEL_CHUNK_MAX_LENGTH 16256 + +#ifdef _WIN32 + +#define CurrentTime _CurrentTime /* Workaround for X11 "CurrentTime" header conflict */ + +#endif + +#if defined(_WIN32) && !defined(_UWP) + +#include <pchannel.h> + +#else + +/** + * Virtual Channel Protocol (pchannel.h) + */ + +#define CHANNEL_CHUNK_LENGTH 1600 + +#define CHANNEL_PDU_LENGTH (CHANNEL_CHUNK_LENGTH + sizeof(CHANNEL_PDU_HEADER)) + +#define CHANNEL_FLAG_FIRST 0x01 +#define CHANNEL_FLAG_LAST 0x02 +#define CHANNEL_FLAG_ONLY (CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST) +#define CHANNEL_FLAG_MIDDLE 0 +#define CHANNEL_FLAG_FAIL 0x100 + +#define CHANNEL_OPTION_INITIALIZED 0x80000000 + +#define CHANNEL_OPTION_ENCRYPT_RDP 0x40000000 +#define CHANNEL_OPTION_ENCRYPT_SC 0x20000000 +#define CHANNEL_OPTION_ENCRYPT_CS 0x10000000 +#define CHANNEL_OPTION_PRI_HIGH 0x08000000 +#define CHANNEL_OPTION_PRI_MED 0x04000000 +#define CHANNEL_OPTION_PRI_LOW 0x02000000 +#define CHANNEL_OPTION_COMPRESS_RDP 0x00800000 +#define CHANNEL_OPTION_COMPRESS 0x00400000 +#define CHANNEL_OPTION_SHOW_PROTOCOL 0x00200000 +#define CHANNEL_OPTION_REMOTE_CONTROL_PERSISTENT 0x00100000 + +#define CHANNEL_MAX_COUNT 31 +#define CHANNEL_NAME_LEN 7 + +typedef struct tagCHANNEL_DEF +{ + char name[CHANNEL_NAME_LEN + 1]; + ULONG options; +} CHANNEL_DEF; +typedef CHANNEL_DEF* PCHANNEL_DEF; +typedef PCHANNEL_DEF* PPCHANNEL_DEF; + +typedef struct tagCHANNEL_PDU_HEADER +{ + UINT32 length; + UINT32 flags; +} CHANNEL_PDU_HEADER, *PCHANNEL_PDU_HEADER; + +#endif /* _WIN32 */ + +/** + * These channel flags are defined in some versions of pchannel.h only + */ + +#ifndef CHANNEL_FLAG_SHOW_PROTOCOL +#define CHANNEL_FLAG_SHOW_PROTOCOL 0x10 +#endif +#ifndef CHANNEL_FLAG_SUSPEND +#define CHANNEL_FLAG_SUSPEND 0x20 +#endif +#ifndef CHANNEL_FLAG_RESUME +#define CHANNEL_FLAG_RESUME 0x40 +#endif +#ifndef CHANNEL_FLAG_SHADOW_PERSISTENT +#define CHANNEL_FLAG_SHADOW_PERSISTENT 0x80 +#endif + +#if !defined(_WIN32) || !defined(H_CCHANNEL) + +/** + * Virtual Channel Client API (cchannel.h) + */ + +#ifdef _WIN32 +#define VCAPITYPE __stdcall +#define VCEXPORT +#else +#define VCAPITYPE CALLBACK +#define VCEXPORT __export +#endif + +typedef VOID VCAPITYPE CHANNEL_INIT_EVENT_FN(LPVOID pInitHandle, UINT event, LPVOID pData, + UINT dataLength); + +typedef CHANNEL_INIT_EVENT_FN* PCHANNEL_INIT_EVENT_FN; + +typedef VOID VCAPITYPE CHANNEL_INIT_EVENT_EX_FN(LPVOID lpUserParam, LPVOID pInitHandle, UINT event, + LPVOID pData, UINT dataLength); + +typedef CHANNEL_INIT_EVENT_EX_FN* PCHANNEL_INIT_EVENT_EX_FN; + +#define CHANNEL_EVENT_INITIALIZED 0 +#define CHANNEL_EVENT_CONNECTED 1 +#define CHANNEL_EVENT_V1_CONNECTED 2 +#define CHANNEL_EVENT_DISCONNECTED 3 +#define CHANNEL_EVENT_TERMINATED 4 +#define CHANNEL_EVENT_REMOTE_CONTROL_START 5 +#define CHANNEL_EVENT_REMOTE_CONTROL_STOP 6 +#define CHANNEL_EVENT_ATTACHED 7 +#define CHANNEL_EVENT_DETACHED 8 +#define CHANNEL_EVENT_DATA_RECEIVED 10 +#define CHANNEL_EVENT_WRITE_COMPLETE 11 +#define CHANNEL_EVENT_WRITE_CANCELLED 12 + +typedef VOID VCAPITYPE CHANNEL_OPEN_EVENT_FN(DWORD openHandle, UINT event, LPVOID pData, + UINT32 dataLength, UINT32 totalLength, + UINT32 dataFlags); + +typedef CHANNEL_OPEN_EVENT_FN* PCHANNEL_OPEN_EVENT_FN; + +typedef VOID VCAPITYPE CHANNEL_OPEN_EVENT_EX_FN(LPVOID lpUserParam, DWORD openHandle, UINT event, + LPVOID pData, UINT32 dataLength, UINT32 totalLength, + UINT32 dataFlags); + +typedef CHANNEL_OPEN_EVENT_EX_FN* PCHANNEL_OPEN_EVENT_EX_FN; + +#define CHANNEL_RC_OK 0 +#define CHANNEL_RC_ALREADY_INITIALIZED 1 +#define CHANNEL_RC_NOT_INITIALIZED 2 +#define CHANNEL_RC_ALREADY_CONNECTED 3 +#define CHANNEL_RC_NOT_CONNECTED 4 +#define CHANNEL_RC_TOO_MANY_CHANNELS 5 +#define CHANNEL_RC_BAD_CHANNEL 6 +#define CHANNEL_RC_BAD_CHANNEL_HANDLE 7 +#define CHANNEL_RC_NO_BUFFER 8 +#define CHANNEL_RC_BAD_INIT_HANDLE 9 +#define CHANNEL_RC_NOT_OPEN 10 +#define CHANNEL_RC_BAD_PROC 11 +#define CHANNEL_RC_NO_MEMORY 12 +#define CHANNEL_RC_UNKNOWN_CHANNEL_NAME 13 +#define CHANNEL_RC_ALREADY_OPEN 14 +#define CHANNEL_RC_NOT_IN_VIRTUALCHANNELENTRY 15 +#define CHANNEL_RC_NULL_DATA 16 +#define CHANNEL_RC_ZERO_LENGTH 17 +#define CHANNEL_RC_INVALID_INSTANCE 18 +#define CHANNEL_RC_UNSUPPORTED_VERSION 19 +#define CHANNEL_RC_INITIALIZATION_ERROR 20 + +#define VIRTUAL_CHANNEL_VERSION_WIN2000 1 + +typedef UINT VCAPITYPE VIRTUALCHANNELINIT(LPVOID* ppInitHandle, PCHANNEL_DEF pChannel, + INT channelCount, ULONG versionRequested, + PCHANNEL_INIT_EVENT_FN pChannelInitEventProc); + +typedef VIRTUALCHANNELINIT* PVIRTUALCHANNELINIT; + +typedef UINT VCAPITYPE VIRTUALCHANNELINITEX(LPVOID lpUserParam, LPVOID clientContext, + LPVOID pInitHandle, PCHANNEL_DEF pChannel, + INT channelCount, ULONG versionRequested, + PCHANNEL_INIT_EVENT_EX_FN pChannelInitEventProcEx); + +typedef VIRTUALCHANNELINITEX* PVIRTUALCHANNELINITEX; + +typedef UINT VCAPITYPE VIRTUALCHANNELOPEN(LPVOID pInitHandle, LPDWORD pOpenHandle, + PCHAR pChannelName, + PCHANNEL_OPEN_EVENT_FN pChannelOpenEventProc); + +typedef VIRTUALCHANNELOPEN* PVIRTUALCHANNELOPEN; + +typedef UINT VCAPITYPE VIRTUALCHANNELOPENEX(LPVOID pInitHandle, LPDWORD pOpenHandle, + PCHAR pChannelName, + PCHANNEL_OPEN_EVENT_EX_FN pChannelOpenEventProcEx); + +typedef VIRTUALCHANNELOPENEX* PVIRTUALCHANNELOPENEX; + +typedef UINT VCAPITYPE VIRTUALCHANNELCLOSE(DWORD openHandle); + +typedef VIRTUALCHANNELCLOSE* PVIRTUALCHANNELCLOSE; + +typedef UINT VCAPITYPE VIRTUALCHANNELCLOSEEX(LPVOID pInitHandle, DWORD openHandle); + +typedef VIRTUALCHANNELCLOSEEX* PVIRTUALCHANNELCLOSEEX; + +typedef UINT VCAPITYPE VIRTUALCHANNELWRITE(DWORD openHandle, LPVOID pData, ULONG dataLength, + LPVOID pUserData); + +typedef VIRTUALCHANNELWRITE* PVIRTUALCHANNELWRITE; + +typedef UINT VCAPITYPE VIRTUALCHANNELWRITEEX(LPVOID pInitHandle, DWORD openHandle, LPVOID pData, + ULONG dataLength, LPVOID pUserData); + +typedef VIRTUALCHANNELWRITEEX* PVIRTUALCHANNELWRITEEX; + +typedef struct tagCHANNEL_ENTRY_POINTS +{ + DWORD cbSize; + DWORD protocolVersion; + PVIRTUALCHANNELINIT pVirtualChannelInit; + PVIRTUALCHANNELOPEN pVirtualChannelOpen; + PVIRTUALCHANNELCLOSE pVirtualChannelClose; + PVIRTUALCHANNELWRITE pVirtualChannelWrite; +} CHANNEL_ENTRY_POINTS, *PCHANNEL_ENTRY_POINTS; + +typedef struct tagCHANNEL_ENTRY_POINTS_EX +{ + DWORD cbSize; + DWORD protocolVersion; + PVIRTUALCHANNELINITEX pVirtualChannelInitEx; + PVIRTUALCHANNELOPENEX pVirtualChannelOpenEx; + PVIRTUALCHANNELCLOSEEX pVirtualChannelCloseEx; + PVIRTUALCHANNELWRITEEX pVirtualChannelWriteEx; +} CHANNEL_ENTRY_POINTS_EX, *PCHANNEL_ENTRY_POINTS_EX; + +typedef BOOL VCAPITYPE VIRTUALCHANNELENTRY(PCHANNEL_ENTRY_POINTS pEntryPoints); + +typedef VIRTUALCHANNELENTRY* PVIRTUALCHANNELENTRY; + +typedef BOOL VCAPITYPE VIRTUALCHANNELENTRYEX(PCHANNEL_ENTRY_POINTS_EX pEntryPointsEx, + PVOID pInitHandle); + +typedef VIRTUALCHANNELENTRYEX* PVIRTUALCHANNELENTRYEX; + +typedef HRESULT(VCAPITYPE* PFNVCAPIGETINSTANCE)(REFIID refiid, PULONG pNumObjs, PVOID* ppObjArray); + +#endif + +#if !defined(_WIN32) || !defined(_INC_WTSAPI) + +/** + * Windows Terminal Services API (wtsapi32.h) + */ + +#define WTS_CURRENT_SERVER ((HANDLE)NULL) +#define WTS_CURRENT_SERVER_HANDLE ((HANDLE)NULL) +#define WTS_CURRENT_SERVER_NAME (NULL) + +#define WTS_CURRENT_SESSION ((DWORD)-1) + +#define WTS_ANY_SESSION ((DWORD)-2) + +#define IDTIMEOUT 32000 +#define IDASYNC 32001 + +#define USERNAME_LENGTH 20 +#define CLIENTNAME_LENGTH 20 +#define CLIENTADDRESS_LENGTH 30 + +#define WTS_WSD_LOGOFF 0x00000001 +#define WTS_WSD_SHUTDOWN 0x00000002 +#define WTS_WSD_REBOOT 0x00000004 +#define WTS_WSD_POWEROFF 0x00000008 +#define WTS_WSD_FASTREBOOT 0x00000010 + +#define MAX_ELAPSED_TIME_LENGTH 15 +#define MAX_DATE_TIME_LENGTH 56 +#define WINSTATIONNAME_LENGTH 32 +#define DOMAIN_LENGTH 17 + +#define WTS_DRIVE_LENGTH 3 +#define WTS_LISTENER_NAME_LENGTH 32 +#define WTS_COMMENT_LENGTH 60 + +#define WTS_LISTENER_CREATE 0x00000001 +#define WTS_LISTENER_UPDATE 0x00000010 + +#define WTS_SECURITY_QUERY_INFORMATION 0x00000001 +#define WTS_SECURITY_SET_INFORMATION 0x00000002 +#define WTS_SECURITY_RESET 0x00000004 +#define WTS_SECURITY_VIRTUAL_CHANNELS 0x00000008 +#define WTS_SECURITY_REMOTE_CONTROL 0x00000010 +#define WTS_SECURITY_LOGON 0x00000020 +#define WTS_SECURITY_LOGOFF 0x00000040 +#define WTS_SECURITY_MESSAGE 0x00000080 +#define WTS_SECURITY_CONNECT 0x00000100 +#define WTS_SECURITY_DISCONNECT 0x00000200 + +#define WTS_SECURITY_GUEST_ACCESS (WTS_SECURITY_LOGON) + +#define WTS_SECURITY_CURRENT_GUEST_ACCESS (WTS_SECURITY_VIRTUAL_CHANNELS | WTS_SECURITY_LOGOFF) + +#define WTS_SECURITY_USER_ACCESS \ + (WTS_SECURITY_CURRENT_GUEST_ACCESS | WTS_SECURITY_QUERY_INFORMATION | WTS_SECURITY_CONNECT) + +#define WTS_SECURITY_CURRENT_USER_ACCESS \ + (WTS_SECURITY_SET_INFORMATION | WTS_SECURITY_RESET WTS_SECURITY_VIRTUAL_CHANNELS | \ + WTS_SECURITY_LOGOFF WTS_SECURITY_DISCONNECT) + +#define WTS_SECURITY_ALL_ACCESS \ + (STANDARD_RIGHTS_REQUIRED | WTS_SECURITY_QUERY_INFORMATION | WTS_SECURITY_SET_INFORMATION | \ + WTS_SECURITY_RESET | WTS_SECURITY_VIRTUAL_CHANNELS | WTS_SECURITY_REMOTE_CONTROL | \ + WTS_SECURITY_LOGON | WTS_SECURITY_MESSAGE | WTS_SECURITY_CONNECT | WTS_SECURITY_DISCONNECT) + +typedef enum +{ + WTSActive, + WTSConnected, + WTSConnectQuery, + WTSShadow, + WTSDisconnected, + WTSIdle, + WTSListen, + WTSReset, + WTSDown, + WTSInit +} WTS_CONNECTSTATE_CLASS; + +typedef struct +{ + LPWSTR pServerName; +} WTS_SERVER_INFOW, *PWTS_SERVER_INFOW; + +typedef struct +{ + LPSTR pServerName; +} WTS_SERVER_INFOA, *PWTS_SERVER_INFOA; + +typedef struct +{ + DWORD SessionId; + LPWSTR pWinStationName; + WTS_CONNECTSTATE_CLASS State; +} WTS_SESSION_INFOW, *PWTS_SESSION_INFOW; + +typedef struct +{ + DWORD SessionId; + LPSTR pWinStationName; + WTS_CONNECTSTATE_CLASS State; +} WTS_SESSION_INFOA, *PWTS_SESSION_INFOA; + +typedef struct +{ + DWORD ExecEnvId; + WTS_CONNECTSTATE_CLASS State; + DWORD SessionId; + LPWSTR pSessionName; + LPWSTR pHostName; + LPWSTR pUserName; + LPWSTR pDomainName; + LPWSTR pFarmName; +} WTS_SESSION_INFO_1W, *PWTS_SESSION_INFO_1W; + +typedef struct +{ + DWORD ExecEnvId; + WTS_CONNECTSTATE_CLASS State; + DWORD SessionId; + LPSTR pSessionName; + LPSTR pHostName; + LPSTR pUserName; + LPSTR pDomainName; + LPSTR pFarmName; +} WTS_SESSION_INFO_1A, *PWTS_SESSION_INFO_1A; + +typedef struct +{ + DWORD SessionId; + DWORD ProcessId; + LPWSTR pProcessName; + PSID pUserSid; +} WTS_PROCESS_INFOW, *PWTS_PROCESS_INFOW; + +typedef struct +{ + DWORD SessionId; + DWORD ProcessId; + LPSTR pProcessName; + PSID pUserSid; +} WTS_PROCESS_INFOA, *PWTS_PROCESS_INFOA; + +#define WTS_PROTOCOL_TYPE_CONSOLE 0 +#define WTS_PROTOCOL_TYPE_ICA 1 +#define WTS_PROTOCOL_TYPE_RDP 2 + +typedef enum +{ + WTSInitialProgram, + WTSApplicationName, + WTSWorkingDirectory, + WTSOEMId, + WTSSessionId, + WTSUserName, + WTSWinStationName, + WTSDomainName, + WTSConnectState, + WTSClientBuildNumber, + WTSClientName, + WTSClientDirectory, + WTSClientProductId, + WTSClientHardwareId, + WTSClientAddress, + WTSClientDisplay, + WTSClientProtocolType, + WTSIdleTime, + WTSLogonTime, + WTSIncomingBytes, + WTSOutgoingBytes, + WTSIncomingFrames, + WTSOutgoingFrames, + WTSClientInfo, + WTSSessionInfo, + WTSSessionInfoEx, + WTSConfigInfo, + WTSValidationInfo, + WTSSessionAddressV4, + WTSIsRemoteSession +} WTS_INFO_CLASS; + +typedef struct +{ + ULONG version; + ULONG fConnectClientDrivesAtLogon; + ULONG fConnectPrinterAtLogon; + ULONG fDisablePrinterRedirection; + ULONG fDisableDefaultMainClientPrinter; + ULONG ShadowSettings; + WCHAR LogonUserName[USERNAME_LENGTH + 1]; + WCHAR LogonDomain[DOMAIN_LENGTH + 1]; + WCHAR WorkDirectory[MAX_PATH + 1]; + WCHAR InitialProgram[MAX_PATH + 1]; + WCHAR ApplicationName[MAX_PATH + 1]; +} WTSCONFIGINFOW, *PWTSCONFIGINFOW; + +typedef struct +{ + ULONG version; + ULONG fConnectClientDrivesAtLogon; + ULONG fConnectPrinterAtLogon; + ULONG fDisablePrinterRedirection; + ULONG fDisableDefaultMainClientPrinter; + ULONG ShadowSettings; + CHAR LogonUserName[USERNAME_LENGTH + 1]; + CHAR LogonDomain[DOMAIN_LENGTH + 1]; + CHAR WorkDirectory[MAX_PATH + 1]; + CHAR InitialProgram[MAX_PATH + 1]; + CHAR ApplicationName[MAX_PATH + 1]; +} WTSCONFIGINFOA, *PWTSCONFIGINFOA; + +typedef struct +{ + WTS_CONNECTSTATE_CLASS State; + DWORD SessionId; + DWORD IncomingBytes; + DWORD OutgoingBytes; + DWORD IncomingFrames; + DWORD OutgoingFrames; + DWORD IncomingCompressedBytes; + DWORD OutgoingCompressedBytes; + WCHAR WinStationName[WINSTATIONNAME_LENGTH]; + WCHAR Domain[DOMAIN_LENGTH]; + WCHAR UserName[USERNAME_LENGTH + 1]; + LARGE_INTEGER ConnectTime; + LARGE_INTEGER DisconnectTime; + LARGE_INTEGER LastInputTime; + LARGE_INTEGER LogonTime; + LARGE_INTEGER _CurrentTime; /* Conflicts with X11 headers */ +} WTSINFOW, *PWTSINFOW; + +typedef struct +{ + WTS_CONNECTSTATE_CLASS State; + DWORD SessionId; + DWORD IncomingBytes; + DWORD OutgoingBytes; + DWORD IncomingFrames; + DWORD OutgoingFrames; + DWORD IncomingCompressedBytes; + DWORD OutgoingCompressedBy; + CHAR WinStationName[WINSTATIONNAME_LENGTH]; + CHAR Domain[DOMAIN_LENGTH]; + CHAR UserName[USERNAME_LENGTH + 1]; + LARGE_INTEGER ConnectTime; + LARGE_INTEGER DisconnectTime; + LARGE_INTEGER LastInputTime; + LARGE_INTEGER LogonTime; + LARGE_INTEGER _CurrentTime; /* Conflicts with X11 headers */ +} WTSINFOA, *PWTSINFOA; + +#define WTS_SESSIONSTATE_UNKNOWN 0xFFFFFFFF +#define WTS_SESSIONSTATE_LOCK 0x00000000 +#define WTS_SESSIONSTATE_UNLOCK 0x00000001 + +typedef struct +{ + ULONG SessionId; + WTS_CONNECTSTATE_CLASS SessionState; + LONG SessionFlags; + WCHAR WinStationName[WINSTATIONNAME_LENGTH + 1]; + WCHAR UserName[USERNAME_LENGTH + 1]; + WCHAR DomainName[DOMAIN_LENGTH + 1]; + LARGE_INTEGER LogonTime; + LARGE_INTEGER ConnectTime; + LARGE_INTEGER DisconnectTime; + LARGE_INTEGER LastInputTime; + LARGE_INTEGER _CurrentTime; /* Conflicts with X11 headers */ + DWORD IncomingBytes; + DWORD OutgoingBytes; + DWORD IncomingFrames; + DWORD OutgoingFrames; + DWORD IncomingCompressedBytes; + DWORD OutgoingCompressedBytes; +} WTSINFOEX_LEVEL1_W, *PWTSINFOEX_LEVEL1_W; + +typedef struct +{ + ULONG SessionId; + WTS_CONNECTSTATE_CLASS SessionState; + LONG SessionFlags; + CHAR WinStationName[WINSTATIONNAME_LENGTH + 1]; + CHAR UserName[USERNAME_LENGTH + 1]; + CHAR DomainName[DOMAIN_LENGTH + 1]; + LARGE_INTEGER LogonTime; + LARGE_INTEGER ConnectTime; + LARGE_INTEGER DisconnectTime; + LARGE_INTEGER LastInputTime; + LARGE_INTEGER _CurrentTime; /* Conflicts with X11 headers */ + DWORD IncomingBytes; + DWORD OutgoingBytes; + DWORD IncomingFrames; + DWORD OutgoingFrames; + DWORD IncomingCompressedBytes; + DWORD OutgoingCompressedBytes; +} WTSINFOEX_LEVEL1_A, *PWTSINFOEX_LEVEL1_A; + +typedef union +{ + WTSINFOEX_LEVEL1_W WTSInfoExLevel1; +} WTSINFOEX_LEVEL_W, *PWTSINFOEX_LEVEL_W; + +typedef union +{ + WTSINFOEX_LEVEL1_A WTSInfoExLevel1; +} WTSINFOEX_LEVEL_A, *PWTSINFOEX_LEVEL_A; + +typedef struct +{ + DWORD Level; + WTSINFOEX_LEVEL_W Data; +} WTSINFOEXW, *PWTSINFOEXW; + +typedef struct +{ + DWORD Level; + WTSINFOEX_LEVEL_A Data; +} WTSINFOEXA, *PWTSINFOEXA; + +typedef struct +{ + WCHAR ClientName[CLIENTNAME_LENGTH + 1]; + WCHAR Domain[DOMAIN_LENGTH + 1]; + WCHAR UserName[USERNAME_LENGTH + 1]; + WCHAR WorkDirectory[MAX_PATH + 1]; + WCHAR InitialProgram[MAX_PATH + 1]; + BYTE EncryptionLevel; + ULONG ClientAddressFamily; + USHORT ClientAddress[CLIENTADDRESS_LENGTH + 1]; + USHORT HRes; + USHORT VRes; + USHORT ColorDepth; + WCHAR ClientDirectory[MAX_PATH + 1]; + ULONG ClientBuildNumber; + ULONG ClientHardwareId; + USHORT ClientProductId; + USHORT OutBufCountHost; + USHORT OutBufCountClient; + USHORT OutBufLength; + WCHAR DeviceId[MAX_PATH + 1]; +} WTSCLIENTW, *PWTSCLIENTW; + +typedef struct +{ + CHAR ClientName[CLIENTNAME_LENGTH + 1]; + CHAR Domain[DOMAIN_LENGTH + 1]; + CHAR UserName[USERNAME_LENGTH + 1]; + CHAR WorkDirectory[MAX_PATH + 1]; + CHAR InitialProgram[MAX_PATH + 1]; + BYTE EncryptionLevel; + ULONG ClientAddressFamily; + USHORT ClientAddress[CLIENTADDRESS_LENGTH + 1]; + USHORT HRes; + USHORT VRes; + USHORT ColorDepth; + CHAR ClientDirectory[MAX_PATH + 1]; + ULONG ClientBuildNumber; + ULONG ClientHardwareId; + USHORT ClientProductId; + USHORT OutBufCountHost; + USHORT OutBufCountClient; + USHORT OutBufLength; + CHAR DeviceId[MAX_PATH + 1]; +} WTSCLIENTA, *PWTSCLIENTA; + +#define PRODUCTINFO_COMPANYNAME_LENGTH 256 +#define PRODUCTINFO_PRODUCTID_LENGTH 4 + +typedef struct +{ + CHAR CompanyName[PRODUCTINFO_COMPANYNAME_LENGTH]; + CHAR ProductID[PRODUCTINFO_PRODUCTID_LENGTH]; +} PRODUCT_INFOA; + +typedef struct +{ + WCHAR CompanyName[PRODUCTINFO_COMPANYNAME_LENGTH]; + WCHAR ProductID[PRODUCTINFO_PRODUCTID_LENGTH]; +} PRODUCT_INFOW; + +#define VALIDATIONINFORMATION_LICENSE_LENGTH 16384 +#define VALIDATIONINFORMATION_HARDWAREID_LENGTH 20 + +typedef struct +{ + PRODUCT_INFOA ProductInfo; + BYTE License[VALIDATIONINFORMATION_LICENSE_LENGTH]; + DWORD LicenseLength; + BYTE HardwareID[VALIDATIONINFORMATION_HARDWAREID_LENGTH]; + DWORD HardwareIDLength; +} WTS_VALIDATION_INFORMATIONA, *PWTS_VALIDATION_INFORMATIONA; + +typedef struct +{ + PRODUCT_INFOW ProductInfo; + BYTE License[VALIDATIONINFORMATION_LICENSE_LENGTH]; + DWORD LicenseLength; + BYTE HardwareID[VALIDATIONINFORMATION_HARDWAREID_LENGTH]; + DWORD HardwareIDLength; +} WTS_VALIDATION_INFORMATIONW, *PWTS_VALIDATION_INFORMATIONW; + +typedef struct +{ + DWORD AddressFamily; + BYTE Address[20]; +} WTS_CLIENT_ADDRESS, *PWTS_CLIENT_ADDRESS; + +typedef struct +{ + DWORD HorizontalResolution; + DWORD VerticalResolution; + DWORD ColorDepth; +} WTS_CLIENT_DISPLAY, *PWTS_CLIENT_DISPLAY; + +typedef enum +{ + WTSUserConfigInitialProgram, + WTSUserConfigWorkingDirectory, + WTSUserConfigfInheritInitialProgram, + WTSUserConfigfAllowLogonTerminalServer, + WTSUserConfigTimeoutSettingsConnections, + WTSUserConfigTimeoutSettingsDisconnections, + WTSUserConfigTimeoutSettingsIdle, + WTSUserConfigfDeviceClientDrives, + WTSUserConfigfDeviceClientPrinters, + WTSUserConfigfDeviceClientDefaultPrinter, + WTSUserConfigBrokenTimeoutSettings, + WTSUserConfigReconnectSettings, + WTSUserConfigModemCallbackSettings, + WTSUserConfigModemCallbackPhoneNumber, + WTSUserConfigShadowingSettings, + WTSUserConfigTerminalServerProfilePath, + WTSUserConfigTerminalServerHomeDir, + WTSUserConfigTerminalServerHomeDirDrive, + WTSUserConfigfTerminalServerRemoteHomeDir, + WTSUserConfigUser +} WTS_CONFIG_CLASS; + +typedef enum +{ + WTSUserConfigSourceSAM +} WTS_CONFIG_SOURCE; + +typedef struct +{ + DWORD Source; + DWORD InheritInitialProgram; + DWORD AllowLogonTerminalServer; + DWORD TimeoutSettingsConnections; + DWORD TimeoutSettingsDisconnections; + DWORD TimeoutSettingsIdle; + DWORD DeviceClientDrives; + DWORD DeviceClientPrinters; + DWORD ClientDefaultPrinter; + DWORD BrokenTimeoutSettings; + DWORD ReconnectSettings; + DWORD ShadowingSettings; + DWORD TerminalServerRemoteHomeDir; + CHAR InitialProgram[MAX_PATH + 1]; + CHAR WorkDirectory[MAX_PATH + 1]; + CHAR TerminalServerProfilePath[MAX_PATH + 1]; + CHAR TerminalServerHomeDir[MAX_PATH + 1]; + CHAR TerminalServerHomeDirDrive[WTS_DRIVE_LENGTH + 1]; +} WTSUSERCONFIGA, *PWTSUSERCONFIGA; + +typedef struct +{ + DWORD Source; + DWORD InheritInitialProgram; + DWORD AllowLogonTerminalServer; + DWORD TimeoutSettingsConnections; + DWORD TimeoutSettingsDisconnections; + DWORD TimeoutSettingsIdle; + DWORD DeviceClientDrives; + DWORD DeviceClientPrinters; + DWORD ClientDefaultPrinter; + DWORD BrokenTimeoutSettings; + DWORD ReconnectSettings; + DWORD ShadowingSettings; + DWORD TerminalServerRemoteHomeDir; + WCHAR InitialProgram[MAX_PATH + 1]; + WCHAR WorkDirectory[MAX_PATH + 1]; + WCHAR TerminalServerProfilePath[MAX_PATH + 1]; + WCHAR TerminalServerHomeDir[MAX_PATH + 1]; + WCHAR TerminalServerHomeDirDrive[WTS_DRIVE_LENGTH + 1]; +} WTSUSERCONFIGW, *PWTSUSERCONFIGW; + +#define WTS_EVENT_NONE 0x00000000 +#define WTS_EVENT_CREATE 0x00000001 +#define WTS_EVENT_DELETE 0x00000002 +#define WTS_EVENT_RENAME 0x00000004 +#define WTS_EVENT_CONNECT 0x00000008 +#define WTS_EVENT_DISCONNECT 0x00000010 +#define WTS_EVENT_LOGON 0x00000020 +#define WTS_EVENT_LOGOFF 0x00000040 +#define WTS_EVENT_STATECHANGE 0x00000080 +#define WTS_EVENT_LICENSE 0x00000100 +#define WTS_EVENT_ALL 0x7FFFFFFF +#define WTS_EVENT_FLUSH 0x80000000 + +#define REMOTECONTROL_KBDSHIFT_HOTKEY 0x1 +#define REMOTECONTROL_KBDCTRL_HOTKEY 0x2 +#define REMOTECONTROL_KBDALT_HOTKEY 0x4 + +typedef enum +{ + WTSVirtualClientData, + WTSVirtualFileHandle, + WTSVirtualEventHandle, /* Extended */ + WTSVirtualChannelReady, /* Extended */ + WTSVirtualChannelOpenStatus /* Extended */ +} WTS_VIRTUAL_CLASS; + +typedef struct +{ + DWORD AddressFamily; + BYTE Address[20]; +} WTS_SESSION_ADDRESS, *PWTS_SESSION_ADDRESS; + +#define WTS_CHANNEL_OPTION_DYNAMIC 0x00000001 +#define WTS_CHANNEL_OPTION_DYNAMIC_PRI_LOW 0x00000000 +#define WTS_CHANNEL_OPTION_DYNAMIC_PRI_MED 0x00000002 +#define WTS_CHANNEL_OPTION_DYNAMIC_PRI_HIGH 0x00000004 +#define WTS_CHANNEL_OPTION_DYNAMIC_PRI_REAL 0x00000006 +#define WTS_CHANNEL_OPTION_DYNAMIC_NO_COMPRESS 0x00000008 + +#define NOTIFY_FOR_ALL_SESSIONS 1 +#define NOTIFY_FOR_THIS_SESSION 0 + +#define WTS_PROCESS_INFO_LEVEL_0 0 +#define WTS_PROCESS_INFO_LEVEL_1 1 + +typedef struct +{ + DWORD SessionId; + DWORD ProcessId; + LPWSTR pProcessName; + PSID pUserSid; + DWORD NumberOfThreads; + DWORD HandleCount; + DWORD PagefileUsage; + DWORD PeakPagefileUsage; + DWORD WorkingSetSize; + DWORD PeakWorkingSetSize; + LARGE_INTEGER UserTime; + LARGE_INTEGER KernelTime; +} WTS_PROCESS_INFO_EXW, *PWTS_PROCESS_INFO_EXW; + +typedef struct +{ + DWORD SessionId; + DWORD ProcessId; + LPSTR pProcessName; + PSID pUserSid; + DWORD NumberOfThreads; + DWORD HandleCount; + DWORD PagefileUsage; + DWORD PeakPagefileUsage; + DWORD WorkingSetSize; + DWORD PeakWorkingSetSize; + LARGE_INTEGER UserTime; + LARGE_INTEGER KernelTime; +} WTS_PROCESS_INFO_EXA, *PWTS_PROCESS_INFO_EXA; + +typedef enum +{ + WTSTypeProcessInfoLevel0, + WTSTypeProcessInfoLevel1, + WTSTypeSessionInfoLevel1 +} WTS_TYPE_CLASS; + +typedef WCHAR WTSLISTENERNAMEW[WTS_LISTENER_NAME_LENGTH + 1]; +typedef WTSLISTENERNAMEW* PWTSLISTENERNAMEW; +typedef CHAR WTSLISTENERNAMEA[WTS_LISTENER_NAME_LENGTH + 1]; +typedef WTSLISTENERNAMEA* PWTSLISTENERNAMEA; + +typedef struct +{ + ULONG version; + ULONG fEnableListener; + ULONG MaxConnectionCount; + ULONG fPromptForPassword; + ULONG fInheritColorDepth; + ULONG ColorDepth; + ULONG fInheritBrokenTimeoutSettings; + ULONG BrokenTimeoutSettings; + ULONG fDisablePrinterRedirection; + ULONG fDisableDriveRedirection; + ULONG fDisableComPortRedirection; + ULONG fDisableLPTPortRedirection; + ULONG fDisableClipboardRedirection; + ULONG fDisableAudioRedirection; + ULONG fDisablePNPRedirection; + ULONG fDisableDefaultMainClientPrinter; + ULONG LanAdapter; + ULONG PortNumber; + ULONG fInheritShadowSettings; + ULONG ShadowSettings; + ULONG TimeoutSettingsConnection; + ULONG TimeoutSettingsDisconnection; + ULONG TimeoutSettingsIdle; + ULONG SecurityLayer; + ULONG MinEncryptionLevel; + ULONG UserAuthentication; + WCHAR Comment[WTS_COMMENT_LENGTH + 1]; + WCHAR LogonUserName[USERNAME_LENGTH + 1]; + WCHAR LogonDomain[DOMAIN_LENGTH + 1]; + WCHAR WorkDirectory[MAX_PATH + 1]; + WCHAR InitialProgram[MAX_PATH + 1]; +} WTSLISTENERCONFIGW, *PWTSLISTENERCONFIGW; + +typedef struct +{ + ULONG version; + ULONG fEnableListener; + ULONG MaxConnectionCount; + ULONG fPromptForPassword; + ULONG fInheritColorDepth; + ULONG ColorDepth; + ULONG fInheritBrokenTimeoutSettings; + ULONG BrokenTimeoutSettings; + ULONG fDisablePrinterRedirection; + ULONG fDisableDriveRedirection; + ULONG fDisableComPortRedirection; + ULONG fDisableLPTPortRedirection; + ULONG fDisableClipboardRedirection; + ULONG fDisableAudioRedirection; + ULONG fDisablePNPRedirection; + ULONG fDisableDefaultMainClientPrinter; + ULONG LanAdapter; + ULONG PortNumber; + ULONG fInheritShadowSettings; + ULONG ShadowSettings; + ULONG TimeoutSettingsConnection; + ULONG TimeoutSettingsDisconnection; + ULONG TimeoutSettingsIdle; + ULONG SecurityLayer; + ULONG MinEncryptionLevel; + ULONG UserAuthentication; + CHAR Comment[WTS_COMMENT_LENGTH + 1]; + CHAR LogonUserName[USERNAME_LENGTH + 1]; + CHAR LogonDomain[DOMAIN_LENGTH + 1]; + CHAR WorkDirectory[MAX_PATH + 1]; + CHAR InitialProgram[MAX_PATH + 1]; +} WTSLISTENERCONFIGA, *PWTSLISTENERCONFIGA; + +#ifdef UNICODE +#define WTS_SERVER_INFO WTS_SERVER_INFOW +#define PWTS_SERVER_INFO PWTS_SERVER_INFOW +#define WTS_SESSION_INFO WTS_SESSION_INFOW +#define PWTS_SESSION_INFO PWTS_SESSION_INFOW +#define WTS_SESSION_INFO_1 WTS_SESSION_INFO_1W +#define PWTS_SESSION_INFO_1 PWTS_SESSION_INFO_1W +#define WTS_PROCESS_INFO WTS_PROCESS_INFOW +#define PWTS_PROCESS_INFO PWTS_PROCESS_INFOW +#define WTSCONFIGINFO WTSCONFIGINFOW +#define PWTSCONFIGINFO PWTSCONFIGINFOW +#define WTSINFO WTSINFOW +#define PWTSINFO PWTSINFOW +#define WTSINFOEX WTSINFOEXW +#define PWTSINFOEX PWTSINFOEXW +#define WTSINFOEX_LEVEL WTSINFOEX_LEVEL_W +#define PWTSINFOEX_LEVEL PWTSINFOEX_LEVEL_W +#define WTSINFOEX_LEVEL1 WTSINFOEX_LEVEL1_W +#define PWTSINFOEX_LEVEL1 PWTSINFOEX_LEVEL1_W +#define WTSCLIENT WTSCLIENTW +#define PWTSCLIENT PWTSCLIENTW +#define PRODUCT_INFO PRODUCT_INFOW +#define WTS_VALIDATION_INFORMATION WTS_VALIDATION_INFORMATIONW +#define PWTS_VALIDATION_INFORMATION PWTS_VALIDATION_INFORMATIONW +#define WTSUSERCONFIG WTSUSERCONFIGW +#define PWTSUSERCONFIG PWTSUSERCONFIGW +#define WTS_PROCESS_INFO_EX WTS_PROCESS_INFO_EXW +#define PWTS_PROCESS_INFO_EX PWTS_PROCESS_INFO_EXW +#define WTSLISTENERNAME WTSLISTENERNAMEW +#define PWTSLISTENERNAME PWTSLISTENERNAMEW +#define WTSLISTENERCONFIG WTSLISTENERCONFIGW +#define PWTSLISTENERCONFIG PWTSLISTENERCONFIGW +#else +#define WTS_SERVER_INFO WTS_SERVER_INFOA +#define PWTS_SERVER_INFO PWTS_SERVER_INFOA +#define WTS_SESSION_INFO WTS_SESSION_INFOA +#define PWTS_SESSION_INFO PWTS_SESSION_INFOA +#define WTS_SESSION_INFO_1 WTS_SESSION_INFO_1A +#define PWTS_SESSION_INFO_1 PWTS_SESSION_INFO_1A +#define WTS_PROCESS_INFO WTS_PROCESS_INFOA +#define PWTS_PROCESS_INFO PWTS_PROCESS_INFOA +#define WTSCONFIGINFO WTSCONFIGINFOA +#define PWTSCONFIGINFO PWTSCONFIGINFOA +#define WTSINFO WTSINFOA +#define PWTSINFO PWTSINFOA +#define WTSINFOEX WTSINFOEXA +#define PWTSINFOEX PWTSINFOEXA +#define WTSINFOEX_LEVEL WTSINFOEX_LEVEL_A +#define PWTSINFOEX_LEVEL PWTSINFOEX_LEVEL_A +#define WTSINFOEX_LEVEL1 WTSINFOEX_LEVEL1_A +#define PWTSINFOEX_LEVEL1 PWTSINFOEX_LEVEL1_A +#define WTSCLIENT WTSCLIENTA +#define PWTSCLIENT PWTSCLIENTA +#define PRODUCT_INFO PRODUCT_INFOA +#define WTS_VALIDATION_INFORMATION WTS_VALIDATION_INFORMATIONA +#define PWTS_VALIDATION_INFORMATION PWTS_VALIDATION_INFORMATIONA +#define WTSUSERCONFIG WTSUSERCONFIGA +#define PWTSUSERCONFIG PWTSUSERCONFIGA +#define WTS_PROCESS_INFO_EX WTS_PROCESS_INFO_EXA +#define PWTS_PROCESS_INFO_EX PWTS_PROCESS_INFO_EXA +#define WTSLISTENERNAME WTSLISTENERNAMEA +#define PWTSLISTENERNAME PWTSLISTENERNAMEA +#define WTSLISTENERCONFIG WTSLISTENERCONFIGA +#define PWTSLISTENERCONFIG PWTSLISTENERCONFIGA +#endif + +#define REMOTECONTROL_FLAG_DISABLE_KEYBOARD 0x00000001 +#define REMOTECONTROL_FLAG_DISABLE_MOUSE 0x00000002 +#define REMOTECONTROL_FLAG_DISABLE_INPUT \ + REMOTECONTROL_FLAG_DISABLE_KEYBOARD | REMOTECONTROL_FLAG_DISABLE_MOUSE + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API BOOL WINAPI WTSStopRemoteControlSession(ULONG LogonId); + + WINPR_API BOOL WINAPI WTSStartRemoteControlSessionW(LPWSTR pTargetServerName, + ULONG TargetLogonId, BYTE HotkeyVk, + USHORT HotkeyModifiers); + WINPR_API BOOL WINAPI WTSStartRemoteControlSessionA(LPSTR pTargetServerName, + ULONG TargetLogonId, BYTE HotkeyVk, + USHORT HotkeyModifiers); + + WINPR_API BOOL WINAPI WTSStartRemoteControlSessionExW(LPWSTR pTargetServerName, + ULONG TargetLogonId, BYTE HotkeyVk, + USHORT HotkeyModifiers, DWORD flags); + WINPR_API BOOL WINAPI WTSStartRemoteControlSessionExA(LPSTR pTargetServerName, + ULONG TargetLogonId, BYTE HotkeyVk, + USHORT HotkeyModifiers, DWORD flags); + + WINPR_API BOOL WINAPI WTSConnectSessionW(ULONG LogonId, ULONG TargetLogonId, PWSTR pPassword, + BOOL bWait); + WINPR_API BOOL WINAPI WTSConnectSessionA(ULONG LogonId, ULONG TargetLogonId, PSTR pPassword, + BOOL bWait); + + WINPR_API BOOL WINAPI WTSEnumerateServersW(LPWSTR pDomainName, DWORD Reserved, DWORD Version, + PWTS_SERVER_INFOW* ppServerInfo, DWORD* pCount); + WINPR_API BOOL WINAPI WTSEnumerateServersA(LPSTR pDomainName, DWORD Reserved, DWORD Version, + PWTS_SERVER_INFOA* ppServerInfo, DWORD* pCount); + + WINPR_API HANDLE WINAPI WTSOpenServerW(LPWSTR pServerName); + WINPR_API HANDLE WINAPI WTSOpenServerA(LPSTR pServerName); + + WINPR_API HANDLE WINAPI WTSOpenServerExW(LPWSTR pServerName); + WINPR_API HANDLE WINAPI WTSOpenServerExA(LPSTR pServerName); + + WINPR_API VOID WINAPI WTSCloseServer(HANDLE hServer); + + WINPR_API BOOL WINAPI WTSEnumerateSessionsW(HANDLE hServer, DWORD Reserved, DWORD Version, + PWTS_SESSION_INFOW* ppSessionInfo, DWORD* pCount); + WINPR_API BOOL WINAPI WTSEnumerateSessionsA(HANDLE hServer, DWORD Reserved, DWORD Version, + PWTS_SESSION_INFOA* ppSessionInfo, DWORD* pCount); + + WINPR_API BOOL WINAPI WTSEnumerateSessionsExW(HANDLE hServer, DWORD* pLevel, DWORD Filter, + PWTS_SESSION_INFO_1W* ppSessionInfo, + DWORD* pCount); + WINPR_API BOOL WINAPI WTSEnumerateSessionsExA(HANDLE hServer, DWORD* pLevel, DWORD Filter, + PWTS_SESSION_INFO_1A* ppSessionInfo, + DWORD* pCount); + + WINPR_API BOOL WINAPI WTSEnumerateProcessesW(HANDLE hServer, DWORD Reserved, DWORD Version, + PWTS_PROCESS_INFOW* ppProcessInfo, DWORD* pCount); + WINPR_API BOOL WINAPI WTSEnumerateProcessesA(HANDLE hServer, DWORD Reserved, DWORD Version, + PWTS_PROCESS_INFOA* ppProcessInfo, DWORD* pCount); + + WINPR_API BOOL WINAPI WTSTerminateProcess(HANDLE hServer, DWORD ProcessId, DWORD ExitCode); + + WINPR_API BOOL WINAPI WTSQuerySessionInformationW(HANDLE hServer, DWORD SessionId, + WTS_INFO_CLASS WTSInfoClass, LPWSTR* ppBuffer, + DWORD* pBytesReturned); + WINPR_API BOOL WINAPI WTSQuerySessionInformationA(HANDLE hServer, DWORD SessionId, + WTS_INFO_CLASS WTSInfoClass, LPSTR* ppBuffer, + DWORD* pBytesReturned); + + WINPR_API BOOL WINAPI WTSQueryUserConfigW(LPWSTR pServerName, LPWSTR pUserName, + WTS_CONFIG_CLASS WTSConfigClass, LPWSTR* ppBuffer, + DWORD* pBytesReturned); + WINPR_API BOOL WINAPI WTSQueryUserConfigA(LPSTR pServerName, LPSTR pUserName, + WTS_CONFIG_CLASS WTSConfigClass, LPSTR* ppBuffer, + DWORD* pBytesReturned); + + WINPR_API BOOL WINAPI WTSSetUserConfigW(LPWSTR pServerName, LPWSTR pUserName, + WTS_CONFIG_CLASS WTSConfigClass, LPWSTR pBuffer, + DWORD DataLength); + WINPR_API BOOL WINAPI WTSSetUserConfigA(LPSTR pServerName, LPSTR pUserName, + WTS_CONFIG_CLASS WTSConfigClass, LPSTR pBuffer, + DWORD DataLength); + + WINPR_API BOOL WINAPI WTSSendMessageW(HANDLE hServer, DWORD SessionId, LPWSTR pTitle, + DWORD TitleLength, LPWSTR pMessage, DWORD MessageLength, + DWORD Style, DWORD Timeout, DWORD* pResponse, BOOL bWait); + WINPR_API BOOL WINAPI WTSSendMessageA(HANDLE hServer, DWORD SessionId, LPSTR pTitle, + DWORD TitleLength, LPSTR pMessage, DWORD MessageLength, + DWORD Style, DWORD Timeout, DWORD* pResponse, BOOL bWait); + + WINPR_API BOOL WINAPI WTSDisconnectSession(HANDLE hServer, DWORD SessionId, BOOL bWait); + + WINPR_API BOOL WINAPI WTSLogoffSession(HANDLE hServer, DWORD SessionId, BOOL bWait); + + WINPR_API BOOL WINAPI WTSShutdownSystem(HANDLE hServer, DWORD ShutdownFlag); + + WINPR_API BOOL WINAPI WTSWaitSystemEvent(HANDLE hServer, DWORD EventMask, DWORD* pEventFlags); + + WINPR_API HANDLE WINAPI WTSVirtualChannelOpen(HANDLE hServer, DWORD SessionId, + LPSTR pVirtualName); + + WINPR_API HANDLE WINAPI WTSVirtualChannelOpenEx(DWORD SessionId, LPSTR pVirtualName, + DWORD flags); + + WINPR_API BOOL WINAPI WTSVirtualChannelClose(HANDLE hChannelHandle); + + WINPR_API BOOL WINAPI WTSVirtualChannelRead(HANDLE hChannelHandle, ULONG TimeOut, PCHAR Buffer, + ULONG BufferSize, PULONG pBytesRead); + + WINPR_API BOOL WINAPI WTSVirtualChannelWrite(HANDLE hChannelHandle, PCHAR Buffer, ULONG Length, + PULONG pBytesWritten); + + WINPR_API BOOL WINAPI WTSVirtualChannelPurgeInput(HANDLE hChannelHandle); + + WINPR_API BOOL WINAPI WTSVirtualChannelPurgeOutput(HANDLE hChannelHandle); + + WINPR_API BOOL WINAPI WTSVirtualChannelQuery(HANDLE hChannelHandle, + WTS_VIRTUAL_CLASS WtsVirtualClass, PVOID* ppBuffer, + DWORD* pBytesReturned); + + WINPR_API VOID WINAPI WTSFreeMemory(PVOID pMemory); + + WINPR_API BOOL WINAPI WTSRegisterSessionNotification(HWND hWnd, DWORD dwFlags); + + WINPR_API BOOL WINAPI WTSUnRegisterSessionNotification(HWND hWnd); + + WINPR_API BOOL WINAPI WTSRegisterSessionNotificationEx(HANDLE hServer, HWND hWnd, + DWORD dwFlags); + + WINPR_API BOOL WINAPI WTSUnRegisterSessionNotificationEx(HANDLE hServer, HWND hWnd); + + WINPR_API BOOL WINAPI WTSQueryUserToken(ULONG SessionId, PHANDLE phToken); + + WINPR_API BOOL WINAPI WTSFreeMemoryExW(WTS_TYPE_CLASS WTSTypeClass, PVOID pMemory, + ULONG NumberOfEntries); + WINPR_API BOOL WINAPI WTSFreeMemoryExA(WTS_TYPE_CLASS WTSTypeClass, PVOID pMemory, + ULONG NumberOfEntries); + + WINPR_API BOOL WINAPI WTSEnumerateProcessesExW(HANDLE hServer, DWORD* pLevel, DWORD SessionId, + LPWSTR* ppProcessInfo, DWORD* pCount); + WINPR_API BOOL WINAPI WTSEnumerateProcessesExA(HANDLE hServer, DWORD* pLevel, DWORD SessionId, + LPSTR* ppProcessInfo, DWORD* pCount); + + WINPR_API BOOL WINAPI WTSEnumerateListenersW(HANDLE hServer, PVOID pReserved, DWORD Reserved, + PWTSLISTENERNAMEW pListeners, DWORD* pCount); + WINPR_API BOOL WINAPI WTSEnumerateListenersA(HANDLE hServer, PVOID pReserved, DWORD Reserved, + PWTSLISTENERNAMEA pListeners, DWORD* pCount); + + WINPR_API BOOL WINAPI WTSQueryListenerConfigW(HANDLE hServer, PVOID pReserved, DWORD Reserved, + LPWSTR pListenerName, + PWTSLISTENERCONFIGW pBuffer); + WINPR_API BOOL WINAPI WTSQueryListenerConfigA(HANDLE hServer, PVOID pReserved, DWORD Reserved, + LPSTR pListenerName, PWTSLISTENERCONFIGA pBuffer); + + WINPR_API BOOL WINAPI WTSCreateListenerW(HANDLE hServer, PVOID pReserved, DWORD Reserved, + LPWSTR pListenerName, PWTSLISTENERCONFIGW pBuffer, + DWORD flag); + WINPR_API BOOL WINAPI WTSCreateListenerA(HANDLE hServer, PVOID pReserved, DWORD Reserved, + LPSTR pListenerName, PWTSLISTENERCONFIGA pBuffer, + DWORD flag); + + WINPR_API BOOL WINAPI WTSSetListenerSecurityW(HANDLE hServer, PVOID pReserved, DWORD Reserved, + LPWSTR pListenerName, + SECURITY_INFORMATION SecurityInformation, + PSECURITY_DESCRIPTOR pSecurityDescriptor); + WINPR_API BOOL WINAPI WTSSetListenerSecurityA(HANDLE hServer, PVOID pReserved, DWORD Reserved, + LPSTR pListenerName, + SECURITY_INFORMATION SecurityInformation, + PSECURITY_DESCRIPTOR pSecurityDescriptor); + + WINPR_API BOOL WINAPI WTSGetListenerSecurityW(HANDLE hServer, PVOID pReserved, DWORD Reserved, + LPWSTR pListenerName, + SECURITY_INFORMATION SecurityInformation, + PSECURITY_DESCRIPTOR pSecurityDescriptor, + DWORD nLength, LPDWORD lpnLengthNeeded); + WINPR_API BOOL WINAPI WTSGetListenerSecurityA(HANDLE hServer, PVOID pReserved, DWORD Reserved, + LPSTR pListenerName, + SECURITY_INFORMATION SecurityInformation, + PSECURITY_DESCRIPTOR pSecurityDescriptor, + DWORD nLength, LPDWORD lpnLengthNeeded); + + /** + * WTSEnableChildSessions, WTSIsChildSessionsEnabled and WTSGetChildSessionId + * are not explicitly declared as WINAPI like other WTSAPI functions. + * Since they are declared as extern "C", we explicitly declare them as CDECL. + */ + + WINPR_API BOOL CDECL WTSEnableChildSessions(BOOL bEnable); + + WINPR_API BOOL CDECL WTSIsChildSessionsEnabled(PBOOL pbEnabled); + + WINPR_API BOOL CDECL WTSGetChildSessionId(PULONG pSessionId); + + WINPR_API BOOL CDECL WTSLogonUser(HANDLE hServer, LPCSTR username, LPCSTR password, + LPCSTR domain); + + WINPR_API BOOL CDECL WTSLogoffUser(HANDLE hServer); + +#ifdef __cplusplus +} +#endif + +#ifdef UNICODE +#define WTSStartRemoteControlSession WTSStartRemoteControlSessionW +#define WTSStartRemoteControlSessionEx WTSStartRemoteControlSessionExW +#define WTSConnectSession WTSConnectSessionW +#define WTSEnumerateServers WTSEnumerateServersW +#define WTSOpenServer WTSOpenServerW +#define WTSOpenServerEx WTSOpenServerExW +#define WTSEnumerateSessions WTSEnumerateSessionsW +#define WTSEnumerateSessionsEx WTSEnumerateSessionsExW +#define WTSEnumerateProcesses WTSEnumerateProcessesW +#define WTSQuerySessionInformation WTSQuerySessionInformationW +#define WTSQueryUserConfig WTSQueryUserConfigW +#define WTSSetUserConfig WTSSetUserConfigW +#define WTSSendMessage WTSSendMessageW +#define WTSFreeMemoryEx WTSFreeMemoryExW +#define WTSEnumerateProcessesEx WTSEnumerateProcessesExW +#define WTSEnumerateListeners WTSEnumerateListenersW +#define WTSQueryListenerConfig WTSQueryListenerConfigW +#define WTSCreateListener WTSCreateListenerW +#define WTSSetListenerSecurity WTSSetListenerSecurityW +#define WTSGetListenerSecurity WTSGetListenerSecurityW +#else +#define WTSStartRemoteControlSession WTSStartRemoteControlSessionA +#define WTSStartRemoteControlSessionEx WTSStartRemoteControlSessionExA +#define WTSConnectSession WTSConnectSessionA +#define WTSEnumerateServers WTSEnumerateServersA +#define WTSOpenServer WTSOpenServerA +#define WTSOpenServerEx WTSOpenServerExA +#define WTSEnumerateSessions WTSEnumerateSessionsA +#define WTSEnumerateSessionsEx WTSEnumerateSessionsExA +#define WTSEnumerateProcesses WTSEnumerateProcessesA +#define WTSQuerySessionInformation WTSQuerySessionInformationA +#define WTSQueryUserConfig WTSQueryUserConfigA +#define WTSSetUserConfig WTSSetUserConfigA +#define WTSSendMessage WTSSendMessageA +#define WTSFreeMemoryEx WTSFreeMemoryExA +#define WTSEnumerateProcessesEx WTSEnumerateProcessesExA +#define WTSEnumerateListeners WTSEnumerateListenersA +#define WTSQueryListenerConfig WTSQueryListenerConfigA +#define WTSCreateListener WTSCreateListenerA +#define WTSSetListenerSecurity WTSSetListenerSecurityA +#define WTSGetListenerSecurity WTSGetListenerSecurityA +#endif + +#endif + +#ifndef _WIN32 + +/** + * WTSGetActiveConsoleSessionId is declared in WinBase.h + * and exported by kernel32.dll, so we have to treat it separately. + */ + +WINPR_API DWORD WINAPI WTSGetActiveConsoleSessionId(void); + +#endif + +typedef BOOL(WINAPI* WTS_STOP_REMOTE_CONTROL_SESSION_FN)(ULONG LogonId); + +typedef BOOL(WINAPI* WTS_START_REMOTE_CONTROL_SESSION_FN_W)(LPWSTR pTargetServerName, + ULONG TargetLogonId, BYTE HotkeyVk, + USHORT HotkeyModifiers); +typedef BOOL(WINAPI* WTS_START_REMOTE_CONTROL_SESSION_FN_A)(LPSTR pTargetServerName, + ULONG TargetLogonId, BYTE HotkeyVk, + USHORT HotkeyModifiers); + +typedef BOOL(WINAPI* WTS_START_REMOTE_CONTROL_SESSION_EX_FN_W)(LPWSTR pTargetServerName, + ULONG TargetLogonId, BYTE HotkeyVk, + USHORT HotkeyModifiers, DWORD flags); +typedef BOOL(WINAPI* WTS_START_REMOTE_CONTROL_SESSION_EX_FN_A)(LPSTR pTargetServerName, + ULONG TargetLogonId, BYTE HotkeyVk, + USHORT HotkeyModifiers, DWORD flags); + +typedef BOOL(WINAPI* WTS_CONNECT_SESSION_FN_W)(ULONG LogonId, ULONG TargetLogonId, PWSTR pPassword, + BOOL bWait); +typedef BOOL(WINAPI* WTS_CONNECT_SESSION_FN_A)(ULONG LogonId, ULONG TargetLogonId, PSTR pPassword, + BOOL bWait); + +typedef BOOL(WINAPI* WTS_ENUMERATE_SERVERS_FN_W)(LPWSTR pDomainName, DWORD Reserved, DWORD Version, + PWTS_SERVER_INFOW* ppServerInfo, DWORD* pCount); +typedef BOOL(WINAPI* WTS_ENUMERATE_SERVERS_FN_A)(LPSTR pDomainName, DWORD Reserved, DWORD Version, + PWTS_SERVER_INFOA* ppServerInfo, DWORD* pCount); + +typedef HANDLE(WINAPI* WTS_OPEN_SERVER_FN_W)(LPWSTR pServerName); +typedef HANDLE(WINAPI* WTS_OPEN_SERVER_FN_A)(LPSTR pServerName); + +typedef HANDLE(WINAPI* WTS_OPEN_SERVER_EX_FN_W)(LPWSTR pServerName); +typedef HANDLE(WINAPI* WTS_OPEN_SERVER_EX_FN_A)(LPSTR pServerName); + +typedef VOID(WINAPI* WTS_CLOSE_SERVER_FN)(HANDLE hServer); + +typedef BOOL(WINAPI* WTS_ENUMERATE_SESSIONS_FN_W)(HANDLE hServer, DWORD Reserved, DWORD Version, + PWTS_SESSION_INFOW* ppSessionInfo, DWORD* pCount); +typedef BOOL(WINAPI* WTS_ENUMERATE_SESSIONS_FN_A)(HANDLE hServer, DWORD Reserved, DWORD Version, + PWTS_SESSION_INFOA* ppSessionInfo, DWORD* pCount); + +typedef BOOL(WINAPI* WTS_ENUMERATE_SESSIONS_EX_FN_W)(HANDLE hServer, DWORD* pLevel, DWORD Filter, + PWTS_SESSION_INFO_1W* ppSessionInfo, + DWORD* pCount); +typedef BOOL(WINAPI* WTS_ENUMERATE_SESSIONS_EX_FN_A)(HANDLE hServer, DWORD* pLevel, DWORD Filter, + PWTS_SESSION_INFO_1A* ppSessionInfo, + DWORD* pCount); + +typedef BOOL(WINAPI* WTS_ENUMERATE_PROCESSES_FN_W)(HANDLE hServer, DWORD Reserved, DWORD Version, + PWTS_PROCESS_INFOW* ppProcessInfo, + DWORD* pCount); +typedef BOOL(WINAPI* WTS_ENUMERATE_PROCESSES_FN_A)(HANDLE hServer, DWORD Reserved, DWORD Version, + PWTS_PROCESS_INFOA* ppProcessInfo, + DWORD* pCount); + +typedef BOOL(WINAPI* WTS_TERMINATE_PROCESS_FN)(HANDLE hServer, DWORD ProcessId, DWORD ExitCode); + +typedef BOOL(WINAPI* WTS_QUERY_SESSION_INFORMATION_FN_W)(HANDLE hServer, DWORD SessionId, + WTS_INFO_CLASS WTSInfoClass, + LPWSTR* ppBuffer, DWORD* pBytesReturned); +typedef BOOL(WINAPI* WTS_QUERY_SESSION_INFORMATION_FN_A)(HANDLE hServer, DWORD SessionId, + WTS_INFO_CLASS WTSInfoClass, + LPSTR* ppBuffer, DWORD* pBytesReturned); + +typedef BOOL(WINAPI* WTS_QUERY_USER_CONFIG_FN_W)(LPWSTR pServerName, LPWSTR pUserName, + WTS_CONFIG_CLASS WTSConfigClass, LPWSTR* ppBuffer, + DWORD* pBytesReturned); +typedef BOOL(WINAPI* WTS_QUERY_USER_CONFIG_FN_A)(LPSTR pServerName, LPSTR pUserName, + WTS_CONFIG_CLASS WTSConfigClass, LPSTR* ppBuffer, + DWORD* pBytesReturned); + +typedef BOOL(WINAPI* WTS_SET_USER_CONFIG_FN_W)(LPWSTR pServerName, LPWSTR pUserName, + WTS_CONFIG_CLASS WTSConfigClass, LPWSTR pBuffer, + DWORD DataLength); +typedef BOOL(WINAPI* WTS_SET_USER_CONFIG_FN_A)(LPSTR pServerName, LPSTR pUserName, + WTS_CONFIG_CLASS WTSConfigClass, LPSTR pBuffer, + DWORD DataLength); + +typedef BOOL(WINAPI* WTS_SEND_MESSAGE_FN_W)(HANDLE hServer, DWORD SessionId, LPWSTR pTitle, + DWORD TitleLength, LPWSTR pMessage, DWORD MessageLength, + DWORD Style, DWORD Timeout, DWORD* pResponse, + BOOL bWait); +typedef BOOL(WINAPI* WTS_SEND_MESSAGE_FN_A)(HANDLE hServer, DWORD SessionId, LPSTR pTitle, + DWORD TitleLength, LPSTR pMessage, DWORD MessageLength, + DWORD Style, DWORD Timeout, DWORD* pResponse, + BOOL bWait); + +typedef BOOL(WINAPI* WTS_DISCONNECT_SESSION_FN)(HANDLE hServer, DWORD SessionId, BOOL bWait); + +typedef BOOL(WINAPI* WTS_LOGOFF_SESSION_FN)(HANDLE hServer, DWORD SessionId, BOOL bWait); + +typedef BOOL(WINAPI* WTS_SHUTDOWN_SYSTEM_FN)(HANDLE hServer, DWORD ShutdownFlag); + +typedef BOOL(WINAPI* WTS_WAIT_SYSTEM_EVENT_FN)(HANDLE hServer, DWORD EventMask, DWORD* pEventFlags); + +typedef HANDLE(WINAPI* WTS_VIRTUAL_CHANNEL_OPEN_FN)(HANDLE hServer, DWORD SessionId, + LPSTR pVirtualName); + +typedef HANDLE(WINAPI* WTS_VIRTUAL_CHANNEL_OPEN_EX_FN)(DWORD SessionId, LPSTR pVirtualName, + DWORD flags); + +typedef BOOL(WINAPI* WTS_VIRTUAL_CHANNEL_CLOSE_FN)(HANDLE hChannelHandle); + +typedef BOOL(WINAPI* WTS_VIRTUAL_CHANNEL_READ_FN)(HANDLE hChannelHandle, ULONG TimeOut, + PCHAR Buffer, ULONG BufferSize, + PULONG pBytesRead); + +typedef BOOL(WINAPI* WTS_VIRTUAL_CHANNEL_WRITE_FN)(HANDLE hChannelHandle, PCHAR Buffer, + ULONG Length, PULONG pBytesWritten); + +typedef BOOL(WINAPI* WTS_VIRTUAL_CHANNEL_PURGE_INPUT_FN)(HANDLE hChannelHandle); + +typedef BOOL(WINAPI* WTS_VIRTUAL_CHANNEL_PURGE_OUTPUT_FN)(HANDLE hChannelHandle); + +typedef BOOL(WINAPI* WTS_VIRTUAL_CHANNEL_QUERY_FN)(HANDLE hChannelHandle, + WTS_VIRTUAL_CLASS WtsVirtualClass, + PVOID* ppBuffer, DWORD* pBytesReturned); + +typedef VOID(WINAPI* WTS_FREE_MEMORY_FN)(PVOID pMemory); + +typedef BOOL(WINAPI* WTS_REGISTER_SESSION_NOTIFICATION_FN)(HWND hWnd, DWORD dwFlags); + +typedef BOOL(WINAPI* WTS_UNREGISTER_SESSION_NOTIFICATION_FN)(HWND hWnd); + +typedef BOOL(WINAPI* WTS_REGISTER_SESSION_NOTIFICATION_EX_FN)(HANDLE hServer, HWND hWnd, + DWORD dwFlags); + +typedef BOOL(WINAPI* WTS_UNREGISTER_SESSION_NOTIFICATION_EX_FN)(HANDLE hServer, HWND hWnd); + +typedef BOOL(WINAPI* WTS_QUERY_USER_TOKEN_FN)(ULONG SessionId, PHANDLE phToken); + +typedef BOOL(WINAPI* WTS_FREE_MEMORY_EX_FN_W)(WTS_TYPE_CLASS WTSTypeClass, PVOID pMemory, + ULONG NumberOfEntries); +typedef BOOL(WINAPI* WTS_FREE_MEMORY_EX_FN_A)(WTS_TYPE_CLASS WTSTypeClass, PVOID pMemory, + ULONG NumberOfEntries); + +typedef BOOL(WINAPI* WTS_ENUMERATE_PROCESSES_EX_FN_W)(HANDLE hServer, DWORD* pLevel, + DWORD SessionId, LPWSTR* ppProcessInfo, + DWORD* pCount); +typedef BOOL(WINAPI* WTS_ENUMERATE_PROCESSES_EX_FN_A)(HANDLE hServer, DWORD* pLevel, + DWORD SessionId, LPSTR* ppProcessInfo, + DWORD* pCount); + +typedef BOOL(WINAPI* WTS_ENUMERATE_LISTENERS_FN_W)(HANDLE hServer, PVOID pReserved, DWORD Reserved, + PWTSLISTENERNAMEW pListeners, DWORD* pCount); +typedef BOOL(WINAPI* WTS_ENUMERATE_LISTENERS_FN_A)(HANDLE hServer, PVOID pReserved, DWORD Reserved, + PWTSLISTENERNAMEA pListeners, DWORD* pCount); + +typedef BOOL(WINAPI* WTS_QUERY_LISTENER_CONFIG_FN_W)(HANDLE hServer, PVOID pReserved, + DWORD Reserved, LPWSTR pListenerName, + PWTSLISTENERCONFIGW pBuffer); +typedef BOOL(WINAPI* WTS_QUERY_LISTENER_CONFIG_FN_A)(HANDLE hServer, PVOID pReserved, + DWORD Reserved, LPSTR pListenerName, + PWTSLISTENERCONFIGA pBuffer); + +typedef BOOL(WINAPI* WTS_CREATE_LISTENER_FN_W)(HANDLE hServer, PVOID pReserved, DWORD Reserved, + LPWSTR pListenerName, PWTSLISTENERCONFIGW pBuffer, + DWORD flag); +typedef BOOL(WINAPI* WTS_CREATE_LISTENER_FN_A)(HANDLE hServer, PVOID pReserved, DWORD Reserved, + LPSTR pListenerName, PWTSLISTENERCONFIGA pBuffer, + DWORD flag); + +typedef BOOL(WINAPI* WTS_SET_LISTENER_SECURITY_FN_W)(HANDLE hServer, PVOID pReserved, + DWORD Reserved, LPWSTR pListenerName, + SECURITY_INFORMATION SecurityInformation, + PSECURITY_DESCRIPTOR pSecurityDescriptor); +typedef BOOL(WINAPI* WTS_SET_LISTENER_SECURITY_FN_A)(HANDLE hServer, PVOID pReserved, + DWORD Reserved, LPSTR pListenerName, + SECURITY_INFORMATION SecurityInformation, + PSECURITY_DESCRIPTOR pSecurityDescriptor); + +typedef BOOL(WINAPI* WTS_GET_LISTENER_SECURITY_FN_W)(HANDLE hServer, PVOID pReserved, + DWORD Reserved, LPWSTR pListenerName, + SECURITY_INFORMATION SecurityInformation, + PSECURITY_DESCRIPTOR pSecurityDescriptor, + DWORD nLength, LPDWORD lpnLengthNeeded); +typedef BOOL(WINAPI* WTS_GET_LISTENER_SECURITY_FN_A)(HANDLE hServer, PVOID pReserved, + DWORD Reserved, LPSTR pListenerName, + SECURITY_INFORMATION SecurityInformation, + PSECURITY_DESCRIPTOR pSecurityDescriptor, + DWORD nLength, LPDWORD lpnLengthNeeded); + +typedef BOOL(CDECL* WTS_ENABLE_CHILD_SESSIONS_FN)(BOOL bEnable); + +typedef BOOL(CDECL* WTS_IS_CHILD_SESSIONS_ENABLED_FN)(PBOOL pbEnabled); + +typedef BOOL(CDECL* WTS_GET_CHILD_SESSION_ID_FN)(PULONG pSessionId); + +typedef DWORD(WINAPI* WTS_GET_ACTIVE_CONSOLE_SESSION_ID_FN)(void); + +typedef BOOL(WINAPI* WTS_LOGON_USER_FN)(HANDLE hServer, LPCSTR username, LPCSTR password, + LPCSTR domain); + +typedef BOOL(WINAPI* WTS_LOGOFF_USER_FN)(HANDLE hServer); + +typedef struct +{ + DWORD dwVersion; + DWORD dwFlags; + + WTS_STOP_REMOTE_CONTROL_SESSION_FN pStopRemoteControlSession; + WTS_START_REMOTE_CONTROL_SESSION_FN_W pStartRemoteControlSessionW; + WTS_START_REMOTE_CONTROL_SESSION_FN_A pStartRemoteControlSessionA; + WTS_CONNECT_SESSION_FN_W pConnectSessionW; + WTS_CONNECT_SESSION_FN_A pConnectSessionA; + WTS_ENUMERATE_SERVERS_FN_W pEnumerateServersW; + WTS_ENUMERATE_SERVERS_FN_A pEnumerateServersA; + WTS_OPEN_SERVER_FN_W pOpenServerW; + WTS_OPEN_SERVER_FN_A pOpenServerA; + WTS_OPEN_SERVER_EX_FN_W pOpenServerExW; + WTS_OPEN_SERVER_EX_FN_A pOpenServerExA; + WTS_CLOSE_SERVER_FN pCloseServer; + WTS_ENUMERATE_SESSIONS_FN_W pEnumerateSessionsW; + WTS_ENUMERATE_SESSIONS_FN_A pEnumerateSessionsA; + WTS_ENUMERATE_SESSIONS_EX_FN_W pEnumerateSessionsExW; + WTS_ENUMERATE_SESSIONS_EX_FN_A pEnumerateSessionsExA; + WTS_ENUMERATE_PROCESSES_FN_W pEnumerateProcessesW; + WTS_ENUMERATE_PROCESSES_FN_A pEnumerateProcessesA; + WTS_TERMINATE_PROCESS_FN pTerminateProcess; + WTS_QUERY_SESSION_INFORMATION_FN_W pQuerySessionInformationW; + WTS_QUERY_SESSION_INFORMATION_FN_A pQuerySessionInformationA; + WTS_QUERY_USER_CONFIG_FN_W pQueryUserConfigW; + WTS_QUERY_USER_CONFIG_FN_A pQueryUserConfigA; + WTS_SET_USER_CONFIG_FN_W pSetUserConfigW; + WTS_SET_USER_CONFIG_FN_A pSetUserConfigA; + WTS_SEND_MESSAGE_FN_W pSendMessageW; + WTS_SEND_MESSAGE_FN_A pSendMessageA; + WTS_DISCONNECT_SESSION_FN pDisconnectSession; + WTS_LOGOFF_SESSION_FN pLogoffSession; + WTS_SHUTDOWN_SYSTEM_FN pShutdownSystem; + WTS_WAIT_SYSTEM_EVENT_FN pWaitSystemEvent; + WTS_VIRTUAL_CHANNEL_OPEN_FN pVirtualChannelOpen; + WTS_VIRTUAL_CHANNEL_OPEN_EX_FN pVirtualChannelOpenEx; + WTS_VIRTUAL_CHANNEL_CLOSE_FN pVirtualChannelClose; + WTS_VIRTUAL_CHANNEL_READ_FN pVirtualChannelRead; + WTS_VIRTUAL_CHANNEL_WRITE_FN pVirtualChannelWrite; + WTS_VIRTUAL_CHANNEL_PURGE_INPUT_FN pVirtualChannelPurgeInput; + WTS_VIRTUAL_CHANNEL_PURGE_OUTPUT_FN pVirtualChannelPurgeOutput; + WTS_VIRTUAL_CHANNEL_QUERY_FN pVirtualChannelQuery; + WTS_FREE_MEMORY_FN pFreeMemory; + WTS_REGISTER_SESSION_NOTIFICATION_FN pRegisterSessionNotification; + WTS_UNREGISTER_SESSION_NOTIFICATION_FN pUnRegisterSessionNotification; + WTS_REGISTER_SESSION_NOTIFICATION_EX_FN pRegisterSessionNotificationEx; + WTS_UNREGISTER_SESSION_NOTIFICATION_EX_FN pUnRegisterSessionNotificationEx; + WTS_QUERY_USER_TOKEN_FN pQueryUserToken; + WTS_FREE_MEMORY_EX_FN_W pFreeMemoryExW; + WTS_FREE_MEMORY_EX_FN_A pFreeMemoryExA; + WTS_ENUMERATE_PROCESSES_EX_FN_W pEnumerateProcessesExW; + WTS_ENUMERATE_PROCESSES_EX_FN_A pEnumerateProcessesExA; + WTS_ENUMERATE_LISTENERS_FN_W pEnumerateListenersW; + WTS_ENUMERATE_LISTENERS_FN_A pEnumerateListenersA; + WTS_QUERY_LISTENER_CONFIG_FN_W pQueryListenerConfigW; + WTS_QUERY_LISTENER_CONFIG_FN_A pQueryListenerConfigA; + WTS_CREATE_LISTENER_FN_W pCreateListenerW; + WTS_CREATE_LISTENER_FN_A pCreateListenerA; + WTS_SET_LISTENER_SECURITY_FN_W pSetListenerSecurityW; + WTS_SET_LISTENER_SECURITY_FN_A pSetListenerSecurityA; + WTS_GET_LISTENER_SECURITY_FN_W pGetListenerSecurityW; + WTS_GET_LISTENER_SECURITY_FN_A pGetListenerSecurityA; + WTS_ENABLE_CHILD_SESSIONS_FN pEnableChildSessions; + WTS_IS_CHILD_SESSIONS_ENABLED_FN pIsChildSessionsEnabled; + WTS_GET_CHILD_SESSION_ID_FN pGetChildSessionId; + WTS_GET_ACTIVE_CONSOLE_SESSION_ID_FN pGetActiveConsoleSessionId; + WTS_LOGON_USER_FN pLogonUser; + WTS_LOGOFF_USER_FN pLogoffUser; + WTS_START_REMOTE_CONTROL_SESSION_EX_FN_W pStartRemoteControlSessionExW; + WTS_START_REMOTE_CONTROL_SESSION_EX_FN_A pStartRemoteControlSessionExA; +} WtsApiFunctionTable; +typedef WtsApiFunctionTable* PWtsApiFunctionTable; + +typedef const WtsApiFunctionTable*(CDECL* INIT_WTSAPI_FN)(void); + +#ifdef __cplusplus +extern "C" +{ +#endif + + WINPR_API BOOL WTSRegisterWtsApiFunctionTable(const WtsApiFunctionTable* table); + WINPR_API const CHAR* WTSErrorToString(UINT error); + WINPR_API const CHAR* WTSSessionStateToString(WTS_CONNECTSTATE_CLASS state); + +#ifdef __cplusplus +} +#endif + +#endif /* WINPR_WTSAPI_H */ |