|
|
b4fabd |
From bf25c45e540d7e961704c245e7be439b580c93c2 Mon Sep 17 00:00:00 2001
|
|
|
b4fabd |
From: Nicolas Dufresne <nicolas.dufresne@collabora.com>
|
|
|
b4fabd |
Date: Thu, 30 Jun 2016 15:08:17 -0400
|
|
|
b4fabd |
Subject: [PATCH 01/16] Add missing windows specific headers
|
|
|
b4fabd |
|
|
|
b4fabd |
https://bugs.freedesktop.org/show_bug.cgi?id=96754
|
|
|
b4fabd |
---
|
|
|
b4fabd |
webrtc/base/win32.h | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
b4fabd |
1 file changed, 103 insertions(+)
|
|
|
b4fabd |
create mode 100644 webrtc/base/win32.h
|
|
|
b4fabd |
|
|
|
b4fabd |
diff --git a/webrtc/base/win32.h b/webrtc/base/win32.h
|
|
|
b4fabd |
new file mode 100644
|
|
|
b4fabd |
index 0000000..6969c10
|
|
|
b4fabd |
--- /dev/null
|
|
|
b4fabd |
+++ b/webrtc/base/win32.h
|
|
|
b4fabd |
@@ -0,0 +1,103 @@
|
|
|
b4fabd |
+/*
|
|
|
b4fabd |
+ * Copyright 2004 The WebRTC Project Authors. All rights reserved.
|
|
|
b4fabd |
+ *
|
|
|
b4fabd |
+ * Use of this source code is governed by a BSD-style license
|
|
|
b4fabd |
+ * that can be found in the LICENSE file in the root of the source
|
|
|
b4fabd |
+ * tree. An additional intellectual property rights grant can be found
|
|
|
b4fabd |
+ * in the file PATENTS. All contributing project authors may
|
|
|
b4fabd |
+ * be found in the AUTHORS file in the root of the source tree.
|
|
|
b4fabd |
+ */
|
|
|
b4fabd |
+#ifndef WEBRTC_BASE_WIN32_H_
|
|
|
b4fabd |
+#define WEBRTC_BASE_WIN32_H_
|
|
|
b4fabd |
+#if defined(WEBRTC_WIN)
|
|
|
b4fabd |
+#ifndef WIN32_LEAN_AND_MEAN
|
|
|
b4fabd |
+#define WIN32_LEAN_AND_MEAN
|
|
|
b4fabd |
+#endif
|
|
|
b4fabd |
+// Make sure we don't get min/max macros
|
|
|
b4fabd |
+#ifndef NOMINMAX
|
|
|
b4fabd |
+#define NOMINMAX
|
|
|
b4fabd |
+#endif
|
|
|
b4fabd |
+#include <winsock2.h>
|
|
|
b4fabd |
+#include <windows.h>
|
|
|
b4fabd |
+#ifndef SECURITY_MANDATORY_LABEL_AUTHORITY
|
|
|
b4fabd |
+// Add defines that we use if we are compiling against older sdks
|
|
|
b4fabd |
+#define SECURITY_MANDATORY_MEDIUM_RID (0x00002000L)
|
|
|
b4fabd |
+#define TokenIntegrityLevel static_cast<TOKEN_INFORMATION_CLASS>(0x19)
|
|
|
b4fabd |
+typedef struct _TOKEN_MANDATORY_LABEL {
|
|
|
b4fabd |
+ SID_AND_ATTRIBUTES Label;
|
|
|
b4fabd |
+} TOKEN_MANDATORY_LABEL, *PTOKEN_MANDATORY_LABEL;
|
|
|
b4fabd |
+#endif // SECURITY_MANDATORY_LABEL_AUTHORITY
|
|
|
b4fabd |
+#undef SetPort
|
|
|
b4fabd |
+#include <string>
|
|
|
b4fabd |
+#include "webrtc/base/stringutils.h"
|
|
|
b4fabd |
+#include "webrtc/base/basictypes.h"
|
|
|
b4fabd |
+namespace rtc {
|
|
|
b4fabd |
+const char* win32_inet_ntop(int af, const void *src, char* dst, socklen_t size);
|
|
|
b4fabd |
+int win32_inet_pton(int af, const char* src, void *dst);
|
|
|
b4fabd |
+inline std::wstring ToUtf16(const char* utf8, size_t len) {
|
|
|
b4fabd |
+ int len16 = ::MultiByteToWideChar(CP_UTF8, 0, utf8, static_cast<int>(len),
|
|
|
b4fabd |
+ NULL, 0);
|
|
|
b4fabd |
+ wchar_t* ws = STACK_ARRAY(wchar_t, len16);
|
|
|
b4fabd |
+ ::MultiByteToWideChar(CP_UTF8, 0, utf8, static_cast<int>(len), ws, len16);
|
|
|
b4fabd |
+ return std::wstring(ws, len16);
|
|
|
b4fabd |
+}
|
|
|
b4fabd |
+inline std::wstring ToUtf16(const std::string& str) {
|
|
|
b4fabd |
+ return ToUtf16(str.data(), str.length());
|
|
|
b4fabd |
+}
|
|
|
b4fabd |
+inline std::string ToUtf8(const wchar_t* wide, size_t len) {
|
|
|
b4fabd |
+ int len8 = ::WideCharToMultiByte(CP_UTF8, 0, wide, static_cast<int>(len),
|
|
|
b4fabd |
+ NULL, 0, NULL, NULL);
|
|
|
b4fabd |
+ char* ns = STACK_ARRAY(char, len8);
|
|
|
b4fabd |
+ ::WideCharToMultiByte(CP_UTF8, 0, wide, static_cast<int>(len), ns, len8,
|
|
|
b4fabd |
+ NULL, NULL);
|
|
|
b4fabd |
+ return std::string(ns, len8);
|
|
|
b4fabd |
+}
|
|
|
b4fabd |
+inline std::string ToUtf8(const wchar_t* wide) {
|
|
|
b4fabd |
+ return ToUtf8(wide, wcslen(wide));
|
|
|
b4fabd |
+}
|
|
|
b4fabd |
+inline std::string ToUtf8(const std::wstring& wstr) {
|
|
|
b4fabd |
+ return ToUtf8(wstr.data(), wstr.length());
|
|
|
b4fabd |
+}
|
|
|
b4fabd |
+// Convert FILETIME to time_t
|
|
|
b4fabd |
+void FileTimeToUnixTime(const FILETIME& ft, time_t* ut);
|
|
|
b4fabd |
+// Convert time_t to FILETIME
|
|
|
b4fabd |
+void UnixTimeToFileTime(const time_t& ut, FILETIME * ft);
|
|
|
b4fabd |
+// Convert a Utf8 path representation to a non-length-limited Unicode pathname.
|
|
|
b4fabd |
+bool Utf8ToWindowsFilename(const std::string& utf8, std::wstring* filename);
|
|
|
b4fabd |
+// Convert a FILETIME to a UInt64
|
|
|
b4fabd |
+inline uint64_t ToUInt64(const FILETIME& ft) {
|
|
|
b4fabd |
+ ULARGE_INTEGER r = {{ft.dwLowDateTime, ft.dwHighDateTime}};
|
|
|
b4fabd |
+ return r.QuadPart;
|
|
|
b4fabd |
+}
|
|
|
b4fabd |
+enum WindowsMajorVersions {
|
|
|
b4fabd |
+ kWindows2000 = 5,
|
|
|
b4fabd |
+ kWindowsVista = 6,
|
|
|
b4fabd |
+};
|
|
|
b4fabd |
+bool GetOsVersion(int* major, int* minor, int* build);
|
|
|
b4fabd |
+inline bool IsWindowsVistaOrLater() {
|
|
|
b4fabd |
+ int major;
|
|
|
b4fabd |
+ return (GetOsVersion(&major, NULL, NULL) && major >= kWindowsVista);
|
|
|
b4fabd |
+}
|
|
|
b4fabd |
+inline bool IsWindowsXpOrLater() {
|
|
|
b4fabd |
+ int major, minor;
|
|
|
b4fabd |
+ return (GetOsVersion(&major, &minor, NULL) &&
|
|
|
b4fabd |
+ (major >= kWindowsVista ||
|
|
|
b4fabd |
+ (major == kWindows2000 && minor >= 1)));
|
|
|
b4fabd |
+}
|
|
|
b4fabd |
+inline bool IsWindows8OrLater() {
|
|
|
b4fabd |
+ int major, minor;
|
|
|
b4fabd |
+ return (GetOsVersion(&major, &minor, NULL) &&
|
|
|
b4fabd |
+ (major > kWindowsVista ||
|
|
|
b4fabd |
+ (major == kWindowsVista && minor >= 2)));
|
|
|
b4fabd |
+}
|
|
|
b4fabd |
+// Determine the current integrity level of the process.
|
|
|
b4fabd |
+bool GetCurrentProcessIntegrityLevel(int* level);
|
|
|
b4fabd |
+inline bool IsCurrentProcessLowIntegrity() {
|
|
|
b4fabd |
+ int level;
|
|
|
b4fabd |
+ return (GetCurrentProcessIntegrityLevel(&level) &&
|
|
|
b4fabd |
+ level < SECURITY_MANDATORY_MEDIUM_RID);
|
|
|
b4fabd |
+}
|
|
|
b4fabd |
+bool AdjustCurrentProcessPrivilege(const TCHAR* privilege, bool to_enable);
|
|
|
b4fabd |
+} // namespace rtc
|
|
|
b4fabd |
+#endif // WEBRTC_WIN
|
|
|
b4fabd |
+#endif // WEBRTC_BASE_WIN32_H_
|
|
|
b4fabd |
--
|
|
|
b4fabd |
2.14.3
|
|
|
b4fabd |
|