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 3 // found in the LICENSE file. 4 5 #include "sandbox/win/src/sandbox_utils.h" 6 7 #include <windows.h> 8 9 #include "base/logging.h" 10 #include "sandbox/win/src/internal_types.h" 11 12 namespace sandbox { 13 14 void InitObjectAttribs(const base::string16& name, 15 ULONG attributes, 16 HANDLE root, 17 OBJECT_ATTRIBUTES* obj_attr, 18 UNICODE_STRING* uni_name) { 19 static RtlInitUnicodeStringFunction RtlInitUnicodeString; 20 if (!RtlInitUnicodeString) { 21 HMODULE ntdll = ::GetModuleHandle(kNtdllName); 22 RtlInitUnicodeString = reinterpret_cast<RtlInitUnicodeStringFunction>( 23 GetProcAddress(ntdll, "RtlInitUnicodeString")); 24 DCHECK(RtlInitUnicodeString); 25 } 26 RtlInitUnicodeString(uni_name, name.c_str()); 27 InitializeObjectAttributes(obj_attr, uni_name, attributes, root, NULL); 28 } 29 30 } // namespace sandbox 31