OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 "chrome/install_static/install_details.h" |
| 6 |
| 7 #include <assert.h> |
| 8 |
| 9 #include "chrome/install_static/install_modes.h" |
| 10 #include "chrome/install_static/install_util.h" |
| 11 #include "chrome_elf/nt_registry/nt_registry.h" |
| 12 |
| 13 namespace install_static { |
| 14 |
| 15 namespace { |
| 16 |
| 17 // This module's instance. |
| 18 InstallDetails* g_module_details = nullptr; |
| 19 |
| 20 } // namespace |
| 21 |
| 22 std::wstring InstallDetails::GetClientStateKeyPath(bool binaries) const { |
| 23 return binaries && multi_install() |
| 24 ? GetBinariesClientStateKeyPath() |
| 25 : install_static::GetClientStateKeyPath(app_guid()); |
| 26 } |
| 27 |
| 28 std::wstring InstallDetails::GetClientStateMediumKeyPath(bool binaries) const { |
| 29 return binaries && multi_install() |
| 30 ? GetBinariesClientStateMediumKeyPath() |
| 31 : install_static::GetClientStateMediumKeyPath(app_guid()); |
| 32 } |
| 33 |
| 34 // static |
| 35 const InstallDetails& InstallDetails::Get() { |
| 36 assert(g_module_details); |
| 37 return *g_module_details; |
| 38 } |
| 39 |
| 40 // static |
| 41 void InstallDetails::SetForProcess( |
| 42 std::unique_ptr<PrimaryInstallDetails> details) { |
| 43 assert(!details || !g_module_details); |
| 44 // Intentionally leaked at shutdown. |
| 45 g_module_details = details.release(); |
| 46 } |
| 47 |
| 48 // static |
| 49 intptr_t InstallDetails::GetPayload() { |
| 50 assert(g_module_details); |
| 51 return reinterpret_cast<intptr_t>(g_module_details->payload_); |
| 52 } |
| 53 |
| 54 // static |
| 55 void InstallDetails::ImportFromModule(const wchar_t* module_name, |
| 56 const char* export_name) { |
| 57 assert(!g_module_details); |
| 58 using GetInstallDetailsPayloadFunction = intptr_t(__cdecl*)(); |
| 59 GetInstallDetailsPayloadFunction payload_getter = |
| 60 reinterpret_cast<GetInstallDetailsPayloadFunction>( |
| 61 ::GetProcAddress(::GetModuleHandle(module_name), export_name)); |
| 62 assert(payload_getter); |
| 63 // Intentionally leaked at shutdown. |
| 64 g_module_details = |
| 65 new InstallDetails(reinterpret_cast<Payload*>(payload_getter())); |
| 66 } |
| 67 |
| 68 } // namespace install_static |
OLD | NEW |