| 1 | // Licensed to the .NET Foundation under one or more agreements. |
| 2 | // The .NET Foundation licenses this file to you under the MIT license. |
| 3 | // See the LICENSE file in the project root for more information. |
| 4 | // |
| 5 | |
| 6 | // |
| 7 | // =========================================================================== |
| 8 | // File: palrt.h |
| 9 | // |
| 10 | // =========================================================================== |
| 11 | |
| 12 | /*++ |
| 13 | |
| 14 | |
| 15 | Abstract: |
| 16 | |
| 17 | PAL runtime functions. These are functions which are ordinarily |
| 18 | implemented as part of the Win32 API set, but when compiling CoreCLR for |
| 19 | Unix-like systems, are implemented as a runtime library on top of the PAL. |
| 20 | |
| 21 | Author: |
| 22 | |
| 23 | |
| 24 | |
| 25 | Revision History: |
| 26 | |
| 27 | --*/ |
| 28 | |
| 29 | #ifndef __PALRT_H__ |
| 30 | #define __PALRT_H__ |
| 31 | |
| 32 | /******************* HRESULTs *********************************************/ |
| 33 | |
| 34 | #ifdef RC_INVOKED |
| 35 | #define _HRESULT_TYPEDEF_(_sc) _sc |
| 36 | #else // RC_INVOKED |
| 37 | #define _HRESULT_TYPEDEF_(_sc) ((HRESULT)_sc) |
| 38 | #endif // RC_INVOKED |
| 39 | |
| 40 | #define S_OK _HRESULT_TYPEDEF_(0x00000000L) |
| 41 | #define S_FALSE _HRESULT_TYPEDEF_(0x00000001L) |
| 42 | |
| 43 | #define E_NOTIMPL _HRESULT_TYPEDEF_(0x80004001L) |
| 44 | #define E_NOINTERFACE _HRESULT_TYPEDEF_(0x80004002L) |
| 45 | #define E_UNEXPECTED _HRESULT_TYPEDEF_(0x8000FFFFL) |
| 46 | #define E_OUTOFMEMORY _HRESULT_TYPEDEF_(0x8007000EL) |
| 47 | #define E_INVALIDARG _HRESULT_TYPEDEF_(0x80070057L) |
| 48 | #define E_POINTER _HRESULT_TYPEDEF_(0x80004003L) |
| 49 | #define E_HANDLE _HRESULT_TYPEDEF_(0x80070006L) |
| 50 | #define E_ABORT _HRESULT_TYPEDEF_(0x80004004L) |
| 51 | #define E_FAIL _HRESULT_TYPEDEF_(0x80004005L) |
| 52 | #define E_ACCESSDENIED _HRESULT_TYPEDEF_(0x80070005L) |
| 53 | #define E_PENDING _HRESULT_TYPEDEF_(0x8000000AL) |
| 54 | |
| 55 | #define DISP_E_PARAMNOTFOUND _HRESULT_TYPEDEF_(0x80020004L) |
| 56 | #define DISP_E_TYPEMISMATCH _HRESULT_TYPEDEF_(0x80020005L) |
| 57 | #define DISP_E_BADVARTYPE _HRESULT_TYPEDEF_(0x80020008L) |
| 58 | #define DISP_E_OVERFLOW _HRESULT_TYPEDEF_(0x8002000AL) |
| 59 | #define DISP_E_DIVBYZERO _HRESULT_TYPEDEF_(0x80020012L) |
| 60 | |
| 61 | #define CLASS_E_CLASSNOTAVAILABLE _HRESULT_TYPEDEF_(0x80040111L) |
| 62 | #define CLASS_E_NOAGGREGATION _HRESULT_TYPEDEF_(0x80040110L) |
| 63 | |
| 64 | #define CO_E_CLASSSTRING _HRESULT_TYPEDEF_(0x800401F3L) |
| 65 | |
| 66 | #define MK_E_SYNTAX _HRESULT_TYPEDEF_(0x800401E4L) |
| 67 | |
| 68 | #define STG_E_INVALIDFUNCTION _HRESULT_TYPEDEF_(0x80030001L) |
| 69 | #define STG_E_FILENOTFOUND _HRESULT_TYPEDEF_(0x80030002L) |
| 70 | #define STG_E_PATHNOTFOUND _HRESULT_TYPEDEF_(0x80030003L) |
| 71 | #define STG_E_WRITEFAULT _HRESULT_TYPEDEF_(0x8003001DL) |
| 72 | #define STG_E_FILEALREADYEXISTS _HRESULT_TYPEDEF_(0x80030050L) |
| 73 | #define STG_E_ABNORMALAPIEXIT _HRESULT_TYPEDEF_(0x800300FAL) |
| 74 | |
| 75 | #define NTE_BAD_UID _HRESULT_TYPEDEF_(0x80090001L) |
| 76 | #define NTE_BAD_HASH _HRESULT_TYPEDEF_(0x80090002L) |
| 77 | #define NTE_BAD_KEY _HRESULT_TYPEDEF_(0x80090003L) |
| 78 | #define NTE_BAD_LEN _HRESULT_TYPEDEF_(0x80090004L) |
| 79 | #define NTE_BAD_DATA _HRESULT_TYPEDEF_(0x80090005L) |
| 80 | #define NTE_BAD_SIGNATURE _HRESULT_TYPEDEF_(0x80090006L) |
| 81 | #define NTE_BAD_VER _HRESULT_TYPEDEF_(0x80090007L) |
| 82 | #define NTE_BAD_ALGID _HRESULT_TYPEDEF_(0x80090008L) |
| 83 | #define NTE_BAD_FLAGS _HRESULT_TYPEDEF_(0x80090009L) |
| 84 | #define NTE_BAD_TYPE _HRESULT_TYPEDEF_(0x8009000AL) |
| 85 | #define NTE_BAD_KEY_STATE _HRESULT_TYPEDEF_(0x8009000BL) |
| 86 | #define NTE_BAD_HASH_STATE _HRESULT_TYPEDEF_(0x8009000CL) |
| 87 | #define NTE_NO_KEY _HRESULT_TYPEDEF_(0x8009000DL) |
| 88 | #define NTE_NO_MEMORY _HRESULT_TYPEDEF_(0x8009000EL) |
| 89 | #define NTE_SIGNATURE_FILE_BAD _HRESULT_TYPEDEF_(0x8009001CL) |
| 90 | #define NTE_FAIL _HRESULT_TYPEDEF_(0x80090020L) |
| 91 | |
| 92 | #define CRYPT_E_HASH_VALUE _HRESULT_TYPEDEF_(0x80091007L) |
| 93 | |
| 94 | #define TYPE_E_SIZETOOBIG _HRESULT_TYPEDEF_(0x800288C5L) |
| 95 | #define TYPE_E_DUPLICATEID _HRESULT_TYPEDEF_(0x800288C6L) |
| 96 | |
| 97 | #define STD_CTL_SCODE(n) MAKE_SCODE(SEVERITY_ERROR, FACILITY_CONTROL, n) |
| 98 | #define CTL_E_OVERFLOW STD_CTL_SCODE(6) |
| 99 | #define CTL_E_OUTOFMEMORY STD_CTL_SCODE(7) |
| 100 | #define CTL_E_DIVISIONBYZERO STD_CTL_SCODE(11) |
| 101 | #define CTL_E_OUTOFSTACKSPACE STD_CTL_SCODE(28) |
| 102 | #define CTL_E_FILENOTFOUND STD_CTL_SCODE(53) |
| 103 | #define CTL_E_DEVICEIOERROR STD_CTL_SCODE(57) |
| 104 | #define CTL_E_PERMISSIONDENIED STD_CTL_SCODE(70) |
| 105 | #define CTL_E_PATHFILEACCESSERROR STD_CTL_SCODE(75) |
| 106 | #define CTL_E_PATHNOTFOUND STD_CTL_SCODE(76) |
| 107 | |
| 108 | #define INET_E_CANNOT_CONNECT _HRESULT_TYPEDEF_(0x800C0004L) |
| 109 | #define INET_E_RESOURCE_NOT_FOUND _HRESULT_TYPEDEF_(0x800C0005L) |
| 110 | #define INET_E_OBJECT_NOT_FOUND _HRESULT_TYPEDEF_(0x800C0006L) |
| 111 | #define INET_E_DATA_NOT_AVAILABLE _HRESULT_TYPEDEF_(0x800C0007L) |
| 112 | #define INET_E_DOWNLOAD_FAILURE _HRESULT_TYPEDEF_(0x800C0008L) |
| 113 | #define INET_E_CONNECTION_TIMEOUT _HRESULT_TYPEDEF_(0x800C000BL) |
| 114 | #define INET_E_UNKNOWN_PROTOCOL _HRESULT_TYPEDEF_(0x800C000DL) |
| 115 | |
| 116 | #define DBG_PRINTEXCEPTION_C _HRESULT_TYPEDEF_(0x40010006L) |
| 117 | |
| 118 | /********************** errorrep.h ****************************************/ |
| 119 | |
| 120 | typedef enum tagEFaultRepRetVal |
| 121 | { |
| 122 | frrvOk = 0, |
| 123 | frrvOkManifest, |
| 124 | frrvOkQueued, |
| 125 | frrvErr, |
| 126 | frrvErrNoDW, |
| 127 | frrvErrTimeout, |
| 128 | frrvLaunchDebugger, |
| 129 | frrvOkHeadless, |
| 130 | frrvErrAnotherInstance |
| 131 | } EFaultRepRetVal; |
| 132 | |
| 133 | /**************************************************************************/ |
| 134 | |
| 135 | #ifndef RC_INVOKED |
| 136 | |
| 137 | #include "pal.h" |
| 138 | |
| 139 | #ifndef PAL_STDCPP_COMPAT |
| 140 | #ifdef __cplusplus |
| 141 | #ifndef __PLACEMENT_NEW_INLINE |
| 142 | #define __PLACEMENT_NEW_INLINE |
| 143 | inline void *__cdecl operator new(size_t, void *_P) |
| 144 | { |
| 145 | return (_P); |
| 146 | } |
| 147 | #endif // __PLACEMENT_NEW_INLINE |
| 148 | #endif // __cplusplus |
| 149 | #endif // !PAL_STDCPP_COMPAT |
| 150 | |
| 151 | #include <pal_assert.h> |
| 152 | |
| 153 | #define NTAPI __cdecl |
| 154 | #define WINAPI __cdecl |
| 155 | #define CALLBACK __cdecl |
| 156 | #define NTSYSAPI |
| 157 | |
| 158 | #define _WINNT_ |
| 159 | |
| 160 | // C++ standard, 18.1.5 - offsetof requires a POD (plain old data) struct or |
| 161 | // union. Since offsetof is a macro, gcc doesn't actually check for improper |
| 162 | // use of offsetof, it keys off of the -> from NULL (which is also invalid for |
| 163 | // non-POD types by 18.1.5) |
| 164 | // |
| 165 | // As we have numerous examples of this behavior in our codebase, |
| 166 | // making an offsetof which doesn't use 0. |
| 167 | |
| 168 | // PAL_safe_offsetof is a version of offsetof that protects against an |
| 169 | // overridden operator& |
| 170 | |
| 171 | #define FIELD_OFFSET(type, field) __builtin_offsetof(type, field) |
| 172 | #ifndef offsetof |
| 173 | #define offsetof(type, field) __builtin_offsetof(type, field) |
| 174 | #endif |
| 175 | #define PAL_safe_offsetof(type, field) __builtin_offsetof(type, field) |
| 176 | |
| 177 | #define CONTAINING_RECORD(address, type, field) \ |
| 178 | ((type *)((LONG_PTR)(address) - FIELD_OFFSET(type, field))) |
| 179 | |
| 180 | #define ARGUMENT_PRESENT(ArgumentPointer) (\ |
| 181 | (CHAR *)(ArgumentPointer) != (CHAR *)(NULL) ) |
| 182 | |
| 183 | #if defined(_WIN64) |
| 184 | #define MAX_NATURAL_ALIGNMENT sizeof(ULONGLONG) |
| 185 | #else |
| 186 | #define MAX_NATURAL_ALIGNMENT sizeof(ULONG) |
| 187 | #endif |
| 188 | |
| 189 | #define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name |
| 190 | |
| 191 | #ifndef COM_NO_WINDOWS_H |
| 192 | #define COM_NO_WINDOWS_H |
| 193 | #endif |
| 194 | |
| 195 | #define interface struct |
| 196 | |
| 197 | #define STDMETHODCALLTYPE __cdecl |
| 198 | #define STDMETHODVCALLTYPE __cdecl |
| 199 | |
| 200 | #define STDAPICALLTYPE __cdecl |
| 201 | #define STDAPIVCALLTYPE __cdecl |
| 202 | |
| 203 | #define STDMETHODIMP HRESULT STDMETHODCALLTYPE |
| 204 | #define STDMETHODIMP_(type) type STDMETHODCALLTYPE |
| 205 | |
| 206 | #define STDMETHODIMPV HRESULT STDMETHODVCALLTYPE |
| 207 | #define STDMETHODIMPV_(type) type STDMETHODVCALLTYPE |
| 208 | |
| 209 | #define STDMETHOD(method) virtual HRESULT STDMETHODCALLTYPE method |
| 210 | #define STDMETHOD_(type,method) virtual type STDMETHODCALLTYPE method |
| 211 | |
| 212 | #define STDMETHODV(method) virtual HRESULT STDMETHODVCALLTYPE method |
| 213 | #define STDMETHODV_(type,method) virtual type STDMETHODVCALLTYPE method |
| 214 | |
| 215 | #define STDAPI EXTERN_C HRESULT STDAPICALLTYPE |
| 216 | #define STDAPI_(type) EXTERN_C type STDAPICALLTYPE |
| 217 | |
| 218 | #define STDAPIV EXTERN_C HRESULT STDAPIVCALLTYPE |
| 219 | #define STDAPIV_(type) EXTERN_C type STDAPIVCALLTYPE |
| 220 | |
| 221 | #define PURE = 0 |
| 222 | #define THIS_ |
| 223 | #define THIS void |
| 224 | |
| 225 | #ifndef _DECLSPEC_DEFINED_ |
| 226 | #define _DECLSPEC_DEFINED_ |
| 227 | |
| 228 | #if defined(_MSC_VER) |
| 229 | #define DECLSPEC_NOVTABLE __declspec(novtable) |
| 230 | #define DECLSPEC_IMPORT __declspec(dllimport) |
| 231 | #define DECLSPEC_SELECTANY __declspec(selectany) |
| 232 | #elif defined(__GNUC__) |
| 233 | #define DECLSPEC_NOVTABLE |
| 234 | #define DECLSPEC_IMPORT |
| 235 | #define DECLSPEC_SELECTANY __attribute__((weak)) |
| 236 | #else |
| 237 | #define DECLSPEC_NOVTABLE |
| 238 | #define DECLSPEC_IMPORT |
| 239 | #define DECLSPEC_SELECTANY |
| 240 | #endif |
| 241 | |
| 242 | #endif // !_DECLSPEC_DEFINED_ |
| 243 | |
| 244 | #define DECLARE_INTERFACE(iface) interface DECLSPEC_NOVTABLE iface |
| 245 | #define DECLARE_INTERFACE_(iface, baseiface) interface DECLSPEC_NOVTABLE iface : public baseiface |
| 246 | |
| 247 | #ifdef __cplusplus |
| 248 | #define REFGUID const GUID & |
| 249 | #else |
| 250 | #define REFGUID const GUID * |
| 251 | #endif |
| 252 | |
| 253 | EXTERN_C const GUID GUID_NULL; |
| 254 | |
| 255 | typedef GUID *LPGUID; |
| 256 | typedef const GUID FAR *LPCGUID; |
| 257 | |
| 258 | #ifdef __cplusplus |
| 259 | extern "C++" { |
| 260 | #if !defined _SYS_GUID_OPERATOR_EQ_ && !defined _NO_SYS_GUID_OPERATOR_EQ_ |
| 261 | #define _SYS_GUID_OPERATOR_EQ_ |
| 262 | inline int IsEqualGUID(REFGUID rguid1, REFGUID rguid2) |
| 263 | { return !memcmp(&rguid1, &rguid2, sizeof(GUID)); } |
| 264 | inline int operator==(REFGUID guidOne, REFGUID guidOther) |
| 265 | { return IsEqualGUID(guidOne,guidOther); } |
| 266 | inline int operator!=(REFGUID guidOne, REFGUID guidOther) |
| 267 | { return !IsEqualGUID(guidOne,guidOther); } |
| 268 | #endif |
| 269 | }; |
| 270 | #endif // __cplusplus |
| 271 | |
| 272 | #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ |
| 273 | EXTERN_C const GUID FAR name |
| 274 | |
| 275 | typedef GUID IID; |
| 276 | #ifdef __cplusplus |
| 277 | #define REFIID const IID & |
| 278 | #else |
| 279 | #define REFIID const IID * |
| 280 | #endif |
| 281 | #define IID_NULL GUID_NULL |
| 282 | #define IsEqualIID(riid1, riid2) IsEqualGUID(riid1, riid2) |
| 283 | |
| 284 | #define __IID_DEFINED__ |
| 285 | |
| 286 | typedef GUID CLSID; |
| 287 | #define CLSID_DEFINED |
| 288 | #ifdef __cplusplus |
| 289 | #define REFCLSID const CLSID & |
| 290 | #else |
| 291 | #define REFCLSID const CLSID * |
| 292 | #endif |
| 293 | #define CLSID_NULL GUID_NULL |
| 294 | #define IsEqualCLSID(rclsid1, rclsid2) IsEqualGUID(rclsid1, rclsid2) |
| 295 | typedef CLSID *LPCLSID; |
| 296 | |
| 297 | typedef UINT_PTR WPARAM; |
| 298 | typedef LONG_PTR LRESULT; |
| 299 | |
| 300 | typedef LONG SCODE; |
| 301 | |
| 302 | |
| 303 | typedef union _ULARGE_INTEGER { |
| 304 | struct { |
| 305 | #if BIGENDIAN |
| 306 | DWORD HighPart; |
| 307 | DWORD LowPart; |
| 308 | #else |
| 309 | DWORD LowPart; |
| 310 | DWORD HighPart; |
| 311 | #endif |
| 312 | } |
| 313 | #ifndef PAL_STDCPP_COMPAT |
| 314 | u |
| 315 | #endif // PAL_STDCPP_COMPAT |
| 316 | ; |
| 317 | ULONGLONG QuadPart; |
| 318 | } ULARGE_INTEGER, *PULARGE_INTEGER; |
| 319 | |
| 320 | /******************* HRESULT types ****************************************/ |
| 321 | |
| 322 | #define FACILITY_WINDOWS 8 |
| 323 | #define FACILITY_URT 19 |
| 324 | #define FACILITY_UMI 22 |
| 325 | #define FACILITY_SXS 23 |
| 326 | #define FACILITY_STORAGE 3 |
| 327 | #define FACILITY_SSPI 9 |
| 328 | #define FACILITY_SCARD 16 |
| 329 | #define FACILITY_SETUPAPI 15 |
| 330 | #define FACILITY_SECURITY 9 |
| 331 | #define FACILITY_RPC 1 |
| 332 | #define FACILITY_WIN32 7 |
| 333 | #define FACILITY_CONTROL 10 |
| 334 | #define FACILITY_NULL 0 |
| 335 | #define FACILITY_MSMQ 14 |
| 336 | #define FACILITY_MEDIASERVER 13 |
| 337 | #define FACILITY_INTERNET 12 |
| 338 | #define FACILITY_ITF 4 |
| 339 | #define FACILITY_DPLAY 21 |
| 340 | #define FACILITY_DISPATCH 2 |
| 341 | #define FACILITY_COMPLUS 17 |
| 342 | #define FACILITY_CERT 11 |
| 343 | #define FACILITY_ACS 20 |
| 344 | #define FACILITY_AAF 18 |
| 345 | |
| 346 | #define NO_ERROR 0L |
| 347 | |
| 348 | #define SEVERITY_SUCCESS 0 |
| 349 | #define SEVERITY_ERROR 1 |
| 350 | |
| 351 | #define SUCCEEDED(Status) ((HRESULT)(Status) >= 0) |
| 352 | #define FAILED(Status) ((HRESULT)(Status)<0) |
| 353 | #define IS_ERROR(Status) ((ULONG)(Status) >> 31 == SEVERITY_ERROR) // diff from win32 |
| 354 | #define HRESULT_CODE(hr) ((hr) & 0xFFFF) |
| 355 | #define SCODE_CODE(sc) ((sc) & 0xFFFF) |
| 356 | #define HRESULT_FACILITY(hr) (((hr) >> 16) & 0x1fff) |
| 357 | #define SCODE_FACILITY(sc) (((sc) >> 16) & 0x1fff) |
| 358 | #define HRESULT_SEVERITY(hr) (((hr) >> 31) & 0x1) |
| 359 | #define SCODE_SEVERITY(sc) (((sc) >> 31) & 0x1) |
| 360 | |
| 361 | // both macros diff from Win32 |
| 362 | #define MAKE_HRESULT(sev,fac,code) \ |
| 363 | ((HRESULT) (((ULONG)(sev)<<31) | ((ULONG)(fac)<<16) | ((ULONG)(code))) ) |
| 364 | #define MAKE_SCODE(sev,fac,code) \ |
| 365 | ((SCODE) (((ULONG)(sev)<<31) | ((ULONG)(fac)<<16) | ((LONG)(code))) ) |
| 366 | |
| 367 | #define FACILITY_NT_BIT 0x10000000 |
| 368 | #define HRESULT_FROM_WIN32(x) ((HRESULT)(x) <= 0 ? ((HRESULT)(x)) : ((HRESULT) (((x) & 0x0000FFFF) | (FACILITY_WIN32 << 16) | 0x80000000))) |
| 369 | #define __HRESULT_FROM_WIN32(x) HRESULT_FROM_WIN32(x) |
| 370 | |
| 371 | #define HRESULT_FROM_NT(x) ((HRESULT) ((x) | FACILITY_NT_BIT)) |
| 372 | |
| 373 | /******************* OLE, BSTR, VARIANT *************************/ |
| 374 | |
| 375 | STDAPI_(LPVOID) CoTaskMemAlloc(SIZE_T cb); |
| 376 | STDAPI_(LPVOID) CoTaskMemRealloc(LPVOID pv, SIZE_T cb); |
| 377 | STDAPI_(void) CoTaskMemFree(LPVOID pv); |
| 378 | |
| 379 | typedef SHORT VARIANT_BOOL; |
| 380 | #define VARIANT_TRUE ((VARIANT_BOOL)-1) |
| 381 | #define VARIANT_FALSE ((VARIANT_BOOL)0) |
| 382 | |
| 383 | typedef WCHAR OLECHAR; |
| 384 | typedef OLECHAR* LPOLESTR; |
| 385 | typedef const OLECHAR* LPCOLESTR; |
| 386 | |
| 387 | typedef WCHAR *BSTR; |
| 388 | |
| 389 | STDAPI_(BSTR) SysAllocString(const OLECHAR*); |
| 390 | STDAPI_(BSTR) SysAllocStringLen(const OLECHAR*, UINT); |
| 391 | STDAPI_(BSTR) SysAllocStringByteLen(const char *, UINT); |
| 392 | STDAPI_(void) SysFreeString(BSTR); |
| 393 | STDAPI_(UINT) SysStringLen(BSTR); |
| 394 | STDAPI_(UINT) SysStringByteLen(BSTR); |
| 395 | |
| 396 | typedef double DATE; |
| 397 | |
| 398 | typedef union tagCY { |
| 399 | struct { |
| 400 | #if BIGENDIAN |
| 401 | LONG Hi; |
| 402 | ULONG Lo; |
| 403 | #else |
| 404 | ULONG Lo; |
| 405 | LONG Hi; |
| 406 | #endif |
| 407 | } u; |
| 408 | LONGLONG int64; |
| 409 | } CY, *LPCY; |
| 410 | |
| 411 | typedef CY CURRENCY; |
| 412 | |
| 413 | typedef struct tagDEC { |
| 414 | // Decimal.cs treats the first two shorts as one long |
| 415 | // And they seriable the data so we need to little endian |
| 416 | // seriliazation |
| 417 | // The wReserved overlaps with Variant's vt member |
| 418 | #if BIGENDIAN |
| 419 | union { |
| 420 | struct { |
| 421 | BYTE sign; |
| 422 | BYTE scale; |
| 423 | } u; |
| 424 | USHORT signscale; |
| 425 | } u; |
| 426 | USHORT wReserved; |
| 427 | #else |
| 428 | USHORT wReserved; |
| 429 | union { |
| 430 | struct { |
| 431 | BYTE scale; |
| 432 | BYTE sign; |
| 433 | } u; |
| 434 | USHORT signscale; |
| 435 | } u; |
| 436 | #endif |
| 437 | ULONG Hi32; |
| 438 | union { |
| 439 | struct { |
| 440 | ULONG Lo32; |
| 441 | ULONG Mid32; |
| 442 | } v; |
| 443 | ULONGLONG Lo64; |
| 444 | } v; |
| 445 | } DECIMAL, *LPDECIMAL; |
| 446 | |
| 447 | #define DECIMAL_NEG ((BYTE)0x80) |
| 448 | #define DECIMAL_SCALE(dec) ((dec).u.u.scale) |
| 449 | #define DECIMAL_SIGN(dec) ((dec).u.u.sign) |
| 450 | #define DECIMAL_SIGNSCALE(dec) ((dec).u.signscale) |
| 451 | #define DECIMAL_LO32(dec) ((dec).v.v.Lo32) |
| 452 | #define DECIMAL_MID32(dec) ((dec).v.v.Mid32) |
| 453 | #define DECIMAL_HI32(dec) ((dec).Hi32) |
| 454 | #define DECIMAL_LO64_GET(dec) ((dec).v.Lo64) |
| 455 | #define DECIMAL_LO64_SET(dec,value) {(dec).v.Lo64 = value; } |
| 456 | |
| 457 | #define DECIMAL_SETZERO(dec) {DECIMAL_LO32(dec) = 0; DECIMAL_MID32(dec) = 0; DECIMAL_HI32(dec) = 0; DECIMAL_SIGNSCALE(dec) = 0;} |
| 458 | |
| 459 | typedef struct tagBLOB { |
| 460 | ULONG cbSize; |
| 461 | BYTE *pBlobData; |
| 462 | } BLOB, *LPBLOB; |
| 463 | |
| 464 | interface IStream; |
| 465 | interface IRecordInfo; |
| 466 | |
| 467 | typedef unsigned short VARTYPE; |
| 468 | |
| 469 | enum VARENUM { |
| 470 | VT_EMPTY = 0, |
| 471 | VT_NULL = 1, |
| 472 | VT_I2 = 2, |
| 473 | VT_I4 = 3, |
| 474 | VT_R4 = 4, |
| 475 | VT_R8 = 5, |
| 476 | VT_CY = 6, |
| 477 | VT_DATE = 7, |
| 478 | VT_BSTR = 8, |
| 479 | VT_DISPATCH = 9, |
| 480 | VT_ERROR = 10, |
| 481 | VT_BOOL = 11, |
| 482 | VT_VARIANT = 12, |
| 483 | VT_UNKNOWN = 13, |
| 484 | VT_DECIMAL = 14, |
| 485 | VT_I1 = 16, |
| 486 | VT_UI1 = 17, |
| 487 | VT_UI2 = 18, |
| 488 | VT_UI4 = 19, |
| 489 | VT_I8 = 20, |
| 490 | VT_UI8 = 21, |
| 491 | VT_INT = 22, |
| 492 | VT_UINT = 23, |
| 493 | VT_VOID = 24, |
| 494 | VT_HRESULT = 25, |
| 495 | VT_PTR = 26, |
| 496 | VT_SAFEARRAY = 27, |
| 497 | VT_CARRAY = 28, |
| 498 | VT_USERDEFINED = 29, |
| 499 | VT_LPSTR = 30, |
| 500 | VT_LPWSTR = 31, |
| 501 | VT_RECORD = 36, |
| 502 | VT_INT_PTR = 37, |
| 503 | VT_UINT_PTR = 38, |
| 504 | |
| 505 | VT_FILETIME = 64, |
| 506 | VT_BLOB = 65, |
| 507 | VT_STREAM = 66, |
| 508 | VT_STORAGE = 67, |
| 509 | VT_STREAMED_OBJECT = 68, |
| 510 | VT_STORED_OBJECT = 69, |
| 511 | VT_BLOB_OBJECT = 70, |
| 512 | VT_CF = 71, |
| 513 | VT_CLSID = 72, |
| 514 | |
| 515 | VT_VECTOR = 0x1000, |
| 516 | VT_ARRAY = 0x2000, |
| 517 | VT_BYREF = 0x4000, |
| 518 | VT_TYPEMASK = 0xfff, |
| 519 | }; |
| 520 | |
| 521 | typedef struct tagVARIANT VARIANT, *LPVARIANT; |
| 522 | typedef struct tagSAFEARRAY SAFEARRAY; |
| 523 | |
| 524 | struct tagVARIANT |
| 525 | { |
| 526 | union |
| 527 | { |
| 528 | struct |
| 529 | { |
| 530 | #if BIGENDIAN |
| 531 | // We need to make sure vt overlaps with DECIMAL's wReserved. |
| 532 | // See the DECIMAL type for details. |
| 533 | WORD wReserved1; |
| 534 | VARTYPE vt; |
| 535 | #else |
| 536 | VARTYPE vt; |
| 537 | WORD wReserved1; |
| 538 | #endif |
| 539 | WORD wReserved2; |
| 540 | WORD wReserved3; |
| 541 | union |
| 542 | { |
| 543 | LONGLONG llVal; |
| 544 | LONG lVal; |
| 545 | BYTE bVal; |
| 546 | SHORT iVal; |
| 547 | FLOAT fltVal; |
| 548 | DOUBLE dblVal; |
| 549 | VARIANT_BOOL boolVal; |
| 550 | SCODE scode; |
| 551 | CY cyVal; |
| 552 | DATE date; |
| 553 | BSTR bstrVal; |
| 554 | interface IUnknown *punkVal; |
| 555 | interface IDispatch *pdispVal; |
| 556 | SAFEARRAY *parray; |
| 557 | BYTE *pbVal; |
| 558 | SHORT *piVal; |
| 559 | LONG *plVal; |
| 560 | LONGLONG *pllVal; |
| 561 | FLOAT *pfltVal; |
| 562 | DOUBLE *pdblVal; |
| 563 | VARIANT_BOOL *pboolVal; |
| 564 | SCODE *pscode; |
| 565 | CY *pcyVal; |
| 566 | DATE *pdate; |
| 567 | BSTR *pbstrVal; |
| 568 | interface IUnknown **ppunkVal; |
| 569 | VARIANT *pvarVal; |
| 570 | PVOID byref; |
| 571 | CHAR cVal; |
| 572 | USHORT uiVal; |
| 573 | ULONG ulVal; |
| 574 | ULONGLONG ullVal; |
| 575 | INT intVal; |
| 576 | UINT uintVal; |
| 577 | DECIMAL *pdecVal; |
| 578 | CHAR *pcVal; |
| 579 | USHORT *puiVal; |
| 580 | ULONG *pulVal; |
| 581 | ULONGLONG *pullVal; |
| 582 | INT *pintVal; |
| 583 | UINT *puintVal; |
| 584 | struct __tagBRECORD |
| 585 | { |
| 586 | PVOID pvRecord; |
| 587 | interface IRecordInfo *pRecInfo; |
| 588 | } brecVal; |
| 589 | } n3; |
| 590 | } n2; |
| 591 | DECIMAL decVal; |
| 592 | } n1; |
| 593 | }; |
| 594 | |
| 595 | typedef VARIANT VARIANTARG, *LPVARIANTARG; |
| 596 | |
| 597 | STDAPI_(void) VariantInit(VARIANT * pvarg); |
| 598 | STDAPI_(HRESULT) VariantClear(VARIANT * pvarg); |
| 599 | |
| 600 | #define V_VT(X) ((X)->n1.n2.vt) |
| 601 | #define V_UNION(X, Y) ((X)->n1.n2.n3.Y) |
| 602 | #define V_RECORDINFO(X) ((X)->n1.n2.n3.brecVal.pRecInfo) |
| 603 | #define V_RECORD(X) ((X)->n1.n2.n3.brecVal.pvRecord) |
| 604 | |
| 605 | #define V_UI1(X) V_UNION(X, bVal) |
| 606 | #define V_UI1REF(X) V_UNION(X, pbVal) |
| 607 | #define V_I2(X) V_UNION(X, iVal) |
| 608 | #define V_I2REF(X) V_UNION(X, piVal) |
| 609 | #define V_I4(X) V_UNION(X, lVal) |
| 610 | #define V_I4REF(X) V_UNION(X, plVal) |
| 611 | #define V_I8(X) V_UNION(X, llVal) |
| 612 | #define V_I8REF(X) V_UNION(X, pllVal) |
| 613 | #define V_R4(X) V_UNION(X, fltVal) |
| 614 | #define V_R4REF(X) V_UNION(X, pfltVal) |
| 615 | #define V_R8(X) V_UNION(X, dblVal) |
| 616 | #define V_R8REF(X) V_UNION(X, pdblVal) |
| 617 | #define V_I1(X) V_UNION(X, cVal) |
| 618 | #define V_I1REF(X) V_UNION(X, pcVal) |
| 619 | #define V_UI2(X) V_UNION(X, uiVal) |
| 620 | #define V_UI2REF(X) V_UNION(X, puiVal) |
| 621 | #define V_UI4(X) V_UNION(X, ulVal) |
| 622 | #define V_UI4REF(X) V_UNION(X, pulVal) |
| 623 | #define V_UI8(X) V_UNION(X, ullVal) |
| 624 | #define V_UI8REF(X) V_UNION(X, pullVal) |
| 625 | #define V_INT(X) V_UNION(X, intVal) |
| 626 | #define V_INTREF(X) V_UNION(X, pintVal) |
| 627 | #define V_UINT(X) V_UNION(X, uintVal) |
| 628 | #define V_UINTREF(X) V_UNION(X, puintVal) |
| 629 | #define V_ARRAY(X) V_UNION(X, parray) |
| 630 | |
| 631 | #ifdef _WIN64 |
| 632 | #define V_INT_PTR(X) V_UNION(X, llVal) |
| 633 | #define V_UINT_PTR(X) V_UNION(X, ullVal) |
| 634 | #define V_INT_PTRREF(X) V_UNION(X, pllVal) |
| 635 | #define V_UINT_PTRREF(X) V_UNION(X, pullVal) |
| 636 | #else |
| 637 | #define V_INT_PTR(X) V_UNION(X, lVal) |
| 638 | #define V_UINT_PTR(X) V_UNION(X, ulVal) |
| 639 | #define V_INT_PTRREF(X) V_UNION(X, plVal) |
| 640 | #define V_UINT_PTRREF(X) V_UNION(X, pulVal) |
| 641 | #endif |
| 642 | |
| 643 | #define V_CY(X) V_UNION(X, cyVal) |
| 644 | #define V_CYREF(X) V_UNION(X, pcyVal) |
| 645 | #define V_DATE(X) V_UNION(X, date) |
| 646 | #define V_DATEREF(X) V_UNION(X, pdate) |
| 647 | #define V_BSTR(X) V_UNION(X, bstrVal) |
| 648 | #define V_BSTRREF(X) V_UNION(X, pbstrVal) |
| 649 | #define V_UNKNOWN(X) V_UNION(X, punkVal) |
| 650 | #define V_UNKNOWNREF(X) V_UNION(X, ppunkVal) |
| 651 | #define V_VARIANTREF(X) V_UNION(X, pvarVal) |
| 652 | #define V_DISPATCH(X) V_UNION(X, pdispVal) |
| 653 | #define V_ERROR(X) V_UNION(X, scode) |
| 654 | #define V_ERRORREF(X) V_UNION(X, pscode) |
| 655 | #define V_BOOL(X) V_UNION(X, boolVal) |
| 656 | #define V_BOOLREF(X) V_UNION(X, pboolVal) |
| 657 | #define V_BYREF(X) V_UNION(X, byref) |
| 658 | |
| 659 | #define V_DECIMAL(X) ((X)->n1.decVal) |
| 660 | #define V_DECIMALREF(X) V_UNION(X, pdecVal) |
| 661 | |
| 662 | #define V_ISBYREF(X) (V_VT(X)&VT_BYREF) |
| 663 | |
| 664 | STDAPI CreateStreamOnHGlobal(PVOID hGlobal, BOOL fDeleteOnRelease, interface IStream** ppstm); |
| 665 | |
| 666 | #define STGM_DIRECT 0x00000000L |
| 667 | |
| 668 | #define STGM_READ 0x00000000L |
| 669 | #define STGM_WRITE 0x00000001L |
| 670 | #define STGM_READWRITE 0x00000002L |
| 671 | |
| 672 | #define STGM_SHARE_DENY_NONE 0x00000040L |
| 673 | #define STGM_SHARE_DENY_READ 0x00000030L |
| 674 | #define STGM_SHARE_DENY_WRITE 0x00000020L |
| 675 | #define STGM_SHARE_EXCLUSIVE 0x00000010L |
| 676 | |
| 677 | #define STGM_DELETEONRELEASE 0x04000000L |
| 678 | |
| 679 | #define STGM_CREATE 0x00001000L |
| 680 | #define STGM_CONVERT 0x00020000L |
| 681 | #define STGM_FAILIFTHERE 0x00000000L |
| 682 | |
| 683 | #define STGM_NOSNAPSHOT 0x00200000L |
| 684 | |
| 685 | STDAPI IIDFromString(LPOLESTR lpsz, IID* lpiid); |
| 686 | STDAPI_(int) StringFromGUID2(REFGUID rguid, LPOLESTR lpsz, int cchMax); |
| 687 | |
| 688 | /******************* CRYPT **************************************/ |
| 689 | |
| 690 | #define PUBLICKEYBLOB 0x6 |
| 691 | |
| 692 | // |
| 693 | // Algorithm IDs and Flags |
| 694 | // |
| 695 | #define GET_ALG_CLASS(x) (x & (7 << 13)) |
| 696 | #define GET_ALG_TYPE(x) (x & (15 << 9)) |
| 697 | #define GET_ALG_SID(x) (x & (511)) |
| 698 | |
| 699 | typedef unsigned int ALG_ID; |
| 700 | |
| 701 | // Algorithm classes |
| 702 | #define ALG_CLASS_SIGNATURE (1 << 13) |
| 703 | #define ALG_CLASS_HASH (4 << 13) |
| 704 | |
| 705 | // Algorithm types |
| 706 | #define ALG_TYPE_ANY (0) |
| 707 | |
| 708 | // Hash sub ids |
| 709 | #define ALG_SID_SHA1 4 |
| 710 | |
| 711 | // algorithm identifier definitions |
| 712 | #define CALG_SHA1 (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA1) |
| 713 | |
| 714 | /******************* NLS ****************************************/ |
| 715 | |
| 716 | typedef |
| 717 | enum tagMIMECONTF { |
| 718 | MIMECONTF_MAILNEWS = 0x1, |
| 719 | MIMECONTF_BROWSER = 0x2, |
| 720 | MIMECONTF_MINIMAL = 0x4, |
| 721 | MIMECONTF_IMPORT = 0x8, |
| 722 | MIMECONTF_SAVABLE_MAILNEWS = 0x100, |
| 723 | MIMECONTF_SAVABLE_BROWSER = 0x200, |
| 724 | MIMECONTF_EXPORT = 0x400, |
| 725 | MIMECONTF_PRIVCONVERTER = 0x10000, |
| 726 | MIMECONTF_VALID = 0x20000, |
| 727 | MIMECONTF_VALID_NLS = 0x40000, |
| 728 | MIMECONTF_MIME_IE4 = 0x10000000, |
| 729 | MIMECONTF_MIME_LATEST = 0x20000000, |
| 730 | MIMECONTF_MIME_REGISTRY = 0x40000000 |
| 731 | } MIMECONTF; |
| 732 | |
| 733 | #define LCMAP_LOWERCASE 0x00000100 |
| 734 | #define LCMAP_UPPERCASE 0x00000200 |
| 735 | #define LCMAP_SORTKEY 0x00000400 |
| 736 | #define LCMAP_BYTEREV 0x00000800 |
| 737 | |
| 738 | #define LCMAP_HIRAGANA 0x00100000 |
| 739 | #define LCMAP_KATAKANA 0x00200000 |
| 740 | #define LCMAP_HALFWIDTH 0x00400000 |
| 741 | #define LCMAP_FULLWIDTH 0x00800000 |
| 742 | |
| 743 | #define LCMAP_LINGUISTIC_CASING 0x01000000 |
| 744 | |
| 745 | // 8 characters for language |
| 746 | // 8 characters for region |
| 747 | // 64 characters for suffix (script) |
| 748 | // 2 characters for '-' separators |
| 749 | // 2 characters for prefix like "i-" or "x-" |
| 750 | // 1 null termination |
| 751 | #define LOCALE_NAME_MAX_LENGTH 85 |
| 752 | |
| 753 | #define LOCALE_SCOUNTRY 0x00000006 |
| 754 | #define LOCALE_SENGCOUNTRY 0x00001002 |
| 755 | |
| 756 | #define LOCALE_SLANGUAGE 0x00000002 |
| 757 | #define LOCALE_SENGLANGUAGE 0x00001001 |
| 758 | |
| 759 | #define LOCALE_SDATE 0x0000001D |
| 760 | #define LOCALE_STIME 0x0000001E |
| 761 | |
| 762 | #define CSTR_LESS_THAN 1 |
| 763 | #define CSTR_EQUAL 2 |
| 764 | #define CSTR_GREATER_THAN 3 |
| 765 | |
| 766 | #define NORM_IGNORENONSPACE 0x00000002 |
| 767 | |
| 768 | #define WC_COMPOSITECHECK 0x00000000 // NOTE: diff from winnls.h |
| 769 | |
| 770 | /******************* shlwapi ************************************/ |
| 771 | |
| 772 | // note: diff in NULL handing and calling convetion |
| 773 | #define StrCpyW PAL_wcscpy |
| 774 | #define StrCatW PAL_wcscat |
| 775 | #define StrChrW (WCHAR*)PAL_wcschr |
| 776 | #define StrCmpW PAL_wcscmp |
| 777 | #define StrCmpIW _wcsicmp |
| 778 | #define StrCmpNW PAL_wcsncmp |
| 779 | #define StrCmpNIW _wcsnicmp |
| 780 | |
| 781 | STDAPI_(LPWSTR) StrNCatW(LPWSTR lpFront, LPCWSTR lpBack, int cchMax); |
| 782 | STDAPI_(int) StrToIntW(LPCWSTR lpSrc); |
| 783 | STDAPI_(LPWSTR) StrStrIW(LPCWSTR lpFirst, LPCWSTR lpSrch); |
| 784 | STDAPI_(LPWSTR) StrRChrW(LPCWSTR lpStart, LPCWSTR lpEnd, WCHAR wMatch); |
| 785 | STDAPI_(LPWSTR) StrCatBuffW(LPWSTR pszDest, LPCWSTR pszSrc, int cchDestBuffSize); |
| 786 | |
| 787 | #define lstrcmpW PAL_wcscmp |
| 788 | #define lstrcmpiW _wcsicmp |
| 789 | |
| 790 | #ifdef UNICODE |
| 791 | #define StrCpy StrCpyW |
| 792 | #define StrCat StrCatW |
| 793 | #define StrNCat StrNCatW |
| 794 | #define StrChr StrChrW |
| 795 | #define StrCmp StrCmpW |
| 796 | #define StrCmpN StrCmpNW |
| 797 | #define StrCmpI StrCmpIW |
| 798 | #define StrCmpNI StrCmpNIW |
| 799 | |
| 800 | #define StrToInt StrToIntW |
| 801 | #define StrStrI StrStrIW |
| 802 | #define StrRChr StrRChrW |
| 803 | #define StrCatBuff StrCatBuffW |
| 804 | |
| 805 | #define lstrcmp lstrcmpW |
| 806 | #define lstrcmpi lstrcmpiW |
| 807 | #endif |
| 808 | |
| 809 | |
| 810 | #ifdef __cplusplus |
| 811 | /* |
| 812 | Safe CRT functions are not available (yet) on all platforms, so we use our own implementations from safecrt.h. |
| 813 | */ |
| 814 | #define _CRT_ALTERNATIVE_INLINES |
| 815 | #define _SAFECRT_NO_INCLUDES 1 |
| 816 | #define _SAFECRT_USE_INLINES 1 |
| 817 | #define _SAFECRT_SET_ERRNO 0 |
| 818 | #define _SAFECRT_DEFINE_MBS_FUNCTIONS 0 |
| 819 | #define _SAFECRT_DEFINE_TCS_MACROS 1 |
| 820 | /* |
| 821 | #define _SAFECRT__ISMBBLEAD(_Character) 0 |
| 822 | #define _SAFECRT__MBSDEC(_String, _Current) (_Current - 1) |
| 823 | */ |
| 824 | #include "safecrt.h" |
| 825 | #include "specstrings.h" |
| 826 | |
| 827 | /* |
| 828 | The wrappers below are simple implementations that may not be as robust as complete functions in the Secure CRT library. |
| 829 | Remember to fix the errcode defintion in safecrt.h. |
| 830 | */ |
| 831 | |
| 832 | #define _wcslwr_s _wcslwr_unsafe |
| 833 | #define swscanf_s swscanf |
| 834 | |
| 835 | #define _wfopen_s _wfopen_unsafe |
| 836 | #define fopen_s _fopen_unsafe |
| 837 | |
| 838 | #define _strlwr_s _strlwr_unsafe |
| 839 | |
| 840 | #define _vscprintf _vscprintf_unsafe |
| 841 | |
| 842 | extern "C++" { |
| 843 | |
| 844 | #include <safemath.h> |
| 845 | |
| 846 | inline errno_t __cdecl _wcslwr_unsafe(WCHAR *str, size_t sz) |
| 847 | { |
| 848 | size_t fullSize; |
| 849 | if(!ClrSafeInt<size_t>::multiply(sz, sizeof(WCHAR), fullSize)) |
| 850 | return 1; |
| 851 | WCHAR *copy = (WCHAR *)malloc(fullSize); |
| 852 | if(copy == nullptr) |
| 853 | return 1; |
| 854 | |
| 855 | errno_t retCode = wcscpy_s(copy, sz, str); |
| 856 | if(retCode) { |
| 857 | free(copy); |
| 858 | return 1; |
| 859 | } |
| 860 | |
| 861 | _wcslwr(copy); |
| 862 | wcscpy_s(str, sz, copy); |
| 863 | free(copy); |
| 864 | |
| 865 | return 0; |
| 866 | } |
| 867 | inline errno_t __cdecl _strlwr_unsafe(char *str, size_t sz) |
| 868 | { |
| 869 | char *copy = (char *)malloc(sz); |
| 870 | if(copy == nullptr) |
| 871 | return 1; |
| 872 | |
| 873 | errno_t retCode = strcpy_s(copy, sz, str); |
| 874 | if(retCode) { |
| 875 | free(copy); |
| 876 | return 1; |
| 877 | } |
| 878 | |
| 879 | _strlwr(copy); |
| 880 | strcpy_s(str, sz, copy); |
| 881 | free(copy); |
| 882 | |
| 883 | return 0; |
| 884 | } |
| 885 | |
| 886 | inline int __cdecl _vscprintf_unsafe(const char *_Format, va_list _ArgList) |
| 887 | { |
| 888 | int guess = 10; |
| 889 | |
| 890 | for (;;) |
| 891 | { |
| 892 | char *buf = (char *)malloc(guess * sizeof(char)); |
| 893 | if(buf == nullptr) |
| 894 | return 0; |
| 895 | |
| 896 | va_list argListCopy; |
| 897 | va_copy(argListCopy, _ArgList); |
| 898 | int ret = _vsnprintf_s(buf, guess, _TRUNCATE, _Format, argListCopy); |
| 899 | free(buf); |
| 900 | va_end(argListCopy); |
| 901 | |
| 902 | if ((ret != -1) && (ret < guess)) |
| 903 | return ret; |
| 904 | |
| 905 | guess *= 2; |
| 906 | } |
| 907 | } |
| 908 | |
| 909 | inline errno_t __cdecl _wfopen_unsafe(PAL_FILE * *ff, const WCHAR *fileName, const WCHAR *mode) |
| 910 | { |
| 911 | PAL_FILE *result = _wfopen(fileName, mode); |
| 912 | if(result == 0) { |
| 913 | return 1; |
| 914 | } else { |
| 915 | *ff = result; |
| 916 | return 0; |
| 917 | } |
| 918 | } |
| 919 | |
| 920 | inline errno_t __cdecl _fopen_unsafe(PAL_FILE * *ff, const char *fileName, const char *mode) |
| 921 | { |
| 922 | PAL_FILE *result = PAL_fopen(fileName, mode); |
| 923 | if(result == 0) { |
| 924 | return 1; |
| 925 | } else { |
| 926 | *ff = result; |
| 927 | return 0; |
| 928 | } |
| 929 | } |
| 930 | |
| 931 | } |
| 932 | #endif /* __cplusplus */ |
| 933 | |
| 934 | |
| 935 | STDAPI_(BOOL) PathAppendW(LPWSTR pszPath, LPCWSTR pszMore); |
| 936 | STDAPI_(int) PathCommonPrefixW(LPCWSTR pszFile1, LPCWSTR pszFile2, LPWSTR pszPath); |
| 937 | PALIMPORT LPWSTR PALAPI PathFindFileNameW(LPCWSTR pPath); |
| 938 | STDAPI_(int) PathGetDriveNumberW(LPCWSTR lpsz); |
| 939 | STDAPI_(BOOL) PathIsRelativeW(LPCWSTR lpszPath); |
| 940 | STDAPI_(BOOL) PathIsUNCW(LPCWSTR pszPath); |
| 941 | STDAPI_(LPWSTR) PathAddBackslashW(LPWSTR lpszPath); |
| 942 | STDAPI_(LPWSTR) PathRemoveBackslashW(LPWSTR lpszPath); |
| 943 | STDAPI_(void) PathRemoveExtensionW(LPWSTR pszPath); |
| 944 | STDAPI_(LPWSTR) PathCombineW(LPWSTR lpszDest, LPCWSTR lpszDir, LPCWSTR lpszFile); |
| 945 | STDAPI_(BOOL) PathCanonicalizeW(LPWSTR lpszDst, LPCWSTR lpszSrc); |
| 946 | STDAPI_(BOOL) PathRelativePathToW(LPWSTR pszPath, LPCWSTR pszFrom, DWORD dwAttrFrom, LPCWSTR pszTo, DWORD dwAttrTo); |
| 947 | STDAPI_(BOOL) PathRenameExtensionW(LPWSTR pszPath, LPCWSTR pszExt); |
| 948 | STDAPI_(BOOL) PathRemoveFileSpecW(LPWSTR pFile); |
| 949 | STDAPI_(void) PathStripPathW (LPWSTR pszPath); |
| 950 | |
| 951 | #ifdef UNICODE |
| 952 | #define PathAppend PathAppendW |
| 953 | #define PathCommonPrefix PathCommonPrefixW |
| 954 | #define PathFindFileName PathFindFileNameW |
| 955 | #define PathIsRelative PathIsRelativeW |
| 956 | #define PathGetDriveNumber PathGetDriveNumberW |
| 957 | #define PathIsUNC PathIsUNCW |
| 958 | #define PathAddBackslash PathAddBackslashW |
| 959 | #define PathRemoveBackslash PathRemoveBackslashW |
| 960 | #define PathRemoveExtension PathRemoveExtensionW |
| 961 | #define PathCombine PathCombineW |
| 962 | #define PathSkipRoot PathSkipRootW |
| 963 | #define PathFindExtension PathFindExtensionW |
| 964 | #define PathCanonicalize PathCanonicalizeW |
| 965 | #define PathRelativePathTo PathRelativePathToW |
| 966 | #define PathRemoveFileSpec PathRemoveFileSpecW |
| 967 | #define PathRenameExtension PathRenameExtensionW |
| 968 | #define PathStripPath PathStripPathW |
| 969 | |
| 970 | |
| 971 | #endif // UNICODE |
| 972 | |
| 973 | /******************* misc ***************************************/ |
| 974 | |
| 975 | #ifdef __cplusplus |
| 976 | namespace std |
| 977 | { |
| 978 | typedef decltype(nullptr) nullptr_t; |
| 979 | } |
| 980 | |
| 981 | extern "C++" |
| 982 | template< class T > |
| 983 | typename std::remove_reference<T>::type&& move( T&& t ); |
| 984 | #endif // __cplusplus |
| 985 | |
| 986 | #define __RPC__out |
| 987 | #define __RPC__in |
| 988 | #define __RPC__deref_out_opt |
| 989 | #define __RPC__in_opt |
| 990 | #define __RPC__inout_xcount(x) |
| 991 | #define __RPC__in_ecount_full(x) |
| 992 | #define __RPC__out_ecount_part(x, y) |
| 993 | #define __RPC__in_xcount(x) |
| 994 | #define __RPC__inout |
| 995 | #define __RPC__deref_out_ecount_full_opt(x) |
| 996 | |
| 997 | typedef DWORD OLE_COLOR; |
| 998 | |
| 999 | #define PF_COMPARE_EXCHANGE_DOUBLE 2 |
| 1000 | |
| 1001 | typedef VOID (NTAPI * WAITORTIMERCALLBACKFUNC) (PVOID, BOOLEAN ); |
| 1002 | |
| 1003 | typedef HANDLE HWND; |
| 1004 | |
| 1005 | #define IS_TEXT_UNICODE_SIGNATURE 0x0008 |
| 1006 | #define IS_TEXT_UNICODE_UNICODE_MASK 0x000F |
| 1007 | |
| 1008 | BOOL IsTextUnicode(CONST VOID* lpv, int iSize, LPINT lpiResult); |
| 1009 | |
| 1010 | typedef struct _LIST_ENTRY { |
| 1011 | struct _LIST_ENTRY *Flink; |
| 1012 | struct _LIST_ENTRY *Blink; |
| 1013 | } LIST_ENTRY, *PLIST_ENTRY; |
| 1014 | |
| 1015 | typedef VOID (NTAPI *WAITORTIMERCALLBACK)(PVOID, BOOLEAN); |
| 1016 | |
| 1017 | // PORTABILITY_ASSERT and PORTABILITY_WARNING macros are meant to be used to |
| 1018 | // mark places in the code that needs attention for portability. The usual |
| 1019 | // usage pattern is: |
| 1020 | // |
| 1021 | // int get_scratch_register() { |
| 1022 | // #if defined(_TARGET_X86_) |
| 1023 | // return eax; |
| 1024 | // #elif defined(_TARGET_AMD64_) |
| 1025 | // return rax; |
| 1026 | // #elif defined(_TARGET_ARM_) |
| 1027 | // return r0; |
| 1028 | // #else |
| 1029 | // PORTABILITY_ASSERT("scratch register"); |
| 1030 | // return 0; |
| 1031 | // #endif |
| 1032 | // } |
| 1033 | // |
| 1034 | // PORTABILITY_ASSERT is meant to be used inside functions/methods. It can |
| 1035 | // introduce compile-time and/or run-time errors. |
| 1036 | // PORTABILITY_WARNING is meant to be used outside functions/methods. It can |
| 1037 | // introduce compile-time errors or warnings only. |
| 1038 | // |
| 1039 | // People starting new ports will first define these to just cause run-time |
| 1040 | // errors. Once they fix all the places that need attention for portability, |
| 1041 | // they can define PORTABILITY_ASSERT and PORTABILITY_WARNING to cause |
| 1042 | // compile-time errors to make sure that they haven't missed anything. |
| 1043 | // |
| 1044 | // If it is reasonably possible all codepaths containing PORTABILITY_ASSERT |
| 1045 | // should be compilable (e.g. functions should return NULL or something if |
| 1046 | // they are expected to return a value). |
| 1047 | // |
| 1048 | // The message in these two macros should not contain any keywords like TODO |
| 1049 | // or NYI. It should be just the brief description of the problem. |
| 1050 | |
| 1051 | #ifdef PORTABILITY_CHECK |
| 1052 | // Finished ports - compile-time errors |
| 1053 | #define PORTABILITY_WARNING(message) NEED_TO_PORT_THIS_ONE(NEED_TO_PORT_THIS_ONE) |
| 1054 | #define PORTABILITY_ASSERT(message) NEED_TO_PORT_THIS_ONE(NEED_TO_PORT_THIS_ONE) |
| 1055 | #else |
| 1056 | // Ports in progress - run-time asserts only |
| 1057 | #define PORTABILITY_WARNING(message) |
| 1058 | #define PORTABILITY_ASSERT(message) _ASSERTE(false && message) |
| 1059 | #endif |
| 1060 | |
| 1061 | #define UNREFERENCED_PARAMETER(P) (void)(P) |
| 1062 | |
| 1063 | #ifdef BIT64 |
| 1064 | #define VALPTR(x) VAL64(x) |
| 1065 | #define GET_UNALIGNED_PTR(x) GET_UNALIGNED_64(x) |
| 1066 | #define GET_UNALIGNED_VALPTR(x) GET_UNALIGNED_VAL64(x) |
| 1067 | #define SET_UNALIGNED_PTR(p,x) SET_UNALIGNED_64(p,x) |
| 1068 | #define SET_UNALIGNED_VALPTR(p,x) SET_UNALIGNED_VAL64(p,x) |
| 1069 | #else |
| 1070 | #define VALPTR(x) VAL32(x) |
| 1071 | #define GET_UNALIGNED_PTR(x) GET_UNALIGNED_32(x) |
| 1072 | #define GET_UNALIGNED_VALPTR(x) GET_UNALIGNED_VAL32(x) |
| 1073 | #define SET_UNALIGNED_PTR(p,x) SET_UNALIGNED_32(p,x) |
| 1074 | #define SET_UNALIGNED_VALPTR(p,x) SET_UNALIGNED_VAL32(p,x) |
| 1075 | #endif |
| 1076 | |
| 1077 | #ifdef _TARGET_AMD64_ |
| 1078 | #define RUNTIME_FUNCTION_INDIRECT 0x1 |
| 1079 | #endif |
| 1080 | |
| 1081 | #define _ReturnAddress() __builtin_return_address(0) |
| 1082 | |
| 1083 | #define DIRECTORY_SEPARATOR_CHAR_A '/' |
| 1084 | #define DIRECTORY_SEPARATOR_CHAR_W W('/') |
| 1085 | #define DIRECTORY_SEPARATOR_STR_A "/" |
| 1086 | #define DIRECTORY_SEPARATOR_STR_W W("/") |
| 1087 | #define PATH_SEPARATOR_CHAR_W W(':') |
| 1088 | #define PATH_SEPARATOR_STR_W W(":") |
| 1089 | #define VOLUME_SEPARATOR_CHAR_W W('/') |
| 1090 | |
| 1091 | #ifndef IMAGE_IMPORT_DESC_FIELD |
| 1092 | #define IMAGE_IMPORT_DESC_FIELD(img, f) ((img).u.f) |
| 1093 | #endif |
| 1094 | |
| 1095 | #ifndef IMAGE_COR20_HEADER_FIELD |
| 1096 | #define (obj, f) ((obj).f) |
| 1097 | #endif |
| 1098 | |
| 1099 | // copied from winnt.h |
| 1100 | #define PROCESSOR_ARCHITECTURE_INTEL 0 |
| 1101 | #define PROCESSOR_ARCHITECTURE_MIPS 1 |
| 1102 | #define PROCESSOR_ARCHITECTURE_ALPHA 2 |
| 1103 | #define PROCESSOR_ARCHITECTURE_PPC 3 |
| 1104 | #define PROCESSOR_ARCHITECTURE_SHX 4 |
| 1105 | #define PROCESSOR_ARCHITECTURE_ARM 5 |
| 1106 | #define PROCESSOR_ARCHITECTURE_IA64 6 |
| 1107 | #define PROCESSOR_ARCHITECTURE_ALPHA64 7 |
| 1108 | #define PROCESSOR_ARCHITECTURE_MSIL 8 |
| 1109 | #define PROCESSOR_ARCHITECTURE_AMD64 9 |
| 1110 | #define PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 10 |
| 1111 | #define PROCESSOR_ARCHITECTURE_NEUTRAL 11 |
| 1112 | #define PROCESSOR_ARCHITECTURE_ARM64 12 |
| 1113 | |
| 1114 | #define PROCESSOR_ARCHITECTURE_UNKNOWN 0xFFFF |
| 1115 | |
| 1116 | // |
| 1117 | // JIT Debugging Info. This structure is defined to have constant size in |
| 1118 | // both the emulated and native environment. |
| 1119 | // |
| 1120 | |
| 1121 | typedef struct _JIT_DEBUG_INFO { |
| 1122 | DWORD dwSize; |
| 1123 | DWORD dwProcessorArchitecture; |
| 1124 | DWORD dwThreadID; |
| 1125 | DWORD dwReserved0; |
| 1126 | ULONG64 lpExceptionAddress; |
| 1127 | ULONG64 lpExceptionRecord; |
| 1128 | ULONG64 lpContextRecord; |
| 1129 | } JIT_DEBUG_INFO, *LPJIT_DEBUG_INFO; |
| 1130 | |
| 1131 | typedef JIT_DEBUG_INFO JIT_DEBUG_INFO32, *LPJIT_DEBUG_INFO32; |
| 1132 | typedef JIT_DEBUG_INFO JIT_DEBUG_INFO64, *LPJIT_DEBUG_INFO64; |
| 1133 | |
| 1134 | /******************* resources ***************************************/ |
| 1135 | |
| 1136 | #define MAKEINTRESOURCEW(i) ((LPWSTR)((ULONG_PTR)((WORD)(i)))) |
| 1137 | #define RT_RCDATA MAKEINTRESOURCE(10) |
| 1138 | #define RT_VERSION MAKEINTRESOURCE(16) |
| 1139 | |
| 1140 | /******************* SAFEARRAY ************************/ |
| 1141 | |
| 1142 | #define FADF_VARIANT ( 0x800 ) |
| 1143 | |
| 1144 | typedef struct tagSAFEARRAYBOUND |
| 1145 | { |
| 1146 | ULONG cElements; |
| 1147 | LONG lLbound; |
| 1148 | } SAFEARRAYBOUND; |
| 1149 | |
| 1150 | typedef struct tagSAFEARRAYBOUND *LPSAFEARRAYBOUND; |
| 1151 | |
| 1152 | typedef struct tagSAFEARRAY |
| 1153 | { |
| 1154 | USHORT cDims; |
| 1155 | USHORT fFeatures; |
| 1156 | ULONG cbElements; |
| 1157 | ULONG cLocks; |
| 1158 | PVOID pvData; |
| 1159 | SAFEARRAYBOUND rgsabound[ 1 ]; |
| 1160 | } SAFEARRAY; |
| 1161 | |
| 1162 | typedef SAFEARRAY *LPSAFEARRAY; |
| 1163 | |
| 1164 | |
| 1165 | STDAPI_(SAFEARRAY *) SafeArrayCreateVector(VARTYPE vt, LONG lLbound, ULONG cElements); |
| 1166 | STDAPI_(UINT) SafeArrayGetDim(SAFEARRAY * psa); |
| 1167 | STDAPI SafeArrayGetElement(SAFEARRAY * psa, LONG * rgIndices, void * pv); |
| 1168 | STDAPI SafeArrayGetLBound(SAFEARRAY * psa, UINT nDim, LONG * plLbound); |
| 1169 | STDAPI SafeArrayGetUBound(SAFEARRAY * psa, UINT nDim, LONG * plUbound); |
| 1170 | STDAPI SafeArrayGetVartype(SAFEARRAY * psa, VARTYPE * pvt); |
| 1171 | STDAPI SafeArrayPutElement(SAFEARRAY * psa, LONG * rgIndices, void * pv); |
| 1172 | STDAPI SafeArrayDestroy(SAFEARRAY * psa); |
| 1173 | |
| 1174 | EXTERN_C void * _stdcall _lfind(const void *, const void *, unsigned int *, unsigned int, |
| 1175 | int (__cdecl *)(const void *, const void *)); |
| 1176 | |
| 1177 | |
| 1178 | /*<TODO>****************** clean this up ***********************</TODO>*/ |
| 1179 | |
| 1180 | |
| 1181 | interface IDispatch; |
| 1182 | interface ITypeInfo; |
| 1183 | interface ITypeLib; |
| 1184 | interface IMoniker; |
| 1185 | |
| 1186 | typedef VOID (WINAPI *LPOVERLAPPED_COMPLETION_ROUTINE)( |
| 1187 | DWORD dwErrorCode, |
| 1188 | DWORD dwNumberOfBytesTransfered, |
| 1189 | LPOVERLAPPED lpOverlapped); |
| 1190 | |
| 1191 | // |
| 1192 | // Debug APIs |
| 1193 | // |
| 1194 | #define EXCEPTION_DEBUG_EVENT 1 |
| 1195 | #define CREATE_THREAD_DEBUG_EVENT 2 |
| 1196 | #define CREATE_PROCESS_DEBUG_EVENT 3 |
| 1197 | #define EXIT_THREAD_DEBUG_EVENT 4 |
| 1198 | #define EXIT_PROCESS_DEBUG_EVENT 5 |
| 1199 | #define LOAD_DLL_DEBUG_EVENT 6 |
| 1200 | #define UNLOAD_DLL_DEBUG_EVENT 7 |
| 1201 | #define OUTPUT_DEBUG_STRING_EVENT 8 |
| 1202 | #define RIP_EVENT 9 |
| 1203 | |
| 1204 | typedef struct _EXCEPTION_DEBUG_INFO { |
| 1205 | EXCEPTION_RECORD ExceptionRecord; |
| 1206 | DWORD dwFirstChance; |
| 1207 | } EXCEPTION_DEBUG_INFO, *LPEXCEPTION_DEBUG_INFO; |
| 1208 | |
| 1209 | typedef struct _CREATE_THREAD_DEBUG_INFO { |
| 1210 | HANDLE hThread; |
| 1211 | LPVOID lpThreadLocalBase; |
| 1212 | LPTHREAD_START_ROUTINE lpStartAddress; |
| 1213 | } CREATE_THREAD_DEBUG_INFO, *LPCREATE_THREAD_DEBUG_INFO; |
| 1214 | |
| 1215 | typedef struct _CREATE_PROCESS_DEBUG_INFO { |
| 1216 | HANDLE hFile; |
| 1217 | HANDLE hProcess; |
| 1218 | HANDLE hThread; |
| 1219 | LPVOID lpBaseOfImage; |
| 1220 | DWORD dwDebugInfoFileOffset; |
| 1221 | DWORD nDebugInfoSize; |
| 1222 | LPVOID lpThreadLocalBase; |
| 1223 | LPTHREAD_START_ROUTINE lpStartAddress; |
| 1224 | LPVOID lpImageName; |
| 1225 | WORD fUnicode; |
| 1226 | } CREATE_PROCESS_DEBUG_INFO, *LPCREATE_PROCESS_DEBUG_INFO; |
| 1227 | |
| 1228 | typedef struct _EXIT_THREAD_DEBUG_INFO { |
| 1229 | DWORD dwExitCode; |
| 1230 | } EXIT_THREAD_DEBUG_INFO, *LPEXIT_THREAD_DEBUG_INFO; |
| 1231 | |
| 1232 | typedef struct _EXIT_PROCESS_DEBUG_INFO { |
| 1233 | DWORD dwExitCode; |
| 1234 | } EXIT_PROCESS_DEBUG_INFO, *LPEXIT_PROCESS_DEBUG_INFO; |
| 1235 | |
| 1236 | typedef struct _LOAD_DLL_DEBUG_INFO { |
| 1237 | HANDLE hFile; |
| 1238 | LPVOID lpBaseOfDll; |
| 1239 | DWORD dwDebugInfoFileOffset; |
| 1240 | DWORD nDebugInfoSize; |
| 1241 | LPVOID lpImageName; |
| 1242 | WORD fUnicode; |
| 1243 | } LOAD_DLL_DEBUG_INFO, *LPLOAD_DLL_DEBUG_INFO; |
| 1244 | |
| 1245 | typedef struct _UNLOAD_DLL_DEBUG_INFO { |
| 1246 | LPVOID lpBaseOfDll; |
| 1247 | } UNLOAD_DLL_DEBUG_INFO, *LPUNLOAD_DLL_DEBUG_INFO; |
| 1248 | |
| 1249 | typedef struct _OUTPUT_DEBUG_STRING_INFO { |
| 1250 | LPSTR lpDebugStringData; |
| 1251 | WORD fUnicode; |
| 1252 | WORD nDebugStringLength; |
| 1253 | } OUTPUT_DEBUG_STRING_INFO, *LPOUTPUT_DEBUG_STRING_INFO; |
| 1254 | |
| 1255 | typedef struct _RIP_INFO { |
| 1256 | DWORD dwError; |
| 1257 | DWORD dwType; |
| 1258 | } RIP_INFO, *LPRIP_INFO; |
| 1259 | |
| 1260 | typedef struct _DEBUG_EVENT { |
| 1261 | DWORD dwDebugEventCode; |
| 1262 | DWORD dwProcessId; |
| 1263 | DWORD dwThreadId; |
| 1264 | union { |
| 1265 | EXCEPTION_DEBUG_INFO Exception; |
| 1266 | CREATE_THREAD_DEBUG_INFO CreateThread; |
| 1267 | CREATE_PROCESS_DEBUG_INFO CreateProcessInfo; |
| 1268 | EXIT_THREAD_DEBUG_INFO ExitThread; |
| 1269 | EXIT_PROCESS_DEBUG_INFO ExitProcess; |
| 1270 | LOAD_DLL_DEBUG_INFO LoadDll; |
| 1271 | UNLOAD_DLL_DEBUG_INFO UnloadDll; |
| 1272 | OUTPUT_DEBUG_STRING_INFO DebugString; |
| 1273 | RIP_INFO RipInfo; |
| 1274 | } u; |
| 1275 | } DEBUG_EVENT, *LPDEBUG_EVENT; |
| 1276 | |
| 1277 | // |
| 1278 | // Define dynamic function table entry. |
| 1279 | // |
| 1280 | |
| 1281 | typedef |
| 1282 | PRUNTIME_FUNCTION |
| 1283 | GET_RUNTIME_FUNCTION_CALLBACK ( |
| 1284 | DWORD64 ControlPc, |
| 1285 | PVOID Context |
| 1286 | ); |
| 1287 | typedef GET_RUNTIME_FUNCTION_CALLBACK *PGET_RUNTIME_FUNCTION_CALLBACK; |
| 1288 | |
| 1289 | typedef |
| 1290 | DWORD |
| 1291 | OUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK ( |
| 1292 | HANDLE Process, |
| 1293 | PVOID TableAddress, |
| 1294 | PDWORD Entries, |
| 1295 | PRUNTIME_FUNCTION* Functions |
| 1296 | ); |
| 1297 | typedef OUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK *POUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK; |
| 1298 | |
| 1299 | #define OUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK_EXPORT_NAME \ |
| 1300 | "OutOfProcessFunctionTableCallback" |
| 1301 | |
| 1302 | #if defined(FEATURE_PAL_SXS) |
| 1303 | |
| 1304 | // #if !defined(_TARGET_MAC64) |
| 1305 | // typedef LONG (*PEXCEPTION_ROUTINE)( |
| 1306 | // IN PEXCEPTION_POINTERS pExceptionPointers, |
| 1307 | // IN LPVOID lpvParam); |
| 1308 | |
| 1309 | // #define DISPATCHER_CONTEXT LPVOID |
| 1310 | |
| 1311 | // #else // defined(_TARGET_MAC64) |
| 1312 | |
| 1313 | // |
| 1314 | // Define unwind history table structure. |
| 1315 | // |
| 1316 | |
| 1317 | #define UNWIND_HISTORY_TABLE_SIZE 12 |
| 1318 | |
| 1319 | typedef struct _UNWIND_HISTORY_TABLE_ENTRY { |
| 1320 | DWORD64 ImageBase; |
| 1321 | PRUNTIME_FUNCTION FunctionEntry; |
| 1322 | } UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY; |
| 1323 | |
| 1324 | typedef struct _UNWIND_HISTORY_TABLE { |
| 1325 | DWORD Count; |
| 1326 | BYTE LocalHint; |
| 1327 | BYTE GlobalHint; |
| 1328 | BYTE Search; |
| 1329 | BYTE Once; |
| 1330 | DWORD64 LowAddress; |
| 1331 | DWORD64 HighAddress; |
| 1332 | UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE]; |
| 1333 | } UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE; |
| 1334 | |
| 1335 | typedef |
| 1336 | EXCEPTION_DISPOSITION |
| 1337 | (*PEXCEPTION_ROUTINE) ( |
| 1338 | PEXCEPTION_RECORD ExceptionRecord, |
| 1339 | ULONG64 EstablisherFrame, |
| 1340 | PCONTEXT ContextRecord, |
| 1341 | PVOID DispatcherContext |
| 1342 | ); |
| 1343 | |
| 1344 | #if defined(_ARM_) |
| 1345 | |
| 1346 | typedef struct _DISPATCHER_CONTEXT { |
| 1347 | DWORD ControlPc; |
| 1348 | DWORD ImageBase; |
| 1349 | PRUNTIME_FUNCTION FunctionEntry; |
| 1350 | DWORD EstablisherFrame; |
| 1351 | DWORD TargetPc; |
| 1352 | PCONTEXT ContextRecord; |
| 1353 | PEXCEPTION_ROUTINE LanguageHandler; |
| 1354 | PVOID HandlerData; |
| 1355 | PUNWIND_HISTORY_TABLE HistoryTable; |
| 1356 | DWORD ScopeIndex; |
| 1357 | BOOLEAN ControlPcIsUnwound; |
| 1358 | PBYTE NonVolatileRegisters; |
| 1359 | DWORD Reserved; |
| 1360 | } DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT; |
| 1361 | |
| 1362 | #elif defined(_ARM64_) |
| 1363 | |
| 1364 | typedef struct _DISPATCHER_CONTEXT { |
| 1365 | ULONG64 ControlPc; |
| 1366 | ULONG64 ImageBase; |
| 1367 | PRUNTIME_FUNCTION FunctionEntry; |
| 1368 | ULONG64 EstablisherFrame; |
| 1369 | ULONG64 TargetPc; |
| 1370 | PCONTEXT ContextRecord; |
| 1371 | PEXCEPTION_ROUTINE LanguageHandler; |
| 1372 | PVOID HandlerData; |
| 1373 | PUNWIND_HISTORY_TABLE HistoryTable; |
| 1374 | ULONG64 ScopeIndex; |
| 1375 | BOOLEAN ControlPcIsUnwound; |
| 1376 | PBYTE NonVolatileRegisters; |
| 1377 | ULONG64 Reserved; |
| 1378 | } DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT; |
| 1379 | |
| 1380 | #elif defined(_AMD64_) |
| 1381 | |
| 1382 | typedef struct _DISPATCHER_CONTEXT { |
| 1383 | ULONG64 ControlPc; |
| 1384 | ULONG64 ImageBase; |
| 1385 | PRUNTIME_FUNCTION FunctionEntry; |
| 1386 | ULONG64 EstablisherFrame; |
| 1387 | ULONG64 TargetIp; |
| 1388 | PCONTEXT ContextRecord; |
| 1389 | PEXCEPTION_ROUTINE LanguageHandler; |
| 1390 | PVOID HandlerData; |
| 1391 | PUNWIND_HISTORY_TABLE HistoryTable; |
| 1392 | } DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT; |
| 1393 | |
| 1394 | #elif defined(_X86_) |
| 1395 | |
| 1396 | typedef struct _DISPATCHER_CONTEXT { |
| 1397 | DWORD ControlPc; |
| 1398 | DWORD ImageBase; |
| 1399 | PRUNTIME_FUNCTION FunctionEntry; |
| 1400 | DWORD EstablisherFrame; |
| 1401 | DWORD TargetIp; |
| 1402 | PKNONVOLATILE_CONTEXT CurrentNonVolatileContextRecord; |
| 1403 | PCONTEXT ContextRecord; |
| 1404 | PEXCEPTION_ROUTINE LanguageHandler; |
| 1405 | PVOID HandlerData; |
| 1406 | PUNWIND_HISTORY_TABLE HistoryTable; |
| 1407 | BOOLEAN ControlPcIsUnwound; |
| 1408 | } DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT; |
| 1409 | |
| 1410 | #else |
| 1411 | |
| 1412 | #error Unknown architecture for defining DISPATCHER_CONTEXT. |
| 1413 | |
| 1414 | #endif |
| 1415 | |
| 1416 | // #endif // !defined(_TARGET_MAC64) |
| 1417 | |
| 1418 | typedef DISPATCHER_CONTEXT *PDISPATCHER_CONTEXT; |
| 1419 | |
| 1420 | #define ExceptionContinueSearch EXCEPTION_CONTINUE_SEARCH |
| 1421 | #define ExceptionStackUnwind EXCEPTION_EXECUTE_HANDLER |
| 1422 | #define ExceptionContinueExecution EXCEPTION_CONTINUE_EXECUTION |
| 1423 | |
| 1424 | #endif // FEATURE_PAL_SXS |
| 1425 | |
| 1426 | typedef struct _EXCEPTION_REGISTRATION_RECORD EXCEPTION_REGISTRATION_RECORD; |
| 1427 | typedef EXCEPTION_REGISTRATION_RECORD *PEXCEPTION_REGISTRATION_RECORD; |
| 1428 | |
| 1429 | typedef LPVOID HKEY; |
| 1430 | typedef LPVOID PACL; |
| 1431 | typedef LPVOID LPBC; |
| 1432 | typedef LPVOID PSECURITY_DESCRIPTOR; |
| 1433 | |
| 1434 | typedef struct _EXCEPTION_RECORD64 { |
| 1435 | DWORD ExceptionCode; |
| 1436 | ULONG ExceptionFlags; |
| 1437 | ULONG64 ExceptionRecord; |
| 1438 | ULONG64 ExceptionAddress; |
| 1439 | ULONG NumberParameters; |
| 1440 | ULONG __unusedAlignment; |
| 1441 | ULONG64 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; |
| 1442 | } EXCEPTION_RECORD64, *PEXCEPTION_RECORD64; |
| 1443 | |
| 1444 | typedef LONG (WINAPI *PTOP_LEVEL_EXCEPTION_FILTER)( |
| 1445 | IN struct _EXCEPTION_POINTERS *ExceptionInfo |
| 1446 | ); |
| 1447 | typedef PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER; |
| 1448 | |
| 1449 | /******************* ntdef ************************************/ |
| 1450 | |
| 1451 | #ifndef ANYSIZE_ARRAY |
| 1452 | #define ANYSIZE_ARRAY 1 // winnt |
| 1453 | #endif |
| 1454 | |
| 1455 | /******************* winnt ************************************/ |
| 1456 | |
| 1457 | typedef struct LIST_ENTRY32 { |
| 1458 | ULONG Flink; |
| 1459 | ULONG Blink; |
| 1460 | } LIST_ENTRY32; |
| 1461 | typedef LIST_ENTRY32 *PLIST_ENTRY32; |
| 1462 | |
| 1463 | typedef struct LIST_ENTRY64 { |
| 1464 | ULONGLONG Flink; |
| 1465 | ULONGLONG Blink; |
| 1466 | } LIST_ENTRY64; |
| 1467 | typedef LIST_ENTRY64 *PLIST_ENTRY64; |
| 1468 | |
| 1469 | /******************** PAL RT APIs *******************************/ |
| 1470 | |
| 1471 | typedef struct _HSATELLITE *HSATELLITE; |
| 1472 | |
| 1473 | EXTERN_C HSATELLITE PALAPI PAL_LoadSatelliteResourceW(LPCWSTR SatelliteResourceFileName); |
| 1474 | EXTERN_C HSATELLITE PALAPI PAL_LoadSatelliteResourceA(LPCSTR SatelliteResourceFileName); |
| 1475 | EXTERN_C BOOL PALAPI PAL_FreeSatelliteResource(HSATELLITE SatelliteResource); |
| 1476 | EXTERN_C UINT PALAPI PAL_LoadSatelliteStringW(HSATELLITE SatelliteResource, |
| 1477 | UINT uID, |
| 1478 | LPWSTR lpBuffer, |
| 1479 | UINT nBufferMax); |
| 1480 | EXTERN_C UINT PALAPI PAL_LoadSatelliteStringA(HSATELLITE SatelliteResource, |
| 1481 | UINT uID, |
| 1482 | LPSTR lpBuffer, |
| 1483 | UINT nBufferMax); |
| 1484 | |
| 1485 | EXTERN_C HRESULT PALAPI PAL_CoCreateInstance(REFCLSID rclsid, |
| 1486 | REFIID riid, |
| 1487 | void **ppv); |
| 1488 | |
| 1489 | // So we can have CoCreateInstance in most of the code base, |
| 1490 | // instead of spreading around of if'def FEATURE_PALs for PAL_CoCreateInstance. |
| 1491 | #define CoCreateInstance(rclsid, pUnkOuter, dwClsContext, riid, ppv) PAL_CoCreateInstance(rclsid, riid, ppv) |
| 1492 | |
| 1493 | STDAPI |
| 1494 | CoCreateGuid(OUT GUID * pguid); |
| 1495 | |
| 1496 | /************** verrsrc.h ************************************/ |
| 1497 | |
| 1498 | /* ----- VS_VERSION.dwFileFlags ----- */ |
| 1499 | #define VS_FF_DEBUG 0x00000001L |
| 1500 | #define VS_FF_PRERELEASE 0x00000002L |
| 1501 | #define VS_FF_PATCHED 0x00000004L |
| 1502 | #define VS_FF_PRIVATEBUILD 0x00000008L |
| 1503 | #define VS_FF_INFOINFERRED 0x00000010L |
| 1504 | #define VS_FF_SPECIALBUILD 0x00000020L |
| 1505 | |
| 1506 | /* ----- Types and structures ----- */ |
| 1507 | typedef struct tagVS_FIXEDFILEINFO |
| 1508 | { |
| 1509 | DWORD dwSignature; /* e.g. 0xfeef04bd */ |
| 1510 | DWORD dwStrucVersion; /* e.g. 0x00000042 = "0.42" */ |
| 1511 | DWORD dwFileVersionMS; /* e.g. 0x00030075 = "3.75" */ |
| 1512 | DWORD dwFileVersionLS; /* e.g. 0x00000031 = "0.31" */ |
| 1513 | DWORD dwProductVersionMS; /* e.g. 0x00030010 = "3.10" */ |
| 1514 | DWORD dwProductVersionLS; /* e.g. 0x00000031 = "0.31" */ |
| 1515 | DWORD dwFileFlagsMask; /* = 0x3F for version "0.42" */ |
| 1516 | DWORD dwFileFlags; /* e.g. VFF_DEBUG | VFF_PRERELEASE */ |
| 1517 | DWORD dwFileOS; /* e.g. VOS_DOS_WINDOWS16 */ |
| 1518 | DWORD dwFileType; /* e.g. VFT_DRIVER */ |
| 1519 | DWORD dwFileSubtype; /* e.g. VFT2_DRV_KEYBOARD */ |
| 1520 | DWORD dwFileDateMS; /* e.g. 0 */ |
| 1521 | DWORD dwFileDateLS; /* e.g. 0 */ |
| 1522 | } VS_FIXEDFILEINFO; |
| 1523 | |
| 1524 | /************** Byte swapping & unaligned access ******************/ |
| 1525 | |
| 1526 | #include <pal_endian.h> |
| 1527 | |
| 1528 | /******************** external includes *************************/ |
| 1529 | |
| 1530 | #include "ntimage.h" |
| 1531 | |
| 1532 | #endif // RC_INVOKED |
| 1533 | |
| 1534 | #endif // __PALRT_H__ |
| 1535 | |