OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "sandbox/src/sandbox_utils.h" | 5 #include "sandbox/src/sandbox_utils.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 if (!RtlInitUnicodeString) { | 69 if (!RtlInitUnicodeString) { |
70 HMODULE ntdll = ::GetModuleHandle(kNtdllName); | 70 HMODULE ntdll = ::GetModuleHandle(kNtdllName); |
71 RtlInitUnicodeString = reinterpret_cast<RtlInitUnicodeStringFunction>( | 71 RtlInitUnicodeString = reinterpret_cast<RtlInitUnicodeStringFunction>( |
72 GetProcAddress(ntdll, "RtlInitUnicodeString")); | 72 GetProcAddress(ntdll, "RtlInitUnicodeString")); |
73 DCHECK(RtlInitUnicodeString); | 73 DCHECK(RtlInitUnicodeString); |
74 } | 74 } |
75 RtlInitUnicodeString(uni_name, name.c_str()); | 75 RtlInitUnicodeString(uni_name, name.c_str()); |
76 InitializeObjectAttributes(obj_attr, uni_name, attributes, root, NULL); | 76 InitializeObjectAttributes(obj_attr, uni_name, attributes, root, NULL); |
77 } | 77 } |
78 | 78 |
79 std::string WideToMultiByte(const std::wstring& wide) { | |
80 if (wide.length() == 0) | |
81 return std::string(); | |
82 | |
83 // compute the length of the buffer we'll need | |
84 int charcount = WideCharToMultiByte(CP_UTF8, 0, wide.c_str(), -1, | |
85 NULL, 0, NULL, NULL); | |
86 if (charcount == 0) | |
87 return std::string(); | |
88 | |
89 std::string mb; | |
90 WideCharToMultiByte(CP_UTF8, 0, wide.c_str(), -1, | |
91 WriteInto(&mb, charcount), charcount, NULL, NULL); | |
92 | |
93 return mb; | |
94 } | |
95 | |
96 }; // namespace sandbox | 79 }; // namespace sandbox |
OLD | NEW |