X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=AcessNative%2Flibacess-native.so_src%2Fexports.c;h=0f71f2121b76de0fc2871a0998f2eb653165ae04;hb=feb0895318d823867b858ec841589ca3ab81f510;hp=b761e61a7ed6270f588b74f87c62c8a374b21689;hpb=edbf6589036993a821a4d2f04af62af8f87a3289;p=tpg%2Facess2.git diff --git a/AcessNative/libacess-native.so_src/exports.c b/AcessNative/libacess-native.so_src/exports.c index b761e61a..0f71f212 100644 --- a/AcessNative/libacess-native.so_src/exports.c +++ b/AcessNative/libacess-native.so_src/exports.c @@ -1,2 +1,58 @@ +#include "common.h" +#define acess__SysSpawn _disabled_acess__SysSpawn #include "../ld-acess_src/exports.c" + +void *_crt0_exit_handler; + +int *libc_geterrno(void) +{ + return &acess__errno; +} + +void _ZN4_sys5debugEPKcz(const char *fmt, ...) __attribute__((alias("acess__SysDebug"))); + +#undef acess__SysSpawn + +int acess__SysSpawn(const char *binary, const char **argv, const char **envp, int nfd, int fds[], struct s_sys_spawninfo *info) +{ + int argc = 0; + while( argv[argc++] ) + ; + + Debug("_SysSpawn('%s', %p (%i), %p, %i, %p, %p)", + binary, argv, argc, envp, nfd, fds, info); + + char realpath[256]; + realpath[255] = 0; + + if( _Syscall(SYS_AN_GETPATH, "s", sizeof(realpath)-1, realpath, binary) <= 0 ) { + Warning("No translation for path '%s'", binary); + acess__errno = -11; + return -1; + } + + Warning("TODO: Spawn '%s' = '%s'", binary, realpath); + + int emulated_tid; + int newID = _Syscall(SYS_AN_SPAWN, "d >d", + sizeof(emulated_tid), &emulated_tid, + nfd*sizeof(int), fds, + (info ? sizeof(*info) : 0), info + ); + + if( newID <= 0 ) { + return -1; + } + + if( acessnative_spawn(realpath, newID, argv, envp) ) { + } + + return emulated_tid; +} + +void ldacess_DumpLoadedLibraries(void) +{ + Debug("ldacess_DumpLoadedLibraries"); +} +