1 From bf25c45e540d7e961704c245e7be439b580c93c2 Mon Sep 17 00:00:00 2001
2 From: Nicolas Dufresne <nicolas.dufresne@collabora.com>
3 Date: Thu, 30 Jun 2016 15:08:17 -0400
4 Subject: Add missing windows specific headers
6 https://bugs.freedesktop.org/show_bug.cgi?id=96754
8 diff --git a/webrtc/base/win32.h b/webrtc/base/win32.h
10 index 0000000..6969c10
12 +++ b/webrtc/base/win32.h
15 + * Copyright 2004 The WebRTC Project Authors. All rights reserved.
17 + * Use of this source code is governed by a BSD-style license
18 + * that can be found in the LICENSE file in the root of the source
19 + * tree. An additional intellectual property rights grant can be found
20 + * in the file PATENTS. All contributing project authors may
21 + * be found in the AUTHORS file in the root of the source tree.
23 +#ifndef WEBRTC_BASE_WIN32_H_
24 +#define WEBRTC_BASE_WIN32_H_
25 +#if defined(WEBRTC_WIN)
26 +#ifndef WIN32_LEAN_AND_MEAN
27 +#define WIN32_LEAN_AND_MEAN
29 +// Make sure we don't get min/max macros
33 +#include <winsock2.h>
35 +#ifndef SECURITY_MANDATORY_LABEL_AUTHORITY
36 +// Add defines that we use if we are compiling against older sdks
37 +#define SECURITY_MANDATORY_MEDIUM_RID (0x00002000L)
38 +#define TokenIntegrityLevel static_cast<TOKEN_INFORMATION_CLASS>(0x19)
39 +typedef struct _TOKEN_MANDATORY_LABEL {
40 + SID_AND_ATTRIBUTES Label;
41 +} TOKEN_MANDATORY_LABEL, *PTOKEN_MANDATORY_LABEL;
42 +#endif // SECURITY_MANDATORY_LABEL_AUTHORITY
45 +#include "webrtc/base/stringutils.h"
46 +#include "webrtc/base/basictypes.h"
48 +const char* win32_inet_ntop(int af, const void *src, char* dst, socklen_t size);
49 +int win32_inet_pton(int af, const char* src, void *dst);
50 +inline std::wstring ToUtf16(const char* utf8, size_t len) {
51 + int len16 = ::MultiByteToWideChar(CP_UTF8, 0, utf8, static_cast<int>(len),
53 + wchar_t* ws = STACK_ARRAY(wchar_t, len16);
54 + ::MultiByteToWideChar(CP_UTF8, 0, utf8, static_cast<int>(len), ws, len16);
55 + return std::wstring(ws, len16);
57 +inline std::wstring ToUtf16(const std::string& str) {
58 + return ToUtf16(str.data(), str.length());
60 +inline std::string ToUtf8(const wchar_t* wide, size_t len) {
61 + int len8 = ::WideCharToMultiByte(CP_UTF8, 0, wide, static_cast<int>(len),
62 + NULL, 0, NULL, NULL);
63 + char* ns = STACK_ARRAY(char, len8);
64 + ::WideCharToMultiByte(CP_UTF8, 0, wide, static_cast<int>(len), ns, len8,
66 + return std::string(ns, len8);
68 +inline std::string ToUtf8(const wchar_t* wide) {
69 + return ToUtf8(wide, wcslen(wide));
71 +inline std::string ToUtf8(const std::wstring& wstr) {
72 + return ToUtf8(wstr.data(), wstr.length());
74 +// Convert FILETIME to time_t
75 +void FileTimeToUnixTime(const FILETIME& ft, time_t* ut);
76 +// Convert time_t to FILETIME
77 +void UnixTimeToFileTime(const time_t& ut, FILETIME * ft);
78 +// Convert a Utf8 path representation to a non-length-limited Unicode pathname.
79 +bool Utf8ToWindowsFilename(const std::string& utf8, std::wstring* filename);
80 +// Convert a FILETIME to a UInt64
81 +inline uint64_t ToUInt64(const FILETIME& ft) {
82 + ULARGE_INTEGER r = {{ft.dwLowDateTime, ft.dwHighDateTime}};
85 +enum WindowsMajorVersions {
89 +bool GetOsVersion(int* major, int* minor, int* build);
90 +inline bool IsWindowsVistaOrLater() {
92 + return (GetOsVersion(&major, NULL, NULL) && major >= kWindowsVista);
94 +inline bool IsWindowsXpOrLater() {
96 + return (GetOsVersion(&major, &minor, NULL) &&
97 + (major >= kWindowsVista ||
98 + (major == kWindows2000 && minor >= 1)));
100 +inline bool IsWindows8OrLater() {
102 + return (GetOsVersion(&major, &minor, NULL) &&
103 + (major > kWindowsVista ||
104 + (major == kWindowsVista && minor >= 2)));
106 +// Determine the current integrity level of the process.
107 +bool GetCurrentProcessIntegrityLevel(int* level);
108 +inline bool IsCurrentProcessLowIntegrity() {
110 + return (GetCurrentProcessIntegrityLevel(&level) &&
111 + level < SECURITY_MANDATORY_MEDIUM_RID);
113 +bool AdjustCurrentProcessPrivilege(const TCHAR* privilege, bool to_enable);
115 +#endif // WEBRTC_WIN
116 +#endif // WEBRTC_BASE_WIN32_H_