1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
/***********************************************************/
/* ntux: native translation und extension */
/* Copyright (C) 2016--2018 Z. Gilboa */
/* Released under GPLv2 and GPLv3; see COPYING.NTUX. */
/***********************************************************/
#define PE_LDSO
#include <psxtypes/psxtypes.h>
#include <pemagine/pemagine.h>
#include <ntapi/ntapi.h>
#include <psxscl/psxglue.h>
#include <ntux/ntux.h>
#ifndef NTUX_ALL_STATIC
#ifndef NTUX_STANDALONE
/* framework (rtdata) abi */
static const struct pe_guid __ldsoabi = NT_PROCESS_GUID_RTDATA;
/* loader root-relative name */
static const unsigned short __rrldso[] = {'l','i','b','\\',
'l','i','b','p','s','x','s','c','l',
'.','s','o',0};
/* pty server root-relative name */
static const unsigned short __rrctty[] = {'b','i','n','\\',
'n','t','c','t','t','y',
'.','e','x','e',0};
/* system call layer init context */
static struct __psx_context ctx = {sizeof(ctx),0,0,0,0,0,0,0,0,0,0,0};
/* ldso buffer */
static uintptr_t __attribute__((section(".dsodata")))
__dsodata[65536/sizeof(unsigned long)];
int ntux_entry_routine(
int(*__psx_init_routine)(int *,char ***,char ***,void *),
struct __psx_context * ctx);
void ntux_entry_point(void)
{
int status;
void * hroot;
void * hdsodir;
void * ldsobase;
int (*__psx_init)(
int *,char ***,char ***,
void *);
if ((status = __ldso_load_framework_loader_ex(
&ldsobase,&hroot,&hdsodir,
&__ldsoabi,
0,__rrldso,ntux_main,
__dsodata,sizeof(__dsodata),
PE_LDSO_DEFAULT_EXECUTABLE,
&(unsigned int){0})))
__ldso_terminate_current_process(status);
if (!(__psx_init = __ldso_get_procedure_address(
ldsobase,"__psx_init")))
__ldso_terminate_current_process(NT_STATUS_NOINTERFACE);
ctx.options = __PSXOPT_LDSO;
ctx.ctty = __rrctty;
ctx.refaddr = ntux_entry_point;
ntux_entry_routine(__psx_init,&ctx);
}
#endif
#endif
|