summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/pemagine/pe_ldso.h1
-rw-r--r--include/pemagine/pemagine.h14
-rw-r--r--project/common.mk1
-rw-r--r--src/ldso/pe_load_framework_loader_ex.c74
4 files changed, 90 insertions, 0 deletions
diff --git a/include/pemagine/pe_ldso.h b/include/pemagine/pe_ldso.h
index f7ae6af..7f6382c 100644
--- a/include/pemagine/pe_ldso.h
+++ b/include/pemagine/pe_ldso.h
@@ -33,6 +33,7 @@
#define pe_get_symbol_module_info __ldso_get_symbol_module_info
#define pe_get_symbol_name __ldso_get_symbol_name
#define pe_load_framework_loader __ldso_load_framework_loader
+#define pe_load_framework_loader_ex __ldso_load_framework_loader_ex
#define pe_open_image_from_addr __ldso_open_image_from_addr
#define pe_open_physical_parent_directory __ldso_open_physical_parent_directory
#define pe_terminate_current_process __ldso_terminate_current_process
diff --git a/include/pemagine/pemagine.h b/include/pemagine/pemagine.h
index 0edd08e..9cfe47a 100644
--- a/include/pemagine/pemagine.h
+++ b/include/pemagine/pemagine.h
@@ -265,6 +265,20 @@ pe_api int32_t pe_load_framework_loader(
uint32_t * flags);
+pe_api int32_t pe_load_framework_loader_ex(
+ void ** baseaddr,
+ void ** hroot,
+ void ** hdsodir,
+ const struct pe_guid * abi,
+ const wchar16_t * basename,
+ const wchar16_t * rrelname,
+ void * refaddr,
+ uintptr_t * buffer,
+ uint32_t bufsize,
+ uint32_t flags,
+ uint32_t * sysflags);
+
+
pe_api int32_t pe_open_image_from_addr(
void ** himage,
void * addr,
diff --git a/project/common.mk b/project/common.mk
index 719394e..5ff3a1e 100644
--- a/project/common.mk
+++ b/project/common.mk
@@ -14,6 +14,7 @@ API_SRCS = \
src/ldso/pe_get_peb_strings.c \
src/ldso/pe_find_framework_loader.c \
src/ldso/pe_load_framework_loader.c \
+ src/ldso/pe_load_framework_loader_ex.c \
src/ldso/pe_open_image_from_addr.c \
src/ldso/pe_open_physical_parent_directory.c \
src/ldso/pe_terminate_current_process.c \
diff --git a/src/ldso/pe_load_framework_loader_ex.c b/src/ldso/pe_load_framework_loader_ex.c
new file mode 100644
index 0000000..80aa8b1
--- /dev/null
+++ b/src/ldso/pe_load_framework_loader_ex.c
@@ -0,0 +1,74 @@
+/*****************************************************************************/
+/* pemagination: a (virtual) tour into portable bits and executable bytes */
+/* Copyright (C) 2013--2017 Z. Gilboa */
+/* Released under GPLv2 and GPLv3; see COPYING.PEMAGINE. */
+/*****************************************************************************/
+
+#include <psxtypes/psxtypes.h>
+#include <pemagine/pemagine.h>
+#include "pe_os.h"
+
+int32_t pe_load_framework_loader_ex(
+ void ** baseaddr,
+ void ** hroot,
+ void ** hdsodir,
+ const struct pe_guid * abi,
+ const wchar16_t * basename,
+ const wchar16_t * rrelname,
+ void * refaddr,
+ uintptr_t * buffer,
+ uint32_t bufsize,
+ uint32_t flags,
+ uint32_t * sysflags)
+{
+ int32_t status;
+ struct pe_framework_runtime_data * rtdata;
+ struct pe_framework_runtime_data context;
+
+ status = pe_get_framework_runtime_data(
+ &rtdata,
+ pe_get_peb_command_line(),
+ abi);
+
+ if (status) {
+ context.hself = 0;
+ context.hparent = 0;
+ context.himage = 0;
+ context.hroot = 0;
+ context.hdsodir = 0;
+ context.hloader = 0;
+ context.hcwd = 0;
+ context.hdrive = 0;
+
+ context.abi.data1 = abi->data1;
+ context.abi.data1 = abi->data2;
+ context.abi.data1 = abi->data3;
+
+ context.abi.data4[0] = abi->data4[0];
+ context.abi.data4[1] = abi->data4[1];
+ context.abi.data4[2] = abi->data4[2];
+ context.abi.data4[3] = abi->data4[3];
+ context.abi.data4[4] = abi->data4[4];
+ context.abi.data4[5] = abi->data4[5];
+ context.abi.data4[6] = abi->data4[6];
+ context.abi.data4[7] = abi->data4[7];
+
+ rtdata = &context;
+ }
+
+ if ((status = pe_find_framework_loader(
+ rtdata,basename,rrelname,refaddr,
+ buffer,bufsize,flags)))
+ return status;
+
+ if ((status = pe_load_framework_loader(
+ baseaddr,rtdata,
+ buffer,bufsize,
+ sysflags)))
+ return status;
+
+ *hroot = rtdata->hroot;
+ *hdsodir = rtdata->hdsodir;
+
+ return OS_STATUS_SUCCESS;
+}