security/sandbox/win/src/sandbox_utils.cc

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/sandbox/win/src/sandbox_utils.cc	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,38 @@
     1.4 +// Copyright (c) 2011 The Chromium Authors. All rights reserved.
     1.5 +// Use of this source code is governed by a BSD-style license that can be
     1.6 +// found in the LICENSE file.
     1.7 +
     1.8 +#include "sandbox/win/src/sandbox_utils.h"
     1.9 +
    1.10 +#include <windows.h>
    1.11 +
    1.12 +#include "base/logging.h"
    1.13 +#include "base/win/windows_version.h"
    1.14 +#include "sandbox/win/src/internal_types.h"
    1.15 +
    1.16 +namespace sandbox {
    1.17 +
    1.18 +bool IsXPSP2OrLater() {
    1.19 +  base::win::Version version = base::win::GetVersion();
    1.20 +  return (version > base::win::VERSION_XP) ||
    1.21 +      ((version == base::win::VERSION_XP) &&
    1.22 +       (base::win::OSInfo::GetInstance()->service_pack().major >= 2));
    1.23 +}
    1.24 +
    1.25 +void InitObjectAttribs(const std::wstring& name,
    1.26 +                       ULONG attributes,
    1.27 +                       HANDLE root,
    1.28 +                       OBJECT_ATTRIBUTES* obj_attr,
    1.29 +                       UNICODE_STRING* uni_name) {
    1.30 +  static RtlInitUnicodeStringFunction RtlInitUnicodeString;
    1.31 +  if (!RtlInitUnicodeString) {
    1.32 +    HMODULE ntdll = ::GetModuleHandle(kNtdllName);
    1.33 +    RtlInitUnicodeString = reinterpret_cast<RtlInitUnicodeStringFunction>(
    1.34 +      GetProcAddress(ntdll, "RtlInitUnicodeString"));
    1.35 +    DCHECK(RtlInitUnicodeString);
    1.36 +  }
    1.37 +  RtlInitUnicodeString(uni_name, name.c_str());
    1.38 +  InitializeObjectAttributes(obj_attr, uni_name, attributes, root, NULL);
    1.39 +}
    1.40 +
    1.41 +};  // namespace sandbox

mercurial