upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src/pe_loader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/src/pe_loader.cpp')
-rw-r--r--runtime/src/pe_loader.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/runtime/src/pe_loader.cpp b/runtime/src/pe_loader.cpp
index 5d0386ec0..278444c6f 100644
--- a/runtime/src/pe_loader.cpp
+++ b/runtime/src/pe_loader.cpp
@@ -556,11 +556,21 @@ bool bundled_owns_handle(void* ctx, void* module) {
556 return static_cast<Loader*>(ctx)->owns_module_handle(module); 556 return static_cast<Loader*>(ctx)->owns_module_handle(module);
557} 557}
558 558
559void* bundled_main_module(void* ctx) {
560 return static_cast<Loader*>(ctx)->main_module();
561}
562
563const std::filesystem::path* bundled_module_path(void* ctx, void* module) {
564 return static_cast<Loader*>(ctx)->module_path_for(module);
565}
566
559const shims::BundledModuleOps kBundledOps{ 567const shims::BundledModuleOps kBundledOps{
560 &bundled_find_loaded, 568 &bundled_find_loaded,
561 &bundled_load, 569 &bundled_load,
562 &bundled_get_proc, 570 &bundled_get_proc,
563 &bundled_owns_handle, 571 &bundled_owns_handle,
572 &bundled_main_module,
573 &bundled_module_path,
564}; 574};
565} // namespace 575} // namespace
566 576
@@ -730,6 +740,19 @@ bool Loader::owns_module_handle(void* module_handle) const {
730 return false; 740 return false;
731} 741}
732 742
743void* Loader::main_module() const {
744 std::lock_guard lock(mutex_);
745 return order_.empty() ? nullptr : static_cast<void*>(order_.front()->base);
746}
747
748const std::filesystem::path* Loader::module_path_for(void* module_handle) const {
749 std::lock_guard lock(mutex_);
750 if (!module_handle) return order_.empty() ? nullptr : &order_.front()->path;
751 for (Module* m : order_)
752 if (m->base == module_handle) return &m->path;
753 return nullptr;
754}
755
733// x64 has no frame-pointer chain to fall back on: without its .pdata registered, an exception raised in (or passing 756// x64 has no frame-pointer chain to fall back on: without its .pdata registered, an exception raised in (or passing
734// through) a mapped image can't be dispatched past that frame, and the process dies. Images the system loader maps 757// through) a mapped image can't be dispatched past that frame, and the process dies. Images the system loader maps
735// are found through its own module list; ours are VirtualAlloc'd, so they are registered as dynamic function tables. 758// are found through its own module list; ours are VirtualAlloc'd, so they are registered as dynamic function tables.