Ejemplo n.º 1
0
hvm_status ProcessGetNameByPid(hvm_address cr3, hvm_address pid, char *name)
{
  PROCESS_DATA prev, next;
  hvm_status r;

  vmm_memset(&next, 0, sizeof(next));

  r = ProcessGetNextProcess(cr3, NULL, &next);
  while(TRUE) {
    if(r == HVM_STATUS_END_OF_FILE)
      break;
    
    if(r != HVM_STATUS_UNSUCCESSFUL && pid == next.pid) {
#ifdef GUEST_WINDOWS      
      vmm_strncpy(name, next.name, 32);
#elif defined GUEST_LINUX
      vmm_strncpy(name, next.name, TASK_COMM_LEN);
#endif
      return HVM_STATUS_SUCCESS;
    }
    prev = next;
    vmm_memset(next.name, 0, sizeof(next.name));
    r = ProcessGetNextProcess(cr3, &prev, &next);
  }
  return HVM_STATUS_UNSUCCESSFUL;
}
Ejemplo n.º 2
0
void cmdline_parse(const char *cmdline, const cmdline_option_t *options,
                          char vals[][MAX_VALUE_LEN])
{
    const char *p = cmdline;
    int i;

    /* copy default values to vals[] */
    for ( i = 0; options[i].name != NULL; i++ ) {
        vmm_strncpy(vals[i], options[i].def_val, MAX_VALUE_LEN-1);
        vals[i][MAX_VALUE_LEN-1] = '\0';
    }

    if ( p == NULL )
        return;

    /* parse options */
    while ( 1 ) {
        /* skip whitespace */
        while ( isspace(*p) )
            p++;
        if ( *p == '\0' )
            break;

        /* find end of current option */
        const char *opt_start = p;
        const char *opt_end = (const char*)vmm_strchr(opt_start, ' ');
        if ( opt_end == NULL )
            opt_end = opt_start + vmm_strlen(opt_start);
        p = opt_end;

        /* find value part; if no value found, use default and continue */
        const char *val_start = vmm_strchr(opt_start, '=');
        if ( val_start == NULL || val_start > opt_end )
            continue;
        val_start++;

        unsigned int opt_name_size = val_start - opt_start - 1;
        unsigned int copy_size = opt_end - val_start;
        if ( copy_size > MAX_VALUE_LEN - 1 )
            copy_size = MAX_VALUE_LEN - 1;
        if ( opt_name_size == 0 || copy_size == 0 )
            continue;

        /* value found, so copy it */
        for ( i = 0; options[i].name != NULL; i++ ) {
            if ( vmm_strncmp(options[i].name, opt_start, opt_name_size ) == 0 ) {
                vmm_strncpy(vals[i], val_start, copy_size);
                vals[i][copy_size] = '\0'; /* add '\0' to the end of string */
                break;
            }
        }
    }
}
Ejemplo n.º 3
0
hvm_status ProcessGetModuleByAddr(hvm_address cr3, hvm_address addr, char *name)
{
  MODULE_DATA prev, next;
  hvm_status r;
#ifdef GUEST_WINDOWS      
  vmm_memset(&next, 0, sizeof(next));
  vmm_memset(&prev, 0, sizeof(prev));

  r = ProcessGetNextModule(cr3, NULL, &next);
  while(TRUE) {
    if(r == HVM_STATUS_END_OF_FILE)
      break;
    
    if(r != HVM_STATUS_UNSUCCESSFUL && (addr < (hvm_address) ((Bit32u) next.baseaddr + next.sizeofimage) && addr >= next.baseaddr)) {
      vmm_strncpy(name, next.name, 32);
      return HVM_STATUS_SUCCESS;
    }
    prev = next;
    vmm_memset(next.name, 0, sizeof(next.name));
    r = ProcessGetNextModule(cr3, &prev, &next);
  }
  return HVM_STATUS_UNSUCCESSFUL;
#elif defined GUEST_LINUX
  
  r = HVM_STATUS_UNSUCCESSFUL;
#endif

}
Ejemplo n.º 4
0
hvm_bool PagerAddLine(Bit8u *line)
{
  Bit32u len;

  /* Perform some checks */

  /* No more space? */
  if(current_page >= PAGES) return FALSE; 

  /* As we take care of checking this at this very function end, if we arrive
     here it means something is screwed up */
  if(current_line >= OUT_SIZE_Y) return FALSE; 

  len = vmm_strlen(line);
  if(len >= OUT_SIZE_X)
    len = OUT_SIZE_X - 1;
  
  vmm_strncpy(pages[current_page][current_line], line, len);
  current_line++;
  if(current_line >= OUT_SIZE_Y) { 
    /* Flip one page */
    current_line = 0;
    /* The check at the beginning of the function will take care of EOPages */
    current_page++;                
  }
  return TRUE;
}
Ejemplo n.º 5
0
/* This will be called at the end of PagerLoop so that it cleans out on exit */
void PagerReset(void)
{
  Bit32u i, ii, iii;

  /* Leave last shown page on the console */
  for(ii = 0; ii < OUT_SIZE_Y; ii++) {
    vmm_strncpy(out_matrix[ii], pages[current_visible_page][ii], OUT_SIZE_X);
  }

  /* Clear pages */
  for(i = 0; i < PAGES; i++) {
    for(ii = 0; ii < OUT_SIZE_Y; ii++) {
      for(iii = 0; iii < OUT_SIZE_X; iii++)
	/* We use spaces to reset as in gui.c */
	pages[i][ii][iii] = ' ';
    }
  }
  current_page = current_line = current_visible_page = 0;
}