From 0a714544d64974ad43ad26b6de533bc3b15d2c0d 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 (cherry picked from commit 355201c51e6aba95c582e2df344782b22e97bb31) --- 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 ff0693a15..bf44cea79 100644 --- a/runtime/src/pe_loader.cpp +++ b/runtime/src/pe_loader.cpp @@ -1094,6 +1094,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_) { @@ -1498,6 +1499,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