From edbf6589036993a821a4d2f04af62af8f87a3289 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Wed, 6 Mar 2013 11:15:55 +0800 Subject: [PATCH] AcessNative - Working on libacess-native --- AcessNative/ld-acess_src/exports.c | 59 ++++++++++++++++++- .../Makefile | 4 +- .../exports.c | 1 + .../main.c | 0 .../memory.c | 0 .../request.c | 0 .../syscalls.c | 0 AcessNative/symbol_renames.ld | 42 +++++++++++++ 8 files changed, 103 insertions(+), 3 deletions(-) rename AcessNative/{ld-acess.so_src => libacess-native.so_src}/Makefile (92%) rename AcessNative/{ld-acess.so_src => libacess-native.so_src}/exports.c (97%) rename AcessNative/{ld-acess.so_src => libacess-native.so_src}/main.c (100%) rename AcessNative/{ld-acess.so_src => libacess-native.so_src}/memory.c (100%) rename AcessNative/{ld-acess.so_src => libacess-native.so_src}/request.c (100%) rename AcessNative/{ld-acess.so_src => libacess-native.so_src}/syscalls.c (100%) create mode 100644 AcessNative/symbol_renames.ld diff --git a/AcessNative/ld-acess_src/exports.c b/AcessNative/ld-acess_src/exports.c index dcfc526a..a5196b5f 100644 --- a/AcessNative/ld-acess_src/exports.c +++ b/AcessNative/ld-acess_src/exports.c @@ -140,6 +140,11 @@ int acess__SysSelect(int nfds, fd_set *read, fd_set *write, fd_set *error, int64 events ); } +int acess__SysUnlink(const char *pathname) +{ + // TODO: + return 0; +} int acess__SysOpenChild(int fd, char *name, int flags) { DEBUG("_SysOpenChild(0x%x, '%s', 0x%x)", fd, name, flags); @@ -163,7 +168,51 @@ int acess__SysSetFaultHandler(int (*Handler)(int)) { return 0; } +void acess__SysSetName(const char *Name) +{ + // TODO: +} + +int acess__SysGetName(char *NameDest) +{ + // TODO: + return 0; +} + +int acess__SysSetPri(int Priority) +{ + // TODO: + return 0; +} + +// --- Binaries? --- +void *acess_SysLoadBin(const char *path, void **entry) +{ + // ERROR! + return NULL; +} + +int acess__SysUnloadBin(void *base) +{ + // ERROR! + return -1; +} + +// --- Timekeeping --- +int64_t acess_SysTimestamp(void) +{ + // TODO: Better impl +// return now()*1000; + return 0; +} + // --- Memory Management --- +uint64_t acess__SysGetPhys(uintptr_t vaddr) +{ + // TODO: + return 0; +} + uint64_t acess__SysAllocate(uintptr_t vaddr) { if( AllocateMemory(vaddr, 0x1000) == -1 ) // Allocate a page @@ -209,6 +258,12 @@ int acess__SysClone(int flags, void *stack) #endif } +int acess__SysKill(int pid, int sig) +{ + // TODO: Impliment SysKill + return -1; +} + int acess__SysExecVE(char *path, char **argv, const char **envp) { int i, argc; @@ -355,7 +410,9 @@ uint32_t acess__SysSetMemFlags(uintptr_t vaddr, uint32_t flags, uint32_t mask) // === Symbol List === -#define DEFSYM(name) {#name, &acess_##name} +#ifndef DEFSYM +# define DEFSYM(name) {#name, &acess_##name} +#endif const tSym caBuiltinSymbols[] = { DEFSYM(_exit), diff --git a/AcessNative/ld-acess.so_src/Makefile b/AcessNative/libacess-native.so_src/Makefile similarity index 92% rename from AcessNative/ld-acess.so_src/Makefile rename to AcessNative/libacess-native.so_src/Makefile index 661e6749..0b9bc20f 100644 --- a/AcessNative/ld-acess.so_src/Makefile +++ b/AcessNative/libacess-native.so_src/Makefile @@ -9,11 +9,11 @@ OBJ := main.o syscalls.o request.o memory.o exports.o OBJ := $(addprefix obj-$(PLATFORM)/,$(OBJ)) ifeq ($(PLATFORM),win) - BIN := ../ld-acess.dll + BIN := ../libacess-native.dll LDFLAGS += -lws2_32 endif ifeq ($(PLATFORM),lin) - BIN := ../ld-acess.so + BIN := ../libacess-native.so endif CFLAGS += -Wall diff --git a/AcessNative/ld-acess.so_src/exports.c b/AcessNative/libacess-native.so_src/exports.c similarity index 97% rename from AcessNative/ld-acess.so_src/exports.c rename to AcessNative/libacess-native.so_src/exports.c index cf38b5bc..b761e61a 100644 --- a/AcessNative/ld-acess.so_src/exports.c +++ b/AcessNative/libacess-native.so_src/exports.c @@ -1 +1,2 @@ + #include "../ld-acess_src/exports.c" diff --git a/AcessNative/ld-acess.so_src/main.c b/AcessNative/libacess-native.so_src/main.c similarity index 100% rename from AcessNative/ld-acess.so_src/main.c rename to AcessNative/libacess-native.so_src/main.c diff --git a/AcessNative/ld-acess.so_src/memory.c b/AcessNative/libacess-native.so_src/memory.c similarity index 100% rename from AcessNative/ld-acess.so_src/memory.c rename to AcessNative/libacess-native.so_src/memory.c diff --git a/AcessNative/ld-acess.so_src/request.c b/AcessNative/libacess-native.so_src/request.c similarity index 100% rename from AcessNative/ld-acess.so_src/request.c rename to AcessNative/libacess-native.so_src/request.c diff --git a/AcessNative/ld-acess.so_src/syscalls.c b/AcessNative/libacess-native.so_src/syscalls.c similarity index 100% rename from AcessNative/ld-acess.so_src/syscalls.c rename to AcessNative/libacess-native.so_src/syscalls.c diff --git a/AcessNative/symbol_renames.ld b/AcessNative/symbol_renames.ld new file mode 100644 index 00000000..eb7377d5 --- /dev/null +++ b/AcessNative/symbol_renames.ld @@ -0,0 +1,42 @@ +_exit = acess__exit; +_SysClone = acess__SysClone; +_SysKill = acess__SysKill; +_SysWaitEvent = acess__SysWaitEvent; +_SysWaitTID = acess__SysWaitTID; +gettid = acess_gettid; +getpid = acess_getpid; +getuid = acess_getuid; +getgid = acess_getgid; +setuid = acess_setuid; +setgid = acess_setgid; +_SysSetName = acess__SysSetName; +_SysGetName = acess__SysGetName; +SysTimestamp = acess_SysTimestamp; +_SysSetPri = acess__SysSetPri; +_SysSendMessage = acess__SysSendMessage; +_SysGetMessage = acess__SysGetMessage; +_SysSpawn = acess__SysSpawn; +_SysExecVE = acess__SysExecVE; +SysLoadBin = acess_SysLoadBin; +_SysUnloadBin = acess__SysUnloadBin; +_SysSetFaultHandler = acess__SysSetFaultHandler; +_SysDebug = acess__SysDebug; +_SysGetPhys = acess__SysGetPhys; +_SysAllocate = acess__SysAllocate; +_SysSetMemFlags = acess__SysSetMemFlags; +_SysOpen = acess__SysOpen; +_SysOpenChild = acess__SysOpenChild; +_SysReopen = acess__SysReopen; +_SysClose = acess__SysClose; +_SysRead = acess__SysRead; +_SysWrite = acess__SysWrite; +_SysSeek = acess__SysSeek; +_SysTell = acess__SysTell; +_SysFInfo = acess__SysFInfo; +_SysReadDir = acess__SysReadDir; +_SysGetACL = acess__SysGetACL; +_SysChdir = acess__SysChdir; +_SysIOCtl = acess__SysIOCtl; +_SysMount = acess__SysMount; +_SysSelect = acess__SysSelect; +_SysUnlink = acess__SysUnlink; -- 2.20.1