@@ -236,35 +236,17 @@ auto AssemblyStore::open_assembly (std::string_view const& name, int64_t &size)
236236 return assembly_data;
237237}
238238
239- void AssemblyStore::map (int fd, std::string_view const & apk_path, std::string_view const & store_path, uint32_t offset, uint32_t size) noexcept
239+ [[gnu::always_inline]]
240+ void AssemblyStore::verify_assembly_store_and_set_info (void *data_start, std::string_view const & name) noexcept
240241{
241- detail::mmap_info assembly_store_map = Util::mmap_file (fd, offset, size, store_path);
242-
243- auto [payload_start, payload_size] = Util::get_wrapper_dso_payload_pointer_and_size (assembly_store_map, store_path);
244- log_debug (LOG_ASSEMBLY, " Adjusted assembly store pointer: {:p}; size: {}" sv, payload_start, payload_size);
245- auto header = static_cast <AssemblyStoreHeader*>(payload_start);
246-
247- auto get_full_store_path = [&apk_path, &store_path]() -> std::string {
248- std::string full_store_path;
249-
250- if (!apk_path.empty ()) {
251- full_store_path.append (apk_path);
252- // store path will be relative, to the apk
253- full_store_path.append (" !/" sv);
254- full_store_path.append (store_path);
255- } else {
256- full_store_path.append (store_path);
257- }
258-
259- return full_store_path;
260- };
242+ auto header = static_cast <AssemblyStoreHeader*>(data_start);
261243
262244 if (header->magic != ASSEMBLY_STORE_MAGIC) {
263245 Helpers::abort_application (
264246 LOG_ASSEMBLY,
265247 std::format (
266248 " Assembly store '{}' is not a valid .NET for Android assembly store file" sv,
267- get_full_store_path ()
249+ name
268250 )
269251 );
270252 }
@@ -274,7 +256,7 @@ void AssemblyStore::map (int fd, std::string_view const& apk_path, std::string_v
274256 LOG_ASSEMBLY,
275257 std::format (
276258 " Assembly store '{}' uses format version {:x}, instead of the expected {:x}" sv,
277- get_full_store_path () ,
259+ name ,
278260 header->version ,
279261 ASSEMBLY_STORE_FORMAT_VERSION
280262 )
@@ -283,11 +265,35 @@ void AssemblyStore::map (int fd, std::string_view const& apk_path, std::string_v
283265
284266 constexpr size_t header_size = sizeof (AssemblyStoreHeader);
285267
286- assembly_store.data_start = static_cast <uint8_t *>(payload_start );
268+ assembly_store.data_start = static_cast <uint8_t *>(data_start );
287269 assembly_store.assembly_count = header->entry_count ;
288270 assembly_store.index_entry_count = header->index_entry_count ;
289271 assembly_store.assemblies = reinterpret_cast <AssemblyStoreEntryDescriptor*>(assembly_store.data_start + header_size + header->index_size );
290272 assembly_store_hashes = reinterpret_cast <AssemblyStoreIndexEntry*>(assembly_store.data_start + header_size);
273+ }
274+
275+ void AssemblyStore::map (int fd, std::string_view const & apk_path, std::string_view const & store_path, uint32_t offset, uint32_t size) noexcept
276+ {
277+ detail::mmap_info assembly_store_map = Util::mmap_file (fd, offset, size, store_path);
278+ auto [payload_start, payload_size] = Util::get_wrapper_dso_payload_pointer_and_size (assembly_store_map, store_path);
279+ log_debug (LOG_ASSEMBLY, " Adjusted assembly store pointer: {:p}; size: {}" sv, payload_start, payload_size);
291280
292- log_debug (LOG_ASSEMBLY, " Mapped assembly store {}" sv, get_full_store_path ());
281+ std::string full_store_path;
282+ if (!apk_path.empty ()) {
283+ full_store_path.append (apk_path);
284+ // store path will be relative, to the apk
285+ full_store_path.append (" !/" sv);
286+ full_store_path.append (store_path);
287+ } else {
288+ full_store_path.append (store_path);
289+ }
290+
291+ verify_assembly_store_and_set_info (payload_start, full_store_path);
292+ log_debug (LOG_ASSEMBLY, " Mapped assembly store {}" sv, full_store_path);
293+ }
294+
295+ void AssemblyStore::map () noexcept
296+ {
297+ verify_assembly_store_and_set_info (embedded_assembly_store, " <embedded>" sv);
298+ log_debug (LOG_ASSEMBLY, " Mapped embedded assembly store" );
293299}
0 commit comments