henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef RTC_BASE_WIN32_H_ |
| 12 | #define RTC_BASE_WIN32_H_ |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 13 | |
Henrik Kjellander | ec78f1c | 2017-06-29 07:52:50 +0200 | [diff] [blame] | 14 | #if defined(WEBRTC_WIN) |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 15 | |
Henrik Kjellander | ec78f1c | 2017-06-29 07:52:50 +0200 | [diff] [blame] | 16 | #ifndef WIN32_LEAN_AND_MEAN |
| 17 | #define WIN32_LEAN_AND_MEAN |
| 18 | #endif |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 19 | |
Henrik Kjellander | ec78f1c | 2017-06-29 07:52:50 +0200 | [diff] [blame] | 20 | // Make sure we don't get min/max macros |
| 21 | #ifndef NOMINMAX |
| 22 | #define NOMINMAX |
| 23 | #endif |
| 24 | |
| 25 | #include <winsock2.h> |
| 26 | #include <windows.h> |
| 27 | |
| 28 | #ifndef SECURITY_MANDATORY_LABEL_AUTHORITY |
| 29 | // Add defines that we use if we are compiling against older sdks |
| 30 | #define SECURITY_MANDATORY_MEDIUM_RID (0x00002000L) |
| 31 | #define TokenIntegrityLevel static_cast<TOKEN_INFORMATION_CLASS>(0x19) |
| 32 | typedef struct _TOKEN_MANDATORY_LABEL { |
| 33 | SID_AND_ATTRIBUTES Label; |
| 34 | } TOKEN_MANDATORY_LABEL, *PTOKEN_MANDATORY_LABEL; |
| 35 | #endif // SECURITY_MANDATORY_LABEL_AUTHORITY |
| 36 | |
| 37 | #undef SetPort |
| 38 | |
| 39 | #include <string> |
| 40 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 41 | #include "rtc_base/basictypes.h" |
| 42 | #include "rtc_base/stringutils.h" |
Henrik Kjellander | ec78f1c | 2017-06-29 07:52:50 +0200 | [diff] [blame] | 43 | |
| 44 | namespace rtc { |
| 45 | |
| 46 | const char* win32_inet_ntop(int af, const void *src, char* dst, socklen_t size); |
| 47 | int win32_inet_pton(int af, const char* src, void *dst); |
| 48 | |
Henrik Kjellander | ec78f1c | 2017-06-29 07:52:50 +0200 | [diff] [blame] | 49 | // Convert a Utf8 path representation to a non-length-limited Unicode pathname. |
| 50 | bool Utf8ToWindowsFilename(const std::string& utf8, std::wstring* filename); |
| 51 | |
Henrik Kjellander | ec78f1c | 2017-06-29 07:52:50 +0200 | [diff] [blame] | 52 | enum WindowsMajorVersions { |
| 53 | kWindows2000 = 5, |
| 54 | kWindowsVista = 6, |
| 55 | }; |
| 56 | bool GetOsVersion(int* major, int* minor, int* build); |
| 57 | |
| 58 | inline bool IsWindowsVistaOrLater() { |
| 59 | int major; |
| 60 | return (GetOsVersion(&major, nullptr, nullptr) && major >= kWindowsVista); |
| 61 | } |
| 62 | |
| 63 | inline bool IsWindowsXpOrLater() { |
| 64 | int major, minor; |
| 65 | return (GetOsVersion(&major, &minor, nullptr) && |
| 66 | (major >= kWindowsVista || (major == kWindows2000 && minor >= 1))); |
| 67 | } |
| 68 | |
| 69 | inline bool IsWindows8OrLater() { |
| 70 | int major, minor; |
| 71 | return (GetOsVersion(&major, &minor, nullptr) && |
| 72 | (major > kWindowsVista || (major == kWindowsVista && minor >= 2))); |
| 73 | } |
| 74 | |
| 75 | // Determine the current integrity level of the process. |
| 76 | bool GetCurrentProcessIntegrityLevel(int* level); |
| 77 | |
| 78 | inline bool IsCurrentProcessLowIntegrity() { |
| 79 | int level; |
| 80 | return (GetCurrentProcessIntegrityLevel(&level) && |
| 81 | level < SECURITY_MANDATORY_MEDIUM_RID); |
| 82 | } |
| 83 | |
| 84 | } // namespace rtc |
| 85 | |
| 86 | #endif // WEBRTC_WIN |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 87 | #endif // RTC_BASE_WIN32_H_ |