Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: src/shared/Utils.cpp

Issue 6308231068516352: Fix issues with security tokens (Enhanced Protected Mode, Protected Mode etc) (Closed)
Patch Set: Created Nov. 15, 2013, 7:22 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« src/shared/Communication.cpp ('K') | « src/shared/Utils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include <memory> 1 #include <memory>
2 #include <stdexcept> 2 #include <stdexcept>
3 #include <vector> 3 #include <vector>
4 4
5 #include <Windows.h> 5 #include <Windows.h>
6 #include <ShlObj.h> 6 #include <ShlObj.h>
7 7
8 #include "Utils.h" 8 #include "Utils.h"
9 9
10 namespace 10 namespace
11 { 11 {
12 // See http://blogs.msdn.com/b/oldnewthing/archive/2004/10/25/247180.aspx 12 // See http://blogs.msdn.com/b/oldnewthing/archive/2004/10/25/247180.aspx
13 EXTERN_C IMAGE_DOS_HEADER __ImageBase; 13 EXTERN_C IMAGE_DOS_HEADER __ImageBase;
14 14
15 std::wstring appDataPath; 15 std::wstring appDataPath;
16 16
17 } 17 }
18 18
19 bool IsWindowsVistaOrLater() 19 bool IsWindowsVistaOrLater()
20 { 20 {
21 OSVERSIONINFOEX osvi; 21 OSVERSIONINFOEX osvi;
22 ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); 22 ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
23 osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); 23 osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
24 GetVersionEx(reinterpret_cast<LPOSVERSIONINFO>(&osvi)); 24 GetVersionEx(reinterpret_cast<LPOSVERSIONINFO>(&osvi));
25 return osvi.dwMajorVersion >= 6; 25 return osvi.dwMajorVersion >= 6;
26 } 26 }
27 27
28 bool IsWindows8()
Felix Dahlke 2013/12/10 16:46:36 Shouldn't this be "isWindows8OrLater"?
29 {
30 OSVERSIONINFOEX osvi;
31 ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
32 osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
33 GetVersionEx(reinterpret_cast<LPOSVERSIONINFO>(&osvi));
34 return osvi.dwMajorVersion == 6 & osvi.dwMinorVersion >= 2;
35 }
36
28 std::string ToUtf8String(const std::wstring& str) 37 std::string ToUtf8String(const std::wstring& str)
29 { 38 {
30 int length = static_cast<int>(str.size()); 39 int length = static_cast<int>(str.size());
31 if (length == 0) 40 if (length == 0)
32 return std::string(); 41 return std::string();
33 42
34 int utf8StringLength = WideCharToMultiByte(CP_UTF8, 0, str.c_str(), length, 0, 0, 0, 0); 43 int utf8StringLength = WideCharToMultiByte(CP_UTF8, 0, str.c_str(), length, 0, 0, 0, 0);
35 if (utf8StringLength == 0) 44 if (utf8StringLength == 0)
36 throw std::runtime_error("Failed to determine the required buffer size"); 45 throw std::runtime_error("Failed to determine the required buffer size");
37 46
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } 121 }
113 122
114 void ReplaceString(std::wstring& input, const std::wstring placeholder, const st d::wstring replacement) 123 void ReplaceString(std::wstring& input, const std::wstring placeholder, const st d::wstring replacement)
115 { 124 {
116 size_t replaceStart = input.find(placeholder); 125 size_t replaceStart = input.find(placeholder);
117 if (replaceStart != std::string::npos) 126 if (replaceStart != std::string::npos)
118 { 127 {
119 input.replace(replaceStart, placeholder.length(), replacement); 128 input.replace(replaceStart, placeholder.length(), replacement);
120 } 129 }
121 } 130 }
OLDNEW
« src/shared/Communication.cpp ('K') | « src/shared/Utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld