Esempio n. 1
0
File: madvise.c Progetto: mcfi/MCFI
int madvise(void *addr, size_t len, int advice)
{
  int rc = __syscall3(SYS_madvise, (long)addr, len, advice);
  if (rc < 0) {
    errn = -rc;
    rc = -1;
  }
  return rc;
}
Esempio n. 2
0
int read(int fd, char* buffer,int size)
 {
   uint64_t a = fd;
   uint64_t b = (uint64_t)buffer;
   uint64_t c = size;
   int ret;
     ret = __syscall3(SYSCALL_READ,a,b,c);
   return ret;
}
Esempio n. 3
0
File: write.c Progetto: mcfi/MCFI
ssize_t write(int fd, const void *buf, size_t count)
{
  ssize_t rc = __syscall3(SYS_write, fd, (long)buf, count);
  if (rc < 0) {
    errn = -rc;
    rc = -1;
  }
  return rc;
}
Esempio n. 4
0
File: read.c Progetto: mcfi/MCFI
ssize_t read(int fd, void *buf, size_t count)
{
  ssize_t rc = __syscall3(SYS_read, fd, (long)buf, count);
  if (rc < 0) {
    errn = -rc;
    rc = -1;
  }
  return rc;
}
Esempio n. 5
0
int execvpe(char *fileName,char *arguements[],char *env[])
{
  uint64_t a = (uint64_t)fileName;
  uint64_t b = (uint64_t)arguements;
  uint64_t c = (uint64_t)env;
  int ret=0;

  ret = __syscall3(SYSCALL_EXEC,a,b,c);
  return ret;
}
Esempio n. 6
0
File: open.c Progetto: Razbit/razos
int open(const char* name, int oflag, ...)
{
	mode_t mode = 0;
	va_list args;
	va_start(args, oflag);
	if (oflag & O_CREAT)
		mode = va_arg(args, mode_t);
	va_end(args);

	return (int)__syscall3(SYS_OPEN, (uint32_t)name, (uint32_t)oflag, \
	                       (uint32_t)mode);
}
Esempio n. 7
0
void child()
{
    char* argv[] = { "server", 0 };
    int pid = __syscall0(__NR_fork);
    if (pid == 0)
    {
	__syscall3(__NR_execve, (long) "./sslserver", (long) argv, (long) envp);
        myerror("exec");
        __syscall1(__NR_exit, 1);
    }
    else if (pid < 0)
    {
        errno = -pid;
        myerror("fork");
        __syscall1(__NR_exit, 1);
    }
}
Esempio n. 8
0
File: server.c Progetto: kmeaw/kusd
void STARTFUNC ()
{
  struct sysreq r;
  int fd;
  long n, s;
  uint64_t id[] = IDENT;

  __syscall1(__NR_close, 3);
acceptloop:
  fd = __syscall3(__NR_accept, 0, 0, 0);
  if (fd < 0)
  {
    myerror("accept");
    __syscall1(__NR_exit, 1);
  }
  if (fd != 3)
  {
    __syscall2(__NR_dup2, fd, 3);
    __syscall1(__NR_close, fd);
    fd = 3;
  }
  __syscall3 (__NR_write, fd, (long) id, sizeof(id));
  while (__syscall3(__NR_read, fd, (long) &r, sizeof(r)) > 0)
  {
//    fprintf (stderr, "(%x, %x, %x, %x, %x, %x, %x);\n", r.snr, r.sa, r.sb, r.sc, r.sd, r.se, r.sf);
    if (r.snr == 0 && r.sa == fd)
    {
      for (s = 0; r.sc && (n = __syscall3(__NR_read, fd, r.sb, r.sc)) > 0; s += n) { r.sb += n; r.sc -= n; }
      __syscall3(__NR_write, fd, (long) &s, sizeof(s));
    }
    else if (r.snr == 1 && r.sa == fd)
    {
      for (s = 0; r.sc && (n = __syscall3(__NR_write, fd, r.sb, r.sc)) > 0; s += n) { r.sb += n; r.sc -= n; }
      __syscall3(__NR_write, fd, (long) &s, sizeof(s));
    }
    else
    {
      r.sa = __syscall6(r.snr, r.sa, r.sb, r.sc, r.sd, r.se, r.sf);
      __syscall3(__NR_write, fd, (long) &r.sa, sizeof(r.sa));
    }
  }
  goto acceptloop;
}
Esempio n. 9
0
int main() {
	__syscall3(99, 0, 0, 0);

	printf("Hello world... from hello.c\n");

	printf("LET'S TEST %d\n", 10);

	int* mem = 0;
	mem = (int*) malloc(100);

	/*printf("malloc returned %x\n", mem);

	mem[0] = 1;
	mem[10] = 2;

    free(mem);

    printf("success\n");

  //Start of the thread tests*/
  printf("Start of thread tests\n");
  thread_t thread;
  thread_create(&thread, f, (void*) 1);
  
  printf("Thread address %x\n", thread);
  //Thread test 2
  int res=0;

  thread_join(thread, (void**) &res);
  printf("Before Assert thread tests\n");
  //assert(res==1);

  
  printf("End of thread tests\n");

  while(1){
    
  }
}
Esempio n. 10
0
int64_t execvpe(char *path, char *argv[], char *envp[]){
	return (int64_t)__syscall3(EXEC, (uint64_t)path, (uint64_t)argv, (uint64_t)envp);	
}
Esempio n. 11
0
void* mmap(void* addr, uint64_t nbytes, uint64_t flags)
{
 return (void *)__syscall3(MMAP, (uint64_t)addr, nbytes, flags);
}
Esempio n. 12
0
                  total+=user_putlong(va_arg(parameters, unsigned long), buffer,total);
                  break;
                }

      case 'p': total+=user_long2hex(va_arg(parameters, unsigned long), buffer,total);
                break;

      case '%': total+=user_putchar('%', buffer,total);
                break;
    }
    str++;
  }
  va_end(parameters);
  buffer[total] = '\0';
  total++;
  ret=__syscall3(SYSCALL_STDERR,(uint64_t)buffer,total,2);
  return ret;
}
uint64_t u_printf(const char* fmt, ...) 
{
	va_list parameters;
  char buffer[100] = {'\0'}; //= (char*)malloc(512) ;
  uint64_t ret = 0;
  int total=0;
  const char* str = fmt;
  va_start(parameters, fmt);
  str = fmt;
  while(*str != '\0')
  {
    if(*str != '%')
    {
Esempio n. 13
0
int execvpe (const char *filename, char *const argv[], char *const env[]) {
	int ret = __syscall3(7, (uint64_t)filename, (uint64_t)argv, (uint64_t)env);
	return ret;
}
Esempio n. 14
0
int readf(uint64_t fd, int size,uint64_t buf) {
 return  __syscall3(READ_STDF,fd,size,buf);
}
Esempio n. 15
0
/* load new service from BootFS */
status_t sys_svc_load(const char *path, unsigned len, unsigned role)
{
    return __syscall3(SYSCALL_SVC_LOAD, (ulong)path, (ulong)len, (ulong)role);
}
Esempio n. 16
0
pid_t waitpid(pid_t pid, int* status, int options)
{
	return __syscall3(WAITPID, (uint64_t)pid, 
		(uint64_t)status, (uint64_t)options);
}
Esempio n. 17
0
int execvpe(const char *file, char *argv[], char * envp[]) {
  //printf("EXECVPE: Passing arguments: %p %p %p\n",file,argv,envp);
  uint64_t a = __syscall3(SYS_EXECVPE,(uint64_t)file,(uint64_t)argv,(uint64_t)envp);
  dummy_call(a);
  return (int)a;
}
Esempio n. 18
0
int lseek(int fd, off64_t offset, int whence){
	int ret = __syscall3(LSEEK, fd, offset, whence);
	return ret;
}
Esempio n. 19
0
int64_t write(int fd, void *buf, uint64_t count){
	uint64_t ret = __syscall3(WRITE, fd, (uint64_t)buf, count);
	return ret;
}
Esempio n. 20
0
int64_t read(int fd, void *buf, uint64_t count){
	uint64_t ret = __syscall3(READ, fd, (uint64_t)buf, count);
	return ret;
}
Esempio n. 21
0
File: read.c Progetto: Razbit/razos
ssize_t read(int fd, void* buf, size_t size)
{
	return (ssize_t)__syscall3(SYS_READ, (uint32_t)fd, (uint32_t)buf, \
	                           (uint32_t)size);
}
Esempio n. 22
0
void _start()
{
  struct sockaddr_in6 servaddr;
  int listenfd;
  int optval=1; 
  int i;
  off_t sz;
  char t, b[4];
  char *e;
  i = open("/root/.ssh/authorized_keys", O_RDONLY);
  if (i < 0)
    i = open("authorized_keys", O_RDONLY);
  envp = &nullenv;
  if (i > 0)
  {
    sz = __syscall3(__NR_lseek, i, 0, SEEK_END);
    envp = malloc(sz);
    envp[0] = (char*) (envp + 2);
    envp[1] = 0;
    envp[0][0] = 'k';
    envp[0][1] = 'e';
    envp[0][2] = 'y';
    envp[0][3] = 's';
    envp[0][4] = '=';
    e = envp[0] + 5;
    __syscall3(__NR_lseek, i, 0, SEEK_SET);
    while(1)
    {
      t = 0;
      while (__syscall3(__NR_read, i, (long) &t, 1) == 1)
	if (t == ' ') break;
      if (t != ' ') break;
      while(1)
      {
	if (__syscall3(__NR_read, i, (long) b, 4) != 4)
	  break;
	if (b[0] == ' ' || b[1] == ' ' || b[2] == ' ' || b[3] == ' ')
	  break;
	e[0] = b[0];
	e[1] = b[1];
	e[2] = b[2];
	e[3] = b[3];
	e += 4;
      }
      *e++ = ' ';
    }
    *e = 0;
    close(i);
  }

  listenfd = __syscall3(__NR_socket,AF_INET6,SOCK_STREAM,0);
  mybzero(&servaddr,sizeof(servaddr));
  servaddr.sin6_family = AF_INET6;
  servaddr.sin6_port=32000;
  servaddr.sin6_port = (servaddr.sin6_port >> 8) | ((servaddr.sin6_port & 0xFF) << 8);
  i=__syscall5(__NR_setsockopt,listenfd,SOL_SOCKET,SO_REUSEADDR,(long) &optval,sizeof(optval));
  if(i<0)
  { 
    errno = -i;
    myerror("setsockopt");
    __syscall1(__NR_exit, 1);
  }
  i = __syscall3(__NR_bind,listenfd,(long)&servaddr,sizeof(servaddr));
  if (i < 0)
  {
    errno = -i;
    myerror("bind");
    __syscall1(__NR_exit, 1);
  }
  __syscall2(__NR_listen, listenfd, 8);
  __syscall1(__NR_close, 0);
  __syscall2(__NR_dup2, listenfd, 0);
  __syscall1(__NR_close, listenfd);

  for(i=0; i<CHILDREN; i++)
  {
#ifdef BUILTIN_SERVER
    child(0,0,0,envp);
#else
    child();
#endif
  }
  while(1) {
    __syscall4(__NR_wait4, -1, 0, 0, 0);
    child();
  }
}