From: John Hodge Date: Sun, 19 Feb 2012 14:31:37 +0000 (+0800) Subject: AcessNative - Fixing a couple of bugs exposed by AxWin X-Git-Tag: rel0.15~760 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=a41f3e5efdf853726d078dc03550de40e9d63bdd;p=tpg%2Facess2.git AcessNative - Fixing a couple of bugs exposed by AxWin --- diff --git a/AcessNative/acesskernel_src/syscalls.c b/AcessNative/acesskernel_src/syscalls.c index 7932cca2..a4692776 100644 --- a/AcessNative/acesskernel_src/syscalls.c +++ b/AcessNative/acesskernel_src/syscalls.c @@ -177,6 +177,11 @@ SYSCALL1(Syscall_SetGID, "i", int, return Threads_SetGID(a0); ); +SYSCALL0(Syscall_GetTID, return Threads_GetTID()); +SYSCALL0(Syscall_GetPID, return Threads_GetPID()); +SYSCALL0(Syscall_GetUID, return Threads_GetUID()); +SYSCALL0(Syscall_GetGID, return Threads_GetGID()); + SYSCALL1(Syscall_AN_Fork, "d", int *, if(Sizes[0] < sizeof(int)) return -1; @@ -206,6 +211,11 @@ const tSyscallHandler caSyscalls[] = { Syscall_SetUID, Syscall_SetGID, + Syscall_GetTID, + Syscall_GetPID, + Syscall_GetUID, + Syscall_GetGID, + Syscall_Sleep, Syscall_AN_Fork, diff --git a/AcessNative/ld-acess_src/Makefile b/AcessNative/ld-acess_src/Makefile index 7d821321..af7f8c86 100644 --- a/AcessNative/ld-acess_src/Makefile +++ b/AcessNative/ld-acess_src/Makefile @@ -14,6 +14,7 @@ ifeq ($(PLATFORM),win) endif ifeq ($(PLATFORM),lin) BIN := ../ld-acess + LINKADDR := 0x200000 # LD += -m elf_i386 endif @@ -46,7 +47,7 @@ obj-$(PLATFORM)/%.o: %.c obj-lin/link.ld: @mkdir -p $(dir $@) @echo "Making Linker Script ($@)" - $(LD) --verbose | awk '{ if( substr($$0,0,5) == "====="){ bPrint = !bPrint; } else { if(bPrint){ print $$0;} } }' | sed 's/\b0x[048][0-9]*\b/0x00200000/g' > $@ + $(LD) --verbose | awk '{ if( substr($$0,0,5) == "====="){ bPrint = !bPrint; } else { if(bPrint){ print $$0;} } }' | sed 's/\b0x[048][0-9]*\b/$(LINKADDR)/g' | sed 's/CONSTANT (MAXPAGESIZE)/0x1000/g' > $@ -include $(DEPFILES) diff --git a/AcessNative/ld-acess_src/binary.c b/AcessNative/ld-acess_src/binary.c index e9408ef9..fa2af0c4 100644 --- a/AcessNative/ld-acess_src/binary.c +++ b/AcessNative/ld-acess_src/binary.c @@ -252,6 +252,7 @@ int Binary_GetSymbol(const char *SymbolName, uintptr_t *Value, size_t *Size) } //printf("Binary_GetSymbol: RETURN 0, not found\n"); + printf("--- ERROR: Unable to find symbol '%s'\n", SymbolName); return 0; } diff --git a/AcessNative/ld-acess_src/exports.c b/AcessNative/ld-acess_src/exports.c index 7131e632..0c87bda6 100644 --- a/AcessNative/ld-acess_src/exports.c +++ b/AcessNative/ld-acess_src/exports.c @@ -112,17 +112,24 @@ int acess_readdir(int fd, char *dest) { return _Syscall(SYS_READDIR, ">i i ?d ?d ?d >d", nfds, + DEBUG("_SysSelect(%i, %p, %p, %p, %p, 0x%x)", nfds, read, write, error, timeout, events); + return _Syscall(SYS_SELECT, ">i ?d ?d ?d >d >i", nfds, read ? (nfds+7)/8 : 0, read, write ? (nfds+7)/8 : 0, write, error ? (nfds+7)/8 : 0, error, - sizeof(*timeout), timeout + sizeof(*timeout), timeout, + events ); } +int acess_select(int nfds, fd_set *read, fd_set *write, fd_set *error, time_t *timeout) +{ + return acess__SysSelect(nfds, read, write, error, timeout, 0); +} + + int acess__SysOpenChild(int fd, char *name, int flags) { return _Syscall(SYS_OPENCHILD, ">i >s >i", fd, name, flags); } @@ -236,15 +243,12 @@ int acess_waittid(int TID, int *ExitStatus) return _Syscall(SYS_WAITTID, ">i i", ID); -} - -int acess_setgid(int ID) -{ - return _Syscall(SYS_SETGID, ">i", ID); -} +int acess_setuid(int ID) { return _Syscall(SYS_SETUID, ">i", ID); } +int acess_setgid(int ID) { return _Syscall(SYS_SETGID, ">i", ID); } +int acess_gettid(void) { return _Syscall(SYS_GETTID, ""); } +int acess_getpid(void) { return _Syscall(SYS_GETPID, ""); } +int acess_getuid(void) { return _Syscall(SYS_GETUID, ""); } +int acess_getgid(void) { return _Syscall(SYS_GETGID, ""); } int acess_SysSendMessage(int DestTID, int Length, void *Data) { @@ -301,6 +305,7 @@ const tSym caBuiltinSymbols[] = { DEFSYM(_SysOpenChild), DEFSYM(_SysGetACL), DEFSYM(_SysMount), + DEFSYM(_SysSelect), DEFSYM(clone), DEFSYM(execve), @@ -309,6 +314,7 @@ const tSym caBuiltinSymbols[] = { DEFSYM(waittid), DEFSYM(setuid), DEFSYM(setgid), + DEFSYM(gettid), DEFSYM(SysSendMessage), DEFSYM(SysGetMessage), diff --git a/AcessNative/ld-acess_src/main.c b/AcessNative/ld-acess_src/main.c index ae130219..80c5b7ad 100644 --- a/AcessNative/ld-acess_src/main.c +++ b/AcessNative/ld-acess_src/main.c @@ -83,7 +83,7 @@ int main(int argc, char *argv[], char **envp) if( !base ) return 127; printf("==============================\n"); - printf("[DEBUG %i] %i %p ", giSyscall_ClientID, appArgc, appArgv); + printf("[DEBUG %i] %i ", giSyscall_ClientID, appArgc); for(i = 0; i < appArgc; i ++) printf("\"%s\" ", appArgv[i]); printf("\n"); diff --git a/AcessNative/ld-acess_src/memory.c b/AcessNative/ld-acess_src/memory.c index 072d3266..872cb2cf 100644 --- a/AcessNative/ld-acess_src/memory.c +++ b/AcessNative/ld-acess_src/memory.c @@ -27,10 +27,14 @@ int AllocateMemory(uintptr_t VirtAddr, size_t ByteCount) return -1; } #else + printf("AllocateMemory: mmap(%p, %lx, ...)\n", (void*)base, ByteCount); tmp = mmap((void*)base, size, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0); if( tmp == MAP_FAILED ) { + printf("ERROR: Unable to allocate memory\n"); + perror("AllocateMemory"); return -1; } + printf("AllocateMemory: RETURN 0\n"); #endif return 0; } diff --git a/AcessNative/syscalls.h b/AcessNative/syscalls.h index 0adb51f0..3c7bd85d 100644 --- a/AcessNative/syscalls.h +++ b/AcessNative/syscalls.h @@ -52,7 +52,12 @@ enum eSyscalls { SYS_WAITTID, SYS_SETUID, SYS_SETGID, - + + SYS_GETTID, + SYS_GETPID, + SYS_GETUID, + SYS_GETGID, + // IPC SYS_SLEEP, SYS_AN_FORK, @@ -88,6 +93,11 @@ static const char * casSYSCALL_NAMES[] = { "SYS_SETUID", "SYS_SETGID", + "SYS_GETTID", + "SYS_GETPID", + "SYS_GETUID", + "SYS_GETGID", + // IPC "SYS_SLEEP", "SYS_AN_FORK",