|
|
dab206 |
/*****************************************************************************/
|
|
|
dab206 |
/* pemagination: a (virtual) tour into portable bits and executable bytes */
|
|
|
6dda52 |
/* Copyright (C) 2013--2020 SysDeer Technologies, LLC */
|
|
|
dab206 |
/* Released under GPLv2 and GPLv3; see COPYING.PEMAGINE. */
|
|
|
dab206 |
/*****************************************************************************/
|
|
|
dab206 |
|
|
|
dab206 |
#include <psxtypes/psxtypes.h>
|
|
|
dab206 |
#include <pemagine/pemagine.h>
|
|
|
dab206 |
#include "pe_os.h"
|
|
|
dab206 |
|
|
|
dab206 |
int32_t pe_load_framework_loader_ex(
|
|
|
dab206 |
void ** baseaddr,
|
|
|
dab206 |
void ** hroot,
|
|
|
dab206 |
void ** hdsodir,
|
|
|
dab206 |
const struct pe_guid * abi,
|
|
|
dab206 |
const wchar16_t * basename,
|
|
|
dab206 |
const wchar16_t * rrelname,
|
|
|
dab206 |
void * refaddr,
|
|
|
dab206 |
uintptr_t * buffer,
|
|
|
dab206 |
uint32_t bufsize,
|
|
|
dab206 |
uint32_t flags,
|
|
|
dab206 |
uint32_t * sysflags)
|
|
|
dab206 |
{
|
|
|
dab206 |
int32_t status;
|
|
|
dab206 |
struct pe_framework_runtime_data * rtdata;
|
|
|
dab206 |
struct pe_framework_runtime_data context;
|
|
|
dab206 |
|
|
|
dab206 |
status = pe_get_framework_runtime_data(
|
|
|
dab206 |
&rtdata,
|
|
|
dab206 |
pe_get_peb_command_line(),
|
|
|
dab206 |
abi);
|
|
|
dab206 |
|
|
|
dab206 |
if (status) {
|
|
|
97b12c |
rtdata = &context;
|
|
|
97b12c |
|
|
|
dab206 |
context.hself = 0;
|
|
|
dab206 |
context.hparent = 0;
|
|
|
dab206 |
context.himage = 0;
|
|
|
dab206 |
context.hroot = 0;
|
|
|
dab206 |
context.hdsodir = 0;
|
|
|
dab206 |
context.hloader = 0;
|
|
|
c95b4a |
context.hexec = 0;
|
|
|
c95b4a |
context.hpeer = 0;
|
|
|
dab206 |
context.hcwd = 0;
|
|
|
dab206 |
context.hdrive = 0;
|
|
|
dab206 |
|
|
|
dab206 |
context.abi.data1 = abi->data1;
|
|
|
dab206 |
context.abi.data1 = abi->data2;
|
|
|
dab206 |
context.abi.data1 = abi->data3;
|
|
|
dab206 |
|
|
|
dab206 |
context.abi.data4[0] = abi->data4[0];
|
|
|
dab206 |
context.abi.data4[1] = abi->data4[1];
|
|
|
dab206 |
context.abi.data4[2] = abi->data4[2];
|
|
|
dab206 |
context.abi.data4[3] = abi->data4[3];
|
|
|
dab206 |
context.abi.data4[4] = abi->data4[4];
|
|
|
dab206 |
context.abi.data4[5] = abi->data4[5];
|
|
|
dab206 |
context.abi.data4[6] = abi->data4[6];
|
|
|
dab206 |
context.abi.data4[7] = abi->data4[7];
|
|
|
dab206 |
|
|
|
97b12c |
context.hldrctx[PE_LDSO_CTX_IDX_PREV_LOADER] = 0;
|
|
|
97b12c |
context.hldrctx[PE_LDSO_CTX_IDX_PREV_ROOT] = 0;
|
|
|
97b12c |
|
|
|
97b12c |
if (__SIZEOF_POINTER__ == 8) {
|
|
|
97b12c |
context.hldrctx[PE_LDSO_CTX_IDX_RESERVED_1] = 0;
|
|
|
97b12c |
context.hldrctx[PE_LDSO_CTX_IDX_RESERVED_2] = 0;
|
|
|
97b12c |
}
|
|
|
97b12c |
} else {
|
|
|
97b12c |
rtdata->hldrctx[PE_LDSO_CTX_IDX_PREV_LOADER] = rtdata->hloader;
|
|
|
97b12c |
rtdata->hldrctx[PE_LDSO_CTX_IDX_PREV_ROOT] = rtdata->hroot;
|
|
|
dab206 |
}
|
|
|
dab206 |
|
|
|
dab206 |
if ((status = pe_find_framework_loader(
|
|
|
dab206 |
rtdata,basename,rrelname,refaddr,
|
|
|
dab206 |
buffer,bufsize,flags)))
|
|
|
dab206 |
return status;
|
|
|
dab206 |
|
|
|
dab206 |
if ((status = pe_load_framework_loader(
|
|
|
dab206 |
baseaddr,rtdata,
|
|
|
dab206 |
buffer,bufsize,
|
|
|
dab206 |
sysflags)))
|
|
|
dab206 |
return status;
|
|
|
dab206 |
|
|
|
dab206 |
*hroot = rtdata->hroot;
|
|
|
dab206 |
*hdsodir = rtdata->hdsodir;
|
|
|
dab206 |
|
|
|
dab206 |
return OS_STATUS_SUCCESS;
|
|
|
dab206 |
}
|