summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2017-10-18 12:09:39 +0000
committermidipix <writeonce@midipix.org>2017-10-19 18:18:47 -0400
commit224f38d84d94ecc12f4cf5b286967109ff3d9504 (patch)
treef922cff0b2cb02114f631b7d3f60f61b082bbdcf /src
parentaa2c177ebbcb9f367f63263f2b0071bdc860975a (diff)
downloadpemagine-224f38d84d94ecc12f4cf5b286967109ff3d9504.tar.bz2
pemagine-224f38d84d94ecc12f4cf5b286967109ff3d9504.tar.xz
ldso: added pe_load_framework_library().
Diffstat (limited to 'src')
-rw-r--r--src/ldso/pe_load_framework_loader.c79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/ldso/pe_load_framework_loader.c b/src/ldso/pe_load_framework_loader.c
index e70c183..347d3ab 100644
--- a/src/ldso/pe_load_framework_loader.c
+++ b/src/ldso/pe_load_framework_loader.c
@@ -259,3 +259,82 @@ int32_t pe_load_framework_loader(
buffer,bufsize,
sysflags);
}
+
+
+int32_t pe_load_framework_library(
+ void ** baseaddr,
+ void * hat,
+ const wchar16_t * atrelname,
+ uintptr_t * buffer,
+ uint32_t bufsize,
+ uint32_t * sysflags)
+{
+ int32_t status;
+ struct pe_unicode_str path;
+ struct os_oa oa;
+ struct os_iosb iosb;
+ const wchar16_t * wch;
+ const wchar16_t * wch_cap;
+ void * hdsolib;
+ void * hntdll;
+ os_zw_close * zw_close;
+ os_zw_open_file * zw_open_file;
+
+ /* init */
+ if (!(hntdll = pe_get_ntdll_module_handle()))
+ return OS_STATUS_INTERNAL_ERROR;
+
+ if (!(zw_close = (os_zw_close *)pe_get_procedure_address(
+ hntdll,"ZwClose")))
+ return OS_STATUS_INTERNAL_ERROR;
+
+ if (!(zw_open_file = (os_zw_open_file *)pe_get_procedure_address(
+ hntdll,"ZwOpenFile")))
+ return OS_STATUS_INTERNAL_ERROR;
+
+ /* oa */
+ oa.len = sizeof(struct os_oa);
+ oa.root_dir = hat;
+ oa.obj_name = &path;
+ oa.obj_attr = 0;
+ oa.sec_desc = 0;
+ oa.sec_qos = 0;
+
+ /* at-relative path */
+ wch = atrelname;
+ wch_cap = atrelname + 512;
+
+ for (; *wch && wch<wch_cap; )
+ wch++;
+
+ if (*wch)
+ return OS_STATUS_NAME_TOO_LONG;
+
+ path.buffer = (wchar16_t *)atrelname;
+ path.strlen = sizeof(wchar16_t) * (wch - atrelname);
+ path.maxlen = 0;
+
+ /* open at */
+ if ((status = zw_open_file(
+ &hdsolib,
+ OS_SEC_SYNCHRONIZE
+ | OS_FILE_READ_ACCESS
+ | OS_FILE_READ_ATTRIBUTES,
+ &oa,&iosb,
+ OS_FILE_SHARE_READ
+ | OS_FILE_SHARE_WRITE
+ | OS_FILE_SHARE_DELETE,
+ OS_FILE_NON_DIRECTORY_FILE)))
+ return status;
+
+ /* hoppla */
+ status = pe_load_library_impl(
+ baseaddr,hdsolib,
+ buffer,bufsize,
+ sysflags);
+
+ /* all done */
+ zw_close(hdsolib);
+
+ return status;
+}