From 355201c51e6aba95c582e2df344782b22e97bb31 Mon Sep 17 00:00:00 2001 From: Khuraie <83483964+Khuraie@users.noreply.github.com> Date: Mon, 23 Nov 2026 23:42:39 +0800 Subject: d3d12_xs: honour __XMemAllocationHooks__ for descriptor heaps and translate CPU handles --- runtime/src/pe_loader.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'runtime/src/pe_loader.cpp') diff --git a/runtime/src/pe_loader.cpp b/runtime/src/pe_loader.cpp index bfeab4c7f..21c4673a8 100644 --- a/runtime/src/pe_loader.cpp +++ b/runtime/src/pe_loader.cpp @@ -932,6 +932,7 @@ Loader::~Loader() { entry(m.base, DLL_PROCESS_DETACH, nullptr); // explicit unload; the return value is ignored } } + shims::remove_xmem_allocation_hooks(this); shims::remove_bundled_loader(this); shims::remove_module_lookup(this); for (auto* m : order_) { @@ -1285,6 +1286,12 @@ Module& Loader::map_image(const std::filesystem::path& path, const std::string& // installed here, before bind_imports can return control to the caller and before any image code can run. initialize_tls(*m); parse_exports(*m); + if (auto it = m->exports.find("__XMemAllocationHooks__"); it != m->exports.end()) { + const auto offset = static_cast(static_cast(it->second) - m->base); + if (offset <= m->size && m->size - offset >= sizeof(shims::XMemAllocationHooks)) { + shims::add_xmem_allocation_hooks(this, static_cast(it->second)); + } + } return *m; } -- cgit v1.2.3