henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [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 04:47:31 | [diff] [blame] | 11 | #include "rtc_base/win32.h" |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 12 | |
| 13 | #include <winsock2.h> |
| 14 | #include <ws2tcpip.h> |
| 15 | #include <algorithm> |
| 16 | |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 17 | #include "rtc_base/arraysize.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 18 | #include "rtc_base/byteorder.h" |
| 19 | #include "rtc_base/checks.h" |
| 20 | #include "rtc_base/logging.h" |
Niels Möller | d7b9131 | 2018-05-24 09:21:34 | [diff] [blame] | 21 | #include "rtc_base/stringutils.h" |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 22 | |
| 23 | namespace rtc { |
| 24 | |
| 25 | // Helper function declarations for inet_ntop/inet_pton. |
| 26 | static const char* inet_ntop_v4(const void* src, char* dst, socklen_t size); |
| 27 | static const char* inet_ntop_v6(const void* src, char* dst, socklen_t size); |
| 28 | static int inet_pton_v4(const char* src, void* dst); |
| 29 | static int inet_pton_v6(const char* src, void* dst); |
| 30 | |
| 31 | // Implementation of inet_ntop (create a printable representation of an |
| 32 | // ip address). XP doesn't have its own inet_ntop, and |
| 33 | // WSAAddressToString requires both IPv6 to be installed and for Winsock |
| 34 | // to be initialized. |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 35 | const char* win32_inet_ntop(int af, |
| 36 | const void* src, |
| 37 | char* dst, |
| 38 | socklen_t size) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 39 | if (!src || !dst) { |
deadbeef | 37f5ecf | 2017-02-27 22:06:41 | [diff] [blame] | 40 | return nullptr; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 41 | } |
| 42 | switch (af) { |
| 43 | case AF_INET: { |
| 44 | return inet_ntop_v4(src, dst, size); |
| 45 | } |
| 46 | case AF_INET6: { |
| 47 | return inet_ntop_v6(src, dst, size); |
| 48 | } |
| 49 | } |
deadbeef | 37f5ecf | 2017-02-27 22:06:41 | [diff] [blame] | 50 | return nullptr; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | // As above, but for inet_pton. Implements inet_pton for v4 and v6. |
| 54 | // Note that our inet_ntop will output normal 'dotted' v4 addresses only. |
| 55 | int win32_inet_pton(int af, const char* src, void* dst) { |
| 56 | if (!src || !dst) { |
| 57 | return 0; |
| 58 | } |
| 59 | if (af == AF_INET) { |
| 60 | return inet_pton_v4(src, dst); |
| 61 | } else if (af == AF_INET6) { |
| 62 | return inet_pton_v6(src, dst); |
| 63 | } |
| 64 | return -1; |
| 65 | } |
| 66 | |
| 67 | // Helper function for inet_ntop for IPv4 addresses. |
| 68 | // Outputs "dotted-quad" decimal notation. |
| 69 | const char* inet_ntop_v4(const void* src, char* dst, socklen_t size) { |
| 70 | if (size < INET_ADDRSTRLEN) { |
deadbeef | 37f5ecf | 2017-02-27 22:06:41 | [diff] [blame] | 71 | return nullptr; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 72 | } |
| 73 | const struct in_addr* as_in_addr = |
| 74 | reinterpret_cast<const struct in_addr*>(src); |
Niels Möller | aba0633 | 2018-10-16 13:14:15 | [diff] [blame^] | 75 | snprintf(dst, size, "%d.%d.%d.%d", as_in_addr->S_un.S_un_b.s_b1, |
| 76 | as_in_addr->S_un.S_un_b.s_b2, as_in_addr->S_un.S_un_b.s_b3, |
| 77 | as_in_addr->S_un.S_un_b.s_b4); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 78 | return dst; |
| 79 | } |
| 80 | |
| 81 | // Helper function for inet_ntop for IPv6 addresses. |
| 82 | const char* inet_ntop_v6(const void* src, char* dst, socklen_t size) { |
| 83 | if (size < INET6_ADDRSTRLEN) { |
deadbeef | 37f5ecf | 2017-02-27 22:06:41 | [diff] [blame] | 84 | return nullptr; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 85 | } |
Peter Boström | 0c4e06b | 2015-10-07 10:23:21 | [diff] [blame] | 86 | const uint16_t* as_shorts = reinterpret_cast<const uint16_t*>(src); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 87 | int runpos[8]; |
| 88 | int current = 1; |
guoweis@webrtc.org | b08f404 | 2015-02-17 19:00:42 | [diff] [blame] | 89 | int max = 0; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 90 | int maxpos = -1; |
tfarina | 5237aaf | 2015-11-11 07:44:30 | [diff] [blame] | 91 | int run_array_size = arraysize(runpos); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 92 | // Run over the address marking runs of 0s. |
| 93 | for (int i = 0; i < run_array_size; ++i) { |
| 94 | if (as_shorts[i] == 0) { |
| 95 | runpos[i] = current; |
| 96 | if (current > max) { |
| 97 | maxpos = i; |
| 98 | max = current; |
| 99 | } |
| 100 | ++current; |
| 101 | } else { |
| 102 | runpos[i] = -1; |
guoweis@webrtc.org | b08f404 | 2015-02-17 19:00:42 | [diff] [blame] | 103 | current = 1; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 104 | } |
| 105 | } |
| 106 | |
guoweis@webrtc.org | b08f404 | 2015-02-17 19:00:42 | [diff] [blame] | 107 | if (max > 0) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 108 | int tmpmax = maxpos; |
| 109 | // Run back through, setting -1 for all but the longest run. |
| 110 | for (int i = run_array_size - 1; i >= 0; i--) { |
| 111 | if (i > tmpmax) { |
| 112 | runpos[i] = -1; |
| 113 | } else if (runpos[i] == -1) { |
| 114 | // We're less than maxpos, we hit a -1, so the 'good' run is done. |
| 115 | // Setting tmpmax -1 means all remaining positions get set to -1. |
| 116 | tmpmax = -1; |
| 117 | } |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | char* cursor = dst; |
| 122 | // Print IPv4 compatible and IPv4 mapped addresses using the IPv4 helper. |
| 123 | // These addresses have an initial run of either eight zero-bytes followed |
| 124 | // by 0xFFFF, or an initial run of ten zero-bytes. |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 125 | if (runpos[0] == 1 && |
| 126 | (maxpos == 5 || (maxpos == 4 && as_shorts[5] == 0xFFFF))) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 127 | *cursor++ = ':'; |
| 128 | *cursor++ = ':'; |
| 129 | if (maxpos == 4) { |
Niels Möller | aba0633 | 2018-10-16 13:14:15 | [diff] [blame^] | 130 | cursor += snprintf(cursor, INET6_ADDRSTRLEN - 2, "ffff:"); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 131 | } |
| 132 | const struct in_addr* as_v4 = |
| 133 | reinterpret_cast<const struct in_addr*>(&(as_shorts[6])); |
| 134 | inet_ntop_v4(as_v4, cursor, |
| 135 | static_cast<socklen_t>(INET6_ADDRSTRLEN - (cursor - dst))); |
| 136 | } else { |
| 137 | for (int i = 0; i < run_array_size; ++i) { |
| 138 | if (runpos[i] == -1) { |
Niels Möller | aba0633 | 2018-10-16 13:14:15 | [diff] [blame^] | 139 | cursor += snprintf(cursor, INET6_ADDRSTRLEN - (cursor - dst), "%x", |
| 140 | NetworkToHost16(as_shorts[i])); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 141 | if (i != 7 && runpos[i + 1] != 1) { |
| 142 | *cursor++ = ':'; |
| 143 | } |
| 144 | } else if (runpos[i] == 1) { |
| 145 | // Entered the run; print the colons and skip the run. |
| 146 | *cursor++ = ':'; |
| 147 | *cursor++ = ':'; |
| 148 | i += (max - 1); |
| 149 | } |
| 150 | } |
| 151 | } |
| 152 | return dst; |
| 153 | } |
| 154 | |
| 155 | // Helper function for inet_pton for IPv4 addresses. |
| 156 | // |src| points to a character string containing an IPv4 network address in |
| 157 | // dotted-decimal format, "ddd.ddd.ddd.ddd", where ddd is a decimal number |
| 158 | // of up to three digits in the range 0 to 255. |
| 159 | // The address is converted and copied to dst, |
| 160 | // which must be sizeof(struct in_addr) (4) bytes (32 bits) long. |
| 161 | int inet_pton_v4(const char* src, void* dst) { |
| 162 | const int kIpv4AddressSize = 4; |
| 163 | int found = 0; |
| 164 | const char* src_pos = src; |
| 165 | unsigned char result[kIpv4AddressSize] = {0}; |
| 166 | |
| 167 | while (*src_pos != '\0') { |
| 168 | // strtol won't treat whitespace characters in the begining as an error, |
| 169 | // so check to ensure this is started with digit before passing to strtol. |
| 170 | if (!isdigit(*src_pos)) { |
| 171 | return 0; |
| 172 | } |
| 173 | char* end_pos; |
| 174 | long value = strtol(src_pos, &end_pos, 10); |
| 175 | if (value < 0 || value > 255 || src_pos == end_pos) { |
| 176 | return 0; |
| 177 | } |
| 178 | ++found; |
| 179 | if (found > kIpv4AddressSize) { |
| 180 | return 0; |
| 181 | } |
| 182 | result[found - 1] = static_cast<unsigned char>(value); |
| 183 | src_pos = end_pos; |
| 184 | if (*src_pos == '.') { |
| 185 | // There's more. |
| 186 | ++src_pos; |
| 187 | } else if (*src_pos != '\0') { |
| 188 | // If it's neither '.' nor '\0' then return fail. |
| 189 | return 0; |
| 190 | } |
| 191 | } |
| 192 | if (found != kIpv4AddressSize) { |
| 193 | return 0; |
| 194 | } |
| 195 | memcpy(dst, result, sizeof(result)); |
| 196 | return 1; |
| 197 | } |
| 198 | |
| 199 | // Helper function for inet_pton for IPv6 addresses. |
| 200 | int inet_pton_v6(const char* src, void* dst) { |
| 201 | // sscanf will pick any other invalid chars up, but it parses 0xnnnn as hex. |
| 202 | // Check for literal x in the input string. |
| 203 | const char* readcursor = src; |
| 204 | char c = *readcursor++; |
| 205 | while (c) { |
| 206 | if (c == 'x') { |
| 207 | return 0; |
| 208 | } |
| 209 | c = *readcursor++; |
| 210 | } |
| 211 | readcursor = src; |
| 212 | |
| 213 | struct in6_addr an_addr; |
| 214 | memset(&an_addr, 0, sizeof(an_addr)); |
| 215 | |
Peter Boström | 0c4e06b | 2015-10-07 10:23:21 | [diff] [blame] | 216 | uint16_t* addr_cursor = reinterpret_cast<uint16_t*>(&an_addr.s6_addr[0]); |
| 217 | uint16_t* addr_end = reinterpret_cast<uint16_t*>(&an_addr.s6_addr[16]); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 218 | bool seencompressed = false; |
| 219 | |
| 220 | // Addresses that start with "::" (i.e., a run of initial zeros) or |
| 221 | // "::ffff:" can potentially be IPv4 mapped or compatibility addresses. |
| 222 | // These have dotted-style IPv4 addresses on the end (e.g. "::192.168.7.1"). |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 223 | if (*readcursor == ':' && *(readcursor + 1) == ':' && |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 224 | *(readcursor + 2) != 0) { |
| 225 | // Check for periods, which we'll take as a sign of v4 addresses. |
| 226 | const char* addrstart = readcursor + 2; |
| 227 | if (rtc::strchr(addrstart, ".")) { |
| 228 | const char* colon = rtc::strchr(addrstart, "::"); |
| 229 | if (colon) { |
Peter Boström | 0c4e06b | 2015-10-07 10:23:21 | [diff] [blame] | 230 | uint16_t a_short; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 231 | int bytesread = 0; |
| 232 | if (sscanf(addrstart, "%hx%n", &a_short, &bytesread) != 1 || |
| 233 | a_short != 0xFFFF || bytesread != 4) { |
| 234 | // Colons + periods means has to be ::ffff:a.b.c.d. But it wasn't. |
| 235 | return 0; |
| 236 | } else { |
| 237 | an_addr.s6_addr[10] = 0xFF; |
| 238 | an_addr.s6_addr[11] = 0xFF; |
| 239 | addrstart = colon + 1; |
| 240 | } |
| 241 | } |
| 242 | struct in_addr v4; |
| 243 | if (inet_pton_v4(addrstart, &v4.s_addr)) { |
| 244 | memcpy(&an_addr.s6_addr[12], &v4, sizeof(v4)); |
| 245 | memcpy(dst, &an_addr, sizeof(an_addr)); |
| 246 | return 1; |
| 247 | } else { |
| 248 | // Invalid v4 address. |
| 249 | return 0; |
| 250 | } |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | // For addresses without a trailing IPv4 component ('normal' IPv6 addresses). |
| 255 | while (*readcursor != 0 && addr_cursor < addr_end) { |
| 256 | if (*readcursor == ':') { |
| 257 | if (*(readcursor + 1) == ':') { |
| 258 | if (seencompressed) { |
| 259 | // Can only have one compressed run of zeroes ("::") per address. |
| 260 | return 0; |
| 261 | } |
| 262 | // Hit a compressed run. Count colons to figure out how much of the |
| 263 | // address is skipped. |
| 264 | readcursor += 2; |
| 265 | const char* coloncounter = readcursor; |
| 266 | int coloncount = 0; |
| 267 | if (*coloncounter == 0) { |
| 268 | // Special case - trailing ::. |
| 269 | addr_cursor = addr_end; |
| 270 | } else { |
| 271 | while (*coloncounter) { |
| 272 | if (*coloncounter == ':') { |
| 273 | ++coloncount; |
| 274 | } |
| 275 | ++coloncounter; |
| 276 | } |
| 277 | // (coloncount + 1) is the number of shorts left in the address. |
deadbeef | 966963a | 2017-05-08 18:35:56 | [diff] [blame] | 278 | // If this number is greater than the number of available shorts, the |
| 279 | // address is malformed. |
| 280 | if (coloncount + 1 > addr_end - addr_cursor) { |
| 281 | return 0; |
| 282 | } |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 283 | addr_cursor = addr_end - (coloncount + 1); |
| 284 | seencompressed = true; |
| 285 | } |
| 286 | } else { |
| 287 | ++readcursor; |
| 288 | } |
| 289 | } else { |
Peter Boström | 0c4e06b | 2015-10-07 10:23:21 | [diff] [blame] | 290 | uint16_t word; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 291 | int bytesread = 0; |
deadbeef | 966963a | 2017-05-08 18:35:56 | [diff] [blame] | 292 | if (sscanf(readcursor, "%4hx%n", &word, &bytesread) != 1) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 293 | return 0; |
| 294 | } else { |
| 295 | *addr_cursor = HostToNetwork16(word); |
| 296 | ++addr_cursor; |
| 297 | readcursor += bytesread; |
| 298 | if (*readcursor != ':' && *readcursor != '\0') { |
| 299 | return 0; |
| 300 | } |
| 301 | } |
| 302 | } |
| 303 | } |
| 304 | |
| 305 | if (*readcursor != '\0' || addr_cursor < addr_end) { |
| 306 | // Catches addresses too short or too long. |
| 307 | return 0; |
| 308 | } |
| 309 | memcpy(dst, &an_addr, sizeof(an_addr)); |
| 310 | return 1; |
| 311 | } |
| 312 | |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 313 | bool Utf8ToWindowsFilename(const std::string& utf8, std::wstring* filename) { |
| 314 | // TODO: Integrate into fileutils.h |
| 315 | // TODO: Handle wide and non-wide cases via TCHAR? |
| 316 | // TODO: Skip \\?\ processing if the length is not > MAX_PATH? |
| 317 | // TODO: Write unittests |
| 318 | |
| 319 | // Convert to Utf16 |
deadbeef | 37f5ecf | 2017-02-27 22:06:41 | [diff] [blame] | 320 | int wlen = |
| 321 | ::MultiByteToWideChar(CP_UTF8, 0, utf8.c_str(), |
| 322 | static_cast<int>(utf8.length() + 1), nullptr, 0); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 323 | if (0 == wlen) { |
| 324 | return false; |
| 325 | } |
| 326 | wchar_t* wfilename = STACK_ARRAY(wchar_t, wlen); |
| 327 | if (0 == ::MultiByteToWideChar(CP_UTF8, 0, utf8.c_str(), |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 328 | static_cast<int>(utf8.length() + 1), wfilename, |
| 329 | wlen)) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 330 | return false; |
| 331 | } |
| 332 | // Replace forward slashes with backslashes |
| 333 | std::replace(wfilename, wfilename + wlen, L'/', L'\\'); |
| 334 | // Convert to complete filename |
deadbeef | 37f5ecf | 2017-02-27 22:06:41 | [diff] [blame] | 335 | DWORD full_len = ::GetFullPathName(wfilename, 0, nullptr, nullptr); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 336 | if (0 == full_len) { |
| 337 | return false; |
| 338 | } |
deadbeef | 37f5ecf | 2017-02-27 22:06:41 | [diff] [blame] | 339 | wchar_t* filepart = nullptr; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 340 | wchar_t* full_filename = STACK_ARRAY(wchar_t, full_len + 6); |
| 341 | wchar_t* start = full_filename + 6; |
| 342 | if (0 == ::GetFullPathName(wfilename, full_len, start, &filepart)) { |
| 343 | return false; |
| 344 | } |
| 345 | // Add long-path prefix |
| 346 | const wchar_t kLongPathPrefix[] = L"\\\\?\\UNC"; |
| 347 | if ((start[0] != L'\\') || (start[1] != L'\\')) { |
| 348 | // Non-unc path: <pathname> |
| 349 | // Becomes: \\?\<pathname> |
| 350 | start -= 4; |
nisse | ede5da4 | 2017-01-12 13:15:36 | [diff] [blame] | 351 | RTC_DCHECK(start >= full_filename); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 352 | memcpy(start, kLongPathPrefix, 4 * sizeof(wchar_t)); |
| 353 | } else if (start[2] != L'?') { |
| 354 | // Unc path: \\<server>\<pathname> |
| 355 | // Becomes: \\?\UNC\<server>\<pathname> |
| 356 | start -= 6; |
nisse | ede5da4 | 2017-01-12 13:15:36 | [diff] [blame] | 357 | RTC_DCHECK(start >= full_filename); |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 358 | memcpy(start, kLongPathPrefix, 7 * sizeof(wchar_t)); |
| 359 | } else { |
| 360 | // Already in long-path form. |
| 361 | } |
| 362 | filename->assign(start); |
| 363 | return true; |
| 364 | } |
| 365 | |
| 366 | bool GetOsVersion(int* major, int* minor, int* build) { |
| 367 | OSVERSIONINFO info = {0}; |
| 368 | info.dwOSVersionInfoSize = sizeof(info); |
| 369 | if (GetVersionEx(&info)) { |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 370 | if (major) |
| 371 | *major = info.dwMajorVersion; |
| 372 | if (minor) |
| 373 | *minor = info.dwMinorVersion; |
| 374 | if (build) |
| 375 | *build = info.dwBuildNumber; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 376 | return true; |
| 377 | } |
| 378 | return false; |
| 379 | } |
| 380 | |
| 381 | bool GetCurrentProcessIntegrityLevel(int* level) { |
| 382 | bool ret = false; |
| 383 | HANDLE process = ::GetCurrentProcess(), token; |
| 384 | if (OpenProcessToken(process, TOKEN_QUERY | TOKEN_QUERY_SOURCE, &token)) { |
| 385 | DWORD size; |
deadbeef | 37f5ecf | 2017-02-27 22:06:41 | [diff] [blame] | 386 | if (!GetTokenInformation(token, TokenIntegrityLevel, nullptr, 0, &size) && |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 387 | GetLastError() == ERROR_INSUFFICIENT_BUFFER) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 388 | char* buf = STACK_ARRAY(char, size); |
| 389 | TOKEN_MANDATORY_LABEL* til = |
| 390 | reinterpret_cast<TOKEN_MANDATORY_LABEL*>(buf); |
| 391 | if (GetTokenInformation(token, TokenIntegrityLevel, til, size, &size)) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 392 | DWORD count = *GetSidSubAuthorityCount(til->Label.Sid); |
| 393 | *level = *GetSidSubAuthority(til->Label.Sid, count - 1); |
| 394 | ret = true; |
| 395 | } |
| 396 | } |
| 397 | CloseHandle(token); |
| 398 | } |
| 399 | return ret; |
| 400 | } |
André Susano Pinto | 5ec9985 | 2015-05-13 07:20:52 | [diff] [blame] | 401 | |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 402 | } // namespace rtc |