* Acess v0.1\r
* ELF Executable Loader Code\r
*/\r
-#define DEBUG 0\r
+#define DEBUG 1\r
#include <stdlib.h>\r
#include <stdio.h>\r
#include <string.h>\r
\r
hdr->entrypoint += iBaseDiff;\r
\r
+ hdr->misc.SymTable = 0;\r
+ hdr->misc.HashTable = 0;\r
+ \r
// === Get Symbol table and String Table ===\r
for( j = 0; dynamicTab[j].d_tag != DT_NULL; j++)\r
{\r
break;\r
}\r
}\r
+ \r
+ LOG("hdr->misc.SymTable = %x, hdr->misc.HashTable = %x",\r
+ hdr->misc.SymTable, hdr->misc.HashTable);\r
\r
\r
// Alter Symbols to true base\r
pBuckets = PTR(hdr->misc.HashTable);\r
symtab = PTR(hdr->misc.SymTable);\r
\r
+ if(!pBuckets || !symtab)\r
+ return 0;\r
+ \r
nbuckets = pBuckets[0];\r
iSymCount = pBuckets[1];\r
pBuckets = &pBuckets[2];\r
/*
*/
+#define DEBUG 0
+
+
+#if DEBUG
+# define DEBUG_S printf
+#else
+# define DEBUG_S(...)
+# define DONT_INCLUDE_SYSCALL_NAMES
+#endif
+
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
{
int i;
char *data = (char*)&Request->Params[Request->NParams];
- printf("Request #%i (%s) -", Request->CallID, casSYSCALL_NAMES[Request->CallID]);
+ DEBUG_S("Request #%i (%s) -", Request->CallID, casSYSCALL_NAMES[Request->CallID]);
for( i = 0; i < Request->NParams; i ++ )
{
switch(Request->Params[i].Type)
{
case ARG_TYPE_INT32:
- printf(" 0x%08x", *(uint32_t*)data);
+ DEBUG_S(" 0x%08x", *(uint32_t*)data);
data += sizeof(uint32_t);
break;
case ARG_TYPE_INT64:
- printf(" 0x%016llx", *(uint64_t*)data);
+ DEBUG_S(" 0x%016llx", *(uint64_t*)data);
data += sizeof(uint64_t);
break;
case ARG_TYPE_STRING:
- printf(" '%s'", (char*)data);
+ DEBUG_S(" '%s'", (char*)data);
data += Request->Params[i].Length;
break;
case ARG_TYPE_DATA:
- printf(" %p:0x%x", (char*)data, Request->Params[i].Length);
+ DEBUG_S(" %p:0x%x", (char*)data, Request->Params[i].Length);
if( !(Request->Params[i].Flags & ARG_FLAG_ZEROED) )
data += Request->Params[i].Length;
break;
}
}
- printf("\n");
+ DEBUG_S("\n");
}
// Send it off
exit(-1);
}
- printf("%i bytes read from socket\n", ret);
+ DEBUG_S("%i bytes read from socket\n", ret);
return ret;
}
free( req );
free( retPtrs );
- printf("Return %llx\n", retValue);
+ DEBUG(": %llx\n", retValue);
return retValue;
}
if(!gaSyscall_LocalFPs[ret]) return -1;
return ret|NATIVE_FILE_MASK;
}
- DEBUG("open(\"%s\", 0x%x)\n", Path, Flags);
+ DEBUG("open(\"%s\", 0x%x)", Path, Flags);
return _Syscall(SYS_OPEN, ">s >i", Path, Flags);
}
gaSyscall_LocalFPs[FD & (NATIVE_FILE_MASK-1)] = NULL;
return ;
}
- DEBUG("close(%i)\n", FD);
+ DEBUG("close(%i)", FD);
_Syscall(SYS_CLOSE, ">i", FD);
}
int acess_reopen(int FD, const char *Path, int Flags) {
- DEBUG("reopen(0x%x, \"%s\", 0x%x)\n", FD, Path, Flags);
+ DEBUG("reopen(0x%x, \"%s\", 0x%x)", FD, Path, Flags);
return _Syscall(SYS_REOPEN, ">i >s >i", FD, Path, Flags);
}
size_t acess_read(int FD, size_t Bytes, void *Dest) {
if(FD & NATIVE_FILE_MASK)
return fread( Dest, Bytes, 1, gaSyscall_LocalFPs[FD & (NATIVE_FILE_MASK-1)] );
- DEBUG("read(0x%x, 0x%x, *%p)\n", FD, Bytes, Dest);
+ DEBUG("read(0x%x, 0x%x, *%p)", FD, Bytes, Dest);
return _Syscall(SYS_READ, ">i >i <d", FD, Bytes, Bytes, Dest);
}
size_t acess_write(int FD, size_t Bytes, void *Src) {
if(FD & NATIVE_FILE_MASK)
return fwrite( Src, Bytes, 1, gaSyscall_LocalFPs[FD & (NATIVE_FILE_MASK-1)] );
- DEBUG("write(0x%x, 0x%x, %p(\"%.*s\"))\n", FD, Bytes, Src, Bytes, (char*)Src);
+ DEBUG("write(0x%x, 0x%x, %p(\"%.*s\"))", FD, Bytes, Src, Bytes, (char*)Src);
return _Syscall(SYS_WRITE, ">i >i >d", FD, Bytes, Bytes, Src);
}
}
return fseek( gaSyscall_LocalFPs[FD & (NATIVE_FILE_MASK-1)], Ofs, Dir );
}
- DEBUG("seek(0x%x, 0x%llx, %i)\n", FD, Ofs, Dir);
+ DEBUG("seek(0x%x, 0x%llx, %i)", FD, Ofs, Dir);
return _Syscall(SYS_SEEK, ">i >I >i", FD, Ofs, Dir);
}
extern int fork(void);
if(flags & CLONE_VM) {
int ret, newID, kernel_tid=0;
- printf("fork()\n");
+ printf("fork()");
- newID = _Syscall(SYS_FORK, "<i", &kernel_tid);
+ newID = _Syscall(SYS_FORK, "<d", sizeof(int), &kernel_tid);
ret = fork();
if(ret < 0) return ret;
int acess_waittid(int TID, int *ExitStatus)
{
- return _Syscall(SYS_WAITTID, ">i <i", TID, ExitStatus);
+ return _Syscall(SYS_WAITTID, ">i <d", TID, sizeof(int), &ExitStatus);
}
int acess_setuid(int ID)