OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/install_static/install_details.h" | 5 #include "chrome/install_static/install_details.h" |
6 | 6 |
7 #include <assert.h> | 7 #include <assert.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include <type_traits> | 10 #include <type_traits> |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // static | 60 // static |
61 const InstallDetails::Payload* InstallDetails::GetPayload() { | 61 const InstallDetails::Payload* InstallDetails::GetPayload() { |
62 assert(g_module_details); | 62 assert(g_module_details); |
63 static_assert(std::is_pod<Payload>::value, "Payload must be a POD-struct"); | 63 static_assert(std::is_pod<Payload>::value, "Payload must be a POD-struct"); |
64 static_assert(std::is_pod<InstallConstants>::value, | 64 static_assert(std::is_pod<InstallConstants>::value, |
65 "InstallConstants must be a POD-struct"); | 65 "InstallConstants must be a POD-struct"); |
66 return g_module_details->payload_; | 66 return g_module_details->payload_; |
67 } | 67 } |
68 | 68 |
69 // static | 69 // static |
70 void InstallDetails::InitializeFromPrimaryModule( | 70 void InstallDetails::InitializeFromPayload( |
71 const wchar_t* primary_module_name) { | 71 const InstallDetails::Payload* payload) { |
72 assert(!g_module_details); | 72 assert(!g_module_details); |
73 using GetInstallDetailsPayloadFunction = const Payload*(__cdecl*)(); | |
74 GetInstallDetailsPayloadFunction payload_getter = | |
75 reinterpret_cast<GetInstallDetailsPayloadFunction>(::GetProcAddress( | |
76 ::GetModuleHandle(primary_module_name), "GetInstallDetailsPayload")); | |
77 assert(payload_getter); | |
78 // Intentionally leaked at shutdown. | 73 // Intentionally leaked at shutdown. |
79 g_module_details = new InstallDetails(payload_getter()); | 74 g_module_details = new InstallDetails(payload); |
80 } | 75 } |
81 | 76 |
82 PrimaryInstallDetails::PrimaryInstallDetails() : InstallDetails(&payload_) { | 77 PrimaryInstallDetails::PrimaryInstallDetails() : InstallDetails(&payload_) { |
83 payload_.size = sizeof(payload_); | 78 payload_.size = sizeof(payload_); |
84 payload_.product_version = &kProductVersion[0]; | 79 payload_.product_version = &kProductVersion[0]; |
85 } | 80 } |
86 | 81 |
87 } // namespace install_static | 82 } // namespace install_static |
OLD | NEW |