11 extern int giSyscall_ClientID;
12 extern void acess__exit(int Status);
13 extern void Request_Preinit(void);
16 void CallUser(void *Entry, int argc, char *argv[], char **envp) __attribute__((noreturn));
22 int main(int argc, char *argv[], char **envp)
28 int (*appMain)(int, char *[], char **);
36 // int syscall_handle = -1;
38 for( i = 1; i < argc; i ++ )
40 if(strcmp(argv[i], "--key") == 0) {
41 giSyscall_ClientID = atoi(argv[++i]);
45 if(strcmp(argv[i], "--socket") == 0) {
46 gSocket = atoi(argv[++i]);
50 if(strcmp(argv[i], "--binary") == 0) {
55 if(strcmp(argv[i], "--open") == 0) {
56 if( acess_open(argv[++i], 6) == -1 ) { // Read/Write
57 fprintf(stderr, "Unable to open '%s'\n", argv[i]);
63 if( argv[i][0] != '-' ) break;
68 "Usage: ld-acess <executable> [arguments ...]\n"
70 "--key\t(internal) used to pass the system call handle when run with execve\n"
71 "--binary\tLoad a local binary directly\n"
72 "--open\tOpen a file before executing\n"
83 // printf("Exectutable Path: '%s'\n", appPath);
84 // printf("Executable argc = %i\n", appArgc);
86 base = Binary_Load(appPath, (uintptr_t*)&appMain);
87 printf("[DEBUG %i] base = %p\n", giSyscall_ClientID, base);
88 if( !base ) return 127;
90 printf("==============================\n");
91 printf("[DEBUG %i] %i ", giSyscall_ClientID, appArgc);
92 for(i = 0; i < appArgc; i ++)
93 printf("\"%s\" ", appArgv[i]);
95 printf("[DEBUG %i] appMain = %p\n", giSyscall_ClientID, appMain);
96 // CallUser(appMain, appArgc, appArgv, envp);
97 rv = appMain(appArgc, appArgv, envp);
102 void CallUser(void *Entry, int argc, char *argv[], char **envp)
105 __asm__ __volatile__ (
110 : : "r" (Entry), "r" (argc), "r" (argv), "r" (envp)
117 void Warning(const char *Format, ...)
120 printf("[WARN %i] ", giSyscall_ClientID);
121 va_start(args, Format);
122 vprintf(Format, args);
127 void Notice(const char *Format, ...)
130 printf("[NOTICE %i] ", giSyscall_ClientID);
131 va_start(args, Format);
132 vprintf(Format, args);
137 void Debug(const char *Format, ...)
141 printf("%2i] ", giSyscall_ClientID);
142 va_start(args, Format);
143 vprintf(Format, args);