michael@0: // Copyright (c) 2011 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: #include "sandbox/win/src/sandbox_utils.h" michael@0: michael@0: #include michael@0: michael@0: #include "base/logging.h" michael@0: #include "base/win/windows_version.h" michael@0: #include "sandbox/win/src/internal_types.h" michael@0: michael@0: namespace sandbox { michael@0: michael@0: bool IsXPSP2OrLater() { michael@0: base::win::Version version = base::win::GetVersion(); michael@0: return (version > base::win::VERSION_XP) || michael@0: ((version == base::win::VERSION_XP) && michael@0: (base::win::OSInfo::GetInstance()->service_pack().major >= 2)); michael@0: } michael@0: michael@0: void InitObjectAttribs(const std::wstring& name, michael@0: ULONG attributes, michael@0: HANDLE root, michael@0: OBJECT_ATTRIBUTES* obj_attr, michael@0: UNICODE_STRING* uni_name) { michael@0: static RtlInitUnicodeStringFunction RtlInitUnicodeString; michael@0: if (!RtlInitUnicodeString) { michael@0: HMODULE ntdll = ::GetModuleHandle(kNtdllName); michael@0: RtlInitUnicodeString = reinterpret_cast( michael@0: GetProcAddress(ntdll, "RtlInitUnicodeString")); michael@0: DCHECK(RtlInitUnicodeString); michael@0: } michael@0: RtlInitUnicodeString(uni_name, name.c_str()); michael@0: InitializeObjectAttributes(obj_attr, uni_name, attributes, root, NULL); michael@0: } michael@0: michael@0: }; // namespace sandbox