1 // Copyright (c) 2012 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 #ifndef BASE_WIN_STARTUP_INFORMATION_H_ 6 #define BASE_WIN_STARTUP_INFORMATION_H_ 7 8 #include <windows.h> 9 10 #include <stddef.h> 11 12 #include <memory> 13 14 #include "base/base_export.h" 15 #include "base/macros.h" 16 17 namespace base { 18 namespace win { 19 20 // Manages the lifetime of additional attributes in STARTUPINFOEX. 21 class BASE_EXPORT StartupInformation { 22 public: 23 StartupInformation(); 24 25 ~StartupInformation(); 26 27 // Initialize the attribute list for the specified number of entries. 28 bool InitializeProcThreadAttributeList(DWORD attribute_count); 29 30 // Sets one entry in the initialized attribute list. 31 // |value| needs to live at least as long as the StartupInformation object 32 // this is called on. 33 bool UpdateProcThreadAttribute(DWORD_PTR attribute, void* value, size_t size); 34 startup_info()35 LPSTARTUPINFOW startup_info() { return &startup_info_.StartupInfo; } startup_info()36 LPSTARTUPINFOW startup_info() const { 37 return const_cast<const LPSTARTUPINFOW>(&startup_info_.StartupInfo); 38 } 39 has_extended_startup_info()40 bool has_extended_startup_info() const { 41 return !!startup_info_.lpAttributeList; 42 } 43 44 private: 45 std::unique_ptr<char[]> attribute_list_; 46 STARTUPINFOEXW startup_info_; 47 DISALLOW_COPY_AND_ASSIGN(StartupInformation); 48 }; 49 50 } // namespace win 51 } // namespace base 52 53 #endif // BASE_WIN_STARTUP_INFORMATION_H_ 54