From 97b12cf730c0d0844945649c9c22a3f815eb647e Mon Sep 17 00:00:00 2001 From: midipix Date: Sat, 9 Jun 2018 08:32:02 +0000 Subject: ldso: pe_load_framework_loader_ex(): rec. val of prev loader and root handles. --- include/pemagine/pemagine.h | 7 +++++++ src/ldso/pe_load_framework_loader_ex.c | 13 ++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/pemagine/pemagine.h b/include/pemagine/pemagine.h index 35fbc74..518b567 100644 --- a/include/pemagine/pemagine.h +++ b/include/pemagine/pemagine.h @@ -26,6 +26,13 @@ enum pe_callback_reason { #define PE_LDSO_STANDALONE_EXECUTABLE 0x00000002 +/* ldso loader context pointer index */ +#define PE_LDSO_CTX_IDX_PREV_LOADER 0x0 +#define PE_LDSO_CTX_IDX_PREV_ROOT 0x1 +#define PE_LDSO_CTX_IDX_RESERVED_1 0x2 +#define PE_LDSO_CTX_IDX_RESERVED_2 0x3 + + /* library specific structures */ struct pe_export_sym { uint32_t * ordinal_base; diff --git a/src/ldso/pe_load_framework_loader_ex.c b/src/ldso/pe_load_framework_loader_ex.c index 25428aa..cd3d8e6 100644 --- a/src/ldso/pe_load_framework_loader_ex.c +++ b/src/ldso/pe_load_framework_loader_ex.c @@ -31,6 +31,8 @@ int32_t pe_load_framework_loader_ex( abi); if (status) { + rtdata = &context; + context.hself = 0; context.hparent = 0; context.himage = 0; @@ -55,7 +57,16 @@ int32_t pe_load_framework_loader_ex( context.abi.data4[6] = abi->data4[6]; context.abi.data4[7] = abi->data4[7]; - rtdata = &context; + context.hldrctx[PE_LDSO_CTX_IDX_PREV_LOADER] = 0; + context.hldrctx[PE_LDSO_CTX_IDX_PREV_ROOT] = 0; + + if (__SIZEOF_POINTER__ == 8) { + context.hldrctx[PE_LDSO_CTX_IDX_RESERVED_1] = 0; + context.hldrctx[PE_LDSO_CTX_IDX_RESERVED_2] = 0; + } + } else { + rtdata->hldrctx[PE_LDSO_CTX_IDX_PREV_LOADER] = rtdata->hloader; + rtdata->hldrctx[PE_LDSO_CTX_IDX_PREV_ROOT] = rtdata->hroot; } if ((status = pe_find_framework_loader( -- cgit v1.2.3