Delete no longer used windows helpers
Utf8ToWindowsFilename:
Unused since deletion of FileStream, cl
https://webrtc-review.googlesource.com/c/src/+/128900
GetCurrentProcessIntegrityLevel and IsCurrentProcessLowIntegrity:
Unused since deletion of GetTemporaryFolder, cl
https://codereview.webrtc.org/2995413002
Bug: webrtc:6424
Change-Id: Iec9e1137c6873fd6f3d6888101bae1a741c9d4b1
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/137807
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28021}
diff --git a/rtc_base/win32.cc b/rtc_base/win32.cc
index acc3d33..67c987f 100644
--- a/rtc_base/win32.cc
+++ b/rtc_base/win32.cc
@@ -310,66 +310,6 @@
return 1;
}
-bool Utf8ToWindowsFilename(const std::string& utf8, std::wstring* filename) {
- // TODO: Integrate into fileutils.h
- // TODO: Handle wide and non-wide cases via TCHAR?
- // TODO: Skip \\?\ processing if the length is not > MAX_PATH?
- // TODO: Write unittests
-
- // Convert to Utf16
- int wlen =
- ::MultiByteToWideChar(CP_UTF8, 0, utf8.c_str(),
- static_cast<int>(utf8.length() + 1), nullptr, 0);
- if (0 == wlen) {
- return false;
- }
- wchar_t* wfilename = STACK_ARRAY(wchar_t, wlen);
- if (0 == ::MultiByteToWideChar(CP_UTF8, 0, utf8.c_str(),
- static_cast<int>(utf8.length() + 1), wfilename,
- wlen)) {
- return false;
- }
- // Replace forward slashes with backslashes
- std::replace(wfilename, wfilename + wlen, L'/', L'\\');
-#if defined(WINUWP)
- // WinUWP sandboxed store applications require the paths to remain as
- // relative paths.
- filename->assign(wfilename);
-#else
- // Convert to complete filename
- DWORD full_len = ::GetFullPathNameW(wfilename, 0, nullptr, nullptr);
- if (0 == full_len) {
- return false;
- }
- wchar_t* filepart = nullptr;
- wchar_t* full_filename = STACK_ARRAY(wchar_t, full_len + 6);
- wchar_t* start = full_filename + 6;
- if (0 == ::GetFullPathNameW(wfilename, full_len, start, &filepart)) {
- return false;
- }
- // Add long-path prefix
- const wchar_t kLongPathPrefix[] = L"\\\\?\\UNC";
- if ((start[0] != L'\\') || (start[1] != L'\\')) {
- // Non-unc path: <pathname>
- // Becomes: \\?\<pathname>
- start -= 4;
- RTC_DCHECK(start >= full_filename);
- memcpy(start, kLongPathPrefix, 4 * sizeof(wchar_t));
- } else if (start[2] != L'?') {
- // Unc path: \\<server>\<pathname>
- // Becomes: \\?\UNC\<server>\<pathname>
- start -= 6;
- RTC_DCHECK(start >= full_filename);
- memcpy(start, kLongPathPrefix, 7 * sizeof(wchar_t));
- } else {
- // Already in long-path form.
- }
- filename->assign(start);
-#endif // defined(WINUWP)
-
- return true;
-}
-
// Windows UWP applications cannot obtain versioning information from
// the sandbox with intention (as behehaviour based on OS versioning rather
// than feature discovery / compilation flags is discoraged and Windows
@@ -392,27 +332,6 @@
return false;
}
-bool GetCurrentProcessIntegrityLevel(int* level) {
- bool ret = false;
- HANDLE process = ::GetCurrentProcess(), token;
- if (OpenProcessToken(process, TOKEN_QUERY | TOKEN_QUERY_SOURCE, &token)) {
- DWORD size;
- if (!GetTokenInformation(token, TokenIntegrityLevel, nullptr, 0, &size) &&
- GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
- char* buf = STACK_ARRAY(char, size);
- TOKEN_MANDATORY_LABEL* til =
- reinterpret_cast<TOKEN_MANDATORY_LABEL*>(buf);
- if (GetTokenInformation(token, TokenIntegrityLevel, til, size, &size)) {
- DWORD count = *GetSidSubAuthorityCount(til->Label.Sid);
- *level = *GetSidSubAuthority(til->Label.Sid, count - 1);
- ret = true;
- }
- }
- CloseHandle(token);
- }
- return ret;
-}
-
#endif // !defined(WINUWP)
} // namespace rtc
diff --git a/rtc_base/win32.h b/rtc_base/win32.h
index 004c6b4..c90296e 100644
--- a/rtc_base/win32.h
+++ b/rtc_base/win32.h
@@ -46,9 +46,6 @@
const char* win32_inet_ntop(int af, const void* src, char* dst, socklen_t size);
int win32_inet_pton(int af, const char* src, void* dst);
-// Convert a Utf8 path representation to a non-length-limited Unicode pathname.
-bool Utf8ToWindowsFilename(const std::string& utf8, std::wstring* filename);
-
enum WindowsMajorVersions {
kWindows2000 = 5,
kWindowsVista = 6,
@@ -80,15 +77,6 @@
return (GetOsVersion(&major, nullptr, nullptr) && (major >= kWindows10));
}
-// Determine the current integrity level of the process.
-bool GetCurrentProcessIntegrityLevel(int* level);
-
-inline bool IsCurrentProcessLowIntegrity() {
- int level;
- return (GetCurrentProcessIntegrityLevel(&level) &&
- level < SECURITY_MANDATORY_MEDIUM_RID);
-}
-
#else
// When targetting WinUWP the OS must be Windows 10 (or greater) as lesser
@@ -109,12 +97,6 @@
return true;
}
-inline bool IsCurrentProcessLowIntegrity() {
- // For WinUWP sandboxed store assume this is NOT a low integrity level run
- // as application privileges can be requested in manifest as appropriate.
- return true;
-}
-
#endif // !defined(WINUWP)
} // namespace rtc